var czrapp = czrapp || {}; (function($, czrapp) { czrapp._printLog = function( log ) { var _render = function() { return $.Deferred( function() { var dfd = this; $.when( $('#footer').before( $('
', { id : "bulklog" }) ) ).done( function() { $('#bulklog').css({ position: 'fixed', 'z-index': '99999', 'font-size': '0.8em', color: '#000', padding: '5%', width: '90%', height: '20%', overflow: 'hidden', bottom: '0', left: '0', background: 'yellow' }); dfd.resolve(); }); }).promise(); }, _print = function() { $('#bulklog').prepend('' + czrapp._prettyfy( { consoleArguments : [ log ], prettyfy : false } ) + '
'); }; if ( 1 != $('#bulk-log').length ) { _render().done( _print ); } else { _print(); } }; czrapp._truncate = function( string , length ){ length = length || 150; if ( ! _.isString( string ) ) return ''; return string.length > length ? string.substr( 0, length - 1 ) : string; }; var _prettyPrintLog = function( args ) { var _defaults = { bgCol : '#5ed1f5', textCol : '#000', consoleArguments : [] }; args = _.extend( _defaults, args ); var _toArr = Array.from( args.consoleArguments ), _truncate = function( string ){ if ( ! _.isString( string ) ) return ''; return string.length > 300 ? string.substr( 0, 299 ) + '...' : string; }; if ( ! _.isEmpty( _.filter( _toArr, function( it ) { return ! _.isString( it ); } ) ) ) { _toArr = JSON.stringify( _toArr.join(' ') ); } else { _toArr = _toArr.join(' '); } return [ '%c ' + _truncate( _toArr ), [ 'background:' + args.bgCol, 'color:' + args.textCol, 'display: block;' ].join(';') ]; }; var _wrapLogInsideTags = function( title, msg, bgColor ) { if ( ( _.isUndefined( console ) && typeof window.console.log != 'function' ) ) return; if ( czrapp.localized.isDevMode ) { if ( _.isUndefined( msg ) ) { console.log.apply( console, _prettyPrintLog( { bgCol : bgColor, textCol : '#000', consoleArguments : [ '<' + title + '>' ] } ) ); } else { console.log.apply( console, _prettyPrintLog( { bgCol : bgColor, textCol : '#000', consoleArguments : [ '<' + title + '>' ] } ) ); console.log( msg ); console.log.apply( console, _prettyPrintLog( { bgCol : bgColor, textCol : '#000', consoleArguments : [ '' + title + '>' ] } ) ); } } else { console.log.apply( console, _prettyPrintLog( { bgCol : bgColor, textCol : '#000', consoleArguments : [ title ] } ) ); } }; czrapp.consoleLog = function() { if ( ! czrapp.localized.isDevMode ) return; if ( ( _.isUndefined( console ) && typeof window.console.log != 'function' ) ) return; console.log.apply( console, _prettyPrintLog( { consoleArguments : arguments } ) ); console.log( 'Unstyled console message : ', arguments ); }; czrapp.errorLog = function() { if ( ( _.isUndefined( console ) && typeof window.console.log != 'function' ) ) return; console.log.apply( console, _prettyPrintLog( { bgCol : '#ffd5a0', textCol : '#000', consoleArguments : arguments } ) ); }; czrapp.errare = function( title, msg ) { _wrapLogInsideTags( title, msg, '#ffd5a0' ); }; czrapp.infoLog = function( title, msg ) { _wrapLogInsideTags( title, msg, '#5ed1f5' ); }; czrapp.doAjax = function( queryParams ) { queryParams = queryParams || ( _.isObject( queryParams ) ? queryParams : {} ); var ajaxUrl = queryParams.ajaxUrl || czrapp.localized.ajaxUrl,//the ajaxUrl can be specified when invoking doAjax nonce = czrapp.localized.frontNonce,//{ 'id' => 'HuFrontNonce', 'handle' => wp_create_nonce( 'hu-front-nonce' ) }, dfd = $.Deferred(), _query_ = _.extend( { action : '', withNonce : false }, queryParams ); if ( "https:" == document.location.protocol ) { ajaxUrl = ajaxUrl.replace( "http://", "https://" ); } if ( _.isEmpty( _query_.action ) || ! _.isString( _query_.action ) ) { czrapp.errorLog( 'czrapp.doAjax : unproper action provided' ); return dfd.resolve().promise(); } _query_[ nonce.id ] = nonce.handle; if ( ! _.isObject( nonce ) || _.isUndefined( nonce.id ) || _.isUndefined( nonce.handle ) ) { czrapp.errorLog( 'czrapp.doAjax : unproper nonce' ); return dfd.resolve().promise(); } $.post( ajaxUrl, _query_ ) .done( function( _r ) { if ( '0' === _r || '-1' === _r || false === _r.success ) { czrapp.errare( 'czrapp.doAjax : done ajax error for action : ' + _query_.action , _r ); dfd.reject( _r ); } dfd.resolve( _r ); }) .fail( function( _r ) { czrapp.errare( 'czrapp.doAjax : failed ajax error for : ' + _query_.action, _r ); dfd.reject( _r ); }); return dfd.promise(); }; })(jQuery, czrapp); (function($, czrapp) { czrapp.isKeydownButNotEnterEvent = function ( event ) { return ( 'keydown' === event.type && 13 !== event.which ); }; czrapp.setupDOMListeners = function( event_map , args, instance ) { var _defaultArgs = { model : {}, dom_el : {} }; if ( _.isUndefined( instance ) || ! _.isObject( instance ) ) { czrapp.errorLog( 'setupDomListeners : instance should be an object', args ); return; } if ( ! _.isArray( event_map ) ) { czrapp.errorLog( 'setupDomListeners : event_map should be an array', args ); return; } if ( ! _.isObject( args ) ) { czrapp.errorLog( 'setupDomListeners : args should be an object', event_map ); return; } args = _.extend( _defaultArgs, args ); if ( ! ( args.dom_el instanceof jQuery ) || 1 != args.dom_el.length ) { czrapp.errorLog( 'setupDomListeners : dom element should be an existing dom element', args ); return; } _.map( event_map , function( _event ) { if ( ! _.isString( _event.selector ) || _.isEmpty( _event.selector ) ) { czrapp.errorLog( 'setupDOMListeners : selector must be a string not empty. Aborting setup of action(s) : ' + _event.actions.join(',') ); return; } if ( ! _.isString( _event.selector ) || _.isEmpty( _event.selector ) ) { czrapp.errorLog( 'setupDOMListeners : selector must be a string not empty. Aborting setup of action(s) : ' + _event.actions.join(',') ); return; } var once = _event.once ? _event.once : false; args.dom_el[ once ? 'one' : 'on' ]( _event.trigger , _event.selector, function( e, event_params ) { e.stopPropagation(); if ( czrapp.isKeydownButNotEnterEvent( e ) ) { return; } e.preventDefault(); // Keep this AFTER the key filter above var actionsParams = $.extend( true, {}, args ); if ( _.has( actionsParams, 'model') && _.has( actionsParams.model, 'id') ) { if ( _.has( instance, 'get' ) ) actionsParams.model = instance(); else actionsParams.model = instance.getModel( actionsParams.model.id ); } $.extend( actionsParams, { event : _event, dom_event : e } ); $.extend( actionsParams, event_params ); if ( ! _.has( actionsParams, 'event' ) || ! _.has( actionsParams.event, 'actions' ) ) { czrapp.errorLog( 'executeEventActionChain : missing obj.event or obj.event.actions' ); return; } try { czrapp.executeEventActionChain( actionsParams, instance ); } catch( er ) { czrapp.errorLog( 'In setupDOMListeners : problem when trying to fire actions : ' + actionsParams.event.actions ); czrapp.errorLog( 'Error : ' + er ); } });//.on() });//_.map() };//setupDomListeners czrapp.executeEventActionChain = function( args, instance ) { if ( 'function' === typeof( args.event.actions ) ) return args.event.actions.call( instance, args ); if ( ! _.isArray( args.event.actions ) ) args.event.actions = [ args.event.actions ]; var _break = false; _.map( args.event.actions, function( _cb ) { if ( _break ) return; if ( 'function' != typeof( instance[ _cb ] ) ) { throw new Error( 'executeEventActionChain : the action : ' + _cb + ' has not been found when firing event : ' + args.event.selector ); } var $_dom_el = ( _.has(args, 'dom_el') && -1 != args.dom_el.length ) ? args.dom_el : false; if ( ! $_dom_el ) { czrapp.errorLog( 'missing dom element'); return; } $_dom_el.trigger( 'before_' + _cb, _.omit( args, 'event' ) ); var _cb_return = instance[ _cb ].call( instance, args ); if ( false === _cb_return ) _break = true; $_dom_el.trigger( 'after_' + _cb, _.omit( args, 'event' ) ); });//_.map }; })(jQuery, czrapp);var czrapp = czrapp || {}; czrapp.methods = {}; (function( $ ){ var ctor, inherits, slice = Array.prototype.slice; ctor = function() {}; inherits = function( parent, protoProps, staticProps ) { var child; if ( protoProps && protoProps.hasOwnProperty( 'constructor' ) ) { child = protoProps.constructor; } else { child = function() { var result = parent.apply( this, arguments ); return result; }; } $.extend( child, parent ); ctor.prototype = parent.prototype; child.prototype = new ctor(); if ( protoProps ) $.extend( child.prototype, protoProps ); if ( staticProps ) $.extend( child, staticProps ); child.prototype.constructor = child; child.__super__ = parent.prototype; return child; }; czrapp.Class = function( applicator, argsArray, options ) { var magic, args = arguments; if ( applicator && argsArray && czrapp.Class.applicator === applicator ) { args = argsArray; $.extend( this, options || {} ); } magic = this; if ( this.instance ) { magic = function() { return magic.instance.apply( magic, arguments ); }; $.extend( magic, this ); } magic.initialize.apply( magic, args ); return magic; }; czrapp.Class.extend = function( protoProps, classProps ) { var child = inherits( this, protoProps, classProps ); child.extend = this.extend; return child; }; czrapp.Class.applicator = {}; czrapp.Class.prototype.initialize = function() {}; czrapp.Class.prototype.extended = function( constructor ) { var proto = this; while ( typeof proto.constructor !== 'undefined' ) { if ( proto.constructor === constructor ) return true; if ( typeof proto.constructor.__super__ === 'undefined' ) return false; proto = proto.constructor.__super__; } return false; }; czrapp.Events = { trigger: function( id ) { if ( this.topics && this.topics[ id ] ) this.topics[ id ].fireWith( this, slice.call( arguments, 1 ) ); return this; }, bind: function( id ) { this.topics = this.topics || {}; this.topics[ id ] = this.topics[ id ] || $.Callbacks(); this.topics[ id ].add.apply( this.topics[ id ], slice.call( arguments, 1 ) ); return this; }, unbind: function( id ) { if ( this.topics && this.topics[ id ] ) this.topics[ id ].remove.apply( this.topics[ id ], slice.call( arguments, 1 ) ); return this; } }; czrapp.Value = czrapp.Class.extend({ initialize: function( initial, options ) { this._value = initial; // @todo: potentially change this to a this.set() call. this.callbacks = $.Callbacks(); this._dirty = false; $.extend( this, options || {} ); this.set = $.proxy( this.set, this ); }, instance: function() { return arguments.length ? this.set.apply( this, arguments ) : this.get(); }, get: function() { return this._value; }, set: function( to, o ) { var from = this._value, dfd = $.Deferred(), self = this, _promises = []; to = this._setter.apply( this, arguments ); to = this.validate( to ); var args = _.extend( { silent : false }, _.isObject( o ) ? o : {} ); if ( null === to || _.isEqual( from, to ) ) { return dfd.resolveWith( self, [ to, from, o ] ).promise(); } this._value = to; this._dirty = true; if ( true === args.silent ) { return dfd.resolveWith( self, [ to, from, o ] ).promise(); } if ( this._deferreds ) { _.each( self._deferreds, function( _prom ) { _promises.push( _prom.apply( null, [ to, from, o ] ) ); }); $.when.apply( null, _promises ) .fail( function() { czrapp.errorLog( 'A deferred callback failed in api.Value::set()'); }) .then( function() { self.callbacks.fireWith( self, [ to, from, o ] ); dfd.resolveWith( self, [ to, from, o ] ); }); } else { this.callbacks.fireWith( this, [ to, from, o ] ); return dfd.resolveWith( self, [ to, from, o ] ).promise( self ); } return dfd.promise( self ); }, silent_set : function( to, dirtyness ) { var from = this._value; to = this._setter.apply( this, arguments ); to = this.validate( to ); if ( null === to || _.isEqual( from, to ) ) { return this; } this._value = to; this._dirty = ( _.isUndefined( dirtyness ) || ! _.isBoolean( dirtyness ) ) ? this._dirty : dirtyness; this.callbacks.fireWith( this, [ to, from, { silent : true } ] ); return this; }, _setter: function( to ) { return to; }, setter: function( callback ) { var from = this.get(); this._setter = callback; this._value = null; this.set( from ); return this; }, resetSetter: function() { this._setter = this.constructor.prototype._setter; this.set( this.get() ); return this; }, validate: function( value ) { return value; }, bind: function() { var self = this, _isDeferred = false, _cbs = []; $.each( arguments, function( _key, _arg ) { if ( ! _isDeferred ) _isDeferred = _.isObject( _arg ) && _arg.deferred; if ( _.isFunction( _arg ) ) _cbs.push( _arg ); }); if ( _isDeferred ) { self._deferreds = self._deferreds || []; _.each( _cbs, function( _cb ) { if ( ! _.contains( _cb, self._deferreds ) ) self._deferreds.push( _cb ); }); } else { self.callbacks.add.apply( self.callbacks, arguments ); } return this; }, unbind: function() { this.callbacks.remove.apply( this.callbacks, arguments ); return this; }, }); czrapp.Values = czrapp.Class.extend({ defaultConstructor: czrapp.Value, initialize: function( options ) { $.extend( this, options || {} ); this._value = {}; this._deferreds = {}; }, instance: function( id ) { if ( arguments.length === 1 ) return this.value( id ); return this.when.apply( this, arguments ); }, value: function( id ) { return this._value[ id ]; }, has: function( id ) { return typeof this._value[ id ] !== 'undefined'; }, add: function( id, value ) { if ( this.has( id ) ) return this.value( id ); this._value[ id ] = value; value.parent = this; if ( value.extended( czrapp.Value ) ) value.bind( this._change ); this.trigger( 'add', value ); if ( this._deferreds[ id ] ) this._deferreds[ id ].resolve(); return this._value[ id ]; }, create: function( id ) { return this.add( id, new this.defaultConstructor( czrapp.Class.applicator, slice.call( arguments, 1 ) ) ); }, each: function( callback, context ) { context = typeof context === 'undefined' ? this : context; $.each( this._value, function( key, obj ) { callback.call( context, obj, key ); }); }, remove: function( id ) { var value; if ( this.has( id ) ) { value = this.value( id ); this.trigger( 'remove', value ); if ( value.extended( czrapp.Value ) ) value.unbind( this._change ); delete value.parent; } delete this._value[ id ]; delete this._deferreds[ id ]; }, when: function() { var self = this, ids = slice.call( arguments ), dfd = $.Deferred(); if ( $.isFunction( ids[ ids.length - 1 ] ) ) dfd.done( ids.pop() ); $.when.apply( $, $.map( ids, function( id ) { if ( self.has( id ) ) return; return self._deferreds[ id ] || $.Deferred(); })).done( function() { var values = $.map( ids, function( id ) { return self( id ); }); if ( values.length !== ids.length ) { self.when.apply( self, ids ).done( function() { dfd.resolveWith( self, values ); }); return; } dfd.resolveWith( self, values ); }); return dfd.promise(); }, _change: function() { this.parent.trigger( 'change', this ); } }); $.extend( czrapp.Values.prototype, czrapp.Events ); })( jQuery );//@global TCParams var czrapp = czrapp || {}; (function($, czrapp) { var _methods = { cacheProp : function() { var self = this; $.extend( czrapp, { $_window : $(window), $_html : $('html'), $_body : $('body'), $_wpadminbar : $('#wpadminbar'), $_header : $('.tc-header'), localized : "undefined" != typeof(TCParams) && TCParams ? TCParams : { _disabled: [] }, is_responsive : self.isResponsive(),//store the initial responsive state of the window current_device : self.getDevice()//store the initial device }); }, isResponsive : function() { return this.matchMedia(979); }, getDevice : function() { var _devices = { desktop : 979, tablet : 767, smartphone : 480 }, _current_device = 'desktop', that = this; _.map( _devices, function( max_width, _dev ){ if ( that.matchMedia( max_width ) ) _current_device = _dev; } ); return _current_device; }, matchMedia : function( _maxWidth ) { if ( window.matchMedia ) return ( window.matchMedia("(max-width: "+_maxWidth+"px)").matches ); var $_window = czrapp.$_window || $(window); return $_window.width() <= ( _maxWidth - 15 ); }, emitCustomEvents : function() { var that = this; czrapp.$_window.resize( function() { var //$_windowWidth = czrapp.$_window.width(), _current = czrapp.current_device,//<= stored on last resize event or on load _to = that.getDevice(); czrapp.is_responsive = that.isResponsive(); czrapp.current_device = _to; czrapp.$_body.trigger( 'tc-resize', { current : _current, to : _to} ); } );//resize(); if ( 'undefined' !== typeof wp && 'undefined' !== typeof wp.customize && 'undefined' !== typeof wp.customize.selectiveRefresh ) { wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function( placement ) { czrapp.$_header = $('.tc-header'); czrapp.$_body.trigger( 'partialRefresh.czr', placement ); }); } }, emit : function( cbs, args ) { cbs = _.isArray(cbs) ? cbs : [cbs]; var self = this; _.map( cbs, function(cb) { if ( 'function' == typeof(self[cb]) ) { args = 'undefined' == typeof( args ) ? [] : args ; self[cb].apply(self, args ); czrapp.trigger( cb, _.object( _.keys(args), args ) ); } });//_.map }, triggerSimpleLoad : function( $_imgs ) { if ( 0 === $_imgs.length ) return; $_imgs.map( function( _ind, _img ) { $(_img).load( function () { $(_img).trigger('simple_load'); });//end load if ( $(_img)[0] && $(_img)[0].complete ) $(_img).load(); } );//end map },//end of fn isUserLogged : function() { return czrapp.$_body.hasClass('logged-in') || 0 !== czrapp.$_wpadminbar.length; }, isSelectorAllowed : function( $_el, skip_selectors, requested_sel_type ) { var sel_type = 'ids' == requested_sel_type ? 'id' : 'class', _selsToSkip = skip_selectors[requested_sel_type]; if ( 'object' != typeof(skip_selectors) || ! skip_selectors[requested_sel_type] || ! $.isArray( skip_selectors[requested_sel_type] ) || 0 === skip_selectors[requested_sel_type].length ) return true; if ( $_el.parents( _selsToSkip.map( function( _sel ){ return 'id' == sel_type ? '#' + _sel : '.' + _sel; } ).join(',') ).length > 0 ) return false; if ( ! $_el.attr( sel_type ) ) return true; var _elSels = $_el.attr( sel_type ).split(' '), _filtered = _elSels.filter( function(classe) { return -1 != $.inArray( classe , _selsToSkip ) ;}); return 0 === _filtered.length; }, _isMobile : function() { return ( _.isFunction( window.matchMedia ) && matchMedia( 'only screen and (max-width: 720px)' ).matches ) || ( this._isCustomizing() && 'desktop' != this.previewDevice() ); }, _isCustomizing : function() { return czrapp.$_body.hasClass('is-customizing') || ( 'undefined' !== typeof wp && 'undefined' !== typeof wp.customize ); }, _has_iframe : function ( $_elements ) { var //that = this, to_return = []; _.each( $_elements, function( $_el, container ){ if ( $_el.length > 0 && $_el.find('IFRAME').length > 0 ) to_return.push(container); }); return to_return; }, };//_methods{} czrapp.methods.Base = czrapp.methods.Base || {}; $.extend( czrapp.methods.Base , _methods );//$.extend })(jQuery, czrapp);/*************************** * ADD BROWSER DETECT METHODS ****************************/ (function($, czrapp) { var _methods = { addBrowserClassToBody : function() { if ( $.browser.chrome ) czrapp.$_body.addClass("chrome"); else if ( $.browser.webkit ) czrapp.$_body.addClass("safari"); if ( $.browser.mozilla ) czrapp.$_body.addClass("mozilla"); else if ( $.browser.msie || '8.0' === $.browser.version || '9.0' === $.browser.version || '10.0' === $.browser.version || '11.0' === $.browser.version ) czrapp.$_body.addClass("ie").addClass("ie" + $.browser.version.replace(/[.0]/g, '')); if ( czrapp.$_body.hasClass("ie") ) czrapp.$_body.addClass($.browser.version); } };//_methods{} czrapp.methods.BrowserDetect = czrapp.methods.BrowserDetect || {}; $.extend( czrapp.methods.BrowserDetect , _methods ); })(jQuery, czrapp); var czrapp = czrapp || {}; (function($, czrapp) { var _methods = { centerImagesWithDelay : function( delay ) { var self = this; setTimeout( function(){ self.emit('centerImages'); }, delay || 300 ); }, centerInfinity : function() { var centerInfiniteImagesClassicStyle = function( collection, _container ) { var $_container = $(_container); if ( 'object' !== typeof collection || 1 > $_container.length) { return; } _.each( collection, function( elementSelector ) { var $_img = $( elementSelector + ' .thumb-wrapper', $_container ).centerImages( { enableCentering : 1 == czrapp.localized.centerAllImg, enableGoldenRatio : false, disableGRUnder : 0,//<= don't disable golden ratio when responsive oncustom : [ 'simple_load'] }).find( 'img' ); if ( $_img.length < 1 ) { $_img = $( elementSelector + ' .tc-rectangular-thumb', $_container ).centerImages( { enableCentering : 1 == czrapp.localized.centerAllImg, enableGoldenRatio : true, goldenRatioVal : czrapp.localized.goldenRatio || 1.618, disableGRUnder : 0,//<= don't disable golden ratio when responsive oncustom : [ 'simple_load'] }).find( 'img' ); } if ( $_img.length < 1 ) { $_img = $( elementSelector + ' .tc-grid-figure', $_container ).centerImages( { enableCentering : 1 == czrapp.localized.centerAllImg, oncustom : [ 'simple_load'], enableGoldenRatio : true, goldenRatioVal : czrapp.localized.goldenRatio || 1.618, goldenRatioLimitHeightTo : czrapp.localized.gridGoldenRatioLimit || 350 }).find( 'img' ); } czrapp.methods.Base.triggerSimpleLoad( $_img ); }); };//end centerInfiniteImagesClassicStyle czrapp.$_body.on( 'post-load', function( e, response ) { if ( ( 'undefined' !== typeof response ) && 'success' == response.type && response.collection && response.container ) { centerInfiniteImagesClassicStyle( response.collection, '#'+response.container //_container ); } } ); }, imgSmartLoad : function() { var smartLoadEnabled = 1 == TCParams.imgSmartLoadEnabled, _where = TCParams.imgSmartLoadOpts.parentSelectors.join(); if ( smartLoadEnabled ) $( _where ).imgSmartLoad( _.size( TCParams.imgSmartLoadOpts.opts ) > 0 ? TCParams.imgSmartLoadOpts.opts : {} ); if ( 1 == TCParams.centerAllImg ) { var self = this, $_to_center = smartLoadEnabled ? $( _.filter( $( _where ).find('img'), function( img ) { return $(img).is(TCParams.imgSmartLoadOpts.opts.excludeImg.join()); }) ): //filter $( _where ).find('img'); var $_to_center_with_delay = $( _.filter( $_to_center, function( img ) { return $(img).hasClass('tc-holder-img'); }) ); setTimeout( function(){ self.triggerSimpleLoad( $_to_center_with_delay ); }, 300 ); self.triggerSimpleLoad( $_to_center ); } }, dropCaps : function() { if ( ! TCParams.dropcapEnabled || ! _.isObject( TCParams.dropcapWhere ) ) return; $.each( TCParams.dropcapWhere , function( ind, val ) { if ( 1 == val ) { $( '.entry-content' , 'body.' + ( 'page' == ind ? 'page' : 'single-post' ) ).children().first().addDropCap( { minwords : TCParams.dropcapMinWords,//@todo check if number skipSelectors : _.isObject(TCParams.dropcapSkipSelectors) ? TCParams.dropcapSkipSelectors : {} }); } });//each }, extLinks : function() { if ( ! TCParams.extLinksStyle && ! TCParams.extLinksTargetExt ) return; $('a' , '.entry-content').extLinks({ addIcon : TCParams.extLinksStyle, newTab : TCParams.extLinksTargetExt, skipSelectors : _.isObject(TCParams.extLinksSkipSelectors) ? TCParams.extLinksSkipSelectors : {} }); }, fancyBox : function() { if ( 1 != TCParams.FancyBoxState || 'function' != typeof($.fn.fancybox) ) return; $("a.grouped_elements").fancybox({ transitionOut: "elastic", transitionIn: "elastic", speedIn: 200, speedOut: 200, overlayShow: !1, autoScale: 1 == TCParams.FancyBoxAutoscale ? "true" : "false", changeFade: "fast", enableEscapeButton: !0 }); $('a[rel*=tc-fancybox-group]').each( function() { var title = $(this).find('img').prop('title'); var alt = $(this).find('img').prop('alt'); if (typeof title !== 'undefined' && 0 !== title.length) $(this).attr('title',title); else if (typeof alt !== 'undefined' && 0 !== alt.length) $(this).attr('title',alt); }); }, centerImages : function() { setTimeout( function() { $.each( $( '.carousel .carousel-inner') , function() { $( this ).centerImages( { enableCentering : 1 == TCParams.centerSliderImg, imgSel : '.czr-item .carousel-image img', oncustom : ['customizr.slid', 'simple_load', 'smartload'], defaultCSSVal : { width : '100%' , height : 'auto' }, useImgAttr : true }); var self = this; setTimeout( function() { $( self ).prevAll('.tc-slider-loader-wrapper').fadeOut(); }, 500 ); }); } , 50); $('.widget-front .thumb-wrapper').centerImages( { enableCentering : 1 == TCParams.centerAllImg, enableGoldenRatio : false, disableGRUnder : 0,//<= don't disable golden ratio when responsive zeroTopAdjust : 1, leftAdjust : 2.5, oncustom : ['smartload', 'simple_load'] }); $('.thumb-wrapper', '.czr-hentry' ).centerImages( { enableCentering : 1 == TCParams.centerAllImg, enableGoldenRatio : false, disableGRUnder : 0,//<= don't disable golden ratio when responsive oncustom : ['smartload', 'simple_load'] }); $('.tc-rectangular-thumb', '.tc-post-list-context' ).centerImages( { enableCentering : 1 == TCParams.centerAllImg, enableGoldenRatio : true, goldenRatioVal : TCParams.goldenRatio || 1.618, disableGRUnder : 0,//<= don't disable golden ratio when responsive oncustom : ['smartload', 'refresh-height', 'simple_load'] //bind 'refresh-height' event (triggered to the the customizer preview frame) }); $('.tc-rectangular-thumb' , '.tc-singular-thumbnail-wrapper').centerImages( { enableCentering : 1 == TCParams.centerAllImg, enableGoldenRatio : false, disableGRUnder : 0,//<= don't disable golden ratio when responsive oncustom : ['smartload', 'refresh-height', 'simple_load'], //bind 'refresh-height' event (triggered to the the customizer preview frame) setOpacityWhenCentered : true,//will set the opacity to 1 opacity : 1 }); $('.tc-grid-figure').centerImages( { enableCentering : 1 == TCParams.centerAllImg, oncustom : ['smartload', 'simple_load'], enableGoldenRatio : true, goldenRatioVal : TCParams.goldenRatio || 1.618, goldenRatioLimitHeightTo : TCParams.gridGoldenRatioLimit || 350 } ); },//center_images parallax : function() { $( '.parallax-item' ).czrParallax( { parallaxRatio : 0.55 } ); } };//_methods{} czrapp.methods.JQPlugins = czrapp.methods.JQPlugins || {}; $.extend( czrapp.methods.JQPlugins = {} , _methods ); })(jQuery, czrapp);var czrapp = czrapp || {}; (function($, czrapp) { var _methods = { initOnDomReady : function() { var self = this; this.$_sliders = $( 'div[id*="customizr-slider"]' ); czrapp.$_window.resize( function(){ self.centerSliderArrows(); }); }, fireSliders : function(name, delay, hover) { var self = this, _name = name || TCParams.SliderName, _delay = delay || TCParams.SliderDelay, _hover = hover || TCParams.SliderHover, _cellSelector = '.czr-item', _cssLoaderClass = 'tc-css-loader', _css_loader = ''; if ( 0 === _name.length || 1 > self.$_sliders.length ) return; if ( czrapp.localized.imgSmartLoadsForSliders ) { self.$_sliders.addClass('disable-transitions-for-smartload'); self.$_sliders.find( _cellSelector + '.active').imgSmartLoad().data( 'czr_smartLoaded', true ); var _maybeRemoveLoader = function( $_cell ) { $_cell.find('.czr-css-loader').fadeOut( { duration: 'fast', done : function() { $(this).remove();} } ); }; var _smartLoadCellImg = function( _event_ ) { _event_ = _event_ || 'czr-smartloaded'; var $_cell = this; if ( 1 > $_cell.find('img[data-src], img[data-smartload]').length ) return; if ( ! $_cell.data( 'czr_smartLoaded' ) ) { if ( 1 > $_cell.find('.czr-css-loader').length ) { $_cell.append( _css_loader ).find('.czr-css-loader').fadeIn( 'slow' ); } $_cell.imgSmartLoad().data( 'czr_smartLoaded', true ).addClass( _event_ ); $_cell.data( 'czr_loader_timer' , $.Deferred( function() { var self = this; _.delay( function() { self.resolve(); }, 2000 ); return this.promise(); }) ); $_cell.data( 'czr_loader_timer' ).done( function() { _maybeRemoveLoader( $_cell ); }); } }; self.$_sliders.data( 'czr_smartload_scheduled', $.Deferred().done( function() { self.$_sliders.addClass('czr-smartload-scheduled'); }) ); var _isSliderDataSetup = function() { return 1 <= self.$_sliders.length && ! _.isUndefined( self.$_sliders.data( 'czr_smartload_scheduled' ) ); }; self.$_sliders.data( 'czr_schedule_select', $.Deferred( function() { var dfd = this; self.$_sliders.parent().one( 'customizr.slide click' , function() { dfd.resolve(); } ); }).done( function() { if ( ! _isSliderDataSetup() || 'resolved' == self.$_sliders.data( 'czr_smartload_scheduled' ).state() ) return; self.$_sliders.find( _cellSelector ).each( function() { _smartLoadCellImg.call( $(this), 'czr-smartloaded-on-select' ); }); self.$_sliders.data( 'czr_smartload_scheduled').resolve(); }) );//data( 'czr_schedule_select' ) self.$_sliders.data( 'czr_schedule_scroll_resize', $.Deferred( function() { var dfd = this; czrapp.$_window.one( 'scroll resize', function() { _.delay( function() { dfd.resolve(); }, 5000 ); }); }).done( function() { if ( ! _isSliderDataSetup() || 'resolved' == self.$_sliders.data( 'czr_smartload_scheduled' ).state() ) return; self.$_sliders.find( _cellSelector ).each( function() { _smartLoadCellImg.call( $(this), 'czr-smartloaded-on-scroll' ); }); self.$_sliders.data( 'czr_smartload_scheduled').resolve(); }) );//data( 'czr_schedule_scroll_resize' ) self.$_sliders.data( 'czr_schedule_autoload', $.Deferred( function() { var dfd = this; _.delay( function() { dfd.resolve(); }, 10000 ); }).done( function() { if ( ! _isSliderDataSetup() || 'resolved' == self.$_sliders.data( 'czr_smartload_scheduled' ).state() ) return; self.$_sliders.find( _cellSelector ).each( function() { _smartLoadCellImg.call( $(this), 'czr-auto-smartloaded' ); }); self.$_sliders.data( 'czr_smartload_scheduled').resolve(); }) ); self.$_sliders.on( 'smartload', _cellSelector , function() { _maybeRemoveLoader( $(this) ); }); }//if czrapp.localized.imgSmartLoadsForSliders if ( 0 !== _delay.length && ! _hover ) { this.$_sliders.czrCarousel({ interval: _delay, pause: "false" }); } else if ( 0 !== _delay.length ) { this.$_sliders.czrCarousel({ interval: _delay }); } else { this.$_sliders.czrCarousel(); } }, parallaxSliders : function() { if ( 'function' == typeof $.fn.czrParallax ) { $( '.czr-parallax-slider' ).czrParallax(); } }, manageHoverClass : function() { this.$_sliders.hover( function() { $(this).addClass('tc-slid-hover'); }, function() { $(this).removeClass('tc-slid-hover'); } ); }, centerSliderArrows : function() { if ( 0 === this.$_sliders.length ) return; this.$_sliders.each( function() { var _slider_height = $( '.carousel-inner' , $(this) ).height(); $('.tc-slider-controls', $(this) ).css("line-height", _slider_height +'px').css("max-height", _slider_height +'px'); }); }, addSwipeSupport : function() { if ( 'function' != typeof($.fn.hammer) || 0 === this.$_sliders.length ) return; this.$_sliders.on('touchstart touchmove', 'input, button, textarea, select, a:not(".tc-slide-link")', function(ev) { ev.stopPropagation(); }); var _is_rtl = czrapp.$_body.hasClass('rtl'); this.$_sliders.each( function() { $(this).hammer().on('swipeleft', function() { $(this).czrCarousel( ! _is_rtl ? 'next' : 'prev' ); }); $(this).hammer().on('swiperight', function(){ $(this).czrCarousel( ! _is_rtl ? 'prev' : 'next' ); }); }); }, sliderTriggerSimpleLoad : function() { this.triggerSimpleLoad( this.$_sliders.find('.carousel-inner img') ); } };//methods {} czrapp.methods.Slider = {}; $.extend( czrapp.methods.Slider , _methods ); })(jQuery, czrapp);var czrapp = czrapp || {}; (function($, czrapp) { var _methods = { initOnDomReady : function() { this.timer = 0; this.increment = 1;//used to wait a little bit after the first user scroll actions to trigger the timer $('.menu-item').on('focusin', 'a', function( evt ) { $(this).closest( '.menu-item' ).addClass('czr-focusin'); }); },//init eventListener : function() { var self = this; czrapp.$_window.scroll( _.throttle( function() { self.eventHandler( 'scroll' ); }, 50 ) ); },//eventListener eventHandler : function ( evt ) { var self = this; switch ( evt ) { case 'scroll' : if ( 0 === $('.tc-btt-wrapper').length ) return; if ( this.timer) { this.increment++; clearTimeout(self.timer); } if ( 1 == TCParams.timerOnScrollAllBrowsers ) { this.timer = setTimeout( function() { self.bttArrowVisibility(); }, self.increment > 5 ? 50 : 0 ); } else if ( czrapp.$_body.hasClass('ie') ) { this.timer = setTimeout( function() { self.bttArrowVisibility(); }, self.increment > 5 ? 50 : 0 ); } break; } },//eventHandler outline: function() { if ( czrapp.$_body.hasClass( 'mozilla' ) && 'function' == typeof( tcOutline ) ) tcOutline(); }, smoothScroll: function() { if ( TCParams.SmoothScroll && TCParams.SmoothScroll.Enabled ) smoothScroll( TCParams.SmoothScroll.Options ); }, anchorSmoothScroll : function() { if ( ! TCParams.anchorSmoothScroll || 'easeOutExpo' != TCParams.anchorSmoothScroll ) return; var _excl_sels = ( TCParams.anchorSmoothScrollExclude && _.isArray( TCParams.anchorSmoothScrollExclude.simple ) ) ? TCParams.anchorSmoothScrollExclude.simple.join(',') : '', self = this, $_links = $('#tc-page-wrap a[href^="#"],#tc-sn a[href^="#"]').not(_excl_sels); var _links, _deep_excl = _.isObject( TCParams.anchorSmoothScrollExclude.deep ) ? TCParams.anchorSmoothScrollExclude.deep : null ; if ( _deep_excl ) _links = _.toArray($_links).filter( function ( _el ) { return ( 2 == ( ['ids', 'classes'].filter( function( sel_type) { return self.isSelectorAllowed( $(_el), _deep_excl, sel_type); } ) ).length ); }); $(_links).click( function () { var anchor_id = $(this).attr("href"); if ( ! $(anchor_id).length ) return; if ('#' != anchor_id) { $('html, body').animate({ scrollTop: $(anchor_id).offset().top }, 700, TCParams.anchorSmoothScroll); } return false; });//click }, bttArrowVisibility : function () { if ( czrapp.$_window.scrollTop() > 100 ) $('.tc-btt-wrapper').addClass('show'); else $('.tc-btt-wrapper').removeClass('show'); },//bttArrowVisibility backToTop : function() { var $_html = $("html, body"), _backToTop = function( evt ) { return ( evt.which > 0 || "mousedown" === evt.type || "mousewheel" === evt.type) && $_html.stop().off( "scroll mousedown DOMMouseScroll mousewheel keyup", _backToTop ); }; $(".back-to-top, .tc-btt-wrapper, .btt-arrow").on("click touchstart touchend", function ( evt ) { evt.preventDefault(); evt.stopPropagation(); $_html.on( "scroll mousedown DOMMouseScroll mousewheel keyup", _backToTop ); $_html.animate({ scrollTop: 0 }, 1e3, function () { $_html.stop().off( "scroll mousedown DOMMouseScroll mousewheel keyup", _backToTop ); }); }); }, widgetsHoverActions : function() { czrapp.$_body.on( 'mouseenter mouseleave', '.widget-front, article', _toggleThisHoverClass ); czrapp.$_body.on( 'mouseenter mouseleave', '.widget li', _toggleThisOnClass ); function _toggleThisHoverClass( evt ) { _toggleElementClassOnHover( $(this), 'hover', evt ); } function _toggleThisOnClass( evt ) { _toggleElementClassOnHover( $(this), 'on', evt ); } function _toggleElementClassOnHover( $_el, _class, _evt ) { if ( 'mouseenter' == _evt.type ) $_el.addClass( _class ); else if ( 'mouseleave' == _evt.type ) $_el.removeClass( _class ); } }, attachmentsFadeEffect : function() { $("article.attachment img").delay(500).animate({ opacity: 1 }, 700, function () {} ); }, clickableCommentButton : function() { if ( ! TCParams.HasComments ) return; $('cite p.edit-link').each(function() { $(this).removeClass('btn btn-success btn-mini'); }); $('cite p.edit-link > a').each(function() { $(this).addClass('btn btn-success btn-mini'); }); $('.comment .reply').each(function() { $(this).removeClass('btn btn-small'); }); $('.comment .reply .comment-reply-link').each(function() { $(this).addClass('btn btn-small'); }); }, dynSidebarReorder : function() { if ( 1 != TCParams.ReorderBlocks ) return; if ( 'desktop' != this.getDevice() ) this._reorderSidebars( 'responsive' ); var self = this; czrapp.$_body.on( 'tc-resize' , function(e, param) { param = _.isObject(param) ? param : {}; var _to = 'desktop' != param.to ? 'responsive' : 'normal', _current = 'desktop' != param.current ? 'responsive' : 'normal'; if ( _current != _to ) self._reorderSidebars( _to ); } ); }, _reorderSidebars : function( _sidebarLayout ) { _sidebarLayout = _sidebarLayout || 'normal'; var that = this, LeftSidebarClass = TCParams.LeftSidebarClass || '.span3.left.tc-sidebar', RightSidebarClass = TCParams.RightSidebarClass || '.span3.right.tc-sidebar'; that.$_content = that.$_content || $("#main-wrapper .container .article-container"); that.$_left = that.$_left || $("#main-wrapper .container " + LeftSidebarClass); that.$_right = that.$_right || $("#main-wrapper .container " + RightSidebarClass); var iframeContainers = that._has_iframe( { 'content' : this.$_content, 'left' : this.$_left } ) ; var leftIframe = $.inArray('left', iframeContainers) > -1, contentIframe = $.inArray('content', iframeContainers) > -1; if ( leftIframe && contentIframe ) return; if ( that.$_left.length ) { if ( leftIframe ) that.$_content[ _sidebarLayout === 'normal' ? 'insertAfter' : 'insertBefore']( that.$_left ); else that.$_left[ _sidebarLayout === 'normal' ? 'insertBefore' : 'insertAfter']( that.$_content ); } }, dropdownMenuEventsHandler : function() { var $dropdown_ahrefs = $('.tc-open-on-click .menu-item.menu-item-has-children > a[href!="#"]'), $dropdown_submenus = $('.tc-open-on-click .dropdown .dropdown-submenu'); $dropdown_ahrefs.on('click', function() { if ( ( $(this).next('.dropdown-menu').css('visibility') != 'hidden' && $(this).next('.dropdown-menu').is(':visible') && ! $(this).parent().hasClass('dropdown-submenu') ) || ( $(this).next('.dropdown-menu').is(':visible') && $(this).parent().hasClass('dropdown-submenu') ) ) window.location = $(this).attr('href'); });//.on() $dropdown_submenus.each(function(){ var $parent = $(this), $children = $parent.children('[data-toggle="dropdown"]'); $children.on('click', function(){ var //submenu = $(this).next('.dropdown-menu'), openthis = false; if ( ! $parent.hasClass('open') ) { openthis = true; } $($parent.parent()).children('.dropdown-submenu').each(function(){ $(this).removeClass('open'); }); if ( openthis ) $parent.addClass('open'); return false; });//.on() });//.each() }, menuButtonHover : function() { var $_menu_btns = $('.btn-toggle-nav'); $_menu_btns.hover( function() { $(this).addClass('hover'); }, function() { $(this).removeClass('hover'); } ); }, secondMenuRespActions : function() { if ( ! TCParams.isSecondMenuEnabled ) return; var userOption = TCParams.secondMenuRespSet || false, that = this; if ( ! userOption || -1 == userOption.indexOf('in-sn') ) return; var _cacheElements = function() { that.$_sec_menu_els = $('.nav > li', '.tc-header .nav-collapse'); that.$_sn_wrap = $('.sn-nav', '.sn-nav-wrapper'); that.$_sec_menu_wrap = $('.nav', '.tc-header .nav-collapse'); }, _maybeClean = function() { var $_sep = $( '.secondary-menu-separator' ); if ( $_sep.length ) { switch(userOption) { case 'in-sn-before' : $_sep.prevAll('.menu-item').remove(); break; case 'in-sn-after' : $_sep.nextAll('.menu-item').remove(); break; } $_sep.remove(); } }; _cacheElements(); var _locationOnDomReady = 'desktop' == this.getDevice() ? 'navbar' : 'side_nav'; if ( 'desktop' != this.getDevice() ) this._manageMenuSeparator( _locationOnDomReady , userOption)._moveSecondMenu( _locationOnDomReady , userOption ); czrapp.$_body.on( 'tc-resize partialRefresh.czr', function( ev, param ) { var _force = false; if ( 'partialRefresh' == ev.type && 'czr' === ev.namespace && param.container && param.container.hasClass('tc-header') ) { _maybeClean(); _cacheElements(); param = { to: czrapp.current_device, current: czrapp.current_device }; _force = true; } param = _.isObject(param) ? param : {}; var _to = 'desktop' != param.to ? 'side_nav' : 'navbar', _current = 'desktop' != param.current ? 'side_nav' : 'navbar'; if ( _current == _to && !_force ) return; that._manageMenuSeparator( _to, userOption)._moveSecondMenu( _to, userOption ); } );//.on() }, _manageMenuSeparator : function( _to, userOption ) { var that = this; if ( 'navbar' == _to ) { $( '.secondary-menu-separator', that.$_sn_wrap).remove(); } else { var $_sep = $( '