dhtmlx=function(obj){ for (var a in obj) dhtmlx[a]=obj[a]; return dhtmlx; //simple singleton }; dhtmlx.extend_api=function(name,map,ext){ var t = window[name]; if (!t) return; //component not defined window[name]=function(obj){ if (obj && typeof obj == "object" && !obj.tagName && !(obj instanceof Array)){ var that = t.apply(this,(map._init?map._init(obj):arguments)); //global settings for (var a in dhtmlx) if (map[a]) this[map[a]](dhtmlx[a]); //local settings for (var a in obj){ if (map[a]) this[map[a]](obj[a]); else if (a.indexOf("on")==0){ this.attachEvent(a,obj[a]); } } } else var that = t.apply(this,arguments); if (map._patch) map._patch(this); return that||this; }; window[name].prototype=t.prototype; if (ext) dhtmlXHeir(window[name].prototype,ext); }; dhtmlxAjax={ get:function(url,callback){ var t=new dtmlXMLLoaderObject(true); t.async=(arguments.length<3); t.waitCall=callback; t.loadXML(url) return t; }, post:function(url,post,callback){ var t=new dtmlXMLLoaderObject(true); t.async=(arguments.length<4); t.waitCall=callback; t.loadXML(url,true,post) return t; }, getSync:function(url){ return this.get(url,null,true) }, postSync:function(url,post){ return this.post(url,post,null,true); } } /** * @desc: xmlLoader object * @type: private * @param: funcObject - xml parser function * @param: object - jsControl object * @param: async - sync/async mode (async by default) * @param: rSeed - enable/disable random seed ( prevent IE caching) * @topic: 0 */ function dtmlXMLLoaderObject(funcObject, dhtmlObject, async, rSeed){ this.xmlDoc=""; if (typeof (async) != "undefined") this.async=async; else this.async=true; this.onloadAction=funcObject||null; this.mainObject=dhtmlObject||null; this.waitCall=null; this.rSeed=rSeed||false; return this; }; /** * @desc: xml loading handler * @type: private * @param: dtmlObject - xmlLoader object * @topic: 0 */ dtmlXMLLoaderObject.prototype.waitLoadFunction=function(dhtmlObject){ var once = true; this.check=function (){ if ((dhtmlObject)&&(dhtmlObject.onloadAction != null)){ if ((!dhtmlObject.xmlDoc.readyState)||(dhtmlObject.xmlDoc.readyState == 4)){ if (!once) return; once=false; //IE 5 fix if (typeof dhtmlObject.onloadAction == "function") dhtmlObject.onloadAction(dhtmlObject.mainObject, null, null, null, dhtmlObject); if (dhtmlObject.waitCall){ dhtmlObject.waitCall.call(this,dhtmlObject); dhtmlObject.waitCall=null; } } } }; return this.check; }; /** * @desc: return XML top node * @param: tagName - top XML node tag name (not used in IE, required for Safari and Mozilla) * @type: private * @returns: top XML node * @topic: 0 */ dtmlXMLLoaderObject.prototype.getXMLTopNode=function(tagName, oldObj){ if (this.xmlDoc.responseXML){ var temp = this.xmlDoc.responseXML.getElementsByTagName(tagName); if(temp.length==0 && tagName.indexOf(":")!=-1) var temp = this.xmlDoc.responseXML.getElementsByTagName((tagName.split(":"))[1]); var z = temp[0]; } else var z = this.xmlDoc.documentElement; if (z){ this._retry=false; return z; } if ((_isIE)&&(!this._retry)){ //fall back to MS.XMLDOM var xmlString = this.xmlDoc.responseText; var oldObj = this.xmlDoc; this._retry=true; this.xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); this.xmlDoc.async=false; this.xmlDoc["loadXM"+"L"](xmlString); return this.getXMLTopNode(tagName, oldObj); } dhtmlxError.throwError("LoadXML", "Incorrect XML", [ (oldObj||this.xmlDoc), this.mainObject ]); return document.createElement("DIV"); }; /** * @desc: load XML from string * @type: private * @param: xmlString - xml string * @topic: 0 */ dtmlXMLLoaderObject.prototype.loadXMLString=function(xmlString){ { try{ var parser = new DOMParser(); this.xmlDoc=parser.parseFromString(xmlString, "text/xml"); } catch (e){ this.xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); this.xmlDoc.async=this.async; this.xmlDoc["loadXM"+"L"](xmlString); } } this.onloadAction(this.mainObject, null, null, null, this); if (this.waitCall){ this.waitCall(); this.waitCall=null; } } /** * @desc: load XML * @type: private * @param: filePath - xml file path * @param: postMode - send POST request * @param: postVars - list of vars for post request * @topic: 0 */ dtmlXMLLoaderObject.prototype.loadXML=function(filePath, postMode, postVars, rpc){ if (this.rSeed) filePath+=((filePath.indexOf("?") != -1) ? "&" : "?")+"a_dhx_rSeed="+(new Date()).valueOf(); this.filePath=filePath; if ((!_isIE)&&(window.XMLHttpRequest)) this.xmlDoc=new XMLHttpRequest(); else { if (document.implementation&&document.implementation.createDocument){ this.xmlDoc=document.implementation.createDocument("", "", null); this.xmlDoc.onload=new this.waitLoadFunction(this); this.xmlDoc.load(filePath); return; } else this.xmlDoc=new ActiveXObject("Microsoft.XMLHTTP"); } if (this.async) this.xmlDoc.onreadystatechange=new this.waitLoadFunction(this); this.xmlDoc.open(postMode ? "POST" : "GET", filePath, this.async); if (rpc){ this.xmlDoc.setRequestHeader("User-Agent", "dhtmlxRPC v0.1 ("+navigator.userAgent+")"); this.xmlDoc.setRequestHeader("Content-type", "text/xml"); } else if (postMode) this.xmlDoc.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); this.xmlDoc.setRequestHeader("X-Requested-With","XMLHttpRequest"); this.xmlDoc.send(null||postVars); if (!this.async) (new this.waitLoadFunction(this))(); }; /** * @desc: destructor, cleans used memory * @type: private * @topic: 0 */ dtmlXMLLoaderObject.prototype.destructor=function(){ this.onloadAction=null; this.mainObject=null; this.xmlDoc=null; return null; } dtmlXMLLoaderObject.prototype.xmlNodeToJSON = function(node){ var t={}; for (var i=0; i-1) _isChrome=true; if ((navigator.userAgent.indexOf('Safari') != -1)||(navigator.userAgent.indexOf('Konqueror') != -1)){ var _KHTMLrv = parseFloat(navigator.userAgent.substr(navigator.userAgent.indexOf('Safari')+7, 5)); if (_KHTMLrv > 525){ //mimic FF behavior for Safari 3.1+ _isFF=true; var _FFrv = 1.9; } else _isKHTML=true; } else if (navigator.userAgent.indexOf('Opera') != -1){ _isOpera=true; _OperaRv=parseFloat(navigator.userAgent.substr(navigator.userAgent.indexOf('Opera')+6, 3)); } else if (navigator.appName.indexOf("Microsoft") != -1){ _isIE=true; if (navigator.appVersion.indexOf("MSIE 8.0")!= -1 && document.compatMode != "BackCompat") _isIE=8; } else { _isFF=true; var _FFrv = parseFloat(navigator.userAgent.split("rv:")[1]) } //multibrowser Xpath processor dtmlXMLLoaderObject.prototype.doXPath=function(xpathExp, docObj, namespace, result_type){ if (_isKHTML || (!_isIE && !window.XPathResult)) return this.doXPathOpera(xpathExp, docObj); if (_isIE){ //IE if (!docObj) if (!this.xmlDoc.nodeName) docObj=this.xmlDoc.responseXML else docObj=this.xmlDoc; if (!docObj) dhtmlxError.throwError("LoadXML", "Incorrect XML", [ (docObj||this.xmlDoc), this.mainObject ]); if (namespace != null) docObj.setProperty("SelectionNamespaces", "xmlns:xsl='"+namespace+"'"); // if (result_type == 'single'){ return docObj.selectSingleNode(xpathExp); } else { return docObj.selectNodes(xpathExp)||new Array(0); } } else { //Mozilla var nodeObj = docObj; if (!docObj){ if (!this.xmlDoc.nodeName){ docObj=this.xmlDoc.responseXML } else { docObj=this.xmlDoc; } } if (!docObj) dhtmlxError.throwError("LoadXML", "Incorrect XML", [ (docObj||this.xmlDoc), this.mainObject ]); if (docObj.nodeName.indexOf("document") != -1){ nodeObj=docObj; } else { nodeObj=docObj; docObj=docObj.ownerDocument; } var retType = XPathResult.ANY_TYPE; if (result_type == 'single') retType=XPathResult.FIRST_ORDERED_NODE_TYPE var rowsCol = new Array(); var col = docObj.evaluate(xpathExp, nodeObj, function(pref){ return namespace }, retType, null); if (retType == XPathResult.FIRST_ORDERED_NODE_TYPE){ return col.singleNodeValue; } var thisColMemb = col.iterateNext(); while (thisColMemb){ rowsCol[rowsCol.length]=thisColMemb; thisColMemb=col.iterateNext(); } return rowsCol; } } function _dhtmlxError(type, name, params){ if (!this.catches) this.catches=new Array(); return this; } _dhtmlxError.prototype.catchError=function(type, func_name){ this.catches[type]=func_name; } _dhtmlxError.prototype.throwError=function(type, name, params){ if (this.catches[type]) return this.catches[type](type, name, params); if (this.catches["ALL"]) return this.catches["ALL"](type, name, params); alert("Error type: "+arguments[0]+"\nDescription: "+arguments[1]); return null; } window.dhtmlxError=new _dhtmlxError(); //opera fake, while 9.0 not released //multibrowser Xpath processor dtmlXMLLoaderObject.prototype.doXPathOpera=function(xpathExp, docObj){ //this is fake for Opera var z = xpathExp.replace(/[\/]+/gi, "/").split('/'); var obj = null; var i = 1; if (!z.length) return []; if (z[0] == ".") obj=[docObj]; else if (z[0] == ""){ obj=(this.xmlDoc.responseXML||this.xmlDoc).getElementsByTagName(z[i].replace(/\[[^\]]*\]/g, "")); i++; } else return []; for (i; i < z.length; i++)obj=this._getAllNamedChilds(obj, z[i]); if (z[i-1].indexOf("[") != -1) obj=this._filterXPath(obj, z[i-1]); return obj; } dtmlXMLLoaderObject.prototype._filterXPath=function(a, b){ var c = new Array(); var b = b.replace(/[^\[]*\[\@/g, "").replace(/[\[\]\@]*/g, ""); for (var i = 0; i < a.length; i++) if (a[i].getAttribute(b)) c[c.length]=a[i]; return c; } dtmlXMLLoaderObject.prototype._getAllNamedChilds=function(a, b){ var c = new Array(); if (_isKHTML) b=b.toUpperCase(); for (var i = 0; i < a.length; i++)for (var j = 0; j < a[i].childNodes.length; j++){ if (_isKHTML){ if (a[i].childNodes[j].tagName&&a[i].childNodes[j].tagName.toUpperCase() == b) c[c.length]=a[i].childNodes[j]; } else if (a[i].childNodes[j].tagName == b) c[c.length]=a[i].childNodes[j]; } return c; } function dhtmlXHeir(a, b){ for (var c in b) if (typeof (b[c]) == "function") a[c]=b[c]; return a; } function dhtmlxEvent(el, event, handler){ if (el.addEventListener) el.addEventListener(event, handler, false); else if (el.attachEvent) el.attachEvent("on"+event, handler); } //============= XSL Extension =================================== dtmlXMLLoaderObject.prototype.xslDoc=null; dtmlXMLLoaderObject.prototype.setXSLParamValue=function(paramName, paramValue, xslDoc){ if (!xslDoc) xslDoc=this.xslDoc if (xslDoc.responseXML) xslDoc=xslDoc.responseXML; var item = this.doXPath("/xsl:stylesheet/xsl:variable[@name='"+paramName+"']", xslDoc, "http:/\/www.w3.org/1999/XSL/Transform", "single"); if (item != null) item.firstChild.nodeValue=paramValue } dtmlXMLLoaderObject.prototype.doXSLTransToObject=function(xslDoc, xmlDoc){ if (!xslDoc) xslDoc=this.xslDoc; if (xslDoc.responseXML) xslDoc=xslDoc.responseXML if (!xmlDoc) xmlDoc=this.xmlDoc; if (xmlDoc.responseXML) xmlDoc=xmlDoc.responseXML //MOzilla if (!_isIE){ if (!this.XSLProcessor){ this.XSLProcessor=new XSLTProcessor(); this.XSLProcessor.importStylesheet(xslDoc); } var result = this.XSLProcessor.transformToDocument(xmlDoc); } else { var result = new ActiveXObject("Msxml2.DOMDocument.3.0"); try{ xmlDoc.transformNodeToObject(xslDoc, result); }catch(e){ result = xmlDoc.transformNode(xslDoc); } } return result; } dtmlXMLLoaderObject.prototype.doXSLTransToString=function(xslDoc, xmlDoc){ var res = this.doXSLTransToObject(xslDoc, xmlDoc); if(typeof(res)=="string") return res; return this.doSerialization(res); } dtmlXMLLoaderObject.prototype.doSerialization=function(xmlDoc){ if (!xmlDoc) xmlDoc=this.xmlDoc; if (xmlDoc.responseXML) xmlDoc=xmlDoc.responseXML if (!_isIE){ var xmlSerializer = new XMLSerializer(); return xmlSerializer.serializeToString(xmlDoc); } else return xmlDoc.xml; } /** * @desc: * @type: private */ dhtmlxEventable=function(obj){ obj.dhx_SeverCatcherPath=""; obj.attachEvent=function(name, catcher, callObj){ name='ev_'+name.toLowerCase(); if (!this[name]) this[name]=new this.eventCatcher(callObj||this); return(name+':'+this[name].addEvent(catcher)); //return ID (event name & event ID) } obj.callEvent=function(name, arg0){ name='ev_'+name.toLowerCase(); if (this[name]) return this[name].apply(this, arg0); return true; } obj.checkEvent=function(name){ return (!!this['ev_'+name.toLowerCase()]) } obj.eventCatcher=function(obj){ var dhx_catch = []; var z = function(){ var res = true; for (var i = 0; i < dhx_catch.length; i++){ if (dhx_catch[i] != null){ var zr = dhx_catch[i].apply(obj, arguments); res=res&&zr; } } return res; } z.addEvent=function(ev){ if (typeof (ev) != "function") ev=eval(ev); if (ev) return dhx_catch.push(ev)-1; return false; } z.removeEvent=function(id){ dhx_catch[id]=null; } return z; } obj.detachEvent=function(id){ if (id != false){ var list = id.split(':'); //get EventName and ID this[list[0]].removeEvent(list[1]); //remove event } } } /** * @desc: constructor, data processor object * @param: serverProcessorURL - url used for update * @type: public */ function dataProcessor(serverProcessorURL){ this.serverProcessor = serverProcessorURL; this.action_param="!nativeeditor_status"; this.obj = null; this.updatedRows = []; //ids of updated rows this.autoUpdate = true; this.updateMode = "cell"; this._tMode="GET"; this._waitMode=0; this._in_progress={};//? this._invalid={}; this.mandatoryFields=[]; this.messages=[]; this.styles={ updated:"font-weight:bold;", inserted:"font-weight:bold;", deleted:"text-decoration : line-through;", invalid:"background-color:FFE0E0;", invalid_cell:"border-bottom:2px solid red;", error:"color:red;", clear:"font-weight:normal;text-decoration:none;" } this.enableUTFencoding(true); dhtmlxEventable(this); return this; } dataProcessor.prototype={ /** * @desc: select GET or POST transaction model * @param: mode - GET/POST * @param: total - true/false - send records row by row or all at once (for grid only) * @type: public */ setTransactionMode:function(mode,total){ this._tMode=mode; this._tSend=total; }, escape:function(data){ if (this._utf) return encodeURIComponent(data); else return escape(data); }, /** * @desc: allows to set escaping mode * @param: true - utf based escaping, simple - use current page encoding * @type: public */ enableUTFencoding:function(mode){ this._utf=convertStringToBoolean(mode); }, /** * @desc: allows to define, which column may trigger update * @param: val - array or list of true/false values * @type: public */ setDataColumns:function(val){ this._columns=(typeof val == "string")?val.split(","):val; }, /** * @desc: get state of updating * @returns: true - all in sync with server, false - some items not updated yet. * @type: public */ getSyncState:function(){ return !this.updatedRows.length; }, /** * @desc: enable/disable named field for data syncing, will use column ids for grid * @param: mode - true/false * @type: public */ enableDataNames:function(mode){ this._endnm=convertStringToBoolean(mode); }, /** * @desc: enable/disable mode , when only changed fields and row id send to the server side, instead of all fields in default mode * @param: mode - true/false * @type: public */ enablePartialDataSend:function(mode){ this._changed=convertStringToBoolean(mode); }, /** * @desc: set if rows should be send to server automaticaly * @param: mode - "row" - based on row selection changed, "cell" - based on cell editing finished, "off" - manual data sending * @type: public */ setUpdateMode:function(mode,dnd){ this.autoUpdate = (mode=="cell"); this.updateMode = mode; this.dnd=dnd; }, /** * @desc: mark row as updated/normal. check mandatory fields,initiate autoupdate (if turned on) * @param: rowId - id of row to set update-status for * @param: state - true for "updated", false for "not updated" * @param: mode - update mode name * @type: public */ setUpdated:function(rowId,state,mode){ var ind=this.findRow(rowId); mode=mode||"updated"; var existing = this.obj.getUserData(rowId,this.action_param); if (existing && mode == "updated") mode=existing; if (state){ this.set_invalid(rowId,false); //clear previous error flag this.updatedRows[ind]=rowId; this.obj.setUserData(rowId,this.action_param,mode); } else{ if (!this.is_invalid(rowId)){ this.updatedRows.splice(ind,1); this.obj.setUserData(rowId,this.action_param,""); } } //clear changed flag if (!state) this._clearUpdateFlag(rowId); this.markRow(rowId,state,mode); if (state && this.autoUpdate) this.sendData(rowId); }, _clearUpdateFlag:function(){ if (this.obj.mytype!="tree"){ var row=this.obj.getRowById(rowId); if (row) for (var j=0; j3){ node.style.left=x+"px"; node.style.top=y+"px"; } } scheduler.get_elements=function(){ //get all child elements as named hash var els=this._obj.getElementsByTagName("DIV"); for (var i=0; i < els.length; i++){ var name=els[i].className; if (!this._els[name]) this._els[name]=[]; this._els[name].push(els[i]); //check if name need to be changed var t=scheduler.locale.labels[els[i].getAttribute("name")||name]; if (t) els[i].innerHTML=t; } } scheduler.set_actions=function(){ for (var a in this._els) if (this._click[a]) for (var i=0; i < this._els[a].length; i++) this._els[a][i].onclick=scheduler._click[a]; this._obj.onselectstart=function(e){ return false; } this._obj.onmousemove=function(e){ scheduler._on_mouse_move(e||event); } this._obj.onmousedown=function(e){ scheduler._on_mouse_down(e||event); } this._obj.onmouseup=function(e){ scheduler._on_mouse_up(e||event); } this._obj.ondblclick=function(e){ scheduler._on_dbl_click(e||event); } } scheduler.select=function(id){ if (this._table_view || !this.getEvent(id)._timed) return; //temporary block if (this._select_id==id) return; this.editStop(false); this.unselect(); this._select_id = id; this.updateEvent(id); } scheduler.unselect=function(id){ if (id && id!=this._select_id) return; var t=this._select_id; this._select_id = null; if (t) this.updateEvent(t); } scheduler._click={ dhx_cal_data:function(e){ var trg = e?e.target:event.srcElement; var id = scheduler._locate_event(trg); if ((id && !scheduler.callEvent("onClick",[id,(e||event)])) ||scheduler.config.readonly) return; if (id) { scheduler.select(id); var mask = trg.className; if (mask.indexOf("_icon")!=-1) scheduler._click.buttons[mask.split(" ")[1].replace("icon_","")](id); } else scheduler._close_not_saved(); }, dhx_cal_prev_button:function(){ scheduler._click.dhx_cal_next_button(0,-1); }, dhx_cal_next_button:function(dummy,step){ scheduler.setCurrentView(scheduler.date.add( //next line changes scheduler._date , but seems it has not side-effects scheduler.date[scheduler._mode+"_start"](scheduler._date),(step||1),scheduler._mode)); }, dhx_cal_today_button:function(){ scheduler.setCurrentView(new Date()); }, dhx_cal_tab:function(){ var mode = this.getAttribute("name").split("_")[0]; scheduler.setCurrentView(scheduler._date,mode); }, buttons:{ "delete":function(id){ var c=scheduler.locale.labels.confirm_deleting; if (!c||confirm(c)) scheduler.deleteEvent(id); }, edit:function(id){ scheduler.edit(id); }, save:function(id){ scheduler.editStop(true); }, details:function(id){ scheduler.showLightbox(id); }, cancel:function(id){ scheduler.editStop(false); } } } scheduler.addEventNow=function(start,end,e){ var d = this.config.time_step*60000; if (!start) start = Math.round((new Date()).valueOf()/d)*d; var start_date = new Date(start); if (!end){ var start_hour = this.config.first_hour; if (start_hour > start_date.getHours()){ start_date.setHours(start_hour); start = start_date.valueOf(); } end = start+d; } this._drag_id=this.uid(); this._drag_mode="new-size"; this._loading=true; this.addEvent(start_date, new Date(end),this.locale.labels.new_event,this._drag_id); this.callEvent("onEventCreated",[this._drag_id,e]); this._loading=false; this._drag_event={}; //dummy , to trigger correct event updating logic this._on_mouse_up(e); } scheduler._on_dbl_click=function(e,src){ src = src||(e.target||e.srcElement); if (this.config.readonly) return; var name = src.className.split(" ")[0]; switch(name){ case "dhx_scale_holder": case "dhx_scale_holder_now": case "dhx_month_body": if (!scheduler.config.dblclick_create) break; var pos=this._mouse_coords(e); var start=this._min_date.valueOf()+(pos.y*this.config.time_step+(this._table_view?0:pos.x)*24*60)*60000; start = this._correct_shift(start); this.addEventNow(start,null,e); break; case "dhx_body": case "dhx_cal_event_line": case "dhx_cal_event_clear": var id = this._locate_event(src); if (!this.callEvent("onDblClick",[id,e])) return; if (this.config.details_on_dblclick || this._table_view || !this.getEvent(id)._timed) this.showLightbox(id); else this.edit(id); break; case "": if (src.parentNode) return scheduler._on_dbl_click(e,src.parentNode); default: var t = this["dblclick_"+name]; if (t) t.call(this,e); break; } } scheduler._mouse_coords=function(ev){ var pos; var b=document.body; var d = document.documentElement; if(ev.pageX || ev.pageY) pos={x:ev.pageX, y:ev.pageY}; else pos={ x:ev.clientX + (b.scrollLeft||d.scrollLeft||0) - b.clientLeft, y:ev.clientY + (b.scrollTop||d.scrollTop||0) - b.clientTop } //apply layout pos.x-=getAbsoluteLeft(this._obj)+(this._table_view?0:this.xy.scale_width); pos.y-=getAbsoluteTop(this._obj)+this.xy.nav_height+this._dy_shift+this.xy.scale_height-this._els["dhx_cal_data"][0].scrollTop; //transform to date if (!this._table_view){ pos.x=Math.max(0,Math.ceil(pos.x/this._cols[0])-1); pos.y=Math.max(0,Math.ceil(pos.y*60/(this.config.time_step*this.config.hour_size_px))-1)+this.config.first_hour*(60/this.config.time_step); } else { var dy=0; for (dy=1; dy < this._colsS.heights.length; dy++) if (this._colsS.heights[dy]>pos.y) break; pos.y=(Math.max(0,Math.ceil(pos.x/this._cols[0])-1)+Math.max(0,dy-1)*7)*24*60/this.config.time_step; pos.x=0; } return pos; } scheduler._close_not_saved=function(){ if (new Date().valueOf()-(scheduler._new_event||0) > 500 && scheduler._edit_id){ var c=scheduler.locale.labels.confirm_closing; if (!c || confirm(c)) scheduler.editStop(scheduler.config.positive_closing); } } scheduler._correct_shift=function(start, back){ return start-=((new Date(scheduler._min_date)).getTimezoneOffset()-(new Date(start)).getTimezoneOffset())*60000*(back?-1:1); } scheduler._on_mouse_move=function(e){ if (this._drag_mode){ var pos=this._mouse_coords(e); if (!this._drag_pos || this._drag_pos.x!=pos.x || this._drag_pos.y!=pos.y){ if (this._edit_id!=this._drag_id) this._close_not_saved(); this._drag_pos=pos; if (this._drag_mode=="create"){ this._close_not_saved(); this._loading=true; //will be ignored by dataprocessor var start=this._min_date.valueOf()+(pos.y*this.config.time_step+(this._table_view?0:pos.x)*24*60)*60000; //if (this._mode != "week" && this._mode != "day") start = this._correct_shift(start); if (!this._drag_start){ this._drag_start=start; return; } var end = start; if (end==this._drag_start) return; this._drag_id=this.uid(); this.addEvent(new Date(this._drag_start), new Date(end),this.locale.labels.new_event,this._drag_id); this.callEvent("onEventCreated",[this._drag_id,e]); this._loading=false; this._drag_mode="new-size"; } var ev=this.getEvent(this._drag_id); var start,end; if (this._drag_mode=="move"){ start = this._min_date.valueOf()+(pos.y*this.config.time_step+pos.x*24*60)*60000+(this._table_view? this.date.time_part(ev.start_date)*1000:0); start = this._correct_shift(start); end = ev.end_date.valueOf()-(ev.start_date.valueOf()-start); } else { start = ev.start_date.valueOf(); if (this._table_view) end = this._min_date.valueOf()+pos.y*this.config.time_step*60000 + 24*60*60000; else{ end = this.date.date_part(ev.end_date).valueOf()+pos.y*this.config.time_step*60000; this._els["dhx_cal_data"][0].style.cursor="s-resize"; if (this._mode == "week" || this._mode == "day") end = this._correct_shift(end); } if (this._drag_mode == "new-size"){ if (end < this._drag_start){ start = end; end = this._drag_start; } } else if (end<=start) end=start+this.config.time_step*60000; } var new_end = new Date(end-1); var new_start = new Date(start); //prevent out-of-borders situation for day|week view if (this._table_view || (new_end.getDate()==new_start.getDate() && new_end.getHours()=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; } scheduler.date={ date_part:function(date){ date.setHours(0); date.setMinutes(0); date.setSeconds(0); date.setMilliseconds(0); return date; }, time_part:function(date){ return (date.valueOf()/1000 - date.getTimezoneOffset()*60)%86400; }, week_start:function(date){ var shift=date.getDay(); if (scheduler.config.start_on_monday){ if (shift==0) shift=6 else shift--; } return this.date_part(this.add(date,-1*shift,"day")); }, month_start:function(date){ date.setDate(1); return this.date_part(date); }, year_start:function(date){ date.setMonth(0); return this.month_start(date); }, day_start:function(date){ return this.date_part(date); }, add:function(date,inc,mode){ var ndate=new Date(date.valueOf()); switch(mode){ case "day": ndate.setDate(ndate.getDate()+inc); break; case "week": ndate.setDate(ndate.getDate()+7*inc); break; case "month": ndate.setMonth(ndate.getMonth()+inc); break; case "year": ndate.setYear(ndate.getFullYear()+inc); break; case "hour": ndate.setHours(ndate.getHours()+inc); break; case "minute": ndate.setMinutes(ndate.getMinutes()+inc); break; default: return scheduler.date["add_"+mode](date,inc,mode); } return ndate; }, to_fixed:function(num){ if (num<10) return "0"+num; return num; }, copy:function(date){ return new Date(date.valueOf()); }, date_to_str:function(format,utc){ format=format.replace(/%[a-zA-Z]/g,function(a){ switch(a){ case "%d": return "\"+scheduler.date.to_fixed(date.getDate())+\""; case "%m": return "\"+scheduler.date.to_fixed((date.getMonth()+1))+\""; case "%j": return "\"+date.getDate()+\""; case "%n": return "\"+(date.getMonth()+1)+\""; case "%y": return "\"+date.getYear()+\""; case "%Y": return "\"+date.getFullYear()+\""; case "%D": return "\"+scheduler.locale.date.day_short[date.getDay()]+\""; case "%l": return "\"+scheduler.locale.date.day_full[date.getDay()]+\""; case "%M": return "\"+scheduler.locale.date.month_short[date.getMonth()]+\""; case "%F": return "\"+scheduler.locale.date.month_full[date.getMonth()]+\""; case "%h": return "\"+scheduler.date.to_fixed((date.getHours()+11)%12+1)+\""; case "%H": return "\"+scheduler.date.to_fixed(date.getHours())+\""; case "%i": return "\"+scheduler.date.to_fixed(date.getMinutes())+\""; case "%a": return "\"+(date.getHours()>11?\"pm\":\"am\")+\""; case "%A": return "\"+(date.getHours()>11?\"PM\":\"AM\")+\""; case "%s": return "\"+scheduler.date.to_fixed(date.getSeconds())+\""; 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 "%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,0,0,0,0]; "+splt+" return new Date("+code+");"); } } 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", /*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-hb-2){ //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) { 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 while (stack.length && stack[stack.length-1]._eday<=ev._sday) //while (stack.length && stack[stack.length-1].end_date<=this.date.date_part(this.date.copy(ev.start_date)) ) stack.splice(stack.length-1,1); //get max height of slot if (stack.length>max[ev._sweek]) max[ev._sweek]=stack.length; ev._sorder=stack.length; if (ev._sday+ev._length<=cols){ start_date=null; out.push(ev); stack.push(ev); } else{ // split long event in chunks copy=this._copy_event(ev); copy._length=cols-ev._sday; copy._eday=cols; copy._sday=ev._sday; copy._sweek=ev._sweek; copy._sorder=ev._sorder; copy.end_date=this.date.add(sd,copy._length,"day"); out.push(copy); stack.push(copy); start_date=copy.end_date; i--; continue; //repeat same step } }; return out; } scheduler._copy_dummy=function(){ this.start_date=new Date(this.start_date); this.end_date=new Date(this.end_date); } scheduler._copy_event=function(ev){ this._copy_dummy.prototype = ev; return new this._copy_dummy(); //return {start_date:ev.start_date, end_date:ev.end_date, text:ev.text, id:ev.id} } scheduler._rendered=[]; scheduler.clear_view=function(){ for (var i=0; i"; 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){ var icons=this.config["icons_"+((this._edit_id==ev.id)?"edit":"select")]; var icons_str=""; for (var i=0; i"; var obj = this._render_v_bar(ev.id,left-menu+1,top,menu,icons.length*20+26,"","
",icons_str,true); obj.style.left=left-menu+1; this._els["dhx_cal_data"][0].appendChild(obj); this._rendered.push(obj); } } scheduler._render_v_bar=function(id,x,y,w,h,style,contentA,contentB,bottom){ var d=document.createElement("DIV"); var ev = this.getEvent(id); var cs = "dhx_cal_event"; var cse = scheduler.templates.event_class(ev.start_date,ev.end_date,ev); if (cse) cs=cs+" "+cse; var html='
'; html+='
 
'; html+='
'+contentA+'
'; html+='
'+contentB+'
'; html+='
'; d.innerHTML=html; return d.firstChild; } scheduler.locate_holder=function(day){ if (this._mode=="day") return this._els["dhx_cal_data"][0].firstChild; //dirty return this._els["dhx_cal_data"][0].childNodes[day]; } scheduler.locate_holder_day=function(date,past){ var day = Math.floor((this._correct_shift(date,1)-this._min_date)/(60*60*24*1000)); //when locating end data of event , we need to use next day if time part was defined if (past && this.date.time_part(date)) day++; return day; } scheduler.render_event_bar=function(ev){ var parent=this._els["dhx_cal_data"][0]; var x=this._colsS[ev._sday]; var x2=this._colsS[ev._eday]; if (x2==x) x2=this._colsS[ev._eday+1]; var hb = this.xy.bar_height; var y=this._colsS.heights[ev._sweek]+(this._colsS.height?(this.xy.scale_height+2):2)+ev._sorder*hb; var d=document.createElement("DIV"); var cs = ev._timed?"dhx_cal_event_clear":"dhx_cal_event_line"; var cse = scheduler.templates.event_class(ev.start_date,ev.end_date,ev); if (cse) cs=cs+" "+cse; var html='
'; if (ev._timed) html+=scheduler.templates.event_bar_date(ev.start_date,ev.end_date,ev); html+=scheduler.templates.event_bar_text(ev.start_date,ev.end_date,ev)+'
'; html+=''; d.innerHTML=html; this._rendered.push(d.firstChild); parent.appendChild(d.firstChild); } scheduler._locate_event=function(node){ var id=null; while (node && !id && node.getAttribute){ id=node.getAttribute("event_id"); node=node.parentNode } return id; } scheduler.edit=function(id){ if (this._edit_id==id) return; this.editStop(false,id); this._edit_id=id; this.updateEvent(id); } scheduler.editStop=function(mode,id){ if (id && this._edit_id==id) return; var ev=this.getEvent(this._edit_id); if (ev){ if (mode) ev.text=this._editor.value; this._edit_id=null; this._editor=null; this.updateEvent(ev.id); this._edit_stop_event(ev,mode); } } scheduler._edit_stop_event=function(ev,mode){ if (this._new_event){ if (!mode) this.deleteEvent(ev.id,true); else this.callEvent("onEventAdded",[ev.id,ev]); this._new_event=null; } else if (mode) this.callEvent("onEventChanged",[ev.id,ev]); } scheduler.getEvents = function(from,to){ var result = []; for (var a in this._events){ var ev = this._events[a]; if (ev && ev.start_datefrom) result.push(ev); } return result; } scheduler._loaded={}; scheduler._load=function(url,from){ url=url||this._load_url; url+=(url.indexOf("?")==-1?"?":"&")+"timeshift="+(new Date()).getTimezoneOffset(); if (this.config.prevent_cache) url+="&uid="+this.uid(); var to; from=from||this._date; if (this._load_mode){ var lf = this.templates.load_format; from = this.date[this._load_mode+"_start"](new Date(from.valueOf())); while (from>this._min_date) from=this.date.add(from,-1,this._load_mode); to = from; var cache_line = true; while (tofrom && this._loaded[lf(temp_to)]); if (to<=from) return false; //already loaded dhtmlxAjax.get(url+"&from="+lf(from)+"&to="+lf(to),function(l){scheduler.on_load(l);}); while(from"; }, set_value:function(node,value,ev){ node.firstChild.value=value||""; }, get_value:function(node,ev){ return node.firstChild.value; }, focus:function(node){ var a=node.firstChild; a.select(); a.focus(); } }, select:{ render:function(sns){ var height=(sns.height||"23")+"px"; var html="
"; return html; }, set_value:function(node,value,ev){ node.firstChild.value=value||""; }, get_value:function(node,ev){ return node.firstChild.value; }, focus:function(node){ var a=node.firstChild; a.select(); a.focus(); } }, time:{ render:function(){ //hours var cfg = scheduler.config; var dt = this.date.date_part(new Date()); if (cfg.first_hour) dt.setHours(cfg.first_hour); var html=" "; return "
"+html+"  –  "+html+"
"; }, set_value:function(node,value,ev){ function _fill_lightbox_select(s,i,d){ s[i+0].value=Math.round((d.getHours()*60+d.getMinutes())/scheduler.config.time_step)*scheduler.config.time_step; s[i+1].value=d.getDate(); s[i+2].value=d.getMonth(); s[i+3].value=d.getFullYear(); } var s=node.getElementsByTagName("select"); _fill_lightbox_select(s,0,ev.start_date); _fill_lightbox_select(s,4,ev.end_date); }, get_value:function(node,ev){ s=node.getElementsByTagName("select"); ev.start_date=new Date(s[3].value,s[2].value,s[1].value,0,s[0].value); ev.end_date=new Date(s[7].value,s[6].value,s[5].value,0,s[4].value); if (ev.end_date<=ev.start_date) ev.end_date=scheduler.date.add(ev.start_date,scheduler.config.time_step,"minute"); }, focus:function(node){ node.getElementsByTagName("select")[0].focus(); } } } scheduler.showCover=function(box){ this.show_cover(); if (box){ box.style.display="block"; var pos = getOffset(this._obj); box.style.top=Math.round(pos.top+(this._obj.offsetHeight-box.offsetHeight)/2)+"px"; box.style.left=Math.round(pos.left+(this._obj.offsetWidth-box.offsetWidth)/2)+"px"; } } scheduler.showLightbox=function(id){ if (!id) return; if (!this.callEvent("onBeforeLightbox",[id])) return; var box = this._get_lightbox(); this.showCover(box); this._fill_lightbox(id,box); } scheduler._fill_lightbox=function(id,box){ var ev=this.getEvent(id); var s=box.getElementsByTagName("span"); s[1].innerHTML=this.templates.event_header(ev.start_date,ev.end_date,ev); s[2].innerHTML=this.templates.event_bar_text(ev.start_date,ev.end_date,ev); var sns = this.config.lightbox.sections; for (var i=0; i < sns.length; i++) { var node=document.getElementById(sns[i].id).nextSibling; var block=this.form_blocks[sns[i].type]; block.set_value.call(this,node,ev[sns[i].map_to],ev) if (sns[i].focus) block.focus.call(this,node); }; scheduler._lightbox_id=id; } scheduler._lightbox_out=function(ev){ var sns = this.config.lightbox.sections; for (var i=0; i < sns.length; i++) { var node=document.getElementById(sns[i].id).nextSibling; var block=this.form_blocks[sns[i].type]; var res=block.get_value.call(this,node,ev); if (sns[i].map_to!="auto") ev[sns[i].map_to]=res; } return ev; } scheduler._empty_lightbox=function(){ var id=scheduler._lightbox_id; var ev=this.getEvent(id); var box=this._get_lightbox(); this._lightbox_out(ev); ev._timed=this.is_one_day_event(ev); this.setEvent(ev.id,ev); this._edit_stop_event(ev,true) this.render_view_data(); } scheduler.hide_lightbox=function(id){ this.hideCover(this._get_lightbox()); this._lightbox_id=null; this.callEvent("onAfterLightbox",[]); } scheduler.hideCover=function(box){ if (box) box.style.display="none"; this.hide_cover(); } scheduler.hide_cover=function(){ if (this._cover) this._cover.parentNode.removeChild(this._cover); this._cover=null; } scheduler.show_cover=function(){ this._cover=document.createElement("DIV"); this._cover.className="dhx_cal_cover"; document.body.appendChild(this._cover); } scheduler._init_lightbox_events=function(){ this._get_lightbox().onclick=function(e){ var src=e?e.target:event.srcElement; if (!src.className) src=src.previousSibling; if (src && src.className) switch(src.className){ case "dhx_save_btn": if (scheduler.checkEvent("onEventSave") && !scheduler.callEvent("onEventSave",[scheduler._lightbox_id,scheduler._lightbox_out({})])) return; scheduler._empty_lightbox() scheduler.hide_lightbox(); break; case "dhx_delete_btn": var c=scheduler.locale.labels.confirm_deleting; if (!c||confirm(c)) { scheduler.deleteEvent(scheduler._lightbox_id); scheduler._new_event = null; //clear flag, if it was unsaved event scheduler.hide_lightbox(); } break; case "dhx_cancel_btn": scheduler.callEvent("onEventCancel",[scheduler._lightbox_id]); scheduler._edit_stop_event(scheduler.getEvent(scheduler._lightbox_id),false); scheduler.hide_lightbox(); break; default: if (src.className.indexOf("dhx_custom_button_")!=-1){ var index = src.parentNode.getAttribute("index"); var block=scheduler.form_blocks[scheduler.config.lightbox.sections[index].type]; var sec = src.parentNode.parentNode; block.button_click(index,src,sec,sec.nextSibling); } } }; this._get_lightbox().onkeypress=function(e){ switch((e||event).keyCode){ case scheduler.keys.edit_save: if ((e||event).shiftKey) return; scheduler._empty_lightbox() scheduler.hide_lightbox(); break; case scheduler.keys.edit_cancel: scheduler._edit_stop_event(scheduler.getEvent(scheduler._lightbox_id),false) scheduler.hide_lightbox(); break; } } } scheduler.setLightboxSize=function(){ var d = this._lightbox; if (!d) return; var con = d.childNodes[1]; con.style.height="0px"; con.style.height=con.scrollHeight+"px"; d.style.height=con.scrollHeight+50+"px"; con.style.height=con.scrollHeight+"px"; //it is incredible , how ugly IE can be } scheduler._get_lightbox=function(){ if (!this._lightbox){ var d=document.createElement("DIV"); d.className="dhx_cal_light"; if (/msie|MSIE 6/.test(navigator.userAgent)) d.className+=" dhx_ie6"; d.style.visibility="hidden"; d.innerHTML=this._lightbox_template; document.body.insertBefore(d,document.body.firstChild); this._lightbox=d; var sns=this.config.lightbox.sections; var html=""; for (var i=0; i < sns.length; i++) { var block=this.form_blocks[sns[i].type]; if (!block) continue; //ignore incorrect blocks sns[i].id="area_"+this.uid(); var button = ""; if (sns[i].button) button = "
"+this.locale.labels["button_"+sns[i].button]+"
"; html+="
"+button+this.locale.labels["section_"+sns[i].name]+"
"+block.render.call(this,sns[i]); }; //localization var ds=d.getElementsByTagName("div"); ds[4].innerHTML=scheduler.locale.labels.icon_save; ds[7].innerHTML=scheduler.locale.labels.icon_cancel; ds[10].innerHTML=scheduler.locale.labels.icon_delete; //sections ds[1].innerHTML=html; //sizes this.setLightboxSize(); this._init_lightbox_events(this); d.style.display="none"; d.style.visibility="visible"; } return this._lightbox; } scheduler._lightbox_template="
 
 
 
 
"; scheduler._dp_init=function(dp){ dp._methods=["setEventTextStyle","","changeEventId","deleteEvent"]; this.attachEvent("onEventAdded",function(id){ if (!this._loading && this.validId(id)) dp.setUpdated(id,true,"inserted"); }); this.attachEvent("onBeforeEventDelete",function(id){ if (!this.validId(id)) return; var z=dp.getState(id); if (z=="inserted" || this._new_event) { dp.setUpdated(id,false); return true; } if (z=="deleted") return false; if (z=="true_deleted") return true; dp.setUpdated(id,true,"deleted"); return false; }); this.attachEvent("onEventChanged",function(id){ if (!this._loading && this.validId(id)) dp.setUpdated(id,true,"updated"); }); dp._getRowData=function(id,pref){ pref=pref||""; var ev=this.obj.getEvent(id); var str=[]; for (var a in ev){ if (a.indexOf("_")==0) continue; if (ev[a] && ev[a].getUTCFullYear) //not very good, but will work str.push(a+"="+this.obj.templates.xml_format(ev[a])); else str.push(a+"="+this.escape(ev[a])); } return pref+str.join("&"+pref); } dp._clearUpdateFlag=function(){} } scheduler.setUserData=function(id,name,value){ this.getEvent(id)[name]=value; } scheduler.getUserData=function(id,name){ return this.getEvent(id)[name]; } scheduler.setEventTextStyle=function(id,style){ this.for_rendered(id,function(r){ r.style.cssText+=";"+style; }) var ev = this.getEvent(id); ev["_text_style"]=style; this.event_updated(ev); } scheduler.validId=function(id){ return true; }