12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- /*
- * Copyright Scand LLC http://www.scbr.com To use this component please contact
- * info@scbr.com to obtain license
- */
- document.write("<script src='" + _js_prefix + "calendar/YAHOO.js'></script>");
- document.write("<script src='" + _js_prefix + "calendar/event.js'></script>");
- document
- .write("<script src='" + _js_prefix + "calendar/calendar.js'></script>");
- document.write("<script src='" + _js_prefix
- + "calendar/calendar_init.js'></script>");
- document.write("<link rel='stylesheet' type='text/css' href='" + _js_prefix
- + "calendar/calendar.css'></link>");
- // simple text editor
- function eXcell_calendar(cell) {
- try {
- this.cell = cell;
- this.grid = this.cell.parentNode.grid;
- } catch (er) {
- }
- this.edit = function() {
- if (!window._grid_calendar)
- _grid_calendar_init();
- var arPos = this.grid.getPosition(this.cell);
- var pval = this._date2str2(this.cell.val || allGetServerTime());
- window._grid_calendar.render(arPos[0] - this.grid.objBox.scrollLeft,
- arPos[1] + this.cell.offsetHeight - this.grid.objBox.scrollTop,
- this, pval);
- this.cell._cediton = true;
- this.val = this.cell.val;
- }
- this.getValue = function() {
- // this.grid.editStop();
- if (this.cell.val)
- return this._date2str2(this.cell.val);
- return this.cell.innerHTML.toString()._dhx_trim()
- }
- this.detach = function() {
- if (this.cell._cediton)
- this.cell._cediton = false;
- else
- return;
- var z = window._grid_calendar.getSelectedDates()[0];
- window._grid_calendar.hide();
- if (!z.getFullYear())
- return;
- this.cell.val = new Date(z.valueOf());
- this.cell.innerHTML = this._date2str(z);
- return this.val.valueOf() != z.valueOf();
- }
- this._2dg = function(val) {
- if (val.toString().length == 1)
- return ("0" + val.toString());
- return val;
- }
- this._date2str2 = function(z) {
- return ("m/d/y").replace("m", this._2dg((z.getMonth() * 1 + 1)))
- .replace("d", this._2dg(z.getDate())).replace("y",
- this._2dg((z.getFullYear() * 1)));
- }
- this._date2str = function(z) {
- return (this.grid._dtmask || "m/d/y").replace("m",
- this._2dg((z.getMonth() * 1 + 1))).replace("d",
- this._2dg(z.getDate())).replace("y",
- this._2dg((z.getFullYear() * 1)));
- }
- }
- eXcell_calendar.prototype = new eXcell;
- eXcell_calendar.prototype.setValue = function(val) {
- if (!val || val.toString()._dhx_trim() == "")
- val = "";
- this.cell.val = new Date(val.toString());
- if (this.cell.val == "NaN") {
- this.cell.val = "";
- this.cell.innerHTML = " ";
- } else
- this.cell.innerHTML = this._date2str(this.cell.val);
- }
|