Ticket #2820: 2820.patch
File 2820.patch, 31.2 KB (added by , 15 years ago) |
---|
-
button.js
4 4 */ 5 5 CKEDITOR.dialog.add( 'button', function( editor ) 6 6 { 7 var addChange = function( name, input ){8 var dialog = input.getDialog();9 if ( input.isChanged() || ( dialog.editMode == false && input.getValue() != '' ))10 {11 dialog.changedAttibutes[ name ] = input.getValue();12 return true;13 }14 return false;15 };16 17 // Function called in onShow to load selected element.18 var loadSelection = function( editor, selection, ranges, element ){19 // Read attributes.20 var type = element.getAttribute( 'type' );21 var name = element.getAttribute( 'name' );22 var value = element.getAttribute( 'value' );23 24 // Fill out all fields.25 this.setValueOf( 'info', 'txtName', name );26 this.setValueOf( 'info', 'txtValue', value );27 this.setValueOf( 'info', 'txtType', type );28 29 this.saveSelection();30 this.editMode = true;31 this.editObj = element;32 33 return false;34 };35 36 7 return { 37 8 title : editor.lang.button.title, 38 resizable : CKEDITOR.DIALOG_RESIZE_NONE,39 9 minWidth : 400, 40 10 minHeight : 230, 41 11 onShow : function() 42 12 { 43 // Default: create a new element. 44 this.editMode = false; 45 46 // IE BUG: Selection must be in the editor for getSelection() to work. 13 // IE BUG: Selection must be in the editor for getSelectedElement() 14 // to work. 47 15 this.restoreSelection(); 48 16 49 var editor = this.getParentEditor(), 50 selection = editor.getSelection(), 51 ranges = selection.getRanges(); 52 53 // Check selection. Fill in all the relevant fields if there's already one link selected. 54 if ( ranges.length == 1 ) 17 var element = this.getParentEditor().getSelection().getSelectedElement(); 18 if ( element && element.getName() == "input" ) 55 19 { 56 ranges[0].enlarge( CKEDITOR.ENLARGE_ELEMENT ); 57 58 var rangeRoot = ranges[0].getCommonAncestor( true ); 59 var element = rangeRoot.getAscendant( 'input', true ); 60 if ( element && element.getAttribute( 'type' ) ) 20 var type = element.getAttribute( 'type' ); 21 if ( type == "button" || type == "reset" || type == "submit" ) 61 22 { 62 var type = element.getAttribute( 'type' ); 63 if ( type == "button" || type == "reset" || type == "submit" ) 64 { 65 loadSelection.apply( this, [ editor, selection, ranges, element ] ); 66 selection.selectElement( element ); 67 } 23 this._element = element; 24 this.setupContent( element ); 68 25 } 69 26 } 70 27 71 if ( this.editMode == false ) //New object.72 this.editObj = editor.document.createElement( 'input' );73 28 this.getContentElement( 'info', 'txtName' ).focus(); 74 75 this.changedAttibutes = new Array();76 29 }, 77 30 onOk : function() 78 31 { 79 this.editObj.setAttributes( this.changedAttibutes ); 32 var editor, 33 element = this._element, 34 isInsertMode = !element; 80 35 81 if ( this.editMode == false )36 if ( isInsertMode ) 82 37 { 38 editor = this.getParentEditor(); 39 element = editor.document.createElement( 'input' ); 40 } 41 this.commitContent( element ); 42 43 if ( isInsertMode ) 44 { 83 45 this.restoreSelection(); 84 46 this.clearSavedSelection(); 85 editor.insertElement( this.editObj);47 editor.insertElement( element ); 86 48 } 87 return true;88 49 }, 89 50 contents : [ 90 51 { … … 98 59 type : 'text', 99 60 label : editor.lang.common.name, 100 61 'default' : '', 101 validate: function()62 setup : function( element ) 102 63 { 103 addChange( 'name', this ); 104 return true; 64 this.setValue( element.getAttribute( 'name' ) ); 65 }, 66 commit : function( element ) 67 { 68 element.setAttribute( 'name', this.getValue() ); 105 69 } 106 70 }, 107 71 { … … 110 74 label : editor.lang.button.text, 111 75 accessKey : 'V', 112 76 'default' : '', 113 validate: function()77 setup : function( element ) 114 78 { 115 addChange( 'value', this ); 116 return true; 79 this.setValue( element.getAttribute( 'value' ) ); 80 }, 81 commit : function( element ) 82 { 83 element.setAttribute( 'value', this.getValue() ); 117 84 } 118 85 }, 119 86 { … … 128 95 [ editor.lang.button.typeSbm, 'submit' ], 129 96 [ editor.lang.button.typeRst, 'reset' ] 130 97 ], 131 validate: function()98 setup : function( element ) 132 99 { 133 addChange( 'type', this ); 134 return true; 100 this.setValue( element.getAttribute( 'type' ) ); 101 }, 102 commit : function( element ) 103 { 104 element.setAttribute( 'type', this.getValue() ); 135 105 } 136 106 } 137 107 ] -
form.js
4 4 */ 5 5 CKEDITOR.dialog.add( 'form', function( editor ) 6 6 { 7 var addChange = function( name, input ){8 var dialog = input.getDialog();9 if ( input.isChanged() || ( dialog.editMode == false && input.getValue() != '' ))10 {11 dialog.changedAttibutes[ name ] = input.getValue();12 return true;13 }14 return false;15 };16 17 // Function called in onShow to load selected element.18 var loadSelection = function( editor, selection, ranges, element )19 {20 this.saveSelection();21 this.editObj = element;22 this.editMode = true;23 24 // Fill out all fields.25 readAttribute.apply( this, [ this.editObj, 'info', 'name', 'txtName', true ] );26 readAttribute.apply( this, [ this.editObj, 'info', 'action', 'txtAction', true ] );27 readAttribute.apply( this, [ this.editObj, 'info', 'method', 'cmbMethod', true ] );28 readAttribute.apply( this, [ this.editObj, 'info', 'encoding', 'cmbEncoding', true ] );29 readAttribute.apply( this, [ this.editObj, 'info', 'target', 'cmbTarget', true ] );30 readAttribute.apply( this, [ this.editObj, 'info', 'id', 'txtId', true ] );31 32 return false;33 };34 35 var readAttribute = function( object, page, attribute, input, setIfNull )36 {37 var attributeValue = object.getAttribute( attribute );38 if ( attributeValue == null )39 if ( setIfNull )40 this.setValueOf( page, input, "" );41 else42 this.setValueOf( page, input, attributeValue );43 return attributeValue;44 }45 46 7 return { 47 8 title : editor.lang.form.title, 48 resizable : CKEDITOR.DIALOG_RESIZE_NONE,49 9 minWidth : 400, 50 10 minHeight : 270, 51 on Ok: function()11 onShow : function() 52 12 { 53 this.editObj.setAttributes( this.changedAttibutes ); 13 // IE BUG: Selection must be in the editor for getSelectedElement() 14 // to work. 15 this.restoreSelection(); 54 16 55 if ( this.editMode == false ) 17 var element = this.getParentEditor().getSelection().getSelectedElement(); 18 if ( element && element.getName() == "form" ) 56 19 { 57 this.restoreSelection(); 58 this.clearSavedSelection(); 59 editor.insertElement( this.editObj ); 20 this._element = element; 21 this.setupContent( element ); 60 22 } 61 return true; 23 24 this.getContentElement( 'info', 'txtName' ).focus(); 62 25 }, 63 on Show: function()26 onOk : function() 64 27 { 65 // Default: create a new element.66 this.editMode = false;67 this.changedAttibutes = new Array();28 var editor, 29 element = this._element, 30 isInsertMode = !element; 68 31 69 // IE BUG: Selection must be in the editor for getSelection() to work. 70 this.restoreSelection(); 71 72 var editor = this.getParentEditor(), 73 selection = editor.getSelection(), 74 ranges = selection.getRanges(); 75 76 // Check selection. Fill in all the relevant fields if there's already one link selected. 77 if ( ranges.length == 1 ) 32 if ( isInsertMode ) 78 33 { 79 ranges[0].enlarge( CKEDITOR.ENLARGE_ELEMENT ); 80 81 var rangeRoot = ranges[0].getCommonAncestor( true ); 82 var element = rangeRoot.getAscendant( 'form', true ); 83 if ( element ) 84 { 85 loadSelection.apply( this, [ editor, selection, ranges, element ] ); 86 selection.selectElement( element ); 87 } 34 editor = this.getParentEditor(); 35 element = editor.document.createElement( 'form' ); 88 36 } 37 this.commitContent( element ); 89 38 90 if( this.editMode == false ) 91 this.editObj = editor.document.createElement( 'form' ); 92 93 this.getContentElement( 'info', 'txtName' ).focus(); 39 if ( isInsertMode ) 40 { 41 this.restoreSelection(); 42 this.clearSavedSelection(); 43 editor.insertElement( element ); 44 } 94 45 }, 95 46 contents : [ 96 47 { … … 105 56 label : editor.lang.common.name, 106 57 'default' : '', 107 58 accessKey : 'N', 108 validate: function()59 setup : function( element ) 109 60 { 110 addChange( 'name', this ); 111 return true; 61 this.setValue( element.getAttribute( 'name' ) ); 62 }, 63 commit : function( element ) 64 { 65 element.setAttribute( 'name', this.getValue() ); 112 66 } 113 67 }, 114 68 { … … 117 71 label : editor.lang.form.action, 118 72 'default' : editor.config.forms.defaultValues.formAction, 119 73 accessKey : 'A', 120 validate: function()74 setup : function( element ) 121 75 { 122 addChange( 'action', this ); 123 return true; 76 this.setValue( element.getAttribute( 'action' ) ); 77 }, 78 commit : function( element ) 79 { 80 element.setAttribute( 'action', this.getValue() ); 124 81 } 125 82 }, 126 83 { … … 134 91 label : editor.lang.common.id, 135 92 'default' : '', 136 93 accessKey : 'I', 137 validate: function()94 setup : function( element ) 138 95 { 139 addChange( 'id', this ); 140 return true; 96 this.setValue( element.getAttribute( 'id' ) ); 97 }, 98 commit : function( element ) 99 { 100 element.setAttribute( 'id', this.getValue() ); 141 101 } 142 102 }, 143 103 { … … 153 113 [ 'multipart/form-data' ], 154 114 [ 'application/x-www-form-urlencoded' ] 155 115 ], 156 validate: function()116 setup : function( element ) 157 117 { 158 addChange( 'encoding', this ); 159 return true; 118 this.setValue( element.getAttribute( 'encoding' ) ); 119 }, 120 commit : function( element ) 121 { 122 element.setAttribute( 'encoding', this.getValue() ); 160 123 } 161 124 } 162 125 ] … … 181 144 [ editor.lang.form.targetSelf, '_self' ], 182 145 [ editor.lang.form.targetParent, '_parent' ] 183 146 ], 184 validate: function()147 setup : function( element ) 185 148 { 186 addChange( 'target', this ); 187 return true; 149 this.setValue( element.getAttribute( 'target' ) ); 150 }, 151 commit : function( element ) 152 { 153 element.setAttribute( 'target', this.getValue() ); 188 154 } 189 155 }, 190 156 { … … 198 164 [ 'GET', 'get' ], 199 165 [ 'POST', 'post' ] 200 166 ], 201 validate: function()167 setup : function( element ) 202 168 { 203 addChange( 'method', this ); 204 return true; 169 this.setValue( element.getAttribute( 'method' ) ); 170 }, 171 commit : function( element ) 172 { 173 element.setAttribute( 'method', this.getValue() ); 205 174 } 206 175 } 207 176 ] -
hiddenfield.js
4 4 */ 5 5 CKEDITOR.dialog.add( 'hiddenfield', function( editor ) 6 6 { 7 var addChange = function( name, input ){8 var dialog = input.getDialog();9 if ( input.isChanged() || ( dialog.editMode == false && input.getValue() != '' ))10 {11 dialog.changedAttibutes[ name ] = input.getValue();12 return true;13 }14 return false;15 };16 17 // Function called in onShow to load selected element.18 var loadSelection = function( editor, selection, ranges, element )19 {20 this.saveSelection();21 this.editObj = element;22 this.editMode = true;23 24 // Fill out all fields.25 var name = element.getAttribute( 'name' );26 var value = element.getAttribute( 'value' );27 28 this.setValueOf( 'info', 'txtName', name );29 this.setValueOf( 'info', 'txtValue', value );30 31 return false;32 };33 7 return { 34 8 title : editor.lang.hidden.title, 35 resizable : CKEDITOR.DIALOG_RESIZE_NONE,36 9 minWidth : 400, 37 10 minHeight : 200, 38 11 onShow : function() 39 12 { 40 // Default: create a new element. 41 this.editMode = false; 42 this.changedAttibutes = new Array(); 43 44 // IE BUG: Selection must be in the editor for getSelection() to work. 13 // IE BUG: Selection must be in the editor for getSelectedElement() 14 // to work. 45 15 this.restoreSelection(); 46 16 47 var editor = this.getParentEditor(), 48 selection = editor.getSelection(), 49 ranges = selection.getRanges(); 50 51 // Check selection. Fill in all the relevant fields if there's already one link selected. 52 if ( ranges.length == 1 ) 17 var element = this.getParentEditor().getSelection().getSelectedElement(); 18 if ( element && element.getName() == "input" && element.getAttribute( 'type' ) == "checkbox" ) 53 19 { 54 ranges[0].enlarge( CKEDITOR.ENLARGE_ELEMENT ); 55 56 var rangeRoot = ranges[0].getCommonAncestor( true ); 57 var element = rangeRoot.getAscendant( 'input', true ); 58 if ( element && element.getAttribute( 'type' ) == "hidden" ) 59 { 60 loadSelection.apply( this, [ editor, selection, ranges, element ] ); 61 selection.selectElement( element ); 62 } 20 this._element = element; 21 this.setupContent( element ); 63 22 } 64 23 65 if( this.editMode == false ) //New object.66 this.editObj = editor.document.createElement( 'input' );67 68 24 this.getContentElement( 'info', 'txtName' ).focus(); 69 25 }, 70 26 onOk : function() 71 27 { 72 this.changedAttibutes[ 'type' ] = 'hidden'; 73 this.editObj.setAttributes( this.changedAttibutes ); 28 var editor, 29 element = this._element, 30 isInsertMode = !element; 74 31 75 if ( this.editMode == false )32 if ( isInsertMode ) 76 33 { 34 editor = this.getParentEditor(); 35 element = editor.document.createElement( 'input' ); 36 element.setAttribute( 'type', 'hidden' ); 37 } 38 this.commitContent( element ); 39 40 if ( isInsertMode ) 41 { 77 42 this.restoreSelection(); 78 43 this.clearSavedSelection(); 79 editor.insertElement( this.editObj);44 editor.insertElement( element ); 80 45 } 81 return true;82 46 }, 83 47 contents : [ 84 48 { … … 93 57 label : editor.lang.hidden.name, 94 58 'default' : '', 95 59 accessKey : 'N', 96 validate: function()60 setup : function( element ) 97 61 { 98 addChange( 'name', this ); 99 return true; 62 this.setValue( element.getAttribute( 'name' ) ); 63 }, 64 commit : function( element ) 65 { 66 element.setAttribute( 'name', this.getValue() ); 100 67 } 101 68 }, 102 69 { … … 105 72 label : editor.lang.hidden.value, 106 73 'default' : '', 107 74 accessKey : 'V', 108 validate: function()75 setup : function( element ) 109 76 { 110 addChange( 'value', this ); 111 return true; 77 this.setValue( element.getAttribute( 'value' ) ); 78 }, 79 commit : function( element ) 80 { 81 element.setAttribute( 'value', this.getValue() ); 112 82 } 113 83 } 114 84 ] -
radio.js
4 4 */ 5 5 CKEDITOR.dialog.add( 'radio', function( editor ) 6 6 { 7 var addChange = function( name, input ){8 var dialog = input.getDialog();9 if ( input.isChanged() || ( dialog.editMode == false && input.getValue() != '' ))10 {11 dialog.changedAttibutes[ name ] = input.getValue();12 return true;13 }14 return false;15 };16 17 // Function called in onShow to load selected element.18 var loadSelection = function( editor, selection, ranges, element )19 {20 this.saveSelection();21 this.editObj = element;22 this.editMode = true;23 24 // Read attributes.25 var checked = element.getAttribute( 'checked' );26 var name = element.getAttribute( 'name' );27 var value = element.getAttribute( 'value' );28 29 // Fill out all fields.30 this.setValueOf( 'info', 'txtName', name );31 this.setValueOf( 'info', 'txtValue', value );32 this.setValueOf( 'info', 'cmbSelected', checked );33 34 return false;35 };36 7 return { 37 8 title : editor.lang.checkboxAndRadio.radioTitle, 38 resizable : CKEDITOR.DIALOG_RESIZE_NONE,39 9 minWidth : 400, 40 10 minHeight : 200, 41 11 onShow : function() 42 12 { 43 // Default: create a new element. 44 this.editMode = false; 45 this.changedAttibutes = new Array(); 46 47 // IE BUG: Selection must be in the editor for getSelection() to work. 13 // IE BUG: Selection must be in the editor for getSelectedElement() 14 // to work. 48 15 this.restoreSelection(); 49 16 50 var editor = this.getParentEditor(), 51 selection = editor.getSelection(), 52 ranges = selection.getRanges(); 53 54 // Check selection. Fill in all the relevant fields if there's already one link selected. 55 if ( ranges.length == 1 ) 17 var element = this.getParentEditor().getSelection().getSelectedElement(); 18 if ( element && element.getName() == "input" && element.getAttribute( 'type' ) == "radio" ) 56 19 { 57 ranges[0].enlarge( CKEDITOR.ENLARGE_ELEMENT ); 58 59 var rangeRoot = ranges[0].getCommonAncestor( true ); 60 var element = rangeRoot.getAscendant( 'input', true ); 61 if ( element && element.getAttribute( 'type' ) == "radio" ) 62 { 63 loadSelection.apply( this, [ editor, selection, ranges, element ] ); 64 selection.selectElement( element ); 65 } 20 this._element = element; 21 this.setupContent( element ); 66 22 } 67 23 68 if( this.editMode == false ) //New object.69 this.editObj = editor.document.createElement( 'input' );70 71 24 this.getContentElement( 'info', 'txtName' ).focus(); 72 25 }, 73 26 onOk : function() 74 27 { 75 this.changedAttibutes[ 'type' ] = 'radio'; 28 var editor, 29 element = this._element, 30 isInsertMode = !element; 76 31 77 this.editObj.setAttributes( this.changedAttibutes ); 32 if ( isInsertMode ) 33 { 34 editor = this.getParentEditor(); 35 element = editor.document.createElement( 'input' ); 36 element.setAttribute( 'type', 'radio' ); 37 } 38 this.commitContent( element ); 78 39 79 if ( this.editMode == false )40 if ( isInsertMode ) 80 41 { 81 // It doesn't work with IE.82 42 this.restoreSelection(); 83 43 this.clearSavedSelection(); 84 editor.insertElement( this.editObj);44 editor.insertElement( element ); 85 45 } 86 return true;87 46 }, 88 47 contents : [ 89 48 { … … 98 57 label : editor.lang.common.name, 99 58 'default' : '', 100 59 accessKey : 'N', 101 validate: function()60 setup : function( element ) 102 61 { 103 addChange( 'name', this ); 104 return true; 62 this.setValue( element.getAttribute( 'name' ) ); 63 }, 64 commit : function( element ) 65 { 66 element.setAttribute( 'name', this.getValue() ); 105 67 } 106 68 }, 107 69 { … … 110 72 label : editor.lang.checkboxAndRadio.value, 111 73 'default' : '', 112 74 accessKey : 'V', 113 validate: function()75 setup : function( element ) 114 76 { 115 addChange( 'value', this ); 116 return true; 77 this.setValue( element.getAttribute( 'value' ) ); 78 }, 79 commit : function( element ) 80 { 81 element.setAttribute( 'value', this.getValue() ); 117 82 } 118 83 }, 119 84 { … … 121 86 type : 'checkbox', 122 87 label : editor.lang.checkboxAndRadio.selected, 123 88 'default' : '', 124 accessKey : 'S', 89 accessKey : 'S', 125 90 value : "checked", 126 validate: function()91 setup : function( element ) 127 92 { 128 addChange( 'checked', this ); 129 return true; 130 } 93 this.setValue( element.getAttribute( 'checked' ) ); 94 }, 95 commit : function( element ) 96 { 97 element.setAttribute( 'checked', this.getValue() ); 98 } 99 131 100 } 132 101 ] 133 102 } -
textarea.js
4 4 */ 5 5 CKEDITOR.dialog.add( 'textarea', function( editor ) 6 6 { 7 var addChange = function( name, input ){8 var dialog = input.getDialog();9 if ( input.isChanged() || ( dialog.editMode == false && input.getValue() != '' ))10 {11 dialog.changedAttibutes[ name ] = input.getValue();12 return true;13 }14 return false;15 };16 17 // Function called in onShow to load selected element.18 var loadSelection = function( editor, selection, ranges, element )19 {20 this.saveSelection();21 this.editObj = element;22 this.editMode = true;23 24 // Fill out all fields.25 readAttribute.apply( this, [ 'info', 'name', 'txtName' ] );26 readAttribute.apply( this, [ 'info', 'cols', 'txtColumns' ] );27 readAttribute.apply( this, [ 'info', 'rows', 'txtRows' ] );28 29 return false;30 };31 32 var readAttribute = function( page, attribute, input )33 {34 var attributeValue = this.editObj.getAttribute( attribute );35 this.setValueOf( page, input, attributeValue );36 37 return attributeValue;38 }39 40 7 return { 41 8 title : editor.lang.textarea.title, 42 resizable : CKEDITOR.DIALOG_RESIZE_NONE,43 9 minWidth : 400, 44 10 minHeight : 230, 45 11 onShow : function() 46 12 { 47 // Default: create a new element. 48 this.editMode = false; 49 50 // IE BUG: Selection must be in the editor for getSelection() to work. 13 // IE BUG: Selection must be in the editor for getSelectedElement() 14 // to work. 51 15 this.restoreSelection(); 52 16 53 var editor = this.getParentEditor(), 54 selection = editor.getSelection(), 55 ranges = selection.getRanges(); 56 57 // Check selection. Fill in all the relevant fields if there's already one link selected. 58 if ( ranges.length == 1 ) 17 var element = this.getParentEditor().getSelection().getSelectedElement(); 18 if ( element && element.getName() == "textarea" ) 59 19 { 60 ranges[0].enlarge( CKEDITOR.ENLARGE_ELEMENT ); 61 62 var rangeRoot = ranges[0].getCommonAncestor( true ); 63 var element = rangeRoot.getAscendant( 'textarea', true ); 64 if ( element ) 65 { 66 loadSelection.apply( this, [ editor, selection, ranges, element ] ); 67 selection.selectElement( element ); 68 } 20 this._element = element; 21 this.setupContent( element ); 69 22 } 70 23 71 if ( this.editMode == false ) //New object.72 this.editObj = editor.document.createElement( 'textarea' );73 74 24 this.getContentElement( 'info', 'txtName' ).focus(); 75 this.changedAttibutes = new Array();76 25 }, 77 26 onOk : function() 78 27 { 79 this.editObj.setAttributes( this.changedAttibutes ); 28 var editor, 29 element = this._element, 30 isInsertMode = !element; 80 31 81 if ( this.editMode == false )32 if ( isInsertMode ) 82 33 { 34 editor = this.getParentEditor(); 35 element = editor.document.createElement( 'textarea' ); 36 } 37 this.commitContent( element ); 38 39 if ( isInsertMode ) 40 { 83 41 this.restoreSelection(); 84 42 this.clearSavedSelection(); 85 editor.insertElement( this.editObj);43 editor.insertElement( element ); 86 44 } 87 return true;88 45 }, 89 46 contents : [ 90 47 { … … 99 56 label : editor.lang.common.name, 100 57 'default' : '', 101 58 accessKey : 'N', 102 validate: function()59 setup : function( element ) 103 60 { 104 addChange( 'name', this ); 105 return true; 61 this.setValue( element.getAttribute( 'name' ) ); 62 }, 63 commit : function( element ) 64 { 65 element.setAttribute( 'name', this.getValue() ); 106 66 } 107 67 }, 108 68 { … … 115 75 validate: function() 116 76 { 117 77 var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ); 118 var isValid = func.apply( this ); 119 if ( isValid ) 120 addChange( 'cols', this ); 121 return isValid; 78 return func.apply( this ); 79 }, 80 setup : function( element ) 81 { 82 this.setValue( element.getAttribute( 'cols' ) ); 83 }, 84 commit : function( element ) 85 { 86 element.setAttribute( 'cols', this.getValue() ); 122 87 } 123 88 }, 124 89 { … … 131 96 validate: function() 132 97 { 133 98 var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ); 134 var isValid = func.apply( this ); 135 if ( isValid ) 136 addChange( 'rows', this ); 137 return isValid; 99 return func.apply( this ); 100 }, 101 setup : function( element ) 102 { 103 this.setValue( element.getAttribute( 'rows' ) ); 104 }, 105 commit : function( element ) 106 { 107 element.setAttribute( 'rows', this.getValue() ); 138 108 } 139 109 } 140 110 ] -
textfield.js
4 4 */ 5 5 CKEDITOR.dialog.add( 'textfield', function( editor ) 6 6 { 7 var addChange = function( name, input ){8 var dialog = input.getDialog();9 if ( input.isChanged() || ( dialog.editMode == false && input.getValue() != '' ))10 {11 dialog.changedAttibutes[ name ] = input.getValue();12 return true;13 }14 return false;15 };16 17 // Function called in onShow to load selected element.18 var loadSelection = function( editor, selection, ranges, element )19 {20 this.saveSelection();21 this.editObj = element;22 this.editMode = true;23 24 // Fill out all fields.25 readAttribute.apply( this, [ 'info', 'name', 'txtName' ] );26 readAttribute.apply( this, [ 'info', 'value', 'txtValue' ] );27 readAttribute.apply( this, [ 'info', 'type', 'cmbType' ] );28 readAttribute.apply( this, [ 'info', 'width', 'txtTextCharWidth' ] );29 readAttribute.apply( this, [ 'info', 'maxlength', 'txtMaxChars' ] );30 31 return false;32 };33 34 var readAttribute = function( page, attribute, input )35 {36 var attributeValue = this.editObj.getAttribute( attribute );37 this.setValueOf( page, input, attributeValue );38 39 return attributeValue;40 }41 7 return { 42 8 title : editor.lang.textfield.title, 43 resizable : CKEDITOR.DIALOG_RESIZE_NONE,44 9 minWidth : 400, 45 10 minHeight : 230, 46 47 11 onShow : function() 48 12 { 49 // Default: create a new element. 50 this.editMode = false; 51 52 // IE BUG: Selection must be in the editor for getSelection() to work. 13 // IE BUG: Selection must be in the editor for getSelectedElement() 14 // to work. 53 15 this.restoreSelection(); 54 16 55 var editor = this.getParentEditor(), 56 selection = editor.getSelection(), 57 ranges = selection.getRanges(); 58 59 // Check selection. Fill in all the relevant fields if there's already one link selected. 60 if ( ranges.length == 1 ) 17 var element = this.getParentEditor().getSelection().getSelectedElement(); 18 if ( element && element.getName() == "input" && ( element.getAttribute( 'type' ) == "text" && !element.getAttribute( 'type' ) ) ) 61 19 { 62 ranges[0].enlarge( CKEDITOR.ENLARGE_ELEMENT ); 63 64 var rangeRoot = ranges[0].getCommonAncestor( true ); 65 var element = rangeRoot.getAscendant( 'input', true ); 66 if ( element ) 67 { 68 var type = element.getAttribute( 'type' ); 69 if ( type == "text" || type == null ) 70 { 71 loadSelection.apply( this, [ editor, selection, ranges, element ] ); 72 selection.selectElement( element ); 73 } 74 } 20 this._element = element; 21 this.setupContent( element ); 75 22 } 76 23 77 if ( this.editMode == false ) //New object.78 this.editObj = editor.document.createElement( 'input' );79 80 24 this.getContentElement( 'info', 'txtName' ).focus(); 81 this.changedAttibutes = new Array();82 25 }, 83 26 onOk : function() 84 27 { 85 this.editObj.setAttributes( this.changedAttibutes ); 28 var editor, 29 element = this._element, 30 isInsertMode = !element; 86 31 87 if ( this.editMode == false )32 if ( isInsertMode ) 88 33 { 34 editor = this.getParentEditor(); 35 element = editor.document.createElement( 'textarea' ); 36 element.setAttribute( 'type', 'text' ); 37 } 38 this.commitContent( element ); 39 40 if ( isInsertMode ) 41 { 89 42 this.restoreSelection(); 90 43 this.clearSavedSelection(); 91 editor.insertElement( this.editObj);44 editor.insertElement( element ); 92 45 } 93 return true;94 46 }, 95 47 contents : [ 96 48 { … … 110 62 label : editor.lang.textfield.name, 111 63 'default' : '', 112 64 accessKey : 'N', 113 validate: function()65 setup : function( element ) 114 66 { 115 addChange( 'name', this ); 116 return true; 67 this.setValue( element.getAttribute( 'name' ) ); 68 }, 69 commit : function( element ) 70 { 71 element.setAttribute( 'name', this.getValue() ); 117 72 } 118 73 }, 119 74 { … … 122 77 label : editor.lang.textfield.value, 123 78 'default' : '', 124 79 accessKey : 'V', 125 validate: function()80 setup : function( element ) 126 81 { 127 addChange( 'value', this ); 128 return true; 82 this.setValue( element.getAttribute( 'value' ) ); 83 }, 84 commit : function( element ) 85 { 86 element.setAttribute( 'value', this.getValue() ); 129 87 } 130 88 } 131 89 ] … … 145 103 validate: function() 146 104 { 147 105 var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ); 148 var isValid = func.apply( this ); 149 if ( isValid ) 150 addChange( 'width', this ); 151 return isValid; 106 return isValid = func.apply( this ); 107 }, 108 setup : function( element ) 109 { 110 this.setValue( element.getAttribute( 'value' ) ); 111 }, 112 commit : function( element ) 113 { 114 element.setAttribute( 'value', this.getValue() ); 152 115 } 153 116 }, 154 117 { … … 161 124 validate: function() 162 125 { 163 126 var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ); 164 var isValid = func.apply( this ); 165 if ( isValid ) 166 addChange( 'maxlength', this ); 167 return isValid; 127 return isValid = func.apply( this ); 128 }, 129 setup : function( element ) 130 { 131 this.setValue( element.getAttribute( 'maxlength' ) ); 132 }, 133 commit : function( element ) 134 { 135 element.setAttribute( 'maxlength', this.getValue() ); 168 136 } 169 137 } 170 138 ] … … 180 148 [ editor.lang.textfield.typeText, 'text' ], 181 149 [ editor.lang.textfield.typePass, 'pass' ], 182 150 ], 183 validate: function()151 setup : function( element ) 184 152 { 185 addChange( 'type', this ); 186 return true; 153 this.setValue( element.getAttribute( 'type' ) ); 154 }, 155 commit : function( element ) 156 { 157 element.setAttribute( 'type', this.getValue() ); 187 158 } 188 159 } 189 160 ]