fineui是帆软报表和BI产品线所使用的前端框架。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.1 KiB

8 years ago
/**
* 选择字段trigger小一号的
*
* @class BI.SmallSelectTextTrigger
* @extends BI.Trigger
*/
BI.SmallSelectTextTrigger = BI.inherit(BI.Trigger, {
_defaultConfig: function () {
return BI.extend(BI.SmallSelectTextTrigger.superclass._defaultConfig.apply(this, arguments), {
8 years ago
baseCls: "bi-small-select-text-trigger bi-border",
3 years ago
height: 20,
8 years ago
});
},
_init: function () {
BI.SmallSelectTextTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options;
6 years ago
var obj = this._digest(o.value, o.items);
8 years ago
this.trigger = BI.createWidget({
type: "bi.small_text_trigger",
8 years ago
element: this,
height: BI.pixFormat(o.height, 2),
7 years ago
text: obj.text,
3 years ago
cls: obj.cls,
textHgap: o.textHgap,
textVgap: o.textVgap,
textLgap: o.textLgap,
textRgap: o.textRgap,
textTgap: o.textTgap,
textBgap: o.textBgap,
8 years ago
});
},
7 years ago
_digest: function(vals, items){
8 years ago
var o = this.options;
vals = BI.isArray(vals) ? vals : [vals];
var result = [];
7 years ago
var formatItems = BI.Tree.transformToArrayFormat(items);
BI.each(formatItems, function (i, item) {
if (BI.deepContains(vals, item.value) && !BI.contains(result, item.text || item.value)) {
8 years ago
result.push(item.text || item.value);
}
});
if (result.length > 0) {
7 years ago
return {
cls: "",
text: result.join(",")
}
8 years ago
} else {
7 years ago
return {
cls: "bi-water-mark",
text: o.text
}
8 years ago
}
},
7 years ago
setValue: function (vals) {
var formatValue = this._digest(vals, this.options.items);
this.trigger.element.removeClass("bi-water-mark").addClass(formatValue.cls);
this.trigger.setText(formatValue.text);
7 years ago
},
8 years ago
populate: function (items) {
this.options.items = items;
}
});
3 years ago
BI.shortcut("bi.small_select_text_trigger", BI.SmallSelectTextTrigger);