1 2 3window.cpMedia = window.cpMedia || (function (global, documentElement) { 4 5 var DEBUG = false; 6 var matchMedia = global.matchMedia; 7 8 function each(collection, fn) { 9 var i = 0, 10 length = collection.length, 11 cont; 12 13 for (i; i < length; i++) { 14 cont = fn(collection[i], i); 15 if (cont === false) { 16 break; //allow early exit 17 } 18 } 19 } 20 21 function isArray(target) { 22 return Object.prototype.toString.apply(target) === '[object Array]'; 23 } 24 25 function isFunction(target) { 26 return typeof target === 'function'; 27 } 28 29 function evalMediaQueryOnElement(query, element) { 30 var media = { all: true, screen: true, print: false }; 31 var coordinates; 32 try { 33 coordinates = element.getBoundingClientRect(); 34 } catch (e) { 35 coordinates = { 36 width: element.offsetWidth, 37 height: element.offsetHeight 38 }; 39 } 40 41 media.thisWidth = coordinates.width || coordinates.right - coordinates.left; 42 media.thisHeight = coordinates.height || coordinates.bottom - coordinates.top; 43 media.thisAspectRatio = media.thisWidth / media.thisHeight, 44 media.thisOrientation = media.thisWidth > media.thisHeight ? "landscape" : "portrait"; 45 46 var qReplaced = query 47 .replace(/\(|\)/g, "") 48 .replace(/\s*,\s*/g, ") || (") 49 .replace(/\s+and\s+/gi, " && ") 50 .replace(/min-(.*?):/gi, "$1>=") 51 .replace(/max-(.*?):/gi, "$1<=") 52 .replace(/above-(.*?):/gi, "$1>") 53 .replace(/below-(.*?):/gi, "$1<") 54 .replace(/min-|max-/gi, "") 55 .replace(/(all|screen|print)/, "d.$1") 56 .replace(/:/g, "==") 57 .replace(/([\w-]+)\s*([<>=]+)\s*(\w+)/g, function ($0, $1, $2, $3) { 58 return "d." + toCamelCase($1) + $2 + parseCSSNumber($3); 59 }) 60 .replace(/([<>=]+)([A-z][\w-]*)/g, '$1"$2"'); 61 var a = Function("d", "return(" + qReplaced + ")")(media); 62 return a; 63 } 64 65 function toCamelCase(value) { 66 return value.toLowerCase().replace(/-[a-z]/g, function ($0) { 67 return $0[1].toUpperCase(); 68 }); 69 } 70 71 function parseCSSNumber(value) { 72 return value.replace(/([\d\.]+)(%|em|in|pt|px)/, function ($0, $1, $2) { 73 return ($2 == "em") ? $1 * 16 : ($2 == "in") ? $1 * 96 : ($2 == "pt") ? $1 * 96 / 72 : ($2 == "%") ? $1 / (scope.innerWidth || documentElement.clientWidth) : $1; 74 }); 75 } 76 77 function diag(message) { 78 if (DEBUG) { 79 console.log(message); 80 } 81 } 82 83 function QueryHandler(options, elements) { 84 this.options = options; 85 !options.deferSetup && this.setup(elements); 86 } 87 QueryHandler.prototype = { 88 89 setup: function (elements) { 90 if (this.options.setup) { 91 this.options.setup(elements); 92 } 93 this.initialised = true; 94 }, 95 96 on: function (e, element) { 97 !this.initialised && this.setup(); 98 this.options.match && this.options.match(e, element); 99 }, 100 101 off: function (e, element) { 102 this.options.unmatch && this.options.unmatch(e, element); 103 }, 104 105 destroy: function () { 106 this.options.destroy ? this.options.destroy() : this.off(); 107 }, 108 109 equals: function (target) { 110 return this.options === target || this.options.match === target; 111 } 112 }; 113 114 function MediaQuery(query, isUnconditional) { 115 this.query = query; 116 this.isUnconditional = isUnconditional; 117 this.handlers = []; 118 this.mql = matchMedia(query); 119 120 if (this.mql.media != query) { 121 diag("Media query might be invalid=" + query + "\nParsed as=" + this.mql.media); 122 } 123 124 var self = this; 125 this.listener = function (mql) { 126 self.mql = mql; 127 self.assess(); 128 }; 129 this.mql.addListener(this.listener); 130 } 131 MediaQuery.prototype = { 132 addHandler: function (handler) { 133 var qh = new QueryHandler(handler); 134 this.handlers.push(qh); 135 136 this.matches() && qh.on(); 137 }, 138 139 removeHandler: function (handler) { 140 var handlers = this.handlers; 141 each(handlers, function (h, i) { 142 if (h.equals(handler)) { 143 h.destroy(); 144 return !handlers.splice(i, 1); //remove from array and exit each early 145 } 146 }); 147 }, 148 149 matches: function () { 150 return this.mql.matches || this.isUnconditional; 151 }, 152 153 clear: function () { 154 each(this.handlers, function (handler) { 155 handler.destroy(); 156 }); 157 this.mql.removeListener(this.listener); 158 this.handlers.length = 0; //clear array 159 }, 160 161 assess: function () { 162 var action = this.matches() ? 'on' : 'off'; 163 164 each(this.handlers, function (handler) { 165 handler[action](); 166 }); 167 } 168 }; 169 170 function ElementWrapper (element, query, rawQuery) { 171 this.element = element; 172 this.matched = false; 173 this.query = query; 174 this.rawQuery = rawQuery; 175 var rwdinfo = $(element).data('rwdinfo'); 176 if (rwdinfo == null) { 177 rwdinfo = []; 178 } 179 rwdinfo.push(this); 180 $(element).data('rwdinfo', rwdinfo); 181 } 182 183 function MediaElement(query, isUnconditional) { 184 this.query = query; 185 this.isUnconditional = isUnconditional; 186 this.handlers = []; 187 this.isMediaElement = true; 188 this.elementWrappers = []; 189 this.initElements(); 190 } 191 MediaElement.prototype = { 192 193 initElements : function () { 194 var all, 195 element, 196 match = this.query.match(/(.+?):media\((.+?)\)/); 197 this.elementWrappers = []; 198 if (match && /this/.test(match[2])) { 199 if (documentElement.querySelectorAll) { 200 all = documentElement.querySelectorAll(match[1]); 201 202 for (var index = 0; element = all[index]; ++index) { 203 this.elementWrappers.push(new ElementWrapper(element, match[2], this.query)); 204 } 205 } 206 } 207 }, 208 addHandler: function (handler) { 209 var elementWrappers = this.elementWrappers, 210 index, 211 elements = []; 212 for (index = 0; index < elementWrappers.length; ++index) { 213 elements.push(elementWrappers[index].element); 214 } 215 var qh = new QueryHandler(handler, elements); 216 this.handlers.push(qh); 217 218 this.assessOneHandler(null, qh);//this.matched && qh.on(); 219 //this.assessForce(null, qh); //performance decrease, but not cached elements 220 }, 221 222 removeHandler: function (handler) { 223 var handlers = this.handlers; 224 each(handlers, function (h, i) { 225 if (h.equals(handler)) { 226 h.destroy(); 227 return !handlers.splice(i, 1); //remove from array and exit each early 228 } 229 }); 230 }, 231 232 clear: function () { 233 each(this.handlers, function (handler) { 234 handler.destroy(); 235 }); 236 //this.mql.removeListener(this.listener); 237 this.handlers.length = 0; //clear array 238 }, 239 240 /// Access and execute specific handler if matches media query on current elements 241 assessOneHandler: function (e, handler) { 242 var elementWrappers = this.elementWrappers, 243 elementWrapper, 244 index; 245 246 for (index = 0; index < elementWrappers.length; ++index) { 247 elementWrapper = elementWrappers[index]; 248 249 if (evalMediaQueryOnElement(elementWrapper.query, elementWrapper.element) || this.isUnconditional) { 250 handler.on(e, elementWrapper.element); 251 elementWrapper.matched = true; 252 } 253 } 254 }, 255 256 /// Access and execute current handlers if matches or unmatched media query on current elements 257 assess: function (e) { 258 var elementWrappers = this.elementWrappers, 259 elementWrapper, 260 index; 261 262 for (index = 0; index < elementWrappers.length; ++index) { 263 elementWrapper = elementWrappers[index]; 264 265 if (evalMediaQueryOnElement(elementWrapper.query, elementWrapper.element) || this.isUnconditional) { 266 this.match(e, elementWrapper); 267 } else { 268 this.unmatch(e, elementWrapper); 269 } 270 } 271 }, 272 273 match: function (e, elementWrapper) { 274 if (elementWrapper.matched) { 275 return; //already on 276 } 277 278 each(this.handlers, function (handler) { 279 handler.on(e, elementWrapper.element); 280 }); 281 elementWrapper.matched = true; 282 }, 283 284 unmatch: function (e, elementWrapper) { 285 if (!elementWrapper.matched) { 286 return; //already off 287 } 288 289 each(this.handlers, function (handler) { 290 handler.off(e, elementWrapper.element); 291 }); 292 elementWrapper.matched = false; 293 }, 294 /// Access and execute current handlers if matches or unmatched media query on all elements (no cached) 295 /// If handler provided, access and execute only that handler if matches media query on all elements (no cached) 296 assessForce: function (e, handler) { 297 var all, 298 element, 299 match = this.query.match(/(.+?):media\((.+?)\)/); 300 if (match && /this/.test(match[2])) { 301 if (documentElement.querySelectorAll) { 302 all = documentElement.querySelectorAll(match[1]); 303 304 for (var index = 0; element = all[index]; ++index) { 305 var action = (evalMediaQueryOnElement(match[2], element) || this.isUnconditional) ? 'on' : 'off'; 306 if (!handler) { 307 each(this.handlers, function (handler) { 308 handler[action](e, element); 309 });
310 } else if (action === 'on') { 311 handler[action](e, element); 312 } 313 } 314 } 315 } 316 } 317 }; 318 319 function MediaQueryDispatch() { 320 if (!matchMedia) { 321 throw new Error('matchMedia not present, legacy browsers require a polyfill'); 322 } 323 this.queries = {}; 324 this.listening = false; 325 this.browserIsIncapable = !matchMedia('only all').matches; 326 327 this.fire = function (e) { 328 var queries = this.queries, 329 mediaQuery; 330 331 for (mediaQuery in queries) { 332 if (queries.hasOwnProperty(mediaQuery)) { 333 queries[mediaQuery].isMediaElement && queries[mediaQuery].assess(e); 334 //queries[mediaQuery].isMediaElement && queries[mediaQuery].assessForce(e, null); //performance decrease, but not cached elements 335 } 336 } 337 return this; 338 }; 339 340 this.fireQuery = function (mediaQuery, e) { 341 var queries = this.queries; 342 343 if (queries.hasOwnProperty(mediaQuery)) { 344 queries[mediaQuery].isMediaElement && queries[mediaQuery].assess(e); 345 } 346 return this; 347 }; 348 349 this.listen = function (timeout) { 350 var self = this; 351 352 timeout = timeout || 160; 353 354 //creates closure for separate timed events 355 function wireFire(event) { 356 var timer; 357 358 window.addEventListener(event, function (e) { 359 timer && clearTimeout(timer); 360 361 timer = setTimeout(function () { 362 self.fire(e); 363 }, timeout); 364 }, false); 365 } 366 367 //prevent multiple event handlers 368 if (this.listening) { 369 return this; 370 } 371 372 // any browser that doesn't implement this 373 // will not have media query support 374 if (window.addEventListener) { 375 wireFire('resize'); 376 wireFire('orientationChange'); 377 } 378 379 self.fire(); 380 this.listening = true; 381 382 return this; 383 }; 384 } 385 MediaQueryDispatch.prototype = { 386 387 register: function (q, options, shouldDegrade) { 388 var queries = this.queries, 389 isUnconditional = shouldDegrade && this.browserIsIncapable; 390 391 if (!queries[q]) { 392 if (/this/.test(q)) { 393 queries[q] = new MediaElement(q, isUnconditional); 394 this.listen(); 395 } else { 396 queries[q] = new MediaQuery(q, isUnconditional); 397 } 398 } 399 400 //normalize to object in an array 401 if (isFunction(options)) { 402 options = { match: options }; 403 } 404 if (!isArray(options)) { 405 options = [options]; 406 } 407 each(options, function (handler) { 408 queries[q].addHandler(handler); 409 }); 410 411 return this; 412 }, 413 414 unregister: function (q, handler) { 415 var query = this.queries[q]; 416 417 if (query) { 418 if (handler) { 419 query.removeHandler(handler); 420 } 421 else { 422 query.clear(); 423 delete this.queries[q]; 424 } 425 } 426 427 return this; 428 }, 429 diag: function (message) { 430 diag(message); 431 } 432 }; 433 434 return new MediaQueryDispatch(); 435}(this, document.documentElement)); 436 437function toggleClassMedia(className, mediaQueryElement, opts) { 438 //Extending toggleClass with options. 439 var defaults = { 440 match: null, // [function] code to execute when media query match on element 441 unmatch: null // [function] code to execute when media query unmatch on element 442 }; 443 var options = $.extend(defaults, opts); 444 cpMedia.register(mediaQueryElement, { 445 setup: function (elements) { 446 elements = elements || []; 447 for (var i = 0; i < elements.length; i++) { 448 $(elements[i]).removeClass(className); 449 cpMedia.diag('$(element[' + i + ']).removeClass("' + className + '"), mediaQuery: ' + mediaQueryElement); 450 if (options.unmatch != null && typeof (options.unmatch) === 'function') { 451 options.unmatch(e, elements[i], className, null, mediaQueryElement); 452 cpMedia.diag('options.unmatch(e, element[' + i + '], "' + className + '", null, "' + mediaQueryElement + '")'); 453 } 454 } 455 }, 456 match: function (e, element) { 457 $(element).addClass(className); 458 cpMedia.diag('$(element).addClass("' + className + '"), mediaQuery: ' + mediaQueryElement); 459 if (options.match != null && typeof (options.match) === 'function') { 460 options.match(e, element, className, null, mediaQueryElement); 461 cpMedia.diag('options.match(e, element, "' + className + '", null, "' + mediaQueryElement + '")'); 462 } 463 }, 464 unmatch: function (e, element) { 465 $(element).removeClass(className); 466 cpMedia.diag('$(element).removeClass("' + className + '"), mediaQuery: ' + mediaQueryElement); 467 if (options.unmatch != null && typeof (options.unmatch) === 'function') { 468 options.unmatch(e, element, className, null, mediaQueryElement); 469 cpMedia.diag('options.unmatch(e, element, "' + className + '", null, "' + mediaQueryElement + '")'); 470 } 471 } 472 }, false); 473} 474 475function toggleClassesMedia(classNameMatch, classNameUnmatch, mediaQueryElement, opts) { 476 //Extending toggleClass with options. 477 var defaults = { 478 match: null, // [function] code to execute when media query match on element 479 unmatch: null // [function] code to execute when media query unmatch on element 480 }; 481 var options = $.extend(defaults, opts); 482 cpMedia.register(mediaQueryElement, { 483 setup: function (elements) { 484 elements = elements || []; 485 for (var i = 0; i < elements.length; i++) { 486 $(elements[i]).addClass(classNameUnmatch).removeClass(classNameMatch); 487 cpMedia.diag('$(elements[' + i + ']).removeClass("' + classNameMatch + '").addClass("' + classNameUnmatch + '"), mediaQuery: ' + mediaQueryElement); 488 if (options.unmatch != null && typeof (options.unmatch) === 'function') { 489 options.unmatch(null, elements[i], classNameMatch, classNameUnmatch, mediaQueryElement); 490 cpMedia.diag('options.unmatch(e, element, "' + classNameUnmatch + '", "' + classNameUnmatch + '", "' + mediaQueryElement + '")'); 491 } 492 } 493 }, 494 match: function (e, element) { 495 $(element).addClass(classNameMatch).removeClass(classNameUnmatch); 496 cpMedia.diag('$(element).addClass("' + classNameMatch + '").removeClass("' + classNameUnmatch + '"), mediaQuery: ' + mediaQueryElement); 497 if (options.match != null && typeof (options.match) === 'function') { 498 options.match(e, element, classNameMatch, classNameUnmatch, mediaQueryElement); 499 cpMedia.diag('options.match(e, element, "' + classNameMatch + '", "' + classNameUnmatch + '", "' + mediaQueryElement + '")'); 500 } 501 }, 502 unmatch: function (e, element) { 503 $(element).addClass(classNameUnmatch).removeClass(classNameMatch); 504 cpMedia.diag('$(element).removeClass("' + classNameMatch + '").addClass("' + classNameUnmatch + '"), mediaQuery: ' + mediaQueryElement); 505 if (options.unmatch != null && typeof (options.unmatch) === 'function') { 506 options.unmatch(e, element, classNameMatch, classNameUnmatch, mediaQueryElement); 507 cpMedia.diag('options.unmatch(e, element, "' + classNameUnmatch + '", "' + classNameUnmatch + '", " ' + mediaQueryElement + '")'); 508 } 509 } 510 }, false); 511} 512 513function fireMediaElementQueriesOfChildren ($parent) { 514 var fireIndividualMediaQuery = function ($element) { 515 var rwdinfo = $element.data('rwdinfo'); 516 for (var i = 0; i < rwdinfo.length; i++) { 517 window.cpMedia.fireQuery(rwdinfo[i].rawQuery); 518 } 519 }; 520 521 $parent.find('*').hasData('rwdinfo').each(function () { 522 fireIndividualMediaQuery($(this)); 523 }); 524 if ($parent.hasData('rwdinfo').length == 1) { 525 fireIndividualMediaQuery($parent); 526 } 527} 528 529function fireAllMediaElementQueries() { 530 window.cpMedia.fire(); 531} 532 533function matchMultiColumn(e, element, classNameMatch, classNameUnmatch, mediaQueryElement) { 534 $(element).find('div .row').addClass(classNameMatch); 535 if (classNameUnmatch != null) 536 $(element).find('div .row').removeClass(classNameUnmatch); 537 cpMedia.diag('$(' + element + ').find("div .row").addClass("' + classNameMatch + '"), mediaQuery: ' + mediaQueryElement); 538} 539 540function unmatchMultiColumn(e, element, classNameMatch, classNameUnmatch, mediaQueryElement) { 541 $(element).find('div .row').removeClass(classNameMatch); 542 if (classNameUnmatch != null) 543 $(element).find('div .row').addClass(classNameUnmatch); 544 cpMedia.diag('$(' + element + ').find("div .row").removeClass("' + classNameMatch + '"), mediaQuery: ' + mediaQueryElement); 545} 546 547function applyElementQueryToChildren ($parent) { 548 $parent.find("[data-elementquery]").each(function () { 549 var jsonQuery = $(this).data("elementquery"); 550 if (jsonQuery != null && typeof(jsonQuery) === "object") { 551 var elementId = $(this).attr("id"); 552 if (elementId == null || elementId == "") { 553 throw new Error("data-elementquery attribute can only by used on elements with unique id."); 554 } 555 if ($(this).parents('.megaMenu').length > 0 && !isResolvedOrState(window)) { 556 cpMedia.diag('#' + elementId + ' is inside megaMenu. MediaQuery: ' + $(this).attr("data-elementquery") + ' was not applied. Because the megaMenu has not been lazyLoaded'); 557 return; 558 } 559 var options = {}; 560 var matchFunction = $(this).data("elementquerymatch"); 561 var unmatchFunction = $(this).data("elementqueryunmatch"); 562 if (typeof matchFunction !== 'undefined' && matchFunction != '') 563 options.match = window[matchFunction]; 564 if (typeof unmatchFunction !== 'undefined' && matchFunction != '') 565 options.unmatch = window[unmatchFunction]; 566 for (var propertyName in jsonQuery) { 567 var mq = jsonQuery[propertyName]; 568 mq = mq 569 .replace("max-", "this-max-") 570 .replace("min-", "this-min-") 571 .replace("below-", "this-below-") 572 .replace("above-", "this-above-"); 573 var elementMediaQuery = "#" + elementId + ":media(" + mq + ")"; 574 toggleClassMedia(propertyName, elementMediaQuery, options); 575 } 576 } 577 }); 578 579 $parent.find("[data-elementqueryclasses]").each(function () { 580 var jsonQuery = $(this).data("elementqueryclasses"); 581 if (jsonQuery != null && typeof (jsonQuery) === "object") { 582 var elementId = $(this).attr("id"); 583 if (elementId == null || elementId == "") { 584 throw new Error("data-elementqueryclasses attribute can only by used on elements with unique id."); 585 } 586 if ($(this).parents('.megaMenu').length > 0 && !isResolvedOrState(window.Pages.megaMenuLoaded)) { 587 cpMedia.diag('#' + elementId + ' is inside megaMenu. MediaQuery: ' + $(this).attr("data-elementquery") + ' was not applied. Because the megaMenu has not been lazyLoaded'); 588 return; 589 } 590 var options = {}; 591 var matchFunction = $(this).data("elementquerymatch"); 592 var unmatchFunction = $(this).data("elementqueryunmatch"); 593 if (typeof matchFunction !== 'undefined' && matchFunction != '') 594 options.match = window[matchFunction]; 595 if (typeof unmatchFunction !== 'undefined' && matchFunction != '') 596 options.unmatch = window[unmatchFunction]; 597 for (var propertyName in jsonQuery) { 598 var mq = jsonQuery[propertyName]; 599 mq = mq 600 .replace("max-", "this-max-") 601 .replace("min-", "this-min-") 602 .replace("below-", "this-below-") 603 .replace("above-", "this-above-"); 604 var elementMediaQuery = "#" + elementId + ":media(" + mq + ")"; 605 var propNameSplit = propertyName.split("-"); 606 if (propNameSplit.length != 2) 607 throw new Error("data-elementqueryclasses attribute needs to have tw
607o classes separated by a dash (â-â)"); 608 609 toggleClassesMedia(propNameSplit[0], propNameSplit[1], elementMediaQuery, options); 610 } 611 } 612 }); 613} 614 615$(function () { 616 $("[data-contentcontainerbreakpoint]").each(function () { 617 var $container = $(this); 618 var breakpoint = $container.data("contentcontainerbreakpoint"); 619 if (breakpoint != null && typeof(breakpoint) === "number") { 620 var elementId = $container.attr("id"); 621 if (elementId == null || elementId == "") { 622 throw new Error("data-contentcontainerbreakpoint attribute can only by used on elements with unique id."); 623 } 624 var elementMediaQueryOuter = "#" + elementId + ":media(this-min-width:" + breakpoint + "em)"; 625 cpMedia.diag('register: ' + elementMediaQueryOuter); 626 cpMedia.register(elementMediaQueryOuter, { 627 setup: function () { 628 $container.children('div.row.outer').removeClass('wide'); 629 cpMedia.diag('#' + elementId + ' div.row.outer .removeClass("wide")'); 630 }, 631 match: function (e, element) { 632 $(element).children('div.row.outer').addClass('wide'); 633 cpMedia.diag('#' + elementId + ' div.row.outer .addClass("wide")'); 634 }, 635 unmatch: function (e, element) { 636 $(element).children('div.row.outer').removeClass('wide'); 637 cpMedia.diag('#' + elementId + ' div.row.outer .removeClass("wide")'); 638 } 639 }); 640 641 var innerBreakpoint = Math.round(breakpoint / 2); 642 var elementMediaQueryInner = "#" + elementId + ":media(this-min-width:" + innerBreakpoint + "em)"; 643 cpMedia.diag('register: ' + elementMediaQueryInner); 644 cpMedia.register(elementMediaQueryInner, { 645 setup: function () { 646 $container.find('div.row.nest').removeClass('wide'); 647 cpMedia.diag('#' + elementId + ' div.row.nest .removeClass("wide")'); 648 }, 649 match: function (e, element) { 650 $(element).find('div.row.nest').addClass('wide'); 651 cpMedia.diag('#' + elementId + ' div.row.nest .addClass("wide")'); 652 }, 653 unmatch: function (e, element) { 654 $(element).find('div.row.nest').removeClass('wide'); 655 cpMedia.diag('#' + elementId + ' div.row.nest .removeClass("wide")'); 656 } 657 }); 658 } 659 }); 660 661 $("[data-ajaxinclude]").each(function () { 662 var jsonData = $(this).data("ajaxinclude"); 663 if (jsonData != null && typeof (jsonData) === "object") { 664 var $div = $(this); 665 var elementId = $(this).attr("id"); 666 if (elementId == null || elementId == "") { 667 throw new Error("data-ajaxinclude attribute can only by used on elements with unique id."); 668 } 669 var url = jsonData.url; 670 var query = jsonData.query; 671 cpMedia.register(query, { 672 setup: function () { 673 cpMedia.diag('div setup init'); 674 AJAX(url, "GET", null, function (response) { 675 var $newContent = $(response); 676 /*$div.replaceWith($newContent); //1.) replace content with the div with ajax-include pattern 677 $div = $newContent; 678 $div.show();*/ 679 $div.append($newContent); //2.) append content in the div with ajax-include pattern 680 console.log('div setup done'); 681 }, false); 682 }, 683 deferSetup: true, 684 match: function () { 685 $div.show(); 686 cpMedia.diag('div show'); 687 }, 688 unmatch: function () { 689 $div.hide(); 690 cpMedia.diag('div hide'); 691 } 692 }); 693 } 694 }); 695 696 applyElementQueryToChildren($('body')); 697 698 //Setup execution of functions when resizing 699 window.Pages = window.Pages || {}; 700 window.Pages.onResizeHandlers = window.Pages.onResizeHandlers || []; 701 if (!window.isRemoveSetHeights) { 702 window.Pages.onResizeHandlers.push(SetHeights); 703 } 704 if (typeof window.dynamicStretchContainers === 'function') 705 window.Pages.onResizeHandlers.push(window.dynamicStretchContainers
705); 706 707 if ($('#hdnWidgetManager').length == 0 && typeof rearrangeFlyoutsOnResizeEvents === 'function') 708 window.Pages.onResizeHandlers.push(rearrangeFlyoutsOnResizeEvents); 709 710 window.Pages.onResizeHandlersExecute = window.Pages.onResizeHandlersExecute || function () { 711 for (var i = 0; i < window.Pages.onResizeHandlers.length; i++) { 712 if (typeof (window.Pages.onResizeHandlers[i]) === 'function') { 713 window.Pages.onResizeHandlers[i](); 714 } 715 } 716 }; 717 718 var timeout = 250; //time out to debounce execution of resize events 719 function executeOnResizeEvents(event) { 720 var timer; 721 722 window.addEventListener(event, function (e) { 723 timer && clearTimeout(timer); 724 725 timer = setTimeout(function () { 726 window.Pages.onResizeHandlersExecute(); 727 }, timeout); 728 }, false); 729 } 730 executeOnResizeEvents('resize'); 731 executeOnResizeEvents('orientationChange'); 732 733 $.when(window.Pages.rwdReady.resolve()).done(function () { 734 window.Pages.rwdSetupComplete.resolve(); 735}); 736});
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.