1 /*
  2  * CKEditor - The text editor for Internet - http://ckeditor.com
  3  * Copyright (C) 2003-2008 Frederico Caldeira Knabben
  4  *
  5  * == BEGIN LICENSE ==
  6  *
  7  * Licensed under the terms of any of the following licenses at your
  8  * choice:
  9  *
 10  *  - GNU General Public License Version 2 or later (the "GPL")
 11  *    http://www.gnu.org/licenses/gpl.html
 12  *
 13  *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
 14  *    http://www.gnu.org/licenses/lgpl.html
 15  *
 16  *  - Mozilla Public License Version 1.1 or later (the "MPL")
 17  *    http://www.mozilla.org/MPL/MPL-1.1.html
 18  *
 19  * == END LICENSE ==
 20  */
 21
 22 /**
 23  * @fileOverview Contains the first and essential part of the {@link CKEDITOR}
 24  *		object definition.
 25  */
 26
 27 // #### Compressed Code
 28 // Must be updated on changes in the script, as well as updated in the
 29 // ckeditor_source.js and ckeditor_basic_source.js files.
 30
 31 // if (!window.CKEDITOR){window.CKEDITOR=(function(){var A={_:{},status:'unloaded',basePath:(function(){var B='';var C=document.getElementsByTagName('script');for (var i=0;i<C.length;i++){var D=C[i].src.match(/(^|.*[\\\/])ckeditor(?:_basic)?(?:_source)?.js(?:\?.*)?$/i);if (D){B=D[1];break;}};if (B.indexOf('://')==-1){if (B.indexOf('/')===0) B=location.href.match(/^.*?:\/\/[^\/]*/)[0]+B;else B=location.href.match(/^[^\?]*\//)[0]+B;};return B;})()};A.scriptsPath=A.basePath+'_source/';return A;})();};
 32
 33 // #### Raw code
 34 // ATTENTION: read the above "Compressed Code" notes when changing this code.
 35
 36 if ( !window.CKEDITOR )
 37 {
 38 	/**
 39 	 * This is the API entry point. The entire CKEditor code runs under this object.
 40 	 * @name CKEDITOR
 41 	 * @namespace
 42 	 * @example
 43 	 */
 44 	window.CKEDITOR = (function()
 45 	{
 46 		var CKEDITOR =
 47 		/** @lends CKEDITOR */
 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 		CKEDITOR.scriptsPath = CKEDITOR.basePath + '_source/';
118
119 		return CKEDITOR;
120 	})();
121 }
122