Your IP : 3.144.233.71


Current Path : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/calendar/
Upload File :
Current File : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/calendar/core_planner_handler.min.js

(function(){if(!!window.BX.CCalendarPlannerHandler)return;var t=window.BX;t.CCalendarPlannerHandler=function(){this.PLANNER=null;this.EVENTS=null;this.EVENTS_LIST=null;this.EVENTWND={};this.CLOCK=null;t.addCustomEvent("onPlannerDataRecieved",t.proxy(this.draw,this))};t.CCalendarPlannerHandler.prototype.draw=function(e,a){if(!!this._skipDraw){this._skipDraw=false;return}this.PLANNER=e;if(!a.CALENDAR_ENABLED)return;if(!this.EVENTS){this.EVENTS=t.create("DIV");this.EVENTS.appendChild(t.create("DIV",{props:{className:"tm-popup-section tm-popup-section-events"},html:'<span class="tm-popup-section-text">'+t.message("JS_CORE_PL_EVENTS")+"</span>"}));this.EVENTS.appendChild(t.create("DIV",{props:{className:"tm-popup-events"+(t.isAmPmMode()?" tm-popup-events-ampm":"")},children:[this.EVENTS_LIST=t.create("DIV",{props:{className:"tm-popup-event-list"}}),this.drawEventForm(t.proxy(this._createEventCallback,this))]}))}else{t.cleanNode(this.EVENTS_LIST)}if(a.EVENTS.length>0){t.removeClass(this.EVENTS,"tm-popup-events-empty");var s=null;for(var p=0,n=a.EVENTS.length;p<n;p++){var i=this.EVENTS_LIST.appendChild(this.drawEvent(a.EVENTS[p]));if(a.EVENT_LAST_ID&&a.EVENT_LAST_ID==a.EVENTS[p].ID)s=i}if(!!s){t.defer(function(){if(s.offsetTop<this.EVENTS_LIST.scrollTop||s.offsetTop+s.offsetHeight>this.EVENTS_LIST.scrollTop+this.EVENTS_LIST.offsetHeight){this.EVENTS_LIST.scrollTop=s.offsetTop-parseInt(this.EVENTS_LIST.offsetHeight/2)}},this)()}}else{t.addClass(this.EVENTS,"tm-popup-events-empty")}e.addBlock(this.EVENTS,300)};t.CCalendarPlannerHandler.prototype.drawEvent=function(e,a,s){a=a||{};a.className="tm-popup-event-name";s=s||false;return t.create("DIV",{props:{className:"tm-popup-event",bx_event_id:e.ID},children:[t.create("DIV",{props:{className:"tm-popup-event-datetime"},html:'<span class="tm-popup-event-time-start'+(e.DATE_FROM_TODAY?"":" tm-popup-event-time-passed")+'">'+(s?t.timeman.formatDate(e.DATE_FROM)+" ":"")+e.TIME_FROM+'</span><span class="tm-popup-event-separator">-</span><span class="tm-popup-event-time-end'+(e.DATE_TO_TODAY?"":" tm-popup-event-time-passed")+'">'+(s?t.timeman.formatDate(e.DATE_TO)+" ":"")+e.TIME_TO+"</span>"}),t.create("DIV",{props:a,events:e.ID?{click:t.proxy(this.showEvent,this)}:null,html:'<span class="tm-popup-event-text">'+t.util.htmlspecialchars(e.NAME)+"</span>"})]})};t.CCalendarPlannerHandler.prototype.showEvent=function(e){var a=t.proxy_context.parentNode.bx_event_id;if(this.EVENTWND[a]&&this.EVENTWND[a].node!=t.proxy_context){this.EVENTWND[a].Clear();this.EVENTWND[a]=null}if(!this.EVENTWND[a]){this.EVENTWND[a]=new t.CCalendarPlannerEventPopup({planner:this.PLANNER,node:t.proxy_context,bind:this.EVENTS.firstChild,id:a})}t.onCustomEvent(this,"onEventWndShow",[this.EVENTWND[a]]);this._skipDraw=true;this.EVENTWND[a].Show(this.PLANNER);return t.PreventDefault(e)};t.CCalendarPlannerHandler.prototype.drawEventForm=function(s){var p=t.isAmPmMode()?"_am_pm":"";var n=t.delegate(function(e,a){l.value=t.util.trim(l.value);if(l.value&&l.value!=t.message("JS_CORE_PL_EVENTS_ADD")){s({from:r.value,to:o.value,name:l.value,absence:d.checked?"Y":"N"});t.timer.start(r.bxtimer);t.timer.start(o.bxtimer);if(!a){t.addClass(l.parentNode,"tm-popup-event-form-disabled");l.value=t.message("JS_CORE_PL_EVENTS_ADD")}else{l.value=""}}return e||window.event?t.PreventDefault(e):null},this),i=function(){t.removeClass(this.parentNode,"tm-popup-event-form-disabled");if(this.value==t.message("JS_CORE_PL_EVENTS_ADD"))this.value=""};var r=t.create("INPUT",{props:{type:"text",className:"tm-popup-event-start-time-textbox"+p}});r.onclick=t.delegate(function(){var s=t.delegate(function(s){this.CLOCK.closeWnd();var p=a(r.value),n=a(o.value);var i=3600;if(p&&n)i=n-p;t.timer.stop(r.bxtimer);t.timer.stop(o.bxtimer);r.value=s;o.value=e(a(s)+i);o.focus();o.onclick()},this);if(!this.CLOCK){this.CLOCK=new t.CClockSelector({start_time:a(r.value),node:r,callback:s})}else{this.CLOCK.setNode(r);this.CLOCK.setTime(a(r.value));this.CLOCK.setCallback(s)}r.blur();this.CLOCK.Show()},this);r.bxtimer=t.timer(r,{dt:36e5,accuracy:3600});var o=t.create("INPUT",{props:{type:"text",className:"tm-popup-event-end-time-textbox"+p}});o.onclick=t.delegate(function(){var e=t.delegate(function(e){this.CLOCK.closeWnd();o.value=e;t.timer.stop(r.bxtimer);t.timer.stop(o.bxtimer);l.focus();i.apply(l)},this);if(!this.CLOCK){this.CLOCK=new t.CClockSelector({start_time:a(o.value),node:o,callback:e})}else{this.CLOCK.setNode(o);this.CLOCK.setTime(a(o.value));this.CLOCK.setCallback(e)}o.blur();this.CLOCK.Show()},this);o.bxtimer=t.timer(o,{dt:72e5,accuracy:3600});var l=t.create("INPUT",{props:{type:"text",className:"tm-popup-event-form-textbox"+p,value:t.message("JS_CORE_PL_EVENTS_ADD")},events:{keypress:function(t){return t.keyCode==13?n(t,true):true},blur:function(){if(this.value==""){t.addClass(this.parentNode,"tm-popup-event-form-disabled");this.value=t.message("JS_CORE_PL_EVENTS_ADD")}},focus:i}});var u="bx_tm_absence_"+Math.random();var d=t.create("INPUT",{props:{type:"checkbox",className:"checkbox",id:u}});this.EVENTS_FORM=t.create("DIV",{props:{className:"tm-popup-event-form tm-popup-event-form-disabled"},children:[r,o,l,t.create("SPAN",{props:{className:"tm-popup-event-form-submit"},events:{click:n}}),t.create("DIV",{props:{className:"tm-popup-event-form-options"},children:[d,t.create("LABEL",{props:{htmlFor:u},text:t.message("JS_CORE_PL_EVENT_ABSENT")})]})]});return this.EVENTS_FORM};t.CCalendarPlannerHandler.prototype._createEventCallback=function(e){calendarLastParams=e;this.PLANNER.query("calendar_add",e);this.EVENTS_LIST.appendChild(this.drawEvent({DATE_FROM_TODAY:true,DATE_TO_TODAY:true,NAME:t.util.htmlspecialchars(e.name),TIME_FROM:e.from,TIME_TO:e.to}))};t.CCalendarPlannerEventPopup=function(e){this.params=e;this.node=e.node;var a=false;this.popup=t.PopupWindowManager.create("event_"+this.params.id,this.params.bind,{closeIcon:{right:"12px",top:"10px"},closeByEsc:true,offsetLeft:a||document.documentMode&&document.documentMode<=7?-347:-340,autoHide:true,bindOptions:{forceBindPosition:true,forceTop:true},angle:{position:"right",offset:this.params.angle_offset||27}});t.addCustomEvent(this.parent,"onEventWndShow",t.delegate(this.onEventWndShow,this));this.bSkipShow=false;this.isReady=false};t.CCalendarPlannerEventPopup.prototype.onEventWndShow=function(t){if(t!=this){if(this.popup)this.popup.close();else this.bSkipShow=true}};t.CCalendarPlannerEventPopup.prototype.Show=function(e,a){t.removeCustomEvent(e,"onPlannerDataRecieved",t.proxy(this.Show,this));a=a||this.data;if(a&&a.error)return;if(!a){t.addCustomEvent(e,"onPlannerDataRecieved",t.proxy(this.Show,this));return e.query("calendar_show",{id:this.params.id})}if(a.EVENT){a=a.EVENT}this.data=a;if(this.bSkipShow){this.bSkipShow=false}else{this.popup.setContent(this.GetContent());this.popup.setButtons(this.GetButtons());var s=0;if(this.params.node&&this.params.node.parentNode&&this.params.node.parentNode.parentNode){s=this.params.node.parentNode.offsetTop-this.params.node.parentNode.parentNode.scrollTop}this.popup.setOffset({offsetTop:this.params.offsetTop||s-20});this.popup.adjustPosition();this.popup.show()}return true};t.CCalendarPlannerEventPopup.prototype.GetContent=function(){var e='<div class="tm-event-popup">',a='<div class="popup-window-hr"><i></i></div>';e+='<div class="tm-popup-title"><a class="tm-popup-title-link" href="'+this.data.URL+'">'+t.util.htmlspecialchars(this.data.NAME)+"</a></div>";if(this.data.DESCRIPTION){e+=a+'<div class="tm-event-popup-description">'+this.data.DESCRIPTION+"</div>"}e+=a;e+='<div class="tm-event-popup-time"><div class="tm-event-popup-time-interval">'+this.data.DATE_F+"</div>";if(this.data.DATE_F_TO&&this.data.DATE_F_TO>0)e+='<div class="tm-event-popup-time-hint">('+this.data.DATE_F_TO+")</div></div>";if(this.data.GUESTS){e+=a+'<div class="tm-event-popup-participants">';if(this.data.HOST){e+='<div class="tm-event-popup-participant"><div class="tm-event-popup-participant-status tm-event-popup-participant-status-accept"></div><div class="tm-event-popup-participant-name"><a class="tm-event-popup-participant-link" href="'+this.data.HOST.url+'">'+this.data.HOST.name+'</a><span class="tm-event-popup-participant-hint">'+t.message("JS_CORE_PL_EVENT_HOST")+"</span></div></div>"}if(this.data.GUESTS.length>0){e+='<table cellspacing="0" class="tm-event-popup-participants-grid"><tbody><tr>';var s=Math.ceil(this.data.GUESTS.length/2),p=["",""];for(var n=0;n<this.data.GUESTS.length;n++){var i="";if(this.data.GUESTS[n].status=="Y")i="tm-event-popup-participant-status-accept";else if(this.data.GUESTS[n].status=="N")i="tm-event-popup-participant-status-decline";p[n<s?0:1]+='<div class="tm-event-popup-participant"><div class="tm-event-popup-participant-status '+i+'"></div><div class="tm-event-popup-participant-name"><a class="tm-event-popup-participant-link" href="'+this.data.GUESTS[n].url+'">'+this.data.GUESTS[n].name+"</a></div></div>"}e+='<td class="tm-event-popup-participants-grid-left">'+p[0]+'</td><td class="tm-event-popup-participants-grid-right">'+p[1]+"</td>";e+="</tr></tbody></table>"}e+="</div>"}e+="</div>";return e};t.CCalendarPlannerEventPopup.prototype.GetButtons=function(){var e=[],a=t.proxy(this.Query,this);if(this.data.STATUS==="Q"){e.push(new t.PopupWindowButton({text:t.message("JS_CORE_PL_EVENT_CONFIRM"),className:"popup-window-button-create",events:{click:function(){a("CONFIRM=Y")}}}));e.push(new t.PopupWindowButton({text:t.message("JS_CORE_PL_EVENT_REJECT"),className:"popup-window-button-cancel",events:{click:function(){a("CONFIRM=N")}}}))}else{e.push(new t.PopupWindowButtonLink({text:t.message("JS_CORE_WINDOW_CLOSE"),className:"popup-window-button-link-cancel",events:{click:function(e){this.popupWindow.close();return t.PreventDefault(e)}}}))}return e};t.CCalendarPlannerEventPopup.prototype.Clear=function(){if(this.popup){this.popup.close();this.popup.destroy();this.popup=null}this.node=null};t.CCalendarPlannerEventPopup.prototype.Query=function(e){t.ajax({method:"GET",url:this.data.URL+"&"+e,processData:false,onsuccess:t.proxy(this._Query,this)})};t.CCalendarPlannerEventPopup.prototype._Query=function(){this.data=null;this.Show()};function e(e,a,s){var p="";if(t.isAmPmMode()&&!s){if(parseInt(e/3600)>12){e=parseInt(e)-12*3600;p=" pm"}else if(parseInt(e/3600)==12){p=" pm"}else if(parseInt(e/3600)==0){e=parseInt(e)+12*3600;p=" am"}else p=" am";if(!!a)return parseInt(e/3600)+":"+t.util.str_pad(parseInt(e%3600/60),2,"0","left")+":"+t.util.str_pad(e%60,2,"0","left")+p;else return parseInt(e/3600)+":"+t.util.str_pad(parseInt(e%3600/60),2,"0","left")+p}else{if(!!a)return t.util.str_pad(parseInt(e/3600),2,"0","left")+":"+t.util.str_pad(parseInt(e%3600/60),2,"0","left")+":"+t.util.str_pad(e%60,2,"0","left")+p;else return t.util.str_pad(parseInt(e/3600),2,"0","left")+":"+t.util.str_pad(parseInt(e%3600/60),2,"0","left")+p}}function a(t){var e=t.split(/[\s:]+/);if(e.length==3){var a=e[2];if(a=="pm"&&e[0]<12)e[0]=parseInt(e[0],10)+12;if(a=="am"&&e[0]==12)e[0]=0}return parseInt(e[0],10)*3600+parseInt(e[1],10)*60}new t.CCalendarPlannerHandler})();
//# sourceMappingURL=core_planner_handler.map.js