diff --git a/app/assets/javascripts/app/views/photo_view.js b/app/assets/javascripts/app/views/photo_view.js index e4035be87eebae7e2f2cafb944c70d66661192df..9bf77602bcedda1aa146ffea1fd55678e999683c 100644 --- a/app/assets/javascripts/app/views/photo_view.js +++ b/app/assets/javascripts/app/views/photo_view.js @@ -4,10 +4,21 @@ app.views.Photo = app.views.Base.extend({ className : "photo loaded", + events: { + "click .remove_post": "destroyModel" + }, + + tooltipSelector : ".block_user, .delete", + initialize : function() { $(this.el).attr("id", this.model.get("guid")); this.model.bind('remove', this.remove, this); return this; + }, + + presenter : function() { + return _.extend(this.defaultPresenter(), { + authorIsCurrentUser : this.authorIsCurrentUser(), + }); } - }); \ No newline at end of file diff --git a/app/assets/stylesheets/application.css.sass b/app/assets/stylesheets/application.css.sass index 51ed2c419692ee0b056f6e23d1f534813680e9f2..3b3cab6e18059378f390f62966b7047001d3ef9d 100644 --- a/app/assets/stylesheets/application.css.sass +++ b/app/assets/stylesheets/application.css.sass @@ -21,6 +21,7 @@ @import 'report' @import 'new_styles/_forms' @import 'tag' +@import 'photo' /* ====== media ====== */ .media diff --git a/app/assets/stylesheets/photo.css.scss b/app/assets/stylesheets/photo.css.scss new file mode 100644 index 0000000000000000000000000000000000000000..5450bff44a65e24c4afb65432f78e12dd82f95a4 --- /dev/null +++ b/app/assets/stylesheets/photo.css.scss @@ -0,0 +1,19 @@ +.photo { + .controls:first-child { + .control_icon { + @include transition(opacity); + @include opacity(0); + } + } + + &:hover { + .controls:first-child { + .control_icon { + @include opacity(0.3); + } + .control_icon:hover { + @include opacity(1); + } + } + } +} \ No newline at end of file diff --git a/app/assets/templates/photo_tpl.jst.hbs b/app/assets/templates/photo_tpl.jst.hbs index 375d6869e4f047153e4261c3fd81cf7846a1b2f6..534b9b998f35509475de425d7cfcdc9a84a1d448 100644 --- a/app/assets/templates/photo_tpl.jst.hbs +++ b/app/assets/templates/photo_tpl.jst.hbs @@ -1,3 +1,29 @@ -<a href="#" class="photo-link"> - <img src="{{sizes.large}}" class="photo big_photo" data-small-photo="{{sizes.small}}" data-full-photo="{{sizes.large}}" rel="lightbox"> -</a> \ No newline at end of file +<div class="media"> + <div class="bd"> + {{#if loggedIn}} + <div class="controls"> + {{#unless authorIsCurrentUser}} + <a href="#" rel="nofollow" data-type="post" class="post_report" title="{{t "report.name"}}"> + <div class="icons-report control_icon"/> + </a> + <a href="#" rel="nofollow" class="block_user" title="{{t "ignore"}}"> + <div class="icons-ignoreuser control_icon"></div> + </a> + <a href="#" rel="nofollow" class="delete hide_post" title="{{t "stream.hide"}}"> + <div class="icons-deletelabel delete control_icon"/> + </a> + {{else}} + <a href="#" rel="nofollow" class="delete remove_post" title="{{t "delete"}}"> + <div class="icons-deletelabel delete control_icon"/> + </a> + {{/unless}} + </div> + {{/if}} + + <a href="#" class="photo-link"> + <img src="{{sizes.large}}" class="photo big_photo" data-small-photo="{{sizes.small}}" data-full-photo="{{sizes.large}}" rel="lightbox"> + </a> + + + +</div> \ No newline at end of file diff --git a/features/desktop/profile_photos.feature b/features/desktop/profile_photos.feature index ea146196c318277a862d490eea5b5d7dd9fc2d28..8042dfa0ccbf0b97436742ecee527e6ae12cb2c1 100644 --- a/features/desktop/profile_photos.feature +++ b/features/desktop/profile_photos.feature @@ -23,3 +23,12 @@ Feature: show photos When I sign in as "alice@alice.alice" And I am on "robert@grimm.grimm"'s page Then I should not see "photos" within "div#profile" + + + Scenario: I delete a photo + Given I am on "robert@grimm.grimm"'s photos page + When I delete a photo + And I confirm the alert + Then I should not see "photos" within "div#profile" + + diff --git a/features/step_definitions/profile_steps.rb b/features/step_definitions/profile_steps.rb index 80b148d9b10f27269678e46836a1657d1dd54f4c..7fdc31ba1e6be11a1b846cef3eaae5f2f2432bd8 100644 --- a/features/step_definitions/profile_steps.rb +++ b/features/step_definitions/profile_steps.rb @@ -6,3 +6,8 @@ And /^I mark myself as safe for work$/ do uncheck('profile[nsfw]') end +When(/^I delete a photo$/) do + find('.photo.loaded').hover + find('.delete', :match => :first).click +end + diff --git a/features/support/paths.rb b/features/support/paths.rb index 1b2fa1790c1c193c2fbe431482e4f0cfb9265879..df677416407f50efe86412ff25797a2503222fa6 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -31,6 +31,9 @@ module NavigationHelpers # '.diaspora_handle' on desktop, '.description' on mobile special_elem: { selector: '.diaspora_handle, .description', text: p.diaspora_handle } } + when /^"([^\"]*)"'s photos page$/ + p = User.find_by_email($1).person + person_photos_path p when /^my account settings page$/ edit_user_path when /^my new profile page$/