⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bs_slider.class.js

📁 在线电子表格SpreadSheet 在线电子表格SpreadSheet
💻 JS
📖 第 1 页 / 共 2 页
字号:
this._containerObj.style.display = 'none';break;case 1:this._containerObj.style.visibility = 'hidden';break;case 2:this._containerObj.style.visibility = 'visible';this._containerObj.style.display = 'block';break;default:}}}this.setDisabled = function(b) {if (typeof(b) == 'undefined') b = !this._disabled;if (b) {var filter = 'progid:DXImageTransform.Microsoft.BasicImage(grayScale=1); progid:DXImageTransform.Microsoft.BasicImage(opacity=.5)';var cursor = 'default';} else {var filter = null;var cursor = 'hand';}var t = new Array(this._containerId, this._arrowLeftContainerId, this._arrowRightContainerId,this._valueFieldId, this._valueTextId,this._slideBarId, this._colorbarId, this._handleId);for (var i=0; i<t.length; i++) {var elm = document.getElementById(t[i]);if (elm != null) elm.style.filter = filter;}var elm = document.getElementById(this._arrowLeftIconId);if (elm != null) elm.style.cursor = cursor;var elm = document.getElementById(this._arrowRightIconId);if (elm != null) elm.style.cursor = cursor;var elm = document.getElementById(this._valueFieldId);if (elm != null) elm.disabled = b;this._disabled = b;}this.getValue = function() {return this._valueInternal;}this.getSliderPos = function() {var absLeng = (this.direction==0) ? getDivLeft(this.ctrl.div) - this.ctrl.minX : getDivTop (this.ctrl.div) - this.ctrl.minY;var absRang = this.maxVal - this.minVal;return (absLeng * absRang/this._slideWidth) + this.minVal;}this.onChangeBySlide = function() {if (this._disabled) return;var newPos = this._getNewLocationFromCursor();var val = this._getValueByPosition(newPos);val = this._roundToGrid(val);if (val != this._valueInternal) {this._valueInternal = 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.onChangeByClick = function(event) {if (this._disabled) return;var newPos = 0;if ('undefined' != typeof(event.offsetX)) {newPos = event.offsetX + this._posSlideStart;} else if ('undefined' != typeof(event.layerX)) {newPos = event.layerX + this._posSlideStart;} else {return;}var val = this._getValueByPosition(newPos);val = this._roundToGrid(val);if (val != this._valueInternal) {this._valueInternal = 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.onChangeByInput = function(val, isBlur) {if (this._disabled) return;if (val == '') {val = this.minVal;}val = this._roundToGrid(val);var newPos = this._getPositionByValue(val);if (val != this._valueInternal) {this._valueInternal = val;this.updateHandle(newPos);this._updateColorbar(newPos);if ('undefined' != typeof(this.eventOnChange)) this.eventOnChange(this, val, newPos);this.fireEvent('onChange');if (isBlur) {this.updateValueField(val);this.updateValueText(val);}} else if (isBlur) {this.updateValueField(val);this.updateValueText(val);}}this.onChangeByArrow = function(leftOrRight) {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');}}this.setValue = function(val) {val = this._roundToGrid(val);var newPos = this._getPositionByValue(val);if (val != this._valueInternal) {this._valueInternal = val;this.updateHandle(newPos);this._updateColorbar(newPos);if ('undefined' != typeof(this.eventOnChange)) this.eventOnChange(this, val, newPos);this.fireEvent('onChange');this.updateValueField(val);this.updateValueText(val);}}this.onChangeByApi = function(val) {this.setValue(val);}this._updateColorbar = function(newPos) {if (this._colorbarObj) {var newWidth = newPos + this.colorbar['widthDifference'];if (newWidth < 0) newWidth = 0;this._colorbarObj.style.width = newWidth;}}this._getValueByPosition = function(pos) {pos -= this.ctrl.minX;var hundertPercent = this.ctrl.maxX - this.ctrl.minX;var myPercent      = pos / hundertPercent;var val            = this.minVal + ((this.maxVal - this.minVal) * myPercent);return val;}this._getPositionByValue = function(val) {val = val - this.minVal;var hundertPercent = this.maxVal - this.minVal;var myPercent      = val / hundertPercent;var pos            = this.ctrl.minX + ((this.ctrl.maxX - this.ctrl.minX) * myPercent);return pos;}this._roundToGrid = function(val) {val = parseFloat(val);if (isNaN(val)) return this.minVal;val = Math.round(val / this.valueInterval) * this.valueInterval;val = Math.round(val*10000)/10000;if (val < this.minVal) val = this.minVal;if (val > this.maxVal) val = this.maxVal;return val;}this._getNewLocationFromCursor = function() {var ox = this._posEventSlideStartX;var oy = this._posEventSlideStartY;switch(this.direction) {case 0:var t = this.ctrl.pageX - ox;var x = parseInt(this._posObjSlideStartX) + t;if (x > this.ctrl.maxX) x = this.ctrl.maxX;if (x < this.ctrl.minX) x = this.ctrl.minX;return x;if (this.ctrl.pageX > this.ctrl.maxX) {x=this.ctrl.maxX;} else if (this.ctrl.pageX < this.ctrl.minX) {x=this.ctrl.minX;} else {x = this.ctrl.pageX;if (x < this.ctrl.minX) x = this.ctrl.minX;if (x > this.ctrl.maxX) x = this.ctrl.maxX;}return x;break;case 1:if(this.ctrl.pageY>this.ctrl.maxY)      y=this.ctrl.maxY;else if(this.ctrl.pageY<this.ctrl.minY) y=this.ctrl.minY;else {y+=this.ctrl.pageY-this.ctrl.curY;if(y<this.ctrl.minY) y=this.ctrl.minY;if(y>this.ctrl.maxY) y=this.ctrl.maxY;}return y;break;}}this.updatePointer = function(newPos) {this.updateHandle(newPos);}this.updateHandle = function(newPos) {this._currentRelSliderPosX = newPos;this.ctrl.div.style.left = newPos;return;switch(this.direction) {case 0:moveDivTo(this.ctrl.div, newPos, getDivTop(this.ctrl.div));break;case 1:moveDivTo(this.ctrl.div, getDivTop(this.ctrl.div), newPos);break;}}this.updateValueField = function(val) {if (this._valueFieldObj) {this._valueFieldObj.value = val;}}this.updateValueText = function(val) {if (this._valueTextObj) {this._valueTextObj.innerHTML = val;}}this.arrowOnClick = function() {}this.onChange = function(val) {this.setValue(val);}this.updateInputBox = function(val) {this.setValue(val);}this.textboxEdit = function(editMode) {if (this._disabled) return;if (editMode) {if ('undefined' != typeof(this._valueFieldObj)) {this._valueTextObj.style.display = 'none';this._valueFieldObj.style.display = 'block';bsFormFieldSetFocusAndSelect(this._valueFieldObj, false);}} else {if ('undefined' != typeof(this._valueTextObj)) {this._valueFieldObj.style.display = 'none';this._valueTextObj.style.display  = 'block';}}}this.slideMove = function(ctrl, client) {ctrl.sliderObj.onChangeBySlide(ctrl);}this.slideStart = function(ctrl,client) {ctrl.sliderObj._posEventSlideStartX = ctrl.startX;ctrl.sliderObj._posEventSlideStartY = ctrl.startY;ctrl.sliderObj._posObjSlideStartX = ctrl.sliderObj._handleObj.style.left;ctrl.sliderObj._posObjSlideStartY = ctrl.sliderObj._handleObj.style.top;var pos = ctrl.sliderObj.getSliderPos();ctrl.sliderObj.setValue(pos);if ('undefined' != typeof(ctrl.sliderObj.slideStartCB)) {ctrl.sliderObj.slideStartCB(ctrl.sliderObj, ctrl.sliderObj.getValue(), pos);}}this.slideEnd = function(ctrl,client){var pos = ctrl.sliderObj.getSliderPos();if ('undefined' != typeof(ctrl.sliderObj.slideEndCB)) {ctrl.sliderObj.slideEndCB(ctrl.sliderObj, ctrl.sliderObj.getValue(), pos);}return;}this._constructor(theFieldnamePrefix);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -