annotation_dashboard/commit
ADDED: missing bits to make pagination work
author | Jacco van Ossenbruggen |
---|---|
Sun Sep 21 21:21:21 2014 +0200 | |
committer | Jacco van Ossenbruggen |
Sun Sep 21 21:21:21 2014 +0200 | |
commit | 721f614e04419a474d05eb896a76eeda04a8cf7b |
tree | 824c6efc575e10b0f7f0e8e2701a14189ec55cbc |
parent | ca554011aec6de1af3383e104d9ecb2fe371c8b8 |
Diff style: patch stat
diff --git a/components/dashboard/pagination.pl b/components/dashboard/pagination.pl index 099a00a..d00446b 100644 --- a/components/dashboard/pagination.pl +++ b/components/dashboard/pagination.pl @@ -11,18 +11,23 @@ pagination(Options) --> { option(limit(Limit), Options), option(offset(Offset), Options), option(total(Total), Options), + option(task(Task), Options), Max is floor(Total/Limit), numlist(0,Max, List1), maplist(multiply(Limit), List1, List) }, - html(ul([class(pagination)],[\pitem(Offset, List)])). + html(ul([class(pagination)],[\pitem(Limit, Offset,Task, List)])). multiply(A,B,P) :- P is A * B. -pitem(_, []) --> !. -pitem(Offset, [H1|T]) --> - { ( T = [H2|_], between(H1, H2, Offset) +pitem(_,_,_, []) --> !. +pitem(Limit, Offset, Task, [H1|T]) --> + { ( T = [H2|_], H1 =< Offset, Offset < H2 -> Class = [active] ; Class = []) }, - html(li([class(Class)],a([href('#')],H1))), - pitem(Offset,T). + html(li([class(Class)], + a([class(pagination), task(Task), + offset(H1), limit(Limit) + ], + H1))), + pitem(Limit, Offset, Task, T). diff --git a/web/js/dashboard.js b/web/js/dashboard.js index be6e60c..afa0e39 100644 --- a/web/js/dashboard.js +++ b/web/js/dashboard.js @@ -1,13 +1,21 @@ -YUI().use('event', 'json', 'io', function(Y) { +YUI().use('event', 'json', 'io', 'querystring', function(Y) { Y.on('domready', function() { Y.all( '.judgebutton.agree.unchecked').on('click', submitJudgement, null, 'agree', 'disagree', 'add'); Y.all('.judgebutton.disagree.unchecked').on('click', submitJudgement, null, 'disagree', 'agree', 'add'); + Y.all('.pagination a').on('click', pagination); }); MOTIVATION = { tagging: 'http://www.w3.org/ns/oa#tagging', commenting: 'http://www.w3.org/ns/oa#commenting', moderating: 'http://www.w3.org/ns/oa#moderating', }; + function pagination(ev) { + var limit = ev.currentTarget.getAttribute('limit'); + var offset = ev.currentTarget.getAttribute('offset'); + var task = ev.currentTarget.getAttribute('task'); + var parameters = Y.QueryString.stringify({ task:task,limit:limit, offset:offset }); + location.assign(location.pathname + '?' + parameters); + } function submitJudgement(ev, type, toggleto, mode) { var button = ev.currentTarget; button.detach('click'); @@ -53,4 +61,3 @@ YUI().use('event', 'json', 'io', function(Y) { }) } }); -