📄 bs_slider.class.js
字号:
val = this._roundToGrid(val, ctrl.knobId); var valInternal = (ctrl.knobId == 1) ? this._valueInternal : this._valueInternal2; if (this.sliderValueType=='time') { strVal=getTimeByVal(val); } else { strVal=val; } if (val != valInternal) { if (ctrl.knobId == 1) { this._valueInternal = val; if (this.sliderValue1) { this.sliderValue1.innerHTML = strVal; } } else { this._valueInternal2 = val; if (this.sliderValue2) { this.sliderValue2.innerHTML = strVal; } } newPos=this._getPositionByValue(val); this.updateHandle(newPos, ctrl.knobId); this.updateValueField(val, ctrl.knobId); this.updateValueText(val, ctrl.knobId); this._updateColorbar(newPos, ctrl.knobId);//if ('undefined' != typeof(this.eventOnChange)) this.eventOnChange(this, val, newPos);this.fireEvent('onChange');}}this.onChangeByClick = function(event) { if (this._disabled) return; var newPos = 0; if ('undefined' != typeof(event.offsetX)) { newPos = (this.direction == 0) ? event.offsetX + this._posSlideStart : event.offsetY + this._posSlideStart; } else if ('undefined' != typeof(event.layerX)) { newPos = (this.direction == 0) ? event.layerX + this._posSlideStart : event.layerY + this._posSlideStart; } else { return; } if ((this.useSecondKnob) && (this.colorbar.type=='between') && (event.srcElement==this['_colorbarObj'])) { newPos = newPos - this._posSlideStart + this._getPositionByValue(this._valueInternal) ; } if (newPos>this._posSlideEnd) { newPos=this._posSlideEnd; } var val = this._getValueByPosition(newPos); if (this.useSecondKnob) { if (val > this._valueInternal2) { var knobId = 2; } else if (val < this._valueInternal) { var knobId = 1; } else { if (val<((this._valueInternal2+this._valueInternal)/2)) { var knobId = 1; } else { var knobId = 2; } } } else { var knobId = 1; } this.currentKnob=knobId; val = this._roundToGrid(val,knobId); if (val != this._valueInternal) { if (knobId == 1) { this._valueInternal = val; } else { this._valueInternal2 = val; } this.updateHandle(newPos, knobId); this.updateValueField(val, knobId); this.updateValueText(val, knobId); this._updateColorbar(newPos, knobId); if ('undefined' != typeof(this.eventOnChange)) this.eventOnChange(this, val, newPos); this.fireEvent('onChange'); }}this.onChangeByInput = function(val, isBlur, knobId) {var k = ((typeof(knobId) == 'undefined') || (knobId == 1)) ? '' : '2';if (this._disabled) return;if (val == '') {val = this['minVal'+k];}val = this._roundToGrid(val, knobId);var newPos = this._getPositionByValue(val);if (val != this['_valueInternal'+k]) {this['_valueInternal'+k] = val;this.updateHandle(newPos, knobId);this._updateColorbar(newPos, knobId);if ('undefined' != typeof(this.eventOnChange)) this.eventOnChange(this, val, newPos);this.fireEvent('onChange');if (isBlur) {this.updateValueField(val, knobId);this.updateValueText(val, knobId);}} else if (isBlur) {this.updateValueField(val, knobId);this.updateValueText(val, knobId);}}this.onChangeByArrow = function(leftOrRight, keepFiring, loopCall) {if (!loopCall) this._stopFireArrowFlag = false;if (this._stopFireArrowFlag) return;if (this._disabled) return;var val = parseFloat(this._valueInternal);if (leftOrRight) {val += this.arrowAmount;} else {val -= this.arrowAmount;}val = this._roundToGrid(val);if (val != this._valueInternal) {this._valueInternal = val;var newPos = this._getPositionByValue(val);this.updateHandle(newPos);this.updateValueField(val);this.updateValueText(val);this._updateColorbar(newPos);if ('undefined' != typeof(this.eventOnChange)) this.eventOnChange(this, val, newPos);this.fireEvent('onChange');}if (keepFiring) {if (!this._stopFireArrowFlag && (this.arrowKeepFiringTimeout > 0)) {setTimeout('Bs_Objects[' + this._id + '].onChangeByArrow(' + leftOrRight + ', ' + keepFiring + ', true);', this.arrowKeepFiringTimeout);}}}this.onMouseWheel = function() {if (this._disabled) return;var val = parseFloat(this._valueInternal);if (event.wheelDelta > 0) {val -= this.wheelAmount;} else {val += this.wheelAmount;}val = this._roundToGrid(val);if (val != this._valueInternal) {this._valueInternal = val;var newPos = this._getPositionByValue(val);this.updateHandle(newPos);this.updateValueField(val);this.updateValueText(val);this._updateColorbar(newPos);if ('undefined' != typeof(this.eventOnChange)) this.eventOnChange(this, val, newPos);this.fireEvent('onChange');}}this.stopFireArrow = function() {this._stopFireArrowFlag = true;}this.setValue = function(val, knobId) { this.currentKnob=knobId; if (typeof(knobId) == 'undefined') knobId = 1; val = this._roundToGrid(val, knobId); var newPos = this._getPositionByValue(val); var valInternal = (knobId == 1) ? this._valueInternal : this._valueInternal2; if (val != valInternal) { if (knobId == 1) { this._valueInternal = val; } else { this._valueInternal2 = val; } this.updateHandle(newPos, knobId); this._updateColorbar(newPos, knobId); //if ('undefined' != typeof(this.eventOnChange)) this.eventOnChange(this, val, newPos); this.fireEvent('onChange'); this.updateValueField(val, knobId); this.updateValueText(val, knobId); }}this.onChangeByApi = function(val, knobId) { this.setValue(val, knobId);}this._updateColorbar = function(newPos, knobId) { var k = ((typeof(knobId) == 'undefined') || (knobId == 1) || ((typeof(this.colorbar) != 'undefined') && ((typeof(this.colorbar.type) != 'undefined') || (this.colorbar.type == 'between')))) ? '' : '2'; if (this['_colorbarObj'+k]) { if ((typeof(this.colorbar.type) != 'undefined') && (this.colorbar.type == 'between')) {/* if ((typeof(knobId) == 'undefined') || (knobId == 1)) { var left = newPos; var right = newPos+50; } else { var right = newPos; var left = newPos-50; } var left = this.ctrl.div.style.left; var right = this.ctrl2.div.style.left+this.ctrl2.div.style.width/2;*/ var left = this._getPositionByValue(this._valueInternal, 1); var right = this._getPositionByValue(this._valueInternal2, 2); this['_colorbarObj'+k].style.left = (left + this.colorbar.offsetLeft)+"px"; this['_colorbarObj'+k].style.width = (right - left)+"px"; } else { var newWidth = newPos + this['colorbar'+k]['widthDifference']; if (newWidth < 0) newWidth = 0;if (k == '2') { var invertedWidth = this.width - newWidth; if (invertedWidth < 0) invertedWidth = 0; this['_colorbarObj'+k].style.width = invertedWidth+"px"; if (typeof(this.colorbar2['offsetLeft']) != 'undefined') newWidth += this.colorbar2['offsetLeft'];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -