JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.6.1
[ckeditor.git] / _source / plugins / forms / plugin.js
index 4668bef..cd3831c 100644 (file)
@@ -1,5 +1,5 @@
 /*\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
@@ -9,6 +9,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
 CKEDITOR.plugins.add( 'forms',\r
 {\r
+       requires : [ 'dialog' ],\r
        init : function( editor )\r
        {\r
                var lang = editor.lang;\r
@@ -149,25 +150,28 @@ CKEDITOR.plugins.add( 'forms',
 \r
                                                if ( name == 'input' )\r
                                                {\r
-                                                       var type = element.getAttribute( 'type' );\r
+                                                       switch( element.getAttribute( 'type' ) )\r
+                                                       {\r
+                                                               case 'button' :\r
+                                                               case 'submit' :\r
+                                                               case 'reset' :\r
+                                                                       return { button : CKEDITOR.TRISTATE_OFF };\r
 \r
-                                                       if ( type == 'text' || type == 'password' )\r
-                                                               return { textfield : CKEDITOR.TRISTATE_OFF };\r
+                                                               case 'checkbox' :\r
+                                                                       return { checkbox : CKEDITOR.TRISTATE_OFF };\r
 \r
-                                                       if ( type == 'button' || type == 'submit' || type == 'reset' )\r
-                                                               return { button : CKEDITOR.TRISTATE_OFF };\r
+                                                               case 'radio' :\r
+                                                                       return { radio : CKEDITOR.TRISTATE_OFF };\r
 \r
-                                                       if ( type == 'checkbox' )\r
-                                                               return { checkbox : CKEDITOR.TRISTATE_OFF };\r
+                                                               case 'image' :\r
+                                                                       return { imagebutton : CKEDITOR.TRISTATE_OFF };\r
 \r
-                                                       if ( type == 'radio' )\r
-                                                               return { radio : CKEDITOR.TRISTATE_OFF };\r
-\r
-                                                       if ( type == 'image' )\r
-                                                               return { imagebutton : CKEDITOR.TRISTATE_OFF };\r
+                                                               default :\r
+                                                                       return { textfield : CKEDITOR.TRISTATE_OFF };\r
+                                                       }\r
                                                }\r
 \r
-                                               if ( name == 'img' && element.getAttribute( '_cke_real_element_type' ) == 'hiddenfield' )\r
+                                               if ( name == 'img' && element.data( 'cke-real-element-type' ) == 'hiddenfield' )\r
                                                        return { hiddenfield : CKEDITOR.TRISTATE_OFF };\r
                                        }\r
                                });\r
@@ -183,18 +187,12 @@ CKEDITOR.plugins.add( 'forms',
                                        evt.data.dialog = 'select';\r
                                else if ( element.is( 'textarea' ) )\r
                                        evt.data.dialog = 'textarea';\r
-                               else if ( element.is( 'img' ) && element.getAttribute( '_cke_real_element_type' ) == 'hiddenfield' )\r
+                               else if ( element.is( 'img' ) && element.data( 'cke-real-element-type' ) == 'hiddenfield' )\r
                                        evt.data.dialog = 'hiddenfield';\r
                                else if ( element.is( 'input' ) )\r
                                {\r
-                                       var type = element.getAttribute( 'type' );\r
-\r
-                                       switch ( type )\r
+                                       switch ( element.getAttribute( 'type' ) )\r
                                        {\r
-                                               case 'text' :\r
-                                               case 'password' :\r
-                                                       evt.data.dialog = 'textfield';\r
-                                                       break;\r
                                                case 'button' :\r
                                                case 'submit' :\r
                                                case 'reset' :\r
@@ -209,6 +207,9 @@ CKEDITOR.plugins.add( 'forms',
                                                case 'image' :\r
                                                        evt.data.dialog = 'imagebutton';\r
                                                        break;\r
+                                               default :\r
+                                                       evt.data.dialog = 'textfield';\r
+                                                       break;\r
                                        }\r
                                }\r
                        });\r
@@ -231,6 +232,9 @@ CKEDITOR.plugins.add( 'forms',
                                        {\r
                                                var attrs = input.attributes,\r
                                                        type = attrs.type;\r
+                                               // Old IEs don't provide type for Text inputs #5522\r
+                                               if ( !type )\r
+                                                       attrs.type = 'text';\r
                                                if ( type == 'checkbox' || type == 'radio' )\r
                                                        attrs.value == 'on' && delete attrs.value;\r
                                        }\r
@@ -258,27 +262,28 @@ CKEDITOR.plugins.add( 'forms',
 \r
 if ( CKEDITOR.env.ie )\r
 {\r
-       CKEDITOR.dom.element.prototype.hasAttribute = function( name )\r
-       {\r
-               var $attr = this.$.attributes.getNamedItem( name );\r
-\r
-               if ( this.getName() == 'input' )\r
+       CKEDITOR.dom.element.prototype.hasAttribute = CKEDITOR.tools.override( CKEDITOR.dom.element.prototype.hasAttribute,\r
+               function( original )\r
                {\r
-                       switch ( name )\r
-                       {\r
-                               case 'class' :\r
-                                       return this.$.className.length > 0;\r
-                               case 'checked' :\r
-                                       return !!this.$.checked;\r
-                               case 'value' :\r
-                                       var type = this.getAttribute( 'type' );\r
-                                       if ( type == 'checkbox' || type == 'radio' )\r
-                                               return this.$.value != 'on';\r
-                                       break;\r
-                               default:\r
-                       }\r
-               }\r
+                       return function( name )\r
+                               {\r
+                                       var $attr = this.$.attributes.getNamedItem( name );\r
+\r
+                                       if ( this.getName() == 'input' )\r
+                                       {\r
+                                               switch ( name )\r
+                                               {\r
+                                                       case 'class' :\r
+                                                               return this.$.className.length > 0;\r
+                                                       case 'checked' :\r
+                                                               return !!this.$.checked;\r
+                                                       case 'value' :\r
+                                                               var type = this.getAttribute( 'type' );\r
+                                                               return type == 'checkbox' || type == 'radio' ? this.$.value != 'on' : this.$.value;\r
+                                               }\r
+                                       }\r
 \r
-               return !!( $attr && $attr.specified );\r
-       };\r
+                                       return original.apply( this, arguments );\r
+                               };\r
+               });\r
 }\r