1/** 2 * Main JavaScript File 3 * Subversion: "4Buubci5RNr1El9/q9YDlCSjeBaFFrZxTipKD/LGTYE=" 4 **/ 5 6var public_vars = public_vars || {}; 7 8;(function($, window, undefined){ 9 10 "use strict"; 11 12 $(document).ready(function() 13 { 14 // Sidebar Menu var 15 public_vars.$body = $("body"); 16 public_vars.$pageContainer = public_vars.$body.find(".page-container"); 17 public_vars.$chat = public_vars.$pageContainer.find('#chat'); 18 public_vars.$horizontalMenu = public_vars.$pageContainer.find('header.navbar'); 19 public_vars.$sidebarMenu = public_vars.$pageContainer.find('.sidebar-menu'); 20 public_vars.$mainMenu = public_vars.$sidebarMenu.find('#main-menu'); 21 public_vars.$mainContent = public_vars.$pageContainer.find('.main-content'); 22 public_vars.$sidebarUserEnv = public_vars.$sidebarMenu.find('.sidebar-user-info'); 23 public_vars.$sidebarUser = public_vars.$sidebarUserEnv.find('.user-link'); 24 25 26 public_vars.$body.addClass('loaded'); 27 28 // Just to make sure... 29 $(window).on('error', function(ev) 30 { 31 // Do not let page without showing if JS fails somewhere 32 init_page_transitions(); 33 }); 34 35 if(public_vars.$pageContainer.hasClass('right-sidebar')) 36 { 37 public_vars.isRightSidebar = true; 38 } 39 40 41 42 43 // Sidebar Menu Setup 44 setup_sidebar_menu(); 45 46 47 48 49 // Horizontal Menu Setup 50 setup_horizontal_menu(); 51 52 53 54 55 // Sidebar Collapse icon 56 public_vars.$sidebarMenu.find(".sidebar-collapse-icon").on('click', function(ev) 57 { 58 ev.preventDefault(); 59 60 var with_animation = $(this).hasClass('with-animation'); 61 62 toggle_sidebar_menu(with_animation); 63 }); 64 65 66 67 68 // Mobile Sidebar Collapse icon 69 public_vars.$sidebarMenu.find(".sidebar-mobile-menu a").on('click', function(ev) 70 { 71 ev.preventDefault(); 72 73 var with_animation = $(this).hasClass('with-animation'); 74 75 if(with_animation) 76 { 77 public_vars.$mainMenu.stop().slideToggle('normal', function() 78 { 79 public_vars.$mainMenu.css('height', 'auto'); 80 }); 81 } 82 else 83 { 84 public_vars.$mainMenu.toggle(); 85 } 86 }); 87 88 89 90 91 // Mobile Horizontal Menu Collapse icon 92 public_vars.$horizontalMenu.find(".horizontal-mobile-menu a").on('click', function(ev) 93 { 94 ev.preventDefault(); 95 96 var $menu = public_vars.$horizontalMenu.find('.navbar-nav'), 97 with_animation = $(this).hasClass('with-animation'); 98 99 if(with_animation) 100 { 101 $menu.stop().slideToggle('normal', function() 102 { 103 $menu.attr('height', 'auto'); 104 105 if($menu.css('display') == 'none') 106 { 107 $menu.attr('style', ''); 108 } 109 }); 110 } 111 else 112 { 113 $menu.toggle(); 114 } 115 }); 116 117 118 119 120 // Close Sidebar if Tablet Screen is visible 121 public_vars.$sidebarMenu.data('initial-state', (public_vars.$pageContainer.hasClass('sidebar-collapsed') ? 'closed' : 'open')); 122 123 if(is('tabletscreen')) 124 { 125 hide_sidebar_menu(false); 126 } 127 128 129 130 131 // NiceScroll 132 if($.isFunction($.fn.niceScroll)) 133 { 134 var nicescroll_defaults = { 135 cursorcolor: '#d4d4d4', 136 cursorborder: '1px solid #ccc', 137 railpadding: {right: 3}, 138 cursorborderradius: 1, 139 autohidemode: true, 140 sensitiverail: true 141 }; 142 143 public_vars.$body.find('.dropdown .scroller').niceScroll(nicescroll_defaults); 144 145 $(".dropdown").on("shown.bs.dropdown", function () 146 { 147 $(".scroller").getNiceScroll().resize(); 148 $(".scroller").getNiceScroll().show(); 149 }); 150 151 var fixed_sidebar = $(".sidebar-menu.fixed"); 152 153 if(fixed_sidebar.length == 1) 154 { 155 var fs_tm = 0; 156 157 fixed_sidebar.niceScroll({ 158 cursorcolor: '#454a54', 159 cursorborder: '1px solid #454a54', 160 railpadding: {right: 3}, 161 railalign: 'right', 162 cursorborderradius: 1 163 }); 164 165 fixed_sidebar.on('click', 'li a', function() 166 { 167 fixed_sidebar.getNiceScroll().resize(); 168 fixed_sidebar.getNiceScroll().show(); 169 170 window.clearTimeout(fs_tm); 171 172 fs_tm = setTimeout(function() 173 { 174 fixed_sidebar.getNiceScroll().resize(); 175 }, 500); 176 }); 177 } 178 } 179 180 181 182 183 // Scrollable 184 if($.isFunction($.fn.slimScroll)) 185 { 186 $(".scrollable").each(function(i, el) 187 { 188 var $this = $(el), 189 height = attrDefault($this, 'height', $this.height()); 190 191 if($this.is(':visible')) 192 { 193 $this.removeClass('scrollable'); 194 195 if($this.height() < parseInt(height, 10)) 196 { 197 height = $this.outerHeight(true) + 10; 198 } 199 200 $this.addClass('scrollable'); 201 } 202 203 $this.css({maxHeight: ''}).slimScroll({ 204 height: height, 205 position: attrDefault($this, 'scroll-position', 'right'), 206 color: attrDefault($this, 'rail-color', '#000'), 207 size: attrDefault($this, 'rail-width', 6), 208 borderRadius: attrDefault($this, 'rail-radius', 3), 209 opacity: attrDefault($this, 'rail-opacity', .3), 210 alwaysVisible: parseInt(attrDefault($this, 'autohide', 1), 10) == 1 ? false : true 211 }); 212 }); 213 } 214 215 216 217 218 // Panels 219 220 // Added on v1.1.4 - Fixed collapsing effect with panel tables 221 $(".panel-heading").each(function(i, el) 222 { 223 var $this = $(el), 224 $body = $this.next('table'); 225 226 $body.wrap('<div class="panel-body with-table"></div>'); 227 228 $body = $this.next('.with-table').next('table'); 229 $body.wrap('<div class="panel-body with-table"></div>'); 230 231 }); 232 233 continueWrappingPanelTables(); 234 // End of: Added on v1.1.4 235 236 237 $('body').on('click', '.panel > .panel-heading > .panel-options > a[data-rel="reload"]', function(ev) 238 { 239 ev.preventDefault(); 240 241 var $this = jQuery(this).closest('.panel'); 242 243 blockUI($this); 244 $this.addClass('reloading'); 245 246 setTimeout(function() 247 { 248 unblockUI($this) 249 $this.removeClass('reloading'); 250 251 }, 900); 252 253 }).on('click', '.panel > .panel-heading > .panel-options > a[data-rel="close"]', function(ev) 254 { 255 ev.preventDefault(); 256 257 var $this = $(this), 258 $panel = $this.closest('.panel'); 259 260 var t = new TimelineLite({ 261 onComplete: function() 262 { 263 $panel.slideUp(function() 264 { 265 $panel.remove(); 266 });
267 } 268 }); 269 270 t.append( TweenMax.to($panel, .2, {css: {scale: 0.95}}) ); 271 t.append( TweenMax.to($panel, .5, {css: {autoAlpha: 0, transform: "translateX(100px) scale(.95)"}}) ); 272 273 }).on('click', '.panel > .panel-heading > .panel-options > a[data-rel="collapse"]', function(ev) 274 { 275 ev.preventDefault(); 276 277 var $this = $(this), 278 $panel = $this.closest('.panel'), 279 $body = $panel.children('.panel-body, .table'), 280 do_collapse = ! $panel.hasClass('panel-collapse'); 281 282 if($panel.is('[data-collapsed="1"]')) 283 { 284 $panel.attr('data-collapsed', 0); 285 $body.hide(); 286 do_collapse = false; 287 } 288 289 if(do_collapse) 290 { 291 $body.slideUp('normal', fit_main_content_height); 292 $panel.addClass('panel-collapse'); 293 } 294 else 295 { 296 $body.slideDown('normal', fit_main_content_height); 297 $panel.removeClass('panel-collapse'); 298 } 299 }); 300 301 302 303 304 // Data Toggle for Radio and Checkbox Elements 305 $('[data-toggle="buttons-radio"]').each(function() 306 { 307 var $buttons = $(this).children(); 308 309 $buttons.each(function(i, el) 310 { 311 var $this = $(el); 312 313 $this.click(function(ev) 314 { 315 $buttons.removeClass('active'); 316 }); 317 }); 318 }); 319 320 $('[data-toggle="buttons-checkbox"]').each(function() 321 { 322 var $buttons = $(this).children(); 323 324 $buttons.each(function(i, el) 325 { 326 var $this = $(el); 327 328 $this.click(function(ev) 329 { 330 $this.removeClass('active'); 331 }); 332 }); 333 }); 334 335 $('[data-loading-text]').each(function(i, el) // Temporary for demo purpose only 336 { 337 var $this = $(el); 338 339 $this.on('click', function(ev) 340 { 341 $this.button('loading'); 342 343 setTimeout(function(){ $this.button('reset'); }, 1800); 344 }); 345 }); 346 347 348 349 350 // Popovers and tooltips 351 $('[data-toggle="popover"]').each(function(i, el) 352 { 353 var $this = $(el), 354 placement = attrDefault($this, 'placement', 'right'), 355 trigger = attrDefault($this, 'trigger', 'click'), 356 popover_class = $this.hasClass('popover-secondary') ? 'popover-secondary' : ($this.hasClass('popover-primary') ? 'popover-primary' : ($this.hasClass('popover-default') ? 'popover-default' : '')); 357 358 $this.popover({ 359 placement: placement, 360 trigger: trigger 361 }); 362 363 $this.on('shown.bs.popover', function(ev) 364 { 365 var $popover = $this.next(); 366 367 $popover.addClass(popover_class); 368 }); 369 }); 370 371 $('[data-toggle="tooltip"]').each(function(i, el) 372 { 373 var $this = $(el), 374 placement = attrDefault($this, 'placement', 'top'), 375 trigger = attrDefault($this, 'trigger', 'hover'), 376 popover_class = $this.hasClass('tooltip-secondary') ? 'tooltip-secondary' : ($this.hasClass('tooltip-primary') ? 'tooltip-primary' : ($this.hasClass('tooltip-default') ? 'tooltip-default' : '')); 377 378 $this.tooltip({ 379 placement: placement, 380 trigger: trigger 381 }); 382 383 $this.on('shown.bs.tooltip', function(ev) 384 { 385 var $tooltip = $this.next(); 386 387 $tooltip.addClass(popover_class); 388 }); 389 }); 390 391 392 393 394 // jQuery Knob 395 if($.isFunction($.fn.knob)) 396 { 397 $(".knob").knob({ 398 change: function (value) { 399 }, 400 release: function (value) { 401 }, 402 cancel: function () { 403 }, 404 draw: function () { 405 406 if (this.$.data('skin') == 'tron') { 407 408 var a = this.angle(this.cv) // Angle 409 , 410 sa = this.startAngle // Previous start angle 411 , 412 sat = this.startAngle // Start angle 413 , 414 ea // Previous end angle 415 , eat = sat + a // End angle 416 , 417 r = 1; 418 419 this.g.lineWidth = this.lineWidth; 420 421 this.o.cursor && (sat = eat - 0.3) && (eat = eat + 0.3); 422 423 if (this.o.displayPrevious) { 424 ea = this.startAngle + this.angle(this.v); 425 this.o.cursor && (sa = ea - 0.3) && (ea = ea + 0.3); 426 this.g.beginPath(); 427 this.g.strokeStyle = this.pColor; 428 this.g.arc(this.xy, this.xy, this.radius - this.lineWidth, sa, ea, false); 429 this.g.stroke(); 430 } 431 432 this.g.beginPath(); 433 this.g.strokeStyle = r ? this.o.fgColor : this.fgColor; 434 this.g.arc(this.xy, this.xy, this.radius - this.lineWidth, sat, eat, false); 435 this.g.stroke(); 436 437 this.g.lineWidth = 2; 438 this.g.beginPath(); 439 this.g.strokeStyle = this.o.fgColor; 440 this.g.arc(this.xy, this.xy, this.radius - this.lineWidth + 1 + this.lineWidth * 2 / 3, 0, 2 * Math.PI, false); 441 this.g.stroke(); 442 443 return false; 444 } 445 } 446 }); 447 } 448 449 450 451 452 // Slider 453 if($.isFunction($.fn.slider)) 454 { 455 $(".slider").each(function(i, el) 456 { 457 var $this = $(el), 458 $label_1 = $('<span class="ui-label"></span>'), 459 $label_2 = $label_1.clone(), 460 461 orientation = attrDefault($this, 'vertical', 0) != 0 ? 'vertical' : 'horizontal', 462 463 prefix = attrDefault($this, 'prefix', ''), 464 postfix = attrDefault($this, 'postfix', ''), 465 466 fill = attrDefault($this, 'fill', ''), 467 $fill = $(fill), 468 469 step = attrDefault($this, 'step', 1), 470 value = attrDefault($this, 'value', 5), 471 min = attrDefault($this, 'min', 0), 472 max = attrDefault($this, 'max', 100), 473 min_val = attrDefault($this, 'min-val', 10), 474 max_val = attrDefault($this, 'max-val', 90), 475 476 is_range = $this.is('[data-min-val]') || $this.is('[data-max-val]'), 477 478 reps = 0; 479 480 481 // Range Slider Options 482 if(is_range) 483 { 484 $this.slider({ 485 range: true, 486 orientation: orientation, 487 min: min, 488 max: max, 489 values: [min_val, max_val], 490 step: step, 491 slide: function(e, ui) 492 { 493 var opts = $this.data('uiSlider').options, 494 min_val = (prefix ? prefix : '') + ui.values[0] + (postfix ? postfix : ''), 495 max_val = (prefix ? prefix : '') + ui.values[1] + (postfix ? postfix : ''); 496 497 $label_1.html( min_val ); 498 $label_2.html( max_val ); 499 500 if(fill) 501 $fill.val(min_val + ',' + max_val); 502 503 reps++; 504 }, 505 change: function(ev, ui) 506 { 507 if(reps == 1) 508 { 509 var opts = $this.data('uiSlider').options, 510 min_val = (prefix ? prefix : '') + ui.values[0] + (postfix ? postfix : ''), 511 max_val = (prefix ? prefix : '') + ui.values[1] + (postfix ? postfix : ''); 512 513 $label_1.html( min_val ); 514 $label_2.html( max_val ); 515 516 if(fill) 517 $fill.val(min_val + ',' + max_val); 518 } 519 520 reps = 0; 521 } 522 });
523 524 var $handles = $this.find('.ui-slider-handle'); 525 526 $label_1.html((prefix ? prefix : '') + min_val + (postfix ? postfix : '')); 527 $handles.first().append( $label_1 ); 528 529 $label_2.html((prefix ? prefix : '') + max_val+ (postfix ? postfix : '')); 530 $handles.last().append( $label_2 ); 531 } 532 // Normal Slider 533 else 534 { 535 536 $this.slider({ 537 range: attrDefault($this, 'basic', 0) ? false : "min", 538 orientation: orientation, 539 min: min, 540 max: max, 541 value: value, 542 step: step, 543 slide: function(ev, ui) 544 { 545 var opts = $this.data('uiSlider').options, 546 val = (prefix ? prefix : '') + opts.value + (postfix ? postfix : ''); 547 548 $label_1.html( val ); 549 550 if(fill) 551 $fill.val(val); 552 553 reps++; 554 }, 555 change: function(ev, ui) 556 { 557 if(reps == 1) 558 { 559 var opts = $this.data('uiSlider').options, 560 val = (prefix ? prefix : '') + opts.value + (postfix ? postfix : ''); 561 562 $label_1.html( val ); 563 564 if(fill) 565 $fill.val(val); 566 } 567 568 reps = 0; 569 } 570 }); 571 572 var $handles = $this.find('.ui-slider-handle'); 573 //$fill = $('<div class="ui-fill"></div>'); 574 575 $label_1.html((prefix ? prefix : '') + value + (postfix ? postfix : '')); 576 $handles.html( $label_1 ); 577 578 //$handles.parent().prepend( $fill ); 579 580 //$fill.width($handles.get(0).style.left); 581 } 582 583 }) 584 } 585 586 587 588 589 // Radio Toggle 590 if($.isFunction($.fn.bootstrapSwitch)) 591 { 592 593 $('.make-switch.is-radio').on('switch-change', function () { 594 $('.make-switch.is-radio').bootstrapSwitch('toggleRadioState'); 595 }); 596 } 597 598 599 600 601 // Select2 Dropdown replacement 602 if($.isFunction($.fn.select2)) 603 { 604 $(".select2").each(function(i, el) 605 { 606 var $this = $(el), 607 opts = { 608 allowClear: attrDefault($this, 'allowClear', false) 609 }; 610 611 $this.select2(opts); 612 $this.addClass('visible'); 613 614 //$this.select2("open"); 615 }); 616 617 618 if($.isFunction($.fn.niceScroll)) 619 { 620 $(".select2-results").niceScroll({ 621 cursorcolor: '#d4d4d4', 622 cursorborder: '1px solid #ccc', 623 railpadding: {right: 3} 624 }); 625 } 626 } 627 628 629 630 631 // SelectBoxIt Dropdown replacement 632 if($.isFunction($.fn.selectBoxIt)) 633 { 634 $("select.selectboxit").each(function(i, el) 635 { 636 var $this = $(el), 637 opts = { 638 showFirstOption: attrDefault($this, 'first-option', true), 639 'native': attrDefault($this, 'native', false), 640 defaultText: attrDefault($this, 'text', ''), 641 }; 642 643 $this.addClass('visible'); 644 $this.selectBoxIt(opts); 645 }); 646 } 647 648 649 650 651 // Auto Size for Textarea 652 if($.isFunction($.fn.autosize)) 653 { 654 $("textarea.autogrow, textarea.autosize").autosize(); 655 } 656 657 658 659 660 // Tagsinput 661 if($.isFunction($.fn.tagsinput)) 662 { 663 $(".tagsinput").tagsinput(); 664 } 665 666 667 668 669 // Typeahead 670 if($.isFunction($.fn.typeahead)) 671 { 672 $(".typeahead").each(function(i, el) 673 { 674 var $this = $(el), 675 opts = { 676 name: $this.attr('name') ? $this.attr('name') : ($this.attr('id') ? $this.attr('id') : 'tt') 677 }; 678 679 if($this.hasClass('tagsinput')) 680 return; 681 682 if($this.data('local')) 683 { 684 var local = $this.data('local'); 685 686 local = local.replace(/\s*,\s*/g, ',').split(','); 687 688 opts['local'] = local; 689 } 690 691 if($this.data('prefetch')) 692 { 693 var prefetch = $this.data('prefetch'); 694 695 opts['prefetch'] = prefetch; 696 } 697 698 if($this.data('remote')) 699 { 700 var remote = $this.data('remote'); 701 702 opts['remote'] = remote; 703 } 704 705 if($this.data('template')) 706 { 707 var template = $this.data('template'); 708 709 opts['template'] = template; 710 opts['engine'] = Hogan; 711 } 712 713 $this.typeahead(opts); 714 }); 715 } 716 717 718 719 720 // Datepicker 721 if($.isFunction($.fn.datepicker)) 722 { 723 $(".datepicker").each(function(i, el) 724 { 725 var $this = $(el), 726 opts = { 727 format: attrDefault($this, 'format', 'mm/dd/yyyy'), 728 startDate: attrDefault($this, 'startDate', ''), 729 endDate: attrDefault($this, 'endDate', ''), 730 daysOfWeekDisabled: attrDefault($this, 'disabledDays', ''), 731 startView: attrDefault($this, 'startView', 0), 732 rtl: rtl() 733 }, 734 $n = $this.next(), 735 $p = $this.prev(); 736 737 $this.datepicker(opts); 738 739 if($n.is('.input-group-addon') && $n.has('a')) 740 { 741 $n.on('click', function(ev) 742 { 743 ev.preventDefault(); 744 745 $this.datepicker('show'); 746 });
747 } 748 749 if($p.is('.input-group-addon') && $p.has('a')) 750 { 751 $p.on('click', function(ev) 752 { 753 ev.preventDefault(); 754 755 $this.datepicker('show'); 756 }); 757 } 758 }); 759 } 760 761 762 763 764 // Timepicker 765 if($.isFunction($.fn.timepicker)) 766 { 767 $(".timepicker").each(function(i, el) 768 { 769 var $this = $(el), 770 opts = { 771 template: attrDefault($this, 'template', false), 772 showSeconds: attrDefault($this, 'showSeconds', false), 773 defaultTime: attrDefault($this, 'defaultTime', 'current'), 774 showMeridian: attrDefault($this, 'showMeridian', true), 775 minuteStep: attrDefault($this, 'minuteStep', 15), 776 secondStep: attrDefault($this, 'secondStep', 15) 777 }, 778 $n = $this.next(), 779 $p = $this.prev(); 780 781 $this.timepicker(opts); 782 783 if($n.is('.input-group-addon') && $n.has('a')) 784 { 785 $n.on('click', function(ev) 786 { 787 ev.preventDefault(); 788 789 $this.timepicker('showWidget'); 790 }); 791 } 792 793 if($p.is('.input-group-addon') && $p.has('a')) 794 { 795 $p.on('click', function(ev) 796 { 797 ev.preventDefault(); 798 799 $this.timepicker('showWidget'); 800 }); 801 } 802 }); 803 } 804 805 806 807 808 // Colorpicker 809 if($.isFunction($.fn.colorpicker)) 810 { 811 $(".colorpicker").each(function(i, el) 812 { 813 var $this = $(el), 814 opts = { 815 //format: attrDefault($this, 'format', false) 816 }, 817 $n = $this.next(), 818 $p = $this.prev(), 819 820 $preview = $this.siblings('.input-group-addon').find('.color-preview'); 821 822 $this.colorpicker(opts); 823 824 if($n.is('.input-group-addon') && $n.has('a')) 825 { 826 $n.on('click', function(ev) 827 { 828 ev.preventDefault(); 829 830 $this.colorpicker('show'); 831 }); 832 } 833 834 if($p.is('.input-group-addon') && $p.has('a')) 835 { 836 $p.on('click', function(ev) 837 { 838 ev.preventDefault(); 839 840 $this.colorpicker('show'); 841 }); 842 } 843 844 if($preview.length) 845 { 846 $this.on('changeColor', function(ev){ 847 848 $preview.css('background-color', ev.color.toHex()); 849 }); 850 851 if($this.val().length) 852 { 853 $preview.css('background-color', $this.val()); 854 } 855 } 856 }); 857 } 858 859 860 861 862 // Date Range Picker 863 if($.isFunction($.fn.daterangepicker)) 864 { 865 $(".daterange").each(function(i, el) 866 { 867 // Change the range as you desire 868 var ranges = { 869 'Today': [moment(), moment()], 870 'Yesterday': [moment().subtract('days', 1), moment().subtract('days', 1)], 871 'Last 7 Days': [moment().subtract('days', 6), moment()], 872 'Last 30 Days': [moment().subtract('days', 29), moment()], 873 'This Month': [moment().startOf('month'), moment().endOf('month')], 874 'Last Month': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')] 875 }; 876 877 var $this = $(el), 878 opts = { 879 format: attrDefault($this, 'format', 'MM/DD/YYYY'), 880 timePicker: attrDefault($this, 'timePicker', false), 881 timePickerIncrement: attrDefault($this, 'timePickerIncrement', false), 882 separator: attrDefault($this, 'separator', ' - '), 883 }, 884 min_date = attrDefault($this, 'minDate', ''), 885 max_date = attrDefault($this, 'maxDate', ''), 886 start_date = attrDefault($this, 'startDate', ''), 887 end_date = attrDefault($this, 'endDate', ''); 888 889 if($this.hasClass('add-ranges')) 890 { 891 opts['ranges'] = ranges; 892 } 893 894 if(min_date.length) 895 { 896 opts['minDate'] = min_date; 897 } 898 899 if(max_date.length) 900 { 901 opts['maxDate'] = max_date; 902 } 903 904 if(start_date.length) 905 { 906 opts['startDate'] = start_date; 907 } 908 909 if(end_date.length) 910 { 911 opts['endDate'] = end_date; 912 } 913 914 915 $this.daterangepicker(opts, function(start, end) 916 { 917 var drp = $this.data('daterangepicker'); 918 919 if($this.is('[data-callback]')) 920 { 921 $($this).parent().children('input').val(start.format('YYYY-MM-DD')+'|'+end.format('YYYY-MM-DD')); 922 } 923 924 if($this.hasClass('daterange-inline')) 925 { 926 $this.find('span').html(start.format(drp.format) + drp.separator + end.format(drp.format)); 927 } 928 }); 929 }); 930 } 931 932 933 934 935 // Input Mask 936 if($.isFunction($.fn.inputmask)) 937 { 938 $("[data-mask]").each(function(i, el) 939 { 940 var $this = $(el), 941 mask = $this.data('mask').toString(), 942 opts = { 943 numericInput: attrDefault($this, 'numeric', false), 944 radixPoint: attrDefault($this, 'radixPoint', ''), 945 rightAlignNumerics: attrDefault($this, 'numericAlign', 'left') == 'right' 946 }, 947 placeholder = attrDefault($this, 'placeholder', ''), 948 is_regex = attrDefault($this, 'isRegex', ''); 949 950 951 if(placeholder.length) 952 { 953 opts[placeholder] = placeholder; 954 } 955 956 switch(mask.toLowerCase()) 957 { 958 case "phone": 959 mask = "(999) 999-9999"; 960 break; 961 962 case "currency": 963 case "rcurrency": 964 965 var sign = attrDefault($this, 'sign', '$');; 966 967 mask = "999,999,999.99"; 968 969 if($this.data('mask').toLowerCase() == 'rcurrency') 970 { 971 mask += ' ' + sign; 972 } 973 else 974 { 975 mask = sign + ' ' + mask; 976 } 977 978 opts.numericInput = true; 979 opts.rightAlignNumerics = false; 980 opts.radixPoint = '.'; 981 break; 982 983 case "email": 984 mask = 'Regex'; 985 opts.regex = "[a-zA-Z0-9._%-]+@[a-zA-Z0-9-]+\\.[a-zA-Z]{2,4}"; 986 break; 987 988 case "fdecimal": 989 mask = 'decimal'; 990 $.extend(opts, { 991 autoGroup : true, 992 groupSize : 3, 993 radixPoint : attrDefault($this, 'rad', '.'), 994 groupSeparator : attrDefault($this, 'dec', ',') 995 });
996 } 997 998 if(is_regex) 999 { 1000 opts.regex = mask; 1001 mask = 'Regex'; 1002 } 1003 1004 $this.inputmask(mask, opts); 1005 }); 1006 } 1007 1008 1009 1010 1011 // Form Validation 1012 if($.isFunction($.fn.validate)) 1013 { 1014 $("form.validate").each(function(i, el) 1015 { 1016 var $this = $(el), 1017 opts = { 1018 rules: {}, 1019 messages: {}, 1020 errorElement: 'span', 1021 errorClass: 'validate-has-error', 1022 highlight: function (element) { 1023 $(element).closest('.form-group').addClass('validate-has-error'); 1024 }, 1025 unhighlight: function (element) { 1026 $(element).closest('.form-group').removeClass('validate-has-error'); 1027 }, 1028 errorPlacement: function (error, element) 1029 { 1030 if(element.closest('.has-switch').length) 1031 { 1032 error.insertAfter(element.closest('.has-switch')); 1033 } 1034 else 1035 if(element.parent('.checkbox, .radio').length || element.parent('.input-group').length) 1036 { 1037 error.insertAfter(element.parent()); 1038 } 1039 else 1040 { 1041 error.insertAfter(element); 1042 } 1043 } 1044 }, 1045 $fields = $this.find('[data-validate]'); 1046 1047 1048 $fields.each(function(j, el2) 1049 { 1050 var $field = $(el2), 1051 name = $field.attr('name'), 1052 validate = attrDefault($field, 'validate', '').toString(), 1053 _validate = validate.split(','); 1054 1055 for(var k in _validate) 1056 { 1057 var rule = _validate[k], 1058 params, 1059 message; 1060 1061 if(typeof opts['rules'][name] == 'undefined') 1062 { 1063 opts['rules'][name] = {}; 1064 opts['messages'][name] = {}; 1065 } 1066 1067 if($.inArray(rule, ['required', 'url', 'email', 'number', 'date', 'creditcard']) != -1) 1068 { 1069 opts['rules'][name][rule] = true; 1070 1071 message = $field.data('message-' + rule); 1072 1073 if(message) 1074 { 1075 opts['messages'][name][rule] = message; 1076 } 1077 } 1078 // Parameter Value (#1 parameter) 1079 else 1080 if(params = rule.match(/(\w+)\[(.*?)\]/i)) 1081 { 1082 if($.inArray(params[1], ['min', 'max', 'minlength', 'maxlength', 'equalTo']) != -1) 1083 { 1084 opts['rules'][name][params[1]] = params[2]; 1085 1086 1087 message = $field.data('message-' + params[1]); 1088 1089 if(message) 1090 { 1091 opts['messages'][name][params[1]] = message; 1092 } 1093 } 1094 } 1095 } 1096 }); 1097 1098 console.log( opts ); 1099 $this.validate(opts); 1100 }); 1101 } 1102 1103 1104 1105 1106 // Replaced File Input 1107 $("input.file2[type=file]").each(function(i, el) 1108 { 1109 var $this = $(el), 1110 label = attrDefault($this, 'label', 'Browse'); 1111 1112 $this.bootstrapFileInput(label); 1113 }); 1114 1115 1116 1117 1118 // Jasny Bootstrap | Fileinput 1119 if($.isFunction($.fn.fileinput)) 1120 { 1121 $(".fileinput").fileinput() 1122 } 1123 1124 1125 1126 1127 // Multi-select 1128 if($.isFunction($.fn.multiSelect)) 1129 { 1130 $(".multi-select").multiSelect(); 1131 } 1132 1133 1134 1135 1136 // Form Wizard 1137 if($.isFunction($.fn.bootstrapWizard)) 1138 { 1139 $(".form-wizard").each(function(i, el) 1140 { 1141 var $this = $(el), 1142 $progress = $this.find(".steps-progress div"), 1143 _index = $this.find('> ul > li.active').index(); 1144 1145 // Validation 1146 var checkFormWizardValidaion = function(tab, navigation, index) 1147 { 1148 if($this.hasClass('validate')) 1149 { 1150 var $valid = $this.valid(); 1151 1152 if( ! $valid) 1153 { 1154 $this.data('validator').focusInvalid(); 1155 return false; 1156 } 1157 } 1158 1159 return true; 1160 }; 1161 1162 1163 $this.bootstrapWizard({ 1164 tabClass: "", 1165 onTabShow: function($tab, $navigation, index) 1166 { 1167 setCurrentProgressTab($this, $navigation, $tab, $progress, index); 1168 }, 1169 1170 onNext: checkFormWizardValidaion, 1171 onTabClick: checkFormWizardValidaion 1172 }); 1173 1174 $this.data('bootstrapWizard').show( _index ); 1175 1176 /*$(window).on('flow.resize', function() 1177 { 1178 $this.data('bootstrapWizard').show( _index ); 1179 });*/ 1180 }); 1181 } 1182 1183 1184 1185 1186 // Wysiwyg Editor 1187 if($.isFunction($.fn.wysihtml5)) 1188 { 1189 $(".wysihtml5").each(function(i, el) 1190 { 1191 var $this = $(el), 1192 stylesheets = attrDefault($this, 'stylesheet-url', '') 1193 1194 $(".wysihtml5").wysihtml5({ 1195 stylesheets: stylesheets.split(',') 1196 }); 1197 }); 1198 } 1199 1200 1201 1202 1203 // CKeditor WYSIWYG 1204 if($.isFunction($.fn.ckeditor)) 1205 { 1206 $(".ckeditor").ckeditor({ 1207 contentsLangDirection: rtl() ? 'rtl' : 'ltr' 1208 }); 1209 } 1210 1211 1212 1213 1214 // Checkbox/Radio Replacement 1215 replaceCheckboxes(); 1216 1217 1218 1219 1220 // Tile Progress 1221 $(".tile-progress").each(function(i, el) 1222 { 1223 var $this = $(el), 1224 $pct_counter = $this.find('.pct-counter'), 1225 $progressbar = $this.find('.tile-progressbar span'), 1226 percentage = parseFloat($progressbar.data('fill')), 1227 pct_len = percentage.toString().length; 1228 1229 if(typeof scrollMonitor == 'undefined') 1230 { 1231 $progressbar.width(percentage + '%'); 1232 $pct_counter.html(percentage); 1233 } 1234 else 1235 { 1236 var tile_progress = scrollMonitor.create( el ); 1237 1238 tile_progress.fullyEnterViewport(function(){ 1239 $progressbar.width(percentage +'%'); 1240 tile_progress.destroy(); 1241 1242 var o = {pct: 0}; 1243 TweenLite.to(o, 1, {pct: percentage, ease: Quint.easeInOut, onUpdate: function() 1244 { 1245 var pct_str = o.pct.toString().substring(0, pct_len); 1246 1247 $pct_counter.html(pct_str); 1248 } 1249 });
1250 }); 1251 } 1252 }); 1253 1254 1255 1256 1257 // Tile Stats 1258 $(".tile-stats").each(function(i, el) 1259 { 1260 var $this = $(el), 1261 $num = $this.find('.num'), 1262 1263 start = attrDefault($num, 'start', 0), 1264 end = attrDefault($num, 'end', 0), 1265 prefix = attrDefault($num, 'prefix', ''), 1266 postfix = attrDefault($num, 'postfix', ''), 1267 duration = attrDefault($num, 'duration', 1000), 1268 delay = attrDefault($num, 'delay', 1000), 1269 decimals = attrDefault($num, 'decimals', 0); 1270 1271 if(start < end) 1272 { 1273 if(typeof scrollMonitor == 'undefined') 1274 { 1275 $num.html(prefix + end + postfix); 1276 } 1277 else 1278 { 1279 var tile_stats = scrollMonitor.create( el ); 1280 1281 tile_stats.fullyEnterViewport(function(){ 1282 1283 var o = {curr: start}; 1284 1285 TweenLite.to(o, duration/1000, {curr: end, ease: Power1.easeInOut, delay: delay/1000, onUpdate: function() 1286 { 1287 $num.html(prefix + o.curr.toFixed(decimals) + postfix); 1288 } 1289 }); 1290 1291 tile_stats.destroy() 1292 }); 1293 } 1294 } 1295 }); 1296 1297 1298 1299 1300 // Tocify Table 1301 if($.isFunction($.fn.tocify) && $("#toc").length) 1302 { 1303 $("#toc").tocify({ 1304 context: '.tocify-content', 1305 selectors: "h2,h3,h4,h5" 1306 }); 1307 1308 1309 var $this = $(".tocify"), 1310 watcher = scrollMonitor.create($this.get(0)); 1311 1312 $this.width( $this.parent().width() ); 1313 1314 watcher.lock(); 1315 1316 watcher.stateChange(function() 1317 { 1318 $($this.get(0)).toggleClass('fixed', this.isAboveViewport) 1319 }); 1320 } 1321 1322 1323 1324 // Modal Static 1325 public_vars.$body.on('click', '.modal[data-backdrop="static"]', function(ev) 1326 { 1327 if( $(ev.target).is('.modal') ) 1328 { 1329 var $modal_dialog = $(this).find('.modal-dialog .modal-content'), 1330 tt = new TimelineMax({paused: true}); 1331 1332 tt.append( TweenMax.to($modal_dialog, .1, {css: {scale: 1.1}, ease: Expo.easeInOut}) ); 1333 tt.append( TweenMax.to($modal_dialog, .3, {css: {scale: 1}, ease: Back.easeOut}) ); 1334 1335 tt.play(); 1336 } 1337 }); 1338 1339 1340 // Added on v1.1 1341 1342 // Sidebar User Links Popup 1343 if(public_vars.$sidebarUserEnv.length) 1344 { 1345 var $su_normal = public_vars.$sidebarUserEnv.find('.sui-normal'), 1346 $su_hover = public_vars.$sidebarUserEnv.find('.sui-hover'); 1347 1348 if($su_normal.length && $su_hover.length) 1349 { 1350 public_vars.$sidebarUser.on('click', function(ev) 1351 { 1352 ev.preventDefault(); 1353 $su_hover.addClass('visible'); 1354 }); 1355 1356 $su_hover.on('click', '.close-sui-popup', function(ev) 1357 { 1358 ev.preventDefault(); 1359 $su_hover.addClass('going-invisible'); 1360 $su_hover.removeClass('visible'); 1361 1362 setTimeout(function(){ $su_hover.removeClass('going-invisible'); }, 220); 1363 }); 1364 } 1365 } 1366 // End of: Added on v1.1 1367 1368 1369 // Added on v1.1.4 1370 $(".input-spinner").each(function(i, el) 1371 { 1372 var $this = $(el), 1373 $minus = $this.find('button:first'), 1374 $plus = $this.find('button:last'), 1375 $input = $this.find('input'), 1376 1377 minus_step = attrDefault($minus, 'step', -1), 1378 plus_step = attrDefault($minus, 'step', 1), 1379 1380 min = attrDefault($input, 'min', null), 1381 max = attrDefault($input, 'max', null); 1382 1383 1384 $this.find('button').on('click', function(ev) 1385 { 1386 ev.preventDefault(); 1387 1388 var $this = $(this), 1389 val = $input.val(), 1390 step = attrDefault($this, 'step', $this[0] == $minus[0] ? -1 : 1); 1391 1392 if( ! step.toString().match(/^[0-9-\.]+$/)) 1393 { 1394 step = $this[0] == $minus[0] ? -1 : 1; 1395 } 1396 1397 if( ! val.toString().match(/^[0-9-\.]+$/)) 1398 { 1399 val = 0; 1400 } 1401 1402 $input.val( parseFloat(val) + step ).trigger('keyup'); 1403 }); 1404 1405 $input.keyup(function() 1406 { 1407 if(min != null && parseFloat($input.val()) < min) 1408 { 1409 $input.val(min); 1410 } 1411 else 1412 1413 if(max != null && parseFloat($input.val()) > max) 1414 { 1415 $input.val(max); 1416 } 1417 }); 1418 1419 }); 1420 1421 1422 // Search Results Tabs 1423 var $search_results_env = $(".search-results-env"); 1424 1425 if($search_results_env.length) 1426 { 1427 var $sr_nav_tabs = $search_results_env.find(".nav-tabs li"), 1428 $sr_tab_panes = $search_results_env.find('.search-results-panes .search-results-pane'); 1429 1430 $sr_nav_tabs.find('a').on('click', function(ev) 1431 { 1432 ev.preventDefault(); 1433 1434 var $this = $(this), 1435 $tab_pane = $sr_tab_panes.filter($this.attr('href')); 1436 1437 $sr_nav_tabs.not($this.parent()).removeClass('active'); 1438 $this.parent().addClass('active'); 1439 1440 $sr_tab_panes.not($tab_pane).fadeOut('fast', function() 1441 { 1442 $tab_pane.fadeIn('fast'); 1443 }); 1444 }); 1445 } 1446 // End of: Added on v1.1.4 1447 1448 1449 1450 1451 // Fit main content height 1452 fit_main_content_height(); 1453 1454 var fmch = 0, 1455 fmch_fn = function(){ 1456 1457 window.clearTimeout(fmch); 1458 fit_main_content_height(); 1459 1460 fmch = setTimeout(fmch_fn, 800); 1461 }; 1462 1463 fmch_fn(); 1464 1465 1466 // Apply Page Transition 1467 onPageAppear(init_page_transitions); 1468 1469 }); 1470 1471 1472 1473 // Enable/Disable Resizable Event 1474 var wid = 0; 1475 1476 $(window).resize(function() { 1477 clearTimeout(wid); 1478 wid = setTimeout(trigger_resizable, 200);
1479 }); 1480 1481 1482 1483})(jQuery, window); 1484 1485 1486/* Functions */ 1487function fit_main_content_height() 1488{ 1489 var $ = jQuery; 1490 1491 if(public_vars.$sidebarMenu.length && public_vars.$sidebarMenu.hasClass('fixed') == false) 1492 { 1493 public_vars.$sidebarMenu.css('min-height', ''); 1494 public_vars.$mainContent.css('min-height', ''); 1495 1496 if(isxs()) 1497 { 1498 if(typeof reset_mail_container_height != 'undefined') 1499 reset_mail_container_height(); 1500 return; 1501 1502 if(typeof fit_calendar_container_height != 'undefined') 1503 reset_calendar_container_height(); 1504 return; 1505 } 1506 1507 var sm_height = public_vars.$sidebarMenu.outerHeight(), 1508 mc_height = public_vars.$mainContent.outerHeight(), 1509 doc_height = $(document).height(), 1510 win_height = $(window).height(), 1511 sm_height_real = 0; 1512 1513 if(win_height > doc_height) 1514 { 1515 doc_height = win_height; 1516 } 1517 1518 if(public_vars.$horizontalMenu.length > 0) 1519 { 1520 var hm_height = public_vars.$horizontalMenu.outerHeight(); 1521 1522 doc_height -= hm_height; 1523 sm_height -= hm_height; 1524 } 1525 1526 public_vars.$mainContent.css('min-height', doc_height); 1527 public_vars.$sidebarMenu.css('min-height', doc_height); 1528 public_vars.$chat.css('min-height', doc_height); 1529 1530 if(typeof fit_mail_container_height != 'undefined') 1531 fit_mail_container_height(); 1532 1533 if(typeof fit_calendar_container_height != 'undefined') 1534 fit_calendar_container_height(); 1535 } 1536} 1537 1538 1539// Sidebar Menu Setup 1540function setup_sidebar_menu() 1541{ 1542 var $ = jQuery, 1543 $items_with_submenu = public_vars.$sidebarMenu.find('li:has(ul)'), 1544 submenu_options = { 1545 submenu_open_delay: 0.5, 1546 submenu_open_easing: Sine.easeInOut, 1547 submenu_opened_class: 'opened' 1548 }, 1549 root_level_class = 'root-level', 1550 is_multiopen = public_vars.$mainMenu.hasClass('multiple-expanded'); 1551 1552 public_vars.$mainMenu.find('> li').addClass(root_level_class); 1553 1554 $items_with_submenu.each(function(i, el) 1555 { 1556 var $this = $(el), 1557 $link = $this.find('> a'), 1558 $submenu = $this.find('> ul'); 1559 1560 $this.addClass('has-sub'); 1561 1562 $link.click(function(ev) 1563 { 1564 ev.preventDefault(); 1565 1566 if( ! is_multiopen && $this.hasClass(root_level_class)) 1567 { 1568 var close_submenus = public_vars.$mainMenu.find('.' + root_level_class).not($this).find('> ul'); 1569 1570 close_submenus.each(function(i, el) 1571 { 1572 var $sub = $(el); 1573 menu_do_collapse($sub, $sub.parent(), submenu_options); 1574 }); 1575 } 1576 1577 if( ! $this.hasClass(submenu_options.submenu_opened_class)) 1578 { 1579 var current_height; 1580 1581 if( ! $submenu.is(':visible')) 1582 { 1583 menu_do_expand($submenu, $this, submenu_options); 1584 } 1585 } 1586 else 1587 { 1588 menu_do_collapse($submenu, $this, submenu_options); 1589 } 1590 1591 fit_main_content_height(); 1592 }); 1593 1594 }); 1595 1596 // Open the submenus with "opened" class 1597 public_vars.$mainMenu.find('.'+submenu_options.submenu_opened_class+' > ul').addClass('visible'); 1598 1599 // Well, somebody may forgot to add "active" for all inhertiance, but we are going to help you (just in case) - we do this job for you for free :P! 1600 if(public_vars.$mainMenu.hasClass('auto-inherit-active-class')) 1601 { 1602 menu_set_active_class_to_parents( public_vars.$mainMenu.find('.active') ); 1603 } 1604 1605 // Search Input 1606 var $search_input = public_vars.$mainMenu.find('#search input[type="text"]'), 1607 $search_el = public_vars.$mainMenu.find('#search'); 1608 1609 public_vars.$mainMenu.find('#search form').submit(function(ev) 1610 { 1611 var is_collapsed = public_vars.$pageContainer.hasClass('sidebar-collapsed'); 1612 1613 if(is_collapsed) 1614 { 1615 if($search_el.hasClass('focused') == false) 1616 { 1617 ev.preventDefault(); 1618 $search_el.addClass('focused'); 1619 1620 $search_input.focus(); 1621 1622 return false; 1623 } 1624 } 1625 }); 1626 1627 $search_input.on('blur', function(ev) 1628 { 1629 var is_collapsed = public_vars.$pageContainer.hasClass('sidebar-collapsed'); 1630 1631 if(is_collapsed) 1632 { 1633 $search_el.removeClass('focused'); 1634 } 1635 }); 1636 1637 1638 // Collapse Icon (mobile device visible) 1639 var show_hide_menu = $(''); 1640 1641 public_vars.$sidebarMenu.find('.logo-env').append(show_hide_menu); 1642} 1643 1644 1645function menu_do_expand($submenu, $this, options) 1646{ 1647 $submenu.addClass('visible').height(''); 1648 current_height = $submenu.outerHeight(); 1649 1650 var props_from = { 1651 opacity: .2, 1652 height: 0, 1653 top: -20 1654 }, 1655 props_to = { 1656 height: current_height, 1657 opacity: 1, 1658 top: 0 1659 }; 1660 1661 if(isxs()) 1662 { 1663 delete props_from['opacity']; 1664 delete props_from['top']; 1665 1666 delete props_to['opacity']; 1667 delete props_to['top']; 1668 } 1669 1670 TweenMax.set($submenu, {css: props_from}); 1671 1672 $this.addClass(options.submenu_opened_class); 1673 1674 TweenMax.to($submenu, options.submenu_open_delay, {css: props_to, ease: options.submenu_open_easing, onComplete: function() 1675 { 1676 $submenu.attr('style', ''); 1677 fit_main_content_height(); 1678 }}); 1679} 1680 1681 1682function menu_do_collapse($submenu, $this, options) 1683{
1684 if(public_vars.$pageContainer.hasClass('sidebar-collapsed') && $this.hasClass('root-level')) 1685 { 1686 return; 1687 } 1688 1689 $this.removeClass(options.submenu_opened_class); 1690 1691 TweenMax.to($submenu, options.submenu_open_delay, {css: {height: 0, opacity: .2}, ease: options.submenu_open_easing, onComplete: function() 1692 { 1693 $submenu.removeClass('visible'); 1694 fit_main_content_height(); 1695 }}); 1696} 1697 1698 1699function menu_set_active_class_to_parents($active_element) 1700{ 1701 if($active_element.length) 1702 { 1703 var $parent = $active_element.parent().parent(); 1704 1705 $parent.addClass('active'); 1706 1707 if(! $parent.hasClass('root-level')) 1708 menu_set_active_class_to_parents($parent) 1709 } 1710} 1711 1712 1713 1714// Horizontal Menu Setup 1715function setup_horizontal_menu() 1716{ 1717 var $ = jQuery, 1718 $nav_bar_menu = public_vars.$horizontalMenu.find('.navbar-nav'), 1719 $items_with_submenu = $nav_bar_menu.find('li:has(ul)'), 1720 $search = public_vars.$horizontalMenu.find('li#search'), 1721 $search_input = $search.find('.search-input'), 1722 $search_submit = $search.find('form'), 1723 root_level_class = 'root-level' 1724 is_multiopen = $nav_bar_menu.hasClass('multiple-expanded'), 1725 submenu_options = { 1726 submenu_open_delay: 0.5, 1727 submenu_open_easing: Sine.easeInOut, 1728 submenu_opened_class: 'opened' 1729 }; 1730 1731 $nav_bar_menu.find('> li').addClass(root_level_class); 1732 1733 $items_with_submenu.each(function(i, el) 1734 { 1735 var $this = $(el), 1736 $link = $this.find('> a'), 1737 $submenu = $this.find('> ul'); 1738 1739 $this.addClass('has-sub'); 1740 1741 setup_horizontal_menu_hover($this, $submenu); 1742 1743 // xs devices only 1744 $link.click(function(ev) 1745 { 1746 if(isxs()) 1747 { 1748 ev.preventDefault(); 1749 1750 if( ! is_multiopen && $this.hasClass(root_level_class)) 1751 { 1752 var close_submenus = $nav_bar_menu.find('.' + root_level_class).not($this).find('> ul'); 1753 1754 close_submenus.each(function(i, el) 1755 { 1756 var $sub = $(el); 1757 menu_do_collapse($sub, $sub.parent(), submenu_options); 1758 }); 1759 } 1760 1761 if( ! $this.hasClass(submenu_options.submenu_opened_class)) 1762 { 1763 var current_height; 1764 1765 if( ! $submenu.is(':visible')) 1766 { 1767 menu_do_expand($submenu, $this, submenu_options); 1768 } 1769 } 1770 else 1771 { 1772 menu_do_collapse($submenu, $this, submenu_options); 1773 } 1774 1775 fit_main_content_height(); 1776 } 1777 }); 1778 1779 }); 1780 1781 1782 // Search Input 1783 if($search.hasClass('search-input-collapsed')) 1784 { 1785 $search_submit.submit(function(ev) 1786 { 1787 if($search.hasClass('search-input-collapsed')) 1788 { 1789 ev.preventDefault(); 1790 $search.removeClass('search-input-collapsed'); 1791 $search_input.focus(); 1792 1793 return false; 1794 } 1795 }); 1796 1797 $search_input.on('blur', function(ev) 1798 { 1799 $search.addClass('search-input-collapsed'); 1800 }); 1801 } 1802} 1803 1804jQuery(public_vars, { 1805 hover_index: 4 1806}); 1807 1808function setup_horizontal_menu_hover($item, $sub) 1809{ 1810 var del = 0.5, 1811 trans_x = -10, 1812 ease = Quad.easeInOut; 1813 1814 TweenMax.set($sub, {css: {autoAlpha: 0, transform: "translateX("+trans_x+"px)"}}); 1815 1816 $item.hoverIntent({ 1817 over: function() 1818 { 1819 if(isxs()) 1820 return false; 1821 1822 if($sub.css('display') == 'none') 1823 { 1824 $sub.css({display: 'block', visibility: 'hidden'}); 1825 } 1826 1827 $sub.css({zIndex: ++public_vars.hover_index}); 1828 TweenMax.to($sub, del, {css: {autoAlpha: 1, transform: "translateX(0px)"}, ease: ease}); 1829 }, 1830 1831 out: function() 1832 { 1833 if(isxs()) 1834 return false; 1835 1836 TweenMax.to($sub, del, {css: {autoAlpha: 0, transform: "translateX("+trans_x+"px)"}, ease: ease, onComplete: function() 1837 { 1838 TweenMax.set($sub, {css: {transform: "translateX("+trans_x+"px)"}}); 1839 $sub.css({display: 'none'}); 1840 }}); 1841 }, 1842 1843 timeout: 300, 1844 interval: 50 1845 }); 1846 1847} 1848 1849 1850 1851// Block UI Helper 1852function blockUI($el) 1853{ 1854 $el.block({ 1855 message: '', 1856 css: { 1857 border: 'none', 1858 padding: '0px', 1859 backgroundColor: 'none' 1860 }, 1861 overlayCSS: { 1862 backgroundColor: '#fff', 1863 opacity: .3, 1864 cursor: 'wait' 1865 } 1866 }); 1867} 1868 1869function unblockUI($el) 1870{ 1871 $el.unblock(); 1872} 1873 1874 1875// Element Attribute Helper 1876function attrDefault($el, data_var, default_val) 1877{ 1878 if(typeof $el.data(data_var) != 'undefined') 1879 { 1880 return $el.data(data_var); 1881 } 1882 1883 return default_val; 1884} 1885 1886 1887 1888// Test function 1889function callback_test() 1890{ 1891 alert("Callback function executed! No. of arguments: " + arguments.length + "\n\nSee console log for outputed of the arguments."); 1892 1893 console.log(arguments); 1894} 1895 1896 1897// Root Wizard Current Tab 1898function setCurrentProgressTab($rootwizard, $nav, $tab, $progress, index) 1899{ 1900 $tab.prevAll().addClass('completed'); 1901 $tab.nextAll().removeClass('completed'); 1902 1903 var items = $nav.children().length, 1904 pct = parseInt((index+1) / items * 100, 10), 1905 $first_tab = $nav.find('li:first-child'), 1906 margin = (1/(items*2) * 100) + '%';//$first_tab.find('span').position().left + 'px'; 1907 1908 if( $first_tab.hasClass('active')) 1909 { 1910 $progress.width(0); 1911 } 1912 else 1913 { 1914 if(rtl()) 1915 { 1916 $progress.width( $progress.parent().outerWidth(true) - $tab.prev().position().left - $tab.find('span').width()/2 ); 1917 } 1918 else 1919 { 1920 $progress.width( ((index-1) /(items-1)) * 100 + '%' ); //$progress.width( $tab.prev().position().left - $tab.find('span').width()/2 ); 1921 } 1922 } 1923 1924 1925 $progress.parent().css({ 1926 marginLeft: margin, 1927 marginRight: margin 1928 }); 1929 1930 /*var m = $first_tab.find('span').position().left - $first_tab.find('span').width() / 2; 1931 1932 $rootwizard.find('.tab-content').css({ 1933 marginLeft: m, 1934 marginRight: m 1935 });*/ 1936} 1937 1938 1939// Replace Checkboxes 1940function replaceCheckboxes() 1941{ 1942 var $ = jQuery; 1943 1944 $(".checkbox-replace:not(.flow-cb-replacement), .radio-replace:not(.flow-cb-replacement)").each(function(i, el) 1945 { 1946 var $this = $(el),
1947 $input = $this.find('input:first'), 1948 $wrapper = $('<label class="cb-wrapper" />'), 1949 $checked = $('<div class="checked" />'), 1950 checked_class = 'checked', 1951 is_radio = $input.is('[type="radio"]'), 1952 $related, 1953 name = $input.attr('name'); 1954 1955 1956 $this.addClass('flow-cb-replacement'); 1957 1958 1959 $input.wrap($wrapper); 1960 1961 $wrapper = $input.parent(); 1962 1963 $wrapper.append($checked).next('label').on('click', function(ev) 1964 { 1965 $wrapper.click(); 1966 }); 1967 1968 $input.on('change', function(ev) 1969 { 1970 if(is_radio) 1971 { 1972 //$(".flow-cb-replacement input[type=radio][name='"+name+"']").closest('.flow-cb-replacement').removeClass(checked_class); 1973 $(".flow-cb-replacement input[type=radio][name='"+name+"']:not(:checked)").closest('.flow-cb-replacement').removeClass(checked_class); 1974 } 1975 1976 if($input.is(':disabled')) 1977 { 1978 $wrapper.addClass('disabled'); 1979 } 1980 1981 $this[$input.is(':checked') ? 'addClass' : 'removeClass'](checked_class); 1982 1983 }).trigger('change'); 1984 }); 1985} 1986 1987 1988 1989// Scroll to Bottom 1990function scrollToBottom($el) 1991{ 1992 var $ = jQuery; 1993 1994 if(typeof $el == 'string') 1995 $el = $($el); 1996 1997 $el.get(0).scrollTop = $el.get(0).scrollHeight; 1998} 1999 2000 2001// Check viewport visibility (entrie element) 2002function elementInViewport(el) 2003{ 2004 var top = el.offsetTop; 2005 var left = el.offsetLeft; 2006 var width = el.offsetWidth; 2007 var height = el.offsetHeight; 2008 2009 while (el.offsetParent) { 2010 el = el.offsetParent; 2011 top += el.offsetTop; 2012 left += el.offsetLeft; 2013 } 2014 2015 return ( 2016 top >= window.pageYOffset && 2017 left >= window.pageXOffset && 2018 (top + height) <= (window.pageYOffset + window.innerHeight) && 2019 (left + width) <= (window.pageXOffset + window.innerWidth) 2020 ); 2021} 2022 2023// X Overflow 2024function disableXOverflow() 2025{ 2026 public_vars.$body.addClass('overflow-x-disabled'); 2027} 2028 2029function enableXOverflow() 2030{ 2031 public_vars.$body.removeClass('overflow-x-disabled'); 2032} 2033 2034 2035// Page Transitions 2036function init_page_transitions() 2037{ 2038 fit_main_content_height(); 2039 2040 var transitions = ['page-fade', 'page-left-in', 'page-right-in', 'page-fade-only']; 2041 2042 for(var i in transitions) 2043 { 2044 var transition_name = transitions[i]; 2045 2046 if(public_vars.$body.hasClass(transition_name)) 2047 { 2048 public_vars.$body.addClass(transition_name + '-init') 2049 2050 setTimeout(function() 2051 { 2052 public_vars.$body.removeClass(transition_name + ' ' + transition_name + '-init'); 2053 2054 }, 850); 2055 2056 return; 2057 } 2058 } 2059} 2060 2061 2062// Page Visibility API 2063function onPageAppear(callback) 2064{ 2065 2066 var hidden, state, visibilityChange; 2067 2068 if (typeof document.hidden !== "undefined") 2069 { 2070 hidden = "hidden"; 2071 visibilityChange = "visibilitychange"; 2072 state = "visibilityState"; 2073 } 2074 else if (typeof document.mozHidden !== "undefined") 2075 { 2076 hidden = "mozHidden"; 2077 visibilityChange = "mozvisibilitychange"; 2078 state = "mozVisibilityState"; 2079 } 2080 else if (typeof document.msHidden !== "undefined") 2081 { 2082 hidden = "msHidden"; 2083 visibilityChange = "msvisibilitychange"; 2084 state = "msVisibilityState"; 2085 } 2086 else if (typeof document.webkitHidden !== "undefined") 2087 { 2088 hidden = "webkitHidden"; 2089 visibilityChange = "webkitvisibilitychange"; 2090 state = "webkitVisibilityState"; 2091 } 2092 2093 if(document[state] || typeof document[state] == 'undefined') 2094 { 2095 callback(); 2096 } 2097 2098 document.addEventListener(visibilityChange, callback, false); 2099} 2100 2101 2102function continueWrappingPanelTables() 2103{ 2104 var $tables = jQuery(".panel-body.with-table + table"); 2105 2106 if($tables.length) 2107 { 2108 $tables.wrap('<div class="panel-body with-table"></div>'); 2109 continueWrappingPanelTables(); 2110 } 2111} 2112 2113 2114function show_loading_bar(options) 2115{ 2116 var defaults = { 2117 pct: 0, 2118 delay: 1.3, 2119 wait: 0, 2120 before: function(){}, 2121 finish: function(){}, 2122 resetOnEnd: true 2123 }; 2124 2125 if(typeof options == 'object') 2126 defaults = jQuery.extend(defaults, options); 2127 else 2128 if(typeof options == 'number') 2129 defaults.pct = options; 2130 2131 2132 if(defaults.pct > 100) 2133 defaults.pct = 100; 2134 else 2135 if(defaults.pct < 0) 2136 defaults.pct = 0; 2137 2138 var $ = jQuery, 2139 $loading_bar = $(".flow-loading-bar"); 2140 2141 if($loading_bar.length == 0) 2142 { 2143 $loading_bar = $('<div class="flow-loading-bar progress-is-hidden"><span data-pct="0"></span></div>'); 2144 public_vars.$body.append( $loading_bar ); 2145 } 2146 2147 var $pct = $loading_bar.find('span'), 2148 current_pct = $pct.data('pct'), 2149 is_regress = current_pct > defaults.pct; 2150 2151 2152 defaults.before(current_pct); 2153 2154 TweenMax.to($pct, defaults.delay, {css: {width: defaults.pct + '%'}, delay: defaults.wait, ease: is_regress ? Expo.easeOut : Expo.easeIn, 2155 onStart: function() 2156 { 2157 $loading_bar.removeClass('progress-is-hidden'); 2158 }, 2159 onComplete: function() 2160 { 2161 var pct = $pct.data('pct'); 2162 2163 if(pct == 100 && defaults.resetOnEnd) 2164 { 2165 hide_loading_bar(); 2166 } 2167 2168 defaults.finish(pct); 2169 }, 2170 onUpdate: function() 2171 { 2172 $pct.data('pct', parseInt($pct.get(0).style.width, 10)); 2173 }}); 2174} 2175 2176function hide_loading_bar() 2177{ 2178 var $ = jQuery, 2179 $loading_bar = $(".flow-loading-bar"), 2180 $pct = $loading_bar.find('span'); 2181 2182 $loading_bar.addClass('progress-is-hidden'); 2183 $pct.width(0).data('pct'); 2184} 2185 2186// added by AW 2187function processAjaxForm(ele, callback) 2188{ 2189 // show loader
2190 showLoaderModal(); 2191 2192 // find form 2193 var form = $(ele).parents('form'); 2194 2195 // submit form via ajax 2196 $.ajax({ 2197 type: "POST", 2198 url: $(form).attr('action'), 2199 data: $(form).serializeArray(), 2200 success: function(data) { 2201 if(data.success == true) 2202 { 2203 // hide loader 2204 hideLoaderModal(); 2205 2206 // notification 2207 if(data.msg.length > 0) 2208 { 2209 showSuccessNotification('Success', data.msg); 2210 } 2211 2212 // callback 2213 if(typeof(callback) != 'undefined') 2214 { 2215 callback(data); 2216 } 2217 } 2218 else 2219 { 2220 // hide loader 2221 hideLoaderModal(); 2222 2223 // error 2224 showErrorNotification('Error', data.msg); 2225 } 2226 }, 2227 dataType: 'json' 2228 }); 2229} 2230 2231var triggeredLoaderModal = null; 2232function showLoaderModal(timer) 2233{ 2234 if(typeof(timer) == 'undefined') 2235 { 2236 timer = 500; 2237 } 2238 2239 if(triggeredLoaderModal == null) 2240 { 2241 triggeredLoaderModal = setTimeout(showLoaderModal, timer); 2242 return false; 2243 } 2244 2245 $('.loader-modal').modal('hide'); 2246 var pleaseWaitDiv = $('<div class="modal custom-width loader-modal" id="loaderModal" data-keyboard="false"><div class="modal-dialog modal-dialog-center" style="width: 300px;"><div class="progress progress-striped active"><div class="progress-bar" style="width: 100%;"></div></div></div></div>'); 2247 pleaseWaitDiv.modal(); 2248 clearTimeout(triggeredLoaderModal); 2249 triggeredLoaderModal = null; 2250} 2251 2252function hideLoaderModal() 2253{ 2254 if(triggeredLoaderModal != null) 2255 { 2256 clearTimeout(triggeredLoaderModal); 2257 triggeredLoaderModal = null; 2258 } 2259 $('.loader-modal').modal('hide'); 2260} 2261 2262function showErrorNotification(title, message) 2263{ 2264 var opts = { 2265 "closeButton": true, 2266 "debug": false, 2267 "positionClass": "toast-top-right", 2268 "showDuration": "300", 2269 "hideDuration": "1000", 2270 "timeOut": "5000", 2271 "extendedTimeOut": "1000", 2272 "showEasing": "swing", 2273 "hideEasing": "linear", 2274 "showMethod": "fadeIn", 2275 "hideMethod": "fadeOut" 2276 }; 2277 toastr.error(message, title, opts); 2278} 2279 2280function showInfoNotification(title, message) 2281{ 2282 var opts = { 2283 "closeButton": true, 2284 "debug": false, 2285 "positionClass": "toast-top-right", 2286 "showDuration": "300", 2287 "hideDuration": "1000", 2288 "timeOut": "5000", 2289 "extendedTimeOut": "1000", 2290 "showEasing": "swing", 2291 "hideEasing": "linear", 2292 "showMethod": "fadeIn", 2293 "hideMethod": "fadeOut" 2294 }; 2295 toastr.info(message, title, opts); 2296} 2297 2298function showSuccessNotification(title, message) 2299{ 2300 var opts = { 2301 "closeButton": true, 2302 "debug": false, 2303 "positionClass": "toast-top-right", 2304 "showDuration": "300", 2305 "hideDuration": "1000", 2306 "timeOut": "5000", 2307 "extendedTimeOut": "1000", 2308 "showEasing": "swing", 2309 "hideEasing": "linear", 2310 "showMethod": "fadeIn", 2311 "hideMethod": "fadeOut" 2312 }; 2313 toastr.success(message, title, opts); 2314} 2315 2316function sleep(milliseconds) 2317{ 2318 var start = new Date().getTime(); 2319 for (var i = 0; i < 1e7; i++) 2320 { 2321 if ((new Date().getTime() - start) > milliseconds) 2322 { 2323 break; 2324 } 2325 } 2326} 2327 2328function setupToolTips() 2329{ 2330 $('[data-toggle="tooltip"]').each(function(i, el) 2331 { 2332 var $this = $(el), 2333 placement = attrDefault($this, 'placement', 'top'), 2334 trigger = attrDefault($this, 'trigger', 'hover'), 2335 popover_class = $this.hasClass('tooltip-secondary') ? 'tooltip-secondary' : ($this.hasClass('tooltip-primary') ? 'tooltip-primary' : ($this.hasClass('tooltip-default') ? 'tooltip-default' : '')); 2336 2337 $this.tooltip({ 2338 placement: placement, 2339 trigger: trigger, 2340 container: 'body' 2341 }); 2342 2343 $this.on('shown.bs.tooltip', function(ev) 2344 { 2345 var $tooltip = $this.next(); 2346 2347 $tooltip.addClass(popover_class); 2348 }); 2349 }); 2350} 2351 2352function setUploaderFolderList(html) 2353{ 2354 $('#upload_folder_id').replaceWith(html); 2355}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.