Commit 29d682a7 authored by campaign's avatar campaign

Merge branch 'dev' of https://github.com/kitygraph/kityminder into dev

parents e02ca71e f76a3351
(function(){
function getKMBasePath ( docUrl, confUrl ) {
( function () {
function getKMBasePath( docUrl, confUrl ) {
return getBasePath( docUrl || self.document.URL || self.location.href, confUrl || getConfigFilePath() );
}
function 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;
......@@ -34,15 +34,15 @@
}
function optimizationPath ( path ) {
function optimizationPath( path ) {
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 ] = "";
......@@ -63,7 +63,7 @@
'KITYMINDER_HOME_URL': getKMBasePath(),
//定义工具栏
toolbars: [
'hand zoom-in zoom-out | undo redo | bold italic | fontfamily fontsize forecolor | saveto | markers | node'
'hand zoom-in zoom-out | undo redo | bold italic | fontfamily fontsize forecolor | saveto | markers | node | layout'
]
//设置主题
......@@ -79,4 +79,4 @@
//设置km整体的z-index大小
//,zIndex : 1000
};
})()
} )()
\ No newline at end of file
......@@ -62,6 +62,7 @@ $dependency = Array(
,'src/adapter/view.js'
,'src/adapter/dialog.js'
,'src/adapter/tooltips.js'
,'src/adapter/layout.js'
,'src/adapter/node.js'
,'src/protocal/plain.js'
,'src/protocal/json.js'
......
......@@ -10,12 +10,13 @@ KityMinder.LANG[ 'zh-cn' ] = {
'fontfamily': '字体',
'fontsize': '字号',
'layoutstyle': '主题',
'node':'节点操作',
'node': '节点操作',
'saveto': '导出',
'hand': '允许拖拽',
'zoom-in': '放大',
'zoom-out': '缩小',
'markers': '添加标签'
'markers': '添加标签',
'layout': '切换主题'
},
'popupcolor': {
'clearColor': '清空颜色',
......@@ -40,10 +41,10 @@ KityMinder.LANG[ 'zh-cn' ] = {
}
}
},
'node':{
'appendsiblingnode':'插入兄弟节点',
'appendchildnode':'插入孩子节点',
'removenode':'删除节点'
'node': {
'appendsiblingnode': '插入兄弟节点',
'appendchildnode': '插入孩子节点',
'removenode': '删除节点'
}
};
\ No newline at end of file
KM.registerToolbarUI( 'layout', function ( name ) {
var me = this,
label = me.getLang( 'tooltips.' + name ),
options = {
label: label,
title: label,
comboboxName: name,
items: me.getLayoutStyleItems() || [],
itemStyles: [],
value: me.getLayoutStyleItems(),
autowidthitem: []
},
$combox = null;
if ( options.items.length == 0 ) {
return null;
}
//实例化
$combox = $.kmuibuttoncombobox( options ).css( 'zIndex', me.getOptions( 'zIndex' ) + 1 );
comboboxWidget = $combox.kmui();
comboboxWidget.on( 'comboboxselect', function ( evt, res ) {
me.execCommand( "switchlayout", res.value );
} ).on( "beforeshow", function () {
if ( $combox.parent().length === 0 ) {
$combox.appendTo( me.$container.find( '.kmui-dialog-container' ) );
}
} );
return comboboxWidget.button().addClass( 'kmui-combobox' );
} );
\ No newline at end of file
KM.registerToolbarUI( 'node', function ( name ) {
var shortcutKeys = {
var shortcutKeys = {
"appendsiblingnode": "enter",
"appendchildnode": "tab",
"removenode":"del|backspace"
"removenode": "del|backspace"
};
var me = this,
msg = me.getLang('node'),
msg = me.getLang( 'node' ),
label = me.getLang( 'tooltips.' + name ),
options = {
label: label,
......@@ -16,10 +16,9 @@ KM.registerToolbarUI( 'node', function ( name ) {
itemStyles: [],
value: [],
autowidthitem: [],
enabledRecord:false
enabledRecord: false
},
$combox = null;
if ( options.items.length == 0 ) {
return null;
}
......@@ -29,21 +28,21 @@ KM.registerToolbarUI( 'node', function ( name ) {
comboboxWidget = $combox.kmui();
comboboxWidget.on( 'comboboxselect', function ( evt, res ) {
me.execCommand( res.value,new MinderNode( me.getLang().topic ) );
}).on( "beforeshow", function () {
me.execCommand( res.value, new MinderNode( me.getLang().topic ) );
} ).on( "beforeshow", function () {
if ( $combox.parent().length === 0 ) {
$combox.appendTo( me.$container.find( '.kmui-dialog-container' ) );
}
var combox = $combox.kmui();
combox.traverseItems(function(label,value){
if(me.queryCommandState(value) == -1){
combox.disableItemByLabel(label)
}else{
combox.enableItemByLabel(label)
combox.traverseItems( function ( label, value ) {
if ( me.queryCommandState( value ) == -1 ) {
combox.disableItemByLabel( label )
} else {
combox.enableItemByLabel( label )
}
})
});
} )
} );
return comboboxWidget.button().addClass( 'kmui-combobox' );
......@@ -56,7 +55,7 @@ KM.registerToolbarUI( 'node', function ( name ) {
utils.each( options.items, function ( k, v ) {
options.value.push( v );
tempItems.push( (msg[k]||k) + '(' + shortcutKeys[v].toUpperCase() + ')');
tempItems.push( ( msg[ k ] || k ) + '(' + shortcutKeys[ v ].toUpperCase() + ')' );
options.autowidthitem.push( $.wordCountAdaptive( tempItems[ tempItems.length - 1 ] ) );
} );
......@@ -65,5 +64,4 @@ KM.registerToolbarUI( 'node', function ( name ) {
}
});
} );
\ No newline at end of file
......@@ -24,7 +24,6 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
options.autowidthitem.push( $.wordCountAdaptive( text ), true );
} );
//实例化
$combox = $.kmuibuttoncombobox( options ).css( 'zIndex', me.getOptions( 'zIndex' ) + 1 );
comboboxWidget = $combox.kmui();
......@@ -40,8 +39,15 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
if ( $combox.parent().length === 0 ) {
$combox.appendTo( me.$container.find( '.kmui-dialog-container' ) );
}
} ).on( 'aftercomboboxselect', function () {
this.setLabelWithDefaultValue();
var combox = $combox.kmui();
combox.traverseItems( function ( label, value ) {
if ( me.queryCommandState( value ) == -1 ) {
combox.disableItemByLabel( label )
} else {
combox.enableItemByLabel( label )
}
} )
} );
......
......@@ -8,7 +8,11 @@ KityMinder.registerModule( "LayoutModule", function () {
return this._layoutStyles[ name ];
},
getLayoutStyleItems: function () {
return this._layoutStyles;
var items = [];
for ( var key in this._layoutStyles ) {
items.push( key );
}
return items;
},
getCurrentStyle: function () {
var _root = this.getRoot();
......@@ -196,7 +200,7 @@ KityMinder.registerModule( "LayoutModule", function () {
}
},
"defaultOptions": {
"defaultlayoutstyle": "bottom",
"defaultlayoutstyle": "default",
"node": {
'appendsiblingnode': 'appendsiblingnode',
'appendchildnode': 'appendchildnode',
......
......@@ -29,11 +29,11 @@ KityMinder.registerModule( "Select", function () {
startPosition = g.snapToSharp( e.getPosition() );
},
selectMove: function ( e ) {
if(minder.isTextEditStatus()){
if ( minder.isTextEditStatus() ) {
return;
}
if ( !startPosition ) return;
var p1 = startPosition,
p2 = e.getPosition();
......@@ -67,7 +67,7 @@ KityMinder.registerModule( "Select", function () {
// 计算选中范围
minder.getRoot().traverse( function ( node ) {
var renderBox = node.getRenderContainer().getRenderBox();
var renderBox = node.getRenderContainer().getRenderBox( "top" );
if ( g.isBoxIntersect( renderBox, marquee ) ) {
selectedNodes.push( node );
}
......@@ -82,7 +82,7 @@ KityMinder.registerModule( "Select", function () {
}
if ( marqueeMode ) {
marqueeShape.fadeOut( 200, 'ease', 0, function () {
if(marqueeShape.remove) marqueeShape.remove();
if ( marqueeShape.remove ) marqueeShape.remove();
} );
marqueeMode = false;
}
......
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