Skip to content

Commit

Permalink
Making NavigatorPlugin more easily testable and allowing programmatic…
Browse files Browse the repository at this point in the history
… page navigation #22
  • Loading branch information
danielalves committed Mar 10, 2015
1 parent 34cd307 commit d217e63
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/plugins/jquery.silver_track.navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,8 @@
this.prev = this.options.prev;
this.next = this.options.next;

var self = this;
this.prev.addClass(this.options.disabledClass).click(function(e) {
e.preventDefault();
self.track.prev();
});

this.next.addClass(this.options.disabledClass).click(function(e) {
e.preventDefault();
self.track.next();
});
this.prev.addClass(this.options.disabledClass).click(this._handlePreviousPageClick.bind(this));
this.next.addClass(this.options.disabledClass).click(this._handleNextPageClick.bind(this));
},

onInstall: function(track) {
Expand Down Expand Up @@ -67,6 +59,24 @@
}
},

goToNextPage: function() {
this.track.next();
},

goToPreviousPage: function() {
this.track.prev();
},

_handlePreviousPageClick: function(e) {
e.preventDefault();
this.goToPreviousPage();
},

_handleNextPageClick: function(e) {
e.preventDefault();
this.goToNextPage();
},

_enable: function(element) {
element.removeClass(this.options.disabledClass);
},
Expand Down

0 comments on commit d217e63

Please sign in to comment.