Skip to content

Commit

Permalink
A bit of work on #22 and other fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gvilarino committed Sep 16, 2013
1 parent a8b21a2 commit 48077d5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
9 changes: 6 additions & 3 deletions lib/homepage/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,13 @@ article.proposal .share-links a.google-plus:hover {
background: #c0392b;
}
.proposal-options {
width: 200px;
position: absolute;
top: 30px;
right: 20px;
}
.proposal-options .vote-options .vote-option {
display: block;
display: inline-block;
width: 200px;
margin-right: 20px;
color: #fff;
text-transform: uppercase;
font-weight: bold;
Expand Down Expand Up @@ -323,6 +323,9 @@ article.proposal .share-links a.google-plus:hover {
.proposal-options .vote-options .vote-option.vote-abstain {
background-color: #666;
}
.proposal-options .vote-options .vote-option.delegate-vote {
background-color: #3498db;
}
.proposal-options .vote-box,
.proposal-options .results-box {
border: 1px solid #eee;
Expand Down
8 changes: 5 additions & 3 deletions lib/homepage/main.styl
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,14 @@ article.proposal


.proposal-options
width: 200px;
position: absolute;
top: 30px;
right: spacing;

.vote-options
.vote-option
display: block;
display: inline-block;
width: 200px;
margin-right: 20px;
color: white;
text-transform: uppercase;
font-weight: bold;
Expand All @@ -313,6 +313,8 @@ article.proposal

&.vote-abstain
background-color: #666;
&.delegate-vote
background-color: #3498db;

.vote-box, .results-box
border: 1px solid #eee;
Expand Down
3 changes: 2 additions & 1 deletion lib/proposal-options/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"visionmedia/superagent": "*",
"visionmedia/page.js": "*",
"visionmedia/jade": "*",
"cristiandouce/Chart.js": "*"
"cristiandouce/Chart.js": "*",
"discore/closest": "*"
},
"local": [ ],
"scripts": [ "proposal-options.js" ],
Expand Down
11 changes: 3 additions & 8 deletions lib/proposal-options/options.jade
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
a.vote-option.vote-no(href="#", data-proposal=proposal.id)
i.flaticon.solid.thumbs-up-1
span Negative

a(href="") Ver resultados

//- h5 Delegations
.results-box
h5 Results
canvas(id="vote-chart", width="200", height="220")
a.vote-option.delegate-vote(href="#", data-proposal=proposal.id)
i.flaticon.solid.thumbs-up-1
span Delegate
14 changes: 8 additions & 6 deletions lib/proposal-options/proposal-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ var page = require('page')
, classes = require('classes')
, request = require('superagent')
, options = require('./options')
, Chart = require('Chart.js');
, closest = require('closest')
, Chart = require('Chart.js')
, log = require('debug')('proposal-options');

/**
* Expose ProposalOptions.
Expand Down Expand Up @@ -65,7 +67,7 @@ ProposalOptions.prototype.showvote = function(ev) {
ProposalOptions.prototype.vote = function(ev) {
ev.preventDefault();

var target = ev.target.parentNode
var target = closest(ev.target, '.vote-option')
, id = target.getAttribute('data-proposal')
, value;

Expand All @@ -81,20 +83,20 @@ ProposalOptions.prototype.vote = function(ev) {
.send({value:value})
.end(function (err, res) {
if (err) {
console.log(err);
log(err);
return;
};

if (res.body.error) {
console.log(res.body.error);
log(res.body.error);
if (res.body.action && res.body.action.redirect) {
return window.location.replace(res.body.action.redirect);
};
}
// reload location.
page(window.location.pathname);
});
}
}

/**
* Render options
Expand All @@ -104,7 +106,7 @@ ProposalOptions.prototype.vote = function(ev) {
*/

ProposalOptions.prototype.render = function() {
this.renderChart();
// this.renderChart();
return this.options;
}

Expand Down

0 comments on commit 48077d5

Please sign in to comment.