1var old_link_post_view=0; 2 3 4function calcularPorcentajeVisible(b) { 5 var g = b.height(); 6 b = b.offset().top; 7 return 100 * ($(window).scrollTop() - b + 150) / g; 8} 9 10 11function loadSlider() { 12 $js_post_slide = $(".js_slide_post"); 13 $js_post_slide.each(function(index) { 14 var $this = $(this); 15 var slideData = $this.data("slide"); 16 17 // Verificar si hay datos en el atributo data-slide 18 if (!slideData || !Array.isArray(slideData) || slideData.length === 0) { 19 return; 20 } 21 // Obtener el contenido del template Handlebars 22 var source = $("#slider-post-template").html(); 23 var template = Handlebars.compile(source); 24 // Generar el HTML utilizando los datos del slide 25 var html = ""; 26 var html = template({ 27 slideData : slideData 28 }); 29 30 $this.replaceWith(html); 31 32 33 $('.slider-for').slick({ 34 slidesToShow: 1, 35 slidesToScroll: 1, 36 arrows: false, 37 // fade: true, 38 asNavFor: '.slider-nav', 39 adaptiveHeight: false, 40 }); 41 42 $('.slider-nav').slick({ 43 slidesToShow: 3, 44 slidesToScroll: 1, 45 asNavFor: '.slider-for', 46 dots: true, 47 centerMode: true, 48 focusOnSelect: true, 49 variableWidth: true, 50 }); 51 52 53 }); 54} 55 56 57 58 59 60 61(function($){ 62 $.fn.isOnScreen = function(x, y){ 63 64 if(x == null || typeof x == 'undefined') x = 1; 65 if(y == null || typeof y == 'undefined') y = 1; 66 67 var win = $(window); 68 69 var viewport = { 70 top : win.scrollTop(), 71 left : win.scrollLeft() 72 }; 73 viewport.right = viewport.left + win.width(); 74 viewport.bottom = viewport.top + win.height(); 75 76 var height = this.outerHeight(); 77 var width = this.outerWidth(); 78 79 if(!width || !height){ 80 return false; 81 } 82 83 var bounds = this.offset(); 84 bounds.right = bounds.left + width; 85 bounds.bottom = bounds.top + height; 86 87 var visible = (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom)); 88 89 if(!visible){ 90 return false; 91 } 92 93 var deltas = { 94 top : Math.min( 1, ( bounds.bottom - viewport.top ) / height), 95 bottom : Math.min(1, ( viewport.bottom - bounds.top ) / height), 96 left : Math.min(1, ( bounds.right - viewport.left ) / width), 97 right : Math.min(1, ( viewport.right - bounds.left ) / width) 98 }; 99 100 return (deltas.left * deltas.right) >= x && (deltas.top * deltas.bottom) >= y; 101 102 }; 103})(jQuery); 104 105 106function getTheUpperArticle(articles, parent) { 107 var $articles = $(articles); 108 var mainSectionScrollTop = $(parent).offset().top; 109 var windowScrollTop = $(window).scrollTop(); 110 var windowScrollBottom = $(window).scrollTop() + $(window).height(); 111 112 if ( (windowScrollTop >= mainSectionScrollTop) ) { 113 $.each($articles, function(index, element) { 114 115 116 // var $element = $(element); 117 var $element = $('.js-content-static').eq(index); 118 var $elementHeight = $element.outerHeight(true); 119 var scrollTop = $element.position().top; 120 var scrollBottom = $elementHeight + scrollTop; 121 var inElementScrollTop = windowScrollTop - scrollTop; 122 var $elementParent = $element.eq(global_count_articles).parents('.js-content-static'); 123 var $elementParentNext = $element.eq(global_count_articles+1).parents('.js-content-static'); 124 var $elementSeparatorBar = $('.js-content-static').eq(global_count_articles).find('.separator-bar'); 125 // var $listItemCircle = $('.js-link-item-post[data-id="'+ $element.data('id') +'"]'); 126 127 if (windowScrollTop >= scrollTop && windowScrollTop <= scrollBottom) { 128 $element.addClass('is-current'); 129 130 // Get the percentage from the element top 131 var percentage = (inElementScrollTop * 100) / $elementHeight; 132 // Get the percentage from the element top 133 // var percentage = (inElementScrollBottom * 100) / $elementHeight; 134 percentage = Math.round(percentage); 135 percentage = (percentage <= 25) ? 0 : percentage; 136 percentage = (percentage >= 85) ? 100 : percentage; 137 138 139 //******************************************************************* 140 //GET VIEW 141 if(typeof json_articles[index]!='undefined' && old_link_post_view!=json_articles[index].post_link){ 142 old_link_post_view = json_articles[index].post_link; 143 } 144 //******************************************************************* 145 146 //******************************************************************* 147 //CHANGE URL AND TITLE 148 // if( $elementSeparatorBar.isOnScreen(0.8, 0.8) ){ 149 if(typeof json_articles[index]!='undefined' && (percentage>=0 && percentage<=50) ){ 150 151 var old_state = ''; 152 if(index==0){ 153 old_state = global_post_segment_url.substr(1,global_post_segment_url.length); 154 } 155 if(typeof window.history.state!='undefined' && window.history.state!=null && typeof window.history.state.article!='undefined' ) 156 old_state = window.history.state.article; 157 158 if(old_state!=json_articles[index].post_link){ 159 160 window.history.replaceState({article:json_articles[index].post_link}, $("<textarea/>").html(json_articles[index].post_title).val(), global_domain+'/'+json_articles[index].post_link); 161 document.title = $("<textarea/>").html(json_articles[index].post_title).val(); 162 163 //ENVIAMOS A GOOGLE 164 ga('set', 'location', global_domain+'/'+json_articles[index].post_link); 165 ga('set', 'page', '/'+json_articles[index].post_link); 166 ga('send', 'pageview'); 167 } 168 } 169 //******************************************************************* 170 171 172 if( (global_count_articles+1)<json_articles.length && !global_flag ){ 173 if( $elementSeparatorBar.isOnScreen(0.8, 0.8) ){ 174 175 global_flag = true; 176 var url_get = '/'+json_articles[global_count_articles+1].post_link+'?content=basic'; 177 178 $elementSeparatorBar.find('.post_loading').fadeIn(); 179 180 181 $.get(url_get, function(data_get){ 182 $elementSeparatorBar.find('.post_loading').fadeOut(); 183 $(".js_main_content").append( data_get ); 184 185 186 global_count_articles++; 187 global_flag = false;
188 189 //*********************** 190 cargarPublicidad(); 191 //*********************** 192 193 194 //*********************** 195 //LOAD TAGS 196 loadTags(); 197 //*********************** 198 199 //*********************** 200 //LOAD SLIDER 201 loadSlider(); 202 //*********************** 203 204 //*********************** 205 //LOAD OLD EMBED 206 loadOldEmbed(); 207 //*********************** 208 209 //*********************** 210 //LOAD EMBED RUDO 211 loadEmbedRudo(false); 212 //*********************** 213 214 //*********************** 215 //UPDATE COUNT 216 send_post_count(json_articles[global_count_articles].id_post); 217 //*********************** 218 219 220 //*********************** 221 // APLICAMOS RESPONSIVE VIDEO 222 setResponsiveVideo('iframe[src*="rudo"]', 'iframe[src*="youtube"]', 'iframe[src*="vimeo"]', 'video', 'audio', 'iframe[src*=docdroid]', 'iframe[src*="facebook"]'); 223 //*********************** 224 225 226 227 }).fail(function(){ 228 $elementSeparatorBar.find('.post_loading').fadeOut(); 229 console.log('Error al cargar la data'); 230 }); 231 232 } 233 } 234 235 // index, percentage 236 } else { 237 $element.removeClass('is-current'); 238 } 239 }); 240 } 241 else{ 242 } 243} 244 245 246function __cargarPublicidad(){ 247 if( !$(".rtb_slot")[0] ) return false; 248 249 googletag.cmd.push(function() { 250 251 $(".rtb_slot").each(function() { 252 253 if( !$(this).hasClass('loaded') ){ 254 $(this).addClass("loaded"); 255 var id = $(this).data("adunit"); 256 var slot = $(this).data("slot"); 257 var dimensions = $(this).data("dimensions"); 258 var ads_itt = false; 259 var slot_ads; 260 // console.log(id, slot, dimensions); 261 262 // Create a div for the slot 263 var slotDiv = document.createElement('div'); 264 slotDiv.id = id; // Id must be the same as slotName 265 266 $(this).html(slotDiv); 267 slot_ads = googletag.defineSlot(slot, dimensions, id). 268 addService(googletag.pubads()); 269 270 googletag.pubads().enableSingleRequest(); 271 googletag.pubads().collapseEmptyDivs(true,true); 272 googletag.pubads().disableInitialLoad(); 273 274 275 googletag.enableServices(); 276 googletag.display(id); 277 googletag.pubads().refresh([slot_ads]); 278 } 279 }); 280 }); 281 282} 283 284function loadItemPostSidebar(){ 285 if( !$('.js-content-static')[0] ){ 286 return false; 287 } 288 289 json_articles.push({ 290 post_title : $('.js-content-static:eq(0) .main-article__title').text(), 291 post_link : global_post_segment_url.slice(1, global_post_segment_url.length ) 292 }); 293 294 global_last_posts.forEach(function(item){ 295 json_articles.push(item); 296 }); 297 // console.log(json_articles); 298 299 getTheUpperArticle('.js-content-static', '.js_main_content'); 300 $(window).on('scroll load', function() { 301 getTheUpperArticle('.js-content-static', '.js_main_content'); 302 }); 303 304 305 old_link_post_view = global_post_segment_url; 306} 307 308 309 310$(document).ready(function(){ 311 312 313 loadItemPostSidebar(); 314 loadSlider(); 315 cargarPublicidad(); 316});
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.