1// 1 - Include Plugins 2// 2 - Loader 3// 3 - Main Navigation Dropdown 4// 4 - Input Field 5// 5 - Top Header Active Background Apply Color 6// 6 - Go To Top Button 7// 7 - Modal Box 8// 8 - LazyLoad Images 9 10 11/***** 1 - Include Plugins*/ 12//window.as_html_preload(); 13 14window.fn_fn_include_file = {}; 15window.fn_include_file = function(e, as_fn) 16{ 17 //console.log(e); 18 var fn_name = e.toString().split(' '); 19 fn_name = fn_name[1]; 20 fn_name = fn_name.split(').'); 21 fn_name = (fn_name[1])?fn_name[1]:fn_name[0]; 22 fn_name = fn_name.split('.'); 23 fn_name = (fn_name[1])?fn_name[1]:fn_name[0]; 24 console.log('Not Found ' + fn_name); 25 try 26 { 27 switch(fn_name) 28 { 29 case 'marqueeInit': 30 console.log(ypulseJsVar.current_url + '/assets/plugins/scrolling/crawler.js'); 31 include_file(ypulseJsVar.current_url + '/assets/plugins/scrolling/crawler.js',as_fn); 32 break; 33 34 default: 35 console.log(fn_name); 36 return; 37 break; 38 } 39 //as_fn(); 40 }catch(e){fn_include_file(e,as_fn);} 41}; 42 43 44window.html_lodded_files = {}; 45function include_file (file, callback ){ 46 var xf = file; 47 xf = xf.split('?'); 48 xf = xf[0]; 49 xf = xf.split('.'); 50 xf = xf[xf.length-1]; 51 xf = xf.toLowerCase(); 52 53 if (window.html_lodded_files[file]) 54 { 55 }else 56 { 57 window.html_lodded_files[file] = true; 58 //console.log(xf); 59 60 61 62 63 64 65 switch(xf) 66 { 67 case 'css': 68 69 var script = document.createElement( "link" ) 70 //script.type = "text/javascript"; 71 72 if(script.readyState) { //IE 73 script.onreadystatechange = function() { 74 if ( script.readyState === "loaded" || script.readyState === "complete" ) { 75 script.onreadystatechange = null; 76 try{callback();}catch(e){} 77 } 78 }; 79 } else { //Others 80 script.onload = function() { 81 try{callback();}catch(e){} 82 }; 83 } 84 85 /*jQuery('head').append('<link rel="stylesheet" href="' + file + '" rel="preload">');*/ 86 script.rel = "stylesheet"; 87 script.href = file; 88 break; 89 90 case 'js': 91 92 var script = document.createElement( "script" ) 93 //script.type = "text/javascript"; 94 95 if(script.readyState) { //IE 96 script.onreadystatechange = function() { 97 if ( script.readyState === "loaded" || script.readyState === "complete" ) { 98 script.onreadystatechange = null; 99 try{callback();}catch(e){} 100 } 101 }; 102 } else { //Others 103 script.onload = function() { 104 try{callback();}catch(e){} 105 }; 106 } 107 108 109 /*jQuery('head').append('<script src="' + file + '"></script>');*/ 110 script.type = "text/javascript"; 111 script.src = file; 112 break; 113 } 114 115 116 document.getElementsByTagName( "head" )[0].appendChild( script ); 117 118 } 119}; 120 121if(false) 122{ 123 include_file(ypulseJsVar.current_url + 'plugins/scrolling/crawler.js'); 124}; 125 126 127 128//***** 2 - Loader 129jQuery( document ).ready(function() { 130 if (typeof(window.afterReady) !== 'undefined') 131 { 132 for(k in window.afterReady) 133 { 134 try{window.afterReady[k]();}catch(e){fn_include_file(e,window.afterReady[k]);} 135 } 136 } 137 window.afterReady = []; 138 setTimeout(function(){ 139 jQuery('#loader-wrapper').fadeOut('fast'); 140 }, 500); 141}); 142 143jQuery(window).on('load',function() { 144 if (typeof(window.afterLoad) !== 'undefined') 145 { 146 for(k in window.afterLoad) 147 { 148 try{window.afterLoad[k]();}catch(e){fn_include_file(e,window.afterLoad[k]);} 149 } 150 } 151 window.afterLoad = []; 152}); 153 154 155//***** 3 - Main Navigation Dropdown 156jQuery(function() { 157 var nav_bar_dropdown_set_timeout = 0; 158 jQuery('.navbar-nav .dropdown, .navbar-nav .dropdown-submenu').mouseenter(function(e) { 159 jQuery(this).addClass('show'); 160 }).mouseleave(function(e) { 161 jQuery(this).removeClass('show'); 162 }); 163 164 //jQuery("li.dropdown").prepend("<span class='down-arrow'></span>"); 165 166 //jQuery('.CategoryLinks .dropdown').on('hide.bs.dropdown', function (e) { 167 // e.preventDefault(); e.stopPropagation(); 168 // }) 169 170 //jQuery('.dropdown #filterpostform img.Close').click(function(e) { 171 // jQuery("#filterpostform .dropdown-menu").hide(); 172 //}); 173 174 //jQuery('.CategoryLinks .dropdown-toggle').click(function(e) { 175 // jQuery("#filterpostform .dropdown-menu").show(); 176 //}); 177 178 //jQuery("ul.dropdown-menu [data-toggle='dropdown'],#TopNav span.down-arrow").on("click", function(event) { 179 // event.preventDefault(); 180 // event.stopPropagation(); 181 // jQuery(this).parent().toggleClass("show"); 182 // jQuery(this).siblings().toggleClass("show"); 183 //}); 184 //jQuery('ul.navbar-nav li.dropdown a').click(function(e) { 185 // var href = jQuery(this).attr('href'); 186 // window.location = href; return false;
187 //}); 188}); 189 190jQuery(document).on('click','[data-target="#navbarContent"]',function(){ 191 console.log('Clicked'); 192 var aria_expanded = jQuery(this).attr('aria-expanded'); 193 //console.log(aria_expanded); 194 if(jQuery.trim(aria_expanded) === 'true') 195 { 196 jQuery('html').addClass('is_mobile_menu'); 197 jQuery('#TopHead').addClass('th_active'); 198 }else 199 { 200 jQuery('html').removeClass('is_mobile_menu'); 201 } 202}); 203 204 205 206//***** 4 - Input Field 207window.ele_valid_chk = function(ele) 208{ 209 if(jQuery.trim(ele.value) === '') 210 { 211 jQuery(ele).removeClass('not_empty'); 212 jQuery(ele).closest('.dropdown').removeClass('not_empty'); 213 }else 214 { 215 jQuery(ele).addClass('not_empty'); 216 jQuery(ele).closest('.dropdown').addClass('not_empty'); 217 } 218}; 219 220jQuery(function() { 221jQuery('.FieldWrapp input, .FieldWrapp textarea, .SelectStyle select').each(function(index, element) { 222 window.ele_valid_chk(element); 223}); 224 225jQuery(document).on('click focus focusin focusout blur change','.FieldWrapp input, .FieldWrapp textarea, .SelectStyle select',function(){ 226 window.ele_valid_chk(this); 227}); 228 229 230
231//***** 5 - Top Header Active Background Apply Color 232 // ** https://stackoverflow.com/questions/28266651/change-header-background-colour-when-page-scrolls 233 // ** http://jsfiddle.net/634d6vgq/2/ 234jQuery(function (){ 235 var $window = jQuery(window); 236 var $topHead = jQuery("#TopHead"); 237 var CLASS_TH_ACTIVE = 'th_active'; 238 var topFixPosition = $topHead.data('fix_top')?$topHead.data('fix_top'):$topHead.attr('data-fix_top'); 239 240 if(!topFixPosition){ 241 topFixPosition = 0; 242 } 243 244 function setTopHeadState(){ 245 if($window.scrollTop() > topFixPosition) { 246 if( !$topHead.hasClass(CLASS_TH_ACTIVE) ) { 247 $topHead.addClass(CLASS_TH_ACTIVE); 248 jQuery("#TopHead.th_active.purple img.logo").attr('src', ypulseJsVar.logoUrlwhite); 249 } 250 } else { 251 //remove the background property so it comes transparent again (defined in your css) 252 if( $topHead.hasClass(CLASS_TH_ACTIVE) ) { 253 $topHead.removeClass(CLASS_TH_ACTIVE); 254 jQuery("#TopHead.purple img.logo").attr('src', ypulseJsVar.logoUrlPurple); 255 } 256 } 257 } 258 259 setTopHeadState(); // initialize 260 261 $window.on("scroll", setTopHeadState ); // recalculate every time scroll happens 262}) 263 264 265 266 267//***** 6 - Go To Top Button 268jQuery(window).scroll(function(){ 269 var totalH = jQuery(window).height(); 270 if( jQuery(window).scrollTop() > (totalH/2) ){ 271 jQuery('.topBtn').fadeIn(); 272 }else{ 273 jQuery('.topBtn').fadeOut(); 274 } 275 jQuery('#set_window_scroll_position').val(jQuery(window).scrollTop()); 276}); 277 278jQuery('.topBtn').unbind('click'); 279jQuery('.topBtn').click(function(e){ 280 e.preventDefault(); 281 //jQuery(window).scrollTop(0); 282 283 284 jQuery('html, body').animate({ 285 scrollTop: 0 286 },1000); 287}); 288 289 290 291//***** 7 - Modal Box 292jQuery('.boostrap_modal_open').click(function(){ 293 jQuery(this).closest('*[role=dialog]').trigger('click.dismiss.bs.modal').delay(1500); 294 var hash = this.hash 295 window.setTimeout(function(){ 296 jQuery(hash).modal('show'); 297 },500); 298}); 299 300 301 302//***** 8 - LazyLoad Images 303jQuery('[data-src]').addClass('lazy').attr('src',ypulseJsVar.current_url+'/assets/images/img.png'); 304jQuery('[data-src][data-size]').each(function(){ 305 var data_size = jQuery(this).data('size')?jQuery(this).data('size'):jQuery(this).attr('data-size'); 306 data_size = data_size.split('x'); 307 console.log(data_size); 308 var ratio = data_size[1] / data_size[0]; 309 jQuery(this).height(parseInt(ratio * jQuery(this).width())); 310}); 311}); 312 313function Utils() { 314 315}; 316 317Utils.prototype = { 318 constructor: Utils, 319 isElementInView: function (element, fullyInView) { 320 var pageTop = jQuery(window).scrollTop(); 321 var pageBottom = pageTop + jQuery(window).height(); 322 var elementTop = jQuery(element).offset().top; 323 var elementBottom = elementTop + jQuery(element).height(); 324 325 if (fullyInView === true) { 326 return ((pageTop < elementTop) && (pageBottom > elementBottom)); 327 } else { 328 return ((elementTop <= pageBottom) && (elementBottom >= pageTop)); 329 } 330 } 331}; 332 333var Utils = new Utils(); 334 335var lazyloadThrottleTimeout; 336 337function lazyload () { 338 var lazyloadImages = jQuery(".lazy"); 339 if(lazyloadThrottleTimeout) { 340 clearTimeout(lazyloadThrottleTimeout); 341 } 342 343 lazyloadThrottleTimeout = setTimeout(function() { 344 var scrollTop = window.pageYOffset; 345 lazyloadImages.each(function(c,img){ 346 347 var isElementInView = Utils.isElementInView(jQuery(img), false); 348 var show_src = img.dataset.src; 349 var src_obj = {}; 350 var src_viewport = []; 351 var cur_w = jQuery( window ).width(); 352 353 jQuery(img.attributes).each(function(c,e){ 354 if(e.name.substring(0,12) === 'data-src-max') 355 { 356 src_viewport.push(e.name.substring(13)); 357 src_obj[e.name.substring(13)] = e.value; 358 //console.log(e.name.substring(0,12)); 359 } 360 }); 361 362 src_viewport.reverse(); 363 364 //console.log(src_obj,src_viewport); 365 366 367 if(src_viewport.length) 368 { 369 for(var i=0;src_viewport.length>i;i++) 370 { 371 if(cur_w<=src_viewport[i]) 372 { 373 show_src = src_obj[src_viewport[i]]; 374 //console.log(src_obj[src_viewport[i]]); 375 } 376 } 377 } 378 379 if(isElementInView) 380 { 381 if(img.localName.toLowerCase() === 'img') 382 { 383 img.src = show_src; 384 img.classList.remove('lazy'); 385 }else 386 { 387 jQuery(img).css('background-image',"url( '"+show_src+"' )"); 388 img.classList.remove('lazy'); 389 } 390 391 lazyloadfn(img); 392 } 393 }); 394 if(lazyloadImages.length == 0) 395 { 396 document.removeEventListener("scroll", lazyload); 397 window.removeEventListener("resize", lazyload); 398 window.removeEventListener("orientationChange", lazyload); 399 } 400 try 401 { 402 jQuery('.home-portfolio').masonry('layout'); 403 }catch(e) 404 { 405 } 406 }, 20); 407}; 408document.addEventListener("DOMContentLoaded", function() { 409 document.addEventListener("scroll", lazyload); 410 window.addEventListener("resize", lazyload); 411 window.addEventListener("orientationChange", lazyload); 412}); 413 414document.addEventListener("scroll", lazyload); 415window.addEventListener("resize", lazyload); 416window.addEventListener("orientationChange", lazyload); 417//setInterval(lazyload,200); 418 419jQuery(function(){ 420jQuery("img").one("load", function() { 421 try 422 { 423 jQuery('.home-portfolio').masonry('layout'); 424 }catch(e) 425 { 426 } 427 lazyload(); 428}).each(function() { 429 if(this.complete) { 430 try 431 { 432 jQuery('.home-portfolio').masonry('layout'); 433 }catch(e) 434 { 435 } 436 } 437 lazyload(); 438}); 439}); 440 441(function($){ 442 $.fn.imgLoad = function(callback) { 443 return this.each(function() { 444 if (callback) { 445 if (this.complete || jQuery(this).height() > 0) { 446 callback.apply(this); 447 } 448 else { 449 jQuery(this).on('load', function(){ 450 callback.apply(this); 451 }); 452 } 453 } 454 }); 455 }; 456 457})(jQuery); 458 459window.lazyloadfn = function(img) 460{ 461 jQuery(img).closest('[data-lazyloadfn]').each(function(){ 462 463 jQuery(this).find('.lazy').imgLoad(function(ele){this.isloaded =true;}); 464
465 if(this.id && jQuery.trim(this.id)!=='') 466 { 467 }else 468 { 469 this.id = 'lazyloadfn_' + Math.round(new Date().getTime() + (Math.random() * 100)); 470 } 471 472 if(window['lazyloadfn_' + this.id]) clearInterval(window['lazyloadfn_' + this.id]); 473 474 window['lazyloadfn_' + this.id] = setInterval(function(id,images,main){ 475 476 var is_as_loaded = true; 477 478 images.each(function(c,im){ 479 if(im.isloaded) 480 { 481 }else 482 { 483 is_as_loaded = false; 484 } 485 }); 486 487 if(is_as_loaded) 488 { 489 clearInterval(window[id]); 490 console.log('All images loaded.'); 491 var callback_fn = jQuery(main).data('lazyloadfn')?jQuery(main).data('lazyloadfn'):jQuery(main).attr('data-lazyloadfn'); 492 console.log(callback_fn); 493 try{window[callback_fn](id,images,main);}catch(e){fn_include_file(e,window[callback_fn]);} 494 } 495 496 },200,'lazyloadfn_' + this.id, jQuery(this).find('.lazy'),this); 497 }); 498}; 499//////////////////////////////////////////////// END!
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.