1(function($){ 2 "use strict"; 3 4 window.yotupro = { 5 init : function (){ 6 console.log("yotupro init"); 7 yotuwp.add_action('after_play_video', yotupro.player.actions); 8 yotuwp.add_filter('next_prev', yotupro.player.next_prev); 9 yotuwp.add_action('lightbox_actions', yotupro.player.lightbox_actions); 10 yotuwp.add_action('loadmore-carousel', yotupro.loadmore.carousel); 11 yotuwp.add_action('loadmore-masonry', yotupro.loadmore.masonry); 12 13 /* Masonry */ 14 $('.yotu-mode-masonry').each(function (el){ 15 var obj = $(this); 16 new Masonry( obj.find('ul').get(0), { 17 itemSelector: 'li', 18 columnWidth: 'li' 19 }); 20 }); 21 //big template 22 $(".yotu-videos.yotu-mode-big-left ul, .yotu-videos.yotu-mode-big-right ul").scroll(function () { 23 24 var elm = $(this), 25 lelm = elm.find('.yotu-last:last-child'); 26 27 if (!lelm.get(0)) return; 28 29 var st = elm.scrollTop(), 30 max_point = lelm.get(0).offsetTop - this.offsetTop - $(this).outerHeight() + 50, 31 parent = $(this).closest('.yotu-template-big-left,.yotu-template-big-right'); 32 33 if( st >= max_point){ 34 parent.find('.yotu-pagination').addClass('yotu-scroll-show'); 35 } else if(parent.find('.yotu-pagination').has('yotu-scroll-show')) { 36 parent.find('.yotu-pagination').removeClass('yotu-scroll-show'); 37 } 38 }); 39 40 $("[class*='yotuwp-modal']").click(function(e){ 41 e.preventDefault(); 42 if($(e.target).closest('.yotu-videos, .yotu-pagination').length == 0){ 43 var ytelm = $(e.target).closest('.yotuwp'); 44 ytelm.addClass('yotuwp-modal-hide'); 45 yotuwp.data.players[ytelm.data('yotu')].pauseVideo(); 46 } 47 }); 48 49 $("[class*='yotuwp-rel'], [class^='yotuwp-rel']").click(function(e){ 50 e.preventDefault(); 51 var elmclass = $(this).attr('class'), 52 rel = elmclass.match(/yotuwp-rel-(\S+)/g), 53 modal = $('.'+rel[0].replace('rel', 'modal')); 54 $(modal).css('display', 'block').removeClass('yotuwp-modal-hide'); 55 }); 56 }, 57 58 player : { 59 60 next_prev: function (html_a){ 61 html_a = ['<div class="yotu-lightbox">', 62 '<div class="yotu-lightbox-body">', 63 '<div class="yotu-lightbox-content yotu-wrapper-player">', 64 '<div class="yotu-playing"></div>', 65 '<div class="yotu-player"><div id="yotu-player-modal"></div></div>', 66 '<div class="yotu-playing-status"></div>', 67 '</div>', 68 '<a href="#" class="yotu-lightbox-func" data-func="prev" title="'+yotuwp.l(8)+'"><span class="yotuicon-prev"></span></a>', 69 '<a href="#" class="yotu-lightbox-func" data-func="next" title="'+yotuwp.l(7)+'"><span class="yotuicon-next"></span></a>', 70 '</div>', 71 '<div class="yotu-thumbnails-wrp" data-yotu="modal"><div id="yotu-thumbnails" class="yotu-thumbnails owl-carousel"></div></div>', 72 '<a href="#" class="yotu-lightbox-close" title=""><span class="yotuicon-close"></span></a>', 73 '<div class="yotu-copyright"><a href="http://bit.ly/yotuwp-popup" rel="nofollow" target="_blank">Power by YoutuWP</a></div>', 74 '<div class="yotu-lightbox-overlay"></div>', 75 '</div>']; 76 return html_a; 77 }, 78 79 actions : function (loaded_ids, video, player){ 80 //next, prev 81 for(var i =0; i< loaded_ids.length; i++){ 82 if( 83 loaded_ids[i] == video && 84 yotuwp.player.current.player !== null 85 ){ 86 var next = '', prev = ''; 87 88 if(typeof loaded_ids[i+1] !== 'undefined') next = loaded_ids[i+1]; 89 90 if(i > 0) prev = loaded_ids[i-1]; 91 92 $('#yotu-player-' + player).data('next', next); 93 $('#yotu-player-' + player).data('prev', prev); 94 break; 95 } 96 } 97 }, 98 lightbox_actions : function (obj){ 99 var player = $('#yotu-player-' + yotuwp.player.current.player), 100 func = $(obj).data('func'), 101 video = player.data(func); 102 103 if(video === '') return; 104 105 switch(func) { 106 case 'prev': 107 case 'next': 108 var loaded_ids = yotuwp.player.current.list.data('loaded'); 109 110 yotuwp.data.players['modal'].loadVideoById(video); 111 yotuwp.player.current.video = video; 112 yotuwp.player.info(); 113 114 yotuwp.do_action('after_play_video', loaded_ids, video, yotuwp.player.current.player); 115 break; 116 } 117 } 118 }, 119 loadmore : { 120 carousel : function(wrp, html, settings){ 121 122 var thumbs = wrp.find('.owl-carousel'), 123 loaded_page = wrp.data('loaded_page'), 124 items = html.find('li'); 125 126 items.map(function (ind){ 127 thumbs.owlCarousel().trigger( 128 'add.owl.carousel', 129 [items[ind]] 130 ); 131 }); 132 133 thumbs.trigger('refresh.owl.carousel'); 134 setTimeout(function () { 135 console.log((loaded_page[loaded_page.length-1] -1) * settings.per_page + 1); 136 thumbs.trigger('to.owl.carousel', [(loaded_page[loaded_page.length-1] -1) * settings.per_page + 1, 300]); 137 }, 1000); 138 }, 139 140 masonry : function(wrp, html, settings){ 141 142 var thumbs = wrp.find('.owl-carousel'), 143 loaded_page = wrp.data('loaded_page'), 144 items = html.find('li'), 145 $grid = wrp.find('ul'); 146 147 items.map(function (ind){ 148 149 $grid.masonry() 150 .append( items[ind] ) 151 .masonry( 'appended', items[ind] ) 152 // layout 153 .masonry(); 154 155 }); 156 157 wrp.masonry(); 158 } 159 } 160 } 161 162 $( document ).ready(function($){ 163 164 // load js when document is ready 165 yotupro.init(); 166 167 }); 168 169 170})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.