odoo/addons/base_calendar/static/lib/dhtmlxScheduler/codebase/ext/dhtmlxscheduler_year_view.js

9 lines
6.6 KiB
JavaScript
Raw Normal View History

/*
dhtmlxScheduler v.2.3
This software is allowed to use under GPL or you need to obtain Commercial or Enterise License
to use it in not GPL project. Please contact sales@dhtmlx.com for details
(c) DHTMLX Ltd.
*/
scheduler.config.year_x=4;scheduler.config.year_y=3;scheduler.config.year_mode_name="year";scheduler.xy.year_top=0;scheduler.templates.year_date=function(A){return scheduler.date.date_to_str(scheduler.locale.labels.year_tab+" %Y")(A)};scheduler.templates.year_month=scheduler.date.date_to_str("%F");scheduler.templates.year_scale_date=scheduler.date.date_to_str("%D");scheduler.templates.year_tooltip=function(A,C,B){return B.text};(function(){var F=function(){return scheduler._mode==scheduler.config.year_mode_name};scheduler.dblclick_dhx_month_head=function(J){if(F()){var I=(J.target||J.srcElement);if(I.parentNode.className.indexOf("dhx_before")!=-1||I.parentNode.className.indexOf("dhx_after")!=-1){return false}var K=this.templates.xml_date(I.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.getAttribute("date"));K.setDate(parseInt(I.innerHTML,10));var H=this.date.add(K,1,"day");if(!this.config.readonly&&this.config.dblclick_create){this.addEventNow(K.valueOf(),H.valueOf(),J)}}};var C=scheduler.changeEventId;scheduler.changeEventId=function(){C.apply(this,arguments);if(F()){this.year_view(true)}};var B=scheduler.render_data;var G=scheduler.date.date_to_str("%Y/%m/%d");var E=scheduler.date.str_to_date("%Y/%m/%d");scheduler.render_data=function(H){if(!F()){return B.apply(this,arguments)}for(var I=0;I<H.length;I++){this._year_render_event(H[I])}};var A=scheduler.clear_view;scheduler.clear_view=function(){if(!F()){return A.apply(this,arguments)}for(var H=0;H<D.length;H++){D[H].className="dhx_month_head";D[H].setAttribute("date","")}D=[]};scheduler.hideToolTip=function(){if(this._tooltip){this._tooltip.style.display="none";this._tooltip.date=new Date(9999,1,1)}};scheduler.showToolTip=function(I,O,M,N){if(this._tooltip){if(this._tooltip.date.valueOf()==I.valueOf()){return }this._tooltip.innerHTML=""}else{var L=this._tooltip=document.createElement("DIV");L.className="dhx_tooltip";document.body.appendChild(L);L.onclick=scheduler._click.dhx_cal_data}var H=this.getEvents(I,this.date.add(I,1,"day"));var K="";for(var J=0;J<H.length;J++){K+="<div class='dhx_tooltip_line' event_id='"+H[J].id+"'>";K+="<div class='dhx_tooltip_date'>"+(H[J]._timed?this.templates.event_date(H[J].start_date):"")+"</div>";K+="<div class='dhx_event_icon icon_details'>&nbsp;</div>";K+=this.templates.year_tooltip(H[J].start_date,H[J].end_date,H[J])+"</div>"}this._tooltip.style.display="";this._tooltip.style.top="0px";if(document.body.offsetWidth-O.left-this._tooltip.offsetWidth<0){this._tooltip.style.left=O.left-this._tooltip.offsetWidth+"px"}else{this._tooltip.style.left=O.left+N.offsetWidth+"px"}this._tooltip.date=I;this._tooltip.innerHTML=K;if(document.body.offsetHeight-O.top-this._tooltip.offsetHeight<0){this._tooltip.style.top=O.top-this._tooltip.offsetHeight+N.offsetHeight+"px"}else{this._tooltip.style.top=O.top+"px"}};scheduler._init_year_tooltip=function(){dhtmlxEvent(scheduler._els.dhx_cal_data[0],"mouseover",function(H){if(!F()){return }var H=H||event;var I=H.target||H.srcElement;if((I.className||"").indexOf("dhx_year_event")!=-1){scheduler.showToolTip(E(I.getAttribute("date")),getOffset(I),H,I)}else{scheduler.hideToolTip()}});this._init_year_tooltip=function(){}};scheduler.attachEvent("onSchedulerResize",function(){if(F()){this.year_view(true);return false}return true});scheduler._get_year_cell=function(J){var H=J.getMonth()+12*(J.getFullYear()-this._min_date.getFullYear())-this.week_starts._month;var I=this._els.dhx_cal_data[0].childNodes[H];var J=this.week_starts[H]+J.getDate()-1;return I.childNodes[2].firstChild.rows[Math.floor(J/7)].cells[J%7].firstChild};var D=[];scheduler._mark_year_date=function(I,H){var J=this._get_year_cell(I);J.className="dhx_month_head dhx_year_event "+this.templates.event_class(H.start_date,H.end_date,H);J.setAttribute("date",G(I));D.push(J)};scheduler._unmark_year_date=function(H){this._get_year_cell(H).className="dhx_month_head"};scheduler._year_render_event=function(H){var I=H.start_date;if(I.valueOf()<this._min_date.valueOf()){I=this._min_date}else{I=this.date.date_part(new Date(I))}while(I<H.end_date){