diff options
| author | Misko Hevery | 2010-03-31 17:56:16 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-03-31 18:18:10 -0700 |
| commit | 11a6431f8926c557f3c58408dacc98466e76cde1 (patch) | |
| tree | ab36304fd373d0947ca36c577e25ca87a1c894af /src/UrlWatcher.js | |
| parent | 35a91085004e31f786df1e0011bc26ed0142ab4d (diff) | |
| download | angular.js-11a6431f8926c557f3c58408dacc98466e76cde1.tar.bz2 | |
started to add services
Diffstat (limited to 'src/UrlWatcher.js')
| -rw-r--r-- | src/UrlWatcher.js | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/src/UrlWatcher.js b/src/UrlWatcher.js deleted file mode 100644 index 0892eb1a..00000000 --- a/src/UrlWatcher.js +++ /dev/null @@ -1,62 +0,0 @@ - -// //////////////////////////// -// UrlWatcher -// //////////////////////////// - -function UrlWatcher(location) { - this.location = location; - this.delay = 25; - this.setTimeout = function(fn, delay) { - window.setTimeout(fn, delay); - }; - this.listener = function(url) { - return url; - }; - this.expectedUrl = location.href; -} - -UrlWatcher.prototype = { - listen: function(fn){ - this.listener = fn; - }, - watch: function() { - var self = this; - var pull = function() { - if (self.expectedUrl !== self.location.href) { - var notify = self.location.hash.match(/^#\$iframe_notify=(.*)$/); - if (notify) { - if (!self.expectedUrl.match(/#/)) { - self.expectedUrl += "#"; - } - self.location.href = self.expectedUrl; - var id = '_iframe_notify_' + notify[1]; - var notifyFn = angularCallbacks[id]; - delete angularCallbacks[id]; - try { - (notifyFn||noop)(); - } catch (e) { - alert(e); - } - } else { - self.listener(self.location.href); - self.expectedUrl = self.location.href; - } - } - self.setTimeout(pull, self.delay); - }; - pull(); - }, - - set: function(url) { - var existingURL = this.location.href; - if (!existingURL.match(/#/)) - existingURL += '#'; - if (existingURL != url) - this.location.href = url; - this.existingURL = url; - }, - - get: function() { - return window.location.href; - } -}; |
