Option for AJAX comments. A bit of JSDoc.

This commit is contained in:
Alexey Skobkin 2015-01-15 13:45:07 +04:00
parent 56bd3117ec
commit 6d6a9fa3d6
4 changed files with 100 additions and 86 deletions

View file

@ -113,8 +113,11 @@
"option_nsfw_blur_comments_entire": {
"message": "Blur entire comments in nsfw posts"
},
"option_ctrl_enter": {
"message": "Send post and comments by CTRL+Enter (deprecated)"
"option_ajax": {
"message": "AJAX"
},
"option_ajax_comments": {
"message": "Send comments via AJAX (CTRL+Enter)"
},
"option_fluid_layout": {
"message": "Fluid layout"

View file

@ -113,8 +113,11 @@
"option_nsfw_blur_comments_entire": {
"message": "Размытие комментариев целиком"
},
"option_ctrl_enter": {
"message": "Отправлять текст по CTRL+Enter (устарело)"
"option_ajax": {
"message": "AJAX"
},
"option_ajax_comments": {
"message": "Отправка комментариев через AJAX (CTRL+Enter)"
},
"option_fluid_layout": {
"message": ""Резиновая" вёрстка (растянуть сайт по горизонтали)"

View file

@ -544,8 +544,9 @@ $(document).ready(function() {
});
}
// @todo implement option
if (true || options.is('option_ajax_comments')) {
if (options.is('option_ajax')) {
// Comments
if (options.is('option_ajax_comments')) {
// Removing old bindings
// Dirty hack for page context
$('#comments').replaceWith($('#comments').clone());
@ -573,13 +574,15 @@ $(document).ready(function() {
alert(chrome.i18n.getMessage('msg_comment_send_failed') + '\n' + error);
},
/**
* @param {object} data Response data
* @param {number} data.comment_id ID of the created comment
* @param {string} data.id ID of the post
* @param {string} textStatus Text of request status
*/
success: function(data, textStatus) {
console.log('data %O', data);
console.log('status %O', textStatus);
/*{
comment_id: 34,
id: 'ovrwcv'
};*/
if (textStatus === 'success') {
// Hiding form
@ -625,7 +628,7 @@ $(document).ready(function() {
});
}
});
}
}
// Hightlight post with new comments

View file

@ -165,10 +165,15 @@
</section>
<section class="tabs-content-item" id="other">
<div class="option-node">
<input type="checkbox" name="option-ajax" id="option-ajax">
<label for="option-ajax" data-i18n="option_ajax"></label>
<label class="option-node">
<input type="checkbox" name="option-ctrl-enter" disabled="disabled">
<span data-i18n="option_ctrl_enter"></span>
<input type="checkbox" name="option-ajax-comments">
<span data-i18n="option_ajax_comments"></span>
</label>
</div>
<label class="option-node">
<input type="checkbox" name="option-fluid-layout">