Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.theme = {};
- // Theme Common Functions
- window.theme.fn = {
- getOptions: function(opts) {
- if (typeof(opts) == 'object') {
- return opts;
- } else if (typeof(opts) == 'string') {
- try {
- return JSON.parse(opts.replace(/'/g,'"').replace(';',''));
- } catch(e) {
- return {};
- }
- } else {
- return {};
- }
- }
- };
- // Navigation
- (function($) {
- 'use strict';
- var $items = $( '.nav-main li.nav-parent' );
- function expand( $li ) {
- $li.children( 'ul.nav-children' ).slideDown( 'fast', function() {
- $li.addClass( 'nav-expanded' );
- $(this).css( 'display', '' );
- ensureVisible( $li );
- });
- }
- function collapse( $li ) {
- $li.children('ul.nav-children' ).slideUp( 'fast', function() {
- $(this).css( 'display', '' );
- $li.removeClass( 'nav-expanded' );
- });
- }
- function ensureVisible( $li ) {
- var scroller = $li.offsetParent();
- if ( !scroller.get(0) ) {
- return false;
- }
- var top = $li.position().top;
- if ( top < 0 ) {
- scroller.animate({
- scrollTop: scroller.scrollTop() + top
- }, 'fast');
- }
- }
- function buildSidebarNav( anchor, prev, next, ev ) {
- if ( anchor.prop('href') ) {
- var arrowWidth = parseInt(window.getComputedStyle(anchor.get(0), ':after').width, 10) || 0;
- if (ev.offsetX > anchor.get(0).offsetWidth - arrowWidth) {
- ev.preventDefault();
- }
- }
- if ( prev.get( 0 ) !== next.get( 0 ) ) {
- collapse( prev );
- expand( next );
- } else {
- collapse( prev );
- }
- }
- $items.find('> a').on('click', function( ev ) {
- var $html = $('html'),
- $window = $(window),
- $anchor = $( this ),
- $prev = $anchor.closest('ul.nav').find('> li.nav-expanded' ),
- $next = $anchor.closest('li'),
- $ev = ev;
- if( !$html.hasClass('sidebar-left-big-icons') ) {
- buildSidebarNav( $anchor, $prev, $next, $ev );
- } else if( $html.hasClass('sidebar-left-big-icons') && $window.width() < 768 ) {
- buildSidebarNav( $anchor, $prev, $next, $ev );
- }
- });
- }).apply(this, [jQuery]);
- // Skeleton
- (function(theme, $) {
- 'use strict';
- theme = theme || {};
- var $body = $( 'body' ),
- $html = $( 'html' ),
- $window = $( window ),
- isAndroid = navigator.userAgent.toLowerCase().indexOf('android') > -1,
- isIpad = navigator.userAgent.match(/iPad/i) != null;
- // mobile devices with fixed has a lot of issues when focus inputs and others...
- if ( typeof $.browser !== 'undefined' && $.browser.mobile && $html.hasClass('fixed') ) {
- $html.removeClass( 'fixed' ).addClass( 'scroll' );
- }
- var Skeleton = {
- options: {
- sidebars: {
- menu: '#content-menu',
- left: '#sidebar-left',
- right: '#sidebar-right'
- }
- },
- customScroll: ( !Modernizr.overflowscrolling && !isAndroid && $.fn.nanoScroller !== 'undefined'),
- initialize: function() {
- this
- .setVars()
- .build()
- .events();
- },
- setVars: function() {
- this.sidebars = {};
- this.sidebars.left = {
- $el: $( this.options.sidebars.left )
- };
- this.sidebars.right = {
- $el: $( this.options.sidebars.right ),
- isOpened: $html.hasClass( 'sidebar-right-opened' )
- };
- this.sidebars.menu = {
- $el: $( this.options.sidebars.menu ),
- isOpened: $html.hasClass( 'inner-menu-opened' )
- };
- return this;
- },
- build: function() {
- if ( typeof $.browser !== 'undefined' && $.browser.mobile ) {
- $html.addClass( 'mobile-device' );
- } else {
- $html.addClass( 'no-mobile-device' );
- }
- $html.addClass( 'custom-scroll' );
- if ( this.customScroll ) {
- this.buildSidebarLeft();
- this.buildContentMenu();
- }
- if( isIpad ) {
- this.fixIpad();
- }
- this.buildSidebarRight();
- return this;
- },
- events: function() {
- if ( this.customScroll ) {
- this.eventsSidebarLeft();
- }
- this.eventsSidebarRight();
- this.eventsContentMenu();
- if ( typeof $.browser !== 'undefined' && !this.customScroll && isAndroid ) {
- this.fixScroll();
- }
- return this;
- },
- fixScroll: function() {
- var _self = this;
- $window
- .on( 'sidebar-left-opened sidebar-right-toggle', function( e, data ) {
- _self.preventBodyScrollToggle( data.added );
- });
- },
- fixIpad: function() {
- var _self = this;
- $('.header, .page-header, .content-body').on('click', function(){
- $html.removeClass('sidebar-left-opened');
- });
- },
- buildSidebarLeft: function() {
- var initialPosition = 0;
- this.sidebars.left.isOpened = !$html.hasClass( 'sidebar-left-collapsed' ) || $html.hasClass( 'sidebar-left-opened' );
- this.sidebars.left.$nano = this.sidebars.left.$el.find( '.nano' );
- if (typeof localStorage !== 'undefined') {
- this.sidebars.left.$nano.on('update', function(e, values) {
- localStorage.setItem('sidebar-left-position', values.position);
- });
- if (localStorage.getItem('sidebar-left-position') !== null) {
- initialPosition = localStorage.getItem('sidebar-left-position');
- this.sidebars.left.$el.find( '.nano-content').scrollTop(initialPosition);
- }
- }
- this.sidebars.left.$nano.nanoScroller({
- scrollTop: initialPosition,
- alwaysVisible: true,
- preventPageScrolling: $html.hasClass( 'fixed' )
- });
- return this;
- },
- eventsSidebarLeft: function() {
- var _self = this,
- $nano = this.sidebars.left.$nano;
- var open = function() {
- if ( _self.sidebars.left.isOpened ) {
- return close();
- }
- _self.sidebars.left.isOpened = true;
- $html.addClass( 'sidebar-left-opened' );
- $window.trigger( 'sidebar-left-toggle', {
- added: true,
- removed: false
- });
- $html.on( 'click.close-left-sidebar', function(e) {
- e.stopPropagation();
- close(e);
- });
- };
- var close = function(e) {
- if ( !!e && !!e.target && ($(e.target).closest( '.sidebar-left' ).get(0) || !$(e.target).closest( 'html' ).get(0)) ) {
- e.preventDefault();
- return false;
- } else {
- $html.removeClass( 'sidebar-left-opened' );
- $html.off( 'click.close-left-sidebar' );
- $window.trigger( 'sidebar-left-toggle', {
- added: false,
- removed: true
- });
- _self.sidebars.left.isOpened = !$html.hasClass( 'sidebar-left-collapsed' );
- }
- };
- var updateNanoScroll = function() {
- if ( $.support.transition ) {
- $nano.nanoScroller();
- $nano
- .one('bsTransitionEnd', updateNanoScroll)
- .emulateTransitionEnd(150)
- } else {
- updateNanoScroll();
- }
- };
- var isToggler = function( element ) {
- return $(element).data('fire-event') === 'sidebar-left-toggle' || $(element).parents().data('fire-event') === 'sidebar-left-toggle';
- };
- this.sidebars.left.$el
- .on( 'click', function() {
- updateNanoScroll();
- })
- .on('touchend', function(e) {
- _self.sidebars.left.isOpened = !$html.hasClass( 'sidebar-left-collapsed' ) || $html.hasClass( 'sidebar-left-opened' );
- if ( !_self.sidebars.left.isOpened && !isToggler(e.target) ) {
- e.stopPropagation();
- e.preventDefault();
- open();
- }
- });
- $nano
- .on( 'mouseenter', function() {
- if ( $html.hasClass( 'sidebar-left-collapsed' ) ) {
- $nano.nanoScroller();
- }
- })
- .on( 'mouseleave', function() {
- if ( $html.hasClass( 'sidebar-left-collapsed' ) ) {
- $nano.nanoScroller();
- }
- });
- $window.on( 'sidebar-left-toggle', function(e, toggle) {
- if ( toggle.removed ) {
- $html.removeClass( 'sidebar-left-opened' );
- $html.off( 'click.close-left-sidebar' );
- }
- // Recalculate Owl Carousel sizes
- $('.owl-carousel').trigger('refresh.owl.carousel');
- });
- return this;
- },
- buildSidebarRight: function() {
- this.sidebars.right.isOpened = $html.hasClass( 'sidebar-right-opened' );
- if ( this.customScroll ) {
- this.sidebars.right.$nano = this.sidebars.right.$el.find( '.nano' );
- this.sidebars.right.$nano.nanoScroller({
- alwaysVisible: true,
- preventPageScrolling: true
- });
- }
- return this;
- },
- eventsSidebarRight: function() {
- var _self = this;
- var open = function() {
- if ( _self.sidebars.right.isOpened ) {
- return close();
- }
- _self.sidebars.right.isOpened = true;
- $html.addClass( 'sidebar-right-opened' );
- $window.trigger( 'sidebar-right-toggle', {
- added: true,
- removed: false
- });
- $html.on( 'click.close-right-sidebar', function(e) {
- e.stopPropagation();
- close(e);
- });
- };
- var close = function(e) {
- if ( !!e && !!e.target && ($(e.target).closest( '.sidebar-right' ).get(0) || !$(e.target).closest( 'html' ).get(0)) ) {
- return false;
- }
- $html.removeClass( 'sidebar-right-opened' );
- $html.off( 'click.close-right-sidebar' );
- $window.trigger( 'sidebar-right-toggle', {
- added: false,
- removed: true
- });
- _self.sidebars.right.isOpened = false;
- };
- var bind = function() {
- $('[data-open="sidebar-right"]').on('click', function(e) {
- var $el = $(this);
- e.stopPropagation();
- if ( $el.is('a') )
- e.preventDefault();
- open();
- });
- };
- this.sidebars.right.$el.find( '.mobile-close' )
- .on( 'click', function( e ) {
- e.preventDefault();
- $html.trigger( 'click.close-right-sidebar' );
- });
- bind();
- return this;
- },
- buildContentMenu: function() {
- if ( !$html.hasClass( 'fixed' ) ) {
- return false;
- }
- this.sidebars.menu.$nano = this.sidebars.menu.$el.find( '.nano' );
- this.sidebars.menu.$nano.nanoScroller({
- alwaysVisible: true,
- preventPageScrolling: true
- });
- return this;
- },
- eventsContentMenu: function() {
- var _self = this;
- var open = function() {
- if ( _self.sidebars.menu.isOpened ) {
- return close();
- }
- _self.sidebars.menu.isOpened = true;
- $html.addClass( 'inner-menu-opened' );
- $window.trigger( 'inner-menu-toggle', {
- added: true,
- removed: false
- });
- $html.on( 'click.close-inner-menu', function(e) {
- close(e);
- });
- };
- var close = function(e) {
- var hasEvent,
- hasTarget,
- isCollapseButton,
- isInsideModal,
- isInsideInnerMenu,
- isInsideHTML,
- $target;
- hasEvent = !!e;
- hasTarget = hasEvent && !!e.target;
- if ( hasTarget ) {
- $target = $(e.target);
- }
- isCollapseButton = hasTarget && !!$target.closest( '.inner-menu-collapse' ).get(0);
- isInsideModal = hasTarget && !!$target.closest( '.mfp-wrap' ).get(0);
- isInsideInnerMenu = hasTarget && !!$target.closest( '.inner-menu' ).get(0);
- isInsideHTML = hasTarget && !!$target.closest( 'html' ).get(0);
- if ( (!isCollapseButton && (isInsideInnerMenu || !isInsideHTML)) || isInsideModal ) {
- return false;
- }
- e.stopPropagation();
- $html.removeClass( 'inner-menu-opened' );
- $html.off( 'click.close-inner-menu' );
- $window.trigger( 'inner-menu-toggle', {
- added: false,
- removed: true
- });
- _self.sidebars.menu.isOpened = false;
- };
- var bind = function() {
- $('[data-open="inner-menu"]').on('click', function(e) {
- var $el = $(this);
- e.stopPropagation();
- if ( $el.is('a') )
- e.preventDefault();
- open();
- });
- };
- bind();
- /* Nano Scroll */
- if ( $html.hasClass( 'fixed' ) ) {
- var $nano = this.sidebars.menu.$nano;
- var updateNanoScroll = function() {
- if ( $.support.transition ) {
- $nano.nanoScroller();
- $nano
- .one('bsTransitionEnd', updateNanoScroll)
- .emulateTransitionEnd(150)
- } else {
- updateNanoScroll();
- }
- };
- this.sidebars.menu.$el
- .on( 'click', function() {
- updateNanoScroll();
- });
- }
- return this;
- },
- preventBodyScrollToggle: function( shouldPrevent, $el ) {
- setTimeout(function() {
- if ( shouldPrevent ) {
- $body
- .data( 'scrollTop', $body.get(0).scrollTop )
- .css({
- position: 'fixed',
- top: $body.get(0).scrollTop * -1
- })
- } else {
- $body
- .css({
- position: '',
- top: ''
- })
- .scrollTop( $body.data( 'scrollTop' ) );
- }
- }, 150);
- }
- };
- // expose to scope
- $.extend(theme, {
- Skeleton: Skeleton
- });
- }).apply(this, [window.theme, jQuery]);
- /* Browser Selector */
- (function($) {
- $.extend({
- browserSelector: function() {
- // jQuery.browser.mobile (http://detectmobilebrowser.com/)
- (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);
- // Touch
- var hasTouch = 'ontouchstart' in window || navigator.msMaxTouchPoints;
- var u = navigator.userAgent,
- ua = u.toLowerCase(),
- is = function (t) {
- return ua.indexOf(t) > -1;
- },
- g = 'gecko',
- w = 'webkit',
- s = 'safari',
- o = 'opera',
- h = document.documentElement,
- 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'];
- c = b.join(' ');
- if ($.browser.mobile) {
- c += ' mobile';
- }
- if (hasTouch) {
- c += ' touch';
- }
- h.className += ' ' + c;
- // IE11 Detect
- var isIE11 = !(window.ActiveXObject) && "ActiveXObject" in window;
- if (isIE11) {
- $('html').removeClass('gecko').addClass('ie ie11');
- return;
- }
- // Dark and Boxed Compatibility
- if($('body').hasClass('dark')) {
- $('html').addClass('dark');
- }
- if($('body').hasClass('boxed')) {
- $('html').addClass('boxed');
- }
- }
- });
- $.browserSelector();
- })(jQuery);
- // Base
- (function(theme, $) {
- 'use strict';
- theme = theme || {};
- theme.Skeleton.initialize();
- }).apply(this, [window.theme, jQuery]);
- // Bootstrap Toggle
- (function($) {
- 'use strict';
- var $window = $( window );
- var toggleClass = function( $el ) {
- if ( !!$el.data('toggleClassBinded') ) {
- return false;
- }
- var $target,
- className,
- eventName;
- $target = $( $el.attr('data-target') );
- className = $el.attr('data-toggle-class');
- eventName = $el.attr('data-fire-event');
- $el.on('click.toggleClass', function(e) {
- e.preventDefault();
- $target.toggleClass( className );
- var hasClass = $target.hasClass( className );
- if ( !!eventName ) {
- $window.trigger( eventName, {
- added: hasClass,
- removed: !hasClass
- });
- }
- });
- $el.data('toggleClassBinded', true);
- return true;
- };
- $(function() {
- $('[data-toggle-class][data-target]').each(function() {
- toggleClass( $(this) );
- });
- });
- }).apply(this, [jQuery]);
- // Header Menu Nav
- (function(theme, $) {
- 'use strict';
- theme = theme || {};
- var initialized = false;
- $.extend(theme, {
- Nav: {
- defaults: {
- wrapper: $('#mainNav'),
- scrollDelay: 600,
- scrollAnimation: 'easeOutQuad'
- },
- initialize: function($wrapper, opts) {
- if (initialized) {
- return this;
- }
- initialized = true;
- this.$wrapper = ($wrapper || this.defaults.wrapper);
- this
- .setOptions(opts)
- .build()
- .events();
- return this;
- },
- setOptions: function(opts) {
- // this.options = $.extend(true, {}, this.defaults, opts, theme.fn.getOptions(this.$wrapper.data('plugin-options')));
- return this;
- },
- build: function() {
- var self = this,
- $html = $('html'),
- $header = $('.header'),
- thumbInfoPreview;
- // Add Arrows
- $header.find('.dropdown-toggle:not(.notification-icon), .dropdown-submenu > a').append($('<i />').addClass('fa fa-caret-down'));
- // Preview Thumbs
- self.$wrapper.find('a[data-thumb-preview]').each(function() {
- thumbInfoPreview = $('<span />').addClass('thumb-info thumb-info-preview')
- .append($('<span />').addClass('thumb-info-wrapper')
- .append($('<span />').addClass('thumb-info-image').css('background-image', 'url(' + $(this).data('thumb-preview') + ')')
- )
- );
- $(this).append(thumbInfoPreview);
- });
- // Side Header Right (Reverse Dropdown)
- if($html.hasClass('side-header-right')) {
- $header.find('.dropdown').addClass('dropdown-reverse');
- }
- return this;
- },
- events: function() {
- var self = this,
- $header = $('.header'),
- $window = $(window);
- $header.find('a[href="#"]').on('click', function(e) {
- e.preventDefault();
- });
- // Mobile Arrows
- $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) {
- e.preventDefault();
- if ($window.width() < 992) {
- $(this).closest('li').toggleClass('opened');
- }
- });
- // Touch Devices with normal resolutions
- if('ontouchstart' in document.documentElement) {
- $header.find('.dropdown-toggle:not([href="#"]), .dropdown-submenu > a:not([href="#"])')
- .on('touchstart click', function(e) {
- if($window.width() > 991) {
- e.stopPropagation();
- e.preventDefault();
- if(e.handled !== true) {
- var li = $(this).closest('li');
- if(li.hasClass('tapped')) {
- location.href = $(this).attr('href');
- }
- li.addClass('tapped');
- e.handled = true;
- } else {
- return false;
- }
- return false;
- }
- })
- .on('blur', function(e) {
- $(this).closest('li').removeClass('tapped');
- });
- }
- // Collapse Nav
- $header.find('[data-collapse-nav]').on('click', function(e) {
- $(this).parents('.collapse').removeClass('in');
- });
- // Anchors Position
- $('[data-hash]').each(function() {
- var target = $(this).attr('href'),
- offset = ($(this).is("[data-hash-offset]") ? $(this).data('hash-offset') : 0);
- if($(target).get(0)) {
- $(this).on('click', function(e) {
- e.preventDefault();
- // Close Collapse if Opened
- $(this).parents('.collapse.in').removeClass('in');
- self.scrollToTarget(target, offset);
- return;
- });
- }
- });
- return this;
- },
- scrollToTarget: function(target, offset) {
- var self = this;
- $('body').addClass('scrolling');
- $('html, body').animate({
- scrollTop: $(target).offset().top - offset
- }, self.options.scrollDelay, self.options.scrollAnimation, function() {
- $('body').removeClass('scrolling');
- });
- return this;
- }
- }
- });
- }).apply(this, [window.theme, jQuery]);
- // Scroll to Top
- (function(theme, $) {
- theme = theme || {};
- $.extend(theme, {
- PluginScrollToTop: {
- defaults: {
- wrapper: $('body'),
- offset: 150,
- buttonClass: 'scroll-to-top',
- iconClass: 'fa fa-chevron-up',
- delay: 500,
- visibleMobile: false,
- label: false
- },
- initialize: function(opts) {
- initialized = true;
- this
- .setOptions(opts)
- .build()
- .events();
- return this;
- },
- setOptions: function(opts) {
- this.options = $.extend(true, {}, this.defaults, opts);
- return this;
- },
- build: function() {
- var self = this,
- $el;
- // Base HTML Markup
- $el = $('<a />')
- .addClass(self.options.buttonClass)
- .attr({
- 'href': '#',
- })
- .append(
- $('<i />')
- .addClass(self.options.iconClass)
- );
- // Visible Mobile
- if (!self.options.visibleMobile) {
- $el.addClass('hidden-mobile');
- }
- // Label
- if (self.options.label) {
- $el.append(
- $('<span />').html(self.options.label)
- );
- }
- this.options.wrapper.append($el);
- this.$el = $el;
- return this;
- },
- events: function() {
- var self = this,
- _isScrolling = false;
- // Click Element Action
- self.$el.on('click', function(e) {
- e.preventDefault();
- $('body, html').animate({
- scrollTop: 0
- }, self.options.delay);
- return false;
- });
- // Show/Hide Button on Window Scroll event.
- $(window).scroll(function() {
- if (!_isScrolling) {
- _isScrolling = true;
- if ($(window).scrollTop() > self.options.offset) {
- self.$el.stop(true, true).addClass('visible');
- _isScrolling = false;
- } else {
- self.$el.stop(true, true).removeClass('visible');
- _isScrolling = false;
- }
- }
- });
- return this;
- }
- }
- });
- }).apply(this, [window.theme, jQuery]);
- // Toggle
- (function(theme, $) {
- theme = theme || {};
- var instanceName = '__toggle';
- var PluginToggle = function($el, opts) {
- return this.initialize($el, opts);
- };
- PluginToggle.defaults = {
- duration: 350,
- isAccordion: false,
- addIcons: true
- };
- PluginToggle.prototype = {
- initialize: function($el, opts) {
- if ( $el.data( instanceName ) ) {
- return this;
- }
- this.$el = $el;
- this
- .setData()
- .setOptions(opts)
- .build();
- return this;
- },
- setData: function() {
- this.$el.data(instanceName, this);
- return this;
- },
- setOptions: function(opts) {
- this.options = $.extend(true, {}, PluginToggle.defaults, opts, {
- wrapper: this.$el
- });
- return this;
- },
- build: function() {
- var self = this,
- $wrapper = this.options.wrapper,
- $items = $wrapper.find('.toggle'),
- $el = null;
- $items.each(function() {
- $el = $(this);
- if(self.options.addIcons) {
- $el.find('> label').prepend(
- $('<i />').addClass('fa fa-plus'),
- $('<i />').addClass('fa fa-minus')
- );
- }
- if($el.hasClass('active')) {
- $el.find('> p').addClass('preview-active');
- $el.find('> .toggle-content').slideDown(self.options.duration);
- }
- self.events($el);
- });
- if(self.options.isAccordion) {
- self.options.duration = self.options.duration/2;
- }
- return this;
- },
- events: function($el) {
- var self = this,
- previewParCurrentHeight = 0,
- previewParAnimateHeight = 0,
- toggleContent = null;
- $el.find('> label').click(function(e) {
- var $this = $(this),
- parentSection = $this.parent(),
- parentWrapper = $this.parents('.toggle'),
- previewPar = null,
- closeElement = null;
- if(self.options.isAccordion && typeof(e.originalEvent) != 'undefined') {
- closeElement = parentWrapper.find('.toggle.active > label');
- if(closeElement[0] == $this[0]) {
- return;
- }
- }
- parentSection.toggleClass('active');
- // Preview Paragraph
- if(parentSection.find('> p').get(0)) {
- previewPar = parentSection.find('> p');
- previewParCurrentHeight = previewPar.css('height');
- previewPar.css('height', 'auto');
- previewParAnimateHeight = previewPar.css('height');
- previewPar.css('height', previewParCurrentHeight);
- }
- // Content
- toggleContent = parentSection.find('> .toggle-content');
- if(parentSection.hasClass('active')) {
- $(previewPar).animate({
- height: previewParAnimateHeight
- }, self.options.duration, function() {
- $(this).addClass('preview-active');
- });
- toggleContent.slideDown(self.options.duration, function() {
- if(closeElement) {
- closeElement.trigger('click');
- }
- });
- } else {
- $(previewPar).animate({
- height: 0
- }, self.options.duration, function() {
- $(this).removeClass('preview-active');
- });
- toggleContent.slideUp(self.options.duration);
- }
- });
- }
- };
- // expose to scope
- $.extend(theme, {
- PluginToggle: PluginToggle
- });
- // jquery plugin
- $.fn.themePluginToggle = function(opts) {
- return this.map(function() {
- var $this = $(this);
- if ($this.data(instanceName)) {
- return $this.data(instanceName);
- } else {
- return new PluginToggle($this, opts);
- }
- });
- }
- }).apply(this, [window.theme, jQuery]);
- // Colorpicker
- (function(theme, $) {
- theme = theme || {};
- var instanceName = '__colorpicker';
- var PluginColorPicker = function($el, opts) {
- return this.initialize($el, opts);
- };
- PluginColorPicker.defaults = {
- };
- PluginColorPicker.prototype = {
- initialize: function($el, opts) {
- if ( $el.data( instanceName ) ) {
- return this;
- }
- this.$el = $el;
- this
- .setData()
- .setOptions(opts)
- .build();
- return this;
- },
- setData: function() {
- this.$el.data(instanceName, this);
- return this;
- },
- setOptions: function(opts) {
- this.options = $.extend( true, {}, PluginColorPicker.defaults, opts );
- return this;
- },
- build: function() {
- this.$el.colorpicker( this.options );
- return this;
- }
- };
- // expose to scope
- $.extend(theme, {
- PluginColorPicker: PluginColorPicker
- });
- // jquery plugin
- $.fn.themePluginColorPicker = function(opts) {
- return this.each(function() {
- var $this = $(this);
- if ($this.data(instanceName)) {
- return $this.data(instanceName);
- } else {
- return new PluginColorPicker($this, opts);
- }
- });
- }
- }).apply(this, [window.theme, jQuery]);
- // SummerNote
- (function(theme, $) {
- theme = theme || {};
- var instanceName = '__summernote';
- var PluginSummerNote = function($el, opts) {
- return this.initialize($el, opts);
- };
- PluginSummerNote.defaults = {
- onfocus: function() {
- $( this ).closest( '.note-editor' ).addClass( 'active' );
- },
- onblur: function() {
- $( this ).closest( '.note-editor' ).removeClass( 'active' );
- }
- };
- PluginSummerNote.prototype = {
- initialize: function($el, opts) {
- if ( $el.data( instanceName ) ) {
- return this;
- }
- this.$el = $el;
- this
- .setData()
- .setOptions(opts)
- .build();
- return this;
- },
- setData: function() {
- this.$el.data(instanceName, this);
- return this;
- },
- setOptions: function(opts) {
- this.options = $.extend( true, {}, PluginSummerNote.defaults, opts );
- return this;
- },
- build: function() {
- this.$el.summernote( this.options );
- return this;
- }
- };
- // expose to scope
- $.extend(theme, {
- PluginSummerNote: PluginSummerNote
- });
- // jquery plugin
- $.fn.themePluginSummerNote = function(opts) {
- return this.each(function() {
- var $this = $(this);
- if ($this.data(instanceName)) {
- return $this.data(instanceName);
- } else {
- return new PluginSummerNote($this, opts);
- }
- });
- }
- }).apply(this, [window.theme, jQuery]);
- // TextArea AutoSize
- (function(theme, $) {
- theme = theme || {};
- var initialized = false;
- var instanceName = '__textareaAutosize';
- var PluginTextAreaAutoSize = function($el, opts) {
- return this.initialize($el, opts);
- };
- PluginTextAreaAutoSize.defaults = {
- };
- PluginTextAreaAutoSize.prototype = {
- initialize: function($el, opts) {
- if (initialized) {
- return this;
- }
- this.$el = $el;
- this
- .setData()
- .setOptions(opts)
- .build();
- return this;
- },
- setData: function() {
- this.$el.data(instanceName, this);
- return this;
- },
- setOptions: function(opts) {
- this.options = $.extend( true, {}, PluginTextAreaAutoSize.defaults, opts );
- return this;
- },
- build: function() {
- autosize($(this.$el));
- return this;
- }
- };
- // expose to scope
- $.extend(theme, {
- PluginTextAreaAutoSize: PluginTextAreaAutoSize
- });
- // jquery plugin
- $.fn.themePluginTextAreaAutoSize = function(opts) {
- return this.each(function() {
- var $this = $(this);
- if ($this.data(instanceName)) {
- return $this.data(instanceName);
- } else {
- return new PluginTextAreaAutoSize($this, opts);
- }
- });
- }
- }).apply(this, [window.theme, jQuery]);
- // Animate
- (function(theme, $) {
- theme = theme || {};
- var instanceName = '__animate';
- var PluginAnimate = function($el, opts) {
- return this.initialize($el, opts);
- };
- PluginAnimate.defaults = {
- accX: 0,
- accY: -150,
- delay: 1
- };
- PluginAnimate.prototype = {
- initialize: function($el, opts) {
- if ( $el.data( instanceName ) ) {
- return this;
- }
- this.$el = $el;
- this
- .setData()
- .setOptions(opts)
- .build();
- return this;
- },
- setData: function() {
- this.$el.data(instanceName, this);
- return this;
- },
- setOptions: function(opts) {
- this.options = $.extend(true, {}, PluginAnimate.defaults, opts, {
- wrapper: this.$el
- });
- return this;
- },
- build: function() {
- var self = this,
- $el = this.options.wrapper,
- delay = 0;
- $el.addClass('appear-animation');
- if(!$('html').hasClass('no-csstransitions') && $(window).width() > 767) {
- $el.appear(function() {
- delay = ($el.attr('data-appear-animation-delay') ? $el.attr('data-appear-animation-delay') : self.options.delay);
- if(delay > 1) {
- $el.css('animation-delay', delay + 'ms');
- }
- $el.addClass($el.attr('data-appear-animation'));
- setTimeout(function() {
- $el.addClass('appear-animation-visible');
- }, delay);
- }, {accX: self.options.accX, accY: self.options.accY});
- } else {
- $el.addClass('appear-animation-visible');
- }
- return this;
- }
- };
- // expose to scope
- $.extend(theme, {
- PluginAnimate: PluginAnimate
- });
- // jquery plugin
- $.fn.themePluginAnimate = function(opts) {
- return this.map(function() {
- var $this = $(this);
- if ($this.data(instanceName)) {
- return $this.data(instanceName);
- } else {
- return new PluginAnimate($this, opts);
- }
- });
- };
- }).apply(this, [window.theme, jQuery]);
- // Lightbox
- (function(theme, $) {
- theme = theme || {};
- var instanceName = '__lightbox';
- var PluginLightbox = function($el, opts) {
- return this.initialize($el, opts);
- };
- PluginLightbox.defaults = {
- tClose: 'Close (Esc)', // Alt text on close button
- tLoading: 'Loading...', // Text that is displayed during loading. Can contain %curr% and %total% keys
- gallery: {
- tPrev: 'Previous (Left arrow key)', // Alt text on left arrow
- tNext: 'Next (Right arrow key)', // Alt text on right arrow
- tCounter: '%curr% of %total%' // Markup for "1 of 7" counter
- },
- image: {
- tError: '<a href="%url%">The image</a> could not be loaded.' // Error message when image could not be loaded
- },
- ajax: {
- tError: '<a href="%url%">The content</a> could not be loaded.' // Error message when ajax request failed
- }
- };
- PluginLightbox.prototype = {
- initialize: function($el, opts) {
- if ( $el.data( instanceName ) ) {
- return this;
- }
- this.$el = $el;
- this
- .setData()
- .setOptions(opts)
- .build();
- return this;
- },
- setData: function() {
- this.$el.data(instanceName, this);
- return this;
- },
- setOptions: function(opts) {
- this.options = $.extend(true, {}, PluginLightbox.defaults, opts, {
- wrapper: this.$el
- });
- return this;
- },
- build: function() {
- this.options.wrapper.magnificPopup(this.options);
- return this;
- }
- };
- // expose to scope
- $.extend(theme, {
- PluginLightbox: PluginLightbox
- });
- // jquery plugin
- $.fn.themePluginLightbox = function(opts) {
- return this.each(function() {
- var $this = $(this);
- if ($this.data(instanceName)) {
- return $this.data(instanceName);
- } else {
- return new PluginLightbox($this, opts);
- }
- });
- }
- }).apply(this, [window.theme, jQuery]);
- /* Init */
- // Tooltip
- (function($) {
- 'use strict';
- if ( $.isFunction( $.fn['tooltip'] ) ) {
- $( '[data-toggle=tooltip],[rel=tooltip]' ).tooltip({ container: 'body' });
- }
- }).apply(this, [jQuery]);
- // Header Menu Nav
- (function(theme, $) {
- 'use strict';
- if (typeof theme.Nav !== 'undefined') {
- theme.Nav.initialize();
- }
- }).apply(this, [window.theme, jQuery]);
- // Scroll to Top
- (function(theme, $) {
- // Scroll to Top Button.
- if (typeof theme.PluginScrollToTop !== 'undefined') {
- theme.PluginScrollToTop.initialize();
- }
- }).apply(this, [window.theme, jQuery]);
- // Sidebar Widgets
- (function($) {
- 'use strict';
- function expand( content ) {
- content.children( '.widget-content' ).slideDown( 'fast', function() {
- $(this).css( 'display', '' );
- content.removeClass( 'widget-collapsed' );
- $(window).trigger('widget.collapsed');
- });
- }
- function collapse( content ) {
- content.children('.widget-content' ).slideUp( 'fast', function() {
- content.addClass( 'widget-collapsed' );
- $(this).css( 'display', '' );
- $(window).trigger('widget.expanded');
- });
- }
- var $widgets = $( '.sidebar-widget' );
- $widgets.each( function() {
- var $widget = $( this ),
- $toggler = $widget.find( '.widget-toggle' );
- $toggler.on('click.widget-toggler', function() {
- $widget.hasClass('widget-collapsed') ? expand($widget) : collapse($widget);
- });
- });
- }).apply(this, [jQuery]);
- // Colorpicker
- (function($) {
- 'use strict';
- if ( $.isFunction($.fn[ 'colorpicker' ]) ) {
- $(function() {
- $('[data-plugin-colorpicker]').each(function() {
- var $this = $( this ),
- opts = {};
- var pluginOptions = $this.data('plugin-options');
- if (pluginOptions)
- opts = pluginOptions;
- $this.themePluginColorPicker(opts);
- });
- });
- }
- }).apply(this, [jQuery]);
- (function($) {
- 'use strict';
- if ( $.isFunction( $.fn[ 'placeholder' ]) ) {
- $('input[placeholder]').placeholder();
- }
- }).apply(this, [jQuery]);
- // SummerNote
- (function($) {
- 'use strict';
- if ( $.isFunction($.fn[ 'summernote' ]) ) {
- $(function() {
- $('[data-plugin-summernote]').each(function() {
- var $this = $( this ),
- opts = {};
- var pluginOptions = $this.data('plugin-options');
- if (pluginOptions)
- opts = pluginOptions;
- $this.themePluginSummerNote(opts);
- });
- });
- }
- }).apply(this, [jQuery]);
- // TextArea AutoSize
- (function($) {
- 'use strict';
- if ( typeof autosize === 'function' ) {
- $(function() {
- $('[data-plugin-textarea-autosize]').each(function() {
- var $this = $( this ),
- opts = {};
- var pluginOptions = $this.data('plugin-options');
- if (pluginOptions)
- opts = pluginOptions;
- $this.themePluginTextAreaAutoSize(opts);
- });
- });
- }
- }).apply(this, [jQuery]);
- // Animate
- (function($) {
- 'use strict';
- if ( $.isFunction($.fn[ 'appear' ]) ) {
- $(function() {
- $('[data-plugin-animate], [data-appear-animation]').each(function() {
- var $this = $( this ),
- opts = {};
- var pluginOptions = $this.data('plugin-options');
- if (pluginOptions)
- opts = pluginOptions;
- $this.themePluginAnimate(opts);
- });
- });
- }
- }).apply(this, [jQuery]);
- // Lightbox
- (function($) {
- 'use strict';
- if ( $.isFunction($.fn[ 'magnificPopup' ]) ) {
- $(function() {
- $('[data-plugin-lightbox], .lightbox:not(.manual)').each(function() {
- var $this = $( this ),
- opts = {};
- var pluginOptions = $this.data('plugin-options');
- if (pluginOptions)
- opts = pluginOptions;
- $this.themePluginLightbox(opts);
- });
- });
- }
- }).apply(this, [jQuery]);
- // Scrollable
- (function($) {
- 'use strict';
- if ( $.isFunction($.fn[ 'nanoScroller' ]) ) {
- $(function() {
- $('[data-plugin-scrollable]').each(function() {
- var $this = $( this ),
- opts = {};
- var pluginOptions = $this.data('plugin-options');
- if (pluginOptions) {
- opts = pluginOptions;
- }
- $this.themePluginScrollable(opts);
- });
- });
- }
- }).apply(this, [jQuery]);
- // Toggle
- (function($) {
- 'use strict';
- $(function() {
- $('[data-plugin-toggle]').each(function() {
- var $this = $( this ),
- opts = {};
- var pluginOptions = $this.data('plugin-options');
- if (pluginOptions)
- opts = pluginOptions;
- $this.themePluginToggle(opts);
- });
- });
- }).apply(this, [jQuery]);
- /* Custom */
- //Galería -> Sender > Imgs
- (function($) {
- 'use strict';
- /*
- Gallery
- */
- if ( $.isFunction($.fn[ 'magnificPopup' ]) ) {
- $('.popup-gallery').magnificPopup({
- delegate: 'a',
- type: 'image',
- tLoading: 'Cargando imagen...',
- mainClass: 'mfp-img-mobile',
- gallery: {
- enabled: true,
- navigateByImgClick: true,
- preload: [0,1] // Will preload 0 - before current, and 1 after the current image
- },
- image: {
- tError: 'Error al cargar la imagen'
- }
- });
- }
- /* Sender -> cargador de parámetros de categorías al modificar */
- $(document).on('change','#app_sender_category', function(){
- $.ajax({
- url : '/category_ajax',
- type: 'POST',
- data: { id: $(this).val()},
- dataType: "json",
- success: function(response) {
- $('#app_sender_tensionAlarm').attr('value', response.tension);
- $('#app_sender_power1Alarm').attr('value', response.power1);
- $('#app_sender_power2Alarm').attr('value', response.power2);
- $('#app_sender_nolightAlarm').attr('value', response.nolight);
- $('#app_sender_notransmitAlarm').attr('value', response.notransmit);
- },
- error: function(response) {
- console.info('ERROR!');
- console.info(response);
- }
- });
- });
- /* Página de Mantenimiento -> Carga la ip */
- $(document).on('click','#load_my_ip', function() {
- if ($('#app_maintenance_ips').val() === '') {
- $('#app_maintenance_ips').val($('#load_my_ip').data('ip'));
- }
- else {
- $('#app_maintenance_ips').attr('value', $('#app_maintenance_ips').val() + ',' + $('#load_my_ip').data('ip'));
- }
- });
- //===============>GEOLOCALIZACIÓN
- $(document).on('click','#btn-get-geo', function() {
- if (navigator.geolocation) {
- navigator.geolocation.getCurrentPosition(showPosition, showError);
- }
- else {
- alert('Geolocalización no disponible en este dispositivo.');
- }
- });
- function showPosition(position) {
- console.info(position.coords.latitude);
- console.info(position.coords.longitude);
- $.ajax({
- url : '/sender_ajax',
- type: 'POST',
- data: {
- id: $('#btn-get-geo').data('id'),
- latitude: position.coords.latitude,
- longitude: position.coords.longitude
- },
- dataType: 'json',
- success: function(response) {
- window.location.replace(response.redirectToRoute)
- },
- error: function(response) {
- console.info('ERROR!');
- console.info(response);
- alert('Error! Contacta con Soporte Técnico.');
- }
- });
- }
- function showError(error) {
- switch(error.code) {
- case error.PERMISSION_DENIED:
- alert('Imposible Geolocalizar el Emisor. Motivo: El usuario ha bloqueado la geolocalización. Para poder geolocalizar el Emisor es necesario que concedas permisos.');
- break;
- case error.POSITION_UNAVAILABLE:
- alert('Imposible Geolocalizar el Emisor. Motivo: La información osbre la localización no está disponible.');
- break;
- case error.TIMEOUT:
- alert('Imposible Geolocalizar el Emisor. Motivo: Tiempo de petición agotado.');
- break;
- case error.UNKNOWN_ERROR:
- alert('Imposible Geolocalizar el Emisor. Motivo: Error desconocido. Contacta con Soporte Técnico.');
- break;
- }
- }
- }).apply(this, [jQuery]);
- /* Inicializa el mapa de los dsb's */
- function initMap() {
- if (data.positions != 'undefinied') {
- var positions = data.positions;
- var map = new google.maps.Map(document.getElementById('map'), {
- center: new google.maps.LatLng('40.428567', '-3.707541'),
- zoom: 6,
- mapTypeId: google.maps.MapTypeId.ROADMAP
- });
- var markers = [];
- positions.forEach(function(positions) {
- marker = new google.maps.Marker({
- map: map,
- title: positions.name,
- position: new google.maps.LatLng(positions.latitude, positions.longitude),
- url: '/sender/'+positions.id
- });
- markers.push(marker);
- google.maps.event.addListener(marker, 'click', function() {
- window.location.href = this.url;
- });
- });
- var markerCluster = new MarkerClusterer(map, markers,
- {imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'});
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement