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 var startStyles = {
\r
171 position : CKEDITOR.env.ie6Compat ? 'absolute' : 'fixed',
\r
173 visibility : 'hidden'
\r
176 startStyles[ dir == 'rtl' ? 'right' : 'left' ] = 0;
\r
177 this.parts.dialog.setStyles( startStyles );
\r
180 // Call the CKEDITOR.event constructor to initialize this instance.
\r
181 CKEDITOR.event.call( this );
\r
183 // Fire the "dialogDefinition" event, making it possible to customize
\r
184 // the dialog definition.
\r
185 this.definition = definition = CKEDITOR.fire( 'dialogDefinition',
\r
188 definition : definition
\r
190 , editor ).definition;
\r
192 var tabsToRemove = {};
\r
193 // Cache tabs that should be removed.
\r
194 if ( !( 'removeDialogTabs' in editor._ ) && editor.config.removeDialogTabs )
\r
196 var removeContents = editor.config.removeDialogTabs.split( ';' );
\r
198 for ( i = 0; i < removeContents.length; i++ )
\r
200 var parts = removeContents[ i ].split( ':' );
\r
201 if ( parts.length == 2 )
\r
203 var removeDialogName = parts[ 0 ];
\r
204 if ( !tabsToRemove[ removeDialogName ] )
\r
205 tabsToRemove[ removeDialogName ] = [];
\r
206 tabsToRemove[ removeDialogName ].push( parts[ 1 ] );
\r
209 editor._.removeDialogTabs = tabsToRemove;
\r
212 // Remove tabs of this dialog.
\r
213 if ( editor._.removeDialogTabs && ( tabsToRemove = editor._.removeDialogTabs[ dialogName ] ) )
\r
215 for ( i = 0; i < tabsToRemove.length; i++ )
\r
216 definition.removeContents( tabsToRemove[ i ] );
\r
219 // Initialize load, show, hide, ok and cancel events.
\r
220 if ( definition.onLoad )
\r
221 this.on( 'load', definition.onLoad );
\r
223 if ( definition.onShow )
\r
224 this.on( 'show', definition.onShow );
\r
226 if ( definition.onHide )
\r
227 this.on( 'hide', definition.onHide );
\r
229 if ( definition.onOk )
\r
231 this.on( 'ok', function( evt )
\r
233 // Dialog confirm might probably introduce content changes (#5415).
\r
234 editor.fire( 'saveSnapshot' );
\r
235 setTimeout( function () { editor.fire( 'saveSnapshot' ); }, 0 );
\r
236 if ( definition.onOk.call( this, evt ) === false )
\r
237 evt.data.hide = false;
\r
241 if ( definition.onCancel )
\r
243 this.on( 'cancel', function( evt )
\r
245 if ( definition.onCancel.call( this, evt ) === false )
\r
246 evt.data.hide = false;
\r
252 // Iterates over all items inside all content in the dialog, calling a
\r
253 // function for each of them.
\r
254 var iterContents = function( func )
\r
256 var contents = me._.contents,
\r
259 for ( var i in contents )
\r
261 for ( var j in contents[i] )
\r
263 stop = func.call( this, contents[i][j] );
\r
270 this.on( 'ok', function( evt )
\r
272 iterContents( function( item )
\r
274 if ( item.validate )
\r
276 var isValid = item.validate( this );
\r
278 if ( typeof isValid == 'string' )
\r
284 if ( isValid === false )
\r
291 evt.data.hide = false;
\r
297 }, this, null, 0 );
\r
299 this.on( 'cancel', function( evt )
\r
301 iterContents( function( item )
\r
303 if ( item.isChanged() )
\r
305 if ( !confirm( editor.lang.common.confirmCancel ) )
\r
306 evt.data.hide = false;
\r
310 }, this, null, 0 );
\r
312 this.parts.close.on( 'click', function( evt )
\r
314 if ( this.fire( 'cancel', { hide : true } ).hide !== false )
\r
316 evt.data.preventDefault();
\r
319 // Sort focus list according to tab order definitions.
\r
320 function setupFocus()
\r
322 var focusList = me._.focusList;
\r
323 focusList.sort( function( a, b )
\r
325 // Mimics browser tab order logics;
\r
326 if ( a.tabIndex != b.tabIndex )
\r
327 return b.tabIndex - a.tabIndex;
\r
328 // Sort is not stable in some browsers,
\r
329 // fall-back the comparator to 'focusIndex';
\r
331 return a.focusIndex - b.focusIndex;
\r
334 var size = focusList.length;
\r
335 for ( var i = 0; i < size; i++ )
\r
336 focusList[ i ].focusIndex = i;
\r
339 function changeFocus( forward )
\r
341 var focusList = me._.focusList,
\r
342 offset = forward ? 1 : -1;
\r
343 if ( focusList.length < 1 )
\r
346 var current = me._.currentFocusIndex;
\r
348 // Trigger the 'blur' event of any input element before anything,
\r
349 // since certain UI updates may depend on it.
\r
352 focusList[ current ].getInputElement().$.blur();
\r
356 var startIndex = ( current + offset + focusList.length ) % focusList.length,
\r
357 currentIndex = startIndex;
\r
358 while ( !focusList[ currentIndex ].isFocusable() )
\r
360 currentIndex = ( currentIndex + offset + focusList.length ) % focusList.length;
\r
361 if ( currentIndex == startIndex )
\r
364 focusList[ currentIndex ].focus();
\r
366 // Select whole field content.
\r
367 if ( focusList[ currentIndex ].type == 'text' )
\r
368 focusList[ currentIndex ].select();
\r
371 this.changeFocus = changeFocus;
\r
375 function focusKeydownHandler( evt )
\r
377 // If I'm not the top dialog, ignore.
\r
378 if ( me != CKEDITOR.dialog._.currentTop )
\r
381 var keystroke = evt.data.getKeystroke(),
\r
382 rtl = editor.lang.dir == 'rtl';
\r
385 if ( keystroke == 9 || keystroke == CKEDITOR.SHIFT + 9 )
\r
387 var shiftPressed = ( keystroke == CKEDITOR.SHIFT + 9 );
\r
389 // Handling Tab and Shift-Tab.
\r
390 if ( me._.tabBarMode )
\r
393 var nextId = shiftPressed ? getPreviousVisibleTab.call( me ) : getNextVisibleTab.call( me );
\r
394 me.selectPage( nextId );
\r
395 me._.tabs[ nextId ][ 0 ].focus();
\r
399 // Change the focus of inputs.
\r
400 changeFocus( !shiftPressed );
\r
405 else if ( keystroke == CKEDITOR.ALT + 121 && !me._.tabBarMode && me.getPageCount() > 1 )
\r
407 // Alt-F10 puts focus into the current tab item in the tab bar.
\r
408 me._.tabBarMode = true;
\r
409 me._.tabs[ me._.currentTabId ][ 0 ].focus();
\r
412 else if ( ( keystroke == 37 || keystroke == 39 ) && me._.tabBarMode )
\r
414 // Arrow keys - used for changing tabs.
\r
415 nextId = ( keystroke == ( rtl ? 39 : 37 ) ? getPreviousVisibleTab.call( me ) : getNextVisibleTab.call( me ) );
\r
416 me.selectPage( nextId );
\r
417 me._.tabs[ nextId ][ 0 ].focus();
\r
420 else if ( ( keystroke == 13 || keystroke == 32 ) && me._.tabBarMode )
\r
422 this.selectPage( this._.currentTabId );
\r
423 this._.tabBarMode = false;
\r
424 this._.currentFocusIndex = -1;
\r
425 changeFocus( true );
\r
432 evt.data.preventDefault();
\r
436 function focusKeyPressHandler( evt )
\r
438 processed && evt.data.preventDefault();
\r
441 var dialogElement = this._.element;
\r
442 // Add the dialog keyboard handlers.
\r
443 this.on( 'show', function()
\r
445 dialogElement.on( 'keydown', focusKeydownHandler, this, null, 0 );
\r
446 // Some browsers instead, don't cancel key events in the keydown, but in the
\r
447 // keypress. So we must do a longer trip in those cases. (#4531)
\r
448 if ( CKEDITOR.env.opera || ( CKEDITOR.env.gecko && CKEDITOR.env.mac ) )
\r
449 dialogElement.on( 'keypress', focusKeyPressHandler, this );
\r
452 this.on( 'hide', function()
\r
454 dialogElement.removeListener( 'keydown', focusKeydownHandler );
\r
455 if ( CKEDITOR.env.opera || ( CKEDITOR.env.gecko && CKEDITOR.env.mac ) )
\r
456 dialogElement.removeListener( 'keypress', focusKeyPressHandler );
\r
458 this.on( 'iframeAdded', function( evt )
\r
460 var doc = new CKEDITOR.dom.document( evt.data.iframe.$.contentWindow.document );
\r
461 doc.on( 'keydown', focusKeydownHandler, this, null, 0 );
\r
464 // Auto-focus logic in dialog.
\r
465 this.on( 'show', function()
\r
467 // Setup tabIndex on showing the dialog instead of on loading
\r
468 // to allow dynamic tab order happen in dialog definition.
\r
471 if ( editor.config.dialog_startupFocusTab
\r
472 && me._.pageCount > 1 )
\r
474 me._.tabBarMode = true;
\r
475 me._.tabs[ me._.currentTabId ][ 0 ].focus();
\r
477 else if ( !this._.hasFocus )
\r
479 this._.currentFocusIndex = -1;
\r
481 // Decide where to put the initial focus.
\r
482 if ( definition.onFocus )
\r
484 var initialFocus = definition.onFocus.call( this );
\r
485 // Focus the field that the user specified.
\r
486 initialFocus && initialFocus.focus();
\r
488 // Focus the first field in layout order.
\r
490 changeFocus( true );
\r
493 * IE BUG: If the initial focus went into a non-text element (e.g. button),
\r
494 * then IE would still leave the caret inside the editing area.
\r
496 if ( this._.editor.mode == 'wysiwyg' && CKEDITOR.env.ie )
\r
498 var $selection = editor.document.$.selection,
\r
499 $range = $selection.createRange();
\r
503 if ( $range.parentElement && $range.parentElement().ownerDocument == editor.document.$
\r
504 || $range.item && $range.item( 0 ).ownerDocument == editor.document.$ )
\r
506 var $myRange = document.body.createTextRange();
\r
507 $myRange.moveToElementText( this.getElement().getFirst().$ );
\r
508 $myRange.collapse( true );
\r
514 }, this, null, 0xffffffff );
\r
516 // IE6 BUG: Text fields and text areas are only half-rendered the first time the dialog appears in IE6 (#2661).
\r
517 // This is still needed after [2708] and [2709] because text fields in hidden TR tags are still broken.
\r
518 if ( CKEDITOR.env.ie6Compat )
\r
520 this.on( 'load', function( evt )
\r
522 var outer = this.getElement(),
\r
523 inner = outer.getFirst();
\r
525 inner.appendTo( outer );
\r
529 initDragAndDrop( this );
\r
530 initResizeHandles( this );
\r
532 // Insert the title.
\r
533 ( new CKEDITOR.dom.text( definition.title, CKEDITOR.document ) ).appendTo( this.parts.title );
\r
535 // Insert the tabs and contents.
\r
536 for ( var i = 0 ; i < definition.contents.length ; i++ )
\r
538 var page = definition.contents[i];
\r
539 page && this.addPage( page );
\r
542 this.parts[ 'tabs' ].on( 'click', function( evt )
\r
544 var target = evt.data.getTarget();
\r
545 // If we aren't inside a tab, bail out.
\r
546 if ( target.hasClass( 'cke_dialog_tab' ) )
\r
548 // Get the ID of the tab, without the 'cke_' prefix and the unique number suffix.
\r
549 var id = target.$.id;
\r
550 this.selectPage( id.substring( 4, id.lastIndexOf( '_' ) ) );
\r
552 if ( this._.tabBarMode )
\r
554 this._.tabBarMode = false;
\r
555 this._.currentFocusIndex = -1;
\r
556 changeFocus( true );
\r
558 evt.data.preventDefault();
\r
563 var buttonsHtml = [],
\r
564 buttons = CKEDITOR.dialog._.uiElementBuilders.hbox.build( this,
\r
567 className : 'cke_dialog_footer_buttons',
\r
569 children : definition.buttons
\r
570 }, buttonsHtml ).getChild();
\r
571 this.parts.footer.setHtml( buttonsHtml.join( '' ) );
\r
573 for ( i = 0 ; i < buttons.length ; i++ )
\r
574 this._.buttons[ buttons[i].id ] = buttons[i];
\r
577 // Focusable interface. Use it via dialog.addFocusable.
\r
578 function Focusable( dialog, element, index )
\r
580 this.element = element;
\r
581 this.focusIndex = index;
\r
582 // TODO: support tabIndex for focusables.
\r
584 this.isFocusable = function()
\r
586 return !element.getAttribute( 'disabled' ) && element.isVisible();
\r
588 this.focus = function()
\r
590 dialog._.currentFocusIndex = this.focusIndex;
\r
591 this.element.focus();
\r
594 element.on( 'keydown', function( e )
\r
596 if ( e.data.getKeystroke() in { 32:1, 13:1 } )
\r
597 this.fire( 'click' );
\r
599 element.on( 'focus', function()
\r
601 this.fire( 'mouseover' );
\r
603 element.on( 'blur', function()
\r
605 this.fire( 'mouseout' );
\r
609 CKEDITOR.dialog.prototype =
\r
611 destroy : function()
\r
614 this._.element.remove();
\r
618 * Resizes the dialog.
\r
619 * @param {Number} width The width of the dialog in pixels.
\r
620 * @param {Number} height The height of the dialog in pixels.
\r
623 * dialogObj.resize( 800, 640 );
\r
625 resize : (function()
\r
627 return function( width, height )
\r
629 if ( this._.contentSize && this._.contentSize.width == width && this._.contentSize.height == height )
\r
632 CKEDITOR.dialog.fire( 'resize',
\r
635 skin : this._.editor.skinName,
\r
638 }, this._.editor );
\r
640 this.fire( 'resize',
\r
642 skin : this._.editor.skinName,
\r
645 }, this._.editor );
\r
647 // Update dialog position when dimension get changed in RTL.
\r
648 if ( this._.editor.lang.dir == 'rtl' && this._.position )
\r
649 this._.position.x = CKEDITOR.document.getWindow().getViewPaneSize().width -
\r
650 this._.contentSize.width - parseInt( this._.element.getFirst().getStyle( 'right' ), 10 );
\r
652 this._.contentSize = { width : width, height : height };
\r
657 * Gets the current size of the dialog in pixels.
\r
658 * @returns {Object} An object with "width" and "height" properties.
\r
660 * var width = dialogObj.getSize().width;
\r
662 getSize : function()
\r
664 var element = this._.element.getFirst();
\r
665 return { width : element.$.offsetWidth || 0, height : element.$.offsetHeight || 0};
\r
669 * Moves the dialog to an (x, y) coordinate relative to the window.
\r
671 * @param {Number} x The target x-coordinate.
\r
672 * @param {Number} y The target y-coordinate.
\r
673 * @param {Boolean} save Flag indicate whether the dialog position should be remembered on next open up.
\r
675 * dialogObj.move( 10, 40 );
\r
680 return function( x, y, save )
\r
682 // The dialog may be fixed positioned or absolute positioned. Ask the
\r
683 // browser what is the current situation first.
\r
684 var element = this._.element.getFirst(),
\r
685 rtl = this._.editor.lang.dir == 'rtl';
\r
687 if ( isFixed === undefined )
\r
688 isFixed = element.getComputedStyle( 'position' ) == 'fixed';
\r
690 if ( isFixed && this._.position && this._.position.x == x && this._.position.y == y )
\r
693 // Save the current position.
\r
694 this._.position = { x : x, y : y };
\r
696 // If not fixed positioned, add scroll position to the coordinates.
\r
699 var scrollPosition = CKEDITOR.document.getWindow().getScrollPosition();
\r
700 x += scrollPosition.x;
\r
701 y += scrollPosition.y;
\r
704 // Translate coordinate for RTL.
\r
707 var dialogSize = this.getSize(),
\r
708 viewPaneSize = CKEDITOR.document.getWindow().getViewPaneSize();
\r
709 x = viewPaneSize.width - dialogSize.width - x;
\r
712 var styles = { 'top' : ( y > 0 ? y : 0 ) + 'px' };
\r
713 styles[ rtl ? 'right' : 'left' ] = ( x > 0 ? x : 0 ) + 'px';
\r
715 element.setStyles( styles );
\r
717 save && ( this._.moved = 1 );
\r
722 * Gets the dialog's position in the window.
\r
723 * @returns {Object} An object with "x" and "y" properties.
\r
725 * var dialogX = dialogObj.getPosition().x;
\r
727 getPosition : function(){ return CKEDITOR.tools.extend( {}, this._.position ); },
\r
730 * Shows the dialog box.
\r
732 * dialogObj.show();
\r
736 // Insert the dialog's element to the root document.
\r
737 var element = this._.element;
\r
738 var definition = this.definition;
\r
739 if ( !( element.getParent() && element.getParent().equals( CKEDITOR.document.getBody() ) ) )
\r
740 element.appendTo( CKEDITOR.document.getBody() );
\r
742 element.setStyle( 'display', 'block' );
\r
744 // FIREFOX BUG: Fix vanishing caret for Firefox 2 or Gecko 1.8.
\r
745 if ( CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 )
\r
747 var dialogElement = this.parts.dialog;
\r
748 dialogElement.setStyle( 'position', 'absolute' );
\r
749 setTimeout( function()
\r
751 dialogElement.setStyle( 'position', 'fixed' );
\r
756 // First, set the dialog to an appropriate size.
\r
757 this.resize( this._.contentSize && this._.contentSize.width || definition.width || definition.minWidth,
\r
758 this._.contentSize && this._.contentSize.height || definition.height || definition.minHeight );
\r
760 // Reset all inputs back to their default value.
\r
763 // Select the first tab by default.
\r
764 this.selectPage( this.definition.contents[0].id );
\r
767 if ( CKEDITOR.dialog._.currentZIndex === null )
\r
768 CKEDITOR.dialog._.currentZIndex = this._.editor.config.baseFloatZIndex;
\r
769 this._.element.getFirst().setStyle( 'z-index', CKEDITOR.dialog._.currentZIndex += 10 );
\r
771 // Maintain the dialog ordering and dialog cover.
\r
772 // Also register key handlers if first dialog.
\r
773 if ( CKEDITOR.dialog._.currentTop === null )
\r
775 CKEDITOR.dialog._.currentTop = this;
\r
776 this._.parentDialog = null;
\r
777 showCover( this._.editor );
\r
779 element.on( 'keydown', accessKeyDownHandler );
\r
780 element.on( CKEDITOR.env.opera ? 'keypress' : 'keyup', accessKeyUpHandler );
\r
782 // Prevent some keys from bubbling up. (#4269)
\r
783 for ( var event in { keyup :1, keydown :1, keypress :1 } )
\r
784 element.on( event, preventKeyBubbling );
\r
788 this._.parentDialog = CKEDITOR.dialog._.currentTop;
\r
789 var parentElement = this._.parentDialog.getElement().getFirst();
\r
790 parentElement.$.style.zIndex -= Math.floor( this._.editor.config.baseFloatZIndex / 2 );
\r
791 CKEDITOR.dialog._.currentTop = this;
\r
794 // Register the Esc hotkeys.
\r
795 registerAccessKey( this, this, '\x1b', null, function()
\r
797 this.getButton( 'cancel' ) && this.getButton( 'cancel' ).click();
\r
800 // Reset the hasFocus state.
\r
801 this._.hasFocus = false;
\r
803 CKEDITOR.tools.setTimeout( function()
\r
806 this.parts.dialog.setStyle( 'visibility', '' );
\r
808 // Execute onLoad for the first show.
\r
809 this.fireOnce( 'load', {} );
\r
810 CKEDITOR.ui.fire( 'ready', this );
\r
812 this.fire( 'show', {} );
\r
813 this._.editor.fire( 'dialogShow', this );
\r
815 // Save the initial values of the dialog.
\r
816 this.foreach( function( contentObj ) { contentObj.setInitValue && contentObj.setInitValue(); } );
\r
823 * Rearrange the dialog to its previous position or the middle of the window.
\r
826 layout : function()
\r
828 var viewSize = CKEDITOR.document.getWindow().getViewPaneSize(),
\r
829 dialogSize = this.getSize();
\r
831 this.move( this._.moved ? this._.position.x : ( viewSize.width - dialogSize.width ) / 2,
\r
832 this._.moved ? this._.position.y : ( viewSize.height - dialogSize.height ) / 2 );
\r
836 * Executes a function for each UI element.
\r
837 * @param {Function} fn Function to execute for each UI element.
\r
838 * @returns {CKEDITOR.dialog} The current dialog object.
\r
840 foreach : function( fn )
\r
842 for ( var i in this._.contents )
\r
844 for ( var j in this._.contents[i] )
\r
845 fn( this._.contents[i][j] );
\r
851 * Resets all input values in the dialog.
\r
853 * dialogObj.reset();
\r
854 * @returns {CKEDITOR.dialog} The current dialog object.
\r
856 reset : (function()
\r
858 var fn = function( widget ){ if ( widget.reset ) widget.reset( 1 ); };
\r
859 return function(){ this.foreach( fn ); return this; };
\r
862 setupContent : function()
\r
864 var args = arguments;
\r
865 this.foreach( function( widget )
\r
867 if ( widget.setup )
\r
868 widget.setup.apply( widget, args );
\r
872 commitContent : function()
\r
874 var args = arguments;
\r
875 this.foreach( function( widget )
\r
877 if ( widget.commit )
\r
878 widget.commit.apply( widget, args );
\r
883 * Hides the dialog box.
\r
885 * dialogObj.hide();
\r
889 if ( !this.parts.dialog.isVisible() )
\r
892 this.fire( 'hide', {} );
\r
893 this._.editor.fire( 'dialogHide', this );
\r
894 var element = this._.element;
\r
895 element.setStyle( 'display', 'none' );
\r
896 this.parts.dialog.setStyle( 'visibility', 'hidden' );
\r
897 // Unregister all access keys associated with this dialog.
\r
898 unregisterAccessKey( this );
\r
900 // Close any child(top) dialogs first.
\r
901 while( CKEDITOR.dialog._.currentTop != this )
\r
902 CKEDITOR.dialog._.currentTop.hide();
\r
904 // Maintain dialog ordering and remove cover if needed.
\r
905 if ( !this._.parentDialog )
\r
909 var parentElement = this._.parentDialog.getElement().getFirst();
\r
910 parentElement.setStyle( 'z-index', parseInt( parentElement.$.style.zIndex, 10 ) + Math.floor( this._.editor.config.baseFloatZIndex / 2 ) );
\r
912 CKEDITOR.dialog._.currentTop = this._.parentDialog;
\r
914 // Deduct or clear the z-index.
\r
915 if ( !this._.parentDialog )
\r
917 CKEDITOR.dialog._.currentZIndex = null;
\r
919 // Remove access key handlers.
\r
920 element.removeListener( 'keydown', accessKeyDownHandler );
\r
921 element.removeListener( CKEDITOR.env.opera ? 'keypress' : 'keyup', accessKeyUpHandler );
\r
923 // Remove bubbling-prevention handler. (#4269)
\r
924 for ( var event in { keyup :1, keydown :1, keypress :1 } )
\r
925 element.removeListener( event, preventKeyBubbling );
\r
927 var editor = this._.editor;
\r
930 if ( editor.mode == 'wysiwyg' && CKEDITOR.env.ie )
\r
932 var selection = editor.getSelection();
\r
933 selection && selection.unlock( true );
\r
937 CKEDITOR.dialog._.currentZIndex -= 10;
\r
939 delete this._.parentDialog;
\r
940 // Reset the initial values of the dialog.
\r
941 this.foreach( function( contentObj ) { contentObj.resetInitValue && contentObj.resetInitValue(); } );
\r
945 * Adds a tabbed page into the dialog.
\r
946 * @param {Object} contents Content definition.
\r
949 addPage : function( contents )
\r
952 titleHtml = contents.label ? ' title="' + CKEDITOR.tools.htmlEncode( contents.label ) + '"' : '',
\r
953 elements = contents.elements,
\r
954 vbox = CKEDITOR.dialog._.uiElementBuilders.vbox.build( this,
\r
957 className : 'cke_dialog_page_contents',
\r
958 children : contents.elements,
\r
959 expand : !!contents.expand,
\r
960 padding : contents.padding,
\r
961 style : contents.style || 'width: 100%;height:100%'
\r
964 // Create the HTML for the tab and the content block.
\r
965 var page = CKEDITOR.dom.element.createFromHtml( pageHtml.join( '' ) );
\r
966 page.setAttribute( 'role', 'tabpanel' );
\r
968 var env = CKEDITOR.env;
\r
969 var tabId = 'cke_' + contents.id + '_' + CKEDITOR.tools.getNextNumber(),
\r
970 tab = CKEDITOR.dom.element.createFromHtml( [
\r
971 '<a class="cke_dialog_tab"',
\r
972 ( this._.pageCount > 0 ? ' cke_last' : 'cke_first' ),
\r
974 ( !!contents.hidden ? ' style="display:none"' : '' ),
\r
975 ' id="', tabId, '"',
\r
976 env.gecko && env.version >= 10900 && !env.hc ? '' : ' href="javascript:void(0)"',
\r
978 ' hidefocus="true"',
\r
984 page.setAttribute( 'aria-labelledby', tabId );
\r
986 // Take records for the tabs and elements created.
\r
987 this._.tabs[ contents.id ] = [ tab, page ];
\r
988 this._.tabIdList.push( contents.id );
\r
989 !contents.hidden && this._.pageCount++;
\r
990 this._.lastTab = tab;
\r
991 this.updateStyle();
\r
993 var contentMap = this._.contents[ contents.id ] = {},
\r
995 children = vbox.getChild();
\r
997 while ( ( cursor = children.shift() ) )
\r
999 contentMap[ cursor.id ] = cursor;
\r
1000 if ( typeof( cursor.getChild ) == 'function' )
\r
1001 children.push.apply( children, cursor.getChild() );
\r
1004 // Attach the DOM nodes.
\r
1006 page.setAttribute( 'name', contents.id );
\r
1007 page.appendTo( this.parts.contents );
\r
1009 tab.unselectable();
\r
1010 this.parts.tabs.append( tab );
\r
1012 // Add access key handlers if access key is defined.
\r
1013 if ( contents.accessKey )
\r
1015 registerAccessKey( this, this, 'CTRL+' + contents.accessKey,
\r
1016 tabAccessKeyDown, tabAccessKeyUp );
\r
1017 this._.accessKeyMap[ 'CTRL+' + contents.accessKey ] = contents.id;
\r
1022 * Activates a tab page in the dialog by its id.
\r
1023 * @param {String} id The id of the dialog tab to be activated.
\r
1025 * dialogObj.selectPage( 'tab_1' );
\r
1027 selectPage : function( id )
\r
1029 if ( this._.currentTabId == id )
\r
1032 // Returning true means that the event has been canceled
\r
1033 if ( this.fire( 'selectPage', { page : id, currentPage : this._.currentTabId } ) === true )
\r
1036 // Hide the non-selected tabs and pages.
\r
1037 for ( var i in this._.tabs )
\r
1039 var tab = this._.tabs[i][0],
\r
1040 page = this._.tabs[i][1];
\r
1043 tab.removeClass( 'cke_dialog_tab_selected' );
\r
1046 page.setAttribute( 'aria-hidden', i != id );
\r
1049 var selected = this._.tabs[ id ];
\r
1050 selected[ 0 ].addClass( 'cke_dialog_tab_selected' );
\r
1052 // [IE] an invisible input[type='text'] will enlarge it's width
\r
1053 // if it's value is long when it shows, so we clear it's value
\r
1054 // before it shows and then recover it (#5649)
\r
1055 if ( CKEDITOR.env.ie6Compat || CKEDITOR.env.ie7Compat )
\r
1057 clearOrRecoverTextInputValue( selected[ 1 ] );
\r
1058 selected[ 1 ].show();
\r
1059 setTimeout( function()
\r
1061 clearOrRecoverTextInputValue( selected[ 1 ], 1 );
\r
1065 selected[ 1 ].show();
\r
1067 this._.currentTabId = id;
\r
1068 this._.currentTabIndex = CKEDITOR.tools.indexOf( this._.tabIdList, id );
\r
1071 // Dialog state-specific style updates.
\r
1072 updateStyle : function()
\r
1074 // If only a single page shown, a different style is used in the central pane.
\r
1075 this.parts.dialog[ ( this._.pageCount === 1 ? 'add' : 'remove' ) + 'Class' ]( 'cke_single_page' );
\r
1079 * Hides a page's tab away from the dialog.
\r
1080 * @param {String} id The page's Id.
\r
1082 * dialog.hidePage( 'tab_3' );
\r
1084 hidePage : function( id )
\r
1086 var tab = this._.tabs[id] && this._.tabs[id][0];
\r
1087 if ( !tab || this._.pageCount == 1 || !tab.isVisible() )
\r
1089 // Switch to other tab first when we're hiding the active tab.
\r
1090 else if ( id == this._.currentTabId )
\r
1091 this.selectPage( getPreviousVisibleTab.call( this ) );
\r
1094 this._.pageCount--;
\r
1095 this.updateStyle();
\r
1099 * Unhides a page's tab.
\r
1100 * @param {String} id The page's Id.
\r
1102 * dialog.showPage( 'tab_2' );
\r
1104 showPage : function( id )
\r
1106 var tab = this._.tabs[id] && this._.tabs[id][0];
\r
1110 this._.pageCount++;
\r
1111 this.updateStyle();
\r
1115 * Gets the root DOM element of the dialog.
\r
1116 * @returns {CKEDITOR.dom.element} The <span> element containing this dialog.
\r
1118 * var dialogElement = dialogObj.getElement().getFirst();
\r
1119 * dialogElement.setStyle( 'padding', '5px' );
\r
1121 getElement : function()
\r
1123 return this._.element;
\r
1127 * Gets the name of the dialog.
\r
1128 * @returns {String} The name of this dialog.
\r
1130 * var dialogName = dialogObj.getName();
\r
1132 getName : function()
\r
1134 return this._.name;
\r
1138 * Gets a dialog UI element object from a dialog page.
\r
1139 * @param {String} pageId id of dialog page.
\r
1140 * @param {String} elementId id of UI element.
\r
1142 * @returns {CKEDITOR.ui.dialog.uiElement} The dialog UI element.
\r
1144 getContentElement : function( pageId, elementId )
\r
1146 var page = this._.contents[ pageId ];
\r
1147 return page && page[ elementId ];
\r
1151 * Gets the value of a dialog UI element.
\r
1152 * @param {String} pageId id of dialog page.
\r
1153 * @param {String} elementId id of UI element.
\r
1155 * @returns {Object} The value of the UI element.
\r
1157 getValueOf : function( pageId, elementId )
\r
1159 return this.getContentElement( pageId, elementId ).getValue();
\r
1163 * Sets the value of a dialog UI element.
\r
1164 * @param {String} pageId id of the dialog page.
\r
1165 * @param {String} elementId id of the UI element.
\r
1166 * @param {Object} value The new value of the UI element.
\r
1169 setValueOf : function( pageId, elementId, value )
\r
1171 return this.getContentElement( pageId, elementId ).setValue( value );
\r
1175 * Gets the UI element of a button in the dialog's button row.
\r
1176 * @param {String} id The id of the button.
\r
1178 * @returns {CKEDITOR.ui.dialog.button} The button object.
\r
1180 getButton : function( id )
\r
1182 return this._.buttons[ id ];
\r
1186 * Simulates a click to a dialog button in the dialog's button row.
\r
1187 * @param {String} id The id of the button.
\r
1189 * @returns The return value of the dialog's "click" event.
\r
1191 click : function( id )
\r
1193 return this._.buttons[ id ].click();
\r
1197 * Disables a dialog button.
\r
1198 * @param {String} id The id of the button.
\r
1201 disableButton : function( id )
\r
1203 return this._.buttons[ id ].disable();
\r
1207 * Enables a dialog button.
\r
1208 * @param {String} id The id of the button.
\r
1211 enableButton : function( id )
\r
1213 return this._.buttons[ id ].enable();
\r
1217 * Gets the number of pages in the dialog.
\r
1218 * @returns {Number} Page count.
\r
1220 getPageCount : function()
\r
1222 return this._.pageCount;
\r
1226 * Gets the editor instance which opened this dialog.
\r
1227 * @returns {CKEDITOR.editor} Parent editor instances.
\r
1229 getParentEditor : function()
\r
1231 return this._.editor;
\r
1235 * Gets the element that was selected when opening the dialog, if any.
\r
1236 * @returns {CKEDITOR.dom.element} The element that was selected, or null.
\r
1238 getSelectedElement : function()
\r
1240 return this.getParentEditor().getSelection().getSelectedElement();
\r
1244 * Adds element to dialog's focusable list.
\r
1246 * @param {CKEDITOR.dom.element} element
\r
1247 * @param {Number} [index]
\r
1249 addFocusable: function( element, index ) {
\r
1250 if ( typeof index == 'undefined' )
\r
1252 index = this._.focusList.length;
\r
1253 this._.focusList.push( new Focusable( this, element, index ) );
\r
1257 this._.focusList.splice( index, 0, new Focusable( this, element, index ) );
\r
1258 for ( var i = index + 1 ; i < this._.focusList.length ; i++ )
\r
1259 this._.focusList[ i ].focusIndex++;
\r
1264 CKEDITOR.tools.extend( CKEDITOR.dialog,
\r
1266 * @lends CKEDITOR.dialog
\r
1270 * Registers a dialog.
\r
1271 * @param {String} name The dialog's name.
\r
1272 * @param {Function|String} dialogDefinition
\r
1273 * A function returning the dialog's definition, or the URL to the .js file holding the function.
\r
1274 * The function should accept an argument "editor" which is the current editor instance, and
\r
1275 * return an object conforming to {@link CKEDITOR.dialog.definition}.
\r
1276 * @see CKEDITOR.dialog.definition
\r
1278 * // Full sample plugin, which does not only register a dialog window but also adds an item to the context menu.
\r
1279 * // To open the dialog window, choose "Open dialog" in the context menu.
\r
1280 * CKEDITOR.plugins.add( 'myplugin',
\r
1282 * init: function( editor )
\r
1284 * editor.addCommand( 'mydialog',new CKEDITOR.dialogCommand( 'mydialog' ) );
\r
1286 * if ( editor.contextMenu )
\r
1288 * editor.addMenuGroup( 'mygroup', 10 );
\r
1289 * editor.addMenuItem( 'My Dialog',
\r
1291 * label : 'Open dialog',
\r
1292 * command : 'mydialog',
\r
1293 * group : 'mygroup'
\r
1295 * editor.contextMenu.addListener( function( element )
\r
1297 * return { 'My Dialog' : CKEDITOR.TRISTATE_OFF };
\r
1301 * <strong>CKEDITOR.dialog.add</strong>( 'mydialog', function( api )
\r
1303 * // CKEDITOR.dialog.definition
\r
1304 * var <strong>dialogDefinition</strong> =
\r
1306 * title : 'Sample dialog',
\r
1308 * minHeight : 130,
\r
1312 * label : 'Label',
\r
1313 * title : 'Title',
\r
1320 * html : '<p>This is some sample HTML content.</p>'
\r
1323 * type : 'textarea',
\r
1324 * id : 'textareaId',
\r
1331 * buttons : [ CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton ],
\r
1332 * onOk : function() {
\r
1333 * // "this" is now a CKEDITOR.dialog object.
\r
1334 * // Accessing dialog elements:
\r
1335 * var textareaObj = this.<strong>getContentElement</strong>( 'tab1', 'textareaId' );
\r
1336 * alert( "You have entered: " + textareaObj.getValue() );
\r
1340 * return dialogDefinition;
\r
1345 * CKEDITOR.replace( 'editor1', { extraPlugins : 'myplugin' } );
\r
1347 add : function( name, dialogDefinition )
\r
1349 // Avoid path registration from multiple instances override definition.
\r
1350 if ( !this._.dialogDefinitions[name]
\r
1351 || typeof dialogDefinition == 'function' )
\r
1352 this._.dialogDefinitions[name] = dialogDefinition;
\r
1355 exists : function( name )
\r
1357 return !!this._.dialogDefinitions[ name ];
\r
1360 getCurrent : function()
\r
1362 return CKEDITOR.dialog._.currentTop;
\r
1366 * The default OK button for dialogs. Fires the "ok" event and closes the dialog if the event succeeds.
\r
1372 okButton : (function()
\r
1374 var retval = function( editor, override )
\r
1376 override = override || {};
\r
1377 return CKEDITOR.tools.extend( {
\r
1380 label : editor.lang.common.ok,
\r
1381 'class' : 'cke_dialog_ui_button_ok',
\r
1382 onClick : function( evt )
\r
1384 var dialog = evt.data.dialog;
\r
1385 if ( dialog.fire( 'ok', { hide : true } ).hide !== false )
\r
1388 }, override, true );
\r
1390 retval.type = 'button';
\r
1391 retval.override = function( override )
\r
1393 return CKEDITOR.tools.extend( function( editor ){ return retval( editor, override ); },
\r
1394 { type : 'button' }, true );
\r
1400 * The default cancel button for dialogs. Fires the "cancel" event and closes the dialog if no UI element value changed.
\r
1406 cancelButton : (function()
\r
1408 var retval = function( editor, override )
\r
1410 override = override || {};
\r
1411 return CKEDITOR.tools.extend( {
\r
1414 label : editor.lang.common.cancel,
\r
1415 'class' : 'cke_dialog_ui_button_cancel',
\r
1416 onClick : function( evt )
\r
1418 var dialog = evt.data.dialog;
\r
1419 if ( dialog.fire( 'cancel', { hide : true } ).hide !== false )
\r
1422 }, override, true );
\r
1424 retval.type = 'button';
\r
1425 retval.override = function( override )
\r
1427 return CKEDITOR.tools.extend( function( editor ){ return retval( editor, override ); },
\r
1428 { type : 'button' }, true );
\r
1434 * Registers a dialog UI element.
\r
1435 * @param {String} typeName The name of the UI element.
\r
1436 * @param {Function} builder The function to build the UI element.
\r
1439 addUIElement : function( typeName, builder )
\r
1441 this._.uiElementBuilders[ typeName ] = builder;
\r
1445 CKEDITOR.dialog._ =
\r
1447 uiElementBuilders : {},
\r
1449 dialogDefinitions : {},
\r
1451 currentTop : null,
\r
1453 currentZIndex : null
\r
1456 // "Inherit" (copy actually) from CKEDITOR.event.
\r
1457 CKEDITOR.event.implementOn( CKEDITOR.dialog );
\r
1458 CKEDITOR.event.implementOn( CKEDITOR.dialog.prototype, true );
\r
1460 var defaultDialogDefinition =
\r
1462 resizable : CKEDITOR.DIALOG_RESIZE_BOTH,
\r
1465 buttons : [ CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton ]
\r
1468 // Tool function used to return an item from an array based on its id
\r
1470 var getById = function( array, id, recurse )
\r
1472 for ( var i = 0, item ; ( item = array[ i ] ) ; i++ )
\r
1474 if ( item.id == id )
\r
1476 if ( recurse && item[ recurse ] )
\r
1478 var retval = getById( item[ recurse ], id, recurse ) ;
\r
1486 // Tool function used to add an item into an array.
\r
1487 var addById = function( array, newItem, nextSiblingId, recurse, nullIfNotFound )
\r
1489 if ( nextSiblingId )
\r
1491 for ( var i = 0, item ; ( item = array[ i ] ) ; i++ )
\r
1493 if ( item.id == nextSiblingId )
\r
1495 array.splice( i, 0, newItem );
\r
1499 if ( recurse && item[ recurse ] )
\r
1501 var retval = addById( item[ recurse ], newItem, nextSiblingId, recurse, true );
\r
1507 if ( nullIfNotFound )
\r
1511 array.push( newItem );
\r
1515 // Tool function used to remove an item from an array based on its id.
\r
1516 var removeById = function( array, id, recurse )
\r
1518 for ( var i = 0, item ; ( item = array[ i ] ) ; i++ )
\r
1520 if ( item.id == id )
\r
1521 return array.splice( i, 1 );
\r
1522 if ( recurse && item[ recurse ] )
\r
1524 var retval = removeById( item[ recurse ], id, recurse );
\r
1533 * This class is not really part of the API. It is the "definition" property value
\r
1534 * passed to "dialogDefinition" event handlers.
\r
1536 * @name CKEDITOR.dialog.definitionObject
\r
1537 * @extends CKEDITOR.dialog.definition
\r
1539 * CKEDITOR.on( 'dialogDefinition', function( evt )
\r
1541 * var definition = evt.data.definition;
\r
1542 * var content = definition.getContents( 'page1' );
\r
1546 var definitionObject = function( dialog, dialogDefinition )
\r
1548 // TODO : Check if needed.
\r
1549 this.dialog = dialog;
\r
1551 // Transform the contents entries in contentObjects.
\r
1552 var contents = dialogDefinition.contents;
\r
1553 for ( var i = 0, content ; ( content = contents[i] ) ; i++ )
\r
1554 contents[ i ] = content && new contentObject( dialog, content );
\r
1556 CKEDITOR.tools.extend( this, dialogDefinition );
\r
1559 definitionObject.prototype =
\r
1560 /** @lends CKEDITOR.dialog.definitionObject.prototype */
\r
1563 * Gets a content definition.
\r
1564 * @param {String} id The id of the content definition.
\r
1565 * @returns {CKEDITOR.dialog.definition.content} The content definition
\r
1568 getContents : function( id )
\r
1570 return getById( this.contents, id );
\r
1574 * Gets a button definition.
\r
1575 * @param {String} id The id of the button definition.
\r
1576 * @returns {CKEDITOR.dialog.definition.button} The button definition
\r
1579 getButton : function( id )
\r
1581 return getById( this.buttons, id );
\r
1585 * Adds a content definition object under this dialog definition.
\r
1586 * @param {CKEDITOR.dialog.definition.content} contentDefinition The
\r
1587 * content definition.
\r
1588 * @param {String} [nextSiblingId] The id of an existing content
\r
1589 * definition which the new content definition will be inserted
\r
1590 * before. Omit if the new content definition is to be inserted as
\r
1592 * @returns {CKEDITOR.dialog.definition.content} The inserted content
\r
1595 addContents : function( contentDefinition, nextSiblingId )
\r
1597 return addById( this.contents, contentDefinition, nextSiblingId );
\r
1601 * Adds a button definition object under this dialog definition.
\r
1602 * @param {CKEDITOR.dialog.definition.button} buttonDefinition The
\r
1603 * button definition.
\r
1604 * @param {String} [nextSiblingId] The id of an existing button
\r
1605 * definition which the new button definition will be inserted
\r
1606 * before. Omit if the new button definition is to be inserted as
\r
1608 * @returns {CKEDITOR.dialog.definition.button} The inserted button
\r
1611 addButton : function( buttonDefinition, nextSiblingId )
\r
1613 return addById( this.buttons, buttonDefinition, nextSiblingId );
\r
1617 * Removes a content definition from this dialog definition.
\r
1618 * @param {String} id The id of the content definition to be removed.
\r
1619 * @returns {CKEDITOR.dialog.definition.content} The removed content
\r
1622 removeContents : function( id )
\r
1624 removeById( this.contents, id );
\r
1628 * Removes a button definition from the dialog definition.
\r
1629 * @param {String} id The id of the button definition to be removed.
\r
1630 * @returns {CKEDITOR.dialog.definition.button} The removed button
\r
1633 removeButton : function( id )
\r
1635 removeById( this.buttons, id );
\r
1640 * This class is not really part of the API. It is the template of the
\r
1641 * objects representing content pages inside the
\r
1642 * CKEDITOR.dialog.definitionObject.
\r
1644 * @name CKEDITOR.dialog.definition.contentObject
\r
1646 * CKEDITOR.on( 'dialogDefinition', function( evt )
\r
1648 * var definition = evt.data.definition;
\r
1649 * var content = definition.getContents( 'page1' );
\r
1650 * content.remove( 'textInput1' );
\r
1654 function contentObject( dialog, contentDefinition )
\r
1661 CKEDITOR.tools.extend( this, contentDefinition );
\r
1664 contentObject.prototype =
\r
1665 /** @lends CKEDITOR.dialog.definition.contentObject.prototype */
\r
1668 * Gets a UI element definition under the content definition.
\r
1669 * @param {String} id The id of the UI element definition.
\r
1670 * @returns {CKEDITOR.dialog.definition.uiElement}
\r
1672 get : function( id )
\r
1674 return getById( this.elements, id, 'children' );
\r
1678 * Adds a UI element definition to the content definition.
\r
1679 * @param {CKEDITOR.dialog.definition.uiElement} elementDefinition The
\r
1680 * UI elemnet definition to be added.
\r
1681 * @param {String} nextSiblingId The id of an existing UI element
\r
1682 * definition which the new UI element definition will be inserted
\r
1683 * before. Omit if the new button definition is to be inserted as
\r
1685 * @returns {CKEDITOR.dialog.definition.uiElement} The element
\r
1686 * definition inserted.
\r
1688 add : function( elementDefinition, nextSiblingId )
\r
1690 return addById( this.elements, elementDefinition, nextSiblingId, 'children' );
\r
1694 * Removes a UI element definition from the content definition.
\r
1695 * @param {String} id The id of the UI element definition to be
\r
1697 * @returns {CKEDITOR.dialog.definition.uiElement} The element
\r
1698 * definition removed.
\r
1701 remove : function( id )
\r
1703 removeById( this.elements, id, 'children' );
\r
1707 function initDragAndDrop( dialog )
\r
1709 var lastCoords = null,
\r
1710 abstractDialogCoords = null,
\r
1711 element = dialog.getElement().getFirst(),
\r
1712 editor = dialog.getParentEditor(),
\r
1713 magnetDistance = editor.config.dialog_magnetDistance,
\r
1714 margins = editor.skin.margins || [ 0, 0, 0, 0 ];
\r
1716 if ( typeof magnetDistance == 'undefined' )
\r
1717 magnetDistance = 20;
\r
1719 function mouseMoveHandler( evt )
\r
1721 var dialogSize = dialog.getSize(),
\r
1722 viewPaneSize = CKEDITOR.document.getWindow().getViewPaneSize(),
\r
1723 x = evt.data.$.screenX,
\r
1724 y = evt.data.$.screenY,
\r
1725 dx = x - lastCoords.x,
\r
1726 dy = y - lastCoords.y,
\r
1729 lastCoords = { x : x, y : y };
\r
1730 abstractDialogCoords.x += dx;
\r
1731 abstractDialogCoords.y += dy;
\r
1733 if ( abstractDialogCoords.x + margins[3] < magnetDistance )
\r
1734 realX = - margins[3];
\r
1735 else if ( abstractDialogCoords.x - margins[1] > viewPaneSize.width - dialogSize.width - magnetDistance )
\r
1736 realX = viewPaneSize.width - dialogSize.width + ( editor.lang.dir == 'rtl' ? 0 : margins[1] );
\r
1738 realX = abstractDialogCoords.x;
\r
1740 if ( abstractDialogCoords.y + margins[0] < magnetDistance )
\r
1741 realY = - margins[0];
\r
1742 else if ( abstractDialogCoords.y - margins[2] > viewPaneSize.height - dialogSize.height - magnetDistance )
\r
1743 realY = viewPaneSize.height - dialogSize.height + margins[2];
\r
1745 realY = abstractDialogCoords.y;
\r
1747 dialog.move( realX, realY, 1 );
\r
1749 evt.data.preventDefault();
\r
1752 function mouseUpHandler( evt )
\r
1754 CKEDITOR.document.removeListener( 'mousemove', mouseMoveHandler );
\r
1755 CKEDITOR.document.removeListener( 'mouseup', mouseUpHandler );
\r
1757 if ( CKEDITOR.env.ie6Compat )
\r
1759 var coverDoc = currentCover.getChild( 0 ).getFrameDocument();
\r
1760 coverDoc.removeListener( 'mousemove', mouseMoveHandler );
\r
1761 coverDoc.removeListener( 'mouseup', mouseUpHandler );
\r
1765 dialog.parts.title.on( 'mousedown', function( evt )
\r
1767 lastCoords = { x : evt.data.$.screenX, y : evt.data.$.screenY };
\r
1769 CKEDITOR.document.on( 'mousemove', mouseMoveHandler );
\r
1770 CKEDITOR.document.on( 'mouseup', mouseUpHandler );
\r
1771 abstractDialogCoords = dialog.getPosition();
\r
1773 if ( CKEDITOR.env.ie6Compat )
\r
1775 var coverDoc = currentCover.getChild( 0 ).getFrameDocument();
\r
1776 coverDoc.on( 'mousemove', mouseMoveHandler );
\r
1777 coverDoc.on( 'mouseup', mouseUpHandler );
\r
1780 evt.data.preventDefault();
\r
1784 function initResizeHandles( dialog )
\r
1786 var def = dialog.definition,
\r
1787 resizable = def.resizable;
\r
1789 if ( resizable == CKEDITOR.DIALOG_RESIZE_NONE )
\r
1792 var editor = dialog.getParentEditor();
\r
1793 var wrapperWidth, wrapperHeight,
\r
1794 viewSize, origin, startSize,
\r
1797 var mouseDownFn = CKEDITOR.tools.addFunction( function( $event )
\r
1799 startSize = dialog.getSize();
\r
1801 var content = dialog.parts.contents,
\r
1802 iframeDialog = content.$.getElementsByTagName( 'iframe' ).length;
\r
1804 // Shim to help capturing "mousemove" over iframe.
\r
1805 if ( iframeDialog )
\r
1807 dialogCover = CKEDITOR.dom.element.createFromHtml( '<div class="cke_dialog_resize_cover" style="height: 100%; position: absolute; width: 100%;"></div>' );
\r
1808 content.append( dialogCover );
\r
1811 // Calculate the offset between content and chrome size.
\r
1812 wrapperHeight = startSize.height - dialog.parts.contents.getSize( 'height', ! ( CKEDITOR.env.gecko || CKEDITOR.env.opera || CKEDITOR.env.ie && CKEDITOR.env.quirks ) );
\r
1813 wrapperWidth = startSize.width - dialog.parts.contents.getSize( 'width', 1 );
\r
1815 origin = { x : $event.screenX, y : $event.screenY };
\r
1817 viewSize = CKEDITOR.document.getWindow().getViewPaneSize();
\r
1819 CKEDITOR.document.on( 'mousemove', mouseMoveHandler );
\r
1820 CKEDITOR.document.on( 'mouseup', mouseUpHandler );
\r
1822 if ( CKEDITOR.env.ie6Compat )
\r
1824 var coverDoc = currentCover.getChild( 0 ).getFrameDocument();
\r
1825 coverDoc.on( 'mousemove', mouseMoveHandler );
\r
1826 coverDoc.on( 'mouseup', mouseUpHandler );
\r
1829 $event.preventDefault && $event.preventDefault();
\r
1832 // Prepend the grip to the dialog.
\r
1833 dialog.on( 'load', function()
\r
1835 var direction = '';
\r
1836 if ( resizable == CKEDITOR.DIALOG_RESIZE_WIDTH )
\r
1837 direction = ' cke_resizer_horizontal';
\r
1838 else if ( resizable == CKEDITOR.DIALOG_RESIZE_HEIGHT )
\r
1839 direction = ' cke_resizer_vertical';
\r
1840 var resizer = CKEDITOR.dom.element.createFromHtml( '<div' +
\r
1841 ' class="cke_resizer' + direction + ' cke_resizer_' + editor.lang.dir + '"' +
\r
1842 ' title="' + CKEDITOR.tools.htmlEncode( editor.lang.resize ) + '"' +
\r
1843 ' onmousedown="CKEDITOR.tools.callFunction(' + mouseDownFn + ', event )"></div>' );
\r
1844 dialog.parts.footer.append( resizer, 1 );
\r
1846 editor.on( 'destroy', function() { CKEDITOR.tools.removeFunction( mouseDownFn ); } );
\r
1848 function mouseMoveHandler( evt )
\r
1850 var rtl = editor.lang.dir == 'rtl',
\r
1851 dx = ( evt.data.$.screenX - origin.x ) * ( rtl ? -1 : 1 ),
\r
1852 dy = evt.data.$.screenY - origin.y,
\r
1853 width = startSize.width,
\r
1854 height = startSize.height,
\r
1855 internalWidth = width + dx * ( dialog._.moved ? 1 : 2 ),
\r
1856 internalHeight = height + dy * ( dialog._.moved ? 1 : 2 ),
\r
1857 element = dialog._.element.getFirst(),
\r
1858 right = rtl && element.getComputedStyle( 'right' ),
\r
1859 position = dialog.getPosition();
\r
1861 if ( position.y + internalHeight > viewSize.height )
\r
1862 internalHeight = viewSize.height - position.y;
\r
1864 if ( ( rtl ? right : position.x ) + internalWidth > viewSize.width )
\r
1865 internalWidth = viewSize.width - ( rtl ? right : position.x );
\r
1867 // Make sure the dialog will not be resized to the wrong side when it's in the leftmost position for RTL.
\r
1868 if ( ( resizable == CKEDITOR.DIALOG_RESIZE_WIDTH || resizable == CKEDITOR.DIALOG_RESIZE_BOTH ) )
\r
1869 width = Math.max( def.minWidth || 0, internalWidth - wrapperWidth );
\r
1871 if ( resizable == CKEDITOR.DIALOG_RESIZE_HEIGHT || resizable == CKEDITOR.DIALOG_RESIZE_BOTH )
\r
1872 height = Math.max( def.minHeight || 0, internalHeight - wrapperHeight );
\r
1874 dialog.resize( width, height );
\r
1876 if ( !dialog._.moved )
\r
1879 evt.data.preventDefault();
\r
1882 function mouseUpHandler()
\r
1884 CKEDITOR.document.removeListener( 'mouseup', mouseUpHandler );
\r
1885 CKEDITOR.document.removeListener( 'mousemove', mouseMoveHandler );
\r
1887 if ( dialogCover )
\r
1889 dialogCover.remove();
\r
1890 dialogCover = null;
\r
1893 if ( CKEDITOR.env.ie6Compat )
\r
1895 var coverDoc = currentCover.getChild( 0 ).getFrameDocument();
\r
1896 coverDoc.removeListener( 'mouseup', mouseUpHandler );
\r
1897 coverDoc.removeListener( 'mousemove', mouseMoveHandler );
\r
1903 // Caching resuable covers and allowing only one cover
\r
1908 function showCover( editor )
\r
1910 var win = CKEDITOR.document.getWindow();
\r
1911 var config = editor.config,
\r
1912 backgroundColorStyle = config.dialog_backgroundCoverColor || 'white',
\r
1913 backgroundCoverOpacity = config.dialog_backgroundCoverOpacity,
\r
1914 baseFloatZIndex = config.baseFloatZIndex,
\r
1915 coverKey = CKEDITOR.tools.genKey(
\r
1916 backgroundColorStyle,
\r
1917 backgroundCoverOpacity,
\r
1918 baseFloatZIndex ),
\r
1919 coverElement = covers[ coverKey ];
\r
1921 if ( !coverElement )
\r
1924 '<div tabIndex="-1" style="position: ', ( CKEDITOR.env.ie6Compat ? 'absolute' : 'fixed' ),
\r
1925 '; z-index: ', baseFloatZIndex,
\r
1926 '; top: 0px; left: 0px; ',
\r
1927 ( !CKEDITOR.env.ie6Compat ? 'background-color: ' + backgroundColorStyle : '' ),
\r
1928 '" class="cke_dialog_background_cover">'
\r
1931 if ( CKEDITOR.env.ie6Compat )
\r
1933 // Support for custom document.domain in IE.
\r
1934 var isCustomDomain = CKEDITOR.env.isCustomDomain(),
\r
1935 iframeHtml = '<html><body style=\\\'background-color:' + backgroundColorStyle + ';\\\'></body></html>';
\r
1939 ' hidefocus="true"' +
\r
1940 ' frameborder="0"' +
\r
1941 ' id="cke_dialog_background_iframe"' +
\r
1942 ' src="javascript:' );
\r
1944 html.push( 'void((function(){' +
\r
1945 'document.open();' +
\r
1946 ( isCustomDomain ? 'document.domain=\'' + document.domain + '\';' : '' ) +
\r
1947 'document.write( \'' + iframeHtml + '\' );' +
\r
1948 'document.close();' +
\r
1954 'position:absolute;' +
\r
1959 'progid:DXImageTransform.Microsoft.Alpha(opacity=0)">' +
\r
1963 html.push( '</div>' );
\r
1965 coverElement = CKEDITOR.dom.element.createFromHtml( html.join( '' ) );
\r
1966 coverElement.setOpacity( backgroundCoverOpacity != undefined ? backgroundCoverOpacity : 0.5 );
\r
1968 coverElement.appendTo( CKEDITOR.document.getBody() );
\r
1969 covers[ coverKey ] = coverElement;
\r
1972 coverElement. show();
\r
1974 currentCover = coverElement;
\r
1975 var resizeFunc = function()
\r
1977 var size = win.getViewPaneSize();
\r
1978 coverElement.setStyles(
\r
1980 width : size.width + 'px',
\r
1981 height : size.height + 'px'
\r
1985 var scrollFunc = function()
\r
1987 var pos = win.getScrollPosition(),
\r
1988 cursor = CKEDITOR.dialog._.currentTop;
\r
1989 coverElement.setStyles(
\r
1991 left : pos.x + 'px',
\r
1992 top : pos.y + 'px'
\r
1999 var dialogPos = cursor.getPosition();
\r
2000 cursor.move( dialogPos.x, dialogPos.y );
\r
2001 } while ( ( cursor = cursor._.parentDialog ) );
\r
2005 resizeCover = resizeFunc;
\r
2006 win.on( 'resize', resizeFunc );
\r
2008 // Using Safari/Mac, focus must be kept where it is (#7027)
\r
2009 if ( !( CKEDITOR.env.mac && CKEDITOR.env.webkit ) )
\r
2010 coverElement.focus();
\r
2012 if ( CKEDITOR.env.ie6Compat )
\r
2014 // IE BUG: win.$.onscroll assignment doesn't work.. it must be window.onscroll.
\r
2015 // So we need to invent a really funny way to make it work.
\r
2016 var myScrollHandler = function()
\r
2019 arguments.callee.prevScrollHandler.apply( this, arguments );
\r
2021 win.$.setTimeout( function()
\r
2023 myScrollHandler.prevScrollHandler = window.onscroll || function(){};
\r
2024 window.onscroll = myScrollHandler;
\r
2030 function hideCover()
\r
2032 if ( !currentCover )
\r
2035 var win = CKEDITOR.document.getWindow();
\r
2036 currentCover.hide();
\r
2037 win.removeListener( 'resize', resizeCover );
\r
2039 if ( CKEDITOR.env.ie6Compat )
\r
2041 win.$.setTimeout( function()
\r
2043 var prevScrollHandler = window.onscroll && window.onscroll.prevScrollHandler;
\r
2044 window.onscroll = prevScrollHandler || null;
\r
2047 resizeCover = null;
\r
2050 function removeCovers()
\r
2052 for ( var coverId in covers )
\r
2053 covers[ coverId ].remove();
\r
2057 var accessKeyProcessors = {};
\r
2059 var accessKeyDownHandler = function( evt )
\r
2061 var ctrl = evt.data.$.ctrlKey || evt.data.$.metaKey,
\r
2062 alt = evt.data.$.altKey,
\r
2063 shift = evt.data.$.shiftKey,
\r
2064 key = String.fromCharCode( evt.data.$.keyCode ),
\r
2065 keyProcessor = accessKeyProcessors[( ctrl ? 'CTRL+' : '' ) + ( alt ? 'ALT+' : '') + ( shift ? 'SHIFT+' : '' ) + key];
\r
2067 if ( !keyProcessor || !keyProcessor.length )
\r
2070 keyProcessor = keyProcessor[keyProcessor.length - 1];
\r
2071 keyProcessor.keydown && keyProcessor.keydown.call( keyProcessor.uiElement, keyProcessor.dialog, keyProcessor.key );
\r
2072 evt.data.preventDefault();
\r
2075 var accessKeyUpHandler = function( evt )
\r
2077 var ctrl = evt.data.$.ctrlKey || evt.data.$.metaKey,
\r
2078 alt = evt.data.$.altKey,
\r
2079 shift = evt.data.$.shiftKey,
\r
2080 key = String.fromCharCode( evt.data.$.keyCode ),
\r
2081 keyProcessor = accessKeyProcessors[( ctrl ? 'CTRL+' : '' ) + ( alt ? 'ALT+' : '') + ( shift ? 'SHIFT+' : '' ) + key];
\r
2083 if ( !keyProcessor || !keyProcessor.length )
\r
2086 keyProcessor = keyProcessor[keyProcessor.length - 1];
\r
2087 if ( keyProcessor.keyup )
\r
2089 keyProcessor.keyup.call( keyProcessor.uiElement, keyProcessor.dialog, keyProcessor.key );
\r
2090 evt.data.preventDefault();
\r
2094 var registerAccessKey = function( uiElement, dialog, key, downFunc, upFunc )
\r
2096 var procList = accessKeyProcessors[key] || ( accessKeyProcessors[key] = [] );
\r
2098 uiElement : uiElement,
\r
2101 keyup : upFunc || uiElement.accessKeyUp,
\r
2102 keydown : downFunc || uiElement.accessKeyDown
\r
2106 var unregisterAccessKey = function( obj )
\r
2108 for ( var i in accessKeyProcessors )
\r
2110 var list = accessKeyProcessors[i];
\r
2111 for ( var j = list.length - 1 ; j >= 0 ; j-- )
\r
2113 if ( list[j].dialog == obj || list[j].uiElement == obj )
\r
2114 list.splice( j, 1 );
\r
2116 if ( list.length === 0 )
\r
2117 delete accessKeyProcessors[i];
\r
2121 var tabAccessKeyUp = function( dialog, key )
\r
2123 if ( dialog._.accessKeyMap[key] )
\r
2124 dialog.selectPage( dialog._.accessKeyMap[key] );
\r
2127 var tabAccessKeyDown = function( dialog, key )
\r
2132 var preventKeyBubblingKeys = { 27 :1, 13 :1 };
\r
2133 var preventKeyBubbling = function( e )
\r
2135 if ( e.data.getKeystroke() in preventKeyBubblingKeys )
\r
2136 e.data.stopPropagation();
\r
2141 CKEDITOR.ui.dialog =
\r
2144 * The base class of all dialog UI elements.
\r
2146 * @param {CKEDITOR.dialog} dialog Parent dialog object.
\r
2147 * @param {CKEDITOR.dialog.definition.uiElement} elementDefinition Element
\r
2148 * definition. Accepted fields:
\r
2150 * <li><strong>id</strong> (Required) The id of the UI element. See {@link
\r
2151 * CKEDITOR.dialog#getContentElement}</li>
\r
2152 * <li><strong>type</strong> (Required) The type of the UI element. The
\r
2153 * value to this field specifies which UI element class will be used to
\r
2154 * generate the final widget.</li>
\r
2155 * <li><strong>title</strong> (Optional) The popup tooltip for the UI
\r
2157 * <li><strong>hidden</strong> (Optional) A flag that tells if the element
\r
2158 * should be initially visible.</li>
\r
2159 * <li><strong>className</strong> (Optional) Additional CSS class names
\r
2160 * to add to the UI element. Separated by space.</li>
\r
2161 * <li><strong>style</strong> (Optional) Additional CSS inline styles
\r
2162 * to add to the UI element. A semicolon (;) is required after the last
\r
2163 * style declaration.</li>
\r
2164 * <li><strong>accessKey</strong> (Optional) The alphanumeric access key
\r
2165 * for this element. Access keys are automatically prefixed by CTRL.</li>
\r
2166 * <li><strong>on*</strong> (Optional) Any UI element definition field that
\r
2167 * starts with <em>on</em> followed immediately by a capital letter and
\r
2168 * probably more letters is an event handler. Event handlers may be further
\r
2169 * divided into registered event handlers and DOM event handlers. Please
\r
2170 * refer to {@link CKEDITOR.ui.dialog.uiElement#registerEvents} and
\r
2171 * {@link CKEDITOR.ui.dialog.uiElement#eventProcessors} for more
\r
2172 * information.</li>
\r
2174 * @param {Array} htmlList
\r
2175 * List of HTML code to be added to the dialog's content area.
\r
2176 * @param {Function|String} nodeNameArg
\r
2177 * A function returning a string, or a simple string for the node name for
\r
2178 * the root DOM node. Default is 'div'.
\r
2179 * @param {Function|Object} stylesArg
\r
2180 * A function returning an object, or a simple object for CSS styles applied
\r
2181 * to the DOM node. Default is empty object.
\r
2182 * @param {Function|Object} attributesArg
\r
2183 * A fucntion returning an object, or a simple object for attributes applied
\r
2184 * to the DOM node. Default is empty object.
\r
2185 * @param {Function|String} contentsArg
\r
2186 * A function returning a string, or a simple string for the HTML code inside
\r
2187 * the root DOM node. Default is empty string.
\r
2190 uiElement : function( dialog, elementDefinition, htmlList, nodeNameArg, stylesArg, attributesArg, contentsArg )
\r
2192 if ( arguments.length < 4 )
\r
2195 var nodeName = ( nodeNameArg.call ? nodeNameArg( elementDefinition ) : nodeNameArg ) || 'div',
\r
2196 html = [ '<', nodeName, ' ' ],
\r
2197 styles = ( stylesArg && stylesArg.call ? stylesArg( elementDefinition ) : stylesArg ) || {},
\r
2198 attributes = ( attributesArg && attributesArg.call ? attributesArg( elementDefinition ) : attributesArg ) || {},
\r
2199 innerHTML = ( contentsArg && contentsArg.call ? contentsArg.call( this, dialog, elementDefinition ) : contentsArg ) || '',
\r
2200 domId = this.domId = attributes.id || CKEDITOR.tools.getNextId() + '_uiElement',
\r
2201 id = this.id = elementDefinition.id,
\r
2204 // Set the id, a unique id is required for getElement() to work.
\r
2205 attributes.id = domId;
\r
2207 // Set the type and definition CSS class names.
\r
2209 if ( elementDefinition.type )
\r
2210 classes[ 'cke_dialog_ui_' + elementDefinition.type ] = 1;
\r
2211 if ( elementDefinition.className )
\r
2212 classes[ elementDefinition.className ] = 1;
\r
2213 var attributeClasses = ( attributes['class'] && attributes['class'].split ) ? attributes['class'].split( ' ' ) : [];
\r
2214 for ( i = 0 ; i < attributeClasses.length ; i++ )
\r
2216 if ( attributeClasses[i] )
\r
2217 classes[ attributeClasses[i] ] = 1;
\r
2219 var finalClasses = [];
\r
2220 for ( i in classes )
\r
2221 finalClasses.push( i );
\r
2222 attributes['class'] = finalClasses.join( ' ' );
\r
2224 // Set the popup tooltop.
\r
2225 if ( elementDefinition.title )
\r
2226 attributes.title = elementDefinition.title;
\r
2228 // Write the inline CSS styles.
\r
2229 var styleStr = ( elementDefinition.style || '' ).split( ';' );
\r
2230 for ( i in styles )
\r
2231 styleStr.push( i + ':' + styles[i] );
\r
2232 if ( elementDefinition.hidden )
\r
2233 styleStr.push( 'display:none' );
\r
2234 for ( i = styleStr.length - 1 ; i >= 0 ; i-- )
\r
2236 if ( styleStr[i] === '' )
\r
2237 styleStr.splice( i, 1 );
\r
2239 if ( styleStr.length > 0 )
\r
2240 attributes.style = ( attributes.style ? ( attributes.style + '; ' ) : '' ) + styleStr.join( '; ' );
\r
2242 // Write the attributes.
\r
2243 for ( i in attributes )
\r
2244 html.push( i + '="' + CKEDITOR.tools.htmlEncode( attributes[i] ) + '" ');
\r
2246 // Write the content HTML.
\r
2247 html.push( '>', innerHTML, '</', nodeName, '>' );
\r
2249 // Add contents to the parent HTML array.
\r
2250 htmlList.push( html.join( '' ) );
\r
2252 ( this._ || ( this._ = {} ) ).dialog = dialog;
\r
2254 // Override isChanged if it is defined in element definition.
\r
2255 if ( typeof( elementDefinition.isChanged ) == 'boolean' )
\r
2256 this.isChanged = function(){ return elementDefinition.isChanged; };
\r
2257 if ( typeof( elementDefinition.isChanged ) == 'function' )
\r
2258 this.isChanged = elementDefinition.isChanged;
\r
2261 CKEDITOR.event.implementOn( this );
\r
2263 this.registerEvents( elementDefinition );
\r
2264 if ( this.accessKeyUp && this.accessKeyDown && elementDefinition.accessKey )
\r
2265 registerAccessKey( this, dialog, 'CTRL+' + elementDefinition.accessKey );
\r
2268 dialog.on( 'load', function()
\r
2270 if ( me.getInputElement() )
\r
2272 me.getInputElement().on( 'focus', function()
\r
2274 dialog._.tabBarMode = false;
\r
2275 dialog._.hasFocus = true;
\r
2276 me.fire( 'focus' );
\r
2281 // Register the object as a tab focus if it can be included.
\r
2282 if ( this.keyboardFocusable )
\r
2284 this.tabIndex = elementDefinition.tabIndex || 0;
\r
2286 this.focusIndex = dialog._.focusList.push( this ) - 1;
\r
2287 this.on( 'focus', function()
\r
2289 dialog._.currentFocusIndex = me.focusIndex;
\r
2293 // Completes this object with everything we have in the
\r
2295 CKEDITOR.tools.extend( this, elementDefinition );
\r
2299 * Horizontal layout box for dialog UI elements, auto-expends to available width of container.
\r
2301 * @extends CKEDITOR.ui.dialog.uiElement
\r
2302 * @param {CKEDITOR.dialog} dialog
\r
2303 * Parent dialog object.
\r
2304 * @param {Array} childObjList
\r
2305 * Array of {@link CKEDITOR.ui.dialog.uiElement} objects inside this
\r
2307 * @param {Array} childHtmlList
\r
2308 * Array of HTML code that correspond to the HTML output of all the
\r
2309 * objects in childObjList.
\r
2310 * @param {Array} htmlList
\r
2311 * Array of HTML code that this element will output to.
\r
2312 * @param {CKEDITOR.dialog.definition.uiElement} elementDefinition
\r
2313 * The element definition. Accepted fields:
\r
2315 * <li><strong>widths</strong> (Optional) The widths of child cells.</li>
\r
2316 * <li><strong>height</strong> (Optional) The height of the layout.</li>
\r
2317 * <li><strong>padding</strong> (Optional) The padding width inside child
\r
2319 * <li><strong>align</strong> (Optional) The alignment of the whole layout
\r
2324 hbox : function( dialog, childObjList, childHtmlList, htmlList, elementDefinition )
\r
2326 if ( arguments.length < 4 )
\r
2329 this._ || ( this._ = {} );
\r
2331 var children = this._.children = childObjList,
\r
2332 widths = elementDefinition && elementDefinition.widths || null,
\r
2333 height = elementDefinition && elementDefinition.height || null,
\r
2337 var innerHTML = function()
\r
2339 var html = [ '<tbody><tr class="cke_dialog_ui_hbox">' ];
\r
2340 for ( i = 0 ; i < childHtmlList.length ; i++ )
\r
2342 var className = 'cke_dialog_ui_hbox_child',
\r
2345 className = 'cke_dialog_ui_hbox_first';
\r
2346 if ( i == childHtmlList.length - 1 )
\r
2347 className = 'cke_dialog_ui_hbox_last';
\r
2348 html.push( '<td class="', className, '" role="presentation" ' );
\r
2352 styles.push( 'width:' + cssLength( widths[i] ) );
\r
2355 styles.push( 'width:' + Math.floor( 100 / childHtmlList.length ) + '%' );
\r
2357 styles.push( 'height:' + cssLength( height ) );
\r
2358 if ( elementDefinition && elementDefinition.padding != undefined )
\r
2359 styles.push( 'padding:' + cssLength( elementDefinition.padding ) );
\r
2360 if ( styles.length > 0 )
\r
2361 html.push( 'style="' + styles.join('; ') + '" ' );
\r
2362 html.push( '>', childHtmlList[i], '</td>' );
\r
2364 html.push( '</tr></tbody>' );
\r
2365 return html.join( '' );
\r
2368 var attribs = { role : 'presentation' };
\r
2369 elementDefinition && elementDefinition.align && ( attribs.align = elementDefinition.align );
\r
2371 CKEDITOR.ui.dialog.uiElement.call(
\r
2374 elementDefinition || { type : 'hbox' },
\r
2383 * Vertical layout box for dialog UI elements.
\r
2385 * @extends CKEDITOR.ui.dialog.hbox
\r
2386 * @param {CKEDITOR.dialog} dialog
\r
2387 * Parent dialog object.
\r
2388 * @param {Array} childObjList
\r
2389 * Array of {@link CKEDITOR.ui.dialog.uiElement} objects inside this
\r
2391 * @param {Array} childHtmlList
\r
2392 * Array of HTML code that correspond to the HTML output of all the
\r
2393 * objects in childObjList.
\r
2394 * @param {Array} htmlList
\r
2395 * Array of HTML code that this element will output to.
\r
2396 * @param {CKEDITOR.dialog.definition.uiElement} elementDefinition
\r
2397 * The element definition. Accepted fields:
\r
2399 * <li><strong>width</strong> (Optional) The width of the layout.</li>
\r
2400 * <li><strong>heights</strong> (Optional) The heights of individual cells.
\r
2402 * <li><strong>align</strong> (Optional) The alignment of the layout.</li>
\r
2403 * <li><strong>padding</strong> (Optional) The padding width inside child
\r
2405 * <li><strong>expand</strong> (Optional) Whether the layout should expand
\r
2406 * vertically to fill its container.</li>
\r
2410 vbox : function( dialog, childObjList, childHtmlList, htmlList, elementDefinition )
\r
2412 if ( arguments.length < 3 )
\r
2415 this._ || ( this._ = {} );
\r
2417 var children = this._.children = childObjList,
\r
2418 width = elementDefinition && elementDefinition.width || null,
\r
2419 heights = elementDefinition && elementDefinition.heights || null;
\r
2421 var innerHTML = function()
\r
2423 var html = [ '<table role="presentation" cellspacing="0" border="0" ' ];
\r
2424 html.push( 'style="' );
\r
2425 if ( elementDefinition && elementDefinition.expand )
\r
2426 html.push( 'height:100%;' );
\r
2427 html.push( 'width:' + cssLength( width || '100%' ), ';' );
\r
2429 html.push( 'align="', CKEDITOR.tools.htmlEncode(
\r
2430 ( elementDefinition && elementDefinition.align ) || ( dialog.getParentEditor().lang.dir == 'ltr' ? 'left' : 'right' ) ), '" ' );
\r
2432 html.push( '><tbody>' );
\r
2433 for ( var i = 0 ; i < childHtmlList.length ; i++ )
\r
2436 html.push( '<tr><td role="presentation" ' );
\r
2438 styles.push( 'width:' + cssLength( width || '100%' ) );
\r
2440 styles.push( 'height:' + cssLength( heights[i] ) );
\r
2441 else if ( elementDefinition && elementDefinition.expand )
\r
2442 styles.push( 'height:' + Math.floor( 100 / childHtmlList.length ) + '%' );
\r
2443 if ( elementDefinition && elementDefinition.padding != undefined )
\r
2444 styles.push( 'padding:' + cssLength( elementDefinition.padding ) );
\r
2445 if ( styles.length > 0 )
\r
2446 html.push( 'style="', styles.join( '; ' ), '" ' );
\r
2447 html.push( ' class="cke_dialog_ui_vbox_child">', childHtmlList[i], '</td></tr>' );
\r
2449 html.push( '</tbody></table>' );
\r
2450 return html.join( '' );
\r
2452 CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition || { type : 'vbox' }, htmlList, 'div', null, { role : 'presentation' }, innerHTML );
\r
2457 CKEDITOR.ui.dialog.uiElement.prototype =
\r
2460 * Gets the root DOM element of this dialog UI object.
\r
2461 * @returns {CKEDITOR.dom.element} Root DOM element of UI object.
\r
2463 * uiElement.getElement().hide();
\r
2465 getElement : function()
\r
2467 return CKEDITOR.document.getById( this.domId );
\r
2471 * Gets the DOM element that the user inputs values.
\r
2472 * This function is used by setValue(), getValue() and focus(). It should
\r
2473 * be overrided in child classes where the input element isn't the root
\r
2475 * @returns {CKEDITOR.dom.element} The element where the user input values.
\r
2477 * var rawValue = textInput.getInputElement().$.value;
\r
2479 getInputElement : function()
\r
2481 return this.getElement();
\r
2485 * Gets the parent dialog object containing this UI element.
\r
2486 * @returns {CKEDITOR.dialog} Parent dialog object.
\r
2488 * var dialog = uiElement.getDialog();
\r
2490 getDialog : function()
\r
2492 return this._.dialog;
\r
2496 * Sets the value of this dialog UI object.
\r
2497 * @param {Object} value The new value.
\r
2498 * @param {Boolean} noChangeEvent Internal commit, to supress 'change' event on this element.
\r
2499 * @returns {CKEDITOR.dialog.uiElement} The current UI element.
\r
2501 * uiElement.setValue( 'Dingo' );
\r
2503 setValue : function( value, noChangeEvent )
\r
2505 this.getInputElement().setValue( value );
\r
2506 !noChangeEvent && this.fire( 'change', { value : value } );
\r
2511 * Gets the current value of this dialog UI object.
\r
2512 * @returns {Object} The current value.
\r
2514 * var myValue = uiElement.getValue();
\r
2516 getValue : function()
\r
2518 return this.getInputElement().getValue();
\r
2522 * Tells whether the UI object's value has changed.
\r
2523 * @returns {Boolean} true if changed, false if not changed.
\r
2525 * if ( uiElement.isChanged() )
\r
2526 * confirm( 'Value changed! Continue?' );
\r
2528 isChanged : function()
\r
2530 // Override in input classes.
\r
2535 * Selects the parent tab of this element. Usually called by focus() or overridden focus() methods.
\r
2536 * @returns {CKEDITOR.dialog.uiElement} The current UI element.
\r
2538 * focus : function()
\r
2540 * this.selectParentTab();
\r
2541 * // do something else.
\r
2544 selectParentTab : function()
\r
2546 var element = this.getInputElement(),
\r
2549 while ( ( cursor = cursor.getParent() ) && cursor.$.className.search( 'cke_dialog_page_contents' ) == -1 )
\r
2552 // Some widgets don't have parent tabs (e.g. OK and Cancel buttons).
\r
2556 tabId = cursor.getAttribute( 'name' );
\r
2557 // Avoid duplicate select.
\r
2558 if ( this._.dialog._.currentTabId != tabId )
\r
2559 this._.dialog.selectPage( tabId );
\r
2564 * Puts the focus to the UI object. Switches tabs if the UI object isn't in the active tab page.
\r
2565 * @returns {CKEDITOR.dialog.uiElement} The current UI element.
\r
2567 * uiElement.focus();
\r
2569 focus : function()
\r
2571 this.selectParentTab().getInputElement().focus();
\r
2576 * Registers the on* event handlers defined in the element definition.
\r
2577 * The default behavior of this function is:
\r
2580 * If the on* event is defined in the class's eventProcesors list,
\r
2581 * then the registration is delegated to the corresponding function
\r
2582 * in the eventProcessors list.
\r
2585 * If the on* event is not defined in the eventProcessors list, then
\r
2586 * register the event handler under the corresponding DOM event of
\r
2587 * the UI element's input DOM element (as defined by the return value
\r
2588 * of {@link CKEDITOR.ui.dialog.uiElement#getInputElement}).
\r
2591 * This function is only called at UI element instantiation, but can
\r
2592 * be overridded in child classes if they require more flexibility.
\r
2593 * @param {CKEDITOR.dialog.definition.uiElement} definition The UI element
\r
2595 * @returns {CKEDITOR.dialog.uiElement} The current UI element.
\r
2598 registerEvents : function( definition )
\r
2600 var regex = /^on([A-Z]\w+)/,
\r
2603 var registerDomEvent = function( uiElement, dialog, eventName, func )
\r
2605 dialog.on( 'load', function()
\r
2607 uiElement.getInputElement().on( eventName, func, uiElement );
\r
2611 for ( var i in definition )
\r
2613 if ( !( match = i.match( regex ) ) )
\r
2615 if ( this.eventProcessors[i] )
\r
2616 this.eventProcessors[i].call( this, this._.dialog, definition[i] );
\r
2618 registerDomEvent( this, this._.dialog, match[1].toLowerCase(), definition[i] );
\r
2625 * The event processor list used by
\r
2626 * {@link CKEDITOR.ui.dialog.uiElement#getInputElement} at UI element
\r
2627 * instantiation. The default list defines three on* events:
\r
2629 * <li>onLoad - Called when the element's parent dialog opens for the
\r
2631 * <li>onShow - Called whenever the element's parent dialog opens.</li>
\r
2632 * <li>onHide - Called whenever the element's parent dialog closes.</li>
\r
2637 * // This connects the 'click' event in CKEDITOR.ui.dialog.button to onClick
\r
2638 * // handlers in the UI element's definitions.
\r
2639 * CKEDITOR.ui.dialog.button.eventProcessors = CKEDITOR.tools.extend( {},
\r
2640 * CKEDITOR.ui.dialog.uiElement.prototype.eventProcessors,
\r
2641 * { onClick : function( dialog, func ) { this.on( 'click', func ); } },
\r
2642 * true );
\r
2646 onLoad : function( dialog, func )
\r
2648 dialog.on( 'load', func, this );
\r
2651 onShow : function( dialog, func )
\r
2653 dialog.on( 'show', func, this );
\r
2656 onHide : function( dialog, func )
\r
2658 dialog.on( 'hide', func, this );
\r
2663 * The default handler for a UI element's access key down event, which
\r
2664 * tries to put focus to the UI element.<br />
\r
2665 * Can be overridded in child classes for more sophisticaed behavior.
\r
2666 * @param {CKEDITOR.dialog} dialog The parent dialog object.
\r
2667 * @param {String} key The key combination pressed. Since access keys
\r
2668 * are defined to always include the CTRL key, its value should always
\r
2669 * include a 'CTRL+' prefix.
\r
2672 accessKeyDown : function( dialog, key )
\r
2678 * The default handler for a UI element's access key up event, which
\r
2679 * does nothing.<br />
\r
2680 * Can be overridded in child classes for more sophisticated behavior.
\r
2681 * @param {CKEDITOR.dialog} dialog The parent dialog object.
\r
2682 * @param {String} key The key combination pressed. Since access keys
\r
2683 * are defined to always include the CTRL key, its value should always
\r
2684 * include a 'CTRL+' prefix.
\r
2687 accessKeyUp : function( dialog, key )
\r
2692 * Disables a UI element.
\r
2695 disable : function()
\r
2697 var element = this.getInputElement();
\r
2698 element.setAttribute( 'disabled', 'true' );
\r
2699 element.addClass( 'cke_disabled' );
\r
2703 * Enables a UI element.
\r
2706 enable : function()
\r
2708 var element = this.getInputElement();
\r
2709 element.removeAttribute( 'disabled' );
\r
2710 element.removeClass( 'cke_disabled' );
\r
2714 * Determines whether an UI element is enabled or not.
\r
2715 * @returns {Boolean} Whether the UI element is enabled.
\r
2718 isEnabled : function()
\r
2720 return !this.getInputElement().getAttribute( 'disabled' );
\r
2724 * Determines whether an UI element is visible or not.
\r
2725 * @returns {Boolean} Whether the UI element is visible.
\r
2728 isVisible : function()
\r
2730 return this.getInputElement().isVisible();
\r
2734 * Determines whether an UI element is focus-able or not.
\r
2735 * Focus-able is defined as being both visible and enabled.
\r
2736 * @returns {Boolean} Whether the UI element can be focused.
\r
2739 isFocusable : function()
\r
2741 if ( !this.isEnabled() || !this.isVisible() )
\r
2747 CKEDITOR.ui.dialog.hbox.prototype = CKEDITOR.tools.extend( new CKEDITOR.ui.dialog.uiElement,
\r
2749 * @lends CKEDITOR.ui.dialog.hbox.prototype
\r
2753 * Gets a child UI element inside this container.
\r
2754 * @param {Array|Number} indices An array or a single number to indicate the child's
\r
2755 * position in the container's descendant tree. Omit to get all the children in an array.
\r
2756 * @returns {Array|CKEDITOR.ui.dialog.uiElement} Array of all UI elements in the container
\r
2757 * if no argument given, or the specified UI element if indices is given.
\r
2759 * var checkbox = hbox.getChild( [0,1] );
\r
2760 * checkbox.setValue( true );
\r
2762 getChild : function( indices )
\r
2764 // If no arguments, return a clone of the children array.
\r
2765 if ( arguments.length < 1 )
\r
2766 return this._.children.concat();
\r
2768 // If indices isn't array, make it one.
\r
2769 if ( !indices.splice )
\r
2770 indices = [ indices ];
\r
2772 // Retrieve the child element according to tree position.
\r
2773 if ( indices.length < 2 )
\r
2774 return this._.children[ indices[0] ];
\r
2776 return ( this._.children[ indices[0] ] && this._.children[ indices[0] ].getChild ) ?
\r
2777 this._.children[ indices[0] ].getChild( indices.slice( 1, indices.length ) ) :
\r
2782 CKEDITOR.ui.dialog.vbox.prototype = new CKEDITOR.ui.dialog.hbox();
\r
2788 var commonBuilder = {
\r
2789 build : function( dialog, elementDefinition, output )
\r
2791 var children = elementDefinition.children,
\r
2793 childHtmlList = [],
\r
2794 childObjList = [];
\r
2795 for ( var i = 0 ; ( i < children.length && ( child = children[i] ) ) ; i++ )
\r
2797 var childHtml = [];
\r
2798 childHtmlList.push( childHtml );
\r
2799 childObjList.push( CKEDITOR.dialog._.uiElementBuilders[ child.type ].build( dialog, child, childHtml ) );
\r
2801 return new CKEDITOR.ui.dialog[elementDefinition.type]( dialog, childObjList, childHtmlList, output, elementDefinition );
\r
2805 CKEDITOR.dialog.addUIElement( 'hbox', commonBuilder );
\r
2806 CKEDITOR.dialog.addUIElement( 'vbox', commonBuilder );
\r
2810 * Generic dialog command. It opens a specific dialog when executed.
\r
2812 * @augments CKEDITOR.commandDefinition
\r
2813 * @param {string} dialogName The name of the dialog to open when executing
\r
2816 * // Register the "link" command, which opens the "link" dialog.
\r
2817 * editor.addCommand( 'link', <b>new CKEDITOR.dialogCommand( 'link' )</b> );
\r
2819 CKEDITOR.dialogCommand = function( dialogName )
\r
2821 this.dialogName = dialogName;
\r
2824 CKEDITOR.dialogCommand.prototype =
\r
2827 exec : function( editor )
\r
2829 editor.openDialog( this.dialogName );
\r
2832 // Dialog commands just open a dialog ui, thus require no undo logic,
\r
2833 // undo support should dedicate to specific dialog implementation.
\r
2836 editorFocus : CKEDITOR.env.ie || CKEDITOR.env.webkit
\r
2841 var notEmptyRegex = /^([a]|[^a])+$/,
\r
2842 integerRegex = /^\d*$/,
\r
2843 numberRegex = /^\d*(?:\.\d+)?$/;
\r
2845 CKEDITOR.VALIDATE_OR = 1;
\r
2846 CKEDITOR.VALIDATE_AND = 2;
\r
2848 CKEDITOR.dialog.validate =
\r
2850 functions : function()
\r
2855 * It's important for validate functions to be able to accept the value
\r
2856 * as argument in addition to this.getValue(), so that it is possible to
\r
2857 * combine validate functions together to make more sophisticated
\r
2860 var value = this && this.getValue ? this.getValue() : arguments[0];
\r
2862 var msg = undefined,
\r
2863 relation = CKEDITOR.VALIDATE_AND,
\r
2864 functions = [], i;
\r
2866 for ( i = 0 ; i < arguments.length ; i++ )
\r
2868 if ( typeof( arguments[i] ) == 'function' )
\r
2869 functions.push( arguments[i] );
\r
2874 if ( i < arguments.length && typeof( arguments[i] ) == 'string' )
\r
2876 msg = arguments[i];
\r
2880 if ( i < arguments.length && typeof( arguments[i]) == 'number' )
\r
2881 relation = arguments[i];
\r
2883 var passed = ( relation == CKEDITOR.VALIDATE_AND ? true : false );
\r
2884 for ( i = 0 ; i < functions.length ; i++ )
\r
2886 if ( relation == CKEDITOR.VALIDATE_AND )
\r
2887 passed = passed && functions[i]( value );
\r
2889 passed = passed || functions[i]( value );
\r
2894 if ( msg !== undefined )
\r
2896 if ( this && ( this.select || this.focus ) )
\r
2897 ( this.select || this.focus )();
\r
2905 regex : function( regex, msg )
\r
2908 * Can be greatly shortened by deriving from functions validator if code size
\r
2909 * turns out to be more important than performance.
\r
2913 var value = this && this.getValue ? this.getValue() : arguments[0];
\r
2914 if ( !regex.test( value ) )
\r
2916 if ( msg !== undefined )
\r
2918 if ( this && ( this.select || this.focus ) )
\r
2920 if ( this.select )
\r
2931 notEmpty : function( msg )
\r
2933 return this.regex( notEmptyRegex, msg );
\r
2936 integer : function( msg )
\r
2938 return this.regex( integerRegex, msg );
\r
2941 'number' : function( msg )
\r
2943 return this.regex( numberRegex, msg );
\r
2946 equals : function( value, msg )
\r
2948 return this.functions( function( val ){ return val == value; }, msg );
\r
2951 notEqual : function( value, msg )
\r
2953 return this.functions( function( val ){ return val != value; }, msg );
\r
2957 CKEDITOR.on( 'instanceDestroyed', function( evt )
\r
2959 // Remove dialog cover on last instance destroy.
\r
2960 if ( CKEDITOR.tools.isEmpty( CKEDITOR.instances ) )
\r
2962 var currentTopDialog;
\r
2963 while ( ( currentTopDialog = CKEDITOR.dialog._.currentTop ) )
\r
2964 currentTopDialog.hide();
\r
2968 var dialogs = evt.editor._.storedDialogs;
\r
2969 for ( var name in dialogs )
\r
2970 dialogs[ name ].destroy();
\r
2976 // Extend the CKEDITOR.editor class with dialog specific functions.
\r
2977 CKEDITOR.tools.extend( CKEDITOR.editor.prototype,
\r
2978 /** @lends CKEDITOR.editor.prototype */
\r
2981 * Loads and opens a registered dialog.
\r
2982 * @param {String} dialogName The registered name of the dialog.
\r
2983 * @param {Function} callback The function to be invoked after dialog instance created.
\r
2984 * @see CKEDITOR.dialog.add
\r
2986 * CKEDITOR.instances.editor1.openDialog( 'smiley' );
\r
2987 * @returns {CKEDITOR.dialog} The dialog object corresponding to the dialog displayed. null if the dialog name is not registered.
\r
2989 openDialog : function( dialogName, callback )
\r
2991 if ( this.mode == 'wysiwyg' && CKEDITOR.env.ie )
\r
2993 var selection = this.getSelection();
\r
2994 selection && selection.lock();
\r
2997 var dialogDefinitions = CKEDITOR.dialog._.dialogDefinitions[ dialogName ],
\r
2998 dialogSkin = this.skin.dialog;
\r
3000 if ( CKEDITOR.dialog._.currentTop === null )
\r
3001 showCover( this );
\r
3003 // If the dialogDefinition is already loaded, open it immediately.
\r
3004 if ( typeof dialogDefinitions == 'function' && dialogSkin._isLoaded )
\r
3006 var storedDialogs = this._.storedDialogs ||
\r
3007 ( this._.storedDialogs = {} );
\r
3009 var dialog = storedDialogs[ dialogName ] ||
\r
3010 ( storedDialogs[ dialogName ] = new CKEDITOR.dialog( this, dialogName ) );
\r
3012 callback && callback.call( dialog, dialog );
\r
3017 else if ( dialogDefinitions == 'failed' )
\r
3020 throw new Error( '[CKEDITOR.dialog.openDialog] Dialog "' + dialogName + '" failed when loading definition.' );
\r
3025 function onDialogFileLoaded( success )
\r
3027 var dialogDefinition = CKEDITOR.dialog._.dialogDefinitions[ dialogName ],
\r
3028 skin = me.skin.dialog;
\r
3030 // Check if both skin part and definition is loaded.
\r
3031 if ( !skin._isLoaded || loadDefinition && typeof success == 'undefined' )
\r
3034 // In case of plugin error, mark it as loading failed.
\r
3035 if ( typeof dialogDefinition != 'function' )
\r
3036 CKEDITOR.dialog._.dialogDefinitions[ dialogName ] = 'failed';
\r
3038 me.openDialog( dialogName, callback );
\r
3041 if ( typeof dialogDefinitions == 'string' )
\r
3043 var loadDefinition = 1;
\r
3044 CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( dialogDefinitions ), onDialogFileLoaded, null, 0, 1 );
\r
3047 CKEDITOR.skins.load( this, 'dialog', onDialogFileLoaded );
\r
3054 CKEDITOR.plugins.add( 'dialog',
\r
3056 requires : [ 'dialogui' ]
\r
3059 // Dialog related configurations.
\r
3062 * The color of the dialog background cover. It should be a valid CSS color
\r
3064 * @name CKEDITOR.config.dialog_backgroundCoverColor
\r
3066 * @default 'white'
\r
3068 * config.dialog_backgroundCoverColor = 'rgb(255, 254, 253)';
\r
3072 * The opacity of the dialog background cover. It should be a number within the
\r
3073 * range [0.0, 1.0].
\r
3074 * @name CKEDITOR.config.dialog_backgroundCoverOpacity
\r
3078 * config.dialog_backgroundCoverOpacity = 0.7;
\r
3082 * If the dialog has more than one tab, put focus into the first tab as soon as dialog is opened.
\r
3083 * @name CKEDITOR.config.dialog_startupFocusTab
\r
3087 * config.dialog_startupFocusTab = true;
\r
3091 * The distance of magnetic borders used in moving and resizing dialogs,
\r
3092 * measured in pixels.
\r
3093 * @name CKEDITOR.config.dialog_magnetDistance
\r
3097 * config.dialog_magnetDistance = 30;
\r
3101 * The guideline to follow when generating the dialog buttons. There are 3 possible options:
\r
3103 * <li>'OS' - the buttons will be displayed in the default order of the user's OS;</li>
\r
3104 * <li>'ltr' - for Left-To-Right order;</li>
\r
3105 * <li>'rtl' - for Right-To-Left order.</li>
\r
3107 * @name CKEDITOR.config.dialog_buttonsOrder
\r
3112 * config.dialog_buttonsOrder = 'rtl';
\r
3116 * The dialog contents to removed. It's a string composed by dialog name and tab name with a colon between them.
\r
3117 * Separate each pair with semicolon (see example).
\r
3118 * <b>Note: All names are case-sensitive.</b>
\r
3119 * <b>Note: Be cautious when specifying dialog tabs that are mandatory, like "info", dialog functionality might be broken because of this!</b>
\r
3120 * @name CKEDITOR.config.removeDialogTabs
\r
3125 * config.removeDialogTabs = 'flash:advanced;image:Link';
\r
3129 * Fired when a dialog definition is about to be used to create a dialog into
\r
3130 * an editor instance. This event makes it possible to customize the definition
\r
3131 * before creating it.
\r
3132 * <p>Note that this event is called only the first time a specific dialog is
\r
3133 * opened. Successive openings will use the cached dialog, and this event will
\r
3134 * not get fired.</p>
\r
3135 * @name CKEDITOR#dialogDefinition
\r
3137 * @param {CKEDITOR.dialog.definition} data The dialog defination that
\r
3138 * is being loaded.
\r
3139 * @param {CKEDITOR.editor} editor The editor instance that will use the
\r
3144 * Fired when a tab is going to be selected in a dialog
\r
3145 * @name CKEDITOR.dialog#selectPage
\r
3147 * @param {String} page The id of the page that it's gonna be selected.
\r
3148 * @param {String} currentPage The id of the current page.
\r
3152 * Fired when the user tries to dismiss a dialog
\r
3153 * @name CKEDITOR.dialog#cancel
\r
3155 * @param {Boolean} hide Whether the event should proceed or not.
\r
3159 * Fired when the user tries to confirm a dialog
\r
3160 * @name CKEDITOR.dialog#ok
\r
3162 * @param {Boolean} hide Whether the event should proceed or not.
\r
3166 * Fired when a dialog is shown
\r
3167 * @name CKEDITOR.dialog#show
\r
3172 * Fired when a dialog is shown
\r
3173 * @name CKEDITOR.editor#dialogShow
\r
3178 * Fired when a dialog is hidden
\r
3179 * @name CKEDITOR.dialog#hide
\r
3184 * Fired when a dialog is hidden
\r
3185 * @name CKEDITOR.editor#dialogHide
\r
3190 * Fired when a dialog is being resized. The event is fired on
\r
3191 * both the 'CKEDITOR.dialog' object and the dialog instance
\r
3192 * since 3.5.3, previously it's available only in the global object.
\r
3193 * @name CKEDITOR.dialog#resize
\r
3196 * @param {CKEDITOR.dialog} dialog The dialog being resized (if
\r
3197 * it's fired on the dialog itself, this parameter isn't sent).
\r
3198 * @param {String} skin The skin name.
\r
3199 * @param {Number} width The new width.
\r
3200 * @param {Number} height The new height.
\r