PageSourceSearch

https://moviemezzanine.com/wp-content/themes/esquise/js/scripting.js?ver=1790278761

js moviemezzanine.com collected 2026-09-24 19:39:55 UTC 71,165 bytes, 1,681 lines download raw bytes

1'use strict';
2// Get all localized variables
3
4var main_color = Esquise.main_color;
5var images_loaded_active = Esquise.ts_enable_imagesloaded;
6var ts_logo_content = Esquise.ts_logo_content;
7var ts_onepage_layout = Esquise.ts_onepage_layout;
8
9if (typeof ts_logo_content !== 'undefined') {
10    addLogoToMenu(ts_logo_content);
11}
12
13function ts_set_like(){
14    jQuery('.touchsize-likes').on('click',function() {
15        var link, id, postfix;
16
17        link = jQuery(this);
18        if(link.hasClass('active')) return false;
19
20        id = jQuery(this).attr('data-id'),
21        postfix = link.find('.touchsize-likes-postfix').text();
22
23        jQuery.post(Esquise.ajaxurl, { action:'touchsize-likes', likes_id:id, postfix:postfix }, function(data){
24            link.html(data).addClass('active').attr('title','You already like this');
25        });
26
27        return false;
28    });
29
30    if( jQuery('body.touchsize-likes').length ) {
31        jQuery('.touchsize-likes').each(function(){
32            var id = jQuery(this).attr('id');
33            jQuery(this).load(Esquise.ajaxurl, { action:'touchsize-likes', post_id:id });
34        });
35    }
36}
37
38/* Testimonials */
39jQuery(function(){
40    jQuery('ul.testimonials-controls li').click(function(){
41        var testimonial_id = jQuery(this).attr('id');
42            jQuery(this).parent().prev().find('li').hide();
43            jQuery(this).parent().find('li.active').removeClass('active');
44            jQuery(this).parent().prev().find('#' + testimonial_id).show();
45            jQuery(this).addClass('active');
46    });
47});
48
49
50/* Article carousel */
51
52function initCarousel() {
53    jQuery('.carousel-wrapper').each(function () {
54        var thisElem = jQuery(this);
55        var numberOfElems = parseInt(jQuery('.carousel-container', thisElem).children().length, 10);
56        var oneElemWidth;
57        var numberOfColumns = [
58            ['col-lg-2', 6],
59            ['col-lg-3', 4],
60            ['col-lg-4', 3],
61            ['col-lg-6', 2],
62            ['col-lg-12', 1]
63        ];
64        var curentNumberOfColumns;
65        var moveMargin;
66        var leftHiddenElems = 0;
67        var rightHiddenElems;
68        var curentMargin = 0;
69        var numberOfElemsDisplayed;
70        var index = 0;
71        var carouselContainerWidth;
72        var carouselContainerWidthPercentage;
73        var elemWidth;
74        var elemWidthPercentage;
75
76        while (index < numberOfColumns.length) {
77            if (jQuery('.carousel-container>div', thisElem).hasClass(numberOfColumns[index][0])) {
78                curentNumberOfColumns = numberOfColumns[index][1];
79                break;
80            }
81            index++;
82        }
83
84        elemWidth = 100 / numberOfElems;
85        elemWidth = elemWidth.toFixed(4);
86        elemWidthPercentage = elemWidth + '%';
87
88        function showHideArrows(){
89            if(curentNumberOfColumns >= numberOfElems){
90
91                jQuery('ul.carousel-nav > li.carousel-nav-left', thisElem).css('opacity','0.4');
92                jQuery('ul.carousel-nav > li.carousel-nav-right', thisElem).css('opacity','0.4');
93
94            } else if(leftHiddenElems === 0){
95
96                jQuery('ul.carousel-nav > li.carousel-nav-left', thisElem).css('opacity','0.4');
97                jQuery('ul.carousel-nav > li.carousel-nav-right', thisElem).css('opacity','1');
98
99            } else if (rightHiddenElems === 0 ){
100
101                jQuery('ul.carousel-nav > li.carousel-nav-left', thisElem).css('opacity','1');
102                jQuery('ul.carousel-nav > li.carousel-nav-right', thisElem).css('opacity','0.4');
103
104            } else {
105                jQuery('ul.carousel-nav > li.carousel-nav-left', thisElem).css('opacity','1');
106                jQuery('ul.carousel-nav > li.carousel-nav-right', thisElem).css('opacity','1');
107            }
108        }
109
110        function reinitCarousel() {
111
112            showHideArrows();
113            jQuery('.carousel-container', thisElem).css('margin-left', 0);
114            leftHiddenElems = 0;
115            jQuery('ul.carousel-nav > li', thisElem).unbind('click');
116
117            if (jQuery(window).width() <= 973) {
118
119                carouselContainerWidth = 100 * numberOfElems;
120                carouselContainerWidthPercentage = carouselContainerWidth + '%';
121                rightHiddenElems = numberOfElems - 1;
122                moveMargin = 100;
123                curentMargin = 0;
124
125                jQuery('ul.carousel-nav > li', thisElem).unbind('click');
126
127                jQuery('ul.carousel-nav > li', thisElem).click(function () {
128
129                    if( jQuery('img.lazy').length > 0 ){
130                        thisElem.find('img.lazy').lazyload();
131                    }
132
133                    if (jQuery(this).hasClass('carousel-nav-left')) {
134                        if (leftHiddenElems > 0) {
135                            curentMargin = curentMargin + moveMargin;
136                            jQuery('.carousel-container', thisElem).css('margin-left', curentMargin + '%');
137                            rightHiddenElems++;
138                            leftHiddenElems--;
139                        }
140                    } else {
141                        if (rightHiddenElems > 0) {
142                            curentMargin = curentMargin - moveMargin;
143                            jQuery('.carousel-container', thisElem).css('margin-left', curentMargin + '%');
144                            rightHiddenElems--;
145                            leftHiddenElems++;
146                        }
147                    }
148                    // Trigger arrows color change
149                    showHideArrows();
150                });
151
152            } else {
153
154                while (index < numberOfColumns.length) {
155                    if (jQuery('.carousel-container>div', thisElem).hasClass(numberOfColumns[index][0])) {
156                        numberOfElemsDisplayed = numberOfColumns[index][1];
157                        moveMargin = 100 / numberOfElemsDisplayed;
158                        rightHiddenElems = numberOfElems - numberOfElemsDisplayed;
159                        oneElemWidth = 100 / numberOfColumns[index][1];
160                        break;
161                    }
162                    index++;
163                }
164
165                carouselContainerWidth = oneElemWidth * numberOfElems;
166                carouselContainerWidthPercentage = carouselContainerWidth + '%';
167
168                curentMargin = 0;
169
170                jQuery('ul.carousel-nav > li', thisElem).click(function () {
171
172                    if( jQuery('img.lazy').length > 0 ){
173                        thisElem.find('img.lazy').lazyload();
174                    }
175
176                    if (jQuery(this).hasClass('carousel-nav-left')) {
177                        if (leftHiddenElems > 0) {
178                            curentMargin = curentMargin + moveMargin + 0.00001;
179                            jQuery('.carousel-container', thisElem).css('margin-left', curentMargin + '%');
180                            rightHiddenElems++;
181                            leftHiddenElems--;
182                        }
183                    } else {
184                        if (rightHiddenElems > 0) {
185                            curentMargin = curentMargin - moveMargin;
186                            jQuery('.carousel-container', thisElem).css('margin-left', curentMargin + '%');
187                            rightHiddenElems--;
188                            leftHiddenElems++;
189                        }
190                    }
191                    // Trigger arrows color change
192                    showHideArrows();
193                });
194            }
195
196            //Set the container total width
197            jQuery('.carousel-container', thisElem).width(carouselContainerWidthPercentage).css({
198                'max-height': '9999px',
199                'opacity': '1'
200            });
201
202            //Set width for each element
203            jQuery('.carousel-container>div', thisElem).each(function () {
204                jQuery(this).attr('style', 'width: ' + elemWidthPercentage + ' !important; float:left;');
205            });
206        }
207
208        reinitCarousel();
209
210        jQuery(window).resize(function () {
211            reinitCarousel();
212        });
213    });
214}
215
216function visibleBeforeAnimation(){
217    jQuery('.ts-grid-view.animated, .ts-thumbnail-view.animated, .ts-big-posts.animated, .ts-list-view.animated, .ts-super-posts.animated').each(function(){
218        jQuery(this).find('article').each(function(index){
219            var thisElem = jQuery(this);
220            if( !thisElem.hasClass('shown') && thisElem.isOnScreen() === true ){
221                thisElem.addClass('shown');
222                thisElem.stop().delay(100*index).animate({opacity: 1},1000);
223            }
224        });
225    });
226    jQuery('.content-block.animated').each(function(index){
227        var thisElem = jQuery(this);
228        var pixelsFromTransform = 0;
229        if( thisElem.hasClass('slideup') ){
230            pixelsFromTransform = 250;
231        }
232        if( thisElem.isOnScreen() === true ){
233            thisElem.addClass('shown');
234            thisElem.animate({opacity: 1},800);
235        }
236    });
237
238    jQuery('.ts-counters').each(function(index){
239        var thisElem = jQuery(this);
240        if ( thisElem.isOnScreen() ) {
241            startCounters();
242        };
243    });
244
245    jQuery('.ts-horizontal-skills > li').each(function(index){
246        var thisElem = jQuery(this);
247        if ( thisElem.isOnScreen() ) {
248            jQuery('.ts-horizontal-skills').countTo();
249        };
250    });
251
252    jQuery('.ts-vertical-skills > li').each(function(index){
253        var thisElem = jQuery(this);
254        if ( thisElem.isOnScreen() ) {
255            jQuery('.ts-vertical-skills').countTo();
256        };
257    });
258
259}
260
261function animateArticlesOnLoad(){
262    var thisElem;
263    // If adds fade effect to articles in grid view
264    jQuery(window).on('scroll',function(){
265        jQuery('.ts-grid-view.animated, .ts-thumbnail-view.animated, .ts-big-posts.animated, .ts-list-view.animated, .ts-super-posts.animated').each(function(){
266            jQuery(this).find('article').each(function(index){
267                thisElem = jQuery(this);
268                if( !thisElem.hasClass('shown') && thisElem.isOnScreen() === true ){
269                    thisElem.addClass("shown");
270                    thisElem.stop().delay(100*index).animate({opacity: 1},1200);
271                }
272            });
273        });
274    });
275}
276
277jQuery.fn.isOnScreen = function(){
278
279    var win = jQuery(window);
280
281    var viewport = {
282        top : win.scrollTop(),
283        left : win.scrollLeft()
284    };
285    viewport.right = viewport.left + win.width();
286    viewport.bottom = viewport.top + win.height();
287
288    var bounds = this.offset();
289    bounds.right = bounds.left + this.outerWidth();
290    bounds.bottom = bounds.top + this.outerHeight();
291
292    return (!(viewport.bottom < bounds.top || viewport.top > bounds.bottom));
293
294};
295
296function animateBlocksOnScroll(){
297    var thisElem;
298    jQuery(window).on('scroll',function(){
299        jQuery('.content-block.animated').each(function(index){
300            var thisElem = jQuery(this);
301            var pixelsFromTransform = 0;
302            if( thisElem.hasClass('slideup') ){
303                pixelsFromTransform = 150;
304            }
305            if( !thisElem.hasClass('shown') && thisElem.isOnScreen() === true ){
306                thisElem.addClass('shown');
307                thisElem.stop().delay(100*index).animate({opacity: 1},1000);
308            }
309        });
310
311        jQuery('.ts-counters').each(function(index){
312            var thisElem = jQuery(this);
313            if( !thisElem.hasClass('shown') && thisElem.isOnScreen() === true ){
314                thisElem.addClass('shown');
315                startCounters();
316            }
317        });
318
319        jQuery('.ts-horizontal-skills > li').each(function(index){
320            var thisElem = jQuery(this);
321            if( !thisElem.hasClass('animated') && thisElem.isOnScreen() === true ){
322                thisElem.addClass('shown');
323                jQuery('.ts-horizontal-skills').countTo();
324            }
325        });
326
327        jQuery('.ts-vertical-skills > li').each(function(index){
328            var thisElem = jQuery(this);
329            if( !thisElem.hasClass('animated') && thisElem.isOnScreen() === true ){
330                thisElem.addClass('shown');
331                jQuery('.ts-vertical-skills').countTo();
332            }
333        });
334
335    });
336
337}
338
339function activateStickyMenu(){
340    var menu = jQuery('.ts-header-menu').first(),
341        sticky_height = 0,
342        offset = 0;
343
344    // there are no menu on the page
345    if (menu.length < 1){
346        offset = 100;
347        sticky_height = 80;
348    }
349    else
350        sticky_height = jQuery('.ts-sticky-menu .megaWrapper').height() + 10;
351    
352    jQuery(window).on('scroll',function(){
353        
354        // check if the offset of the menu has changed
355        if(menu.length > 0 && offset !== menu.offset().top )
356            offset = menu.offset().top;
357
358        if( jQuery(window).scrollTop() > offset && !jQuery('.ts-sticky-menu').hasClass('active') ){
359            jQuery('.ts-sticky-menu').outerHeight(sticky_height);
360            jQuery('.ts-sticky-menu').addClass('active');
361        }
362
363        if( jQuery(window).scrollTop() < offset && jQuery('.ts-sticky-menu').hasClass('active') ) {
364            jQuery('.ts-sticky-menu').removeClass('active');
365            jQuery('.ts-sticky-menu').outerHeight(0);
366        }
367    });
368}
369
370function startOnePageNav(){
371    jQuery('.main-menu a').click(function(e){
372        e.preventDefault();
373        var navItemUrl = jQuery(this).attr('href');
374        jQuery(document).scrollTo(navItemUrl,500);
375    });
376}
377
378function filterButtonsRegister(){
379    // Adds active class to "all" button
380    jQuery('.ts-filters > li:first').addClass('active');
381
382    // Code to change the .active class on click
383    jQuery('.ts-filters > li a').click(function(e){
384        e.preventDefault();
385
386        var thisElem = jQuery(this);
387        jQuery('.ts-filters > li.active').removeClass('active');
388        thisElem.parent().addClass('active');
389        return false;
390    });
391}
392
393function hidePreloader(){
394    // Animate the proloader after the page has been loaded
395    setTimeout(function () {
396        jQuery('.ts-page-loading').addClass('ts-page-loading-animate');
397    }, 600);
398}
399
400function resizeVideo(iframe_width, iframe_height){
401
402    if(jQuery('.embedded_videos').length){
403        jQuery('.embedded_videos iframe').each(function(){
404            var iframe_width = jQuery(this).width();
405            var iframe_height = jQuery(this).height();
406
407            var iframe_proportion = iframe_width/iframe_height;
408
409            if ( iframe_height > iframe_width){
410                iframe_proportion = jQuery(this).attr('width')/jQuery(this).attr('height');
411            }
412
413            var iframe_parent_width = jQuery(this).parents('.embedded_videos').parent().width();
414            jQuery(this).attr('width',iframe_parent_width);
415            jQuery(this).attr('height',iframe_parent_width/iframe_proportion);
416        });
417
418        jQuery('.embedded_videos .wp-video').each(function(){
419            var iframe = jQuery(this);
420            var iframe_width = jQuery(this).width();
421            var iframe_height = jQuery(this).height();
422            var iframe_proportion = iframe_width/iframe_height;
423
424            var iframe_parent_width = jQuery(this).parents('.embedded_videos').parent().width();
425
426            jQuery(iframe).css('width',iframe_parent_width);
427            jQuery(iframe).css('height',iframe_parent_width/iframe_proportion);
428            jQuery(iframe).find('.wp-video-shortcode').css('width',iframe_parent_width);
429            jQuery(iframe).find('.wp-video-shortcode').css('height',iframe_parent_width/iframe_proportion);
430
431            setTimeout(function(){
432                jQuery(window).trigger('resize');
433            },400);
434
435        });
436    }
437}
438
439function twitterWidgetAnimated(){
440    /*Tweets widget*/
441    var delay = 4000; //millisecond delay between cycles
442
443    function cycleThru(variable, j){
444        var jmax = jQuery(variable + " li").length;
445        jQuery(variable + " li:eq(" + j + ")")
446            .css('display', 'block')
447            .animate({opacity: 1}, 600)
448            .animate({opacity: 1}, delay)
449            .animate({opacity: 0}, 800, function(){
450                if(j+1 === jmax){
451                    j=0;
452                }else{
453                    j++;
454                }
455                jQuery(this).css('display', 'none').animate({opacity: 0}, 10);
456                cycleThru(variable, j);
457            });
458    }
459
460    jQuery('.tweets').each(function(index, val) {
461        //iterate through array or object
462        var parent_tweets = jQuery(val).attr('id');
463        var actioner = '#' + parent_tweets + ' .ts-twitter-container.dynamic .slides_container .widget-items';
464        cycleThru(actioner, 0);
465    });
466}
467
468function activateFancyBox(){
469    if( jQuery("a[rel^='fancybox']").length > 0 ){
470        jQuery("a[rel^='fancybox']").fancybox({
471            prevEffect  : 'none',
472            nextEffect  : 'none',
473            helpers : {
474                title   : {
475                    type: 'outside'
476                },
477                thumbs  : {
478                    width   : 50,
479                    height  : 50
480                }
481            }
482        });
483    }
484}
485
486//Add logo to the center of all menu item list
487function addLogoToMenu(logoContent){
488    var menu_item_number = jQuery(".menu-with-logo > .main-menu > li").length;
489    var middle = Math.round(menu_item_number / 2);
490    jQuery(".menu-with-logo > .main-menu > li:nth-child(" + middle + ")").after(jQuery('<li class="menu-logo">'+logoContent+'</li>'));
491    if (typeof logoContent !== 'undefined') {
492        jQuery(".ts-sticky-menu .main-menu > li:nth-child(" + middle + ")").after(jQuery('<li class="menu-logo">'+logoContent+'</li>'));
493    }
494}
495
496jQuery(document).on('click', '#ts-mobile-menu .trigger', function(event){
497    event.preventDefault();
498    jQuery(this).parent().next().slideToggle();
499});
500
501jQuery(document).on('click', '#ts-mobile-menu .menu-item-has-children > a', function(event){
502    event.preventDefault();
503    if (jQuery(this).next().attr('class').split(' ')[0] === 'ts_is_mega_div') {
504        jQuery(this).next().children().slideToggle();
505    }else{
506        jQuery(this).next().slideToggle();
507    }
508});
509
510jQuery(document).on('click', '.ts-vertical-menu .menu-item-has-children > a', function(event){
511    event.preventDefault();
512    jQuery(this).parent().toggleClass('collapsed');
513    jQuery(this).next().slideToggle();
514});
515
516/* This function aligns the vertical center elements */
517function alignElementVerticalyCenter(){
518    var container = jQuery('.site-section');
519
520    jQuery(container).each(function(){
521        if( jQuery(this).hasClass('ts-fullscreen-row') ){
522            var windowHeight = jQuery(window).height();
523            var containerHeight = windowHeight;
524        }else{
525            var windowHeight = '100%';
526            var containerHeight = jQuery(this).outerHeight();
527        }
528
529        var innerContent = jQuery(this).find('.container').height();
530        var insertPadding = Math.round((containerHeight-innerContent)/2);
531
532        if( jQuery(this).attr('data-alignment') == 'middle' && jQuery(this).hasClass('ts-fullscreen-row') ){
533            jQuery(this).css({'padding-top':insertPadding,'padding-bottom':insertPadding,'min-height':windowHeight});
534        }else if( jQuery(this).attr('data-alignment') == 'top' && jQuery(this).hasClass('ts-fullscreen-row') ){
535            jQuery(this).css('min-height',windowHeight);
536        }else if( jQuery(this).attr('data-alignment') == 'bottom' && jQuery(this).hasClass('ts-fullscreen-row') ){
537            jQuery(this).css({'width':'100%','height':containerHeight,'position':'relative','min-height':windowHeight});
538            jQuery(this).children('.container').css({'width':'100%','height':'100%'});
539            jQuery(this).find('.row-align-bottom').css({'position':'absolute','width':'100%','bottom':'0'});
540        }
541    });
542
543    // align the elements vertically in the middle for banner box
544    if( jQuery('.ts-banner-box').length > 0 ){
545        jQuery('.ts-banner-box').each(function(){
546            var containerHeight = jQuery(this).outerHeight();
547            var innerContent = jQuery(this).find('.container').height();
548            var insertPadding = Math.round((containerHeight-innerContent)/2);
549
550            jQuery(this).css({'padding-top':insertPadding,'padding-bottom':insertPadding});
551        });
552    }
553
554}
555
556function alignMegaMenu(){
557    setTimeout(function(){
558        if ( jQuery('.main-menu').length > 0 ) {
559            jQuery('.main-menu').each(function(){
560                if( !jQuery(this).parent().hasClass('mobile_menu') ){
561                    var thisElem = jQuery(this).find('.is_mega .t
561s_is_mega_div');
562                    if ( jQuery(thisElem).length > 0 ) {
563                        var windowWidth = jQuery(window).width();
564                        var thisElemWidth = jQuery(thisElem).outerWidth();
565                        jQuery(thisElem).removeAttr('style');
566                        var menuOffset = jQuery(thisElem).offset().left;
567                        var result = Math.round((windowWidth-thisElemWidth)/2);
568
569                        var result2 = result - menuOffset;
570                        jQuery(thisElem).css('left',result2);
571                    };
572                }
573            });
574        };
575    },100);
576}
577
578function fb_comments_width(){
579    setTimeout(function(){
580        jQuery('#comments .fb-comments').css('width','100%');
581        jQuery('#comments .fb-comments > span').css('width','100%');
582        jQuery('#comments .fb-comments > span > iframe').css('width','100%');
583    },300);
584}
585
586function startCounters(){
587    
588    jQuery('.ts-counters').each(function(){
589
590        var current = jQuery(this);
591        var $chart = current.find('.chart');
592        var $cnvSize = (jQuery(this).data('counter-type') == 'with-track-bar') ? 160 : 'auto';
593        var bar_color = current.attr('data-bar-color');
594        var track_color = '#fff';
595
596        if( bar_color == 'transparent' ) track_color = false;
597        
598        $chart.easyPieChart({
599            animate: 2000,
600            scaleColor: false,
601            barColor: bar_color,
602            trackColor: track_color,
603            size: $cnvSize,
604            lineWidth: 10,
605            lineCap: 'square',
606            onStep: function(from, to, percent) {
607                jQuery(this.el).find('.percent').text(Math.round(percent)).css({
608                    "line-height": $cnvSize+'px',
609                    width: $cnvSize
610                })
611            }
612        });
613
614    });
615
616}
617
618/* Running functions on page load */
619jQuery(window).on('load resize orientationchange', function(){
620    alignMegaMenu();
621});
622
623function showMosaic(){
624    jQuery('.mosaic-view').each(function(){
625        if(jQuery(this).hasClass('fade-effect')){
626            jQuery(this).find('.scroll-container > div').each(function(index){
627                var thisElem = jQuery(this);
628                var parentOffset = thisElem.parent().parent().parent().parent().offset().left;
629                var parentWidth = thisElem.parent().parent().parent().parent().outerWidth();
630
631                if( !thisElem.hasClass('shown') && thisElem.offset().left < parentOffset+parentWidth ){
632                    thisElem.delay(index*2).animate({opacity:1},1000).addClass('shown');
633                }
634            });
635        }
636    });
637}
638
639function getFrameSize(content){
640    
641    var frame = jQuery(content),
642        new_iframe_url = frame.attr('src').split('?feature=oembed'),
643        videoLink = new_iframe_url[0],
644        videoWidth = frame.width(),
645        videoHeight = frame.height(),
646        container = jQuery(".video-container").width(),
647        calc = parseFloat(parseFloat(videoWidth/videoHeight).toPrecision(1)),
648        frameHeight = parseInt(container/calc)
649
650    var frameOptions = {
651        iframe:frame,
652        videourl:videoLink,
653        iwidth:container,
654        iheight:frameHeight
655    }
656    return frameOptions
657}
658function autoPlayVideo(){
659    var content = jQuery('#post-video').find('iframe');
660    if(content.length != 0 && content.length > 0){
661        var option = getFrameSize(content);
662    }
663
664    if ( option.videourl.indexOf('youtube') >= 0 ){
665        var videoid = option.videourl.match(/(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)\/embed\/([^\s&]+)/);
666    if(videoid == null) {
667       alert('Video [id] not available!');
668    }
669    }else if( option.videourl.indexOf('vimeo') >= 0 ){
670        var videoid = option.videourl.match(/(?:https?:\/{2})?(?:w{3}\.)?player\.vimeo\.com\/video\/([0-9]*)/);
671    if(videoid == null) {
672       alert('Video [id] not available!');
673    }
674    }else{
675        alert('No valid video url!');
676    };
677
678    jQuery('.overimg').css("display","none");
679    option.iframe.css('display','block').attr("src",option.videourl+'?autoplay=1');
680}
681
682
683function getVideoThumb(){
684    
685    var content = jQuery('#post-video').find('iframe');
686
687    // ----- If you want to get the video feature image, decomment the code below ------
688    // if(content.length != 0 && content.length > 0){
689    //     var iframe = jQuery('#post-video iframe'),
690    //         new_iframe_url = iframe.attr('src').split('?feature=oembed'),
691    //         videoLink = new_iframe_url[0];
692
693    //     jQuery('.over-image').empty();
694
695    //     if ( videoLink.indexOf('youtube') >= 0 ){
696    //         var videoid = videoLink.match(/(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)\/embed\/([^\s&]+)/);
697
698    //         jQuery('.over-image').append('<img src="http://img.youtube.com/vi/'+videoid[1]+'/maxresdefault.jpg"/>');
699
700    //     }else if( videoLink.indexOf('vimeo') >= 0 ){
701    //         var videoid = videoLink.match(/(?:https?:\/{2})?(?:w{3}\.)?player\.vimeo\.com\/video\/([0-9]*)/);
702
703    //         jQuery.getJSON('http://vimeo.com/api/v2/video/'+videoid[1]+'.json?callback=?',{format:"json"},function(data,status){
704    //             var videourl=data[0].url,
705    //             largeThumb=data[0].thumbnail_large,
706    //             raw=largeThumb.split('_'),
707    //             urlsnip=raw[0],
708    //             hdThumb=urlsnip+'_1280.jpg';
709    //             jQuery('.over-image').append('<img src="'+hdThumb+'"/>');
710    //         });
711    //     };
712    // }
713}
714
715function videoPostShow(){
716
717    if ( jQuery('.video-post-open').prev().height() <= 120 ){
718        jQuery('.video-post-open').hide();
719        jQuery('.video-post-open').prev().find('.content-cortina').hide();
720    } else{
721        jQuery('.video-post-open').prev().addClass('content-is-big');
722    }
723
724    jQuery('.video-post-open').click(function(){
725        var element = jQuery(this);
726
727        // Hide the details button if content is smaller
728
729
730
731        // If show less
732        if ( jQuery(element).hasClass('opened') ){
733            jQuery(element).prev().css('height', '100px');
734            jQuery(element).prev().find('.content-cortina').show();
735            jQuery(element).find('i.icon-up').removeClass('icon-up').addClass('icon-down');
736            jQuery(element).removeClass('opened');
737        }
738
739        // If show more
740        else if ( !jQuery(element).hasClass('opened') ){
741            jQuery(element).prev().css('height','auto');
742            jQuery(element).prev().find('.content-cortina').hide();
743            jQuery(element).find('i.icon-down').removeClass('icon-down').addClass('icon-up');
744            jQuery(element).addClass('opened');
745        }
746        return false;
747    });
748}
749
750function singleVideoResize(){
751    jQuery('.video-single-resize').click(function(){
752        var container = jQuery('.featured-image.video-featured-image > .container');
753        var iframe = jQuery(container).find('iframe');
754        var is_iframe = true;
755
756        if( jQuery(iframe).length <= 0 ){
757            iframe = jQuery(container).find('.wp-video');
758            is_iframe = false;
759            jQuery(iframe).animate({opacity: 0},300);
760        }
761        var element = jQuery(this);
762
763        var iframe_width = jQuery(iframe).width();
764        var iframe_height = jQuery(iframe).height();
765        var iframe_proportion = iframe_width/iframe_height;
766
767        setTimeout(function(){
768            // If make smaller
769            if ( !jQuery(container).hasClass('is-smaller') ) {
770                jQuery(container).addClass('is-smaller');
771                jQuery(element).removeClass('in').addClass('out');
772                jQuery(element).find('i:last-child').removeClass('icon-left').addClass('icon-right');
773                jQuery(element).find('i:first-child').removeClass('icon-right').addClass('icon-left');
774            }
775            else if( jQuery(container).hasClass('is-smaller') ){
776                jQuery(container).removeClass('is-smaller');
777                jQuery(element).removeClass('out').addClass('in');
778                jQuery(element).find('i:first-child').removeClass('icon-left').addClass('icon-right');
779                jQuery(element).find('i:last-child').removeClass('icon-right').addClass('icon-left');
780            }
781
782            var iframe_parent_width = jQuery(iframe).parents('.embedded_videos').parent().width();
783            jQuery(iframe).css('width',iframe_parent_width);
784            jQuery(iframe).css('height',iframe_parent_width/iframe_proportion);
785            jQuery(iframe).find('.wp-video-shortcode, .mejs-layer').css('width',iframe_parent_width);
786            jQuery(iframe).find('.wp-video-shortcode, .mejs-layer').css('height',iframe_parent_width/iframe_proportion);
787            jQuery(iframe).find('.mejs-time-rail').css('width',iframe_parent_width);
788        },400);
789
790        setTimeout(function(){
791            jQuery(window).trigger('resize');
792            jQuery(iframe).animate({opacity: 1},150);
793        },700);
794
795        return false;
796    });
797}
798
799
800function ts_video_view(){
801
802    jQuery('.ts-featured-area .nav-tabs li').on('click', function(){
803        jQuery('.ts-featured-area .nav-tabs li.active').removeClass('active');
804        setTimeout(function(){
805            // resizeVideo();
806        },400);
807    });
808
809    jQuery("li.has-submenu[role='item']").on("click", function (e){
810        e.preventDefault();
811        jQuery(this).toggleClass('openned');
812    });
813}
814
815/* ***
816* Count down element
817*/
818function ts_count_down_element() {
819    // find all the countdown on the page
820
821    var countdowns = jQuery('.ts-countdown');
822
823    countdowns.each(function(index) {
824        // save contect
825        var ctx = jQuery(this);
826
827        // get date and time
828        var countdown_data = ctx.find('.time-remaining'),
829            date = countdown_data.data('date'),
830            time = countdown_data.data('time');
831
832        // get dom elements of the countdown
833        var $days = ctx.find('.ts-days'),
834            $hours = ctx.find('.ts-hours'),
835            $minutes = ctx.find('.ts-minutes'),
836            $seconds = ctx.find('.ts-seconds');
837
838        // start the countdown
839        var days, hours, minutes, seconds, sec_remaining, date_diff;
840
841        start_countdown();
842
843        function start_countdown(){
844            var curr_date = new Date(),
845                event_date = new Date(date + ' ' + time);
846
847            if ( curr_date > event_date ) {
848                ctx.remove();
849                return;
850            }
851
852            date_diff =  Math.abs(Math.floor( (event_date - curr_date) / 1000));
853
854            days = Math.floor( date_diff / (24*60*60) );
855            sec_remaining = date_diff - days * 24*60*60;
856
857            hours = Math.floor( sec_remaining / (60*60) );
858            sec_remaining = sec_remaining - hours * 60*60;
859
860            minutes = Math.floor( sec_remaining / (60) );
861            sec_remaining = sec_remaining - minutes * 60;
862
863            $days.text( days );
864            $hours.text( hours );
865            $minutes.text( minutes );
866            $seconds.text( sec_remaining );
867
868            setTimeout(start_countdown, 1000);
869        }
870    });
871}
872
873function ts_fullscreen_scroll_btn(){
874    var container = jQuery('.site-section'),
875        scroll = jQuery('.site-section').attr('data-scroll-btn');
876
877    if ( scroll === 'yes' ) {
878        container.find('.ts-scroll-down-btn > a').on('click', function(e){
879            e.preventDefault();
880
881            jQuery('html, body').animate({
882
883                scrollTop: jQuery(this).parents('.site-section').outerHeight()
884
885            }, 1000)
886        })
887    };
888}
889
890
891/* ******************************* */
892/*          Video Carousel         */
893/* ******************************* */
894
895(function($) {
896    $.fn.ts_video_carousel = function(options) {
897        var ts_slider_options = $.extend({
898            transition: 700
899        }, options);
900
901        var $context = $(this),
902            $slides = $(this).find('.slides'),
903            $slide = $slides.children('li'),
904            $nav_arrows = null;
905
906        var viewport = $(window).width(),
907            slide_width = $slide.eq(0).outerWidth(true),
908            current = 0,
909            ts_delay = null;
910
911        // get the height of the slide thumb ( afte the iframe has been resized )
912        $(window).load(function(){
913            if ( $nav_arrows !== null){
914                $nav_arrows.css({ 'height': $slide.find('.thumb').height() });
915            }
916        });
917
918        $(window).resize(function(){
919            // delay the calculation of the viewport on resize
920            if ( ts_delay !== null ){
921                clearTimeout(ts_delay);
922            }
923
924            ts_delay = setTimeout(function(){
925                viewport = $(window).width();
926                if ( $nav_arrows !== null){
927                    $nav_arrows.css({ 'height': $slide.find('.thumb').height() });
928                }
929                ts_setWidths();
930            }, 400);
931        });
932
933        // create navigations
934        (function ts_createElements(){
935            var navigations =  '<div class="nav-arrow prev"><span class="nav-icon icon-left"></span></div>\
936                                <div class="nav-arrow next"><span class="nav-icon icon-right"></span></div>';
937            $slides.after(navigations);
938        })();
939
940        // set initial states for slider elements
941        (function ts_video_slider_init(){
942            $slides.width( slide_width * $slide.size() );
943            $slide.eq(0).addClass('current-active');
944            $nav_arrows = $context.find('.nav-arrow');
945            $nav_arrows.eq(0).addClass('fade-me');
946            ts_setWidths();
947        })();
948
949        function ts_setWidths(){
950            if ( viewport < slide_width ) {
951                $slide.width( viewport );
952                slide_width = viewport;
953
954                $slide.css( {
955                    'left': slide_width * current * -1
956                });
957            } else {
958                $slide.removeAttr('style');
959                slide_width = $slide.width();
960
961                $slide.css( {
962                    'left': slide_width * current * -1
963                });
964            }
965
966            if ( viewport < $context.parent('.ts-video-slider-wrap').width() ) {
967                $context.parent('.ts-video-slider-wrap').width(viewport);
968            } else {
969                $context.parent('.ts-video-slider-wrap').removeAttr('style');
970            }
971        };
972
973        $slide.on( 'click', function(){
974            if ( $(this).index() < current ){
975                $slide.eq(current).removeClass('current-active');
976                current--;
977
978            } else if( $(this).index() > current) {
979                $slide.eq(current).removeClass('current-active');
980                current++;
981            }
982            ts_changeSlide()
983        });
984
985        $nav_arrows.on('click', function(){
986            if ( $(this).hasClass('next') ) {
987                if ( current !== $slide.size() - 1) {
988                    $slide.eq(current).removeClass('current-active');
989                    current++;
990                    $nav_arrows.eq(0).removeClass('fade-me');
991                    ts_changeSlide();
992                }
993                if ( $nav_arrows.eq(0).hasClass('fade-me') ){
994                    $nav_arrows.eq(0).removeClass('fade-me');
995                }
996            }
997            else if( $(this).hasClass('prev') ){
998                if ( parseFloat($slide.eq(0).css('left').replace( 'px', '')) < 0 && current > 0 ) {
999                    $slide.eq(current).removeClass('current-active');
1000                    current--;
1001                    ts_changeSlide();
1002                }
1003
1004                if ( $nav_arrows.eq(1).hasClass('fade-me') ){
1005                    $nav_arrows.eq(1).removeClass('fade-me');
1006                }
1007            }
1008        });
1009
1010        function ts_changeSlide(){
1011            $slide.animate({
1012                'left': ( slide_width ) * current * -1
1013            }, {
1014                duration: ts_slider_options.transition,
1015                complete: function() {
1016                    $slide.eq(current).addClass('current-active');
1017                }
1018            });
1019
1020            if ( current === 0){
1021                $nav_arrows.eq(0).addClass('fade-me');
1022            }
1023            else if( current === $slide.size() - 1){
1024                $nav_arrows.eq(1).addClass('fade-me');
1025            }
1026        }
1027    }
1028})(jQuery);
1029
1030function ts_scroll_top(){
1031    jQuery(window).scroll(function() {
1032        if(jQuery(this).scrollTop() > 200){
1033            jQuery('#ts-back-to-top').stop().animate({
1034                bottom: '30px'    
1035            }, 500);
1036        }else{
1037            jQuery('#ts-back-to-top').stop().animate({
1038               bottom: '-100px'    
1039            }, 500);
1040        }
1041    });
1042    jQuery('#ts-back-to-top').on('click',function() {
1043        jQuery('html, body').stop().animate({
1044           scrollTop: 0
1045        }, 500, function() {
1046            jQuery('#ts-back-to-top').stop().animate({
1047                bottom: '-100px'    
1048            }, 500);
1049        });
1050    });
1051}
1052
1053jQuery(document).ready(function($){
1054    ts_scroll_top();
1055
1056    if( jQuery(".ts-map-create").length > 0 ){
1057        google.maps.event.addDomListener(window, "load", initialize);
1058    }
1059    
1060    //Count To
1061    $.fn.countTo = function() {
1062
1063        var element = this;
1064
1065        function execute() {
1066
1067            element.each(function(){
1068
1069                var item = $(this).find('.countTo-item');
1070
1071                item.each(function(){
1072
1073                    var current = $(this),
1074                        percent = current.find('.skill-level').attr('data-percent');
1075                    
1076                    if ( !current.hasClass('animated') ) {
1077                        current.find('.skill-title').css({'color' : 'inherit'});
1078                        if( element.hasClass('ts-horizontal-skills') ){
1079                            current.find('.skill-level').animate({'width' : percent+'%'}, 800);
1080                        } else {
1081                            current.find('.skill-level').animate({'height' : percent+'%'}, 800);
1082                        }
1083                        current.addClass('animated');
1084                    }
1085
1086                    if ( current.hasClass('animated') && element.attr('data-percentage') == 'true' && current.find('.percent').length < 1 ) {
1087                        current.append('<span class="percent">'+percent+'%'+'</span>');
1088                        current.find('.percent').css({'left' : percent+'%'}).delay(1600).fadeIn();
1089                    };
1090
1091                    if ( percent == 100 ) {
1092                        item.addClass('full');
1093                    };
1094
1095                })
1096
1097            })
1098
1099        }
1100
1101        execute();
1102
1103        return this;
1104    };
1105
1106    ts_set_like();
1107
1108    /* Widget Tabs */
1109
1110    jQuery('.tabs-control > li > a').click(function () {
1111        var this_id = jQuery(this).attr('href'); // Get the id of the div to show
1112        var tabs_container_divs = '.' + jQuery(this).parent().parent().next().attr('class') + ' >  div'; // All of elements to hide
1113        jQuery(tabs_container_divs).hide(); // Hide all other divs
1114        jQuery(this).parent().parent().next().find(this_id).show(); // Show the selected element
1115        jQuery(this).parent().parent().find('.active').removeClass('active'); // Remove '.active' from elements
1116        jQuery(this).addClass('active'); // Add class '.active' to the active element
1117        return false;
1118    });
1119
1120    jQuery('.toggle_title').click(function () {
1121        jQuery(this).next().slideToggle('fast');
1122        jQuery(this).find('.toggler').toggleClass('toggled');
1123    });
1124
1125    jQuery('.tabs-switch li a').click(function () {
1126        var tab_id = jQuery(this).attr('href');
1127        if (jQuery(this).parent().parent().next().find(tab_id).is(':hidden')) {
1128            jQuery(this).parent().parent().find('li').removeClass('active');
1129            jQuery(this).parent().addClass('active');
1130            jQuery(this).parent().parent().next().find('div').hide('fast');
1131        }
1132        jQuery(this).parent().parent().next().find(tab_id).show('fast');
1133        return false;
1134    });
1135
1136    var $container = jQuery('.shortcode_accordion > div'),
1137        $trigger = jQuery('.shortcode_accordion > h3');
1138    $container.hide();
1139    $trigger.first().addClass('toggled').next().show();
1140    $trigger.on('click', function (e) {
1141        if (jQuery(this).next().is(':hidden')) {
1142            $trigger.removeClass('toggled').next().slideUp(300);
1143            jQuery(this).toggleClass('toggled').next().slideDown(300);
1144        }
1145        e.preventDefault();
1146    });
1147
1148    jQuery('.shortcode_infobox .close').click(function () {
1149        jQuery(this).parent().fadeOut(500);
1150    });
1151
1152    if(jQuery('#post-video').find('iframe').length > 0){
1153        var option = getFrameSize('#post-video iframe');
1154    }
1155
1156    jQuery('.video-single-resize').on('click', function(){
1157        var date = new Date();
1158        date.setTime(date.getTime() + (1 * 60 * 1000));
1159        if( jQuery('.video-featured-image > .container').hasClass('is-smaller') != true ){
1160            var videoType = 'small';
1161        }else{
1162            var videoType = 'big';
1163        }
1164        jQuery.cookie('ts_single_video_resize_type', videoType, { expires: date, path:'/' });
1165
1166        ExpireCookie(1, 'ts_single_video_resize');
1167    });
1168
1169    jQuery('a.videoPlay').on('click',function(event){
1170        event.preventDefault();
1171        setTimeout(function(){
1172            autoPlayVideo();
1173        },500)
1174    });
1175
1176    jQuery('#searchbox .search-trigger').on('click', function(e){
1177        e.preventDefault();
1178        jQuery(this).next().addClass('active');
1179    })
1180
1181    jQuery('#searchbox .search-close').on('click', function(e){
1182        e.preventDefault();
1183        jQuery(this).parent().removeClass('active');
1184    })
1185
1186    jQuery("body").keydown(function (e) {
1187
1188        if(e.which == 27){
1189            jQuery("#searchbox .search-close").parent().removeClass('active');
1190        }
1191    })
1192
1193    jQuery('.single .post-rating .rating-items > li').each(function(){
1194        var bar_width = jQuery(this).find('.bar-progress').data('bar-size');
1195
1196        jQuery(this).find('.bar-progress').css({width: bar_width+'%'});
1197    })
1198
1199
1200    jQuery('.share-options li').click(function(){
1201        var social = jQuery(this).attr('data-social');
1202        var postId = jQuery(this).attr('data-post-id');
1203        var socialCount = jQuery(this).find('.how-many');
1204
1205        var data = {
1206                action      : 'ts_set_share',
1207                ts_security : Esquise.ts_security,
1208                postId      : postId,
1209                social      : social
1210            };
1211
1212        jQuery.post(Esquise.ajaxurl, data, function(response){
1213
1214            if( response && response !== '-1' ){
1215                jQuery(socialCount).text(response);
1216                jQuery('.counted').text(parseInt(jQuery('.counted').text()) + 1);
1217            }
1218        });
1219    });
1220
1221    // Show more button on share
1222    jQuery('.share-options .show-more').on('click', function(e){
1223        e.preventDefault();
1224        if ( jQuery(this).children().attr('data-tooltip') !== 'hide' ) {
1225            jQuery(this).children().attr('data-tooltip','hide');
1226        } else {
1227            jQuery(this).children().attr('data-tooltip','show more');
1228        };
1229        var this_item = jQuery(this).parent().find('.share-menu-item');
1230        this_item.each(function(){
1231            if( !jQuery(this).hasClass('shown') ){
1232                jQuery(this).toggleClass('hidden');
1233            }
1234        })
1235    });
1236
1237    $('.ts-vertical-menu').find('.menu-item-has-children').each(function(){
1238        var url_link = $(this).children('a').attr('href');
1239        $(this).children('a').attr('href','#');
1240        $(this).append('<span class="menu-item-url-link"><a href="'+url_link+'" title="View page"><i class="icon-link"></i></a></span>')
1241    });
1242
1243    $('.menu-item-type-taxonomy').each(function(){
1244        if($(this).find('.ts_is_mega_div').length !== 0){
1245            $(this).addClass('menu-item-has-children is_mega');
1246        }
1247    })
1248
1249    $('.ts-user-login-modal').find('form > p').each(function(){
1250        var inputResult = $(this).children('label').html();
1251        $(this).children('input').attr('placeholder',inputResult);
1252    })
1253    $('.ts-user-login-modal').find('.login-submit input[type="submit"]').attr('class','btn medium active');
1254
1255    $('a[data-toggle="tab"]').on('shown.bs.tab', function(e){
1256        if ( $(this).attr('data-video-type') == 'upload' ) {
1257            $('#ts-video-type').val('upload');
1258        } else{
1259            $('#ts-video-type').val('url');
1260        }
1261    });
1262
1263    function ts_ajax_load_more(){
1264
1265        $('.ts-pagination-more').click(function(){
1266            
1267            var loop            = parseInt( $(this).attr('data-loop') );
1268            var args            = $(this).attr('data-args');
1269            var paginationNonce = $(this).find('input[type="hidden"]').val();
1270            var loadmoreButton  = $(this);
1271            var $container      = $(this).prev();
1272
1273            // Show preloader
1274            $('#ts-loading-preload').show();
1275            loadmoreButton.attr('data-loop', loop + 1);
1276
1277            jQuery.post(Esquise.ajaxurl, {
1278                    action         : 'ts_pagination',
1279                    args           : args,
1280                    paginationNonce: paginationNonce,
1281                    loop           : loop
1282                },  function(data){
1283                        if( data !== '0' ){
1284                            if( $container.hasClass('ts-filters-container') ){
1285                                var data_content = $(data).appendTo($container);
1286                                $container.isotope('appended', $(data_content));
1287                                setTimeout(function(){
1288                                    $container.isotope('layout');
1289                                },1200);
1290                            }else{
1291                                $container.append($(data));
1292                            }
1293
1294                            if( $container.hasClass('ts-filters-container') ){
1295                                if( jQuery("img.lazy").length > 0 ){
1296                                    jQuery("img.lazy").lazyload({
1297                                        effect : "fadeIn",
1298                                        load : function(){
1299                                            setTimeout(function(){
1300                                                $container.isotope('layout');
1301                                            }, 1200);
1302                                        }
1303                                    });
1304                                }else{
1305                                    $container.isotope('layout');
1306                                }
1307
1308                            }else{
1309                                if( jQuery("img.lazy").length > 0 ){
1310                                    jQuery("img.lazy").lazyload({
1311                                        effect : "fadeIn"
1312                                    });
1313                                }
1314                            }
1315                        }else{
1316                            loadmoreButton.remove();
1317                        }
1318                        // Hide the preloader
1319                        $('#ts-loading-preload').hide();
1320                    }
1321            );
1322        });
1323    }
1324    ts_ajax_load_more();
1325
1326    //circle share effect on single video page
1327    $('.post-share-box-circle').find('label').on('click', function(e){
1328        e.preventDefault();
1329        $(this).toggleClass('shown');
1330    });
1331
1332    function ts_send_date_ajax(id){
1333
1334        $(document).on('click', '.contact-form-submit', function(event) {
1335            event.preventDefault();
1336            
1337            var form         = $(this).closest('form'),
1338                name         = form.find('.contact-form-name'),
1339                email        = form.find('.contact-form-email'),
1340                subject      = form.find('.contact-form-subject'),
1341                message      = form.find('.contact-form-text'),
1342                emailRegEx   = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
1343                errors       = 0,
1344                custom_field = form.find('.ts_contact_custom_field'),
1345                data         = {},
1346                this_element = jQuery(this);
1347
1348            String.prototype.trim = function() {
1349                return this.replace(/^\s+|\s+$/g,"");
1350            };
1351
1352            if ( emailRegEx.test(email.val()) ) {
1353                email.removeClass('invalid');
1354            } else {
1355                email.addClass('invalid');
1356                errors = errors + 1;
1357            }
1358
1359            jQuery(custom_field).each(function(i,val){
1360                if(jQuery(this).hasClass('contact-form-require')){
1361                    if (jQuery(this).val().trim() !== '') {
1362                        jQuery(this).removeClass('invalid');
1363                    } else {
1364                        jQuery(this).addClass('invalid');
1365                        errors = errors + 1;
1366                    }
1367                }
1368            });
1369
1370            if (name.val().trim() !== '') {
1371                name.removeClass('invalid');
1372            } else {
1373                name.addClass('invalid');
1374                errors = errors + 1;
1375            }
1376
1377
1378            if ( subject.length !== 0 ) {
1379                if (subject.val().trim() !== '') {
1380                    subject.removeClass('invalid');
1381                } else {
1382                    subject.addClass('invalid');
1383                    errors = errors + 1;
1384                }
1385            }
1386
1387            if (message.val().trim() !== '') {
1388                message.removeClass('invalid');
1389            } else {
1390                message.addClass('invalid');
1391                errors = errors + 1;
1392            }
1393            
1394            if ( errors === 0 ) {
1395
1396                data['action']  = 'esquise_contact_me';
1397                data['token']   = Esquise.contact_form_token;
1398                data['name']    = name.val().trim();
1399                data['from']    = email.val().trim();
1400                data['subject'] = (subject.length) ? subject.val().trim() : '';
1401                data['message'] = message.val().trim();
1402                data['custom_field'] = new Array();
1403
1404                jQuery(custom_field).each(function(i,val){
1405                    var title = jQuery(this).next().val();
1406                    var value = jQuery(this).val();
1407                    var require = jQuery(this).next().next().val();
1408                    var new_item = {value : value, title: title, require: require};
1409                    data['custom_field'].push(new_item);
1410                });
1411
1412                $.post(Esquise.ajaxurl, data, function(data, textStatus, xhr) {
1413                    form.find('.contact-form-messages').html('');
1414                    console.log(data.status);
1415                    if ( data !== '-1' ) {
1416                        if ( data.status === 'ok' ) {
1417                            form.find('.contact-form-messages').removeClass("hidden").html(Esquise.contact_form_success).addClass('success');
1418
1419                            jQuery(this_element).attr('disabled', 'disabled');
1420                            form.find("input, textarea").not(".contact-form-submit").val('');
1421
1422                        } else {
1423                            form.find('.contact-form-messages').removeClass("hidden").html('<div class="invalid">' + data.message + '</div>');
1424                        }
1425
1426                        if ( typeof data.token !== "undefined" ) {
1427                            Esquise.contact_form_error = data.token;
1428                        }
1429
1430                    } else {
1431                        form.addClass('hidden');
1432                        form.find('.contact-form-messages').html(Esquise.contact_form_error);
1433                        $(clickElement).removeAttr('disabled');
1434                    }
1435                });
1436            }
1437        });
1438    }
1439    ts_send_date_ajax();
1440
1441    jQuery(document).on('click', '.ts-get-calendar', function(){
1442        var tsYear  = jQuery(this).attr('data-year');
1443        var tsMonth = jQuery(this).attr('data-month');
1444        var classSize = 'ts-big-calendar';
1445
1446        if(jQuery(this).parent().find('.ts-events-calendar').hasClass('ts-small-calendar')){
1447            classSize = 'ts-small-calendar';
1448        }
1449
1450        var tsCalendar = jQuery(this).parent();
1451        var data = {};
1452
1453        data = {
1454            action  : 'ts_draw_calendar',
1455            nonce   : Esquise.ts_security,
1456            tsYear  : tsYear,
1457            tsMonth : tsMonth,
1458            size    : classSize
1459        };
1460
1461        jQuery.post(Esquise.ajaxurl, data, function(response) {
1462
1463            if( response ) {
1464                jQuery(tsCalendar).html(response);
1465            }
1466        });
1467        return false;
1468    });
1469
1470    jQuery('.ts-select-by-category li').click(function(){
1471
1472        var idCategory = jQuery(this).attr('data-category-li');
1473
1474        jQuery('.ts-select-by-category li').each(function(){
1475            if( jQuery(this).hasClass('active') ){
1476                jQuery(this).removeClass('active');
1477            }
1478        })
1479
1480        jQuery(this).addClass('active');
1481
1482        jQuery(this).closest('section').find('.ts-tabbed-category').each(function(){
1483            jQuery(this).css('display', 'none').removeClass('shown');
1484        });
1485
1486        jQuery(this).closest('section').find('.ts-tabbed-category').each(function(){
1487            var categories = jQuery(this).attr('data-category').split('\\');
1488            for(var category in categories){
1489                if( idCategory == categories[category] ){
1490                    var thisHtml = jQuery(this).css('display', '').get(0).outerHTML;
1491                    jQuery('[data-category-div="' + idCategory + '"]').find('.ts-cat-row').append(thisHtml);
1492                    jQuery(this).remove();
1493                }
1494            }
1495        });
1496    });
1497    
1498    if( jQuery('.ts-video-fancybox').length > 0 ){
1499        jQuery('.ts-video-fancybox').fancybox({
1500            maxWidth    : 800,
1501            maxHeight   : 600,
1502            fitToView   : false,
1503            width       : '70%',
1504            height      : '70%',
1505            autoSize    : false,
1506            closeClick  : false,
1507            openEffect  : 'none',
1508            closeEffect : 'none'
1509        });
1510    }
1511
1512});
1513
1514var map, mapAddress, latlng, mapLat, mapLng, mapType, mapStyle, mapZoom,
1515    mapTypeCtrl, mapZoomCtrl, mapScaleCtrl, mapScroll, mapDraggable, mapMarker;
1516var style = '';
1517
1518    var infinite_loading = false;
1519    jQuery(window).on('scroll',function() {
1520        jQuery(".ts-infinite-scroll").each(function(){
1521            var thisElem = jQuery(this);
1522            if( thisElem.prev().offset().top + thisElem.parent().height() - 120 < jQuery(window).scrollTop() + jQuery(window).height() && infinite_loading == false ){
1523                
1524                infinite_loading = true;
1525                jQuery(thisElem).trigger("click");
1526                setTimeout(function(){
1527                    infinite_loading = false;
1528                }, 1000)
1529            }
1530        });
1531    });
1532function ts_select_post_by_category(){
1533    jQuery('.ts-select-by-category li:first-child').each(function(){
1534        jQuery(this).trigger('click');
1535    });
1536}
1537
1538function initialize(){
1539    jQuery('.ts-map-create').each(function(){
1540        var element = jQuery(this);
1541        mapAddress = jQuery(element).attr('data-address');
1542        mapLat = jQuery(element).attr('data-lat');
1543        mapLng = jQuery(element).attr('data-lng');
1544        mapStyle = jQuery(element).attr('data-style');
1545        mapZoom = jQuery(element).attr('data-zoom');
1546        mapTypeCtrl = (jQuery(element).attr('data-type-ctrl') === 'true') ? true : false;
1547        mapZoomCtrl = (jQuery(element).attr('data-zoom-ctrl') === 'true') ? true : false;
1548        mapScaleCtrl = (jQuery(element).attr('data-scale-ctrl') === 'true') ? true : false;
1549        mapScroll = (jQuery(element).attr('data-scroll') === 'true') ? true : false;
1550        mapDraggable = (jQuery(element).attr('data-draggable') === 'true') ? true : false;
1551        mapMarker = jQuery(element).attr('data-marker');
1552
1553        if( jQuery(element).attr('data-type') === 'ROADMAP' )
1554            mapType = google.maps.MapTypeId.ROADMAP
1555        else if( jQuery(element).attr('data-type') === 'HYBRID' )
1556            mapType = google.maps.MapTypeId.HYBRID
1557        else if( jQuery(element).attr('data-type') === 'SATELLITE' )
1558            mapType = google.maps.MapTypeId.SATELLITE
1559        else if( jQuery(element).attr('data-type') === 'TERRAIN' )
1560            mapType = google.maps.MapTypeId.TERRAIN
1561        else
1562            mapType = google.maps.MapTypeId.ROADMAP
1563
1564        // How you would like to style the map. 
1565        // This is where you would paste any style found on Snazzy Maps.
1566        if ( mapStyle === 'map-style-essence' ){
1567            style = [{"featureType":"landscape.natural","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#e0efef"}]},{"featureType":"poi","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"hue":"#1900ff"},{"color":"#c0e8e8"}]},{"featureType":"landscape.man_made","elementType":"geometry.fill"},{"featureType":"road","elementType":"geometry","stylers":[{"lightness":100},{"visibility":"simplified"}]},{"featureType":"road","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"water","stylers":[{"color":"#7dcdcd"}]},{"featureType":"transit.line","elementType":"geometry","stylers":[{"visibility":"on"},{"lightness":700}]}]
1568
1569        } else if( mapStyle === 'map-style-subtle-grayscale' ){
1570            style = [{"featureType":"landscape","stylers":[{"saturation":-100},{"lightness":65},{"visibility":"on"}]},{"featureType":"poi","stylers":[{"saturation":-100},{"lightness":51},{"visibility":"simplified"}]},{"featureType":"road.highway","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"road.arterial","stylers":[{"saturation":-100},{"lightness":30},{"visibility":"on"}]},{"featureType":"road.local","stylers":[{"saturation":-100},{"lightness":40},{"visibility":"on"}]},{"featureType":"transit","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"administrative.province","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"labels","stylers":[{"visibility":"on"},{"lightness":-25},{"saturation":-100}]},{"featureType":"water","elementType":"geometry","stylers":[{"hue":"#ffff00"},{"lightness":-25},{"saturation":-97}]}]
1571
1572        } else if( mapStyle === 'map-style-shades-of-grey' ){
1573            style = [{"featureType":"water","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":17}]},{"featureType":"landscape","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":20}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":"#000000"},{"lightness":17}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#000000"},{"lightness":29},{"weight":0.2}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":18}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":16}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":21}]},{"elementType":"labels.text.stroke","stylers":[{"visibility":"on"},{"color":"#000000"},{"lightness":16}]},{"elementType":"labels.text.fill","stylers":[{"saturation":36},{"color":"#000000"},{"lightness":40}]},{"elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":19}]},{"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":"#000000"},{"lightness":20}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":"#000000"},{"lightness":17},{"weight":1.2}]}]
1574
1575        } else if( mapStyle === 'map-style-purple' ){
1576            style = [{"featureType":"all","elementType":"all","stylers":[{"visibility":"simplified"},{"hue":"#bc00ff"},{"saturation":"0"}]},{"featureType":"administrative","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"administrative","elementType":"labels.text.fill","stylers":[{"color":"#e8b8f9"}]},{"featureType":"administrative.country","elementType":"labels","stylers":[{"color":"#ff0000"}]},{"featureType":"administrative.land_parcel","elementType":"labels.text.fill","stylers":[{"visibility":"simplified"}]},{"featureType":"landscape","elementType":"all","stylers":[{"color":"#3e114e"},{"visibility":"simplified"}]},{"featureType":"landscape","elementType":"labels","stylers":[{"visibility":"off"},{"color":"#a02aca"}]},{"featureType":"landscape.natural","elementType":"all","stylers":[{"visibility":"simplified"},{"color":"#2e093b"}]},{"featureType":"landscape.natural","elementType":"labels.text","stylers":[{"color":"#9e1010"},{"visibility":"off"}]},{"featureType":"landscape.natural","elementType":"labels.text.fill","stylers":[{"color":"#ff0000"}]},{"featureType":"landscape.natural.landcover","elementType":"all","stylers":[{"visibility":"simplified"},{"color":"#58176e"}]},{"featureType":"landscape.natural.landcover","elementType":"labels.text.fill","stylers":[{"visibility":"simplified"}]},{"featureType":"poi","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"poi.business","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"road","elementType":"all","stylers":[{"saturation":-100},{"lightness":45}]},{"featureType":"road","elementType":"geometry","stylers":[{"visibility":"simplified"},{"color":"#a02aca"}]},{"featureType":"road","elementType":"labels","stylers":[{"visibility":"simplified"}]},{"featureType":"road","elementType":"labels.text.fill","stylers":[{"color":"#d180ee"}]},{"featureType":"road","elementType":"labels.text.stroke","stylers":[{"visibility":"simplified"}]},{"featureType":"road.highway","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"visibility":"simplified"},{"color":"#a02aca"}]},{"featureType":"road.highway","elementType":"labels","stylers":[{"visibility":"off"},{"color":"#ff0000"}]},{"featureType":"road.highway","elementType":"labels.text","stylers":[{"color":"#a02aca"},{"visibility":"simplified"}]},{"featureType":"road.highway","elementType":"labels.text.fill","stylers":[{"color":"#cc81e7"},{"visibility":"simplified"}]},{"featureType":"road.highway","elementType":"labels.text.stroke","stylers":[{"visibility":"simplified"},{"hue":"#bc00ff"}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#6d2388"}]},{"featureType":"road.arterial","elementType":"labels.text.fill","stylers":[{"color":"#c46ce3"}]},{"featureType":"road.arterial","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"all","stylers":[{"color":"#b7918f"},{"visibility":"on"}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#280b33"}]},{"featureType":"water","elementType":"labels","stylers":[{"visibility":"simplified"},{"color":"#a02aca"}]}];
1577
1578        } else if( mapStyle === 'map-style-best-ski-pros' ){
1579            style = [{"featureType":"administrative","elementType":"labels.text.fill","stylers":[{"color":"#2c3645"}]},{"featureType":"administrative","elementType":"labels.text.stroke","stylers":[{"visibility":"on"}]},{"featureType":"landscape","elementType":"all","stylers":[{"color":"#dcdcdc"}]},{"featureType":"landscape.man_made","elementType":"geometry.stroke","stylers":[{"color":"#476653"}]},{"featureType":"landscape.natural.landcover","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#93d09e"}]},{"featureType":"landscape.natural.terrain","elementType":"labels","stylers":[{"visibility":"on"},{"color":"#0d6f32"}]},{"featureType":"landscape.natural.terrain","elementType":"labels.text.stroke","stylers":[{"visibility":"on"}]},{"featureType":"poi","elementType":"all","stylers":[{"visibility":"on"}]},{"featureType":"poi","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#62bf85"}]},{"featureType":"road","elementType":"all","stylers":[{"saturation":-100},{"lightness":45}]},{"featureType":"road","elementType":"geometry.stroke","stylers":[{"visibility":"on"},{"color":"#95c4a7"}]},{"featureType":"road","elementType":"labels.text","stylers":[{"color":"#334767"}]},{"featureType":"road","elementType":"labels.text.fill","stylers":[{"visibility":"on"},{"color":"#334767"}]},{"featureType":"road.highway","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"road.arterial","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"road.local","elementType":"geometry.stroke","stylers":[{"visibility":"on"},{"color":"#b7b7b7"}]},{"featureType":"road.local","elementType":"labels.text","stylers":[{"visibility":"on"}]},{"featureType":"transit","elementType":"all","stylers":[{"visibility":"on"},{"color":"#364a6a"}]},{"featureType":"transit","elementType":"labels.text.fill","stylers":[{"visibility":"on"},{"color":"#ffffff"}]},{"featureType":"transit","elementType":"labels.text.stroke","stylers":[{"visibility":"on"}]},{"featureType":"transit.station.rail","elementType":"geometry.stroke","stylers":[{"visibility":"on"},{"color":"#535353"}]},{"featureType":"water","elementType":"all","stylers":[{"color":"#3fc672"},{"visibility":"on"}]},{"featureType":"water","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#4d6489"}]},{"featureType":"water","elementType":"labels.text.stroke","stylers":[{"visibility":"off"}]}]
1580
1581        } else {
1582            style = '';
1583        }
1584
1585        latlng = new google.maps.LatLng(mapLat, mapLng);
1586
1587        var mapOptions = {
1588            zoom: parseInt(mapZoom),
1589            center: latlng,
1590            styles: style,
1591            zoomControl: mapZoomCtrl,
1592            scaleControl: mapScaleCtrl,
1593            mapTypeControl: mapTypeCtrl,
1594            scrollwheel: mapScroll,
1595            draggable: mapDraggable,
1596            mapTypeControlOptions: {
1597                style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
1598            },
1599            zoomControlOptions: {
1600                style: google.maps.ZoomControlStyle.SMALL
1601            },
1602            mapTypeId: mapType
1603        }
1604        var idElement = jQuery(element).attr('id');
1605
1606        map = new google.maps.Map(document.getElementById(idElement), mapOptions);
1607
1608        var marker = new google.maps.Marker({
1609            map: map,
1610            icon: mapMarker,
1611            position: latlng,
1612            title: mapAddress
1613        });
1614    });
1615}
1616
1617jQuery(window).load(function() {
1618    initCarousel();
1619    animateArticlesOnLoad();
1620    animateBlocksOnScroll();
1621    visibleBeforeAnimation();
1622    activateStickyMenu();
1623    filterButtonsRegister();
1624    hidePreloader();
1625    twitterWidgetAnimated();
1626    activateFancyBox();
1627    fb_comments_width();
1628    alignElementVerticalyCenter();
1629    showMosaic();
1630    ts_video_view();
1631    alignMegaMenu();
1632    resizeVideo();
1633    videoPostShow();
1634    singleVideoResize();
1635    getVideoThumb();
1636    ts_count_down_element();
1637    ts_fullscreen_scroll_btn();
1638    ts_select_post_by_category();
1639
1640    jQuery('.joyslider').addClass('active');
1641
1642    // If onepage layout - run the onepage menu
1643    if ( ts_onepage_layout == 'yes' ) {
1644        startOnePageNav();
1645    }
1646
1647    jQuery('.panel-heading a[data-toggle="collapse"]').on('click', function(){
1648        var panelCollapse = jQuery(this).parent().next();
1649        if ( panelCollapse.hasClass('in')) {
1650            jQuery(this).find('i').css({
1651                '-webkit-transform': 'rotate(0deg)',
1652                '-o-transform': 'rotate(0deg)',
1653                '-mz-transform': 'rotate(0deg)',
1654                'transform': 'rotate(0deg)'
1655            })
1656        } else {
1657            jQuery(this).find('i').css({
1658                '-webkit-transform': 'rotate(90deg)',
1659                '-o-transform': 'rotate(90deg)',
1660                '-mz-transform': 'rotate(90deg)',
1661                'transform': 'rotate(90deg)'
1662            })
1663        }
1664    });
1665
1666    jQuery('.megaWrapper').each(function(){
1667        if( jQuery(this).hasClass('ts-behold-menu') ){
1668            jQuery(this).removeClass('ts-behold-menu').addClass('ts-mega-menu');
1669        }
1670        jQuery(this).find('.ts_is_mega_div .sub-menu').addClass('ts_is_mega');
1671        jQuery(this).find('.ts_is_mega_div').parent().addClass('is_mega');
1672    });
1673
1674    var all_anchor = jQuery('.ts-article-accordion > .panel-group').find('.panel-title > a');
1675
1676    all_anchor.on('click', function(){
1677        all_anchor.not(this).parent().parent().removeClass('hidden');
1678        jQuery(this).parent().parent().addClass('hidden');
1679    });
1680
1681}); //end load function

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.