PageSourceSearch

https://slaviclore.com/components/page_editor/js/components/page_editor/page_editor_css_ready.js?v=11.1.2.13

js slaviclore.com collected 2026-10-07 02:27:55 UTC 9,209 bytes, 264 lines download raw bytes

1/*! onloadCSS. (onload callback for loadCSS) [c]2017 Filament Group, Inc. MIT License */
2/* global navigator */
3
4/* exported onloadCSS */
5function onloadCSS(ss, callback) {
6    let called = false;
7
8    function newcb() {
9        if (!called && callback) {
10            called = true;
11            callback.call(ss);
12        }
13    }
14
15    if (ss.addEventListener) {
16        ss.addEventListener("load", newcb);
17    }
18    if (ss.attachEvent) {
19        ss.attachEvent("onload", newcb);
20    }
21
22    // This code is for browsers that don’t support onload
23    // No support for onload (it'll bind but never fire):
24    //	* Android 4.3 (Samsung Galaxy S4, Browserstack)
25    //	* Android 4.2 Browser (Samsung Galaxy SIII Mini GT-I8200L)
26    //	* Android 2.3 (Pantech Burst P9070)
27
28    // Weak inference targets Android < 4.4
29    if ("isApplicationInstalled" in navigator && "onloadcssdefined" in ss) {
30        ss.onloadcssdefined(newcb);
31    }
32}
33
34/*! loadCSS. [c]2017 Filament Group, Inc. MIT License */
35/* This file is meant as a standalone workflow for
36- testing support for link[rel=preload]
37- enabling async CSS loading in browsers that do not support rel=preload
38- applying rel preload css once loaded, whether supported or not.
39*/
40(function (w) {
41    "use strict";
42    // rel=preload support test
43    if (!w.loadCSS) {
44        w.loadCSS = function () {
45        };
46    }
47    // define on the loadCSS obj
48    var rp = loadCSS.relpreload = {};
49    // rel=preload feature support test
50    // runs once and returns a function for compat purposes
51    rp.support = (function () {
52        var ret;
53        try {
54            ret = w.document.createElement("link").relList.supports("preload");
55        } catch (e) {
56            ret = false;
57        }
58        return function () {
59            return ret;
60        };
61    })();
62
63    // if preload isn't supported, get an asynchronous load by using a non-matching media attribute
64    // then change that media back to its intended value on load
65    rp.bindMediaToggle = function (link) {
66        // remember existing media attr for ultimate state, or default to 'all'
67        var finalMedia = link.media || "all";
68
69        function enableStylesheet() {
70            link.media = finalMedia;
71        }
72
73        // bind load handlers to enable media
74        if (link.addEventListener) {
75            link.addEventListener("load", enableStylesheet);
76        } else if (link.attachEvent) {
77            link.attachEvent("onload", enableStylesheet);
78        }
79
80        // Set rel and non-applicable media type to start an async request
81        // note: timeout allows this to happen async to let rendering continue in IE
82        setTimeout(function () {
83            link.rel = "stylesheet";
84            link.media = "only x";
85        });
86        // also enable media after 3 seconds,
87        // which will catch very old browsers (android 2.x, old firefox) that don't support onload on link
88        setTimeout(enableStylesheet, 3000);
89    };
90
91    // loop through link elements in DOM
92    rp.poly = function () {
93        // double check this to prevent external calls from running
94        if (rp.support()) {
95            return;
96        }
97        var links = w.document.getElementsByTagName("link");
98        for (var i = 0; i < links.length; i++) {
99            var link = links[i];
100            // qualify links to those with rel=preload and as=style attrs
101            if (link.rel === "preload" && link.getAttribute("as") === "style" && !link.getAttribute("data-loadcss")) {
102                // prevent rerunning on link
103                link.setAttribute("data-loadcss", true);
104                // bind listeners to toggle media back
105                rp.bindMediaToggle(link);
106            }
107        }
108    };
109
110    // if unsupported, run the polyfill
111    if (!rp.support()) {
112        // run once at least
113        rp.poly();
114
115        // rerun poly on an interval until onload
116        var run = w.setInterval(rp.poly, 500);
117        if (w.addEventListener) {
118            w.addEventListener("load", function () {
119                rp.poly();
120                w.clearInterval(run);
121            });
122        } else if (w.attachEvent) {
123            w.attachEvent("onload", function () {
124                rp.poly();
125                w.clearInterval(run);
126            });
127        }
128    }
129
130
131    // commonjs
132    if (typeof exports !== "undefined") {
133        exports.loadCSS = loadCSS;
134    } else {
135        w.loadCSS = loadCSS;
136    }
137})(typeof global !== "undefined" ? global : this);
138
139/*! loadCSS. [c]2017 Filament Group, Inc. MIT License */
140(function (w) {
141    "use strict";
142    /* exported loadCSS */
143    var loadCSS = function (href, before, media, attributes) {
144        // Arguments explained:
145        // `href` [REQUIRED] is the URL for your CSS file.
146        // `before` [OPTIONAL] is the element the script should use as a reference for injecting our stylesheet <link> before
147        // By default, loadCSS attempts to inject the link after the last stylesheet or script in the DOM. However, you might desire a more specific location in your document.
148        // `media` [OPTIONAL] is the media type or query of the stylesheet. By default it will be 'all'
149        // `attributes` [OPTIONAL] is the Object of attribute name/attribute value pairs to set on the stylesheet's DOM Element.
150        var doc = w.document;
151        var ss = doc.createElement("link");
152        var ref;
153        if (before) {
154            ref = before;
155        } else {
156            var refs = (doc.body || doc.getElementsByTagName("head")[0]).childNodes;
157            ref = refs[refs.length - 1];
158        }
159
160        var sheets = doc.styleSheets;
161        // Set any of the provided attributes to the stylesheet DOM Element.
162        if (attributes) {
163            for (var attributeName in attributes) {
164                if (attributes.hasOwnProperty(attributeName)) {
165                    ss.setAttribute(attributeName, attributes[attributeName]);
166                }
167            }
168        }
169        ss.rel = "stylesheet";
170        ss.href = href;
171        // temporarily set media to something inapplicable to ensure it'll fetch without blocking render
172        ss.media = "only x";
173
174        // wait until body is defined before injecting link. This ensures a non-blocking load in IE11.
175        function ready(cb) {
176            if (doc.body) {
177                return cb();
178            }
179            setTimeout(function () {
180                ready(cb);
181            });
182        }
183
184        // Inject link
185        // Note: the ternary preserves the existing behavior of "before" argument, but we could choose to change the argument to "after" in a later release and standardize on ref.nextSibling for all refs
186        // Note: `insertBefore` is used instead of `appendChild`, for safety re: http://www.paulirish.com/2011/surefire-dom-element-insertion/
187        ready(function () {
188            ref.parentNode.insertBefore(ss, (before ? ref : ref.nextSibling));
189        });
190        // A method (exposed on return object for external use) that mimics onload by polling document.styleSheets until it includes the new sheet.
191        var onloadcssdefined = function (cb) {
192            var resolvedHref = ss.href;
193            var i = sheets.length;
194            while (i--) {
195                if (sheets[i].href === resolvedHref) {
196                    return cb();
197                }
198            }
199            setTimeout(function () {
200                onloadcssdefined(cb);
201            });
202        };
203
204        function loadCB() {
205            if (ss.addEventListener) {
206                ss.removeEventListener("load", loadCB);
207            }
208            ss.media = media || "all";
209        }
210
211        // once loaded, set link's media back to `all` so that the stylesheet applies once it loads
212        if (ss.addEventListener) {
213            ss.addEventListener("load", loadCB);
214        }
215        ss.onloadcssdefined = onloadcssdefined;
216        onloadcssdefined(loadCB);
217        return ss;
218    };
219    // commonjs
220    if (typeof exports !== "undefined") {
221        exports.loadCSS = loadCSS;
222    } else {
223        w.loadCSS = loadCSS;
224    }
225})(typeof global !== "undefined" ? global : this);
226
227var limecube_ready = false;
228var limecube_style_editor_css_ready = false;
229
230function domReady() {
231    setTimeout(function () {
232        if (!limecube_ready) {
233            limecube_ready = true;
234
235            if (document.body) {
236                document.body.className += " loaded";
237            } else {
238                var bodyLoad = setInterval(function () {
239                    if (document.body) {
240                        document.body.className += " loaded";
241                        clearInterval(bodyLoad);
242                    }
243                }, 500);
244            }
245
246            if (typeof $ !== 'undefined') {
247                $("body").trigger("limecubeReady");
248            } else {
249                window.addEventListener("load", function (event) {
250                    if (typeof $ !== 'undefined') $("body").trigger("limecubeReady");
251                });
252            }
253        }
254    }, 500);
255}
256
257setTimeout(function () {
258    domReady();
259    console.log('domReady by timeout');
260}, 3000);
261
262function styleEditorCssReady() {
263    limecube_style_editor_css_ready = true;
264}

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.