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), draft = drafts.getDraft(postData.save_id),
submitBtn = postContainer.find('.composer-submit'); submitBtn = postContainer.find('.composer-submit');
preview.handleToggler(postContainer);
tags.init(postContainer, composer.posts[post_uuid]); tags.init(postContainer, composer.posts[post_uuid]);
categoryList.init(postContainer, composer.posts[post_uuid]); categoryList.init(postContainer, composer.posts[post_uuid]);
@ -386,7 +387,6 @@ define('composer', [
preview.render(postContainer, function() { preview.render(postContainer, function() {
preview.matchScroll(postContainer); preview.matchScroll(postContainer);
}); });
preview.handleToggler(postContainer);
drafts.init(postContainer, postData); drafts.init(postContainer, postData);

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

Loading…
Cancel
Save