Improve set read/unread in notifications dropdown
This commit is contained in:
parent
b64e418020
commit
232e4fa236
7 changed files with 89 additions and 110 deletions
|
|
@ -25,6 +25,7 @@ Read more in [#4249](https://github.com/diaspora/diaspora/pull/4249) and [#4883]
|
||||||
* Reorder and reword items on user settings page [#4912](https://github.com/diaspora/diaspora/pull/4912)
|
* Reorder and reword items on user settings page [#4912](https://github.com/diaspora/diaspora/pull/4912)
|
||||||
* SPV: Improve padding and interaction counts [#4426](https://github.com/diaspora/diaspora/pull/4426)
|
* SPV: Improve padding and interaction counts [#4426](https://github.com/diaspora/diaspora/pull/4426)
|
||||||
* Remove auto 'mark as read' for notifications [#4810](https://github.com/diaspora/diaspora/pull/4810)
|
* Remove auto 'mark as read' for notifications [#4810](https://github.com/diaspora/diaspora/pull/4810)
|
||||||
|
* Improve set read/unread in notifications dropdown [#4869](https://github.com/diaspora/diaspora/pull/4869)
|
||||||
|
|
||||||
## Bug fixes
|
## Bug fixes
|
||||||
* Fix email body language when invite a friend [#4832](https://github.com/diaspora/diaspora/issues/4832)
|
* Fix email body language when invite a friend [#4832](https://github.com/diaspora/diaspora/issues/4832)
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@
|
||||||
};
|
};
|
||||||
this.readClick = function() {
|
this.readClick = function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/notifications/" + $(this).data("guid"),
|
url: "/notifications/" + $(this).closest(".stream_element,.notification_element").data("guid"),
|
||||||
data: { set_unread: false },
|
data: { set_unread: false },
|
||||||
type: "PUT",
|
type: "PUT",
|
||||||
success: self.clickSuccess
|
success: self.clickSuccess
|
||||||
|
|
@ -59,42 +59,46 @@
|
||||||
};
|
};
|
||||||
this.setUpUnread = function( an_obj ) {
|
this.setUpUnread = function( an_obj ) {
|
||||||
an_obj.removeClass("read").addClass( "unread" );
|
an_obj.removeClass("read").addClass( "unread" );
|
||||||
an_obj.find('.unread-setter').hide();
|
an_obj.find('.unread-toggle')
|
||||||
an_obj.find('.unread-setter').unbind("click");
|
.unbind("click")
|
||||||
an_obj.unbind( "mouseenter mouseleave" );
|
.click(self.readClick)
|
||||||
an_obj.click(self.readClick);
|
.find('.entypo')
|
||||||
|
.tooltip('destroy')
|
||||||
|
.removeAttr('data-original-title')
|
||||||
|
.attr('title', Diaspora.I18n.t('notifications.mark_read'))
|
||||||
|
.tooltip();
|
||||||
}
|
}
|
||||||
this.setUpRead = function( an_obj ) {
|
this.setUpRead = function( an_obj ) {
|
||||||
an_obj.removeClass("unread").addClass( "read" );
|
an_obj.removeClass("unread").addClass( "read" );
|
||||||
an_obj.unbind( "click" );
|
an_obj.find('.unread-toggle')
|
||||||
an_obj.find(".unread-setter").click(Diaspora.page.header.notifications.unreadClick);
|
.unbind("click")
|
||||||
an_obj.hover(
|
.click(self.unreadClick)
|
||||||
function () {
|
.find('.entypo')
|
||||||
$(this).find(".unread-setter").show();
|
.tooltip('destroy')
|
||||||
},
|
.removeAttr('data-original-title')
|
||||||
function () {
|
.attr('title', Diaspora.I18n.t('notifications.mark_unread'))
|
||||||
$(this).find(".unread-setter").hide();
|
.tooltip();
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
this.clickSuccess = function( data ) {
|
this.clickSuccess = function( data ) {
|
||||||
var itemID = data["guid"]
|
var itemID = data["guid"]
|
||||||
var isUnread = data["unread"]
|
var isUnread = data["unread"]
|
||||||
if ( isUnread ) {
|
|
||||||
self.incrementCount();
|
|
||||||
}else{
|
|
||||||
self.decrementCount();
|
|
||||||
}
|
|
||||||
self.notificationMenu.find('.read,.unread').each(function(index) {
|
self.notificationMenu.find('.read,.unread').each(function(index) {
|
||||||
if ( $(this).data("guid") == itemID ) {
|
if ( $(this).data("guid") == itemID ) {
|
||||||
if ( isUnread ) {
|
if ( isUnread ) {
|
||||||
|
self.notificationMenu.find('a#mark_all_read_link').removeClass('disabled')
|
||||||
self.setUpUnread( $(this) )
|
self.setUpUnread( $(this) )
|
||||||
} else {
|
} else {
|
||||||
self.setUpRead( $(this) )
|
self.setUpRead( $(this) )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if ( self.notificationPage != null ) {
|
if ( self.notificationPage == null ) {
|
||||||
|
if ( isUnread ) {
|
||||||
|
self.incrementCount();
|
||||||
|
}else{
|
||||||
|
self.decrementCount();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
var type = $('.notification_element[data-guid=' + data["guid"] + ']').data('type');
|
var type = $('.notification_element[data-guid=' + data["guid"] + ']').data('type');
|
||||||
self.notificationPage.updateView(data["guid"], type, isUnread);
|
self.notificationPage.updateView(data["guid"], type, isUnread);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -239,6 +239,12 @@ ul.as-selections
|
||||||
.grey *
|
.grey *
|
||||||
:color $text-grey
|
:color $text-grey
|
||||||
|
|
||||||
|
.pull-left
|
||||||
|
:float left
|
||||||
|
|
||||||
|
.pull-right
|
||||||
|
:float right
|
||||||
|
|
||||||
.details,
|
.details,
|
||||||
.details *
|
.details *
|
||||||
:font
|
:font
|
||||||
|
|
@ -543,39 +549,6 @@ input[type="search"]
|
||||||
h3 span.current_gs_step
|
h3 span.current_gs_step
|
||||||
:color #22C910
|
:color #22C910
|
||||||
|
|
||||||
#notifications
|
|
||||||
:z-index 10
|
|
||||||
:position fixed
|
|
||||||
:bottom 21px
|
|
||||||
:right 12px
|
|
||||||
|
|
||||||
.notification
|
|
||||||
@include border-radius(5px)
|
|
||||||
@include box-shadow(0,2px,3px,#333)
|
|
||||||
|
|
||||||
:margin
|
|
||||||
:bottom 10px
|
|
||||||
|
|
||||||
:background
|
|
||||||
:color rgb(30,30,30)
|
|
||||||
:color rgba(30,30,30,0.9)
|
|
||||||
|
|
||||||
:min-width 200px
|
|
||||||
:padding 12px
|
|
||||||
:color #fff
|
|
||||||
|
|
||||||
:vertical
|
|
||||||
:align middle
|
|
||||||
|
|
||||||
.avatar
|
|
||||||
:display inline-block
|
|
||||||
:height 20px
|
|
||||||
:width 20px
|
|
||||||
:margin
|
|
||||||
:right 5px
|
|
||||||
:vertical
|
|
||||||
:align middle
|
|
||||||
|
|
||||||
ul#request_result
|
ul#request_result
|
||||||
:padding 0
|
:padding 0
|
||||||
:margin 0
|
:margin 0
|
||||||
|
|
@ -949,27 +922,6 @@ h1.tag
|
||||||
.month
|
.month
|
||||||
:font-size 14px
|
:font-size 14px
|
||||||
|
|
||||||
.notification_count
|
|
||||||
:background
|
|
||||||
:color #f0f0f0
|
|
||||||
:color $text-grey
|
|
||||||
:font
|
|
||||||
:weight normal
|
|
||||||
|
|
||||||
:padding 0 5px
|
|
||||||
:left 11px
|
|
||||||
:margin
|
|
||||||
:right 5px
|
|
||||||
:border
|
|
||||||
:radius 5px
|
|
||||||
|
|
||||||
&.unread
|
|
||||||
:background
|
|
||||||
:color lighten($red, 5%)
|
|
||||||
:color #eee !important
|
|
||||||
:font
|
|
||||||
:weight bold
|
|
||||||
|
|
||||||
.subtle
|
.subtle
|
||||||
:color $text-grey
|
:color $text-grey
|
||||||
:font
|
:font
|
||||||
|
|
|
||||||
|
|
@ -38,5 +38,3 @@ header
|
||||||
.timeago
|
.timeago
|
||||||
border: medium none
|
border: medium none
|
||||||
cursor: text
|
cursor: text
|
||||||
.unread-setter
|
|
||||||
display: none
|
|
||||||
|
|
|
||||||
|
|
@ -124,16 +124,7 @@ body > header {
|
||||||
width: 380px;
|
width: 380px;
|
||||||
display: none;
|
display: none;
|
||||||
float: left;
|
float: left;
|
||||||
color: #444;
|
color: $grey;
|
||||||
|
|
||||||
.right {
|
|
||||||
font-size: smaller;
|
|
||||||
display: inline;
|
|
||||||
position: relative;
|
|
||||||
float: right;
|
|
||||||
top: 4px;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
a { color: $blue; }
|
a { color: $blue; }
|
||||||
a.disabled {
|
a.disabled {
|
||||||
|
|
@ -142,39 +133,71 @@ body > header {
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
padding: 10px;
|
border-bottom: 1px solid $border-grey;
|
||||||
|
padding: 5px 10px 5px 5px;
|
||||||
|
|
||||||
h4 {
|
h4 {
|
||||||
padding-bottom: 0;
|
padding-bottom: 0;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
|
font-size: 16px;
|
||||||
|
color: $black;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.notification_element,
|
|
||||||
.header { border-bottom: 1px solid $border-grey; }
|
|
||||||
|
|
||||||
.ajax_loader {
|
.ajax_loader {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.notification_element {
|
.notification_element {
|
||||||
padding: 10px;
|
border-bottom: 1px solid $border-grey;
|
||||||
padding-left: 50px;
|
padding: 5px;
|
||||||
min-height: 30px;
|
min-height: 35px;
|
||||||
|
line-height: 18px;
|
||||||
&:hover { background-color: $highlight-white; }
|
|
||||||
|
|
||||||
> .avatar {
|
> .avatar {
|
||||||
height: 30px;
|
height: 35px;
|
||||||
width: 30px;
|
width: 35px;
|
||||||
float: left;
|
float: left;
|
||||||
margin-left: -40px;
|
}
|
||||||
|
|
||||||
|
.notification_message {
|
||||||
|
margin-left: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unread-toggle {
|
||||||
|
padding: 9px 5px;
|
||||||
|
.entypo {
|
||||||
|
cursor: pointer;
|
||||||
|
color: lighten($black,75%);
|
||||||
|
font-size: 17px;
|
||||||
|
line-height: 17px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.unread {
|
&.unread {
|
||||||
background-color: $background-grey;
|
background-color: $background-grey;
|
||||||
color: #000;
|
color: $black;
|
||||||
|
.unread-toggle {
|
||||||
|
.entypo { color: $black; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.view_all {
|
||||||
|
background-color: $blue;
|
||||||
|
border-bottom: 1px solid $border-dark-grey;
|
||||||
|
text-align: center;
|
||||||
|
a {
|
||||||
|
display: block;
|
||||||
|
padding: 5px;
|
||||||
|
color: white;
|
||||||
|
font-size: 12px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,15 +43,10 @@
|
||||||
|
|
||||||
<div id="notification_dropdown">
|
<div id="notification_dropdown">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<div class="right">
|
<div class="pull-right">
|
||||||
|
|
||||||
<a href="#" id="mark_all_read_link" class="{{#unless current_user.notifications_count}}disabled{{/unless}}">
|
<a href="#" id="mark_all_read_link" class="{{#unless current_user.notifications_count}}disabled{{/unless}}">
|
||||||
{{t "header.mark_all_as_read"}}
|
{{t "header.mark_all_as_read"}}
|
||||||
</a>
|
</a>
|
||||||
|
|
|
||||||
<a href="/notifications" id="view_all_notifications">
|
|
||||||
{{t "header.view_all"}}
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h4>
|
<h4>
|
||||||
|
|
@ -64,6 +59,11 @@
|
||||||
<img alt="Ajax-loader" src="{{imageUrl "ajax-loader.gif"}}">
|
<img alt="Ajax-loader" src="{{imageUrl "ajax-loader.gif"}}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="view_all">
|
||||||
|
<a href="/notifications" id="view_all_notifications">
|
||||||
|
{{t "header.view_all"}}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
.notification_element{:data=>{:guid => n.id, :type => (Notification.types.key(n.type) || '')}, :class => (n.unread ? "unread" : "read")}
|
.notification_element{:data=>{:guid => n.id, :type => (Notification.types.key(n.type) || '')}, :class => (n.unread ? "unread" : "read")}
|
||||||
|
.pull-right.unread-toggle
|
||||||
|
%i.entypo.eye{ :title => (n.unread ? t('notifications.index.mark_read') : t('notifications.index.mark_unread')) }
|
||||||
= person_image_tag n.actors.first, :thumb_small
|
= person_image_tag n.actors.first, :thumb_small
|
||||||
= notification_message_for(n)
|
.notification_message
|
||||||
%div
|
= notification_message_for(n)
|
||||||
= timeago(n.created_at)
|
%div= timeago(n.created_at)
|
||||||
= link_to t('notifications.index.mark_unread'), "#", :class => "unread-setter"
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue