From a37d9d532b7cbb6b1dea6fdc13a0570abde30487 Mon Sep 17 00:00:00 2001 From: Augier Date: Sat, 24 Sep 2016 16:15:38 +0200 Subject: [PATCH] Fix some pronto remarks closes #7119 --- .../app/views/notifications_view.js | 2 +- .../javascripts/app/views/stream/shortcuts.js | 19 +++++++++++-------- .../app/views/stream_post_views.js | 2 +- app/assets/stylesheets/mobile/mobile.scss | 13 +++++-------- app/views/notifications/_notification.haml | 3 ++- app/views/notifications/index.mobile.haml | 2 +- app/views/people/_index.html.haml | 2 +- app/views/photos/show.mobile.haml | 2 +- app/views/shared/_post_info.mobile.haml | 2 +- features/step_definitions/custom_web_steps.rb | 6 +++--- 10 files changed, 27 insertions(+), 26 deletions(-) diff --git a/app/assets/javascripts/app/views/notifications_view.js b/app/assets/javascripts/app/views/notifications_view.js index 69ac3cd01..08400742e 100644 --- a/app/assets/javascripts/app/views/notifications_view.js +++ b/app/assets/javascripts/app/views/notifications_view.js @@ -20,7 +20,7 @@ app.views.Notifications = Backbone.View.extend({ else { this.setUnread(guid); } }, - getAllUnread: function(){ return $(".media.stream-element.unread"); }, + getAllUnread: function() { return $(".media.stream-element.unread"); }, setRead: function(guid) { this.setUnreadStatus(guid, false); }, diff --git a/app/assets/javascripts/app/views/stream/shortcuts.js b/app/assets/javascripts/app/views/stream/shortcuts.js index 0be50ca26..56d9df05d 100644 --- a/app/assets/javascripts/app/views/stream/shortcuts.js +++ b/app/assets/javascripts/app/views/stream/shortcuts.js @@ -90,23 +90,27 @@ app.views.StreamShortcuts = Backbone.View.extend({ }, commentSelected: function() { - $('a.focus_comment_textarea',this.$('div.stream-element.loaded.shortcut_selected')).click(); + this.shortcutSelected().find("a.focus_comment_textarea").click(); }, likeSelected: function() { - $('a.like:first',this.$('div.stream-element.loaded.shortcut_selected')).click(); + this.shortcutSelected().find("a.like:first").click(); }, reshareSelected: function() { - $('a.reshare:first',this.$('div.stream-element.loaded.shortcut_selected')).click(); + this.shortcutSelected().find("a.reshare:first").click(); }, expandSelected: function() { - $('div.expander:first',this.$('div.stream-element.loaded.shortcut_selected')).click(); + this.shortcutSelected().find("div.expander:first").click(); + }, + + shortcutSelected: function() { + return this.$("div.stream-element.loaded.shortcut_selected"); }, openFirstLinkSelected: function() { - var link = $('div.collapsible a[target="_blank"]:first',this.$('div.stream-element.loaded.shortcut_selected')); + var link = $("div.collapsible a[target='_blank']:first"); if(link.length > 0) { // click does only work with vanilla javascript link[0].click(); @@ -115,12 +119,11 @@ app.views.StreamShortcuts = Backbone.View.extend({ selectPost: function(element){ //remove the selection and selected-class from all posts - var selected=this.$('div.stream-element.loaded.shortcut_selected'); - selected.removeClass('shortcut_selected').removeClass('highlighted'); + this.shortcutSelected().removeClass("shortcut_selected").removeClass("highlighted"); //move to new post window.scrollTo(window.pageXOffset, Math.round($(element).offset().top - this._headerSize)); //add the selection and selected-class to new post element.className+=" shortcut_selected highlighted"; - }, + } }); // @license-end diff --git a/app/assets/javascripts/app/views/stream_post_views.js b/app/assets/javascripts/app/views/stream_post_views.js index 4e4f4f307..31746783c 100644 --- a/app/assets/javascripts/app/views/stream_post_views.js +++ b/app/assets/javascripts/app/views/stream_post_views.js @@ -2,7 +2,7 @@ app.views.StreamPost = app.views.Post.extend({ templateName: "stream-element", - className : "stream-element loaded", + className: "stream-element loaded", subviews : { ".feedback": "feedbackView", diff --git a/app/assets/stylesheets/mobile/mobile.scss b/app/assets/stylesheets/mobile/mobile.scss index 87f6ca9bb..588ce26b8 100644 --- a/app/assets/stylesheets/mobile/mobile.scss +++ b/app/assets/stylesheets/mobile/mobile.scss @@ -108,14 +108,6 @@ textarea { resize: vertical; } width: 100%; } -.stream-element:not(.shield-active) .shield{ - display: none; -} - -.stream-element.shield-active .nsfw-hidden{ - display: none; -} - .login_error, .login_alert { color: #DF0101; @@ -195,6 +187,11 @@ footer { padding: 0; } margin-top: 0; } + + &.shield-active .nsfw-hidden, + &:not(.shield-active) .shield { + display: none; + } } .photo_attachments { diff --git a/app/views/notifications/_notification.haml b/app/views/notifications/_notification.haml index 5c9207d9c..8c537bdc0 100644 --- a/app/views/notifications/_notification.haml +++ b/app/views/notifications/_notification.haml @@ -1,4 +1,5 @@ -.media.stream-element{:data=>{:guid => note.id, :type => (Notification.types.key(note.type) || '') }, :class => (note.unread ? 'unread' : 'read')} +.media.stream-element{data: {guid: note.id, type: (Notification.types.key(note.type) || "")}, + class: (note.unread ? "unread" : "read")} .unread-toggle.pull-right %i.entypo-eye{title: (note.unread ? t("notifications.index.mark_read") : t("notifications.index.mark_unread"))} - if note.type == "Notifications::StartedSharing" && (!defined?(no_aspect_dropdown) || !no_aspect_dropdown) diff --git a/app/views/notifications/index.mobile.haml b/app/views/notifications/index.mobile.haml index 6b6d67c3a..d53a7db55 100644 --- a/app/views/notifications/index.mobile.haml +++ b/app/views/notifications/index.mobile.haml @@ -14,7 +14,7 @@ = locale_date(date) %ul.notifications_for_day - notes.each do |note| - .stream-element{data: {guid: note.id}, class: "#{note.unread ? "unread" : "read"}"} + .stream-element{data: {guid: note.id}, class: (note.unread ? "unread" : "read")} .content.from .media .media-left diff --git a/app/views/people/_index.html.haml b/app/views/people/_index.html.haml index 813cebe52..3980b16d7 100644 --- a/app/views/people/_index.html.haml +++ b/app/views/people/_index.html.haml @@ -1,6 +1,6 @@ #people_stream - people.each do |person| - .media.stream-element{:id => person.id} + .media.stream-element{id: person.id} .media-object.pull-left = person_image_link(person, :size => :thumb_small) .media-body diff --git a/app/views/photos/show.mobile.haml b/app/views/photos/show.mobile.haml index 0d5e3ec8c..69d2a96f9 100644 --- a/app/views/photos/show.mobile.haml +++ b/app/views/photos/show.mobile.haml @@ -8,7 +8,7 @@ #show_content.photos .photo = image_tag photo.url(:scaled_full) - .stream-element{:class => "photo_mobile"} + .stream-element.photo_mobile .content .from.media .media-left diff --git a/app/views/shared/_post_info.mobile.haml b/app/views/shared/_post_info.mobile.haml index 03caf1beb..e5548d3a8 100644 --- a/app/views/shared/_post_info.mobile.haml +++ b/app/views/shared/_post_info.mobile.haml @@ -21,7 +21,7 @@ = timeago(post.created_at) %span.via - if post.provider_display_name == "mobile" - = t('shared.stream-element.via_mobile', link: nil) + = t("shared.stream_element.via_mobile", link: nil) – %span.scope_scope - if post.public? diff --git a/features/step_definitions/custom_web_steps.rb b/features/step_definitions/custom_web_steps.rb index 0c0e62b70..97a8e1035 100644 --- a/features/step_definitions/custom_web_steps.rb +++ b/features/step_definitions/custom_web_steps.rb @@ -204,7 +204,7 @@ Then /^the "([^"]*)" field(?: within "([^"]*)")? should be filled with "([^"]*)" end Then /^I should see (\d+) contacts$/ do |n_posts| - has_css?("#people_stream .stream-element", :count => n_posts.to_i).should be true + has_css?("#people_stream .stream-element", count: n_posts.to_i).should be true end And /^I scroll down$/ do @@ -245,11 +245,11 @@ When /^I resize my window to 800x600$/ do end Then 'I should see an image attached to the post' do - step %{I should see a "img" within ".stream-element div.photo_attachments"} + step %(I should see a "img" within ".stream-element div.photo_attachments") end Then 'I press the attached image' do - step %{I press the 1st "img" within ".stream-element div.photo_attachments"} + step %(I press the 1st "img" within ".stream-element div.photo_attachments") end And "I wait for the popovers to appear" do