Commit 104a05e7 authored by campaign's avatar campaign

Merge branch 'dev' of https://github.com/fex-team/kityminder into dev

parents 41ecad4f f44593c4
dialogs/markers/images/iconpriority.png

3.74 KB | W: | H:

dialogs/markers/images/iconpriority.png

4.44 KB | W: | H:

dialogs/markers/images/iconpriority.png
dialogs/markers/images/iconpriority.png
dialogs/markers/images/iconpriority.png
dialogs/markers/images/iconpriority.png
  • 2-up
  • Swipe
  • Onion skin
dialogs/markers/images/iconprogress.png

3.74 KB | W: | H:

dialogs/markers/images/iconprogress.png

5.06 KB | W: | H:

dialogs/markers/images/iconprogress.png
dialogs/markers/images/iconprogress.png
dialogs/markers/images/iconprogress.png
dialogs/markers/images/iconprogress.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -7,20 +7,39 @@
".kmui-dialog-<%= container %> .icon.p3{background-position: -40px 0}" +
".kmui-dialog-<%= container %> .icon.p4{background-position: -60px 0}" +
".kmui-dialog-<%= container %> .icon.p5{background-position: -80px 0}" +
".kmui-dialog-<%= container %> .icon.p6{background-position: -100px 0}" +
".kmui-dialog-<%= container %> .icon.p7{background-position: -120px 0}" +
".kmui-dialog-<%= container %> .icon.p8{background-position: -140px 0}" +
".kmui-dialog-<%= container %> .icon.p9{background-position: -160px 0}" +
".kmui-dialog-<%= container %> .icon.p0{background-position: -180px 0}" +
".kmui-dialog-<%= container %> ul li{width:40%;display:inline-block}" +
".kmui-dialog-<%= container %> h4{padding:5px 10px; margin:0; background:#eee}" +
"</style>" +
"<h4><%= priority %></h3>" +
"<ul class='icon-list priority'>" +
"<li value='1' type='priority'><span class='icon p1'></span><span><%= priority %>1</span></li>" +
"<li value='2' type='priority'><span class='icon p2'></span><span><%= priority %>2</span></li>" +
"<li value='3' type='priority'><span class='icon p3'></span><span><%= priority %>3</span></li>" +
"<li value='4' type='priority'><span class='icon p4'></span><span><%= priority %>4</span></li>" +
"<li value='5' type='priority'><span class='icon p5'></span><span><%= priority %>5</span></li>" +
"<li value='6' type='priority'><span class='icon p6'></span><span><%= priority %>6</span></li>" +
"<li value='7' type='priority'><span class='icon p7'></span><span><%= priority %>7</span></li>" +
"<li value='8' type='priority'><span class='icon p8'></span><span><%= priority %>8</span></li>" +
"<li value='9' type='priority'><span class='icon p9'></span><span><%= priority %>9</span></li>" +
"<li value='0' type='priority'><span class='icon p0'></span><span><%= none %></span></li>" +
"</ul>" +
"<h4><%= progress.title %></h4>" +
"<ul class='icon-list progress'>" +
"<li value='1' type='progress'><span class='icon p1'></span><span><%= progress.notdone %></span></li>" +
"<li value='2' type='progress'><span class='icon p2'></span><span><%= progress.quarterdone %></span></li>" +
"<li value='3' type='progress'><span class='icon p3'></span><span><%= progress.halfdone %></span></li>" +
"<li value='4' type='progress'><span class='icon p4'></span><span><%= progress.threequartersdone %></span></li>" +
"<li value='5' type='progress'><span class='icon p5'></span><span><%= progress.done %></span></li>" +
"<li value='2' type='progress'><span class='icon p2'></span><span><%= progress.done1 %></span></li>" +
"<li value='3' type='progress'><span class='icon p3'></span><span><%= progress.done2 %></span></li>" +
"<li value='4' type='progress'><span class='icon p4'></span><span><%= progress.done3 %></span></li>" +
"<li value='5' type='progress'><span class='icon p5'></span><span><%= progress.done4 %></span></li>" +
"<li value='6' type='progress'><span class='icon p6'></span><span><%= progress.done5 %></span></li>" +
"<li value='7' type='progress'><span class='icon p7'></span><span><%= progress.done6 %></span></li>" +
"<li value='8' type='progress'><span class='icon p8'></span><span><%= progress.done7 %></span></li>" +
"<li value='9' type='progress'><span class='icon p9'></span><span><%= progress.done %></span></li>" +
"<li value='0' type='progress'><span class='icon p0'></span><span><%= none %></span></li>" +
"</ul>",
initContent: function (km, $w) {
var lang = km.getLang('dialogs.markers');
......@@ -30,8 +49,8 @@
}, lang));
}
this.root().html(html);
var valPri = km.queryCommandValue("priority");
var valPro = km.queryCommandValue("progress");
var valPri = km.queryCommandValue("priority") || 0;
var valPro = km.queryCommandValue("progress") || 0;
$w.find("li[type='priority']").removeClass("active");
$w.find("li[type='priority'][value='" + valPri + "']").addClass("active");
$w.find("li[type='progress']").removeClass("active");
......@@ -41,11 +60,7 @@
$w.on("click", "li", function () {
var $this = $(this);
$this.siblings().removeClass("active");
$this.toggleClass("active");
var val = $this.val();
if (!$this.hasClass("active")) {
val = null;
}
var type = $this.attr("type");
km.execCommand(type, val);
});
......
( function () {
function getKMBasePath( docUrl, confUrl ) {
(function () {
function getKMBasePath(docUrl, confUrl) {
return getBasePath( docUrl || self.document.URL || self.location.href, confUrl || getConfigFilePath() );
return getBasePath(docUrl || self.document.URL || self.location.href, confUrl || getConfigFilePath());
}
function getConfigFilePath() {
var configPath = document.getElementsByTagName( 'script' );
var configPath = document.getElementsByTagName('script');
return configPath[ configPath.length - 1 ].src;
return configPath[configPath.length - 1].src;
}
function getBasePath( docUrl, confUrl ) {
function getBasePath(docUrl, confUrl) {
var basePath = confUrl;
if ( /^(\/|\\\\)/.test( confUrl ) ) {
if (/^(\/|\\\\)/.test(confUrl)) {
basePath = /^.+?\w(\/|\\\\)/.exec( docUrl )[ 0 ] + confUrl.replace( /^(\/|\\\\)/, '' );
basePath = /^.+?\w(\/|\\\\)/.exec(docUrl)[0] + confUrl.replace(/^(\/|\\\\)/, '');
} else if ( !/^[a-z]+:/i.test( confUrl ) ) {
} else if (!/^[a-z]+:/i.test(confUrl)) {
docUrl = docUrl.split( "#" )[ 0 ].split( "?" )[ 0 ].replace( /[^\\\/]+$/, '' );
docUrl = docUrl.split("#")[0].split("?")[0].replace(/[^\\\/]+$/, '');
basePath = docUrl + "" + confUrl;
}
return optimizationPath( basePath );
return optimizationPath(basePath);
}
function optimizationPath( path ) {
function optimizationPath(path) {
var protocol = /^[a-z]+:\/\//.exec( path )[ 0 ],
var protocol = /^[a-z]+:\/\//.exec(path)[0],
tmp = null,
res = [];
path = path.replace( protocol, "" ).split( "?" )[ 0 ].split( "#" )[ 0 ];
path = path.replace(protocol, "").split("?")[0].split("#")[0];
path = path.replace( /\\/g, '/' ).split( /\// );
path = path.replace(/\\/g, '/').split(/\//);
path[ path.length - 1 ] = "";
path[path.length - 1] = "";
while ( path.length ) {
while (path.length) {
if ( ( tmp = path.shift() ) === ".." ) {
if ((tmp = path.shift()) === "..") {
res.pop();
} else if ( tmp !== "." ) {
res.push( tmp );
} else if (tmp !== ".") {
res.push(tmp);
}
}
return protocol + res.join( "/" );
return protocol + res.join("/");
}
window.KITYMINDER_CONFIG = {
'KITYMINDER_HOME_URL': getKMBasePath(),
//定义工具栏
toolbars: [
'hand | zoom-in zoom zoom-out | collapsenode expandnode | undo redo | bold italic | fontfamily fontsize forecolor | saveto | hyperlink unhyperlink image removeimage | markers resource | node | help'
'hand | zoom-in zoom zoom-out | collapsenode expandnode | undo redo | bold italic | fontfamily fontsize forecolor | saveto | switchlayout | hyperlink unhyperlink image removeimage | markers resource | node | help'
]
//只读模式,默认是false
//readOnly: true
......@@ -95,4 +95,4 @@
//,maxImageHeight: 200
//
};
} )();
\ No newline at end of file
})();
\ No newline at end of file
KityMinder.LANG[ 'zh-cn' ] = {
KityMinder.LANG['zh-cn'] = {
'maintopic': '中心主题',
'topic': '分支主题',
'tooltips': {
......@@ -39,11 +39,17 @@ KityMinder.LANG[ 'zh-cn' ] = {
'lang_input_target': '是否在新窗口打开:'
},
'priority': '优先级',
'none': '无',
'progress': {
'title': '进度',
'notdone': "未完成",
'quarterdone': '完成1/4',
'halfdone': '完成1/2',
'threequartersdone': '完成3/4',
'done1': '完成1/8',
'done2': '完成1/4',
'done3': '完成3/8',
'done4': '完成1/2',
'done5': '完成5/8',
'done6': '完成3/4',
'done7': '完成7/8',
'done': '已完成'
}
},
......@@ -52,8 +58,7 @@ KityMinder.LANG[ 'zh-cn' ] = {
},
'hyperlink': {},
'image': {},
'resource': {
}
'resource': {}
},
'node': {
'appendsiblingnode': '插入同级节点',
......@@ -65,11 +70,11 @@ KityMinder.LANG[ 'zh-cn' ] = {
'default': '左右展开',
'bottom': '向下展开'
},
'hyperlink':{
'hyperlink':'插入超链接',
'unhyperlink':"取消超链接"
'hyperlink': {
'hyperlink': '插入超链接',
'unhyperlink': "取消超链接"
},
'image':{
'image': {
'image': '插入图片',
'removeimage': '删除图片'
}
......
KM.registerToolbarUI( 'switchlayout', function ( name ) {
KM.registerToolbarUI('switchlayout', function (name) {
var me = this,
label = me.getLang( 'tooltips.' + name ),
label = me.getLang('tooltips.' + name),
options = {
label: label,
title: label,
......@@ -13,54 +12,55 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) {
enabledRecord: false
},
$combox = null;
if ( options.items.length == 0 ) {
if (options.items.length == 0) {
return null;
}
utils.each( options.items, function ( i, item ) {
options.items[ i ] = me.getLang( 'layout' )[ item ];
} );
utils.each(options.items, function (i, item) {
options.items[i] = me.getLang('layout')[item];
});
//实例化
$combox = $.kmuibuttoncombobox( options ).css( 'zIndex', me.getOptions( 'zIndex' ) + 1 );
$combox = $.kmuibuttoncombobox(options).css('zIndex', me.getOptions('zIndex') + 1);
var comboboxWidget = $combox.kmui();
comboboxWidget.on( 'comboboxselect', function ( evt, res ) {
me.execCommand( name, res.value );
} ).on( "beforeshow", function () {
if ( $combox.parent().length === 0 ) {
$combox.appendTo( me.$container.find( '.kmui-dialog-container' ) );
comboboxWidget.on('comboboxselect', function (evt, res) {
me.execCommand(name, res.value);
me.initStyle();
}).on("beforeshow", function () {
if ($combox.parent().length === 0) {
$combox.appendTo(me.$container.find('.kmui-dialog-container'));
}
} );
});
//状态反射
me.on( 'interactchange', function () {
var state = this.queryCommandState( name ),
value = this.queryCommandValue( name );
me.on('interactchange', function () {
var state = this.queryCommandState(name),
value = this.queryCommandValue(name);
//设置按钮状态
comboboxWidget.button().kmui().disabled( state == -1 ).active( state == 1 );
comboboxWidget.button().kmui().disabled(state == -1).active(state == 1);
if ( value ) {
if (value) {
//设置label
value = value.replace( /['"]/g, '' ).toLowerCase().split( /['|"]?\s*,\s*[\1]?/ );
comboboxWidget.selectItemByLabel( value );
value = value.replace(/['"]/g, '').toLowerCase().split(/['|"]?\s*,\s*[\1]?/);
comboboxWidget.selectItemByLabel(value);
}
} );
});
var data = [];
utils.each( me.getLayoutStyleItems(), function ( i, v ) {
data.push( {
label: me.getLang( 'tooltips.' + name ) + ' ' + v,
utils.each(me.getLayoutStyleItems(), function (i, v) {
data.push({
label: me.getLang('tooltips.' + name) + ' ' + v,
cmdName: 'switchlayout',
exec: function () {
me.execCommand( 'switchlayout', v );
me.execCommand('switchlayout', v);
}
} )
} );
data.push( {
})
});
data.push({
divider: 1
} );
me.addContextmenu( data );
return comboboxWidget.button().addClass( 'kmui-combobox' );
} );
\ No newline at end of file
});
me.addContextmenu(data);
return comboboxWidget.button().addClass('kmui-combobox');
});
\ No newline at end of file
KityMinder.registerModule( "IconModule", function () {
KityMinder.registerModule("IconModule", function () {
var minder = this;
var renderPriorityIcon = function ( node, val ) {
var colors = [ "", "#A92E24", "#29A6BD", "#1E8D54", "#eb6100", "#876DDA" ];
var _bg = new kity.Rect().fill( colors[ val ] ).setRadius( 3 ).setWidth( 20 ).setHeight( 20 );
var _number = new kity.Text().setContent( val ).fill( "white" ).setSize( 12 );
var renderPriorityIcon = function (node, val) {
var colors = ["", "#A92E24", "#29A6BD", "#1E8D54", "#eb6100", "#876DDA", "#828282", "#828282", "#828282", "#828282"];
var bgcolor = colors[val];
var _bg = new kity.Rect().fill(colors[val]).setRadius(3).setWidth(20).setHeight(20);
var _number = new kity.Text().setContent(val).fill("white").setSize(12);
var _rc = new kity.Group();
_rc.addShapes( [ _bg, _number ] );
node.getContRc().addShape( _rc );
_number.setTranslate( 6, 15 );
_rc.addShapes([_bg, _number]);
node.getContRc().addShape(_rc);
_number.setTranslate(6, 15);
var rcHeight = _rc.getHeight();
_rc.setTranslate( 0, -rcHeight / 2 );
_rc.setTranslate(0, -rcHeight / 2);
};
var renderProgressIcon = function ( node, val ) {
var renderProgressIcon = function (node, val) {
var _rc = new kity.Group();
var _contRc = node.getContRc();
var _bg = new kity.Circle().setRadius( 8 ).fill( "white" ).stroke( new kity.Pen( "#29A6BD", 2 ) );
var _bg = new kity.Circle().setRadius(8).fill("white").stroke(new kity.Pen("#29A6BD", 2));
var _percent, d;
if ( val < 5 ) {
if (val < 9) {
_percent = new kity.Path();
d = _percent.getDrawer();
d.moveTo( 0, 0 ).lineTo( 6, 0 );
d.moveTo(0, 0).lineTo(0, -6);
} else _percent = new kity.Group();
_rc.addShapes( [ _bg, _percent ] );
_contRc.addShape( _rc );
switch ( val ) {
_rc.addShapes([_bg, _percent]);
_contRc.addShape(_rc);
//r, laf, sf, x, y
//large-arc-flag 为1 表示大角度弧线,0 代表小角度弧线。
//sweep-flag 为1代表从起点到终点弧线绕中心顺时针方向,0 代表逆时针方向。
switch (val) {
case 1:
break;
case 2:
d.carcTo( 6, 0, 0, 0, -6 );
d.carcTo(6, 0, 1, 6 * Math.cos(2 * Math.PI / 8), -6 * Math.sin(2 * Math.PI / 8));
break;
case 3:
d.carcTo( 6, 0, 0, -6, 0 );
d.carcTo(6, 0, 1, 6, 0);
break;
case 4:
d.carcTo( 6, 1, 0, 0, 6 );
d.carcTo(6, 0, 1, 6 * Math.cos(2 * Math.PI / 8), 6 * Math.sin(2 * Math.PI / 8));
break;
case 5:
d.carcTo(6, 0, 1, 0, 6);
break;
case 6:
d.carcTo(6, 1, 1, -6 * Math.cos(2 * Math.PI / 8), 6 * Math.sin(2 * Math.PI / 8));
break;
case 7:
d.carcTo(6, 1, 1, -6, 0);
break;
case 8:
d.carcTo(6, 1, 1, -6 * Math.cos(2 * Math.PI / 8), -6 * Math.sin(2 * Math.PI / 8));
break;
case 9:
var check = new kity.Path();
_percent.addShapes( [ new kity.Circle().setRadius( 6 ).fill( "#29A6BD" ), check ] );
check.getDrawer().moveTo( -3, 0 ).lineTo( -1, 3 ).lineTo( 3, -2 );
check.stroke( new kity.Pen( "white", 2 ).setLineCap( "round" ) );
_percent.addShapes([new kity.Circle().setRadius(6).fill("#29A6BD"), check]);
check.getDrawer().moveTo(-3, 0).lineTo(-1, 3).lineTo(3, -2);
check.stroke(new kity.Pen("white", 2).setLineCap("round"));
break;
}
if ( val < 5 ) d.close();
_percent.fill( "#29A6BD" );
var pre = node.getData( "PriorityIcon" );
var style = minder.getCurrentLayoutStyle()[ node.getType() ];
if ( !pre ) _rc.setTranslate( _rc.getWidth() / 2, 0 );
else _rc.setTranslate( _contRc.getWidth() + style.spaceLeft, 0 );
if (val && val < 8) d.close();
_percent.fill("#29A6BD");
var pre = node.getData("PriorityIcon");
var style = minder.getCurrentLayoutStyle()[node.getType()];
if (!pre) _rc.setTranslate(_rc.getWidth() / 2, 0);
else _rc.setTranslate(_contRc.getWidth() + style.spaceLeft, 0);
};
var setPriorityCommand = kity.createClass( "SetPriorityCommand", ( function () {
var setPriorityCommand = kity.createClass("SetPriorityCommand", (function () {
return {
base: Command,
execute: function ( km, value ) {
execute: function (km, value) {
var nodes = km.getSelectedNodes();
for ( var i = 0; i < nodes.length; i++ ) {
nodes[ i ].setData( "PriorityIcon", value );
km.updateLayout( nodes[ i ] );
for (var i = 0; i < nodes.length; i++) {
nodes[i].setData("PriorityIcon", value);
km.updateLayout(nodes[i]);
}
},
queryValue: function ( km ) {
queryValue: function (km) {
var nodes = km.getSelectedNodes();
var val;
for ( var i = 0; i < nodes.length; i++ ) {
val = nodes[ i ].getData( "PriorityIcon" );
if ( val ) break;
for (var i = 0; i < nodes.length; i++) {
val = nodes[i].getData("PriorityIcon");
if (val) break;
}
return val;
}
};
} )() );
var setProgressCommand = kity.createClass( "SetProgressCommand", ( function () {
})());
var setProgressCommand = kity.createClass("SetProgressCommand", (function () {
return {
base: Command,
execute: function ( km, value ) {
execute: function (km, value) {
var nodes = km.getSelectedNodes();
for ( var i = 0; i < nodes.length; i++ ) {
nodes[ i ].setData( "ProgressIcon", value );
km.updateLayout( nodes[ i ] );
for (var i = 0; i < nodes.length; i++) {
nodes[i].setData("ProgressIcon", value);
km.updateLayout(nodes[i]);
}
},
queryValue: function ( km ) {
queryValue: function (km) {
var nodes = km.getSelectedNodes();
var val;
for ( var i = 0; i < nodes.length; i++ ) {
val = nodes[ i ].getData( "ProgressIcon" );
if ( val ) break;
for (var i = 0; i < nodes.length; i++) {
val = nodes[i].getData("ProgressIcon");
if (val) break;
}
return val;
}
};
} )() );
})());
return {
"commands": {
"priority": setPriorityCommand,
"progress": setProgressCommand
},
"events": {
"RenderNodeLeft": function ( e ) {
"RenderNodeLeft": function (e) {
var node = e.node;
var PriorityIconVal = node.getData( "PriorityIcon" );
var ProgressIconVal = node.getData( "ProgressIcon" );
var PriorityIconVal = node.getData("PriorityIcon");
var ProgressIconVal = node.getData("ProgressIcon");
var contRc = node.getContRc();
if ( PriorityIconVal ) {
renderPriorityIcon( node, PriorityIconVal );
if (PriorityIconVal) {
renderPriorityIcon(node, PriorityIconVal);
}
if ( ProgressIconVal ) {
renderProgressIcon( node, ProgressIconVal );
if (ProgressIconVal) {
renderProgressIcon(node, ProgressIconVal);
}
}
}
};
} );
\ No newline at end of file
});
\ No newline at end of file
KityMinder.registerModule( "KeyboardModule", function () {
KityMinder.registerModule("KeyboardModule", function () {
var min = Math.min,
max = Math.max,
abs = Math.abs,
sqrt = Math.sqrt,
exp = Math.exp;
function buildPositionNetwork( root ) {
function buildPositionNetwork(root) {
var pointIndexes = [],
p;
root.traverse( function ( node ) {
p = node.getRenderContainer().getRenderBox( 'top' );
root.traverse(function (node) {
p = node.getRenderContainer().getRenderBox('top');
// bugfix: 不应导航到收起的节点(判断其尺寸是否存在)
if ( p.width && p.height ) {
pointIndexes.push( {
if (p.width && p.height) {
pointIndexes.push({
left: p.x,
top: p.y,
right: p.x + p.width,
......@@ -22,30 +22,30 @@ KityMinder.registerModule( "KeyboardModule", function () {
height: p.height,
node: node,
text: node.getText()
} );
});
}
} );
for ( var i = 0; i < pointIndexes.length; i++ ) {
findClosestPointsFor( pointIndexes, i );
});
for (var i = 0; i < pointIndexes.length; i++) {
findClosestPointsFor(pointIndexes, i);
}
}
// 这是金泉的点子,赞!
// 求两个不相交矩形的最近距离
function getCoefedDistance( box1, box2 ) {
function getCoefedDistance(box1, box2) {
var xMin, xMax, yMin, yMax, xDist, yDist, dist, cx, cy;
xMin = min( box1.left, box2.left );
xMax = max( box1.right, box2.right );
yMin = min( box1.top, box2.top );
yMax = max( box1.bottom, box2.bottom );
xMin = min(box1.left, box2.left);
xMax = max(box1.right, box2.right);
yMin = min(box1.top, box2.top);
yMax = max(box1.bottom, box2.bottom);
xDist = xMax - xMin - box1.width - box2.width;
yDist = yMax - yMin - box1.height - box2.height;
if ( xDist < 0 ) dist = yDist;
else if ( yDist < 0 ) dist = xDist;
else dist = sqrt( xDist * xDist + yDist * yDist );
if (xDist < 0) dist = yDist;
else if (yDist < 0) dist = xDist;
else dist = sqrt(xDist * xDist + yDist * yDist);
return {
cx: dist,
......@@ -53,21 +53,22 @@ KityMinder.registerModule( "KeyboardModule", function () {
};
}
function findClosestPointsFor( pointIndexes, iFind ) {
var find = pointIndexes[ iFind ];
var most = {}, quad;
function findClosestPointsFor(pointIndexes, iFind) {
var find = pointIndexes[iFind];
var most = {},
quad;
var current, dist;
for ( var i = 0; i < pointIndexes.length; i++ ) {
for (var i = 0; i < pointIndexes.length; i++) {
if ( i == iFind ) continue;
current = pointIndexes[ i ];
if (i == iFind) continue;
current = pointIndexes[i];
dist = getCoefedDistance( current, find );
dist = getCoefedDistance(current, find);
// left check
if ( current.right < find.left ) {
if ( !most.left || dist.cx < most.left.dist ) {
if (current.right < find.left) {
if (!most.left || dist.cx < most.left.dist) {
most.left = {
dist: dist.cx,
node: current.node
......@@ -76,8 +77,8 @@ KityMinder.registerModule( "KeyboardModule", function () {
}
// right check
if ( current.left > find.right ) {
if ( !most.right || dist.cx < most.right.dist ) {
if (current.left > find.right) {
if (!most.right || dist.cx < most.right.dist) {
most.right = {
dist: dist.cx,
node: current.node
......@@ -86,8 +87,8 @@ KityMinder.registerModule( "KeyboardModule", function () {
}
// top check
if ( current.bottom < find.top ) {
if ( !most.top || dist.cy < most.top.dist ) {
if (current.bottom < find.top) {
if (!most.top || dist.cy < most.top.dist) {
most.top = {
dist: dist.cy,
node: current.node
......@@ -96,8 +97,8 @@ KityMinder.registerModule( "KeyboardModule", function () {
}
// bottom check
if ( current.top > find.bottom ) {
if ( !most.down || dist.cy < most.down.dist ) {
if (current.top > find.bottom) {
if (!most.down || dist.cy < most.down.dist) {
most.down = {
dist: dist.cy,
node: current.node
......@@ -114,63 +115,63 @@ KityMinder.registerModule( "KeyboardModule", function () {
}
function navigateTo( km, direction ) {
function navigateTo(km, direction) {
var referNode = km.getSelectedNode();
if ( !referNode ) {
km.select( km.getRoot() );
buildPositionNetwork( km.getRoot() );
if (!referNode) {
km.select(km.getRoot());
buildPositionNetwork(km.getRoot());
return;
}
var nextNode = referNode._nearestNodes[ direction ];
if ( nextNode ) {
km.select( nextNode, true );
var nextNode = referNode._nearestNodes[direction];
if (nextNode) {
km.select(nextNode, true);
}
}
return {
"events": {
contentchange: function () {
buildPositionNetwork( this.getRoot() );
buildPositionNetwork(this.getRoot());
},
"normal.keydown": function ( e ) {
"normal.keydown": function (e) {
var keys = KityMinder.keymap;
var node = e.getTargetNode();
this.receiver.keydownNode = node;
switch ( e.originEvent.keyCode ) {
switch (e.originEvent.keyCode) {
case keys.Enter:
this.execCommand( 'appendSiblingNode', new MinderNode( this.getLang().topic ), true );
this.execCommand('appendSiblingNode', new MinderNode(this.getLang().topic));
e.preventDefault();
break;
case keys.Tab:
this.execCommand( 'appendChildNode', new MinderNode( this.getLang().topic ), true );
this.execCommand('appendChildNode', new MinderNode(this.getLang().topic));
e.preventDefault();
break;
case keys.Backspace:
case keys.Del:
e.preventDefault();
this.execCommand( 'removenode' );
this.execCommand('removenode');
break;
case keys.F2:
e.preventDefault();
this.execCommand( 'editnode' );
this.execCommand('editnode');
break;
case keys.Left:
navigateTo( this, 'left' );
navigateTo(this, 'left');
e.preventDefault();
break;
case keys.Up:
navigateTo( this, 'top' );
navigateTo(this, 'top');
e.preventDefault();
break;
case keys.Right:
navigateTo( this, 'right' );
navigateTo(this, 'right');
e.preventDefault();
break;
case keys.Down:
navigateTo( this, 'down' );
navigateTo(this, 'down');
e.preventDefault();
break;
}
......@@ -178,4 +179,4 @@ KityMinder.registerModule( "KeyboardModule", function () {
}
}
};
} );
\ No newline at end of file
});
\ No newline at end of file
This diff is collapsed.
......@@ -396,12 +396,16 @@ KityMinder.registerModule("LayoutDefault", function () {
minder.getRenderContainer().addShape(connect);
}
connect = Layout.connect;
var parentShape = node.getParent().getRenderContainer();
var parent = node.getParent();
var parentShape = parent.getRenderContainer();
var parentBox = parentShape.getRenderBox();
var parentLayout = node.getParent().getLayout();
var parentLayout = parent.getLayout();
var parentStyle = nodeStyles[node.getParent().getType()];
var Shape = node.getRenderContainer();
var sX, sY = parentLayout.y;
var sX, sY = parentBox.bottom - 5;
if (parent.getType() === 'main') {
sY = (parentBox.top + parentBox.bottom) / 2
}
var nodeX, nodeY = Shape.getRenderBox().closurePoints[1].y;
if (Layout.appendside === "left") {
sX = parentBox.closurePoints[1].x - parentStyle.margin[1];
......@@ -587,11 +591,11 @@ KityMinder.registerModule("LayoutDefault", function () {
}
}
},
appendChildNode: function (parent, node, focus, sibling) {
appendChildNode: function (parent, node, sibling) {
minder.handelNodeInsert(node);
var Layout = node.getLayout();
node.clearLayout();
node.getContRc().clear();
var Layout = node.getLayout();
Layout = node.getLayout();
Layout.added = true;
var parentLayout = parent.getLayout();
......@@ -690,16 +694,13 @@ KityMinder.registerModule("LayoutDefault", function () {
updateConnectAndshIcon(set [i]);
}
// if ( focus ) {
// showNodeInView( node );
// }
parent.expand();
var shicon = parent.getLayout().shicon;
if (shicon) shicon.switchState(true);
},
appendSiblingNode: function (sibling, node, focus) {
appendSiblingNode: function (sibling, node) {
var parent = sibling.getParent();
this.appendChildNode(parent, node, focus, sibling);
this.appendChildNode(parent, node, sibling);
},
removeNode: function (nodes) {
nodes = utils.isArray(nodes) ? nodes : [nodes];
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment