-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make poll to be compatible with bootstrap
- Loading branch information
Showing
10 changed files
with
142 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
app.models.PollParticipation = Backbone.Model.extend({ | ||
urlRoot: function(){ | ||
return 'posts/' + this.get('post_id') + "/poll_participations"; | ||
return '/posts/' + this.get('post_id') + "/poll_participations"; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//= require ./poll_view | ||
app.views.PollBlueprint = app.views.Poll.extend({ | ||
templateName: 'poll_blueprint', | ||
|
||
initialize: function(options) { | ||
this.constructor.__super__.initialize.apply(this, options); | ||
this.progressBarFactor = 3; | ||
}, | ||
setProgressBarData: function(progressBar, percent) { | ||
progressBar.css('width', percent * this.progressBarFactor + 'px'); | ||
progressBar.parent().next().html(" - " + percent + "%"); | ||
}, | ||
toggleElements: function() { | ||
this.$('.poll_progress_bar_wrapper').toggle(); | ||
this.$('.percentage').toggle(); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@import '../colors'; | ||
@import '../mixins'; | ||
@import 'new_mixins'; | ||
|
||
.poll_form { | ||
border-top: 1px solid $border-grey; | ||
border-bottom: 1px solid $border-grey; | ||
margin: 10px 0px 10px 0px; | ||
padding: 10px 0px 5px 0px; | ||
|
||
.poll_content { | ||
margin-top: 5px; | ||
} | ||
.toggle_result_wrapper { | ||
display: inline-block; | ||
margin-top: 10px; | ||
} | ||
form { | ||
margin-bottom: 0px; | ||
} | ||
|
||
.progress { | ||
background-image: none; | ||
@include box-shadow(0, 0, 0); | ||
margin-bottom: 5px; | ||
height: 10px !important; | ||
|
||
.bar { | ||
background-image: none; | ||
background-color: $border-dark-grey; | ||
color: $text-dark-grey; | ||
text-align: left; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{{#if poll}} | ||
<div class="poll_form"> | ||
<p class="poll_statistic">{{t "poll.count" count=poll.participation_count}}</p> | ||
<strong>{{poll.question}}</strong><br/> | ||
{{#unless already_participated_in_poll}} | ||
<form action="/posts/{{poll.post_id}}/poll_participations" method="POST"> | ||
{{#poll.poll_answers}} | ||
<input type="radio" name="vote" value="{{id}}"/> | ||
<div class="poll_progress_bar_wrapper" style="display:none;"> | ||
<div class="poll_progress_bar" data-answerid="{{id}}"></div> | ||
</div> | ||
{{answer}} | ||
<p class="percentage" style="display:none;"></p> | ||
<br/> | ||
{{/poll.poll_answers}} | ||
<input type="submit" class="button submit" style="float:right;" value="{{t "poll.vote"}}"/> | ||
</form> | ||
<p class="toggle_result_wrapper"> | ||
<br/><a href="#" class="toggle_result">{{t "poll.show_result"}}</a><br/> | ||
</p> | ||
{{else}} | ||
{{#poll.poll_answers}} | ||
<div class="poll_progress_bar_wrapper"> | ||
<div class="poll_progress_bar" data-answerid="{{id}}"></div> | ||
</div> | ||
{{answer}} | ||
<p class="percentage"></p> | ||
<br/> | ||
{{/poll.poll_answers}} | ||
{{/unless}} | ||
</div> | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,42 @@ | ||
{{#if poll}} | ||
<div class="poll_form"> | ||
<p class="poll_statistic">{{t "poll.count" count=poll.participation_count}}</p> | ||
<strong>{{poll.question}}</strong><br/> | ||
{{#unless already_participated_in_poll}} | ||
<form action="/posts/{{poll.post_id}}/poll_participations" method="POST"> | ||
<div class="row-fluid poll_head"> | ||
<strong>{{{poll.question}}}</strong> | ||
<div class="poll_statistic pull-right"> | ||
{{t "poll.count" count=poll.participation_count}} | ||
</div> | ||
</div> | ||
<div class="row-fluid poll_content"> | ||
{{#unless already_participated_in_poll}} | ||
<form action="/posts/{{poll.post_id}}/poll_participations" method="POST"> | ||
{{#poll.poll_answers}} | ||
<label class="radio result-row"> | ||
<input type="radio" name="vote" value="{{id}}"/> | ||
{{answer}} | ||
<span class="percentage pull-right" style="display: none;"></span> | ||
<div class="poll_progress_bar_wrapper progress" style="display: none"> | ||
<div class="poll_progress_bar bar" data-answerid="{{id}}"> | ||
</div> | ||
</div> | ||
</label> | ||
{{/poll.poll_answers}} | ||
<div class="toggle_result_wrapper"> | ||
<a class="toggle_result" href="#">{{t "poll.show_result"}}</a> | ||
</div> | ||
<input type="submit" class="button submit pull-rigth btn" style="float:right;" value="{{t "poll.vote"}}"/> | ||
</form> | ||
{{else}} | ||
{{#poll.poll_answers}} | ||
<input type="radio" name="vote" value="{{id}}"/> | ||
<div class="poll_progress_bar_wrapper" style="display:none;"> | ||
<div class="poll_progress_bar" data-answerid="{{id}}"></div> | ||
<div class="result-row"> | ||
{{answer}} | ||
<span class="percentage pull-right"></span> | ||
<div class="poll_progress_bar_wrapper progress"> | ||
<div class="poll_progress_bar bar" data-answerid="{{id}}"> | ||
</div> | ||
</div> | ||
</div> | ||
{{answer}} | ||
<p class="percentage" style="display:none;"></p> | ||
<br/> | ||
{{/poll.poll_answers}} | ||
<input type="submit" class="button submit" style="float:right;" value="{{t "poll.vote"}}"/> | ||
</form> | ||
<p class="toggle_result_wrapper"> | ||
<br/><a href="#" class="toggle_result">{{t "poll.show_result"}}</a><br/> | ||
</p> | ||
{{else}} | ||
{{#poll.poll_answers}} | ||
<div class="poll_progress_bar_wrapper"> | ||
<div class="poll_progress_bar" data-answerid="{{id}}"></div> | ||
</div> | ||
{{answer}} | ||
<p class="percentage"></p> | ||
<br/> | ||
{{/poll.poll_answers}} | ||
{{/unless}} | ||
{{/unless}} | ||
</div> | ||
</div> | ||
{{/if}} | ||
{{/if}} |
4 changes: 2 additions & 2 deletions
4
spec/javascripts/app/views/poll_view_spec.js → ...pts/app/views/poll_blueprint_view_spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters