2017-02-14 23:19:21 +00:00
|
|
|
;(function () {
|
|
|
|
'use strict';
|
|
|
|
|
2017-08-10 20:35:24 +00:00
|
|
|
var modules = {
|
|
|
|
azp: [
|
2017-02-14 23:19:21 +00:00
|
|
|
'$timeout'
|
|
|
|
, '$q'
|
2017-08-25 23:47:31 +00:00
|
|
|
, '$rootScope'
|
|
|
|
, function Oauth3($timeout, $q, $rootScope) {
|
2017-08-10 20:35:24 +00:00
|
|
|
var OAUTH3 = window.OAUTH3;
|
2017-02-14 23:19:21 +00:00
|
|
|
|
2017-08-10 20:35:24 +00:00
|
|
|
// We need to make angular's $q appear to be a standard Promise/A+
|
|
|
|
// fortunately, this is pretty easy
|
|
|
|
function PromiseAngularQ(fn) {
|
|
|
|
var d = $q.defer();
|
2017-02-14 23:19:21 +00:00
|
|
|
|
2017-08-10 20:35:24 +00:00
|
|
|
//$timeout(function () {
|
|
|
|
fn(d.resolve, d.reject);
|
|
|
|
//}, 0);
|
2017-02-14 23:19:21 +00:00
|
|
|
|
2017-08-10 20:35:24 +00:00
|
|
|
//this.then = d.promise.then;
|
|
|
|
//this.catch = d.promise.catch;
|
|
|
|
return d.promise;
|
|
|
|
}
|
2017-02-14 23:19:21 +00:00
|
|
|
|
2017-08-10 20:35:24 +00:00
|
|
|
//PromiseAngularQ.create = PromiseAngularQ;
|
|
|
|
PromiseAngularQ.resolve = $q.when;
|
|
|
|
PromiseAngularQ.reject = $q.reject;
|
|
|
|
PromiseAngularQ.all = $q.all;
|
2017-02-14 23:19:21 +00:00
|
|
|
|
2017-08-10 20:35:24 +00:00
|
|
|
OAUTH3.PromiseA = PromiseAngularQ;
|
2017-08-25 23:47:31 +00:00
|
|
|
OAUTH3._digest = function () {
|
|
|
|
$rootScope.$digest();
|
|
|
|
};
|
2017-02-14 23:19:21 +00:00
|
|
|
|
2017-08-10 20:35:24 +00:00
|
|
|
window.ngOauth3 = OAUTH3;
|
2017-02-14 23:19:21 +00:00
|
|
|
|
2017-08-10 20:35:24 +00:00
|
|
|
return OAUTH3;
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('oauth3.org', [])
|
2017-08-10 20:39:35 +00:00
|
|
|
.service('azp@oauth3.org', modules.azp)
|
|
|
|
.service('AzpOauth3', modules.azp)
|
|
|
|
;
|
2017-02-14 23:19:21 +00:00
|
|
|
}());
|