Browse Source
* commit '3a13391a90d315990363cb43c82ade798b6017cc': BI-19983 update update BI-20841 BI-20978es6
guy
7 years ago
24 changed files with 3077 additions and 5776 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,174 +0,0 @@
|
||||
/** |
||||
* 单选加载数据搜索loader面板 |
||||
* Created by guy on 15/11/4. |
||||
* @class BI.SingleSelectSearchLoader |
||||
* @extends Widget |
||||
*/ |
||||
BI.SingleSelectSearchLoader = BI.inherit(BI.Widget, { |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.SingleSelectSearchLoader.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-single-select-search-loader", |
||||
itemsCreator: BI.emptyFn, |
||||
keywordGetter: BI.emptyFn, |
||||
valueFormatter: BI.emptyFn |
||||
}); |
||||
}, |
||||
|
||||
_init: function () { |
||||
BI.SingleSelectSearchLoader.superclass._init.apply(this, arguments); |
||||
|
||||
var self = this, opts = this.options; |
||||
var hasNext = false; |
||||
|
||||
this.button_group = BI.createWidget({ |
||||
type: "bi.single_select_list", |
||||
element: this, |
||||
logic: { |
||||
dynamic: false |
||||
}, |
||||
el: { |
||||
tipText: BI.i18nText("BI-No_Select"), |
||||
el: { |
||||
type: "bi.loader", |
||||
isDefaultInit: false, |
||||
logic: { |
||||
dynamic: true, |
||||
scrolly: true |
||||
}, |
||||
el: { |
||||
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, |
||||
behaviors: { |
||||
redmark: function () { |
||||
return true; |
||||
} |
||||
}, |
||||
layouts: [{ |
||||
type: "bi.vertical" |
||||
}] |
||||
} |
||||
} |
||||
}, |
||||
itemsCreator: function (op, callback) { |
||||
self.storeValue && (op = BI.extend(op || {}, { |
||||
selectedValues: [self.storeValue] |
||||
})); |
||||
opts.itemsCreator(op, function (ob) { |
||||
var keyword = ob.keyword = opts.keywordGetter(); |
||||
hasNext = ob.hasNext; |
||||
var firstItems = []; |
||||
if (op.times === 1 && self.storeValue) { |
||||
var json = BI.map([self.storeValue], function (i, v) { |
||||
var txt = opts.valueFormatter(v) || v; |
||||
return { |
||||
text: txt, |
||||
value: v, |
||||
title: txt, |
||||
selected: false |
||||
}; |
||||
}); |
||||
firstItems = self._createItems(json); |
||||
} |
||||
if(keyword) { |
||||
var flag = false; |
||||
for(var i = 0; i < ob.items.length; i++) { |
||||
if(BI.contains(ob.items[i], keyword)) { |
||||
flag = true; |
||||
} |
||||
} |
||||
if(!flag) { |
||||
var preItems = self._createItems([{ |
||||
text: keyword, |
||||
value: keyword, |
||||
title: keyword, |
||||
selected: false |
||||
}]); |
||||
firstItems = firstItems.concat(preItems); |
||||
} |
||||
} |
||||
callback(firstItems.concat(self._createItems(ob.items)), keyword); |
||||
if (op.times === 1 && self.storeValue) { |
||||
self.setValue(self.storeValue); |
||||
} |
||||
}); |
||||
}, |
||||
hasNext: function () { |
||||
return hasNext; |
||||
} |
||||
}); |
||||
this.button_group.on(BI.Controller.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
}); |
||||
this.button_group.on(BI.SingleSelectList.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.SingleSelectSearchLoader.EVENT_CHANGE, arguments); |
||||
}); |
||||
}, |
||||
|
||||
_createItems: function (items) { |
||||
return BI.createItems(items, { |
||||
type: "bi.single_select_combo.item", |
||||
logic: { |
||||
dynamic: false |
||||
}, |
||||
height: 25, |
||||
selected: false |
||||
}); |
||||
}, |
||||
|
||||
_filterValues: function (src) { |
||||
var o = this.options; |
||||
var keyword = o.keywordGetter(); |
||||
var values = BI.deepClone(src.value) || []; |
||||
var newValues = BI.map(values, function (i, v) { |
||||
return { |
||||
text: o.valueFormatter(v) || v, |
||||
value: v |
||||
}; |
||||
}); |
||||
if (BI.isKey(keyword)) { |
||||
var search = BI.Func.getSearchResult(newValues, keyword); |
||||
values = search.match.concat(search.find); |
||||
} |
||||
return BI.map(values, function (i, v) { |
||||
return { |
||||
text: v.text, |
||||
title: v.text, |
||||
value: v.value, |
||||
selected: false |
||||
}; |
||||
}); |
||||
}, |
||||
|
||||
setValue: function (v) { |
||||
// 暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了
|
||||
this.storeValue = v; |
||||
this.button_group.setValue(v); |
||||
}, |
||||
|
||||
getValue: function () { |
||||
return this.button_group.getValue(); |
||||
}, |
||||
|
||||
getAllButtons: function () { |
||||
return this.button_group.getAllButtons(); |
||||
}, |
||||
|
||||
empty: function () { |
||||
this.button_group.empty(); |
||||
}, |
||||
|
||||
populate: function (items) { |
||||
this.button_group.populate.apply(this.button_group, arguments); |
||||
}, |
||||
|
||||
resetHeight: function (h) { |
||||
this.button_group.resetHeight(h); |
||||
}, |
||||
|
||||
resetWidth: function (w) { |
||||
this.button_group.resetWidth(w); |
||||
} |
||||
}); |
||||
|
||||
BI.SingleSelectSearchLoader.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.shortcut("bi.single_select_search_add_loader", BI.SingleSelectSearchLoader); |
@ -1,98 +0,0 @@
|
||||
/** |
||||
* |
||||
* 在搜索框中输入文本弹出的面板 |
||||
* @class BI.SingleSelectSearchPane |
||||
* @extends Widget |
||||
*/ |
||||
|
||||
BI.SingleSelectSearchPane = BI.inherit(BI.Widget, { |
||||
|
||||
constants: { |
||||
height: 25, |
||||
lgap: 10, |
||||
tgap: 5 |
||||
}, |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.SingleSelectSearchPane.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-single-select-search-pane bi-card", |
||||
itemsCreator: BI.emptyFn, |
||||
valueFormatter: BI.emptyFn, |
||||
keywordGetter: BI.emptyFn |
||||
}); |
||||
}, |
||||
|
||||
_init: function () { |
||||
BI.SingleSelectSearchPane.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
|
||||
this.tooltipClick = BI.createWidget({ |
||||
type: "bi.label", |
||||
invisible: true, |
||||
text: BI.i18nText("BI-Click_Blank_To_Select"), |
||||
cls: "single-select-toolbar", |
||||
height: this.constants.height |
||||
}); |
||||
|
||||
this.loader = BI.createWidget({ |
||||
type: "bi.single_select_search_add_loader", |
||||
keywordGetter: o.keywordGetter, |
||||
valueFormatter: o.valueFormatter, |
||||
itemsCreator: function (op, callback) { |
||||
o.itemsCreator.apply(self, [op, function (res) { |
||||
callback(res); |
||||
self.setKeyword(o.keywordGetter()); |
||||
}]); |
||||
} |
||||
}); |
||||
this.loader.on(BI.Controller.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
}); |
||||
|
||||
this.resizer = BI.createWidget({ |
||||
type: "bi.vtape", |
||||
element: this, |
||||
items: [{ |
||||
el: this.tooltipClick, |
||||
height: 0 |
||||
}, { |
||||
el: this.loader |
||||
}] |
||||
}); |
||||
this.tooltipClick.setVisible(false); |
||||
}, |
||||
|
||||
setKeyword: function (keyword) { |
||||
var btn; |
||||
var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === btn.getValue()); |
||||
if (isVisible !== this.tooltipClick.isVisible()) { |
||||
this.tooltipClick.setVisible(isVisible); |
||||
this.resizer.attr("items")[0].height = (isVisible ? this.constants.height : 0); |
||||
this.resizer.resize(); |
||||
} |
||||
}, |
||||
|
||||
hasMatched: function () { |
||||
return this.tooltipClick.isVisible(); |
||||
}, |
||||
|
||||
setValue: function (v) { |
||||
this.loader.setValue(v); |
||||
}, |
||||
|
||||
getValue: function () { |
||||
return this.loader.getValue(); |
||||
}, |
||||
|
||||
empty: function () { |
||||
this.loader.empty(); |
||||
}, |
||||
|
||||
populate: function (items) { |
||||
this.loader.populate.apply(this.loader, arguments); |
||||
} |
||||
}); |
||||
|
||||
BI.SingleSelectSearchPane.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
|
||||
BI.shortcut("bi.single_select_search_add_pane", BI.SingleSelectSearchPane); |
@ -1,110 +0,0 @@
|
||||
/** |
||||
* |
||||
* 单选下拉框 |
||||
* @class BI.SingleSelectTrigger |
||||
* @extends BI.Trigger |
||||
*/ |
||||
|
||||
BI.SingleSelectTrigger = BI.inherit(BI.Trigger, { |
||||
|
||||
constants: { |
||||
height: 14, |
||||
rgap: 4, |
||||
lgap: 4 |
||||
}, |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.SingleSelectTrigger.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-single-select-trigger bi-border", |
||||
itemsCreator: BI.emptyFn, |
||||
valueFormatter: BI.emptyFn, |
||||
searcher: {}, |
||||
switcher: {}, |
||||
|
||||
adapter: null, |
||||
masker: {} |
||||
}); |
||||
}, |
||||
|
||||
_init: function () { |
||||
BI.SingleSelectTrigger.superclass._init.apply(this, arguments); |
||||
|
||||
var self = this, o = this.options; |
||||
if (o.height) { |
||||
this.setHeight(o.height - 2); |
||||
} |
||||
|
||||
this.searcher = BI.createWidget(o.searcher, { |
||||
type: "bi.single_select_add_searcher", |
||||
height: o.height, |
||||
itemsCreator: o.itemsCreator, |
||||
valueFormatter: o.valueFormatter, |
||||
popup: {}, |
||||
adapter: o.adapter, |
||||
masker: o.masker |
||||
}); |
||||
this.searcher.on(BI.SingleSelectSearcher.EVENT_START, function () { |
||||
self.fireEvent(BI.SingleSelectTrigger.EVENT_START); |
||||
}); |
||||
this.searcher.on(BI.SingleSelectSearcher.EVENT_PAUSE, function () { |
||||
self.fireEvent(BI.SingleSelectTrigger.EVENT_PAUSE); |
||||
}); |
||||
this.searcher.on(BI.SingleSelectSearcher.EVENT_SEARCHING, function () { |
||||
self.fireEvent(BI.SingleSelectTrigger.EVENT_SEARCHING, arguments); |
||||
}); |
||||
this.searcher.on(BI.SingleSelectSearcher.EVENT_STOP, function () { |
||||
self.fireEvent(BI.SingleSelectTrigger.EVENT_STOP); |
||||
}); |
||||
this.searcher.on(BI.SingleSelectSearcher.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.SingleSelectTrigger.EVENT_CHANGE, arguments); |
||||
}); |
||||
|
||||
var wrapper = BI.createWidget({ |
||||
type: "bi.htape", |
||||
element: this, |
||||
items: [ |
||||
{ |
||||
el: this.searcher, |
||||
width: "fill" |
||||
}, { |
||||
el: BI.createWidget(), |
||||
width: 30 |
||||
}] |
||||
}); |
||||
}, |
||||
|
||||
getSearcher: function () { |
||||
return this.searcher; |
||||
}, |
||||
|
||||
stopEditing: function () { |
||||
this.searcher.stopSearch(); |
||||
}, |
||||
|
||||
setAdapter: function (adapter) { |
||||
this.searcher.setAdapter(adapter); |
||||
}, |
||||
|
||||
setValue: function (v) { |
||||
this.searcher.setValue(v); |
||||
}, |
||||
|
||||
getKey: function () { |
||||
return this.searcher.getKey(); |
||||
}, |
||||
|
||||
getValue: function () { |
||||
return this.searcher.getValue(); |
||||
} |
||||
}); |
||||
|
||||
BI.SingleSelectTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; |
||||
BI.SingleSelectTrigger.EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK"; |
||||
BI.SingleSelectTrigger.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.SingleSelectTrigger.EVENT_START = "EVENT_START"; |
||||
BI.SingleSelectTrigger.EVENT_STOP = "EVENT_STOP"; |
||||
BI.SingleSelectTrigger.EVENT_PAUSE = "EVENT_PAUSE"; |
||||
BI.SingleSelectTrigger.EVENT_SEARCHING = "EVENT_SEARCHING"; |
||||
BI.SingleSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW"; |
||||
|
||||
BI.shortcut("bi.single_select_add_trigger", BI.SingleSelectTrigger); |
@ -1,139 +0,0 @@
|
||||
/** |
||||
* searcher |
||||
* Created by guy on 15/11/3. |
||||
* @class BI.SingleSelectSearcher |
||||
* @extends Widget |
||||
*/ |
||||
BI.SingleSelectSearcher = BI.inherit(BI.Widget, { |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.SingleSelectSearcher.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-single-select-searcher", |
||||
itemsCreator: BI.emptyFn, |
||||
el: {}, |
||||
popup: {}, |
||||
valueFormatter: BI.emptyFn, |
||||
adapter: null, |
||||
masker: {} |
||||
}); |
||||
}, |
||||
|
||||
_init: function () { |
||||
BI.SingleSelectSearcher.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
this.editor = BI.createWidget(o.el, { |
||||
type: "bi.single_select_editor", |
||||
height: o.height |
||||
}); |
||||
|
||||
this.searcher = BI.createWidget({ |
||||
type: "bi.searcher", |
||||
element: this, |
||||
height: o.height, |
||||
isAutoSearch: false, |
||||
isAutoSync: false, |
||||
onSearch: function (op, callback) { |
||||
callback(); |
||||
}, |
||||
el: this.editor, |
||||
|
||||
popup: BI.extend({ |
||||
type: "bi.single_select_search_add_pane", |
||||
valueFormatter: o.valueFormatter, |
||||
keywordGetter: function () { |
||||
return self.editor.getValue(); |
||||
}, |
||||
itemsCreator: function (op, callback) { |
||||
op.keyword = self.editor.getValue(); |
||||
this.setKeyword(op.keyword); |
||||
o.itemsCreator(op, callback); |
||||
} |
||||
}, o.popup), |
||||
|
||||
adapter: o.adapter, |
||||
masker: o.masker |
||||
}); |
||||
this.searcher.on(BI.Searcher.EVENT_START, function () { |
||||
self.fireEvent(BI.SingleSelectSearcher.EVENT_START); |
||||
}); |
||||
this.searcher.on(BI.Searcher.EVENT_PAUSE, function () { |
||||
if (this.hasMatched()) { |
||||
|
||||
} |
||||
self.fireEvent(BI.SingleSelectSearcher.EVENT_PAUSE); |
||||
}); |
||||
this.searcher.on(BI.Searcher.EVENT_STOP, function () { |
||||
self.fireEvent(BI.SingleSelectSearcher.EVENT_STOP); |
||||
}); |
||||
this.searcher.on(BI.Searcher.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.SingleSelectSearcher.EVENT_CHANGE, arguments); |
||||
}); |
||||
this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () { |
||||
var keywords = this.getKeywords(); |
||||
self.fireEvent(BI.SingleSelectSearcher.EVENT_SEARCHING, keywords); |
||||
}); |
||||
}, |
||||
|
||||
adjustView: function () { |
||||
this.searcher.adjustView(); |
||||
}, |
||||
|
||||
isSearching: function () { |
||||
return this.searcher.isSearching(); |
||||
}, |
||||
|
||||
stopSearch: function () { |
||||
this.searcher.stopSearch(); |
||||
}, |
||||
|
||||
getKeyword: function () { |
||||
return this.editor.getValue(); |
||||
}, |
||||
|
||||
hasMatched: function () { |
||||
return this.searcher.hasMatched(); |
||||
}, |
||||
|
||||
hasChecked: function () { |
||||
return this.searcher.getView() && this.searcher.getView().hasChecked(); |
||||
}, |
||||
|
||||
setAdapter: function (adapter) { |
||||
this.searcher.setAdapter(adapter); |
||||
}, |
||||
|
||||
setState: function (v) { |
||||
var o = this.options; |
||||
v || (v = ""); |
||||
if (v === "") { |
||||
this.editor.setState(BI.Selection.None); |
||||
} else { |
||||
this.editor.setState(o.valueFormatter(v + "") || (v + "")); |
||||
} |
||||
}, |
||||
|
||||
setValue: function (ob) { |
||||
this.setState(ob); |
||||
this.searcher.setValue(ob); |
||||
}, |
||||
|
||||
getKey: function () { |
||||
return this.editor.getValue(); |
||||
}, |
||||
|
||||
getValue: function () { |
||||
return this.searcher.getValue(); |
||||
}, |
||||
|
||||
populate: function (items) { |
||||
this.searcher.populate.apply(this.searcher, arguments); |
||||
} |
||||
}); |
||||
|
||||
BI.SingleSelectSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; |
||||
BI.SingleSelectSearcher.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.SingleSelectSearcher.EVENT_START = "EVENT_START"; |
||||
BI.SingleSelectSearcher.EVENT_STOP = "EVENT_STOP"; |
||||
BI.SingleSelectSearcher.EVENT_PAUSE = "EVENT_PAUSE"; |
||||
BI.SingleSelectSearcher.EVENT_SEARCHING = "EVENT_SEARCHING"; |
||||
BI.shortcut("bi.single_select_add_searcher", BI.SingleSelectSearcher); |
Loading…
Reference in new issue