move preview toggle function into composer/preview.js

v1.18.x
psychobunny 10 years ago
parent 56fc958939
commit e1ff3deaf0

@ -382,15 +382,17 @@ define('composer', [
});
bodyEl.val(draft ? draft : postData.body);
preview.render(postContainer, function() {
preview.matchScroll(postContainer);
});
preview.handleToggler(postContainer);
drafts.init(postContainer, postData);
resize.handleResize(postContainer);
handleHelp(postContainer);
handleTogglePreview(postContainer);
$(window).trigger('action:composer.loaded', {
post_uuid: post_uuid
@ -419,27 +421,6 @@ define('composer', [
});
}
function handleTogglePreview(postContainer) {
var showBtn = postContainer.find('.write-container .toggle-preview'),
hideBtn = postContainer.find('.preview-container .toggle-preview');
hideBtn.on('click', function() {
$('.preview-container').addClass('hide');
$('.write-container').addClass('maximized');
showBtn.removeClass('hide');
$('.write').focus();
});
showBtn.on('click', function() {
$('.preview-container').removeClass('hide');
$('.write-container').removeClass('maximized');
showBtn.addClass('hide');
$('.write').focus();
});
}
function updateTitle(postData, postContainer) {
var titleEl = postContainer.find('.title');

@ -44,5 +44,26 @@ define('composer/preview', function() {
preview.scrollTop(Math.max(preview[0].scrollHeight - preview.height(), 0) * scrollPercent);
};
preview.handleToggler = function(postContainer) {
var showBtn = postContainer.find('.write-container .toggle-preview'),
hideBtn = postContainer.find('.preview-container .toggle-preview');
hideBtn.on('click', function() {
$('.preview-container').addClass('hide');
$('.write-container').addClass('maximized');
showBtn.removeClass('hide');
$('.write').focus();
});
showBtn.on('click', function() {
$('.preview-container').removeClass('hide');
$('.write-container').removeClass('maximized');
showBtn.addClass('hide');
$('.write').focus();
});
};
return preview;
});
Loading…
Cancel
Save