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 Contains the first and essential part of the {@link CKEDITOR} 8 * object definition. 9 */ 10 11 // #### Compressed Code 12 // Must be updated on changes in the script, as well as updated in the 13 // ckeditor_source.js and ckeditor_basic_source.js files. 14 15 // if (!window.CKEDITOR){window.CKEDITOR=(function(){return/**@lends CKEDITOR*/{_:{},status:'unloaded',timestamp:'',basePath:(function(){var A='';var B=document.getElementsByTagName('script');for (var i=0;i<B.length;i++){var C=B[i].src.match(/(^|.*[\\\/])ckeditor(?:_basic)?(?:_source)?.js(?:\?.*)?$/i);if (C){A=C[1];break;}};if (A.indexOf('://')==-1){if (A.indexOf('/')===0) A=location.href.match(/^.*?:\/\/[^\/]*/)[0]+A;else A=location.href.match(/^[^\?]*\//)[0]+A;};return A;})(),getUrl:function(resource){if (resource.indexOf('://')==-1&&resource.indexOf('/')!==0) resource=this.basePath+resource;if (this.timestamp) resource+=(resource.indexOf('?')>=0?'&':'?')+'t='+this.timestamp;return resource;}};})();}; 16 17 // #### Raw code 18 // ATTENTION: read the above "Compressed Code" notes when changing this code. 19 20 if ( !window.CKEDITOR ) 21 { 22 /** 23 * This is the API entry point. The entire CKEditor code runs under this object. 24 * @name CKEDITOR 25 * @namespace 26 * @example 27 */ 28 window.CKEDITOR = (function() 29 { 30 return /** @lends CKEDITOR */ { 31 32 /** 33 * A constant string unique for each release of CKEditor. Its value 34 * is used, by default, to build the URL for all resources loaded 35 * by the editor code, guaranteing clean cache results when 36 * upgrading. 37 * @type String 38 * @example 39 * alert( CKEDITOR.timestamp ); // e.g. '87dm' 40 */ 43 // The production implementation contains a fixed timestamp, unique 44 // for each release, generated by the releaser. 45 // (Base 36 value of each component of YYMMDDHH - 4 chars total - e.g. 87bm == 08071122) 46 timestamp : '9128', 48 49 /** 50 * Private object used to hold core stuff. It should not be used out of 51 * the API code as properties defined here may change at any time 52 * without notice. 53 * @private 54 */ 55 _ : {}, 56 57 /** 58 * Indicates the API loading status. The following status are available: 59 * <ul> 60 * <li><b>unloaded</b>: the API is not yet loaded.</li> 61 * <li><b>basic_loaded</b>: the basic API features are available.</li> 62 * <li><b>basic_ready</b>: the basic API is ready to load the full core code.</li> 63 * <li><b>loading</b>: the full API is being loaded.</li> 64 * <li><b>ready</b>: the API can be fully used.</li> 65 * </ul> 66 * @type String 67 * @example 68 * if ( <b>CKEDITOR.status</b> == 'ready' ) 69 * { 70 * // The API can now be fully used. 71 * } 72 */ 73 status : 'unloaded', 74 75 /** 76 * Contains the full URL for the CKEditor installation directory. 77 * @type String 78 * @example 79 * alert( <b>CKEDITOR.basePath</b> ); // "http://www.example.com/ckeditor/" (e.g.) 80 */ 81 basePath : (function() 82 { 83 // ATTENTION: fixes on this code must be ported to 84 // var basePath in "core/loader.js". 85 86 // Find out the editor directory path, based on its <script> tag. 87 var path = ''; 88 var scripts = document.getElementsByTagName( 'script' ); 89 90 for ( var i = 0 ; i < scripts.length ; i++ ) 91 { 92 var match = scripts[i].src.match( /(^|.*[\\\/])ckeditor(?:_basic)?(?:_source)?.js(?:\?.*)?$/i ); 93 94 if ( match ) 95 { 96 path = match[1]; 97 break; 98 } 99 } 100 101 // In IE (only) the script.src string is the raw valued entered in the 102 // HTML. Other browsers return the full resolved URL instead. 103 if ( path.indexOf('://') == -1 ) 104 { 105 // Absolute path. 106 if ( path.indexOf( '/' ) === 0 ) 107 path = location.href.match( /^.*?:\/\/[^\/]*/ )[0] + path; 108 // Relative path. 109 else 110 path = location.href.match( /^[^\?]*\/(?:)/ )[0] + path; 111 } 112 113 return path; 114 })(), 115 116 /** 117 * Gets the full URL for CKEditor resources. By default, URLs 118 * returned by this function contains a querystring parameter ("t") 119 * set to the {@link CKEDITOR.timestamp} value. 120 * @returns {String} The full URL. 121 * @example 122 * // e.g. http://www.example.com/ckeditor/skins/default/editor.css?t=87dm 123 * alert( CKEDITOR.getUrl( 'skins/default/editor.css' ) ); 124 * @example 125 * // e.g. http://www.example.com/skins/default/editor.css?t=87dm 126 * alert( CKEDITOR.getUrl( '/skins/default/editor.css' ) ); 127 * @example 128 * // e.g. http://www.somesite.com/skins/default/editor.css?t=87dm 129 * alert( CKEDITOR.getUrl( 'http://www.somesite.com/skins/default/editor.css' ) ); 130 */ 131 getUrl : function( resource ) 132 { 133 // If this is not a full or absolute path. 134 if ( resource.indexOf('://') == -1 && resource.indexOf( '/' ) !== 0 ) 135 resource = this.basePath + resource; 136 137 if ( this.timestamp ) 138 resource += ( resource.indexOf( '?' ) >= 0 ? '&' : '?' ) + 't=' + this.timestamp; 139 140 return resource; 141 } 142 }; 143 })(); 144 } 145 146 // PACKAGER_RENAME( CKEDITOR ) 147