/*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
* @extends CKEDITOR.ui.dialog.uiElement\r
* @param {CKEDITOR.dialog} dialog\r
* Parent dialog object.\r
- * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition\r
+ * @param {CKEDITOR.dialog.definition.uiElement} elementDefinition\r
* The element definition. Accepted fields:\r
* <ul>\r
* <li><strong>label</strong> (Required) The label string.</li>\r
if ( elementDefinition.labelLayout != 'horizontal' )\r
html.push( '<label class="cke_dialog_ui_labeled_label' + requiredClass + '" ',\r
' id="'+ _.labelId + '"',\r
- ' for="' + _.inputId + '"',\r
- ' style="' + elementDefinition.labelStyle + '">',\r
+ ( _.inputId? ' for="' + _.inputId + '"' : '' ),\r
+ ( elementDefinition.labelStyle ? ' style="' + elementDefinition.labelStyle + '"' : '' ) +'>',\r
elementDefinition.label,\r
'</label>',\r
- '<div class="cke_dialog_ui_labeled_content" role="presentation">',\r
+ '<div class="cke_dialog_ui_labeled_content"' + ( elementDefinition.controlStyle ? ' style="' + elementDefinition.controlStyle + '"' : '' ) + ' role="presentation">',\r
contentHtml.call( this, dialog, elementDefinition ),\r
'</div>' );\r
else\r
html : '<label class="cke_dialog_ui_labeled_label' + requiredClass + '"' +\r
' id="' + _.labelId + '"' +\r
' for="' + _.inputId + '"' +\r
- ' style="' + elementDefinition.labelStyle + '">' +\r
+ ( elementDefinition.labelStyle ? ' style="' + elementDefinition.labelStyle + '"' : '' ) +'>' +\r
CKEDITOR.tools.htmlEncode( elementDefinition.label ) +\r
'</span>'\r
},\r
{\r
type : 'html',\r
- html : '<span class="cke_dialog_ui_labeled_content">' +\r
+ html : '<span class="cke_dialog_ui_labeled_content"' + ( elementDefinition.controlStyle ? ' style="' + elementDefinition.controlStyle + '"' : '' ) + '>' +\r
contentHtml.call( this, dialog, elementDefinition ) +\r
'</span>'\r
}\r
* @extends CKEDITOR.ui.dialog.labeledElement\r
* @param {CKEDITOR.dialog} dialog\r
* Parent dialog object.\r
- * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition\r
+ * @param {CKEDITOR.dialog.definition.uiElement} elementDefinition\r
* The element definition. Accepted fields:\r
* <ul>\r
* <li><strong>default</strong> (Optional) The default value.</li>\r
\r
initPrivateObject.call( this, elementDefinition );\r
var domId = this._.inputId = CKEDITOR.tools.getNextId() + '_textInput',\r
- attributes = { 'class' : 'cke_dialog_ui_input_' + elementDefinition.type, id : domId, type : 'text' },\r
+ attributes = { 'class' : 'cke_dialog_ui_input_' + elementDefinition.type, id : domId, type : elementDefinition.type },\r
i;\r
\r
// Set the validator, if any.\r
if ( elementDefinition.size )\r
attributes.size = elementDefinition.size;\r
\r
- if ( elementDefinition.controlStyle )\r
- attributes.style = elementDefinition.controlStyle;\r
-\r
- // If user presses Enter in a text box, it implies clicking OK for the dialog.\r
- var me = this, keyPressedOnMe = false;\r
- dialog.on( 'load', function()\r
- {\r
- me.getInputElement().on( 'keydown', function( evt )\r
- {\r
- if ( evt.data.getKeystroke() == 13 )\r
- keyPressedOnMe = true;\r
- } );\r
-\r
- // Lower the priority this 'keyup' since 'ok' will close the dialog.(#3749)\r
- me.getInputElement().on( 'keyup', function( evt )\r
- {\r
- if ( evt.data.getKeystroke() == 13 && keyPressedOnMe )\r
- {\r
- dialog.getButton( 'ok' ) && setTimeout( function ()\r
- {\r
- dialog.getButton( 'ok' ).click();\r
- }, 0 );\r
- keyPressedOnMe = false;\r
- }\r
- }, null, null, 1000 );\r
- } );\r
+ if ( elementDefinition.inputStyle )\r
+ attributes.style = elementDefinition.inputStyle;\r
\r
/** @ignore */\r
var innerHTML = function()\r
* @example\r
* @param {CKEDITOR.dialog} dialog\r
* Parent dialog object.\r
- * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition\r
+ * @param {CKEDITOR.dialog.definition.uiElement} elementDefinition\r
* The element definition. Accepted fields:\r
* <ul>\r
* <li><strong>rows</strong> (Optional) The number of rows displayed.\r
attributes.rows = elementDefinition.rows || 5;\r
attributes.cols = elementDefinition.cols || 20;\r
\r
+ if ( typeof elementDefinition.inputStyle != 'undefined' )\r
+ attributes.style = elementDefinition.inputStyle;\r
+\r
+\r
/** @ignore */\r
var innerHTML = function()\r
{\r
* @example\r
* @param {CKEDITOR.dialog} dialog\r
* Parent dialog object.\r
- * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition\r
+ * @param {CKEDITOR.dialog.definition.uiElement} elementDefinition\r
* The element definition. Accepted fields:\r
* <ul>\r
* <li><strong>checked</strong> (Optional) Whether the checkbox is checked\r
if ( elementDefinition[ 'default' ] )\r
attributes.checked = 'checked';\r
\r
- if ( typeof myDefinition.controlStyle != 'undefined' )\r
- myDefinition.style = myDefinition.controlStyle;\r
+ if ( typeof myDefinition.inputStyle != 'undefined' )\r
+ myDefinition.style = myDefinition.inputStyle;\r
\r
_.checkbox = new CKEDITOR.ui.dialog.uiElement( dialog, myDefinition, html, 'input', null, attributes );\r
- html.push( ' <label id="', labelId, '" for="', attributes.id, '">',\r
+ html.push( ' <label id="', labelId, '" for="', attributes.id, '"' + ( elementDefinition.labelStyle ? ' style="' + elementDefinition.labelStyle + '"' : '' ) + '>',\r
CKEDITOR.tools.htmlEncode( elementDefinition.label ),\r
'</label>' );\r
return html.join( '' );\r
* @extends CKEDITOR.ui.dialog.labeledElement\r
* @param {CKEDITOR.dialog} dialog\r
* Parent dialog object.\r
- * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition\r
+ * @param {CKEDITOR.dialog.definition.uiElement} elementDefinition\r
* The element definition. Accepted fields:\r
* <ul>\r
* <li><strong>default</strong> (Required) The default value.</li>\r
cleanInnerDefinition( inputDefinition );\r
cleanInnerDefinition( labelDefinition );\r
\r
- if ( typeof inputDefinition.controlStyle != 'undefined' )\r
- inputDefinition.style = inputDefinition.controlStyle;\r
+ if ( typeof inputDefinition.inputStyle != 'undefined' )\r
+ inputDefinition.style = inputDefinition.inputStyle;\r
\r
children.push( new CKEDITOR.ui.dialog.uiElement( dialog, inputDefinition, inputHtml, 'input', null, inputAttributes ) );\r
inputHtml.push( ' ' );\r
item[0] );\r
inputHtmlList.push( inputHtml.join( '' ) );\r
}\r
- new CKEDITOR.ui.dialog.hbox( dialog, [], inputHtmlList, html );\r
+ new CKEDITOR.ui.dialog.hbox( dialog, children, inputHtmlList, html );\r
return html.join( '' );\r
};\r
\r
* @extends CKEDITOR.ui.dialog.uiElement\r
* @param {CKEDITOR.dialog} dialog\r
* Parent dialog object.\r
- * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition\r
+ * @param {CKEDITOR.dialog.definition.uiElement} elementDefinition\r
* The element definition. Accepted fields:\r
* <ul>\r
* <li><strong>label</strong> (Required) The button label.</li>\r
* @constructor\r
* @param {CKEDITOR.dialog} dialog\r
* Parent dialog object.\r
- * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition\r
+ * @param {CKEDITOR.dialog.definition.uiElement} elementDefinition\r
* The element definition. Accepted fields:\r
* <ul>\r
* <li><strong>default</strong> (Required) The default value.</li>\r
for ( var i = 0, item ; i < elementDefinition.items.length && ( item = elementDefinition.items[i] ) ; i++ )\r
{\r
innerHTML.push( '<option value="',\r
- CKEDITOR.tools.htmlEncode( item[1] !== undefined ? item[1] : item[0] ), '" /> ',\r
+ CKEDITOR.tools.htmlEncode( item[1] !== undefined ? item[1] : item[0] ).replace( /"/g, '"' ), '" /> ',\r
CKEDITOR.tools.htmlEncode( item[0] ) );\r
}\r
\r
- if ( typeof myDefinition.controlStyle != 'undefined' )\r
- myDefinition.style = myDefinition.controlStyle;\r
+ if ( typeof myDefinition.inputStyle != 'undefined' )\r
+ myDefinition.style = myDefinition.inputStyle;\r
\r
_.select = new CKEDITOR.ui.dialog.uiElement( dialog, myDefinition, html, 'select', null, attributes, innerHTML.join( '' ) );\r
return html.join( '' );\r
* @constructor\r
* @param {CKEDITOR.dialog} dialog\r
* Parent dialog object.\r
- * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition\r
+ * @param {CKEDITOR.dialog.definition.uiElement} elementDefinition\r
* The element definition. Accepted fields:\r
* <ul>\r
* <li><strong>validate</strong> (Optional) The validation function.</li>\r
' frameborder="0"' +\r
' allowtransparency="0"' +\r
' class="cke_dialog_ui_input_file"' +\r
+ ' role="presentation"' +\r
' id="', _.frameId, '"' +\r
' title="', elementDefinition.label, '"' +\r
' src="javascript:void(' ];\r
* @constructor\r
* @param {CKEDITOR.dialog} dialog\r
* Parent dialog object.\r
- * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition\r
+ * @param {CKEDITOR.dialog.definition.uiElement} elementDefinition\r
* The element definition. Accepted fields:\r
* <ul>\r
* <li><strong>for</strong> (Required) The file input's page and element Id\r
* @extends CKEDITOR.ui.dialog.uiElement\r
* @name CKEDITOR.ui.dialog.html\r
* @param {CKEDITOR.dialog} dialog Parent dialog object.\r
- * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition Element definition.\r
+ * @param {CKEDITOR.dialog.definition.uiElement} elementDefinition Element definition.\r
* Accepted fields:\r
* <ul>\r
* <li><strong>html</strong> (Required) HTML code of this element.</li>\r
* objects in childObjList.\r
* @param {Array} htmlList\r
* Array of HTML code that this element will output to.\r
- * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition\r
+ * @param {CKEDITOR.dialog.definition.uiElement} elementDefinition\r
* The element definition. Accepted fields:\r
* <ul>\r
* <li><strong>label</strong> (Optional) The legend of the this fieldset.</li>\r
var innerHTML = function()\r
{\r
var html = [];\r
- legendLabel && html.push( '<legend>' + legendLabel + '</legend>' );\r
+ legendLabel && html.push( '<legend' +\r
+ ( elementDefinition.labelStyle ? ' style="' + elementDefinition.labelStyle + '"' : '' ) +\r
+ '>' + legendLabel + '</legend>' );\r
for ( var i = 0; i < childHtmlList.length; i++ )\r
html.push( childHtmlList[ i ] );\r
return html.join( '' );\r
/** @ignore */\r
onClick : function( dialog, func )\r
{\r
- this.on( 'click', func );\r
+ this.on( 'click', function()\r
+ {\r
+ // Some browsers (Chrome, IE8, IE7 compat mode) don't move\r
+ // focus to clicked button. Force this.\r
+ this.getElement().focus();\r
+ func.apply( this, arguments );\r
+ });\r
}\r
}, true ),\r
\r
{\r
onChange : function( dialog, func )\r
{\r
- if ( !CKEDITOR.env.ie )\r
+ if ( !CKEDITOR.env.ie || ( CKEDITOR.env.version > 8 ) )\r
return commonEventProcessors.onChange.apply( this, arguments );\r
else\r
{\r
if ( elementDefinition.size )\r
size = elementDefinition.size - ( CKEDITOR.env.ie ? 7 : 0 ); // "Browse" button is bigger in IE.\r
\r
+ var inputId = _.frameId + '_input';\r
+\r
frameDocument.$.write( [ '<html dir="' + langDir + '" lang="' + langCode + '"><head><title></title></head><body style="margin: 0; overflow: hidden; background: transparent;">',\r
'<form enctype="multipart/form-data" method="POST" dir="' + langDir + '" lang="' + langCode + '" action="',\r
CKEDITOR.tools.htmlEncode( elementDefinition.action ),\r
'">',\r
- '<input type="file" name="',\r
+ // Replicate the field label inside of iframe.\r
+ '<label id="', _.labelId, '" for="', inputId, '" style="display:none">',\r
+ CKEDITOR.tools.htmlEncode( elementDefinition.label ),\r
+ '</label>',\r
+ '<input id="', inputId, '" aria-labelledby="', _.labelId,'" type="file" name="',\r
CKEDITOR.tools.htmlEncode( elementDefinition.id || 'cke_upload' ),\r
'" size="',\r
CKEDITOR.tools.htmlEncode( size > 0 ? size : "" ),\r
CKEDITOR.dialog.addUIElement( 'html', commonBuilder );\r
CKEDITOR.dialog.addUIElement( 'fieldset', containerBuilder );\r
})();\r
+\r
+/**\r
+ * Fired when the value of the uiElement is changed\r
+ * @name CKEDITOR.ui.dialog.uiElement#change\r
+ * @event\r
+ */\r
+\r
+/**\r
+ * Fired when the inner frame created by the element is ready.\r
+ * Each time the button is used or the dialog is loaded a new\r
+ * form might be created.\r
+ * @name CKEDITOR.ui.dialog.fileButton#formLoaded\r
+ * @event\r
+ */\r