mirror of
https://github.com/wahyd4/cdnjs.git
synced 2026-08-14 15:25:52 +10:00
Sources: http://code.angularjs.org/* Added missing versions, fixed some files reporting as min’d but weren’t, the sneaky varmints. Addresses https://github.com/cdnjs/cdnjs/issues/1188 - I think. Can be closed if it does.
1 line
4.3 KiB
JavaScript
1 line
4.3 KiB
JavaScript
angular.mock={};function MockBrowser(){var a=this,b={},c=[];this.isMock=true;a.url="http://server";a.lastUrl=a.url;a.pollFns=[];a.onHashChange=function(d){a.pollFns.push(function(){if(a.lastUrl!=a.url){a.lastUrl=a.url;d()}});return d};a.xhr=function(j,e,g,i,h){h=h||{};if(g&&angular.isObject(g)){g=angular.toJson(g)}if(g&&angular.isString(g)){e+="|"+g}var f=b[j]||{};var d=f[e];if(!d){throw new Error("Unexpected request for method '"+j+"' and url '"+e+"'.")}c.push(function(){forEach(d.headers,function(l,k){if(h[k]!==l){throw new Error("Missing HTTP request header: "+k+": "+l)}});i(d.code,d.response)})};a.xhr.expectations=b;a.xhr.requests=c;a.xhr.expect=function(h,d,f,g){if(f&&angular.isObject(f)){f=angular.toJson(f)}if(f&&angular.isString(f)){d+="|"+f}var e=b[h]||(b[h]={});return{respond:function(j,i){if(!angular.isNumber(j)){i=j;j=200}e[d]={code:j,response:i,headers:g||{}}}}};a.xhr.expectGET=angular.bind(a,a.xhr.expect,"GET");a.xhr.expectPOST=angular.bind(a,a.xhr.expect,"POST");a.xhr.expectDELETE=angular.bind(a,a.xhr.expect,"DELETE");a.xhr.expectPUT=angular.bind(a,a.xhr.expect,"PUT");a.xhr.expectJSON=angular.bind(a,a.xhr.expect,"JSON");a.xhr.flush=function(){if(c.length==0){throw new Error("No xhr requests to be flushed!")}while(c.length){c.pop()()}};a.cookieHash={};a.lastCookieHash={};a.deferredFns=[];a.defer=function(d){a.deferredFns.push(d)};a.defer.flush=function(){while(a.deferredFns.length){a.deferredFns.shift()()}}}MockBrowser.prototype={poll:function poll(){angular.forEach(this.pollFns,function(a){a()})},addPollFn:function(a){this.pollFns.push(a);return a},hover:function(a){},getUrl:function(){return this.url},setUrl:function(a){this.url=a},cookies:function(a,b){if(a){if(b==undefined){delete this.cookieHash[a]}else{if(angular.isString(b)&&b.length<=4096){this.cookieHash[a]=b}}}else{if(!angular.equals(this.cookieHash,this.lastCookieHash)){this.lastCookieHash=angular.copy(this.cookieHash);this.cookieHash=angular.copy(this.cookieHash)}return this.cookieHash}}};angular.service("$browser",function(){return new MockBrowser()});angular.service("$exceptionHandler",function(a){return function(b){throw b}});angular.service("$log",MockLogFactory);function MockLogFactory(){var a={log:function(){a.log.logs.push(arguments)},warn:function(){a.warn.logs.push(arguments)},info:function(){a.info.logs.push(arguments)},error:function(){a.error.logs.push(arguments)}};a.log.logs=[];a.warn.logs=[];a.info.logs=[];a.error.logs=[];return a}function TzDate(e,c){if(angular.isString(c)){var a=c;this.origDate=angular.String.toDate(c);c=this.origDate.getTime();if(isNaN(c)){throw {name:"Illegal Argument",message:"Arg '"+a+"' passed into TzDate constructor is not a valid date string"}}}else{this.origDate=new Date(c)}var d=new Date(c).getTimezoneOffset();this.offsetDiff=d*60*1000-e*1000*60*60;this.date=new Date(c+this.offsetDiff);this.getTime=function(){return this.date.getTime()-this.offsetDiff};this.toLocaleDateString=function(){return this.date.toLocaleDateString()};this.getFullYear=function(){return this.date.getFullYear()};this.getMonth=function(){return this.date.getMonth()};this.getDate=function(){return this.date.getDate()};this.getHours=function(){return this.date.getHours()};this.getMinutes=function(){return this.date.getMinutes()};this.getSeconds=function(){return this.date.getSeconds()};this.getTimezoneOffset=function(){return e*60};this.getUTCFullYear=function(){return this.origDate.getUTCFullYear()};this.getUTCMonth=function(){return this.origDate.getUTCMonth()};this.getUTCDate=function(){return this.origDate.getUTCDate()};this.getUTCHours=function(){return this.origDate.getUTCHours()};this.getUTCMinutes=function(){return this.origDate.getUTCMinutes()};this.getUTCSeconds=function(){return this.origDate.getUTCSeconds()};var b=["getDay","getMilliseconds","getTime","getUTCDay","getUTCMilliseconds","getYear","setDate","setFullYear","setHours","setMilliseconds","setMinutes","setMonth","setSeconds","setTime","setUTCDate","setUTCFullYear","setUTCHours","setUTCMilliseconds","setUTCMinutes","setUTCMonth","setUTCSeconds","setYear","toDateString","toJSON","toGMTString","toLocaleFormat","toLocaleString","toLocaleTimeString","toSource","toString","toTimeString","toUTCString","valueOf"];angular.forEach(b,function(f){this[f]=function(){throw {name:"MethodNotImplemented",message:"Method '"+f+"' is not implemented in the TzDate mock"}}})}TzDate.prototype=Date.prototype; |