move public option into aspect dropdown in publisher
This commit is contained in:
parent
6e4b4bc81b
commit
4896d056c7
7 changed files with 132 additions and 28 deletions
|
|
@ -14,4 +14,8 @@ module PublisherHelper
|
||||||
def public_helper_text
|
def public_helper_text
|
||||||
(public_value)? t('javascripts.publisher.public'): t('javascripts.publisher.limited')
|
(public_value)? t('javascripts.publisher.public'): t('javascripts.publisher.limited')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def all_aspects_selected?(selected_aspects)
|
||||||
|
@all_aspects_selected ||= all_aspects.size == selected_aspects.size
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -25,21 +25,43 @@
|
||||||
= image_tag 'icons/camera.svg', :height => 14
|
= image_tag 'icons/camera.svg', :height => 14
|
||||||
|
|
||||||
|
|
||||||
- for aspect_id in aspect_ids
|
- if all_aspects_selected?(selected_aspects)
|
||||||
= hidden_field_tag 'aspect_ids[]', aspect_id.to_s
|
= 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
|
.options_and_submit
|
||||||
.public_toggle
|
.public_toggle
|
||||||
%span#publisher_service_icons
|
%span#publisher_service_icons
|
||||||
= t("shared.publisher.click_to_share_with")
|
|
||||||
- if((defined?(for_all_aspects) && for_all_aspects) || aspect == :profile)
|
|
||||||
= status.hidden_field(:public, :value => public_value )
|
|
||||||
= image_tag "icons/globe.png", :title => public_helper_text, :class => "public_icon #{'dim' if !public_value}", :width => 16, :height => 16
|
|
||||||
- if current_user.services
|
- if current_user.services
|
||||||
- for service in current_user.services
|
- for service in current_user.services
|
||||||
= image_tag "social_media_logos/#{service.provider}-16x16.png", :title => service.provider.titleize, :class => "service_icon dim", :id =>"#{service.provider}", :maxchar => "#{service.class::MAX_CHARACTERS}"
|
= image_tag "social_media_logos/#{service.provider}-16x16.png", :title => service.provider.titleize, :class => "service_icon dim", :id =>"#{service.provider}", :maxchar => "#{service.class::MAX_CHARACTERS}"
|
||||||
= link_to (image_tag "icons/monotone_wrench_settings.png"), "#question_mark_pane", :class => 'question_mark', :rel => 'facebox', :title => t('shared.public_explain.manage')
|
= link_to (image_tag "icons/monotone_wrench_settings.png"), "#question_mark_pane", :class => 'question_mark', :rel => 'facebox', :title => t('shared.public_explain.manage')
|
||||||
= render "shared/aspect_dropdown", :selected_aspects => selected_aspects, :hang => 'left'
|
|
||||||
|
|
||||||
|
// NOTE(dropdown special casing to DRY up -- taken from the aspect_dropdown partial)
|
||||||
|
.dropdown{:class => "hang_right"}
|
||||||
|
.button.toggle.publisher
|
||||||
|
- if selected_aspects.size == all_aspects.size
|
||||||
|
= t('all_aspects')
|
||||||
|
- elsif selected_aspects.size == 1
|
||||||
|
= selected_aspects.first.name
|
||||||
|
- else
|
||||||
|
= t('.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"}
|
||||||
|
Public
|
||||||
|
|
||||||
|
%li.divider.all_aspects.radio{:style => "border-bottom: 1px solid #ddd;", "data-aspect_id" => "all_aspects", :class => ("selected" if all_aspects_selected?(selected_aspects))}
|
||||||
|
All Aspects
|
||||||
|
|
||||||
|
- for aspect in all_aspects
|
||||||
|
= aspect_dropdown_list_item(aspect, !all_aspects_selected?(selected_aspects) && selected_aspects.include?(aspect) )
|
||||||
|
|
||||||
= status.submit t('.share'), :disable_with => t('.posting'), :class => 'button creation', :tabindex => 2
|
= status.submit t('.share'), :disable_with => t('.posting'), :class => 'button creation', :tabindex => 2
|
||||||
|
|
||||||
.facebox_content
|
.facebox_content
|
||||||
|
|
|
||||||
|
|
@ -736,7 +736,6 @@ en:
|
||||||
share_with: "share with"
|
share_with: "share with"
|
||||||
whats_on_your_mind: "What's on your mind?"
|
whats_on_your_mind: "What's on your mind?"
|
||||||
publishing_to: "publishing to: "
|
publishing_to: "publishing to: "
|
||||||
click_to_share_with: "Click to share with: "
|
|
||||||
discard_post: "Discard post"
|
discard_post: "Discard post"
|
||||||
add_contact:
|
add_contact:
|
||||||
enter_a_diaspora_username: "Enter a Diaspora username:"
|
enter_a_diaspora_username: "Enter a Diaspora username:"
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,8 @@ Feature: following and being followed
|
||||||
And I am on the home page
|
And I am on the home page
|
||||||
And I expand the publisher
|
And I expand the publisher
|
||||||
And I fill in "status_message_fake_text" with "I am ALICE"
|
And I fill in "status_message_fake_text" with "I am ALICE"
|
||||||
And I press the first ".public_icon" within "#publisher"
|
And I press the first ".toggle" within "#publisher"
|
||||||
|
And I press the first ".public" within "#publisher"
|
||||||
And I press "Share"
|
And I press "Share"
|
||||||
And I go to the destroy user session page
|
And I go to the destroy user session page
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,25 @@ var AspectsDropdown = {
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleCheckbox: function(check) {
|
toggleCheckbox: function(check) {
|
||||||
|
if(!check.hasClass('radio')){
|
||||||
|
var selectedAspects = check.closest(".dropdown").find("li.radio");
|
||||||
|
AspectsDropdown.uncheckGroup(selectedAspects);
|
||||||
|
}
|
||||||
|
|
||||||
check.toggleClass('selected');
|
check.toggleClass('selected');
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleRadio: function(check) {
|
||||||
|
var selectedAspects = check.closest(".dropdown").find("li");
|
||||||
|
|
||||||
|
AspectsDropdown.uncheckGroup(selectedAspects);
|
||||||
|
AspectsDropdown.toggleCheckbox(check);
|
||||||
|
},
|
||||||
|
|
||||||
|
uncheckGroup: function(elements){
|
||||||
|
$.each(elements, function(index, value) {
|
||||||
|
$(value).removeClass('selected');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -316,19 +316,63 @@ var Publisher = {
|
||||||
'<input id="services_" name="services[]" type="hidden" value="'+provider+'">');
|
'<input id="services_" name="services[]" type="hidden" value="'+provider+'">');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isPublicPost: function(){
|
||||||
|
return $('#publisher [name="aspect_ids[]"]').first().val() == "public";
|
||||||
|
},
|
||||||
|
|
||||||
|
isToAllAspects: function(){
|
||||||
|
return $('#publisher [name="aspect_ids[]"]').first().val() == "all_aspects";
|
||||||
|
},
|
||||||
|
|
||||||
selectedAspectIds: function() {
|
selectedAspectIds: function() {
|
||||||
var aspects = $('#publisher [name="aspect_ids[]"]');
|
var aspects = $('#publisher [name="aspect_ids[]"]');
|
||||||
var aspectIds = [];
|
var aspectIds = [];
|
||||||
aspects.each(function() { aspectIds.push( parseInt($(this).attr('value'))); });
|
aspects.each(function() { aspectIds.push( parseInt($(this).attr('value'))); });
|
||||||
return aspectIds;
|
return aspectIds;
|
||||||
},
|
},
|
||||||
toggleAspectIds: function(aspectId) {
|
|
||||||
var hidden_field = $('#publisher [name="aspect_ids[]"][value="'+aspectId+'"]');
|
removeRadioSelection: function(hiddenFields){
|
||||||
if(hidden_field.length > 0){
|
$.each(hiddenFields, function(index, value){
|
||||||
hidden_field.remove();
|
var el = $(value);
|
||||||
|
|
||||||
|
if(el.val() == "all_aspects" || el.val() == "public") {
|
||||||
|
el.remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleAspectIds: function(li) {
|
||||||
|
var aspectId = li.attr('data-aspect_id'),
|
||||||
|
hiddenFields = $('#publisher [name="aspect_ids[]"]'),
|
||||||
|
appendId = function(){
|
||||||
|
console.log(aspectId);
|
||||||
|
$("#publisher .content_creation form").append(
|
||||||
|
'<input id="aspect_ids_" name="aspect_ids[]" type="hidden" value="'+aspectId+'">');
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log(aspectId);
|
||||||
|
|
||||||
|
if(li.hasClass('radio')){
|
||||||
|
$.each(hiddenFields, function(index, value){
|
||||||
|
$(value).remove();
|
||||||
|
});
|
||||||
|
appendId();
|
||||||
|
|
||||||
|
// close dropdown after selecting a binary option
|
||||||
|
li.closest('.dropdown').removeClass('active');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$("#publisher .content_creation form").append(
|
var hiddenField = $('#publisher [name="aspect_ids[]"][value="'+aspectId+'"]');
|
||||||
'<input id="aspect_ids_" name="aspect_ids[]" type="hidden" value="'+aspectId+'">');
|
|
||||||
|
// remove all radio selections
|
||||||
|
Publisher.removeRadioSelection(hiddenFields);
|
||||||
|
|
||||||
|
if(hiddenField.length > 0){
|
||||||
|
hiddenField.remove();
|
||||||
|
} else {
|
||||||
|
appendId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
createCounter: function(service){
|
createCounter: function(service){
|
||||||
|
|
@ -350,10 +394,15 @@ var Publisher = {
|
||||||
var li = $(this),
|
var li = $(this),
|
||||||
button = li.parent('.dropdown').find('.button');
|
button = li.parent('.dropdown').find('.button');
|
||||||
|
|
||||||
AspectsDropdown.toggleCheckbox(li);
|
if(li.hasClass('radio')){
|
||||||
|
AspectsDropdown.toggleRadio(li);
|
||||||
|
} else {
|
||||||
|
AspectsDropdown.toggleCheckbox(li);
|
||||||
|
}
|
||||||
|
|
||||||
AspectsDropdown.updateNumber(li.closest(".dropdown_list"), null, li.parent().find('li.selected').length, '');
|
AspectsDropdown.updateNumber(li.closest(".dropdown_list"), null, li.parent().find('li.selected').length, '');
|
||||||
|
|
||||||
Publisher.toggleAspectIds(li.attr('data-aspect_id'));
|
Publisher.toggleAspectIds(li);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
beforeSubmit: function(){
|
beforeSubmit: function(){
|
||||||
|
|
@ -378,10 +427,17 @@ var Publisher = {
|
||||||
if (Publisher.bookmarklet == false) {
|
if (Publisher.bookmarklet == false) {
|
||||||
var isPostVisible = Diaspora.page.aspectNavigation.selectedAspects().length == 0;
|
var isPostVisible = Diaspora.page.aspectNavigation.selectedAspects().length == 0;
|
||||||
var postedTo = Publisher.selectedAspectIds();
|
var postedTo = Publisher.selectedAspectIds();
|
||||||
$.each(Diaspora.page.aspectNavigation.selectedAspects(), function(index, value) {
|
|
||||||
if (postedTo.indexOf(parseInt(value)) > -1)
|
|
||||||
isPostVisible = true;
|
if(Publisher.isPublicPost() || Publisher.isToAllAspects()){
|
||||||
});
|
isPostVisible = true;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$.each(Diaspora.page.aspectNavigation.selectedAspects(), function(index, value) {
|
||||||
|
if (postedTo.indexOf(parseInt(value)) > -1)
|
||||||
|
isPostVisible = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if(isPostVisible) {
|
if(isPostVisible) {
|
||||||
ContentUpdater.addPostToStream(json.html);
|
ContentUpdater.addPostToStream(json.html);
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ $button-border-color: #aaa
|
||||||
|
|
||||||
.button
|
.button
|
||||||
@include border-radius(3px)
|
@include border-radius(3px)
|
||||||
@include linear-gradient(rgb(248,250,250),rgb(228,223,223))
|
|
||||||
@include button-gradient($light-grey)
|
@include button-gradient($light-grey)
|
||||||
@include box-shadow(0,1px,1px,#cfcfcf)
|
@include box-shadow(0,1px,1px,#cfcfcf)
|
||||||
@include transition(border)
|
@include transition(border)
|
||||||
|
|
@ -96,10 +95,11 @@ input.button
|
||||||
|
|
||||||
.wrapper
|
.wrapper
|
||||||
@include box-shadow(0, 2px, 5px, #666)
|
@include box-shadow(0, 2px, 5px, #666)
|
||||||
|
@include opacity(0)
|
||||||
|
@include transition(opacity)
|
||||||
|
|
||||||
:z-index 20
|
:z-index 20
|
||||||
:position absolute
|
:position absolute
|
||||||
:display none
|
|
||||||
:width 140px
|
:width 140px
|
||||||
:padding 4px 0
|
:padding 4px 0
|
||||||
:margin-top 2px
|
:margin-top 2px
|
||||||
|
|
@ -166,20 +166,20 @@ input.button
|
||||||
@include border-radius(0, 3px, 3px, 3px)
|
@include border-radius(0, 3px, 3px, 3px)
|
||||||
:left 0px
|
:left 0px
|
||||||
|
|
||||||
|
.selected
|
||||||
|
:font-weight bold
|
||||||
|
|
||||||
&.active
|
&.active
|
||||||
.wrapper
|
.wrapper
|
||||||
:display block
|
@include opacity(1)
|
||||||
|
|
||||||
.button
|
.button
|
||||||
@include border-radius(3px, 3px, 0, 0)
|
@include border-radius(3px, 3px, 0, 0)
|
||||||
:border 1px solid #444
|
:border 1px solid #444
|
||||||
|
|
||||||
.selected
|
|
||||||
:font-weight bold
|
|
||||||
|
|
||||||
.button
|
.button
|
||||||
:background #666
|
:background #666
|
||||||
|
|
||||||
.button,
|
.button,
|
||||||
.wrapper ul > li:hover
|
.wrapper ul > li:hover
|
||||||
:background
|
:background
|
||||||
|
|
@ -196,6 +196,10 @@ input.button
|
||||||
:top 2px
|
:top 2px
|
||||||
:bottom 2px
|
:bottom 2px
|
||||||
|
|
||||||
|
&.divider
|
||||||
|
:padding
|
||||||
|
:bottom 3px
|
||||||
|
|
||||||
a
|
a
|
||||||
:color #ccc
|
:color #ccc
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue