|
|
|
@ -321,117 +321,127 @@ define('composer', [
|
|
|
|
|
isAdminOrMod: app.user.isAdmin || postData.isMod
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
parseAndTranslate('composer', data, function(composerTemplate) {
|
|
|
|
|
if ($('#cmp-uuid-' + post_uuid).length) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
composerTemplate = $(composerTemplate);
|
|
|
|
|
if (data.isMobile) {
|
|
|
|
|
ajaxify.go('compose', function() {
|
|
|
|
|
renderComposer();
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
renderComposer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
composerTemplate.attr('id', 'cmp-uuid-' + post_uuid);
|
|
|
|
|
function renderComposer() {
|
|
|
|
|
parseAndTranslate('composer', data, function(composerTemplate) {
|
|
|
|
|
if ($('#cmp-uuid-' + post_uuid).length) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
composerTemplate = $(composerTemplate);
|
|
|
|
|
|
|
|
|
|
$(document.body).append(composerTemplate);
|
|
|
|
|
composerTemplate.attr('id', 'cmp-uuid-' + post_uuid);
|
|
|
|
|
|
|
|
|
|
var postContainer = $(composerTemplate[0]),
|
|
|
|
|
bodyEl = postContainer.find('textarea'),
|
|
|
|
|
draft = drafts.getDraft(postData.save_id),
|
|
|
|
|
submitBtn = postContainer.find('.composer-submit');
|
|
|
|
|
$(document.body).append(composerTemplate);
|
|
|
|
|
|
|
|
|
|
preview.handleToggler(postContainer);
|
|
|
|
|
tags.init(postContainer, composer.posts[post_uuid]);
|
|
|
|
|
categoryList.init(postContainer, composer.posts[post_uuid]);
|
|
|
|
|
var postContainer = $(composerTemplate[0]),
|
|
|
|
|
bodyEl = postContainer.find('textarea'),
|
|
|
|
|
draft = drafts.getDraft(postData.save_id),
|
|
|
|
|
submitBtn = postContainer.find('.composer-submit');
|
|
|
|
|
|
|
|
|
|
activate(post_uuid);
|
|
|
|
|
resize.reposition(postContainer);
|
|
|
|
|
preview.handleToggler(postContainer);
|
|
|
|
|
tags.init(postContainer, composer.posts[post_uuid]);
|
|
|
|
|
categoryList.init(postContainer, composer.posts[post_uuid]);
|
|
|
|
|
|
|
|
|
|
if (config.allowFileUploads || config.hasImageUploadPlugin) {
|
|
|
|
|
uploads.initialize(post_uuid);
|
|
|
|
|
}
|
|
|
|
|
activate(post_uuid);
|
|
|
|
|
resize.reposition(postContainer);
|
|
|
|
|
|
|
|
|
|
formatting.addHandler(postContainer);
|
|
|
|
|
if (config.allowFileUploads || config.hasImageUploadPlugin) {
|
|
|
|
|
uploads.initialize(post_uuid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (allowTopicsThumbnail) {
|
|
|
|
|
uploads.toggleThumbEls(postContainer, composer.posts[post_uuid].topic_thumb || '');
|
|
|
|
|
}
|
|
|
|
|
formatting.addHandler(postContainer);
|
|
|
|
|
|
|
|
|
|
postContainer.on('change', 'input, textarea', function() {
|
|
|
|
|
composer.posts[post_uuid].modified = true;
|
|
|
|
|
});
|
|
|
|
|
if (allowTopicsThumbnail) {
|
|
|
|
|
uploads.toggleThumbEls(postContainer, composer.posts[post_uuid].topic_thumb || '');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
submitBtn.on('click', function() {
|
|
|
|
|
var action = $(this).attr('data-action');
|
|
|
|
|
postContainer.on('change', 'input, textarea', function() {
|
|
|
|
|
composer.posts[post_uuid].modified = true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
switch(action) {
|
|
|
|
|
case 'post-lock':
|
|
|
|
|
$(this).attr('disabled', true);
|
|
|
|
|
post(post_uuid, {lock: true});
|
|
|
|
|
break;
|
|
|
|
|
submitBtn.on('click', function() {
|
|
|
|
|
var action = $(this).attr('data-action');
|
|
|
|
|
|
|
|
|
|
case 'post': // intentional fall-through
|
|
|
|
|
default:
|
|
|
|
|
$(this).attr('disabled', true);
|
|
|
|
|
post(post_uuid);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
switch(action) {
|
|
|
|
|
case 'post-lock':
|
|
|
|
|
$(this).attr('disabled', true);
|
|
|
|
|
post(post_uuid, {lock: true});
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
postContainer.on('click', 'a[data-switch-action]', function() {
|
|
|
|
|
var action = $(this).attr('data-switch-action'),
|
|
|
|
|
label = $(this).html();
|
|
|
|
|
case 'post': // intentional fall-through
|
|
|
|
|
default:
|
|
|
|
|
$(this).attr('disabled', true);
|
|
|
|
|
post(post_uuid);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
submitBtn.attr('data-action', action).html(label);
|
|
|
|
|
});
|
|
|
|
|
postContainer.on('click', 'a[data-switch-action]', function() {
|
|
|
|
|
var action = $(this).attr('data-switch-action'),
|
|
|
|
|
label = $(this).html();
|
|
|
|
|
|
|
|
|
|
postContainer.find('.composer-discard').on('click', function() {
|
|
|
|
|
if (!composer.posts[post_uuid].modified) {
|
|
|
|
|
removeComposerHistory();
|
|
|
|
|
discard(post_uuid);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var btn = $(this).prop('disabled', true);
|
|
|
|
|
translator.translate('[[modules:composer.discard]]', function(translated) {
|
|
|
|
|
bootbox.confirm(translated, function(confirm) {
|
|
|
|
|
if (confirm) {
|
|
|
|
|
removeComposerHistory();
|
|
|
|
|
discard(post_uuid);
|
|
|
|
|
}
|
|
|
|
|
btn.prop('disabled', false);
|
|
|
|
|
submitBtn.attr('data-action', action).html(label);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
postContainer.find('.composer-discard').on('click', function() {
|
|
|
|
|
if (!composer.posts[post_uuid].modified) {
|
|
|
|
|
removeComposerHistory();
|
|
|
|
|
discard(post_uuid);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var btn = $(this).prop('disabled', true);
|
|
|
|
|
translator.translate('[[modules:composer.discard]]', function(translated) {
|
|
|
|
|
bootbox.confirm(translated, function(confirm) {
|
|
|
|
|
if (confirm) {
|
|
|
|
|
removeComposerHistory();
|
|
|
|
|
discard(post_uuid);
|
|
|
|
|
}
|
|
|
|
|
btn.prop('disabled', false);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
postContainer.on('click', function() {
|
|
|
|
|
if (!taskbar.isActive(post_uuid)) {
|
|
|
|
|
taskbar.updateActive(post_uuid);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
postContainer.on('click', function() {
|
|
|
|
|
if (!taskbar.isActive(post_uuid)) {
|
|
|
|
|
taskbar.updateActive(post_uuid);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
bodyEl.on('input propertychange', function() {
|
|
|
|
|
preview.render(postContainer);
|
|
|
|
|
});
|
|
|
|
|
bodyEl.on('input propertychange', function() {
|
|
|
|
|
preview.render(postContainer);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
bodyEl.on('scroll', function() {
|
|
|
|
|
preview.matchScroll(postContainer);
|
|
|
|
|
});
|
|
|
|
|
bodyEl.on('scroll', function() {
|
|
|
|
|
preview.matchScroll(postContainer);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
bodyEl.val(draft ? draft : postData.body);
|
|
|
|
|
bodyEl.val(draft ? draft : postData.body);
|
|
|
|
|
|
|
|
|
|
preview.render(postContainer, function() {
|
|
|
|
|
preview.matchScroll(postContainer);
|
|
|
|
|
});
|
|
|
|
|
preview.render(postContainer, function() {
|
|
|
|
|
preview.matchScroll(postContainer);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
drafts.init(postContainer, postData);
|
|
|
|
|
drafts.init(postContainer, postData);
|
|
|
|
|
|
|
|
|
|
resize.handleResize(postContainer);
|
|
|
|
|
resize.handleResize(postContainer);
|
|
|
|
|
|
|
|
|
|
handleHelp(postContainer);
|
|
|
|
|
handleHelp(postContainer);
|
|
|
|
|
|
|
|
|
|
$(window).trigger('action:composer.loaded', {
|
|
|
|
|
post_uuid: post_uuid
|
|
|
|
|
});
|
|
|
|
|
$(window).trigger('action:composer.loaded', {
|
|
|
|
|
post_uuid: post_uuid
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
formatting.addComposerButtons();
|
|
|
|
|
focusElements(postContainer);
|
|
|
|
|
});
|
|
|
|
|
formatting.addComposerButtons();
|
|
|
|
|
focusElements(postContainer);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseAndTranslate(template, data, callback) {
|
|
|
|
|