PageSourceSearch

https://danielbarnett.com/wp-content/plugins/op-builder/public/ass…&ver=8c83adc031e41f420db947cff2dd6851

js danielbarnett.com collected 2026-10-04 01:52:44 UTC 11,689 bytes, 55 lines download raw bytes

1/**
2 * DOMContentLoaded Event Deferral Helper
3 * 
4 * Intercepts DOMContentLoaded event listeners and automatically wraps their
5 * callbacks with requestAnimationFrame to prevent forced synchronous layouts
6 * (reflows) that negatively impact page performance metrics.
7 * 
8 * This approach maintains full backward compatibility while deferring layout-
9 * triggering operations (offsetHeight, getComputedStyle, etc.) until the next
10 * animation frame, allowing the browser to optimize rendering.
11 * 
12 * @see https://web.dev/avoid-large-complex-layouts-and-layout-thrashing/
13 */
14(function() {
15    'use strict';
16    
17    var originalAddEventListener = document.addEventListener;
18    var isDOMReady = document.readyState === 'complete' || document.readyState === 'interactive';
19    
20    /**
21     * Intercept document.addEventListener to defer DOMContentLoaded callbacks
22     * 
23     * @param {string} event - Event name
24     * @param {Function} callback - Event callback
25     * @param {Object|boolean} options - Event listener options
26     */
27    document.addEventListener = function(event, callback, options) {
28        if (event === 'DOMContentLoaded' && typeof callback === 'function') {
29            var deferredCallback = function(e) {
30                requestAnimationFrame(function() {
31                    callback.call(this, e);
32                }.bind(this));
33            };
34            
35            if (isDOMReady) {
36                // DOM already loaded, execute immediately but deferred
37                requestAnimationFrame(function() {
38                    callback.call(document, new Event('DOMContentLoaded'));
39                });
40            } else {
41                originalAddEventListener.call(document, event, deferredCallback, options);
42            }
43        } else {
44            originalAddEventListener.call(document, event, callback, options);
45        }
46    };
47    
48    // Track when DOM becomes ready
49    if (!isDOMReady) {
50        originalAddEventListener.call(document, 'DOMContentLoaded', function() {
51            isDOMReady = true;
52        });
53    }
54})();
55!function(t,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof module&&module.exports?module.exports=e():t.Stickify=e()}("undefined"!=typeof self?self:this,function(){"use strict";var t=[],e=function(t,i){if(!(this instanceof e))throw"Stickify: Stickify is a constructor.";if(!(t instanceof HTMLElement))throw"Stickify: element argument must be of HTMLElement type.";if("object"!=typeof(i||{}))throw"Stickify: options argument must be of Object type.";this._init.apply(this,arguments)};return e.prototype={constructor:e,_defaultOptions:{matchMedia:"all",position:"top",untilElement:null,offset:0,zIndex:"1000"},_init:function(e,i){if(!e._stickify){for(var n in e.classList.add("stickify"),e._stickify=this,this._element=e,t.push(e),this._options={},this._defaultOptions){var s=i&&n in i?this._validateOption(n,i[n]):this._defaultOptions[n];void 0===s&&(s=this._defaultOptions[n]),this._options[n]=s}var o=e.ownerDocument,r=o.defaultView,l=o.createElement("div");l.classList.add("stickify__placeholder"),this._placeholder=l;var a=o.createElement("div");a.classList.add("stickify__collapser"),this._collapser=a,this._boundHandleWindowMove=this._handleWindowMove.bind(this),r.addEventListener("scroll",this._boundHandleWindowMove),r.addEventListener("resize",this._boundHandleWindowMove),this.__reverseRepaint=!0,this.refresh(),delete this.__reverseRepaint}},destroy:function(){var e=this.element,i=e.classList,n=e.ownerDocument.defaultView;i.remove("stickify--sticky"),i.remove("stickify"),this._repaintElement(),delete e._stickify,t=t.filter(function(t){return t!==this.element}.bind(this)),this._collapser.remove(),this._placeholder.remove(),n.removeEventListener("resize",this._boundHandleWindowMove),n.removeEventListener("scroll",this._boundHandleWindowMove),delete this._boundHandleWindowMove,delete this._collapser,delete this._placeholder,delete this._options,delete this._element},get element(){return this._element},get isSticky(){return this.element.classList.contains("stickify--sticky")},get isAnchored(){return this.element.classList.contains("stickify--anchored")},getOption:function(t){return this._options[t]},setOption:function(t,e){if(t in this._defaultOptions&&void 0!==(e=this._val
55idateOption(t,e))){var i=this.getOption(t);i!==e&&(this._options[t]=e,this._dispatchEvent("option",{key:t,value:e,oldValue:i}),this.refresh())}},refresh:function(){var t=this.element;if("none"!==this._css(t,"display")){var e=t.ownerDocument.defaultView,i=this._getNonStickyLayout(),n=i.viewport.rect,s=i.element.rect,o=this.getOption("matchMedia"),r=this.getOption("position"),l=this.getOption("offset"),a=e.matchMedia(o).matches&&("top"===r?s.top<l:s.bottom<n.height-l),c=this.isSticky!==a;c&&t.classList[a?"add":"remove"]("stickify--sticky"),this._repaint(i),c&&this._dispatchEvent("change",{sticky:a})}},_dispatchEvent:function(t,e){var i=new CustomEvent("stickify"+t,{detail:e});return this.element.dispatchEvent(i),i},_toKebabCase:function(t){return t.replace(/[A-Z]+/g,function(t){return"-"+t.toLowerCase()})},_css:function(t,e,i){var n=t.ownerDocument.defaultView;if("string"==typeof e&&void 0===i)return n.getComputedStyle(t).getPropertyValue(this._toKebabCase(e));if("string"==typeof e)t.style.setProperty(e,i);else if(null===e)t.removeAttribute("style");else{if(Array.isArray(e)){var s=n.getComputedStyle(t);return e.reduce(function(t,e){return t[e]=s.getPropertyValue(this._toKebabCase(e)),t}.bind(this),{})}"object"==typeof e&&Object.keys(e).forEach(function(i){t.style.setProperty(this._toKebabCase(i),e[i])}.bind(this))}},_getMargins:function(t){var e=["marginTop","marginRight","marginBottom","marginLeft"],i=this._css(t,e);return i=e.reduce(function(t,e){return t.push(parseFloat(i[e])),t},[])},_getCollapsedMargin:function(t,e){return Math.max(parseFloat(this._css(t,"marginBottom")),e?parseFloat(this._css(e,e.contains(t)?"marginBottom":"marginTop")):0)},_getNonStickyLayout:function(){var t=this.element,e=this._placeholder,i=this._collapser,n=t.ownerDocument.documentElement,s=this.getOption("untilElement"),o=t.getAttribute("style");this._css(t,null),this._css(e,"display","none"),this._css(i,"display","none");var r={viewport:{margin:null,padding:null,rect:new DOMRect(0,0,n.clientWidth,n.clientHeight)},element:{margin:this._getMargins(t),padding:null,rect:t.getBoundingClientRect()},untilElement:s?{margin:this._getMargins(s),padding:null,rect:s.getBoundingClientRect()}:null};return this._css(i,"display",""),this._css(e,"display",""),t.setAttribute("style",o||""),r},_getRealOffsetOption:function(t){if(!this.isSticky)return null;var e=this.getOption("position"),i=this.getOption("untilElement"),n=this.getOption("offset"),s=t.viewport.rect;if(t.untilElement){var o,r=i.contains(this.element),l=t.untilElement.rect[r?"bottom":"top"];"top"===e?(o=n+t.element.rect.height,(o+=this._getCollapsedMargin(this._placeholder,i))>l&&(n-=o-l)):(o=s.height-n,(o+=this._getCollapsedMargin(this._placeholder,this._placeholder.nextElementSibling))>l&&(n+=o-l))}return n},_repaint:function(t){var e=["_repaintElement","_repaintPlaceholder","_repaintCollapser"];this.__reverseRepaint&&e.reverse(),e.forEach(function(e){this[e].call(this,t)}.bind(this))},_repaintCollapser:function(t){},_repaintPlaceholder:function(t){var e=this._placeholder;if(!this.isSticky)return e.remove();var i=this.element,n=(this._collapser,this.getOption("untilElement")),s=this.getOption("position"),o=(this.getOption("offset"),t.element.margin),r=t.element.rect;this._css(e,{height:r.height+"px",margin:o.map(function(t){return t+"px"}).join(" ")}),"top"===s?i.insertAdjacentElement("beforebegin",e):n&&!n.contains(i)?n.insertAdjacentElement("beforebegin",e):n?n.insertAdjacentElement("afterend",e):i.ownerDocument.body.appendChild(e)},_repaintElement:function(t){var e=this.isSticky,i=this.isAnchored,n=this.element,s=n.classList,o=t?t.element.rect:null,r={position:e?"fixed":"",boxSizing:e?"border-box":"",top:"",right:"",bottom:"",left:e?o.left+"px":"",width:e?o.width+"px":"",margin:e?"0px":"",zIndex:e?this.getOption("zIndex"):""};if(s.remove("stickify--anchored"),e){var l=this.getOption("position"),a=this.getOption("offset"),c=this._getRealOffsetOption(t);r[l]=c+"px",a!==c&&s.add("stickify--anchored")}i!==this.isAnchored&&this._dispatchEvent("anchor",{anchor:i?null:this.getOption("untilElement")}),this._css(n,r)},_validateOption:function(t,e){var i=this["_validateOption"+t.charAt(0).toUpperCase()+t.slice(1)];return"function"==typeof i?i.call(this,e):t in this._defaultOptions?e:void 0},_validateOptionMatchMedia:function(t){return String(t)},_validateOptionPosition:function(t){return t=(t=(t=String(t)).replace(/[^a-zA-Z]+/g,"")).toLowerCase(),["top","bottom"].includes(t)||(t="top"),t}
55,_validateOptionUntilElement:function(t){try{if("string"==typeof t&&(t=this.element.ownerDocument.querySelector(t)||""),t instanceof HTMLElement&&!this.element.contains(t))return t}catch(t){}return this._defaultOptions.untilElement},_validateOptionOffset:function(t){return t*=1,isNaN(t)?this._defaultOptions.offset:t},_validateOptionZIndex:function(t){var e=1*t;return!isNaN(e)&&e>=0?String(e):["inherit","initial","revert","revert-layer","unset"].includes(t)?t:this._defaultOptions.zIndex},_handleWindowMove:function(t){this.refresh()}},e.getElements=function(){return t},e.getInstance=function(e){return t.includes(e)&&e._stickify?e._stickify:null},e});document.addEventListener("DOMContentLoaded",function(t){var e={getProperties:function(t){for(var e=null,i=0;i<t.children.length;i++)if("1"===t.children[i].getAttribute("data-op3-sticky")){e=t.children[i];break}return{activeDesktop:e.getAttribute("data-op3-sticky-active-desktop")||"1",activeTablet:e.getAttribute("data-op3-sticky-active-tablet")||"1",activeMobile:e.getAttribute("data-op3-sticky-active-mobile")||"1",position:e.getAttribute("data-op3-sticky-position")||"top",offsetDesktop:e.getAttribute("data-op3-sticky-top-desktop")||"0",offsetTablet:e.getAttribute("data-op3-sticky-top-tablet")||"0",offsetMobile:e.getAttribute("data-op3-sticky-top-mobile")||"0",stickyUntil:e.getAttribute("data-op3-sticky-until")||"0",untilElement:e.getAttribute("data-op3-sticky-until-element")||""}},getOptions:function(t){var i=e.getProperties(t),a={desktop:"screen and (min-width: 1024px)",tablet:"screen and (max-width: 1023px) and (min-width: 768px)",mobile:"screen and (max-width: 767px)"},o=null,n={matchMedia:"all",position:"top",untilElement:null,offset:0,zIndex:1e3};if(i){for(var d in a)window.matchMedia(a[d]).matches&&(o=d);for(var d in n.matchMedia="",a){"1"===i["active"+d.charAt(0).toUpperCase()+d.slice(1)]&&(n.matchMedia+=", "+a[d])}if(n.matchMedia=n.matchMedia?n.matchMedia.replace(/^,\s/,""):"none",n.position=i.position||"top","1"===i.stickyUntil?n.untilElement=t.parentElement.closest(".op3-element, .op3-designer-element > [data-op3-children]"):"2"===i.stickyUntil&&i.untilElement&&(n.untilElement=i.untilElement),n.offset="mobile"===o?i.offsetMobile:"tablet"===o?i.offsetTablet:i.offsetDesktop,n.offset=parseInt(n.offset),"top"===n.position){var r=e.getAdminBar();r&&"fixed"===window.getComputedStyle(r).getPropertyValue("position")&&(n.offset+=r.offsetHeight)}n.zIndex-=1*t.getAttribute("data-stickify-index")||0}return n},getAdminBar:function(){return"_adminBar"in e?e._adminBar:(e._adminBar=document.querySelector("#wpadminbar"),e.getAdminBar())}};document.querySelectorAll('[data-op3-sticky="1"]:not([data-op3-sticky-active-desktop="0"][data-op3-sticky-active-tablet="0"][data-op3-sticky-active-mobile="0"])').forEach(function(t,i){var a=t.parentElement;a.setAttribute("data-stickify-index",i),new Stickify(a,e.getOptions(a))})});

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.