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

Function Browser

test/angular/1.6/angular.js:6416–6745  ·  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

6414 * @param {object} $sniffer $sniffer service
6415 */
6416function Browser(window, document, $log, $sniffer) {
6417 var self = this,
6418 location = window.location,
6419 history = window.history,
6420 setTimeout = window.setTimeout,
6421 clearTimeout = window.clearTimeout,
6422 pendingDeferIds = {};
6423
6424 self.isMock = false;
6425
6426 var outstandingRequestCount = 0;
6427 var outstandingRequestCallbacks = [];
6428
6429 // TODO(vojta): remove this temporary api
6430 self.$$completeOutstandingRequest = completeOutstandingRequest;
6431 self.$$incOutstandingRequestCount = function() { outstandingRequestCount++; };
6432
6433 /**
6434 * Executes the `fn` function(supports currying) and decrements the `outstandingRequestCallbacks`
6435 * counter. If the counter reaches 0, all the `outstandingRequestCallbacks` are executed.
6436 */
6437 function completeOutstandingRequest(fn) {
6438 try {
6439 fn.apply(null, sliceArgs(arguments, 1));
6440 } finally {
6441 outstandingRequestCount--;
6442 if (outstandingRequestCount === 0) {
6443 while (outstandingRequestCallbacks.length) {
6444 try {
6445 outstandingRequestCallbacks.pop()();
6446 } catch (e) {
6447 $log.error(e);
6448 }
6449 }
6450 }
6451 }
6452 }
6453
6454 function getHash(url) {
6455 var index = url.indexOf('#');
6456 return index === -1 ? '' : url.substr(index);
6457 }
6458
6459 /**
6460 * @private
6461 * TODO(vojta): prefix this method with $$ ?
6462 * @param {function()} callback Function that will be called when no outstanding request
6463 */
6464 self.notifyWhenNoOutstandingRequests = function(callback) {
6465 if (outstandingRequestCount === 0) {
6466 callback();
6467 } else {
6468 outstandingRequestCallbacks.push(callback);
6469 }
6470 };
6471
6472 //////////////////////////////////////////////////////////////
6473 // URL API

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