diff options
author | David Thompson <dthompson2@worcester.edu> | 2014-08-09 09:27:56 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2014-08-09 09:27:56 -0400 |
commit | ab8432a1bbdb779ae374fe273dca069184486cc6 (patch) | |
tree | 4ab6c8f752e8e9d0ea6add54227fa78471857ce9 | |
parent | 6d5af995d9c6294a164e0b0056950731be948866 (diff) |
Move controller methods to prototype.
* js/guix-packages.js: Move functions defined on each instance of
guix.controller to guix.controller's prototype.
-rw-r--r-- | js/guix-packages.js | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/js/guix-packages.js b/js/guix-packages.js index 7ab30a0..c9a61ca 100644 --- a/js/guix-packages.js +++ b/js/guix-packages.js @@ -52,37 +52,37 @@ guix.controller = function() { this.packages.then(function(packages) { self.pages(guix.paginate(packages, self.pageSize)); }); +}; - this.currentPage = function() { - return self.pages()[self.currentPageIndex] || []; - }; +guix.controller.prototype.currentPage = function() { + return this.pages()[this.currentPageIndex] || []; +}; - this.isFirstPage = function() { - return self.currentPageIndex === 0; - }; +guix.controller.prototype.isFirstPage = function() { + return this.currentPageIndex === 0; +}; - this.isLastPage = function() { - return self.currentPageIndex === self.pages().length - 1; - }; +guix.controller.prototype.isLastPage = function() { + return this.currentPageIndex === this.pages().length - 1; +}; - this.isCurrentPage = function(i) { - return self.currentPageIndex === i; - }; +guix.controller.prototype.isCurrentPage = function(i) { + return this.currentPageIndex === i; +}; - this.packageCount = function() { - return self.pages().reduce(function(memo, page) { - return memo + page.length; - }, 0); - }; +guix.controller.prototype.packageCount = function() { + return this.pages().reduce(function(memo, page) { + return memo + page.length; + }, 0); +}; - this.doSearch = function() { - var regexp = new RegExp(this.searchTerm(), "i"); +guix.controller.prototype.doSearch = function() { + var regexp = new RegExp(this.searchTerm(), "i"); - this.pages(guix.paginate(this.packages().filter(function(package) { - return regexp.test(package.name) || - regexp.test(package.synopsis); - }), self.pageSize)); - }; + this.pages(guix.paginate(this.packages().filter(function(package) { + return regexp.test(package.name) || + regexp.test(package.synopsis); + }), this.pageSize)); }; guix.view = function(ctrl) { |