source: branches/2.2.0.1/calendar/js/dhtmlx/samples/05_calendar/extra/dhtmlxcontainer.js @ 4001

Revision 4001, 30.2 KB checked in by rafaelraymundo, 13 years ago (diff)

Ticket #1615 - Componente novo para agenda......................................

Line 
1function dhtmlXContainer(obj) {
2       
3        var that = this;
4       
5        this.obj = obj;
6        this.dhxcont = null;
7       
8        this.setContent = function(data) {
9                this.dhxcont = data;
10                this.dhxcont.innerHTML = "<div id='dhxMainCont' style='position: relative; left: 0px; top: 0px; overflow: hidden;'></div>"+
11                                         "<div id='dhxContBlocker' class='dhxcont_content_blocker' style='display: none;'></div>";
12                this.dhxcont.mainCont = this.dhxcont.childNodes[0];
13                this.obj.dhxcont = this.dhxcont;
14        }
15       
16        this.obj._genStr = function(w) {
17                var s = ""; var z = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
18                for (var q=0; q<w; q++) { s = s + z.charAt(Math.round(Math.random() * z.length)); }
19                return s;
20        }
21       
22        this.obj.setMinContentSize = function(w, h) {
23                this._minDataSizeW = w;
24                this._minDataSizeH = h;
25        }
26       
27        this.obj.moveContentTo = function(cont) {
28               
29               
30                // move dhtmlx components
31               
32                var pref = null;
33                if (this.grid) pref = "grid";
34                if (this.tree) pref = "tree";
35                if (this.tabbar) pref = "tabbar";
36                if (this.folders) pref = "folders";
37                if (this.layout) pref = "layout";
38               
39                if (pref != null) {
40                        if (pref == "layout" && this._isCell && cont._isWindow) {
41                                var aDim = this.layout._defineWindowMinDimension(this, true);
42                                var bDim = cont.getDimension();
43                                cont.setDimension((aDim[1]>bDim[0]?aDim[1]:null), (aDim[2]>bDim[1]?aDim[2]:null));
44                        }
45                        if (pref == "tabbar" && cont._isCell) cont.hideHeader();
46                        cont.attachObject(this[pref+"Id"]);
47                        cont[pref] = this[pref];
48                        cont[pref+"Id"] = this[pref+"Id"];
49                        cont[pref+"Obj"] = this[pref+"Obj"];
50                        if (pref == "layout") {
51                                cont.layout._baseWFix = -2;
52                                cont.layout._baseHFix = -2;
53                                // from layout to window, attach event
54                                if (cont._isWindow) cont.attachEvent("_onBeforeTryResize", cont.layout._defineWindowMinDimension);
55                        }
56                        this[pref] = null;
57                        this[pref+"Id"] = null;
58                        this[pref+"Obj"] = null;
59                        if (pref == "tabbar" && this._isCell) this.showHeader();
60                }
61               
62                // menu/toolbar/statusbar should be after any object
63                if (this.menu != null) {
64                        cont.dhxcont.insertBefore(document.getElementById(this.menuId), cont.dhxcont.childNodes[0]);
65                        cont.menu = this.menu;
66                        cont.menuId = this.menuId;
67                        cont.menuHeight = this.menuHeight;
68                        this.menu = null;
69                        this.menuId = null;
70                        this.menuHeight = null;
71                        if (this._doOnAttachMenu) this._doOnAttachMenu("unload");
72                        if (cont._doOnAttachMenu) cont._doOnAttachMenu("move");
73                }
74                if (this.toolbar != null) {
75                        cont.dhxcont.insertBefore(document.getElementById(this.toolbarId), cont.dhxcont.childNodes[(cont.menu != null?1:0)]);
76                        cont.toolbar = this.toolbar;
77                        cont.toolbarId = this.toolbarId;
78                        cont.toolbarHeight = this.toolbarHeight;
79                        this.toolbar = null;
80                        this.toolbarId = null;
81                        this.toolbarHeight = null;
82                        if (this._doOnAttachToolbar) this._doOnAttachToolbar("unload");
83                        if (cont._doOnAttachToolbar) cont._doOnAttachToolbar("move");
84                }
85                if (this.sb != null) {
86                        cont.dhxcont.insertBefore(document.getElementById(this.sbId), cont.dhxcont.childNodes[cont.dhxcont.childNodes.length-1]);
87                        cont.sb = this.sb;
88                        cont.sbId = this.sbId;
89                        cont.sbHeight = this.sbHeight;
90                        this.sb = null;
91                        this.sbId = null;
92                        this.sbHeight = null;
93                        if (this._doOnAttachToolbar) this._doOnAttachToolbar("unload");
94                        if (cont._doOnAttachToolbar) cont._doOnAttachToolbar("move");
95                }
96               
97                // other objects
98                var objA = this.dhxcont.childNodes[0];
99                var objB = cont.dhxcont.childNodes[0];
100                while (objA.childNodes.length > 0) objB.appendChild(objA.childNodes[0]);
101                //
102                cont.updateNestedObjects();
103        }
104       
105        this.obj.adjustContent = function(parentObj, offsetTop, marginTop, notCalcWidth, offsetBottom) {
106               
107                this.dhxcont.style.left = (this._offsetLeft||0)+"px";
108                this.dhxcont.style.top = (this._offsetTop||0)+offsetTop+"px";
109                //
110                var cw = parentObj.clientWidth+(this._offsetWidth||0);
111                if (notCalcWidth !== true) this.dhxcont.style.width = Math.max(0, cw)+"px";
112                if (notCalcWidth !== true) if (this.dhxcont.offsetWidth > cw) this.dhxcont.style.width = Math.max(0, cw*2-this.dhxcont.offsetWidth)+"px";
113                //
114                var ch = parentObj.clientHeight+(this._offsetHeight||0);
115                this.dhxcont.style.height = Math.max(0, ch-offsetTop)+(marginTop!=null?marginTop:0)+"px";
116                if (this.dhxcont.offsetHeight > ch - offsetTop) this.dhxcont.style.height = Math.max(0, (ch-offsetTop)*2-this.dhxcont.offsetHeight)+"px";
117                if (offsetBottom) if (!isNaN(offsetBottom)) this.dhxcont.style.height = Math.max(0, parseInt(this.dhxcont.style.height)-offsetBottom)+"px";
118               
119                // main window content
120                if (this._minDataSizeH != null) {
121                        // height for menu/toolbar/status bar should be included
122                        if (parseInt(this.dhxcont.style.height) < this._minDataSizeH) this.dhxcont.style.height = this._minDataSizeH+"px";
123                }
124                if (this._minDataSizeW != null) {
125                        if (parseInt(this.dhxcont.style.width) < this._minDataSizeW) this.dhxcont.style.width = this._minDataSizeW+"px";
126                }
127               
128                if (notCalcWidth !== true) {
129                        this.dhxcont.mainCont.style.width = this.dhxcont.clientWidth+"px";
130                        // allow border to this.dhxcont.mainCont
131                        if (this.dhxcont.mainCont.offsetWidth > this.dhxcont.clientWidth) this.dhxcont.mainCont.style.width = Math.max(0, this.dhxcont.clientWidth*2-this.dhxcont.mainCont.offsetWidth)+"px";
132                }
133               
134                var menuOffset = (this.menu!=null?(!this.menuHidden?this.menuHeight:0):0);
135                var toolbarOffset = (this.toolbar!=null?(!this.toolbarHidden?this.toolbarHeight:0):0);
136                var statusOffset = (this.sb!=null?(!this.sbHidden?this.sbHeight:0):0);
137               
138                // allow border to this.dhxcont.mainCont
139                this.dhxcont.mainCont.style.height = this.dhxcont.clientHeight+"px";
140                if (this.dhxcont.mainCont.offsetHeight > this.dhxcont.clientHeight) this.dhxcont.mainCont.style.height = Math.max(0, this.dhxcont.clientHeight*2-this.dhxcont.mainCont.offsetHeight)+"px";
141                this.dhxcont.mainCont.style.height = Math.max(0, parseInt(this.dhxcont.mainCont.style.height)-menuOffset-toolbarOffset-statusOffset)+"px";
142               
143        }
144        this.obj.coverBlocker = function() {
145                return this.dhxcont.childNodes[this.dhxcont.childNodes.length-1];
146        }
147        this.obj.showCoverBlocker = function() {
148                this.coverBlocker().style.display = "";
149        }
150        this.obj.hideCoverBlocker = function() {
151                this.coverBlocker().style.display = "none";
152        }
153        this.obj.updateNestedObjects = function() {
154                if (this.grid) { this.grid.setSizes(); }
155                if (this.tabbar) { this.tabbar.adjustOuterSize(); }
156                if (this.folders) { this.folders.setSizes(); }
157                if (this.editor) {
158                        if (!_isIE) this.editor._prepareContent(true);
159                        this.editor.setSizes();
160                }
161                 //if (_isOpera) { var t = this; window.setTimeout(function(){t.editor.adjustSize();},10); } else { this.editor.adjustSize(); } }
162                if (this.layout) {
163                        this.layoutObj.style.width = this.dhxcont.mainCont.style.width;
164                        this.layoutObj.style.height = this.dhxcont.mainCont.style.height;
165                       
166                        if (this._isAcc && this.skin == "dhx_skyblue") {
167                                this.layoutObj.style.width = parseInt(this.dhxcont.mainCont.style.width)+2+"px";
168                                this.layoutObj.style.height = parseInt(this.dhxcont.mainCont.style.height)+2+"px";
169                        }
170                       
171                        this.layout.setSizes();
172                }
173                if (this.accordion != null) {
174                        this.accordionObj.style.width = parseInt(this.dhxcont.mainCont.style.width)+2+"px";
175                        this.accordionObj.style.height = parseInt(this.dhxcont.mainCont.style.height)+2+"px";
176                        this.accordion.setSizes();
177                }
178                // docked layout's cell
179                if (this.dockedCell) { this.dockedCell.updateNestedObjects(); }
180                /*
181                if (win.accordion != null) { win.accordion.setSizes(); }
182                if (win.layout != null) { win.layout.setSizes(win); }
183                */
184        }
185        /**
186        *   @desc: attaches a status bar to a window
187        *   @type: public
188        */
189        this.obj.attachStatusBar = function() {
190                var sbObj = document.createElement("DIV");
191               
192                if (this._isCell) {
193                        sbObj.className = "dhxcont_sb_container_layoutcell";
194                } else {
195                        sbObj.className = "dhxcont_sb_container";
196                }
197                sbObj.id = "sbobj_"+this._genStr(12);
198                sbObj.innerHTML = "<div class='dhxcont_statusbar'></div>";
199                this.dhxcont.insertBefore(sbObj, this.dhxcont.childNodes[this.dhxcont.childNodes.length-1]);
200               
201                sbObj.setText = function(text) { this.childNodes[0].innerHTML = text; }
202                sbObj.getText = function() { return this.childNodes[0].innerHTML; }
203                sbObj.onselectstart = function(e) { e=e||event; e.returnValue=false; return false; }
204                this.sb = sbObj;
205                this.sbHeight = sbObj.offsetHeight;
206                this.sbId = sbObj.id;
207               
208                if (this._doOnAttachStatusBar) this._doOnAttachStatusBar("init");
209                this.adjust();
210                return this.sb;
211        }
212        /**
213        *   @desc: detaches a status bar from a window
214        *   @type: public
215        */
216        this.obj.detachStatusBar = function() {
217                if (!this.sb) return;
218                this.sb.setText = null;
219                this.sb.getText = null;
220                this.sb.onselectstart = null;
221                this.sb.parentNode.removeChild(this.sb);
222                this.sb = null;
223                this.sbHeight = null;
224                this.sbId = null;
225                if (this._doOnAttachStatusBar) this._doOnAttachStatusBar("unload");
226        }
227        /**
228        *   @desc: attaches a dhtmlxMenu to a window
229        *   @type: public
230        */
231        this.obj.attachMenu = function() {
232                var menuObj = document.createElement("DIV");
233                menuObj.style.position = "relative";
234                menuObj.style.overflow = "hidden";
235               
236                menuObj.id = "dhxmenu_"+this._genStr(12);
237                this.dhxcont.insertBefore(menuObj, this.dhxcont.childNodes[0]);
238               
239                this.menu = new dhtmlXMenuObject(menuObj.id, this.skin);
240               
241                this.menuHeight = menuObj.offsetHeight;
242                this.menuId = menuObj.id;
243               
244                if (this._doOnAttachMenu) this._doOnAttachMenu("init");
245               
246                this.adjust();
247                return this.menu;
248        }
249        /**
250        *   @desc: detaches a dhtmlxMenu from a window
251        *   @type: public
252        */
253        this.obj.detachMenu = function() {
254                if (!this.menu) return;
255                var menuObj = document.getElementById(this.menuId);
256                this.menu.unload();
257                this.menu = null;
258                this.menuId = null;
259                this.menuHeight = null;
260                menuObj.parentNode.removeChild(menuObj);
261                menuObj = null;
262                if (this._doOnAttachMenu) this._doOnAttachMenu("unload");
263        }
264        /**
265        *   @desc: attaches a dhtmlxToolbar to a window
266        *   @type: public
267        */
268        this.obj.attachToolbar = function() {
269                var toolbarObj = document.createElement("DIV");
270                toolbarObj.style.position = "relative";
271                toolbarObj.style.overflow = "hidden";
272                toolbarObj.id = "dhxtoolbar_"+this._genStr(12);
273                this.dhxcont.insertBefore(toolbarObj, this.dhxcont.childNodes[(this.menu!=null?1:0)]);
274                this.toolbar = new dhtmlXToolbarObject(toolbarObj.id, this.skin);
275                this.toolbarHeight = toolbarObj.offsetHeight+(this._isLayout&&this.skin=="dhx_skyblue"?2:0);
276                this.toolbarId = toolbarObj.id;
277                if (this._doOnAttachToolbar) this._doOnAttachToolbar("init");
278                this.adjust();
279                return this.toolbar;
280        }
281        /**
282        *   @desc: detaches a dhtmlxToolbar from a window
283        *   @type: public
284        */
285        this.obj.detachToolbar = function() {
286                if (!this.toolbar) return;
287                var toolbarObj = document.getElementById(this.toolbarId);
288                this.toolbar.unload();
289                this.toolbar = null;
290                this.toolbarId = null;
291                this.toolbarHeight = null;
292                toolbarObj.parentNode.removeChild(toolbarObj);
293                toolbarObj = null;
294                if (this._doOnAttachToolbar) this._doOnAttachToolbar("unload");
295        }
296        /**
297        *   @desc: attaches a dhtmlxGrid to a window
298        *   @type: public
299        */
300        this.obj.attachGrid = function() {
301                if (this._isWindow && this.skin == "dhx_skyblue") {
302                        this.dhxcont.mainCont.style.border = "#a4bed4 1px solid";
303                        this._redraw();
304                }
305                var obj = document.createElement("DIV");
306                obj.id = "dhxGridObj_"+this._genStr(12);
307                obj.style.width = "100%";
308                obj.style.height = "100%";
309                obj.cmp = "grid";
310                document.body.appendChild(obj);
311                this.attachObject(obj.id);
312                this.grid = new dhtmlXGridObject(obj.id);
313                this.grid.setSkin(this.skin);
314                this.grid.entBox.style.border = "0px solid white";
315                this.grid._sizeFix=0;
316               
317                this.gridId = obj.id;
318                this.gridObj = obj;
319               
320                return this.grid;
321        }
322        /**
323        *   @desc: attaches a dhtmlxScheduler to a window
324        *   @type: public
325        */     
326        this.obj.attachScheduler = function(day,mode) {
327                var obj = document.createElement("DIV");
328                obj.innerHTML='<div id="scheduler_here" class="dhx_cal_container" style="width:100%; height:100%;"><div class="dhx_cal_navline"><div class="dhx_cal_prev_button">&nbsp;</div><div class="dhx_cal_next_button">&nbsp;</div><div class="dhx_cal_today_button"></div><div class="dhx_cal_date"></div><div class="dhx_cal_tab" name="day_tab" style="right:204px;"></div><div class="dhx_cal_tab" name="week_tab" style="right:140px;"></div><div class="dhx_cal_tab" name="month_tab" style="right:76px;"></div></div><div class="dhx_cal_header"></div><div class="dhx_cal_data"></div></div>';
329               
330                document.body.appendChild(obj.firstChild);
331                this.attachObject("scheduler_here");
332               
333                this.grid = scheduler;
334                scheduler.setSizes = scheduler.update_view;
335                scheduler.destructor=function(){};
336                scheduler.init("scheduler_here",day,mode);
337               
338                //this.grid.entBox.style.border = "0px solid white";
339               
340
341                return this.grid;
342        }       
343        /**
344        *   @desc: attaches a dhtmlxTree to a window
345        *   @param: rootId - not mandatory, tree super root, see dhtmlxTree documentation for details
346        *   @type: public
347        */
348        this.obj.attachTree = function(rootId) {
349                if (this._isWindow && this.skin == "dhx_skyblue") {
350                        this.dhxcont.mainCont.style.border = "#a4bed4 1px solid";
351                        this._redraw();
352                }
353                var obj = document.createElement("DIV");
354                obj.id = "dhxTreeObj_"+this._genStr(12);
355                obj.style.width = "100%";
356                obj.style.height = "100%";
357                obj.cmp = "tree";
358                document.body.appendChild(obj);
359                this.attachObject(obj.id);
360                this.tree = new dhtmlXTreeObject(obj.id, "100%", "100%", (rootId||0));
361                this.tree.setSkin(this.skin);
362                // this.tree.allTree.style.paddingTop = "2px";
363                this.tree.allTree.childNodes[0].style.marginTop = "2px";
364                this.tree.allTree.childNodes[0].style.marginBottom = "2px";
365               
366                this.treeId = obj.id;
367                this.treeObj = obj;
368               
369                return this.tree;
370        }
371        /**
372        *   @desc: attaches a dhtmlxTabbar to a window
373        *   @type: public
374        */
375        this.obj.attachTabbar = function(mode) {
376               
377                if (this._isWindow && this.skin == "dhx_skyblue") {
378                        this.dhxcont.style.border = "none";
379                        this.setDimension(this.w, this.h);
380                }
381               
382                var obj = document.createElement("DIV");
383                obj.id = "dhxTabbarObj_"+this._genStr(12);
384                obj.style.width = "100%";
385                obj.style.height = "100%";
386                obj.style.overflow = "hidden";
387                obj.cmp = "tabbar";
388                document.body.appendChild(obj);
389                this.attachObject(obj.id);
390               
391                // manage dockcell if exists
392                /*
393                if (this._dockCell != null && that.dhxLayout != null) {
394                        var dockCell = that.dhxLayout.polyObj[this._dockCell];
395                        if (dockCell != null) {
396                                dockCell.childNodes[0]._tabbarMode = true;
397                                that.dhxLayout.hidePanel(this._dockCell);
398                                dockCell.className = "dhtmlxLayoutSinglePolyTabbar";
399                                // dockCell.childNodes[0]._h = -2;
400                                // dockCell.childNodes[1].style.height = parseInt(dockCell.childNodes[1].style.height) - dockCell.childNodes[0]._h + "px";
401                                // dockCell.className = "dhtmlxLayoutSinglePolyTabbar";
402                                // fix panel
403                                // that.dhxLayout._panelForTabs(this._dockCell);
404                        }
405                }
406                */
407                if (this.className == "dhtmlxLayoutSinglePoly") { this.hideHeader(); }
408                //
409                this.tabbar = new dhtmlXTabBar(obj.id, mode||"top", 20);
410                if (!this._isWindow)
411                        this.tabbar._s.expand = true;
412                this.tabbar.setSkin(this.skin);
413                /*
414                if ((_isIE)&&(document.compatMode == "BackCompat")){
415                        this.tabbar._lineAHeight=this.tabbar._lineA.style.height="6px";
416                        this.tabbar._bFix=5;
417                } else{
418                        this.tabbar._lineAHeight=this.tabbar._lineA.style.height="4px";
419                        this.tabbar._bFix=4;
420                }
421                */
422                //this.tabbar.setSkin("dhx_blue");
423                //this.tabbar.enableScroll(false)
424                //this.tabbar._conZone.style.borderWidth="0px";
425                //this.tabbar._EARS = true;
426                //this.tabbar.setMargin(-1)
427                //this.tabbar.setOffset(0)
428                this.tabbar.adjustOuterSize();
429                this.tabbarId = obj.id;
430                this.tabbarObj = obj;
431               
432                return this.tabbar;
433        }
434        /**
435        *   @desc: attaches a dhtmlxFolders to a window
436        *   @type: public
437        */
438        this.obj.attachFolders = function() {
439                if (this._isWindow && this.skin == "dhx_skyblue") {
440                        this.dhxcont.mainCont.style.border = "#a4bed4 1px solid";
441                        this._redraw();
442                }
443                var obj = document.createElement("DIV");
444                obj.id = "dhxFoldersObj_"+this._genStr(12);
445                obj.style.width = "100%";
446                obj.style.height = "100%";
447                obj.style.overflow = "hidden";
448                obj.cmp = "folders";
449                document.body.appendChild(obj);
450                this.attachObject(obj.id);
451                this.folders = new dhtmlxFolders(obj.id);
452                this.folders.setSizes();
453               
454                this.foldersId = obj.id;
455                this.foldersObj = obj;
456               
457                return this.folders;
458        }
459        /**
460        *   @desc: attaches a dhtmlxAccordion to a window
461        *   @type: public
462        */
463        this.obj.attachAccordion = function() {
464                if (this._isWindow && this.skin == "dhx_skyblue") {
465                        this.dhxcont.mainCont.style.border = "#a4bed4 1px solid";
466                        this._redraw();
467                }
468               
469                var obj = document.createElement("DIV");
470                obj.id = "dhxAccordionObj_"+this._genStr(12);
471               
472                obj.style.left = "-1px";
473                obj.style.top = "-1px";
474                obj.style.width = parseInt(this.dhxcont.mainCont.style.width)+2+"px";
475                obj.style.height = parseInt(this.dhxcont.mainCont.style.height)+2+"px";
476                //
477                obj.style.position = "relative";
478                obj.cmp = "accordion";
479                document.body.appendChild(obj);
480                this.attachObject(obj.id);
481                this.accordion = new dhtmlXAccordion(obj.id, this.skin);
482               
483                // win._content.childNodes[2].className += " dhtmlxAccordionAttached";
484                this.accordion.setSizes();
485               
486                this.accordionId = obj.id;
487                this.accordionObj = obj;
488               
489                return this.accordion;
490        }
491        /**
492        *   @desc: attaches a dhtmlxLayout to a window
493        *   @param: view - layout's pattern
494        *   @param: skin - layout's skin
495        *   @type: public
496        */
497        this.obj.attachLayout = function(view, skin) {
498               
499                // attach layout to layout
500                if (this._isCell && this.skin == "dhx_skyblue") {
501                        this.hideHeader();
502                        this.dhxcont.style.border = "0px solid white";
503                        this.adjustContent(this.childNodes[0], 0);
504                }
505               
506                var obj = document.createElement("DIV");
507                obj.id = "dhxLayoutObj_"+this._genStr(12);
508                obj.style.overflow = "hidden";
509                obj.style.position = "absolute";
510               
511                obj.style.left = "0px";
512                obj.style.top = "0px";
513                obj.style.width = parseInt(this.dhxcont.mainCont.style.width)+"px";
514                obj.style.height = parseInt(this.dhxcont.mainCont.style.height)+"px";
515               
516                if (this._isAcc && this.skin == "dhx_skyblue") {
517                        obj.style.left = "-1px";
518                        obj.style.top = "-1px";
519                        obj.style.width = parseInt(this.dhxcont.mainCont.style.width)+2+"px";
520                        obj.style.height = parseInt(this.dhxcont.mainCont.style.height)+2+"px";
521                }
522               
523                // needed for layout's init
524                obj.dhxContExists = true;
525                obj.cmp = "layout";
526                document.body.appendChild(obj);
527                this.attachObject(obj.id);
528               
529                this.layout = new dhtmlXLayoutObject(obj, view, this.skin);
530               
531                // window/layout events configuration
532               
533                if (this._isWindow) this.attachEvent("_onBeforeTryResize", this.layout._defineWindowMinDimension);
534               
535                this.layoutId = obj.id;
536                this.layoutObj = obj;
537               
538                // this.adjust();
539                return this.layout;
540        }
541        /**
542        *   @desc: attaches a dhtmlxEditor to a window
543        *   @param: skin - not mandatory, editor's skin
544        *   @type: public
545        */
546        this.obj.attachEditor = function(skin) {
547                if (this._isWindow && this.skin == "dhx_skyblue") {
548                        this.dhxcont.mainCont.style.border = "#a4bed4 1px solid";
549                        this._redraw();
550                }
551                var obj = document.createElement("DIV");
552                obj.id = "dhxEditorObj_"+this._genStr(12);
553                obj.style.position = "relative";
554                obj.style.display = "none";
555                obj.style.overflow = "hidden";
556                obj.style.width = "100%";
557                obj.style.height = "100%";
558                obj.cmp = "editor";
559                document.body.appendChild(obj);
560                //
561                this.attachObject(obj.id);
562                //
563                this.editor = new dhtmlXEditor(obj.id, this.skin);
564               
565                this.editorId = obj.id;
566                this.editorObj = obj;
567                return this.editor;
568               
569        }
570       
571        /**
572        *   @desc: attaches an object into a window
573        *   @param: obj - object or object id
574        *   @param: autoSize - set true to adjust a window to object's dimension
575        *   @type: public
576        */
577        this.obj.attachObject = function(obj, autoSize) {
578                if (typeof(obj) == "string") obj = document.getElementById(obj);
579                if (autoSize) {
580                        obj.style.visibility = "hidden";
581                        obj.style.display = "";
582                        var objW = obj.offsetWidth;
583                        var objH = obj.offsetHeight;
584                }
585                this._attachContent("obj", obj);
586                if (autoSize && this._isWindow) {
587                        obj.style.visibility = "visible";
588                        this._adjustToContent(objW, objH);
589                        /* this._engineAdjustWindowToContent(this, objW, objH); */
590                }
591        }
592        /**
593        *
594        *
595        */
596        this.obj.detachObject = function(remove) {
597               
598                // detach dhtmlx components
599               
600                var pref = null;
601               
602                if (this.tree) pref = "tree";
603                if (this.grid) pref = "grid";
604                if (this.layout) pref = "layout";
605                if (this.tabbar) pref = "tabbar";
606                if (this.accordion) pref = "accordion";
607                if (this.folders) pref = "folders";
608               
609                if (pref != null) {
610                        var objHandler = null;
611                        var objLink = null;
612                        if (remove == true) {
613                                // completely remove
614                                if (this[pref].unload) this[pref].unload();
615                                if (this[pref].destructor) this[pref].destructor();
616                                while (this[pref+"Obj"].childNodes.length > 0) this[pref+"Obj"].removeChild(this[pref+"Obj"].childNodes[0]);
617                        } else {
618                                // attach to body
619                                document.body.appendChild(this[pref+"Obj"]);
620                                this[pref+"Obj"].style.display = "none";
621                                objHandler = this[pref];
622                                objLink = this[pref+"Obj"];
623                        }
624                        this[pref] = null;
625                        this[pref+"Id"] = null;
626                        this[pref+"Obj"] = null;
627                        return new Array(objHandler, objLink);
628                }
629               
630                // detach any other content
631                var objA = this.dhxcont.childNodes[0];
632                while (objA.childNodes.length > 0) {
633                        if (remove == true) {
634                                objA.removeChild(objA.childNodes[0]);
635                        } else {
636                                var obj = objA.childNodes[0];
637                                document.body.appendChild(obj);
638                                obj.style.display = "none";
639                        }
640                }
641        }
642       
643        /**
644        *   @desc: appends an object into a window
645        *   @param: obj - object or object id
646        *   @type: public
647        */
648        this.obj.appendObject = function(obj) {
649                if (typeof(obj) == "string") { obj = document.getElementById(obj); }
650                this._attachContent("obj", obj, true);
651        }
652        /**
653        *   @desc: attaches an html string as an object into a window
654        *   @param: str - html string
655        *   @type: public
656        */
657        this.obj.attachHTMLString = function(str) {
658                this._attachContent("str", str);
659                var z=str.match(/<script[^>]*>[^\f]*?<\/script>/g)||[];
660                for (var i=0; i<z.length; i++){
661                        var s=z[i].replace(/<([\/]{0,1})script[^>]*>/g,"")
662                        if (window.execScript) {
663                                if (!s.length){
664                                        var url =/src=('|")([^'"]+)('|")/.match(z[i]);
665                                        debugger;
666                                        if (!url) return;
667                                       
668                                        s=dhtmlxAjaxa.getSync(url);
669                                }
670                                window.execScript(s);
671                        }
672                        else window.eval(s);
673                }
674        }
675        /**
676        *   @desc: attaches an url into a window
677        *   @param: url
678        *   @param: ajax - loads an url with ajax
679        *   @type: public
680        */
681        this.obj.attachURL = function(url, ajax) {
682                this._attachContent((ajax==true?"urlajax":"url"), url, false);
683        }
684        this.obj.adjust = function() {
685                if (this.skin == "dhx_skyblue") {
686                        if (this.menu) {
687                                if (this._isWindow || this._isLayout) {
688                                        this.menu._topLevelOffsetLeft = 0;
689                                        document.getElementById(this.menuId).style.height = "26px";
690                                        this.menuHeight = document.getElementById(this.menuId).offsetHeight;
691                                        if (this._doOnAttachMenu) this._doOnAttachMenu("show");
692                                }
693                                if (this._isCell) {
694                                        document.getElementById(this.menuId).className += " in_layoutcell";
695                                        // document.getElementById(this.menuId).style.height = "25px";
696                                        this.menuHeight = 25;
697                                }
698                                if (this._isAcc) {
699                                        document.getElementById(this.menuId).className += " in_acccell";
700                                        // document.getElementById(this.menuId).style.height = "25px";
701                                        this.menuHeight = 25;
702                                }
703                                if (this._doOnAttachMenu) this._doOnAttachMenu("adjust");
704                        }
705                        if (this.toolbar) {
706                                if (this._isWindow || this._isLayout) {
707                                        document.getElementById(this.toolbarId).style.height = "29px";
708                                        this.toolbarHeight = document.getElementById(this.toolbarId).offsetHeight;
709                                        if (this._doOnAttachToolbar) this._doOnAttachToolbar("show");
710                                }
711                                if (this._isCell) {
712                                        document.getElementById(this.toolbarId).className += " in_layoutcell";
713                                }
714                                if (this._isAcc) {
715                                        document.getElementById(this.toolbarId).className += " in_acccell";
716                                }
717                        }
718                }
719        }
720        // attach content obj|url
721        this.obj._attachContent = function(type, obj, append) {
722                // clear old content
723                if (append !== true) {
724                        while (that.dhxcont.mainCont.childNodes.length > 0) { that.dhxcont.mainCont.removeChild(that.dhxcont.mainCont.childNodes[0]); }
725                }
726                // attach
727                if (type == "url") {
728                        if (this._isWindow && obj.cmp == null && this.skin == "dhx_skyblue") {
729                                this.dhxcont.mainCont.style.border = "#a4bed4 1px solid";
730                                this._redraw();
731                        }
732                        var fr = document.createElement("IFRAME");
733                        fr.frameBorder = 0;
734                        fr.border = 0;
735                        fr.style.width = "100%";
736                        fr.style.height = "100%";
737                        fr.setAttribute("src","javascript:false;");
738                        that.dhxcont.mainCont.appendChild(fr);
739                        fr.src = obj;
740                        this._frame = fr;
741                        if (this._doOnAttachURL) this._doOnAttachURL(true);
742                } else if (type == "urlajax") {
743                        if (this._isWindow && obj.cmp == null && this.skin == "dhx_skyblue") {
744                                this.dhxcont.mainCont.style.border = "#a4bed4 1px solid";
745                                this.dhxcont.mainCont.style.backgroundColor = "#FFFFFF";
746                                this._redraw();
747                        }
748                        var t = this;
749                        var xmlParser = function(){
750                                t.attachHTMLString(this.xmlDoc.responseText,this);
751                                if (t._doOnAttachURL) t._doOnAttachURL(false);
752                                this.destructor();
753                        }
754                        var xmlLoader = new dtmlXMLLoaderObject(xmlParser, window);
755                        xmlLoader.dhxWindowObject = this;
756                        xmlLoader.loadXML(obj);
757                } else if (type == "obj") {
758                        if (this._isWindow && obj.cmp == null && this.skin == "dhx_skyblue") {
759                                this.dhxcont.mainCont.style.border = "#a4bed4 1px solid";
760                                this.dhxcont.mainCont.style.backgroundColor = "#FFFFFF";
761                                this._redraw();
762                        }
763                        that.dhxcont._frame = null;
764                        that.dhxcont.mainCont.appendChild(obj);
765                        // this._engineGetWindowContent(win).style.overflow = (append===true?"auto":"hidden");
766                        // win._content.childNodes[2].appendChild(obj);
767                        that.dhxcont.mainCont.style.overflow = (append===true?"auto":"hidden");
768                        obj.style.display = "";
769                } else if (type == "str") {
770                        if (this._isWindow && obj.cmp == null && this.skin == "dhx_skyblue") {
771                                this.dhxcont.mainCont.style.border = "#a4bed4 1px solid";
772                                this.dhxcont.mainCont.style.backgroundColor = "#FFFFFF";
773                                this._redraw();
774                        }
775                        that.dhxcont._frame = null;
776                        that.dhxcont.mainCont.innerHTML = obj;
777                }
778        }
779       
780        this.obj.showMenu = function() {
781                if (!(this.menu && this.menuId)) return;
782                if (document.getElementById(this.menuId).style.display != "none") return;
783                this.menuHidden = false;
784                if (this._doOnAttachMenu) this._doOnAttachMenu("show");
785                document.getElementById(this.menuId).style.display = "";
786        }
787       
788        this.obj.hideMenu = function() {
789                if (!(this.menu && this.menuId)) return;
790                if (document.getElementById(this.menuId).style.display == "none") return;
791                document.getElementById(this.menuId).style.display = "none";
792                this.menuHidden = true;
793                if (this._doOnAttachMenu) this._doOnAttachMenu("hide");
794        }
795       
796        this.obj.showToolbar = function() {
797                if (!(this.toolbar && this.toolbarId)) return;
798                if (document.getElementById(this.toolbarId).style.display != "none") return;
799                this.toolbarHidden = false;
800                if (this._doOnAttachToolbar) this._doOnAttachToolbar("show");
801                document.getElementById(this.toolbarId).style.display = "";
802        }
803       
804        this.obj.hideToolbar = function() {
805                if (!(this.toolbar && this.toolbarId)) return;
806                if (document.getElementById(this.toolbarId).style.display == "none") return;
807                this.toolbarHidden = true;
808                document.getElementById(this.toolbarId).style.display = "none";
809                if (this._doOnAttachToolbar) this._doOnAttachToolbar("hide");
810        }
811       
812        this.obj.showStatusBar = function() {
813                if (!(this.sb && this.sbId)) return;
814                if (document.getElementById(this.sbId).style.display != "none") return;
815                this.sbHidden = false;
816                if (this._doOnAttachStatusBar) this._doOnAttachStatusBar("show");
817                document.getElementById(this.sbId).style.display = "";
818        }
819       
820        this.obj.hideStatusBar = function() {
821                if (!(this.sb && this.sbId)) return;
822                if (document.getElementById(this.sbId).style.display == "none") return;
823                this.sbHidden = true;
824                document.getElementById(this.sbId).style.display = "none";
825                if (this._doOnAttachStatusBar) this._doOnAttachStatusBar("hide");
826        }
827       
828        this.obj._dhxContDestruct = function() {
829               
830                // clear attached objects
831                this.detachMenu();
832                this.detachToolbar();
833                this.detachStatusBar();
834               
835                // remove any attached object
836                this.detachObject(true);
837               
838                // remove attached components
839                if (this.layout) this.layout.unlaod();
840                if (this.accordion) this.accordion.unlaod();
841                if (this.grid) this.grid.destructor();
842                if (this.tree) this.tree.destructor();
843                if (this.tabbar) this.tabbar.destructor();
844                this.layout = null;
845                this.accordion = null;
846                this.grid = null;
847                this.tree = null;
848                this.tabbar = null;
849               
850                // clear methods
851                this.adjust = null;
852                this._genStr = null;
853                this.setMinContentSize = null;
854                this.moveContentTo = null;
855                this.adjustContent = null;
856                this.coverBlocker = null;
857                this.showCoverBlocker = null;
858                this.hideCoverBlocker = null;
859                this.updateNestedObjects = null;
860                this.attachStatusBar = null;
861                this.detachStatusBar = null;
862                this.attachMenu = null;
863                this.detachMenu = null;
864                this.attachToolbar = null;
865                this.detachToolbar = null;
866               
867                this.attachGrid = this.attachTree = this.attachTabbar = this.attachFolders = this.attachAccordion = this.attachLayout = this.attachEditor = this.attachObject = this.detachObject = this.appendObject = this.attachHTMLString =  this.attachURL = this._attachContent = this.attachScheduler = null;
868               
869                this.showMenu = null;
870                this.hideMenu = null;
871                this.showToolbar = null;
872                this.hideToolbar = null;
873                this.showStatusBar = null;
874                this.hideStatusBar = null;
875               
876                while (this.dhxcont.mainCont.childNodes.length > 0) this.dhxcont.mainCont.removeChild(this.dhxcont.mainCont.childNodes[0]);
877                this.dhxcont.mainCont.innerHTML = "";
878                this.dhxcont.mainCont = null;
879                try { delete this.dhxcont["mainCont"]; } catch(e){};
880               
881                while (this.dhxcont.childNodes.length > 0) this.dhxcont.removeChild(this.dhxcont.childNodes[0]);
882                this.dhxcont.innerHTML = "";
883                this.dhxcont = null;
884                try { delete this["dhxcont"]; } catch(e){};
885        }
886       
887}
Note: See TracBrowser for help on using the repository browser.