X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fforms%2Fplugin.js;h=cd3831ca657da2d2c8b5c60ce3616e6f5442977d;hb=a272c66d841421f8bf933c16535bdcde1c4649fc;hp=4668bef9c2e8e6f693465bffbfee2ad64cdc6133;hpb=039a051ccf3901311661022a30afd60fc38130c9;p=ckeditor.git diff --git a/_source/plugins/forms/plugin.js b/_source/plugins/forms/plugin.js index 4668bef..cd3831c 100644 --- a/_source/plugins/forms/plugin.js +++ b/_source/plugins/forms/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -9,6 +9,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license CKEDITOR.plugins.add( 'forms', { + requires : [ 'dialog' ], init : function( editor ) { var lang = editor.lang; @@ -149,25 +150,28 @@ CKEDITOR.plugins.add( 'forms', if ( name == 'input' ) { - var type = element.getAttribute( 'type' ); + switch( element.getAttribute( 'type' ) ) + { + case 'button' : + case 'submit' : + case 'reset' : + return { button : CKEDITOR.TRISTATE_OFF }; - if ( type == 'text' || type == 'password' ) - return { textfield : CKEDITOR.TRISTATE_OFF }; + case 'checkbox' : + return { checkbox : CKEDITOR.TRISTATE_OFF }; - if ( type == 'button' || type == 'submit' || type == 'reset' ) - return { button : CKEDITOR.TRISTATE_OFF }; + case 'radio' : + return { radio : CKEDITOR.TRISTATE_OFF }; - if ( type == 'checkbox' ) - return { checkbox : CKEDITOR.TRISTATE_OFF }; + case 'image' : + return { imagebutton : CKEDITOR.TRISTATE_OFF }; - if ( type == 'radio' ) - return { radio : CKEDITOR.TRISTATE_OFF }; - - if ( type == 'image' ) - return { imagebutton : CKEDITOR.TRISTATE_OFF }; + default : + return { textfield : CKEDITOR.TRISTATE_OFF }; + } } - if ( name == 'img' && element.getAttribute( '_cke_real_element_type' ) == 'hiddenfield' ) + if ( name == 'img' && element.data( 'cke-real-element-type' ) == 'hiddenfield' ) return { hiddenfield : CKEDITOR.TRISTATE_OFF }; } }); @@ -183,18 +187,12 @@ CKEDITOR.plugins.add( 'forms', evt.data.dialog = 'select'; else if ( element.is( 'textarea' ) ) evt.data.dialog = 'textarea'; - else if ( element.is( 'img' ) && element.getAttribute( '_cke_real_element_type' ) == 'hiddenfield' ) + else if ( element.is( 'img' ) && element.data( 'cke-real-element-type' ) == 'hiddenfield' ) evt.data.dialog = 'hiddenfield'; else if ( element.is( 'input' ) ) { - var type = element.getAttribute( 'type' ); - - switch ( type ) + switch ( element.getAttribute( 'type' ) ) { - case 'text' : - case 'password' : - evt.data.dialog = 'textfield'; - break; case 'button' : case 'submit' : case 'reset' : @@ -209,6 +207,9 @@ CKEDITOR.plugins.add( 'forms', case 'image' : evt.data.dialog = 'imagebutton'; break; + default : + evt.data.dialog = 'textfield'; + break; } } }); @@ -231,6 +232,9 @@ CKEDITOR.plugins.add( 'forms', { var attrs = input.attributes, type = attrs.type; + // Old IEs don't provide type for Text inputs #5522 + if ( !type ) + attrs.type = 'text'; if ( type == 'checkbox' || type == 'radio' ) attrs.value == 'on' && delete attrs.value; } @@ -258,27 +262,28 @@ CKEDITOR.plugins.add( 'forms', if ( CKEDITOR.env.ie ) { - CKEDITOR.dom.element.prototype.hasAttribute = function( name ) - { - var $attr = this.$.attributes.getNamedItem( name ); - - if ( this.getName() == 'input' ) + CKEDITOR.dom.element.prototype.hasAttribute = CKEDITOR.tools.override( CKEDITOR.dom.element.prototype.hasAttribute, + function( original ) { - switch ( name ) - { - case 'class' : - return this.$.className.length > 0; - case 'checked' : - return !!this.$.checked; - case 'value' : - var type = this.getAttribute( 'type' ); - if ( type == 'checkbox' || type == 'radio' ) - return this.$.value != 'on'; - break; - default: - } - } + return function( name ) + { + var $attr = this.$.attributes.getNamedItem( name ); + + if ( this.getName() == 'input' ) + { + switch ( name ) + { + case 'class' : + return this.$.className.length > 0; + case 'checked' : + return !!this.$.checked; + case 'value' : + var type = this.getAttribute( 'type' ); + return type == 'checkbox' || type == 'radio' ? this.$.value != 'on' : this.$.value; + } + } - return !!( $attr && $attr.specified ); - }; + return original.apply( this, arguments ); + }; + }); }