vanilla-lazyload
4 months ago
jquery.lazy.av.min.js
4 years ago
jquery.lazy.iframe.min.js
4 years ago
jquery.lazy.js
3 years ago
jquery.lazy.min.js
3 years ago
lazyload.min.js
4 years ago
loader.js
1 week ago
two_delay.js
1 week ago
two_elementor_video_to_iframe.js
4 years ago
two_lazyload.js
3 years ago
two_merge_google_font_faces.js
3 years ago
two_worker.js
2 years ago
two_yt_vi_lazyload.js
3 years ago
two_yt_vi_lazyload.min.js
3 years ago
loader.js
108 lines
| 1 | |
| 2 | window.addEventListener("load", function () { |
| 3 | window.two_page_loaded = true; |
| 4 | }); |
| 5 | |
| 6 | function logLoaded() { |
| 7 | console.log("window is loaded"); |
| 8 | } |
| 9 | |
| 10 | (function listen () { |
| 11 | if (window.two_page_loaded) { |
| 12 | logLoaded(); |
| 13 | } else { |
| 14 | console.log("window is notLoaded"); |
| 15 | window.setTimeout(listen, 50); |
| 16 | } |
| 17 | })(); |
| 18 | |
| 19 | function applyElementorControllers (){ |
| 20 | // Important line, because if there is no widget with JS, there is no elementorFrontend instance |
| 21 | if (!window.elementorFrontend) return; |
| 22 | // Where the magic hapen |
| 23 | window.elementorFrontend.init() |
| 24 | } |
| 25 | |
| 26 | //Bonus to apply css of the loaded page |
| 27 | function applyViewCss (cssUrl) { |
| 28 | if (!cssUrl) return; |
| 29 | const cssNode = document.createElement('link'); |
| 30 | cssNode.setAttribute("href", cssUrl); |
| 31 | cssNode.setAttribute("rel", "stylesheet"); |
| 32 | cssNode.setAttribute("type", "text/css"); |
| 33 | document.head.appendChild(cssNode); |
| 34 | |
| 35 | } |
| 36 | |
| 37 | function two_is_native_editable(el) { |
| 38 | if (!el) { |
| 39 | return false; |
| 40 | } |
| 41 | if (el.nodeType !== 1) { |
| 42 | el = el.parentElement; |
| 43 | } |
| 44 | while (el) { |
| 45 | if (el.isContentEditable) { |
| 46 | return true; |
| 47 | } |
| 48 | var tag = el.tagName; |
| 49 | if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT") { |
| 50 | return true; |
| 51 | } |
| 52 | el = el.parentElement; |
| 53 | } |
| 54 | return false; |
| 55 | } |
| 56 | |
| 57 | var two_scripts_load = true; |
| 58 | var two_load_delayed_javascript = function (event) { |
| 59 | if(two_scripts_load){ |
| 60 | two_scripts_load = false; |
| 61 | two_connect_script(0); |
| 62 | if(typeof two_delay_custom_js_new == "object"){ |
| 63 | document.dispatchEvent(two_delay_custom_js_new) |
| 64 | } |
| 65 | window.two_delayed_loading_events.forEach(function (event) { |
| 66 | console.log("removed event listener"); |
| 67 | document.removeEventListener(event, two_load_delayed_javascript, false) |
| 68 | }); |
| 69 | } |
| 70 | }; |
| 71 | function two_loading_events(event){ |
| 72 | if (two_is_native_editable(event && event.target)) { |
| 73 | return; |
| 74 | } |
| 75 | setTimeout(function(event) { |
| 76 | return function() { |
| 77 | var t = function(eventType, elementClientX, elementClientY) { |
| 78 | var _event = new Event(eventType, { |
| 79 | bubbles: true, |
| 80 | cancelable: true |
| 81 | }); |
| 82 | if (eventType === "click") { |
| 83 | _event.clientX = elementClientX; |
| 84 | _event.clientY = elementClientY |
| 85 | } else { |
| 86 | _event.touches = [{ |
| 87 | clientX: elementClientX, |
| 88 | clientY: elementClientY |
| 89 | }] |
| 90 | } |
| 91 | return _event |
| 92 | }; |
| 93 | var element; |
| 94 | if (event && event.type === "touchend") { |
| 95 | var touch = event.changedTouches[0]; |
| 96 | element = document.elementFromPoint(touch.clientX, touch.clientY); |
| 97 | element.dispatchEvent(t('touchstart', touch.clientX, touch.clientY)); |
| 98 | element.dispatchEvent(t('touchend', touch.clientX, touch.clientY)); |
| 99 | element.dispatchEvent(t('click', touch.clientX, touch.clientY)); |
| 100 | } else if (event && event.type === "click") { |
| 101 | element = document.elementFromPoint(event.clientX, event.clientY); |
| 102 | element.dispatchEvent(t(event.type, event.clientX, event.clientY)); |
| 103 | } |
| 104 | } |
| 105 | }(event), 150); |
| 106 | |
| 107 | |
| 108 | } |