PageSourceSearch

https://ichehol.ru/bitrix/templates/aspro_max/js/autoload/item-action.min.js?169620283810067

js ichehol.ru collected 2026-10-06 15:25:18 UTC 10,067 bytes, 1 lines download raw bytes

1void 0===window.JItemAction&&(JItemAction=function(node,config){node="object"==typeof node&&node&&node instanceof Node?node:null,config="object"==typeof config&&config?config:{},this.node=node;var _private={inited:!1,data:null,config:{bindEvents:!0,changeState:!0,fireGoals:!0}};let _config=Object.assign({},_private.config,config);Object.defineProperties(this,{inited:{get:function(){return _private.inited},set:function(value){value&&(_private.inited=!0)}},config:{get:function(){return _config}},data:{get:function(){let data=null;return this.valid&&(data=this.node.dataset),_private.data&&(data=_private.data),Object.assign({},data)},set:function(data){_private.data=data}}}),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(value){if(this.valid&&this.config.changeState&&(this.node.removeAttribute("style"),value!=this.state)){value?BX.addClass(this.node,this.activeClass):BX.removeClass(this.node,this.activeClass);let title=this.getStateTitle(value);this.node.setAttribute("title",title);let button=this.node.querySelector(".info-buttons__item-text");if(button&&button.setAttribute("title",title),BX.hasClass(this.node,"btn")){const $likeText=this.node.querySelector(".like-text");$likeText&&($likeText.textContent=title)}}},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(event){if(this.valid&&!this.busy&&"object"==typeof event&&event){let eventType=event.type;eventType&&"click"===eventType&&BX.proxy(this.handlers.onClickNode,this)(event)}},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(state){return this.valid?state?this.node.getAttribute("data-title_added")||"":this.node.getAttribute("data-title")||"":""},getStateGoalCode:function(state){return"goal_"+this.action+(state?"_add":"_remove")},showStateNotice:function(state){this.showNotice([this.node],state)},showNotice:function(items,state=1){if(this.valid&&"function"==typeof JNoticeSurface){let surface=JNoticeSurface.get(),actionCapitalize,noticeFunc="onAdd2"+this.action.replace(/^\w/,c=>c.toUpperCase());noticeFunc&&"function"==typeof surface[noticeFunc]&&surface[noticeFunc](items,state)}},updateState:function(){this.valid&&!this.busy&&(this.busy=!0,this.node.blur(),this.prevState=this.state,this.sendRequest())},collectRequestData:async function(){const data={fields:{}};return data.fields=this.data,data.fields.state=Number(this.state),data},sendRequest:function(){this.valid&&this.collectRequestData().then(data=>{BX.ajax.runAction(this.requestUrl,{data:data}).then(response=>{"function"==typeof this.onRequestSuccess&&this.onRequestSuccess(response),"function"==typeof this.onRequestComplete&&this.onRequestComplete(data)},response=>{"function"==typeof this.onRequestFailure&&this.onRequestFailure(response),"function"==typeof this.onRequestComplete&&this.onRequestComplete(data)})}).catch(()=>{setTimeout(()=>{this.isStateChanged()&&(this.state=this.prevState,this.prevState=null),this.parentNode&&BX.removeClass(this.parentNode,"loadings"),this.busy=!1},0)})},onRequestComplete:function(config){setTimeout(()=>{this.parentNode&&BX.removeClass(this.parentNode,"loadings"),this.busy=!1},0)},onRequestSuccess:function(response){if("success"===response.status){if(this.action&&response.data){let actionUpper=this.action.toUpperCase();"object"!=typeof arAsproCounters&&(arAsproCounters={}),"object"!=typeof arAsproCounters[actionUpper]&&(arAsproCounters[actionUpper]={});const data=response.data;"items"in data&&(arAsproCounters[actionUpper].ITEMS=data.items),"count"in data&&(arAsproCounters[actionUpper].COUNT=data.count),"title"in data&&(arAsproCounters[actionUpper].TITLE=data.title),this.class&&"function"==typeof window[this.class]&&"function"==typeof window[this.class].markBadges&&window[this.class].markBadges();let state=this.state;this.class&&"function"==typeof window[this.class]&&"function"==typeof window[this.class].markItems&&window[this.class].markItems(),this.isStateChanged()&&(this.showStateNotice(state),this.config.fireGoals&&BX.onCustomEvent("onCounterGoals",[{goal:this.getStateGoalCode(state),params:{id:this.node.getAttribute("data-item")}}])),this.onCompleteEvent()}}else if(console.error(response),this.isStateChanged()&&(this.state=this.prevState),"function"==typeof JNoticeSurface){let surface=JNoticeSurface.get();response.error=this.getMessageFromErrors(response.errors),surface.onResultError&&surface.onResultError(response)}},onRequestFailure:function(xhr){if(this.isStateChanged()&&(this.state=this.prevState),"function"==typeof JNoticeSurface){let surface=JNoticeSurface.get();xhr.statusText=this.getMessageFromErrors(xhr.errors),surface.onRequestError&&surface.onRequestError(xhr)}},getMessageFromErrors:function(errors){let messages=[];
1return errors.length&&errors.forEach(error=>{messages.push(error.message)}),messages.join("<br>")},onCompleteEvent:function(){},handlers:{onClickNode:function(event){if(this.valid&&!this.busy){event||(event=window.event);let target=event.target||event.srcElement;void 0!==target&&target&&(this.busy=!0,this.node.blur(),this.prevState=this.state,this.state=!this.state,this.sendRequest())}}}},JItemAction.checkItemAction=function(node){return node.itemAction&&node.itemAction instanceof JItemAction},JItemAction.getItemAction=function(node){return node.itemAction},JItemAction.factory=function(node,config){if("object"==typeof node&&node&&node instanceof Node){if(JItemAction.checkItemAction(node))return JItemAction.getItemAction(node);{let action=(node.getAttribute("data-action")||"").trim();if(action){let actionCapitalize,className="JItemAction"+action.replace(/^\w/,c=>c.toUpperCase());if("function"==typeof window[className])return new window[className](node,config)}}}return new window.JItemAction(node,config)},JItemActionFavorite=function(node,config){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(state){return"goal_wish"+(state?"_add":"_remove")},JItemActionFavorite.markBadges=function(){if("object"==typeof arAsproCounters&&arAsproCounters&&"object"==typeof arAsproCounters.FAVORITE&&arAsproCounters.FAVORITE&&void 0!==arAsproCounters.FAVORITE.COUNT){let blocks=Array.prototype.slice.call(document.querySelectorAll(".basket-link.delay .js-count"));if(blocks.length)for(let i in blocks)blocks[i].textContent=arAsproCounters.FAVORITE.COUNT,arAsproCounters.FAVORITE.COUNT>0?(BX.removeClass(blocks[i],"empted"),BX.addClass(blocks[i].closest(".basket-link.delay"),"basket-count"),BX.removeClass(blocks[i].closest(".basket-link.delay"),"counter-state--empty")):(BX.addClass(blocks[i],"empted"),BX.removeClass(blocks[i].closest(".basket-link.delay"),"basket-count"),BX.addClass(blocks[i].closest(".basket-link.delay"),"counter-state--empty"))}},JItemActionFavorite.markItems=function(){if("object"==typeof arAsproCounters&&arAsproCounters&&"object"==typeof arAsproCounters.FAVORITE&&arAsproCounters.FAVORITE&&"object"==typeof arAsproCounters.FAVORITE.ITEMS&&arAsproCounters.FAVORITE.ITEMS){let blocks=Array.prototype.slice.call(document.querySelectorAll('.js-item-action.added.in[data-action="favorite"]'));if(blocks.length)for(let y in blocks){let id=BX.data(blocks[y],"item");if(id&&(!arAsproCounters.FAVORITE.ITEMS[id]||"Y"===BX.data(blocks[y],"offers"))){let itemAction=JItemAction.checkItemAction(blocks[y])?JItemAction.getItemAction(blocks[y]):"";"Y"===BX.data(blocks[y],"offers")&&itemAction&&itemAction.isItemChanged()&&(itemAction=new this(blocks[y])),itemAction||(itemAction=new this(blocks[y])),itemAction.state=!1}}if(arAsproCounters.FAVORITE.ITEMS)for(let i in arAsproCounters.FAVORITE.ITEMS){let id=arAsproCounters.FAVORITE.ITEMS[i],blocks=Array.prototype.slice.call(document.querySelectorAll('.js-item-action[data-action="favorite"][data-item="'+id+'"]:not(.added.in)'));if(blocks.length)for(let y in blocks){let itemAction;(JItemAction.checkItemAction(blocks[y])?JItemAction.getItemAction(blocks[y]):new this(blocks[y])).state=!0}}}},JItemAction.actual=function(){"function"==typeof JItemActionFavorite&&(JItemActionFavorite.markItems(),JItemActionFavorite.markBadges())},BX.bindDelegate(document,"click",{class:"js-item-action"},(function(event){event||(event=window.event),BX.PreventDefault(event);let target=event.target||event.srcElement;void 0!==target&&target&&(target.closest(".opt_action")||JItemAction.factory(this).fireEvent(event))})),BX.addCustomEvent("onCompleteAction",(function(eventdata){try{"ajaxContentLoaded"===eventdata.action&&JItemAction.actual()}catch(e){console.error(e)}})),BX.addCustomEvent("onSetBasketStatusBtn",(function(eventdata){JItemAction.actual()})),BX.addCustomEvent("onSetItemButtonStatus",(function(eventdata){JItemAction.actual()})),BX.addCustomEvent("onAjaxResponesTabs",(function(eventdata){JItemAction.actual()})),BX.addCustomEvent("onFinalActionSKUInfo",(function(eventdata){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.