Created
April 2, 2015 20:27
-
-
Save lamchau/0111768220259868c622 to your computer and use it in GitHub Desktop.
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
| (function(History) { | |
| if (!Ember.Object.detectInstance(History)) { | |
| throw new Error("Native `Ember.History` is already defined."); | |
| } | |
| if (Ember.Evented.detect(History)) { | |
| return; | |
| } else { | |
| History.reopen(Ember.Evented); | |
| } | |
| History.reopen({ | |
| back: function() { | |
| window.history.go(-1); | |
| }, | |
| forward: function() { | |
| window.history.go(1); | |
| }, | |
| go: function(count) { | |
| // most likely an error, explicitly use reload when we mean it | |
| if (count === 0) { | |
| throw new Ember.Error("Use `window.location.reload()` instead"); | |
| } | |
| Ember.assert("Count must be an integer", Math.round(count) === count); | |
| window.history.go(count); | |
| this.trigger("go", count); | |
| }, | |
| pushState: function(state, title, url) { | |
| window.history.pushState(state, title, url); | |
| this.trigger("pushState", state, title, url); | |
| }, | |
| replaceState: function(state, title, url) { | |
| window.history.replaceState(state, title, url); | |
| this.trigger("replaceState", state, title, url); | |
| } | |
| }); | |
| })(Ember.History || (Ember.History = Ember.Object.create())); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment