Ticket #3148: 3148_2.patch
File 3148_2.patch, 4.8 KB (added by , 15 years ago) |
---|
-
_source/tests/core/plugins.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>CKEDITOR.plugins</title> 5 <link rel="stylesheet" type="text/css" href="../test.css" /> 6 <script type="text/javascript" src="../../../ckeditor_source.js"></script> <!-- %REMOVE_LINE% 7 <script type="text/javascript" src="../../ckeditor.js"></script> 8 %REMOVE_LINE% --> 9 <script type="text/javascript" src="../test.js"></script> 10 <script type="text/javascript"> 11 //<![CDATA[ 12 13 CKEDITOR.test.addTestCase( (function() 14 { 15 // Local reference to the "assert" object. 16 var assert = CKEDITOR.test.assert; 17 18 return { 19 20 /** 21 * Test loading self defined external plugin file paths. 22 */ 23 test_addExternal : function() 24 { 25 CKEDITOR.plugins.addExternal( 'myplugin', 26 '_source/' + // %REMOVE_LINE% 27 'tests/core/plugins/myplugins/sample/', 'my_plugin.js' ); 28 29 CKEDITOR.plugins.load( 'myplugin', function(){ 30 this.resume( function(){ 31 32 assert.isTrue( CKEDITOR.plugins.get( 'myplugin' ).definition ); 33 } ); 34 }, this ); 35 this.wait(); 36 }, 37 38 name : document.title 39 }; 40 })() ); 41 42 //]]> 43 </script> 44 </head> 45 <body> 46 </body> 47 </html> -
_source/tests/core/plugins/myplugins/sample/my_plugin.js
1 CKEDITOR.plugins.add( 'myplugin' , { 2 definition : true 3 } ); -
_source/core/resourcemanager.js
102 102 }, 103 103 104 104 /** 105 * Get the f ullpath for a specific loaded resource.105 * Get the folder path for a specific loaded resource. 106 106 * @param {String} name The resource name. 107 107 * @type String 108 108 * @example … … 110 110 */ 111 111 getPath : function( name ) 112 112 { 113 return this.externals[ name ] || this.basePath + name + '/'; 113 var external = this.externals[ name ] 114 return CKEDITOR.getUrl( ( external && external.dir ) || this.basePath + name + '/' ); 115 }, 116 117 /** 118 * Get the file path for a specific loaded resource. 119 * @param {String} name The resource name. 120 * @type String 121 * @example 122 * alert( <b>CKEDITOR.plugins.getFilePath( 'sample' )</b> ); // "<editor path>/plugins/sample/plugin.js" 123 */ 124 getFilePath : function( name ) 125 { 126 var external = this.externals[ name ] 127 return CKEDITOR.getUrl( 128 this.getPath( name ) + 129 ( ( external && external.file ) || ( this.fileName + '.js' ) ) ); 114 130 }, 115 131 116 132 /** 117 * Registers a resource to be loaded from an external path instead of the core base path. 133 * Registers one or more resources to be loaded from an external path 134 * instead of the core base path. 118 135 * @param {String} names The resource names, separated by commas. 119 * @param {String} path The resource external path. 136 * @param {String} path The path of the folder containing the resource. 137 * @param {String} [fileName] The resource file name. If not provided, the 138 * default name is used. 120 139 * @example 121 140 * // Loads a plugin from '/myplugin/samples/plugin.js'. 122 141 * CKEDITOR.plugins.addExternal( 'sample', '/myplugins/sample/' ); 142 * @example 143 * // Loads a plugin from '/myplugin/samples/my_plugin.js'. 144 * CKEDITOR.plugins.addExternal( 'sample', '/myplugins/sample/', 'my_plugin.js' ); 123 145 */ 124 addExternal : function( names, path )146 addExternal : function( names, path, fileName ) 125 147 { 126 148 names = names.split( ',' ); 127 149 for ( var i = 0 ; i < names.length ; i++ ) … … 127 149 for ( var i = 0 ; i < names.length ; i++ ) 128 150 { 129 151 var name = names[ i ]; 130 if ( this.registered[ name ] || this.externals[ name ] )131 throw '[CKEDITOR.resourceManager.import] The resource name "' + name + '" is already registered or imported.';132 152 133 this.externals[ name ] = path; 153 this.externals[ name ] = 154 { 155 dir : path, 156 file : fileName 157 }; 134 158 } 135 159 }, 136 160 … … 172 196 // If not available yet. 173 197 if ( !loaded[ name ] && !registered[ name ] ) 174 198 { 175 var url = CKEDITOR.getUrl( this.getPath( name ) + this.fileName + '.js');199 var url = this.getFilePath( name ); 176 200 urls.push( url ); 177 201 if ( !( url in urlsNames ) ) 178 202 urlsNames[ url ] = [];