#7080: SCSS adaptation for displaying the selection of the aspect selection button

This commit is contained in:
Sébastien Adam 2017-08-30 16:43:41 +02:00 committed by Thorsten Claus
parent fa39f7d348
commit 71c856e330
6 changed files with 65 additions and 48 deletions

View file

@ -50,19 +50,19 @@ $(document).ready(function(){
new Diaspora.MarkdownEditor("#status_message_text"); new Diaspora.MarkdownEditor("#status_message_text");
$(".dropdown-menu > li").bind("tap click", function(evt) { $(".dropdown-menu > li").bind("tap click", function(evt) {
var target = $(evt.target).closest('li'); var target = $(evt.target).closest("li");
// visually toggle the aspect selection // visually toggle the aspect selection
if (target.is('.radio')) { if (target.is(".radio")) {
_toggleRadio(target); _toggleRadio(target);
} else if (target.is('.aspect_selector')) { } else if (target.is(".aspect-selector")) {
// don't close the dropdown // don't close the dropdown
evt.stopPropagation(); evt.stopPropagation();
_toggleCheckbox(target); _toggleCheckbox(target);
} }
_updateSelectedAspectIds(); _updateSelectedAspectIds();
_updateButton('btn-default'); _updateButton("btn-default");
// update the globe or lock icon // update the globe or lock icon
var icon = $("#visibility-icon"); var icon = $("#visibility-icon");
@ -75,15 +75,15 @@ $(document).ready(function(){
} }
}); });
function _toggleRadio (target) { function _toggleRadio(target) {
$('.dropdown-menu > li').removeClass('selected'); $(".dropdown-menu > li").removeClass("selected");
target.toggleClass('selected'); target.toggleClass("selected");
}; }
function _toggleCheckbox (target) { function _toggleCheckbox(target) {
$('.dropdown-menu > li.radio').removeClass('selected'); $(".dropdown-menu > li.radio").removeClass("selected");
target.toggleClass('selected'); target.toggleClass("selected");
}; }
// take care of the form fields that will indicate the selected aspects // take care of the form fields that will indicate the selected aspects
function _updateSelectedAspectIds() { function _updateSelectedAspectIds() {
@ -93,33 +93,31 @@ $(document).ready(function(){
form.find('input[name="aspect_ids[]"]').remove(); form.find('input[name="aspect_ids[]"]').remove();
// create fields for current selection // create fields for current selection
$('.dropdown-menu > li.selected').each(function() { form.find(".dropdown-menu > li.selected").each(function() {
var uid = _.uniqueId('aspect_ids_'); var uid = _.uniqueId("aspect_ids_");
var id = $(this).data('aspect_id'); var id = $(this).data("aspect_id");
form.append( form.append('<input id="' + uid + '" name="aspect_ids[]" type="hidden" value="' + id + '">');
'<input id="'+uid+'" name="aspect_ids[]" type="hidden" value="'+id+'">'
);
}); });
}; }
// change class and text of the dropdown button // change class and text of the dropdown button
function _updateButton(inAspectClass) { function _updateButton(inAspectClass) {
var button = $('.btn.dropdown-toggle'), var button = $(".btn.dropdown-toggle"),
selectedAspects = $(".dropdown-menu > li.selected").length, selectedAspects = $(".dropdown-menu > li.selected").length,
buttonText; buttonText;
if (selectedAspects === 0) { if (selectedAspects === 0) {
button.removeClass(inAspectClass).addClass('btn-default'); button.removeClass(inAspectClass).addClass("btn-default");
buttonText = Diaspora.I18n.t("aspect_dropdown.select_aspects"); buttonText = Diaspora.I18n.t("aspect_dropdown.select_aspects");
} else { } else {
button.removeClass('btn-default').addClass(inAspectClass); button.removeClass("btn-default").addClass(inAspectClass);
if (selectedAspects === 1) { if (selectedAspects === 1) {
buttonText = this.$(".dropdown-menu > li.selected .text").first().text(); buttonText = this.$(".dropdown-menu > li.selected .text").first().text();
} else { } else {
buttonText = Diaspora.I18n.t("aspect_dropdown.toggle", { count: selectedAspects.toString() }); buttonText = Diaspora.I18n.t("aspect_dropdown.toggle", {count: selectedAspects.toString()});
} }
} }
button.find('.text').text(buttonText); button.find(".text").text(buttonText);
} }
}); });

View file

@ -658,7 +658,9 @@ form#update_profile_form {
.submit_block { margin-bottom: 20px; } .submit_block { margin-bottom: 20px; }
} }
select#user_language, select#user_color_theme, #user_auto_follow_back_aspect_id, #aspect_ids_ { select#user_language,
select#user_color_theme,
#user_auto_follow_back_aspect_id {
padding: 3px; padding: 3px;
} }
@ -680,14 +682,39 @@ input#q.search {
margin-bottom: 20px; margin-bottom: 20px;
} }
select#aspect_ids_ { @mixin aspect-dropdown-link() {
width: auto !important; $link-text-color: #333;
float: right;
margin: 0px; a {
cursor: pointer;
padding-left: 10px;
.text {
color: $link-text-color;
font-size: 128%;
}
&:hover {
background: $background-grey;
}
}
}
.aspect-dropdown {
li {
@include selectable-list;
@include aspect-dropdown-link;
.status-indicator {
display: inline-block;
height: 14px;
width: 19px;
}
}
} }
#file-upload-spinner { #file-upload-spinner {
top: 0px; top: 0;
} }
#publisher_mobile { #publisher_mobile {

View file

@ -6,7 +6,7 @@
dropdown_css["data-content"] = t("shared.public_explain.visibility_dropdown") dropdown_css["data-content"] = t("shared.public_explain.visibility_dropdown")
end end
.btn-group.aspect_dropdown .btn-group.aspect-dropdown
%button.btn.btn-default.dropdown-toggle{dropdown_css} %button.btn.btn-default.dropdown-toggle{dropdown_css}
%i.entypo-lock.small#visibility-icon %i.entypo-lock.small#visibility-icon
%span.text %span.text
@ -16,21 +16,21 @@
%li.public.radio{"data-aspect_id" => "public"} %li.public.radio{"data-aspect_id" => "public"}
%a %a
%span.status_indicator %span.status-indicator
%i.glyphicon.glyphicon-ok %i.glyphicon.glyphicon-ok
%span.text %span.text
= t("public") = t("public")
%li.all_aspects.radio.selected{"data-aspect_id" => "all_aspects"} %li.all-aspects.radio.selected{"data-aspect_id" => "all_aspects"}
%a %a
%span.status_indicator %span.status-indicator
%i.glyphicon.glyphicon-ok %i.glyphicon.glyphicon-ok
%span.text %span.text
= t("all_aspects") = t("all_aspects")
%li.divider %li.divider
- all_aspects.each do |aspect| - all_aspects.each do |aspect|
%li.aspect_selector{"data-aspect_id" => aspect.id} %li.aspect-selector{"data-aspect_id" => aspect.id}
%a %a
%span.status_indicator %span.status-indicator
%i.glyphicon.glyphicon-ok %i.glyphicon.glyphicon-ok
%span.text %span.text
= aspect.name = aspect.name

View file

@ -17,16 +17,6 @@
title: service.provider.titleize, class: "service_icon dim", title: service.provider.titleize, class: "service_icon dim",
id: "#{service.provider}", maxchar: "#{service.class::MAX_CHARACTERS}" id: "#{service.provider}", maxchar: "#{service.class::MAX_CHARACTERS}"
-# %select{id: "aspect_ids_", class: "form-control", name: "aspect_ids[]"}
-# %option{value: 'public'}
-# = t('public')
-# %option{value: 'all_aspects', selected: true}
-# = t('all_aspects')
-# - current_user.aspects.each do |aspect|
-# %option{value: aspect.id}
-# = "· #{aspect.name}"
.btn-toolbar.pull-right .btn-toolbar.pull-right
= render partial: "aspects/aspect_dropdown" = render partial: "aspects/aspect_dropdown"

View file

@ -153,7 +153,7 @@ Feature: posting from the main page
And I go to the aspects page And I go to the aspects page
Then I should not see "I am eating a yogurt" Then I should not see "I am eating a yogurt"
Scenario: change post target aspects with the aspect-dropdown before posting Scenario: change post target aspects with the aspect_dropdown before posting
When I expand the publisher When I expand the publisher
And I press the aspect dropdown And I press the aspect dropdown
And I toggle the aspect "PostingTo" And I toggle the aspect "PostingTo"

View file

@ -21,7 +21,9 @@ Feature: posting from the mobile main page
Scenario: post and delete some text Scenario: post and delete some text
Given I visit the mobile publisher page Given I visit the mobile publisher page
And I append "I am eating yogurt" to the publisher And I append "I am eating yogurt" to the publisher
And I select "Unicorns" from "aspect_ids_" And I press the aspect dropdown
And I toggle the aspect "Unicorns"
And I press the aspect dropdown
And I press "Share" And I press "Share"
When I go to the stream page When I go to the stream page
Then I should see "I am eating yogurt" Then I should see "I am eating yogurt"