From ddbff78926e329bf1d9b79eaa2fb7cccbc1a51e8 Mon Sep 17 00:00:00 2001 From: Andreas N Date: Tue, 27 Jan 2015 18:13:24 +0100 Subject: [PATCH 1/2] add panel-footer to inbox panel --- app/views/inbox/_entry.html.haml | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/app/views/inbox/_entry.html.haml b/app/views/inbox/_entry.html.haml index fb65cce2..8acac5fa 100644 --- a/app/views/inbox/_entry.html.haml +++ b/app/views/inbox/_entry.html.haml @@ -23,8 +23,20 @@ Answer %button.btn.btn-danger{name: 'ib-destroy', data: { ib_id: i.id }} Delete - - current_user.services.each do |service| - %label - %input{type: 'checkbox', name: 'ib-share', checked: :checked, data: { ib_id: i.id, service: service.provider }} - Post to - = service.provider.capitalize \ No newline at end of file + %button.btn.btn-default + Options + .panel-footer + %h4 Sharing + - if @services.count > 0 + .row + - current_user.services.each do |service| + .col-md-2.col-sm-4.col-xs-6 + %label + %input{type: 'checkbox', name: 'ib-share', checked: :checked, data: { ib_id: i.id, service: service.provider }} + Post to + = service.provider.capitalize + - else + %p + You have not connected any services yet. Visit your + = link_to "service settings", services_path + to connect one. \ No newline at end of file From 9c2b0951bfcb2756a29053bf7afd817d514e5e5d Mon Sep 17 00:00:00 2001 From: Andreas N Date: Tue, 27 Jan 2015 18:25:20 +0100 Subject: [PATCH 2/2] add coffescript to expand options --- app/assets/javascripts/inbox.coffee | 15 +++++++++++++++ app/views/inbox/_entry.html.haml | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/inbox.coffee b/app/assets/javascripts/inbox.coffee index 397fb515..50fabac3 100644 --- a/app/assets/javascripts/inbox.coffee +++ b/app/assets/javascripts/inbox.coffee @@ -121,3 +121,18 @@ $(document).on "click", "button[name=ib-destroy]", -> complete: (jqxhr, status) -> btn.button "reset" $("textarea[name=ib-answer][data-id=#{iid}]").removeAttr "readonly" + +# Toggle button +$(document).on "click", "button[name=ib-options]", -> + btn = $(this) + ibid = btn[0].dataset.ib_id + state = btn[0].dataset.state + optionBox = $("#ib-options-#{ibid}") + + switch state + when 'hidden' + optionBox.slideDown() + btn[0].dataset.state = 'shown' + when 'shown' + optionBox.slideUp() + btn[0].dataset.state = 'hidden' \ No newline at end of file diff --git a/app/views/inbox/_entry.html.haml b/app/views/inbox/_entry.html.haml index 8acac5fa..6504a537 100644 --- a/app/views/inbox/_entry.html.haml +++ b/app/views/inbox/_entry.html.haml @@ -23,9 +23,9 @@ Answer %button.btn.btn-danger{name: 'ib-destroy', data: { ib_id: i.id }} Delete - %button.btn.btn-default + %button.btn.btn-default{name: 'ib-options', data: { ib_id: i.id, state: :hidden }} Options - .panel-footer + .panel-footer{id: "ib-options-#{i.id}", style: 'display: none'} %h4 Sharing - if @services.count > 0 .row