Browse Source

Merge pull request #253 in FUI/fineui from ~WINDY/fui:master to master

* commit 'f5a9f694d0799bf65d222c69b174d541d0d60fa9':
  button可配bubble&可搜索的单选下拉框
es6
guy 7 years ago
parent
commit
19ade01566
  1. 12
      demo/js/base/button/demo.button.js
  2. 74
      demo/js/case/combo/demo.search_text_value_combo.js
  3. 4
      demo/js/config/case.js
  4. 65
      dist/base.js
  5. 346
      dist/bundle.js
  6. 281
      dist/case.js
  7. 89
      dist/demo.js
  8. 346
      dist/fineui.js
  9. 65
      src/base/single/button/button.basic.js
  10. 108
      src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js
  11. 67
      src/case/combo/searchtextvaluecombo/popup.searchtextvalue.js
  12. 107
      src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js
  13. 2
      src/case/editor/editor.state.js

12
demo/js/base/button/demo.button.js

@ -204,6 +204,18 @@ Demo.Button = BI.inherit(BI.Widget, {
ghost: true, ghost: true,
height: 30 height: 30
} }
}, {
el: {
type: "bi.button",
text: "弹出bubble",
bubble: function () {
return BI.parseInt(Math.random() * 100) % 10 + "提示"
},
handler: function () {
BI.Msg.toast("1111");
},
height: 30
}
} }
]; ];
// BI.each(items, function (i, item) { // BI.each(items, function (i, item) {

74
demo/js/case/combo/demo.search_text_value_combo.js

@ -0,0 +1,74 @@
/**
* Created by Windy on 2018/2/4.
*/
Demo.SearchTextValueCombo = BI.inherit(BI.Widget, {
props: {
baseCls: ""
},
render: function () {
var combo;
return {
type: "bi.horizontal_auto",
items: [{
type: "bi.search_text_value_combo",
ref: function () {
combo = this;
},
text: "默认值",
value: 2,
width: 300,
items: [{
text: "ABC-1",
iconCls: "date-font",
value: 1
}, {
text: "BCD-2",
iconCls: "search-font",
value: 2
}, {
text: "CDE-3",
iconCls: "pull-right-font",
value: 3
}, {
text: "DEF-3",
iconCls: "pull-right-font",
value: 4
}, {
text: "FEG-3",
iconCls: "pull-right-font",
value: 5
}, {
text: "FGH-3",
iconCls: "pull-right-font",
value: 6
}, {
text: "GHI-3",
iconCls: "pull-right-font",
value: 7
}, {
text: "HIJ-3",
iconCls: "pull-right-font",
value: 8
}, {
text: "IJK-3",
iconCls: "pull-right-font",
value: 9
}, {
text: "JKL-3",
iconCls: "pull-right-font",
value: 10
}]
}, {
type: "bi.button",
width: 90,
height: 25,
handler: function () {
combo.setValue(3);
}
}],
vgap: 20
};
}
});
BI.shortcut("demo.search_text_value_combo", Demo.SearchTextValueCombo);

4
demo/js/config/case.js

@ -130,6 +130,10 @@ Demo.CASE_CONFIG = [{
pId: 306, pId: 306,
text: "bi.text_value_combo", text: "bi.text_value_combo",
value: "demo.text_value_combo" value: "demo.text_value_combo"
}, {
pId: 306,
text: "bi.search_text_value_combo",
value: "demo.search_text_value_combo"
}, { }, {
pId: 306, pId: 306,
text: "bi.icon_text_value_combo", text: "bi.icon_text_value_combo",

65
dist/base.js vendored

@ -624,7 +624,8 @@ BI.BasicButton = BI.inherit(BI.Single, {
shadow: false, shadow: false,
isShadowShowingOnSelected: false, // 选中状态下是否显示阴影 isShadowShowingOnSelected: false, // 选中状态下是否显示阴影
trigger: null, trigger: null,
handler: BI.emptyFn handler: BI.emptyFn,
bubble: null
}); });
}, },
_init: function () { _init: function () {
@ -816,8 +817,70 @@ BI.BasicButton = BI.inherit(BI.Single, {
if (!self.isEnabled() || (self.isOnce() && self.isSelected())) { if (!self.isEnabled() || (self.isOnce() && self.isSelected())) {
return; return;
} }
if(BI.isKey(o.bubble) || BI.isFunction(o.bubble)) {
if(BI.isNull(self.combo)){
var popup;
BI.createWidget({
type: "bi.absolute",
element: self,
items: [{
el: {
type: "bi.bubble_combo",
trigger: "",
ref: function () {
self.combo = this;
},
el: {
type: "bi.layout",
height: "100%"
},
popup: {
type: "bi.text_bubble_bar_popup_view",
text: getBubble(),
ref: function () {
popup = this;
},
listeners: [{
eventName: BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON,
action: function (v) {
self.combo.hideView();
if(v){
onClick.apply(self, arguments);
}
}
}]
},
listeners: [{
eventName: BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW,
action: function () {
popup.populate(getBubble());
}
}]
},
left: 0,
right: 0,
bottom: 0,
top: 0
}]
});
}
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
return;
}
onClick.apply(self, arguments); onClick.apply(self, arguments);
} }
function getBubble() {
var bubble = self.options.bubble;
if(BI.isFunction(bubble)) {
return bubble();
}
return bubble;
}
}, },
_trigger: function () { _trigger: function () {

346
dist/bundle.js vendored

@ -26676,7 +26676,8 @@ BI.BasicButton = BI.inherit(BI.Single, {
shadow: false, shadow: false,
isShadowShowingOnSelected: false, // 选中状态下是否显示阴影 isShadowShowingOnSelected: false, // 选中状态下是否显示阴影
trigger: null, trigger: null,
handler: BI.emptyFn handler: BI.emptyFn,
bubble: null
}); });
}, },
_init: function () { _init: function () {
@ -26868,8 +26869,70 @@ BI.BasicButton = BI.inherit(BI.Single, {
if (!self.isEnabled() || (self.isOnce() && self.isSelected())) { if (!self.isEnabled() || (self.isOnce() && self.isSelected())) {
return; return;
} }
if(BI.isKey(o.bubble) || BI.isFunction(o.bubble)) {
if(BI.isNull(self.combo)){
var popup;
BI.createWidget({
type: "bi.absolute",
element: self,
items: [{
el: {
type: "bi.bubble_combo",
trigger: "",
ref: function () {
self.combo = this;
},
el: {
type: "bi.layout",
height: "100%"
},
popup: {
type: "bi.text_bubble_bar_popup_view",
text: getBubble(),
ref: function () {
popup = this;
},
listeners: [{
eventName: BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON,
action: function (v) {
self.combo.hideView();
if(v){
onClick.apply(self, arguments); onClick.apply(self, arguments);
} }
}
}]
},
listeners: [{
eventName: BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW,
action: function () {
popup.populate(getBubble());
}
}]
},
left: 0,
right: 0,
bottom: 0,
top: 0
}]
});
}
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
return;
}
onClick.apply(self, arguments);
}
function getBubble() {
var bubble = self.options.bubble;
if(BI.isFunction(bubble)) {
return bubble();
}
return bubble;
}
}, },
_trigger: function () { _trigger: function () {
@ -68180,6 +68243,285 @@ BI.IconTextValueComboPopup = BI.inherit(BI.Pane, {
}); });
BI.IconTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; BI.IconTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.icon_text_value_combo_popup", BI.IconTextValueComboPopup);/** BI.shortcut("bi.icon_text_value_combo_popup", BI.IconTextValueComboPopup);/**
* Created by Windy on 2018/2/2.
*/
BI.SearchTextValueCombo = BI.inherit(BI.Widget, {
props: {
baseCls: "bi-search-text-value-combo",
height: 30,
text: "",
items: []
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.absolute",
items: [{
el: {
type: "bi.combo",
adjustLength: 2,
toggle: false,
ref: function () {
self.combo = this;
},
el: {
type: "bi.search_text_value_trigger",
ref: function () {
self.trigger = this;
},
items: o.items,
height: o.height - 2,
text: o.text,
value: o.value,
listeners: [{
eventName: BI.SearchTextValueTrigger.EVENT_CHANGE,
action: function () {
self.setValue(this.getValue());
self.combo.hideView();
self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE);
}
}]
},
popup: {
el:{
type: "bi.text_value_combo_popup",
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
value: o.value,
items: o.items,
ref: function () {
self.popup = this;
self.trigger.getSearcher().setAdapter(self.popup);
},
listeners: [{
eventName: BI.TextValueComboPopup.EVENT_CHANGE,
action: function () {
self.setValue(this.getValue());
self.combo.hideView();
self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE);
}
}]
},
maxHeight: 300
},
listeners: [{
eventName: BI.Combo.EVENT_AFTER_HIDEVIEW,
action: function(){
self.trigger.stopEditing();
}
}]
},
left: 0,
right: 0,
bottom: 0,
top: 0
}, {
el: {
type: "bi.trigger_icon_button",
width: o.height,
handler: function () {
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
}
},
right: 0,
bottom: 0,
top: 0
}]
}
},
populate: function (items) {
this.combo.populate(items);
},
setValue: function (v) {
this.combo.setValue(v);
},
getValue: function () {
var value = this.popup.getValue();
return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]);
}
});
BI.SearchTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.search_text_value_combo", BI.SearchTextValueCombo);/**
* Created by Windy on 2018/2/5.
*/
BI.SearchTextValueComboPopup = BI.inherit(BI.Pane, {
props: {
baseCls: "bi-search-text-value-popup"
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.vertical",
items: [{
type: "bi.button_group",
ref: function () {
self.popup = this;
},
items: BI.createItems(o.items, {
type: "bi.single_select_item",
textAlign: o.textAlign,
height: 30
}),
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
layouts: [{
type: "bi.vertical"
}],
behaviors: {
redmark: function () {
return true;
}
},
value: o.value,
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function (type, val, obj) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
if (type === BI.Events.CLICK) {
self.fireEvent(BI.SearchTextValueComboPopup.EVENT_CHANGE, val, obj);
}
}
}]
}]
};
},
populate: function (finded, matched, keyword) {
var items = BI.concat(finded, matched);
BI.SearchTextValueComboPopup.superclass.populate.apply(this, items);
items = BI.createItems(items, {
type: "bi.single_select_item",
height: 30
});
this.popup.populate(items, keyword);
},
getValue: function () {
return this.popup.getValue();
},
setValue: function (v) {
this.popup.setValue(v);
}
});
BI.SearchTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.search_text_value_combo_popup", BI.SearchTextValueComboPopup);/**
* Created by Windy on 2018/2/2.
*/
BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, {
props: {
baseCls: "bi-search-text-value-trigger bi-border",
height: 30
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.htape",
items: [
{
el: {
type: "bi.searcher",
ref: function () {
self.searcher = this;
},
isAutoSearch: false,
el: {
type: "bi.state_editor",
ref: function () {
self.editor = this;
},
text: this._digest(o.value, o.items),
value: o.value,
height: o.height
},
popup: {
type: "bi.search_text_value_combo_popup",
cls: "bi-card",
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE
},
onSearch: function (obj, callback) {
var keyword = obj.keyword;
var finding = BI.Func.getSearchResult(o.items, keyword);
var matched = finding.matched, finded = finding.finded;
callback(finded, matched);
},
listeners: [{
eventName: BI.Searcher.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.SearchTextValueTrigger.EVENT_CHANGE);
}
}]
}
}, {
el: {
type: "bi.layout",
width: 30
},
width: 30
}
]
}
},
_setState: function (v) {
this.editor.setState(v);
},
_digest: function(vals, items){
var o = this.options;
vals = BI.isArray(vals) ? vals : [vals];
var result = [];
var formatItems = BI.Tree.transformToArrayFormat(items);
BI.each(formatItems, function (i, item) {
if (BI.deepContains(vals, item.value) && !result.contains(item.text || item.value)) {
result.push(item.text || item.value);
}
});
if (result.length > 0) {
return result.join(",");
} else {
return o.text;
}
},
stopEditing: function () {
this.searcher.stopSearch();
},
getSearcher: function () {
return this.searcher;
},
populate: function (items) {
this.options.items = items;
},
setValue: function (vals) {
this._setState(this._digest(vals, this.options.items));
},
getValue: function () {
return this.searcher.getValue();
}
});
BI.SearchTextValueTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.SearchTextValueTrigger.EVENT_STOP = "EVENT_STOP";
BI.SearchTextValueTrigger.EVENT_START = "EVENT_START";
BI.SearchTextValueTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.search_text_value_trigger", BI.SearchTextValueTrigger);/**
* 单选combo * 单选combo
* *
* @class BI.StaticCombo * @class BI.StaticCombo
@ -69785,7 +70127,7 @@ BI.StateEditor = BI.inherit(BI.Widget, {
}); });
this.text = BI.createWidget({ this.text = BI.createWidget({
type: "bi.text_button", type: "bi.text_button",
cls: "state-editor-infinite-text bi-disabled", cls: "state-editor-infinite-text",
textAlign: "left", textAlign: "left",
height: o.height, height: o.height,
text: BI.i18nText("BI-Basic_Unrestricted"), text: BI.i18nText("BI-Basic_Unrestricted"),

281
dist/case.js vendored

@ -5611,6 +5611,285 @@ BI.IconTextValueComboPopup = BI.inherit(BI.Pane, {
}); });
BI.IconTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; BI.IconTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.icon_text_value_combo_popup", BI.IconTextValueComboPopup);/** BI.shortcut("bi.icon_text_value_combo_popup", BI.IconTextValueComboPopup);/**
* Created by Windy on 2018/2/2.
*/
BI.SearchTextValueCombo = BI.inherit(BI.Widget, {
props: {
baseCls: "bi-search-text-value-combo",
height: 30,
text: "",
items: []
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.absolute",
items: [{
el: {
type: "bi.combo",
adjustLength: 2,
toggle: false,
ref: function () {
self.combo = this;
},
el: {
type: "bi.search_text_value_trigger",
ref: function () {
self.trigger = this;
},
items: o.items,
height: o.height - 2,
text: o.text,
value: o.value,
listeners: [{
eventName: BI.SearchTextValueTrigger.EVENT_CHANGE,
action: function () {
self.setValue(this.getValue());
self.combo.hideView();
self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE);
}
}]
},
popup: {
el:{
type: "bi.text_value_combo_popup",
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
value: o.value,
items: o.items,
ref: function () {
self.popup = this;
self.trigger.getSearcher().setAdapter(self.popup);
},
listeners: [{
eventName: BI.TextValueComboPopup.EVENT_CHANGE,
action: function () {
self.setValue(this.getValue());
self.combo.hideView();
self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE);
}
}]
},
maxHeight: 300
},
listeners: [{
eventName: BI.Combo.EVENT_AFTER_HIDEVIEW,
action: function(){
self.trigger.stopEditing();
}
}]
},
left: 0,
right: 0,
bottom: 0,
top: 0
}, {
el: {
type: "bi.trigger_icon_button",
width: o.height,
handler: function () {
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
}
},
right: 0,
bottom: 0,
top: 0
}]
}
},
populate: function (items) {
this.combo.populate(items);
},
setValue: function (v) {
this.combo.setValue(v);
},
getValue: function () {
var value = this.popup.getValue();
return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]);
}
});
BI.SearchTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.search_text_value_combo", BI.SearchTextValueCombo);/**
* Created by Windy on 2018/2/5.
*/
BI.SearchTextValueComboPopup = BI.inherit(BI.Pane, {
props: {
baseCls: "bi-search-text-value-popup"
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.vertical",
items: [{
type: "bi.button_group",
ref: function () {
self.popup = this;
},
items: BI.createItems(o.items, {
type: "bi.single_select_item",
textAlign: o.textAlign,
height: 30
}),
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
layouts: [{
type: "bi.vertical"
}],
behaviors: {
redmark: function () {
return true;
}
},
value: o.value,
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function (type, val, obj) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
if (type === BI.Events.CLICK) {
self.fireEvent(BI.SearchTextValueComboPopup.EVENT_CHANGE, val, obj);
}
}
}]
}]
};
},
populate: function (finded, matched, keyword) {
var items = BI.concat(finded, matched);
BI.SearchTextValueComboPopup.superclass.populate.apply(this, items);
items = BI.createItems(items, {
type: "bi.single_select_item",
height: 30
});
this.popup.populate(items, keyword);
},
getValue: function () {
return this.popup.getValue();
},
setValue: function (v) {
this.popup.setValue(v);
}
});
BI.SearchTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.search_text_value_combo_popup", BI.SearchTextValueComboPopup);/**
* Created by Windy on 2018/2/2.
*/
BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, {
props: {
baseCls: "bi-search-text-value-trigger bi-border",
height: 30
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.htape",
items: [
{
el: {
type: "bi.searcher",
ref: function () {
self.searcher = this;
},
isAutoSearch: false,
el: {
type: "bi.state_editor",
ref: function () {
self.editor = this;
},
text: this._digest(o.value, o.items),
value: o.value,
height: o.height
},
popup: {
type: "bi.search_text_value_combo_popup",
cls: "bi-card",
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE
},
onSearch: function (obj, callback) {
var keyword = obj.keyword;
var finding = BI.Func.getSearchResult(o.items, keyword);
var matched = finding.matched, finded = finding.finded;
callback(finded, matched);
},
listeners: [{
eventName: BI.Searcher.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.SearchTextValueTrigger.EVENT_CHANGE);
}
}]
}
}, {
el: {
type: "bi.layout",
width: 30
},
width: 30
}
]
}
},
_setState: function (v) {
this.editor.setState(v);
},
_digest: function(vals, items){
var o = this.options;
vals = BI.isArray(vals) ? vals : [vals];
var result = [];
var formatItems = BI.Tree.transformToArrayFormat(items);
BI.each(formatItems, function (i, item) {
if (BI.deepContains(vals, item.value) && !result.contains(item.text || item.value)) {
result.push(item.text || item.value);
}
});
if (result.length > 0) {
return result.join(",");
} else {
return o.text;
}
},
stopEditing: function () {
this.searcher.stopSearch();
},
getSearcher: function () {
return this.searcher;
},
populate: function (items) {
this.options.items = items;
},
setValue: function (vals) {
this._setState(this._digest(vals, this.options.items));
},
getValue: function () {
return this.searcher.getValue();
}
});
BI.SearchTextValueTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.SearchTextValueTrigger.EVENT_STOP = "EVENT_STOP";
BI.SearchTextValueTrigger.EVENT_START = "EVENT_START";
BI.SearchTextValueTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.search_text_value_trigger", BI.SearchTextValueTrigger);/**
* 单选combo * 单选combo
* *
* @class BI.StaticCombo * @class BI.StaticCombo
@ -7216,7 +7495,7 @@ BI.StateEditor = BI.inherit(BI.Widget, {
}); });
this.text = BI.createWidget({ this.text = BI.createWidget({
type: "bi.text_button", type: "bi.text_button",
cls: "state-editor-infinite-text bi-disabled", cls: "state-editor-infinite-text",
textAlign: "left", textAlign: "left",
height: o.height, height: o.height,
text: BI.i18nText("BI-Basic_Unrestricted"), text: BI.i18nText("BI-Basic_Unrestricted"),

89
dist/demo.js vendored

@ -223,6 +223,18 @@ $(function () {
ghost: true, ghost: true,
height: 30 height: 30
} }
}, {
el: {
type: "bi.button",
text: "弹出bubble",
bubble: function () {
return BI.parseInt(Math.random() * 100) % 10 + "提示"
},
handler: function () {
BI.Msg.toast("1111");
},
height: 30
}
} }
]; ];
// BI.each(items, function (i, item) { // BI.each(items, function (i, item) {
@ -1944,6 +1956,79 @@ Demo.IconTextValueCombo = BI.inherit(BI.Widget, {
}); });
BI.shortcut("demo.icon_text_value_combo", Demo.IconTextValueCombo);/** BI.shortcut("demo.icon_text_value_combo", Demo.IconTextValueCombo);/**
* Created by Windy on 2018/2/4.
*/
Demo.SearchTextValueCombo = BI.inherit(BI.Widget, {
props: {
baseCls: ""
},
render: function () {
var combo;
return {
type: "bi.horizontal_auto",
items: [{
type: "bi.search_text_value_combo",
ref: function () {
combo = this;
},
text: "默认值",
value: 2,
width: 300,
items: [{
text: "ABC-1",
iconCls: "date-font",
value: 1
}, {
text: "BCD-2",
iconCls: "search-font",
value: 2
}, {
text: "CDE-3",
iconCls: "pull-right-font",
value: 3
}, {
text: "DEF-3",
iconCls: "pull-right-font",
value: 4
}, {
text: "FEG-3",
iconCls: "pull-right-font",
value: 5
}, {
text: "FGH-3",
iconCls: "pull-right-font",
value: 6
}, {
text: "GHI-3",
iconCls: "pull-right-font",
value: 7
}, {
text: "HIJ-3",
iconCls: "pull-right-font",
value: 8
}, {
text: "IJK-3",
iconCls: "pull-right-font",
value: 9
}, {
text: "JKL-3",
iconCls: "pull-right-font",
value: 10
}]
}, {
type: "bi.button",
width: 90,
height: 25,
handler: function () {
combo.setValue(3);
}
}],
vgap: 20
};
}
});
BI.shortcut("demo.search_text_value_combo", Demo.SearchTextValueCombo);/**
* Created by Dailer on 2017/7/11. * Created by Dailer on 2017/7/11.
*/ */
Demo.StaticCombo = BI.inherit(BI.Widget, { Demo.StaticCombo = BI.inherit(BI.Widget, {
@ -5037,6 +5122,10 @@ BI.shortcut("demo.value_chooser_pane", Demo.ValueChooserPane);Demo.BASE_CONFIG =
pId: 306, pId: 306,
text: "bi.text_value_combo", text: "bi.text_value_combo",
value: "demo.text_value_combo" value: "demo.text_value_combo"
}, {
pId: 306,
text: "bi.search_text_value_combo",
value: "demo.search_text_value_combo"
}, { }, {
pId: 306, pId: 306,
text: "bi.icon_text_value_combo", text: "bi.icon_text_value_combo",

346
dist/fineui.js vendored

@ -28440,7 +28440,8 @@ BI.BasicButton = BI.inherit(BI.Single, {
shadow: false, shadow: false,
isShadowShowingOnSelected: false, // 选中状态下是否显示阴影 isShadowShowingOnSelected: false, // 选中状态下是否显示阴影
trigger: null, trigger: null,
handler: BI.emptyFn handler: BI.emptyFn,
bubble: null
}); });
}, },
_init: function () { _init: function () {
@ -28632,8 +28633,70 @@ BI.BasicButton = BI.inherit(BI.Single, {
if (!self.isEnabled() || (self.isOnce() && self.isSelected())) { if (!self.isEnabled() || (self.isOnce() && self.isSelected())) {
return; return;
} }
if(BI.isKey(o.bubble) || BI.isFunction(o.bubble)) {
if(BI.isNull(self.combo)){
var popup;
BI.createWidget({
type: "bi.absolute",
element: self,
items: [{
el: {
type: "bi.bubble_combo",
trigger: "",
ref: function () {
self.combo = this;
},
el: {
type: "bi.layout",
height: "100%"
},
popup: {
type: "bi.text_bubble_bar_popup_view",
text: getBubble(),
ref: function () {
popup = this;
},
listeners: [{
eventName: BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON,
action: function (v) {
self.combo.hideView();
if(v){
onClick.apply(self, arguments); onClick.apply(self, arguments);
} }
}
}]
},
listeners: [{
eventName: BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW,
action: function () {
popup.populate(getBubble());
}
}]
},
left: 0,
right: 0,
bottom: 0,
top: 0
}]
});
}
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
return;
}
onClick.apply(self, arguments);
}
function getBubble() {
var bubble = self.options.bubble;
if(BI.isFunction(bubble)) {
return bubble();
}
return bubble;
}
}, },
_trigger: function () { _trigger: function () {
@ -69944,6 +70007,285 @@ BI.IconTextValueComboPopup = BI.inherit(BI.Pane, {
}); });
BI.IconTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; BI.IconTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.icon_text_value_combo_popup", BI.IconTextValueComboPopup);/** BI.shortcut("bi.icon_text_value_combo_popup", BI.IconTextValueComboPopup);/**
* Created by Windy on 2018/2/2.
*/
BI.SearchTextValueCombo = BI.inherit(BI.Widget, {
props: {
baseCls: "bi-search-text-value-combo",
height: 30,
text: "",
items: []
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.absolute",
items: [{
el: {
type: "bi.combo",
adjustLength: 2,
toggle: false,
ref: function () {
self.combo = this;
},
el: {
type: "bi.search_text_value_trigger",
ref: function () {
self.trigger = this;
},
items: o.items,
height: o.height - 2,
text: o.text,
value: o.value,
listeners: [{
eventName: BI.SearchTextValueTrigger.EVENT_CHANGE,
action: function () {
self.setValue(this.getValue());
self.combo.hideView();
self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE);
}
}]
},
popup: {
el:{
type: "bi.text_value_combo_popup",
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
value: o.value,
items: o.items,
ref: function () {
self.popup = this;
self.trigger.getSearcher().setAdapter(self.popup);
},
listeners: [{
eventName: BI.TextValueComboPopup.EVENT_CHANGE,
action: function () {
self.setValue(this.getValue());
self.combo.hideView();
self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE);
}
}]
},
maxHeight: 300
},
listeners: [{
eventName: BI.Combo.EVENT_AFTER_HIDEVIEW,
action: function(){
self.trigger.stopEditing();
}
}]
},
left: 0,
right: 0,
bottom: 0,
top: 0
}, {
el: {
type: "bi.trigger_icon_button",
width: o.height,
handler: function () {
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
}
},
right: 0,
bottom: 0,
top: 0
}]
}
},
populate: function (items) {
this.combo.populate(items);
},
setValue: function (v) {
this.combo.setValue(v);
},
getValue: function () {
var value = this.popup.getValue();
return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]);
}
});
BI.SearchTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.search_text_value_combo", BI.SearchTextValueCombo);/**
* Created by Windy on 2018/2/5.
*/
BI.SearchTextValueComboPopup = BI.inherit(BI.Pane, {
props: {
baseCls: "bi-search-text-value-popup"
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.vertical",
items: [{
type: "bi.button_group",
ref: function () {
self.popup = this;
},
items: BI.createItems(o.items, {
type: "bi.single_select_item",
textAlign: o.textAlign,
height: 30
}),
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
layouts: [{
type: "bi.vertical"
}],
behaviors: {
redmark: function () {
return true;
}
},
value: o.value,
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function (type, val, obj) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
if (type === BI.Events.CLICK) {
self.fireEvent(BI.SearchTextValueComboPopup.EVENT_CHANGE, val, obj);
}
}
}]
}]
};
},
populate: function (finded, matched, keyword) {
var items = BI.concat(finded, matched);
BI.SearchTextValueComboPopup.superclass.populate.apply(this, items);
items = BI.createItems(items, {
type: "bi.single_select_item",
height: 30
});
this.popup.populate(items, keyword);
},
getValue: function () {
return this.popup.getValue();
},
setValue: function (v) {
this.popup.setValue(v);
}
});
BI.SearchTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.search_text_value_combo_popup", BI.SearchTextValueComboPopup);/**
* Created by Windy on 2018/2/2.
*/
BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, {
props: {
baseCls: "bi-search-text-value-trigger bi-border",
height: 30
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.htape",
items: [
{
el: {
type: "bi.searcher",
ref: function () {
self.searcher = this;
},
isAutoSearch: false,
el: {
type: "bi.state_editor",
ref: function () {
self.editor = this;
},
text: this._digest(o.value, o.items),
value: o.value,
height: o.height
},
popup: {
type: "bi.search_text_value_combo_popup",
cls: "bi-card",
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE
},
onSearch: function (obj, callback) {
var keyword = obj.keyword;
var finding = BI.Func.getSearchResult(o.items, keyword);
var matched = finding.matched, finded = finding.finded;
callback(finded, matched);
},
listeners: [{
eventName: BI.Searcher.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.SearchTextValueTrigger.EVENT_CHANGE);
}
}]
}
}, {
el: {
type: "bi.layout",
width: 30
},
width: 30
}
]
}
},
_setState: function (v) {
this.editor.setState(v);
},
_digest: function(vals, items){
var o = this.options;
vals = BI.isArray(vals) ? vals : [vals];
var result = [];
var formatItems = BI.Tree.transformToArrayFormat(items);
BI.each(formatItems, function (i, item) {
if (BI.deepContains(vals, item.value) && !result.contains(item.text || item.value)) {
result.push(item.text || item.value);
}
});
if (result.length > 0) {
return result.join(",");
} else {
return o.text;
}
},
stopEditing: function () {
this.searcher.stopSearch();
},
getSearcher: function () {
return this.searcher;
},
populate: function (items) {
this.options.items = items;
},
setValue: function (vals) {
this._setState(this._digest(vals, this.options.items));
},
getValue: function () {
return this.searcher.getValue();
}
});
BI.SearchTextValueTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.SearchTextValueTrigger.EVENT_STOP = "EVENT_STOP";
BI.SearchTextValueTrigger.EVENT_START = "EVENT_START";
BI.SearchTextValueTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.search_text_value_trigger", BI.SearchTextValueTrigger);/**
* 单选combo * 单选combo
* *
* @class BI.StaticCombo * @class BI.StaticCombo
@ -71549,7 +71891,7 @@ BI.StateEditor = BI.inherit(BI.Widget, {
}); });
this.text = BI.createWidget({ this.text = BI.createWidget({
type: "bi.text_button", type: "bi.text_button",
cls: "state-editor-infinite-text bi-disabled", cls: "state-editor-infinite-text",
textAlign: "left", textAlign: "left",
height: o.height, height: o.height,
text: BI.i18nText("BI-Basic_Unrestricted"), text: BI.i18nText("BI-Basic_Unrestricted"),

65
src/base/single/button/button.basic.js

@ -23,7 +23,8 @@ BI.BasicButton = BI.inherit(BI.Single, {
shadow: false, shadow: false,
isShadowShowingOnSelected: false, // 选中状态下是否显示阴影 isShadowShowingOnSelected: false, // 选中状态下是否显示阴影
trigger: null, trigger: null,
handler: BI.emptyFn handler: BI.emptyFn,
bubble: null
}); });
}, },
_init: function () { _init: function () {
@ -215,8 +216,70 @@ BI.BasicButton = BI.inherit(BI.Single, {
if (!self.isEnabled() || (self.isOnce() && self.isSelected())) { if (!self.isEnabled() || (self.isOnce() && self.isSelected())) {
return; return;
} }
if(BI.isKey(o.bubble) || BI.isFunction(o.bubble)) {
if(BI.isNull(self.combo)){
var popup;
BI.createWidget({
type: "bi.absolute",
element: self,
items: [{
el: {
type: "bi.bubble_combo",
trigger: "",
ref: function () {
self.combo = this;
},
el: {
type: "bi.layout",
height: "100%"
},
popup: {
type: "bi.text_bubble_bar_popup_view",
text: getBubble(),
ref: function () {
popup = this;
},
listeners: [{
eventName: BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON,
action: function (v) {
self.combo.hideView();
if(v){
onClick.apply(self, arguments);
}
}
}]
},
listeners: [{
eventName: BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW,
action: function () {
popup.populate(getBubble());
}
}]
},
left: 0,
right: 0,
bottom: 0,
top: 0
}]
});
}
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
return;
}
onClick.apply(self, arguments); onClick.apply(self, arguments);
} }
function getBubble() {
var bubble = self.options.bubble;
if(BI.isFunction(bubble)) {
return bubble();
}
return bubble;
}
}, },
_trigger: function () { _trigger: function () {

108
src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js

@ -0,0 +1,108 @@
/**
* Created by Windy on 2018/2/2.
*/
BI.SearchTextValueCombo = BI.inherit(BI.Widget, {
props: {
baseCls: "bi-search-text-value-combo",
height: 30,
text: "",
items: []
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.absolute",
items: [{
el: {
type: "bi.combo",
adjustLength: 2,
toggle: false,
ref: function () {
self.combo = this;
},
el: {
type: "bi.search_text_value_trigger",
ref: function () {
self.trigger = this;
},
items: o.items,
height: o.height - 2,
text: o.text,
value: o.value,
listeners: [{
eventName: BI.SearchTextValueTrigger.EVENT_CHANGE,
action: function () {
self.setValue(this.getValue());
self.combo.hideView();
self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE);
}
}]
},
popup: {
el:{
type: "bi.text_value_combo_popup",
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
value: o.value,
items: o.items,
ref: function () {
self.popup = this;
self.trigger.getSearcher().setAdapter(self.popup);
},
listeners: [{
eventName: BI.TextValueComboPopup.EVENT_CHANGE,
action: function () {
self.setValue(this.getValue());
self.combo.hideView();
self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE);
}
}]
},
maxHeight: 300
},
listeners: [{
eventName: BI.Combo.EVENT_AFTER_HIDEVIEW,
action: function(){
self.trigger.stopEditing();
}
}]
},
left: 0,
right: 0,
bottom: 0,
top: 0
}, {
el: {
type: "bi.trigger_icon_button",
width: o.height,
handler: function () {
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
}
},
right: 0,
bottom: 0,
top: 0
}]
}
},
populate: function (items) {
this.combo.populate(items);
},
setValue: function (v) {
this.combo.setValue(v);
},
getValue: function () {
var value = this.popup.getValue();
return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]);
}
});
BI.SearchTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.search_text_value_combo", BI.SearchTextValueCombo);

67
src/case/combo/searchtextvaluecombo/popup.searchtextvalue.js

@ -0,0 +1,67 @@
/**
* Created by Windy on 2018/2/5.
*/
BI.SearchTextValueComboPopup = BI.inherit(BI.Pane, {
props: {
baseCls: "bi-search-text-value-popup"
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.vertical",
items: [{
type: "bi.button_group",
ref: function () {
self.popup = this;
},
items: BI.createItems(o.items, {
type: "bi.single_select_item",
textAlign: o.textAlign,
height: 30
}),
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
layouts: [{
type: "bi.vertical"
}],
behaviors: {
redmark: function () {
return true;
}
},
value: o.value,
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function (type, val, obj) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
if (type === BI.Events.CLICK) {
self.fireEvent(BI.SearchTextValueComboPopup.EVENT_CHANGE, val, obj);
}
}
}]
}]
};
},
populate: function (finded, matched, keyword) {
var items = BI.concat(finded, matched);
BI.SearchTextValueComboPopup.superclass.populate.apply(this, items);
items = BI.createItems(items, {
type: "bi.single_select_item",
height: 30
});
this.popup.populate(items, keyword);
},
getValue: function () {
return this.popup.getValue();
},
setValue: function (v) {
this.popup.setValue(v);
}
});
BI.SearchTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.search_text_value_combo_popup", BI.SearchTextValueComboPopup);

107
src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js

@ -0,0 +1,107 @@
/**
* Created by Windy on 2018/2/2.
*/
BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, {
props: {
baseCls: "bi-search-text-value-trigger bi-border",
height: 30
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.htape",
items: [
{
el: {
type: "bi.searcher",
ref: function () {
self.searcher = this;
},
isAutoSearch: false,
el: {
type: "bi.state_editor",
ref: function () {
self.editor = this;
},
text: this._digest(o.value, o.items),
value: o.value,
height: o.height
},
popup: {
type: "bi.search_text_value_combo_popup",
cls: "bi-card",
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE
},
onSearch: function (obj, callback) {
var keyword = obj.keyword;
var finding = BI.Func.getSearchResult(o.items, keyword);
var matched = finding.matched, finded = finding.finded;
callback(finded, matched);
},
listeners: [{
eventName: BI.Searcher.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.SearchTextValueTrigger.EVENT_CHANGE);
}
}]
}
}, {
el: {
type: "bi.layout",
width: 30
},
width: 30
}
]
}
},
_setState: function (v) {
this.editor.setState(v);
},
_digest: function(vals, items){
var o = this.options;
vals = BI.isArray(vals) ? vals : [vals];
var result = [];
var formatItems = BI.Tree.transformToArrayFormat(items);
BI.each(formatItems, function (i, item) {
if (BI.deepContains(vals, item.value) && !result.contains(item.text || item.value)) {
result.push(item.text || item.value);
}
});
if (result.length > 0) {
return result.join(",");
} else {
return o.text;
}
},
stopEditing: function () {
this.searcher.stopSearch();
},
getSearcher: function () {
return this.searcher;
},
populate: function (items) {
this.options.items = items;
},
setValue: function (vals) {
this._setState(this._digest(vals, this.options.items));
},
getValue: function () {
return this.searcher.getValue();
}
});
BI.SearchTextValueTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.SearchTextValueTrigger.EVENT_STOP = "EVENT_STOP";
BI.SearchTextValueTrigger.EVENT_START = "EVENT_START";
BI.SearchTextValueTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.search_text_value_trigger", BI.SearchTextValueTrigger);

2
src/case/editor/editor.state.js

@ -45,7 +45,7 @@ BI.StateEditor = BI.inherit(BI.Widget, {
}); });
this.text = BI.createWidget({ this.text = BI.createWidget({
type: "bi.text_button", type: "bi.text_button",
cls: "state-editor-infinite-text bi-disabled", cls: "state-editor-infinite-text",
textAlign: "left", textAlign: "left",
height: o.height, height: o.height,
text: BI.i18nText("BI-Basic_Unrestricted"), text: BI.i18nText("BI-Basic_Unrestricted"),

Loading…
Cancel
Save