PageSourceSearch

https://mx-sport36.ru/bitrix/templates/aspro_max/js/autoload/item-action.min.js?174038225811381

js mx-sport36.ru collected 2026-10-01 12:39:08 UTC 11,381 bytes, 1 lines download raw bytes

1void 0===window.JItemAction&&(JItemAction=function(t,e){t="object"==typeof t&&t&&t instanceof Node?t:null,e="object"==typeof e&&e?e:{},this.node=t;var o={inited:!1,data:null,config:{bindEvents:!0,changeState:!0,fireGoals:!0}};let n=Object.assign({},o.config,e);Object.defineProperties(this,{inited:{get:function(){return o.inited},set:function(t){t&&(o.inited=!0)}},config:{get:function(){return n}},data:{get:function(){let t=null;return this.valid&&(t=this.node.dataset),o.data&&(t=o.data),Object.assign({},t)},set:function(t){o.data=t}}}),this.init()},JItemAction.prototype={constructor:JItemAction,busy:!1,parentNode:null,prevState:null,activeClass:"added in",get class(){return this.constructor.name},get action(){return""},get requestUrl(){return`aspro:max.ItemAction.${this.action}`},get valid(){return this.node&&this.action},get state(){return!this.config.changeState||this.valid&&BX.hasClass(this.node,this.activeClass)},set state(t){if(this.valid&&this.config.changeState&&(this.node.removeAttribute("style"),t!=this.state)){t?BX.addClass(this.node,this.activeClass):BX.removeClass(this.node,this.activeClass);let e=this.getStateTitle(t);this.node.setAttribute("title",e);let o=this.node.querySelector(".info-buttons__item-text");if(o&&o.setAttribute("title",e),BX.hasClass(this.node,"btn")){const t=this.node.querySelector(".like-text");t&&(t.textContent=e)}}},init:function(){this.inited||(this.inited=!0,this.valid&&(this.node.itemAction=this,this.parentNode=this.node.parentElement,"Y"===this.data.offers&&(this.data=this.node.dataset),this.config.bindEvents&&(this.unbindAllEvents(),this.bindEvents())))},bindEvents:function(){this.valid&&"function"==typeof this.handlers.onClickNode&&BX.bind(this.node,"click",BX.proxy(this.handlers.onClickNode,this))},unbindEvents:function(){this.valid&&"function"==typeof this.handlers.onClickNode&&BX.unbind(this.node,"click",BX.proxy(this.handlers.onClickNode,this))},unbindAllEvents:function(){this.valid&&BX.unbindAll(this.node,"click")},fireEvent:function(t){if(this.valid&&!this.busy&&"object"==typeof t&&t){let e=t.type;e&&"click"===e&&BX.proxy(this.handlers.onClickNode,this)(t)}},isStateChanged:function(){return null!==this.prevState&&this.prevState!=this.state},isItemChanged:function(){return null!==this.node&&this.node.dataset.item!=this.data.item},getStateTitle:function(t){return this.valid?t?this.node.getAttribute("data-title_added")||"":this.node.getAttribute("data-title")||"":""},getStateGoalCode:function(t){return"goal_"+this.action+(t?"_add":"_remove")},showStateNotice:function(t){this.showNotice([this.node],t)},showNotice:function(t,e=1){if(this.valid&&"function"==typeof JNoticeSurface){let o=JNoticeSurface.get(),n="onAdd2"+this.action.replace(/^\w/,(t=>t.toUpperCase()));n&&"function"==typeof o[n]&&o[n](t,e)}},updateState:function(){this.valid&&!this.busy&&(this.busy=!0,this.node.blur(),this.prevState=this.state,this.sendRequest())},collectRequestData:async function(){const t={fields:{}};return t.fields=this.data,t.fields.state=Number(this.state),t},sendRequest:function(){this.valid&&this.collectRequestData().then((t=>{BX.ajax.runAction(this.requestUrl,{data:t}).then((e=>{"function"==typeof this.onRequestSuccess&&this.onRequestSuccess(e),"function"==typeof this.onRequestComplete&&this.onRequestComplete(t)}),(e=>{"function"==typeof this.onRequestFailure&&this.onRequestFailure(e),"function"==typeof this.onRequestComplete&&this.onRequestComplete(t)}))})).catch((()=>{setTimeout((()=>{this.isStateChanged()&&(this.state=this.prevState,this.prevState=null),this.parentNode&&BX.removeClass(this.parentNode,"loadings"),this.busy=!1}),0)}))},onRequestComplete:function(t){setTimeout((()=>{this.parentNode&&BX.removeClass(this.parentNode,"loadings"),this.busy=!1}),0)},onRequestSuccess:function(t){if("success"===t.status){if(this.action&&t.data){let e=this.action.toUpperCase();"object"!=typeof arAsproCounters&&(arAsproCounters={}),"object"!=typeof arAsproCounters[e]&&(arAsproCounters[e]={});const o=t.data;"items"in o&&(arAsproCounters[e].ITEMS=o.items),"count"in o&&(arAsproCounters[e].COUNT=o.count),"title"in o&&(arAsproCounters[e].TITLE=o.title),this.class&&"function"==typeof window[this.class]&&"function"==typeof window[this.class].markBadges&&window[this.class].markBadges();let n=this.state;this.class&&"function"==typeof window[this.class]&&"function"==typeof window[this.class].markItems&&window[this.class].markItems(),this.isStateChanged()&&(this.showStateNotice(n),this.config.fireGoals&&BX.onCustomEvent("onCounterGoals",[{goal:this.getStateGoalCode(n),params:{id:this.node.getAttribute("data-item")}}])),this.onCompleteEvent()}}else if(this.isStateChanged()&&(this.state=this.prevState),"function"==typeof JNoticeSurface){let e=JNoticeSurface.get();t.error=this.getMessageFromErrors(t.errors),e.onResultError&&e.onResultError(t)}},onRequestFailure:function(t){if(this.isStateChanged()&&(this.state=this.prevState),"function"==typeof JNoticeSurface){let e=JNoticeSurface.get();t.statusText=this.getMessageFromErrors(t.errors),e.onRequestError&&e.onRequestError(t)}},getMessageFromErrors:function(t){let e=[];return t.length&&t.forEach((t=>{e.push(t.message)})),e.join("<br>")},onCompleteEvent:function(){this.finalAction()},finalAction:function(){this.updateDropdownBlocks(this.action)},updateDropdownBlocks:function(t){document.querySelectorAll(`.dropdown-${t}`).forEach((t=>{t.classList.remove("loaded")}))},handlers:{onClickNode:function(t){if(this.valid&&!this.busy){t||(t=window.event);let e=t.target||t.srcElement;void 0!==e&&e&&(this.busy=!0,this.node.blur(),this.prevState=this.state,this.state=!this.state,this.sendRequest())}}}},JItemAction.checkItemAction=function(t){return t.itemAction&&t.itemAction instanceof JItemAction},JItemAction.getItemAction=function(t){return t.itemAction},JItemAction.factory=function(t,e){if("object"==typeof t&&t&&t instanceof Node){if(JItemAction.checkItemAction(t))return JItemAction.getItemAction(t);{let o=(t.getAttribute("data-action")||"").trim();if(o){let n="JItemAction"+o.replace(/^\w/,(t=>t.toUpperCase()));if("function"==typeof window[n])return new window[n](t,e)}}}return new window.JItemAction(t,e)},JItemActionFavorite=function(t,e){JItemAction.apply(this,arguments)},JItemActionFavorite.prototype=Object.create(JItemAction.prototype),JItemActionFavorite.prototype.constructor=JItemActionFavorite,Object.defineProperties(JItemActionFavorite.prototype,{action:{get:()=>"favorite"}}),JItemActionFavorite.prototype.getStateGoalCode=function(t){return"goal_wish"+(t?"_add":"_remove")},JItemActionFavorite.markBadges=function(){if("object"==typeof arAsproCounters&&arAsproCounters&&"object"==typeof arAsproCounters.FAVORITE&&arAsproCounters.FAVORITE&&void 0!==arAsproCounters.FAVORITE.COUNT){let t=Array.prototype.slice.call(document.querySelectorAll(".basket-link.delay .js-count"));if(t.length){for(let e in t)t[e].textContent=arAsproCounters.FAVORITE.COUNT,arAsproCounters.FAVORITE.COUNT>0?(BX.removeClass(t[e],"empted"),BX.addClass(t[e].closest(".basket-link.delay"),"basket-count"),BX.removeClass(t[e].closest(".basket-link.delay"),"counter-state--empty")):(BX.addClass(t[e],"empted"),BX.removeClass(t[e].closest(".basket-link.delay"),"basket-count"),BX.addClass(t[e].closest(".basket-link.delay"),"counter-state--empty"));JItemAction.prototype.updateDropdownBlocks(JItemActionFavorite.prototype.action)}}},JItemActionFavorite.markItems=function(){if("object"==typeof arAsproCounters&&arAsproCounters&&"object"==typeof arAsproCounters.FAVORITE&&arAsproCounters.FAVORITE&&"object"==typeof arAsproCounters.FAVORITE.ITEMS&&arAsproCounters.FAVORITE.ITEMS){let t=Array.prototype.slice.call(document.querySelectorAll('.js-item-action.added.in[data-action="favorite"]'));if(t.length)for(let e in t){let o=BX.data(t[e],"item");if(o&&(!arAsproCounters.FAVORITE.ITEMS[o]||"Y"===BX.data(t[e],"offers"))){let o=JItemAction.checkItemAction(t[e])?JItemAction.getItemAction(t[e]):"";"Y"===BX.data(t[e],"offers")&&o&&o.isItemChanged()&&(o=new this(t[e])),o||(o=new this(t[e])),o.state=!1}}if(arAsproCounters.FAVORITE.ITEMS)for(let t in arAsproCounters.FAVORITE.ITEMS){let e=arAsproCounters.FAVORITE.ITEMS[t],o=Array.prototype.slice.call(document.querySelectorAll('.js-item-action[data-action="favorite"][data-item="'+e+'"]:not(.added.in)'));if(o.length)for(let t in o){(JItemAction.checkItemAction(o[t])?JItemAction.getItemAction(o[t]):new this(o[t])).state=!0}}}},JItemActionCompare=function(t,e){JItemAction.apply(this,arguments)},JItemActionCompare.prototype=Object.create(JItemAction.prototype),JItemActionCompare.prototype.constructor=JItemActionCompare,Object.defineProperties(JItemActionCompare.prototype,{action:{get:()=>"compare"}}),JItemActionCompare.markItems=function(){if("object"==typeof arAsproCounters&&arAsproCounters&&"object"==typeof arAsproCounters.COMPARE&&arAsproCounters.COMPARE&&"object"==typeof arAsproCounters.COMPARE.ITEMS){let t=Array.prototype.slice.call(document.querySelectorAll('.js-item-action.added.in[data-action="compare"]'));if(t.length)for(let e in t){let o=BX.data(t[e],"item");if(o&&(!arAsproCounters.COMPARE.ITEMS[o]||"Y"===BX.data(t[e],"offers"))){let o=JItemAction.checkItemAction(t[e])?JItemAction.getItemAction(t[e]):"";"Y"===BX.data(t[e],"offers")&&o&&o.isItemChanged()&&(o=new this(t[e])),o||(o=new this(t[e])),o.state=!1}}if(arAsproCounters.COMPARE.ITEMS)for(let t in arAsproCounters.COMPARE.ITEMS){let e=arAsproCounters.COMPARE.ITEMS[t],o=Array.prototype.slice.call(document.querySelectorAll('.js-item-action[data-action="compare"][data-item="'+e+'"]:not(.added.in)'));if(o.length)for(let t in o){(JItemAction.checkItemAction(o[t])?JItemAction.getItemAction(o[t]):new this(o[t])).state=!0}}}},JItemActionCompare.markBadges=function(){if("object"==typeof arAsproCounters&&arAsproCounters&&"object"==typeof arAsproCounters.COMPARE&&arAsproCounters.COMPARE&&void 0!==arAsproCounters.COMPARE.COUNT){let t=Array.prototype.slice.call(document.querySelectorAll(".compare .js-count"));if(t.length){for(let e in t)t[e].textContent=arAsproCounters.COMPARE.COUNT,arAsproCounters.COMPARE.COUNT>0?(BX.removeClass(t[e],"empted"),BX.addClass(t[e].closest(".compare"),"basket-count"),BX.removeClass(t[e].closest(".compare"),"counter-state--empty")):(BX.addClass(t[e],"empted"),BX.removeClass(t[e].closest(".compare"),"basket-count"),BX.addClass(t[e].closest(".compare"),"counter-state--empty"));JItemAction.prototype.updateDropdownBlocks(JItemActionCompare.prototype.action)}}},JItemAction.actual=function(){"function"==typeof JItemActionFavorite&&(JItemActionFavorite.markItems(),JItemActionFavorite.markBadges()),"function"==typeof JItemActionCompare&&(JItemActionCompare.markItems(),JItemActionCompare.markBadges())},BX.bindDelegate(document,"click",{class:"js-item-action"},(function(t){t||(t=window.event),BX.PreventDefault(t);let e=t.target||t.srcElement;void 0!==e&&e&&(e.closest(".opt_action")||JItemAction.factory(this).fireEvent(t))})),BX.addCustomEvent("onCompleteAction",(function(t){try{"ajaxContentLoaded"===t.action&&JItemAction.actual()}catch(t){}})),BX.addCustomEvent("onSetBasketStatusBtn",(function(t){JItemAction.actual()})),BX.addCustomEvent("onSetItemButtonStatus",(function(t){JItemAction.actual()})),BX.addCustomEvent("onAjaxResponesTabs",(function(t){JItemAction.actual(),setBasketStatusBtn(!0)})),BX.addCustomEvent("onFinalActionSKUInfo",(function(t){JItemAction.actual()})));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.