Ticket #3673: 3673_3.patch
File 3673_3.patch, 24.1 KB (added by , 15 years ago) |
---|
-
_source/core/config.js
149 149 * @example 150 150 * config.plugins = 'basicstyles,button,htmldataprocessor,toolbar,wysiwygarea'; 151 151 */ 152 153 plugins : 'about,basicstyles,blockquote,button,clipboard,colorbutton,contextmenu,elementspath,enterkey,entities,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,maximize,newpage,pagebreak,pastefromword,pastetext,preview,print,removeformat,resize,save,scayt,smiley,showblocks,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc', 154 152 plugins : 'about,basicstyles,blockquote,button,clipboard,colorbutton,contextmenu,elementspath,enterkey,entities,filebrowser,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,maximize,newpage,pagebreak,pastefromword,pastetext,popup,preview,print,removeformat,save,smiley,showblocks,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc', 155 153 /** 156 154 * List of additional plugins to be loaded. This is a tool setting which 157 155 * makes it easier to add new plugins, whithout having to touch and -
_source/lang/en.js
545 545 panelTitle3 : 'Object Styles' 546 546 }, 547 547 548 filebrowser : 549 { 550 browserNotConfigured : 'Unable to open file browser due to missing configuration settings', 551 uploaderNotConfigured : 'Unable to upload file due to missing configuration settings', 552 }, 553 548 554 format : 549 555 { 550 556 label : 'Format', -
_source/plugins/dialog/plugin.js
871 871 }, 872 872 873 873 /** 874 * Gets the name of the dialog. 875 * @returns {String} The name of this dialog. 876 * @example 877 * var dialogName = dialogObj.getName(); 878 */ 879 getName : function() 880 { 881 return this._.name; 882 }, 883 884 /** 874 885 * Gets a dialog UI element object from a dialog page. 875 886 * @param {String} pageId id of dialog page. 876 887 * @param {String} elementId id of UI element. … … 2177 2188 }, 2178 2189 2179 2190 /** 2191 * Gets the name of the parent tab of this element. 2192 * @returns {String} The name of selected tab. 2193 * @example 2194 * focus : function() 2195 * { 2196 * this.getParentTab(); 2197 * // do something else. 2198 * } 2199 */ 2200 getParentTab : function() 2201 { 2202 var element = this.getInputElement(), 2203 cursor = element, 2204 tabId; 2205 while ( ( cursor = cursor.getParent() ) && cursor.$.className.search( 'cke_dialog_page_contents' ) == -1 ) 2206 { /*jsl:pass*/ } 2207 2208 tabId = cursor.getAttribute( 'name' ); 2209 2210 return tabId; 2211 }, 2212 2213 /** 2180 2214 * Puts the focus to the UI object. Switches tabs if the UI object isn't in the active tab page. 2181 2215 * @returns {CKEDITOR.dialog.uiElement} The current UI element. 2182 2216 * @example -
_source/plugins/dialogui/plugin.js
654 654 this.validate = elementDefinition.validate; 655 655 656 656 var myDefinition = CKEDITOR.tools.extend( {}, elementDefinition ); 657 var onClick = myDefinition.onClick; 657 658 myDefinition.className = ( myDefinition.className ? myDefinition.className + ' ' : '' ) + 'cke_dialog_ui_button'; 658 659 myDefinition.onClick = function( evt ) 659 660 { 660 661 var target = elementDefinition[ 'for' ]; // [ pageId, elementId ] 661 dialog.getContentElement( target[0], target[1] ).submit(); 662 this.disable(); 662 if ( !onClick || onClick.call( this, evt ) !== false ) 663 { 664 dialog.getContentElement( target[0], target[1] ).submit(); 665 this.disable(); 666 } 663 667 }; 664 668 665 669 dialog.on( 'load', function() … … 1197 1201 }, 1198 1202 1199 1203 /** 1204 * Get the action assigned to the form. 1205 * @returns {String} The value of the action. 1206 * @example 1207 */ 1208 getAction : function( action ) 1209 { 1210 return this.getInputElement().getParent().$.action; 1211 }, 1212 1213 /** 1200 1214 * Redraws the file input and resets the file path in the file input. 1201 1215 * The redraw logic is necessary because non-IE browsers tend to clear 1202 1216 * the <iframe> containing the file input after closing the dialog. 1203 1217 * @example 1204 1218 */ 1205 reset : function( )1219 reset : function( action ) 1206 1220 { 1207 1221 var frameElement = CKEDITOR.document.getById( this._.frameId ), 1208 1222 frameDocument = frameElement.getFrameDocument(), … … 1219 1233 1220 1234 frameDocument.$.write( [ '<html><head><title></title></head><body style="margin: 0; overflow: hidden; background: transparent;">', 1221 1235 '<form enctype="multipart/form-data" method="POST" action="', 1222 CKEDITOR.tools.htmlEncode( elementDefinition.action ),1236 CKEDITOR.tools.htmlEncode( action || elementDefinition.action ), 1223 1237 '">', 1224 1238 '<input type="file" name="', 1225 1239 CKEDITOR.tools.htmlEncode( elementDefinition.id || 'cke_upload' ), -
_source/plugins/filebrowser/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 * @fileOverview The "filebrowser" plugin, it adds support for file uploads and 8 * browsing. 9 * 10 * When file is selected inside of the file browser or uploaded, its url is 11 * inserted automatically to a field, which is described in the 'filebrowser' 12 * attribute. To specify field that should be updated, pass the tab id and 13 * element id, separated with a colon. 14 * 15 * Example 1: (Browse) 16 * 17 * <pre> 18 * { 19 * type : 'button', 20 * id : 'browse', 21 * filebrowser : 'tabId:elementId', 22 * label : editor.lang.common.browseServer 23 * } 24 * </pre> 25 * 26 * If you set the 'filebrowser' attribute on any element other than 27 * 'fileButton', the 'Browse' action will be triggered. 28 * 29 * Example 2: (Quick Upload) 30 * 31 * <pre> 32 * { 33 * type : 'fileButton', 34 * id : 'uploadButton', 35 * filebrowser : 'tabId:elementId', 36 * label : editor.lang.common.uploadSubmit, 37 * 'for' : [ 'upload', 'upload' ] 38 * } 39 * </pre> 40 * 41 * If you set the 'filebrowser' attribute on a fileButton element, the 42 * 'QuickUpload' action will be executed. 43 * 44 * Filebrowser plugin also supports more advanced configuration (through 45 * javascript object). 46 * 47 * The following settings are supported: 48 * 49 * <pre> 50 * [action] - Browse or QuickUpload 51 * [target] - field to update, tabId:elementId 52 * [params] - additional arguments to be passed to the server connector (optional) 53 * [onSelect] - function to execute when file is selected/uploaded (optional) 54 * [url] - the URL to be called (optional) 55 * </pre> 56 * 57 * Example 3: (Quick Upload) 58 * 59 * <pre> 60 * { 61 * type : 'fileButton', 62 * label : editor.lang.common.uploadSubmit, 63 * id : 'buttonId', 64 * filebrowser : 65 * { 66 * action : 'QuickUpload', //required 67 * target : 'tab1:elementId', //required 68 * params : //optional 69 * { 70 * type : 'Files', 71 * currentFolder : '/folder/' 72 * }, 73 * onSelect : function( fileUrl, errorMessage ) //optional 74 * { 75 * // Do not call the built-in selectFuntion 76 * // return false; 77 * } 78 * }, 79 * 'for' : [ 'tab1', 'myFile' ] 80 * } 81 * </pre> 82 * 83 * Suppose we have a file element with id 'myFile', text field with id 84 * 'elementId' and a fileButton. If filebowser.url is not specified explicitly, 85 * form action will be set to 'filebrowser[DialogName]UploadUrl' or, if not 86 * specified, to 'filebrowserUploadUrl'. Additional parameters from 'params' 87 * object will be added to the query string. It is possible to create your own 88 * uploadHandler and cancel the built-in updateTargetElement command. 89 * 90 * Example 4: (Browse) 91 * 92 * <pre> 93 * { 94 * type : 'button', 95 * id : 'buttonId', 96 * label : editor.lang.common.browseServer, 97 * filebrowser : 98 * { 99 * action : 'Browse', 100 * url : '/ckfinder/ckfinder.html&type=Images', 101 * target : 'tab1:elementId' 102 * } 103 * } 104 * </pre> 105 * 106 * In this example, after pressing a button, file browser will be opened in a 107 * popup. If we don't specify filebrowser.url attribute, 108 * 'filebrowser[DialogName]BrowseUrl' or 'filebrowserBrowseUrl' will be used. 109 * After selecting a file in a file browser, an element with id 'elementId' will 110 * be updated. Just like in the third example, a custom 'onSelect' function may be 111 * defined. 112 */ 113 ( function() 114 { 115 /** 116 * Reference to the editor instance. 117 * 118 * @type CKEDITOR 119 */ 120 var editorInstance; 121 /** 122 * Reference to the UI element that started the Browse/QuickUpload action. 123 * 124 * @type CKEDITOR.ui.dialog.uiElement 125 */ 126 var sourceElement; 127 128 /** 129 * Adds (additional) arguments to given url. 130 * 131 * @param {String} 132 * url The url. 133 * @param {Object} 134 * params Additional parameters. 135 */ 136 var addQueryString = function( url, params ) 137 { 138 var queryString = []; 139 140 if ( !params ) 141 return url; 142 else 143 { 144 for ( var i in params ) 145 queryString.push( i + "=" + encodeURIComponent( params[ i ] ) ); 146 } 147 148 return url + ( ( url.indexOf( "?" ) != -1 ) ? "&" : "?" ) + queryString.join( "&" ); 149 }; 150 151 /** 152 * Make a string's first character uppercase. 153 * 154 * @param {String} 155 * str String. 156 */ 157 var ucFirst = function( str ) 158 { 159 str += ''; 160 var f = str.charAt( 0 ).toUpperCase(); 161 return f + str.substr( 1 ); 162 }; 163 164 /** 165 * The onlick function assigned to the 'Browse Server' button. Opens the 166 * file browser and updates target field when file is selected. 167 * 168 * @param {CKEDITOR.event} 169 * evt The event object. 170 */ 171 var browseServer = function( evt ) 172 { 173 sourceElement = this; 174 175 var dialog = this.getDialog(); 176 var width = editorInstance.config[ 'filebrowser' + ucFirst( dialog.getName() ) + 'WindowWidth' ] 177 || editorInstance.config.filebrowserWindowWidth || '80%'; 178 var height = editorInstance.config[ 'filebrowser' + ucFirst( dialog.getName() ) + 'WindowHeight' ] 179 || editorInstance.config.filebrowserWindowHeight || '70%'; 180 var url = this.filebrowser.url || editorInstance.config[ 'filebrowser' + ucFirst( dialog.getName() ) + 'BrowseUrl' ] 181 || editorInstance.config.filebrowserBrowseUrl; 182 183 if ( !url ) 184 { 185 alert( editorInstance.lang.filebrowser.browserNotConfigured ); 186 return; 187 } 188 189 var params = this.filebrowser.params || {}; 190 params.CKEditor = editorInstance.name; 191 if ( !params.langCode ) 192 params.langCode = editorInstance.langCode; 193 194 url = addQueryString( url, params ); 195 editorInstance.popup( url, width, height ); 196 }; 197 198 /** 199 * The onlick function assigned to the 'Upload' button. Makes the final 200 * decision whether form is really submitted and updates target field when 201 * file is uploaded. 202 * 203 * @param {CKEDITOR.event} 204 * evt The event object. 205 */ 206 var uploadFile = function( evt ) 207 { 208 sourceElement = this; 209 210 var dialog = this.getDialog(); 211 212 // If user didn't select the file, stop the upload. 213 if ( !dialog.getContentElement( this[ 'for' ][ 0 ], this[ 'for' ][ 1 ] ).getInputElement().$.value ) 214 { 215 alert( editorInstance.lang.filebrowser.fileNotSelected ); 216 return false; 217 } 218 219 if ( !dialog.getContentElement( this[ 'for' ][ 0 ], this[ 'for' ][ 1 ] ).getAction() ) 220 { 221 alert( editorInstance.lang.filebrowser.uploaderNotConfigured ); 222 return false; 223 } 224 225 return true; 226 }; 227 228 /** 229 * Setups the file element. 230 * 231 * @param {CKEDITOR.ui.dialog.file} 232 * fileInput The file element used during file upload. 233 * @param {Object} 234 * filebrowser Object containing filebrowser settings assigned to 235 * the fileButton associated with this file element. 236 */ 237 var setupFileElement = function( dialogName, fileInput, filebrowser ) 238 { 239 var params = filebrowser.params || {}; 240 params.CKEditor = editorInstance.name; 241 if ( !params.langCode ) 242 params.langCode = editorInstance.langCode; 243 244 var url = filebrowser.url || editorInstance.config[ 'filebrowser' + ucFirst( dialogName ) + 'UploadUrl' ] 245 || editorInstance.config.filebrowserUploadUrl; 246 247 fileInput.action = url ? addQueryString( url, params ) : ''; 248 fileInput.filebrowser = filebrowser; 249 }; 250 251 /** 252 * Traverse through the content definition and attach filebrowser to 253 * elements with 'filebrowser' attribute. 254 * 255 * @param {CKEDITOR.dialog.dialogDefinitionObject} 256 * definition 257 * @param {Array} 258 * elements Array of {@link CKEDITOR.dialog.contentDefinition} 259 * objects. 260 */ 261 var attachFileBrowser = function( dialogName, definition, elements ) 262 { 263 var element, fileInput; 264 265 for ( var i in elements ) 266 { 267 element = elements[ i ]; 268 269 if ( element.type == 'hbox' || element.type == 'vbox' ) 270 attachFileBrowser( dialogName, definition, element.children ); 271 272 if ( !element.filebrowser ) 273 continue; 274 275 if ( typeof element.filebrowser == 'string' ) 276 { 277 var fb = 278 { 279 action : ( element.type == 'fileButton' ) ? 'QuickUpload' : 'Browse', 280 target : element.filebrowser 281 }; 282 element.filebrowser = fb; 283 } 284 285 if ( element.filebrowser.action == 'Browse' ) 286 { 287 element.onClick = browseServer; 288 } 289 else if ( element.filebrowser.action == 'QuickUpload' && element[ 'for' ] ) 290 { 291 setupFileElement( dialogName, definition.getContents( element[ 'for' ][ 0 ] ).get( element[ 'for' ][ 1 ] ), 292 element.filebrowser ); 293 element.onClick = uploadFile; 294 } 295 } 296 }; 297 298 /** 299 * Updates the target element with the url of uploaded/selected file. 300 * 301 * @param {String} 302 * url The url of a file. 303 */ 304 var updateTargetElement = function( url ) 305 { 306 var dialog = sourceElement.getDialog(); 307 var targetElement = sourceElement.filebrowser.target || null; 308 url = url.replace( /#/g, '%23' ); 309 310 // If there is a reference to targetElement, update it. 311 if ( targetElement ) 312 { 313 if ( targetElement === true ) 314 targetElement = 'url'; 315 316 if ( targetElement.indexOf( ':' ) == -1 ) 317 { 318 dialog.foreach( function( element ) 319 { 320 if ( element.id == targetElement ) 321 { 322 element.setValue( url ); 323 dialog.selectPage( element.getParentTab() ); 324 } 325 } ); 326 } 327 else 328 { 329 var target = targetElement.split( ':' ); 330 var element = dialog.getContentElement( target[ 0 ], target[ 1 ] ); 331 if ( element ) 332 { 333 element.setValue( url ); 334 dialog.selectPage( target[ 0 ] ); 335 } 336 } 337 } 338 }; 339 340 CKEDITOR.plugins.add( 'filebrowser', 341 { 342 init : function( editor, pluginPath ) 343 { 344 CKEDITOR.on( 'dialogDefinition', function( evt ) 345 { 346 editorInstance = editor; 347 348 // Associate filebrowser to elements with 'filebrowser' attribute. 349 for ( var i in evt.data.definition.contents ) 350 attachFileBrowser( evt.data.name, evt.data.definition, evt.data.definition.contents[ i ].elements ); 351 } ); 352 }, 353 354 setUrl : function( fileUrl, data ) 355 { 356 var dialog = sourceElement.getDialog(), 357 targetInput = sourceElement[ 'for' ], 358 onSelect = sourceElement.filebrowser.onSelect; 359 360 if ( targetInput ) 361 { 362 var formAction = dialog.getContentElement( targetInput[ 0 ], targetInput[ 1 ] ).getAction(); 363 dialog.getContentElement( targetInput[ 0 ], targetInput[ 1 ] ).reset( formAction ); 364 } 365 366 if ( onSelect && onSelect.call( sourceElement, fileUrl, data ) === false ) 367 return; 368 369 // The "data" argument may be used to pass the error message to the editor. 370 if ( typeof data == 'string' ) 371 alert( data ); 372 373 if ( fileUrl ) 374 updateTargetElement( fileUrl ); 375 } 376 } ); 377 378 } )(); -
_source/plugins/flash/dialogs/flash.js
347 347 { 348 348 type : 'button', 349 349 id : 'browse', 350 filebrowser : 'src', 350 351 align : 'center', 351 352 label : editor.lang.common.browseServer 352 353 } … … 445 446 type : 'file', 446 447 id : 'upload', 447 448 label : editor.lang.common.upload, 448 action : editor.config.image_uploadAction,449 449 size : 38 450 450 }, 451 451 { 452 452 type : 'fileButton', 453 453 id : 'uploadButton', 454 454 label : editor.lang.common.uploadSubmit, 455 filebrowser : 'src', 455 456 'for' : [ 'Upload', 'upload' ] 456 457 } 457 458 ] -
_source/plugins/flash/plugin.js
143 143 CKEDITOR.tools.extend( CKEDITOR.config, 144 144 { 145 145 flashUploadTab : true, 146 flashUploadAction : 'nowhere.php',147 146 flashBrowseServer : true, 148 147 149 148 /** -
_source/plugins/image/dialogs/image.js
445 445 id : 'browse', 446 446 align : 'center', 447 447 label : editor.lang.common.browseServer, 448 filebrowser : 'info:txtUrl', 448 449 onLoad : function() 449 450 { 450 451 var dialog = this.getDialog(); 451 452 if ( !dialog.getParentEditor().config.image_browseServer ) 452 453 dialog.getContentElement( 'info', 'browse' ).getElement().hide(); 453 },454 onClick : function()455 {456 457 454 } 458 455 } 459 456 ] … … 930 927 { 931 928 type : 'button', 932 929 id : 'browse', 930 filebrowser : 'Link:txtUrl', 933 931 style : 'float:right', 934 label : editor.lang.common.browseServer, 935 onClick : function() 936 { 937 } 932 label : editor.lang.common.browseServer 938 933 }, 939 934 { 940 935 id : 'cmbTarget', … … 974 969 type : 'file', 975 970 id : 'upload', 976 971 label : editor.lang.image.btnUpload, 977 action : editor.config.image_uploadAction,978 972 size : 38 979 973 }, 980 974 { 981 975 type : 'fileButton', 982 976 id : 'uploadButton', 977 filebrowser : 'info:txtUrl', 983 978 label : editor.lang.image.btnUpload, 984 979 'for' : [ 'Upload', 'upload' ] 985 980 } -
_source/plugins/image/plugin.js
61 61 */ 62 62 CKEDITOR.config.image_browseServer = true; 63 63 64 /**65 * Upload action attribute.66 * @type URL67 */68 CKEDITOR.config.image_uploadAction = 'nowhere.php';69 70 64 CKEDITOR.config.image_removeLinkByEmptyURL = true; -
_source/plugins/link/dialogs/link.js
388 388 { 389 389 type : 'button', 390 390 id : 'browse', 391 filebrowser : 'url', 391 392 label : editor.lang.common.browseServer 392 393 } 393 394 ] … … 821 822 type : 'file', 822 823 id : 'upload', 823 824 label : editor.lang.common.upload, 824 action : editor.config.linkUploadAction,825 825 size : 38 826 826 }, 827 827 { 828 828 type : 'fileButton', 829 829 id : 'uploadButton', 830 830 label : editor.lang.common.uploadSubmit, 831 filebrowser : 'url', 831 832 'for' : [ 'upload', 'upload' ] 832 833 } 833 834 ] … … 1039 1040 case 'url': 1040 1041 var protocol = ( data.url && data.url.protocol != undefined ) ? data.url.protocol : 'http://', 1041 1042 url = ( data.url && data.url.url ) || ''; 1042 attributes._cke_saved_href = protocol + url;1043 attributes._cke_saved_href = ( url.indexOf( '/' ) === 0 ) ? url : protocol + url; 1043 1044 break; 1044 1045 case 'anchor': 1045 1046 var name = ( data.anchor && data.anchor.name ), -
_source/plugins/link/plugin.js
185 185 { 186 186 linkUploadTab : true, 187 187 linkBrowseServer : true, 188 linkUploadAction : 'nowhere.php',189 188 linkShowAdvancedTab : true, 190 189 linkShowTargetTab : true 191 190 } ); -
_source/plugins/popup/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 CKEDITOR.plugins.add( 'popup'); 7 8 CKEDITOR.tools.extend( CKEDITOR.editor.prototype, 9 { 10 /** 11 * Opens Browser in a popup. The "width" and "height" parameters accept 12 * numbers (pixels) or percent (of screen size) values. 13 * @param {String} url The url of the external file browser. 14 * @param {String} width Popup window width. 15 * @param {String} height Popup window height. 16 */ 17 popup : function( url, width, height ) 18 { 19 width = width || '80%'; 20 height = height || '70%'; 21 22 if ( typeof width == 'string' && width.length > 1 && width.substr( width.length - 1, 1 ) == '%' ) 23 width = parseInt( window.screen.width * parseInt( width, 10 ) / 100, 10 ); 24 25 if ( typeof height == 'string' && height.length > 1 && height.substr( height.length - 1, 1 ) == '%' ) 26 height = parseInt( window.screen.height * parseInt( height, 10 ) / 100, 10 ); 27 28 if ( width < 640 ) 29 width = 640; 30 31 if ( height < 420 ) 32 height = 420; 33 34 var top = parseInt( ( window.screen.height - height ) / 2, 10 ), 35 left = parseInt( ( window.screen.width - width ) / 2, 10 ), 36 options = 'location=no,menubar=no,toolbar=no,dependent=yes,minimizable=no,modal=yes,alwaysRaised=yes,resizable=yes' + 37 ',width=' + width + 38 ',height=' + height + 39 ',top=' + top + 40 ',left=' + left; 41 42 var popupWindow = window.open( '', null, options, true ); 43 44 // Blocked by a popup blocker. 45 if ( !popupWindow ) 46 return false; 47 48 try 49 { 50 popupWindow.moveTo( left, top ); 51 popupWindow.resizeTo( width, height ); 52 popupWindow.focus(); 53 popupWindow.location.href = url; 54 } 55 catch (e) 56 { 57 popupWindow = window.open( url, null, options, true ); 58 } 59 60 return true ; 61 } 62 }); -
ckeditor.pack
153 153 '_source/plugins/pagebreak/plugin.js', 154 154 '_source/plugins/pastefromword/plugin.js', 155 155 '_source/plugins/pastetext/plugin.js', 156 '_source/plugins/popup/plugin.js', 156 157 '_source/plugins/preview/plugin.js', 157 158 '_source/plugins/print/plugin.js', 158 159 '_source/plugins/removeformat/plugin.js', 159 160 '_source/plugins/resize/plugin.js', 160 161 '_source/plugins/save/plugin.js', 162 '_source/plugins/filebrowser/plugin.js', 161 163 '_source/plugins/scayt/plugin.js', 162 164 '_source/plugins/smiley/plugin.js', 163 165 '_source/plugins/showblocks/plugin.js',