diff options
Diffstat (limited to 'web-ui/app/js/mail_list_actions/ui/pagination_trigger.js')
-rw-r--r-- | web-ui/app/js/mail_list_actions/ui/pagination_trigger.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/web-ui/app/js/mail_list_actions/ui/pagination_trigger.js b/web-ui/app/js/mail_list_actions/ui/pagination_trigger.js new file mode 100644 index 00000000..1ada36e7 --- /dev/null +++ b/web-ui/app/js/mail_list_actions/ui/pagination_trigger.js @@ -0,0 +1,50 @@ +define( + [ + 'flight/lib/component', + 'views/templates', + 'page/events' + ], + + function(defineComponent, templates, events) { + 'use strict'; + + return defineComponent(paginationTrigger); + + function paginationTrigger() { + this.defaultAttrs({ + previous: '#left-arrow', + next: '#right-arrow', + currentPage: "#current-page" + }); + + this.renderWithPageNumber = function(pageNumber) { + this.$node.html(templates.mailActions.paginationTrigger({ + currentPage: pageNumber + })); + this.on(this.attr.previous, 'click', this.previousPage); + this.on(this.attr.next, 'click', this.nextPage); + }; + + this.render = function() { + this.renderWithPageNumber(1); + }; + + this.updatePageDisplay = function(event, data) { + this.renderWithPageNumber(data.currentPage + 1); + }; + + this.previousPage = function(event) { + this.trigger(document, events.ui.page.previous); + }; + + this.nextPage = function(event) { + this.trigger(document, events.ui.page.next); + }; + + this.after('initialize', function () { + this.render(); + this.on(document, events.ui.page.changed, this.updatePageDisplay); + }); + } + } +); |