Browse Source

Merge pull request #62 in FUI/fineui from ~GUY/fineui:master to master

* commit '3d325db44eced54e56a62ab377974685dc799fc8':
  整理
  去掉滑块
  add
  BI-7322 update
  BI-7322 带时刻的日期选择控件
es6
guy 7 years ago
parent
commit
09efe0fb06
  1. 13
      bi/case.js
  2. 1057
      bi/widget.js
  3. 43
      demo/css/main.css
  4. 18
      demo/js/config/widget.js
  5. 70
      demo/js/widget/intervalslider/demo.interval_slider.js
  6. 125
      demo/js/widget/multidatetime/multi.datetime.combo.js
  7. 38
      demo/js/widget/multidatetime/multi.datetime.js
  8. 177
      demo/js/widget/multidatetime/multi.datetime.popup.js
  9. 106
      demo/js/widget/multidatetime/multi.datetime.select.js
  10. 63
      demo/js/widget/multidatetime/multi.datetime.trigger.js
  11. 48
      demo/js/widget/singleslider/demo.single_slider.js
  12. 56
      demo/less/main.less
  13. 13
      docs/case.js
  14. 28681
      docs/core.js
  15. 43
      docs/demo.css
  16. 635
      docs/demo.js
  17. 1057
      docs/widget.js
  18. 13
      src/case/tree/tree.display.js
  19. 6
      src/less/widget/singleslider/singleslider.less
  20. 4
      src/less/widget/singleslider/slider/widget.slider.less
  21. 15
      src/less/widget/singleslider/track/widget.track.less
  22. 495
      src/widget/intervalslider/intervalslider.js
  23. 222
      src/widget/intervalslider/model.accuratecalculation.js
  24. 9
      src/widget/singleslider/jquery-ui/jquery-ui.min.js
  25. 299
      src/widget/singleslider/singleslider.js
  26. 33
      src/widget/singleslider/slider/widget.slider.js

13
bi/case.js

@ -12033,6 +12033,19 @@ BI.DisplayTree = BI.inherit(BI.TreeView, {
return setting; return setting;
}, },
_dealWidthNodes: function (nodes) {
nodes = BI.DisplayTree.superclass._dealWidthNodes.apply(this, arguments);
var self = this, o = this.options;
BI.each(nodes, function (i, node) {
if (node.count > 0) {
node.text = node.value + "(" + BI.i18nText("BI-Basic_Altogether") + node.count + BI.i18nText("BI-Basic_Count") + ")";
} else {
node.text = node.value;
}
});
return nodes;
},
initTree: function (nodes, setting) { initTree: function (nodes, setting) {
var setting = setting || this._configSetting(); var setting = setting || this._configSetting();
this.nodes = $.fn.zTree.init(this.tree.element, setting, nodes); this.nodes = $.fn.zTree.init(this.tree.element, setting, nodes);

1057
bi/widget.js

File diff suppressed because one or more lines are too long

43
demo/css/main.css

@ -48,46 +48,3 @@ body {
.demo-editor { .demo-editor {
border: 1px solid #cccccc; border: 1px solid #cccccc;
} }
.bi-slider-track .background-track {
background-color: rgba(153, 153, 153, 0);
_filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#33999999, 99, endColorstr=#33999999, 99);
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
}
.bi-slider-track .gray-track {
background: #cccccc;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
.bi-slider-track .blue-track {
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
.widget-slider-icon .x-icon {
display: block;
background: url('icon/slider.png') no-repeat;
_filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${remoteServletURL}?op=resource&resource=/com/fr/bi/web/images/icon/slider-normal.png');
_background: none;
background-size: 100% 100%;
}
.widget-slider-icon:hover .x-icon {
display: block;
background: url('icon/双向箭头.png') no-repeat;
_filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${remoteServletURL}?op=resource&resource=/com/fr/bi/web/images/icon/slider-active.png');
_background: none;
background-size: 100% 100%;
}
.widget-slider-icon::focus .x-icon {
display: block;
background: url('icon/双向箭头.png') no-repeat;
_filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${remoteServletURL}?op=resource&resource=/com/fr/bi/web/images/icon/slider-active.png');
_background: none;
background-size: 100% 100%;
}
.widget-slider-icon.native .x-icon,
.widget-slider-icon.disabled .x-icon {
display: block;
}

18
demo/js/config/widget.js

@ -249,21 +249,5 @@ Demo.WIDGET_CONFIG = [{
pId: 418, pId: 418,
text: "bi.dialog", text: "bi.dialog",
value: "demo.dialog" value: "demo.dialog"
}, { }
pId: 4,
id: 419,
text: "单值滑块"
}, {
pId: 419,
text: "bi.single_slider",
value: "demo.single_slider"
},{
pId: 4,
id: 420,
text: "区间滑块"
}, {
pId: 420,
text: "bi.interval_slider",
value: "demo.interval_slider"
},
]; ];

70
demo/js/widget/intervalslider/demo.interval_slider.js

@ -1,70 +0,0 @@
/**
* Created by Dailer on 2017/7/14.
*/
Demo.IntervalSlider = BI.inherit(BI.Widget, {
props: {
baseCls: ""
},
render: function () {
var self = this;
var min = BI.createWidget({
type: "bi.text_editor",
watermark: "min",
width: 100
});
var max = BI.createWidget({
type: "bi.text_editor",
watermark: "max",
width: 100
})
return {
type: "bi.horizontal_auto",
items: [{
type: "bi.interval_slider",
ref: function (_ref) {
self.slider = _ref;
},
width: 300,
height: 90
}, {
type: "bi.center_adapt",
width: 300,
items: [{
type: "bi.text",
text: "min"
}, min, {
type: "bi.text",
text: "max"
}, max]
}, {
type: "bi.button",
text: "populate",
handler: function () {
self.slider.setMinAndMax({
min: min.getValue() || 0,
max: max.getValue() || 100
});
self.slider.populate();
},
width: 300
}, {
type: "bi.button",
text: "setValue",
handler: function () {
//既然 setVlaue后要重新 populate 才能生效,为何不直接在 setValue方法的结尾调用 populate 方法呢?
self.slider.setValue({
min: 20,
max: 80
});
self.slider.populate();
},
width: 300
}],
vgap: 20
}
}
})
BI.shortcut("demo.interval_slider", Demo.IntervalSlider);

125
demo/js/widget/multidatetime/multi.datetime.combo.js

@ -0,0 +1,125 @@
/**
* Created by Urthur on 2017/7/14.
*/
BI.MultiDateTimeCombo = BI.inherit(BI.Single, {
constants: {
popupHeight: 290,
popupWidth: 270,
comboAdjustHeight: 1,
border: 1,
DATE_MIN_VALUE: "1900-01-01",
DATE_MAX_VALUE: "2099-12-31"
},
_defaultConfig: function () {
return BI.extend(BI.MultiDateTimeCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-date-time-combo bi-border',
height: 24
});
},
_init: function () {
BI.MultiDateTimeCombo.superclass._init.apply(this, arguments);
var self = this, opts = this.options;
var date = new Date();
this.storeValue = {
value: {
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate(),
hour: date.getHours(),
minute: date.getMinutes(),
second: date.getSeconds()
}
};
this.trigger = BI.createWidget({
type: 'bi.date_time_trigger',
min: this.constants.DATE_MIN_VALUE,
max: this.constants.DATE_MAX_VALUE
});
this.popup = BI.createWidget({
type: "bi.multi_date_time_popup",
min: this.constants.DATE_MIN_VALUE,
max: this.constants.DATE_MAX_VALUE
});
self.setValue(this.storeValue);
this.popup.on(BI.MultiDateTimePopup.BUTTON_CANCEL_EVENT_CHANGE, function () {
self.combo.hideView();
self.fireEvent(BI.MultiDateTimeCombo.EVENT_CANCEL);
});
this.popup.on(BI.MultiDateTimePopup.BUTTON_OK_EVENT_CHANGE, function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.MultiDateTimeCombo.EVENT_CONFIRM);
});
this.popup.on(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE, function () {
self.setValue(self.popup.getValue());
});
this.combo = BI.createWidget({
type: 'bi.combo',
toggle: false,
isNeedAdjustHeight: false,
isNeedAdjustWidth: false,
el: this.trigger,
adjustLength: this.constants.comboAdjustHeight,
popup: {
el: this.popup,
maxHeight: this.constants.popupHeight,
width: this.constants.popupWidth,
stopPropagation: false
}
});
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.popup.setValue(self.storeValue);
self.fireEvent(BI.MultiDateTimeCombo.EVENT_BEFORE_POPUPVIEW);
});
var triggerBtn = BI.createWidget({
type: "bi.trigger_icon_button",
cls: "bi-trigger-date-button chart-date-normal-font bi-border-right",
width: 30,
height: 24
});
triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
});
BI.createWidget({
type: "bi.htape",
element: this,
items: [{
type: "bi.absolute",
items: [{
el: this.combo,
top: 0,
left: 0,
right: 0,
bottom: 0
}, {
el: triggerBtn,
top: 0,
left: 0
}]
}]
})
},
setValue: function (v) {
this.storeValue = v;
this.popup.setValue(v);
this.trigger.setValue(v);
},
getValue: function () {
return this.storeValue;
}
});
BI.MultiDateTimeCombo.EVENT_CANCEL = "EVENT_CANCEL";
BI.MultiDateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.MultiDateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiDateTimeCombo.EVENT_BEFORE_POPUPVIEW = "BI.MultiDateTimeCombo.EVENT_BEFORE_POPUPVIEW";
BI.shortcut('bi.multi_date_time_combo', BI.MultiDateTimeCombo);

38
demo/js/widget/multidatetime/multi.datetime.js

@ -0,0 +1,38 @@
/**
* Created by Urthur on 2017/7/14.
*/
BI.CustomMultiDateTimeCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.CustomMultiDateTimeCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-custom-multi-date-time-combo"
})
},
_init: function () {
BI.CustomMultiDateTimeCombo.superclass._init.apply(this, arguments);
var self = this;
this.multiDateTime = BI.createWidget({
type: "bi.multi_date_time_combo",
element: this
});
this.multiDateTime.on(BI.MultiDateTimeCombo.EVENT_CANCEL, function () {
self.fireEvent(BI.CustomMultiDateTimeCombo.EVENT_CANCEL);
});
this.multiDateTime.on(BI.MultiDateTimeCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.CustomMultiDateTimeCombo.EVENT_CONFIRM);
});
},
getValue: function () {
return this.multiDateTime.getValue();
},
setValue: function (v) {
this.multiDateTime.setValue(v);
}
});
BI.CustomMultiDateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.CustomMultiDateTimeCombo.EVENT_CANCEL = "EVENT_CANCEL";
BI.CustomMultiDateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.custom_multi_date_time_combo", BI.CustomMultiDateTimeCombo);

177
demo/js/widget/multidatetime/multi.datetime.popup.js

@ -0,0 +1,177 @@
/**
* Created by Urthur on 2017/7/14.
*/
BI.MultiDateTimePopup = BI.inherit(BI.Widget, {
constants: {
tabHeight: 30,
tabWidth: 42,
titleHeight: 27,
itemHeight: 30,
triggerHeight: 24,
buttonWidth: 90,
buttonHeight: 25,
popupHeight: 290,
popupWidth: 270,
comboAdjustHeight: 1,
lgap: 2,
border: 1
},
_defaultConfig: function () {
return BI.extend(BI.MultiDateTimePopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-date-time-popup',
width: 268,
height: 290
});
},
_init: function () {
BI.MultiDateTimePopup.superclass._init.apply(this, arguments);
var self = this, opts = this.options;
this.cancelButton = BI.createWidget({
type: 'bi.text_button',
forceCenter: true,
cls: 'bi-multidate-popup-button bi-border-top bi-border-right',
shadow: true,
text: BI.i18nText("BI-Basic_Cancel")
});
this.cancelButton.on(BI.TextButton.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiDateTimePopup.BUTTON_CANCEL_EVENT_CHANGE);
});
this.okButton = BI.createWidget({
type: "bi.text_button",
forceCenter: true,
cls: 'bi-multidate-popup-button bi-border-top',
shadow: true,
text: BI.i18nText("BI-Basic_OK")
});
this.okButton.on(BI.TextButton.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiDateTimePopup.BUTTON_OK_EVENT_CHANGE);
});
this.dateCombo = BI.createWidget({
type: "bi.date_calendar_popup",
min: self.options.min,
max: self.options.max
});
self.dateCombo.on(BI.DateCalendarPopup.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE);
});
this.dateSelect = BI.createWidget({
type: "bi.horizontal",
cls: "bi-border-top",
items: [{
type: "bi.label",
text: BI.i18nText("BI-Basic_Time"),
width: 45
},{
type: "bi.multi_date_time_select",
max: 23,
min: 0,
width: 60,
height: 30,
ref: function (_ref) {
self.hour = _ref;
self.hour.on(BI.MultiDateTimeSelect.EVENT_CONFIRM, function () {
self.fireEvent(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE);
});
}
},{
type: "bi.label",
text: ":",
width: 15
},{
type: "bi.multi_date_time_select",
max: 59,
min: 0,
width: 60,
height: 30,
ref: function (_ref) {
self.minute = _ref;
self.minute.on(BI.MultiDateTimeSelect.EVENT_CONFIRM, function () {
self.fireEvent(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE);
});
}
},{
type: "bi.label",
text: ":",
width: 15
},{
type: "bi.multi_date_time_select",
max: 59,
min: 0,
width: 60,
height: 30,
ref: function (_ref) {
self.second = _ref;
self.second.on(BI.MultiDateTimeSelect.EVENT_CONFIRM, function () {
self.fireEvent(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE);
});
}
}]
});
this.dateButton = BI.createWidget({
type: "bi.grid",
items: [[this.cancelButton, this.okButton]]
});
BI.createWidget({
element: this,
type: "bi.vtape",
items: [{
el: this.dateCombo
}, {
el: this.dateSelect,
height: 50
},{
el: this.dateButton,
height: 30
}]
});
},
setValue: function (v) {
var value, date;
if (BI.isNotNull(v)) {
value = v.value;
if(BI.isNull(value)){
date = new Date();
this.dateCombo.setValue({
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate()
});
this.hour.setValue(date.getHours());
this.minute.setValue(date.getMinutes());
this.second.setValue(date.getSeconds());
} else {
this.dateCombo.setValue({
year: value.year,
month: value.month,
day: value.day
});
this.hour.setValue(value.hour);
this.minute.setValue(value.minute);
this.second.setValue(value.second);
}
}
},
getValue: function () {
return {
value: {
year: this.dateCombo.getValue().year,
month: this.dateCombo.getValue().month,
day: this.dateCombo.getValue().day,
hour: this.hour.getValue(),
minute: this.minute.getValue(),
second: this.second.getValue()
}
}
}
});
BI.MultiDateTimePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
BI.MultiDateTimePopup.BUTTON_CANCEL_EVENT_CHANGE = "BUTTON_CANCEL_EVENT_CHANGE";
BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE";
BI.shortcut('bi.multi_date_time_popup', BI.MultiDateTimePopup);

106
demo/js/widget/multidatetime/multi.datetime.select.js

@ -0,0 +1,106 @@
/**
* Created by Urthur on 2017/7/14.
*/
BI.MultiDateTimeSelect = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.MultiDateTimeSelect.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multi-date-time-select bi-border",
max: 23,
min: 0
})
},
_init: function () {
BI.MultiDateTimeSelect.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget({
type: "bi.sign_editor",
value: this._alertInEditorValue(o.min),
errorText: BI.i18nText("BI-Please_Input_Natural_Number"),
validationChecker: function(v){
return BI.isNaturalNumber(v);
}
});
this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){
self._finetuning(0);
self.fireEvent(BI.MultiDateTimeSelect.EVENT_CONFIRM);
});
this.topBtn = BI.createWidget({
type: "bi.icon_button",
cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom"
});
this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(1);
self.fireEvent(BI.MultiDateTimeSelect.EVENT_CONFIRM);
});
this.bottomBtn = BI.createWidget({
type: "bi.icon_button",
cls: "column-next-page-h-font bottom-button bi-border-left"
});
this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(-1);
self.fireEvent(BI.MultiDateTimeSelect.EVENT_CONFIRM);
});
this._finetuning(0);
BI.createWidget({
type: "bi.htape",
element: this,
items: [this.editor, {
el: {
type: "bi.grid",
columns: 1,
rows: 2,
items: [{
column: 0,
row: 0,
el: this.topBtn
}, {
column: 0,
row: 1,
el: this.bottomBtn
}]
},
width: 30
}]
});
},
_alertOutEditorValue: function(v){
if (v > this.options.max){
v = this.options.min;
}
if (v < this.options.min){
v = this.options.max
}
return BI.parseInt(v);
},
_alertInEditorValue: function(v){
if (v > this.options.max){
v = this.options.min;
}
if (v < this.options.min){
v = this.options.max;
}
v = v < 10 ? "0" + v : v;
return v;
},
_finetuning: function(add){
var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue()));
this.editor.setValue(this._alertInEditorValue(v + add));
},
getValue: function () {
var v = this.editor.getValue();
return this._alertOutEditorValue(v);
},
setValue: function (v) {
this.editor.setValue(this._alertInEditorValue(v));
this._finetuning(0);
}
});
BI.MultiDateTimeSelect.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.multi_date_time_select", BI.MultiDateTimeSelect);

63
demo/js/widget/multidatetime/multi.datetime.trigger.js

@ -0,0 +1,63 @@
/**
* Created by Urthur on 2017/7/14.
*/
BI.DateTimeTrigger = BI.inherit(BI.Trigger, {
_const: {
hgap: 4,
vgap: 2,
triggerWidth: 30
},
_defaultConfig: function () {
return BI.extend(BI.DateTimeTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-date-time-trigger",
min: '1900-01-01', //最小日期
max: '2099-12-31', //最大日期
height: 25
});
},
_init: function () {
BI.DateTimeTrigger.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,
hgap: c.hgap,
vgap: c.vgap,
disabled: true
});
BI.createWidget({
type: "bi.htape",
element: this,
items: [{
el: BI.createWidget(),
width: 30
}, {
el: this.editor
}]
})
},
_printTime: function (v) {
return v < 10 ? "0" + v : v;
},
setValue: function (v) {
var self = this;
if (BI.isNotNull(v)) {
var value = v.value, dateStr;
if(BI.isNull(value)){
value = new Date();
dateStr = value.getFullYear() + "-" + self._printTime(value.getMonth() + 1) + "-" + self._printTime(value.getDate())
+ " " + self._printTime(value.getHours()) + ":" + self._printTime(value.getMinutes()) + ":" + self._printTime(value.getSeconds());
} else {
dateStr = value.year + "-" + self._printTime(value.month + 1) + "-" + self._printTime(value.day)
+ " " + self._printTime(value.hour) + ":" + self._printTime(value.minute) + ":" + self._printTime(value.second);
}
this.editor.setValue(dateStr);
}
}
});
BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger);

48
demo/js/widget/singleslider/demo.single_slider.js

@ -1,48 +0,0 @@
/**
* Created by Dailer on 2017/7/14.
*/
Demo.SingleSlider = BI.inherit(BI.Widget, {
props: {
baseCls: ""
},
render: function () {
var self = this;
return {
type: "bi.horizontal_auto",
items: [{
type: "bi.single_slider",
ref: function (_ref) {
self.slider = _ref;
},
width: 300,
height: 50
}, {
type: "bi.button",
text: "populate",
handler: function () {
self.slider.setMinAndMax({
min: 1,
max: 100
});
self.slider.populate();
},
width: 300
}, {
type: "bi.button",
text: "setValue",
handler: function () {
//既然 setVlaue后要重新 populate 才能生效,为何不直接在 setValue方法的结尾调用 populate 方法呢?
self.slider.setValue(50);
self.slider.populate();
},
width: 300
}],
vgap: 20
}
}
})
BI.shortcut("demo.single_slider", Demo.SingleSlider);

56
demo/less/main.less

@ -64,59 +64,3 @@ body {
.demo-editor { .demo-editor {
border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(204, 204, 204);
} }
.bi-slider-track {
.background-track {
background-color: rgba(153, 153, 153, 0);
_filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#33999999, endColorstr=#33999999);
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
}
.gray-track {
background: #cccccc;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
.blue-track {
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
}
.widget-slider-icon {
.x-icon {
display: block;
background: url('./icon/slider.png') no-repeat;
_filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${remoteServletURL}?op=resource&resource=/com/fr/bi/web/images/icon/slider-normal.png');
_background: none;
background-size: 100% 100%;
}
&:hover {
.x-icon {
display: block;
background: url('./icon/双向箭头.png') no-repeat;
_filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${remoteServletURL}?op=resource&resource=/com/fr/bi/web/images/icon/slider-active.png');
_background: none;
background-size: 100% 100%;
}
}
&::focus {
.x-icon {
display: block;
background: url('./icon/双向箭头.png') no-repeat;
_filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${remoteServletURL}?op=resource&resource=/com/fr/bi/web/images/icon/slider-active.png');
_background: none;
background-size: 100% 100%;
}
}
}
.widget-slider-icon.native,
.widget-slider-icon.disabled {
.x-icon {
display: block;
}
}

13
docs/case.js

@ -12033,6 +12033,19 @@ BI.DisplayTree = BI.inherit(BI.TreeView, {
return setting; return setting;
}, },
_dealWidthNodes: function (nodes) {
nodes = BI.DisplayTree.superclass._dealWidthNodes.apply(this, arguments);
var self = this, o = this.options;
BI.each(nodes, function (i, node) {
if (node.count > 0) {
node.text = node.value + "(" + BI.i18nText("BI-Basic_Altogether") + node.count + BI.i18nText("BI-Basic_Count") + ")";
} else {
node.text = node.value;
}
});
return nodes;
},
initTree: function (nodes, setting) { initTree: function (nodes, setting) {
var setting = setting || this._configSetting(); var setting = setting || this._configSetting();
this.nodes = $.fn.zTree.init(this.tree.element, setting, nodes); this.nodes = $.fn.zTree.init(this.tree.element, setting, nodes);

28681
docs/core.js

File diff suppressed because it is too large Load Diff

43
docs/demo.css

@ -51,49 +51,6 @@ body {
.demo-editor { .demo-editor {
border: 1px solid #cccccc; border: 1px solid #cccccc;
} }
.bi-slider-track .background-track {
background-color: rgba(153, 153, 153, 0);
_filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#33999999, 99, endColorstr=#33999999, 99);
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
}
.bi-slider-track .gray-track {
background: #cccccc;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
.bi-slider-track .blue-track {
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
.widget-slider-icon .x-icon {
display: block;
background: url('icon/slider.png') no-repeat;
_filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${remoteServletURL}?op=resource&resource=/com/fr/bi/web/images/icon/slider-normal.png');
_background: none;
background-size: 100% 100%;
}
.widget-slider-icon:hover .x-icon {
display: block;
background: url('icon/双向箭头.png') no-repeat;
_filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${remoteServletURL}?op=resource&resource=/com/fr/bi/web/images/icon/slider-active.png');
_background: none;
background-size: 100% 100%;
}
.widget-slider-icon::focus .x-icon {
display: block;
background: url('icon/双向箭头.png') no-repeat;
_filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${remoteServletURL}?op=resource&resource=/com/fr/bi/web/images/icon/slider-active.png');
_background: none;
background-size: 100% 100%;
}
.widget-slider-icon.native .x-icon,
.widget-slider-icon.disabled .x-icon {
display: block;
}
.demo-north { .demo-north {
background-color: #3c8dbc; background-color: #3c8dbc;
} }

635
docs/demo.js

@ -3588,23 +3588,7 @@ Demo.COMPONENT_CONFIG = [{
pId: 418, pId: 418,
text: "bi.dialog", text: "bi.dialog",
value: "demo.dialog" value: "demo.dialog"
}, { }
pId: 4,
id: 419,
text: "单值滑块"
}, {
pId: 419,
text: "bi.single_slider",
value: "demo.single_slider"
},{
pId: 4,
id: 420,
text: "区间滑块"
}, {
pId: 420,
text: "bi.interval_slider",
value: "demo.interval_slider"
},
];Demo.Func = BI.inherit(BI.Widget, { ];Demo.Func = BI.inherit(BI.Widget, {
props: { props: {
baseCls: "demo-func" baseCls: "demo-func"
@ -7059,94 +7043,534 @@ Demo.TextEditor = BI.inherit(BI.Widget, {
}) })
BI.shortcut("demo.text_editor", Demo.TextEditor);/** BI.shortcut("demo.text_editor", Demo.TextEditor);/**
* Created by Dailer on 2017/7/14. * Created by Dailer on 2017/7/11.
*/ */
Demo.IntervalSlider = BI.inherit(BI.Widget, { Demo.Month = BI.inherit(BI.Widget, {
props: { props: {
baseCls: "" baseCls: "demo-exceltable"
}, },
render: function () { render: function () {
var self = this; return {
var min = BI.createWidget({ type: "bi.horizontal_adapt",
type: "bi.text_editor", items: [{
watermark: "min", type: "bi.month_combo",
width: 100 width: 300
}]
}
}
})
BI.shortcut("demo.month", Demo.Month);/**
* Created by Urthur on 2017/7/14.
*/
BI.MultiDateTimeCombo = BI.inherit(BI.Single, {
constants: {
popupHeight: 290,
popupWidth: 270,
comboAdjustHeight: 1,
border: 1,
DATE_MIN_VALUE: "1900-01-01",
DATE_MAX_VALUE: "2099-12-31"
},
_defaultConfig: function () {
return BI.extend(BI.MultiDateTimeCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-date-time-combo bi-border',
height: 24
}); });
var max = BI.createWidget({ },
type: "bi.text_editor", _init: function () {
watermark: "max", BI.MultiDateTimeCombo.superclass._init.apply(this, arguments);
width: 100 var self = this, opts = this.options;
var date = new Date();
this.storeValue = {
value: {
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate(),
hour: date.getHours(),
minute: date.getMinutes(),
second: date.getSeconds()
}
};
this.trigger = BI.createWidget({
type: 'bi.date_time_trigger',
min: this.constants.DATE_MIN_VALUE,
max: this.constants.DATE_MAX_VALUE
});
this.popup = BI.createWidget({
type: "bi.multi_date_time_popup",
min: this.constants.DATE_MIN_VALUE,
max: this.constants.DATE_MAX_VALUE
});
self.setValue(this.storeValue);
this.popup.on(BI.MultiDateTimePopup.BUTTON_CANCEL_EVENT_CHANGE, function () {
self.combo.hideView();
self.fireEvent(BI.MultiDateTimeCombo.EVENT_CANCEL);
});
this.popup.on(BI.MultiDateTimePopup.BUTTON_OK_EVENT_CHANGE, function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.MultiDateTimeCombo.EVENT_CONFIRM);
});
this.popup.on(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE, function () {
self.setValue(self.popup.getValue());
});
this.combo = BI.createWidget({
type: 'bi.combo',
toggle: false,
isNeedAdjustHeight: false,
isNeedAdjustWidth: false,
el: this.trigger,
adjustLength: this.constants.comboAdjustHeight,
popup: {
el: this.popup,
maxHeight: this.constants.popupHeight,
width: this.constants.popupWidth,
stopPropagation: false
}
});
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.popup.setValue(self.storeValue);
self.fireEvent(BI.MultiDateTimeCombo.EVENT_BEFORE_POPUPVIEW);
});
var triggerBtn = BI.createWidget({
type: "bi.trigger_icon_button",
cls: "bi-trigger-date-button chart-date-normal-font bi-border-right",
width: 30,
height: 24
});
triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
});
BI.createWidget({
type: "bi.htape",
element: this,
items: [{
type: "bi.absolute",
items: [{
el: this.combo,
top: 0,
left: 0,
right: 0,
bottom: 0
}, {
el: triggerBtn,
top: 0,
left: 0
}]
}]
}) })
return { },
type: "bi.horizontal_auto",
setValue: function (v) {
this.storeValue = v;
this.popup.setValue(v);
this.trigger.setValue(v);
},
getValue: function () {
return this.storeValue;
}
});
BI.MultiDateTimeCombo.EVENT_CANCEL = "EVENT_CANCEL";
BI.MultiDateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.MultiDateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiDateTimeCombo.EVENT_BEFORE_POPUPVIEW = "BI.MultiDateTimeCombo.EVENT_BEFORE_POPUPVIEW";
BI.shortcut('bi.multi_date_time_combo', BI.MultiDateTimeCombo);
/**
* Created by Urthur on 2017/7/14.
*/
BI.CustomMultiDateTimeCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.CustomMultiDateTimeCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-custom-multi-date-time-combo"
})
},
_init: function () {
BI.CustomMultiDateTimeCombo.superclass._init.apply(this, arguments);
var self = this;
this.multiDateTime = BI.createWidget({
type: "bi.multi_date_time_combo",
element: this
});
this.multiDateTime.on(BI.MultiDateTimeCombo.EVENT_CANCEL, function () {
self.fireEvent(BI.CustomMultiDateTimeCombo.EVENT_CANCEL);
});
this.multiDateTime.on(BI.MultiDateTimeCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.CustomMultiDateTimeCombo.EVENT_CONFIRM);
});
},
getValue: function () {
return this.multiDateTime.getValue();
},
setValue: function (v) {
this.multiDateTime.setValue(v);
}
});
BI.CustomMultiDateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.CustomMultiDateTimeCombo.EVENT_CANCEL = "EVENT_CANCEL";
BI.CustomMultiDateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.custom_multi_date_time_combo", BI.CustomMultiDateTimeCombo);
/**
* Created by Urthur on 2017/7/14.
*/
BI.MultiDateTimePopup = BI.inherit(BI.Widget, {
constants: {
tabHeight: 30,
tabWidth: 42,
titleHeight: 27,
itemHeight: 30,
triggerHeight: 24,
buttonWidth: 90,
buttonHeight: 25,
popupHeight: 290,
popupWidth: 270,
comboAdjustHeight: 1,
lgap: 2,
border: 1
},
_defaultConfig: function () {
return BI.extend(BI.MultiDateTimePopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-date-time-popup',
width: 268,
height: 290
});
},
_init: function () {
BI.MultiDateTimePopup.superclass._init.apply(this, arguments);
var self = this, opts = this.options;
this.cancelButton = BI.createWidget({
type: 'bi.text_button',
forceCenter: true,
cls: 'bi-multidate-popup-button bi-border-top bi-border-right',
shadow: true,
text: BI.i18nText("BI-Basic_Cancel")
});
this.cancelButton.on(BI.TextButton.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiDateTimePopup.BUTTON_CANCEL_EVENT_CHANGE);
});
this.okButton = BI.createWidget({
type: "bi.text_button",
forceCenter: true,
cls: 'bi-multidate-popup-button bi-border-top',
shadow: true,
text: BI.i18nText("BI-Basic_OK")
});
this.okButton.on(BI.TextButton.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiDateTimePopup.BUTTON_OK_EVENT_CHANGE);
});
this.dateCombo = BI.createWidget({
type: "bi.date_calendar_popup",
min: self.options.min,
max: self.options.max
});
self.dateCombo.on(BI.DateCalendarPopup.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE);
});
this.dateSelect = BI.createWidget({
type: "bi.horizontal",
cls: "bi-border-top",
items: [{ items: [{
type: "bi.interval_slider", type: "bi.label",
text: BI.i18nText("BI-Basic_Time"),
width: 45
},{
type: "bi.multi_date_time_select",
max: 23,
min: 0,
width: 60,
height: 30,
ref: function (_ref) { ref: function (_ref) {
self.slider = _ref; self.hour = _ref;
}, self.hour.on(BI.MultiDateTimeSelect.EVENT_CONFIRM, function () {
width: 300, self.fireEvent(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE);
height: 90
}, {
type: "bi.center_adapt",
width: 300,
items: [{
type: "bi.text",
text: "min"
}, min, {
type: "bi.text",
text: "max"
}, max]
}, {
type: "bi.button",
text: "populate",
handler: function () {
self.slider.setMinAndMax({
min: min.getValue() || 0,
max: max.getValue() || 100
}); });
self.slider.populate(); }
}, },{
width: 300 type: "bi.label",
text: ":",
width: 15
},{
type: "bi.multi_date_time_select",
max: 59,
min: 0,
width: 60,
height: 30,
ref: function (_ref) {
self.minute = _ref;
self.minute.on(BI.MultiDateTimeSelect.EVENT_CONFIRM, function () {
self.fireEvent(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE);
});
}
},{
type: "bi.label",
text: ":",
width: 15
},{
type: "bi.multi_date_time_select",
max: 59,
min: 0,
width: 60,
height: 30,
ref: function (_ref) {
self.second = _ref;
self.second.on(BI.MultiDateTimeSelect.EVENT_CONFIRM, function () {
self.fireEvent(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE);
});
}
}]
});
this.dateButton = BI.createWidget({
type: "bi.grid",
items: [[this.cancelButton, this.okButton]]
});
BI.createWidget({
element: this,
type: "bi.vtape",
items: [{
el: this.dateCombo
}, { }, {
type: "bi.button", el: this.dateSelect,
text: "setValue", height: 50
handler: function () { },{
el: this.dateButton,
height: 30
}]
});
},
//既然 setVlaue后要重新 populate 才能生效,为何不直接在 setValue方法的结尾调用 populate 方法呢? setValue: function (v) {
self.slider.setValue({ var value, date;
min: 20, if (BI.isNotNull(v)) {
max: 80 value = v.value;
}); if(BI.isNull(value)){
self.slider.populate(); date = new Date();
this.dateCombo.setValue({
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate()
});
this.hour.setValue(date.getHours());
this.minute.setValue(date.getMinutes());
this.second.setValue(date.getSeconds());
} else {
this.dateCombo.setValue({
year: value.year,
month: value.month,
day: value.day
});
this.hour.setValue(value.hour);
this.minute.setValue(value.minute);
this.second.setValue(value.second);
}
}
},
getValue: function () {
return {
value: {
year: this.dateCombo.getValue().year,
month: this.dateCombo.getValue().month,
day: this.dateCombo.getValue().day,
hour: this.hour.getValue(),
minute: this.minute.getValue(),
second: this.second.getValue()
}
}
}
});
BI.MultiDateTimePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
BI.MultiDateTimePopup.BUTTON_CANCEL_EVENT_CHANGE = "BUTTON_CANCEL_EVENT_CHANGE";
BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE";
BI.shortcut('bi.multi_date_time_popup', BI.MultiDateTimePopup);
/**
* Created by Urthur on 2017/7/14.
*/
BI.MultiDateTimeSelect = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.MultiDateTimeSelect.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multi-date-time-select bi-border",
max: 23,
min: 0
})
},
_init: function () {
BI.MultiDateTimeSelect.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget({
type: "bi.sign_editor",
value: this._alertInEditorValue(o.min),
errorText: BI.i18nText("BI-Please_Input_Natural_Number"),
validationChecker: function(v){
return BI.isNaturalNumber(v);
}
});
this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){
self._finetuning(0);
self.fireEvent(BI.MultiDateTimeSelect.EVENT_CONFIRM);
});
this.topBtn = BI.createWidget({
type: "bi.icon_button",
cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom"
});
this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(1);
self.fireEvent(BI.MultiDateTimeSelect.EVENT_CONFIRM);
});
this.bottomBtn = BI.createWidget({
type: "bi.icon_button",
cls: "column-next-page-h-font bottom-button bi-border-left"
});
this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(-1);
self.fireEvent(BI.MultiDateTimeSelect.EVENT_CONFIRM);
});
this._finetuning(0);
BI.createWidget({
type: "bi.htape",
element: this,
items: [this.editor, {
el: {
type: "bi.grid",
columns: 1,
rows: 2,
items: [{
column: 0,
row: 0,
el: this.topBtn
}, {
column: 0,
row: 1,
el: this.bottomBtn
}]
}, },
width: 300 width: 30
}], }]
vgap: 20 });
},
_alertOutEditorValue: function(v){
if (v > this.options.max){
v = this.options.min;
} }
if (v < this.options.min){
v = this.options.max
}
return BI.parseInt(v);
},
_alertInEditorValue: function(v){
if (v > this.options.max){
v = this.options.min;
}
if (v < this.options.min){
v = this.options.max;
}
v = v < 10 ? "0" + v : v;
return v;
},
_finetuning: function(add){
var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue()));
this.editor.setValue(this._alertInEditorValue(v + add));
},
getValue: function () {
var v = this.editor.getValue();
return this._alertOutEditorValue(v);
},
setValue: function (v) {
this.editor.setValue(this._alertInEditorValue(v));
this._finetuning(0);
} }
})
BI.shortcut("demo.interval_slider", Demo.IntervalSlider);/** });
* Created by Dailer on 2017/7/11. BI.MultiDateTimeSelect.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.multi_date_time_select", BI.MultiDateTimeSelect);
/**
* Created by Urthur on 2017/7/14.
*/ */
Demo.Month = BI.inherit(BI.Widget, { BI.DateTimeTrigger = BI.inherit(BI.Trigger, {
props: { _const: {
baseCls: "demo-exceltable" hgap: 4,
vgap: 2,
triggerWidth: 30
},
_defaultConfig: function () {
return BI.extend(BI.DateTimeTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-date-time-trigger",
min: '1900-01-01', //最小日期
max: '2099-12-31', //最大日期
height: 25
});
}, },
render: function () { _init: function () {
return { BI.DateTimeTrigger.superclass._init.apply(this, arguments);
type: "bi.horizontal_adapt", var self = this, o = this.options, c = this._const;
this.editor = BI.createWidget({
type: "bi.sign_editor",
height: o.height,
hgap: c.hgap,
vgap: c.vgap,
disabled: true
});
BI.createWidget({
type: "bi.htape",
element: this,
items: [{ items: [{
type: "bi.month_combo", el: BI.createWidget(),
width: 300 width: 30
}, {
el: this.editor
}] }]
})
},
_printTime: function (v) {
return v < 10 ? "0" + v : v;
},
setValue: function (v) {
var self = this;
if (BI.isNotNull(v)) {
var value = v.value, dateStr;
if(BI.isNull(value)){
value = new Date();
dateStr = value.getFullYear() + "-" + self._printTime(value.getMonth() + 1) + "-" + self._printTime(value.getDate())
+ " " + self._printTime(value.getHours()) + ":" + self._printTime(value.getMinutes()) + ":" + self._printTime(value.getSeconds());
} else {
dateStr = value.year + "-" + self._printTime(value.month + 1) + "-" + self._printTime(value.day)
+ " " + self._printTime(value.hour) + ":" + self._printTime(value.minute) + ":" + self._printTime(value.second);
}
this.editor.setValue(dateStr);
} }
} }
})
BI.shortcut("demo.month", Demo.Month);/** });
BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger);
/**
* Created by User on 2017/3/22. * Created by User on 2017/3/22.
*/ */
Demo.MultiSelectCombo = BI.inherit(BI.Widget, { Demo.MultiSelectCombo = BI.inherit(BI.Widget, {
@ -7862,53 +8286,6 @@ Demo.SelectTreeCombo = BI.inherit(BI.Widget, {
}) })
BI.shortcut("demo.select_tree_combo", Demo.SelectTreeCombo);/** BI.shortcut("demo.select_tree_combo", Demo.SelectTreeCombo);/**
* Created by Dailer on 2017/7/14.
*/
Demo.SingleSlider = BI.inherit(BI.Widget, {
props: {
baseCls: ""
},
render: function () {
var self = this;
return {
type: "bi.horizontal_auto",
items: [{
type: "bi.single_slider",
ref: function (_ref) {
self.slider = _ref;
},
width: 300,
height: 50
}, {
type: "bi.button",
text: "populate",
handler: function () {
self.slider.setMinAndMax({
min: 1,
max: 100
});
self.slider.populate();
},
width: 300
}, {
type: "bi.button",
text: "setValue",
handler: function () {
//既然 setVlaue后要重新 populate 才能生效,为何不直接在 setValue方法的结尾调用 populate 方法呢?
self.slider.setValue(50);
self.slider.populate();
},
width: 300
}],
vgap: 20
}
}
})
BI.shortcut("demo.single_slider", Demo.SingleSlider);/**
* Created by Dailer on 2017/7/13. * Created by Dailer on 2017/7/13.
*/ */
Demo.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { Demo.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {

1057
docs/widget.js

File diff suppressed because one or more lines are too long

13
src/case/tree/tree.display.js

@ -44,6 +44,19 @@ BI.DisplayTree = BI.inherit(BI.TreeView, {
return setting; return setting;
}, },
_dealWidthNodes: function (nodes) {
nodes = BI.DisplayTree.superclass._dealWidthNodes.apply(this, arguments);
var self = this, o = this.options;
BI.each(nodes, function (i, node) {
if (node.count > 0) {
node.text = node.value + "(" + BI.i18nText("BI-Basic_Altogether") + node.count + BI.i18nText("BI-Basic_Count") + ")";
} else {
node.text = node.value;
}
});
return nodes;
},
initTree: function (nodes, setting) { initTree: function (nodes, setting) {
var setting = setting || this._configSetting(); var setting = setting || this._configSetting();
this.nodes = $.fn.zTree.init(this.tree.element, setting, nodes); this.nodes = $.fn.zTree.init(this.tree.element, setting, nodes);

6
src/less/widget/singleslider/singleslider.less

@ -1,6 +0,0 @@
@import "../../bibase";
.bi-single-slider {
& .slider-editor-button {
}
}

4
src/less/widget/singleslider/slider/widget.slider.less

@ -1,4 +0,0 @@
@import "../../../bibase";
.bi-single-slider-slider{
cursor: url('@{leftRightCursor}'), auto;
}

15
src/less/widget/singleslider/track/widget.track.less

@ -1,15 +0,0 @@
@import "../../../bibase";
.bi-slider-track {
.background-track {
.background-color(@color-bi-background-gray, 0);
.border-radius(12px);
}
.gray-track {
background: @color-bi-background-disabled;
.border-radius(4px);
}
.blue-track {
.border-radius(4px);
}
}

495
src/widget/intervalslider/intervalslider.js

@ -1,495 +0,0 @@
/**
* Created by zcf on 2016/9/26.
* Make some change by dailer on 2017/7/17
*/
BI.IntervalSlider = BI.inherit(BI.Widget, {
_constant: {
EDITOR_WIDTH: 58,
EDITOR_R_GAP: 60,
EDITOR_HEIGHT: 30,
HEIGHT: 28,
SLIDER_WIDTH_HALF: 15,
SLIDER_WIDTH: 30,
SLIDER_HEIGHT: 30,
TRACK_HEIGHT: 24
},
_defaultConfig: function () {
return BI.extend(BI.IntervalSlider.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-slider bi-slider-track"
})
},
_init: function () {
BI.IntervalSlider.superclass._init.apply(this, arguments);
var self = this;
var c = this._constant;
this.enable = false;
this.valueOne = "";
this.valueTwo = "";
this.calculation = new BI.AccurateCalculationModel();
this.backgroundTrack = BI.createWidget({
type: "bi.layout",
cls: "background-track",
height: c.TRACK_HEIGHT
});
this.grayTrack = BI.createWidget({
type: "bi.layout",
cls: "gray-track",
height: 8
});
this.blueTrack = BI.createWidget({
type: "bi.layout",
cls: "blue-track bi-high-light-background",
height: 8
});
this.track = this._createTrackWrapper();
this.labelOne = BI.createWidget({
type: "bi.sign_editor",
cls: "slider-editor-button",
errorText: "",
allowBlank: false,
height: c.HEIGHT,
width: c.EDITOR_WIDTH,
validationChecker: function (v) {
return self._checkValidation(v);
}
});
this.labelOne.on(BI.Editor.EVENT_CONFIRM, function () {
var v = BI.parseFloat(this.getValue());
self.valueOne = v;
var percent = self._getPercentByValue(v);
var significantPercent = BI.parseFloat(percent.toFixed(1)); //分成1000份
self._setLabelOnePosition(significantPercent);
self._setSliderOnePosition(significantPercent);
self._setBlueTrack();
self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
});
this.labelOne.on(BI.SignEditor.EVENT_FOCUS, function () {
self.labelOne.element.addClass("bi-border");
});
this.labelOne.on(BI.SignEditor.EVENT_BLUR, function () {
self.labelOne.element.removeClass("bi-border");
});
this.labelTwo = BI.createWidget({
type: "bi.sign_editor",
cls: "slider-editor-button",
errorText: "",
allowBlank: false,
height: c.HEIGHT,
width: c.EDITOR_WIDTH,
validationChecker: function (v) {
return self._checkValidation(v);
}
});
this.labelTwo.on(BI.Editor.EVENT_CONFIRM, function () {
var v = BI.parseFloat(this.getValue());
self.valueTwo = v;
var percent = self._getPercentByValue(v);
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setLabelTwoPosition(significantPercent);
self._setSliderTwoPosition(significantPercent);
self._setBlueTrack();
self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
});
this.labelTwo.on(BI.SignEditor.EVENT_FOCUS, function () {
self.labelTwo.element.addClass("bi-border");
});
this.labelTwo.on(BI.SignEditor.EVENT_BLUR, function () {
self.labelTwo.element.removeClass("bi-border");
});
this.sliderOne = BI.createWidget({
type: "bi.single_slider_slider"
});
this.sliderOne.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setLabelOnePosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
self.labelOne.setValue(v);
self.valueOne = v;
self._setBlueTrack();
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderOnePosition(significantPercent);
self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
}
});
this.sliderTwo = BI.createWidget({
type: "bi.single_slider_slider"
});
this.sliderTwo.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setLabelTwoPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
self.labelTwo.setValue(v);
self.valueTwo = v;
self._setBlueTrack();
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderTwoPosition(significantPercent);
self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
}
});
this._setVisible(false);
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
}]
}],
hgap: 7,
height: c.TRACK_HEIGHT
},
top: 33,
left: 0,
width: "100%"
},
this._createLabelWrapper(),
this._createSliderWrapper()
]
})
},
_createLabelWrapper: function () {
var c = this._constant;
return {
el: {
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [{
el: this.labelOne,
top: 0,
left: "0%"
}]
}, {
type: "bi.absolute",
items: [{
el: this.labelTwo,
top: 0,
left: "100%"
}]
}],
rgap: c.EDITOR_R_GAP,
height: 90
},
top: 0,
left: 0,
width: "100%"
}
},
_createSliderWrapper: function () {
var c = this._constant;
return {
el: {
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [{
el: this.sliderOne,
top: 0,
left: "0%"
}]
}, {
type: "bi.absolute",
items: [{
el: this.sliderTwo,
top: 0,
left: "100%"
}]
}],
hgap: c.SLIDER_WIDTH_HALF,
height: c.SLIDER_HEIGHT
},
top: 30,
left: 0,
width: "100%"
}
},
_createTrackWrapper: function () {
return BI.createWidget({
type: "bi.absolute",
items: [{
el: this.backgroundTrack,
width: "100%"
}, {
el: {
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [{
el: this.grayTrack,
top: 0,
left: 0,
width: "100%"
}, {
el: this.blueTrack,
top: 0,
left: 0,
width: "0%"
}]
}],
hgap: 8,
height: 8
},
top: 8,
left: 0,
width: "100%"
}]
})
},
_checkValidation: function (v) {
return BI.isNumeric(v) && !(BI.isNull(v) || v < this.min || v > this.max)
},
_checkOverlap: function () {
var labelOneLeft = this.labelOne.element[0].offsetLeft;
var labelTwoLeft = this.labelTwo.element[0].offsetLeft;
if (labelOneLeft <= labelTwoLeft) {
if ((labelTwoLeft - labelOneLeft) < 90) {
this.labelTwo.element.css({
"top": 60
});
} else {
this.labelTwo.element.css({
"top": 0
});
}
} else {
if ((labelOneLeft - labelTwoLeft) < 90) {
this.labelTwo.element.css({
"top": 60
});
} else {
this.labelTwo.element.css({
"top": 0
});
}
}
},
_setLabelOnePosition: function (percent) {
this.labelOne.element.css({
"left": percent + "%"
});
this._checkOverlap();
},
_setLabelTwoPosition: function (percent) {
this.labelTwo.element.css({
"left": percent + "%"
});
this._checkOverlap();
},
_setSliderOnePosition: function (percent) {
this.sliderOne.element.css({
"left": percent + "%"
});
},
_setSliderTwoPosition: function (percent) {
this.sliderTwo.element.css({
"left": percent + "%"
});
},
_setBlueTrackLeft: function (percent) {
this.blueTrack.element.css({
"left": percent + "%"
});
},
_setBlueTrackWidth: function (percent) {
this.blueTrack.element.css({
"width": percent + "%"
});
},
_setBlueTrack: function () {
var percentOne = this._getPercentByValue(this.labelOne.getValue());
var percentTwo = this._getPercentByValue(this.labelTwo.getValue());
if (percentOne <= percentTwo) {
this._setBlueTrackLeft(percentOne);
this._setBlueTrackWidth(percentTwo - percentOne);
} else {
this._setBlueTrackLeft(percentTwo);
this._setBlueTrackWidth(percentOne - percentTwo);
}
},
_setAllPosition: function (one, two) {
this._setSliderOnePosition(one);
this._setLabelOnePosition(one);
this._setSliderTwoPosition(two);
this._setLabelTwoPosition(two);
this._setBlueTrack();
},
_setVisible: function (visible) {
this.sliderOne.setVisible(visible);
this.sliderTwo.setVisible(visible);
this.labelOne.setVisible(visible);
this.labelTwo.setVisible(visible);
},
_setErrorText: function () {
var errorText = BI.i18nText("BI-Please_Enter") + this.min + "-" + this.max + BI.i18nText("BI-Basic_De") + BI.i18nText("BI-Basic_Number");
this.labelOne.setErrorText(errorText);
this.labelTwo.setErrorText(errorText);
},
_getGrayTrackLength: function () {
return this.grayTrack.element[0].scrollWidth
},
//其中取max-min后保留4为有效数字后的值的小数位数为最终value的精度
_getValueByPercent: function (percent) { //return (((max-min)*percent)/100+min)
var sub = this.calculation.accurateSubtraction(this.max, this.min);
var mul = this.calculation.accurateMultiplication(sub, percent);
var div = this.calculation.accurateDivisionTenExponent(mul, 2);
if (this.precision >= 0) {
return BI.parseFloat(this.calculation.accurateAddition(div, this.min).toFixed(this.precision));
} else {
return BI.parseFloat(this.calculation.accurateAddition(div, this.min) - this.calculation.accurateAddition(div, this.min) % (Math.pow(10, (-1) * this.precision)));
}
},
_getPercentByValue: function (v) {
return (v - this.min) * 100 / (this.max - this.min);
},
_setDraggableEnable: function (enable) {
if (enable) {
this.sliderOne.element.draggable("enable");
this.sliderTwo.element.draggable("enable")
} else {
this.sliderOne.element.draggable("disable");
this.sliderTwo.element.draggable("disable")
}
},
getValue: function () {
if (this.valueOne <= this.valueTwo) {
return {
min: this.valueOne,
max: this.valueTwo
}
} else {
return {
min: this.valueTwo,
max: this.valueOne
}
}
},
setMinAndMax: function (v) {
var minNumber = BI.parseFloat(v.min);
var maxNumber = BI.parseFloat(v.max);
if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber >= minNumber)) {
this.min = minNumber;
this.max = maxNumber;
this.valueOne = minNumber;
this.valueTwo = maxNumber;
//计算每一份值的精度(最大值和最小值的差值保留4为有效数字后的精度)
//如果差值的整数位数大于4,toPrecision得到的是科学计数法1234 => 1.2e+3
var sub = this.calculation.accurateSubtraction(this.max, this.min);
var pre = sub.toPrecision(4);
if(pre.indexOf("e") > -1 ){
this.precision = 3 - pre.charAt(pre.length - 1);
}else{
var arr = pre.split(".");
if(arr.length>1){
this.precision = arr[1].length;
}else{
this.precision=0;
}
}
this._setDraggableEnable(true);
}
if (maxNumber === minNumber) {
this._setDraggableEnable(false);
}
},
setValue: function (v) {
var valueOne = BI.parseFloat(v.min);
var valueTwo = BI.parseFloat(v.max);
if (!isNaN(valueOne) && !isNaN(valueTwo)) {
if (this._checkValidation(valueOne)) {
this.valueOne = valueOne;
}
if (this._checkValidation(valueTwo)) {
this.valueTwo = valueTwo;
}
if (valueOne < this.min) {
this.valueOne = this.min;
}
if (valueTwo > this.max) {
this.valueTwo = this.max;
}
}
},
reset: function () {
this._setVisible(false);
this.enable = false;
this.valueOne = "";
this.valueTwo = "";
this.min = NaN;
this.max = NaN;
this._setBlueTrackWidth(0);
},
populate: function () {
if (!isNaN(this.min) && !isNaN(this.max)) {
this.enable = true;
this._setVisible(true);
this._setErrorText();
if ((BI.isNumeric(this.valueOne) || BI.isNotEmptyString(this.valueOne)) && (BI.isNumeric(this.valueTwo) || BI.isNotEmptyString(this.valueTwo))) {
this.labelOne.setValue(this.valueOne);
this.labelTwo.setValue(this.valueTwo);
this._setAllPosition(this._getPercentByValue(this.valueOne), this._getPercentByValue(this.valueTwo));
} else {
this.labelOne.setValue(this.min);
this.labelTwo.setValue(this.max);
this._setAllPosition(0, 100)
}
}
}
});
BI.IntervalSlider.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.interval_slider", BI.IntervalSlider);

222
src/widget/intervalslider/model.accuratecalculation.js

@ -1,222 +0,0 @@
/**
* Created by zcf on 2017/3/1.
* 万恶的IEEE-754
* 使用字符串精确计算含小数加法减法乘法和10的指数倍除法支持负数
*/
BI.AccurateCalculationModel = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.AccurateCalculationModel.superclass._defaultConfig.apply(this, arguments), {
baseCls: ""
})
},
_init: function () {
BI.AccurateCalculationModel.superclass._init.apply(this, arguments);
},
_getMagnitude: function (n) {
var magnitude = "1";
for (var i = 0; i < n; i++) {
magnitude += "0";
}
return BI.parseInt(magnitude);
},
_formatDecimal: function (stringNumber1, stringNumber2) {
if (stringNumber1.numDecimalLength === stringNumber2.numDecimalLength) {
return;
}
var magnitudeDiff = stringNumber1.numDecimalLength - stringNumber2.numDecimalLength;
if (magnitudeDiff > 0) {
var needAddZero = stringNumber2
} else {
var needAddZero = stringNumber1;
magnitudeDiff = (0 - magnitudeDiff);
}
for (var i = 0; i < magnitudeDiff; i++) {
if (needAddZero.numDecimal === "0" && i === 0) {
continue
}
needAddZero.numDecimal += "0"
}
},
_stringNumberFactory: function (num) {
var strNum = num.toString();
var numStrArray = strNum.split(".");
var numInteger = numStrArray[0];
if (numStrArray.length === 1) {
var numDecimal = "0";
var numDecimalLength = 0;
} else {
var numDecimal = numStrArray[1];
var numDecimalLength = numStrArray[1].length;
}
return {
"numInteger": numInteger,
"numDecimal": numDecimal,
"numDecimalLength": numDecimalLength
}
},
_accurateSubtraction: function (num1, num2) {//num1-num2 && num1>num2
var stringNumber1 = this._stringNumberFactory(num1);
var stringNumber2 = this._stringNumberFactory(num2);
//整数部分计算
var integerResult = BI.parseInt(stringNumber1.numInteger) - BI.parseInt(stringNumber2.numInteger);
//小数部分
this._formatDecimal(stringNumber1, stringNumber2);
var decimalMaxLength = getDecimalMaxLength(stringNumber1, stringNumber2);
if (BI.parseInt(stringNumber1.numDecimal) >= BI.parseInt(stringNumber2.numDecimal)) {
var decimalResultTemp = (BI.parseInt(stringNumber1.numDecimal) - BI.parseInt(stringNumber2.numDecimal)).toString();
var decimalResult = addZero(decimalResultTemp, decimalMaxLength);
} else {//否则借位
integerResult--;
var borrow = this._getMagnitude(decimalMaxLength);
var decimalResultTemp = (borrow + BI.parseInt(stringNumber1.numDecimal) - BI.parseInt(stringNumber2.numDecimal)).toString();
var decimalResult = addZero(decimalResultTemp, decimalMaxLength);
}
var result = integerResult + "." + decimalResult;
return BI.parseFloat(result);
function getDecimalMaxLength(num1, num2) {
if (num1.numDecimal.length >= num2.numDecimal.length) {
return num1.numDecimal.length
}
return num2.numDecimal.length
}
function addZero(resultTemp, length) {
var diff = length - resultTemp.length;
for (var i = 0; i < diff; i++) {
resultTemp = "0" + resultTemp;
}
return resultTemp
}
},
_accurateAddition: function (num1, num2) {//加法结合律
var stringNumber1 = this._stringNumberFactory(num1);
var stringNumber2 = this._stringNumberFactory(num2);
//整数部分计算
var integerResult = BI.parseInt(stringNumber1.numInteger) + BI.parseInt(stringNumber2.numInteger);
//小数部分
this._formatDecimal(stringNumber1, stringNumber2);
var decimalResult = (BI.parseInt(stringNumber1.numDecimal) + BI.parseInt(stringNumber2.numDecimal)).toString();
if (decimalResult !== "0") {
if (decimalResult.length <= stringNumber1.numDecimal.length) {
decimalResult = addZero(decimalResult, stringNumber1.numDecimal.length)
} else {
integerResult++;//进一
decimalResult = decimalResult.slice(1);
}
}
var result = integerResult + "." + decimalResult;
return BI.parseFloat(result);
function addZero(resultTemp, length) {
var diff = length - resultTemp.length;
for (var i = 0; i < diff; i++) {
resultTemp = "0" + resultTemp;
}
return resultTemp
}
},
_accurateMultiplication: function (num1, num2) {//乘法分配律
var stringNumber1 = this._stringNumberFactory(num1);
var stringNumber2 = this._stringNumberFactory(num2);
//整数部分计算
var integerResult = BI.parseInt(stringNumber1.numInteger) * BI.parseInt(stringNumber2.numInteger);
//num1的小数和num2的整数
var dec1Int2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numDecimal) * BI.parseInt(stringNumber2.numInteger), stringNumber1.numDecimalLength);
//num1的整数和num2的小数
var int1dec2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numInteger) * BI.parseInt(stringNumber2.numDecimal), stringNumber2.numDecimalLength);
//小数*小数
var dec1dec2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numDecimal) * BI.parseInt(stringNumber2.numDecimal), (stringNumber1.numDecimalLength + stringNumber2.numDecimalLength));
return this._accurateAddition(this._accurateAddition(this._accurateAddition(integerResult, dec1Int2), int1dec2), dec1dec2);
},
_accurateDivisionTenExponent: function (num, n) {// num/10^n && n>0
var stringNumber = this._stringNumberFactory(num);
if (stringNumber.numInteger.length > n) {
var integerResult = stringNumber.numInteger.slice(0, (stringNumber.numInteger.length - n));
var partDecimalResult = stringNumber.numInteger.slice(-n);
} else {
var integerResult = "0";
var partDecimalResult = addZero(stringNumber.numInteger, n);
}
var result = integerResult + "." + partDecimalResult + stringNumber.numDecimal;
return BI.parseFloat(result);
function addZero(resultTemp, length) {
var diff = length - resultTemp.length;
for (var i = 0; i < diff; i++) {
resultTemp = "0" + resultTemp;
}
return resultTemp
}
},
accurateSubtraction: function (num1, num2) {
if (num1 >= 0 && num2 >= 0) {
if (num1 >= num2) {
return this._accurateSubtraction(num1, num2)
}
return -this._accurateSubtraction(num2, num1)
}
if (num1 >= 0 && num2 < 0) {
return this._accurateAddition(num1, -num2)
}
if (num1 < 0 && num2 >= 0) {
return -this._accurateAddition(-num1, num2)
}
if (num1 < 0 && num2 < 0) {
if (num1 >= num2) {
return this._accurateSubtraction(-num2, -num1)
}
return this._accurateSubtraction(-num1, -num2)
}
},
accurateAddition: function (num1, num2) {
if (num1 >= 0 && num2 >= 0) {
return this._accurateAddition(num1, num2)
}
if (num1 >= 0 && num2 < 0) {
return this.accurateSubtraction(num1, -num2)
}
if (num1 < 0 && num2 >= 0) {
return this.accurateSubtraction(num2, -num1)
}
if (num1 < 0 && num2 < 0) {
return -this._accurateAddition(-num1, -num2)
}
},
accurateMultiplication: function (num1, num2) {
if (num1 >= 0 && num2 >= 0) {
return this._accurateMultiplication(num1, num2)
}
if (num1 >= 0 && num2 < 0) {
return -this._accurateMultiplication(num1, -num2)
}
if (num1 < 0 && num2 >= 0) {
return -this._accurateMultiplication(-num1, num2)
}
if (num1 < 0 && num2 < 0) {
return this._accurateMultiplication(-num1, -num2)
}
},
accurateDivisionTenExponent: function (num1, n) {
if (num1 >= 0) {
return this._accurateDivisionTenExponent(num1, n);
}
return -this._accurateDivisionTenExponent(-num1, n);
}
});

9
src/widget/singleslider/jquery-ui/jquery-ui.min.js vendored

File diff suppressed because one or more lines are too long

299
src/widget/singleslider/singleslider.js

@ -1,299 +0,0 @@
/**
* Created by zcf on 2016/9/22.
*/
BI.SingleSlider = BI.inherit(BI.Widget, {
_constant: {
EDITOR_WIDTH: 60,
EDITOR_HEIGHT: 30,
HEIGHT: 28,
SLIDER_WIDTH_HALF: 15,
SLIDER_WIDTH: 30,
SLIDER_HEIGHT: 30,
TRACK_HEIGHT: 24
},
_defaultConfig: function () {
return BI.extend(BI.SingleSlider.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-slider bi-slider-track"
});
},
_init: function () {
BI.SingleSlider.superclass._init.apply(this, arguments);
var self = this;
var c = this._constant;
this.enable = false;
this.value = "";
this.backgroundTrack = BI.createWidget({
type: "bi.layout",
cls: "background-track bi-background",
height: c.TRACK_HEIGHT
});
this.grayTrack = BI.createWidget({
type: "bi.layout",
cls: "gray-track",
height: 8
});
this.blueTrack = BI.createWidget({
type: "bi.layout",
cls: "blue-track bi-high-light-background",
height: 8
});
this.track = this._createTrackWrapper();
this.slider = BI.createWidget({
type: "bi.single_slider_slider"
});
this.slider.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1)); //直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent);
self._setLabelPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
self.label.setValue(v);
self.value = v;
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
}
});
var sliderVertical = BI.createWidget({
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [this.slider]
}],
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._getGrayTrackLength();
}
if (offset > (trackLength - c.SLIDER_WIDTH)) {
percent = 100
}
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setAllPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
self.label.setValue(v);
self.value = v;
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
}
});
this.label = BI.createWidget({
type: "bi.sign_editor",
cls: "slider-editor-button",
errorText: "",
height: c.HEIGHT,
width: c.EDITOR_WIDTH,
allowBlank: false,
validationChecker: function (v) {
return self._checkValidation(v);
},
quitChecker: function (v) {
return self._checkValidation(v);
}
});
this.label.on(BI.SignEditor.EVENT_CONFIRM, function () {
var percent = self._getPercentByValue(this.getValue());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setAllPosition(significantPercent);
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
});
this.label.on(BI.SignEditor.EVENT_FOCUS, function () {
self.label.element.addClass("bi-border");
});
this.label.on(BI.SignEditor.EVENT_BLUR, function () {
self.label.element.removeClass("bi-border");
});
this._setVisible(false);
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
}]
}],
hgap: 7,
height: c.TRACK_HEIGHT
},
top: 33,
left: 0,
width: "100%"
}, {
el: sliderVertical,
top: 30,
left: 0,
width: "100%"
}, {
el: {
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [this.label]
}],
rgap: c.EDITOR_WIDTH / 2,
height: c.EDITOR_HEIGHT
},
top: 0,
left: 0,
width: "100%"
}]
})
},
_createTrackWrapper: function () {
return BI.createWidget({
type: "bi.absolute",
items: [{
el: this.backgroundTrack,
width: "100%"
}, {
el: {
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [{
el: this.grayTrack,
top: 0,
left: 0,
width: "100%"
}, {
el: this.blueTrack,
top: 0,
left: 0,
width: "0%"
}]
}],
hgap: 8,
height: 8
},
top: 8,
left: 0,
width: "100%"
}]
})
},
_checkValidation: function (v) {
return !(BI.isNull(v) || v < this.min || v > this.max)
},
_setBlueTrack: function (percent) {
this.blueTrack.element.css({
"width": percent + "%"
});
},
_setLabelPosition: function (percent) {
this.label.element.css({
"left": percent + "%"
});
},
_setSliderPosition: function (percent) {
this.slider.element.css({
"left": percent + "%"
});
},
_setAllPosition: function (percent) {
this._setSliderPosition(percent);
this._setLabelPosition(percent);
this._setBlueTrack(percent);
},
_setVisible: function (visible) {
this.slider.setVisible(visible);
this.label.setVisible(visible);
},
_getGrayTrackLength: function () {
return this.grayTrack.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;
}
}
},
setMinAndMax: function (v) {
var minNumber = BI.parseFloat(v.min);
var maxNumber = BI.parseFloat(v.max);
if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber > minNumber)) {
this.min = minNumber;
this.max = maxNumber;
}
},
reset: function () {
this._setVisible(false);
this.enable = false;
this.value = "";
this.min = 0;
this.max = 0;
this._setBlueTrack(0);
},
populate: function () {
if (!isNaN(this.min) && !isNaN(this.max)) {
this._setVisible(true);
this.enable = true;
this.label.setErrorText(BI.i18nText("BI-Please_Enter") + this.min + "-" + this.max + BI.i18nText("BI-Basic_De") + BI.i18nText("BI-Basic_Number"));
if (BI.isNumeric(this.value) || BI.isNotEmptyString(this.value)) {
this.label.setValue(this.value);
this._setAllPosition(this._getPercentByValue(this.value));
} else {
this.label.setValue(this.max);
this._setAllPosition(100);
}
}
}
});
BI.SingleSlider.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.single_slider", BI.SingleSlider);

33
src/widget/singleslider/slider/widget.slider.js

@ -1,33 +0,0 @@
/**
* Created by zcf on 2016/9/22.
*/
BI.Slider = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.Slider.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-slider-slider"
});
},
_init: function () {
BI.extend(BI.Slider.superclass._init.apply(this, arguments));
this.slider = BI.createWidget({
type: "bi.icon_button",
cls: "widget-slider-icon",
iconWidth: 30,
iconHeight: 30,
height: 30,
width: 30
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.slider,
top: 0,
left: -15
}],
width: 0,
height: 30
});
}
});
BI.shortcut("bi.single_slider_slider", BI.Slider);
Loading…
Cancel
Save