[ 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 if (!window.dd) 14 { 15 throw("wz_dragdrop lib must be loaded!"); 16 } 17 18 function dJSWin(params) 19 { 20 this.init(params); 21 } 22 23 dJSWin.prototype.init = function(params) 24 { 25 if (!params || typeof(params) != 'object' || !params.id || !params.width || !params.height || !params.content_id) 26 { 27 throw("Can't create empty window or window without width, height or ID"); 28 } 29 30 /* Internal Variables */ 31 this.clientArea = document.createElement('div'); 32 this.title = document.createElement('div'); 33 this.title_text = document.createElement('span'); 34 this.buttons = new Array(); 35 this.shadows = new Array(); 36 this.border = new Array(); 37 this.content = Element(params.content_id); 38 this.includedContents = params['include_contents']; 39 var _this = this; 40 var style; 41 42 style = document.createElement('link'); 43 style.href = GLOBALS['serverRoot'] + "phpgwapi/js/dJSWin/dJSWin.css"; 44 style.rel = "stylesheet"; 45 style.type = "text/css"; 46 document.body.appendChild(style); 47 48 if (is_moz1_6) 49 { 50 var content_ = this.content; 51 this.content = this.content.cloneNode(true); 52 53 content_.id = content_.id+'CLONE'; 54 content_.style.display = 'none'; 55 } 56 57 this.border['t'] = document.createElement('div'); 58 this.border['b'] = document.createElement('div'); 59 this.border['l'] = document.createElement('div'); 60 this.border['r'] = document.createElement('div'); 61 62 this.shadows['r'] = document.createElement('div'); 63 this.shadows['b'] = document.createElement('div'); 64 65 this.buttons['xDIV'] = document.createElement('div'); 66 67 if (params['button_x_img']) 68 { 69 this.buttons['xIMG'] = document.createElement('IMG'); 70 this.buttons['xIMG'].src = params['button_x_img']; 71 this.buttons['xIMG'].style.cursor = 'hand'; 72 this.buttons['xDIV'].appendChild(this.buttons['xIMG']); 73 } 74 else 75 { 76 this.buttons.xDIV.innerHTML = 'X'; 77 } 78 79 /* Inicialization */ 80 this.title.id = params['id']; 81 this.title.style.position = 'absolute'; 82 this.title.style.visibility = 'hidden'; 83 this.title.style.width = parseInt(params['width']) + 2 + 'px'; 84 this.title.style.height = params['title_height'] ? params['title_height'] : '18px'; 85 this.title.style.backgroundColor = '#3978d6'; 86 // this.title.className = 'dJSWin_title'; 87 this.title.style.top = '0px'; 88 this.title.style.left = '0px'; 89 this.title.style.zIndex = '1'; 90 91 this.title_text.style.position = 'relative'; 92 this.title_text.className = 'dJSWin_title_text'; 93 // this.title_text.style.cursor = 'move'; 94 this.title_text.innerHTML = params['title']; 95 this.title_text.style.zIndex = '1'; 96 97 this.clientArea.id = params['id']+'_clientArea'; 98 this.clientArea.style.position = 'absolute'; 99 this.clientArea.style.visibility = 'hidden'; 100 this.clientArea.style.width = parseInt(params['width']) + 2 + 'px'; 101 this.clientArea.style.height = params['height']; 102 this.clientArea.style.top = parseInt(this.title.style.height) + 'px'; 103 this.clientArea.style.left = '0px'; 104 // this.clientArea.style.backgroundColor = params['bg_color']; 105 // this.clientArea.style.overflow = 'auto'; 106 this.clientArea.className = 'dJSWin_main'; 107 108 this.buttons.xDIV.id = params['id']+'_button'; 109 this.buttons.xDIV.style.position = 'absolute'; 110 this.buttons.xDIV.style.visibility = 'hidden'; 111 this.buttons.xDIV.style.cursor = 'hand'; 112 this.buttons.xDIV.style.top = '1px'; 113 this.buttons.xDIV.style.left = parseInt(params['width']) - 13 + 'px'; 114 this.buttons.xDIV.style.zIndex = '1'; 115 this.buttons.xDIV.onclick = function() {_this.close();}; 116 117 this.content.style.visibility = 'hidden'; 118 //this.content.style.top = parseInt(this.title.style.height) + 'px'; 119 this.content.style.top = '0px'; 120 this.content.style.left = '0px'; 121 122 this.shadows.b.id = params['id']+'_shadowb'; 123 this.shadows.b.style.position = 'absolute'; 124 this.shadows.b.style.visibility = 'hidden'; 125 this.shadows.b.style.backgroundColor = '#666'; 126 this.shadows.b.style.width = params['width']; 127 this.shadows.b.style.height = '4px'; 128 this.shadows.b.style.top = parseInt(this.title.style.height) + parseInt(params['height']) + 'px'; 129 this.shadows.b.style.left = '4px'; 130 131 this.shadows.r.id = params['id']+'_shadowr'; 132 this.shadows.r.style.position = 'absolute'; 133 this.shadows.r.style.visibility = 'hidden'; 134 this.shadows.r.style.backgroundColor = '#666'; 135 this.shadows.r.style.width = '4px'; 136 this.shadows.r.style.height = parseInt(params['height']) + parseInt(this.title.style.height) + 'px'; 137 this.shadows.r.style.top = '4px'; 138 this.shadows.r.style.left = params['width']; 139 140 this.border.t.id = params['id']+'_border_t'; 141 this.border.b.id = params['id']+'_border_b'; 142 this.border.l.id = params['id']+'_border_l'; 143 this.border.r.id = params['id']+'_border_r'; 144 145 this.border.t.style.position = 'absolute'; 146 this.border.b.style.position = 'absolute'; 147 this.border.l.style.position = 'absolute'; 148 this.border.r.style.position = 'absolute'; 149 150 this.border.t.style.visibility = 'hidden'; 151 this.border.b.style.visibility = 'hidden'; 152 this.border.l.style.visibility = 'hidden'; 153 this.border.r.style.visibility = 'hidden'; 154 155 this.border.t.className = 'dJSWin_title'; 156 this.border.b.className = 'dJSWin_title'; 157 this.border.l.className = 'dJSWin_title'; 158 this.border.r.className = 'dJSWin_title'; 159 160 this.border.t.style.border = '0px'; 161 this.border.b.style.border = '0px'; 162 this.border.l.style.border = '0px'; 163 this.border.r.style.border = '0px'; 164 165 if (params['border']) 166 { 167 this.border.t.style.width = parseInt(params['width']) + 2 + 'px'; 168 this.border.b.style.width = parseInt(params['width']) + 2 + 'px'; 169 this.border.l.style.width = '2px'; 170 this.border.r.style.width = '2px'; 171 172 this.border.t.style.height = '2px'; 173 this.border.b.style.height = '2px'; 174 this.border.l.style.height = parseInt(params['height']) + parseInt(this.title.style.height) + 4 + 'px'; 175 this.border.r.style.height = parseInt(params['height']) + parseInt(this.title.style.height) + 4 + 'px'; 176 177 this.border.t.style.top = '-2px'; 178 this.border.b.style.top = parseInt(params['height']) + parseInt(this.title.style.height) + 'px'; 179 this.border.l.style.top = '-2px'; 180 this.border.r.style.top = '-2px'; 181 182 this.border.t.style.left = '-2px'; 183 this.border.b.style.left = '-2px'; 184 this.border.l.style.left = '-2px'; 185 this.border.r.style.left = params['width']; 186 187 this.shadows.b.style.top = parseInt(this.shadows.b.style.top) + 2 + 'px'; 188 this.shadows.r.style.top = parseInt(this.shadows.r.style.top) + 2 + 'px'; 189 this.shadows.b.style.left = parseInt(this.shadows.b.style.left) + 2 + 'px'; 190 this.shadows.r.style.left = parseInt(this.shadows.r.style.left) + 2 + 'px'; 191 } 192 else 193 { 194 this.border.t.style.width = '0px'; 195 this.border.b.style.width = '0px'; 196 this.border.l.style.width = '0px'; 197 this.border.r.style.width = '0px'; 198 } 199 200 if (!is_moz1_6) 201 { 202 this.content.parentNode.removeChild(this.content); 203 } 204 205 this.title.appendChild(this.title_text); 206 this.title.appendChild(this.clientArea); 207 this.title.appendChild(this.buttons.xDIV); 208 this.title.appendChild(this.border.t); 209 this.title.appendChild(this.border.b); 210 this.title.appendChild(this.border.l); 211 this.title.appendChild(this.border.r); 212 this.title.appendChild(this.shadows.r); 213 this.title.appendChild(this.shadows.b); 214 this.clientArea.appendChild(this.content); 215 216 document.body.appendChild(this.title); 217 this.draw(); 218 } 219 220 dJSWin.prototype.close = function() 221 { 222 dd.elements[this.title.id].hide(); 223 } 224 225 dJSWin.prototype.open = function() 226 { 227 this.moveTo(window.innerWidth/2 + window.pageXOffset - dd.elements[this.title.id].w/2, 228 window.innerHeight/2 + window.pageYOffset - dd.elements[this.clientArea.id].h/2); 229 230 dd.elements[this.title.id].maximizeZ(); 231 dd.elements[this.title.id].show(); 232 } 233 234 dJSWin.prototype.show = function() 235 { 236 this.open(); 237 } 238 239 dJSWin.prototype.hide = function() 240 { 241 this.close(); 242 } 243 244 dJSWin.prototype.moveTo = function(x,y) 245 { 246 dd.elements[this.title.id].moveTo(x,y); 247 } 248 249 dJSWin.prototype.x = function() 250 { 251 return dd.elements[this.title.id].x; 252 } 253 254 dJSWin.prototype.y = function() 255 { 256 return dd.elements[this.title.id].y; 257 } 258 259 dJSWin.prototype.draw = function() 260 { 261 if (dd.elements && dd.elements[this.title.id]) 262 { 263 return; 264 } 265 266 if (this.drawn) 267 { 268 return; 269 } 270 271 this.drawn = true; 272 273 ADD_DHTML(this.title.id+CURSOR_MOVE); 274 ADD_DHTML(this.clientArea.id+NO_DRAG); 275 ADD_DHTML(this.buttons.xDIV.id+NO_DRAG); 276 ADD_DHTML(this.content.id+NO_DRAG); 277 ADD_DHTML(this.shadows.r.id+NO_DRAG); 278 ADD_DHTML(this.shadows.b.id+NO_DRAG); 279 ADD_DHTML(this.border.t.id+NO_DRAG); 280 ADD_DHTML(this.border.b.id+NO_DRAG); 281 ADD_DHTML(this.border.l.id+NO_DRAG); 282 ADD_DHTML(this.border.r.id+NO_DRAG); 283 284 dd.elements[this.title.id].addChild(dd.elements[this.border.t.id]); 285 286 dd.elements[this.title.id].addChild(dd.elements[this.clientArea.id]); 287 dd.elements[this.title.id].addChild(dd.elements[this.buttons.xDIV.id]); 288 dd.elements[this.title.id].addChild(dd.elements[this.content.id]); 289 dd.elements[this.title.id].addChild(dd.elements[this.shadows.r.id]); 290 dd.elements[this.title.id].addChild(dd.elements[this.shadows.b.id]); 291 dd.elements[this.title.id].addChild(dd.elements[this.border.b.id]); 292 dd.elements[this.title.id].addChild(dd.elements[this.border.l.id]); 293 dd.elements[this.title.id].addChild(dd.elements[this.border.r.id]); 294 295 296 if (typeof(this.includedContents) == 'object') 297 { 298 for (var i in this.includedContents) 299 { 300 ADD_DHTML(this.includedContents[i]+NO_DRAG); 301 dd.elements[this.title.id].addChild(dd.elements[this.includedContents[i]]); 302 } 303 } 304 305 dd.elements[this.title.id].hide(); 306 dd.elements[this.title.id].moveTo(window.innerWidth/2 - dd.elements[this.clientArea.id].w/2, 307 window.innerHeight/2 - dd.elements[this.clientArea.id].h/2); 308 309 } 310 311 if (!dd.elements) 312 { 313 var div = document.createElement('div'); 314 div.id = '__NONE__#'; 315 div.style.position = 'absolute'; 316 317 SET_DHTML(div.id); 318 }
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 |