From c484b2cd0c0759da82da58a92f009d9e8988ad2a Mon Sep 17 00:00:00 2001 From: Jannik Streek Date: Wed, 26 Mar 2014 18:45:49 +0100 Subject: [PATCH] fixed poll icon issue, improved code, poll in bookmarklets now available --- app/assets/javascripts/app/views/poll.js | 1 - .../javascripts/app/views/publisher_view.js | 2 +- app/assets/stylesheets/publisher.css.scss | 8 +++++- .../stylesheets/publisher_blueprint.css.scss | 19 +++++++++++--- .../poll_participations_controller.rb | 26 +++++++++---------- app/views/publisher/_publisher.mobile.haml | 2 +- .../publisher/_publisher_blueprint.html.haml | 4 ++- .../publisher/_publisher_bootstrap.html.haml | 13 ++++++++++ 8 files changed, 53 insertions(+), 22 deletions(-) diff --git a/app/assets/javascripts/app/views/poll.js b/app/assets/javascripts/app/views/poll.js index 31fa48379..7d3691eb2 100644 --- a/app/assets/javascripts/app/views/poll.js +++ b/app/assets/javascripts/app/views/poll.js @@ -9,7 +9,6 @@ app.views.Poll = app.views.Base.extend({ initialize : function(options) { this.poll = this.model.attributes.poll; this.progressBarFactor = 3; - //this.model.bind('remove', this.remove, this); }, postRenderTemplate : function() { diff --git a/app/assets/javascripts/app/views/publisher_view.js b/app/assets/javascripts/app/views/publisher_view.js index b8062347e..b2c58e4c7 100644 --- a/app/assets/javascripts/app/views/publisher_view.js +++ b/app/assets/javascripts/app/views/publisher_view.js @@ -202,7 +202,7 @@ app.views.Publisher = Backbone.View.extend({ }, removePollAnswer: function(evt){ - $(evt.target).parents().eq(1).remove(); + $(evt.currentTarget).parent().remove(); if($(".poll_answer").size() == 1) { $(".remove_poll_answer").css("visibility","hidden");; } diff --git a/app/assets/stylesheets/publisher.css.scss b/app/assets/stylesheets/publisher.css.scss index 76bce5669..bdb835dca 100644 --- a/app/assets/stylesheets/publisher.css.scss +++ b/app/assets/stylesheets/publisher.css.scss @@ -82,6 +82,13 @@ &.with_attachments .row-fluid#photodropzone_container { border-top: 1px dashed $border-grey; } + + #poll_creator_wrapper { + display:none; + border-top: 1px dashed $border-grey; + padding:4px 6px 4px 6px; + } + &.with_location .row-fluid#location_container { height: 30px; #hide_location { display: none !important; } @@ -216,4 +223,3 @@ } } } - diff --git a/app/assets/stylesheets/publisher_blueprint.css.scss b/app/assets/stylesheets/publisher_blueprint.css.scss index f4cb7171f..d252f0578 100644 --- a/app/assets/stylesheets/publisher_blueprint.css.scss +++ b/app/assets/stylesheets/publisher_blueprint.css.scss @@ -310,9 +310,22 @@ } } #poll_creator { - @extend #locator; - right: 60px; - margin-bottom:-5px; + bottom: 1px !important; + display: inline-block; + margin: 0; + cursor: pointer; + position: absolute !important; + right: 55px; + i { + @include opacity(0.4); + } + &:hover { + color: $text-dark-grey; + cursor: pointer; + i { + @include opacity(1); + } + } } .btn { diff --git a/app/controllers/poll_participations_controller.rb b/app/controllers/poll_participations_controller.rb index 89f6854f5..2fd07c76e 100644 --- a/app/controllers/poll_participations_controller.rb +++ b/app/controllers/poll_participations_controller.rb @@ -3,20 +3,18 @@ class PollParticipationsController < ApplicationController before_filter :authenticate_user! def create - begin - answer = PollAnswer.find(params[:poll_answer_id]) - poll_participation = current_user.participate_in_poll!(target, answer) if target - respond_to do |format| - format.html { redirect_to :back } - format.mobile { redirect_to stream_path } - format.json { render json: poll_participation, :status => 201 } - end - rescue ActiveRecord::RecordInvalid - respond_to do |format| - format.html { redirect_to :back } - format.mobile { redirect_to stream_path } - format.json { render :nothing => true, :status => 403 } - end + answer = PollAnswer.find(params[:poll_answer_id]) + poll_participation = current_user.participate_in_poll!(target, answer) if target + respond_to do |format| + format.html { redirect_to :back } + format.mobile { redirect_to stream_path } + format.json { render json: poll_participation, :status => 201 } + end + rescue ActiveRecord::RecordInvalid + respond_to do |format| + format.html { redirect_to :back } + format.mobile { redirect_to stream_path } + format.json { render :nothing => true, :status => 403 } end end diff --git a/app/views/publisher/_publisher.mobile.haml b/app/views/publisher/_publisher.mobile.haml index a1556a32c..dca0f8cf2 100644 --- a/app/views/publisher/_publisher.mobile.haml +++ b/app/views/publisher/_publisher.mobile.haml @@ -39,4 +39,4 @@ #publisher_mobile = submit_tag t('shared.publisher.share'), :class => 'btn primary', :id => "submit_new_message" - #publisher_photo_upload + #publisher_photo_upload \ 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 f12881770..cccf338d6 100644 --- a/app/views/publisher/_publisher_blueprint.html.haml +++ b/app/views/publisher/_publisher_blueprint.html.haml @@ -28,7 +28,9 @@ %span#publisher-images %span.markdownIndications != t('shared.publisher.formatWithMarkdown', markdown_link: link_to(t('help.markdown'), 'https://diasporafoundation.org/formatting', target: :blank)) - %a{:id => "poll_creator", :href => "#", :class => "entypo bar-graph gray small publisher_image"} + #poll_creator.btn{:title => t('shared.publisher.poll.add_a_poll')} + %i.entypo.bar-graph{:class => "publisher_image"} + #locator.btn{:title => t('shared.publisher.get_location')} = image_tag 'icons/marker.png', :alt => t('shared.publisher.get_location').titleize, :class => 'publisher_image' #file-upload.btn{:title => t('shared.publisher.upload_photos')} diff --git a/app/views/publisher/_publisher_bootstrap.html.haml b/app/views/publisher/_publisher_bootstrap.html.haml index 9df147931..103c53d5a 100644 --- a/app/views/publisher/_publisher_bootstrap.html.haml +++ b/app/views/publisher/_publisher_bootstrap.html.haml @@ -22,8 +22,21 @@ %ul#photodropzone .row-fluid#location_container = hidden_field :location, :coords + .row-fluid#poll_creator_wrapper + = t('shared.publisher.poll.add_a_poll') + #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#button_container #publisher-images.pull-right + #poll_creator.btn.btn-link{:title => t('shared.publisher.poll.add_a_poll')} + %i.entypo.bar-graph #file-upload.btn.btn-link{:title => t('shared.publisher.upload_photos')} %i.entypo.camera.publisher_image #locator.btn.btn-link{:title => t('shared.publisher.get_location')}