1var $ = jQuery.noConflict(); 2var working = false; 3var lastwidth, lastheight = 0; 4var win_height = $.windowHeight(); 5var main_swiper = null; 6$(function() { 7 //Add target _blank to external links 8 $('a').each(function() { 9 var a = new RegExp('/' + window.location.host + '/'); 10 if(this.href){ 11 if (!a.test(this.href)) { 12 $(this).attr("target","_blank"); 13 } 14 } 15}); 16 // Text ellipsis 17 $('.ellipsis').each(function(){ 18 var lines = $(this).attr('lines'); 19 if(!lines){ 20 lines = 2; 21 } 22 $(this).ellipsis( 23 { 24 lines: parseInt(lines), 25 responsive:true 26 }); 27 }); 28 // Go to previews page 29 $('.btn_goback').click(function(){ 30 var referrer = document.referrer; 31 var loc = window.location; 32 myurl = loc.hostname; 33 var hostname = $('<a>').prop('href', referrer).prop('hostname'); 34 if(hostname != myurl || document.referrer==loc) { 35 return true; 36 }else{ 37 location.href = referrer; 38 return false; 39 } 40 }); 41 $('.post_container img,.sidebar_image img').click(function(){ 42 if($('.post_image_pop_up')[0]){ 43 var src = $(this).attr('src'); 44 $('.post_image_pop_up .post_image_pop_up_img_div').css('background-image','url('+src+')'); 45 $('.post_image_pop_up').addClass('open'); 46 } 47 48 }); 49 $('.post_image_pop_up_close').click(function(){ 50 $('.post_image_pop_up').removeClass('open'); 51 }); 52 $('.hamburger').click(function() { 53 var items = $('.mobile_menu,.menu_black_btn'); 54 if (!$('.mobile_menu').hasClass('open')) { 55 items.addClass('open'); 56 $('body').addClass('open_menu'); 57 } else { 58 items.removeClass('open'); 59 $('body').removeClass('open_menu'); 60 } 61 }); 62// Close main banner 63$('.close_main_banner').click(function(){ 64$('.main_banner_container_wrapper').animate({'opacity':0},200,function(){ 65$('.main_banner_container').slideUp('slow'); 66}); 67}); 68//Share buttons actions 69$('.whatsapp_share_btn').click(function(){ 70 shareWhatsapp(); 71}); 72$('.facebook_share_btn').click(function(){ 73 shareFb(); 74}); 75$('.twitter_share_btn').click(function(){ 76 shareTw(); 77}); 78$('.twitter_module_container').click(function(){ 79shareTwModule($(this).attr('quote')); 80}); 81// Newsletter ajax action 82$('.newsletter_form').ajaxForm({ 83 context : this, 84 beforeSubmit : function(arr, $form) { 85 if (!working) { 86 if (validateNewsletter($form)) { 87 working = true; 88 $('body').addClass('waiting'); 89 $form.find('input[type=submit]').prop('disabled', true); 90 return true; 91 } 92 } 93 return false; 94 }, 95 success : function(html, status, xhr, myForm) { 96 $(myForm).find('.newsletter_thanks_wrapper').fadeIn(); 97 98 $(myForm)[0].reset(); 99 $(myForm).find('input[type=submit]').prop('disabled', false); 100 }, 101 complete : function(xhr) { 102 working = false; 103 $('body').removeClass('waiting'); 104 $('form').find('input[type=submit]').prop('disabled', false); 105 } 106 }); 107 108 fix_links(); 109 fix_all(); 110 set_orientation(); 111 $('body').addClass('loaded'); 112 113}); 114document.addEventListener("touchstart", function(){}, true); 115// Actions on load 116$(window).on('load', function() { 117 118}); 119// Actions on scroll 120$(window).scroll(function() { 121 fix_all(); 122 fix_header(); 123}); 124// Actions on resize window 125$(window).resize(function() { 126 set_orientation(); 127 fix_all(); 128 fix_header(); 129}); 130// Keep ration on containers 131$.fn.keepRatio = function(which, width, height, resize) { 132 133 var $this = $(this); 134 135 var w = width; 136 var h = height; 137 var ratio = w / h; 138 switch (which) { 139 case 'width': 140 var nh = Math.round($this.width() / ratio); 141 $this.css('height', nh + 'px'); 142 break; 143 case 'height': 144 var nw = Math.round($this.height() * ratio); 145 $this.css('width', nw + 'px'); 146 break; 147 } 148 if (resize != false) { 149 $(window).resize(function() { 150 switch (which) { 151 case 'width': 152 var nh = Math.round($this.width() / ratio); 153 $this.css('height', nh + 'px'); 154 break; 155 case 'height': 156 var nw = Math.round($this.height() * ratio); 157 $this.css('width', nw + 'px'); 158 break; 159 } 160 161 }); 162 } 163 164}; 165// Check if string is an email 166function IsEmail(email) { 167 var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; 168 return regex.test(email); 169} 170// If element is visible in viewport 171function elementInViewport(el) { 172 if ($(el)[0]) { 173 var top = el.offsetTop; 174 var left = el.offsetLeft; 175 var width = el.offsetWidth; 176 var height = el.offsetHeight; 177 178 while (el.offsetParent) { 179 el = el.offsetParent; 180 top += el.offsetTop; 181 left += el.offsetLeft; 182 } 183 184 return ( 185 top < (window.pageYOffset + window.innerHeight) && 186 left < (window.pageXOffset + window.innerWidth) && 187 (top + height) > window.pageYOffset && 188 (left + width) > window.pageXOffset 189 ); 190 } else { 191 return false;
192 } 193} 194// select current link 195function fix_links() { 196 197 $('nav .main-nav li.active,.sub-menu ul li.active,.about_submenu nav ul li a.active,.children_menu ul li a.active').removeClass('active'); 198 $('nav .main-nav li a,.about_submenu nav ul li a,.children_menu ul li a').each(function() { 199 var ob = $(this); 200 if (ob.attr('url')) { 201 ob.attr('href', ob.attr('url')); 202 } 203 var url = ob.attr('href'); 204 ob.attr('url', url); 205 if (url) { 206 if(url.indexOf('#')!==-1){ 207 url = url.substr(0,url.indexOf('#')); 208 } 209 $('.associated_page').each(function(){ 210 current_url = $(this).val() ?$(this).val() : window.location.href; 211 212 if ((url) == (current_url)) { 213 ob.parent().addClass('active'); 214 if (ob.parent().attr('parent_id')) { 215 var parent_id =ob.parent().attr('parent_id'); 216 $('nav .main-nav li[item_id="' + parent_id + '"]').addClass('active'); 217 } 218 } else { 219 ob.attr('href', $(this).attr('url')); 220 } 221 }); 222 223 } 224 }); 225 226} 227 228function getPathFromUrl(url) { 229 return url.split(/[?#]/)[0]; 230} 231// Get value from query string by string 232var getUrlParameter = function getUrlParameter(sParam, url) { 233 if (!url) { 234 var sPageURL = decodeURIComponent(window.location.search.substring(1)); 235 } else { 236 var sPageURL = decodeURIComponent(url.split(/[?#]/)[1]); 237 } 238 var sURLVariables = sPageURL.split('&'), 239 sParameterName, 240 i; 241 242 for (i = 0; i < sURLVariables.length; i++) { 243 sParameterName = sURLVariables[i].split('='); 244 245 if (sParameterName[0] === sParam) { 246 return sParameterName[1] === undefined ? true : sParameterName[1]; 247 } 248 } 249}; 250 251// Event on mouse up 252$(document).mouseup(function(e) { 253 254 if ($('.main_menu.open')[0]) { 255 var container = $(".main_menu .main_menu_wrapper,.menu_black_btn");
256 var container_close_div = $('.menu_black_btn'); 257 } 258 259 260 261 if (container) { 262 if (!container.is(e.target) // if the target of the click isn't the container... 263 && 264 container.has(e.target).length === 0) // ... nor a descendant of the container 265 { 266 if (container_close_div) { 267 container_close_div.click(); 268 $('body,html').removeClass('overflow_hidden'); 269 } else { 270 container.hide(); 271 } 272 } 273 } 274}); 275 276// Event on keybord key is press 277$(document).keydown(function(e) { 278 switch (e.which) { 279 case 37: 280 //left 281 282 283 break; 284 case 13: 285 case 32: 286 287 break; 288 289 case 38: 290 // up 291 292 break; 293 294 case 39: 295 // right 296 297 break; 298 299 case 40: 300 301 break; 302 case 27: 303 304 break; 305 306 default: 307 return; 308 // exit this handler for other keys 309 } 310 311 // prevent the default action (scroll / move caret) 312}); 313 314// Set orientation class 315function set_orientation() { 316 if (window.innerHeight > window.innerWidth) { 317 $('body').addClass('portrait'); 318 win_height = $.windowHeight(); 319 $('body').removeClass('landscape'); 320 } else { 321 $('body').removeClass('portrait'); 322 win_height = $.windowHeight(); 323 $('body').addClass('landscape'); 324 } 325} 326// Fix heights to avoid using vh 327function fix_all() { 328 if (lastheight != win_height) { 329 var full_height_ob = ''; 330 // $(full_height_ob).css('height', win_height); 331 332 var full_min_height_ob = 'html,body,.page_content_container'; 333 $(full_min_height_ob).css('min-height', win_height); 334 335 var full_height_ob_no_header = '.about_container'; 336 $(full_height_ob_no_header).css('height', win_height - $('#masthead').outerHeight()); 337 var full_height_ob_no_header_no_footer = '.media_info_wrapper'; 338 lastheight = win_height; 339 } 340 if($('.top_scroll_bar')[0]){ 341 var full_height = $(document).height() - $(window).height(); 342 var scrolltop = $(window).scrollTop(); 343 per = scrolltop*100/full_height; 344 $('.top_scroll_bar_progress').css('width',per+'%'); 345 } 346} 347 348// Open Pop up 349function PopupCenter(pageURL, title, w, h) { 350 var left = (screen.width / 2) - (w / 2); 351 var top = (screen.height / 2) - (h / 2); 352 var targetWin = window.open(pageURL, '', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left); 353} 354 355// Action to share on Facebook 356function shareFb() { 357 title=$('#social_title').val(); 358 desc=$('#social_description').val(); 359 image=$('#social_image').val(); 360 url=$('#social_url').val(); 361 var dest = 'https://www.facebook.com/sharer/sharer.php?u=' + url; 362 PopupCenter(dest, 'Compartir en Facebook', 650, 350); 363} 364// Action to share on Whatsapp 365function shareWhatsapp() { 366 title=$('#social_title').val(); 367 desc=$('#social_description').val(); 368 image=$('#social_image').val(); 369 url=$('#social_url').val(); 370 371 var dest = 'https://api.whatsapp.com/send?text='+encodeURIComponent(desc+' '+url); 372 PopupCenter(dest, 'Compartir en Whatsapp', 650, 350); 373} 374// Action to share on Twitter 375function shareTw() { 376 title=$('#social_title').val(); 377 desc=$('#social_description').val(); 378 image=$('#social_image').val(); 379 url=$('#social_url').val(); 380 textString=desc; 381 if (textString.length > (276 - url.length)) { 382 textString = textString.substring(0, ((276 - url.length)) - 1); 383 textString += "... "; 384 } 385 386 var text = encodeURIComponent(textString) + encodeURIComponent(url); 387 var dest = 'http://twitter.com/intent/tweet?lang=es&text=' + text; 388 PopupCenter(dest, 'Compartir en Twiiter', 650, 350); 389} 390// Action to share quote on Twitter 391function shareTwModule(quote) { 392 textString=quote; 393 if (textString.length > 280) { 394 textString = textString.substring(0, ((277)) - 1); 395 textString += "..."; 396 } 397 var mssg = window.location.href; 398 399 var text = encodeURIComponent(textString); 400 var dest = 'http://twitter.com/intent/tweet?lang=es&via=imcomx&url='+mssg+'&text="' +text+'"'; 401 PopupCenter(dest, 'Compartir en Twiiter', 650, 350); 402} 403function fix_header() { 404 405} 406//validate newsletter form 407function validateNewsletter($form){ 408 var email = $form.find('.newsletter_email'); 409 if($.trim(email.val())==''){ 410 email.parents('.newsletter_content_right_column_wrapper').addClass('empty_error'); 411 }else{ 412 email.parents('.newsletter_content_right_column_wrapper').removeClass('empty_error'); 413 if(IsEmail($.trim(email.val()))){ 414 email.parents('.newsletter_content_right_column_wrapper').removeClass('invalid_email'); 415 }else{ 416 email.parents('.newsletter_content_right_column_wrapper').addClass('invalid_email'); 417 } 418 } 419 420
421 if($form.find('.empty_error')[0] || $form.find('.invalid_email')[0]){ 422 return false; 423 }else{ 424 return true; 425 } 426}
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.