Skip to content

Instantly share code, notes, and snippets.

@milcktoast
Last active August 29, 2015 14:13
Show Gist options
  • Select an option

  • Save milcktoast/a384ef07a9f87701bb08 to your computer and use it in GitHub Desktop.

Select an option

Save milcktoast/a384ef07a9f87701bb08 to your computer and use it in GitHub Desktop.
var get = Ember.get;
var set = Ember.set;
var HardLocation = App.HardLocation = Ember.Object.extend({
init : function() {
return set(this, 'location', get(this, 'location') || window.location);
},
getURL : function() {
var location = get(this, 'location');
var path = location.pathname;
var url = path;
var search;
if (Ember.FEATURES.isEnabled('query-params')) {
search = location.search || '';
url += search;
}
return url;
},
setURL : function(path) {
get(this, 'location').href = path;
return path;
},
replaceURL : function(path) {},
onUpdateURL : function(callback) {
var location = get(this, 'location');
var path = location.pathname;
var url = path;
return callback(url);
},
formatURL : function(url) {
return url;
},
willDestroy : function() {}
});
return Ember.Application.initializer({
name : 'hard-location',
initialize : function(container, application) {
return application.register('location:hard', HardLocation);
}
});
App.Router.reopen({
location : Modernizr.history ? 'history' : 'hard'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment