%PDF- %PDF-
Direktori : /home/bitrix/www/bitrix/components/bitrix/catalog.product.search/templates/.default/ |
Current File : /home/bitrix/www/bitrix/components/bitrix/catalog.product.search/templates/.default/script.min.js |
BX.namespace("BX.Catalog");BX.Catalog.ProductSearchDialog=function(){var e=function(e){this.callback=null;this.event=null;this.tableId=e.tableId;if(typeof e.event!=="undefined"){this.event=e.event}else if(typeof e.callback!=="undefined"){this.callback=e.callback}this.callerName=e.callerName;this.currentUri=e.currentUri;this.popup=e.popup;this.iblockName=e.iblockName;this.searchTimer=null;this.ignoreFilter=true;var t=this,a=function(e){var n=!!BX(t.tableId+"_reload_container");if(n){if(!e.altKey&&!e.ctrlKey&&!e.metaKey&&document.activeElement.tagName!=="INPUT"&&document.activeElement.tagName!=="SELECT"&&document.activeElement.tagName!=="TEXTAREA"){if(e.keyCode>=48&&e.keyCode<=90||e.keyCode>=96&&e.keyCode<=105||e.keyCode==219||e.keyCode==221){BX(t.tableId+"_query").focus()}}}else if(document.removeEventListener)document.removeEventListener("keydown",a);else document.detachEvent("onkeydown",a)};if(document.addEventListener)document.addEventListener("keydown",a);else if(document.attachEvent)document.attachEvent("onkeydown",a)};e.prototype.getIblockId=function(){return BX(this.tableId+"_iblock").value};e.prototype.getForm=function(){return BX(this.tableId+"_form")};e.prototype.SelEl=function(e,t){var a,n;if(BX.hasClass(t,"adm-list-table-row")){BX.addClass(t,"row-sku-selected")}else{n=BX.findParent(t,{className:"adm-list-table-row"});if(BX.type.isElementNode(n))BX.addClass(n,"row-sku-selected");n=null}if(typeof e["quantity"]==="undefined")e["quantity"]=1;a=BX(this.tableId+"_qty_"+e["id"]);if(!!a)e["quantity"]=a.value;if(!!this.event){if(typeof e.IBLOCK_ID==="undefined")e.IBLOCK_ID=this.getIblockId();BX.onCustomEvent(this.event,[e])}else if(!!this.callback){window[this.callback](e,this.getIblockId())}};e.prototype.fShowSku=function(e,t){var a,n,i=BX.hasClass(t,"is-expand");if(!BX.type.isArray(e)||e.length<1)return false;for(a=0;a<e.length;a++){n=BX(this.tableId+"_sku-"+e[a]);if(BX.type.isElementNode(n)){if(!i)BX.show(n.parentNode.parentNode);else BX.hide(n.parentNode.parentNode)}n=null}BX.toggleClass(t,"is-expand");return false};e.prototype.onSubmitForm=function(){var e=this.buildUrl();window[this.tableId].GetAdminList(e);return false};e.prototype.onSearch=function(e,t){var a=BX(this.tableId+"_query_value"),n=a.value;if(n===e)return false;a.value=e;var i=this;if(this.searchTimer!=null)clearTimeout(this.searchTimer);this.searchTimer=setTimeout(function(){if(e.length===0||e.length>2){i.onSubmitForm()}BX(i.tableId+"_query_clear").style.display=e.length===0?"none":"inline";BX(i.tableId+"_query_clear_separator").style.display=e.length===0?"none":"inline-block";i.searchTimer=null},t||300);return true};e.prototype.clearQuery=function(){var e=BX(this.tableId+"_query"),t=e.value;e.value="";if(t.length>2)this.onSearch("",10);return false};e.prototype.checkSubstring=function(){var e=BX(this.tableId+"_query_substring"),t=BX(this.tableId+"_query_substring_value");if(BX.type.isElementNode(e)&&BX.type.isElementNode(t)){t.value=e.checked?"Y":"N";return true}return false};e.prototype.search=function(){var e=BX(this.tableId+"_query_value"),t=BX(this.tableId+"_query");if(BX.type.isElementNode(e)&&BX.type.isElementNode(t)){e.value=t.value;this.onSubmitForm()}};e.prototype.onIblockChange=function(e,t){var a=this,n=this.buildUrl({action:"change_iblock",IBLOCK_ID:e,SECTION_ID:0});if(t)a.iblockName=t;BX.ajax.get(n,null,BX.proxy(function(e){BX(a.tableId+"_reload_container").innerHTML=e},this));BX(this.tableId+"_section_label").style.display="none";return false};e.prototype.onSectionClick=function(e,t){BX(this.tableId+"_section_id").value=e;this.onSubmitForm();var a=BX.findChildren(BX(this.tableId+"_catalog_tree_wrap"),{className:"adm-submenu-item-active"},true);BX.removeClass(a[0],"adm-submenu-item-active");var n=BX(this.tableId+"_section_"+e);if(n){BX.addClass(n.parentNode,"adm-submenu-item-active");if(!BX.hasClass(n.parentNode,"adm-sub-submenu-open")){var i=BX.findChild(n,{className:"adm-submenu-item-arrow"});if(i)i.click()}}if(!t&&n){var s=BX.findChild(BX(this.tableId+"_section_"+e).parentNode,{className:"adm-submenu-item-name-link-text"},true);t=s.innerHTML}var l=BX(this.tableId+"_section_label");l.innerHTML=e!="0"?t+' <span class="adm-s-search-tag-del" onclick="return '+this.tableId+'_helper.onSectionClick(0)"></span>':"";l.style.display=e!="0"?"inline-block":"none";return false};e.prototype.toggleSection=function(e){var t=!BX.hasClass(e,"adm-sub-submenu-open");BX[t?"addClass":"removeClass"](e,"adm-sub-submenu-open");return t};e.prototype.toggleDynSection=function(e,t,a,n,i){var s=BX.findChild(t,{className:"adm-sub-submenu-block-children"});if(s.hasChildNodes()){this.toggleSection(t,a,n);return}var l=false;var o=BX.create("SPAN",{props:{className:"adm-submenu-loading adm-sub-submenu-block"},style:{marginLeft:parseInt(e)+"px"},text:BX.message("JS_CORE_LOADING")});setTimeout(BX.proxy(function(){if(!l){s.appendChild(o);this.toggleSection(t,a,n)}},this),200);var r=this,c=this.currentUri+"?action=open_section&lang="+BX.message("LANGUAGE_ID")+"§ion_id="+a+"&IBLOCK_ID="+r.getIblockId()+"&caller="+this.callerName+"&level="+n+"&active_id="+(i?i:0);BX.ajax.get(c,BX.proxy(function(e){l=true;e=BX.util.trim(e);if(e!=""){var i=o.parentNode?true:false;s.innerHTML=e;if(!i)this.toggleSection(t,a,n)}else{o.innerHTML=BX.message("JS_CORE_NO_DATA");if(!o.parentNode){s.appendChild(o);this.toggleSection(t,a,n)}}},this))};e.prototype.openBranchByPath=function(e){var t=e.pop();for(var a=0;a<e.length;++a){var n=BX(this.tableId+"_section_"+e[a]);if(n){var i=parseInt(n.getAttribute("data-level"))+1,s=n.getAttribute("data-offset"),l=n.parentNode;if(BX.hasClass(l,"adm-sub-submenu-open"))continue;var o=BX.findChild(l,{className:"adm-sub-submenu-block-children"});if(o.hasChildNodes()){this.toggleSection(l,e[a],i)}else{this.toggleDynSection(s,l,e[a],i,t);break}}}};e.prototype.setBreadcrumbs=function(e){var t=this.iblockName,a=['<a class="adm-navchain-item adm-navchain-item-desktop" href="#" onclick="return '+this.tableId+'_helper.onSectionClick(0)">'+BX.util.htmlspecialchars(t)+"</a>"],n=[];for(var i in e){if(e.hasOwnProperty(i)){n.push(e[i].ID);a.push('<a class="adm-navchain-item adm-navchain-item-desktop" href="#" onclick="return '+this.tableId+"_helper.onSectionClick("+e[i].ID+')">'+BX.util.htmlspecialchars(e[i].NAME)+"</a>");t=e[i].NAME}}this.popup.SetTitle(BX.util.htmlspecialcharsback(t));BX(this.tableId+"_breadcrumbs").innerHTML=a.join('<span class="adm-navchain-delimiter"></span>');this.openBranchByPath(n)};e.prototype.setIgnoreFilter=function(e){this.ignoreFilter=!!e};e.prototype.buildUrl=function(e){var t=BX.ajax.prepareForm(this.getForm()),a=[],n;for(n in t.data){if(t.data.hasOwnProperty(n)&&t.data[n]){if(this.ignoreFilter&&n.indexOf("filter_")===0)continue;a.push(encodeURIComponent(n)+"="+encodeURIComponent(t.data[n]))}}if(BX.type.isPlainObject(e)){for(n in e){if(e.hasOwnProperty(n)&&e[n]){a.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]))}}}return this.currentUri+"?"+a.join("&",a)};return e}();