1(function($) { 2 /* ========================================================================== 3 Globals 4 ========================================================================== */ 5 // System 6 var str_site_title = "Ceiba | v02"; 7 var bool_mobile = false; 8 var bool_touch = false; 9 var bool_ie = false; 10 11 // Layout 12 var px_width_window = $(window).width(); 13 var px_height_window = $(window).innerHeight(); 14 var px_height_offset; 15 var px_sm_width = 768; 16 var px_md_width = 992; 17 var px_lg_width = 1200; 18 19 // Scroll 20 var px_scroll_top = 0; 21 22 23 /* ========================================================================== 24 Pre-DOM 25 ========================================================================== */ 26 report('[â¢] ' + str_site_title + ' main.js'); 27 28 /* ========================================================================== 29 Post-DOM 30 ========================================================================== */ 31 $(document).ready(function(){ 32 report('[â¢] Run Post-DOM Routine...'); 33 34 px_width_window = $(window).width(); 35 px_height_window = $(window).height(); 36 px_height_offset = parseInt($("body").css("paddingTop")); 37 38 checkBrowser(); 39 initGlobalBindings(); 40 onWindowResizeInterval(); 41 42 report('[â¢] Post-DOM Routine complete.'); 43 }); 44 45 46 /* ========================================================================== 47 Init Functions 48 ========================================================================== */ 49 function initGlobalBindings(){ 50 report('[â¢] initGlobalBindings()'); 51 $(window).resize(onWindowResize); 52 $(window).scroll(onWindowScroll); 53 54 $('.toggle-menu').click(function(){ 55 if ($(this).hasClass('on')){ 56 $(this).removeClass('on'); 57 $('#header .top-nav').removeClass('on'); 58 $('#header .mobile-nav').removeClass('on'); 59 } else { 60 $(this).addClass('on'); 61 $('#header .top-nav').addClass('on'); 62 $('#header .mobile-nav').addClass('on'); 63 } 64 return false; 65 }); 66 $('#header .top-nav .mobile-nav ul li.menu-item-has-children .toggle').click(function(e){ 67 obj_parent = $(this).parent(); 68 if ($(obj_parent).hasClass("open-sub-menu")){ 69 $(obj_parent).removeClass("open-sub-menu"); 70 $(obj_parent).find("> .sub-menu").slideUp(500); 71 } else { 72 obj_menu = $(obj_parent).parent(); 73 obj_menu.find('.open-sub-menu').removeClass("open-sub-menu"); 74 obj_menu.find('ul.sub-menu').slideUp(500); 75 $(obj_parent).addClass("open-sub-menu"); 76 $(obj_parent).find("> .sub-menu").stop().slideDown(500); 77 } 78 return false; 79 }); 80 } 81 82 83 /* ========================================================================== 84 Layout Functions 85 ========================================================================== */ 86 function onWindowResize(){ 87 px_width_window = $(window).width(); 88 px_height_window = $(window).height(); 89 90 // Width Sync Elements 91 $(".w-sync").each(function(){ $(this).parent().attr("data-w-sync-px", 0); }); 92 $(".w-sync").each(function(){ 93 var px_width = parseInt($(this).parent().attr("data-w-sync-px")); 94 $(this).css("width", "auto"); 95 if ($(this).innerWidth() > px_width){ px_width = $(this).innerWidth(); } 96 $(this).parent().attr("data-w-sync-px", px_width); 97 $(this).parent().find("> .w-sync").css("width", (px_width + 5)); 98 $(this).parent().find("> .w-sync").addClass("w-sync-set"); 99 }); 100 101 // Height Sync Elements 102 $(".h-sync").each(function(){ $(this).parent().attr("data-h-sync-px", 0); }); 103 $(".h-sync").each(function(){ 104 var px_height = parseInt($(this).parent().attr("data-h-sync-px")); 105 $(this).css("height", "auto"); 106 if ($(this).innerHeight() > px_height){ px_height = $(this).innerHeight(); } 107 $(this).parent().attr("data-h-sync-px", px_height); 108 $(this).parent().find("> .h-sync").css("height", px_height); 109 $(this).parent().find("> .h-sync").addClass("h-sync-set"); 110 }); 111 112 $(".h-sync-md").each(function(){ $(this).parent().attr("data-h-sync-md-px", 0); }); 113 $(".h-sync-md").each(function(){ 114 $(this).css("height", "auto"); 115 if (px_width_window > px_md_width){ 116 var px_height = parseInt($(this).parent().attr("data-h-sync-md-px")); 117 if ($(this).innerHeight() > px_height){ px_height = $(this).innerHeight(); } 118 $(this).parent().attr("data-h-sync-md-px", px_height); 119 $(this).parent().find("> .h-sync-md").css("height", px_height); 120 } 121 $(this).parent().find("> .h-sync-md").addClass("h-sync-md-set"); 122 }); 123 124 $(".h-sync-lg").each(function(){ $(this).parent().attr("data-h-sync-lg-px", 0); }); 125 $(".h-sync-lg").each(function(){ 126 $(this).css("height", "auto"); 127 if (px_width_window > px_lg_width){ 128 var px_height = parseInt($(this).parent().attr("data-h-sync-lg-px")); 129 if ($(this).innerHeight() > px_height){ px_height = $(this).innerHeight(); } 130 $(this).parent().attr("data-h-sync-lg-px", px_height); 131 $(this).parent().find("> .h-sync-lg").css("height", px_height); 132 } 133 $(this).parent().find("> .h-sync-lg").addClass("h-sync-lg-set"); 134 }); 135 136 $(".h-sync-md-parent").each(function(){ $(this).parent().parent().attr("data-h-sync-md-parent-px", 0); }); 137 $(".h-sync-md-parent").each(function(){ 138 $(this).css("height", "auto"); 139 if (px_width_window > px_md_width){ 140 var px_height = parseInt($(this).parent().parent().attr("data-h-sync-md-parent-px")); 141 if ($(this).innerHeight() > px_height){ px_height = $(this).innerHeight(); } 142 $(this).parent().parent().attr("data-h-sync-md-parent-px", px_height); 143 $(this).parent().parent().find(".h-sync-md-parent").css("height", px_height); 144 } 145 $(this).parent().parent().find(".h-sync-md-parent").addClass("h-sync-md-parent-set"); 146 }); 147 148 // Square Element 149 $(".w-h-sync").each(function(){ 150 $(this).css("height", $(this).css("width")); 151 $(this).addClass("w-h-sync-set"); 152 }); 153 154 // Vertical Center Element 155 $(".y-center").each(function(){ $(this).css("top",0); }); 156 $(".y-center").each(function(){ 157 var px_padding = (($(this).parent().height() - $(this).innerHeight()) / 2); 158 $(this).css("top", px_padding); 159 $(this).addClass("y-center-set"); 160 }); 161 162 $(".y-center-md").each(function(){ $(this).css("top",0); }); 163 $(".y-center-md").each(function(){ 164 $(this).css("height", "auto"); 165 if (px_width_window > px_md_width){ 166 var px_padding = (($(this).parent().height() - $(this).innerHeight()) / 2); 167 $(this).css("top", px_padding); 168 } 169 $(this).addClass("y-center-md-set"); 170 }); 171 172 // Vertical Fourth Element 173 $(".y-fourth").each(function(){ $(this).css("top",0); }); 174 $(".y-fourth").each(function(){ 175 var px_padding = (($(this).parent().height() - $(this).innerHeight()) / 4); 176 $(this).css("top", px_padding); 177 $(this).addClass("y-fourth-set"); 178 }); 179 180 $(".y-fourth-md").each(function(){ $(this).css("top",0); }); 181 $(".y-fourth-md").each(function(){ 182 $(this).css("height", "auto"); 183 if (px_width_window > px_md_width){ 184 var px_padding = (($(this).parent().height() - $(this).innerHeight()) / 4); 185 $(this).css("top", px_padding); 186 } 187 $(this).addClass("y-fourth-md-set"); 188 }); 189 190 onWindowScroll(); 191 } 192 193 function onWindowResizeInterval(){ 194 onWindowResize(); 195 setTimeout(onWindowResize, 500); 196 setTimeout(onWindowResize, 1000); 197 setTimeout(onWindowResize, 3000); 198 setTimeout(onWindowResize, 5000); 199 } 200 201 202 /* ========================================================================== 203 Scroll Functions 204 ========================================================================== */ 205 function onWindowScroll(){ 206 px_scroll_top = $(window).scrollTop(); 207 px_height_window = $(window).height(); 208 px_height_document = $(document).height(); 209 210 211 // Scroll Effect 212 $(".scroll-effect-0").not(".scroll-effect-set").each(function(){ 213 $(this).addClass("scroll-effect-set"); 214 }); 215 216 $(".scroll-effect-33").not(".scroll-effect-set").each(function(){ 217 if ($(this).offset().top < (px_scroll_top + (px_height_window * 0.33))){ 218 $(this).addClass("scroll-effect-set"); 219 } 220 }); 221 222 $(".scroll-effect-66").not(".scroll-effect-set").each(function(){ 223 if ($(this).offset().top < (px_scroll_top + (px_height_window * 0.66))){ 224 $(this).addClass("scroll-effect-set"); 225 } 226 }); 227 228 $(".scroll-effect-99").not(".scroll-effect-set").each(function(){ 229 if ($(this).offset().top < (px_scroll_top + (px_height_window * 0.99))){ 230 $(this).addClass("scroll-effect-set"); 231 } 232 }); 233
234 // Scroll Background Effect 235 $(".scroll-background").each(function(){ 236 if (px_width_window > px_md_width){ 237 var px_image_pull = (($(this).offset().top + 400) - (px_scroll_top + px_height_window)) / 6; 238 $(this).css("backgroundPositionY", "calc(100% - " + px_image_pull + "px)"); 239 } else { 240 $(this).css("backgroundPositionY", "center"); 241 } 242 }); 243 244 // Header Management 245 if (px_scroll_top <= 10){ $("#header").removeClass("compact"); } 246 else { $("#header").addClass("compact"); } 247 248 // Subnav Management 249 if ($("#subnav").length){ 250 $("#header").addClass("has-subnav"); 251 var obj_subnav = $("#subnav"); 252 if ((px_scroll_top + px_height_offset) >= obj_subnav.offset().top){ obj_subnav.addClass("fixed"); } 253 else { obj_subnav.removeClass("fixed"); } 254 255 if ($(".layout .anchor-link").length){ 256 if (!$("#subnav").hasClass("lock")){ 257 if ((px_scroll_top + px_height_offset) < $(".layout .anchor-link").eq(0).offset().top){ 258 $("#subnav .menu li").removeClass("active"); 259 } else { 260 for (i = 0; i <= ($(".layout .anchor-link").length - 1); i++){ 261 if ((px_scroll_top + px_height_offset) >= $(".layout .anchor-link").eq(i).offset().top){ 262 obj_item = $("#subnav .menu li").eq(i); 263 $("#subnav .menu li").not(obj_item).removeClass("active"); 264 obj_item.addClass("active"); 265 } 266 } 267 } 268 } 269 } 270 271 } 272 } 273 274 /* ========================================================================== 275 Utility Functions 276 ========================================================================== */ 277 function checkBrowser(){ 278 // Mobile 279 (function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))bool_mobile = true})(navigator.userAgent||navigator.vendor||window.opera); 280 report('[â¢] checkBrowser(): Mobile == ' + bool_mobile); 281 282 // Touch 283 bool_touch = 'ontouchstart' in document.documentElement; 284 if (bool_touch){ $("body").addClass("touch"); } 285 report('[â¢] checkBrowser(): Touch == ' + bool_touch); 286 287 // IE 288 var version_ie = detectIE(); 289 // var version_ie = 11; 290 if (version_ie === false) { bool_ie = false; } 291 else if (version_ie >= 12) { bool_ie = false; } 292 else { bool_ie = true; $("body").addClass("msie"); } 293 report('[â¢] checkBrowser(): Internet Explorer == ' + bool_ie); 294 } 295 296 function report(str){ 297 if(typeof console != 'undefined') { 298 str += ''; 299 if (str.substr(0,3) == '[!]'){ alert(str); } 300 if (str.substr(0,1) == '['){ console.log(str); } 301 else { console.log('[ ] ' + str); } 302 } 303 if ($(".debug").length){ 304 if (str.substr(0,1) == '['){ $(".debug").html($(".debug").html() + "<br>" + str); } 305 else { $(".debug").html($(".debug").html() + "<br>[ ] " + str); } 306 } 307 } 308 309 function reportObject(obj){ 310 report('[o] reportObject()'); 311 var str = ''; 312 for(var k in obj){ if (obj.hasOwnProperty(k)){ str += '[o] ' + k + ' = ' + obj[k] + '\n'; } } 313 report(str); 314 } 315 316 function getQueryVariable(str_var){ 317 var query = window.location.search.substring(1); 318 var vars = query.split("&"); 319 for (var i=0; i<vars.length; i++) { 320 var pair = vars[i].split("="); 321 if(pair[0] == str_var){return pair[1];} 322 } 323 return(false); 324 } 325 326 function getRandom(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } 327 328 function isNumeric(num) { return !isNaN(parseFloat(n)) && isFinite(n); } 329 330 function isInteger(num) { return !isNaN(num) && (function(x) { return (x | 0) === x; })(parseFloat(num)) } 331 332 function isElementPresent(str_element){ return ($(str_element).length > 0); } 333 334 function isAttrPresent(obj, str_attr){ attr = obj.attr(str_attr); if (typeof attr !== typeof undefined && attr !== false) { return true; } else { return false; } } 335 336 function delayAddClass(obj, str_class, ms_delay){ setTimeout(function(){ obj.addClass(str_class); }, ms_delay); } 337 338 function delayRemoveClass(obj, str_class, ms_delay){ setTimeout(function(){ obj.removeClass(str_class); }, ms_delay); } 339 340 function validateEmail(email) { var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email); } 341 342 function detectIE(){ var ua = window.navigator.userAgent; var msie = ua.indexOf('MSIE '); if (msie > 0) {return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10); } var trident = ua.indexOf('Trident/'); if (trident > 0) {var rv = ua.indexOf('rv:'); return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10); } var edge = ua.indexOf('Edge/'); if (edge >
342 0) {return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10); } return false; } 343 344})(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.