Commit 68fb69e2 authored by campaign's avatar campaign

by zhanyi

parent d285ccb7
KM.registerUI('saveto', function( name ) {
var me = this,
label = me.getLang('tooltips.' + name),
options = {
label: label,
title: label,
comboboxName: name,
items: [],
itemStyles: [],
value: [],
autowidthitem: []
},
$combox = null,
comboboxWidget = null;
utils.each(KityMinder.getAllRegisteredProtocals(),function(k){
options.value.push(k);
options.items.push(k);
options.autowidthitem.push($.wordCountAdaptive( k ) );
});
//实例化
$combox = $.kmuibuttoncombobox(options).css('zIndex',me.getOptions('zIndex') + 1);
comboboxWidget = $combox.kmui();
comboboxWidget.on('comboboxselect', function( evt, res ){
alert(me.exportData(res.value));
}).on("beforeshow", function(){
if( $combox.parent().length === 0 ) {
$combox.appendTo( me.$container.find('.kmui-dialog-container') );
}
}).on('aftercomboboxselect',function(){
this.setLabelWithDefaultValue()
});
return comboboxWidget.button().addClass('kmui-combobox');
});
/**
* 宽度自适应工具函数
* @param word 单词内容
* @param hasSuffix 是否含有后缀
*/
$.wordCountAdaptive = function( 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 );
}
};
\ 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