mirror of
https://github.com/wahyd4/cdnjs.git
synced 2026-08-18 01:08:18 +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
1.6 KiB
JavaScript
1 line
1.6 KiB
JavaScript
function MockBrowser(){var a=this,b={},c=[];this.isMock=true;a.url="http://server";a.pollFns=[];a.xhr=function(i,e,g,h){if(angular.isFunction(g)){h=g;g=null}if(g&&angular.isObject(g)){g=angular.toJson(g)}if(g&&angular.isString(g)){e+="|"+g}var f=b[i]||{};var d=f[e];if(!d){throw {message:"Unexpected request for method '"+i+"' and url '"+e+"'.",name:"Unexpected Request"}}c.push(function(){h(d.code,d.response)})};a.xhr.expectations=b;a.xhr.requests=c;a.xhr.expect=function(g,d,f){if(f&&angular.isObject(f)){f=angular.toJson(f)}if(f&&angular.isString(f)){d+="|"+f}var e=b[g]||(b[g]={});return{respond:function(i,h){if(!angular.isNumber(i)){h=i;i=200}e[d]={code:i,response:h}}}};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(){while(c.length){c.pop()()}};a.cookieHash={};a.lastCookieHash={}}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()}); |