Advertisement
Guest User

js

a guest
Jun 5th, 2019
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. window.theme = {};
  2.  
  3. // Theme Common Functions
  4. window.theme.fn = {
  5.  
  6.     getOptions: function(opts) {
  7.  
  8.         if (typeof(opts) == 'object') {
  9.  
  10.             return opts;
  11.  
  12.         } else if (typeof(opts) == 'string') {
  13.  
  14.             try {
  15.                 return JSON.parse(opts.replace(/'/g,'"').replace(';',''));
  16.             } catch(e) {
  17.                 return {};
  18.             }
  19.  
  20.         } else {
  21.  
  22.             return {};
  23.  
  24.         }
  25.  
  26.     }
  27.  
  28. };
  29.  
  30. // Navigation
  31. (function($) {
  32.  
  33.     'use strict';
  34.  
  35.     var $items = $( '.nav-main li.nav-parent' );
  36.  
  37.     function expand( $li ) {
  38.         $li.children( 'ul.nav-children' ).slideDown( 'fast', function() {
  39.             $li.addClass( 'nav-expanded' );
  40.             $(this).css( 'display', '' );
  41.             ensureVisible( $li );
  42.         });
  43.     }
  44.  
  45.     function collapse( $li ) {
  46.         $li.children('ul.nav-children' ).slideUp( 'fast', function() {
  47.             $(this).css( 'display', '' );
  48.             $li.removeClass( 'nav-expanded' );
  49.         });
  50.     }
  51.  
  52.     function ensureVisible( $li ) {
  53.         var scroller = $li.offsetParent();
  54.         if ( !scroller.get(0) ) {
  55.             return false;
  56.         }
  57.  
  58.         var top = $li.position().top;
  59.         if ( top < 0 ) {
  60.             scroller.animate({
  61.                 scrollTop: scroller.scrollTop() + top
  62.             }, 'fast');
  63.         }
  64.     }
  65.  
  66.     function buildSidebarNav( anchor, prev, next, ev ) {
  67.         if ( anchor.prop('href') ) {
  68.             var arrowWidth = parseInt(window.getComputedStyle(anchor.get(0), ':after').width, 10) || 0;
  69.             if (ev.offsetX > anchor.get(0).offsetWidth - arrowWidth) {
  70.                 ev.preventDefault();
  71.             }
  72.         }
  73.  
  74.         if ( prev.get( 0 ) !== next.get( 0 ) ) {
  75.             collapse( prev );
  76.             expand( next );
  77.         } else {
  78.             collapse( prev );
  79.         }
  80.     }
  81.  
  82.     $items.find('> a').on('click', function( ev ) {
  83.  
  84.         var $html   = $('html'),
  85.             $window = $(window),
  86.             $anchor = $( this ),
  87.             $prev   = $anchor.closest('ul.nav').find('> li.nav-expanded' ),
  88.             $next   = $anchor.closest('li'),
  89.             $ev     = ev;
  90.  
  91.         if( !$html.hasClass('sidebar-left-big-icons') ) {
  92.             buildSidebarNav( $anchor, $prev, $next, $ev );
  93.         } else if( $html.hasClass('sidebar-left-big-icons') && $window.width() < 768 ) {
  94.             buildSidebarNav( $anchor, $prev, $next, $ev );
  95.         }
  96.  
  97.     });
  98.  
  99.  
  100. }).apply(this, [jQuery]);
  101.  
  102. // Skeleton
  103. (function(theme, $) {
  104.  
  105.     'use strict';
  106.  
  107.     theme = theme || {};
  108.  
  109.     var $body       = $( 'body' ),
  110.         $html       = $( 'html' ),
  111.         $window     = $( window ),
  112.         isAndroid   = navigator.userAgent.toLowerCase().indexOf('android') > -1,
  113.         isIpad      = navigator.userAgent.match(/iPad/i) != null;
  114.  
  115.     // mobile devices with fixed has a lot of issues when focus inputs and others...
  116.     if ( typeof $.browser !== 'undefined' && $.browser.mobile && $html.hasClass('fixed') ) {
  117.         $html.removeClass( 'fixed' ).addClass( 'scroll' );
  118.     }
  119.  
  120.     var Skeleton = {
  121.  
  122.         options: {
  123.             sidebars: {
  124.                 menu: '#content-menu',
  125.                 left: '#sidebar-left',
  126.                 right: '#sidebar-right'
  127.             }
  128.         },
  129.  
  130.         customScroll: ( !Modernizr.overflowscrolling && !isAndroid && $.fn.nanoScroller !== 'undefined'),
  131.  
  132.         initialize: function() {
  133.             this
  134.                 .setVars()
  135.                 .build()
  136.                 .events();
  137.         },
  138.  
  139.         setVars: function() {
  140.             this.sidebars = {};
  141.  
  142.             this.sidebars.left = {
  143.                 $el: $( this.options.sidebars.left )
  144.             };
  145.  
  146.             this.sidebars.right = {
  147.                 $el: $( this.options.sidebars.right ),
  148.                 isOpened: $html.hasClass( 'sidebar-right-opened' )
  149.             };
  150.  
  151.             this.sidebars.menu = {
  152.                 $el: $( this.options.sidebars.menu ),
  153.                 isOpened: $html.hasClass( 'inner-menu-opened' )
  154.             };
  155.  
  156.             return this;
  157.         },
  158.  
  159.         build: function() {
  160.  
  161.             if ( typeof $.browser !== 'undefined' && $.browser.mobile ) {
  162.                 $html.addClass( 'mobile-device' );
  163.             } else {
  164.                 $html.addClass( 'no-mobile-device' );
  165.             }
  166.  
  167.             $html.addClass( 'custom-scroll' );
  168.             if ( this.customScroll ) {
  169.                 this.buildSidebarLeft();
  170.                 this.buildContentMenu();
  171.             }
  172.  
  173.             if( isIpad ) {
  174.                 this.fixIpad();
  175.             }
  176.  
  177.             this.buildSidebarRight();
  178.  
  179.             return this;
  180.         },
  181.  
  182.         events: function() {
  183.             if ( this.customScroll ) {
  184.                 this.eventsSidebarLeft();
  185.             }
  186.  
  187.             this.eventsSidebarRight();
  188.             this.eventsContentMenu();
  189.  
  190.             if ( typeof $.browser !== 'undefined' && !this.customScroll && isAndroid ) {
  191.                 this.fixScroll();
  192.             }
  193.  
  194.             return this;
  195.         },
  196.  
  197.         fixScroll: function() {
  198.             var _self = this;
  199.  
  200.             $window
  201.                 .on( 'sidebar-left-opened sidebar-right-toggle', function( e, data ) {
  202.                     _self.preventBodyScrollToggle( data.added );
  203.                 });
  204.  
  205.         },
  206.  
  207.         fixIpad: function() {
  208.             var _self = this;
  209.  
  210.             $('.header, .page-header, .content-body').on('click', function(){
  211.                 $html.removeClass('sidebar-left-opened');
  212.             });
  213.         },
  214.  
  215.         buildSidebarLeft: function() {
  216.  
  217.             var initialPosition = 0;
  218.  
  219.             this.sidebars.left.isOpened = !$html.hasClass( 'sidebar-left-collapsed' ) || $html.hasClass( 'sidebar-left-opened' );
  220.  
  221.             this.sidebars.left.$nano = this.sidebars.left.$el.find( '.nano' );
  222.  
  223.             if (typeof localStorage !== 'undefined') {
  224.                 this.sidebars.left.$nano.on('update', function(e, values) {
  225.                     localStorage.setItem('sidebar-left-position', values.position);
  226.                 });
  227.  
  228.                 if (localStorage.getItem('sidebar-left-position') !== null) {
  229.                     initialPosition = localStorage.getItem('sidebar-left-position');
  230.                     this.sidebars.left.$el.find( '.nano-content').scrollTop(initialPosition);
  231.                 }
  232.             }
  233.  
  234.             this.sidebars.left.$nano.nanoScroller({
  235.                 scrollTop: initialPosition,
  236.                 alwaysVisible: true,
  237.                 preventPageScrolling: $html.hasClass( 'fixed' )
  238.             });
  239.  
  240.             return this;
  241.         },
  242.  
  243.         eventsSidebarLeft: function() {
  244.  
  245.             var _self = this,
  246.                 $nano = this.sidebars.left.$nano;
  247.  
  248.             var open = function() {
  249.                 if ( _self.sidebars.left.isOpened ) {
  250.                     return close();
  251.                 }
  252.  
  253.                 _self.sidebars.left.isOpened = true;
  254.  
  255.                 $html.addClass( 'sidebar-left-opened' );
  256.  
  257.                 $window.trigger( 'sidebar-left-toggle', {
  258.                     added: true,
  259.                     removed: false
  260.                 });
  261.  
  262.                 $html.on( 'click.close-left-sidebar', function(e) {
  263.                     e.stopPropagation();
  264.                     close(e);
  265.                 });
  266.  
  267.  
  268.             };
  269.  
  270.             var close = function(e) {
  271.                 if ( !!e && !!e.target && ($(e.target).closest( '.sidebar-left' ).get(0) || !$(e.target).closest( 'html' ).get(0)) ) {
  272.                     e.preventDefault();
  273.                     return false;
  274.                 } else {
  275.  
  276.                     $html.removeClass( 'sidebar-left-opened' );
  277.                     $html.off( 'click.close-left-sidebar' );
  278.  
  279.                     $window.trigger( 'sidebar-left-toggle', {
  280.                         added: false,
  281.                         removed: true
  282.                     });
  283.  
  284.                     _self.sidebars.left.isOpened = !$html.hasClass( 'sidebar-left-collapsed' );
  285.  
  286.                 }
  287.             };
  288.  
  289.             var updateNanoScroll = function() {
  290.                 if ( $.support.transition ) {
  291.                     $nano.nanoScroller();
  292.                     $nano
  293.                         .one('bsTransitionEnd', updateNanoScroll)
  294.                         .emulateTransitionEnd(150)
  295.                 } else {
  296.                     updateNanoScroll();
  297.                 }
  298.             };
  299.  
  300.             var isToggler = function( element ) {
  301.                 return $(element).data('fire-event') === 'sidebar-left-toggle' || $(element).parents().data('fire-event') === 'sidebar-left-toggle';
  302.             };
  303.  
  304.             this.sidebars.left.$el
  305.                 .on( 'click', function() {
  306.                     updateNanoScroll();
  307.                 })
  308.                 .on('touchend', function(e) {
  309.                     _self.sidebars.left.isOpened = !$html.hasClass( 'sidebar-left-collapsed' ) || $html.hasClass( 'sidebar-left-opened' );
  310.                     if ( !_self.sidebars.left.isOpened && !isToggler(e.target) ) {
  311.                         e.stopPropagation();
  312.                         e.preventDefault();
  313.                         open();
  314.                     }
  315.                 });
  316.  
  317.             $nano
  318.                 .on( 'mouseenter', function() {
  319.                     if ( $html.hasClass( 'sidebar-left-collapsed' ) ) {
  320.                         $nano.nanoScroller();
  321.                     }
  322.                 })
  323.                 .on( 'mouseleave', function() {
  324.                     if ( $html.hasClass( 'sidebar-left-collapsed' ) ) {
  325.                         $nano.nanoScroller();
  326.                     }
  327.                 });
  328.  
  329.             $window.on( 'sidebar-left-toggle', function(e, toggle) {
  330.                 if ( toggle.removed ) {
  331.                     $html.removeClass( 'sidebar-left-opened' );
  332.                     $html.off( 'click.close-left-sidebar' );
  333.                 }
  334.                
  335.                 // Recalculate Owl Carousel sizes
  336.                 $('.owl-carousel').trigger('refresh.owl.carousel');
  337.             });
  338.  
  339.             return this;
  340.         },
  341.  
  342.         buildSidebarRight: function() {
  343.             this.sidebars.right.isOpened = $html.hasClass( 'sidebar-right-opened' );
  344.  
  345.             if ( this.customScroll ) {
  346.                 this.sidebars.right.$nano = this.sidebars.right.$el.find( '.nano' );
  347.  
  348.                 this.sidebars.right.$nano.nanoScroller({
  349.                     alwaysVisible: true,
  350.                     preventPageScrolling: true
  351.                 });
  352.             }
  353.  
  354.             return this;
  355.         },
  356.  
  357.         eventsSidebarRight: function() {
  358.             var _self = this;
  359.  
  360.             var open = function() {
  361.                 if ( _self.sidebars.right.isOpened ) {
  362.                     return close();
  363.                 }
  364.  
  365.                 _self.sidebars.right.isOpened = true;
  366.  
  367.                 $html.addClass( 'sidebar-right-opened' );
  368.  
  369.                 $window.trigger( 'sidebar-right-toggle', {
  370.                     added: true,
  371.                     removed: false
  372.                 });
  373.  
  374.                 $html.on( 'click.close-right-sidebar', function(e) {
  375.                     e.stopPropagation();
  376.                     close(e);
  377.                 });
  378.             };
  379.  
  380.             var close = function(e) {
  381.                 if ( !!e && !!e.target && ($(e.target).closest( '.sidebar-right' ).get(0) || !$(e.target).closest( 'html' ).get(0)) ) {
  382.                     return false;
  383.                 }
  384.  
  385.                 $html.removeClass( 'sidebar-right-opened' );
  386.                 $html.off( 'click.close-right-sidebar' );
  387.  
  388.                 $window.trigger( 'sidebar-right-toggle', {
  389.                     added: false,
  390.                     removed: true
  391.                 });
  392.  
  393.                 _self.sidebars.right.isOpened = false;
  394.             };
  395.  
  396.             var bind = function() {
  397.                 $('[data-open="sidebar-right"]').on('click', function(e) {
  398.                     var $el = $(this);
  399.                     e.stopPropagation();
  400.  
  401.                     if ( $el.is('a') )
  402.                         e.preventDefault();
  403.  
  404.                     open();
  405.                 });
  406.             };
  407.  
  408.             this.sidebars.right.$el.find( '.mobile-close' )
  409.                 .on( 'click', function( e ) {
  410.                     e.preventDefault();
  411.                     $html.trigger( 'click.close-right-sidebar' );
  412.                 });
  413.  
  414.             bind();
  415.  
  416.             return this;
  417.         },
  418.  
  419.         buildContentMenu: function() {
  420.             if ( !$html.hasClass( 'fixed' ) ) {
  421.                 return false;
  422.             }
  423.  
  424.             this.sidebars.menu.$nano = this.sidebars.menu.$el.find( '.nano' );
  425.  
  426.             this.sidebars.menu.$nano.nanoScroller({
  427.                 alwaysVisible: true,
  428.                 preventPageScrolling: true
  429.             });
  430.  
  431.             return this;
  432.         },
  433.  
  434.         eventsContentMenu: function() {
  435.             var _self = this;
  436.  
  437.             var open = function() {
  438.                 if ( _self.sidebars.menu.isOpened ) {
  439.                     return close();
  440.                 }
  441.  
  442.                 _self.sidebars.menu.isOpened = true;
  443.  
  444.                 $html.addClass( 'inner-menu-opened' );
  445.  
  446.                 $window.trigger( 'inner-menu-toggle', {
  447.                     added: true,
  448.                     removed: false
  449.                 });
  450.  
  451.                 $html.on( 'click.close-inner-menu', function(e) {
  452.  
  453.                     close(e);
  454.                 });
  455.  
  456.             };
  457.  
  458.             var close = function(e) {
  459.                 var hasEvent,
  460.                     hasTarget,
  461.                     isCollapseButton,
  462.                     isInsideModal,
  463.                     isInsideInnerMenu,
  464.                     isInsideHTML,
  465.                     $target;
  466.  
  467.                 hasEvent = !!e;
  468.                 hasTarget = hasEvent && !!e.target;
  469.  
  470.                 if ( hasTarget ) {
  471.                     $target = $(e.target);
  472.                 }
  473.  
  474.                 isCollapseButton = hasTarget && !!$target.closest( '.inner-menu-collapse' ).get(0);
  475.                 isInsideModal = hasTarget && !!$target.closest( '.mfp-wrap' ).get(0);
  476.                 isInsideInnerMenu = hasTarget && !!$target.closest( '.inner-menu' ).get(0);
  477.                 isInsideHTML = hasTarget && !!$target.closest( 'html' ).get(0);
  478.  
  479.                 if ( (!isCollapseButton && (isInsideInnerMenu || !isInsideHTML)) || isInsideModal ) {
  480.                     return false;
  481.                 }
  482.  
  483.                 e.stopPropagation();
  484.  
  485.                 $html.removeClass( 'inner-menu-opened' );
  486.                 $html.off( 'click.close-inner-menu' );
  487.  
  488.                 $window.trigger( 'inner-menu-toggle', {
  489.                     added: false,
  490.                     removed: true
  491.                 });
  492.  
  493.                 _self.sidebars.menu.isOpened = false;
  494.             };
  495.  
  496.             var bind = function() {
  497.                 $('[data-open="inner-menu"]').on('click', function(e) {
  498.                     var $el = $(this);
  499.                     e.stopPropagation();
  500.  
  501.                     if ( $el.is('a') )
  502.                         e.preventDefault();
  503.  
  504.                     open();
  505.                 });
  506.             };
  507.  
  508.             bind();
  509.  
  510.             /* Nano Scroll */
  511.             if ( $html.hasClass( 'fixed' ) ) {
  512.                 var $nano = this.sidebars.menu.$nano;
  513.  
  514.                 var updateNanoScroll = function() {
  515.                     if ( $.support.transition ) {
  516.                         $nano.nanoScroller();
  517.                         $nano
  518.                             .one('bsTransitionEnd', updateNanoScroll)
  519.                             .emulateTransitionEnd(150)
  520.                     } else {
  521.                         updateNanoScroll();
  522.                     }
  523.                 };
  524.  
  525.                 this.sidebars.menu.$el
  526.                     .on( 'click', function() {
  527.                         updateNanoScroll();
  528.                     });
  529.             }
  530.  
  531.             return this;
  532.         },
  533.  
  534.         preventBodyScrollToggle: function( shouldPrevent, $el ) {
  535.             setTimeout(function() {
  536.                 if ( shouldPrevent ) {
  537.                     $body
  538.                         .data( 'scrollTop', $body.get(0).scrollTop )
  539.                         .css({
  540.                             position: 'fixed',
  541.                             top: $body.get(0).scrollTop * -1
  542.                         })
  543.                 } else {
  544.                     $body
  545.                         .css({
  546.                             position: '',
  547.                             top: ''
  548.                         })
  549.                         .scrollTop( $body.data( 'scrollTop' ) );
  550.                 }
  551.             }, 150);
  552.         }
  553.  
  554.     };
  555.  
  556.     // expose to scope
  557.     $.extend(theme, {
  558.         Skeleton: Skeleton
  559.     });
  560.  
  561. }).apply(this, [window.theme, jQuery]);
  562.  
  563. /* Browser Selector */
  564. (function($) {
  565.     $.extend({
  566.  
  567.         browserSelector: function() {
  568.  
  569.             // jQuery.browser.mobile (http://detectmobilebrowser.com/)
  570.             (function(a){(jQuery.browser=jQuery.browser||{}).mobile=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))})(navigator.userAgent||navigator.vendor||window.opera);
  571.  
  572.             // Touch
  573.             var hasTouch = 'ontouchstart' in window || navigator.msMaxTouchPoints;
  574.  
  575.             var u = navigator.userAgent,
  576.                 ua = u.toLowerCase(),
  577.                 is = function (t) {
  578.                     return ua.indexOf(t) > -1;
  579.                 },
  580.                 g = 'gecko',
  581.                 w = 'webkit',
  582.                 s = 'safari',
  583.                 o = 'opera',
  584.                 h = document.documentElement,
  585.                 b = [(!(/opera|webtv/i.test(ua)) && /msie\s(\d)/.test(ua)) ? ('ie ie' + parseFloat(navigator.appVersion.split("MSIE")[1])) : is('firefox/2') ? g + ' ff2' : is('firefox/3.5') ? g + ' ff3 ff3_5' : is('firefox/3') ? g + ' ff3' : is('gecko/') ? g : is('opera') ? o + (/version\/(\d+)/.test(ua) ? ' ' + o + RegExp.jQuery1 : (/opera(\s|\/)(\d+)/.test(ua) ? ' ' + o + RegExp.jQuery2 : '')) : is('konqueror') ? 'konqueror' : is('chrome') ? w + ' chrome' : is('iron') ? w + ' iron' : is('applewebkit/') ? w + ' ' + s + (/version\/(\d+)/.test(ua) ? ' ' + s + RegExp.jQuery1 : '') : is('mozilla/') ? g : '', is('j2me') ? 'mobile' : is('iphone') ? 'iphone' : is('ipod') ? 'ipod' : is('mac') ? 'mac' : is('darwin') ? 'mac' : is('webtv') ? 'webtv' : is('win') ? 'win' : is('freebsd') ? 'freebsd' : (is('x11') || is('linux')) ? 'linux' : '', 'js'];
  586.  
  587.             c = b.join(' ');
  588.  
  589.             if ($.browser.mobile) {
  590.                 c += ' mobile';
  591.             }
  592.  
  593.             if (hasTouch) {
  594.                 c += ' touch';
  595.             }
  596.  
  597.             h.className += ' ' + c;
  598.  
  599.             // IE11 Detect
  600.             var isIE11 = !(window.ActiveXObject) && "ActiveXObject" in window;
  601.  
  602.             if (isIE11) {
  603.                 $('html').removeClass('gecko').addClass('ie ie11');
  604.                 return;
  605.             }
  606.  
  607.             // Dark and Boxed Compatibility
  608.             if($('body').hasClass('dark')) {
  609.                 $('html').addClass('dark');
  610.             }
  611.  
  612.             if($('body').hasClass('boxed')) {
  613.                 $('html').addClass('boxed');
  614.             }
  615.  
  616.         }
  617.  
  618.     });
  619.  
  620.     $.browserSelector();
  621.  
  622. })(jQuery);
  623.  
  624. // Base
  625. (function(theme, $) {
  626.  
  627.     'use strict';
  628.  
  629.     theme = theme || {};
  630.  
  631.     theme.Skeleton.initialize();
  632.  
  633. }).apply(this, [window.theme, jQuery]);
  634.  
  635. // Bootstrap Toggle
  636. (function($) {
  637.  
  638.     'use strict';
  639.  
  640.     var $window = $( window );
  641.  
  642.     var toggleClass = function( $el ) {
  643.         if ( !!$el.data('toggleClassBinded') ) {
  644.             return false;
  645.         }
  646.  
  647.         var $target,
  648.             className,
  649.             eventName;
  650.  
  651.         $target = $( $el.attr('data-target') );
  652.         className = $el.attr('data-toggle-class');
  653.         eventName = $el.attr('data-fire-event');
  654.  
  655.  
  656.         $el.on('click.toggleClass', function(e) {
  657.             e.preventDefault();
  658.             $target.toggleClass( className );
  659.  
  660.             var hasClass = $target.hasClass( className );
  661.  
  662.             if ( !!eventName ) {
  663.                 $window.trigger( eventName, {
  664.                     added: hasClass,
  665.                     removed: !hasClass
  666.                 });
  667.             }
  668.         });
  669.  
  670.         $el.data('toggleClassBinded', true);
  671.  
  672.         return true;
  673.     };
  674.  
  675.     $(function() {
  676.         $('[data-toggle-class][data-target]').each(function() {
  677.             toggleClass( $(this) );
  678.         });
  679.     });
  680.  
  681. }).apply(this, [jQuery]);
  682.  
  683.  
  684. // Header Menu Nav
  685. (function(theme, $) {
  686.  
  687.     'use strict';
  688.  
  689.     theme = theme || {};
  690.  
  691.     var initialized = false;
  692.  
  693.     $.extend(theme, {
  694.  
  695.         Nav: {
  696.  
  697.             defaults: {
  698.                 wrapper: $('#mainNav'),
  699.                 scrollDelay: 600,
  700.                 scrollAnimation: 'easeOutQuad'
  701.             },
  702.  
  703.             initialize: function($wrapper, opts) {
  704.                 if (initialized) {
  705.                     return this;
  706.                 }
  707.  
  708.                 initialized = true;
  709.                 this.$wrapper = ($wrapper || this.defaults.wrapper);
  710.  
  711.                 this
  712.                     .setOptions(opts)
  713.                     .build()
  714.                     .events();
  715.  
  716.                 return this;
  717.             },
  718.  
  719.             setOptions: function(opts) {
  720.                 // this.options = $.extend(true, {}, this.defaults, opts, theme.fn.getOptions(this.$wrapper.data('plugin-options')));
  721.  
  722.                 return this;
  723.             },
  724.  
  725.             build: function() {
  726.                 var self = this,
  727.                     $html = $('html'),
  728.                     $header = $('.header'),
  729.                     thumbInfoPreview;
  730.  
  731.                 // Add Arrows
  732.                 $header.find('.dropdown-toggle:not(.notification-icon), .dropdown-submenu > a').append($('<i />').addClass('fa fa-caret-down'));
  733.  
  734.                 // Preview Thumbs
  735.                 self.$wrapper.find('a[data-thumb-preview]').each(function() {
  736.                     thumbInfoPreview = $('<span />').addClass('thumb-info thumb-info-preview')
  737.                                             .append($('<span />').addClass('thumb-info-wrapper')
  738.                                                 .append($('<span />').addClass('thumb-info-image').css('background-image', 'url(' + $(this).data('thumb-preview') + ')')
  739.                                            )
  740.                                        );
  741.  
  742.                     $(this).append(thumbInfoPreview);
  743.                 });
  744.  
  745.                 // Side Header Right (Reverse Dropdown)
  746.                 if($html.hasClass('side-header-right')) {
  747.                     $header.find('.dropdown').addClass('dropdown-reverse');
  748.                 }
  749.  
  750.                 return this;
  751.             },
  752.  
  753.             events: function() {
  754.                 var self = this,
  755.                     $header = $('.header'),
  756.                     $window = $(window);
  757.  
  758.                 $header.find('a[href="#"]').on('click', function(e) {
  759.                     e.preventDefault();
  760.                 });
  761.  
  762.                 // Mobile Arrows
  763.                 $header.find('.dropdown-toggle[href="#"], .dropdown-submenu a[href="#"], .dropdown-toggle[href!="#"] .fa-caret-down, .dropdown-submenu a[href!="#"] .fa-caret-down').on('click', function(e) {
  764.                     e.preventDefault();
  765.                     if ($window.width() < 992) {
  766.                         $(this).closest('li').toggleClass('opened');
  767.                     }
  768.                 });
  769.  
  770.                 // Touch Devices with normal resolutions
  771.                 if('ontouchstart' in document.documentElement) {
  772.                     $header.find('.dropdown-toggle:not([href="#"]), .dropdown-submenu > a:not([href="#"])')
  773.                         .on('touchstart click', function(e) {
  774.                             if($window.width() > 991) {
  775.  
  776.                                 e.stopPropagation();
  777.                                 e.preventDefault();
  778.  
  779.                                 if(e.handled !== true) {
  780.  
  781.                                     var li = $(this).closest('li');
  782.  
  783.                                     if(li.hasClass('tapped')) {
  784.                                         location.href = $(this).attr('href');
  785.                                     }
  786.  
  787.                                     li.addClass('tapped');
  788.  
  789.                                     e.handled = true;
  790.                                 } else {
  791.                                     return false;
  792.                                 }
  793.  
  794.                                 return false;
  795.  
  796.                             }
  797.                         })
  798.                         .on('blur', function(e) {
  799.                             $(this).closest('li').removeClass('tapped');
  800.                         });
  801.  
  802.                 }
  803.  
  804.                 // Collapse Nav
  805.                 $header.find('[data-collapse-nav]').on('click', function(e) {
  806.                     $(this).parents('.collapse').removeClass('in');
  807.                 });
  808.  
  809.                 // Anchors Position
  810.                 $('[data-hash]').each(function() {
  811.  
  812.                     var target = $(this).attr('href'),
  813.                         offset = ($(this).is("[data-hash-offset]") ? $(this).data('hash-offset') : 0);
  814.  
  815.                     if($(target).get(0)) {
  816.                         $(this).on('click', function(e) {
  817.                             e.preventDefault();
  818.  
  819.                             // Close Collapse if Opened
  820.                             $(this).parents('.collapse.in').removeClass('in');
  821.  
  822.                             self.scrollToTarget(target, offset);
  823.  
  824.                             return;
  825.                         });
  826.                     }
  827.  
  828.                 });
  829.  
  830.                 return this;
  831.             },
  832.  
  833.             scrollToTarget: function(target, offset) {
  834.                 var self = this;
  835.  
  836.                 $('body').addClass('scrolling');
  837.  
  838.                 $('html, body').animate({
  839.                     scrollTop: $(target).offset().top - offset
  840.                 }, self.options.scrollDelay, self.options.scrollAnimation, function() {
  841.                     $('body').removeClass('scrolling');
  842.                 });
  843.  
  844.                 return this;
  845.  
  846.             }
  847.  
  848.         }
  849.  
  850.     });
  851.  
  852. }).apply(this, [window.theme, jQuery]);
  853.  
  854. // Scroll to Top
  855. (function(theme, $) {
  856.  
  857.     theme = theme || {};
  858.  
  859.     $.extend(theme, {
  860.  
  861.         PluginScrollToTop: {
  862.  
  863.             defaults: {
  864.                 wrapper: $('body'),
  865.                 offset: 150,
  866.                 buttonClass: 'scroll-to-top',
  867.                 iconClass: 'fa fa-chevron-up',
  868.                 delay: 500,
  869.                 visibleMobile: false,
  870.                 label: false
  871.             },
  872.  
  873.             initialize: function(opts) {
  874.                 initialized = true;
  875.  
  876.                 this
  877.                     .setOptions(opts)
  878.                     .build()
  879.                     .events();
  880.  
  881.                 return this;
  882.             },
  883.  
  884.             setOptions: function(opts) {
  885.                 this.options = $.extend(true, {}, this.defaults, opts);
  886.  
  887.                 return this;
  888.             },
  889.  
  890.             build: function() {
  891.                 var self = this,
  892.                     $el;
  893.  
  894.                 // Base HTML Markup
  895.                 $el = $('<a />')
  896.                     .addClass(self.options.buttonClass)
  897.                     .attr({
  898.                         'href': '#',
  899.                     })
  900.                     .append(
  901.                         $('<i />')
  902.                         .addClass(self.options.iconClass)
  903.                 );
  904.  
  905.                 // Visible Mobile
  906.                 if (!self.options.visibleMobile) {
  907.                     $el.addClass('hidden-mobile');
  908.                 }
  909.  
  910.                 // Label
  911.                 if (self.options.label) {
  912.                     $el.append(
  913.                         $('<span />').html(self.options.label)
  914.                     );
  915.                 }
  916.  
  917.                 this.options.wrapper.append($el);
  918.  
  919.                 this.$el = $el;
  920.  
  921.                 return this;
  922.             },
  923.  
  924.             events: function() {
  925.                 var self = this,
  926.                     _isScrolling = false;
  927.  
  928.                 // Click Element Action
  929.                 self.$el.on('click', function(e) {
  930.                     e.preventDefault();
  931.                     $('body, html').animate({
  932.                         scrollTop: 0
  933.                     }, self.options.delay);
  934.                     return false;
  935.                 });
  936.  
  937.                 // Show/Hide Button on Window Scroll event.
  938.                 $(window).scroll(function() {
  939.  
  940.                     if (!_isScrolling) {
  941.  
  942.                         _isScrolling = true;
  943.  
  944.                         if ($(window).scrollTop() > self.options.offset) {
  945.  
  946.                             self.$el.stop(true, true).addClass('visible');
  947.                             _isScrolling = false;
  948.  
  949.                         } else {
  950.  
  951.                             self.$el.stop(true, true).removeClass('visible');
  952.                             _isScrolling = false;
  953.  
  954.                         }
  955.  
  956.                     }
  957.  
  958.                 });
  959.  
  960.                 return this;
  961.             }
  962.  
  963.         }
  964.  
  965.     });
  966.  
  967. }).apply(this, [window.theme, jQuery]);
  968.  
  969. // Toggle
  970. (function(theme, $) {
  971.  
  972.     theme = theme || {};
  973.  
  974.     var instanceName = '__toggle';
  975.  
  976.     var PluginToggle = function($el, opts) {
  977.         return this.initialize($el, opts);
  978.     };
  979.  
  980.     PluginToggle.defaults = {
  981.         duration: 350,
  982.         isAccordion: false,
  983.         addIcons: true
  984.     };
  985.  
  986.     PluginToggle.prototype = {
  987.         initialize: function($el, opts) {
  988.             if ( $el.data( instanceName ) ) {
  989.                 return this;
  990.             }
  991.  
  992.             this.$el = $el;
  993.  
  994.             this
  995.                 .setData()
  996.                 .setOptions(opts)
  997.                 .build();
  998.  
  999.             return this;
  1000.         },
  1001.  
  1002.         setData: function() {
  1003.             this.$el.data(instanceName, this);
  1004.  
  1005.             return this;
  1006.         },
  1007.  
  1008.         setOptions: function(opts) {
  1009.             this.options = $.extend(true, {}, PluginToggle.defaults, opts, {
  1010.                 wrapper: this.$el
  1011.             });
  1012.  
  1013.             return this;
  1014.         },
  1015.  
  1016.         build: function() {
  1017.             var self = this,
  1018.                 $wrapper = this.options.wrapper,
  1019.                 $items = $wrapper.find('.toggle'),
  1020.                 $el = null;
  1021.  
  1022.             $items.each(function() {
  1023.                 $el = $(this);
  1024.  
  1025.                 if(self.options.addIcons) {
  1026.                     $el.find('> label').prepend(
  1027.                         $('<i />').addClass('fa fa-plus'),
  1028.                         $('<i />').addClass('fa fa-minus')
  1029.                     );
  1030.                 }
  1031.  
  1032.                 if($el.hasClass('active')) {
  1033.                     $el.find('> p').addClass('preview-active');
  1034.                     $el.find('> .toggle-content').slideDown(self.options.duration);
  1035.                 }
  1036.  
  1037.                 self.events($el);
  1038.             });
  1039.  
  1040.             if(self.options.isAccordion) {
  1041.                 self.options.duration = self.options.duration/2;
  1042.             }
  1043.  
  1044.             return this;
  1045.         },
  1046.  
  1047.         events: function($el) {
  1048.             var self = this,
  1049.                 previewParCurrentHeight = 0,
  1050.                 previewParAnimateHeight = 0,
  1051.                 toggleContent = null;
  1052.  
  1053.             $el.find('> label').click(function(e) {
  1054.  
  1055.                 var $this = $(this),
  1056.                     parentSection = $this.parent(),
  1057.                     parentWrapper = $this.parents('.toggle'),
  1058.                     previewPar = null,
  1059.                     closeElement = null;
  1060.  
  1061.                 if(self.options.isAccordion && typeof(e.originalEvent) != 'undefined') {
  1062.                     closeElement = parentWrapper.find('.toggle.active > label');
  1063.  
  1064.                     if(closeElement[0] == $this[0]) {
  1065.                         return;
  1066.                     }
  1067.                 }
  1068.  
  1069.                 parentSection.toggleClass('active');
  1070.  
  1071.                 // Preview Paragraph
  1072.                 if(parentSection.find('> p').get(0)) {
  1073.  
  1074.                     previewPar = parentSection.find('> p');
  1075.                     previewParCurrentHeight = previewPar.css('height');
  1076.                     previewPar.css('height', 'auto');
  1077.                     previewParAnimateHeight = previewPar.css('height');
  1078.                     previewPar.css('height', previewParCurrentHeight);
  1079.  
  1080.                 }
  1081.  
  1082.                 // Content
  1083.                 toggleContent = parentSection.find('> .toggle-content');
  1084.  
  1085.                 if(parentSection.hasClass('active')) {
  1086.  
  1087.                     $(previewPar).animate({
  1088.                         height: previewParAnimateHeight
  1089.                     }, self.options.duration, function() {
  1090.                         $(this).addClass('preview-active');
  1091.                     });
  1092.  
  1093.                     toggleContent.slideDown(self.options.duration, function() {
  1094.                         if(closeElement) {
  1095.                             closeElement.trigger('click');
  1096.                         }
  1097.                     });
  1098.  
  1099.                 } else {
  1100.  
  1101.                     $(previewPar).animate({
  1102.                         height: 0
  1103.                     }, self.options.duration, function() {
  1104.                         $(this).removeClass('preview-active');
  1105.                     });
  1106.  
  1107.                     toggleContent.slideUp(self.options.duration);
  1108.  
  1109.                 }
  1110.  
  1111.             });
  1112.         }
  1113.     };
  1114.  
  1115.     // expose to scope
  1116.     $.extend(theme, {
  1117.         PluginToggle: PluginToggle
  1118.     });
  1119.  
  1120.     // jquery plugin
  1121.     $.fn.themePluginToggle = function(opts) {
  1122.         return this.map(function() {
  1123.             var $this = $(this);
  1124.  
  1125.             if ($this.data(instanceName)) {
  1126.                 return $this.data(instanceName);
  1127.             } else {
  1128.                 return new PluginToggle($this, opts);
  1129.             }
  1130.  
  1131.         });
  1132.     }
  1133.  
  1134. }).apply(this, [window.theme, jQuery]);
  1135.  
  1136. // Colorpicker
  1137. (function(theme, $) {
  1138.  
  1139.     theme = theme || {};
  1140.  
  1141.     var instanceName = '__colorpicker';
  1142.  
  1143.     var PluginColorPicker = function($el, opts) {
  1144.         return this.initialize($el, opts);
  1145.     };
  1146.  
  1147.     PluginColorPicker.defaults = {
  1148.     };
  1149.  
  1150.     PluginColorPicker.prototype = {
  1151.         initialize: function($el, opts) {
  1152.             if ( $el.data( instanceName ) ) {
  1153.                 return this;
  1154.             }
  1155.  
  1156.             this.$el = $el;
  1157.  
  1158.             this
  1159.                 .setData()
  1160.                 .setOptions(opts)
  1161.                 .build();
  1162.  
  1163.             return this;
  1164.         },
  1165.  
  1166.         setData: function() {
  1167.             this.$el.data(instanceName, this);
  1168.  
  1169.             return this;
  1170.         },
  1171.  
  1172.         setOptions: function(opts) {
  1173.             this.options = $.extend( true, {}, PluginColorPicker.defaults, opts );
  1174.  
  1175.             return this;
  1176.         },
  1177.  
  1178.         build: function() {
  1179.             this.$el.colorpicker( this.options );
  1180.  
  1181.             return this;
  1182.         }
  1183.     };
  1184.  
  1185.     // expose to scope
  1186.     $.extend(theme, {
  1187.         PluginColorPicker: PluginColorPicker
  1188.     });
  1189.  
  1190.     // jquery plugin
  1191.     $.fn.themePluginColorPicker = function(opts) {
  1192.         return this.each(function() {
  1193.             var $this = $(this);
  1194.  
  1195.             if ($this.data(instanceName)) {
  1196.                 return $this.data(instanceName);
  1197.             } else {
  1198.                 return new PluginColorPicker($this, opts);
  1199.             }
  1200.  
  1201.         });
  1202.     }
  1203.  
  1204. }).apply(this, [window.theme, jQuery]);
  1205.  
  1206. // SummerNote
  1207. (function(theme, $) {
  1208.  
  1209.     theme = theme || {};
  1210.  
  1211.     var instanceName = '__summernote';
  1212.  
  1213.     var PluginSummerNote = function($el, opts) {
  1214.         return this.initialize($el, opts);
  1215.     };
  1216.  
  1217.     PluginSummerNote.defaults = {
  1218.         onfocus: function() {
  1219.             $( this ).closest( '.note-editor' ).addClass( 'active' );
  1220.         },
  1221.         onblur: function() {
  1222.             $( this ).closest( '.note-editor' ).removeClass( 'active' );
  1223.         }
  1224.     };
  1225.  
  1226.     PluginSummerNote.prototype = {
  1227.         initialize: function($el, opts) {
  1228.             if ( $el.data( instanceName ) ) {
  1229.                 return this;
  1230.             }
  1231.  
  1232.             this.$el = $el;
  1233.  
  1234.             this
  1235.                 .setData()
  1236.                 .setOptions(opts)
  1237.                 .build();
  1238.  
  1239.             return this;
  1240.         },
  1241.  
  1242.         setData: function() {
  1243.             this.$el.data(instanceName, this);
  1244.  
  1245.             return this;
  1246.         },
  1247.  
  1248.         setOptions: function(opts) {
  1249.             this.options = $.extend( true, {}, PluginSummerNote.defaults, opts );
  1250.  
  1251.             return this;
  1252.         },
  1253.  
  1254.         build: function() {
  1255.             this.$el.summernote( this.options );
  1256.  
  1257.             return this;
  1258.         }
  1259.     };
  1260.  
  1261.     // expose to scope
  1262.     $.extend(theme, {
  1263.         PluginSummerNote: PluginSummerNote
  1264.     });
  1265.  
  1266.     // jquery plugin
  1267.     $.fn.themePluginSummerNote = function(opts) {
  1268.         return this.each(function() {
  1269.             var $this = $(this);
  1270.  
  1271.             if ($this.data(instanceName)) {
  1272.                 return $this.data(instanceName);
  1273.             } else {
  1274.                 return new PluginSummerNote($this, opts);
  1275.             }
  1276.  
  1277.         });
  1278.     }
  1279.  
  1280. }).apply(this, [window.theme, jQuery]);
  1281.  
  1282. // TextArea AutoSize
  1283. (function(theme, $) {
  1284.  
  1285.     theme = theme || {};
  1286.  
  1287.     var initialized = false;
  1288.     var instanceName = '__textareaAutosize';
  1289.  
  1290.     var PluginTextAreaAutoSize = function($el, opts) {
  1291.         return this.initialize($el, opts);
  1292.     };
  1293.  
  1294.     PluginTextAreaAutoSize.defaults = {
  1295.     };
  1296.  
  1297.     PluginTextAreaAutoSize.prototype = {
  1298.         initialize: function($el, opts) {
  1299.             if (initialized) {
  1300.                 return this;
  1301.             }
  1302.  
  1303.             this.$el = $el;
  1304.  
  1305.             this
  1306.                 .setData()
  1307.                 .setOptions(opts)
  1308.                 .build();
  1309.  
  1310.             return this;
  1311.         },
  1312.  
  1313.         setData: function() {
  1314.             this.$el.data(instanceName, this);
  1315.  
  1316.             return this;
  1317.         },
  1318.  
  1319.         setOptions: function(opts) {
  1320.             this.options = $.extend( true, {}, PluginTextAreaAutoSize.defaults, opts );
  1321.  
  1322.             return this;
  1323.         },
  1324.  
  1325.         build: function() {
  1326.  
  1327.             autosize($(this.$el));
  1328.  
  1329.             return this;
  1330.         }
  1331.     };
  1332.  
  1333.     // expose to scope
  1334.     $.extend(theme, {
  1335.         PluginTextAreaAutoSize: PluginTextAreaAutoSize
  1336.     });
  1337.  
  1338.     // jquery plugin
  1339.     $.fn.themePluginTextAreaAutoSize = function(opts) {
  1340.         return this.each(function() {
  1341.             var $this = $(this);
  1342.  
  1343.             if ($this.data(instanceName)) {
  1344.                 return $this.data(instanceName);
  1345.             } else {
  1346.                 return new PluginTextAreaAutoSize($this, opts);
  1347.             }
  1348.  
  1349.         });
  1350.     }
  1351.  
  1352. }).apply(this, [window.theme, jQuery]);
  1353.  
  1354. // Animate
  1355. (function(theme, $) {
  1356.  
  1357.     theme = theme || {};
  1358.  
  1359.     var instanceName = '__animate';
  1360.  
  1361.     var PluginAnimate = function($el, opts) {
  1362.         return this.initialize($el, opts);
  1363.     };
  1364.  
  1365.     PluginAnimate.defaults = {
  1366.         accX: 0,
  1367.         accY: -150,
  1368.         delay: 1
  1369.     };
  1370.  
  1371.     PluginAnimate.prototype = {
  1372.         initialize: function($el, opts) {
  1373.             if ( $el.data( instanceName ) ) {
  1374.                 return this;
  1375.             }
  1376.  
  1377.             this.$el = $el;
  1378.  
  1379.             this
  1380.                 .setData()
  1381.                 .setOptions(opts)
  1382.                 .build();
  1383.  
  1384.             return this;
  1385.         },
  1386.  
  1387.         setData: function() {
  1388.             this.$el.data(instanceName, this);
  1389.  
  1390.             return this;
  1391.         },
  1392.  
  1393.         setOptions: function(opts) {
  1394.             this.options = $.extend(true, {}, PluginAnimate.defaults, opts, {
  1395.                 wrapper: this.$el
  1396.             });
  1397.  
  1398.             return this;
  1399.         },
  1400.  
  1401.         build: function() {
  1402.             var self = this,
  1403.                 $el = this.options.wrapper,
  1404.                 delay = 0;
  1405.  
  1406.             $el.addClass('appear-animation');
  1407.  
  1408.             if(!$('html').hasClass('no-csstransitions') && $(window).width() > 767) {
  1409.  
  1410.                 $el.appear(function() {
  1411.  
  1412.                     delay = ($el.attr('data-appear-animation-delay') ? $el.attr('data-appear-animation-delay') : self.options.delay);
  1413.  
  1414.                     if(delay > 1) {
  1415.                         $el.css('animation-delay', delay + 'ms');
  1416.                     }
  1417.  
  1418.                     $el.addClass($el.attr('data-appear-animation'));
  1419.  
  1420.                     setTimeout(function() {
  1421.                         $el.addClass('appear-animation-visible');
  1422.                     }, delay);
  1423.  
  1424.                 }, {accX: self.options.accX, accY: self.options.accY});
  1425.  
  1426.             } else {
  1427.  
  1428.                 $el.addClass('appear-animation-visible');
  1429.  
  1430.             }
  1431.  
  1432.             return this;
  1433.         }
  1434.     };
  1435.  
  1436.     // expose to scope
  1437.     $.extend(theme, {
  1438.         PluginAnimate: PluginAnimate
  1439.     });
  1440.  
  1441.     // jquery plugin
  1442.     $.fn.themePluginAnimate = function(opts) {
  1443.         return this.map(function() {
  1444.             var $this = $(this);
  1445.  
  1446.             if ($this.data(instanceName)) {
  1447.                 return $this.data(instanceName);
  1448.             } else {
  1449.                 return new PluginAnimate($this, opts);
  1450.             }
  1451.  
  1452.         });
  1453.     };
  1454.  
  1455. }).apply(this, [window.theme, jQuery]);
  1456.  
  1457. // Lightbox
  1458. (function(theme, $) {
  1459.  
  1460.     theme = theme || {};
  1461.  
  1462.     var instanceName = '__lightbox';
  1463.  
  1464.     var PluginLightbox = function($el, opts) {
  1465.         return this.initialize($el, opts);
  1466.     };
  1467.  
  1468.     PluginLightbox.defaults = {
  1469.         tClose: 'Close (Esc)', // Alt text on close button
  1470.         tLoading: 'Loading...', // Text that is displayed during loading. Can contain %curr% and %total% keys
  1471.         gallery: {
  1472.             tPrev: 'Previous (Left arrow key)', // Alt text on left arrow
  1473.             tNext: 'Next (Right arrow key)', // Alt text on right arrow
  1474.             tCounter: '%curr% of %total%' // Markup for "1 of 7" counter
  1475.         },
  1476.         image: {
  1477.             tError: '<a href="%url%">The image</a> could not be loaded.' // Error message when image could not be loaded
  1478.         },
  1479.         ajax: {
  1480.             tError: '<a href="%url%">The content</a> could not be loaded.' // Error message when ajax request failed
  1481.         }
  1482.     };
  1483.  
  1484.     PluginLightbox.prototype = {
  1485.         initialize: function($el, opts) {
  1486.             if ( $el.data( instanceName ) ) {
  1487.                 return this;
  1488.             }
  1489.  
  1490.             this.$el = $el;
  1491.  
  1492.             this
  1493.                 .setData()
  1494.                 .setOptions(opts)
  1495.                 .build();
  1496.  
  1497.             return this;
  1498.         },
  1499.  
  1500.         setData: function() {
  1501.             this.$el.data(instanceName, this);
  1502.  
  1503.             return this;
  1504.         },
  1505.  
  1506.         setOptions: function(opts) {
  1507.             this.options = $.extend(true, {}, PluginLightbox.defaults, opts, {
  1508.                 wrapper: this.$el
  1509.             });
  1510.  
  1511.             return this;
  1512.         },
  1513.  
  1514.         build: function() {
  1515.             this.options.wrapper.magnificPopup(this.options);
  1516.  
  1517.             return this;
  1518.         }
  1519.     };
  1520.  
  1521.     // expose to scope
  1522.     $.extend(theme, {
  1523.         PluginLightbox: PluginLightbox
  1524.     });
  1525.  
  1526.     // jquery plugin
  1527.     $.fn.themePluginLightbox = function(opts) {
  1528.         return this.each(function() {
  1529.             var $this = $(this);
  1530.  
  1531.             if ($this.data(instanceName)) {
  1532.                 return $this.data(instanceName);
  1533.             } else {
  1534.                 return new PluginLightbox($this, opts);
  1535.             }
  1536.  
  1537.         });
  1538.     }
  1539.  
  1540. }).apply(this, [window.theme, jQuery]);
  1541.  
  1542.  
  1543. /* Init */
  1544. // Tooltip
  1545. (function($) {
  1546.  
  1547.     'use strict';
  1548.  
  1549.     if ( $.isFunction( $.fn['tooltip'] ) ) {
  1550.         $( '[data-toggle=tooltip],[rel=tooltip]' ).tooltip({ container: 'body' });
  1551.     }
  1552.  
  1553. }).apply(this, [jQuery]);
  1554.  
  1555. // Header Menu Nav
  1556. (function(theme, $) {
  1557.  
  1558.     'use strict';
  1559.    
  1560.     if (typeof theme.Nav !== 'undefined') {
  1561.         theme.Nav.initialize();
  1562.     }
  1563.    
  1564. }).apply(this, [window.theme, jQuery]);
  1565.  
  1566. // Scroll to Top
  1567. (function(theme, $) {
  1568.     // Scroll to Top Button.
  1569.     if (typeof theme.PluginScrollToTop !== 'undefined') {
  1570.         theme.PluginScrollToTop.initialize();
  1571.     }
  1572. }).apply(this, [window.theme, jQuery]);
  1573.  
  1574. // Sidebar Widgets
  1575. (function($) {
  1576.  
  1577.     'use strict';
  1578.  
  1579.     function expand( content ) {
  1580.         content.children( '.widget-content' ).slideDown( 'fast', function() {
  1581.             $(this).css( 'display', '' );
  1582.             content.removeClass( 'widget-collapsed' );
  1583.  
  1584.             $(window).trigger('widget.collapsed');
  1585.         });
  1586.     }
  1587.  
  1588.     function collapse( content ) {
  1589.         content.children('.widget-content' ).slideUp( 'fast', function() {
  1590.             content.addClass( 'widget-collapsed' );
  1591.             $(this).css( 'display', '' );
  1592.  
  1593.             $(window).trigger('widget.expanded');
  1594.         });
  1595.     }
  1596.  
  1597.     var $widgets = $( '.sidebar-widget' );
  1598.  
  1599.     $widgets.each( function() {
  1600.  
  1601.         var $widget = $( this ),
  1602.             $toggler = $widget.find( '.widget-toggle' );
  1603.  
  1604.         $toggler.on('click.widget-toggler', function() {
  1605.             $widget.hasClass('widget-collapsed') ? expand($widget) : collapse($widget);
  1606.         });
  1607.     });
  1608.  
  1609. }).apply(this, [jQuery]);
  1610.  
  1611. // Colorpicker
  1612. (function($) {
  1613.  
  1614.     'use strict';
  1615.  
  1616.     if ( $.isFunction($.fn[ 'colorpicker' ]) ) {
  1617.  
  1618.         $(function() {
  1619.             $('[data-plugin-colorpicker]').each(function() {
  1620.                 var $this = $( this ),
  1621.                     opts = {};
  1622.  
  1623.                 var pluginOptions = $this.data('plugin-options');
  1624.                 if (pluginOptions)
  1625.                     opts = pluginOptions;
  1626.  
  1627.                 $this.themePluginColorPicker(opts);
  1628.             });
  1629.         });
  1630.  
  1631.     }
  1632.  
  1633. }).apply(this, [jQuery]);
  1634.  
  1635. (function($) {
  1636.  
  1637.     'use strict';
  1638.  
  1639.     if ( $.isFunction( $.fn[ 'placeholder' ]) ) {
  1640.  
  1641.         $('input[placeholder]').placeholder();
  1642.  
  1643.     }
  1644.  
  1645. }).apply(this, [jQuery]);
  1646.  
  1647. // SummerNote
  1648. (function($) {
  1649.  
  1650.     'use strict';
  1651.  
  1652.     if ( $.isFunction($.fn[ 'summernote' ]) ) {
  1653.  
  1654.         $(function() {
  1655.             $('[data-plugin-summernote]').each(function() {
  1656.                 var $this = $( this ),
  1657.                     opts = {};
  1658.  
  1659.                 var pluginOptions = $this.data('plugin-options');
  1660.                 if (pluginOptions)
  1661.                     opts = pluginOptions;
  1662.  
  1663.                 $this.themePluginSummerNote(opts);
  1664.             });
  1665.         });
  1666.  
  1667.     }
  1668.  
  1669. }).apply(this, [jQuery]);
  1670.  
  1671. // TextArea AutoSize
  1672. (function($) {
  1673.  
  1674.     'use strict';
  1675.  
  1676.     if ( typeof autosize === 'function' ) {
  1677.  
  1678.         $(function() {
  1679.             $('[data-plugin-textarea-autosize]').each(function() {
  1680.                 var $this = $( this ),
  1681.                     opts = {};
  1682.  
  1683.                 var pluginOptions = $this.data('plugin-options');
  1684.                 if (pluginOptions)
  1685.                     opts = pluginOptions;
  1686.  
  1687.                 $this.themePluginTextAreaAutoSize(opts);
  1688.             });
  1689.         });
  1690.  
  1691.     }
  1692.  
  1693. }).apply(this, [jQuery]);
  1694.  
  1695. // Animate
  1696. (function($) {
  1697.  
  1698.     'use strict';
  1699.  
  1700.     if ( $.isFunction($.fn[ 'appear' ]) ) {
  1701.  
  1702.         $(function() {
  1703.             $('[data-plugin-animate], [data-appear-animation]').each(function() {
  1704.                 var $this = $( this ),
  1705.                     opts = {};
  1706.  
  1707.                 var pluginOptions = $this.data('plugin-options');
  1708.                 if (pluginOptions)
  1709.                     opts = pluginOptions;
  1710.  
  1711.                 $this.themePluginAnimate(opts);
  1712.             });
  1713.         });
  1714.  
  1715.     }
  1716.  
  1717. }).apply(this, [jQuery]);
  1718.  
  1719. // Lightbox
  1720. (function($) {
  1721.  
  1722.     'use strict';
  1723.  
  1724.     if ( $.isFunction($.fn[ 'magnificPopup' ]) ) {
  1725.  
  1726.         $(function() {
  1727.             $('[data-plugin-lightbox], .lightbox:not(.manual)').each(function() {
  1728.                 var $this = $( this ),
  1729.                     opts = {};
  1730.  
  1731.                 var pluginOptions = $this.data('plugin-options');
  1732.                 if (pluginOptions)
  1733.                     opts = pluginOptions;
  1734.  
  1735.                 $this.themePluginLightbox(opts);
  1736.             });
  1737.         });
  1738.  
  1739.     }
  1740.  
  1741. }).apply(this, [jQuery]);
  1742.  
  1743. // Scrollable
  1744. (function($) {
  1745.  
  1746.     'use strict';
  1747.  
  1748.     if ( $.isFunction($.fn[ 'nanoScroller' ]) ) {
  1749.  
  1750.         $(function() {
  1751.             $('[data-plugin-scrollable]').each(function() {
  1752.                 var $this = $( this ),
  1753.                     opts = {};
  1754.  
  1755.                 var pluginOptions = $this.data('plugin-options');
  1756.                 if (pluginOptions) {
  1757.                     opts = pluginOptions;
  1758.                 }
  1759.  
  1760.                 $this.themePluginScrollable(opts);
  1761.             });
  1762.         });
  1763.  
  1764.     }
  1765.  
  1766. }).apply(this, [jQuery]);
  1767.  
  1768. // Toggle
  1769. (function($) {
  1770.  
  1771.     'use strict';
  1772.  
  1773.     $(function() {
  1774.         $('[data-plugin-toggle]').each(function() {
  1775.             var $this = $( this ),
  1776.                 opts = {};
  1777.  
  1778.             var pluginOptions = $this.data('plugin-options');
  1779.             if (pluginOptions)
  1780.                 opts = pluginOptions;
  1781.  
  1782.             $this.themePluginToggle(opts);
  1783.         });
  1784.     });
  1785.  
  1786. }).apply(this, [jQuery]);
  1787.  
  1788. /* Custom */
  1789. //Galería -> Sender > Imgs
  1790. (function($) {
  1791.  
  1792.     'use strict';
  1793.  
  1794.     /*
  1795.     Gallery
  1796.     */
  1797.     if ( $.isFunction($.fn[ 'magnificPopup' ]) ) {
  1798.         $('.popup-gallery').magnificPopup({
  1799.             delegate: 'a',
  1800.             type: 'image',
  1801.             tLoading: 'Cargando imagen...',
  1802.             mainClass: 'mfp-img-mobile',
  1803.             gallery: {
  1804.                 enabled: true,
  1805.                 navigateByImgClick: true,
  1806.                 preload: [0,1] // Will preload 0 - before current, and 1 after the current image
  1807.             },
  1808.             image: {
  1809.                 tError: 'Error al cargar la imagen'
  1810.             }
  1811.         });
  1812.     }
  1813.  
  1814.     /* Sender -> cargador de parámetros de categorías al modificar */
  1815.     $(document).on('change','#app_sender_category', function(){
  1816.         $.ajax({
  1817.             url : '/category_ajax',
  1818.             type: 'POST',
  1819.             data: { id: $(this).val()},
  1820.             dataType: "json",
  1821.             success: function(response) {
  1822.                 $('#app_sender_tensionAlarm').attr('value', response.tension);
  1823.                 $('#app_sender_power1Alarm').attr('value', response.power1);
  1824.                 $('#app_sender_power2Alarm').attr('value', response.power2);
  1825.                 $('#app_sender_nolightAlarm').attr('value', response.nolight);
  1826.                 $('#app_sender_notransmitAlarm').attr('value', response.notransmit);
  1827.             },
  1828.             error: function(response) {
  1829.                 console.info('ERROR!');
  1830.                 console.info(response);
  1831.             }
  1832.         });
  1833.     });
  1834.  
  1835.     /* Página de Mantenimiento -> Carga la ip  */
  1836.     $(document).on('click','#load_my_ip', function() {
  1837.         if ($('#app_maintenance_ips').val() === '') {
  1838.             $('#app_maintenance_ips').val($('#load_my_ip').data('ip'));
  1839.         }
  1840.         else {
  1841.             $('#app_maintenance_ips').attr('value', $('#app_maintenance_ips').val() + ',' + $('#load_my_ip').data('ip'));
  1842.         }
  1843.        
  1844.     });
  1845.  
  1846.     //===============>GEOLOCALIZACIÓN
  1847.     $(document).on('click','#btn-get-geo', function() {
  1848.         if (navigator.geolocation) {
  1849.             navigator.geolocation.getCurrentPosition(showPosition, showError);
  1850.         }
  1851.         else {
  1852.             alert('Geolocalización no disponible en este dispositivo.');
  1853.         }
  1854.     });
  1855.  
  1856.     function showPosition(position) {
  1857.         console.info(position.coords.latitude);
  1858.         console.info(position.coords.longitude);
  1859.  
  1860.         $.ajax({
  1861.             url : '/sender_ajax',
  1862.             type: 'POST',
  1863.             data: {
  1864.                 id: $('#btn-get-geo').data('id'),
  1865.                 latitude: position.coords.latitude,
  1866.                 longitude: position.coords.longitude
  1867.             },
  1868.             dataType: 'json',
  1869.             success: function(response) {
  1870.                 window.location.replace(response.redirectToRoute)
  1871.             },
  1872.             error: function(response) {
  1873.                 console.info('ERROR!');
  1874.                 console.info(response);
  1875.                 alert('Error! Contacta con Soporte Técnico.');
  1876.             }
  1877.         });
  1878.     }
  1879.  
  1880.     function showError(error) {
  1881.         switch(error.code) {
  1882.             case error.PERMISSION_DENIED:
  1883.                 alert('Imposible Geolocalizar el Emisor. Motivo: El usuario ha bloqueado la geolocalización. Para poder geolocalizar el Emisor es necesario que concedas permisos.');
  1884.                 break;
  1885.             case error.POSITION_UNAVAILABLE:
  1886.                 alert('Imposible Geolocalizar el Emisor. Motivo: La información osbre la localización no está disponible.');
  1887.                 break;
  1888.             case error.TIMEOUT:
  1889.                 alert('Imposible Geolocalizar el Emisor. Motivo: Tiempo de petición agotado.');
  1890.                 break;
  1891.             case error.UNKNOWN_ERROR:
  1892.                 alert('Imposible Geolocalizar el Emisor. Motivo: Error desconocido. Contacta con Soporte Técnico.');
  1893.                 break;
  1894.           }
  1895.     }
  1896. }).apply(this, [jQuery]);
  1897.  
  1898.     /* Inicializa el mapa de los dsb's */
  1899.     function initMap() {
  1900.  
  1901.         if (data.positions != 'undefinied') {
  1902.  
  1903.             var positions = data.positions;
  1904.  
  1905.             var map = new google.maps.Map(document.getElementById('map'), {
  1906.                 center: new google.maps.LatLng('40.428567', '-3.707541'),
  1907.                 zoom: 6,
  1908.                 mapTypeId: google.maps.MapTypeId.ROADMAP
  1909.             });
  1910.  
  1911.             var markers = [];
  1912.  
  1913.             positions.forEach(function(positions) {
  1914.                 marker = new google.maps.Marker({
  1915.                     map: map,
  1916.                     title: positions.name,
  1917.                     position: new google.maps.LatLng(positions.latitude, positions.longitude),
  1918.                     url: '/sender/'+positions.id
  1919.                 });
  1920.                 markers.push(marker);
  1921.  
  1922.                 google.maps.event.addListener(marker, 'click', function() {
  1923.                     window.location.href = this.url;
  1924.                 });
  1925.             });
  1926.  
  1927.  
  1928.  
  1929.             var markerCluster = new MarkerClusterer(map, markers,
  1930.                 {imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'});
  1931.         }
  1932.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement