|
|
@ -1,10 +1,11 @@
|
|
|
|
define([
|
|
|
|
define([
|
|
|
|
|
|
|
|
'jquery',
|
|
|
|
'json.sortify',
|
|
|
|
'json.sortify',
|
|
|
|
'/common/common-util.js',
|
|
|
|
'/common/common-util.js',
|
|
|
|
'/common/hyperscript.js',
|
|
|
|
'/common/hyperscript.js',
|
|
|
|
'/common/common-interface.js',
|
|
|
|
'/common/common-interface.js',
|
|
|
|
'/customize/messages.js'
|
|
|
|
'/customize/messages.js'
|
|
|
|
], function (Sortify, Util, h, UI, Messages) {
|
|
|
|
], function ($, Sortify, Util, h, UI, Messages) {
|
|
|
|
var Comments = {};
|
|
|
|
var Comments = {};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -262,20 +263,27 @@ define([
|
|
|
|
}, function () {
|
|
|
|
}, function () {
|
|
|
|
// Delete the comment
|
|
|
|
// Delete the comment
|
|
|
|
delete Env.comments.data[key];
|
|
|
|
delete Env.comments.data[key];
|
|
|
|
Env.editor.plugins.comments.uncomment(key);
|
|
|
|
var els = Env.$inner.find('comment[data-uid="'+key+'"]').toArray();
|
|
|
|
|
|
|
|
Env.editor.plugins.comments.uncomment(key, els);
|
|
|
|
|
|
|
|
|
|
|
|
// Send to chainpad
|
|
|
|
// Send to chainpad
|
|
|
|
updateMetadata(Env);
|
|
|
|
updateMetadata(Env);
|
|
|
|
Env.framework.localChange();
|
|
|
|
Env.framework.localChange();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var focusContent = function () {
|
|
|
|
|
|
|
|
Env.$inner.find('comment[data-uid="'+key+'"]').focus();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
$div.click(function () {
|
|
|
|
$div.click(function () {
|
|
|
|
if ($div.hasClass('cp-comment-active')) { return; }
|
|
|
|
if ($div.hasClass('cp-comment-active')) { return; }
|
|
|
|
Env.$container.find('.cp-comment-active').removeClass('cp-comment-active');
|
|
|
|
Env.$container.find('.cp-comment-active').removeClass('cp-comment-active');
|
|
|
|
$div.addClass('cp-comment-active');
|
|
|
|
$div.addClass('cp-comment-active');
|
|
|
|
|
|
|
|
div.scrollIntoView();
|
|
|
|
$actions.css('display', '');
|
|
|
|
$actions.css('display', '');
|
|
|
|
Env.$container.find('.cp-comment-form').remove();
|
|
|
|
Env.$container.find('.cp-comment-form').remove();
|
|
|
|
// XXX highlight (and scroll to) the comment in the doc?
|
|
|
|
|
|
|
|
|
|
|
|
focusContent();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if ($oldInput && $oldInput.attr('data-uid') === key) {
|
|
|
|
if ($oldInput && $oldInput.attr('data-uid') === key) {
|
|
|
@ -283,6 +291,7 @@ define([
|
|
|
|
$actions.hide();
|
|
|
|
$actions.hide();
|
|
|
|
$div.append($oldInput);
|
|
|
|
$div.append($oldInput);
|
|
|
|
$oldInput.find('textarea').focus();
|
|
|
|
$oldInput.find('textarea').focus();
|
|
|
|
|
|
|
|
focusContent();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -338,7 +347,7 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Comment not in the metadata: uncomment (probably an undo)
|
|
|
|
// Comment not in the metadata: uncomment (probably an undo)
|
|
|
|
if (comments.indexOf(id) === -1) {
|
|
|
|
if (comments.indexOf(id) === -1) {
|
|
|
|
Env.editor.plugins.comments.uncomment(id);
|
|
|
|
Env.editor.plugins.comments.uncomment(id, [el]);
|
|
|
|
changed = true;
|
|
|
|
changed = true;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -459,6 +468,12 @@ sel.forEach(function (el) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Env.$container.find('.cp-comment-active').removeClass('cp-comment-active');
|
|
|
|
Env.$container.find('.cp-comment-active').removeClass('cp-comment-active');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
Env.$inner.on('click', 'comment', function (e) {
|
|
|
|
|
|
|
|
var $comment = $(e.target);
|
|
|
|
|
|
|
|
var uid = $comment.attr('data-uid');
|
|
|
|
|
|
|
|
if (!uid) { return; }
|
|
|
|
|
|
|
|
Env.$container.find('.cp-comment-container[data-uid="'+uid+'"]').click();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var call = function (f) {
|
|
|
|
var call = function (f) {
|
|
|
|
return function () {
|
|
|
|
return function () {
|
|
|
|