poll form completed
This commit is contained in:
parent
95d98ff2b6
commit
18a43295b7
4 changed files with 62 additions and 16 deletions
|
|
@ -32,6 +32,7 @@ app.views.Publisher = Backbone.View.extend({
|
|||
|
||||
initialize : function(opts){
|
||||
this.standalone = opts ? opts.standalone : false;
|
||||
this.option_counter = 1;
|
||||
|
||||
// init shortcut references to the various elements
|
||||
this.el_input = this.$('#status_message_fake_text');
|
||||
|
|
@ -182,16 +183,29 @@ app.views.Publisher = Backbone.View.extend({
|
|||
},
|
||||
|
||||
addPollAnswer: function(){
|
||||
if($(".poll_answer").size() == 1) {
|
||||
$(".remove_poll_answer").css("visibility","visible");
|
||||
}
|
||||
|
||||
this.option_counter++;
|
||||
var clone = this.el_poll_answer.clone();
|
||||
var count_of_answers = $('.poll_answer_input').size()+1;
|
||||
clone.children('.poll_answer_input').attr("name", "poll_answer_"+count_of_answers);
|
||||
this.el_poll_answer.last().after(clone);
|
||||
|
||||
var answer = clone.find('.poll_answer_input');
|
||||
answer.attr("name", "poll_answer_" + this.option_counter);
|
||||
|
||||
var placeholder = answer.attr("placeholder");
|
||||
var expression = /[^0-9]+/;
|
||||
answer.attr("placeholder", expression.exec(placeholder) + this.option_counter);
|
||||
|
||||
$('#poll_creator_wrapper .poll_answer').last().after(clone);
|
||||
},
|
||||
|
||||
removePollAnswer: function(evt){
|
||||
if($(".poll_answer_input").size() > 1) {
|
||||
$(evt.target).parent().remove();
|
||||
$(evt.target).parent().remove();
|
||||
if($(".poll_answer").size() == 1) {
|
||||
$(".remove_poll_answer").css("visibility","hidden");;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
// avoid submitting form when pressing Enter key
|
||||
|
|
|
|||
|
|
@ -324,8 +324,36 @@
|
|||
display:none;
|
||||
border: 1px solid $border-dark-grey;
|
||||
padding:5px;
|
||||
@include border-radius(2px);
|
||||
}
|
||||
|
||||
.remove_poll_answer {
|
||||
display:inline;
|
||||
visibility:hidden;
|
||||
float:right;
|
||||
display: table-cell;
|
||||
}
|
||||
|
||||
.poll_answer_input {
|
||||
width:100%;
|
||||
}
|
||||
|
||||
#add_poll_answer_wrapper {
|
||||
padding:5px 0 5px 0;
|
||||
display:block;
|
||||
}
|
||||
|
||||
#poll_question {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
}
|
||||
|
||||
.poll_answer {
|
||||
display: table;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.poll_answer_input_wrapper {
|
||||
display: table-cell;
|
||||
}
|
||||
|
|
@ -38,15 +38,16 @@
|
|||
#location_container
|
||||
%br
|
||||
#poll_creator_wrapper
|
||||
= 'Poll creation'
|
||||
%br
|
||||
%input{:id => 'poll_question', :placeholder => 'Question', :name => 'poll_question', :class => 'span-12'}
|
||||
%div{:class => 'poll_answer span-12'}
|
||||
%input{:class => 'poll_answer_input span-8', :placeholder => 'Answer', :name => 'poll_answer_1'}
|
||||
%a{:class => 'remove_poll_answer span-3'}
|
||||
= t('shared.publisher.poll.add_a_poll')
|
||||
%input{:id => 'poll_question', :placeholder => t('shared.publisher.poll.question'), :name => 'poll_question'}
|
||||
.poll_answer
|
||||
%span{:class => 'poll_answer_input_wrapper'}
|
||||
%input{:class => 'poll_answer_input', :placeholder => t('shared.publisher.poll.option'), :name => 'poll_answer_1'}
|
||||
%a{:class => 'remove_poll_answer'}
|
||||
= t('shared.publisher.poll.remove_poll_answer')
|
||||
%div{:id => 'add_poll_answer', :class => 'button creation'}
|
||||
= t('shared.publisher.poll.add_poll_answer')
|
||||
#add_poll_answer_wrapper
|
||||
#add_poll_answer{:class => 'button creation'}
|
||||
= t('shared.publisher.poll.add_poll_answer')
|
||||
|
||||
- if publisher_public
|
||||
= hidden_field_tag 'aspect_ids[]', "public"
|
||||
|
|
|
|||
|
|
@ -1046,8 +1046,11 @@ en:
|
|||
i_like: "I'm interested in %{tags}. "
|
||||
invited_by: "Thanks for the invite, "
|
||||
poll:
|
||||
remove_poll_answer: "Remove answer"
|
||||
add_poll_answer: "Add answer"
|
||||
remove_poll_answer: "Remove option"
|
||||
add_poll_answer: "Add option"
|
||||
add_a_poll: "Add a poll"
|
||||
question: "Question"
|
||||
option: "Option 1"
|
||||
add_contact:
|
||||
enter_a_diaspora_username: "Enter a diaspora* username:"
|
||||
your_diaspora_username_is: "Your diaspora* username is: %{diaspora_handle}"
|
||||
|
|
|
|||
Loading…
Reference in a new issue