";
for (var j=0; j<7; j++){
html+="=ed)
cls='dhx_after';
else if (sd.valueOf()==cd.valueOf())
cls='dhx_now';
html+=" class='"+cls+" "+this.templates.month_date_class(sd,cd)+"' ";
html+="> "+this.templates.month_day(sd)+" | "
sd=this.date.add(sd,1,"day");
}
html+="";
h[i] = cellheight;
cellheight+=this._colsS.height;
}
html+="";
this._max_date=sd;
b.innerHTML=html;
return sd;
}
scheduler.getLabel = function(property, key) {
var sections = this.config.lightbox.sections;
for (var i=0; i11?\"pm\":\"am\")+\"";
case "%A": return "\"+(date.getHours()>11?\"PM\":\"AM\")+\"";
case "%s": return "\"+scheduler.date.to_fixed(date.getSeconds())+\"";
case "%W": return "\"+scheduler.date.to_fixed(scheduler.date.getISOWeek(date))+\"";
default: return a;
}
})
if (utc) format=format.replace(/date\.get/g,"date.getUTC");
return new Function("date","return \""+format+"\";");
},
str_to_date:function(format,utc){
var splt="var temp=date.split(/[^0-9a-zA-Z]+/g);";
var mask=format.match(/%[a-zA-Z]/g);
for (var i=0; i50?1900:2000);";
break;
case "%g":
case "%G":
case "%h":
case "%H":
splt+="set[3]=temp["+i+"]||0;";
break;
case "%i":
splt+="set[4]=temp["+i+"]||0;";
break;
case "%Y": splt+="set[0]=temp["+i+"]||0;";
break;
case "%a":
case "%A": splt+="set[3]=set[3]%12+((temp["+i+"]||'').toLowerCase()=='am'?0:12);";
break;
case "%s": splt+="set[5]=temp["+i+"]||0;";
break;
}
}
var code ="set[0],set[1],set[2],set[3],set[4],set[5]";
if (utc) code =" Date.UTC("+code+")";
return new Function("date","var set=[0,0,1,0,0,0]; "+splt+" return new Date("+code+");");
},
getISOWeek: function(ndate) {
if(!ndate) return false;
var nday = ndate.getDay();
if (nday == 0) {
nday = 7;
}
var first_thursday = new Date(ndate.valueOf());
first_thursday.setDate(ndate.getDate() + (4 - nday));
var year_number = first_thursday.getFullYear(); // year of the first Thursday
var ordinal_date = Math.floor( (first_thursday.getTime() - new Date(year_number, 0, 1).getTime()) / 86400000); //ordinal date of the first Thursday - 1 (so not really ordinal date)
var week_number = 1 + Math.floor( ordinal_date / 7);
return week_number;
},
getUTCISOWeek: function(ndate){
return this.getISOWeek(ndate);
}
}
scheduler.locale={
date:{
month_full:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
month_short:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
day_full:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
day_short:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
},
labels:{
dhx_cal_today_button:"Today",
day_tab:"Day",
week_tab:"Week",
month_tab:"Month",
new_event:"New event",
icon_save:"Save",
icon_cancel:"Cancel",
icon_details:"Details",
icon_edit:"Edit",
icon_delete:"Delete",
confirm_closing:"",//Your changes will be lost, are your sure ?
confirm_deleting:"Event will be deleted permanently, are you sure?",
section_description:"Description",
section_time:"Time period",
full_day:"Full day",
/*recurring events*/
confirm_recurring:"Do you want to edit the whole set of repeated events?",
section_recurring:"Repeat event",
button_recurring:"Disabled",
button_recurring_open:"Enabled",
/*agenda view extension*/
agenda_tab:"Agenda",
date:"Date",
description:"Description",
/*year view extension*/
year_tab:"Year"
}
}
/*
%e Day of the month without leading zeros (01..31)
%d Day of the month, 2 digits with leading zeros (01..31)
%j Day of the year, 3 digits with leading zeros (001..366)
%a A textual representation of a day, two letters
%W A full textual representation of the day of the week
%c Numeric representation of a month, without leading zeros (0..12)
%m Numeric representation of a month, with leading zeros (00..12)
%b A short textual representation of a month, three letters (Jan..Dec)
%M A full textual representation of a month, such as January or March (January..December)
%y A two digit representation of a year (93..03)
%Y A full numeric representation of a year, 4 digits (1993..03)
*/
scheduler.config={
default_date: "%j %M %Y",
month_date: "%F %Y",
load_date: "%Y-%m-%d",
week_date: "%l",
day_date: "%D, %F %j",
hour_date: "%H:%i",
month_day : "%d",
xml_date:"%m/%d/%Y %H:%i",
api_date:"%d-%m-%Y %H:%i",
hour_size_px:42,
time_step:5,
start_on_monday:1,
first_hour:0,
last_hour:24,
readonly:false,
drag_resize:1,
drag_move:1,
drag_create:1,
dblclick_create:1,
edit_on_create:1,
details_on_create:0,
click_form_details:0,
server_utc:false,
positive_closing:false,
icons_edit:["icon_save","icon_cancel"],
icons_select:["icon_details","icon_edit","icon_delete"],
lightbox:{
sections:[ {name:"description", height:200, map_to:"text", type:"textarea" , focus:true},
{name:"time", height:72, type:"time", map_to:"auto"} ]
}
};
scheduler.templates={}
scheduler.init_templates=function(){
var d=scheduler.date.date_to_str;
var c=scheduler.config;
var f = function(a,b){
for (var c in b)
if (!a[c]) a[c]=b[c];
}
f(scheduler.templates,{
day_date:d(c.default_date),
month_date:d(c.month_date),
week_date:function(d1,d2){
return scheduler.templates.day_date(d1)+" – "+scheduler.templates.day_date(scheduler.date.add(d2,-1,"day"));
},
day_scale_date:d(c.default_date),
month_scale_date:d(c.week_date),
week_scale_date:d(c.day_date),
hour_scale:d(c.hour_date),
time_picker:d(c.hour_date),
event_date:d(c.hour_date),
month_day:d(c.month_day),
xml_date:scheduler.date.str_to_date(c.xml_date,c.server_utc),
load_format:d(c.load_date,c.server_utc),
xml_format:d(c.xml_date,c.server_utc),
api_date:scheduler.date.str_to_date(c.api_date),
event_header:function(start,end,ev){
return scheduler.templates.event_date(start)+" - "+scheduler.templates.event_date(end);
},
event_text:function(start,end,ev){
return ev.text;
},
event_class:function(start,end,ev){
return "";
},
month_date_class:function(d){
return "";
},
week_date_class:function(d){
return "";
},
event_bar_date:function(start,end,ev){
return scheduler.templates.event_date(start)+" ";
},
event_bar_text:function(start,end,ev){
return ev.text;
}
});
this.callEvent("onTemplatesReady",[])
}
scheduler.uid=function(){
if (!this._seed) this._seed=(new Date).valueOf();
return this._seed++;
};
scheduler._events={};
scheduler.clearAll=function(){
this._events={};
this._loaded={};
this.clear_view();
};
scheduler.addEvent=function(start_date,end_date,text,id,extra_data){
var ev=start_date;
if (arguments.length!=1){
ev=extra_data||{};
ev.start_date=start_date;
ev.end_date=end_date;
ev.text=text;
ev.id=id;
};
ev.id = ev.id||scheduler.uid();
ev.text = ev.text||"";
if (typeof ev.start_date == "string") ev.start_date=this.templates.api_date(ev.start_date);
if (typeof ev.end_date == "string") ev.end_date=this.templates.api_date(ev.end_date);
ev._timed=this.is_one_day_event(ev);
var is_new=!this._events[ev.id];
this._events[ev.id]=ev;
this.event_updated(ev);
if (!this._loading)
this.callEvent(is_new?"onEventAdded":"onEventChanged",[ev.id,ev]);
};
scheduler.deleteEvent=function(id,silent){
var ev=this._events[id];
if (!silent && !this.callEvent("onBeforeEventDelete",[id,ev])) return;
if (ev){
delete this._events[id];
this.unselect(id);
this.event_updated(ev);
}
};
scheduler.getEvent=function(id){
return this._events[id];
};
scheduler.setEvent=function(id,hash){
this._events[id]=hash;
};
scheduler.for_rendered=function(id,method){
for (var i=this._rendered.length-1; i>=0; i--)
if (this._rendered[i].getAttribute("event_id")==id)
method(this._rendered[i],i);
};
scheduler.changeEventId=function(id,new_id){
if (id == new_id) return;
var ev=this._events[id];
if (ev){
ev.id=new_id;
this._events[new_id]=ev;
delete this._events[id];
}
this.for_rendered(id,function(r){
r.setAttribute("event_id",new_id);
});
if (this._select_id==id) this._select_id=new_id;
if (this._edit_id==id) this._edit_id=new_id;
this.callEvent("onEventIdChange",[id,new_id]);
};
(function(){
var attrs=["text","Text","start_date","StartDate","end_date","EndDate"];
var create_getter=function(name){
return function(id){ return (scheduler.getEvent(id))[name]; };
};
var create_setter=function(name){
return function(id,value){
var ev=scheduler.getEvent(id); ev[name]=value;
ev._changed=true;
ev._timed=this.is_one_day_event(ev);
scheduler.event_updated(ev,true);
};
};
for (var i=0; i this._colsS.height-22){ // 22 - height of cell's header
//we have overflow, update heights
var cells = evl.rows[i].cells;
for (var j=0; j < cells.length; j++) {
cells[j].childNodes[1].style.height = h[i]*hb+"px";
}
h[i]=(h[i-1]||0)+cells[0].offsetHeight;
}
h[i]=(h[i-1]||0)+evl.rows[i].cells[0].offsetHeight;
}
h.unshift(0);
if (evl.parentNode.offsetHeightb.start_date?1:-1; });
var days=[]; //events by weeks
var evs_originals = [];
for (var i=0; i < evs.length; i++) {
var ev=evs[i];
//check scale overflow
var sh = ev.start_date.getHours();
var eh = ev.end_date.getHours();
ev._sday=this._get_event_sday(ev);
if (!days[ev._sday]) days[ev._sday]=[];
if (!hold){
ev._inner=false;
var stack=days[ev._sday];
while (stack.length && stack[stack.length-1].end_date<=ev.start_date)
stack.splice(stack.length-1,1);
if (stack.length) stack[stack.length-1]._inner=true;
ev._sorder=stack.length; stack.push(ev);
if (stack.length>(stack.max_count||0)) stack.max_count=stack.length;
}
if (sh < this.config.first_hour || eh >= this.config.last_hour){
evs_originals.push(ev);
evs[i]=ev=this._copy_event(ev);
if (sh < this.config.first_hour){
ev.start_date.setHours(this.config.first_hour);
ev.start_date.setMinutes(0);
}
if (eh >= this.config.last_hour){
ev.end_date.setMinutes(0);
ev.end_date.setHours(this.config.last_hour);
}
if (ev.start_date>ev.end_date || sh==this.config.last_hour) {
evs.splice(i,1); i--; continue;
}
}
}
if (!hold){
for (var i=0; i < evs.length; i++)
evs[i]._count=days[evs[i]._sday].max_count;
for (var i=0; i < evs_originals.length; i++)
evs_originals[i]._count=days[evs_originals[i]._sday].max_count;
}
return evs;
};
scheduler._time_order=function(evs){
evs.sort(function(a,b){
if (a.start_date.valueOf()==b.start_date.valueOf()){
if (a._timed && !b._timed) return 1;
if (!a._timed && b._timed) return -1;
return 0;
}
return a.start_date>b.start_date?1:-1;
});
};
scheduler._pre_render_events_table=function(evs,hold){ // max - max height of week slot
this._time_order(evs);
var out=[];
var weeks=[[],[],[],[],[],[],[]]; //events by weeks
var max = this._colsS.heights;
var start_date;
var cols = this._cols.length;
for (var i=0; i < evs.length; i++) {
var ev=evs[i];
var sd = (start_date||ev.start_date);
var ed = ev.end_date;
//trim events which are crossing through current view
if (sdthis._max_date) ed=this._max_date;
var locate_s = this.locate_holder_day(sd,false,ev);
ev._sday=locate_s%cols;
var locate_e = this.locate_holder_day(ed,true,ev)||cols;
ev._eday=(locate_e%cols)||cols; //cols used to fill full week, when event end on monday
ev._length=locate_e-locate_s;
//3600000 - compensate 1 hour during winter|summer time shift
ev._sweek=Math.floor((this._correct_shift(sd.valueOf(),1)-this._min_date.valueOf())/(60*60*1000*24*cols));
//current slot
var stack=weeks[ev._sweek];
//check order position
var stack_line;
for (stack_line=0; stack_line";
if (this._quirks7) d2.firstChild.style.height=height-12+"px"; //IEFIX
this._editor=d2.firstChild;
this._editor.onkeypress=function(e){
if ((e||event).shiftKey) return true;
var code=(e||event).keyCode;
if (code==scheduler.keys.edit_save) scheduler.editStop(true);
if (code==scheduler.keys.edit_cancel) scheduler.editStop(false);
};
this._editor.onselectstart=function(e){ return (e||event).cancelBubble=true; };
d2.firstChild.focus();
//IE and opera can add x-scroll during focusing
this._els["dhx_cal_data"][0].scrollLeft=0;
d2.firstChild.select();
}
if (this._select_id==ev.id){
//d.style.zIndex = 1; //fix overlapping issue
var icons=this.config["icons_"+((this._edit_id==ev.id)?"edit":"select")];
var icons_str="";
for (var i=0; i