PageSourceSearch

https://psariego.es/wp-content/themes/zuka/assets/js/app.js

js psariego.es collected 2026-10-10 02:00:07 UTC 253,873 bytes, 6,291 lines download raw bytes

1(function($) {
2    "use strict";
3
4    // Initialize global variable
5    var LA = {
6        core        : {},
7        ui 			: {},
8        utils 	    : {},
9        component 	: {}
10    };
11    window.LA = LA;
12
13    $.exists = function($selector) {
14        return ($selector.length > 0);
15    };
16
17    $.getCachedScript = function( url ) {
18        var options = {
19            dataType: "script",
20            cache: true,
21            url: url
22        };
23        return $.ajax( options );
24    };
25
26    $.fn.LA_ImagesLoaded = function () {
27        var $imgs = this.find('img[src!=""]');
28        if (!$imgs.length) {
29            return $.Deferred().resolve().promise();
30        }
31        var dfds = [];
32        $imgs.each(function(){
33            var dfd = $.Deferred();
34            dfds.push(dfd);
35            var img = new Image();
36            img.onload = function(){
37                dfd.resolve();
38            };
39            img.onerror = function(){
40                dfd.resolve();
41            };
42            img.src = this.src;
43        });
44        return $.when.apply($,dfds);
45    };
46
47    // "appeared" custom filter
48    $.expr[':'].appeared = function(element) {
49        var $element = $(element),
50            $window = $(window);
51        if (!$element.is(':visible')) {
52            return false;
53        }
54
55        var window_left = $window.scrollLeft();
56        var window_top = $window.scrollTop();
57        var offset = $element.offset();
58        var left = offset.left;
59        var top = offset.top;
60
61        if (top + $element.height() >= window_top &&
62            top - ($element.data('appear-top-offset') || 0) <= window_top + $window.height() &&
63            left + $element.width() >= window_left &&
64            left - ($element.data('appear-left-offset') || 0) <= window_left + $window.width()) {
65            return true;
66        } else {
67            return false;
68        }
69    };
70
71    var la_hover_effect = function( selector ){
72        this.$el = $(selector);
73        this._init();
74    };
75
76    la_hover_effect.prototype = {
77        _init : function( ) {
78            this._loadEvents();
79        },
80        _loadEvents : function() {
81            var self = this;
82            this.$el.on( 'mouseenter.hoverdir, mouseleave.hoverdir', function( event ) {
83                var $el = $(this),
84                    direction = self._getDir( $el, { x : event.pageX, y : event.pageY } ),
85                    _cls = self._getClass( direction),
86                    _prefix = ( event.type === 'mouseenter' ) ? 'in-' : 'out-';
87
88                $el.removeClass('in-top in-left in-right in-bottom out-top out-left out-right out-bottom');
89                $el.addClass(_prefix + _cls)
90            })
91        },
92        _getDir : function( $el, coordinates ) {
93            var w = $el.width(),
94                h = $el.height(),
95                x = ( coordinates.x - $el.offset().left - ( w/2 )) * ( w > h ? ( h/w ) : 1 ),
96                y = ( coordinates.y - $el.offset().top  - ( h/2 )) * ( h > w ? ( w/h ) : 1 );
97            return Math.round( ( ( ( Math.atan2(y, x) * (180 / Math.PI) ) + 180 ) / 90 ) + 3 ) % 4;
98        },
99        _getClass : function( direction ){
100            var _cls;
101            switch( direction ) {
102                case 0:
103                    _cls = 'top';
104                    break;
105                case 1:
106                    _cls = 'right';
107                    break;
108                case 2:
109                    _cls = 'bottom';
110                    break;
111                case 3:
112                    _cls = 'left';
113                    break;
114            }
115            return _cls;
116        }
117    };
118
119    $.fn.la_hover_effect = function(){
120        return new la_hover_effect( this );
121    };
122
123
124})(jQuery);
125
126// Initialize Helper
127
128(function($) {
129    'use strict';
130
131    var LA = window.LA || {};
132    LA.utils = window.LA.utils || {};
133
134    LA.utils.isDebug = true;
135
136    LA.utils.logger = {
137        $cache : {},
138        display : function( msg ){
139            if(!LA.utils.isDebug) return;
140            return console.log( msg );
141        },
142        set : function( msg, group_name, group_title ){
143            if(!LA.utils.isDebug) return;
144
145            if(typeof group_name !== "undefined" ){
146                if(typeof group_title === "undefined"){
147                    group_title = group_name;
148                }
149            }else{
150                group_name = "anonymous";
151                group_title = "Anonymous";
152            }
153
154            var self = this,
155                _o_obj = self.$cache[group_name] || [];
156
157            _o_obj.push([msg, group_title]);
158
159            self.$cache[group_name] = _o_obj;
160        },
161        get : function( group ){
162            if(!LA.utils.isDebug) return;
163            var self = this;
164            if(typeof group === "undefined"){
165                console.group('ALL');
166                $.each(self.$cache,function(key, val){
167                    $.each(val, function( k, v ){
168                        console.group("Com [" +  key + "] : " +  v[1]);
169                        console.log(v[0]);
170                        console.groupEnd();
171                    })
172                });
173                console.groupEnd();
174            }
175            else{
176                $.each(self.$cache[group], function(k, v){
177                    console.group("Com [" +  group + "] : " +  v[1]);
178                    console.log(v[0]);
179                    console.groupEnd();
180                })
181            }
182        }
183    };
184
185    LA.utils.isCookieEnable = function(){
186        if (navigator.cookieEnabled) return true;
187        document.cookie = "cookietest=1";
188        var ret = document.cookie.indexOf("cookietest=") != -1;
189        document.cookie = "cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT";
190        return ret;
191    };
192
193    LA.utils.browser = (function() {
194
195        var name,version,platform_name, _tmp;
196
197        var ua = navigator.userAgent.toLowerCase(),
198            platform = navigator.platform.toLowerCase(),
199            UA = ua.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/) || [null, 'unknown', '0'];
200
201
202        function getInternetExplorerVersion() {
203            var rv = -1;
204            if (navigator.appName == 'Microsoft Internet Explorer') {
205                var ua2 = navigator.userAgent;
206                var re2  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
207                if (re2.exec(ua2) != null)
208                    rv = parseFloat( RegExp.$1 );
209            }
210            else if (navigator.appName == 'Netscape') {
211                var ua2 = navigator.userAgent;
212                var re2  = new RegExp("Trident/.*rv:([0-9]{1,}[\.0-9]{0,})");
213                if (re2.exec(ua2) != null)
214                    rv = parseFloat( RegExp.$1 );
215            }
216            return rv;
217        }
218
219        _tmp = getInternetExplorerVersion();
220
221        if(_tmp != -1){
222            name = 'ie';
223            version = _tmp;
224        }
225        else{
226            name = (UA[1] == 'version') ? UA[3] : UA[1];
227            version = UA[2].substring(0,2);
228        }
229
230        platform_name = ua.match(/ip(?:ad|od|hone)/) ? 'ios' : (ua.match(/(?:webos|android)/) || platform.match(/mac|win|linux/) || ['other'])[0];
231
232        // Expose for css
233        $('html').addClass(name).addClass(name + ' ' + name + version + ' platform-' + platform_name);
234
235        return {
236            name : name,
237            version : version,
238            platform: platform_name
239        };
240
241    })();
242
243    LA.utils.isMobile = function() {
244
245        function android() {
246            return navigator.userAgent.match(/Android/i);
247        }
248
249        function blackBerry() {
250            return navigator.userAgent.match(/BlackBerry/i);
251        }
252
253        function iOS() {
254            return navigator.userAgent.match(/iPhone|iPad|iPod/i);
255        }
256
257        function opera() {
258            return navigator.userAgent.match(/Opera Mini/i);
259        }
260
261        function windows() {
262            return navigator.userAgent.match(/IEMobile/i);
263        }
264
265        return (android() || blackBerry() || iOS() || opera() || windows());
266
267    };
268
269    LA.utils.isRTL = function(){
270        return $(document.body).hasClass('rtl');
271    };
272
273    LA.utils.isActiveVC = function(){
274        return $(document.body).hasClass('wpb-js-composer');
275    };
276
277    LA.utils.sanitizeSlug = function( text ){
278        return text.toString().toLowerCase()
279            .replace(/\s+/g, '-')           // Replace spaces with -
280            .replace(/[^\w\-]+/g, '')       // Remove all non-word chars
281            .replace(/\-\-+/g, '-')         // Replace multiple - with single -
282            .replace(/^-+/, '')             // Trim - from start of text
283            .replace(/-+$/, '');
284    };
285
286    LA.utils.randomID = function(){
287        var text = "",
288            char = "abcdefghijklmnopqrstuvwxyz",
289            num = "0123456789",
290            i;
291        for( i = 0; i < 5; i++ ){
292            text += char.charAt(Math.floor(Math.random() * char.length));
293        }
294        for( i = 0; i < 5; i++ ){
295            text += num.charAt(Math.floor(Math.random() * num.length));
296        }
297        return text;
298    };
299
300    LA.utils.getAdminbarHeight = function(){
301        var $adminBar = $('#wpadminbar');
302        return ($.exists($adminBar) && $adminBar.css('position') == 'fixed') ? $adminBar.height() : 0;
303    };
304
305    LA.utils.addStyleSheet = function(css){
306        var head, styleElement;
307        head = document.getElementsByTagName('head')[0];
308        styleElement = document.createElement('style');
309        styleElement.setAttribute('type', 'text/css');
310        if (styleElement.styleSheet) {
311            styleElement.styleSheet.cssText = css;
312        } else {
313            styleElement.appendChild(document.createTextNode(css));
314        }
315        head.appendChild(styleElement);
316        return styleElement;
317    };
318
319    LA.utils.decodeURI = function(uri){
320        try {
321            uri = decodeURI( uri );
322        } catch( e ) {
323            uri = uri.replace( /%5B/g, '[' ).replace( /%5D/g, ']' ).replace( /%20/g, ' ' );
324        }
325        return uri;
326    };
327
328    LA.utils.getUrlParameter = function (name, url) {
329        if (!url) url = window.location.href;
330        name = name.replace(/[\[\]]/g, "\\$&");
331        var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
332            results = regex.exec(url);
333        if (!results) return null;
334        if (!results[2]) return '';
335        return decodeURIComponent(results[2].replace(/\+/g, " "));
336    };
337
338    LA.utils.addQueryArg = function( url, key, value ){
339        var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
340        var separator = url.indexOf('?') !== -1 ? "&" : "?";
341        if (url.match(re)){
342            return url.replace(re, '$1' + key + "=" + value + '$2');
343        }
344        else{
345            return url + separator + key + "=" + value;
346        }
347    };
348
349    LA.utils.removeURLParameter = function(url, parameter){
350        var urlparts= url.split('?');
351        if (urlparts.length>=2) {
352            var prefix= encodeURIComponent(parameter)+'=';
353            var pars= urlparts[1].split(/[&;]/g);
354            //reverse iteration as may be destructive
355            for (var i= pars.length; i-- > 0;) {
356                //idiom for string.startsWith
357                if (pars[i].lastIndexOf(prefix, 0) !== -1) {
358                    pars.splice(i, 1);
359                }
360            }
361            url= urlparts[0] + (pars.length > 0 ? '?' + pars.join('&') : "");
362            return url;
363        }
364        else {
365            return url;
366        }
367    };
368
369    LA.utils.reverseString = function( str ){
370        return str.split("").reverse().join("");
371    };
372
373    LA.utils.decodeToken = function(token){
374        var new_token = '';
375        if(token != ''){
376            var _tmp = token.split('.'),
377                _tmp2 = [];
378            _tmp.forEach(function(str,idx){
379                var _lg = str.length,
380                    _new_str = '';
381                if(_lg > 5){
382                    var f_str = str.substr(0,3),
383                        e_str = str.substr(_lg - 3),
384                        m_str = str.substr(3, _lg - 6);
385                    if(m_str){
386                        m_str = LA.utils.reverseString(m_str);
387                    }
388                    _new_str = LA.utils.reverseString(e_str) + m_str + LA.utils.reverseString(f_str);
389                }
390                else{
391                    _new_str = _lg > 0 ? LA.utils.reverseString(str) : str;
392                }
393                _tmp2.push(_new_str);
394            });
395            new_token = _tmp2.join('.');
396        }
397        return new_token;
398    };
399
400    function getHtmlScroll() {
401        return {
402            x: window.pageXOffset || document.documentElement.scrollLeft,
403            y: window.pageYOffset || document.documentElement.scrollTop
404        };
405    }
406
407    function isHtmlBodyTag(element) {
408        return (/^(?:body|html)$/i).test(element.tagName);
409    }
410
411    function getElementScroll(elem) {
412        var element = elem.parentNode,
413            position = {x: 0, y: 0};
414        while (element && !isHtmlBodyTag(element)) {
415            position.x += element.scrollLeft;
416            position.y += element.scrollTop;
417            element = element.parentNode;
418        }
419        return position;
420    }
421
422    function getStyleToString(element, style){
423        return $(element).css(style);
424    }
425
426    function getStyleToNumber(element, style) {
427        return parseInt(getStyleToString(element, style)) || 0;
428    }
429
430    function getTopBorderOfElement(element) {
431        return getStyleToNumber(element, 'border-top-width');
432    }
433
434    function getTopLeftOfElement(element) {
435        return getStyleToNumber(element, 'border-left-width');
436    }
437
438    function elementHasBorderBox(element) {
439        return getStyleToString(element, '-moz-box-sizing') == 'border-box';
440    }
441
442    function getOffset(elem){
443        if (elem.getBoundingClientRect && LA.utils.browser.platform != 'ios') {
444            var bound = elem.getBoundingClientRect(),
445                html = elem.ownerDocument.documentElement,
446                htmlScroll = getHtmlScroll(),
447                elemScrolls = getElementScroll(elem),
448                isFixed = (getStyleToString(elem, 'position') == 'fixed');
449            return {
450                x: parseInt(bound.left) + elemScrolls.x + ((isFixed) ? 0 : htmlScroll.x) - html.clientLeft,
451                y: parseInt(bound.top) + elemScrolls.y + ((isFixed) ? 0 : htmlScroll.y) - html.clientTop
452            };
453        }
454        var element = elem,
455            position = {
456                x: 0,
457                y: 0
458            };
459
460        if (isHtmlBodyTag(elem)) return position;
461
462        while (element && !isHtmlBodyTag(element)) {
463            position.x += element.offsetLeft;
464            position.y += element.offsetTop;
465            if (LA.utils.browser.name == 'firefox') {
466                if (!elementHasBorderBox(element)) {
467                    position.x += getTopLeftOfElement(element);
468                    position.y += getTopBorderOfElement(element);
469                }
470                var parent = element.parentNode;
471                if (parent && getStyleToString(parent, 'overflow') != 'visible') {
472                    position.x += getTopLeftOfElement(parent);
473                    position.y += getTopBorderOfElement(parent);
474                }
475            } else if (element != elem && LA.utils.browser.name == 'safari') {
476                position.x += getTopLeftOfElement(element);
477                position.y += getTopBorderOfElement(element);
478            }
479            element = element.offsetParent;
480        }
481        if (LA.utils.browser.name == 'firefox' && !elementHasBorderBox(elem)) {
482            position.x -= getTopLeftOfElement(elem);
483            position.y -= getTopBorderOfElement(elem);
484        }
485        return position;
486    }
487
488    LA.utils.getOffset = function( $element ){
489        return $.exists($element) ? getOffset($element.get(0)) : {x:0, y:0};
490    };
491
492    LA.utils.localCache = {
493        /**
494         * timeout for cache in millis
495         * @type {number}
496         */
497        timeout: 600000, // 10 minutes
498        /**
499         * @type {{_: number, data: {}}}
500         **/
501        data: {},
502        remove: function (url) {
503            delete LA.utils.localCache.data[url];
504        },
505        exist: function (url) {
506            return !!LA.utils.localCache.data[url] && ((new D
506ate().getTime() - LA.utils.localCache.data[url]._) < LA.utils.localCache.timeout);
507        },
508        get: function (url) {
509            console.log('Getting in cache for url ' + url);
510            return LA.utils.localCache.data[url].data;
511        },
512        set: function (url, cachedData, callback) {
513            LA.utils.localCache.remove(url);
514            LA.utils.localCache.data[url] = {
515                _: new Date().getTime(),
516                data: cachedData
517            };
518            if ($.isFunction(callback)) callback(cachedData);
519        }
520    };
521
522    $.ajaxPrefilter(function (options, originalOptions, jqXHR) {
523        if (options.cache) {
524            //Here is our identifier for the cache. Maybe have a better, safer ID (it depends on the object string representation here) ?
525            // on $.ajax call we could also set an ID in originalOptions
526
527            var id = originalOptions.url + ( "undefined" !== typeof originalOptions.ajax_request_id ? JSON.stringify(originalOptions.ajax_request_id) : JSON.str
527ingify(originalOptions.data) );
528            options.cache = false;
529            options.beforeSend = function () {
530                if (!LA.utils.localCache.exist(id)) {
531                    jqXHR.promise().done(function (data, textStatus) {
532                        LA.utils.localCache.set(id, data);
533                    });
534                }
535                return true;
536            };
537        }
538    });
539
540    $.ajaxTransport("+*", function (options, originalOptions, jqXHR) {
541
542        //same here, careful because options.url has already been through jQuery processing
543        var id = originalOptions.url + ( "undefined" !== typeof originalOptions.ajax_request_id ? JSON.stringify(originalOptions.ajax_request_id) : JSON.stringify(originalOptions.data) );
544
545        options.cache = false;
546
547        if (LA.utils.localCache.exist(id)) {
548            return {
549                send: function (headers, completeCallback) {
550                    completeCallback(200, "OK", [LA.utils.localCache.get(id)]);
551                },
552                abort: function () {
553                    /* abort code, nothing needed here I guess... */
554                }
555            };
556        }
557    });
558
559
560}(jQuery));
561
562// Initialize Lozad
563
564(function($) {
565    "use strict";
566
567    var LA = window.LA || {};
568    LA.utils = window.LA.utils || {};
569
570    var defaultConfig = {
571        rootMargin: '50px',
572        threshold: 0,
573        load: function load(element) {
574            var base_src = element.getAttribute('data-src') || element.getAttribute('data-lazy') || element.getAttribute('data-lazy-src') || element.getAttribute('data-lazy-original'),
575                base_srcset = element.getAttribute('data-src') || element.getAttribute('data-lazy-srcset'),
576                base_sizes = element.getAttribute('data-sizes') || element.getAttribute('data-lazy-sizes');
577
578            if(element.getAttribute('datanolazy') == 'true'){
579                base_src = base_srcset = base_sizes = '';
580            }
581
582            if (base_src) {
583                element.src = base_src;
584            }
585            if (base_srcset) {
586                element.srcset = base_srcset;
587            }
588            if (base_sizes) {
589                element.sizes = base_sizes;
590            }
591            if (element.getAttribute('data-background-image')) {
592                element.style.backgroundImage = 'url("' + element.getAttribute('data-background-image') + '")';
593            }
594        },
595        complete: function( $elm ){
596            // this function will be activated when element has been loaded
597        }
598    };
599
600    function markAsLoaded(element) {
601        element.setAttribute('data-element-loaded', true);
602    }
603
604    var isLoaded = function isLoaded(element) {
605        return element.getAttribute('data-element-loaded') === 'true';
606    };
607
608    var onIntersection = function onIntersection(load) {
609        return function (entries, observer) {
610            entries.forEach(function (entry) {
611                if (entry.intersectionRatio > 0) {
612                    observer.unobserve(entry.target);
613
614                    if (!isLoaded(entry.target)) {
615                        load(entry.target);
616                        markAsLoaded(entry.target);
617                    }
618                }
619            });
620        };
621    };
622
623    LA.utils.LazyLoad = function () {
624        var selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
625        var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
626
627        var _defaultConfig$option = $.extend({}, defaultConfig, options),
628            rootMargin = _defaultConfig$option.rootMargin,
629            threshold = _defaultConfig$option.threshold,
630            load = _defaultConfig$option.load,
631            complete = _defaultConfig$option.complete;
632
633        var observer = void 0;
634
635        if (window.IntersectionObserver) {
636            observer = new IntersectionObserver(onIntersection(load), {
637                rootMargin: rootMargin,
638                threshold: threshold
639            });
640        }
641
642        return {
643            triggerSingleLoad: function triggerSingleLoad(){
644                if(!$.exists(selector)){
645                    return;
646                }
647                var element = selector.get(0);
648                if(isLoaded(element)){
649                    return;
650                }
651                if (observer) {
652                    observer.observe(element);
653                    return;
654                }
655                load(element);
656                markAsLoaded(element);
657                complete(selector);
658
659            },
660            observe: function observe() {
661                if ( !$.exists(selector) ) {
662                    return;
663                }
664                for (var i = 0; i < selector.length; i++) {
665                    if (isLoaded(selector[i])) {
666                        continue;
667                    }
668                    if (observer) {
669                        observer.observe(selector[i]);
670                        continue;
671                    }
672                    load(selector[i]);
673                    markAsLoaded(selector[i]);
674                }
675                complete(selector);
676            },
677            triggerLoad: function triggerLoad(element) {
678                if (isLoaded(element)) {
679                    return;
680                }
681                load(element);
682                markAsLoaded(element);
683                complete(selector);
684            }
685        };
686    };
687
688}(jQuery));
689
690// Initialize LA Sticky
691
692(function($) {
693    "use strict";
694    var doc, win;
695
696    win = $(window);
697
698    doc = $(document);
699
700    $.fn.la_sticky = function(opts) {
701        var doc_height, elm, enable_bottoming, inner_scrolling, manual_spacer, offset_top, outer_width, parent_selector, recalc_every, sticky_class, win_height, _fn, _i, _len, fake_parent, fake_parent_height;
702        if (opts == null) {
703            opts = {};
704        }
705        sticky_class = opts.sticky_class, inner_scrolling = opts.inner_scrolling, recalc_every = opts.recalc_every, parent_selector = opts.parent, offset_top = opts.offset_top, manual_spacer = opts.spacer, enable_bottoming = opts.bottoming, fake_parent = opts.fake_parent, fake_parent_height = opts.fake_parent_height;
706        win_height = win.height();
707        doc_height = doc.height();
708        if (offset_top == null) {
709            offset_top = 0;
710        }
711        if (parent_selector == null) {
712            parent_selector = void 0;
713        }
714        if (inner_scrolling == null) {
715            inner_scrolling = true;
716        }
717        if (sticky_class == null) {
718            sticky_class = "is_stuck";
719        }
720        if (enable_bottoming == null) {
721            enable_bottoming = true;
722        }
723
724        outer_width = function(el) {
725            var computed, w, _el;
726            if (window.getComputedStyle) {
727                _el = el[0];
728                computed = window.getComputedStyle(el[0]);
729                w = parseFloat(computed.getPropertyValue("width")) + parseFloat(computed.getPropertyValue("margin-left")) + parseFloat(computed.getPropertyValue("margin-right"));
730                if (computed.getPropertyValue("box-sizing") !== "border-box") {
731                    w += parseFloat(computed.getPropertyValue("border-left-width")) + parseFloat(computed.getPropertyValue("border-right-width")) + parseFloat(computed.getPropertyValue("padding-left")) + parseFloat(computed.getPropertyValue("padding-right"));
732                }
733                return w;
734            } else {
735                return el.outerWidth(true);
736            }
737        };
738        _fn = function(elm, padding_bottom, parent_top, parent_height, top, height, el_float, detached) {
739            var bottomed, detach, fixed, last_pos, last_scroll_height, offset, parent, recalc, recalc_and_tick, recalc_counter, spacer, tick;
740            var _fake_parent;
741            if (elm.data("la_sticky")) {
742                return;
743            }
744
745            elm.data("la_sticky", true);
746
747            last_scroll_height = doc_height;
748            parent = elm.parent();
749            if(fake_parent){
750                _fake_parent = fake_parent;
751            }
752            if (parent_selector != null) {
753                parent = parent.closest(parent_selector);
754            }
755            if (!parent.length) {
756                throw "failed to find stick parent";
757            }
758            fixed = false;
759            bottomed = false;
760            spacer = manual_spacer != null ? manual_spacer && elm.closest(manual_spacer) : $("<div />");
761            if (spacer) {
762                spacer.css('position', elm.css('position'));
763            }
764            recalc = function() {
765                var border_top, padding_top, restore;
766                if (detached) {
767                    return;
768                }
769                win_height = win.height();
770                doc_height = doc.height();
771                last_scroll_height = doc_height;
772                border_top = parseInt(parent.css("border-top-width"), 10);
773                padding_top = parseInt(parent.css("padding-top"), 10);
774                padding_bottom = parseInt(parent.css("padding-bottom"), 10);
775                parent_top = parent.offset().top + border_top + padding_top;
776                parent_height = fake_parent ? _fake_parent.height() : parent.height();
777                if (fixed) {
778                    fixed = false;
779                    bottomed = false;
780                    if (manual_spacer == null) {
781                        elm.insertAfter(spacer);
782                        spacer.detach();
783                    }
784                    elm.css({
785                        position: "",
786                        top: "",
787                        width: "",
788                        bottom: ""
789                    }).removeClass(sticky_class);
790                    restore = true;
791                }
792                top = elm.offset().top - (parseInt(elm.css("margin-top"), 10) || 0) - offset_top;
793                height = elm.outerHeight(true);
794                el_float = elm.css("float");
795                if (spacer) {
796                    spacer.css({
797                        width: outer_width(elm),
798                        height: height,
799                        display: elm.css("display"),
800                        "vertical-align": elm.css("vertical-align"),
801                        "float": el_float
802                    });
803                }
804                if (restore) {
805                    return tick();
806                }
807            };
808            recalc();
809            if (height === parent_height) {
810                return;
811            }
812            last_pos = void 0;
813            offset = offset_top;
814            recalc_counter = recalc_every;
815            tick = function() {
816                var css, delta, recalced, scroll, will_bottom;
817                if (detached) {
818                    return;
819                }
820                recalced = false;
821                if (recalc_counter != null) {
822                    recalc_counter -= 1;
823                    if (recalc_counter <= 0) {
824                        recalc_counter = recalc_every;
825                        recalc();
826                        recalced = true;
827                    }
828                }
829                if (!recalced && doc_height !== last_scroll_height) {
830                    recalc();
831                    recalced = true;
832                }
833                scroll = win.scrollTop();
834                if (last_pos != null) {
835                    delta = scroll - last_pos;
836                }
837                last_pos = scroll;
838                if (fixed) {
839                    if (enable_bottoming) {
840                        will_bottom = scroll + height + offset > parent_height + parent_top;
841                        if (bottomed && !will_bottom) {
842                            bottomed = false;
843                            elm.css({
844                                position: "fixed",
845                                bottom: "",
846                                top: offset
847                            }).trigger("la_sticky:unbottom");
848                        }
849                    }
850                    if (scroll <= top) {
851                        fixed = false;
852                        offset = offset_top;
853                        if (manual_spacer == null) {
854                            if (el_float === "left" || el_float === "right") {
855                                elm.insertAfter(spacer);
856                            }
857                            spacer.detach();
858                        }
859                        css = {
860                            position: "",
861                            width: "",
862                            top: ""
863                        };
864                        elm.css(css).removeClass(sticky_class).trigger("la_sticky:unstick");
865                    }
866                    if (inner_scrolling) {
867                        if (height + offset_top > win_height) {
868                            if (!bottomed) {
869                                offset -= delta;
870                                offset = Math.max(win_height - height, offset);
871                                offset = Math.min(offset_top, offset);
872                                if (fixed) {
873                                    elm.css({
874                                        top: offset + "px"
875                                    });
876                                }
877                            }
878                        }
879                    }
880                } else {
881                    if (scroll > top) {
882                        fixed = true;
883                        css = {
884                            position: "fixed",
885                            top: offset
886                        };
887                        css.width = elm.css("box-sizing") === "border-box" ? elm.outerWidth() + "px" : elm.width() + "px";
888                        elm.css(css).addClass(sticky_class);
889                        if (manual_spacer == null) {
890                            elm.after(spacer);
891                            if (el_float === "left" || el_float === "right") {
892                                spacer.append(elm);
893                            }
894                        }
895                        elm.trigger("la_sticky:stick");
896                    }
897                }
898                if (fixed && enable_bottoming) {
899                    if (will_bottom == null) {
900                        will_bottom = scroll + height + offset > parent_height + parent_top;
901                    }
902                    if (!bottomed && will_bottom) {
903                        bottomed = true;
904                        if (parent.css("position") === "static") {
905                            parent.css({
906                                position: "relative"
907                            });
908                        }
909                        return elm.css({
910                            position: "absolute",
911                            bottom: padding_bottom,
912                            top: "auto"
913                        }).trigger("la_sticky:bottom");
914                    }
915                }
916            };
917            recalc_and_tick = function() {
918                recalc();
919                return tick();
920            };
921            detach = function() {
922                detached = true;
923                win.off("touchmove", tick);
924                win.off("scroll", tick);
925                win.off("resize", recalc_and_tick);
926                $(document.body).off("la_sticky:recalc", recalc_and_tick);
927                elm.off("la_sticky:detach", detach);
928                elm.removeData("la_sticky");
929                elm.css({
930                    position: "",
931                    bottom: "",
932                    top: "",
933                    width: ""
934                });
935                parent.position("position", "");
936                if (fixed) {
937                    if (manual_spacer == null) {
938                        if (el_float === "left" || el_float === "right") {
939                            elm.insertAfter(spacer);
940                        }
941                        spacer.remove();
942                    }
943                    return elm.removeClass(sticky_class);
944                }
945            };
946            win.on("touchmove", tick);
947            win.on("scroll", tick);
948            win.on("resize", recalc_and_tick);
949            $(document.body).on("la_sticky:recalc", recalc_and_tick);
950            elm.on("la_sticky:detach", detach);
951            return setTimeout(tick, 0);
952        };
953        for (_i = 0, _len = this.length; _i < _len; _i++) {
954            elm = this[_i];
955            _fn($(elm));
956        }
957        return this;
958    };
959
960}(jQuery));
961
962// Initialize Event Manager
963(function($) {
964    'use strict';
965
966    var LA = window.LA || {};
967    LA.utils = window.LA.utils || {};
968
969    LA.utils.eventManager = {};
970
971    LA.utils.eventManager.subscribe = function(evt, func) {
972        $(this).on(evt, func);
973    };
974
975    LA.utils.eventManager.unsubscribe = function(evt, func) {
976        $(this).off(evt, func);
977    };
978
979    LA.utils.eventManager.publish = function(evt, params) {
980        $(this).trigger(evt, params);
981    };
982
983}(jQuery));
984
985/*
986 Initialize LA_ProductGallery
987 */
988(function($) {
989    'use strict';
990
991    /**
992     * Product gallery class.
993     */
994    var LA_ProductGallery = function( $target, args ) {
995
996        this.$target = $target;
997        this.$images = $( '.woocommerce-product-gallery__image', $target );
998
999        if(!$target.parent('.product--large-image').data('old_gallery')){
1000            $target.parent('.product--large-image').data('old_gallery', $target.find('.woocommerce-product-gallery__wrapper').html()).data('prev_gallery', $target.find('.woocommerce-product-gallery__wrapper').html());
1001        }
1002
1003        this.$target.parent().attr('data-totalG', this.$images.length);
1004
1005        // No images? Abort.
1006        if ( 0 === this.$images.length ) {
1007            this.$target.css( 'opacity', 1 );
1008            this.$target.parent().addClass('no-gallery');
1009            return;
1010        }
1011        if( 1 === this.$images.length ){
1012            this.$target.parent().addClass('no-gallery');
1013        }
1014        else{
1015            this.$target.parent().removeClass('no-gallery');
1016        }
1017
1018
1019        // Make this object available.
1020        $target.data( 'product_gallery', this );
1021
1022        // Pick functionality to initialize...
1023        this.flexslider_enabled = true;
1024
1025        if ($target.hasClass('no-slider-script') || $target.hasClass('force-disable-slider-script') ){
1026            this.flexslider_enabled = false;
1027        }
1028
1029        //this.flexslider_enabled = false;
1030        this.zoom_enabled       = $.isFunction( $.fn.zoom ) && wc_single_product_params.zoom_enabled;
1031        this.photoswipe_enabled = typeof PhotoSwipe !== 'undefined' && wc_single_product_params.photoswipe_enabled;
1032
1033        // ...also taking args into account.
1034        if ( args ) {
1035            this.flexslider_enabled = false === args.flexslider_enabled ? false : this.flexslider_enabled;
1036            this.zoom_enabled       = false === args.zoom_enabled ? false : this.zoom_enabled;
1037            this.photoswipe_enabled = false === args.photoswipe_enabled ? false : this.photoswipe_enabled;
1038        }
1039
1040        if($target.hasClass('force-disable-slider-script')){
1041            this.flexslider_enabled = false;
1042            //this.zoom_enabled       = false;
1043        }
1044
1045        this.thumb_verital = false;
1046
1047
1048        if(this.$images.length < 2){
1049            this.flexslider_enabled = false;
1050        }
1051
1052        try {
1053            if(la_theme_config.product_single_design == 2){
1054                this.thumb_verital = true;
1055            }
1056        }catch (ex){
1057            this.thumb_verital = false;
1058        }
1059
1060        this.parent_is_quickview = false;
1061
1062        if($target.closest('.lightcase-contentInner').length){
1063            this.thumb_verital = true;
1064            //this.zoom_enabled = false;
1065            this.parent_is_quickview = true;
1066        }
1067
1068        // Bind functions to this.
1069        this.initSlickslider       = this.initSlickslider.bind( this );
1070        this.initZoom             = this.initZoom.bind( this );
1071        this.initPhotoswipe       = this.initPhotoswipe.bind( this );
1072        this.onResetSlidePosition = this.onResetSlidePosition.bind( this );
1073        this.getGalleryItems      = this.getGalleryItems.bind( this );
1074        this.openPhotoswipe       = this.openPhotoswipe.bind( this );
1075
1076        if ( this.flexslider_enabled ) {
1077
1078            if($.isFunction( $.fn.slick )){
1079                this.initSlickslider();
1080                $target.on( 'woocommerce_gallery_reset_slide_position', this.onResetSlidePosition );
1081            }else{
1082                var _self = this;
1083                LA.core.loadDependencies([ LA.core.path.plugins + 'jquery.slick.js'], function(){
1084                    _self.initSlickslider();
1085                    $target.on( 'woocommerce_gallery_reset_slide_position', _self.onResetSlidePosition );
1086                })
1087            }
1088        }
1089        else {
1090
1091            if(this.parent_is_quickview){
1092                $('body').removeClass('lightcase--pending').addClass('lightcase--completed');
1093            }
1094            else{
1095                setTimeout(function(){
1096                    $('body').trigger("la_sticky:recalc");
1097                },200);
1098            }
1099
1100            this.$target.css( 'opacity', 1 );
1101            $target.removeClass('la-rebuild-product-gallery').parent().removeClass('swatch-loading');
1102        }
1103
1104        if ( this.zoom_enabled ) {
1105            this.initZoom();
1106            $target.on( 'woocommerce_gallery_init_zoom', this.initZoom );
1107        }
1108
1109        if ( this.photoswipe_enabled ) {
1110            this.initPhotoswipe();
1111        }
1112
1113    };
1114
1115    /**
1116     * Initialize flexSlider.
1117     */
1118    LA_ProductGallery.prototype.initSlickslider = function() {
1119        var images  = this.$images,
1120            $target = this.$target,
1121            $slides = $target.find('.woocommerce-product-gallery__wrapper'),
1122            $thumb = $target.parent().find('.la-thumb-inner'),
1123            rand_num = Math.floor((Math.random() * 100) + 1),
1124            thumb_id = 'la_woo_thumb_' + rand_num,
1125            target_id = 'la_woo_target_' + rand_num,
1126            is_quickview = this.parent_is_quickview;
1127
1128        $slides.attr('id', target_id);
1129        $thumb.attr('id', thumb_id);
1130
1131        images.each(function(){
1132            var $that = $(this);
1133            var video_code = $that.find('a[data-videolink]').data('videolink');
1134            var image_h = $slides.css('height');
1135            var thumb_html = '<div class="la-thumb"><img src="'+ $that.attr('data-thumb') +'"/></div>';
1136            if (typeof video_code != 'undefined' && video_code) {
1137
1138                $that.unbind('click');
1139                $that.find('.zoomImg').css({
1140                    'display': 'none!important'
1141                });
1142
1143                if (video_code.indexOf("http://selfhosted/") == 0) {
1144                    video_code = video_code.replace('http://selfhosted/', '');
1145                    thumb_html = '<div class="la-thumb has-thumb-video"><div><img src="'+ $that.attr('data-thumb') +'"/><span class="play-overlay"><i class="fa fa-play-circle-o" aria-hidden="true"></i></span></div></div>';
1146                    $that.append('<video class="selfhostedvid  noLightbox" width="460" height="315" controls preload="auto"><source src="' + video_code + '" /></video>');
1147                    $that.attr('data-video', '<div class="la-media-wrapper"><video class="selfhostedvid  noLightbox" width="460" height="315" controls preload="auto"><source src="' + video_code + '" /></video></div>');
1148                } else {
1149                    thumb_html = '<div class="la-thumb has-thumb-video"><div><img src="'+ $that.attr('data-thumb') +'"/><span class="play-overlay"><i class="fa-play-circle-o"></i></span></div></div>';
1150                    $that.append('<iframe src ="' + video_code + '" width="460" " style="height:' + image_h + '; z-index:999999;" frameborder="no"></iframe>');
1151                    $that.attr('data-video', '<div class="la-media-wrapper"><iframe src ="' + video_code + '" width="980" height="551" frameborder="no" allowfullscreen></iframe></div>');
1152                }
1153
1154                $that.find('img').css({
1155                    'opacity': '0',
1156                    'z-index': '-1'
1157                });
1158
1159                $that.find('iframe').next().remove();
1160            }
1161            $thumb.append(thumb_html);
1162        });
1163
1164        var _thumb_column = $.extend({
1165            'xlg' : 3,
1166            'lg'  : 3,
1167            'md'  : 3,
1168            'sm'  : 5,
1169            'xs'  : 4,
1170            'mb'  : 3
1171        }, (JSON.parse(la_theme_config.product_gallery_column) || {}) );
1172
1173        var _thumb_carousel_config = {
1174            infinite: false,
1175            slidesToShow: parseInt(_thumb_column['xlg']),
1176            slidesToScroll: 1,
1177            asNavFor: '#' + target_id,
1178            dots: false,
1179            arrows: true,
1180            focusOnSelect: true,
1181            prevArrow: '<span class="slick-prev"><i class="dl-icon-left"></i></span>',
1182            nextArrow: '<span class="slick-next"><i class="dl-icon-right"></i></span>',
1183            vertical: this.thumb_verital,
1184            responsive: [
1185                {
1186                    breakpoint: 1024,
1187                    settings: {
1188                        vertical: this.thumb_verital,
1189                        slidesToShow: parseInt(_thumb_column['lg'])
1190                    }
1191                },
1192                {
1193                    breakpoint: 991,
1194                    settings: {
1195                        vertical: false,
1196                        slidesToShow: parseInt(_thumb_column['md'])
1197                    }
1198                },
1199                {
1200                    breakpoint: 768,
1201                    settings: {
1202                        vertical: false,
1203                        slidesToShow: parseInt(_thumb_column['sm'])
1204                    }
1205                },
1206                {
1207                    breakpoint: 600,
1208                    settings: {
1209                        vertical: false,
1210                        slidesToShow: parseInt(_thumb_column['xs'])
1211                    }
1212                },
1213                {
1214                    breakpoint: 480,
1215                    settings: {
1216                        vertical: false,
1217                        slidesToShow: parseInt(_thumb_column['mb'])
1218                    }
1219                }
1220            ]
1221        };
1222
1223        if(!this.thumb_verital){
1224            _thumb_carousel_config.infinite = false;
1225            _thumb_carousel_config.centerMode = false;
1226            _thumb_carousel_config.centerPadding = '0px';
1227        }
1228
1229        var _slide_carousel_config = {
1230            infinite: false,
1231            swipe: true,
1232            slidesToShow: 1,
1233            slidesToScroll: 1,
1234            arrows: true,
1235            asNavFor: '#' + thumb_id,
1236            prevArrow: '<span class="slick-prev"><i class="dl-icon-left"></i></span>',
1237            nextArrow: '<span class="slick-next"><i class="dl-icon-right"></i></span>',
1238            rtl: LA.utils.isRTL()
1239        };
1240        if(!this.thumb_verital){
1241            _slide_carousel_config.infinite = false;
1242        }
1243
1244        $thumb.slick(_thumb_carousel_config);
1245        $slides.slick(_slide_carousel_config);
1246
1247        LA.utils.LazyLoad($('img,.la-lazyload-image', $target.parent()), {
1248            rootMargin: '0px',
1249            complete : function(){
1250                $target.css( 'opacity', 1 );
1251                $thumb.slick('setPosition');
1252                $target.parent().removeClass('swatch-loading');
1253
1254                if(is_quickview){
1255                    setTimeout(function(){
1256                        $slides.resize();
1257                        setTimeout(function(){
1258                            $('body').removeClass('lightcase--pending').addClass('lightcase--completed');
1259                        }, 50);
1260                    }, 150);
1261                }
1262                else{
1263                    setTimeout(function(){
1264                        $('body').trigger("la_sticky:recalc");
1265                    },200);
1266                }
1267            }
1268        }).observe();
1269
1270    };
1271
1272    /**
1273     * Init zoom.
1274     */
1275    LA_ProductGallery.prototype.initZoom = function() {
1276        this.initZoomForTarget( this.$images );
1277    };
1278
1279    LA_ProductGallery.prototype.initZoomForTarget = function( zoomTarget ) {
1280        if ( ! this.zoom_enabled ) {
1281            return false;
1282        }
1283
1284        var galleryWidth = this.$target.width(),
1285            zoomEnabled  = false,
1286            zoom_options;
1287
1288        $( zoomTarget ).each( function( index, target ) {
1289            var image = $( target ).find( 'img' );
1290
1291            if ( image.data( 'large_image_width' ) > galleryWidth ) {
1292                zoomEnabled = true;
1293                return false;
1294            }
1295        } );
1296
1297        // But only zoom if the img is larger than its container.
1298        if ( zoomEnabled ) {
1299            try{
1300                zoom_options = $.extend( {
1301                    touch: false
1302                }, wc_single_product_params.zoom_options );
1303            }
1304            catch (ex){
1305                zoom_options = {
1306                    touch: false
1307                };
1308            }
1309
1310            if ( 'ontouchstart' in document.documentElement ) {
1311                zoom_options.on = 'click';
1312            }
1313
1314            zoomTarget.trigger( 'zoom.destroy' );
1315            zoomTarget.zoom( zoom_options );
1316        }
1317    };
1318
1319    /**
1320     * Init PhotoSwipe.
1321     */
1322    LA_ProductGallery.prototype.initPhotoswipe = function() {
1323        if ( this.zoom_enabled && this.$images.length > 0 ) {
1324            this.$target.find('.woocommerce-product-gallery__actions').prepend( '<a href="#" class="woocommerce-product-gallery__trigger"><span><i class="dl-icon-zoom-in"></i></span></a>' );
1325            this.$target.on( 'click', '.woocommerce-product-gallery__trigger', this.openPhotoswipe );
1326        }
1327        this.$target.on( 'click', '.woocommerce-product-gallery__image a', this.openPhotoswipe );
1328    };
1329
1330    /**
1331     * Reset slide position to 0.
1332     */
1333    LA_ProductGallery.prototype.onResetSlidePosition = function() {
1334        this.$target.parent().removeClass('swatch-loading');
1335        this.$target.find('.woocommerce-product-gallery__wrapper').slick('slickGoTo', 0);
1336    };
1337
1338    /**
1339     * Get product gallery image items.
1340     */
1341    LA_ProductGallery.prototype.getGalleryItems = function() {
1342        var $slides = this.$images,
1343            items   = [];
1344
1345        if ( $slides.length > 0 ) {
1346            $slides.each( function( i, el ) {
1347                var img = $( el ).find( 'img' ),
1348                    large_image_src = img.attr( 'data-large_image' ),
1349                    large_image_w   = img.attr( 'data-large_image_width' ),
1350                    large_image_h   = img.attr( 'data-large_image_height' ),
1351                    item            = {
1352                        src: large_image_src,
1353                        w:   large_image_w,
1354                        h:   large_image_h,
1355                        title: img.attr( 'title' )
1356                    };
1357                if($(el).attr('data-video')){
1358                    item = {
1359                        html: $(el).attr('data-video')
1360                    };
1361                }
1362                items.push( item );
1363            } );
1364        }
1365
1366        return items;
1367    };
1368
1369    /**
1370     * Open photoswipe modal.
1371     */
1372    LA_ProductGallery.prototype.openPhotoswipe = function( e ) {
1373        e.preventDefault();
1374
1375        var pswpElement = $( '.pswp' )[0],
1376            items       = this.getGalleryItems(),
1377            eventTarget = $( e.target ),
1378            clicked;
1379
1380        if ( ! eventTarget.is( '.woocommerce-product-gallery__trigger' ) ) {
1381            clicked = eventTarget.closest( '.woocommerce-product-gallery__image' );
1382        } else {
1383            clicked = this.$target.find( '.slick-current' );
1384        }
1385
1386        var options = {
1387            index:                 $( clicked ).index(),
1388            shareEl:               false,
1389            closeOnScroll:         false,
1390            history:               false,
1391            hideAnimationDuration: 0,
1392            showAnimationDuration: 0
1393        };
1394
1395        // Initializes and opens PhotoSwipe.
1396        var photoswipe = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options );
1397        photoswipe.init();
1398    };
1399
1400    /**
1401     * Function to call la_product_gallery on jquery selector.
1402     */
1403    $.fn.la_product_gallery = function( args ) {
1404        new LA_ProductGallery( this, args );
1405        return this;
1406    };
1407
1408}(jQuery));
1409
1410/*
1411 Initialize LA Swatches
1412 */
1413(function($) {
1414    'use strict';
1415
1416    function variation_calculator(variation_attributes, product_variations) {
1417
1418        this.recalc_needed = true;
1419        this.variation_attributes = variation_attributes;
1420
1421        //The actual variations that are configured in woocommerce.
1422        this.variations_available = product_variations;
1423
1424        //Stores the calculation result for attribute + values that are available based on the selected attributes.
1425        this.variations_current = {};
1426
1427        //Stores the selected attributes + values
1428        this.variations_selected = {};
1429
1430        //Reset all the attributes + values to disabled.  They will be reenabled durring the calcution.
1431        this.reset_current = function () {
1432            for (var attribute in this.variation_attributes) {
1433                this.variations_current[attribute] = {};
1434                for (var av = 0; av < this.variation_attributes[attribute].length; av++) {
1435                    this.variations_current[attribute.toString()][this.variation_attributes[attribute][av].toString()] = 0;
1436                }
1437            }
1438        };
1439
1440        //Do the things to update the variations_current object with attributes + values which are enabled.
1441        this.update_current = function () {
1442            this.reset_current();
1443            for (var i = 0; i < this.variations_available.length; i++) {
1444                if (!this.variations_available[i].variation_is_active) {
1445                    continue; //Variation is unavailable, probably out of stock.
1446                }
1447
1448                //the variation attributes for the product this variation.
1449                var variation_attributes = this.variations_available[i].attributes;
1450
1451                //loop though each variation attribute, turning on and off attributes which won't be available.
1452                for (var attribute in variation_attributes) {
1453
1454                    var maybe_available_attribute_value = variation_attributes[attribute];
1455                    var selected_value = this.variations_selected[attribute];
1456
1457                    if (selected_value && selected_value == maybe_available_attribute_value) {
1458                        this.variations_current[attribute][maybe_available_attribute_value] = 1; //this is a currently selected attribute value
1459                    } else {
1460
1461                        var result = true;
1462
1463                        /*
1464
1465                         Loop though any other item that is selected,
1466                         checking to see if the attribute value does not match one of the attributes for this variation.
1467                         If it does not match the attributes for this variation we do nothing.
1468                         If none have matched at the end of these loops, the atttribute_option will remain off and unavailable.
1469
1470                         */
1471                        for (var other_selected_attribute in this.variations_selected) {
1472
1473                            if (other_selected_attribute == attribute) {
1474                                //We are looking to see if any attribute that is selected will cause this to fail.
1475                                //Continue the loop since this is the attribute from above and we don't need to check against ourselves.
1476                                continue;
1477                            }
1478
1479                            //Grab the value that is selected for the other attribute.
1480                            var other_selected_attribute_value = this.variations_selected[other_selected_attribute];
1481
1482                            //Grab the current product variations attribute value for the other selected attribute we are checking.
1483                            var other_available_attribute_value = variation_attributes[other_selected_attribute];
1484
1485                            if (other_selected_attribute_value) {
1486                                if (other_available_attribute_value) {
1487                                    if (other_selected_attribute_value != other_available_attribute_value) {
1488                                        /*
1489                                         The value this variation has for the "other_selected_attribute" does not match.
1490                                         Since it does not match it does not allow us to turn on an available attribute value.
1491
1492                                         Set the result to false so we skip turning anything on.
1493
1494                                         Set the result to false so that we do not enable this attribute value.
1495
1496                                         If the value does match then we know that the current attribute we are looping through
1497                                         might be available for us to set available attribute values.
1498                                         */
1499                                        result = false;
1500                                        //Something on this variation didn't match the current selection, so we don't care about any of it's attributes.
1501                                    }
1502                                }
1503                            }
1504                        }
1505
1506                        /**
1507                         After checking this attribute against this variation's attributes
1508                         we either have an attribute which should be enabled or not.
1509
1510                         If the result is false we know that something on this variation did not match the currently selected attribute values.
1511
1512                         **/
1513                        if (result) {
1514                            if (maybe_available_attribute_value === "") {
1515                                for (var av in this.variations_current[attribute]) {
1516                                    this.variations_current[attribute][av] = 1;
1517                                }
1518
1519                            } else {
1520                                this.variations_current[attribute][maybe_available_attribute_value] = 1;
1521                            }
1522                        }
1523
1524                    }
1525                }
1526            }
1527
1528            this.recalc_needed = false;
1529        };
1530
1531        this.get_current = function () {
1532            if (this.recalc_needed) {
1533                this.update_current();
1534            }
1535            return this.variations_current;
1536        };
1537
1538        this.reset_selected = function () {
1539            this.recalc_needed = true;
1540            this.variations_selected = {};
1541        }
1542
1543        this.set_selected = function (key, value) {
1544            this.recalc_needed = true;
1545            this.variations_selected[key] = value;
1546        };
1547
1548        this.get_selected = function () {
1549            return this.variations_selected;
1550        }
1551    }
1552
1553    function la_generator_gallery_html( variation ){
1554        var _html = '';
1555        if( typeof variation !== "undefined" && $.isArray(variation.la_additional_images) ){
1556            $.each(variation.la_additional_images, function(idx, val){
1557                _html += '<div data-thumb="'+val.thumb[0]+'" class="woocommerce-product-gallery__image">';
1558                _html += '<a href="'+val.large[0]+'" data-videolink="'+val.videolink+'">';
1559                _html += '<span class="g-overlay" style="background-image: url('+val.large[0]+')"></span>';
1560                _html += '<img ';
1561                _html += 'width="'+val.single[1]+'" ';
1562                _html += 'height="'+val.single[2]+'" ';
1563                _html += 'src="'+val.single[0]+'" ';
1564                _html += 'class="attachment-shop_single size-shop_single" ';
1565                _html += 'alt="'+val.alt+'" ';
1566                _html += 'title="'+val.title+'" ';
1567                _html += 'data-caption="'+val.caption+'" ';
1568                _html += 'data-src="'+val.large[0]+'" ';
1569                _html += 'data-large_image="'+val.large[0]+'" ';
1570                _html += 'data-large_image_width="'+val.large[1]+'" ';
1571                _html += 'data-large_image_height="'+val.large[2]+'" ';
1572                _html += 'srcset="'+val.srcset+'" ';
1573                _html += 'sizes="'+val.sizes+'" ';
1574                _html += '</a>';
1575                _html += '</div>';
1576            });
1577        }
1578        return _html;
1579    }
1580
1581    function la_update_swatches_gallery($form, variation ){
1582        var $product_selector = $form.closest('.la-p-single-wrap'),
1583            $main_image_col = $product_selector.find('.product--large-image'),
1584            _html = '';
1585        if(variation !== null){
1586            _html = la_generator_gallery_html(variation);
1587        }
1588        else{
1589            var _old_gallery = $main_image_col.data('old_gallery') || false;
1590            if(_old_gallery){
1591                _html = _old_gallery;
1592            }
1593        }
1594        if (_html != '') {
1595
1596            if(!!$main_image_col.data('prev_gallery')){
1597
1598                var $_oldGalleryObject = $($main_image_col.data('prev_gallery')),
1599                    $_newGalleryObject = $(_html);
1600
1601                var _donot_swap = true;
1602
1603                if($_oldGalleryObject.length == $_newGalleryObject.length){
1604                    for (var idx = 0; idx < $_oldGalleryObject.length; idx++){
1605                        if($($_oldGalleryObject[idx]).attr('data-thumb') != $($_newGalleryObject[idx]).attr('data-thumb')){
1606                            _donot_swap = false;
1607                        }
1608                    }
1609                }else{
1610                    _donot_swap = false;
1611                }
1612
1613                if(_donot_swap){
1614                    return;
1615                }
1616
1617            }
1618
1619            $main_image_col.data('prev_gallery', _html);
1620
1621            _html = '<div class="woocommerce-product-gallery--with-images la-woo-product-gallery'+ ($main_image_col.hasClass('force-disable-slider-script') ? ' force-disable-slider-script' : '') +'"><figure class="woocommerce-product-gallery__wrapper">'+_html+'</figure><div class="la_woo_loading"><div class="la-loader spinner3"><div class="dot1"></div><div class="dot2"></div><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div></div></div>';
1622            _html += '<div id="la_woo_thumbs" class="la-woo-thumbs"><div class="la-thumb-inner"></div></div>';
1623            $main_image_col.css({
1624                'max-height': $main_image_col.height(),
1625                'min-height': $main_image_col.height()
1626            }).addClass('swatch-loading');
1627
1628            LA.utils.LazyLoad($('img,.la-lazyload-image', $(_html)), {
1629                rootMargin: '0px',
1630                complete : function(){
1631                    $main_image_col.html(_html);
1632                    var $la_gallery_selector = $main_image_col.find('.la-woo-product-gallery');
1633                    if(variation !== null){
1634                        $la_gallery_selector.addClass('la-rebuild-product-gallery');
1635                    }
1636                    $la_gallery_selector.la_product_gallery().addClass('swatch-loaded');
1637                    $main_image_col.css({
1638                        'max-height': 'none',
1639                        'min-height': '0'
1640                    });
1641                }
1642            }).observe();
1643        }
1644    }
1645
1646    try{
1647
1648        $.fn.la_variation_form = function () {
1649            var $form = this;
1650            var $product_id = parseInt($form.data('product_id'), 10);
1651            var calculator = null;
1652            var $use_ajax = false;
1653            var $swatches_xhr = null;
1654
1655            $form.addClass('la-init-swatches');
1656
1657            $form.find('td.label').each(function(){
1658                var $label = $(this).find('label');
1659                $label.append('<span class="swatch-label"></span>');
1660            });
1661
1662            $form.on('bind_calculator', function () {
1663
1664                var $product_variations = $form.data('product_variations');
1665                $use_ajax = $product_variations === false;
1666
1667                if ($use_ajax) {
1668                    $form.block({message: null, overlayCSS: {background: '#fff', opacity: 0.6}});
1669                }
1670
1671                var attribute_keys = {};
1672
1673                //Set the default label.
1674                $form.find('.select-option.selected').each(function (index, el) {
1675                    var $this = $(this);
1676
1677                    //Get the wrapper select div
1678                    var $option_wrapper = $this.closest('div.select').eq(0);
1679                    var $label = $option_wrapper.closest('tr').find('.swatch-label').eq(0);
1680                    var $la_select_box = $option_wrapper.find('select').first();
1681
1682                    // Decode entities
1683                    var attr_val = $('<div/>').html($this.data('value')).text();
1684
1685                    // Add slashes
1686                    attr_val = attr_val.replace(/'/g, '\\\'');
1687                    attr_val = attr_val.replace(/"/g, '\\\"');
1688
1689                    if ($label) {
1690                        $label.html($la_select_box.children("[value='" + attr_val + "']").eq(0).text());
1691                    }
1692                    $la_select_box.trigger('change');
1693                });
1694
1695                $form.find('.variations select').each(function (index, el) {
1696                    var $current_attr_select = $(el);
1697                    var current_attribute_name = $current_attr_select.data('attribute_name') || $current_attr_select.attr('name');
1698
1699                    attribute_keys[current_attribute_name] = [];
1700
1701                    //Build out a list of all available attributes and their values.
1702                    var current_options = '';
1703                    current_options = $current_attr_select.find('option:gt(0)').get();
1704
1705                    if (current_options.length) {
1706                        for (var i = 0; i < current_options.length; i++) {
1707                            var option = current_options[i];
1708                            attribute_keys[current_attribute_name].push($(option).val());
1709                        }
1710                    }
1711                });
1712
1713                if ($use_ajax) {
1714                    if ($swatches_xhr) {
1715                        $swatches_xhr.abort();
1716                    }
1717
1718                    var data = {
1719                        product_id: $product_id,
1720                        action: 'la_swatch_get_product_variations'
1721                    };
1722
1723                    $swatches_xhr = $.ajax({
1724                        url: la_theme_config.ajax_url,
1725                        type: 'POST',
1726                        data: data,
1727                        success: function (response) {
1728                            calculator = new variation_calculator(attribute_keys, response.data, null, null);
1729                            $form.unblock();
1730                        }
1731                    });
1732                } else {
1733                    calculator = new variation_calculator(attribute_keys, $product_variations, null, null);
1734                }
1735
1736                $form.trigger('woocommerce_variation_has_changed');
1737            });
1738
1739            $form
1740                .on('change', '.wc-default-select', function(e){
1741                    var $__that = $(this);
1742                    var $label = $__that.closest('tr').find('.swatch-label').eq(0);
1743                    if($__that.val() != ''){
1744                        $label.html($__that.find('option:selected').html());
1745                    }else{
1746                        $label.html('');
1747                    }
1748                });
1749
1750            $form.find('.wc-default-select').trigger('change');
1751
1752            $form
1753            // On clicking the reset variation button
1754                .on('click', '.reset_variations', function () {
1755                    $form.find('.swatch-label').html('');
1756                    $form.find('.select-option').removeClass('selected');
1757                    $form.find('.radio-option').prop('checked', false);
1758                    return false;
1759                })
1760                .on('click', '.select-option', function (e) {
1761                    e.preventDefault();
1762
1763                    var $this = $(this);
1764
1765                    //Get the wrapper select div
1766                    var $option_wrapper = $this.closest('div.select').eq(0);
1767                    var $label = $option_wrapper.closest('tr').find('.swatch-label').eq(0);
1768                    var $la_select_box = $option_wrapper.find('select').first();
1769                    if ($this.hasClass('disabled')) {
1770                        return false;
1771                    }
1772                    else if ($this.hasClass('selected')) {
1773                        $this.removeClass('selected');
1774                        $la_select_box.children('option:eq(0)').prop("selected", "selected").change();
1775                        if ($label) {
1776                            $label.html('');
1777                        }
1778                    }
1779                    else {
1780
1781                        $option_wrapper.find('.select-option').removeClass('selected');
1782                        //Set the option to selected.
1783                        $this.addClass('selected');
1784
1785                        // Decode entities
1786                        var attr_val = $('<div/>').html($this.data('value')).text();
1787
1788                        // Add slashes
1789                        attr_val = attr_val.replace(/'/g, '\\\'');
1790                        attr_val = attr_val.replace(/"/g, '\\\"');
1791
1792                        $la_select_box.trigger('focusin').children("[value='" + attr_val + "']").prop("selected", "selected").change();
1793                        if ($label) {
1794                            $label.html($la_select_box.children("[value='" + attr_val + "']").eq(0).text());
1795                        }
1796                    }
1797                })
1798                .on('change', '.radio-option', function (e) {
1799
1800                    var $this = $(this);
1801
1802                    //Get the wrapper select div
1803                    var $option_wrapper = $this.closest('div.select').eq(0);
1804
1805                    //Select the option.
1806                    var $la_select_box = $option_wrapper.find('select').first();
1807
1808                    // Decode entities
1809                    var attr_val = $('<div/>').html($this.val()).text();
1810
1811                    // Add slashes
1812                    attr_val = attr_val.replace(/'/g, '\\\'');
1813                    attr_val = attr_val.replace(/"/g, '\\\"');
1814
1815                    $la_select_box.trigger('focusin').children("[value='" + attr_val + "']").prop("selected", "selected").change();
1816
1817
1818                })
1819                .on('woocommerce_variation_has_changed', function () {
1820                    if (calculator === null) {
1821                        return;
1822                    }
1823
1824                    $form.find('.variations select').each(function () {
1825                        var attribute_name = $(this).data('attribute_name') || $(this).attr('name');
1826                        calculator.set_selected(attribute_name, $(this).val());
1827                    });
1828
1829                    var current_options = calculator.get_current();
1830
1831                    //Grey out or show valid options.
1832                    $form.find('div.select').each(function (index, element) {
1833                        var $la_select_box = $(element).find('select').first();
1834
1835                        var attribute_name = $la_select_box.data('attribute_name') || $la_select_box.attr('name');
1836                        var avaiable_options = current_options[attribute_name];
1837
1838                        $(element).find('div.select-option').each(function (index, option) {
1839                            if (!avaiable_options[$(option).data('value')]) {
1840                                $(option).addClass('disabled', 'disabled');
1841                            } else {
1842                                $(option).removeClass('disabled');
1843                            }
1844                        });
1845
1846                        $(element).find('input.radio-option').each(function (index, option) {
1847                            if (!avaiable_options[$(option).val()]) {
1848                                $(option).attr('disabled', 'disabled');
1849                                $(option).parent().addClass('disabled', 'disabled');
1850                            } else {
1851                                $(option).removeAttr('disabled');
1852                                $(option).parent().removeClass('disabled');
1853                            }
1854                        });
1855                    });
1856
1857                    if ($use_ajax) {
1858                        //Manage a regular  default select list.
1859                        // WooCommerce core does not do this if it's using AJAX for it's processing.
1860                        $form.find('.wc-default-select').each(function (index, element) {
1861                            var $la_select_box = $(element);
1862
1863                            var attribute_name = $la_select_box.data('attribute_name') || $la_select_box.attr('name');
1864                            var avaiable_options = current_options[attribute_name];
1865
1866                            $la_select_box.find('option:gt(0)').removeClass('attached');
1867                            $la_select_box.find('option:gt(0)').removeClass('enabled');
1868                            $la_select_box.find('option:gt(0)').removeAttr('disabled');
1869
1870                            //Disable all options
1871                            $la_select_box.find('option:gt(0)').each(function (optindex, option_element) {
1872                                if (!avaiable_options[$(option_element).val()]) {
1873                                    $(option_element).addClass('disabled', 'disabled');
1874                                } else {
1875                                    $(option_element).addClass('attached');
1876                                    $(option_element).addClass('enabled');
1877                                }
1878                            });
1879
1880                            $la_select_box.find('option:gt(0):not(.enabled)').attr('disabled', 'disabled');
1881
1882                        });
1883                    }
1884                })
1885                .on('found_variation', function( event, variation ){
1886                    la_update_swatches_gallery($form, variation);
1887                })
1888                .on('reset_image', function( event ){
1889                    la_update_swatches_gallery($form, null);
1890                });
1891
1892            $form.find('.single_variation').on('show_variation', function(e, variation, purchasable ){
1893                var $priceWrapper = $form.siblings('.single-price-wrapper');
1894                $('span.price', $priceWrapper).remove();
1895                $priceWrapper.append(variation.price_html);
1896            })
1897        };
1898
1899        var forms = [];
1900
1901        if(la_theme_config.la_extension_available.swatches){
1902            $(document).on('wc_variation_form', '.variations_form',  function (e) {
1903                var $form = $(e.target);
1904                forms.push($form);
1905                if ( !$form.data('has_swatches_form') ) {
1906                    if (true || $form.find('.swatch-control').length) {
1907                        $form.data('has_swatches_form', true);
1908
1909                        $form.la_variation_form();
1910                        $form.trigger('bind_calculator');
1911
1912                        $form.on('reload_product_variations', function () {
1913                            for (var i = 0; i < forms.length; i++) {
1914
1915                                forms[i].trigger('woocommerce_variation_has_changed');
1916                                forms[i].trigger('bind_calculator');
1917                                forms[i].trigger('woocommerce_variation_has_changed');
1918                            }
1919                        })
1920                    }
1921                }
1922            });
1923        }
1924    }catch (ex){
1925        console.log('la_theme_config.la_extension_available.swatches is not activate');
1926    }
1927
1928})(jQuery);
1929
1930/*
1931 Initialize Core
1932 */
1933(function($) {
1934    'use strict';
1935
1936    var LA = window.LA || {};
1937    LA.core = window.LA.core || {};
1938
1939    var _loadedDependencies = [],
1940        _inQueue = {};
1941
1942    LA.core.initAll = function( $scope ) {
1943        var $el = $scope.find( '.js-el' ),
1944            $components = $el.filter( '[data-la_component]' ),
1945            component = null,
1946            tooltip_element = '';
1947
1948        tooltip_element += '.product--summary .add_compare,';
1949        tooltip_element += '.product--summary .add_wishlist,';
1950        tooltip_element += '.products-list .product_item .product_item--thumbn
1950ail .product_item--action .quickview,';
1951        tooltip_element += '.products-grid-6 .button:not(.add_to_cart_button),';
1952        tooltip_element += '.products-grid-6 .add_to_cart_button span,';
1953        tooltip_element += '.products-grid:not(.products-grid-6) .product_item_thumbnail_action .button:not(.add_to_cart_button),';
1954        tooltip_element += '.products-grid:not(.products-grid-6) .product_item_thumbnail_action .add_to_cart_button span';
1955
1956
1957        if($scope.find(tooltip_element).length){
1958            LA.core.ToolTip($scope.find(tooltip_element)).init();
1959        }
1960        LA.core.ToolTip($scope.find('.social--sharing a'), {
1961            placement: LA.utils.isRTL() ? 'right' : 'left'
1962        }).init();
1963
1964        if($components.length <= 0 ){
1965            return;
1966        }
1967
1968        // initialize  component
1969        var init = function init(name, el) {
1970            var $el = $(el);
1971
1972            if ( $el.data('init-' + name) ) return;
1973
1974            if ( typeof LA.component[ name ] !== 'function' ){
1975                LA.utils.logger.set( name, 'Component' , 'Component init error' );
1976            }
1977            else {
1978                component = new LA.component[ name ]( el );
1979                component.init();
1980                $el.data('init-' + name, true);
1981                LA.utils.eventManager.publish('LA:component_inited');
1982            }
1983        };
1984
1985        $components.each( function() {
1986            var self = this,
1987                $this = $( this ),
1988                names = $this.data( 'la_component' );
1989
1990            if( typeof names === 'string' ) {
1991                var _name = names ;
1992                init( _name , self);
1993            }
1994            else {
1995                names.forEach( function( name ) {
1996                    init(name, self);
1997                });
1998            }
1999        });
2000    };
2001
2002    LA.core.loadDependencies = function( dependencies, callback ) {
2003        var _callback = callback || function() {};
2004
2005        if( !dependencies ) {
2006            _callback();
2007            return;
2008        }
2009
2010        var newDeps = dependencies.map( function( dep ) {
2011            if( _loadedDependencies.indexOf( dep ) === -1 ) {
2012                if( typeof _inQueue[ dep ] === 'undefined' ) {
2013                    LA.utils.logger.display(dep);
2014                    return dep;
2015                } else {
2016                    _inQueue[ dep ].push( _callback );
2017                    return true;
2018                }
2019            } else {
2020                return false;
2021            }
2022        });
2023
2024        if( newDeps[0] === true ) {
2025            LA.utils.logger.set({
2026                new_deps : newDeps[0],
2027                waitingFor : dependencies[0]
2028            }, 'Component', 'waitingFor: load js file before running callback');
2029            return;
2030        }
2031
2032        if( newDeps[0] === false ) {
2033            _callback();
2034            return;
2035        }
2036
2037        var queue = newDeps.map( function( script ) {
2038            //LA.utils.logger.display(script);
2039            _inQueue[ script ] = [ _callback ];
2040            return $.getCachedScript( script );
2041        });
2042
2043        // Callbacks invoking
2044        var onLoad = function onLoad() {
2045            var index = 0;
2046            newDeps.map( function( loaded ) {
2047                index++;
2048                _inQueue[ loaded ].forEach( function( callback ) {
2049                    if(index == newDeps.length){
2050                        callback();
2051                    }
2052                });
2053                delete _inQueue[ loaded ];
2054                _loadedDependencies.push( loaded );
2055            });
2056        };
2057
2058        // Run callbacks when promise is resolved
2059        $.when.apply( null, queue ).done( onLoad );
2060    };
2061
2062    LA.core.path = {
2063        theme   : la_theme_config.theme_path,
2064        plugins : la_theme_config.js_path,
2065        ajaxUrl : la_theme_config.ajax_url,
2066        security : la_theme_config.security
2067    };
2068
2069})(jQuery);
2070
2071/*
2072 Initialize Component
2073 */
2074
2075(function($) {
2076    "use strict";
2077
2078    var LA = window.LA || {},
2079        $window = $(window),
2080        $document = $(document),
2081        $htmlbody = $('html,body'),
2082        $body = $('body.zuka-body'),
2083        $masthead = $('#masthead'),
2084        $masthead_inner = $masthead.find('.site-header-inner'),
2085        $masthead_aside = $('#masthead_aside'),
2086        $masthead_aside_inner = $masthead_aside.find('.site-header-inner'),
2087        $masthead_mb = $('.site-header-mobile'),
2088        $masthead_mb_inner = $masthead_mb.find('.site-header-inner'),
2089        $footer_colophon = $('#colophon'),
2090        $la_full_page = $('#la_full_page');
2091
2092    LA.utils = window.LA.utils || {};
2093    LA.component = window.LA.component || {};
2094    LA.ui = window.LA.ui || {};
2095    LA.core = window.LA.core || {};
2096
2097    LA.ui.AnimateLoadElement = function( effect_name, $elements, callback ){
2098        var _callback = callback || function() {};
2099        var animation_timeout = 0;
2100
2101        // hide all element that not yet loaded
2102        $elements.css({ 'opacity': 0 });
2103
2104        if ( effect_name == 'fade'){
2105            $elements.each(function () {
2106                $(this).stop().animate({
2107                    'opacity': 1
2108                }, 1000 );
2109            });
2110            animation_timeout = 1000;
2111        }
2112        else if ( effect_name == 'sequencefade'){
2113            $elements.each(function (i) {
2114                var $elm = $(this);
2115                setTimeout(function () {
2116                    $elm.stop().animate({
2117                        'opacity': 1
2118                    }, 1000 );
2119                }, 100 + (i * 50) );
2120            });
2121            animation_timeout = 500 + ($elements.length * 50);
2122        }
2123        else if ( effect_name == 'upfade'){
2124
2125            $elements.each(function(){
2126                var $elm = $(this),
2127                    t = parseInt($elm.css('top'), 10) + ( $elm.height() / 2);
2128                $elm.css({
2129                    top: t + 'px',
2130                    opacity: 0
2131                });
2132            });
2133
2134            $elements.each(function () {
2135                var $el = $(this);
2136                $el.stop().animate({
2137                    top: parseInt($el.css('top'), 10) - ( $el.height() / 2),
2138                    opacity: 1
2139                }, 1500);
2140            });
2141
2142            animation_timeout = 2000;
2143        }
2144        else if ( effect_name == 'sequenceupfade'){
2145
2146            $elements.each(function(){
2147                var $elm = $(this),
2148                    t = parseInt($elm.css('top'), 10) + ( $elm.height() / 2);
2149                $elm.css({
2150                    top: t + 'px',
2151                    opacity: 0
2152                });
2153            });
2154
2155            $elements.each(function (i) {
2156                var $elm = $(this);
2157                setTimeout(function () {
2158                    $elm.stop().animate({
2159                        top: parseInt($elm.css('top'), 10) - ( $elm.height() / 2),
2160                        opacity: 1
2161                    }, 1000);
2162                }, 100 + i * 50);
2163            });
2164
2165            animation_timeout = 500 + ($elements.length * 50);
2166        }
2167        else{
2168            $elements.css({ 'opacity': 1 });
2169            animation_timeout = 1000;
2170        }
2171
2172        /* run callback */
2173        setTimeout(function(){
2174            _callback.call();
2175        }, animation_timeout );
2176    };
2177
2178    LA.ui.LazyLoadElementEffect = function( selector, $container ){
2179        function _init_effect(){
2180            var _effect_name = false === !!$container.attr('data-la-effect') ? 'sequenceupfade' : $container.attr('data-la-effect');
2181            LA.ui.AnimateLoadElement(_effect_name, $(selector, $container), function(){
2182                $(selector, $container).addClass('showmenow');
2183            });
2184        }
2185
2186        if($container.hasClass('LazyLoadElementEffect-inited')){
2187            return;
2188        }
2189
2190        LA.utils.LazyLoad($container, {
2191            load : _init_effect()
2192        }).observe();
2193
2194        $container.addClass('LazyLoadElementEffect-inited');
2195
2196    };
2197
2198    LA.ui.MobileMenuEffect = function(){
2199        var animationClasses = {
2200            classin : 'dl-animate-in-2',
2201            classout : 'dl-animate-out-2'
2202        };
2203        switch (la_theme_config.mm_mb_effect){
2204            case "1":
2205                animationClasses = {
2206                    classin : 'dl-animate-in-1',
2207                    classout : 'dl-animate-out-1'
2208                };
2209                break;
2210
2211            case "2":
2212                animationClasses = {
2213                    classin : 'dl-animate-in-2',
2214                    classout : 'dl-animate-out-2'
2215                };
2216                break;
2217
2218            case "3":
2219                animationClasses = {
2220                    classin : 'dl-animate-in-3',
2221                    classout : 'dl-animate-out-3'
2222                };
2223                break;
2224
2225            case "4":
2226                animationClasses = {
2227                    classin : 'dl-animate-in-4',
2228                    classout : 'dl-animate-out-4'
2229                };
2230                break;
2231
2232            case "5":
2233                animationClasses = {
2234                    classin : 'dl-animate-in-5',
2235                    classout : 'dl-animate-out-5'
2236                };
2237                break;
2238        }
2239
2240        return animationClasses;
2241    };
2242
2243    LA.ui.ShowMessageBox = function( html, ex_class ) {
2244
2245        var show_popup = function(){
2246            lightcase.start({
2247                href: '#',
2248                showSequenceInfo: false,
2249                maxWidth:600,
2250                maxHeight: 500,
2251                onInit: {
2252                    clearTimeout: function(){
2253                        clearTimeout(LA['timeOutMessageBox']);
2254                    }
2255                },
2256                onFinish: {
2257                    insertContent: function () {
2258                        if(ex_class) {
2259                            $body.addClass(ex_class);
2260                        }
2261                        lightcase.get('content').append('<div class="custom-lightcase-overlay"></div>');
2262                        lightcase.get('contentInner').children().html('<div class="la-global-message">' + html + '</div>');
2263                        lightcase.get('contentInner').append('<a class="custom-lighcase-btn-close" href="#"><i class="dl-icon-close"></i></a>');
2264                        lightcase.resize();
2265                        LA['timeOutMessageBox'] = setTimeout(function(){
2266                            lightcase.close();
2267                        }, 20 * 1000);
2268                    }
2269                },
2270                onClose : {
2271                    qux: function() {
2272                        if(ex_class){
2273                            $body.removeClass(ex_class);
2274                        }
2275                        $('.custom-lightcase-overlay').remove();
2276                        $('.custom-lighcase-btn-close').remove();
2277                        clearTimeout(LA['timeOutMessageBox']);
2278                    }
2279                }
2280            });
2281        };
2282
2283        if($.fn.lightcase){
2284            show_popup();
2285        }else{
2286            LA.core.loadDependencies([ LA.core.path.plugins + 'jquery.lightcase.js'], show_popup )
2287        }
2288    };
2289
2290    LA.core.ToolTip = function ($el, opts){
2291
2292        var set_up_tooltip = function(){
2293            $el.tooltip($.extend({
2294                container: 'body',
2295                trigger: 'hover'
2296            }, opts));
2297        }
2298
2299        return {
2300            init : function(){
2301                if( "undefined" !== typeof $.fn.tooltip){
2302                    set_up_tooltip();
2303                }else{
2304                    LA.core.loadDependencies([ LA.core.path.plugins + 'bstooltip.js'], set_up_tooltip );
2305                }
2306            }
2307        }
2308    }
2309
2310    LA.component.ToolTip = function( el ) {
2311
2312        var $el = $(el);
2313        var set_up_tooltip = function(){
2314            $el.tooltip();
2315        }
2316
2317        return {
2318            init : function(){
2319                if( "undefined" !== typeof $.fn.tooltip){
2320                    set_up_tooltip();
2321                }else{
2322                    LA.core.loadDependencies([ LA.core.path.plugins + 'bstooltip.js'], set_up_tooltip );
2323                }
2324            }
2325        }
2326    };
2327
2328    LA.component.loadCSSFile = function( el ) {
2329        return {
2330            init : function(){
2331
2332            }
2333        }
2334    };
2335
2336    LA.component.UnitResponsive = function( el ){
2337        var $elm = $(el),
2338            n 		= $elm.attr('data-el_media_sizes'),
2339            target 	= $elm.attr('data-el_target'),
2340            tmp_xlg = '',
2341            tmp_lg  = '',
2342            tmp_md  = '',
2343            tmp_sm  = '',
2344            tmp_xs  = '',
2345            tmp_mb  = '';
2346
2347        var init = function(){
2348            if (typeof n !== 'undefined' || n != null) {
2349                $.each($.parseJSON(n), function (i, v) {
2350                    var css_prop = i;
2351                    if (typeof v !== 'undefined' && v != null && v != '') {
2352                        $.each(v.split(";"), function(i, vl) {
2353                            if (typeof vl !== 'undefined' && vl != null && vl != '') {
2354                                var splitval = vl.split(":"),
2355                                    _elm_attr = css_prop + ":" + splitval[1] + ";";
2356                                switch( splitval[0]) {
2357                                    case 'xlg':
2358                                        tmp_xlg     += _elm_attr;
2359                                        break;
2360                                    case 'lg':
2361                                        tmp_lg      += _elm_attr;
2362                                        break;
2363                                    case 'md':
2364                                        tmp_md      += _elm_attr;
2365                                        break;
2366                                    case 'sm':
2367                                        tmp_sm      += _elm_attr;
2368                                        break;
2369                                    case 'xs':
2370                                        tmp_xs      += _elm_attr;
2371                                        break;
2372                                    case 'mb':
2373                                        tmp_mb      += _elm_attr;
2374                                        break;
2375                                }
2376                            }
2377                        });
2378                    }
2379                });
2380            }
2381
2382            if(tmp_xlg!='') {
2383                appendCSS(target+ '{' + tmp_xlg + '}', 'xlg');
2384            }
2385            if(tmp_lg!='') {
2386                appendCSS(target+ '{' + tmp_lg + '}', 'lg');
2387            }
2388            if(tmp_md!='') {
2389                appendCSS(target+ '{' + tmp_md + '}', 'md');
2390            }
2391            if(tmp_sm!='') {
2392                appendCSS(target+ '{' + tmp_sm + '}', 'sm');
2393            }
2394            if(tmp_xs!='') {
2395                appendCSS(target+ '{' + tmp_xs + '}', 'xs');
2396            }
2397            if(tmp_mb!='') {
2398                appendCSS(target+ '{' + tmp_mb + '}', 'mb');
2399            }
2400        };
2401
2402        var appendCSS = function(css, screen){
2403            var screen_obj = {
2404                'lg' : 'all',
2405                'xlg' : 'screen and (min-width:1825px)',
2406                'md' : 'screen and (max-width:1199px)',
2407                'sm' : 'screen and (max-width:991px)',
2408                'xs' : 'screen and (max-width:767px)',
2409                'mb' : 'screen and (max-width:575px)'
2410            };
2411
2412            $.each(screen_obj,function(item){
2413                if(!$.exists($('#latheme_custom_css_' + item))){
2414                    $(
2415                        '<style></style>',
2416                        {
2417                            'id' : 'latheme_custom_css_' + item,
2418                            'media' : screen_obj[item]
2419                        }
2420                    ).appendTo('head');
2421                }
2422            });
2423
2424            var $style_tag = $('#latheme_custom_css_' + screen);
2425
2426            $style_tag.append(css);
2427        };
2428
2429        return {
2430            init : init
2431        }
2432    };
2433
2434    LA.component.AutoCarousel = function(el){
2435
2436        var $slider = $(el),
2437            slider_config =  $slider.data('slider_config') || {},
2438            CustomPaging = $slider.data('slick_custompaging') || '';
2439        if(CustomPaging != ''){
2440            slider_config.customPaging = function( slide, i ){
2441                return CustomPaging;
2442            }
2443        }
2444        slider_config = $.extend({
2445            prevArrow: '<button type="button" class="slick-prev default"><i class
2445="dl-icon-left"></i></button>',
2446            nextArrow: '<button type="button" class="slick-next default"><i class="dl-icon-right"></i></button>',
2447            rtl: LA.utils.isRTL()
2448        }, slider_config);
2449
2450
2451        var init = function(){
2452            if($.isFunction( $.fn.slick )){
2453                setup_slick();
2454            }else{
2455                LA.core.loadDependencies([ LA.core.path.plugins + 'jquery.slick.js'], setup_slick );
2456            }
2457        };
2458
2459        var setup_slick = function(){
2460            if(typeof slider_config.arrows !== "undefined" && typeof slider_config._appendArrows === "undefined" && slider_config.arrows == true){
2461                if($slider.closest('.woocommerce').length && $slider.closest('.woocommerce').closest('.vc_row').length ){
2462                    slider_config.appendArrows = $('<div class="la-slick-nav"></div>').prependTo($slider.parent());
2463                }
2464            }
2465            if(typeof slider_config.arrows !== "undefined" && typeof slider_config._appendArrows !== "undefined" && slider_config.arrows == true){
2466                if($.exists($(slider_config._appendArrows))){
2467                    slider_config.appendArrows = $(slider_config._appendArrows)    
2468                }
2469            }
2470
2471            if($slider.closest('.la-carousel-wrapper').hasClass('slider-fade')){
2472                slider_config.fade = true;
2473            }
2474            try{
2475                $slider.on('init', function(e, slick){
2476                    if(slick.slideCount <= slick.options.slidesToShow){
2477                        slick.$slider.addClass('hidden-dots');
2478                    }
2479                    else{
2480                        slick.$slider.removeClass('hidden-dots');
2481                    }
2482
2483                    if(slick.options.centerMode){
2484                        slick.$slider.addClass('la-slick-centerMode');
2485                    }
2486                    LA.utils.LazyLoad($('.la-lazyload-image'), {rootMargin: '0px'}).observe();
2487                });
2488                $slider.slick(slider_config);
2489            }catch (ex){
2490                LA.utils.logger.set(ex, 'AutoCarousel');
2491            }
2492        };
2493
2494        return {
2495            init : init
2496        };
2497
2498    };
2499
2500    LA.component.InsertCustomCSS = function(el){
2501        var $style_tag = $('#latheme_custom_css'),
2502            custom_css = $(el).html();
2503        if(!$.exists($style_tag)){
2504            $style_tag = $('<style></style>', { 'id' : 'latheme_custom_css'}).appendTo('head');
2505        }
2506        return {
2507            init : function(){
2508                $style_tag.append(custom_css);
2509            }
2510        }
2511    };
2512
2513    LA.component.AjaxLoadShortCode = function(el){
2514
2515        var $this = $(el),
2516            query = $this.data('query-settings'),
2517            request_url = $this.data('request'),
2518            nonce = $this.data('public-nonce'),
2519            requestData = {
2520                action : 'la_get_shortcode_loader_by_ajax',
2521                tag : query.tag,
2522                data : query,
2523                _vcnonce : nonce
2524            };
2525
2526        var init = function(){
2527            LA.utils.LazyLoad($this, {
2528                rootMargin: '200px',
2529                load : setup_ajax
2530            }).observe();
2531        };
2532
2533        var setup_ajax = function(){
2534
2535            if($this.hasClass('is-loading') || $this.hasClass('has-loaded')){
2536                return;
2537            }
2538            $this.addClass('is-loading');
2539
2540            var _ajax_option = {
2541                url : request_url,
2542                method: "POST",
2543                dataType: "html",
2544                data : requestData
2545            };
2546
2547            $.ajax(_ajax_option).done(function(response_data){
2548
2549                var $data = $(response_data);
2550                $document.trigger('LA:AjaxLoadShortCode:before_render',[$this,$data]);
2551                $this.removeClass('is-loading');
2552                $this.addClass('has-loaded');
2553                $data.addClass('fadeIn animated');
2554                $data.appendTo($this);
2555
2556                LA.core.initAll($this);
2557
2558                /**
2559                 * We need to refresh Parallax
2560                 */
2561                $window.trigger('la_vc_row_parallax:refresh');
2562
2563                $document.trigger('LA:AjaxLoadShortCode:after_render',[$this,$data]);
2564
2565                LA.utils.LazyLoad($('.la-lazyload-image'), {rootMargin: '0px'}).observe();
2566
2567                if($.exists($masthead_aside_inner)){
2568                    setTimeout(function(){
2569                        $body.trigger("la_sticky:recalc");
2570                    },300);
2571                }
2572
2573                LA.utils.localCache.set(request_url + JSON.stringify({ container : '#' + $data.attr('id'), paged: 1}), response_data);
2574
2575            });
2576        };
2577
2578        return {
2579            init: init
2580        }
2581    };
2582
2583    LA.component.DefaultMasonry = function(el){
2584        var $isotope_container = $(el),
2585            item_selector   = $isotope_container.data('item_selector'),
2586            configs         = ( $isotope_container.data('config_isotope') || {} );
2587
2588        configs = $.extend({
2589            percentPosition: true,
2590            itemSelector : item_selector
2591        },configs);
2592
2593        var setup_masonry = function(){
2594            $isotope_container.find('img[data-lazy-src!=""]').each(function(){
2595                $(this).attr('src', $(this).attr('data-lazy-src')).removeAttr('data-lazy-src');
2596            });
2597            $isotope_container.isotope(configs);
2598            if(!$isotope_container.hasClass('showposts-loop') && !$isotope_container.hasClass('loaded')){
2599                $isotope_container.on('layoutComplete', function(e){
2600                    LA.ui.LazyLoadElementEffect(item_selector, $isotope_container);
2601                });
2602            }
2603
2604            LA.utils.LazyLoad($('img,.la-lazyload-image',$isotope_container), {
2605                rootMargin: '0px',
2606                complete : function(){
2607                    $('.la-isotope-loading', $isotope_container).hide();
2608                    $isotope_container.addClass('loaded').isotope('layout');
2609                }
2610            }).observe();
2611
2612        };
2613
2614        return {
2615            init : function(){
2616                $('.la-isotope-loading', $isotope_container).show();
2617                if($.isFunction( $.fn.isotope )){
2618                    setup_masonry();
2619                }else{
2620                    LA.core.loadDependencies([ LA.core.path.plugins + 'jquery.isotope.pkgd.js'], setup_masonry );
2621                }
2622            }
2623        }
2624
2625    };
2626
2627    LA.component.AdvancedMasonry = function(el){
2628        var $isotope_container = $(el),
2629            item_selector   = $isotope_container.data('item_selector'),
2630            configs         = ( $isotope_container.data('config_isotope') || {} );
2631
2632        configs = $.extend({
2633            percentPosition: true,
2634            itemSelector : item_selector,
2635            masonry : {
2636                gutter: 0
2637            }
2638        },configs);
2639
2640        var get_isotope_column_number = function (w_w, item_w) {
2641            //w_w = ( w_w > 1920 ) ? 1920 : w_w;
2642            return Math.round(w_w / item_w);
2643        };
2644
2645        LA.utils.eventManager.subscribe('LA:AdvancedMasonry:calculatorItemWidth', function( e, $isotope_container ){
2646            if($isotope_container.hasClass('grid-items')){
2647                return;
2648            }
2649            var ww = $window.width(),
2650                _base_w = $isotope_container.data('item-width'),
2651                _base_h = $isotope_container.data('item-height'),
2652                _container_width_base = ( false !== !!$isotope_container.data('container-width') ? $isotope_container.data('container-width') : $isotope_container.width()),
2653                _container_width = $isotope_container.width();
2654
2655            var portfolionumber = get_isotope_column_number(_container_width_base, _base_w);
2656
2657            if( ww > 1300){
2658
2659                var __maxItem = $isotope_container.parent().attr('class').match(/masonry-max-item-per-row-(\d+)/);
2660                var __minItem = $isotope_container.parent().attr('class').match(/masonry-min-item-per-row-(\d+)/);
2661
2662                if(__maxItem && __maxItem[1] && portfolionumber > parseInt(__maxItem[1])){
2663                    portfolionumber = parseInt(__maxItem[1]);
2664                }
2665                if(__minItem && __minItem[1] && portfolionumber < parseInt(__minItem[1])){
2666                    portfolionumber = parseInt(__minItem[1]);
2667                }
2668            }
2669
2670            if( ww < 1024){
2671                portfolionumber = $isotope_container.data('md-col');
2672                $isotope_container.removeClass('cover-img-bg');
2673            }
2674            else{
2675                $isotope_container.addClass('cover-img-bg');
2676            }
2677            if( ww < 992){
2678                portfolionumber = $isotope_container.data('sm-col');
2679            }
2680            if( ww < 768){
2681                portfolionumber = $isotope_container.data('xs-col');
2682            }
2683            if( ww < 576){
2684                portfolionumber = $isotope_container.data('mb-col');
2685            }
2686
2687            var itemwidth = Math.floor(_container_width / portfolionumber),
2688                selector = $isotope_container.data('item_selector'),
2689                margin = parseInt($isotope_container.data('item_margin') || 0),
2690                dimension = parseFloat( _base_w / _base_h );
2691
2692            $( selector, $isotope_container ).each(function (idx) {
2693
2694                var thiswidth = parseFloat( $(this).data('width') || 1 ),
2695                    thisheight = parseFloat( $(this).data('height') || 1),
2696                    _css = {};
2697
2698                if (isNaN(thiswidth)) thiswidth = 1;
2699                if (isNaN(thisheight)) thisheight = 1;
2700
2701                if( ww < 1024){
2702                    thiswidth = thisheight = 1;
2703                }
2704
2705                _css.width = Math.floor((itemwidth * thiswidth) - (margin / 2));
2706                _css.height = Math.floor((itemwidth / dimension) * thisheight);
2707
2708                if( ww < 1024){
2709                    _css.height = 'auto';
2710                }
2711
2712                $(this).css(_css);
2713
2714            });
2715        });
2716
2717        var setup_masonry = function(){
2718
2719            $isotope_container.find('img[data-lazy-src!=""]').each(function(){
2720                $(this).attr('src', $(this).attr('data-lazy-src')).removeAttr('data-lazy-src');
2721            });
2722            if(!$isotope_container.hasClass('masonry__column-type-default')){
2723                configs.masonry.columnWidth = 1;
2724            }
2725            $isotope_container.isotope(configs);
2726            $isotope_container.on('layoutComplete', function(e){
2727                LA.ui.LazyLoadElementEffect(item_selector, $isotope_container);
2728            });
2729
2730            LA.utils.LazyLoad($('img,.la-lazyload-image',$isotope_container), {
2731                rootMargin: '0px',
2732                complete : function(){
2733                    $('.la-isotope-loading', $isotope_container).hide();
2734                    $isotope_container.addClass('loaded').isotope('layout');
2735                }
2736            }).observe();
2737
2738            $window.on('resize', function(e) {
2739                LA.utils.eventManager.publish('LA:AdvancedMasonry:calculatorItemWidth', [$isotope_container]);
2740            });
2741        };
2742
2743        return {
2744            init : function(){
2745                $('.la-isotope-loading', $isotope_container).show();
2746                LA.utils.eventManager.publish('LA:AdvancedMasonry:calculatorItemWidth', [$isotope_container]);
2747                if($.isFunction( $.fn.isotope )){
2748                    setup_masonry();
2749                }else{
2750                    LA.core.loadDependencies([ LA.core.path.plugins + 'jquery.isotope.pkgd.js'], setup_masonry );
2751                }
2752            }
2753        }
2754    };
2755
2756    LA.component.MasonryFilter = function(el){
2757
2758        var $this = $(el),
2759            options = ($this.data('isotope_option') || {}),
2760            $isotope = $($this.data('isotope_container'));
2761
2762
2763        var setup_filter = function(){
2764            $('li', $this).on('click', function (e) {
2765                e.preventDefault();
2766                var selector = $(this).attr('data-filter');
2767                $this.find('.active').removeClass('active');
2768
2769                if (selector != '*')
2770                    selector = '.' + selector;
2771                if ($isotope){
2772                    $isotope.isotope(
2773                        $.extend(options,{
2774                            filter: selector
2775                        })
2776                    );
2777                }
2778                $(this).addClass('active');
2779                $this.find('.la-toggle-filter').removeClass('active').text($(this).text());
2780            })
2781        };
2782
2783        return {
2784            init : function(){
2785                if($.isFunction( $.fn.isotope )){
2786                    setup_filter();
2787                }else{
2788                    LA.core.loadDependencies([ LA.core.path.plugins + 'jquery.isotope.pkgd.js'], setup_filter );
2789                }
2790            }
2791        }
2792    };
2793
2794    LA.component.CountUp = function(el){
2795        var $shortcode = $(el);
2796
2797        var init = function(){
2798            LA.utils.LazyLoad($shortcode, {
2799                load : function(){
2800                    if($.isFunction( $.fn.countup )){
2801                        init_countUp();
2802                    }else{
2803                        LA.core.loadDependencies([ LA.core.path.plugins + 'jquery.countUp.js'], init_countUp );
2804                    }
2805                }
2806            }).observe();
2807        };
2808
2809        var init_countUp = function(){
2810            var $this = $shortcode,
2811                $elm = $this.find('.stats-value');
2812
2813            var endNum = parseFloat($elm.data('counter-value'));
2814            var Num = $elm.data('counter-value') + ' ';
2815            var speed = parseInt($elm.data('speed'));
2816            var sep = $elm.data('separator');
2817            var dec = $elm.data('decimal');
2818            var dec_count = Num.split(".");
2819            var grouping = true;
2820            var prefix = endNum > 0 && endNum < 10 ? '0' : '';
2821
2822            if(dec_count[1]){
2823                dec_count = dec_count[1].length-1;
2824            }else{
2825                dec_count = 0;
2826            }
2827            if(sep == "none"){
2828                grouping = false;
2829            }else{
2830                grouping = true;
2831            }
2832            if(dec == "none"){
2833                dec = "";
2834            }
2835            $elm.countup({
2836                startVal: 0,
2837                endVal: endNum,
2838                decimals: dec_count,
2839                duration: speed,
2840                options: {
2841                    useEasing : true,
2842                    useGrouping : grouping,
2843                    separator : sep,
2844                    decimal : dec,
2845                    prefix: prefix
2846                }
2847            });
2848
2849        };
2850
2851        return {
2852            init : init
2853        }
2854    };
2855
2856    LA.component.CountDownTimer = function(el){
2857        var $shortcode = $(el);
2858
2859        var init_CountDownTimer = function(){
2860
2861            var $this = $shortcode.find('.elm-countdown-dateandtime'),
2862                t = new Date($this.html()),
2863                tfrmt = $this.data('countformat'),
2864                labels_new = $this.data('labels'),
2865                new_labels = labels_new.split(","),
2866                labels_new_2 = $this.data('labels2'),
2867                new_labels_2 = labels_new_2.split(",");
2868
2869            var server_time = new Date($this.data('time-now'));
2870
2871            var ticked = function (a){
2872                var $amount = $this.find('.countdown-amount'),
2873                    $period = $this.find('.countdown-period');
2874                $amount.css({
2875                    'color': $this.data('tick-col'),
2876                    'border-color':$this.data('br-color'),
2877                    'border-width':$this.data('br-size'),
2878                    'border-style':$this.data('br-style'),
2879                    'border-radius':$this.data('br-radius'),
2880                    'background':$this.data('bg-color'),
2881                    'padding':$this.data('padd')
2882                });
2883                $period.css({
2884                    'font-size':$this.data('tick-p-size'),
2885                    'color':$this.data('tick-p-col')
2886                });
2887
2888                if($this.data('tick-style')=='bold'){
2889                    $amount.css('font-weight','bold');
2890                }
2891                else if ($this.data('tick-style')=='italic'){
2892                    $amount.css('font-style','italic');
2893                }
2894                else if ($this.data('tick-style')=='boldnitalic'){
2895                    $amount.css('font-weight','bold');
2896                    $amount.css('font-style','italic');
2897                }
2898                if($this.data('tick-p-style')=='bold'){
2899                    $period.css('font-weight','bold');
2900                }
2901                else if ($this.data('tick-p-style')=='italic'){
2902                    $period.css('font-style','italic');
2903                }
2904                else if ($this.data('tick-p-style')=='boldnitalic'){
2905                    $period.css('font-weight','bold');
2906                    $period.css('font-style','italic');
2907                }
2908            };
2909
2910            if($this.hasClass('usrtz')){
2911                $this.countdown({labels: new_labels, labels1: new_labels_2, until : t, format: tfrmt, padZeroes:true,onTick:ticked});
2912            }else{
2913                $this.countdown({labels: new_labels, labels1: new_labels_2, until : t, format: tfrmt, padZeroes:true,onTick:ticked , serverSync:server_time});
2914            }
2915        };
2916
2917        return {
2918            init : function(){
2919                LA.utils.LazyLoad($shortcode, {
2920                    load : function(){
2921                        if($.isFunction( $.fn.countup )){
2922                            init_CountDownTimer();
2923                        }else{
2924                            LA.core.loadDependencies([ LA.core.path.plugins + 'jquery.countdown.js'], init_CountDownTimer );
2925                        }
2926                    }
2927                }).observe();
2928            }
2929        }
2930    };
2931
2932    LA.component.ParallaxRow = function(el){
2933
2934        var $elem = $(el);
2935        if( typeof window.el_vc_row_parallax_pos === "undefined" ){
2936            window.el_vc_row_parallax_pos = 0;
2937        }
2938
2939        window.el_vc_row_parallax_pos = window.el_vc_row_parallax_pos - 1;
2940
2941        $elem.css('z-index', window.el_vc_row_parallax_pos).attr('data-zindex', window.el_vc_row_parallax_pos);
2942
2943        var init = function(){
2944            if($.isFunction( $.fn.la_vc_row_parallax )){
2945                setup_parallax_row();
2946            }else{
2947                LA.core.loadDependencies([ LA.core.path.plugins + 'jquery.vc_row_parallax.js'], setup_parallax_row );
2948            }
2949        };
2950
2951        var setup_parallax_row = function(){
2952
2953            function findElementParentRow( el ){
2954                // find VC row
2955                var row = el.parentNode;
2956                while ( ! row.classList.contains('vc_row') && ! row.classList.contains('wpb_row') ) {
2957                    if ( row.tagName === 'HTML' ) {
2958                        row = false;
2959                        break;
2960                    }
2961                    row = row.parentNode;
2962                }
2963                if ( row !== false ) {
2964                    return row;
2965                }
2966
2967                // If vc_row & wpb_row have been removed/renamed, find a suitable row
2968                row = el.parentNode;
2969                var found = false;
2970                while ( ! found ) {
2971                    Array.prototype.forEach.call( row.classList, function(className, i) {
2972                        if ( found ) {
2973                            return;
2974                        }
2975                        if ( className.match(/row/g) ){
2976                            found = true;
2977                            return;
2978                        }
2979                    })
2980                    if ( found ) {
2981                        return row;
2982                    }
2983                    if ( row.tagName === 'HTML' ) {
2984                        break;
2985                    }
2986                    row = row.parentNode;
2987                }
2988
2989                // Last resort, return the immediate parent
2990                return el.parentNode;
2991            }
2992
2993            var $row_target =  $( findElementParentRow($elem[0]) );
2994
2995            $elem.la_vc_row_parallax({
2996                image: $elem.attr('data-bg-image'),
2997                direction: $elem.attr('data-direction'),
2998                mobileenabled: $elem.attr('data-mobile-enabled'),
2999                mobiledevice: LA.utils.isMobile(),
3000                opacity: $elem.attr('data-opacity'),
3001                width: $elem.attr('data-bg-width'),
3002                height: $elem.attr('data-bg-height'),
3003                velocity: $elem.attr('data-velocity'),
3004                align: $elem.attr('data-bg-align'),
3005                repeat: $elem.attr('data-bg-repeat'),
3006                repeatType: $elem.attr('data-bg-repeat-type'),
3007                zIndex: $elem.attr('data-zindex'),
3008                target: $row_target,
3009                id: $elem.attr('data-id') || '',
3010                removeOrig: false,
3011                complete: function() {
3012                    $row_target.addClass('la-parent-parallax-row');
3013                    $('.parallax-inner-' + this.id).addClass($elem.attr('class').replace('la_parallax_row js-el', ''));
3014                    $(window).trigger('la_vc_row_parallax:refresh');
3015                }
3016            })
3017        };
3018
3019        return {
3020            init : init
3021        }
3022    };
3023
3024    LA.component.GradientBackground = function(el){
3025
3026        return {
3027            init : function(){
3028                var selector = $(el),
3029                    grad = selector.data('grad'),
3030                    row = selector.next();
3031                grad = grad.replace('url(data:image/svg+xml;base64,','');
3032                var e_pos = grad.indexOf(';');
3033                grad = grad.substring(e_pos+1);
3034                row.attr('style', (typeof row.attr('style') !== "undefined" ? row.attr('style') : '') + grad);
3035                selector.remove();
3036            }
3037        }
3038    };
3039
3040    LA.component.AnimationBlock = function(el){
3041
3042        var $component = $(el),
3043            $childs = $component.find('>div:not(.la-animation-block):not([data-la_component]), >.vc_custom_heading'),
3044            animationName = $component.data('animate'),
3045            animationDuration = parseInt($component.data('animation-duration') || 0),
3046            animationIteration = parseInt($component.data('animation-iteration') || 1),
3047            animationDelay = parseFloat($component.data('animation-delay') || 0);
3048
3049        function renderTransitionAttribute( attributeName, value ) {
3050            var output = attributeName + ':' + value + ';';
3051            output += '-webkit-' + attributeName + ':' + value + ';';
3052            return output;
3053        }
3054
3055        function setUpEventForChilds(){
3056            var styleAttribute = 'opacity:0;';
3057            styleAttribute += renderTransitionAttribute('animation-duration', animationDuration + 's' );
3058            styleAttribute += renderTransitionAttribute('animation-iteration-count', animationIteration );
3059            var _idx2 = 0;
3060            $childs.each(function( idx, elm ){
3061                var $that = $(elm),
3062                    prev_style = $that.attr('style') || '',
3063                    new_style = '',
3064                    tmp_child_style = styleAttribute;
3065
3066                if(idx == 5){
3067                    _idx2 = 0;
3068                }
3069                tmp_child_style += renderTransitionAttribute('animation-delay', (animationDelay + parseFloat(_idx2 * 0.1)).toFixed(3) + 's' );
3070                if( prev_style.indexOf(tmp_child_style) == 0 ){
3071                    new_style = prev_style;
3072                }
3073                else {
3074                    new_style = tmp_child_style + prev_style;
3075                }
3076                $that.attr('style', new_style );
3077                _idx2++;
3078            });
3079
3080            LA.utils.LazyLoad( $childs, {
3081                rootMargin: '20px',
3082                load : function( child ){
3083                    $(child).css('opacity', '1').addClass('animated').addClass(animationName);
3084                }
3085            }).observe();
3086
3087        }
3088
3089        return {
3090            init : function(){
3091                if(false !== !!animationName) {
3092
3093                    setUpEventForChilds();
3094
3095                    LA.utils.LazyLoad( $component, {
3096                        rootMargin: '20px',
3097                        load : function () {
3098
3099                            var container_style = 'opacity:1;' + renderTransitionAttribute( 'animation-delay', animationDelay + 's' );
3100
3101                            if( $component.is('.wpb_wrapper') ) {
3102                                var $parent_column = $component.closest('.wpb_column'),
3103                                    parent_stype = $parent_column.attr('style') || '';
3104                                parent_stype = parent_stype.replace(/ /g,'');
3105                                if(parent_stype == 'opacity:0;'){
3106                                    if( parent_stype.indexOf(container_style) !== 0 ) {
3107                                        $parent_column.attr('style',container_style).css('opacity','1');
3108                                    }
3109                                }
3110                                $component.css('opacity','1');
3111                                $parent_column.addClass('animated').addClass(animationName);
3112                            }
3113                            else{
3114                                var p_st = $component.attr('style') || 'test';
3115                                p_st = p_st.replace(/ /g,'');
3116                                if(p_st == 'opacity:0;'){
3117                                    if( p_st.indexOf(container_style) !== 0 ) {
3118                                        $component.attr('style',container_style).css('opacity','1');
3119                                    }
3120                                }
3121                            }
3122                        }
3123                    }).observe();
3124                }
3125            }
3126        }
3127    };
3128
3129    LA.component.PieChart = function(el){
3130        var $shortcode = $(el);
3131
3132        var init = function(){
3133            LA.utils.LazyLoad($shortcode, {
3134                load : function(){
3135                    if ($.isFunction($.fn.countup)) {
3136                        init_PieChart();
3137                    } else {
3138                        LA.core.loadDependencies([LA.core.path.plugins + 'jquery.circle-progress.js'], init_PieChart);
3139                    }
3140                }
3141            }).observe();
3142        };
3143
3144        var init_PieChart = function(){
3145            var $this = $shortcode;
3146            if(false === !!$this.data('pie-init-success')){
3147                var value = $this.data('pie-value'),
3148                    color = $this.data('pie-color'),
3149                    unit  = $this.data('pie-units'),
3150                    emptyFill = $this.data('empty-fill'),
3151                    border = parseInt($this.data('stroke')),
3152                    size = $this.find('.sc-cp-canvas').innerHeight(),
3153                    $el_val = $this.find('.sc-cp-v');
3154                $this.find('.sc-cp-canvas').circleProgress({
3155                    value: parseFloat(value/100),
3156                    thickness: border,
3157                    emptyFill: emptyFill,
3158                    reverse: true,
3159                    lineCap: 'butt',
3160                    size: size,
3161                    startAngle: 0 - (Math.PI/2),
3162                    fill: {
3163                        color: color
3164                    }
3165                }).on('circle-animation-progress', function(event, progress, stepValue) {
3166                    $el_val.text( parseInt(100 * stepValue) + unit );
3167                });
3168                $this.data('pie-init-success','true');
3169            }
3170        };
3171
3172        return {
3173            init : init
3174        }
3175    };
3176
3177    LA.component.InstagramFeed = function(el){
3178        var $shortcode = $(el);
3179
3180        var init_feed = function(){
3181            var $this = $shortcode,
3182                _configs = $this.data('feed_config'),
3183                $target, feed_configs, feed;
3184            if(false === !!$this.data('appear-success')){
3185
3186                if($this.hasClass('loading')){
3187                    return;
3188                }
3189                $this.addClass('loading');
3190
3191                if( '' == la_theme_config.security.instagram_token ){
3192                    $this.addClass('loaded loaded-error');
3193                }
3194
3195                $target = $('.la-instagram-loop', $this);
3196
3197                var cache_key = '';
3198                for (var _k in _configs) {
3199                    if('template' == _k){
3200                        continue;
3201                    }
3202                    cache_key += '_';
3203                    cache_key += _configs[_k];
3204                }
3205                cache_key = LA.utils.sanitizeSlug(cache_key).replace(/\-+/, '_').replace(/\_\_+/g, '_').replace(/^_+/, '');
3206
3207                feed_configs = $.extend({
3208                    target: $target.get(0),
3209                    accessToken: la_theme_config.security.instagram_token,
3210                    filter: function(image) {
3211                        //image.created_time_ago = moment.unix(image.created_time).fromNow();
3212                        return true;
3213                    },
3214                    before: function(){
3215                        $target.html('');
3216                    },
3217                    success: function() {
3218                        if($target.hasClass('la-instagram-slider')){
3219                            $target.addClass('js-el la-slick-slider');
3220                            setTimeout(function(){
3221                                LA.core.initAll($this);
3222                            }, 200);
3223                        }
3224                        $this.removeClass('loading').addClass('loaded');
3225                    },
3226                    after: function(){
3227                        if(cache_key != ''){
3228                            try {
3229                                Cookies.set(cache_key, 'yes', { expires: 1/48 });
3230                                var $_html_cache = $target.clone();
3231                                if($target.hasClass('la-instagram-slider')){
3232                                    $_html_cache.find('.slick-list').remove();
3233                                }
3234                                sessionStorage.setItem(cache_key, $_html_cache.html());
3235                            }
3236                            catch (ex){
3237                                LA.utils.logger.set( 'Cannot set cache', 'Instafeed' , 'sessionStorage init error' );
3238                            }
3239                        }
3240                    }
3241                }, _configs);
3242
3243                try{
3244                    var _feedFormCache = sessionStorage.getItem(cache_key);
3245                    if(cache_key != '' && "undefined" !== typeof Cookies && Cookies.get(cache_key) == 'yes' && typeof _feedFormCache !== "undefined" && _feedFormCache != null ) {
3246                        $target.html(_feedFormCache);
3247                        feed_configs.success();
3248                    }
3249                    else{
3250                        feed = new Instafeed(feed_configs);
3251                        feed.run();
3252                    }
3253                }
3254                catch (ex){
3255                    $this.removeClass('loading').addClass('loaded loaded-error');
3256                    LA.utils.logger.set(ex, 'Instafeed' , 'Instafeed init error' );
3257                }
3258
3259                $this.attr('data-appear-success','true');
3260            }
3261
3262        };
3263
3264        return {
3265            init : function(){
3266                $(window).load(function(){
3267                    LA.utils.LazyLoad($shortcode, {
3268                        load : function(){
3269                            if($.isFunction( window.Instafeed )){
3270                                init_feed();
3271                            }else{
3272                                LA.core.loadDependencies([ LA.core.path.plugins + 'jquery.instafeed.js'], init_feed );
3273                            }
3274                        }
3275                    }).observe();
3276                })
3277            }
3278        }
3279    };
3280
3281    LA.component.tweetsFeed = function(el){
3282
3283        var $shortcode = $(el);
3284        var init_feed = function(){
3285            $shortcode.attr('id', 'la_tweets_' + LA.utils.randomID );
3286            var $this = $shortcode,
3287                widget_id = $this.attr('data-widget-id'),
3288                profile = $this.attr('data-profile'),
3289                count = $this.attr('data-amount');
3290
3291            var config = {
3292                "id": '',
3293                "profile": {"screenName": 'lastudioweb'},
3294                "dataOnly": true,
3295                "maxTweets": count,
3296                "customCallback": handleTweetCallback
3297            };
3298            if(widget_id){
3299                config.id = widget_id;
3300            }
3301            if(profile){
3302                config.profile = {"screenName": profile};
3303            }
3304
3305            function handleTweetCallback(tweets){
3306                var html = '';
3307                for (var i = 0, lgth = tweets.length; i < lgth ; i++) {
3308                    var tweetObject = tweets[i];
3309                    html += '<div class="tweet-feed-item">'
3310                        + '<div class="tweet-content">' + tweetObject.tweet + '</div>'
3311                        + '<div class="tweet-infos">
3311' + tweetObject.author + '</div>'
3312                        + '<div class="tweet-link"><a href="' + tweetObject.permalinkURL + '"><i class="fa fa-twitter"></i>' + tweetObject.time + '</a></div>'
3313                        + '</div>';
3314                }
3315                $this.html(html);
3316                $('.tweet-content a.link.customisable', $this).each(function(){
3317                    var $that = $(this);
3318                    $that.html($that.attr('href'));
3319                });
3320                if($this.parent('.twitter-feed').hasClass('tweets-slider')){
3321                    $this.slick({
3322                        arrows: false,
3323                        infinite: true,
3324                        autoplay: false,
3325                        autoplaySpeed: 5000,
3326                        adaptiveHeight: true,
3327                        speed: 1000,
3328                        rtl: LA.utils.isRTL()
3329                    })
3330                }
3331            }
3332
3333            twitterFetcher.fetch(config);
3334        };
3335
3336        return {
3337            init : function(){
3338                $(window).load(function(){
3339                    LA.utils.LazyLoad($shortcode, {
3340                        load : function(){
3341                            if( typeof twitterFetcher !== 'undefined'){
3342                                init_feed();
3343                            }
3344                            else{
3345                                LA.core.loadDependencies([ LA.core.path.plugins + 'jquery.twitterFetcher.js'], init_feed );
3346                            }
3347                        }
3348                    }).observe();
3349                })
3350            }
3351        }
3352    };
3353
3354    LA.component.InfiniteScroll = function(el){
3355
3356        var $this = $(el),
3357            itemSelector    = $this.data('item_selector'),
3358            curr_page       = $this.data('page_num'),
3359            max_page        = $this.data('page_num_max'),
3360            navSelector     = $this.data('navSelector') || ".la-pagination",
3361            nextSelector    = $this.data('nextSelector') || ".la-pagination a.next";
3362
3363        var default_options =  {
3364            navSelector  : navSelector,
3365            nextSelector : nextSelector,
3366            loading      : {
3367                finished: function(){
3368                    $('.la-infinite-loading', $this).remove();
3369                },
3370                msg: $("<div class='la-infinite-loading'><div class='la-loader spinner3'><div class='dot1'></div><div class='dot2'></div><div class='bounce1'></div><div class='bounce2'></div><div class='bounce3'></div></div></div>")
3371            }
3372        };
3373
3374        var setup_infinite = function(){
3375
3376            $this.parent().append('<div class="la-infinite-container-flag"></div>');
3377            default_options = $.extend( default_options, {
3378                itemSelector : itemSelector,
3379                state : {
3380                    currPage: curr_page
3381                },
3382                maxPage : max_page,
3383                debug : false
3384            });
3385            $this.infinitescroll(
3386                default_options,
3387                function(data) {
3388
3389                    var $data = $(data);
3390
3391                    if( $this.data('isotope') ){
3392                        $this.isotope('insert', $data.addClass('showmenow') );
3393                        if($.inArray('AdvancedMasonry', $this.data('la_component')) != -1){
3394                            LA.utils.eventManager.publish('LA:AdvancedMasonry:calculatorItemWidth', [$this]);
3395                            $this.isotope('layout');
3396                        }
3397                        $this.trigger('LA:Masonry:ajax_loadmore', [$this]);
3398                    }
3399                    else{
3400                        $data.each(function(idx){
3401                            if(idx == 0){
3402                                idx = 1;
3403                            }
3404                            $(this).css({
3405                                'animation-delay': (idx * 100) + 'ms',
3406                                '-webkit-animation-delay': (idx * 100) + 'ms'
3407                            });
3408                        });
3409                        $data.addClass('fadeInUp animated');
3410                    }
3411
3412                    LA.core.initAll($data);
3413                    LA.utils.LazyLoad($('.la-lazyload-image'), {rootMargin: '0px'}).observe();
3414
3415
3416                    if($.exists($masthead_aside_inner)){
3417                        setTimeout(function(){
3418                            $body.trigger("la_sticky:recalc");
3419                        },300);
3420                    }
3421
3422                    $('.la-infinite-loading', $this).remove();
3423
3424                    if($('.la-infinite-container-flag', $this.parent()).length){
3425                        var _offset = LA.utils.getOffset($('.la-infinite-container-flag', $this.parent()));
3426                        if(_offset.y  < window.innerHeight - 200){
3427                            $this.infinitescroll('retrieve');
3428                        }
3429                    }
3430
3431                    var __instance = $this.data('infinitescroll');
3432                    try{
3433                        $('.blog-main-loop__btn-loadmore').removeClass('loading');
3434                        if(max_page == __instance.options.state.currPage ){
3435                            $('.blog-main-loop__btn-loadmore').addClass('nothing-to-load');
3436                        }
3437                    }
3438                    catch (ex){
3439                        LA.utils.logger.set(ex, 'infinitescroll', 'error when call')
3440                    }
3441
3442                }
3443            );
3444            if( $this.hasClass('infinite-show-loadmore')){
3445                $this.infinitescroll('pause');
3446            }
3447            if($('.la-infinite-container-flag', $this.parent()).length){
3448                var _offset = LA.utils.getOffset($('.la-infinite-container-flag', $this.parent()));
3449                if(_offset.y < window.innerHeight - 200){
3450                    $this.infinitescroll('retrieve');
3451                }
3452            }
3453
3454            $(document).on('click', '.blog-main-loop__btn-loadmore a', function(e){
3455                e.preventDefault();
3456                if($(this).parent().hasClass('loading')){
3457                    return false;
3458                }
3459                else{
3460                    $(this).parent().addClass('loading');
3461                    $(this).parent().parent().find('.la-infinite-container').infinitescroll('retrieve');
3462                }
3463            });
3464        };
3465
3466        var init = function(){
3467            if($.isFunction( $.fn.infinitescroll )){
3468                setup_infinite();
3469            }
3470            else{
3471                LA.core.loadDependencies([ LA.core.path.plugins + 'jquery.infinitescroll.js'], setup_infinite );
3472            }
3473        };
3474
3475        return {
3476            init: init
3477        }
3478    };
3479
3480    LA.component.WooThreeSixty = function(el){
3481        var $shortcode = $(el);
3482
3483        if( $shortcode.data('woothreesixty_vars') == '') return;
3484
3485        var init = function(){
3486            if($.isFunction( $.fn.ThreeSixty )){
3487                init_threesixy();
3488            }else{
3489                LA.core.loadDependencies([ LA.core.path.plugins + 'jquery.threesixty.js'], init_threesixy );
3490            }
3491        };
3492
3493        var init_threesixy = function(){
3494            var opts = $shortcode.data('woothreesixty_vars');
3495            var woothreesixty_image_array = JSON.parse(opts.images);
3496            try {
3497                var $threesixy_instance = $shortcode.ThreeSixty({
3498                    totalFrames : woothreesixty_image_array.length,
3499                    currentFrame: 1,
3500                    endFrame    : woothreesixty_image_array.length,
3501                    framerate   : opts.framerate,
3502                    playSpeed   : opts.playspeed,
3503                    imgList     : '.threesixty_images',
3504                    progress    : '.spinner',
3505                    filePrefix  : '',
3506                    height      : opts.height,
3507                    width       : opts.width,
3508                    navigation  : opts.navigation,
3509                    imgArray    : woothreesixty_image_array,
3510                    responsive  : opts.responsive,
3511                    drag        : opts.drag,
3512                    disableSpin : opts.spin
3513                });
3514                LA.utils.eventManager.publish('LA:WooThreeSixty', [$threesixy_instance, $shortcode]);
3515            }catch (ex){
3516                LA.utils.logger.display(ex);
3517            }
3518        };
3519
3520        return {
3521            init : init
3522        }
3523
3524    };
3525
3526    LA.component.InlineSVG = function(el){
3527        var $this = $(el),
3528            _settings = $this.data(),
3529            _type     = _settings.type ? _settings.type : 'oneByOne',
3530            _duration = _settings.duration ? _settings.duration : 150,
3531            _options  = {
3532                type: _type,
3533                duration: _duration,
3534                file: _settings.svg
3535            };
3536
3537        var setup_vius = function(){
3538            var _vivus = new Vivus( $this[0], _options );
3539            if (_settings.hover && $(_settings.hover).hasClass('active-svg-effect')){
3540                $(_settings.hover)
3541                    .on('mouseenter', function(){
3542                        _vivus.stop()
3543                            .reset()
3544                            .play( 2 );
3545                    })
3546                    .on('mouseleave', function(){
3547                        _vivus.finish();
3548                    })
3549            }
3550        };
3551
3552        return {
3553            init : function(){
3554                if(typeof Vivus === 'undefined'){
3555                    LA.core.loadDependencies([ LA.core.path.plugins + 'vivus.js'], setup_vius );
3556                }
3557                else{
3558                    setup_vius();
3559                }
3560            }
3561        }
3562    };
3563
3564    LA.component.HotSpotImages = function(el){
3565        var $this = $(el),
3566            tooltip_func = $this.data('tooltip-func');
3567        var init = function(){
3568
3569            $('> img', $(el)).on('click', function(e){
3570                $(el).find('.hotspot__item.open,.nttip.open').removeClass('open');
3571            });
3572
3573            if( tooltip_func == 'hover' ) {
3574
3575                $('.la_hotspot_wrap', $(el))
3576                    .on('mouseenter', function(e){
3577                        if($window.width() > 1024){
3578                            $(this).find('>.hotspot__item,>.nttip').addClass('open');
3579                        }
3580                    })
3581                    .on('mouseleave', function(e){
3582                        if($window.width() > 1024){
3583                            $(this).find('>.hotspot__item,>.nttip').removeClass('open');
3584                        }
3585                    })
3586            }
3587
3588            $('.la_hotspot_wrap', $(el)).on('click', function(e){
3589                e.preventDefault();
3590                $(this).siblings('.la_hotspot_wrap').find('>.hotspot__item,>.nttip').removeClass('open');
3591                if( $(e.target).is('.tipclose') || $(e.target).parent().is('.tipclose') ){
3592                    $(this).find('>.hotspot__item,>.nttip').removeClass('open');
3593                }
3594                else{
3595                    $(this).find('>.hotspot__item,>.nttip').addClass('open');
3596                }
3597            });
3598
3599            $('.tipclose', $(el)).on('click', function(e){
3600                e.preventDefault();
3601                $(this).closest('.la_hotspot_wrap').find('>.hotspot__item,>.nttip').removeClass('open');
3602            });
3603
3604            LA.utils.LazyLoad($('.la_hotspot_wrap', $(el)), {
3605                load : function(elem){
3606                    $(elem).addClass('animated-in');
3607                }
3608            }).observe();
3609        }
3610
3611        return {
3612            init: init
3613        }
3614
3615    };
3616
3617    LA.core.MegaMenu = function(){
3618
3619        function fix_megamenu_position( $elem, $container, container_width, isVerticalMenu) {
3620
3621            if($('.megamenu-inited', $elem).length){
3622                return false;
3623            }
3624
3625            var $popup = $('> .sub-menu', $elem);
3626
3627            if ($popup.length == 0) return;
3628            var megamenu_width = $popup.outerWidth();
3629
3630            if (megamenu_width > container_width) {
3631                megamenu_width = container_width;
3632            }
3633            if (!isVerticalMenu) {
3634
3635                // if(containerClass == 'body.zuka-body'){
3636                //     $popup.css('left', 0 - $elem.offset().left).css('left');
3637                //     return;
3638                // }
3639
3640                var container_padding_left = parseInt($container.css('padding-left')),
3641                    container_padding_right = parseInt($container.css('padding-right')),
3642                    parent_width = $popup.parent().outerWidth(),
3643                    left = 0,
3644                    container_offset = LA.utils.getOffset($container),
3645                    megamenu_offset = LA.utils.getOffset($popup);
3646
3647                if (megamenu_width > parent_width) {
3648                    left = -(megamenu_width - parent_width) / 2;
3649                }
3650                else{
3651                    left = 0
3652                }
3653
3654                if ((megamenu_offset.x - container_offset.x - container_padding_left + left) < 0) {
3655                    left = -(megamenu_offset.x - container_offset.x - container_padding_left);
3656                }
3657                if ((megamenu_offset.x + megamenu_width + left) > (container_offset.x + $container.outerWidth() - container_padding_right)) {
3658                    left -= (megamenu_offset.x + megamenu_width + left) - (container_offset.x + $container.outerWidth() - container_padding_right);
3659                }
3660                $popup.css('left', left).css('left');
3661            }
3662
3663            if (isVerticalMenu) {
3664                var clientHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
3665                    itemOffset = $popup.offset(),
3666                    itemHeight = $popup.outerHeight(),
3667                    scrollTop = $window.scrollTop();
3668                if (itemOffset.top - scrollTop + itemHeight > clientHeight) {
3669                    $popup.css({top: clientHeight - itemOffset.top + scrollTop - itemHeight - 20});
3670                }
3671            }
3672
3673            $popup.addClass('megamenu-inited');
3674
3675        }
3676
3677        function fix_com_submenu_position( $elem, containerClass, container_width) {
3678            if($('.submenu-inited', $elem).length){
3679                return false;
3680            }
3681
3682            var $popup = $('> .menu', $elem);
3683
3684            if ($popup.length == 0) return;
3685            var megamenu_width = $popup.outerWidth();
3686
3687            if (megamenu_width > container_width) {
3688                megamenu_width = container_width;
3689            }
3690            var $container = $(containerClass),
3691                container_padding_left = parseInt($container.css('padding-left')),
3692                container_padding_right = parseInt($container.css('padding-right')),
3693                parent_width = $popup.parent().outerWidth(),
3694                left = 0,
3695                container_offset = LA.utils.getOffset($container),
3696                megamenu_offset = LA.utils.getOffset($popup);
3697
3698            if (megamenu_width > parent_width) {
3699                left = -(megamenu_width - parent_width) / 2;
3700            }else{
3701                left = 0
3702            }
3703
3704            if ((megamenu_offset.x - container_offset.x - container_padding_left + left) < 0) {
3705                left = -(megamenu_offset.x - container_offset.x - container_padding_left);
3706            }
3707            if ((megamenu_offset.x + megamenu_width + left) > (container_offset.x + $container.outerWidth() - container_padding_right)) {
3708                left -= (megamenu_offset.x + megamenu_width + left) - (container_offset.x + $container.outerWidth() - container_padding_right);
3709            }
3710            $popup.css('left', left).css('left');
3711            $popup.addClass('submenu-inited');
3712        }
3713
3714
3715        LA.utils.eventManager.subscribe('LA:MegaMenu:ComponentSubMenuPosition', function(e, $menu_item, containerClass, container_width){
3716            if($.exists($menu_item)){
3717                $menu_item.each(function(){
3718                    $('>.menu', $(this)).removeAttr('style');
3719                    $('>.menu.submenu-inited', $(this)).removeClass('submenu-inited');
3720                    fix_com_submenu_position( $(this), containerClass , container_width);
3721                })
3722            }
3723        });
3724
3725
3726        LA.utils.eventManager.publish('LA:MegaMenu:ComponentSubMenuPosition', [$('.header-top-elements .la_com_action--dropdownmenu'), '.header-top-elements', $('.header-top-elements').width()]);
3727        LA.utils.eventManager.publish('LA:MegaMenu:ComponentSubMenuPosition', [$('.header-main .la_com_action--dropdownmenu'), '.header-main', $('.header-main').width()]);
3728        LA.utils.eventManager.publish('LA:MegaMenu:ComponentSubMenuPosition', [$('.site-header-mobile .la_com_action--dropdownmenu'), '.site-header-mobile', $('.site-header-mobile').width()]);
3729
3730
3731        LA.utils.eventManager.subscribe('LA:MegaMenuBuilder:MenuPosition', function(e, $megamenu){
3732            if($.exists($megamenu)){
3733
3734                $megamenu.closest('.lahfb-content-wrap').addClass('position-relative');
3735
3736                $megamenu.each(function(){
3737                    var _that = $(this),
3738                        $container = _that.closest('.lahfb-content-wrap'),
3739                        container_width = $container.width(),
3740                        isVerticalMenu = false;
3741
3742                    $('li.mega .megamenu-inited', _that).removeClass('megamenu-inited');
3743
3744                    $('li.mega > .sub-menu', _that).removeAttr('style');
3745
3746                    $('li.mega', _that).each(function(){
3747                        var $menu_item = $(this),
3748                            $popup = $('> .sub-menu', $menu_item),
3749                            $inner_popup = $('> .sub-menu > .mm-mega-li', $menu_item),
3750                            item_max_width = parseInt(!!$inner_popup.data('maxWidth') ? $inner_popup.data('maxWidth') : $inner_popup.css('maxWidth')),
3751                            $_container = $container;
3752
3753                        var default_width = 1920;
3754
3755                        if(container_width < default_width){
3756                            default_width = container_width;
3757                        }
3758
3759                        if(default_width > item_max_width){
3760                            default_width = parseInt(item_max_width);
3761                        }
3762
3763                        if( $menu_item.hasClass('mm-popup-force-fullwidth')){
3764                            $inner_popup.data('maxWidth', item_max_width).css('maxWidth', 'none');
3765                            $('> ul', $inner_popup).css('width', item_max_width);
3766                            if(!isVerticalMenu){
3767                                default_width = $window.width();
3768                                $_container = $('body.zuka-body');
3769                            }
3770                            else{
3771                                default_width = $('#page.site > .site-inner').width();
3772                            }
3773                        }
3774                        $popup.width(default_width);
3775                        fix_megamenu_position( $menu_item, $_container, container_width, isVerticalMenu);
3776                    });
3777                })
3778            }
3779        });
3780
3781
3782        LA.utils.eventManager.publish('LA:MegaMenuBuilder:MenuPosition', [ $('.lahfb-nav-wrap.has-megamenu') ]);
3783
3784        $window.on('resize', function(){
3785
3786            LA.utils.eventManager.publish('LA:MegaMenuBuilder:MenuPosition', [ $('.lahfb-nav-wrap.has-megamenu') ]);
3787
3788            LA.utils.eventManager.publish('LA:MegaMenu:ComponentSubMenuPosition', [$('.header-top-elements .la_com_action--dropdownmenu'), '.header-top-elements', $('.header-top-elements').width()]);
3789            LA.utils.eventManager.publish('LA:MegaMenu:ComponentSubMenuPosition', [$('.site-header-mobile .la_com_action--dropdownmenu'), '.site-header-mobile', $('.site-header-mobile').width()]);
3790            LA.utils.eventManager.publish('LA:MegaMenu:ComponentSubMenuPosition', [$('.header-main .la_com_action--dropdownmenu'), '.header-main', $('.header-main').width()]);
3791        });
3792
3793
3794        function helper_init_dlmenu($menu, opts){
3795            $menu.find('> .dl-menu > div > ul > li').unwrap().unwrap();
3796            $menu.find('.sub-menu, ul.children').addClass('dl-submenu');
3797            $menu.dlmenu($.extend({
3798                backLabel: la_theme_config.i18n.backtext,
3799                animationClasses : LA.ui.MobileMenuEffect()
3800            }, opts))
3801        }
3802
3803        var init_dlmenu = function(){
3804            helper_init_dlmenu($('#la_mobile_nav'), {});
3805            if($('#la_dlmenu_main').length){
3806                helper_init_dlmenu($('#la_dlmenu_main'), {
3807                    animationClasses: {
3808                        classin : 'dl-animate-in-2',
3809                        classout : 'dl-animate-out-2'
3810                    }
3811                });
3812            }
3813        }
3814
3815        var Init = function(){
3816            if($.isFunction($.fn.dlmenu)){
3817                init_dlmenu();
3818            }else{
3819                LA.core.loadDependencies([LA.core.path.plugins + 'jquery.dlmenu.js'], init_dlmenu);
3820            }
3821        };
3822
3823        Init();
3824
3825        $document.on('click', 'html.support-touch-click .mega-menu > li.menu-item-has-children > a', function(e){
3826            $(this).parent().siblings().removeClass('go-go');
3827            if(!$(this).parent().hasClass('go-go')){
3828                e.preventDefault();
3829                $(this).parent().addClass('go-go');
3830            }
3831        })
3832    };
3833
3834    LA.core.SitePreload = function(){
3835        setTimeout(function(){
3836            $body.removeClass('site-loading');
3837        }, 500);
3838        $window.load(function(){
3839            $body.removeClass('site-loading');
3840        });
3841        $window.on('beforeunload', function(e){
3842            if(LA.utils.browser.name != 'safari'){
3843                if( typeof window['hack_beforeunload_time'] === "undefined" || ( typeof window['hack_beforeunload_time'] !== "undefined" && e.t
3843imeStamp - window['hack_beforeunload_time'] > 1000 ) ) {
3844                    $('#page.site').css('opacity', '0');
3845                    $body.addClass('site-loading');
3846                }
3847            }
3848        });
3849        $(document).on('click', 'a[href^="tel:"], a[href^="mailto:"], a[href^="callto"], a[href^="skype"], a[href^="whatsapp"]', function(e){
3850            window['hack_beforeunload_time'] = parseInt(e.timeStamp);
3851        });
3852        $window.on('pageshow', function(e){
3853            if (e.originalEvent.persisted) {
3854                $body.removeClass('site-loading');
3855            }
3856        });
3857
3858        LA.utils.LazyLoad($('.la-lazyload-image'), {rootMargin: '0px'}).observe();
3859
3860        LA.utils.eventManager.subscribe('LA:Component:LazyLoadImage', function(e, $container){
3861            $container.find('img[data-lazy-src], img[data-lazy-original]').each(function(idx, img){
3862                var srcset = img.getAttribute('data-lazy-srcset'),
3863                    sizes = img.getAttribute('data-lazy-sizes'),
3864                    src = img.getAttribute('data-lazy-src') || img.getAttribute('data-lazy-original');
3865                if(srcset){
3866                    img.setAttribute('srcset', srcset);
3867                }
3868                if(sizes){
3869                    img.setAttribute('sizes', sizes);
3870                }
3871                if(src){
3872                    img.setAttribute('src', src);
3873                }
3874                $(img).removeClass('lazyload');
3875            })
3876        });
3877    };
3878
3879    LA.core.FixVCRowFullWidth = function() {
3880
3881        if(!LA.utils.isActiveVC()) return;
3882
3883        $('.la-shortcode-maps').each(function(){
3884            $(this).closest('.wpb_wrapper').height('100%');
3885        });
3886        $window.on('load resize',function(){
3887            var $maps = $('.map-full-height');
3888            $maps.css('height',$maps.closest('.vc_column-inner ').height());
3889        });
3890
3891        var $page = $('#main.site-main');
3892
3893        $document.on('vc-full-width-row', function(e) {
3894
3895            for (var i = 1; i < arguments.length; i++) {
3896                var $el = $(arguments[i]);
3897                $el.addClass('vc_hidden');
3898                var $el_full = $el.next('.vc_row-full-width');
3899                $el_full.length || ($el_full = $el.parent().next('.vc_row-full-width'));
3900                var el_margin_left = parseInt($el.css("margin-left"), 10),
3901                    el_margin_right = parseInt($el.css("margin-right"), 10),
3902                    offset = 0 - $el_full.offset().left - el_margin_left + $page.offset().left + parseInt($page.css('padding-left')),
3903                    width = $page.width();
3904
3905                var el_max_width = parseInt($el.css('maxWidth'));
3906
3907                if(el_max_width > 0 && el_max_width < width){
3908                    if(offset < 0){
3909                        offset = offset + (width - el_max_width)/2;
3910                    }
3911                    width = el_max_width;
3912                }
3913                if ($el.css({
3914                        position: "relative",
3915                        left: offset,
3916                        "box-sizing": "border-box",
3917                        width: width
3918                    }), !$el.data("vcStretchContent")) {
3919                    var padding = -1 * offset;
3920                    0 > padding && (padding = 0);
3921                    var paddingRight = width - padding - $el_full.width() + el_margin_left + el_margin_right;
3922                    0 > paddingRight && (paddingRight = 0), $el.css({
3923                        "padding-left": padding + "px",
3924                        "padding-right": paddingRight + "px"
3925                    })
3926                }
3927                if($.exists($el.find('[data-la_component="AdvancedMasonry"]'))){
3928                    var $advanceMasonry = $el.find('[data-la_component="AdvancedMasonry"]');
3929
3930                    $advanceMasonry.each(function(){
3931                        if(false === !!$(this).data('data-advancedmasonry-setwidth')){
3932                            LA.utils.eventManager.publish('LA:AdvancedMasonry:calculatorItemWidth', [$(this)]);
3933                            $(this).attr('data-advancedmasonry-setwidth', true);
3934                        }
3935                    })
3936                }
3937                $el.attr('data-vc-full-width-init', 'true');
3938                $el.addClass('vc-has-modified').removeClass('vc_hidden');
3939            }
3940        });
3941
3942        if(typeof vc_js === "undefined"){
3943            $window.on('load resize', function(){
3944                $document.trigger('vc-full-width-row',$('[data-vc-full-width="true"]'));
3945            });
3946        }
3947        else{
3948            $document.trigger('vc-full-width-row',$('[data-vc-full-width="true"]'));
3949        }
3950
3951        function fix_rtl_fullWidth(){
3952            var $elements = $('[data-vc-full-width="true"]');
3953            $.each($elements, function () {
3954                var $el = $(this);
3955                $el.css('right', $el.css('left')).css('left', '');
3956            });
3957        }
3958
3959        if(LA.utils.isRTL()){
3960            // Fixes rows in RTL
3961            $document.on('vc-full-width-row', function () {
3962                fix_rtl_fullWidth();
3963            });
3964            fix_rtl_fullWidth();
3965        }
3966    };
3967
3968    LA.core.ElementAjaxClickEvent = function(){
3969        $document
3970            .on('click', '.elm-loadmore-ajax a', function(e){
3971                e.preventDefault();
3972                var $this = $(this).closest('.elm-loadmore-ajax');
3973                if($this.hasClass('is-loading')){
3974                    return;
3975                }
3976                var $container = $($this.data('container')),
3977                    elem = $this.data('item-class'),
3978                    query = $this.data('query-settings'),
3979                    request_url = $this.data('request'),
3980                    nonce = $this.data('public-nonce'),
3981                    paged = parseInt($this.data('paged')),
3982                    max_page = parseInt($this.data('max-page')),
3983                    requestData;
3984                if(paged < max_page){
3985                    query.atts.paged = paged + 1;
3986                    requestData = {
3987                        action : 'la_get_shortcode_loader_by_ajax',
3988                        tag : query.tag,
3989                        data : query,
3990                        _vcnonce : nonce
3991                    };
3992                    $this.addClass('is-loading');
3993
3994                    var _ajax_option = {
3995                        url : request_url,
3996                        method: "POST",
3997                        dataType: "html",
3998                        data : requestData,
3999                        cache: false,
4000                        ajax_request_id: {
4001                            container : $this.data('container'),
4002                            paged: query.atts.paged
4003                        }
4004                    };
4005
4006                    $.ajax( _ajax_option ).done(function(response_data){
4007
4008                        var $data = $(response_data).find(elem);
4009
4010                        if($container.hasClass('la-slick-slider')) {
4011                            $container.slick('slickAdd', $data);
4012                            $container.slick('setPosition');
4013                        }
4014                        else if( $container.hasClass('la-isotope-container') ){
4015                            $container.isotope('insert', $data.addClass('showmenow') );
4016                            if( $container.data('la_component') == 'AdvancedMasonry' ) {
4017                                LA.utils.eventManager.publish('LA:AdvancedMasonry:calculatorItemWidth', [$container]);
4018                                $container.isotope('layout');
4019                            }
4020                            $container.trigger('LA:Masonry:ajax_loadmore', [$container]);
4021                        }
4022                        else{
4023                            $data.addClass('fadeIn animated').appendTo($container);
4024                        }
4025
4026                        LA.core.initAll($data);
4027
4028                        LA.utils.LazyLoad($('.la-lazyload-image'), {rootMargin: '0px'}).observe();
4029
4030                        if($.exists($masthead_aside_inner)){
4031                            setTimeout(function(){
4032                                $body.trigger("la_sticky:recalc");
4033                            },300);
4034                        }
4035
4036                        $this.data('paged', paged + 1);
4037                        $this.removeClass('is-loading');
4038                        if( max_page === paged + 1 ){
4039                            $this.addClass('hide');
4040                        }
4041
4042                    });
4043                }
4044            })
4045            .on('click', '.elm-pagination-ajax a', function(e){
4046                e.preventDefault();
4047                if($(this).closest('.elm-pagination-ajax').hasClass('is-loading')){
4048                    return;
4049                }
4050                var $this = $(this),
4051                    $parent = $this.closest('.elm-pagination-ajax'),
4052                    $container = $($parent.data('container')),
4053                    $parent_container = $parent.data('parent-container') ? $($parent.data('parent-container')) : false,
4054                    elem = $parent.data('item-class'),
4055                    query = $parent.data('query-settings'),
4056                    request_url = $parent.data('request'),
4057                    nonce = $parent.data('public-nonce'),
4058                    paged = parseInt(LA.utils.getUrlParameter('la_paged', $this.attr('href'))),
4059                    appendType = $parent.data('append-type'),
4060                    requestData;
4061                if(paged > 0){
4062                    query.atts.paged = paged;
4063                    requestData = {
4064                        action : 'la_get_shortcode_loader_by_ajax',
4065                        tag : query.tag,
4066                        data : query,
4067                        _vcnonce : nonce
4068                    };
4069                    $parent.addClass('is-loading');
4070
4071                    var _ajax_option = {
4072                        url : request_url,
4073                        method: "POST",
4074                        dataType: "html",
4075                        data : requestData,
4076                        cache: true,
4077                        ajax_request_id: {
4078                            container : $parent.data('parent-container') ? $parent.data('parent-container') : false,
4079                            paged: paged
4080                        }
4081                    }
4082
4083                    $.ajax( _ajax_option ).done(function(response_data, status, jq){
4084
4085                        var $data = $(response_data).find(elem);
4086                        if($container.hasClass('la-slick-slider')) {
4087                            $container.slick('unslick').removeData('initAutoCarousel');
4088                            $data.appendTo($container.empty());
4089                        }
4090                        else if( $container.data('isotope') ){
4091
4092                            $container.isotope('remove', $container.isotope('getItemElements'));
4093                            $container.isotope('insert', $data.addClass('showmenow'));
4094                            if( $container.data('la_component') == 'AdvancedMasonry' ) {
4095                                LA.utils.eventManager.publish('LA:AdvancedMasonry:calculatorItemWidth', [$container]);
4096                                $container.isotope('layout');
4097                            }
4098                            else{
4099                                setTimeout(function(){
4100                                    $container.isotope('layout');
4101                                }, 400);
4102                            }
4103
4104                            $container.trigger('LA:Masonry:ajax_pagination', [$container]);
4105                        }
4106                        else{
4107                            $data.addClass('fadeIn animated');
4108                            $data.appendTo($container.empty());
4109                        }
4110
4111                        LA.core.initAll($parent_container ? $parent_container : $container);
4112
4113                        LA.utils.LazyLoad($('.la-lazyload-image'), {rootMargin: '0px'}).observe();
4114
4115                        $parent.removeClass('is-loading');
4116
4117                        $parent.find('.la-pagination').html($(response_data).find('.la-pagination').html());
4118                    });
4119                }
4120            })
4121
4122            .on('click', '.la-favorite-link a', function(e){
4123                e.preventDefault();
4124                var $this = $(this),
4125                    post_id = $this.data('favorite_id');
4126                if(!$this.hasClass('loading') && !$this.hasClass('exists')){
4127
4128                    var $el_exists = $('a[data-favorite_id="'+post_id+'"]');
4129                    $el_exists.addClass('loading');
4130
4131                    $.ajax({
4132                        url : LA.core.path.ajaxUrl,
4133                        method: "POST",
4134                        dataType: "json",
4135                        data : {
4136                            'action' : 'la_helpers_favorite',
4137                            'type' : $this.hasClass('added') ? 'remove' : 'add',
4138                            'post_id' : post_id,
4139                            'security' : LA.core.path.security.favorite_posts
4140                        }
4141                    }).done(function( response ){
4142                            $el_exists.removeClass('loading');
4143                            if(response.success){
4144                                if($this.hasClass('added')){
4145                                    $el_exists.removeClass('added exists');
4146                                }
4147                                else{
4148                                    $el_exists.addClass('added exists');
4149                                }
4150                                $el_exists.find('.favorite_count').html(response.data.count);
4151                            }
4152                        })
4153                        .fail(function() {
4154                            $el_exists.removeClass('loading');
4155                        })
4156                }
4157            })
4158    };
4159
4160    LA.core.ElementClickEvent = function(){
4161
4162
4163        /**
4164         * Access Component Action
4165         */
4166
4167        $document
4168            .on('click', '.la_com_action--searchbox.searchbox__01 .component-target', function(e){
4169                e.preventDefault();
4170                $body.addClass('open-search-form');
4171                setTimeout(function(){
4172                    $('.searchform-fly .search-field').focus();
4173                }, 600);
4174            })
4175            .on('click', '.la_com_action--aside_header .component-target,.btn-aside-toggle', function(e){
4176                e.preventDefault();
4177                if($.exists($('.header--menu-burger'))){
4178                    $body.removeClass('open-header-aside');
4179                    $body.toggleClass('open-burger-menu');
4180                }else{
4181                    $body.removeClass('open-burger-menu');
4182                    $body.toggleClass('open-header-aside');
4183                }
4184            })
4185            .on('click', '.btn-close-search', function(e){
4186                e.preventDefault();
4187                $body.removeClass('open-search-form');
4188            })
4189        ;
4190
4191        /**
4192         * Mobile Menu Trigger
4193         */
4194        $document
4195            .on('click', '.site-header-mobile .la_com_action--primary-menu', function(e){
4196                e.preventDefault();
4197                $(this).toggleClass('active');
4198                $body.toggleClass('open-mobile-menu');
4199            })
4200            .on('touchend click', '.la-overlay-global,.header-aside-overlay', function(e){
4201                e.preventDefault();
4202                $('.la_com_action--primary-menu,.la_com_action--dropdownmenu').removeClass('active');
4203                $body.removeClass('open-aside open-search-form open-cart-aside open-mobile-menu open-advanced-shop-filter open-header-aside open-master-aside open-overlay open-burger-menu');
4204            })
4205            .on('touchend click', '.site-main,.section-page-header', function(e){
4206                $('.site-header-mobile .la_com_action--primary-menu').removeClass('active');
4207                $body.removeClass('open-mobile-menu');
4208            })
4209            .on('click', '.footer-handheld-footer-bar .la_com_action--dropdownmenu .component-target', function(e){
4210                e.preventDefault();
4211                var $_parent = $(this).parent();
4212                $body.removeClass('open-mobile-menu open-search-form');
4213                if($_parent.hasClass('active')){
4214                    $_parent.removeClass('active');
4215                    $body.removeClass('open-overlay');
4216                }else{
4217                    $_parent.addClass('active');
4218                    $_parent.siblings().removeClass('active');
4219                    $body.addClass('open-overlay');
4220                }
4221            })
4222            .on('click', '.footer-handheld-footer-bar .la_com_action--searchbox', function(e){
4223                e.preventDefault();
4224                var $this = $(this);
4225                if($this.hasClass('active')){
4226                    $body.removeClass('open-mobile-menu open-search-form');
4227                    $this.removeClass('active');
4228                }else{
4229                    $body.addClass('open-search-form');
4230                    $this.addClass('active');
4231                    $this.siblings().removeClass('active');
4232                    $body.removeClass('open-overlay');
4233                }
4234            })
4235        ;
4236
4237        /** Back To Top **/
4238        $window.on('load scroll', function(){
4239            if($window.scrollTop() > $window.height() + 100){
4240                $('.backtotop-container').addClass('show');
4241            }else{
4242                $('.backtotop-container').removeClass('show');
4243            }
4244        })
4245        $document.on('click', '.btn-backtotop', function(e){
4246            e.preventDefault();
4247            $htmlbody.animate({
4248                scrollTop: 0
4249            }, 800)
4250        })
4251
4252        /** Other Element **/
4253        $document
4254            .on('click', '.la-popup:not(.wpb_single_image), .banner-video .banner--link-overlay, .la-popup.wpb_single_image a,.la-popup-slideshow', function(e){
4255                e.preventDefault();
4256                var $that = $(this);
4257                var init_auto_popup = function(){
4258                    lightcase.start({
4259                        href: $that.attr('href'),
4260                        showTitle: false,
4261                        showCaption: false,
4262                        maxWidth: $window.width(),
4263                        maxHeight: $window.height(),
4264                        iframe:{
4265                            width:1280,
4266                            height:720
4267                        },
4268                        onFinish: {
4269                            createOverlay: function () {
4270                                lightcase.get('content').append('<div class="custom-lightcase-overlay"></div>');
4271                                lightcase.get('contentInner').append('<a class="custom-lighcase-btn-close" href="#"><i class="dl-icon-close"></i></a>');
4272                            }
4273                        },
4274                        onClose : {
4275                            qux : function(){
4276                                $('.custom-lightcase-overlay').remove();
4277                                $('.custom-lighcase-btn-close').remove();
4278                            }
4279                        }
4280                    });
4281                }
4282                if($.fn.lightcase){
4283                    init_auto_popup();
4284                }else{
4285                    LA.core.loadDependencies([ LA.core.path.plugins + 'jquery.lightcase.js'], init_auto_popup )
4286                }
4287            })
4288            .on('click', '.custom-lighcase-btn-close, .popup-button-continue, .custom-lightcase-overlay', function(e){
4289                e.preventDefault();
4290                try{
4291                    lightcase.close();
4292                }catch (ex){}
4293            })
4294            .on('click', '.vc_message_box > .close-button', function(e){
4295                e.preventDefault();
4296                var _this = $(this),
4297                    _parent = _this.closest('.vc_message_box');
4298                _parent.slideUp(300);
4299            })
4300    };
4301
4302    LA.core.FullPageJs = function(){
4303
4304        function FPsetSectionAnimation($from, $to, direction){
4305
4306            var from_idx = $from.index(),
4307                to_idx = $to.index(),
4308                _tmp;
4309            if(from_idx > to_idx){
4310                _tmp = to_idx;
4311                to_idx = from_idx;
4312                from_idx = _tmp;
4313            }
4314            if( 'up' == direction ) {
4315                $('>.fp-tableCell', $from).removeClass('go-down is-active').addClass('go-up');
4316                if( (to_idx - from_idx) > 1 ) {
4317                    $('>.fp-tableCell', $('.vc_section.la_fp_section').slice(from_idx, to_idx)).removeClass('go-down').addClass('go-up');
4318                }
4319            }else{
4320                $('>.fp-tableCell', $from).removeClass('go-up is-active').addClass('go-down');
4321                if( (to_idx - from_idx) > 1 ) {
4322                    $('>.fp-tableCell', $('.vc_section.la_fp_section').slice(from_idx, to_idx)).removeClass('go-up').addClass('go-down');
4323                }
4324            }
4325
4326            $('>.fp-tableCell', $to).removeClass('go-up go-down').addClass('is-active');
4327        }
4328
4329        function FPsetSectionAnimationComplete(animation, $currentSection){
4330
4331        }
4332
4333        function FPAnimationBeforeInit(){
4334            $('.la_fp_section:not(.active) > .fp-tableCell').addClass('go-up');
4335            $('.la_fp_section.active > .fp-tableCell').addClass('is-active');
4336        }
4337
4338        if( "undefined" !== typeof $.fn.fullpage ){
4339            var anchors = [],
4340                navigationTooltips = [],
4341                fp_config;
4342
4343            $('<div class="la-fp-arrows"><ul><li class="prev"><i></i></li><li class="num"><span class="current">01</span><span class="total">01</span></li><li class="next"><i></i></li></ul></div>').appendTo($body);
4344            $document
4345                .on('click', '.la-fp-arrows .prev', function(e){
4346                    e.preventDefault();
4347                    $.fn.fullpage.moveSectionUp();
4348                })
4349                .on('click', '.la-fp-arrows .next', function(e){
4350                    e.preventDefault();
4351                    $.fn.fullpage.moveSectionDown();
4352                });
4353
4354            $footer_colophon.addClass('la_fp_section fp-auto-height').attr('data-anchor', 'colophon').appendTo($la_full_page);
4355
4356            $('.vc_section.la_fp_section').each(function(){
4357                var _name = $(this).attr('data-anchor'),
4358                    _tip = $(this).attr('data-fp-tooltip');
4359                if(!_name) _name = LA.utils.randomID();
4360                if(!_tip) _tip = '';
4361                anchors.push(_name);
4362                navigationTooltips.push(_tip);
4363
4364                /**
4365                 * Copy background to make parallax
4366                 */
4367                if($('.la_fp_slide.la_fp_child_section', $(this)).length == 0){
4368                    var $fp_bg = $('<div class="fp-bg" data-parent-anchor="'+_name+'"></div>');
4369                    var styleprops = getComputedStyle( $(this).get(0) );
4370                    var clonebg = {};
4371                    for( var prop in styleprops ){
4372                        if( prop.indexOf('background') == 0 && styleprops[prop] != "" ){
4373                            clonebg[ prop ] =  styleprops[prop];
4374                        }
4375                    }
4376                    $fp_bg.css(clonebg);
4377                    $(this).addClass('dont-need-bg').prepend($fp_bg);
4378                }
4379
4380            });
4381
4382            if($.exists($('#section_page_header'))){
4383                $('#section_page_header').remove();
4384            }
4385
4386            var _fp_animation = $la_full_page.data('fp-animation');
4387
4388            fp_config = $.extend({
4389                sectionSelector : '.la_fp_section',
4390                slideSelector : '.la_fp_slide',
4391                navigation : false,
4392                anchors: anchors,
4393                navigationTooltips: navigationTooltips,
4394                paddingTop: LA.utils.getAdminbarHeight(),
4395                onLeave: function(index, nextIndex, direction){
4396                    if(nextIndex > 1){
4397                        $body.removeClass('fp-active-firstsection');
4398                    }else{
4399                        $body.addClass('fp-active-firstsection');
4400                    }
4401                    var $that = $(this),
4402                        $next_elem = $('#la_full_page > .fp-section:nth-child('+nextIndex+')');
4403
4404                    $('.la-fp-arrows .num .current').html(nextIndex < 10 ? '0' + nextIndex : nextIndex );
4405
4406                    if($next_elem.hasClass('site-footer')){
4407                        $that.addClass('last-before-footer no-effect');
4408                    }
4409                    else{
4410                        if('up' == direction){
4411                            if($next_elem.hasClass('last-before-footer')){
4412                                $next_elem.addClass('no-effect');
4413                            }
4414                            if($that.hasClass('last-before-footer')){
4415                                $that.removeClass('no-effect');
4416                            }
4417                        }else{
4418                            $that.siblings('.last-before-footer').removeClass('no-effect');
4419                        }
4420                    }
4421
4422                    if( $that.hasClass('last-before-footer') ) {
4423                        if('down' == direction){
4424                            $that.css({
4425                                'transform' : 'translateY(-' + $footer_colophon.innerHeight() + 'px)',
4426                                '-webkit-transform' : 'translateY(-' + $footer_colophon.innerHeight() + 'px)',
4427                                '-moz-transform' : 'translateY(-' + $footer_colophon.innerHeight() + 'px)'
4428                            });
4429                        }
4430                    }
4431                    if( $next_elem.hasClass('last-before-footer') ) {
4432                        $next_elem.css({
4433                            'transform' : 'translateY(0)',
4434                            '-webkit-transform' : 'translateY(0)',
4435                            '-moz-transform' : 'translateY(0)'
4436                        });
4437                    }
4438
4439                    /**
4440                     * Reset VC Animated
4441                     */
4442                    if ($that.find('.fp-slides').length){
4443                        $that.find('.fp-slide.active .wpb_animate_when_almost_visible.wpb_start_animation').removeClass('wpb_start_animation');
4444                    }
4445                    else{
4446                        $that.find('.wpb_animate_when_almost_visible.wpb_start_animation').removeClass('wpb_start_animation');
4447                    }
4448
4449                    FPsetSectionAnimation($that, $next_elem, direction);
4450
4451                    if(nextIndex > 1){
4452                        if( direction == 'down' ) {
4453                            $('.site-header').addClass('is-sticky');
4454                            $('.site-header-mobile').addClass('is-sticky');
4455                            $('.site-header-inner').removeClass('sticky--pinned').addClass('sticky--unpinned');
4456                            $('.la-header-sticky-height').css('height', $('.la-header-sticky-height').prev().innerHeight()).hide();
4457                            $('.la-header-sticky-height-mb').css('height', $('.la-header-sticky-height-mb').prev().innerHeight()).hide();
4458                        }
4459                        else{
4460                            $('.site-header-inner').removeClass('sticky--unpinned').addClass('sticky--pinned');
4461                            $('.la-header-sticky-height').css('height', $('.la-header-sticky-height').prev().innerHeight()).show();
4462                            $('.la-header-sticky-height-mb').css('height', $('.la-header-sticky-height-mb').prev().innerHeight()).show();
4463                        }
4464                    }
4465                    else{
4466                        $('.site-header').removeClass('is-sticky');
4467                        $('.site-header-mobile').removeClass('is-sticky');
4468                        $('.site-header-inner').removeClass('sticky--unpinned').addClass('sticky--pinned');
4469                        $('.la-header-sticky-height').css('height', $('.la-header-sticky-height').prev().innerHeight()).show();
4470                        $('.la-header-sticky-height-mb').css('height', $('.la-header-sticky-height-mb').prev().innerHeight()).show();
4471                    }
4472
4473                    $la_full_page.trigger('la_event_fp:onLeave', [index, nextIndex, direction]);
4474
4475                },
4476                afterLoad: function(anchorLink, index){
4477                    var $that = $(this);
4478
4479                    if($that.hasClass('site-footer')){
4480                        $that.prev('.vc_section').addClass('last-before-footer');
4481                    }
4482
4483                    FPsetSectionAnimationComplete(_fp_animation, $that);
4484                    /**
4485                     * Init VC Animated
4486                     */
4487                    if ($.exists($that.find('.fp-slides'))){
4488                        $that.find('.fp-slide.active .wpb_animate_when_almost_visible:not(.wpb_start_animation)').addClass('wpb_start_animation');
4489                    }
4490                    else{
4491                        $that.find('.wpb_animate_when_almost_visible:not(.wpb_start_animation)').addClass('wpb_start_animation');
4492                    }
4493
4494                    $la_full_page.trigger('la_event_fp:afterLoad', [anchorLink, index]);
4495                },
4496                afterRender: function(){
4497                    $('.la-fp-arrows .num .total').html(anchors.length);
4498                    if($body.hasClass('enable-header-transparency')){
4499                        $masthead.addClass('fp-header-is-transparency');
4500                    }
4501                    $body.addClass('fp-active-firstsection');
4502
4503                    FPAnimationBeforeInit();
4504
4505                    $('#fp-nav ul li, .fp-slidesNav ul li').each(function(){
4506                        $(this).find('>a').append('<b class="num">'+ ($(this).index() + 1) +'</b>');
4507                    });
4508
4509                    $('#fp-nav li:gt('+ parseInt(anchors.length - 1) +')').remove();
4510
4511                    $la_full_page.trigger('la_event_fp:afterRender');
4512                },
4513                afterResize: function(){
4514
4515                    $la_full_page.trigger('la_event_fp:afterResize');
4516                },
4517                afterResponsive: function(isResponsive){
4518
4519                    $la_full_page.trigger('la_event_fp:afterResponsive', [isResponsive]);
4520                },
4521                afterSlideLoad: function(anchorLink, index, slideAnchor, slideIndex){
4522                    var $that = $(this);
4523
4524                    /**
4525                     * Init VC Animated
4526                     */
4527                    $that.find('.wpb_animate_when_almost_visible:not(.wpb_start_animation)').addClass('wpb_start_animation');
4528
4529                    $la_full_page.trigger('la_event_fp:afterSlideLoad', [anchorLink, index, slideAnchor, slideIndex]);
4530                },
4531                onSlideLeave: function(anchorLink, index, slideIndex, direction, nextSlideIndex){
4532                    var $that = $(this);
4533                    /**
4534                     * Reset VC Animated
4535                     */
4536                    $that.find('.wpb_animate_when_almost_visible.wpb_start_animation').removeClass('wpb_start_animation');
4537                    $la_full_page.trigger('la_event_fp:onSlideLeave', [anchorLink, index, slideIndex, direction, nextSlideIndex]);
4538
4539                }
4540            }, la_theme_config.fullpage );
4541
4542            if($('.vc_section.la_fp_fixed_top').length == 0){
4543                fp_config.fixedElements = fp_config.fixedElements.replace('.la_fp_fixed_top', '');
4544            }
4545            if($('.vc_section.la_fp_fixed_bottom').length == 0 ){
4546                fp_config.fixedElements = fp_config.fixedElements.replace('.la_fp_fixed_bottom', '');
4547            }
4548
4549            fp_config.fixedElements = fp_config.fixedElements.replace(/^,+/, '');
4550
4551            $body.removeClass('admin-bar');
4552
4553            $(atob("I3dwYWRtaW5iYXI=")).css('position', 'absolute').addClass('hidden');
4554
4555            $la_full_page.fullpage(fp_config);
4556
4557            $window.resize(function(){
4558                try {
4559                    $.fn.fullpage.reBuild();
4560                }catch (ex){
4561                    LA.utils.logger.display(ex)
4562                }
4563            });
4564
4565        }
4566    };
4567
4568    LA.core.HeaderSticky = function(){
4569
4570        var obj_height = la_theme_config.header_height;
4571
4572        var $header_builder = $('#lastudio-header-builder');
4573
4574        var scroll_direction = 'none',
4575            last_scroll = $window.scrollTop();
4576
4577        $window.on('scroll', function(){
4578            var currY = $window.scrollTop();
4579            scroll_direction = (currY > last_scroll) ? 'down' : ((currY === last_scroll) ? 'none' : 'up');
4580            last_scroll = currY;
4581        });
4582
4583        if($.exists($masthead_aside_inner)){
4584
4585            var _aside_lasticky_opts = {
4586                offset_top: LA.utils.getAdminbarHeight()
4587            };
4588
4589
4590            $masthead_aside_inner.la_sticky(_aside_lasticky_opts);
4591            $window.on('resize', function(){
4592                setTimeout(function(){
4593                    $body.trigger("la_sticky:recalc");
4594                },300);
4595            })
4596        }
4597
4598        var sticky_auto_hide = $body.hasClass('header-sticky-type-auto') ? true : false;
4599
4600        var prepareHeightForHeader = function (){
4601            var winW = $window.width(),
4602                _lg_height = obj_height.desktop.normal,
4603                _sm_height = obj_height.tablet.normal,
4604                _xs_height = obj_height.mobile.normal;
4605
4606            var _current_height = 0;
4607
4608            if( $.exists($header_builder) ){
4609
4610                _current_height = $('.lahfbhinner').outerHeight();
4611
4612                $('.lahfb-wrap-sticky-height').height( _current_height );
4613            }
4614
4615            if(winW > 992){
4616                if($.exists($masthead)){
4617                    _lg_height = _sm_height = $masthead_inner.outerHeight();
4618                    if(winW > 1300){
4619                        $('.la-header-sticky-height').height( _lg_height );
4620                    }
4621                    else{
4622                        $('.la-header-sticky-height').height( _sm_height );
4623                    }
4624                }
4625            }
4626            else{
4627                if($.exists($masthead_mb)){
4628                    _xs_height = $masthead_mb_inner.outerHeight();
4629                    $('.la-header-sticky-height-mb').height( _xs_height );
4630                }
4631            }
4632        }
4633
4634        prepareHeightForHeader();
4635
4636        $window.on('resize', prepareHeightForHeader);
4637
4638        function init_desktop_sticky(){
4639
4640            if(!$.exists($masthead)) return;
4641
4642            var $_header = $masthead,
4643                $_header_outer = $('.site-header-outer', $masthead),
4644                $_header_inner = $masthead_inner;
4645
4646            var lastY = 0,
4647                offsetY = LA.utils.getOffset($_header_outer).y;
4648
4649            $window
4650                .on('resize', function(e){
4651                    offsetY = LA.utils.getOffset($_header_outer).y;
4652                })
4653                .on('scroll', function(e){
4654
4655                    if($window.width() < 992) return;
4656
4657                    var currentScrollY = $window.scrollTop();
4658
4659                    var _breakpoint = offsetY - LA.utils.getAdminbarHeight();
4660
4661                    if(sticky_auto_hide){
4662                        _breakpoint = offsetY - LA.utils.getAdminbarHeight() + $_header_outer.outerHeight();
4663                    }
4664
4665                    if( currentScrollY > _breakpoint ) {
4666                        $_header_inner.css('top', LA.utils.getAdminbarHeight());
4667
4668                        if( !$_header.hasClass('is-sticky') ) {
4669                            $_header.addClass('is-sticky');
4670                        }
4671
4672                        if(sticky_auto_hide){
4673                            if(currentScrollY < $body.height() && lastY > currentScrollY){
4674                                if($_header_inner.hasClass('sticky--unpinned')){
4675                                    $_header_inner.removeClass('sticky--unpinned');
4676                                }
4677                                if(!$_header_inner.hasClass('sticky--pinned')){
4678                                    $_header_inner.addClass('sticky--pinned');
4679                                }
4680                            }else{
4681                                if($_header_inner.hasClass('sticky--pinned')){
4682                                    $_header_inner.removeClass('sticky--pinned');
4683                                }
4684                                if(!$_header_inner.hasClass('sticky--unpinned')){
4685                                    $_header_inner.addClass('sticky--unpinned');
4686                                }
4687                            }
4688                        }
4689                        else{
4690                            $_header_inner.addClass('sticky--pinned');
4691                        }
4692                    }
4693                    else{
4694                        if(sticky_auto_hide){
4695                            if($_header.hasClass('is-sticky')){
4696                                if(_breakpoint - currentScrollY < $_header_outer.outerHeight()){
4697                                    //console.log('here !!');
4698                                    //var diff = $_header_outer.outerHeight() - $_header_inner.outerHeight();
4699                                    //if(currentScrollY < diff){
4700                                    //    var _curtop = diff - (currentScrollY + LA.utils.getAdminbarHeight());
4701                                    //    $_header_inner.css('top', _curtop);
4702                                    //}else{
4703                                    //    $_header_inner.css('top', LA.utils.getAdminbarHeight());
4704                                    //}
4705                                }else{
4706                                    /** remove stuck **/
4707                                    $_header.removeClass('is-sticky');
4708                                    $_header_inner.css('top','0').removeClass('sticky--pinned sticky--unpinned');
4709                                }
4710                            }
4711                        }else{
4712                            if($_header.hasClass('is-sticky')){
4713                                $_header.removeClass('is-sticky');
4714                                $_header_inner.css('top','0').removeClass('sticky--pinned sticky--unpinned');
4715                            }
4716                        }
4717                    }
4718
4719                    lastY = currentScrollY;
4720                })
4721
4722        }
4723
4724        function init_mobile_sticky(){
4725            if(!$.exists($masthead_mb)) return;
4726
4727            var $_header = $masthead_mb,
4728                $_header_outer = $('.site-header-outer', $masthead_mb),
4729                $_header_inner = $masthead_mb_inner;
4730
4731            var lastY = 0,
4732                offsetY = LA.utils.getOffset($_header_outer).y;
4733
4734            $window
4735                .on('resize', function(e){
4736                    offsetY = LA.utils.getOffset($_header_outer).y;
4737                })
4738                .on('scroll', function(e){
4739
4740                    if($window.width() > 992) return;
4741
4742                    var currentScrollY = $window.scrollTop();
4743
4744                    var _breakpoint = offsetY - LA.utils.getAdminbarHeight();
4745
4746                    if(sticky_auto_hide){
4747                        _breakpoint = offsetY - LA.utils.getAdminbarHeight() + $_header_outer.outerHeight();
4748                    }
4749
4750                    if( currentScrollY > _breakpoint ) {
4751                        $_header_inner.css('top', LA.utils.getAdminbarHeight());
4752
4753                        if( !$_header.hasClass('is-sticky') ) {
4754                            $_header.addClass('is-sticky');
4755                        }
4756
4757                        if(sticky_auto_hide){
4758                            if(currentScrollY < $body.height() && lastY > currentScrollY){
4759                                if($_header_inner.hasClass('sticky--unpinned')){
4760                                    $_header_inner.removeClass('sticky--unpinned');
4761                                }
4762                                if(!$_header_inner.hasClass('sticky--pinned')){
4763                                    $_header_inner.addClass('sticky--pinned');
4764                                }
4765                            }else{
4766                                if($_header_inner.hasClass('sticky--pinned')){
4767                                    $_header_inner.removeClass('sticky--pinned');
4768                                }
4769                                if(!$_header_inner.hasClass('sticky--unpinned')){
4770                                    $_header_inner.addClass('sticky--unpinned');
4771                                }
4772                            }
4773                        }
4774                        else{
4775                            $_header_inner.addClass('sticky--pinned');
4776                        }
4777                    }
4778                    else{
4779                        if(sticky_auto_hide){
4780                            if($_header.hasClass('is-sticky')){
4781                                if(_breakpoint - currentScrollY < $_header_outer.outerHeight()){
4782
4783                                }else{
4784                                    /** remove stuck **/
4785                                    $_header.removeClass('is-sticky');
4786                                    $_header_inner.css('top','0').removeClass('sticky--pinned sticky--unpinned');
4787                                }
4788
4789                            }
4790                        }else{
4791                            if($_header.hasClass('is-sticky')){
4792                                $_header.removeClass('is-sticky');
4793                                $_header_inner.css('top','0').removeClass('sticky--pinned sticky--unpinned');
4794                            }
4795                        }
4796                    }
4797
4798                    lastY = currentScrollY;
4799                })
4800        }
4801
4802        function init_mobile_bar_sticky(){
4803            if(!$.exists($('.footer-handheld-footer-bar'))){
4804                return;
4805            }
4806
4807            var $_mobile_bar = $('.footer-handheld-footer-bar');
4808
4809            $window.on('scroll', function(e){
4810                if($window.width() > 600) return;
4811
4812                var mb_height = parseInt(la_theme_config.header_height.mobile.normal);
4813                if(mb_height < 20){
4814                    mb_height = 100;
4815                }
4816
4817                if($window.scrollTop() > mb_height){
4818                    if(la_theme_config.mobile_bar == 'down'){
4819                        if(scroll_direction == 'down'){
4820                            $_mobile_bar.removeClass('sticky--unpinned').addClass('sticky--pinned');
4821                        }
4822                        else{
4823                            $_mobile_bar.removeClass('sticky--pinned').addClass('sticky--unpinned');
4824                        }
4825                    }
4826                    else if(la_theme_config.mobile_bar == 'up'){
4827                        if(scroll_direction == 'up'){
4828                            $_mobile_bar.removeClass('sticky--unpinned').addClass('sticky--pinned');
4829                        }
4830                        else{
4831                            $_mobile_bar.removeClass('sticky--pinned').addClass('sticky--unpinned');
4832                        }
4833                    }
4834                }
4835                else{
4836                    $_mobile_bar.removeClass('sticky--pinned sticky--unpinned');
4837                }
4838            })
4839        }
4840
4841        init_mobile_bar_sticky();
4842
4843
4844        function init_builder_sticky() {
4845            if( ! $.exists($header_builder) ) {
4846                return;
4847            }
4848
4849            var $_header = $header_builder,
4850                $_header_outer = $('.lahfbhouter', $header_builder),
4851                $_header_inner = $('.lahfbhinner', $header_builder);
4852
4853            var lastY = 0,
4854                offsetY = LA.utils.getOffset($_header_outer).y;
4855
4856            $window
4857                .on('resize', function(e){
4858                    offsetY = LA.utils.getOffset($_header_outer).y;
4859                    if($('#page').hasClass('lahfb-header-vertical-no-toggle')){
4860                        if( $window.width() > 992 ){
4861                            $_header.removeClass('is-sticky');
4862                            $_header_inner.removeClass('sticky--unpinned sticky--pinned').removeAttr('style');
4863                            return;
4864                        }
4865                    }
4866                })
4867                .on('scroll', function(e){
4868
4869                    if($('#page').hasClass('lahfb-header-vertical-no-toggle')){
4870                        if( $window.width() > 992 ){
4871                            $_header.removeClass('is-sticky');
4872                            $_header_inner.removeClass('sticky--unpinned sticky--pinned').removeAttr('style');
4873                            return;
4874                        }
4875                    }
4876
4877                    var currentScrollY = $window.scrollTop();
4878
4879                    var _breakpoint = offsetY - LA.utils.getAdminbarHeight();
4880
4881                    if(sticky_auto_hide){
4882                        _breakpoint = offsetY - LA.utils.getAdminbarHeight() + $_header_outer.outerHeight();
4883                    }
4884
4885                    console.log(_breakpoint);
4886
4887                    if( currentScrollY > _breakpoint ) {
4888                        $_header_inner.css('top', LA.utils.getAdminbarHeight());
4889
4890                        if( !$_header.hasClass('is-sticky') ) {
4891                            $_header.addClass('is-sticky');
4892                        }
4893
4894                        if(sticky_auto_hide){
4895                            if(currentScrollY < $body.height() && lastY > currentScrollY){
4896                                if($_header_inner.hasClass('sticky--unpinned')){
4897                                    $_header_inner.removeClass('sticky--unpinned');
4898                                }
4899                                if(!$_header_inner.hasClass('sticky--pinned')){
4900                                    $_header_inner.addClass('sticky--pinned');
4901                                }
4902                            }else{
4903                                if($_header_inner.hasClass('sticky--pinned')){
4904                                    $_header_inner.removeClass('sticky--pinned');
4905                                }
4906                                if(!$_header_inner.hasClass('sticky--unpinned')){
4907                                    $_header_inner.addClass('sticky--unpinned');
4908                                }
4909                            }
4910                        }
4911                        else{
4912                            $_header_inner.addClass('sticky--pinned');
4913                        }
4914                    }
4915                    else{
4916                        if(sticky_auto_hide){
4917                            if($_header.hasClass('is-sticky')){
4918                                if(_breakpoint - currentScrollY < $_header_outer.outerHeight()){
4919                                    //console.log('here !!');
4920                                    //var diff = $_header_outer.outerHeight() - $_header_inner.outerHeight();
4921                                    //if(currentScrollY < diff){
4922                                    //    var _curtop = diff - (currentScrollY + LA.utils.getAdminbarHeight());
4923                                    //    $_header_inner.css('top', _curtop);
4924                                    //}else{
4925                                    //    $_header_inner.css('top', LA.utils.getAdminbarHeight());
4926                                    //}
4927                                }else{
4928                                    /** remove stuck **/
4929                                    $_header.removeClass('is-sticky');
4930                                    $_header_inner.css('top','0').removeClass('sticky--pinned sticky--unpinned');
4931                                }
4932                            }
4933                        }else{
4934                            if($_header.hasClass('is-sticky')){
4935                                $_header.removeClass('is-sticky');
4936                                $_header_inner.css('top','0').removeClass('sticky--pinned sticky--unpinned');
4937                            }
4938                        }
4939                    }
4940
4941                    lastY = currentScrollY;
4942                })
4943        }
4944
4945        if(!$body.hasClass('enable-header-sticky')) return;
4946
4947        init_desktop_sticky();
4948        init_mobile_sticky();
4949        init_builder_sticky();
4950
4951    };
4952
4953    LA.core.WooCommerce = function(){
4954        /*
4955         * Initialize all galleries on page.
4956         */
4957        $( '.la-woo-product-gallery' ).each( function() {
4958            $( this ).la_product_gallery();
4959        } );
4960
4961    
4961    $('.variations_form').trigger('wc_variation_form');
4962
4963        $document.on('click','.product_item .la-swatch-control .swatch-wrapper', function(e){
4964            e.preventDefault();
4965            var $swatch_control = $(this),
4966                $image = $swatch_control.closest('.product_item').find('.product_item--thumbnail-holder img').first();
4967
4968            if($swatch_control.closest('.product_item--thumbnail').length > 0){
4969                $image = $swatch_control.closest('.product_item--thumbnail').find('.product_item--thumbnail-holder img').last();
4970            }
4971            if($swatch_control.hasClass('selected')) return;
4972            $swatch_control.addClass('selected').siblings().removeClass('selected');
4973            if(!$image.hasClass('_has_changed')){
4974                $image.attr('data-o-src', $image.attr('src')).attr('data-o-sizes', $image.attr('sizes')).attr('data-o-srcset', $image.attr('srcset'));
4975            }
4976            if(!!$swatch_control.attr('data-thumb')){
4977                $image.attr('src', $swatch_control.attr('data-thumb')).removeAttr('sizes srcset');
4978            }
4979        });
4980
4981        $document.on('click','.la-quickview-button',function(e){
4982
4983            var _qv_mw, _qv_mh;
4984            if( $window.width() > 1500){
4985                _qv_mw = 1440;
4986                _qv_mh = 900;
4987            }
4988            else if( $window.width() > 1200 ) {
4989                _qv_mw = 1000;
4990                _qv_mh = 650;
4991            }
4992            else{
4993                _qv_mw = 900;
4994                _qv_mh = 600;
4995            }
4996
4997            if(_qv_mh > $window.height()){
4998                _qv_mh = $window.height() * 0.8;
4999            }
5000
5001            if($window.width() > 900){
5002                e.preventDefault();
5003                var $this = $(this);
5004                var show_popup = function(){
5005                    lightcase.start({
5006                        href: $this.data('href'),
5007                        showSequenceInfo: false,
5008                        type: 'ajax',
5009                        maxWidth: _qv_mw,
5010                        maxHeight: _qv_mh,
5011                        speedIn: 150,
5012                        speedOut: 100,
5013                        ajax: {
5014                            width: _qv_mw,
5015                            height: _qv_mh,
5016                            cache: true,
5017                            ajax_request_id: LA.utils.getUrlParameter('product_quickview', $this.data('href'))
5018                        },
5019
5020                        onClose : {
5021                            qux : function(){
5022                                $body.removeClass('open-quickview-product lightcase--completed lightcase--pending');
5023                                $('.custom-lightcase-overlay').remove();
5024                                $('.custom-lighcase-btn-close').remove();
5025                            }
5026                        },
5027                        onWait: function( obj, $obj, data){
5028                            $body.addClass('open-quickview-product');
5029                            obj.objects.content.append('<div class="custom-lightcase-overlay"></div>');
5030                            obj.objects.contentInner.append('<a class="custom-lighcase-btn-close" href="#"><i class="dl-icon-close"></i></a>');
5031                            $obj.html(data);
5032                            var $woo_gallery = $('.la-woo-product-gallery', $obj);
5033                            if($woo_gallery.length){
5034                                $body.addClass('lightcase--pending');
5035                                $woo_gallery.la_product_gallery();
5036                                obj._showContent($obj);
5037                            }
5038                            else{
5039                                obj._showContent($obj);
5040                            }
5041                        }
5042                    })
5043                }
5044                if($.fn.lightcase){
5045                    show_popup();
5046                }
5047                else{
5048                    LA.core.loadDependencies([ LA.core.path.plugins + 'jquery.lightcase.js'], show_popup )
5049                }
5050            }
5051        });
5052
5053        $document.on('click', '#lightcase-case .product-main-image .product--large-image a', function(e){
5054            e.preventDefault();
5055        });
5056
5057
5058        /** Wishlist **/
5059
5060        function set_attribute_for_wl_table(){
5061            var $table = $('table.wishlist_table');
5062            $table.addClass('shop_table_responsive');
5063            $table.find('thead th').each(function(){
5064                var _th = $(this),
5065                    _text = _th.text().trim();
5066                if(_text != ""){
5067                    $('td.' + _th.attr('class'), $table).attr('data-title', _text);
5068                }
5069            });
5070        }
5071        set_attribute_for_wl_table();
5072        $body.on('removed_from_wishlist', function(e){
5073            set_attribute_for_wl_table();
5074        });
5075        $document.on('added_to_cart', function(e, fragments, cart_hash, $button){
5076            setTimeout(set_attribute_for_wl_table, 800);
5077        });
5078        $document.on('click','.product a.add_wishlist.la-yith-wishlist',function(e){
5079            if(!$(this).hasClass('added')) {
5080                e.preventDefault();
5081                var $button     = $(this),
5082                    product_id = $button.data( 'product_id' ),
5083                    $product_image = $button.closest('.product').find('.product_item--thumbn
5083ail img:eq(0)'),
5084                    product_name = 'Product',
5085                    data = {
5086                        add_to_wishlist: product_id,
5087                        product_type: $button.data( 'product-type' ),
5088                        action: yith_wcwl_l10n.actions.add_to_wishlist_action
5089                    };
5090                if (!!$button.data('product_title')) {
5091                    product_name = $button.data('product_title');
5092                }
5093                if($button.closest('.product--summary').length){
5094                    $product_image = $button.closest('.product').find('.woocommerce-product-gallery__image img:eq(0)');
5095                }
5096                try {
5097                    if (yith_wcwl_l10n.multi_wishlist && yith_wcwl_l10n.is_user_logged_in) {
5098                        var wishlist_popup_container = $button.parents('.yith-wcwl-popup-footer').prev('.yith-wcwl-popup-content'),
5099                            wishlist_popup_select = wishlist_popup_container.find('.wishlist-select'),
5100                            wishlist_popup_name = wishlist_popup_container.find('.wishlist-name'),
5101                            wishlist_popup_visibility = wishlist_popup_container.find('.wishlist-visibility');
5102
5103                        data.wishlist_id = wishlist_popup_select.val();
5104                        data.wishlist_name = wishlist_popup_name.val();
5105                        data.wishlist_visibility = wishlist_popup_visibility.val();
5106                    }
5107
5108                    if (!LA.utils.isCookieEnable()) {
5109                        alert(yith_wcwl_l10n.labels.cookie_disabled);
5110                        return;
5111                    }
5112
5113                    $.ajax({
5114                        type: 'POST',
5115                        url: yith_wcwl_l10n.ajax_url,
5116                        data: data,
5117                        dataType: 'json',
5118                        beforeSend: function () {
5119                            $button.addClass('loading');
5120                        },
5121                        complete: function () {
5122                            $button.removeClass('loading').addClass('added');
5123                        },
5124                        success: function (response) {
5125                            var msg = $('#yith-wcwl-popup-message'),
5126                                response_result = response.result,
5127                                response_message = response.message;
5128
5129                            if (yith_wcwl_l10n.multi_wishlist && yith_wcwl_l10n.is_user_logged_in) {
5130                                var wishlist_select = $('select.wishlist-select');
5131                                if (typeof $.prettyPhoto !== 'undefined') {
5132                                    $.prettyPhoto.close();
5133                                }
5134                                wishlist_select.each(function (index) {
5135                                    var t = $(this),
5136                                        wishlist_options = t.find('option');
5137                                    wishlist_options = wishlist_options.slice(1, wishlist_options.length - 1);
5138                                    wishlist_options.remove();
5139
5140                                    if (typeof response.user_wishlists !== 'undefined') {
5141                                        var i = 0;
5142                                        for (i in response.user_wishlists) {
5143                                            if (response.user_wishlists[i].is_default != "1") {
5144                                                $('<option>')
5145                                                    .val(response.user_wishlists[i].ID)
5146                                                    .html(response.user_wishlists[i].wishlist_name)
5147                                                    .insertBefore(t.find('option:last-child'))
5148                                            }
5149                                        }
5150                                    }
5151                                });
5152
5153                            }
5154                            var html = '<div class="popup-added-msg">';
5155                            if (response_result == 'true') {
5156                                if ($product_image.length){
5157                                    html += $('<div>').append($product_image.clone()).html();
5158                                }
5159                                html += '<div class="popup-message"><strong class="text-color-heading">'+ product_name +' </strong>' + la_theme_config.i18n.wishlist.success + '</div>';
5160                            }else {
5161                                html += '<div class="popup-message">' + response_message + '</div>';
5162                            }
5163                            html += '<a class="btn btn-secondary view-popup-wis
5163hlish" rel="nofollow" href="' + response.wishlist_url.replace('/view', '') + '">' + la_theme_config.i18n.wishlist.view + '</a>';
5164                            html += '<a class="btn popup-button-continue" rel="nofollow" href="#">' + la_theme_config.i18n.global.continue_shopping + '</a>';
5165                            html += '</div>';
5166
5167                            LA.ui.ShowMessageBox(html, 'open-wishlist-msg');
5168
5169                            $button.attr('href',response.wishlist_url);
5170                            $('.add_wishlist[data-product_id="' + $button.data('product_id') + '"]').addClass('added');
5171                            $body.trigger('added_to_wishlist');
5172                        }
5173                    });
5174                } catch (ex) {
5175                    LA.utils.logger.set(ex, 'WooCommerce', 'Wishlist');
5176                }
5177            }
5178        });
5179
5180        $document.on('click','.product a.add_wishlist.la-ti-wishlist',function(e){
5181            e.preventDefault();
5182            var $ti_action;
5183            if($(this).closest('.entry-summary').length){
5184                $ti_action = $(this).closest('.entry-summary').find('form.cart .tinvwl_add_to_wishlist_button');
5185            }
5186            else{
5187                $ti_action = $(this).closest('.product').find('.tinvwl_add_to_wishlist_button');
5188            }
5189            $ti_action.trigger('click');
5190        })
5191
5192        /** LA Wishlist **/
5193
5194        $document.on('click','.product a.add_wishlist.la-core-wishlist',function(e){
5195            if(!$(this).hasClass('added')) {
5196                e.preventDefault();
5197                var $button     = $(this),
5198                    product_id = $button.data( 'product_id' ),
5199                    $product_image = $button.closest('.product').find('.product_item--thumbnail img:eq(0)'),
5200                    product_name = 'Product',
5201                    data = {
5202                        action: 'la_helpers_wishlist',
5203                        security: la_theme_config.security.wishlist_nonce,
5204                        post_id: product_id,
5205                        type: 'add'
5206                    };
5207                if (!!$button.data('product_title')) {
5208                    product_name = $button.data('product_title');
5209                }
5210                if($button.closest('.product--summary').length){
5211                    $product_image = $button.closest('.product').find('.woocommerce-product-gallery__image img:eq(0)');
5212                }
5213
5214                $.ajax({
5215                    type: 'POST',
5216                    url: la_theme_config.ajax_url,
5217                    data: data,
5218                    dataType: 'json',
5219                    beforeSend: function () {
5220                        $button.addClass('loading');
5221                    },
5222                    complete: function () {
5223                        $button.removeClass('loading').addClass('added');
5224                    },
5225                    success: function (response) {
5226                        var html = '<div class="popup-added-msg">';
5227
5228                        if (response.success) {
5229                            if ($product_image.length){
5230                                html += $('<div>').append($product_image.clone()).html();
5231                            }
5232                            html += '<div class="popup-message"><strong class="text-color-heading">'+ product_name +' </strong>' + la_theme_config.i18n.wishlist.success + '</div>';
5233                        }
5234                        else {
5235                            html += '<div class="popup-message">' + response.data.message + '</div>';
5236                        }
5237                        html += '<a class="btn btn-secondary view-popup-wis
5237hlish" rel="nofollow" href="'+response.data.wishlist_url+'">' + la_theme_config.i18n.wishlist.view + '</a>';
5238                        html += '<a class="btn popup-button-continue" rel="nofollow" href="#">' + la_theme_config.i18n.global.continue_shopping + '</a>';
5239                        html += '</div>';
5240
5241                        LA.ui.ShowMessageBox(html, 'open-wishlist-msg');
5242
5243                        $('.add_wishlist[data-product_id="' + $button.data('product_id') + '"]').addClass('added').attr('href', response.data.wishlist_url);
5244                    }
5245                });
5246
5247            }
5248        });
5249
5250        $document.on('click', '.la_wishlist_table a.la_remove_from_wishlist', function(e){
5251            e.preventDefault();
5252            var $table = $('#la_wishlist_table_wrapper');
5253            if( typeof $.fn.block != 'undefined' ) {
5254                $table.block({message: null, overlayCSS: {background: '#fff', opacity: 0.6}});
5255            }
5256            $table.load( e.target.href + ' #la_wishlist_table_wrapper2', function(){
5257                if( typeof $.fn.unblock != 'undefined' ) {
5258                    $table.stop(true).css('opacity', '1').unblock();
5259                }
5260            } );
5261        });
5262
5263        $document.on('adding_to_cart', function( e, $button, data ){
5264            if( $button && $button.closest('.la_wishlist_table').length ) {
5265                data.la_remove_from_wishlist_after_add_to_cart = data.product_id;
5266            }
5267        });
5268
5269        $document.on('added_to_cart', function( e, fragments, cart_hash, $button ){
5270            if($button && $button.closest('.la_wishlist_table').length ) {
5271                var $table = $('#la_wishlist_table_wrapper');
5272                $button.closest('tr').remove();
5273                $table.load( window.location.href + ' #la_wishlist_table_wrapper2')
5274            }
5275        });
5276
5277        /** Compare **/
5278        $document.on('click', 'table.compare-list .remove a', function(e){
5279            e.preventDefault();
5280            $('.add_compare[data-product_id="' + $(this).data('product_id') + '"]', window.parent.document).removeClass('added');
5281        });
5282
5283        $document.on('click','.la_com_action--compare', function(e){
5284            if(typeof yith_woocompare !== "undefined"){
5285                e.preventDefault();
5286                try{
5287                    lightcase.close();
5288                }catch (ex){}
5289                var action_url = LA.utils.addQueryArg('', 'action', yith_woocompare.actionview);
5290                action_url = LA.utils.addQueryArg(action_url, 'iframe', 'true');
5291                $body.trigger('yith_woocompare_open_popup', { response: action_url });
5292            }
5293        });
5294
5295        $document.on('click', '.product a.add_compare:not(.la-core-compare)', function(e){
5296            e.preventDefault();
5297
5298            if($(this).hasClass('added')){
5299                $body.trigger('yith_woocompare_open_popup', { response: LA.utils.addQueryArg( LA.utils.addQueryArg('', 'action', yith_woocompare.actionview) , 'iframe', 'true') });
5300                return;
5301            }
5302
5303            var $button     = $(this),
5304                widget_list = $('.yith-woocompare-widget ul.products-list'),
5305                $product_image = $button.closest('.product').find('.product_item--thumbnail img:eq(0)'),
5306                data        = {
5307                    action: yith_woocompare.actionadd,
5308                    id: $button.data('product_id'),
5309                    context: 'frontend'
5310                },
5311                product_name = 'Product';
5312            if(!!$button.data('product_title')){
5313                product_name = $button.data('product_title');
5314            }
5315
5316            if($button.closest('.product--summary').length){
5317                $product_image = $button.closest('.product').find('.woocommerce-product-gallery__image img:eq(0)');
5318            }
5319
5320            $.ajax({
5321                type: 'post',
5322                url: yith_woocompare.ajaxurl.toString().replace( '%%endpoint%%', yith_woocompare.actionadd ),
5323                data: data,
5324                dataType: 'json',
5325                beforeSend: function(){
5326                    $button.addClass('loading');
5327                },
5328                complete: function(){
5329                    $button.removeClass('loading').addClass('added');
5330                },
5331                success: function(response){
5332                    if($.isFunction($.fn.block) ) {
5333                        widget_list.unblock()
5334                    }
5335                    var html = '<div class="popup-added-msg">';
5336                    if ($product_image.length){
5337                        html += $('<div>').append($product_image.clone()).html();
5338                    }
5339                    html += '<div class="popup-message"><strong class="text-color-heading">'+ product_name +' </strong>' + la_theme_config.i18n.compare.success + '</div>';
5340                    html += '<a class="btn btn-secondary la_com_action--compare" rel="nofollow" href="'+response.table_url+'">'+la_theme_config.i18n.compare.view+'</a>';
5341                    html += '<a class="btn popup-button-continue" href="#" rel="nofollow">'+ la_theme_config.i18n.global.continue_shopping + '</a>';
5342                    html += '</div>';
5343
5344                    LA.ui.ShowMessageBox(html, 'open-compare-msg');
5345
5346                    $('.add_compare[data-product_id="' + $button.data('product_id') + '"]').addClass('added');
5347
5348                    widget_list.unblock().html( response.widget_table );
5349                }
5350            });
5351        });
5352
5353        /** LA Compare **/
5354        $document.on('click', '.product a.add_compare.la-core-compare', function(e){
5355            if(!$(this).hasClass('added')) {
5356                e.preventDefault();
5357                var $button     = $(this),
5358                    product_id = $button.data( 'product_id' ),
5359                    $product_image = $button.closest('.product').find('.product_item--thumbn
5359ail img:eq(0)'),
5360                    product_name = 'Product',
5361                    data = {
5362                        action: 'la_helpers_compare',
5363                        security: la_theme_config.security.compare_nonce,
5364                        post_id: product_id,
5365                        type: 'add'
5366                    };
5367                if (!!$button.data('product_title')) {
5368                    product_name = $button.data('product_title');
5369                }
5370                if($button.closest('.product--summary').length){
5371                    $product_image = $button.closest('.product').find('.woocommerce-product-gallery__image img:eq(0)');
5372                }
5373
5374                $.ajax({
5375                    type: 'POST',
5376                    url: la_theme_config.ajax_url,
5377                    data: data,
5378                    dataType: 'json',
5379                    beforeSend: function () {
5380                        $button.addClass('loading');
5381                    },
5382                    complete: function () {
5383                        $button.removeClass('loading').addClass('added');
5384                    },
5385                    success: function (response) {
5386                        var html = '<div class="popup-added-msg">';
5387
5388                        if (response.success) {
5389                            if ($product_image.length){
5390                                html += $('<div>').append($product_image.clone()).html();
5391                            }
5392                            html += '<div class="popup-message"><strong class="text-color-heading">'+ product_name +' </strong>' + la_theme_config.i18n.compare.success + '</div>';
5393                        }
5394                        else {
5395                            html += '<div class="popup-message">' + response.data.message + '</div>';
5396                        }
5397                        html += '<a class="btn btn-secondary view-popup-compare" rel="nofollow" href="'+response.data.compare_url+'">' + la_theme_config.i18n.compare.view + '</a>';
5398                        html += '<a class="btn popup-button-continue" rel="nofollow" href="#">' + la_theme_config.i18n.global.continue_shopping + '</a>';
5399                        html += '</div>';
5400
5401                        LA.ui.ShowMessageBox(html, 'open-compare-msg');
5402
5403                        $('.add_compare[data-product_id="' + $button.data('product_id') + '"]').addClass('added').attr('href', response.data.compare_url);
5404                    }
5405                });
5406
5407            }
5408        });
5409
5410        $document.on('click', '.la_remove_from_compare', function(e){
5411            e.preventDefault();
5412            var $table = $('#la_compare_table_wrapper');
5413            if( typeof $.fn.block != 'undefined' ) {
5414                $table.block({message: null, overlayCSS: {background: '#fff', opacity: 0.6}});
5415            }
5416            $table.load( e.target.href + ' #la_compare_table_wrapper2', function(){
5417                if( typeof $.fn.unblock != 'undefined' ) {
5418                    $table.stop(true).css('opacity', '1').unblock();
5419                }
5420            } );
5421        })
5422
5423        /** Cart **/
5424        var cart_timeout = null;
5425        $(document.body).on('wc_fragments_refreshed updated_wc_div wc_fragments_loaded', function(e){
5426            clearTimeout( cart_timeout );
5427            cart_timeout = setTimeout( function(){
5428                LA.utils.eventManager.publish('LA:Component:LazyLoadImage', [$('.widget_shopping_cart_content')]);
5429            }, 100);
5430        });
5431        $document.on('click', '.la_com_action--cart', function(e){
5432            if(!$(this).hasClass('force-display-on-mobile')){
5433                if($window.width() > 767){
5434                    e.preventDefault();
5435                    $body.toggleClass('open-cart-aside');
5436                }
5437            }
5438            else{
5439                e.preventDefault();
5440                $body.toggleClass('open-cart-aside');
5441            }
5442        });
5443
5444        $document.on('click', '.btn-close-cart', function(e){
5445            e.preventDefault();
5446            $body.removeClass('open-cart-aside');
5447        });
5448
5449        $document.on('adding_to_cart', function( e ){
5450            $body.removeClass('open-search-form').addClass('open-cart-aside');
5451            $('.cart-flyout').addClass('cart-flyout--loading');
5452            $('.la_com_action--cart > a > i').addClass('fa fa-spinner fa-spin');
5453        });
5454        $document.on('added_to_cart', function( e, fragments, cart_hash, $button ){
5455            $('.cart-flyout').removeClass('cart-flyout--loading');
5456            $('.la_com_action--cart > a > i').removeClass('fa fa-spinner fa-spin');
5457        } );
5458
5459        $('.la-global-message').on('click','.popup-button-continue',function(e){
5460            e.preventDefault();
5461            $('.la-global-message .close-message').trigger('click');
5462        });
5463
5464
5465        $document
5466            .on('touchend click','.wc-view-toggle span',function(){
5467                var _this = $(this),
5468                    _mode = _this.data('view_mode');
5469                if(!_this.hasClass('active')){
5470                    $('.wc-view-toggle span').removeClass('active');
5471                    _this.addClass('active');
5472
5473                    var $ul_products = $('.page-content').find('ul.products[data-grid_layout]'),
5474                        _old_grid = $ul_products.attr('data-grid_layout');
5475                    $ul_products.removeClass('products-grid').removeClass('products-list').addClass('products-'+_mode);
5476
5477                    if(_mode == 'grid'){
5478                        $ul_products.addClass(_old_grid);
5479                    }
5480                    else {
5481                        $ul_products.removeClass(_old_grid);
5482                    }
5483                    Cookies.set('zuka_wc_catalog_view_mode', _mode, { expires: 2 });
5484                }
5485            });
5486
5487
5488        /**
5489         * Single
5490         */
5491
5492
5493        var single_product_page_sticky_element = '.la-p-single-wrap.la-p-single-3 .la-custom-pright';
5494
5495        $(single_product_page_sticky_element).la_sticky({
5496            parent: $('.la-single-product-page'),
5497            offset_top: ($masthead.length ? parseInt($masthead.height()) + 30 : 30)
5498        });
5499
5500        $('.woocommerce-tabs .wc-tab-title a').on('click', function(e){
5501            e.preventDefault();
5502            var $this = $(this),
5503                $wrap = $this.closest('.woocommerce-tabs'),
5504                $wc_tabs = $wrap.find('.wc-tabs'),
5505                $panel = $this.closest('.wc-tab');
5506
5507            $wc_tabs.find('a[href="'+ $this.attr('href') +'"]').parent().toggleClass('active').siblings().removeClass('active');
5508            $panel.toggleClass('active').siblings().removeClass('active');
5509        });
5510        $('.woocommerce-Tabs-panel--description').addClass('active');
5511
5512        $document
5513            .on('click', '.quantity .qty-minus', function(e){
5514                e.preventDefault();
5515                var $qty = $(this).next('.qty'),
5516                    val = parseInt($qty.val());
5517                $qty.val( val > 1 ? val-1 : 1).trigger('change');
5518            })
5519            .on('click', '.quantity .qty-plus', function(e){
5520                e.preventDefault();
5521                var $qty = $(this).prev('.qty'),
5522                    val = parseInt($qty.val());
5523                $qty.val( val > 0 ? val+1 : 1 ).trigger('change');
5524            })
5525            .on('click', single_product_page_sticky_element + ' .wc-tabs a', function(e){
5526                setTimeout(function(){
5527                    $body.trigger('la_sticky:recalc');
5528                }, 300);
5529            });
5530
5531        if(la_theme_config.single_ajax_add_cart == 'on' || la_theme_config.single_ajax_add_cart == 'yes'){
5532            $(document).on('submit', '.la-p-single-wrap:not(.product-type-external) .entry-summary form.cart', function(e){
5533                e.preventDefault();
5534                $(document).trigger('adding_to_cart');
5535
5536                var form = $(this),
5537                    product_url = form.attr('action') || window.location.href,
5538                    action_url = LA.utils.addQueryArg(product_url, 'product_quickview', '1');
5539
5540                $.post(action_url, form.serialize() + '&_wp_http_referer=' + product_url, function (result) {
5541                    // Show message
5542                    if($(result).eq(0).hasClass('woocommerce-message') || $(result).eq(0).hasClass('woocommerce-error')){
5543                        $('.woocommerce-message, .woocommerce-error').remove();
5544                        $('.la-p-single-wrap.type-product').eq(0).before($(result).eq(0));
5545                    }
5546                    try{
5547                        lightcase.close();
5548                    }catch (ex){}
5549                    // update fragments
5550                    $.ajax({
5551                        url: woocommerce_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'get_refreshed_fragments' ),
5552                        type: 'POST',
5553                        success: function( data ) {
5554                            if ( data && data.fragments ) {
5555                                $.each( data.fragments, function( key, value ) {
5556                                    $( key ).replaceWith( value );
5557                                });
5558                                $( document.body ).trigger( 'wc_fragments_refreshed' );
5559                                $('.cart-flyout').removeClass('cart-flyout--loading');
5560                                $('.la_com_action--cart > a > i').removeClass('fa fa-spinner fa-spin');
5561                            }
5562                        }
5563                    });
5564                });
5565            });
5566        }
5567
5568        /**
5569         * Other
5570         */
5571        $('#coupon_code_ref').on('change', function(e){
5572            $('.woocommerce-cart-form__contents #coupon_code').val($(this).val());
5573        });
5574        $('#coupon_btn_ref').on('click', function(e){
5575            e.preventDefault();
5576            $('.woocommerce-cart-form__contents [name="apply_coupon"]').trigger('click');
5577        });
5578        $document.on('click', '#la_tabs_customer_login .la_tab_control a', function(e){
5579            e.preventDefault();
5580            var $this = $(this),
5581                $target = $($this.attr('href'));
5582            $this.parent().addClass('active').siblings().removeClass('active');
5583            $target.addClass('active').show().siblings('div').removeClass('active').hide();
5584            window.location.hash = $(this).attr('href').replace('#la_tab--', '');
5585        });
5586        $document.on('click', '#la_tabs_customer_login .btn-create-account', function(e){
5587            e.preventDefault();
5588            $('#la_tabs_customer_login .la_tab_control li:eq(1) a').trigger('click');
5589        });
5590
5591        if( ( window.location.hash == '#la_tab--register' || window.location.hash == '#register' ) && $.exists($('#la_tabs_customer_login .la_tab_control li a[href="#la_tab--register"]')) ) {
5592            $('#la_tabs_customer_login .la_tab_control li a[href="#la_tab--register"]').trigger('click');
5593        }
5594        else{
5595            if($.exists($('#la_tabs_customer_login .la_tab_control li a[href="#la_tab--login"]'))){
5596                $('#la_tabs_customer_login .la_tab_control li a[href="#la_tab--login"]').trigger('click');
5597            }
5598        }
5599
5600    };
5601
5602    LA.core.AjaxShopFilter = function(){
5603        LA.utils.logger.ajax_xhr = null;
5604        if( $('#la_shop_products').length == 0){
5605            return;
5606        }
5607        if($('#la_shop_products').hasClass('deactive-filters')){
5608            return;
5609        }
5610        var elm_to_replace = [
5611            '#la_shop_products',
5612            '.wc-toolbar-top',
5613            '.la-advanced-product-filters .sidebar-inner',
5614            '.wc_page_description',
5615            '.section-page-header',
5616        ];
5617
5618        var target_to_init = '#la_shop_products .la-pagination a, .la-advanced-product-filters-result a',
5619            target_to_init2 = '.woo-widget-filter a, .wc-ordering a, .wc-view-count a, .woocommerce.product-sort-by a, .woocommerce.la-price-filter-list a, .woocommerce.widget_layered_nav a, .woocommerce.widget_product_tag_cloud li a, .woocommerce.widget_product_categories a',
5620            target_to_init3 = '.woocommerce.widget_product_tag_cloud:not(.la_product_tag_cloud) a';
5621
5622        function init_price_filter() {
5623            if ( typeof woocommerce_price_slider_params === 'undefined' ) {
5624                return false;
5625            }
5626
5627            $( 'input#min_price, input#max_price' ).hide();
5628            $( '.price_slider, .price_label' ).show();
5629
5630            var min_price = $( '.price_slider_amount #min_price' ).data( 'min' ),
5631                max_price = $( '.price_slider_amount #max_price' ).data( 'max' ),
5632                current_min_price = $( '.price_slider_amount #min_price' ).val(),
5633                current_max_price = $( '.price_slider_amount #max_price' ).val();
5634
5635            $( '.price_slider:not(.ui-slider)' ).slider({
5636                range: true,
5637                animate: true,
5638                min: min_price,
5639                max: max_price,
5640                values: [ current_min_price, current_max_price ],
5641                create: function() {
5642
5643                    $( '.price_slider_amount #min_price' ).val( current_min_price );
5644                    $( '.price_slider_amount #max_price' ).val( current_max_price );
5645
5646                    $( document.body ).trigger( 'price_slider_create', [ current_min_price, current_max_price ] );
5647                },
5648                slide: function( event, ui ) {
5649
5650                    $( 'input#min_price' ).val( ui.values[0] );
5651                    $( 'input#max_price' ).val( ui.values[1] );
5652
5653                    $( document.body ).trigger( 'price_slider_slide', [ ui.values[0], ui.values[1] ] );
5654                },
5655                change: function( event, ui ) {
5656
5657                    $( document.body ).trigger( 'price_slider_change', [ ui.values[0], ui.values[1] ] );
5658                }
5659            });
5660        }
5661
5662        LA.utils.eventManager.subscribe('LA:AjaxShopFilter', function(e, url, element){
5663
5664            if( $('.wc-toolbar-container').length > 0) {
5665                var position = $('.wc-toolbar-container').offset().top - 200;
5666                $htmlbody.stop().animate({
5667                    scrollTop: position
5668                }, 800 );
5669            }
5670
5671            if ('?' == url.slice(-1)) {
5672                url = url.slice(0, -1);
5673            }
5674            url = url.replace(/%2C/g, ',');
5675
5676            url = LA.utils.removeURLParameter(url,'la_doing_ajax');
5677
5678            if (typeof (history.pushState) != "undefined") {
5679                history.pushState(null, null, url);
5680            }
5681
5682            LA.utils.eventManager.publish('LA:AjaxShopFilter:before_send', [url, element]);
5683
5684            if (LA.utils.logger.ajax_xhr) {
5685                LA.utils.logger.ajax_xhr.abort();
5686            }
5687
5688            url = LA.utils.addQueryArg(url, 'la_doing_ajax', 'true');
5689
5690            LA.utils.logger.ajax_xhr = $.get(url, function ( response ) {
5691
5692                for ( var i = 0; i < elm_to_replace.length; i++){
5693                    if( $(elm_to_replace[i]).length ){
5694                        if( elm_to_replace[i] == '.la-advanced-product-filters .sidebar-inner'){
5695                            if( $(response).find(elm_to_replace[i]).length ){
5696                                $(elm_to_replace[i]).replaceWith( $(response).find(elm_to_replace[i]) );
5697                            }
5698                        }
5699                        else{
5700                            try {
5701                                $(elm_to_replace[i]).find('[data-la_component="CountDownTimer"] .elm-countdown-div').countdown('destroy');
5702                            }
5703                            catch (ex){ }
5704
5705                            $(elm_to_replace[i]).replaceWith( $(response).find(elm_to_replace[i]) );
5706
5707                        }
5708                    }
5709                }
5710
5711                if( $('#sidebar_primary').length && $(response).find('#sidebar_primary').length ) {
5712                    $('#sidebar_primary').replaceWith($(response).find('#sidebar_primary'));
5713                    LA.core.Blog($('#sidebar_primary'));
5714                }
5715
5716                $('.la-ajax-shop-loading').removeClass('loading');
5717
5718                LA.utils.eventManager.publish('LA:AjaxShopFilter:success', [response, url, element]);
5719
5720            }, 'html');
5721        });
5722        LA.utils.eventManager.subscribe('LA:AjaxShopFilter:success', function(e, response, url, element){
5723            var $product_container = $('#la_shop_products');
5724
5725            if( $('.widget.woocommerce.widget_price_filter').length ) {
5726                init_price_filter();
5727            }
5728
5729            if($body.hasClass('open-advanced-shop-filter')){
5730                $body.removeClass('open-advanced-shop-filter');
5731                $('.la-advanced-product-filters').stop().slideUp('fast');
5732            }
5733
5734            LA.core.initAll($product_container);
5735
5736            LA.utils.LazyLoad($('.la-lazyload-image'), {rootMargin: '0px'}).observe();
5737        });
5738
5739        $document
5740            .on('click', '.btn-advanced-shop-filter', function(e){
5741                e.preventDefault();
5742                $body.toggleClass('open-advanced-shop-filter');
5743                $('.la-advanced-product-filters').stop().animate({
5744                    height: 'toggle'
5745                });
5746            })
5747            .on('click', '.la-advanced-product-filters .close-advanced-product-filters', function(e){
5748                e.preventDefault();
5749                $('.btn-advanced-shop-filter').trigger('click');
5750            })
5751            .on('click', target_to_init, function(e){
5752                e.preventDefault();
5753                $('.la-ajax-shop-loading').addClass('loading');
5754                LA.utils.eventManager.publish('LA:AjaxShopFilter', [$(this).attr('href'), $(this)]);
5755            })
5756            .on('click', target_to_init2, function(e){
5757                e.preventDefault();
5758                $('.la-ajax-shop-loading').addClass('loading');
5759                if($(this).closest('.widget_layered_nav').length){
5760                    $(this).parent().addClass('active');
5761                }
5762                else{
5763                    $(this).parent().addClass('active').siblings().removeClass('active');
5764                }
5765
5766                var _url = $(this).attr('href'),
5767                    _preset_from_w = LA.utils.getUrlParameter('la_preset'),
5768                    _preset_from_e = LA.utils.getUrlParameter('la_preset', _url);
5769
5770                if(!_preset_from_e && _preset_from_w){
5771                    _url = LA.utils.addQueryArg(_url, 'la_preset', _preset_from_w);
5772                }
5773
5774                LA.utils.eventManager.publish('LA:AjaxShopFilter', [_url, $(this)]);
5775            })
5776
5777            .on('click', target_to_init3, function(e){
5778                e.preventDefault();
5779                $('.la-ajax-shop-loading').addClass('loading');
5780                $(this).addClass('active').siblings().removeClass('active');
5781                var _url = $(this).attr('href'),
5782                    _preset_from_w = LA.utils.getUrlParameter('la_preset'),
5783                    _preset_from_e = LA.utils.getUrlParameter('la_preset', _url);
5784
5785                if(!_preset_from_e && _preset_from_w){
5786                    _url = LA.utils.addQueryArg(_url, 'la_preset', _preset_from_w);
5787                }
5788                LA.utils.eventManager.publish('LA:AjaxShopFilter', [_url, $(this)]);
5789            })
5790            .on('click', '.woocommerce.widget_layered_nav_filters a', function(e){
5791                e.preventDefault();
5792                $('.la-ajax-shop-loading').addClass('loading');
5793                LA.utils.eventManager.publish('LA:AjaxShopFilter', [$(this).attr('href'), $(this)]);
5794            })
5795            .on('submit', '.widget_price_filter form', function(e){
5796                e.preventDefault();
5797                var $form = $(this),
5798                    url = $form.attr('action') + '?' + $form.serialize();
5799                $('.la-ajax-shop-loading').addClass('loading');
5800                LA.utils.eventManager.publish('LA:AjaxShopFilter', [url, $form]);
5801            })
5802    };
5803
5804    LA.core.Blog = function( $sidebar_inner ){
5805
5806        $sidebar_inner = $sidebar_inner || $('.sidebar-inner');
5807
5808        $('.widget_pages > ul, .widget_archive > ul, .widget_categories > ul, .widget_product_categories > ul, .widget_meta > ul', $sidebar_inner).addClass('menu').closest('.widget').addClass('accordion-menu');
5809        $('.widget_nav_menu', $sidebar_inner).closest('.widget').addClass('accordion-menu');
5810        $('.widget_categories > ul li.cat-parent,.widget_product_categories li.cat-parent', $sidebar_inner).addClass('mm-item-has-sub');
5811
5812        $('.menu li > ul').each(function(){
5813            var $ul = $(this);
5814            $ul.before('<span class="narrow"><i></i></span>');
5815        });
5816
5817        $document.on('click','.accordion-menu li.menu-item-has-children > a,.menu li.mm-item-has-sub > a,.menu li > .narrow',function(e){
5818            e.preventDefault();
5819            var $parent = $(this).parent();
5820            if ($parent.hasClass('open')) {
5821                $parent.removeClass('open');
5822                $parent.find('>ul').stop().slideUp();
5823            } else {
5824                $parent.addClass('open');
5825                $parent.find('>ul').stop().slideDown();
5826                $parent.siblings().removeClass('open').find('>ul').stop().slideUp();
5827            }
5828        });
5829    };
5830
5831    LA.core.SinglePostShare = function(){
5832        if($('.single-post-content .la-sharing-single-posts').length){
5833            $('.single-post-content .la-sharing-single-posts .social--sharing').la_sticky({
5834                parent: $('.single-post-content'),
5835                offset_top: ($masthead.length ? parseInt($masthead.height()) + 30 : 30)
5836            });
5837        }
5838    };
5839
5840    LA.core.InstanceSearch = function(){
5841        var xhr = null,
5842            term = '',
5843            searchCache = {},
5844            $modal = $( '.searchform-fly-overlay' ),
5845            $form = $modal.find( 'form.search-form' ),
5846            $search = $form.find( 'input.search-field' ),
5847            $results = $modal.find( '.search-results' ),
5848            $button = $results.find( '.search-results-button' ),
5849            post_type = $modal.find( 'input[name=post_type]' ).val();
5850
5851
5852        var delaySearch = (function(){
5853            var timer = 0;
5854            return function(callback, ms){
5855                clearTimeout (timer);
5856                timer = setTimeout(callback, ms);
5857            };
5858        })();
5859
5860        $modal.on( 'keyup', '.search-field', function ( e ) {
5861
5862            var valid = false;
5863
5864            if ( typeof e.which === 'undefined' ) {
5865                valid = true;
5866            }
5867            else if ( typeof e.which === 'number' && e.which > 0 ) {
5868                valid = !e.ctrlKey && !e.metaKey && !e.altKey;
5869            }
5870            if ( !valid ) {
5871                return;
5872            }
5873            if ( xhr ) {
5874                xhr.abort();
5875            }
5876            delaySearch(function(){
5877                search( true );
5878            }, 400 );
5879
5880            })
5881            .on( 'change', '.product-cats input', function () {
5882                if ( xhr ) {
5883                    xhr.abort();
5884                }
5885                search( false );
5886            })
5887            .on( 'click', '.search-reset', function () {
5888                if ( xhr ) {
5889                    xhr.abort();
5890                }
5891                $modal.addClass( 'reset' );
5892                $results.find( '.results-container, .view-more-results' ).slideUp( function () {
5893                    $modal.removeClass( 'searching searched found-products found-no-product invalid-length reset' );
5894                });
5895            } )
5896            .on( 'focusout', '.search-field', function () {
5897                if ( $search.val().length < 2 ) {
5898                    $results.find( '.results-container, .view-more-results' ).slideUp( function () {
5899                        $modal.removeClass( 'searching searched found-products found-no-product invalid-length' );
5900                    });
5901                }
5902            });
5903
5904        /**
5905         * Private function for searching products
5906         */
5907        function search( typing ) {
5908            var keyword = $search.val(),
5909                $category = $form.find( '.product-cats input:checked' ),
5910                category = $category.length ? $category.val() : '',
5911                key = keyword + '[' + category + ']';
5912
5913            if ( term === keyword && typing ) {
5914                return;
5915            }
5916
5917            term = keyword;
5918
5919            if ( keyword.length < 2 ) {
5920                $modal.removeClass( 'searching found-products found-no-product' ).addClass( 'invalid-length' );
5921                return;
5922            }
5923
5924            var url = $form.attr( 'action' ) + '?' + $form.serialize();
5925
5926            $button.removeClass( 'fadeInUp' );
5927            $( '.view-more-results', $results ).slideUp( 10 );
5928            $modal.removeClass( 'found-products found-no-product' ).addClass( 'searching' );
5929
5930            if ( key in searchCache ) {
5931                showResult( searchCache[key] );
5932            }
5933            else {
5934                xhr = $.get( url, function ( response ) {
5935
5936                    var $content = $( '#site-content', response );
5937
5938                    if ( 'product' === post_type ) {
5939                        var $products = $( '#la_shop_products .row ul.products', $content );
5940
5941                        if ( $products.length ) {
5942                            $products.children( 'li:eq(7)' ).nextAll().remove();
5943                            // Cache
5944                            searchCache[key] = {
5945                                found: true,
5946                                items: $products,
5947                                url  : url
5948                            };
5949                        }
5950                        else {
5951                            // Cache
5952                            searchCache[key] = {
5953                                found: false,
5954                                text : $( '.woocommerce-info', $content ).text()
5955                            };
5956                        }
5957                    }
5958                    else {
5959
5960                        var $posts = $( '#blog_content_container .main-search-loop .blog__item:lt(3)', $content );
5961
5962                        if ( $posts.length ) {
5963                            $posts.addClass( 'col-md-4' );
5964
5965                            searchCache[key] = {
5966                                found: true,
5967                                items: $( '<div class="posts row" />' ).append( $posts ),
5968                                url  : url
5969                            };
5970                        }
5971                        else {
5972                            searchCache[key] = {
5973                                found: false,
5974                                text : $( '#blog_content_container article .entry-content', $content ).text()
5975                            };
5976                        }
5977                    }
5978
5979                    showResult( searchCache[key] );
5980
5981                    $modal.addClass( 'searched' );
5982                }, 'html' );
5983            }
5984        }
5985
5986        /**
5987         * Private function for showing the search result
5988         *
5989         * @param result
5990         */
5991        function showResult( result ) {
5992
5993            var extraClass = 'product' === post_type ? 'woocommerce' : 'la-post-grid';
5994
5995            $modal.removeClass( 'searching' );
5996
5997            if ( result.found ) {
5998                var grid = result.items.clone(),
5999                    items = grid.children();
6000
6001                $modal.addClass( 'found-products' );
6002
6003                $results.find( '.results-container' ).addClass( extraClass ).html( grid );
6004
6005                LA.core.initAll($results);
6006
6007				// Fix image lazy load
6008				LA.utils.LazyLoad($('.la-lazyload-image'), {rootMargin: '0px'}).observe();
6009				
6010                // Add animation class
6011                for ( var index = 0; index < items.length; index++ ) {
6012                    $( items[index] ).css( 'animation-delay', index * 100 + 'ms' );
6013                }
6014
6015                items.addClass( 'fadeInUp animated' );
6016
6017                $button.attr( 'href', result.url ).css( 'animation-delay', index * 100 + 'ms' ).addClass( 'fadeInUp animated' );
6018
6019                $results.find( '.results-container, .view-more-results' ).slideDown( 300, function () {
6020                    $modal.removeClass( 'invalid-length' );
6021                } );
6022            }
6023            else {
6024                $modal.addClass( 'found-no-product' );
6025
6026                $results.find( '.results-container' ).removeClass( extraClass ).html( $( '<div class="not-found text-center" />' ).text( result.text ) );
6027                $button.attr( 'href', '#' );
6028
6029                $results.find( '.view-more-results' ).slideUp( 300 );
6030                $results.find( '.results-container' ).slideDown( 300, function () {
6031                    $modal.removeClass( 'invalid-length' );
6032                });
6033            }
6034
6035            $modal.addClass( 'searched' );
6036        }
6037    };
6038
6039    LA.utils.OpenNewsletterPopup = function( $popup, callback ){
6040        lightcase.start({
6041            href: '#',
6042            maxWidth: parseInt(la_theme_config.popup.max_width),
6043            maxHeight: parseInt(la_theme_config.popup.max_height),
6044            inline: {
6045                width : parseInt(la_theme_config.popup.max_width),
6046                height : parseInt(la_theme_config.popup.max_height)
6047            },
6048            onInit : {
6049                foo: function() {
6050                    $('body.lastudio-zuka').addClass('open-newsletter-popup');
6051                }
6052            },
6053            onClose : {
6054                qux: function() {
6055                    if(typeof callback === 'function'){
6056                        callback();
6057                    }
6058                    $('body.lastudio-zuka').removeClass('open-newsletter-popup');
6059                    $('.custom-lightcase-overlay').remove();
6060                    $('.custom-lighcase-btn-close').remove();
6061                }
6062            },
6063            onFinish: {
6064                injectContent: function () {
6065                    lightcase.get('content').append('<div class="custom-lightcase-overlay"></div>');
6066                    lightcase.get('contentInner').children().append($popup);
6067                    lightcase.get('contentInner').append('<a class="custom-lighcase-btn-close" href="#"><i class="dl-icon-close"></i></a>');
6068                    $('.lightcase-icon-close').hide();
6069                    lightcase.resize();
6070                }
6071            }
6072        });
6073    }
6074
6075    LA.component.NewsletterPopup = function(el){
6076        var $popup = $(el),
6077            disable_on_mobile = parseInt($popup.attr('data-show-mobile') || 0),
6078            p_delay = parseInt($popup.attr('data-delay') || 2000),
6079            backtime = parseInt($popup.attr('data-back-time') || 1),
6080            waitfortrigger = parseInt($popup.attr('data-waitfortrigger') || 0);
6081
6082        $(document).on('click', '.btn-close-newsletter-popup', function(e){
6083            e.preventDefault();
6084            lightcase.close();
6085        });
6086
6087        if(waitfortrigger == 1){
6088            $(document).on('click touchend', '.elm-trigger-open-newsletter', function(e){
6089                e.preventDefault();
6090                LA.utils.OpenNewsletterPopup($popup);
6091            })
6092        }
6093
6094        return {
6095            init : function(){
6096                if(waitfortrigger != 1){
6097                    if($(window).width() < 767){
6098                        if(disable_on_mobile){
6099                            return;
6100                        }
6101                    }
6102                    try{
6103                        if(Cookies.get('zuka_dont_display_popup') == 'yes'){
6104                            return;
6105                        }
6106                    }catch (ex){ console.log(ex); }
6107
6108                    $(window).load(function(){
6109                        setTimeout(function(){
6110                            LA.utils.OpenNewsletterPopup($popup, function(){
6111                                if($('.cbo-dont-show-popup', $popup).length && $('.cbo-dont-show-popup', $popup).is(':checked')){
6112                                    try {
6113                                        Cookies.set('zuka_dont_display_popup', 'yes', { expires: backtime, path: '/' });
6114                                    } catch (ex){}
6115                                }
6116                            })
6117                        }, p_delay)
6118                    })
6119                }
6120            }
6121        }
6122
6123    };
6124
6125    $(function(){
6126
6127        LA.core.SitePreload();
6128        LA.core.MegaMenu();
6129        LA.core.FullPageJs();
6130        LA.core.InstanceSearch();
6131
6132        LA.core.FixVCRowFullWidth();
6133        LA.core.initAll($(document));
6134
6135        LA.core.ElementAjaxClickEvent();
6136        LA.core.ElementClickEvent();
6137
6138        LA.core.Blog();
6139        LA.core.SinglePostShare();
6140        LA.core.WooCommerce();
6141        LA.core.AjaxShopFilter();
6142
6143        if($.exists($('.item-overlay-effect'))){
6144            $('.item-overlay-effect').la_hover_effect();
6145        }
6146    });
6147
6148    $window.on('load', function(){
6149        $body.removeClass('site-loading').addClass('body-loaded');
6150        LA.core.HeaderSticky();
6151    });
6152
6153})(jQuery);
6154
6155
6156/*
6157 For Demo
6158 */
6159
6160(function($) {
6161    "use strict";
6162
6163    $(function(){
6164
6165        var $replace_menu_switches = $('.la_com_action--dropdownmenu.component-dropdown-display-active-item');
6166        $replace_menu_switches.each(function(){
6167            var $label = $(this).find('.component-target-text');
6168            if( $(this).find('li.current-menu-item').length ){
6169                $label.html = $label.find('li.current-menu-item').eq(0).html();
6170            }
6171        });
6172
6173        var $mm_account = $('.site-header .header__action--account-menu');
6174        $('> a', $mm_account).attr('href', $('.menu a', $mm_account).first().attr('href'));
6175        $('>.menu', $mm_account).remove();
6176
6177        if($.exists($('.search-form .sf-fields select.postform'))){
6178            var $selectCat = $('.search-form .sf-fields select.postform');
6179            $('<select id="sf_select_category_tmp"><option id="sf_select_category_option_tmp">'+ $('option:selected', $selectCat).text() +'</option></select>').insertAfter($selectCat);
6180            $selectCat.width($('#sf_select_category_tmp').width());
6181            $selectCat.change(function(){
6182                $('#sf_select_category_option_tmp').html($('option:selected', $(this)).text());
6183                $(this).width($('#sf_select_category_tmp').width());
6184            });
6185        }
6186        if(false && $.exists($('#section_page_header'))){
6187            var $page_header = $('#section_page_header');
6188            if ( typeof $page_header.css('backgroundImage') !== 'undefined' && $page_header.css('backgroundImage') !== '' && typeof $page_header.css('backgroundRepeat') !== 'undefined' && ( $page_header.css('backgroundRepeat') === 'no-repeat' || $page_header.css('backgroundRepeat') === 'inherit') ) {
6189                var el_parallax_bg = $page_header.css('backgroundImage');
6190                var patt = new RegExp(/url\(/g);
6191                var check = patt.test(el_parallax_bg);
6192                if(check){
6193                    el_parallax_bg = el_parallax_bg.replace( /url\(|\)|"|'/g, '' );
6194                    if(el_parallax_bg != '' && el_parallax_bg != 'none'){
6195                        $('<img/>')
6196                            .on('load', function() {
6197                                var el_parallax = $("<div class='la_parallax_row js-el' data-bg-align='' data-direction='up' data-opacity='100' data-velocity='-0.15' data-mobile-enabled='parallax-enable-mobile' data-bg-height='' data-bg-width='' data-bg-image='' data-bg-repeat='false' data-id='' data-la_component='ParallaxRow' style='display: none'></div>");
6198                                if(this.naturalWidth != "undefined" && this.naturalWidth != 0 && this.naturalHeight != "undefined" && this.naturalHeight != 0){
6199                                    el_parallax.attr('data-bg-image', el_parallax_bg.replace(/^http(s)?:\/\//, '//')).attr('data-bg-height', this.naturalHeight).attr('data-bg-width', this.naturalWidth).appendTo($page_header);
6200                                    LA.core.initAll($page_header);
6201                                }
6202                            })
6203                            .attr('src', el_parallax_bg.replace(/^http(s)?:\/\//, '//'));
6204                    }
6205                }
6206            }
6207        }
6208
6209        $(document).on('touchstart click', '.portfolio-single-page .link-display-portfolio-information', function(e){
6210            e.preventDefault();
6211            $('.portfolio-single-page #portfolio_information').toggleClass('force-display');
6212
6213        })
6214
6215        $(document)
6216            .on('click', 'html.touchevents .product_item--thumbnail-holder .woocommerce-loop-product__link', function(e){
6217                if( $(window).width() < 992) {
6218                    if (!$(this).hasClass('go-go')) {
6219                        e.preventDefault();
6220                        $('.product_item--thumbnail-holder .woocommerce-loop-product__link').removeClass('go-go');
6221                        $(this).addClass('go-go');
6222                    }
6223                }
6224            })
6225            .on('click', 'html.touchevents .header_component--dropdown-menu > a', function(e){
6226                $(this).closest('.la_compt_iem').toggleClass('active');
6227            })
6228            .on('touchstart', 'html.touchevents .site-main, html.touchevents .site-footer', function(e){
6229                $('html.touchevents .header_component--dropdown-menu').removeClass('active');
6230                if($(e.target).closest('.wc-ordering').length == 0){
6231                    $('.wc-toolbar .wc-ordering').removeClass('active');
6232                }
6233            })
6234            .on('touchstart', 'html.touchevents .wc-toolbar .wc-ordering', function(e){
6235                $('.wc-toolbar .wc-ordering').toggleClass('active');
6236            });
6237
6238        $('.la-slick-slider').on('beforeChange afterChange', function( event, slick, currentSlide, nextSlide ){
6239            LA.utils.LazyLoad($('.la-lazyload-image'), {rootMargin: '0px'}).observe();
6240        })
6241
6242    });
6243
6244
6245})(jQuery);
6246
6247(function($) {
6248    "use strict";
6249
6250
6251    $(function(){
6252
6253        $( 'body' )
6254            .on( 'init', '.more_demo_aside .la-tabs-wrapper', function() {
6255                $( '.more_demo_aside .la-tab' ).hide();
6256
6257                var hash  = window.location.hash;
6258                var url   = window.location.href;
6259                var $tabs = $( this ).find( '.la-tabs' ).first();
6260                $tabs.find( 'li:first a' ).click();
6261            } )
6262            .on( 'click', '.more_demo_aside .la-tabs li a', function( e ) {
6263                e.preventDefault();
6264                var $tab          = $( this );
6265                var $tabs_wrapper = $tab.closest( '.la-tabs-wrapper' );
6266                var $tabs         = $tabs_wrapper.find( '.la-tabs' );
6267
6268                $tabs.find( 'li' ).removeClass( 'active' );
6269                $tabs_wrapper.find( '.la-tab' ).hide();
6270
6271                $tab.closest( 'li' ).addClass( 'active' );
6272                $tabs_wrapper.find( $tab.attr( 'href' ) ).show();
6273            });
6274
6275        $( '.more_demo_aside .la-tabs-wrapper' ).trigger( 'init' );
6276
6277        $(document).on('click', '.more_demo_aside button', function(e){
6278            $('body').toggleClass('open-aside-demo');
6279        });
6280
6281        $(window).load(function(){
6282            if(location.hash != '' && $(location.hash).length){
6283                $('html,body').animate({
6284                    scrollTop: $(location.hash).offset().top - 100
6285                }, 800);
6286            }
6287        })
6288
6289    });
6290
6291})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.