Commit 1ad7b1d1 authored by campaign's avatar campaign

Merge remote-tracking branch 'origin/dev' into dev

parents 0ec90d2d 0b314a0c
<!DOCTYPE html>
<html>
<head>
<script src="../dist/jquery-2.1.0.min.js"></script>
<script src="../kity/dist/kitygraph.all.js"></script>
<script src="../configure.js"></script>
<script src="../dist/dev.js"></script>
<script src="../lang/zh-cn/zh-cn.js" charset="utf-8"></script>
<link href="../themes/default/css/import.css" type="text/css" rel="stylesheet">
<style>
.km_receiver{
width:0;
height:0;
}
.km-minderNode{
cursor:default;
}
.kmui-container {
height: 100%;
}
html, body, div {
margin: 0;
padding: 0;
}
</style>
</head>
<body >
<div id="kityminder" style="height:100%;width:100%" onselectstart="return false">
</div>
</body>
<script>
window.km = KM.getKityMinder('kityminder');
</script>
</html>
\ No newline at end of file
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
}, },
'cancel': {} 'cancel': {}
}, },
width: 200, width: 200
} ) } )
} )(); } )();
\ No newline at end of file
...@@ -533,7 +533,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", { ...@@ -533,7 +533,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
node.parent.removeChild( node ); node.parent.removeChild( node );
} }
node.parent = this; node.parent = this;
node.root = parent.root; node.root = node.parent.root;
this.children.splice( index, 0, node ); this.children.splice( index, 0, node );
}, },
...@@ -789,6 +789,9 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", { ...@@ -789,6 +789,9 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this._paper = new kity.Paper(); this._paper = new kity.Paper();
this._paper.getNode().setAttribute( 'contenteditable', true ); this._paper.getNode().setAttribute( 'contenteditable', true );
this._paper.getNode().ondragstart = function(e) {
e.preventDefault();
};
this._addRenderContainer(); this._addRenderContainer();
...@@ -3201,9 +3204,11 @@ KityMinder.registerModule( "LayoutBottom", function () { ...@@ -3201,9 +3204,11 @@ KityMinder.registerModule( "LayoutBottom", function () {
Layout.connect = null; Layout.connect = null;
Layout.shicon = null; Layout.shicon = null;
} else { } else {
_buffer[ 0 ].getRenderContainer().remove(); try {
Layout.connect.remove(); _buffer[ 0 ].getRenderContainer().remove();
if ( Layout.shicon ) Layout.shicon.remove(); Layout.connect.remove();
if ( Layout.shicon ) Layout.shicon.remove();
} catch ( error ) {}
} }
_buffer = _buffer.concat( _buffer[ 0 ].getChildren() ); _buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
_buffer.shift(); _buffer.shift();
...@@ -3352,6 +3357,9 @@ var ViewDragger = kity.createClass( "ViewDragger", { ...@@ -3352,6 +3357,9 @@ var ViewDragger = kity.createClass( "ViewDragger", {
paper.setStyle( 'cursor', value ? '-webkit-grab' : 'default' ); paper.setStyle( 'cursor', value ? '-webkit-grab' : 'default' );
this._enabled = value; this._enabled = value;
}, },
move: function ( offset ) {
this._minder.getRenderContainer().translate( offset.x, offset.y );
},
_bind: function () { _bind: function () {
var dragger = this, var dragger = this,
...@@ -3368,7 +3376,7 @@ var ViewDragger = kity.createClass( "ViewDragger", { ...@@ -3368,7 +3376,7 @@ var ViewDragger = kity.createClass( "ViewDragger", {
} }
// 点击未选中的根节点临时开启 // 点击未选中的根节点临时开启
else if ( e.getTargetNode() == this.getRoot() && else if ( e.getTargetNode() == this.getRoot() &&
(!this.getRoot().isSelected() || !this.isSingleSelect())) { ( !this.getRoot().isSelected() || !this.isSingleSelect() ) ) {
lastPosition = e.getPosition(); lastPosition = e.getPosition();
dragger.setEnabled( true ); dragger.setEnabled( true );
isRootDrag = true; isRootDrag = true;
...@@ -3382,8 +3390,7 @@ var ViewDragger = kity.createClass( "ViewDragger", { ...@@ -3382,8 +3390,7 @@ var ViewDragger = kity.createClass( "ViewDragger", {
// 当前偏移加上历史偏移 // 当前偏移加上历史偏移
var offset = kity.Vector.fromPoints( lastPosition, currentPosition ); var offset = kity.Vector.fromPoints( lastPosition, currentPosition );
dragger.move( offset );
this.getRenderContainer().translate( offset.x, offset.y );
e.stopPropagation(); e.stopPropagation();
lastPosition = currentPosition; lastPosition = currentPosition;
} }
...@@ -3425,6 +3432,23 @@ KityMinder.registerModule( 'Hand', function () { ...@@ -3425,6 +3432,23 @@ KityMinder.registerModule( 'Hand', function () {
this.execCommand( 'hand' ); this.execCommand( 'hand' );
e.preventDefault(); e.preventDefault();
} }
},
mousewheel: function ( e ) {
var dx = e.originEvent.wheelDeltaX || e.originEvent.wheelDelta,
dy = e.originEvent.wheelDeltaY || 0;
this._viewDragger.move( {
x: dx / 2.5,
y: dy / 2.5
} );
e.originEvent.preventDefault();
},
dblclick: function() {
var viewport = this.getPaper().getViewPort();
var offset = this.getRoot().getRenderContainer(this.getRenderContainer()).getTransform().getTranslate();
var dx = viewport.center.x - offset.x,
dy = viewport.center.y - offset.y;
this.getRenderContainer().fxTranslate(dx, dy, 300);
} }
} }
}; };
...@@ -4465,7 +4489,9 @@ Minder.Receiver = kity.createClass('Receiver',{ ...@@ -4465,7 +4489,9 @@ Minder.Receiver = kity.createClass('Receiver',{
var text = this.container.firstChild; var text = this.container.firstChild;
this.range = range; this.range = range;
range.setStart(text || this.container, this.index).collapse(true); range.setStart(text || this.container, this.index).collapse(true);
var me = this;
setTimeout(function(){ setTimeout(function(){
me.container.focus();
range.select() range.select()
}); });
return this; return this;
...@@ -4523,7 +4549,7 @@ Minder.Receiver = kity.createClass('Receiver',{ ...@@ -4523,7 +4549,7 @@ Minder.Receiver = kity.createClass('Receiver',{
return; return;
} }
var text = (this.container.textContent || this.container.innerText).replace(/\u200b/g,''); var text = this.container.textContent.replace(/\u200b/g,'');
if(this.textShape.getOpacity() == 0){ if(this.textShape.getOpacity() == 0){
this.textShape.setOpacity(1); this.textShape.setOpacity(1);
...@@ -5464,16 +5490,16 @@ KM.ui.define('menu',{ ...@@ -5464,16 +5490,16 @@ KM.ui.define('menu',{
}); });
//dropmenu 类 //dropmenu 类
KM.ui.define( 'dropmenu', { KM.ui.define('dropmenu', {
tmpl: '<ul class="kmui-dropdown-menu" aria-labelledby="dropdownMenu" >' + tmpl: '<ul class="kmui-dropdown-menu" aria-labelledby="dropdownMenu" >' +
'<%if(data && data.length){for(var i=0,ci;ci=data[i++];){%>' + '<%if(data && data.length){for(var i=0,ci;ci=data[i++];){%>' +
'<%if(ci.divider){%><li class="kmui-divider"></li><%}else{%>' + '<%if(ci.divider){%><li class="kmui-divider"></li><%}else{%>' +
'<li <%if(ci.active||ci.disabled){%>class="<%= ci.active|| \'\' %> <%=ci.disabled||\'\' %>" <%}%> data-value="<%= ci.value%>" data-label="<%= ci.label%>">' + '<li <%if(ci.active||ci.disabled){%>class="<%= ci.active|| \'\' %> <%=ci.disabled||\'\' %>" <%}%> data-value="<%= ci.value%>" data-label="<%= ci.label%>">' +
'<a href="#" tabindex="-1"><em class="kmui-dropmenu-checkbox"><i class="kmui-icon-ok"></i></em><%= ci.label%></a>' + '<a href="#" tabindex="-1"><em class="kmui-dropmenu-checkbox"><i class="kmui-icon-ok"></i></em><%= ci.label%></a>' +
'</li><%}}%>' + '</li><%}}%>' +
'<%}%>' + '<%}%>'+
'</ul>', '</ul>',
subTmpl: '<%if(data && data.length){for(var i=0,ci;ci=data[i++];){%>' + subTmpl:'<%if(data && data.length){for(var i=0,ci;ci=data[i++];){%>' +
'<%if(ci.divider){%><li class="kmui-divider"></li><%}else{%>' + '<%if(ci.divider){%><li class="kmui-divider"></li><%}else{%>' +
'<li <%if(ci.active||ci.disabled){%>class="<%= ci.active|| \'\' %> <%=ci.disabled||\'\' %>" <%}%> data-value="<%= ci.value%>" data-label="<%= ci.label%>">' + '<li <%if(ci.active||ci.disabled){%>class="<%= ci.active|| \'\' %> <%=ci.disabled||\'\' %>" <%}%> data-value="<%= ci.value%>" data-label="<%= ci.label%>">' +
'<a href="#" tabindex="-1"><em class="kmui-dropmenu-checkbox"><i class="kmui-icon-ok"></i></em><%= ci.label%></a>' + '<a href="#" tabindex="-1"><em class="kmui-dropmenu-checkbox"><i class="kmui-icon-ok"></i></em><%= ci.label%></a>' +
...@@ -5481,33 +5507,32 @@ KM.ui.define( 'dropmenu', { ...@@ -5481,33 +5507,32 @@ KM.ui.define( 'dropmenu', {
'<%}%>', '<%}%>',
defaultOpt: { defaultOpt: {
data: [], data: [],
click: function () {} click: function () {
}
}, },
setData: function ( items ) { setData:function(items){
this.root().html( $.parseTmpl( this.subTmpl, items ) ); this.root().html($.parseTmpl(this.subTmpl,items));
return this; return this;
}, },
position: function ( offset ) { position:function(offset){
this.root().css( { this.root().css({
left: offset.x, left:offset.x,
top: offset.y top:offset.y
} ); });
return this; return this;
}, },
show: function () { show:function(){
if ( this.trigger( 'beforeshow' ) === false ) { if(this.trigger('beforeshow') === false){
return; return;
} else { }else{
this.root().css( { this.root().css({display:'block'});
display: 'block' this.trigger('aftershow');
} );
this.trigger( 'aftershow' );
} }
return this; return this;
}, },
init: function ( options ) { init: function (options) {
var me = this; var me = this;
var eventName = { var eventName = {
click: 1, click: 1,
...@@ -5515,48 +5540,54 @@ KM.ui.define( 'dropmenu', { ...@@ -5515,48 +5540,54 @@ KM.ui.define( 'dropmenu', {
mouseout: 1 mouseout: 1
}; };
this.root( $( $.parseTmpl( this.tmpl, options ) ) ).on( 'click', 'li[class!="kmui-disabled kmui-divider kmui-dropdown-submenu"]', function ( evt ) { this.root($($.parseTmpl(this.tmpl, options))).on('click', 'li[class!="kmui-disabled kmui-divider kmui-dropdown-submenu"]',function (evt) {
$.proxy( options.click, me, evt, $( this ).data( 'value' ), $( this ).data( 'label' ), $( this ) )() $.proxy(options.click, me, evt, $(this).data('value'), $(this).data('label'),$(this))()
} ).find( 'li' ).each( function ( i, el ) { }).find('li').each(function (i, el) {
var $this = $( this ); var $this = $(this);
if ( !$this.hasClass( "kmui-disabled kmui-divider kmui-dropdown-submenu" ) ) { if (!$this.hasClass("kmui-disabled kmui-divider kmui-dropdown-submenu")) {
var data = options.data[ i ]; var data = options.data[i];
$.each( eventName, function ( k ) { $.each(eventName, function (k) {
data[ k ] && $this[ k ]( function ( evt ) { data[k] && $this[k](function (evt) {
$.proxy( data[ k ], el )( evt, data, me.root ) $.proxy(data[k], el)(evt, data, me.root)
} ) })
} ) })
} }
} ) });
}, },
disabled: function ( cb ) { _initEvent:function(){
$( 'li[class!=kmui-divider]', this.root() ).each( function () { this.root().on('mouseover','li[class="kmui-dropdown-submenu',function(e){
var $el = $( this ); var $submenu = $(this).data('widget');
if ( cb === true ) { $submenu.kmui().show($(this),'right','position',5,2)
$el.addClass( 'kmui-disabled' ) });
} else if ( $.isFunction( cb ) ) { },
$el.toggleClass( 'kmui-disabled', cb( li ) ) disabled: function (cb) {
$('li[class!=kmui-divider]', this.root()).each(function () {
var $el = $(this);
if (cb === true) {
$el.addClass('kmui-disabled')
} else if ($.isFunction(cb)) {
$el.toggleClass('kmui-disabled', cb(li))
} else { } else {
$el.removeClass( 'kmui-disabled' ) $el.removeClass('kmui-disabled')
} }
} ); });
}, },
val: function ( val ) { val: function (val) {
var currentVal; var currentVal;
$( 'li[class!="kmui-divider kmui-disabled kmui-dropdown-submenu"]', this.root() ).each( function () { $('li[class!="kmui-divider kmui-disabled kmui-dropdown-submenu"]', this.root()).each(function () {
var $el = $( this ); var $el = $(this);
if ( val === undefined ) { if (val === undefined) {
if ( $el.find( 'em.kmui-dropmenu-checked' ).length ) { if ($el.find('em.kmui-dropmenu-checked').length) {
currentVal = $el.data( 'value' ); currentVal = $el.data('value');
return false return false
} }
} else { } else {
$el.find( 'em' ).toggleClass( 'kmui-dropmenu-checked', $el.data( 'value' ) == val ) $el.find('em').toggleClass('kmui-dropmenu-checked', $el.data('value') == val)
} }
} ); });
if ( val === undefined ) { if (val === undefined) {
return currentVal return currentVal
} }
}, },
...@@ -5569,21 +5600,21 @@ KM.ui.define( 'dropmenu', { ...@@ -5569,21 +5600,21 @@ KM.ui.define( 'dropmenu', {
var $item = $( html ).click( item.click ); var $item = $( html ).click( item.click );
this.root().append( $item ); this.root().append( $item );
}, },
addSubmenu: function ( label, menu, index ) { addSubmenu: function (label, menu, index) {
index = index || 0; index = index || 0;
var $list = $( 'li[class!=kmui-divider]', this.root() ); var $list = $('li[class!=kmui-divider]', this.root());
var $node = $( '<li class="kmui-dropdown-submenu"><a tabindex="-1" href="#">' + label + '</a></li>' ).append( menu ); var $node = $('<li class="kmui-dropdown-submenu"><a tabindex="-1" href="#">' + label + '</a></li>').append(menu);
$node.data('widget',menu);
if ( index >= 0 && index < $list.length ) { if (index >= 0 && index < $list.length) {
$node.insertBefore( $list[ index ] ); $node.insertBefore($list[index]);
} else if ( index < 0 ) { } else if (index < 0) {
$node.insertBefore( $list[ 0 ] ); $node.insertBefore($list[0]);
} else if ( index >= $list.length ) { } else if (index >= $list.length) {
$node.appendTo( $list ); $node.appendTo($list);
} }
} }
}, 'menu' ); }, 'menu');
//splitbutton 类 //splitbutton 类
///import button ///import button
......
...@@ -91,7 +91,7 @@ $( function () { ...@@ -91,7 +91,7 @@ $( function () {
var options = { var options = {
response_type: 'token', response_type: 'token',
media_type: 'baidu', media_type: 'baidu',
redirect_uri: baseUrl + 'index.html', redirect_uri: window.location.href,
client_type: 'web' client_type: 'web'
}; };
baidu.frontia.social.login( options ); baidu.frontia.social.login( options );
...@@ -129,7 +129,7 @@ $( function () { ...@@ -129,7 +129,7 @@ $( function () {
by: 'time', by: 'time',
success: function ( result ) { success: function ( result ) {
if ( result.list.length ) { if ( result.list.length ) {
if ( !isShareLink ) { if ( !isShareLink && !thisMapFilename ) {
loadPersonal( result.list[ 0 ].path ); loadPersonal( result.list[ 0 ].path );
} else { } else {
$user_btn.loading( false ); $user_btn.loading( false );
...@@ -141,7 +141,7 @@ $( function () { ...@@ -141,7 +141,7 @@ $( function () {
} }
function addToRecentMenu( list ) { function addToRecentMenu( list ) {
list.splice(8); list.splice( 8 );
list.forEach( function ( file ) { list.forEach( function ( file ) {
$user_menu.appendItem( { $user_menu.appendItem( {
item: { item: {
...@@ -290,7 +290,7 @@ $( function () { ...@@ -290,7 +290,7 @@ $( function () {
function loadShare() { function loadShare() {
var pattern = /share_id=(\w+)([&#]|$)/; var pattern = /share_id=(\w+)([&#]|$)/;
var match = pattern.exec( window.location.href ); var match = pattern.exec( window.location ) || pattern.exec( document.referrer );
if ( !match ) return; if ( !match ) return;
var shareId = match[ 1 ]; var shareId = match[ 1 ];
var query = new baidu.frontia.storage.Query(); var query = new baidu.frontia.storage.Query();
...@@ -308,11 +308,23 @@ $( function () { ...@@ -308,11 +308,23 @@ $( function () {
} ); } );
isShareLink = true; isShareLink = true;
} }
function loadPath() {
var pattern = /path=(.+?)([&#]|$)/;
var match = pattern.exec( window.location ) || pattern.exec( document.referrer );
if ( !match ) return;
thisMapFilename = decodeURIComponent( match[ 1 ] );
}
loadShare(); loadShare();
currentUser = baidu.frontia.getCurrentAccount(); currentUser = baidu.frontia.getCurrentAccount();
if ( currentUser ) { if ( currentUser ) {
setCurrentUser( currentUser ); setCurrentUser( currentUser );
loadPath();
if(thisMapFilename) {
loadPersonal( thisMapFilename );
}
} else { } else {
$login_btn.appendTo( $panel ); $login_btn.appendTo( $panel );
} }
......
Subproject commit a9630e638b29633f62cdc2df239bc702118b231a Subproject commit ebccc80ba41995fa718b1fb0b8f7d79938501ed1
...@@ -39,8 +39,8 @@ KM.registerToolbarUI( 'saveto', function ( name ) { ...@@ -39,8 +39,8 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
var transform = renderContainer.getTransform(); var transform = renderContainer.getTransform();
renderContainer.resetTransform(); renderContainer.resetTransform();
var svg = $( svghtml ).attr( { var svg = $( svghtml ).attr( {
width: renderBox.x + renderBox.width, width: renderBox.width,
height: renderBox.y + renderBox.height, height: renderBox.height,
viewBox: null viewBox: null
} ); } );
var div = $( "<div></div>" ).append( svg ); var div = $( "<div></div>" ).append( svg );
......
...@@ -180,7 +180,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", { ...@@ -180,7 +180,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
node.parent.removeChild( node ); node.parent.removeChild( node );
} }
node.parent = this; node.parent = this;
node.root = parent.root; node.root = node.parent.root;
this.children.splice( index, 0, node ); this.children.splice( index, 0, node );
}, },
......
...@@ -17,6 +17,9 @@ var ViewDragger = kity.createClass( "ViewDragger", { ...@@ -17,6 +17,9 @@ var ViewDragger = kity.createClass( "ViewDragger", {
paper.setStyle( 'cursor', value ? '-webkit-grab' : 'default' ); paper.setStyle( 'cursor', value ? '-webkit-grab' : 'default' );
this._enabled = value; this._enabled = value;
}, },
move: function ( offset ) {
this._minder.getRenderContainer().translate( offset.x, offset.y );
},
_bind: function () { _bind: function () {
var dragger = this, var dragger = this,
...@@ -33,7 +36,7 @@ var ViewDragger = kity.createClass( "ViewDragger", { ...@@ -33,7 +36,7 @@ var ViewDragger = kity.createClass( "ViewDragger", {
} }
// 点击未选中的根节点临时开启 // 点击未选中的根节点临时开启
else if ( e.getTargetNode() == this.getRoot() && else if ( e.getTargetNode() == this.getRoot() &&
(!this.getRoot().isSelected() || !this.isSingleSelect())) { ( !this.getRoot().isSelected() || !this.isSingleSelect() ) ) {
lastPosition = e.getPosition(); lastPosition = e.getPosition();
dragger.setEnabled( true ); dragger.setEnabled( true );
isRootDrag = true; isRootDrag = true;
...@@ -47,8 +50,7 @@ var ViewDragger = kity.createClass( "ViewDragger", { ...@@ -47,8 +50,7 @@ var ViewDragger = kity.createClass( "ViewDragger", {
// 当前偏移加上历史偏移 // 当前偏移加上历史偏移
var offset = kity.Vector.fromPoints( lastPosition, currentPosition ); var offset = kity.Vector.fromPoints( lastPosition, currentPosition );
dragger.move( offset );
this.getRenderContainer().translate( offset.x, offset.y );
e.stopPropagation(); e.stopPropagation();
lastPosition = currentPosition; lastPosition = currentPosition;
} }
...@@ -100,6 +102,23 @@ KityMinder.registerModule( 'Hand', function () { ...@@ -100,6 +102,23 @@ KityMinder.registerModule( 'Hand', function () {
this.execCommand( 'hand' ); this.execCommand( 'hand' );
e.preventDefault(); e.preventDefault();
} }
},
mousewheel: function ( e ) {
var dx = e.originEvent.wheelDeltaX || 0,
dy = e.originEvent.wheelDeltaY || e.originEvent.wheelDelta;
this._viewDragger.move( {
x: dx / 2.5,
y: dy / 2.5
} );
e.originEvent.preventDefault();
},
dblclick: function() {
var viewport = this.getPaper().getViewPort();
var offset = this.getRoot().getRenderContainer(this.getRenderContainer()).getTransform().getTranslate();
var dx = viewport.center.x - offset.x,
dy = viewport.center.y - offset.y;
//this.getRenderContainer().fxTranslate(dx, dy, 300);
} }
} }
}; };
......
...@@ -408,9 +408,11 @@ KityMinder.registerModule( "LayoutBottom", function () { ...@@ -408,9 +408,11 @@ KityMinder.registerModule( "LayoutBottom", function () {
appendChildNode: function ( parent, node, sibling ) { appendChildNode: function ( parent, node, sibling ) {
node.clearLayout(); node.clearLayout();
var parentLayout = parent.getLayout(); var parentLayout = parent.getLayout();
var expand = parent.getData( "expand" );
//设置分支类型 //设置分支类型
if ( parent.getType() === "root" ) { if ( parent.getType() === "root" ) {
node.setType( "main" ); node.setType( "main" );
node.setData( "expand", true );
minder.handelNodeInsert( node ); minder.handelNodeInsert( node );
} else { } else {
node.setType( "sub" ); node.setType( "sub" );
...@@ -490,8 +492,15 @@ KityMinder.registerModule( "LayoutBottom", function () { ...@@ -490,8 +492,15 @@ KityMinder.registerModule( "LayoutBottom", function () {
} }
}, },
expandNode: function ( ico ) { expandNode: function ( ico ) {
var isExpand = ico.icon.switchState(); var isExpand, node;
var node = ico.icon._node; 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 _buffer = node.getChildren();
var _cleanbuffer = []; var _cleanbuffer = [];
......
...@@ -537,6 +537,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -537,6 +537,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
node.setType( "main" ); node.setType( "main" );
} else { } else {
node.setType( "sub" ); node.setType( "sub" );
//var isExpand = parent.getData( "expand" );
} }
//计算位置等流程 //计算位置等流程
updateBg( node ); updateBg( node );
...@@ -600,8 +601,15 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -600,8 +601,15 @@ KityMinder.registerModule( "LayoutDefault", function () {
} }
}, },
expandNode: function ( ico ) { expandNode: function ( ico ) {
var isExpand = ico.icon.switchState(); var isExpand, node;
var node = ico.icon._node; 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 _buffer = node.getChildren();
var _cleanbuffer = []; var _cleanbuffer = [];
......
...@@ -106,6 +106,9 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -106,6 +106,9 @@ KityMinder.registerModule( "LayoutModule", function () {
base: Command, base: Command,
execute: function ( km, node ) { execute: function ( km, node ) {
var parent = km.getSelectedNode(); var parent = km.getSelectedNode();
if ( parent.getType() !== "root" && parent.getChildren().length !== 0 && parent.getData( "expand" ) === false ) {
km.expandNode( parent );
}
km.appendChildNode( parent, node ); km.appendChildNode( parent, node );
km.select( node, true ); km.select( node, true );
return node; return node;
...@@ -129,7 +132,6 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -129,7 +132,6 @@ KityMinder.registerModule( "LayoutModule", function () {
node.setType( "main" ); node.setType( "main" );
km.appendChildNode( selectedNode, node ); km.appendChildNode( selectedNode, node );
} else { } else {
node.setType( "sub" );
km.appendSiblingNode( selectedNode, node ); km.appendSiblingNode( selectedNode, node );
} }
km.select( node, true ); km.select( node, true );
...@@ -203,29 +205,26 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -203,29 +205,26 @@ KityMinder.registerModule( "LayoutModule", function () {
this.initStyle( this.getRoot() ); this.initStyle( this.getRoot() );
} }
}, },
'contextmenu':[ 'contextmenu': [ {
{ label: this.getLang( 'node.appendsiblingnode' ),
label:this.getLang('node.appendsiblingnode'), exec: function () {
exec:function(){ this.execCommand( 'appendsiblingnode', new MinderNode( this.getLang( 'topic' ) ) )
this.execCommand('appendsiblingnode',new MinderNode(this.getLang('topic'))) },
}, cmdName: 'appendsiblingnode'
cmdName:'appendsiblingnode' }, {
}, label: this.getLang( 'node.appendchildnode' ),
{ exec: function () {
label:this.getLang('node.appendchildnode'), this.execCommand( 'appendchildnode', new MinderNode( this.getLang( 'topic' ) ) )
exec:function(){ },
this.execCommand('appendchildnode',new MinderNode(this.getLang('topic'))) cmdName: 'appendchildnode'
}, }, {
cmdName:'appendchildnode' label: this.getLang( 'node.removenode' ),
}, cmdName: 'removenode'
{ }, {
label:this.getLang('node.removenode'), divider: 1
cmdName:'removenode' }
},{
divider:1
}
], ],
"defaultOptions": { "defaultOptions": {
"defaultlayoutstyle": "default", "defaultlayoutstyle": "default",
"node": { "node": {
......
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