Commit d91df167 authored by techird's avatar techird

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

Conflicts:
	src/core/node.js
parents e4083e3a d3b81471
window.KITYMINDER_CONFIG = { window.KITYMINDER_CONFIG = {
//定义工具栏
toolbars:[
'undo redo | bold italic | forecolor | layoutstyle | fontfamily fontsize'
]
//设置主题 //设置主题
//layoutstyle : 'default' //,defaultlayoutstyle : 'default' //设置默认的主题
//,layoutstyle : [] //添加有那些主图
//回退相关选项 //回退相关选项
//maxUndoCount:20 //最大可回退的次数,默认20 //,maxUndoCount:20 //最大可回退的次数,默认20
//语言默认是zh-cn
//,lang:'zh-cn'
//设置km整体的z-index大小
//,zIndex : 1000
}; };
\ No newline at end of file
...@@ -4,8 +4,10 @@ ...@@ -4,8 +4,10 @@
<head> <head>
<script src="jquery-2.1.0.min.js"></script> <script src="jquery-2.1.0.min.js"></script>
<script src="kity.all.js"></script> <script src="kity.all.js"></script>
<script src="../configure.js"></script>
<script src="../dist/dev.php"></script> <script src="../dist/dev.php"></script>
<link href="import.css" /> <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> <style>
.km_receiver{ .km_receiver{
width:300px;height:300px; width:300px;height:300px;
...@@ -15,25 +17,11 @@ ...@@ -15,25 +17,11 @@
} }
</style> </style>
</head> </head>
<body style="background:#262626; margin:0; padding:0"> <body >
<div id="kityminder" style="height:1000px;width:100%" onselectstart="return false"> <div id="kityminder" style="height:1000px;width:100%" onselectstart="return false">
<select id="StyleChange">
<option value="default">Default</option>
<option value="green" selected>Green</option>
</select>
</div> </div>
</body> </body>
<script> <script>
var minder = KM.createMinder(kityminder); KM.getKityMinder('kityminder');
document.getElementById("StyleChange").addEventListener("change",function(e){
var val = e.target.value;
minder.execCommand("switchlayout",val);
},false);
minder.select(minder.getRoot());
var node = new KM.MinderNode('test');
node.setData('fontcolor','red');
minder.execCommand('appendChildNode',node);
// var b = new kity.Bezier([new kity.BezierPoint(0,0).setVertex(100,100),new kity.BezierPoint(100,0).setVertex(100,100)]);
// minder.getRenderContainer().addShape(b.stroke("white"));
</script> </script>
</html> </html>
\ No newline at end of file
...@@ -14,6 +14,8 @@ $dependency = Array( ...@@ -14,6 +14,8 @@ $dependency = Array(
,'src/core/minder.command.js' ,'src/core/minder.command.js'
,'src/core/minder.node.js' ,'src/core/minder.node.js'
,'src/core/keymap.js' ,'src/core/keymap.js'
,'src/core/minder.lang.js'
,'src/core/minder.defaultoptions.js'
,'src/module/history.js' ,'src/module/history.js'
,'src/module/icon.js' ,'src/module/icon.js'
,'src/module/layout.js' ,'src/module/layout.js'
...@@ -29,6 +31,26 @@ $dependency = Array( ...@@ -29,6 +31,26 @@ $dependency = Array(
,'src/module/editor.cursor.js' ,'src/module/editor.cursor.js'
,'src/module/basestyle.js' ,'src/module/basestyle.js'
,'src/module/font.js' ,'src/module/font.js'
,'src/ui/widget.js'
,'src/ui/button.js'
,'src/ui/toolbar.js'
,'src/ui/menu.js'
,'src/ui/dropmenu.js'
,'src/ui/splitbutton.js'
,'src/ui/colorsplitbutton.js'
,'src/ui/popup.js'
,'src/ui/scale.js'
,'src/ui/colorpicker.js'
,'src/ui/combobox.js'
,'src/ui/buttoncombobox.js'
,'src/ui/modal.js'
,'src/ui/tooltip.js'
,'src/ui/tab.js'
,'src/ui/separator.js'
,'src/ui/scale.js'
,'src/adapter/adapter.js'
,'src/adapter/button.js'
,'src/adapter/combobox.js'
); );
......
KityMinder.LANG['zh-cn'] = {
'tooltips':{
'undo':'撤销', 'redo':'重做',
'bold':'加粗', 'italic':'斜体',
'forecolor':'字体颜色', 'fontfamily':'字体', 'fontsize':'字号',
'layoutstyle':'选择主题'
},
'popupcolor':{
'clearColor':'清空颜色',
'standardColor':'标准颜色',
'themeColor':'主题颜色'
}
};
\ No newline at end of file
utils.extend(KityMinder,function(){
var _kityminderUI = {},
_activeWidget = null,
_widgetData = {},
_widgetCallBack = {};
return {
registerUI:function(uiname,fn){
utils.each(uiname.split(/\s+/), function (i,name) {
_kityminderUI[name] = fn;
})
},
_createUI:function(id){
var $cont = $('<div class="kmui-container"></div>'),
$toolbar = $.kmuitoolbar(),
$kmbody = $('<div class="kmui-editor-body"></div>'),
$statusbar = $('<div class="kmui-statusbar"></div>');
$cont.append($toolbar).append($kmbody).append($statusbar);
$(utils.isString(id) ? '#' + id : id).append($cont);
return {
'$container':$cont,
'$toolbar':$toolbar,
'$body':$kmbody,
'$statusbar':$statusbar
};
},
_createToolbar:function($toolbar,km){
var toolbars = km.getOptions('toolbars');
if (toolbars && toolbars.length) {
var btns = [];
$.each(toolbars,function(i,uiNames){
$.each(uiNames.split(/\s+/),function(index,name){
if(name == '|'){
$.kmuiseparator && btns.push($.kmuiseparator());
}else{
if(_kityminderUI[name]){
var ui = _kityminderUI[name].call(km,name);
ui && btns.push(ui);
}
}
});
btns.length && $toolbar.kmui().appendToBtnmenu(btns);
});
}
$toolbar.append($('<div class="kmui-dialog-container"></div>'));
},
_createStatusbar:function($statusbar,km){
},
getKityMinder:function(id,options){
var containers = this._createUI(id);
var km = this.getMinder(containers.$body.get(0),options);
this._createToolbar(containers.$toolbar,km);
this._createStatusbar(containers.$statusbar,km);
km.$container = containers.$container;
},
registerWidget : function(name,pro,cb){
_widgetData[name] = $.extend2(pro,{
$root : '',
_preventDefault:false,
root:function($el){
return this.$root || (this.$root = $el);
},
preventDefault:function(){
this._preventDefault = true;
},
clear:false
});
if(cb){
_widgetCallBack[name] = cb;
}
},
getWidgetData : function(name){
return _widgetData[name]
},
setWidgetBody : function(name,$widget,km){
if(!km._widgetData){
utils.extend(km,{
_widgetData : {},
getWidgetData : function(name){
return this._widgetData[name];
},
getWidgetCallback : function(widgetName){
var me = this;
return function(){
return _widgetCallBack[widgetName].apply(me,[me,$widget].concat(utils.argsToArray(arguments,0)))
}
}
})
}
var pro = _widgetData[name];
if(!pro){
return null;
}
pro = km._widgetData[name];
if(!pro){
pro = _widgetData[name];
pro = km._widgetData[name] = $.type(pro) == 'function' ? pro : utils.clone(pro);
}
pro.root($widget.kmui().getBodyContainer());
pro.initContent(km,$widget);
if(!pro._preventDefault){
pro.initEvent(km,$widget);
}
pro.width && $widget.width(pro.width);
},
setActiveWidget : function($widget){
_activeWidget = $widget;
}
}
}());
KM.registerUI('bold italic redo undo',
function(name) {
var me = this;
var $btn = $.kmuibutton({
icon : name,
click : function(){
me.execCommand(name);
},
title: this.getLang('tooltips')[name] || ''
});
this.on('interactchange',function(){
var state = this.queryCommandState(name);
$btn.kmui().disabled(state == -1).active(state == 1)
});
return $btn;
}
);
KM.registerUI('layoutstyle fontfamily fontsize', function( name ) {
var me = this,
label = me.getLang('tooltips.' + name),
options = {
label: label,
title: label,
comboboxName: name,
items: me.getOptions(name) || [],
itemStyles: [],
value: [],
autowidthitem: []
},
$combox = null,
comboboxWidget = null;
if(options.items.length == 0){
return null;
}
switch ( name ) {
case 'layoutstyle':
options = transForLayoutstyle( options );
break;
case 'fontfamily':
options = transForFontfamily( options );
break;
case 'fontsize':
options = transForFontsize( options );
break;
}
//实例化
$combox = $.kmuibuttoncombobox(options).css('zIndex',me.getOptions('zIndex') + 1);
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') );
}
});
//状态反射
this.on('interactchange',function( ){
var state = this.queryCommandState( name ),
value = this.queryCommandValue( name );
//设置按钮状态
comboboxWidget.button().kmui().disabled( state == -1 ).active( state == 1 );
if(value){
//设置label
value = value.replace(/['"]/g, '').toLowerCase().split(/['|"]?\s*,\s*[\1]?/);
comboboxWidget.selectItemByLabel( value );
}
});
return comboboxWidget.button().addClass('kmui-combobox');
/**
* 宽度自适应工具函数
* @param word 单词内容
* @param hasSuffix 是否含有后缀
*/
function wordCountAdaptive ( word, hasSuffix ) {
var $tmpNode = $('<span>' ).html( word ).css( {
display: 'inline',
position: 'absolute',
top: -10000000,
left: -100000
} ).appendTo( document.body),
width = $tmpNode.width();
$tmpNode.remove();
$tmpNode = null;
if( width < 50 ) {
return word;
} else {
word = word.slice( 0, hasSuffix ? -4 : -1 );
if( !word.length ) {
return '...';
}
return wordCountAdaptive( word + '...', true );
}
}
function transForLayoutstyle ( options ) {
var tempItems = [];
utils.each(options.items,function(k,v){
options.value.push(k);
tempItems.push(k);
options.autowidthitem.push( wordCountAdaptive( tempItems[ tempItems.length - 1 ] ) );
});
options.items = tempItems;
return options;
}
//字体参数转换
function transForFontfamily ( options ) {
var temp = null,
tempItems = [];
for( var i = 0, len = options.items.length; i < len; i++ ) {
temp = options.items[ i ].val;
tempItems.push( temp.split(/\s*,\s*/)[0] );
options.itemStyles.push('font-family: ' + temp);
options.value.push( temp );
options.autowidthitem.push( wordCountAdaptive( tempItems[ i ] ) );
}
options.items = tempItems;
return options;
}
//字体大小参数转换
function transForFontsize ( options ) {
var temp = null,
tempItems = [];
options.itemStyles = [];
options.value = [];
for( var i = 0, len = options.items.length; i < len; i++ ) {
temp = options.items[ i ];
tempItems.push( temp );
options.itemStyles.push('font-size: ' + temp +'px');
}
options.value = options.items;
options.items = tempItems;
options.autoRecord = false;
return options;
}
});
KM.registerUI('forecolor', function( name ) {
function getCurrentColor() {
return $colorLabel.css('background-color');
}
var me = this,
$colorPickerWidget = null,
$colorLabel = null,
$btn = null;
this.on('interactchange', function(){
var state = this.queryCommandState( name );
$btn.kmui().disabled( state == -1 ).active( state == 1 );
});
$btn = $.kmuicolorsplitbutton({
icon: name,
caret: true,
name: name,
title: this.getLang('tooltips')[name] || '',
click: function() {
me.execCommand( name, getCurrentColor() );
}
});
$colorLabel = $btn.kmui().colorLabel();
$colorPickerWidget = $.kmuicolorpicker({
name: name,
lang_clearColor: me.getLang('popupcolor')['clearColor']|| '',
lang_themeColor: me.getLang('popupcolor')['themeColor'] || '',
lang_standardColor: me.getLang('popupcolor')['standardColor'] || ''
}).on('pickcolor', function( evt, color ){
window.setTimeout( function(){
$colorLabel.css("backgroundColor", color);
me.execCommand( name, color );
}, 0 );
}).on('show',function(){
KM.setActiveWidget( $colorPickerWidget.kmui().root() );
}).css('zIndex',me.getOptions('zIndex') + 1);
$btn.kmui().on('arrowclick',function(){
if(!$colorPickerWidget.parent().length){
me.$container.find('.kmui-dialog-container').append($colorPickerWidget);
}
$colorPickerWidget.kmui().show($btn,{
caretDir:"down",
offsetTop:-5,
offsetLeft:8,
caretLeft:11,
caretTop:-8
});
}).register('click', $btn, function () {
$colorPickerWidget.kmui().hide()
});
return $btn;
});
\ No newline at end of file
...@@ -28,7 +28,9 @@ var KityMinder = ...@@ -28,7 +28,9 @@ var KityMinder =
id = target.id || ( "KM_INSTANCE_" + instanceId++ ); id = target.id || ( "KM_INSTANCE_" + instanceId++ );
} }
return instanceMap[ id ] || this.createMinder(target,options); return instanceMap[ id ] || this.createMinder(target,options);
} },
//挂接多语言
LANG:{}
} }
}(); }();
//这里只放不是由模块产生的默认参数
KM.defaultOptions = {
zIndex : 1000,
lang:'zh-cn'
};
\ No newline at end of file
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
var Minder = KityMinder.Minder = kity.createClass( "KityMinder", { var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
constructor: function ( options ) { constructor: function ( options ) {
this._options = Utils.extend( window.KITYMINDER_CONFIG || {}, options ); this._options = Utils.extend( window.KITYMINDER_CONFIG || {}, options );
this.setDefaultOptions(KM.defaultOptions);
this._initEvents(); this._initEvents();
this._initMinder(); this._initMinder();
this._initSelection(); this._initSelection();
...@@ -29,7 +30,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", { ...@@ -29,7 +30,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
} else { } else {
obj = key; obj = key;
} }
Utils.extend( this._options, obj, true ); utils.extend( this._options, obj, true );
}, },
_initMinder: function () { _initMinder: function () {
......
//添加多语言模块
kity.extendClass( Minder, {
getLang:function(path){
var lang = KM.LANG[this.getOptions('lang')];
if (!lang) {
throw Error("not import language file");
}
path = (path || "").split(".");
for (var i = 0, ci; ci = path[i++];) {
lang = lang[ci];
if (!lang)break;
}
return lang;
}
} );
\ No newline at end of file
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
kity.extendClass( Minder, function () { kity.extendClass( Minder, function () {
function highlightNode( km, node ) { function highlightNode( km, node ) {
node.setData( "highlight", true ); node.setData( "highlight", true );
km.renderNode( node ); km.highlightNode( node );
} }
function unhighlightNode( km, node ) { function unhighlightNode( km, node ) {
node.setData( "highlight", false ); node.setData( "highlight", false );
km.renderNode( node ); km.highlightNode( node );
} }
return { return {
_initSelection: function () { _initSelection: function () {
......
...@@ -9,7 +9,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", { ...@@ -9,7 +9,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
this.setData( options ); this.setData( options );
} }
this._createShapeDom(); this._createShapeDom();
this.setData( "layout", {} );
}, },
_createShapeDom: function () { _createShapeDom: function () {
this.rc = new kity.Group(); this.rc = new kity.Group();
...@@ -37,7 +37,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", { ...@@ -37,7 +37,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
getContRc: function () { getContRc: function () {
var groups = this.rc.getShapesByType( 'group' ), var groups = this.rc.getShapesByType( 'group' ),
result; result;
utils.each( groups, function ( i, p ) { Utils.each( groups, function ( i, p ) {
if ( p.getData( 'rctype' ) == 'contrc' ) { if ( p.getData( 'rctype' ) == 'contrc' ) {
result = p; result = p;
return false; return false;
...@@ -48,7 +48,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", { ...@@ -48,7 +48,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
getBgRc: function () { getBgRc: function () {
var groups = this.rc.getShapesByType( 'group' ), var groups = this.rc.getShapesByType( 'group' ),
result; result;
utils.each( groups, function ( i, p ) { Utils.each( groups, function ( i, p ) {
if ( p.getData( 'rctype' ) == 'bgrc' ) { if ( p.getData( 'rctype' ) == 'bgrc' ) {
result = p; result = p;
return false; return false;
......
/**
* 模块初始化函数:模块名称大写,以 Module 作为后缀
*/
KityMinder.registerModule( "ExampleModule", function () {
//console.log( "You can cheat: 上下左右ABAB" );
// TODO: 初始化模块静态变量
var cheatCode = "38 40 37 39 65 66 65 66".split( ' ' );
// TODO: 进行模块命令定义
// HINT: 复杂的命令也可以在其它的文件中定义
var ExampleCommand = kity.createClass( "ExampleCommand", {
base: Command,
/**
* 命令执行函数
* @required
* @param {KityMinder} km 命令执行时的 KityMinder 实例
*/
execute: function ( km ) {
// this.setContentChange(true) 可以告知 KM 命令的执行导致了内容的变化,KM会抛出 contentchange 事件
// this.setSelectionChange(true) 可以告知 KM 命令的执行导致了选区的变化,KM会抛出 selectionchange 事件
window.alert( 'you cheat!' );
},
/**
* 命令状态查询
* @optional
* @param {KityMinder} km 命令查询针对的 KityMinder 实例
* @return {int} 返回 0 表示命令在正常状态(Default)
* 返回 1 表示命令在生效的状态
* 返回 -1 表示命令当前不可用
*/
queryState: function ( km ) {
},
/**
* 命令当前值查询
* @param {KityMinder} km 命令查询针对的 KityMinder 实例
* @return {any} 返回命令自定义类型数据。
*/
queryValue: function ( km ) {
}
} );
return {
// TODO: 默认属性
"defaultOptions": {
"test": 123
},
// TODO: 初始化完成后执行的函数
"init": function ( config ) {
// console.log( "init", config );
},
// TODO: 需要注册的命令
"commands": {
// 约定:命令名称全用小写
"cheat": ExampleCommand
},
// TODO: 需要注册的事件
"events": {
"click": function ( e ) {
// 支持的鼠标事件:mousedown, mouseup, mousemove, click
},
"keydown": function ( e ) {
// 支持的键盘事件:keydown, keyup, keypress
if ( !this._cheated || this._cheated[ 0 ] != e.keyCode ) {
this._cheated = cheatCode.slice( 0 );
}
if ( this._cheated[ 0 ] == e.keyCode ) {
this._cheated.shift();
}
// console.log( this._cheated );
if ( this._cheated.length === 0 ) {
this.execCommand( 'cheat' );
}
},
"beforeExecCommand": function ( e ) {
// e.cancel() 方法可以阻止 before 事件进入下个阶段
// e.cancelImmediately() 方法可以阻止当前回调后的回调执行,并且阻止事件进入下个阶段
console.log( e.type + ' fired' );
e.stopPropagation();
},
"preExecCommand": function ( e ) {
// 命令执行后的事件
console.log( e.type + ' fired' );
},
"contentchange": function ( e ) {
// 内容改变后的事件
},
"selectionchange": function ( e ) {
// 选区改变后的事件
}
},
// TODO: 定义模块的destroy方法
"destroy": function () {
console.log( "destroy" );
},
// TODO: 定义模块的reset方法
"reset": function () {
console.log( "reset" );
}
};
} );
\ No newline at end of file
...@@ -13,11 +13,13 @@ KityMinder.registerModule( "basestylemodule", function () { ...@@ -13,11 +13,13 @@ KityMinder.registerModule( "basestylemodule", function () {
utils.each(nodes,function(i,n){ utils.each(nodes,function(i,n){
n.setData('bold'); n.setData('bold');
n.getTextShape().setAttr('font-weight'); n.getTextShape().setAttr('font-weight');
km.updateLayout(n)
}) })
}else{ }else{
utils.each(nodes,function(i,n){ utils.each(nodes,function(i,n){
n.setData('bold',true); n.setData('bold',true);
n.getTextShape().setAttr('font-weight','bold'); n.getTextShape().setAttr('font-weight','bold');
km.updateLayout(n)
}) })
} }
}, },
...@@ -43,11 +45,13 @@ KityMinder.registerModule( "basestylemodule", function () { ...@@ -43,11 +45,13 @@ KityMinder.registerModule( "basestylemodule", function () {
utils.each(nodes,function(i,n){ utils.each(nodes,function(i,n){
n.setData('italic'); n.setData('italic');
n.getTextShape().setAttr('font-style'); n.getTextShape().setAttr('font-style');
km.updateLayout(n)
}) })
}else{ }else{
utils.each(nodes,function(i,n){ utils.each(nodes,function(i,n){
n.setData('italic',true); n.setData('italic',true);
n.getTextShape().setAttr('font-style','italic'); n.getTextShape().setAttr('font-style','italic');
km.updateLayout(n)
}) })
} }
}, },
......
...@@ -88,7 +88,6 @@ Minder.Receiver = kity.createClass('Receiver',{ ...@@ -88,7 +88,6 @@ Minder.Receiver = kity.createClass('Receiver',{
this.textShape.setContent(text); this.textShape.setContent(text);
this.setContainerStyle(); this.setContainerStyle();
this.minderNode.setText(text); this.minderNode.setText(text);
this.km.renderNode(this.minderNode);
this.km.updateLayout(this.minderNode); this.km.updateLayout(this.minderNode);
this.setBaseOffset(); this.setBaseOffset();
this.updateTextData(); this.updateTextData();
......
KityMinder.registerModule( "fontmodule", function () { KityMinder.registerModule( "fontmodule", function () {
return { return {
defaultOptions:{
'fontfamily': [
{ name: 'songti', val: '宋体,SimSun'},
{ name: 'yahei', val: '微软雅黑,Microsoft YaHei'},
{ name: 'kaiti', val: '楷体,楷体_GB2312, SimKai'},
{ name: 'heiti', val: '黑体, SimHei'},
{ name: 'lishu', val: '隶书, SimLi'},
{ name: 'andaleMono', val: 'andale mono'},
{ name: 'arial', val: 'arial, helvetica,sans-serif'},
{ name: 'arialBlack', val: 'arial black,avant garde'},
{ name: 'comicSansMs', val: 'comic sans ms'},
{ name: 'impact', val: 'impact,chicago'},
{ name: 'timesNewRoman', val: 'times new roman'},
{ name: 'sans-serif',val:'sans-serif'}
],
'fontsize': [10, 12, 16, 18,24, 32,48]
},
"commands": { "commands": {
"fontcolor": kity.createClass( "fontcolorCommand", { "forecolor": kity.createClass( "fontcolorCommand", {
base: Command, base: Command,
execute: function ( km, color ) { execute: function ( km, color ) {
...@@ -23,6 +39,19 @@ KityMinder.registerModule( "fontmodule", function () { ...@@ -23,6 +39,19 @@ KityMinder.registerModule( "fontmodule", function () {
utils.each( nodes, function ( i, n ) { utils.each( nodes, function ( i, n ) {
n.setData( 'fontfamily', family ); n.setData( 'fontfamily', family );
n.getTextShape().setAttr( 'font-family', family ); n.getTextShape().setAttr( 'font-family', family );
km.updateLayout(n)
} )
}
} ),
"fontsize": kity.createClass( "fontsizeCommand", {
base: Command,
execute: function ( km, size ) {
var nodes = km.getSelectedNodes();
utils.each( nodes, function ( i, n ) {
n.setData( 'fontsize', size );
n.getTextShape().setSize(size);
km.updateLayout(n)
} ) } )
} }
} ) } )
...@@ -35,6 +64,7 @@ KityMinder.registerModule( "fontmodule", function () { ...@@ -35,6 +64,7 @@ KityMinder.registerModule( "fontmodule", function () {
e.node.getTextShape().setAttr( 'font-family', val ); e.node.getTextShape().setAttr( 'font-family', val );
} }
if ( val = e.node.getData( 'fontcolor' ) ) { if ( val = e.node.getData( 'fontcolor' ) ) {
console.log( val );
e.node.getTextShape().fill( val ); e.node.getTextShape().fill( val );
} }
} }
......
...@@ -60,37 +60,35 @@ KityMinder.registerModule( "KeyboardModule", function () { ...@@ -60,37 +60,35 @@ KityMinder.registerModule( "KeyboardModule", function () {
buildPositionNetwork( this.getRoot() ); buildPositionNetwork( this.getRoot() );
}, },
keydown: function ( e ) { keydown: function ( e ) {
switch ( e.originEvent.keyCode ) { switch ( e.originEvent.keyCode ) {
case keymap.Enter:
this.execCommand( 'appendSiblingNode', new MinderNode( 'Topic' ) );
e.preventDefault();
break;
case keymap.Tab:
this.execCommand( 'appendChildNode', new MinderNode( 'Topic' ) );
e.preventDefault();
break;
case keymap.Backspace:
case keymap.Del:
this.execCommand( 'removenode' );
e.preventDefault();
break;
case keymap.Enter: case keymap.Left:
this.execCommand( 'appendSiblingNode', new MinderNode( 'Topic' ) ); case keymap.up:
e.preventDefault(); case keymap.Right:
break; case keymap.Down:
case keymap.Tab: if ( this.isSingleSelect() ) {
this.execCommand( 'appendChildNode', new MinderNode( 'Topic' ) ); KBNavigate( this, {
e.preventDefault(); 37: 'left',
break; 38: 'top',
case keymap.Backspace: 39: 'right',
case keymap.Del: 40: 'down'
this.execCommand( 'removenode' ); }[ e.originEvent.keyCode ] );
e.preventDefault(); }
break; e.preventDefault();
break;
case keymap.Left:
case keymap.up:
case keymap.Right:
case keymap.Down:
if ( this.isSingleSelect() ) {
KBNavigate( this, {
37: 'left',
38: 'top',
39: 'right',
40: 'down'
}[ e.originEvent.keyCode ] );
}
e.preventDefault();
break;
} }
} }
......
This diff is collapsed.
...@@ -7,6 +7,9 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -7,6 +7,9 @@ KityMinder.registerModule( "LayoutModule", function () {
getLayoutStyle: function ( name ) { getLayoutStyle: function ( name ) {
return this._layoutStyles[ name ]; return this._layoutStyles[ name ];
}, },
getLayoutStyleItems: function () {
return this._layoutStyles;
},
getCurrentStyle: function () { getCurrentStyle: function () {
var _root = this.getRoot(); var _root = this.getRoot();
return _root.getData( "currentstyle" ); return _root.getData( "currentstyle" );
...@@ -16,12 +19,13 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -16,12 +19,13 @@ KityMinder.registerModule( "LayoutModule", function () {
_root.setData( "currentstyle", name ); _root.setData( "currentstyle", name );
return name; return name;
}, },
renderNode: function ( node ) { highlightNode: function ( node ) {
var curStyle = this.getCurrentStyle(); var curStyle = this.getCurrentStyle();
this.getLayoutStyle( curStyle ).renderNode.call( this, node ); this.getLayoutStyle( curStyle ).highlightNode.call( this, node );
}, },
initStyle: function () { initStyle: function () {
var curStyle = this.getCurrentStyle(); var curStyle = this.getCurrentStyle();
this.getRenderContainer().clear();
this.getLayoutStyle( curStyle ).initStyle.call( this ); this.getLayoutStyle( curStyle ).initStyle.call( this );
}, },
appendChildNode: function ( parent, node, index ) { appendChildNode: function ( parent, node, index ) {
...@@ -39,6 +43,10 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -39,6 +43,10 @@ KityMinder.registerModule( "LayoutModule", function () {
updateLayout: function ( node ) { updateLayout: function ( node ) {
var curStyle = this.getCurrentStyle(); var curStyle = this.getCurrentStyle();
this.getLayoutStyle( curStyle ).updateLayout.call( this, node ); this.getLayoutStyle( curStyle ).updateLayout.call( this, node );
},
expandNode: function ( ico ) {
var curStyle = this.getCurrentStyle();
this.getLayoutStyle( curStyle ).expandNode.call( this, ico );
} }
} ); } );
kity.extendClass( MinderNode, { kity.extendClass( MinderNode, {
...@@ -128,11 +136,11 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -128,11 +136,11 @@ KityMinder.registerModule( "LayoutModule", function () {
for ( var i = 0; i < selectedNodes.length; i++ ) { for ( var i = 0; i < selectedNodes.length; i++ ) {
_buffer.push( selectedNodes[ i ] ); _buffer.push( selectedNodes[ i ] );
} }
while ( _buffer.length !== 1 ) { do {
var parent = _buffer[ 0 ].getParent(); var parent = _buffer[ 0 ].getParent();
if ( parent && _buffer.indexOf( parent ) === -1 ) _buffer.push( parent ); if ( parent && _buffer.indexOf( parent ) === -1 ) _buffer.push( parent );
_buffer.shift(); _buffer.shift();
} } while ( _buffer.length !== 1 );
km.removeNode( selectedNodes ); km.removeNode( selectedNodes );
km.select( _buffer[ 0 ] ); km.select( _buffer[ 0 ] );
} }
...@@ -148,11 +156,18 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -148,11 +156,18 @@ KityMinder.registerModule( "LayoutModule", function () {
}, },
"events": { "events": {
"ready": function () { "ready": function () {
switchLayout( this, this.getOptions( 'layoutstyle' ) ); this.setDefaultOptions( 'layoutstyle', this.getLayoutStyleItems() );
switchLayout( this, this.getOptions( 'defaultlayoutstyle' ) );
},
"click": function ( e ) {
var ico = e.kityEvent.targetShape.container;
if ( ico.class === "shicon" ) {
this.expandNode( ico );
}
} }
}, },
"defaultOptions": { "defaultOptions": {
"layoutstyle": "default" "defaultlayoutstyle": "default"
} }
}; };
} ); } );
\ No newline at end of file
/*普通按钮*/
.kmui-btn-toolbar .kmui-btn{
position: relative;
display: inline-block;
vertical-align: top;
*display: inline;
*zoom:1;
width:auto;
margin: 0 1px;
padding:1px;
border:none;
background: none;
}
.kmui-btn-toolbar .kmui-btn .kmui-icon{
width: 20px;
height: 20px;
margin: 0;
padding:0;
background-repeat: no-repeat;
background-image: url(../images/icons.png);
background-image: url(../images/icons.gif) \9;
}
/*状态反射*/
.kmui-btn-toolbar .kmui-btn.kmui-hover,
.kmui-btn-toolbar .kmui-btn.kmui-active{
background-color: #d5e1f2;
padding: 0;
border: 1px solid #a3bde3;
_z-index: 1;
}
.kmui-btn-toolbar .kmui-btn.kmui-disabled{
opacity: 0.3;
filter: alpha(opacity = 30);
}
\ No newline at end of file
.kmui-btn-toolbar .kmui-btn .kmui-icon-undo {
background-position: -160px 0;
}
.kmui-btn-toolbar .kmui-btn .kmui-icon-redo {
background-position: -100px 0;
}
.kmui-btn-toolbar .kmui-btn .kmui-icon-bold{
background-position: 0 0;
}
.kmui-btn-toolbar .kmui-btn .kmui-icon-italic {
background-position: -60px 0;
}
.kmui-btn-toolbar .kmui-btn .kmui-icon-font, .kmui-btn-toolbar .kmui-btn .kmui-icon-forecolor {
background-position: -720px 0;
}
.kmui-splitbutton-color-label {
width: 16px;
height: 3px;
position: absolute;
bottom: 2px;
left: 50%;
margin-left: -8px;
overflow: hidden;
line-height: 3px;
}
.kmui-popup .kmui-colorpicker {
margin: 10px;
font-size: 12px;
}
.kmui-colorpicker .kmui-colorpicker-topbar{
height: 27px;
width: 200px;
overflow: hidden;
}
.kmui-colorpicker .kmui-colorpicker-topbar .kmui-colorpicker-preview{
height: 20px;
border: 1px inset black;
margin-left: 1px;
width: 128px;
float: left;
}
.kmui-colorpicker .kmui-colorpicker-topbar .kmui-colorpicker-nocolor{
float: right;
margin-right: 1px;
font-size: 12px;
line-height: 14px;
height: 14px;
border: 1px solid #333;
padding: 3px 5px;
cursor: pointer;
}
.kmui-colorpicker table{
border-collapse: collapse;
border-spacing: 2px;
}
.kmui-colorpicker tr.kmui-colorpicker-firstrow{
height: 30px;
}
.kmui-colorpicker table td{
padding: 0 2px;
}
.kmui-colorpicker table td .kmui-colorpicker-colorcell{
display: block;
text-decoration: none;
color: black;
width: 14px;
height: 14px;
margin: 0;
cursor: pointer;
}
\ No newline at end of file
.kmui-btn-toolbar .kmui-combobox{
border: 1px solid #CCC;
padding:0;
margin:0 2px;
line-height: 20px;
}
.kmui-combobox .kmui-button-label{
position: relative;
display: inline-block;
vertical-align: top;
*display: inline ;
*zoom:1;
width:60px;
height:20px;
line-height: 20px;
padding: 2px;
margin: 0;
font-size: 12px;
text-align: center;
cursor: default;
}
.kmui-combobox .kmui-button-spacing{
position: relative;
display: inline-block ;
vertical-align: top;
*display: inline ;
*zoom:1;
height:20px;
margin: 0;
padding:0 3px;
}
.kmui-combobox .kmui-caret{
position: relative;
display: inline-block ;
vertical-align: top;
*display: inline ;
*zoom:1;
height:20px;
width: 12px;
margin: 0;
padding: 0;
background: url(../images/icons.png) -741px 0;
_background: url(../images/icons.gif) -741px 0;
}
.kmui-btn-toolbar .kmui-combobox.kmui-disabled{
opacity: 0.2;
filter: alpha(opacity = 20);
}
.kmui-combobox-menu{
position: absolute;
top: 100%;
left: 0;
display: none;
list-style: none;
text-decoration: none;
margin: 0;
padding:5px;
background-color: #ffffff;
border: 1px solid #ccc;
font-size: 12px;
box-shadow: 2px 2px 5px #d3d6da;
min-width: 160px;
_width: 160px;
}
.kmui-combobox-menu .kmui-combobox-item {
display: block;
border: 1px solid white;
}
.kmui-combobox-menu .kmui-combobox-item-label {
height: 25px;
line-height: 25px;
display: inline-block;
_display: inline;
_zoom: 1;
margin-left: 10px;
}
.kmui-combobox-menu .kmui-combobox-item:hover, .kmui-combobox-menu .kmui-combobox-stack-item:hover, .kmui-combobox-menu .kmui-combobox-item-hover {
background-color: #d5e1f2;
padding: 0;
border: 1px solid #a3bde3;
}
.kmui-combobox-menu .kmui-combobox-item .kmui-combobox-icon {
display: inline-block;
*zoom: 1;
*display: inline;
width: 24px;
height: 25px;
background: red;
vertical-align: bottom;
background: url(../images/ok.gif) no-repeat 1000px 1000px;
}
.kmui-combobox-menu .kmui-combobox-checked .kmui-combobox-icon {
background-position: 10px 7px;
}
.kmui-combobox-menu .kmui-combobox-item-separator {
min-width: 160px;
height: 1px;
line-height: 1px;
overflow: hidden;
background: #d3d3d3;
margin: 5px 0;
*margin-top: -8px;
}
/* 字体样式校正 */
.kmui-combobox-fontsize .kmui-combobox-item-0.kmui-combobox-checked .kmui-combobox-icon {
background-position: 10px 7px;
}
.kmui-combobox-fontsize .kmui-combobox-item-1.kmui-combobox-checked .kmui-combobox-icon {
background-position: 10px 7px;
}
.kmui-combobox-fontsize .kmui-combobox-item-2.kmui-combobox-checked .kmui-combobox-icon {
background-position: 10px 7px;
}
.kmui-combobox-fontsize .kmui-combobox-item-3.kmui-combobox-checked .kmui-combobox-icon {
background-position: 10px 7px;
}
/* 24 */
.kmui-combobox-fontsize .kmui-combobox-item-4 .kmui-combobox-item-label {
height: 27px;
line-height: 27px;
}
.kmui-combobox-fontsize .kmui-combobox-item-4.kmui-combobox-checked .kmui-combobox-icon {
background-position: 10px 5px;
}
/* 32 */
.kmui-combobox-fontsize .kmui-combobox-item-5 .kmui-combobox-item-label {
height: 31px;
line-height: 31px;
}
.kmui-combobox-fontsize .kmui-combobox-item-5.kmui-combobox-checked .kmui-combobox-icon {
background-position: 10px 4px;
}
/* 48 */
.kmui-combobox-fontsize .kmui-combobox-item-6 .kmui-combobox-item-label {
height: 47px;
line-height: 47px;
}
/*.kmui-combobox-fontsize .kmui-combobox-item-6 .kmui-combobox-icon {*/
/*height: 25px;*/
/*margin-bottom: 11px;*/
/*}*/
/*.kmui-combobox-fontsize .kmui-combobox-item-6.kmui-combobox-checked .kmui-combobox-icon {*/
/*background-position: 10px 7px;*/
/*}*/
/* 段落样式校正 */
/* h1 */
.kmui-combobox-paragraph .kmui-combobox-item-1 .kmui-combobox-item-label {
font-size: 32px;
height: 36px;
line-height: 36px;
}
.kmui-combobox-paragraph .kmui-combobox-item-1 .kmui-combobox-icon {
height: 25px;
margin-bottom: 5px;
}
.kmui-combobox-paragraph .kmui-combobox-item-1.kmui-combobox-checked .kmui-combobox-icon {
background-position: 10px 7px;
}
/* h2 */
.kmui-combobox-paragraph .kmui-combobox-item-2 .kmui-combobox-item-label {
font-size: 28px;
height: 27px;
line-height: 27px;
}
.kmui-combobox-paragraph .kmui-combobox-item-2 .kmui-combobox-icon {
margin-bottom: 5px;
}
.kmui-combobox-paragraph .kmui-combobox-item-2.kmui-combobox-checked .kmui-combobox-icon {
background-position: 10px 10px;
}
/* h3 */
.kmui-combobox-paragraph .kmui-combobox-item-3 .kmui-combobox-item-label {
font-size: 24px;
height: 25px;
line-height: 25px;
}
.kmui-combobox-paragraph .kmui-combobox-item-3 .kmui-combobox-icon {
height: 25px;
margin-bottom: 5px;
}
.kmui-combobox-paragraph .kmui-combobox-item-3.kmui-combobox-checked .kmui-combobox-icon {
background-position: 10px 11px;
}
/* h4 */
.kmui-combobox-paragraph .kmui-combobox-item-4 .kmui-combobox-item-label {
font-size: 18px;
height: 25px;
line-height: 25px;
}
.kmui-combobox-paragraph .kmui-combobox-item-4.kmui-combobox-checked .kmui-combobox-icon {
background-position: 10px 6px;
}
/* h5 */
.kmui-combobox-paragraph .kmui-combobox-item-5 .kmui-combobox-item-label {
font-size: 16px;
}
/* h6 */
.kmui-combobox-paragraph .kmui-combobox-item-6 .kmui-combobox-item-label {
font-size: 12px;
}
\ No newline at end of file
.kmui-modal {
position: fixed;
_position: absolute;
top: 10%;
left: 50%;
border: 1px solid #acacac;
box-shadow: 2px 2px 5px #d3d6da;
background-color: #ffffff;
outline: 0;
}
.kmui-modal-header {
padding: 5px 10px;
border-bottom: 1px solid #eee;
}
.kmui-modal-header .kmui-close {
float: right;
width:20px;
height:20px;
margin-top: 2px;
padding: 1px;
border: 0;
background: url("../images/close.png") no-repeat center center;
cursor: pointer;
}
.kmui-modal-header .kmui-close.kmui-hover {
background-color: #d5e1f2;
padding:0;
border: 1px solid #a3bde3;
}
.kmui-modal-header .kmui-title {
margin: 0;
line-height: 25px;
font-size: 20px;
}
.kmui-modal-body {
position: relative;
max-height: 400px;
font-size: 12px;
overflow-y: auto;
}
.kmui-modal-footer {
float: right;
padding: 5px 15px 15px;
overflow: hidden;
}
.kmui-modal-footer .kmui-btn {
float: left;
height: 24px;
width: 96px;
margin: 0 10px;
background-color: #ffffff;
padding: 0;
border: 1px solid #ababab;
font-size: 12px;
line-height: 24px;
text-align: center;
cursor: pointer;
}
.kmui-modal-footer .kmui-btn.kmui-hover{
background-color: #d5e1f2;
border: 1px solid #a3bde3;
}
.kmui-modal-backdrop{
opacity: 0.5;
filter: alpha(opacity=50);
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: #c6c6c6;
}
.kmui-modal .kmui-modal-tip {
color: red;
position: absolute;
bottom: 10px;
left: 10px;
height: 30px;
line-height: 30px;
display: none;
}
\ No newline at end of file
/*图片上传*/
.kmui-dialog-image-body {
width: 700px;
height: 400px;
}
/*插入视频*/
.kmui-dialog-video-body{
width: 600px;
height: 350px;
}
/*谷歌地图*/
.kmui-dialog-gmap-body{
width:550px;
height: 400px;
}
/*百度地图*/
.kmui-dialog-map-body{
width:580px;
height: 400px;
}
/*链接*/
.kmui-dialog-link-body{
width:400px;
height:200px;
}
\ No newline at end of file
@import "kityminder.css";
@import "button.css";
@import "buttonicon.css";
@import "splitbutton.css";
@import "combobox.css";
@import "comboboxmenu.css";
@import "dialog.css";
@import "dialogsize.css";
@import "popup.css";
@import "tab.css";
@import "tooltip.css";
@import "colorpicker.css";
@import "separator.css";
.kmui-container{
position: relative;
border: 1px solid #d4d4d4;
box-shadow: 2px 2px 5px #d3d6da;
background-color: #fff;
}
.kmui-container .kmui-toolbar{
position: relative;
width:auto;
border-bottom: 1px solid #e1e1e1;
box-shadow: 2px 2px 5px #d3d6da;
background-color: #fafafa;
z-index: 99999;
}
.kmui-toolbar .kmui-btn-toolbar{
position: relative;
padding: 5px;
}
.kmui-container .kmui-editor-body{
background-color: #000000;
}
\ No newline at end of file
.kmui-popup{
display: none;
background: url('../images/pop-bg.png') repeat #fff;
padding: 2px;
}
.kmui-popup .kmui-popup-body{
border: 1px solid #bfbfbf;
background-color: #fff;
}
.kmui-popup .kmui-popup-caret{
width: 21px;
height: 11px;
}
.kmui-popup .kmui-popup-caret.up{
background:url('../images/caret.png') no-repeat 0 0;
}
.kmui-popup .kmui-popup-caret.down{
background:url('../images/caret.png') no-repeat 0 0;
}
.kmui-toolbar .kmui-separator{
width: 2px;
height: 20px;
padding: 1px 2px;
background: url(../images/icons.png) -179px 1px;
background: url(../images/icons.gif) -179px 1px \9;
display: inline-block ;
vertical-align: top;
*display: inline ;
*zoom:1;
border:none;
}
\ No newline at end of file
.kmui-btn-toolbar .kmui-splitbutton{
position: relative;
display: inline-block ;
vertical-align: top;
*display: inline ;
*zoom:1;
margin:0 2px;
}
.kmui-splitbutton .kmui-btn{
margin: 0;
}
.kmui-splitbutton .kmui-caret{
position: relative;
display: inline-block ;
vertical-align: top;
*display: inline ;
*zoom:1;
width: 8px;
height: 20px;
background: url(../images/icons.png) -741px 0;
_background: url(../images/icons.gif) -741px 0;
}
.kmui-btn-toolbar .kmui-splitbutton,
.kmui-btn-toolbar .kmui-splitbutton{
_border: none;
}
/*状态反射*/
.kmui-btn-toolbar .kmui-splitbutton.kmui-hover .kmui-btn{
background-color: #d5e1f2;
}
.kmui-btn-toolbar .kmui-splitbutton.kmui-disabled{
opacity: 0.3;
filter: alpha(opacity = 30);
}
.kmui-tab-nav {
margin: 0;
padding:0;
border-bottom: 1px solid #ddd;
list-style: none;
height:30px;
}
.kmui-tab-nav .kmui-tab-item {
float:left;
margin-bottom: -1px;
margin-top: 1px;
margin-top: 0\9;
}
.kmui-tab-nav .kmui-tab-item .kmui-tab-text{
display: block;
padding:8px 12px;
border: 1px solid transparent;
color: #0088cc;
text-decoration: none;
outline: 0;
_border:1px solid #fff ;
cursor: pointer;
}
.kmui-tab-nav .kmui-tab-item .kmui-tab-text:FOCUS {
outline: none;
}
.kmui-tab-nav .kmui-tab-item.kmui-active .kmui-tab-text{
border: 1px solid #ddd;
border-bottom-color: transparent;
background-color: #fff;
padding:8px 12px;
color: #555555;
cursor: default;
}
.kmui-tab-content .kmui-tab-pane{
padding: 1px;
position: relative;
display: none;
background-color: #fff;
clear: both;
}
.kmui-tab-content .kmui-tab-pane.kmui-active{
display: block;
}
.kmui-btn-toolbar .kmui-tooltip{
position: absolute;
padding: 5px 0;
display: none;
/*opacity: 0.8;*/
/*filter: alpha(opacity=80);*/
z-index: 99999;
}
.kmui-tooltip .kmui-tooltip-arrow{
position: absolute;
top: 0;
_top: -19px;
left: 50%;
width: 0;
height: 0;
padding: 0;
margin-left: -5px;
border-color: transparent;
border-style: dashed dashed solid dashed;
border-bottom-color: #000000;
border-width: 0 5px 5px;
background: transparent;
}
.kmui-tooltip .kmui-tooltip-inner{
padding: 6px;
color: #ffffff;
text-align: center;
text-decoration: none;
font-size: 10px;
background-color: #000000;
white-space: nowrap;
line-height: 12px;
}
\ 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