MCPcopy
hub / github.com/angular-ui/ui-router / Browser

Function Browser

test/angular/1.5/angular.js:6022–6351  ·  view source on GitHub ↗

* @param {object} window The global window object. * @param {object} document jQuery wrapped document. * @param {object} $log window.console or an object with the same interface. * @param {object} $sniffer $sniffer service

(window, document, $log, $sniffer)

Source from the content-addressed store, hash-verified

6020 * @param {object} $sniffer $sniffer service
6021 */
6022function Browser(window, document, $log, $sniffer) {
6023 var self = this,
6024 location = window.location,
6025 history = window.history,
6026 setTimeout = window.setTimeout,
6027 clearTimeout = window.clearTimeout,
6028 pendingDeferIds = {};
6029
6030 self.isMock = false;
6031
6032 var outstandingRequestCount = 0;
6033 var outstandingRequestCallbacks = [];
6034
6035 // TODO(vojta): remove this temporary api
6036 self.$$completeOutstandingRequest = completeOutstandingRequest;
6037 self.$$incOutstandingRequestCount = function() { outstandingRequestCount++; };
6038
6039 /**
6040 * Executes the `fn` function(supports currying) and decrements the `outstandingRequestCallbacks`
6041 * counter. If the counter reaches 0, all the `outstandingRequestCallbacks` are executed.
6042 */
6043 function completeOutstandingRequest(fn) {
6044 try {
6045 fn.apply(null, sliceArgs(arguments, 1));
6046 } finally {
6047 outstandingRequestCount--;
6048 if (outstandingRequestCount === 0) {
6049 while (outstandingRequestCallbacks.length) {
6050 try {
6051 outstandingRequestCallbacks.pop()();
6052 } catch (e) {
6053 $log.error(e);
6054 }
6055 }
6056 }
6057 }
6058 }
6059
6060 function getHash(url) {
6061 var index = url.indexOf('#');
6062 return index === -1 ? '' : url.substr(index);
6063 }
6064
6065 /**
6066 * @private
6067 * Note: this method is used only by scenario runner
6068 * TODO(vojta): prefix this method with $$ ?
6069 * @param {function()} callback Function that will be called when no outstanding request
6070 */
6071 self.notifyWhenNoOutstandingRequests = function(callback) {
6072 if (outstandingRequestCount === 0) {
6073 callback();
6074 } else {
6075 outstandingRequestCallbacks.push(callback);
6076 }
6077 };
6078
6079 //////////////////////////////////////////////////////////////

Callers

nothing calls this directly

Calls 6

callbackFunction · 0.70
cacheStateFunction · 0.70
isUndefinedFunction · 0.70
stripHashFunction · 0.70
getHashFunction · 0.70

Tested by

no test coverage detected