mirror of
https://bitbucket.org/skobkin/chrome_point_plus.git
synced 2024-12-27 17:04:21 +00:00
Показывать уведомление при успешной рекомендации без комментария; Fixes #86
This commit is contained in:
parent
d45df7d629
commit
af70f93ec0
|
@ -188,5 +188,8 @@
|
|||
},
|
||||
"msg_saving_post_draft":{
|
||||
"message": "Saving the post..."
|
||||
},
|
||||
"msg_success_recommendation": {
|
||||
"message": "is recommended"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -189,5 +189,8 @@
|
|||
},
|
||||
"msg_saving_post_draft":{
|
||||
"message": "Сохранение поста..."
|
||||
},
|
||||
"msg_success_recommendation": {
|
||||
"message": "рекомендовано"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -503,6 +503,9 @@ function PointPlus(ppVersion) {
|
|||
if (options.is('option_ajax')) {
|
||||
// Comments
|
||||
if (options.is('option_ajax_comments')) {
|
||||
messenger.css({
|
||||
file: 'modules/ajax-comments.css'
|
||||
});
|
||||
messenger.js({
|
||||
file: 'modules/ajax-comments.js'
|
||||
}, function() {
|
||||
|
|
27
chrome_point_plus/modules/ajax-comments.css
Normal file
27
chrome_point_plus/modules/ajax-comments.css
Normal file
|
@ -0,0 +1,27 @@
|
|||
.pp-notification {
|
||||
display: block;
|
||||
position: fixed;
|
||||
top: 40px;
|
||||
right: 40px;
|
||||
padding: 20px;
|
||||
border-radius: 2px;
|
||||
font-size: 15px;
|
||||
line-height: 20px;
|
||||
transition: all 10s ease-in;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.pp-notification a,
|
||||
.pp-notification a:visited, {
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.pp-notification-success {
|
||||
background: #4CAF50;
|
||||
}
|
||||
|
||||
.pp-notification.pp-fade {
|
||||
opacity: 0;
|
||||
}
|
|
@ -194,8 +194,11 @@ AjaxCommentProcessor.prototype.onSuccess = function(data, textStatus) {
|
|||
if (data.error) {
|
||||
this.onError(null, null, data.error);
|
||||
} else {
|
||||
this.createComment(data);
|
||||
|
||||
if (this.isRecommendation() && this._text.trim().length === 0) {
|
||||
this.showSuccessRecommendation();
|
||||
} else {
|
||||
this.createComment(data);
|
||||
}
|
||||
this.hideForm();
|
||||
|
||||
// Cleaning textarea
|
||||
|
@ -277,3 +280,32 @@ AjaxCommentProcessor.prototype.setProgress = function(isProgress) {
|
|||
this._$textarea.prop('disabled', isProgress);
|
||||
this._$form.toggleClass('pp-progress', isProgress);
|
||||
};
|
||||
|
||||
AjaxCommentProcessor.prototype.getRecommendationLink = function() {
|
||||
var url = '//point.im/' + this._postId;
|
||||
var text = '#' + this._postId;
|
||||
|
||||
if (this._commentId) {
|
||||
url += '#' + this._commentId;
|
||||
text += '/' + this._commentId;
|
||||
}
|
||||
|
||||
return '<a href="' + url + '">' + text + '</a>';
|
||||
};
|
||||
|
||||
AjaxCommentProcessor.prototype.showSuccessRecommendation = function() {
|
||||
var $notification = $('<div>')
|
||||
.addClass('pp-notification pp-notification-success');
|
||||
|
||||
$notification.html(this.getRecommendationLink() + ' ' + chrome.i18n.getMessage('msg_success_recommendation'));
|
||||
|
||||
$notification.on('transitionend', function() {
|
||||
$notification.remove();
|
||||
});
|
||||
|
||||
$('body').append($notification);
|
||||
|
||||
window.requestAnimationFrame(function() {
|
||||
$notification.addClass('pp-fade');
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue