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
KityMinder.registerModule( "LayoutBottom", function () {
KityMinder.registerModule("LayoutBottom", function () {
var _target = this.getRenderTarget();
function getMinderSize() {
......@@ -9,43 +9,43 @@ KityMinder.registerModule( "LayoutBottom", function () {
}
var minder = this;
//收缩-展开子树的节点
var ShIcon = kity.createClass( "DefaultshIcon", ( function () {
var ShIcon = kity.createClass("DefaultshIcon", (function () {
return {
constructor: function ( node ) {
constructor: function (node) {
this._show = false;
this._node = node;
var iconShape = this.shape = new kity.Group();
iconShape.class = "shicon";
iconShape.icon = this;
var rect = this._rect = new kity.Rect().fill( "white" ).stroke( "gray" ).setRadius( 2 ).setWidth( 10 ).setHeight( 10 );
var rect = this._rect = new kity.Rect().fill("white").stroke("gray").setRadius(2).setWidth(10).setHeight(10);
var plus = this._plus = new kity.Path();
plus.getDrawer()
.moveTo( 2, 5 )
.lineTo( 8, 5 )
.moveTo( 5, 2 )
.lineTo( 5, 8 );
plus.stroke( "gray" );
.moveTo(2, 5)
.lineTo(8, 5)
.moveTo(5, 2)
.lineTo(5, 8);
plus.stroke("gray");
var dec = this._dec = new kity.Path();
dec.getDrawer()
.moveTo( 2, 5 )
.lineTo( 8, 5 );
dec.stroke( "gray" );
if ( node.getType() === "main" ) minder.getRenderContainer().addShape( iconShape );
.moveTo(2, 5)
.lineTo(8, 5);
dec.stroke("gray");
if (node.getType() === "main") minder.getRenderContainer().addShape(iconShape);
else {
node.getLayout().subgroup.addShape( iconShape );
node.getLayout().subgroup.addShape(iconShape);
}
iconShape.addShapes( [ rect, plus, dec ] );
iconShape.addShapes([rect, plus, dec]);
this.update();
this.switchState();
},
switchState: function () {
if ( !this._show ) {
this._plus.setOpacity( 0 );
this._dec.setOpacity( 1 );
if (!this._show) {
this._plus.setOpacity(0);
this._dec.setOpacity(1);
this._show = true;
} else {
this._plus.setOpacity( 1 );
this._dec.setOpacity( 0 );
this._plus.setOpacity(1);
this._dec.setOpacity(0);
this._show = false;
}
return this._show;
......@@ -55,259 +55,282 @@ KityMinder.registerModule( "LayoutBottom", function () {
var Layout = node.getLayout();
var nodeShape = node.getRenderContainer();
var nodeType = node.getType();
var nodeX = nodeShape.getRenderBox().closurePoints[ 1 ].x + 5;
var nodeY = nodeShape.getRenderBox().closurePoints[ 0 ].y;
this.shape.setTranslate( nodeX, nodeY );
var nodeX = nodeShape.getRenderBox().closurePoints[1].x + 5;
var nodeY = nodeShape.getRenderBox().closurePoints[0].y;
this.shape.setTranslate(nodeX, nodeY);
},
remove: function () {
this.shape.remove();
}
};
} )() );
})());
//样式的配置(包括颜色、字号等)
var nodeStyles = {
"root": {
color: '#430',
fill: '#e9df98',
fontSize: 24,
padding: [ 15.5, 25.5, 15.5, 25.5 ],
margin: [ 0, 0, 20, 0 ],
padding: [15.5, 25.5, 15.5, 25.5],
margin: [0, 0, 20, 0],
radius: 0,
highlight: 'rgb(254, 219, 0)'
highlight: 'rgb(254, 219, 0)',
spaceLeft: 3,
spaceRight: 0,
spaceTop: 3,
spaceBottom: 10
},
"main": {
stroke: new kity.Pen( "white", 2 ).setLineCap( "round" ).setLineJoin( "round" ),
stroke: new kity.Pen("white", 2).setLineCap("round").setLineJoin("round"),
fill: '#A4c5c0',
color: "#333",
padding: [ 6.5, 20, 6.5, 20 ],
padding: [6.5, 20, 6.5, 20],
fontSize: 16,
margin: [ 20, 20, 10, 10 ],
margin: [20, 20, 10, 10],
radius: 0,
highlight: 'rgb(254, 219, 0)'
highlight: 'rgb(254, 219, 0)',
spaceLeft: 3,
spaceRight: 0,
spaceTop: 3,
spaceBottom: 10
},
"sub": {
stroke: new kity.Pen( "white", 2 ).setLineCap( "round" ).setLineJoin( "round" ),
stroke: new kity.Pen("white", 2).setLineCap("round").setLineJoin("round"),
color: "#333",
fontSize: 12,
margin: [ 10, 10, 10, 30 ],
padding: [ 5, 10, 5.5, 10 ],
margin: [10, 10, 10, 30],
padding: [5, 10, 5.5, 10],
highlight: 'rgb(254, 219, 0)',
fill: 'rgb(231, 243, 255)'
fill: 'rgb(231, 243, 255)',
spaceLeft: 3,
spaceRight: 0,
spaceTop: 3,
spaceBottom: 10
}
};
//更新背景
var updateBg = function ( node ) {
var updateBg = function (node) {
var nodeType = node.getType();
var nodeStyle = nodeStyles[ nodeType ];
var nodeStyle = nodeStyles[nodeType];
var Layout = node.getLayout();
switch ( node.getType() ) {
switch (node.getType()) {
case "root":
case "main":
var bg = node.getBgRc().clear();
bg.addShape( Layout.bgShadow = new kity.Rect() );
bg.addShape( Layout.bgRect = new kity.Rect() );
Layout.bgRect.fill( nodeStyle.fill ).setRadius( nodeStyle.radius );
Layout.bgShadow.fill( 'black' ).setOpacity( 0.2 ).setRadius( nodeStyle.radius ).translate( 3, 5 );
bg.addShape(Layout.bgShadow = new kity.Rect());
bg.addShape(Layout.bgRect = new kity.Rect());
Layout.bgRect.fill(nodeStyle.fill).setRadius(nodeStyle.radius);
Layout.bgShadow.fill('black').setOpacity(0.2).setRadius(nodeStyle.radius).translate(3, 5);
break;
case "sub":
var bgRc = node.getBgRc().clear();
bgRc.addShape( Layout.bgRect = new kity.Rect() );
Layout.bgRect.fill( nodeStyle.fill );
bgRc.addShape(Layout.bgRect = new kity.Rect());
Layout.bgRect.fill(nodeStyle.fill);
break;
default:
break;
}
};
//初始化样式
var initLayout = function ( node ) {
var initLayout = function (node) {
var Layout = node.getLayout();
var nodeType = node.getType();
var nodeStyle = nodeStyles[ nodeType ];
var nodeStyle = nodeStyles[nodeType];
// var txtShape = node.getTextShape();
// txtShape.fill( nodeStyle.color ).setSize( nodeStyle.fontSize ).setY( -3 );
if ( nodeType === "main" ) {
if (nodeType === "main") {
var subgroup = Layout.subgroup = new kity.Group();
minder.getRenderContainer().addShape( subgroup );
minder.getRenderContainer().addShape(subgroup);
}
};
//根据内容调整节点尺寸
var updateShapeByCont = function ( node ) {
var updateShapeByCont = function (node) {
var contRc = node.getContRc();
var nodeType = node.getType();
var nodeStyle = nodeStyles[ nodeType ];
var nodeStyle = nodeStyles[nodeType];
var _contRCWidth = contRc.getWidth();
var _contRCHeight = contRc.getHeight();
var Layout = node.getLayout();
switch ( nodeType ) {
switch (nodeType) {
case "root":
case "main":
var width = _contRCWidth + nodeStyle.padding[ 1 ] + nodeStyle.padding[ 3 ],
height = _contRCHeight + nodeStyle.padding[ 0 ] + nodeStyle.padding[ 2 ];
Layout.bgRect.setWidth( width ).setHeight( height );
Layout.bgShadow.setWidth( width ).setHeight( height );
var width = _contRCWidth + nodeStyle.padding[1] + nodeStyle.padding[3],
height = _contRCHeight + nodeStyle.padding[0] + nodeStyle.padding[2];
Layout.bgRect.setWidth(width).setHeight(height);
Layout.bgShadow.setWidth(width).setHeight(height);
break;
case "sub":
width = _contRCWidth + nodeStyle.padding[ 1 ] + nodeStyle.padding[ 3 ];
height = _contRCHeight + nodeStyle.padding[ 0 ] + nodeStyle.padding[ 2 ];
Layout.bgRect.setWidth( width ).setHeight( height );
width = _contRCWidth + nodeStyle.padding[1] + nodeStyle.padding[3];
height = _contRCHeight + nodeStyle.padding[0] + nodeStyle.padding[2];
Layout.bgRect.setWidth(width).setHeight(height);
break;
default:
break;
}
contRc.setTranslate( nodeStyle.padding[ 3 ], nodeStyle.padding[ 0 ] + _contRCHeight / 2 );
var rBox = contRc.getRenderBox();
// Todo:很坑的改法,不知为何就对了,需要处理
contRc.setTranslate(nodeStyle.padding[3], 0);
contRc.translate(0, nodeStyle.padding[0] - rBox.top);
};
var updateLayoutMain = function () {
var _root = minder.getRoot();
var mainnodes = _root.getChildren();
var countMainWidth = function ( node ) {
var mainnodes = (function () {
var main_added = [];
var children = _root.getChildren();
for (var i = 0; i < children.length; i++) {
if (children[i].getLayout().added) main_added.push(children[i]);
}
return main_added;
})();
var countMainWidth = function (node) {
var nLayout = node.getLayout();
var selfwidth = node.getRenderContainer().getWidth() + nodeStyles.main.margin[ 1 ] + nodeStyles.main.margin[ 3 ];
var childwidth = nLayout.subgroup.getWidth() + nodeStyles.main.margin[ 1 ] + nodeStyles.sub.margin[ 3 ];
var branchwidth = nLayout.branchwidth = ( selfwidth > childwidth ? selfwidth : childwidth );
var selfwidth = node.getRenderContainer().getWidth() + nodeStyles.main.margin[1] + nodeStyles.main.margin[3];
var childwidth = 0;
if (nLayout.added) childwidth = nLayout.subgroup.getWidth() + nodeStyles.main.margin[1] + nodeStyles.sub.margin[3];
var branchwidth = nLayout.branchwidth = (selfwidth > childwidth ? selfwidth : childwidth);
return branchwidth;
};
var rootLayout = _root.getLayout();
var rootbranchwidth = 0;
for ( var j = 0; j < mainnodes.length; j++ ) {
rootbranchwidth += countMainWidth( mainnodes[ j ] );
for (var j = 0; j < mainnodes.length; j++) {
rootbranchwidth += countMainWidth(mainnodes[j]);
}
var sX = rootLayout.x - rootbranchwidth / 2;
for ( var k = 0; k < mainnodes.length; k++ ) {
var mLayout = mainnodes[ k ].getLayout();
mLayout.x = sX + nodeStyles.main.margin[ 3 ] + 5;
for (var k = 0; k < mainnodes.length; k++) {
var mLayout = mainnodes[k].getLayout();
mLayout.x = sX + nodeStyles.main.margin[3] + 5;
sX += mLayout.branchwidth;
}
return mainnodes;
};
var updateLayoutAll = function ( node, parent, action ) {
var updateLayoutAll = function (node, parent, action) {
var effectSet = [];
var nodeType = node.getType();
var Layout = node.getLayout();
var _root = minder.getRoot();
var rootLayout = _root.getLayout();
if ( nodeType === "root" ) {
if (nodeType === "root") {
Layout.x = getMinderSize().width / 2;
Layout.y = 100;
Layout.align = "center";
effectSet.push( node );
effectSet.push(node);
var children = node.getChildren();
for ( var i = 0; i < children.length; i++ ) {
var childLayout = children[ i ].getLayout();
childLayout.y = Layout.y + node.getRenderContainer().getHeight() + nodeStyles.root.margin[ 2 ] + nodeStyles.main.margin[ 0 ];
for (var i = 0; i < children.length; i++) {
var childLayout = children[i].getLayout();
childLayout.y = Layout.y + node.getRenderContainer().getHeight() + nodeStyles.root.margin[2] + nodeStyles.main.margin[0];
}
effectSet = effectSet.concat( children );
} else if ( nodeType === "main" ) {
effectSet = effectSet.concat(children);
} else if (nodeType === "main") {
Layout.align = "left";
if ( action === "append" || action === "contract" ) {
Layout.y = rootLayout.y + _root.getRenderContainer().getHeight() + nodeStyles.root.margin[ 2 ] + nodeStyles.main.margin[ 0 ];
if (action === "append" || action === "contract") {
Layout.y = rootLayout.y + _root.getRenderContainer().getHeight() + nodeStyles.root.margin[2] + nodeStyles.main.margin[0];
}
effectSet = updateLayoutMain();
} else {
Layout.align = "left";
var parentLayout = parent.getLayout();
if ( action === "append" ) {
if ( parent.getType() === "main" ) {
Layout.x = nodeStyles.sub.margin[ 3 ];
if (action === "append") {
if (parent.getType() === "main") {
Layout.x = nodeStyles.sub.margin[3];
} else {
Layout.x = parentLayout.x + nodeStyles.sub.margin[ 3 ];
Layout.x = parentLayout.x + nodeStyles.sub.margin[3];
}
}
if ( action === "append" || action === "contract" ) {
Layout.branchheight = node.getRenderContainer().getHeight() + nodeStyles.sub.margin[ 0 ] + nodeStyles.sub.margin[ 2 ];
if (action === "append" || action === "contract") {
Layout.branchheight = node.getRenderContainer().getHeight() + nodeStyles.sub.margin[0] + nodeStyles.sub.margin[2];
}
var prt = parent;
if ( action === "change" ) {
if (action === "change") {
prt = node;
}
//自底向上更新branchheight
while ( prt.getType() !== "main" ) {
while (prt.getType() !== "main") {
var c = prt.getChildren();
var prtLayout = prt.getLayout();
var branchHeight = prt.getRenderContainer().getHeight() + nodeStyles.sub.margin[ 0 ] + nodeStyles.sub.margin[ 2 ];
for ( var i1 = 0; i1 < c.length; i1++ ) {
branchHeight += c[ i1 ].getLayout().branchheight;
var branchHeight = prt.getRenderContainer().getHeight() + nodeStyles.sub.margin[0] + nodeStyles.sub.margin[2];
for (var i1 = 0; i1 < c.length; i1++) {
branchHeight += c[i1].getLayout().branchheight;
}
prtLayout.branchheight = branchHeight;
prt = prt.getParent();
}
//自顶向下更新y
var _buffer = [ prt ];
while ( _buffer.length !== 0 ) {
var childrenC = _buffer[ 0 ].getChildren();
_buffer = _buffer.concat( childrenC );
var _buffer0Layout = _buffer[ 0 ].getLayout();
var _buffer0Style = nodeStyles[ _buffer[ 0 ].getType() ];
var _buffer = [prt];
while (_buffer.length !== 0) {
var childrenC = _buffer[0].getChildren();
_buffer = _buffer.concat(childrenC);
var _buffer0Layout = _buffer[0].getLayout();
var _buffer0Style = nodeStyles[_buffer[0].getType()];
var sY;
if ( _buffer[ 0 ].getType() === "main" ) sY = 0;
else sY = _buffer0Layout.y + _buffer[ 0 ].getRenderContainer().getHeight() + _buffer0Style.margin[ 2 ];
for ( var s = 0; s < childrenC.length; s++ ) {
var childLayoutC = childrenC[ s ].getLayout();
var childStyleC = nodeStyles[ childrenC[ s ].getType() ];
childLayoutC.y = sY + childStyleC.margin[ 0 ];
if (_buffer[0].getType() === "main") sY = 0;
else sY = _buffer0Layout.y + _buffer[0].getRenderContainer().getHeight() + _buffer0Style.margin[2];
for (var s = 0; s < childrenC.length; s++) {
var childLayoutC = childrenC[s].getLayout();
var childStyleC = nodeStyles[childrenC[s].getType()];
childLayoutC.y = sY + childStyleC.margin[0];
sY += childLayoutC.branchheight;
}
effectSet.push( _buffer[ 0 ] );
effectSet.push(_buffer[0]);
_buffer.shift();
}
}
return effectSet;
};
var translateNode = function ( node ) {
var translateNode = function (node) {
var Layout = node.getLayout();
var nodeShape = node.getRenderContainer();
var align = Layout.align;
var _rectHeight = nodeShape.getHeight();
var _rectWidth = nodeShape.getWidth();
switch ( align ) {
switch (align) {
case "right":
nodeShape.setTranslate( Layout.x - _rectWidth, Layout.y );
nodeShape.setTranslate(Layout.x - _rectWidth, Layout.y);
break;
case "center":
nodeShape.setTranslate( Layout.x - _rectWidth / 2, Layout.y );
nodeShape.setTranslate(Layout.x - _rectWidth / 2, Layout.y);
break;
default:
nodeShape.setTranslate( Layout.x, Layout.y );
nodeShape.setTranslate(Layout.x, Layout.y);
break;
}
if ( node.getType() === "main" ) {
Layout.subgroup.setTranslate( Layout.x, Layout.y + node.getRenderContainer().getHeight() );
if (node.getType() === "main") {
Layout.subgroup.setTranslate(Layout.x, Layout.y + node.getRenderContainer().getHeight());
}
node.setPoint( Layout.x, Layout.y );
node.setPoint(Layout.x, Layout.y);
};
var updateConnectAndshIcon = function ( node ) {
var updateConnectAndshIcon = function (node) {
var nodeType = node.getType();
var Layout = node.getLayout();
var nodeStyle = nodeStyles[ node.getType() ];
var nodeStyle = nodeStyles[node.getType()];
var connect;
var _root = minder.getRoot();
var _rootLayout = _root.getLayout();
//更新连线
if ( nodeType === "main" ) {
if ( !Layout.connect ) {
if (nodeType === "main") {
if (!Layout.connect) {
connect = Layout.connect = new kity.Path();
minder.getRenderContainer().addShape( connect );
minder.getRenderContainer().addShape(connect);
}
connect = Layout.connect;
var sX = _rootLayout.x;
var sY = _rootLayout.y + _root.getRenderContainer().getHeight();
var transX = Layout.x + node.getRenderContainer().getWidth() / 2;
var transY = sY + nodeStyles.root.margin[ 2 ];
var transY = sY + nodeStyles.root.margin[2];
connect.getDrawer().clear()
.moveTo( sX, sY )
.lineTo( sX, transY )
.lineTo( transX, transY )
.lineTo( transX, Layout.y );
connect.stroke( nodeStyles.main.stroke );
} else if ( nodeType === "sub" ) {
.moveTo(sX, sY)
.lineTo(sX, transY)
.lineTo(transX, transY)
.lineTo(transX, Layout.y);
connect.stroke(nodeStyles.main.stroke);
} else if (nodeType === "sub") {
var parent = node.getParent();
var parentLayout = parent.getLayout();
if ( !Layout.connect ) {
if (!Layout.connect) {
connect = Layout.connect = new kity.Path();
Layout.subgroup.addShape( connect );
Layout.subgroup.addShape(connect);
}
connect = Layout.connect;
var ssX, ssY;
if ( parent.getType() === "main" ) {
if (parent.getType() === "main") {
ssX = 10;
ssY = 0;
} else {
......@@ -316,15 +339,15 @@ KityMinder.registerModule( "LayoutBottom", function () {
}
var transsY = Layout.y + node.getRenderContainer().getHeight() / 2;
connect.getDrawer().clear()
.moveTo( ssX, ssY )
.lineTo( ssX, transsY )
.lineTo( Layout.x, transsY );
connect.stroke( nodeStyles.sub.stroke );
.moveTo(ssX, ssY)
.lineTo(ssX, transsY)
.lineTo(Layout.x, transsY);
connect.stroke(nodeStyles.sub.stroke);
}
//更新收放icon
if ( nodeType !== "root" && node.getChildren().length !== 0 ) {
if ( !Layout.shicon ) {
Layout.shicon = new ShIcon( node );
if (nodeType !== "root" && node.getChildren().length !== 0) {
if (!Layout.shicon) {
Layout.shicon = new ShIcon(node);
}
Layout.shicon.update();
}
......@@ -333,253 +356,264 @@ KityMinder.registerModule( "LayoutBottom", function () {
getCurrentLayoutStyle: function () {
return nodeStyles;
},
highlightNode: function ( node ) {
highlightNode: function (node) {
var highlight = node.isHighlight();
var nodeType = node.getType();
var nodeStyle = nodeStyles[ nodeType ];
var nodeStyle = nodeStyles[nodeType];
var Layout = node.getLayout();
switch ( nodeType ) {
switch (nodeType) {
case "root":
case "main":
case "sub":
if ( highlight ) {
Layout.bgRect.fill( nodeStyle.highlight );
if (highlight) {
Layout.bgRect.fill(nodeStyle.highlight);
} else {
Layout.bgRect.fill( nodeStyle.fill );
Layout.bgRect.fill(nodeStyle.fill);
}
break;
default:
break;
}
},
updateLayout: function ( node ) {
updateLayout: function (node) {
node.getContRc().clear();
this._firePharse( new MinderEvent( "RenderNodeLeft", {
this._firePharse(new MinderEvent("RenderNodeLeft", {
node: node
}, false));
this._firePharse(new MinderEvent("RenderNodeCenter", {
node: node
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeCenter", {
}, false));
this._firePharse(new MinderEvent("RenderNodeRight", {
node: node
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeRight", {
}, false));
this._firePharse(new MinderEvent("RenderNodeBottom", {
node: node
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeBottom", {
}, false));
this._firePharse(new MinderEvent("RenderNodeTop", {
node: node
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeTop", {
}, false));
this._firePharse(new MinderEvent("RenderNode", {
node: node
}, false ) );
updateShapeByCont( node );
var set = updateLayoutAll( node, node.getParent(), "change" );
for ( var i = 0; i < set.length; i++ ) {
translateNode( set[ i ] );
updateConnectAndshIcon( set[ i ] );
}
if ( node.getType() === "sub" ) {
}, false));
updateShapeByCont(node);
var set = updateLayoutAll(node, node.getParent(), "change");
for (var i = 0; i < set.length; i++) {
translateNode(set [i]);
updateConnectAndshIcon(set [i]);
}
if (node.getType() === "sub") {
var set1 = updateLayoutMain();
for ( var j = 0; j < set1.length; j++ ) {
translateNode( set1[ j ] );
updateConnectAndshIcon( set1[ j ] );
for (var j = 0; j < set1.length; j++) {
translateNode(set1[j]);
updateConnectAndshIcon(set1[j]);
}
}
},
initStyle: function () {
var _root = minder.getRoot();
minder.handelNodeInsert( _root );
minder.handelNodeInsert(_root);
//设置root的align
_root.getLayout().align = "center";
updateBg( _root );
initLayout( _root );
updateBg(_root);
initLayout(_root);
_root.getContRc().clear();
this._firePharse( new MinderEvent( "RenderNodeLeft", {
this._firePharse(new MinderEvent("RenderNodeLeft", {
node: _root
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeCenter", {
}, false));
this._firePharse(new MinderEvent("RenderNodeCenter", {
node: _root
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeRight", {
}, false));
this._firePharse(new MinderEvent("RenderNodeRight", {
node: _root
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeBottom", {
}, false));
this._firePharse(new MinderEvent("RenderNodeBottom", {
node: _root
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeTop", {
}, false));
this._firePharse(new MinderEvent("RenderNodeTop", {
node: _root
}, false ) );
updateShapeByCont( _root );
updateLayoutAll( _root );
translateNode( _root );
var _buffer = [ _root ];
}, false));
this._firePharse(new MinderEvent("RenderNode", {
node: _root
}, false));
updateShapeByCont(_root);
updateLayoutAll(_root);
translateNode(_root);
var _buffer = [_root];
var _cleanbuffer = [];
//打散结构
while ( _buffer.length !== 0 ) {
var children = _buffer[ 0 ].getChildren();
_buffer = _buffer.concat( children );
for ( var i = 0; i < children.length; i++ ) {
children[ i ].getLayout().parent = _buffer[ 0 ];
}
_buffer[ 0 ].clearChildren();
if ( _buffer[ 0 ] !== _root ) _cleanbuffer.push( _buffer[ 0 ] );
_buffer.shift();
}
//重组结构
for ( var j = 0; j < _cleanbuffer.length; j++ ) {
this.appendChildNode( _cleanbuffer[ j ].getLayout().parent, _cleanbuffer[ j ] );
var mains = _root.getChildren();
for (var i = 0; i < mains.length; i++) {
this.appendChildNode(_root, mains[i]);
}
//打散结构
// while (_buffer.length !== 0) {
// var children = _buffer[0].getChildren();
// _buffer = _buffer.concat(children);
// for (var i = 0; i < children.length; i++) {
// children[i].getLayout().parent = _buffer[0];
// }
// _buffer[0].clearChildren();
// if (_buffer[0] !== _root) _cleanbuffer.push(_buffer[0]);
// _buffer.shift();
// }
// //重组结构
// for (var j = 0; j < _cleanbuffer.length; j++) {
// this.appendChildNode(_cleanbuffer[j].getLayout().parent, _cleanbuffer[j]);
// }
},
appendChildNode: function ( parent, node, focus, sibling ) {
appendChildNode: function (parent, node, sibling) {
minder.handelNodeInsert(node);
node.clearLayout();
node.getContRc().clear();
var Layout = node.getLayout();
Layout = node.getLayout();
Layout.added = true;
initLayout(node);
var parentLayout = parent.getLayout();
var expand = parent.getData( "expand" );
//设置分支类型
if ( parent.getType() === "root" ) {
node.setType( "main" );
node.setData( "expand", true );
minder.handelNodeInsert( node );
if (parent.getType() === "root") {
node.setType("main");
node.setData("expand", true);
} else {
node.setType( "sub" );
node.setType("sub");
//将节点加入到main分支的subgroup中
parentLayout.subgroup.addShape( node.getRenderContainer() );
parentLayout.subgroup.addShape(node.getRenderContainer());
node.getLayout().subgroup = parentLayout.subgroup;
}
if ( sibling ) {
parent.insertChild( node, sibling.getIndex() + 1 );
if (sibling) {
parent.insertChild(node, sibling.getIndex() + 1);
} else {
parent.appendChild( node );
parent.appendChild(node);
}
//计算位置等流程
updateBg( node );
initLayout( node );
// this._fire( new MinderEvent( "beforeRenderNode", {
// node: node
// }, false ) );
// this._fire( new MinderEvent( "RenderNode", {
// node: node
// }, false ) );
node.getRenderContainer().clear();
this._firePharse( new MinderEvent( "RenderNodeLeft", {
this._firePharse(new MinderEvent("RenderNodeLeft", {
node: node
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeCenter", {
}, false));
this._firePharse(new MinderEvent("RenderNodeCenter", {
node: node
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeRight", {
}, false));
this._firePharse(new MinderEvent("RenderNodeRight", {
node: node
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeBottom", {
}, false));
this._firePharse(new MinderEvent("RenderNodeBottom", {
node: node
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeTop", {
}, false));
this._firePharse(new MinderEvent("RenderNodeTop", {
node: node
}, false ) );
updateShapeByCont( node );
var set = updateLayoutAll( node, parent, "append" );
for ( var i = 0; i < set.length; i++ ) {
translateNode( set[ i ] );
updateConnectAndshIcon( set[ i ] );
}
if ( node.getType() === "sub" ) {
var set1 = updateLayoutMain();
for ( var j = 0; j < set1.length; j++ ) {
translateNode( set1[ j ] );
updateConnectAndshIcon( set1[ j ] );
}
}
}, false));
this._firePharse(new MinderEvent("RenderNode", {
node: node
}, false));
updateBg(node);
updateShapeByCont(node);
var set = updateLayoutAll(node, parent, "append");
for (var i = 0; i < set.length; i++) {
translateNode(set [i]);
updateConnectAndshIcon(set [i]);
}
// if (node.getType() === "sub") {
// var set1 = updateLayoutMain();
// for (var j = 0; j < set1.length; j++) {
// translateNode(set1[j]);
// updateConnectAndshIcon(set1[j]);
// }
// }
},
appendSiblingNode: function ( sibling, node ) {
appendSiblingNode: function (sibling, node) {
var parent = sibling.getParent();
this.appendChildNode( parent, node, sibling );
this.appendChildNode(parent, node, sibling);
},
removeNode: function ( nodes ) {
while ( nodes.length !== 0 ) {
var parent = nodes[ 0 ].getParent();
if ( !parent ) {
nodes.splice( 0, 1 );
removeNode: function (nodes) {
while (nodes.length !== 0) {
var parent = nodes[0].getParent();
if (!parent) {
nodes.splice(0, 1);
return false;
}
var nodeLayout = nodes[ 0 ].getLayout();
parent.removeChild( nodes[ 0 ] );
if ( parent.getType() !== "root" && parent.getChildren().length === 0 ) {
var nodeLayout = nodes[0].getLayout();
parent.removeChild(nodes[0]);
if (parent.getType() !== "root" && parent.getChildren().length === 0) {
var prtLayout = parent.getLayout();
prtLayout.shicon.remove();
prtLayout.shicon = null;
}
var set = updateLayoutAll( nodes[ 0 ], parent, "remove" );
for ( var j = 0; j < set.length; j++ ) {
translateNode( set[ j ] );
updateConnectAndshIcon( set[ j ] );
var set = updateLayoutAll(nodes[0], parent, "remove");
for (var j = 0; j < set.length; j++) {
translateNode(set [j]);
updateConnectAndshIcon(set [j]);
}
var set1 = updateLayoutMain();
for ( var k = 0; k < set1.length; k++ ) {
translateNode( set1[ k ] );
updateConnectAndshIcon( set1[ k ] );
for (var k = 0; k < set1.length; k++) {
translateNode(set1[k]);
updateConnectAndshIcon(set1[k]);
}
var _buffer = [ nodes[ 0 ] ];
while ( _buffer.length !== 0 ) {
_buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
var _buffer = [nodes[0]];
while (_buffer.length !== 0) {
_buffer = _buffer.concat(_buffer[0].getChildren());
try {
_buffer[ 0 ].getRenderContainer().remove();
var Layout = _buffer[ 0 ].getLayout();
_buffer[0].getRenderContainer().remove();
var Layout = _buffer[0].getLayout();
Layout.connect.remove();
Layout.shicon.remove();
} catch ( error ) {
console.log( "isRemoved" );
} catch (error) {
console.log("isRemoved");
}
//检测当前节点是否在选中的数组中,如果在的话,从选中数组中去除
var idx = nodes.indexOf( _buffer[ 0 ] );
if ( idx !== -1 ) {
nodes.splice( idx, 1 );
var idx = nodes.indexOf(_buffer[0]);
if (idx !== -1) {
nodes.splice(idx, 1);
}
_buffer.shift();
}
}
},
expandNode: function ( ico ) {
expandNode: function (ico) {
var isExpand, node;
if ( ico instanceof MinderNode ) {
if (ico instanceof MinderNode) {
node = ico;
isExpand = node.getLayout().shicon.switchState();
} else {
isExpand = ico.icon.switchState();
node = ico.icon._node;
}
node.setData( "expand", isExpand );
var _buffer = node.getChildren();
var _cleanbuffer = [];
while ( _buffer.length !== 0 ) {
var Layout = _buffer[ 0 ].getLayout();
if ( isExpand ) {
var parent = _buffer[ 0 ].getParent();
Layout.parent = parent;
_cleanbuffer.push( _buffer[ 0 ] );
Layout.connect = null;
Layout.shicon = null;
var _buffer;
if (isExpand) {
node.expand();
//遍历子树展开需要展开的节点
_buffer = [node];
while (_buffer.length !== 0) {
var c = _buffer[0].getChildren();
if (_buffer[0].isExpanded() && c.length !== 0) {
for (var x = 0; x < c.length; x++) {
minder.appendChildNode(_buffer[0], c[x]);
}
_buffer = _buffer.concat(c);
}
_buffer.shift();
}
} else {
try {
_buffer[ 0 ].getRenderContainer().remove();
node.collapse();
//遍历子树移除需要移除的节点
_buffer = node.getChildren();
while (_buffer.length !== 0) {
var Layout = _buffer[0].getLayout();
if (Layout.added) {
Layout.added = false;
_buffer[0].getRenderContainer().remove();
Layout.connect.remove();
if ( Layout.shicon ) Layout.shicon.remove();
} catch ( error ) {}
if (Layout.shicon) Layout.shicon.remove();
}
_buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
_buffer = _buffer.concat(_buffer[0].getChildren());
_buffer.shift();
}
if ( isExpand ) {
node.clearChildren();
for ( var j = 0; j < _cleanbuffer.length; j++ ) {
_cleanbuffer[ j ].clearChildren();
minder.appendChildNode( _cleanbuffer[ j ].getLayout().parent, _cleanbuffer[ j ] );
}
var set = updateLayoutVertical(node, node.getParent(), "contract");
for (var i = 0; i < set.length; i++) {
translateNode(set [i]);
updateConnectAndshIcon(set [i]);
}
var set = [];
if ( !isExpand ) set = updateLayoutAll( node, node.getParent(), "contract" );
for ( var i = 0; i < set.length; i++ ) {
translateNode( set[ i ] );
updateConnectAndshIcon( set[ i ] );
}
}
};
this.addLayoutStyle( "bottom", _style );
this.addLayoutStyle("bottom", _style);
return {};
} );
\ No newline at end of file
});
\ No newline at end of file
......@@ -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];
......
KityMinder.registerModule( "LayoutModule", function () {
KityMinder.registerModule("LayoutModule", function () {
var me = this;
var clearPaper = function () {
me._rc.remove();
me._rc = new kity.Group();
me._paper.addShape( this._rc );
me._paper.addShape(this._rc);
};
kity.extendClass( Minder, {
addLayoutStyle: function ( name, style ) {
if ( !this._layoutStyles ) this._layoutStyles = {};
this._layoutStyles[ name ] = style;
kity.extendClass(Minder, {
addLayoutStyle: function (name, style) {
if (!this._layoutStyles) this._layoutStyles = {};
this._layoutStyles[name] = style;
},
getLayoutStyle: function ( name ) {
return this._layoutStyles[ name ];
getLayoutStyle: function (name) {
return this._layoutStyles[name];
},
getLayoutStyleItems: function () {
var items = [];
for ( var key in this._layoutStyles ) {
items.push( key );
for (var key in this._layoutStyles) {
items.push(key);
}
return items;
},
getCurrentStyle: function () {
var _root = this.getRoot();
return "default"; //_root.getData( "currentstyle" );
return _root.getData("currentstyle");
},
setCurrentStyle: function ( name ) {
setCurrentStyle: function (name) {
var _root = this.getRoot();
_root.setData( "currentstyle", name );
_root.setData("currentstyle", name);
return name;
},
getCurrentLayoutStyle: function () {
var curStyle = this.getCurrentStyle();
return this.getLayoutStyle( curStyle ).getCurrentLayoutStyle.call( this );
return this.getLayoutStyle(curStyle).getCurrentLayoutStyle.call(this);
},
highlightNode: function ( node ) {
highlightNode: function (node) {
var curStyle = this.getCurrentStyle();
this.getLayoutStyle( curStyle ).highlightNode.call( this, node );
this.getLayoutStyle(curStyle).highlightNode.call(this, node);
},
initStyle: function () {
var curStyle = this.getCurrentStyle();
this._rc.remove();
var transform = this._rc.transform;
this._rc = new kity.Group();
this._paper.addShape( this._rc );
this._paper.addShape(this._rc);
this._rc.transform = transform;
this._rc._applyTransform();
var _root = this.getRoot();
_root.preTraverse( function ( n ) {
_root.preTraverse(function (n) {
n.clearLayout();
} );
this.getLayoutStyle( curStyle ).initStyle.call( this );
this.fire( 'afterinitstyle' );
});
this.getLayoutStyle(curStyle).initStyle.call(this);
this.fire('afterinitstyle');
},
appendChildNode: function ( parent, node, focus, index ) {
appendChildNode: function (parent, node, index) {
var curStyle = this.getCurrentStyle();
this.getLayoutStyle( curStyle ).appendChildNode.call( this, parent, node, focus, index );
this.getLayoutStyle(curStyle).appendChildNode.call(this, parent, node, index);
},
appendSiblingNode: function ( sibling, node, focus ) {
appendSiblingNode: function (sibling, node) {
var curStyle = this.getCurrentStyle();
this.getLayoutStyle( curStyle ).appendSiblingNode.call( this, sibling, node, focus );
this.getLayoutStyle(curStyle).appendSiblingNode.call(this, sibling, node);
},
removeNode: function ( nodes ) {
removeNode: function (nodes) {
var curStyle = this.getCurrentStyle();
this.getLayoutStyle( curStyle ).removeNode.call( this, nodes );
this.getLayoutStyle(curStyle).removeNode.call(this, nodes);
},
updateLayout: function ( node ) {
updateLayout: function (node) {
var curStyle = this.getCurrentStyle();
this.getLayoutStyle( curStyle ).updateLayout.call( this, node );
this.getLayoutStyle(curStyle).updateLayout.call(this, node);
},
expandNode: function ( ico ) {
expandNode: function (ico) {
var curStyle = this.getCurrentStyle();
this.getLayoutStyle( curStyle ).expandNode.call( this, ico );
this.getLayoutStyle(curStyle).expandNode.call(this, ico);
}
} );
kity.extendClass( MinderNode, {
setLayout: function ( k, v ) {
if ( this._layout === undefined ) {
});
kity.extendClass(MinderNode, {
setLayout: function (k, v) {
if (this._layout === undefined) {
this._layout = {};
}
var _pros = this.getLayout();
Utils.extend( _pros, {
Utils.extend(_pros, {
k: v
} );
});
this._layout = _pros;
},
getLayout: function ( k ) {
if ( k === undefined ) {
getLayout: function (k) {
if (k === undefined) {
return this._layout;
}
return this._layout[ k ];
return this._layout[k];
},
clearLayout: function () {
this._layout = {};
}
} );
var switchLayout = function ( km, style ) {
});
var switchLayout = function (km, style) {
var _root = km.getRoot();
_root.preTraverse( function ( n ) {
_root.preTraverse(function (n) {
n.setPoint();
n.getBgRc().clear();
} );
km.setCurrentStyle( style );
});
km.setCurrentStyle(style);
//km.initStyle();
return style;
};
var SwitchLayoutCommand = kity.createClass( "SwitchLayoutCommand", ( function () {
var SwitchLayoutCommand = kity.createClass("SwitchLayoutCommand", (function () {
return {
base: Command,
execute: switchLayout,
queryValue: function ( km ) {
queryValue: function (km) {
return km.getCurrentStyle();
}
};
} )() );
var AppendChildNodeCommand = kity.createClass( "AppendChildNodeCommand", ( function () {
})());
var AppendChildNodeCommand = kity.createClass("AppendChildNodeCommand", (function () {
return {
base: Command,
execute: function ( km, node, focus, silbling ) {
execute: function (km, node, silbling) {
var parent = km.getSelectedNode();
if ( !parent ) {
if (!parent) {
return null;
}
if ( parent.getType() !== "root" && parent.getChildren().length !== 0 && !parent.isExpanded() ) {
km.expandNode( parent );
if (parent.getType() !== "root" && parent.getChildren().length !== 0 && !parent.isExpanded()) {
km.expandNode(parent);
}
parent.expand();
km.appendChildNode( parent, node, focus, silbling );
km.select( node, true );
km.appendChildNode(parent, node, silbling);
km.select(node, true);
return node;
},
queryState: function ( km ) {
queryState: function (km) {
var selectedNode = km.getSelectedNode();
if ( !selectedNode ) {
if (!selectedNode) {
return -1;
} else {
return 0;
}
}
};
} )() );
var AppendSiblingNodeCommand = kity.createClass( "AppendSiblingNodeCommand", ( function () {
})());
var AppendSiblingNodeCommand = kity.createClass("AppendSiblingNodeCommand", (function () {
return {
base: Command,
execute: function ( km, node, focus ) {
execute: function (km, node) {
var selectedNode = km.getSelectedNode();
if ( !selectedNode ) {
if (!selectedNode) {
return null;
}
if ( selectedNode.isRoot() ) {
node.setType( "main" );
km.appendChildNode( selectedNode, node, focus );
if (selectedNode.isRoot()) {
node.setType("main");
km.appendChildNode(selectedNode, node);
} else {
km.appendSiblingNode( selectedNode, node, focus );
km.appendSiblingNode(selectedNode, node);
}
km.select( node, true );
km.select(node, true);
return node;
},
queryState: function ( km ) {
queryState: function (km) {
var selectedNodes = km.getSelectedNodes();
//没选中节点和单选root的时候返回不可执行
if ( selectedNodes.length === 0 || ( selectedNodes.length === 1 && selectedNodes[ 0 ] === km.getRoot() ) ) {
if (selectedNodes.length === 0 || (selectedNodes.length === 1 && selectedNodes[0] === km.getRoot())) {
return -1;
} else {
return 0;
}
}
};
} )() );
var RemoveNodeCommand = kity.createClass( "RemoveNodeCommand", ( function () {
})());
var RemoveNodeCommand = kity.createClass("RemoveNodeCommand", (function () {
return {
base: Command,
execute: function ( km ) {
execute: function (km) {
if ( km.getRoot().children.length == 0 ) {
if (km.getRoot().children.length == 0) {
return;
}
var selectedNodes = km.getSelectedNodes();
var _root = km.getRoot();
var _buffer = [];
for ( var i = 0; i < selectedNodes.length; i++ ) {
_buffer.push( selectedNodes[ i ] );
for (var i = 0; i < selectedNodes.length; i++) {
_buffer.push(selectedNodes[i]);
}
do {
var parent = _buffer[ 0 ].getParent();
if ( parent && _buffer.indexOf( parent ) === -1 ) _buffer.push( parent );
var parent = _buffer[0].getParent();
if (parent && _buffer.indexOf(parent) === -1) _buffer.push(parent);
_buffer.shift();
} while ( _buffer.length > 1 );
km.removeNode( selectedNodes );
km.select( _buffer[ 0 ] );
} while (_buffer.length > 1);
km.removeNode(selectedNodes);
km.select(_buffer[0]);
},
queryState: function ( km ) {
queryState: function (km) {
var selectedNodes = km.getSelectedNodes();
if ( selectedNodes.length === 0 || ( selectedNodes.length === 1 && selectedNodes[ 0 ] === km.getRoot() ) ) {
if (selectedNodes.length === 0 || (selectedNodes.length === 1 && selectedNodes[0] === km.getRoot())) {
return -1;
} else {
return 0;
}
}
};
} )() );
var EditNodeCommand = kity.createClass( "EditNodeCommand", ( function () {
})());
var EditNodeCommand = kity.createClass("EditNodeCommand", (function () {
return {
base: Command,
execute: function ( km ) {
execute: function (km) {
var selectedNode = km.getSelectedNode();
if ( !selectedNode ) {
if (!selectedNode) {
return null;
}
km.select( selectedNode, true );
km.textEditNode( selectedNode );
km.select(selectedNode, true);
km.textEditNode(selectedNode);
},
queryState: function ( km ) {
queryState: function (km) {
var selectedNode = km.getSelectedNode();
if ( !selectedNode ) {
if (!selectedNode) {
return -1;
} else {
return 0;
......@@ -228,7 +228,7 @@ KityMinder.registerModule( "LayoutModule", function () {
return false;
}
};
} )() );
})());
return {
"commands": {
......@@ -240,47 +240,46 @@ KityMinder.registerModule( "LayoutModule", function () {
},
"events": {
"ready": function () {
this.setDefaultOptions( 'layoutstyle', this.getLayoutStyleItems() );
switchLayout( this, this.getOptions( 'defaultlayoutstyle' ) );
this.setDefaultOptions('layoutstyle', this.getLayoutStyleItems());
switchLayout(this, this.getOptions('defaultlayoutstyle'));
},
"click": function ( e ) {
"click": function (e) {
var ico = e.kityEvent.targetShape && e.kityEvent.targetShape.container;
if ( ico && ico.class === "shicon" ) {
this.expandNode( ico );
this.fire( 'contentchange' );
if (ico && ico.class === "shicon") {
this.expandNode(ico);
this.fire('contentchange');
}
},
"resize": function ( e ) {
clearTimeout( this._lastStyleResetTimeout );
this._lastStyleResetTimeout = setTimeout( function () {
this.updateLayout( this.getRoot() );
}.bind( this ), 100 );
"resize": function (e) {
clearTimeout(this._lastStyleResetTimeout);
this._lastStyleResetTimeout = setTimeout(function () {
this.updateLayout(this.getRoot());
}.bind(this), 100);
},
"import": function ( e ) {
"import": function (e) {
this.initStyle();
}
},
'contextmenu': [ {
label: this.getLang( 'node.appendsiblingnode' ),
'contextmenu': [{
label: this.getLang('node.appendsiblingnode'),
exec: function () {
this.execCommand( 'appendsiblingnode', new MinderNode( this.getLang( 'topic' ) ) )
this.execCommand('appendsiblingnode', new MinderNode(this.getLang('topic')))
},
cmdName: 'appendsiblingnode'
}, {
label: this.getLang( 'node.appendchildnode' ),
label: this.getLang('node.appendchildnode'),
exec: function () {
this.execCommand( 'appendchildnode', new MinderNode( this.getLang( 'topic' ) ) )
this.execCommand('appendchildnode', new MinderNode(this.getLang('topic')))
},
cmdName: 'appendchildnode'
}, {
label: this.getLang( 'node.editnode' ),
label: this.getLang('node.editnode'),
exec: function () {
this.execCommand( 'editnode', null );
this.execCommand('editnode', null);
},
cmdName: 'editnode'
}, {
label: this.getLang( 'node.removenode' ),
label: this.getLang('node.removenode'),
cmdName: 'removenode'
}, {
divider: 1
......@@ -301,4 +300,4 @@ KityMinder.registerModule( "LayoutModule", function () {
}
}
};
} );
\ No newline at end of file
});
\ No newline at end of file
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