Commit feb0bf6d authored by techird's avatar techird

add package import

parent 3593ebd7
......@@ -9,7 +9,7 @@
<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="lang/zh-cn/zh-cn.js" charset="utf-8"></script>
......@@ -83,8 +83,8 @@
/* jshint browser:true */
$(function() {
/* 依赖库初始化 */
zip.inflateJSPath = 'lib/inflate.js';
/* 依赖库初始化 */
zip.inflateJSPath = 'lib/inflate.js';
});
// create km instance
......@@ -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>
<!--社会分享代码-->
......
This diff is collapsed.
......@@ -20,34 +20,42 @@
/* 核心代码 */
'src/core/kityminder.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/node.js',
'src/core/module.js',
'src/core/event.js',
'src/core/minder.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/data.js',
'src/core/compatibility.js',
'src/core/render.js',
'src/core/connect.js',
'src/core/theme.js',
'src/core/layout.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.connect.js',
'src/layout/bottom.js',
'src/layout/mind.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',
......@@ -55,7 +63,10 @@
'src/theme/fresh.js',
/* 模板 */
'src/template/default.js',
'src/template/structure.js',
'src/template/filetree.js',
'src/template/right.js',
/* 模块 */
'src/module/node.js',
......
......@@ -2,6 +2,8 @@
* 开发版本的文件导入
*/
(function() {
/* 可能的文件路径,已按照依赖关系排序 */
var paths = [
/* 依赖库 */
......@@ -17,28 +19,30 @@
/* 核心代码 */
'src/core/kityminder.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/node.js',
'src/core/module.js',
'src/core/event.js',
'src/core/minder.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/data.js',
'src/core/compatibility.js',
'src/core/render.js',
'src/core/connect.js',
'src/core/theme.js',
'src/core/layout.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',
......
......@@ -61,6 +61,12 @@ KityMinder.LANG['zh-cn'] = {
'view': '视图'
},
'quickvisit': {
'new': '新建',
'save': '保存',
'share': '分享'
},
'menu': {
'mainmenutext': '百度脑图', // 主菜单按钮文本
......@@ -69,8 +75,8 @@ KityMinder.LANG['zh-cn'] = {
'opentab': '打开',
'savetab': '保存',
'sharetab': '分享',
'preferencetab': '设置',
'helptab': '帮助',
'settingtab': '设置',
'recenttab': '最近使用',
'netdisktab': '百度云存储',
'localtab': '本地文件',
......@@ -84,7 +90,8 @@ KityMinder.LANG['zh-cn'] = {
'saveheader': '保存到',
'draftheader': '草稿箱',
'shareheader': '分享我的脑图',
'downloadheader': '导出到指定格式'
'downloadheader': '导出到指定格式',
'preferenceheader': '偏好设置'
},
'mydocument': '我的文档',
......@@ -198,7 +205,9 @@ KityMinder.LANG['zh-cn'] = {
'longago': '很久之前',
'redirect': '您正在打开连接 {0},百度脑图不能保证连接的安全性,是否要继续?',
'navigator': '导航器'
'navigator': '导航器',
'unsavedcontent': '当前文件还没有保存到网盘:\n\n{0}\n\n确定要继续操作么?(未保存的数据会缓存在草稿箱)'
},
'popupcolor': {
'clearColor': '清空颜色',
......
......@@ -99,7 +99,7 @@ kity.extendClass(Minder, {
if (cmd.isSelectionChanged()) {
this._firePharse(new MinderEvent('selectionchange'));
}
this._firePharse(new MinderEvent('interactchange'));
this._interactChange();
}
this._hasEnterExecCommand = false;
} else {
......@@ -110,7 +110,7 @@ kity.extendClass(Minder, {
this._firePharse(new MinderEvent('selectionchange'));
}
this._firePharse(new MinderEvent('interactchange'));
this._interactChange();
}
}
......
......@@ -6,6 +6,11 @@
* @author: techird
* @copyright: Baidu FEX, 2014
*/
Minder.registerInit(function() {
this._initContextMenu();
});
kity.extendClass(Minder, {
_initContextMenu: function() {
this.contextmenus = [];
......
......@@ -11,6 +11,10 @@ var DEFAULT_TEXT = {
'sub': 'topic'
};
Minder.registerInit(function() {
this._initProtocols();
});
// 导入导出
kity.extendClass(Minder, {
......@@ -100,9 +104,7 @@ kity.extendClass(Minder, {
this._firePharse({
type: 'contentchange'
});
this._firePharse({
type: 'interactchange'
});
this._interactChange();
},
exportData: function(protocolName) {
......
......@@ -55,6 +55,10 @@ var MinderEvent = kity.createClass('MindEvent', {
}
});
Minder.registerInit(function() {
this._initEvents();
});
// 事件机制
kity.extendClass(Minder, {
_initEvents: function() {
......@@ -109,8 +113,8 @@ kity.extendClass(Minder, {
preEvent = new MinderEvent('pre' + e.type, e, true);
executeEvent = new MinderEvent(e.type, e, true);
this._fire(preEvent) ||
this._fire(executeEvent) ||
if (this._fire(preEvent) ||
this._fire(executeEvent))
this._fire(new MinderEvent('after' + e.type, e, false));
if (~'mousedown mouseup keydown keyup'.indexOf(e.type)) {
......@@ -120,15 +124,16 @@ kity.extendClass(Minder, {
_interactChange: function(e) {
var minder = this;
clearTimeout(this._interactTimeout);
this._interactTimeout = setTimeout(function() {
var trigger = function trigger() {
var stoped = minder._fire(new MinderEvent('beforeinteractchange'));
if (stoped) {
return;
}
minder._fire(new MinderEvent('preinteractchange'));
minder._fire(new MinderEvent('interactchange'));
}, 20);
};
this._interactTimeout = setTimeout(trigger, 100);
},
_listen: function(type, callback) {
var callbacks = this._eventCallbacks[type] || (this._eventCallbacks[type] = []);
......
......@@ -61,6 +61,10 @@ kity.extendClass(MinderEvent, {
}
});
Minder.registerInit(function() {
this._initShortcutKey();
});
kity.extendClass(Minder, {
_initShortcutKey: function() {
......
......@@ -142,6 +142,14 @@ kity.extendClass(MinderNode, {
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) {
this._layoutVectorIn = v;
return this;
......@@ -206,14 +214,6 @@ kity.extendClass(MinderNode, {
return this.setLayoutOffset(null);
},
getLayoutVertexIn: function() {
return this.getGlobalLayoutTransform().transformPoint(this.getVertexIn());
},
getLayoutVertexOut: function() {
return this.getGlobalLayoutTransform().transformPoint(this.getVertexOut());
},
getLayoutRoot: function() {
if (this.isLayoutRoot()) {
return this;
......@@ -226,6 +226,10 @@ kity.extendClass(MinderNode, {
}
});
Minder.registerInit(function(options) {
this.refresh();
});
kity.extendClass(Minder, {
layout: function(duration) {
......@@ -264,7 +268,7 @@ kity.extendClass(Minder, {
refresh: function(duration) {
this.getRoot().renderTree();
this.layout(duration).fire('contentchange').fire('interactchange');
this.layout(duration).fire('contentchange')._interactChange();
return this;
},
......@@ -319,7 +323,7 @@ kity.extendClass(Minder, {
// 如果要求以动画形式来更新,创建动画
if (duration) {
node._layoutTimeline = new kity.Animator(lastMatrix, matrix, applyMatrix)
.start(node, duration + 300, 'ease')
.start(node, duration, 'ease')
.on('finish', function() {
//可能性能低的时候会丢帧,手动添加一帧
kity.Timeline.requestFrame(function() {
......@@ -499,7 +503,7 @@ var Layout = kity.createClass('Layout', {
treeBox = node.getContentBox();
if (node.children.length) {
if (node.isExpanded() && node.children.length) {
treeBox = g.mergeBox(treeBox, this.getTreeBox(node.children));
}
......
/* jshint -W079 */
var Minder = KityMinder.Minder = kity.createClass('KityMinder', {
constructor: function(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
this._initStatus(options); // @see status.js
this._initPaper(options); // @see paper.js
this._initSelection(options); // @see select.js
this._initShortcutKey(options); // @see key.js
this._initContextMenu(options); // @see contextmenu.js
this._initModules(options); // @see module.js
this._initProtocols(options); // @see data.js
if (this.getOptions('readOnly') === true) {
this.setDisabled(); // @see readonly.js
}
this.refresh(); // @see layout.js
this.setTheme(); // @see theme.js
// @see option.js
// @see event.js
// @see status.js
// @see paper.js
// @see select.js
// @see key.js
// @see contextmenu.js
// @see module.js
// @see data.js
// @see readonly.js
// @see layout.js
// @see theme.js
while (initQueue.length) initQueue.shift().call(this, options);
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 @@
};
} )();
Minder.registerInit(function() {
this._initModules();
});
// 模块声明周期维护
kity.extendClass(Minder, {
_initModules: function() {
......
......@@ -36,4 +36,9 @@ kity.extendClass(Minder, {
setOptions: function(key, val) {
this.setPreferences(key, val);
}
});
Minder.registerInit(function(option) {
this.setDefaultOptions(KM.defaultOptions);
});
\ No newline at end of file
......@@ -6,6 +6,9 @@
* @author: techird
* @copyright: Baidu FEX, 2014
*/
Minder.registerInit(function() {
this._initPaper();
});
kity.extendClass(Minder, {
_initPaper: function() {
......
......@@ -41,7 +41,7 @@ kity.extendClass( Minder, function(){
} )();
return {
setPreferences:function(key,value){
setPreferences: function(key,value){
var obj = {};
if ( Utils.isString( key ) ) {
obj[ key ] = value;
......@@ -57,15 +57,15 @@ kity.extendClass( Minder, function(){
}
LocalStorage.saveLocalData(ROOTKEY,JSON.stringify(data));
},
getPreferences:function(key){
getPreferences: function(key){
var data = LocalStorage.getLocalData(ROOTKEY);
if(data){
data = JSON.parse(data);
return key ? data[key] : data;
}
return null;
return {};
},
resetPreferences:function(pres){
resetPreferences: function(pres){
var str = pres ? JSON.stringify(pres) : '';
LocalStorage.saveLocalData(str);
}
......
......@@ -6,6 +6,11 @@
* @author: techird
* @copyright: Baidu FEX, 2014
*/
Minder.registerInit(function(options) {
if (options.readOnly) {
this.setDisabled();
}
});
kity.extendClass(Minder, {
disable: function() {
......@@ -28,7 +33,7 @@ kity.extendClass(Minder, {
return null;
};
this.setStatus('readonly');
me.fire('interactchange');
me._interactChange();
},
enable: function() {
......@@ -45,6 +50,6 @@ kity.extendClass(Minder, {
this.rollbackStatus();
me.fire('interactchange');
me._interactChange();
}
});
\ No newline at end of file
Minder.registerInit(function() {
this._initSelection();
});
// 选区管理
kity.extendClass(Minder, {
_initSelection: function() {
......@@ -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();
},
getSelectedNodes: function() {
......
......@@ -7,6 +7,10 @@
* @copyright: Baidu FEX, 2014
*/
Minder.registerInit(function() {
this._initStatus();
});
kity.extendClass(Minder, {
_initStatus: function() {
......
......@@ -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() {
if (!changed) return;
var vo = node.getVertexOut();
if (state == STATE_EXPAND) {
var m = node.getGlobalLayoutTransform();
var m = node.getGlobalLayoutTransform().clone().translate(vo.x, vo.y);
node.traverse(function(child) {
child.setGlobalLayoutTransform(m);
child.getRenderContainer().fadeIn();
child.getRenderContainer().setOpacity(0).fadeIn();
}, true);
node.renderTree().getMinder().layout(30);
node.renderTree().getMinder().layout(300);
} else {
node.traverse(function(child) {
child.setLayoutTransform(null);
child.getRenderContainer().fadeOut();
child.setLayoutTransform(child.parent == node ? new kity.Matrix().translate(vo.x, vo.y) : null);
child.getRenderContainer().fadeOut(100);
}, true);
node.getMinder().applyLayoutResult(node, 30).then(function() {
node.renderTree();
node.getMinder().applyLayoutResult(node, 150).then(function() {
node.renderTree().getMinder().layout(150);
});
}
......
......@@ -30,7 +30,6 @@ KityMinder.registerModule('KeyboardModule', function() {
}
}
// 这是金泉的点子,赞!
// 求两个不相交矩形的最近距离
function getCoefedDistance(box1, box2) {
......@@ -114,7 +113,6 @@ KityMinder.registerModule('KeyboardModule', function() {
};
}
function navigateTo(km, direction) {
var referNode = km.getSelectedNode();
if (!referNode) {
......@@ -127,21 +125,36 @@ KityMinder.registerModule('KeyboardModule', function() {
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;
return {
'commands': {
'navparent': NavigateToParentCommand
},
'commandShortcutKeys': {
'navparent': 'shift+tab'
},
'events': {
'layoutallfinish': function() {
var root = this.getRoot();
function build() {
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();
buildPositionNetwork(root);
},
'normal.keydown': function(e) {
var minder = this;
......
......@@ -5,7 +5,7 @@ var AppendChildCommand = kity.createClass('AppendChildCommand', {
if (!parent) {
return null;
}
text = text || km.getLang(parent.isRoot() ? 'maintopic' : 'topic');
text = text || km.getLang('topic');
parent.expand();
var node = km.createNode(text, parent);
km.select(node, true);
......@@ -26,7 +26,7 @@ var AppendSiblingCommand = kity.createClass('AppendSiblingCommand', {
if (!parent) {
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);
km.select(node, true);
node.render();
......
KityMinder.registerModule('PriorityModule', function() {
var minder = this;
// 进度图标使用的颜色
var PRIORITY_COLORS = ['', '#A92E24', '#29A6BD',
'#1E8D54', '#eb6100', '#876DDA', '#828282',
'#828282', '#828282', '#828282'
];
// Designed by Akikonata
// [MASK, BACK]
var PRIORITY_COLORS = [null,
['#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';
// 进度图标的图形
......@@ -24,34 +36,39 @@ KityMinder.registerModule('PriorityModule', function() {
},
create: function() {
var bg, number;
var white, back, mask, number; // 4 layer
bg = new kity.Rect()
.setRadius(3)
.setPosition(0.5, 0.5)
.setSize(this.width, this.height);
white = new kity.Path().setPathData(MASK_PATH).fill('white');
back = new kity.Path().setPathData(BACK_PATH).setTranslate(0.5, 0.5);
mask = new kity.Path().setPathData(MASK_PATH).setOpacity(0.8).setTranslate(0.5, 0.5);
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')
.setVerticalAlign('middle')
.setFontSize(12)
.setFontItalic(true)
.setFontSize(14)
.fill('white');
number.mark = 'hello';
this.addShapes([bg, number]);
this.bg = bg;
this.addShapes([back, mask, number]);
this.mask = mask;
this.back = back;
this.number = number;
},
setValue: function(value) {
var bg = this.bg,
var back = this.back,
mask = this.mask,
number = this.number;
if (PRIORITY_COLORS[value]) {
bg.fill(PRIORITY_COLORS[value]);
number.setContent(value);
var color = PRIORITY_COLORS[value];
if (color) {
back.fill(color[1]);
mask.fill(color[0]);
}
number.setContent(value);
}
});
......
......@@ -3,6 +3,23 @@ KityMinder.registerModule('ProgressModule', function() {
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', {
base: kity.Group,
......@@ -13,6 +30,7 @@ KityMinder.registerModule('ProgressModule', function() {
this.create();
this.setValue(value);
this.setId(KityMinder.uuid('node_progress'));
this.translate(0.5, 0.5);
},
setSize: function(size) {
......@@ -21,30 +39,36 @@ KityMinder.registerModule('ProgressModule', function() {
create: function() {
var circle = new kity.Circle(8)
.stroke('#29A6BD', 2)
.fill('white');
var bg, pie, shadow, frame, check;
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)
.fill('#29A6BD');
frame = new kity.Path()
.setTranslate(-10, -10)
.setPathData(FRAME_PATH)
.fill(FRAME_GRAD);
var check = new kity.Path()
.getDrawer()
.moveTo(-3, -1)
.lineTo(-1, 2)
.lineTo(3, -3)
.getPath()
.stroke('white', 2)
.setVisible(false);
check = new kity.Path()
.setTranslate(-10, -10)
.setPathData(CHECK_PATH)
.fill(CHECK_COLOR);
this.addShapes([circle, pie, check]);
this.circle = circle;
this.addShapes([bg, pie, shadow, check, frame]);
this.pie = pie;
this.check = check;
},
setValue: function(value) {
this.pie.setAngle(360 * (value - 1) / 8);
this.pie.setAngle(-360 * (value - 1) / 8);
this.check.setVisible(value == 9);
}
});
......
......@@ -33,7 +33,9 @@ var ViewDragger = kity.createClass("ViewDragger", {
if (duration) {
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(),
position,
function(target, value) {
......@@ -41,6 +43,10 @@ var ViewDragger = kity.createClass("ViewDragger", {
}
), duration, 'easeOutCubic');
this._moveTimeline.on('finish', function() {
dragger._moveTimeline = null;
});
return this;
}
......@@ -133,6 +139,9 @@ var ViewDragger = kity.createClass("ViewDragger", {
.on('mouseup touchend', dragEnd);
window.addEventListener('mouseup', dragEnd);
this._minder.on('contextmenu', function(e) {
e.preventDefault();
});
}
});
......@@ -183,16 +192,16 @@ KityMinder.registerModule('View', function() {
var size = km._lastClientSize;
switch (dir) {
case 'up':
dragger.move(new kity.Point(0, -size.height / 2), duration);
dragger.move(new kity.Point(0, size.height / 2), duration);
break;
case 'down':
dragger.move(new kity.Point(0, size.height / 2), duration);
dragger.move(new kity.Point(0, -size.height / 2), duration);
break;
case 'left':
dragger.move(new kity.Point(-size.width / 2, 0), duration);
dragger.move(new kity.Point(size.width / 2, 0), duration);
break;
case 'right':
dragger.move(new kity.Point(size.width / 2, 0), duration);
dragger.move(new kity.Point(-size.width / 2, 0), duration);
break;
}
}
......@@ -218,10 +227,14 @@ KityMinder.registerModule('View', function() {
var minder = this;
['up', 'down', 'left', 'right'].forEach(function(name) {
if (e.isShortcutKey('ctrl+' + name)) {
minder.execCommand('move', name, 600);
minder.removeAllSelectedNodes();
minder.execCommand('move', name, 100);
e.preventDefault();
}
});
if (e.isShortcutKey('ctrl+enter')) {
minder.execCommand('camera', minder.getRoot(), 100);
}
},
statuschange: function(e) {
this._viewDragger.setEnabled(e.currentStatus == 'hand');
......@@ -270,6 +283,29 @@ KityMinder.registerModule('View', function() {
this._viewDragger.move(
new kity.Point((a.width - b.width) / 2 | 0, (a.height - b.height) / 2 | 0));
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) {
var ret = minder.getUI('eve').setup({});
var current = {};
var loading = false;
var saved = true;
/**
* 加载文档
......@@ -45,7 +46,7 @@ KityMinder.registerUI('doc', function(minder) {
doc.data = 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);
......@@ -65,7 +66,7 @@ KityMinder.registerUI('doc', function(minder) {
doc.data = minder.exportJson();
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);
}
......@@ -73,6 +74,10 @@ KityMinder.registerUI('doc', function(minder) {
return current;
}
function checkSaved() {
return saved || window.confirm(minder.getLang('ui.unsavedcontent', '* ' + current.title));
}
/* 绕开初始化时候的乱事件 */
setTimeout(function() {
minder.on('contentchange', function() {
......@@ -83,16 +88,16 @@ KityMinder.registerUI('doc', function(minder) {
if (current.source != 'netdisk') {
current.title = minder.getMinderTitle();
$title.setTitle(current.title, false);
$title.setTitle(current.title, saved = false);
ret.fire('docchange', current);
} else {
if (current.json != JSON.stringify(minder.exportJson())) {
$title.setSaved(false);
$title.setSaved(saved = false);
ret.fire('docchange', current);
} else {
$title.setSaved(true);
$title.setSaved(saved = true);
}
}
......@@ -103,6 +108,7 @@ KityMinder.registerUI('doc', function(minder) {
ret.load = load;
ret.save = save;
ret.current = getCurrent;
ret.checkSaved = checkSaved;
return ret;
});
\ No newline at end of file
......@@ -20,20 +20,26 @@ kity.extendClass(FUI.Widget, {
bindExecution: function(event, fn) {
var widget = this;
widget.executionFlag = false;
widget.on(event, function() {
widget.executionFlag = true;
if (widget.interactFlag) return;
fn.apply(widget, arguments);
widget.executionFlag = false;
});
},
bindCommandState: function(minder, command, valueHandle) {
var widget = this;
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.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 @@
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('menu/default', function (minder) {
KityMinder.registerUI('menu/default', function(minder) {
minder.on('uiready', function() {
var $menu = minder.getUI('menu/menu');
var $open = minder.getUI('menu/open/open');
var $recent = minder.getUI('menu/open/recent');
var $save = minder.getUI('menu/save/save');
var $share = minder.getUI('menu/share/share');
var $draft = minder.getUI('menu/open/draft');
$menu.$tabs.select(1); // 打开
$open.$tabs.select(0); // 最近
$save.$tabs.select(0); // 云存储
$share.$tabs.select(0); // 当前脑图
// 主菜单默认选中「打开」
$menu.$tabs.select(1);
// 打开菜单默认选中「本地文件」
$open.$tabs.select(2);
if ($draft.hasDraft()) {
// 草稿箱有草稿,默认选中「草稿箱」,并打开最近编辑的文件
$open.$tabs.select(3);
$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();
});
});
\ No newline at end of file
......@@ -38,11 +38,16 @@ KityMinder.registerUI('menu/menu', function(minder) {
function hide() {
$panel.removeClass('show');
minder.getRenderTarget().focus();
ret.fire('hide');
}
function isVisible() {
return $panel.hasClass('show');
}
function toggle() {
($panel.hasClass('show') ? hide : show)();
(isVisible() ? hide : show)();
}
function createSub(name, asDefault) {
......@@ -75,6 +80,7 @@ KityMinder.registerUI('menu/menu', function(minder) {
ret.show = show;
ret.hide = hide;
ret.toggle = toggle;
ret.isVisible = isVisible;
ret.createSub = createSub;
ret.createSubMenu = createSubMenu;
ret.$panel = $panel;
......
......@@ -35,6 +35,9 @@ KityMinder.registerUI('menu/new/new', function(minder) {
}
$ul.delegate('.template-item', 'click', function(e) {
if (!$doc.checkSaved()) return;
var template = $(e.target).data('template');
$doc.load({
content: {
......@@ -44,7 +47,8 @@ KityMinder.registerUI('menu/new/new', function(minder) {
text: minder.getLang('template')[template]
}
},
protocol: null
protocol: null,
saved: true
});
$menu.hide();
});
......
......@@ -54,6 +54,9 @@ KityMinder.registerUI('menu/open/draft', function(minder) {
lastDoc = null;
$ul.delegate('.draft-list-item', 'click', function(e) {
if (!$doc.checkSaved()) return;
var item = $(e.target).closest('.draft-list-item').data('item');
var index = draftList.findIndex(function(finding) {
......@@ -117,7 +120,6 @@ KityMinder.registerUI('menu/open/draft', function(minder) {
current = null;
}
renderList();
console.log('pop draft');
}
function renderList() {
......
......@@ -55,6 +55,7 @@ KityMinder.registerUI('menu/open/local', function(minder) {
/* 交互事件 */
$pickButton.click(function() {
if (!$doc.checkSaved()) return;
$('<input type="file" />')
.attr('accept', accepts.join())
.on('change', function(e) {
......@@ -67,6 +68,7 @@ KityMinder.registerUI('menu/open/local', function(minder) {
e.preventDefault();
e.stopPropagation();
}).on('drop', function(e) {
if (!$doc.checkSave()) return;
e = e.originalEvent;
read(e.dataTransfer.files[0]);
$menu.hide();
......
......@@ -36,6 +36,7 @@ KityMinder.registerUI('menu/open/netdisk', function(minder) {
});
$finder.on('fileclick', function(file) {
if (!$doc.checkSaved()) return;
return open(file.path);
});
......
......@@ -40,6 +40,8 @@ KityMinder.registerUI('menu/open/recent', function(minder) {
$ul.delegate('.recent-file-item', 'click', function(e) {
if (!doc.checkSaved()) return;
var netdisk = minder.getUI('menu/open/netdisk');
var path = $(e.target)
.closest('.recent-file-item')
......@@ -107,6 +109,9 @@ KityMinder.registerUI('menu/open/recent', function(minder) {
}
return {
hasRecent: function() {
return recentList.length;
},
loadLast: function() {
$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) {
.attr('placeholder', minder.getLang('ui.filename'))
.attr('title', minder.getLang('ui.filename'))
.on('keydown', function(e) {
if (e.keyCode == 27) $menu.toggleClass('show');
if (e.keyCode == 27) $menu.toggle();
if (e.keyCode == 13) save();
})
.appendTo($selects);
......@@ -77,7 +78,29 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) {
$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();
if (fio.file.anlysisPath(filename).extension != $format.val()) {
......@@ -92,16 +115,36 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) {
var match = doc.path == path; // 目标路径正是当前文档
var duplicated = exist && !match;
if (!exist || match || duplicated && window.confirm(minder.getLang('ui.overrideconfirm', filename))) {
doSave(path, protocol, doc);
return {
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({
path: path,
......@@ -111,7 +154,8 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) {
}).then(function() {
$panel.removeClass('loading');
if ($mask) $mask.removeClass('loading');
$menu.hide();
doc.path = path;
......@@ -123,9 +167,10 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) {
setTimeout($finder.list, 500);
})['catch'](function(e) {
window.alert('保存文件失败:' + (e.message || minder.getLang('ui.unknownreason')));
}).then(function(e) {
saving = false;
});
}
......
......@@ -256,7 +256,7 @@ KityMinder.registerUI('menu/share/share', function(minder) {
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;
}
......
......@@ -11,6 +11,8 @@ KityMinder.registerUI('menu/share/view', function (minder) {
var $save = minder.getUI('menu/save/save');
var $doc = minder.getUI('doc');
$menu.$tabs.select(0);
$save.$tabs.select(0);
function loadShareDoc() {
......@@ -65,6 +67,7 @@ KityMinder.registerUI('menu/share/view', function (minder) {
$(minder.getRenderTarget()).removeClass('loading');
minder.execCommand('hand');
minder.disable();
});
}
......
......@@ -9,6 +9,8 @@
KityMinder.registerUI('nav', function(minder) {
var memory = minder.getUI('memory');
var $navBar = $('<div>').addClass('nav-bar').appendTo('#content-wrapper');
var $commandbutton = minder.getUI('widget/commandbutton');
......@@ -60,47 +62,87 @@ KityMinder.registerUI('nav', function(minder) {
return $pan;
}
/**
* 创建导航器的 DOM 元素以及交互的逻辑代码
*/
function createViewNavigator() {
var $previewNavigator = $('<div>')
.addClass('preview-navigator')
.appendTo('#content-wrapper');
var width = $previewNavigator.width();
var height = $previewNavigator.height();
// 画布,渲染缩略图
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 currentView = paper.put(new kity.Rect(100, 100).stroke('red', '1%'));
// 表示可视区域的矩形
var visibleRect = 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) {
dragging = true;
moveView(e.getPosition('top'), 200);
$previewNavigator.addClass('grab');
});
$previewNavigator.show = function() {
$.fn.show.call(this);
bind();
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) {
if (dragging) {
moveView(e.getPosition('top'));
function moveView(center, duration) {
var box = visibleRect.getBox();
center.x = -center.x;
center.y = -center.y;
minder.getViewDragger().moveTo(center.offset(box.width / 2, box.height / 2), duration);
}
});
$(window).on('mouseup', function() {
dragging = false;
$previewNavigator.removeClass('grab');
});
var dragging = false;
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;
paper.setViewBox(
view.x - padding - 0.5,
view.y - padding - 0.5,
......@@ -108,7 +150,7 @@ KityMinder.registerUI('nav', function(minder) {
view.height + padding * 2 + 1);
var nodePathData = [];
var connectPathData = [];
var connectionThumbData = [];
minder.getRoot().traverse(function(node) {
var box = node.getLayoutBox();
......@@ -116,39 +158,33 @@ KityMinder.registerUI('nav', function(minder) {
'h', box.width, 'v', box.height,
'h', -box.width, 'z');
if (node.getConnection() && node.parent && node.parent.isExpanded()) {
connectPathData.push(node.getConnection().getPathData());
connectionThumbData.push(node.getConnection().getPathData());
}
});
paper.setStyle('background', minder.getStyle('background'));
if (nodePathData.length) {
nodePath
nodeThumb
.fill(minder.getStyle('root-background'))
.setPathData(nodePathData);
} else {
nodePath.setPathData(null);
nodeThumb.setPathData(null);
}
if (connectPathData.length) {
connectPath
if (connectionThumbData.length) {
connectionThumb
.stroke(minder.getStyle('connect-color'), '0.5%')
.setPathData(connectPathData);
.setPathData(connectionThumbData);
} else {
connectPath.setPathData(null);
connectionThumb.setPathData(null);
}
}
function updateView() {
var view = minder.getViewDragger().getView();
currentView.setBox(view);
}
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);
function updateVisibleView() {
visibleView = minder.getViewDragger().getView();
visibleRect.setBox(visibleView);
updateContentView();
}
return $previewNavigator;
......@@ -156,16 +192,24 @@ KityMinder.registerUI('nav', function(minder) {
function createPreviewTrigger($previewNavigator) {
var $trigger = $('<div>').addClass('command-button nav-trigger');
$trigger.append('<div class="fui-icon">');
$trigger.click(function() {
$trigger.toggleClass('active');
if ($trigger.hasClass('active')) {
$trigger.click(toggle);
$trigger.attr('title', minder.getLang('ui.navigator'));
function toggle() {
if ($trigger.toggleClass('active').hasClass('active')) {
$previewNavigator.show();
memory.set('navigator-hidden', false);
} else {
$previewNavigator.hide();
memory.set('navigator-hidden', true);
}
}).click();
$trigger.attr('title', minder.getLang('ui.navigator'));
}
if (memory.get('navigator-hidden')) toggle();
toggle();
return $trigger;
}
......
......@@ -8,6 +8,8 @@
*/
KityMinder.registerUI('ribbon/tabs', function(minder) {
var memory = minder.getUI('memory');
var $tab = new FUI.Tabs({
buttons: ['idea', 'appearence'/*, 'view'*/].map(function(key) {
return minder.getLang('ui.tabs.' + key);
......@@ -34,12 +36,19 @@ KityMinder.registerUI('ribbon/tabs', function(minder) {
$container.removeClass('collapsed');
$header.removeClass('collapsed');
}
memory.set('ribbon-tab-collapsed', $container.hasClass('collapsed'));
memory.set('ribbon-tab-index', info.index);
lastIndex = info.index;
});
$tab.idea = $tab.getPanel(0);
$tab.appearence = $tab.getPanel(1);
$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;
});
\ No newline at end of file
......@@ -40,7 +40,6 @@
}
&.undo {
margin-left: 10px;
}
&.redo {
......
......@@ -31,9 +31,16 @@ html, body {
}
#kityminder {
.dock(@panel-height, 0, 0, 0);
.dock(100px, 0, 0, 0);
&.maximize {
top: 40px;
}
-moz-user-select: none;
}
#tab-container.collapsed + #kityminder,
#panel + #kityminder{
top: 40px;
}
#panel {
background: @ui-color;
......@@ -50,6 +57,20 @@ html, body {
text-align: center;
font-weight: normal;
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 - 1);
&.priority-@{count} .fui-icon {
background-position: (-20px * (@count - 1)) 0;
background-position: 0 (-20px * (@count - 1));
}
}
......@@ -18,7 +18,7 @@
display: block;
height: 20px;
width: 20px;
background: url(../images/iconpriority.png) repeat-x;
background: url(../images/iconpriority.png) repeat-y;
background-color: transparent;
}
padding: 2px;
......
.progress-sprite(@count) when (@count >= 0) {
.progress-sprite(@count - 1);
&.progress-@{count} .fui-icon {
background-position: (-20px * (@count - 1)) 0;
background-position: 0 (-20px * (@count - 1));
}
}
......@@ -18,7 +18,7 @@
display: block;
height: 20px;
width: 20px;
background: url(../images/iconprogress.png) repeat-x;
background: url(../images/iconprogress.png) repeat-y;
background-color: transparent;
}
padding: 2px;
......
......@@ -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-target {
......@@ -100,21 +112,12 @@ input[type=url] {
&:before {
content: ' ';
width: 40px;
height: 40px;
border: 4px solid;
border-color: @border-color transparent transparent;
box-shadow: 0 0 35px white;
.loading-circle;
position: absolute;
left: 50%;
top: 50%;
margin-left: -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 {
width: 40px;
height: 40px;
border: 4px solid;
border-color: #ffffff transparent transparent;
box-shadow: 0 0 35px white;
position: absolute;
left: 50%;
top: 50%;
margin-left: -24px;
margin-top: -24px;
border-color: #c9ced1 transparent transparent;
box-shadow: 0 0 35px #ffffff;
z-index: 10;
border-radius: 100%;
-webkit-animation: rotate 1.33s ease infinite;
......@@ -657,6 +652,11 @@ input[type=url]:focus {
animation: rotate 1.33s ease infinite;
filter: none;
-webkit-filter: none;
position: absolute;
left: 50%;
top: 50%;
margin-left: -24px;
margin-top: -24px;
}
@-webkit-keyframes rotate {
from {
......@@ -1332,12 +1332,19 @@ body {
}
#kityminder {
position: absolute;
top: 40px;
top: 100px;
right: 0;
bottom: 0;
left: 0;
-moz-user-select: none;
}
#kityminder.maximize {
top: 40px;
}
#tab-container.collapsed + #kityminder,
#panel + #kityminder {
top: 40px;
}
#panel {
background: #393f4f;
font-family: 'Hiragino Sans GB', 'Arial', 'Microsoft Yahei';
......@@ -1354,6 +1361,30 @@ body {
font-weight: normal;
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 {
-webkit-font-smoothing: auto;
}
......@@ -1709,6 +1740,46 @@ body {
.new-file-template-select li:active:before {
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.redo {
float: left;
......@@ -1752,9 +1823,6 @@ body {
.command-button.redo.fui-disabled .fui-icon {
background-position-y: 0;
}
.command-button.undo {
margin-left: 10px;
}
.command-button.redo .fui-icon {
background-position-x: -40px;
}
......@@ -2404,38 +2472,38 @@ body {
display: block;
height: 20px;
width: 20px;
background: url(../images/iconpriority.png) repeat-x;
background: url(../images/iconpriority.png) repeat-y;
background-color: transparent;
}
#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 {
background-position: 0px 0;
background-position: 0 0px;
}
#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 {
background-position: -40px 0;
background-position: 0 -40px;
}
#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 {
background-position: -80px 0;
background-position: 0 -80px;
}
#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 {
background-position: -120px 0;
background-position: 0 -120px;
}
#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 {
background-position: -160px 0;
background-position: 0 -160px;
}
#tab-container .command-buttonset.priority .fui-button.fui-button-pressed {
background-color: #c4d0ee;
......@@ -2457,38 +2525,38 @@ body {
display: block;
height: 20px;
width: 20px;
background: url(../images/iconprogress.png) repeat-x;
background: url(../images/iconprogress.png) repeat-y;
background-color: transparent;
}
#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 {
background-position: 0px 0;
background-position: 0 0px;
}
#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 {
background-position: -40px 0;
background-position: 0 -40px;
}
#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 {
background-position: -80px 0;
background-position: 0 -80px;
}
#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 {
background-position: -120px 0;
background-position: 0 -120px;
}
#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 {
background-position: -160px 0;
background-position: 0 -160px;
}
#tab-container .command-buttonset.progress .fui-button.fui-button-pressed {
background-color: #c4d0ee;
......
This diff is collapsed.
......@@ -8,6 +8,7 @@
@import "_kityminder";
@import "_mainmenu";
@import "_mainmenu.new.less";
@import "_quickvisit.less";
@import "_history";
@import "_tab";
@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() {
list.forEach(callback);
}
load();
load.call(this);
this.get = get;
this.remove = remove;
......
......@@ -91,11 +91,15 @@ KityMinder.registerUI('widget/netdiskfinder', function(minder) {
$input.on('keydown', function(e) {
if (e.keyCode == 13) confirm();
if (e.keyCode == 27) {
$li.remove();
mkdir.onprogress = false;
cancel();
e.stopPropagation();
}
});
}).on('blur', confirm);
function cancel() {
$li.remove();
mkdir.onprogress = false;
}
function confirm() {
var name = $input.val();
......@@ -106,6 +110,9 @@ KityMinder.registerUI('widget/netdiskfinder', function(minder) {
}).then(function() {
return list(currentPath, true);
}, function(e) {
if (e.message.indexOf('31061') === 0) {
e.message = '已存在同名目录';
}
window.alert('创建目录失败:' + e.message);
$li.remove();
}).then(function() {
......
......@@ -9,7 +9,7 @@
<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="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