Your IP : 18.116.10.48


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

(function(){"use strict";BX.namespace("BX.Landing.UI.Card");var a=BX.Landing.Utils.addClass;var i=BX.Landing.Utils.removeClass;var t=BX.Landing.Utils.hasClass;var n=BX.Landing.Utils.append;var e=BX.Landing.Utils.create;var r=BX.Landing.Utils.data;var s=BX.Landing.Utils.slice;var d=BX.Landing.Utils.Show;var c=BX.Landing.Utils.Hide;var h=BX.Landing.Collection.BaseCollection;BX.Landing.UI.Card.TabCard=function(i){BX.Landing.UI.Card.BaseCard.apply(this,arguments);a(this.layout,"landing-ui-card-tabs");this.fields=new h;this.tabs=[];this.headersArea=e("div",{props:{className:"landing-ui-card-tabs-headers"}});this.tabsArea=e("div",{props:{className:"landing-ui-card-tabs-tabs"}});n(this.headersArea,this.layout);n(this.tabsArea,this.layout);i.tabs.forEach(this.addTab,this);this.render();var t=i.tabs.find(function(a){return a.active===true});if(!t){t=i.tabs[0]}this.activateTab(t.id)};BX.Landing.UI.Card.TabCard.prototype={constructor:BX.Landing.UI.Card.TabCard,__proto__:BX.Landing.UI.Card.BaseCard.prototype,addTab:function(a){this.tabs.push({id:a.id,name:a.name,fields:a.fields.map(function(a){return a.layout})});a.fields.forEach(function(a){this.fields.push(a)},this)},render:function(){this.headersArea.innerHTML="";this.tabsArea.innerHTML="";this.tabs.forEach(function(a,i){n(this.createHeader({id:a.id,name:a.name}),this.headersArea);n(this.createTab({id:a.id,fields:a.fields}),this.tabsArea)},this)},createHeader:function(a){return e("div",{props:{className:"landing-ui-card-tabs-headers-item"},text:a.name,attrs:{"data-id":a.id},events:{click:this.onHeaderClick.bind(this)}})},onHeaderClick:function(a){a.preventDefault();if(!this.isActive(a.currentTarget)){this.activateTab(r(a.currentTarget,"data-id"))}},isActive:function(a){return t(a,"landing-ui-active")},activateTab:function(t){s(this.headersArea.children).forEach(function(a){i(a,"landing-ui-active")});s(this.tabsArea.children).forEach(function(a){i(a,"landing-ui-active");c(a)});var n=this.getHeader(t);var e=this.getTab(t);if(n){a(n,"landing-ui-active")}if(e){d(e).then(function(){a(e,"landing-ui-active")})}},createTab:function(a){return e("div",{props:{className:"landing-ui-card-tabs-tabs-item landing-ui-hide"},children:a.fields,attrs:{"data-id":a.id}})},getHeader:function(a){return s(this.headersArea.children).find(function(i){return r(i,"data-id")===a})},getTab:function(a){return s(this.tabsArea.children).find(function(i){return r(i,"data-id")===a})}}})();