(function () { 'use strict'; // I did try to shim jQuery's deferred, but it's just too clunky. // Here I use es6-promise which lacks asynchrity, but it's the smallest Promise implementation. // Only Opera Mini and MSIE (even on 11) will use this shim, so no biggie; var oauth3 = window.OAUTH3; var count = 0; function inject() { count += 1; if (count >= 100) { throw new Error("you forgot to include rsvp.js, methinks"); } /* * [window.Promise, window.ES6Promise, window.RSVP.Promise].forEach(function (PromiseA) { var x = 1; new PromiseA(function (resolve, reject) { console.log('x', 1 === x); resolve(); }); x = 2; void null; var y = 1; PromiseA.resolve().then(function () { console.log('y', 2 === x); }); y = 2; void null; }); */ var PromiseA = /*(window.RSVP && window.RSVP.Promise) || window.ES6Promise || */window.Promise; if ('undefined' !== typeof PromiseA) { oauth3.providePromise(PromiseA).then(function () { // ignore window.jqOauth3 = oauth3; }, function (err) { console.error(err); console.error("Bad Promise Implementation!"); }); return; } // because MSIE can't tell when a script is loaded setTimeout(inject, 100); } if ('undefined' === typeof Promise) { // support Opera Mini and MSIE 11+ (which doesn't support