1/* 2Product Name: dhtmlxSuite 3Version: 5.1.0 4Edition: Professional 5License: content of this file is covered by DHTMLX Commercial or Enterprise license. Usage without proper license is prohibited. To obtain it contact [email protected] 6Copyright UAB Dinamenta http://www.dhtmlx.com 7*/ 8 9function dhtmlXCellObject(idd, css) { 10 11 this.cell = document.createElement("DIV"); 12 this.cell.className = "dhx_cell"+(css||""); 13 14 this._idd = idd; 15 this._isCell = true; 16 17 this.conf = { 18 borders: true, 19 idx: {}, 20 css: css||"", 21 idx_data: { 22 cont: "dhx_cell_cont", 23 pr1: "dhx_cell_progress_bar", 24 pr2: "dhx_cell_progress_img", 25 pr3: "dhx_cell_progress_svg", 26 menu: "dhx_cell_menu", 27 toolbar: "dhx_cell_toolbar", 28 ribbon: "dhx_cell_ribbon", 29 sb: "dhx_cell_statusbar", 30 cover: "dhx_cell_cover" 31 }, 32 ofs_nodes: { t:{}, b:{} } // attached dataNodes (menu/toolbar/status), can be true, false; 33 // in case of layout - "func" for header 34 } 35 36 this.dataNodes = {}; // menu/toolbar/status 37 38 this.views = {}; 39 40 // cont 41 var p = document.createElement("DIV"); 42 p.className = "dhx_cell_cont"+this.conf.css; 43 this.cell.appendChild(p); 44 p = null; 45 46 this._updateIdx = function() { 47 for (var a in this.conf.idx) { 48 this.conf.idx[a] = null; 49 delete this.conf.idx[a]; 50 } 51 for (var q=0; q<this.cell.childNodes.length; q++) { 52 var css = this.cell.childNodes[q].className; 53 for (var a in this.conf.idx_data) { 54 var r = new RegExp(this.conf.idx_data[a]); 55 if (css.match(r) != null) this.conf.idx[a] = q; 56 } 57 } 58 59 this.callEvent("_onIdxUpdated",[]); 60 } 61 62 this._adjustAttached = function() { 63 // mtb/ribbon 64 for (var a in this.dataNodes) { 65 if (this.dataNodes[a] != null && typeof(this.dataNodes[a].setSizes) == "function") { 66 this.dataNodes[a].setSizes(); 67 } 68 } 69 // attached node 70 if (this.dataObj != null && typeof(this.dataObj.setSizes) == "function") { 71 // check if dataObj is layuot which was attached separately 72 if (this.dataType == "layout" && typeof(window.dhtmlXLayoutCell) == "function" && this instanceof window.dhtmlXLayoutCell && this.dataObj._getMainInst() != this.layout._getMainInst()) { 73 this.dataObj.setSizes(); 74 return; 75 } 76 this.dataObj.setSizes.apply(this.dataObj, arguments); 77 } 78 } 79 80 this._setSize = function(x, y, w, h, parentIdd, noCalcCont, actionType, customProps) { 81 82 if (this.conf.size == null) this.conf.size = {}; 83 if (customProps == null) customProps = {}; // ability to use margin-left instead of left 84 85 var styleProps = {left: "x", top: "y", width: "w", height: "h"}; 86 87 this.conf.size.x = x; 88 this.conf.size.y = y; 89 this.conf.size.w = Math.max(w,0); 90 this.conf.size.h = Math.max(h,0); 91 92 for (var a in styleProps) { 93 var name = (customProps[a]||a); 94 this.cell.style[name] = this.conf.size[styleProps[a]]+"px"; 95 } 96 97 this.callEvent("_onSetSize",[]); 98 99 if (noCalcCont !== true) { 100 this._adjustCont(parentIdd, actionType); 101 } else { 102 this._adjustAttached(parentIdd); 103 } 104 105 this._adjustProgress(); 106 } 107 108 this._adjustCont = function(parentIdd, actionType) { 109 110 var t = this.cell.childNodes[this.conf.idx.cont]; 111 112 // attempt to adjust cell in collapsed layout 113 if (typeof(window.dhtmlXLayoutCell) == "function" && this instanceof window.dhtmlXLayoutCell && this.conf.collapsed == true) { 114 t.style.left = t.style.top = "0px"; 115 t.style.width = t.style.height = "200px"; 116 t = null; 117 return; 118 } 119 120 // header height, menu, toolbar if any 121 var ht = 0; 122 for (var a in this.conf.ofs_nodes.t) { 123 var k = this.conf.ofs_nodes.t[a]; 124 ht += (k=="func"?this[a]():(k==true?this.cell.childNodes[this.conf.idx[a]].offsetHeight:0)); 125 } 126 127 // bottom offset (height reduce if status attached) 128 var hb = 0; 129 for (var a in this.conf.ofs_nodes.b) { 130 var k = this.conf.ofs_nodes.b[a]; 131 hb += (k=="func"?this[a]():(k==true?this.cell.childNodes[this.conf.idx[a]].offsetHeight:0)); 132 } 133 134 t.style.left = "0px"; 135 t.style.top = ht+"px"; 136 137 if (this.conf.cells_cont == null) { 138 this.conf.cells_cont = {}; 139 t.style.width = this.cell.offsetWidth+"px"; 140 t.style.height = Math.max(this.cell.offsetHeight-ht-hb,0)+"px"; 141 this.conf.cells_cont.w = parseInt(t.style.width)-t.offsetWidth; 142 this.conf.cells_cont.h = parseInt(t.style.height)-t.offsetHeight; 143 } 144
145 t.style.left = "0px"; 146 t.style.top = ht+"px"; 147 t.style.width = Math.max(this.cell.offsetWidth+this.conf.cells_cont.w,0)+"px"; 148 t.style.height = Math.max(this.conf.size.h-ht-hb+this.conf.cells_cont.h,0)+"px"; 149 t = null; 150 151 // move out? 152 this._adjustAttached(parentIdd); // for layout only 1 arg should be here 153 154 // editor adjust cont here, browser check needed ( !!make some tests :) 155 if (actionType == "expand" && this.dataType == "editor" && this.dataObj != null) { 156 this.dataObj._prepareContent(true); 157 } 158 } 159 160 this._mtbUpdBorder = function() { 161 162 var t = ["menu","toolbar","ribbon"]; 163 for (var q=0; q<t.length; q++) { 164 if (this.conf.idx[t[q]] != null) { 165 var p = this.cell.childNodes[this.conf.idx[t[q]]]; 166 var c1 = "dhx_cell_"+t[q]+"_no_borders"; 167 var c2 = "dhx_cell_"+t[q]+"_def"; 168 p.className = p.className.replace(new RegExp(this.conf.borders?c1:c2), this.conf.borders?c2:c1); 169 p = null; 170 } 171 } 172 } 173 174 this._resetSizeState = function() { 175 // delete autosize settings, autocalc for cell_cont borders, paddings, useful on skinchange 176 this.conf.cells_cont = null; 177 } 178 179 /* views */ 180 181 // test with url and getFrame() 182 183 // current view 184 this.conf.view = "def"; 185 186 // views loaded at least once 187 this.conf.views_loaded = {}; 188 this.conf.views_loaded[this.conf.view] = true; 189 190 // move current data to archive 191 this._viewSave = function(name) { 192 193 this.views[name] = { 194 borders: this.conf.borders, 195 ofs_nodes: {t:{},b:{}}, 196 url_data: this.conf.url_data, 197 dataType: this.dataType, 198 dataObj: this.dataObj, 199 cellCont: [], 200 dataNodes: {}, 201 dataNodesCont: {} 202 }; 203 204 // attached cont 205 var cellCont = this.cell.childNodes[this.conf.idx.cont]; 206 while (cellCont.childNodes.length > 0) { 207 this.views[name].cellCont.push(cellCont.firstChild); 208 cellCont.removeChild(cellCont.firstChild); 209 } 210 cellCont = null; 211 212 this.dataType = null; 213 this.dataObj = null; 214 this.conf.url_data = null; 215 216 // menu/toolbar/status 217 for (var a in this.dataNodes) { 218 219 for (var b in this.conf.ofs_nodes) { 220 if (typeof(this.conf.ofs_nodes[b][a]) != "undefined") { 221 this.views[name].ofs_nodes[b][a] = this.conf.ofs_nodes[b][a]; 222 this.conf.ofs_nodes[b][a] = null; 223 delete this.conf.ofs_nodes[b][a]; 224 } 225 } 226 227 this.views[name].dataNodesCont[a] = this.cell.childNodes[this.conf.idx[a]]; 228 this.cell.removeChild(this.cell.childNodes[this.conf.idx[a]]); 229 230 this.views[name].dataNodes[a] = this.dataNodes[a]; 231 this.dataNodes[a] = null; 232 delete this.dataNodes[a]; 233 234 this._updateIdx(); 235 } 236 237 this.callEvent("_onViewSave", [name]); 238 239 } 240 241 this._viewRestore = function(name) { 242 243 if (this.views[name] == null) return; 244 245 // content 246 this.dataObj = this.views[name].dataObj; 247 this.dataType = this.views[name].dataType; 248 this.conf.url_data = this.views[name].url_data; 249 for (var q=0; q<this.views[name].cellCont.length; q++) this.cell.childNodes[this.conf.idx.cont].appendChild(this.views[name].cellCont[q]); 250 251 // data nodes (menu/toolbar/status) 252 for (var a in this.views[name].dataNodes) { 253 254 this.dataNodes[a] = this.views[name].dataNodes[a]; 255 // below is not very universal solution for extending 256 if (a == "menu") this.cell.insertBefore(this.views[name].dataNodesCont[a], this.cell.childNodes[this.conf.idx.toolbar||this.conf.idx.cont]); 257 if (a == "toolbar") this.cell.insertBefore(this.views[name].dataNodesCont[a], this.cell.childNodes[this.conf.idx.cont]); 258 if (a == "ribbon") this.cell.insertBefore(this.views[name].dataNodesCont[a], this.cell.childNodes[this.conf.idx.cont]); 259 if (a == "sb") this.cell.appendChild(this.views[name].dataNodesCont[a]); 260 261 this._updateIdx(); 262 } 263
264 // ofs_nodes 265 for (var a in this.views[name].ofs_nodes) { 266 for (var b in this.views[name].ofs_nodes[a]) this.conf.ofs_nodes[a][b] = this.views[name].ofs_nodes[a][b]; 267 } 268 269 if (this.conf.borders != this.views[name].borders) { 270 this[this.views[name].borders?"_showBorders":"_hideBorders"](true); 271 } 272 273 // reload url attache dwith POST 274 if (this.dataType == "url" && this.conf.url_data != null && this.conf.url_data.ajax == false && this.conf.url_data.post_data != null) { 275 this.reloadURL(); 276 } 277 278 this.callEvent("_onViewRestore", [name]); 279 280 this._viewDelete(name); 281 282 } 283 284 this._viewDelete = function(name) { 285 286 if (this.views[name] == null) return; 287 288 this.views[name].borders = null; 289 290 for (var a in this.views[name].ofs_nodes) { 291 for (var b in this.views[name].ofs_nodes[a]) this.views[name].ofs_nodes[a][b] = null; 292 this.views[name].ofs_nodes[a] = null; 293 } 294 295 this.views[name].dataType = null; 296 this.views[name].dataObj = null; 297 this.views[name].url_data = null; 298 299 for (var q=0; q<this.views[name].cellCont.length; q++) this.views[name].cellCont[q] = null; 300 this.views[name].cellCont = null; 301 302 for (var a in this.views[name].dataNodes) { 303 this.views[name].dataNodes[a] = null; 304 this.views[name].dataNodesCont[a] = null; 305 } 306 307 this.views[name].dataNodes = this.views[name].dataNodesCont = null; 308 309 this.views[name] = null; 310 delete this.views[name]; 311 312 } 313 314 /* views end */ 315 316 window.dhx4._eventable(this); 317 this._updateIdx(); 318 319 return this; 320 321}; 322 323// views 324dhtmlXCellObject.prototype.showView = function(name) { 325 326 if (this.conf.view == name) return false; // alredy visible 327 328 // save current view 329 this._viewSave(this.conf.view); 330 331 // restore requested view if exists 332 this._viewRestore(name); 333 334 // update cell rendering 335 this._updateIdx(); 336 this._adjustCont(); 337 338 this.conf.view = name; 339 340 var t = (typeof(this.conf.views_loaded[this.conf.view]) == "undefined"); 341 this.conf.views_loaded[this.conf.view] = true; 342 343 return t; 344 345}; 346 347dhtmlXCellObject.prototype.getViewName = function() { 348 return this.conf.view; 349}; 350 351dhtmlXCellObject.prototype.unloadView = function(name) { 352 // hidden view, unload menu/toolbar/status, etc 353 354 // unload actve view 355 if (name == this.conf.view) { 356 357 // set unloading flag to prevent some adjust operations 358 var t = this.conf.unloading; 359 this.conf.unloading = true; 360 361 // remove content 362 if (typeof(this.detachMenu) == "function") this.detachMenu(); 363 if (typeof(this.detachToolbar) == "function") this.detachToolbar(); 364 if (typeof(this.detachRibbon) == "function") this.detachRibbon(); 365 this.detachStatusBar(); 366 this._detachObject(null, true); 367 368 // restore unloading flag 369 this.conf.unloading = t; 370 if (!this.conf.unloading) this._adjustCont(this._idd); 371 372 return; 373 } 374 375 if (this.views[name] == null) return; 376 377 var v = this.views[name]; 378 for (var a in v.dataNodes) { 379 if (typeof(v.dataNodes[a].unload) == "function") v.dataNodes[a].unload(); 380 v.dataNodes[a] = null; 381 v.dataNodesCont[a] = null; 382 } 383 if (v.dataType == "url") { 384 if (v.cellCont != null && v.cellCont[0] != "null") { 385 this._detachURLEvents(v.cellCont[0]); 386 } 387 } else if (v.dataObj != null) { 388 if (typeof(v.dataObj.unload) == "function") { 389 v.dataObj.unload(); 390 } else if (typeof(v.dataObj.destructor) == "function") { 391 v.dataObj.destructor(); 392 } 393 v.dataObj = null; 394 } 395 v = null; 396 397 this._viewDelete(name); 398 399 if (typeof(this.conf.views_loaded[name]) != "undefined") { 400 delete this.conf.views_loaded[name]; 401 } 402 403}; 404 405 406// id 407dhtmlXCellObject.prototype.getId = function() { 408 return this._idd; 409}; 410 411// progress 412dhtmlXCellObject.prototype.progressOn = function() { 413 414 if (this.conf.progress == true) return; 415 416 this.conf.progress = true; 417 418 // cover 419 var t1 = document.createElement("DIV"); 420 t1.className = this.conf.idx_data.pr1; 421 422 // image/animation 423 var t2 = document.createElement("DIV"); 424 if (this.conf.skin == "material" && (window.dhx4.isFF || window.dhx4.isChrome || window.dhx4.isOpera || window.dhx4.isEdge)) { 425 t2.className = this.conf.idx_data.pr3; 426 t2.innerHTML = '<svg class="dhx_cell_prsvg" viewBox="25 25 50 50"><circle class="dhx_cell_prcircle" cx="50" cy="50" r="20"/></svg>'; 427 } else { 428 t2.className = this.conf.idx_data.pr2; 429 } 430 431 if (this.conf.idx.cover != null) { 432 this.cell.insertBefore(t2, this.cell.childNodes[this.conf.idx.cover]); 433 } else {
434 this.cell.appendChild(t2); 435 } 436 this.cell.insertBefore(t1, t2); 437 438 t1 = t2 = null; 439 440 this._updateIdx(); 441 this._adjustProgress(); 442 443}; 444 445dhtmlXCellObject.prototype.progressOff = function() { 446 447 if (this.conf.progress != true) return; 448 449 for (var a in {pr3:3,pr2:2,pr1:1}) { 450 var node = this.cell.childNodes[this.conf.idx[a]]; 451 if (node != null) node.parentNode.removeChild(node); 452 node = null; 453 } 454 455 this.conf.progress = false; 456 457 this._updateIdx(); 458}; 459 460dhtmlXCellObject.prototype._adjustProgress = function() { 461 462 if (this.conf.idx.pr1 == null) return; 463 464 if (!this.conf.pr) this.conf.pr = {}; 465 466 var p1 = this.cell.childNodes[this.conf.idx.pr1]; // half-transparent cover 467 var p2 = this.cell.childNodes[this.conf.idx.pr2]||this.cell.childNodes[this.conf.idx.pr3]; // image/svg 468 469 if (!this.conf.pr.ofs) { 470 p2.style.width = p1.offsetWidth + "px"; 471 p2.style.height = p1.offsetHeight + "px"; 472 this.conf.pr.ofs = { 473 w: p2.offsetWidth-p2.clientWidth, 474 h: p2.offsetHeight-p2.clientHeight 475 }; 476 } 477 478 p2.style.width = p1.offsetWidth - this.conf.pr.ofs.w + "px"; 479 p2.style.height = p1.offsetHeight - this.conf.pr.ofs.h + "px"; 480 481 p1 = p2 = null; 482}; 483 484// content cover 485dhtmlXCellObject.prototype._showCellCover = function() { 486 487 if (this.conf.cover == true) return; 488 this.conf.cover = true; 489 490 var t = document.createElement("DIV"); 491 t.className = this.conf.idx_data.cover; 492 this.cell.appendChild(t); 493 t = null; 494 495 this._updateIdx(); 496}; 497 498dhtmlXCellObject.prototype._hideCellCover = function() { 499 500 if (this.conf.cover != true) return; 501 502 this.cell.removeChild(this.cell.childNodes[this.conf.idx.cover]); 503 this._updateIdx(); 504 505 this.conf.cover = false; 506 507}; 508 509// borders 510dhtmlXCellObject.prototype._showBorders = function(noAdjust) { 511 512 if (this.conf.borders) return; 513 514 this.conf.borders = true; 515 516 this.cell.childNodes[this.conf.idx.cont].className = "dhx_cell_cont"+this.conf.css; 517 518 this.conf.cells_cont = null; 519 this._mtbUpdBorder(); 520 521 this.callEvent("_onBorderChange",[true]); 522 523 if (noAdjust !== true) this._adjustCont(this._idd); 524 525}; 526 527dhtmlXCellObject.prototype._hideBorders = function(noAdjust) { 528 529 if (!this.conf.borders) return; 530 531 this.conf.borders = false; 532 533 this.cell.childNodes[this.conf.idx.cont].className = "dhx_cell_cont"+this.conf.css+" dhx_cell_cont_no_borders"; 534 this.conf.cells_cont = null; 535 this._mtbUpdBorder(); 536 537 this.callEvent("_onBorderChange",[false]); 538 539 if (noAdjust !== true) this._adjustCont(this._idd); 540 541}; 542 543// basic width/height 544dhtmlXCellObject.prototype._getWidth = function() { 545 return this.cell.offsetWidth; 546};
547 548dhtmlXCellObject.prototype._getHeight = function() { 549 return this.cell.offsetHeight; 550}; 551 552 553dhtmlXCellObject.prototype.showInnerScroll = function() { 554 this.cell.childNodes[this.conf.idx.cont].style.overflow = "auto"; 555}; 556 557/* unload */ 558dhtmlXCellObject.prototype._unload = function() { 559 560 this.conf.unloading = true; 561 562 this.callEvent("_onCellUnload",[]); 563 564 this.progressOff(); 565 566 // unload current view (remove attached content) 567 this.unloadView(this.conf.view); 568 569 this.dataNodes = null; 570 571 this.cell.parentNode.removeChild(this.cell); 572 this.cell = null; 573 574 window.dhx4._eventable(this, "clear"); 575 576 // views 577 for (var a in this.views) this.unloadView(a); 578 579 this.conf = null; 580 581 // others 582 for (var a in this) this[a] = null; // no mercy 583 584}; 585 586 587dhtmlXCellObject.prototype.attachObject = function(obj, adjust) { 588 589 // adjust - for windows only 590 if (window.dhx4.s2b(adjust) && !(typeof(window.dhtmlXWindowsCell) == "function" && this instanceof window.dhtmlXWindowsCell)) { 591 adjust = false; 592 } 593 594 if (typeof(obj) == "string") obj = document.getElementById(obj); 595 596 // already attached 597 if (obj.parentNode == this.cell.childNodes[this.conf.idx.cont]) { 598 obj = null; 599 return; 600 } 601 602 if (adjust) { 603 obj.style.display = ""; 604 var w = obj.offsetWidth; 605 var h = obj.offsetHeight; 606 } 607 608 this._attachObject(obj); 609 this.dataType = "obj"; 610 obj.style.display = ""; 611 obj = null; 612 613 if (adjust) this._adjustByCont(w,h); 614 615}; 616 617dhtmlXCellObject.prototype.appendObject = function(obj) { 618 619 if (typeof(obj) == "string") obj = document.getElementById(obj); 620 621 // already attached 622 if (obj.parentNode == this.cell.childNodes[this.conf.idx.cont]) { 623 obj = null; 624 return; 625 } 626 627 628 if (!this.conf.append_mode) { 629 this.cell.childNodes[this.conf.idx.cont].style.overflow = "auto"; 630 this.conf.append_mode = true; 631 } 632 633 this._attachObject(obj, null, null, true); 634 this.dataType = "obj"; 635 obj.style.display = ""; 636 obj = null; 637 638}; 639 640dhtmlXCellObject.prototype.detachObject = function(remove, moveTo) { 641 this._detachObject(null, remove, moveTo); 642}; 643 644dhtmlXCellObject.prototype.getAttachedStatusBar = function() { 645 return this.dataNodes.sb; 646}; 647dhtmlXCellObject.prototype.getAttachedObject = function() { 648 if (this.dataType == "obj" || this.dataType == "url" || this.dataType == "url-ajax") { 649 return this.cell.childNodes[this.conf.idx.cont].firstChild; 650 } else { 651 return this.dataObj; 652 } 653}; 654 655dhtmlXCellObject.prototype.attachURL = function(url, useAjax, postData) { 656 657 // prepare POST if any, postData should be true or {} otherwise GET 658 if (postData == true) postData = {}; 659 var postReq = (typeof(postData) != "undefined" && postData != false && postData != null); 660 661 if (this.conf.url_data == null) this.conf.url_data = {}; 662 this.conf.url_data.url = url; 663 this.conf.url_data.ajax = (useAjax == true); 664 this.conf.url_data.post_data = (postData==true?{}:(postData||null)); // true or object 665 666 if (this.conf.url_data.xml_doc != null) { 667 try {this.conf.url_data.xml_doc.xmlDoc.abort();}catch(e){}; 668 this.conf.url_data.xml_doc.xmlDoc = null; 669 this.conf.url_data.xml_doc = null; 670 } 671 672 if (useAjax == true) { 673 674 var t = this; 675 if (postReq) { 676 var params = ""; 677 for (var a in postData) params += "&"+encodeURIComponent(a)+"="+encodeURIComponent(postData[a]); 678 679 this.conf.url_data.xml_doc = dhx4.ajax.post(url, params, function(r){ 680 if (t.attachHTMLString != null && typeof(r.xmlDoc.responseText) == "string") { 681 t.attachHTMLString("<div style='position:relative;width:100%;height:100%;overflow:auto;'>"+r.xmlDoc.responseText+"</div>"); 682 if (typeof(t._doOnFrameContentLoaded) == "function") t._doOnFrameContentLoaded(); 683 t.dataType = "url-ajax"; 684 } 685 t = r = null; 686 }); 687 } else { 688 this.conf.url_data.xml_doc = dhx4.ajax.get(url, function(r){ 689 if (t.attachHTMLString != null && typeof(r.xmlDoc.responseText) == "string") { 690 t.attachHTMLString("<div style='position:relative;width:100%;height:100%;overflow:auto;'>"+r.xmlDoc.responseText+"</div>"); 691 if (typeof(t._doOnFrameContentLoaded) == "function") t._doOnFrameContentLoaded(); 692 t.dataType = "url-ajax"; 693 } 694 t = r = null; 695 }); 696 } 697 698 } else { 699 if (this.dataType == "url") { 700 var fr = this.getFrame(); 701 } else {
702 var fr = document.createElement("IFRAME"); 703 fr.frameBorder = 0; 704 fr.border = 0; 705 fr.style.width = "100%"; 706 fr.style.height = "100%"; 707 fr.style.position = "relative"; 708 this._attachObject(fr); 709 this.dataType = "url"; 710 this._attachURLEvents(); 711 } 712 if (postReq) { 713 var firstLoad = (typeof(this.conf.url_data.post_ifr) == "undefined"); 714 this.conf.url_data.post_ifr = true; // load later 715 if (firstLoad) this._attachURLEvents(); 716 fr.src = "about:blank"; 717 } else { 718 fr.src = url+window.dhx4.ajax._dhxr(url); 719 } 720 fr = null; 721 } 722 723 fr = null; 724}; 725 726dhtmlXCellObject.prototype.reloadURL = function() { 727 if (!(this.dataType == "url" || this.dataType == "url-ajax")) return; 728 if (this.conf.url_data == null) return; 729 this.attachURL(this.conf.url_data.url, this.conf.url_data.ajax, this.conf.url_data.post_data); 730}; 731 732dhtmlXCellObject.prototype.attachHTMLString = function(str) { 733 this._attachObject(null, null, str); 734 // esec script 735 var z = str.match(/<script[^>]*>[^\f]*?<\/script>/g)||[]; 736 for (var i=0; i<z.length; i++) { 737 var s = z[i].replace(/<([\/]{0,1})script[^>]*>/gi,""); 738 if (s) { 739 if (window.execScript) window.execScript(s); else window.eval(s); 740 } 741 } 742}; 743 744dhtmlXCellObject.prototype.attachScheduler = function(day, mode, cont_id, scheduler) { 745 746 scheduler = scheduler || window.scheduler; 747 748 var ready = false; 749 if (cont_id) { 750 var obj = document.getElementById(cont_id); 751 if (obj) ready = true; 752 } 753 if (!ready) { 754 var tabs = cont_id || '<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>'; 755 var obj = document.createElement("DIV"); 756 obj.id = "dhxSchedObj_"+new Date().getTime(); 757 obj.style.width = "100%"; 758 obj.style.height = "100%"; 759 obj.style.position = "relative"; 760 obj.style.overflow = "hidden"; 761 obj.className = "dhx_cal_container"; 762 obj.innerHTML = '<div class="dhx_cal_navline"><div class="dhx_cal_prev_button"> </div><div class="dhx_cal_next_button"> </div><div class="dhx_cal_today_button"></div><div class="dhx_cal_date"></div>'+tabs+'</div><div class="dhx_cal_header"></div><div class="dhx_cal_data"></div>'; 763 } 764 765 this._attachObject(obj); 766 767 this.dataType = "scheduler"; 768 this.dataObj = scheduler; 769 this.dataObj.setSizes = function(){ 770 this.update_view(); 771 } 772 773 scheduler.init(obj.id, day, mode); 774 775 obj = null; 776 777 this.callEvent("_onContentAttach",[]); 778 779 return this.dataObj; 780}; 781 782dhtmlXCellObject.prototype.attachMap = function(opts) { 783 784 var obj = document.createElement("DIV"); 785 obj.style.width = "100%"; 786 obj.style.height = "100%"; 787 obj.style.position = "relative"; 788 obj.style.overflow = "hidden"; 789 this._attachObject(obj); 790 791 if (!opts) opts = {center: new google.maps.LatLng(40.719837,-73.992348), zoom: 11, mapTypeId: google.maps.MapTypeId.ROADMAP}; 792 793 this.dataType = "maps"; 794 this.dataObj = new google.maps.Map(obj, opts); 795 796 this.dataObj.setSizes = function() { 797 google.maps.event.trigger(this, "resize"); 798 } 799 800 obj = null; 801 802 this.callEvent("_onContentAttach",[]); 803 804 return this.dataObj; 805 806}; 807 808// status bar 809dhtmlXCellObject.prototype._createNode_sb = function(obj, type, htmlString, append, node) { 810 // type -> (object) conf={text:string,height:number} 811 if (typeof(node) != "undefined") { 812 obj = node; 813 } else { 814 var conf = type||{}; 815 var text = (typeof(conf.text)=="string" && conf.text.length > 0 ? conf.text : " "); 816 var h = (typeof(conf.height) == "number" ? conf.height : false); 817 var obj = document.createElement("DIV"); 818 819 obj.className = "dhx_cell_statusbar_def"; 820 obj.innerHTML = "<div class='"+(conf.paging==true?"dhx_cell_statusbar_paging":"dhx_cell_statusbar_text")+"'>"+text+"</div>"; 821 822 // height, optional 823 if (h != false) obj.firstChild.style.height = obj.firstChild.style.lineHeight = h+"px"; 824 } 825 826 // before progress or last 827 if (this.conf.idx.pr1 != null) { 828 this.cell.insertBefore(obj, this.cell.childNodes[this.conf.idx.pr1]); 829 } else {
830 this.cell.appendChild(obj); 831 } 832 833 this.conf.ofs_nodes.b.sb = true; 834 this._updateIdx(); 835 this._adjustCont(this._idd); 836 837 return obj; 838}; 839 840dhtmlXCellObject.prototype.attachStatusBar = function(conf) { // args-optinal, new in version 841 842 if (this.dataNodes.sb) return; // return this.dataNodes.sb? 843 844 if (conf != null && window.dhx4.s2b(conf.paging) == true) conf.height = null; // will set by css 845 846 if (this.conf.skin == "dhx_skyblue" && typeof(window.dhtmlXWindowsCell) == "function" && this instanceof window.dhtmlXWindowsCell) { 847 this.cell.childNodes[this.conf.idx.cont].className += " dhx_cell_statusbar_attached"; 848 } 849 this.dataNodes.sb = this._attachObject("sb", conf); 850 851 this.dataNodes.sb.setText = function(text) { this.childNodes[0].innerHTML = text; } 852 this.dataNodes.sb.getText = function() { return this.childNodes[0].innerHTML; } 853 this.dataNodes.sb.onselectstart = function(e) { return false; } 854 855 return this.dataNodes.sb; 856 857}; 858 859dhtmlXCellObject.prototype.detachStatusBar = function() { 860 861 if (!this.dataNodes.sb) return; 862 863 if (this.conf.skin == "dhx_skyblue" && typeof(window.dhtmlXWindowsCell)== "function" && this instanceof window.dhtmlXWindowsCell) { 864 this.cell.childNodes[this.conf.idx.cont].className = this.cell.childNodes[this.conf.idx.cont].className.replace(/\s{0,}dhx_cell_statusbar_attached/,""); 865 } 866 867 this.dataNodes.sb.setText = this.dataNodes.sb.getText = this.dataNodes.sb.onselectstart = null; 868 this.dataNodes.sb = null; 869 delete this.dataNodes.sb; 870 871 this._detachObject("sb"); 872 873}; 874 875dhtmlXCellObject.prototype.showStatusBar = function() { 876 this._mtbShowHide("sb", ""); 877}; 878 879dhtmlXCellObject.prototype.hideStatusBar = function() { 880 this._mtbShowHide("sb", "none"); 881}; 882 883dhtmlXCellObject.prototype._mtbShowHide = function(name, disp) { 884 if (!this.dataNodes[name]) return; 885 this.cell.childNodes[this.conf.idx[name]].style.display = disp; 886 this._adjustCont(); 887}; 888 889 890/* private logic */ 891 892// !!! fix 893dhtmlXCellObject.prototype.getFrame = dhtmlXCellObject.prototype._getFrame = function() { // _getFrame deprecated, use getFrame 894 if (this.dataType != "url") return null; 895 return this.cell.childNodes[this.conf.idx.cont].firstChild; 896}; 897 898dhtmlXCellObject.prototype._attachURLEvents = function() { 899 900 if (this.dataType != "url") return; 901 902 var t = this; 903 var cId = this._idd; 904 var fr = this.cell.childNodes[this.conf.idx.cont].firstChild; 905 906 if (typeof(this._doOnFrameMouseDown) != "function") { 907 this._doOnFrameMouseDown = function(e) { 908 // console.log("frame mouse down"); // needed for windows to activate window 909 t.callEvent("_onContentMouseDown", [cId,e||event]); 910 } 911 } 912 913 if (typeof(window.addEventListener) == "function") { 914 fr.onload = function() { 915 try { if (typeof(t._doOnFrameMouseDown) == "function") this.contentWindow.document.body.addEventListener("mousedown", t._doOnFrameMouseDown, false); } catch(e) {}; 916 try { if (typeof(t._doOnFrameContentLoaded) == "function") t._doOnFrameContentLoaded(); } catch(e) {}; 917 } 918 } else { 919 // ie8- 920 fr.onreadystatechange = function(a) { 921 if (this.readyState == "complete") { 922 try { if (typeof(t._doOnFrameMouseDown) == "function") this.contentWindow.document.body.attachEvent("onmousedown", t._doOnFrameMouseDown); } catch(e) {}; 923 try { if (typeof(t._doOnFrameContentLoaded) == "function") t._doOnFrameContentLoaded(); } catch(e) {}; 924 } 925 } 926 } 927 //fr = null; 928}; 929 930 931dhtmlXCellObject.prototype._doOnFrameContentLoaded = function() { 932 if (this.conf.url_data.post_ifr == true) { 933 var d = this.getFrame().contentWindow.document; 934 var f = d.createElement("FORM"); 935 f.method = "POST"; 936 f.action = this.conf.url_data.url; 937 d.body.appendChild(f); 938 var postData = {}; 939 if (window.dhx4.ajax.cache != true) postData["dhxr"+new Date().getTime()] = "1"; 940 for (var a in this.conf.url_data.post_data) postData[a] = this.conf.url_data.post_data[a]; 941 for (var a in postData) { 942 var k = d.createElement("INPUT"); 943 k.type = "hidden"; 944 k.name = a; 945 k.value = postData[a]; 946 f.appendChild(k); 947 k = null; 948 } 949 this.conf.url_data.post_ifr = false; 950 f.submit(); 951 } else { 952 this.callEvent("_onContentLoaded", [this._idd]); 953 } 954}; 955 956dhtmlXCellObject.prototype._detachURLEvents = function(fr) { 957 if (fr == null) { 958 if (this.dataType != "url") return; 959 fr = this.cell.childNodes[this.conf.idx.cont].firstChild; 960 } 961 if (!fr) return; 962 963 if (typeof(window.addEventListener) == "function") { 964 fr.onload = null; 965 try { fr.contentWindow.document.body.removeEventListener("mousedown", this._doOnFrameMouseDown, false); } catch(e) {/* console.log("error: url detach mousedown event fail"); */}; 966 } else { 967 fr.onreadystatechange = null; 968 try { fr.contentWindow.document.body.detachEvent("onmousedown", this._doOnFrameMouseDown); } catch(e) { }; 969 } 970 fr = null; 971}; 972 973 974 975 976dhtmlXCellObject.prototype._attachObject = function(obj, type, htmlString, append, node) { 977 978 if (typeof(obj) == "string" && {menu:1,toolbar:1,ribbon:1,sb:1}[obj] == 1) { 979 return this["_createNode_"+obj].apply(this, arguments); 980 } 981 982 if (append != true) this._detachObject(null, true, null); 983 984 if (typeof(htmlString) == "string") { 985 this.cell.childNodes[this.conf.idx.cont].innerHTML = htmlString; 986 } else { 987 this.cell.childNodes[this.conf.idx.cont].appendChild(obj); 988 } 989 990 obj = null; 991}; 992 993dhtmlXCellObject.prototype._detachObject = function(obj, remove, moveTo) { 994 995 this.callEvent("_onBeforeContentDetach",[]); 996 997 if (obj == "menu" || obj == "toolbar" || obj == "ribbon" || obj == "sb") { 998 999 var p = this.cell.childNodes[this.conf.idx[obj]]; 1000 p.parentNode.removeChild(p); 1001 p = null; 1002 1003 this.conf.ofs_nodes[obj=="sb"?"b":"t"][obj] = false; 1004 1005 this._updateIdx(); 1006 if (!this.conf.unloading) this._adjustCont(this._idd); 1007 1008 return; 1009 } 1010 1011 if (remove == true) { 1012 moveTo = false; 1013 } else { 1014 if (typeof(moveTo) == "undefined") { 1015 moveTo = document.body; 1016 } else { 1017 if (typeof(moveTo) == "string") moveTo = document.getElementById(moveTo); 1018 } 1019 } 1020 1021 // clear obj 1022 if (moveTo === false) { 1023 // cancel ajax-request if unloading 1024 if (this.conf.unloading == true && String(this.dataType).match(/ajax/) != null) { 1025 if (this.conf.url_data != null && this.conf.url_data.xml_doc != null) { 1026 try {this.conf.url_data.xml_doc.xmlDoc.abort();}catch(e){}; 1027 this.conf.url_data.xml_doc.xmlDoc = null; 1028 this.conf.url_data.xml_doc = null; 1029 } 1030 } 1031 // 1032 if (this.dataType == "url") { 1033 this._detachURLEvents(); 1034 } else if (this.dataObj != null) { 1035 if (typeof(this.dataObj.unload) == "function") { 1036 this.dataObj.unload(); 1037 } else if (typeof(this.dataObj.destructor) == "function") { 1038 this.dataObj.destructor(); // at least for grid 1039 } 1040 } 1041 } 1042 1043 // clear cell cont 1044 var p = this.cell.childNodes[this.conf.idx.cont]; 1045 while (p.childNodes.length > 0) { 1046 if (moveTo === false) { 1047 p.removeChild(p.lastChild); 1048 } else { 1049 p.firstChild.style.display = "none"; // replace with/add - visibility:hidden? 1050 moveTo.appendChild(p.firstChild); 1051 } 1052 } 1053 1054 if (this.conf.append_mode) { 1055 p.style.overflow = ""; 1056 this.conf.append_mode = false; 1057 } 1058 1059 var resetHdrBrd = (this.dataType == "tabbar"); 1060 1061 this.dataObj = null; 1062 this.dataType = null; 1063 1064 moveTo = p = null; 1065 1066 if (this.conf.unloading != true && resetHdrBrd) { 1067 this.showHeader(true); 1068 this._showBorders(); 1069 } 1070 1071}; 1072 1073// for dock/undock 1074dhtmlXCellObject.prototype._attachFromCell = function(cell) { 1075 1076 // clear existing 1077 this.detachObject(true); 1078 1079 var mode = "layout"; 1080 if (typeof(window.dhtmlXWindowsCell) == "function" && this instanceof window.dhtmlXWindowsCell) { 1081 mode = "window"; 1082 } 1083 1084 // check opacity: 1085 // 1) detach from window cell, opacity set to 0.4 1086 if (typeof(window.dhtmlXWindowsCell) == "function" && cell instanceof window.dhtmlXWindowsCell && cell.wins.w[cell._idd].conf.parked == true) { 1087 cell.wins._winCellSetOpacity(cell._idd, "open", false); 1088 } 1089 // 2) acc-cell collapsed 1090 if (typeof(window.dhtmlXAccordionCell) == "function" && cell instanceof window.dhtmlXAccordionCell && cell.conf.opened == false) { 1091 cell._cellSetOpacity("open", false); 1092 } 1093 1094 // menu, toolbar, status
1095 for (var a in cell.dataNodes) { 1096 1097 this._attachObject(a, null, null, null, cell.cell.childNodes[cell.conf.idx[a]]); 1098 this.dataNodes[a] = cell.dataNodes[a]; 1099 1100 cell.dataNodes[a] = null; 1101 cell.conf.ofs_nodes[a=="sb"?"b":"t"][a] = false; 1102 cell._updateIdx(); 1103 1104 } 1105 1106 this._mtbUpdBorder(); 1107 1108 if (cell.dataType != null && cell.dataObj != null) { 1109 this.dataType = cell.dataType; 1110 this.dataObj = cell.dataObj; 1111 while (cell.cell.childNodes[cell.conf.idx.cont].childNodes.length > 0) { 1112 this.cell.childNodes[this.conf.idx.cont].appendChild(cell.cell.childNodes[cell.conf.idx.cont].firstChild); 1113 } 1114 cell.dataType = null; 1115 cell.dataObj = null; 1116 1117 // fixes 1118 if (this.dataType == "grid") { 1119 if (mode == "window" && this.conf.skin == "dhx_skyblue") { 1120 this.dataObj.entBox.style.border = "1px solid #a4bed4"; 1121 this.dataObj._sizeFix = 0; 1122 } else { 1123 this.dataObj.entBox.style.border = "0px solid white"; 1124 this.dataObj._sizeFix = 2; 1125 } 1126 } 1127 } else { 1128 // for attached urls and objects simple move them 1129 while (cell.cell.childNodes[cell.conf.idx.cont].childNodes.length > 0) { 1130 this.cell.childNodes[this.conf.idx.cont].appendChild(cell.cell.childNodes[cell.conf.idx.cont].firstChild); 1131 } 1132 } 1133 1134 this.conf.view = cell.conf.view; 1135 cell.conf.view = "def"; 1136 for (var a in cell.views) { 1137 this.views[a] = cell.views[a]; 1138 cell.views[a] = null; 1139 delete cell.views[a]; 1140 } 1141 1142 cell._updateIdx(); 1143 cell._adjustCont(); 1144 1145 this._updateIdx(); 1146 this._adjustCont(); 1147 1148 // save progress state 1149 if (cell.conf.progress == true) { 1150 cell.progressOff(); 1151 this.progressOn(); 1152 } else { 1153 this.progressOff(); 1154 } 1155 1156 // check opacity, set opacity to 0.4 1157 // 1) attach to window cell, window parked 1158 if (mode == "window" && this.wins.w[this._idd].conf.parked) { 1159 this.wins._winCellSetOpacity(this._idd, "close", false); 1160 } 1161 1162}; 1163 1164/* 1165 1166 +--------------------------------------------------------+ 1167 | base | 1168 | | 1169 | +-----------------------------------------------+ | 1170 | | header | | 1171 | +-----------------------------------------------+ | 1172 | | 1173 | +-----------------------------------------------+ | 1174 | | mtb | | 1175 | +-----------------------------------------------+ | 1176 | | 1177 | +-----------------------------------------------+ | 1178 | | cont | | 1179 | | | | 1180 | | | | 1181 | +-----------------------------------------------+ | 1182 | | 1183 | +-----------------------------------------------+ | 1184 | | sb | | 1185 | +-----------------------------------------------+ | 1186 | | 1187 | +-----------------------------------------------+ | 1188 | | footer | | 1189 | +-----------------------------------------------+ | 1190 | | 1191 +--------------------------------------------------------+ 1192 1193*/ 1194 1195function dhtmlXCellTop(base, offsets) { 1196 1197 if (arguments.length == 0 || typeof(base) == "undefined") return; 1198 1199 var that = this; 1200 1201 this.dataNodes = {}; // menu/toolbar/ribbon/sb/hdr/ftr 1202 1203 this.conf.ofs = {t:0, b:0, l:0, r:0}; // base outer offset (fullscreen margins) 1204 this.conf.ofs_nodes = {t:{}, b:{}}; // attached menu/toolbar/sb/hdr/ftr 1205 this.conf.progress = false; 1206 1207 this.conf.fs_mode = false; // fullscreen mode 1208 this.conf.fs_tm = null; // fullscreen resize timeout 1209 this.conf.fs_resize = false; // fullscreen resize 1210 1211 if (base == document.body) { 1212 1213 this.conf.fs_mode = true; 1214 1215 // fullscreen init 1216 this.base = base; 1217 1218 // custom offset for body 1219 if (this.base == document.body) { 1220 var ofsDef = { 1221 dhx_skyblue: {t: 2, b: 2, l: 2, r: 2}, 1222 dhx_web: {t: 8, b: 8, l: 8, r: 8}, 1223 dhx_terrace: {t: 9, b: 9, l: 8, r: 8}, 1224 material: {t: 9, b: 9, l: 8, r: 8} 1225 }; 1226 this.conf.ofs = (ofsDef[this.conf.skin] != null ? ofsDef[this.conf.skin] : ofsDef.dhx_skyblue); 1227 } 1228 1229 } else { 1230 this.base = (typeof(base)=="string"?document.getElementById(base):base); 1231 } 1232 1233 this.base.className += " "+this.conf.css+"_base_"+this.conf.skin; 1234 1235 this.cont = document.createElement("DIV"); 1236 this.cont.className = this.conf.css+"_cont"; 1237 this.base.appendChild(this.cont); 1238 1239 // conf-offsets override (attachObject usualy) 1240 if (offsets != null) { 1241 this.setOffsets(offsets, false); 1242 } else if (this.base._ofs != null) { 1243 this.setOffsets(this.base._ofs, false); 1244 this.base._ofs = null; 1245 try {delete this.base._ofs;}catch(e){}; // IE6/IE7 fix 1246 } 1247 1248 this._adjustCont = function() { 1249 1250 var ofsYT = this.conf.ofs.t; 1251 for (var a in this.conf.ofs_nodes.t) ofsYT += (this.conf.ofs_nodes.t[a]==true ? this.dataNodes[a].offsetHeight:0); 1252 1253 var ofsYB = this.conf.ofs.b; 1254 for (var a in this.conf.ofs_nodes.b) ofsYB += (this.conf.ofs_nodes.b[a]==true ? this.dataNodes[a].offsetHeight:0); 1255 1256 this.cont.style.left = this.conf.ofs.l + "px"; 1257 this.cont.style.width = this.base.clientWidth - this.conf.ofs.l - this.conf.ofs.r + "px"; 1258 1259 this.cont.style.top = ofsYT + "px"; 1260 this.cont.style.height = this.base.clientHeight - ofsYT - ofsYB + "px"; 1261 1262 } 1263 1264 this._setBaseSkin = function(skin) { 1265 this.base.className = this.base.className.replace(new RegExp(this.conf.css+"_base_"+this.conf.skin,"gi"), this.conf.css+"_base_"+skin); 1266 } 1267 1268 this._initFSResize = function() { 1269 1270 if (this.conf.fs_resize == true) return; // already inited 1271 1272 this._doOnResizeStart = function() { 1273 window.clearTimeout(that.conf.fs_tm); 1274 that.conf.fs_tm = window.setTimeout(that._doOnResizeEnd, 200); 1275 } 1276 1277 this._doOnResizeEnd = function() { 1278 that.setSizes(); 1279 } 1280 1281 if (typeof(window.addEventListener) == "function") { 1282 window.addEventListener("resize", this._doOnResizeStart, false); 1283 } else { 1284 window.attachEvent("onresize", this._doOnResizeStart); 1285 } 1286 1287 this.conf.fs_resize = true; 1288 } 1289 1290 // resize events 1291 if (this.conf.fs_mode == true) this._initFSResize(); 1292 1293 this._unloadTop = function() { 1294 1295 this._mtbUnload(); 1296 this.detachHeader(); 1297 this.detachFooter(); 1298 1299 if (this.conf.fs_mode == true) { 1300 if (typeof(window.addEventListener) == "function") { 1301 window.removeEventListener("resize", this._doOnResizeStart, false); 1302 } else { 1303 window.detachEvent("onresize", this._doOnResizeStart); 1304 } 1305 } 1306 1307 this.base.removeChild(this.cont); 1308 var r = new RegExp("\s{0,}"+this.conf.css+"_base_"+this.conf.skin, "gi"); 1309 this.base.className = this.base.className.replace(r, ""); 1310 this.cont = this.base = null; 1311 1312 that = null; 1313 } 1314 1315 base = null; 1316}; 1317 1318// outer offsets 1319dhtmlXCellTop.prototype.setOffsets = function(data, upd) { // set 'upd' to false to prevent adju
1319sting (useful on init stage) 1320 var t = false; 1321 for (var a in data) { 1322 var k = a.charAt(0); 1323 if (typeof(this.conf.ofs[k]) != "undefined" && !isNaN(data[a])) { 1324 this.conf.ofs[k] = parseInt(data[a]); 1325 t = true; 1326 } 1327 } 1328 if (upd !== false && typeof(this.setSizes) == "function" && t == true) this.setSizes(); 1329}; 1330 1331 1332// top-level menu/toolbar/ribbon/status 1333 1334// menu 1335dhtmlXCellTop.prototype.attachMenu = function(conf) { 1336 1337 if (this.dataNodes.menu != null) return; 1338 1339 this.dataNodes.menuObj = document.createElement("DIV"); 1340 this.dataNodes.menuObj.className = "dhxcelltop_menu"; 1341 1342 this.base.insertBefore(this.dataNodes.menuObj, this.dataNodes.toolbarObj||this.dataNodes.ribbonObj||this.cont); 1343 1344 if (typeof(conf) != "object" || conf == null) conf = {}; 1345 conf.skin = this.conf.skin; 1346 conf.parent = this.dataNodes.menuObj; 1347 1348 this.dataNodes.menu = new dhtmlXMenuObject(conf); 1349 1350 this.dataNodes.menuEv = this.attachEvent("_onSetSizes", function(){ 1351 if (this.dataNodes.menuObj.style.display == "none") return; 1352 if (this.conf.ofs_menu == null) { 1353 this.dataNodes.menuObj.style.width = this.base.offsetWidth-this.conf.ofs.l-this.conf.ofs.r+"px"; 1354 this.conf.ofs_menu = {w: this.dataNodes.menuObj.offsetWidth-parseInt(this.dataNodes.menuObj.style.width)}; 1355 } 1356 this.dataNodes.menuObj.style.left = this.conf.ofs.l+"px"; 1357 this.dataNodes.menuObj.style.marginTop = (this.dataNodes.haObj!=null?0:this.conf.ofs.t)+"px"; 1358 this.dataNodes.menuObj.style.width = this.base.offsetWidth-this.conf.ofs.l-this.conf.ofs.r-this.conf.ofs_menu.w+"px"; 1359 1360 }); 1361 1362 this.conf.ofs_nodes.t.menuObj = true; 1363 1364 this.setSizes(); 1365 1366 conf.parnt = null; 1367 conf = null; 1368 1369 return this.dataNodes.menu; 1370}; 1371 1372dhtmlXCellTop.prototype.detachMenu = function() { 1373 1374 if (this.dataNodes.menu == null) return; 1375 1376 this.dataNodes.menu.unload(); 1377 this.dataNodes.menu = null; 1378 1379 this.dataNodes.menuObj.parentNode.removeChild(this.dataNodes.menuObj); 1380 this.dataNodes.menuObj = null; 1381 1382 this.detachEvent(this.dataNodes.menuEv); 1383 this.dataNodes.menuEv = null; 1384 1385 delete this.dataNodes.menu; 1386 delete this.dataNodes.menuObj; 1387 delete this.dataNodes.menuEv; 1388 1389 this.conf.ofs_nodes.t.menuObj = false; 1390 1391 if (!this.conf.unloading) this.setSizes(); 1392}; 1393 1394// toolbar 1395dhtmlXCellTop.prototype.attachToolbar = function(conf) { 1396 1397 if (!(this.dataNodes.ribbon == null && this.dataNodes.toolbar == null)) return; 1398 1399 this.dataNodes.toolbarObj = document.createElement("DIV"); 1400 this.dataNodes.toolbarObj.className = "dhxcelltop_toolbar"; 1401 this.base.insertBefore(this.dataNodes.toolbarObj, this.cont); 1402 this.dataNodes.toolbarObj.appendChild(document.createElement("DIV")); 1403 1404 if (typeof(conf) != "object" || conf == null) conf = {}; 1405 conf.skin = this.conf.skin; 1406 conf.parent = this.dataNodes.toolbarObj.firstChild; 1407 1408 this.dataNodes.toolbar = new dhtmlXToolbarObject(conf); 1409 1410 this.dataNodes.toolbarEv = this.attachEvent("_onSetSizes", function() { 1411 if (this.dataNodes.toolbarObj.style.display == "none") return; 1412 this.dataNodes.toolbarObj.style.left = this.conf.ofs.l+"px"; 1413 this.dataNodes.toolbarObj.style.marginTop = (this.dataNodes.haObj!=null||this.dataNodes.menuObj!=null?0:this.conf.ofs.t)+"px"; 1414 this.dataNodes.toolbarObj.style.width = this.base.offsetWidth-this.conf.ofs.l-this.conf.ofs.r+"px"; 1415 }); 1416 1417 this.dataNodes.toolbar._masterCell = this; 1418 this.dataNodes.toolbar.attachEvent("_onIconSizeChange", function(){ 1419 this._masterCell.setSizes(); 1420 }); 1421 1422 this.conf.ofs_nodes.t.toolbarObj = true; 1423 1424 this.setSizes(); 1425 1426 conf.parnt = null; 1427 conf = null; 1428 1429 return this.dataNodes.toolbar; 1430}; 1431 1432dhtmlXCellTop.prototype.detachToolbar = function() { 1433 1434 if (this.dataNodes.toolbar == null) return; 1435 1436 this.dataNodes.toolbar._masterCell = null; // link to this 1437 this.dataNodes.toolbar.unload(); 1438 this.dataNodes.toolbar = null; 1439 1440 this.dataNodes.toolbarObj.parentNode.removeChild(this.dataNodes.toolbarObj); 1441 this.dataNodes.toolbarObj = null; 1442 1443 this.detachEvent(this.dataNodes.toolbarEv); 1444 this.dataNodes.toolbarEv = null; 1445 1446 this.conf.ofs_nodes.t.toolbarObj = false; 1447 1448 delete this.dataNodes.toolbar; 1449 delete this.dataNodes.toolbarObj; 1450 delete this.dataNodes.toolbarEv; 1451 1452 if (!this.conf.unloading) this.setSizes(); 1453}; 1454 1455// ribbon 1456dhtmlXCellTop.prototype.attachRibbon = function(conf) { 1457 1458 if (!(this.dataNodes.ribbon == null && this.dataNodes.toolbar == null)) return; 1459 1460 this.dataNodes.ribbonObj = document.createElement("DIV"); 1461 this.dataNodes.ribbonObj.className = "dhxcelltop_ribbon"; 1462 this.base.insertBefore(this.dataNodes.ribbonObj, this.cont); 1463 this.dataNodes.ribbonObj.appendChild(document.createElement("DIV")); 1464 1465 if (typeof(conf) != "object" || conf == null) conf = {}; 1466 conf.skin = this.conf.skin; 1467 conf.parent = this.dataNodes.ribbonObj.firstChild; 1468 1469 this.dataNodes.ribbon = new dhtmlXRibbon(conf); 1470 1471 this.dataNodes.ribbonEv = this.attachEvent("_onSetSizes", function() { 1472 if (this.dataNodes.ribbonObj.style.display == "none") return; 1473 this.dataNodes.ribbonObj.style.left = this.conf.ofs.l+"px"; 1474 this.dataNodes.ribbonObj.style.marginTop = (this.dataNodes.haObj!=null||this.dataNodes.menuObj!=null?0:this.conf.ofs.t)+"px"; 1475 this.dataNodes.ribbonObj.style.width = this.base.offsetWidth-this.conf.ofs.l-this.conf.ofs.r+"px"; 1476 this.dataNodes.ribbon.setSizes(); 1477 }); 1478 1479 this.conf.ofs_nodes.t.ribbonObj = true; 1480 1481 var t = this; 1482 this.dataNodes.ribbon.attachEvent("_onHeightChanged", function(){ 1483 t.setSizes(); 1484 }); 1485 1486 this.setSizes(); 1487 1488 conf.parnt = null; 1489 conf = null; 1490 1491 return this.dataNodes.ribbon; 1492};
1493 1494dhtmlXCellTop.prototype.detachRibbon = function() { 1495 1496 if (this.dataNodes.ribbon == null) return; 1497 1498 this.dataNodes.ribbon.unload(); 1499 this.dataNodes.ribbon = null; 1500 1501 this.dataNodes.ribbonObj.parentNode.removeChild(this.dataNodes.ribbonObj); 1502 this.dataNodes.ribbonObj = null; 1503 1504 this.detachEvent(this.dataNodes.ribbonEv); 1505 this.dataNodes.ribbonEv = null; 1506 1507 this.conf.ofs_nodes.t.ribbonObj = false; 1508 1509 delete this.dataNodes.ribbon; 1510 delete this.dataNodes.ribbonObj; 1511 delete this.dataNodes.ribbonEv; 1512 1513 if (!this.conf.unloading) this.setSizes(); 1514}; 1515 1516 1517// status 1518dhtmlXCellTop.prototype.attachStatusBar = function(conf) { // arg-optional, new in version 1519 1520 if (this.dataNodes.sbObj) return; 1521 1522 if (typeof(conf) == "undefined") conf = {}; 1523 1524 this.dataNodes.sbObj = document.createElement("DIV"); 1525 this.dataNodes.sbObj.className = "dhxcelltop_statusbar"; 1526 1527 if (this.cont.nextSibling != null) { 1528 this.base.insertBefore(this.dataNodes.sbObj, this.cont.nextSibling); 1529 } else { 1530 this.base.appendChild(this.dataNodes.sbObj); 1531 } 1532 1533 this.dataNodes.sbObj.innerHTML = "<div class='dhxcont_statusbar'>"+(typeof(conf.text)=="string" && conf.text.length > 0 ? conf.text:" ")+"</div>"; 1534 if (typeof(conf.height) == "number") this.dataNodes.sbObj.firstChild.style.height = this.dataNodes.sbObj.firstChild.style.lineHeight = conf.height+"px"; 1535 1536 this.dataNodes.sbObj.setText = function(text) { this.childNodes[0].innerHTML = text; } 1537 this.dataNodes.sbObj.getText = function() { return this.childNodes[0].innerHTML; } 1538 this.dataNodes.sbObj.onselectstart = function(e) { return false; } 1539 1540 1541 this.dataNodes.sbEv = this.attachEvent("_onSetSizes", function(){ 1542 if (this.dataNodes.sbObj.style.display == "none") return; 1543 this.dataNodes.sbObj.style.left = this.conf.ofs.l+"px"; 1544 this.dataNodes.sbObj.style.bottom = (this.dataNodes.faObj != null?this.dataNodes.faObj.offsetHeight:0)+this.conf.ofs.t+"px"; 1545 this.dataNodes.sbObj.style.width = this.base.offsetWidth-this.conf.ofs.l-this.conf.ofs.r+"px"; 1546 }); 1547 1548 this.conf.ofs_nodes.b.sbObj = true; 1549 1550 this.setSizes(); 1551 1552 return this.dataNodes.sbObj; 1553 1554}; 1555 1556dhtmlXCellTop.prototype.detachStatusBar = function() { 1557 1558 if (!this.dataNodes.sbObj) return; 1559 1560 this.dataNodes.sbObj.setText = this.dataNodes.sbObj.getText = this.dataNodes.sbObj.onselectstart = null; 1561 this.dataNodes.sbObj.parentNode.removeChild(this.dataNodes.sbObj); 1562 this.dataNodes.sbObj = null; 1563 1564 this.detachEvent(this.dataNodes.sbEv); 1565 this.dataNodes.sbEv = null; 1566 1567 this.conf.ofs_nodes.b.sbObj = false; 1568 1569 delete this.dataNodes.sb; 1570 delete this.dataNodes.sbObj; 1571 delete this.dataNodes.sbEv; 1572 1573 if (!this.conf.unloading) this.setSizes(); 1574 1575}; 1576 1577// show/hide 1578dhtmlXCellTop.prototype.showMenu = function() { 1579 this._mtbShowHide("menuObj", ""); 1580}; 1581 1582dhtmlXCellTop.prototype.hideMenu = function() { 1583 this._mtbShowHide("menuObj", "none"); 1584}; 1585 1586dhtmlXCellTop.prototype.showToolbar = function(){ 1587 this._mtbShowHide("toolbarObj", ""); 1588}; 1589 1590dhtmlXCellTop.prototype.hideToolbar = function(){ 1591 this._mtbShowHide("toolbarObj", "none"); 1592}; 1593 1594dhtmlXCellTop.prototype.showRibbon = function(){ 1595 this._mtbShowHide("ribbonObj", ""); 1596}; 1597 1598dhtmlXCellTop.prototype.hideRibbon = function(){ 1599 this._mtbShowHide("ribbonObj", "none"); 1600}; 1601 1602dhtmlXCellTop.prototype.showStatusBar = function() { 1603 this._mtbShowHide("sbObj", ""); 1604}; 1605 1606dhtmlXCellTop.prototype.hideStatusBar = function(){ 1607 this._mtbShowHide("sbObj", "none"); 1608}; 1609 1610dhtmlXCellTop.prototype._mtbShowHide = function(name, disp) { 1611 if (this.dataNodes[name] == null) return; 1612 this.dataNodes[name].style.display = disp; 1613 this.setSizes(); 1614}; 1615 1616dhtmlXCellTop.prototype._mtbUnload = function(name, disp) { 1617 this.detachMenu(); 1618 this.detachToolbar(); 1619 this.detachStatusBar(); 1620 this.detachRibbon(); 1621}; 1622 1623// getters 1624dhtmlXCellTop.prototype.getAttachedMenu = function() { 1625 return this.dataNodes.menu; 1626}; 1627dhtmlXCellTop.prototype.getAttachedToolbar = function() { 1628 return this.dataNodes.toolbar; 1629}; 1630dhtmlXCellTop.prototype.getAttachedRibbon = function() { 1631 return this.dataNodes.ribbon; 1632};
1633dhtmlXCellTop.prototype.getAttachedStatusBar = function() { 1634 return this.dataNodes.sbObj; 1635}; 1636 1637// top-level progress 1638dhtmlXCellTop.prototype.progressOn = function() { 1639 1640 if (this.conf.progress) return; 1641 1642 this.conf.progress = true; 1643 1644 var t1 = document.createElement("DIV"); 1645 t1.className = "dhxcelltop_progress"; 1646 this.base.appendChild(t1); 1647 1648 var t2 = document.createElement("DIV"); 1649 if (this.conf.skin == "material" && (window.dhx4.isFF || window.dhx4.isChrome || window.dhx4.isOpera || window.dhx4.isEdge)) { 1650 t2.className = "dhxcelltop_progress_svg"; 1651 t2.innerHTML = '<svg class="dhx_cell_prsvg" viewBox="25 25 50 50"><circle class="dhx_cell_prcircle" cx="50" cy="50" r="20"/></svg>'; 1652 } else { 1653 var t2 = document.createElement("DIV"); 1654 t2.className = "dhxcelltop_progress_img"; 1655 } 1656 this.base.appendChild(t2); 1657 1658 t1 = t2 = null; 1659 1660}; 1661 1662dhtmlXCellTop.prototype.progressOff = function() { 1663 1664 if (!this.conf.progress) return; 1665 1666 var p = {dhxcelltop_progress: true, dhxcelltop_progress_img: true, dhxcelltop_progress_svg: true}; 1667 for (var q=0; q<this.base.childNodes.length; q++) { 1668 if (typeof(this.base.childNodes[q].className) != "undefined" && p[this.base.childNodes[q].className] == true) { 1669 p[this.base.childNodes[q].className] = this.base.childNodes[q]; 1670 } 1671 } 1672 1673 for (var a in p) { 1674 if (p[a] != true) this.base.removeChild(p[a]); 1675 p[a] = null; 1676 } 1677 1678 this.conf.progress = false; 1679 p = null; 1680 1681}; 1682 1683// fullscreen header-footer 1684 1685// top margin (2px for skyblue) for fullscreen will always adjusted automatcaly 1686// bottom margin - can be generated by user-content, write in documentstion 1687// same for footer 1688 1689dhtmlXCellTop.prototype.attachHeader = function(obj, height) { 1690 1691 if (this.dataNodes.haObj != null) return; // already attached 1692 1693 if (typeof(obj) != "object") obj = document.getElementById(obj); 1694 1695 this.dataNodes.haObj = document.createElement("DIV"); 1696 this.dataNodes.haObj.className = "dhxcelltop_hdr"; 1697 this.dataNodes.haObj.style.height = (height||obj.offsetHeight)+"px"; 1698 1699 this.base.insertBefore(this.dataNodes.haObj, this.dataNodes.menuObj||this.dataNodes.toolbarObj||this.cont); 1700 1701 this.dataNodes.haObj.appendChild(obj); 1702 obj.style.visibility = "visible"; 1703 obj = null; 1704 1705 this.dataNodes.haEv = this.attachEvent("_onSetSizes", function(){ 1706 this.dataNodes.haObj.style.left = this.conf.ofs.l+"px"; 1707 this.dataNodes.haObj.style.marginTop = this.conf.ofs.t+"px"; 1708 this.dataNodes.haObj.style.width = this.base.offsetWidth-this.conf.ofs.l-this.conf.ofs.r+"px"; 1709 }); 1710 1711 this.conf.ofs_nodes.t.haObj = true; 1712 1713 this.setSizes(); 1714 1715}; 1716 1717dhtmlXCellTop.prototype.detachHeader = function() { 1718 1719 if (!this.dataNodes.haObj) return; 1720 1721 while (this.dataNodes.haObj.childNodes.length > 0) { 1722 this.dataNodes.haObj.lastChild.style.visibility = "hidden"; 1723 document.body.appendChild(this.dataNodes.haObj.lastChild); 1724 } 1725 this.dataNodes.haObj.parentNode.removeChild(this.dataNodes.haObj); 1726 this.dataNodes.haObj = null; 1727 1728 this.detachEvent(this.dataNodes.haEv); 1729 this.dataNodes.haEv = null; 1730 1731 this.conf.ofs_nodes.t.haObj = false; 1732 1733 delete this.dataNodes.haEv; 1734 delete this.dataNodes.haObj; 1735 1736 if (!this.conf.unloading) this.setSizes(); 1737 1738}; 1739 1740dhtmlXCellTop.prototype.attachFooter = function(obj, height) { 1741 1742 if (this.dataNodes.faObj != null) return; 1743 1744 if (typeof(obj) != "object") obj = document.getElementById(obj); 1745 1746 this.dataNodes.faObj = document.createElement("DIV"); 1747 this.dataNodes.faObj.className = "dhxcelltop_ftr"; 1748 this.dataNodes.faObj.style.height = (height||obj.offsetHeight)+"px"; 1749 1750 var p = (this.dataNodes.sbObj||this.cont); 1751 if (this.base.lastChild == p) { 1752 this.base.appendChild(this.dataNodes.faObj); 1753 } else { 1754 this.base.insertBefore(this.dataNodes.faObj, p.nextSibling); 1755 } 1756 1757 this.dataNodes.faEv = this.attachEvent("_onSetSizes", function(){ 1758 this.dataNodes.faObj.style.left = this.conf.ofs.l+"px"; 1759 this.dataNodes.faObj.style.bottom = this.conf.ofs.b+"px"; 1760 this.dataNodes.faObj.style.width = this.base.offsetWidth-this.conf.ofs.l-this.conf.ofs.r+"px"; 1761 }); 1762 1763 this.dataNodes.faObj.appendChild(obj); 1764 obj.style.visibility = "visible"; 1765 p = obj = null; 1766 1767 this.conf.ofs_nodes.b.faObj = true; 1768 1769 this.setSizes(); 1770 1771}; 1772 1773dhtmlXCellTop.prototype.detachFooter = function() { 1774 1775 if (!this.dataNodes.faObj) return; 1776 1777 while (this.dataNodes.faObj.childNodes.length > 0) { 1778 this.dataNodes.faObj.lastChild.style.visibility = "hidden"; 1779 document.body.appendChild(this.dataNodes.faObj.lastChild); 1780 } 1781 this.dataNodes.faObj.parentNode.removeChild(this.dataNodes.faObj); 1782 this.dataNodes.faObj = null; 1783 1784 this.detachEvent(this.dataNodes.faEv); 1785 this.dataNodes.faEv = null; 1786 1787 this.conf.ofs_nodes.b.faObj = false; 1788 1789 delete this.dataNodes.faEv; 1790 delete this.dataNodes.faObj; 1791 1792 if (!this.conf.unloading) this.setSizes(); 1793 1794}; 1795
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.