Your IP : 18.222.118.188


Current Path : /var/www/www-root/data/www/monolith-realty.ru/bitrix/js/aspro.allcorp3/property/
Upload File :
Current File : /var/www/www-root/data/www/monolith-realty.ru/bitrix/js/aspro.allcorp3/property/tariffitem.min.js

void 0===window.JTariffItem&&(window.JTariffItem=function(tableId){this.tableId=tableId,this.table=!1,this.tbody=!1,this.eventListners=[],this.init()},window.JTariffItem.prototype={init:function(){var that=this;BX.ready((function(){(that.table=BX(that.tableId))&&(that.table.tariffitem=that,that.tbody=that.table.querySelector("tbody"),that.updateControls(),that.bindEvents())}))},bindEvents:function(){var that=this;"function"!=typeof that.onButtonDeleteClick&&that.table&&(that.onButtonDeleteClick=function(e){var table;if(e||(e=window.event),BX.PreventDefault(e),this.closest("#"+that.tableId)){var item=this.closest(".aspro_property_tariffitem_item");if(item){var row=item.closest("tr");if(row)if(that.isHasOneRow()){var inputs=Array.prototype.slice.call(row.querySelectorAll("input"));for(var i in inputs)inputs[i].value="";that.updateControls()}else{var wrapper=item.querySelector(".wrapper");wrapper&&BX.addClass(wrapper,"no_drag"),BX.addClass(item,"aspro_property_tariffitem_item--deleted"),setTimeout((function(){BX.remove(row),that.updateControls()}),490)}}}},BX.bindDelegate(that.table,"click",{class:"remove"},that.onButtonDeleteClick),"function"==typeof Sortable&&that.tbody&&Sortable.create(that.tbody,{handle:".drag",animation:150,forceFallback:!0,filter:".no_drag",onStart:function(evt){BX.addClass(document.body,"no-trz"),window.getSelection().removeAllRanges()},onEnd:function(evt){BX.removeClass(document.body,"no-trz")},onMove:function(evt){return null===evt.related.querySelector(".no_drag")&&null!==evt.related.querySelector(".aspro_property_tariffitem_item")},onUpdate:function(evt){try{var keys=[],inputsNames=[],rows=Array.prototype.slice.call(that.tbody.querySelectorAll("tr"));for(var j in rows){keys.push(1*j);var names=[],inputs=Array.prototype.slice.call(rows[j].querySelectorAll("input"));for(var k in inputs)names.push(inputs[k].getAttribute("name"));inputsNames.push(names)}var k=evt.oldIndex;do{keys[k]=k==evt.oldIndex?evt.newIndex:evt.newIndex>evt.oldIndex?k-1:k+1,evt.newIndex>evt.oldIndex?++k:--k}while(evt.newIndex>evt.oldIndex?k<=evt.newIndex:k>=evt.newIndex);for(var j in rows)if(keys[j]!=j){var inputs=Array.prototype.slice.call(rows[j].querySelectorAll("input"));for(var k in inputs)inputs[k].setAttribute("name",inputsNames[keys[j]][k])}}catch(e){console.error(e)}}}),window.JTariffItem._bindTitleChange(that.table))},unbindEvents:function(){"function"==typeof this.onButtonDeleteClick&&this.table&&this.table.removeEventListener("click",this.onButtonDeleteClick)},getItemsCount:function(){return this.table?Array.prototype.slice.call(this.table.querySelectorAll("tr .aspro_property_tariffitem_item")).length-Array.prototype.slice.call(this.table.querySelectorAll("tr .aspro_property_tariffitem_item>.wrapper.has_title")).length:0},isHasOneRow:function(){return 1===this.getItemsCount()},updateControls:function(){if(this.table)if(this.isHasOneRow()){var rows=Array.prototype.slice.call(this.table.querySelectorAll("tr"));for(var i in rows){var item=rows[i].querySelector(".aspro_property_tariffitem_item");if(item&&!item.querySelector(".wrapper.has_title"))return void BX.addClass(item,"aspro_property_tariffitem_item--hiddendrag")}}else BX.removeClass(this.table.querySelector(".aspro_property_tariffitem_item--hiddendrag"),"aspro_property_tariffitem_item--hiddendrag")}},window.JTariffItem._parseEmail=function(email){var re=/(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/,matches=email.toLowerCase().match(re);return matches?matches[0]:""},window.JTariffItem._setHref=function(title,href){if(title&&"object"==typeof title&&href&&"object"==typeof href){var href_value=href.value.trim(),bCanSet;if(!href_value.length||0===href_value.indexOf("mailto:")||0===href_value.indexOf("tel:")){href_value="";var title_value=title.value.trim(),email=window.JTariffItem._parseEmail(title_value);if(email.length)href_value="mailto:"+email;else{var phone=title_value.replace(/[^+0-9]/g,""),bPlus="+"===phone[0];(phone=phone.replace(/[^0-9]/g,"")).length&&(phone=(bPlus?"+":"")+phone).length&&(href_value="tel:"+phone)}href.value=href_value}}},window.JTariffItem._bindTitleChange=function(table){table&&"object"==typeof table&&(BX.bindDelegate(table,"keydown",{tag:"input",attribute:{type:"text"}},(function(e){if(e||(e=window.event),255!=e.which&&-1!==this.getAttribute("name").indexOf("VALUE")&&-1!==this.getAttribute("name").indexOf("PHONE")){var inner_wrapper=this.closest(".inner_wrapper");if(inner_wrapper){var inputs=Array.prototype.slice.call(inner_wrapper.querySelectorAll("input[type=text]"));if(inputs)for(var i in inputs)if(-1!==inputs[i].getAttribute("name").indexOf("HREF")){var href=inputs[i],title=this;setTimeout((function(){window.JTariffItem._setHref(title,href)}),50);break}}}})),BX.bindDelegate(table,"cut",{tag:"input",attribute:{type:"text"}},(function(e){if(e||(e=window.event),-1!==this.getAttribute("name").indexOf("VALUE")&&-1!==this.getAttribute("name").indexOf("PHONE")){var inner_wrapper=this.closest(".inner_wrapper");if(inner_wrapper){var inputs=Array.prototype.slice.call(inner_wrapper.querySelectorAll("input[type=text]"));if(inputs)for(var i in inputs)if(-1!==inputs[i].getAttribute("name").indexOf("HREF")){var href=inputs[i],title=this;setTimeout((function(){window.JTariffItem._setHref(title,href)}),50);break}}}})),BX.bindDelegate(table,"paste",{tag:"input",attribute:{type:"text"}},(function(e){if(e||(e=window.event),-1!==this.getAttribute("name").indexOf("VALUE")&&-1!==this.getAttribute("name").indexOf("PHONE")){var inner_wrapper=this.closest(".inner_wrapper");if(inner_wrapper){var inputs=Array.prototype.slice.call(inner_wrapper.querySelectorAll("input[type=text]"));if(inputs)for(var i in inputs)if(-1!==inputs[i].getAttribute("name").indexOf("HREF")){var href=inputs[i],title=this;setTimeout((function(){window.JTariffItem._setHref(title,href)}),50);break}}}})))},BX.ready((function(){BX.addCustomEvent(window,"onAddNewRowBeforeInner",(function(htmlObject){if(htmlObject&&"object"==typeof htmlObject&&htmlObject.html&&htmlObject.html.length&&-1!==htmlObject.html.indexOf("aspro_property_tariffitem_item")){var row=BX.create({tag:"div",html:htmlObject.html}),inputs=Array.prototype.slice.call(row.querySelectorAll("input"));for(var i in inputs)inputs[i].value="",inputs[i].setAttribute("value","");htmlObject.html=row.innerHTML.replace("aspro_property_tariffitem_item--hiddendrag","");var name=htmlObject.html.match(new RegExp('name="([^"]+)"',"")),bAdminList,valueId,valueId;if(null!==name)if(name[1].match(new RegExp("^FIELDS\\[","")))null===(valueId=name[1].match(new RegExp("FIELDS\\[([^\\]]*)\\]\\[(PROPERTY_\\d+)\\]\\[(n\\d+)\\]","i")))&&(htmlObject.html=htmlObject.html.replace(new RegExp("FIELDS\\[([^\\]]*)\\]\\[(PROPERTY_\\d+)\\]\\[([^\\]]*)\\]","ig"),"FIELDS[$1][$2][n0]"));else null===(valueId=name[1].match(new RegExp("PROP\\[\\d+\\]\\[(n\\d+)\\]","i")))&&(htmlObject.html=htmlObject.html.replace(new RegExp("PROP\\[(\\d+)\\]\\[([^\\]]*)\\]","ig"),"PROP[$1][n0]"));name=htmlObject.html.match(new RegExp('name="([^"]+)"',"")),BX.remove(row),setTimeout((function(){var input=document.querySelector('input[name="'+name[1]+'"]');if(input){var table=input.closest("table");table&&"object"==typeof table.tariffitem&&table.tariffitem&&table.tariffitem.updateControls()}}),100)}})),BX.addCustomEvent(window,"grid::thereeditedrows",(function(){var adminRows=BX.Main.gridManager.data[0].instance.rows.getSelected();for(var i in adminRows){var adminRow=adminRows[i].node;if(adminRow){var tablesIds=[],items=Array.prototype.slice.call(adminRow.querySelectorAll(".aspro_property_tariffitem_item--admlistedit"));for(var i in items){var table=items[i].closest("table");table&&void 0===table.tariffitem&&new JTariffItem(table.id)}}}}))})));
//# sourceMappingURL=tariffitem.min.js.map