Created
August 23, 2013 07:50
-
-
Save czechdude/6316616 to your computer and use it in GitHub Desktop.
When I run unit tests with jasmine, PhantomJS stops responing, while in Chrome the unit tests run without problems. I use: VS 2010SP1, Resharper 8, PhantomJS 1.9.1.0, Jasmine 1.2rc1, angular 1.1.5, angular-mocks 1.0.6
This file contains hidden or 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
/** | |
* @license AngularJS v1.0.6 | |
* (c) 2010-2012 Google, Inc. http://angularjs.org | |
* License: MIT | |
* | |
* TODO(vojta): wrap whole file into closure during build | |
*/ | |
/** | |
* @ngdoc overview | |
* @name angular.mock | |
* @description | |
* | |
* Namespace from 'angular-mocks.js' which contains testing related code. | |
*/ | |
angular.mock = {}; | |
/** | |
* ! This is a private undocumented service ! | |
* | |
* @name ngMock.$browser | |
* | |
* @description | |
* This service is a mock implementation of {@link ng.$browser}. It provides fake | |
* implementation for commonly used browser apis that are hard to test, e.g. setTimeout, xhr, | |
* cookies, etc... | |
* | |
* The api of this service is the same as that of the real {@link ng.$browser $browser}, except | |
* that there are several helper methods available which can be used in tests. | |
*/ | |
angular.mock.$BrowserProvider = function() { | |
this.$get = function(){ | |
return new angular.mock.$Browser(); | |
}; | |
}; | |
angular.mock.$Browser = function() { | |
var self = this; | |
this.isMock = true; | |
self.$$url = "http://server/"; | |
self.$$lastUrl = self.$$url; // used by url polling fn | |
self.pollFns = []; | |
// TODO(vojta): remove this temporary api | |
self.$$completeOutstandingRequest = angular.noop; | |
self.$$incOutstandingRequestCount = angular.noop; | |
// register url polling fn | |
self.onUrlChange = function(listener) { | |
self.pollFns.push( | |
function() { | |
if (self.$$lastUrl != self.$$url) { | |
self.$$lastUrl = self.$$url; | |
listener(self.$$url); | |
} | |
} | |
); | |
return listener; | |
}; | |
self.cookieHash = {}; | |
self.lastCookieHash = {}; | |
self.deferredFns = []; | |
self.deferredNextId = 0; | |
self.defer = function(fn, delay) { | |
delay = delay || 0; | |
self.deferredFns.push({time:(self.defer.now + delay), fn:fn, id: self.deferredNextId}); | |
self.deferredFns.sort(function(a,b){ return a.time - b.time;}); | |
return self.deferredNextId++; | |
}; | |
self.defer.now = 0; | |
self.defer.cancel = function(deferId) { | |
var fnIndex; | |
angular.forEach(self.deferredFns, function(fn, index) { | |
if (fn.id === deferId) fnIndex = index; | |
}); | |
if (fnIndex !== undefined) { | |
self.deferredFns.splice(fnIndex, 1); | |
return true; | |
} | |
return false; | |
}; | |
/** | |
* @name ngMock.$browser#defer.flush | |
* @methodOf ngMock.$browser | |
* | |
* @description | |
* Flushes all pending requests and executes the defer callbacks. | |
* | |
* @param {number=} number of milliseconds to flush. See {@link #defer.now} | |
*/ | |
self.defer.flush = function(delay) { | |
if (angular.isDefined(delay)) { | |
self.defer.now += delay; | |
} else { | |
if (self.deferredFns.length) { | |
self.defer.now = self.deferredFns[self.deferredFns.length-1].time; | |
} else { | |
throw Error('No deferred tasks to be flushed'); | |
} | |
} | |
while (self.deferredFns.length && self.deferredFns[0].time <= self.defer.now) { | |
self.deferredFns.shift().fn(); | |
} | |
}; | |
/** | |
* @name ngMock.$browser#defer.now | |
* @propertyOf ngMock.$browser | |
* | |
* @description | |
* Current milliseconds mock time. | |
*/ | |
self.$$baseHref = ''; | |
self.baseHref = function() { | |
return this.$$baseHref; | |
}; | |
}; | |
angular.mock.$Browser.prototype = { | |
/** | |
* @name ngMock.$browser#poll | |
* @methodOf ngMock.$browser | |
* | |
* @description | |
* run all fns in pollFns | |
*/ | |
poll: function poll() { | |
angular.forEach(this.pollFns, function(pollFn){ | |
pollFn(); | |
}); | |
}, | |
addPollFn: function(pollFn) { | |
this.pollFns.push(pollFn); | |
return pollFn; | |
}, | |
url: function(url, replace) { | |
if (url) { | |
this.$$url = url; | |
return this; | |
} | |
return this.$$url; | |
}, | |
cookies: function(name, value) { | |
if (name) { | |
if (value == undefined) { | |
delete this.cookieHash[name]; | |
} else { | |
if (angular.isString(value) && //strings only | |
value.length <= 4096) { //strict cookie storage limits | |
this.cookieHash[name] = value; | |
} | |
} | |
} else { | |
if (!angular.equals(this.cookieHash, this.lastCookieHash)) { | |
this.lastCookieHash = angular.copy(this.cookieHash); | |
this.cookieHash = angular.copy(this.cookieHash); | |
} | |
return this.cookieHash; | |
} | |
}, | |
notifyWhenNoOutstandingRequests: function(fn) { | |
fn(); | |
} | |
}; | |
/** | |
* @ngdoc object | |
* @name ngMock.$exceptionHandlerProvider | |
* | |
* @description | |
* Configures the mock implementation of {@link ng.$exceptionHandler} to rethrow or to log errors passed | |
* into the `$exceptionHandler`. | |
*/ | |
/** | |
* @ngdoc object | |
* @name ngMock.$exceptionHandler | |
* | |
* @description | |
* Mock implementation of {@link ng.$exceptionHandler} that rethrows or logs errors passed | |
* into it. See {@link ngMock.$exceptionHandlerProvider $exceptionHandlerProvider} for configuration | |
* information. | |
* | |
* | |
* <pre> | |
* describe('$exceptionHandlerProvider', function() { | |
* | |
* it('should capture log messages and exceptions', function() { | |
* | |
* module(function($exceptionHandlerProvider) { | |
* $exceptionHandlerProvider.mode('log'); | |
* }); | |
* | |
* inject(function($log, $exceptionHandler, $timeout) { | |
* $timeout(function() { $log.log(1); }); | |
* $timeout(function() { $log.log(2); throw 'banana peel'; }); | |
* $timeout(function() { $log.log(3); }); | |
* expect($exceptionHandler.errors).toEqual([]); | |
* expect($log.assertEmpty()); | |
* $timeout.flush(); | |
* expect($exceptionHandler.errors).toEqual(['banana peel']); | |
* expect($log.log.logs).toEqual([[1], [2], [3]]); | |
* }); | |
* }); | |
* }); | |
* </pre> | |
*/ | |
angular.mock.$ExceptionHandlerProvider = function() { | |
var handler; | |
/** | |
* @ngdoc method | |
* @name ngMock.$exceptionHandlerProvider#mode | |
* @methodOf ngMock.$exceptionHandlerProvider | |
* | |
* @description | |
* Sets the logging mode. | |
* | |
* @param {string} mode Mode of operation, defaults to `rethrow`. | |
* | |
* - `rethrow`: If any errors are are passed into the handler in tests, it typically | |
* means that there is a bug in the application or test, so this mock will | |
* make these tests fail. | |
* - `log`: Sometimes it is desirable to test that an error is thrown, for this case the `log` mode stores an | |
* array of errors in `$exceptionHandler.errors`, to allow later assertion of them. | |
* See {@link ngMock.$log#assertEmpty assertEmpty()} and | |
* {@link ngMock.$log#reset reset()} | |
*/ | |
this.mode = function(mode) { | |
switch(mode) { | |
case 'rethrow': | |
handler = function(e) { | |
throw e; | |
}; | |
break; | |
case 'log': | |
var errors = []; | |
handler = function(e) { | |
if (arguments.length == 1) { | |
errors.push(e); | |
} else { | |
errors.push([].slice.call(arguments, 0)); | |
} | |
}; | |
handler.errors = errors; | |
break; | |
default: | |
throw Error("Unknown mode '" + mode + "', only 'log'/'rethrow' modes are allowed!"); | |
} | |
}; | |
this.$get = function() { | |
return handler; | |
}; | |
this.mode('rethrow'); | |
}; | |
/** | |
* @ngdoc service | |
* @name ngMock.$log | |
* | |
* @description | |
* Mock implementation of {@link ng.$log} that gathers all logged messages in arrays | |
* (one array per logging level). These arrays are exposed as `logs` property of each of the | |
* level-specific log function, e.g. for level `error` the array is exposed as `$log.error.logs`. | |
* | |
*/ | |
angular.mock.$LogProvider = function() { | |
function concat(array1, array2, index) { | |
return array1.concat(Array.prototype.slice.call(array2, index)); | |
} | |
this.$get = function () { | |
var $log = { | |
log: function() { $log.log.logs.push(concat([], arguments, 0)); }, | |
warn: function() { $log.warn.logs.push(concat([], arguments, 0)); }, | |
info: function() { $log.info.logs.push(concat([], arguments, 0)); }, | |
error: function() { $log.error.logs.push(concat([], arguments, 0)); } | |
}; | |
/** | |
* @ngdoc method | |
* @name ngMock.$log#reset | |
* @methodOf ngMock.$log | |
* | |
* @description | |
* Reset all of the logging arrays to empty. | |
*/ | |
$log.reset = function () { | |
/** | |
* @ngdoc property | |
* @name ngMock.$log#log.logs | |
* @propertyOf ngMock.$log | |
* | |
* @description | |
* Array of logged messages. | |
*/ | |
$log.log.logs = []; | |
/** | |
* @ngdoc property | |
* @name ngMock.$log#warn.logs | |
* @propertyOf ngMock.$log | |
* | |
* @description | |
* Array of logged messages. | |
*/ | |
$log.warn.logs = []; | |
/** | |
* @ngdoc property | |
* @name ngMock.$log#info.logs | |
* @propertyOf ngMock.$log | |
* | |
* @description | |
* Array of logged messages. | |
*/ | |
$log.info.logs = []; | |
/** | |
* @ngdoc property | |
* @name ngMock.$log#error.logs | |
* @propertyOf ngMock.$log | |
* | |
* @description | |
* Array of logged messages. | |
*/ | |
$log.error.logs = []; | |
}; | |
/** | |
* @ngdoc method | |
* @name ngMock.$log#assertEmpty | |
* @methodOf ngMock.$log | |
* | |
* @description | |
* Assert that the all of the logging methods have no logged messages. If messages present, an exception is thrown. | |
*/ | |
$log.assertEmpty = function() { | |
var errors = []; | |
angular.forEach(['error', 'warn', 'info', 'log'], function(logLevel) { | |
angular.forEach($log[logLevel].logs, function(log) { | |
angular.forEach(log, function (logItem) { | |
errors.push('MOCK $log (' + logLevel + '): ' + String(logItem) + '\n' + (logItem.stack || '')); | |
}); | |
}); | |
}); | |
if (errors.length) { | |
errors.unshift("Expected $log to be empty! Either a message was logged unexpectedly, or an expected " + | |
"log message was not checked and removed:"); | |
errors.push(''); | |
throw new Error(errors.join('\n---------\n')); | |
} | |
}; | |
$log.reset(); | |
return $log; | |
}; | |
}; | |
(function() { | |
var R_ISO8061_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?:\:?(\d\d)(?:\:?(\d\d)(?:\.(\d{3}))?)?)?(Z|([+-])(\d\d):?(\d\d)))?$/; | |
function jsonStringToDate(string){ | |
var match; | |
if (match = string.match(R_ISO8061_STR)) { | |
var date = new Date(0), | |
tzHour = 0, | |
tzMin = 0; | |
if (match[9]) { | |
tzHour = int(match[9] + match[10]); | |
tzMin = int(match[9] + match[11]); | |
} | |
date.setUTCFullYear(int(match[1]), int(match[2]) - 1, int(match[3])); | |
date.setUTCHours(int(match[4]||0) - tzHour, int(match[5]||0) - tzMin, int(match[6]||0), int(match[7]||0)); | |
return date; | |
} | |
return string; | |
} | |
function int(str) { | |
return parseInt(str, 10); | |
} | |
function padNumber(num, digits, trim) { | |
var neg = ''; | |
if (num < 0) { | |
neg = '-'; | |
num = -num; | |
} | |
num = '' + num; | |
while(num.length < digits) num = '0' + num; | |
if (trim) | |
num = num.substr(num.length - digits); | |
return neg + num; | |
} | |
/** | |
* @ngdoc object | |
* @name angular.mock.TzDate | |
* @description | |
* | |
* *NOTE*: this is not an injectable instance, just a globally available mock class of `Date`. | |
* | |
* Mock of the Date type which has its timezone specified via constructor arg. | |
* | |
* The main purpose is to create Date-like instances with timezone fixed to the specified timezone | |
* offset, so that we can test code that depends on local timezone settings without dependency on | |
* the time zone settings of the machine where the code is running. | |
* | |
* @param {number} offset Offset of the *desired* timezone in hours (fractions will be honored) | |
* @param {(number|string)} timestamp Timestamp representing the desired time in *UTC* | |
* | |
* @example | |
* !!!! WARNING !!!!! | |
* This is not a complete Date object so only methods that were implemented can be called safely. | |
* To make matters worse, TzDate instances inherit stuff from Date via a prototype. | |
* | |
* We do our best to intercept calls to "unimplemented" methods, but since the list of methods is | |
* incomplete we might be missing some non-standard methods. This can result in errors like: | |
* "Date.prototype.foo called on incompatible Object". | |
* | |
* <pre> | |
* var newYearInBratislava = new TzDate(-1, '2009-12-31T23:00:00Z'); | |
* newYearInBratislava.getTimezoneOffset() => -60; | |
* newYearInBratislava.getFullYear() => 2010; | |
* newYearInBratislava.getMonth() => 0; | |
* newYearInBratislava.getDate() => 1; | |
* newYearInBratislava.getHours() => 0; | |
* newYearInBratislava.getMinutes() => 0; | |
* </pre> | |
* | |
*/ | |
angular.mock.TzDate = function (offset, timestamp) { | |
var self = new Date(0); | |
if (angular.isString(timestamp)) { | |
var tsStr = timestamp; | |
self.origDate = jsonStringToDate(timestamp); | |
timestamp = self.origDate.getTime(); | |
if (isNaN(timestamp)) | |
throw { | |
name: "Illegal Argument", | |
message: "Arg '" + tsStr + "' passed into TzDate constructor is not a valid date string" | |
}; | |
} else { | |
self.origDate = new Date(timestamp); | |
} | |
var localOffset = new Date(timestamp).getTimezoneOffset(); | |
self.offsetDiff = localOffset*60*1000 - offset*1000*60*60; | |
self.date = new Date(timestamp + self.offsetDiff); | |
self.getTime = function() { | |
return self.date.getTime() - self.offsetDiff; | |
}; | |
self.toLocaleDateString = function() { | |
return self.date.toLocaleDateString(); | |
}; | |
self.getFullYear = function() { | |
return self.date.getFullYear(); | |
}; | |
self.getMonth = function() { | |
return self.date.getMonth(); | |
}; | |
self.getDate = function() { | |
return self.date.getDate(); | |
}; | |
self.getHours = function() { | |
return self.date.getHours(); | |
}; | |
self.getMinutes = function() { | |
return self.date.getMinutes(); | |
}; | |
self.getSeconds = function() { | |
return self.date.getSeconds(); | |
}; | |
self.getTimezoneOffset = function() { | |
return offset * 60; | |
}; | |
self.getUTCFullYear = function() { | |
return self.origDate.getUTCFullYear(); | |
}; | |
self.getUTCMonth = function() { | |
return self.origDate.getUTCMonth(); | |
}; | |
self.getUTCDate = function() { | |
return self.origDate.getUTCDate(); | |
}; | |
self.getUTCHours = function() { | |
return self.origDate.getUTCHours(); | |
}; | |
self.getUTCMinutes = function() { | |
return self.origDate.getUTCMinutes(); | |
}; | |
self.getUTCSeconds = function() { | |
return self.origDate.getUTCSeconds(); | |
}; | |
self.getUTCMilliseconds = function() { | |
return self.origDate.getUTCMilliseconds(); | |
}; | |
self.getDay = function() { | |
return self.date.getDay(); | |
}; | |
// provide this method only on browsers that already have it | |
if (self.toISOString) { | |
self.toISOString = function() { | |
return padNumber(self.origDate.getUTCFullYear(), 4) + '-' + | |
padNumber(self.origDate.getUTCMonth() + 1, 2) + '-' + | |
padNumber(self.origDate.getUTCDate(), 2) + 'T' + | |
padNumber(self.origDate.getUTCHours(), 2) + ':' + | |
padNumber(self.origDate.getUTCMinutes(), 2) + ':' + | |
padNumber(self.origDate.getUTCSeconds(), 2) + '.' + | |
padNumber(self.origDate.getUTCMilliseconds(), 3) + 'Z' | |
} | |
} | |
//hide all methods not implemented in this mock that the Date prototype exposes | |
var unimplementedMethods = ['getMilliseconds', 'getUTCDay', | |
'getYear', 'setDate', 'setFullYear', 'setHours', 'setMilliseconds', | |
'setMinutes', 'setMonth', 'setSeconds', 'setTime', 'setUTCDate', 'setUTCFullYear', | |
'setUTCHours', 'setUTCMilliseconds', 'setUTCMinutes', 'setUTCMonth', 'setUTCSeconds', | |
'setYear', 'toDateString', 'toGMTString', 'toJSON', 'toLocaleFormat', 'toLocaleString', | |
'toLocaleTimeString', 'toSource', 'toString', 'toTimeString', 'toUTCString', 'valueOf']; | |
angular.forEach(unimplementedMethods, function(methodName) { | |
self[methodName] = function() { | |
throw Error("Method '" + methodName + "' is not implemented in the TzDate mock"); | |
}; | |
}); | |
return self; | |
}; | |
//make "tzDateInstance instanceof Date" return true | |
angular.mock.TzDate.prototype = Date.prototype; | |
})(); | |
/** | |
* @ngdoc function | |
* @name angular.mock.dump | |
* @description | |
* | |
* *NOTE*: this is not an injectable instance, just a globally available function. | |
* | |
* Method for serializing common angular objects (scope, elements, etc..) into strings, useful for debugging. | |
* | |
* This method is also available on window, where it can be used to display objects on debug console. | |
* | |
* @param {*} object - any object to turn into string. | |
* @return {string} a serialized string of the argument | |
*/ | |
angular.mock.dump = function(object) { | |
return serialize(object); | |
function serialize(object) { | |
var out; | |
if (angular.isElement(object)) { | |
object = angular.element(object); | |
out = angular.element('<div></div>'); | |
angular.forEach(object, function(element) { | |
out.append(angular.element(element).clone()); | |
}); | |
out = out.html(); | |
} else if (angular.isArray(object)) { | |
out = []; | |
angular.forEach(object, function(o) { | |
out.push(serialize(o)); | |
}); | |
out = '[ ' + out.join(', ') + ' ]'; | |
} else if (angular.isObject(object)) { | |
if (angular.isFunction(object.$eval) && angular.isFunction(object.$apply)) { | |
out = serializeScope(object); | |
} else if (object instanceof Error) { | |
out = object.stack || ('' + object.name + ': ' + object.message); | |
} else { | |
out = angular.toJson(object, true); | |
} | |
} else { | |
out = String(object); | |
} | |
return out; | |
} | |
function serializeScope(scope, offset) { | |
offset = offset || ' '; | |
var log = [offset + 'Scope(' + scope.$id + '): {']; | |
for ( var key in scope ) { | |
if (scope.hasOwnProperty(key) && !key.match(/^(\$|this)/)) { | |
log.push(' ' + key + ': ' + angular.toJson(scope[key])); | |
} | |
} | |
var child = scope.$$childHead; | |
while(child) { | |
log.push(serializeScope(child, offset + ' ')); | |
child = child.$$nextSibling; | |
} | |
log.push('}'); | |
return log.join('\n' + offset); | |
} | |
}; | |
/** | |
* @ngdoc object | |
* @name ngMock.$httpBackend | |
* @description | |
* Fake HTTP backend implementation suitable for unit testing application that use the | |
* {@link ng.$http $http service}. | |
* | |
* *Note*: For fake http backend implementation suitable for end-to-end testing or backend-less | |
* development please see {@link ngMockE2E.$httpBackend e2e $httpBackend mock}. | |
* | |
* During unit testing, we want our unit tests to run quickly and have no external dependencies so | |
* we don’t want to send {@link https://developer.mozilla.org/en/xmlhttprequest XHR} or | |
* {@link http://en.wikipedia.org/wiki/JSONP JSONP} requests to a real server. All we really need is | |
* to verify whether a certain request has been sent or not, or alternatively just let the | |
* application make requests, respond with pre-trained responses and assert that the end result is | |
* what we expect it to be. | |
* | |
* This mock implementation can be used to respond with static or dynamic responses via the | |
* `expect` and `when` apis and their shortcuts (`expectGET`, `whenPOST`, etc). | |
* | |
* When an Angular application needs some data from a server, it calls the $http service, which | |
* sends the request to a real server using $httpBackend service. With dependency injection, it is | |
* easy to inject $httpBackend mock (which has the same API as $httpBackend) and use it to verify | |
* the requests and respond with some testing data without sending a request to real server. | |
* | |
* There are two ways to specify what test data should be returned as http responses by the mock | |
* backend when the code under test makes http requests: | |
* | |
* - `$httpBackend.expect` - specifies a request expectation | |
* - `$httpBackend.when` - specifies a backend definition | |
* | |
* | |
* # Request Expectations vs Backend Definitions | |
* | |
* Request expectations provide a way to make assertions about requests made by the application and | |
* to define responses for those requests. The test will fail if the expected requests are not made | |
* or they are made in the wrong order. | |
* | |
* Backend definitions allow you to define a fake backend for your application which doesn't assert | |
* if a particular request was made or not, it just returns a trained response if a request is made. | |
* The test will pass whether or not the request gets made during testing. | |
* | |
* | |
* <table class="table"> | |
* <tr><th width="220px"></th><th>Request expectations</th><th>Backend definitions</th></tr> | |
* <tr> | |
* <th>Syntax</th> | |
* <td>.expect(...).respond(...)</td> | |
* <td>.when(...).respond(...)</td> | |
* </tr> | |
* <tr> | |
* <th>Typical usage</th> | |
* <td>strict unit tests</td> | |
* <td>loose (black-box) unit testing</td> | |
* </tr> | |
* <tr> | |
* <th>Fulfills multiple requests</th> | |
* <td>NO</td> | |
* <td>YES</td> | |
* </tr> | |
* <tr> | |
* <th>Order of requests matters</th> | |
* <td>YES</td> | |
* <td>NO</td> | |
* </tr> | |
* <tr> | |
* <th>Request required</th> | |
* <td>YES</td> | |
* <td>NO</td> | |
* </tr> | |
* <tr> | |
* <th>Response required</th> | |
* <td>optional (see below)</td> | |
* <td>YES</td> | |
* </tr> | |
* </table> | |
* | |
* In cases where both backend definitions and request expectations are specified during unit | |
* testing, the request expectations are evaluated first. | |
* | |
* If a request expectation has no response specified, the algorithm will search your backend | |
* definitions for an appropriate response. | |
* | |
* If a request didn't match any expectation or if the expectation doesn't have the response | |
* defined, the backend definitions are evaluated in sequential order to see if any of them match | |
* the request. The response from the first matched definition is returned. | |
* | |
* | |
* # Flushing HTTP requests | |
* | |
* The $httpBackend used in production, always responds to requests with responses asynchronously. | |
* If we preserved this behavior in unit testing, we'd have to create async unit tests, which are | |
* hard to write, follow and maintain. At the same time the testing mock, can't respond | |
* synchronously because that would change the execution of the code under test. For this reason the | |
* mock $httpBackend has a `flush()` method, which allows the test to explicitly flush pending | |
* requests and thus preserving the async api of the backend, while allowing the test to execute | |
* synchronously. | |
* | |
* | |
* # Unit testing with mock $httpBackend | |
* | |
* <pre> | |
// controller | |
function MyController($scope, $http) { | |
$http.get('/auth.py').success(function(data) { | |
$scope.user = data; | |
}); | |
this.saveMessage = function(message) { | |
$scope.status = 'Saving...'; | |
$http.post('/add-msg.py', message).success(function(response) { | |
$scope.status = ''; | |
}).error(function() { | |
$scope.status = 'ERROR!'; | |
}); | |
}; | |
} | |
// testing controller | |
var $httpBackend; | |
beforeEach(inject(function($injector) { | |
$httpBackend = $injector.get('$httpBackend'); | |
// backend definition common for all tests | |
$httpBackend.when('GET', '/auth.py').respond({userId: 'userX'}, {'A-Token': 'xxx'}); | |
})); | |
afterEach(function() { | |
$httpBackend.verifyNoOutstandingExpectation(); | |
$httpBackend.verifyNoOutstandingRequest(); | |
}); | |
it('should fetch authentication token', function() { | |
$httpBackend.expectGET('/auth.py'); | |
var controller = scope.$new(MyController); | |
$httpBackend.flush(); | |
}); | |
it('should send msg to server', function() { | |
// now you don’t care about the authentication, but | |
// the controller will still send the request and | |
// $httpBackend will respond without you having to | |
// specify the expectation and response for this request | |
$httpBackend.expectPOST('/add-msg.py', 'message content').respond(201, ''); | |
var controller = scope.$new(MyController); | |
$httpBackend.flush(); | |
controller.saveMessage('message content'); | |
expect(controller.status).toBe('Saving...'); | |
$httpBackend.flush(); | |
expect(controller.status).toBe(''); | |
}); | |
it('should send auth header', function() { | |
$httpBackend.expectPOST('/add-msg.py', undefined, function(headers) { | |
// check if the header was send, if it wasn't the expectation won't | |
// match the request and the test will fail | |
return headers['Authorization'] == 'xxx'; | |
}).respond(201, ''); | |
var controller = scope.$new(MyController); | |
controller.saveMessage('whatever'); | |
$httpBackend.flush(); | |
}); | |
</pre> | |
*/ | |
angular.mock.$HttpBackendProvider = function() { | |
this.$get = [createHttpBackendMock]; | |
}; | |
/** | |
* General factory function for $httpBackend mock. | |
* Returns instance for unit testing (when no arguments specified): | |
* - passing through is disabled | |
* - auto flushing is disabled | |
* | |
* Returns instance for e2e testing (when `$delegate` and `$browser` specified): | |
* - passing through (delegating request to real backend) is enabled | |
* - auto flushing is enabled | |
* | |
* @param {Object=} $delegate Real $httpBackend instance (allow passing through if specified) | |
* @param {Object=} $browser Auto-flushing enabled if specified | |
* @return {Object} Instance of $httpBackend mock | |
*/ | |
function createHttpBackendMock($delegate, $browser) { | |
var definitions = [], | |
expectations = [], | |
responses = [], | |
responsesPush = angular.bind(responses, responses.push); | |
function createResponse(status, data, headers) { | |
if (angular.isFunction(status)) return status; | |
return function() { | |
return angular.isNumber(status) | |
? [status, data, headers] | |
: [200, status, data]; | |
}; | |
} | |
// TODO(vojta): change params to: method, url, data, headers, callback | |
function $httpBackend(method, url, data, callback, headers) { | |
var xhr = new MockXhr(), | |
expectation = expectations[0], | |
wasExpected = false; | |
function prettyPrint(data) { | |
return (angular.isString(data) || angular.isFunction(data) || data instanceof RegExp) | |
? data | |
: angular.toJson(data); | |
} | |
if (expectation && expectation.match(method, url)) { | |
if (!expectation.matchData(data)) | |
throw Error('Expected ' + expectation + ' with different data\n' + | |
'EXPECTED: ' + prettyPrint(expectation.data) + '\nGOT: ' + data); | |
if (!expectation.matchHeaders(headers)) | |
throw Error('Expected ' + expectation + ' with different headers\n' + | |
'EXPECTED: ' + prettyPrint(expectation.headers) + '\nGOT: ' + | |
prettyPrint(headers)); | |
expectations.shift(); | |
if (expectation.response) { | |
responses.push(function() { | |
var response = expectation.response(method, url, data, headers); | |
xhr.$$respHeaders = response[2]; | |
callback(response[0], response[1], xhr.getAllResponseHeaders()); | |
}); | |
return; | |
} | |
wasExpected = true; | |
} | |
var i = -1, definition; | |
while ((definition = definitions[++i])) { | |
if (definition.match(method, url, data, headers || {})) { | |
if (definition.response) { | |
// if $browser specified, we do auto flush all requests | |
($browser ? $browser.defer : responsesPush)(function() { | |
var response = definition.response(method, url, data, headers); | |
xhr.$$respHeaders = response[2]; | |
callback(response[0], response[1], xhr.getAllResponseHeaders()); | |
}); | |
} else if (definition.passThrough) { | |
$delegate(method, url, data, callback, headers); | |
} else throw Error('No response defined !'); | |
return; | |
} | |
} | |
throw wasExpected ? | |
Error('No response defined !') : | |
Error('Unexpected request: ' + method + ' ' + url + '\n' + | |
(expectation ? 'Expected ' + expectation : 'No more request expected')); | |
} | |
/** | |
* @ngdoc method | |
* @name ngMock.$httpBackend#when | |
* @methodOf ngMock.$httpBackend | |
* @description | |
* Creates a new backend definition. | |
* | |
* @param {string} method HTTP method. | |
* @param {string|RegExp} url HTTP url. | |
* @param {(string|RegExp)=} data HTTP request body. | |
* @param {(Object|function(Object))=} headers HTTP headers or function that receives http header | |
* object and returns true if the headers match the current definition. | |
* @returns {requestHandler} Returns an object with `respond` method that control how a matched | |
* request is handled. | |
* | |
* - respond – `{function([status,] data[, headers])|function(function(method, url, data, headers)}` | |
* – The respond method takes a set of static data to be returned or a function that can return | |
* an array containing response status (number), response data (string) and response headers | |
* (Object). | |
*/ | |
$httpBackend.when = function(method, url, data, headers) { | |
var definition = new MockHttpExpectation(method, url, data, headers), | |
chain = { | |
respond: function(status, data, headers) { | |
definition.response = createResponse(status, data, headers); | |
} | |
}; | |
if ($browser) { | |
chain.passThrough = function() { | |
definition.passThrough = true; | |
}; | |
} | |
definitions.push(definition); | |
return chain; | |
}; | |
/** | |
* @ngdoc method | |
* @name ngMock.$httpBackend#whenGET | |
* @methodOf ngMock.$httpBackend | |
* @description | |
* Creates a new backend definition for GET requests. For more info see `when()`. | |
* | |
* @param {string|RegExp} url HTTP url. | |
* @param {(Object|function(Object))=} headers HTTP headers. | |
* @returns {requestHandler} Returns an object with `respond` method that control how a matched | |
* request is handled. | |
*/ | |
/** | |
* @ngdoc method | |
* @name ngMock.$httpBackend#whenHEAD | |
* @methodOf ngMock.$httpBackend | |
* @description | |
* Creates a new backend definition for HEAD requests. For more info see `when()`. | |
* | |
* @param {string|RegExp} url HTTP url. | |
* @param {(Object|function(Object))=} headers HTTP headers. | |
* @returns {requestHandler} Returns an object with `respond` method that control how a matched | |
* request is handled. | |
*/ | |
/** | |
* @ngdoc method | |
* @name ngMock.$httpBackend#whenDELETE | |
* @methodOf ngMock.$httpBackend | |
* @description | |
* Creates a new backend definition for DELETE requests. For more info see `when()`. | |
* | |
* @param {string|RegExp} url HTTP url. | |
* @param {(Object|function(Object))=} headers HTTP headers. | |
* @returns {requestHandler} Returns an object with `respond` method that control how a matched | |
* request is handled. | |
*/ | |
/** | |
* @ngdoc method | |
* @name ngMock.$httpBackend#whenPOST | |
* @methodOf ngMock.$httpBackend | |
* @description | |
* Creates a new backend definition for POST requests. For more info see `when()`. | |
* | |
* @param {string|RegExp} url HTTP url. | |
* @param {(string|RegExp)=} data HTTP request body. | |
* @param {(Object|function(Object))=} headers HTTP headers. | |
* @returns {requestHandler} Returns an object with `respond` method that control how a matched | |
* request is handled. | |
*/ | |
/** | |
* @ngdoc method | |
* @name ngMock.$httpBackend#whenPUT | |
* @methodOf ngMock.$httpBackend | |
* @description | |
* Creates a new backend definition for PUT requests. For more info see `when()`. | |
* | |
* @param {string|RegExp} url HTTP url. | |
* @param {(string|RegExp)=} data HTTP request body. | |
* @param {(Object|function(Object))=} headers HTTP headers. | |
* @returns {requestHandler} Returns an object with `respond` method that control how a matched | |
* request is handled. | |
*/ | |
/** | |
* @ngdoc method | |
* @name ngMock.$httpBackend#whenJSONP | |
* @methodOf ngMock.$httpBackend | |
* @description | |
* Creates a new backend definition for JSONP requests. For more info see `when()`. | |
* | |
* @param {string|RegExp} url HTTP url. | |
* @returns {requestHandler} Returns an object with `respond` method that control how a matched | |
* request is handled. | |
*/ | |
createShortMethods('when'); | |
/** | |
* @ngdoc method | |
* @name ngMock.$httpBackend#expect | |
* @methodOf ngMock.$httpBackend | |
* @description | |
* Creates a new request expectation. | |
* | |
* @param {string} method HTTP method. | |
* @param {string|RegExp} url HTTP url. | |
* @param {(string|RegExp)=} data HTTP request body. | |
* @param {(Object|function(Object))=} headers HTTP headers or function that receives http header | |
* object and returns true if the headers match the current expectation. | |
* @returns {requestHandler} Returns an object with `respond` method that control how a matched | |
* request is handled. | |
* | |
* - respond – `{function([status,] data[, headers])|function(function(method, url, data, headers)}` | |
* – The respond method takes a set of static data to be returned or a function that can return | |
* an array containing response status (number), response data (string) and response headers | |
* (Object). | |
*/ | |
$httpBackend.expect = function(method, url, data, headers) { | |
var expectation = new MockHttpExpectation(method, url, data, headers); | |
expectations.push(expectation); | |
return { | |
respond: function(status, data, headers) { | |
expectation.response = createResponse(status, data, headers); | |
} | |
}; | |
}; | |
/** | |
* @ngdoc method | |
* @name ngMock.$httpBackend#expectGET | |
* @methodOf ngMock.$httpBackend | |
* @description | |
* Creates a new request expectation for GET requests. For more info see `expect()`. | |
* | |
* @param {string|RegExp} url HTTP url. | |
* @param {Object=} headers HTTP headers. | |
* @returns {requestHandler} Returns an object with `respond` method that control how a matched | |
* request is handled. See #expect for more info. | |
*/ | |
/** | |
* @ngdoc method | |
* @name ngMock.$httpBackend#expectHEAD | |
* @methodOf ngMock.$httpBackend | |
* @description | |
* Creates a new request expectation for HEAD requests. For more info see `expect()`. | |
* | |
* @param {string|RegExp} url HTTP url. | |
* @param {Object=} headers HTTP headers. | |
* @returns {requestHandler} Returns an object with `respond` method that control how a matched | |
* request is handled. | |
*/ | |
/** | |
* @ngdoc method | |
* @name ngMock.$httpBackend#expectDELETE | |
* @methodOf ngMock.$httpBackend | |
* @description | |
* Creates a new request expectation for DELETE requests. For more info see `expect()`. | |
* | |
* @param {string|RegExp} url HTTP url. | |
* @param {Object=} headers HTTP headers. | |
* @returns {requestHandler} Returns an object with `respond` method that control how a matched | |
* request is handled. | |
*/ | |
/** | |
* @ngdoc method | |
* @name ngMock.$httpBackend#expectPOST | |
* @methodOf ngMock.$httpBackend | |
* @description | |
* Creates a new request expectation for POST requests. For more info see `expect()`. | |
* | |
* @param {string|RegExp} url HTTP url. | |
* @param {(string|RegExp)=} data HTTP request body. | |
* @param {Object=} headers HTTP headers. | |
* @returns {requestHandler} Returns an object with `respond` method that control how a matched | |
* request is handled. | |
*/ | |
/** | |
* @ngdoc method | |
* @name ngMock.$httpBackend#expectPUT | |
* @methodOf ngMock.$httpBackend | |
* @description | |
* Creates a new request expectation for PUT requests. For more info see `expect()`. | |
* | |
* @param {string|RegExp} url HTTP url. | |
* @param {(string|RegExp)=} data HTTP request body. | |
* @param {Object=} headers HTTP headers. | |
* @returns {requestHandler} Returns an object with `respond` method that control how a matched | |
* request is handled. | |
*/ | |
/** | |
* @ngdoc method | |
* @name ngMock.$httpBackend#expectPATCH | |
* @methodOf ngMock.$httpBackend | |
* @description | |
* Creates a new request expectation for PATCH requests. For more info see `expect()`. | |
* | |
* @param {string|RegExp} url HTTP url. | |
* @param {(string|RegExp)=} data HTTP request body. | |
* @param {Object=} headers HTTP headers. | |
* @returns {requestHandler} Returns an object with `respond` method that control how a matched | |
* request is handled. | |
*/ | |
/** | |
* @ngdoc method | |
* @name ngMock.$httpBackend#expectJSONP | |
* @methodOf ngMock.$httpBackend | |
* @description | |
* Creates a new request expectation for JSONP requests. For more info see `expect()`. | |
* | |
* @param {string|RegExp} url HTTP url. | |
* @returns {requestHandler} Returns an object with `respond` method that control how a matched | |
* request is handled. | |
*/ | |
createShortMethods('expect'); | |
/** | |
* @ngdoc method | |
* @name ngMock.$httpBackend#flush | |
* @methodOf ngMock.$httpBackend | |
* @description | |
* Flushes all pending requests using the trained responses. | |
* | |
* @param {number=} count Number of responses to flush (in the order they arrived). If undefined, | |
* all pending requests will be flushed. If there are no pending requests when the flush method | |
* is called an exception is thrown (as this typically a sign of programming error). | |
*/ | |
$httpBackend.flush = function(count) { | |
if (!responses.length) throw Error('No pending request to flush !'); | |
if (angular.isDefined(count)) { | |
while (count--) { | |
if (!responses.length) throw Error('No more pending request to flush !'); | |
responses.shift()(); | |
} | |
} else { | |
while (responses.length) { | |
responses.shift()(); | |
} | |
} | |
$httpBackend.verifyNoOutstandingExpectation(); | |
}; | |
/** | |
* @ngdoc method | |
* @name ngMock.$httpBackend#verifyNoOutstandingExpectation | |
* @methodOf ngMock.$httpBackend | |
* @description | |
* Verifies that all of the requests defined via the `expect` api were made. If any of the | |
* requests were not made, verifyNoOutstandingExpectation throws an exception. | |
* | |
* Typically, you would call this method following each test case that asserts requests using an | |
* "afterEach" clause. | |
* | |
* <pre> | |
* afterEach($httpBackend.verifyExpectations); | |
* </pre> | |
*/ | |
$httpBackend.verifyNoOutstandingExpectation = function() { | |
if (expectations.length) { | |
throw Error('Unsatisfied requests: ' + expectations.join(', ')); | |
} | |
}; | |
/** | |
* @ngdoc method | |
* @name ngMock.$httpBackend#verifyNoOutstandingRequest | |
* @methodOf ngMock.$httpBackend | |
* @description | |
* Verifies that there are no outstanding requests that need to be flushed. | |
* | |
* Typically, you would call this method following each test case that asserts requests using an | |
* "afterEach" clause. | |
* | |
* <pre> | |
* afterEach($httpBackend.verifyNoOutstandingRequest); | |
* </pre> | |
*/ | |
$httpBackend.verifyNoOutstandingRequest = function() { | |
if (responses.length) { | |
throw Error('Unflushed requests: ' + responses.length); | |
} | |
}; | |
/** | |
* @ngdoc method | |
* @name ngMock.$httpBackend#resetExpectations | |
* @methodOf ngMock.$httpBackend | |
* @description | |
* Resets all request expectations, but preserves all backend definitions. Typically, you would | |
* call resetExpectations during a multiple-phase test when you want to reuse the same instance of | |
* $httpBackend mock. | |
*/ | |
$httpBackend.resetExpectations = function() { | |
expectations.length = 0; | |
responses.length = 0; | |
}; | |
return $httpBackend; | |
function createShortMethods(prefix) { | |
angular.forEach(['GET', 'DELETE', 'JSONP'], function(method) { | |
$httpBackend[prefix + method] = function(url, headers) { | |
return $httpBackend[prefix](method, url, undefined, headers) | |
} | |
}); | |
angular.forEach(['PUT', 'POST', 'PATCH'], function(method) { | |
$httpBackend[prefix + method] = function(url, data, headers) { | |
return $httpBackend[prefix](method, url, data, headers) | |
} | |
}); | |
} | |
} | |
function MockHttpExpectation(method, url, data, headers) { | |
this.data = data; | |
this.headers = headers; | |
this.match = function(m, u, d, h) { | |
if (method != m) return false; | |
if (!this.matchUrl(u)) return false; | |
if (angular.isDefined(d) && !this.matchData(d)) return false; | |
if (angular.isDefined(h) && !this.matchHeaders(h)) return false; | |
return true; | |
}; | |
this.matchUrl = function(u) { | |
if (!url) return true; | |
if (angular.isFunction(url.test)) return url.test(u); | |
return url == u; | |
}; | |
this.matchHeaders = function(h) { | |
if (angular.isUndefined(headers)) return true; | |
if (angular.isFunction(headers)) return headers(h); | |
return angular.equals(headers, h); | |
}; | |
this.matchData = function(d) { | |
if (angular.isUndefined(data)) return true; | |
if (data && angular.isFunction(data.test)) return data.test(d); | |
if (data && !angular.isString(data)) return angular.toJson(data) == d; | |
return data == d; | |
}; | |
this.toString = function() { | |
return method + ' ' + url; | |
}; | |
} | |
function MockXhr() { | |
// hack for testing $http, $httpBackend | |
MockXhr.$$lastInstance = this; | |
this.open = function(method, url, async) { | |
this.$$method = method; | |
this.$$url = url; | |
this.$$async = async; | |
this.$$reqHeaders = {}; | |
this.$$respHeaders = {}; | |
}; | |
this.send = function(data) { | |
this.$$data = data; | |
}; | |
this.setRequestHeader = function(key, value) { | |
this.$$reqHeaders[key] = value; | |
}; | |
this.getResponseHeader = function(name) { | |
// the lookup must be case insensitive, that's why we try two quick lookups and full scan at last | |
var header = this.$$respHeaders[name]; | |
if (header) return header; | |
name = angular.lowercase(name); | |
header = this.$$respHeaders[name]; | |
if (header) return header; | |
header = undefined; | |
angular.forEach(this.$$respHeaders, function(headerVal, headerName) { | |
if (!header && angular.lowercase(headerName) == name) header = headerVal; | |
}); | |
return header; | |
}; | |
this.getAllResponseHeaders = function() { | |
var lines = []; | |
angular.forEach(this.$$respHeaders, function(value, key) { | |
lines.push(key + ': ' + value); | |
}); | |
return lines.join('\n'); | |
}; | |
this.abort = angular.noop; | |
} | |
/** | |
* @ngdoc function | |
* @name ngMock.$timeout | |
* @description | |
* | |
* This service is just a simple decorator for {@link ng.$timeout $timeout} service | |
* that adds a "flush" method. | |
*/ | |
/** | |
* @ngdoc method | |
* @name ngMock.$timeout#flush | |
* @methodOf ngMock.$timeout | |
* @description | |
* | |
* Flushes the queue of pending tasks. | |
*/ | |
/** | |
* | |
*/ | |
angular.mock.$RootElementProvider = function() { | |
this.$get = function() { | |
return angular.element('<div ng-app></div>'); | |
} | |
}; | |
/** | |
* @ngdoc overview | |
* @name ngMock | |
* @description | |
* | |
* The `ngMock` is an angular module which is used with `ng` module and adds unit-test configuration as well as useful | |
* mocks to the {@link AUTO.$injector $injector}. | |
*/ | |
angular.module('ngMock', ['ng']).provider({ | |
$browser: angular.mock.$BrowserProvider, | |
$exceptionHandler: angular.mock.$ExceptionHandlerProvider, | |
$log: angular.mock.$LogProvider, | |
$httpBackend: angular.mock.$HttpBackendProvider, | |
$rootElement: angular.mock.$RootElementProvider | |
}).config(function($provide) { | |
$provide.decorator('$timeout', function($delegate, $browser) { | |
$delegate.flush = function() { | |
$browser.defer.flush(); | |
}; | |
return $delegate; | |
}); | |
}); | |
/** | |
* @ngdoc overview | |
* @name ngMockE2E | |
* @description | |
* | |
* The `ngMockE2E` is an angular module which contains mocks suitable for end-to-end testing. | |
* Currently there is only one mock present in this module - | |
* the {@link ngMockE2E.$httpBackend e2e $httpBackend} mock. | |
*/ | |
angular.module('ngMockE2E', ['ng']).config(function($provide) { | |
$provide.decorator('$httpBackend', angular.mock.e2e.$httpBackendDecorator); | |
}); | |
/** | |
* @ngdoc object | |
* @name ngMockE2E.$httpBackend | |
* @description | |
* Fake HTTP backend implementation suitable for end-to-end testing or backend-less development of | |
* applications that use the {@link ng.$http $http service}. | |
* | |
* *Note*: For fake http backend implementation suitable for unit testing please see | |
* {@link ngMock.$httpBackend unit-testing $httpBackend mock}. | |
* | |
* This implementation can be used to respond with static or dynamic responses via the `when` api | |
* and its shortcuts (`whenGET`, `whenPOST`, etc) and optionally pass through requests to the | |
* real $httpBackend for specific requests (e.g. to interact with certain remote apis or to fetch | |
* templates from a webserver). | |
* | |
* As opposed to unit-testing, in an end-to-end testing scenario or in scenario when an application | |
* is being developed with the real backend api replaced with a mock, it is often desirable for | |
* certain category of requests to bypass the mock and issue a real http request (e.g. to fetch | |
* templates or static files from the webserver). To configure the backend with this behavior | |
* use the `passThrough` request handler of `when` instead of `respond`. | |
* | |
* Additionally, we don't want to manually have to flush mocked out requests like we do during unit | |
* testing. For this reason the e2e $httpBackend automatically flushes mocked out requests | |
* automatically, closely simulating the behavior of the XMLHttpRequest object. | |
* | |
* To setup the application to run with this http backend, you have to create a module that depends | |
* on the `ngMockE2E` and your application modules and defines the fake backend: | |
* | |
* <pre> | |
* myAppDev = angular.module('myAppDev', ['myApp', 'ngMockE2E']); | |
* myAppDev.run(function($httpBackend) { | |
* phones = [{name: 'phone1'}, {name: 'phone2'}]; | |
* | |
* // returns the current list of phones | |
* $httpBackend.whenGET('/phones').respond(phones); | |
* | |
* // adds a new phone to the phones array | |
* $httpBackend.whenPOST('/phones').respond(function(method, url, data) { | |
* phones.push(angular.fromJSON(data)); | |
* }); | |
* $httpBackend.whenGET(/^\/templates\//).passThrough(); | |
* //... | |
* }); | |
* </pre> | |
* | |
* Afterwards, bootstrap your app with this new module. | |
*/ | |
/** | |
* @ngdoc method | |
* @name ngMockE2E.$httpBackend#when | |
* @methodOf ngMockE2E.$httpBackend | |
* @description | |
* Creates a new backend definition. | |
* | |
* @param {string} method HTTP method. | |
* @param {string|RegExp} url HTTP url. | |
* @param {(string|RegExp)=} data HTTP request body. | |
* @param {(Object|function(Object))=} headers HTTP headers or function that receives http header | |
* object and returns true if the headers match the current definition. | |
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that | |
* control how a matched request is handled. | |
* | |
* - respond – `{function([status,] data[, headers])|function(function(method, url, data, headers)}` | |
* – The respond method takes a set of static data to be returned or a function that can return | |
* an array containing response status (number), response data (string) and response headers | |
* (Object). | |
* - passThrough – `{function()}` – Any request matching a backend definition with `passThrough` | |
* handler, will be pass through to the real backend (an XHR request will be made to the | |
* server. | |
*/ | |
/** | |
* @ngdoc method | |
* @name ngMockE2E.$httpBackend#whenGET | |
* @methodOf ngMockE2E.$httpBackend | |
* @description | |
* Creates a new backend definition for GET requests. For more info see `when()`. | |
* | |
* @param {string|RegExp} url HTTP url. | |
* @param {(Object|function(Object))=} headers HTTP headers. | |
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that | |
* control how a matched request is handled. | |
*/ | |
/** | |
* @ngdoc method | |
* @name ngMockE2E.$httpBackend#whenHEAD | |
* @methodOf ngMockE2E.$httpBackend | |
* @description | |
* Creates a new backend definition for HEAD requests. For more info see `when()`. | |
* | |
* @param {string|RegExp} url HTTP url. | |
* @param {(Object|function(Object))=} headers HTTP headers. | |
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that | |
* control how a matched request is handled. | |
*/ | |
/** | |
* @ngdoc method | |
* @name ngMockE2E.$httpBackend#whenDELETE | |
* @methodOf ngMockE2E.$httpBackend | |
* @description | |
* Creates a new backend definition for DELETE requests. For more info see `when()`. | |
* | |
* @param {string|RegExp} url HTTP url. | |
* @param {(Object|function(Object))=} headers HTTP headers. | |
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that | |
* control how a matched request is handled. | |
*/ | |
/** | |
* @ngdoc method | |
* @name ngMockE2E.$httpBackend#whenPOST | |
* @methodOf ngMockE2E.$httpBackend | |
* @description | |
* Creates a new backend definition for POST requests. For more info see `when()`. | |
* | |
* @param {string|RegExp} url HTTP url. | |
* @param {(string|RegExp)=} data HTTP request body. | |
* @param {(Object|function(Object))=} headers HTTP headers. | |
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that | |
* control how a matched request is handled. | |
*/ | |
/** | |
* @ngdoc method | |
* @name ngMockE2E.$httpBackend#whenPUT | |
* @methodOf ngMockE2E.$httpBackend | |
* @description | |
* Creates a new backend definition for PUT requests. For more info see `when()`. | |
* | |
* @param {string|RegExp} url HTTP url. | |
* @param {(string|RegExp)=} data HTTP request body. | |
* @param {(Object|function(Object))=} headers HTTP headers. | |
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that | |
* control how a matched request is handled. | |
*/ | |
/** | |
* @ngdoc method | |
* @name ngMockE2E.$httpBackend#whenPATCH | |
* @methodOf ngMockE2E.$httpBackend | |
* @description | |
* Creates a new backend definition for PATCH requests. For more info see `when()`. | |
* | |
* @param {string|RegExp} url HTTP url. | |
* @param {(string|RegExp)=} data HTTP request body. | |
* @param {(Object|function(Object))=} headers HTTP headers. | |
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that | |
* control how a matched request is handled. | |
*/ | |
/** | |
* @ngdoc method | |
* @name ngMockE2E.$httpBackend#whenJSONP | |
* @methodOf ngMockE2E.$httpBackend | |
* @description | |
* Creates a new backend definition for JSONP requests. For more info see `when()`. | |
* | |
* @param {string|RegExp} url HTTP url. | |
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that | |
* control how a matched request is handled. | |
*/ | |
angular.mock.e2e = {}; | |
angular.mock.e2e.$httpBackendDecorator = ['$delegate', '$browser', createHttpBackendMock]; | |
angular.mock.clearDataCache = function() { | |
var key, | |
cache = angular.element.cache; | |
for(key in cache) { | |
if (cache.hasOwnProperty(key)) { | |
var handle = cache[key].handle; | |
handle && angular.element(handle.elem).unbind(); | |
delete cache[key]; | |
} | |
} | |
}; | |
window.jstestdriver && (function(window) { | |
/** | |
* Global method to output any number of objects into JSTD console. Useful for debugging. | |
*/ | |
window.dump = function() { | |
var args = []; | |
angular.forEach(arguments, function(arg) { | |
args.push(angular.mock.dump(arg)); | |
}); | |
jstestdriver.console.log.apply(jstestdriver.console, args); | |
if (window.console) { | |
window.console.log.apply(window.console, args); | |
} | |
}; | |
})(window); | |
window.jasmine && (function(window) { | |
afterEach(function() { | |
var spec = getCurrentSpec(); | |
var injector = spec.$injector; | |
spec.$injector = null; | |
spec.$modules = null; | |
if (injector) { | |
injector.get('$rootElement').unbind(); | |
injector.get('$browser').pollFns.length = 0; | |
} | |
angular.mock.clearDataCache(); | |
// clean up jquery's fragment cache | |
angular.forEach(angular.element.fragments, function(val, key) { | |
delete angular.element.fragments[key]; | |
}); | |
MockXhr.$$lastInstance = null; | |
angular.forEach(angular.callbacks, function(val, key) { | |
delete angular.callbacks[key]; | |
}); | |
angular.callbacks.counter = 0; | |
}); | |
function getCurrentSpec() { | |
return jasmine.getEnv().currentSpec; | |
} | |
function isSpecRunning() { | |
var spec = getCurrentSpec(); | |
return spec && spec.queue.running; | |
} | |
/** | |
* @ngdoc function | |
* @name angular.mock.module | |
* @description | |
* | |
* *NOTE*: This function is also published on window for easy access.<br> | |
* *NOTE*: Only available with {@link http://pivotal.github.com/jasmine/ jasmine}. | |
* | |
* This function registers a module configuration code. It collects the configuration information | |
* which will be used when the injector is created by {@link angular.mock.inject inject}. | |
* | |
* See {@link angular.mock.inject inject} for usage example | |
* | |
* @param {...(string|Function)} fns any number of modules which are represented as string | |
* aliases or as anonymous module initialization functions. The modules are used to | |
* configure the injector. The 'ng' and 'ngMock' modules are automatically loaded. | |
*/ | |
window.module = angular.mock.module = function() { | |
var moduleFns = Array.prototype.slice.call(arguments, 0); | |
return isSpecRunning() ? workFn() : workFn; | |
///////////////////// | |
function workFn() { | |
var spec = getCurrentSpec(); | |
if (spec.$injector) { | |
throw Error('Injector already created, can not register a module!'); | |
} else { | |
var modules = spec.$modules || (spec.$modules = []); | |
angular.forEach(moduleFns, function(module) { | |
modules.push(module); | |
}); | |
} | |
} | |
}; | |
/** | |
* @ngdoc function | |
* @name angular.mock.inject | |
* @description | |
* | |
<<<<<<< HEAD | |
* *NOTE*: This is function is also published on window for easy access.<br> | |
* *NOTE*: Only available with {@link http://pivotal.github.com/jasmine/ jasmine}. | |
======= | |
* *NOTE*: This function is also published on window for easy access.<br> | |
>>>>>>> 8dca056... docs(mocks): fix typos | |
* | |
* The inject function wraps a function into an injectable function. The inject() creates new | |
* instance of {@link AUTO.$injector $injector} per test, which is then used for | |
* resolving references. | |
* | |
* See also {@link angular.mock.module module} | |
* | |
* Example of what a typical jasmine tests looks like with the inject method. | |
* <pre> | |
* | |
* angular.module('myApplicationModule', []) | |
* .value('mode', 'app') | |
* .value('version', 'v1.0.1'); | |
* | |
* | |
* describe('MyApp', function() { | |
* | |
* // You need to load modules that you want to test, | |
* // it loads only the "ng" module by default. | |
* beforeEach(module('myApplicationModule')); | |
* | |
* | |
* // inject() is used to inject arguments of all given functions | |
* it('should provide a version', inject(function(mode, version) { | |
* expect(version).toEqual('v1.0.1'); | |
* expect(mode).toEqual('app'); | |
* })); | |
* | |
* | |
* // The inject and module method can also be used inside of the it or beforeEach | |
* it('should override a version and test the new version is injected', function() { | |
* // module() takes functions or strings (module aliases) | |
* module(function($provide) { | |
* $provide.value('version', 'overridden'); // override version here | |
* }); | |
* | |
* inject(function(version) { | |
* expect(version).toEqual('overridden'); | |
* }); | |
* )); | |
* }); | |
* | |
* </pre> | |
* | |
* @param {...Function} fns any number of functions which will be injected using the injector. | |
*/ | |
window.inject = angular.mock.inject = function() { | |
var blockFns = Array.prototype.slice.call(arguments, 0); | |
var errorForStack = new Error('Declaration Location'); | |
return isSpecRunning() ? workFn() : workFn; | |
///////////////////// | |
function workFn() { | |
var spec = getCurrentSpec(); | |
var modules = spec.$modules || []; | |
modules.unshift('ngMock'); | |
modules.unshift('ng'); | |
var injector = spec.$injector; | |
if (!injector) { | |
injector = spec.$injector = angular.injector(modules); | |
} | |
for(var i = 0, ii = blockFns.length; i < ii; i++) { | |
try { | |
injector.invoke(blockFns[i] || angular.noop, this); | |
} catch (e) { | |
if(e.stack && errorForStack) e.stack += '\n' + errorForStack.stack; | |
throw e; | |
} finally { | |
errorForStack = null; | |
} | |
} | |
} | |
}; | |
})(window); |
This file contains hidden or 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
/* | |
AngularJS v1.1.5 | |
(c) 2010-2012 Google, Inc. http://angularjs.org | |
License: MIT | |
*/ | |
(function(M,T,p){'use strict';function lc(){var b=M.angular;M.angular=mc;return b}function Xa(b){return!b||typeof b.length!=="number"?!1:typeof b.hasOwnProperty!="function"&&typeof b.constructor!="function"?!0:b instanceof R||ga&&b instanceof ga||Ea.call(b)!=="[object Object]"||typeof b.callee==="function"}function n(b,a,c){var d;if(b)if(H(b))for(d in b)d!="prototype"&&d!="length"&&d!="name"&&b.hasOwnProperty(d)&&a.call(c,b[d],d);else if(b.forEach&&b.forEach!==n)b.forEach(a,c);else if(Xa(b))for(d= | |
0;d<b.length;d++)a.call(c,b[d],d);else for(d in b)b.hasOwnProperty(d)&&a.call(c,b[d],d);return b}function qb(b){var a=[],c;for(c in b)b.hasOwnProperty(c)&&a.push(c);return a.sort()}function nc(b,a,c){for(var d=qb(b),e=0;e<d.length;e++)a.call(c,b[d[e]],d[e]);return d}function rb(b){return function(a,c){b(c,a)}}function Fa(){for(var b=ba.length,a;b;){b--;a=ba[b].charCodeAt(0);if(a==57)return ba[b]="A",ba.join("");if(a==90)ba[b]="0";else return ba[b]=String.fromCharCode(a+1),ba.join("")}ba.unshift("0"); | |
return ba.join("")}function sb(b,a){a?b.$$hashKey=a:delete b.$$hashKey}function t(b){var a=b.$$hashKey;n(arguments,function(a){a!==b&&n(a,function(a,c){b[c]=a})});sb(b,a);return b}function N(b){return parseInt(b,10)}function tb(b,a){return t(new (t(function(){},{prototype:b})),a)}function q(){}function qa(b){return b}function S(b){return function(){return b}}function C(b){return typeof b=="undefined"}function B(b){return typeof b!="undefined"}function L(b){return b!=null&&typeof b=="object"}function E(b){return typeof b== | |
"string"}function Ya(b){return typeof b=="number"}function ra(b){return Ea.apply(b)=="[object Date]"}function F(b){return Ea.apply(b)=="[object Array]"}function H(b){return typeof b=="function"}function sa(b){return b&&b.document&&b.location&&b.alert&&b.setInterval}function U(b){return E(b)?b.replace(/^\s*/,"").replace(/\s*$/,""):b}function oc(b){return b&&(b.nodeName||b.bind&&b.find)}function Za(b,a,c){var d=[];n(b,function(b,g,i){d.push(a.call(c,b,g,i))});return d}function Ga(b,a){if(b.indexOf)return b.indexOf(a); | |
for(var c=0;c<b.length;c++)if(a===b[c])return c;return-1}function ta(b,a){var c=Ga(b,a);c>=0&&b.splice(c,1);return a}function V(b,a){if(sa(b)||b&&b.$evalAsync&&b.$watch)throw Error("Can't copy Window or Scope");if(a){if(b===a)throw Error("Can't copy equivalent objects or arrays");if(F(b))for(var c=a.length=0;c<b.length;c++)a.push(V(b[c]));else{c=a.$$hashKey;n(a,function(b,c){delete a[c]});for(var d in b)a[d]=V(b[d]);sb(a,c)}}else(a=b)&&(F(b)?a=V(b,[]):ra(b)?a=new Date(b.getTime()):L(b)&&(a=V(b,{}))); | |
return a}function pc(b,a){var a=a||{},c;for(c in b)b.hasOwnProperty(c)&&c.substr(0,2)!=="$$"&&(a[c]=b[c]);return a}function ia(b,a){if(b===a)return!0;if(b===null||a===null)return!1;if(b!==b&&a!==a)return!0;var c=typeof b,d;if(c==typeof a&&c=="object")if(F(b)){if((c=b.length)==a.length){for(d=0;d<c;d++)if(!ia(b[d],a[d]))return!1;return!0}}else if(ra(b))return ra(a)&&b.getTime()==a.getTime();else{if(b&&b.$evalAsync&&b.$watch||a&&a.$evalAsync&&a.$watch||sa(b)||sa(a))return!1;c={};for(d in b)if(!(d.charAt(0)=== | |
"$"||H(b[d]))){if(!ia(b[d],a[d]))return!1;c[d]=!0}for(d in a)if(!c[d]&&d.charAt(0)!=="$"&&a[d]!==p&&!H(a[d]))return!1;return!0}return!1}function $a(b,a){var c=arguments.length>2?ka.call(arguments,2):[];return H(a)&&!(a instanceof RegExp)?c.length?function(){return arguments.length?a.apply(b,c.concat(ka.call(arguments,0))):a.apply(b,c)}:function(){return arguments.length?a.apply(b,arguments):a.call(b)}:a}function qc(b,a){var c=a;/^\$+/.test(b)?c=p:sa(a)?c="$WINDOW":a&&T===a?c="$DOCUMENT":a&&a.$evalAsync&& | |
a.$watch&&(c="$SCOPE");return c}function ha(b,a){return JSON.stringify(b,qc,a?" ":null)}function ub(b){return E(b)?JSON.parse(b):b}function ua(b){b&&b.length!==0?(b=I(""+b),b=!(b=="f"||b=="0"||b=="false"||b=="no"||b=="n"||b=="[]")):b=!1;return b}function va(b){b=w(b).clone();try{b.html("")}catch(a){}var c=w("<div>").append(b).html();try{return b[0].nodeType===3?I(c):c.match(/^(<[^>]+>)/)[1].replace(/^<([\w\-]+)/,function(a,b){return"<"+I(b)})}catch(d){return I(c)}}function vb(b){var a={},c,d;n((b|| | |
"").split("&"),function(b){b&&(c=b.split("="),d=decodeURIComponent(c[0]),a[d]=B(c[1])?decodeURIComponent(c[1]):!0)});return a}function wb(b){var a=[];n(b,function(b,d){a.push(wa(d,!0)+(b===!0?"":"="+wa(b,!0)))});return a.length?a.join("&"):""}function ab(b){return wa(b,!0).replace(/%26/gi,"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+")}function wa(b,a){return encodeURIComponent(b).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,a?"%20":"+")}function rc(b, | |
a){function c(a){a&&d.push(a)}var d=[b],e,g,i=["ng:app","ng-app","x-ng-app","data-ng-app"],f=/\sng[:\-]app(:\s*([\w\d_]+);?)?\s/;n(i,function(a){i[a]=!0;c(T.getElementById(a));a=a.replace(":","\\:");b.querySelectorAll&&(n(b.querySelectorAll("."+a),c),n(b.querySelectorAll("."+a+"\\:"),c),n(b.querySelectorAll("["+a+"]"),c))});n(d,function(a){if(!e){var b=f.exec(" "+a.className+" ");b?(e=a,g=(b[2]||"").replace(/\s+/g,",")):n(a.attributes,function(b){if(!e&&i[b.name])e=a,g=b.value})}});e&&a(e,g?[g]:[])} | |
function xb(b,a){var c=function(){b=w(b);a=a||[];a.unshift(["$provide",function(a){a.value("$rootElement",b)}]);a.unshift("ng");var c=yb(a);c.invoke(["$rootScope","$rootElement","$compile","$injector","$animator",function(a,b,c,d,e){a.$apply(function(){b.data("$injector",d);c(b)(a)});e.enabled(!0)}]);return c},d=/^NG_DEFER_BOOTSTRAP!/;if(M&&!d.test(M.name))return c();M.name=M.name.replace(d,"");Ha.resumeBootstrap=function(b){n(b,function(b){a.push(b)});c()}}function bb(b,a){a=a||"_";return b.replace(sc, | |
function(b,d){return(d?a:"")+b.toLowerCase()})}function cb(b,a,c){if(!b)throw Error("Argument '"+(a||"?")+"' is "+(c||"required"));return b}function xa(b,a,c){c&&F(b)&&(b=b[b.length-1]);cb(H(b),a,"not a function, got "+(b&&typeof b=="object"?b.constructor.name||"Object":typeof b));return b}function tc(b){function a(a,b,e){return a[b]||(a[b]=e())}return a(a(b,"angular",Object),"module",function(){var b={};return function(d,e,g){e&&b.hasOwnProperty(d)&&(b[d]=null);return a(b,d,function(){function a(c, | |
d,e){return function(){b[e||"push"]([c,d,arguments]);return m}}if(!e)throw Error("No module: "+d);var b=[],c=[],j=a("$injector","invoke"),m={_invokeQueue:b,_runBlocks:c,requires:e,name:d,provider:a("$provide","provider"),factory:a("$provide","factory"),service:a("$provide","service"),value:a("$provide","value"),constant:a("$provide","constant","unshift"),animation:a("$animationProvider","register"),filter:a("$filterProvider","register"),controller:a("$controllerProvider","register"),directive:a("$compileProvider", | |
"directive"),config:j,run:function(a){c.push(a);return this}};g&&j(g);return m})}})}function Ia(b){return b.replace(uc,function(a,b,d,e){return e?d.toUpperCase():d}).replace(vc,"Moz$1")}function db(b,a){function c(){var e;for(var b=[this],c=a,i,f,h,j,m,k;b.length;){i=b.shift();f=0;for(h=i.length;f<h;f++){j=w(i[f]);c?j.triggerHandler("$destroy"):c=!c;m=0;for(e=(k=j.children()).length,j=e;m<j;m++)b.push(ga(k[m]))}}return d.apply(this,arguments)}var d=ga.fn[b],d=d.$original||d;c.$original=d;ga.fn[b]= | |
c}function R(b){if(b instanceof R)return b;if(!(this instanceof R)){if(E(b)&&b.charAt(0)!="<")throw Error("selectors not implemented");return new R(b)}if(E(b)){var a=T.createElement("div");a.innerHTML="<div> </div>"+b;a.removeChild(a.firstChild);eb(this,a.childNodes);this.remove()}else eb(this,b)}function fb(b){return b.cloneNode(!0)}function ya(b){zb(b);for(var a=0,b=b.childNodes||[];a<b.length;a++)ya(b[a])}function Ab(b,a,c){var d=ca(b,"events");ca(b,"handle")&&(C(a)?n(d,function(a,c){gb(b, | |
c,a);delete d[c]}):C(c)?(gb(b,a,d[a]),delete d[a]):ta(d[a],c))}function zb(b){var a=b[Ja],c=Ka[a];c&&(c.handle&&(c.events.$destroy&&c.handle({},"$destroy"),Ab(b)),delete Ka[a],b[Ja]=p)}function ca(b,a,c){var d=b[Ja],d=Ka[d||-1];if(B(c))d||(b[Ja]=d=++wc,d=Ka[d]={}),d[a]=c;else return d&&d[a]}function Bb(b,a,c){var d=ca(b,"data"),e=B(c),g=!e&&B(a),i=g&&!L(a);!d&&!i&&ca(b,"data",d={});if(e)d[a]=c;else if(g)if(i)return d&&d[a];else t(d,a);else return d}function La(b,a){return(" "+b.className+" ").replace(/[\n\t]/g, | |
" ").indexOf(" "+a+" ")>-1}function Cb(b,a){a&&n(a.split(" "),function(a){b.className=U((" "+b.className+" ").replace(/[\n\t]/g," ").replace(" "+U(a)+" "," "))})}function Db(b,a){a&&n(a.split(" "),function(a){if(!La(b,a))b.className=U(b.className+" "+U(a))})}function eb(b,a){if(a)for(var a=!a.nodeName&&B(a.length)&&!sa(a)?a:[a],c=0;c<a.length;c++)b.push(a[c])}function Eb(b,a){return Ma(b,"$"+(a||"ngController")+"Controller")}function Ma(b,a,c){b=w(b);for(b[0].nodeType==9&&(b=b.find("html"));b.length;){if(c= | |
b.data(a))return c;b=b.parent()}}function Fb(b,a){var c=Na[a.toLowerCase()];return c&&Gb[b.nodeName]&&c}function xc(b,a){var c=function(c,e){if(!c.preventDefault)c.preventDefault=function(){c.returnValue=!1};if(!c.stopPropagation)c.stopPropagation=function(){c.cancelBubble=!0};if(!c.target)c.target=c.srcElement||T;if(C(c.defaultPrevented)){var g=c.preventDefault;c.preventDefault=function(){c.defaultPrevented=!0;g.call(c)};c.defaultPrevented=!1}c.isDefaultPrevented=function(){return c.defaultPrevented|| | |
c.returnValue==!1};n(a[e||c.type],function(a){a.call(b,c)});Z<=8?(c.preventDefault=null,c.stopPropagation=null,c.isDefaultPrevented=null):(delete c.preventDefault,delete c.stopPropagation,delete c.isDefaultPrevented)};c.elem=b;return c}function la(b){var a=typeof b,c;if(a=="object"&&b!==null)if(typeof(c=b.$$hashKey)=="function")c=b.$$hashKey();else{if(c===p)c=b.$$hashKey=Fa()}else c=b;return a+":"+c}function za(b){n(b,this.put,this)}function Hb(b){var a,c;if(typeof b=="function"){if(!(a=b.$inject))a= | |
[],c=b.toString().replace(yc,""),c=c.match(zc),n(c[1].split(Ac),function(b){b.replace(Bc,function(b,c,d){a.push(d)})}),b.$inject=a}else F(b)?(c=b.length-1,xa(b[c],"fn"),a=b.slice(0,c)):xa(b,"fn",!0);return a}function yb(b){function a(a){return function(b,c){if(L(b))n(b,rb(a));else return a(b,c)}}function c(a,b){if(H(b)||F(b))b=k.instantiate(b);if(!b.$get)throw Error("Provider "+a+" must define $get factory method.");return m[a+f]=b}function d(a,b){return c(a,{$get:b})}function e(a){var b=[];n(a,function(a){if(!j.get(a))if(j.put(a, | |
!0),E(a)){var c=Aa(a);b=b.concat(e(c.requires)).concat(c._runBlocks);try{for(var d=c._invokeQueue,c=0,f=d.length;c<f;c++){var g=d[c],o=k.get(g[0]);o[g[1]].apply(o,g[2])}}catch(h){throw h.message&&(h.message+=" from "+a),h;}}else if(H(a))try{b.push(k.invoke(a))}catch(l){throw l.message&&(l.message+=" from "+a),l;}else if(F(a))try{b.push(k.invoke(a))}catch(i){throw i.message&&(i.message+=" from "+String(a[a.length-1])),i;}else xa(a,"module")});return b}function g(a,b){function c(d){if(typeof d!=="string")throw Error("Service name expected"); | |
if(a.hasOwnProperty(d)){if(a[d]===i)throw Error("Circular dependency: "+h.join(" <- "));return a[d]}else try{return h.unshift(d),a[d]=i,a[d]=b(d)}finally{h.shift()}}function d(a,b,e){var f=[],j=Hb(a),g,o,h;o=0;for(g=j.length;o<g;o++)h=j[o],f.push(e&&e.hasOwnProperty(h)?e[h]:c(h));a.$inject||(a=a[g]);switch(b?-1:f.length){case 0:return a();case 1:return a(f[0]);case 2:return a(f[0],f[1]);case 3:return a(f[0],f[1],f[2]);case 4:return a(f[0],f[1],f[2],f[3]);case 5:return a(f[0],f[1],f[2],f[3],f[4]); | |
case 6:return a(f[0],f[1],f[2],f[3],f[4],f[5]);case 7:return a(f[0],f[1],f[2],f[3],f[4],f[5],f[6]);case 8:return a(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7]);case 9:return a(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],f[8]);case 10:return a(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],f[8],f[9]);default:return a.apply(b,f)}}return{invoke:d,instantiate:function(a,b){var c=function(){},e;c.prototype=(F(a)?a[a.length-1]:a).prototype;c=new c;e=d(a,c,b);return L(e)?e:c},get:c,annotate:Hb,has:function(b){return m.hasOwnProperty(b+ | |
f)||a.hasOwnProperty(b)}}}var i={},f="Provider",h=[],j=new za,m={$provide:{provider:a(c),factory:a(d),service:a(function(a,b){return d(a,["$injector",function(a){return a.instantiate(b)}])}),value:a(function(a,b){return d(a,S(b))}),constant:a(function(a,b){m[a]=b;l[a]=b}),decorator:function(a,b){var c=k.get(a+f),d=c.$get;c.$get=function(){var a=u.invoke(d,c);return u.invoke(b,null,{$delegate:a})}}}},k=m.$injector=g(m,function(){throw Error("Unknown provider: "+h.join(" <- "));}),l={},u=l.$injector= | |
g(l,function(a){a=k.get(a+f);return u.invoke(a.$get,a)});n(e(b),function(a){u.invoke(a||q)});return u}function Cc(){var b=!0;this.disableAutoScrolling=function(){b=!1};this.$get=["$window","$location","$rootScope",function(a,c,d){function e(a){var b=null;n(a,function(a){!b&&I(a.nodeName)==="a"&&(b=a)});return b}function g(){var b=c.hash(),d;b?(d=i.getElementById(b))?d.scrollIntoView():(d=e(i.getElementsByName(b)))?d.scrollIntoView():b==="top"&&a.scrollTo(0,0):a.scrollTo(0,0)}var i=a.document;b&&d.$watch(function(){return c.hash()}, | |
function(){d.$evalAsync(g)});return g}]}function Ib(b){this.register=function(a,c){b.factory(Ia(a)+"Animation",c)};this.$get=["$injector",function(a){return function(b){if(b&&(b=Ia(b)+"Animation",a.has(b)))return a.get(b)}}]}function Dc(b,a,c,d){function e(a){try{a.apply(null,ka.call(arguments,1))}finally{if(o--,o===0)for(;z.length;)try{z.pop()()}catch(b){c.error(b)}}}function g(a,b){(function s(){n(r,function(a){a()});y=b(s,a)})()}function i(){x!=f.url()&&(x=f.url(),n(v,function(a){a(f.url())}))} | |
var f=this,h=a[0],j=b.location,m=b.history,k=b.setTimeout,l=b.clearTimeout,u={};f.isMock=!1;var o=0,z=[];f.$$completeOutstandingRequest=e;f.$$incOutstandingRequestCount=function(){o++};f.notifyWhenNoOutstandingRequests=function(a){n(r,function(a){a()});o===0?a():z.push(a)};var r=[],y;f.addPollFn=function(a){C(y)&&g(100,k);r.push(a);return a};var x=j.href,W=a.find("base");f.url=function(a,b){if(a){if(x!=a)return x=a,d.history?b?m.replaceState(null,"",a):(m.pushState(null,"",a),W.attr("href",W.attr("href"))): | |
b?j.replace(a):j.href=a,f}else return j.href.replace(/%27/g,"'")};var v=[],A=!1;f.onUrlChange=function(a){A||(d.history&&w(b).bind("popstate",i),d.hashchange?w(b).bind("hashchange",i):f.addPollFn(i),A=!0);v.push(a);return a};f.baseHref=function(){var a=W.attr("href");return a?a.replace(/^https?\:\/\/[^\/]*/,""):""};var G={},D="",$=f.baseHref();f.cookies=function(a,b){var d,e,f,j;if(a)if(b===p)h.cookie=escape(a)+"=;path="+$+";expires=Thu, 01 Jan 1970 00:00:00 GMT";else{if(E(b))d=(h.cookie=escape(a)+ | |
"="+escape(b)+";path="+$).length+1,d>4096&&c.warn("Cookie '"+a+"' possibly not set or overflowed because it was too large ("+d+" > 4096 bytes)!")}else{if(h.cookie!==D){D=h.cookie;d=D.split("; ");G={};for(f=0;f<d.length;f++)e=d[f],j=e.indexOf("="),j>0&&(a=unescape(e.substring(0,j)),G[a]===p&&(G[a]=unescape(e.substring(j+1))))}return G}};f.defer=function(a,b){var c;o++;c=k(function(){delete u[c];e(a)},b||0);u[c]=!0;return c};f.defer.cancel=function(a){return u[a]?(delete u[a],l(a),e(q),!0):!1}}function Ec(){this.$get= | |
["$window","$log","$sniffer","$document",function(b,a,c,d){return new Dc(b,d,a,c)}]}function Fc(){this.$get=function(){function b(b,d){function e(a){if(a!=k){if(l){if(l==a)l=a.n}else l=a;g(a.n,a.p);g(a,k);k=a;k.n=null}}function g(a,b){if(a!=b){if(a)a.p=b;if(b)b.n=a}}if(b in a)throw Error("cacheId "+b+" taken");var i=0,f=t({},d,{id:b}),h={},j=d&&d.capacity||Number.MAX_VALUE,m={},k=null,l=null;return a[b]={put:function(a,b){var c=m[a]||(m[a]={key:a});e(c);if(!C(b))return a in h||i++,h[a]=b,i>j&&this.remove(l.key), | |
b},get:function(a){var b=m[a];if(b)return e(b),h[a]},remove:function(a){var b=m[a];if(b){if(b==k)k=b.p;if(b==l)l=b.n;g(b.n,b.p);delete m[a];delete h[a];i--}},removeAll:function(){h={};i=0;m={};k=l=null},destroy:function(){m=f=h=null;delete a[b]},info:function(){return t({},f,{size:i})}}}var a={};b.info=function(){var b={};n(a,function(a,e){b[e]=a.info()});return b};b.get=function(b){return a[b]};return b}}function Gc(){this.$get=["$cacheFactory",function(b){return b("templates")}]}function Jb(b){var a= | |
{},c="Directive",d=/^\s*directive\:\s*([\d\w\-_]+)\s+(.*)$/,e=/(([\d\w\-_]+)(?:\:([^;]+))?;?)/,g="Template must have exactly one root element. was: ",i=/^\s*(https?|ftp|mailto|file):/;this.directive=function h(d,e){E(d)?(cb(e,"directive"),a.hasOwnProperty(d)||(a[d]=[],b.factory(d+c,["$injector","$exceptionHandler",function(b,c){var e=[];n(a[d],function(a){try{var g=b.invoke(a);if(H(g))g={compile:S(g)};else if(!g.compile&&g.link)g.compile=S(g.link);g.priority=g.priority||0;g.name=g.name||d;g.require= | |
g.require||g.controller&&g.name;g.restrict=g.restrict||"A";e.push(g)}catch(h){c(h)}});return e}])),a[d].push(e)):n(d,rb(h));return this};this.urlSanitizationWhitelist=function(a){return B(a)?(i=a,this):i};this.$get=["$injector","$interpolate","$exceptionHandler","$http","$templateCache","$parse","$controller","$rootScope","$document",function(b,j,m,k,l,u,o,z,r){function y(a,b,c){a instanceof w||(a=w(a));n(a,function(b,c){b.nodeType==3&&b.nodeValue.match(/\S+/)&&(a[c]=w(b).wrap("<span></span>").parent()[0])}); | |
var d=W(a,b,a,c);return function(b,c){cb(b,"scope");for(var e=c?Ba.clone.call(a):a,j=0,g=e.length;j<g;j++){var h=e[j];(h.nodeType==1||h.nodeType==9)&&e.eq(j).data("$scope",b)}x(e,"ng-scope");c&&c(e,b);d&&d(b,e,e);return e}}function x(a,b){try{a.addClass(b)}catch(c){}}function W(a,b,c,d){function e(a,c,d,g){var h,i,k,l,o,m,u,z=[];o=0;for(m=c.length;o<m;o++)z.push(c[o]);u=o=0;for(m=j.length;o<m;u++)i=z[u],c=j[o++],h=j[o++],c?(c.scope?(k=a.$new(L(c.scope)),w(i).data("$scope",k)):k=a,(l=c.transclude)|| | |
!g&&b?c(h,k,i,d,function(b){return function(c){var d=a.$new();d.$$transcluded=!0;return b(d,c).bind("$destroy",$a(d,d.$destroy))}}(l||b)):c(h,k,i,p,g)):h&&h(a,i.childNodes,p,g)}for(var j=[],g,h,k,i=0;i<a.length;i++)h=new ma,g=v(a[i],[],h,d),h=(g=g.length?A(g,a[i],h,b,c):null)&&g.terminal||!a[i].childNodes||!a[i].childNodes.length?null:W(a[i].childNodes,g?g.transclude:b),j.push(g),j.push(h),k=k||g||h;return k?e:null}function v(a,b,c,j){var g=c.$attr,h;switch(a.nodeType){case 1:G(b,da(hb(a).toLowerCase()), | |
"E",j);var i,k,l;h=a.attributes;for(var o=0,m=h&&h.length;o<m;o++)if(i=h[o],i.specified)k=i.name,l=da(k),Y.test(l)&&(k=l.substr(6).toLowerCase()),l=da(k.toLowerCase()),g[l]=k,c[l]=i=U(Z&&k=="href"?decodeURIComponent(a.getAttribute(k,2)):i.value),Fb(a,l)&&(c[l]=!0),s(a,b,i,l),G(b,l,"A",j);a=a.className;if(E(a)&&a!=="")for(;h=e.exec(a);)l=da(h[2]),G(b,l,"C",j)&&(c[l]=U(h[3])),a=a.substr(h.index+h[0].length);break;case 3:P(b,a.nodeValue);break;case 8:try{if(h=d.exec(a.nodeValue))l=da(h[1]),G(b,l,"M", | |
j)&&(c[l]=U(h[2]))}catch(u){}}b.sort(K);return b}function A(a,b,c,d,e){function h(a,b){if(a)a.require=s.require,z.push(a);if(b)b.require=s.require,ea.push(b)}function i(a,b){var c,d="data",e=!1;if(E(a)){for(;(c=a.charAt(0))=="^"||c=="?";)a=a.substr(1),c=="^"&&(d="inheritedData"),e=e||c=="?";c=b[d]("$"+a+"Controller");if(!c&&!e)throw Error("No controller: "+a);}else F(a)&&(c=[],n(a,function(a){c.push(i(a,b))}));return c}function k(a,d,e,g,h){var l,v,r,D,x;l=b===e?c:pc(c,new ma(w(e),c.$attr));v=l.$$element; | |
if(K){var y=/^\s*([@=&])(\??)\s*(\w*)\s*$/,s=d.$parent||d;n(K.scope,function(a,b){var c=a.match(y)||[],e=c[3]||b,g=c[2]=="?",c=c[1],h,k,i;d.$$isolateBindings[b]=c+e;switch(c){case "@":l.$observe(e,function(a){d[b]=a});l.$$observers[e].$$scope=s;l[e]&&(d[b]=j(l[e])(s));break;case "=":if(g&&!l[e])break;k=u(l[e]);i=k.assign||function(){h=d[b]=k(s);throw Error(Kb+l[e]+" (directive: "+K.name+")");};h=d[b]=k(s);d.$watch(function(){var a=k(s);a!==d[b]&&(a!==h?h=d[b]=a:i(s,a=h=d[b]));return a});break;case "&":k= | |
u(l[e]);d[b]=function(a){return k(s,a)};break;default:throw Error("Invalid isolate scope definition for directive "+K.name+": "+a);}})}q&&n(q,function(a){var b={$scope:d,$element:v,$attrs:l,$transclude:h};x=a.controller;x=="@"&&(x=l[a.name]);v.data("$"+a.name+"Controller",o(x,b))});g=0;for(r=z.length;g<r;g++)try{D=z[g],D(d,v,l,D.require&&i(D.require,v))}catch(Hc){m(Hc,va(v))}a&&a(d,e.childNodes,p,h);g=0;for(r=ea.length;g<r;g++)try{D=ea[g],D(d,v,l,D.require&&i(D.require,v))}catch(J){m(J,va(v))}}for(var l= | |
-Number.MAX_VALUE,z=[],ea=[],r=null,K=null,W=null,J=c.$$element=w(b),s,A,Y,G,P=d,q,na,t,B=0,C=a.length;B<C;B++){s=a[B];Y=p;if(l>s.priority)break;if(t=s.scope)O("isolated scope",K,s,J),L(t)&&(x(J,"ng-isolate-scope"),K=s),x(J,"ng-scope"),r=r||s;A=s.name;if(t=s.controller)q=q||{},O("'"+A+"' controller",q[A],s,J),q[A]=s;if(t=s.transclude)O("transclusion",G,s,J),G=s,l=s.priority,t=="element"?(Y=w(b),J=c.$$element=w(T.createComment(" "+A+": "+c[A]+" ")),b=J[0],ja(e,w(Y[0]),b),P=y(Y,d,l)):(Y=w(fb(b)).contents(), | |
J.html(""),P=y(Y,d));if(s.template)if(O("template",W,s,J),W=s,t=H(s.template)?s.template(J,c):s.template,t=Lb(t),s.replace){Y=w("<div>"+U(t)+"</div>").contents();b=Y[0];if(Y.length!=1||b.nodeType!==1)throw Error(g+t);ja(e,J,b);A={$attr:{}};a=a.concat(v(b,a.splice(B+1,a.length-(B+1)),A));D(c,A);C=a.length}else J.html(t);if(s.templateUrl)O("template",W,s,J),W=s,k=$(a.splice(B,a.length-B),k,J,c,e,s.replace,P),C=a.length;else if(s.compile)try{na=s.compile(J,c,P),H(na)?h(null,na):na&&h(na.pre,na.post)}catch(I){m(I, | |
va(J))}if(s.terminal)k.terminal=!0,l=Math.max(l,s.priority)}k.scope=r&&r.scope;k.transclude=G&&P;return k}function G(d,e,j,g){var l=!1;if(a.hasOwnProperty(e))for(var k,e=b.get(e+c),i=0,o=e.length;i<o;i++)try{if(k=e[i],(g===p||g>k.priority)&&k.restrict.indexOf(j)!=-1)d.push(k),l=!0}catch(u){m(u)}return l}function D(a,b){var c=b.$attr,d=a.$attr,e=a.$$element;n(a,function(d,e){e.charAt(0)!="$"&&(b[e]&&(d+=(e==="style"?";":" ")+b[e]),a.$set(e,d,!0,c[e]))});n(b,function(b,j){j=="class"?(x(e,b),a["class"]= | |
(a["class"]?a["class"]+" ":"")+b):j=="style"?e.attr("style",e.attr("style")+";"+b):j.charAt(0)!="$"&&!a.hasOwnProperty(j)&&(a[j]=b,d[j]=c[j])})}function $(a,b,c,d,e,j,h){var i=[],o,m,u=c[0],z=a.shift(),r=t({},z,{controller:null,templateUrl:null,transclude:null,scope:null}),z=H(z.templateUrl)?z.templateUrl(c,d):z.templateUrl;c.html("");k.get(z,{cache:l}).success(function(l){var k,z,l=Lb(l);if(j){z=w("<div>"+U(l)+"</div>").contents();k=z[0];if(z.length!=1||k.nodeType!==1)throw Error(g+l);l={$attr:{}}; | |
ja(e,c,k);v(k,a,l);D(d,l)}else k=u,c.html(l);a.unshift(r);o=A(a,k,d,h);for(m=W(c[0].childNodes,h);i.length;){var ea=i.shift(),l=i.shift();z=i.shift();var x=i.shift(),y=k;l!==u&&(y=fb(k),ja(z,w(l),y));o(function(){b(m,ea,y,e,x)},ea,y,e,x)}i=null}).error(function(a,b,c,d){throw Error("Failed to load template: "+d.url);});return function(a,c,d,e,j){i?(i.push(c),i.push(d),i.push(e),i.push(j)):o(function(){b(m,c,d,e,j)},c,d,e,j)}}function K(a,b){return b.priority-a.priority}function O(a,b,c,d){if(b)throw Error("Multiple directives ["+ | |
b.name+", "+c.name+"] asking for "+a+" on: "+va(d));}function P(a,b){var c=j(b,!0);c&&a.push({priority:0,compile:S(function(a,b){var d=b.parent(),e=d.data("$binding")||[];e.push(c);x(d.data("$binding",e),"ng-binding");a.$watch(c,function(a){b[0].nodeValue=a})})})}function s(a,b,c,d){var e=j(c,!0);e&&b.push({priority:100,compile:S(function(a,b,c){b=c.$$observers||(c.$$observers={});if(e=j(c[d],!0))c[d]=e(a),(b[d]||(b[d]=[])).$$inter=!0,(c.$$observers&&c.$$observers[d].$$scope||a).$watch(e,function(a){c.$set(d, | |
a)})})})}function ja(a,b,c){var d=b[0],e=d.parentNode,j,g;if(a){j=0;for(g=a.length;j<g;j++)if(a[j]==d){a[j]=c;break}}e&&e.replaceChild(c,d);c[w.expando]=d[w.expando];b[0]=c}var ma=function(a,b){this.$$element=a;this.$attr=b||{}};ma.prototype={$normalize:da,$set:function(a,b,c,d){var e=Fb(this.$$element[0],a),j=this.$$observers;e&&(this.$$element.prop(a,b),d=e);this[a]=b;d?this.$attr[a]=d:(d=this.$attr[a])||(this.$attr[a]=d=bb(a,"-"));if(hb(this.$$element[0])==="A"&&a==="href")q.setAttribute("href", | |
b),e=q.href,e.match(i)||(this[a]=b="unsafe:"+e);c!==!1&&(b===null||b===p?this.$$element.removeAttr(d):this.$$element.attr(d,b));j&&n(j[a],function(a){try{a(b)}catch(c){m(c)}})},$observe:function(a,b){var c=this,d=c.$$observers||(c.$$observers={}),e=d[a]||(d[a]=[]);e.push(b);z.$evalAsync(function(){e.$$inter||b(c[a])});return b}};var q=r[0].createElement("a"),ea=j.startSymbol(),J=j.endSymbol(),Lb=ea=="{{"||J=="}}"?qa:function(a){return a.replace(/\{\{/g,ea).replace(/}}/g,J)},Y=/^ngAttr[A-Z]/;return y}]} | |
function da(b){return Ia(b.replace(Ic,""))}function Jc(){var b={},a=/^(\S+)(\s+as\s+(\w+))?$/;this.register=function(a,d){L(a)?t(b,a):b[a]=d};this.$get=["$injector","$window",function(c,d){return function(e,g){var i,f;E(e)&&(f=e.match(a),i=f[1],f=f[3],e=b.hasOwnProperty(i)?b[i]:ib(g.$scope,i,!0)||ib(d,i,!0),xa(e,i,!0));i=c.instantiate(e,g);if(f){if(typeof g.$scope!=="object")throw Error('Can not export controller as "'+f+'". No scope object provided!');g.$scope[f]=i}return i}}]}function Kc(){this.$get= | |
["$window",function(b){return w(b.document)}]}function Lc(){this.$get=["$log",function(b){return function(a,c){b.error.apply(b,arguments)}}]}function Mc(){var b="{{",a="}}";this.startSymbol=function(a){return a?(b=a,this):b};this.endSymbol=function(b){return b?(a=b,this):a};this.$get=["$parse","$exceptionHandler",function(c,d){function e(e,h){for(var j,m,k=0,l=[],u=e.length,o=!1,z=[];k<u;)(j=e.indexOf(b,k))!=-1&&(m=e.indexOf(a,j+g))!=-1?(k!=j&&l.push(e.substring(k,j)),l.push(k=c(o=e.substring(j+g, | |
m))),k.exp=o,k=m+i,o=!0):(k!=u&&l.push(e.substring(k)),k=u);if(!(u=l.length))l.push(""),u=1;if(!h||o)return z.length=u,k=function(a){try{for(var b=0,c=u,j;b<c;b++){if(typeof(j=l[b])=="function")j=j(a),j==null||j==p?j="":typeof j!="string"&&(j=ha(j));z[b]=j}return z.join("")}catch(g){d(Error("Error while interpolating: "+e+"\n"+g.toString()))}},k.exp=e,k.parts=l,k}var g=b.length,i=a.length;e.startSymbol=function(){return b};e.endSymbol=function(){return a};return e}]}function Mb(b){for(var b=b.split("/"), | |
a=b.length;a--;)b[a]=ab(b[a]);return b.join("/")}function Nb(b,a){var c=jb.exec(b);a.$$protocol=c[1];a.$$host=c[3];a.$$port=N(c[5])||Oa[c[1]]||null}function Ob(b,a){var c=Pb.exec(b);a.$$path=decodeURIComponent(c[1]);a.$$search=vb(c[3]);a.$$hash=decodeURIComponent(c[5]||"");if(a.$$path&&a.$$path.charAt(0)!="/")a.$$path="/"+a.$$path}function fa(b,a,c){return a.indexOf(b)==0?a.substr(b.length):c}function Ca(b){var a=b.indexOf("#");return a==-1?b:b.substr(0,a)}function kb(b){return b.substr(0,Ca(b).lastIndexOf("/")+ | |
1)}function Qb(b,a){var a=a||"",c=kb(b);this.$$parse=function(a){var b={};Nb(a,b);var g=fa(c,a);if(!E(g))throw Error('Invalid url "'+a+'", missing path prefix "'+c+'".');Ob(g,b);t(this,b);if(!this.$$path)this.$$path="/";this.$$compose()};this.$$compose=function(){var a=wb(this.$$search),b=this.$$hash?"#"+ab(this.$$hash):"";this.$$url=Mb(this.$$path)+(a?"?"+a:"")+b;this.$$absUrl=c+this.$$url.substr(1)};this.$$rewrite=function(d){var e;if((e=fa(b,d))!==p)return d=e,(e=fa(a,e))!==p?c+(fa("/",e)||e): | |
b+d;else if((e=fa(c,d))!==p)return c+e;else if(c==d+"/")return c}}function lb(b,a){var c=kb(b);this.$$parse=function(d){Nb(d,this);var e=fa(b,d)||fa(c,d);if(!E(e))throw Error('Invalid url "'+d+'", does not start with "'+b+'".');e=e.charAt(0)=="#"?fa(a,e):e;if(!E(e))throw Error('Invalid url "'+d+'", missing hash prefix "'+a+'".');Ob(e,this);this.$$compose()};this.$$compose=function(){var c=wb(this.$$search),e=this.$$hash?"#"+ab(this.$$hash):"";this.$$url=Mb(this.$$path)+(c?"?"+c:"")+e;this.$$absUrl= | |
b+(this.$$url?a+this.$$url:"")};this.$$rewrite=function(a){if(Ca(b)==Ca(a))return a}}function Rb(b,a){lb.apply(this,arguments);var c=kb(b);this.$$rewrite=function(d){var e;if(b==Ca(d))return d;else if(e=fa(c,d))return b+a+e;else if(c===d+"/")return c}}function Pa(b){return function(){return this[b]}}function Sb(b,a){return function(c){if(C(c))return this[b];this[b]=a(c);this.$$compose();return this}}function Nc(){var b="",a=!1;this.hashPrefix=function(a){return B(a)?(b=a,this):b};this.html5Mode=function(b){return B(b)? | |
(a=b,this):a};this.$get=["$rootScope","$browser","$sniffer","$rootElement",function(c,d,e,g){function i(a){c.$broadcast("$locationChangeSuccess",f.absUrl(),a)}var f,h=d.baseHref(),j=d.url();a?(h=h?j.substring(0,j.indexOf("/",j.indexOf("//")+2))+h:j,e=e.history?Qb:Rb):(h=Ca(j),e=lb);f=new e(h,"#"+b);f.$$parse(f.$$rewrite(j));g.bind("click",function(a){if(!a.ctrlKey&&!(a.metaKey||a.which==2)){for(var b=w(a.target);I(b[0].nodeName)!=="a";)if(b[0]===g[0]||!(b=b.parent())[0])return;var e=b.prop("href"), | |
j=f.$$rewrite(e);e&&!b.attr("target")&&j&&!a.isDefaultPrevented()&&(a.preventDefault(),j!=d.url()&&(f.$$parse(j),c.$apply(),M.angular["ff-684208-preventDefault"]=!0))}});f.absUrl()!=j&&d.url(f.absUrl(),!0);d.onUrlChange(function(a){f.absUrl()!=a&&(c.$broadcast("$locationChangeStart",a,f.absUrl()).defaultPrevented?d.url(f.absUrl()):(c.$evalAsync(function(){var b=f.absUrl();f.$$parse(a);i(b)}),c.$$phase||c.$digest()))});var m=0;c.$watch(function(){var a=d.url(),b=f.$$replace;if(!m||a!=f.absUrl())m++, | |
c.$evalAsync(function(){c.$broadcast("$locationChangeStart",f.absUrl(),a).defaultPrevented?f.$$parse(a):(d.url(f.absUrl(),b),i(a))});f.$$replace=!1;return m});return f}]}function Oc(){var b=!0,a=this;this.debugEnabled=function(a){return B(a)?(b=a,this):b};this.$get=["$window",function(c){function d(a){a instanceof Error&&(a.stack?a=a.message&&a.stack.indexOf(a.message)===-1?"Error: "+a.message+"\n"+a.stack:a.stack:a.sourceURL&&(a=a.message+"\n"+a.sourceURL+":"+a.line));return a}function e(a){var b= | |
c.console||{},e=b[a]||b.log||q;return e.apply?function(){var a=[];n(arguments,function(b){a.push(d(b))});return e.apply(b,a)}:function(a,b){e(a,b)}}return{log:e("log"),warn:e("warn"),info:e("info"),error:e("error"),debug:function(){var c=e("debug");return function(){b&&c.apply(a,arguments)}}()}}]}function Pc(b,a){function c(a){return a.indexOf(r)!=-1}function d(a){a=a||1;return o+a<b.length?b.charAt(o+a):!1}function e(a){return"0"<=a&&a<="9"}function g(a){return a==" "||a=="\r"||a=="\t"||a=="\n"|| | |
a=="\u000b"||a=="\u00a0"}function i(a){return"a"<=a&&a<="z"||"A"<=a&&a<="Z"||"_"==a||a=="$"}function f(a){return a=="-"||a=="+"||e(a)}function h(a,c,d){d=d||o;throw Error("Lexer Error: "+a+" at column"+(B(c)?"s "+c+"-"+o+" ["+b.substring(c,d)+"]":" "+d)+" in expression ["+b+"].");}function j(){for(var a="",c=o;o<b.length;){var j=I(b.charAt(o));if(j=="."||e(j))a+=j;else{var g=d();if(j=="e"&&f(g))a+=j;else if(f(j)&&g&&e(g)&&a.charAt(a.length-1)=="e")a+=j;else if(f(j)&&(!g||!e(g))&&a.charAt(a.length- | |
1)=="e")h("Invalid exponent");else break}o++}a*=1;l.push({index:c,text:a,json:!0,fn:function(){return a}})}function m(){for(var c="",d=o,f,j,h,k;o<b.length;){k=b.charAt(o);if(k=="."||i(k)||e(k))k=="."&&(f=o),c+=k;else break;o++}if(f)for(j=o;j<b.length;){k=b.charAt(j);if(k=="("){h=c.substr(f-d+1);c=c.substr(0,f-d);o=j;break}if(g(k))j++;else break}d={index:d,text:c};if(Da.hasOwnProperty(c))d.fn=d.json=Da[c];else{var m=Tb(c,a);d.fn=t(function(a,b){return m(a,b)},{assign:function(a,b){return Ub(a,c,b)}})}l.push(d); | |
h&&(l.push({index:f,text:".",json:!1}),l.push({index:f+1,text:h,json:!1}))}function k(a){var c=o;o++;for(var d="",e=a,f=!1;o<b.length;){var j=b.charAt(o);e+=j;if(f)j=="u"?(j=b.substring(o+1,o+5),j.match(/[\da-f]{4}/i)||h("Invalid unicode escape [\\u"+j+"]"),o+=4,d+=String.fromCharCode(parseInt(j,16))):(f=Qc[j],d+=f?f:j),f=!1;else if(j=="\\")f=!0;else if(j==a){o++;l.push({index:c,text:e,string:d,json:!0,fn:function(){return d}});return}else d+=j;o++}h("Unterminated quote",c)}for(var l=[],u,o=0,z=[], | |
r,y=":";o<b.length;){r=b.charAt(o);if(c("\"'"))k(r);else if(e(r)||c(".")&&e(d()))j();else if(i(r)){if(m(),"{,".indexOf(y)!=-1&&z[0]=="{"&&(u=l[l.length-1]))u.json=u.text.indexOf(".")==-1}else if(c("(){}[].,;:?"))l.push({index:o,text:r,json:":[,".indexOf(y)!=-1&&c("{[")||c("}]:,")}),c("{[")&&z.unshift(r),c("}]")&&z.shift(),o++;else if(g(r)){o++;continue}else{var x=r+d(),n=x+d(2),v=Da[r],A=Da[x],G=Da[n];G?(l.push({index:o,text:n,fn:G}),o+=3):A?(l.push({index:o,text:x,fn:A}),o+=2):v?(l.push({index:o, | |
text:r,fn:v,json:"[,:".indexOf(y)!=-1&&c("+-")}),o+=1):h("Unexpected next character ",o,o+1)}y=r}return l}function Rc(b,a,c,d){function e(a,c){throw Error("Syntax Error: Token '"+c.text+"' "+a+" at column "+(c.index+1)+" of the expression ["+b+"] starting at ["+b.substring(c.index)+"].");}function g(){if(O.length===0)throw Error("Unexpected end of expression: "+b);return O[0]}function i(a,b,c,d){if(O.length>0){var e=O[0],f=e.text;if(f==a||f==b||f==c||f==d||!a&&!b&&!c&&!d)return e}return!1}function f(b, | |
c,d,f){return(b=i(b,c,d,f))?(a&&!b.json&&e("is not valid json",b),O.shift(),b):!1}function h(a){f(a)||e("is unexpected, expecting ["+a+"]",i())}function j(a,b){return t(function(c,d){return a(c,d,b)},{constant:b.constant})}function m(a,b,c){return t(function(d,e){return a(d,e)?b(d,e):c(d,e)},{constant:a.constant&&b.constant&&c.constant})}function k(a,b,c){return t(function(d,e){return b(d,e,a,c)},{constant:a.constant&&c.constant})}function l(){for(var a=[];;)if(O.length>0&&!i("}",")",";","]")&&a.push(w()), | |
!f(";"))return a.length==1?a[0]:function(b,c){for(var d,e=0;e<a.length;e++){var f=a[e];f&&(d=f(b,c))}return d}}function u(){for(var a=f(),b=c(a.text),d=[];;)if(a=f(":"))d.push(P());else{var e=function(a,c,e){for(var e=[e],f=0;f<d.length;f++)e.push(d[f](a,c));return b.apply(a,e)};return function(){return e}}}function o(){var a=z(),b,c;if(f("?"))if(b=o(),c=f(":"))return m(a,b,o());else e("expected :",c);else return a}function z(){for(var a=r(),b;;)if(b=f("||"))a=k(a,b.fn,r());else return a}function r(){var a= | |
y(),b;if(b=f("&&"))a=k(a,b.fn,r());return a}function y(){var a=x(),b;if(b=f("==","!=","===","!=="))a=k(a,b.fn,y());return a}function x(){var a;a=n();for(var b;b=f("+","-");)a=k(a,b.fn,n());if(b=f("<",">","<=",">="))a=k(a,b.fn,x());return a}function n(){for(var a=v(),b;b=f("*","/","%");)a=k(a,b.fn,v());return a}function v(){var a;return f("+")?A():(a=f("-"))?k($,a.fn,v()):(a=f("!"))?j(a.fn,v()):A()}function A(){var a;if(f("("))a=w(),h(")");else if(f("["))a=G();else if(f("{"))a=D();else{var b=f();(a= | |
b.fn)||e("not a primary expression",b);if(b.json)a.constant=a.literal=!0}for(var c;b=f("(","[",".");)b.text==="("?(a=s(a,c),c=null):b.text==="["?(c=a,a=ma(a)):b.text==="."?(c=a,a=ja(a)):e("IMPOSSIBLE");return a}function G(){var a=[],b=!0;if(g().text!="]"){do{var c=P();a.push(c);c.constant||(b=!1)}while(f(","))}h("]");return t(function(b,c){for(var d=[],e=0;e<a.length;e++)d.push(a[e](b,c));return d},{literal:!0,constant:b})}function D(){var a=[],b=!0;if(g().text!="}"){do{var c=f(),c=c.string||c.text; | |
h(":");var d=P();a.push({key:c,value:d});d.constant||(b=!1)}while(f(","))}h("}");return t(function(b,c){for(var d={},e=0;e<a.length;e++){var f=a[e];d[f.key]=f.value(b,c)}return d},{literal:!0,constant:b})}var $=S(0),K,O=Pc(b,d),P=function(){var a=o(),c,d;return(d=f("="))?(a.assign||e("implies assignment but ["+b.substring(0,d.index)+"] can not be assigned to",d),c=o(),function(b,d){return a.assign(b,c(b,d),d)}):a},s=function(a,b){var c=[];if(g().text!=")"){do c.push(P());while(f(","))}h(")");return function(d, | |
e){for(var f=[],j=b?b(d,e):d,g=0;g<c.length;g++)f.push(c[g](d,e));g=a(d,e,j)||q;return g.apply?g.apply(j,f):g(f[0],f[1],f[2],f[3],f[4])}},ja=function(a){var b=f().text,c=Tb(b,d);return t(function(b,d,e){return c(e||a(b,d),d)},{assign:function(c,d,e){return Ub(a(c,e),b,d)}})},ma=function(a){var b=P();h("]");return t(function(c,d){var e=a(c,d),f=b(c,d),j;if(!e)return p;if((e=e[f])&&e.then){j=e;if(!("$$v"in e))j.$$v=p,j.then(function(a){j.$$v=a});e=e.$$v}return e},{assign:function(c,d,e){return a(c, | |
e)[b(c,e)]=d}})},w=function(){for(var a=P(),b;;)if(b=f("|"))a=k(a,b.fn,u());else return a};a?(P=z,s=ja=ma=w=function(){e("is not valid json",{text:b,index:0})},K=A()):K=l();O.length!==0&&e("is an unexpected token",O[0]);K.literal=!!K.literal;K.constant=!!K.constant;return K}function Ub(b,a,c){for(var a=a.split("."),d=0;a.length>1;d++){var e=a.shift(),g=b[e];g||(g={},b[e]=g);b=g}return b[a.shift()]=c}function ib(b,a,c){if(!a)return b;for(var a=a.split("."),d,e=b,g=a.length,i=0;i<g;i++)d=a[i],b&&(b= | |
(e=b)[d]);return!c&&H(b)?$a(e,b):b}function Vb(b,a,c,d,e){return function(g,i){var f=i&&i.hasOwnProperty(b)?i:g,h;if(f===null||f===p)return f;if((f=f[b])&&f.then){if(!("$$v"in f))h=f,h.$$v=p,h.then(function(a){h.$$v=a});f=f.$$v}if(!a||f===null||f===p)return f;if((f=f[a])&&f.then){if(!("$$v"in f))h=f,h.$$v=p,h.then(function(a){h.$$v=a});f=f.$$v}if(!c||f===null||f===p)return f;if((f=f[c])&&f.then){if(!("$$v"in f))h=f,h.$$v=p,h.then(function(a){h.$$v=a});f=f.$$v}if(!d||f===null||f===p)return f;if((f= | |
f[d])&&f.then){if(!("$$v"in f))h=f,h.$$v=p,h.then(function(a){h.$$v=a});f=f.$$v}if(!e||f===null||f===p)return f;if((f=f[e])&&f.then){if(!("$$v"in f))h=f,h.$$v=p,h.then(function(a){h.$$v=a});f=f.$$v}return f}}function Tb(b,a){if(mb.hasOwnProperty(b))return mb[b];var c=b.split("."),d=c.length,e;if(a)e=d<6?Vb(c[0],c[1],c[2],c[3],c[4]):function(a,b){var e=0,j;do j=Vb(c[e++],c[e++],c[e++],c[e++],c[e++])(a,b),b=p,a=j;while(e<d);return j};else{var g="var l, fn, p;\n";n(c,function(a,b){g+="if(s === null || s === undefined) return s;\nl=s;\ns="+ | |
(b?"s":'((k&&k.hasOwnProperty("'+a+'"))?k:s)')+'["'+a+'"];\nif (s && s.then) {\n if (!("$$v" in s)) {\n p=s;\n p.$$v = undefined;\n p.then(function(v) {p.$$v=v;});\n}\n s=s.$$v\n}\n'});g+="return s;";e=Function("s","k",g);e.toString=function(){return g}}return mb[b]=e}function Sc(){var b={};this.$get=["$filter","$sniffer",function(a,c){return function(d){switch(typeof d){case "string":return b.hasOwnProperty(d)?b[d]:b[d]=Rc(d,!1,a,c.csp);case "function":return d;default:return q}}}]}function Tc(){this.$get= | |
["$rootScope","$exceptionHandler",function(b,a){return Uc(function(a){b.$evalAsync(a)},a)}]}function Uc(b,a){function c(a){return a}function d(a){return i(a)}var e=function(){var f=[],h,j;return j={resolve:function(a){if(f){var c=f;f=p;h=g(a);c.length&&b(function(){for(var a,b=0,d=c.length;b<d;b++)a=c[b],h.then(a[0],a[1])})}},reject:function(a){j.resolve(i(a))},promise:{then:function(b,j){var g=e(),i=function(d){try{g.resolve((b||c)(d))}catch(e){a(e),g.reject(e)}},o=function(b){try{g.resolve((j|| | |
d)(b))}catch(c){a(c),g.reject(c)}};f?f.push([i,o]):h.then(i,o);return g.promise},always:function(a){function b(a,c){var d=e();c?d.resolve(a):d.reject(a);return d.promise}function d(e,f){var j=null;try{j=(a||c)()}catch(g){return b(g,!1)}return j&&j.then?j.then(function(){return b(e,f)},function(a){return b(a,!1)}):b(e,f)}return this.then(function(a){return d(a,!0)},function(a){return d(a,!1)})}}}},g=function(a){return a&&a.then?a:{then:function(c){var d=e();b(function(){d.resolve(c(a))});return d.promise}}}, | |
i=function(a){return{then:function(c,j){var g=e();b(function(){g.resolve((j||d)(a))});return g.promise}}};return{defer:e,reject:i,when:function(f,h,j){var m=e(),k,l=function(b){try{return(h||c)(b)}catch(d){return a(d),i(d)}},u=function(b){try{return(j||d)(b)}catch(c){return a(c),i(c)}};b(function(){g(f).then(function(a){k||(k=!0,m.resolve(g(a).then(l,u)))},function(a){k||(k=!0,m.resolve(u(a)))})});return m.promise},all:function(a){var b=e(),c=0,d=F(a)?[]:{};n(a,function(a,e){c++;g(a).then(function(a){d.hasOwnProperty(e)|| | |
(d[e]=a,--c||b.resolve(d))},function(a){d.hasOwnProperty(e)||b.reject(a)})});c===0&&b.resolve(d);return b.promise}}}function Vc(){var b={};this.when=function(a,c){b[a]=t({reloadOnSearch:!0,caseInsensitiveMatch:!1},c);if(a){var d=a[a.length-1]=="/"?a.substr(0,a.length-1):a+"/";b[d]={redirectTo:a}}return this};this.otherwise=function(a){this.when(null,a);return this};this.$get=["$rootScope","$location","$routeParams","$q","$injector","$http","$templateCache",function(a,c,d,e,g,i,f){function h(a,b,c){for(var b= | |
"^"+b.replace(/[-\/\\^$:*+?.()|[\]{}]/g,"\\$&")+"$",d="",e=[],f={},j=/\\([:*])(\w+)/g,g,i=0;(g=j.exec(b))!==null;){d+=b.slice(i,g.index);switch(g[1]){case ":":d+="([^\\/]*)";break;case "*":d+="(.*)"}e.push(g[2]);i=j.lastIndex}d+=b.substr(i);var h=a.match(RegExp(d,c.caseInsensitiveMatch?"i":""));h&&n(e,function(a,b){f[a]=h[b+1]});return h?f:null}function j(){var b=m(),j=u.current;if(b&&j&&b.$$route===j.$$route&&ia(b.pathParams,j.pathParams)&&!b.reloadOnSearch&&!l)j.params=b.params,V(j.params,d),a.$broadcast("$routeUpdate", | |
j);else if(b||j)l=!1,a.$broadcast("$routeChangeStart",b,j),(u.current=b)&&b.redirectTo&&(E(b.redirectTo)?c.path(k(b.redirectTo,b.params)).search(b.params).replace():c.url(b.redirectTo(b.pathParams,c.path(),c.search())).replace()),e.when(b).then(function(){if(b){var a=t({},b.resolve),c;n(a,function(b,c){a[c]=E(b)?g.get(b):g.invoke(b)});if(B(c=b.template))H(c)&&(c=c(b.params));else if(B(c=b.templateUrl))if(H(c)&&(c=c(b.params)),B(c))b.loadedTemplateUrl=c,c=i.get(c,{cache:f}).then(function(a){return a.data}); | |
B(c)&&(a.$template=c);return e.all(a)}}).then(function(c){if(b==u.current){if(b)b.locals=c,V(b.params,d);a.$broadcast("$routeChangeSuccess",b,j)}},function(c){b==u.current&&a.$broadcast("$routeChangeError",b,j,c)})}function m(){var a,d;n(b,function(b,e){if(!d&&(a=h(c.path(),e,b)))d=tb(b,{params:t({},c.search(),a),pathParams:a}),d.$$route=b});return d||b[null]&&tb(b[null],{params:{},pathParams:{}})}function k(a,b){var c=[];n((a||"").split(":"),function(a,d){if(d==0)c.push(a);else{var e=a.match(/(\w+)(.*)/), | |
f=e[1];c.push(b[f]);c.push(e[2]||"");delete b[f]}});return c.join("")}var l=!1,u={routes:b,reload:function(){l=!0;a.$evalAsync(j)}};a.$on("$locationChangeSuccess",j);return u}]}function Wc(){this.$get=S({})}function Xc(){var b=10;this.digestTtl=function(a){arguments.length&&(b=a);return b};this.$get=["$injector","$exceptionHandler","$parse",function(a,c,d){function e(){this.$id=Fa();this.$$phase=this.$parent=this.$$watchers=this.$$nextSibling=this.$$prevSibling=this.$$childHead=this.$$childTail=null; | |
this["this"]=this.$root=this;this.$$destroyed=!1;this.$$asyncQueue=[];this.$$listeners={};this.$$isolateBindings={}}function g(a){if(h.$$phase)throw Error(h.$$phase+" already in progress");h.$$phase=a}function i(a,b){var c=d(a);xa(c,b);return c}function f(){}e.prototype={$new:function(a){if(H(a))throw Error("API-CHANGE: Use $controller to instantiate controllers.");a?(a=new e,a.$root=this.$root):(a=function(){},a.prototype=this,a=new a,a.$id=Fa());a["this"]=a;a.$$listeners={};a.$parent=this;a.$$watchers= | |
a.$$nextSibling=a.$$childHead=a.$$childTail=null;a.$$prevSibling=this.$$childTail;this.$$childHead?this.$$childTail=this.$$childTail.$$nextSibling=a:this.$$childHead=this.$$childTail=a;return a},$watch:function(a,b,c){var d=i(a,"watch"),e=this.$$watchers,g={fn:b,last:f,get:d,exp:a,eq:!!c};if(!H(b)){var h=i(b||q,"listener");g.fn=function(a,b,c){h(c)}}if(typeof a=="string"&&d.constant){var r=g.fn;g.fn=function(a,b,c){r.call(this,a,b,c);ta(e,g)}}if(!e)e=this.$$watchers=[];e.unshift(g);return function(){ta(e, | |
g)}},$watchCollection:function(a,b){var c=this,e,f,g=0,i=d(a),h=[],n={},x=0;return this.$watch(function(){f=i(c);var a,b;if(L(f))if(Xa(f)){if(e!==h)e=h,x=e.length=0,g++;a=f.length;if(x!==a)g++,e.length=x=a;for(b=0;b<a;b++)e[b]!==f[b]&&(g++,e[b]=f[b])}else{e!==n&&(e=n={},x=0,g++);a=0;for(b in f)f.hasOwnProperty(b)&&(a++,e.hasOwnProperty(b)?e[b]!==f[b]&&(g++,e[b]=f[b]):(x++,e[b]=f[b],g++));if(x>a)for(b in g++,e)e.hasOwnProperty(b)&&!f.hasOwnProperty(b)&&(x--,delete e[b])}else e!==f&&(e=f,g++);return g}, | |
function(){b(f,e,c)})},$digest:function(){var a,d,e,i,u=this.$$asyncQueue,o,z,r=b,n,x=[],p,v;g("$digest");do{z=!1;for(n=this;u.length;)try{n.$eval(u.shift())}catch(A){c(A)}do{if(i=n.$$watchers)for(o=i.length;o--;)try{if(a=i[o],(d=a.get(n))!==(e=a.last)&&!(a.eq?ia(d,e):typeof d=="number"&&typeof e=="number"&&isNaN(d)&&isNaN(e)))z=!0,a.last=a.eq?V(d):d,a.fn(d,e===f?d:e,n),r<5&&(p=4-r,x[p]||(x[p]=[]),v=H(a.exp)?"fn: "+(a.exp.name||a.exp.toString()):a.exp,v+="; newVal: "+ha(d)+"; oldVal: "+ha(e),x[p].push(v))}catch(G){c(G)}if(!(i= | |
n.$$childHead||n!==this&&n.$$nextSibling))for(;n!==this&&!(i=n.$$nextSibling);)n=n.$parent}while(n=i);if(z&&!r--)throw h.$$phase=null,Error(b+" $digest() iterations reached. Aborting!\nWatchers fired in the last 5 iterations: "+ha(x));}while(z||u.length);h.$$phase=null},$destroy:function(){if(!(h==this||this.$$destroyed)){var a=this.$parent;this.$broadcast("$destroy");this.$$destroyed=!0;if(a.$$childHead==this)a.$$childHead=this.$$nextSibling;if(a.$$childTail==this)a.$$childTail=this.$$prevSibling; | |
if(this.$$prevSibling)this.$$prevSibling.$$nextSibling=this.$$nextSibling;if(this.$$nextSibling)this.$$nextSibling.$$prevSibling=this.$$prevSibling;this.$parent=this.$$nextSibling=this.$$prevSibling=this.$$childHead=this.$$childTail=null}},$eval:function(a,b){return d(a)(this,b)},$evalAsync:function(a){this.$$asyncQueue.push(a)},$apply:function(a){try{return g("$apply"),this.$eval(a)}catch(b){c(b)}finally{h.$$phase=null;try{h.$digest()}catch(d){throw c(d),d;}}},$on:function(a,b){var c=this.$$listeners[a]; | |
c||(this.$$listeners[a]=c=[]);c.push(b);return function(){c[Ga(c,b)]=null}},$emit:function(a,b){var d=[],e,f=this,g=!1,i={name:a,targetScope:f,stopPropagation:function(){g=!0},preventDefault:function(){i.defaultPrevented=!0},defaultPrevented:!1},h=[i].concat(ka.call(arguments,1)),n,x;do{e=f.$$listeners[a]||d;i.currentScope=f;n=0;for(x=e.length;n<x;n++)if(e[n])try{if(e[n].apply(null,h),g)return i}catch(p){c(p)}else e.splice(n,1),n--,x--;f=f.$parent}while(f);return i},$broadcast:function(a,b){var d= | |
this,e=this,f={name:a,targetScope:this,preventDefault:function(){f.defaultPrevented=!0},defaultPrevented:!1},g=[f].concat(ka.call(arguments,1)),i,h;do{d=e;f.currentScope=d;e=d.$$listeners[a]||[];i=0;for(h=e.length;i<h;i++)if(e[i])try{e[i].apply(null,g)}catch(n){c(n)}else e.splice(i,1),i--,h--;if(!(e=d.$$childHead||d!==this&&d.$$nextSibling))for(;d!==this&&!(e=d.$$nextSibling);)d=d.$parent}while(d=e);return f}};var h=new e;return h}]}function Yc(){this.$get=["$window","$document",function(b,a){var c= | |
{},d=N((/android (\d+)/.exec(I((b.navigator||{}).userAgent))||[])[1]),e=a[0]||{},g,i=/^(Moz|webkit|O|ms)(?=[A-Z])/,f=e.body&&e.body.style,h=!1,j=!1;if(f){for(var m in f)if(h=i.exec(m)){g=h[0];g=g.substr(0,1).toUpperCase()+g.substr(1);break}h=!!("transition"in f||g+"Transition"in f);j=!!("animation"in f||g+"Animation"in f)}return{history:!(!b.history||!b.history.pushState||d<4),hashchange:"onhashchange"in b&&(!e.documentMode||e.documentMode>7),hasEvent:function(a){if(a=="input"&&Z==9)return!1;if(C(c[a])){var b= | |
e.createElement("div");c[a]="on"+a in b}return c[a]},csp:e.securityPolicy?e.securityPolicy.isActive:!1,vendorPrefix:g,transitions:h,animations:j}}]}function Zc(){this.$get=S(M)}function Wb(b){var a={},c,d,e;if(!b)return a;n(b.split("\n"),function(b){e=b.indexOf(":");c=I(U(b.substr(0,e)));d=U(b.substr(e+1));c&&(a[c]?a[c]+=", "+d:a[c]=d)});return a}function $c(b,a){var c=ad.exec(b);if(c==null)return!0;var d={protocol:c[2],host:c[4],port:N(c[6])||Oa[c[2]]||null,relativeProtocol:c[2]===p||c[2]===""}, | |
c=jb.exec(a),c={protocol:c[1],host:c[3],port:N(c[5])||Oa[c[1]]||null};return(d.protocol==c.protocol||d.relativeProtocol)&&d.host==c.host&&(d.port==c.port||d.relativeProtocol&&c.port==Oa[c.protocol])}function Xb(b){var a=L(b)?b:p;return function(c){a||(a=Wb(b));return c?a[I(c)]||null:a}}function Yb(b,a,c){if(H(c))return c(b,a);n(c,function(c){b=c(b,a)});return b}function bd(){var b=/^\s*(\[|\{[^\{])/,a=/[\}\]]\s*$/,c=/^\)\]\}',?\n/,d={"Content-Type":"application/json;charset=utf-8"},e=this.defaults= | |
{transformResponse:[function(d){E(d)&&(d=d.replace(c,""),b.test(d)&&a.test(d)&&(d=ub(d,!0)));return d}],transformRequest:[function(a){return L(a)&&Ea.apply(a)!=="[object File]"?ha(a):a}],headers:{common:{Accept:"application/json, text/plain, */*"},post:d,put:d,patch:d},xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN"},g=this.interceptors=[],i=this.responseInterceptors=[];this.$get=["$httpBackend","$browser","$cacheFactory","$rootScope","$q","$injector",function(a,b,c,d,k,l){function u(a){function c(a){var b= | |
t({},a,{data:Yb(a.data,a.headers,d.transformResponse)});return 200<=a.status&&a.status<300?b:k.reject(b)}var d={transformRequest:e.transformRequest,transformResponse:e.transformResponse},f={};t(d,a);d.headers=f;d.method=oa(d.method);t(f,e.headers.common,e.headers[I(d.method)],a.headers);(a=$c(d.url,b.url())?b.cookies()[d.xsrfCookieName||e.xsrfCookieName]:p)&&(f[d.xsrfHeaderName||e.xsrfHeaderName]=a);var g=[function(a){var b=Yb(a.data,Xb(f),a.transformRequest);C(a.data)&&delete f["Content-Type"];if(C(a.withCredentials)&& | |
!C(e.withCredentials))a.withCredentials=e.withCredentials;return o(a,b,f).then(c,c)},p],j=k.when(d);for(n(y,function(a){(a.request||a.requestError)&&g.unshift(a.request,a.requestError);(a.response||a.responseError)&&g.push(a.response,a.responseError)});g.length;)var a=g.shift(),i=g.shift(),j=j.then(a,i);j.success=function(a){j.then(function(b){a(b.data,b.status,b.headers,d)});return j};j.error=function(a){j.then(null,function(b){a(b.data,b.status,b.headers,d)});return j};return j}function o(b,c,g){function j(a, | |
b,c){n&&(200<=a&&a<300?n.put(s,[a,b,Wb(c)]):n.remove(s));i(b,a,c);d.$$phase||d.$apply()}function i(a,c,d){c=Math.max(c,0);(200<=c&&c<300?l.resolve:l.reject)({data:a,status:c,headers:Xb(d),config:b})}function h(){var a=Ga(u.pendingRequests,b);a!==-1&&u.pendingRequests.splice(a,1)}var l=k.defer(),o=l.promise,n,p,s=z(b.url,b.params);u.pendingRequests.push(b);o.then(h,h);if((b.cache||e.cache)&&b.cache!==!1&&b.method=="GET")n=L(b.cache)?b.cache:L(e.cache)?e.cache:r;if(n)if(p=n.get(s))if(p.then)return p.then(h, | |
h),p;else F(p)?i(p[1],p[0],V(p[2])):i(p,200,{});else n.put(s,o);p||a(b.method,s,c,j,g,b.timeout,b.withCredentials,b.responseType);return o}function z(a,b){if(!b)return a;var c=[];nc(b,function(a,b){a==null||a==p||(F(a)||(a=[a]),n(a,function(a){L(a)&&(a=ha(a));c.push(wa(b)+"="+wa(a))}))});return a+(a.indexOf("?")==-1?"?":"&")+c.join("&")}var r=c("$http"),y=[];n(g,function(a){y.unshift(E(a)?l.get(a):l.invoke(a))});n(i,function(a,b){var c=E(a)?l.get(a):l.invoke(a);y.splice(b,0,{response:function(a){return c(k.when(a))}, | |
responseError:function(a){return c(k.reject(a))}})});u.pendingRequests=[];(function(a){n(arguments,function(a){u[a]=function(b,c){return u(t(c||{},{method:a,url:b}))}})})("get","delete","head","jsonp");(function(a){n(arguments,function(a){u[a]=function(b,c,d){return u(t(d||{},{method:a,url:b,data:c}))}})})("post","put");u.defaults=e;return u}]}function cd(){this.$get=["$browser","$window","$document",function(b,a,c){return dd(b,ed,b.defer,a.angular.callbacks,c[0],a.location.protocol.replace(":",""))}]} | |
function dd(b,a,c,d,e,g){function i(a,b){var c=e.createElement("script"),d=function(){e.body.removeChild(c);b&&b()};c.type="text/javascript";c.src=a;Z?c.onreadystatechange=function(){/loaded|complete/.test(c.readyState)&&d()}:c.onload=c.onerror=d;e.body.appendChild(c);return d}return function(e,h,j,m,k,l,u,o){function z(){p=-1;t&&t();v&&v.abort()}function r(a,d,e,f){var j=(h.match(jb)||["",g])[1];A&&c.cancel(A);t=v=null;d=j=="file"?e?200:404:d;a(d==1223?204:d,e,f);b.$$completeOutstandingRequest(q)} | |
var p;b.$$incOutstandingRequestCount();h=h||b.url();if(I(e)=="jsonp"){var x="_"+(d.counter++).toString(36);d[x]=function(a){d[x].data=a};var t=i(h.replace("JSON_CALLBACK","angular.callbacks."+x),function(){d[x].data?r(m,200,d[x].data):r(m,p||-2);delete d[x]})}else{var v=new a;v.open(e,h,!0);n(k,function(a,b){a&&v.setRequestHeader(b,a)});v.onreadystatechange=function(){if(v.readyState==4){var a=v.getAllResponseHeaders(),b=["Cache-Control","Content-Language","Content-Type","Expires","Last-Modified", | |
"Pragma"];a||(a="",n(b,function(b){var c=v.getResponseHeader(b);c&&(a+=b+": "+c+"\n")}));r(m,p||v.status,v.responseType?v.response:v.responseText,a)}};if(u)v.withCredentials=!0;if(o)v.responseType=o;v.send(j||"")}if(l>0)var A=c(z,l);else l&&l.then&&l.then(z)}}function fd(){this.$get=function(){return{id:"en-us",NUMBER_FORMATS:{DECIMAL_SEP:".",GROUP_SEP:",",PATTERNS:[{minInt:1,minFrac:0,maxFrac:3,posPre:"",posSuf:"",negPre:"-",negSuf:"",gSize:3,lgSize:3},{minInt:1,minFrac:2,maxFrac:2,posPre:"\u00a4", | |
posSuf:"",negPre:"(\u00a4",negSuf:")",gSize:3,lgSize:3}],CURRENCY_SYM:"$"},DATETIME_FORMATS:{MONTH:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),SHORTMONTH:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),DAY:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),SHORTDAY:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(","),AMPMS:["AM","PM"],medium:"MMM d, y h:mm:ss a","short":"M/d/yy h:mm a",fullDate:"EEEE, MMMM d, y",longDate:"MMMM d, y", | |
mediumDate:"MMM d, y",shortDate:"M/d/yy",mediumTime:"h:mm:ss a",shortTime:"h:mm a"},pluralCat:function(b){return b===1?"one":"other"}}}}function gd(){this.$get=["$rootScope","$browser","$q","$exceptionHandler",function(b,a,c,d){function e(e,f,h){var j=c.defer(),m=j.promise,k=B(h)&&!h,f=a.defer(function(){try{j.resolve(e())}catch(a){j.reject(a),d(a)}k||b.$apply()},f),h=function(){delete g[m.$$timeoutId]};m.$$timeoutId=f;g[f]=j;m.then(h,h);return m}var g={};e.cancel=function(b){return b&&b.$$timeoutId in | |
g?(g[b.$$timeoutId].reject("canceled"),a.defer.cancel(b.$$timeoutId)):!1};return e}]}function Zb(b){function a(a,e){return b.factory(a+c,e)}var c="Filter";this.register=a;this.$get=["$injector",function(a){return function(b){return a.get(b+c)}}];a("currency",$b);a("date",ac);a("filter",hd);a("json",id);a("limitTo",jd);a("lowercase",kd);a("number",bc);a("orderBy",cc);a("uppercase",ld)}function hd(){return function(b,a,c){if(!F(b))return b;var d=[];d.check=function(a){for(var b=0;b<d.length;b++)if(!d[b](a))return!1; | |
return!0};switch(typeof c){case "function":break;case "boolean":if(c==!0){c=function(a,b){return Ha.equals(a,b)};break}default:c=function(a,b){b=(""+b).toLowerCase();return(""+a).toLowerCase().indexOf(b)>-1}}var e=function(a,b){if(typeof b=="string"&&b.charAt(0)==="!")return!e(a,b.substr(1));switch(typeof a){case "boolean":case "number":case "string":return c(a,b);case "object":switch(typeof b){case "object":return c(a,b);default:for(var d in a)if(d.charAt(0)!=="$"&&e(a[d],b))return!0}return!1;case "array":for(d= | |
0;d<a.length;d++)if(e(a[d],b))return!0;return!1;default:return!1}};switch(typeof a){case "boolean":case "number":case "string":a={$:a};case "object":for(var g in a)g=="$"?function(){if(a[g]){var b=g;d.push(function(c){return e(c,a[b])})}}():function(){if(a[g]){var b=g;d.push(function(c){return e(ib(c,b),a[b])})}}();break;case "function":d.push(a);break;default:return b}for(var i=[],f=0;f<b.length;f++){var h=b[f];d.check(h)&&i.push(h)}return i}}function $b(b){var a=b.NUMBER_FORMATS;return function(b, | |
d){if(C(d))d=a.CURRENCY_SYM;return dc(b,a.PATTERNS[1],a.GROUP_SEP,a.DECIMAL_SEP,2).replace(/\u00A4/g,d)}}function bc(b){var a=b.NUMBER_FORMATS;return function(b,d){return dc(b,a.PATTERNS[0],a.GROUP_SEP,a.DECIMAL_SEP,d)}}function dc(b,a,c,d,e){if(isNaN(b)||!isFinite(b))return"";var g=b<0,b=Math.abs(b),i=b+"",f="",h=[],j=!1;if(i.indexOf("e")!==-1){var m=i.match(/([\d\.]+)e(-?)(\d+)/);m&&m[2]=="-"&&m[3]>e+1?i="0":(f=i,j=!0)}if(!j){i=(i.split(ec)[1]||"").length;C(e)&&(e=Math.min(Math.max(a.minFrac,i), | |
a.maxFrac));var i=Math.pow(10,e),b=Math.round(b*i)/i,b=(""+b).split(ec),i=b[0],b=b[1]||"",j=0,m=a.lgSize,k=a.gSize;if(i.length>=m+k)for(var j=i.length-m,l=0;l<j;l++)(j-l)%k===0&&l!==0&&(f+=c),f+=i.charAt(l);for(l=j;l<i.length;l++)(i.length-l)%m===0&&l!==0&&(f+=c),f+=i.charAt(l);for(;b.length<e;)b+="0";e&&e!=="0"&&(f+=d+b.substr(0,e))}h.push(g?a.negPre:a.posPre);h.push(f);h.push(g?a.negSuf:a.posSuf);return h.join("")}function nb(b,a,c){var d="";b<0&&(d="-",b=-b);for(b=""+b;b.length<a;)b="0"+b;c&&(b= | |
b.substr(b.length-a));return d+b}function Q(b,a,c,d){c=c||0;return function(e){e=e["get"+b]();if(c>0||e>-c)e+=c;e===0&&c==-12&&(e=12);return nb(e,a,d)}}function Qa(b,a){return function(c,d){var e=c["get"+b](),g=oa(a?"SHORT"+b:b);return d[g][e]}}function ac(b){function a(a){var b;if(b=a.match(c)){var a=new Date(0),g=0,i=0,f=b[8]?a.setUTCFullYear:a.setFullYear,h=b[8]?a.setUTCHours:a.setHours;b[9]&&(g=N(b[9]+b[10]),i=N(b[9]+b[11]));f.call(a,N(b[1]),N(b[2])-1,N(b[3]));g=N(b[4]||0)-g;i=N(b[5]||0)-i;f= | |
N(b[6]||0);b=Math.round(parseFloat("0."+(b[7]||0))*1E3);h.call(a,g,i,f,b)}return a}var c=/^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;return function(c,e){var g="",i=[],f,h,e=e||"mediumDate",e=b.DATETIME_FORMATS[e]||e;E(c)&&(c=md.test(c)?N(c):a(c));Ya(c)&&(c=new Date(c));if(!ra(c))return c;for(;e;)(h=nd.exec(e))?(i=i.concat(ka.call(h,1)),e=i.pop()):(i.push(e),e=null);n(i,function(a){f=od[a];g+=f?f(c,b.DATETIME_FORMATS):a.replace(/(^'|'$)/g, | |
"").replace(/''/g,"'")});return g}}function id(){return function(b){return ha(b,!0)}}function jd(){return function(b,a){if(!F(b)&&!E(b))return b;a=N(a);if(E(b))return a?a>=0?b.slice(0,a):b.slice(a,b.length):"";var c=[],d,e;a>b.length?a=b.length:a<-b.length&&(a=-b.length);a>0?(d=0,e=a):(d=b.length+a,e=b.length);for(;d<e;d++)c.push(b[d]);return c}}function cc(b){return function(a,c,d){function e(a,b){return ua(b)?function(b,c){return a(c,b)}:a}if(!F(a))return a;if(!c)return a;for(var c=F(c)?c:[c],c= | |
Za(c,function(a){var c=!1,d=a||qa;if(E(a)){if(a.charAt(0)=="+"||a.charAt(0)=="-")c=a.charAt(0)=="-",a=a.substring(1);d=b(a)}return e(function(a,b){var c;c=d(a);var e=d(b),f=typeof c,g=typeof e;f==g?(f=="string"&&(c=c.toLowerCase()),f=="string"&&(e=e.toLowerCase()),c=c===e?0:c<e?-1:1):c=f<g?-1:1;return c},c)}),g=[],i=0;i<a.length;i++)g.push(a[i]);return g.sort(e(function(a,b){for(var d=0;d<c.length;d++){var e=c[d](a,b);if(e!==0)return e}return 0},d))}}function aa(b){H(b)&&(b={link:b});b.restrict=b.restrict|| | |
"AC";return S(b)}function fc(b,a){function c(a,c){c=c?"-"+bb(c,"-"):"";b.removeClass((a?Ra:Sa)+c).addClass((a?Sa:Ra)+c)}var d=this,e=b.parent().controller("form")||Ta,g=0,i=d.$error={},f=[];d.$name=a.name;d.$dirty=!1;d.$pristine=!0;d.$valid=!0;d.$invalid=!1;e.$addControl(d);b.addClass(pa);c(!0);d.$addControl=function(a){f.push(a);a.$name&&!d.hasOwnProperty(a.$name)&&(d[a.$name]=a)};d.$removeControl=function(a){a.$name&&d[a.$name]===a&&delete d[a.$name];n(i,function(b,c){d.$setValidity(c,!0,a)});ta(f, | |
a)};d.$setValidity=function(a,b,f){var k=i[a];if(b){if(k&&(ta(k,f),!k.length)){g--;if(!g)c(b),d.$valid=!0,d.$invalid=!1;i[a]=!1;c(!0,a);e.$setValidity(a,!0,d)}}else{g||c(b);if(k){if(Ga(k,f)!=-1)return}else i[a]=k=[],g++,c(!1,a),e.$setValidity(a,!1,d);k.push(f);d.$valid=!1;d.$invalid=!0}};d.$setDirty=function(){b.removeClass(pa).addClass(Ua);d.$dirty=!0;d.$pristine=!1;e.$setDirty()};d.$setPristine=function(){b.removeClass(Ua).addClass(pa);d.$dirty=!1;d.$pristine=!0;n(f,function(a){a.$setPristine()})}} | |
function X(b){return C(b)||b===""||b===null||b!==b}function Va(b,a,c,d,e,g){var i=function(){var e=a.val();if(ua(c.ngTrim||"T"))e=U(e);d.$viewValue!==e&&b.$apply(function(){d.$setViewValue(e)})};if(e.hasEvent("input"))a.bind("input",i);else{var f,h=function(){f||(f=g.defer(function(){i();f=null}))};a.bind("keydown",function(a){a=a.keyCode;a===91||15<a&&a<19||37<=a&&a<=40||h()});a.bind("change",i);e.hasEvent("paste")&&a.bind("paste cut",h)}d.$render=function(){a.val(X(d.$viewValue)?"":d.$viewValue)}; | |
var j=c.ngPattern,m=function(a,b){return X(b)||a.test(b)?(d.$setValidity("pattern",!0),b):(d.$setValidity("pattern",!1),p)};j&&((e=j.match(/^\/(.*)\/([gim]*)$/))?(j=RegExp(e[1],e[2]),e=function(a){return m(j,a)}):e=function(a){var c=b.$eval(j);if(!c||!c.test)throw Error("Expected "+j+" to be a RegExp but was "+c);return m(c,a)},d.$formatters.push(e),d.$parsers.push(e));if(c.ngMinlength){var k=N(c.ngMinlength),e=function(a){return!X(a)&&a.length<k?(d.$setValidity("minlength",!1),p):(d.$setValidity("minlength", | |
!0),a)};d.$parsers.push(e);d.$formatters.push(e)}if(c.ngMaxlength){var l=N(c.ngMaxlength),e=function(a){return!X(a)&&a.length>l?(d.$setValidity("maxlength",!1),p):(d.$setValidity("maxlength",!0),a)};d.$parsers.push(e);d.$formatters.push(e)}}function ob(b,a){b="ngClass"+b;return aa(function(c,d,e){function g(b){if(a===!0||c.$index%2===a)h&&!ia(b,h)&&i(h),f(b);h=V(b)}function i(a){L(a)&&!F(a)&&(a=Za(a,function(a,b){if(a)return b}));d.removeClass(F(a)?a.join(" "):a)}function f(a){L(a)&&!F(a)&&(a=Za(a, | |
function(a,b){if(a)return b}));a&&d.addClass(F(a)?a.join(" "):a)}var h=p;c.$watch(e[b],g,!0);e.$observe("class",function(){var a=c.$eval(e[b]);g(a,a)});b!=="ngClass"&&c.$watch("$index",function(d,g){var h=d&1;h!==g&1&&(h===a?f(c.$eval(e[b])):i(c.$eval(e[b])))})})}var I=function(b){return E(b)?b.toLowerCase():b},oa=function(b){return E(b)?b.toUpperCase():b},Z=N((/msie (\d+)/.exec(I(navigator.userAgent))||[])[1]),w,ga,ka=[].slice,Wa=[].push,Ea=Object.prototype.toString,mc=M.angular,Ha=M.angular||(M.angular= | |
{}),Aa,hb,ba=["0","0","0"];q.$inject=[];qa.$inject=[];hb=Z<9?function(b){b=b.nodeName?b:b[0];return b.scopeName&&b.scopeName!="HTML"?oa(b.scopeName+":"+b.nodeName):b.nodeName}:function(b){return b.nodeName?b.nodeName:b[0].nodeName};var sc=/[A-Z]/g,pd={full:"1.1.5",major:1,minor:1,dot:5,codeName:"triangle-squarification"},Ka=R.cache={},Ja=R.expando="ng-"+(new Date).getTime(),wc=1,gc=M.document.addEventListener?function(b,a,c){b.addEventListener(a,c,!1)}:function(b,a,c){b.attachEvent("on"+a,c)},gb= | |
M.document.removeEventListener?function(b,a,c){b.removeEventListener(a,c,!1)}:function(b,a,c){b.detachEvent("on"+a,c)},uc=/([\:\-\_]+(.))/g,vc=/^moz([A-Z])/,Ba=R.prototype={ready:function(b){function a(){c||(c=!0,b())}var c=!1;T.readyState==="complete"?setTimeout(a):(this.bind("DOMContentLoaded",a),R(M).bind("load",a))},toString:function(){var b=[];n(this,function(a){b.push(""+a)});return"["+b.join(", ")+"]"},eq:function(b){return b>=0?w(this[b]):w(this[this.length+b])},length:0,push:Wa,sort:[].sort, | |
splice:[].splice},Na={};n("multiple,selected,checked,disabled,readOnly,required,open".split(","),function(b){Na[I(b)]=b});var Gb={};n("input,select,option,textarea,button,form,details".split(","),function(b){Gb[oa(b)]=!0});n({data:Bb,inheritedData:Ma,scope:function(b){return Ma(b,"$scope")},controller:Eb,injector:function(b){return Ma(b,"$injector")},removeAttr:function(b,a){b.removeAttribute(a)},hasClass:La,css:function(b,a,c){a=Ia(a);if(B(c))b.style[a]=c;else{var d;Z<=8&&(d=b.currentStyle&&b.currentStyle[a], | |
d===""&&(d="auto"));d=d||b.style[a];Z<=8&&(d=d===""?p:d);return d}},attr:function(b,a,c){var d=I(a);if(Na[d])if(B(c))c?(b[a]=!0,b.setAttribute(a,d)):(b[a]=!1,b.removeAttribute(d));else return b[a]||(b.attributes.getNamedItem(a)||q).specified?d:p;else if(B(c))b.setAttribute(a,c);else if(b.getAttribute)return b=b.getAttribute(a,2),b===null?p:b},prop:function(b,a,c){if(B(c))b[a]=c;else return b[a]},text:t(Z<9?function(b,a){if(b.nodeType==1){if(C(a))return b.innerText;b.innerText=a}else{if(C(a))return b.nodeValue; | |
b.nodeValue=a}}:function(b,a){if(C(a))return b.textContent;b.textContent=a},{$dv:""}),val:function(b,a){if(C(a))return b.value;b.value=a},html:function(b,a){if(C(a))return b.innerHTML;for(var c=0,d=b.childNodes;c<d.length;c++)ya(d[c]);b.innerHTML=a}},function(b,a){R.prototype[a]=function(a,d){var e,g;if((b.length==2&&b!==La&&b!==Eb?a:d)===p)if(L(a)){for(e=0;e<this.length;e++)if(b===Bb)b(this[e],a);else for(g in a)b(this[e],g,a[g]);return this}else{if(this.length)return b(this[0],a,d)}else{for(e=0;e< | |
this.length;e++)b(this[e],a,d);return this}return b.$dv}});n({removeData:zb,dealoc:ya,bind:function a(c,d,e){var g=ca(c,"events"),i=ca(c,"handle");g||ca(c,"events",g={});i||ca(c,"handle",i=xc(c,g));n(d.split(" "),function(d){var h=g[d];if(!h){if(d=="mouseenter"||d=="mouseleave"){var j=T.body.contains||T.body.compareDocumentPosition?function(a,c){var d=a.nodeType===9?a.documentElement:a,e=c&&c.parentNode;return a===e||!(!e||!(e.nodeType===1&&(d.contains?d.contains(e):a.compareDocumentPosition&&a.compareDocumentPosition(e)& | |
16)))}:function(a,c){if(c)for(;c=c.parentNode;)if(c===a)return!0;return!1};g[d]=[];a(c,{mouseleave:"mouseout",mouseenter:"mouseover"}[d],function(a){var c=a.relatedTarget;(!c||c!==this&&!j(this,c))&&i(a,d)})}else gc(c,d,i),g[d]=[];h=g[d]}h.push(e)})},unbind:Ab,replaceWith:function(a,c){var d,e=a.parentNode;ya(a);n(new R(c),function(c){d?e.insertBefore(c,d.nextSibling):e.replaceChild(c,a);d=c})},children:function(a){var c=[];n(a.childNodes,function(a){a.nodeType===1&&c.push(a)});return c},contents:function(a){return a.childNodes|| | |
[]},append:function(a,c){n(new R(c),function(c){(a.nodeType===1||a.nodeType===11)&&a.appendChild(c)})},prepend:function(a,c){if(a.nodeType===1){var d=a.firstChild;n(new R(c),function(c){d?a.insertBefore(c,d):(a.appendChild(c),d=c)})}},wrap:function(a,c){var c=w(c)[0],d=a.parentNode;d&&d.replaceChild(c,a);c.appendChild(a)},remove:function(a){ya(a);var c=a.parentNode;c&&c.removeChild(a)},after:function(a,c){var d=a,e=a.parentNode;n(new R(c),function(a){e.insertBefore(a,d.nextSibling);d=a})},addClass:Db, | |
removeClass:Cb,toggleClass:function(a,c,d){C(d)&&(d=!La(a,c));(d?Db:Cb)(a,c)},parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},next:function(a){if(a.nextElementSibling)return a.nextElementSibling;for(a=a.nextSibling;a!=null&&a.nodeType!==1;)a=a.nextSibling;return a},find:function(a,c){return a.getElementsByTagName(c)},clone:fb,triggerHandler:function(a,c){var d=(ca(a,"events")||{})[c];n(d,function(c){c.call(a,{preventDefault:q})})}},function(a,c){R.prototype[c]=function(c,e){for(var g, | |
i=0;i<this.length;i++)g==p?(g=a(this[i],c,e),g!==p&&(g=w(g))):eb(g,a(this[i],c,e));return g==p?this:g}});za.prototype={put:function(a,c){this[la(a)]=c},get:function(a){return this[la(a)]},remove:function(a){var c=this[a=la(a)];delete this[a];return c}};var zc=/^function\s*[^\(]*\(\s*([^\)]*)\)/m,Ac=/,/,Bc=/^\s*(_?)(\S+?)\1\s*$/,yc=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;Ib.$inject=["$provide"];var qd=function(){var a="$ngAnimateController",c={running:!0};this.$get=["$animation","$window","$sniffer","$rootElement", | |
"$rootScope",function(d,e,g,i){i.data(a,c);i=function(c,i){function j(j,k,o){return function(m,r,p){function x(a){var c=0,a=E(a)?a.split(/\s*,\s*/):[];n(a,function(a){c=Math.max(parseFloat(a)||0,c)});return c}function t(){m.addClass(K);if($)$(m,v,P);else if(H(e.getComputedStyle)){var a=g.vendorPrefix+"Animation",c=g.vendorPrefix+"Transition",d=0;n(m,function(f){if(f.nodeType==1){var g="transition",i=c,j=1,h=e.getComputedStyle(f)||{};if(parseFloat(h.animationDuration)>0||parseFloat(h[a+"Duration"])> | |
0)g="animation",i=a,j=Math.max(parseInt(h[g+"IterationCount"])||0,parseInt(h[i+"IterationCount"])||0,j);f=Math.max(x(h[g+"Delay"]),x(h[i+"Delay"]));g=Math.max(x(h[g+"Duration"]),x(h[i+"Duration"]));d=Math.max(f+j*g,d)}});e.setTimeout(v,d*1E3)}else v()}function v(){if(!v.run)v.run=!0,o(m,r,p),m.removeClass(w),m.removeClass(K),m.removeData(a)}var A=c.$eval(i.ngAnimate),w=A?L(A)?A[j]:A+"-"+j:"",D=d(w),A=D&&D.setup,$=D&&D.start,D=D&&D.cancel;if(w){var K=w+"-active";r||(r=p?p.parent():m.parent());if(!g.transitions&& | |
!A&&!$||(r.inheritedData(a)||q).running)k(m,r,p),o(m,r,p);else{var O=m.data(a)||{};O.running&&((D||q)(m),O.done());m.data(a,{running:!0,done:v});m.addClass(w);k(m,r,p);if(m.length==0)return v();var P=(A||q)(m);e.setTimeout(t,1)}}else k(m,r,p),o(m,r,p)}}function m(a,c,d){d?d.after(a):c.append(a)}var k={};k.enter=j("enter",m,q);k.leave=j("leave",q,function(a){a.remove()});k.move=j("move",function(a,c,d){m(a,c,d)},q);k.show=j("show",function(a){a.css("display","")},q);k.hide=j("hide",q,function(a){a.css("display", | |
"none")});k.animate=function(a,c){j(a,q,q)(c)};return k};i.enabled=function(a){if(arguments.length)c.running=!a;return!c.running};return i}]},Kb="Non-assignable model expression: ";Jb.$inject=["$provide"];var Ic=/^(x[\:\-_]|data[\:\-_])/i,jb=/^([^:]+):\/\/(\w+:{0,1}\w*@)?(\{?[\w\.-]*\}?)(:([0-9]+))?(\/[^\?#]*)?(\?([^#]*))?(#(.*))?$/,Pb=/^([^\?#]*)(\?([^#]*))?(#(.*))?$/,Oa={http:80,https:443,ftp:21};Rb.prototype=lb.prototype=Qb.prototype={$$replace:!1,absUrl:Pa("$$absUrl"),url:function(a,c){if(C(a))return this.$$url; | |
var d=Pb.exec(a);d[1]&&this.path(decodeURIComponent(d[1]));if(d[2]||d[1])this.search(d[3]||"");this.hash(d[5]||"",c);return this},protocol:Pa("$$protocol"),host:Pa("$$host"),port:Pa("$$port"),path:Sb("$$path",function(a){return a.charAt(0)=="/"?a:"/"+a}),search:function(a,c){if(C(a))return this.$$search;B(c)?c===null?delete this.$$search[a]:this.$$search[a]=c:this.$$search=E(a)?vb(a):a;this.$$compose();return this},hash:Sb("$$hash",qa),replace:function(){this.$$replace=!0;return this}};var Da={"null":function(){return null}, | |
"true":function(){return!0},"false":function(){return!1},undefined:q,"+":function(a,c,d,e){d=d(a,c);e=e(a,c);return B(d)?B(e)?d+e:d:B(e)?e:p},"-":function(a,c,d,e){d=d(a,c);e=e(a,c);return(B(d)?d:0)-(B(e)?e:0)},"*":function(a,c,d,e){return d(a,c)*e(a,c)},"/":function(a,c,d,e){return d(a,c)/e(a,c)},"%":function(a,c,d,e){return d(a,c)%e(a,c)},"^":function(a,c,d,e){return d(a,c)^e(a,c)},"=":q,"===":function(a,c,d,e){return d(a,c)===e(a,c)},"!==":function(a,c,d,e){return d(a,c)!==e(a,c)},"==":function(a, | |
c,d,e){return d(a,c)==e(a,c)},"!=":function(a,c,d,e){return d(a,c)!=e(a,c)},"<":function(a,c,d,e){return d(a,c)<e(a,c)},">":function(a,c,d,e){return d(a,c)>e(a,c)},"<=":function(a,c,d,e){return d(a,c)<=e(a,c)},">=":function(a,c,d,e){return d(a,c)>=e(a,c)},"&&":function(a,c,d,e){return d(a,c)&&e(a,c)},"||":function(a,c,d,e){return d(a,c)||e(a,c)},"&":function(a,c,d,e){return d(a,c)&e(a,c)},"|":function(a,c,d,e){return e(a,c)(a,c,d(a,c))},"!":function(a,c,d){return!d(a,c)}},Qc={n:"\n",f:"\u000c",r:"\r", | |
t:"\t",v:"\u000b","'":"'",'"':'"'},mb={},ad=/^(([^:]+):)?\/\/(\w+:{0,1}\w*@)?([\w\.-]*)?(:([0-9]+))?(.*)$/,ed=M.XMLHttpRequest||function(){try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(c){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(d){}throw Error("This browser does not support XMLHttpRequest.");};Zb.$inject=["$provide"];$b.$inject=["$locale"];bc.$inject=["$locale"];var ec=".",od={yyyy:Q("FullYear",4),yy:Q("FullYear", | |
2,0,!0),y:Q("FullYear",1),MMMM:Qa("Month"),MMM:Qa("Month",!0),MM:Q("Month",2,1),M:Q("Month",1,1),dd:Q("Date",2),d:Q("Date",1),HH:Q("Hours",2),H:Q("Hours",1),hh:Q("Hours",2,-12),h:Q("Hours",1,-12),mm:Q("Minutes",2),m:Q("Minutes",1),ss:Q("Seconds",2),s:Q("Seconds",1),sss:Q("Milliseconds",3),EEEE:Qa("Day"),EEE:Qa("Day",!0),a:function(a,c){return a.getHours()<12?c.AMPMS[0]:c.AMPMS[1]},Z:function(a){var a=-1*a.getTimezoneOffset(),c=a>=0?"+":"";c+=nb(Math[a>0?"floor":"ceil"](a/60),2)+nb(Math.abs(a%60), | |
2);return c}},nd=/((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/,md=/^\d+$/;ac.$inject=["$locale"];var kd=S(I),ld=S(oa);cc.$inject=["$parse"];var rd=S({restrict:"E",compile:function(a,c){Z<=8&&(!c.href&&!c.name&&c.$set("href",""),a.append(T.createComment("IE fix")));return function(a,c){c.bind("click",function(a){c.attr("href")||a.preventDefault()})}}}),pb={};n(Na,function(a,c){var d=da("ng-"+c);pb[d]=function(){return{priority:100,compile:function(){return function(a, | |
g,i){a.$watch(i[d],function(a){i.$set(c,!!a)})}}}}});n(["src","srcset","href"],function(a){var c=da("ng-"+a);pb[c]=function(){return{priority:99,link:function(d,e,g){g.$observe(c,function(c){c&&(g.$set(a,c),Z&&e.prop(a,g[a]))})}}}});var Ta={$addControl:q,$removeControl:q,$setValidity:q,$setDirty:q,$setPristine:q};fc.$inject=["$element","$attrs","$scope"];var Wa=function(a){return["$timeout",function(c){var d={name:"form",restrict:"E",controller:fc,compile:function(){return{pre:function(a,d,i,f){if(!i.action){var h= | |
function(a){a.preventDefault?a.preventDefault():a.returnValue=!1};gc(d[0],"submit",h);d.bind("$destroy",function(){c(function(){gb(d[0],"submit",h)},0,!1)})}var j=d.parent().controller("form"),m=i.name||i.ngForm;m&&(a[m]=f);j&&d.bind("$destroy",function(){j.$removeControl(f);m&&(a[m]=p);t(f,Ta)})}}}};return a?t(V(d),{restrict:"EAC"}):d}]},sd=Wa(),td=Wa(!0),ud=/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/,vd=/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/, | |
wd=/^\s*(\-|\+)?(\d+|(\d*(\.\d*)))\s*$/,hc={text:Va,number:function(a,c,d,e,g,i){Va(a,c,d,e,g,i);e.$parsers.push(function(a){var c=X(a);return c||wd.test(a)?(e.$setValidity("number",!0),a===""?null:c?a:parseFloat(a)):(e.$setValidity("number",!1),p)});e.$formatters.push(function(a){return X(a)?"":""+a});if(d.min){var f=parseFloat(d.min),a=function(a){return!X(a)&&a<f?(e.$setValidity("min",!1),p):(e.$setValidity("min",!0),a)};e.$parsers.push(a);e.$formatters.push(a)}if(d.max){var h=parseFloat(d.max), | |
d=function(a){return!X(a)&&a>h?(e.$setValidity("max",!1),p):(e.$setValidity("max",!0),a)};e.$parsers.push(d);e.$formatters.push(d)}e.$formatters.push(function(a){return X(a)||Ya(a)?(e.$setValidity("number",!0),a):(e.$setValidity("number",!1),p)})},url:function(a,c,d,e,g,i){Va(a,c,d,e,g,i);a=function(a){return X(a)||ud.test(a)?(e.$setValidity("url",!0),a):(e.$setValidity("url",!1),p)};e.$formatters.push(a);e.$parsers.push(a)},email:function(a,c,d,e,g,i){Va(a,c,d,e,g,i);a=function(a){return X(a)||vd.test(a)? | |
(e.$setValidity("email",!0),a):(e.$setValidity("email",!1),p)};e.$formatters.push(a);e.$parsers.push(a)},radio:function(a,c,d,e){C(d.name)&&c.attr("name",Fa());c.bind("click",function(){c[0].checked&&a.$apply(function(){e.$setViewValue(d.value)})});e.$render=function(){c[0].checked=d.value==e.$viewValue};d.$observe("value",e.$render)},checkbox:function(a,c,d,e){var g=d.ngTrueValue,i=d.ngFalseValue;E(g)||(g=!0);E(i)||(i=!1);c.bind("click",function(){a.$apply(function(){e.$setViewValue(c[0].checked)})}); | |
e.$render=function(){c[0].checked=e.$viewValue};e.$formatters.push(function(a){return a===g});e.$parsers.push(function(a){return a?g:i})},hidden:q,button:q,submit:q,reset:q},ic=["$browser","$sniffer",function(a,c){return{restrict:"E",require:"?ngModel",link:function(d,e,g,i){i&&(hc[I(g.type)]||hc.text)(d,e,g,i,c,a)}}}],Sa="ng-valid",Ra="ng-invalid",pa="ng-pristine",Ua="ng-dirty",xd=["$scope","$exceptionHandler","$attrs","$element","$parse",function(a,c,d,e,g){function i(a,c){c=c?"-"+bb(c,"-"):""; | |
e.removeClass((a?Ra:Sa)+c).addClass((a?Sa:Ra)+c)}this.$modelValue=this.$viewValue=Number.NaN;this.$parsers=[];this.$formatters=[];this.$viewChangeListeners=[];this.$pristine=!0;this.$dirty=!1;this.$valid=!0;this.$invalid=!1;this.$name=d.name;var f=g(d.ngModel),h=f.assign;if(!h)throw Error(Kb+d.ngModel+" ("+va(e)+")");this.$render=q;var j=e.inheritedData("$formController")||Ta,m=0,k=this.$error={};e.addClass(pa);i(!0);this.$setValidity=function(a,c){if(k[a]!==!c){if(c){if(k[a]&&m--,!m)i(!0),this.$valid= | |
!0,this.$invalid=!1}else i(!1),this.$invalid=!0,this.$valid=!1,m++;k[a]=!c;i(c,a);j.$setValidity(a,c,this)}};this.$setPristine=function(){this.$dirty=!1;this.$pristine=!0;e.removeClass(Ua).addClass(pa)};this.$setViewValue=function(d){this.$viewValue=d;if(this.$pristine)this.$dirty=!0,this.$pristine=!1,e.removeClass(pa).addClass(Ua),j.$setDirty();n(this.$parsers,function(a){d=a(d)});if(this.$modelValue!==d)this.$modelValue=d,h(a,d),n(this.$viewChangeListeners,function(a){try{a()}catch(d){c(d)}})}; | |
var l=this;a.$watch(function(){var c=f(a);if(l.$modelValue!==c){var d=l.$formatters,e=d.length;for(l.$modelValue=c;e--;)c=d[e](c);if(l.$viewValue!==c)l.$viewValue=c,l.$render()}})}],yd=function(){return{require:["ngModel","^?form"],controller:xd,link:function(a,c,d,e){var g=e[0],i=e[1]||Ta;i.$addControl(g);c.bind("$destroy",function(){i.$removeControl(g)})}}},zd=S({require:"ngModel",link:function(a,c,d,e){e.$viewChangeListeners.push(function(){a.$eval(d.ngChange)})}}),jc=function(){return{require:"?ngModel", | |
link:function(a,c,d,e){if(e){d.required=!0;var g=function(a){if(d.required&&(X(a)||a===!1))e.$setValidity("required",!1);else return e.$setValidity("required",!0),a};e.$formatters.push(g);e.$parsers.unshift(g);d.$observe("required",function(){g(e.$viewValue)})}}}},Ad=function(){return{require:"ngModel",link:function(a,c,d,e){var g=(a=/\/(.*)\//.exec(d.ngList))&&RegExp(a[1])||d.ngList||",";e.$parsers.push(function(a){var c=[];a&&n(a.split(g),function(a){a&&c.push(U(a))});return c});e.$formatters.push(function(a){return F(a)? | |
a.join(", "):p})}}},Bd=/^(true|false|\d+)$/,Cd=function(){return{priority:100,compile:function(a,c){return Bd.test(c.ngValue)?function(a,c,g){g.$set("value",a.$eval(g.ngValue))}:function(a,c,g){a.$watch(g.ngValue,function(a){g.$set("value",a,!1)})}}}},Dd=aa(function(a,c,d){c.addClass("ng-binding").data("$binding",d.ngBind);a.$watch(d.ngBind,function(a){c.text(a==p?"":a)})}),Ed=["$interpolate",function(a){return function(c,d,e){c=a(d.attr(e.$attr.ngBindTemplate));d.addClass("ng-binding").data("$binding", | |
c);e.$observe("ngBindTemplate",function(a){d.text(a)})}}],Fd=[function(){return function(a,c,d){c.addClass("ng-binding").data("$binding",d.ngBindHtmlUnsafe);a.$watch(d.ngBindHtmlUnsafe,function(a){c.html(a||"")})}}],Gd=ob("",!0),Hd=ob("Odd",0),Id=ob("Even",1),Jd=aa({compile:function(a,c){c.$set("ngCloak",p);a.removeClass("ng-cloak")}}),Kd=[function(){return{scope:!0,controller:"@"}}],Ld=["$sniffer",function(a){return{priority:1E3,compile:function(){a.csp=!0}}}],kc={};n("click dblclick mousedown mouseup mouseover mouseout mousemove mouseenter mouseleave keydown keyup keypress".split(" "), | |
function(a){var c=da("ng-"+a);kc[c]=["$parse",function(d){return function(e,g,i){var f=d(i[c]);g.bind(I(a),function(a){e.$apply(function(){f(e,{$event:a})})})}}]});var Md=aa(function(a,c,d){c.bind("submit",function(){a.$apply(d.ngSubmit)})}),Nd=["$animator",function(a){return{transclude:"element",priority:1E3,terminal:!0,restrict:"A",compile:function(c,d,e){return function(c,d,f){var h=a(c,f),j,m;c.$watch(f.ngIf,function(a){j&&(h.leave(j),j=p);m&&(m.$destroy(),m=p);ua(a)&&(m=c.$new(),e(m,function(a){j= | |
a;h.enter(a,d.parent(),d)}))})}}}}],Od=["$http","$templateCache","$anchorScroll","$compile","$animator",function(a,c,d,e,g){return{restrict:"ECA",terminal:!0,compile:function(i,f){var h=f.ngInclude||f.src,j=f.onload||"",m=f.autoscroll;return function(f,i,n){var o=g(f,n),p=0,r,t=function(){r&&(r.$destroy(),r=null);o.leave(i.contents(),i)};f.$watch(h,function(g){var h=++p;g?(a.get(g,{cache:c}).success(function(a){h===p&&(r&&r.$destroy(),r=f.$new(),o.leave(i.contents(),i),a=w("<div/>").html(a).contents(), | |
o.enter(a,i),e(a)(r),B(m)&&(!m||f.$eval(m))&&d(),r.$emit("$includeContentLoaded"),f.$eval(j))}).error(function(){h===p&&t()}),f.$emit("$includeContentRequested")):t()})}}}}],Pd=aa({compile:function(){return{pre:function(a,c,d){a.$eval(d.ngInit)}}}}),Qd=aa({terminal:!0,priority:1E3}),Rd=["$locale","$interpolate",function(a,c){var d=/{}/g;return{restrict:"EA",link:function(e,g,i){var f=i.count,h=g.attr(i.$attr.when),j=i.offset||0,m=e.$eval(h),k={},l=c.startSymbol(),p=c.endSymbol();n(m,function(a,e){k[e]= | |
c(a.replace(d,l+f+"-"+j+p))});e.$watch(function(){var c=parseFloat(e.$eval(f));return isNaN(c)?"":(c in m||(c=a.pluralCat(c-j)),k[c](e,g,!0))},function(a){g.text(a)})}}}],Sd=["$parse","$animator",function(a,c){return{transclude:"element",priority:1E3,terminal:!0,compile:function(d,e,g){return function(d,e,h){var j=c(d,h),m=h.ngRepeat,k=m.match(/^\s*(.+)\s+in\s+(.*?)\s*(\s+track\s+by\s+(.+)\s*)?$/),l,p,o,z,r,t={$id:la};if(!k)throw Error("Expected ngRepeat in form of '_item_ in _collection_[ track by _id_]' but got '"+ | |
m+"'.");h=k[1];o=k[2];(k=k[4])?(l=a(k),p=function(a,c,e){r&&(t[r]=a);t[z]=c;t.$index=e;return l(d,t)}):p=function(a,c){return la(c)};k=h.match(/^(?:([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\))$/);if(!k)throw Error("'item' in 'item in collection' should be identifier or (key, value) but got '"+h+"'.");z=k[3]||k[1];r=k[2];var x={};d.$watchCollection(o,function(a){var c,h,k=e,l,o={},t,q,w,s,B,y,C=[];if(Xa(a))B=a;else{B=[];for(w in a)a.hasOwnProperty(w)&&w.charAt(0)!="$"&&B.push(w);B.sort()}t=B.length;h= | |
C.length=B.length;for(c=0;c<h;c++)if(w=a===B?c:B[c],s=a[w],l=p(w,s,c),x.hasOwnProperty(l))y=x[l],delete x[l],o[l]=y,C[c]=y;else if(o.hasOwnProperty(l))throw n(C,function(a){a&&a.element&&(x[a.id]=a)}),Error("Duplicates in a repeater are not allowed. Repeater: "+m+" key: "+l);else C[c]={id:l},o[l]=!1;for(w in x)if(x.hasOwnProperty(w))y=x[w],j.leave(y.element),y.element[0].$$NG_REMOVED=!0,y.scope.$destroy();c=0;for(h=B.length;c<h;c++){w=a===B?c:B[c];s=a[w];y=C[c];if(y.element){q=y.scope;l=k[0];do l= | |
l.nextSibling;while(l&&l.$$NG_REMOVED);y.element[0]!=l&&j.move(y.element,null,k);k=y.element}else q=d.$new();q[z]=s;r&&(q[r]=w);q.$index=c;q.$first=c===0;q.$last=c===t-1;q.$middle=!(q.$first||q.$last);y.element||g(q,function(a){j.enter(a,null,k);k=a;y.scope=q;y.element=a;o[y.id]=y})}x=o})}}}}],Td=["$animator",function(a){return function(c,d,e){var g=a(c,e);c.$watch(e.ngShow,function(a){g[ua(a)?"show":"hide"](d)})}}],Ud=["$animator",function(a){return function(c,d,e){var g=a(c,e);c.$watch(e.ngHide, | |
function(a){g[ua(a)?"hide":"show"](d)})}}],Vd=aa(function(a,c,d){a.$watch(d.ngStyle,function(a,d){d&&a!==d&&n(d,function(a,d){c.css(d,"")});a&&c.css(a)},!0)}),Wd=["$animator",function(a){return{restrict:"EA",require:"ngSwitch",controller:["$scope",function(){this.cases={}}],link:function(c,d,e,g){var i=a(c,e),f,h,j=[];c.$watch(e.ngSwitch||e.on,function(a){for(var d=0,l=j.length;d<l;d++)j[d].$destroy(),i.leave(h[d]);h=[];j=[];if(f=g.cases["!"+a]||g.cases["?"])c.$eval(e.change),n(f,function(a){var d= | |
c.$new();j.push(d);a.transclude(d,function(c){var d=a.element;h.push(c);i.enter(c,d.parent(),d)})})})}}}],Xd=aa({transclude:"element",priority:500,require:"^ngSwitch",compile:function(a,c,d){return function(a,g,i,f){f.cases["!"+c.ngSwitchWhen]=f.cases["!"+c.ngSwitchWhen]||[];f.cases["!"+c.ngSwitchWhen].push({transclude:d,element:g})}}}),Yd=aa({transclude:"element",priority:500,require:"^ngSwitch",compile:function(a,c,d){return function(a,c,i,f){f.cases["?"]=f.cases["?"]||[];f.cases["?"].push({transclude:d, | |
element:c})}}}),Zd=aa({controller:["$transclude","$element",function(a,c){a(function(a){c.append(a)})}]}),$d=["$http","$templateCache","$route","$anchorScroll","$compile","$controller","$animator",function(a,c,d,e,g,i,f){return{restrict:"ECA",terminal:!0,link:function(a,c,m){function k(){var f=d.current&&d.current.locals,k=f&&f.$template;if(k){o.leave(c.contents(),c);l&&(l.$destroy(),l=null);k=w("<div></div>").html(k).contents();o.enter(k,c);var k=g(k),m=d.current;l=m.scope=a.$new();if(m.controller)f.$scope= | |
l,f=i(m.controller,f),m.controllerAs&&(l[m.controllerAs]=f),c.children().data("$ngControllerController",f);k(l);l.$emit("$viewContentLoaded");l.$eval(n);e()}else o.leave(c.contents(),c),l&&(l.$destroy(),l=null)}var l,n=m.onload||"",o=f(a,m);a.$on("$routeChangeSuccess",k);k()}}}],ae=["$templateCache",function(a){return{restrict:"E",terminal:!0,compile:function(c,d){d.type=="text/ng-template"&&a.put(d.id,c[0].text)}}}],be=S({terminal:!0}),ce=["$compile","$parse",function(a,c){var d=/^\s*(.*?)(?:\s+as\s+(.*?))?(?:\s+group\s+by\s+(.*))?\s+for\s+(?:([\$\w][\$\w\d]*)|(?:\(\s*([\$\w][\$\w\d]*)\s*,\s*([\$\w][\$\w\d]*)\s*\)))\s+in\s+(.*?)(?:\s+track\s+by\s+(.*?))?$/, | |
e={$setViewValue:q};return{restrict:"E",require:["select","?ngModel"],controller:["$element","$scope","$attrs",function(a,c,d){var h=this,j={},m=e,k;h.databound=d.ngModel;h.init=function(a,c,d){m=a;k=d};h.addOption=function(c){j[c]=!0;m.$viewValue==c&&(a.val(c),k.parent()&&k.remove())};h.removeOption=function(a){this.hasOption(a)&&(delete j[a],m.$viewValue==a&&this.renderUnknownOption(a))};h.renderUnknownOption=function(c){c="? "+la(c)+" ?";k.val(c);a.prepend(k);a.val(c);k.prop("selected",!0)};h.hasOption= | |
function(a){return j.hasOwnProperty(a)};c.$on("$destroy",function(){h.renderUnknownOption=q})}],link:function(e,i,f,h){function j(a,c,d,e){d.$render=function(){var a=d.$viewValue;e.hasOption(a)?(v.parent()&&v.remove(),c.val(a),a===""&&t.prop("selected",!0)):C(a)&&t?c.val(""):e.renderUnknownOption(a)};c.bind("change",function(){a.$apply(function(){v.parent()&&v.remove();d.$setViewValue(c.val())})})}function m(a,c,d){var e;d.$render=function(){var a=new za(d.$viewValue);n(c.find("option"),function(c){c.selected= | |
B(a.get(c.value))})};a.$watch(function(){ia(e,d.$viewValue)||(e=V(d.$viewValue),d.$render())});c.bind("change",function(){a.$apply(function(){var a=[];n(c.find("option"),function(c){c.selected&&a.push(c.value)});d.$setViewValue(a)})})}function k(e,f,g){function i(){var a={"":[]},c=[""],d,h,q,v,s;q=g.$modelValue;v=u(e)||[];var z=l?qb(v):v,B,y,A;y={};s=!1;var C,D;if(o)if(t&&F(q)){s=new za([]);for(h=0;h<q.length;h++)y[k]=q[h],s.put(t(e,y),q[h])}else s=new za(q);for(A=0;B=z.length,A<B;A++){y[k]=v[l?y[l]= | |
z[A]:A];d=m(e,y)||"";if(!(h=a[d]))h=a[d]=[],c.push(d);o?d=s.remove(t?t(e,y):n(e,y))!=p:(t?(d={},d[k]=q,d=t(e,d)===t(e,y)):d=q===n(e,y),s=s||d);C=j(e,y);C=C===p?"":C;h.push({id:t?t(e,y):l?z[A]:A,label:C,selected:d})}o||(r||q===null?a[""].unshift({id:"",label:"",selected:!s}):s||a[""].unshift({id:"?",label:"",selected:!0}));y=0;for(z=c.length;y<z;y++){d=c[y];h=a[d];if(w.length<=y)q={element:E.clone().attr("label",d),label:h.label},v=[q],w.push(v),f.append(q.element);else if(v=w[y],q=v[0],q.label!=d)q.element.attr("label", | |
q.label=d);C=null;A=0;for(B=h.length;A<B;A++)if(d=h[A],s=v[A+1]){C=s.element;if(s.label!==d.label)C.text(s.label=d.label);if(s.id!==d.id)C.val(s.id=d.id);if(C[0].selected!==d.selected)C.prop("selected",s.selected=d.selected)}else d.id===""&&r?D=r:(D=x.clone()).val(d.id).attr("selected",d.selected).text(d.label),v.push({element:D,label:d.label,id:d.id,selected:d.selected}),C?C.after(D):q.element.append(D),C=D;for(A++;v.length>A;)v.pop().element.remove()}for(;w.length>y;)w.pop()[0].element.remove()} | |
var h;if(!(h=q.match(d)))throw Error("Expected ngOptions in form of '_select_ (as _label_)? for (_key_,)?_value_ in _collection_ (track by _expr_)?' but got '"+q+"'.");var j=c(h[2]||h[1]),k=h[4]||h[6],l=h[5],m=c(h[3]||""),n=c(h[2]?h[1]:k),u=c(h[7]),t=h[8]?c(h[8]):null,w=[[{element:f,label:""}]];r&&(a(r)(e),r.removeClass("ng-scope"),r.remove());f.html("");f.bind("change",function(){e.$apply(function(){var a,c=u(e)||[],d={},h,i,j,m,q,r;if(o){i=[];m=0;for(r=w.length;m<r;m++){a=w[m];j=1;for(q=a.length;j< | |
q;j++)if((h=a[j].element)[0].selected){h=h.val();l&&(d[l]=h);if(t)for(var s=0;s<c.length;s++){if(d[k]=c[s],t(e,d)==h)break}else d[k]=c[h];i.push(n(e,d))}}}else if(h=f.val(),h=="?")i=p;else if(h=="")i=null;else if(t)for(s=0;s<c.length;s++){if(d[k]=c[s],t(e,d)==h){i=n(e,d);break}}else d[k]=c[h],l&&(d[l]=h),i=n(e,d);g.$setViewValue(i)})});g.$render=i;e.$watch(i)}if(h[1]){for(var l=h[0],u=h[1],o=f.multiple,q=f.ngOptions,r=!1,t,x=w(T.createElement("option")),E=w(T.createElement("optgroup")),v=x.clone(), | |
h=0,A=i.children(),G=A.length;h<G;h++)if(A[h].value==""){t=r=A.eq(h);break}l.init(u,r,v);if(o&&(f.required||f.ngRequired)){var D=function(a){u.$setValidity("required",!f.required||a&&a.length);return a};u.$parsers.push(D);u.$formatters.unshift(D);f.$observe("required",function(){D(u.$viewValue)})}q?k(e,i,u):o?m(e,i,u):j(e,i,u,l)}}}}],de=["$interpolate",function(a){var c={addOption:q,removeOption:q};return{restrict:"E",priority:100,compile:function(d,e){if(C(e.value)){var g=a(d.text(),!0);g||e.$set("value", | |
d.text())}return function(a,d,e){var j=d.parent(),m=j.data("$selectController")||j.parent().data("$selectController");m&&m.databound?d.prop("selected",!1):m=c;g?a.$watch(g,function(a,c){e.$set("value",a);a!==c&&m.removeOption(c);m.addOption(a)}):m.addOption(e.value);d.bind("$destroy",function(){m.removeOption(e.value)})}}}}],ee=S({restrict:"E",terminal:!0});(ga=M.jQuery)?(w=ga,t(ga.fn,{scope:Ba.scope,controller:Ba.controller,injector:Ba.injector,inheritedData:Ba.inheritedData}),db("remove",!0),db("empty"), | |
db("html")):w=R;Ha.element=w;(function(a){t(a,{bootstrap:xb,copy:V,extend:t,equals:ia,element:w,forEach:n,injector:yb,noop:q,bind:$a,toJson:ha,fromJson:ub,identity:qa,isUndefined:C,isDefined:B,isString:E,isFunction:H,isObject:L,isNumber:Ya,isElement:oc,isArray:F,version:pd,isDate:ra,lowercase:I,uppercase:oa,callbacks:{counter:0},noConflict:lc});Aa=tc(M);try{Aa("ngLocale")}catch(c){Aa("ngLocale",[]).provider("$locale",fd)}Aa("ng",["ngLocale"],["$provide",function(a){a.provider("$compile",Jb).directive({a:rd, | |
input:ic,textarea:ic,form:sd,script:ae,select:ce,style:ee,option:de,ngBind:Dd,ngBindHtmlUnsafe:Fd,ngBindTemplate:Ed,ngClass:Gd,ngClassEven:Id,ngClassOdd:Hd,ngCsp:Ld,ngCloak:Jd,ngController:Kd,ngForm:td,ngHide:Ud,ngIf:Nd,ngInclude:Od,ngInit:Pd,ngNonBindable:Qd,ngPluralize:Rd,ngRepeat:Sd,ngShow:Td,ngSubmit:Md,ngStyle:Vd,ngSwitch:Wd,ngSwitchWhen:Xd,ngSwitchDefault:Yd,ngOptions:be,ngView:$d,ngTransclude:Zd,ngModel:yd,ngList:Ad,ngChange:zd,required:jc,ngRequired:jc,ngValue:Cd}).directive(pb).directive(kc); | |
a.provider({$anchorScroll:Cc,$animation:Ib,$animator:qd,$browser:Ec,$cacheFactory:Fc,$controller:Jc,$document:Kc,$exceptionHandler:Lc,$filter:Zb,$interpolate:Mc,$http:bd,$httpBackend:cd,$location:Nc,$log:Oc,$parse:Sc,$route:Vc,$routeParams:Wc,$rootScope:Xc,$q:Tc,$sniffer:Yc,$templateCache:Gc,$timeout:gd,$window:Zc})}])})(Ha);w(T).ready(function(){rc(T,xb)})})(window,document);angular.element(document).find("head").append('<style type="text/css">@charset "UTF-8";[ng\\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak{display:none;}ng\\:form{display:block;}</style>'); |
This file contains hidden or 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
function Cheese() { | |
return { | |
isGood: true | |
}; | |
} | |
function PasswordCtrl($scope) { | |
$scope.password = ''; | |
$scope.grade = function () { | |
var size = $scope.password.length; | |
if (size > 8) { | |
$scope.strength = 'strong'; | |
} else if (size > 3) { | |
$scope.strength = 'medium'; | |
} else { | |
$scope.strength = 'weak'; | |
} | |
}; | |
} | |
function PhoneDetailCtrl($scope, $routeParams, $http) { | |
$http.get('phones/' + $routeParams.phoneId + '.json').success(function (data) { | |
$scope.phone = data; | |
}); | |
} |
This file contains hidden or 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
var isCommonJS = typeof window == "undefined" && typeof exports == "object"; | |
/** | |
* Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework. | |
* | |
* @namespace | |
*/ | |
var jasmine = {}; | |
if (isCommonJS) exports.jasmine = jasmine; | |
/** | |
* @private | |
*/ | |
jasmine.unimplementedMethod_ = function() { | |
throw new Error("unimplemented method"); | |
}; | |
/** | |
* Use <code>jasmine.undefined</code> instead of <code>undefined</code>, since <code>undefined</code> is just | |
* a plain old variable and may be redefined by somebody else. | |
* | |
* @private | |
*/ | |
jasmine.undefined = jasmine.___undefined___; | |
/** | |
* Show diagnostic messages in the console if set to true | |
* | |
*/ | |
jasmine.VERBOSE = false; | |
/** | |
* Default interval in milliseconds for event loop yields (e.g. to allow network activity or to refresh the screen with the HTML-based runner). Small values here may result in slow test running. Zero means no updates until all tests have completed. | |
* | |
*/ | |
jasmine.DEFAULT_UPDATE_INTERVAL = 250; | |
/** | |
* Maximum levels of nesting that will be included when an object is pretty-printed | |
*/ | |
jasmine.MAX_PRETTY_PRINT_DEPTH = 40; | |
/** | |
* Default timeout interval in milliseconds for waitsFor() blocks. | |
*/ | |
jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000; | |
/** | |
* By default exceptions thrown in the context of a test are caught by jasmine so that it can run the remaining tests in the suite. | |
* Set to false to let the exception bubble up in the browser. | |
* | |
*/ | |
jasmine.CATCH_EXCEPTIONS = true; | |
jasmine.getGlobal = function() { | |
function getGlobal() { | |
return this; | |
} | |
return getGlobal(); | |
}; | |
/** | |
* Allows for bound functions to be compared. Internal use only. | |
* | |
* @ignore | |
* @private | |
* @param base {Object} bound 'this' for the function | |
* @param name {Function} function to find | |
*/ | |
jasmine.bindOriginal_ = function(base, name) { | |
var original = base[name]; | |
if (original.apply) { | |
return function() { | |
return original.apply(base, arguments); | |
}; | |
} else { | |
// IE support | |
return jasmine.getGlobal()[name]; | |
} | |
}; | |
jasmine.setTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'setTimeout'); | |
jasmine.clearTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearTimeout'); | |
jasmine.setInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'setInterval'); | |
jasmine.clearInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearInterval'); | |
jasmine.MessageResult = function(values) { | |
this.type = 'log'; | |
this.values = values; | |
this.trace = new Error(); // todo: test better | |
}; | |
jasmine.MessageResult.prototype.toString = function() { | |
var text = ""; | |
for (var i = 0; i < this.values.length; i++) { | |
if (i > 0) text += " "; | |
if (jasmine.isString_(this.values[i])) { | |
text += this.values[i]; | |
} else { | |
text += jasmine.pp(this.values[i]); | |
} | |
} | |
return text; | |
}; | |
jasmine.ExpectationResult = function(params) { | |
this.type = 'expect'; | |
this.matcherName = params.matcherName; | |
this.passed_ = params.passed; | |
this.expected = params.expected; | |
this.actual = params.actual; | |
this.message = this.passed_ ? 'Passed.' : params.message; | |
var trace = (params.trace || new Error(this.message)); | |
this.trace = this.passed_ ? '' : trace; | |
}; | |
jasmine.ExpectationResult.prototype.toString = function () { | |
return this.message; | |
}; | |
jasmine.ExpectationResult.prototype.passed = function () { | |
return this.passed_; | |
}; | |
/** | |
* Getter for the Jasmine environment. Ensures one gets created | |
*/ | |
jasmine.getEnv = function() { | |
var env = jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env(); | |
return env; | |
}; | |
/** | |
* @ignore | |
* @private | |
* @param value | |
* @returns {Boolean} | |
*/ | |
jasmine.isArray_ = function(value) { | |
return jasmine.isA_("Array", value); | |
}; | |
/** | |
* @ignore | |
* @private | |
* @param value | |
* @returns {Boolean} | |
*/ | |
jasmine.isString_ = function(value) { | |
return jasmine.isA_("String", value); | |
}; | |
/** | |
* @ignore | |
* @private | |
* @param value | |
* @returns {Boolean} | |
*/ | |
jasmine.isNumber_ = function(value) { | |
return jasmine.isA_("Number", value); | |
}; | |
/** | |
* @ignore | |
* @private | |
* @param {String} typeName | |
* @param value | |
* @returns {Boolean} | |
*/ | |
jasmine.isA_ = function(typeName, value) { | |
return Object.prototype.toString.apply(value) === '[object ' + typeName + ']'; | |
}; | |
/** | |
* Pretty printer for expecations. Takes any object and turns it into a human-readable string. | |
* | |
* @param value {Object} an object to be outputted | |
* @returns {String} | |
*/ | |
jasmine.pp = function(value) { | |
var stringPrettyPrinter = new jasmine.StringPrettyPrinter(); | |
stringPrettyPrinter.format(value); | |
return stringPrettyPrinter.string; | |
}; | |
/** | |
* Returns true if the object is a DOM Node. | |
* | |
* @param {Object} obj object to check | |
* @returns {Boolean} | |
*/ | |
jasmine.isDomNode = function(obj) { | |
return obj.nodeType > 0; | |
}; | |
/** | |
* Returns a matchable 'generic' object of the class type. For use in expecations of type when values don't matter. | |
* | |
* @example | |
* // don't care about which function is passed in, as long as it's a function | |
* expect(mySpy).toHaveBeenCalledWith(jasmine.any(Function)); | |
* | |
* @param {Class} clazz | |
* @returns matchable object of the type clazz | |
*/ | |
jasmine.any = function(clazz) { | |
return new jasmine.Matchers.Any(clazz); | |
}; | |
/** | |
* Returns a matchable subset of a JSON object. For use in expectations when you don't care about all of the | |
* attributes on the object. | |
* | |
* @example | |
* // don't care about any other attributes than foo. | |
* expect(mySpy).toHaveBeenCalledWith(jasmine.objectContaining({foo: "bar"}); | |
* | |
* @param sample {Object} sample | |
* @returns matchable object for the sample | |
*/ | |
jasmine.objectContaining = function (sample) { | |
return new jasmine.Matchers.ObjectContaining(sample); | |
}; | |
/** | |
* Jasmine Spies are test doubles that can act as stubs, spies, fakes or when used in an expecation, mocks. | |
* | |
* Spies should be created in test setup, before expectations. They can then be checked, using the standard Jasmine | |
* expectation syntax. Spies can be checked if they were called or not and what the calling params were. | |
* | |
* A Spy has the following fields: wasCalled, callCount, mostRecentCall, and argsForCall (see docs). | |
* | |
* Spies are torn down at the end of every spec. | |
* | |
* Note: Do <b>not</b> call new jasmine.Spy() directly - a spy must be created using spyOn, jasmine.createSpy or jasmine.createSpyObj. | |
* | |
* @example | |
* // a stub | |
* var myStub = jasmine.createSpy('myStub'); // can be used anywhere | |
* | |
* // spy example | |
* var foo = { | |
* not: function(bool) { return !bool; } | |
* } | |
* | |
* // actual foo.not will not be called, execution stops | |
* spyOn(foo, 'not'); | |
// foo.not spied upon, execution will continue to implementation | |
* spyOn(foo, 'not').andCallThrough(); | |
* | |
* // fake example | |
* var foo = { | |
* not: function(bool) { return !bool; } | |
* } | |
* | |
* // foo.not(val) will return val | |
* spyOn(foo, 'not').andCallFake(function(value) {return value;}); | |
* | |
* // mock example | |
* foo.not(7 == 7); | |
* expect(foo.not).toHaveBeenCalled(); | |
* expect(foo.not).toHaveBeenCalledWith(true); | |
* | |
* @constructor | |
* @see spyOn, jasmine.createSpy, jasmine.createSpyObj | |
* @param {String} name | |
*/ | |
jasmine.Spy = function(name) { | |
/** | |
* The name of the spy, if provided. | |
*/ | |
this.identity = name || 'unknown'; | |
/** | |
* Is this Object a spy? | |
*/ | |
this.isSpy = true; | |
/** | |
* The actual function this spy stubs. | |
*/ | |
this.plan = function() { | |
}; | |
/** | |
* Tracking of the most recent call to the spy. | |
* @example | |
* var mySpy = jasmine.createSpy('foo'); | |
* mySpy(1, 2); | |
* mySpy.mostRecentCall.args = [1, 2]; | |
*/ | |
this.mostRecentCall = {}; | |
/** | |
* Holds arguments for each call to the spy, indexed by call count | |
* @example | |
* var mySpy = jasmine.createSpy('foo'); | |
* mySpy(1, 2); | |
* mySpy(7, 8); | |
* mySpy.mostRecentCall.args = [7, 8]; | |
* mySpy.argsForCall[0] = [1, 2]; | |
* mySpy.argsForCall[1] = [7, 8]; | |
*/ | |
this.argsForCall = []; | |
this.calls = []; | |
}; | |
/** | |
* Tells a spy to call through to the actual implemenatation. | |
* | |
* @example | |
* var foo = { | |
* bar: function() { // do some stuff } | |
* } | |
* | |
* // defining a spy on an existing property: foo.bar | |
* spyOn(foo, 'bar').andCallThrough(); | |
*/ | |
jasmine.Spy.prototype.andCallThrough = function() { | |
this.plan = this.originalValue; | |
return this; | |
}; | |
/** | |
* For setting the return value of a spy. | |
* | |
* @example | |
* // defining a spy from scratch: foo() returns 'baz' | |
* var foo = jasmine.createSpy('spy on foo').andReturn('baz'); | |
* | |
* // defining a spy on an existing property: foo.bar() returns 'baz' | |
* spyOn(foo, 'bar').andReturn('baz'); | |
* | |
* @param {Object} value | |
*/ | |
jasmine.Spy.prototype.andReturn = function(value) { | |
this.plan = function() { | |
return value; | |
}; | |
return this; | |
}; | |
/** | |
* For throwing an exception when a spy is called. | |
* | |
* @example | |
* // defining a spy from scratch: foo() throws an exception w/ message 'ouch' | |
* var foo = jasmine.createSpy('spy on foo').andThrow('baz'); | |
* | |
* // defining a spy on an existing property: foo.bar() throws an exception w/ message 'ouch' | |
* spyOn(foo, 'bar').andThrow('baz'); | |
* | |
* @param {String} exceptionMsg | |
*/ | |
jasmine.Spy.prototype.andThrow = function(exceptionMsg) { | |
this.plan = function() { | |
throw exceptionMsg; | |
}; | |
return this; | |
}; | |
/** | |
* Calls an alternate implementation when a spy is called. | |
* | |
* @example | |
* var baz = function() { | |
* // do some stuff, return something | |
* } | |
* // defining a spy from scratch: foo() calls the function baz | |
* var foo = jasmine.createSpy('spy on foo').andCall(baz); | |
* | |
* // defining a spy on an existing property: foo.bar() calls an anonymnous function | |
* spyOn(foo, 'bar').andCall(function() { return 'baz';} ); | |
* | |
* @param {Function} fakeFunc | |
*/ | |
jasmine.Spy.prototype.andCallFake = function(fakeFunc) { | |
this.plan = fakeFunc; | |
return this; | |
}; | |
/** | |
* Resets all of a spy's the tracking variables so that it can be used again. | |
* | |
* @example | |
* spyOn(foo, 'bar'); | |
* | |
* foo.bar(); | |
* | |
* expect(foo.bar.callCount).toEqual(1); | |
* | |
* foo.bar.reset(); | |
* | |
* expect(foo.bar.callCount).toEqual(0); | |
*/ | |
jasmine.Spy.prototype.reset = function() { | |
this.wasCalled = false; | |
this.callCount = 0; | |
this.argsForCall = []; | |
this.calls = []; | |
this.mostRecentCall = {}; | |
}; | |
jasmine.createSpy = function(name) { | |
var spyObj = function() { | |
spyObj.wasCalled = true; | |
spyObj.callCount++; | |
var args = jasmine.util.argsToArray(arguments); | |
spyObj.mostRecentCall.object = this; | |
spyObj.mostRecentCall.args = args; | |
spyObj.argsForCall.push(args); | |
spyObj.calls.push({object: this, args: args}); | |
return spyObj.plan.apply(this, arguments); | |
}; | |
var spy = new jasmine.Spy(name); | |
for (var prop in spy) { | |
spyObj[prop] = spy[prop]; | |
} | |
spyObj.reset(); | |
return spyObj; | |
}; | |
/** | |
* Determines whether an object is a spy. | |
* | |
* @param {jasmine.Spy|Object} putativeSpy | |
* @returns {Boolean} | |
*/ | |
jasmine.isSpy = function(putativeSpy) { | |
return putativeSpy && putativeSpy.isSpy; | |
}; | |
/** | |
* Creates a more complicated spy: an Object that has every property a function that is a spy. Used for stubbing something | |
* large in one call. | |
* | |
* @param {String} baseName name of spy class | |
* @param {Array} methodNames array of names of methods to make spies | |
*/ | |
jasmine.createSpyObj = function(baseName, methodNames) { | |
if (!jasmine.isArray_(methodNames) || methodNames.length === 0) { | |
throw new Error('createSpyObj requires a non-empty array of method names to create spies for'); | |
} | |
var obj = {}; | |
for (var i = 0; i < methodNames.length; i++) { | |
obj[methodNames[i]] = jasmine.createSpy(baseName + '.' + methodNames[i]); | |
} | |
return obj; | |
}; | |
/** | |
* All parameters are pretty-printed and concatenated together, then written to the current spec's output. | |
* | |
* Be careful not to leave calls to <code>jasmine.log</code> in production code. | |
*/ | |
jasmine.log = function() { | |
var spec = jasmine.getEnv().currentSpec; | |
spec.log.apply(spec, arguments); | |
}; | |
/** | |
* Function that installs a spy on an existing object's method name. Used within a Spec to create a spy. | |
* | |
* @example | |
* // spy example | |
* var foo = { | |
* not: function(bool) { return !bool; } | |
* } | |
* spyOn(foo, 'not'); // actual foo.not will not be called, execution stops | |
* | |
* @see jasmine.createSpy | |
* @param obj | |
* @param methodName | |
* @return {jasmine.Spy} a Jasmine spy that can be chained with all spy methods | |
*/ | |
var spyOn = function(obj, methodName) { | |
return jasmine.getEnv().currentSpec.spyOn(obj, methodName); | |
}; | |
if (isCommonJS) exports.spyOn = spyOn; | |
/** | |
* Creates a Jasmine spec that will be added to the current suite. | |
* | |
* // TODO: pending tests | |
* | |
* @example | |
* it('should be true', function() { | |
* expect(true).toEqual(true); | |
* }); | |
* | |
* @param {String} desc description of this specification | |
* @param {Function} func defines the preconditions and expectations of the spec | |
*/ | |
var it = function(desc, func) { | |
return jasmine.getEnv().it(desc, func); | |
}; | |
if (isCommonJS) exports.it = it; | |
/** | |
* Creates a <em>disabled</em> Jasmine spec. | |
* | |
* A convenience method that allows existing specs to be disabled temporarily during development. | |
* | |
* @param {String} desc description of this specification | |
* @param {Function} func defines the preconditions and expectations of the spec | |
*/ | |
var xit = function(desc, func) { | |
return jasmine.getEnv().xit(desc, func); | |
}; | |
if (isCommonJS) exports.xit = xit; | |
/** | |
* Starts a chain for a Jasmine expectation. | |
* | |
* It is passed an Object that is the actual value and should chain to one of the many | |
* jasmine.Matchers functions. | |
* | |
* @param {Object} actual Actual value to test against and expected value | |
* @return {jasmine.Matchers} | |
*/ | |
var expect = function(actual) { | |
return jasmine.getEnv().currentSpec.expect(actual); | |
}; | |
if (isCommonJS) exports.expect = expect; | |
/** | |
* Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs. | |
* | |
* @param {Function} func Function that defines part of a jasmine spec. | |
*/ | |
var runs = function(func) { | |
jasmine.getEnv().currentSpec.runs(func); | |
}; | |
if (isCommonJS) exports.runs = runs; | |
/** | |
* Waits a fixed time period before moving to the next block. | |
* | |
* @deprecated Use waitsFor() instead | |
* @param {Number} timeout milliseconds to wait | |
*/ | |
var waits = function(timeout) { | |
jasmine.getEnv().currentSpec.waits(timeout); | |
}; | |
if (isCommonJS) exports.waits = waits; | |
/** | |
* Waits for the latchFunction to return true before proceeding to the next block. | |
* | |
* @param {Function} latchFunction | |
* @param {String} optional_timeoutMessage | |
* @param {Number} optional_timeout | |
*/ | |
var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) { | |
jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments); | |
}; | |
if (isCommonJS) exports.waitsFor = waitsFor; | |
/** | |
* A function that is called before each spec in a suite. | |
* | |
* Used for spec setup, including validating assumptions. | |
* | |
* @param {Function} beforeEachFunction | |
*/ | |
var beforeEach = function(beforeEachFunction) { | |
jasmine.getEnv().beforeEach(beforeEachFunction); | |
}; | |
if (isCommonJS) exports.beforeEach = beforeEach; | |
/** | |
* A function that is called after each spec in a suite. | |
* | |
* Used for restoring any state that is hijacked during spec execution. | |
* | |
* @param {Function} afterEachFunction | |
*/ | |
var afterEach = function(afterEachFunction) { | |
jasmine.getEnv().afterEach(afterEachFunction); | |
}; | |
if (isCommonJS) exports.afterEach = afterEach; | |
/** | |
* Defines a suite of specifications. | |
* | |
* Stores the description and all defined specs in the Jasmine environment as one suite of specs. Variables declared | |
* are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be nested, allowing for specialization | |
* of setup in some tests. | |
* | |
* @example | |
* // TODO: a simple suite | |
* | |
* // TODO: a simple suite with a nested describe block | |
* | |
* @param {String} description A string, usually the class under test. | |
* @param {Function} specDefinitions function that defines several specs. | |
*/ | |
var describe = function(description, specDefinitions) { | |
return jasmine.getEnv().describe(description, specDefinitions); | |
}; | |
if (isCommonJS) exports.describe = describe; | |
/** | |
* Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development. | |
* | |
* @param {String} description A string, usually the class under test. | |
* @param {Function} specDefinitions function that defines several specs. | |
*/ | |
var xdescribe = function(description, specDefinitions) { | |
return jasmine.getEnv().xdescribe(description, specDefinitions); | |
}; | |
if (isCommonJS) exports.xdescribe = xdescribe; | |
// Provide the XMLHttpRequest class for IE 5.x-6.x: | |
jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() { | |
function tryIt(f) { | |
try { | |
return f(); | |
} catch(e) { | |
} | |
return null; | |
} | |
var xhr = tryIt(function() { | |
return new ActiveXObject("Msxml2.XMLHTTP.6.0"); | |
}) || | |
tryIt(function() { | |
return new ActiveXObject("Msxml2.XMLHTTP.3.0"); | |
}) || | |
tryIt(function() { | |
return new ActiveXObject("Msxml2.XMLHTTP"); | |
}) || | |
tryIt(function() { | |
return new ActiveXObject("Microsoft.XMLHTTP"); | |
}); | |
if (!xhr) throw new Error("This browser does not support XMLHttpRequest."); | |
return xhr; | |
} : XMLHttpRequest; | |
/** | |
* @namespace | |
*/ | |
jasmine.util = {}; | |
/** | |
* Declare that a child class inherit it's prototype from the parent class. | |
* | |
* @private | |
* @param {Function} childClass | |
* @param {Function} parentClass | |
*/ | |
jasmine.util.inherit = function(childClass, parentClass) { | |
/** | |
* @private | |
*/ | |
var subclass = function() { | |
}; | |
subclass.prototype = parentClass.prototype; | |
childClass.prototype = new subclass(); | |
}; | |
jasmine.util.formatException = function(e) { | |
var lineNumber; | |
if (e.line) { | |
lineNumber = e.line; | |
} | |
else if (e.lineNumber) { | |
lineNumber = e.lineNumber; | |
} | |
var file; | |
if (e.sourceURL) { | |
file = e.sourceURL; | |
} | |
else if (e.fileName) { | |
file = e.fileName; | |
} | |
var message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString(); | |
if (file && lineNumber) { | |
message += ' in ' + file + ' (line ' + lineNumber + ')'; | |
} | |
return message; | |
}; | |
jasmine.util.htmlEscape = function(str) { | |
if (!str) return str; | |
return str.replace(/&/g, '&') | |
.replace(/</g, '<') | |
.replace(/>/g, '>'); | |
}; | |
jasmine.util.argsToArray = function(args) { | |
var arrayOfArgs = []; | |
for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]); | |
return arrayOfArgs; | |
}; | |
jasmine.util.extend = function(destination, source) { | |
for (var property in source) destination[property] = source[property]; | |
return destination; | |
}; | |
/** | |
* Environment for Jasmine | |
* | |
* @constructor | |
*/ | |
jasmine.Env = function() { | |
this.currentSpec = null; | |
this.currentSuite = null; | |
this.currentRunner_ = new jasmine.Runner(this); | |
this.reporter = new jasmine.MultiReporter(); | |
this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL; | |
this.defaultTimeoutInterval = jasmine.DEFAULT_TIMEOUT_INTERVAL; | |
this.lastUpdate = 0; | |
this.specFilter = function() { | |
return true; | |
}; | |
this.nextSpecId_ = 0; | |
this.nextSuiteId_ = 0; | |
this.equalityTesters_ = []; | |
// wrap matchers | |
this.matchersClass = function() { | |
jasmine.Matchers.apply(this, arguments); | |
}; | |
jasmine.util.inherit(this.matchersClass, jasmine.Matchers); | |
jasmine.Matchers.wrapInto_(jasmine.Matchers.prototype, this.matchersClass); | |
}; | |
jasmine.Env.prototype.setTimeout = jasmine.setTimeout; | |
jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout; | |
jasmine.Env.prototype.setInterval = jasmine.setInterval; | |
jasmine.Env.prototype.clearInterval = jasmine.clearInterval; | |
/** | |
* @returns an object containing jasmine version build info, if set. | |
*/ | |
jasmine.Env.prototype.version = function () { | |
if (jasmine.version_) { | |
return jasmine.version_; | |
} else { | |
throw new Error('Version not set'); | |
} | |
}; | |
/** | |
* @returns string containing jasmine version build info, if set. | |
*/ | |
jasmine.Env.prototype.versionString = function() { | |
if (!jasmine.version_) { | |
return "version unknown"; | |
} | |
var version = this.version(); | |
var versionString = version.major + "." + version.minor + "." + version.build; | |
if (version.release_candidate) { | |
versionString += ".rc" + version.release_candidate; | |
} | |
versionString += " revision " + version.revision; | |
return versionString; | |
}; | |
/** | |
* @returns a sequential integer starting at 0 | |
*/ | |
jasmine.Env.prototype.nextSpecId = function () { | |
return this.nextSpecId_++; | |
}; | |
/** | |
* @returns a sequential integer starting at 0 | |
*/ | |
jasmine.Env.prototype.nextSuiteId = function () { | |
return this.nextSuiteId_++; | |
}; | |
/** | |
* Register a reporter to receive status updates from Jasmine. | |
* @param {jasmine.Reporter} reporter An object which will receive status updates. | |
*/ | |
jasmine.Env.prototype.addReporter = function(reporter) { | |
this.reporter.addReporter(reporter); | |
}; | |
jasmine.Env.prototype.execute = function() { | |
this.currentRunner_.execute(); | |
}; | |
jasmine.Env.prototype.describe = function(description, specDefinitions) { | |
var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite); | |
var parentSuite = this.currentSuite; | |
if (parentSuite) { | |
parentSuite.add(suite); | |
} else { | |
this.currentRunner_.add(suite); | |
} | |
this.currentSuite = suite; | |
var declarationError = null; | |
try { | |
specDefinitions.call(suite); | |
} catch(e) { | |
declarationError = e; | |
} | |
if (declarationError) { | |
this.it("encountered a declaration exception", function() { | |
throw declarationError; | |
}); | |
} | |
this.currentSuite = parentSuite; | |
return suite; | |
}; | |
jasmine.Env.prototype.beforeEach = function(beforeEachFunction) { | |
if (this.currentSuite) { | |
this.currentSuite.beforeEach(beforeEachFunction); | |
} else { | |
this.currentRunner_.beforeEach(beforeEachFunction); | |
} | |
}; | |
jasmine.Env.prototype.currentRunner = function () { | |
return this.currentRunner_; | |
}; | |
jasmine.Env.prototype.afterEach = function(afterEachFunction) { | |
if (this.currentSuite) { | |
this.currentSuite.afterEach(afterEachFunction); | |
} else { | |
this.currentRunner_.afterEach(afterEachFunction); | |
} | |
}; | |
jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) { | |
return { | |
execute: function() { | |
} | |
}; | |
}; | |
jasmine.Env.prototype.it = function(description, func) { | |
var spec = new jasmine.Spec(this, this.currentSuite, description); | |
this.currentSuite.add(spec); | |
this.currentSpec = spec; | |
if (func) { | |
spec.runs(func); | |
} | |
return spec; | |
}; | |
jasmine.Env.prototype.xit = function(desc, func) { | |
return { | |
id: this.nextSpecId(), | |
runs: function() { | |
} | |
}; | |
}; | |
jasmine.Env.prototype.compareRegExps_ = function(a, b, mismatchKeys, mismatchValues) { | |
if (a.source != b.source) | |
mismatchValues.push("expected pattern /" + b.source + "/ is not equal to the pattern /" + a.source + "/"); | |
if (a.ignoreCase != b.ignoreCase) | |
mismatchValues.push("expected modifier i was" + (b.ignoreCase ? " " : " not ") + "set and does not equal the origin modifier"); | |
if (a.global != b.global) | |
mismatchValues.push("expected modifier g was" + (b.global ? " " : " not ") + "set and does not equal the origin modifier"); | |
if (a.multiline != b.multiline) | |
mismatchValues.push("expected modifier m was" + (b.multiline ? " " : " not ") + "set and does not equal the origin modifier"); | |
if (a.sticky != b.sticky) | |
mismatchValues.push("expected modifier y was" + (b.sticky ? " " : " not ") + "set and does not equal the origin modifier"); | |
return (mismatchValues.length === 0); | |
}; | |
jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) { | |
if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) { | |
return true; | |
} | |
a.__Jasmine_been_here_before__ = b; | |
b.__Jasmine_been_here_before__ = a; | |
var hasKey = function(obj, keyName) { | |
return obj !== null && obj[keyName] !== jasmine.undefined; | |
}; | |
for (var property in b) { | |
if (!hasKey(a, property) && hasKey(b, property)) { | |
mismatchKeys.push("expected has key '" + property + "', but missing from actual."); | |
} | |
} | |
for (property in a) { | |
if (!hasKey(b, property) && hasKey(a, property)) { | |
mismatchKeys.push("expected missing key '" + property + "', but present in actual."); | |
} | |
} | |
for (property in b) { | |
if (property == '__Jasmine_been_here_before__') continue; | |
if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) { | |
mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "' in actual."); | |
} | |
} | |
if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) { | |
mismatchValues.push("arrays were not the same length"); | |
} | |
delete a.__Jasmine_been_here_before__; | |
delete b.__Jasmine_been_here_before__; | |
return (mismatchKeys.length === 0 && mismatchValues.length === 0); | |
}; | |
jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) { | |
mismatchKeys = mismatchKeys || []; | |
mismatchValues = mismatchValues || []; | |
for (var i = 0; i < this.equalityTesters_.length; i++) { | |
var equalityTester = this.equalityTesters_[i]; | |
var result = equalityTester(a, b, this, mismatchKeys, mismatchValues); | |
if (result !== jasmine.undefined) return result; | |
} | |
if (a === b) return true; | |
if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) { | |
return (a == jasmine.undefined && b == jasmine.undefined); | |
} | |
if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) { | |
return a === b; | |
} | |
if (a instanceof Date && b instanceof Date) { | |
return a.getTime() == b.getTime(); | |
} | |
if (a.jasmineMatches) { | |
return a.jasmineMatches(b); | |
} | |
if (b.jasmineMatches) { | |
return b.jasmineMatches(a); | |
} | |
if (a instanceof jasmine.Matchers.ObjectContaining) { | |
return a.matches(b); | |
} | |
if (b instanceof jasmine.Matchers.ObjectContaining) { | |
return b.matches(a); | |
} | |
if (jasmine.isString_(a) && jasmine.isString_(b)) { | |
return (a == b); | |
} | |
if (jasmine.isNumber_(a) && jasmine.isNumber_(b)) { | |
return (a == b); | |
} | |
if (a instanceof RegExp && b instanceof RegExp) { | |
return this.compareRegExps_(a, b, mismatchKeys, mismatchValues); | |
} | |
if (typeof a === "object" && typeof b === "object") { | |
return this.compareObjects_(a, b, mismatchKeys, mismatchValues); | |
} | |
//Straight check | |
return (a === b); | |
}; | |
jasmine.Env.prototype.contains_ = function(haystack, needle) { | |
if (jasmine.isArray_(haystack)) { | |
for (var i = 0; i < haystack.length; i++) { | |
if (this.equals_(haystack[i], needle)) return true; | |
} | |
return false; | |
} | |
return haystack.indexOf(needle) >= 0; | |
}; | |
jasmine.Env.prototype.addEqualityTester = function(equalityTester) { | |
this.equalityTesters_.push(equalityTester); | |
}; | |
/** No-op base class for Jasmine reporters. | |
* | |
* @constructor | |
*/ | |
jasmine.Reporter = function() { | |
}; | |
//noinspection JSUnusedLocalSymbols | |
jasmine.Reporter.prototype.reportRunnerStarting = function(runner) { | |
}; | |
//noinspection JSUnusedLocalSymbols | |
jasmine.Reporter.prototype.reportRunnerResults = function(runner) { | |
}; | |
//noinspection JSUnusedLocalSymbols | |
jasmine.Reporter.prototype.reportSuiteResults = function(suite) { | |
}; | |
//noinspection JSUnusedLocalSymbols | |
jasmine.Reporter.prototype.reportSpecStarting = function(spec) { | |
}; | |
//noinspection JSUnusedLocalSymbols | |
jasmine.Reporter.prototype.reportSpecResults = function(spec) { | |
}; | |
//noinspection JSUnusedLocalSymbols | |
jasmine.Reporter.prototype.log = function(str) { | |
}; | |
/** | |
* Blocks are functions with executable code that make up a spec. | |
* | |
* @constructor | |
* @param {jasmine.Env} env | |
* @param {Function} func | |
* @param {jasmine.Spec} spec | |
*/ | |
jasmine.Block = function(env, func, spec) { | |
this.env = env; | |
this.func = func; | |
this.spec = spec; | |
}; | |
jasmine.Block.prototype.execute = function(onComplete) { | |
if (!jasmine.CATCH_EXCEPTIONS) { | |
this.func.apply(this.spec); | |
} | |
else { | |
try { | |
this.func.apply(this.spec); | |
} catch (e) { | |
this.spec.fail(e); | |
} | |
} | |
onComplete(); | |
}; | |
/** JavaScript API reporter. | |
* | |
* @constructor | |
*/ | |
jasmine.JsApiReporter = function() { | |
this.started = false; | |
this.finished = false; | |
this.suites_ = []; | |
this.results_ = {}; | |
}; | |
jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) { | |
this.started = true; | |
var suites = runner.topLevelSuites(); | |
for (var i = 0; i < suites.length; i++) { | |
var suite = suites[i]; | |
this.suites_.push(this.summarize_(suite)); | |
} | |
}; | |
jasmine.JsApiReporter.prototype.suites = function() { | |
return this.suites_; | |
}; | |
jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) { | |
var isSuite = suiteOrSpec instanceof jasmine.Suite; | |
var summary = { | |
id: suiteOrSpec.id, | |
name: suiteOrSpec.description, | |
type: isSuite ? 'suite' : 'spec', | |
children: [] | |
}; | |
if (isSuite) { | |
var children = suiteOrSpec.children(); | |
for (var i = 0; i < children.length; i++) { | |
summary.children.push(this.summarize_(children[i])); | |
} | |
} | |
return summary; | |
}; | |
jasmine.JsApiReporter.prototype.results = function() { | |
return this.results_; | |
}; | |
jasmine.JsApiReporter.prototype.resultsForSpec = function(specId) { | |
return this.results_[specId]; | |
}; | |
//noinspection JSUnusedLocalSymbols | |
jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) { | |
this.finished = true; | |
}; | |
//noinspection JSUnusedLocalSymbols | |
jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) { | |
}; | |
//noinspection JSUnusedLocalSymbols | |
jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) { | |
this.results_[spec.id] = { | |
messages: spec.results().getItems(), | |
result: spec.results().failedCount > 0 ? "failed" : "passed" | |
}; | |
}; | |
//noinspection JSUnusedLocalSymbols | |
jasmine.JsApiReporter.prototype.log = function(str) { | |
}; | |
jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){ | |
var results = {}; | |
for (var i = 0; i < specIds.length; i++) { | |
var specId = specIds[i]; | |
results[specId] = this.summarizeResult_(this.results_[specId]); | |
} | |
return results; | |
}; | |
jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){ | |
var summaryMessages = []; | |
var messagesLength = result.messages.length; | |
for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) { | |
var resultMessage = result.messages[messageIndex]; | |
summaryMessages.push({ | |
text: resultMessage.type == 'log' ? resultMessage.toString() : jasmine.undefined, | |
passed: resultMessage.passed ? resultMessage.passed() : true, | |
type: resultMessage.type, | |
message: resultMessage.message, | |
trace: { | |
stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined | |
} | |
}); | |
} | |
return { | |
result : result.result, | |
messages : summaryMessages | |
}; | |
}; | |
/** | |
* @constructor | |
* @param {jasmine.Env} env | |
* @param actual | |
* @param {jasmine.Spec} spec | |
*/ | |
jasmine.Matchers = function(env, actual, spec, opt_isNot) { | |
this.env = env; | |
this.actual = actual; | |
this.spec = spec; | |
this.isNot = opt_isNot || false; | |
this.reportWasCalled_ = false; | |
}; | |
// todo: @deprecated as of Jasmine 0.11, remove soon [xw] | |
jasmine.Matchers.pp = function(str) { | |
throw new Error("jasmine.Matchers.pp() is no longer supported, please use jasmine.pp() instead!"); | |
}; | |
// todo: @deprecated Deprecated as of Jasmine 0.10. Rewrite your custom matchers to return true or false. [xw] | |
jasmine.Matchers.prototype.report = function(result, failing_message, details) { | |
throw new Error("As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs"); | |
}; | |
jasmine.Matchers.wrapInto_ = function(prototype, matchersClass) { | |
for (var methodName in prototype) { | |
if (methodName == 'report') continue; | |
var orig = prototype[methodName]; | |
matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig); | |
} | |
}; | |
jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) { | |
return function() { | |
var matcherArgs = jasmine.util.argsToArray(arguments); | |
var result = matcherFunction.apply(this, arguments); | |
if (this.isNot) { | |
result = !result; | |
} | |
if (this.reportWasCalled_) return result; | |
var message; | |
if (!result) { | |
if (this.message) { | |
message = this.message.apply(this, arguments); | |
if (jasmine.isArray_(message)) { | |
message = message[this.isNot ? 1 : 0]; | |
} | |
} else { | |
var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); }); | |
message = "Expected " + jasmine.pp(this.actual) + (this.isNot ? " not " : " ") + englishyPredicate; | |
if (matcherArgs.length > 0) { | |
for (var i = 0; i < matcherArgs.length; i++) { | |
if (i > 0) message += ","; | |
message += " " + jasmine.pp(matcherArgs[i]); | |
} | |
} | |
message += "."; | |
} | |
} | |
var expectationResult = new jasmine.ExpectationResult({ | |
matcherName: matcherName, | |
passed: result, | |
expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0], | |
actual: this.actual, | |
message: message | |
}); | |
this.spec.addMatcherResult(expectationResult); | |
return jasmine.undefined; | |
}; | |
}; | |
/** | |
* toBe: compares the actual to the expected using === | |
* @param expected | |
*/ | |
jasmine.Matchers.prototype.toBe = function(expected) { | |
return this.actual === expected; | |
}; | |
/** | |
* toNotBe: compares the actual to the expected using !== | |
* @param expected | |
* @deprecated as of 1.0. Use not.toBe() instead. | |
*/ | |
jasmine.Matchers.prototype.toNotBe = function(expected) { | |
return this.actual !== expected; | |
}; | |
/** | |
* toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc. | |
* | |
* @param expected | |
*/ | |
jasmine.Matchers.prototype.toEqual = function(expected) { | |
return this.env.equals_(this.actual, expected); | |
}; | |
/** | |
* toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual | |
* @param expected | |
* @deprecated as of 1.0. Use not.toEqual() instead. | |
*/ | |
jasmine.Matchers.prototype.toNotEqual = function(expected) { | |
return !this.env.equals_(this.actual, expected); | |
}; | |
/** | |
* Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes | |
* a pattern or a String. | |
* | |
* @param expected | |
*/ | |
jasmine.Matchers.prototype.toMatch = function(expected) { | |
return new RegExp(expected).test(this.actual); | |
}; | |
/** | |
* Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch | |
* @param expected | |
* @deprecated as of 1.0. Use not.toMatch() instead. | |
*/ | |
jasmine.Matchers.prototype.toNotMatch = function(expected) { | |
return !(new RegExp(expected).test(this.actual)); | |
}; | |
/** | |
* Matcher that compares the actual to jasmine.undefined. | |
*/ | |
jasmine.Matchers.prototype.toBeDefined = function() { | |
return (this.actual !== jasmine.undefined); | |
}; | |
/** | |
* Matcher that compares the actual to jasmine.undefined. | |
*/ | |
jasmine.Matchers.prototype.toBeUndefined = function() { | |
return (this.actual === jasmine.undefined); | |
}; | |
/** | |
* Matcher that compares the actual to null. | |
*/ | |
jasmine.Matchers.prototype.toBeNull = function() { | |
return (this.actual === null); | |
}; | |
/** | |
* Matcher that compares the actual to NaN. | |
*/ | |
jasmine.Matchers.prototype.toBeNaN = function() { | |
this.message = function() { | |
return [ "Expected " + jasmine.pp(this.actual) + " to be NaN." ]; | |
}; | |
return (this.actual !== this.actual); | |
}; | |
/** | |
* Matcher that boolean not-nots the actual. | |
*/ | |
jasmine.Matchers.prototype.toBeTruthy = function() { | |
return !!this.actual; | |
}; | |
/** | |
* Matcher that boolean nots the actual. | |
*/ | |
jasmine.Matchers.prototype.toBeFalsy = function() { | |
return !this.actual; | |
}; | |
/** | |
* Matcher that checks to see if the actual, a Jasmine spy, was called. | |
*/ | |
jasmine.Matchers.prototype.toHaveBeenCalled = function() { | |
if (arguments.length > 0) { | |
throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith'); | |
} | |
if (!jasmine.isSpy(this.actual)) { | |
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); | |
} | |
this.message = function() { | |
return [ | |
"Expected spy " + this.actual.identity + " to have been called.", | |
"Expected spy " + this.actual.identity + " not to have been called." | |
]; | |
}; | |
return this.actual.wasCalled; | |
}; | |
/** @deprecated Use expect(xxx).toHaveBeenCalled() instead */ | |
jasmine.Matchers.prototype.wasCalled = jasmine.Matchers.prototype.toHaveBeenCalled; | |
/** | |
* Matcher that checks to see if the actual, a Jasmine spy, was not called. | |
* | |
* @deprecated Use expect(xxx).not.toHaveBeenCalled() instead | |
*/ | |
jasmine.Matchers.prototype.wasNotCalled = function() { | |
if (arguments.length > 0) { | |
throw new Error('wasNotCalled does not take arguments'); | |
} | |
if (!jasmine.isSpy(this.actual)) { | |
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); | |
} | |
this.message = function() { | |
return [ | |
"Expected spy " + this.actual.identity + " to not have been called.", | |
"Expected spy " + this.actual.identity + " to have been called." | |
]; | |
}; | |
return !this.actual.wasCalled; | |
}; | |
/** | |
* Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters. | |
* | |
* @example | |
* | |
*/ | |
jasmine.Matchers.prototype.toHaveBeenCalledWith = function() { | |
var expectedArgs = jasmine.util.argsToArray(arguments); | |
if (!jasmine.isSpy(this.actual)) { | |
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); | |
} | |
this.message = function() { | |
var invertedMessage = "Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was."; | |
var positiveMessage = ""; | |
if (this.actual.callCount === 0) { | |
positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called."; | |
} else { | |
positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but actual calls were " + jasmine.pp(this.actual.argsForCall).replace(/^\[ | \]$/g, '') | |
} | |
return [positiveMessage, invertedMessage]; | |
}; | |
return this.env.contains_(this.actual.argsForCall, expectedArgs); | |
}; | |
/** @deprecated Use expect(xxx).toHaveBeenCalledWith() instead */ | |
jasmine.Matchers.prototype.wasCalledWith = jasmine.Matchers.prototype.toHaveBeenCalledWith; | |
/** @deprecated Use expect(xxx).not.toHaveBeenCalledWith() instead */ | |
jasmine.Matchers.prototype.wasNotCalledWith = function() { | |
var expectedArgs = jasmine.util.argsToArray(arguments); | |
if (!jasmine.isSpy(this.actual)) { | |
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); | |
} | |
this.message = function() { | |
return [ | |
"Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was", | |
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was" | |
]; | |
}; | |
return !this.env.contains_(this.actual.argsForCall, expectedArgs); | |
}; | |
/** | |
* Matcher that checks that the expected item is an element in the actual Array. | |
* | |
* @param {Object} expected | |
*/ | |
jasmine.Matchers.prototype.toContain = function(expected) { | |
return this.env.contains_(this.actual, expected); | |
}; | |
/** | |
* Matcher that checks that the expected item is NOT an element in the actual Array. | |
* | |
* @param {Object} expected | |
* @deprecated as of 1.0. Use not.toContain() instead. | |
*/ | |
jasmine.Matchers.prototype.toNotContain = function(expected) { | |
return !this.env.contains_(this.actual, expected); | |
}; | |
jasmine.Matchers.prototype.toBeLessThan = function(expected) { | |
return this.actual < expected; | |
}; | |
jasmine.Matchers.prototype.toBeGreaterThan = function(expected) { | |
return this.actual > expected; | |
}; | |
/** | |
* Matcher that checks that the expected item is equal to the actual item | |
* up to a given level of decimal precision (default 2). | |
* | |
* @param {Number} expected | |
* @param {Number} precision, as number of decimal places | |
*/ | |
jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) { | |
if (!(precision === 0)) { | |
precision = precision || 2; | |
} | |
return Math.abs(expected - this.actual) < (Math.pow(10, -precision) / 2); | |
}; | |
/** | |
* Matcher that checks that the expected exception was thrown by the actual. | |
* | |
* @param {String} [expected] | |
*/ | |
jasmine.Matchers.prototype.toThrow = function(expected) { | |
var result = false; | |
var exception; | |
if (typeof this.actual != 'function') { | |
throw new Error('Actual is not a function'); | |
} | |
try { | |
this.actual(); | |
} catch (e) { | |
exception = e; | |
} | |
if (exception) { | |
result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected)); | |
} | |
var not = this.isNot ? "not " : ""; | |
this.message = function() { | |
if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) { | |
return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' '); | |
} else { | |
return "Expected function to throw an exception."; | |
} | |
}; | |
return result; | |
}; | |
jasmine.Matchers.Any = function(expectedClass) { | |
this.expectedClass = expectedClass; | |
}; | |
jasmine.Matchers.Any.prototype.jasmineMatches = function(other) { | |
if (this.expectedClass == String) { | |
return typeof other == 'string' || other instanceof String; | |
} | |
if (this.expectedClass == Number) { | |
return typeof other == 'number' || other instanceof Number; | |
} | |
if (this.expectedClass == Function) { | |
return typeof other == 'function' || other instanceof Function; | |
} | |
if (this.expectedClass == Object) { | |
return typeof other == 'object'; | |
} | |
return other instanceof this.expectedClass; | |
}; | |
jasmine.Matchers.Any.prototype.jasmineToString = function() { | |
return '<jasmine.any(' + this.expectedClass + ')>'; | |
}; | |
jasmine.Matchers.ObjectContaining = function (sample) { | |
this.sample = sample; | |
}; | |
jasmine.Matchers.ObjectContaining.prototype.jasmineMatches = function(other, mismatchKeys, mismatchValues) { | |
mismatchKeys = mismatchKeys || []; | |
mismatchValues = mismatchValues || []; | |
var env = jasmine.getEnv(); | |
var hasKey = function(obj, keyName) { | |
return obj != null && obj[keyName] !== jasmine.undefined; | |
}; | |
for (var property in this.sample) { | |
if (!hasKey(other, property) && hasKey(this.sample, property)) { | |
mismatchKeys.push("expected has key '" + property + "', but missing from actual."); | |
} | |
else if (!env.equals_(this.sample[property], other[property], mismatchKeys, mismatchValues)) { | |
mismatchValues.push("'" + property + "' was '" + (other[property] ? jasmine.util.htmlEscape(other[property].toString()) : other[property]) + "' in expected, but was '" + (this.sample[property] ? jasmine.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + "' in actual."); | |
} | |
} | |
return (mismatchKeys.length === 0 && mismatchValues.length === 0); | |
}; | |
jasmine.Matchers.ObjectContaining.prototype.jasmineToString = function () { | |
return "<jasmine.objectContaining(" + jasmine.pp(this.sample) + ")>"; | |
}; | |
// Mock setTimeout, clearTimeout | |
// Contributed by Pivotal Computer Systems, www.pivotalsf.com | |
jasmine.FakeTimer = function() { | |
this.reset(); | |
var self = this; | |
self.setTimeout = function(funcToCall, millis) { | |
self.timeoutsMade++; | |
self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false); | |
return self.timeoutsMade; | |
}; | |
self.setInterval = function(funcToCall, millis) { | |
self.timeoutsMade++; | |
self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true); | |
return self.timeoutsMade; | |
}; | |
self.clearTimeout = function(timeoutKey) { | |
self.scheduledFunctions[timeoutKey] = jasmine.undefined; | |
}; | |
self.clearInterval = function(timeoutKey) { | |
self.scheduledFunctions[timeoutKey] = jasmine.undefined; | |
}; | |
}; | |
jasmine.FakeTimer.prototype.reset = function() { | |
this.timeoutsMade = 0; | |
this.scheduledFunctions = {}; | |
this.nowMillis = 0; | |
}; | |
jasmine.FakeTimer.prototype.tick = function(millis) { | |
var oldMillis = this.nowMillis; | |
var newMillis = oldMillis + millis; | |
this.runFunctionsWithinRange(oldMillis, newMillis); | |
this.nowMillis = newMillis; | |
}; | |
jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) { | |
var scheduledFunc; | |
var funcsToRun = []; | |
for (var timeoutKey in this.scheduledFunctions) { | |
scheduledFunc = this.scheduledFunctions[timeoutKey]; | |
if (scheduledFunc != jasmine.undefined && | |
scheduledFunc.runAtMillis >= oldMillis && | |
scheduledFunc.runAtMillis <= nowMillis) { | |
funcsToRun.push(scheduledFunc); | |
this.scheduledFunctions[timeoutKey] = jasmine.undefined; | |
} | |
} | |
if (funcsToRun.length > 0) { | |
funcsToRun.sort(function(a, b) { | |
return a.runAtMillis - b.runAtMillis; | |
}); | |
for (var i = 0; i < funcsToRun.length; ++i) { | |
try { | |
var funcToRun = funcsToRun[i]; | |
this.nowMillis = funcToRun.runAtMillis; | |
funcToRun.funcToCall(); | |
if (funcToRun.recurring) { | |
this.scheduleFunction(funcToRun.timeoutKey, | |
funcToRun.funcToCall, | |
funcToRun.millis, | |
true); | |
} | |
} catch(e) { | |
} | |
} | |
this.runFunctionsWithinRange(oldMillis, nowMillis); | |
} | |
}; | |
jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) { | |
this.scheduledFunctions[timeoutKey] = { | |
runAtMillis: this.nowMillis + millis, | |
funcToCall: funcToCall, | |
recurring: recurring, | |
timeoutKey: timeoutKey, | |
millis: millis | |
}; | |
}; | |
/** | |
* @namespace | |
*/ | |
jasmine.Clock = { | |
defaultFakeTimer: new jasmine.FakeTimer(), | |
reset: function() { | |
jasmine.Clock.assertInstalled(); | |
jasmine.Clock.defaultFakeTimer.reset(); | |
}, | |
tick: function(millis) { | |
jasmine.Clock.assertInstalled(); | |
jasmine.Clock.defaultFakeTimer.tick(millis); | |
}, | |
runFunctionsWithinRange: function(oldMillis, nowMillis) { | |
jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis); | |
}, | |
scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) { | |
jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring); | |
}, | |
useMock: function() { | |
if (!jasmine.Clock.isInstalled()) { | |
var spec = jasmine.getEnv().currentSpec; | |
spec.after(jasmine.Clock.uninstallMock); | |
jasmine.Clock.installMock(); | |
} | |
}, | |
installMock: function() { | |
jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer; | |
}, | |
uninstallMock: function() { | |
jasmine.Clock.assertInstalled(); | |
jasmine.Clock.installed = jasmine.Clock.real; | |
}, | |
real: { | |
setTimeout: jasmine.getGlobal().setTimeout, | |
clearTimeout: jasmine.getGlobal().clearTimeout, | |
setInterval: jasmine.getGlobal().setInterval, | |
clearInterval: jasmine.getGlobal().clearInterval | |
}, | |
assertInstalled: function() { | |
if (!jasmine.Clock.isInstalled()) { | |
throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()"); | |
} | |
}, | |
isInstalled: function() { | |
return jasmine.Clock.installed == jasmine.Clock.defaultFakeTimer; | |
}, | |
installed: null | |
}; | |
jasmine.Clock.installed = jasmine.Clock.real; | |
//else for IE support | |
jasmine.getGlobal().setTimeout = function(funcToCall, millis) { | |
if (jasmine.Clock.installed.setTimeout.apply) { | |
return jasmine.Clock.installed.setTimeout.apply(this, arguments); | |
} else { | |
return jasmine.Clock.installed.setTimeout(funcToCall, millis); | |
} | |
}; | |
jasmine.getGlobal().setInterval = function(funcToCall, millis) { | |
if (jasmine.Clock.installed.setInterval.apply) { | |
return jasmine.Clock.installed.setInterval.apply(this, arguments); | |
} else { | |
return jasmine.Clock.installed.setInterval(funcToCall, millis); | |
} | |
}; | |
jasmine.getGlobal().clearTimeout = function(timeoutKey) { | |
if (jasmine.Clock.installed.clearTimeout.apply) { | |
return jasmine.Clock.installed.clearTimeout.apply(this, arguments); | |
} else { | |
return jasmine.Clock.installed.clearTimeout(timeoutKey); | |
} | |
}; | |
jasmine.getGlobal().clearInterval = function(timeoutKey) { | |
if (jasmine.Clock.installed.clearTimeout.apply) { | |
return jasmine.Clock.installed.clearInterval.apply(this, arguments); | |
} else { | |
return jasmine.Clock.installed.clearInterval(timeoutKey); | |
} | |
}; | |
/** | |
* @constructor | |
*/ | |
jasmine.MultiReporter = function() { | |
this.subReporters_ = []; | |
}; | |
jasmine.util.inherit(jasmine.MultiReporter, jasmine.Reporter); | |
jasmine.MultiReporter.prototype.addReporter = function(reporter) { | |
this.subReporters_.push(reporter); | |
}; | |
(function() { | |
var functionNames = [ | |
"reportRunnerStarting", | |
"reportRunnerResults", | |
"reportSuiteResults", | |
"reportSpecStarting", | |
"reportSpecResults", | |
"log" | |
]; | |
for (var i = 0; i < functionNames.length; i++) { | |
var functionName = functionNames[i]; | |
jasmine.MultiReporter.prototype[functionName] = (function(functionName) { | |
return function() { | |
for (var j = 0; j < this.subReporters_.length; j++) { | |
var subReporter = this.subReporters_[j]; | |
if (subReporter[functionName]) { | |
subReporter[functionName].apply(subReporter, arguments); | |
} | |
} | |
}; | |
})(functionName); | |
} | |
})(); | |
/** | |
* Holds results for a set of Jasmine spec. Allows for the results array to hold another jasmine.NestedResults | |
* | |
* @constructor | |
*/ | |
jasmine.NestedResults = function() { | |
/** | |
* The total count of results | |
*/ | |
this.totalCount = 0; | |
/** | |
* Number of passed results | |
*/ | |
this.passedCount = 0; | |
/** | |
* Number of failed results | |
*/ | |
this.failedCount = 0; | |
/** | |
* Was this suite/spec skipped? | |
*/ | |
this.skipped = false; | |
/** | |
* @ignore | |
*/ | |
this.items_ = []; | |
}; | |
/** | |
* Roll up the result counts. | |
* | |
* @param result | |
*/ | |
jasmine.NestedResults.prototype.rollupCounts = function(result) { | |
this.totalCount += result.totalCount; | |
this.passedCount += result.passedCount; | |
this.failedCount += result.failedCount; | |
}; | |
/** | |
* Adds a log message. | |
* @param values Array of message parts which will be concatenated later. | |
*/ | |
jasmine.NestedResults.prototype.log = function(values) { | |
this.items_.push(new jasmine.MessageResult(values)); | |
}; | |
/** | |
* Getter for the results: message & results. | |
*/ | |
jasmine.NestedResults.prototype.getItems = function() { | |
return this.items_; | |
}; | |
/** | |
* Adds a result, tracking counts (total, passed, & failed) | |
* @param {jasmine.ExpectationResult|jasmine.NestedResults} result | |
*/ | |
jasmine.NestedResults.prototype.addResult = function(result) { | |
if (result.type != 'log') { | |
if (result.items_) { | |
this.rollupCounts(result); | |
} else { | |
this.totalCount++; | |
if (result.passed()) { | |
this.passedCount++; | |
} else { | |
this.failedCount++; | |
} | |
} | |
} | |
this.items_.push(result); | |
}; | |
/** | |
* @returns {Boolean} True if <b>everything</b> below passed | |
*/ | |
jasmine.NestedResults.prototype.passed = function() { | |
return this.passedCount === this.totalCount; | |
}; | |
/** | |
* Base class for pretty printing for expectation results. | |
*/ | |
jasmine.PrettyPrinter = function() { | |
this.ppNestLevel_ = 0; | |
}; | |
/** | |
* Formats a value in a nice, human-readable string. | |
* | |
* @param value | |
*/ | |
jasmine.PrettyPrinter.prototype.format = function(value) { | |
this.ppNestLevel_++; | |
try { | |
if (value === jasmine.undefined) { | |
this.emitScalar('undefined'); | |
} else if (value === null) { | |
this.emitScalar('null'); | |
} else if (value === jasmine.getGlobal()) { | |
this.emitScalar('<global>'); | |
} else if (value.jasmineToString) { | |
this.emitScalar(value.jasmineToString()); | |
} else if (typeof value === 'string') { | |
this.emitString(value); | |
} else if (jasmine.isSpy(value)) { | |
this.emitScalar("spy on " + value.identity); | |
} else if (value instanceof RegExp) { | |
this.emitScalar(value.toString()); | |
} else if (typeof value === 'function') { | |
this.emitScalar('Function'); | |
} else if (typeof value.nodeType === 'number') { | |
this.emitScalar('HTMLNode'); | |
} else if (value instanceof Date) { | |
this.emitScalar('Date(' + value + ')'); | |
} else if (value.__Jasmine_been_here_before__) { | |
this.emitScalar('<circular reference: ' + (jasmine.isArray_(value) ? 'Array' : 'Object') + '>'); | |
} else if (jasmine.isArray_(value) || typeof value == 'object') { | |
value.__Jasmine_been_here_before__ = true; | |
if (jasmine.isArray_(value)) { | |
this.emitArray(value); | |
} else { | |
this.emitObject(value); | |
} | |
delete value.__Jasmine_been_here_before__; | |
} else { | |
this.emitScalar(value.toString()); | |
} | |
} finally { | |
this.ppNestLevel_--; | |
} | |
}; | |
jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) { | |
for (var property in obj) { | |
if (!obj.hasOwnProperty(property)) continue; | |
if (property == '__Jasmine_been_here_before__') continue; | |
fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined && | |
obj.__lookupGetter__(property) !== null) : false); | |
} | |
}; | |
jasmine.PrettyPrinter.prototype.emitArray = jasmine.unimplementedMethod_; | |
jasmine.PrettyPrinter.prototype.emitObject = jasmine.unimplementedMethod_; | |
jasmine.PrettyPrinter.prototype.emitScalar = jasmine.unimplementedMethod_; | |
jasmine.PrettyPrinter.prototype.emitString = jasmine.unimplementedMethod_; | |
jasmine.StringPrettyPrinter = function() { | |
jasmine.PrettyPrinter.call(this); | |
this.string = ''; | |
}; | |
jasmine.util.inherit(jasmine.StringPrettyPrinter, jasmine.PrettyPrinter); | |
jasmine.StringPrettyPrinter.prototype.emitScalar = function(value) { | |
this.append(value); | |
}; | |
jasmine.StringPrettyPrinter.prototype.emitString = function(value) { | |
this.append("'" + value + "'"); | |
}; | |
jasmine.StringPrettyPrinter.prototype.emitArray = function(array) { | |
if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) { | |
this.append("Array"); | |
return; | |
} | |
this.append('[ '); | |
for (var i = 0; i < array.length; i++) { | |
if (i > 0) { | |
this.append(', '); | |
} | |
this.format(array[i]); | |
} | |
this.append(' ]'); | |
}; | |
jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) { | |
if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) { | |
this.append("Object"); | |
return; | |
} | |
var self = this; | |
this.append('{ '); | |
var first = true; | |
this.iterateObject(obj, function(property, isGetter) { | |
if (first) { | |
first = false; | |
} else { | |
self.append(', '); | |
} | |
self.append(property); | |
self.append(' : '); | |
if (isGetter) { | |
self.append('<getter>'); | |
} else { | |
self.format(obj[property]); | |
} | |
}); | |
this.append(' }'); | |
}; | |
jasmine.StringPrettyPrinter.prototype.append = function(value) { | |
this.string += value; | |
}; | |
jasmine.Queue = function(env) { | |
this.env = env; | |
// parallel to blocks. each true value in this array means the block will | |
// get executed even if we abort | |
this.ensured = []; | |
this.blocks = []; | |
this.running = false; | |
this.index = 0; | |
this.offset = 0; | |
this.abort = false; | |
}; | |
jasmine.Queue.prototype.addBefore = function(block, ensure) { | |
if (ensure === jasmine.undefined) { | |
ensure = false; | |
} | |
this.blocks.unshift(block); | |
this.ensured.unshift(ensure); | |
}; | |
jasmine.Queue.prototype.add = function(block, ensure) { | |
if (ensure === jasmine.undefined) { | |
ensure = false; | |
} | |
this.blocks.push(block); | |
this.ensured.push(ensure); | |
}; | |
jasmine.Queue.prototype.insertNext = function(block, ensure) { | |
if (ensure === jasmine.undefined) { | |
ensure = false; | |
} | |
this.ensured.splice((this.index + this.offset + 1), 0, ensure); | |
this.blocks.splice((this.index + this.offset + 1), 0, block); | |
this.offset++; | |
}; | |
jasmine.Queue.prototype.start = function(onComplete) { | |
this.running = true; | |
this.onComplete = onComplete; | |
this.next_(); | |
}; | |
jasmine.Queue.prototype.isRunning = function() { | |
return this.running; | |
}; | |
jasmine.Queue.LOOP_DONT_RECURSE = true; | |
jasmine.Queue.prototype.next_ = function() { | |
var self = this; | |
var goAgain = true; | |
while (goAgain) { | |
goAgain = false; | |
if (self.index < self.blocks.length && !(this.abort && !this.ensured[self.index])) { | |
var calledSynchronously = true; | |
var completedSynchronously = false; | |
var onComplete = function () { | |
if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) { | |
completedSynchronously = true; | |
return; | |
} | |
if (self.blocks[self.index].abort) { | |
self.abort = true; | |
} | |
self.offset = 0; | |
self.index++; | |
var now = new Date().getTime(); | |
if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) { | |
self.env.lastUpdate = now; | |
self.env.setTimeout(function() { | |
self.next_(); | |
}, 0); | |
} else { | |
if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) { | |
goAgain = true; | |
} else { | |
self.next_(); | |
} | |
} | |
}; | |
self.blocks[self.index].execute(onComplete); | |
calledSynchronously = false; | |
if (completedSynchronously) { | |
onComplete(); | |
} | |
} else { | |
self.running = false; | |
if (self.onComplete) { | |
self.onComplete(); | |
} | |
} | |
} | |
}; | |
jasmine.Queue.prototype.results = function() { | |
var results = new jasmine.NestedResults(); | |
for (var i = 0; i < this.blocks.length; i++) { | |
if (this.blocks[i].results) { | |
results.addResult(this.blocks[i].results()); | |
} | |
} | |
return results; | |
}; | |
/** | |
* Runner | |
* | |
* @constructor | |
* @param {jasmine.Env} env | |
*/ | |
jasmine.Runner = function(env) { | |
var self = this; | |
self.env = env; | |
self.queue = new jasmine.Queue(env); | |
self.before_ = []; | |
self.after_ = []; | |
self.suites_ = []; | |
}; | |
jasmine.Runner.prototype.execute = function() { | |
var self = this; | |
if (self.env.reporter.reportRunnerStarting) { | |
self.env.reporter.reportRunnerStarting(this); | |
} | |
self.queue.start(function () { | |
self.finishCallback(); | |
}); | |
}; | |
jasmine.Runner.prototype.beforeEach = function(beforeEachFunction) { | |
beforeEachFunction.typeName = 'beforeEach'; | |
this.before_.splice(0,0,beforeEachFunction); | |
}; | |
jasmine.Runner.prototype.afterEach = function(afterEachFunction) { | |
afterEachFunction.typeName = 'afterEach'; | |
this.after_.splice(0,0,afterEachFunction); | |
}; | |
jasmine.Runner.prototype.finishCallback = function() { | |
this.env.reporter.reportRunnerResults(this); | |
}; | |
jasmine.Runner.prototype.addSuite = function(suite) { | |
this.suites_.push(suite); | |
}; | |
jasmine.Runner.prototype.add = function(block) { | |
if (block instanceof jasmine.Suite) { | |
this.addSuite(block); | |
} | |
this.queue.add(block); | |
}; | |
jasmine.Runner.prototype.specs = function () { | |
var suites = this.suites(); | |
var specs = []; | |
for (var i = 0; i < suites.length; i++) { | |
specs = specs.concat(suites[i].specs()); | |
} | |
return specs; | |
}; | |
jasmine.Runner.prototype.suites = function() { | |
return this.suites_; | |
}; | |
jasmine.Runner.prototype.topLevelSuites = function() { | |
var topLevelSuites = []; | |
for (var i = 0; i < this.suites_.length; i++) { | |
if (!this.suites_[i].parentSuite) { | |
topLevelSuites.push(this.suites_[i]); | |
} | |
} | |
return topLevelSuites; | |
}; | |
jasmine.Runner.prototype.results = function() { | |
return this.queue.results(); | |
}; | |
/** | |
* Internal representation of a Jasmine specification, or test. | |
* | |
* @constructor | |
* @param {jasmine.Env} env | |
* @param {jasmine.Suite} suite | |
* @param {String} description | |
*/ | |
jasmine.Spec = function(env, suite, description) { | |
if (!env) { | |
throw new Error('jasmine.Env() required'); | |
} | |
if (!suite) { | |
throw new Error('jasmine.Suite() required'); | |
} | |
var spec = this; | |
spec.id = env.nextSpecId ? env.nextSpecId() : null; | |
spec.env = env; | |
spec.suite = suite; | |
spec.description = description; | |
spec.queue = new jasmine.Queue(env); | |
spec.afterCallbacks = []; | |
spec.spies_ = []; | |
spec.results_ = new jasmine.NestedResults(); | |
spec.results_.description = description; | |
spec.matchersClass = null; | |
}; | |
jasmine.Spec.prototype.getFullName = function() { | |
return this.suite.getFullName() + ' ' + this.description + '.'; | |
}; | |
jasmine.Spec.prototype.results = function() { | |
return this.results_; | |
}; | |
/** | |
* All parameters are pretty-printed and concatenated together, then written to the spec's output. | |
* | |
* Be careful not to leave calls to <code>jasmine.log</code> in production code. | |
*/ | |
jasmine.Spec.prototype.log = function() { | |
return this.results_.log(arguments); | |
}; | |
jasmine.Spec.prototype.runs = function (func) { | |
var block = new jasmine.Block(this.env, func, this); | |
this.addToQueue(block); | |
return this; | |
}; | |
jasmine.Spec.prototype.addToQueue = function (block) { | |
if (this.queue.isRunning()) { | |
this.queue.insertNext(block); | |
} else { | |
this.queue.add(block); | |
} | |
}; | |
/** | |
* @param {jasmine.ExpectationResult} result | |
*/ | |
jasmine.Spec.prototype.addMatcherResult = function(result) { | |
this.results_.addResult(result); | |
}; | |
jasmine.Spec.prototype.expect = function(actual) { | |
var positive = new (this.getMatchersClass_())(this.env, actual, this); | |
positive.not = new (this.getMatchersClass_())(this.env, actual, this, true); | |
return positive; | |
}; | |
/** | |
* Waits a fixed time period before moving to the next block. | |
* | |
* @deprecated Use waitsFor() instead | |
* @param {Number} timeout milliseconds to wait | |
*/ | |
jasmine.Spec.prototype.waits = function(timeout) { | |
var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this); | |
this.addToQueue(waitsFunc); | |
return this; | |
}; | |
/** | |
* Waits for the latchFunction to return true before proceeding to the next block. | |
* | |
* @param {Function} latchFunction | |
* @param {String} optional_timeoutMessage | |
* @param {Number} optional_timeout | |
*/ | |
jasmine.Spec.prototype.waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) { | |
var latchFunction_ = null; | |
var optional_timeoutMessage_ = null; | |
var optional_timeout_ = null; | |
for (var i = 0; i < arguments.length; i++) { | |
var arg = arguments[i]; | |
switch (typeof arg) { | |
case 'function': | |
latchFunction_ = arg; | |
break; | |
case 'string': | |
optional_timeoutMessage_ = arg; | |
break; | |
case 'number': | |
optional_timeout_ = arg; | |
break; | |
} | |
} | |
var waitsForFunc = new jasmine.WaitsForBlock(this.env, optional_timeout_, latchFunction_, optional_timeoutMessage_, this); | |
this.addToQueue(waitsForFunc); | |
return this; | |
}; | |
jasmine.Spec.prototype.fail = function (e) { | |
var expectationResult = new jasmine.ExpectationResult({ | |
passed: false, | |
message: e ? jasmine.util.formatException(e) : 'Exception', | |
trace: { stack: e.stack } | |
}); | |
this.results_.addResult(expectationResult); | |
}; | |
jasmine.Spec.prototype.getMatchersClass_ = function() { | |
return this.matchersClass || this.env.matchersClass; | |
}; | |
jasmine.Spec.prototype.addMatchers = function(matchersPrototype) { | |
var parent = this.getMatchersClass_(); | |
var newMatchersClass = function() { | |
parent.apply(this, arguments); | |
}; | |
jasmine.util.inherit(newMatchersClass, parent); | |
jasmine.Matchers.wrapInto_(matchersPrototype, newMatchersClass); | |
this.matchersClass = newMatchersClass; | |
}; | |
jasmine.Spec.prototype.finishCallback = function() { | |
this.env.reporter.reportSpecResults(this); | |
}; | |
jasmine.Spec.prototype.finish = function(onComplete) { | |
this.removeAllSpies(); | |
this.finishCallback(); | |
if (onComplete) { | |
onComplete(); | |
} | |
}; | |
jasmine.Spec.prototype.after = function(doAfter) { | |
if (this.queue.isRunning()) { | |
this.queue.add(new jasmine.Block(this.env, doAfter, this), true); | |
} else { | |
this.afterCallbacks.unshift(doAfter); | |
} | |
}; | |
jasmine.Spec.prototype.execute = function(onComplete) { | |
var spec = this; | |
if (!spec.env.specFilter(spec)) { | |
spec.results_.skipped = true; | |
spec.finish(onComplete); | |
return; | |
} | |
this.env.reporter.reportSpecStarting(this); | |
spec.env.currentSpec = spec; | |
spec.addBeforesAndAftersToQueue(); | |
spec.queue.start(function () { | |
spec.finish(onComplete); | |
}); | |
}; | |
jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() { | |
var runner = this.env.currentRunner(); | |
var i; | |
for (var suite = this.suite; suite; suite = suite.parentSuite) { | |
for (i = 0; i < suite.before_.length; i++) { | |
this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this)); | |
} | |
} | |
for (i = 0; i < runner.before_.length; i++) { | |
this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this)); | |
} | |
for (i = 0; i < this.afterCallbacks.length; i++) { | |
this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this), true); | |
} | |
for (suite = this.suite; suite; suite = suite.parentSuite) { | |
for (i = 0; i < suite.after_.length; i++) { | |
this.queue.add(new jasmine.Block(this.env, suite.after_[i], this), true); | |
} | |
} | |
for (i = 0; i < runner.after_.length; i++) { | |
this.queue.add(new jasmine.Block(this.env, runner.after_[i], this), true); | |
} | |
}; | |
jasmine.Spec.prototype.explodes = function() { | |
throw 'explodes function should not have been called'; | |
}; | |
jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) { | |
if (obj == jasmine.undefined) { | |
throw "spyOn could not find an object to spy upon for " + methodName + "()"; | |
} | |
if (!ignoreMethodDoesntExist && obj[methodName] === jasmine.undefined) { | |
throw methodName + '() method does not exist'; | |
} | |
if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) { | |
throw new Error(methodName + ' has already been spied upon'); | |
} | |
var spyObj = jasmine.createSpy(methodName); | |
this.spies_.push(spyObj); | |
spyObj.baseObj = obj; | |
spyObj.methodName = methodName; | |
spyObj.originalValue = obj[methodName]; | |
obj[methodName] = spyObj; | |
return spyObj; | |
}; | |
jasmine.Spec.prototype.removeAllSpies = function() { | |
for (var i = 0; i < this.spies_.length; i++) { | |
var spy = this.spies_[i]; | |
spy.baseObj[spy.methodName] = spy.originalValue; | |
} | |
this.spies_ = []; | |
}; | |
/** | |
* Internal representation of a Jasmine suite. | |
* | |
* @constructor | |
* @param {jasmine.Env} env | |
* @param {String} description | |
* @param {Function} specDefinitions | |
* @param {jasmine.Suite} parentSuite | |
*/ | |
jasmine.Suite = function(env, description, specDefinitions, parentSuite) { | |
var self = this; | |
self.id = env.nextSuiteId ? env.nextSuiteId() : null; | |
self.description = description; | |
self.queue = new jasmine.Queue(env); | |
self.parentSuite = parentSuite; | |
self.env = env; | |
self.before_ = []; | |
self.after_ = []; | |
self.children_ = []; | |
self.suites_ = []; | |
self.specs_ = []; | |
}; | |
jasmine.Suite.prototype.getFullName = function() { | |
var fullName = this.description; | |
for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) { | |
fullName = parentSuite.description + ' ' + fullName; | |
} | |
return fullName; | |
}; | |
jasmine.Suite.prototype.finish = function(onComplete) { | |
this.env.reporter.reportSuiteResults(this); | |
this.finished = true; | |
if (typeof(onComplete) == 'function') { | |
onComplete(); | |
} | |
}; | |
jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) { | |
beforeEachFunction.typeName = 'beforeEach'; | |
this.before_.unshift(beforeEachFunction); | |
}; | |
jasmine.Suite.prototype.afterEach = function(afterEachFunction) { | |
afterEachFunction.typeName = 'afterEach'; | |
this.after_.unshift(afterEachFunction); | |
}; | |
jasmine.Suite.prototype.results = function() { | |
return this.queue.results(); | |
}; | |
jasmine.Suite.prototype.add = function(suiteOrSpec) { | |
this.children_.push(suiteOrSpec); | |
if (suiteOrSpec instanceof jasmine.Suite) { | |
this.suites_.push(suiteOrSpec); | |
this.env.currentRunner().addSuite(suiteOrSpec); | |
} else { | |
this.specs_.push(suiteOrSpec); | |
} | |
this.queue.add(suiteOrSpec); | |
}; | |
jasmine.Suite.prototype.specs = function() { | |
return this.specs_; | |
}; | |
jasmine.Suite.prototype.suites = function() { | |
return this.suites_; | |
}; | |
jasmine.Suite.prototype.children = function() { | |
return this.children_; | |
}; | |
jasmine.Suite.prototype.execute = function(onComplete) { | |
var self = this; | |
this.queue.start(function () { | |
self.finish(onComplete); | |
}); | |
}; | |
jasmine.WaitsBlock = function(env, timeout, spec) { | |
this.timeout = timeout; | |
jasmine.Block.call(this, env, null, spec); | |
}; | |
jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block); | |
jasmine.WaitsBlock.prototype.execute = function (onComplete) { | |
if (jasmine.VERBOSE) { | |
this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...'); | |
} | |
this.env.setTimeout(function () { | |
onComplete(); | |
}, this.timeout); | |
}; | |
/** | |
* A block which waits for some condition to become true, with timeout. | |
* | |
* @constructor | |
* @extends jasmine.Block | |
* @param {jasmine.Env} env The Jasmine environment. | |
* @param {Number} timeout The maximum time in milliseconds to wait for the condition to become true. | |
* @param {Function} latchFunction A function which returns true when the desired condition has been met. | |
* @param {String} message The message to display if the desired condition hasn't been met within the given time period. | |
* @param {jasmine.Spec} spec The Jasmine spec. | |
*/ | |
jasmine.WaitsForBlock = function(env, timeout, latchFunction, message, spec) { | |
this.timeout = timeout || env.defaultTimeoutInterval; | |
this.latchFunction = latchFunction; | |
this.message = message; | |
this.totalTimeSpentWaitingForLatch = 0; | |
jasmine.Block.call(this, env, null, spec); | |
}; | |
jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block); | |
jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 10; | |
jasmine.WaitsForBlock.prototype.execute = function(onComplete) { | |
if (jasmine.VERBOSE) { | |
this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen')); | |
} | |
var latchFunctionResult; | |
try { | |
latchFunctionResult = this.latchFunction.apply(this.spec); | |
} catch (e) { | |
this.spec.fail(e); | |
onComplete(); | |
return; | |
} | |
if (latchFunctionResult) { | |
onComplete(); | |
} else if (this.totalTimeSpentWaitingForLatch >= this.timeout) { | |
var message = 'timed out after ' + this.timeout + ' msec waiting for ' + (this.message || 'something to happen'); | |
this.spec.fail({ | |
name: 'timeout', | |
message: message | |
}); | |
this.abort = true; | |
onComplete(); | |
} else { | |
this.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT; | |
var self = this; | |
this.env.setTimeout(function() { | |
self.execute(onComplete); | |
}, jasmine.WaitsForBlock.TIMEOUT_INCREMENT); | |
} | |
}; | |
jasmine.version_= { | |
"major": 1, | |
"minor": 3, | |
"build": 1, | |
"revision": 1354556913 | |
}; |
This file contains hidden or 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
/// <reference path="~/js/libs/testing/jasmine.js"/> | |
/// <reference path="~/js/libs/angular.min.js"/> | |
/// <reference path="~/js/libs/testing/angular-mocks.js"/> | |
/// <reference path="cheese.js"/> | |
describe('simplest possible test', function () { | |
var cheese = null; | |
it('cheese is good', function () { | |
cheese = new Cheese(); | |
expect(cheese.isGood).toBe(true); | |
}); | |
}); | |
describe('PasswordCtrl controllers', function () { | |
describe('PasswordCtrl', function() { | |
var $scope; | |
var $controller; | |
beforeEach(inject(function($rootScope, _$controller_){ | |
// The injector unwraps the underscores (_) | |
// from around the parameter names when matching | |
$scope = $rootScope.$new(); | |
$controller = _$controller_; | |
})); | |
it('should evaluate password strenght', function () { | |
var $scope = {}; | |
var pc = $controller('PasswordCtrl', { $scope: $scope }); | |
$scope.password = 'abc'; | |
$scope.grade(); | |
expect($scope.strength).toEqual('weak'); | |
}); | |
}); | |
}); | |
/* | |
describe('PhoneDetailCtrl controllers',function() { | |
describe('PhoneDetailCtrl', function () { | |
var scope, $httpBackend, ctrl; | |
beforeEach(inject(function (_$httpBackend_, $rootScope, $routeParams, $controller) { | |
$httpBackend = _$httpBackend_; | |
$httpBackend.expectGET('phones/xyz.json').respond({ name: 'phone xyz' }); | |
$routeParams.phoneId = 'xyz'; | |
scope = $rootScope.$new(); | |
ctrl = $controller(PhoneDetailCtrl, { $scope: scope }); | |
//this is needed since some version of Angular.. | |
//$rootScope.$digest(); | |
})); | |
it('should fetch phone detail', function () { | |
expect(scope.phone).toBeUndefined(); | |
$httpBackend.flush(); | |
expect(scope.phone).toEqual({ name: 'phone xyz' }); | |
}); | |
}); | |
});*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment