%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/bitrix/www/bitrix/js/sale/admin/discountpreset/
Upload File :
Create Path :
Current File : //home/bitrix/www/bitrix/js/sale/admin/discountpreset/select_product_preset.min.js

BX.namespace("BX.Sale.Admin.DiscountPreset");BX.Sale.Admin.DiscountPreset.SelectProduct=function(){var t=function(t){this.tableId="sale_discount_preset_product_table";this.emptyRowId="sale_discount_preset_product_table_empty_row";this.idPrefix="idPrefix";this.siteId=t.siteId;this.presetId=t.presetId;this.sectionCount=t.sectionCount||1;this.inputNameProduct=t.inputNameProduct||"discount_product[]";this.inputNameSection=t.inputNameSection||"discount_section[]";this.container=BX("sale_discount_preset_section_box");this.productIds={};if(t.products){for(var e in t.products){if(!t.products.hasOwnProperty(e))continue;this.productAdd(t.products[e])}}setTimeout(BX.delegate(function(){var t=BX.findChildrenByClassName(this.container,"mli-field",true);for(var e in t){if(!t.hasOwnProperty(e)){continue}BX.adjust(t[e],{style:{width:"99%"}})}},this),200);this.setEvents()};t.prototype.setEvents=function(){BX.bind(BX("sale_discount_preset_section_add"),"click",BX.delegate(this.onClickAddSection,this));BX.bind(BX("sale_discount_preset_product_add"),"click",BX.delegate(this.onClickAddProduct,this));BX.addCustomEvent("onDeletePresetProduct",BX.delegate(this.onDeletePresetProduct,this))};t.prototype.onClickSectionToShowPopup=function(t){var e=t.srcElement||t.target;var i=e.getAttribute("data-section-number");var r="cat_section_search.php?land=ru&discount=Y&n=sect_"+i;window.open(r,"","scrollbars=yes,resizable=yes,width=900,height=600,top="+parseInt((screen.height-500)/2-14,10)+",left="+parseInt((screen.width-600)/2-5,10));BX.PreventDefault(t)};t.prototype.onClickDeleteSection=function(t){var e=t.srcElement||t.target;var i=BX.findParent(e,{tagName:"tr"},10);if(i){BX.remove(i)}BX.PreventDefault(t)};t.prototype.onDeletePresetProduct=function(t){var e=BX(this.createProductRowId({PRODUCT_ID:t}));this.productIds[t]=false;BX.remove(e);if(BX.findChildren(BX(this.tableId),{tagName:"tbody"}).length===1){BX.show(BX(this.emptyRowId),"block")}};t.prototype.createProductRowId=function(t){return this.idPrefix+"discount-preset-product-"+(t.OFFER_ID||t.PRODUCT_ID)};t.prototype.createProductMenuContent=function(t){return[{ICON:"delete",TEXT:BX.message("JS_SALE_HANDLERS_DISCOUNTPRESET_DELETE_PRODUCT"),ACTION:"BX.onCustomEvent('onDeletePresetProduct', ["+t+"])"}]};t.prototype.createMenuCell=function(t,e){var i,r=this.createProductMenuContent(e.OFFER_ID||e.PRODUCT_ID);if(r.length<=0)return false;if(e.IS_SET_ITEM!="Y"){i=BX.create("span",{props:{className:"adm-s-order-item-title-icon"}});BX.bind(i,"click",BX.proxy(function(t){i.blur();BX.adminList.ShowMenu(i,r)},this))}else{i=BX.create("span",{html:"&nbsp;"})}return BX.create("td",{props:{className:"tac bdb-line",id:this.idPrefix+"sale-order-basket-product-"+t+"-menu"},children:[i]})};t.prototype.createFieldImage=function(t,e,i){var r,s;if(e.PICTURE_URL){r=BX.create("img",{props:{src:e.PICTURE_URL}})}else{r=BX.create("div",{props:{className:"no_foto"},text:BX.message("SALE_ORDER_BASKET_NO_PICTURE")})}if(typeof e.EDIT_PAGE_URL!="undefined"){s=BX.create("a",{props:{href:e.EDIT_PAGE_URL?e.EDIT_PAGE_URL:"",target:"_blank"},children:[r]});s.style.textAlign="center"}else{s=BX.create("div",{style:{width:"150px",textAlign:"center"},children:[r]})}return s};t.prototype.createFieldSkuProps=function(t,e,i){return this.createSkuPropsTable(t,e)};t.prototype.createSkuPropsTable=function(t,e){var i=BX.create("table"),r,s=[],n=null;if(e.SKU_PROPS){for(var a in e.SKU_PROPS){if(!e.SKU_PROPS.hasOwnProperty(a))continue;if(!e.SKU_PROPS[a]["VALUE"])e.SKU_PROPS[a]["VALUE"]={NAME:a};if(e.SKU_PROPS[a]["VALUE"]["PICT"])r='<div style="width: 17px; height: 17px; text-align: center; border: 1px solid gray;">'+'<img  width="17" height="17" src="'+e.SKU_PROPS[a]["VALUE"]["PICT"]+'">'+"</div>";else r='<div style="font-size: 9px; padding: 2px 5px; text-align: center; border: 1px solid gray;">'+BX.util.htmlspecialchars(e.SKU_PROPS[a]["VALUE"]["NAME"])+"</div>";if(!e.SKU_PROPS[a]["NAME"])e.SKU_PROPS[a]["NAME"]=a;var o=BX.create("td",{html:'<span style="color: gray; font-size: 11px">'+BX.util.htmlspecialchars(e.SKU_PROPS[a]["NAME"])+" </span>",style:{"text-align":"left"}});i.appendChild(BX.create("tr",{children:[o,BX.create("td",{html:r})]}));s.push(e.SKU_PROPS[a]["CODE"])}}if(e.PROPS){for(var d in e.PROPS){if(!e.PROPS.hasOwnProperty(d))continue;if(!e.PROPS[d]||s.indexOf(e.PROPS[d]["CODE"])!=-1)continue;if(!e.PROPS[d]["NAME"])e.PROPS[d]["NAME"]="";if(!e.PROPS[d]["VALUE"])e.PROPS[d]["VALUE"]="";if(e.PROPS[d]["CODE"]=="PRODUCT.XML_ID"||e.PROPS[d]["CODE"]=="CATALOG.XML_ID")continue;var o=BX.create("td",{html:'<span style="color: gray; font-size: 11px">'+BX.util.htmlspecialchars(e.PROPS[d]["NAME"])+" </span>",style:{"text-align":"left"}});var c=BX.create("tr",{children:[o,BX.create("td",{html:'<div style="font-size: 9px; padding: 2px 5px; text-align: center;">'+BX.util.htmlspecialchars(e.PROPS[d]["VALUE"])+"</div>"})]});i.appendChild(c)}}if(i.children.length)n=i;return n};t.prototype.createProductCell=function(t,e,i){var r=null,s=[],n=e[i],a="",o=this;switch(i){case"NUMBER":s.push(BX.create("span",{props:{id:e.IS_SET_ITEM!="Y"?this.idPrefix+"sale_order_product_"+t+"_number":"&nbsp;"},html:"&nbsp;"}));break;case"NAME":if(e.EDIT_PAGE_URL){d=BX.create("a",{props:{href:e.EDIT_PAGE_URL,target:"_blank"},html:BX.util.htmlspecialchars(n)})}else{d=BX.create("span",{style:{fontWeight:"bold"},html:BX.util.htmlspecialchars(e[i])})}s.push(d);break;case"IMAGE":s.push(this.createFieldImage(t,e,i));a="adm-s-order-table-ddi-table-img";break;case"PROPS":var d=this.createFieldSkuProps(t,e,i);if(d)s.push(d);break}if(s.length>0){r=BX.create("td");if(a)BX.addClass(r,a);while(s.length>0)r.appendChild(s.pop());if(i=="NAME"){r.style.minWidth="250px";if(e.IS_SET_ITEM=="Y"){r.style.fontStyle="italic";r.style.paddingLeft="40px"}}}return r};t.prototype.productAdd=function(t){if(t.PRODUCT_ID&&!t.OFFER_ID){if(this.productIds[t.PRODUCT_ID]){return}this.productIds[t.PRODUCT_ID]=true}if(t.PRODUCT_ID&&t.OFFER_ID){if(this.productIds[t.OFFER_ID]){return}this.productIds[t.OFFER_ID]=true}var e=t.id;var i=this.createProductRow(e,t);BX(this.tableId).appendChild(i);BX.hide(BX(this.emptyRowId))};t.prototype.createProductRow=function(t,e){var i,r=BX.create("tbody",{props:{id:this.createProductRowId(e)},style:{textAlign:"left",borderBottom:"1px solid #DDD"}}),s=this.createMenuCell(t,e),n=BX.create("tr");if(s){n.appendChild(s)}var a,o=[];if(e.IS_SET_ITEM!="Y"){r.setAttribute("data-product-id",e.OFFER_ID||e.PRODUCT_ID);if(e.IS_SET_PARENT&&e.OLD_PARENT_ID)r.setAttribute("data-old-parent-id-parent",e.OLD_PARENT_ID)}else{BX.addClass(r,"bundle-child-"+e.OLD_PARENT_ID);BX.addClass(r,"basket-bundle-child-hidden");BX.addClass(r,"bundle-child")}for(var d in{IMAGE:"IMAGE",NAME:"NAME",PROPS:"PROPS"}){i=this.createProductCell(t,e,d);if(i){if(o)while(a=o.pop())i.appendChild(a);n.appendChild(i)}else{var c=n.lastChild.getAttribute("colspan")||1;c++;n.lastChild.setAttribute("colspan",c)}}n.appendChild(BX.create("input",{props:{type:"hidden",name:this.inputNameProduct,value:e.OFFER_ID||e.PRODUCT_ID}}));r.appendChild(n);return r};t.prototype.getParamsByProductId=function(t,e){BX.ajax({url:"sale_discount_preset_detail.php?"+"lang="+BX.message.LANGUAGE_ID+"&"+"action=getProductDetails&"+"PRESET_ID="+BX.util.urlencode(this.presetId)+"&public=y",method:"POST",dataType:"json",data:{productId:t.id,iblockId:e,quantity:t.quantity,sessid:BX.bitrix_sessid(),siteId:this.siteId},onsuccess:BX.delegate(function(t){this.productAdd(t)},this),onfailure:function(t){}})};t.prototype.onClickAddProduct=function(t){var e="perDayPreset"+".getParamsByProductId";window[e]=BX.proxy(function(t,e){this.getParamsByProductId(t,e)},this);var i=new BX.CDialog({content_url:"/bitrix/tools/sale/product_search_dialog.php?"+"lang="+BX.message.LANGUAGE_ID+"&LID="+this.siteId+"&caller=preset_edit"+"&allow_select_parent=Y"+"&func_name="+e+"&STORE_FROM_ID=0",height:Math.max(500,window.innerHeight-400),width:Math.max(800,window.innerWidth-400),draggable:true,resizable:true,min_height:500,min_width:800});BX.addCustomEvent(i,"onWindowRegister",BX.defer(function(){i.Get().style.position="fixed";i.Get().style.top=parseInt(i.Get().style.top)-BX.GetWindowScrollPos().scrollTop+"px"}));i.Show();BX.PreventDefault(t)};t.prototype.onClickAddSection=function(t){if(!BX("sect_stub")){this.container.appendChild(BX.create("input",{props:{type:"hidden",id:"sect_stub",name:"sect_stub"}}))}var e="cat_section_search.php?land=ru&discount=Y&n=sect_stub";var i=window.open(e,"","scrollbars=yes,resizable=yes,width=900,height=600,top="+parseInt((screen.height-500)/2-14,10)+",left="+parseInt((screen.width-600)/2-5,10));i.onbeforeunload=function(){if(window.jsMLI_select_section){jsMLI_select_section.AddValue(BX("sect_stub").value)}};BX.PreventDefault(t)};return t}();

Zerion Mini Shell 1.0