Commit 70ae9c51 authored by techird's avatar techird

草稿箱兼容

parent e8712d94
......@@ -8,6 +8,27 @@ function DraftManager( minder ) {
function init() {
drafts = localStorage.getItem( 'drafts' );
drafts = drafts ? JSON.parse( drafts ) : [];
loadDraftForOldVersion();
}
/**
* @todo 1.2 版本中删除该方法
*
* 加载老版本的草稿
*/
function loadDraftForOldVersion() {
var path = localStorage.getItem( 'draft_filename' ),
data = localStorage.getItem( 'draft_data' );
if ( path && data ) {
drafts.push( {
path: path,
data: data,
name: JSON.parse( data ).data.text,
update: new Date()
} );
localStorage.removeItem( 'draft_filename' );
localStorage.removeItem( 'draft_data' );
}
}
function store() {
......
......@@ -457,7 +457,8 @@ $( function () {
var list = draftManager.list(),
draft, $draft, index;
if ( !list.length ) {
return false;
draftManager.create();
list = draftManager.list();
}
draft = list.shift();
......@@ -488,7 +489,7 @@ $( function () {
function adjustDraftMenu() {
var pos = $draft_btn.offset();
pos.top -= $draft_menu.outerHeight() + 15;
pos.top -= $draft_menu.outerHeight() + 5;
$draft_menu.offset( pos );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment