Changeset 786
- Timestamp:
- 03/16/07 00:18:25 (6 years ago)
- Location:
- branches/ray
- Files:
-
- 2 removed
- 9 modified
-
Xinha.css (modified) (1 diff)
-
XinhaCore.js (modified) (4 diffs)
-
examples/testbed.html (modified) (4 diffs)
-
modules/ColorPicker/ColorPicker.js (modified) (1 diff)
-
modules/Dialogs/XinhaDialog.js (modified) (23 diffs)
-
plugins/CharacterMap/CharacterMap.css (modified) (1 diff)
-
plugins/CharacterMap/character-map.js (modified) (8 diffs)
-
plugins/CharacterMap/dialog.html (deleted)
-
plugins/CharacterMap/popups (deleted)
-
plugins/SmartReplace/smart-replace.js (modified) (1 diff)
-
plugins/Stylist/stylist.js (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/ray/Xinha.css
r783 r786 266 266 267 267 .htmlarea .panel h1 { 268 background: ButtonFace;269 border: 1px solid;270 border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;271 margin: 0px;272 padding: 0px;273 font-size:100%;274 font-weight:bold;275 padding: 2px;276 268 clear:left; 277 letter-spacing: 0.01em; 278 } 279 280 .htmlarea .panel { overflow:hidden; } 269 font-size:0.9em; 270 } 271 272 .htmlarea .panel { 273 overflow:hidden; 274 background-color:white; 275 padding-bottom:0 !IMPORTANT; 276 border: none !IMPORTANT; 277 } 281 278 .htmlarea .panels.left .panel { border-right:none; border-left:none; } 282 279 .htmlarea .panels.left h1 { border-right:none; } -
branches/ray/XinhaCore.js
r784 r786 3288 3288 Xinha.prototype.updateToolbar = function(noStatus) 3289 3289 { 3290 if (this.suspendUpdateToolbar) return; 3291 3290 3292 var doc = this._doc; 3291 3293 var text = (this._editMode == "textmode"); … … 3299 3301 { 3300 3302 var item = this._statusBarItems.pop(); 3301 Xinha.free(item); 3303 item.el = null; 3304 item.editor = null; 3305 item.onclick = null; 3306 item.oncontextmenu = null; 3307 item._xinha_dom0Events['click'] = null; 3308 item._xinha_dom0Events['contextmenu'] = null; 3309 item = null; 3302 3310 } 3303 3311 … … 4045 4053 clearTimeout(editor._timerToolbar); 4046 4054 } 4047 editor._timerToolbar = setTimeout( 4048 function() 4049 { 4050 editor.updateToolbar(); 4051 editor._timerToolbar = null; 4052 }, 4053 250); 4055 if (!this.suspendUpdateToolbar) 4056 { 4057 editor._timerToolbar = setTimeout( 4058 function() 4059 { 4060 editor.updateToolbar(); 4061 editor._timerToolbar = null; 4062 }, 4063 250); 4064 } 4054 4065 }; 4055 4066 … … 5591 5602 }; 5592 5603 5604 Xinha.pageSize = function(scope) 5605 { 5606 scope = (scope) ? scope : window; 5607 var x,y; 5608 5609 var test1 = scope.document.body.scrollHeight; //IE Quirks 5610 var test2 = scope.document.documentElement.scrollHeight; // IE Standard + Moz Here quirksmode.org errs! 5611 5612 if (test1 > test2) 5613 { 5614 x = scope.document.body.scrollWidth; 5615 y = scope.document.body.scrollHeight; 5616 } 5617 else 5618 { 5619 x = scope.document.documentElement.scrollWidth; 5620 y = scope.document.documentElement.scrollHeight; 5621 } 5622 return {'x':x,'y':y}; 5623 }; 5624 5593 5625 Xinha.prototype.scrollPos = function(scope) 5594 5626 { -
branches/ray/examples/testbed.html
r784 r786 1 <!DOCTYPE html 2 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 3 2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 4 3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> … … 65 64 'CharacterMap', 66 65 'Linker', 67 'Stylist' 66 'Stylist', 67 'SmartReplace' 68 68 ]; 69 69 // THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING :) … … 88 88 89 89 xinha_config.CharacterMap.mode = 'panel'; 90 //xinha_config.stylistLoadStylesheet(document.location.href.replace(/[^\/]*\.html/, 'stylist.css'));90 xinha_config.stylistLoadStylesheet(document.location.href.replace(/[^\/]*\.html/, 'stylist.css')); 91 91 92 92 /* … … 154 154 </select> 155 155 <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> 156 <textarea id="myTextArea" name="myTextArea" style="width:100%;height: 200px;">156 <textarea id="myTextArea" name="myTextArea" style="width:100%;height:300px;"> 157 157 <table cellspacing="1" cellpadding="1" border="1" style="width: 100%;"><tbody><tr><td style="width: 25%;"> </td><td style="width: 25%;"> </td><td style="width: 25%;"> </td><td style="width: 25%;"> </td></tr><tr><td style="width: 25%;"> </td><td style="width: 25%;"> </td><td style="width: 25%;"> </td><td style="width: 25%;"> </td></tr></tbody></table><br /></textarea> 158 158 -
branches/ray/modules/ColorPicker/ColorPicker.js
r775 r786 364 364 do 365 365 { 366 if (e.style.position == 'fixed') 367 { 368 this.table.style.position = 'absolute'; 369 } 366 370 top += e.offsetTop; 367 371 left += e.offsetLeft; -
branches/ray/modules/Dialogs/XinhaDialog.js
r784 r786 21 21 -- $LastChangedBy$ 22 22 --------------------------------------------------------------------------*/ 23 Xinha.Dialog = function(editor, html, localizer, size, modal, layer) 23 24 /** Xinha Dialog 25 * 26 * 27 * @param editor Xinha object 28 * @param html string 29 * @param localizer string the "context" parameter for Xinha._lc(), typically the name of the plugin 30 * @param size object with two possible properties of the size: width & height as int, where height is optional 31 */ 32 Xinha.Dialog = function(editor, html, localizer, size, options) 24 33 { 25 34 var dialog = this; … … 28 37 this.editor = editor; 29 38 this.document = document; 30 this.modal = (modal === false) ? false : true; 31 this.layer = (layer) ? layer : 0; 39 this.modal = (options && options.modal === false) ? false : true; 40 this.closable = (options && options.closable === false) ? false : true; 41 this.layer = (options && options.layer) ? options.layer : 0; 32 42 33 43 if ( !this.background ) … … 55 65 overflow = "hidden"; 56 66 display = "none"; 57 zIndex = 1001+ this.layer;67 zIndex = (this.modal ? 1025 : 1001 ) + this.layer; 58 68 } 59 69 document.body.appendChild(backG); … … 63 73 with (backG.style) 64 74 { 65 position = "absolute"; //(Xinha.is_ie) ? "absolute" : "fixed";75 position = "absolute"; 66 76 top = 0; 67 77 left = 0; 68 78 overflow = "hidden"; 69 79 display = "none"; 70 zIndex = 1002+ this.layer;80 zIndex = (this.modal ? 1026 : 1002 ) + this.layer; 71 81 } 72 82 document.body.appendChild(backG); … … 76 86 } 77 87 var rootElem = document.createElement('div'); 78 rootElem.style.position = 'absolute'; 79 rootElem.style.zIndex = 1003+ this.layer; 88 //I've got the feeling dragging is much slower in IE7 w/ pos:fixed, besides the strange fact that it only works in Strict mode 89 //rootElem.style.position = (Xinha.ie_version < 7 ||(Xinha.is_ie && document.compatMode == "BackCompat") || !this.modal) ? "absolute" : "fixed"; 90 rootElem.style.position = (Xinha.is_ie || !this.modal) ? "absolute" : "fixed"; 91 rootElem.style.zIndex = (this.modal ? 1027 : 1003 ) + this.layer; 80 92 rootElem.style.display = 'none'; 93 94 if (!this.modal) 95 { 96 Xinha._addEvent(rootElem,'mousedown', function () { Xinha.Dialog.activateModeless(dialog);}); 97 } 81 98 82 99 // FIXME: This is nice, but I don't manage to get it switched off on text inputs :( … … 134 151 rootElem.insertBefore(captionBar,main); 135 152 captionBar.onmousedown = function(ev) { dialog._dragStart(ev); }; 153 136 154 captionBar.style.MozUserSelect = "none"; 137 155 138 var closer = document.createElement('div'); 139 closer.className= 'closeButton'; 140 141 closer.onmousedown = function(ev) { this.className = "closeButton buttonClick"; Xinha._stopEvent((ev) ? ev : window.event); return false;}; 142 closer.onmouseout = function(ev) { this.className = "closeButton"; Xinha._stopEvent((ev) ? ev : window.event); return false;}; 143 closer.onmouseup = function() { this.className = "closeButton"; dialog.hide(); return false;}; 144 captionBar.appendChild(closer); 145 146 var butX = document.createElement('span'); 147 butX.className = 'innerX'; 148 butX.style.position = 'relative'; 149 butX.style.top = '-3px'; 150 151 butX.appendChild(document.createTextNode('\u00D7')); 152 closer.appendChild(butX); 153 butX = null; 154 156 var closer = null; 157 if ( this.closable ) 158 { 159 var closer = document.createElement('div'); 160 closer.className= 'closeButton'; 161 162 closer.onmousedown = function(ev) { this.className = "closeButton buttonClick"; Xinha._stopEvent((ev) ? ev : window.event); return false;}; 163 closer.onmouseout = function(ev) { this.className = "closeButton"; Xinha._stopEvent((ev) ? ev : window.event); return false;}; 164 closer.onmouseup = function() { this.className = "closeButton"; dialog.hide(); return false;}; 165 captionBar.appendChild(closer); 166 167 var butX = document.createElement('span'); 168 butX.className = 'innerX'; 169 butX.style.position = 'relative'; 170 butX.style.top = '-3px'; 171 172 butX.appendChild(document.createTextNode('\u00D7')); 173 closer.appendChild(butX); 174 butX = null; 175 } 176 155 177 var icon = document.createElement('img'); 156 178 icon.className = 'icon'; … … 159 181 icon.style.top = '3px'; 160 182 icon.style.left = '2px'; 161 captionBar.style.paddingLeft = ' 30px';183 captionBar.style.paddingLeft = '22px'; 162 184 captionBar.appendChild(icon); 163 185 … … 212 234 }; 213 235 236 Xinha.Dialog.activateModeless = function(dialog) 237 { 238 var zIndex; 239 if (Xinha.Dialog.activeModeless == dialog || dialog.attached ) 240 { 241 return; 242 } 243 244 if (Xinha.Dialog.activeModeless ) 245 { 246 Xinha.Dialog.activeModeless.rootElem.style.zIndex = parseInt(Xinha.Dialog.activeModeless.rootElem.style.zIndex) -10; 247 } 248 Xinha.Dialog.activeModeless = dialog; 249 250 Xinha.Dialog.activeModeless.rootElem.style.zIndex = parseInt(Xinha.Dialog.activeModeless.rootElem.style.zIndex) + 10; 251 } 252 214 253 Xinha.Dialog.prototype.sizeBackground = function() 215 254 { 216 var win_dim = Xinha.viewportSize(); 255 var pageSize = Xinha.pageSize(); 256 217 257 if ( this.modal ) 218 258 { 219 this.background[0].style.width = win_dim.x + 'px'; 220 this.background[0].style.height = win_dim.y + 'px'; 221 this.background[1].style.width = win_dim.x + 'px'; 222 this.background[1].style.height = win_dim.y + 'px'; 223 } 224 window.scroll(this.scrollPos.x, this.scrollPos.y); 225 return win_dim; 259 this.resizeBackground({width: pageSize.x + 'px', height: pageSize.y + 'px'}); 260 } 261 //window.scroll(this.scrollPos.x, this.scrollPos.y); 226 262 } 227 263 … … 234 270 { 235 271 var rootElem = this.rootElem; 272 var rootElemStyle = rootElem.style; 273 var modal = this.modal; 236 274 var scrollPos = this.scrollPos = this.editor.scrollPos(); 237 275 var dialog = this; 238 239 if ( this.modal ) 240 { 241 function resetScroll() 242 { 243 if ( dialog.dialogShown ) 244 { 245 window.scroll(scrollPos.x,scrollPos.y); 246 window.setTimeout(resetScroll,150); 247 } 248 } 249 this.background[0].style.left = this.scrollPos.x + 'px'; 250 this.background[0].style.top = this.scrollPos.y + 'px'; 251 this.background[1].style.left = this.scrollPos.x + 'px'; 252 this.background[1].style.top = this.scrollPos.y + 'px'; 276 //dialog.main.style.height = ''; 277 if ( this.attached ) 278 { 279 this.editor.showPanel(rootElem); 280 } 281 282 if ( modal ) 283 { 284 this.posBackground({top:0, left:0}); 253 285 } 254 286 … … 256 288 this._lastRange = this.editor.saveSelection(); 257 289 258 if (Xinha.is_ie && ! this.modal)290 if (Xinha.is_ie && !modal) 259 291 { 260 292 dialog.saveSelection = function() { dialog._lastRange = dialog.editor.saveSelection();}; … … 262 294 } 263 295 264 if ( this.modal ) this.editor.deactivateEditor();296 if ( modal ) this.editor.deactivateEditor(); 265 297 266 298 // unfortunately we have to hide the editor (iframe/caret bug) 267 if (Xinha.is_gecko && this.modal)299 if (Xinha.is_gecko && modal) 268 300 { 269 301 this._restoreTo = [this.editor._textArea.style.display, this.editor._iframe.style.visibility, this.editor.hidePanels()]; … … 272 304 } 273 305 274 if (!this.editor._isFullScreen && this.modal) 275 { 276 if(Xinha.is_ie && document.compatMode == 'CSS1Compat') 277 { 278 var bod = document.getElementsByTagName('html'); 306 if ( !this.attached) 307 { 308 this.showBackground(); 309 var viewport = Xinha.viewportSize(); 310 this.sizeBackground(); 311 var viewportHeight = viewport.y; 312 var viewportWidth = viewport.x; 313 //this.onResizeWin = function () {dialog.sizeBackground()}; 314 //Xinha._addEvent(window, 'resize', this.onResizeWin ); 315 316 rootElemStyle.display = ''; 317 318 var dialogHeight = rootElem.offsetHeight; 319 var dialogWidth = rootElem.offsetWidth; 320 321 if (dialogHeight > viewportHeight) 322 { 323 rootElemStyle.height = viewportHeight + "px"; 324 if (rootElem.scrollHeight > dialogHeight) 325 { 326 dialog.main.style.overflowY = "auto"; 327 } 328 } 329 330 if(this.size.top && this.size.left) 331 { 332 rootElemStyle.top = parseInt(this.size.top,10) + 'px'; 333 rootElemStyle.left = parseInt(this.size.left,10) + 'px'; 334 } 335 else if (this.editor.btnClickEvent) 336 { 337 var btnClickEvent = this.editor.btnClickEvent; 338 if (rootElemStyle.position == 'absolute') 339 { 340 rootElemStyle.top = btnClickEvent.clientY + this.scrollPos.y +'px'; 341 } 342 else 343 { 344 rootElemStyle.top = btnClickEvent.clientY +'px'; 345 } 346 347 if (dialogHeight + rootElem.offsetTop > viewportHeight) 348 { 349 rootElemStyle.top = (rootElemStyle.position == 'absolute' ? this.scrollPos.y : 0 ) + "px" ; 350 } 351 352 if (rootElemStyle.position == 'absolute') 353 { 354 rootElemStyle.left = btnClickEvent.clientX + this.scrollPos.x +'px'; 355 } 356 else 357 { 358 rootElemStyle.left = btnClickEvent.clientX +'px'; 359 } 360 361 if (dialogWidth + rootElem.offsetLeft > viewportWidth) 362 { 363 rootElemStyle.left = btnClickEvent.clientX - dialogWidth + 'px'; 364 if (rootElem.offsetLeft < 0) 365 { 366 rootElemStyle.left = 0; 367 } 368 } 369 this.editor.btnClickEvent = null; 279 370 } 280 371 else 281 372 { 282 var bod = document.getElementsByTagName('body'); 283 } 284 285 bod[0].style.overflow='hidden'; 286 window.scroll(this.scrollPos.x, this.scrollPos.y); 287 } 288 289 this.background[0].style.display = ''; 290 this.background[1].style.display = ''; 291 292 var backgroundSize = this.sizeBackground(); 293 var backgroundHeight = backgroundSize.y; 294 var backgroundWidth = backgroundSize.x; 295 296 this.onResizeWin = function () {dialog.sizeBackground()}; 297 Xinha._addEvent(window, 'resize', this.onResizeWin ); 298 299 300 301 var rootElemStyle = rootElem.style; 302 rootElemStyle.display = ''; 303 304 var dialogHeight = rootElem.offsetHeight; 305 var dialogWidth = rootElem.offsetWidth; 306 307 if (dialogHeight > backgroundHeight) 308 { 309 rootElemStyle.height = backgroundHeight + "px"; 310 if (rootElem.scrollHeight > dialogHeight) 311 { 312 rootElemStyle.overflowY = "auto"; 313 } 314 } 315 316 if(this.size.top && this.size.left) 317 { 318 rootElemStyle.top = parseInt(this.size.top,10) + 'px'; 319 rootElemStyle.left = parseInt(this.size.left,10) + 'px'; 373 var top = ( viewportHeight - dialogHeight) / 2; 374 var left = ( viewportWidth - dialogWidth) / 2; 375 rootElemStyle.top = ((top > 0) ? top : 0) +'px'; 376 rootElemStyle.left = ((left > 0) ? left : 0)+'px'; 377 } 378 } 379 this.width = dialogWidth; 380 this.height = dialogHeight; 381 382 if (!modal) 383 { 384 this.sizeBackground({width: dialogWidth + 'px', height: dialogHeight + 'px' }); 385 this.posBackground({top: rootElemStyle.top, left: rootElemStyle.left}); 386 } 387 388 if(typeof values != 'undefined') 389 { 390 this.setValues(values); 391 } 392 this.dialogShown = true; 393 }; 394 395 Xinha.Dialog.prototype.hide = function() 396 { 397 if ( this.attached ) 398 { 399 this.editor.hidePanel(this.rootElem); 320 400 } 321 401 else 322 402 { 323 if (this.editor.btnClickEvent) 324 { 325 var btnClickEvent = this.editor.btnClickEvent; 326 rootElemStyle.top = btnClickEvent.clientY + this.scrollPos.y +'px'; 327 328 if (dialogHeight + rootElem.offsetTop > backgroundHeight) 329 { 330 rootElemStyle.top = this.scrollPos.y; 331 } 332 rootElemStyle.left = btnClickEvent.clientX + this.scrollPos.x +'px'; 333 if (dialogWidth + rootElem.offsetLeft > backgroundWidth) 334 { 335 rootElemStyle.left = btnClickEvent.clientX - dialogWidth + 'px'; 336 if (rootElem.offsetLeft < 0) 337 { 338 rootElemStyle.left = 0; 339 } 340 } 341 this.editor.btnClickEvent = null; 342 } 343 else 344 { 345 var top = ( backgroundHeight - dialogHeight) / 2; 346 var left = ( backgroundWidth - dialogWidth) / 2; 347 rootElemStyle.top = ((top > 0) ? top : 0) +'px'; 348 rootElemStyle.left = ((left > 0) ? left : 0)+'px'; 349 } 350 351 } 352 this.width = dialogWidth; 353 this.height = dialogHeight; 354 355 if (!this.modal) 356 { 357 this.background[0].style.left = rootElemStyle.left; 358 this.background[0].style.top = rootElemStyle.top; 359 this.background[1].style.left = rootElemStyle.left; 360 this.background[1].style.top = rootElemStyle.top; 361 362 this.background[0].style.width = dialogWidth + 'px'; 363 this.background[0].style.height = dialogHeight + 'px'; 364 this.background[1].style.width = dialogWidth + 'px'; 365 this.background[1].style.height = dialogHeight + 'px'; 366 } 367 368 if(typeof values != 'undefined') 369 { 370 this.setValues(values); 371 } 372 this.dialogShown = true; 373 if (this.modal) resetScroll(); 374 }; 375 376 Xinha.Dialog.prototype.hide = function() 377 { 378 this.rootElem.style.display = 'none'; 379 this.background[0].style.display = 'none'; 380 this.background[1].style.display = 'none'; 381 var dialog = this; 382 383 Xinha._removeEvent(window, 'resize', this.onResizeWin); 384 385 if (Xinha.is_gecko && this.modal) 386 { 387 this.editor._textArea.style.display = this._restoreTo[0]; 388 this.editor._iframe.style.visibility = this._restoreTo[1]; 389 this.editor.showPanels(this._restoreTo[2]); 390 } 391 392 if (!this.editor._isFullScreen && this.modal) 393 { 394 if(Xinha.is_ie && document.compatMode == 'CSS1Compat') 395 { 396 var bod = document.getElementsByTagName('html'); 397 } 398 else 399 { 400 var bod = document.getElementsByTagName('body'); 401 } 402 bod[0].style.overflow=''; 403 window.scroll(this.scrollPos.x, this.scrollPos.y); 404 } 405 // Restore the selection 403 this.rootElem.style.display = 'none'; 404 this.hideBackground(); 405 var dialog = this; 406 407 if (Xinha.is_gecko && this.modal) 408 { 409 this.editor._textArea.style.display = this._restoreTo[0]; 410 this.editor._iframe.style.visibility = this._restoreTo[1]; 411 this.editor.showPanels(this._restoreTo[2]); 412 } 413 414 if (!this.editor._isFullScreen && this.modal) 415 { 416 window.scroll(this.scrollPos.x, this.scrollPos.y); 417 } 418 419 if (Xinha.is_ie && !this.modal) 420 { 421 Xinha._removeEvent(this.editor._doc.body,'mouseup', dialog.saveSelection); 422 } 423 424 if (this.modal) 425 { 426 this.editor.activateEditor(); 427 } 428 } 429 // Restore the selection 406 430 this.editor.restoreSelection(this._lastRange); 407 if (Xinha.is_ie && !this.modal) 408 { 409 Xinha._removeEvent(this.editor._doc.body,'mouseup', dialog.saveSelection); 410 } 411 412 if (this.modal) 413 { 414 this.editor.activateEditor(); 415 } 431 416 432 this.dialogShown = false; 417 433 this.editor.updateToolbar(); … … 430 446 } 431 447 }; 448 Xinha.Dialog.prototype.collapse = function() 449 { 450 if(this.collapsed) 451 { 452 this.collapsed = false; 453 this.show(); 454 } 455 else 456 { 457 this.main.style.height = 0; 458 this.collapsed = true; 459 } 460 }; 432 461 433 462 Xinha.Dialog.prototype.getElementById = function(id) … … 443 472 Xinha.Dialog.prototype._dragStart = function (ev) 444 473 { 445 446 var dialog = this; 447 if (dialog.dragging) 474 if ( this.attached || this.dragging) 448 475 { 449 476 return; 450 477 } 478 this.editor.suspendUpdateToolbar = true; 479 var dialog = this; 480 451 481 dialog.dragging = true; 452 482 483 dialog.scrollPos = dialog.editor.scrollPos(); 484 453 485 var st = dialog.rootElem.style; 454 486 … … 456 488 dialog.yOffs = ((Xinha.is_ie) ? window.event.offsetY : ev.layerY); 457 489 458 Xinha._addEvent(document, "mousemove", function(ev) { dialog.dragIt(ev); } ); 459 Xinha._addEvent(document, "mouseup", function (ev) { dialog.dragEnd(ev); } ); 490 dialog.mouseMove = function(ev) { dialog.dragIt(ev); }; 491 Xinha._addEvent(document, "mousemove", dialog.mouseMove ); 492 dialog.mouseUp = function (ev) { dialog.dragEnd(ev); }; 493 Xinha._addEvent(document, "mouseup", dialog.mouseUp); 494 460 495 }; 461 496 … … 470 505 ev = (Xinha.is_ie) ? window.event : ev; 471 506 472 var posY = ev.clientY + this.scrollPos.y; 473 var posX = ev.clientX + this.scrollPos.x; 474 475 var st = dialog.rootElem.style; 476 477 st.left = (posX - dialog.xOffs) + "px"; 478 st.top = (posY - dialog.yOffs) + "px"; 479 480 if (!this.modal) 481 { 482 this.background[0].style.left = st.left; 483 this.background[0].style.top = st.top; 484 this.background[1].style.left = st.left; 485 this.background[1].style.top = st.top; 507 if (dialog.rootElem.style.position == 'absolute') 508 { 509 var posY = (ev.clientY + this.scrollPos.y) - dialog.yOffs + "px"; 510 var posX = (ev.clientX + this.scrollPos.x) - dialog.xOffs + "px"; 511 512 var newPos = {top: posY,left: posX}; 513 } 514 else if (dialog.rootElem.style.position == 'fixed') 515 { 516 var posY = ev.clientY - dialog.yOffs + "px"; 517 var posX = ev.clientX - dialog.xOffs + "px"; 518 519 var newPos = {top: posY,left: posX}; 520 } 521 522 dialog.posDialog(newPos); 523 524 if (!dialog.modal) 525 { 526 dialog.posBackground(newPos); 486 527 } 487 528 }; … … 490 531 { 491 532 var dialog = this; 533 this.editor.suspendUpdateToolbar = false; 534 if (!dialog.dragging) 535 { 536 return false; 537 } 492 538 dialog.dragging = false; 493 539 494 Xinha._removeEvent(document, "mousemove", function(ev) { dialog.dragIt(ev); });495 Xinha._removeEvent(document, "mouseup", function (ev) { dialog.dragEnd(ev); });540 Xinha._removeEvent(document, "mousemove", dialog.mouseMove ); 541 Xinha._removeEvent(document, "mouseup", dialog.mouseUp ); 496 542 497 543 dialog.size.top = dialog.rootElem.style.top; 498 dialog.size.left =dialog.rootElem.style.left; 499 }; 544 dialog.size.left = dialog.rootElem.style.left; 545 }; 546 500 547 501 548 Xinha.Dialog.prototype._resizeStart = function (ev) { 502 549 var dialog = this; 503 550 this.editor.suspendUpdateToolbar = true; 504 551 if (dialog.resizing) 505 552 { … … 507 554 } 508 555 dialog.resizing = true; 509 556 dialog.scrollPos = dialog.editor.scrollPos(); 557 510 558 var st = dialog.rootElem.style; 511 559 st.minHeight = ''; … … 514 562 dialog.yOffs = parseInt(st.top,10); 515 563 516 Xinha._addEvent(document, "mousemove", function(ev) { dialog.resizeIt(ev); } ); 517 Xinha._addEvent(document, "mouseup", function (ev) { dialog.resizeEnd(ev); } ); 564 dialog.mouseMove = function(ev) { dialog.resizeIt(ev); }; 565 Xinha._addEvent(document, "mousemove", dialog.mouseMove ); 566 dialog.mouseUp = function (ev) { dialog.resizeEnd(ev); }; 567 Xinha._addEvent(document, "mouseup", dialog.mouseUp); 568 518 569 }; 519 570 … … 526 577 } 527 578 528 var posY = ev.clientY + dialog.scrollPos.y; 529 var posX = ev.clientX + dialog.scrollPos.x; 530 531 var st = dialog.rootElem.style; 532 533 posX = posX - dialog.xOffs; 534 posY = posY - dialog.yOffs; 535 536 st.width = (( posX > 10) ? posX : 10) + "px"; 537 st.height = (( posY > 10) ? posY : 10) + "px"; 538 579 if (dialog.rootElem.style.position == 'absolute') 580 { 581 var posY = ev.clientY + dialog.scrollPos.y; 582 var posX = ev.clientX + dialog.scrollPos.x; 583 } 584 else 585 { 586 var posY = ev.clientY; 587 var posX = ev.clientX; 588 } 589 590 posX -= dialog.xOffs; 591 posY -= dialog.yOffs; 592 593 var newSize = {}; 594 newSize.width = (( posX > 10) ? posX : 10) + 8 + "px"; 595 newSize.height = (( posY > 10) ? posY : 10) + "px"; 596 597 dialog.sizeDialog(newSize); 598 599 if (!this.modal) 600 { 601 dialog.resizeBackground(newSize); 602 } 603 539 604 dialog.width = dialog.rootElem.offsetWidth; 540 605 dialog.height = dialog.rootElem.offsetHeight; 541 606 542 if (!this.modal)543 {544 this.background[0].style.width = st.width ;545 this.background[0].style.height = st.height;546 this.background[1].style.width = st.width ;547 this.background[1].style.height = st.height;548 }549 607 dialog.onresize(); 550 608 }; … … 554 612 var dialog = this; 555 613 dialog.resizing = false; 556 557 Xinha._removeEvent(document, "mousemove", function(ev) { dialog.resizeIt(ev); } ); 558 Xinha._removeEvent(document, "mouseup", function (ev) { dialog.resizeEnd(ev); } ); 559 614 this.editor.suspendUpdateToolbar = false; 615 616 Xinha._removeEvent(document, "mousemove", dialog.mouseMove ); 617 Xinha._removeEvent(document, "mouseup", dialog.mouseUp ); 618 560 619 dialog.size.width = dialog.rootElem.offsetWidth; 561 620 dialog.size.height = dialog.rootElem.offsetHeight; 562 621 }; 563 622 623 Xinha.Dialog.prototype.attachToPanel = function(side) 624 { 625 var dialog = this; 626 var rootElem = this.rootElem; 627 var editor = this.editor; 628 629 this.attached = true; 630 this.rootElem.side = side; 631 this.captionBar.ondblclick = function(ev) { dialog.detachFromPanel(ev ? ev :window.event); }; 632 633 rootElem.style.position = "static"; 634 rootElem.parentNode.removeChild(rootElem); 635 636 this.captionBar.style.paddingLeft = "3px"; 637 this.resizer.style.display = 'none'; 638 if ( this.closable ) this.closer.style.display = 'none'; 639 this.icon.style.display = 'none'; 640 641 if ( side == 'left' || side == 'right' ) 642 { 643 rootElem.style.width = editor.config.panel_dimensions[side]; 644 } 645 else 646 { 647 rootElem.style.width = ''; 648 } 649 Xinha.addClasses(rootElem, 'panel'); 650 editor._panels[side].panels.push(rootElem); 651 editor._panels[side].div.appendChild(rootElem); 652 653 editor.notifyOf('panel_change', {'action':'add','panel':rootElem}); 654 }; 655 656 Xinha.Dialog.prototype.detachFromPanel = function(ev) 657 { 658 var dialog = this; 659 var rootElem = dialog.rootElem; 660 var editor = dialog.editor; 661 662 dialog.attached = false; 663 664 rootElem.style.position = "absolute"; 665 666 dialog.captionBar.style.paddingLeft = "22px"; 667 dialog.resizer.style.display = ''; 668 if ( dialog.closable ) dialog.closer.style.display = ''; 669 dialog.icon.style.display = ''; 670 671 672 if ( dialog.size.width ) rootElem.style.width = dialog.size.width + 'px'; 673 674 Xinha.removeClasses(rootElem, 'panel'); 675 editor.removePanel(rootElem); 676 document.body.appendChild(rootElem); 677 678 if (ev) 679 { 680 var scrollPos = dialog.editor.scrollPos(); 681 rootElem.style.top = (ev.clientY + scrollPos.y) - ((Xinha.is_ie) ? window.event.offsetY : ev.layerY) + "px"; 682 rootElem.style.left =(ev.clientX + scrollPos.x) - ((Xinha.is_ie) ? window.event.offsetX : ev.layerX) + "px"; 683 } 684 dialog.captionBar.ondblclick = function() { dialog.attachToPanel(rootElem.side); }; 685 686 }; 687 688 Xinha.Dialog.prototype.hideBackground = function() 689 { 690 this.background[0].style.display = 'none'; 691 this.background[1].style.display = 'none'; 692 } 693 Xinha.Dialog.prototype.showBackground = function() 694 { 695 this.background[0].style.display = ''; 696 this.background[1].style.display = ''; 697 } 698 Xinha.Dialog.prototype.posBackground = function(pos) 699 { 700 this.background[0].style.top = pos.top; 701 this.background[0].style.left = pos.left; 702 this.background[1].style.top = pos.top; 703 this.background[1].style.left = pos.left; 704 } 705 Xinha.Dialog.prototype.resizeBackground = function(size) 706 { 707 this.background[0].style.width = size.width; 708 this.background[0].style.height = size.height; 709 this.background[1].style.width = size.width; 710 this.background[1].style.height = size.height; 711 } 712 Xinha.Dialog.prototype.posDialog = function(pos) 713 { 714 var st = this.rootElem.style; 715 st.left = pos.left; 716 st.top = pos.top; 717 } 718 Xinha.Dialog.prototype.sizeDialog = function(size) 719 { 720 var st = this.rootElem.style; 721 st.height = size.height; 722 st.width = size.width; 723 this.main.style.height = parseInt(size.height,10) - this.captionBar.offsetHeight + "px"; 724 this.main.style.width = size.width; 725 726 } 564 727 Xinha.Dialog.prototype.setValues = function(values) 565 728 { … … 594 757 break; 595 758 } 596 597 759 598 760 case 'textarea': … … 781 943 } 782 944 783 Xinha.PanelDialog = function(editor, side, html, localizer)784 {785 this.id = { };786 this.r_id = { }; // reverse lookup id787 this.editor = editor;788 this.document = document;789 this.rootElem = editor.addPanel(side);790 791 var dialog = this;792 if(typeof localizer == 'function')793 {794 this._lc = localizer;795 }796 else if(localizer)797 {798 this._lc = function(string)799 {800 return Xinha._lc(string,localizer);801 };802 }803 else804 {805 this._lc = function(string)806 {807 return string;808 };809 }810 811 html = html.replace(/\[([a-z0-9_]+)\]/ig,812 function(fullString, id)813 {814 if(typeof dialog.id[id] == 'undefined')815 {816 dialog.id[id] = Xinha.uniq('Dialog');817 dialog.r_id[dialog.id[id]] = id;818 }819 return dialog.id[id];820 }821 ).replace(/<l10n>(.*?)<\/l10n>/ig,822 function(fullString,translate)823 {824 return dialog._lc(translate) ;825 }826 ).replace(/="_\((.*?)\)"/g,827 function(fullString, translate)828 {829 return '="' + dialog._lc(translate) + '"';830 }831 );832 833 this.rootElem.innerHTML = html;834 };835 836 Xinha.PanelDialog.prototype.show = function(values)837 {838 this.editor.showPanel(this.rootElem);839 };840 841 Xinha.PanelDialog.prototype.hide = function()842 {843 this.editor.hidePanel(this.rootElem);844 return this.getValues();845 };846 847 Xinha.PanelDialog.prototype.onresize = Xinha.Dialog.prototype.onresize;848 849 Xinha.PanelDialog.prototype.toggle = Xinha.Dialog.prototype.toggle;850 851 Xinha.PanelDialog.prototype.setValues = Xinha.Dialog.prototype.setValues;852 853 Xinha.PanelDialog.prototype.getValues = Xinha.Dialog.prototype.getValues;854 855 Xinha.PanelDialog.prototype.getElementById = Xinha.Dialog.prototype.getElementById;856 857 Xinha.PanelDialog.prototype.getElementsByName = Xinha.Dialog.prototype.getElementsByName; -
branches/ray/plugins/CharacterMap/CharacterMap.css
r761 r786 1 .CharacterMap { } 1 .CharacterMap { 2 background-color:white; 3 } 2 4 .CharacterMap a.entity { 3 5 font-size:12px; -
branches/ray/plugins/CharacterMap/character-map.js
r782 r786 1 // Character Map plugin for HTMLArea1 // Character Map plugin for Xinha 2 2 // Original Author - Bernhard Pfeifer novocaine@gmx.net 3 HTMLArea.loadStyle( 'CharacterMap.css', 'CharacterMap' );3 Xinha.loadStyle( 'CharacterMap.css', 'CharacterMap' ); 4 4 5 5 function CharacterMap( editor ) … … 11 11 { 12 12 id : 'insertcharacter', 13 tooltip : HTMLArea._lc( 'Insert special character', 'CharacterMap' ),13 tooltip : Xinha._lc( 'Insert special character', 'CharacterMap' ), 14 14 image : editor.imgURL( 'ed_charmap.gif', 'CharacterMap' ), 15 15 textMode : false, … … 19 19 cfg.addToolbarElement('insertcharacter', 'createlink', -1); 20 20 21 if ( cfg.CharacterMap.mode == 'panel' )22 {23 //editor._CharacterMap = editor.addPanel( 'right' );24 // HTMLArea._addClass( editor._CharacterMap, 'CharacterMap' );25 26 27 /* editor.notifyOn( 'modechange',28 function( e, args )29 {30 if ( args.mode == 'text' ) editor.hidePanel( editor._CharacterMap );31 }32 );*/33 34 35 //editor.hidePanel( editor._CharacterMap );36 }37 21 } 38 22 39 23 // configuration mode : panel or popup 40 HTMLArea.Config.prototype.CharacterMap =24 Xinha.Config.prototype.CharacterMap = 41 25 { 42 26 'mode': 'popup' // configuration mode : panel or popup … … 57 41 CharacterMap._isActive = false; 58 42 59 CharacterMap.prototype.buttonPress = function( editor )60 {61 var cfg = editor.config;62 if ( cfg.CharacterMap.mode == 'panel' )63 {64 if ( this._isActive )65 {66 this._isActive = false;67 editor.hidePanel( editor._CharacterMap );68 }69 else70 {71 this._isActive = true;72 editor.showPanel( editor._CharacterMap );73 }74 }75 else76 {77 editor._popupDialog( "plugin://CharacterMap/select_character", function( entity )78 {79 if ( !entity ) return false;80 if ( HTMLArea.is_ie ) editor.focusEditor();81 editor.insertHTML( entity );82 }, null);83 }84 };85 43 86 44 CharacterMap.prototype.addEntity = function ( entite, pos ) … … 89 47 var self = this; 90 48 var a = document.createElement( 'a' ); 91 HTMLArea._addClass( a, 'entity' );49 Xinha._addClass( a, 'entity' ); 92 50 a.innerHTML = entite; 93 51 a.href = 'javascript:void(0)'; 94 HTMLArea._addClass(a, (pos%2)? 'light':'dark');52 Xinha._addClass(a, (pos%2)? 'light':'dark'); 95 53 a.onclick = function() 96 54 { 97 if ( HTMLArea.is_ie) editor.focusEditor();55 if (Xinha.is_ie) editor.focusEditor(); 98 56 editor.insertHTML( entite ); 99 57 //self._isActive = false; … … 115 73 var editor = this.editor; 116 74 117 if(!this.html) // retrieve the raw dialog contents 118 { 119 Xinha._getback(_editor_url + 'plugins/CharacterMap/dialog.html', function(getback) { self.html = getback; self._prepareDialog(); }); 120 return; 121 } 75 var html = '<h1><l10n>Insert special character</l10n></h1>'; 122 76 123 77 // Now we have everything we need, so we can build the dialog. 124 this.dialog = new Xinha.Dialog(editor, this.html, 'CharacterMap',{width:300},false); 125 HTMLArea._addClass( this.dialog.rootElem, 'CharacterMap' ); 78 this.dialog = new Xinha.Dialog(editor, html, 'CharacterMap',{width:300},{modal:false}); 79 Xinha._addClass( this.dialog.rootElem, 'CharacterMap' ); 80 81 if (editor.config.CharacterMap.mode == 'panel') this.dialog.attachToPanel('right'); 82 126 83 var entites = 127 84 [ … … 153 110 CharacterMap.prototype.show = function() 154 111 { 155 if(!this.ready) // if the user is too fast clicking the, we have to make them wait112 if(!this.ready) // if the user is too fast clicking the, we have to make them wait 156 113 { 157 114 var self = this; … … 159 116 return; 160 117 } 161 162 this.dialog.show(); 163 118 this.dialog.toggle(); 164 119 }; 165 120 CharacterMap.prototype.hide = function() -
branches/ray/plugins/SmartReplace/smart-replace.js
r774 r786 302 302 303 303 // Now we have everything we need, so we can build the dialog. 304 this.dialog = new Xinha.Dialog(editor, this.html, 'SmartReplace',{width:300}); 304 this.dialog = new Xinha.Dialog(editor, this.html, 'SmartReplace',{},{modal:false}); 305 this.dialog.attachToPanel('top'); 305 306 this.ready = true; 306 307 }; -
branches/ray/plugins/Stylist/stylist.js
r784 r786 66 66 Xinha.prototype._fillStylist = function() 67 67 { 68 if(!this._stylist) return false; 69 this.plugins.Stylist.instance.main.innerHTML = ''; 68 if(!this.plugins.Stylist.instance.dialog) return false; 69 var main = this.plugins.Stylist.instance.dialog.main; 70 main.innerHTML = ''; 70 71 71 72 var may_apply = true; … … 307 308 } 308 309 309 this.plugins.Stylist.instance.main.appendChild(anch);310 main.appendChild(anch); 310 311 } 311 312 } … … 776 777 var editor = this.editor; 777 778 var stylist = this; 779 780 var html = '<h1><l10n>Styles</l10n></h1>'; 778 781 779 editor._stylist = null; // This needs to be changes to be Stylist::_stylist sometime 780 editor._stylist = editor.addPanel('right'); 781 Xinha.addClass(editor._stylist, 'stylist'); 782 783 this.caption = document.createElement("h1"); 784 this.caption.innerHTML = Xinha._lc('Styles', 'Stylist'); 785 editor._stylist.appendChild(this.caption); 786 this.main = document.createElement("div"); 787 this.main.style.overflow = "auto"; 788 this.main.style.height = this.editor._framework.ed_cell.offsetHeight - this.caption.offsetHeight + 'px'; 789 790 editor._stylist.appendChild(this.main); 791 792 Xinha.freeLater(this,"caption"); 793 Xinha.freeLater(this,"main"); 794 795 editor.notifyOn('modechange', 796 function(e,args) 797 { 798 switch(args.mode) 799 { 800 case 'text': 801 { 802 editor.hidePanel(editor._stylist); 803 break; 804 } 805 case 'wysiwyg': 806 { 807 editor.showPanel(editor._stylist); 808 break; 809 } 810 } 811 } 812 ); 813 editor.notifyOn('panel_change', 814 function(e,args) 815 { 816 switch (args.action) 817 { 818 case 'show': 819 var newHeight = stylist.main.offsetHeight - args.panel.offsetHeight; 820 stylist.main.style.height = ((newHeight > 0) ? stylist.main.offsetHeight - args.panel.offsetHeight : 0) + 'px'; 821 editor._stylist.style.height = stylist.caption.offsetHeight + "px"; 822 editor.sizeEditor(); 823 break; 824 case 'hide': 825 stylist.resize(); 826 break; 827 } 828 } 829 ); 830 editor.notifyOn('before_resize', 831 function() 832 { 833 editor._stylist.style.height = stylist.caption.offsetHeight + "px"; 834 } 835 ); 836 editor.notifyOn('resize', 837 function() 838 { 839 stylist.resize(); 840 } 841 ); 782 this.dialog = new Xinha.Dialog(editor, html, 'Stylist',{width:200},{modal:false,closable:false}); 783 Xinha._addClass( this.dialog.rootElem, 'Stylist' ); 784 this.dialog.attachToPanel('right'); 785 this.dialog.show(); 786 787 var dialog = this.dialog; 788 var main = this.dialog.main; 789 var caption = this.dialog.captionBar; 790 791 main.style.overflow = "auto"; 792 main.style.height = this.editor._framework.ed_cell.offsetHeight - caption.offsetHeight + 'px'; 793 794 editor.notifyOn('modechange', 795 function(e,args) 796 { 797 if (!dialog.attached) 798 { 799 return; 800 } 801 switch(args.mode) 802 { 803 case 'text': 804 { 805 dialog.hide(); 806 break; 807 } 808 case 'wysiwyg': 809 { 810 dialog.show(); 811 break; 812 } 813 } 814 } 815 ); 816 editor.notifyOn('panel_change', 817 function(e,args) 818 { 819 if (!dialog.attached) 820 { 821 return; 822 } 823 switch (args.action) 824 { 825 case 'show': 826 var newHeight = main.offsetHeight - args.panel.offsetHeight; 827 main.style.height = ((newHeight > 0) ? main.offsetHeight - args.panel.offsetHeight : 0) + 'px'; 828 dialog.rootElem.style.height = caption.offsetHeight + "px"; 829 editor.sizeEditor(); 830 break; 831 case 'hide': 832 stylist.resize(); 833 break; 834 } 835 } 836 ); 837 editor.notifyOn('before_resize', 838 function() 839 { 840 if (!dialog.attached) 841 { 842 return; 843 } 844 dialog.rootElem.style.height = caption.offsetHeight + "px"; 845 } 846 ); 847 editor.notifyOn('resize', 848 function() 849 { 850 if (!dialog.attached) 851 { 852 return; 853 } 854 stylist.resize(); 855 } 856 ); 842 857 } 843 858 Stylist.prototype.resize = function() 844 859 { 845 860 var editor = this.editor; 846 var panelContainer = editor._stylist.parentNode; 861 var rootElem = this.dialog.rootElem; 862 var panelContainer = rootElem.parentNode; 847 863 848 864 var newSize = panelContainer.offsetHeight; 849 865 for (var i=0; i < panelContainer.childNodes.length;++i) 850 866 { 851 if (panelContainer.childNodes[i] ==editor._stylist|| !panelContainer.childNodes[i].offsetHeight)867 if (panelContainer.childNodes[i] == rootElem || !panelContainer.childNodes[i].offsetHeight) 852 868 { 853 869 continue; … … 855 871 newSize -= panelContainer.childNodes[i].offsetHeight; 856 872 } 857 editor._stylist.style.height = newSize-5 + 'px';858 this. main.style.height = newSize - this.caption.offsetHeight -5 + 'px';873 rootElem.style.height = newSize-5 + 'px'; 874 this.dialog.main.style.height = newSize - this.dialog.captionBar.offsetHeight -5 + 'px'; 859 875 } 860 876 861 877 Stylist.prototype.onUpdateToolbar = function() 862 878 { 863 if(this. editor._stylist)879 if(this.dialog) 864 880 { 865 881 if(this._timeoutID)
