forked from owen0o0/WebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
768 lines (766 loc) · 30.7 KB
/
app.js
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
/*! perfect-scrollbar - v1.1
* https://github.com/owen0o0/WebStack
* https://www.iotheme.cn/store/webstack.html
*/
(function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?e(require("jquery")):e(jQuery)})(function(e){"use strict";function t(e){return"string"==typeof e?parseInt(e,10):~~e}var o={wheelSpeed:1,wheelPropagation:!1,swipePropagation:!0,minScrollbarLength:null,maxScrollbarLength:null,useBothWheelAxes:!1,useKeyboard:!0,suppressScrollX:!1,suppressScrollY:!1,scrollXMarginOffset:0,scrollYMarginOffset:0,includePadding:!1},n=0,r=function(){var e=n++;return function(t){var o=".perfect-scrollbar-"+e;return t===void 0?o:t+o}},l="WebkitAppearance"in document.documentElement.style;e.fn.perfectScrollbar=function(n,i){return this.each(function(){function a(e,o){var n=e+o,r=D-R;j=0>n?0:n>r?r:n;var l=t(j*(Y-D)/(D-R));M.scrollTop(l)}function s(e,o){var n=e+o,r=E-k;W=0>n?0:n>r?r:n;var l=t(W*(C-E)/(E-k));M.scrollLeft(l)}function c(e){return P.minScrollbarLength&&(e=Math.max(e,P.minScrollbarLength)),P.maxScrollbarLength&&(e=Math.min(e,P.maxScrollbarLength)),e}function u(){var e={width:I};e.left=B?M.scrollLeft()+E-C:M.scrollLeft(),N?e.bottom=_-M.scrollTop():e.top=Q+M.scrollTop(),H.css(e);var t={top:M.scrollTop(),height:A};Z?t.right=B?C-M.scrollLeft()-V-J.outerWidth():V-M.scrollLeft():t.left=B?M.scrollLeft()+2*E-C-$-J.outerWidth():$+M.scrollLeft(),G.css(t),U.css({left:W,width:k-z}),J.css({top:j,height:R-et})}function d(){M.removeClass("ps-active-x"),M.removeClass("ps-active-y"),E=P.includePadding?M.innerWidth():M.width(),D=P.includePadding?M.innerHeight():M.height(),C=M.prop("scrollWidth"),Y=M.prop("scrollHeight"),!P.suppressScrollX&&C>E+P.scrollXMarginOffset?(X=!0,I=E-F,k=c(t(I*E/C)),W=t(M.scrollLeft()*(I-k)/(C-E))):(X=!1,k=0,W=0,M.scrollLeft(0)),!P.suppressScrollY&&Y>D+P.scrollYMarginOffset?(O=!0,A=D-tt,R=c(t(A*D/Y)),j=t(M.scrollTop()*(A-R)/(Y-D))):(O=!1,R=0,j=0,M.scrollTop(0)),W>=I-k&&(W=I-k),j>=A-R&&(j=A-R),u(),X&&M.addClass("ps-active-x"),O&&M.addClass("ps-active-y")}function p(){var t,o,n=function(e){s(t,e.pageX-o),d(),e.stopPropagation(),e.preventDefault()},r=function(){H.removeClass("in-scrolling"),e(q).unbind(K("mousemove"),n)};U.bind(K("mousedown"),function(l){o=l.pageX,t=U.position().left,H.addClass("in-scrolling"),e(q).bind(K("mousemove"),n),e(q).one(K("mouseup"),r),l.stopPropagation(),l.preventDefault()}),t=o=null}function f(){var t,o,n=function(e){a(t,e.pageY-o),d(),e.stopPropagation(),e.preventDefault()},r=function(){G.removeClass("in-scrolling"),e(q).unbind(K("mousemove"),n)};J.bind(K("mousedown"),function(l){o=l.pageY,t=J.position().top,G.addClass("in-scrolling"),e(q).bind(K("mousemove"),n),e(q).one(K("mouseup"),r),l.stopPropagation(),l.preventDefault()}),t=o=null}function v(e,t){var o=M.scrollTop();if(0===e){if(!O)return!1;if(0===o&&t>0||o>=Y-D&&0>t)return!P.wheelPropagation}var n=M.scrollLeft();if(0===t){if(!X)return!1;if(0===n&&0>e||n>=C-E&&e>0)return!P.wheelPropagation}return!0}function g(e,t){var o=M.scrollTop(),n=M.scrollLeft(),r=Math.abs(e),l=Math.abs(t);if(l>r){if(0>t&&o===Y-D||t>0&&0===o)return!P.swipePropagation}else if(r>l&&(0>e&&n===C-E||e>0&&0===n))return!P.swipePropagation;return!0}function b(){function e(e){var t=e.originalEvent.deltaX,o=-1*e.originalEvent.deltaY;return(t===void 0||o===void 0)&&(t=-1*e.originalEvent.wheelDeltaX/6,o=e.originalEvent.wheelDeltaY/6),e.originalEvent.deltaMode&&1===e.originalEvent.deltaMode&&(t*=10,o*=10),t!==t&&o!==o&&(t=0,o=e.originalEvent.wheelDelta),[t,o]}function t(t){if(l||!(M.find("select:focus").length>0)){var n=e(t),r=n[0],i=n[1];o=!1,P.useBothWheelAxes?O&&!X?(i?M.scrollTop(M.scrollTop()-i*P.wheelSpeed):M.scrollTop(M.scrollTop()+r*P.wheelSpeed),o=!0):X&&!O&&(r?M.scrollLeft(M.scrollLeft()+r*P.wheelSpeed):M.scrollLeft(M.scrollLeft()-i*P.wheelSpeed),o=!0):(M.scrollTop(M.scrollTop()-i*P.wheelSpeed),M.scrollLeft(M.scrollLeft()+r*P.wheelSpeed)),d(),o=o||v(r,i),o&&(t.stopPropagation(),t.preventDefault())}}var o=!1;window.onwheel!==void 0?M.bind(K("wheel"),t):window.onmousewheel!==void 0&&M.bind(K("mousewheel"),t)}function h(){var t=!1;M.bind(K("mouseenter"),function(){t=!0}),M.bind(K("mouseleave"),function(){t=!1});var o=!1;e(q).bind(K("keydown"),function(n){if((!n.isDefaultPrevented||!n.isDefaultPrevented())&&t){for(var r=document.activeElement?document.activeElement:q.activeElement;r.shadowRoot;)r=r.shadowRoot.activeElement;if(!e(r).is(":input,[contenteditable]")){var l=0,i=0;switch(n.which){case 37:l=-30;break;case 38:i=30;break;case 39:l=30;break;case 40:i=-30;break;case 33:i=90;break;case 32:case 34:i=-90;break;case 35:i=n.ctrlKey?-Y:-D;break;case 36:i=n.ctrlKey?M.scrollTop():D;break;default:return}M.scrollTop(M.scrollTop()-i),M.scrollLeft(M.scrollLeft()+l),o=v(l,i),o&&n.preventDefault()}}})}function w(){function e(e){e.stopPropagation()}J.bind(K("click"),e),G.bind(K("click"),function(e){var o=t(R/2),n=e.pageY-G.offset().top-o,r=D-R,l=n/r;0>l?l=0:l>1&&(l=1),M.scrollTop((Y-D)*l)}),U.bind(K("click"),e),H.bind(K("click"),function(e){var o=t(k/2),n=e.pageX-H.offset().left-o,r=E-k,l=n/r;0>l?l=0:l>1&&(l=1),M.scrollLeft((C-E)*l)})}function m(){function t(){var e=window.getSelection?window.getSelection():document.getSlection?document.getSlection():{rangeCount:0};return 0===e.rangeCount?null:e.getRangeAt(0).commonAncestorContainer}function o(){r||(r=setInterval(function(){return x()?(M.scrollTop(M.scrollTop()+l.top),M.scrollLeft(M.scrollLeft()+l.left),d(),void 0):(clearInterval(r),void 0)},50))}function n(){r&&(clearInterval(r),r=null),H.removeClass("in-scrolling"),G.removeClass("in-scrolling")}var r=null,l={top:0,left:0},i=!1;e(q).bind(K("selectionchange"),function(){e.contains(M[0],t())?i=!0:(i=!1,n())}),e(window).bind(K("mouseup"),function(){i&&(i=!1,n())}),e(window).bind(K("mousemove"),function(e){if(i){var t={x:e.pageX,y:e.pageY},r=M.offset(),a={left:r.left,right:r.left+M.outerWidth(),top:r.top,bottom:r.top+M.outerHeight()};t.x<a.left+3?(l.left=-5,H.addClass("in-scrolling")):t.x>a.right-3?(l.left=5,H.addClass("in-scrolling")):l.left=0,t.y<a.top+3?(l.top=5>a.top+3-t.y?-5:-20,G.addClass("in-scrolling")):t.y>a.bottom-3?(l.top=5>t.y-a.bottom+3?5:20,G.addClass("in-scrolling")):l.top=0,0===l.top&&0===l.left?n():o()}})}function T(t,o){function n(e,t){M.scrollTop(M.scrollTop()-t),M.scrollLeft(M.scrollLeft()-e),d()}function r(){h=!0}function l(){h=!1}function i(e){return e.originalEvent.targetTouches?e.originalEvent.targetTouches[0]:e.originalEvent}function a(e){var t=e.originalEvent;return t.targetTouches&&1===t.targetTouches.length?!0:t.pointerType&&"mouse"!==t.pointerType&&t.pointerType!==t.MSPOINTER_TYPE_MOUSE?!0:!1}function s(e){if(a(e)){w=!0;var t=i(e);p.pageX=t.pageX,p.pageY=t.pageY,f=(new Date).getTime(),null!==b&&clearInterval(b),e.stopPropagation()}}function c(e){if(!h&&w&&a(e)){var t=i(e),o={pageX:t.pageX,pageY:t.pageY},r=o.pageX-p.pageX,l=o.pageY-p.pageY;n(r,l),p=o;var s=(new Date).getTime(),c=s-f;c>0&&(v.x=r/c,v.y=l/c,f=s),g(r,l)&&(e.stopPropagation(),e.preventDefault())}}function u(){!h&&w&&(w=!1,clearInterval(b),b=setInterval(function(){return x()?.01>Math.abs(v.x)&&.01>Math.abs(v.y)?(clearInterval(b),void 0):(n(30*v.x,30*v.y),v.x*=.8,v.y*=.8,void 0):(clearInterval(b),void 0)},10))}var p={},f=0,v={},b=null,h=!1,w=!1;t&&(e(window).bind(K("touchstart"),r),e(window).bind(K("touchend"),l),M.bind(K("touchstart"),s),M.bind(K("touchmove"),c),M.bind(K("touchend"),u)),o&&(window.PointerEvent?(e(window).bind(K("pointerdown"),r),e(window).bind(K("pointerup"),l),M.bind(K("pointerdown"),s),M.bind(K("pointermove"),c),M.bind(K("pointerup"),u)):window.MSPointerEvent&&(e(window).bind(K("MSPointerDown"),r),e(window).bind(K("MSPointerUp"),l),M.bind(K("MSPointerDown"),s),M.bind(K("MSPointerMove"),c),M.bind(K("MSPointerUp"),u)))}function y(){M.bind(K("scroll"),function(){d()})}function L(){M.unbind(K()),e(window).unbind(K()),e(q).unbind(K()),M.data("perfect-scrollbar",null),M.data("perfect-scrollbar-update",null),M.data("perfect-scrollbar-destroy",null),U.remove(),J.remove(),H.remove(),G.remove(),M=H=G=U=J=X=O=E=D=C=Y=k=W=_=N=Q=R=j=V=Z=$=B=K=null}function S(){d(),y(),p(),f(),w(),m(),b(),(ot||nt)&&T(ot,nt),P.useKeyboard&&h(),M.data("perfect-scrollbar",M),M.data("perfect-scrollbar-update",d),M.data("perfect-scrollbar-destroy",L)}var P=e.extend(!0,{},o),M=e(this),x=function(){return!!M};if("object"==typeof n?e.extend(!0,P,n):i=n,"update"===i)return M.data("perfect-scrollbar-update")&&M.data("perfect-scrollbar-update")(),M;if("destroy"===i)return M.data("perfect-scrollbar-destroy")&&M.data("perfect-scrollbar-destroy")(),M;if(M.data("perfect-scrollbar"))return M.data("perfect-scrollbar");M.addClass("ps-container");var E,D,C,Y,X,k,W,I,O,R,j,A,B="rtl"===M.css("direction"),K=r(),q=this.ownerDocument||document,H=e("<div class='ps-scrollbar-x-rail'>").appendTo(M),U=e("<div class='ps-scrollbar-x'>").appendTo(H),_=t(H.css("bottom")),N=_===_,Q=N?null:t(H.css("top")),z=t(H.css("borderLeftWidth"))+t(H.css("borderRightWidth")),F=t(H.css("marginLeft"))+t(H.css("marginRight")),G=e("<div class='ps-scrollbar-y-rail'>").appendTo(M),J=e("<div class='ps-scrollbar-y'>").appendTo(G),V=t(G.css("right")),Z=V===V,$=Z?null:t(G.css("left")),et=t(G.css("borderTopWidth"))+t(G.css("borderBottomWidth")),tt=t(G.css("marginTop"))+t(G.css("marginBottom")),ot="ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch,nt=null!==window.navigator.msMaxTouchPoints;return S(),M})}});
console.log("\n %c WebStack导航主题 V"+theme.version+" By 一为 %c https://www.iotheme.cn/ \n", "color: #ffffff; background: #f1404b; padding:5px 0;", "background: #030307; padding:5px 0;");
var public_vars = public_vars || {};
jQuery.extend(public_vars, {
breakpoints: {
largescreen: [991, -1],
tabletscreen: [768, 990],
devicescreen: [420, 767],
sdevicescreen: [0, 419]
},
lastBreakpoint: null
});
/* Main Function that will be called each time when the screen breakpoint changes */
function resizable(breakpoint)
{
var sb_with_animation;
// Large Screen Specific Script
if(is('largescreen'))
{
}
// Tablet or larger screen
if(ismdxl())
{
}
// Tablet Screen Specific Script
if(is('tabletscreen'))
{
}
// Tablet device screen
if(is('tabletscreen'))
{
public_vars.$sidebarMenu.addClass('collapsed');
ps_destroy();
}
// Tablet Screen Specific Script
if(isxs())
{
}
// Trigger Event
jQuery(window).trigger('xenon.resize');
}
// Get current breakpoint
function get_current_breakpoint()
{
var width = jQuery(window).width(),
breakpoints = public_vars.breakpoints;
for(var breakpont_label in breakpoints)
{
var bp_arr = breakpoints[breakpont_label],
min = bp_arr[0],
max = bp_arr[1];
if(max == -1)
max = width;
if(min <= width && max >= width)
{
return breakpont_label;
}
}
return null;
}
// Check current screen breakpoint
function is(screen_label)
{
return get_current_breakpoint() == screen_label;
}
// Is xs device
function isxs()
{
return is('devicescreen') || is('sdevicescreen');
}
// Is md or xl
function ismdxl()
{
return is('tabletscreen') || is('largescreen');
}
// Trigger Resizable Function
function trigger_resizable()
{
if(public_vars.lastBreakpoint != get_current_breakpoint())
{
public_vars.lastBreakpoint = get_current_breakpoint();
resizable(public_vars.lastBreakpoint);
}
// Trigger Event (Repeated)
jQuery(window).trigger('xenon.resized');
}
;(function($, window, undefined)
{
"use strict";
$(document).ready(function()
{
// Chat Toggler
$('a[data-toggle="chat"]').each(function(i, el)
{
$(el).on('click', function(ev)
{
ev.preventDefault();
public_vars.$body.toggleClass('chat-open');
if($.isFunction($.fn.perfectScrollbar))
{
setTimeout(function()
{
public_vars.$chat.find('.chat_inner').perfectScrollbar('update');
$(window).trigger('xenon.resize');
}, 1);
}
});
});
// Settings Pane Toggler
$('a[data-toggle="settings-pane"]').each(function(i, el)
{
$(el).on('click', function(ev)
{
ev.preventDefault();
var use_animation = attrDefault($(el), 'animate', false) && ! isxs();
var scroll = {
top: $(document).scrollTop(),
toTop: 0
};
if(public_vars.$body.hasClass('settings-pane-open'))
{
scroll.toTop = scroll.top;
}
TweenMax.to(scroll, (use_animation ? .1 : 0), {top: scroll.toTop, roundProps: ['top'], ease: scroll.toTop < 10 ? null : Sine.easeOut, onUpdate: function()
{
$(window).scrollTop( scroll.top );
},
onComplete: function()
{
if(use_animation)
{
// With Animation
public_vars.$settingsPaneIn.addClass('with-animation');
// Opening
if( ! public_vars.$settingsPane.is(':visible'))
{
public_vars.$body.addClass('settings-pane-open');
var height = public_vars.$settingsPane.outerHeight(true);
public_vars.$settingsPane.css({
height: 0
});
TweenMax.to(public_vars.$settingsPane, .25, {css: {height: height}, ease: Circ.easeInOut, onComplete: function()
{
public_vars.$settingsPane.css({height: ''});
}});
public_vars.$settingsPaneIn.addClass('visible');
}
// Closing
else
{
public_vars.$settingsPaneIn.addClass('closing');
TweenMax.to(public_vars.$settingsPane, .25, {css: {height: 0}, delay: .15, ease: Power1.easeInOut, onComplete: function()
{
public_vars.$body.removeClass('settings-pane-open');
public_vars.$settingsPane.css({height: ''});
public_vars.$settingsPaneIn.removeClass('closing visible');
}});
}
}
else
{
// Without Animation
public_vars.$body.toggleClass('settings-pane-open');
public_vars.$settingsPaneIn.removeClass('visible');
public_vars.$settingsPaneIn.removeClass('with-animation');
}
}
});
});
});
// Sidebar Toggle
$('a[data-toggle="sidebar"]').each(function(i, el)
{
$(el).on('click', function(ev)
{
ev.preventDefault();
if(public_vars.$sidebarMenu.hasClass('collapsed'))
{
public_vars.$sidebarMenu.removeClass('collapsed');
ps_init();
}
else
{
public_vars.$sidebarMenu.addClass('collapsed');
ps_destroy();
}
$(window).trigger('xenon.resize');
});
});
// Mobile Menu Trigger
$('a[data-toggle="mobile-menu"]').on('click', function(ev)
{
ev.preventDefault();
public_vars.$mainMenu.add(public_vars.$sidebarProfile).toggleClass('mobile-is-visible');
if($("#main-menu").hasClass('mobile-is-visible') === true){
public_vars.$sidebarMenu.removeClass('collapsed');
$(".sidebar-menu-inner").css("max-height",window.innerHeight);
ps_init();
}
else{
ps_destroy();
}
});
// Mobile Menu Trigger for Horizontal Menu
$('a[data-toggle="mobile-menu-horizontal"]').on('click', function(ev)
{
ev.preventDefault();
public_vars.$horizontalMenu.toggleClass('mobile-is-visible');
});
// Mobile Menu Trigger for Sidebar & Horizontal Menu
$('a[data-toggle="mobile-menu-both"]').on('click', function(ev)
{
ev.preventDefault();
public_vars.$mainMenu.toggleClass('mobile-is-visible both-menus-visible');
public_vars.$horizontalMenu.toggleClass('mobile-is-visible both-menus-visible');
});
// Mobile User Info Menu Trigger
$('a[data-toggle="user-info-menu"]').on('click', function(ev)
{
ev.preventDefault();
public_vars.$userInfoMenu.toggleClass('mobile-is-visible');
});
// Mobile User Info Menu Trigger for Horizontal Menu
$('a[data-toggle="user-info-menu-horizontal"]').on('click', function(ev)
{
ev.preventDefault();
public_vars.$userInfoMenuHor.find('.nav.nav-userinfo').toggleClass('mobile-is-visible');
});
// Panel Close
$('body').on('click', '.panel a[data-toggle="remove"]', function(ev)
{
ev.preventDefault();
var $panel = $(this).closest('.panel'),
$panel_parent = $panel.parent();
$panel.remove();
if($panel_parent.children().length == 0)
{
$panel_parent.remove();
}
});
// Panel Reload
$('body').on('click', '.panel a[data-toggle="reload"]', function(ev)
{
ev.preventDefault();
var $panel = $(this).closest('.panel');
// This is just a simulation, nothing is going to be reloaded
$panel.append('<div class="panel-disabled"><div class="loader-1"></div></div>');
var $pd = $panel.find('.panel-disabled');
setTimeout(function()
{
$pd.fadeOut('fast', function()
{
$pd.remove();
});
}, 500 + 300 * (Math.random() * 5));
});
// Panel Expand/Collapse Toggle
$('body').on('click', '.panel a[data-toggle="panel"]', function(ev)
{
ev.preventDefault();
var $panel = $(this).closest('.panel');
$panel.toggleClass('collapsed');
});
// Loading Text toggle
$('[data-loading-text]').each(function(i, el) // Temporary for demo purpose only
{
var $this = $(el);
$this.on('click', function(ev)
{
$this.button('loading');
setTimeout(function(){ $this.button('reset'); }, 1800);
});
});
// Popovers and tooltips
$('[data-toggle="popover"]').each(function(i, el)
{
var $this = $(el),
placement = attrDefault($this, 'placement', 'right'),
trigger = attrDefault($this, 'trigger', 'click'),
popover_class = $this.get(0).className.match(/(popover-[a-z0-9]+)/i);
$this.popover({
placement: placement,
trigger: trigger
});
if(popover_class)
{
$this.removeClass(popover_class[1]);
$this.on('show.bs.popover', function(ev)
{
setTimeout(function()
{
var $popover = $this.next();
$popover.addClass(popover_class[1]);
}, 0);
});
}
});
$('[data-toggle="tooltip"]').each(function(i, el)
{
var $this = $(el),
placement = attrDefault($this, 'placement', 'top'),
trigger = attrDefault($this, 'trigger', 'hover'),
tooltip_class = $this.get(0).className.match(/(tooltip-[a-z0-9]+)/i);
$this.tooltip({
placement: placement,
trigger: trigger
});
if(tooltip_class)
{
$this.removeClass(tooltip_class[1]);
$this.on('show.bs.tooltip', function(ev)
{
setTimeout(function()
{
var $tooltip = $this.next();
$tooltip.addClass(tooltip_class[1]);
}, 0);
});
}
});
});
})(jQuery, window);
/**
* Xenon Main
*
**/
var public_vars = public_vars || {};
;(function($, window, undefined){
"use strict";
$(document).ready(function()
{
// Main Vars
public_vars.$body = $("body");
public_vars.$pageContainer = public_vars.$body.find(".page-container");
public_vars.$chat = public_vars.$pageContainer.find("#chat");
public_vars.$sidebarMenu = public_vars.$pageContainer.find('.sidebar-menu');
public_vars.$sidebarProfile = public_vars.$sidebarMenu.find('.sidebar-user-info');
public_vars.$mainMenu = public_vars.$sidebarMenu.find('.main-menu');
public_vars.$horizontalNavbar = public_vars.$body.find('.navbar.horizontal-menu');
public_vars.$horizontalMenu = public_vars.$horizontalNavbar.find('.navbar-nav');
public_vars.$mainContent = public_vars.$pageContainer.find('.main-content');
public_vars.$mainFooter = public_vars.$body.find('footer.main-footer');
public_vars.$userInfoMenuHor = public_vars.$body.find('.navbar.horizontal-menu');
public_vars.$userInfoMenu = public_vars.$body.find('nav.navbar.user-info-navbar');
public_vars.$settingsPane = public_vars.$body.find('.settings-pane');
public_vars.$settingsPaneIn = public_vars.$settingsPane.find('.settings-pane-inner');
public_vars.wheelPropagation = true; // used in Main menu (sidebar)
public_vars.$pageLoadingOverlay = public_vars.$body.find('.page-loading-overlay');
public_vars.defaultColorsPalette = ['#68b828','#7c38bc','#0e62c7','#fcd036','#4fcdfc','#00b19d','#ff6264','#f7aa47'];
// Setup Sidebar Menu
setup_sidebar_menu();
// Setup Horizontal Menu
setup_horizontal_menu();
// Sticky Footer
if(public_vars.$mainFooter.hasClass('sticky'))
{
stickFooterToBottom();
$(window).on('xenon.resized', stickFooterToBottom);
}
// Perfect Scrollbar
if($.isFunction($.fn.perfectScrollbar))
{
if(public_vars.$sidebarMenu.hasClass('fixed'))
ps_init();
$(".ps-scrollbar").each(function(i, el)
{
var $el = $(el);
if($el.hasClass('ps-scroll-down'))
{
$el.scrollTop($el.prop('scrollHeight'));
}
$el.perfectScrollbar({
wheelPropagation: false
});
});
// Chat Scrollbar
var $chat_inner = public_vars.$pageContainer.find('#chat .chat-inner');
if($chat_inner.parent().hasClass('fixed'))
$chat_inner.css({maxHeight: $(window).height()}).perfectScrollbar();
// User info opening dropdown trigger PS update
$(".dropdown:has(.ps-scrollbar)").each(function(i, el)
{
var $scrollbar = $(this).find('.ps-scrollbar');
$(this).on('click', '[data-toggle="dropdown"]', function(ev)
{
ev.preventDefault();
setTimeout(function()
{
$scrollbar.perfectScrollbar('update');
}, 1);
});
});
// Scrollable
$("div.scrollable").each(function(i, el)
{
var $this = $(el),
max_height = parseInt(attrDefault($this, 'max-height', 200), 10);
max_height = max_height < 0 ? 200 : max_height;
$this.css({maxHeight: max_height}).perfectScrollbar({
wheelPropagation: true
});
});
}
// Go to top links
$('body').on('click', 'a[rel="go-top"]', function(ev)
{
ev.preventDefault();
var obj = {pos: $(window).scrollTop()};
TweenLite.to(obj, .3, {pos: 0, ease:Power4.easeOut, onUpdate: function()
{
$(window).scrollTop(obj.pos);
}});
});
// Auto hidden breadcrumbs
$(".breadcrumb.auto-hidden").each(function(i, el)
{
var $bc = $(el),
$as = $bc.find('li a'),
collapsed_width = $as.width(),
expanded_width = 0;
$as.each(function(i, el)
{
var $a = $(el);
expanded_width = $a.outerWidth(true) + 5;
$a.addClass('collapsed').width(expanded_width);
$a.hover(function()
{
$a.removeClass('collapsed');
},
function()
{
$a.addClass('collapsed');
});
});
});
});
// Enable/Disable Resizable Event
var wid = 0;
$(window).resize(function() {
clearTimeout(wid);
wid = setTimeout(trigger_resizable, 200);
});
})(jQuery, window);
// Sideber Menu Setup function
var sm_duration = .2,
sm_transition_delay = 150;
function setup_sidebar_menu()
{
if(public_vars.$sidebarMenu.length)
{
var $items_with_subs = public_vars.$sidebarMenu.find('li:has(> ul)'),
toggle_others = public_vars.$sidebarMenu.hasClass('toggle-others');
$items_with_subs.filter('.active').addClass('expanded');
// On larger screens collapse sidebar when the window is tablet screen
if(is('largescreen') && public_vars.$sidebarMenu.hasClass('collapsed') == false)
{
$(window).on('resize', function()
{
if(is('tabletscreen'))
{
public_vars.$sidebarMenu.addClass('collapsed');
ps_destroy();
}
else
if(is('largescreen'))
{
public_vars.$sidebarMenu.removeClass('collapsed');
ps_init();
}
});
}
$items_with_subs.each(function(i, el)
{
var $li = jQuery(el),
$a = $li.children('a'),
$sub = $li.children('ul');
$li.addClass('has-sub');
$a.on('click', function(ev)
{
ev.preventDefault();
if(toggle_others)
{
sidebar_menu_close_items_siblings($li);
}
if($li.hasClass('expanded') || $li.hasClass('opened'))
sidebar_menu_item_collapse($li, $sub);
else
sidebar_menu_item_expand($li, $sub);
});
});
}
}
function sidebar_menu_item_expand($li, $sub)
{
if($li.data('is-busy') || ($li.parent('.main-menu').length && public_vars.$sidebarMenu.hasClass('collapsed')))
return;
$li.addClass('expanded').data('is-busy', true);
$sub.show();
var $sub_items = $sub.children(),
sub_height = $sub.outerHeight(),
win_y = jQuery(window).height(),
total_height = $li.outerHeight(),
current_y = public_vars.$sidebarMenu.scrollTop(),
item_max_y = $li.position().top + current_y,
fit_to_viewpport = public_vars.$sidebarMenu.hasClass('fit-in-viewport');
$sub_items.addClass('is-hidden');
$sub.height(0);
TweenMax.to($sub, sm_duration, {css: {height: sub_height}, onUpdate: ps_update, onComplete: function(){
$sub.height('');
}});
var interval_1 = $li.data('sub_i_1'),
interval_2 = $li.data('sub_i_2');
window.clearTimeout(interval_1);
interval_1 = setTimeout(function()
{
$sub_items.each(function(i, el)
{
var $sub_item = jQuery(el);
$sub_item.addClass('is-shown');
});
var finish_on = sm_transition_delay * $sub_items.length,
t_duration = parseFloat($sub_items.eq(0).css('transition-duration')),
t_delay = parseFloat($sub_items.last().css('transition-delay'));
if(t_duration && t_delay)
{
finish_on = (t_duration + t_delay) * 1000;
}
// In the end
window.clearTimeout(interval_2);
interval_2 = setTimeout(function()
{
$sub_items.removeClass('is-hidden is-shown');
}, finish_on);
$li.data('is-busy', false);
}, 0);
$li.data('sub_i_1', interval_1),
$li.data('sub_i_2', interval_2);
}
function sidebar_menu_item_collapse($li, $sub)
{
if($li.data('is-busy'))
return;
var $sub_items = $sub.children();
$li.removeClass('expanded').data('is-busy', true);
$sub_items.addClass('hidden-item');
TweenMax.to($sub, sm_duration, {css: {height: 0}, onUpdate: ps_update, onComplete: function()
{
$li.data('is-busy', false).removeClass('opened');
$sub.attr('style', '').hide();
$sub_items.removeClass('hidden-item');
$li.find('li.expanded ul').attr('style', '').hide().parent().removeClass('expanded');
ps_update(true);
}});
}
function sidebar_menu_close_items_siblings($li)
{
$li.siblings().not($li).filter('.expanded, .opened').each(function(i, el)
{
var $_li = jQuery(el),
$_sub = $_li.children('ul');
sidebar_menu_item_collapse($_li, $_sub);
});
}
// Horizontal Menu
function setup_horizontal_menu()
{
if(public_vars.$horizontalMenu.length)
{
var $items_with_subs = public_vars.$horizontalMenu.find('li:has(> ul)'),
click_to_expand = public_vars.$horizontalMenu.hasClass('click-to-expand');
if(click_to_expand)
{
public_vars.$mainContent.add( public_vars.$sidebarMenu ).on('click', function(ev)
{
$items_with_subs.removeClass('hover');
});
}
$items_with_subs.each(function(i, el)
{
var $li = jQuery(el),
$a = $li.children('a'),
$sub = $li.children('ul'),
is_root_element = $li.parent().is('.navbar-nav');
$li.addClass('has-sub');
// Mobile Only
$a.on('click', function(ev)
{
if(isxs())
{
ev.preventDefault();
// Automatically will toggle other menu items in mobile view
if(true)
{
sidebar_menu_close_items_siblings($li);
}
if($li.hasClass('expanded') || $li.hasClass('opened'))
sidebar_menu_item_collapse($li, $sub);
else
sidebar_menu_item_expand($li, $sub);
}
});
// Click To Expand
if(click_to_expand)
{
$a.on('click', function(ev)
{
ev.preventDefault();
if(isxs())
return;
// For parents only
if(is_root_element)
{
$items_with_subs.filter(function(i, el){ return jQuery(el).parent().is('.navbar-nav'); }).not($li).removeClass('hover');
$li.toggleClass('hover');
}
// Sub menus
else
{
var sub_height;
// To Expand
if($li.hasClass('expanded') == false)
{
$li.addClass('expanded');
$sub.addClass('is-visible');
sub_height = $sub.outerHeight();
$sub.height(0);
TweenLite.to($sub, .15, {css: {height: sub_height}, ease: Sine.easeInOut, onComplete: function(){ $sub.attr('style', ''); }});
// Hide Existing in the list
$li.siblings().find('> ul.is-visible').not($sub).each(function(i, el)
{
var $el = jQuery(el);
sub_height = $el.outerHeight();
$el.removeClass('is-visible').height(sub_height);
$el.parent().removeClass('expanded');
TweenLite.to($el, .15, {css: {height: 0}, onComplete: function(){ $el.attr('style', ''); }});
});
}
// To Collapse
else
{
sub_height = $sub.outerHeight();
$li.removeClass('expanded');
$sub.removeClass('is-visible').height(sub_height);
TweenLite.to($sub, .15, {css: {height: 0}, onComplete: function(){ $sub.attr('style', ''); }});
}
}
});
}
// Hover To Expand
else
{
$li.hoverIntent({
over: function()
{
if(isxs())
return;
if(is_root_element)
{
$li.addClass('hover');
}
else
{
$sub.addClass('is-visible');
sub_height = $sub.outerHeight();
$sub.height(0);
TweenLite.to($sub, .25, {css: {height: sub_height}, ease: Sine.easeInOut, onComplete: function(){ $sub.attr('style', ''); }});
}
},
out: function()
{
if(isxs())
return;
if(is_root_element)
{
$li.removeClass('hover');
}
else
{
sub_height = $sub.outerHeight();
$li.removeClass('expanded');
$sub.removeClass('is-visible').height(sub_height);
TweenLite.to($sub, .25, {css: {height: 0}, onComplete: function(){ $sub.attr('style', ''); }});
}
},
timeout: 200,
interval: is_root_element ? 10 : 100
});
}
});
}
}
function stickFooterToBottom()
{
public_vars.$mainFooter.add( public_vars.$mainContent ).add( public_vars.$sidebarMenu ).attr('style', '');
if(isxs())
return false;
if(public_vars.$mainFooter.hasClass('sticky'))
{
var win_height = jQuery(window).height(),
footer_height = public_vars.$mainFooter.outerHeight(true),
main_content_height = public_vars.$mainFooter.position().top + footer_height,
main_content_height_only = main_content_height - footer_height,
extra_height = public_vars.$horizontalNavbar.outerHeight();
if(win_height > main_content_height - parseInt(public_vars.$mainFooter.css('marginTop'), 10))
{
public_vars.$mainFooter.css({
marginTop: win_height - main_content_height - extra_height
});
}
}
}
// Perfect scroll bar functions by Arlind Nushi
function ps_update(destroy_init)
{
//if(isxs())
// return;
if(jQuery.isFunction(jQuery.fn.perfectScrollbar))
{
if(public_vars.$sidebarMenu.hasClass('collapsed'))
{
return;
}
public_vars.$sidebarMenu.find('.sidebar-menu-inner').perfectScrollbar('update');
if(destroy_init)
{
ps_destroy();
ps_init();
}
}
}
function ps_init()
{
//if(isxs())
// return;
if(jQuery.isFunction(jQuery.fn.perfectScrollbar))
{
if(public_vars.$sidebarMenu.hasClass('collapsed') || ! public_vars.$sidebarMenu.hasClass('fixed'))
{
return;
}
public_vars.$sidebarMenu.find('.sidebar-menu-inner').perfectScrollbar({
wheelSpeed: 1,
wheelPropagation: public_vars.wheelPropagation
});
}
}
function ps_destroy()
{
if(jQuery.isFunction(jQuery.fn.perfectScrollbar))
{
public_vars.$sidebarMenu.find('.sidebar-menu-inner').perfectScrollbar('destroy');
}
}
// Element Attribute Helper
function attrDefault($el, data_var, default_val)
{
if(typeof $el.data(data_var) != 'undefined')
{
return $el.data(data_var);
}
return default_val;
}