CKEDITOR.dialog
This is the base class for runtime dialog objects. An instance of this class represents a single named dialog for a single editor instance.
var dialogObj = new CKEDITOR.dialog( editor, 'smiley' );
Filtering
Properties
Static properties
-
Indicates that the dialog is introducing new changes to the editor, for example inserting a newly created element as a part of a feature used with this dialog.
Defaults to
0 -
Indicates that the dialog is modifying the existing editor state, for example updating an existing element as a part of a feature used with this dialog.
Defaults to
1
Methods
constructor( editor, dialogName ) → dialogCKEDITOR.dialog#constructorCreates a dialog class instance.
Parameters
editor : ObjectThe editor which created the dialog.
dialogName : StringThe dialog's registered name.
Returns
dialog
addFocusable( element, [ index ] )CKEDITOR.dialog#addFocusableaddPage( contents )CKEDITOR.dialog#addPageclick( id ) → ObjectCKEDITOR.dialog#clickSimulates a click to a dialog button in the dialog's button row.
Parameters
id : StringThe id of the button.
Returns
ObjectThe return value of the dialog's
clickevent.
commitContent()CKEDITOR.dialog#commitContentCalls the CKEDITOR.dialog.definition.uiElement.commit method of each of the UI elements, with the arguments passed through it. It is usually being called when the user confirms the dialog, to process the values.
dialogObj.commitContent(); var timestamp = ( new Date() ).valueOf(); dialogObj.commitContent( timestamp );disableButton( id )CKEDITOR.dialog#disableButtonenableButton( id )CKEDITOR.dialog#enableButton-
Executes a function for each UI element.
Parameters
fn : FunctionFunction to execute for each UI element.
Returns
dialogThe current dialog object.
getButton( id ) → buttonCKEDITOR.dialog#getButtonGets the UI element of a button in the dialog's button row.
Parameters
id : StringThe id of the button.
Returns
buttonThe button object.
getContentElement( pageId, elementId ) → uiElementCKEDITOR.dialog#getContentElementGets a dialog UI element object from a dialog page.
dialogObj.getContentElement( 'tabId', 'elementId' ).setValue( 'Example' );Parameters
pageId : Stringid of dialog page.
elementId : Stringid of UI element.
Returns
uiElementThe dialog UI element.
getElement() → elementCKEDITOR.dialog#getElementGets the root DOM element of the dialog.
var dialogElement = dialogObj.getElement().getFirst(); dialogElement.setStyle( 'padding', '5px' );Returns
elementThe
<span>element containing this dialog.
-
Returns the current dialog mode based on the state of the feature used with this dialog.
In case if the dialog definition did not define the CKEDITOR.dialog.definition.getMode function, it will use the getModel method to recognize the editor mode:
The editing mode is used when the method returns:
- A CKEDITOR.dom.element attached to the DOM.
- A CKEDITOR.plugins.widget instance.
Otherwise the creation mode is used.
Parameters
editor : editor
Returns
NumberDialog mode.
getModel( editor ) → element | widget | Object | nullCKEDITOR.dialog#getModelReturns the subject of the dialog.
For most plugins, like the
tableorlinkplugin, it should return a DOM element instance if there is an element related to the dialog. For widget plugins (image2,placeholder) it should return a CKEDITOR.plugins.widget instance that is the subject of this dialog.Parameters
editor : editor
Returns
element | widget | Object | nullReturns
nullif the dialog does not use the model.
getName() → StringCKEDITOR.dialog#getNameGets the name of the dialog.
var dialogName = dialogObj.getName();Returns
StringThe name of this dialog.
getPageCount() → NumberCKEDITOR.dialog#getPageCountgetParentEditor() → editorCKEDITOR.dialog#getParentEditorgetPosition() → ObjectCKEDITOR.dialog#getPositionGets the dialog's position in the window.
var dialogX = dialogObj.getPosition().x;Returns
Object- Properties
x : Numbery : Number
getSelectedElement() → elementCKEDITOR.dialog#getSelectedElementGets the element that was selected when opening the dialog, if any.
Returns
elementThe element that was selected, or
null.
getSize() → ObjectCKEDITOR.dialog#getSizeGets the current size of the dialog in pixels.
var width = dialogObj.getSize().width;
Returns
Object- Properties
width : Numberheight : Number
getValueOf( pageId, elementId ) → ObjectCKEDITOR.dialog#getValueOfGets the value of a dialog UI element.
alert( dialogObj.getValueOf( 'tabId', 'elementId' ) );Parameters
pageId : Stringid of dialog page.
elementId : Stringid of UI element.
Returns
ObjectThe value of the UI element.
hide()CKEDITOR.dialog#hidehidePage( id )CKEDITOR.dialog#hidePageHides a page's tab away from the dialog.
dialog.hidePage( 'tab_3' );Parameters
id : StringThe page's Id.
-
Rearrange the dialog to its previous position or the middle of the window.
move( x, y, save )CKEDITOR.dialog#moveMoves the dialog to an
(x, y)coordinate relative to the window.dialogObj.move( 10, 40 );
Parameters
x : NumberThe target x-coordinate.
y : NumberThe target y-coordinate.
save : BooleanFlag indicate whether the dialog position should be remembered on next open up.
-
resize( width, height )CKEDITOR.dialog#resizeResizes the dialog.
dialogObj.resize( 800, 640 );Parameters
width : NumberThe width of the dialog in pixels.
height : NumberThe height of the dialog in pixels.
selectPage( id )CKEDITOR.dialog#selectPageActivates a tab page in the dialog by its id.
dialogObj.selectPage( 'tab_1' );Parameters
id : StringThe id of the dialog tab to be activated.
-
Sets the dialog state.
Parameters
state : NumberEither CKEDITOR.DIALOG_STATE_IDLE or CKEDITOR.DIALOG_STATE_BUSY.
setValueOf( pageId, elementId, value )CKEDITOR.dialog#setValueOfSets the value of a dialog UI element.
dialogObj.setValueOf( 'tabId', 'elementId', 'Example' );Parameters
pageId : Stringid of the dialog page.
elementId : Stringid of the UI element.
value : ObjectThe new value of the UI element.
setupContent()CKEDITOR.dialog#setupContentCalls the CKEDITOR.dialog.definition.uiElement.setup method of each of the UI elements, with the arguments passed through it. It is usually being called when the dialog is opened, to put the initial value inside the field.
dialogObj.setupContent(); var timestamp = ( new Date() ).valueOf(); dialogObj.setupContent( timestamp );show()CKEDITOR.dialog#showshowPage( id )CKEDITOR.dialog#showPageupdateStyle()CKEDITOR.dialog#updateStyleDialog state-specific style updates.
-
Sets the given model as the subject of the dialog.
For most plugins, like the
tableorlinkplugin, the given model should be a DOM element instance if there is an element related to the dialog. For widget plugins (image2,placeholder) you should provide a CKEDITOR.plugins.widget instance that is the subject of this dialog.Parameters
newModel : element | widget | Object | nullThe model to be set.
Static methods
-
Registers a dialog.
// Full sample plugin, which does not only register a dialog window but also adds an item to the context menu. // To open the dialog window, choose "Open dialog" in the context menu. CKEDITOR.plugins.add( 'myplugin', { init: function( editor ) { editor.addCommand( 'mydialog',new CKEDITOR.dialogCommand( 'mydialog' ) ); if ( editor.contextMenu ) { editor.addMenuGroup( 'mygroup', 10 ); editor.addMenuItem( 'My Dialog', { label: 'Open dialog', command: 'mydialog', group: 'mygroup' } ); editor.contextMenu.addListener( function( element ) { return { 'My Dialog': CKEDITOR.TRISTATE_OFF }; } ); } CKEDITOR.dialog.add( 'mydialog', function( api ) { // CKEDITOR.dialog.definition var dialogDefinition = { title: 'Sample dialog', minWidth: 390, minHeight: 130, contents: [ { id: 'tab1', label: 'Label', title: 'Title', expand: true, padding: 0, elements: [ { type: 'html', html: '<p>This is some sample HTML content.</p>' }, { type: 'textarea', id: 'textareaId', rows: 4, cols: 40 } ] } ], buttons: [ CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton ], onOk: function() { // "this" is now a CKEDITOR.dialog object. // Accessing dialog elements: var textareaObj = this.getContentElement( 'tab1', 'textareaId' ); alert( "You have entered: " + textareaObj.getValue() ); } }; return dialogDefinition; } ); } } ); CKEDITOR.replace( 'editor1', { extraPlugins: 'myplugin' } );Parameters
name : StringThe dialog's name.
dialogDefinition : Function | StringA function returning the dialog's definition, or the URL to the
.jsfile holding the function. The function should accept an argumenteditorwhich is the current editor instance, and return an object conforming to CKEDITOR.dialog.definition. CKEDITOR.dialog.definition
static
addIframe( name, title, src, minWidth, minHeight, [ onContentLoad ], [ userDefinition ] )CKEDITOR.dialog#addIframeAn iframe base dialog.
Parameters
name : StringName of the dialog.
title : StringTitle of the dialog.
src : StringURL address of the dialog.
minWidth : NumberMinimum width of the dialog.
minHeight : NumberMinimum height of the dialog.
[ onContentLoad ] : FunctionFunction called when the iframe has been loaded. If it isn't specified, the inner frame is notified of the dialog events (
'load','resize','ok'and'cancel') on a function called'onDialogEvent'.[ userDefinition ] : ObjectAdditional properties for the dialog definition.
-
Registers a dialog UI element.
Parameters
typeName : StringThe name of the UI element.
builder : FunctionThe function to build the UI element.
-
The default cancel button for dialogs. Fires the
cancelevent and closes the dialog if no UI element value changed. -
-
Check whether tab wasn't removed by CKEDITOR.config.removeDialogTabs.
Parameters
editor : editordialogName : StringtabName : String
Returns
Boolean
-
The default OK button for dialogs. Fires the
okevent and closes the dialog if the event succeeds.
Events
cancel( evt )CKEDITOR.dialog#cancelhide( evt )CKEDITOR.dialog#hideok( evt )CKEDITOR.dialog#ok-
Event fired when a dialog is being resized. The event is fired on both the CKEDITOR.dialog object and the dialog instance since 3.5.3, previously it was only available in the global object.
Parameters
evt : eventInfo
-
Event fired when a dialog is being resized. The event is fired on both the CKEDITOR.dialog object and the dialog instance since 3.5.3, previously it was only available in the global object.
Parameters
evt : eventInfo
selectPage( evt )CKEDITOR.dialog#selectPageshow( evt )CKEDITOR.dialog#show-