diff --git a/additional/a/analytics.js b/a/analytics.js similarity index 100% rename from additional/a/analytics.js rename to a/analytics.js diff --git a/additional/a/jquery-1.12.2.js b/a/jquery-1.12.2.js similarity index 100% rename from additional/a/jquery-1.12.2.js rename to a/jquery-1.12.2.js diff --git a/additional/a/jquery-1.12.2.min.js b/a/jquery-1.12.2.min.js similarity index 100% rename from additional/a/jquery-1.12.2.min.js rename to a/jquery-1.12.2.min.js diff --git a/additional/height-animation/index.html b/additional/height-animation/index.html index c3a9fbf..c1e3a25 100755 --- a/additional/height-animation/index.html +++ b/additional/height-animation/index.html @@ -57,7 +57,7 @@

Current solution (jQuery)

- + - + \ No newline at end of file diff --git a/additional/height-animation/toggle.js b/additional/height-animation/toggle.js index 57ee0f1..6e1b0fa 100644 --- a/additional/height-animation/toggle.js +++ b/additional/height-animation/toggle.js @@ -1,72 +1,70 @@ - (function(document, window, undefined) { +;(function(document, window, undefined) { - 'use strict'; + 'use strict'; - if (!document.addEventListener || !('classList' in document.createElement('span'))) { // classList = IE11 - return; - } - - function widget_toggle(e) { - - var widget_ref = document.getElementById(this.getAttribute('aria-controls')); + if (!document.addEventListener || !('classList' in document.createElement('span'))) { // classList = IE11 + return; + } - if (widget_ref.getAttribute('aria-hidden') == 'true') { + function widget_toggle(e) { - this.setAttribute('aria-expanded', 'true'); - this.textContent = this.getAttribute('data-toggle-hidden'); + var widget_ref = document.getElementById(this.getAttribute('aria-controls')); - widget_ref.setAttribute('aria-hidden', 'false'); - widget_ref.focus(); + if (widget_ref.getAttribute('aria-hidden') == 'true') { - } else { + this.setAttribute('aria-expanded', 'true'); + this.textContent = this.getAttribute('data-toggle-hidden'); - this.setAttribute('aria-expanded', 'false'); - this.textContent = this.getAttribute('data-toggle-shown'); + widget_ref.setAttribute('aria-hidden', 'false'); + widget_ref.focus(); - widget_ref.setAttribute('aria-hidden', 'true'); + } else { - } + this.setAttribute('aria-expanded', 'false'); + this.textContent = this.getAttribute('data-toggle-shown'); - e.preventDefault(); + widget_ref.setAttribute('aria-hidden', 'true'); } - function init() { + e.preventDefault(); - var links = document.querySelectorAll('a[data-toggle-hidden]'), - widget_ref_id, - widget_ref; + } - for (var k = (links.length - 1); k >= 0; k--) { + function init() { - widget_ref_id = links[k].getAttribute('href').substr(1); - widget_ref = document.getElementById(widget_ref_id); + var links = document.querySelectorAll('a[data-toggle-hidden]'), + widget_ref_id, + widget_ref; - if (widget_ref) { + for (var k = (links.length - 1); k >= 0; k--) { - widget_ref.setAttribute('aria-hidden', 'true'); - widget_ref.setAttribute('tabindex', '-1'); - widget_ref.style.outline = 'none'; + widget_ref_id = links[k].getAttribute('href').substr(1); + widget_ref = document.getElementById(widget_ref_id); - links[k].setAttribute('data-toggle-shown', links[k].textContent); - links[k].setAttribute('role', 'button'); - links[k].setAttribute('aria-expanded', 'false'); - links[k].setAttribute('aria-controls', widget_ref_id); - links[k].addEventListener('click', widget_toggle); + if (widget_ref) { - } + widget_ref.setAttribute('aria-hidden', 'true'); + widget_ref.setAttribute('tabindex', '-1'); + widget_ref.style.outline = 'none'; + + links[k].setAttribute('data-toggle-shown', links[k].textContent); + links[k].setAttribute('role', 'button'); + links[k].setAttribute('aria-expanded', 'false'); + links[k].setAttribute('aria-controls', widget_ref_id); + links[k].addEventListener('click', widget_toggle); } } - if (document.readyState !== 'loading') { -console.log('a'); - window.setTimeout(init); // Handle asynchronously - } else { -console.log('b'); - document.addEventListener('DOMContentLoaded', init); - } + } + + if (document.readyState !== 'loading') { + window.setTimeout(init); // Handle asynchronously + } else { + document.addEventListener('DOMContentLoaded', init); + } - })(document, window); +})(document, window); diff --git a/additional/textarea/index.html b/additional/textarea/index.html index 849a12e..6629e63 100755 --- a/additional/textarea/index.html +++ b/additional/textarea/index.html @@ -47,7 +47,7 @@

Current solution (jQuery)

- + + \ No newline at end of file diff --git a/example/index.html b/example/index.html index ac2f7d3..08ed22e 100755 --- a/example/index.html +++ b/example/index.html @@ -10,8 +10,10 @@

IFrame Height

- + + + \ No newline at end of file diff --git a/example/size-same-origin.js b/example/size-same-origin.js index 7f062c4..95f676d 100644 --- a/example/size-same-origin.js +++ b/example/size-same-origin.js @@ -7,14 +7,33 @@ return; } - function init() { + var iframe; + + function init_iframe() { var height = Math.max(iframe.contentWindow.document.body.scrollHeight, iframe.contentWindow.document.body.offsetHeight, iframe.contentWindow.document.documentElement.clientHeight, iframe.contentWindow.document.documentElement.scrollHeight, iframe.contentWindow.document.documentElement.offsetHeight); iframe.style.height = height + 'px'; } - var iframe = document.getElementById('iframe'); - if (iframe) { - iframe.addEventListener('load', init); + function init() { + iframe = document.getElementById('iframe'); + if (iframe) { + + iframe.addEventListener('load', init_iframe); + + try { + if (iframe.contentWindow.document.readyState !== 'loading') { + window.setTimeout(init_iframe); + } + } catch (e) { + } + + } + } + + if (document.readyState !== 'loading') { + window.setTimeout(init); // Handle asynchronously + } else { + document.addEventListener('DOMContentLoaded', init); } })(document, window);