Current Path : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/fileman/ |
Current File : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/fileman/sticker.min.js |
function BXSticker(e,t,i){this.MESS=i;this.Stickers=t||[];this.Params=e;this.sessid_get=e.sessid_get;this.bShowStickers=e.bShowStickers;this.curEditorStickerInd=false;this.oneGifSrc="/bitrix/images/1.gif";this.colorSchemes=[{name:"bxst-yellow",color:"#FFFCB3",title:this.MESS.Yellow},{name:"bxst-green",color:"#DBFCCD",title:this.MESS.Green},{name:"bxst-blue",color:"#DCE7F7",title:this.MESS.Blue},{name:"bxst-red",color:"#FCDFDF",title:this.MESS.Red},{name:"bxst-purple",color:"#F6DAF8",title:this.MESS.Purple},{name:"bxst-gray",color:"#F5F5F5",title:this.MESS.Gray}];this.curPageCount=this.Params.curPageCount;if(this.Params.useHotkeys)BX.bind(document,"keyup",BX.proxy(this.OnKeyUp,this));window.__bxst_result={};if(e.bShowStickers)this.Init(e)}BXSticker.prototype={Init:function(e){this.oMarkerConfig={attr:{title:true,src:true,href:true,alt:true,"class":true,className:true,id:true,name:true,type:true,value:true},impAttr:{src:true,id:true,name:true,href:true}};this.Params.changeColorEffect=true;this.arStickers=[];this.posReg={};this.bInited=true;this.access=this.Params.access;this._arSavedStickers={};BX.bind(document,"mousedown",BX.proxy(this.OnMousedown,this));var t=this;BX.addCustomEvent("onMenuOpen",function(){var e=BX.findChild(BX("bxst-show-sticker-icon"),{className:"icon"},true);if(e){if(t.bShowStickers)BX.addClass(e,"checked");else BX.removeClass(e,"checked")}t.UpdateStickersCount()});this.DisplayStickers(!!e.bVisEffects);this.ShowEditor({ind:-1})},ShowAll:function(e,t){if(typeof e=="undefined")e=!this.bShowStickers;var i=this;var s=BX.findChild(BX("bxst-show-sticker-icon"),{className:"icon"},true);if(s){if(e)BX.addClass(s,"checked");else BX.removeClass(s,"checked")}this.bShowStickers=e;window.__bxst_result.show=null;window.__bxst_result.stickers=null;this.Request(e?"show_stickers":"hide_stickers",{pageUrl:this.Params.pageUrl,b_inited:this.bInited?"Y":"N"},function(e){if(i.bInited)return;i.bShowStickers=window.__bxst_result.show;if(window.__bxst_result.stickers){i.Stickers=window.__bxst_result.stickers;i.Params.bVisEffects=true;if(!i.bInited)i.Init(i.Params);if(t)i.AddSticker()}});if(!e){this.HideAll()}else if(e&&this.bInited){var r;for(var o=0,a=this.arStickers.length;o<a;o++){r=this.arStickers[o];r.pWin.Get().style.display="block";r.pShadow.style.display="block";if(r.pMarker)r.pMarker.style.display=""}}},HideAll:function(){var e;for(var t=0,i=this.arStickers.length;t<i;t++){e=this.arStickers[t];e.pWin.Get().style.display="none";e.pShadow.style.display="none";if(e.pMarker)e.pMarker.style.display="none"}},AddSticker:function(e,t,i){if(!this.bInited)return this.ShowAll(true,true);if(!this.bShowStickers&&this.bInited)this.ShowAll(true,false);if(this.curEditorStickerInd!==false){var s=this;this.SaveAndCloseEditor(this.curEditorStickerInd,true,true);return setTimeout(function(){s.AddSticker(e,t,i)},300)}var r;if(e){r=this.ConvertStickerObj(e)}else{r={bNew:true,personal:false,colorInd:parseInt(this.Params.start_color),width:parseInt(this.Params.start_width),height:parseInt(this.Params.start_height),collapsed:false,completed:false,info:" "}}var o=this.CreateWindow(r,!!t,i);if(r.bNew)this.SetMarker(o,"area")},CreateWindow:function(e,t,i){var s=new BX.CWindow(false,"float");s.Show(true);s.Get().style.zIndex=s.zIndex=this.Params.zIndex;s.SETTINGS.min_width=this.Params.min_width;s.SETTINGS.min_height=this.Params.min_height;BX.addClass(s.Get(),"bx-sticker");s.DenyClose();var r=this.access=="R",o=!!e.bNew,a=this,n,l=this.arStickers.length,d=s.Get().appendChild(BX.create("DIV",{props:{className:"bxst-header",id:"bxst_head_"+l}})),c=d.appendChild(BX.create("DIV",{props:{className:"bxst-id-cont bxst-title"},html:e.id>0?'<a href="'+this.Params.pageUrl+"?show_sticker="+e.id+'"><span>'+e.id+"</span></a>":""})),h=d.appendChild(BX.create("DIV",{props:{className:"bxst-check-cont"}})),p=h.appendChild(BX.create("INPUT",{props:{id:"bxst_conplited_"+l,name:"bxst_conplited_"+l,type:"checkbox",value:"Y",title:this.MESS.Complete}})),u=h.appendChild(BX.create("LABEL",{attrs:{"for":"bxst_conplited_"+l,title:this.MESS.Complete},text:this.MESS.CompleteLabel})),f=d.appendChild(BX.create("DIV",{props:{id:"bxst_col_title_"+l,className:"bxst-col-title-cont",title:this.MESS.UnCollapseTitle}})),k=d.appendChild(BX.create("DIV",{props:{className:"bxst-close bxst-but",title:this.MESS.Close}})).appendChild(BX.create("IMG",{props:{id:"bxst_close_"+l,src:this.oneGifSrc,className:"bxst-sprite"}})),S=d.appendChild(BX.create("DIV",{props:{className:"bxst-collapse bxst-but"}})).appendChild(BX.create("IMG",{props:{id:"bxst_collapse_"+l,src:this.oneGifSrc,className:"bxst-sprite",title:this.MESS.Collapse}}));if(o||this.Params.curUserId==e.authorId){n=d.appendChild(BX.create("DIV",{props:{id:"bxst_type_"+l,className:"bxst-type-cont"}}));n.appendChild(BX.create("DIV",{props:{className:"bxst-type-l bxst-type-corn"}}));n.appendChild(BX.create("DIV",{props:{className:"bxst-type-c bxst-type-c-publ"}})).appendChild(BX.create("SPAN",{props:{},text:this.MESS.Public}));n.appendChild(BX.create("DIV",{props:{className:"bxst-type-c bxst-type-c-pers"}})).appendChild(BX.create("SPAN",{props:{},text:this.MESS.Personal}));n.appendChild(BX.create("DIV",{props:{className:"bxst-type-r bxst-type-corn"}}));if(!r)n.onclick=function(){if(!s.__stWasDragged){a.SetType(parseInt(this.id.substr("bxst_type_".length)),true)}};this.SetUnselectable([n])}var b=s.Get().appendChild(BX.create("DIV",{props:{id:"bxst_body_"+l,className:"bxst-content"}}));var m=b.appendChild(BX.create("DIV",{props:{id:"bxst_content_"+l,className:"bxst-content-area"}}));var C=s.Get().appendChild(BX.create("DIV",{props:{className:"bxst-footer"}})),y=C.appendChild(BX.create("DIV",{props:{className:"bxst-marker-area-but"}})).appendChild(BX.create("IMG",{props:{id:"bxst_marker_but0_"+l,src:this.oneGifSrc,className:"bxst-sprite",title:this.MESS.SetMarkerArea}})),w=C.appendChild(BX.create("DIV",{props:{className:"bxst-marker-elem-but"}})).appendChild(BX.create("IMG",{props:{id:"bxst_marker_but1_"+l,src:this.oneGifSrc,className:"bxst-sprite",title:this.MESS.SetMarkerEl}})),v=C.appendChild(BX.create("DIV",{props:{className:"bxst-ctrl-txt bxst-color-but"}})).appendChild(BX.create("SPAN",{props:{id:"bxst_color_"+l},text:this.MESS.Color})),M=C.appendChild(BX.create("DIV",{props:{className:"bxst-ctrl-txt bxst-add-but"}})).appendChild(BX.create("SPAN",{props:{id:"bxst_add_but_"+l},text:this.MESS.Add})),_=C.appendChild(BX.create("DIV",{props:{className:"bxst-resizer"}})).appendChild(BX.create("IMG",{props:{src:this.oneGifSrc,className:"bxst-sprite"}}));var B=C.appendChild(BX.create("DIV",{props:{className:"bxst-info-icon"}})).appendChild(BX.create("IMG",{props:{id:"bxst_info_"+l,src:this.oneGifSrc,className:"bxst-sprite"},style:{display:o?"none":"block"}}));var g=new BX.CHintSimple({parent:B,hint:e.info});if(r)BX.addClass(s.Get(),"bx-sticker-readonly");var x=BX.GetWindowInnerSize();var I=BX.GetWindowScrollPos();if(o||e.left<=0||e.top<=0){e.left=s.Get().style.left=parseInt(I.scrollLeft+x.innerWidth/2-parseInt(s.Get().offsetWidth)/2)+Math.round(e.width/2);e.top=Math.max(parseInt(I.scrollTop+x.innerHeight/2-parseInt(s.Get().offsetHeight)/2),0)-Math.round(e.height/2)}s.StickerInd=l;if(o)M.style.display="none";pShadow=document.body.appendChild(BX.create("DIV",{props:{className:"bxst-shadow"},style:{zIndex:parseInt(s.Get().style.zIndex)-5}}));this.RegisterSticker({obj:e,pWin:s,pCheck:p,pCloseBut:k,pCollapseBut:S,pCollapsedTitle:f,pBody:b,pHead:d,pTypeCont:n||false,pContentArea:m,pIdsCont:c,pShadow:pShadow,bButPanelShowed:true,pMarkerAreaBut:y,pMarkerElementBut:w,pColorBut:v,pAddBut:M,pInfo:B,pHint:g,_over:!o&&!i,bButPanelShowed:!o&&!i});this.AdjustToSize(l,e.width,e.height);this.SetColorScheme(l,e.colorInd,false);this.SetType(l,false,e.personal?"personal":"public");this.SetCompleted(l,e.completed,false);this.CollapseSticker(l,false,e.collapsed);s.SetDraggable(d);BX.addCustomEvent(s,"onWindowDragStart",function(){this.__stWasDragged=true});BX.addCustomEvent(s,"onWindowDragFinished",function(){a.OnDragEnd(this)});BX.addCustomEvent(s,"onWindowDrag",function(){a.OnDragDrop(this)});s.SetResize(_);BX.addCustomEvent(s,"onWindowResize",function(){a.AdjustToSize(this.StickerInd)});BX.addCustomEvent(s,"onWindowResizeStart",function(){a.OnResizeStart(this)});BX.addCustomEvent(s,"onWindowResizeFinished",function(){a.OnResizeEnd(this)});d.ondblclick=function(){a.CollapseSticker(parseInt(this.id.substr("bxst_head_".length)),true)};S.onclick=function(){if(!s.__stWasDragged){a.CollapseSticker(parseInt(this.id.substr("bxst_collapse_".length)),true)}};if(!r){k.onclick=function(){if(!s.__stWasDragged){a.CloseSticker(parseInt(this.id.substr("bxst_close_".length)),true)}};M.onclick=function(){a.AddToSticker(parseInt(this.id.substr("bxst_add_but_".length)))};p.onclick=function(){if(!s.__stWasDragged){a.SetCompleted(parseInt(this.id.substr("bxst_conplited_".length)),!!this.checked,true)}};v.onclick=function(){a.ShowColorSelector(parseInt(this.id.substr("bxst_color_".length)))};y.onclick=function(){a.SetMarker(parseInt(this.id.substr("bxst_marker_but0_".length)),"area")};w.onclick=function(){a.SetMarker(parseInt(this.id.substr("bxst_marker_but1_".length)),"element")}}else{p.disabled=true}if(!o&&!i&&!e.collapsed)s.Get().style.height=e.height-24+"px";if(o){var E=this.GetSuitablePosition(e.left,e.top);if(E!==true){e.left=E.left;e.top=E.top}}else{c.style.display="block"}this.RegisterPosition(e.left,e.top);s.Get().style.left=e.left+"px";s.Get().style.top=e.top+"px";this.AdjustShadow(l);this.SetUnselectable([k,S,v,y,y,_]);if(o||i===true){this.ShowEditor({ind:l});if(i){this.OnDivMouseOver(l,true);this.DisplayMarker(l)}}else{b.style.overflow="auto";m.innerHTML=e.html_content;this.DisplayMarker(l);if(e.id==this.Params.focusOnSticker){window.scrollTo(0,e.top>200?e.top-200:0);this.Hightlight(l,true);this.BlinkRed(l)}}if(!r){b.onclick=function(){if(!this.id)return;var e=parseInt(this.id.substr("bxst_body_".length));if(a.curEditorStickerInd!==e)a.ShowEditor({ind:e})}}s.Get().onmouseover=function(){a.OnDivMouseOver(l,true)};s.Get().onmouseout=function(){a.OnDivMouseOver(l,false)};return l},UpdateNewSticker:function(e){var t=this.arStickers[e];t.pAddBut.style.display="block";t.pInfo.style.display="block";t.pIdsCont.style.display="block";t.pIdsCont.innerHTML='<a href="'+this.Params.pageUrl+"?show_sticker="+t.obj.id+'"><span>'+t.obj.id+"</span></a>";if(e===this.curEditorStickerInd&&typeof window.oLHESticker=="object"){setTimeout(function(){oLHESticker.SetFocusToEnd()},100);setTimeout(function(){oLHESticker.SetFocusToEnd()},500)}},RegisterPosition:function(e,t){var i=20,s=Math.round(e/i)*i,r=Math.round(t/i)*i;this.posReg[s+"_"+r]=true},GetSuitablePosition:function(e,t,i){var s=20,r=Math.round(e/s)*s,o=Math.round(t/s)*s;if(this.posReg[r+"_"+o])return this.GetSuitablePosition(e+s,t+s,true);else if(i)return{left:e,top:t};return true},RegisterSticker:function(e){this.arStickers.push(e);return this.arStickers.length-1},AdjustToSize:function(e,t,i){var s,r=this.arStickers[e];if(typeof t=="undefined"||typeof i=="undefined"){t=parseInt(r.pWin.Get().style.width);i=parseInt(r.pWin.Get().style.height)}else{r.pWin.Get().style.width=t+"px";r.pWin.Get().style.height=i+"px"}if(BX.browser.IsIE()&&!BX.browser.IsDoctype())s=i-19-27-0;else s=i-19-24-0;if(window.oLHESticker){window.oLHESticker.pFrame.style.width=t-2+"px";window.oLHESticker.pFrame.style.height=s-2+"px";window.oLHESticker.ResizeFrame(s-2)}r.pCollapsedTitle.style.width=t-100+"px";r.pBody.style.height=s+"px";this.AdjustShadow(e)},AdjustShadow:function(e){var t=this.arStickers[e];if(t.obj.closed&&t.pShadow.parentNode)return t.pShadow.parentNode.removeChild(t.pShadow);t.pShadow.style.top=parseInt(t.pWin.Get().style.top)+4+"px";t.pShadow.style.left=parseInt(t.pWin.Get().style.left)+3+"px";t.pShadow.style.width=t.pWin.Get().style.width;t.pShadow.style.height=t.pWin.Get().style.height},AdjustEditorSizeAndPos:function(e){var t=this.arStickers[e];this.pEditorCont.style.top=parseInt(t.pWin.Get().style.top)+20+"px";this.pEditorCont.style.left=t.pWin.Get().style.left;this.pEditorCont.style.width=t.pWin.Get().style.width;this.pEditorCont.style.height=t.pBody.style.height;this.pEditorCont.style.zIndex=parseInt(t.pWin.Get().style.zIndex)+10},AdjustHintToCursor:function(e,t){e.style.left=t.realX+30+"px";e.style.top=t.realY-12+"px"},AdjustScrollPosToCursor:function(){},AdjustStickerToArea:function(e){var t,i,s=BX.GetWindowInnerSize(document),r=BX.GetWindowScrollPos(document),o=this.arStickers[e],a=o.obj.marker&&o.obj.marker.adjust?0:10;if(o.pMarker&&o.obj.marker){t=o.obj.marker.left+o.obj.marker.width-60;i=o.obj.marker.top-o.obj.height+a;if(t+o.obj.width>s.innerWidth)t=s.innerWidth-o.obj.width-30;if(i<r.scrollTop+50)i=o.obj.marker.top+o.obj.marker.height-a}this.MoveToPos(e,{left:t,top:i});o.obj.top=i;o.obj.left=t;if(this.arStickers[e].obj.id)this.SaveSticker(e)},MoveToPos:function(e,t){var i=this.arStickers[e];var s=parseInt(i.obj.top),r=parseInt(i.obj.left),o=parseInt(t.top),a=parseInt(t.left),n=parseInt(s),l=parseInt(r),d=this,c=0,h=s>o,p=r>a,u=BX.browser.IsIE()?10:10,f=BX.browser.IsIE()?10:10,k=Math.ceil(Math.abs((r-a)/50)),S=Math.ceil(Math.abs((s-o)/50)),b=p?-k:k,m=h?-S:S;var C=function(t,s){if(t!==false)i.pWin.Get().style.top=t+"px";if(s!==false)i.pWin.Get().style.left=s+"px";d.AdjustShadow(e)};var y=setInterval(function(){if(o!=n&&n!==false)n+=Math.round(m*c/2);if(a!=l&&l!==false)l+=Math.round(b*c/2);if(n!==false&&(!h&&n>=o||h&&n<=o))n=o;if(l!==false&&(!p&&l>=a||p&&l<=a))l=a;C(n,l);if(n==o)n=false;if(l==a)l=false;if(n===false&&l===false){clearInterval(y);return d.OnDragEnd(i.pWin)}c++},u)},ChangeColor:function(e,t,i,s){var r=this.arStickers[e];if(!this.Params.changeColorEffect)i=false;if(i&&s===true){this.Params.start_color=t;return this.ShowColorOverlay(e,t,true)}else if(i&&s===false||!i){this.SetColorScheme(e,t,true);if(i)return this.ShowColorOverlay(e,t,false)}},SetColorScheme:function(e,t,i){if(e===this.curEditorStickerInd&&typeof window.oLHESticker=="object"){if(window.oLHESticker.pEditorDocument&&window.oLHESticker.pEditorDocument.body)window.oLHESticker.pEditorDocument.body.className=this.colorSchemes[t].name}this.arStickers[e].obj.colorInd=t;for(var s=0,r=this.colorSchemes.length;s<r;s++){if(s==t)BX.addClass(this.arStickers[e].pWin.Get(),this.colorSchemes[s].name);else BX.removeClass(this.arStickers[e].pWin.Get(),this.colorSchemes[s].name)}if(this.arStickers[e].pMarker)this.arStickers[e].pMarker.className="bxst-sticker-marker "+this.colorSchemes[t].name;if(i&&this.arStickers[e].obj.id>0){var o=this;if(this.arStickers[e]._colTimeout){clearTimeout(this.arStickers[e]._colTimeout);this.arStickers[e]._colTimeout=null}o.SaveSticker(e)}},SetType:function(e,t,i){var s=this.arStickers[e],r=typeof i=="undefined"?!s.obj.personal:i=="personal";if(!s.pTypeCont)return;if(r){BX.addClass(s.pTypeCont,"bxst-type-pers");BX.removeClass(s.pTypeCont,"bxst-type-publ");s.pTypeCont.title=this.MESS.PersonalTitle}else{BX.addClass(s.pTypeCont,"bxst-type-publ");BX.removeClass(s.pTypeCont,"bxst-type-pers");s.pTypeCont.title=this.MESS.PublicTitle}s.obj.personal=r;if(s.obj.id&&t)this.SaveSticker(e)},SetCompleted:function(e,t,i){this.arStickers[e].obj.completed=t;this.arStickers[e].pCheck.checked=t;if(this.arStickers[e].obj.id&&i)this.SaveSticker(e)},CloseSticker:function(e,t,i){var s=this.arStickers[e];if(t&&s.obj.authorName&&this.Params.curUserId!=s.obj.authorId&&!confirm(this.MESS.CloseConfirm.replace("#USER_NAME#",s.obj.authorName)))return;s.obj.closed=!s.obj.closed;if(e===this.curEditorStickerInd)this.curEditorStickerInd=false;this.arStickers[e].pWin.Close(true);this.arStickers[e].pWin.onUnRegister(true);if(s.pMarkerNode)BX.removeClass(s.pMarkerNode,"bxst-sicked");if(s.pMarker&&s.pMarker.parentNode)s.pMarker.parentNode.removeChild(s.pMarker);this.AdjustShadow(e);if(this.arStickers[e].obj.id&&t){this.SaveSticker(e);BX.admin.panel.Notify(this.MESS.CloseNotify.replace(/(.*?)#LINK#(.*?)#LINK#/gi,'$1<span class="bxst-close-notify-link" onclick="window.oBXSticker.ShowList(\'current\'); return false;">$2</span>'))}var r=document.body.getElementsByTagName("A");if(r&&r[0])BX.focus(r[0])},CollapseSticker:function(e,t,i){var s=this.arStickers[e];if(typeof i=="undefined")i=!s.obj.collapsed;if(t&&this.curEditorStickerInd===e)this.SaveAndCloseEditor(e,true,false);if(i){BX.addClass(s.pWin.Get(),"bxst-collapsed");s.pCollapseBut.title=this.MESS.UnCollapse;s.pWin.Get().style.height="19px";s.pCollapsedTitle.innerHTML=this.GetCollapsedContent(s.obj.html_content)}else{BX.removeClass(s.pWin.Get(),"bxst-collapsed");s.pCollapseBut.title=this.MESS.Collapse;s.pWin.Get().style.height=parseInt(s.obj.height)+"px"}this.AdjustShadow(e);s.obj.collapsed=i;if(s.obj.id&&t)this.SaveSticker(e)},OnDragEnd:function(e){setTimeout(function(){e.__stWasDragged=false},200);var t=e.StickerInd;this.arStickers[t].obj.top=parseInt(e.Get().style.top);this.arStickers[t].obj.left=parseInt(e.Get().style.left);this.SaveSticker(t)},OnDragDrop:function(e){this.AdjustShadow(e.StickerInd)},OnResizeEnd:function(e){var t=e.StickerInd;this.arStickers[t].bResizingNow=false;this.arStickers[t].obj.width=parseInt(e.Get().style.width);this.arStickers[t].obj.height=parseInt(e.Get().style.height);if(this.arStickers[t].obj.id)this.SaveSticker(t)},OnResizeStart:function(e){this.arStickers[e.StickerInd].bResizingNow=true},ShowEditor:function(e){var t=e.ind===-1,i=this,s=this.arStickers[e.ind];if(!this.pEditorCont){this.pEditorCont=(t?document.body:s.pBody).appendChild(BX.create("DIV",{props:{className:"bxst-lhe-cont"}}))}this.pEditorCont.style.visibility="hidden";if(window.oLHESticker){if(this.bLoadLHEEditor){this.PrepareEditorAfterLoading();this.bLoadLHEEditor=false}if(!t)this.DisplayEditor(s,e.ind)}else if(!this.bLoadLHEEditor){this.Request("load_lhe",{},function(t){i.pEditorCont.innerHTML=t;var s=setInterval(function(){if(typeof window.LoadLHE_LHEBxStickers=="undefined")return;clearInterval(s);if(!i.bLoadLHEEditor&&!window.oLHESticker)LoadLHE_LHEBxStickers();return setTimeout(function(){i.bLoadLHEEditor=true;i.ShowEditor(e)},50)},50)})}else if(i.bLoadLHEEditor&&!window.oLHESticker){return setTimeout(function(){i.ShowEditor(e)},50)}},PrepareEditorAfterLoading:function(){if(!oLHESticker)return;oLHESticker.oSpecialParsers["st_title"]={Parse:function(e,t,i){t=t.replace(/\[ST_TITLE\]((?:\s|\S)*?)\[\/ST_TITLE\]/gi,'<span id="'+i.SetBxTag(false,{tag:"st_title"})+'" class="bxst-title" >$1</span>');return t},UnParse:function(e,t,s){var r="[ST_TITLE]";for(i=0;i<t.arNodes.length;i++)r+=s._RecursiveGetHTML(t.arNodes[i]);r+="[/ST_TITLE]";return r}};BX.addCustomEvent(oLHESticker,"OnUnParseContentAfter",function(){this.__sContent=this.__sContent.replace(/\[\/ST_TITLE\](?:\n|\r)+/gi,"[/ST_TITLE]\n")})},DisplayEditor:function(e,t,i){var s=this;if(!i){e.pBody.appendChild(this.pEditorCont);this.AdjustToSize(t);oLHESticker.SetContent(e.obj.content||this.GetNewStickerContent()+"\n");oLHESticker.CreateFrame();oLHESticker.SetEditorContent(oLHESticker.content);window.oLHESticker.pEditorDocument.body.className=this.colorSchemes[e.obj.colorInd].name;if(this.Params.useHotkeys)BX.bind(window.oLHESticker.pEditorDocument,"keyup",BX.proxy(this.OnKeyUp,this));setTimeout(function(){try{window.oLHESticker.pEditorDocument.execCommand("styleWithCSS",false,false)}catch(e){}},100);setTimeout(function(){try{window.oLHESticker.pEditorDocument.execCommand("styleWithCSS",false,false)}catch(e){}},500);setTimeout(function(){try{window.oLHESticker.pEditorDocument.execCommand("styleWithCSS",false,false)}catch(e){}},1e3);this.curEditorStickerInd=t;e.pBody.style.overflow="hidden";var r=0,o=1,a=22;var n=setInterval(function(){if(r>=a)r=a;else r+=o;e.pContentArea.style.top=r+"px";if(r==a){clearInterval(n);s.DisplayEditor(e,t,true)}},BX.browser.IsIE()?5:10)}else{setTimeout(function(){e.pBody.style.overflow="auto";s.pEditorCont.style.visibility="visible";e.pContentArea.style.display="none";s.pEditorCont.style.display="block";setTimeout(function(){oLHESticker.SetFocusToEnd()},100)},100)}},AddToSticker:function(e){var t=this.arStickers[e];if(this.curEditorStickerInd===e&&window.oLHESticker){oLHESticker.SetFocusToEnd();oLHESticker.InsertHTML("<br />"+oLHESticker.ParseContent(this.GetNewStickerContent())+"<br />");setTimeout(function(){oLHESticker.SetFocusToEnd()},100)}else{t.obj.content+="\n"+this.GetNewStickerContent();this.ShowEditor({ind:e})}},Request:function(e,t,i,s){s=s===true;if(s)BX.showWait();var r="/bitrix/admin/fileman_stickers.php?sticker_action="+e+"&"+this.sessid_get+"&site_id="+this.Params.site_id;return BX.ajax.post(r,t||{},function(e){if(s)BX.closeWait();if(i)setTimeout(function(){i(e)},10)})},SetUnselectable:function(e){if(typeof e!="object")e=[e];for(var t=0,i=e.length;t<i;t++){BX.setUnselectable(e[t]);e[t].ondragstart=function(e){return BX.PreventDefault(e)}}},ShowColorOverlay:function(e,t,i){var s=this,r=0,o,a=this.arStickers[e];if(!this.pColorOverlay)this.pColorOverlay=document.body.appendChild(BX.create("DIV",{props:{className:"bx-sticker-overlay"}}));this.pColorOverlay.style.zIndex=parseInt(a.pWin.Get().style.zIndex)+10;this.pColorOverlay.style.top=a.pWin.Get().style.top;this.pColorOverlay.style.left=a.pWin.Get().style.left;this.pColorOverlay.style.width=a.pWin.Get().style.width;this.pColorOverlay.style.height=a.pWin.Get().style.height;o=setInterval(function(){if(r>2){if(i)s.ChangeColor(e,t,true,false);else s.pColorOverlay.className="bx-sticker-overlay";return clearInterval(o)}if(i)s.pColorOverlay.className="bx-sticker-overlay bx-sticker-op-"+r;else s.pColorOverlay.className="bx-sticker-overlay bx-sticker-op-"+(3-r);r++},20)},DisplayStickers:function(e){for(var t=0,i=this.Stickers.length;t<i;t++)this.AddSticker(this.Stickers[t],e)},MousePos:function(e){if(window.event)e=window.event;if(e.pageX||e.pageY){e.realX=e.pageX;e.realY=e.pageY}else if(e.clientX||e.clientY){e.realX=e.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft)-document.documentElement.clientLeft;e.realY=e.clientY+(document.documentElement.scrollTop||document.body.scrollTop)-document.documentElement.clientTop}return e},SaveAndCloseEditor:function(e,t,i){if(!window.oLHESticker||this.bLoadLHEEditor){var s=this;return setTimeout(function(){s.SaveAndCloseEditor(e,t)},100)}var r=this.arStickers[e];oLHESticker.SaveContent();var o=oLHESticker.GetContent();var a=oLHESticker.ParseContent(o);r.obj.html_content=a;r.pContentArea.innerHTML=a;this.arStickers[e].obj.content=o;if(t!==false){r.pContentArea.style.display="block";this.pEditorCont.style.display="none";r.pContentArea.style.top="0px";r.pBody.style.overflow="auto";this.curEditorStickerInd=false}if(i!==false)this.SaveSticker(e)},GetNewStickerContent:function(){var e=BX.date.format(BX.date.convertBitrixFormat(BX.message("FORMAT_DATETIME")));return"[ST_TITLE]"+BX.util.htmlspecialchars(this.Params.curUserName)+" "+e+"[/ST_TITLE]\n"},SaveSticker:function(e){if(this.access=="R")return;if(this.curEditorStickerInd===e)this.SaveAndCloseEditor(e,false,false);var t=this.arStickers[e];var i=this;var s=Math.round(Math.random()*1e5);window.__bxst_result[s]=false;if(typeof t.obj.content=="undefined")t.obj.content=this.GetNewStickerContent()+"\n";if(t.obj.bNew){if(this._arSavedStickers[e])return;this._arSavedStickers[e]=true}this.Request("save_sticker",{reqid:s,id:t.obj.bNew?0:t.obj.id,page_url:this.Params.pageUrl,page_title:this.Params.pageTitle,personal:t.obj.personal?"Y":"N",content:t.obj.content,width:t.obj.width,height:t.obj.height,top:t.obj.top,left:t.obj.left,color:t.obj.colorInd,collapsed:t.obj.collapsed?"Y":"N",completed:t.obj.completed?"Y":"N",closed:t.obj.closed?"Y":"N",marker:t.obj.marker},function(){if(window.__bxst_result[s]){var r=!!t.obj.bNew;i.arStickers[e].obj=i.ConvertStickerObj(window.__bxst_result[s]);if(i.arStickers[e].pHint){i.arStickers[e].pHint.HINT=i.arStickers[e].obj.info;if(i.arStickers[e].pHint.CONTENT_TEXT)i.arStickers[e].pHint.CONTENT_TEXT.innerHTML=i.arStickers[e].obj.info}if(r){i.UpdateNewSticker(e);if(!i.arStickers[e].obj.closed){i.curPageCount++;i.UpdateStickersCount()}}else{if(i.arStickers[e].obj.closed){i.curPageCount--;i.UpdateStickersCount()}}}window.__bxst_result[s]=null})},GetCollapsedContent:function(e){var t="";if(e.indexOf("bxst-title")!=-1){t=e.replace(/<span[^>]*?class="bxst-title"[^>]*?>((?:\s|\S)*?)<\/span>/gi,function(e,t){if(t.indexOf(String.fromCharCode(160))>0)return'<span class="bxst-title">'+t.substr(0,t.indexOf(String.fromCharCode(160)))+"</span> ";return t});t=t.replace(/<br( \/)?>/gi," ")}if(t!="")return t;return e},ConvertStickerObj:function(e){return{bNew:false,id:parseInt(e.ID),personal:e.PERSONAL=="Y",colorInd:e.COLOR||0,content:e.CONTENT,html_content:e.HTML_CONTENT,top:parseInt(e.POS_TOP),left:parseInt(e.POS_LEFT),width:parseInt(e.WIDTH),height:parseInt(e.HEIGHT),collapsed:e.COLLAPSED=="Y",completed:e.COMPLETED=="Y",closed:e.CLOSED=="Y",info:e.INFO,authorName:e.AUTHOR,authorId:e.CREATED_BY,marker:e.MARKER_ADJUST||e.MARKER_WIDTH||e.MARKER_HEIGHT?{top:parseInt(e.MARKER_TOP),left:parseInt(e.MARKER_LEFT),width:parseInt(e.MARKER_WIDTH),height:parseInt(e.MARKER_HEIGHT),adjust:e.MARKER_ADJUST}:{}}},SetMarker:function(e,t){var i=this;var s=this.arStickers[e];this.bHightlightElementMode=false;this.bSelectAreaMode=false;BX.removeClass(s.pMarkerElementBut,"bxst-pressed");BX.removeClass(s.pMarkerAreaBut,"bxst-pressed");if(!this.oMarker)this.oMarker={};this.oMarker.StickerInd=e;if(s.pMarkerNode)BX.removeClass(s.pMarkerNode,"bxst-sicked");if(s.pMarker){s.pMarker.style.display="none";s.pMarker.style.top="-1000px"}if(s.markerResizer&&s.markerResizer.cont)s.markerResizer.cont.style.display="none";if(s.obj&&s.obj.marker)s.obj.marker={};this.oMarker.node=null;s.bSetMarkerMode=true;if(t=="area"){BX.addClass(s.pMarkerAreaBut,"bxst-pressed");setTimeout(function(){i.bSelectAreaMode=true},10);if(!this.oMarker.pOverlay)this.oMarker.pOverlay=document.body.appendChild(BX.create("DIV",{props:{className:"bxst-marker-overlay"}}));this.oMarker.pOverlay.style.display="block";var r=BX.GetWindowScrollSize(document);this.oMarker.pOverlay.style.width=r.scrollWidth+"px";this.oMarker.pOverlay.style.height=r.scrollHeight+"px";if(!this.oMarker.pCursorHint)this.oMarker.pCursorHint=document.body.appendChild(BX.create("DIV",{props:{className:"bxst-cursor-hint"},text:this.MESS.CursorHint}));this.oMarker.pCursorHint.style.top="";this.oMarker.pCursorHint.style.left="";this.oMarker.pCursorHint.style.display="block";this.oMarker.pWnd=document.body.appendChild(BX.create("DIV"));this.oMarker.pWnd.className="bxst-cur-marker "+this.colorSchemes[s.obj.colorInd].name}else{BX.addClass(s.pMarkerElementBut,"bxst-pressed");setTimeout(function(){i.bHightlightElementMode=true},10)}BX.bind(document,"mousemove",BX.proxy(this.OnMouseMove,this));BX.bind(document,"mouseup",BX.proxy(this.OnMouseUp,this))},OnMousedown:function(e){if(this.curEditorStickerInd!==false&&window.oLHESticker&&!window.oLHESticker.bPopup){var t=this.arStickers[this.curEditorStickerInd];if(t&&t.pWin.Get()){var i=this.bSelectAreaMode||this.bHightlightElementMode,s=3,r=parseInt(t.pWin.Get().style.top)-s,o=parseInt(t.pWin.Get().style.left)-s,a=o+parseInt(t.pWin.Get().style.width)+s*2,n=r+parseInt(t.pWin.Get().style.height)+s*2;e=this.MousePos(e);if(e.realX<o||e.realX>a||e.realY<r||e.realY>n)this.SaveAndCloseEditor(this.curEditorStickerInd,!i,!i)}}if(this.bSelectAreaMode){e=this.MousePos(e);this.bDrawMarkerMode=true;if(this.oMarker.pCursorHint)this.oMarker.pCursorHint.style.display="none";this.oMarker.from={top:e.realY,left:e.realX}}else if(this.bHightlightElementMode){var l=false;if(this.pCurMarkeredNode){l=true;var d=this.pCurMarkeredNode.pNode.className;if(d&&(d.indexOf("bx-sticker")!=-1||d.indexOf("bxst")!=-1)&&d.indexOf("bxst-sicked")==-1)l=false;if(l)l=!BX.findParent(this.pCurMarkeredNode.pNode,{className:new RegExp("bx-sticker","ig")})}if(l)return BX.PreventDefault(e);else this.MarkerHightlightNode()}},OnMouseMove:function(e){if(this.bHightlightElementMode){var t;if(e.target)t=e.target;else if(e.srcElement)t=e.srcElement;if(t.nodeType==3)t=t.parentNode;if(t&&t.nodeName)this.MarkerHightlightNode(t)}if(this.bSelectAreaMode){e=this.MousePos(e);if(this.oMarker.pCursorHint)this.AdjustHintToCursor(this.oMarker.pCursorHint,e);if(!this.bDrawMarkerMode)return;this.oMarker.to={top:e.realY,left:e.realX};var i=this.oMarker.from.top,s=this.oMarker.from.left,r=Math.abs(this.oMarker.to.left-this.oMarker.from.left),o=Math.abs(this.oMarker.to.top-this.oMarker.from.top);if(this.oMarker.to.top<=this.oMarker.from.top&&this.oMarker.to.left>=this.oMarker.from.left){i=this.oMarker.to.top;s=this.oMarker.from.left}else if(this.oMarker.to.top>this.oMarker.from.top&&this.oMarker.to.left>this.oMarker.from.left){i=this.oMarker.from.top;s=this.oMarker.from.left}else if(this.oMarker.to.top>this.oMarker.from.top&&this.oMarker.to.left<this.oMarker.from.left){i=this.oMarker.from.top;s=this.oMarker.to.left}else if(this.oMarker.to.top<this.oMarker.from.top&&this.oMarker.to.left<this.oMarker.from.left){i=this.oMarker.to.top;s=this.oMarker.to.left}this.oMarker.pWnd.style.display="block";this.oMarker.pWnd.style.width=r+"px";this.oMarker.pWnd.style.height=o+"px";this.oMarker.pWnd.style.top=i+"px";this.oMarker.pWnd.style.left=s+"px";this.oMarker.top=i;this.oMarker.left=s;this.oMarker.width=r;this.oMarker.height=o}},OnMouseUp:function(e){if(this.bHightlightElementMode&&this.pCurMarkeredNode){var t=false;var i=this.pCurMarkeredNode.pNode.className;if(i&&(i.indexOf("bx-sticker")!=-1||i.indexOf("bxst")!=-1)&&i.indexOf("bxst-sicked")==-1)t=true;if(!t)t=!!BX.findParent(this.pCurMarkeredNode.pNode,{className:new RegExp("bx-sticker","ig")});if(!t)this.oMarker.node=this.pCurMarkeredNode.pNode}this.bDrawMarkerMode=false;this.bHightlightElementMode=false;this.bSelectAreaMode=false;if(this.oMarker.StickerInd>=0&&this.arStickers[this.oMarker.StickerInd]){var s=this.arStickers[this.oMarker.StickerInd];BX.removeClass(s.pMarkerElementBut,"bxst-pressed");BX.removeClass(s.pMarkerAreaBut,"bxst-pressed");s.bSetMarkerMode=false}BX.unbind(document,"mousemove",BX.proxy(this.OnMouseMove,this));BX.unbind(document,"mouseup",BX.proxy(this.OnMouseUp,this));if(this.oMarker.pOverlay)this.oMarker.pOverlay.style.display="none";if(this.oMarker.pCursorHint)this.oMarker.pCursorHint.style.display="none";if(!t)this.CreateMarker(this.oMarker)},MarkerHightlightNode:function(e){if(this.pCurMarkeredNode){if(this.pCurMarkeredNode.onclick)this.pCurMarkeredNode.pNode.onclick=this.pCurMarkeredNode.onclick;if(this.pCurMarkeredNode.onmousedown)this.pCurMarkeredNode.pNode.onmousedown=this.pCurMarkeredNode.onmousedown;BX.removeClass(this.pCurMarkeredNode.pNode,"bxst-sicked")}if(e){this.pCurMarkeredNode={pNode:e};if(e.onclick)this.pCurMarkeredNode.onclick=e.onclick;if(e.onmousedown)this.pCurMarkeredNode.onmousedown=e.onmousedown;e.onmousedown=BX.proxy(this.OnMousedown,this);e.onclick=function(){return BX.PreventDefault(arguments[0])};BX.addClass(e,"bxst-sicked")}else{this.pCurMarkeredNode=false}},CreateMarker:function(e){if(!e)return;var t=this.arStickers[e.StickerInd];if(e.node){t.pMarkerNode=e.node;t.obj.marker={adjust:this.GetNodeAdjustInfo(e.node)};var i=BX.pos(t.pMarkerNode);if(i){t.obj.marker.top=i.top-2;t.obj.marker.left=i.left-2;t.obj.marker.width=i.width-4;t.obj.marker.height=i.height-4}}else{t.obj.marker={top:e.top,left:e.left,width:e.width,height:e.height}}if(t.obj.marker&&(t.obj.marker.adjust||t.obj.marker.width&&t.obj.marker.height&&t.obj.marker.top&&t.obj.marker.left)){this.DisplayMarker(e.StickerInd,true);this.AdjustStickerToArea(e.StickerInd)}if(this.oMarker.pWnd)this.oMarker.pWnd.style.display="none";if(!t.pWin.__stWasDragged)this.SaveSticker(e.StickerInd)},DisplayMarker:function(e,t){var i=this.arStickers[e];if(i.pMarker)i.pMarker.style.display="none";if(i.obj.marker&&i.obj.marker.adjust){if(!i.pMarkerNode)i.pMarkerNode=this.FindMarkerNode(i.obj.marker.adjust);if(i.pMarkerNode){var s=BX.pos(i.pMarkerNode);if(s){if(!i.pMarker)i.pMarker=document.body.appendChild(BX.create("DIV",{props:{className:"bxst-sticker-marker "+this.colorSchemes[i.obj.colorInd].name }}));if(t)BX.addClass(i.pMarker,"bxst-marker-over");i.pMarker.style.display="";i.pMarker.style.width=s.width-4+"px";i.pMarker.style.height=s.height-4+"px";i.pMarker.style.top=s.top-2+"px";i.pMarker.style.left=s.left-2+"px"}BX.removeClass(i.pMarkerNode,"bxst-sicked");return}}if(i.obj.marker&&i.obj.marker.width>0){if(!i.pMarker)i.pMarker=document.body.appendChild(BX.create("DIV",{props:{className:"bxst-sticker-marker "+this.colorSchemes[i.obj.colorInd].name}}));if(t)BX.addClass(i.pMarker,"bxst-marker-over");i.pMarker.style.display="";i.pMarker.style.width=i.obj.marker.width+"px";i.pMarker.style.height=i.obj.marker.height+"px";i.pMarker.style.top=i.obj.marker.top+"px";i.pMarker.style.left=i.obj.marker.left+"px"}},GetNodeAdjustInfo:function(e){var t=this._GetNodeAdjustInfo(e);t=this._GetNodeAdjustSiblings(e,t);return t},_GetNodeAdjustInfo:function(e){var t={nodeName:e.nodeName.toLowerCase(),attr:{},innerHTML:null};if(e.innerHTML&&e.innerHTML.length){t.innerHTML=BX.util.trim(e.innerHTML.toLowerCase());t.innerHTML=t.innerHTML.replace(/class=""/gi,"");t.innerHTML=t.innerHTML.replace(/class=''/gi,"");t.innerHTML=t.innerHTML.replace(/\n+/gi,"");t.innerHTML=t.innerHTML.replace(/\r+/gi,"");t.innerHTML=t.innerHTML.replace(/\s+/gi," ");if(t.innerHTML.length>250)t.innerHTML=t.innerHTML.substr(0,250)}if(e.attributes){var i,s=e.attributes.length;for(i=0;i<s;i++){name=e.attributes[i].name;if(!name||typeof name!="string")continue;name=name.toLowerCase();if(this.oMarkerConfig.attr[name]){val=e.attributes[i].value;if(name=="class"||name=="classname"){name="classname";val=val.replace("bxst-sicked","");val=BX.util.trim(val)}if(val.length>0)t.attr[name]=val}}}return t},_GetNodeAdjustSiblings:function(e,t){t.withId={};var i=BX.findParent(e,{attr:{id:new RegExp(".+","ig")}});if(i)t.withId.parent=i.getAttribute("id");var s=BX.findChild(e,{attr:{id:new RegExp(".+","ig")}},true,true);if(s){t.withId.children=[];for(var r=0,o=s.length;r<o;r++)t.withId.children.push(s[r].getAttribute("id"))}var a=BX.findPreviousSibling(e,{attr:{id:new RegExp(".+","ig")}});if(a)t.withId.prevSibling=a.getAttribute("id");var n=BX.findNextSibling(e,{attr:{id:new RegExp(".+","ig")}});if(n)t.withId.nextSibling=n.getAttribute("id");return t},FindMarkerNode:function(e){var t=false;if(!e||!e.nodeName)return false;if(!e.attr)e.attr={};if(e.attr.id)t=BX(e.attr.id);var i=[];var s;if(!t){if(!e.withId)e.withId={};if(e.withId.prevSibling){var r=BX(e.withId.prevSibling);if(r){while(r=r.nextSibling){s=this.TestNodeWithAttributes(r,e);if(s)i.push(s);if(s.coincide==100)break}}}if(e.withId.nextSibling){var o=BX(e.withId.nextSibling);if(o){while(o=o.previousSibling){s=this.TestNodeWithAttributes(o,e);if(s)i.push(s);if(s.coincide==100)break}}}if(e.withId.children){var a,n=e.withId.children.length,l,d;for(a=0;a<n;a++){l=BX(e.withId.children[a]);if(l){d=l;while(true){d=BX.findParent(d,{tagName:e.nodeName});if(!d)break;s=this.TestNodeWithAttributes(o,e);if(s)i.push(s);if(s.coincide==100)break}}}}var c;if(e.withId.parent)c=BX(e.withId.parent);if(!c)c=document.body;var h=c.getElementsByTagName(e.nodeName);var a,n=h.length;for(a=0;a<n;a++){s=this.TestNodeWithAttributes(h[a],e);if(s)i.push(s);if(s.coincide==100)break}}else{i.push({coincide:100,node:t,bImpAttrCoincide:true})}var a,n=i.length;var p=[],u=0,f=false;for(a=0;a<n;a++){if(i[a].coincide>u){u=i[a].coincide;f=i[a].node;p=[]}if(i[a].coincide==u&&i[a].node!=f)p.push(i[a].node)}if(p.length==0&&f)return f;else p[0];return false},TestNodeWithAttributes:function(e,t){if(!e||!e.nodeName)return false;var s={coincide:0,node:e};var r=this._GetNodeAdjustInfo(e);if(r.nodeName!=t.nodeName)return false;var o=0;var a=typeof t.innerHTML=="string";if(typeof r.innerHTML!="string"&&a)return false;var n=0;for(i in t.attr)if(typeof t.attr[i]=="string")n++;if(n>0){o=100/(n+(a?1:0));var l=true;for(i in t.attr){if(typeof t.attr[i]=="string"){if(t.attr[i]==r.attr[i])s.coincide+=o;else if(this.oMarkerConfig.impAttr[i])l=false}}s.bImpAttrCoincide=l}if(a&&r.innerHTML==t.innerHTML)s.coincide+=n>0?o:95;s.coincide=Math.round(s.coincide);if(s.coincide>0)return s;return false},OnDivMouseOver:function(e,t){var i=this.arStickers[e];if(i.bSetMarkerMode)return this.ShowButtonsPanel(e,true,false);i._over=t;if(i._overTimeout)clearTimeout(i._overTimeout);var s=this;i._overTimeout=setTimeout(function(){if(i._over==t){s.ShowButtonsPanel(e,t);s.Hightlight(e,t)}},t?100:500)},ShowButtonsPanel:function(e,t,i){if(!this.Params.bHideBottom){t=true;i=false}i=i!==false;var s=this,r=this.arStickers[e],o=24,a=3,n=1,l=r.obj.height-(r.bButPanelShowed?0:o),d=l+o*(t?1:-1),c=BX.browser.IsIE()?3:10;if(this.bSelectAreaMode||this.bHightlightElementMode||r.obj.collapsed||r.obj.closed||r.bColSelShowed||r.bResizingNow)return;if(r.bButPanelShowed==t){r.pWin.Get().style.height=l+"px";return this.AdjustShadow(e)}var h=setInterval(function(){l+=a*n*(t?1:-1);if(t&&l>=d||!t&&l<=d)l=d;r.pWin.Get().style.height=l+"px";s.AdjustShadow(e);if(l==d){clearInterval(h);r.bButPanelShowed=t}n++},c)},ShowColorSelector:function(e){var t=this,i=this.arStickers[e],s;if(!i)return;if(!i.pColSelector){i.pColSelector=document.body.appendChild(BX.create("DIV",{props:{className:"bxst-col-sel"}}));for(var r=0,o=this.colorSchemes.length;r<o;r++){s=i.pColSelector.appendChild(BX.create("SPAN",{props:{id:"bxst_"+e+"_"+r,className:"bxst-col-pic "+this.colorSchemes[r].name,title:this.colorSchemes[r].title}}));s.onclick=function(){t.ChangeColor(e,parseInt(this.id.substr(("bxst_"+e+"_").length)),true,true);t.ShowColorSelector(e)}}i.pColSelector.style.zIndex=this.Params.zIndex+20}i.bColSelShowed=!i.bColSelShowed;if(i.bColSelShowed){var a=BX.pos(i.pColorBut);i.pColSelector.style.top=parseInt(a.top)+16+"px";i.pColSelector.style.left=a.left+"px";i.pColSelector.style.display="block";this.ShowOverlay(true,this.Params.zIndex+15);this.pTransOverlay.onmousedown=function(){t.ShowColorSelector(e)};BX.bind(document,"keydown",BX.proxy(function(t){this.OnKeyDown(t,e)},this))}else{i.pColSelector.style.display="none";this.ShowOverlay(false);BX.unbind(document,"keydown",BX.proxy(function(t){this.OnKeyDown(t,e)},this))}},ShowOverlay:function(e,t){if(!this.pTransOverlay)this.pTransOverlay=document.body.appendChild(BX.create("DIV",{props:{className:"bxst-trans-overlay"}}));if(e){this.pTransOverlay.style.display="block";this.pTransOverlay.style.zIndex=t||800;var i=BX.GetWindowScrollSize(document);this.pTransOverlay.style.width=i.scrollWidth+"px";this.pTransOverlay.style.height=i.scrollHeight+"px"}else{this.pTransOverlay.style.display="none";this.pTransOverlay.onmousedown=BX.False}},OnKeyDown:function(e,t){if(!e)e=window.event;var i=e.which||e.keyCode;if(i==27){var s=this.arStickers[t];if(s&&s.bColSelShowed)this.ShowColorSelector(t)}},Hightlight:function(e,t){var i=this.arStickers[e];if(i.bOver===t)return;i.bOver=t;if(t){if(i.pMarker)BX.addClass(i.pMarker,"bxst-marker-over");BX.addClass(i.pWin.Get(),"bx-sticker-over");BX.addClass(i.pHead,"bxst-header-over");i.pWin.Get().style.top=parseInt(i.pWin.Get().style.top)-1+"px";i.pWin.Get().style.left=parseInt(i.pWin.Get().style.left)-1+"px"}else{if(i.pMarker)BX.removeClass(i.pMarker,"bxst-marker-over");BX.removeClass(i.pWin.Get(),"bx-sticker-over");BX.removeClass(i.pHead,"bxst-header-over");i.pWin.Get().style.top=parseInt(i.pWin.Get().style.top)+1+"px";i.pWin.Get().style.left=parseInt(i.pWin.Get().style.left)+1+"px"}},BlinkRed:function(e){var t=this,i=4,s=0,r=0,o,a=this.arStickers[e];if(!this.pBlinkRed)this.pBlinkRed=document.body.appendChild(BX.create("DIV",{props:{className:"bxst-blink-red"}}));this.pBlinkRed.style.zIndex=parseInt(a.pWin.Get().style.zIndex)+10;this.pBlinkRed.style.top=a.pWin.Get().style.top;this.pBlinkRed.style.left=a.pWin.Get().style.left;this.pBlinkRed.style.width=a.pWin.Get().style.width;this.pBlinkRed.style.height=a.pWin.Get().style.height;bFadeIn=true;o=setInterval(function(){if(s>2){if(bFadeIn){t.pBlinkRed.className="bxst-blink-red bx-sticker-op-3";s=1}else{t.pBlinkRed.className="bxst-blink-red";s=0}r++;bFadeIn=!bFadeIn;if(r>=i)clearInterval(o);return}if(bFadeIn)t.pBlinkRed.className="bxst-blink-red bx-sticker-op-"+s;else t.pBlinkRed.className="bxst-blink-red bx-sticker-op-"+(3-s);s++},BX.browser.IsIE()?30:60)},ShowList:function(e){if(!this.List)this.List=new BXStickerList(this);this.List.Show(e)},OnKeyUp:function(e){if(!e)e=window.event;var t=e.which||e.keyCode;if(t==17){var i=this;this._bCtrlPressed=true;setTimeout(function(){i._bCtrlPressed=false},400)}else if(t==16){var i=this;this._bShiftPressed=true;setTimeout(function(){i._bShiftPressed=false},400)}else if((this._bShiftPressed||e.shiftKey)&&(e.ctrlKey||this._bCtrlPressed)){if(t==83&&this.Params.access=="W"){this.AddSticker();return BX.PreventDefault(e)}else if(t==88){this.ShowAll();return BX.PreventDefault(e)}else if(t==76){this.ShowList("current");return BX.PreventDefault(e)}}},UpdateStickersCount:function(){if(this.curPageCount<0||isNaN(parseInt(this.curPageCount)))this.curPageCount=0;var e=BX.findChild(BX("bxst-show-sticker-icon"),{tagName:"B"},true);if(e)e.innerHTML="("+this.curPageCount+")"}};function BXStickerList(e){this.BXSticker=e;this.access=this.BXSticker.access;this.MESS=this.BXSticker.MESS;this.arCurPageIds={}}BXStickerList.prototype={Show:function(e){if(this.bShowed)return;var t={content_url:"/bitrix/admin/fileman_stickers.php?sticker_action=show_list&"+this.BXSticker.sessid_get+"&cur_page="+encodeURIComponent(this.BXSticker.Params.pageUrl)+"&type="+e+"&site_id="+this.BXSticker.Params.site_id,title:this.MESS.StickerListTitle,width:this.BXSticker.Params.listWidth,height:this.BXSticker.Params.listHeight,min_width:800,min_height:400,resizable:true,resize_id:"bx_sticker_list_resize_id"};this.type=e;this.bRefreshPage=false;this.naviSize=this.BXSticker.Params.listNaviSize;this.oDialog=new BX.CDialog(t);this.oDialog.Show();this.oDialog.SetButtons([this.oDialog.btnClose]);this.bShowed=true;var i=this;BX.addCustomEvent(this.oDialog,"onWindowUnRegister",function(){i.bShowed=false;if(i.bRefreshPage)window.location=window.location});BX.addCustomEvent(this.oDialog,"onWindowResizeFinished",function(){i.AdjustNaviSize()});BX.addCustomEvent(this.oDialog,"onWindowExpand",function(){i.AdjustNaviSize()});BX.addCustomEvent(this.oDialog,"onWindowNarrow",function(){i.AdjustNaviSize()})},OnLoad:function(e){this.pAllBut=BX("bxstl_fil_all_but");this.pMyBut=BX("bxstl_fil_my_but");this.pColorCont=BX("bxstl_col_cont");this.pOpenedBut=BX("bxstl_fil_opened_but");this.pClosedBut=BX("bxstl_fil_closed_but");this.pAllStickersBut=BX("bxstl_fil_all_p_but");this.pItemsTable=BX("bxstl_items_table");this.pItemsTableCnt=BX("bxstl_items_table_cnt");this.pNaviCont=BX("bxstl_navi_cont");if(this.access=="W"){this.pActionSel=BX("bxstl_action_sel");this.pActionBut=BX("bxstl_action_ok")}this.pPageSelect=BX("bxstl_fil_page_sel");if(this.type=="current"){this.BXSticker.Params.filterParams.status="all";this.BXSticker.Params.filterParams.page="current"}else if(this.type=="all"){this.BXSticker.Params.filterParams.status="opened";this.BXSticker.Params.filterParams.page="all"}var t=this;var i=this.BXSticker.Params.filterParams.colors;if(i&&i!="all"&&i.length>0){this.checkedColors=[false,false,false,false,false,false];for(var s=0,r=i.length;s<r;s++)if(i[s]!=99)this.checkedColors[parseInt(i[s])]=true}else{this.checkedColors=[true,true,true,true,true,true]}if(!this.bRefreshPage&&window.__bxst_result.cur_page_ids!==false&&typeof window.__bxst_result.cur_page_ids=="object"){for(var s in window.__bxst_result.cur_page_ids)this.arCurPageIds[parseInt(window.__bxst_result.cur_page_ids[s])]=true}var s,r=this.BXSticker.colorSchemes.length,o,a,n=BX.browser.IsIE()&&!BX.browser.IsDoctype()?'style="width: 12px; height: 12px"':"";for(s=0;s<r;s++){o=this.BXSticker.colorSchemes[s];a=this.pColorCont.appendChild(BX.create("DIV",{props:{id:"bxstl_color_"+s,className:"bxstl-color-pick"+(this.checkedColors[s]?" bxstl-color-pick-ch":""),title:o.title},html:'<div class="bxstl-col-pic-l"></div><div class="bxstl-col-pic-c"><div class="'+o.name+'" '+n+'> </div></div><div class="bxstl-col-pic-r"></div>'}));a.onclick=function(){var e=parseInt(this.id.substr("bxstl_color_".length));t.checkedColors[e]=!t.checkedColors[e];if(t.checkedColors[e])BX.addClass(this,"bxstl-color-pick-ch");else BX.removeClass(this,"bxstl-color-pick-ch");t.ReloadList()}}this.SetStickerType(this.BXSticker.Params.filterParams.type,false);this.pAllBut.onclick=function(){t.SetStickerType("all")};this.pMyBut.onclick=function(){t.SetStickerType("my")};this.SetStickerStatus(this.BXSticker.Params.filterParams.status,false);this.pOpenedBut.onclick=function(){t.SetStickerStatus("opened")};this.pClosedBut.onclick=function(){t.SetStickerStatus("closed")};this.pAllStickersBut.onclick=function(){t.SetStickerStatus("all")};if(this.access=="W")this.pActionBut.onclick=function(){t.Action()};this.pPageSelect.onchange=function(){t.SetPage(this.value)};this.SetPage(this.BXSticker.Params.filterParams.page=="current"?this.BXSticker.Params.pageUrl:this.BXSticker.Params.filterParams.page,false);e=parseInt(e);this.oDialog.SetTitle(this.MESS.StickerListTitle+" ("+e+")");this.EnableActionBut(false)},SetStickerStatus:function(e,t){if(e=="opened"){BX.addClass(this.pOpenedBut,"bxstl-but-checked");BX.removeClass(this.pClosedBut,"bxstl-but-checked");BX.removeClass(this.pAllStickersBut,"bxstl-but-checked")}else if(e=="closed"){BX.removeClass(this.pOpenedBut,"bxstl-but-checked");BX.addClass(this.pClosedBut,"bxstl-but-checked");BX.removeClass(this.pAllStickersBut,"bxstl-but-checked")}else{BX.removeClass(this.pOpenedBut,"bxstl-but-checked");BX.removeClass(this.pClosedBut,"bxstl-but-checked");BX.addClass(this.pAllStickersBut,"bxstl-but-checked")}this.StickersStatus=e;if(t!==false)this.ReloadList()},SetStickerType:function(e,t){if(e=="all"){BX.addClass(this.pAllBut,"bxstl-but-checked");BX.removeClass(this.pMyBut,"bxstl-but-checked")}else{BX.addClass(this.pMyBut,"bxstl-but-checked");BX.removeClass(this.pAllBut,"bxstl-but-checked")}this.StickersType=e;if(t!==false)this.ReloadList()},SetPage:function(e,t){this.pPageSelect.value=e;this.StickersPage=e;if(t!==false)this.ReloadList()},NaviGet:function(e,t){var i={};i["PAGEN_"+t]=e;this.ReloadList(i)},ReloadList:function(e){var t=this;if(!e)e={};e.sticker_just_res="Y";e.colors=[99];e.sticker_type=this.StickersType;e.sticker_status=this.StickersStatus;e.sticker_page=this.StickersPage;e.navi_size=this.naviSize;e.cur_page=this.BXSticker.Params.pageUrl;e.type=this.type;var i,s=this.checkedColors.length;for(i=0;i<s;i++)if(this.checkedColors[i]===true)e.colors.push(i);window.__bxst_result.list_rows_count=false;window.__bxst_result.cur_page_ids=false;this.BXSticker.Request("show_list",e,function(e){var i=e.split("#BX_STICKER_SPLITER#");if(i.length==2){t.pItemsTableCnt.innerHTML=i[0];t.pNaviCont.innerHTML=i[1]}if(window.__bxst_result.list_rows_count!==false)t.oDialog.SetTitle(t.MESS.StickerListTitle+" ("+parseInt(window.__bxst_result.list_rows_count)+")");if(!t.bRefreshPage&&window.__bxst_result.cur_page_ids!==false&&typeof window.__bxst_result.cur_page_ids=="object"){for(var s in window.__bxst_result.cur_page_ids)t.arCurPageIds[parseInt(window.__bxst_result.cur_page_ids[s])]=true}t.pItemsTable=BX("bxstl_items_table");t.EnableActionBut(false)},true)},AdjustToSize:function(e,t){return},AdjustNaviSize:function(){var e,t=parseInt(this.oDialog.GetContent().style.height),i=40,s=t-100-80;if(s!=i*this.naviSize)e=Math.floor(s/i);if(e<5)e=5;if(e>30)e=30;if(this.naviSize!=e){this.naviSize=e;this.ReloadList()}},CheckAll:function(e){var t,i=this.pItemsTable.rows.length,s=false;for(t=1;t<i;t++){if(this.pItemsTable.rows[t].cells.length==7){this.pItemsTable.rows[t].cells[6].firstChild.checked=!!e;s=true}}if(s)this.EnableActionBut(e)},Action:function(){if(this.access!="W")return;var e=this.pActionSel.value;if(e==""||e=="del"&&!confirm(this.MESS.DelConfirm))return;var t,i=this.pItemsTable.rows.length,s=[];for(t=1;t<i;t++){if(this.pItemsTable.rows[t].cells.length<7)continue;ch=this.pItemsTable.rows[t].cells[6].firstChild;if(ch.checked){s.push(ch.value);if(!this.bRefreshPage&&this.arCurPageIds[parseInt(ch.value)])this.bRefreshPage=true}}this.ReloadList({list_action:e,list_ids:s})},EnableActionBut:function(e){if(this.access!="W")return;if(e=="check"){var t,i=this.pItemsTable.rows.length,e=false;for(t=1;t<i;t++){if(this.pItemsTable.rows[t].cells.length<7)continue;if(this.pItemsTable.rows[t].cells[6].firstChild.checked){e=true;break}}}this.pActionBut.disabled=!e;this.pActionSel.disabled=!e}}; //# sourceMappingURL=sticker.map.js