Commit 8adf6816 authored by campaign's avatar campaign

by zhanyi

parent 0c2f2610
......@@ -63,7 +63,7 @@
'KITYMINDER_HOME_URL': getKMBasePath(),
//定义工具栏
toolbars: [
'hand zoom-in zoom-out | undo redo | bold italic | fontfamily fontsize forecolor | saveto | markers | node | layout'
'hand zoom-in zoom-out | undo redo | bold italic | fontfamily fontsize forecolor | saveto | markers | node | switchlayout'
]
//设置主题
......
......@@ -16,7 +16,7 @@ KityMinder.LANG[ 'zh-cn' ] = {
'zoom-in': '放大',
'zoom-out': '缩小',
'markers': '添加标签',
'layout': '切换主题'
'switchlayout': '切换主题'
},
'popupcolor': {
'clearColor': '清空颜色',
......
KM.registerToolbarUI( 'layout', function ( name ) {
KM.registerToolbarUI( 'switchlayout', function ( name ) {
debugger
var me = this,
label = me.getLang( 'tooltips.' + name ),
options = {
......@@ -8,7 +9,8 @@ KM.registerToolbarUI( 'layout', function ( name ) {
items: me.getLayoutStyleItems() || [],
itemStyles: [],
value: me.getLayoutStyleItems(),
autowidthitem: []
autowidthitem: [],
enabledRecord:false
},
$combox = null;
if ( options.items.length == 0 ) {
......@@ -20,20 +22,25 @@ KM.registerToolbarUI( 'layout', function ( name ) {
comboboxWidget = $combox.kmui();
comboboxWidget.on( 'comboboxselect', function ( evt, res ) {
me.execCommand( "switchlayout", res.value );
me.execCommand( name, res.value );
} ).on( "beforeshow", function () {
if ( $combox.parent().length === 0 ) {
$combox.appendTo( me.$container.find( '.kmui-dialog-container' ) );
}
} );
//状态反射
me.on( 'interactchange', function () {
var value = this.queryCommandValue( "switchlayout" );
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' );
} );
\ No newline at end of file
......@@ -134,9 +134,7 @@
*/
select: function( index ){
if(!this.data('options').enabledRecord){
return this;
}
var options = this.data( 'options' ),
itemCount = options.itemCount,
items = options.autowidthitem;
......@@ -166,6 +164,7 @@
this.trigger( 'changebefore', items[ index ] );
this._update( index );
this.trigger( 'changeafter', items[ index ] );
......@@ -334,22 +333,25 @@
var options = this.data("options"),
newStack = [];
$.each( options.recordStack, function( i, item ){
if(this.data('options').enabledRecord){
$.each( options.recordStack, function( i, item ){
if( item != index ) {
newStack.push( item );
}
if( item != index ) {
newStack.push( item );
}
} );
} );
//压入最新的记录
newStack.unshift( index );
//压入最新的记录
newStack.unshift( index );
if( newStack.length > options.recordCount ) {
newStack.length = options.recordCount;
}
if( newStack.length > options.recordCount ) {
newStack.length = options.recordCount;
options.recordStack = newStack;
}
options.recordStack = newStack;
options.selected = index;
this._repaint();
......
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