Ticket #2790: 2790.patch
File 2790.patch, 20.0 KB (added by , 15 years ago) |
---|
-
_samples/api_dialog/api_dialog.css
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 .cke_skin_default a.cke_button.cke_button_custom .cke_icon 7 { 8 display: none; 9 } 10 11 .cke_skin_default a.cke_button.cke_button_custom .cke_label 12 { 13 display: inline; 14 } -
_samples/api_dialog/api_dialog.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 (function() 7 { 8 function hook( obj, name, func ) 9 { 10 if ( obj.attachEvent ) 11 return obj.attachEvent( 'on' + name, func ); 12 else 13 return obj.addEventListener( name, func, false ); 14 } 15 16 function init() 17 { 18 CKEDITOR.replace( 'editor1', 19 { 20 plugins : 'basicstyles,button,dialog,elementspath,htmldataprocessor,keystrokes,sourcearea,tab,toolbar,wysiwygarea', 21 toolbar : [ [ 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike', '-', 'Custom' ] ] 22 } ); 23 24 var editor = CKEDITOR.instances.editor1, 25 // This adds a second page and third page after the first. 26 addPages = function( definition ) 27 { 28 definition.addContents( { 29 id : 'tab2', 30 label : 'Second Tab', 31 title : 'Second Tab Title', 32 accessKey : 'W', 33 elements : [ 34 { 35 type : 'hbox', 36 children : [ 37 { 38 type : 'text', 39 label : 'Test Text 4', 40 title : 'Your love is like bad medicine!', 41 id : 'testText4', 42 'default' : 'hello world!', 43 validate : function( dialog ) 44 { 45 var valid = /^[A-Z a-z!]+$/.test( this.getValue() ); 46 if ( !valid ) 47 { 48 this.select(); 49 alert( 'Test Text 4 must only contain alphanumeric characters, space, or ! and must not be empty.' ); 50 } 51 return valid; 52 }, 53 isChanged : false 54 }, 55 56 { 57 type : 'text', 58 label : 'Test Text 5', 59 id : 'testText5', 60 'default' : 'Wheee' 61 }, 62 63 { 64 type : 'text', 65 label : 'Test Text 6', 66 onChange : function(){ console.log( this.getValue() ); }, 67 id : 'testText6', 68 'default' : 'Blah blah' 69 } 70 ] 71 } 72 ] 73 } ); 74 definition.addContents( { 75 id : 'tab3', 76 label : 'Third Tab', 77 title : 'Third Tab Title', 78 accessKey : 'E', 79 elements : [ 80 { 81 type : 'vbox', 82 children : [ 83 { 84 type : 'checkbox', 85 label : 'Enable this', 86 title : 'Shake it up, just like bad medicine!', 87 accessKey : 'T', 88 checked : false 89 }, 90 91 { 92 type : 'checkbox', 93 label : 'Enable that', 94 checked : true 95 }, 96 97 { 98 type : 'checkbox', 99 label : 'Enable those', 100 onChange : function(){ console.log( this.getValue() ); }, 101 checked : false 102 }, 103 104 { 105 type : 'radio', 106 label : 'Include library:', 107 title : 'Trying to include a library in LOLCODE.', 108 'default' : 'stdio', 109 accessKey : 'Y', 110 onChange : function(){ console.log( this.getValue() ); }, 111 items : [ 112 [ 'Standard I/O', 'stdio', 'You need this to write Hello World.' ], 113 [ 'Standard C Library', 'stdlib', 'You need this to exit.' ], 114 [ 'POSIX Library', 'unistd', 'You need this to sleep.' ], 115 [ 'Signal Library', 'signal' ] 116 ] 117 }, 118 119 { 120 type : 'button', 121 label : 'Click Me', 122 title : 'Click me plz!', 123 accessKey : 'U', 124 onClick : function( evt ) 125 { 126 console.log( 'Clicked!!' ); 127 } 128 }, 129 130 { 131 type : 'html', 132 html : '<strong>CKEditor rocks.</strong>' 133 } 134 ] 135 } 136 ] 137 } ); 138 }, 139 // This removes the second page. 140 removePages = function( definition ) 141 { 142 definition.removeContents( 'tab2' ); 143 }, 144 // This adds three text fields in the first page. 145 addFields = function( definition ) 146 { 147 var page1 = definition.getContents( 'tab1' ); 148 page1.add( { 149 type : 'text', 150 label : 'Test Text 1', 151 id : 'testText1', 152 'default' : 'hello world!', 153 accessKey : 'R' 154 } ); 155 page1.add( { 156 type : 'text', 157 label : 'Test Text 2', 158 id : 'testText2', 159 'default' : 'Wheee' 160 } ); 161 page1.add( { 162 type : 'text', 163 label : 'Test Text 3', 164 id : 'testText3', 165 'default' : 'Blah blah' 166 } ); 167 }, 168 // This removes the first text field (originally defined in custom_dialog.js) 169 // in the first page. 170 removeFields = function( definition ) 171 { 172 var page1 = definition.getContents( 'tab1' ); 173 page1.remove( 'input1' ); 174 }, 175 // This sets the default value of the 'testText1' text field in the first 176 // page. 177 setDefaultValues = function( definition ) 178 { 179 var testText1 = definition.getContents( 'tab1' ).get( 'testText1' ); 180 testText1['default'] = 'Modified'; 181 }, 182 // This modifies the default size of the dialog. 183 setDefaultSize = function( definition ) 184 { 185 definition.minWidth = 500; 186 definition.minHeight = 400; 187 }, 188 // This modifies the custom dialog's definition when it's created. 189 modifyDefinition = function( evt ) 190 { 191 if ( evt.data.name != 'custom' ) 192 return; 193 194 var definition = evt.data.definition; 195 addPages( definition ); 196 removePages( definition ); 197 addFields( definition ); 198 removeFields( definition ); 199 setDefaultValues( definition ); 200 setDefaultSize( definition ); 201 202 return evt.data; 203 }, 204 addDialog = function() 205 { 206 // Register the custom dialog. 207 var href = document.location.href.split( '/' ); 208 href.pop(); 209 href.push( 'api_dialog', 'custom_dialog.js' ); 210 CKEDITOR.dialog.add( 'custom', href.join( '/' ) ); 211 212 // Add the custom dialog buttons. 213 editor.addCommand( 'custom', new CKEDITOR.dialogCommand( 'custom' ) ); 214 editor.ui.addButton( 'Custom', 215 { 216 label : 'Custom Dialog', 217 command : 'custom' 218 } ); 219 220 // Add .css file related to custom dialog button. 221 var doc = new CKEDITOR.dom.document( document ); 222 href.pop(); 223 href.push( 'api_dialog.css' ); 224 doc.appendStyleSheet( href.join( '/' ) ); 225 226 // Modify the dialog definition to demonstrate the API. 227 editor.on( 'dialogDefinition', modifyDefinition ); 228 }; 229 230 // Add the custom dialog after the dialog plugin loaded. 231 if ( typeof( editor.openDialog ) == 'function' ) 232 addDialog(); 233 else 234 editor.on( 'dialogPluginLoaded', addDialog ); 235 } 236 237 hook( window, 'load', init ); 238 })(); -
_samples/api_dialog/custom_dialog.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 CKEDITOR.dialog.add( 'custom', function( editor ) 7 { 8 return { 9 title : 'Custom Dialog', 10 minWidth : 400, 11 minHeight : 320, 12 contents : [ 13 { 14 id : 'tab1', 15 label : 'First Tab', 16 title : 'First Tab', 17 elements : 18 [ 19 { 20 id : 'input1', 21 type : 'text', 22 label : 'Input 1' 23 } 24 ] 25 } 26 ] 27 }; 28 } ); -
_samples/api_dialog.html
1 <!DOCTYPE html> 2 <!-- 3 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 4 For licensing, see LICENSE.html or http://ckeditor.com/license 5 --> 6 <html> 7 <head> 8 <title>Dialog API - CKEditor Sample</title> 9 <script type="text/javascript" src="../ckeditor_source.js"></script> 10 <script type="text/javascript" src="api_dialog/api_dialog.js"></script> 11 <link type="text/css" rel="stylesheet" href="sample.css" /> 12 <meta content="text/html; charset=utf-8" http-equiv="content-type" /> 13 </head> 14 <body> 15 <h1>CKEditor Sample</h1> 16 <p>This sample shows how the dialog API can be used to</p> 17 <ol> 18 <li>Add dialog pages;</li> 19 <li>Remove dialog pages;</li> 20 <li>Add dialog fields;</li> 21 <li>Remove dialog fields;</li> 22 <li>Set default values.</li> 23 </ol> 24 <p>Without modifying the original dialog's .js file.</p> 25 <fieldset title="Editor"> 26 <textarea id="editor1" name="editor1" rows="10" cols="80"><p>This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.</p></textarea> 27 </fieldset> 28 <div id="footer"> 29 <hr/> 30 <p> 31 CKEditor - The text editor for Internet - <a href="http://ckeditor.com/">http://ckeditor.com</a> 32 </p> 33 <p id="copy"> 34 Copyright © 2003-2009, <a href="http://cksource.com/">CKSource</a> - Frederico Knabben. All rights reserved. 35 </p> 36 </div> 37 </body> 38 </html> -
_samples/api_dialog/api_dialog.css
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 .cke_skin_default a.cke_button.cke_button_custom .cke_icon 7 { 8 display: none; 9 } 10 11 .cke_skin_default a.cke_button.cke_button_custom .cke_label 12 { 13 display: inline; 14 } -
_samples/api_dialog/api_dialog.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 (function() 7 { 8 function hook( obj, name, func ) 9 { 10 if ( obj.attachEvent ) 11 return obj.attachEvent( 'on' + name, func ); 12 else 13 return obj.addEventListener( name, func, false ); 14 } 15 16 function init() 17 { 18 CKEDITOR.replace( 'editor1', 19 { 20 plugins : 'basicstyles,button,dialog,elementspath,htmldataprocessor,keystrokes,sourcearea,tab,toolbar,wysiwygarea', 21 toolbar : [ [ 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike', '-', 'Custom' ] ] 22 } ); 23 24 var editor = CKEDITOR.instances.editor1, 25 // This adds a second page and third page after the first. 26 addPages = function( definition ) 27 { 28 definition.addContents( { 29 id : 'tab2', 30 label : 'Second Tab', 31 title : 'Second Tab Title', 32 accessKey : 'W', 33 elements : [ 34 { 35 type : 'hbox', 36 children : [ 37 { 38 type : 'text', 39 label : 'Test Text 4', 40 title : 'Your love is like bad medicine!', 41 id : 'testText4', 42 'default' : 'hello world!', 43 validate : function( dialog ) 44 { 45 var valid = /^[A-Z a-z!]+$/.test( this.getValue() ); 46 if ( !valid ) 47 { 48 this.select(); 49 alert( 'Test Text 4 must only contain alphanumeric characters, space, or ! and must not be empty.' ); 50 } 51 return valid; 52 }, 53 isChanged : false 54 }, 55 56 { 57 type : 'text', 58 label : 'Test Text 5', 59 id : 'testText5', 60 'default' : 'Wheee' 61 }, 62 63 { 64 type : 'text', 65 label : 'Test Text 6', 66 onChange : function(){ console.log( this.getValue() ); }, 67 id : 'testText6', 68 'default' : 'Blah blah' 69 } 70 ] 71 } 72 ] 73 } ); 74 definition.addContents( { 75 id : 'tab3', 76 label : 'Third Tab', 77 title : 'Third Tab Title', 78 accessKey : 'E', 79 elements : [ 80 { 81 type : 'vbox', 82 children : [ 83 { 84 type : 'checkbox', 85 label : 'Enable this', 86 title : 'Shake it up, just like bad medicine!', 87 accessKey : 'T', 88 checked : false 89 }, 90 91 { 92 type : 'checkbox', 93 label : 'Enable that', 94 checked : true 95 }, 96 97 { 98 type : 'checkbox', 99 label : 'Enable those', 100 onChange : function(){ console.log( this.getValue() ); }, 101 checked : false 102 }, 103 104 { 105 type : 'radio', 106 label : 'Include library:', 107 title : 'Trying to include a library in LOLCODE.', 108 'default' : 'stdio', 109 accessKey : 'Y', 110 onChange : function(){ console.log( this.getValue() ); }, 111 items : [ 112 [ 'Standard I/O', 'stdio', 'You need this to write Hello World.' ], 113 [ 'Standard C Library', 'stdlib', 'You need this to exit.' ], 114 [ 'POSIX Library', 'unistd', 'You need this to sleep.' ], 115 [ 'Signal Library', 'signal' ] 116 ] 117 }, 118 119 { 120 type : 'button', 121 label : 'Click Me', 122 title : 'Click me plz!', 123 accessKey : 'U', 124 onClick : function( evt ) 125 { 126 console.log( 'Clicked!!' ); 127 } 128 }, 129 130 { 131 type : 'html', 132 html : '<strong>CKEditor rocks.</strong>' 133 } 134 ] 135 } 136 ] 137 } ); 138 }, 139 // This removes the second page. 140 removePages = function( definition ) 141 { 142 definition.removeContents( 'tab2' ); 143 }, 144 // This adds three text fields in the first page. 145 addFields = function( definition ) 146 { 147 var page1 = definition.getContents( 'tab1' ); 148 page1.add( { 149 type : 'text', 150 label : 'Test Text 1', 151 id : 'testText1', 152 'default' : 'hello world!', 153 accessKey : 'R' 154 } ); 155 page1.add( { 156 type : 'text', 157 label : 'Test Text 2', 158 id : 'testText2', 159 'default' : 'Wheee' 160 } ); 161 page1.add( { 162 type : 'text', 163 label : 'Test Text 3', 164 id : 'testText3', 165 'default' : 'Blah blah' 166 } ); 167 }, 168 // This removes the first text field (originally defined in custom_dialog.js) 169 // in the first page. 170 removeFields = function( definition ) 171 { 172 var page1 = definition.getContents( 'tab1' ); 173 page1.remove( 'input1' ); 174 }, 175 // This sets the default value of the 'testText1' text field in the first 176 // page. 177 setDefaultValues = function( definition ) 178 { 179 var testText1 = definition.getContents( 'tab1' ).get( 'testText1' ); 180 testText1['default'] = 'Modified'; 181 }, 182 // This modifies the default size of the dialog. 183 setDefaultSize = function( definition ) 184 { 185 definition.minWidth = 500; 186 definition.minHeight = 400; 187 }, 188 // This modifies the custom dialog's definition when it's created. 189 modifyDefinition = function( evt ) 190 { 191 if ( evt.data.name != 'custom' ) 192 return; 193 194 var definition = evt.data.definition; 195 addPages( definition ); 196 removePages( definition ); 197 addFields( definition ); 198 removeFields( definition ); 199 setDefaultValues( definition ); 200 setDefaultSize( definition ); 201 202 return evt.data; 203 }, 204 addDialog = function() 205 { 206 // Register the custom dialog. 207 var href = document.location.href.split( '/' ); 208 href.pop(); 209 href.push( 'api_dialog', 'custom_dialog.js' ); 210 CKEDITOR.dialog.add( 'custom', href.join( '/' ) ); 211 212 // Add the custom dialog buttons. 213 editor.addCommand( 'custom', new CKEDITOR.dialogCommand( 'custom' ) ); 214 editor.ui.addButton( 'Custom', 215 { 216 label : 'Custom Dialog', 217 command : 'custom' 218 } ); 219 220 // Add .css file related to custom dialog button. 221 var doc = new CKEDITOR.dom.document( document ); 222 href.pop(); 223 href.push( 'api_dialog.css' ); 224 doc.appendStyleSheet( href.join( '/' ) ); 225 226 // Modify the dialog definition to demonstrate the API. 227 editor.on( 'dialogDefinition', modifyDefinition ); 228 }; 229 230 // Add the custom dialog after the dialog plugin loaded. 231 if ( typeof( editor.openDialog ) == 'function' ) 232 addDialog(); 233 else 234 editor.on( 'dialogPluginLoaded', addDialog ); 235 } 236 237 hook( window, 'load', init ); 238 })(); -
_samples/api_dialog/custom_dialog.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 CKEDITOR.dialog.add( 'custom', function( editor ) 7 { 8 return { 9 title : 'Custom Dialog', 10 minWidth : 400, 11 minHeight : 320, 12 contents : [ 13 { 14 id : 'tab1', 15 label : 'First Tab', 16 title : 'First Tab', 17 elements : 18 [ 19 { 20 id : 'input1', 21 type : 'text', 22 label : 'Input 1' 23 } 24 ] 25 } 26 ] 27 }; 28 } ); -
_source/plugins/dialog/plugin.js
9 9 10 10 CKEDITOR.plugins.add( 'dialog', 11 11 { 12 requires : [ 'dialogui' ] 12 requires : [ 'dialogui' ], 13 14 init : function( editor, pluginPath ) 15 { 16 editor.fire( 'dialogPluginLoaded' ); 17 } 13 18 }); 14 19 15 20 /** … … 69 74 return; 70 75 } 71 76 definition = new CKEDITOR.dialog._.definitionObject( this, definition ); 72 definition = CKEDITOR.fire( 'dialogDefinition', { name : dialogName, definition : definition }, editor ).definition;77 definition = editor.fire( 'dialogDefinition', { name : dialogName, definition : definition }, editor ).definition; 73 78 74 79 // Initialize some basic parameters. 75 80 CKEDITOR.tools.extend( ( this._ || ( this._ = {} ) ), { … … 1243 1248 1244 1249 currentZIndex : null, 1245 1250 1246 storedDialogs : {},1247 1248 1251 margins : [0, 0, 0, 0], 1249 1252 1250 1253 /** … … 2129 2132 // If the dialogDefinition is already loaded, open it immediately. 2130 2133 if ( typeof( CKEDITOR.dialog._.dialogDefinitions[dialogName] ) == 'function' ) 2131 2134 { 2132 var dialog = CKEDITOR.dialog._.storedDialogs[dialogName] || new CKEDITOR.dialog( this, dialogName ); 2133 CKEDITOR.dialog._.storedDialogs[dialogName] = dialog; 2135 if ( !this._.storedDialogs ) 2136 this._.storedDialogs = {}; 2137 2138 var dialog = this._.storedDialogs[dialogName] || new CKEDITOR.dialog( this, dialogName ); 2139 this._.storedDialogs[dialogName] = dialog; 2134 2140 dialog.show(); 2135 2141 return dialog; 2136 2142 } -
_source/plugins/dialogui/plugin.js
360 360 this._['default'] = [ elementDefinition.items[0][1] ] ; 361 361 if ( elementDefinition.validate ) 362 362 this.validate = elementDefinition.valdiate; 363 var children = [] ;363 var children = [], me = this; 364 364 365 365 /** @ignore */ 366 366 var innerHTML = function() … … 392 392 name : commonName, 393 393 value : value 394 394 }; 395 if ( this.getDefault() == value )395 if ( me.getDefault() == value ) 396 396 inputAttributes.checked = 'checked'; 397 397 cleanInnerDefinition( inputDefinition ); 398 398 cleanInnerDefinition( labelDefinition );