aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisko Hevery2010-04-02 11:16:49 -0700
committerMisko Hevery2010-04-02 11:16:49 -0700
commit5bd23fde7ab94646190d18d2891532feafad6e2e (patch)
tree06388d97d2eba76191fd46a8769348b35ef4345c
parentd717020911a350a5ea3c0a985c57d56c8fcad607 (diff)
parent861bac1d2808b15abb867e761ded8144bf5f7e94 (diff)
downloadangular.js-5bd23fde7ab94646190d18d2891532feafad6e2e.tar.bz2
merge
-rw-r--r--src/Angular.js1
-rw-r--r--src/Scope.js1
-rw-r--r--src/UrlWatcher.js46
-rw-r--r--test/servicesSpec.js1
4 files changed, 49 insertions, 0 deletions
diff --git a/src/Angular.js b/src/Angular.js
index 4e3266eb..d97c2282 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -411,3 +411,4 @@ function angularInit(config){
compile(window.document, config).$init();
}
}
+
diff --git a/src/Scope.js b/src/Scope.js
index ae5bd384..2b2db189 100644
--- a/src/Scope.js
+++ b/src/Scope.js
@@ -163,6 +163,7 @@ function createScope(parent, Class) {
behavior.$root = instance;
behavior.$parent = instance;
}
+
(parent.$onEval || noop)(instance.$eval);
Class.apply(instance, slice.call(arguments, 2, arguments.length));
diff --git a/src/UrlWatcher.js b/src/UrlWatcher.js
new file mode 100644
index 00000000..1b2a9cf0
--- /dev/null
+++ b/src/UrlWatcher.js
@@ -0,0 +1,46 @@
+
+// ////////////////////////////
+// UrlWatcher
+// ////////////////////////////
+
+function UrlWatcher(location) {
+ this.location = location;
+ this.delay = 25;
+ this.setTimeout = function(fn, delay) {
+ window.setTimeout(fn, delay);
+ };
+ this.expectedUrl = location.href;
+ this.listeners = [];
+}
+
+UrlWatcher.prototype = {
+ watch: function(fn){
+ this.listeners.push(fn);
+ },
+
+ start: function() {
+ var self = this;
+ (function pull () {
+ if (self.expectedUrl !== self.location.href) {
+ foreach(self.listeners, function(listener){
+ listener(self.location.href);
+ });
+ self.expectedUrl = self.location.href;
+ }
+ self.setTimeout(pull, self.delay);
+ })();
+ },
+
+ 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 this.location.href;
+ }
+};
diff --git a/test/servicesSpec.js b/test/servicesSpec.js
index dec4550f..b92975d0 100644
--- a/test/servicesSpec.js
+++ b/test/servicesSpec.js
@@ -45,4 +45,5 @@ describe("services", function(){
expect(scope.$location()).toEqual('file:///Users/Shared/misko/work/angular.js/scenario/widgets.html');
});
+
});