-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor($ionicLoading,$ionicPopup): factor out common code, add tests
Also fixes $ionicLoading flickering on ios7 in beta.1.
- Loading branch information
Showing
24 changed files
with
959 additions
and
692 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Included by karma | ||
* Usage: var result = TestUtil.unwrapPromise(promise); | ||
*/ | ||
var TestUtil = { | ||
unwrapPromise: function(value) { | ||
var result; | ||
inject(function($rootScope, $q) { | ||
$q.when(value).then(function(data) { | ||
result = data; | ||
}); | ||
$rootScope.$apply(); | ||
}); | ||
return result; | ||
}, | ||
createMockTimeout: function(shouldApply) { | ||
var timeoutQueue = []; | ||
function timeout(fn, delay) { | ||
timeoutQueue.push({fn: fn, delay: delay}); | ||
} | ||
timeout.queue = timeoutQueue; | ||
timeout.expect = function(expectedDelay) { | ||
if (timeoutQueue.length > 0) { | ||
return { | ||
process: function() { | ||
var tick = timeoutQueue.shift(); | ||
if (angular.isDefined(expectedDelay)) { | ||
expect(tick.delay).toEqual(expectedDelay); | ||
} | ||
tick.fn(); | ||
shouldApply && inject(function($rootScope) { | ||
$rootScope.$apply(); | ||
}); | ||
} | ||
}; | ||
} else { | ||
expect('TimoutQueue empty. Expecting delay of ').toEqual(delay); | ||
} | ||
}; | ||
return timeout; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* deprecated.js | ||
* https://github.com/wearefractal/deprecated/ | ||
* Copyright (c) 2014 Fractal <[email protected]> | ||
* License MIT | ||
*/ | ||
//Interval object | ||
var deprecated = { | ||
method: function(msg, log, fn) { | ||
var called = false; | ||
return function deprecatedMethod(){ | ||
if (!called) { | ||
called = true; | ||
log(msg); | ||
} | ||
return fn.apply(this, arguments); | ||
}; | ||
}, | ||
|
||
field: function(msg, log, parent, field, val) { | ||
var called = false; | ||
var getter = function(){ | ||
if (!called) { | ||
called = true; | ||
log(msg); | ||
} | ||
return val; | ||
}; | ||
var setter = function(v) { | ||
if (!called) { | ||
called = true; | ||
log(msg); | ||
} | ||
val = v; | ||
return v; | ||
}; | ||
Object.defineProperty(parent, field, { | ||
get: getter, | ||
set: setter, | ||
enumerable: true | ||
}); | ||
return; | ||
} | ||
}; | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
angular.module('ionic') | ||
|
||
/** | ||
* @private | ||
*/ | ||
.factory('$ionicBackdrop', [ | ||
'$animate', | ||
'$document', | ||
function($animate, $document) { | ||
|
||
var el; | ||
var backdropHolds = 0; | ||
|
||
return { | ||
retain: retain, | ||
release: release, | ||
_getElement: getElement | ||
}; | ||
|
||
function getElement() { | ||
if (!el) { | ||
el = angular.element('<div class="backdrop ng-hide">'); | ||
$document[0].body.appendChild(el[0]); | ||
} | ||
return el; | ||
} | ||
function retain() { | ||
if ( (++backdropHolds) === 1 ) { | ||
$animate.removeClass(getElement(), 'ng-hide'); | ||
} | ||
} | ||
function release() { | ||
if ( (--backdropHolds) === 0 ) { | ||
$animate.addClass(getElement(), 'ng-hide'); | ||
} | ||
} | ||
}]); |
Oops, something went wrong.