Author: kmorin Date: 2013-06-14 17:12:49 +0200 (Fri, 14 Jun 2013) New Revision: 3829 Url: http://chorem.org/projects/pollen/repository/revisions/3829 Log: i18n + layout + start adding results in the table Added: trunk/pollen-ui-js/src/main/webapp/bundle/ trunk/pollen-ui-js/src/main/webapp/bundle/Messages.properties trunk/pollen-ui-js/src/main/webapp/js/libs/jquery.i18n.properties-min-1.0.9.js Modified: trunk/pollen-ui-js/src/main/webapp/css/style.css trunk/pollen-ui-js/src/main/webapp/index.html trunk/pollen-ui-js/src/main/webapp/js/controls/poll_form.js trunk/pollen-ui-js/src/main/webapp/js/controls/poll_summary.js trunk/pollen-ui-js/src/main/webapp/js/controls/vote.js trunk/pollen-ui-js/src/main/webapp/views/menu.ejs trunk/pollen-ui-js/src/main/webapp/views/poll_form.ejs trunk/pollen-ui-js/src/main/webapp/views/summary.ejs trunk/pollen-ui-js/src/main/webapp/views/vote.ejs Added: trunk/pollen-ui-js/src/main/webapp/bundle/Messages.properties =================================================================== --- trunk/pollen-ui-js/src/main/webapp/bundle/Messages.properties (rev 0) +++ trunk/pollen-ui-js/src/main/webapp/bundle/Messages.properties 2013-06-14 15:12:49 UTC (rev 3829) @@ -0,0 +1,61 @@ +#common +pollen.common.cancel=Annuler +pollen.common.validate=Valider +pollen.common.format.date=dd/MM/yyyy +pollen.common.format.dateTime=dd/MM/yyyy HH:mm +pollen.common.format.time=HH:mm +pollen.common.date.from=à partir du {0} +pollen.common.date.fromTo=du {0} au {1} +pollen.common.date.to=jusqu'au {0} + +#poll attributes +pollen.poll.description.label=Description +pollen.poll.description.placeholder=Description +pollen.poll.title.label=Titre +pollen.poll.title.placeholder=Titre + +#choice attributes +pollen.choice.description.label=Description +pollen.choice.description.placeholder=Description +pollen.choice.name.label=Titre +pollen.choice.name.placeholder=Titre + +#menu +pollen.menu.home=Accueil +pollen.menu.polls=Sondages + +#poll creation form +pollen.poll.form.create.button.save=Créer le sondage +pollen.poll.form.create.field.title.label=Titre +pollen.poll.form.create.field.title.placeholder=Titre +pollen.poll.form.create.title=Création de sondage + +#poll summary +pollen.poll.summary.title=Sondage \'{0}\' +pollen.poll.summary.linkToVote=Lien pour participer : +pollen.poll.summary.part.export.title=Export +pollen.poll.summary.part.export.item.export=Exporter +pollen.poll.summary.part.poll.title=Sondage +pollen.poll.summary.part.poll.item.close=Clore +pollen.poll.summary.part.poll.item.delete=Supprimer +pollen.poll.summary.part.poll.item.duplicate=Dupliquer +pollen.poll.summary.part.poll.item.edit=Modifier +pollen.poll.summary.part.poll.item.history=Historique +pollen.poll.summary.part.poll.item.notification=Notification +pollen.poll.summary.part.voters.title=Participants +pollen.poll.summary.part.voters.item.invite=Inviter des participants +pollen.poll.summary.part.voters.item.contact=Contacter les invités + +#vote +pollen.vote.poll.author=Sondage lancé par {0} +pollen.vote.poll.closed.alert=<strong>Ce sondage est clos.</strong> Vous ne pouvez plus voter. +pollen.vote.choices.list.title=Propositions +pollen.vote.choices.list.button.addChoice=Ajouter un choix +pollen.vote.votes.list.title=Votes +pollen.vote.votes.list.header.voter=Votant +pollen.vote.form.add.field.userName.placeholder=Votre nom +pollen.vote.form.add.button.vote=Voter +pollen.vote.comments.list.title=Commentaires +pollen.vote.comments.list.button.addComment=Ajouter un commentaire +pollen.vote.comments.add.field.userName.placeholder=Votre nom +pollen.vote.comments.add.field.message.placeholder=Votre commentaire \ No newline at end of file Modified: trunk/pollen-ui-js/src/main/webapp/css/style.css =================================================================== --- trunk/pollen-ui-js/src/main/webapp/css/style.css 2013-06-14 13:10:08 UTC (rev 3828) +++ trunk/pollen-ui-js/src/main/webapp/css/style.css 2013-06-14 15:12:49 UTC (rev 3829) @@ -31,17 +31,22 @@ background-position: -313px -119px; } -#content >div { - display: none; +.list.alternate-colors > div { + padding: 10px 20px; } -#choicesSummary { - padding: 20px; - margin-bottom: 30px; - background-color: rgb(238, 238, 238); - border-radius: 6px 6px 6px 6px; +.list.alternate-colors > .even { + background-color: rgb(245, 245, 245); } +.list.alternate-colors .footer { + color: rgb(150, 150, 150); +} + +#content > div { + display: none; +} + #voteForm .choice { background-position: center; background-repeat: no-repeat; Modified: trunk/pollen-ui-js/src/main/webapp/index.html =================================================================== --- trunk/pollen-ui-js/src/main/webapp/index.html 2013-06-14 13:10:08 UTC (rev 3828) +++ trunk/pollen-ui-js/src/main/webapp/index.html 2013-06-14 15:12:49 UTC (rev 3829) @@ -28,7 +28,6 @@ </div> - <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.js"></script> <script src="js/libs/bootstrap.min.js"></script> <script src="js/libs/can.jquery.js"></script> @@ -38,6 +37,7 @@ <script src="js/libs/can.observe.delegate.js"></script> <script src="js/libs/jquery.scrollto.js"></script> <script src="js/libs/date.js"></script> + <script src="js/libs/jquery.i18n.properties-min-1.0.9.js"></script> <script src="js/models/polls.js"></script> <script src="js/models/comments.js"></script> @@ -50,15 +50,30 @@ <script type="text/javascript"> - var menu = new Menu('#menu'); + // This will initialize the plugin + // and show two dialog boxes: one with the text "Olá World" + // and other with the text "Good morning John!" + $.i18n.properties({ + name:'Messages', + path:'bundle/', + mode:'both', + language:'fr_FR', + callback: function() { - var pf = new PollForm('#pollForm'); - var summary = new PollSummary('#pollSummary'); - var vote = new PollVote('#vote'); + var menu = new Menu('#menu'); - can.route(':type/:action'); - can.route(':type/:id/:action'); + var pf = new PollForm('#pollForm'); + var summary = new PollSummary('#pollSummary'); + var vote = new PollVote('#vote'); + can.route(':type/:action'); + can.route(':type/:id/:action'); + + } + }); + + + </script> </body> Modified: trunk/pollen-ui-js/src/main/webapp/js/controls/poll_form.js =================================================================== --- trunk/pollen-ui-js/src/main/webapp/js/controls/poll_form.js 2013-06-14 13:10:08 UTC (rev 3828) +++ trunk/pollen-ui-js/src/main/webapp/js/controls/poll_form.js 2013-06-14 15:12:49 UTC (rev 3829) @@ -13,18 +13,6 @@ }, - '{can.route} change': function(data, ev, prop, how, newVal, oldVal ) { - if (prop === "type" && (how === "set" || how === "add")) { - if (newVal != "poll") { - this.element.hide(); - } - } else if (prop === "action" && (how === "set" || how === "add")) { - if (newVal != "edit") { - this.element.hide(); - } - } - }, - ':type/:action route': function(data) { if (data.type === "poll" && data.action === "edit") { this.editPoll(new Poll()); @@ -74,10 +62,10 @@ }, editPoll: function(poll) { - console.log("edit poll " + poll.id + " : " + poll.description); this.options.poll = poll; this.on(); this.refreshForm(); + this.element.siblings().hide(); this.element.show(); }, Modified: trunk/pollen-ui-js/src/main/webapp/js/controls/poll_summary.js =================================================================== --- trunk/pollen-ui-js/src/main/webapp/js/controls/poll_summary.js 2013-06-14 13:10:08 UTC (rev 3828) +++ trunk/pollen-ui-js/src/main/webapp/js/controls/poll_summary.js 2013-06-14 15:12:49 UTC (rev 3829) @@ -1,17 +1,5 @@ var PollSummary = can.Control({ - '{can.route} change': function(data, ev, prop, how, newVal, oldVal ) { - if (prop === "type" && (how === "set" || how === "add")) { - if (newVal != "poll") { - this.element.hide(); - } - } else if (prop === "action" && (how === "set" || how === "add")) { - if (newVal != "summary") { - this.element.hide(); - } - } - }, - ':type/:id/:action route': function(data) { if (data.type === "poll" && data.action === "summary") { var self = this; @@ -27,6 +15,7 @@ this.element.html(can.view('views/summary.ejs', { poll: poll })); + this.element.siblings().hide(); this.element.show(); } Modified: trunk/pollen-ui-js/src/main/webapp/js/controls/vote.js =================================================================== --- trunk/pollen-ui-js/src/main/webapp/js/controls/vote.js 2013-06-14 13:10:08 UTC (rev 3828) +++ trunk/pollen-ui-js/src/main/webapp/js/controls/vote.js 2013-06-14 15:12:49 UTC (rev 3829) @@ -2,18 +2,6 @@ // route - '{can.route} change': function(data, ev, prop, how, newVal, oldVal ) { - if (prop === "type" && (how === "set" || how === "add")) { - if (newVal != "poll") { - this.element.hide(); - } - } else if (prop === "action" && (how === "set" || how === "add")) { - if (newVal != "vote") { - this.element.hide(); - } - } - }, - ':type/:id/:action route': function(data) { if (data.type === "poll" && data.action === "vote") { var self = this; @@ -80,7 +68,11 @@ var author = form.find("[name='author']").val(); var message = form.find("[name='message']").val(); - var comment = new Comment({ author: author, text: message }); + var comment = new Comment({ + author: author, + text: message, + postDate: new Date().getTime() + }); var self = this; comment.save({ pollId: this.options.poll.id }, function(data) { @@ -116,6 +108,7 @@ comments: comments, votes: votes })); + this.element.siblings().hide(); this.element.show(); }, Added: trunk/pollen-ui-js/src/main/webapp/js/libs/jquery.i18n.properties-min-1.0.9.js =================================================================== --- trunk/pollen-ui-js/src/main/webapp/js/libs/jquery.i18n.properties-min-1.0.9.js (rev 0) +++ trunk/pollen-ui-js/src/main/webapp/js/libs/jquery.i18n.properties-min-1.0.9.js 2013-06-14 15:12:49 UTC (rev 3829) @@ -0,0 +1,9 @@ +(function(k){function n(c,a){k.ajax({url:c,async:!1,cache:a.cache,contentType:"text/plain;charset="+a.encoding,dataType:"text",success:function(b){r(b,a.mode)}})}function r(c,a){for(var b="",e=c.split(/\n/),d=/(\{\d+\})/g,q=/\{(\d+)\}/g,m=/(\\u.{4})/ig,f=0;f<e.length;f++)if(e[f]=e[f].replace(/^\s\s*/,"").replace(/\s\s*$/,""),e[f].length>0&&e[f].match("^#")!="#"){var g=e[f].split("=");if(g.length>0){for(var o=unescape(g[0]).replace(/^\s\s*/,"").replace(/\s\s*$/,""),h=g.length==1?"":g[1];h.match(/\\$/)== +"\\";)h=h.substring(0,h.length-1),h+=e[++f].replace(/\s\s*$/,"");for(var l=2;l<g.length;l++)h+="="+g[l];h=h.replace(/^\s\s*/,"").replace(/\s\s*$/,"");if(a=="map"||a=="both"){if(g=h.match(m))for(l=0;l<g.length;l++)h=h.replace(g[l],s(g[l]));k.i18n.map[o]=h}if(a=="vars"||a=="both")if(h=h.replace(/"/g,'\\"'),t(o),d.test(h)){for(var g=h.split(d),l=!0,j="",n=[],p=0;p<g.length;p++)if(d.test(g[p])&&(n.length==0||n.indexOf(g[p])==-1))l||(j+=","),j+=g[p].replace(q,"v$1"),n.push(g[p]),l=!1;b+=o+"=function("+ +j+"){";o='"'+h.replace(q,'"+v$1+"')+'"';b+="return "+o+";};"}else b+=o+'="'+h+'";'}}eval(b)}function t(c){if(/\./.test(c))for(var a="",c=c.split(/\./),b=0;b<c.length;b++)b>0&&(a+="."),a+=c[b],eval("typeof "+a+' == "undefined"')&&eval(a+"={};")}function s(c){var a=[],c=parseInt(c.substr(2),16);c>=0&&c<Math.pow(2,16)&&a.push(c);for(var c="",b=0;b<a.length;++b)c+=String.fromCharCode(a[b]);return c}k.i18n={};k.i18n.map={};k.i18n.properties=function(c){c=k.extend({name:"Messages",language:"",path:"",mode:"vars", +cache:!1,encoding:"UTF-8",callback:null},c);if(c.language===null||c.language=="")c.language=k.i18n.browserLang();if(c.language===null)c.language="";var a=c.name&&c.name.constructor==Array?c.name:[c.name];for(i=0;i<a.length;i++)n(c.path+a[i]+".properties",c),c.language.length>=2&&n(c.path+a[i]+"_"+c.language.substring(0,2)+".properties",c),c.language.length>=5&&n(c.path+a[i]+"_"+c.language.substring(0,5)+".properties",c);c.callback&&c.callback()};k.i18n.prop=function(c){var a=k.i18n.map[c];if(a==null)return"["+ +c+"]";var b;if(typeof a=="string"){for(b=0;(b=a.indexOf("\\",b))!=-1;)a=a[b+1]=="t"?a.substring(0,b)+"\t"+a.substring(b++ +2):a[b+1]=="r"?a.substring(0,b)+"\r"+a.substring(b++ +2):a[b+1]=="n"?a.substring(0,b)+"\n"+a.substring(b++ +2):a[b+1]=="f"?a.substring(0,b)+"\u000c"+a.substring(b++ +2):a[b+1]=="\\"?a.substring(0,b)+"\\"+a.substring(b++ +2):a.substring(0,b)+a.substring(b+1);var e=[],d,j;for(b=0;b<a.length;)if(a[b]=="'")if(b==a.length-1)a=a.substring(0,b);else if(a[b+1]=="'")a=a.substring(0,b)+ +a.substring(++b);else{for(d=b+2;(d=a.indexOf("'",d))!=-1;)if(d==a.length-1||a[d+1]!="'"){a=a.substring(0,b)+a.substring(b+1,d)+a.substring(d+1);b=d-1;break}else a=a.substring(0,d)+a.substring(++d);d==-1&&(a=a.substring(0,b)+a.substring(b+1))}else if(a[b]=="{")if(d=a.indexOf("}",b+1),d==-1)b++;else if(j=parseInt(a.substring(b+1,d)),!isNaN(j)&&j>=0){var m=a.substring(0,b);m!=""&&e.push(m);e.push(j);b=0;a=a.substring(d+1)}else b=d+1;else b++;a!=""&&e.push(a);a=e;k.i18n.map[c]=e}if(a.length==0)return""; +if(a.lengh==1&&typeof a[0]=="string")return a[0];m="";for(b=0;b<a.length;b++)m+=typeof a[b]=="string"?a[b]:a[b]+1<arguments.length?arguments[a[b]+1]:"{"+a[b]+"}";return m};k.i18n.browserLang=function(){var c=navigator.language||navigator.userLanguage,c=c.toLowerCase();c.length>3&&(c=c.substring(0,3)+c.substring(3).toUpperCase());return c};var j;if(!j)j=function(c,a,b){if(Object.prototype.toString.call(a)!=="[object RegExp]")return typeof j._nativeSplit=="undefined"?c.split(a,b):j._nativeSplit.call(c, +a,b);var e=[],d=0,k=(a.ignoreCase?"i":"")+(a.multiline?"m":"")+(a.sticky?"y":""),a=RegExp(a.source,k+"g"),m,f,g;c+="";j._compliantExecNpcg||(m=RegExp("^"+a.source+"$(?!\\s)",k));if(b===void 0||+b<0)b=Infinity;else if(b=Math.floor(+b),!b)return[];for(;f=a.exec(c);){k=f.index+f[0].length;if(k>d&&(e.push(c.slice(d,f.index)),!j._compliantExecNpcg&&f.length>1&&f[0].replace(m,function(){for(var a=1;a<arguments.length-2;a++)arguments[a]===void 0&&(f[a]=void 0)}),f.length>1&&f.index<c.length&&Array.prototype.push.apply(e, +f.slice(1)),g=f[0].length,d=k,e.length>=b))break;a.lastIndex===f.index&&a.lastIndex++}d===c.length?(g||!a.test(""))&&e.push(""):e.push(c.slice(d));return e.length>b?e.slice(0,b):e},j._compliantExecNpcg=/()??/.exec("")[1]===void 0,j._nativeSplit=String.prototype.split;String.prototype.split=function(c,a){return j(this,c,a)}})(jQuery); \ No newline at end of file Modified: trunk/pollen-ui-js/src/main/webapp/views/menu.ejs =================================================================== --- trunk/pollen-ui-js/src/main/webapp/views/menu.ejs 2013-06-14 13:10:08 UTC (rev 3828) +++ trunk/pollen-ui-js/src/main/webapp/views/menu.ejs 2013-06-14 15:12:49 UTC (rev 3829) @@ -1,2 +1,2 @@ -<li><%== can.route.link('Sondage', { type: 'poll', action: 'edit' }) %></li> -<li><%== can.route.link('Autre', { type: 'other', action: 'donothing' }) %></li> \ No newline at end of file +<li><%== can.route.link(pollen.menu.home, {}) %></li> +<li><%== can.route.link(pollen.menu.polls, { type: 'poll', action: 'edit' }) %></li> \ No newline at end of file Modified: trunk/pollen-ui-js/src/main/webapp/views/poll_form.ejs =================================================================== --- trunk/pollen-ui-js/src/main/webapp/views/poll_form.ejs 2013-06-14 13:10:08 UTC (rev 3828) +++ trunk/pollen-ui-js/src/main/webapp/views/poll_form.ejs 2013-06-14 15:12:49 UTC (rev 3829) @@ -1,19 +1,19 @@ -<h1>Création de sondage</h1> +<h1><%= pollen.poll.form.create.title %></h1> <form id='pollCreationForm' class="form-horizontal"> <div class="control-group"> - <label class="control-label" for="pollCreationFormTitle">Title</label> + <label class="control-label" for="pollCreationFormTitle"><%= pollen.poll.title.label %></label> <div class="controls"> - <input type='text' name='title' id='pollCreationFormTitle' placeholder='title' + <input type='text' name='title' id='pollCreationFormTitle' placeholder='<%= pollen.poll.title.placeholder %>' <%= poll.attr("title") ? "value='" + poll.attr("title") + "'" : "class='empty'" %>/> </div> </div> <div class="control-group"> - <label class="control-label" for='pollCreationFormDescription'>Description</label> + <label class="control-label" for='pollCreationFormDescription'><%= pollen.poll.description.label %></label> <div class="controls"> - <textarea id='pollCreationFormDescription' name='description' + <textarea id='pollCreationFormDescription' name='description' placeholder="<%= pollen.poll.description.placeholder %>" <% if (!poll.attr("description")) {%> class='empty' <% } %>><%= poll.attr('description') %></textarea> @@ -21,7 +21,7 @@ </div> <div class="form-actions"> - <a href="javascript://" class="btn btn-primary save">Save</a> + <a href="javascript://" class="btn btn-primary save"><%= pollen.poll.form.create.button.save %></a> <a href="javascript://" class="btn btn-primary create">New poll</a> <a href="javascript://" data-id="1" class="btn btn">Edit poll 1</a> <a href="javascript://" data-id="2" class="btn btn">Edit poll 2</a> Modified: trunk/pollen-ui-js/src/main/webapp/views/summary.ejs =================================================================== --- trunk/pollen-ui-js/src/main/webapp/views/summary.ejs 2013-06-14 13:10:08 UTC (rev 3828) +++ trunk/pollen-ui-js/src/main/webapp/views/summary.ejs 2013-06-14 15:12:49 UTC (rev 3829) @@ -1,36 +1,36 @@ -<h1>Sondage <%= poll.title %></h1> +<h1><%= pollen.poll.summary.title(poll.title) %></h1> <div class="control-group"> - <label class="control-label" for='pollSummaryLink'>Lien pour participer</label> + <label class="control-label" for='pollSummaryLink'><%= pollen.poll.summary.linkToVote %></label> <input type='url' id='pollSummaryLink' value="<%== window.location.href.split('#')[0] + can.route.url({ type: 'poll', action: 'vote', id: poll.id }) %>"/> <%== can.route.link('<i class="icon-link bigger link"></i>', {type: 'poll', action: 'vote', id: poll.id}) %> </div> <div class='row-fluid'> <div class='span4'> - <h2>Sondage</h2> + <h2><%= pollen.poll.summary.part.poll.title %></h2> <ul class='noListStyle'> - <li><%== can.route.link('<i class="icon-ok"></i>Clore', {}) %></li> - <li><%== can.route.link('<i class="icon-pencil"></i>Modifer', {type: 'poll', action: 'edit', id: poll.id}) %></li> - <li><%== can.route.link('<i class="icon-envelope"></i>Notification', {}) %></li> - <li><%== can.route.link('<i class="icon-time"></i>Historique', {}) %></li> - <li><%== can.route.link('<i class="icon-clone"></i>Créer un duplicata', {}) %></li> - <li><%== can.route.link('<i class="icon-trash"></i>Effacer', {}) %></li> + <li><%== can.route.link('<i class="icon-ok"></i>' + pollen.poll.summary.part.poll.item.close, {}) %></li> + <li><%== can.route.link('<i class="icon-pencil"></i>' + pollen.poll.summary.part.poll.item.edit, {type: 'poll', action: 'edit', id: poll.id}) %></li> + <li><%== can.route.link('<i class="icon-envelope"></i>' + pollen.poll.summary.part.poll.item.notification, {}) %></li> + <li><%== can.route.link('<i class="icon-time"></i>' + pollen.poll.summary.part.poll.item.history, {}) %></li> + <li><%== can.route.link('<i class="icon-clone"></i>' + pollen.poll.summary.part.poll.item.duplicate, {}) %></li> + <li><%== can.route.link('<i class="icon-trash"></i>' + pollen.poll.summary.part.poll.item.delete, {}) %></li> </ul> </div> <div class='span4'> - <h2>Participants</h2> + <h2><%= pollen.poll.summary.part.voters.title %></h2> <ul class='noListStyle'> - <li><%== can.route.link('<i class="icon-user"></i>Inviter des participants', {}) %></li> - <li><%== can.route.link('<i class="icon-envelope"></i>Contacter les invités', {}) %></li> + <li><%== can.route.link('<i class="icon-user"></i>' + pollen.poll.summary.part.voters.item.invite, {}) %></li> + <li><%== can.route.link('<i class="icon-envelope"></i>' + pollen.poll.summary.part.voters.item.contact, {}) %></li> </ul> </div> <div class='span4'> - <h2>Export</h2> + <h2><%= pollen.poll.summary.part.export.title %></h2> <ul class='noListStyle'> - <li><i class="icon-upload"></i>clore</li> + <li><%== can.route.link('<i class="icon-upload"></i>'+ pollen.poll.summary.part.export.item.export, {}) %></li> </ul> </div> </div> \ No newline at end of file Modified: trunk/pollen-ui-js/src/main/webapp/views/vote.ejs =================================================================== --- trunk/pollen-ui-js/src/main/webapp/views/vote.ejs 2013-06-14 13:10:08 UTC (rev 3828) +++ trunk/pollen-ui-js/src/main/webapp/views/vote.ejs 2013-06-14 15:12:49 UTC (rev 3829) @@ -3,18 +3,18 @@ <h1><%= poll.attr('title') %></h1> <p> - Sondage lancé par <%= poll.attr('creatorName') %> + <%= pollen.vote.poll.author(poll.attr('creatorName')) %> <!-- number of votes --> | <a id="voteSummary" class='link'><i class='icon-user'></i> <%= votes.attr('length') %></a> <!-- number of comments--> | <a id="commentSummary" class='link'><i class='icon-comment'></i> <%= comments.attr('length') %></a> <!-- poll dates --> <% if (poll.attr('beginDate') && poll.attr('endDate')) { %> - | <i class='icon-time'></i> du <%= new Date(poll.attr('beginDate')).toString("dd/MM/yyyy") %> au <%= new Date(poll.attr('endDate')).toString("dd/MM/yyyy") %> + | <i class='icon-time'></i> <%= pollen.common.date.fromTo(new Date(poll.attr('beginDate')).toString(pollen.common.format.date), new Date(poll.attr('endDate')).toString(pollen.common.format.date)) %> <% } else if (poll.attr('beginDate')) { %> - | <i class='icon-time'></i> à partir du <%= new Date(poll.attr('beginDate')).toString("dd/MM/yyyy") %> + | <i class='icon-time'></i> <%= pollen.common.date.from(new Date(poll.attr('beginDate')).toString(pollen.common.format.date)) %> <% } else if (poll.attr('endDate')) { %> - | <i class='icon-time'></i> jusqu'au <%= new Date(poll.attr('endDate')).toString("dd/MM/yyyy") %> + | <i class='icon-time'></i> <%= pollen.common.date.to(new Date(poll.attr('endDate')).toString(pollen.common.format.date)) %> <% } %> </p> @@ -26,14 +26,14 @@ <% if (poll.attr('closed')) { %> <div class="alert fade in"> <button type="button" class="close" data-dismiss="alert">×</button> - <strong>Ce sondage est clos.</strong> Vous ne pouvez plus voter. + <%== pollen.vote.poll.closed.alert %> </div> <% } %> <!-- list of the choices --> -<div id='choicesSummary'> +<div class='well'> - <h3>Propositions</h3> + <h3><%= pollen.vote.choices.list.title %></h3> <ol> <% poll.choices.each(function(choice) { %> @@ -45,14 +45,14 @@ <!-- link to show/hide the new choice form --> <button class="collapsed btn btn-link" data-toggle="collapse" data-target="#addChoiceForm"> - Ajouter un choix <i class="icon-collapse"></i> + <%= pollen.vote.choices.list.button.addChoice %> <i class="icon-collapse"></i> </button> <!-- form to add a new choice to the poll --> <form id="addChoiceForm" class="collapse"> - <input type="text" name="name" placeholder="Nom"/> - <textarea name="description" placeholder="Description"></textarea> - <button type="submit" class="btn btn-primary">Valider</button> + <input type="text" name="name" placeholder="<%= pollen.choice.name.placeholder %>"/> + <textarea name="description" placeholder="<%= pollen.choice.description.placeholder %>"></textarea> + <button type="submit" class="btn btn-primary"><%= pollen.common.validate %></button> </form> <% } %> </div> @@ -60,14 +60,17 @@ <!-- table of the votes --> <form id="voteForm"> + <h2><%= pollen.vote.votes.list.title %></h2> + <table id="voteTable" class="table table-bordered table-striped"> - <caption>Votes</caption> + <% var results = new can.Observe.List(new Array(poll.attr('choices.length'))); %> <thead> <tr> - <th>Votant</th> - <% poll.choices.each(function(choice) { %> + <th><%= pollen.vote.votes.list.header.voter %></th> + <% poll.choices.each(function(choice, i) { %> <th data-container='body' data-placement='top' title='<%= choice.attr("description") %>'> <%= choice.attr('name') %> + <% results[i] = 0 %> </th> <% }); %> </tr> @@ -81,22 +84,34 @@ var voteChoice = vote.voteToChoices.attr(i); if (voteChoice == null) { %> - <td class='choice voteBeforeChoice'></td> + <td class='choice voteBeforeChoice'></td> <% } else { %> - <td class='choice <%= voteChoice.attr("voteValue") ? "selected" : "notSelected" %>'> - <%= voteChoice.attr("voteValue") ? "OK" : "" %> - </td> - <% + <td class='choice <%= voteChoice.attr("voteValue") ? "selected" : "notSelected" %>'> + <%= voteChoice.attr("voteValue") ? "OK" : "" %> + </td> + <% + if (voteChoice.attr("voteValue")) { + // todo 20130614 kmorin check why if we do a results.attr(i, results[i] +1) ==> too much recursion + results[i] = results[i] + 1 + } } }); %> </tr> - <% - }); - if (!poll.attr('closed')) { - %> + <% }); %> + + <tr> + <td>Resultats</td> + <% poll.choices.each(function(choice, i) { %> + <td class='result'> + <%= results.attr(i) %> + </td> + <% }); %> + </tr> + + <% if (!poll.attr('closed')) { %> <tr> - <td><input name="userName" type='text'/></td> + <td><input name="userName" type='text' placeholder='<%= pollen.vote.form.add.field.userName.placeholder %>'/></td> <%poll.choices.each(function(choice, i) { %> <td><input name="<%= i %>" type='checkbox'/></td> <% }); %> @@ -107,7 +122,7 @@ <% if (!poll.attr('closed')) { %> <div class="form-actions"> - <button type="submit" id="voteButton" class="btn btn-primary">Voter</button> + <button type="submit" id="voteButton" class="btn btn-primary"><%= pollen.vote.form.add.button.vote %></button> </div> <% } %> @@ -115,27 +130,30 @@ <!-- Comments --> <div id="comments"> - <h2>Commentaires</h2> + <h2><%= pollen.vote.comments.list.title %></h2> <button class="collapsed btn btn-link" data-toggle="collapse" data-target="#addCommentForm"> - Ajouter un commentaire <i class="icon-collapse"></i> + <%= pollen.vote.comments.list.button.addComment %> <i class="icon-collapse"></i> </button> <form id="addCommentForm" class="collapse"> - <input type="text" name="author" placeholder="Votre nom"/> - <textarea name="message" placeholder="Entrez votre message"></textarea> + <input type="text" name="author" placeholder="<%= pollen.vote.comments.add.field.userName.placeholder %>"/> + <textarea name="message" placeholder="<%= pollen.vote.comments.add.field.message.placeholder %>"></textarea> <button type="submit" class="btn btn-primary">Valider</button> </form> - <dl> - <% comments.each(function(comment) { %> + <div class='list alternate-colors'> + <% comments.each(function(comment, i) { %> - <dt><%= comment.attr('author') %> - <em><%= new Date(comment.attr('postDate')).toString("dd/MM/yyyy hh:mm") %></em></dt> - <dd> - <%= comment.attr('text') %> - </dd> - </div> + <div class="<%= i % 2 ? 'odd' : 'even' %>"> + <p> + <%= comment.attr('text') %> + </p> + <div class='footer'> + <small><%= comment.attr('author') %> | <%= new Date(comment.attr('postDate')).toString(pollen.common.format.dateTime) %></small> + </div> + </div> <% }); %> - </dl> + </div> </div> \ No newline at end of file