Commit feb0bf6d authored by techird's avatar techird

add package import

parent 3593ebd7
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<title>百度脑图 - 便捷的思维导图工具</title> <title>百度脑图 - 便捷的思维导图工具</title>
<script src="import.js" charset="utf-8"></script> <script src="import.js?pack=edit" charset="utf-8"></script>
<script src="kityminder.config.js" charset="utf-8"></script> <script src="kityminder.config.js" charset="utf-8"></script>
<script src="lang/zh-cn/zh-cn.js" charset="utf-8"></script> <script src="lang/zh-cn/zh-cn.js" charset="utf-8"></script>
...@@ -83,8 +83,8 @@ ...@@ -83,8 +83,8 @@
/* jshint browser:true */ /* jshint browser:true */
$(function() { $(function() {
/* 依赖库初始化 */ /* 依赖库初始化 */
zip.inflateJSPath = 'lib/inflate.js'; zip.inflateJSPath = 'lib/inflate.js';
}); });
// create km instance // create km instance
...@@ -105,18 +105,6 @@ $(function() { ...@@ -105,18 +105,6 @@ $(function() {
} }
}); });
km.on('unziperror', function(ev) {
window.alert('文件解析错误,文件可能已损坏!');
});
km.on('parseerror', function(ev) {
window.alert('文件解析错误,文件可能已损坏!');
});
km.on('unknownprotocal', function(ev) {
window.alert('不支持的文件格式!');
});
</script> </script>
<!--社会分享代码--> <!--社会分享代码-->
......
This diff is collapsed.
...@@ -20,34 +20,42 @@ ...@@ -20,34 +20,42 @@
/* 核心代码 */ /* 核心代码 */
'src/core/kityminder.js', 'src/core/kityminder.js',
'src/core/utils.js', 'src/core/utils.js',
'src/core/browser.js',
'src/core/minder.js',
'src/core/option.js',
'src/core/event.js',
'src/core/status.js',
'src/core/paper.js',
'src/core/readonly.js',
'src/core/command.js', 'src/core/command.js',
'src/core/node.js', 'src/core/node.js',
'src/core/module.js', 'src/core/module.js',
'src/core/event.js', 'src/core/data.js',
'src/core/minder.js', 'src/core/compatibility.js',
'src/core/minder.data.compatibility.js',
'src/core/minder.data.js',
'src/core/minder.event.js',
'src/core/minder.module.js',
'src/core/minder.command.js',
'src/core/minder.node.js',
'src/core/minder.select.js',
'src/core/keymap.js',
'src/core/minder.lang.js',
'src/core/minder.defaultoptions.js',
'src/core/minder.preference.js',
'src/core/browser.js',
'src/core/layout.js',
'src/core/connect.js',
'src/core/render.js', 'src/core/render.js',
'src/core/connect.js',
'src/core/theme.js', 'src/core/theme.js',
'src/core/layout.js',
'src/core/template.js', 'src/core/template.js',
'src/core/select.js',
'src/core/lang.js',
'src/core/defaultoptions.js',
'src/core/preference.js',
'src/core/keymap.js',
'src/core/key.js',
'src/core/contextmenu.js',
/* 布局 */ /* 布局 */
'src/layout/default.js', 'src/layout/mind.js',
'src/layout/default.connect.js',
'src/layout/bottom.js',
'src/layout/filetree.js', 'src/layout/filetree.js',
'src/layout/btree.js',
/* 连线 */
'src/connect/bezier.js',
'src/connect/poly.js',
'src/connect/arc.js',
'src/connect/under.js',
'src/connect/l.js',
/* 皮肤 */ /* 皮肤 */
'src/theme/default.js', 'src/theme/default.js',
...@@ -55,7 +63,10 @@ ...@@ -55,7 +63,10 @@
'src/theme/fresh.js', 'src/theme/fresh.js',
/* 模板 */ /* 模板 */
'src/template/default.js',
'src/template/structure.js', 'src/template/structure.js',
'src/template/filetree.js',
'src/template/right.js',
/* 模块 */ /* 模块 */
'src/module/node.js', 'src/module/node.js',
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
* 开发版本的文件导入 * 开发版本的文件导入
*/ */
(function() { (function() {
/* 可能的文件路径,已按照依赖关系排序 */
var paths = [ var paths = [
/* 依赖库 */ /* 依赖库 */
...@@ -17,28 +19,30 @@ ...@@ -17,28 +19,30 @@
/* 核心代码 */ /* 核心代码 */
'src/core/kityminder.js', 'src/core/kityminder.js',
'src/core/utils.js', 'src/core/utils.js',
'src/core/browser.js',
'src/core/minder.js',
'src/core/option.js',
'src/core/event.js',
'src/core/status.js',
'src/core/paper.js',
'src/core/readonly.js',
'src/core/command.js', 'src/core/command.js',
'src/core/node.js', 'src/core/node.js',
'src/core/module.js', 'src/core/module.js',
'src/core/event.js', 'src/core/data.js',
'src/core/minder.js', 'src/core/compatibility.js',
'src/core/minder.data.compatibility.js',
'src/core/minder.data.js',
'src/core/minder.event.js',
'src/core/minder.module.js',
'src/core/minder.command.js',
'src/core/minder.node.js',
'src/core/minder.select.js',
'src/core/keymap.js',
'src/core/minder.lang.js',
'src/core/minder.defaultoptions.js',
'src/core/minder.preference.js',
'src/core/browser.js',
'src/core/layout.js',
'src/core/connect.js',
'src/core/render.js', 'src/core/render.js',
'src/core/connect.js',
'src/core/theme.js', 'src/core/theme.js',
'src/core/layout.js',
'src/core/template.js', 'src/core/template.js',
'src/core/select.js',
'src/core/lang.js',
'src/core/defaultoptions.js',
'src/core/preference.js',
'src/core/keymap.js',
'src/core/key.js',
'src/core/contextmenu.js',
/* 布局 */ /* 布局 */
'src/layout/default.js', 'src/layout/default.js',
......
...@@ -61,6 +61,12 @@ KityMinder.LANG['zh-cn'] = { ...@@ -61,6 +61,12 @@ KityMinder.LANG['zh-cn'] = {
'view': '视图' 'view': '视图'
}, },
'quickvisit': {
'new': '新建',
'save': '保存',
'share': '分享'
},
'menu': { 'menu': {
'mainmenutext': '百度脑图', // 主菜单按钮文本 'mainmenutext': '百度脑图', // 主菜单按钮文本
...@@ -69,8 +75,8 @@ KityMinder.LANG['zh-cn'] = { ...@@ -69,8 +75,8 @@ KityMinder.LANG['zh-cn'] = {
'opentab': '打开', 'opentab': '打开',
'savetab': '保存', 'savetab': '保存',
'sharetab': '分享', 'sharetab': '分享',
'preferencetab': '设置',
'helptab': '帮助', 'helptab': '帮助',
'settingtab': '设置',
'recenttab': '最近使用', 'recenttab': '最近使用',
'netdisktab': '百度云存储', 'netdisktab': '百度云存储',
'localtab': '本地文件', 'localtab': '本地文件',
...@@ -84,7 +90,8 @@ KityMinder.LANG['zh-cn'] = { ...@@ -84,7 +90,8 @@ KityMinder.LANG['zh-cn'] = {
'saveheader': '保存到', 'saveheader': '保存到',
'draftheader': '草稿箱', 'draftheader': '草稿箱',
'shareheader': '分享我的脑图', 'shareheader': '分享我的脑图',
'downloadheader': '导出到指定格式' 'downloadheader': '导出到指定格式',
'preferenceheader': '偏好设置'
}, },
'mydocument': '我的文档', 'mydocument': '我的文档',
...@@ -198,7 +205,9 @@ KityMinder.LANG['zh-cn'] = { ...@@ -198,7 +205,9 @@ KityMinder.LANG['zh-cn'] = {
'longago': '很久之前', 'longago': '很久之前',
'redirect': '您正在打开连接 {0},百度脑图不能保证连接的安全性,是否要继续?', 'redirect': '您正在打开连接 {0},百度脑图不能保证连接的安全性,是否要继续?',
'navigator': '导航器' 'navigator': '导航器',
'unsavedcontent': '当前文件还没有保存到网盘:\n\n{0}\n\n确定要继续操作么?(未保存的数据会缓存在草稿箱)'
}, },
'popupcolor': { 'popupcolor': {
'clearColor': '清空颜色', 'clearColor': '清空颜色',
......
...@@ -99,7 +99,7 @@ kity.extendClass(Minder, { ...@@ -99,7 +99,7 @@ kity.extendClass(Minder, {
if (cmd.isSelectionChanged()) { if (cmd.isSelectionChanged()) {
this._firePharse(new MinderEvent('selectionchange')); this._firePharse(new MinderEvent('selectionchange'));
} }
this._firePharse(new MinderEvent('interactchange')); this._interactChange();
} }
this._hasEnterExecCommand = false; this._hasEnterExecCommand = false;
} else { } else {
...@@ -110,7 +110,7 @@ kity.extendClass(Minder, { ...@@ -110,7 +110,7 @@ kity.extendClass(Minder, {
this._firePharse(new MinderEvent('selectionchange')); this._firePharse(new MinderEvent('selectionchange'));
} }
this._firePharse(new MinderEvent('interactchange')); this._interactChange();
} }
} }
......
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
Minder.registerInit(function() {
this._initContextMenu();
});
kity.extendClass(Minder, { kity.extendClass(Minder, {
_initContextMenu: function() { _initContextMenu: function() {
this.contextmenus = []; this.contextmenus = [];
......
...@@ -11,6 +11,10 @@ var DEFAULT_TEXT = { ...@@ -11,6 +11,10 @@ var DEFAULT_TEXT = {
'sub': 'topic' 'sub': 'topic'
}; };
Minder.registerInit(function() {
this._initProtocols();
});
// 导入导出 // 导入导出
kity.extendClass(Minder, { kity.extendClass(Minder, {
...@@ -100,9 +104,7 @@ kity.extendClass(Minder, { ...@@ -100,9 +104,7 @@ kity.extendClass(Minder, {
this._firePharse({ this._firePharse({
type: 'contentchange' type: 'contentchange'
}); });
this._firePharse({ this._interactChange();
type: 'interactchange'
});
}, },
exportData: function(protocolName) { exportData: function(protocolName) {
......
...@@ -55,6 +55,10 @@ var MinderEvent = kity.createClass('MindEvent', { ...@@ -55,6 +55,10 @@ var MinderEvent = kity.createClass('MindEvent', {
} }
}); });
Minder.registerInit(function() {
this._initEvents();
});
// 事件机制 // 事件机制
kity.extendClass(Minder, { kity.extendClass(Minder, {
_initEvents: function() { _initEvents: function() {
...@@ -109,8 +113,8 @@ kity.extendClass(Minder, { ...@@ -109,8 +113,8 @@ kity.extendClass(Minder, {
preEvent = new MinderEvent('pre' + e.type, e, true); preEvent = new MinderEvent('pre' + e.type, e, true);
executeEvent = new MinderEvent(e.type, e, true); executeEvent = new MinderEvent(e.type, e, true);
this._fire(preEvent) || if (this._fire(preEvent) ||
this._fire(executeEvent) || this._fire(executeEvent))
this._fire(new MinderEvent('after' + e.type, e, false)); this._fire(new MinderEvent('after' + e.type, e, false));
if (~'mousedown mouseup keydown keyup'.indexOf(e.type)) { if (~'mousedown mouseup keydown keyup'.indexOf(e.type)) {
...@@ -120,15 +124,16 @@ kity.extendClass(Minder, { ...@@ -120,15 +124,16 @@ kity.extendClass(Minder, {
_interactChange: function(e) { _interactChange: function(e) {
var minder = this; var minder = this;
clearTimeout(this._interactTimeout); var trigger = function trigger() {
this._interactTimeout = setTimeout(function() {
var stoped = minder._fire(new MinderEvent('beforeinteractchange')); var stoped = minder._fire(new MinderEvent('beforeinteractchange'));
if (stoped) { if (stoped) {
return; return;
} }
minder._fire(new MinderEvent('preinteractchange')); minder._fire(new MinderEvent('preinteractchange'));
minder._fire(new MinderEvent('interactchange')); minder._fire(new MinderEvent('interactchange'));
}, 20); };
this._interactTimeout = setTimeout(trigger, 100);
}, },
_listen: function(type, callback) { _listen: function(type, callback) {
var callbacks = this._eventCallbacks[type] || (this._eventCallbacks[type] = []); var callbacks = this._eventCallbacks[type] || (this._eventCallbacks[type] = []);
......
...@@ -61,6 +61,10 @@ kity.extendClass(MinderEvent, { ...@@ -61,6 +61,10 @@ kity.extendClass(MinderEvent, {
} }
}); });
Minder.registerInit(function() {
this._initShortcutKey();
});
kity.extendClass(Minder, { kity.extendClass(Minder, {
_initShortcutKey: function() { _initShortcutKey: function() {
......
...@@ -142,6 +142,14 @@ kity.extendClass(MinderNode, { ...@@ -142,6 +142,14 @@ kity.extendClass(MinderNode, {
return this._vertexOut || new kity.Point(); return this._vertexOut || new kity.Point();
}, },
getLayoutVertexIn: function() {
return this.getGlobalLayoutTransform().transformPoint(this.getVertexIn());
},
getLayoutVertexOut: function() {
return this.getGlobalLayoutTransform().transformPoint(this.getVertexOut());
},
setLayoutVectorIn: function(v) { setLayoutVectorIn: function(v) {
this._layoutVectorIn = v; this._layoutVectorIn = v;
return this; return this;
...@@ -206,14 +214,6 @@ kity.extendClass(MinderNode, { ...@@ -206,14 +214,6 @@ kity.extendClass(MinderNode, {
return this.setLayoutOffset(null); return this.setLayoutOffset(null);
}, },
getLayoutVertexIn: function() {
return this.getGlobalLayoutTransform().transformPoint(this.getVertexIn());
},
getLayoutVertexOut: function() {
return this.getGlobalLayoutTransform().transformPoint(this.getVertexOut());
},
getLayoutRoot: function() { getLayoutRoot: function() {
if (this.isLayoutRoot()) { if (this.isLayoutRoot()) {
return this; return this;
...@@ -226,6 +226,10 @@ kity.extendClass(MinderNode, { ...@@ -226,6 +226,10 @@ kity.extendClass(MinderNode, {
} }
}); });
Minder.registerInit(function(options) {
this.refresh();
});
kity.extendClass(Minder, { kity.extendClass(Minder, {
layout: function(duration) { layout: function(duration) {
...@@ -264,7 +268,7 @@ kity.extendClass(Minder, { ...@@ -264,7 +268,7 @@ kity.extendClass(Minder, {
refresh: function(duration) { refresh: function(duration) {
this.getRoot().renderTree(); this.getRoot().renderTree();
this.layout(duration).fire('contentchange').fire('interactchange'); this.layout(duration).fire('contentchange')._interactChange();
return this; return this;
}, },
...@@ -319,7 +323,7 @@ kity.extendClass(Minder, { ...@@ -319,7 +323,7 @@ kity.extendClass(Minder, {
// 如果要求以动画形式来更新,创建动画 // 如果要求以动画形式来更新,创建动画
if (duration) { if (duration) {
node._layoutTimeline = new kity.Animator(lastMatrix, matrix, applyMatrix) node._layoutTimeline = new kity.Animator(lastMatrix, matrix, applyMatrix)
.start(node, duration + 300, 'ease') .start(node, duration, 'ease')
.on('finish', function() { .on('finish', function() {
//可能性能低的时候会丢帧,手动添加一帧 //可能性能低的时候会丢帧,手动添加一帧
kity.Timeline.requestFrame(function() { kity.Timeline.requestFrame(function() {
...@@ -499,7 +503,7 @@ var Layout = kity.createClass('Layout', { ...@@ -499,7 +503,7 @@ var Layout = kity.createClass('Layout', {
treeBox = node.getContentBox(); treeBox = node.getContentBox();
if (node.children.length) { if (node.isExpanded() && node.children.length) {
treeBox = g.mergeBox(treeBox, this.getTreeBox(node.children)); treeBox = g.mergeBox(treeBox, this.getTreeBox(node.children));
} }
......
/* jshint -W079 */
var Minder = KityMinder.Minder = kity.createClass('KityMinder', { var Minder = KityMinder.Minder = kity.createClass('KityMinder', {
constructor: function(options) { constructor: function(options) {
this._options = Utils.extend(window.KITYMINDER_CONFIG || {}, options); this._options = Utils.extend(window.KITYMINDER_CONFIG || {}, options);
this.setDefaultOptions(KM.defaultOptions); // @see option.js var initQueue = Minder._initFnQueue.slice();
this._initEvents(options); // @see event.js // @see option.js
this._initStatus(options); // @see status.js // @see event.js
this._initPaper(options); // @see paper.js // @see status.js
this._initSelection(options); // @see select.js // @see paper.js
this._initShortcutKey(options); // @see key.js // @see select.js
this._initContextMenu(options); // @see contextmenu.js // @see key.js
this._initModules(options); // @see module.js // @see contextmenu.js
this._initProtocols(options); // @see data.js // @see module.js
// @see data.js
if (this.getOptions('readOnly') === true) { // @see readonly.js
this.setDisabled(); // @see readonly.js // @see layout.js
} // @see theme.js
this.refresh(); // @see layout.js while (initQueue.length) initQueue.shift().call(this, options);
this.setTheme(); // @see theme.js
this.fire('ready'); this.fire('ready');
} }
}); });
\ No newline at end of file /* jshint +W079 */
Minder._initFnQueue = [];
Minder.registerInit = function(fn) {
Minder._initFnQueue.push(fn);
};
\ No newline at end of file
...@@ -13,6 +13,10 @@ ...@@ -13,6 +13,10 @@
}; };
} )(); } )();
Minder.registerInit(function() {
this._initModules();
});
// 模块声明周期维护 // 模块声明周期维护
kity.extendClass(Minder, { kity.extendClass(Minder, {
_initModules: function() { _initModules: function() {
......
...@@ -36,4 +36,9 @@ kity.extendClass(Minder, { ...@@ -36,4 +36,9 @@ kity.extendClass(Minder, {
setOptions: function(key, val) { setOptions: function(key, val) {
this.setPreferences(key, val); this.setPreferences(key, val);
} }
});
Minder.registerInit(function(option) {
this.setDefaultOptions(KM.defaultOptions);
}); });
\ No newline at end of file
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
Minder.registerInit(function() {
this._initPaper();
});
kity.extendClass(Minder, { kity.extendClass(Minder, {
_initPaper: function() { _initPaper: function() {
......
...@@ -41,7 +41,7 @@ kity.extendClass( Minder, function(){ ...@@ -41,7 +41,7 @@ kity.extendClass( Minder, function(){
} )(); } )();
return { return {
setPreferences:function(key,value){ setPreferences: function(key,value){
var obj = {}; var obj = {};
if ( Utils.isString( key ) ) { if ( Utils.isString( key ) ) {
obj[ key ] = value; obj[ key ] = value;
...@@ -57,15 +57,15 @@ kity.extendClass( Minder, function(){ ...@@ -57,15 +57,15 @@ kity.extendClass( Minder, function(){
} }
LocalStorage.saveLocalData(ROOTKEY,JSON.stringify(data)); LocalStorage.saveLocalData(ROOTKEY,JSON.stringify(data));
}, },
getPreferences:function(key){ getPreferences: function(key){
var data = LocalStorage.getLocalData(ROOTKEY); var data = LocalStorage.getLocalData(ROOTKEY);
if(data){ if(data){
data = JSON.parse(data); data = JSON.parse(data);
return key ? data[key] : data; return key ? data[key] : data;
} }
return null; return {};
}, },
resetPreferences:function(pres){ resetPreferences: function(pres){
var str = pres ? JSON.stringify(pres) : ''; var str = pres ? JSON.stringify(pres) : '';
LocalStorage.saveLocalData(str); LocalStorage.saveLocalData(str);
} }
......
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
Minder.registerInit(function(options) {
if (options.readOnly) {
this.setDisabled();
}
});
kity.extendClass(Minder, { kity.extendClass(Minder, {
disable: function() { disable: function() {
...@@ -28,7 +33,7 @@ kity.extendClass(Minder, { ...@@ -28,7 +33,7 @@ kity.extendClass(Minder, {
return null; return null;
}; };
this.setStatus('readonly'); this.setStatus('readonly');
me.fire('interactchange'); me._interactChange();
}, },
enable: function() { enable: function() {
...@@ -45,6 +50,6 @@ kity.extendClass(Minder, { ...@@ -45,6 +50,6 @@ kity.extendClass(Minder, {
this.rollbackStatus(); this.rollbackStatus();
me.fire('interactchange'); me._interactChange();
} }
}); });
\ No newline at end of file
Minder.registerInit(function() {
this._initSelection();
});
// 选区管理 // 选区管理
kity.extendClass(Minder, { kity.extendClass(Minder, {
_initSelection: function() { _initSelection: function() {
...@@ -22,7 +27,10 @@ kity.extendClass(Minder, { ...@@ -22,7 +27,10 @@ kity.extendClass(Minder, {
} }
}); });
if (changed.length) this.fire('interactchange'); if (changed.length) {
this._interactChange();
this.fire('selectionchange');
}
while (i < changed.length) changed[i++].render(); while (i < changed.length) changed[i++].render();
}, },
getSelectedNodes: function() { getSelectedNodes: function() {
......
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
Minder.registerInit(function() {
this._initStatus();
});
kity.extendClass(Minder, { kity.extendClass(Minder, {
_initStatus: function() { _initStatus: function() {
......
...@@ -135,4 +135,8 @@ KityMinder.registerModule('Theme', { ...@@ -135,4 +135,8 @@ KityMinder.registerModule('Theme', {
} }
}) })
} }
});
Minder.registerInit(function() {
this.setTheme();
}); });
\ No newline at end of file
...@@ -76,24 +76,26 @@ KityMinder.registerModule('Expand', function() { ...@@ -76,24 +76,26 @@ KityMinder.registerModule('Expand', function() {
if (!changed) return; if (!changed) return;
var vo = node.getVertexOut();
if (state == STATE_EXPAND) { if (state == STATE_EXPAND) {
var m = node.getGlobalLayoutTransform(); var m = node.getGlobalLayoutTransform().clone().translate(vo.x, vo.y);
node.traverse(function(child) { node.traverse(function(child) {
child.setGlobalLayoutTransform(m); child.setGlobalLayoutTransform(m);
child.getRenderContainer().fadeIn(); child.getRenderContainer().setOpacity(0).fadeIn();
}, true); }, true);
node.renderTree().getMinder().layout(30); node.renderTree().getMinder().layout(300);
} else { } else {
node.traverse(function(child) { node.traverse(function(child) {
child.setLayoutTransform(null); child.setLayoutTransform(child.parent == node ? new kity.Matrix().translate(vo.x, vo.y) : null);
child.getRenderContainer().fadeOut(); child.getRenderContainer().fadeOut(100);
}, true); }, true);
node.getMinder().applyLayoutResult(node, 30).then(function() { node.getMinder().applyLayoutResult(node, 150).then(function() {
node.renderTree(); node.renderTree().getMinder().layout(150);
}); });
} }
......
...@@ -30,7 +30,6 @@ KityMinder.registerModule('KeyboardModule', function() { ...@@ -30,7 +30,6 @@ KityMinder.registerModule('KeyboardModule', function() {
} }
} }
// 这是金泉的点子,赞! // 这是金泉的点子,赞!
// 求两个不相交矩形的最近距离 // 求两个不相交矩形的最近距离
function getCoefedDistance(box1, box2) { function getCoefedDistance(box1, box2) {
...@@ -114,7 +113,6 @@ KityMinder.registerModule('KeyboardModule', function() { ...@@ -114,7 +113,6 @@ KityMinder.registerModule('KeyboardModule', function() {
}; };
} }
function navigateTo(km, direction) { function navigateTo(km, direction) {
var referNode = km.getSelectedNode(); var referNode = km.getSelectedNode();
if (!referNode) { if (!referNode) {
...@@ -127,21 +125,36 @@ KityMinder.registerModule('KeyboardModule', function() { ...@@ -127,21 +125,36 @@ KityMinder.registerModule('KeyboardModule', function() {
km.select(nextNode, true); km.select(nextNode, true);
} }
} }
var NavigateToParentCommand = kity.createClass({
base: Command,
execute: function(km) {
var node = km.getSelectedNode();
if (node && node.parent) {
km.select(node.parent, true);
}
this.setContentChanged(false);
},
queryState: function(km) {
return km.getSelectedNode() ? 0 : -1;
}
});
// 稀释用 // 稀释用
var lastFrame; var lastFrame;
return { return {
'commands': {
'navparent': NavigateToParentCommand
},
'commandShortcutKeys': {
'navparent': 'shift+tab'
},
'events': { 'events': {
'layoutallfinish': function() { 'layoutallfinish': function() {
var root = this.getRoot(); var root = this.getRoot();
function build() { buildPositionNetwork(root);
buildPositionNetwork(root);
}
kity.Timeline.releaseFrame(lastFrame);
lastFrame = kity.Timeline.requestFrame(build);
},
'inputready.beforekeydown': function(e) {
var keyEvent = e.originEvent;
if (keyEvent.shiftKey && keyEvent.keyCode == KityMinder.keymap.Tab) e.preventDefault();
}, },
'normal.keydown': function(e) { 'normal.keydown': function(e) {
var minder = this; var minder = this;
......
...@@ -5,7 +5,7 @@ var AppendChildCommand = kity.createClass('AppendChildCommand', { ...@@ -5,7 +5,7 @@ var AppendChildCommand = kity.createClass('AppendChildCommand', {
if (!parent) { if (!parent) {
return null; return null;
} }
text = text || km.getLang(parent.isRoot() ? 'maintopic' : 'topic'); text = text || km.getLang('topic');
parent.expand(); parent.expand();
var node = km.createNode(text, parent); var node = km.createNode(text, parent);
km.select(node, true); km.select(node, true);
...@@ -26,7 +26,7 @@ var AppendSiblingCommand = kity.createClass('AppendSiblingCommand', { ...@@ -26,7 +26,7 @@ var AppendSiblingCommand = kity.createClass('AppendSiblingCommand', {
if (!parent) { if (!parent) {
return km.execCommand('AppendChildNode', text); return km.execCommand('AppendChildNode', text);
} }
text = text || km.getLang(parent.isRoot() ? 'maintopic' : 'topic'); text = text || km.getLang('topic');
var node = km.createNode(text, parent, sibling.getIndex() + 1); var node = km.createNode(text, parent, sibling.getIndex() + 1);
km.select(node, true); km.select(node, true);
node.render(); node.render();
......
KityMinder.registerModule('PriorityModule', function() { KityMinder.registerModule('PriorityModule', function() {
var minder = this; var minder = this;
// 进度图标使用的颜色 // Designed by Akikonata
var PRIORITY_COLORS = ['', '#A92E24', '#29A6BD', // [MASK, BACK]
'#1E8D54', '#eb6100', '#876DDA', '#828282', var PRIORITY_COLORS = [null,
'#828282', '#828282', '#828282' ['#FF1200', '#840023'], // 1 - red
]; ['#0074FF', '#01467F'], // 2 - blue
['#00AF00', '#006300'], // 3 - green
['#FF962E', '#B25000'], // 4 - orange
['#A464FF', '#4720C4'], // 5 - purple
['#A3A3A3', '#515151'], // 6,7,8,9 - gray
['#A3A3A3', '#515151'],
['#A3A3A3', '#515151'],
['#A3A3A3', '#515151'],
]; // hue from 1 to 5
var BACK_PATH = 'M0,13c0,3.866,3.134,7,7,7h6c3.866,0,7-3.134,7-7V7H0V13z';
var MASK_PATH = 'M20,10c0,3.866-3.134,7-7,7H7c-3.866,0-7-3.134-7-7V7c0-3.866,3.134-7,7-7h6c3.866,0,7,3.134,7,7V10z';
var PRIORITY_DATA = 'priority'; var PRIORITY_DATA = 'priority';
// 进度图标的图形 // 进度图标的图形
...@@ -24,34 +36,39 @@ KityMinder.registerModule('PriorityModule', function() { ...@@ -24,34 +36,39 @@ KityMinder.registerModule('PriorityModule', function() {
}, },
create: function() { create: function() {
var bg, number; var white, back, mask, number; // 4 layer
bg = new kity.Rect() white = new kity.Path().setPathData(MASK_PATH).fill('white');
.setRadius(3) back = new kity.Path().setPathData(BACK_PATH).setTranslate(0.5, 0.5);
.setPosition(0.5, 0.5) mask = new kity.Path().setPathData(MASK_PATH).setOpacity(0.8).setTranslate(0.5, 0.5);
.setSize(this.width, this.height);
number = new kity.Text() number = new kity.Text()
.setX(this.width / 2 + 0.5).setY(this.height / 2 - 0.5) .setX(this.width / 2 - 0.5).setY(this.height / 2 - 1.5)
.setTextAnchor('middle') .setTextAnchor('middle')
.setVerticalAlign('middle') .setVerticalAlign('middle')
.setFontSize(12) .setFontItalic(true)
.setFontSize(14)
.fill('white'); .fill('white');
number.mark = 'hello';
this.addShapes([bg, number]); this.addShapes([back, mask, number]);
this.bg = bg; this.mask = mask;
this.back = back;
this.number = number; this.number = number;
}, },
setValue: function(value) { setValue: function(value) {
var bg = this.bg, var back = this.back,
mask = this.mask,
number = this.number; number = this.number;
if (PRIORITY_COLORS[value]) { var color = PRIORITY_COLORS[value];
bg.fill(PRIORITY_COLORS[value]);
number.setContent(value); if (color) {
back.fill(color[1]);
mask.fill(color[0]);
} }
number.setContent(value);
} }
}); });
......
...@@ -3,6 +3,23 @@ KityMinder.registerModule('ProgressModule', function() { ...@@ -3,6 +3,23 @@ KityMinder.registerModule('ProgressModule', function() {
var PROGRESS_DATA = 'progress'; var PROGRESS_DATA = 'progress';
// Designed by Akikonata
var BG_COLOR = '#FFED83';
var PIE_COLOR = '#43BC00';
var SHADOW_PATH = 'M10,3c4.418,0,8,3.582,8,8h1c0-5.523-3.477-10-9-10S1,5.477,1,11h1C2,6.582,5.582,3,10,3z';
var SHADOW_COLOR = '#8E8E8E';
var FRAME_PATH = 'M10,0C4.477,0,0,4.477,0,10c0,5.523,4.477,10,10,10s10-4.477,10-10C20,4.477,15.523,0,10,0zM10,18c-4.418,0-8-3.582-8-8s3.582-8,8-8s8,3.582,8,8S14.418,18,10,18z';
var FRAME_GRAD = new kity.LinearGradientBrush().pipe(function(g) {
g.setStartPosition(0, 0);
g.setEndPosition(0, 1);
g.addStop(0, '#fff');
g.addStop(1, '#ccc');
});
var CHECK_PATH = 'M15.812,7.896l-6.75,6.75l-4.5-4.5L6.25,8.459l2.812,2.803l5.062-5.053L15.812,7.896z';
var CHECK_COLOR = '#EEE';
minder.getPaper().addResource(FRAME_GRAD);
// 进度图标的图形 // 进度图标的图形
var ProgressIcon = kity.createClass('ProgressIcon', { var ProgressIcon = kity.createClass('ProgressIcon', {
base: kity.Group, base: kity.Group,
...@@ -13,6 +30,7 @@ KityMinder.registerModule('ProgressModule', function() { ...@@ -13,6 +30,7 @@ KityMinder.registerModule('ProgressModule', function() {
this.create(); this.create();
this.setValue(value); this.setValue(value);
this.setId(KityMinder.uuid('node_progress')); this.setId(KityMinder.uuid('node_progress'));
this.translate(0.5, 0.5);
}, },
setSize: function(size) { setSize: function(size) {
...@@ -21,30 +39,36 @@ KityMinder.registerModule('ProgressModule', function() { ...@@ -21,30 +39,36 @@ KityMinder.registerModule('ProgressModule', function() {
create: function() { create: function() {
var circle = new kity.Circle(8) var bg, pie, shadow, frame, check;
.stroke('#29A6BD', 2)
.fill('white'); bg = new kity.Circle(9)
.fill(BG_COLOR);
pie = new kity.Pie(9, 0)
.fill(PIE_COLOR);
shadow = new kity.Path()
.setPathData(SHADOW_PATH)
.setTranslate(-10, -10)
.fill(SHADOW_COLOR);
var pie = new kity.Pie(6, 0, -90) frame = new kity.Path()
.fill('#29A6BD'); .setTranslate(-10, -10)
.setPathData(FRAME_PATH)
.fill(FRAME_GRAD);
var check = new kity.Path() check = new kity.Path()
.getDrawer() .setTranslate(-10, -10)
.moveTo(-3, -1) .setPathData(CHECK_PATH)
.lineTo(-1, 2) .fill(CHECK_COLOR);
.lineTo(3, -3)
.getPath()
.stroke('white', 2)
.setVisible(false);
this.addShapes([circle, pie, check]); this.addShapes([bg, pie, shadow, check, frame]);
this.circle = circle;
this.pie = pie; this.pie = pie;
this.check = check; this.check = check;
}, },
setValue: function(value) { setValue: function(value) {
this.pie.setAngle(360 * (value - 1) / 8); this.pie.setAngle(-360 * (value - 1) / 8);
this.check.setVisible(value == 9); this.check.setVisible(value == 9);
} }
}); });
......
...@@ -33,7 +33,9 @@ var ViewDragger = kity.createClass("ViewDragger", { ...@@ -33,7 +33,9 @@ var ViewDragger = kity.createClass("ViewDragger", {
if (duration) { if (duration) {
var dragger = this; var dragger = this;
this._minder.getRenderContainer().animate(new kity.Animator( if (this._moveTimeline) this._moveTimeline.stop();
this._moveTimeline = this._minder.getRenderContainer().animate(new kity.Animator(
this.getMovement(), this.getMovement(),
position, position,
function(target, value) { function(target, value) {
...@@ -41,6 +43,10 @@ var ViewDragger = kity.createClass("ViewDragger", { ...@@ -41,6 +43,10 @@ var ViewDragger = kity.createClass("ViewDragger", {
} }
), duration, 'easeOutCubic'); ), duration, 'easeOutCubic');
this._moveTimeline.on('finish', function() {
dragger._moveTimeline = null;
});
return this; return this;
} }
...@@ -133,6 +139,9 @@ var ViewDragger = kity.createClass("ViewDragger", { ...@@ -133,6 +139,9 @@ var ViewDragger = kity.createClass("ViewDragger", {
.on('mouseup touchend', dragEnd); .on('mouseup touchend', dragEnd);
window.addEventListener('mouseup', dragEnd); window.addEventListener('mouseup', dragEnd);
this._minder.on('contextmenu', function(e) {
e.preventDefault();
});
} }
}); });
...@@ -183,16 +192,16 @@ KityMinder.registerModule('View', function() { ...@@ -183,16 +192,16 @@ KityMinder.registerModule('View', function() {
var size = km._lastClientSize; var size = km._lastClientSize;
switch (dir) { switch (dir) {
case 'up': case 'up':
dragger.move(new kity.Point(0, -size.height / 2), duration); dragger.move(new kity.Point(0, size.height / 2), duration);
break; break;
case 'down': case 'down':
dragger.move(new kity.Point(0, size.height / 2), duration); dragger.move(new kity.Point(0, -size.height / 2), duration);
break; break;
case 'left': case 'left':
dragger.move(new kity.Point(-size.width / 2, 0), duration); dragger.move(new kity.Point(size.width / 2, 0), duration);
break; break;
case 'right': case 'right':
dragger.move(new kity.Point(size.width / 2, 0), duration); dragger.move(new kity.Point(-size.width / 2, 0), duration);
break; break;
} }
} }
...@@ -218,10 +227,14 @@ KityMinder.registerModule('View', function() { ...@@ -218,10 +227,14 @@ KityMinder.registerModule('View', function() {
var minder = this; var minder = this;
['up', 'down', 'left', 'right'].forEach(function(name) { ['up', 'down', 'left', 'right'].forEach(function(name) {
if (e.isShortcutKey('ctrl+' + name)) { if (e.isShortcutKey('ctrl+' + name)) {
minder.execCommand('move', name, 600); minder.removeAllSelectedNodes();
minder.execCommand('move', name, 100);
e.preventDefault(); e.preventDefault();
} }
}); });
if (e.isShortcutKey('ctrl+enter')) {
minder.execCommand('camera', minder.getRoot(), 100);
}
}, },
statuschange: function(e) { statuschange: function(e) {
this._viewDragger.setEnabled(e.currentStatus == 'hand'); this._viewDragger.setEnabled(e.currentStatus == 'hand');
...@@ -270,6 +283,29 @@ KityMinder.registerModule('View', function() { ...@@ -270,6 +283,29 @@ KityMinder.registerModule('View', function() {
this._viewDragger.move( this._viewDragger.move(
new kity.Point((a.width - b.width) / 2 | 0, (a.height - b.height) / 2 | 0)); new kity.Point((a.width - b.width) / 2 | 0, (a.height - b.height) / 2 | 0));
this._lastClientSize = a; this._lastClientSize = a;
},
selectionchange: function() {
var selected = this.getSelectedNode();
if (!selected) return;
var dragger = this._viewDragger;
var view = dragger.getView();
var focus = selected.getLayoutBox();
var space = 50;
if (focus.right > view.right) {
dragger.move(new kity.Point(view.right - focus.right - space, 0), 100);
}
if (focus.left < view.left) {
dragger.move(new kity.Point(view.left - focus.left + space, 0), 100);
}
if (focus.bottom > view.bottom) {
dragger.move(new kity.Point(0, view.bottom - focus.bottom - space), 100);
}
if (focus.top < view.top) {
dragger.move(new kity.Point(0, view.top - focus.top + space), 100);
}
} }
} }
}; };
......
...@@ -12,6 +12,7 @@ KityMinder.registerUI('doc', function(minder) { ...@@ -12,6 +12,7 @@ KityMinder.registerUI('doc', function(minder) {
var ret = minder.getUI('eve').setup({}); var ret = minder.getUI('eve').setup({});
var current = {}; var current = {};
var loading = false; var loading = false;
var saved = true;
/** /**
* 加载文档 * 加载文档
...@@ -45,7 +46,7 @@ KityMinder.registerUI('doc', function(minder) { ...@@ -45,7 +46,7 @@ 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); minder.getUI('topbar/title').setTitle(doc.title, saved = doc.saved);
ret.fire('docload', doc); ret.fire('docload', doc);
...@@ -65,7 +66,7 @@ KityMinder.registerUI('doc', function(minder) { ...@@ -65,7 +66,7 @@ KityMinder.registerUI('doc', function(minder) {
doc.data = minder.exportJson(); doc.data = minder.exportJson();
doc.json = JSON.stringify(doc.data); doc.json = JSON.stringify(doc.data);
minder.getUI('topbar/title').setTitle(doc.title, true); minder.getUI('topbar/title').setTitle(doc.title, saved = true);
ret.fire('docsave', doc); ret.fire('docsave', doc);
} }
...@@ -73,6 +74,10 @@ KityMinder.registerUI('doc', function(minder) { ...@@ -73,6 +74,10 @@ KityMinder.registerUI('doc', function(minder) {
return current; return current;
} }
function checkSaved() {
return saved || window.confirm(minder.getLang('ui.unsavedcontent', '* ' + current.title));
}
/* 绕开初始化时候的乱事件 */ /* 绕开初始化时候的乱事件 */
setTimeout(function() { setTimeout(function() {
minder.on('contentchange', function() { minder.on('contentchange', function() {
...@@ -83,16 +88,16 @@ KityMinder.registerUI('doc', function(minder) { ...@@ -83,16 +88,16 @@ KityMinder.registerUI('doc', function(minder) {
if (current.source != 'netdisk') { if (current.source != 'netdisk') {
current.title = minder.getMinderTitle(); current.title = minder.getMinderTitle();
$title.setTitle(current.title, false); $title.setTitle(current.title, saved = false);
ret.fire('docchange', current); ret.fire('docchange', current);
} else { } else {
if (current.json != JSON.stringify(minder.exportJson())) { if (current.json != JSON.stringify(minder.exportJson())) {
$title.setSaved(false); $title.setSaved(saved = false);
ret.fire('docchange', current); ret.fire('docchange', current);
} else { } else {
$title.setSaved(true); $title.setSaved(saved = true);
} }
} }
...@@ -103,6 +108,7 @@ KityMinder.registerUI('doc', function(minder) { ...@@ -103,6 +108,7 @@ KityMinder.registerUI('doc', function(minder) {
ret.load = load; ret.load = load;
ret.save = save; ret.save = save;
ret.current = getCurrent; ret.current = getCurrent;
ret.checkSaved = checkSaved;
return ret; return ret;
}); });
\ No newline at end of file
...@@ -20,20 +20,26 @@ kity.extendClass(FUI.Widget, { ...@@ -20,20 +20,26 @@ kity.extendClass(FUI.Widget, {
bindExecution: function(event, fn) { bindExecution: function(event, fn) {
var widget = this; var widget = this;
widget.executionFlag = false;
widget.on(event, function() { widget.on(event, function() {
widget.executionFlag = true; if (widget.interactFlag) return;
fn.apply(widget, arguments); fn.apply(widget, arguments);
widget.executionFlag = false;
}); });
}, },
bindCommandState: function(minder, command, valueHandle) { bindCommandState: function(minder, command, valueHandle) {
var widget = this; var widget = this;
minder.on('interactchange', function() { minder.on('interactchange', function() {
widget.interactFlag = true;
if (valueHandle) {
var value = this.queryCommandValue(command);
if (value != widget.lastHandleCommandValue) {
valueHandle.call(widget, value);
widget.lastHandleCommandValue = value;
}
}
widget.setEnable(this.queryCommandState(command) !== -1); widget.setEnable(this.queryCommandState(command) !== -1);
widget.setActive(this.queryCommandState(command) === 1); widget.setActive(this.queryCommandState(command) === 1);
if (valueHandle && !widget.executionFlag) valueHandle.call(widget, this.queryCommandValue(command)); widget.interactFlag = false;
}); });
} }
}); });
\ No newline at end of file
/**
* @fileOverview
*
* UI 状态记忆
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('memory', function () {
var ls = window.localStorage;
var memory = ls.uiMemory ? JSON.parse(ls.uiMemory) : {};
return {
get: function(item) {
return memory[item] || null;
},
set: function(item, value) {
memory[item] = value;
ls.uiMemory = JSON.stringify(memory);
}
};
});
\ No newline at end of file
...@@ -6,24 +6,55 @@ ...@@ -6,24 +6,55 @@
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
KityMinder.registerUI('menu/default', function (minder) { KityMinder.registerUI('menu/default', function(minder) {
minder.on('uiready', function() { minder.on('uiready', function() {
var $menu = minder.getUI('menu/menu'); var $menu = minder.getUI('menu/menu');
var $open = minder.getUI('menu/open/open'); var $open = minder.getUI('menu/open/open');
var $recent = minder.getUI('menu/open/recent');
var $save = minder.getUI('menu/save/save'); var $save = minder.getUI('menu/save/save');
var $share = minder.getUI('menu/share/share'); var $share = minder.getUI('menu/share/share');
var $draft = minder.getUI('menu/open/draft'); var $draft = minder.getUI('menu/open/draft');
$menu.$tabs.select(1); // 打开 // 主菜单默认选中「打开」
$open.$tabs.select(0); // 最近 $menu.$tabs.select(1);
$save.$tabs.select(0); // 云存储
$share.$tabs.select(0); // 当前脑图 // 打开菜单默认选中「本地文件」
$open.$tabs.select(2);
if ($draft.hasDraft()) { if ($draft.hasDraft()) {
// 草稿箱有草稿,默认选中「草稿箱」,并打开最近编辑的文件
$open.$tabs.select(3);
$draft.openLast(); $draft.openLast();
} else {
// 没有草稿,但用户登陆了
fio.user.check().then(function(user) {
if (user) {
// 有最近文件选中「最近文件」
if ($recent.hasRecent()) {
$open.$tabs.select(0);
$recent.loadLast();
}
// 否则选中网盘目录
else {
$open.$tabs.select(1);
}
}
});
} }
// 保存菜单默认选中「导出到本地」
$save.$tabs.select(1);
// 如果用户登陆了,选中「百度云存储」
fio.user.check().then(function(user) {
if (user) {
$save.$tabs.select(0);
}
});
$share.$tabs.select(0); // 当前脑图
// $menu.show(); // $menu.show();
}); });
}); });
\ No newline at end of file
...@@ -38,11 +38,16 @@ KityMinder.registerUI('menu/menu', function(minder) { ...@@ -38,11 +38,16 @@ KityMinder.registerUI('menu/menu', function(minder) {
function hide() { function hide() {
$panel.removeClass('show'); $panel.removeClass('show');
minder.getRenderTarget().focus();
ret.fire('hide'); ret.fire('hide');
} }
function isVisible() {
return $panel.hasClass('show');
}
function toggle() { function toggle() {
($panel.hasClass('show') ? hide : show)(); (isVisible() ? hide : show)();
} }
function createSub(name, asDefault) { function createSub(name, asDefault) {
...@@ -75,6 +80,7 @@ KityMinder.registerUI('menu/menu', function(minder) { ...@@ -75,6 +80,7 @@ KityMinder.registerUI('menu/menu', function(minder) {
ret.show = show; ret.show = show;
ret.hide = hide; ret.hide = hide;
ret.toggle = toggle; ret.toggle = toggle;
ret.isVisible = isVisible;
ret.createSub = createSub; ret.createSub = createSub;
ret.createSubMenu = createSubMenu; ret.createSubMenu = createSubMenu;
ret.$panel = $panel; ret.$panel = $panel;
......
...@@ -35,6 +35,9 @@ KityMinder.registerUI('menu/new/new', function(minder) { ...@@ -35,6 +35,9 @@ KityMinder.registerUI('menu/new/new', function(minder) {
} }
$ul.delegate('.template-item', 'click', function(e) { $ul.delegate('.template-item', 'click', function(e) {
if (!$doc.checkSaved()) return;
var template = $(e.target).data('template'); var template = $(e.target).data('template');
$doc.load({ $doc.load({
content: { content: {
...@@ -44,7 +47,8 @@ KityMinder.registerUI('menu/new/new', function(minder) { ...@@ -44,7 +47,8 @@ KityMinder.registerUI('menu/new/new', function(minder) {
text: minder.getLang('template')[template] text: minder.getLang('template')[template]
} }
}, },
protocol: null protocol: null,
saved: true
}); });
$menu.hide(); $menu.hide();
}); });
......
...@@ -54,6 +54,9 @@ KityMinder.registerUI('menu/open/draft', function(minder) { ...@@ -54,6 +54,9 @@ KityMinder.registerUI('menu/open/draft', function(minder) {
lastDoc = null; lastDoc = null;
$ul.delegate('.draft-list-item', 'click', function(e) { $ul.delegate('.draft-list-item', 'click', function(e) {
if (!$doc.checkSaved()) return;
var item = $(e.target).closest('.draft-list-item').data('item'); var item = $(e.target).closest('.draft-list-item').data('item');
var index = draftList.findIndex(function(finding) { var index = draftList.findIndex(function(finding) {
...@@ -117,7 +120,6 @@ KityMinder.registerUI('menu/open/draft', function(minder) { ...@@ -117,7 +120,6 @@ KityMinder.registerUI('menu/open/draft', function(minder) {
current = null; current = null;
} }
renderList(); renderList();
console.log('pop draft');
} }
function renderList() { function renderList() {
......
...@@ -55,6 +55,7 @@ KityMinder.registerUI('menu/open/local', function(minder) { ...@@ -55,6 +55,7 @@ KityMinder.registerUI('menu/open/local', function(minder) {
/* 交互事件 */ /* 交互事件 */
$pickButton.click(function() { $pickButton.click(function() {
if (!$doc.checkSaved()) return;
$('<input type="file" />') $('<input type="file" />')
.attr('accept', accepts.join()) .attr('accept', accepts.join())
.on('change', function(e) { .on('change', function(e) {
...@@ -67,6 +68,7 @@ KityMinder.registerUI('menu/open/local', function(minder) { ...@@ -67,6 +68,7 @@ KityMinder.registerUI('menu/open/local', function(minder) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
}).on('drop', function(e) { }).on('drop', function(e) {
if (!$doc.checkSave()) return;
e = e.originalEvent; e = e.originalEvent;
read(e.dataTransfer.files[0]); read(e.dataTransfer.files[0]);
$menu.hide(); $menu.hide();
......
...@@ -36,6 +36,7 @@ KityMinder.registerUI('menu/open/netdisk', function(minder) { ...@@ -36,6 +36,7 @@ KityMinder.registerUI('menu/open/netdisk', function(minder) {
}); });
$finder.on('fileclick', function(file) { $finder.on('fileclick', function(file) {
if (!$doc.checkSaved()) return;
return open(file.path); return open(file.path);
}); });
......
...@@ -40,6 +40,8 @@ KityMinder.registerUI('menu/open/recent', function(minder) { ...@@ -40,6 +40,8 @@ KityMinder.registerUI('menu/open/recent', function(minder) {
$ul.delegate('.recent-file-item', 'click', function(e) { $ul.delegate('.recent-file-item', 'click', function(e) {
if (!doc.checkSaved()) return;
var netdisk = minder.getUI('menu/open/netdisk'); var netdisk = minder.getUI('menu/open/netdisk');
var path = $(e.target) var path = $(e.target)
.closest('.recent-file-item') .closest('.recent-file-item')
...@@ -107,6 +109,9 @@ KityMinder.registerUI('menu/open/recent', function(minder) { ...@@ -107,6 +109,9 @@ KityMinder.registerUI('menu/open/recent', function(minder) {
} }
return { return {
hasRecent: function() {
return recentList.length;
},
loadLast: function() { loadLast: function() {
$ul.find('.recent-file-item').eq(0).click(); $ul.find('.recent-file-item').eq(0).click();
} }
......
/**
* @fileOverview
*
* 配置面板
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('ui/menu/preference/preference', function (minder) {
var $menu = minder.getUI('menu/menu');
var ret = minder.getUI('eve').setup({});
var $panel = $menu.createSub('preference');
// 同步用户配置文件
function syncPreference() {
// 配置文件在网盘的路径
var remotePreferencesPath = '/apps/kityminder/app.preferences';
// 记录远端配置的和本地配置的版本
// - 远端配置保存在 json 内容的 version 字段中
// - 本地配置用 localStorage 来记录
var remoteVersion = 0,
localVersion = localStorage.preferencesVersion || 0;
// 远端配置和本地配置的内容
var remotePreferences, localPreferences;
downloadPreferences();
// 绑定实例上配置改变的事件,配置有变需要上传
minder.on('preferenceschange', function() {
localStorage.preferencesVersion = ++localVersion;
uploadPreferences();
});
// 下载远端配置
function downloadPreferences() {
// 比较远端和本地版本
// - 远端版本较新则设置本地版本为远端版本
// - 本地版本较新则上传本地版本
function merge(remote) {
if (!remote) return;
remote = JSON.parse(remote.data.content);
remoteVersion = remote.version;
remotePreferences = remote.preferences;
localPreferences = minder.getPreferences();
if (localVersion < remoteVersion) {
minder.resetPreferences(remotePreferences);
} else if (localVersion > remoteVersion) {
uploadPreferences();
}
}
// 下载配置的过程
// 需要先获得下载的 URL 再使用 ajax 请求内容
fio.file.read({
path: remotePreferencesPath,
dataType: 'text'
}).then(merge);
}
// 上传本地配置
function uploadPreferences() {
localPreferences = minder.getPreferences();
// 上传的数据需要附带版本信息
var data = {
version: localVersion,
preferences: localPreferences
};
fio.file.write({
path: remotePreferencesPath,
content: JSON.stringify(data),
ondup: fio.file.DUP_OVERWRITE
});
}
}
});
\ No newline at end of file
...@@ -43,7 +43,8 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) { ...@@ -43,7 +43,8 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) {
.attr('placeholder', minder.getLang('ui.filename')) .attr('placeholder', minder.getLang('ui.filename'))
.attr('title', minder.getLang('ui.filename')) .attr('title', minder.getLang('ui.filename'))
.on('keydown', function(e) { .on('keydown', function(e) {
if (e.keyCode == 27) $menu.toggleClass('show'); if (e.keyCode == 27) $menu.toggle();
if (e.keyCode == 13) save();
}) })
.appendTo($selects); .appendTo($selects);
...@@ -77,7 +78,29 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) { ...@@ -77,7 +78,29 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) {
$filename.val(file.filename); $filename.val(file.filename);
}); });
function save() { ret.quickSave = quickSave;
window.onbeforeunload = function() {
var noask = window.location.href.indexOf('noask') > 0;
if (!$doc.checkSave() && !noask)
return minder.getLang('ui.unsavedcontent', '* ' + $doc.current().title);
};
// 快速保存
function quickSave() {
var doc = $doc.current();
if (doc.source != 'netdisk' && !$menu.isVisible()) {
$menu.$tabs.select(2);
$save.$tabs.select(0);
return $menu.show();
} else {
var $title = minder.getUI('topbar/title').$title;
$filename.val(doc.title);
doSave(doc.path, doc.protocol, doc, $title);
}
}
function getSaveContext() {
var filename = $filename.val(); var filename = $filename.val();
if (fio.file.anlysisPath(filename).extension != $format.val()) { if (fio.file.anlysisPath(filename).extension != $format.val()) {
...@@ -92,16 +115,36 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) { ...@@ -92,16 +115,36 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) {
var match = doc.path == path; // 目标路径正是当前文档 var match = doc.path == path; // 目标路径正是当前文档
var duplicated = exist && !match; var duplicated = exist && !match;
if (!exist || match || duplicated && window.confirm(minder.getLang('ui.overrideconfirm', filename))) { return {
doSave(path, protocol, doc); filename: filename,
path: path,
doc: doc,
protocol: protocol,
exist: exist,
match: match,
duplicated: duplicated
};
}
function save() {
var ctx = getSaveContext();
if (ctx.match || !ctx.exist || ctx.duplicated && window.confirm(minder.getLang('ui.overrideconfirm', ctx.filename))) {
doSave(ctx.path, ctx.protocol.name, ctx.doc, $panel);
} }
} }
function doSave(path, protocol, doc) { var saving = false;
function doSave(path, protocol, doc, $mask) {
$panel.addClass('loading'); // if (saving) return;
return minder.exportData(protocol.name).then(function(data) { saving = true;
if ($mask) $mask.addClass('loading');
return minder.exportData(protocol).then(function(data) {
return fio.file.write({ return fio.file.write({
path: path, path: path,
...@@ -111,7 +154,8 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) { ...@@ -111,7 +154,8 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) {
}).then(function() { }).then(function() {
$panel.removeClass('loading'); if ($mask) $mask.removeClass('loading');
$menu.hide(); $menu.hide();
doc.path = path; doc.path = path;
...@@ -123,9 +167,10 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) { ...@@ -123,9 +167,10 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) {
setTimeout($finder.list, 500); setTimeout($finder.list, 500);
})['catch'](function(e) { })['catch'](function(e) {
window.alert('保存文件失败:' + (e.message || minder.getLang('ui.unknownreason'))); window.alert('保存文件失败:' + (e.message || minder.getLang('ui.unknownreason')));
}).then(function(e) {
saving = false;
}); });
} }
......
...@@ -256,7 +256,7 @@ KityMinder.registerUI('menu/share/share', function(minder) { ...@@ -256,7 +256,7 @@ KityMinder.registerUI('menu/share/share', function(minder) {
var baseUrl = /^(.*?)(\?|\#|$)/.exec(window.location.href)[1]; var baseUrl = /^(.*?)(\?|\#|$)/.exec(window.location.href)[1];
baseUrl = baseUrl.split('index.html')[0]; baseUrl = baseUrl.split('edit.html')[0];
return baseUrl + 'viewshare.html?shareId=' + id; return baseUrl + 'viewshare.html?shareId=' + id;
} }
......
...@@ -11,6 +11,8 @@ KityMinder.registerUI('menu/share/view', function (minder) { ...@@ -11,6 +11,8 @@ KityMinder.registerUI('menu/share/view', function (minder) {
var $save = minder.getUI('menu/save/save'); var $save = minder.getUI('menu/save/save');
var $doc = minder.getUI('doc'); var $doc = minder.getUI('doc');
$menu.$tabs.select(0);
$save.$tabs.select(0);
function loadShareDoc() { function loadShareDoc() {
...@@ -65,6 +67,7 @@ KityMinder.registerUI('menu/share/view', function (minder) { ...@@ -65,6 +67,7 @@ KityMinder.registerUI('menu/share/view', function (minder) {
$(minder.getRenderTarget()).removeClass('loading'); $(minder.getRenderTarget()).removeClass('loading');
minder.execCommand('hand'); minder.execCommand('hand');
minder.disable();
}); });
} }
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
KityMinder.registerUI('nav', function(minder) { KityMinder.registerUI('nav', function(minder) {
var memory = minder.getUI('memory');
var $navBar = $('<div>').addClass('nav-bar').appendTo('#content-wrapper'); var $navBar = $('<div>').addClass('nav-bar').appendTo('#content-wrapper');
var $commandbutton = minder.getUI('widget/commandbutton'); var $commandbutton = minder.getUI('widget/commandbutton');
...@@ -60,47 +62,87 @@ KityMinder.registerUI('nav', function(minder) { ...@@ -60,47 +62,87 @@ KityMinder.registerUI('nav', function(minder) {
return $pan; return $pan;
} }
/**
* 创建导航器的 DOM 元素以及交互的逻辑代码
*/
function createViewNavigator() { function createViewNavigator() {
var $previewNavigator = $('<div>') var $previewNavigator = $('<div>')
.addClass('preview-navigator') .addClass('preview-navigator')
.appendTo('#content-wrapper'); .appendTo('#content-wrapper');
var width = $previewNavigator.width(); // 画布,渲染缩略图
var height = $previewNavigator.height();
var paper = new kity.Paper($previewNavigator[0]); var paper = new kity.Paper($previewNavigator[0]);
paper.setWidth(width); // 用两个路径来挥之节点和连线的缩略图
paper.setHeight(height); var nodeThumb = paper.put(new kity.Path());
var connectionThumb = paper.put(new kity.Path());
var nodePath = paper.put(new kity.Path()); // 表示可视区域的矩形
var connectPath = paper.put(new kity.Path()); var visibleRect = paper.put(new kity.Rect(100, 100).stroke('red', '1%'));
var currentView = paper.put(new kity.Rect(100, 100).stroke('red', '1%'));
minder.on('layout layoutallfinish', preview); // 分别表示脑图内容区域大小和当前见区域大小
minder.on('viewchange', updateView); var contentView, visibleView;
var dragging = false; navigate();
paper.on('mousedown', function(e) { $previewNavigator.show = function() {
dragging = true; $.fn.show.call(this);
moveView(e.getPosition('top'), 200); bind();
$previewNavigator.addClass('grab'); updateVisibleView();
}); };
$previewNavigator.hide = function() {
$.fn.hide.call(this);
unbind();
};
function bind() {
minder.on('layout layoutallfinish', updateContentView);
minder.on('viewchange', updateVisibleView);
}
function unbind() {
minder.off('layout layoutallfinish', updateContentView);
minder.off('viewchange', updateVisibleView);
}
function navigate() {
paper.on('mousemove', function(e) { function moveView(center, duration) {
if (dragging) { var box = visibleRect.getBox();
moveView(e.getPosition('top')); center.x = -center.x;
center.y = -center.y;
minder.getViewDragger().moveTo(center.offset(box.width / 2, box.height / 2), duration);
} }
});
$(window).on('mouseup', function() { var dragging = false;
dragging = false;
$previewNavigator.removeClass('grab'); paper.on('mousedown', function(e) {
}); dragging = true;
moveView(e.getPosition('top'), 200);
$previewNavigator.addClass('grab');
});
paper.on('mousemove', function(e) {
if (dragging) {
moveView(e.getPosition('top'));
}
});
$(window).on('mouseup', function() {
dragging = false;
$previewNavigator.removeClass('grab');
});
}
function updateContentView() {
contentView = minder.getRenderContainer().getBoundaryBox();
var view = visibleView ? contentView.merge(visibleView) : contentView;
function preview() {
var view = minder.getRenderContainer().getBoundaryBox();
var padding = 30; var padding = 30;
paper.setViewBox( paper.setViewBox(
view.x - padding - 0.5, view.x - padding - 0.5,
view.y - padding - 0.5, view.y - padding - 0.5,
...@@ -108,7 +150,7 @@ KityMinder.registerUI('nav', function(minder) { ...@@ -108,7 +150,7 @@ KityMinder.registerUI('nav', function(minder) {
view.height + padding * 2 + 1); view.height + padding * 2 + 1);
var nodePathData = []; var nodePathData = [];
var connectPathData = []; var connectionThumbData = [];
minder.getRoot().traverse(function(node) { minder.getRoot().traverse(function(node) {
var box = node.getLayoutBox(); var box = node.getLayoutBox();
...@@ -116,39 +158,33 @@ KityMinder.registerUI('nav', function(minder) { ...@@ -116,39 +158,33 @@ KityMinder.registerUI('nav', function(minder) {
'h', box.width, 'v', box.height, 'h', box.width, 'v', box.height,
'h', -box.width, 'z'); 'h', -box.width, 'z');
if (node.getConnection() && node.parent && node.parent.isExpanded()) { if (node.getConnection() && node.parent && node.parent.isExpanded()) {
connectPathData.push(node.getConnection().getPathData()); connectionThumbData.push(node.getConnection().getPathData());
} }
}); });
paper.setStyle('background', minder.getStyle('background')); paper.setStyle('background', minder.getStyle('background'));
if (nodePathData.length) { if (nodePathData.length) {
nodePath nodeThumb
.fill(minder.getStyle('root-background')) .fill(minder.getStyle('root-background'))
.setPathData(nodePathData); .setPathData(nodePathData);
} else { } else {
nodePath.setPathData(null); nodeThumb.setPathData(null);
} }
if (connectPathData.length) { if (connectionThumbData.length) {
connectPath connectionThumb
.stroke(minder.getStyle('connect-color'), '0.5%') .stroke(minder.getStyle('connect-color'), '0.5%')
.setPathData(connectPathData); .setPathData(connectionThumbData);
} else { } else {
connectPath.setPathData(null); connectionThumb.setPathData(null);
} }
} }
function updateView() { function updateVisibleView() {
var view = minder.getViewDragger().getView(); visibleView = minder.getViewDragger().getView();
currentView.setBox(view); visibleRect.setBox(visibleView);
} updateContentView();
function moveView(center, duration) {
var box = currentView.getBox();
center.x = -center.x;
center.y = -center.y;
minder.getViewDragger().moveTo(center.offset(box.width / 2, box.height / 2), duration);
} }
return $previewNavigator; return $previewNavigator;
...@@ -156,16 +192,24 @@ KityMinder.registerUI('nav', function(minder) { ...@@ -156,16 +192,24 @@ KityMinder.registerUI('nav', function(minder) {
function createPreviewTrigger($previewNavigator) { function createPreviewTrigger($previewNavigator) {
var $trigger = $('<div>').addClass('command-button nav-trigger'); var $trigger = $('<div>').addClass('command-button nav-trigger');
$trigger.append('<div class="fui-icon">'); $trigger.append('<div class="fui-icon">');
$trigger.click(function() { $trigger.click(toggle);
$trigger.toggleClass('active'); $trigger.attr('title', minder.getLang('ui.navigator'));
if ($trigger.hasClass('active')) {
function toggle() {
if ($trigger.toggleClass('active').hasClass('active')) {
$previewNavigator.show(); $previewNavigator.show();
memory.set('navigator-hidden', false);
} else { } else {
$previewNavigator.hide(); $previewNavigator.hide();
memory.set('navigator-hidden', true);
} }
}).click(); }
$trigger.attr('title', minder.getLang('ui.navigator'));
if (memory.get('navigator-hidden')) toggle();
toggle();
return $trigger; return $trigger;
} }
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
*/ */
KityMinder.registerUI('ribbon/tabs', function(minder) { KityMinder.registerUI('ribbon/tabs', function(minder) {
var memory = minder.getUI('memory');
var $tab = new FUI.Tabs({ var $tab = new FUI.Tabs({
buttons: ['idea', 'appearence'/*, 'view'*/].map(function(key) { buttons: ['idea', 'appearence'/*, 'view'*/].map(function(key) {
return minder.getLang('ui.tabs.' + key); return minder.getLang('ui.tabs.' + key);
...@@ -34,12 +36,19 @@ KityMinder.registerUI('ribbon/tabs', function(minder) { ...@@ -34,12 +36,19 @@ KityMinder.registerUI('ribbon/tabs', function(minder) {
$container.removeClass('collapsed'); $container.removeClass('collapsed');
$header.removeClass('collapsed'); $header.removeClass('collapsed');
} }
memory.set('ribbon-tab-collapsed', $container.hasClass('collapsed'));
memory.set('ribbon-tab-index', info.index);
lastIndex = info.index; lastIndex = info.index;
}); });
$tab.idea = $tab.getPanel(0); $tab.idea = $tab.getPanel(0);
$tab.appearence = $tab.getPanel(1); $tab.appearence = $tab.getPanel(1);
$tab.view = $tab.getPanel(2); $tab.view = $tab.getPanel(2);
$tab.select(1);
$tab.select(memory.get('ribbon-tab-index') || 0);
if (memory.get('ribbon-tab-collapsed')) {
$container.addClass('collapsed');
$header.addClass('collapsed');
}
return $tab; return $tab;
}); });
\ No newline at end of file
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
} }
&.undo { &.undo {
margin-left: 10px;
} }
&.redo { &.redo {
......
...@@ -31,9 +31,16 @@ html, body { ...@@ -31,9 +31,16 @@ html, body {
} }
#kityminder { #kityminder {
.dock(@panel-height, 0, 0, 0); .dock(100px, 0, 0, 0);
&.maximize {
top: 40px;
}
-moz-user-select: none; -moz-user-select: none;
} }
#tab-container.collapsed + #kityminder,
#panel + #kityminder{
top: 40px;
}
#panel { #panel {
background: @ui-color; background: @ui-color;
...@@ -50,6 +57,20 @@ html, body { ...@@ -50,6 +57,20 @@ html, body {
text-align: center; text-align: center;
font-weight: normal; font-weight: normal;
color: @ui-fore; color: @ui-fore;
&.loading {
&:before {
position: relative;
display: inline-block;
.loading-circle(12px, 3px);
left: -6px;
top: 3px;
box-shadow: none;
}
&:after {
display: none;
}
}
} }
} }
......
.priority-sprite(@count) when (@count >= 0) { .priority-sprite(@count) when (@count >= 0) {
.priority-sprite(@count - 1); .priority-sprite(@count - 1);
&.priority-@{count} .fui-icon { &.priority-@{count} .fui-icon {
background-position: (-20px * (@count - 1)) 0; background-position: 0 (-20px * (@count - 1));
} }
} }
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
display: block; display: block;
height: 20px; height: 20px;
width: 20px; width: 20px;
background: url(../images/iconpriority.png) repeat-x; background: url(../images/iconpriority.png) repeat-y;
background-color: transparent; background-color: transparent;
} }
padding: 2px; padding: 2px;
......
.progress-sprite(@count) when (@count >= 0) { .progress-sprite(@count) when (@count >= 0) {
.progress-sprite(@count - 1); .progress-sprite(@count - 1);
&.progress-@{count} .fui-icon { &.progress-@{count} .fui-icon {
background-position: (-20px * (@count - 1)) 0; background-position: 0 (-20px * (@count - 1));
} }
} }
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
display: block; display: block;
height: 20px; height: 20px;
width: 20px; width: 20px;
background: url(../images/iconprogress.png) repeat-x; background: url(../images/iconprogress.png) repeat-y;
background-color: transparent; background-color: transparent;
} }
padding: 2px; padding: 2px;
......
...@@ -84,6 +84,18 @@ input[type=url] { ...@@ -84,6 +84,18 @@ input[type=url] {
} }
} }
.loading-circle(@size: 40px, @border-size: 4px) {
width: @size;
height: @size;
border: @border-size solid;
border-color: @border-color transparent transparent;
box-shadow: 0 0 (@size - 5px) white;
z-index: 10;
border-radius: 100%;
.animation(rotate 1.33s ease infinite);
filter: none;
-webkit-filter: none;
}
.loading(@color: rgb(128, 130, 140), @border-color: #fff) { .loading(@color: rgb(128, 130, 140), @border-color: #fff) {
.loading-target { .loading-target {
...@@ -100,21 +112,12 @@ input[type=url] { ...@@ -100,21 +112,12 @@ input[type=url] {
&:before { &:before {
content: ' '; content: ' ';
width: 40px; .loading-circle;
height: 40px;
border: 4px solid;
border-color: @border-color transparent transparent;
box-shadow: 0 0 35px white;
position: absolute; position: absolute;
left: 50%; left: 50%;
top: 50%; top: 50%;
margin-left: -24px; margin-left: -24px;
margin-top: -24px; margin-top: -24px;
z-index: 10;
border-radius: 100%;
.animation(rotate 1.33s ease infinite);
filter: none;
-webkit-filter: none;
} }
} }
......
#panel .quick-visit-button {
float: left;
border: none;
width: 40px;
height: 40px;
line-height: 40px;
padding: 0;
margin: 0;
display: block;
position: relative;
&:after {
content: ' ';
position: absolute;
display: block;
width: 25px;
height: 25px;
left: 7.5px;
top: 5.5px;
background: url(../images/icons.png) no-repeat;
}
text-indent: -10000px;
&.new {
&:after {
background-position: 0 -895px;
}
}
&.save {
&:after {
background-position: 0 -920px;
}
}
&.share {
&:after {
background-position: 0 -945px;
}
}
&:hover {
background-color: @tab-hover;
}
&:active {
background-color: @tab-active;
}
&:first-child {
margin-left: 5px;
}
}
\ No newline at end of file
...@@ -641,13 +641,8 @@ input[type=url]:focus { ...@@ -641,13 +641,8 @@ input[type=url]:focus {
width: 40px; width: 40px;
height: 40px; height: 40px;
border: 4px solid; border: 4px solid;
border-color: #ffffff transparent transparent; border-color: #c9ced1 transparent transparent;
box-shadow: 0 0 35px white; box-shadow: 0 0 35px #ffffff;
position: absolute;
left: 50%;
top: 50%;
margin-left: -24px;
margin-top: -24px;
z-index: 10; z-index: 10;
border-radius: 100%; border-radius: 100%;
-webkit-animation: rotate 1.33s ease infinite; -webkit-animation: rotate 1.33s ease infinite;
...@@ -657,6 +652,11 @@ input[type=url]:focus { ...@@ -657,6 +652,11 @@ input[type=url]:focus {
animation: rotate 1.33s ease infinite; animation: rotate 1.33s ease infinite;
filter: none; filter: none;
-webkit-filter: none; -webkit-filter: none;
position: absolute;
left: 50%;
top: 50%;
margin-left: -24px;
margin-top: -24px;
} }
@-webkit-keyframes rotate { @-webkit-keyframes rotate {
from { from {
...@@ -1332,12 +1332,19 @@ body { ...@@ -1332,12 +1332,19 @@ body {
} }
#kityminder { #kityminder {
position: absolute; position: absolute;
top: 40px; top: 100px;
right: 0; right: 0;
bottom: 0; bottom: 0;
left: 0; left: 0;
-moz-user-select: none; -moz-user-select: none;
} }
#kityminder.maximize {
top: 40px;
}
#tab-container.collapsed + #kityminder,
#panel + #kityminder {
top: 40px;
}
#panel { #panel {
background: #393f4f; background: #393f4f;
font-family: 'Hiragino Sans GB', 'Arial', 'Microsoft Yahei'; font-family: 'Hiragino Sans GB', 'Arial', 'Microsoft Yahei';
...@@ -1354,6 +1361,30 @@ body { ...@@ -1354,6 +1361,30 @@ body {
font-weight: normal; font-weight: normal;
color: #ffffff; color: #ffffff;
} }
#panel h1.loading:before {
position: relative;
display: inline-block;
width: 12px;
height: 12px;
border: 3px solid;
border-color: #c9ced1 transparent transparent;
box-shadow: 0 0 7px #ffffff;
z-index: 10;
border-radius: 100%;
-webkit-animation: rotate 1.33s ease infinite;
-moz-animation: rotate 1.33s ease infinite;
-ms-animation: rotate 1.33s ease infinite;
-o-animation: rotate 1.33s ease infinite;
animation: rotate 1.33s ease infinite;
filter: none;
-webkit-filter: none;
left: -6px;
top: 3px;
box-shadow: none;
}
#panel h1.loading:after {
display: none;
}
.fui-widget { .fui-widget {
-webkit-font-smoothing: auto; -webkit-font-smoothing: auto;
} }
...@@ -1709,6 +1740,46 @@ body { ...@@ -1709,6 +1740,46 @@ body {
.new-file-template-select li:active:before { .new-file-template-select li:active:before {
background-color: #fee6e6; background-color: #fee6e6;
} }
#panel .quick-visit-button {
float: left;
border: none;
width: 40px;
height: 40px;
line-height: 40px;
padding: 0;
margin: 0;
display: block;
position: relative;
text-indent: -10000px;
}
#panel .quick-visit-button:after {
content: ' ';
position: absolute;
display: block;
width: 25px;
height: 25px;
left: 7.5px;
top: 5.5px;
background: url(../images/icons.png) no-repeat;
}
#panel .quick-visit-button.new:after {
background-position: 0 -895px;
}
#panel .quick-visit-button.save:after {
background-position: 0 -920px;
}
#panel .quick-visit-button.share:after {
background-position: 0 -945px;
}
#panel .quick-visit-button:hover {
background-color: #5a6378;
}
#panel .quick-visit-button:active {
background-color: #444b5b;
}
#panel .quick-visit-button:first-child {
margin-left: 5px;
}
.command-button.undo, .command-button.undo,
.command-button.redo { .command-button.redo {
float: left; float: left;
...@@ -1752,9 +1823,6 @@ body { ...@@ -1752,9 +1823,6 @@ body {
.command-button.redo.fui-disabled .fui-icon { .command-button.redo.fui-disabled .fui-icon {
background-position-y: 0; background-position-y: 0;
} }
.command-button.undo {
margin-left: 10px;
}
.command-button.redo .fui-icon { .command-button.redo .fui-icon {
background-position-x: -40px; background-position-x: -40px;
} }
...@@ -2404,38 +2472,38 @@ body { ...@@ -2404,38 +2472,38 @@ body {
display: block; display: block;
height: 20px; height: 20px;
width: 20px; width: 20px;
background: url(../images/iconpriority.png) repeat-x; background: url(../images/iconpriority.png) repeat-y;
background-color: transparent; background-color: transparent;
} }
#tab-container .command-buttonset.priority .fui-button.priority-0 .fui-icon { #tab-container .command-buttonset.priority .fui-button.priority-0 .fui-icon {
background-position: 20px 0; background-position: 0 20px;
} }
#tab-container .command-buttonset.priority .fui-button.priority-1 .fui-icon { #tab-container .command-buttonset.priority .fui-button.priority-1 .fui-icon {
background-position: 0px 0; background-position: 0 0px;
} }
#tab-container .command-buttonset.priority .fui-button.priority-2 .fui-icon { #tab-container .command-buttonset.priority .fui-button.priority-2 .fui-icon {
background-position: -20px 0; background-position: 0 -20px;
} }
#tab-container .command-buttonset.priority .fui-button.priority-3 .fui-icon { #tab-container .command-buttonset.priority .fui-button.priority-3 .fui-icon {
background-position: -40px 0; background-position: 0 -40px;
} }
#tab-container .command-buttonset.priority .fui-button.priority-4 .fui-icon { #tab-container .command-buttonset.priority .fui-button.priority-4 .fui-icon {
background-position: -60px 0; background-position: 0 -60px;
} }
#tab-container .command-buttonset.priority .fui-button.priority-5 .fui-icon { #tab-container .command-buttonset.priority .fui-button.priority-5 .fui-icon {
background-position: -80px 0; background-position: 0 -80px;
} }
#tab-container .command-buttonset.priority .fui-button.priority-6 .fui-icon { #tab-container .command-buttonset.priority .fui-button.priority-6 .fui-icon {
background-position: -100px 0; background-position: 0 -100px;
} }
#tab-container .command-buttonset.priority .fui-button.priority-7 .fui-icon { #tab-container .command-buttonset.priority .fui-button.priority-7 .fui-icon {
background-position: -120px 0; background-position: 0 -120px;
} }
#tab-container .command-buttonset.priority .fui-button.priority-8 .fui-icon { #tab-container .command-buttonset.priority .fui-button.priority-8 .fui-icon {
background-position: -140px 0; background-position: 0 -140px;
} }
#tab-container .command-buttonset.priority .fui-button.priority-9 .fui-icon { #tab-container .command-buttonset.priority .fui-button.priority-9 .fui-icon {
background-position: -160px 0; background-position: 0 -160px;
} }
#tab-container .command-buttonset.priority .fui-button.fui-button-pressed { #tab-container .command-buttonset.priority .fui-button.fui-button-pressed {
background-color: #c4d0ee; background-color: #c4d0ee;
...@@ -2457,38 +2525,38 @@ body { ...@@ -2457,38 +2525,38 @@ body {
display: block; display: block;
height: 20px; height: 20px;
width: 20px; width: 20px;
background: url(../images/iconprogress.png) repeat-x; background: url(../images/iconprogress.png) repeat-y;
background-color: transparent; background-color: transparent;
} }
#tab-container .command-buttonset.progress .fui-button.progress-0 .fui-icon { #tab-container .command-buttonset.progress .fui-button.progress-0 .fui-icon {
background-position: 20px 0; background-position: 0 20px;
} }
#tab-container .command-buttonset.progress .fui-button.progress-1 .fui-icon { #tab-container .command-buttonset.progress .fui-button.progress-1 .fui-icon {
background-position: 0px 0; background-position: 0 0px;
} }
#tab-container .command-buttonset.progress .fui-button.progress-2 .fui-icon { #tab-container .command-buttonset.progress .fui-button.progress-2 .fui-icon {
background-position: -20px 0; background-position: 0 -20px;
} }
#tab-container .command-buttonset.progress .fui-button.progress-3 .fui-icon { #tab-container .command-buttonset.progress .fui-button.progress-3 .fui-icon {
background-position: -40px 0; background-position: 0 -40px;
} }
#tab-container .command-buttonset.progress .fui-button.progress-4 .fui-icon { #tab-container .command-buttonset.progress .fui-button.progress-4 .fui-icon {
background-position: -60px 0; background-position: 0 -60px;
} }
#tab-container .command-buttonset.progress .fui-button.progress-5 .fui-icon { #tab-container .command-buttonset.progress .fui-button.progress-5 .fui-icon {
background-position: -80px 0; background-position: 0 -80px;
} }
#tab-container .command-buttonset.progress .fui-button.progress-6 .fui-icon { #tab-container .command-buttonset.progress .fui-button.progress-6 .fui-icon {
background-position: -100px 0; background-position: 0 -100px;
} }
#tab-container .command-buttonset.progress .fui-button.progress-7 .fui-icon { #tab-container .command-buttonset.progress .fui-button.progress-7 .fui-icon {
background-position: -120px 0; background-position: 0 -120px;
} }
#tab-container .command-buttonset.progress .fui-button.progress-8 .fui-icon { #tab-container .command-buttonset.progress .fui-button.progress-8 .fui-icon {
background-position: -140px 0; background-position: 0 -140px;
} }
#tab-container .command-buttonset.progress .fui-button.progress-9 .fui-icon { #tab-container .command-buttonset.progress .fui-button.progress-9 .fui-icon {
background-position: -160px 0; background-position: 0 -160px;
} }
#tab-container .command-buttonset.progress .fui-button.fui-button-pressed { #tab-container .command-buttonset.progress .fui-button.fui-button-pressed {
background-color: #c4d0ee; background-color: #c4d0ee;
......
This diff is collapsed.
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
@import "_kityminder"; @import "_kityminder";
@import "_mainmenu"; @import "_mainmenu";
@import "_mainmenu.new.less"; @import "_mainmenu.new.less";
@import "_quickvisit.less";
@import "_history"; @import "_history";
@import "_tab"; @import "_tab";
@import "_search"; @import "_search";
......
ui/theme/default/images/icons.png

16.5 KB | W: | H:

ui/theme/default/images/icons.png

17.3 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
/**
* @fileOverview
*
* 快速访问区域
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('topbar/quickvisit', function (minder) {
function btn(name) {
return $('<a class="quick-visit-button"></a>')
.text(minder.getLang('ui.quickvisit.' + name))
.addClass(name)
.appendTo('#panel');
}
var $new = btn('new'),
$save = btn('save'),
$share = btn('share');
minder.on('uiready', function quickVisit() {
function quickNew() {
var $doc = minder.getUI('doc');
if (!$doc.checkSaved()) return;
$doc.load({
content: {
template: 'default',
version: KityMinder.version,
data: {
text: minder.getLang('maintopic')
}
},
saved: true
});
}
function quickSave() {
minder.getUI('menu/save/netdisk').quickSave();
}
function quickShare() {
var $menu = minder.getUI('menu/menu');
$menu.$tabs.select(3);
$menu.show();
}
$new.click(quickNew);
$save.click(quickSave);
$share.click(quickShare);
minder.addShortcut('ctrl+alt+n', quickNew);
minder.addShortcut('ctrl+s', quickSave);
minder.addShortcut('ctrl+alt+s', quickShare);
minder.addShortcut('ctrl+shift+s', function() {
var $menu = minder.getUI('menu/menu');
$menu.$tabs.select(2);
$menu.show();
});
});
});
\ No newline at end of file
...@@ -72,7 +72,7 @@ KityMinder.registerUI('widget/locallist', function() { ...@@ -72,7 +72,7 @@ KityMinder.registerUI('widget/locallist', function() {
list.forEach(callback); list.forEach(callback);
} }
load(); load.call(this);
this.get = get; this.get = get;
this.remove = remove; this.remove = remove;
......
...@@ -91,11 +91,15 @@ KityMinder.registerUI('widget/netdiskfinder', function(minder) { ...@@ -91,11 +91,15 @@ KityMinder.registerUI('widget/netdiskfinder', function(minder) {
$input.on('keydown', function(e) { $input.on('keydown', function(e) {
if (e.keyCode == 13) confirm(); if (e.keyCode == 13) confirm();
if (e.keyCode == 27) { if (e.keyCode == 27) {
$li.remove(); cancel();
mkdir.onprogress = false;
e.stopPropagation(); e.stopPropagation();
} }
}); }).on('blur', confirm);
function cancel() {
$li.remove();
mkdir.onprogress = false;
}
function confirm() { function confirm() {
var name = $input.val(); var name = $input.val();
...@@ -106,6 +110,9 @@ KityMinder.registerUI('widget/netdiskfinder', function(minder) { ...@@ -106,6 +110,9 @@ KityMinder.registerUI('widget/netdiskfinder', function(minder) {
}).then(function() { }).then(function() {
return list(currentPath, true); return list(currentPath, true);
}, function(e) { }, function(e) {
if (e.message.indexOf('31061') === 0) {
e.message = '已存在同名目录';
}
window.alert('创建目录失败:' + e.message); window.alert('创建目录失败:' + e.message);
$li.remove(); $li.remove();
}).then(function() { }).then(function() {
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<title>百度脑图 - 便捷的思维导图工具</title> <title>百度脑图 - 便捷的思维导图工具</title>
<script src="import.share.js" charset="utf-8"></script> <script src="import.js?pack=share" charset="utf-8"></script>
<script src="kityminder.config.js" charset="utf-8"></script> <script src="kityminder.config.js" charset="utf-8"></script>
<script src="lang/zh-cn/zh-cn.js" charset="utf-8"></script> <script src="lang/zh-cn/zh-cn.js" charset="utf-8"></script>
......
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