Commit 6f547367 authored by Akikonata's avatar Akikonata

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

parents 4c0db9f7 2f15bc11
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
"<%if(autoRecord) {%>" + "<%if(autoRecord) {%>" +
"<%for( var i=0, len = recordStack.length; i<len; i++ ) {%>" + "<%for( var i=0, len = recordStack.length; i<len; i++ ) {%>" +
"<%var index = recordStack[i];%>" + "<%var index = recordStack[i];%>" +
"<li class=\"<%=itemClassName%><%if( selected == index ) {%> kmui-combobox-checked<%}%>\" data-item-index=\"<%=index%>\" unselectable=\"on\" onmousedown=\"return false\">" + "<li class=\"<%=itemClassName%><%if( selected == index ) {%> kmui-combobox-checked<%}%><%if( disabled[ index ] === true ) {%> kmui-combobox-item-disabled<%}%>\" data-item-index=\"<%=index%>\" unselectable=\"on\" onmousedown=\"return false\">" +
"<span class=\"kmui-combobox-icon\" unselectable=\"on\" onmousedown=\"return false\"></span>" + "<span class=\"kmui-combobox-icon\" unselectable=\"on\" onmousedown=\"return false\"></span>" +
"<label class=\"<%=labelClassName%>\" style=\"<%=itemStyles[ index ]%>\" unselectable=\"on\" onmousedown=\"return false\"><%=items[index]%></label>" + "<label class=\"<%=labelClassName%>\" style=\"<%=itemStyles[ index ]%>\" unselectable=\"on\" onmousedown=\"return false\"><%=items[index]%></label>" +
"</li>" + "</li>" +
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
"<%}%>" + "<%}%>" +
"<%}%>" + "<%}%>" +
"<%for( var i=0, label; label = items[i]; i++ ) {%>" + "<%for( var i=0, label; label = items[i]; i++ ) {%>" +
"<li class=\"<%=itemClassName%><%if( selected == i ) {%> kmui-combobox-checked<%}%> kmui-combobox-item-<%=i%>\" data-item-index=\"<%=i%>\" unselectable=\"on\" onmousedown=\"return false\">" + "<li class=\"<%=itemClassName%><%if( selected == i ) {%> kmui-combobox-checked<%}%> kmui-combobox-item-<%=i%><%if( disabled[ i ] === true ) {%> kmui-combobox-item-disabled<%}%>\" data-item-index=\"<%=i%>\" unselectable=\"on\" onmousedown=\"return false\">" +
"<span class=\"kmui-combobox-icon\" unselectable=\"on\" onmousedown=\"return false\"></span>" + "<span class=\"kmui-combobox-icon\" unselectable=\"on\" onmousedown=\"return false\"></span>" +
"<label class=\"<%=labelClassName%>\" style=\"<%=itemStyles[ i ]%>\" unselectable=\"on\" onmousedown=\"return false\"><%=label%></label>" + "<label class=\"<%=labelClassName%>\" style=\"<%=itemStyles[ i ]%>\" unselectable=\"on\" onmousedown=\"return false\"><%=label%></label>" +
"</li>" + "</li>" +
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
value: [], value: [],
comboboxName: '', comboboxName: '',
selected: '', selected: '',
//初始禁用状态
disabled: {},
//自动记录 //自动记录
autoRecord: true, autoRecord: true,
//最多记录条数 //最多记录条数
...@@ -126,11 +128,17 @@ ...@@ -126,11 +128,17 @@
*/ */
select: function( index ){ select: function( index ){
var itemCount = this.data('options').itemCount, var options = this.data( 'options' ),
items = this.data('options').autowidthitem; itemCount = options.itemCount,
items = options.autowidthitem;
if ( items && !items.length ) { if ( items && !items.length ) {
items = this.data('options').items; items = options.items;
}
// 禁用
if ( options.disabled[ index ] ) {
return null;
} }
if( itemCount == 0 ) { if( itemCount == 0 ) {
...@@ -178,6 +186,58 @@ ...@@ -178,6 +186,58 @@
} ); } );
}, },
getItems: function () {
return this.data( "options" ).items;
},
getItemMapping: function () {
return this.data( "options" ).itemMapping;
},
disableItemByIndex: function ( index ) {
var options = this.data( "options" );
options.disabled[ index ] = true;
this._repaint();
},
disableItemByLabel: function ( label ) {
var itemMapping = this.data('options').itemMapping,
index = itemMapping[ label ];
if ( typeof index === "number" ) {
return this.disableItemByIndex( index );
}
return false;
},
enableItemByIndex: function ( index ) {
var options = this.data( "options" );
delete options.disabled[ index ];
this._repaint();
},
enableItemByLabel: function ( label ) {
var itemMapping = this.data('options').itemMapping,
index = itemMapping[ label ];
if ( typeof index === "number" ) {
return this.enableItemByIndex( index );
}
return false;
},
/** /**
* 转换记录栈 * 转换记录栈
*/ */
...@@ -256,8 +316,7 @@ ...@@ -256,8 +316,7 @@
_update: function ( index ) { _update: function ( index ) {
var options = this.data("options"), var options = this.data("options"),
newStack = [], newStack = [];
newChilds = null;
$.each( options.recordStack, function( i, item ){ $.each( options.recordStack, function( i, item ){
...@@ -277,13 +336,20 @@ ...@@ -277,13 +336,20 @@
options.recordStack = newStack; options.recordStack = newStack;
options.selected = index; options.selected = index;
newChilds = $( $.parseTmpl( this.tpl, options ) ); this._repaint();
newStack = null;
},
_repaint: function () {
var newChilds = $( $.parseTmpl( this.tpl, this.data("options") ) );
//重新渲染 //重新渲染
this.root().html( newChilds.html() ); this.root().html( newChilds.html() );
newChilds = null; newChilds = null;
newStack = null;
} }
}; };
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
.kmui-combobox-menu .kmui-combobox-item { .kmui-combobox-menu .kmui-combobox-item {
display: block; display: block;
border: 1px solid white; border: 1px solid white;
white-space:nowrap;
} }
.kmui-combobox-menu .kmui-combobox-item-label { .kmui-combobox-menu .kmui-combobox-item-label {
...@@ -184,4 +185,13 @@ ...@@ -184,4 +185,13 @@
/* h6 */ /* h6 */
.kmui-combobox-paragraph .kmui-combobox-item-6 .kmui-combobox-item-label { .kmui-combobox-paragraph .kmui-combobox-item-6 .kmui-combobox-item-label {
font-size: 12px; font-size: 12px;
}
.kmui-combobox-menu .kmui-combobox-item-disabled {
opacity: 0.3;
}
.kmui-combobox-menu .kmui-combobox-item-disabled:HOVER {
border-color: #fff;
background-color: #fff;
} }
\ 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