[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 /****************************************************************************\ 2 * Dynamic JS Win - Javascript Object * 3 * * 4 * Written by: * 5 * - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net> * 6 * ------------------------------------------------------------------------ * 7 * This program is free software; you can redistribute it and/or modify it * 8 * under the terms of the GNU General Public License as published by the * 9 * Free Software Foundation; either version 2 of the License, or (at your * 10 * option) any later version. * 11 \****************************************************************************/ 12 13 dJSWin.prototype.init = function(params) 14 { 15 if (!params || typeof(params) != 'object' || !params.id || !params.width || !params.height || !params.content_id) 16 { 17 throw("Can't create empty window or window without width, height or ID"); 18 } 19 20 /* Internal Variables */ 21 this.winContainer = document.createElement('iframe'); 22 this.clientArea = document.createElement('div'); 23 this.title = document.createElement('div'); 24 this.title_text = null; //document.createElement(''); 25 this.buttons = new Array(); 26 this.shadows = new Array(); 27 this.border = new Array(); 28 this.content_id = params.content_id; 29 this.includedContents = params['include_contents']; 30 var pixelTABLE, pixelTBODY, pixelTR, pixelTD; 31 var _this = this; 32 var style; 33 34 /* Create 1 pixel table to be able to create freely 35 * sizeble DIVs on IE 36 */ 37 pixelTABLE = document.createElement('table'); 38 pixelTBODY = document.createElement('tbody'); 39 pixelTR = document.createElement('tR'); 40 pixelTD = document.createElement('td'); 41 42 pixelTABLE.appendChild(pixelTBODY); 43 pixelTBODY.appendChild(pixelTR); 44 pixelTR.appendChild(pixelTD); 45 46 this.title_text_cont = pixelTABLE.cloneNode(true); 47 this.title_text = this.title_text_cont.firstChild.firstChild.firstChild; 48 49 pixelTABLE.style.width = '1px'; 50 pixelTABLE.style.height = '1px'; 51 52 pixelTD.style.width = '1px'; 53 pixelTD.style.height = '1px'; 54 55 this.border['t'] = document.createElement('div'); 56 this.border['b'] = document.createElement('div'); 57 this.border['l'] = document.createElement('div'); 58 this.border['r'] = document.createElement('div'); 59 60 this.shadows['r'] = document.createElement('div'); 61 this.shadows['b'] = document.createElement('div'); 62 63 this.buttons['xDIV'] = document.createElement('div'); 64 65 if (params['button_x_img']) 66 { 67 this.buttons['xIMG'] = document.createElement('IMG'); 68 this.buttons['xIMG'].src = params['button_x_img']; 69 this.buttons['xIMG'].style.cursor = 'hand'; 70 this.buttons['xDIV'].appendChild(this.buttons['xIMG']); 71 } 72 else 73 { 74 this.buttons.xDIV.innerHTML = 'X'; 75 } 76 77 /* Inicialization */ 78 this.title.id = params['id']; 79 this.title.style.position = 'absolute'; 80 this.title.style.visibility = 'hidden'; 81 this.title.style.width = parseInt(params['width']) + 2 + 'px'; 82 this.title.style.height = params['title_height'] ? params['title_height'] : '18px'; 83 this.title.style.backgroundColor = '#3978d6'; 84 // this.title.className = 'dJSWin_title'; 85 this.title.style.top = '0px'; 86 this.title.style.left = '0px'; 87 this.title.style.zIndex = '1'; 88 89 this.title_text_cont.id = params['id'] + '_text'; 90 this.title_text_cont.style.position = 'relative'; 91 // this.title_text_cont.border = '0'; 92 this.title_text_cont.style.width = '100%'; 93 this.title_text_cont.style.height = '100%'; 94 this.title_text.style.cursor = 'move'; 95 this.title_text_cont.className = 'dJSWin_title_text'; 96 this.title_text.className = 'dJSWin_title_text'; 97 // this.title_text.style.cursor = 'move'; 98 this.title_text.innerHTML = params['title']; 99 this.title_text_cont.style.zIndex = '1'; 100 101 this.winContainer.id = params['id']+'_winContainer'; 102 this.winContainer.style.position = 'absolute'; 103 this.winContainer.style.visibility = 'hidden'; 104 this.winContainer.style.width = params['width']; 105 this.winContainer.style.height = parseInt(params['height']) + parseInt(this.title.style.height) + 'px'; 106 // this.winContainer.style.top = '0px'; 107 this.winContainer.style.top = '0px'; //this.title.style.height; 108 this.winContainer.style.left = '0px'; 109 this.winContainer.style.zIndex = '-1'; 110 // this.winContainer.style.backgroundColor = params['bg_color']; 111 // this.winContainer.className = params['win_class']; 112 this.winContainer.src = ''; 113 114 this.clientArea.id = params['id']+'_clientArea'; 115 this.clientArea.style.position = 'absolute'; 116 this.clientArea.style.visibility = 'hidden'; 117 this.clientArea.style.width = parseInt(params['width']) + 2 + 'px'; 118 this.clientArea.style.height = params['height']; 119 this.clientArea.style.top = parseInt(this.title.style.height) + 'px'; 120 this.clientArea.style.left = '0px'; 121 // this.clientArea.style.backgroundColor = params['bg_color']; 122 // this.clientArea.style.overflow = 'auto'; 123 this.clientArea.className = 'dJSWin_main'; 124 125 this.buttons.xDIV.id = params['id']+'_button'; 126 this.buttons.xDIV.style.position = 'absolute'; 127 this.buttons.xDIV.style.visibility = 'hidden'; 128 this.buttons.xDIV.style.cursor = 'hand'; 129 this.buttons.xDIV.style.top = '1px'; 130 this.buttons.xDIV.style.left = parseInt(params['width']) - 13 + 'px'; 131 this.buttons.xDIV.style.zIndex = '1'; 132 this.buttons.xDIV.onclick = function() {_this.close();}; 133 134 this.shadows.b.id = params['id']+'_shadowb'; 135 this.shadows.b.style.position = 'absolute'; 136 this.shadows.b.style.visibility = 'hidden'; 137 this.shadows.b.style.backgroundColor = '#666'; 138 this.shadows.b.style.width = params['width']; 139 this.shadows.b.style.height = '4px'; 140 this.shadows.b.style.top = parseInt(this.title.style.height) + parseInt(params['height']) + 2 + 'px'; 141 this.shadows.b.style.left = '4px'; 142 this.shadows.b.appendChild(pixelTABLE.cloneNode(true)); 143 144 this.shadows.r.id = params['id']+'_shadowr'; 145 this.shadows.r.style.position = 'absolute'; 146 this.shadows.r.style.visibility = 'hidden'; 147 this.shadows.r.style.backgroundColor = '#666'; 148 this.shadows.r.style.width = '4px'; 149 this.shadows.r.style.height = parseInt(params['height']) + parseInt(this.title.style.height) + 'px'; 150 this.shadows.r.style.top = '4px'; 151 this.shadows.r.style.left = params['width']; 152 153 this.border.t.id = params['id']+'_border_t'; 154 this.border.b.id = params['id']+'_border_b'; 155 this.border.l.id = params['id']+'_border_l'; 156 this.border.r.id = params['id']+'_border_r'; 157 158 this.border.t.style.position = 'absolute'; 159 this.border.b.style.position = 'absolute'; 160 this.border.l.style.position = 'absolute'; 161 this.border.r.style.position = 'absolute'; 162 163 this.border.t.style.visibility = 'hidden'; 164 this.border.b.style.visibility = 'hidden'; 165 this.border.l.style.visibility = 'hidden'; 166 this.border.r.style.visibility = 'hidden'; 167 168 this.border.t.className = 'dJSWin_title'; 169 this.border.b.className = 'dJSWin_title'; 170 this.border.l.className = 'dJSWin_title'; 171 this.border.r.className = 'dJSWin_title'; 172 173 this.border.t.style.border = '0px'; 174 this.border.b.style.border = '0px'; 175 this.border.l.style.border = '0px'; 176 this.border.r.style.border = '0px'; 177 178 this.border.t.appendChild(pixelTABLE.cloneNode(true)); 179 this.border.b.appendChild(pixelTABLE.cloneNode(true)); 180 181 if (params['border']) 182 { 183 this.border.t.style.width = parseInt(params['width']) + 2 + 'px'; 184 this.border.b.style.width = parseInt(params['width']) + 4 + 'px'; 185 this.border.l.style.width = '2px'; 186 this.border.r.style.width = '2px'; 187 188 this.border.t.style.height = '2px'; 189 this.border.b.style.height = '2px'; 190 this.border.l.style.height = parseInt(params['height']) + parseInt(this.title.style.height) + 4 + 'px'; 191 this.border.r.style.height = parseInt(params['height']) + parseInt(this.title.style.height) + 4 + 'px'; 192 193 this.border.t.style.top = '-2px'; 194 this.border.b.style.top = parseInt(params['height']) + parseInt(this.title.style.height) + 'px'; 195 this.border.l.style.top = '-2px'; 196 this.border.r.style.top = '-2px'; 197 198 this.border.t.style.left = '-2px'; 199 this.border.b.style.left = '-2px'; 200 this.border.l.style.left = '-2px'; 201 this.border.r.style.left = params['width']; 202 203 this.shadows.b.style.top = parseInt(this.shadows.b.style.top) + 2 + 'px'; 204 this.shadows.r.style.top = parseInt(this.shadows.r.style.top) + 2 + 'px'; 205 this.shadows.b.style.left = parseInt(this.shadows.b.style.left) + 2 + 'px'; 206 this.shadows.r.style.left = parseInt(this.shadows.r.style.left) + 2 + 'px'; 207 208 this.winContainer.style.top = '-3px'; 209 this.winContainer.style.left = '-2px'; 210 this.winContainer.style.width = parseInt(this.winContainer.style.width) + 8 + 'px'; 211 this.winContainer.style.height = parseInt(this.winContainer.style.height) + 10 + 'px'; 212 } 213 else 214 { 215 this.border.t.style.width = '0px'; 216 this.border.b.style.width = '0px'; 217 this.border.l.style.width = '0px'; 218 this.border.r.style.width = '0px'; 219 } 220 221 //JsLib.postponeFunction(function(){_this._createWin();}); 222 this._createWin(); 223 } 224 225 dJSWin.prototype.open = function() 226 { 227 this.moveTo(document.body.offsetWidth/2 + document.body.scrollLeft - dd.elements[this.title.id].w/2, 228 document.body.offsetHeight/2 + document.body.scrollTop - dd.elements[this.winContainer.id].h/2); 229 230 dd.elements[this.title.id].maximizeZ(); 231 dd.elements[this.title.id].show(); 232 } 233 234 dJSWin.prototype.draw = function() 235 { 236 if (this.drawn) 237 { 238 return; 239 } 240 241 this.drawn = true; 242 243 if (dd.elements && dd.elements[this.title.id]) 244 { 245 return; 246 } 247 248 ADD_DHTML(this.title.id+CURSOR_MOVE); 249 ADD_DHTML(this.title_text_cont.id+NO_DRAG); 250 ADD_DHTML(this.winContainer.id+NO_DRAG); 251 ADD_DHTML(this.clientArea.id+NO_DRAG); 252 ADD_DHTML(this.buttons.xDIV.id+NO_DRAG); 253 ADD_DHTML(this.content.id+NO_DRAG); 254 ADD_DHTML(this.shadows.r.id+NO_DRAG); 255 ADD_DHTML(this.shadows.b.id+NO_DRAG); 256 ADD_DHTML(this.border.t.id+NO_DRAG); 257 ADD_DHTML(this.border.b.id+NO_DRAG); 258 ADD_DHTML(this.border.l.id+NO_DRAG); 259 ADD_DHTML(this.border.r.id+NO_DRAG); 260 261 262 dd.elements[this.winContainer.id].setZ(-1); 263 dd.elements[this.title.id].setZ(0); 264 dd.elements[this.title.id].addChild(dd.elements[this.title_text_cont.id]); 265 dd.elements[this.title.id].addChild(dd.elements[this.winContainer.id]); 266 dd.elements[this.title.id].addChild(dd.elements[this.clientArea.id]); 267 dd.elements[this.title.id].addChild(dd.elements[this.buttons.xDIV.id]); 268 dd.elements[this.title.id].addChild(dd.elements[this.content.id]); 269 dd.elements[this.title.id].addChild(dd.elements[this.shadows.r.id]); 270 dd.elements[this.title.id].addChild(dd.elements[this.shadows.b.id]); 271 dd.elements[this.title.id].addChild(dd.elements[this.border.t.id]); 272 dd.elements[this.title.id].addChild(dd.elements[this.border.b.id]); 273 dd.elements[this.title.id].addChild(dd.elements[this.border.l.id]); 274 dd.elements[this.title.id].addChild(dd.elements[this.border.r.id]); 275 276 277 if (typeof(this.includedContents) == 'object') 278 { 279 for (var i in this.includedContents) 280 { 281 ADD_DHTML(this.includedContents[i]+NO_DRAG); 282 dd.elements[this.title.id].addChild(dd.elements[this.includedContents[i]]); 283 } 284 } 285 286 dd.elements[this.title.id].moveTo(document.body.offsetWidth/2 - dd.elements[this.winContainer.id].w/2, 287 document.body.offsetHeight/2 - dd.elements[this.winContainer.id].h/2) 288 289 dd.elements[this.title.id].hide(); 290 } 291 292 dJSWin.prototype._createWin = function() 293 { 294 style = document.createElement('link'); 295 style.href = GLOBALS['serverRoot'] + "phpgwapi/js/dJSWin/dJSWin.css"; 296 style.rel = "stylesheet"; 297 style.type = "text/css"; 298 document.body.appendChild(style); 299 300 this.content = Element(this.content_id); 301 this.content.style.visibility = 'hidden'; 302 //this.content.style.top = parseInt(this.title.style.height) + 'px'; 303 this.content.style.top = '0px'; 304 this.content.style.left = '0px'; 305 306 this.title.appendChild(this.title_text_cont); 307 this.title.appendChild(this.winContainer); 308 this.title.appendChild(this.clientArea); 309 this.title.appendChild(this.buttons.xDIV); 310 this.title.appendChild(this.border.t); 311 this.title.appendChild(this.border.b); 312 this.title.appendChild(this.border.l); 313 this.title.appendChild(this.border.r); 314 this.title.appendChild(this.shadows.r); 315 this.title.appendChild(this.shadows.b); 316 this.clientArea.appendChild(this.content); 317 318 document.body.appendChild(this.title); 319 320 this.draw(); 321 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |