PluginProbe
School Management System – WPSchoolPress / trunk
School Management System – WPSchoolPress vtrunk
2.2.48 2.2.47 2.2.46 2.2.45 2.2.44 2.2.43 2.2.42 2.2.41 2.2.40 2.2.39 2.2.38 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 All 103 releases
wpschoolpress / js / lib / app.js

app.js in School Management System – WPSchoolPress trunk, at js/lib/app.js

2,472 lines 23.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*! AdminLTE app.js
2
3
4
5 * ================
6
7
8
9 * Main JS application file for AdminLTE v2. This file
10
11
12
13 * should be included in all pages. It controls some layout
14
15
16
17 * options and implements exclusive AdminLTE plugins.
18
19
20
21 *
22
23
24
25 * @Author Almsaeed Studio
26
27
28
29 * @Support <http://www.almsaeedstudio.com>
30
31
32
33 * @Email <support@almsaeedstudio.com>
34
35
36
37 * @version 2.1.0
38
39
40
41 * @license MIT <http://opensource.org/licenses/MIT>
42
43
44
45 */
46 'use strict';
47
48
49
50
51 //Make sure jQuery has been loaded before app.js
52
53
54
55 if (typeof jQuery === "undefined") {
56
57
58
59 throw new Error("AdminLTE requires jQuery");
60
61
62
63 }
64
65
66
67
68 /* AdminLTE
69
70
71
72 *
73
74
75
76 * @type Object
77
78
79
80 * @description $.AdminLTE is the main object for the template's app.
81
82
83
84 * It's used for implementing functions and options related
85
86
87
88 * to the template. Keeping everything wrapped in an object
89
90
91
92 * prevents conflict with other plugins and is a better
93
94
95
96 * way to organize our code.
97
98
99
100 */
101
102
103
104 $.AdminLTE = {};
105
106
107
108
109 /* --------------------
110
111
112
113 * - AdminLTE Options -
114
115
116
117 * --------------------
118
119
120
121 * Modify these options to suit your implementation
122
123
124
125 */
126
127
128
129 $.AdminLTE.options = {
130
131
132
133 //Add slimscroll to navbar menus
134
135
136
137 //This requires you to load the slimscroll plugin
138
139
140
141 //in every page before app.js
142
143
144
145 navbarMenuSlimscroll: true,
146
147
148
149 navbarMenuSlimscrollWidth: "3px", //The width of the scroll bar
150
151
152
153 navbarMenuHeight: "200px", //The height of the inner menu
154
155
156
157 //Sidebar push menu toggle button selector
158
159
160
161 sidebarToggleSelector: "[data-toggle='offcanvas']",
162
163
164
165 //Activate sidebar push menu
166
167
168
169 sidebarPushMenu: true,
170
171
172
173 //Activate sidebar slimscroll if the fixed layout is set (requires SlimScroll Plugin)
174
175
176
177 sidebarSlimScroll: true,
178
179
180
181 //Enable sidebar expand on hover effect for sidebar mini
182
183
184
185 //This option is forced to true if both the fixed layout and sidebar mini
186
187
188
189 //are used together
190
191
192
193 sidebarExpandOnHover: false,
194
195
196
197 //BoxRefresh Plugin
198
199
200
201 enableBoxRefresh: true,
202
203
204
205 //Bootstrap.js tooltip
206
207
208
209 enableBSToppltip: true,
210
211
212
213 BSTooltipSelector: "[data-toggle='tooltip']",
214
215
216
217 //Enable Fast Click. Fastclick.js creates a more
218
219
220
221 //native touch experience with touch devices. If you
222
223
224
225 //choose to enable the plugin, make sure you load the script
226
227
228
229 //before AdminLTE's app.js
230
231
232
233 enableFastclick: true,
234
235
236
237 //Control Sidebar Options
238
239
240
241 enableControlSidebar: true,
242
243
244
245 controlSidebarOptions: {
246
247
248
249 //Which button should trigger the open/close event
250
251
252
253 toggleBtnSelector: "[data-toggle='control-sidebar']",
254
255
256
257 //The sidebar selector
258
259
260
261 selector: ".control-sidebar",
262
263
264
265 //Enable slide over content
266
267
268
269 slide: true
270
271
272
273 },
274
275
276
277 //Box Widget Plugin. Enable this plugin
278
279
280
281 //to allow boxes to be collapsed and/or removed
282
283
284
285 enableBoxWidget: true,
286
287
288
289 //Box Widget plugin options
290
291
292
293 boxWidgetOptions: {
294
295
296
297 boxWidgetIcons: {
298
299
300
301 //Collapse icon
302
303
304
305 collapse: 'fa-minus',
306
307
308
309 //Open icon
310
311
312
313 open: 'fa-plus',
314
315
316
317 //Remove icon
318
319
320
321 remove: 'fa-times'
322
323
324
325 },
326
327
328
329 boxWidgetSelectors: {
330
331
332
333 //Remove button selector
334
335
336
337 remove: '[data-widget="remove"]',
338
339
340
341 //Collapse button selector
342
343
344
345 collapse: '[data-widget="collapse"]'
346
347
348
349 }
350
351
352
353 },
354
355
356
357 //Direct Chat plugin options
358
359
360
361 directChat: {
362
363
364
365 //Enable direct chat by default
366
367
368
369 enable: true,
370
371
372
373 //The button to open and close the chat contacts pane
374
375
376
377 contactToggleSelector: '[data-widget="chat-pane-toggle"]'
378
379
380
381 },
382
383
384
385 //Define the set of colors to use globally around the website
386
387
388
389 colors: {
390
391
392
393 lightBlue: "#3c8dbc",
394
395
396
397 red: "#f56954",
398
399
400
401 green: "#00a65a",
402
403
404
405 aqua: "#00c0ef",
406
407
408
409 yellow: "#f39c12",
410
411
412
413 blue: "#0073b7",
414
415
416
417 navy: "#001F3F",
418
419
420
421 teal: "#39CCCC",
422
423
424
425 olive: "#3D9970",
426
427
428
429 lime: "#01FF70",
430
431
432
433 orange: "#FF851B",
434
435
436
437 fuchsia: "#F012BE",
438
439
440
441 purple: "#8E24AA",
442
443
444
445 maroon: "#D81B60",
446
447
448
449 black: "#222222",
450
451
452
453 gray: "#d2d6de"
454
455
456
457 },
458
459
460
461 //The standard screen sizes that bootstrap uses.
462
463
464
465 //If you change these in the variables.less file, change
466
467
468
469 //them here too.
470
471
472
473 screenSizes: {
474
475
476
477 xs: 480,
478
479
480
481 sm: 768,
482
483
484
485 md: 992,
486
487
488
489 lg: 1200
490
491
492
493 }
494
495
496
497 };
498
499
500
501
502 /* ------------------
503
504
505
506 * - Implementation -
507
508
509
510 * ------------------
511
512
513
514 * The next block of code implements AdminLTE's
515
516
517
518 * functions and plugins as specified by the
519
520
521
522 * options above.
523
524
525
526 */
527
528
529
530 $(function() {
531
532
533
534 //Extend options if external options exist
535
536
537
538 if (typeof AdminLTEOptions !== "undefined") {
539
540
541
542 $.extend(true,
543
544
545
546 $.AdminLTE.options,
547
548
549
550 AdminLTEOptions);
551
552
553
554 }
555
556
557
558
559 //Easy access to options
560
561
562
563 var o = $.AdminLTE.options;
564
565
566
567
568 //Set up the object
569
570
571
572 _init();
573
574
575
576
577 //Activate the layout maker
578
579
580
581 $.AdminLTE.layout.activate();
582
583
584
585
586 //Enable sidebar tree view controls
587
588
589
590 $.AdminLTE.tree('.sidebar');
591
592
593
594
595 //Enable control sidebar
596
597
598
599 if (o.enableControlSidebar) {
600
601
602
603 $.AdminLTE.controlSidebar.activate();
604
605
606
607 }
608
609
610
611
612 //Add slimscroll to navbar dropdown
613
614
615
616 if (o.navbarMenuSlimscroll && typeof $.fn.slimscroll != 'undefined') {
617
618
619
620 $(".navbar .menu").slimscroll({
621
622
623
624 height: o.navbarMenuHeight,
625
626
627
628 alwaysVisible: false,
629
630
631
632 size: o.navbarMenuSlimscrollWidth
633
634
635
636 }).css("width", "100%");
637
638
639
640 }
641
642
643
644
645 //Activate sidebar push menu
646
647
648
649 if (o.sidebarPushMenu) {
650
651
652
653 $.AdminLTE.pushMenu.activate(o.sidebarToggleSelector);
654
655
656
657 }
658
659
660
661
662 //Activate Bootstrap tooltip
663
664
665
666 if (o.enableBSToppltip) {
667
668
669
670 $('body').tooltip({
671
672
673
674 selector: o.BSTooltipSelector
675
676
677
678 });
679
680
681
682 }
683
684
685
686
687 //Activate box widget
688
689
690
691 if (o.enableBoxWidget) {
692
693
694
695 $.AdminLTE.boxWidget.activate();
696
697
698
699 }
700
701
702
703
704 //Activate fast click
705
706
707
708 if (o.enableFastclick && typeof FastClick != 'undefined') {
709
710
711
712 FastClick.attach(document.body);
713
714
715
716 }
717
718
719
720
721 //Activate direct chat widget
722
723
724
725 if (o.directChat.enable) {
726
727
728
729 $(o.directChat.contactToggleSelector).on('click', function() {
730
731
732
733 var box = $(this).parents('.direct-chat').first();
734
735
736
737 box.toggleClass('direct-chat-contacts-open');
738
739
740
741 });
742
743
744
745 }
746
747
748
749
750 /*
751
752
753
754 * INITIALIZE BUTTON TOGGLE
755
756
757
758 * ------------------------
759
760
761
762 */
763
764
765
766 $('.btn-group[data-toggle="btn-toggle"]').each(function() {
767
768
769
770 var group = $(this);
771
772
773
774 $(this).find(".btn").on('click', function(e) {
775
776
777
778 group.find(".btn.active").removeClass("active");
779
780
781
782 $(this).addClass("active");
783
784
785
786 e.preventDefault();
787
788
789
790 });
791
792
793
794
795 });
796
797
798
799 });
800
801
802
803
804 /* ----------------------------------
805
806
807
808 * - Initialize the AdminLTE Object -
809
810
811
812 * ----------------------------------
813
814
815
816 * All AdminLTE functions are implemented below.
817
818
819
820 */
821
822
823
824 function _init() {
825
826
827
828
829 /* Layout
830
831
832
833 * ======
834
835
836
837 * Fixes the layout height in case min-height fails.
838
839
840
841 *
842
843
844
845 * @type Object
846
847
848
849 * @usage $.AdminLTE.layout.activate()
850
851
852
853 * $.AdminLTE.layout.fix()
854
855
856
857 * $.AdminLTE.layout.fixSidebar()
858
859
860
861 */
862
863
864
865 $.AdminLTE.layout = {
866
867
868
869 activate: function() {
870
871
872
873 var _this = this;
874
875
876
877 _this.fix();
878
879
880
881 _this.fixSidebar();
882
883
884
885 $(window, ".wrapper").resize(function() {
886
887
888
889 _this.fix();
890
891
892
893 _this.fixSidebar();
894
895
896
897 });
898
899
900
901 },
902
903
904
905 fix: function() {
906
907
908
909 //Get window height and the wrapper height
910
911
912
913 var neg = $('.main-header').outerHeight() + $('.main-footer').outerHeight();
914
915
916
917 var window_height = $(window).height();
918
919
920
921 var sidebar_height = $(".sidebar").height();
922
923
924
925 //Set the min-height of the content and sidebar based on the
926
927
928
929 //the height of the document.
930
931
932
933 if ($("body").hasClass("fixed")) {
934
935
936
937 $(".content-wrapper, .right-side").css('min-height', window_height - $('.main-footer').outerHeight());
938
939
940
941 } else {
942
943
944
945 var postSetWidth;
946
947
948
949 if (window_height >= sidebar_height) {
950
951
952
953 $(".content-wrapper, .right-side").css('min-height', window_height - neg);
954
955
956
957 postSetWidth = window_height - neg;
958
959
960
961 } else {
962
963
964
965 $(".content-wrapper, .right-side").css('min-height', sidebar_height);
966
967
968
969 postSetWidth = sidebar_height;
970
971
972
973 }
974
975
976
977
978 //Fix for the control sidebar height
979
980
981
982 var controlSidebar = $($.AdminLTE.options.controlSidebarOptions.selector);
983
984
985
986 if (typeof controlSidebar !== "undefined") {
987
988
989
990 if (controlSidebar.height() > postSetWidth)
991
992
993
994 $(".content-wrapper, .right-side").css('min-height', controlSidebar.height());
995
996
997
998 }
999
1000
1001
1002
1003 }
1004
1005
1006
1007 },
1008
1009
1010
1011 fixSidebar: function() {
1012
1013
1014
1015 //Make sure the body tag has the .fixed class
1016
1017
1018
1019 if (!$("body").hasClass("fixed")) {
1020
1021
1022
1023 if (typeof $.fn.slimScroll != 'undefined') {
1024
1025
1026
1027 $(".sidebar").slimScroll({
1028 destroy: true
1029 }).height("auto");
1030
1031
1032
1033 }
1034
1035
1036
1037 return;
1038
1039
1040
1041 } else if (typeof $.fn.slimScroll == 'undefined' && console) {
1042
1043
1044
1045 console.error("Error: the fixed layout requires the slimscroll plugin!");
1046
1047
1048
1049 }
1050
1051
1052
1053 //Enable slimscroll for fixed layout
1054
1055
1056
1057 if ($.AdminLTE.options.sidebarSlimScroll) {
1058
1059
1060
1061 if (typeof $.fn.slimScroll != 'undefined') {
1062
1063
1064
1065 //Destroy if it exists
1066
1067
1068
1069 $(".sidebar").slimScroll({
1070 destroy: true
1071 }).height("auto");
1072
1073
1074
1075 //Add slimscroll
1076
1077
1078
1079 $(".sidebar").slimscroll({
1080
1081
1082
1083 height: ($(window).height() - $(".main-header").height()) + "px",
1084
1085
1086
1087 color: "rgba(0,0,0,0.2)",
1088
1089
1090
1091 size: "3px"
1092
1093
1094
1095 });
1096
1097
1098
1099 }
1100
1101
1102
1103 }
1104
1105
1106
1107 }
1108
1109
1110
1111 };
1112
1113
1114
1115
1116 /* PushMenu()
1117
1118
1119
1120 * ==========
1121
1122
1123
1124 * Adds the push menu functionality to the sidebar.
1125
1126
1127
1128 *
1129
1130
1131
1132 * @type Function
1133
1134
1135
1136 * @usage: $.AdminLTE.pushMenu("[data-toggle='offcanvas']")
1137
1138
1139
1140 */
1141
1142
1143
1144 $.AdminLTE.pushMenu = {
1145
1146
1147
1148 activate: function(toggleBtn) {
1149
1150
1151
1152 //Get the screen sizes
1153
1154
1155
1156 var screenSizes = $.AdminLTE.options.screenSizes;
1157
1158
1159
1160
1161 //Enable sidebar toggle
1162
1163
1164
1165 $(toggleBtn).on('click', function(e) {
1166
1167
1168
1169 e.preventDefault();
1170
1171
1172
1173
1174 //Enable sidebar push menu
1175
1176
1177
1178 if ($(window).width() > (screenSizes.sm - 1)) {
1179
1180
1181
1182 $("body").toggleClass('sidebar-collapse');
1183
1184
1185
1186 }
1187
1188
1189
1190 //Handle sidebar push menu for small screens
1191 else {
1192
1193
1194
1195 if ($("body").hasClass('sidebar-open')) {
1196
1197
1198
1199 $("body").removeClass('sidebar-open');
1200
1201
1202
1203 $("body").removeClass('sidebar-collapse')
1204
1205
1206
1207 } else {
1208
1209
1210
1211 $("body").addClass('sidebar-open');
1212
1213
1214
1215 }
1216
1217
1218
1219 }
1220
1221
1222
1223 });
1224
1225
1226
1227
1228 $(".content-wrapper").click(function() {
1229
1230
1231
1232 //Enable hide menu when clicking on the content-wrapper on small screens
1233
1234
1235
1236 if ($(window).width() <= (screenSizes.sm - 1) && $("body").hasClass("sidebar-open")) {
1237
1238
1239
1240 $("body").removeClass('sidebar-open');
1241
1242
1243
1244 }
1245
1246
1247
1248 });
1249
1250
1251
1252
1253 //Enable expand on hover for sidebar mini
1254
1255
1256
1257 if ($.AdminLTE.options.sidebarExpandOnHover
1258
1259
1260
1261 ||
1262 ($('body').hasClass('fixed')
1263
1264
1265
1266 &&
1267 $('body').hasClass('sidebar-mini'))) {
1268
1269
1270
1271 this.expandOnHover();
1272
1273
1274
1275 }
1276
1277
1278
1279
1280 },
1281
1282
1283
1284 expandOnHover: function() {
1285
1286
1287
1288 var _this = this;
1289
1290
1291
1292 var screenWidth = $.AdminLTE.options.screenSizes.sm - 1;
1293
1294
1295
1296 //Expand sidebar on hover
1297
1298
1299
1300 $('.main-sidebar').hover(function() {
1301
1302
1303
1304 if ($('body').hasClass('sidebar-mini')
1305
1306
1307
1308 &&
1309 $("body").hasClass('sidebar-collapse')
1310
1311
1312
1313 &&
1314 $(window).width() > screenWidth) {
1315
1316
1317
1318 _this.expand();
1319
1320
1321
1322 }
1323
1324
1325
1326 }, function() {
1327
1328
1329
1330 if ($('body').hasClass('sidebar-mini')
1331
1332
1333
1334 &&
1335 $('body').hasClass('sidebar-expanded-on-hover')
1336
1337
1338
1339 &&
1340 $(window).width() > screenWidth) {
1341
1342
1343
1344 _this.collapse();
1345
1346
1347
1348 }
1349
1350
1351
1352 });
1353
1354
1355
1356 },
1357
1358
1359
1360 expand: function() {
1361
1362
1363
1364 $("body").removeClass('sidebar-collapse').addClass('sidebar-expanded-on-hover');
1365
1366
1367
1368 },
1369
1370
1371
1372 collapse: function() {
1373
1374
1375
1376 if ($('body').hasClass('sidebar-expanded-on-hover')) {
1377
1378
1379
1380 $('body').removeClass('sidebar-expanded-on-hover').addClass('sidebar-collapse');
1381
1382
1383
1384 }
1385
1386
1387
1388 }
1389
1390
1391
1392 };
1393
1394
1395
1396
1397 /* Tree()
1398
1399
1400
1401 * ======
1402
1403
1404
1405 * Converts the sidebar into a multilevel
1406
1407
1408
1409 * tree view menu.
1410
1411
1412
1413 *
1414
1415
1416
1417 * @type Function
1418
1419
1420
1421 * @Usage: $.AdminLTE.tree('.sidebar')
1422
1423
1424
1425 */
1426
1427
1428
1429 $.AdminLTE.tree = function(menu) {
1430
1431
1432
1433 var _this = this;
1434
1435
1436
1437
1438 $("li a", $(menu)).on('click', function(e) {
1439
1440
1441
1442 //Get the clicked link and the next element
1443
1444
1445
1446 var $this = $(this);
1447
1448
1449
1450 var checkElement = $this.next();
1451
1452
1453
1454
1455 //Check if the next element is a menu and is visible
1456
1457
1458
1459 if ((checkElement.is('.treeview-menu')) && (checkElement.is(':visible'))) {
1460
1461
1462
1463 //Close the menu
1464
1465
1466
1467 checkElement.slideUp('normal', function() {
1468
1469
1470
1471 checkElement.removeClass('menu-open');
1472
1473
1474
1475 //Fix the layout in case the sidebar stretches over the height of the window
1476
1477
1478
1479 //_this.layout.fix();
1480
1481
1482
1483 });
1484
1485
1486
1487 checkElement.parent("li").removeClass("active");
1488
1489
1490
1491 }
1492
1493
1494
1495 //If the menu is not visible
1496 else if ((checkElement.is('.treeview-menu')) && (!checkElement.is(':visible'))) {
1497
1498
1499
1500 //Get the parent menu
1501
1502
1503
1504 var parent = $this.parents('ul').first();
1505
1506
1507
1508 //Close all open menus within the parent
1509
1510
1511
1512 var ul = parent.find('ul:visible').slideUp('normal');
1513
1514
1515
1516 //Remove the menu-open class from the parent
1517
1518
1519
1520 ul.removeClass('menu-open');
1521
1522
1523
1524 //Get the parent li
1525
1526
1527
1528 var parent_li = $this.parent("li");
1529
1530
1531
1532
1533 //Open the target menu and add the menu-open class
1534
1535
1536
1537 checkElement.slideDown('normal', function() {
1538
1539
1540
1541 //Add the class active to the parent li
1542
1543
1544
1545 checkElement.addClass('menu-open');
1546
1547
1548
1549 parent.find('li.active').removeClass('active');
1550
1551
1552
1553 parent_li.addClass('active');
1554
1555
1556
1557 //Fix the layout in case the sidebar stretches over the height of the window
1558
1559
1560
1561 _this.layout.fix();
1562
1563
1564
1565 });
1566
1567
1568
1569 }
1570
1571
1572
1573 //if this isn't a link, prevent the page from being redirected
1574
1575
1576
1577 if (checkElement.is('.treeview-menu')) {
1578
1579
1580
1581 e.preventDefault();
1582
1583
1584
1585 }
1586
1587
1588
1589 });
1590
1591
1592
1593 };
1594
1595
1596
1597
1598 /* ControlSidebar
1599
1600
1601
1602 * ==============
1603
1604
1605
1606 * Adds functionality to the right sidebar
1607
1608
1609
1610 *
1611
1612
1613
1614 * @type Object
1615
1616
1617
1618 * @usage $.AdminLTE.controlSidebar.activate(options)
1619
1620
1621
1622 */
1623
1624
1625
1626 $.AdminLTE.controlSidebar = {
1627
1628
1629
1630 //instantiate the object
1631
1632
1633
1634 activate: function() {
1635
1636
1637
1638 //Get the object
1639
1640
1641
1642 var _this = this;
1643
1644
1645
1646 //Update options
1647
1648
1649
1650 var o = $.AdminLTE.options.controlSidebarOptions;
1651
1652
1653
1654 //Get the sidebar
1655
1656
1657
1658 var sidebar = $(o.selector);
1659
1660
1661
1662 //The toggle button
1663
1664
1665
1666 var btn = $(o.toggleBtnSelector);
1667
1668
1669
1670
1671 //Listen to the click event
1672
1673
1674
1675 btn.on('click', function(e) {
1676
1677
1678
1679 e.preventDefault();
1680
1681
1682
1683 //If the sidebar is not open
1684
1685
1686
1687 if (!sidebar.hasClass('control-sidebar-open')
1688
1689
1690
1691 &&
1692 !$('body').hasClass('control-sidebar-open')) {
1693
1694
1695
1696 //Open the sidebar
1697
1698
1699
1700 _this.open(sidebar, o.slide);
1701
1702
1703
1704 } else {
1705
1706
1707
1708 _this.close(sidebar, o.slide);
1709
1710
1711
1712 }
1713
1714
1715
1716 });
1717
1718
1719
1720
1721 //If the body has a boxed layout, fix the sidebar bg position
1722
1723
1724
1725 var bg = $(".control-sidebar-bg");
1726
1727
1728
1729 _this._fix(bg);
1730
1731
1732
1733
1734 //If the body has a fixed layout, make the control sidebar fixed
1735
1736
1737
1738 if ($('body').hasClass('fixed')) {
1739
1740
1741
1742 _this._fixForFixed(sidebar);
1743
1744
1745
1746 } else {
1747
1748
1749
1750 //If the content height is less than the sidebar's height, force max height
1751
1752
1753
1754 if ($('.content-wrapper, .right-side').height() < sidebar.height()) {
1755
1756
1757
1758 _this._fixForContent(sidebar);
1759
1760
1761
1762 }
1763
1764
1765
1766 }
1767
1768
1769
1770 },
1771
1772
1773
1774 //Open the control sidebar
1775
1776
1777
1778 open: function(sidebar, slide) {
1779
1780
1781
1782 var _this = this;
1783
1784
1785
1786 //Slide over content
1787
1788
1789
1790 if (slide) {
1791
1792
1793
1794 sidebar.addClass('control-sidebar-open');
1795
1796
1797
1798 } else {
1799
1800
1801
1802 //Push the content by adding the open class to the body instead
1803
1804
1805
1806 //of the sidebar itself
1807
1808
1809
1810 $('body').addClass('control-sidebar-open');
1811
1812
1813
1814 }
1815
1816
1817
1818 },
1819
1820
1821
1822 //Close the control sidebar
1823
1824
1825
1826 close: function(sidebar, slide) {
1827
1828
1829
1830 if (slide) {
1831
1832
1833
1834 sidebar.removeClass('control-sidebar-open');
1835
1836
1837
1838 } else {
1839
1840
1841
1842 $('body').removeClass('control-sidebar-open');
1843
1844
1845
1846 }
1847
1848
1849
1850 },
1851
1852
1853
1854 _fix: function(sidebar) {
1855
1856
1857
1858 var _this = this;
1859
1860
1861
1862 if ($("body").hasClass('layout-boxed')) {
1863
1864
1865
1866 sidebar.css('position', 'absolute');
1867
1868
1869
1870 sidebar.height($(".wrapper").height());
1871
1872
1873
1874 $(window).resize(function() {
1875
1876
1877
1878 _this._fix(sidebar);
1879
1880
1881
1882 });
1883
1884
1885
1886 } else {
1887
1888
1889
1890 sidebar.css({
1891
1892
1893
1894 'position': 'fixed',
1895
1896
1897
1898 'height': 'auto'
1899
1900
1901
1902 });
1903
1904
1905
1906 }
1907
1908
1909
1910 },
1911
1912
1913
1914 _fixForFixed: function(sidebar) {
1915
1916
1917
1918 sidebar.css({
1919
1920
1921
1922 'position': 'fixed',
1923
1924
1925
1926 'max-height': '100%',
1927
1928
1929
1930 'overflow': 'auto',
1931
1932
1933
1934 'padding-bottom': '50px'
1935
1936
1937
1938 });
1939
1940
1941
1942 },
1943
1944
1945
1946 _fixForContent: function(sidebar) {
1947
1948
1949
1950 $(".content-wrapper, .right-side").css('min-height', sidebar.height());
1951
1952
1953
1954 }
1955
1956
1957
1958 };
1959
1960
1961
1962
1963 /* BoxWidget
1964
1965
1966
1967 * =========
1968
1969
1970
1971 * BoxWidget is a plugin to handle collapsing and
1972
1973
1974
1975 * removing boxes from the screen.
1976
1977
1978
1979 *
1980
1981
1982
1983 * @type Object
1984
1985
1986
1987 * @usage $.AdminLTE.boxWidget.activate()
1988
1989
1990
1991 * Set all your options in the main $.AdminLTE.options object
1992
1993
1994
1995 */
1996
1997
1998
1999 $.AdminLTE.boxWidget = {
2000
2001
2002
2003 selectors: $.AdminLTE.options.boxWidgetOptions.boxWidgetSelectors,
2004
2005
2006
2007 icons: $.AdminLTE.options.boxWidgetOptions.boxWidgetIcons,
2008
2009
2010
2011 activate: function() {
2012
2013
2014
2015 var _this = this;
2016
2017
2018
2019 //Listen for collapse event triggers
2020
2021
2022
2023 $(_this.selectors.collapse).on('click', function(e) {
2024
2025
2026
2027 e.preventDefault();
2028
2029
2030
2031 _this.collapse($(this));
2032
2033
2034
2035 });
2036
2037
2038
2039
2040 //Listen for remove event triggers
2041
2042
2043
2044 $(_this.selectors.remove).on('click', function(e) {
2045
2046
2047
2048 e.preventDefault();
2049
2050
2051
2052 _this.remove($(this));
2053
2054
2055
2056 });
2057
2058
2059
2060 },
2061
2062
2063
2064 collapse: function(element) {
2065
2066
2067
2068 var _this = this;
2069
2070
2071
2072 //Find the box parent
2073
2074
2075
2076 var box = element.parents(".box").first();
2077
2078
2079
2080 //Find the body and the footer
2081
2082
2083
2084 var box_content = box.find("> .box-body, > .box-footer");
2085
2086
2087
2088 if (!box.hasClass("collapsed-box")) {
2089
2090
2091
2092 //Convert minus into plus
2093
2094
2095
2096 element.children(":first")
2097
2098
2099
2100 .removeClass(_this.icons.collapse)
2101
2102
2103
2104 .addClass(_this.icons.open);
2105
2106
2107
2108 //Hide the content
2109
2110
2111
2112 box_content.slideUp(300, function() {
2113
2114
2115
2116 box.addClass("collapsed-box");
2117
2118
2119
2120 });
2121
2122
2123
2124 } else {
2125
2126
2127
2128 //Convert plus into minus
2129
2130
2131
2132 element.children(":first")
2133
2134
2135
2136 .removeClass(_this.icons.open)
2137
2138
2139
2140 .addClass(_this.icons.collapse);
2141
2142
2143
2144 //Show the content
2145
2146
2147
2148 box_content.slideDown(300, function() {
2149
2150
2151
2152 box.removeClass("collapsed-box");
2153
2154
2155
2156 });
2157
2158
2159
2160 }
2161
2162
2163
2164 },
2165
2166
2167
2168 remove: function(element) {
2169
2170
2171
2172 //Find the box parent
2173
2174
2175
2176 var box = element.parents(".box").first();
2177
2178
2179
2180 box.slideUp();
2181
2182
2183
2184 }
2185
2186
2187
2188 };
2189
2190
2191
2192 }
2193
2194
2195
2196
2197 /* ------------------
2198
2199
2200
2201 * - Custom Plugins -
2202
2203
2204
2205 * ------------------
2206
2207
2208
2209 * All custom plugins are defined below.
2210
2211
2212
2213 */
2214
2215
2216
2217
2218 /*
2219
2220
2221
2222 * BOX REFRESH BUTTON
2223
2224
2225
2226 * ------------------
2227
2228
2229
2230 * This is a custom plugin to use with the component BOX. It allows you to add
2231
2232
2233
2234 * a refresh button to the box. It converts the box's state to a loading state.
2235
2236
2237
2238 *
2239
2240
2241
2242 * @type plugin
2243
2244
2245
2246 * @usage $("#box-widget").boxRefresh( options );
2247
2248
2249
2250 */
2251
2252
2253
2254 (function($) {
2255
2256
2257
2258
2259 $.fn.boxRefresh = function(options) {
2260
2261
2262
2263
2264 // Render options
2265
2266
2267
2268 var settings = $.extend({
2269
2270
2271
2272 //Refresh button selector
2273
2274
2275
2276 trigger: ".refresh-btn",
2277
2278
2279
2280 //File source to be loaded (e.g: ajax/src.php)
2281
2282
2283
2284 source: "",
2285
2286
2287
2288 //Callbacks
2289
2290
2291
2292 onLoadStart: function(box) {
2293
2294
2295
2296 }, //Right after the button has been clicked
2297
2298
2299
2300 onLoadDone: function(box) {
2301
2302
2303
2304 } //When the source has been loaded
2305
2306
2307
2308
2309 }, options);
2310
2311
2312
2313
2314 //The overlay
2315
2316
2317
2318 var overlay = $('<div class="overlay"><div class="fa fa-refresh fa-spin"></div></div>');
2319
2320
2321
2322
2323 return this.each(function() {
2324
2325
2326
2327 //if a source is specified
2328
2329
2330
2331 if (settings.source === "") {
2332
2333
2334
2335 if (console) {
2336
2337
2338
2339 console.log("Please specify a source first - boxRefresh()");
2340
2341
2342
2343 }
2344
2345
2346
2347 return;
2348
2349
2350
2351 }
2352
2353
2354
2355 //the box
2356
2357
2358
2359 var box = $(this);
2360
2361
2362
2363 //the button
2364
2365
2366
2367 var rBtn = box.find(settings.trigger).first();
2368
2369
2370
2371
2372 //On trigger click
2373
2374
2375
2376 rBtn.on('click', function(e) {
2377
2378
2379
2380 e.preventDefault();
2381
2382
2383
2384 //Add loading overlay
2385
2386
2387
2388 start(box);
2389
2390
2391
2392
2393 //Perform ajax call
2394
2395
2396
2397 box.find(".box-body").load(settings.source, function() {
2398
2399
2400
2401 done(box);
2402
2403
2404
2405 });
2406
2407
2408
2409 });
2410
2411
2412
2413 });
2414
2415
2416
2417
2418 function start(box) {
2419
2420
2421
2422 //Add overlay and loading img
2423
2424
2425
2426 box.append(overlay);
2427
2428
2429
2430
2431 settings.onLoadStart.call(box);
2432
2433
2434
2435 }
2436
2437
2438
2439
2440 function done(box) {
2441
2442
2443
2444 //Remove overlay and loading img
2445
2446
2447
2448 box.find(overlay).remove();
2449
2450
2451
2452
2453 settings.onLoadDone.call(box);
2454
2455
2456
2457 }
2458
2459
2460
2461
2462 };
2463
2464
2465
2466
2467 })(jQuery);
2468
2469
2470
2471
2472 /* Pnotify function */