forked from Cacti/cacti
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.zoom.js
More file actions
1182 lines (1039 loc) · 50.8 KB
/
jquery.zoom.js
File metadata and controls
1182 lines (1039 loc) · 50.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2022 The Cacti Group |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDtool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/
/* requirements:
jQuery 1.7.x or above
jQuery UI 1.8.x or above
jQuery cookie plugin
*/
(function($){
$.fn.zoom = function(options) {
storage=Storages.localStorage;
/* +++++++++++++++++++++++ Global Variables +++++++++++++++++++++++++ */
// JS calculates in relation to the localization of the client - we have to take care of that, but only for 0.8.8
var clientTime = new Date();
var clientTimeOffset = clientTime.getTimezoneOffset()*60*(-1); //requires -1, because PHP return the opposite
var timeOffset = 0;
var mouseDown = false;
// default values of the different options being offered
var defaults = {
inputfieldStartTime : '', // ID of the input field that contains the start date
inputfieldEndTime : '', // ID of the input field that contains the end date
submitButton : 'button_refresh_x', // ID of the submit button
cookieName : 'cacti_zoom', // default name required for session cookie
serverTimeOffset : 0 // JS calculates in relation to the localization of the browser :/ - only required for 0.8.8
};
// define global variables / objects here
var zoom = {
// 'initiator' is the element that initiates Zoom
initiator: $(this),
// 'image' means the image tag and its properties
image: { top:0, left:0, width:0, height:0 },
// 'graph' stands for the rrdgraph itself excluding legend, graph title etc.
graph: { timespan:0, secondsPerPixel:0 },
// 'box' describes the area in front of the graph within jQueryZoom will allow interaction
box: { top:0, left:0, right:0, width:0, height:0 },
// 'markers' are selectors useable within the advanced mode
marker: { 1 : { placed:false }, 2 : { placed:false} },
// 'custom' holds the local configuration done by the user
custom: {},
// 'options' contains the start input parameters
options: $.extend(defaults, options),
// 'attributes' holds all values that will describe the selected area
attr: { start:'none', end:'none', action:'left2right', location: window.location.href.split('?'), urlPath: ((typeof urlPath == 'undefined') ? '' : urlPath), origin: ((typeof location.origin == 'undefined') ? location.protocol + '//' + location.host : location.origin)}
};
// support jQuery's concatenation
return this.each(function() {
zoom_init( $(this) );
});
/* ++++++++++++++++++++ Universal Functions +++++++++++++++++++++++++ */
/**
* splits off the parameters of a given URL
**/
function getUrlVars(url) {
var parameters = [], name, value;
urlBaseAndParameters = url.split('?');
urlBase = urlBaseAndParameters[0];
urlParameters = urlBaseAndParameters[1].split('&');
parameters['urlBase'] = urlBase;
for (var i=0; i<urlParameters.length; i++) {
parameter = urlParameters[i].split('=');
parameters[parameter[0].replace(/^graph_/, '')] = $.isNumeric(parameter[1]) ? +parameter[1] : parameter[1];
}
return parameters;
}
/**
* transforms an object into a comma separated string of key-value pairs
**/
function serialize(object){
var str = '';
for (var key in object) { str += (key + '=' + object[key] + ','); }
return str.slice(0, -1);
}
/**
* transforms a comma separated string of key-values pairs into an object
* including a change of the value type from string to boolean or numeric if reasonable.
**/
function unserialize(string){
var obj = new Array();
if (string != null) {
pairs = string.split(',');
for (var i=0; i<pairs.length; i++) {
pair = pairs[i].split('=');
if (pair[1] == 'true') {
pair[1] = true;
} else if (pair[1] == 'false') {
pair[1] = false;
} else if ($.isNumeric(pair[1])) {
pair[1] = +pair[1];
}
obj[pair[0]] = pair[1];
}
}
return obj;
}
/**
* converts a Unix time stamp to a formatted date string
**/
function unixTime2Date(unixTime){
var date = new Date(unixTime*1000+timeOffset);
var year = date.getFullYear();
var month = ((date.getMonth()+1) < 9 ) ? '0' + (date.getMonth()+1) : date.getMonth()+1;
var day = (date.getDate() > 9) ? date.getDate() : '0' + date.getDate();
var hours = (date.getHours() > 9) ? date.getHours() : '0' + date.getHours();
var minutes = (date.getMinutes() > 9) ? date.getMinutes() : '0' + date.getMinutes();
var seconds = (date.getSeconds() > 9) ? date.getSeconds() : '0' + date.getSeconds();
var formattedTime = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
return formattedTime;
}
/* +++++++++++++++++++++++ Core Functions +++++++++++++++++++++++++++ */
/* init zoom */
function zoom_init(image) {
var $this = image;
var activeElement = '';
$this.parent().disableSelection();
$this.off().mouseover(
function(){
if($('#zoom-container').length != 0) {
activeElement = $('#zoom-container').attr('data-active-element');
}
if (!activeElement || activeElement !== zoomGetImageId($this)){
zoomElements_remove();
zoomFunction_init($this);
}
}
);
}
function zoomGetElement(zoom) {
var id = '#' + zoom.image.reference;
if (zoom.image.rra_id > 0) {
id += '[rra_id=\'' + zoom.image.rra_id + '\']';
}
return id;
}
function zoomGetImageId(image) {
var id = image.attr('id');
if (image.attr('rra_id') > 0) {
id += '_rra' + image.attr('rra_id');
}
return id;
}
function zoomGetId(zoom) {
var id = zoom.image.reference;
if (zoom.image.rra_id > 0) {
id += '_rra' + zoom.image.rra_id;
}
return id;
}
function zoomFunction_init(image) {
var $this = image;
/* load global settings cached in a cookie if available */
if (storage.isSet(zoom.options.cookieName)) {
zoom.custom = unserialize(storage.get(zoom.options.cookieName));
}
if (zoom.custom.zoomMode == undefined) zoom.custom.zoomMode = 'quick';
if (zoom.custom.zoomOutPositioning == undefined) zoom.custom.zoomOutPositioning = 'center';
if (zoom.custom.zoomOutFactor == undefined) zoom.custom.zoomOutFactor = '2';
if (zoom.custom.zoomTimestamps == undefined) zoom.custom.zoomTimestamps = 'auto';
if (zoom.custom.zoom3rdMouseButton == undefined) zoom.custom.zoom3rdMouseButton = 'zoom_out';
storage.set(zoom.options.cookieName, serialize(zoom.custom));
/* take care of different time zones server and client can make use of */
if (zoom.options.serverTimeOffset > clientTimeOffset ) {
timeOffset = (zoom.options.serverTimeOffset - clientTimeOffset)*1000;
} else {
timeOffset = (clientTimeOffset - zoom.options.serverTimeOffset)*1000*(-1);
}
/* fetch all attributes that rrdgraph provides */
zoom.image.data = atob( zoom.initiator.attr('src').split(',')[1] );
zoom.image.type = (zoom.initiator.attr('src').split(';')[0] == 'data:image/svg+xml' )? 'svg' : 'png';
zoom.image.reference = zoom.initiator.attr('id');
zoom.image.id = zoom.image.reference.replace('graph_', '');
zoom.image.rra_id = zoom.initiator.attr('rra_id');
zoom.image.name = 'cacti_' + zoomGetImageId(zoom.initiator)+ '.' + zoom.image.type;
zoom.image.legend = ($('#thumbnails').length != 0 && $('#thumbnails').is(':checked')) ? false : true;
zoom.image.top = parseInt(zoom.initiator.offset().top);
zoom.image.left = parseInt(zoom.initiator.offset().left);
zoom.image.width = parseInt(zoom.initiator.attr('image_width'));
zoom.image.height = parseInt(zoom.initiator.attr('image_height'));
zoom.graph.top = parseInt(zoom.initiator.attr('graph_top'));
zoom.graph.left = parseInt(zoom.initiator.attr('graph_left'));
zoom.graph.width = parseInt(zoom.initiator.attr('graph_width'));
zoom.graph.height = parseInt(zoom.initiator.attr('graph_height'));
zoom.graph.start = parseInt(zoom.initiator.attr('graph_start'));
zoom.graph.end = parseInt(zoom.initiator.attr('graph_end'));
zoom.graph.timespan = zoom.graph.end - zoom.graph.start;
zoom.graph.secondsPerPixel = zoom.graph.timespan/zoom.graph.width;
zoom.box.width = zoom.graph.width + ((zoom.custom.zoomMode === 'quick') ? 0 : 1);
zoom.box.height = zoom.graph.height;
zoom.box.top = zoom.graph.top-1;
zoom.box.bottom = zoom.graph.top + zoom.box.height;
zoom.box.left = zoom.graph.left;
zoom.box.right = zoom.box.left + zoom.box.width;
//console.log('BoxTop: ' + zoom.box.top);
//console.log('BoxBottom: ' + zoom.box.bottom);
//console.log('BoxLeft: ' + zoom.box.left);
//console.log('BoxRight: ' + zoom.box.right);
//console.log('ImageTop: ' + zoom.initiator.offset().top);
//console.log('ImageLeft: ' + zoom.initiator.offset().left);
//console.log('GraphTop: ' + zoom.initiator.attr('graph_top'));
//console.log('GraphLeft: ' + zoom.initiator.attr('graph_left'));
// get all graph parameters and merge results with zoom.graph object
// $.extend(zoom.graph, getUrlVars( $this.attr("src") ));
// add all additional HTML elements to the DOM if necessary and register
// the individual events needed. Once added we will only reset
// and reposition these elements.
// add the container for all elements Zoom requires
if ($('#zoom-container').length === 0) {
// Please note: IE does not fire hover or click behaviors on completely transparent elements.
// Use a background color and set opacity to 1% as a workaround.(see CSS file)
$('<div id="zoom-container" data-active-element=""></div>').appendTo('body').delay(1000);
$('#zoom-container').css({ position: 'absolute', 'pointer-events': 'none' });
}else {
$('#zoom-container').attr('data-active-element', '');
}
// add a hidden anchor to use for downloads
if ($('#zoom-image').length == 0) {
$('<a class="zoom-hidden" id="zoom-image"></a>').appendTo('body');
}
// add a hidden textareas used to copy images / links
if ($('#zoom-textarea').length == 0) {
$('<textarea id="zoom-textarea" class="zoom-hidden"></textarea>').appendTo('body');
}
// add the 'zoomBox'
if ($('#zoom-box').length == 0) {
// Please note: IE does not fire hover or click behaviors on completely transparent elements.
// Use a background color and set opacity to 1% as a workaround.(see CSS file)
$('<div id="zoom-box"></div>').appendTo('#zoom-container');
}
// add the 'zoomSelectedArea'
if ($('#zoom-area').length == 0) {
$('<div id="zoom-area"></div>').appendTo('#zoom-container');
}
// add two markers for the advanced mode
if ($('#zoom-marker-1').length == 0) {
$('<div id="zoom-excluded-area-1" class="zoom-area-excluded"></div>').appendTo('#zoom-container');
$('<div class="zoom-marker" id="zoom-marker-1"><div class="zoom-marker-arrow-down"></div><div class="zoom-marker-arrow-up"></div></div>').appendTo('#zoom-container');
$('<div id="zoom-marker-tooltip-1" class="zoom-marker-tooltip"><div id="zoom-marker-tooltip-1-arrow-left" class="zoom-marker-tooltip-arrow-left"><div id="zoom-marker-tooltip-1-arrow-left-inner" class="zoom-marker-tooltip-arrow-left-inner"></div></div><span id="zoom-marker-tooltip-value-1" class="zoom-marker-tooltip-value">-</span><div id="zoom-marker-tooltip-1-arrow-right" class="zoom-marker-tooltip-arrow-right"><div id="zoom-marker-tooltip-1-arrow-right-inner" class="zoom-marker-tooltip-arrow-right-inner"></div></div></div>').appendTo('#zoom-container');
}
if ($('#zoom-marker-2').length == 0) {
$('<div id="zoom-excluded-area-2" class="zoom-area-excluded"></div>').appendTo('#zoom-container');
$('<div class="zoom-marker" id="zoom-marker-2"><div class="zoom-marker-arrow-down"></div><div class="zoom-marker-arrow-up"></div></div>').appendTo('#zoom-container');
$('<div id="zoom-marker-tooltip-2" class="zoom-marker-tooltip"><div id="zoom-marker-tooltip-2-arrow-left" class="zoom-marker-tooltip-arrow-left"><div id="zoom-marker-tooltip-1-arrow-left-inner" class="zoom-marker-tooltip-arrow-left-inner"></div></div><span id="zoom-marker-tooltip-value-2" class="zoom-marker-tooltip-value">-</span><div id="zoom-marker-tooltip-2-arrow-right" class="zoom-marker-tooltip-arrow-right"><div id="zoom-marker-tooltip-2-arrow-right-inner" class="zoom-marker-tooltip-arrow-right-inner"></div></div></div>').appendTo('#zoom-container');
}
zoom.marker[1].placed = false;
zoom.marker[2].placed = false;
// add the context (right click) menu
if ($('#zoom-menu').length == 0) {
$('<div id="zoom-menu" class="zoom-menu">'
+ '<div class="first_li">'
+ '<div class="ui-icon ui-icon-zoomin zoomContextMenuAction__zoom_in"></div>'
+ '<span class="zoomContextMenuAction__zoom_in">' + zoom_i18n_zoom_in + '</span>'
+ '</div>'
+ '<div class="first_li">'
+ '<div class="ui-icon ui-icon-zoomout zoomContextMenuAction__zoom_out"></div>'
+ '<div class="ui-icon ui-icon-play ui-icon-right"></div>'
+ '<span class="zoomContextMenuAction__zoom_out">' + zoom_i18n_zoom_out + '</span>'
+ '<div class="inner_li">'
+ '<span class="zoomContextMenuAction__zoom_out__2">' + zoom_i18n_zoom_2 + '</span>'
+ '<span class="zoomContextMenuAction__zoom_out__4">' + zoom_i18n_zoom_4 + '</span>'
+ '<span class="zoomContextMenuAction__zoom_out__8">' + zoom_i18n_zoom_8 + '</span>'
+ '<span class="zoomContextMenuAction__zoom_out__16">' + zoom_i18n_zoom_16 + '</span>'
+ '<span class="zoomContextMenuAction__zoom_out__32">' + zoom_i18n_zoom_32 + '</span>'
+ '</div>'
+ '</div>'
+ '<div class="sep_li"></div>'
+ '<div class="first_li">'
+ '<div class="ui-icon ui-icon-empty"></div>'
+ '<div class="ui-icon ui-icon-play ui-icon-right"></div>'
+ '<span>' + zoom_i18n_mode + '</span>'
+ '<div class="inner_li">'
+ '<span class="zoomContextMenuAction__set_zoomMode__quick">' + zoom_i18n_quick + '</span>'
+ '<span class="zoomContextMenuAction__set_zoomMode__advanced">' + zoom_i18n_advanced + '</span>'
+ '</div>'
+ '</div>'
+ '<div class="sep_li"></div>'
+ '<div class="first_li">'
+ '<div class="ui-icon ui-icon-empty"></div>'
+ '<div class="ui-icon ui-icon-play ui-icon-right"></div>'
+ '<span>' + zoom_i18n_graph + '</span>'
+ '<div class="inner_li">'
+ '<span class="zoomContextMenuAction__newTab">' + zoom_i18n_newTab + '</span>'
+ '<span class="zoomContextMenuAction__save">' + zoom_i18n_save_graph + '</span>'
+ '<span class="zoomContextMenuAction__copy">' + zoom_i18n_copy_graph + '</span>'
+ '<span class="zoomContextMenuAction__link">' + zoom_i18n_copy_graph_link + '</span>'
+ '</div>'
+ '</div>'
+ '<div class="first_li">'
+ '<div class="ui-icon ui-icon-wrench"></div>'
+ '<div class="ui-icon ui-icon-play ui-icon-right"></div>'
+ '<span>' + zoom_i18n_settings + '</span>'
+ '<div class="inner_li">'
+ '<div class="sec_li">'
+ '<div class="ui-icon ui-icon-play ui-icon-right"></div>'
+ '<span>' + zoom_i18n_timestamps + '</span>'
+ '<div class="inner_li">'
+ '<span class="zoomContextMenuAction__set_zoomTimestamps__on">' + zoom_i18n_on + '</span>'
+ '<span class="zoomContextMenuAction__set_zoomTimestamps__auto">' + zoom_i18n_auto + '</span>'
+ '<span class="zoomContextMenuAction__set_zoomTimestamps__off">' + zoom_i18n_off + '</span>'
+ '</div>'
+ '</div>'
+ '<div class="sep_li"></div>'
+ '<div class="sec_li">'
+ '<div class="ui-icon ui-icon-play ui-icon-right"></div>'
+ '<span>' + zoom_i18n_zoom_out_factor + '</span>'
+ '<div class="inner_li">'
+ '<span class="zoomContextMenuAction__set_zoomOutFactor__2">' + zoom_i18n_zoom_2 + '</span>'
+ '<span class="zoomContextMenuAction__set_zoomOutFactor__4">' + zoom_i18n_zoom_4 + '</span>'
+ '<span class="zoomContextMenuAction__set_zoomOutFactor__8">' + zoom_i18n_zoom_8 + '</span>'
+ '<span class="zoomContextMenuAction__set_zoomOutFactor__16">' + zoom_i18n_zoom_16 + '</span>'
+ '<span class="zoomContextMenuAction__set_zoomOutFactor__32">' + zoom_i18n_zoom_32 + '</span>'
+ '</div>'
+ '</div>'
+ '<div class="sec_li">'
+ '<div class="ui-icon ui-icon-play ui-icon-right"></div>'
+ '<span>' + zoom_i18n_zoom_out_positioning + '</span>'
+ '<div class="inner_li">'
+ '<span class="zoomContextMenuAction__set_zoomOutPositioning__begin">' + zoom_i18n_begin + '</span>'
+ '<span class="zoomContextMenuAction__set_zoomOutPositioning__center">' + zoom_i18n_center + '</span>'
+ '<span class="zoomContextMenuAction__set_zoomOutPositioning__end">' + zoom_i18n_end + '</span>'
+ '</div>'
+ '</div>'
+ '<div class="sec_li">'
+ '<div class="ui-icon ui-icon-play ui-icon-right"></div>'
+ '<span>' + zoom_i18n_3rd_button + '</span>'
+ '<div class="inner_li">'
+ '<span class="zoomContextMenuAction__set_zoom3rdMouseButton__zoom_in">' + zoom_i18n_zoom_in + '</span>'
+ '<span class="zoomContextMenuAction__set_zoom3rdMouseButton__zoom_out">' + zoom_i18n_zoom_out + '</span>'
+ '<span class="zoomContextMenuAction__set_zoom3rdMouseButton__off">' + zoom_i18n_disabled + '</span>'
+ '</div>'
+ '</div>'
+ '</div>'
+ '</div>'
+ '<div class="sep_li"></div>'
+ '<div class="first_li">'
+ '<div class="ui-icon ui-icon-close zoomContextMenuAction__close"></div>'
+ '<span class="zoomContextMenuAction__close">' + zoom_i18n_close + '</span>'
+ '</div>').appendTo('body');
}
zoomElements_reposition();
zoomElements_reset();
zoomContextMenu_init();
zoomAction_init(image);
}
/**
* reposition all elements of Zoom
**/
function zoomElements_reposition() {
$('#zoom-container').insertBefore(zoomGetElement(zoom));
}
/**
* resets and destroys all elements of Zoom
**/
function zoomElements_remove() {
zoomElements_reset();
$('#zoom-container').find('*').off().remove();
$('#zoom-menu').remove();
}
/**
* resets all elements of Zoom
**/
function zoomElements_reset() {
zoom.attr.start = 'none';
zoom.marker = { 1 : { placed:false }, 2 : { placed:false} };
$('#zoom-container > div[id^="zoom-"]').not('#zoom-menu').each( function () {
$(this).removeAttr('style');
});
$('#zoom-container').off();
$('#zoom-container').bind('contextmenu', function(e) { zoomContextMenu_toggle(e); return false;} );
$('#zoom-box').off();
$('#zoom-box').css({ cursor:'crosshair', width:zoom.box.width + 'px', height:zoom.box.height + 'px', top:zoom.box.top+'px', left:zoom.box.left+'px' });
$('#zoom-box').bind('contextmenu', function(e) { zoomContextMenu_toggle(e); return false;} );
$('#zoom-area').off().css({ top:zoom.graph.top+'px', height:zoom.graph.height+'px' });
$('.zoom-area-excluded').off();
$('.zoom-area-excluded').bind('contextmenu', function(e) { zoomContextMenu_toggle(e); return false;} );
$('.zoom-area-excluded').bind('click', function(e) { zoomContextMenu_hide(); return false;} );
$('.zoom-marker-arrow-up').css({ top:(zoom.box.height-6) + 'px' });
$('.zoom-marker-tooltip-value').disableSelection();
$('#zoom-container > div[id^="zoom-"]').css({ 'pointer-events': 'all' });
}
/*
* registers all the different mouse click event handler
*/
function zoomAction_init(image) {
if (zoom.custom.zoomMode === 'quick') {
zoom.box.width = zoom.graph.width;
$('#zoom-box').css({ width:zoom.box.width + 'px' });
$('#zoom-area').resizable({ containment: '#zoom-box', handles: 'e, w' });
$('#zoom-box').off('mousedown').on('mousedown', function(e) {
switch(e.which) {
/* clicking the left mouse button will initiates a zoom-in */
case 1:
// remember active element
$('#zoom-container').attr('data-active-element', zoomGetImageId(image));
// ensure menu is closed
zoomContextMenu_hide();
// reset the zoom area
zoom.attr.start = e.pageX;
$('#zoom-box').css({ cursor:'e-resize' });
$('#zoom-area').css({ width:'0px', left: zoom.attr.start-zoom.image.left+'px', display:'block' });
break;
}
});
/* register the mouse up event */
$('#zoom-box, #zoom-area').off('mouseup').on('mouseup', function(e) {
switch(e.which) {
/* leaving the left mouse button will execute a zoom in */
case 1:
if (zoom.attr.start != 'none') {
zoomAction_zoom_in();
}
break;
case 2:
/* hide context menu if open */
zoomContextMenu_hide();
if (zoom.custom.zoom3rdMouseButton == 'zoom_in') {
zoomAction_zoom_in();
} else {
zoomAction_zoom_out( zoom.custom.zoomOutFactor );
}
break;
}
});
/* stretch the zoom area in that direction the user moved the mouse pointer.
That is required to get it working faultlessly with Opera, IE and Chrome */
$('#zoom-box, #zoom-area').mousemove( function(e) {
zoomAction_draw(e);
} );
/* capture mouse up/down events for zoom */
$(document).off('mousedown').on('mousedown', function() {
mouseDown = true;
clearTimeout(myRefresh);
}).off('mouseup').on('mouseup', function() {
if (mouseDown) {
if (zoom.attr.start != 'none') {
zoomAction_zoom_in();
}
}
mouseDown = false;
});
/* moving the mouse pointer quickly will avoid that the mousemove event has enough time to actualize the zoom area */
$('#zoom-container').mouseout( function(e) {
zoomAction_draw(e);
} );
} else{
/* welcome to the advanced mode ;) */
zoom.box.width = zoom.graph.width+1;
$('#zoom-box').css({ width:zoom.box.width + 'px' });
$('#zoom-box').off('mousedown').on('mousedown', function(e) {
switch(e.which) {
case 1:
// remember active element
$('#zoom-container').attr('data-active-element', zoomGetImageId(image));
// ensure menu is closed
zoomContextMenu_hide();
/* find out which marker has to be added */
if (zoom.marker[1].placed && zoom.marker[2].placed) {
zoomAction_zoom_in();
return;
} else {
var marker = zoom.marker[1].placed ? 2 : 1;
var secondmarker = (marker == 1) ? 2 : 1;
}
/* select marker */
var $this = $('#zoom-marker-' + marker);
/* place the marker and make it visible */
var pos_relative_left = e.pageX-zoom.image.left;
var pos_relative_top = e.pageY-zoom.image.top;
$this.css({ height:zoom.box.height+'px', top:zoom.box.top+'px', left:pos_relative_left+'px', display:'block' });
zoom.marker[marker].placed = true;
zoom.marker[marker].left = pos_relative_left;
/* place the marker's tooltip, update its value and make it visible if necessary (Setting: 'Always On') */
zoom.marker[marker].unixtime = parseInt(parseInt(zoom.graph.start) + (pos_relative_left - zoom.box.left)*zoom.graph.secondsPerPixel);
$('#zoom-marker-tooltip-value-' + marker).html(
unixTime2Date(zoom.marker[marker].unixtime).replace(' ', '<br>')
);
zoom.marker[marker].width = Math.ceil($('#zoom-marker-tooltip-' + marker).width());
zoom.marker[marker].height = Math.ceil($('#zoom-marker-tooltip-' + marker).height());
$('#zoom-marker-tooltip-' + marker).css({
width: zoom.marker[marker].width +'px',
top: ( (marker == 1) ? zoom.box.top+3 : zoom.box.bottom-zoom.marker[marker].height-3 )+'px',
left:( (marker == 1) ? pos_relative_left - zoom.marker[marker].width : pos_relative_left )+'px'}
);
if (zoom.custom.zoomTimestamps === true) {
$('#zoom-marker-tooltip-' + marker).fadeIn(500);
}
if (e.pageX == $('#zoom-marker-tooltip-' + marker).position().left) {
$('#zoom-marker-tooltip-' + marker + '-arrow-right').css({ visibility:'hidden'});
} else {
$('#zoom-marker-tooltip-' + marker + '-arrow-left').css({ visibility:'hidden'});
}
/* make the excluded areas visible directly in that moment both markers are set */
if (zoom.marker[1].placed && zoom.marker[2].placed) {
zoom.marker.distance = zoom.marker[1].left - zoom.marker[2].left;
$('#zoom-excluded-area-1').css({
position:'absolute',
height:zoom.box.height+'px',
top:zoom.box.top+'px',
left: (zoom.marker.distance > 0) ? zoom.marker[1].left : zoom.box.left,
width: (zoom.marker.distance > 0) ? zoom.box.right - zoom.marker[1].left : zoom.marker[1].left - zoom.box.left,
display:'block'
});
$('#zoom-excluded-area-2').css({
position:'absolute',
height:zoom.box.height+'px',
top:zoom.box.top+'px',
left: (zoom.marker.distance < 0) ? zoom.marker[2].left : zoom.box.left,
width: (zoom.marker.distance < 0) ? zoom.box.right - zoom.marker[2].left : zoom.marker[2].left - zoom.box.left,
display:'block'
});
/* reposition both tooltips */
$('#zoom-marker-tooltip-1').css({ left: $('#zoom-marker-1').position().left - ( (zoom.marker.distance > 0) ? 0 : $('#zoom-marker-tooltip-1').width() ) + 'px' });
$('#zoom-marker-tooltip-1-arrow-left').css({ visibility: (($('#zoom-marker-tooltip-1').position().left < $('#zoom-marker-1').position().left ) ? 'hidden' : 'visible') });
$('#zoom-marker-tooltip-1-arrow-right').css({ visibility: (($('#zoom-marker-tooltip-1').position().left < $('#zoom-marker-1').position().left ) ? 'visible' : 'hidden') });
$('#zoom-marker-tooltip-2').css({ left: $('#zoom-marker-2').position().left - ( (zoom.marker.distance < 0) ? 0 : $('#zoom-marker-tooltip-2').width() ) + 'px' });
$('#zoom-marker-tooltip-2-arrow-left').css({ visibility: (($('#zoom-marker-tooltip-2').position().left < $('#zoom-marker-2').position().left ) ? 'hidden' : 'visible') });
$('#zoom-marker-tooltip-2-arrow-right').css({ visibility: (($('#zoom-marker-tooltip-2').position().left < $('#zoom-marker-2').position().left ) ? 'visible' : 'hidden') });
/* change cursor */
$('#zoom-box').css({cursor: 'pointer'});
}
/* make the marker draggable */
$this.draggable({
containment: '#zoom-box',
axis: 'x',
scroll: false,
start:
function(event, ui) {
if (zoom.custom.zoomTimestamps == 'auto') {
$('.zoom-marker-tooltip').fadeIn(500);
}
},
drag:
function(event, ui) {
if (ui.position['left'] <= zoom.box.left) {
zoom.marker[marker].left = zoom.box.left;
} else if (ui.position['left'] >= zoom.box.right) {
zoom.marker[marker].left = zoom.box.right;
} else {
zoom.marker[marker].left = Math.ceil(parseFloat(ui.position['left']));
}
/* update the timestamp shown in tooltip */
zoom.marker[marker].unixtime = Math.ceil( parseFloat(parseInt(zoom.graph.start) + (zoom.marker[marker].left - zoom.graph.left)*zoom.graph.secondsPerPixel));
$('#zoom-marker-tooltip-value-' + marker).html(
unixTime2Date(zoom.marker[marker].unixtime).replace(' ', '<br>')
);
zoom.marker[marker].width = $('#zoom-marker-tooltip-' + marker).width();
/* update the execludedArea if both markers have been placed */
if (zoom.marker[1].placed && zoom.marker[2].placed) {
zoom.marker.distance = zoom.marker[marker].left - zoom.marker[secondmarker].left;
if ( zoom.marker.distance > 0 ) {
zoom.marker[marker].excludeArea = 'right';
zoom.marker[secondmarker].excludeArea = 'left';
} else {
zoom.marker[marker].excludeArea = 'left';
zoom.marker[secondmarker].excludeArea = 'right';
}
/* in that case we have to update the tooltip of both marker */
$('#zoom-excluded-area-' + marker).css({ left: (zoom.marker.distance > 0) ? zoom.marker[marker].left : zoom.box.left, width: (zoom.marker.distance > 0) ? zoom.box.right - zoom.marker[marker].left : zoom.marker[marker].left - zoom.box.left});
$('#zoom-marker-tooltip-' + marker).css({ left: zoom.marker[marker].left + ( (zoom.marker[marker].excludeArea == 'right') ? (0) : (-zoom.marker[marker].width) ) });
$('#zoom-marker-tooltip-' + marker + '-arrow-left').css({ visibility: ( zoom.marker[marker].excludeArea == 'left' ? 'hidden' : 'visible') });
$('#zoom-marker-tooltip-' + marker + '-arrow-right').css({ visibility: ( zoom.marker[marker].excludeArea == 'left' ? 'visible' : 'hidden') });
$('#zoom-excluded-area-' + secondmarker).css({ left: (zoom.marker.distance > 0) ? zoom.box.left : zoom.marker[secondmarker].left, width: (zoom.marker.distance > 0) ? zoom.marker[secondmarker].left - zoom.box.left : zoom.box.right - zoom.marker[secondmarker].left});
$('#zoom-marker-tooltip-' + secondmarker ).css({ left: zoom.marker[secondmarker].left + ( (zoom.marker[secondmarker].excludeArea == 'right') ? (0) : (-zoom.marker[secondmarker].width) ) });
$('#zoom-marker-tooltip-' + secondmarker + '-arrow-left').css({ visibility: ( zoom.marker[secondmarker].excludeArea == 'left' ? 'hidden' : 'visible') });
$('#zoom-marker-tooltip-' + secondmarker + '-arrow-right').css({ visibility: ( zoom.marker[secondmarker].excludeArea == 'left' ? 'visible' : 'hidden') });
} else {
/* let the tooltip follow its marker */
$('#zoom-marker-tooltip-' + marker).css({ left: zoom.marker[marker].left -zoom.marker[marker].width });
}
},
stop:
function(event,ui) {
/* hide all tooltip if we are in auto mode */
if (zoom.custom.zoomTimestamps == 'auto') {
$('.zoom-marker-tooltip').fadeOut(1000);
}
}
});
break;
case 2:
if (zoom.custom.zoom3rdMouseButton != false) {
/* hide context menu if open */
zoomContextMenu_hide();
if (zoom.custom.zoom3rdMouseButton == 'zoom_in') {
zoomAction_zoom_in();
} else {
zoomAction_zoom_out( zoom.custom.zoomOutFactor );
}
}
break;
}
return false;
});
}
}
/*
* executes a dynamic zoom in
*/
function zoomAction_zoom_in(){
setCustomFilterActionActionAndDate();
/* hide context menu if open */
zoomContextMenu_hide();
if (zoom.custom.zoomMode == 'quick') {
var newGraphStartTime = (zoom.attr.action == 'left2right') ? parseInt(parseInt(zoom.graph.start) + (zoom.attr.start -zoom.image.left -zoom.box.left)*zoom.graph.secondsPerPixel)
: parseInt(parseInt(zoom.graph.start) + (zoom.attr.end -zoom.image.left -zoom.box.left)*zoom.graph.secondsPerPixel);
var newGraphEndTime = (zoom.attr.action == 'left2right') ? Math.ceil( parseFloat(newGraphStartTime + (zoom.attr.end-zoom.attr.start)*zoom.graph.secondsPerPixel))
: parseInt(newGraphStartTime + (zoom.attr.start-zoom.attr.end)*zoom.graph.secondsPerPixel);
/* If the user only clicked on a graph then equal end and start date to ensure that we do not propergate NaNs */
if (isNaN(newGraphStartTime) & isNaN(newGraphEndTime)) {
return;
} else if (isNaN(newGraphStartTime) & !isNaN(newGraphEndTime)) {
newGraphStartTime = newGraphEndTime;
} else if (!isNaN(newGraphStartTime) & isNaN(newGraphEndTime)){
newGraphEndTime = newGraphStartTime;
}
} else {
/* advanced mode has other requirements */
/* first of, do nothing if not both marker have been positioned */
if (!zoom.marker[1].placed | !zoom.marker[2].placed) {
alert('NOTE: In advanced mode both markers have to be positioned first to define the period of time you want to zoom in.');
return;
} else {
var newGraphStartTime = zoom.marker[((zoom.marker[1].unixtime > zoom.marker[2].unixtime)? 2 : 1 )].unixtime;
var newGraphEndTime = zoom.marker[((zoom.marker[1].unixtime > zoom.marker[2].unixtime)? 1 : 2 )].unixtime;
}
}
/* hide Zoom without destroying its container */
$('#zoom-container').html('');
if (zoom.options.inputfieldStartTime != '' & zoom.options.inputfieldEndTime != ''){
zoom.initiator.attr('graph_start', newGraphStartTime);
zoom.initiator.attr('graph_end', newGraphEndTime);
/* execute zoom within 'tree view' or the 'preview view' */
$('#' + zoom.options.inputfieldStartTime).val(unixTime2Date(newGraphStartTime));
$('#' + zoom.options.inputfieldEndTime).val(unixTime2Date(newGraphEndTime));
if (graph_start !== null && graph_end !== null) {
zoom.attr.start = 'none';
if (pageAction != 'graph') {
graph_start = newGraphStartTime;
graph_end = newGraphEndTime;
initializeGraphs(true);
}else{
$('#graph_start').val(newGraphStartTime);
$('#graph_end').val(newGraphEndTime);
initializeGraph();
}
} else {
$("input[name='" + zoom.options.submitButton + "']").trigger('click');
}
zoomAction_update_session(newGraphStartTime, newGraphEndTime);
return false;
} else {
/* graph view is already in zoom status */
open(zoom.attr.location[0] + '?action=' + zoom.graph.action + '&local_graph_id=' + zoom.graph.local_graph_id + '&rra_id=' + zoom.graph.rra_id + '&view_type=' + zoom.graph.view_type + '&graph_start=' + newGraphStartTime + '&graph_end=' + newGraphEndTime + '&graph_height=' + zoom.graph.height + '&graph_width=' + zoom.graph.width + '&title_font_size=' + zoom.graph.title_font_size + '&disable_cache=true', '_self');
}
zoom.attr.start = 'none';
}
/*
* sets the predefined timespan to 'Custom'
*/
function setCustomFilterActionActionAndDate() {
onChange = $('#predefined_timespan').attr('onchange');
if (typeof $('#predefined_timespan').selectmenu() == 'function') {
$('#predefined_timespan').val('0').selectmenu('refresh');
} else{
$('#predefined_timespan').val('0');
}
}
function getZoomOutFactorText(zoomOutFactor) {
switch(zoomOutFactor) {
case 2:
return zoom_i18n_zoom_out + ' (' + zoom_i18n_zoom_2 + ')';
break;
case 4:
return zoom_i18n_zoom_out + ' (' + zoom_i18n_zoom_4 + ')';
break;
case 8:
return zoom_i18n_zoom_out + ' (' + zoom_i18n_zoom_8 + ')';
break;
case 16:
return zoom_i18n_zoom_out + ' (' + zoom_i18n_zoom_16 + ')';
break;
case 32:
return zoom_i18n_zoom_out + ' (' + zoom_i18n_zoom_32 + ')';
break;
}
}
/*
* executes a static zoom out (as right click event)
*/
function zoomAction_zoom_out(multiplier){
setCustomFilterActionActionAndDate();
/* hide context menu if open */
zoomContextMenu_hide();
multiplier--;
/* avoid that we can not zoom out anymore if start and end date will be equal */
if (zoom.graph.timespan == 0) {
zoom.graph.timespan = 1;
}
if (zoom.custom.zoomMode == 'quick' || !zoom.marker[1].placed || !zoom.marker[2].placed ) {
if (zoom.custom.zoomOutPositioning == 'begin') {
var newGraphStartTime = parseInt(zoom.graph.start);
var newGraphEndTime = parseInt(parseInt(zoom.graph.end) + (multiplier * zoom.graph.timespan));
} else if (zoom.custom.zoomOutPositioning == 'end') {
var newGraphStartTime = parseInt(parseInt(zoom.graph.start) - (multiplier * zoom.graph.timespan));
var newGraphEndTime = parseInt(zoom.graph.end);
} else {
if ($('#future').val() == 'on') {
// define the new start and end time, so that the selected area will be centered per default
var newGraphStartTime = parseInt(parseInt(zoom.graph.start) - (0.5 * multiplier * zoom.graph.timespan));
var newGraphEndTime = parseInt(parseInt(zoom.graph.end) + (0.5 * multiplier * zoom.graph.timespan));
} else{
var now = parseInt($.now() / 1000);
var newGraphEndTime = parseInt(parseInt(zoom.graph.end) + (0.5 * multiplier * zoom.graph.timespan));
var newGraphStartTime = parseInt(parseInt(zoom.graph.start) - (0.5 * multiplier * zoom.graph.timespan));
if (newGraphEndTime > now) {
offset = newGraphEndTime - now;
newGraphEndTime = now;
newGraphStartTime -= offset;
}
}
}
} else {
var newGraphStartTime = zoom.marker[((zoom.marker[1].unixtime > zoom.marker[2].unixtime)? 2 : 1 )].unixtime;
var newGraphEndTime = zoom.marker[((zoom.marker[1].unixtime > zoom.marker[2].unixtime)? 1 : 2 )].unixtime;
var selectedTimeSpan = newGraphEndTime - newGraphStartTime;
if (zoom.custom.zoomOutPositioning == 'begin') {
newGraphEndTime = newGraphEndTime + multiplier * selectedTimeSpan;
} else if (zoom.custom.zoomOutPositioning == 'end') {
newGraphStartTime = newGraphStartTime - multiplier * selectedTimeSpan;
} else {
newGraphStartTime = parseInt(newGraphStartTime - 0.5 * multiplier * selectedTimeSpan);
newGraphEndTime = parseInt(newGraphEndTime + 0.5 * multiplier * selectedTimeSpan);
}
}
/* hide Zoom without destroying its container */
$('#zoom-container').html('');
if (zoom.options.inputfieldStartTime != '' & zoom.options.inputfieldEndTime != ''){
zoom.initiator.attr('graph_start', newGraphStartTime);
zoom.initiator.attr('graph_end', newGraphEndTime);
/* execute zoom within 'tree view' or the 'preview view' */
$('#' + zoom.options.inputfieldStartTime).val(unixTime2Date(newGraphStartTime));
$('#' + zoom.options.inputfieldEndTime).val(unixTime2Date(newGraphEndTime));
if (graph_start !== null && graph_end !== null) {
zoom.attr.start = 'none';
if (pageAction != 'graph') {
graph_start = newGraphStartTime;
graph_end = newGraphEndTime;
initializeGraphs(true);
}else{
$('#graph_start').val(newGraphStartTime);
$('#graph_end').val(newGraphEndTime);
initializeGraph();
}
} else {
$("input[name='" + zoom.options.submitButton + "']").trigger('click');
}
zoomAction_update_session(newGraphStartTime, newGraphEndTime);
} else {
open(zoom.attr.location[0] + '?action=' + zoom.graph.action + '&local_graph_id=' + zoom.graph.local_graph_id + '&rra_id=' + zoom.graph.rra_id + '&view_type=' + zoom.graph.view_type + '&graph_start=' + newGraphStartTime + '&graph_end=' + newGraphEndTime + '&graph_height=' + zoom.graph.height + '&graph_width=' + zoom.graph.width + '&title_font_size=' + zoom.graph.title_font_size + '&disable_cache=true', '_self');
}
}
/*
* when updating the zoom window, we have to update cacti's zoom session variables
*/
function zoomAction_update_session(newGraphStartTime, newGraphEndTime) {
$.get(document.location.pathname +
'?action=update_timespan' +
'&date1=' + unixTime2Date(newGraphStartTime) +
'&date2=' + unixTime2Date(newGraphEndTime), function() {
$('#predefined_timespan').val('0');
if (typeof $('#predefined_timespan').selectmenu() === 'object') {
$('#predefined_timespan').selectmenu('refresh');
}
});
}
/*
* updates the css parameters of the zoom area to reflect user's interaction
*/
function zoomAction_draw(event) {
if (zoom.attr.start == 'none') { return; }
/* mouse has been moved from right to left */
if ((event.pageX-zoom.attr.start)<0) {
zoom.attr.action = 'right2left';
zoom.attr.end = (event.pageX < zoom.image.left+zoom.box.left) ? zoom.image.left+zoom.box.left : event.pageX;
$('#zoom-area').css({ left:zoom.attr.end-zoom.image.left+'px', width:Math.abs(zoom.attr.start-zoom.attr.end-1)+'px' });
/* mouse has been moved from left to right*/
} else {
zoom.attr.action = 'left2right';
zoom.attr.end = (event.pageX > zoom.image.left+zoom.box.right) ? zoom.image.left+zoom.box.right : event.pageX;
$('#zoom-area').css({ left:zoom.attr.start-zoom.image.left+'px', width:Math.abs(zoom.attr.end-zoom.attr.start)+'px' });
}
}
/**
*
* @access public
* @return void
**/
function zoomContextMenu_init(){
/* sync menu with cookie parameters */
$('.zoomContextMenuAction__set_zoomMode__' + zoom.custom.zoomMode).addClass('zoom-menu-highlight');
$('.zoomContextMenuAction__set_zoomTimestamps__' + ((zoom.custom.zoomTimestamps == 'auto') ? 'auto' : ((zoom.custom.zoomTimestamps) ? 'on' : 'off' ))).addClass('zoom-menu-highlight');
$('.zoomContextMenuAction__set_zoomOutFactor__' + zoom.custom.zoomOutFactor).addClass('zoom-menu-highlight');
$('.zoomContextMenuAction__set_zoomOutPositioning__' + zoom.custom.zoomOutPositioning).addClass('zoom-menu-highlight');
$('.zoomContextMenuAction__set_zoom3rdMouseButton__' + ((zoom.custom.zoom3rdMouseButton === false) ? 'off' : zoom.custom.zoom3rdMouseButton) ).addClass('zoom-menu-highlight');
$('.zoomContextMenuAction__zoom_out').text(getZoomOutFactorText(zoom.custom.zoomOutFactor));
if (zoom.custom.zoomMode == 'quick') {
$('.advanced_mode').hide();
}
/* init click on events */
$('[class*=zoomContextMenuAction__]').off().on('click', function() {
var zoomContextMenuAction = false;
var zoomContextMenuActionValue = false;
var classList = $.trim($(this).attr('class')).split(/\s+/);
$.each( classList, function(index, item){
if ( item.search('zoomContextMenuAction__') != -1) {
zoomContextMenuActionList = item.replace('zoomContextMenuAction__', '').split('__');
zoomContextMenuAction = zoomContextMenuActionList[0];
if (zoomContextMenuActionList[1] == 'undefined' || zoomContextMenuActionList[1] == 'off') {
zoomContextMenuActionValue = false;
} else if (zoomContextMenuActionList[1] == 'on') {
zoomContextMenuActionValue = true;
} else {
zoomContextMenuActionValue = zoomContextMenuActionList[1];
}
return( false );
}
});
if ( zoomContextMenuAction ) {
if ( zoomContextMenuAction.substring(0,8) == 'set_zoom') {
zoomContextMenuAction_set( zoomContextMenuAction.replace('set_zoom', '').toLowerCase(), zoomContextMenuActionValue);
} else {
zoomContextMenuAction_do( zoomContextMenuAction, zoomContextMenuActionValue);
}
}
});
/* init hover events */
$('.first_li , .sec_li, .inner_li span').hover(
function () {
$(this).addClass('zoom-menu-hover');
if ( $(this).children().length >0 )
if (zoom.custom.zoomMode == 'quick') {
$(this).children('.inner_li:not(.advanced_mode)').show();
} else {
$(this).children('.inner_li').show();
}
},
function () {
$(this).removeClass('zoom-menu-hover');
$(this).children('.inner_li').hide();
}
);
};
/**
*
* @access public
* @return void
**/
function zoomContextMenuAction_set(object, value){
switch(object) {
case 'mode':
if ( zoom.custom.zoomMode != value) {
zoom.custom.zoomMode = value;
$('[class*=zoomContextMenuAction__set_zoomMode__]').toggleClass('zoom-menu-highlight');
if (value == 'quick') {
// reset menu