Browse Source

BI-52072 test: 若干控件单测绿化

master
windy 5 years ago
parent
commit
a032850f8b
  1. 85
      src/widget/date/calendar/popup.month.js
  2. 31
      src/widget/month/__test__/month.test.js
  3. 92
      src/widget/month/combo.month.js
  4. 110
      src/widget/month/trigger.month.js
  5. 62
      src/widget/multilayerdownlist/__test__/downlist.test.js
  6. 135
      src/widget/multilayerselecttree/__test__/multilayerselecttree.combo.test.js
  7. 133
      src/widget/multilayersingletree/__test__/multilayersingletree.combo.test.js
  8. 5
      src/widget/multiselect/__test__/multiselect.loader.nobar.test.js
  9. 5
      src/widget/multiselect/__test__/multiselect.loader.test.js
  10. 5
      src/widget/multiselect/__test__/multiselectcombo.test.js
  11. 5
      src/widget/multiselect/__test__/multiselectinsert.combo.test.js
  12. 92
      src/widget/quarter/combo.quarter.js
  13. 74
      src/widget/quarter/popup.quarter.js
  14. 106
      src/widget/quarter/trigger.quarter.js

85
src/widget/date/calendar/popup.month.js

@ -0,0 +1,85 @@
/**
* 月份展示面板
*
* Created by GUY on 2015/9/2.
* @class BI.MonthPopup
* @extends BI.Trigger
*/
BI.MonthPopup = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.MonthPopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-month-popup",
behaviors: {}
});
},
_init: function () {
BI.MonthPopup.superclass._init.apply(this, arguments);
var self = this, o = this.options;
// 纵向排列月
var month = [1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12];
var items = [];
items.push(month.slice(0, 2));
items.push(month.slice(2, 4));
items.push(month.slice(4, 6));
items.push(month.slice(6, 8));
items.push(month.slice(8, 10));
items.push(month.slice(10, 12));
items = BI.map(items, function (i, item) {
return BI.map(item, function (j, td) {
return {
type: "bi.text_item",
cls: "bi-list-item-select",
textAlign: "center",
whiteSpace: "nowrap",
once: false,
forceSelected: true,
height: 23,
width: 38,
value: td,
text: td
};
});
});
this.month = BI.createWidget({
type: "bi.button_group",
element: this,
behaviors: o.behaviors,
items: BI.createItems(items, {}),
layouts: [BI.LogicFactory.createLogic("table", BI.extend({
dynamic: true
}, {
columns: 2,
rows: 6,
columnSize: [1 / 2, 1 / 2],
rowSize: 25
})), {
type: "bi.center_adapt",
vgap: 1,
hgap: 2
}],
value: o.value
});
this.month.on(BI.Controller.EVENT_CHANGE, function (type) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
if (type === BI.Events.CLICK) {
self.fireEvent(BI.MonthPopup.EVENT_CHANGE);
}
});
},
getValue: function () {
return this.month.getValue()[0];
},
setValue: function (v) {
v = BI.parseInt(v);
this.month.setValue([v]);
}
});
BI.MonthPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.month_popup", BI.MonthPopup);

31
src/widget/month/__test__/month.test.js

@ -1,31 +0,0 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2019/9/12
*/
describe("month", function () {
/**
* test_author_windy
*/
it("setValue", function () {
var combo = BI.Test.createWidget({
type: "bi.month_combo",
});
combo.setValue(11);
expect(combo.getValue()).to.equal(11);
});
/**
* test_author_windy
*/
it("getValue", function () {
var combo = BI.Test.createWidget({
type: "bi.month_combo",
value: 1
});
expect(combo.getValue()).to.equal(1);
});
});

92
src/widget/month/combo.month.js

@ -1,92 +0,0 @@
/**
* 月份下拉框
*
* Created by GUY on 2015/8/28.
* @class BI.MonthCombo
* @extends BI.Trigger
*/
BI.MonthCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.MonthCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-month-combo",
behaviors: {},
height: 24
});
},
_init: function () {
BI.MonthCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.trigger = BI.createWidget({
type: "bi.month_trigger",
value: o.value
});
this.trigger.on(BI.MonthTrigger.EVENT_CONFIRM, function (v) {
if (self.combo.isViewVisible()) {
return;
}
if (this.getKey() && this.getKey() !== self.storeValue) {
self.setValue(this.getValue());
} else if (!this.getKey()) {
self.setValue();
}
self.fireEvent(BI.MonthCombo.EVENT_CONFIRM);
});
this.trigger.on(BI.MonthTrigger.EVENT_FOCUS, function () {
self.storeValue = this.getKey();
});
this.trigger.on(BI.MonthTrigger.EVENT_START, function () {
self.combo.hideView();
});
this.trigger.on(BI.MonthTrigger.EVENT_STOP, function () {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
});
this.popup = BI.createWidget({
type: "bi.month_popup",
behaviors: o.behaviors,
value: o.value
});
this.popup.on(BI.MonthPopup.EVENT_CHANGE, function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.MonthCombo.EVENT_CONFIRM);
});
this.combo = BI.createWidget({
type: "bi.combo",
container: o.container,
element: this,
isNeedAdjustHeight: false,
isNeedAdjustWidth: false,
el: this.trigger,
popup: {
minWidth: 85,
el: this.popup
}
});
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.fireEvent(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW);
});
},
setValue: function (v) {
this.trigger.setValue(v);
this.popup.setValue(v);
},
getValue: function () {
if (BI.isNull(this.popup)) {
return this.options.value || "";
} else {
return this.popup.getValue() || "";
}
}
});
BI.MonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.MonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.month_combo", BI.MonthCombo);

110
src/widget/month/trigger.month.js

@ -1,110 +0,0 @@
/**
* 月份trigger
*
* Created by GUY on 2015/8/21.
* @class BI.MonthTrigger
* @extends BI.Trigger
*/
BI.MonthTrigger = BI.inherit(BI.Trigger, {
_const: {
hgap: 4,
vgap: 2
},
_defaultConfig: function () {
return BI.extend(BI.MonthTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-month-trigger bi-border",
height: 24
});
},
_init: function () {
BI.MonthTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options, c = this._const;
this.editor = BI.createWidget({
type: "bi.sign_editor",
height: o.height,
validationChecker: function (v) {
return v === "" || (BI.isPositiveInteger(v) && v >= 1 && v <= 12);
},
quitChecker: function (v) {
return false;
},
hgap: c.hgap,
vgap: c.vgap,
allowBlank: true,
errorText: BI.i18nText("BI-Month_Trigger_Error_Text")
});
this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
self.fireEvent(BI.MonthTrigger.EVENT_FOCUS);
});
this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
self.fireEvent(BI.MonthTrigger.EVENT_CHANGE);
});
this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
var value = self.editor.getValue();
if (BI.isNotNull(value)) {
self.editor.setValue(value);
self.editor.setTitle(value);
}
self.fireEvent(BI.MonthTrigger.EVENT_CONFIRM);
});
this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
if (self.editor.isValid()) {
self.editor.blur();
}
});
this.editor.on(BI.SignEditor.EVENT_START, function () {
self.fireEvent(BI.MonthTrigger.EVENT_START);
});
this.editor.on(BI.SignEditor.EVENT_STOP, function () {
self.fireEvent(BI.MonthTrigger.EVENT_STOP);
});
BI.createWidget({
element: this,
type: "bi.htape",
items: [
{
el: this.editor
}, {
el: {
type: "bi.text_button",
text: BI.i18nText("BI-Multi_Date_Month"),
baseCls: "bi-trigger-month-text",
width: o.height
},
width: o.height
}, {
el: {
type: "bi.trigger_icon_button",
width: o.height
},
width: o.height
}
]
});
this.setValue(o.value);
},
setValue: function (v) {
if(BI.isNotNull(v)) {
this.editor.setState(v + 1);
this.editor.setValue(v + 1);
this.editor.setTitle(v + 1);
return;
}
this.editor.setState("");
this.editor.setValue("");
this.editor.setTitle("");
},
getKey: function () {
return this.editor.getValue() | 0;
},
getValue: function () {
return this.editor.getValue() - 1;
}
});
BI.MonthTrigger.EVENT_FOCUS = "EVENT_FOCUS";
BI.MonthTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.MonthTrigger.EVENT_START = "EVENT_START";
BI.MonthTrigger.EVENT_STOP = "EVENT_STOP";
BI.MonthTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.month_trigger", BI.MonthTrigger);

62
src/widget/multilayerdownlist/__test__/downlist.test.js

@ -0,0 +1,62 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2019/9/18
*/
describe("multi_layer_down_list_combo", function () {
/**
* test_author_windy
*/
it("defaultValue", function () {
var downListCombo = BI.Test.createWidget({
type: "bi.multi_layer_down_list_combo",
items: [[{"el":{"text":"column 1111","iconCls1":"dot-e-font","value":12},"children":[{"text":"column 1.1","value":21,"cls":"dot-e-font"},{"text":"column 1.2","value":22,"cls":"dot-e-font"}]}],[{"el":{"text":"column 1111","iconCls1":"dot-e-font","value":11},"children":[{"text":"column 1.1","value":21,"cls":"dot-e-font", children: [{"text":"column 1.1","value":21,"cls":"dot-e-font"}]},{"text":"column 1.2","value":22,"cls":"dot-e-font"}]}]]
});
downListCombo.setValue([{value: 12, childValue: 21}]);
expect(downListCombo.getValue()).to.deep.equal([ { childValue: 21, value: 12 } ]);
downListCombo.destroy();
});
/**
* test_author_windy
*/
it("点击父亲选值", function (done) {
var downListCombo = BI.Test.createWidget({
type: "bi.multi_layer_down_list_combo",
height: 30,
width: 30,
items: [[{"el":{"text":"column 1111","iconCls1":"dot-e-font","value":12},"children":[{"text":"column 1.1","value":21,"cls":"dot-e-font"},{"text":"column 1.2","value":22,"cls":"dot-e-font"}]}],[{"el":{"text":"column 1111","iconCls1":"dot-e-font","value":11},"children":[{"text":"column 1.1","value":21,"cls":"dot-e-font"},{"text":"column 1.2","value":22,"cls":"dot-e-font"}]}], [{"text": "column 1122", value: 32}, {"text": "column 1133", value: 33}]]
});
downListCombo.element.children(".pull-down-font").click();
BI.nextTick(function () {
downListCombo.element.find(".bi-down-list-group:last-child .bi-down-list-item").click();
expect(downListCombo.getValue()).to.deep.equal([ { value: 33 } ]);
done();
});
});
/**
* test_author_windy
*/
it("点击儿子选值", function (done) {
var downListCombo = BI.Test.createWidget({
type: "bi.multi_layer_down_list_combo",
height: 30,
width: 30,
items: [[{"el":{"text":"column 1111","iconCls1":"dot-e-font","value":12},"children":[{"text":"column 1.1","value":21,"cls":"dot-e-font"},{"text":"column 1.2","value":22,"cls":"dot-e-font"}]}],[{"el":{"text":"column 1111","iconCls1":"dot-e-font","value":11},"children":[{"text":"column 1.1","value":21,"cls":"dot-e-font"},{"text":"column 1.2","value":22,"cls":"dot-e-font"}]}]]
});
downListCombo.element.children(".pull-down-font").click();
BI.Test.triggerMouseover(downListCombo.element.find(".bi-down-list-group:first-child .bi-down-list-group-item"), function () {
BI.nextTick(function () {
downListCombo.element.find(".child-down-list-item:first-child").click();
expect(downListCombo.getValue()).to.deep.equal([ { childValue: 21, value: 12 } ]);
downListCombo.destroy();
done();
});
});
});
});

135
src/widget/multilayerselecttree/__test__/multilayerselecttree.combo.test.js

@ -0,0 +1,135 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2019/9/18
*/
describe("multilayer_select_tree", function () {
var items = [{id: -1, pId: -2, value: "根目录", text: "根目录"},
{id: 1, pId: -1, value: "第一级目录1", text: "第一级目录1"},
{id: 11, pId: 1, value: "第二级文件1", text: "第二级文件1"},
{id: 12, pId: 1, value: "第二级目录2", text: "第二级目录2"},
{id: 121, pId: 12, value: "第三级目录1", text: "第三级目录1"},
{id: 122, pId: 12, value: "第三级文件1", text: "第三级文件1"},
{id: 1211, pId: 121, value: "第四级目录1", text: "第四级目录1"},
{
id: 12111,
pId: 1211,
value: "第五级文件1",
text: "第五级文件111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
},
{id: 2, pId: -1, value: "第一级目录2", text: "第一级目录2"},
{id: 21, pId: 2, value: "第二级目录3", text: "第二级目录3"},
{id: 22, pId: 2, value: "第二级文件2", text: "第二级文件2"},
{id: 211, pId: 21, value: "第三级目录2", text: "第三级目录2"},
{id: 212, pId: 21, value: "第三级文件2", text: "第三级文件2"},
{id: 2111, pId: 211, value: "第四级文件1", text: "第四级文件1"}];
/**
* test_author_windy
**/
it("defaultValue_allowEdit", function () {
var tree = BI.Test.createWidget({
type: "bi.multilayer_select_tree_combo",
width: 300,
height: 24,
allowEdit: true,
items: BI.deepClone(items),
value: "第一级目录2"
});
expect(tree.getValue()).to.equal("第一级目录2");
tree.destroy();
});
/**
* test_author_windy
**/
it("defaultValue_not_allowEdit", function () {
var tree = BI.Test.createWidget({
type: "bi.multilayer_select_tree_combo",
width: 300,
height: 24,
items: BI.deepClone(items),
value: "第一级目录2"
});
expect(tree.getValue()).to.equal("第一级目录2");
tree.destroy();
});
/**
* test_author_windy
**/
it("点选选值", function (done) {
var tree = BI.Test.createWidget({
type: "bi.multilayer_select_tree_combo",
width: 300,
height: 24,
allowEdit: true,
items: BI.deepClone(items),
value: "第一级目录2"
});
tree.element.find(".bi-multi-layer-select-tree-trigger").click();
BI.nextTick(function () {
tree.element.find(".bi-select-tree-plus-group-node").click();
expect(tree.getValue()[0]).to.equal("根目录");
tree.destroy();
done();
});
});
/**
* test_author_windy
**/
it("搜索选值", function (done) {
var tree = BI.Test.createWidget({
type: "bi.multilayer_select_tree_combo",
width: 300,
height: 24,
allowEdit: true,
items: BI.deepClone(items)
});
BI.nextTick(function () {
tree.element.find(".bi-multi-layer-select-tree-trigger .tip-text-style").click();
// 这边为啥要加呢,因为input的setValue中有nextTick
BI.nextTick(function () {
BI.Test.triggerKeyDown(tree.element.find(".bi-multi-layer-select-tree-trigger .bi-input"), "2", 50, function () {
BI.nextTick(function () {
tree.element.find(".bi-select-tree-mid-plus-group-node").click();
expect(tree.getValue()[0]).to.equal("第一级目录2");
tree.destroy();
done();
});
});
});
});
});
/**
* test_author_windy
**/
it("新增值", function (done) {
var tree = BI.Test.createWidget({
type: "bi.multilayer_select_tree_combo",
width: 300,
height: 24,
allowEdit: true,
allowInsertValue: true,
items: BI.deepClone(items)
});
BI.nextTick(function () {
tree.element.find(".bi-multi-layer-select-tree-trigger .tip-text-style").click();
// 这边为啥要加呢,因为input的setValue中有nextTick
BI.nextTick(function () {
BI.Test.triggerKeyDown(tree.element.find(".bi-multi-layer-select-tree-trigger .bi-input"), "z", 50, function () {
BI.nextTick(function () {
tree.element.find(".bi-text-button:contains(+点击新增\"z\")").click();
expect(tree.getValue()[0]).to.equal("z");
tree.destroy();
done();
});
});
});
});
});
});

133
src/widget/multilayersingletree/__test__/multilayersingletree.combo.test.js

@ -0,0 +1,133 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2019/9/18
*/
describe("multilayer_single_tree", function () {
var items = [{id: -1, pId: -2, value: "根目录", text: "根目录", open: true},
{id: 1, pId: -1, value: "第一级目录1", text: "第一级目录1", open: true},
{id: 11, pId: 1, value: "第二级文件1", text: "第二级文件1"},
{id: 12, pId: 1, value: "第二级目录2", text: "第二级目录2", open: true},
{id: 121, pId: 12, value: "第三级目录1", text: "第三级目录1", open: true},
{id: 122, pId: 12, value: "第三级文件1", text: "第三级文件1"},
{id: 1211, pId: 121, value: "第四级目录1", text: "第四级目录1", open: true},
{
id: 12111,
pId: 1211,
value: "第五级文件1",
text: "第五级文件111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
},
{id: 2, pId: -1, value: "第一级目录2", text: "第一级目录2", open: true},
{id: 21, pId: 2, value: "第二级目录3", text: "第二级目录3", open: true},
{id: 22, pId: 2, value: "第二级文件2", text: "第二级文件2"},
{id: 211, pId: 21, value: "第三级目录2", text: "第三级目录2", open: true},
{id: 212, pId: 21, value: "第三级文件2", text: "第三级文件2"},
{id: 2111, pId: 211, value: "第四级文件1", text: "第四级文件1"}];
/**
* test_author_windy
**/
it("defaultValue_allowEdit", function () {
var tree = BI.Test.createWidget({
type: "bi.multilayer_single_tree_combo",
width: 300,
height: 24,
allowEdit: true,
items: BI.deepClone(items),
value: "第二级文件1"
});
expect(tree.getValue()).to.equal("第二级文件1");
tree.destroy();
});
/**
* test_author_windy
**/
it("defaultValue_not_allowEdit", function () {
var tree = BI.Test.createWidget({
type: "bi.multilayer_single_tree_combo",
width: 300,
height: 24,
items: BI.deepClone(items),
value: "第二级文件1"
});
expect(tree.getValue()).to.equal("第二级文件1");
tree.destroy();
});
/**
* test_author_windy
**/
it("点选选值", function (done) {
var tree = BI.Test.createWidget({
type: "bi.multilayer_single_tree_combo",
width: 300,
height: 24,
allowEdit: true,
items: BI.deepClone(items)
});
tree.element.find(".bi-multi-layer-single-tree-trigger").click();
BI.nextTick(function () {
tree.element.find(".bi-multilayer-single-tree-mid-tree-leaf-item").click();
expect(tree.getValue()[0]).to.equal("第二级文件1");
tree.destroy();
done();
});
});
/**
* test_author_windy
**/
it("搜索选值", function (done) {
var tree = BI.Test.createWidget({
type: "bi.multilayer_single_tree_combo",
width: 300,
height: 24,
allowEdit: true,
items: BI.deepClone(items)
});
BI.nextTick(function () {
tree.element.find(".bi-multi-layer-single-tree-trigger .tip-text-style").click();
// 这边为啥要加呢,因为input的setValue中有nextTick
BI.nextTick(function () {
BI.Test.triggerKeyDown(tree.element.find(".bi-multi-layer-single-tree-trigger .bi-input"), "2", 50, function () {
BI.nextTick(function () {
tree.element.find(".bi-multilayer-single-tree-mid-tree-leaf-item").click();
expect(tree.getValue()[0]).to.equal("第二级文件1");
tree.destroy();
done();
});
});
});
});
});
/**
* test_author_windy
**/
it("新增值", function (done) {
var tree = BI.Test.createWidget({
type: "bi.multilayer_single_tree_combo",
width: 300,
height: 24,
allowEdit: true,
allowInsertValue: true,
items: BI.deepClone(items)
});
BI.nextTick(function () {
tree.element.find(".bi-multi-layer-single-tree-trigger .tip-text-style").click();
// 这边为啥要加呢,因为input的setValue中有nextTick
BI.nextTick(function () {
BI.Test.triggerKeyDown(tree.element.find(".bi-multi-layer-single-tree-trigger .bi-input"), "z", 50, function () {
BI.nextTick(function () {
tree.element.find(".bi-text-button:contains(+点击新增\"z\")").click();
expect(tree.getValue()[0]).to.equal("z");
tree.destroy();
done();
});
});
});
});
});
});

5
src/widget/multiselect/__test__/multiselect.loader.nobar.test.js

@ -0,0 +1,5 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2019/9/18
*/

5
src/widget/multiselect/__test__/multiselect.loader.test.js

@ -0,0 +1,5 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2019/9/18
*/

5
src/widget/multiselect/__test__/multiselectcombo.test.js

@ -0,0 +1,5 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2019/9/18
*/

5
src/widget/multiselect/__test__/multiselectinsert.combo.test.js

@ -0,0 +1,5 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2019/9/18
*/

92
src/widget/quarter/combo.quarter.js

@ -1,92 +0,0 @@
/**
* 季度下拉框
*
* Created by GUY on 2015/8/28.
* @class BI.QuarterCombo
* @extends BI.Widget
*/
BI.QuarterCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.QuarterCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-quarter-combo",
behaviors: {},
height: 25
});
},
_init: function () {
BI.QuarterCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.storeValue = "";
this.trigger = BI.createWidget({
type: "bi.quarter_trigger",
value: o.value
});
this.trigger.on(BI.QuarterTrigger.EVENT_FOCUS, function () {
self.storeValue = this.getKey();
});
this.trigger.on(BI.QuarterTrigger.EVENT_START, function () {
self.combo.isViewVisible() && self.combo.hideView();
});
this.trigger.on(BI.QuarterTrigger.EVENT_STOP, function () {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
});
this.trigger.on(BI.QuarterTrigger.EVENT_CONFIRM, function () {
if (self.combo.isViewVisible()) {
return;
}
if (this.getKey() && this.getKey() !== self.storeValue) {
self.setValue(this.getKey());
} else if (!this.getKey()) {
self.setValue();
}
self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM);
});
this.popup = BI.createWidget({
type: "bi.quarter_popup",
behaviors: o.behaviors,
value: o.value
});
this.popup.on(BI.QuarterPopup.EVENT_CHANGE, function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM);
});
this.combo = BI.createWidget({
type: "bi.combo",
container: o.container,
element: this,
isNeedAdjustHeight: false,
isNeedAdjustWidth: false,
el: this.trigger,
popup: {
minWidth: 85,
el: this.popup
}
});
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.fireEvent(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW);
});
},
setValue: function (v) {
this.trigger.setValue(v);
this.popup.setValue(v);
},
getValue: function () {
if (BI.isNull(this.popup)) {
return this.options.value || "";
} else {
return this.popup.getValue() || "";
}
}
});
BI.QuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.quarter_combo", BI.QuarterCombo);

74
src/widget/quarter/popup.quarter.js

@ -1,74 +0,0 @@
/**
* 季度展示面板
*
* Created by GUY on 2015/9/2.
* @class BI.QuarterPopup
* @extends BI.Trigger
*/
BI.QuarterPopup = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.QuarterPopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-quarter-popup",
behaviors: {}
});
},
_init: function () {
BI.QuarterPopup.superclass._init.apply(this, arguments);
var self = this, o = this.options;
var items = [{
text: BI.Date._QN[1],
value: 1
}, {
text: BI.Date._QN[2],
value: 2
}, {
text: BI.Date._QN[3],
value: 3
}, {
text: BI.Date._QN[4],
value: 4
}];
items = BI.map(items, function (j, item) {
return BI.extend(item, {
type: "bi.text_item",
cls: "bi-list-item-active",
textAlign: "left",
whiteSpace: "nowrap",
once: false,
forceSelected: true,
height: 25
});
});
this.quarter = BI.createWidget({
type: "bi.button_group",
element: this,
behaviors: o.behaviors,
items: BI.createItems(items, {}),
layouts: [{
type: "bi.vertical"
}],
value: o.value
});
this.quarter.on(BI.Controller.EVENT_CHANGE, function (type) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
if (type === BI.Events.CLICK) {
self.fireEvent(BI.MonthPopup.EVENT_CHANGE);
}
});
},
getValue: function () {
return this.quarter.getValue()[0];
},
setValue: function (v) {
this.quarter.setValue([v]);
}
});
BI.QuarterPopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.quarter_popup", BI.QuarterPopup);

106
src/widget/quarter/trigger.quarter.js

@ -1,106 +0,0 @@
/**
* 季度trigger
*
* Created by GUY on 2015/8/21.
* @class BI.QuarterTrigger
* @extends BI.Trigger
*/
BI.QuarterTrigger = BI.inherit(BI.Trigger, {
_const: {
hgap: 4,
vgap: 2,
textWidth: 40
},
_defaultConfig: function () {
return BI.extend(BI.QuarterTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-quarter-trigger bi-border",
height: 24
});
},
_init: function () {
BI.QuarterTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options, c = this._const;
this.editor = BI.createWidget({
type: "bi.sign_editor",
height: o.height,
validationChecker: function (v) {
return v === "" || (BI.isPositiveInteger(v) && v >= 1 && v <= 4);
},
quitChecker: function (v) {
return false;
},
hgap: c.hgap,
vgap: c.vgap,
allowBlank: true,
errorText: BI.i18nText("BI-Quarter_Trigger_Error_Text")
});
this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
self.fireEvent(BI.QuarterTrigger.EVENT_FOCUS);
});
this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
self.fireEvent(BI.QuarterTrigger.EVENT_CHANGE);
});
this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
var value = self.editor.getValue();
if (BI.isNotNull(value)) {
self.editor.setValue(value);
self.editor.setTitle(value);
}
self.fireEvent(BI.QuarterTrigger.EVENT_CONFIRM);
});
this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
if (self.editor.isValid()) {
self.editor.blur();
}
});
this.editor.on(BI.SignEditor.EVENT_START, function () {
self.fireEvent(BI.QuarterTrigger.EVENT_START);
});
this.editor.on(BI.SignEditor.EVENT_STOP, function () {
self.fireEvent(BI.QuarterTrigger.EVENT_STOP);
});
BI.createWidget({
element: this,
type: "bi.htape",
items: [
{
el: this.editor
}, {
el: {
type: "bi.text_button",
baseCls: "bi-trigger-quarter-text",
text: BI.i18nText("BI-Multi_Date_Quarter"),
width: c.textWidth
},
width: c.textWidth
}, {
el: {
type: "bi.trigger_icon_button",
width: o.height
},
width: o.height
}
]
});
this.setValue(o.value);
},
setValue: function (v) {
v = v || "";
this.editor.setState(v);
this.editor.setValue(v);
this.editor.setTitle(v);
},
getKey: function () {
return this.editor.getValue();
}
});
BI.QuarterTrigger.EVENT_FOCUS = "EVENT_FOCUS";
BI.QuarterTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.QuarterTrigger.EVENT_START = "EVENT_START";
BI.QuarterTrigger.EVENT_STOP = "EVENT_STOP";
BI.QuarterTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.quarter_trigger", BI.QuarterTrigger);
Loading…
Cancel
Save