iapyang 7 years ago
parent
commit
249cadafc4
  1. 4
      Gruntfile.js
  2. 30
      bi/base.js
  3. 75
      bi/case.js
  4. 267
      bi/slider.js
  5. 2
      bi/widget.css
  6. 69
      demo/js/widget/slider/demo.slider.js
  7. 30
      dist/base.js
  8. 2
      dist/bundle.css
  9. 105
      dist/bundle.js
  10. 2
      dist/bundle.min.css
  11. 68
      dist/bundle.min.js
  12. 75
      dist/case.js
  13. 69
      dist/demo.js
  14. 267
      dist/slider.js
  15. 2
      dist/widget.css
  16. 12
      src/addons/slider/singleslider/button/iconbutton.slider.js
  17. 8
      src/addons/slider/singleslider/singleslider.js
  18. 2
      src/addons/slider/singleslider/singleslider.normal.js
  19. 44
      src/addons/slider/slider/slider.button.js
  20. 201
      src/addons/slider/slider/slider.js
  21. 30
      src/base/combination/combo.js
  22. 76
      src/case/trigger/trigger.icon.text.js

4
Gruntfile.js

@ -83,7 +83,7 @@ module.exports = function (grunt) {
},
sliderJs: {
src: [
'src/addons/slider/slider/**/*.js'
'src/addons/slider/singleslider/**/*.js'
],
dest: 'dist/slider.js'
},
@ -226,7 +226,7 @@ module.exports = function (grunt) {
},
bi_sliderJs: {
src: [
'src/addons/slider/slider/**/*.js'
'src/addons/slider/singleslider/**/*.js'
],
dest: 'bi/slider.js'
},

30
bi/base.js

@ -3024,6 +3024,9 @@ BI.Combo = BI.inherit(BI.Widget, {
var debounce = BI.debounce(function (e) {
if (self.combo.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
if (!o.toggle && self.isViewVisible()) {
return;
}
o.toggle ? self._toggle() : self._popupView();
if (self.isViewVisible()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
@ -3040,6 +3043,33 @@ BI.Combo = BI.inherit(BI.Widget, {
st(e);
});
break;
case "click-hover":
var debounce = BI.debounce(function (e) {
if (self.combo.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
if (self.isViewVisible()) {
return;
}
self._popupView();
if (self.isViewVisible()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
self.fireEvent(BI.Combo.EVENT_EXPAND);
}
}
}
}, BI.EVENT_RESPONSE_TIME, true);
self.element.off(ev + "." + self.getName()).on(ev + "." + self.getName(), function (e) {
debounce(e);
st(e);
});
self.element.on("mouseleave." + self.getName(), function (e) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid() && o.toggle === true) {
self._hideView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo);
self.fireEvent(BI.Combo.EVENT_COLLAPSE);
}
});
break;
}
});
},

75
bi/case.js

@ -12545,6 +12545,81 @@ BI.IconTrigger = BI.inherit(BI.Trigger, {
}
});
BI.shortcut('bi.icon_trigger', BI.IconTrigger);/**
* 文字trigger
*
* Created by GUY on 2015/9/15.
* @class BI.IconTextTrigger
* @extends BI.Trigger
*/
BI.IconTextTrigger = BI.inherit(BI.Trigger, {
_const: {
hgap: 4,
triggerWidth: 30
},
_defaultConfig: function () {
var conf = BI.IconTextTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-trigger",
height: 30
});
},
_init: function () {
BI.IconTextTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options, c = this._const;
this.text = BI.createWidget({
type: "bi.label",
textAlign: "left",
height: o.height,
text: o.text,
hgap: c.hgap
});
this.trigerButton = BI.createWidget({
type: "bi.trigger_icon_button",
cls: "bi-border-left",
width: c.triggerWidth
});
BI.createWidget({
element: this,
type: 'bi.htape',
items: [{
el: {
type: "bi.icon_change_button",
cls: "icon-combo-trigger-icon " + o.iconClass,
ref: function (_ref) {
self.icon = _ref;
},
disableSelected: true
},
width: 24
},
{
el: this.text
}, {
el: this.trigerButton,
width: c.triggerWidth
}
]
});
},
setValue: function (value) {
this.text.setValue(value);
this.text.setTitle(value);
},
setIcon: function (iconCls) {
this.icon.setIcon(iconCls);
},
setText: function (text) {
this.text.setText(text);
this.text.setTitle(text);
}
});
BI.shortcut("bi.icon_text_trigger", BI.IconTextTrigger);/**
* 文字trigger
*
* Created by GUY on 2015/9/15.

267
bi/slider.js

@ -1,17 +1,17 @@
/**
* Created by zcf on 2016/9/22.
*/
BI.Slider = BI.inherit(BI.Widget, {
BI.SliderIconButton = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.Slider.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-button-button"
return BI.extend(BI.SliderIconButton.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-slider-button"
});
},
_init: function () {
BI.extend(BI.Slider.superclass._init.apply(this, arguments));
BI.extend(BI.SliderIconButton.superclass._init.apply(this, arguments));
this.slider = BI.createWidget({
type: "bi.icon_button",
cls: "widget-button-icon button-button",
cls: "widget-slider-icon slider-button",
iconWidth: 14,
iconHeight: 14,
height: 14,
@ -30,7 +30,7 @@ BI.Slider = BI.inherit(BI.Widget, {
});
}
});
BI.shortcut("bi.single_slider_slider", BI.Slider);/**
BI.shortcut("bi.single_slider_button", BI.SliderIconButton);/**
* Created by zcf on 2016/9/22.
*/
BI.SingleSlider = BI.inherit(BI.Widget, {
@ -69,7 +69,7 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
this.track = this._createTrackWrapper();
this.slider = BI.createWidget({
type: "bi.single_slider_slider"
type: "bi.single_slider_button"
});
this.slider.element.draggable({
axis: "x",
@ -127,7 +127,7 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
cls: "slider-editor-button bi-border",
errorText: "",
height: c.HEIGHT,
width: c.EDITOR_WIDTH,
width: c.EDITOR_WIDTH - 2,
allowBlank: false,
validationChecker: function (v) {
return self._checkValidation(v);
@ -137,7 +137,9 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
}
});
this.label.on(BI.SignEditor.EVENT_CONFIRM, function () {
var percent = self._getPercentByValue(this.getValue());
var v = BI.parseFloat(this.getValue());
self.value = v;
var percent = self._getPercentByValue(v);
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setAllPosition(significantPercent);
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
@ -338,7 +340,7 @@ BI.SingleSliderNormal = BI.inherit(BI.Widget, {
var c = this._constant;
var track = this._createTrack();
this.slider = BI.createWidget({
type: "bi.single_slider_slider"
type: "bi.single_slider_button"
});
this.slider.element.draggable({
axis: "x",
@ -551,247 +553,4 @@ BI.SingleSliderNormal = BI.inherit(BI.Widget, {
}
});
BI.SingleSliderNormal.EVENT_DRAG = "EVENT_DRAG";
BI.shortcut("bi.single_slider_normal", BI.SingleSliderNormal);/**
* Created by Urthur on 2017/9/4.
*/
BI.SliderButton = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.SliderButton.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-slider-button"
});
},
_init: function () {
BI.extend(BI.SliderButton.superclass._init.apply(this, arguments));
var self = this;
var sliderButton = BI.createWidget({
type: "bi.icon_button",
cls: "column-next-page-h-font",
iconWidth: 16,
iconHeight: 16,
height: 16,
width: 16
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: sliderButton,
left: -8
}, {
el: {
type: "bi.label",
ref: function (_ref) {
self.label = _ref;
}
},
left: -8,
top: -10
}]
});
},
setValue: function (v) {
this.label.setText(v);
}
});
BI.shortcut("bi.slider_button", BI.SliderButton);/**
* Created by Urthur on 2017/9/4.
*/
BI.SliderNormal = BI.inherit(BI.Widget, {
_constant: {
HEIGHT: 28,
SLIDER_WIDTH_HALF: 10,
SLIDER_WIDTH: 25,
SLIDER_HEIGHT: 30,
TRACK_HEIGHT: 24
},
_defaultConfig: function () {
return BI.extend(BI.SliderNormal.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-slider",
min: 10,
max: 50
})
},
_init: function () {
BI.SliderNormal.superclass._init.apply(this, arguments);
var self = this;
var c = this._constant, o = this.options;
this.enable = false;
this.value = o.min;
this.min = o.min;
this.max = o.max;
this.rightTrack = BI.createWidget({
type: "bi.layout",
cls: "bi-slider-track",
height: 5
});
this.track = this._createTrack();
this.slider = BI.createWidget({
type: "bi.slider_button"
});
this.slider.setValue(this.getValue());
this.slider.element.draggable({
axis: "x",
containment: this.rightTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getRightTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
var v = self._getValueByPercent(significantPercent);
self.value = BI.parseInt(v) + 1;
self.slider.setValue(self.getValue());
self.fireEvent(BI.SliderNormal.EVENT_CHANGE);
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getRightTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
self.fireEvent(BI.SliderNormal.EVENT_CHANGE);
}
});
var sliderVertical = BI.createWidget({
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [{
el: this.slider,
top: 10
}]
}],
hgap: c.SLIDER_WIDTH_HALF,
height: c.SLIDER_HEIGHT
});
sliderVertical.element.click(function (e) {
if (self.enable) {
var offset = e.clientX - self.element.offset().left - c.SLIDER_WIDTH_HALF;
var trackLength = self.track.element[0].scrollWidth;
var percent = 0;
if (offset < 0) {
percent = 0
}
if (offset > 0 && offset < (trackLength - c.SLIDER_WIDTH)) {
percent = offset * 100 / self._getRightTrackLength();
}
if (offset > (trackLength - c.SLIDER_WIDTH)) {
percent = 100
}
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
self.value = BI.parseInt(v);
self.slider.setValue(self.getValue());
self.fireEvent(BI.SliderNormal.EVENT_CHANGE);
}
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: {
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [{
el: this.track,
width: "100%",
height: c.TRACK_HEIGHT
}]
}],
height: c.TRACK_HEIGHT
},
top: 33,
left: 0,
width: "100%"
}, {
el: sliderVertical,
top: 15,
left: 0,
width: "100%"
}]
});
},
_createTrack: function () {
return BI.createWidget({
type: "bi.absolute",
items: [{
el: {
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [{
el: this.rightTrack,
top: 0,
left: 0,
width: "100%"
}]
}],
hgap: 8,
height: 5
},
top: 5,
left: 0,
width: "100%"
}]
})
},
_checkValidation: function (v) {
return !(BI.isNull(v) || v < this.min || v > this.max)
},
_setSliderPosition: function (percent) {
this.slider.element.css({"left": percent + "%"});
},
_getRightTrackLength: function () {
return this.rightTrack.element[0].scrollWidth
},
_getValueByPercent: function (percent) {
var thousandth = BI.parseInt(percent * 10);
return (((this.max - this.min) * thousandth) / 1000 + this.min);
},
_getPercentByValue: function (v) {
return (v - this.min) * 100 / (this.max - this.min);
},
getValue: function () {
return this.value;
},
setValue: function (v) {
var value = BI.parseFloat(v);
if ((!isNaN(value))) {
if (this._checkValidation(value)) {
this.value = value;
}
if (value > this.max) {
this.value = this.max;
}
if (value < this.min) {
this.value = this.min;
}
}
if (!isNaN(this.min) && !isNaN(this.max)) {
this.enable = true;
if (BI.isNumeric(this.value) || BI.isNotEmptyString(this.value)) {
this.slider.setValue(BI.parseInt(this.value));
this._setSliderPosition(this._getPercentByValue(this.value));
} else {
this.slider.setValue(this.max);
this._setSliderPosition(100);
}
}
}
});
BI.SliderNormal.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.slider", BI.SliderNormal);
BI.shortcut("bi.single_slider_normal", BI.SingleSliderNormal);

2
bi/widget.css

@ -433,7 +433,7 @@
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
.bi-single-slider-slider .slider-button {
cursor: url('${remoteServletURL}?op=resource&resource=/com/fr/bi/web/images/1x/cursor/cursor_drag_slider.cur'), auto;
cursor: url('images/1x/cursor/cursor_drag_slider.cur'), auto;
-webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);

69
demo/js/widget/slider/demo.slider.js

@ -11,32 +11,57 @@ Demo.Slider = BI.inherit(BI.Widget, {
},
_init: function () {
Demo.Slider.superclass._init.apply(this, arguments);
var self = this;
var singleSlider = BI.createWidget({
type: "bi.single_slider",
width: 300,
height: 50
});
singleSlider.setMinAndMax({
min: 10,
max: 100
});
singleSlider.populate();
var normalSingleSlider = BI.createWidget({
type: "bi.single_slider_normal",
height: 30,
width: 300
});
normalSingleSlider.setMinAndMax({
min: 0,
max: 100
});
normalSingleSlider.setValue(10);
normalSingleSlider.populate();
BI.createWidget({
type: "bi.vertical_adapt",
type: "bi.vtape",
element: this,
width: 100,
items: [{
type: "bi.htape",
items: [{
el: {
type: "bi.slider",
min: 16,
max: 50,
ref: function (_ref) {
self.slider = _ref;
}
}
}],
height: 30,
width: 100
}]
el: {
type: "bi.center_adapt",
items: [{
el: singleSlider
}]
},
height: 200
}, {
el: {
type: "bi.center_adapt",
items: [{
el: normalSingleSlider
}]
},
height: 200
}],
hgap: 20
});
this.slider.setValue("30");
this.slider.on(BI.SliderNormal.EVENT_CHANGE, function () {
console.log(this.getValue());
})
}
});
BI.shortcut("demo.slider", Demo.Slider);

30
dist/base.js vendored

@ -3024,6 +3024,9 @@ BI.Combo = BI.inherit(BI.Widget, {
var debounce = BI.debounce(function (e) {
if (self.combo.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
if (!o.toggle && self.isViewVisible()) {
return;
}
o.toggle ? self._toggle() : self._popupView();
if (self.isViewVisible()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
@ -3040,6 +3043,33 @@ BI.Combo = BI.inherit(BI.Widget, {
st(e);
});
break;
case "click-hover":
var debounce = BI.debounce(function (e) {
if (self.combo.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
if (self.isViewVisible()) {
return;
}
self._popupView();
if (self.isViewVisible()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
self.fireEvent(BI.Combo.EVENT_EXPAND);
}
}
}
}, BI.EVENT_RESPONSE_TIME, true);
self.element.off(ev + "." + self.getName()).on(ev + "." + self.getName(), function (e) {
debounce(e);
st(e);
});
self.element.on("mouseleave." + self.getName(), function (e) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid() && o.toggle === true) {
self._hideView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo);
self.fireEvent(BI.Combo.EVENT_COLLAPSE);
}
});
break;
}
});
},

2
dist/bundle.css vendored

@ -3210,7 +3210,7 @@ li.CodeMirror-hint-active {
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
.bi-single-slider-slider .slider-button {
cursor: url('${remoteServletURL}?op=resource&resource=/com/fr/bi/web/images/1x/cursor/cursor_drag_slider.cur'), auto;
cursor: url('images/1x/cursor/cursor_drag_slider.cur'), auto;
-webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);

105
dist/bundle.js vendored

@ -31812,6 +31812,9 @@ BI.Combo = BI.inherit(BI.Widget, {
var debounce = BI.debounce(function (e) {
if (self.combo.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
if (!o.toggle && self.isViewVisible()) {
return;
}
o.toggle ? self._toggle() : self._popupView();
if (self.isViewVisible()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
@ -31828,6 +31831,33 @@ BI.Combo = BI.inherit(BI.Widget, {
st(e);
});
break;
case "click-hover":
var debounce = BI.debounce(function (e) {
if (self.combo.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
if (self.isViewVisible()) {
return;
}
self._popupView();
if (self.isViewVisible()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
self.fireEvent(BI.Combo.EVENT_EXPAND);
}
}
}
}, BI.EVENT_RESPONSE_TIME, true);
self.element.off(ev + "." + self.getName()).on(ev + "." + self.getName(), function (e) {
debounce(e);
st(e);
});
self.element.on("mouseleave." + self.getName(), function (e) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid() && o.toggle === true) {
self._hideView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo);
self.fireEvent(BI.Combo.EVENT_COLLAPSE);
}
});
break;
}
});
},
@ -76860,6 +76890,81 @@ BI.IconTrigger = BI.inherit(BI.Trigger, {
}
});
BI.shortcut('bi.icon_trigger', BI.IconTrigger);/**
* 文字trigger
*
* Created by GUY on 2015/9/15.
* @class BI.IconTextTrigger
* @extends BI.Trigger
*/
BI.IconTextTrigger = BI.inherit(BI.Trigger, {
_const: {
hgap: 4,
triggerWidth: 30
},
_defaultConfig: function () {
var conf = BI.IconTextTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-trigger",
height: 30
});
},
_init: function () {
BI.IconTextTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options, c = this._const;
this.text = BI.createWidget({
type: "bi.label",
textAlign: "left",
height: o.height,
text: o.text,
hgap: c.hgap
});
this.trigerButton = BI.createWidget({
type: "bi.trigger_icon_button",
cls: "bi-border-left",
width: c.triggerWidth
});
BI.createWidget({
element: this,
type: 'bi.htape',
items: [{
el: {
type: "bi.icon_change_button",
cls: "icon-combo-trigger-icon " + o.iconClass,
ref: function (_ref) {
self.icon = _ref;
},
disableSelected: true
},
width: 24
},
{
el: this.text
}, {
el: this.trigerButton,
width: c.triggerWidth
}
]
});
},
setValue: function (value) {
this.text.setValue(value);
this.text.setTitle(value);
},
setIcon: function (iconCls) {
this.icon.setIcon(iconCls);
},
setText: function (text) {
this.text.setText(text);
this.text.setTitle(text);
}
});
BI.shortcut("bi.icon_text_trigger", BI.IconTextTrigger);/**
* 文字trigger
*
* Created by GUY on 2015/9/15.

2
dist/bundle.min.css vendored

File diff suppressed because one or more lines are too long

68
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

75
dist/case.js vendored

@ -12545,6 +12545,81 @@ BI.IconTrigger = BI.inherit(BI.Trigger, {
}
});
BI.shortcut('bi.icon_trigger', BI.IconTrigger);/**
* 文字trigger
*
* Created by GUY on 2015/9/15.
* @class BI.IconTextTrigger
* @extends BI.Trigger
*/
BI.IconTextTrigger = BI.inherit(BI.Trigger, {
_const: {
hgap: 4,
triggerWidth: 30
},
_defaultConfig: function () {
var conf = BI.IconTextTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-trigger",
height: 30
});
},
_init: function () {
BI.IconTextTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options, c = this._const;
this.text = BI.createWidget({
type: "bi.label",
textAlign: "left",
height: o.height,
text: o.text,
hgap: c.hgap
});
this.trigerButton = BI.createWidget({
type: "bi.trigger_icon_button",
cls: "bi-border-left",
width: c.triggerWidth
});
BI.createWidget({
element: this,
type: 'bi.htape',
items: [{
el: {
type: "bi.icon_change_button",
cls: "icon-combo-trigger-icon " + o.iconClass,
ref: function (_ref) {
self.icon = _ref;
},
disableSelected: true
},
width: 24
},
{
el: this.text
}, {
el: this.trigerButton,
width: c.triggerWidth
}
]
});
},
setValue: function (value) {
this.text.setValue(value);
this.text.setTitle(value);
},
setIcon: function (iconCls) {
this.icon.setIcon(iconCls);
},
setText: function (text) {
this.text.setText(text);
this.text.setTitle(text);
}
});
BI.shortcut("bi.icon_text_trigger", BI.IconTextTrigger);/**
* 文字trigger
*
* Created by GUY on 2015/9/15.

69
dist/demo.js vendored

@ -8445,32 +8445,57 @@ Demo.Slider = BI.inherit(BI.Widget, {
},
_init: function () {
Demo.Slider.superclass._init.apply(this, arguments);
var self = this;
var singleSlider = BI.createWidget({
type: "bi.single_slider",
width: 300,
height: 50
});
singleSlider.setMinAndMax({
min: 10,
max: 100
});
singleSlider.populate();
var normalSingleSlider = BI.createWidget({
type: "bi.single_slider_normal",
height: 30,
width: 300
});
normalSingleSlider.setMinAndMax({
min: 0,
max: 100
});
normalSingleSlider.setValue(10);
normalSingleSlider.populate();
BI.createWidget({
type: "bi.vertical_adapt",
type: "bi.vtape",
element: this,
width: 100,
items: [{
type: "bi.htape",
items: [{
el: {
type: "bi.slider",
min: 16,
max: 50,
ref: function (_ref) {
self.slider = _ref;
}
}
}],
height: 30,
width: 100
}]
el: {
type: "bi.center_adapt",
items: [{
el: singleSlider
}]
},
height: 200
}, {
el: {
type: "bi.center_adapt",
items: [{
el: normalSingleSlider
}]
},
height: 200
}],
hgap: 20
});
this.slider.setValue("30");
this.slider.on(BI.SliderNormal.EVENT_CHANGE, function () {
console.log(this.getValue());
})
}
});
BI.shortcut("demo.slider", Demo.Slider);/**

267
dist/slider.js vendored

@ -1,17 +1,17 @@
/**
* Created by zcf on 2016/9/22.
*/
BI.Slider = BI.inherit(BI.Widget, {
BI.SliderIconButton = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.Slider.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-button-button"
return BI.extend(BI.SliderIconButton.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-slider-button"
});
},
_init: function () {
BI.extend(BI.Slider.superclass._init.apply(this, arguments));
BI.extend(BI.SliderIconButton.superclass._init.apply(this, arguments));
this.slider = BI.createWidget({
type: "bi.icon_button",
cls: "widget-button-icon button-button",
cls: "widget-slider-icon slider-button",
iconWidth: 14,
iconHeight: 14,
height: 14,
@ -30,7 +30,7 @@ BI.Slider = BI.inherit(BI.Widget, {
});
}
});
BI.shortcut("bi.single_slider_slider", BI.Slider);/**
BI.shortcut("bi.single_slider_button", BI.SliderIconButton);/**
* Created by zcf on 2016/9/22.
*/
BI.SingleSlider = BI.inherit(BI.Widget, {
@ -69,7 +69,7 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
this.track = this._createTrackWrapper();
this.slider = BI.createWidget({
type: "bi.single_slider_slider"
type: "bi.single_slider_button"
});
this.slider.element.draggable({
axis: "x",
@ -127,7 +127,7 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
cls: "slider-editor-button bi-border",
errorText: "",
height: c.HEIGHT,
width: c.EDITOR_WIDTH,
width: c.EDITOR_WIDTH - 2,
allowBlank: false,
validationChecker: function (v) {
return self._checkValidation(v);
@ -137,7 +137,9 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
}
});
this.label.on(BI.SignEditor.EVENT_CONFIRM, function () {
var percent = self._getPercentByValue(this.getValue());
var v = BI.parseFloat(this.getValue());
self.value = v;
var percent = self._getPercentByValue(v);
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setAllPosition(significantPercent);
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
@ -338,7 +340,7 @@ BI.SingleSliderNormal = BI.inherit(BI.Widget, {
var c = this._constant;
var track = this._createTrack();
this.slider = BI.createWidget({
type: "bi.single_slider_slider"
type: "bi.single_slider_button"
});
this.slider.element.draggable({
axis: "x",
@ -551,247 +553,4 @@ BI.SingleSliderNormal = BI.inherit(BI.Widget, {
}
});
BI.SingleSliderNormal.EVENT_DRAG = "EVENT_DRAG";
BI.shortcut("bi.single_slider_normal", BI.SingleSliderNormal);/**
* Created by Urthur on 2017/9/4.
*/
BI.SliderButton = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.SliderButton.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-slider-button"
});
},
_init: function () {
BI.extend(BI.SliderButton.superclass._init.apply(this, arguments));
var self = this;
var sliderButton = BI.createWidget({
type: "bi.icon_button",
cls: "column-next-page-h-font",
iconWidth: 16,
iconHeight: 16,
height: 16,
width: 16
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: sliderButton,
left: -8
}, {
el: {
type: "bi.label",
ref: function (_ref) {
self.label = _ref;
}
},
left: -8,
top: -10
}]
});
},
setValue: function (v) {
this.label.setText(v);
}
});
BI.shortcut("bi.slider_button", BI.SliderButton);/**
* Created by Urthur on 2017/9/4.
*/
BI.SliderNormal = BI.inherit(BI.Widget, {
_constant: {
HEIGHT: 28,
SLIDER_WIDTH_HALF: 10,
SLIDER_WIDTH: 25,
SLIDER_HEIGHT: 30,
TRACK_HEIGHT: 24
},
_defaultConfig: function () {
return BI.extend(BI.SliderNormal.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-slider",
min: 10,
max: 50
})
},
_init: function () {
BI.SliderNormal.superclass._init.apply(this, arguments);
var self = this;
var c = this._constant, o = this.options;
this.enable = false;
this.value = o.min;
this.min = o.min;
this.max = o.max;
this.rightTrack = BI.createWidget({
type: "bi.layout",
cls: "bi-slider-track",
height: 5
});
this.track = this._createTrack();
this.slider = BI.createWidget({
type: "bi.slider_button"
});
this.slider.setValue(this.getValue());
this.slider.element.draggable({
axis: "x",
containment: this.rightTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getRightTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
var v = self._getValueByPercent(significantPercent);
self.value = BI.parseInt(v) + 1;
self.slider.setValue(self.getValue());
self.fireEvent(BI.SliderNormal.EVENT_CHANGE);
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getRightTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
self.fireEvent(BI.SliderNormal.EVENT_CHANGE);
}
});
var sliderVertical = BI.createWidget({
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [{
el: this.slider,
top: 10
}]
}],
hgap: c.SLIDER_WIDTH_HALF,
height: c.SLIDER_HEIGHT
});
sliderVertical.element.click(function (e) {
if (self.enable) {
var offset = e.clientX - self.element.offset().left - c.SLIDER_WIDTH_HALF;
var trackLength = self.track.element[0].scrollWidth;
var percent = 0;
if (offset < 0) {
percent = 0
}
if (offset > 0 && offset < (trackLength - c.SLIDER_WIDTH)) {
percent = offset * 100 / self._getRightTrackLength();
}
if (offset > (trackLength - c.SLIDER_WIDTH)) {
percent = 100
}
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
self.value = BI.parseInt(v);
self.slider.setValue(self.getValue());
self.fireEvent(BI.SliderNormal.EVENT_CHANGE);
}
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: {
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [{
el: this.track,
width: "100%",
height: c.TRACK_HEIGHT
}]
}],
height: c.TRACK_HEIGHT
},
top: 33,
left: 0,
width: "100%"
}, {
el: sliderVertical,
top: 15,
left: 0,
width: "100%"
}]
});
},
_createTrack: function () {
return BI.createWidget({
type: "bi.absolute",
items: [{
el: {
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [{
el: this.rightTrack,
top: 0,
left: 0,
width: "100%"
}]
}],
hgap: 8,
height: 5
},
top: 5,
left: 0,
width: "100%"
}]
})
},
_checkValidation: function (v) {
return !(BI.isNull(v) || v < this.min || v > this.max)
},
_setSliderPosition: function (percent) {
this.slider.element.css({"left": percent + "%"});
},
_getRightTrackLength: function () {
return this.rightTrack.element[0].scrollWidth
},
_getValueByPercent: function (percent) {
var thousandth = BI.parseInt(percent * 10);
return (((this.max - this.min) * thousandth) / 1000 + this.min);
},
_getPercentByValue: function (v) {
return (v - this.min) * 100 / (this.max - this.min);
},
getValue: function () {
return this.value;
},
setValue: function (v) {
var value = BI.parseFloat(v);
if ((!isNaN(value))) {
if (this._checkValidation(value)) {
this.value = value;
}
if (value > this.max) {
this.value = this.max;
}
if (value < this.min) {
this.value = this.min;
}
}
if (!isNaN(this.min) && !isNaN(this.max)) {
this.enable = true;
if (BI.isNumeric(this.value) || BI.isNotEmptyString(this.value)) {
this.slider.setValue(BI.parseInt(this.value));
this._setSliderPosition(this._getPercentByValue(this.value));
} else {
this.slider.setValue(this.max);
this._setSliderPosition(100);
}
}
}
});
BI.SliderNormal.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.slider", BI.SliderNormal);
BI.shortcut("bi.single_slider_normal", BI.SingleSliderNormal);

2
dist/widget.css vendored

@ -433,7 +433,7 @@
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
.bi-single-slider-slider .slider-button {
cursor: url('${remoteServletURL}?op=resource&resource=/com/fr/bi/web/images/1x/cursor/cursor_drag_slider.cur'), auto;
cursor: url('images/1x/cursor/cursor_drag_slider.cur'), auto;
-webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);

12
src/addons/slider/slider/singleslider/button/iconbutton.slider.js → src/addons/slider/singleslider/button/iconbutton.slider.js

@ -1,17 +1,17 @@
/**
* Created by zcf on 2016/9/22.
*/
BI.Slider = BI.inherit(BI.Widget, {
BI.SliderIconButton = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.Slider.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-button-button"
return BI.extend(BI.SliderIconButton.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-slider-button"
});
},
_init: function () {
BI.extend(BI.Slider.superclass._init.apply(this, arguments));
BI.extend(BI.SliderIconButton.superclass._init.apply(this, arguments));
this.slider = BI.createWidget({
type: "bi.icon_button",
cls: "widget-button-icon button-button",
cls: "widget-slider-icon slider-button",
iconWidth: 14,
iconHeight: 14,
height: 14,
@ -30,4 +30,4 @@ BI.Slider = BI.inherit(BI.Widget, {
});
}
});
BI.shortcut("bi.single_slider_slider", BI.Slider);
BI.shortcut("bi.single_slider_button", BI.SliderIconButton);

8
src/addons/slider/slider/singleslider/singleslider.js → src/addons/slider/singleslider/singleslider.js

@ -37,7 +37,7 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
this.track = this._createTrackWrapper();
this.slider = BI.createWidget({
type: "bi.single_slider_slider"
type: "bi.single_slider_button"
});
this.slider.element.draggable({
axis: "x",
@ -95,7 +95,7 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
cls: "slider-editor-button bi-border",
errorText: "",
height: c.HEIGHT,
width: c.EDITOR_WIDTH,
width: c.EDITOR_WIDTH - 2,
allowBlank: false,
validationChecker: function (v) {
return self._checkValidation(v);
@ -105,7 +105,9 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
}
});
this.label.on(BI.SignEditor.EVENT_CONFIRM, function () {
var percent = self._getPercentByValue(this.getValue());
var v = BI.parseFloat(this.getValue());
self.value = v;
var percent = self._getPercentByValue(v);
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setAllPosition(significantPercent);
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);

2
src/addons/slider/slider/singleslider/singleslider.normal.js → src/addons/slider/singleslider/singleslider.normal.js

@ -28,7 +28,7 @@ BI.SingleSliderNormal = BI.inherit(BI.Widget, {
var c = this._constant;
var track = this._createTrack();
this.slider = BI.createWidget({
type: "bi.single_slider_slider"
type: "bi.single_slider_button"
});
this.slider.element.draggable({
axis: "x",

44
src/addons/slider/slider/slider.button.js

@ -1,44 +0,0 @@
/**
* Created by Urthur on 2017/9/4.
*/
BI.SliderButton = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.SliderButton.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-slider-button"
});
},
_init: function () {
BI.extend(BI.SliderButton.superclass._init.apply(this, arguments));
var self = this;
var sliderButton = BI.createWidget({
type: "bi.icon_button",
cls: "column-next-page-h-font",
iconWidth: 16,
iconHeight: 16,
height: 16,
width: 16
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: sliderButton,
left: -8
}, {
el: {
type: "bi.label",
ref: function (_ref) {
self.label = _ref;
}
},
left: -8,
top: -10
}]
});
},
setValue: function (v) {
this.label.setText(v);
}
});
BI.shortcut("bi.slider_button", BI.SliderButton);

201
src/addons/slider/slider/slider.js

@ -1,201 +0,0 @@
/**
* Created by Urthur on 2017/9/4.
*/
BI.SliderNormal = BI.inherit(BI.Widget, {
_constant: {
HEIGHT: 28,
SLIDER_WIDTH_HALF: 10,
SLIDER_WIDTH: 25,
SLIDER_HEIGHT: 30,
TRACK_HEIGHT: 24
},
_defaultConfig: function () {
return BI.extend(BI.SliderNormal.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-slider",
min: 10,
max: 50
})
},
_init: function () {
BI.SliderNormal.superclass._init.apply(this, arguments);
var self = this;
var c = this._constant, o = this.options;
this.enable = false;
this.value = o.min;
this.min = o.min;
this.max = o.max;
this.rightTrack = BI.createWidget({
type: "bi.layout",
cls: "bi-slider-track",
height: 5
});
this.track = this._createTrack();
this.slider = BI.createWidget({
type: "bi.slider_button"
});
this.slider.setValue(this.getValue());
this.slider.element.draggable({
axis: "x",
containment: this.rightTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getRightTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
var v = self._getValueByPercent(significantPercent);
self.value = BI.parseInt(v) + 1;
self.slider.setValue(self.getValue());
self.fireEvent(BI.SliderNormal.EVENT_CHANGE);
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getRightTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
self.fireEvent(BI.SliderNormal.EVENT_CHANGE);
}
});
var sliderVertical = BI.createWidget({
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [{
el: this.slider,
top: 10
}]
}],
hgap: c.SLIDER_WIDTH_HALF,
height: c.SLIDER_HEIGHT
});
sliderVertical.element.click(function (e) {
if (self.enable) {
var offset = e.clientX - self.element.offset().left - c.SLIDER_WIDTH_HALF;
var trackLength = self.track.element[0].scrollWidth;
var percent = 0;
if (offset < 0) {
percent = 0
}
if (offset > 0 && offset < (trackLength - c.SLIDER_WIDTH)) {
percent = offset * 100 / self._getRightTrackLength();
}
if (offset > (trackLength - c.SLIDER_WIDTH)) {
percent = 100
}
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
self.value = BI.parseInt(v);
self.slider.setValue(self.getValue());
self.fireEvent(BI.SliderNormal.EVENT_CHANGE);
}
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: {
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [{
el: this.track,
width: "100%",
height: c.TRACK_HEIGHT
}]
}],
height: c.TRACK_HEIGHT
},
top: 33,
left: 0,
width: "100%"
}, {
el: sliderVertical,
top: 15,
left: 0,
width: "100%"
}]
});
},
_createTrack: function () {
return BI.createWidget({
type: "bi.absolute",
items: [{
el: {
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [{
el: this.rightTrack,
top: 0,
left: 0,
width: "100%"
}]
}],
hgap: 8,
height: 5
},
top: 5,
left: 0,
width: "100%"
}]
})
},
_checkValidation: function (v) {
return !(BI.isNull(v) || v < this.min || v > this.max)
},
_setSliderPosition: function (percent) {
this.slider.element.css({"left": percent + "%"});
},
_getRightTrackLength: function () {
return this.rightTrack.element[0].scrollWidth
},
_getValueByPercent: function (percent) {
var thousandth = BI.parseInt(percent * 10);
return (((this.max - this.min) * thousandth) / 1000 + this.min);
},
_getPercentByValue: function (v) {
return (v - this.min) * 100 / (this.max - this.min);
},
getValue: function () {
return this.value;
},
setValue: function (v) {
var value = BI.parseFloat(v);
if ((!isNaN(value))) {
if (this._checkValidation(value)) {
this.value = value;
}
if (value > this.max) {
this.value = this.max;
}
if (value < this.min) {
this.value = this.min;
}
}
if (!isNaN(this.min) && !isNaN(this.max)) {
this.enable = true;
if (BI.isNumeric(this.value) || BI.isNotEmptyString(this.value)) {
this.slider.setValue(BI.parseInt(this.value));
this._setSliderPosition(this._getPercentByValue(this.value));
} else {
this.slider.setValue(this.max);
this._setSliderPosition(100);
}
}
}
});
BI.SliderNormal.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.slider", BI.SliderNormal);

30
src/base/combination/combo.js

@ -126,6 +126,9 @@ BI.Combo = BI.inherit(BI.Widget, {
var debounce = BI.debounce(function (e) {
if (self.combo.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
if (!o.toggle && self.isViewVisible()) {
return;
}
o.toggle ? self._toggle() : self._popupView();
if (self.isViewVisible()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
@ -142,6 +145,33 @@ BI.Combo = BI.inherit(BI.Widget, {
st(e);
});
break;
case "click-hover":
var debounce = BI.debounce(function (e) {
if (self.combo.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
if (self.isViewVisible()) {
return;
}
self._popupView();
if (self.isViewVisible()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
self.fireEvent(BI.Combo.EVENT_EXPAND);
}
}
}
}, BI.EVENT_RESPONSE_TIME, true);
self.element.off(ev + "." + self.getName()).on(ev + "." + self.getName(), function (e) {
debounce(e);
st(e);
});
self.element.on("mouseleave." + self.getName(), function (e) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid() && o.toggle === true) {
self._hideView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo);
self.fireEvent(BI.Combo.EVENT_COLLAPSE);
}
});
break;
}
});
},

76
src/case/trigger/trigger.icon.text.js

@ -0,0 +1,76 @@
/**
* 文字trigger
*
* Created by GUY on 2015/9/15.
* @class BI.IconTextTrigger
* @extends BI.Trigger
*/
BI.IconTextTrigger = BI.inherit(BI.Trigger, {
_const: {
hgap: 4,
triggerWidth: 30
},
_defaultConfig: function () {
var conf = BI.IconTextTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-trigger",
height: 30
});
},
_init: function () {
BI.IconTextTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options, c = this._const;
this.text = BI.createWidget({
type: "bi.label",
textAlign: "left",
height: o.height,
text: o.text,
hgap: c.hgap
});
this.trigerButton = BI.createWidget({
type: "bi.trigger_icon_button",
cls: "bi-border-left",
width: c.triggerWidth
});
BI.createWidget({
element: this,
type: 'bi.htape',
items: [{
el: {
type: "bi.icon_change_button",
cls: "icon-combo-trigger-icon " + o.iconClass,
ref: function (_ref) {
self.icon = _ref;
},
disableSelected: true
},
width: 24
},
{
el: this.text
}, {
el: this.trigerButton,
width: c.triggerWidth
}
]
});
},
setValue: function (value) {
this.text.setValue(value);
this.text.setTitle(value);
},
setIcon: function (iconCls) {
this.icon.setIcon(iconCls);
},
setText: function (text) {
this.text.setText(text);
this.text.setTitle(text);
}
});
BI.shortcut("bi.icon_text_trigger", BI.IconTextTrigger);
Loading…
Cancel
Save