diff --git a/app/assets/javascripts/app/views/publisher_view.js b/app/assets/javascripts/app/views/publisher_view.js index 10f01896b..ae60f0376 100644 --- a/app/assets/javascripts/app/views/publisher_view.js +++ b/app/assets/javascripts/app/views/publisher_view.js @@ -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 diff --git a/app/assets/stylesheets/publisher_blueprint.css.scss b/app/assets/stylesheets/publisher_blueprint.css.scss index 879917660..e01fef626 100644 --- a/app/assets/stylesheets/publisher_blueprint.css.scss +++ b/app/assets/stylesheets/publisher_blueprint.css.scss @@ -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; +} \ No newline at end of file diff --git a/app/views/publisher/_publisher_blueprint.html.haml b/app/views/publisher/_publisher_blueprint.html.haml index b5eb1936f..a34e10893 100644 --- a/app/views/publisher/_publisher_blueprint.html.haml +++ b/app/views/publisher/_publisher_blueprint.html.haml @@ -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" diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 2f36c7c38..ed21bf4c9 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -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}"