Commit 8adf6816 authored by campaign's avatar campaign

by zhanyi

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