event-ready-base-ie.js revision 772f655fcf57e58b97fa46b6a8d3fc772b83f743
011173392d3a1a59092095d5a24857134cb16f93Adam Moore
011173392d3a1a59092095d5a24857134cb16f93Adam Moore(function() {
011173392d3a1a59092095d5a24857134cb16f93Adam Moore
011173392d3a1a59092095d5a24857134cb16f93Adam Moorevar stateChangeListener,
011173392d3a1a59092095d5a24857134cb16f93Adam Moore GLOBAL_ENV = YUI.Env,
011173392d3a1a59092095d5a24857134cb16f93Adam Moore config = YUI.config,
011173392d3a1a59092095d5a24857134cb16f93Adam Moore doc = config.doc,
011173392d3a1a59092095d5a24857134cb16f93Adam Moore docElement = doc && doc.documentElement,
011173392d3a1a59092095d5a24857134cb16f93Adam Moore EVENT_NAME = 'onreadystatechange',
011173392d3a1a59092095d5a24857134cb16f93Adam Moore pollInterval = config.pollInterval || 40;
011173392d3a1a59092095d5a24857134cb16f93Adam Moore
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Mooreif (docElement.doScroll && !GLOBAL_ENV._ieready) {
011173392d3a1a59092095d5a24857134cb16f93Adam Moore GLOBAL_ENV._ieready = function() {
011173392d3a1a59092095d5a24857134cb16f93Adam Moore GLOBAL_ENV._ready();
011173392d3a1a59092095d5a24857134cb16f93Adam Moore };
011173392d3a1a59092095d5a24857134cb16f93Adam Moore
011173392d3a1a59092095d5a24857134cb16f93Adam Moore/*! DOMReady: based on work by: Dean Edwards/John Resig/Matthias Miller/Diego Perini */
011173392d3a1a59092095d5a24857134cb16f93Adam Moore// Internet Explorer: use the doScroll() method on the root element.
011173392d3a1a59092095d5a24857134cb16f93Adam Moore// This isolates what appears to be a safe moment to manipulate the
011173392d3a1a59092095d5a24857134cb16f93Adam Moore// DOM prior to when the document's readyState suggests it is safe to do so.
011173392d3a1a59092095d5a24857134cb16f93Adam Moore if (self !== self.top) {
011173392d3a1a59092095d5a24857134cb16f93Adam Moore stateChangeListener = function() {
011173392d3a1a59092095d5a24857134cb16f93Adam Moore if (doc.readyState == 'complete') {
011173392d3a1a59092095d5a24857134cb16f93Adam Moore GLOBAL_ENV.Env.remove(doc, EVENT_NAME, stateChangeListener);
011173392d3a1a59092095d5a24857134cb16f93Adam Moore GLOBAL_ENV.ieready();
011173392d3a1a59092095d5a24857134cb16f93Adam Moore }
011173392d3a1a59092095d5a24857134cb16f93Adam Moore };
011173392d3a1a59092095d5a24857134cb16f93Adam Moore GLOBAL_ENV.Env.add(doc, EVENT_NAME, stateChangeListener);
011173392d3a1a59092095d5a24857134cb16f93Adam Moore } else {
011173392d3a1a59092095d5a24857134cb16f93Adam Moore GLOBAL_ENV._dri = setInterval(function() {
011173392d3a1a59092095d5a24857134cb16f93Adam Moore try {
011173392d3a1a59092095d5a24857134cb16f93Adam Moore docElement.doScroll('left');
011173392d3a1a59092095d5a24857134cb16f93Adam Moore clearInterval(GLOBAL_ENV._dri);
011173392d3a1a59092095d5a24857134cb16f93Adam Moore GLOBAL_ENV._dri = null;
011173392d3a1a59092095d5a24857134cb16f93Adam Moore GLOBAL_ENV._ieready();
011173392d3a1a59092095d5a24857134cb16f93Adam Moore } catch (domNotReady) { }
011173392d3a1a59092095d5a24857134cb16f93Adam Moore }, pollInterval);
011173392d3a1a59092095d5a24857134cb16f93Adam Moore }
011173392d3a1a59092095d5a24857134cb16f93Adam Moore}
011173392d3a1a59092095d5a24857134cb16f93Adam Moore
011173392d3a1a59092095d5a24857134cb16f93Adam Moore})();