if mobile, go to /compose route #3090

v1.18.x
psychobunny 11 years ago
parent 117bb407b0
commit 55bed3464e

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

Loading…
Cancel
Save