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.js and ckeditor_basic.js files.
 30
 31 // if (!window.CKEDITOR){window.CKEDITOR=(function(){return {_:{},status:'unloaded',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)?.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;})()};})();};
 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 		/** @lends CKEDITOR */
 47 		return {
 48 			/**
 49 			 * Private object used to hold core stuff. It should not be used out of
 50 			 * the API code as properties defined here may change at any time
 51 			 * without notice.
 52 			 * @private
 53 			 */
 54 			_ : {},
 55
 56 			/**
 57 			 * Indicates the API loading status. The following status are available:
 58 			 *		<ul>
 59 			 *			<li><b>unloaded</b>: the API is not yet loaded.</li>
 60 			 *			<li><b>basic_loaded</b>: the basic API features are available.</li>
 61 			 *			<li><b>basic_ready</b>: the basic API is ready to load the full core code.</li>
 62 			 *			<li><b>loading</b>: the full API is being loaded.</li>
 63 			 *			<li><b>ready</b>: the API can be fully used.</li>
 64 			 *		</ul>
 65 			 * @type string
 66 			 * @example
 67 			 * if ( <b>CKEDITOR.status</b> == 'ready' )
 68 			 * {
 69 			 *     // The API can now be fully used.
 70 			 * }
 71 			 */
 72 			status : 'unloaded',
 73
 74 			/**
 75 			 * Contains the full URL for the CKEditor installation directory.
 76 			 * @type string
 77 			 * @example
 78 			 * alert( <b>CKEDITOR.basePath</b> );  // "http://www.example.com/ckeditor/" (e.g.)
 79 			 */
 80 			basePath : (function()
 81 			{
 82 				// ATTENTION: fixes on this code must be ported to
 83 				// var basePath in "core/loader.js".
 84
 85 				// Find out the editor directory path, based on its <script> tag.
 86 				var path = '';
 87 				var scripts = document.getElementsByTagName( 'script' );
 88
 89 				for ( var i = 0 ; i < scripts.length ; i++ )
 90 				{
 91 					var match = scripts[i].src.match( /(^|.*[\\\/])ckeditor(?:_basic)?.js(?:\?.*)?$/i );
 92
 93 					if ( match )
 94 					{
 95 						path = match[1];
 96 						break;
 97 					}
 98 				}
 99
100 				// In IE (only) the script.src string is the raw valued entered in the
101 				// HTML. Other browsers return the full resolved URL instead.
102 				if ( path.indexOf('://') == -1 )
103 				{
104 					// Absolute path.
105 					if ( path.indexOf( '/' ) === 0 )
106 						path = location.href.match( /^.*?:\/\/[^\/]*/ )[0] + path;
107 					// Relative path.
108 					else
109 						path = location.href.match( /^[^\?]*\// )[0] + path;
110 				}
111
112 				return path;
113 			})()
114 		};
115 	})();
116 }
117