MCPcopy Create free account
hub / github.com/cafebazaar/blacksmith / Browser

Function Browser

web/static/bower_components/angular/angular.js:5483–5811  ·  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

5481 * @param {object} $sniffer $sniffer service
5482 */
5483function Browser(window, document, $log, $sniffer) {
5484 var self = this,
5485 rawDocument = document[0],
5486 location = window.location,
5487 history = window.history,
5488 setTimeout = window.setTimeout,
5489 clearTimeout = window.clearTimeout,
5490 pendingDeferIds = {};
5491
5492 self.isMock = false;
5493
5494 var outstandingRequestCount = 0;
5495 var outstandingRequestCallbacks = [];
5496
5497 // TODO(vojta): remove this temporary api
5498 self.$$completeOutstandingRequest = completeOutstandingRequest;
5499 self.$$incOutstandingRequestCount = function() { outstandingRequestCount++; };
5500
5501 /**
5502 * Executes the `fn` function(supports currying) and decrements the `outstandingRequestCallbacks`
5503 * counter. If the counter reaches 0, all the `outstandingRequestCallbacks` are executed.
5504 */
5505 function completeOutstandingRequest(fn) {
5506 try {
5507 fn.apply(null, sliceArgs(arguments, 1));
5508 } finally {
5509 outstandingRequestCount--;
5510 if (outstandingRequestCount === 0) {
5511 while (outstandingRequestCallbacks.length) {
5512 try {
5513 outstandingRequestCallbacks.pop()();
5514 } catch (e) {
5515 $log.error(e);
5516 }
5517 }
5518 }
5519 }
5520 }
5521
5522 function getHash(url) {
5523 var index = url.indexOf('#');
5524 return index === -1 ? '' : url.substr(index);
5525 }
5526
5527 /**
5528 * @private
5529 * Note: this method is used only by scenario runner
5530 * TODO(vojta): prefix this method with $$ ?
5531 * @param {function()} callback Function that will be called when no outstanding request
5532 */
5533 self.notifyWhenNoOutstandingRequests = function(callback) {
5534 if (outstandingRequestCount === 0) {
5535 callback();
5536 } else {
5537 outstandingRequestCallbacks.push(callback);
5538 }
5539 };
5540

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected