Ticket #2820: 2820_3.patch
| File 2820_3.patch, 46.6 KB (added by , 17 years ago) |
|---|
-
_source/core/config.js
146 146 * @example 147 147 * config.plugins = 'basicstyles,button,htmldataprocessor,toolbar,wysiwygarea'; 148 148 */ 149 plugins : 'basicstyles,button,elementspath, horizontalrule,htmldataprocessor,keystrokes,newpage,pagebreak,removeformat,smiley,sourcearea,specialchar,tab,toolbar,wysiwygarea',149 plugins : 'basicstyles,button,elementspath,forms,horizontalrule,htmldataprocessor,keystrokes,newpage,pagebreak,removeformat,smiley,sourcearea,specialchar,tab,toolbar,wysiwygarea', 150 150 151 151 /** 152 152 * The theme to be used to build the UI. -
_source/plugins/forms/dialogs/button.js
1 /* 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 CKEDITOR.dialog.add( 'button', function( editor ) 6 { 7 return { 8 title : editor.lang.button.title, 9 minWidth : 400, 10 minHeight : 230, 11 onShow : function() 12 { 13 // IE BUG: Selection must be in the editor for getSelectedElement() 14 // to work. 15 this.restoreSelection(); 16 17 var element = this.getParentEditor().getSelection().getSelectedElement(); 18 if ( element && element.getName() == "input" ) 19 { 20 var type = element.getAttribute( 'type' ); 21 if ( type == "button" || type == "reset" || type == "submit" ) 22 { 23 this._element = element; 24 this.setupContent( element ); 25 } 26 } 27 }, 28 onOk : function() 29 { 30 var editor, 31 element = this._element, 32 isInsertMode = !element; 33 34 if ( isInsertMode ) 35 { 36 editor = this.getParentEditor(); 37 element = editor.document.createElement( 'input' ); 38 } 39 this.commitContent( element ); 40 41 if ( isInsertMode ) 42 { 43 this.restoreSelection(); 44 this.clearSavedSelection(); 45 editor.insertElement( element ); 46 } 47 }, 48 contents : [ 49 { 50 id : 'info', 51 label : editor.lang.button.title, 52 title : editor.lang.button.title, 53 accessKey : 'I', 54 elements : [ 55 { 56 id : 'txtName', 57 type : 'text', 58 label : editor.lang.common.name, 59 'default' : '', 60 setup : function( element ) 61 { 62 this.setValue( element.getAttribute( 'name' ) ); 63 this.focus(); 64 }, 65 commit : function( element ) 66 { 67 if ( this.getValue() != '' || this.isChanged() ) 68 element.setAttribute( 'name', this.getValue() ); 69 } 70 }, 71 { 72 id : 'txtValue', 73 type : 'text', 74 label : editor.lang.button.text, 75 accessKey : 'V', 76 'default' : '', 77 setup : function( element ) 78 { 79 this.setValue( element.getAttribute( 'value' ) ); 80 }, 81 commit : function( element ) 82 { 83 if ( this.getValue() != '' || this.isChanged() ) 84 element.setAttribute( 'value', this.getValue() ); 85 } 86 }, 87 { 88 id : 'txtType', 89 type : 'select', 90 label : editor.lang.button.type, 91 'default' : 'button', 92 accessKey : 'T', 93 items : 94 [ 95 [ editor.lang.button.typeBtn, 'button' ], 96 [ editor.lang.button.typeSbm, 'submit' ], 97 [ editor.lang.button.typeRst, 'reset' ] 98 ], 99 setup : function( element ) 100 { 101 this.setValue( element.getAttribute( 'type' ) ); 102 }, 103 commit : function( element ) 104 { 105 element.setAttribute( 'type', this.getValue() ); 106 } 107 } 108 ] 109 } 110 ] 111 }; 112 }); -
_source/plugins/forms/dialogs/checkbox.js
1 /* 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 CKEDITOR.dialog.add( 'checkbox', function( editor ) 6 { 7 return { 8 title : editor.lang.checkboxAndRadio.checkboxTitle, 9 minWidth : 400, 10 minHeight : 230, 11 onShow : function() 12 { 13 // IE BUG: Selection must be in the editor for getSelectedElement() 14 // to work. 15 this.restoreSelection(); 16 17 var element = this.getParentEditor().getSelection().getSelectedElement(); 18 19 if ( element && element.getAttribute( 'type' ) == "checkbox" ) 20 { 21 this._element = element; 22 this.setupContent( element ); 23 } 24 }, 25 onOk : function() 26 { 27 var editor, 28 element = this._element, 29 isInsertMode = !element; 30 31 if ( isInsertMode ) 32 { 33 editor = this.getParentEditor(); 34 element = editor.document.createElement( 'input' ); 35 element.setAttribute( 'type', 'checkbox' ); 36 } 37 38 this.commitContent( element ); 39 40 if ( isInsertMode ) 41 { 42 this.restoreSelection(); 43 this.clearSavedSelection(); 44 editor.insertElement( element ); 45 } 46 }, 47 contents : [ 48 { 49 id : 'info', 50 label : editor.lang.checkboxAndRadio.checkboxTitle, 51 title : editor.lang.checkboxAndRadio.checkboxTitle, 52 accessKey : 'I', 53 startupFocus : 'txtName', 54 elements : [ 55 { 56 id : 'txtName', 57 type : 'text', 58 label : editor.lang.common.name, 59 'default' : '', 60 accessKey : 'N', 61 setup : function( element ) 62 { 63 this.setValue( element.getAttribute( 'name' ) ); 64 this.focus(); 65 }, 66 commit : function( element ) 67 { 68 if ( this.getValue() != '' || this.isChanged() ) 69 element.setAttribute( 'name', this.getValue() ); 70 } 71 }, 72 { 73 id : 'txtValue', 74 type : 'text', 75 label : editor.lang.checkboxAndRadio.value, 76 'default' : '', 77 accessKey : 'V', 78 setup : function( element ) 79 { 80 this.setValue( element.getAttribute( 'value' ) ); 81 }, 82 commit : function( element ) 83 { 84 if ( this.getValue() != '' || this.isChanged() ) 85 element.setAttribute( 'value', this.getValue() ); 86 } 87 }, 88 { 89 id : 'cmbSelected', 90 type : 'checkbox', 91 label : editor.lang.checkboxAndRadio.selected, 92 'default' : '', 93 accessKey : 'S', 94 value : "checked", 95 setup : function( element ) 96 { 97 this.setValue( element.getAttribute( 'checked' ) ); 98 }, 99 commit : function( element ) 100 { 101 if ( this.getValue() == true || this.isChanged() ) 102 element.setAttribute( 'checked', this.getValue() ); 103 } 104 } 105 ] 106 } 107 ] 108 }; 109 }); -
_source/plugins/forms/dialogs/form.js
1 /* 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 CKEDITOR.dialog.add( 'form', function( editor ) 6 { 7 return { 8 title : editor.lang.form.title, 9 minWidth : 400, 10 minHeight : 270, 11 onShow : function() 12 { 13 // IE BUG: Selection must be in the editor for getSelectedElement() 14 // to work. 15 this.restoreSelection(); 16 17 var element = this.getParentEditor().getSelection().getSelectedElement(); 18 if ( element && element.getName() == "form" ) 19 { 20 this._element = element; 21 this.setupContent( element ); 22 } 23 24 this.getContentElement( 'info', 'txtName' ).focus(); 25 }, 26 onOk : function() 27 { 28 var editor, 29 element = this._element, 30 isInsertMode = !element; 31 32 if ( isInsertMode ) 33 { 34 editor = this.getParentEditor(); 35 element = editor.document.createElement( 'form' ); 36 } 37 this.commitContent( element ); 38 39 if ( isInsertMode ) 40 { 41 this.restoreSelection(); 42 this.clearSavedSelection(); 43 editor.insertElement( element ); 44 } 45 }, 46 contents : [ 47 { 48 id : 'info', 49 label : editor.lang.form.title, 50 title : editor.lang.form.title, 51 accessKey : 'I', 52 elements : [ 53 { 54 id : 'txtName', 55 type : 'text', 56 label : editor.lang.common.name, 57 'default' : '', 58 accessKey : 'N', 59 setup : function( element ) 60 { 61 this.setValue( element.getAttribute( 'name' ) ); 62 this.focus(); 63 }, 64 commit : function( element ) 65 { 66 if ( this.getValue() != '' || this.isChanged() ) 67 element.setAttribute( 'name', this.getValue() ); 68 } 69 }, 70 { 71 id : 'txtAction', 72 type : 'text', 73 label : editor.lang.form.action, 74 'default' : '', 75 accessKey : 'A', 76 setup : function( element ) 77 { 78 this.setValue( element.getAttribute( 'action' ) ); 79 }, 80 commit : function( element ) 81 { 82 if ( this.getValue() != '' || this.isChanged() ) 83 element.setAttribute( 'action', this.getValue() ); 84 } 85 }, 86 { 87 type : 'hbox', 88 widths : [ '45%', '55%' ], 89 children : 90 [ 91 { 92 id : 'txtId', 93 type : 'text', 94 label : editor.lang.common.id, 95 'default' : '', 96 accessKey : 'I', 97 setup : function( element ) 98 { 99 this.setValue( element.getAttribute( 'id' ) ); 100 }, 101 commit : function( element ) 102 { 103 if ( this.getValue() != '' || this.isChanged() ) 104 element.setAttribute( 'id', this.getValue() ); 105 } 106 }, 107 { 108 id : 'cmbEncoding', 109 type : 'select', 110 label : editor.lang.form.encoding, 111 style : 'width:100%', 112 accessKey : 'E', 113 'default' : '', 114 items : 115 [ 116 [ '' ], 117 [ 'text/plain' ], 118 [ 'multipart/form-data' ], 119 [ 'application/x-www-form-urlencoded' ] 120 ], 121 setup : function( element ) 122 { 123 this.setValue( element.getAttribute( 'encoding' ) ); 124 }, 125 commit : function( element ) 126 { 127 if ( this.getValue() != '' || this.isChanged() ) 128 element.setAttribute( 'encoding', this.getValue() ); 129 } 130 } 131 ] 132 }, 133 { 134 type : 'hbox', 135 widths : [ '45%', '55%' ], 136 children : 137 [ 138 { 139 id : 'cmbTarget', 140 type : 'select', 141 label : editor.lang.form.target, 142 style : 'width:100%', 143 accessKey : 'M', 144 'default' : '', 145 items : 146 [ 147 [ editor.lang.form.targetNotSet, '' ], 148 [ editor.lang.form.targetNew, '_blank' ], 149 [ editor.lang.form.targetTop, '_top' ], 150 [ editor.lang.form.targetSelf, '_self' ], 151 [ editor.lang.form.targetParent, '_parent' ] 152 ], 153 setup : function( element ) 154 { 155 this.setValue( element.getAttribute( 'target' ) ); 156 }, 157 commit : function( element ) 158 { 159 if ( this.getValue() != '' || this.isChanged() ) 160 element.setAttribute( 'target', this.getValue() ); 161 } 162 }, 163 { 164 id : 'cmbMethod', 165 type : 'select', 166 label : editor.lang.form.method, 167 accessKey : 'M', 168 'default' : 'GET', 169 items : 170 [ 171 [ 'GET', 'get' ], 172 [ 'POST', 'post' ] 173 ], 174 setup : function( element ) 175 { 176 this.setValue( element.getAttribute( 'method' ) ); 177 }, 178 commit : function( element ) 179 { 180 element.setAttribute( 'method', this.getValue() ); 181 } 182 } 183 ] 184 } 185 ] 186 } 187 ] 188 }; 189 }); -
_source/plugins/forms/dialogs/hiddenfield.js
1 /* 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 CKEDITOR.dialog.add( 'hiddenfield', function( editor ) 6 { 7 return { 8 title : editor.lang.hidden.title, 9 minWidth : 400, 10 minHeight : 200, 11 onShow : function() 12 { 13 // IE BUG: Selection must be in the editor for getSelectedElement() 14 // to work. 15 this.restoreSelection(); 16 17 var element = this.getParentEditor().getSelection().getSelectedElement(); 18 if ( element && element.getName() == "input" && element.getAttribute( 'type' ) == "checkbox" ) 19 { 20 this._element = element; 21 this.setupContent( element ); 22 } 23 }, 24 onOk : function() 25 { 26 var editor, 27 element = this._element, 28 isInsertMode = !element; 29 30 if ( isInsertMode ) 31 { 32 editor = this.getParentEditor(); 33 element = editor.document.createElement( 'input' ); 34 element.setAttribute( 'type', 'hidden' ); 35 } 36 this.commitContent( element ); 37 38 if ( isInsertMode ) 39 { 40 this.restoreSelection(); 41 this.clearSavedSelection(); 42 editor.insertElement( element ); 43 } 44 }, 45 contents : [ 46 { 47 id : 'info', 48 label : editor.lang.hidden.title, 49 title : editor.lang.hidden.title, 50 accessKey : 'I', 51 elements : [ 52 { 53 id : 'txtName', 54 type : 'text', 55 label : editor.lang.hidden.name, 56 'default' : '', 57 accessKey : 'N', 58 setup : function( element ) 59 { 60 this.setValue( element.getAttribute( 'name' ) ); 61 this.focus(); 62 }, 63 commit : function( element ) 64 { 65 if ( this.getValue() != '' || this.isChanged() ) 66 element.setAttribute( 'name', this.getValue() ); 67 } 68 }, 69 { 70 id : 'txtValue', 71 type : 'text', 72 label : editor.lang.hidden.value, 73 'default' : '', 74 accessKey : 'V', 75 setup : function( element ) 76 { 77 this.setValue( element.getAttribute( 'value' ) ); 78 }, 79 commit : function( element ) 80 { 81 if ( this.getValue() != '' || this.isChanged() ) 82 element.setAttribute( 'value', this.getValue() ); 83 } 84 } 85 ] 86 } 87 ] 88 }; 89 }); -
_source/plugins/forms/dialogs/radio.js
1 /* 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 CKEDITOR.dialog.add( 'radio', function( editor ) 6 { 7 return { 8 title : editor.lang.checkboxAndRadio.radioTitle, 9 minWidth : 400, 10 minHeight : 200, 11 onShow : function() 12 { 13 // IE BUG: Selection must be in the editor for getSelectedElement() 14 // to work. 15 this.restoreSelection(); 16 17 var element = this.getParentEditor().getSelection().getSelectedElement(); 18 if ( element && element.getName() == "input" && element.getAttribute( 'type' ) == "radio" ) 19 { 20 this._element = element; 21 this.setupContent( element ); 22 } 23 }, 24 onOk : function() 25 { 26 var editor, 27 element = this._element, 28 isInsertMode = !element; 29 30 if ( isInsertMode ) 31 { 32 editor = this.getParentEditor(); 33 element = editor.document.createElement( 'input' ); 34 element.setAttribute( 'type', 'radio' ); 35 } 36 this.commitContent( element ); 37 38 if ( isInsertMode ) 39 { 40 this.restoreSelection(); 41 this.clearSavedSelection(); 42 editor.insertElement( element ); 43 } 44 }, 45 contents : [ 46 { 47 id : 'info', 48 label : editor.lang.checkboxAndRadio.radioTitle, 49 title : editor.lang.checkboxAndRadio.radioTitle, 50 accessKey : 'I', 51 elements : [ 52 { 53 id : 'txtName', 54 type : 'text', 55 label : editor.lang.common.name, 56 'default' : '', 57 accessKey : 'N', 58 setup : function( element ) 59 { 60 this.setValue( element.getAttribute( 'name' ) ); 61 this.focus(); 62 }, 63 commit : function( element ) 64 { 65 if ( this.getValue() != '' || this.isChanged() ) 66 element.setAttribute( 'name', this.getValue() ); 67 } 68 }, 69 { 70 id : 'txtValue', 71 type : 'text', 72 label : editor.lang.checkboxAndRadio.value, 73 'default' : '', 74 accessKey : 'V', 75 setup : function( element ) 76 { 77 this.setValue( element.getAttribute( 'value' ) ); 78 }, 79 commit : function( element ) 80 { 81 if ( this.getValue() != '' || this.isChanged() ) 82 element.setAttribute( 'value', this.getValue() ); 83 } 84 }, 85 { 86 id : 'cmbSelected', 87 type : 'checkbox', 88 label : editor.lang.checkboxAndRadio.selected, 89 'default' : '', 90 accessKey : 'S', 91 value : "checked", 92 setup : function( element ) 93 { 94 this.setValue( element.getAttribute( 'checked' ) ); 95 }, 96 commit : function( element ) 97 { 98 if ( this.getValue() == true || this.isChanged() ) 99 element.setAttribute( 'checked', this.getValue() ); 100 } 101 } 102 ] 103 } 104 ] 105 }; 106 }); -
_source/plugins/forms/dialogs/select.js
1 /* 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 CKEDITOR.dialog.add( 'select', function( editor ) 6 { 7 var plugin = CKEDITOR.plugins.forms.select; 8 return { 9 title : editor.lang.select.title, 10 minWidth : 400, 11 minHeight : 370, 12 onShow : function() 13 { 14 // IE BUG: Selection must be in the editor for getSelectedElement() 15 // to work. 16 this.restoreSelection(); 17 18 this.setupContent( 'clear' ); 19 var element = this.getParentEditor().getSelection().getSelectedElement(); 20 if ( element && element.getName() == "select" ) 21 { 22 this._element = element; 23 this.setupContent( element.getName(), element ); 24 25 //Load Options into dialog. 26 var objOptions = plugin.getOptions( element ); 27 for ( var i = 0 ; i < objOptions.length ; i++ ) 28 this.setupContent( objOptions[i].getName(), objOptions[i] ); 29 } 30 }, 31 onOk : function() 32 { 33 var editor = this.getParentEditor(), 34 element = this._element, 35 isInsertMode = !element; 36 37 if ( isInsertMode ) 38 element = editor.document.createElement( 'select' ); 39 this.commitContent( element ); 40 41 if ( isInsertMode ) 42 { 43 this.restoreSelection(); 44 this.clearSavedSelection(); 45 editor.insertElement( element ); 46 } 47 }, 48 contents : [ 49 { 50 id : 'info', 51 label : editor.lang.select.selectInfo, 52 title : editor.lang.select.selectInfo, 53 accessKey : '', 54 elements : [ 55 { 56 id : 'txtName', 57 type : 'text', 58 widths : [ '25%','75%' ], 59 labelLayout : 'horizontal', 60 label : editor.lang.common.name, 61 'default' : '', 62 accessKey : 'N', 63 align : 'center', 64 style : 'width:350px', 65 setup : function( name, element ) 66 { 67 if ( name == 'select' ) 68 { 69 this.setValue( element.getAttribute( 'name' ) ); 70 this.focus(); 71 } 72 }, 73 commit : function( element ) 74 { 75 if ( this.getValue() != '' || this.isChanged() ) 76 element.setAttribute( 'name', this.getValue() ); 77 } 78 }, 79 { 80 id : 'txtValue', 81 type : 'text', 82 widths : [ '25%','75%' ], 83 labelLayout : 'horizontal', 84 label : editor.lang.select.value, 85 style : 'width:350px', 86 'default' : '', 87 readonly : true, //TODO: make it readonly somehow. 88 disabled : true 89 }, 90 { 91 type : 'hbox', 92 widths : [ '175px', '170px' ], 93 align : 'center', 94 children : 95 [ 96 { 97 id : 'txtSize', 98 type : 'text', 99 align : 'center', 100 labelLayout : 'horizontal', 101 label : editor.lang.select.size, 102 'default' : '', 103 accessKey : 'S', 104 style : 'width:175px', 105 validate: function() 106 { 107 var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ); 108 return ( ( this.getValue() == '' ) || func.apply( this ) ); 109 }, 110 setup : function( name, element ) 111 { 112 if ( name == 'select' ) 113 this.setValue( element.getAttribute( 'size' ) ); 114 }, 115 commit : function( element ) 116 { 117 if ( this.getValue() != '' || this.isChanged() ) 118 element.setAttribute( 'size', this.getValue() ); 119 } 120 }, 121 { 122 type : 'html', 123 html : '<span>' + CKEDITOR.tools.htmlEncode( editor.lang.select.lines ) + '</span>' 124 } 125 ] 126 }, 127 { 128 type : 'html', 129 html : '<span>' + CKEDITOR.tools.htmlEncode( editor.lang.select.opAvail ) + '</span>' 130 }, 131 { 132 type : 'hbox', 133 widths : [ '35%', '35%' ,'30%' ], 134 padding : 2, 135 align : 'top', 136 children : 137 [ 138 { 139 type : 'vbox', 140 padding : 0, 141 children : 142 [ 143 { 144 id : 'txtOptName', 145 type : 'text', 146 label : editor.lang.select.opText, 147 style : 'width:100%;margin-bottom:10px' 148 }, 149 { 150 type : 'select', 151 id : 'cmbName', 152 label : '', 153 title : '', 154 size : 5, 155 style : 'width:100%; height:75px; margin-bottom:5px', 156 items : [], 157 onChange : function() 158 { 159 var dialog = this.getDialog(), 160 values = dialog.getContentElement( 'info', 'cmbValue' ), 161 optName = dialog.getContentElement( 'info', 'txtOptName' ), 162 optValue = dialog.getContentElement( 'info', 'txtOptValue' ), 163 iIndex = plugin.getSelectedIndex( this ); 164 165 plugin.setSelectedIndex( values, iIndex ); 166 optName.setValue( this.getValue() ); 167 optValue.setValue( values.getValue() ); 168 }, 169 setup : function( name, element ) 170 { 171 if ( name == 'clear' ) 172 plugin.removeAllOptions( this ); 173 else if ( name == 'option' ) 174 plugin.addOption( this, element.innerHTML, element.innerHTML, 175 this.getDialog.getParentEditor().document ); 176 }, 177 commit : function( element ) 178 { 179 var dialog = this.getDialog(), 180 optionsNames = plugin.getOptions( this ), 181 optionsValues = plugin.getOptions( 182 dialog.getContentElement( 'info', 'cmbValue' ) ), 183 selectValue = dialog.getContentElement( 'info', 'txtValue' ); 184 185 plugin.removeAllOptions( element ); 186 187 for ( var i = 0 ; i < optionsNames.length ; i++ ) 188 { 189 var oOption = plugin.addOption( element, optionsNames[i].value, 190 optionsValues[i].value, dialog.getParentEditor().document ); 191 if ( optionsValues == selectValue ) 192 { 193 oOption.setAttribute( 'selected', 'selected' ); 194 oOption.selected = true; 195 } 196 } 197 } 198 } 199 ] 200 }, 201 { 202 type : 'vbox', 203 padding : 0, 204 children : 205 [ 206 { 207 id : 'txtOptValue', 208 type : 'text', 209 label : editor.lang.select.opValue, 210 style : 'width:100%;margin-bottom:10px;' 211 }, 212 { 213 type : 'select', 214 id : 'cmbValue', 215 label : '', 216 size : 5, 217 style : 'width:100%; height:75px;margin-bottom:5px', 218 items : [], 219 onChange : function() 220 { 221 var dialog = this.getDialog(), 222 names = dialog.getContentElement( 'info', 'cmbName' ), 223 optName = dialog.getContentElement( 'info', 'txtOptName' ), 224 optValue = dialog.getContentElement( 'info', 'txtOptValue' ), 225 iIndex = plugin.getSelectedIndex( this ); 226 227 plugin.setSelectedIndex( names, iIndex ); 228 optName.setValue( names.getValue() ); 229 optValue.setValue( this.getValue() ); 230 }, 231 setup : function( name, element ) 232 { 233 if ( name == 'clear' ) 234 plugin.removeAllOptions( this ); 235 else if ( name == 'option' ) 236 { 237 var oValue = element.value; 238 plugin.addOption( this, oValue, oValue, 239 this.getDialog.getParentEditor().document ); 240 if ( element.getAttribute( 'selected' ) == 'selected' ) 241 this.getDialog().getContentElement( 'info', 'txtValue' ).setValue( oValue ); 242 } 243 } 244 }, 245 ] 246 }, 247 { 248 type : 'vbox', 249 children : 250 [ 251 { 252 type : 'button', 253 style : '', 254 label : editor.lang.select.btnAdd, 255 title : editor.lang.select.btnAdd, 256 style : 'width:100%;', 257 onClick : function() 258 { 259 //Add new option. 260 var dialog = this.getDialog(); 261 parentEditor = dialog.getParentEditor(), 262 optName = dialog.getContentElement( 'info', 'txtOptName' ), 263 optValue = dialog.getContentElement( 'info', 'txtOptValue' ), 264 names = dialog.getContentElement( 'info', 'cmbName' ), 265 values = dialog.getContentElement( 'info', 'cmbValue' ); 266 267 plugin.addOption(names, optName.getValue(), optName.getValue() ); 268 plugin.addOption(values, optValue.getValue(), optValue.getValue() ); 269 270 optName.setValue( "" ); 271 optValue.setValue( "" ); 272 } 273 }, 274 { 275 type : 'button', 276 label : editor.lang.select.btnModify, 277 title : editor.lang.select.btnModify, 278 style : 'width:100%;', 279 onClick : function() 280 { 281 //Modify selected option. 282 var dialog = this.getDialog(); 283 optName = dialog.getContentElement( 'info', 'txtOptName' ), 284 optValue = dialog.getContentElement( 'info', 'txtOptValue' ), 285 names = dialog.getContentElement( 'info', 'cmbName' ), 286 values = dialog.getContentElement( 'info', 'cmbValue' ), 287 iIndex = plugin.getSelectedIndex( names ); 288 289 if ( iIndex >= 0 ) 290 { 291 plugin.modifyOption( names, iIndex, optName.getValue(), optName.getValue() ); 292 plugin.modifyOption( values, iIndex, optValue.getValue(), optValue.getValue() ); 293 } 294 } 295 }, 296 { 297 type : 'button', 298 style : 'width:100%;', 299 label : editor.lang.select.btnUp, 300 title : editor.lang.select.btnUp, 301 onClick : function() 302 { 303 //Move up. 304 var dialog = this.getDialog(), 305 names = dialog.getContentElement( 'info', 'cmbName' ), 306 values = dialog.getContentElement( 'info', 'cmbValue' ); 307 308 plugin.changeOptionPosition( names, -1, dialog.getParentEditor().document ); 309 plugin.changeOptionPosition( values, -1, dialog.getParentEditor().document ); 310 } 311 }, 312 { 313 type : 'button', 314 style : 'width:100%;', 315 label : editor.lang.select.btnDown, 316 title : editor.lang.select.btnDown, 317 onClick : function() 318 { 319 //Move down. 320 var dialog = this.getDialog(), 321 names = dialog.getContentElement( 'info', 'cmbName' ), 322 values = dialog.getContentElement( 'info', 'cmbValue' ); 323 324 plugin.changeOptionPosition( names, 1, dialog.getParentEditor().document ); 325 plugin.changeOptionPosition( values, 1, dialog.getParentEditor().document ); 326 } 327 } 328 ] 329 } 330 ] 331 }, 332 { 333 type : 'hbox', 334 widths : [ '40%', '20%', '40%' ], 335 children : 336 [ 337 { 338 type : 'button', 339 label : editor.lang.select.btnSetValue, 340 title : editor.lang.select.btnSetValue, 341 onClick : function() 342 { 343 //Set as default value. 344 var dialog = this.getDialog(), 345 values = dialog.getContentElement( 'info', 'cmbValue' ), 346 txtValue = dialog.getContentElement( 'info', 'txtValue' ); 347 txtValue.setValue( values.getValue() ); 348 } 349 }, 350 { 351 type : 'button', 352 label : editor.lang.select.btnDelete, 353 title : editor.lang.select.btnDelete, 354 onClick : function() 355 { 356 // Delete option. 357 var dialog = this.getDialog(), 358 names = dialog.getContentElement( 'info', 'cmbName' ), 359 values = dialog.getContentElement( 'info', 'cmbValue' ), 360 optName = dialog.getContentElement( 'info', 'txtOptName' ), 361 optValue = dialog.getContentElement( 'info', 'txtOptValue' ); 362 363 plugin.removeSelectedOptions( names ); 364 plugin.removeSelectedOptions( values ); 365 366 optName.setValue( "" ); 367 optValue.setValue( "" ); 368 } 369 }, 370 { 371 id : 'chkMulti', 372 type : 'checkbox', 373 label : editor.lang.select.chkMulti, 374 'default' : 'url', 375 accessKey : 'M', 376 value : "checked", 377 setup : function( name, element ) 378 { 379 if ( name == 'select' ) 380 this.setValue( element.getAttribute( 'multiple' ) ); 381 }, 382 commit : function( element ) 383 { 384 if ( this.getValue() == true || this.isChanged() ) 385 element.setAttribute( 'multiple', this.getValue() ); 386 } 387 } 388 ] 389 } 390 ] 391 } 392 ] 393 }; 394 }); -
_source/plugins/forms/dialogs/textarea.js
1 /* 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 CKEDITOR.dialog.add( 'textarea', function( editor ) 6 { 7 return { 8 title : editor.lang.textarea.title, 9 minWidth : 400, 10 minHeight : 230, 11 onShow : function() 12 { 13 // IE BUG: Selection must be in the editor for getSelectedElement() 14 // to work. 15 this.restoreSelection(); 16 17 var element = this.getParentEditor().getSelection().getSelectedElement(); 18 if ( element && element.getName() == "textarea" ) 19 { 20 this._element = element; 21 this.setupContent( element ); 22 } 23 }, 24 onOk : function() 25 { 26 var editor, 27 element = this._element, 28 isInsertMode = !element; 29 30 if ( isInsertMode ) 31 { 32 editor = this.getParentEditor(); 33 element = editor.document.createElement( 'textarea' ); 34 } 35 this.commitContent( element ); 36 37 if ( isInsertMode ) 38 { 39 this.restoreSelection(); 40 this.clearSavedSelection(); 41 editor.insertElement( element ); 42 } 43 }, 44 contents : [ 45 { 46 id : 'info', 47 label : editor.lang.textarea.title, 48 title : editor.lang.textarea.title, 49 accessKey : 'I', 50 elements : [ 51 { 52 id : 'txtName', 53 type : 'text', 54 label : editor.lang.common.name, 55 'default' : '', 56 accessKey : 'N', 57 setup : function( element ) 58 { 59 this.setValue( element.getAttribute( 'name' ) ); 60 this.focus(); 61 }, 62 commit : function( element ) 63 { 64 if ( this.getValue() != '' || this.isChanged() ) 65 element.setAttribute( 'name', this.getValue() ); 66 } 67 }, 68 { 69 id : 'txtColumns', 70 type : 'text', 71 label : editor.lang.textarea.cols, 72 'default' : '', 73 accessKey : 'C', 74 style : 'width:50px', 75 validate: function() 76 { 77 var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ); 78 return func.apply( this ); 79 }, 80 setup : function( element ) 81 { 82 this.setValue( element.getAttribute( 'cols' ) ); 83 }, 84 commit : function( element ) 85 { 86 if ( this.getValue() != '' || this.isChanged() ) 87 element.setAttribute( 'cols', this.getValue() ); 88 } 89 }, 90 { 91 id : 'txtRows', 92 type : 'text', 93 label : editor.lang.textarea.rows, 94 'default' : '', 95 accessKey : 'R', 96 style : 'width:50px', 97 validate: function() 98 { 99 var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ); 100 return func.apply( this ); 101 }, 102 setup : function( element ) 103 { 104 this.setValue( element.getAttribute( 'rows' ) ); 105 }, 106 commit : function( element ) 107 { 108 if ( this.getValue() != '' || this.isChanged() ) 109 element.setAttribute( 'rows', this.getValue() ); 110 } 111 } 112 ] 113 } 114 ] 115 }; 116 }); -
_source/plugins/forms/dialogs/textfield.js
1 /* 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 CKEDITOR.dialog.add( 'textfield', function( editor ) 6 { 7 return { 8 title : editor.lang.textfield.title, 9 minWidth : 400, 10 minHeight : 230, 11 onShow : function() 12 { 13 // IE BUG: Selection must be in the editor for getSelectedElement() 14 // to work. 15 this.restoreSelection(); 16 17 var element = this.getParentEditor().getSelection().getSelectedElement(); 18 if ( element && element.getName() == "input" && ( element.getAttribute( 'type' ) == "text" && !element.getAttribute( 'type' ) ) ) 19 { 20 this._element = element; 21 this.setupContent( element ); 22 } 23 }, 24 onOk : function() 25 { 26 var editor, 27 element = this._element, 28 isInsertMode = !element; 29 30 if ( isInsertMode ) 31 { 32 editor = this.getParentEditor(); 33 element = editor.document.createElement( 'input' ); 34 element.setAttribute( 'type', 'text' ); 35 } 36 this.commitContent( element ); 37 38 if ( isInsertMode ) 39 { 40 this.restoreSelection(); 41 this.clearSavedSelection(); 42 editor.insertElement( element ); 43 } 44 }, 45 contents : [ 46 { 47 id : 'info', 48 label : editor.lang.textfield.title, 49 title : editor.lang.textfield.title, 50 accessKey : 'I', 51 elements : [ 52 { 53 type : 'hbox', 54 widths : [ '50%', '50%' ], 55 children : 56 [ 57 { 58 id : 'txtName', 59 type : 'text', 60 label : editor.lang.textfield.name, 61 'default' : '', 62 accessKey : 'N', 63 setup : function( element ) 64 { 65 this.setValue( element.getAttribute( 'name' ) ); 66 this.focus(); 67 }, 68 commit : function( element ) 69 { 70 if ( this.getValue() != '' || this.isChanged() ) 71 element.setAttribute( 'name', this.getValue() ); 72 } 73 }, 74 { 75 id : 'txtValue', 76 type : 'text', 77 label : editor.lang.textfield.value, 78 'default' : '', 79 accessKey : 'V', 80 setup : function( element ) 81 { 82 this.setValue( element.getAttribute( 'value' ) ); 83 }, 84 commit : function( element ) 85 { 86 if ( this.getValue() != '' || this.isChanged() ) 87 element.setAttribute( 'value', this.getValue() ); 88 } 89 } 90 ] 91 }, 92 { 93 type : 'hbox', 94 widths : [ '50%', '50%' ], 95 children : 96 [ 97 { 98 id : 'txtTextCharWidth', 99 type : 'text', 100 label : editor.lang.textfield.charWidth, 101 'default' : '', 102 accessKey : 'C', 103 style : 'width:50px', 104 validate: function() 105 { 106 var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ); 107 return isValid = func.apply( this ); 108 }, 109 setup : function( element ) 110 { 111 this.setValue( element.getAttribute( 'size' ) ); 112 }, 113 commit : function( element ) 114 { 115 if ( this.getValue() != '' || this.isChanged() ) 116 element.setAttribute( 'size', this.getValue() ); 117 } 118 }, 119 { 120 id : 'txtMaxChars', 121 type : 'text', 122 label : editor.lang.textfield.maxChars, 123 'default' : '', 124 accessKey : 'M', 125 style : 'width:50px', 126 validate: function() 127 { 128 var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ); 129 return isValid = func.apply( this ); 130 }, 131 setup : function( element ) 132 { 133 this.setValue( element.getAttribute( 'maxlength' ) ); 134 }, 135 commit : function( element ) 136 { 137 if ( this.getValue() != '' || this.isChanged() ) 138 element.setAttribute( 'maxlength', this.getValue() ); 139 } 140 } 141 ] 142 }, 143 { 144 id : 'cmbType', 145 type : 'select', 146 label : editor.lang.textfield.type, 147 'default' : 'test', 148 accessKey : 'M', 149 items : 150 [ 151 [ editor.lang.textfield.typeText, 'text' ], 152 [ editor.lang.textfield.typePass, 'pass' ], 153 ], 154 setup : function( element ) 155 { 156 this.setValue( element.getAttribute( 'type' ) ); 157 }, 158 commit : function( element ) 159 { 160 element.setAttribute( 'type', this.getValue() ); 161 } 162 } 163 ] 164 } 165 ] 166 }; 167 }); -
_source/plugins/forms/plugin.js
1 /* 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 6 /** 7 * @file Forms Plugin 8 */ 9 10 CKEDITOR.plugins.add( 'forms', 11 { 12 init : function( editor ) 13 { 14 var forms = CKEDITOR.plugins.forms; 15 editor.ui.addButton( 'Form', 16 { 17 label : editor.lang.common.form, 18 command : 'form' 19 }); 20 editor.addCommand( 'form', new CKEDITOR.dialogCommand( 'form' ) ); 21 22 editor.ui.addButton( 'Checkbox', 23 { 24 label : editor.lang.common.checkbox, 25 command : 'checkbox' 26 }); 27 editor.addCommand( 'checkbox', new CKEDITOR.dialogCommand( 'checkbox' ) ); 28 29 editor.ui.addButton( 'Radio', 30 { 31 label : editor.lang.common.radio, 32 command : 'radio' 33 }); 34 editor.addCommand( 'radio', new CKEDITOR.dialogCommand( 'radio' ) ); 35 36 editor.ui.addButton( 'TextField', 37 { 38 label : editor.lang.common.textField, 39 command : 'textfield' 40 }); 41 editor.addCommand( 'textfield', new CKEDITOR.dialogCommand( 'textfield' ) ); 42 43 editor.ui.addButton( 'Textarea', 44 { 45 label : editor.lang.common.textarea, 46 command : 'textarea' 47 }); 48 editor.addCommand( 'textarea', new CKEDITOR.dialogCommand( 'textarea' ) ); 49 50 editor.ui.addButton( 'Select', 51 { 52 label : editor.lang.common.select, 53 command : 'select' 54 }); 55 editor.addCommand( 'select', new CKEDITOR.dialogCommand( 'select' ) ); 56 57 editor.ui.addButton( 'Button', 58 { 59 label : editor.lang.common.button, 60 command : 'button' 61 }); 62 editor.addCommand( 'button', new CKEDITOR.dialogCommand( 'button' ) ); 63 64 editor.ui.addButton( 'ImageButton', 65 { 66 label : editor.lang.common.imageButton, 67 command : 'imagebutton' 68 }); 69 editor.addCommand( 'imagebutton', new CKEDITOR.dialogCommand( 'imagebutton' ) ); 70 71 editor.ui.addButton( 'HiddenField', 72 { 73 label : editor.lang.common.hiddenField, 74 command : 'hiddenfield' 75 }); 76 editor.addCommand( 'hiddenfield', new CKEDITOR.dialogCommand( 'hiddenfield' ) ); 77 78 CKEDITOR.dialog.add( 'form', this.path + 'dialogs/form.js' ); 79 CKEDITOR.dialog.add( 'checkbox', this.path + 'dialogs/checkbox.js' ); 80 CKEDITOR.dialog.add( 'radio', this.path + 'dialogs/radio.js' ); 81 CKEDITOR.dialog.add( 'textfield', this.path + 'dialogs/textfield.js' ); 82 CKEDITOR.dialog.add( 'textarea', this.path + 'dialogs/textarea.js' ); 83 CKEDITOR.dialog.add( 'select', this.path + 'dialogs/select.js' ); 84 CKEDITOR.dialog.add( 'button', this.path + 'dialogs/button.js' ); 85 CKEDITOR.dialog.add( 'hiddenfield', this.path + 'dialogs/hiddenfield.js' ); 86 CKEDITOR.dialog.add( 'imagebutton', CKEDITOR.plugins.getPath('image') + 'dialogs/image.js' ); 87 }, 88 requires : [ 'image' ] 89 } ); 90 91 CKEDITOR.plugins.forms = 92 { 93 select : 94 { 95 // Add a new option to a SELECT object (combo or list). 96 addOption : function( combo, optionText, optionValue, documentObject, index ) 97 { 98 combo = this._getObject( combo, false ); 99 var oOption; 100 if ( documentObject ) 101 oOption = documentObject.createElement( "OPTION" ); 102 else 103 oOption = document.createElement( "OPTION" ); 104 105 oOption = this._getObject( oOption, false ); 106 107 if ( combo && oOption && oOption.getName() == 'option' ) 108 { 109 if ( index != null && index < combo.getChildCount() ) 110 { 111 index = index < 0 ? 0 : index; 112 var indexOpt = combo.getChild( index ); 113 indexOpt.insertBeforeMe( oOption ); //Doesn't work in IE. 114 } 115 else 116 combo.append( oOption ); 117 118 oOption.setText( optionText.length > 0 ? CKEDITOR.tools.htmlEncode( optionText ) : '' ); 119 oOption.setValue( optionValue ); 120 } 121 else 122 return false; 123 124 return oOption; 125 }, 126 127 // Remove all selected options from a SELECT object. 128 removeSelectedOptions : function ( combo ) 129 { 130 combo = this._getObject( combo, true ); 131 132 // Save the selected index 133 var iSelectedIndex = combo.selectedIndex, 134 oOptions = combo.options; 135 136 // Remove all selected options. 137 for ( var i = oOptions.length - 1 ; i >= 0 ; i-- ) 138 if ( oOptions[i].selected ) combo.remove(i); 139 140 // Reset the selection based on the original selected index. 141 if ( combo.options.length > 0 ) 142 { 143 if ( iSelectedIndex >= combo.options.length ) 144 iSelectedIndex = combo.options.length - 1; 145 combo.selectedIndex = iSelectedIndex; 146 } 147 }, 148 149 //Modify option from a SELECT object. 150 modifyOption : function( combo, index, title, value ) 151 { 152 combo = this._getObject( combo, true ); 153 if ( index < 0 ) return ; 154 155 combo.options[ index ].innerHTML = CKEDITOR.tools.htmlEncode( title ) ; 156 combo.options[ index ].value = CKEDITOR.tools.htmlEncode( value ) ; 157 }, 158 removeAllOptions : function( combo ) 159 { 160 combo = this._getObject( combo, true ); 161 while( combo.options.length ) 162 combo.options[0].parentNode.removeChild( combo.options[0] ); 163 }, 164 165 // Moves the selected option by a number of steps (also negative). 166 changeOptionPosition : function ( combo, steps, documentObject ) 167 { 168 combo = this._getObject( combo, false ); 169 var iActualIndex = this.getSelectedIndex( combo ); 170 if ( iActualIndex < 0 ) 171 return false; 172 173 var iFinalIndex = iActualIndex + steps; 174 iFinalIndex = ( iFinalIndex < 0 ) ? 0 : iFinalIndex; 175 176 if ( iFinalIndex >= combo.getChildCount() ) 177 iFinalIndex = combo.getChildCount() - 1; 178 179 if ( iActualIndex == iFinalIndex ) 180 return false; 181 182 var oOption = combo.getChild( iActualIndex ), 183 sText = this._htmlDecode( oOption.getText() ), 184 sValue = this._htmlDecode( oOption.getValue() ); 185 186 oOption.remove(); 187 if ( !documentObject ) 188 documentObject = null; 189 190 oOption = this.addOption( combo, sText, sValue, documentObject, iFinalIndex ); 191 this.setSelectedIndex( combo, iFinalIndex ); 192 return oOption; 193 }, 194 getSelectedIndex : function( combo ) 195 { 196 combo = this._getObject( combo, true ); 197 var iIndex = combo ? combo.selectedIndex : -1; 198 return iIndex; 199 }, 200 setSelectedIndex : function( combo, index ) 201 { 202 combo = this._getObject( combo, true ); 203 if ( index < 0 ) return ; 204 combo.selectedIndex = index; 205 return combo; 206 }, 207 getOptions : function ( combo ) 208 { 209 combo = this._getObject( combo, true ); 210 return combo ? combo.options : false; 211 }, 212 _getObject : function ( obj, getReal ) 213 { 214 if ( obj ) 215 { 216 // Dialog element. 217 if ( obj.domId && obj.getInputElement().$ ) 218 return getReal ? obj.getInputElement().$ : obj.getInputElement(); 219 220 else if ( obj.tagName && ( obj.tagName.toLowerCase() == 'select' || obj.tagName.toLowerCase() == 'option' ) ) 221 return getReal ? obj : new CKEDITOR.dom.element( obj ); 222 223 else if ( obj.$ ) 224 return getReal ? obj.$ : obj; 225 226 return false; 227 } 228 else 229 return false; 230 }, 231 _htmlDecode : function( text ) 232 { 233 if ( !text ) 234 return ''; 235 236 text = text.replace( />/g, '>' ); 237 text = text.replace( /</g, '<' ); 238 text = text.replace( /&/g, '&' ); 239 240 return text; 241 } 242 } 243 } 244 -
_source/plugins/toolbar/plugin.js
211 211 'Bold', 'Italic', 'Underline', 'Strike', '-', 212 212 'Subscript', 'Superscript', '-', 213 213 'SelectAll', 'RemoveFormat', '-', 214 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField', '-', 214 215 'Smiley', 'HorizontalRule', 'SpecialChar', 'PageBreak' 215 216 ] 216 217 ];
