JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.6.1
[ckeditor.git] / _source / plugins / dialogui / plugin.js
index 826dc57..888c015 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2011, 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
@@ -157,7 +157,7 @@ CKEDITOR.plugins.add( 'dialogui' );
                                        if ( elementDefinition.labelLayout != 'horizontal' )\r
                                                html.push( '<label class="cke_dialog_ui_labeled_label' + requiredClass + '" ',\r
                                                                ' id="'+  _.labelId + '"',\r
-                                                               ' for="' + _.inputId + '"',\r
+                                                               ( _.inputId? ' for="' + _.inputId + '"' : '' ),\r
                                                                ( elementDefinition.labelStyle ? ' style="' + elementDefinition.labelStyle + '"' : '' ) +'>',\r
                                                                elementDefinition.label,\r
                                                                '</label>',\r
@@ -224,7 +224,7 @@ CKEDITOR.plugins.add( 'dialogui' );
 \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
@@ -240,30 +240,6 @@ CKEDITOR.plugins.add( 'dialogui' );
                                if ( elementDefinition.inputStyle )\r
                                        attributes.style = elementDefinition.inputStyle;\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
-\r
                                /** @ignore */\r
                                var innerHTML = function()\r
                                {\r
@@ -677,6 +653,7 @@ CKEDITOR.plugins.add( 'dialogui' );
                                                        ' 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
@@ -855,7 +832,9 @@ CKEDITOR.plugins.add( 'dialogui' );
                                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
@@ -969,7 +948,13 @@ CKEDITOR.plugins.add( 'dialogui' );
                                                /** @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
@@ -1197,7 +1182,7 @@ CKEDITOR.plugins.add( 'dialogui' );
                                {\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
@@ -1435,11 +1420,17 @@ CKEDITOR.plugins.add( 'dialogui' );
                                                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