Ticket #3008: 3008_2.patch
File 3008_2.patch, 33.7 KB (added by , 15 years ago) |
---|
-
_source/plugins/htmldataprocessor/plugin.js
70 70 71 71 if ( attribs._cke_saved_href ) 72 72 delete attribs.href; 73 }, 74 75 /** 76 * IE sucks with dynamic 'name' attribute after element is created, '_cke_saved_name' is used instead for this attribute. 77 */ 78 input : function( element ) 79 { 80 var attribs = element.attributes; 81 82 if ( attribs._cke_saved_name ) 83 delete attribs.name; 73 84 } 74 85 }, 75 86 … … 93 104 }; 94 105 } 95 106 96 var protect UrlTagRegex = /<(?:a|area|img).*?\s((?:href|src)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+)))/gi;97 98 function protect Urls( html )107 var protectAttributeRegex = /<(?:a|area|img|input).*?\s((?:href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+)))/gi; 108 109 function protectAttributes( html ) 99 110 { 100 return html.replace( protect UrlTagRegex, '$& _cke_saved_$1' );111 return html.replace( protectAttributeRegex, '$& _cke_saved_$1' ); 101 112 } 102 113 103 114 CKEDITOR.plugins.add( 'htmldataprocessor', … … 132 143 // Before anything, we must protect the URL attributes as the 133 144 // browser may changing them when setting the innerHTML later in 134 145 // the code. 135 data = protect Urls( data );146 data = protectAttributes( data ); 136 147 137 148 // Call the browser to help us fixing a possibly invalid HTML 138 149 // structure. -
_source/plugins/forms/dialogs/checkbox.js
31 31 element.setAttribute( 'type', 'checkbox' ); 32 32 } 33 33 34 this.commitContent( element );35 36 34 if ( isInsertMode ) 37 35 editor.insertElement( element ); 36 this.commitContent( { element : element } ); 38 37 }, 39 38 contents : [ 40 39 { … … 51 50 accessKey : 'N', 52 51 setup : function( element ) 53 52 { 54 this.setValue( element.getAttribute( ' name' ));53 this.setValue( element.getAttribute( '_cke_saved_name' ) || '' ); 55 54 }, 56 commit : function( element)55 commit : function( data ) 57 56 { 58 if ( this.getValue() || this.isChanged() ) 59 element.setAttribute( 'name', this.getValue() ); 57 var element = data.element; 58 59 // IE failed to update 'name' property on input elements, protect it now. 60 if ( this.getValue() ) 61 element.setAttribute( '_cke_saved_name', this.getValue() ); 62 else 63 { 64 element.removeAttribute( '_cke_saved_name' ); 65 element.removeAttribute( 'name' ); 66 } 60 67 } 61 68 }, 62 69 { … … 67 74 accessKey : 'V', 68 75 setup : function( element ) 69 76 { 70 this.setValue( element.getAttribute( 'value' ) );77 this.setValue( element.getAttribute( 'value' ) || '' ); 71 78 }, 72 commit : function( element)79 commit : function( data ) 73 80 { 74 if ( this.getValue() || this.isChanged() ) 81 var element = data.element; 82 83 if ( this.getValue() ) 75 84 element.setAttribute( 'value', this.getValue() ); 85 else 86 element.removeAttribute( 'value' ); 76 87 } 77 88 }, 78 89 { … … 86 97 { 87 98 this.setValue( element.getAttribute( 'checked' ) ); 88 99 }, 89 commit : function( element)100 commit : function( data ) 90 101 { 91 if ( this.getValue() || this.isChanged() ) 92 element.setAttribute( 'checked', this.getValue() ); 102 var element = data.element; 103 104 if ( CKEDITOR.env.ie ) 105 { 106 var isElementChecked = !!element.getAttribute( 'checked' ); 107 var isChecked = !!this.getValue(); 108 109 if ( isElementChecked != isChecked ) 110 { 111 var replace = CKEDITOR.dom.element.createFromHtml( '<input type="checkbox"' 112 + ( isChecked ? ' checked="checked"' : '' ) 113 + '></input>', editor.document ); 114 element.copyAttributes( replace, { type : 1, checked : 1 } ); 115 replace.replace( element ); 116 editor.getSelection().selectElement( replace ); 117 data.element = replace; 118 } 119 } 120 else 121 { 122 if ( this.getValue() ) 123 element.setAttribute( 'checked', this.getValue() ); 124 else 125 element.removeAttribute( 'checked' ); 126 } 93 127 } 94 128 } 95 129 ] -
_source/plugins/forms/dialogs/textfield.js
4 4 */ 5 5 CKEDITOR.dialog.add( 'textfield', function( editor ) 6 6 { 7 var autoAttributes = 8 { 9 value : 1, 10 size : 1, 11 maxLength : 1 12 }; 13 14 var ieDefaults = 15 { 16 size : 20, 17 maxLength : 0x7fffffff 18 }; 19 20 var acceptedTypes = 21 { 22 text : 1, 23 password : 1 24 }; 25 7 26 return { 8 27 title : editor.lang.textfield.title, 9 28 minWidth : 350, … … 11 30 onShow : function() 12 31 { 13 32 var element = this.getParentEditor().getSelection().getSelectedElement(); 14 if ( element && element.getName() == "input" && ( element.getAttribute( 'type' ) == "text" || !element.getAttribute( 'type' ) ) ) 33 if ( element && element.getName() == "input" && 34 ( acceptedTypes[ element.getAttribute( 'type' ) ] || !element.getAttribute( 'type' ) ) ) 15 35 { 16 36 this._element = element; 17 37 this.setupContent( element ); … … 29 49 element = editor.document.createElement( 'input' ); 30 50 element.setAttribute( 'type', 'text' ); 31 51 } 32 this.commitContent( element );33 52 34 53 if ( isInsertMode ) 35 54 editor.insertElement( element ); 55 this.commitContent( { element : element } ); 36 56 }, 57 onLoad : function() 58 { 59 var autoSetup = function( element ) 60 { 61 var value = element.getAttribute( this.id ); 62 if ( CKEDITOR.env.ie && ( this.id in ieDefaults ) && ieDefaults[ this.id ] == value ) 63 this.setValue( '' ); 64 else 65 this.setValue( element.getAttribute( this.id ) || '' ); 66 }; 67 68 var autoCommit = function( data ) 69 { 70 var element = data.element; 71 var value = this.getValue(); 72 73 if ( value ) 74 element.setAttribute( this.id, value ); 75 else 76 element.removeAttribute( this.id ); 77 }; 78 79 this.foreach( function( contentObj ) 80 { 81 if ( autoAttributes[ contentObj.id ] ) 82 { 83 contentObj.setup = autoSetup; 84 contentObj.commit = autoCommit; 85 } 86 } ); 87 }, 37 88 contents : [ 38 89 { 39 90 id : 'info', … … 46 97 children : 47 98 [ 48 99 { 49 id : ' txtName',100 id : '_cke_saved_name', 50 101 type : 'text', 51 102 label : editor.lang.textfield.name, 52 103 'default' : '', 53 104 accessKey : 'N', 54 105 setup : function( element ) 55 106 { 56 this.setValue( element.getAttribute( 'name' ) ); 57 this.focus(); 107 this.setValue( 108 element.getAttribute( '_cke_saved_name' ) || 109 element.getAttribute( 'name' ) || 110 '' ); 58 111 }, 59 commit : function( element)112 commit : function( data ) 60 113 { 61 if ( this.getValue() || this.isChanged() ) 62 element.setAttribute( 'name', this.getValue() ); 114 var element = data.element; 115 116 if ( this.getValue() ) 117 element.setAttribute( '_cke_saved_name', this.getValue() ); 118 else 119 { 120 element.removeAttribute( '_cke_saved_name' ); 121 element.removeAttribute( 'name' ); 122 } 63 123 } 64 124 }, 65 125 { 66 id : ' txtValue',126 id : 'value', 67 127 type : 'text', 68 128 label : editor.lang.textfield.value, 69 129 'default' : '', 70 accessKey : 'V', 71 setup : function( element ) 72 { 73 this.setValue( element.getAttribute( 'value' ) ); 74 }, 75 commit : function( element ) 76 { 77 if ( this.getValue() || this.isChanged() ) 78 element.setAttribute( 'value', this.getValue() ); 79 } 130 accessKey : 'V' 80 131 } 81 132 ] 82 133 }, … … 86 137 children : 87 138 [ 88 139 { 89 id : ' txtTextCharWidth',140 id : 'size', 90 141 type : 'text', 91 142 label : editor.lang.textfield.charWidth, 92 143 'default' : '', 93 144 accessKey : 'C', 94 145 style : 'width:50px', 95 validate: function() 96 { 97 var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ); 98 return func.apply( this ); 99 }, 100 setup : function( element ) 101 { 102 this.setValue( element.getAttribute( 'size' ) ); 103 }, 104 commit : function( element ) 105 { 106 if ( this.getValue() || this.isChanged() ) 107 element.setAttribute( 'size', this.getValue() ); 108 } 146 validate : CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ) 109 147 }, 110 148 { 111 id : ' txtMaxChars',149 id : 'maxLength', 112 150 type : 'text', 113 151 label : editor.lang.textfield.maxChars, 114 152 'default' : '', 115 153 accessKey : 'M', 116 154 style : 'width:50px', 117 validate: function() 118 { 119 var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ); 120 return func.apply( this ); 121 }, 122 setup : function( element ) 123 { 124 this.setValue( element.getAttribute( 'maxlength' ) ); 125 }, 126 commit : function( element ) 127 { 128 if ( this.getValue() || this.isChanged() ) 129 element.setAttribute( 'maxlength', this.getValue() ); 130 } 155 validate : CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ) 131 156 } 132 157 ] 133 158 }, 134 159 { 135 id : ' cmbType',160 id : 'type', 136 161 type : 'select', 137 162 label : editor.lang.textfield.type, 138 163 'default' : 'text', … … 140 165 items : 141 166 [ 142 167 [ editor.lang.textfield.typeText, 'text' ], 143 [ editor.lang.textfield.typePass, 'pass ' ]168 [ editor.lang.textfield.typePass, 'password' ] 144 169 ], 145 170 setup : function( element ) 146 171 { 147 172 this.setValue( element.getAttribute( 'type' ) ); 148 173 }, 149 commit : function( element)174 commit : function( data ) 150 175 { 151 element.setAttribute( 'type', this.getValue() ); 176 var element = data.element; 177 178 if ( CKEDITOR.env.ie ) 179 { 180 var elementType = element.getAttribute( 'type' ); 181 var myType = this.getValue(); 182 183 if ( elementType != myType ) 184 { 185 var replace = CKEDITOR.dom.element.createFromHtml( '<input type="' + myType + '"></input>', editor.document ); 186 element.copyAttributes( replace, { type : 1 } ); 187 replace.replace( element ); 188 editor.getSelection().selectElement( replace ); 189 data.element = element; 190 } 191 } 192 else 193 element.setAttribute( 'type', this.getValue() ); 152 194 } 153 195 } 154 196 ] -
_source/plugins/forms/dialogs/button.js
32 32 editor = this.getParentEditor(); 33 33 element = editor.document.createElement( 'input' ); 34 34 } 35 this.commitContent( element );36 35 37 36 if ( isInsertMode ) 38 37 editor.insertElement( element ); 38 this.commitContent( { element : element } ); 39 39 }, 40 40 contents : [ 41 41 { … … 44 44 title : editor.lang.button.title, 45 45 elements : [ 46 46 { 47 id : ' txtName',47 id : '_cke_saved_name', 48 48 type : 'text', 49 49 label : editor.lang.common.name, 50 50 'default' : '', 51 51 setup : function( element ) 52 52 { 53 this.setValue( element.getAttribute( 'name' ) ); 54 this.focus(); 53 this.setValue( 54 element.getAttribute( '_cke_saved_name' ) || 55 element.getAttribute( 'name' ) || 56 '' ); 55 57 }, 56 commit : function( element)58 commit : function( data ) 57 59 { 58 if ( this.getValue() || this.isChanged() ) 59 element.setAttribute( 'name', this.getValue() ); 60 var element = data.element; 61 62 if ( this.getValue() ) 63 element.setAttribute( '_cke_saved_name', this.getValue() ); 64 else 65 { 66 element.removeAttribute( '_cke_saved_name' ); 67 element.removeAttribute( 'name' ); 68 } 60 69 } 61 70 }, 62 71 { 63 id : ' txtValue',72 id : 'value', 64 73 type : 'text', 65 74 label : editor.lang.button.text, 66 75 accessKey : 'V', 67 76 'default' : '', 68 77 setup : function( element ) 69 78 { 70 this.setValue( element.getAttribute( 'value' ) );79 this.setValue( element.getAttribute( 'value' ) || '' ); 71 80 }, 72 commit : function( element)81 commit : function( data ) 73 82 { 74 if ( this.getValue() || this.isChanged() ) 83 var element = data.element; 84 85 if ( this.getValue() ) 75 86 element.setAttribute( 'value', this.getValue() ); 87 else 88 element.removeAttribute( 'value' ); 76 89 } 77 90 }, 78 91 { 79 id : 't xtType',92 id : 'type', 80 93 type : 'select', 81 94 label : editor.lang.button.type, 82 95 'default' : 'button', … … 89 102 ], 90 103 setup : function( element ) 91 104 { 92 this.setValue( element.getAttribute( 'type' ) );105 this.setValue( element.getAttribute( 'type' ) || '' ); 93 106 }, 94 commit : function( element)107 commit : function( data ) 95 108 { 96 element.setAttribute( 'type', this.getValue() ); 109 var element = data.element; 110 111 if ( CKEDITOR.env.ie ) 112 { 113 var elementType = element.getAttribute( 'type' ); 114 var currentType = this.getValue(); 115 116 if ( currentType != elementType ) 117 { 118 var replace = CKEDITOR.dom.element.createFromHtml( '<input type="' + currentType + 119 '"></input>', editor.document ); 120 element.copyAttributes( replace, { type : 1 } ); 121 replace.replace( element ); 122 editor.getSelection().selectElement( replace ); 123 data.element = replace; 124 } 125 } 126 else 127 element.setAttribute( 'type', this.getValue() ); 97 128 } 98 129 } 99 130 ] -
_source/plugins/forms/dialogs/textarea.js
40 40 title : editor.lang.textarea.title, 41 41 elements : [ 42 42 { 43 id : ' txtName',43 id : '_cke_saved_name', 44 44 type : 'text', 45 45 label : editor.lang.common.name, 46 46 'default' : '', 47 47 accessKey : 'N', 48 48 setup : function( element ) 49 49 { 50 this.setValue( element.getAttribute( 'name' ) ); 51 this.focus(); 50 this.setValue( element.getAttribute( '_cke_saved_name' ) ); 52 51 }, 53 52 commit : function( element ) 54 53 { 55 if ( this.getValue() || this.isChanged() ) 56 element.setAttribute( 'name', this.getValue() ); 54 if ( this.getValue() ) 55 element.setAttribute( '_cke_saved_name', this.getValue() ); 56 else 57 { 58 element.removeAttribute( '_cke_saved_name' ); 59 element.removeAttribute( 'name' ); 60 } 57 61 } 58 62 }, 59 63 { 60 id : ' txtColumns',64 id : 'cols', 61 65 type : 'text', 62 66 label : editor.lang.textarea.cols, 63 67 'default' : '', 64 68 accessKey : 'C', 65 69 style : 'width:50px', 66 validate: function() 67 { 68 var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ); 69 return func.apply( this ); 70 }, 70 validate : CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ), 71 71 setup : function( element ) 72 72 { 73 this.setValue( element.getAttribute( 'cols' ) ); 73 var ieDefault = 20; 74 var value = element.getAttribute( 'cols' ); 75 this.setValue( ( CKEDITOR.env.ie && ( value == ieDefault ) ? '' : value ) || '' ); 74 76 }, 75 77 commit : function( element ) 76 78 { 77 if ( this.getValue() || this.isChanged())79 if ( this.getValue() ) 78 80 element.setAttribute( 'cols', this.getValue() ); 81 else 82 element.removeAttribute( 'cols' ); 79 83 } 80 84 }, 81 85 { 82 id : ' txtRows',86 id : 'rows', 83 87 type : 'text', 84 88 label : editor.lang.textarea.rows, 85 89 'default' : '', 86 90 accessKey : 'R', 87 91 style : 'width:50px', 88 validate: function() 89 { 90 var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ); 91 return func.apply( this ); 92 }, 92 validate : CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ), 93 93 setup : function( element ) 94 94 { 95 this.setValue( element.getAttribute( 'rows' ) ); 95 var ieDefault = 2; 96 var value = element.getAttribute( 'rows' ); 97 this.setValue( ( CKEDITOR.env.ie && ( value == ieDefault ) ? '' : value ) || '' ); 96 98 }, 97 99 commit : function( element ) 98 100 { 99 if ( this.getValue() || this.isChanged())101 if ( this.getValue() ) 100 102 element.setAttribute( 'rows', this.getValue() ); 103 else 104 element.removeAttribute( 'rows' ); 101 105 } 102 106 } 103 107 ] -
_source/plugins/forms/dialogs/radio.js
29 29 element = editor.document.createElement( 'input' ); 30 30 element.setAttribute( 'type', 'radio' ); 31 31 } 32 this.commitContent( element );33 32 34 33 if ( isInsertMode ) 35 34 editor.insertElement( element ); 35 this.commitContent( { element : element } ); 36 36 }, 37 37 contents : [ 38 38 { … … 41 41 title : editor.lang.checkboxAndRadio.radioTitle, 42 42 elements : [ 43 43 { 44 id : ' txtName',44 id : 'name', 45 45 type : 'text', 46 46 label : editor.lang.common.name, 47 47 'default' : '', 48 48 accessKey : 'N', 49 49 setup : function( element ) 50 50 { 51 this.setValue( element.getAttribute( 'name' ) ); 52 this.focus(); 51 this.setValue( element.getAttribute( '_cke_saved_name' ) || '' ); 53 52 }, 54 commit : function( element)53 commit : function( data ) 55 54 { 56 if ( this.getValue() || this.isChanged() ) 57 element.setAttribute( 'name', this.getValue() ); 55 var element = data.element; 56 57 if ( this.getValue() ) 58 element.setAttribute( '_cke_saved_name', this.getValue() ); 59 else 60 { 61 element.removeAttribute( '_cke_saved_name' ); 62 element.removeAttribute( 'name' ); 63 } 58 64 } 59 65 }, 60 66 { 61 id : ' txtValue',67 id : 'value', 62 68 type : 'text', 63 69 label : editor.lang.checkboxAndRadio.value, 64 70 'default' : '', 65 71 accessKey : 'V', 66 72 setup : function( element ) 67 73 { 68 this.setValue( element.getAttribute( 'value' ) );74 this.setValue( element.getAttribute( 'value' ) || '' ); 69 75 }, 70 commit : function( element)76 commit : function( data ) 71 77 { 72 if ( this.getValue() || this.isChanged() ) 78 var element = data.element; 79 80 if ( this.getValue() ) 73 81 element.setAttribute( 'value', this.getValue() ); 82 else 83 element.removeAttribute( 'value' ); 74 84 } 75 85 }, 76 86 { 77 id : 'c mbSelected',87 id : 'checked', 78 88 type : 'checkbox', 79 89 label : editor.lang.checkboxAndRadio.selected, 80 90 'default' : '', … … 84 94 { 85 95 this.setValue( element.getAttribute( 'checked' ) ); 86 96 }, 87 commit : function( element)97 commit : function( data ) 88 98 { 89 if ( this.getValue() || this.isChanged() ) 90 element.setAttribute( 'checked', this.getValue() ); 99 var element = data.element; 100 101 if ( !CKEDITOR.env.ie ) 102 { 103 if ( this.getValue() ) 104 element.setAttribute( 'checked', 'checked' ); 105 else 106 element.removeAttribute( 'checked' ); 107 } 108 else 109 { 110 var isElementChecked = element.getAttribute( 'checked' ); 111 var isChecked = !!this.getValue(); 112 113 if ( isElementChecked != isChecked ) 114 { 115 var replace = CKEDITOR.dom.element.createFromHtml( '<input type="radio"' 116 + ( isChecked ? ' checked="checked"' : '' ) 117 + '></input>', editor.document ); 118 element.copyAttributes( replace, { type : 1, checked : 1 } ); 119 replace.replace( element ); 120 editor.getSelection().selectElement( replace ); 121 data.element = replace; 122 } 123 } 91 124 } 92 125 } 93 126 ] -
_source/plugins/forms/dialogs/hiddenfield.js
29 29 element = editor.document.createElement( 'input' ); 30 30 element.setAttribute( 'type', 'hidden' ); 31 31 } 32 this.commitContent( element ); 33 32 34 33 if ( isInsertMode ) 35 34 editor.insertElement( element ); 35 this.commitContent( element ); 36 36 }, 37 37 contents : [ 38 38 { … … 41 41 title : editor.lang.hidden.title, 42 42 elements : [ 43 43 { 44 id : ' txtName',44 id : '_cke_saved_name', 45 45 type : 'text', 46 46 label : editor.lang.hidden.name, 47 47 'default' : '', 48 48 accessKey : 'N', 49 49 setup : function( element ) 50 50 { 51 this.setValue( element.getAttribute( 'name' ) ); 52 this.focus(); 51 this.setValue( 52 element.getAttribute( '_cke_saved_name' ) || 53 element.getAttribute( 'name' ) || 54 '' ); 53 55 }, 54 56 commit : function( element ) 55 57 { 56 if ( this.getValue() || this.isChanged() ) 57 element.setAttribute( 'name', this.getValue() ); 58 if ( this.getValue() ) 59 element.setAttribute( '_cke_saved_name', this.getValue() ); 60 else 61 { 62 element.removeAttribute( '_cke_saved_name' ); 63 element.removeAttribute( 'name' ); 64 } 58 65 } 59 66 }, 60 67 { 61 id : ' txtValue',68 id : 'value', 62 69 type : 'text', 63 70 label : editor.lang.hidden.value, 64 71 'default' : '', 65 72 accessKey : 'V', 66 73 setup : function( element ) 67 74 { 68 this.setValue( element.getAttribute( 'value' ) );75 this.setValue( element.getAttribute( 'value' ) || '' ); 69 76 }, 70 77 commit : function( element ) 71 78 { 72 if ( this.getValue() || this.isChanged())79 if ( this.getValue() ) 73 80 element.setAttribute( 'value', this.getValue() ); 81 else 82 element.removeAttribute( 'value' ); 74 83 } 75 84 } 76 85 ] -
_source/plugins/forms/dialogs/select.js
132 132 return { 133 133 title : editor.lang.select.title, 134 134 minWidth : 375, 135 minHeight : 2 70,135 minHeight : 290, 136 136 onShow : function() 137 137 { 138 138 this.setupContent( 'clear' ); … … 142 142 this._element = element; 143 143 this.setupContent( element.getName(), element ); 144 144 145 // Load Options into dialog.145 // Load Options into dialog. 146 146 var objOptions = getOptions( element ); 147 147 for ( var i = 0 ; i < objOptions.count() ; i++ ) 148 148 this.setupContent( 'option', objOptions.getItem( i ) ); … … 180 180 style : 'width:350px', 181 181 setup : function( name, element ) 182 182 { 183 if ( name == 'select' ) 184 { 185 this.setValue( element.getAttribute( 'name' ) ); 186 this.focus(); 187 } 183 if ( name == 'clear' ) 184 this.setValue( '' ); 185 else if ( name == 'select' ) 186 this.setValue( element.getAttribute( '_cke_saved_name' ) || '' ); 188 187 }, 189 188 commit : function( element ) 190 189 { 191 if ( this.getValue() || this.isChanged() ) 192 element.setAttribute( 'name', this.getValue() ); 190 if ( this.getValue() ) 191 element.setAttribute( '_cke_saved_name', this.getValue() ); 192 else 193 { 194 element.removeAttribute( '_cke_saved_name' ) ; 195 element.removeAttribute( 'name' ); 196 } 193 197 } 194 198 }, 195 199 { … … 200 204 label : editor.lang.select.value, 201 205 style : 'width:350px', 202 206 'default' : '', 203 readonly : true, // TODO: make it readonly somehow. 204 disabled : true 207 onLoad : function() 208 { 209 this.getInputElement().setAttribute( 'readOnly', true ); 210 }, 211 setup : function( name, element ) 212 { 213 if ( name == 'clear' ) 214 this.setValue( '' ); 215 else if ( name == 'option' && element.getAttribute( 'selected' ) ) 216 this.setValue( element.$.value ); 217 } 205 218 }, 206 219 { 207 220 type : 'hbox', … … 226 239 setup : function( name, element ) 227 240 { 228 241 if ( name == 'select' ) 229 this.setValue( element.getAttribute( 'size' ) );242 this.setValue( element.getAttribute( 'size' ) || '' ); 230 243 }, 231 244 commit : function( element ) 232 245 { 233 if ( this.getValue() || this.isChanged())246 if ( this.getValue() ) 234 247 element.setAttribute( 'size', this.getValue() ); 248 else 249 element.removeAttribute( 'size' ); 235 250 } 236 251 }, 237 252 { … … 504 519 }, 505 520 commit : function( element ) 506 521 { 507 if ( this.getValue() || this.isChanged())522 if ( this.getValue() ) 508 523 element.setAttribute( 'multiple', this.getValue() ); 524 else 525 element.removeAttribute( 'multiple' ); 509 526 } 510 527 } 511 528 ] -
_source/plugins/forms/dialogs/form.js
4 4 */ 5 5 CKEDITOR.dialog.add( 'form', function( editor ) 6 6 { 7 var autoAttributes = 8 { 9 action : 1, 10 id : 1, 11 method : 1, 12 encoding : 1, 13 target : 1 14 }; 15 7 16 return { 8 17 title : editor.lang.form.title, 9 18 minWidth : 350, 10 19 minHeight : 190, 11 20 onShow : function() 12 21 { 13 var element = this.getParentEditor().getSelection().getSelectedElement(); 14 if ( element && element.getName() == "form" ) 22 var element = this.getParentEditor().getSelection().getStartElement(); 23 var form = element && element.getAscendant( 'form', true ); 24 if ( form ) 15 25 { 16 this._element = element;17 this.setupContent( element);26 this._element = form; 27 this.setupContent( form ); 18 28 } 19 29 }, 20 30 onOk : function() … … 29 39 element = editor.document.createElement( 'form' ); 30 40 element.append( editor.document.createElement( 'br' ) ); 31 41 } 32 this.commitContent( element );33 42 34 43 if ( isInsertMode ) 35 44 editor.insertElement( element ); 45 this.commitContent( element ); 36 46 }, 47 onLoad : function() 48 { 49 function autoSetup( element ) 50 { 51 this.setValue( element.getAttribute( this.id ) || '' ); 52 } 53 54 function autoCommit( element ) 55 { 56 if ( this.getValue() ) 57 element.setAttribute( this.id, this.getValue() ); 58 else 59 element.removeAttribute( this.id ); 60 } 61 62 this.foreach( function( contentObj ) 63 { 64 if ( autoAttributes[ contentObj.id ] ) 65 { 66 contentObj.setup = autoSetup; 67 contentObj.commit = autoCommit; 68 } 69 } ); 70 }, 37 71 contents : [ 38 72 { 39 73 id : 'info', … … 48 82 accessKey : 'N', 49 83 setup : function( element ) 50 84 { 51 this.setValue( element.getAttribute( 'name' ) ); 52 this.focus(); 85 this.setValue( element.getAttribute( '_cke_saved_name' ) || 86 element.getAttribute( 'name' ) || 87 '' ); 53 88 }, 54 89 commit : function( element ) 55 90 { 56 if ( this.getValue() || this.isChanged() ) 57 element.setAttribute( 'name', this.getValue() ); 91 if ( this.getValue() ) 92 element.setAttribute( '_cke_saved_name', this.getValue() ); 93 else 94 { 95 element.removeAttribute( '_cke_saved_name' ); 96 element.removeAttribute( 'name' ); 97 } 58 98 } 59 99 }, 60 100 { 61 id : ' txtAction',101 id : 'action', 62 102 type : 'text', 63 103 label : editor.lang.form.action, 64 104 'default' : '', 65 accessKey : 'A', 66 setup : function( element ) 67 { 68 this.setValue( element.getAttribute( 'action' ) ); 69 }, 70 commit : function( element ) 71 { 72 if ( this.getValue() || this.isChanged() ) 73 element.setAttribute( 'action', this.getValue() ); 74 } 105 accessKey : 'A' 75 106 }, 76 107 { 77 108 type : 'hbox', … … 79 110 children : 80 111 [ 81 112 { 82 id : ' txtId',113 id : 'id', 83 114 type : 'text', 84 115 label : editor.lang.common.id, 85 116 'default' : '', 86 accessKey : 'I', 87 setup : function( element ) 88 { 89 this.setValue( element.getAttribute( 'id' ) ); 90 }, 91 commit : function( element ) 92 { 93 if ( this.getValue() || this.isChanged() ) 94 element.setAttribute( 'id', this.getValue() ); 95 } 117 accessKey : 'I' 96 118 }, 97 119 { 98 id : ' cmbEncoding',120 id : 'encoding', 99 121 type : 'select', 100 122 label : editor.lang.form.encoding, 101 123 style : 'width:100%', … … 107 129 [ 'text/plain' ], 108 130 [ 'multipart/form-data' ], 109 131 [ 'application/x-www-form-urlencoded' ] 110 ], 111 setup : function( element ) 112 { 113 this.setValue( element.getAttribute( 'encoding' ) ); 114 }, 115 commit : function( element ) 116 { 117 if ( this.getValue() || this.isChanged() ) 118 element.setAttribute( 'encoding', this.getValue() ); 119 } 132 ] 120 133 } 121 134 ] 122 135 }, … … 126 139 children : 127 140 [ 128 141 { 129 id : ' cmbTarget',142 id : 'target', 130 143 type : 'select', 131 144 label : editor.lang.form.target, 132 145 style : 'width:100%', … … 139 152 [ editor.lang.form.targetTop, '_top' ], 140 153 [ editor.lang.form.targetSelf, '_self' ], 141 154 [ editor.lang.form.targetParent, '_parent' ] 142 ], 143 setup : function( element ) 144 { 145 this.setValue( element.getAttribute( 'target' ) ); 146 }, 147 commit : function( element ) 148 { 149 if ( this.getValue() || this.isChanged() ) 150 element.setAttribute( 'target', this.getValue() ); 151 } 155 ] 152 156 }, 153 157 { 154 id : ' cmbMethod',158 id : 'method', 155 159 type : 'select', 156 160 label : editor.lang.form.method, 157 161 accessKey : 'M', … … 160 164 [ 161 165 [ 'GET', 'get' ], 162 166 [ 'POST', 'post' ] 163 ], 164 setup : function( element ) 165 { 166 this.setValue( element.getAttribute( 'method' ) ); 167 }, 168 commit : function( element ) 169 { 170 element.setAttribute( 'method', this.getValue() ); 171 } 167 ] 172 168 } 173 169 ] 174 170 } -
_source/core/dom/element.js
421 421 return tabIndex; 422 422 break; 423 423 424 case 'checked': 425 return this.$.checked; 426 break; 427 424 428 case 'style': 425 429 // IE does not return inline styles via getAttribute(). See #2947. 426 430 return this.$.style.cssText; … … 828 832 } 829 833 }, 830 834 831 copyAttributes : function( target, skip )832 {833 skip || ( skip = {} );834 var attributes = this.$.attributes;835 836 for ( var n = 0 ; n < attributes.length ; n++ )837 {838 var attr = attributes[n];839 840 if ( attr.specified )841 {842 var attrName = attr.nodeName;843 if ( attrName in skip )844 continue;845 846 var attrValue = this.getAttribute( attrName );847 if ( !attrValue )848 attrValue = attr.nodeValue;849 850 target.setAttribute( attrName, attrValue );851 }852 }853 854 if ( this.$.style.cssText !== '' )855 target.$.style.cssText = this.$.style.cssText;856 },857 858 835 /** 859 836 * Shows this element (display it). 860 837 * @example … … 1278 1255 { 1279 1256 var attribute = attributes[n]; 1280 1257 1281 if ( attribute.specified ) 1258 // IE BUG: value attribute is never specified even if it exists. 1259 if ( attribute.specified || 1260 ( CKEDITOR.env.ie && attribute.nodeValue && attribute.nodeName.toLowerCase() == 'value' ) ) 1282 1261 { 1283 1262 var attrName = attribute.nodeName; 1284 1263 // We can set the type only once, so do it with the proper value, not copying it.