PageSourceSearch

https://historyofspain.es/wp-content/themes/videotouch/js/scripting.js?ver=1790298427

js historyofspain.es collected 2026-09-25 01:07:30 UTC 67,676 bytes, 1,828 lines download raw bytes

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

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.