Browse Source

multiselectbar加上selected和halfSeleced

es6
windy 7 years ago
parent
commit
47a15e8f25
  1. 22
      demo/js/base/button/demo.button.js
  2. 24
      dist/bundle.js
  3. 24
      dist/case.js
  4. 22
      dist/demo.js
  5. 24
      dist/fineui.js
  6. 24
      src/case/toolbar/toolbar.multiselect.js

22
demo/js/base/button/demo.button.js

@ -177,6 +177,28 @@ Demo.Button = BI.inherit(BI.Widget, {
iconClass: "close-font", iconClass: "close-font",
height: 30 height: 30
} }
}, {
el: {
type: "bi.multi_select_bar",
selected: true,
halfSelected: true
}
}, {
el: {
type: "bi.multi_select_bar",
selected: true,
halfSelected: false
}
}, {
el: {
type: "bi.multi_select_bar",
selected: false,
halfSelected: true
}
}, {
el: {
type: "bi.multi_select_bar"
}
} }
]; ];
BI.each(items, function (i, item) { BI.each(items, function (i, item) {

24
dist/bundle.js vendored

@ -74555,25 +74555,31 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
disableSelected: true, disableSelected: true,
isHalfCheckedBySelectedValue: function (selectedValues) { isHalfCheckedBySelectedValue: function (selectedValues) {
return selectedValues.length > 0; return selectedValues.length > 0;
} },
halfSelected: false
}); });
}, },
_init: function () { _init: function () {
BI.MultiSelectBar.superclass._init.apply(this, arguments); BI.MultiSelectBar.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
var isSelect = o.selected === true;
var isHalfSelect = !o.selected && o.halfSelected;
this.checkbox = BI.createWidget({ this.checkbox = BI.createWidget({
type: "bi.checkbox", type: "bi.checkbox",
stopPropagation: true, stopPropagation: true,
handler: function () { handler: function () {
self.setSelected(self.isSelected()); self.setSelected(self.isSelected());
} },
selected: isSelect,
invisible: isHalfSelect
}); });
this.half = BI.createWidget({ this.half = BI.createWidget({
type: "bi.half_icon_button", type: "bi.half_icon_button",
stopPropagation: true, stopPropagation: true,
handler: function () { handler: function () {
self.setSelected(true); self.setSelected(true);
} },
invisible: isSelect || !isHalfSelect
}); });
this.checkbox.on(BI.Controller.EVENT_CHANGE, function () { this.checkbox.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self);
@ -74612,7 +74618,10 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
el: this.text el: this.text
}] }]
}); });
this.half.invisible(); },
_setSelected: function (v) {
this.checkbox.setSelected(!!v);
}, },
// 自己手动控制选中 // 自己手动控制选中
@ -74631,8 +74640,9 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
}, },
setHalfSelected: function (b) { setHalfSelected: function (b) {
this._half = !!b; this.halfSelected = !!b;
if (b === true) { if (b === true) {
this.checkbox.setSelected(false);
this.half.visible(); this.half.visible();
this.checkbox.invisible(); this.checkbox.invisible();
} else { } else {
@ -74642,7 +74652,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
}, },
isHalfSelected: function () { isHalfSelected: function () {
return !!this._half; return !this.isSelected() && !!this.halfSelected;
}, },
isSelected: function () { isSelected: function () {
@ -74652,7 +74662,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
setValue: function (selectedValues) { setValue: function (selectedValues) {
BI.MultiSelectBar.superclass.setValue.apply(this, arguments); BI.MultiSelectBar.superclass.setValue.apply(this, arguments);
var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments); var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments);
this.setSelected(isAllChecked); this._setSelected(isAllChecked);
!isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments)); !isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments));
} }
}); });

24
dist/case.js vendored

@ -12410,25 +12410,31 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
disableSelected: true, disableSelected: true,
isHalfCheckedBySelectedValue: function (selectedValues) { isHalfCheckedBySelectedValue: function (selectedValues) {
return selectedValues.length > 0; return selectedValues.length > 0;
} },
halfSelected: false
}); });
}, },
_init: function () { _init: function () {
BI.MultiSelectBar.superclass._init.apply(this, arguments); BI.MultiSelectBar.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
var isSelect = o.selected === true;
var isHalfSelect = !o.selected && o.halfSelected;
this.checkbox = BI.createWidget({ this.checkbox = BI.createWidget({
type: "bi.checkbox", type: "bi.checkbox",
stopPropagation: true, stopPropagation: true,
handler: function () { handler: function () {
self.setSelected(self.isSelected()); self.setSelected(self.isSelected());
} },
selected: isSelect,
invisible: isHalfSelect
}); });
this.half = BI.createWidget({ this.half = BI.createWidget({
type: "bi.half_icon_button", type: "bi.half_icon_button",
stopPropagation: true, stopPropagation: true,
handler: function () { handler: function () {
self.setSelected(true); self.setSelected(true);
} },
invisible: isSelect || !isHalfSelect
}); });
this.checkbox.on(BI.Controller.EVENT_CHANGE, function () { this.checkbox.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self);
@ -12467,7 +12473,10 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
el: this.text el: this.text
}] }]
}); });
this.half.invisible(); },
_setSelected: function (v) {
this.checkbox.setSelected(!!v);
}, },
// 自己手动控制选中 // 自己手动控制选中
@ -12486,8 +12495,9 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
}, },
setHalfSelected: function (b) { setHalfSelected: function (b) {
this._half = !!b; this.halfSelected = !!b;
if (b === true) { if (b === true) {
this.checkbox.setSelected(false);
this.half.visible(); this.half.visible();
this.checkbox.invisible(); this.checkbox.invisible();
} else { } else {
@ -12497,7 +12507,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
}, },
isHalfSelected: function () { isHalfSelected: function () {
return !!this._half; return !this.isSelected() && !!this.halfSelected;
}, },
isSelected: function () { isSelected: function () {
@ -12507,7 +12517,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
setValue: function (selectedValues) { setValue: function (selectedValues) {
BI.MultiSelectBar.superclass.setValue.apply(this, arguments); BI.MultiSelectBar.superclass.setValue.apply(this, arguments);
var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments); var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments);
this.setSelected(isAllChecked); this._setSelected(isAllChecked);
!isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments)); !isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments));
} }
}); });

22
dist/demo.js vendored

@ -196,6 +196,28 @@ $(function () {
iconClass: "close-font", iconClass: "close-font",
height: 30 height: 30
} }
}, {
el: {
type: "bi.multi_select_bar",
selected: true,
halfSelected: true
}
}, {
el: {
type: "bi.multi_select_bar",
selected: true,
halfSelected: false
}
}, {
el: {
type: "bi.multi_select_bar",
selected: false,
halfSelected: true
}
}, {
el: {
type: "bi.multi_select_bar"
}
} }
]; ];
BI.each(items, function (i, item) { BI.each(items, function (i, item) {

24
dist/fineui.js vendored

@ -76249,25 +76249,31 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
disableSelected: true, disableSelected: true,
isHalfCheckedBySelectedValue: function (selectedValues) { isHalfCheckedBySelectedValue: function (selectedValues) {
return selectedValues.length > 0; return selectedValues.length > 0;
} },
halfSelected: false
}); });
}, },
_init: function () { _init: function () {
BI.MultiSelectBar.superclass._init.apply(this, arguments); BI.MultiSelectBar.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
var isSelect = o.selected === true;
var isHalfSelect = !o.selected && o.halfSelected;
this.checkbox = BI.createWidget({ this.checkbox = BI.createWidget({
type: "bi.checkbox", type: "bi.checkbox",
stopPropagation: true, stopPropagation: true,
handler: function () { handler: function () {
self.setSelected(self.isSelected()); self.setSelected(self.isSelected());
} },
selected: isSelect,
invisible: isHalfSelect
}); });
this.half = BI.createWidget({ this.half = BI.createWidget({
type: "bi.half_icon_button", type: "bi.half_icon_button",
stopPropagation: true, stopPropagation: true,
handler: function () { handler: function () {
self.setSelected(true); self.setSelected(true);
} },
invisible: isSelect || !isHalfSelect
}); });
this.checkbox.on(BI.Controller.EVENT_CHANGE, function () { this.checkbox.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self);
@ -76306,7 +76312,10 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
el: this.text el: this.text
}] }]
}); });
this.half.invisible(); },
_setSelected: function (v) {
this.checkbox.setSelected(!!v);
}, },
// 自己手动控制选中 // 自己手动控制选中
@ -76325,8 +76334,9 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
}, },
setHalfSelected: function (b) { setHalfSelected: function (b) {
this._half = !!b; this.halfSelected = !!b;
if (b === true) { if (b === true) {
this.checkbox.setSelected(false);
this.half.visible(); this.half.visible();
this.checkbox.invisible(); this.checkbox.invisible();
} else { } else {
@ -76336,7 +76346,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
}, },
isHalfSelected: function () { isHalfSelected: function () {
return !!this._half; return !this.isSelected() && !!this.halfSelected;
}, },
isSelected: function () { isSelected: function () {
@ -76346,7 +76356,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
setValue: function (selectedValues) { setValue: function (selectedValues) {
BI.MultiSelectBar.superclass.setValue.apply(this, arguments); BI.MultiSelectBar.superclass.setValue.apply(this, arguments);
var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments); var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments);
this.setSelected(isAllChecked); this._setSelected(isAllChecked);
!isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments)); !isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments));
} }
}); });

24
src/case/toolbar/toolbar.multiselect.js

@ -16,25 +16,31 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
disableSelected: true, disableSelected: true,
isHalfCheckedBySelectedValue: function (selectedValues) { isHalfCheckedBySelectedValue: function (selectedValues) {
return selectedValues.length > 0; return selectedValues.length > 0;
} },
halfSelected: false
}); });
}, },
_init: function () { _init: function () {
BI.MultiSelectBar.superclass._init.apply(this, arguments); BI.MultiSelectBar.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
var isSelect = o.selected === true;
var isHalfSelect = !o.selected && o.halfSelected;
this.checkbox = BI.createWidget({ this.checkbox = BI.createWidget({
type: "bi.checkbox", type: "bi.checkbox",
stopPropagation: true, stopPropagation: true,
handler: function () { handler: function () {
self.setSelected(self.isSelected()); self.setSelected(self.isSelected());
} },
selected: isSelect,
invisible: isHalfSelect
}); });
this.half = BI.createWidget({ this.half = BI.createWidget({
type: "bi.half_icon_button", type: "bi.half_icon_button",
stopPropagation: true, stopPropagation: true,
handler: function () { handler: function () {
self.setSelected(true); self.setSelected(true);
} },
invisible: isSelect || !isHalfSelect
}); });
this.checkbox.on(BI.Controller.EVENT_CHANGE, function () { this.checkbox.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self);
@ -73,7 +79,10 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
el: this.text el: this.text
}] }]
}); });
this.half.invisible(); },
_setSelected: function (v) {
this.checkbox.setSelected(!!v);
}, },
// 自己手动控制选中 // 自己手动控制选中
@ -92,8 +101,9 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
}, },
setHalfSelected: function (b) { setHalfSelected: function (b) {
this._half = !!b; this.halfSelected = !!b;
if (b === true) { if (b === true) {
this.checkbox.setSelected(false);
this.half.visible(); this.half.visible();
this.checkbox.invisible(); this.checkbox.invisible();
} else { } else {
@ -103,7 +113,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
}, },
isHalfSelected: function () { isHalfSelected: function () {
return !!this._half; return !this.isSelected() && !!this.halfSelected;
}, },
isSelected: function () { isSelected: function () {
@ -113,7 +123,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
setValue: function (selectedValues) { setValue: function (selectedValues) {
BI.MultiSelectBar.superclass.setValue.apply(this, arguments); BI.MultiSelectBar.superclass.setValue.apply(this, arguments);
var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments); var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments);
this.setSelected(isAllChecked); this._setSelected(isAllChecked);
!isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments)); !isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments));
} }
}); });

Loading…
Cancel
Save