1(function($){ 2 "use strict"; 3 4 var dummyTip = null; 5 6 function reBindScripts(){ 7 var lightBoxParams = { 8 iframe: {'allowfullscreen':true}, 9 }; 10 if(window.mxYouTubeR_lightboxParams !== undefined){ 11 lightBoxParams = $.extend(lightBoxParams,mxYouTubeR_lightboxParams); 12 } 13 $('a.mxyt-lightbox').fancybox(lightBoxParams); 14 15 $('.mxyt-tip').each(function(index, element) { 16 var $this = $(this); 17 var mainContainer = $this.closest('.mxYouTubeR'); 18 var _class = ''; 19 if(mainContainer.attr('class')){ 20 var matches = mainContainer.attr('class').match(/(mxYouTubeR_theme_[a-z0-9\-_]+)/); 21 if(matches && matches.length>0){ 22 _class = matches[0]; 23 } 24 } 25 $this.off('mouseenter'); 26 $this.on('mouseenter',function(){ 27 if(!dummyTip.hasClass(_class)){ 28 dummyTip.addClass(_class); 29 } 30 dummyTip.children('span').html($this.attr('title')); 31 var pos = $this.offset(); 32 dummyTip.css('left',pos.left+$this.innerWidth()/2-dummyTip.width()/2); 33 dummyTip.css('top',pos.top); 34 35 dummyTip.addClass('active'); 36 dummyTip.stop().css('opacity',0).animate({ 37 'opacity': 0.9, 38 'margin-top': -25 39 },200,'swing',function(){ 40 //console.info(tip,this); 41 }); 42 }); 43 $this.off('mouseleave'); 44 $this.on('mouseleave',function(){ 45 dummyTip.removeClass(_class); 46 dummyTip.removeClass('active'); 47 dummyTip.css('margin-top',-15); 48 }); 49 }); 50 51 $('.mxyt-text-description.mxyt-less').each(function(index, element){ 52 var $this = $(this); 53 if($this.next().is('.mxyt-text-description-btn')){ 54 return; 55 } 56 var moreBtn = $('<div class="mxyt-text-description-btn">'+mxyt_ajax_object.lang.more+'</div>'); 57 var fullHeight = $this.children().height(); 58 if($this.height()<fullHeight){ 59 $this.addClass('hasMore'); 60 moreBtn.insertAfter($this); 61 moreBtn.off('click'); 62 moreBtn.on('click',function(){ 63 var btn = $(this); 64 if($this.hasClass('mxyt-less')){ 65 $this.removeClass('mxyt-less'); 66 btn.html(mxyt_ajax_object.lang.less); 67 } 68 else{ 69 $this.addClass('mxyt-less'); 70 btn.html(mxyt_ajax_object.lang.more); 71 } 72 }); 73 } 74 else{ 75 $this.removeClass('hasMore'); 76 $this.addClass('noMore'); 77 } 78 }); 79 80 $('.mxyt-playlist-select span').off('click'); 81 $('.mxyt-playlist-select span').on('click',function(){ 82 var $this = $(this); 83 playlistLoader.loadPlaylist($this.closest('.mxyt-channel-videos'),$this.attr('data-mxyt-cfg'),''); 84 return false; 85 }); 86 87 $('.mxyt-load-more').each(function(index, element) { 88 var $this = $(this); 89 if($this.attr('data-checked')){ 90 return; 91 } 92 $this.attr('data-checked','true'); 93 if($this.hasClass('mxyt-infinite-scroll')){ 94 $(window).on('scroll',function(){ 95 var top = $(window).scrollTop() + $(window).height(); 96 if(top>$this.offset().top){ 97 playlistLoader.loadMore($this); 98 } 99 }); 100 } 101 else{ 102 $this.off('click'); 103 $this.on('click',function(){ 104 playlistLoader.loadMore($(this)); 105 return false; 106 }); 107 } 108 }); 109 $('.ch-item').on('mouseenter',function(){ 110 $(this).addClass('mx-active'); 111 }); 112 $('.ch-item').on('mouseleave',function(){ 113 $(this).removeClass('mx-active'); 114 }); 115 } 116 117 var playlistLoader = { 118 loading: false, 119 pageToken: '', 120 button: null, 121 loadingBar: null, 122 params: {}, 123 target: null, 124 125 bind: function(jqBtn){ 126 this.button = jqBtn; 127 this.pageToken = jqBtn.attr('data-mxyt-pagetoken'); 128 this.params = jqBtn.attr('data-mxyt-cfg'); 129 this.target = jqBtn.closest('.mxYouTubeR').find('.mxyt-playlist'); 130 }, 131 loadMore: function(jqBtn){ 132 if(this.loading){ 133 return false; 134 } 135 this.bind(jqBtn); 136 if(this.pageToken==''){ 137 return false; 138 } 139 this.loading = true; 140 this.loadingBar = $('<i class="mxyt-icon mxyt-icon-spinner"></i>'); 141 this.button.hide(); 142 this.button.parent().append(this.loadingBar); 143 144 var loader = this; 145 $.ajax({
146 url: mxyt_ajax_object.ajax_url, 147 type: 'post', 148 dataType: "json", 149 data:{ 150 action: 'mxyoutuber', 151 pageToken: loader.pageToken, 152 params: loader.params, 153 }, 154 success: function( result ){ 155 if(result && result.success){ 156 loader.loaded(result); 157 } 158 else{ 159 alert('mxYouTubeR ajax error.'); 160 } 161 }, 162 error: function(){ 163 alert('mxYouTubeR ajax error.'); 164 } 165 }); 166 }, 167 loadPlaylist: function(_container,_params,_pageToken){ 168 if(this.loading){ 169 return false; 170 } 171 this.loading = true; 172 var loadingBar = $('<p align="center"><i class="mxyt-icon mxyt-icon-spinner"></i></p>'); 173 _container.html(loadingBar); 174 175 var loader = this; 176 $.ajax({ 177 url: mxyt_ajax_object.ajax_url, 178 type: 'post', 179 dataType: "json", 180 data:{ 181 action: 'mxyoutuber', 182 pageToken: _pageToken, 183 params: _params, 184 }, 185 success: function( result ){ 186 if(result.success){ 187 loader.loading = false; 188 loadingBar.remove(); 189 var items = $($(result.html).find('.mxyt-channel-videos').html()); 190 _container.append(items); 191 reBindScripts(); 192 items.css('opacity',0); 193 items.stop().animate({ 194 'opacity': 1 195 },300); 196 } 197 else{ 198 alert('mxYouTubeR ajax error.'); 199 } 200 }, 201 error: function(){ 202 alert('mxYouTubeR ajax error.'); 203 } 204 }); 205 }, 206 loaded: function(result){ 207 this.pageToken = result.pageToken; 208 this.loading = false; 209 this.loadingBar.remove(); 210 this.button.attr('data-mxyt-pagetoken',this.pageToken); 211 if(this.pageToken){ 212 this.button.show(); 213 } 214 var items = $(result.html).find('.mxyt-row, .mxyt-brow'); 215 this.target.append(items); 216 reBindScripts(); 217 items.css('opacity',0); 218 items.stop().animate({ 219 'opacity': 1 220 },300); 221 } 222 }; 223 224 window.mxYouTuberInit = function(){ 225 if(!dummyTip){ 226 dummyTip = $('<div id="mxyt-tooltip" class="mxyt-tooltip"><span></span><div></div></div>'); 227 $('body').append(dummyTip); 228 } 229 reBindScripts(); 230 } 231 232 $(document).ready(function(e) { 233 window.mxYouTuberInit(); 234 }); 235 236})(jQuery); 237 238 239 240 241 242 243
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.