| 1 |
/* |
| 2 |
|
| 3 |
* FCKeditor - The text editor for Internet - http://www.fckeditor.net |
| 4 |
|
| 5 |
* Copyright (C) 2003-2009 Frederico Caldeira Knabben |
| 6 |
|
| 7 |
* |
| 8 |
|
| 9 |
* == BEGIN LICENSE == |
| 10 |
|
| 11 |
* |
| 12 |
|
| 13 |
* Licensed under the terms of any of the following licenses at your |
| 14 |
|
| 15 |
* choice: |
| 16 |
|
| 17 |
* |
| 18 |
|
| 19 |
* - GNU General Public License Version 2 or later (the "GPL") |
| 20 |
|
| 21 |
* http://www.gnu.org/licenses/gpl.html |
| 22 |
|
| 23 |
* |
| 24 |
|
| 25 |
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL") |
| 26 |
|
| 27 |
* http://www.gnu.org/licenses/lgpl.html |
| 28 |
|
| 29 |
* |
| 30 |
|
| 31 |
* - Mozilla Public License Version 1.1 or later (the "MPL") |
| 32 |
|
| 33 |
* http://www.mozilla.org/MPL/MPL-1.1.html |
| 34 |
|
| 35 |
* |
| 36 |
|
| 37 |
* == END LICENSE == |
| 38 |
|
| 39 |
* |
| 40 |
|
| 41 |
* Component that creates floating panels. It is used by many |
| 42 |
|
| 43 |
* other components, like the toolbar items, context menu, etc... |
| 44 |
|
| 45 |
*/ |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
var FCKPanel = function( parentWindow ) |
| 50 |
|
| 51 |
{ |
| 52 |
|
| 53 |
this.IsRTL = ( FCKLang.Dir == 'rtl' ) ; |
| 54 |
|
| 55 |
this.IsContextMenu = false ; |
| 56 |
|
| 57 |
this._LockCounter = 0 ; |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
this._Window = parentWindow || window ; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
var oDocument ; |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
if ( FCKBrowserInfo.IsIE ) |
| 70 |
|
| 71 |
{ |
| 72 |
|
| 73 |
// Create the Popup that will hold the panel. |
| 74 |
|
| 75 |
// The popup has to be created before playing with domain hacks, see #1666. |
| 76 |
|
| 77 |
this._Popup = this._Window.createPopup() ; |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
// this._Window cannot be accessed while playing with domain hacks, but local variable is ok. |
| 82 |
|
| 83 |
// See #1666. |
| 84 |
|
| 85 |
var pDoc = this._Window.document ; |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
// This is a trick to IE6 (not IE7). The original domain must be set |
| 90 |
|
| 91 |
// before creating the popup, so we are able to take a refence to the |
| 92 |
|
| 93 |
// document inside of it, and the set the proper domain for it. (#123) |
| 94 |
|
| 95 |
if ( FCK_IS_CUSTOM_DOMAIN && !FCKBrowserInfo.IsIE7 ) |
| 96 |
|
| 97 |
{ |
| 98 |
|
| 99 |
pDoc.domain = FCK_ORIGINAL_DOMAIN ; |
| 100 |
|
| 101 |
document.domain = FCK_ORIGINAL_DOMAIN ; |
| 102 |
|
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
oDocument = this.Document = this._Popup.document ; |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
// Set the proper domain inside the popup. |
| 112 |
|
| 113 |
if ( FCK_IS_CUSTOM_DOMAIN ) |
| 114 |
|
| 115 |
{ |
| 116 |
|
| 117 |
oDocument.domain = FCK_RUNTIME_DOMAIN ; |
| 118 |
|
| 119 |
pDoc.domain = FCK_RUNTIME_DOMAIN ; |
| 120 |
|
| 121 |
document.domain = FCK_RUNTIME_DOMAIN ; |
| 122 |
|
| 123 |
} |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
FCK.IECleanup.AddItem( this, FCKPanel_Cleanup ) ; |
| 128 |
|
| 129 |
} |
| 130 |
|
| 131 |
else |
| 132 |
|
| 133 |
{ |
| 134 |
|
| 135 |
var oIFrame = this._IFrame = this._Window.document.createElement('iframe') ; |
| 136 |
|
| 137 |
FCKTools.ResetStyles( oIFrame ); |
| 138 |
|
| 139 |
oIFrame.src = 'javascript:void(0)' ; |
| 140 |
|
| 141 |
oIFrame.allowTransparency = true ; |
| 142 |
|
| 143 |
oIFrame.frameBorder = '0' ; |
| 144 |
|
| 145 |
oIFrame.scrolling = 'no' ; |
| 146 |
|
| 147 |
oIFrame.style.width = oIFrame.style.height = '0px' ; |
| 148 |
|
| 149 |
FCKDomTools.SetElementStyles( oIFrame, |
| 150 |
|
| 151 |
{ |
| 152 |
|
| 153 |
position : 'absolute', |
| 154 |
|
| 155 |
zIndex : FCKConfig.FloatingPanelsZIndex |
| 156 |
|
| 157 |
} ) ; |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
this._Window.document.body.appendChild( oIFrame ) ; |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
var oIFrameWindow = oIFrame.contentWindow ; |
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
oDocument = this.Document = oIFrameWindow.document ; |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
// Workaround for Safari 12256. Ticket #63 |
| 174 |
|
| 175 |
var sBase = '' ; |
| 176 |
|
| 177 |
if ( FCKBrowserInfo.IsSafari ) |
| 178 |
|
| 179 |
sBase = '<base href="' + window.document.location + '">' ; |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
// Initialize the IFRAME document body. |
| 184 |
|
| 185 |
oDocument.open() ; |
| 186 |
|
| 187 |
oDocument.write( '<html><head>' + sBase + '<\/head><body style="margin:0px;padding:0px;"><\/body><\/html>' ) ; |
| 188 |
|
| 189 |
oDocument.close() ; |
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
if( FCKBrowserInfo.IsAIR ) |
| 194 |
|
| 195 |
FCKAdobeAIR.Panel_Contructor( oDocument, window.document.location ) ; |
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
FCKTools.AddEventListenerEx( oIFrameWindow, 'focus', FCKPanel_Window_OnFocus, this ) ; |
| 200 |
|
| 201 |
FCKTools.AddEventListenerEx( oIFrameWindow, 'blur', FCKPanel_Window_OnBlur, this ) ; |
| 202 |
|
| 203 |
} |
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
oDocument.dir = FCKLang.Dir ; |
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
FCKTools.AddEventListener( oDocument, 'contextmenu', FCKTools.CancelEvent ) ; |
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
// Create the main DIV that is used as the panel base. |
| 218 |
|
| 219 |
this.MainNode = oDocument.body.appendChild( oDocument.createElement('DIV') ) ; |
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
// The "float" property must be set so Firefox calculates the size correctly. |
| 224 |
|
| 225 |
this.MainNode.style.cssFloat = this.IsRTL ? 'right' : 'left' ; |
| 226 |
|
| 227 |
} |
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
FCKPanel.prototype.AppendStyleSheet = function( styleSheet ) |
| 234 |
|
| 235 |
{ |
| 236 |
|
| 237 |
FCKTools.AppendStyleSheet( this.Document, styleSheet ) ; |
| 238 |
|
| 239 |
} |
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
FCKPanel.prototype.Preload = function( x, y, relElement ) |
| 244 |
|
| 245 |
{ |
| 246 |
|
| 247 |
// The offsetWidth and offsetHeight properties are not available if the |
| 248 |
|
| 249 |
// element is not visible. So we must "show" the popup with no size to |
| 250 |
|
| 251 |
// be able to use that values in the second call (IE only). |
| 252 |
|
| 253 |
if ( this._Popup ) |
| 254 |
|
| 255 |
this._Popup.show( x, y, 0, 0, relElement ) ; |
| 256 |
|
| 257 |
} |
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
// Workaround for IE7 problem. See #1982 |
| 262 |
|
| 263 |
// Submenus are restricted to the size of its parent, so we increase it as needed. |
| 264 |
|
| 265 |
// Returns true if the panel has been repositioned |
| 266 |
|
| 267 |
FCKPanel.prototype.ResizeForSubpanel = function( panel, width, height ) |
| 268 |
|
| 269 |
{ |
| 270 |
|
| 271 |
if ( !FCKBrowserInfo.IsIE7 ) |
| 272 |
|
| 273 |
return false ; |
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
if ( !this._Popup.isOpen ) |
| 278 |
|
| 279 |
{ |
| 280 |
|
| 281 |
this.Subpanel = null ; |
| 282 |
|
| 283 |
return false ; |
| 284 |
|
| 285 |
} |
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
// If we are resetting the extra space |
| 290 |
|
| 291 |
if ( width == 0 && height == 0 ) |
| 292 |
|
| 293 |
{ |
| 294 |
|
| 295 |
// Another subpanel is being shown, so we must not shrink back |
| 296 |
|
| 297 |
if (this.Subpanel !== panel) |
| 298 |
|
| 299 |
return false ; |
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
// Reset values. |
| 304 |
|
| 305 |
// We leave the IncreasedY untouched to avoid vertical movement of the |
| 306 |
|
| 307 |
// menu if the submenu is higher than the main menu. |
| 308 |
|
| 309 |
this.Subpanel = null ; |
| 310 |
|
| 311 |
this.IncreasedX = 0 ; |
| 312 |
|
| 313 |
} |
| 314 |
|
| 315 |
else |
| 316 |
|
| 317 |
{ |
| 318 |
|
| 319 |
this.Subpanel = panel ; |
| 320 |
|
| 321 |
// If the panel has already been increased enough, get out |
| 322 |
|
| 323 |
if ( ( this.IncreasedX >= width ) && ( this.IncreasedY >= height ) ) |
| 324 |
|
| 325 |
return false ; |
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
this.IncreasedX = Math.max( this.IncreasedX, width ) ; |
| 330 |
|
| 331 |
this.IncreasedY = Math.max( this.IncreasedY, height ) ; |
| 332 |
|
| 333 |
} |
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
var x = this.ShowRect.x ; |
| 338 |
|
| 339 |
var w = this.IncreasedX ; |
| 340 |
|
| 341 |
if ( this.IsRTL ) |
| 342 |
|
| 343 |
x = x - w ; |
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
// Horizontally increase as needed (sum of widths). |
| 348 |
|
| 349 |
// Vertically, use only the maximum of this menu or the submenu |
| 350 |
|
| 351 |
var finalWidth = this.ShowRect.w + w ; |
| 352 |
|
| 353 |
var finalHeight = Math.max( this.ShowRect.h, this.IncreasedY ) ; |
| 354 |
|
| 355 |
if ( this.ParentPanel ) |
| 356 |
|
| 357 |
this.ParentPanel.ResizeForSubpanel( this, finalWidth, finalHeight ) ; |
| 358 |
|
| 359 |
this._Popup.show( x, this.ShowRect.y, finalWidth, finalHeight, this.RelativeElement ) ; |
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
return this.IsRTL ; |
| 364 |
|
| 365 |
} |
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
FCKPanel.prototype.Show = function( x, y, relElement, width, height ) |
| 370 |
|
| 371 |
{ |
| 372 |
|
| 373 |
var iMainWidth ; |
| 374 |
|
| 375 |
var eMainNode = this.MainNode ; |
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
if ( this._Popup ) |
| 380 |
|
| 381 |
{ |
| 382 |
|
| 383 |
// The offsetWidth and offsetHeight properties are not available if the |
| 384 |
|
| 385 |
// element is not visible. So we must "show" the popup with no size to |
| 386 |
|
| 387 |
// be able to use that values in the second call. |
| 388 |
|
| 389 |
this._Popup.show( x, y, 0, 0, relElement ) ; |
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
// The following lines must be place after the above "show", otherwise it |
| 394 |
|
| 395 |
// doesn't has the desired effect. |
| 396 |
|
| 397 |
FCKDomTools.SetElementStyles( eMainNode, |
| 398 |
|
| 399 |
{ |
| 400 |
|
| 401 |
width : width ? width + 'px' : '', |
| 402 |
|
| 403 |
height : height ? height + 'px' : '' |
| 404 |
|
| 405 |
} ) ; |
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
iMainWidth = eMainNode.offsetWidth ; |
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
if ( FCKBrowserInfo.IsIE7 ) |
| 414 |
|
| 415 |
{ |
| 416 |
|
| 417 |
if (this.ParentPanel && this.ParentPanel.ResizeForSubpanel(this, iMainWidth, eMainNode.offsetHeight) ) |
| 418 |
|
| 419 |
{ |
| 420 |
|
| 421 |
// As the parent has moved, allow the browser to update its internal data, so the new position is correct. |
| 422 |
|
| 423 |
FCKTools.RunFunction( this.Show, this, [x, y, relElement] ) ; |
| 424 |
|
| 425 |
return ; |
| 426 |
|
| 427 |
} |
| 428 |
|
| 429 |
} |
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
if ( this.IsRTL ) |
| 434 |
|
| 435 |
{ |
| 436 |
|
| 437 |
if ( this.IsContextMenu ) |
| 438 |
|
| 439 |
x = x - iMainWidth + 1 ; |
| 440 |
|
| 441 |
else if ( relElement ) |
| 442 |
|
| 443 |
x = ( x * -1 ) + relElement.offsetWidth - iMainWidth ; |
| 444 |
|
| 445 |
} |
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
if ( FCKBrowserInfo.IsIE7 ) |
| 450 |
|
| 451 |
{ |
| 452 |
|
| 453 |
// Store the values that will be used by the ResizeForSubpanel function |
| 454 |
|
| 455 |
this.ShowRect = {x:x, y:y, w:iMainWidth, h:eMainNode.offsetHeight} ; |
| 456 |
|
| 457 |
this.IncreasedX = 0 ; |
| 458 |
|
| 459 |
this.IncreasedY = 0 ; |
| 460 |
|
| 461 |
this.RelativeElement = relElement ; |
| 462 |
|
| 463 |
} |
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
// Second call: Show the Popup at the specified location, with the correct size. |
| 468 |
|
| 469 |
this._Popup.show( x, y, iMainWidth, eMainNode.offsetHeight, relElement ) ; |
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
if ( this.OnHide ) |
| 474 |
|
| 475 |
{ |
| 476 |
|
| 477 |
if ( this._Timer ) |
| 478 |
|
| 479 |
CheckPopupOnHide.call( this, true ) ; |
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
this._Timer = FCKTools.SetInterval( CheckPopupOnHide, 100, this ) ; |
| 484 |
|
| 485 |
} |
| 486 |
|
| 487 |
} |
| 488 |
|
| 489 |
else |
| 490 |
|
| 491 |
{ |
| 492 |
|
| 493 |
// Do not fire OnBlur while the panel is opened. |
| 494 |
|
| 495 |
if ( typeof( FCK.ToolbarSet.CurrentInstance.FocusManager ) != 'undefined' ) |
| 496 |
|
| 497 |
FCK.ToolbarSet.CurrentInstance.FocusManager.Lock() ; |
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
if ( this.ParentPanel ) |
| 502 |
|
| 503 |
{ |
| 504 |
|
| 505 |
this.ParentPanel.Lock() ; |
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
// Due to a bug on FF3, we must ensure that the parent panel will |
| 510 |
|
| 511 |
// blur (#1584). |
| 512 |
|
| 513 |
FCKPanel_Window_OnBlur( null, this.ParentPanel ) ; |
| 514 |
|
| 515 |
} |
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
// Toggle the iframe scrolling attribute to prevent the panel |
| 520 |
|
| 521 |
// scrollbars from disappearing in FF Mac. (#191) |
| 522 |
|
| 523 |
if ( FCKBrowserInfo.IsGecko && FCKBrowserInfo.IsMac ) |
| 524 |
|
| 525 |
{ |
| 526 |
|
| 527 |
this._IFrame.scrolling = '' ; |
| 528 |
|
| 529 |
FCKTools.RunFunction( function(){ this._IFrame.scrolling = 'no'; }, this ) ; |
| 530 |
|
| 531 |
} |
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
// Be sure we'll not have more than one Panel opened at the same time. |
| 536 |
|
| 537 |
// Do not unlock focus manager here because we're displaying another floating panel |
| 538 |
|
| 539 |
// instead of returning the editor to a "no panel" state (Bug #1514). |
| 540 |
|
| 541 |
if ( FCK.ToolbarSet.CurrentInstance.GetInstanceObject( 'FCKPanel' )._OpenedPanel && |
| 542 |
|
| 543 |
FCK.ToolbarSet.CurrentInstance.GetInstanceObject( 'FCKPanel' )._OpenedPanel != this ) |
| 544 |
|
| 545 |
FCK.ToolbarSet.CurrentInstance.GetInstanceObject( 'FCKPanel' )._OpenedPanel.Hide( false, true ) ; |
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
FCKDomTools.SetElementStyles( eMainNode, |
| 550 |
|
| 551 |
{ |
| 552 |
|
| 553 |
width : width ? width + 'px' : '', |
| 554 |
|
| 555 |
height : height ? height + 'px' : '' |
| 556 |
|
| 557 |
} ) ; |
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
iMainWidth = eMainNode.offsetWidth ; |
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
if ( !width ) this._IFrame.width = 1 ; |
| 566 |
|
| 567 |
if ( !height ) this._IFrame.height = 1 ; |
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
// This is weird... but with Firefox, we must get the offsetWidth before |
| 572 |
|
| 573 |
// setting the _IFrame size (which returns "0"), and then after that, |
| 574 |
|
| 575 |
// to return the correct width. Remove the first step and it will not |
| 576 |
|
| 577 |
// work when the editor is in RTL. |
| 578 |
|
| 579 |
// |
| 580 |
|
| 581 |
// The "|| eMainNode.firstChild.offsetWidth" part has been added |
| 582 |
|
| 583 |
// for Opera compatibility (see #570). |
| 584 |
|
| 585 |
iMainWidth = eMainNode.offsetWidth || eMainNode.firstChild.offsetWidth ; |
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
// Base the popup coordinates upon the coordinates of relElement. |
| 590 |
|
| 591 |
var oPos = FCKTools.GetDocumentPosition( this._Window, |
| 592 |
|
| 593 |
relElement.nodeType == 9 ? |
| 594 |
|
| 595 |
( FCKTools.IsStrictMode( relElement ) ? relElement.documentElement : relElement.body ) : |
| 596 |
|
| 597 |
relElement ) ; |
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
// Minus the offsets provided by any positioned parent element of the panel iframe. |
| 602 |
|
| 603 |
var positionedAncestor = FCKDomTools.GetPositionedAncestor( this._IFrame.parentNode ) ; |
| 604 |
|
| 605 |
if ( positionedAncestor ) |
| 606 |
|
| 607 |
{ |
| 608 |
|
| 609 |
var nPos = FCKTools.GetDocumentPosition( FCKTools.GetElementWindow( positionedAncestor ), positionedAncestor ) ; |
| 610 |
|
| 611 |
oPos.x -= nPos.x ; |
| 612 |
|
| 613 |
oPos.y -= nPos.y ; |
| 614 |
|
| 615 |
} |
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
if ( this.IsRTL && !this.IsContextMenu ) |
| 620 |
|
| 621 |
x = ( x * -1 ) ; |
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
x += oPos.x ; |
| 626 |
|
| 627 |
y += oPos.y ; |
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
if ( this.IsRTL ) |
| 632 |
|
| 633 |
{ |
| 634 |
|
| 635 |
if ( this.IsContextMenu ) |
| 636 |
|
| 637 |
x = x - iMainWidth + 1 ; |
| 638 |
|
| 639 |
else if ( relElement ) |
| 640 |
|
| 641 |
x = x + relElement.offsetWidth - iMainWidth ; |
| 642 |
|
| 643 |
} |
| 644 |
|
| 645 |
else |
| 646 |
|
| 647 |
{ |
| 648 |
|
| 649 |
var oViewPaneSize = FCKTools.GetViewPaneSize( this._Window ) ; |
| 650 |
|
| 651 |
var oScrollPosition = FCKTools.GetScrollPosition( this._Window ) ; |
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
var iViewPaneHeight = oViewPaneSize.Height + oScrollPosition.Y ; |
| 656 |
|
| 657 |
var iViewPaneWidth = oViewPaneSize.Width + oScrollPosition.X ; |
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
if ( ( x + iMainWidth ) > iViewPaneWidth ) |
| 662 |
|
| 663 |
x -= x + iMainWidth - iViewPaneWidth ; |
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
if ( ( y + eMainNode.offsetHeight ) > iViewPaneHeight ) |
| 668 |
|
| 669 |
y -= y + eMainNode.offsetHeight - iViewPaneHeight ; |
| 670 |
|
| 671 |
} |
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
// Set the context menu DIV in the specified location. |
| 676 |
|
| 677 |
FCKDomTools.SetElementStyles( this._IFrame, |
| 678 |
|
| 679 |
{ |
| 680 |
|
| 681 |
left : x + 'px', |
| 682 |
|
| 683 |
top : y + 'px' |
| 684 |
|
| 685 |
} ) ; |
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
// Move the focus to the IFRAME so we catch the "onblur". |
| 690 |
|
| 691 |
this._IFrame.contentWindow.focus() ; |
| 692 |
|
| 693 |
this._IsOpened = true ; |
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
var me = this ; |
| 698 |
|
| 699 |
this._resizeTimer = setTimeout( function() |
| 700 |
|
| 701 |
{ |
| 702 |
|
| 703 |
var iWidth = eMainNode.offsetWidth || eMainNode.firstChild.offsetWidth ; |
| 704 |
|
| 705 |
var iHeight = eMainNode.offsetHeight ; |
| 706 |
|
| 707 |
me._IFrame.style.width = iWidth + 'px' ; |
| 708 |
|
| 709 |
me._IFrame.style.height = iHeight + 'px' ; |
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
}, 0 ) ; |
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
FCK.ToolbarSet.CurrentInstance.GetInstanceObject( 'FCKPanel' )._OpenedPanel = this ; |
| 718 |
|
| 719 |
} |
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
FCKTools.RunFunction( this.OnShow, this ) ; |
| 724 |
|
| 725 |
} |
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
FCKPanel.prototype.Hide = function( ignoreOnHide, ignoreFocusManagerUnlock ) |
| 730 |
|
| 731 |
{ |
| 732 |
|
| 733 |
if ( this._Popup ) |
| 734 |
|
| 735 |
this._Popup.hide() ; |
| 736 |
|
| 737 |
else |
| 738 |
|
| 739 |
{ |
| 740 |
|
| 741 |
if ( !this._IsOpened || this._LockCounter > 0 ) |
| 742 |
|
| 743 |
return ; |
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
// Enable the editor to fire the "OnBlur". |
| 748 |
|
| 749 |
if ( typeof( FCKFocusManager ) != 'undefined' && !ignoreFocusManagerUnlock ) |
| 750 |
|
| 751 |
FCKFocusManager.Unlock() ; |
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
// It is better to set the sizes to 0, otherwise Firefox would have |
| 756 |
|
| 757 |
// rendering problems. |
| 758 |
|
| 759 |
this._IFrame.style.width = this._IFrame.style.height = '0px' ; |
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
this._IsOpened = false ; |
| 764 |
|
| 765 |
|
| 766 |
|
| 767 |
if ( this._resizeTimer ) |
| 768 |
|
| 769 |
{ |
| 770 |
|
| 771 |
clearTimeout( this._resizeTimer ) ; |
| 772 |
|
| 773 |
this._resizeTimer = null ; |
| 774 |
|
| 775 |
} |
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
if ( this.ParentPanel ) |
| 780 |
|
| 781 |
this.ParentPanel.Unlock() ; |
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
if ( !ignoreOnHide ) |
| 786 |
|
| 787 |
FCKTools.RunFunction( this.OnHide, this ) ; |
| 788 |
|
| 789 |
} |
| 790 |
|
| 791 |
} |
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
FCKPanel.prototype.CheckIsOpened = function() |
| 796 |
|
| 797 |
{ |
| 798 |
|
| 799 |
if ( this._Popup ) |
| 800 |
|
| 801 |
return this._Popup.isOpen ; |
| 802 |
|
| 803 |
else |
| 804 |
|
| 805 |
return this._IsOpened ; |
| 806 |
|
| 807 |
} |
| 808 |
|
| 809 |
|
| 810 |
|
| 811 |
FCKPanel.prototype.CreateChildPanel = function() |
| 812 |
|
| 813 |
{ |
| 814 |
|
| 815 |
var oWindow = this._Popup ? FCKTools.GetDocumentWindow( this.Document ) : this._Window ; |
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
var oChildPanel = new FCKPanel( oWindow ) ; |
| 820 |
|
| 821 |
oChildPanel.ParentPanel = this ; |
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
return oChildPanel ; |
| 826 |
|
| 827 |
} |
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
FCKPanel.prototype.Lock = function() |
| 832 |
|
| 833 |
{ |
| 834 |
|
| 835 |
this._LockCounter++ ; |
| 836 |
|
| 837 |
} |
| 838 |
|
| 839 |
|
| 840 |
|
| 841 |
FCKPanel.prototype.Unlock = function() |
| 842 |
|
| 843 |
{ |
| 844 |
|
| 845 |
if ( --this._LockCounter == 0 && !this.HasFocus ) |
| 846 |
|
| 847 |
this.Hide() ; |
| 848 |
|
| 849 |
} |
| 850 |
|
| 851 |
|
| 852 |
|
| 853 |
/* Events */ |
| 854 |
|
| 855 |
|
| 856 |
|
| 857 |
function FCKPanel_Window_OnFocus( e, panel ) |
| 858 |
|
| 859 |
{ |
| 860 |
|
| 861 |
panel.HasFocus = true ; |
| 862 |
|
| 863 |
} |
| 864 |
|
| 865 |
|
| 866 |
|
| 867 |
function FCKPanel_Window_OnBlur( e, panel ) |
| 868 |
|
| 869 |
{ |
| 870 |
|
| 871 |
panel.HasFocus = false ; |
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
if ( panel._LockCounter == 0 ) |
| 876 |
|
| 877 |
FCKTools.RunFunction( panel.Hide, panel ) ; |
| 878 |
|
| 879 |
} |
| 880 |
|
| 881 |
|
| 882 |
|
| 883 |
function CheckPopupOnHide( forceHide ) |
| 884 |
|
| 885 |
{ |
| 886 |
|
| 887 |
if ( forceHide || !this._Popup.isOpen ) |
| 888 |
|
| 889 |
{ |
| 890 |
|
| 891 |
window.clearInterval( this._Timer ) ; |
| 892 |
|
| 893 |
this._Timer = null ; |
| 894 |
|
| 895 |
|
| 896 |
|
| 897 |
if (this._Popup && this.ParentPanel && !forceHide) |
| 898 |
|
| 899 |
this.ParentPanel.ResizeForSubpanel(this, 0, 0) ; |
| 900 |
|
| 901 |
|
| 902 |
|
| 903 |
FCKTools.RunFunction( this.OnHide, this ) ; |
| 904 |
|
| 905 |
} |
| 906 |
|
| 907 |
} |
| 908 |
|
| 909 |
|
| 910 |
|
| 911 |
function FCKPanel_Cleanup() |
| 912 |
|
| 913 |
{ |
| 914 |
|
| 915 |
this._Popup = null ; |
| 916 |
|
| 917 |
this._Window = null ; |
| 918 |
|
| 919 |
this.Document = null ; |
| 920 |
|
| 921 |
this.MainNode = null ; |
| 922 |
|
| 923 |
this.RelativeElement = null ; |
| 924 |
|
| 925 |
} |
| 926 |
|
| 927 |
|