mirror of
https://github.com/correl/melpa.git
synced 2024-11-22 03:00:11 +00:00
Allow pagination to be toggled off (#2307)
This commit is contained in:
parent
a0a4072d6c
commit
c27d7f0e92
2 changed files with 21 additions and 4 deletions
|
@ -47,6 +47,7 @@
|
|||
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.7.0/moment.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js"></script>
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/Cookies.js/1.1.0/cookies.min.js"></script>
|
||||
<script src="js/melpa.js"></script>
|
||||
<script src="http://platform.twitter.com/widgets.js" type="text/javascript" async="async"></script>
|
||||
<script>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* global window */
|
||||
(function(m, document, _, moment, jQuery){
|
||||
(function(m, document, _, moment, jQuery, Cookies){
|
||||
"use strict";
|
||||
|
||||
// TODO Disqus
|
||||
|
@ -264,6 +264,18 @@
|
|||
this.sortBy(field);
|
||||
}
|
||||
};
|
||||
this.wantPagination = function() {
|
||||
return !Cookies.get("nopagination");
|
||||
};
|
||||
this.togglePagination = function() {
|
||||
console.log("toggle " + this.wantPagination());
|
||||
if (this.wantPagination()) {
|
||||
Cookies.set("nopagination", "1");
|
||||
} else {
|
||||
Cookies.expire("nopagination");
|
||||
}
|
||||
console.log("toggled " + Cookies.get("nopagination"));
|
||||
};
|
||||
this.paginatorCtrl = new melpa.paginator.controller(this.sortedPackages);
|
||||
};
|
||||
|
||||
|
@ -304,7 +316,7 @@
|
|||
])
|
||||
]),
|
||||
m("tbody",
|
||||
ctrl.paginatorCtrl.paginatedItems().map(function(p) {
|
||||
(ctrl.wantPagination() ? ctrl.paginatorCtrl.paginatedItems() : ctrl.sortedPackages()).map(function(p) {
|
||||
return m("tr", { key: p.name }, [
|
||||
m("td", packageLink(p)),
|
||||
m("td", packageLink(p, p.description)),
|
||||
|
@ -321,7 +333,11 @@
|
|||
]);
|
||||
}))
|
||||
]),
|
||||
melpa.paginator.view(ctrl.paginatorCtrl)
|
||||
(ctrl.wantPagination() ? melpa.paginator.view(ctrl.paginatorCtrl) : null),
|
||||
m("small",
|
||||
m("a", {onclick: ctrl.togglePagination.bind(ctrl)},
|
||||
(ctrl.wantPagination() ? "Disable pagination (may slow down display)" : "Enable pagination")
|
||||
))
|
||||
]);
|
||||
};
|
||||
|
||||
|
@ -550,4 +566,4 @@
|
|||
if (window.twttr && window.twttr.widgets) window.twttr.widgets.load();
|
||||
}, 100);
|
||||
|
||||
})(window.m, window.document, window._, window.moment, window.jQuery);
|
||||
})(window.m, window.document, window._, window.moment, window.jQuery, window.Cookies);
|
||||
|
|
Loading…
Reference in a new issue