Commit f0709a44 authored by techird's avatar techird

文件移动及重命名功能

parent a2cac974
...@@ -57,6 +57,7 @@ KityMinder.LANG['zh-cn'] = { ...@@ -57,6 +57,7 @@ KityMinder.LANG['zh-cn'] = {
'err_share_data': '加载分享内容出错', 'err_share_data': '加载分享内容出错',
'err_share_sync_fail': '分享内容同步失败', 'err_share_sync_fail': '分享内容同步失败',
'err_move_file': '文件移动失败', 'err_move_file': '文件移动失败',
'err_rename': '重命名失败',
'unknownreason': '可能是外星人篡改了代码...', 'unknownreason': '可能是外星人篡改了代码...',
'pcs_code': { 'pcs_code': {
...@@ -131,12 +132,16 @@ KityMinder.LANG['zh-cn'] = { ...@@ -131,12 +132,16 @@ KityMinder.LANG['zh-cn'] = {
'ui': { 'ui': {
'load_share_for_edit': '正在加载分享的文件...', 'load_share_for_edit': '正在加载分享的文件...',
'share_sync_success': '分享内容已同步', 'share_sync_success': '分享内容已同步',
'recycle_clear_confirm': '确认清空回收站么?清空后的文件无法恢复。',
'fullscreen_exit_hint': '按 Esc 或 F11 退出全屏', 'fullscreen_exit_hint': '按 Esc 或 F11 退出全屏',
'error_detail': '详细信息', 'error_detail': '详细信息',
'copy_and_feedback': '复制并反馈', 'copy_and_feedback': '复制并反馈',
'move_file_confirm': '确定把 "{0}" 移动到 "{1}" 吗?', 'move_file_confirm': '确定把 "{0}" 移动到 "{1}" 吗?',
'rename': '重命名',
'rename_success': '<b>{0}</b> 重命名成功',
'move_success': '<b>{0}</b> 移动成功',
'command': { 'command': {
'appendsiblingnode': '插入同级主题', 'appendsiblingnode': '插入同级主题',
......
...@@ -73,8 +73,6 @@ KityMinder.registerModule('Expand', function() { ...@@ -73,8 +73,6 @@ KityMinder.registerModule('Expand', function() {
var changed = node.isExpanded() ? (state == STATE_COLLAPSE) : (state == STATE_EXPAND); var changed = node.isExpanded() ? (state == STATE_COLLAPSE) : (state == STATE_EXPAND);
policy = policy || EXPAND_POLICY.KEEP_STATE; policy = policy || EXPAND_POLICY.KEEP_STATE;
policy(node, state, policy); policy(node, state, policy);
if (!changed) return;
node.renderTree().getMinder().layout(100); node.renderTree().getMinder().layout(100);
......
...@@ -13,6 +13,33 @@ KityMinder.registerUI('doc', function(minder) { ...@@ -13,6 +13,33 @@ KityMinder.registerUI('doc', function(minder) {
var current = { saved: true }; var current = { saved: true };
var loading = false; var loading = false;
var notice = minder.getUI('widget/notice'); var notice = minder.getUI('widget/notice');
var finder = minder.getUI('widget/netdiskfinder');
finder.on('mv', trackFileMove);
function trackFileMove(from, to) {
if (current.source != 'netdisk') return;
var fromPath = from.split('/');
var toPath = to.split('/');
function preCommonLength(a, b) {
var i = 0;
while((i in a) && (i in b) && a[i] == b[i]) i++;
return (i in b) ? 0 : i;
}
var originPath = current.path.split('/');
var clen = preCommonLength(originPath, fromPath);
if (clen) {
var movedPath = toPath.concat(originPath.slice(clen));
current.path = movedPath.join('/');
current.title = movedPath.pop();
ret.fire('docchange', current);
}
}
/** /**
* 加载文档 * 加载文档
...@@ -46,9 +73,8 @@ KityMinder.registerUI('doc', function(minder) { ...@@ -46,9 +73,8 @@ KityMinder.registerUI('doc', function(minder) {
doc.data = data; doc.data = data;
doc.json = JSON.stringify(data); doc.json = JSON.stringify(data);
minder.getUI('topbar/title').setTitle(doc.title, doc.saved);
ret.fire('docload', doc); ret.fire('docload', doc);
ret.fire('docchange', doc);
return doc; return doc;
...@@ -67,9 +93,10 @@ KityMinder.registerUI('doc', function(minder) { ...@@ -67,9 +93,10 @@ KityMinder.registerUI('doc', function(minder) {
current = doc; current = doc;
doc.data = minder.exportJson(); doc.data = minder.exportJson();
doc.json = JSON.stringify(doc.data); doc.json = JSON.stringify(doc.data);
doc.saved = true;
minder.getUI('topbar/title').setTitle(doc.title, doc.saved = true);
ret.fire('docsave', doc); ret.fire('docsave', doc);
ret.fire('docchange', doc);
} }
function getCurrent() { function getCurrent() {
...@@ -87,24 +114,16 @@ KityMinder.registerUI('doc', function(minder) { ...@@ -87,24 +114,16 @@ KityMinder.registerUI('doc', function(minder) {
minder.on('contentchange', function() { minder.on('contentchange', function() {
if (loading) return; if (loading) return;
var $title = minder.getUI('topbar/title');
if (current.source != 'netdisk') { if (current.source != 'netdisk') {
current.title = minder.getMinderTitle(); current.title = minder.getMinderTitle();
$title.setTitle(current.title, current.saved = false); current.saved = false;
ret.fire('docchange', current);
} else { } else {
current.saved = current.json == JSON.stringify(minder.exportJson());
if (current.json != JSON.stringify(minder.exportJson())) {
$title.setSaved(current.saved = false);
ret.fire('docchange', current);
} else {
$title.setSaved(current.saved = true);
}
} }
ret.fire('docchange', current);
}); });
}, 1000); }, 1000);
......
...@@ -96,6 +96,7 @@ KityMinder.registerUI('menu/open/draft', function(minder) { ...@@ -96,6 +96,7 @@ KityMinder.registerUI('menu/open/draft', function(minder) {
renderList(); renderList();
function pushDraft(doc) { function pushDraft(doc) {
if (doc.saved) return;
if (doc == lastDoc) { if (doc == lastDoc) {
if (current) { if (current) {
draftList.remove(0); draftList.remove(0);
......
...@@ -18,7 +18,7 @@ KityMinder.registerUI('menu/open/netdisk', function(minder) { ...@@ -18,7 +18,7 @@ KityMinder.registerUI('menu/open/netdisk', function(minder) {
var notice = minder.getUI('widget/notice'); var notice = minder.getUI('widget/notice');
/* 网盘面板 */ /* 网盘面板 */
var $panel = $($open.createSub('netdisk')); var $panel = $($open.createSub('netdisk')).addClass('netdisk-open-panel');
/* extension => protocol */ /* extension => protocol */
var supports = {}; var supports = {};
......
...@@ -15,6 +15,7 @@ KityMinder.registerUI('menu/open/recent', function(minder) { ...@@ -15,6 +15,7 @@ KityMinder.registerUI('menu/open/recent', function(minder) {
var frdTime = minder.getUI('widget/friendlytimespan'); var frdTime = minder.getUI('widget/friendlytimespan');
var doc = minder.getUI('doc'); var doc = minder.getUI('doc');
var recentList = minder.getUI('widget/locallist').use('recent'); var recentList = minder.getUI('widget/locallist').use('recent');
var finder = minder.getUI('widget/netdiskfinder');
/* 网盘面板 */ /* 网盘面板 */
var $panel = $($open.createSub('recent')).addClass('recent-file-panel'); var $panel = $($open.createSub('recent')).addClass('recent-file-panel');
...@@ -59,8 +60,33 @@ KityMinder.registerUI('menu/open/recent', function(minder) { ...@@ -59,8 +60,33 @@ KityMinder.registerUI('menu/open/recent', function(minder) {
doc.on('docload', addToList); doc.on('docload', addToList);
doc.on('docsave', addToList); doc.on('docsave', addToList);
finder.on('mv', trackFileMove);
renderList(); renderList();
function trackFileMove(from, to) {
var fromPath = from.split('/');
var toPath = to.split('/');
function preCommonLength(a, b) {
var i = 0;
while((i in a) && (i in b) && a[i] == b[i]) i++;
return (i in b) ? 0 : i;
}
recentList.forEach(function(item) {
var originPath = item.path.split('/');
var clen = preCommonLength(originPath, fromPath);
if (clen) {
var movedPath = toPath.concat(originPath.slice(clen));
item.path = movedPath.join('/');
item.filename = toPath.pop();
}
});
renderList();
}
function addToList(doc) { function addToList(doc) {
if (doc.source != 'netdisk') return; if (doc.source != 'netdisk') return;
......
...@@ -66,6 +66,8 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) { ...@@ -66,6 +66,8 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) {
$format.val('.km'); $format.val('.km');
$format.on('change', normalizeFilename);
/* 保存按钮 */ /* 保存按钮 */
var $saveBtn = $('<button></button>') var $saveBtn = $('<button></button>')
.addClass('save-button') .addClass('save-button')
...@@ -73,7 +75,7 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) { ...@@ -73,7 +75,7 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) {
.click(save) .click(save)
.appendTo($selects); .appendTo($selects);
$menu.on('show', setFileName); $menu.on('show', setFilename);
$finder.on('fileclick', function(file) { $finder.on('fileclick', function(file) {
$finder.select(file.path); $finder.select(file.path);
...@@ -98,7 +100,8 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) { ...@@ -98,7 +100,8 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) {
var autoSaveTimer = 0; var autoSaveTimer = 0;
function autoSave() { function autoSave() {
function lazySave() { function lazySave(doc) {
if (doc.saved) return;
clearTimeout(autoSaveTimer); clearTimeout(autoSaveTimer);
autoSaveTimer = setTimeout(saveCurrent, autoSaveDuration); autoSaveTimer = setTimeout(saveCurrent, autoSaveDuration);
} }
...@@ -127,13 +130,26 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) { ...@@ -127,13 +130,26 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) {
return doSave(doc.path, doc.protocol, doc, $title, 'leaveTheMenu'); return doSave(doc.path, doc.protocol, doc, $title, 'leaveTheMenu');
} }
function getSaveContext() { function normalizeFilename() {
var filename = $filename.val(); var filename = $filename.val();
var info = fio.file.anlysisPath(filename);
if (fio.file.anlysisPath(filename).extension != $format.val()) { var ext = info.extension;
$filename.val(filename += $format.val())[0].select();
if (ext != $format.val()) {
if (ext in supports) {
$filename.val(info.name + $format.val());
} else {
$filename.val(filename + $format.val());
}
$filename[0].select();
} }
return $filename.val();
}
function getSaveContext() {
var filename = normalizeFilename();
var path = $finder.pwd() + filename; var path = $finder.pwd() + filename;
var doc = $doc.current(); var doc = $doc.current();
var protocol = supports[$format.val()]; var protocol = supports[$format.val()];
...@@ -212,22 +228,27 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) { ...@@ -212,22 +228,27 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) {
}); });
} }
function setFileName() { function setFilename() {
var doc = $doc.current(); var doc = $doc.current();
switch (doc.source) { switch (doc.source) {
case 'netdisk': case 'netdisk':
setFileNameForNetDiskSource(doc); setFilenameForNetDiskSource(doc);
break; break;
default: default:
setFileNameForOtherSource(doc); setFilenameForOtherSource(doc);
break; break;
} }
$filename[0].select(); $filename[0].select();
} }
function setFileNameForNetDiskSource(doc) { function setFilenameInputValue(filename) {
$filename.val(filename);
normalizeFilename(filename);
}
function setFilenameForNetDiskSource(doc) {
if (!fio.user.current()) return; if (!fio.user.current()) return;
var path = doc.path; var path = doc.path;
...@@ -242,11 +263,11 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) { ...@@ -242,11 +263,11 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) {
$finder.select(path); $finder.select(path);
} }
$filename.val(pathInfo.filename); setFilenameInputValue(pathInfo.filename);
} }
function setFileNameForOtherSource(doc) { function setFilenameForOtherSource(doc) {
$filename.val(doc.title); setFilenameInputValue(doc.title);
$finder.select(null); $finder.select(null);
} }
......
...@@ -11,11 +11,19 @@ KityMinder.registerUI('menu/share/share', function(minder) { ...@@ -11,11 +11,19 @@ KityMinder.registerUI('menu/share/share', function(minder) {
var $share_menu = minder.getUI('menu/menu').createSubMenu('share'); var $share_menu = minder.getUI('menu/menu').createSubMenu('share');
var $create_menu = $($share_menu.createSub('createshare')); var $create_menu = $($share_menu.createSub('createshare'));
var $manage_menu = $($share_menu.createSub('manageshare')); var $manage_menu = $($share_menu.createSub('manageshare'));
var $share_list = $('<ul>')
.attr('id', 'manage-share-list')
.appendTo($manage_menu);
var $doc = minder.getUI('doc'); var $doc = minder.getUI('doc');
var notice = minder.getUI('widget/notice'); var notice = minder.getUI('widget/notice');
var finder = minder.getUI('widget/netdiskfinder');
var BACKEND_URL = 'http://naotu.baidu.com/share.php'; var BACKEND_URL = 'http://naotu.baidu.com/share.php';
if (window.location.host == 'local.host') {
BACKEND_URL = 'http://naotu.baidu.com/share_debug.php'; // 测试环境
}
var currentShare = null; var currentShare = null;
var shareList = []; var shareList = [];
...@@ -67,6 +75,51 @@ KityMinder.registerUI('menu/share/share', function(minder) { ...@@ -67,6 +75,51 @@ KityMinder.registerUI('menu/share/share', function(minder) {
} }
}); });
finder.on('mv', trackFileMove);
function trackFileMove(from, to) {
var fromPath = from.split('/');
var toPath = to.split('/');
function preCommonLength(a, b) {
var i = 0;
while((i in a) && (i in b) && a[i] == b[i]) i++;
return (i in b) ? 0 : i;
}
shareListLoaded.then(function(list) {
var userChecked = fio.user.check();
list.forEach(function(item) {
var originPath = item.path.split('/');
var clen = preCommonLength(originPath, fromPath);
if (clen) {
var movedPath = toPath.concat(originPath.slice(clen));
userChecked.then(function(user) {
$.pajax({
url: BACKEND_URL,
type: 'POST',
data: {
action: 'move',
ak: user.access_token,
id: item.id || item.shareMinder.id,
path: movedPath.join('/')
}
}).then(function() {
notice.info(minder.getLang('ui.share_sync_success', item.title));
})['catch'](function(e) {
notice.error('err_share_sync_failed', e);
});
});
item.path = movedPath.join('/');
}
});
renderShareList(list);
});
}
function loadShareFile() { function loadShareFile() {
var pattern = /(?:shareId|share_id)=(\w+)([&#]|$)/; var pattern = /(?:shareId|share_id)=(\w+)([&#]|$)/;
...@@ -424,12 +477,10 @@ KityMinder.registerUI('menu/share/share', function(minder) { ...@@ -424,12 +477,10 @@ KityMinder.registerUI('menu/share/share', function(minder) {
function renderShareList(list) { function renderShareList(list) {
var frdTime = minder.getUI('widget/friendlytimespan'); var frdTime = minder.getUI('widget/friendlytimespan');
var $list = $('<ul>')
.attr('id', 'manage-share-list')
.appendTo($manage_menu);
if (!list) return; if (!list) return;
$share_list.empty();
list.forEach(function(share) { list.forEach(function(share) {
$list.append(buildShareItem(share)); $share_list.append(buildShareItem(share));
}); });
} }
......
...@@ -71,6 +71,47 @@ html, body { ...@@ -71,6 +71,47 @@ html, body {
text-align: center; text-align: center;
font-weight: normal; font-weight: normal;
color: @ui-fore; color: @ui-fore;
vertical-align: middle;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
span {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
input {
outline: none;
font-size: 14px;
border: none;
border-radius: 2px;
box-shadow: 0 0 3px black;
padding: 3px 2px 3px 5px;
background: white;
}
&.rename-enabled{
cursor: text;
&:after {
content: ' ';
width: 20px;
height: 20px;
display: inline-block;
background: url(../images/icons.png) 1px -1110px;
vertical-align: middle;
position: relative;
top: -1px;
margin-left: 5px;
opacity: 0;
transition: opacity ease .3s;
}
}
&.rename-enabled:hover:after {
opacity: 0.6;
}
&.loading { &.loading {
&:before { &:before {
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
} }
#main-menu { #main-menu {
@left-width: 200px; @left-width: 150px;
background: white; background: white;
.dock; .dock;
......
...@@ -7,6 +7,13 @@ ...@@ -7,6 +7,13 @@
100% { transform: translate(0, 0); } 100% { transform: translate(0, 0); }
} }
@keyframes shake-left-right {
0% { transform: translate(0, 0); }
25% { transform: translate(-3px, 0); }
75% { transform: translate(3px, 0); }
100% { transform: translate(0, 0); }
}
.netdisk-finder { .netdisk-finder {
.dir.drag-enter { .dir.drag-enter {
...@@ -23,23 +30,44 @@ ...@@ -23,23 +30,44 @@
} }
} }
&.recycle-bin {
.head .control {
.button.mkdir {
display: none;
}
.button.recycle {
display: none;
}
.button.recycle-clear {
display: block;
}
}
.file-list .file-list-item.dir:after {
display: none;
}
}
.head { .head {
padding-bottom: 10px; padding-bottom: 10px;
height: 30px; height: 30px;
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
.control { .control {
float: right; float: right;
.mkdir {
}
.button { .button {
vertical-align: middle; vertical-align: middle;
font-size: 0; font-size: 0;
background: url(../images/finder.svg) no-repeat; background: url(../images/finder.svg) no-repeat;
box-sizing: border-box;
width: 30px; width: 30px;
height: 30px; height: 30px;
border-radius: 2px; border-radius: 2px;
box-sizing: border-box;
border: 1px solid transparent; border: 1px solid transparent;
&:hover {
border: 1px solid lighten(#717B94, 30%);
}
&:active {
box-shadow: inset 0 1px 3px fadeOut(#717B94, 80%);
}
&.recycle { &.recycle {
background-position: -30px 0; background-position: -30px 0;
...@@ -48,12 +76,11 @@ ...@@ -48,12 +76,11 @@
} }
} }
&:hover { &.recycle-clear {
border: 1px solid lighten(#717B94, 30%); display: none;
} background-position: -90px 0;
&:active {
box-shadow: inset 0 1px 3px fadeOut(#717B94, 80%);
} }
} }
} }
.nav { .nav {
...@@ -111,6 +138,7 @@ ...@@ -111,6 +138,7 @@
} }
.file-list { .file-list {
.dock(41px, 0, 0, 0);
margin: 0; margin: 0;
padding: 0; padding: 0;
list-style: none; list-style: none;
...@@ -124,20 +152,59 @@ ...@@ -124,20 +152,59 @@
} }
.file-list-item { .file-list-item {
font-size: 14px; font-size: 14px;
height: 20px;
line-height: 20px; line-height: 20px;
padding: 10px 20px 10px 40px; padding: 10px 20px 10px 40px;
cursor: default; cursor: default;
-webkit-user-drag: element; -webkit-user-drag: element;
-khtml-user-drag: element; -khtml-user-drag: element;
border: 1px solid transparent; border: 1px solid transparent;
.rename-button {
display: inline-block;
width: 20px;
height: 20px;
margin-left: 15px;
vertical-align: middle;
border-radius: 2px;
box-sizing: border-box;
border: 1px solid transparent;
opacity: 0;
transition: transform,opacity ease .2s;
transform: scale(0);
font-size: 0;
&:hover {
border: 1px solid lighten(#717B94, 30%);
}
&:active {
box-shadow: inset 0 1px 3px fadeOut(#717B94, 80%);
}
}
.filename {
height: 20px;
line-height: 20px;
vertical-align: middle;
}
input {
margin: 0;
outline: none;
width: 61.80%;
}
&:hover { &:hover {
/* background-color: lighten(@tab-hover, 55%); */ .rename-button {
} transition: transform,opacity ease .2s .5s;
&:active { transform: scale(1);
background-color: lighten(@tab-hover, 50%); opacity: 1;
background: url(../images/icons.png) 1px -1130px;
}
} }
&.selected { &.selected {
&:hover .rename-button {
background: url(../images/icons.png) 1px -1110px;
}
background-color: lighten(@tab-active, 20%); background-color: lighten(@tab-active, 20%);
color: white; color: white;
&.dir .icon { &.dir .icon {
...@@ -165,6 +232,14 @@ ...@@ -165,6 +232,14 @@
background: url(../images/icons.png) 0 -445px no-repeat; background: url(../images/icons.png) 0 -445px no-repeat;
} }
} }
&.renaming {
input.invalid-name {
animation: shake-left-right .3s ease;
}
.rename-button {
display: none !important;
}
}
&.dir { &.dir {
position: relative; position: relative;
.icon { .icon {
...@@ -183,16 +258,19 @@ ...@@ -183,16 +258,19 @@
top: 20px; top: 20px;
margin-top: -4px; margin-top: -4px;
} }
input {
margin: 0;
outline: none;
width: 61.80%;
}
} }
} }
} }
} }
.netdisk-open-panel .netdisk-finder {
.dock;
}
.netdisk-save-panel .netdisk-finder {
.dock(0, 0, 50px, 0);
}
// for save // for save
.netdisk-save-panel .netdisk-file-list { .netdisk-save-panel .netdisk-file-list {
bottom: 50px; bottom: 50px;
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
overflow: auto; overflow: auto;
overflow-x: hidden; overflow-x: hidden;
overflow-y: auto; overflow-y: auto;
padding-right: 10px;
&:empty:after { &:empty:after {
content: '没有分享'; content: '没有分享';
......
This diff is collapsed.
ui/theme/default/images/icons.png

20.3 KB | W: | H:

ui/theme/default/images/icons.png

20.6 KB | W: | H:

ui/theme/default/images/icons.png
ui/theme/default/images/icons.png
ui/theme/default/images/icons.png
ui/theme/default/images/icons.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -9,22 +9,111 @@ ...@@ -9,22 +9,111 @@
KityMinder.registerUI('topbar/title', function(minder) { KityMinder.registerUI('topbar/title', function(minder) {
var $title = $('<h1>').appendTo('#panel'); var $title = $('<h1>').appendTo('#panel');
var $doc = minder.getUI('doc');
var finder = minder.getUI('widget/netdiskfinder');
var notice = minder.getUI('widget/notice');
var renameEnabled = false;
var renameMode = false;
var _title = minder.getLang('ui.untitleddoc'); $doc.on('docchange', update);
var _saved = false;
$title.on('click', rename);
function rename() {
if (!renameEnabled || renameMode) return;
var doc = $doc.current();
var $input = $('<input>').width($title.find('.title-content').width());
var oldFilename = doc.title;
var oldPath = doc.path;
$input.val(oldFilename);
setTimeout(function() {
$input[0].select();
});
$title.addClass('rename-mode');
$title.empty();
$title.append($input);
renameMode = true;
$input.on('keydown', function(e) {
if (e.keyCode == 13) confirm();
else if (e.keyCode == 27) {
cancel();
e.stopPropagation();
}
}).on('blur', cancel);
function exit() {
setTimeout(function() {
renameMode = false;
});
}
function cancel() {
update();
exit();
}
function confirm() {
var newFilename = $input.val();
var oldFilenameInfo = fio.file.anlysisPath(oldFilename);
var newFilenameInfo = fio.file.anlysisPath(newFilename);
if (!newFilenameInfo.name.length) return cancel();
newFilename = newFilenameInfo.name + oldFilenameInfo.extension;
var newPath = fio.file.anlysisPath(oldPath).parentPath + newFilename;
if (newPath == oldPath) return cancel();
$title.addClass('loading');
fio.file.move({
path: oldPath,
newPath: newPath
}).then(function() {
doc.path = newPath;
doc.title = newFilename;
finder.fire('mv', oldPath, newPath);
notice.info(minder.getLang('ui.rename_success', newFilename));
})['catch'](function(e) {
notice.error('err_rename', e);
}).then(function() {
$title.removeClass('loading');
update();
exit();
});
}
}
function enableRename(enabled) {
renameEnabled = enabled;
if (enabled) $title.addClass('rename-enabled');
else $title.removeClass('rename-enabled');
}
function update() { function update() {
var doc = $doc.current();
function setTitle(title) { function setTitle(title) {
$title.text(title); title = title || minder.getLang('ui.untitleddoc');
document.title = title + ' - 百度脑图'; $title.empty().append('<span class="title-content">' + title + '</span>');
document.title = title ? title + ' - 百度脑图' : '百度脑图';
} }
if (_saved) { if (doc.saved) {
setTitle(_title); setTitle(doc.title);
} else { } else {
setTitle('* ' + _title); setTitle('* ' + doc.title);
} }
enableRename(doc.source == 'netdisk' && doc.saved);
} }
update(); update();
...@@ -32,23 +121,8 @@ KityMinder.registerUI('topbar/title', function(minder) { ...@@ -32,23 +121,8 @@ KityMinder.registerUI('topbar/title', function(minder) {
return { return {
$title: $title, $title: $title,
setTitle: function(title, saved) {
_title = title;
return this.setSaved(saved);
},
getTitle: function() { getTitle: function() {
return _title; return $doc.current().title;
},
setSaved: function(saved) {
_saved = saved !== false;
update();
return this;
} }
}; };
}); });
\ No newline at end of file
...@@ -70,6 +70,7 @@ KityMinder.registerUI('widget/locallist', function() { ...@@ -70,6 +70,7 @@ KityMinder.registerUI('widget/locallist', function() {
function forEach(callback) { function forEach(callback) {
list.forEach(callback); list.forEach(callback);
save();
} }
load.call(this); load.call(this);
......
This diff is collapsed.
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