added localStorage for preview toggled state

v1.18.x
psychobunny 10 years ago
parent e1ff3deaf0
commit 7563e9aba1

@ -305,6 +305,7 @@ define('composer', [
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]);
@ -386,7 +387,6 @@ define('composer', [
preview.render(postContainer, function() {
preview.matchScroll(postContainer);
});
preview.handleToggler(postContainer);
drafts.init(postContainer, postData);

@ -45,24 +45,37 @@ define('composer/preview', function() {
};
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');
function hidePreview() {
previewContainer.addClass('hide');
writeContainer.addClass('maximized');
showBtn.removeClass('hide');
$('.write').focus();
});
localStorage.setItem('composer:previewToggled', true);
}
showBtn.on('click', function() {
$('.preview-container').removeClass('hide');
$('.write-container').removeClass('maximized');
function showPreview() {
previewContainer.removeClass('hide');
writeContainer.removeClass('maximized');
showBtn.addClass('hide');
$('.write').focus();
});
localStorage.removeItem('composer:previewToggled');
}
var showBtn = postContainer.find('.write-container .toggle-preview'),
hideBtn = postContainer.find('.preview-container .toggle-preview'),
previewContainer = $('.preview-container'),
writeContainer = $('.write-container');
hideBtn.on('click', hidePreview);
showBtn.on('click', showPreview);
if (localStorage.getItem('composer:previewToggled')) {
hidePreview();
} else {
showPreview();
}
};
return preview;

Loading…
Cancel
Save