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 @@
"<%if(autoRecord) {%>" +
"<%for( var i=0, len = recordStack.length; i<len; 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>" +
"<label class=\"<%=labelClassName%>\" style=\"<%=itemStyles[ index ]%>\" unselectable=\"on\" onmousedown=\"return false\"><%=items[index]%></label>" +
"</li>" +
......@@ -31,7 +31,7 @@
"<%}%>" +
"<%}%>" +
"<%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>" +
"<label class=\"<%=labelClassName%>\" style=\"<%=itemStyles[ i ]%>\" unselectable=\"on\" onmousedown=\"return false\"><%=label%></label>" +
"</li>" +
......@@ -46,6 +46,8 @@
value: [],
comboboxName: '',
selected: '',
//初始禁用状态
disabled: {},
//自动记录
autoRecord: true,
//最多记录条数
......@@ -126,11 +128,17 @@
*/
select: function( index ){
var itemCount = this.data('options').itemCount,
items = this.data('options').autowidthitem;
var options = this.data( 'options' ),
itemCount = options.itemCount,
items = options.autowidthitem;
if ( items && !items.length ) {
items = this.data('options').items;
items = options.items;
}
// 禁用
if ( options.disabled[ index ] ) {
return null;
}
if( itemCount == 0 ) {
......@@ -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 @@
_update: function ( index ) {
var options = this.data("options"),
newStack = [],
newChilds = null;
newStack = [];
$.each( options.recordStack, function( i, item ){
......@@ -277,13 +336,20 @@
options.recordStack = newStack;
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() );
newChilds = null;
newStack = null;
}
};
......
......@@ -19,6 +19,7 @@
.kmui-combobox-menu .kmui-combobox-item {
display: block;
border: 1px solid white;
white-space:nowrap;
}
.kmui-combobox-menu .kmui-combobox-item-label {
......@@ -184,4 +185,13 @@
/* h6 */
.kmui-combobox-paragraph .kmui-combobox-item-6 .kmui-combobox-item-label {
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