annotation_dashboard/commit
IMPROVED: changes judgebuttons in proper bootstrap radio buttons, fixed boken login in javascript
author | Jacco van Ossenbruggen |
---|---|
Fri Sep 19 17:52:01 2014 +0200 | |
committer | Jacco van Ossenbruggen |
Fri Sep 19 17:52:01 2014 +0200 | |
commit | dd8eab2b9ae022636d939433ae2ae6bc1391d6bf |
tree | b5cce47d7ce56792b0fbdb928e236552bcfe3e05 |
parent | 0407421c06064be4c610cd8e3f5b5e3c2da34077 |
Diff style: patch stat
diff --git a/applications/dashboard.pl b/applications/dashboard.pl index 2c5cc06..af83e15 100644 --- a/applications/dashboard.pl +++ b/applications/dashboard.pl @@ -1,6 +1,10 @@ :- module(an_dashboard, []). % from SWI-Prolog libraries: +:- use_module(library(apply)). +:- use_module(library(lists)). +:- use_module(library(pairs)). + :- use_module(library(semweb/rdf_db)). :- use_module(library(http/http_dispatch)). :- use_module(library(http/http_parameters)). @@ -18,6 +22,7 @@ :- use_module(library(yui3_beta)). % needed for html resource declarations :- use_module(library(oa_schema)). :- use_module(library(oa_annotation)). +:- use_module(library(ac_list_util)). :- use_module(api(media_caching)). % needed for http api handlers :- use_module(applications(annotation)). @@ -89,7 +94,8 @@ task_page(Task, Options0) :- find_annotations_by_task(Task, Annotations), partition(is_tag, Annotations, Tags, Judgements), maplist(rdf_get_annotation_target, Tags, Targets), - sort(Targets, Objects), + list_limit(Targets, 1, TargetsLimited, _Rest), + sort(TargetsLimited, Objects), maplist(count_annotations, Objects, CountPairs), sort(CountPairs, SortedPairs0), reverse(SortedPairs0, ReversePairs), @@ -421,29 +427,43 @@ current_judgment(_,_,_, null, unchecked). %button_image(disagree, '../../icons/thumbDown.png'). button_glyph(agree) --> - html(span([class([glyphicon,'glyphicon-thumbs-up'])],[])). + html(span([class([glyphicon,'glyphicon-thumbs-up'])],[' agree'])). button_glyph(disagree) --> - html(span([class([glyphicon,'glyphicon-thumbs-down'])],[])). + html(span([class([glyphicon,'glyphicon-thumbs-down'])],[' disagree'])). + +checked_active(checked, active). +checked_active(_, ''). button_class(Type, Checked, Class) :- + checked_active(Checked, Active), atomic_list_concat( ['inline judgeButton ', Type, 'Button ', - Checked + Checked , ' ', + Active ], Class). judge_button(Type, Annotation, Field, Judgements) --> { current_judgment(Type, Annotation, Judgements, J, Checked), - button_class(Type, Checked, ButtonClass) + checked_active(Checked, Active) }, - html([button([class([ButtonClass, btn, 'btn-default', 'btn-lg']), - field(Field), - judgement(J), - annotation(Annotation)], - \button_glyph(Type) - )]). + html([ + label([class([Active, btn,'btn-primary'])], + [ input([class([judgebutton, Type, Checked + ]), + field(Field), + judgement(J), + annotation(Annotation), + type(radio), + title(Type), 'data-toggle'(tooltip) + ], + [ + \button_glyph(Type) + ]) + ]) + ]). is_judgement_of(A, J) :- @@ -460,7 +480,7 @@ show_annotation_summery(A, Options) --> }, html([ td([class(judgebuttoncell)], - div([class('btn-group')], + div([class('btn-group'), 'data-toggle'(buttons)], [ \judge_button(agree, A, Field, Js), \judge_button(disagree, A, Field, Js) ]) diff --git a/web/js/dashboard.js b/web/js/dashboard.js index e9287db..be6e60c 100644 --- a/web/js/dashboard.js +++ b/web/js/dashboard.js @@ -1,7 +1,7 @@ YUI().use('event', 'json', 'io', function(Y) { Y.on('domready', function() { - Y.all( '.agreeButton.unchecked').on('click', submitJudgement, null, 'agree', 'disagree', 'add'); - Y.all('.disagreeButton.unchecked').on('click', submitJudgement, null, 'disagree', 'agree', 'add'); + Y.all( '.judgebutton.agree.unchecked').on('click', submitJudgement, null, 'agree', 'disagree', 'add'); + Y.all('.judgebutton.disagree.unchecked').on('click', submitJudgement, null, 'disagree', 'agree', 'add'); }); MOTIVATION = { tagging: 'http://www.w3.org/ns/oa#tagging', @@ -38,16 +38,17 @@ YUI().use('event', 'json', 'io', function(Y) { }, on:{ success: function(e,o) { var r = Y.JSON.parse(o.responseText); - var buttons = button.get('parentNode').all('.judgeButton'); - var peer = null; - if (buttons.item(0) == button) peer = buttons.item(1); - if (buttons.item(1) == button) peer = buttons.item(0); + var buttons = button.get('parentNode').get('parentNode').all('.judgebutton'); + var labels = button.get('parentNode').get('parentNode').all('label.btn'); + labels.removeClass('active'); buttons.setAttribute('judgement', r.annotation['@id']); + buttons.removeClass('checked'); + buttons.addClass('unchecked'); + buttons.on('click', submitJudgement, null, toggleto, type, 'add'); + button.detach('click'); button.removeClass('unchecked'); button.addClass('checked'); - peer.addClass('unchecked'); - peer.removeClass('checked'); - peer.on('click', submitJudgement, null, toggleto, type, 'add'); + button.get('parentNode').addClass('active'); } } }) }