From 42a3e702e68595af66540aad3ad7b0720fce884e Mon Sep 17 00:00:00 2001 From: Steffen van Bergerem Date: Sat, 11 Oct 2014 16:56:34 +0200 Subject: [PATCH] Fix poll for Bootstrap publisher --- .../app/views/publisher/poll_creator_view.js | 5 ++-- .../javascripts/app/views/publisher_view.js | 2 +- app/assets/stylesheets/publisher.css.scss | 15 ++++++++--- .../stylesheets/publisher_blueprint.css.scss | 11 ++++---- app/assets/templates/poll_creator_tpl.jst.hbs | 25 ++++++++++--------- .../publisher/_publisher_blueprint.html.haml | 2 +- .../publisher/_publisher_bootstrap.html.haml | 12 ++------- features/desktop/post_with_a_poll.feature | 14 +++++------ .../step_definitions/post_with_poll_steps.rb | 6 ++--- 9 files changed, 46 insertions(+), 46 deletions(-) diff --git a/app/assets/javascripts/app/views/publisher/poll_creator_view.js b/app/assets/javascripts/app/views/publisher/poll_creator_view.js index ebc6755aa..f443801c5 100644 --- a/app/assets/javascripts/app/views/publisher/poll_creator_view.js +++ b/app/assets/javascripts/app/views/publisher/poll_creator_view.js @@ -71,15 +71,14 @@ app.views.PublisherPollCreator = app.views.Base.extend({ }, validateInput: function(input){ - var wrapper = input.parents('.control-group'); var isValid = this.isValidInput(input); if(isValid){ - wrapper.removeClass('error'); + input.removeClass('error'); return true; } else { - wrapper.addClass('error'); + input.addClass('error'); return false; } }, diff --git a/app/assets/javascripts/app/views/publisher_view.js b/app/assets/javascripts/app/views/publisher_view.js index 2f20a3b44..a14b55df7 100644 --- a/app/assets/javascripts/app/views/publisher_view.js +++ b/app/assets/javascripts/app/views/publisher_view.js @@ -123,7 +123,7 @@ app.views.Publisher = Backbone.View.extend({ this.view_uploader.on('change', this.checkSubmitAvailability, this); this.view_poll_creator = new app.views.PublisherPollCreator({ - el: this.$('#publisher-poll-creator') + el: this.$('#poll_creator_container') }); this.view_poll_creator.on('change', this.checkSubmitAvailability, this); this.view_poll_creator.render(); diff --git a/app/assets/stylesheets/publisher.css.scss b/app/assets/stylesheets/publisher.css.scss index 696f573d6..6326d8ea1 100644 --- a/app/assets/stylesheets/publisher.css.scss +++ b/app/assets/stylesheets/publisher.css.scss @@ -50,7 +50,7 @@ border-radius: 3px; border: 1px solid $border-dark-grey; - input[type='text'] { + input[type='text']#status_message_text { border: none; box-shadow: none; margin: none; @@ -87,13 +87,22 @@ border-top: 1px dashed $border-grey; } - #poll_creator_wrapper { - display:none; + .row-fluid#poll_creator_container { + display: none; border-top: 1px dashed $border-grey; padding:4px 6px 4px 6px; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; + .remove-answer.entypo.cross { + display: none; + color: lighten($black,75%); + &.active { display: block; } + &:hover { color: $black; } + line-height: 30px; + font-size: 18px; + cursor: pointer; + } } &.with_location .row-fluid#location_container { diff --git a/app/assets/stylesheets/publisher_blueprint.css.scss b/app/assets/stylesheets/publisher_blueprint.css.scss index 97dd3b56d..95ea2ac45 100644 --- a/app/assets/stylesheets/publisher_blueprint.css.scss +++ b/app/assets/stylesheets/publisher_blueprint.css.scss @@ -344,7 +344,7 @@ } } -#publisher-poll-creator { +#poll_creator_container { border: 1px solid $border-dark-grey; padding: 5px; margin-top: 5px; @@ -379,19 +379,18 @@ } } .poll-answer { + .span1, .span11 { display: inline-block; } + .span11 { width: 96%; } input { - width: 96%; + width: 100%; display: inline-block; vertical-align: bottom; } .remove-answer { - width: 14px; - height: 14px; @include opacity(0.4); cursor: pointer; - vertical-align: top; - margin-top: 7px; display: none; + line-height: 27px; &:hover { @include opacity(1); diff --git a/app/assets/templates/poll_creator_tpl.jst.hbs b/app/assets/templates/poll_creator_tpl.jst.hbs index f71d46f01..ea5ce6207 100644 --- a/app/assets/templates/poll_creator_tpl.jst.hbs +++ b/app/assets/templates/poll_creator_tpl.jst.hbs @@ -1,20 +1,21 @@
-
- -
+
-
-
- -
+
+
+ +
+
+
-
-
- -
+
+
+ +
+
+
- diff --git a/app/views/publisher/_publisher_blueprint.html.haml b/app/views/publisher/_publisher_blueprint.html.haml index b54a3e716..b43ea5512 100644 --- a/app/views/publisher/_publisher_blueprint.html.haml +++ b/app/views/publisher/_publisher_blueprint.html.haml @@ -37,7 +37,7 @@ = image_tag 'icons/camera.png', :alt => t('shared.publisher.upload_photos').titleize, :class => 'publisher_image' = hidden_field :location, :coords #location_container - #publisher-poll-creator + #poll_creator_container - if publisher_public = hidden_field_tag 'aspect_ids[]', "public" diff --git a/app/views/publisher/_publisher_bootstrap.html.haml b/app/views/publisher/_publisher_bootstrap.html.haml index 627f7258e..77c506702 100644 --- a/app/views/publisher/_publisher_bootstrap.html.haml +++ b/app/views/publisher/_publisher_bootstrap.html.haml @@ -22,16 +22,8 @@ %ul#photodropzone .row-fluid#location_container = hidden_field :location, :coords - .row-fluid#poll_creator_wrapper - #poll_question_wrapper{:class => "input-block-level"} - %input{:id => 'poll_question', :placeholder => t('shared.publisher.poll.question'), :name => 'poll_question', :class=> "form-control"} - .poll_answer - %input{:class => 'form-control poll_answer_input', :placeholder => t('shared.publisher.poll.option'), :name => 'poll_answers[]'} - .remove_poll_answer.btn.btn-link{:title => t('shared.publisher.poll.remove_poll_answer')} - %i.entypo.trash - #add_poll_answer_wrapper - #add_poll_answer{:class => 'btn btn-default'} - = t('shared.publisher.poll.add_poll_answer') + .row-fluid#poll_creator_container + -# handlebars template .row-fluid#button_container #publisher-images.pull-right #poll_creator.btn.btn-link{:title => t('shared.publisher.poll.add_a_poll')} diff --git a/features/desktop/post_with_a_poll.feature b/features/desktop/post_with_a_poll.feature index 807ec908f..89fa8d506 100644 --- a/features/desktop/post_with_a_poll.feature +++ b/features/desktop/post_with_a_poll.feature @@ -9,18 +9,18 @@ Feature: posting with a poll And I am on the home page Scenario: expanding the publisher - Given "#publisher-poll-creator" is hidden + Given "#poll_creator_container" is hidden When I expand the publisher Then I should see an element "#poll_creator" Scenario: expanding the poll creator - Given "#publisher-poll-creator" is hidden + Given "#poll_creator_container" is hidden When I expand the publisher And I press the element "#poll_creator" - Then I should see an element "#publisher-poll-creator" + Then I should see an element "#poll_creator_container" Scenario: adding option to poll - Given "#publisher-poll-creator" is hidden + Given "#poll_creator_container" is hidden When I expand the publisher And I press the element "#poll_creator" And I fill in values for the first two options @@ -28,7 +28,7 @@ Feature: posting with a poll Then I should see 3 options Scenario: delete an option - Given "#publisher-poll-creator" is hidden + Given "#poll_creator_container" is hidden When I expand the publisher And I press the element "#poll_creator" And I fill in values for the first two options @@ -89,6 +89,6 @@ Feature: posting with a poll And I fill in the following for the options: | normal | | | - And I press the element "#publisher-poll-creator" + And I press the element "#poll_creator_container" And I press the element "input[type=submit]" - Then I should see an element ".poll-answer.error" + Then I should see an element ".poll-answer input.error" diff --git a/features/step_definitions/post_with_poll_steps.rb b/features/step_definitions/post_with_poll_steps.rb index 2b3725c3c..cee8f77d3 100644 --- a/features/step_definitions/post_with_poll_steps.rb +++ b/features/step_definitions/post_with_poll_steps.rb @@ -1,9 +1,9 @@ Then /^I should see ([1-9]+) options?$/ do |number| - find("#publisher-poll-creator").all(".poll-answer").count.should eql(number.to_i) + find("#poll_creator_container").all(".poll-answer").count.should eql(number.to_i) end And /^I delete the last option$/ do - find("#publisher-poll-creator").all(".poll-answer .remove-answer").first.click + find("#poll_creator_container").all(".poll-answer .remove-answer").first.click end And /^I should not see a remove icon$/ do @@ -36,7 +36,7 @@ When(/^I fill in values for the first two options$/) do end When(/^I lose focus$/) do - find("#publisher-poll-creator").click + find("#poll_creator_container").click end Then /^I should see an element "([^"]*)"$/ do |selector|