X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fdialogui%2Fplugin.js;h=7875b5bd604662352486fda21f7f82fee6a7089d;hb=9873d66421922c7aef8be0f5d2ab51e547b19e66;hp=d8b423dcb2f96aa9d987c470d76a5d25853f57aa;hpb=ea7e3453c7b0f023b050aca6d9f83ab372860d91;p=ckeditor.git diff --git a/_source/plugins/dialogui/plugin.js b/_source/plugins/dialogui/plugin.js index d8b423d..7875b5b 100644 --- a/_source/plugins/dialogui/plugin.js +++ b/_source/plugins/dialogui/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -13,6 +13,7 @@ CKEDITOR.plugins.add( 'dialogui' ); { this._ || ( this._ = {} ); this._['default'] = this._.initValue = elementDefinition['default'] || ''; + this._.required = elementDefinition[ 'required' ] || false; var args = [ this._ ]; for ( var i = 1 ; i < arguments.length ; i++ ) args.push( arguments[i] ); @@ -34,6 +35,23 @@ CKEDITOR.plugins.add( 'dialogui' ); return new CKEDITOR.ui.dialog[elementDefinition.type]( dialog, elementDefinition, output ); } }, + containerBuilder = + { + build : function( dialog, elementDefinition, output ) + { + var children = elementDefinition.children, + child, + childHtmlList = [], + childObjList = []; + for ( var i = 0 ; ( i < children.length && ( child = children[i] ) ) ; i++ ) + { + var childHtml = []; + childHtmlList.push( childHtml ); + childObjList.push( CKEDITOR.dialog._.uiElementBuilders[ child.type ].build( dialog, child, childHtml ) ); + } + return new CKEDITOR.ui.dialog[ elementDefinition.type ]( dialog, childObjList, childHtmlList, output, elementDefinition ); + } + }, commonPrototype = { isChanged : function() @@ -41,9 +59,9 @@ CKEDITOR.plugins.add( 'dialogui' ); return this.getValue() != this.getInitValue(); }, - reset : function() + reset : function( noChangeEvent ) { - this.setValue( this.getInitValue() ); + this.setValue( this.getInitValue(), noChangeEvent ); }, setInitValue : function() @@ -69,7 +87,14 @@ CKEDITOR.plugins.add( 'dialogui' ); { dialog.on( 'load', function() { - this.getInputElement().on( 'change', function(){ this.fire( 'change', { value : this.getValue() } ); }, this ); + this.getInputElement().on( 'change', function() + { + // Make sure 'onchange' doesn't get fired after dialog closed. (#5719) + if ( !dialog.parts.dialog.isVisible() ) + return; + + this.fire( 'change', { value : this.getValue() } ); + }, this ); }, this ); this._.domOnChangeRegistered = true; } @@ -122,20 +147,22 @@ CKEDITOR.plugins.add( 'dialogui' ); return; var _ = initPrivateObject.call( this, elementDefinition ); - _.labelId = CKEDITOR.tools.getNextNumber() + '_label'; + _.labelId = CKEDITOR.tools.getNextId() + '_label'; var children = this._.children = []; /** @ignore */ var innerHTML = function() { - var html = []; + var html = [], + requiredClass = elementDefinition.required ? ' cke_required' : '' ; if ( elementDefinition.labelLayout != 'horizontal' ) - html.push( '
', + html.push( '
', - '
', - contentHtml( dialog, elementDefinition ), + '', + '' ); else { @@ -147,14 +174,17 @@ CKEDITOR.plugins.add( 'dialogui' ); [ { type : 'html', - html : '' + CKEDITOR.tools.htmlEncode( elementDefinition.label ) + + html : '' }, { type : 'html', html : '' + - contentHtml( dialog, elementDefinition ) + + contentHtml.call( this, dialog, elementDefinition ) + '' } ] @@ -163,7 +193,7 @@ CKEDITOR.plugins.add( 'dialogui' ); } return html.join( '' ); }; - CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition, htmlList, 'div', null, null, innerHTML ); + CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition, htmlList, 'div', null, { role : 'presentation' }, innerHTML ); }, /** @@ -193,7 +223,7 @@ CKEDITOR.plugins.add( 'dialogui' ); return; initPrivateObject.call( this, elementDefinition ); - var domId = this._.inputId = CKEDITOR.tools.getNextNumber() + '_textInput', + var domId = this._.inputId = CKEDITOR.tools.getNextId() + '_textInput', attributes = { 'class' : 'cke_dialog_ui_input_' + elementDefinition.type, id : domId, type : 'text' }, i; @@ -207,6 +237,9 @@ CKEDITOR.plugins.add( 'dialogui' ); if ( elementDefinition.size ) attributes.size = elementDefinition.size; + if ( elementDefinition.controlStyle ) + attributes.style = elementDefinition.controlStyle; + // If user presses Enter in a text box, it implies clicking OK for the dialog. var me = this, keyPressedOnMe = false; dialog.on( 'load', function() @@ -222,7 +255,10 @@ CKEDITOR.plugins.add( 'dialogui' ); { if ( evt.data.getKeystroke() == 13 && keyPressedOnMe ) { - dialog.getButton( 'ok' ) && dialog.getButton( 'ok' ).click(); + dialog.getButton( 'ok' ) && setTimeout( function () + { + dialog.getButton( 'ok' ).click(); + }, 0 ); keyPressedOnMe = false; } }, null, null, 1000 ); @@ -233,12 +269,15 @@ CKEDITOR.plugins.add( 'dialogui' ); { // IE BUG: Text input fields in IE at 100% would exceed a or inline // container's width, so need to wrap it inside a
. - var html = [ '' ); @@ -274,7 +313,7 @@ CKEDITOR.plugins.add( 'dialogui' ); initPrivateObject.call( this, elementDefinition ); var me = this, - domId = this._.inputId = CKEDITOR.tools.getNextNumber() + '_textarea', + domId = this._.inputId = CKEDITOR.tools.getNextId() + '_textarea', attributes = {}; if ( elementDefinition.validate ) @@ -287,7 +326,9 @@ CKEDITOR.plugins.add( 'dialogui' ); /** @ignore */ var innerHTML = function() { - var html = [ '
' ); @@ -329,15 +370,21 @@ CKEDITOR.plugins.add( 'dialogui' ); { var myDefinition = CKEDITOR.tools.extend( {}, elementDefinition, { - id : elementDefinition.id ? elementDefinition.id + '_checkbox' : CKEDITOR.tools.getNextNumber() + '_checkbox' + id : elementDefinition.id ? elementDefinition.id + '_checkbox' : CKEDITOR.tools.getNextId() + '_checkbox' }, true ), - html = [], - attributes = { 'class' : 'cke_dialog_ui_checkbox_input', type : 'checkbox' }; + html = []; + + var labelId = CKEDITOR.tools.getNextId() + '_label'; + var attributes = { 'class' : 'cke_dialog_ui_checkbox_input', type : 'checkbox', 'aria-labelledby' : labelId }; cleanInnerDefinition( myDefinition ); if ( elementDefinition[ 'default' ] ) attributes.checked = 'checked'; + + if (typeof myDefinition.controlStyle != 'undefined') + myDefinition.style = myDefinition.controlStyle; + _.checkbox = new CKEDITOR.ui.dialog.uiElement( dialog, myDefinition, html, 'input', null, attributes ); - html.push( '