Commit 6fc6474e authored by Steffen van Bergerem's avatar Steffen van Bergerem

Refactor publisher

parent 1b85d9d0
......@@ -85,4 +85,7 @@ module LayoutHelper
end.join(' ').html_safe
end
def bootstrap?
@css_framework == :bootstrap
end
end
......@@ -10,4 +10,19 @@ module PublisherHelper
def all_aspects_selected?(selected_aspects)
@all_aspects_selected ||= all_aspects.size == selected_aspects.size
end
def service_button(service)
content_tag :div,
:class => "btn btn-link service_icon dim",
:title => "#{service.provider.titleize} (#{service.nickname})",
:id => "#{service.provider}",
:maxchar => "#{service.class::MAX_CHARACTERS}",
:data => {:toggle=>'tooltip', :placement=>'bottom'} do
if service.provider == 'wordpress'
content_tag(:span, '', :class => "social_media_logos-wordpress-16x16")
else
content_tag(:i, '', :class => "entypo small #{ service.provider }")
end
end
end
end
......@@ -6,7 +6,7 @@
%h3#aspect_stream_header.stream_title
= stream.title
= render 'shared/publisher', :selected_aspects => stream.aspects, :aspect_ids => stream.aspect_ids, :for_all_aspects => stream.for_all_aspects?, :aspect => stream.aspect
= render 'publisher/publisher', :selected_aspects => stream.aspects, :aspect_ids => stream.aspect_ids, :aspect => stream.aspect
= render 'aspects/no_posts_message'
#gs-shim{:title => popover_with_close_html("3. #{t('.stay_updated')}"), 'data-content' => t('.stay_updated_explanation')}
......
.btn-group.aspect_dropdown
%button.btn.btn-default.dropdown-toggle{ ! current_user.getting_started? ? {'data-toggle' => 'dropdown'} : {'data-toggle' => 'dropdown', :title => popover_with_close_html("2. #{t('shared.public_explain.control_your_audience')}"), 'data-content'=> t('shared.public_explain.visibility_dropdown')} }
%span.text
- if publisher_public
= t('public')
- elsif all_aspects_selected?(selected_aspects)
= t('all_aspects')
- elsif selected_aspects.size == 1
= selected_aspects.first.name
- else
= t('shared.aspect_dropdown.toggle', :count => selected_aspects.size)
%span.caret
%ul.dropdown-menu.pull-right{ :unSelectable => 'on' }
%li.public.radio{"data-aspect_id" => "public", :class => ("selected" if publisher_public)}
%a
%span.status_indicator
%i.icon-ok
%span.text
= t('public')
%li.all_aspects.radio{"data-aspect_id" => "all_aspects", :class => ("selected" if (!publisher_public && all_aspects_selected?(selected_aspects)))}
%a
%span.status_indicator
%i.icon-ok
%span.text
= t('all_aspects')
%li.divider
- for aspect in all_aspects
%li.aspect_selector{ 'data-aspect_id' => aspect.id, :class => !all_aspects_selected?(selected_aspects) && selected_aspects.include?(aspect) ? "selected" : "" }
%a
%span.status_indicator
%i.icon-ok
%span.text
= aspect.name
- if bootstrap?
= render :partial => 'publisher/publisher_bootstrap', :locals => { :aspect => aspect, :selected_aspects => selected_aspects, :aspect_ids => aspect_ids }
- else
= render :partial => 'publisher/publisher_blueprint', :locals => { :aspect => aspect, :selected_aspects => selected_aspects, :aspect_ids => aspect_ids }
......@@ -10,7 +10,7 @@
= form_for StatusMessage.new, {:data => {:ajax => false}} do |status|
= status.hidden_field :provider_display_name, :value => 'mobile'
= status.text_area :text, :placeholder => t('.whats_on_your_mind'), :rows => 4, :autofocus => "autofocus"
= status.text_area :text, :placeholder => t('shared.publisher.whats_on_your_mind'), :rows => 4, :autofocus => "autofocus"
%fieldset
%span#publisher_service_icons
......@@ -34,9 +34,9 @@
%ul#photodropzone
#fileInfo-publisher
#file-upload-publisher{:title => t('.upload_photos'), :class => 'btn'}
= image_tag 'icons/camera.png', alt: t('.upload_photos').titleize
#file-upload-publisher{:title => t('shared.publisher.upload_photos'), :class => 'btn'}
= image_tag 'icons/camera.png', alt: t('shared.publisher.upload_photos').titleize
#publisher_mobile
= submit_tag t('.share'), :class => 'btn primary', :id => "submit_new_message"
= submit_tag t('shared.publisher.share'), :class => 'btn primary', :id => "submit_new_message"
#publisher_photo_upload
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
-if publisher_explain
:javascript
$(document).ready(function() {
if( app.publisher ) app.publisher.triggerGettingStarted();
});
#publisher{:class => ((aspect == :profile || publisher_open) ? "mention_popup" : "closed")}
.content_creation
= form_for(StatusMessage.new) do |status|
= status.error_messages
%div
%params
#publisher_textarea_wrapper
= link_to(content_tag(:div, nil, :class => 'icons-deletelabel'), "#", :id => "hide_publisher", :title => t('shared.publisher.discard_post'))
%ul#photodropzone
- if current_user.getting_started?
= status.text_area :fake_text, :rows => 2, :value => h(publisher_formatted_text), :tabindex => 1, :placeholder => "#{t('contacts.index.start_a_conversation')}...",
:title => popover_with_close_html( '1. ' + t('shared.public_explain.share') ),
'data-content' => t('shared.public_explain.new_user_welcome_message')
- else
= status.text_area :fake_text, :rows => 2, :value => h(publisher_formatted_text), :tabindex => 1, :placeholder => "#{t('contacts.index.start_a_conversation')}..."
= status.hidden_field :text, :value => h(publisher_hidden_text), :class => 'clear_on_submit'
#publisher-images
%span.markdownIndications
!= t('shared.publisher.formatWithMarkdown', markdown_link: link_to(t('help.markdown'), 'https://diasporafoundation.org/formatting', target: :blank))
#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')}
= image_tag 'icons/camera.png', :alt => t('shared.publisher.upload_photos').titleize, :class => 'publisher_image'
= hidden_field :location, :coords
#location_container
- if publisher_public
= hidden_field_tag 'aspect_ids[]', "public"
- elsif all_aspects_selected?(selected_aspects)
= hidden_field_tag 'aspect_ids[]', "all_aspects"
- else
- for aspect_id in aspect_ids
= hidden_field_tag 'aspect_ids[]', aspect_id.to_s
.options_and_submit
.public_toggle
%span#publisher_service_icons
- if current_user.services
- for service in current_user.services
= content_tag :div, nil,
:title => "#{service.provider.titleize} (#{service.nickname})",
:class => "social_media_logos-#{service.provider}-16x16 service_icon dim",
:id => "#{service.provider}",
:maxchar => "#{service.class::MAX_CHARACTERS}",
:data => {:toggle=>'tooltip', :placement=>'bottom'}
%a{ :href => "#question_mark_pane", :class => 'question_mark', :rel => 'facebox', :title => t('shared.public_explain.manage') }
.icons-monotone_wrench_settings
.dropdown{ ! current_user.getting_started? ? {:class => "hang_right"} : { :class => "hang_right", :title => popover_with_close_html("2. #{t('shared.public_explain.control_your_audience')}"), 'data-content'=> t('shared.public_explain.visibility_dropdown')} }
.button.toggle.publisher
- if publisher_public
= t('public')
- elsif all_aspects_selected?(selected_aspects)
= t('all_aspects')
- elsif selected_aspects.size == 1
= selected_aspects.first.name
- else
= t('shared.aspect_dropdown.toggle', :count => selected_aspects.size)
▼
.wrapper
%ul.dropdown_list{:unSelectable => 'on', 'data-person_id' => (person.id if defined?(person) && person), 'data-service_uid' => (service_uid if defined?(service_uid))}
%li.public.radio{"data-aspect_id" => "public", :class => ("selected" if publisher_public)}
= t('public')
%li.divider.all_aspects.radio{:style => "padding-bottom: 5px; border-bottom: 1px solid #ddd;", "data-aspect_id" => "all_aspects", :class => ("selected" if (!publisher_public && all_aspects_selected?(selected_aspects)))}
= t('all_aspects')
- for aspect in all_aspects
= aspect_dropdown_list_item(aspect, !all_aspects_selected?(selected_aspects) && selected_aspects.include?(aspect) )
%button{ :disabled => ("disabled" if publisher_hidden_text.blank?), :class => 'button post_preview_button'}
= t('shared.publisher.preview')
= status.submit t('shared.publisher.share'), :disabled => publisher_hidden_text.blank?, :class => 'button creation', :tabindex => 2
.facebox_content
#question_mark_pane
= render 'shared/public_explain'
= link_to '', contacts_path(:aspect_ids => aspect_ids), :class => 'selected_contacts_link hidden'
#publisher_photo_upload
-if publisher_explain
:javascript
$(document).ready(function() {
if( app.publisher ) app.publisher.triggerGettingStarted();
});
.row-fluid#publisher{:class => ((aspect == :profile || publisher_open) ? "mention_popup" : "closed")}
.content_creation
= form_for(StatusMessage.new) do |status|
= status.error_messages
%params
#publisher_textarea_wrapper
- if current_user.getting_started?
= status.text_area :fake_text, :rows => 2, :value => h(publisher_formatted_text), :tabindex => 1, :placeholder => "#{t('contacts.index.start_a_conversation')}...",
'data-title' => popover_with_close_html( '1. ' + t('shared.public_explain.share') ),
'data-content' => t('shared.public_explain.new_user_welcome_message')
- else
= status.text_area :fake_text, :rows => 2, :value => h(publisher_formatted_text), :tabindex => 1, :placeholder => "#{t('contacts.index.start_a_conversation')}..."
= status.hidden_field :text, :value => h(publisher_hidden_text), :class => 'clear_on_submit'
.row-fluid#photodropzone_container
%ul#photodropzone
.row-fluid#location_container
= hidden_field :location, :coords
.row-fluid#button_container
#publisher-images.pull-right
#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')}
%i.entypo.location.publisher_image
#hide_location.btn.btn-link{:title => t('shared.publisher.remove_location')}
%i.entypo.cross.publisher_image
%span.help-block.markdownIndications
!= t('shared.publisher.formatWithMarkdown', markdown_link: link_to(t('help.markdown'), 'https://diasporafoundation.org/formatting', target: :blank))
- if publisher_public
= hidden_field_tag 'aspect_ids[]', "public"
- elsif all_aspects_selected?(selected_aspects)
= hidden_field_tag 'aspect_ids[]', "all_aspects"
- else
- for aspect_id in aspect_ids
= hidden_field_tag 'aspect_ids[]', aspect_id.to_s
.row-fluid.options_and_submit
.public_toggle
%button.btn.btn-default.pull-left#hide_publisher{:title => t('shared.publisher.discard_post')}
=t('cancel')
.btn-toolbar.pull-right
%span#publisher_service_icons
- if current_user.services
- for service in current_user.services
= service_button(service)
%a.btn.btn-link{ :href => "#question_mark_pane", :class => 'question_mark', :rel => 'facebox', :title => t('shared.public_explain.manage') }
%i.entypo.small.cog
= render :partial => "publisher/aspect_dropdown", :locals => { :selected_aspects => selected_aspects }
%button{ :disabled => ("disabled" if publisher_hidden_text.blank?), :class => 'btn btn-default post_preview_button'}
= t('shared.publisher.preview')
%button#submit.btn.btn-primary.creation{ :disabled => ("disabled" if publisher_hidden_text.blank?), :tabindex => 2}
= t('shared.publisher.share')
.facebox_content
#question_mark_pane
= render 'shared/public_explain'
= link_to '', contacts_path(:aspect_ids => aspect_ids), :class => 'selected_contacts_link hidden'
#publisher_photo_upload
This diff is collapsed.
......@@ -8,7 +8,7 @@
.row-fluid
%h4
=t('bookmarklet.post_something')
= render :partial => 'shared/publisher', :locals => { :aspect => :profile, :selected_aspects => @aspects, :aspect_ids => @aspect_ids, :bootstrap => 'true' }
= render :partial => 'publisher/publisher', :locals => { :aspect => :profile, :selected_aspects => @aspects, :aspect_ids => @aspect_ids }
:javascript
app.publisher = new app.views.Publisher({
......
......@@ -2,7 +2,7 @@
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
= render :partial => 'shared/publisher', :locals => { :aspect => :profile, :selected_aspects => @aspects, :aspect_ids => @aspect_ids }
= render :partial => 'publisher/publisher', :locals => { :aspect => :profile, :selected_aspects => @aspects, :aspect_ids => @aspect_ids }
:javascript
var contents = "#{escape_javascript params[:content]}";
......
......@@ -10,7 +10,7 @@
%h3
= t('.mentioning', :person => @person.name)
= render :partial => 'shared/publisher', :locals => { :aspect => @aspect, :aspect_ids => @aspect_ids, :selected_aspects => @aspects_with_person, :person => @person}
= render :partial => 'publisher/publisher', :locals => { :aspect => @aspect, :aspect_ids => @aspect_ids, :selected_aspects => @aspects_with_person, :person => @person}
:javascript
$(function() {
......
......@@ -2,4 +2,4 @@
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
= render :partial => 'shared/publisher', :locals => {:aspect => @aspects.first, :for_all_aspects => true, :aspect_ids => @aspect_ids, :selected_aspects => @aspects}
= render :partial => 'publisher/publisher', :locals => {:aspect => @aspects.first, :aspect_ids => @aspect_ids, :selected_aspects => @aspects}
......@@ -31,7 +31,7 @@
= @stream.display_tag_name
- if current_user
= render 'shared/publisher', :selected_aspects => @stream.aspect_ids, :aspect_ids => @stream.aspect_ids, :for_all_aspects => true, :aspect => @stream.aspect
= render 'publisher/publisher', :selected_aspects => @stream.aspect_ids, :aspect_ids => @stream.aspect_ids, :aspect => @stream.aspect
%hr
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment