reload on hashchange

0.1
Michael Blix 2014-02-27 14:34:42 -05:00
rodzic 82e8d76466
commit 005610dc7d
2 zmienionych plików z 14 dodań i 2 usunięć

Wyświetl plik

@ -41,6 +41,8 @@
this.loop = undefined;
this.publish("addToDat", this, {name: "City", properties: ["init"]});
this.subscribe("hashchange", this.onHashchange);
};
VIZI.City.prototype.init = function(options) {
@ -57,8 +59,8 @@
var hash = window.location.hash.replace('#', '');
var coordCheck = /^(\-?\d+(\.\d+)?),(\-?\d+(\.\d+)?)$/;
if (coordCheck.test(hash) && !_.has(options, 'coords')) {
options.coords = hash.split(',');
if (coordCheck.test(hash)) {
options.coords = hash.split(',').reverse();
}
_.defaults(options, {
@ -264,4 +266,9 @@
return deferred.promise;
};
VIZI.City.prototype.onHashchange = function(){
window.location.reload();
};
}());

Wyświetl plik

@ -19,6 +19,11 @@
self.publish("resize", event);
}, false );
// Hash change
window.addEventListener( "hashchange", function(event) {
self.publish("hashchange", event);
}, false );
return Q.fcall(function() {});
};
}());