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(){var a={timestamp:'',_:{},status:'unloaded',basePath:(function(){var d=window.CKEDITOR_BASEPATH||'';if(!d){var e=document.getElementsByTagName('script');for(var f=0;f<e.length;f++){var g=e[f].src.match(/(^|.*[\\\/])ckeditor(?:_basic)?(?:_source)?.js(?:\?.*)?$/i);if(g){d=g[1];break;}}}if(d.indexOf('://')==-1)if(d.indexOf('/')===0)d=location.href.match(/^.*?:\/\/[^\/]*/)[0]+d;else d=location.href.match(/^[^\?]*\/(?:)/)[0]+d;return d;})(),getUrl:function(d){if(d.indexOf('://')==-1&&d.indexOf('/')!==0)d=this.basePath+d;if(this.timestamp&&d.charAt(d.length-1)!='/')d+=(d.indexOf('?')>=0?'&':'?')+('t=')+this.timestamp;return d;}},b=window.CKEDITOR_GETURL;if(b){var c=a.getUrl;a.getUrl=function(d){return b.call(a,d)||c.call(a,d);};}return a;})();
 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 		var CKEDITOR =
 31 		/** @lends CKEDITOR */
 32 		{
 33
 34 			/**
 35 			 * A constant string unique for each release of CKEditor. Its value
 36 			 * is used, by default, to build the URL for all resources loaded
 37 			 * by the editor code, guaranteing clean cache results when
 38 			 * upgrading.
 39 			 * @type String
 40 			 * @example
 41 			 * alert( CKEDITOR.timestamp );  // e.g. '87dm'
 42 			 */
 45 			// The production implementation contains a fixed timestamp, unique
 46 			// for each release, generated by the releaser.
 47 			// (Base 36 value of each component of YYMMDDHH - 4 chars total - e.g. 87bm == 08071122)
 48 			timestamp : '92L1',
 50
 51 			/**
 52 			 * Private object used to hold core stuff. It should not be used out of
 53 			 * the API code as properties defined here may change at any time
 54 			 * without notice.
 55 			 * @private
 56 			 */
 57 			_ : {},
 58
 59 			/**
 60 			 * Indicates the API loading status. The following status are available:
 61 			 *		<ul>
 62 			 *			<li><b>unloaded</b>: the API is not yet loaded.</li>
 63 			 *			<li><b>basic_loaded</b>: the basic API features are available.</li>
 64 			 *			<li><b>basic_ready</b>: the basic API is ready to load the full core code.</li>
 65 			 *			<li><b>loading</b>: the full API is being loaded.</li>
 66 			 *			<li><b>ready</b>: the API can be fully used.</li>
 67 			 *		</ul>
 68 			 * @type String
 69 			 * @example
 70 			 * if ( <b>CKEDITOR.status</b> == 'ready' )
 71 			 * {
 72 			 *     // The API can now be fully used.
 73 			 * }
 74 			 */
 75 			status : 'unloaded',
 76
 77 			/**
 78 			 * Contains the full URL for the CKEditor installation directory.
 79 			 * It's possible to manually provide the base path by setting a
 80 			 * global variable named CKEDITOR_BASEPATH. This global variable
 81 			 * must be set "before" the editor script loading.
 82 			 * @type String
 83 			 * @example
 84 			 * alert( <b>CKEDITOR.basePath</b> );  // "http://www.example.com/ckeditor/" (e.g.)
 85 			 */
 86 			basePath : (function()
 87 			{
 88 				// ATTENTION: fixes on this code must be ported to
 89 				// var basePath in "core/loader.js".
 90
 91 				// Find out the editor directory path, based on its <script> tag.
 92 				var path = window.CKEDITOR_BASEPATH || '';
 93
 94 				if ( !path )
 95 				{
 96 					var scripts = document.getElementsByTagName( 'script' );
 97
 98 					for ( var i = 0 ; i < scripts.length ; i++ )
 99 					{
100 						var match = scripts[i].src.match( /(^|.*[\\\/])ckeditor(?:_basic)?(?:_source)?.js(?:\?.*)?$/i );
101
102 						if ( match )
103 						{
104 							path = match[1];
105 							break;
106 						}
107 					}
108 				}
109
110 				// In IE (only) the script.src string is the raw valued entered in the
111 				// HTML. Other browsers return the full resolved URL instead.
112 				if ( path.indexOf('://') == -1 )
113 				{
114 					// Absolute path.
115 					if ( path.indexOf( '/' ) === 0 )
116 						path = location.href.match( /^.*?:\/\/[^\/]*/ )[0] + path;
117 					// Relative path.
118 					else
119 						path = location.href.match( /^[^\?]*\/(?:)/ )[0] + path;
120 				}
121
122 				return path;
123 			})(),
124
125 			/**
126 			 * Gets the full URL for CKEditor resources. By default, URLs
127 			 * returned by this function contains a querystring parameter ("t")
128 			 * set to the {@link CKEDITOR.timestamp} value.
129 			 * It's possible to provide a custom implementation to this
130 			 * function by setting a global variable named CKEDITOR_GETURL.
131 			 * This global variable must be set "before" the editor script
132 			 * loading. If the custom implementation returns nothing, the
133 			 * default implementation is used.
134 			 * @returns {String} The full URL.
135 			 * @example
136 			 * // e.g. http://www.example.com/ckeditor/skins/default/editor.css?t=87dm
137 			 * alert( CKEDITOR.getUrl( 'skins/default/editor.css' ) );
138 			 * @example
139 			 * // e.g. http://www.example.com/skins/default/editor.css?t=87dm
140 			 * alert( CKEDITOR.getUrl( '/skins/default/editor.css' ) );
141 			 * @example
142 			 * // e.g. http://www.somesite.com/skins/default/editor.css?t=87dm
143 			 * alert( CKEDITOR.getUrl( 'http://www.somesite.com/skins/default/editor.css' ) );
144 			 */
145 			getUrl : function( resource )
146 			{
147 				// If this is not a full or absolute path.
148 				if ( resource.indexOf('://') == -1 && resource.indexOf( '/' ) !== 0 )
149 					resource = this.basePath + resource;
150
151 				// Add the timestamp, except for directories.
152 				if ( this.timestamp && resource.charAt( resource.length - 1 ) != '/' )
153 					resource += ( resource.indexOf( '?' ) >= 0 ? '&' : '?' ) + 't=' + this.timestamp;
154
155 				return resource;
156 			}
157 		};
158
159 		// Make it possible to override the getUrl function with a custom
160 		// implementation pointing to a global named CKEDITOR_GETURL.
161 		var newGetUrl = window.CKEDITOR_GETURL;
162 		if ( newGetUrl )
163 		{
164 			var originalGetUrl = CKEDITOR.getUrl;
165 			CKEDITOR.getUrl = function ( resource )
166 			{
167 				return newGetUrl.call( CKEDITOR, resource ) ||
168 					originalGetUrl.call( CKEDITOR, resource );
169 			}
170 		}
171
172 		return CKEDITOR;
173 	})();
174 }
175
176 // PACKAGER_RENAME( CKEDITOR )
177