Current Path : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/landing/ui/form/ |
Current File : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/landing/ui/form/base_form.min.js |
(function(){"use strict";BX.namespace("BX.Landing.UI.Form");var e=BX.Landing.Utils.append;var t=BX.Landing.Utils.clone;var i=BX.Landing.Utils.remove;BX.Landing.UI.Form.BaseForm=function(e){this.data=BX.type.isPlainObject(e)?e:{};this.id="id"in this.data?this.data.id:BX.Landing.Utils.random();this.selector="selector"in this.data?this.data.selector:"";this.title="title"in this.data?this.data.title:"";this.label="label"in this.data?this.data.label:"";this.type="type"in this.data?this.data.type:"content";this.code="code"in this.data?this.data.code:"";this.descriptionText="description"in this.data?this.data.description:"";this.headerCheckbox=this.data.headerCheckbox;this.layout=BX.Landing.UI.Form.BaseForm.createLayout();this.fields=new BX.Landing.Collection.BaseCollection;this.cards=new BX.Landing.Collection.BaseCollection;this.description=BX.Landing.UI.Form.BaseForm.createDescription();this.header=BX.Landing.UI.Form.BaseForm.createHeader();this.body=BX.Landing.UI.Form.BaseForm.createBody();this.footer=BX.Landing.UI.Form.BaseForm.createFooter();this.header.innerHTML=this.title;this.layout.appendChild(this.header);if(this.descriptionText){this.description.innerHTML=this.descriptionText;this.layout.appendChild(this.description)}this.layout.appendChild(this.body);this.layout.appendChild(this.footer);var t=BX.Landing.Main.getInstance().options.sources;if(!BX.type.isArray(t)||t.length<1){this.headerCheckbox=null}if(this.headerCheckbox){this.adjustHeaderCheckbox()}};BX.Landing.UI.Form.BaseForm.createLayout=function(){return BX.create("div",{props:{className:"landing-ui-form"}})};BX.Landing.UI.Form.BaseForm.createHeader=function(){return BX.create("div",{props:{className:"landing-ui-form-header"}})};BX.Landing.UI.Form.BaseForm.createDescription=function(){return BX.create("div",{props:{className:"landing-ui-form-description"}})};BX.Landing.UI.Form.BaseForm.createBody=function(){return BX.create("div",{props:{className:"landing-ui-form-body"}})};BX.Landing.UI.Form.BaseForm.createFooter=function(){return BX.create("div",{props:{className:"landing-ui-form-footer"}})};BX.Landing.UI.Form.BaseForm.prototype={adjustHeaderCheckbox:function(){var e=this;var t=BX.create("div",{props:{className:"landing-form-header"},children:[BX.create("div",{props:{className:"landing-form-dynamic-block-header-text"},text:this.header.innerText}),BX.create("div",{props:{className:"landing-form-header-checkbox-wrapper"},children:[BX.create("input",{props:{type:"checkbox",id:this.id,className:"landing-form-header-checkbox-input"},attrs:!!this.headerCheckbox.state?{checked:true}:null,events:{change:function(){if(BX.type.isFunction(e.headerCheckbox.onChange)){e.headerCheckbox.onChange({state:this.checked,form:e})}}}}),BX.create("label",{props:{className:"landing-form-header-checkbox-label"},attrs:{for:this.id},text:this.headerCheckbox.text}),this.headerCheckbox.help?BX.create("div",{props:{className:"landing-form-header-checkbox-help"},events:{click:function(){top.open(this.headerCheckbox.help,"_blank")}.bind(this)}}):undefined]})]});this.header.innerHTML="";this.header.appendChild(t)},isDynamicEnabled:function(){var e=this.header.querySelector("input");return!!e&&e.checked},addField:function(e){this.fields.add(e);this.body.appendChild(e.getNode())},getNode:function(){return this.layout},addCard:function(t){this.cards.push(t);e(t.layout,this.body);t.fields.forEach(function(e){this.fields.add(e)},this)},replaceCard:function(e,t){if(e){e.fields.forEach(function(e){this.fields.remove(e)},this);this.cards.remove(e);i(e.layout)}this.addCard(t)},removeCard:function(e){if(e){e.fields.forEach(function(e){this.fields.remove(e)},this);this.cards.remove(e);i(e.layout)}},clone:function(e){var i=new this.constructor(t(e||this.data));this.fields.forEach(function(e){if(e instanceof BX.Landing.UI.Field.Date){var a=t(e.data);a.selector=i.selector;i.addField(e.clone(a))}else{i.addField(e.clone())}});return i},serialize:function(){var e={};this.fields.forEach(function(t){e[t.selector]=t.getValue()});return e}}})(); //# sourceMappingURL=base_form.map.js