2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license
\r
7 * @fileOverview The floating dialog plugin.
\r
11 * No resize for this dialog.
\r
14 CKEDITOR.DIALOG_RESIZE_NONE = 0;
\r
17 * Only allow horizontal resizing for this dialog, disable vertical resizing.
\r
20 CKEDITOR.DIALOG_RESIZE_WIDTH = 1;
\r
23 * Only allow vertical resizing for this dialog, disable horizontal resizing.
\r
26 CKEDITOR.DIALOG_RESIZE_HEIGHT = 2;
\r
29 * Allow the dialog to be resized in both directions.
\r
32 CKEDITOR.DIALOG_RESIZE_BOTH = 3;
\r
36 var cssLength = CKEDITOR.tools.cssLength;
\r
37 function isTabVisible( tabId )
\r
39 return !!this._.tabs[ tabId ][ 0 ].$.offsetHeight;
\r
42 function getPreviousVisibleTab()
\r
44 var tabId = this._.currentTabId,
\r
45 length = this._.tabIdList.length,
\r
46 tabIndex = CKEDITOR.tools.indexOf( this._.tabIdList, tabId ) + length;
\r
48 for ( var i = tabIndex - 1 ; i > tabIndex - length ; i-- )
\r
50 if ( isTabVisible.call( this, this._.tabIdList[ i % length ] ) )
\r
51 return this._.tabIdList[ i % length ];
\r
57 function getNextVisibleTab()
\r
59 var tabId = this._.currentTabId,
\r
60 length = this._.tabIdList.length,
\r
61 tabIndex = CKEDITOR.tools.indexOf( this._.tabIdList, tabId );
\r
63 for ( var i = tabIndex + 1 ; i < tabIndex + length ; i++ )
\r
65 if ( isTabVisible.call( this, this._.tabIdList[ i % length ] ) )
\r
66 return this._.tabIdList[ i % length ];
\r
73 function clearOrRecoverTextInputValue( container, isRecover )
\r
75 var inputs = container.$.getElementsByTagName( 'input' );
\r
76 for ( var i = 0, length = inputs.length; i < length ; i++ )
\r
78 var item = new CKEDITOR.dom.element( inputs[ i ] );
\r
80 if ( item.getAttribute( 'type' ).toLowerCase() == 'text' )
\r
84 item.setAttribute( 'value', item.getCustomData( 'fake_value' ) || '' );
\r
85 item.removeCustomData( 'fake_value' );
\r
89 item.setCustomData( 'fake_value', item.getAttribute( 'value' ) );
\r
90 item.setAttribute( 'value', '' );
\r
97 * This is the base class for runtime dialog objects. An instance of this
\r
98 * class represents a single named dialog for a single editor instance.
\r
99 * @param {Object} editor The editor which created the dialog.
\r
100 * @param {String} dialogName The dialog's registered name.
\r
103 * var dialogObj = new CKEDITOR.dialog( editor, 'smiley' );
\r
105 CKEDITOR.dialog = function( editor, dialogName )
\r
107 // Load the dialog definition.
\r
108 var definition = CKEDITOR.dialog._.dialogDefinitions[ dialogName ],
\r
109 defaultDefinition = CKEDITOR.tools.clone( defaultDialogDefinition ),
\r
110 buttonsOrder = editor.config.dialog_buttonsOrder || 'OS',
\r
111 dir = editor.lang.dir;
\r
113 if ( ( buttonsOrder == 'OS' && CKEDITOR.env.mac ) || // The buttons in MacOS Apps are in reverse order (#4750)
\r
114 ( buttonsOrder == 'rtl' && dir == 'ltr' ) ||
\r
115 ( buttonsOrder == 'ltr' && dir == 'rtl' ) )
\r
116 defaultDefinition.buttons.reverse();
\r
119 // Completes the definition with the default values.
\r
120 definition = CKEDITOR.tools.extend( definition( editor ), defaultDefinition );
\r
122 // Clone a functionally independent copy for this dialog.
\r
123 definition = CKEDITOR.tools.clone( definition );
\r
125 // Create a complex definition object, extending it with the API
\r
127 definition = new definitionObject( this, definition );
\r
129 var doc = CKEDITOR.document;
\r
131 var themeBuilt = editor.theme.buildDialog( editor );
\r
133 // Initialize some basic parameters.
\r
137 element : themeBuilt.element,
\r
139 contentSize : { width : 0, height : 0 },
\r
140 size : { width : 0, height : 0 },
\r
145 // Initialize the tab and page map.
\r
148 currentTabId : null,
\r
149 currentTabIndex : null,
\r
152 tabBarMode : false,
\r
154 // Initialize the tab order array for input widgets.
\r
156 currentFocusIndex : 0,
\r
160 this.parts = themeBuilt.parts;
\r
162 CKEDITOR.tools.setTimeout( function()
\r
164 editor.fire( 'ariaWidget', this.parts.contents );
\r
168 // Set the startup styles for the dialog, avoiding it enlarging the
\r
169 // page size on the dialog creation.
\r
170 this.parts.dialog.setStyles(
\r
172 position : CKEDITOR.env.ie6Compat ? 'absolute' : 'fixed',
\r
175 visibility : 'hidden'
\r
178 // Call the CKEDITOR.event constructor to initialize this instance.
\r
179 CKEDITOR.event.call( this );
\r
181 // Fire the "dialogDefinition" event, making it possible to customize
\r
182 // the dialog definition.
\r
183 this.definition = definition = CKEDITOR.fire( 'dialogDefinition',
\r
186 definition : definition
\r
188 , editor ).definition;
\r
190 var tabsToRemove = {};
\r
191 // Cache tabs that should be removed.
\r
192 if ( !( 'removeDialogTabs' in editor._ ) && editor.config.removeDialogTabs )
\r
194 var removeContents = editor.config.removeDialogTabs.split( ';' );
\r
196 for ( i = 0; i < removeContents.length; i++ )
\r
198 var parts = removeContents[ i ].split( ':' );
\r
199 if ( parts.length == 2 )
\r
201 var removeDialogName = parts[ 0 ];
\r
202 if ( !tabsToRemove[ removeDialogName ] )
\r
203 tabsToRemove[ removeDialogName ] = [];
\r
204 tabsToRemove[ removeDialogName ].push( parts[ 1 ] );
\r
207 editor._.removeDialogTabs = tabsToRemove;
\r
210 // Remove tabs of this dialog.
\r
211 if ( editor._.removeDialogTabs && ( tabsToRemove = editor._.removeDialogTabs[ dialogName ] ) )
\r
213 for ( i = 0; i < tabsToRemove.length; i++ )
\r
214 definition.removeContents( tabsToRemove[ i ] );
\r
217 // Initialize load, show, hide, ok and cancel events.
\r
218 if ( definition.onLoad )
\r
219 this.on( 'load', definition.onLoad );
\r
221 if ( definition.onShow )
\r
222 this.on( 'show', definition.onShow );
\r
224 if ( definition.onHide )
\r
225 this.on( 'hide', definition.onHide );
\r
227 if ( definition.onOk )
\r
229 this.on( 'ok', function( evt )
\r
231 // Dialog confirm might probably introduce content changes (#5415).
\r
232 editor.fire( 'saveSnapshot' );
\r
233 setTimeout( function () { editor.fire( 'saveSnapshot' ); }, 0 );
\r
234 if ( definition.onOk.call( this, evt ) === false )
\r
235 evt.data.hide = false;
\r
239 if ( definition.onCancel )
\r
241 this.on( 'cancel', function( evt )
\r
243 if ( definition.onCancel.call( this, evt ) === false )
\r
244 evt.data.hide = false;
\r
250 // Iterates over all items inside all content in the dialog, calling a
\r
251 // function for each of them.
\r
252 var iterContents = function( func )
\r
254 var contents = me._.contents,
\r
257 for ( var i in contents )
\r
259 for ( var j in contents[i] )
\r
261 stop = func.call( this, contents[i][j] );
\r
268 this.on( 'ok', function( evt )
\r
270 iterContents( function( item )
\r
272 if ( item.validate )
\r
274 var isValid = item.validate( this );
\r
276 if ( typeof isValid == 'string' )
\r
282 if ( isValid === false )
\r
289 evt.data.hide = false;
\r
295 }, this, null, 0 );
\r
297 this.on( 'cancel', function( evt )
\r
299 iterContents( function( item )
\r
301 if ( item.isChanged() )
\r
303 if ( !confirm( editor.lang.common.confirmCancel ) )
\r
304 evt.data.hide = false;
\r
308 }, this, null, 0 );
\r
310 this.parts.close.on( 'click', function( evt )
\r
312 if ( this.fire( 'cancel', { hide : true } ).hide !== false )
\r
314 evt.data.preventDefault();
\r
317 // Sort focus list according to tab order definitions.
\r
318 function setupFocus()
\r
320 var focusList = me._.focusList;
\r
321 focusList.sort( function( a, b )
\r
323 // Mimics browser tab order logics;
\r
324 if ( a.tabIndex != b.tabIndex )
\r
325 return b.tabIndex - a.tabIndex;
\r
326 // Sort is not stable in some browsers,
\r
327 // fall-back the comparator to 'focusIndex';
\r
329 return a.focusIndex - b.focusIndex;
\r
332 var size = focusList.length;
\r
333 for ( var i = 0; i < size; i++ )
\r
334 focusList[ i ].focusIndex = i;
\r
337 function changeFocus( forward )
\r
339 var focusList = me._.focusList,
\r
340 offset = forward ? 1 : -1;
\r
341 if ( focusList.length < 1 )
\r
344 var current = me._.currentFocusIndex;
\r
346 // Trigger the 'blur' event of any input element before anything,
\r
347 // since certain UI updates may depend on it.
\r
350 focusList[ current ].getInputElement().$.blur();
\r
354 var startIndex = ( current + offset + focusList.length ) % focusList.length,
\r
355 currentIndex = startIndex;
\r
356 while ( !focusList[ currentIndex ].isFocusable() )
\r
358 currentIndex = ( currentIndex + offset + focusList.length ) % focusList.length;
\r
359 if ( currentIndex == startIndex )
\r
362 focusList[ currentIndex ].focus();
\r
364 // Select whole field content.
\r
365 if ( focusList[ currentIndex ].type == 'text' )
\r
366 focusList[ currentIndex ].select();
\r
369 this.changeFocus = changeFocus;
\r
373 function focusKeydownHandler( evt )
\r
375 // If I'm not the top dialog, ignore.
\r
376 if ( me != CKEDITOR.dialog._.currentTop )
\r
379 var keystroke = evt.data.getKeystroke(),
\r
380 rtl = editor.lang.dir == 'rtl';
\r
383 if ( keystroke == 9 || keystroke == CKEDITOR.SHIFT + 9 )
\r
385 var shiftPressed = ( keystroke == CKEDITOR.SHIFT + 9 );
\r
387 // Handling Tab and Shift-Tab.
\r
388 if ( me._.tabBarMode )
\r
391 var nextId = shiftPressed ? getPreviousVisibleTab.call( me ) : getNextVisibleTab.call( me );
\r
392 me.selectPage( nextId );
\r
393 me._.tabs[ nextId ][ 0 ].focus();
\r
397 // Change the focus of inputs.
\r
398 changeFocus( !shiftPressed );
\r
403 else if ( keystroke == CKEDITOR.ALT + 121 && !me._.tabBarMode && me.getPageCount() > 1 )
\r
405 // Alt-F10 puts focus into the current tab item in the tab bar.
\r
406 me._.tabBarMode = true;
\r
407 me._.tabs[ me._.currentTabId ][ 0 ].focus();
\r
410 else if ( ( keystroke == 37 || keystroke == 39 ) && me._.tabBarMode )
\r
412 // Arrow keys - used for changing tabs.
\r
413 nextId = ( keystroke == ( rtl ? 39 : 37 ) ? getPreviousVisibleTab.call( me ) : getNextVisibleTab.call( me ) );
\r
414 me.selectPage( nextId );
\r
415 me._.tabs[ nextId ][ 0 ].focus();
\r
418 else if ( ( keystroke == 13 || keystroke == 32 ) && me._.tabBarMode )
\r
420 this.selectPage( this._.currentTabId );
\r
421 this._.tabBarMode = false;
\r
422 this._.currentFocusIndex = -1;
\r
423 changeFocus( true );
\r
430 evt.data.preventDefault();
\r
434 function focusKeyPressHandler( evt )
\r
436 processed && evt.data.preventDefault();
\r
439 var dialogElement = this._.element;
\r
440 // Add the dialog keyboard handlers.
\r
441 this.on( 'show', function()
\r
443 dialogElement.on( 'keydown', focusKeydownHandler, this, null, 0 );
\r
444 // Some browsers instead, don't cancel key events in the keydown, but in the
\r
445 // keypress. So we must do a longer trip in those cases. (#4531)
\r
446 if ( CKEDITOR.env.opera || ( CKEDITOR.env.gecko && CKEDITOR.env.mac ) )
\r
447 dialogElement.on( 'keypress', focusKeyPressHandler, this );
\r
450 this.on( 'hide', function()
\r
452 dialogElement.removeListener( 'keydown', focusKeydownHandler );
\r
453 if ( CKEDITOR.env.opera || ( CKEDITOR.env.gecko && CKEDITOR.env.mac ) )
\r
454 dialogElement.removeListener( 'keypress', focusKeyPressHandler );
\r
456 this.on( 'iframeAdded', function( evt )
\r
458 var doc = new CKEDITOR.dom.document( evt.data.iframe.$.contentWindow.document );
\r
459 doc.on( 'keydown', focusKeydownHandler, this, null, 0 );
\r
462 // Auto-focus logic in dialog.
\r
463 this.on( 'show', function()
\r
465 // Setup tabIndex on showing the dialog instead of on loading
\r
466 // to allow dynamic tab order happen in dialog definition.
\r
469 if ( editor.config.dialog_startupFocusTab
\r
470 && me._.pageCount > 1 )
\r
472 me._.tabBarMode = true;
\r
473 me._.tabs[ me._.currentTabId ][ 0 ].focus();
\r
475 else if ( !this._.hasFocus )
\r
477 this._.currentFocusIndex = -1;
\r
479 // Decide where to put the initial focus.
\r
480 if ( definition.onFocus )
\r
482 var initialFocus = definition.onFocus.call( this );
\r
483 // Focus the field that the user specified.
\r
484 initialFocus && initialFocus.focus();
\r
486 // Focus the first field in layout order.
\r
488 changeFocus( true );
\r
491 * IE BUG: If the initial focus went into a non-text element (e.g. button),
\r
492 * then IE would still leave the caret inside the editing area.
\r
494 if ( this._.editor.mode == 'wysiwyg' && CKEDITOR.env.ie )
\r
496 var $selection = editor.document.$.selection,
\r
497 $range = $selection.createRange();
\r
501 if ( $range.parentElement && $range.parentElement().ownerDocument == editor.document.$
\r
502 || $range.item && $range.item( 0 ).ownerDocument == editor.document.$ )
\r
504 var $myRange = document.body.createTextRange();
\r
505 $myRange.moveToElementText( this.getElement().getFirst().$ );
\r
506 $myRange.collapse( true );
\r
512 }, this, null, 0xffffffff );
\r
514 // IE6 BUG: Text fields and text areas are only half-rendered the first time the dialog appears in IE6 (#2661).
\r
515 // This is still needed after [2708] and [2709] because text fields in hidden TR tags are still broken.
\r
516 if ( CKEDITOR.env.ie6Compat )
\r
518 this.on( 'load', function( evt )
\r
520 var outer = this.getElement(),
\r
521 inner = outer.getFirst();
\r
523 inner.appendTo( outer );
\r
527 initDragAndDrop( this );
\r
528 initResizeHandles( this );
\r
530 // Insert the title.
\r
531 ( new CKEDITOR.dom.text( definition.title, CKEDITOR.document ) ).appendTo( this.parts.title );
\r
533 // Insert the tabs and contents.
\r
534 for ( var i = 0 ; i < definition.contents.length ; i++ )
\r
536 var page = definition.contents[i];
\r
537 page && this.addPage( page );
\r
540 this.parts[ 'tabs' ].on( 'click', function( evt )
\r
542 var target = evt.data.getTarget();
\r
543 // If we aren't inside a tab, bail out.
\r
544 if ( target.hasClass( 'cke_dialog_tab' ) )
\r
546 // Get the ID of the tab, without the 'cke_' prefix and the unique number suffix.
\r
547 var id = target.$.id;
\r
548 this.selectPage( id.substring( 4, id.lastIndexOf( '_' ) ) );
\r
550 if ( this._.tabBarMode )
\r
552 this._.tabBarMode = false;
\r
553 this._.currentFocusIndex = -1;
\r
554 changeFocus( true );
\r
556 evt.data.preventDefault();
\r
561 var buttonsHtml = [],
\r
562 buttons = CKEDITOR.dialog._.uiElementBuilders.hbox.build( this,
\r
565 className : 'cke_dialog_footer_buttons',
\r
567 children : definition.buttons
\r
568 }, buttonsHtml ).getChild();
\r
569 this.parts.footer.setHtml( buttonsHtml.join( '' ) );
\r
571 for ( i = 0 ; i < buttons.length ; i++ )
\r
572 this._.buttons[ buttons[i].id ] = buttons[i];
\r
575 // Focusable interface. Use it via dialog.addFocusable.
\r
576 function Focusable( dialog, element, index )
\r
578 this.element = element;
\r
579 this.focusIndex = index;
\r
580 // TODO: support tabIndex for focusables.
\r
582 this.isFocusable = function()
\r
584 return !element.getAttribute( 'disabled' ) && element.isVisible();
\r
586 this.focus = function()
\r
588 dialog._.currentFocusIndex = this.focusIndex;
\r
589 this.element.focus();
\r
592 element.on( 'keydown', function( e )
\r
594 if ( e.data.getKeystroke() in { 32:1, 13:1 } )
\r
595 this.fire( 'click' );
\r
597 element.on( 'focus', function()
\r
599 this.fire( 'mouseover' );
\r
601 element.on( 'blur', function()
\r
603 this.fire( 'mouseout' );
\r
607 CKEDITOR.dialog.prototype =
\r
609 destroy : function()
\r
612 this._.element.remove();
\r
616 * Resizes the dialog.
\r
617 * @param {Number} width The width of the dialog in pixels.
\r
618 * @param {Number} height The height of the dialog in pixels.
\r
621 * dialogObj.resize( 800, 640 );
\r
623 resize : (function()
\r
625 return function( width, height )
\r
627 if ( this._.contentSize && this._.contentSize.width == width && this._.contentSize.height == height )
\r
630 CKEDITOR.dialog.fire( 'resize',
\r
633 skin : this._.editor.skinName,
\r
636 }, this._.editor );
\r
638 this._.contentSize = { width : width, height : height };
\r
643 * Gets the current size of the dialog in pixels.
\r
644 * @returns {Object} An object with "width" and "height" properties.
\r
646 * var width = dialogObj.getSize().width;
\r
648 getSize : function()
\r
650 var element = this._.element.getFirst();
\r
651 return { width : element.$.offsetWidth || 0, height : element.$.offsetHeight || 0};
\r
655 * Moves the dialog to an (x, y) coordinate relative to the window.
\r
657 * @param {Number} x The target x-coordinate.
\r
658 * @param {Number} y The target y-coordinate.
\r
659 * @param {Boolean} save Flag indicate whether the dialog position should be remembered on next open up.
\r
661 * dialogObj.move( 10, 40 );
\r
666 return function( x, y, save )
\r
668 // The dialog may be fixed positioned or absolute positioned. Ask the
\r
669 // browser what is the current situation first.
\r
670 var element = this._.element.getFirst();
\r
671 if ( isFixed === undefined )
\r
672 isFixed = element.getComputedStyle( 'position' ) == 'fixed';
\r
674 if ( isFixed && this._.position && this._.position.x == x && this._.position.y == y )
\r
677 // Save the current position.
\r
678 this._.position = { x : x, y : y };
\r
680 // If not fixed positioned, add scroll position to the coordinates.
\r
683 var scrollPosition = CKEDITOR.document.getWindow().getScrollPosition();
\r
684 x += scrollPosition.x;
\r
685 y += scrollPosition.y;
\r
690 'left' : ( x > 0 ? x : 0 ) + 'px',
\r
691 'top' : ( y > 0 ? y : 0 ) + 'px'
\r
694 save && ( this._.moved = 1 );
\r
699 * Gets the dialog's position in the window.
\r
700 * @returns {Object} An object with "x" and "y" properties.
\r
702 * var dialogX = dialogObj.getPosition().x;
\r
704 getPosition : function(){ return CKEDITOR.tools.extend( {}, this._.position ); },
\r
707 * Shows the dialog box.
\r
709 * dialogObj.show();
\r
713 // Insert the dialog's element to the root document.
\r
714 var element = this._.element;
\r
715 var definition = this.definition;
\r
716 if ( !( element.getParent() && element.getParent().equals( CKEDITOR.document.getBody() ) ) )
\r
717 element.appendTo( CKEDITOR.document.getBody() );
\r
719 element.setStyle( 'display', 'block' );
\r
721 // FIREFOX BUG: Fix vanishing caret for Firefox 2 or Gecko 1.8.
\r
722 if ( CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 )
\r
724 var dialogElement = this.parts.dialog;
\r
725 dialogElement.setStyle( 'position', 'absolute' );
\r
726 setTimeout( function()
\r
728 dialogElement.setStyle( 'position', 'fixed' );
\r
733 // First, set the dialog to an appropriate size.
\r
734 this.resize( this._.contentSize && this._.contentSize.width || definition.minWidth,
\r
735 this._.contentSize && this._.contentSize.height || definition.minHeight );
\r
737 // Reset all inputs back to their default value.
\r
740 // Select the first tab by default.
\r
741 this.selectPage( this.definition.contents[0].id );
\r
744 if ( CKEDITOR.dialog._.currentZIndex === null )
\r
745 CKEDITOR.dialog._.currentZIndex = this._.editor.config.baseFloatZIndex;
\r
746 this._.element.getFirst().setStyle( 'z-index', CKEDITOR.dialog._.currentZIndex += 10 );
\r
748 // Maintain the dialog ordering and dialog cover.
\r
749 // Also register key handlers if first dialog.
\r
750 if ( CKEDITOR.dialog._.currentTop === null )
\r
752 CKEDITOR.dialog._.currentTop = this;
\r
753 this._.parentDialog = null;
\r
754 showCover( this._.editor );
\r
756 element.on( 'keydown', accessKeyDownHandler );
\r
757 element.on( CKEDITOR.env.opera ? 'keypress' : 'keyup', accessKeyUpHandler );
\r
759 // Prevent some keys from bubbling up. (#4269)
\r
760 for ( var event in { keyup :1, keydown :1, keypress :1 } )
\r
761 element.on( event, preventKeyBubbling );
\r
765 this._.parentDialog = CKEDITOR.dialog._.currentTop;
\r
766 var parentElement = this._.parentDialog.getElement().getFirst();
\r
767 parentElement.$.style.zIndex -= Math.floor( this._.editor.config.baseFloatZIndex / 2 );
\r
768 CKEDITOR.dialog._.currentTop = this;
\r
771 // Register the Esc hotkeys.
\r
772 registerAccessKey( this, this, '\x1b', null, function()
\r
774 this.getButton( 'cancel' ) && this.getButton( 'cancel' ).click();
\r
777 // Reset the hasFocus state.
\r
778 this._.hasFocus = false;
\r
780 CKEDITOR.tools.setTimeout( function()
\r
783 this.parts.dialog.setStyle( 'visibility', '' );
\r
785 // Execute onLoad for the first show.
\r
786 this.fireOnce( 'load', {} );
\r
787 CKEDITOR.ui.fire( 'ready', this );
\r
789 this.fire( 'show', {} );
\r
790 this._.editor.fire( 'dialogShow', this );
\r
792 // Save the initial values of the dialog.
\r
793 this.foreach( function( contentObj ) { contentObj.setInitValue && contentObj.setInitValue(); } );
\r
800 * Rearrange the dialog to its previous position or the middle of the window.
\r
803 layout : function()
\r
805 var viewSize = CKEDITOR.document.getWindow().getViewPaneSize(),
\r
806 dialogSize = this.getSize();
\r
808 this.move( this._.moved ? this._.position.x : ( viewSize.width - dialogSize.width ) / 2,
\r
809 this._.moved ? this._.position.y : ( viewSize.height - dialogSize.height ) / 2 );
\r
813 * Executes a function for each UI element.
\r
814 * @param {Function} fn Function to execute for each UI element.
\r
815 * @returns {CKEDITOR.dialog} The current dialog object.
\r
817 foreach : function( fn )
\r
819 for ( var i in this._.contents )
\r
821 for ( var j in this._.contents[i] )
\r
822 fn( this._.contents[i][j] );
\r
828 * Resets all input values in the dialog.
\r
830 * dialogObj.reset();
\r
831 * @returns {CKEDITOR.dialog} The current dialog object.
\r
833 reset : (function()
\r
835 var fn = function( widget ){ if ( widget.reset ) widget.reset( 1 ); };
\r
836 return function(){ this.foreach( fn ); return this; };
\r
839 setupContent : function()
\r
841 var args = arguments;
\r
842 this.foreach( function( widget )
\r
844 if ( widget.setup )
\r
845 widget.setup.apply( widget, args );
\r
849 commitContent : function()
\r
851 var args = arguments;
\r
852 this.foreach( function( widget )
\r
854 if ( widget.commit )
\r
855 widget.commit.apply( widget, args );
\r
860 * Hides the dialog box.
\r
862 * dialogObj.hide();
\r
866 if ( !this.parts.dialog.isVisible() )
\r
869 this.fire( 'hide', {} );
\r
870 this._.editor.fire( 'dialogHide', this );
\r
871 var element = this._.element;
\r
872 element.setStyle( 'display', 'none' );
\r
873 this.parts.dialog.setStyle( 'visibility', 'hidden' );
\r
874 // Unregister all access keys associated with this dialog.
\r
875 unregisterAccessKey( this );
\r
877 // Close any child(top) dialogs first.
\r
878 while( CKEDITOR.dialog._.currentTop != this )
\r
879 CKEDITOR.dialog._.currentTop.hide();
\r
881 // Maintain dialog ordering and remove cover if needed.
\r
882 if ( !this._.parentDialog )
\r
886 var parentElement = this._.parentDialog.getElement().getFirst();
\r
887 parentElement.setStyle( 'z-index', parseInt( parentElement.$.style.zIndex, 10 ) + Math.floor( this._.editor.config.baseFloatZIndex / 2 ) );
\r
889 CKEDITOR.dialog._.currentTop = this._.parentDialog;
\r
891 // Deduct or clear the z-index.
\r
892 if ( !this._.parentDialog )
\r
894 CKEDITOR.dialog._.currentZIndex = null;
\r
896 // Remove access key handlers.
\r
897 element.removeListener( 'keydown', accessKeyDownHandler );
\r
898 element.removeListener( CKEDITOR.env.opera ? 'keypress' : 'keyup', accessKeyUpHandler );
\r
900 // Remove bubbling-prevention handler. (#4269)
\r
901 for ( var event in { keyup :1, keydown :1, keypress :1 } )
\r
902 element.removeListener( event, preventKeyBubbling );
\r
904 var editor = this._.editor;
\r
907 if ( editor.mode == 'wysiwyg' && CKEDITOR.env.ie )
\r
909 var selection = editor.getSelection();
\r
910 selection && selection.unlock( true );
\r
914 CKEDITOR.dialog._.currentZIndex -= 10;
\r
916 delete this._.parentDialog;
\r
917 // Reset the initial values of the dialog.
\r
918 this.foreach( function( contentObj ) { contentObj.resetInitValue && contentObj.resetInitValue(); } );
\r
922 * Adds a tabbed page into the dialog.
\r
923 * @param {Object} contents Content definition.
\r
926 addPage : function( contents )
\r
929 titleHtml = contents.label ? ' title="' + CKEDITOR.tools.htmlEncode( contents.label ) + '"' : '',
\r
930 elements = contents.elements,
\r
931 vbox = CKEDITOR.dialog._.uiElementBuilders.vbox.build( this,
\r
934 className : 'cke_dialog_page_contents',
\r
935 children : contents.elements,
\r
936 expand : !!contents.expand,
\r
937 padding : contents.padding,
\r
938 style : contents.style || 'width: 100%;'
\r
941 // Create the HTML for the tab and the content block.
\r
942 var page = CKEDITOR.dom.element.createFromHtml( pageHtml.join( '' ) );
\r
943 page.setAttribute( 'role', 'tabpanel' );
\r
945 var env = CKEDITOR.env;
\r
946 var tabId = 'cke_' + contents.id + '_' + CKEDITOR.tools.getNextNumber(),
\r
947 tab = CKEDITOR.dom.element.createFromHtml( [
\r
948 '<a class="cke_dialog_tab"',
\r
949 ( this._.pageCount > 0 ? ' cke_last' : 'cke_first' ),
\r
951 ( !!contents.hidden ? ' style="display:none"' : '' ),
\r
952 ' id="', tabId, '"',
\r
953 env.gecko && env.version >= 10900 && !env.hc ? '' : ' href="javascript:void(0)"',
\r
955 ' hidefocus="true"',
\r
961 page.setAttribute( 'aria-labelledby', tabId );
\r
963 // Take records for the tabs and elements created.
\r
964 this._.tabs[ contents.id ] = [ tab, page ];
\r
965 this._.tabIdList.push( contents.id );
\r
966 !contents.hidden && this._.pageCount++;
\r
967 this._.lastTab = tab;
\r
968 this.updateStyle();
\r
970 var contentMap = this._.contents[ contents.id ] = {},
\r
972 children = vbox.getChild();
\r
974 while ( ( cursor = children.shift() ) )
\r
976 contentMap[ cursor.id ] = cursor;
\r
977 if ( typeof( cursor.getChild ) == 'function' )
\r
978 children.push.apply( children, cursor.getChild() );
\r
981 // Attach the DOM nodes.
\r
983 page.setAttribute( 'name', contents.id );
\r
984 page.appendTo( this.parts.contents );
\r
986 tab.unselectable();
\r
987 this.parts.tabs.append( tab );
\r
989 // Add access key handlers if access key is defined.
\r
990 if ( contents.accessKey )
\r
992 registerAccessKey( this, this, 'CTRL+' + contents.accessKey,
\r
993 tabAccessKeyDown, tabAccessKeyUp );
\r
994 this._.accessKeyMap[ 'CTRL+' + contents.accessKey ] = contents.id;
\r
999 * Activates a tab page in the dialog by its id.
\r
1000 * @param {String} id The id of the dialog tab to be activated.
\r
1002 * dialogObj.selectPage( 'tab_1' );
\r
1004 selectPage : function( id )
\r
1006 if ( this._.currentTabId == id )
\r
1009 // Returning true means that the event has been canceled
\r
1010 if ( this.fire( 'selectPage', { page : id, currentPage : this._.currentTabId } ) === true )
\r
1013 // Hide the non-selected tabs and pages.
\r
1014 for ( var i in this._.tabs )
\r
1016 var tab = this._.tabs[i][0],
\r
1017 page = this._.tabs[i][1];
\r
1020 tab.removeClass( 'cke_dialog_tab_selected' );
\r
1023 page.setAttribute( 'aria-hidden', i != id );
\r
1026 var selected = this._.tabs[ id ];
\r
1027 selected[ 0 ].addClass( 'cke_dialog_tab_selected' );
\r
1029 // [IE] an invisible input[type='text'] will enlarge it's width
\r
1030 // if it's value is long when it shows, so we clear it's value
\r
1031 // before it shows and then recover it (#5649)
\r
1032 if ( CKEDITOR.env.ie6Compat || CKEDITOR.env.ie7Compat )
\r
1034 clearOrRecoverTextInputValue( selected[ 1 ] );
\r
1035 selected[ 1 ].show();
\r
1036 setTimeout( function()
\r
1038 clearOrRecoverTextInputValue( selected[ 1 ], 1 );
\r
1042 selected[ 1 ].show();
\r
1044 this._.currentTabId = id;
\r
1045 this._.currentTabIndex = CKEDITOR.tools.indexOf( this._.tabIdList, id );
\r
1048 // Dialog state-specific style updates.
\r
1049 updateStyle : function()
\r
1051 // If only a single page shown, a different style is used in the central pane.
\r
1052 this.parts.dialog[ ( this._.pageCount === 1 ? 'add' : 'remove' ) + 'Class' ]( 'cke_single_page' );
\r
1056 * Hides a page's tab away from the dialog.
\r
1057 * @param {String} id The page's Id.
\r
1059 * dialog.hidePage( 'tab_3' );
\r
1061 hidePage : function( id )
\r
1063 var tab = this._.tabs[id] && this._.tabs[id][0];
\r
1064 if ( !tab || this._.pageCount == 1 || !tab.isVisible() )
\r
1066 // Switch to other tab first when we're hiding the active tab.
\r
1067 else if ( id == this._.currentTabId )
\r
1068 this.selectPage( getPreviousVisibleTab.call( this ) );
\r
1071 this._.pageCount--;
\r
1072 this.updateStyle();
\r
1076 * Unhides a page's tab.
\r
1077 * @param {String} id The page's Id.
\r
1079 * dialog.showPage( 'tab_2' );
\r
1081 showPage : function( id )
\r
1083 var tab = this._.tabs[id] && this._.tabs[id][0];
\r
1087 this._.pageCount++;
\r
1088 this.updateStyle();
\r
1092 * Gets the root DOM element of the dialog.
\r
1093 * @returns {CKEDITOR.dom.element} The <span> element containing this dialog.
\r
1095 * var dialogElement = dialogObj.getElement().getFirst();
\r
1096 * dialogElement.setStyle( 'padding', '5px' );
\r
1098 getElement : function()
\r
1100 return this._.element;
\r
1104 * Gets the name of the dialog.
\r
1105 * @returns {String} The name of this dialog.
\r
1107 * var dialogName = dialogObj.getName();
\r
1109 getName : function()
\r
1111 return this._.name;
\r
1115 * Gets a dialog UI element object from a dialog page.
\r
1116 * @param {String} pageId id of dialog page.
\r
1117 * @param {String} elementId id of UI element.
\r
1119 * @returns {CKEDITOR.ui.dialog.uiElement} The dialog UI element.
\r
1121 getContentElement : function( pageId, elementId )
\r
1123 var page = this._.contents[ pageId ];
\r
1124 return page && page[ elementId ];
\r
1128 * Gets the value of a dialog UI element.
\r
1129 * @param {String} pageId id of dialog page.
\r
1130 * @param {String} elementId id of UI element.
\r
1132 * @returns {Object} The value of the UI element.
\r
1134 getValueOf : function( pageId, elementId )
\r
1136 return this.getContentElement( pageId, elementId ).getValue();
\r
1140 * Sets the value of a dialog UI element.
\r
1141 * @param {String} pageId id of the dialog page.
\r
1142 * @param {String} elementId id of the UI element.
\r
1143 * @param {Object} value The new value of the UI element.
\r
1146 setValueOf : function( pageId, elementId, value )
\r
1148 return this.getContentElement( pageId, elementId ).setValue( value );
\r
1152 * Gets the UI element of a button in the dialog's button row.
\r
1153 * @param {String} id The id of the button.
\r
1155 * @returns {CKEDITOR.ui.dialog.button} The button object.
\r
1157 getButton : function( id )
\r
1159 return this._.buttons[ id ];
\r
1163 * Simulates a click to a dialog button in the dialog's button row.
\r
1164 * @param {String} id The id of the button.
\r
1166 * @returns The return value of the dialog's "click" event.
\r
1168 click : function( id )
\r
1170 return this._.buttons[ id ].click();
\r
1174 * Disables a dialog button.
\r
1175 * @param {String} id The id of the button.
\r
1178 disableButton : function( id )
\r
1180 return this._.buttons[ id ].disable();
\r
1184 * Enables a dialog button.
\r
1185 * @param {String} id The id of the button.
\r
1188 enableButton : function( id )
\r
1190 return this._.buttons[ id ].enable();
\r
1194 * Gets the number of pages in the dialog.
\r
1195 * @returns {Number} Page count.
\r
1197 getPageCount : function()
\r
1199 return this._.pageCount;
\r
1203 * Gets the editor instance which opened this dialog.
\r
1204 * @returns {CKEDITOR.editor} Parent editor instances.
\r
1206 getParentEditor : function()
\r
1208 return this._.editor;
\r
1212 * Gets the element that was selected when opening the dialog, if any.
\r
1213 * @returns {CKEDITOR.dom.element} The element that was selected, or null.
\r
1215 getSelectedElement : function()
\r
1217 return this.getParentEditor().getSelection().getSelectedElement();
\r
1221 * Adds element to dialog's focusable list.
\r
1223 * @param {CKEDITOR.dom.element} element
\r
1224 * @param {Number} [index]
\r
1226 addFocusable: function( element, index ) {
\r
1227 if ( typeof index == 'undefined' )
\r
1229 index = this._.focusList.length;
\r
1230 this._.focusList.push( new Focusable( this, element, index ) );
\r
1234 this._.focusList.splice( index, 0, new Focusable( this, element, index ) );
\r
1235 for ( var i = index + 1 ; i < this._.focusList.length ; i++ )
\r
1236 this._.focusList[ i ].focusIndex++;
\r
1241 CKEDITOR.tools.extend( CKEDITOR.dialog,
\r
1243 * @lends CKEDITOR.dialog
\r
1247 * Registers a dialog.
\r
1248 * @param {String} name The dialog's name.
\r
1249 * @param {Function|String} dialogDefinition
\r
1250 * A function returning the dialog's definition, or the URL to the .js file holding the function.
\r
1251 * The function should accept an argument "editor" which is the current editor instance, and
\r
1252 * return an object conforming to {@link CKEDITOR.dialog.dialogDefinition}.
\r
1254 * @see CKEDITOR.dialog.dialogDefinition
\r
1256 add : function( name, dialogDefinition )
\r
1258 // Avoid path registration from multiple instances override definition.
\r
1259 if ( !this._.dialogDefinitions[name]
\r
1260 || typeof dialogDefinition == 'function' )
\r
1261 this._.dialogDefinitions[name] = dialogDefinition;
\r
1264 exists : function( name )
\r
1266 return !!this._.dialogDefinitions[ name ];
\r
1269 getCurrent : function()
\r
1271 return CKEDITOR.dialog._.currentTop;
\r
1275 * The default OK button for dialogs. Fires the "ok" event and closes the dialog if the event succeeds.
\r
1281 okButton : (function()
\r
1283 var retval = function( editor, override )
\r
1285 override = override || {};
\r
1286 return CKEDITOR.tools.extend( {
\r
1289 label : editor.lang.common.ok,
\r
1290 'class' : 'cke_dialog_ui_button_ok',
\r
1291 onClick : function( evt )
\r
1293 var dialog = evt.data.dialog;
\r
1294 if ( dialog.fire( 'ok', { hide : true } ).hide !== false )
\r
1297 }, override, true );
\r
1299 retval.type = 'button';
\r
1300 retval.override = function( override )
\r
1302 return CKEDITOR.tools.extend( function( editor ){ return retval( editor, override ); },
\r
1303 { type : 'button' }, true );
\r
1309 * The default cancel button for dialogs. Fires the "cancel" event and closes the dialog if no UI element value changed.
\r
1315 cancelButton : (function()
\r
1317 var retval = function( editor, override )
\r
1319 override = override || {};
\r
1320 return CKEDITOR.tools.extend( {
\r
1323 label : editor.lang.common.cancel,
\r
1324 'class' : 'cke_dialog_ui_button_cancel',
\r
1325 onClick : function( evt )
\r
1327 var dialog = evt.data.dialog;
\r
1328 if ( dialog.fire( 'cancel', { hide : true } ).hide !== false )
\r
1331 }, override, true );
\r
1333 retval.type = 'button';
\r
1334 retval.override = function( override )
\r
1336 return CKEDITOR.tools.extend( function( editor ){ return retval( editor, override ); },
\r
1337 { type : 'button' }, true );
\r
1343 * Registers a dialog UI element.
\r
1344 * @param {String} typeName The name of the UI element.
\r
1345 * @param {Function} builder The function to build the UI element.
\r
1348 addUIElement : function( typeName, builder )
\r
1350 this._.uiElementBuilders[ typeName ] = builder;
\r
1354 CKEDITOR.dialog._ =
\r
1356 uiElementBuilders : {},
\r
1358 dialogDefinitions : {},
\r
1360 currentTop : null,
\r
1362 currentZIndex : null
\r
1365 // "Inherit" (copy actually) from CKEDITOR.event.
\r
1366 CKEDITOR.event.implementOn( CKEDITOR.dialog );
\r
1367 CKEDITOR.event.implementOn( CKEDITOR.dialog.prototype, true );
\r
1369 var defaultDialogDefinition =
\r
1371 resizable : CKEDITOR.DIALOG_RESIZE_BOTH,
\r
1374 buttons : [ CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton ]
\r
1377 // Tool function used to return an item from an array based on its id
\r
1379 var getById = function( array, id, recurse )
\r
1381 for ( var i = 0, item ; ( item = array[ i ] ) ; i++ )
\r
1383 if ( item.id == id )
\r
1385 if ( recurse && item[ recurse ] )
\r
1387 var retval = getById( item[ recurse ], id, recurse ) ;
\r
1395 // Tool function used to add an item into an array.
\r
1396 var addById = function( array, newItem, nextSiblingId, recurse, nullIfNotFound )
\r
1398 if ( nextSiblingId )
\r
1400 for ( var i = 0, item ; ( item = array[ i ] ) ; i++ )
\r
1402 if ( item.id == nextSiblingId )
\r
1404 array.splice( i, 0, newItem );
\r
1408 if ( recurse && item[ recurse ] )
\r
1410 var retval = addById( item[ recurse ], newItem, nextSiblingId, recurse, true );
\r
1416 if ( nullIfNotFound )
\r
1420 array.push( newItem );
\r
1424 // Tool function used to remove an item from an array based on its id.
\r
1425 var removeById = function( array, id, recurse )
\r
1427 for ( var i = 0, item ; ( item = array[ i ] ) ; i++ )
\r
1429 if ( item.id == id )
\r
1430 return array.splice( i, 1 );
\r
1431 if ( recurse && item[ recurse ] )
\r
1433 var retval = removeById( item[ recurse ], id, recurse );
\r
1442 * This class is not really part of the API. It is the "definition" property value
\r
1443 * passed to "dialogDefinition" event handlers.
\r
1445 * @name CKEDITOR.dialog.dialogDefinitionObject
\r
1446 * @extends CKEDITOR.dialog.dialogDefinition
\r
1448 * CKEDITOR.on( 'dialogDefinition', function( evt )
\r
1450 * var definition = evt.data.definition;
\r
1451 * var content = definition.getContents( 'page1' );
\r
1455 var definitionObject = function( dialog, dialogDefinition )
\r
1457 // TODO : Check if needed.
\r
1458 this.dialog = dialog;
\r
1460 // Transform the contents entries in contentObjects.
\r
1461 var contents = dialogDefinition.contents;
\r
1462 for ( var i = 0, content ; ( content = contents[i] ) ; i++ )
\r
1463 contents[ i ] = content && new contentObject( dialog, content );
\r
1465 CKEDITOR.tools.extend( this, dialogDefinition );
\r
1468 definitionObject.prototype =
\r
1469 /** @lends CKEDITOR.dialog.dialogDefinitionObject.prototype */
\r
1472 * Gets a content definition.
\r
1473 * @param {String} id The id of the content definition.
\r
1474 * @returns {CKEDITOR.dialog.contentDefinition} The content definition
\r
1477 getContents : function( id )
\r
1479 return getById( this.contents, id );
\r
1483 * Gets a button definition.
\r
1484 * @param {String} id The id of the button definition.
\r
1485 * @returns {CKEDITOR.dialog.buttonDefinition} The button definition
\r
1488 getButton : function( id )
\r
1490 return getById( this.buttons, id );
\r
1494 * Adds a content definition object under this dialog definition.
\r
1495 * @param {CKEDITOR.dialog.contentDefinition} contentDefinition The
\r
1496 * content definition.
\r
1497 * @param {String} [nextSiblingId] The id of an existing content
\r
1498 * definition which the new content definition will be inserted
\r
1499 * before. Omit if the new content definition is to be inserted as
\r
1501 * @returns {CKEDITOR.dialog.contentDefinition} The inserted content
\r
1504 addContents : function( contentDefinition, nextSiblingId )
\r
1506 return addById( this.contents, contentDefinition, nextSiblingId );
\r
1510 * Adds a button definition object under this dialog definition.
\r
1511 * @param {CKEDITOR.dialog.buttonDefinition} buttonDefinition The
\r
1512 * button definition.
\r
1513 * @param {String} [nextSiblingId] The id of an existing button
\r
1514 * definition which the new button definition will be inserted
\r
1515 * before. Omit if the new button definition is to be inserted as
\r
1517 * @returns {CKEDITOR.dialog.buttonDefinition} The inserted button
\r
1520 addButton : function( buttonDefinition, nextSiblingId )
\r
1522 return addById( this.buttons, buttonDefinition, nextSiblingId );
\r
1526 * Removes a content definition from this dialog definition.
\r
1527 * @param {String} id The id of the content definition to be removed.
\r
1528 * @returns {CKEDITOR.dialog.contentDefinition} The removed content
\r
1531 removeContents : function( id )
\r
1533 removeById( this.contents, id );
\r
1537 * Removes a button definition from the dialog definition.
\r
1538 * @param {String} id The id of the button definition to be removed.
\r
1539 * @returns {CKEDITOR.dialog.buttonDefinition} The removed button
\r
1542 removeButton : function( id )
\r
1544 removeById( this.buttons, id );
\r
1549 * This class is not really part of the API. It is the template of the
\r
1550 * objects representing content pages inside the
\r
1551 * CKEDITOR.dialog.dialogDefinitionObject.
\r
1553 * @name CKEDITOR.dialog.contentDefinitionObject
\r
1555 * CKEDITOR.on( 'dialogDefinition', function( evt )
\r
1557 * var definition = evt.data.definition;
\r
1558 * var content = definition.getContents( 'page1' );
\r
1559 * content.remove( 'textInput1' );
\r
1563 function contentObject( dialog, contentDefinition )
\r
1570 CKEDITOR.tools.extend( this, contentDefinition );
\r
1573 contentObject.prototype =
\r
1574 /** @lends CKEDITOR.dialog.contentDefinitionObject.prototype */
\r
1577 * Gets a UI element definition under the content definition.
\r
1578 * @param {String} id The id of the UI element definition.
\r
1579 * @returns {CKEDITOR.dialog.uiElementDefinition}
\r
1581 get : function( id )
\r
1583 return getById( this.elements, id, 'children' );
\r
1587 * Adds a UI element definition to the content definition.
\r
1588 * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition The
\r
1589 * UI elemnet definition to be added.
\r
1590 * @param {String} nextSiblingId The id of an existing UI element
\r
1591 * definition which the new UI element definition will be inserted
\r
1592 * before. Omit if the new button definition is to be inserted as
\r
1594 * @returns {CKEDITOR.dialog.uiElementDefinition} The element
\r
1595 * definition inserted.
\r
1597 add : function( elementDefinition, nextSiblingId )
\r
1599 return addById( this.elements, elementDefinition, nextSiblingId, 'children' );
\r
1603 * Removes a UI element definition from the content definition.
\r
1604 * @param {String} id The id of the UI element definition to be
\r
1606 * @returns {CKEDITOR.dialog.uiElementDefinition} The element
\r
1607 * definition removed.
\r
1610 remove : function( id )
\r
1612 removeById( this.elements, id, 'children' );
\r
1616 function initDragAndDrop( dialog )
\r
1618 var lastCoords = null,
\r
1619 abstractDialogCoords = null,
\r
1620 element = dialog.getElement().getFirst(),
\r
1621 editor = dialog.getParentEditor(),
\r
1622 magnetDistance = editor.config.dialog_magnetDistance,
\r
1623 margins = editor.skin.margins || [ 0, 0, 0, 0 ];
\r
1625 if ( typeof magnetDistance == 'undefined' )
\r
1626 magnetDistance = 20;
\r
1628 function mouseMoveHandler( evt )
\r
1630 var dialogSize = dialog.getSize(),
\r
1631 viewPaneSize = CKEDITOR.document.getWindow().getViewPaneSize(),
\r
1632 x = evt.data.$.screenX,
\r
1633 y = evt.data.$.screenY,
\r
1634 dx = x - lastCoords.x,
\r
1635 dy = y - lastCoords.y,
\r
1638 lastCoords = { x : x, y : y };
\r
1639 abstractDialogCoords.x += dx;
\r
1640 abstractDialogCoords.y += dy;
\r
1642 if ( abstractDialogCoords.x + margins[3] < magnetDistance )
\r
1643 realX = - margins[3];
\r
1644 else if ( abstractDialogCoords.x - margins[1] > viewPaneSize.width - dialogSize.width - magnetDistance )
\r
1645 realX = viewPaneSize.width - dialogSize.width + ( editor.lang.dir == 'rtl' ? 0 : margins[1] );
\r
1647 realX = abstractDialogCoords.x;
\r
1649 if ( abstractDialogCoords.y + margins[0] < magnetDistance )
\r
1650 realY = - margins[0];
\r
1651 else if ( abstractDialogCoords.y - margins[2] > viewPaneSize.height - dialogSize.height - magnetDistance )
\r
1652 realY = viewPaneSize.height - dialogSize.height + margins[2];
\r
1654 realY = abstractDialogCoords.y;
\r
1656 dialog.move( realX, realY, 1 );
\r
1658 evt.data.preventDefault();
\r
1661 function mouseUpHandler( evt )
\r
1663 CKEDITOR.document.removeListener( 'mousemove', mouseMoveHandler );
\r
1664 CKEDITOR.document.removeListener( 'mouseup', mouseUpHandler );
\r
1666 if ( CKEDITOR.env.ie6Compat )
\r
1668 var coverDoc = currentCover.getChild( 0 ).getFrameDocument();
\r
1669 coverDoc.removeListener( 'mousemove', mouseMoveHandler );
\r
1670 coverDoc.removeListener( 'mouseup', mouseUpHandler );
\r
1674 dialog.parts.title.on( 'mousedown', function( evt )
\r
1676 lastCoords = { x : evt.data.$.screenX, y : evt.data.$.screenY };
\r
1678 CKEDITOR.document.on( 'mousemove', mouseMoveHandler );
\r
1679 CKEDITOR.document.on( 'mouseup', mouseUpHandler );
\r
1680 abstractDialogCoords = dialog.getPosition();
\r
1682 if ( CKEDITOR.env.ie6Compat )
\r
1684 var coverDoc = currentCover.getChild( 0 ).getFrameDocument();
\r
1685 coverDoc.on( 'mousemove', mouseMoveHandler );
\r
1686 coverDoc.on( 'mouseup', mouseUpHandler );
\r
1689 evt.data.preventDefault();
\r
1693 function initResizeHandles( dialog )
\r
1695 var def = dialog.definition,
\r
1696 resizable = def.resizable;
\r
1698 if ( resizable == CKEDITOR.DIALOG_RESIZE_NONE )
\r
1701 var editor = dialog.getParentEditor();
\r
1702 var wrapperWidth, wrapperHeight,
\r
1703 viewSize, origin, startSize,
\r
1706 function positionDialog( right )
\r
1708 // Maintain righthand sizing in RTL.
\r
1709 if ( dialog._.moved && editor.lang.dir == 'rtl' )
\r
1711 var element = dialog._.element.getFirst();
\r
1712 element.setStyle( 'right', right + "px" );
\r
1713 element.removeStyle( 'left' );
\r
1715 else if ( !dialog._.moved )
\r
1719 var mouseDownFn = CKEDITOR.tools.addFunction( function( $event )
\r
1721 startSize = dialog.getSize();
\r
1723 var content = dialog.parts.contents,
\r
1724 iframeDialog = content.$.getElementsByTagName( 'iframe' ).length;
\r
1726 // Shim to help capturing "mousemove" over iframe.
\r
1727 if ( iframeDialog )
\r
1729 dialogCover = CKEDITOR.dom.element.createFromHtml( '<div class="cke_dialog_resize_cover" style="height: 100%; position: absolute; width: 100%;"></div>' );
\r
1730 content.append( dialogCover );
\r
1733 // Calculate the offset between content and chrome size.
\r
1734 wrapperHeight = startSize.height - dialog.parts.contents.getSize( 'height', ! ( CKEDITOR.env.gecko || CKEDITOR.env.opera || CKEDITOR.env.ie && CKEDITOR.env.quirks ) );
\r
1735 wrapperWidth = startSize.width - dialog.parts.contents.getSize( 'width', 1 );
\r
1737 origin = { x : $event.screenX, y : $event.screenY };
\r
1739 viewSize = CKEDITOR.document.getWindow().getViewPaneSize();
\r
1741 CKEDITOR.document.on( 'mousemove', mouseMoveHandler );
\r
1742 CKEDITOR.document.on( 'mouseup', mouseUpHandler );
\r
1744 if ( CKEDITOR.env.ie6Compat )
\r
1746 var coverDoc = currentCover.getChild( 0 ).getFrameDocument();
\r
1747 coverDoc.on( 'mousemove', mouseMoveHandler );
\r
1748 coverDoc.on( 'mouseup', mouseUpHandler );
\r
1751 $event.preventDefault && $event.preventDefault();
\r
1754 // Prepend the grip to the dialog.
\r
1755 dialog.on( 'load', function()
\r
1757 var direction = '';
\r
1758 if ( resizable == CKEDITOR.DIALOG_RESIZE_WIDTH )
\r
1759 direction = ' cke_resizer_horizontal';
\r
1760 else if ( resizable == CKEDITOR.DIALOG_RESIZE_HEIGHT )
\r
1761 direction = ' cke_resizer_vertical';
\r
1762 var resizer = CKEDITOR.dom.element.createFromHtml( '<div class="cke_resizer' + direction + '"' +
\r
1763 ' title="' + CKEDITOR.tools.htmlEncode( editor.lang.resize ) + '"' +
\r
1764 ' onmousedown="CKEDITOR.tools.callFunction(' + mouseDownFn + ', event )"></div>' );
\r
1765 dialog.parts.footer.append( resizer, 1 );
\r
1767 editor.on( 'destroy', function() { CKEDITOR.tools.removeFunction( mouseDownFn ); } );
\r
1769 function mouseMoveHandler( evt )
\r
1771 var rtl = editor.lang.dir == 'rtl',
\r
1772 dx = ( evt.data.$.screenX - origin.x ) * ( rtl ? -1 : 1 ),
\r
1773 dy = evt.data.$.screenY - origin.y,
\r
1774 width = startSize.width,
\r
1775 height = startSize.height,
\r
1776 internalWidth = width + dx * ( dialog._.moved ? 1 : 2 ),
\r
1777 internalHeight = height + dy * ( dialog._.moved ? 1 : 2 ),
\r
1778 element = dialog._.element.getFirst(),
\r
1779 right = rtl && element.getComputedStyle( 'right' ),
\r
1780 position = dialog.getPosition();
\r
1782 // IE might return "auto", we need exact position.
\r
1784 right = right == 'auto' ? viewSize.width - ( position.x || 0 ) - element.getSize( 'width' ) : parseInt( right, 10 );
\r
1786 if ( position.y + internalHeight > viewSize.height )
\r
1787 internalHeight = viewSize.height - position.y;
\r
1789 if ( ( rtl ? right : position.x ) + internalWidth > viewSize.width )
\r
1790 internalWidth = viewSize.width - ( rtl ? right : position.x );
\r
1792 // Make sure the dialog will not be resized to the wrong side when it's in the leftmost position for RTL.
\r
1793 if ( ( resizable == CKEDITOR.DIALOG_RESIZE_WIDTH || resizable == CKEDITOR.DIALOG_RESIZE_BOTH ) && !( rtl && dx > 0 && !position.x ) )
\r
1794 width = Math.max( def.minWidth || 0, internalWidth - wrapperWidth );
\r
1796 if ( resizable == CKEDITOR.DIALOG_RESIZE_HEIGHT || resizable == CKEDITOR.DIALOG_RESIZE_BOTH )
\r
1797 height = Math.max( def.minHeight || 0, internalHeight - wrapperHeight );
\r
1799 dialog.resize( width, height );
\r
1800 // The right property might get broken during resizing, so computing it before the resizing.
\r
1801 positionDialog( right );
\r
1803 evt.data.preventDefault();
\r
1806 function mouseUpHandler()
\r
1808 CKEDITOR.document.removeListener( 'mouseup', mouseUpHandler );
\r
1809 CKEDITOR.document.removeListener( 'mousemove', mouseMoveHandler );
\r
1811 if ( dialogCover )
\r
1813 dialogCover.remove();
\r
1814 dialogCover = null;
\r
1817 if ( CKEDITOR.env.ie6Compat )
\r
1819 var coverDoc = currentCover.getChild( 0 ).getFrameDocument();
\r
1820 coverDoc.removeListener( 'mouseup', mouseUpHandler );
\r
1821 coverDoc.removeListener( 'mousemove', mouseMoveHandler );
\r
1824 // Switch back to use the left property, if RTL is used.
\r
1825 if ( editor.lang.dir == 'rtl' )
\r
1827 var element = dialog._.element.getFirst(),
\r
1828 left = element.getComputedStyle( 'left' );
\r
1830 // IE might return "auto", we need exact position.
\r
1831 if ( left == 'auto' )
\r
1832 left = viewSize.width - parseInt( element.getStyle( 'right' ), 10 ) - dialog.getSize().width;
\r
1834 left = parseInt( left, 10 );
\r
1836 element.removeStyle( 'right' );
\r
1837 // Make sure the left property gets applied, even if it is the same as previously.
\r
1838 dialog._.position.x += 1;
\r
1839 dialog.move( left, dialog._.position.y );
\r
1845 // Caching resuable covers and allowing only one cover
\r
1850 function showCover( editor )
\r
1852 var win = CKEDITOR.document.getWindow();
\r
1853 var config = editor.config,
\r
1854 backgroundColorStyle = config.dialog_backgroundCoverColor || 'white',
\r
1855 backgroundCoverOpacity = config.dialog_backgroundCoverOpacity,
\r
1856 baseFloatZIndex = config.baseFloatZIndex,
\r
1857 coverKey = CKEDITOR.tools.genKey(
\r
1858 backgroundColorStyle,
\r
1859 backgroundCoverOpacity,
\r
1860 baseFloatZIndex ),
\r
1861 coverElement = covers[ coverKey ];
\r
1863 if ( !coverElement )
\r
1866 '<div tabIndex="-1" style="position: ', ( CKEDITOR.env.ie6Compat ? 'absolute' : 'fixed' ),
\r
1867 '; z-index: ', baseFloatZIndex,
\r
1868 '; top: 0px; left: 0px; ',
\r
1869 ( !CKEDITOR.env.ie6Compat ? 'background-color: ' + backgroundColorStyle : '' ),
\r
1870 '" class="cke_dialog_background_cover">'
\r
1873 if ( CKEDITOR.env.ie6Compat )
\r
1875 // Support for custom document.domain in IE.
\r
1876 var isCustomDomain = CKEDITOR.env.isCustomDomain(),
\r
1877 iframeHtml = '<html><body style=\\\'background-color:' + backgroundColorStyle + ';\\\'></body></html>';
\r
1881 ' hidefocus="true"' +
\r
1882 ' frameborder="0"' +
\r
1883 ' id="cke_dialog_background_iframe"' +
\r
1884 ' src="javascript:' );
\r
1886 html.push( 'void((function(){' +
\r
1887 'document.open();' +
\r
1888 ( isCustomDomain ? 'document.domain=\'' + document.domain + '\';' : '' ) +
\r
1889 'document.write( \'' + iframeHtml + '\' );' +
\r
1890 'document.close();' +
\r
1896 'position:absolute;' +
\r
1901 'progid:DXImageTransform.Microsoft.Alpha(opacity=0)">' +
\r
1905 html.push( '</div>' );
\r
1907 coverElement = CKEDITOR.dom.element.createFromHtml( html.join( '' ) );
\r
1908 coverElement.setOpacity( backgroundCoverOpacity != undefined ? backgroundCoverOpacity : 0.5 );
\r
1910 coverElement.appendTo( CKEDITOR.document.getBody() );
\r
1911 covers[ coverKey ] = coverElement;
\r
1914 coverElement. show();
\r
1916 currentCover = coverElement;
\r
1917 var resizeFunc = function()
\r
1919 var size = win.getViewPaneSize();
\r
1920 coverElement.setStyles(
\r
1922 width : size.width + 'px',
\r
1923 height : size.height + 'px'
\r
1927 var scrollFunc = function()
\r
1929 var pos = win.getScrollPosition(),
\r
1930 cursor = CKEDITOR.dialog._.currentTop;
\r
1931 coverElement.setStyles(
\r
1933 left : pos.x + 'px',
\r
1934 top : pos.y + 'px'
\r
1941 var dialogPos = cursor.getPosition();
\r
1942 cursor.move( dialogPos.x, dialogPos.y );
\r
1943 } while ( ( cursor = cursor._.parentDialog ) );
\r
1947 resizeCover = resizeFunc;
\r
1948 win.on( 'resize', resizeFunc );
\r
1950 // Using Safari/Mac, focus must be kept where it is (#7027)
\r
1951 if ( !( CKEDITOR.env.mac && CKEDITOR.env.webkit ) )
\r
1952 coverElement.focus();
\r
1954 if ( CKEDITOR.env.ie6Compat )
\r
1956 // IE BUG: win.$.onscroll assignment doesn't work.. it must be window.onscroll.
\r
1957 // So we need to invent a really funny way to make it work.
\r
1958 var myScrollHandler = function()
\r
1961 arguments.callee.prevScrollHandler.apply( this, arguments );
\r
1963 win.$.setTimeout( function()
\r
1965 myScrollHandler.prevScrollHandler = window.onscroll || function(){};
\r
1966 window.onscroll = myScrollHandler;
\r
1972 function hideCover()
\r
1974 if ( !currentCover )
\r
1977 var win = CKEDITOR.document.getWindow();
\r
1978 currentCover.hide();
\r
1979 win.removeListener( 'resize', resizeCover );
\r
1981 if ( CKEDITOR.env.ie6Compat )
\r
1983 win.$.setTimeout( function()
\r
1985 var prevScrollHandler = window.onscroll && window.onscroll.prevScrollHandler;
\r
1986 window.onscroll = prevScrollHandler || null;
\r
1989 resizeCover = null;
\r
1992 function removeCovers()
\r
1994 for ( var coverId in covers )
\r
1995 covers[ coverId ].remove();
\r
1999 var accessKeyProcessors = {};
\r
2001 var accessKeyDownHandler = function( evt )
\r
2003 var ctrl = evt.data.$.ctrlKey || evt.data.$.metaKey,
\r
2004 alt = evt.data.$.altKey,
\r
2005 shift = evt.data.$.shiftKey,
\r
2006 key = String.fromCharCode( evt.data.$.keyCode ),
\r
2007 keyProcessor = accessKeyProcessors[( ctrl ? 'CTRL+' : '' ) + ( alt ? 'ALT+' : '') + ( shift ? 'SHIFT+' : '' ) + key];
\r
2009 if ( !keyProcessor || !keyProcessor.length )
\r
2012 keyProcessor = keyProcessor[keyProcessor.length - 1];
\r
2013 keyProcessor.keydown && keyProcessor.keydown.call( keyProcessor.uiElement, keyProcessor.dialog, keyProcessor.key );
\r
2014 evt.data.preventDefault();
\r
2017 var accessKeyUpHandler = function( evt )
\r
2019 var ctrl = evt.data.$.ctrlKey || evt.data.$.metaKey,
\r
2020 alt = evt.data.$.altKey,
\r
2021 shift = evt.data.$.shiftKey,
\r
2022 key = String.fromCharCode( evt.data.$.keyCode ),
\r
2023 keyProcessor = accessKeyProcessors[( ctrl ? 'CTRL+' : '' ) + ( alt ? 'ALT+' : '') + ( shift ? 'SHIFT+' : '' ) + key];
\r
2025 if ( !keyProcessor || !keyProcessor.length )
\r
2028 keyProcessor = keyProcessor[keyProcessor.length - 1];
\r
2029 if ( keyProcessor.keyup )
\r
2031 keyProcessor.keyup.call( keyProcessor.uiElement, keyProcessor.dialog, keyProcessor.key );
\r
2032 evt.data.preventDefault();
\r
2036 var registerAccessKey = function( uiElement, dialog, key, downFunc, upFunc )
\r
2038 var procList = accessKeyProcessors[key] || ( accessKeyProcessors[key] = [] );
\r
2040 uiElement : uiElement,
\r
2043 keyup : upFunc || uiElement.accessKeyUp,
\r
2044 keydown : downFunc || uiElement.accessKeyDown
\r
2048 var unregisterAccessKey = function( obj )
\r
2050 for ( var i in accessKeyProcessors )
\r
2052 var list = accessKeyProcessors[i];
\r
2053 for ( var j = list.length - 1 ; j >= 0 ; j-- )
\r
2055 if ( list[j].dialog == obj || list[j].uiElement == obj )
\r
2056 list.splice( j, 1 );
\r
2058 if ( list.length === 0 )
\r
2059 delete accessKeyProcessors[i];
\r
2063 var tabAccessKeyUp = function( dialog, key )
\r
2065 if ( dialog._.accessKeyMap[key] )
\r
2066 dialog.selectPage( dialog._.accessKeyMap[key] );
\r
2069 var tabAccessKeyDown = function( dialog, key )
\r
2074 var preventKeyBubblingKeys = { 27 :1, 13 :1 };
\r
2075 var preventKeyBubbling = function( e )
\r
2077 if ( e.data.getKeystroke() in preventKeyBubblingKeys )
\r
2078 e.data.stopPropagation();
\r
2083 CKEDITOR.ui.dialog =
\r
2086 * The base class of all dialog UI elements.
\r
2088 * @param {CKEDITOR.dialog} dialog Parent dialog object.
\r
2089 * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition Element
\r
2090 * definition. Accepted fields:
\r
2092 * <li><strong>id</strong> (Required) The id of the UI element. See {@link
\r
2093 * CKEDITOR.dialog#getContentElement}</li>
\r
2094 * <li><strong>type</strong> (Required) The type of the UI element. The
\r
2095 * value to this field specifies which UI element class will be used to
\r
2096 * generate the final widget.</li>
\r
2097 * <li><strong>title</strong> (Optional) The popup tooltip for the UI
\r
2099 * <li><strong>hidden</strong> (Optional) A flag that tells if the element
\r
2100 * should be initially visible.</li>
\r
2101 * <li><strong>className</strong> (Optional) Additional CSS class names
\r
2102 * to add to the UI element. Separated by space.</li>
\r
2103 * <li><strong>style</strong> (Optional) Additional CSS inline styles
\r
2104 * to add to the UI element. A semicolon (;) is required after the last
\r
2105 * style declaration.</li>
\r
2106 * <li><strong>accessKey</strong> (Optional) The alphanumeric access key
\r
2107 * for this element. Access keys are automatically prefixed by CTRL.</li>
\r
2108 * <li><strong>on*</strong> (Optional) Any UI element definition field that
\r
2109 * starts with <em>on</em> followed immediately by a capital letter and
\r
2110 * probably more letters is an event handler. Event handlers may be further
\r
2111 * divided into registered event handlers and DOM event handlers. Please
\r
2112 * refer to {@link CKEDITOR.ui.dialog.uiElement#registerEvents} and
\r
2113 * {@link CKEDITOR.ui.dialog.uiElement#eventProcessors} for more
\r
2114 * information.</li>
\r
2116 * @param {Array} htmlList
\r
2117 * List of HTML code to be added to the dialog's content area.
\r
2118 * @param {Function|String} nodeNameArg
\r
2119 * A function returning a string, or a simple string for the node name for
\r
2120 * the root DOM node. Default is 'div'.
\r
2121 * @param {Function|Object} stylesArg
\r
2122 * A function returning an object, or a simple object for CSS styles applied
\r
2123 * to the DOM node. Default is empty object.
\r
2124 * @param {Function|Object} attributesArg
\r
2125 * A fucntion returning an object, or a simple object for attributes applied
\r
2126 * to the DOM node. Default is empty object.
\r
2127 * @param {Function|String} contentsArg
\r
2128 * A function returning a string, or a simple string for the HTML code inside
\r
2129 * the root DOM node. Default is empty string.
\r
2132 uiElement : function( dialog, elementDefinition, htmlList, nodeNameArg, stylesArg, attributesArg, contentsArg )
\r
2134 if ( arguments.length < 4 )
\r
2137 var nodeName = ( nodeNameArg.call ? nodeNameArg( elementDefinition ) : nodeNameArg ) || 'div',
\r
2138 html = [ '<', nodeName, ' ' ],
\r
2139 styles = ( stylesArg && stylesArg.call ? stylesArg( elementDefinition ) : stylesArg ) || {},
\r
2140 attributes = ( attributesArg && attributesArg.call ? attributesArg( elementDefinition ) : attributesArg ) || {},
\r
2141 innerHTML = ( contentsArg && contentsArg.call ? contentsArg.call( this, dialog, elementDefinition ) : contentsArg ) || '',
\r
2142 domId = this.domId = attributes.id || CKEDITOR.tools.getNextId() + '_uiElement',
\r
2143 id = this.id = elementDefinition.id,
\r
2146 // Set the id, a unique id is required for getElement() to work.
\r
2147 attributes.id = domId;
\r
2149 // Set the type and definition CSS class names.
\r
2151 if ( elementDefinition.type )
\r
2152 classes[ 'cke_dialog_ui_' + elementDefinition.type ] = 1;
\r
2153 if ( elementDefinition.className )
\r
2154 classes[ elementDefinition.className ] = 1;
\r
2155 var attributeClasses = ( attributes['class'] && attributes['class'].split ) ? attributes['class'].split( ' ' ) : [];
\r
2156 for ( i = 0 ; i < attributeClasses.length ; i++ )
\r
2158 if ( attributeClasses[i] )
\r
2159 classes[ attributeClasses[i] ] = 1;
\r
2161 var finalClasses = [];
\r
2162 for ( i in classes )
\r
2163 finalClasses.push( i );
\r
2164 attributes['class'] = finalClasses.join( ' ' );
\r
2166 // Set the popup tooltop.
\r
2167 if ( elementDefinition.title )
\r
2168 attributes.title = elementDefinition.title;
\r
2170 // Write the inline CSS styles.
\r
2171 var styleStr = ( elementDefinition.style || '' ).split( ';' );
\r
2172 for ( i in styles )
\r
2173 styleStr.push( i + ':' + styles[i] );
\r
2174 if ( elementDefinition.hidden )
\r
2175 styleStr.push( 'display:none' );
\r
2176 for ( i = styleStr.length - 1 ; i >= 0 ; i-- )
\r
2178 if ( styleStr[i] === '' )
\r
2179 styleStr.splice( i, 1 );
\r
2181 if ( styleStr.length > 0 )
\r
2182 attributes.style = ( attributes.style ? ( attributes.style + '; ' ) : '' ) + styleStr.join( '; ' );
\r
2184 // Write the attributes.
\r
2185 for ( i in attributes )
\r
2186 html.push( i + '="' + CKEDITOR.tools.htmlEncode( attributes[i] ) + '" ');
\r
2188 // Write the content HTML.
\r
2189 html.push( '>', innerHTML, '</', nodeName, '>' );
\r
2191 // Add contents to the parent HTML array.
\r
2192 htmlList.push( html.join( '' ) );
\r
2194 ( this._ || ( this._ = {} ) ).dialog = dialog;
\r
2196 // Override isChanged if it is defined in element definition.
\r
2197 if ( typeof( elementDefinition.isChanged ) == 'boolean' )
\r
2198 this.isChanged = function(){ return elementDefinition.isChanged; };
\r
2199 if ( typeof( elementDefinition.isChanged ) == 'function' )
\r
2200 this.isChanged = elementDefinition.isChanged;
\r
2203 CKEDITOR.event.implementOn( this );
\r
2205 this.registerEvents( elementDefinition );
\r
2206 if ( this.accessKeyUp && this.accessKeyDown && elementDefinition.accessKey )
\r
2207 registerAccessKey( this, dialog, 'CTRL+' + elementDefinition.accessKey );
\r
2210 dialog.on( 'load', function()
\r
2212 if ( me.getInputElement() )
\r
2214 me.getInputElement().on( 'focus', function()
\r
2216 dialog._.tabBarMode = false;
\r
2217 dialog._.hasFocus = true;
\r
2218 me.fire( 'focus' );
\r
2223 // Register the object as a tab focus if it can be included.
\r
2224 if ( this.keyboardFocusable )
\r
2226 this.tabIndex = elementDefinition.tabIndex || 0;
\r
2228 this.focusIndex = dialog._.focusList.push( this ) - 1;
\r
2229 this.on( 'focus', function()
\r
2231 dialog._.currentFocusIndex = me.focusIndex;
\r
2235 // Completes this object with everything we have in the
\r
2237 CKEDITOR.tools.extend( this, elementDefinition );
\r
2241 * Horizontal layout box for dialog UI elements, auto-expends to available width of container.
\r
2243 * @extends CKEDITOR.ui.dialog.uiElement
\r
2244 * @param {CKEDITOR.dialog} dialog
\r
2245 * Parent dialog object.
\r
2246 * @param {Array} childObjList
\r
2247 * Array of {@link CKEDITOR.ui.dialog.uiElement} objects inside this
\r
2249 * @param {Array} childHtmlList
\r
2250 * Array of HTML code that correspond to the HTML output of all the
\r
2251 * objects in childObjList.
\r
2252 * @param {Array} htmlList
\r
2253 * Array of HTML code that this element will output to.
\r
2254 * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition
\r
2255 * The element definition. Accepted fields:
\r
2257 * <li><strong>widths</strong> (Optional) The widths of child cells.</li>
\r
2258 * <li><strong>height</strong> (Optional) The height of the layout.</li>
\r
2259 * <li><strong>padding</strong> (Optional) The padding width inside child
\r
2261 * <li><strong>align</strong> (Optional) The alignment of the whole layout
\r
2266 hbox : function( dialog, childObjList, childHtmlList, htmlList, elementDefinition )
\r
2268 if ( arguments.length < 4 )
\r
2271 this._ || ( this._ = {} );
\r
2273 var children = this._.children = childObjList,
\r
2274 widths = elementDefinition && elementDefinition.widths || null,
\r
2275 height = elementDefinition && elementDefinition.height || null,
\r
2279 var innerHTML = function()
\r
2281 var html = [ '<tbody><tr class="cke_dialog_ui_hbox">' ];
\r
2282 for ( i = 0 ; i < childHtmlList.length ; i++ )
\r
2284 var className = 'cke_dialog_ui_hbox_child',
\r
2287 className = 'cke_dialog_ui_hbox_first';
\r
2288 if ( i == childHtmlList.length - 1 )
\r
2289 className = 'cke_dialog_ui_hbox_last';
\r
2290 html.push( '<td class="', className, '" role="presentation" ' );
\r
2294 styles.push( 'width:' + cssLength( widths[i] ) );
\r
2297 styles.push( 'width:' + Math.floor( 100 / childHtmlList.length ) + '%' );
\r
2299 styles.push( 'height:' + cssLength( height ) );
\r
2300 if ( elementDefinition && elementDefinition.padding != undefined )
\r
2301 styles.push( 'padding:' + cssLength( elementDefinition.padding ) );
\r
2302 if ( styles.length > 0 )
\r
2303 html.push( 'style="' + styles.join('; ') + '" ' );
\r
2304 html.push( '>', childHtmlList[i], '</td>' );
\r
2306 html.push( '</tr></tbody>' );
\r
2307 return html.join( '' );
\r
2310 var attribs = { role : 'presentation' };
\r
2311 elementDefinition && elementDefinition.align && ( attribs.align = elementDefinition.align );
\r
2313 CKEDITOR.ui.dialog.uiElement.call(
\r
2316 elementDefinition || { type : 'hbox' },
\r
2325 * Vertical layout box for dialog UI elements.
\r
2327 * @extends CKEDITOR.ui.dialog.hbox
\r
2328 * @param {CKEDITOR.dialog} dialog
\r
2329 * Parent dialog object.
\r
2330 * @param {Array} childObjList
\r
2331 * Array of {@link CKEDITOR.ui.dialog.uiElement} objects inside this
\r
2333 * @param {Array} childHtmlList
\r
2334 * Array of HTML code that correspond to the HTML output of all the
\r
2335 * objects in childObjList.
\r
2336 * @param {Array} htmlList
\r
2337 * Array of HTML code that this element will output to.
\r
2338 * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition
\r
2339 * The element definition. Accepted fields:
\r
2341 * <li><strong>width</strong> (Optional) The width of the layout.</li>
\r
2342 * <li><strong>heights</strong> (Optional) The heights of individual cells.
\r
2344 * <li><strong>align</strong> (Optional) The alignment of the layout.</li>
\r
2345 * <li><strong>padding</strong> (Optional) The padding width inside child
\r
2347 * <li><strong>expand</strong> (Optional) Whether the layout should expand
\r
2348 * vertically to fill its container.</li>
\r
2352 vbox : function( dialog, childObjList, childHtmlList, htmlList, elementDefinition )
\r
2354 if ( arguments.length < 3 )
\r
2357 this._ || ( this._ = {} );
\r
2359 var children = this._.children = childObjList,
\r
2360 width = elementDefinition && elementDefinition.width || null,
\r
2361 heights = elementDefinition && elementDefinition.heights || null;
\r
2363 var innerHTML = function()
\r
2365 var html = [ '<table role="presentation" cellspacing="0" border="0" ' ];
\r
2366 html.push( 'style="' );
\r
2367 if ( elementDefinition && elementDefinition.expand )
\r
2368 html.push( 'height:100%;' );
\r
2369 html.push( 'width:' + cssLength( width || '100%' ), ';' );
\r
2371 html.push( 'align="', CKEDITOR.tools.htmlEncode(
\r
2372 ( elementDefinition && elementDefinition.align ) || ( dialog.getParentEditor().lang.dir == 'ltr' ? 'left' : 'right' ) ), '" ' );
\r
2374 html.push( '><tbody>' );
\r
2375 for ( var i = 0 ; i < childHtmlList.length ; i++ )
\r
2378 html.push( '<tr><td role="presentation" ' );
\r
2380 styles.push( 'width:' + cssLength( width || '100%' ) );
\r
2382 styles.push( 'height:' + cssLength( heights[i] ) );
\r
2383 else if ( elementDefinition && elementDefinition.expand )
\r
2384 styles.push( 'height:' + Math.floor( 100 / childHtmlList.length ) + '%' );
\r
2385 if ( elementDefinition && elementDefinition.padding != undefined )
\r
2386 styles.push( 'padding:' + cssLength( elementDefinition.padding ) );
\r
2387 if ( styles.length > 0 )
\r
2388 html.push( 'style="', styles.join( '; ' ), '" ' );
\r
2389 html.push( ' class="cke_dialog_ui_vbox_child">', childHtmlList[i], '</td></tr>' );
\r
2391 html.push( '</tbody></table>' );
\r
2392 return html.join( '' );
\r
2394 CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition || { type : 'vbox' }, htmlList, 'div', null, { role : 'presentation' }, innerHTML );
\r
2399 CKEDITOR.ui.dialog.uiElement.prototype =
\r
2402 * Gets the root DOM element of this dialog UI object.
\r
2403 * @returns {CKEDITOR.dom.element} Root DOM element of UI object.
\r
2405 * uiElement.getElement().hide();
\r
2407 getElement : function()
\r
2409 return CKEDITOR.document.getById( this.domId );
\r
2413 * Gets the DOM element that the user inputs values.
\r
2414 * This function is used by setValue(), getValue() and focus(). It should
\r
2415 * be overrided in child classes where the input element isn't the root
\r
2417 * @returns {CKEDITOR.dom.element} The element where the user input values.
\r
2419 * var rawValue = textInput.getInputElement().$.value;
\r
2421 getInputElement : function()
\r
2423 return this.getElement();
\r
2427 * Gets the parent dialog object containing this UI element.
\r
2428 * @returns {CKEDITOR.dialog} Parent dialog object.
\r
2430 * var dialog = uiElement.getDialog();
\r
2432 getDialog : function()
\r
2434 return this._.dialog;
\r
2438 * Sets the value of this dialog UI object.
\r
2439 * @param {Object} value The new value.
\r
2440 * @param {Boolean} noChangeEvent Internal commit, to supress 'change' event on this element.
\r
2441 * @returns {CKEDITOR.dialog.uiElement} The current UI element.
\r
2443 * uiElement.setValue( 'Dingo' );
\r
2445 setValue : function( value, noChangeEvent )
\r
2447 this.getInputElement().setValue( value );
\r
2448 !noChangeEvent && this.fire( 'change', { value : value } );
\r
2453 * Gets the current value of this dialog UI object.
\r
2454 * @returns {Object} The current value.
\r
2456 * var myValue = uiElement.getValue();
\r
2458 getValue : function()
\r
2460 return this.getInputElement().getValue();
\r
2464 * Tells whether the UI object's value has changed.
\r
2465 * @returns {Boolean} true if changed, false if not changed.
\r
2467 * if ( uiElement.isChanged() )
\r
2468 * confirm( 'Value changed! Continue?' );
\r
2470 isChanged : function()
\r
2472 // Override in input classes.
\r
2477 * Selects the parent tab of this element. Usually called by focus() or overridden focus() methods.
\r
2478 * @returns {CKEDITOR.dialog.uiElement} The current UI element.
\r
2480 * focus : function()
\r
2482 * this.selectParentTab();
\r
2483 * // do something else.
\r
2486 selectParentTab : function()
\r
2488 var element = this.getInputElement(),
\r
2491 while ( ( cursor = cursor.getParent() ) && cursor.$.className.search( 'cke_dialog_page_contents' ) == -1 )
\r
2494 // Some widgets don't have parent tabs (e.g. OK and Cancel buttons).
\r
2498 tabId = cursor.getAttribute( 'name' );
\r
2499 // Avoid duplicate select.
\r
2500 if ( this._.dialog._.currentTabId != tabId )
\r
2501 this._.dialog.selectPage( tabId );
\r
2506 * Puts the focus to the UI object. Switches tabs if the UI object isn't in the active tab page.
\r
2507 * @returns {CKEDITOR.dialog.uiElement} The current UI element.
\r
2509 * uiElement.focus();
\r
2511 focus : function()
\r
2513 this.selectParentTab().getInputElement().focus();
\r
2518 * Registers the on* event handlers defined in the element definition.
\r
2519 * The default behavior of this function is:
\r
2522 * If the on* event is defined in the class's eventProcesors list,
\r
2523 * then the registration is delegated to the corresponding function
\r
2524 * in the eventProcessors list.
\r
2527 * If the on* event is not defined in the eventProcessors list, then
\r
2528 * register the event handler under the corresponding DOM event of
\r
2529 * the UI element's input DOM element (as defined by the return value
\r
2530 * of {@link CKEDITOR.ui.dialog.uiElement#getInputElement}).
\r
2533 * This function is only called at UI element instantiation, but can
\r
2534 * be overridded in child classes if they require more flexibility.
\r
2535 * @param {CKEDITOR.dialog.uiElementDefinition} definition The UI element
\r
2537 * @returns {CKEDITOR.dialog.uiElement} The current UI element.
\r
2540 registerEvents : function( definition )
\r
2542 var regex = /^on([A-Z]\w+)/,
\r
2545 var registerDomEvent = function( uiElement, dialog, eventName, func )
\r
2547 dialog.on( 'load', function()
\r
2549 uiElement.getInputElement().on( eventName, func, uiElement );
\r
2553 for ( var i in definition )
\r
2555 if ( !( match = i.match( regex ) ) )
\r
2557 if ( this.eventProcessors[i] )
\r
2558 this.eventProcessors[i].call( this, this._.dialog, definition[i] );
\r
2560 registerDomEvent( this, this._.dialog, match[1].toLowerCase(), definition[i] );
\r
2567 * The event processor list used by
\r
2568 * {@link CKEDITOR.ui.dialog.uiElement#getInputElement} at UI element
\r
2569 * instantiation. The default list defines three on* events:
\r
2571 * <li>onLoad - Called when the element's parent dialog opens for the
\r
2573 * <li>onShow - Called whenever the element's parent dialog opens.</li>
\r
2574 * <li>onHide - Called whenever the element's parent dialog closes.</li>
\r
2579 * // This connects the 'click' event in CKEDITOR.ui.dialog.button to onClick
\r
2580 * // handlers in the UI element's definitions.
\r
2581 * CKEDITOR.ui.dialog.button.eventProcessors = CKEDITOR.tools.extend( {},
\r
2582 * CKEDITOR.ui.dialog.uiElement.prototype.eventProcessors,
\r
2583 * { onClick : function( dialog, func ) { this.on( 'click', func ); } },
\r
2584 * true );
\r
2588 onLoad : function( dialog, func )
\r
2590 dialog.on( 'load', func, this );
\r
2593 onShow : function( dialog, func )
\r
2595 dialog.on( 'show', func, this );
\r
2598 onHide : function( dialog, func )
\r
2600 dialog.on( 'hide', func, this );
\r
2605 * The default handler for a UI element's access key down event, which
\r
2606 * tries to put focus to the UI element.<br />
\r
2607 * Can be overridded in child classes for more sophisticaed behavior.
\r
2608 * @param {CKEDITOR.dialog} dialog The parent dialog object.
\r
2609 * @param {String} key The key combination pressed. Since access keys
\r
2610 * are defined to always include the CTRL key, its value should always
\r
2611 * include a 'CTRL+' prefix.
\r
2614 accessKeyDown : function( dialog, key )
\r
2620 * The default handler for a UI element's access key up event, which
\r
2621 * does nothing.<br />
\r
2622 * Can be overridded in child classes for more sophisticated behavior.
\r
2623 * @param {CKEDITOR.dialog} dialog The parent dialog object.
\r
2624 * @param {String} key The key combination pressed. Since access keys
\r
2625 * are defined to always include the CTRL key, its value should always
\r
2626 * include a 'CTRL+' prefix.
\r
2629 accessKeyUp : function( dialog, key )
\r
2634 * Disables a UI element.
\r
2637 disable : function()
\r
2639 var element = this.getInputElement();
\r
2640 element.setAttribute( 'disabled', 'true' );
\r
2641 element.addClass( 'cke_disabled' );
\r
2645 * Enables a UI element.
\r
2648 enable : function()
\r
2650 var element = this.getInputElement();
\r
2651 element.removeAttribute( 'disabled' );
\r
2652 element.removeClass( 'cke_disabled' );
\r
2656 * Determines whether an UI element is enabled or not.
\r
2657 * @returns {Boolean} Whether the UI element is enabled.
\r
2660 isEnabled : function()
\r
2662 return !this.getInputElement().getAttribute( 'disabled' );
\r
2666 * Determines whether an UI element is visible or not.
\r
2667 * @returns {Boolean} Whether the UI element is visible.
\r
2670 isVisible : function()
\r
2672 return this.getInputElement().isVisible();
\r
2676 * Determines whether an UI element is focus-able or not.
\r
2677 * Focus-able is defined as being both visible and enabled.
\r
2678 * @returns {Boolean} Whether the UI element can be focused.
\r
2681 isFocusable : function()
\r
2683 if ( !this.isEnabled() || !this.isVisible() )
\r
2689 CKEDITOR.ui.dialog.hbox.prototype = CKEDITOR.tools.extend( new CKEDITOR.ui.dialog.uiElement,
\r
2691 * @lends CKEDITOR.ui.dialog.hbox.prototype
\r
2695 * Gets a child UI element inside this container.
\r
2696 * @param {Array|Number} indices An array or a single number to indicate the child's
\r
2697 * position in the container's descendant tree. Omit to get all the children in an array.
\r
2698 * @returns {Array|CKEDITOR.ui.dialog.uiElement} Array of all UI elements in the container
\r
2699 * if no argument given, or the specified UI element if indices is given.
\r
2701 * var checkbox = hbox.getChild( [0,1] );
\r
2702 * checkbox.setValue( true );
\r
2704 getChild : function( indices )
\r
2706 // If no arguments, return a clone of the children array.
\r
2707 if ( arguments.length < 1 )
\r
2708 return this._.children.concat();
\r
2710 // If indices isn't array, make it one.
\r
2711 if ( !indices.splice )
\r
2712 indices = [ indices ];
\r
2714 // Retrieve the child element according to tree position.
\r
2715 if ( indices.length < 2 )
\r
2716 return this._.children[ indices[0] ];
\r
2718 return ( this._.children[ indices[0] ] && this._.children[ indices[0] ].getChild ) ?
\r
2719 this._.children[ indices[0] ].getChild( indices.slice( 1, indices.length ) ) :
\r
2724 CKEDITOR.ui.dialog.vbox.prototype = new CKEDITOR.ui.dialog.hbox();
\r
2730 var commonBuilder = {
\r
2731 build : function( dialog, elementDefinition, output )
\r
2733 var children = elementDefinition.children,
\r
2735 childHtmlList = [],
\r
2736 childObjList = [];
\r
2737 for ( var i = 0 ; ( i < children.length && ( child = children[i] ) ) ; i++ )
\r
2739 var childHtml = [];
\r
2740 childHtmlList.push( childHtml );
\r
2741 childObjList.push( CKEDITOR.dialog._.uiElementBuilders[ child.type ].build( dialog, child, childHtml ) );
\r
2743 return new CKEDITOR.ui.dialog[elementDefinition.type]( dialog, childObjList, childHtmlList, output, elementDefinition );
\r
2747 CKEDITOR.dialog.addUIElement( 'hbox', commonBuilder );
\r
2748 CKEDITOR.dialog.addUIElement( 'vbox', commonBuilder );
\r
2752 * Generic dialog command. It opens a specific dialog when executed.
\r
2754 * @augments CKEDITOR.commandDefinition
\r
2755 * @param {string} dialogName The name of the dialog to open when executing
\r
2758 * // Register the "link" command, which opens the "link" dialog.
\r
2759 * editor.addCommand( 'link', <b>new CKEDITOR.dialogCommand( 'link' )</b> );
\r
2761 CKEDITOR.dialogCommand = function( dialogName )
\r
2763 this.dialogName = dialogName;
\r
2766 CKEDITOR.dialogCommand.prototype =
\r
2769 exec : function( editor )
\r
2771 editor.openDialog( this.dialogName );
\r
2774 // Dialog commands just open a dialog ui, thus require no undo logic,
\r
2775 // undo support should dedicate to specific dialog implementation.
\r
2778 editorFocus : CKEDITOR.env.ie || CKEDITOR.env.webkit
\r
2783 var notEmptyRegex = /^([a]|[^a])+$/,
\r
2784 integerRegex = /^\d*$/,
\r
2785 numberRegex = /^\d*(?:\.\d+)?$/;
\r
2787 CKEDITOR.VALIDATE_OR = 1;
\r
2788 CKEDITOR.VALIDATE_AND = 2;
\r
2790 CKEDITOR.dialog.validate =
\r
2792 functions : function()
\r
2797 * It's important for validate functions to be able to accept the value
\r
2798 * as argument in addition to this.getValue(), so that it is possible to
\r
2799 * combine validate functions together to make more sophisticated
\r
2802 var value = this && this.getValue ? this.getValue() : arguments[0];
\r
2804 var msg = undefined,
\r
2805 relation = CKEDITOR.VALIDATE_AND,
\r
2806 functions = [], i;
\r
2808 for ( i = 0 ; i < arguments.length ; i++ )
\r
2810 if ( typeof( arguments[i] ) == 'function' )
\r
2811 functions.push( arguments[i] );
\r
2816 if ( i < arguments.length && typeof( arguments[i] ) == 'string' )
\r
2818 msg = arguments[i];
\r
2822 if ( i < arguments.length && typeof( arguments[i]) == 'number' )
\r
2823 relation = arguments[i];
\r
2825 var passed = ( relation == CKEDITOR.VALIDATE_AND ? true : false );
\r
2826 for ( i = 0 ; i < functions.length ; i++ )
\r
2828 if ( relation == CKEDITOR.VALIDATE_AND )
\r
2829 passed = passed && functions[i]( value );
\r
2831 passed = passed || functions[i]( value );
\r
2836 if ( msg !== undefined )
\r
2838 if ( this && ( this.select || this.focus ) )
\r
2839 ( this.select || this.focus )();
\r
2847 regex : function( regex, msg )
\r
2850 * Can be greatly shortened by deriving from functions validator if code size
\r
2851 * turns out to be more important than performance.
\r
2855 var value = this && this.getValue ? this.getValue() : arguments[0];
\r
2856 if ( !regex.test( value ) )
\r
2858 if ( msg !== undefined )
\r
2860 if ( this && ( this.select || this.focus ) )
\r
2862 if ( this.select )
\r
2873 notEmpty : function( msg )
\r
2875 return this.regex( notEmptyRegex, msg );
\r
2878 integer : function( msg )
\r
2880 return this.regex( integerRegex, msg );
\r
2883 'number' : function( msg )
\r
2885 return this.regex( numberRegex, msg );
\r
2888 equals : function( value, msg )
\r
2890 return this.functions( function( val ){ return val == value; }, msg );
\r
2893 notEqual : function( value, msg )
\r
2895 return this.functions( function( val ){ return val != value; }, msg );
\r
2899 CKEDITOR.on( 'instanceDestroyed', function( evt )
\r
2901 // Remove dialog cover on last instance destroy.
\r
2902 if ( CKEDITOR.tools.isEmpty( CKEDITOR.instances ) )
\r
2904 var currentTopDialog;
\r
2905 while ( ( currentTopDialog = CKEDITOR.dialog._.currentTop ) )
\r
2906 currentTopDialog.hide();
\r
2910 var dialogs = evt.editor._.storedDialogs;
\r
2911 for ( var name in dialogs )
\r
2912 dialogs[ name ].destroy();
\r
2918 // Extend the CKEDITOR.editor class with dialog specific functions.
\r
2919 CKEDITOR.tools.extend( CKEDITOR.editor.prototype,
\r
2920 /** @lends CKEDITOR.editor.prototype */
\r
2923 * Loads and opens a registered dialog.
\r
2924 * @param {String} dialogName The registered name of the dialog.
\r
2925 * @param {Function} callback The function to be invoked after dialog instance created.
\r
2926 * @see CKEDITOR.dialog.add
\r
2928 * CKEDITOR.instances.editor1.openDialog( 'smiley' );
\r
2929 * @returns {CKEDITOR.dialog} The dialog object corresponding to the dialog displayed. null if the dialog name is not registered.
\r
2931 openDialog : function( dialogName, callback )
\r
2933 if ( this.mode == 'wysiwyg' && CKEDITOR.env.ie )
\r
2935 var selection = this.getSelection();
\r
2936 selection && selection.lock();
\r
2939 var dialogDefinitions = CKEDITOR.dialog._.dialogDefinitions[ dialogName ],
\r
2940 dialogSkin = this.skin.dialog;
\r
2942 if ( CKEDITOR.dialog._.currentTop === null )
\r
2943 showCover( this );
\r
2945 // If the dialogDefinition is already loaded, open it immediately.
\r
2946 if ( typeof dialogDefinitions == 'function' && dialogSkin._isLoaded )
\r
2948 var storedDialogs = this._.storedDialogs ||
\r
2949 ( this._.storedDialogs = {} );
\r
2951 var dialog = storedDialogs[ dialogName ] ||
\r
2952 ( storedDialogs[ dialogName ] = new CKEDITOR.dialog( this, dialogName ) );
\r
2954 callback && callback.call( dialog, dialog );
\r
2959 else if ( dialogDefinitions == 'failed' )
\r
2960 throw new Error( '[CKEDITOR.dialog.openDialog] Dialog "' + dialogName + '" failed when loading definition.' );
\r
2964 function onDialogFileLoaded( success )
\r
2966 var dialogDefinition = CKEDITOR.dialog._.dialogDefinitions[ dialogName ],
\r
2967 skin = me.skin.dialog;
\r
2969 // Check if both skin part and definition is loaded.
\r
2970 if ( !skin._isLoaded || loadDefinition && typeof success == 'undefined' )
\r
2973 // In case of plugin error, mark it as loading failed.
\r
2974 if ( typeof dialogDefinition != 'function' )
\r
2975 CKEDITOR.dialog._.dialogDefinitions[ dialogName ] = 'failed';
\r
2977 me.openDialog( dialogName, callback );
\r
2980 if ( typeof dialogDefinitions == 'string' )
\r
2982 var loadDefinition = 1;
\r
2983 CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( dialogDefinitions ), onDialogFileLoaded, null, 0, 1 );
\r
2986 CKEDITOR.skins.load( this, 'dialog', onDialogFileLoaded );
\r
2993 CKEDITOR.plugins.add( 'dialog',
\r
2995 requires : [ 'dialogui' ]
\r
2998 // Dialog related configurations.
\r
3001 * The color of the dialog background cover. It should be a valid CSS color
\r
3003 * @name CKEDITOR.config.dialog_backgroundCoverColor
\r
3005 * @default 'white'
\r
3007 * config.dialog_backgroundCoverColor = 'rgb(255, 254, 253)';
\r
3011 * The opacity of the dialog background cover. It should be a number within the
\r
3012 * range [0.0, 1.0].
\r
3013 * @name CKEDITOR.config.dialog_backgroundCoverOpacity
\r
3017 * config.dialog_backgroundCoverOpacity = 0.7;
\r
3021 * If the dialog has more than one tab, put focus into the first tab as soon as dialog is opened.
\r
3022 * @name CKEDITOR.config.dialog_startupFocusTab
\r
3026 * config.dialog_startupFocusTab = true;
\r
3030 * The distance of magnetic borders used in moving and resizing dialogs,
\r
3031 * measured in pixels.
\r
3032 * @name CKEDITOR.config.dialog_magnetDistance
\r
3036 * config.dialog_magnetDistance = 30;
\r
3040 * The guideline to follow when generating the dialog buttons. There are 3 possible options:
\r
3042 * <li>'OS' - the buttons will be displayed in the default order of the user's OS;</li>
\r
3043 * <li>'ltr' - for Left-To-Right order;</li>
\r
3044 * <li>'rtl' - for Right-To-Left order.</li>
\r
3046 * @name CKEDITOR.config.dialog_buttonsOrder
\r
3051 * config.dialog_buttonsOrder = 'rtl';
\r
3055 * The dialog contents to removed. It's a string composed by dialog name and tab name with a colon between them.
\r
3056 * Separate each pair with semicolon (see example).
\r
3057 * <b>Note: All names are case-sensitive.</b>
\r
3058 * <b>Note: Be cautious when specifying dialog tabs that are mandatory, like "info", dialog functionality might be broken because of this!</b>
\r
3059 * @name CKEDITOR.config.removeDialogTabs
\r
3064 * config.removeDialogTabs = 'flash:advanced;image:Link';
\r
3068 * Fired when a dialog definition is about to be used to create a dialog into
\r
3069 * an editor instance. This event makes it possible to customize the definition
\r
3070 * before creating it.
\r
3071 * <p>Note that this event is called only the first time a specific dialog is
\r
3072 * opened. Successive openings will use the cached dialog, and this event will
\r
3073 * not get fired.</p>
\r
3074 * @name CKEDITOR#dialogDefinition
\r
3076 * @param {CKEDITOR.dialog.dialogDefinition} data The dialog defination that
\r
3077 * is being loaded.
\r
3078 * @param {CKEDITOR.editor} editor The editor instance that will use the
\r
3083 * Fired when a tab is going to be selected in a dialog
\r
3084 * @name CKEDITOR.dialog#selectPage
\r
3086 * @param {String} page The id of the page that it's gonna be selected.
\r
3087 * @param {String} currentPage The id of the current page.
\r
3091 * Fired when the user tries to dismiss a dialog
\r
3092 * @name CKEDITOR.dialog#cancel
\r
3094 * @param {Boolean} hide Whether the event should proceed or not.
\r
3098 * Fired when the user tries to confirm a dialog
\r
3099 * @name CKEDITOR.dialog#ok
\r
3101 * @param {Boolean} hide Whether the event should proceed or not.
\r
3105 * Fired when a dialog is shown
\r
3106 * @name CKEDITOR.dialog#show
\r
3111 * Fired when a dialog is shown
\r
3112 * @name CKEDITOR.editor#dialogShow
\r
3117 * Fired when a dialog is hidden
\r
3118 * @name CKEDITOR.dialog#hide
\r
3123 * Fired when a dialog is hidden
\r
3124 * @name CKEDITOR.editor#dialogHide
\r
3129 * Fired when a dialog is being resized. The event is fired on
\r
3130 * the 'CKEDITOR.dialog' object, not a dialog instance.
\r
3131 * @name CKEDITOR.dialog#resize
\r
3134 * @param {CKEDITOR.dialog} dialog The dialog being resized.
\r
3135 * @param {String} skin The skin name.
\r
3136 * @param {Number} width The new width.
\r
3137 * @param {Number} height The new height.
\r