Your IP : 3.143.239.234


Current Path : /var/www/www-root/data/www/info.monolith-realty.ru/bitrix/js/landing/ui/field/
Upload File :
Current File : /var/www/www-root/data/www/info.monolith-realty.ru/bitrix/js/landing/ui/field/range_field.min.js

(function(){"use strict";BX.namespace("BX.Landing.UI.Field");BX.Landing.UI.Field.Range=function(t){this.items=BX.type.isArray(t.items)?t.items:[];this.values=new BX.Landing.Collection.BaseCollection;this.isMultiple=typeof t.type==="string"&&t.type==="multiple";this.inputInner=this.createInputInner();this.container=BX.create("div",{props:{className:"landing-ui-field-range-container"}});this.output=this.createOutput();this.sliderFrom=null;this.sliderTo=this.createSlider();this.sliderValue=this.createValue();this.elements=[];this.frame=typeof t.frame==="object"?t.frame:null;this.format=typeof t.format==="function"?t.format:function(){};this.postfix=typeof t.postfix==="string"?t.postfix:"";this.changeHandler=typeof t.onChange==="function"?t.onChange:function(){};this.onValueChangeHandler=t.onValueChange?t.onValueChange:function(){};this.dragStartHandler=typeof t.onDragStart==="function"?t.onDragStart:function(){};this.dragEndHandler=typeof t.onDragEnd==="function"?t.onDragEnd:function(){};var e=BX.Landing.PageObject.getRootWindow();this.jsDD=this.frame?e.jsDD:window.jsDD;this.value=null;this.valueFrom=null;this.valueTo=null;BX.Landing.UI.Field.BaseField.apply(this,arguments);this.layout.classList.add("landing-ui-field-range");this.stepPercent=100/this.values.length;if(this.content===null||this.content===undefined||this.content===""){if(this.isMultiple){this.content={from:this.items[0].value,to:this.items[this.items.length-1].value}}else{this.content=this.items[0].value;this.value=this.items[0].value}}var i=function(t){this.jsDD.stopDrag(t)}.bind(this);BX.Event.bind(window,"mouseup",i);BX.Event.bind(e,"mouseup",i);BX.Event.bind(window.top,"mouseup",i);this.setValue(this.content,true)};BX.Landing.UI.Field.Range.prototype={constructor:BX.Landing.UI.Field.Range,__proto__:BX.Landing.UI.Field.BaseField.prototype,init:function(){this.input.appendChild(this.inputInner);this.input.appendChild(this.sliderValue);this.layout.appendChild(this.container);this.container.appendChild(this.input);if(!this.isMultiple){this.container.appendChild(this.output)}if(this.isMultiple){this.sliderFrom=this.createSlider();this.inputInner.appendChild(this.sliderFrom)}this.inputInner.appendChild(this.sliderTo);this.items.forEach((function(t,e){this.values.add({value:t.value,valuePercent:this.valueToPercent(e),left:this.valueToLeftPercent(t.value),name:t.name})}),this);if(this.isMultiple){this.sliderFrom.onbxdragstart=this.onDragStart.bind(this);this.sliderFrom.onbxdrag=this.onDrag.bind(this);this.sliderFrom.onbxdragstop=this.onDragEnd.bind(this);this.jsDD.registerObject(this.sliderFrom)}this.sliderTo.onbxdragstart=this.onDragStart.bind(this);this.sliderTo.onbxdrag=this.onDrag.bind(this);this.sliderTo.onbxdragstop=this.onDragEnd.bind(this);this.jsDD.registerObject(this.sliderTo);if(this.isMultiple){requestAnimationFrame(function(){this.sliderFrom.style.transform="translateX(-"+this.values[this.values.length-1].valuePercent+"%)";this.sliderFrom.style.left=this.values[this.values.length-1].valuePercent+"%"}.bind(this))}if(this.frame){this.onFrameLoad()}},createOutput:function(){this.outputInput=BX.create("div",{props:{className:"landing-ui-field-range-output-input"},text:"0"});return BX.create("div",{props:{className:"landing-ui-field-range-output"},children:[this.outputInput,BX.create("div",{props:{className:"landing-ui-field-range-output-arrows"},children:[BX.create("div",{props:{className:"landing-ui-field-range-output-arrows-up"},events:{click:this.onArrowUpClick.bind(this)}}),BX.create("div",{props:{className:"landing-ui-field-range-output-arrows-down"},events:{click:this.onArrowDownClick.bind(this)}})]})]})},onArrowUpClick:function(){var t=!!this.value?this.values.length-1:0;var e;this.values.forEach((function(e,i){if(e.value===this.value){t=i}}),this);e=this.values[t+1]?this.values[t+1]:this.values[t];this.setValue(e.value)},onArrowDownClick:function(){var t=0;var e;this.values.forEach((function(e,i){if(e.value==this.value){t=i}}),this);e=this.values[t-1]?this.values[t-1]:this.values[t];this.setValue(e.value)},onFrameLoad:function(){this.elements=[].slice.call(this.frame.document.querySelectorAll(this.selector));if(this.elements.length){const t=this.elements[0];if(this.isMultiple){const e=this.values.find((function(e){return t.classList.contains(e.value)}));const i=this.values.find((function(i){return t.classList.contains(i.value)&&i.value!==e}));this.setValue({from:!!e?e.value:null,to:!!i?i.value:null},true)}else{const e=this.values.find((function(e){return t.classList.contains(e.value)}));this.setValue(!!e?e.value:null,true)}}},getStartXOffset:function(){var t=parseFloat(this.jsDD.current_node.style.left)*(this.inputInner.getBoundingClientRect().width/100);return this.jsDD.current_node.getBoundingClientRect().left+window.pageXOffset-(t===t?t:0)},onDragStart:function(){this.offset=this.getStartXOffset();this.dragStartHandler()},onDrag:function(t){t=(t-this.offset)/this.inputInner.getBoundingClientRect().width*100;t=t<0?0:t>100?100:t;var e=t;var i;var n=parseFloat(this.jsDD.current_node.style.left);n=n===n?n:0;if(t>this.lastPos){e+=this.stepPercent/2;i=this.values.filter((function(t){return e>=t.valuePercent&&t.valuePercent>n}),this);i=i[i.length-1]}else{e-=this.stepPercent/2;i=this.values.filter((function(t){return e<=t.valuePercent&&t.valuePercent<n}),this);i=i[0]}if(i){if(this.isMultiple){if(this.jsDD.current_node===this.sliderFrom){this.valueFrom=i.value}if(this.jsDD.current_node===this.sliderTo){this.valueTo=i.value}this.setValue({from:this.valueFrom,to:this.valueTo})}else{this.setValue(i.value)}}this.lastPos=t},onChange:function(){this.changeHandler(this.getValue(),this.items,this.postfix,this.property);this.onValueChangeHandler(this)},onDragEnd:function(){this.dragEndHandler()},getValue:function(){var t;if(this.isMultiple){t={from:this.toPercent<this.fromPercent?this.valueTo:this.valueFrom,to:this.toPercent>this.fromPercent?this.valueTo:this.valueFrom}}else{t=this.value}return t},setValue:function(t,e){if(t&&typeof t==="object"){var i=this.values.filter((function(e){return e.value==t.from}));var n=this.values.filter((function(e){return e.value==t.to}));i=i.length?i[0]:this.values[0];n=n.length?n[0]:this.values[this.values.length-1];if(i){requestAnimationFrame(function(){this.sliderFrom.style.transform="translateX(-"+i.valuePercent+"%)";this.sliderFrom.style.left=i.valuePercent+"%"}.bind(this));this.valueFrom=i.value;this.fromPercent=i.valuePercent}if(n){requestAnimationFrame(function(){this.sliderTo.style.transform="translateX(-"+n.valuePercent+"%)";this.sliderTo.style.left=n.valuePercent+"%"}.bind(this));this.valueTo=n.value;this.toPercent=n.valuePercent}this.updateValuePosition(i.valuePercent,n.valuePercent)}else if(t){var s=this.values.filter((function(e){return e.value==t}));s=s.length?s[0]:null;if(s){requestAnimationFrame(function(){this.sliderTo.style.transform="translateX(-"+s.valuePercent+"%)";this.sliderTo.style.left=s.valuePercent+"%"}.bind(this));this.value=t;this.updateValuePosition(s.valuePercent)}}if(!e){this.onChange()}},updateValuePosition:function(t,e){if(typeof t!=="number"&&typeof e!=="number"){t=0;e=100}if(typeof t==="number"&&typeof e!=="number"){e=t;t=0}requestAnimationFrame(function(){this.sliderValue.style.left=Math.min(t,e)+"%";this.sliderValue.style.right=100-Math.max(t,e)+"%"}.bind(this));var i=this.values.filter((function(t){return t.valuePercent==e}));i=i.length?i[0]:null;this.outputInput.innerText=!!i?i.name:0;BX.Dom.attr(this.outputInput,"title",BX.Text.encode(this.outputInput.innerText))},createInputInner:function(){return BX.create("div",{props:{className:"landing-ui-field-range-input-inner"}})},createValue:function(){return BX.create("div",{props:{className:"landing-ui-field-range-value"}})},createSlider:function(){return BX.create("div",{props:{className:"landing-ui-field-range-input-slider"}})},createInput:function(){return BX.create("div",{props:{className:"landing-ui-field-input landing-ui-field-range-input"}})},valueToPercent:function(t){return t/(this.items.length-1)*100},valueToLeftPercent:function(t){return t/this.inputInner.getBoundingClientRect().width*100},isChanged:function(){if(this.isMultiple){return JSON.stringify(this.content)!==JSON.stringify(this.getValue())}return this.content!=this.getValue()}}})();
//# sourceMappingURL=range_field.map.js