Last active
August 29, 2015 14:13
-
-
Save milcktoast/a384ef07a9f87701bb08 to your computer and use it in GitHub Desktop.
Hard page loads for SEO / old IE, see http://discuss.emberjs.com/t/best-practice-for-seo-and-lt-ie9/4408
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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