1$.ajaxSetup({ cache: false }); 2 3// Show Menu on Hover 4( function($) { 5 6 var enter, leave; 7 8 var storage = { 9 activeClass: "submenu-is-shown", 10 activeShadowClass: "is-shadow-shown", 11 showTime: 200, 12 $last_li: false 13 }; 14 15 var bindEvents = function() { 16 var $selector = $(".flyout-nav > li"), 17 links = $selector.find("> a"); 18 19 $selector.on("mouseenter", function() { 20 showSubMenu( $(this) ); 21 }); 22 23 $selector.on("mouseleave", function() { 24 hideSubMenu( $(this) ); 25 }); 26 27 links.on("click", function() { 28 onClick( $(this).closest("li") ); 29 }); 30 31 links.each( function() { 32 var link = this, 33 $li = $(link).closest("li"), 34 has_sub_menu = ( $li.find(".flyout").length ); 35 36 if (has_sub_menu) { 37 link.addEventListener("touchstart", function(event) { 38 onTouchStart(event, $li ); 39 }, false); 40 } 41 }); 42 43 $("body").get(0).addEventListener("touchstart", function(event) { 44 onBodyClick(event, $(this)); 45 }, false); 46 47 }; 48 49 var onBodyClick = function(event) { 50 var activeBodyClass = storage.activeShadowClass, 51 is_click_on_shadow = ( $(event.target).hasClass(activeBodyClass) ); 52 53 if (is_click_on_shadow) { 54 var $active_li = $(".flyout-nav > li." + storage.activeClass).first(); 55 56 if ($active_li.length) { 57 hideSubMenu( $active_li ); 58 } 59 } 60 }; 61 62 var onClick = function( $li ) { 63 var is_active = $li.hasClass(storage.activeClass); 64 65 if (is_active) { 66 var href = $li.find("> a").attr("href"); 67 if ( href && (href !== "javascript:void(0);") ) { 68 hideSubMenu( $li ); 69 } 70 71 } else { 72 showSubMenu( $li ); 73 } 74 }; 75 76 var onTouchStart = function(event, $li) { 77 event.preventDefault(); 78 79 var is_active = $li.hasClass(storage.activeClass); 80 81 if (is_active) { 82 hideSubMenu( $li ); 83 } else { 84 var $last_li = $(".flyout-nav > li." +storage.activeClass); 85 if ($last_li.length) { 86 storage.$last_li = $last_li; 87 } 88 showSubMenu( $li ); 89 } 90 }; 91 92 var showSubMenu = function( $li ) { 93 var is_active = $li.hasClass(storage.activeClass), 94 has_sub_menu = ( $li.find(".flyout").length ); 95 96 if (is_active) { 97 clearTimeout( leave ); 98 99 } else { 100 if (has_sub_menu) { 101 102 enter = setTimeout( function() { 103 104 if (storage.$last_li && storage.$last_li.length) { 105 clearTimeout( leave ); 106 storage.$last_li.removeClass(storage.activeClass); 107 } 108 109 $li.addClass(storage.activeClass); 110 toggleMainOrnament(true); 111 }, storage.showTime); 112 } 113 } 114 }; 115 116 var hideSubMenu = function( $li ) { 117 var is_active = $li.hasClass(storage.activeClass); 118 119 if (!is_active) { 120 clearTimeout( enter ); 121 122 } else { 123 storage.$last_li = $li; 124 125 leave = setTimeout(function () { 126 $li.removeClass(storage.activeClass); 127 toggleMainOrnament(false); 128 }, storage.showTime * 2); 129 } 130 }; 131 132 var toggleMainOrnament = function($toggle) { 133 var $body = $("body"), 134 activeClass = storage.activeShadowClass; 135 136 if ($toggle) { 137 $body.addClass(activeClass); 138 } else { 139 $body.removeClass(activeClass); 140 } 141 }; 142 143 $(document).ready( function() { 144 bindEvents(); 145 }); 146 147})(jQuery); 148 149var MatchMedia = function( media_query ) { 150 var matchMedia = window.matchMedia, 151 is_supported = (typeof matchMedia === "function");
152 if (is_supported && media_query) { 153 return matchMedia(media_query).matches 154 } else { 155 return false; 156 } 157}; 158 159$(document).ready(function() { 160 161 // MOBILE nav slide-out menu 162 $('#mobile-nav-toggle').click( function(){ 163 if (!$('.nav-negative').length) { 164 $('body').prepend($('header .apps').clone().removeClass('apps').addClass('nav-negative')); 165 $('body').prepend($('header .auth').clone().addClass('nav-negative')); 166 $('body').prepend($('header .search').clone().addClass('nav-negative')); 167 $('body').prepend($('header .offline').clone().addClass('nav-negative')); 168 $('.nav-negative').hide().slideToggle(200); 169 } else { 170 $('.nav-negative').slideToggle(200); 171 } 172 $("html, body").animate({ scrollTop: 0 }, 200); 173 return false; 174 }); 175 176 // STICKY CART for non-mobile 177 var $clone = null; 178 179 /*$(window).scroll(function(){ 180 var is_mobile_case = MatchMedia("only screen and (max-width: 760px)"); 181 if (!is_mobile_case) { 182 var scroll_top = $(this).scrollTop(); 183 var $cart = $("#cart"), 184 $flyer = $('#cart-flyer'); 185 186 if ( scroll_top >= 55 && !$cart.hasClass( "fixed" ) && !$cart.hasClass( "empty" ) && !($(".cart-summary-page")).length ) { 187 $cart.hide(); 188 189 if (!$clone) { 190 $clone = $("<div />").css({ 191 width: $cart.outerWidth(), 192 height: "1rem" 193 }); 194 $cart.before($clone); 195 } 196 197 $cart.addClass( "fixed" ); 198 199 if ($flyer.length) { 200 var _width = $flyer.width()+52; 201 var _offset_right = $(window).width() - $flyer.offset().left - _width + 1; 202 203 $("#cart").css({ "right": _offset_right+"px", "width": _width+"px" }); 204 } 205 206 $cart.show(); 207 // $cart.slideToggle(200); 208 } else if ( scroll_top < 50 && $("#cart").hasClass( "fixed" ) ) { 209 210 $cart.removeClass( "fixed" ); 211 $cart.css({ "width": "auto" }); 212 213 if ($clone) { $clone.remove(); $clone = null; } 214 } 215 } 216 });*/ 217}); 218 219// MAILER app email subscribe form 220var SubscribeSection = ( function($) { 221 222 SubscribeSection = function(options) { 223 var that = this; 224 225 // DOM 226 that.$wrapper = options["$wrapper"]; 227 that.$form = that.$wrapper.find("form"); 228 that.$emailField = that.$wrapper.find(".js-email-field"); 229 that.$submitButton = that.$wrapper.find(".js-submit-button"); 230 231 // VARS 232 that.request_uri = options["request_uri"]; 233 that.locales = options["locales"]; 234 235 // DYNAMIC VARS 236 237 // INIT 238 that.initClass(); 239 }; 240 241 SubscribeSection.prototype.initClass = function() { 242 var that = this; 243 244 if (that.request_uri.substr(0,4) === "http") { 245 that.request_uri = that.request_uri.replace("http:", "").replace("https:", ""); 246 } 247 248 var $invisible_captcha = that.$form.find(".wa-invisible-recaptcha"); 249 if (!$invisible_captcha.length) { 250 that.initView(); 251 } 252 253 that.initSubmit(); 254 }; 255 256 SubscribeSection.prototype.initView = function() { 257 var that = this; 258 259 that.$emailField.on("focus", function() { 260 toggleView(true); 261 }); 262 263 $(document).on("click", watcher); 264 265 function watcher(event) { 266 var is_exist = $.contains(document, that.$wrapper[0]); 267 if (is_exist) { 268 var is_target = $.contains(that.$wrapper[0], event.target); 269 if (!is_target) { 270 toggleView(false); 271 } 272 } else { 273 $(document).off("click", watcher); 274 } 275 } 276 277 function toggleView(show) { 278 var active_class = "is-extended"; 279 if (show) { 280 that.$wrapper.addClass(active_class); 281 } else { 282 var email_value = that.$emailField.val(); 283 if (!email_value.length) { 284 that.$wrapper.removeClass(active_class); 285 } else { 286 287 } 288 } 289 } 290 }; 291 292 SubscribeSection.prototype.initSubmit = function() { 293 var that = this, 294 $form = that.$form, 295 $errorsPlace = that.$wrapper.find(".js-errors-place"), 296 is_locked = false; 297 298 $form.on("submit", onSubmit); 299 300 function onSubmit(event) { 301 event.preventDefault(); 302 303 var formData = getData(); 304 305 if (formData.errors.length) { 306 renderErrors(formData.errors); 307 } else { 308 request(formData.data); 309 } 310 } 311 312 /** 313 * @return {Object} 314 * */ 315 function getData() { 316 var result = { 317 data: [], 318 errors: [] 319 }, 320 data = $form.serializeArray(); 321 322 $.each(data, function(index, item) { 323 if (item.value) { 324 result.data.push(item); 325 } else { 326 result.errors.push({ 327 name: item.name 328 }); 329 } 330 }); 331 332 return result; 333 } 334 335 /** 336 * @param {Array} data 337 * */ 338 function request(data) { 339 if (!is_locked) { 340 is_locked = true; 341 342 var href = that.request_uri; 343 344 $.post(href, data, "jsonp") 345 .always( function() { 346 is_locked = false; 347 }) 348 .done( function(response) { 349 if (response.status === "ok") { 350 renderSuccess(); 351 352 } else if (response.errors) { 353 var errors = formatErrors(response.errors); 354 renderErrors(errors); 355 } 356 }); 357 } 358 359 /** 360 * @param {Object} errors 361 * @result {Array} 362 * */ 363 function formatErrors(errors) { 364 var result = []; 365 366 $.each(errors, function(text, item) { 367 var name = item[0]; 368 369 if (name === "subscriber[email]") { name = "email"; } 370 371 result.push({ 372 name: name, 373 value: text 374 }); 375 }); 376 377 return result; 378 } 379 } 380 381 /** 382 * @param {Array} errors 383 * */ 384 function renderErrors(errors) { 385 var error_class = "error"; 386 387 if (!errors || !errors[0]) { 388 errors = []; 389 } 390 391 $.each(errors, function(index, item) { 392 var name = item.name, 393 text = item.value; 394 395 var $field = that.$wrapper.find("[name=\"" + name + "\"]"), 396 $text = $("<span class='c-error' />").addClass("error"); 397 398 if ($field.length && !$field.hasClass(error_class)) { 399 if (text) { 400 $field.parent().append($text.text(text)); 401 } 402 403 $field 404 .addClass(error_class) 405 .one("focus click change", function() { 406 $field.removeClass(error_class); 407 $text.remove(); 408 }); 409 } else { 410 $errorsPlace.append($text); 411 412 $form.one("submit", function() { 413 $text.remove(); 414 }); 415 } 416 }); 417 } 418
419 function renderSuccess() { 420 var $text = that.$wrapper.find(".js-success-message"); 421 $form.hide(); 422 $text.show(); 423 } 424 }; 425 426 return SubscribeSection; 427 428})(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.