Commit 8f055633 authored by techird's avatar techird

草稿箱大小限制;文件编辑状态调整

parent 8057635b
function DraftManager( minder ) {
var current = null,
localStorage = window.localStorage,
drafts;
drafts,
MAX_SIZE = 15;
init();
......@@ -32,7 +33,7 @@ function DraftManager( minder ) {
}
function store() {
localStorage.setItem( 'drafts', JSON.stringify( drafts ) );
localStorage.setItem( 'drafts', JSON.stringify( drafts.slice( 0, MAX_SIZE ) ) );
}
function create( path ) {
......@@ -84,6 +85,7 @@ function DraftManager( minder ) {
current.update = new Date();
store();
}
return current;
}
function sync() {
......@@ -92,7 +94,7 @@ function DraftManager( minder ) {
}
function list() {
return drafts.slice();
return drafts.slice( 0, 15 );
}
function remove( remove_index ) {
......
......@@ -328,7 +328,9 @@ $( function () {
draft = draftManager.openByPath( path );
setRemotePath( path, !draft || draft.sync );
if ( draft ) {
watchingChanges = false;
draftManager.load();
watchingChanges = true;
} else {
loadRemote();
}
......@@ -338,12 +340,9 @@ $( function () {
// 新建文件
function newFile() {
setRemotePath( null, true );
watchingChanges = false;
minder.importData( '新建脑图', 'plain' );
draftManager.create();
watchingChanges = true;
minder.importData( '新建脑图', 'plain' );
minder.execCommand( 'camera', minder.getRoot() );
$user_btn.text( '<新建脑图>' );
}
function generateRemotePath() {
......@@ -471,14 +470,10 @@ $( function () {
function watchChanges() {
minder.on( 'contentchange', function () {
if ( !watchingChanges ) return;
var currentData = minder.exportData( 'json' );
if ( watchChanges.lastData != currentData ) {
if ( currentAccount ) {
$save_btn.disabled( false ).text( '保存' );
watchChanges.lastData = currentData;
setRemotePath( remotePath, false );
}
draftManager.save();
var current = draftManager.save();
if ( currentAccount ) {
$save_btn.disabled( current.sync ).text( '保存' );
setRemotePath( remotePath, current.sync );
}
} );
}
......
......@@ -89,6 +89,7 @@ KityMinder.registerModule( 'View', function () {
} else {
minder.rollbackStatus();
}
this.setContentChanged( false );
},
queryState: function ( minder ) {
......
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