Index: /CKEditor/branches/versions/3.0.x/.htaccess
===================================================================
--- /CKEditor/branches/versions/3.0.x/.htaccess (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/.htaccess (revision 3751)
@@ -0,0 +1,24 @@
+#
+# Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+# For licensing, see LICENSE.html or http://ckeditor.com/license
+#
+
+#
+# On some specific Linux installations you could face problems with Firefox.
+# It could give you errors when loading the editor saying that some illegal
+# characters were found (three strange chars in the beginning of the file).
+# This could happen if you map the .js or .css files to PHP, for example.
+#
+# Those characters are the Byte Order Mask (BOM) of the Unicode encoded files.
+# All FCKeditor files are Unicode encoded.
+#
+
+AddType application/x-javascript .js
+AddType text/css .css
+
+#
+# If PHP is mapped to handle XML files, you could have some issues. The
+# following will disable it.
+#
+
+AddType text/xml .xml
Index: /CKEditor/branches/versions/3.0.x/CHANGES.html
===================================================================
--- /CKEditor/branches/versions/3.0.x/CHANGES.html (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/CHANGES.html (revision 3751)
@@ -0,0 +1,52 @@
+
+
+
+
+ You are not required to, but if you want to explicitly declare the license you have
+ chosen to be bound to when using, reproducing, modifying and distributing this software,
+ just include a text file titled "LEGAL" in your version of this software, indicating
+ your license choice. In any case, your choice will not restrict any recipient of
+ your version of this software to use, reproduce, modify and distribute this software
+ under any of the above licenses.
+
+
+ Sources of Intellectual Property Included in CKEditor
+
+
+ Where not otherwise indicated, all CKEditor content is authored by CKSource engineers
+ and consists of CKSource-owned intellectual property. In some specific instances,
+ CKEditor will incorporate work done by developers outside of CKSource with their
+ express permission.
+
+ CKEditor is a trademark of CKSource - Frederico Knabben. All other brand and product
+ names are trademarks, registered trademarks or service marks of their respective
+ holders.
+
+
+
Index: /CKEditor/branches/versions/3.0.x/_dev/_thirdparty/console_getopt/Getopt.php
===================================================================
--- /CKEditor/branches/versions/3.0.x/_dev/_thirdparty/console_getopt/Getopt.php (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_dev/_thirdparty/console_getopt/Getopt.php (revision 3751)
@@ -0,0 +1,290 @@
+ |
+// +----------------------------------------------------------------------+
+//
+// $Id: Getopt.php,v 1.4 2007/06/12 14:58:56 cellog Exp $
+
+require_once 'PEAR.php';
+
+/**
+ * Command-line options parsing class.
+ *
+ * @author Andrei Zmievski
+ *
+ */
+class Console_Getopt {
+ /**
+ * Parses the command-line options.
+ *
+ * The first parameter to this function should be the list of command-line
+ * arguments without the leading reference to the running program.
+ *
+ * The second parameter is a string of allowed short options. Each of the
+ * option letters can be followed by a colon ':' to specify that the option
+ * requires an argument, or a double colon '::' to specify that the option
+ * takes an optional argument.
+ *
+ * The third argument is an optional array of allowed long options. The
+ * leading '--' should not be included in the option name. Options that
+ * require an argument should be followed by '=', and options that take an
+ * option argument should be followed by '=='.
+ *
+ * The return value is an array of two elements: the list of parsed
+ * options and the list of non-option command-line arguments. Each entry in
+ * the list of parsed options is a pair of elements - the first one
+ * specifies the option, and the second one specifies the option argument,
+ * if there was one.
+ *
+ * Long and short options can be mixed.
+ *
+ * Most of the semantics of this function are based on GNU getopt_long().
+ *
+ * @param array $args an array of command-line arguments
+ * @param string $short_options specifies the list of allowed short options
+ * @param array $long_options specifies the list of allowed long options
+ *
+ * @return array two-element array containing the list of parsed options and
+ * the non-option arguments
+ *
+ * @access public
+ *
+ */
+ function getopt2($args, $short_options, $long_options = null)
+ {
+ return Console_Getopt::doGetopt(2, $args, $short_options, $long_options);
+ }
+
+ /**
+ * This function expects $args to start with the script name (POSIX-style).
+ * Preserved for backwards compatibility.
+ * @see getopt2()
+ */
+ function getopt($args, $short_options, $long_options = null)
+ {
+ return Console_Getopt::doGetopt(1, $args, $short_options, $long_options);
+ }
+
+ /**
+ * The actual implementation of the argument parsing code.
+ */
+ function doGetopt($version, $args, $short_options, $long_options = null)
+ {
+ // in case you pass directly readPHPArgv() as the first arg
+ if (PEAR::isError($args)) {
+ return $args;
+ }
+ if (empty($args)) {
+ return array(array(), array());
+ }
+ $opts = array();
+ $non_opts = array();
+
+ settype($args, 'array');
+
+ if ($long_options) {
+ sort($long_options);
+ }
+
+ /*
+ * Preserve backwards compatibility with callers that relied on
+ * erroneous POSIX fix.
+ */
+ if ($version < 2) {
+ if (isset($args[0]{0}) && $args[0]{0} != '-') {
+ array_shift($args);
+ }
+ }
+
+ reset($args);
+ while (list($i, $arg) = each($args)) {
+
+ /* The special element '--' means explicit end of
+ options. Treat the rest of the arguments as non-options
+ and end the loop. */
+ if ($arg == '--') {
+ $non_opts = array_merge($non_opts, array_slice($args, $i + 1));
+ break;
+ }
+
+ if ($arg{0} != '-' || (strlen($arg) > 1 && $arg{1} == '-' && !$long_options)) {
+ $non_opts = array_merge($non_opts, array_slice($args, $i));
+ break;
+ } elseif (strlen($arg) > 1 && $arg{1} == '-') {
+ $error = Console_Getopt::_parseLongOption(substr($arg, 2), $long_options, $opts, $args);
+ if (PEAR::isError($error))
+ return $error;
+ } elseif ($arg == '-') {
+ // - is stdin
+ $non_opts = array_merge($non_opts, array_slice($args, $i));
+ break;
+ } else {
+ $error = Console_Getopt::_parseShortOption(substr($arg, 1), $short_options, $opts, $args);
+ if (PEAR::isError($error))
+ return $error;
+ }
+ }
+
+ return array($opts, $non_opts);
+ }
+
+ /**
+ * @access private
+ *
+ */
+ function _parseShortOption($arg, $short_options, &$opts, &$args)
+ {
+ for ($i = 0; $i < strlen($arg); $i++) {
+ $opt = $arg{$i};
+ $opt_arg = null;
+
+ /* Try to find the short option in the specifier string. */
+ if (($spec = strstr($short_options, $opt)) === false || $arg{$i} == ':')
+ {
+ return PEAR::raiseError("Console_Getopt: unrecognized option -- $opt");
+ }
+
+ if (strlen($spec) > 1 && $spec{1} == ':') {
+ if (strlen($spec) > 2 && $spec{2} == ':') {
+ if ($i + 1 < strlen($arg)) {
+ /* Option takes an optional argument. Use the remainder of
+ the arg string if there is anything left. */
+ $opts[] = array($opt, substr($arg, $i + 1));
+ break;
+ }
+ } else {
+ /* Option requires an argument. Use the remainder of the arg
+ string if there is anything left. */
+ if ($i + 1 < strlen($arg)) {
+ $opts[] = array($opt, substr($arg, $i + 1));
+ break;
+ } else if (list(, $opt_arg) = each($args)) {
+ /* Else use the next argument. */;
+ if (Console_Getopt::_isShortOpt($opt_arg) || Console_Getopt::_isLongOpt($opt_arg)) {
+ return PEAR::raiseError("Console_Getopt: option requires an argument -- $opt");
+ }
+ } else {
+ return PEAR::raiseError("Console_Getopt: option requires an argument -- $opt");
+ }
+ }
+ }
+
+ $opts[] = array($opt, $opt_arg);
+ }
+ }
+
+ /**
+ * @access private
+ *
+ */
+ function _isShortOpt($arg)
+ {
+ return strlen($arg) == 2 && $arg[0] == '-' && preg_match('/[a-zA-Z]/', $arg[1]);
+ }
+
+ /**
+ * @access private
+ *
+ */
+ function _isLongOpt($arg)
+ {
+ return strlen($arg) > 2 && $arg[0] == '-' && $arg[1] == '-' &&
+ preg_match('/[a-zA-Z]+$/', substr($arg, 2));
+ }
+
+ /**
+ * @access private
+ *
+ */
+ function _parseLongOption($arg, $long_options, &$opts, &$args)
+ {
+ @list($opt, $opt_arg) = explode('=', $arg, 2);
+ $opt_len = strlen($opt);
+
+ for ($i = 0; $i < count($long_options); $i++) {
+ $long_opt = $long_options[$i];
+ $opt_start = substr($long_opt, 0, $opt_len);
+ $long_opt_name = str_replace('=', '', $long_opt);
+
+ /* Option doesn't match. Go on to the next one. */
+ if ($long_opt_name != $opt) {
+ continue;
+ }
+
+ $opt_rest = substr($long_opt, $opt_len);
+
+ /* Check that the options uniquely matches one of the allowed
+ options. */
+ if ($i + 1 < count($long_options)) {
+ $next_option_rest = substr($long_options[$i + 1], $opt_len);
+ } else {
+ $next_option_rest = '';
+ }
+ if ($opt_rest != '' && $opt{0} != '=' &&
+ $i + 1 < count($long_options) &&
+ $opt == substr($long_options[$i+1], 0, $opt_len) &&
+ $next_option_rest != '' &&
+ $next_option_rest{0} != '=') {
+ return PEAR::raiseError("Console_Getopt: option --$opt is ambiguous");
+ }
+
+ if (substr($long_opt, -1) == '=') {
+ if (substr($long_opt, -2) != '==') {
+ /* Long option requires an argument.
+ Take the next argument if one wasn't specified. */;
+ if (!strlen($opt_arg) && !(list(, $opt_arg) = each($args))) {
+ return PEAR::raiseError("Console_Getopt: option --$opt requires an argument");
+ }
+ if (Console_Getopt::_isShortOpt($opt_arg) || Console_Getopt::_isLongOpt($opt_arg)) {
+ return PEAR::raiseError("Console_Getopt: option requires an argument --$opt");
+ }
+ }
+ } else if ($opt_arg) {
+ return PEAR::raiseError("Console_Getopt: option --$opt doesn't allow an argument");
+ }
+
+ $opts[] = array('--' . $opt, $opt_arg);
+ return;
+ }
+
+ return PEAR::raiseError("Console_Getopt: unrecognized option --$opt");
+ }
+
+ /**
+ * Safely read the $argv PHP array across different PHP configurations.
+ * Will take care on register_globals and register_argc_argv ini directives
+ *
+ * @access public
+ * @return mixed the $argv PHP array or PEAR error if not registered
+ */
+ function readPHPArgv()
+ {
+ global $argv;
+ if (!is_array($argv)) {
+ if (!@is_array($_SERVER['argv'])) {
+ if (!@is_array($GLOBALS['HTTP_SERVER_VARS']['argv'])) {
+ return PEAR::raiseError("Console_Getopt: Could not read cmd args (register_argc_argv=Off?)");
+ }
+ return $GLOBALS['HTTP_SERVER_VARS']['argv'];
+ }
+ return $_SERVER['argv'];
+ }
+ return $argv;
+ }
+
+}
+
+?>
Index: /CKEditor/branches/versions/3.0.x/_dev/_thirdparty/console_getopt/PEAR.php
===================================================================
--- /CKEditor/branches/versions/3.0.x/_dev/_thirdparty/console_getopt/PEAR.php (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_dev/_thirdparty/console_getopt/PEAR.php (revision 3751)
@@ -0,0 +1,1118 @@
+
+ * @author Stig Bakken
+ * @author Tomas V.V.Cox
+ * @author Greg Beaver
+ * @copyright 1997-2008 The PHP Group
+ * @license http://www.php.net/license/3_0.txt PHP License 3.0
+ * @version CVS: $Id: PEAR.php,v 1.104 2008/01/03 20:26:34 cellog Exp $
+ * @link http://pear.php.net/package/PEAR
+ * @since File available since Release 0.1
+ */
+
+/**#@+
+ * ERROR constants
+ */
+define('PEAR_ERROR_RETURN', 1);
+define('PEAR_ERROR_PRINT', 2);
+define('PEAR_ERROR_TRIGGER', 4);
+define('PEAR_ERROR_DIE', 8);
+define('PEAR_ERROR_CALLBACK', 16);
+/**
+ * WARNING: obsolete
+ * @deprecated
+ */
+define('PEAR_ERROR_EXCEPTION', 32);
+/**#@-*/
+define('PEAR_ZE2', (function_exists('version_compare') &&
+ version_compare(zend_version(), "2-dev", "ge")));
+
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ define('OS_WINDOWS', true);
+ define('OS_UNIX', false);
+ define('PEAR_OS', 'Windows');
+} else {
+ define('OS_WINDOWS', false);
+ define('OS_UNIX', true);
+ define('PEAR_OS', 'Unix'); // blatant assumption
+}
+
+// instant backwards compatibility
+if (!defined('PATH_SEPARATOR')) {
+ if (OS_WINDOWS) {
+ define('PATH_SEPARATOR', ';');
+ } else {
+ define('PATH_SEPARATOR', ':');
+ }
+}
+
+$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN;
+$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE;
+$GLOBALS['_PEAR_destructor_object_list'] = array();
+$GLOBALS['_PEAR_shutdown_funcs'] = array();
+$GLOBALS['_PEAR_error_handler_stack'] = array();
+
+@ini_set('track_errors', true);
+
+/**
+ * Base class for other PEAR classes. Provides rudimentary
+ * emulation of destructors.
+ *
+ * If you want a destructor in your class, inherit PEAR and make a
+ * destructor method called _yourclassname (same name as the
+ * constructor, but with a "_" prefix). Also, in your constructor you
+ * have to call the PEAR constructor: $this->PEAR();.
+ * The destructor method will be called without parameters. Note that
+ * at in some SAPI implementations (such as Apache), any output during
+ * the request shutdown (in which destructors are called) seems to be
+ * discarded. If you need to get any debug information from your
+ * destructor, use error_log(), syslog() or something similar.
+ *
+ * IMPORTANT! To use the emulated destructors you need to create the
+ * objects by reference: $obj =& new PEAR_child;
+ *
+ * @category pear
+ * @package PEAR
+ * @author Stig Bakken
+ * @author Tomas V.V. Cox
+ * @author Greg Beaver
+ * @copyright 1997-2006 The PHP Group
+ * @license http://www.php.net/license/3_0.txt PHP License 3.0
+ * @version Release: 1.7.1
+ * @link http://pear.php.net/package/PEAR
+ * @see PEAR_Error
+ * @since Class available since PHP 4.0.2
+ * @link http://pear.php.net/manual/en/core.pear.php#core.pear.pear
+ */
+class PEAR
+{
+ // {{{ properties
+
+ /**
+ * Whether to enable internal debug messages.
+ *
+ * @var bool
+ * @access private
+ */
+ var $_debug = false;
+
+ /**
+ * Default error mode for this object.
+ *
+ * @var int
+ * @access private
+ */
+ var $_default_error_mode = null;
+
+ /**
+ * Default error options used for this object when error mode
+ * is PEAR_ERROR_TRIGGER.
+ *
+ * @var int
+ * @access private
+ */
+ var $_default_error_options = null;
+
+ /**
+ * Default error handler (callback) for this object, if error mode is
+ * PEAR_ERROR_CALLBACK.
+ *
+ * @var string
+ * @access private
+ */
+ var $_default_error_handler = '';
+
+ /**
+ * Which class to use for error objects.
+ *
+ * @var string
+ * @access private
+ */
+ var $_error_class = 'PEAR_Error';
+
+ /**
+ * An array of expected errors.
+ *
+ * @var array
+ * @access private
+ */
+ var $_expected_errors = array();
+
+ // }}}
+
+ // {{{ constructor
+
+ /**
+ * Constructor. Registers this object in
+ * $_PEAR_destructor_object_list for destructor emulation if a
+ * destructor object exists.
+ *
+ * @param string $error_class (optional) which class to use for
+ * error objects, defaults to PEAR_Error.
+ * @access public
+ * @return void
+ */
+ function PEAR($error_class = null)
+ {
+ $classname = strtolower(get_class($this));
+ if ($this->_debug) {
+ print "PEAR constructor called, class=$classname\n";
+ }
+ if ($error_class !== null) {
+ $this->_error_class = $error_class;
+ }
+ while ($classname && strcasecmp($classname, "pear")) {
+ $destructor = "_$classname";
+ if (method_exists($this, $destructor)) {
+ global $_PEAR_destructor_object_list;
+ $_PEAR_destructor_object_list[] = &$this;
+ if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {
+ register_shutdown_function("_PEAR_call_destructors");
+ $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;
+ }
+ break;
+ } else {
+ $classname = get_parent_class($classname);
+ }
+ }
+ }
+
+ // }}}
+ // {{{ destructor
+
+ /**
+ * Destructor (the emulated type of...). Does nothing right now,
+ * but is included for forward compatibility, so subclass
+ * destructors should always call it.
+ *
+ * See the note in the class desciption about output from
+ * destructors.
+ *
+ * @access public
+ * @return void
+ */
+ function _PEAR() {
+ if ($this->_debug) {
+ printf("PEAR destructor called, class=%s\n", strtolower(get_class($this)));
+ }
+ }
+
+ // }}}
+ // {{{ getStaticProperty()
+
+ /**
+ * If you have a class that's mostly/entirely static, and you need static
+ * properties, you can use this method to simulate them. Eg. in your method(s)
+ * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar');
+ * You MUST use a reference, or they will not persist!
+ *
+ * @access public
+ * @param string $class The calling classname, to prevent clashes
+ * @param string $var The variable to retrieve.
+ * @return mixed A reference to the variable. If not set it will be
+ * auto initialised to NULL.
+ */
+ function &getStaticProperty($class, $var)
+ {
+ static $properties;
+ if (!isset($properties[$class])) {
+ $properties[$class] = array();
+ }
+ if (!array_key_exists($var, $properties[$class])) {
+ $properties[$class][$var] = null;
+ }
+ return $properties[$class][$var];
+ }
+
+ // }}}
+ // {{{ registerShutdownFunc()
+
+ /**
+ * Use this function to register a shutdown method for static
+ * classes.
+ *
+ * @access public
+ * @param mixed $func The function name (or array of class/method) to call
+ * @param mixed $args The arguments to pass to the function
+ * @return void
+ */
+ function registerShutdownFunc($func, $args = array())
+ {
+ // if we are called statically, there is a potential
+ // that no shutdown func is registered. Bug #6445
+ if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {
+ register_shutdown_function("_PEAR_call_destructors");
+ $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;
+ }
+ $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args);
+ }
+
+ // }}}
+ // {{{ isError()
+
+ /**
+ * Tell whether a value is a PEAR error.
+ *
+ * @param mixed $data the value to test
+ * @param int $code if $data is an error object, return true
+ * only if $code is a string and
+ * $obj->getMessage() == $code or
+ * $code is an integer and $obj->getCode() == $code
+ * @access public
+ * @return bool true if parameter is an error
+ */
+ function isError($data, $code = null)
+ {
+ if (is_a($data, 'PEAR_Error')) {
+ if (is_null($code)) {
+ return true;
+ } elseif (is_string($code)) {
+ return $data->getMessage() == $code;
+ } else {
+ return $data->getCode() == $code;
+ }
+ }
+ return false;
+ }
+
+ // }}}
+ // {{{ setErrorHandling()
+
+ /**
+ * Sets how errors generated by this object should be handled.
+ * Can be invoked both in objects and statically. If called
+ * statically, setErrorHandling sets the default behaviour for all
+ * PEAR objects. If called in an object, setErrorHandling sets
+ * the default behaviour for that object.
+ *
+ * @param int $mode
+ * One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
+ * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,
+ * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION.
+ *
+ * @param mixed $options
+ * When $mode is PEAR_ERROR_TRIGGER, this is the error level (one
+ * of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
+ *
+ * When $mode is PEAR_ERROR_CALLBACK, this parameter is expected
+ * to be the callback function or method. A callback
+ * function is a string with the name of the function, a
+ * callback method is an array of two elements: the element
+ * at index 0 is the object, and the element at index 1 is
+ * the name of the method to call in the object.
+ *
+ * When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is
+ * a printf format string used when printing the error
+ * message.
+ *
+ * @access public
+ * @return void
+ * @see PEAR_ERROR_RETURN
+ * @see PEAR_ERROR_PRINT
+ * @see PEAR_ERROR_TRIGGER
+ * @see PEAR_ERROR_DIE
+ * @see PEAR_ERROR_CALLBACK
+ * @see PEAR_ERROR_EXCEPTION
+ *
+ * @since PHP 4.0.5
+ */
+
+ function setErrorHandling($mode = null, $options = null)
+ {
+ if (isset($this) && is_a($this, 'PEAR')) {
+ $setmode = &$this->_default_error_mode;
+ $setoptions = &$this->_default_error_options;
+ } else {
+ $setmode = &$GLOBALS['_PEAR_default_error_mode'];
+ $setoptions = &$GLOBALS['_PEAR_default_error_options'];
+ }
+
+ switch ($mode) {
+ case PEAR_ERROR_EXCEPTION:
+ case PEAR_ERROR_RETURN:
+ case PEAR_ERROR_PRINT:
+ case PEAR_ERROR_TRIGGER:
+ case PEAR_ERROR_DIE:
+ case null:
+ $setmode = $mode;
+ $setoptions = $options;
+ break;
+
+ case PEAR_ERROR_CALLBACK:
+ $setmode = $mode;
+ // class/object method callback
+ if (is_callable($options)) {
+ $setoptions = $options;
+ } else {
+ trigger_error("invalid error callback", E_USER_WARNING);
+ }
+ break;
+
+ default:
+ trigger_error("invalid error mode", E_USER_WARNING);
+ break;
+ }
+ }
+
+ // }}}
+ // {{{ expectError()
+
+ /**
+ * This method is used to tell which errors you expect to get.
+ * Expected errors are always returned with error mode
+ * PEAR_ERROR_RETURN. Expected error codes are stored in a stack,
+ * and this method pushes a new element onto it. The list of
+ * expected errors are in effect until they are popped off the
+ * stack with the popExpect() method.
+ *
+ * Note that this method can not be called statically
+ *
+ * @param mixed $code a single error code or an array of error codes to expect
+ *
+ * @return int the new depth of the "expected errors" stack
+ * @access public
+ */
+ function expectError($code = '*')
+ {
+ if (is_array($code)) {
+ array_push($this->_expected_errors, $code);
+ } else {
+ array_push($this->_expected_errors, array($code));
+ }
+ return sizeof($this->_expected_errors);
+ }
+
+ // }}}
+ // {{{ popExpect()
+
+ /**
+ * This method pops one element off the expected error codes
+ * stack.
+ *
+ * @return array the list of error codes that were popped
+ */
+ function popExpect()
+ {
+ return array_pop($this->_expected_errors);
+ }
+
+ // }}}
+ // {{{ _checkDelExpect()
+
+ /**
+ * This method checks unsets an error code if available
+ *
+ * @param mixed error code
+ * @return bool true if the error code was unset, false otherwise
+ * @access private
+ * @since PHP 4.3.0
+ */
+ function _checkDelExpect($error_code)
+ {
+ $deleted = false;
+
+ foreach ($this->_expected_errors AS $key => $error_array) {
+ if (in_array($error_code, $error_array)) {
+ unset($this->_expected_errors[$key][array_search($error_code, $error_array)]);
+ $deleted = true;
+ }
+
+ // clean up empty arrays
+ if (0 == count($this->_expected_errors[$key])) {
+ unset($this->_expected_errors[$key]);
+ }
+ }
+ return $deleted;
+ }
+
+ // }}}
+ // {{{ delExpect()
+
+ /**
+ * This method deletes all occurences of the specified element from
+ * the expected error codes stack.
+ *
+ * @param mixed $error_code error code that should be deleted
+ * @return mixed list of error codes that were deleted or error
+ * @access public
+ * @since PHP 4.3.0
+ */
+ function delExpect($error_code)
+ {
+ $deleted = false;
+
+ if ((is_array($error_code) && (0 != count($error_code)))) {
+ // $error_code is a non-empty array here;
+ // we walk through it trying to unset all
+ // values
+ foreach($error_code as $key => $error) {
+ if ($this->_checkDelExpect($error)) {
+ $deleted = true;
+ } else {
+ $deleted = false;
+ }
+ }
+ return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
+ } elseif (!empty($error_code)) {
+ // $error_code comes alone, trying to unset it
+ if ($this->_checkDelExpect($error_code)) {
+ return true;
+ } else {
+ return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
+ }
+ } else {
+ // $error_code is empty
+ return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME
+ }
+ }
+
+ // }}}
+ // {{{ raiseError()
+
+ /**
+ * This method is a wrapper that returns an instance of the
+ * configured error class with this object's default error
+ * handling applied. If the $mode and $options parameters are not
+ * specified, the object's defaults are used.
+ *
+ * @param mixed $message a text error message or a PEAR error object
+ *
+ * @param int $code a numeric error code (it is up to your class
+ * to define these if you want to use codes)
+ *
+ * @param int $mode One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
+ * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,
+ * PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION.
+ *
+ * @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter
+ * specifies the PHP-internal error level (one of
+ * E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
+ * If $mode is PEAR_ERROR_CALLBACK, this
+ * parameter specifies the callback function or
+ * method. In other error modes this parameter
+ * is ignored.
+ *
+ * @param string $userinfo If you need to pass along for example debug
+ * information, this parameter is meant for that.
+ *
+ * @param string $error_class The returned error object will be
+ * instantiated from this class, if specified.
+ *
+ * @param bool $skipmsg If true, raiseError will only pass error codes,
+ * the error message parameter will be dropped.
+ *
+ * @access public
+ * @return object a PEAR error object
+ * @see PEAR::setErrorHandling
+ * @since PHP 4.0.5
+ */
+ function &raiseError($message = null,
+ $code = null,
+ $mode = null,
+ $options = null,
+ $userinfo = null,
+ $error_class = null,
+ $skipmsg = false)
+ {
+ // The error is yet a PEAR error object
+ if (is_object($message)) {
+ $code = $message->getCode();
+ $userinfo = $message->getUserInfo();
+ $error_class = $message->getType();
+ $message->error_message_prefix = '';
+ $message = $message->getMessage();
+ }
+
+ if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) {
+ if ($exp[0] == "*" ||
+ (is_int(reset($exp)) && in_array($code, $exp)) ||
+ (is_string(reset($exp)) && in_array($message, $exp))) {
+ $mode = PEAR_ERROR_RETURN;
+ }
+ }
+ // No mode given, try global ones
+ if ($mode === null) {
+ // Class error handler
+ if (isset($this) && isset($this->_default_error_mode)) {
+ $mode = $this->_default_error_mode;
+ $options = $this->_default_error_options;
+ // Global error handler
+ } elseif (isset($GLOBALS['_PEAR_default_error_mode'])) {
+ $mode = $GLOBALS['_PEAR_default_error_mode'];
+ $options = $GLOBALS['_PEAR_default_error_options'];
+ }
+ }
+
+ if ($error_class !== null) {
+ $ec = $error_class;
+ } elseif (isset($this) && isset($this->_error_class)) {
+ $ec = $this->_error_class;
+ } else {
+ $ec = 'PEAR_Error';
+ }
+ if (intval(PHP_VERSION) < 5) {
+ // little non-eval hack to fix bug #12147
+ include 'PEAR/FixPHP5PEARWarnings.php';
+ return $a;
+ }
+ if ($skipmsg) {
+ $a = new $ec($code, $mode, $options, $userinfo);
+ } else {
+ $a = new $ec($message, $code, $mode, $options, $userinfo);
+ }
+ return $a;
+ }
+
+ // }}}
+ // {{{ throwError()
+
+ /**
+ * Simpler form of raiseError with fewer options. In most cases
+ * message, code and userinfo are enough.
+ *
+ * @param string $message
+ *
+ */
+ function &throwError($message = null,
+ $code = null,
+ $userinfo = null)
+ {
+ if (isset($this) && is_a($this, 'PEAR')) {
+ $a = &$this->raiseError($message, $code, null, null, $userinfo);
+ return $a;
+ } else {
+ $a = &PEAR::raiseError($message, $code, null, null, $userinfo);
+ return $a;
+ }
+ }
+
+ // }}}
+ function staticPushErrorHandling($mode, $options = null)
+ {
+ $stack = &$GLOBALS['_PEAR_error_handler_stack'];
+ $def_mode = &$GLOBALS['_PEAR_default_error_mode'];
+ $def_options = &$GLOBALS['_PEAR_default_error_options'];
+ $stack[] = array($def_mode, $def_options);
+ switch ($mode) {
+ case PEAR_ERROR_EXCEPTION:
+ case PEAR_ERROR_RETURN:
+ case PEAR_ERROR_PRINT:
+ case PEAR_ERROR_TRIGGER:
+ case PEAR_ERROR_DIE:
+ case null:
+ $def_mode = $mode;
+ $def_options = $options;
+ break;
+
+ case PEAR_ERROR_CALLBACK:
+ $def_mode = $mode;
+ // class/object method callback
+ if (is_callable($options)) {
+ $def_options = $options;
+ } else {
+ trigger_error("invalid error callback", E_USER_WARNING);
+ }
+ break;
+
+ default:
+ trigger_error("invalid error mode", E_USER_WARNING);
+ break;
+ }
+ $stack[] = array($mode, $options);
+ return true;
+ }
+
+ function staticPopErrorHandling()
+ {
+ $stack = &$GLOBALS['_PEAR_error_handler_stack'];
+ $setmode = &$GLOBALS['_PEAR_default_error_mode'];
+ $setoptions = &$GLOBALS['_PEAR_default_error_options'];
+ array_pop($stack);
+ list($mode, $options) = $stack[sizeof($stack) - 1];
+ array_pop($stack);
+ switch ($mode) {
+ case PEAR_ERROR_EXCEPTION:
+ case PEAR_ERROR_RETURN:
+ case PEAR_ERROR_PRINT:
+ case PEAR_ERROR_TRIGGER:
+ case PEAR_ERROR_DIE:
+ case null:
+ $setmode = $mode;
+ $setoptions = $options;
+ break;
+
+ case PEAR_ERROR_CALLBACK:
+ $setmode = $mode;
+ // class/object method callback
+ if (is_callable($options)) {
+ $setoptions = $options;
+ } else {
+ trigger_error("invalid error callback", E_USER_WARNING);
+ }
+ break;
+
+ default:
+ trigger_error("invalid error mode", E_USER_WARNING);
+ break;
+ }
+ return true;
+ }
+
+ // {{{ pushErrorHandling()
+
+ /**
+ * Push a new error handler on top of the error handler options stack. With this
+ * you can easily override the actual error handler for some code and restore
+ * it later with popErrorHandling.
+ *
+ * @param mixed $mode (same as setErrorHandling)
+ * @param mixed $options (same as setErrorHandling)
+ *
+ * @return bool Always true
+ *
+ * @see PEAR::setErrorHandling
+ */
+ function pushErrorHandling($mode, $options = null)
+ {
+ $stack = &$GLOBALS['_PEAR_error_handler_stack'];
+ if (isset($this) && is_a($this, 'PEAR')) {
+ $def_mode = &$this->_default_error_mode;
+ $def_options = &$this->_default_error_options;
+ } else {
+ $def_mode = &$GLOBALS['_PEAR_default_error_mode'];
+ $def_options = &$GLOBALS['_PEAR_default_error_options'];
+ }
+ $stack[] = array($def_mode, $def_options);
+
+ if (isset($this) && is_a($this, 'PEAR')) {
+ $this->setErrorHandling($mode, $options);
+ } else {
+ PEAR::setErrorHandling($mode, $options);
+ }
+ $stack[] = array($mode, $options);
+ return true;
+ }
+
+ // }}}
+ // {{{ popErrorHandling()
+
+ /**
+ * Pop the last error handler used
+ *
+ * @return bool Always true
+ *
+ * @see PEAR::pushErrorHandling
+ */
+ function popErrorHandling()
+ {
+ $stack = &$GLOBALS['_PEAR_error_handler_stack'];
+ array_pop($stack);
+ list($mode, $options) = $stack[sizeof($stack) - 1];
+ array_pop($stack);
+ if (isset($this) && is_a($this, 'PEAR')) {
+ $this->setErrorHandling($mode, $options);
+ } else {
+ PEAR::setErrorHandling($mode, $options);
+ }
+ return true;
+ }
+
+ // }}}
+ // {{{ loadExtension()
+
+ /**
+ * OS independant PHP extension load. Remember to take care
+ * on the correct extension name for case sensitive OSes.
+ *
+ * @param string $ext The extension name
+ * @return bool Success or not on the dl() call
+ */
+ function loadExtension($ext)
+ {
+ if (!extension_loaded($ext)) {
+ // if either returns true dl() will produce a FATAL error, stop that
+ if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) {
+ return false;
+ }
+ if (OS_WINDOWS) {
+ $suffix = '.dll';
+ } elseif (PHP_OS == 'HP-UX') {
+ $suffix = '.sl';
+ } elseif (PHP_OS == 'AIX') {
+ $suffix = '.a';
+ } elseif (PHP_OS == 'OSX') {
+ $suffix = '.bundle';
+ } else {
+ $suffix = '.so';
+ }
+ return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix);
+ }
+ return true;
+ }
+
+ // }}}
+}
+
+// {{{ _PEAR_call_destructors()
+
+function _PEAR_call_destructors()
+{
+ global $_PEAR_destructor_object_list;
+ if (is_array($_PEAR_destructor_object_list) &&
+ sizeof($_PEAR_destructor_object_list))
+ {
+ reset($_PEAR_destructor_object_list);
+ if (PEAR::getStaticProperty('PEAR', 'destructlifo')) {
+ $_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list);
+ }
+ while (list($k, $objref) = each($_PEAR_destructor_object_list)) {
+ $classname = get_class($objref);
+ while ($classname) {
+ $destructor = "_$classname";
+ if (method_exists($objref, $destructor)) {
+ $objref->$destructor();
+ break;
+ } else {
+ $classname = get_parent_class($classname);
+ }
+ }
+ }
+ // Empty the object list to ensure that destructors are
+ // not called more than once.
+ $_PEAR_destructor_object_list = array();
+ }
+
+ // Now call the shutdown functions
+ if (is_array($GLOBALS['_PEAR_shutdown_funcs']) AND !empty($GLOBALS['_PEAR_shutdown_funcs'])) {
+ foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) {
+ call_user_func_array($value[0], $value[1]);
+ }
+ }
+}
+
+// }}}
+/**
+ * Standard PEAR error class for PHP 4
+ *
+ * This class is supserseded by {@link PEAR_Exception} in PHP 5
+ *
+ * @category pear
+ * @package PEAR
+ * @author Stig Bakken
+ * @author Tomas V.V. Cox
+ * @author Gregory Beaver
+ * @copyright 1997-2006 The PHP Group
+ * @license http://www.php.net/license/3_0.txt PHP License 3.0
+ * @version Release: 1.7.1
+ * @link http://pear.php.net/manual/en/core.pear.pear-error.php
+ * @see PEAR::raiseError(), PEAR::throwError()
+ * @since Class available since PHP 4.0.2
+ */
+class PEAR_Error
+{
+ // {{{ properties
+
+ var $error_message_prefix = '';
+ var $mode = PEAR_ERROR_RETURN;
+ var $level = E_USER_NOTICE;
+ var $code = -1;
+ var $message = '';
+ var $userinfo = '';
+ var $backtrace = null;
+
+ // }}}
+ // {{{ constructor
+
+ /**
+ * PEAR_Error constructor
+ *
+ * @param string $message message
+ *
+ * @param int $code (optional) error code
+ *
+ * @param int $mode (optional) error mode, one of: PEAR_ERROR_RETURN,
+ * PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER,
+ * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION
+ *
+ * @param mixed $options (optional) error level, _OR_ in the case of
+ * PEAR_ERROR_CALLBACK, the callback function or object/method
+ * tuple.
+ *
+ * @param string $userinfo (optional) additional user/debug info
+ *
+ * @access public
+ *
+ */
+ function PEAR_Error($message = 'unknown error', $code = null,
+ $mode = null, $options = null, $userinfo = null)
+ {
+ if ($mode === null) {
+ $mode = PEAR_ERROR_RETURN;
+ }
+ $this->message = $message;
+ $this->code = $code;
+ $this->mode = $mode;
+ $this->userinfo = $userinfo;
+ if (!PEAR::getStaticProperty('PEAR_Error', 'skiptrace')) {
+ $this->backtrace = debug_backtrace();
+ if (isset($this->backtrace[0]) && isset($this->backtrace[0]['object'])) {
+ unset($this->backtrace[0]['object']);
+ }
+ }
+ if ($mode & PEAR_ERROR_CALLBACK) {
+ $this->level = E_USER_NOTICE;
+ $this->callback = $options;
+ } else {
+ if ($options === null) {
+ $options = E_USER_NOTICE;
+ }
+ $this->level = $options;
+ $this->callback = null;
+ }
+ if ($this->mode & PEAR_ERROR_PRINT) {
+ if (is_null($options) || is_int($options)) {
+ $format = "%s";
+ } else {
+ $format = $options;
+ }
+ printf($format, $this->getMessage());
+ }
+ if ($this->mode & PEAR_ERROR_TRIGGER) {
+ trigger_error($this->getMessage(), $this->level);
+ }
+ if ($this->mode & PEAR_ERROR_DIE) {
+ $msg = $this->getMessage();
+ if (is_null($options) || is_int($options)) {
+ $format = "%s";
+ if (substr($msg, -1) != "\n") {
+ $msg .= "\n";
+ }
+ } else {
+ $format = $options;
+ }
+ die(sprintf($format, $msg));
+ }
+ if ($this->mode & PEAR_ERROR_CALLBACK) {
+ if (is_callable($this->callback)) {
+ call_user_func($this->callback, $this);
+ }
+ }
+ if ($this->mode & PEAR_ERROR_EXCEPTION) {
+ trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING);
+ eval('$e = new Exception($this->message, $this->code);throw($e);');
+ }
+ }
+
+ // }}}
+ // {{{ getMode()
+
+ /**
+ * Get the error mode from an error object.
+ *
+ * @return int error mode
+ * @access public
+ */
+ function getMode() {
+ return $this->mode;
+ }
+
+ // }}}
+ // {{{ getCallback()
+
+ /**
+ * Get the callback function/method from an error object.
+ *
+ * @return mixed callback function or object/method array
+ * @access public
+ */
+ function getCallback() {
+ return $this->callback;
+ }
+
+ // }}}
+ // {{{ getMessage()
+
+
+ /**
+ * Get the error message from an error object.
+ *
+ * @return string full error message
+ * @access public
+ */
+ function getMessage()
+ {
+ return ($this->error_message_prefix . $this->message);
+ }
+
+
+ // }}}
+ // {{{ getCode()
+
+ /**
+ * Get error code from an error object
+ *
+ * @return int error code
+ * @access public
+ */
+ function getCode()
+ {
+ return $this->code;
+ }
+
+ // }}}
+ // {{{ getType()
+
+ /**
+ * Get the name of this error/exception.
+ *
+ * @return string error/exception name (type)
+ * @access public
+ */
+ function getType()
+ {
+ return get_class($this);
+ }
+
+ // }}}
+ // {{{ getUserInfo()
+
+ /**
+ * Get additional user-supplied information.
+ *
+ * @return string user-supplied information
+ * @access public
+ */
+ function getUserInfo()
+ {
+ return $this->userinfo;
+ }
+
+ // }}}
+ // {{{ getDebugInfo()
+
+ /**
+ * Get additional debug information supplied by the application.
+ *
+ * @return string debug information
+ * @access public
+ */
+ function getDebugInfo()
+ {
+ return $this->getUserInfo();
+ }
+
+ // }}}
+ // {{{ getBacktrace()
+
+ /**
+ * Get the call backtrace from where the error was generated.
+ * Supported with PHP 4.3.0 or newer.
+ *
+ * @param int $frame (optional) what frame to fetch
+ * @return array Backtrace, or NULL if not available.
+ * @access public
+ */
+ function getBacktrace($frame = null)
+ {
+ if (defined('PEAR_IGNORE_BACKTRACE')) {
+ return null;
+ }
+ if ($frame === null) {
+ return $this->backtrace;
+ }
+ return $this->backtrace[$frame];
+ }
+
+ // }}}
+ // {{{ addUserInfo()
+
+ function addUserInfo($info)
+ {
+ if (empty($this->userinfo)) {
+ $this->userinfo = $info;
+ } else {
+ $this->userinfo .= " ** $info";
+ }
+ }
+
+ // }}}
+ // {{{ toString()
+ function __toString()
+ {
+ return $this->getMessage();
+ }
+ // }}}
+ // {{{ toString()
+
+ /**
+ * Make a string representation of this object.
+ *
+ * @return string a string with an object summary
+ * @access public
+ */
+ function toString() {
+ $modes = array();
+ $levels = array(E_USER_NOTICE => 'notice',
+ E_USER_WARNING => 'warning',
+ E_USER_ERROR => 'error');
+ if ($this->mode & PEAR_ERROR_CALLBACK) {
+ if (is_array($this->callback)) {
+ $callback = (is_object($this->callback[0]) ?
+ strtolower(get_class($this->callback[0])) :
+ $this->callback[0]) . '::' .
+ $this->callback[1];
+ } else {
+ $callback = $this->callback;
+ }
+ return sprintf('[%s: message="%s" code=%d mode=callback '.
+ 'callback=%s prefix="%s" info="%s"]',
+ strtolower(get_class($this)), $this->message, $this->code,
+ $callback, $this->error_message_prefix,
+ $this->userinfo);
+ }
+ if ($this->mode & PEAR_ERROR_PRINT) {
+ $modes[] = 'print';
+ }
+ if ($this->mode & PEAR_ERROR_TRIGGER) {
+ $modes[] = 'trigger';
+ }
+ if ($this->mode & PEAR_ERROR_DIE) {
+ $modes[] = 'die';
+ }
+ if ($this->mode & PEAR_ERROR_RETURN) {
+ $modes[] = 'return';
+ }
+ return sprintf('[%s: message="%s" code=%d mode=%s level=%s '.
+ 'prefix="%s" info="%s"]',
+ strtolower(get_class($this)), $this->message, $this->code,
+ implode("|", $modes), $levels[$this->level],
+ $this->error_message_prefix,
+ $this->userinfo);
+ }
+
+ // }}}
+}
+
+/*
+ * Local Variables:
+ * mode: php
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ */
+?>
Index: /CKEditor/branches/versions/3.0.x/_dev/docs_build/docs_build.bat
===================================================================
--- /CKEditor/branches/versions/3.0.x/_dev/docs_build/docs_build.bat (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_dev/docs_build/docs_build.bat (revision 3751)
@@ -0,0 +1,17 @@
+@ECHO OFF
+::
+:: Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+:: For licensing, see LICENSE.html or http://ckeditor.com/license
+::
+:: Build the _docs/api documentation files.
+::
+
+ECHO Building the API document at _docs/api...
+
+del /F /Q "../../_docs/api/*.*"
+
+java -jar ../_thirdparty/jsdoc-toolkit/jsrun.jar ../_thirdparty/jsdoc-toolkit/app/run.js -c=docs_build.conf
+
+:: php ../fixlineends/fixlineends.php --eolstripwhite --eofnewline --eofstripwhite --nohidden --nosystem ../../_docs/api/
+
+ECHO Finished!
Index: /CKEditor/branches/versions/3.0.x/_dev/docs_build/docs_build.conf
===================================================================
--- /CKEditor/branches/versions/3.0.x/_dev/docs_build/docs_build.conf (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_dev/docs_build/docs_build.conf (revision 3751)
@@ -0,0 +1,36 @@
+/*
+ This is an example of one way you could set up a configuration file to more
+ conveniently define some commandline options. You might like to do this if
+ you frequently reuse the same options. Note that you don't need to define
+ every option in this file, you can combine a configuration file with
+ additional options on the commandline if your wish.
+
+ You would include this configuration file by running JsDoc Toolkit like so:
+ java -jar jsrun.jar app/run.js -c=conf/sample.conf
+
+*/
+
+{
+ // Source files to parse.
+ _:
+ [
+ '../../_source/core/',
+ '../../_source/plugins/',
+ '../../_source/lang/en.js'
+ ],
+
+ // Document all functions, even uncommented ones.
+ a: true,
+
+ // Recursively, up to 100 directories depth.
+ r: 100,
+
+ // use this directory as the output directory
+ d: '../../_docs/api',
+
+ // Template.
+ t: 'template',
+
+ // Verbose mode.
+ v: true
+}
Index: /CKEditor/branches/versions/3.0.x/_dev/docs_build/template/allclasses.tmpl
===================================================================
--- /CKEditor/branches/versions/3.0.x/_dev/docs_build/template/allclasses.tmpl (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_dev/docs_build/template/allclasses.tmpl (revision 3751)
@@ -0,0 +1,26 @@
+
+ This sample shows how to use the dialog API to customize dialogs whithout changing
+ the original editor code. The following customizations are being done::
+
+
Add dialog pages ("My Tab" in the Link dialog).
+
Remove a dialog tab ("Target" tab from the Link dialog).
+
Add dialog fields ("My Custom Field" into the Link dialog).
+
Remove dialog fields ("Link Type" and "Browser Server" the Link dialog).
+
Set default values for dialog fields (for the "URL" field in the
+ Link dialog).
+ Double-click on any of the following DIVs to transform them into editor instances.
+
+
+ Part 1
+
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras et ipsum quis mi
+ semper accumsan. Integer pretium dui id massa. Suspendisse in nisl sit amet urna
+ rutrum imperdiet. Nulla eu tellus. Donec ante nisi, ullamcorper quis, fringilla
+ nec, sagittis eleifend, pede. Nulla commodo interdum massa. Donec id metus. Fusce
+ eu ipsum. Suspendisse auctor. Phasellus fermentum porttitor risus.
+
+
+
+
+ Part 2
+
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras et ipsum quis mi
+ semper accumsan. Integer pretium dui id massa. Suspendisse in nisl sit amet urna
+ rutrum imperdiet. Nulla eu tellus. Donec ante nisi, ullamcorper quis, fringilla
+ nec, sagittis eleifend, pede. Nulla commodo interdum massa. Donec id metus. Fusce
+ eu ipsum. Suspendisse auctor. Phasellus fermentum porttitor risus.
+
+
+ Donec velit. Mauris massa. Vestibulum non nulla. Nam suscipit arcu nec elit. Phasellus
+ sollicitudin iaculis ante. Ut non mauris et sapien tincidunt adipiscing. Vestibulum
+ vitae leo. Suspendisse nec mi tristique nulla laoreet vulputate.
+
+
+
+
+ Part 3
+
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras et ipsum quis mi
+ semper accumsan. Integer pretium dui id massa. Suspendisse in nisl sit amet urna
+ rutrum imperdiet. Nulla eu tellus. Donec ante nisi, ullamcorper quis, fringilla
+ nec, sagittis eleifend, pede. Nulla commodo interdum massa. Donec id metus. Fusce
+ eu ipsum. Suspendisse auctor. Phasellus fermentum porttitor risus.
+
+
+
+
+
+
Index: /CKEditor/branches/versions/3.0.x/_samples/sample.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_samples/sample.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_samples/sample.js (revision 3751)
@@ -0,0 +1,133 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+// This file is not required by CKEditor and may be safely ignored.
+// It is just a helper file that displays a red message about browser compatibility
+// at the top of the samples (if incompatible browser is detected).
+// %REMOVE_START%
+// In the SVN version of CKEditor, it does some more magic, for example it
+// redirects all samples to the sample.html file. It still can be ignored anyway.
+// %REMOVE_END%
+
+// Firebug has been presented some bugs with console. It must be "initialized"
+// before the page load to work.
+// FIXME: Remove the following in the future, if Firebug gets fixed.
+if ( typeof console != 'undefined' )
+ console.log();
+
+// %REMOVE_START%
+(function()
+{
+ // The sample##.html files also include this script. We don't want them to
+ // run, so we redirect to the samples.html page, passing the correct
+ // querystring parameter to load the desired page.
+
+ var sampleMatch = window.location.pathname.match( /[\/\\]([^\/\\]+).html/ );
+ if ( sampleMatch && sampleMatch[1] != 'sample' )
+ window.location = 'sample.html?sample=' + sampleMatch[1] + ( location.search.length > 1 ? '&' + location.search.substr(1) : '' );
+})();
+// %REMOVE_END%
+
+if ( window.CKEDITOR )
+{
+// %REMOVE_START%
+ CKEDITOR.samples = (function()
+ {
+ var ajax = CKEDITOR.ajax;
+
+ // Default values for the CKEDITOR.samples properties.
+ var samples =
+ {
+ htmlData : '
No HTML data available.
',
+ codeData : '
No code data available.
'
+ };
+
+ if ( /[?&]sample=[^&]+/.test( document.location.search ) )
+ {
+ var currentSample = document.location.search.match( /[?&]sample=([^&]+)/ )[1];
+ var sampleData = ajax.loadXml( CKEDITOR.getUrl( '_samples/' + currentSample + '.html' ) );
+
+ if ( sampleData )
+ {
+ var getNodeHtml = function ( id )
+ {
+ return sampleData.getInnerXml( '//*[@id="' + id + '"]' );
+ };
+
+ samples.headScript = getNodeHtml( 'headscript' ) || '';
+ samples.styles = getNodeHtml( 'styles' ) || '';
+ samples.htmlData = getNodeHtml( 'html' ) || '';
+ samples.codeData = getNodeHtml( 'code' ) || '';
+
+ if ( samples.headScript )
+ samples.headScript = '';
+
+ if ( samples.styles )
+ samples.styles = '';
+
+ // The '//*/*/*' XPath is the only way to make it work with
+ // xmlns="http://www.w3.org/1999/xhtml" without workarounds. It
+ // means that we must always have in this
+ // precise order.
+ document.title = sampleData.getInnerXml( '//*/*/*' );
+ }
+ }
+
+ return samples;
+ })();
+// %REMOVE_END%
+ (function()
+ {
+ var showCompatibilityMsg = function()
+ {
+ var env = CKEDITOR.env;
+
+ var html = '
Your browser is not compatible with CKEditor.';
+
+ var browsers =
+ {
+ gecko : 'Firefox 2.0',
+ ie : 'Internet Explorer 6.0',
+ opera : 'Opera 9.5',
+ webkit : 'Safari 3.0'
+ };
+
+ var alsoBrowsers = '';
+
+ for ( var key in env )
+ {
+ if ( browsers[ key ] )
+ {
+ if ( env[key] )
+ html += ' CKEditor is compatible with ' + browsers[ key ] + ' or higher.';
+ else
+ alsoBrowsers += browsers[ key ] + '+, ';
+ }
+ }
+
+ alsoBrowsers = alsoBrowsers.replace( /\+,([^,]+), $/, '+ and $1' );
+
+ html += ' It is also compatible with ' + alsoBrowsers + '.';
+
+ html += '
With non compatible browsers, you should still be able to see and edit the contents (HTML) in a plain text field.
';
+
+ document.getElementById( 'alerts' ).innerHTML = html;
+ };
+
+ var onload = function()
+ {
+ // Show a friendly compatibility message as soon as the page is loaded,
+ // for those browsers that are not compatible with CKEditor.
+ if ( !CKEDITOR.env.isCompatible )
+ showCompatibilityMsg();
+ };
+
+ // Register the onload listener.
+ if ( window.addEventListener )
+ window.addEventListener( 'load', onload, false );
+ else if ( window.attachEvent )
+ window.attachEvent( 'onload', onload );
+ })();
+}
Index: /CKEditor/branches/versions/3.0.x/_samples/sample_posteddata.php
===================================================================
--- /CKEditor/branches/versions/3.0.x/_samples/sample_posteddata.php (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_samples/sample_posteddata.php (revision 3751)
@@ -0,0 +1,59 @@
+
+
+
+
+ Sample - CKEditor
+
+
+
+
+
+
+
Index: /CKEditor/branches/versions/3.0.x/_source/core/_bootstrap.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/_bootstrap.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/_bootstrap.js (revision 3751)
@@ -0,0 +1,64 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @fileOverview API initialization code.
+ */
+
+(function()
+{
+ // Check is High Contrast is active by creating a temporary element with a
+ // background image.
+
+ var testImage = ( CKEDITOR.env.ie && CKEDITOR.env.version < 7 ) ? ( CKEDITOR.basePath + 'images/spacer.gif' ) : 'about:blank';
+
+ var hcDetect = CKEDITOR.dom.element.createFromHtml(
+ '', CKEDITOR.document );
+
+ hcDetect.appendTo( CKEDITOR.document.getHead() );
+
+ // Update CKEDITOR.env.
+ if ( ( CKEDITOR.env.hc = ( hcDetect.getComputedStyle( 'background-image' ) == 'none' ) ) )
+ CKEDITOR.env.cssClass += ' cke_hc';
+
+ hcDetect.remove();
+})();
+
+// Load core plugins.
+CKEDITOR.plugins.load( CKEDITOR.config.corePlugins.split( ',' ), function()
+ {
+ CKEDITOR.status = 'loaded';
+ CKEDITOR.fire( 'loaded' );
+
+ // Process all instances created by the "basic" implementation.
+ var pending = CKEDITOR._.pending;
+ if ( pending )
+ {
+ delete CKEDITOR._.pending;
+
+ for ( var i = 0 ; i < pending.length ; i++ )
+ CKEDITOR.add( pending[ i ] );
+ }
+ });
+
+/*
+TODO: Enable the following and check if effective.
+
+if ( CKEDITOR.env.ie )
+{
+ // Remove IE mouse flickering on IE6 because of background images.
+ try
+ {
+ document.execCommand( 'BackgroundImageCache', false, true );
+ }
+ catch (e)
+ {
+ // We have been reported about loading problems caused by the above
+ // line. For safety, let's just ignore errors.
+ }
+}
+*/
Index: /CKEditor/branches/versions/3.0.x/_source/core/ajax.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/ajax.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/ajax.js (revision 3751)
@@ -0,0 +1,143 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @fileOverview Defines the {@link CKEDITOR.ajax} object, which holds ajax methods for
+ * data loading.
+ */
+
+/**
+ * Ajax methods for data loading.
+ * @namespace
+ * @example
+ */
+CKEDITOR.ajax = (function()
+{
+ var createXMLHttpRequest = function()
+ {
+ // In IE, using the native XMLHttpRequest for local files may throw
+ // "Access is Denied" errors.
+ if ( !CKEDITOR.env.ie || location.protocol != 'file:' )
+ try { return new XMLHttpRequest(); } catch(e) {}
+
+ try { return new ActiveXObject( 'Msxml2.XMLHTTP' ); } catch (e) {}
+ try { return new ActiveXObject( 'Microsoft.XMLHTTP' ); } catch (e) {}
+
+ return null;
+ };
+
+ var checkStatus = function( xhr )
+ {
+ // HTTP Status Codes:
+ // 2xx : Success
+ // 304 : Not Modified
+ // 0 : Returned when running locally (file://)
+ // 1223 : IE may change 204 to 1223 (see http://dev.jquery.com/ticket/1450)
+
+ return ( xhr.readyState == 4 &&
+ ( ( xhr.status >= 200 && xhr.status < 300 ) ||
+ xhr.status == 304 ||
+ xhr.status === 0 ||
+ xhr.status == 1223 ) );
+ };
+
+ var getResponseText = function( xhr )
+ {
+ if ( checkStatus( xhr ) )
+ return xhr.responseText;
+ return null;
+ };
+
+ var getResponseXml = function( xhr )
+ {
+ if ( checkStatus( xhr ) )
+ {
+ var xml = xhr.responseXML;
+ return new CKEDITOR.xml( xml && xml.firstChild ? xml : xhr.responseText );
+ }
+ return null;
+ };
+
+ var load = function( url, callback, getResponseFn )
+ {
+ var async = !!callback;
+
+ var xhr = createXMLHttpRequest();
+
+ if ( !xhr )
+ return null;
+
+ xhr.open( 'GET', url, async );
+
+ if ( async )
+ {
+ // TODO: perform leak checks on this closure.
+ /** @ignore */
+ xhr.onreadystatechange = function()
+ {
+ if ( xhr.readyState == 4 )
+ {
+ callback( getResponseFn( xhr ) );
+ xhr = null;
+ }
+ };
+ }
+
+ xhr.send(null);
+
+ return async ? '' : getResponseFn( xhr );
+ };
+
+ return /** @lends CKEDITOR.ajax */ {
+
+ /**
+ * Loads data from an URL as plain text.
+ * @param {String} url The URL from which load data.
+ * @param {Function} [callback] A callback function to be called on
+ * data load. If not provided, the data will be loaded
+ * asynchronously, passing the data value the function on load.
+ * @returns {String} The loaded data. For asynchronous requests, an
+ * empty string. For invalid requests, null.
+ * @example
+ * // Load data synchronously.
+ * var data = CKEDITOR.ajax.load( 'somedata.txt' );
+ * alert( data );
+ * @example
+ * // Load data asynchronously.
+ * var data = CKEDITOR.ajax.load( 'somedata.txt', function( data )
+ * {
+ * alert( data );
+ * } );
+ */
+ load : function( url, callback )
+ {
+ return load( url, callback, getResponseText );
+ },
+
+ /**
+ * Loads data from an URL as XML.
+ * @param {String} url The URL from which load data.
+ * @param {Function} [callback] A callback function to be called on
+ * data load. If not provided, the data will be loaded
+ * asynchronously, passing the data value the function on load.
+ * @returns {CKEDITOR.xml} An XML object holding the loaded data. For asynchronous requests, an
+ * empty string. For invalid requests, null.
+ * @example
+ * // Load XML synchronously.
+ * var xml = CKEDITOR.ajax.loadXml( 'somedata.xml' );
+ * alert( xml.getInnerXml( '//' ) );
+ * @example
+ * // Load XML asynchronously.
+ * var data = CKEDITOR.ajax.loadXml( 'somedata.xml', function( xml )
+ * {
+ * alert( xml.getInnerXml( '//' ) );
+ * } );
+ */
+ loadXml : function( url, callback )
+ {
+ return load( url, callback, getResponseXml );
+ }
+ };
+})();
Index: /CKEditor/branches/versions/3.0.x/_source/core/ckeditor.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/ckeditor.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/ckeditor.js (revision 3751)
@@ -0,0 +1,96 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @fileOverview Contains the third and last part of the {@link CKEDITOR} object
+ * definition.
+ */
+
+// Remove the CKEDITOR.loadFullCore reference defined on ckeditor_basic.
+delete CKEDITOR.loadFullCore;
+
+/**
+ * Holds references to all editor instances created. The name of the properties
+ * in this object correspond to instance names, and their values contains the
+ * {@link CKEDITOR.editor} object representing them.
+ * @type {Object}
+ * @example
+ * alert( CKEDITOR.instances.editor1.name ); // "editor1"
+ */
+CKEDITOR.instances = {};
+
+/**
+ * The document of the window holding the CKEDITOR object.
+ * @type {CKEDITOR.dom.document}
+ * @example
+ * alert( CKEDITOR.document.getBody().getName() ); // "body"
+ */
+CKEDITOR.document = new CKEDITOR.dom.document( document );
+
+/**
+ * Adds an editor instance to the global {@link CKEDITOR} object. This function
+ * is available for internal use mainly.
+ * @param {CKEDITOR.editor} editor The editor instance to be added.
+ * @example
+ */
+CKEDITOR.add = function( editor )
+{
+ CKEDITOR.instances[ editor.name ] = editor;
+
+ editor.on( 'focus', function()
+ {
+ if ( CKEDITOR.currentInstance != editor )
+ {
+ CKEDITOR.currentInstance = editor;
+ CKEDITOR.fire( 'currentInstance' );
+ }
+ });
+
+ editor.on( 'blur', function()
+ {
+ if ( CKEDITOR.currentInstance == editor )
+ {
+ CKEDITOR.currentInstance = null;
+ CKEDITOR.fire( 'currentInstance' );
+ }
+ });
+};
+
+/**
+ * Removes and editor instance from the global {@link CKEDITOR} object. his function
+ * is available for internal use mainly.
+ * @param {CKEDITOR.editor} editor The editor instance to be added.
+ * @example
+ */
+CKEDITOR.remove = function( editor )
+{
+ delete CKEDITOR.instances[ editor.name ];
+};
+
+// Load the bootstrap script.
+CKEDITOR.loader.load( 'core/_bootstrap' ); // @Packager.RemoveLine
+
+// Tri-state constants.
+
+/**
+ * Used to indicate the ON or ACTIVE state.
+ * @constant
+ * @example
+ */
+CKEDITOR.TRISTATE_ON = 1;
+
+/**
+ * Used to indicate the OFF or NON ACTIVE state.
+ * @constant
+ * @example
+ */
+CKEDITOR.TRISTATE_OFF = 2;
+
+/**
+ * Used to indicate DISABLED state.
+ * @constant
+ * @example
+ */
+CKEDITOR.TRISTATE_DISABLED = 0;
Index: /CKEditor/branches/versions/3.0.x/_source/core/ckeditor_base.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/ckeditor_base.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/ckeditor_base.js (revision 3751)
@@ -0,0 +1,193 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @fileOverview Contains the first and essential part of the {@link CKEDITOR}
+ * object definition.
+ */
+
+// #### Compressed Code
+// Must be updated on changes in the script, as well as updated in the
+// ckeditor_source.js and ckeditor_basic_source.js files.
+
+// if(!window.CKEDITOR)window.CKEDITOR=(function(){var a={timestamp:'',version:'%VERSION%',rev:'%REV%',_:{},status:'unloaded',basePath:(function(){var d=window.CKEDITOR_BASEPATH||'';if(!d){var e=document.getElementsByTagName('script');for(var f=0;f=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;})();
+
+// #### Raw code
+// ATTENTION: read the above "Compressed Code" notes when changing this code.
+
+if ( !window.CKEDITOR )
+{
+ /**
+ * This is the API entry point. The entire CKEditor code runs under this object.
+ * @name CKEDITOR
+ * @namespace
+ * @example
+ */
+ window.CKEDITOR = (function()
+ {
+ var CKEDITOR =
+ /** @lends CKEDITOR */
+ {
+
+ /**
+ * A constant string unique for each release of CKEditor. Its value
+ * is used, by default, to build the URL for all resources loaded
+ * by the editor code, guaranteing clean cache results when
+ * upgrading.
+ * @type String
+ * @example
+ * alert( CKEDITOR.timestamp ); // e.g. '87dm'
+ */
+ timestamp : '', // %REMOVE_LINE%
+ /* // %REMOVE_LINE%
+ // The production implementation contains a fixed timestamp, unique
+ // for each release, generated by the releaser.
+ // (Base 36 value of each component of YYMMDDHH - 4 chars total - e.g. 87bm == 08071122)
+ timestamp : '%TIMESTAMP%',
+ */ // %REMOVE_LINE%
+
+ /**
+ * Contains the CKEditor version number.
+ * @type String
+ * @example
+ * alert( CKEDITOR.version ); // e.g. 'CKEditor 3.0 Beta'
+ */
+ version : '%VERSION%',
+
+ /**
+ * Contains the CKEditor revision number.
+ * Revision number is incremented automatically after each modification of CKEditor source code.
+ * @type String
+ * @example
+ * alert( CKEDITOR.revision ); // e.g. '3975'
+ */
+ revision : '%REV%',
+
+ /**
+ * Private object used to hold core stuff. It should not be used out of
+ * the API code as properties defined here may change at any time
+ * without notice.
+ * @private
+ */
+ _ : {},
+
+ /**
+ * Indicates the API loading status. The following status are available:
+ *
+ *
unloaded: the API is not yet loaded.
+ *
basic_loaded: the basic API features are available.
+ *
basic_ready: the basic API is ready to load the full core code.
+ *
loading: the full API is being loaded.
+ *
ready: the API can be fully used.
+ *
+ * @type String
+ * @example
+ * if ( CKEDITOR.status == 'ready' )
+ * {
+ * // The API can now be fully used.
+ * }
+ */
+ status : 'unloaded',
+
+ /**
+ * Contains the full URL for the CKEditor installation directory.
+ * It's possible to manually provide the base path by setting a
+ * global variable named CKEDITOR_BASEPATH. This global variable
+ * must be set "before" the editor script loading.
+ * @type String
+ * @example
+ * alert( CKEDITOR.basePath ); // "http://www.example.com/ckeditor/" (e.g.)
+ */
+ basePath : (function()
+ {
+ // ATTENTION: fixes on this code must be ported to
+ // var basePath in "core/loader.js".
+
+ // Find out the editor directory path, based on its ")' );
+ }
+ }
+
+ return $ && new CKEDITOR.dom.document( $.contentWindow.document );
+ },
+
+ /**
+ * Copy all the attributes from one node to the other, kinda like a clone
+ * skipAttributes is an object with the attributes that must NOT be copied.
+ * @param {CKEDITOR.dom.element} dest The destination element.
+ * @param {Object} skipAttributes A dictionary of attributes to skip.
+ * @example
+ */
+ copyAttributes : function( dest, skipAttributes )
+ {
+ var attributes = this.$.attributes;
+ skipAttributes = skipAttributes || {};
+
+ for ( var n = 0 ; n < attributes.length ; n++ )
+ {
+ var attribute = attributes[n];
+
+ // IE BUG: value attribute is never specified even if it exists.
+ if ( attribute.specified ||
+ ( CKEDITOR.env.ie && attribute.nodeValue && attribute.nodeName.toLowerCase() == 'value' ) )
+ {
+ var attrName = attribute.nodeName;
+ // We can set the type only once, so do it with the proper value, not copying it.
+ if ( attrName in skipAttributes )
+ continue;
+
+ var attrValue = this.getAttribute( attrName );
+ if ( attrValue === null )
+ attrValue = attribute.nodeValue;
+
+ dest.setAttribute( attrName, attrValue );
+ }
+ }
+
+ // The style:
+ if ( this.$.style.cssText !== '' )
+ dest.$.style.cssText = this.$.style.cssText;
+ },
+
+ /**
+ * Changes the tag name of the current element.
+ * @param {String} newTag The new tag for the element.
+ */
+ renameNode : function( newTag )
+ {
+ // If it's already correct exit here.
+ if ( this.getName() == newTag )
+ return;
+
+ var doc = this.getDocument();
+
+ // Create the new node.
+ var newNode = new CKEDITOR.dom.element( newTag, doc );
+
+ // Copy all attributes.
+ this.copyAttributes( newNode );
+
+ // Move children to the new node.
+ this.moveChildren( newNode );
+
+ // Replace the node.
+ this.$.parentNode.replaceChild( newNode.$, this.$ );
+ newNode.$._cke_expando = this.$._cke_expando;
+ this.$ = newNode.$;
+ },
+
+ /**
+ * Gets a DOM tree descendant under the current node.
+ * @param {Array|Number} indices The child index or array of child indices under the node.
+ * @returns {CKEDITOR.dom.node} The specified DOM child under the current node. Null if child does not exist.
+ * @example
+ * var strong = p.getChild(0);
+ */
+ getChild : function( indices )
+ {
+ var rawNode = this.$;
+
+ if ( !indices.slice )
+ rawNode = rawNode.childNodes[ indices ];
+ else
+ {
+ while ( indices.length > 0 && rawNode )
+ rawNode = rawNode.childNodes[ indices.shift() ];
+ }
+
+ return rawNode ? new CKEDITOR.dom.node( rawNode ) : null;
+ },
+
+ getChildCount : function()
+ {
+ return this.$.childNodes.length;
+ }
+ });
Index: /CKEditor/branches/versions/3.0.x/_source/core/dom/elementpath.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/dom/elementpath.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/dom/elementpath.js (revision 3751)
@@ -0,0 +1,104 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+(function()
+{
+ // Elements that may be considered the "Block boundary" in an element path.
+ var pathBlockElements = { address:1,blockquote:1,dl:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1,li:1,dt:1,de:1 };
+
+ // Elements that may be considered the "Block limit" in an element path.
+ var pathBlockLimitElements = { body:1,div:1,table:1,tbody:1,tr:1,td:1,th:1,caption:1,form:1 };
+
+ // Check if an element contains any block element.
+ var checkHasBlock = function( element )
+ {
+ var childNodes = element.getChildren();
+
+ for ( var i = 0, count = childNodes.count() ; i < count ; i++ )
+ {
+ var child = childNodes.getItem( i );
+
+ if ( child.type == CKEDITOR.NODE_ELEMENT && CKEDITOR.dtd.$block[ child.getName() ] )
+ return true;
+ }
+
+ return false;
+ };
+
+ CKEDITOR.dom.elementPath = function( lastNode )
+ {
+ var block = null;
+ var blockLimit = null;
+ var elements = [];
+
+ var e = lastNode;
+
+ while ( e )
+ {
+ if ( e.type == CKEDITOR.NODE_ELEMENT )
+ {
+ if ( !this.lastElement )
+ this.lastElement = e;
+
+ var elementName = e.getName();
+ if ( CKEDITOR.env.ie && e.$.scopeName != 'HTML' )
+ elementName = e.$.scopeName.toLowerCase() + ':' + elementName;
+
+ if ( !blockLimit )
+ {
+ if ( !block && pathBlockElements[ elementName ] )
+ block = e;
+
+ if ( pathBlockLimitElements[ elementName ] )
+ {
+ // DIV is considered the Block, if no block is available (#525)
+ // and if it doesn't contain other blocks.
+ if ( !block && elementName == 'div' && !checkHasBlock( e ) )
+ block = e;
+ else
+ blockLimit = e;
+ }
+ }
+
+ elements.push( e );
+
+ if ( elementName == 'body' )
+ break;
+ }
+ e = e.getParent();
+ }
+
+ this.block = block;
+ this.blockLimit = blockLimit;
+ this.elements = elements;
+ };
+})();
+
+CKEDITOR.dom.elementPath.prototype =
+{
+ /**
+ * Compares this element path with another one.
+ * @param {CKEDITOR.dom.elementPath} otherPath The elementPath object to be
+ * compared with this one.
+ * @returns {Boolean} "true" if the paths are equal, containing the same
+ * number of elements and the same elements in the same order.
+ */
+ compare : function( otherPath )
+ {
+ var thisElements = this.elements;
+ var otherElements = otherPath && otherPath.elements;
+
+ if ( !otherElements || thisElements.length != otherElements.length )
+ return false;
+
+ for ( var i = 0 ; i < thisElements.length ; i++ )
+ {
+ if ( !thisElements[ i ].equals( otherElements[ i ] ) )
+ return false;
+ }
+
+ return true;
+ }
+};
Index: /CKEditor/branches/versions/3.0.x/_source/core/dom/event.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/dom/event.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/dom/event.js (revision 3751)
@@ -0,0 +1,137 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @fileOverview Defines the {@link CKEDITOR.dom.event} class, which
+ * represents the a native DOM event object.
+ */
+
+/**
+ * Represents a native DOM event object.
+ * @constructor
+ * @param {Object} domEvent A native DOM event object.
+ * @example
+ */
+CKEDITOR.dom.event = function( domEvent )
+{
+ /**
+ * The native DOM event object represented by this class instance.
+ * @type Object
+ * @example
+ */
+ this.$ = domEvent;
+};
+
+CKEDITOR.dom.event.prototype =
+{
+ /**
+ * Gets the key code associated to the event.
+ * @returns {Number} The key code.
+ * @example
+ * alert( event.getKey() ); "65" is "a" has been pressed
+ */
+ getKey : function()
+ {
+ return this.$.keyCode || this.$.which;
+ },
+
+ /**
+ * Gets a number represeting the combination of the keys pressed during the
+ * event. It is the sum with the current key code and the {@link CKEDITOR.CTRL},
+ * {@link CKEDITOR.SHIFT} and {@link CKEDITOR.ALT} constants.
+ * @returns {Number} The number representing the keys combination.
+ * @example
+ * alert( event.getKeystroke() == 65 ); // "a" key
+ * alert( event.getKeystroke() == CKEDITOR.CTRL + 65 ); // CTRL + "a" key
+ * alert( event.getKeystroke() == CKEDITOR.CTRL + CKEDITOR.SHIFT + 65 ); // CTRL + SHIFT + "a" key
+ */
+ getKeystroke : function()
+ {
+ var keystroke = this.getKey();
+
+ if ( this.$.ctrlKey || this.$.metaKey )
+ keystroke += CKEDITOR.CTRL;
+
+ if ( this.$.shiftKey )
+ keystroke += CKEDITOR.SHIFT;
+
+ if ( this.$.altKey )
+ keystroke += CKEDITOR.ALT;
+
+ return keystroke;
+ },
+
+ /**
+ * Prevents the original behavior of the event to happen. It can optionally
+ * stop propagating the event in the event chain.
+ * @param {Boolean} [stopPropagation] Stop propagating this event in the
+ * event chain.
+ * @example
+ * var element = CKEDITOR.document.getById( 'myElement' );
+ * element.on( 'click', function( ev )
+ * {
+ * // The DOM event object is passed by the "data" property.
+ * var domEvent = ev.data;
+ * // Prevent the click to chave any effect in the element.
+ * domEvent.preventDefault();
+ * });
+ */
+ preventDefault : function( stopPropagation )
+ {
+ var $ = this.$;
+ if ( $.preventDefault )
+ $.preventDefault();
+ else
+ $.returnValue = false;
+
+ if ( stopPropagation )
+ {
+ if ( $.stopPropagation )
+ $.stopPropagation();
+ else
+ $.cancelBubble = true;
+ }
+ },
+ /**
+ * Returns the DOM node where the event was targeted to.
+ * @returns {CKEDITOR.dom.node} The target DOM node.
+ * @example
+ * var element = CKEDITOR.document.getById( 'myElement' );
+ * element.on( 'click', function( ev )
+ * {
+ * // The DOM event object is passed by the "data" property.
+ * var domEvent = ev.data;
+ * // Add a CSS class to the event target.
+ * domEvent.getTarget().addClass( 'clicked' );
+ * });
+ */
+
+ getTarget : function()
+ {
+ var rawNode = this.$.target || this.$.srcElement;
+ return rawNode ? new CKEDITOR.dom.node( rawNode ) : null;
+ }
+};
+
+/**
+ * CTRL key (1000).
+ * @constant
+ * @example
+ */
+CKEDITOR.CTRL = 1000;
+
+/**
+ * SHIFT key (2000).
+ * @constant
+ * @example
+ */
+CKEDITOR.SHIFT = 2000;
+
+/**
+ * ALT key (4000).
+ * @constant
+ * @example
+ */
+CKEDITOR.ALT = 4000;
Index: /CKEditor/branches/versions/3.0.x/_source/core/dom/node.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/dom/node.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/dom/node.js (revision 3751)
@@ -0,0 +1,646 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @fileOverview Defines the {@link CKEDITOR.dom.node} class, which is the base
+ * class for classes that represent DOM nodes.
+ */
+
+/**
+ * Base class for classes representing DOM nodes. This constructor may return
+ * and instance of classes that inherits this class, like
+ * {@link CKEDITOR.dom.element} or {@link CKEDITOR.dom.text}.
+ * @augments CKEDITOR.dom.domObject
+ * @param {Object} domNode A native DOM node.
+ * @constructor
+ * @see CKEDITOR.dom.element
+ * @see CKEDITOR.dom.text
+ * @example
+ */
+CKEDITOR.dom.node = function( domNode )
+{
+ if ( domNode )
+ {
+ switch ( domNode.nodeType )
+ {
+ case CKEDITOR.NODE_ELEMENT :
+ return new CKEDITOR.dom.element( domNode );
+
+ case CKEDITOR.NODE_TEXT :
+ return new CKEDITOR.dom.text( domNode );
+ }
+
+ // Call the base constructor.
+ CKEDITOR.dom.domObject.call( this, domNode );
+ }
+
+ return this;
+};
+
+CKEDITOR.dom.node.prototype = new CKEDITOR.dom.domObject();
+
+/**
+ * Element node type.
+ * @constant
+ * @example
+ */
+CKEDITOR.NODE_ELEMENT = 1;
+
+/**
+ * Text node type.
+ * @constant
+ * @example
+ */
+CKEDITOR.NODE_TEXT = 3;
+
+/**
+ * Comment node type.
+ * @constant
+ * @example
+ */
+CKEDITOR.NODE_COMMENT = 8;
+
+CKEDITOR.NODE_DOCUMENT_FRAGMENT = 11;
+
+CKEDITOR.POSITION_IDENTICAL = 0;
+CKEDITOR.POSITION_DISCONNECTED = 1;
+CKEDITOR.POSITION_FOLLOWING = 2;
+CKEDITOR.POSITION_PRECEDING = 4;
+CKEDITOR.POSITION_IS_CONTAINED = 8;
+CKEDITOR.POSITION_CONTAINS = 16;
+
+CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype,
+ /** @lends CKEDITOR.dom.node.prototype */
+ {
+ /**
+ * Makes this node child of another element.
+ * @param {CKEDITOR.dom.element} element The target element to which append
+ * this node.
+ * @returns {CKEDITOR.dom.element} The target element.
+ * @example
+ * var p = new CKEDITOR.dom.element( 'p' );
+ * var strong = new CKEDITOR.dom.element( 'strong' );
+ * strong.appendTo( p );
+ *
+ * // result: "<p><strong></strong></p>"
+ */
+ appendTo : function( element, toStart )
+ {
+ element.append( this, toStart );
+ return element;
+ },
+
+ clone : function( includeChildren, cloneId )
+ {
+ var $clone = this.$.cloneNode( includeChildren );
+
+ if ( !cloneId )
+ {
+ var removeIds = function( node )
+ {
+ if ( node.nodeType != CKEDITOR.NODE_ELEMENT )
+ return;
+
+ node.removeAttribute( 'id', false ) ;
+ node.removeAttribute( '_cke_expando', false ) ;
+
+ var childs = node.childNodes;
+ for ( var i=0 ; i < childs.length ; i++ )
+ removeIds( childs[ i ] );
+ };
+
+ // The "id" attribute should never be cloned to avoid duplication.
+ removeIds( $clone );
+ }
+
+ return new CKEDITOR.dom.node( $clone );
+ },
+
+ hasPrevious : function()
+ {
+ return !!this.$.previousSibling;
+ },
+
+ hasNext : function()
+ {
+ return !!this.$.nextSibling;
+ },
+
+ /**
+ * Inserts this element after a node.
+ * @param {CKEDITOR.dom.node} node The that will preceed this element.
+ * @returns {CKEDITOR.dom.node} The node preceeding this one after
+ * insertion.
+ * @example
+ * var em = new CKEDITOR.dom.element( 'em' );
+ * var strong = new CKEDITOR.dom.element( 'strong' );
+ * strong.insertAfter( em );
+ *
+ * // result: "<em></em><strong></strong>"
+ */
+ insertAfter : function( node )
+ {
+ node.$.parentNode.insertBefore( this.$, node.$.nextSibling );
+ return node;
+ },
+
+ /**
+ * Inserts this element before a node.
+ * @param {CKEDITOR.dom.node} node The that will be after this element.
+ * @returns {CKEDITOR.dom.node} The node being inserted.
+ * @example
+ * var em = new CKEDITOR.dom.element( 'em' );
+ * var strong = new CKEDITOR.dom.element( 'strong' );
+ * strong.insertBefore( em );
+ *
+ * // result: "<strong></strong><em></em>"
+ */
+ insertBefore : function( node )
+ {
+ node.$.parentNode.insertBefore( this.$, node.$ );
+ return node;
+ },
+
+ insertBeforeMe : function( node )
+ {
+ this.$.parentNode.insertBefore( node.$, this.$ );
+ return node;
+ },
+
+ /**
+ * Retrieves a uniquely identifiable tree address for this node.
+ * The tree address returns is an array of integers, with each integer
+ * indicating a child index of a DOM node, starting from
+ * document.documentElement.
+ *
+ * For example, assuming is the second child from (
+ * being the first), and we'd like to address the third child under the
+ * fourth child of body, the tree address returned would be:
+ * [1, 3, 2]
+ *
+ * The tree address cannot be used for finding back the DOM tree node once
+ * the DOM tree structure has been modified.
+ */
+ getAddress : function( normalized )
+ {
+ var address = [];
+ var $documentElement = this.getDocument().$.documentElement;
+ var node = this.$;
+
+ while ( node && node != $documentElement )
+ {
+ var parentNode = node.parentNode;
+ var currentIndex = -1;
+
+ for ( var i = 0 ; i < parentNode.childNodes.length ; i++ )
+ {
+ var candidate = parentNode.childNodes[i];
+
+ if ( normalized &&
+ candidate.nodeType == 3 &&
+ candidate.previousSibling &&
+ candidate.previousSibling.nodeType == 3 )
+ {
+ continue;
+ }
+
+ currentIndex++;
+
+ if ( candidate == node )
+ break;
+ }
+
+ address.unshift( currentIndex );
+
+ node = node.parentNode;
+ }
+
+ return address;
+ },
+
+ /**
+ * Gets the document containing this element.
+ * @returns {CKEDITOR.dom.document} The document.
+ * @example
+ * var element = CKEDITOR.document.getById( 'example' );
+ * alert( element.getDocument().equals( CKEDITOR.document ) ); // "true"
+ */
+ getDocument : function()
+ {
+ var document = new CKEDITOR.dom.document( this.$.ownerDocument || this.$.parentNode.ownerDocument );
+
+ return (
+ /** @ignore */
+ this.getDocument = function()
+ {
+ return document;
+ })();
+ },
+
+ getIndex : function()
+ {
+ var $ = this.$;
+
+ var currentNode = $.parentNode && $.parentNode.firstChild;
+ var currentIndex = -1;
+
+ while ( currentNode )
+ {
+ currentIndex++;
+
+ if ( currentNode == $ )
+ return currentIndex;
+
+ currentNode = currentNode.nextSibling;
+ }
+
+ return -1;
+ },
+
+ getNextSourceNode : function( startFromSibling, nodeType, guard )
+ {
+ // If "guard" is a node, transform it in a function.
+ if ( guard && !guard.call )
+ {
+ var guardNode = guard;
+ guard = function( node )
+ {
+ return !node.equals( guardNode );
+ };
+ }
+
+ var node = ( !startFromSibling && this.getFirst && this.getFirst() ),
+ parent;
+
+ // Guarding when we're skipping the current element( no children or 'startFromSibling' ).
+ // send the 'moving out' signal even we don't actually dive into.
+ if ( !node )
+ {
+ if ( this.type == CKEDITOR.NODE_ELEMENT && guard && guard( this, true ) === false )
+ return null;
+ node = this.getNext();
+ }
+
+ while ( !node && ( parent = ( parent || this ).getParent() ) )
+ {
+ // The guard check sends the "true" paramenter to indicate that
+ // we are moving "out" of the element.
+ if ( guard && guard( parent, true ) === false )
+ return null;
+
+ node = parent.getNext();
+ }
+
+ if ( !node )
+ return null;
+
+ if ( guard && guard( node ) === false )
+ return null;
+
+ if ( nodeType && nodeType != node.type )
+ return node.getNextSourceNode( false, nodeType, guard );
+
+ return node;
+ },
+
+ getPreviousSourceNode : function( startFromSibling, nodeType, guard )
+ {
+ if ( guard && !guard.call )
+ {
+ var guardNode = guard;
+ guard = function( node )
+ {
+ return !node.equals( guardNode );
+ };
+ }
+
+ var node = ( !startFromSibling && this.getLast && this.getLast() ),
+ parent;
+
+ // Guarding when we're skipping the current element( no children or 'startFromSibling' ).
+ // send the 'moving out' signal even we don't actually dive into.
+ if ( !node )
+ {
+ if ( this.type == CKEDITOR.NODE_ELEMENT && guard && guard( this, true ) === false )
+ return null;
+ node = this.getPrevious();
+ }
+
+ while ( !node && ( parent = ( parent || this ).getParent() ) )
+ {
+ // The guard check sends the "true" paramenter to indicate that
+ // we are moving "out" of the element.
+ if ( guard && guard( parent, true ) === false )
+ return null;
+
+ node = parent.getPrevious();
+ }
+
+ if ( !node )
+ return null;
+
+ if ( guard && guard( node ) === false )
+ return null;
+
+ if ( nodeType && node.type != nodeType )
+ return node.getPreviousSourceNode( false, nodeType, guard );
+
+ return node;
+ },
+
+ getPrevious : function( ignoreSpaces )
+ {
+ var previous = this.$.previousSibling;
+ while ( ignoreSpaces && previous && ( previous.nodeType == CKEDITOR.NODE_TEXT )
+ && !CKEDITOR.tools.trim( previous.nodeValue ) )
+ previous = previous.previousSibling;
+
+ return previous ? new CKEDITOR.dom.node( previous ) : null;
+ },
+
+ /**
+ * Gets the node that follows this element in its parent's child list.
+ * @param {Boolean} ignoreSpaces Whether should ignore empty text nodes.
+ * @returns {CKEDITOR.dom.node} The next node or null if not
+ * available.
+ * @example
+ * var element = CKEDITOR.dom.element.createFromHtml( '<div><b>Example</b> <i>next</i></div>' );
+ * var first = element.getFirst().getNext();
+ * alert( first.getName() ); // "i"
+ */
+ getNext : function( ignoreSpaces )
+ {
+ var next = this.$.nextSibling;
+ while ( ignoreSpaces && next && ( next.nodeType == CKEDITOR.NODE_TEXT )
+ && !CKEDITOR.tools.trim( next.nodeValue ) )
+ next = next.nextSibling;
+
+ return next ? new CKEDITOR.dom.node( next ) : null;
+ },
+
+ /**
+ * Gets the parent element for this node.
+ * @returns {CKEDITOR.dom.element} The parent element.
+ * @example
+ * var node = editor.document.getBody().getFirst();
+ * var parent = node.getParent();
+ * alert( node.getName() ); // "body"
+ */
+ getParent : function()
+ {
+ var parent = this.$.parentNode;
+ return ( parent && parent.nodeType == 1 ) ? new CKEDITOR.dom.node( parent ) : null;
+ },
+
+ getParents : function()
+ {
+ var node = this;
+ var parents = [];
+
+ do
+ {
+ parents.unshift( node );
+ }
+ while ( ( node = node.getParent() ) )
+
+ return parents;
+ },
+
+ getCommonAncestor : function( node )
+ {
+ if ( node.equals( this ) )
+ return this;
+
+ if ( node.contains && node.contains( this ) )
+ return node;
+
+ var start = this.contains ? this : this.getParent();
+
+ do
+ {
+ if ( start.contains( node ) )
+ return start;
+ }
+ while ( ( start = start.getParent() ) );
+
+ return null;
+ },
+
+ getPosition : function( otherNode )
+ {
+ var $ = this.$;
+ var $other = otherNode.$;
+
+ if ( $.compareDocumentPosition )
+ return $.compareDocumentPosition( $other );
+
+ // IE and Safari have no support for compareDocumentPosition.
+
+ if ( $ == $other )
+ return CKEDITOR.POSITION_IDENTICAL;
+
+ // Only element nodes support contains and sourceIndex.
+ if ( this.type == CKEDITOR.NODE_ELEMENT && otherNode.type == CKEDITOR.NODE_ELEMENT )
+ {
+ if ( $.contains )
+ {
+ if ( $.contains( $other ) )
+ return CKEDITOR.POSITION_CONTAINS + CKEDITOR.POSITION_PRECEDING;
+
+ if ( $other.contains( $ ) )
+ return CKEDITOR.POSITION_IS_CONTAINED + CKEDITOR.POSITION_FOLLOWING;
+ }
+
+ if ( 'sourceIndex' in $ )
+ {
+ return ( $.sourceIndex < 0 || $other.sourceIndex < 0 ) ? CKEDITOR.POSITION_DISCONNECTED :
+ ( $.sourceIndex < $other.sourceIndex ) ? CKEDITOR.POSITION_PRECEDING :
+ CKEDITOR.POSITION_FOLLOWING;
+ }
+ }
+
+ // For nodes that don't support compareDocumentPosition, contains
+ // or sourceIndex, their "address" is compared.
+
+ var addressOfThis = this.getAddress(),
+ addressOfOther = otherNode.getAddress(),
+ minLevel = Math.min( addressOfThis.length, addressOfOther.length );
+
+ // Determinate preceed/follow relationship.
+ for ( var i = 0 ; i <= minLevel - 1 ; i++ )
+ {
+ if ( addressOfThis[ i ] != addressOfOther[ i ] )
+ {
+ if ( i < minLevel )
+ {
+ return addressOfThis[ i ] < addressOfOther[ i ] ?
+ CKEDITOR.POSITION_PRECEDING : CKEDITOR.POSITION_FOLLOWING;
+ }
+ break;
+ }
+ }
+
+ // Determinate contains/contained relationship.
+ return ( addressOfThis.length < addressOfOther.length ) ?
+ CKEDITOR.POSITION_CONTAINS + CKEDITOR.POSITION_PRECEDING :
+ CKEDITOR.POSITION_IS_CONTAINED + CKEDITOR.POSITION_FOLLOWING;
+ },
+
+ /**
+ * Gets the closes ancestor node of a specified node name.
+ * @param {String} name Node name of ancestor node.
+ * @param {Boolean} includeSelf (Optional) Whether to include the current
+ * node in the calculation or not.
+ * @returns {CKEDITOR.dom.node} Ancestor node.
+ */
+ getAscendant : function( name, includeSelf )
+ {
+ var $ = this.$;
+
+ if ( !includeSelf )
+ $ = $.parentNode;
+
+ while ( $ )
+ {
+ if ( $.nodeName && $.nodeName.toLowerCase() == name )
+ return new CKEDITOR.dom.node( $ );
+
+ $ = $.parentNode;
+ }
+ return null;
+ },
+
+ hasAscendant : function( name, includeSelf )
+ {
+ var $ = this.$;
+
+ if ( !includeSelf )
+ $ = $.parentNode;
+
+ while ( $ )
+ {
+ if ( $.nodeName && $.nodeName.toLowerCase() == name )
+ return true;
+
+ $ = $.parentNode;
+ }
+ return false;
+ },
+
+ move : function( target, toStart )
+ {
+ target.append( this.remove(), toStart );
+ },
+
+ /**
+ * Removes this node from the document DOM.
+ * @param {Boolean} [preserveChildren] Indicates that the children
+ * elements must remain in the document, removing only the outer
+ * tags.
+ * @example
+ * var element = CKEDITOR.dom.element.getById( 'MyElement' );
+ * element.remove();
+ */
+ remove : function( preserveChildren )
+ {
+ var $ = this.$;
+ var parent = $.parentNode;
+
+ if ( parent )
+ {
+ if ( preserveChildren )
+ {
+ // Move all children before the node.
+ for ( var child ; ( child = $.firstChild ) ; )
+ {
+ parent.insertBefore( $.removeChild( child ), $ );
+ }
+ }
+
+ parent.removeChild( $ );
+ }
+
+ return this;
+ },
+
+ replace : function( nodeToReplace )
+ {
+ this.insertBefore( nodeToReplace );
+ nodeToReplace.remove();
+ },
+
+ trim : function()
+ {
+ this.ltrim();
+ this.rtrim();
+ },
+
+ ltrim : function()
+ {
+ var child;
+ while ( this.getFirst && ( child = this.getFirst() ) )
+ {
+ if ( child.type == CKEDITOR.NODE_TEXT )
+ {
+ var trimmed = CKEDITOR.tools.ltrim( child.getText() ),
+ originalLength = child.getLength();
+
+ if ( !trimmed )
+ {
+ child.remove();
+ continue;
+ }
+ else if ( trimmed.length < originalLength )
+ {
+ child.split( originalLength - trimmed.length );
+
+ // IE BUG: child.remove() may raise JavaScript errors here. (#81)
+ this.$.removeChild( this.$.firstChild );
+ }
+ }
+ break;
+ }
+ },
+
+ rtrim : function()
+ {
+ var child;
+ while ( this.getLast && ( child = this.getLast() ) )
+ {
+ if ( child.type == CKEDITOR.NODE_TEXT )
+ {
+ var trimmed = CKEDITOR.tools.rtrim( child.getText() ),
+ originalLength = child.getLength();
+
+ if ( !trimmed )
+ {
+ child.remove();
+ continue;
+ }
+ else if ( trimmed.length < originalLength )
+ {
+ child.split( trimmed.length );
+
+ // IE BUG: child.getNext().remove() may raise JavaScript errors here.
+ // (#81)
+ this.$.lastChild.parentNode.removeChild( this.$.lastChild );
+ }
+ }
+ break;
+ }
+
+ if ( !CKEDITOR.env.ie && !CKEDITOR.env.opera )
+ {
+ child = this.$.lastChild;
+
+ if ( child && child.type == 1 && child.nodeName.toLowerCase() == 'br' )
+ {
+ // Use "eChildNode.parentNode" instead of "node" to avoid IE bug (#324).
+ child.parentNode.removeChild( child ) ;
+ }
+ }
+ }
+ }
+);
Index: /CKEditor/branches/versions/3.0.x/_source/core/dom/nodelist.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/dom/nodelist.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/dom/nodelist.js (revision 3751)
@@ -0,0 +1,23 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+CKEDITOR.dom.nodeList = function( nativeList )
+{
+ this.$ = nativeList;
+};
+
+CKEDITOR.dom.nodeList.prototype =
+{
+ count : function()
+ {
+ return this.$.length;
+ },
+
+ getItem : function( index )
+ {
+ var $node = this.$[ index ];
+ return $node ? new CKEDITOR.dom.node( $node ) : null;
+ }
+};
Index: /CKEditor/branches/versions/3.0.x/_source/core/dom/range.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/dom/range.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/dom/range.js (revision 3751)
@@ -0,0 +1,1643 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+CKEDITOR.dom.range = function( document )
+{
+ this.startContainer = null;
+ this.startOffset = null;
+ this.endContainer = null;
+ this.endOffset = null;
+ this.collapsed = true;
+
+ this.document = document;
+};
+
+(function()
+{
+ // Updates the "collapsed" property for the given range object.
+ var updateCollapsed = function( range )
+ {
+ range.collapsed = (
+ range.startContainer &&
+ range.endContainer &&
+ range.startContainer.equals( range.endContainer ) &&
+ range.startOffset == range.endOffset );
+ };
+
+ // This is a shared function used to delete, extract and clone the range
+ // contents.
+ // V2
+ var execContentsAction = function( range, action, docFrag )
+ {
+ range.optimizeBookmark();
+
+ var startNode = range.startContainer;
+ var endNode = range.endContainer;
+
+ var startOffset = range.startOffset;
+ var endOffset = range.endOffset;
+
+ var removeStartNode;
+ var removeEndNode;
+
+ // For text containers, we must simply split the node and point to the
+ // second part. The removal will be handled by the rest of the code .
+ if ( endNode.type == CKEDITOR.NODE_TEXT )
+ endNode = endNode.split( endOffset );
+ else
+ {
+ // If the end container has children and the offset is pointing
+ // to a child, then we should start from it.
+ if ( endNode.getChildCount() > 0 )
+ {
+ // If the offset points after the last node.
+ if ( endOffset >= endNode.getChildCount() )
+ {
+ // Let's create a temporary node and mark it for removal.
+ endNode = endNode.append( range.document.createText( '' ) );
+ removeEndNode = true;
+ }
+ else
+ endNode = endNode.getChild( endOffset );
+ }
+ }
+
+ // For text containers, we must simply split the node. The removal will
+ // be handled by the rest of the code .
+ if ( startNode.type == CKEDITOR.NODE_TEXT )
+ {
+ startNode.split( startOffset );
+
+ // In cases the end node is the same as the start node, the above
+ // splitting will also split the end, so me must move the end to
+ // the second part of the split.
+ if ( startNode.equals( endNode ) )
+ endNode = startNode.getNext();
+ }
+ else
+ {
+ // If the start container has children and the offset is pointing
+ // to a child, then we should start from its previous sibling.
+
+ // If the offset points to the first node, we don't have a
+ // sibling, so let's use the first one, but mark it for removal.
+ if ( !startOffset )
+ {
+ // Let's create a temporary node and mark it for removal.
+ startNode = startNode.getFirst().insertBeforeMe( range.document.createText( '' ) );
+ removeStartNode = true;
+ }
+ else if ( startOffset >= startNode.getChildCount() )
+ {
+ // Let's create a temporary node and mark it for removal.
+ startNode = startNode.append( range.document.createText( '' ) );
+ removeStartNode = true;
+ }
+ else
+ startNode = startNode.getChild( startOffset ).getPrevious();
+ }
+
+ // Get the parent nodes tree for the start and end boundaries.
+ var startParents = startNode.getParents();
+ var endParents = endNode.getParents();
+
+ // Compare them, to find the top most siblings.
+ var i, topStart, topEnd;
+
+ for ( i = 0 ; i < startParents.length ; i++ )
+ {
+ topStart = startParents[ i ];
+ topEnd = endParents[ i ];
+
+ // The compared nodes will match until we find the top most
+ // siblings (different nodes that have the same parent).
+ // "i" will hold the index in the parents array for the top
+ // most element.
+ if ( !topStart.equals( topEnd ) )
+ break;
+ }
+
+ var clone = docFrag, levelStartNode, levelClone, currentNode, currentSibling;
+
+ // Remove all successive sibling nodes for every node in the
+ // startParents tree.
+ for ( var j = i ; j < startParents.length ; j++ )
+ {
+ levelStartNode = startParents[j];
+
+ // For Extract and Clone, we must clone this level.
+ if ( clone && !levelStartNode.equals( startNode ) ) // action = 0 = Delete
+ levelClone = clone.append( levelStartNode.clone() );
+
+ currentNode = levelStartNode.getNext();
+
+ while( currentNode )
+ {
+ // Stop processing when the current node matches a node in the
+ // endParents tree or if it is the endNode.
+ if ( currentNode.equals( endParents[ j ] ) || currentNode.equals( endNode ) )
+ break;
+
+ // Cache the next sibling.
+ currentSibling = currentNode.getNext();
+
+ // If cloning, just clone it.
+ if ( action == 2 ) // 2 = Clone
+ clone.append( currentNode.clone( true ) );
+ else
+ {
+ // Both Delete and Extract will remove the node.
+ currentNode.remove();
+
+ // When Extracting, move the removed node to the docFrag.
+ if ( action == 1 ) // 1 = Extract
+ clone.append( currentNode );
+ }
+
+ currentNode = currentSibling;
+ }
+
+ if ( clone )
+ clone = levelClone;
+ }
+
+ clone = docFrag;
+
+ // Remove all previous sibling nodes for every node in the
+ // endParents tree.
+ for ( var k = i ; k < endParents.length ; k++ )
+ {
+ levelStartNode = endParents[ k ];
+
+ // For Extract and Clone, we must clone this level.
+ if ( action > 0 && !levelStartNode.equals( endNode ) ) // action = 0 = Delete
+ levelClone = clone.append( levelStartNode.clone() );
+
+ // The processing of siblings may have already been done by the parent.
+ if ( !startParents[ k ] || levelStartNode.$.parentNode != startParents[ k ].$.parentNode )
+ {
+ currentNode = levelStartNode.getPrevious();
+
+ while( currentNode )
+ {
+ // Stop processing when the current node matches a node in the
+ // startParents tree or if it is the startNode.
+ if ( currentNode.equals( startParents[ k ] ) || currentNode.equals( startNode ) )
+ break;
+
+ // Cache the next sibling.
+ currentSibling = currentNode.getPrevious();
+
+ // If cloning, just clone it.
+ if ( action == 2 ) // 2 = Clone
+ clone.$.insertBefore( currentNode.$.cloneNode( true ), clone.$.firstChild ) ;
+ else
+ {
+ // Both Delete and Extract will remove the node.
+ currentNode.remove();
+
+ // When Extracting, mode the removed node to the docFrag.
+ if ( action == 1 ) // 1 = Extract
+ clone.$.insertBefore( currentNode.$, clone.$.firstChild );
+ }
+
+ currentNode = currentSibling;
+ }
+ }
+
+ if ( clone )
+ clone = levelClone;
+ }
+
+ if ( action == 2 ) // 2 = Clone.
+ {
+ // No changes in the DOM should be done, so fix the split text (if any).
+
+ var startTextNode = range.startContainer;
+ if ( startTextNode.type == CKEDITOR.NODE_TEXT )
+ {
+ startTextNode.$.data += startTextNode.$.nextSibling.data;
+ startTextNode.$.parentNode.removeChild( startTextNode.$.nextSibling );
+ }
+
+ var endTextNode = range.endContainer;
+ if ( endTextNode.type == CKEDITOR.NODE_TEXT && endTextNode.$.nextSibling )
+ {
+ endTextNode.$.data += endTextNode.$.nextSibling.data;
+ endTextNode.$.parentNode.removeChild( endTextNode.$.nextSibling );
+ }
+ }
+ else
+ {
+ // Collapse the range.
+
+ // If a node has been partially selected, collapse the range between
+ // topStart and topEnd. Otherwise, simply collapse it to the start. (W3C specs).
+ if ( topStart && topEnd && ( startNode.$.parentNode != topStart.$.parentNode || endNode.$.parentNode != topEnd.$.parentNode ) )
+ {
+ var endIndex = topEnd.getIndex();
+
+ // If the start node is to be removed, we must correct the
+ // index to reflect the removal.
+ if ( removeStartNode && topEnd.$.parentNode == startNode.$.parentNode )
+ endIndex--;
+
+ range.setStart( topEnd.getParent(), endIndex );
+ }
+
+ // Collapse it to the start.
+ range.collapse( true );
+ }
+
+ // Cleanup any marked node.
+ if( removeStartNode )
+ startNode.remove();
+
+ if( removeEndNode && endNode.$.parentNode )
+ endNode.remove();
+ };
+
+ var inlineChildReqElements = { abbr:1,acronym:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,'var':1 };
+
+ // Creates the appropriate node evaluator for the dom walker used inside
+ // check(Start|End)OfBlock.
+ function getCheckStartEndBlockEvalFunction( isStart )
+ {
+ var hadBr = false, bookmarkEvaluator = CKEDITOR.dom.walker.bookmark( true );
+ return function( node )
+ {
+ // First ignore bookmark nodes.
+ if ( bookmarkEvaluator( node ) )
+ return true;
+
+ if ( node.type == CKEDITOR.NODE_TEXT )
+ {
+ // If there's any visible text, then we're not at the start.
+ if ( CKEDITOR.tools.trim( node.getText() ).length )
+ return false;
+ }
+ else
+ {
+ // If there are non-empty inline elements (e.g. ), then we're not
+ // at the start.
+ if ( !inlineChildReqElements[ node.getName() ] )
+ {
+ // If we're working at the end-of-block, forgive the first in non-IE
+ // browsers.
+ if ( !isStart && !CKEDITOR.env.ie && node.getName() == 'br' && !hadBr )
+ hadBr = true;
+ else
+ return false;
+ }
+ }
+ return true;
+ };
+ }
+
+ // Evaluator for CKEDITOR.dom.element::checkBoundaryOfElement, reject any
+ // text node and non-empty elements unless it's being bookmark text.
+ function elementBoundaryEval( node )
+ {
+ // Reject any text node unless it's being bookmark.
+ return node.type != CKEDITOR.NODE_TEXT
+ && node.getName() in CKEDITOR.dtd.$removeEmpty
+ || node.getParent().hasAttribute( '_fck_bookmark' );
+ }
+
+ CKEDITOR.dom.range.prototype =
+ {
+ clone : function()
+ {
+ var clone = new CKEDITOR.dom.range( this.document );
+
+ clone.startContainer = this.startContainer;
+ clone.startOffset = this.startOffset;
+ clone.endContainer = this.endContainer;
+ clone.endOffset = this.endOffset;
+ clone.collapsed = this.collapsed;
+
+ return clone;
+ },
+
+ collapse : function( toStart )
+ {
+ if ( toStart )
+ {
+ this.endContainer = this.startContainer;
+ this.endOffset = this.startOffset;
+ }
+ else
+ {
+ this.startContainer = this.endContainer;
+ this.startOffset = this.endOffset;
+ }
+
+ this.collapsed = true;
+ },
+
+ // The selection may be lost when cloning (due to the splitText() call).
+ cloneContents : function()
+ {
+ var docFrag = new CKEDITOR.dom.documentFragment( this.document );
+
+ if ( !this.collapsed )
+ execContentsAction( this, 2, docFrag );
+
+ return docFrag;
+ },
+
+ deleteContents : function()
+ {
+ if ( this.collapsed )
+ return;
+
+ execContentsAction( this, 0 );
+ },
+
+ extractContents : function()
+ {
+ var docFrag = new CKEDITOR.dom.documentFragment( this.document );
+
+ if ( !this.collapsed )
+ execContentsAction( this, 1, docFrag );
+
+ return docFrag;
+ },
+
+ /**
+ * Creates a bookmark object, which can be later used to restore the
+ * range by using the moveToBookmark function.
+ * This is an "intrusive" way to create a bookmark. It includes tags
+ * in the range boundaries. The advantage of it is that it is possible to
+ * handle DOM mutations when moving back to the bookmark.
+ * Attention: the inclusion of nodes in the DOM is a design choice and
+ * should not be changed as there are other points in the code that may be
+ * using those nodes to perform operations. See GetBookmarkNode.
+ * @param {Boolean} [serializable] Indicates that the bookmark nodes
+ * must contain ids, which can be used to restore the range even
+ * when these nodes suffer mutations (like a clonation or innerHTML
+ * change).
+ * @returns {Object} And object representing a bookmark.
+ */
+ createBookmark : function( serializable )
+ {
+ var startNode, endNode;
+ var baseId;
+ var clone;
+
+ startNode = this.document.createElement( 'span' );
+ startNode.setAttribute( '_fck_bookmark', 1 );
+ startNode.setStyle( 'display', 'none' );
+
+ // For IE, it must have something inside, otherwise it may be
+ // removed during DOM operations.
+ startNode.setHtml( ' ' );
+
+ if ( serializable )
+ {
+ baseId = 'cke_bm_' + CKEDITOR.tools.getNextNumber();
+ startNode.setAttribute( 'id', baseId + 'S' );
+ }
+
+ // If collapsed, the endNode will not be created.
+ if ( !this.collapsed )
+ {
+ endNode = startNode.clone();
+ endNode.setHtml( ' ' );
+
+ if ( serializable )
+ endNode.setAttribute( 'id', baseId + 'E' );
+
+ clone = this.clone();
+ clone.collapse();
+ clone.insertNode( endNode );
+ }
+
+ clone = this.clone();
+ clone.collapse( true );
+ clone.insertNode( startNode );
+
+ // Update the range position.
+ if ( endNode )
+ {
+ this.setStartAfter( startNode );
+ this.setEndBefore( endNode );
+ }
+ else
+ this.moveToPosition( startNode, CKEDITOR.POSITION_AFTER_END );
+
+ return {
+ startNode : serializable ? baseId + 'S' : startNode,
+ endNode : serializable ? baseId + 'E' : endNode,
+ serializable : serializable
+ };
+ },
+
+ /**
+ * Creates a "non intrusive" and "mutation sensible" bookmark. This
+ * kind of bookmark should be used only when the DOM is supposed to
+ * remain stable after its creation.
+ * @param {Boolean} [normalized] Indicates that the bookmark must
+ * normalized. When normalized, the successive text nodes are
+ * considered a single node. To sucessful load a normalized
+ * bookmark, the DOM tree must be also normalized before calling
+ * moveToBookmark.
+ * @returns {Object} An object representing the bookmark.
+ */
+ createBookmark2 : function( normalized )
+ {
+ var startContainer = this.startContainer,
+ endContainer = this.endContainer;
+
+ var startOffset = this.startOffset,
+ endOffset = this.endOffset;
+
+ var child, previous;
+
+ // If there is no range then get out of here.
+ // It happens on initial load in Safari #962 and if the editor it's
+ // hidden also in Firefox
+ if ( !startContainer || !endContainer )
+ return { start : 0, end : 0 };
+
+ if ( normalized )
+ {
+ // Find out if the start is pointing to a text node that will
+ // be normalized.
+ if ( startContainer.type == CKEDITOR.NODE_ELEMENT )
+ {
+ child = startContainer.getChild( startOffset );
+
+ // In this case, move the start information to that text
+ // node.
+ if ( child && child.type == CKEDITOR.NODE_TEXT
+ && startOffset > 0 && child.getPrevious().type == CKEDITOR.NODE_TEXT )
+ {
+ startContainer = child;
+ startOffset = 0;
+ }
+ }
+
+ // Normalize the start.
+ while ( startContainer.type == CKEDITOR.NODE_TEXT
+ && ( previous = startContainer.getPrevious() )
+ && previous.type == CKEDITOR.NODE_TEXT )
+ {
+ startContainer = previous;
+ startOffset += previous.getLength();
+ }
+
+ // Process the end only if not normalized.
+ if ( !this.isCollapsed )
+ {
+ // Find out if the start is pointing to a text node that
+ // will be normalized.
+ if ( endContainer.type == CKEDITOR.NODE_ELEMENT )
+ {
+ child = endContainer.getChild( endOffset );
+
+ // In this case, move the start information to that
+ // text node.
+ if ( child && child.type == CKEDITOR.NODE_TEXT
+ && endOffset > 0 && child.getPrevious().type == CKEDITOR.NODE_TEXT )
+ {
+ endContainer = child;
+ endOffset = 0;
+ }
+ }
+
+ // Normalize the end.
+ while ( endContainer.type == CKEDITOR.NODE_TEXT
+ && ( previous = endContainer.getPrevious() )
+ && previous.type == CKEDITOR.NODE_TEXT )
+ {
+ endContainer = previous;
+ endOffset += previous.getLength();
+ }
+ }
+ }
+
+ return {
+ start : startContainer.getAddress( normalized ),
+ end : this.isCollapsed ? null : endContainer.getAddress( normalized ),
+ startOffset : startOffset,
+ endOffset : endOffset,
+ normalized : normalized,
+ is2 : true // It's a createBookmark2 bookmark.
+ };
+ },
+
+ moveToBookmark : function( bookmark )
+ {
+ if ( bookmark.is2 ) // Created with createBookmark2().
+ {
+ // Get the start information.
+ var startContainer = this.document.getByAddress( bookmark.start, bookmark.normalized ),
+ startOffset = bookmark.startOffset;
+
+ // Get the end information.
+ var endContainer = bookmark.end && this.document.getByAddress( bookmark.end, bookmark.normalized ),
+ endOffset = bookmark.endOffset;
+
+ // Set the start boundary.
+ this.setStart( startContainer, startOffset );
+
+ // Set the end boundary. If not available, collapse it.
+ if ( endContainer )
+ this.setEnd( endContainer, endOffset );
+ else
+ this.collapse( true );
+ }
+ else // Created with createBookmark().
+ {
+ var serializable = bookmark.serializable,
+ startNode = serializable ? this.document.getById( bookmark.startNode ) : bookmark.startNode,
+ endNode = serializable ? this.document.getById( bookmark.endNode ) : bookmark.endNode;
+
+ // Set the range start at the bookmark start node position.
+ this.setStartBefore( startNode );
+
+ // Remove it, because it may interfere in the setEndBefore call.
+ startNode.remove();
+
+ // Set the range end at the bookmark end node position, or simply
+ // collapse it if it is not available.
+ if ( endNode )
+ {
+ this.setEndBefore( endNode );
+ endNode.remove();
+ }
+ else
+ this.collapse( true );
+ }
+ },
+
+ getBoundaryNodes : function()
+ {
+ var startNode = this.startContainer,
+ endNode = this.endContainer,
+ startOffset = this.startOffset,
+ endOffset = this.endOffset,
+ childCount;
+
+ if ( startNode.type == CKEDITOR.NODE_ELEMENT )
+ {
+ childCount = startNode.getChildCount();
+ if ( childCount > startOffset )
+ startNode = startNode.getChild( startOffset );
+ else if ( childCount < 1 )
+ startNode = startNode.getPreviousSourceNode();
+ else // startOffset > childCount but childCount is not 0
+ {
+ // Try to take the node just after the current position.
+ startNode = startNode.$;
+ while ( startNode.lastChild )
+ startNode = startNode.lastChild;
+ startNode = new CKEDITOR.dom.node( startNode );
+
+ // Normally we should take the next node in DFS order. But it
+ // is also possible that we've already reached the end of
+ // document.
+ startNode = startNode.getNextSourceNode() || startNode;
+ }
+ }
+ if ( endNode.type == CKEDITOR.NODE_ELEMENT )
+ {
+ childCount = endNode.getChildCount();
+ if ( childCount > endOffset )
+ endNode = endNode.getChild( endOffset ).getPreviousSourceNode( true );
+ else if ( childCount < 1 )
+ endNode = endNode.getPreviousSourceNode();
+ else // endOffset > childCount but childCount is not 0
+ {
+ // Try to take the node just before the current position.
+ endNode = endNode.$;
+ while ( endNode.lastChild )
+ endNode = endNode.lastChild;
+ endNode = new CKEDITOR.dom.node( endNode );
+ }
+ }
+
+ // Sometimes the endNode will come right before startNode for collapsed
+ // ranges. Fix it. (#3780)
+ if ( startNode.getPosition( endNode ) & CKEDITOR.POSITION_FOLLOWING )
+ startNode = endNode;
+
+ return { startNode : startNode, endNode : endNode };
+ },
+
+ /**
+ * Find the node which fully contains the range.
+ * @param includeSelf
+ * @param {Boolean} ignoreTextNode Whether ignore CKEDITOR.NODE_TEXT type.
+ */
+ getCommonAncestor : function( includeSelf , ignoreTextNode )
+ {
+ var start = this.startContainer,
+ end = this.endContainer,
+ ancestor;
+
+ if ( start.equals( end ) )
+ {
+ if ( includeSelf
+ && start.type == CKEDITOR.NODE_ELEMENT
+ && this.startOffset == this.endOffset - 1 )
+ ancestor = start.getChild( this.startOffset );
+ else
+ ancestor = start;
+ }
+ else
+ ancestor = start.getCommonAncestor( end );
+
+ return ignoreTextNode && !ancestor.is ? ancestor.getParent() : ancestor;
+ },
+
+ /**
+ * Transforms the startContainer and endContainer properties from text
+ * nodes to element nodes, whenever possible. This is actually possible
+ * if either of the boundary containers point to a text node, and its
+ * offset is set to zero, or after the last char in the node.
+ */
+ optimize : function()
+ {
+ var container = this.startContainer;
+ var offset = this.startOffset;
+
+ if ( container.type != CKEDITOR.NODE_ELEMENT )
+ {
+ if ( !offset )
+ this.setStartBefore( container );
+ else if ( offset >= container.getLength() )
+ this.setStartAfter( container );
+ }
+
+ container = this.endContainer;
+ offset = this.endOffset;
+
+ if ( container.type != CKEDITOR.NODE_ELEMENT )
+ {
+ if ( !offset )
+ this.setEndBefore( container );
+ else if ( offset >= container.getLength() )
+ this.setEndAfter( container );
+ }
+ },
+
+ /**
+ * Move the range out of bookmark nodes if they're been the container.
+ */
+ optimizeBookmark: function()
+ {
+ var startNode = this.startContainer,
+ endNode = this.endContainer;
+
+ if ( startNode.is && startNode.is( 'span' )
+ && startNode.hasAttribute( '_fck_bookmark' ) )
+ this.setStartAt( startNode, CKEDITOR.POSITION_BEFORE_START );
+ if ( endNode && endNode.is && endNode.is( 'span' )
+ && endNode.hasAttribute( '_fck_bookmark' ) )
+ this.setEndAt( endNode, CKEDITOR.POSITION_AFTER_END );
+ },
+
+ trim : function( ignoreStart, ignoreEnd )
+ {
+ var startContainer = this.startContainer,
+ startOffset = this.startOffset,
+ collapsed = this.collapsed;
+ if ( ( !ignoreStart || collapsed )
+ && startContainer && startContainer.type == CKEDITOR.NODE_TEXT )
+ {
+ // If the offset is zero, we just insert the new node before
+ // the start.
+ if ( !startOffset )
+ {
+ startOffset = startContainer.getIndex();
+ startContainer = startContainer.getParent();
+ }
+ // If the offset is at the end, we'll insert it after the text
+ // node.
+ else if ( startOffset >= startContainer.getLength() )
+ {
+ startOffset = startContainer.getIndex() + 1;
+ startContainer = startContainer.getParent();
+ }
+ // In other case, we split the text node and insert the new
+ // node at the split point.
+ else
+ {
+ var nextText = startContainer.split( startOffset );
+
+ startOffset = startContainer.getIndex() + 1;
+ startContainer = startContainer.getParent();
+ // Check if it is necessary to update the end boundary.
+ if ( !collapsed && this.startContainer.equals( this.endContainer ) )
+ this.setEnd( nextText, this.endOffset - this.startOffset );
+ }
+
+ this.setStart( startContainer, startOffset );
+
+ if ( collapsed )
+ this.collapse( true );
+ }
+
+ var endContainer = this.endContainer;
+ var endOffset = this.endOffset;
+
+ if ( !( ignoreEnd || collapsed )
+ && endContainer && endContainer.type == CKEDITOR.NODE_TEXT )
+ {
+ // If the offset is zero, we just insert the new node before
+ // the start.
+ if ( !endOffset )
+ {
+ endOffset = endContainer.getIndex();
+ endContainer = endContainer.getParent();
+ }
+ // If the offset is at the end, we'll insert it after the text
+ // node.
+ else if ( endOffset >= endContainer.getLength() )
+ {
+ endOffset = endContainer.getIndex() + 1;
+ endContainer = endContainer.getParent();
+ }
+ // In other case, we split the text node and insert the new
+ // node at the split point.
+ else
+ {
+ endContainer.split( endOffset );
+
+ endOffset = endContainer.getIndex() + 1;
+ endContainer = endContainer.getParent();
+ }
+
+ this.setEnd( endContainer, endOffset );
+ }
+ },
+
+ enlarge : function( unit )
+ {
+ switch ( unit )
+ {
+ case CKEDITOR.ENLARGE_ELEMENT :
+
+ if ( this.collapsed )
+ return;
+
+ // Get the common ancestor.
+ var commonAncestor = this.getCommonAncestor();
+
+ var body = this.document.getBody();
+
+ // For each boundary
+ // a. Depending on its position, find out the first node to be checked (a sibling) or, if not available, to be enlarge.
+ // b. Go ahead checking siblings and enlarging the boundary as much as possible until the common ancestor is not reached. After reaching the common ancestor, just save the enlargeable node to be used later.
+
+ var startTop, endTop;
+
+ var enlargeable, sibling, commonReached;
+
+ // Indicates that the node can be added only if whitespace
+ // is available before it.
+ var needsWhiteSpace = false;
+ var isWhiteSpace;
+ var siblingText;
+
+ // Process the start boundary.
+
+ var container = this.startContainer;
+ var offset = this.startOffset;
+
+ if ( container.type == CKEDITOR.NODE_TEXT )
+ {
+ if ( offset )
+ {
+ // Check if there is any non-space text before the
+ // offset. Otherwise, container is null.
+ container = !CKEDITOR.tools.trim( container.substring( 0, offset ) ).length && container;
+
+ // If we found only whitespace in the node, it
+ // means that we'll need more whitespace to be able
+ // to expand. For example, can be expanded in
+ // "A [B]", but not in "A [B]".
+ needsWhiteSpace = !!container;
+ }
+
+ if ( container )
+ {
+ if ( !( sibling = container.getPrevious() ) )
+ enlargeable = container.getParent();
+ }
+ }
+ else
+ {
+ // If we have offset, get the node preceeding it as the
+ // first sibling to be checked.
+ if ( offset )
+ sibling = container.getChild( offset - 1 ) || container.getLast();
+
+ // If there is no sibling, mark the container to be
+ // enlarged.
+ if ( !sibling )
+ enlargeable = container;
+ }
+
+ while ( enlargeable || sibling )
+ {
+ if ( enlargeable && !sibling )
+ {
+ // If we reached the common ancestor, mark the flag
+ // for it.
+ if ( !commonReached && enlargeable.equals( commonAncestor ) )
+ commonReached = true;
+
+ if ( !body.contains( enlargeable ) )
+ break;
+
+ // If we don't need space or this element breaks
+ // the line, then enlarge it.
+ if ( !needsWhiteSpace || enlargeable.getComputedStyle( 'display' ) != 'inline' )
+ {
+ needsWhiteSpace = false;
+
+ // If the common ancestor has been reached,
+ // we'll not enlarge it immediately, but just
+ // mark it to be enlarged later if the end
+ // boundary also enlarges it.
+ if ( commonReached )
+ startTop = enlargeable;
+ else
+ this.setStartBefore( enlargeable );
+ }
+
+ sibling = enlargeable.getPrevious();
+ }
+
+ // Check all sibling nodes preceeding the enlargeable
+ // node. The node wil lbe enlarged only if none of them
+ // blocks it.
+ while ( sibling )
+ {
+ // This flag indicates that this node has
+ // whitespaces at the end.
+ isWhiteSpace = false;
+
+ if ( sibling.type == CKEDITOR.NODE_TEXT )
+ {
+ siblingText = sibling.getText();
+
+ if ( /[^\s\ufeff]/.test( siblingText ) )
+ sibling = null;
+
+ isWhiteSpace = /[\s\ufeff]$/.test( siblingText );
+ }
+ else
+ {
+ // If this is a visible element.
+ // We need to check for the bookmark attribute because IE insists on
+ // rendering the display:none nodes we use for bookmarks. (#3363)
+ if ( sibling.$.offsetWidth > 0 && !sibling.getAttribute( '_fck_bookmark' ) )
+ {
+ // We'll accept it only if we need
+ // whitespace, and this is an inline
+ // element with whitespace only.
+ if ( needsWhiteSpace && CKEDITOR.dtd.$removeEmpty[ sibling.getName() ] )
+ {
+ // It must contains spaces and inline elements only.
+
+ siblingText = sibling.getText();
+
+ if ( !(/[^\s\ufeff]/).test( siblingText ) ) // Spaces + Zero Width No-Break Space (U+FEFF)
+ sibling = null;
+ else
+ {
+ var allChildren = sibling.$.all || sibling.$.getElementsByTagName( '*' );
+ for ( var i = 0, child ; child = allChildren[ i++ ] ; )
+ {
+ if ( !CKEDITOR.dtd.$removeEmpty[ child.nodeName.toLowerCase() ] )
+ {
+ sibling = null;
+ break;
+ }
+ }
+ }
+
+ if ( sibling )
+ isWhiteSpace = !!siblingText.length;
+ }
+ else
+ sibling = null;
+ }
+ }
+
+ // A node with whitespaces has been found.
+ if ( isWhiteSpace )
+ {
+ // Enlarge the last enlargeable node, if we
+ // were waiting for spaces.
+ if ( needsWhiteSpace )
+ {
+ if ( commonReached )
+ startTop = enlargeable;
+ else if ( enlargeable )
+ this.setStartBefore( enlargeable );
+ }
+ else
+ needsWhiteSpace = true;
+ }
+
+ if ( sibling )
+ {
+ var next = sibling.getPrevious();
+
+ if ( !enlargeable && !next )
+ {
+ // Set the sibling as enlargeable, so it's
+ // parent will be get later outside this while.
+ enlargeable = sibling;
+ sibling = null;
+ break;
+ }
+
+ sibling = next;
+ }
+ else
+ {
+ // If sibling has been set to null, then we
+ // need to stop enlarging.
+ enlargeable = null;
+ }
+ }
+
+ if ( enlargeable )
+ enlargeable = enlargeable.getParent();
+ }
+
+ // Process the end boundary. This is basically the same
+ // code used for the start boundary, with small changes to
+ // make it work in the oposite side (to the right). This
+ // makes it difficult to reuse the code here. So, fixes to
+ // the above code are likely to be replicated here.
+
+ container = this.endContainer;
+ offset = this.endOffset;
+
+ // Reset the common variables.
+ enlargeable = sibling = null;
+ commonReached = needsWhiteSpace = false;
+
+ if ( container.type == CKEDITOR.NODE_TEXT )
+ {
+ // Check if there is any non-space text after the
+ // offset. Otherwise, container is null.
+ container = !CKEDITOR.tools.trim( container.substring( offset ) ).length && container;
+
+ // If we found only whitespace in the node, it
+ // means that we'll need more whitespace to be able
+ // to expand. For example, can be expanded in
+ // "A [B]", but not in "A [B]".
+ needsWhiteSpace = !( container && container.getLength() );
+
+ if ( container )
+ {
+ if ( !( sibling = container.getNext() ) )
+ enlargeable = container.getParent();
+ }
+ }
+ else
+ {
+ // Get the node right after the boudary to be checked
+ // first.
+ sibling = container.getChild( offset );
+
+ if ( !sibling )
+ enlargeable = container;
+ }
+
+ while ( enlargeable || sibling )
+ {
+ if ( enlargeable && !sibling )
+ {
+ if ( !commonReached && enlargeable.equals( commonAncestor ) )
+ commonReached = true;
+
+ if ( !body.contains( enlargeable ) )
+ break;
+
+ if ( !needsWhiteSpace || enlargeable.getComputedStyle( 'display' ) != 'inline' )
+ {
+ needsWhiteSpace = false;
+
+ if ( commonReached )
+ endTop = enlargeable;
+ else if ( enlargeable )
+ this.setEndAfter( enlargeable );
+ }
+
+ sibling = enlargeable.getNext();
+ }
+
+ while ( sibling )
+ {
+ isWhiteSpace = false;
+
+ if ( sibling.type == CKEDITOR.NODE_TEXT )
+ {
+ siblingText = sibling.getText();
+
+ if ( /[^\s\ufeff]/.test( siblingText ) )
+ sibling = null;
+
+ isWhiteSpace = /^[\s\ufeff]/.test( siblingText );
+ }
+ else
+ {
+ // If this is a visible element.
+ // We need to check for the bookmark attribute because IE insists on
+ // rendering the display:none nodes we use for bookmarks. (#3363)
+ if ( sibling.$.offsetWidth > 0 && !sibling.getAttribute( '_fck_bookmark' ) )
+ {
+ // We'll accept it only if we need
+ // whitespace, and this is an inline
+ // element with whitespace only.
+ if ( needsWhiteSpace && CKEDITOR.dtd.$removeEmpty[ sibling.getName() ] )
+ {
+ // It must contains spaces and inline elements only.
+
+ siblingText = sibling.getText();
+
+ if ( !(/[^\s\ufeff]/).test( siblingText ) )
+ sibling = null;
+ else
+ {
+ allChildren = sibling.$.all || sibling.$.getElementsByTagName( '*' );
+ for ( i = 0 ; child = allChildren[ i++ ] ; )
+ {
+ if ( !CKEDITOR.dtd.$removeEmpty[ child.nodeName.toLowerCase() ] )
+ {
+ sibling = null;
+ break;
+ }
+ }
+ }
+
+ if ( sibling )
+ isWhiteSpace = !!siblingText.length;
+ }
+ else
+ sibling = null;
+ }
+ }
+
+ if ( isWhiteSpace )
+ {
+ if ( needsWhiteSpace )
+ {
+ if ( commonReached )
+ endTop = enlargeable;
+ else
+ this.setEndAfter( enlargeable );
+ }
+ }
+
+ if ( sibling )
+ {
+ next = sibling.getNext();
+
+ if ( !enlargeable && !next )
+ {
+ enlargeable = sibling;
+ sibling = null;
+ break;
+ }
+
+ sibling = next;
+ }
+ else
+ {
+ // If sibling has been set to null, then we
+ // need to stop enlarging.
+ enlargeable = null;
+ }
+ }
+
+ if ( enlargeable )
+ enlargeable = enlargeable.getParent();
+ }
+
+ // If the common ancestor can be enlarged by both boundaries, then include it also.
+ if ( startTop && endTop )
+ {
+ commonAncestor = startTop.contains( endTop ) ? endTop : startTop;
+
+ this.setStartBefore( commonAncestor );
+ this.setEndAfter( commonAncestor );
+ }
+ break;
+
+ case CKEDITOR.ENLARGE_BLOCK_CONTENTS:
+ case CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS:
+
+ // Enlarging the start boundary.
+ var walkerRange = new CKEDITOR.dom.range( this.document );
+
+ body = this.document.getBody();
+
+ walkerRange.setStartAt( body, CKEDITOR.POSITION_AFTER_START );
+ walkerRange.setEnd( this.startContainer, this.startOffset );
+
+ var walker = new CKEDITOR.dom.walker( walkerRange ),
+ blockBoundary, // The node on which the enlarging should stop.
+ tailBr, //
+ defaultGuard = CKEDITOR.dom.walker.blockBoundary(
+ ( unit == CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS ) ? { br : 1 } : null ),
+ // Record the encountered 'blockBoundary' for later use.
+ boundaryGuard = function( node )
+ {
+ var retval = defaultGuard( node );
+ if ( !retval )
+ blockBoundary = node;
+ return retval;
+ },
+ // Record the encounted 'tailBr' for later use.
+ tailBrGuard = function( node )
+ {
+ var retval = boundaryGuard( node );
+ if ( !retval && node.is && node.is( 'br' ) )
+ tailBr = node;
+ return retval;
+ };
+
+ walker.guard = boundaryGuard;
+
+
+ if ( ( enlargeable = walker.lastBackward() ) )
+ {
+ // It's the body which stop the enlaring if no block boundary found.
+ blockBoundary = blockBoundary || body;
+
+ // Start the range at different position by comparing
+ // the document position of it with 'enlargeable' node.
+ this.setStartAt(
+ blockBoundary,
+ blockBoundary.contains( enlargeable ) ?
+ CKEDITOR.POSITION_AFTER_START :
+ CKEDITOR.POSITION_AFTER_END );
+ }
+
+ // Enlarging the end boundary.
+ walkerRange = this.clone();
+ walkerRange.collapse();
+ walkerRange.setEndAt( body, CKEDITOR.POSITION_BEFORE_END );
+ walker = new CKEDITOR.dom.walker( walkerRange );
+
+ // tailBrGuard only used for on range end.
+ walker.guard = ( unit == CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS ) ?
+ tailBrGuard : boundaryGuard;
+ blockBoundary = null;
+ // End the range right before the block boundary node.
+
+ if ( ( enlargeable = walker.lastForward() ) )
+ {
+ // It's the body which stop the enlaring if no block boundary found.
+ blockBoundary = blockBoundary || body;
+
+ // Start the range at different position by comparing
+ // the document position of it with 'enlargeable' node.
+ this.setEndAt(
+ blockBoundary,
+ blockBoundary.contains( enlargeable ) ?
+ CKEDITOR.POSITION_BEFORE_END :
+ CKEDITOR.POSITION_BEFORE_START );
+ }
+ // We must include the at the end of range if there's
+ // one and we're expanding list item contents
+ if ( tailBr )
+ this.setEndAfter( tailBr );
+ }
+ },
+
+ /**
+ * Inserts a node at the start of the range. The range will be expanded
+ * the contain the node.
+ */
+ insertNode : function( node )
+ {
+ this.optimizeBookmark();
+ this.trim( false, true );
+
+ var startContainer = this.startContainer;
+ var startOffset = this.startOffset;
+
+ var nextNode = startContainer.getChild( startOffset );
+
+ if ( nextNode )
+ node.insertBefore( nextNode );
+ else
+ startContainer.append( node );
+
+ // Check if we need to update the end boundary.
+ if ( node.getParent().equals( this.endContainer ) )
+ this.endOffset++;
+
+ // Expand the range to embrace the new node.
+ this.setStartBefore( node );
+ },
+
+ moveToPosition : function( node, position )
+ {
+ this.setStartAt( node, position );
+ this.collapse( true );
+ },
+
+ selectNodeContents : function( node )
+ {
+ this.setStart( node, 0 );
+ this.setEnd( node, node.type == CKEDITOR.NODE_TEXT ? node.getLength() : node.getChildCount() );
+ },
+
+ /**
+ * Sets the start position of a Range.
+ * @param {CKEDITOR.dom.node} startNode The node to start the range.
+ * @param {Number} startOffset An integer greater than or equal to zero
+ * representing the offset for the start of the range from the start
+ * of startNode.
+ */
+ setStart : function( startNode, startOffset )
+ {
+ // W3C requires a check for the new position. If it is after the end
+ // boundary, the range should be collapsed to the new start. It seams
+ // we will not need this check for our use of this class so we can
+ // ignore it for now.
+
+ this.startContainer = startNode;
+ this.startOffset = startOffset;
+
+ if ( !this.endContainer )
+ {
+ this.endContainer = startNode;
+ this.endOffset = startOffset;
+ }
+
+ updateCollapsed( this );
+ },
+
+ /**
+ * Sets the end position of a Range.
+ * @param {CKEDITOR.dom.node} endNode The node to end the range.
+ * @param {Number} endOffset An integer greater than or equal to zero
+ * representing the offset for the end of the range from the start
+ * of endNode.
+ */
+ setEnd : function( endNode, endOffset )
+ {
+ // W3C requires a check for the new position. If it is before the start
+ // boundary, the range should be collapsed to the new end. It seams we
+ // will not need this check for our use of this class so we can ignore
+ // it for now.
+
+ this.endContainer = endNode;
+ this.endOffset = endOffset;
+
+ if ( !this.startContainer )
+ {
+ this.startContainer = endNode;
+ this.startOffset = endOffset;
+ }
+
+ updateCollapsed( this );
+ },
+
+ setStartAfter : function( node )
+ {
+ this.setStart( node.getParent(), node.getIndex() + 1 );
+ },
+
+ setStartBefore : function( node )
+ {
+ this.setStart( node.getParent(), node.getIndex() );
+ },
+
+ setEndAfter : function( node )
+ {
+ this.setEnd( node.getParent(), node.getIndex() + 1 );
+ },
+
+ setEndBefore : function( node )
+ {
+ this.setEnd( node.getParent(), node.getIndex() );
+ },
+
+ setStartAt : function( node, position )
+ {
+ switch( position )
+ {
+ case CKEDITOR.POSITION_AFTER_START :
+ this.setStart( node, 0 );
+ break;
+
+ case CKEDITOR.POSITION_BEFORE_END :
+ if ( node.type == CKEDITOR.NODE_TEXT )
+ this.setStart( node, node.getLength() );
+ else
+ this.setStart( node, node.getChildCount() );
+ break;
+
+ case CKEDITOR.POSITION_BEFORE_START :
+ this.setStartBefore( node );
+ break;
+
+ case CKEDITOR.POSITION_AFTER_END :
+ this.setStartAfter( node );
+ }
+
+ updateCollapsed( this );
+ },
+
+ setEndAt : function( node, position )
+ {
+ switch( position )
+ {
+ case CKEDITOR.POSITION_AFTER_START :
+ this.setEnd( node, 0 );
+ break;
+
+ case CKEDITOR.POSITION_BEFORE_END :
+ if ( node.type == CKEDITOR.NODE_TEXT )
+ this.setEnd( node, node.getLength() );
+ else
+ this.setEnd( node, node.getChildCount() );
+ break;
+
+ case CKEDITOR.POSITION_BEFORE_START :
+ this.setEndBefore( node );
+ break;
+
+ case CKEDITOR.POSITION_AFTER_END :
+ this.setEndAfter( node );
+ }
+
+ updateCollapsed( this );
+ },
+
+ fixBlock : function( isStart, blockTag )
+ {
+ var bookmark = this.createBookmark(),
+ fixedBlock = this.document.createElement( blockTag );
+
+ this.collapse( isStart );
+
+ this.enlarge( CKEDITOR.ENLARGE_BLOCK_CONTENTS );
+
+ this.extractContents().appendTo( fixedBlock );
+ fixedBlock.trim();
+
+ if ( !CKEDITOR.env.ie )
+ fixedBlock.appendBogus();
+
+ this.insertNode( fixedBlock );
+
+ this.moveToBookmark( bookmark );
+
+ return fixedBlock;
+ },
+
+ splitBlock : function( blockTag )
+ {
+ var startPath = new CKEDITOR.dom.elementPath( this.startContainer ),
+ endPath = new CKEDITOR.dom.elementPath( this.endContainer );
+
+ var startBlockLimit = startPath.blockLimit,
+ endBlockLimit = endPath.blockLimit;
+
+ var startBlock = startPath.block,
+ endBlock = endPath.block;
+
+ var elementPath = null;
+ // Do nothing if the boundaries are in different block limits.
+ if ( !startBlockLimit.equals( endBlockLimit ) )
+ return null;
+
+ // Get or fix current blocks.
+ if ( blockTag != 'br' )
+ {
+ if ( !startBlock )
+ {
+ startBlock = this.fixBlock( true, blockTag );
+ endBlock = new CKEDITOR.dom.elementPath( this.endContainer ).block;
+ }
+
+ if ( !endBlock )
+ endBlock = this.fixBlock( false, blockTag );
+ }
+
+ // Get the range position.
+ var isStartOfBlock = startBlock && this.checkStartOfBlock(),
+ isEndOfBlock = endBlock && this.checkEndOfBlock();
+
+ // Delete the current contents.
+ // TODO: Why is 2.x doing CheckIsEmpty()?
+ this.deleteContents();
+
+ if ( startBlock && startBlock.equals( endBlock ) )
+ {
+ if ( isEndOfBlock )
+ {
+ elementPath = new CKEDITOR.dom.elementPath( this.startContainer );
+ this.moveToPosition( endBlock, CKEDITOR.POSITION_AFTER_END );
+ endBlock = null;
+ }
+ else if ( isStartOfBlock )
+ {
+ elementPath = new CKEDITOR.dom.elementPath( this.startContainer );
+ this.moveToPosition( startBlock, CKEDITOR.POSITION_BEFORE_START );
+ startBlock = null;
+ }
+ else
+ {
+ // Extract the contents of the block from the selection point to the end
+ // of its contents.
+ this.setEndAt( startBlock, CKEDITOR.POSITION_BEFORE_END );
+ var documentFragment = this.extractContents();
+
+ // Duplicate the block element after it.
+ endBlock = startBlock.clone( false );
+
+ // Place the extracted contents into the duplicated block.
+ documentFragment.appendTo( endBlock );
+ endBlock.insertAfter( startBlock );
+ this.moveToPosition( startBlock, CKEDITOR.POSITION_AFTER_END );
+
+ // In Gecko, the last child node must be a bogus .
+ // Note: bogus added under
or would cause
+ // lists to be incorrectly rendered.
+ if ( !CKEDITOR.env.ie && !startBlock.is( 'ul', 'ol') )
+ startBlock.appendBogus() ;
+ }
+ }
+
+ return {
+ previousBlock : startBlock,
+ nextBlock : endBlock,
+ wasStartOfBlock : isStartOfBlock,
+ wasEndOfBlock : isEndOfBlock,
+ elementPath : elementPath
+ };
+ },
+
+ /**
+ * Check whether current range is on the inner edge of the specified element.
+ * @param {Number} checkType ( CKEDITOR.START | CKEDITOR.END ) The checking side.
+ * @param {CKEDITOR.dom.element} element The target element to check.
+ */
+ checkBoundaryOfElement : function( element, checkType )
+ {
+ var walkerRange = this.clone();
+ // Expand the range to element boundary.
+ walkerRange[ checkType == CKEDITOR.START ?
+ 'setStartAt' : 'setEndAt' ]
+ ( element, checkType == CKEDITOR.START ?
+ CKEDITOR.POSITION_AFTER_START
+ : CKEDITOR.POSITION_BEFORE_END );
+
+ var walker = new CKEDITOR.dom.walker( walkerRange ),
+ retval = false;
+ walker.evaluator = elementBoundaryEval;
+ return walker[ checkType == CKEDITOR.START ?
+ 'checkBackward' : 'checkForward' ]();
+ },
+ // Calls to this function may produce changes to the DOM. The range may
+ // be updated to reflect such changes.
+ checkStartOfBlock : function()
+ {
+ var startContainer = this.startContainer,
+ startOffset = this.startOffset;
+
+ // If the starting node is a text node, and non-empty before the offset,
+ // then we're surely not at the start of block.
+ if ( startOffset && startContainer.type == CKEDITOR.NODE_TEXT )
+ {
+ var textBefore = CKEDITOR.tools.ltrim( startContainer.substring( 0, startOffset ) );
+ if ( textBefore.length )
+ return false;
+ }
+
+ // Antecipate the trim() call here, so the walker will not make
+ // changes to the DOM, which would not get reflected into this
+ // range otherwise.
+ this.trim();
+
+ // We need to grab the block element holding the start boundary, so
+ // let's use an element path for it.
+ var path = new CKEDITOR.dom.elementPath( this.startContainer );
+
+ // Creates a range starting at the block start until the range start.
+ var walkerRange = this.clone();
+ walkerRange.collapse( true );
+ walkerRange.setStartAt( path.block || path.blockLimit, CKEDITOR.POSITION_AFTER_START );
+
+ var walker = new CKEDITOR.dom.walker( walkerRange );
+ walker.evaluator = getCheckStartEndBlockEvalFunction( true );
+
+ return walker.checkBackward();
+ },
+
+ checkEndOfBlock : function()
+ {
+ var endContainer = this.endContainer,
+ endOffset = this.endOffset;
+
+ // If the ending node is a text node, and non-empty after the offset,
+ // then we're surely not at the end of block.
+ if ( endContainer.type == CKEDITOR.NODE_TEXT )
+ {
+ var textAfter = CKEDITOR.tools.rtrim( endContainer.substring( endOffset ) );
+ if ( textAfter.length )
+ return false;
+ }
+
+ // Antecipate the trim() call here, so the walker will not make
+ // changes to the DOM, which would not get reflected into this
+ // range otherwise.
+ this.trim();
+
+ // We need to grab the block element holding the start boundary, so
+ // let's use an element path for it.
+ var path = new CKEDITOR.dom.elementPath( this.endContainer );
+
+ // Creates a range starting at the block start until the range start.
+ var walkerRange = this.clone();
+ walkerRange.collapse( false );
+ walkerRange.setEndAt( path.block || path.blockLimit, CKEDITOR.POSITION_BEFORE_END );
+
+ var walker = new CKEDITOR.dom.walker( walkerRange );
+ walker.evaluator = getCheckStartEndBlockEvalFunction( false );
+
+ return walker.checkForward();
+ },
+
+ /**
+ * Moves the range boundaries to the first editing point inside an
+ * element. For example, in an element tree like
+ * "<p><b><i></i></b> Text</p>", the start editing point is
+ * "<p><b><i>^</i></b> Text</p>" (inside <i>).
+ * @param {CKEDITOR.dom.element} targetElement The element into which
+ * look for the editing spot.
+ */
+ moveToElementEditStart : function( targetElement )
+ {
+ var editableElement;
+
+ while ( targetElement && targetElement.type == CKEDITOR.NODE_ELEMENT )
+ {
+ if ( targetElement.isEditable() )
+ editableElement = targetElement;
+ else if ( editableElement )
+ break ; // If we already found an editable element, stop the loop.
+
+ targetElement = targetElement.getFirst();
+ }
+
+ if ( editableElement )
+ this.moveToPosition( editableElement, CKEDITOR.POSITION_AFTER_START );
+ },
+
+ getTouchedStartNode : function()
+ {
+ var container = this.startContainer ;
+
+ if ( this.collapsed || container.type != CKEDITOR.NODE_ELEMENT )
+ return container ;
+
+ return container.getChild( this.startOffset ) || container ;
+ },
+
+ getTouchedEndNode : function()
+ {
+ var container = this.endContainer ;
+
+ if ( this.collapsed || container.type != CKEDITOR.NODE_ELEMENT )
+ return container ;
+
+ return container.getChild( this.endOffset - 1 ) || container ;
+ }
+ };
+})();
+
+CKEDITOR.POSITION_AFTER_START = 1; // ^contents "^text"
+CKEDITOR.POSITION_BEFORE_END = 2; // contents^ "text^"
+CKEDITOR.POSITION_BEFORE_START = 3; // ^contents ^"text"
+CKEDITOR.POSITION_AFTER_END = 4; // contents^ "text"
+
+CKEDITOR.ENLARGE_ELEMENT = 1;
+CKEDITOR.ENLARGE_BLOCK_CONTENTS = 2;
+CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS = 3;
+
+/**
+ * Check boundary types.
+ * @see CKEDITOR.dom.range::checkBoundaryOfElement
+ */
+CKEDITOR.START = 1;
+CKEDITOR.END = 2;
+CKEDITOR.STARTEND = 3;
Index: /CKEditor/branches/versions/3.0.x/_source/core/dom/text.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/dom/text.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/dom/text.js (revision 3751)
@@ -0,0 +1,123 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @fileOverview Defines the {@link CKEDITOR.dom.text} class, which represents
+ * a DOM text node.
+ */
+
+/**
+ * Represents a DOM text node.
+ * @constructor
+ * @augments CKEDITOR.dom.node
+ * @param {Object|String} text A native DOM text node or a string containing
+ * the text to use to create a new text node.
+ * @param {CKEDITOR.dom.document} [ownerDocument] The document that will contain
+ * the node in case of new node creation. Defaults to the current document.
+ * @example
+ * var nativeNode = document.createTextNode( 'Example' );
+ * var text = CKEDITOR.dom.text( nativeNode );
+ * @example
+ * var text = CKEDITOR.dom.text( 'Example' );
+ */
+CKEDITOR.dom.text = function( text, ownerDocument )
+{
+ if ( typeof text == 'string' )
+ text = ( ownerDocument ? ownerDocument.$ : document ).createTextNode( text );
+
+ // Theoretically, we should call the base constructor here
+ // (not CKEDITOR.dom.node though). But, IE doesn't support expando
+ // properties on text node, so the features provided by domObject will not
+ // work for text nodes (which is not a big issue for us).
+ //
+ // CKEDITOR.dom.domObject.call( this, element );
+
+ /**
+ * The native DOM text node represented by this class instance.
+ * @type Object
+ * @example
+ * var element = new CKEDITOR.dom.text( 'Example' );
+ * alert( element.$.nodeType ); // "3"
+ */
+ this.$ = text;
+};
+
+CKEDITOR.dom.text.prototype = new CKEDITOR.dom.node();
+
+CKEDITOR.tools.extend( CKEDITOR.dom.text.prototype,
+ /** @lends CKEDITOR.dom.text.prototype */
+ {
+ /**
+ * The node type. This is a constant value set to
+ * {@link CKEDITOR.NODE_TEXT}.
+ * @type Number
+ * @example
+ */
+ type : CKEDITOR.NODE_TEXT,
+
+ getLength : function()
+ {
+ return this.$.nodeValue.length;
+ },
+
+ getText : function()
+ {
+ return this.$.nodeValue;
+ },
+
+ /**
+ * Breaks this text node into two nodes at the specified offset,
+ * keeping both in the tree as siblings. This node then only contains
+ * all the content up to the offset point. A new text node, which is
+ * inserted as the next sibling of this node, contains all the content
+ * at and after the offset point. When the offset is equal to the
+ * length of this node, the new node has no data.
+ * @param {Number} The position at which to split, starting from zero.
+ * @returns {CKEDITOR.dom.text} The new text node.
+ */
+ split : function( offset )
+ {
+ // If the offset is after the last char, IE creates the text node
+ // on split, but don't include it into the DOM. So, we have to do
+ // that manually here.
+ if ( CKEDITOR.env.ie && offset == this.getLength() )
+ {
+ var next = this.getDocument().createText( '' );
+ next.insertAfter( this );
+ return next;
+ }
+
+ var doc = this.getDocument();
+ var retval = new CKEDITOR.dom.text( this.$.splitText( offset ), doc );
+
+ // IE BUG: IE8 does not update the childNodes array in DOM after splitText(),
+ // we need to make some DOM changes to make it update. (#3436)
+ if ( CKEDITOR.env.ie8 )
+ {
+ var workaround = new CKEDITOR.dom.text( '', doc );
+ workaround.insertAfter( retval );
+ workaround.remove();
+ }
+
+ return retval;
+ },
+
+ /**
+ * Extracts characters from indexA up to but not including indexB.
+ * @param {Number} indexA An integer between 0 and one less than the
+ * length of the text.
+ * @param {Number} [indexB] An integer between 0 and the length of the
+ * string. If omitted, extracts characters to the end of the text.
+ */
+ substring : function( indexA, indexB )
+ {
+ // We need the following check due to a Firefox bug
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=458886
+ if ( typeof indexB != 'number' )
+ return this.$.nodeValue.substr( indexA );
+ else
+ return this.$.nodeValue.substring( indexA, indexB );
+ }
+ });
Index: /CKEditor/branches/versions/3.0.x/_source/core/dom/walker.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/dom/walker.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/dom/walker.js (revision 3751)
@@ -0,0 +1,392 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+(function()
+{
+ // This function is to be called under a "walker" instance scope.
+ function iterate( rtl, breakOnFalse )
+ {
+ // Return null if we have reached the end.
+ if ( this._.end )
+ return null;
+
+ var node,
+ range = this.range,
+ guard,
+ userGuard = this.guard,
+ type = this.type,
+ getSourceNodeFn = ( rtl ? 'getPreviousSourceNode' : 'getNextSourceNode' );
+
+ // This is the first call. Initialize it.
+ if ( !this._.start )
+ {
+ this._.start = 1;
+
+ // Trim text nodes and optmize the range boundaries. DOM changes
+ // may happen at this point.
+ range.trim();
+
+ // A collapsed range must return null at first call.
+ if ( range.collapsed )
+ {
+ this.end();
+ return null;
+ }
+ }
+
+ // Create the LTR guard function, if necessary.
+ if ( !rtl && !this._.guardLTR )
+ {
+ // Gets the node that stops the walker when going LTR.
+ var limitLTR = range.endContainer,
+ blockerLTR = limitLTR.getChild( range.endOffset );
+
+ this._.guardLTR = function( node, movingOut )
+ {
+ return ( ( !movingOut || !limitLTR.equals( node ) )
+ && ( !blockerLTR || !node.equals( blockerLTR ) )
+ && ( node.type != CKEDITOR.NODE_ELEMENT || node.getName() != 'body' ) );
+ };
+ }
+
+ // Create the RTL guard function, if necessary.
+ if ( rtl && !this._.guardRTL )
+ {
+ // Gets the node that stops the walker when going LTR.
+ var limitRTL = range.startContainer,
+ blockerRTL = ( range.startOffset > 0 ) && limitRTL.getChild( range.startOffset - 1 );
+
+ this._.guardRTL = function( node, movingOut )
+ {
+ return ( ( !movingOut || !limitRTL.equals( node ) )
+ && ( !blockerRTL || !node.equals( blockerRTL ) )
+ && ( node.type != CKEDITOR.NODE_ELEMENT || node.getName() != 'body' ) );
+ };
+ }
+
+ // Define which guard function to use.
+ var stopGuard = rtl ? this._.guardRTL : this._.guardLTR;
+
+ // Make the user defined guard function participate in the process,
+ // otherwise simply use the boundary guard.
+ if ( userGuard )
+ {
+ guard = function( node, movingOut )
+ {
+ if ( stopGuard( node, movingOut ) === false )
+ return false;
+
+ return userGuard( node );
+ };
+ }
+ else
+ guard = stopGuard;
+
+ if ( this.current )
+ node = this.current[ getSourceNodeFn ]( false, type, guard );
+ else
+ {
+ // Get the first node to be returned.
+
+ if ( rtl )
+ {
+ node = range.endContainer;
+
+ if ( range.endOffset > 0 )
+ {
+ node = node.getChild( range.endOffset - 1 );
+ if ( guard( node ) === false )
+ node = null;
+ }
+ else
+ node = ( guard ( node ) === false ) ?
+ null : node.getPreviousSourceNode( true, type, guard );
+ }
+ else
+ {
+ node = range.startContainer;
+ node = node.getChild( range.startOffset );
+
+ if ( node )
+ {
+ if ( guard( node ) === false )
+ node = null;
+ }
+ else
+ node = ( guard ( range.startContainer ) === false ) ?
+ null : range.startContainer.getNextSourceNode( true, type, guard ) ;
+ }
+ }
+
+ while ( node && !this._.end )
+ {
+ this.current = node;
+
+ if ( !this.evaluator || this.evaluator( node ) !== false )
+ {
+ if ( !breakOnFalse )
+ return node;
+ }
+ else if ( breakOnFalse && this.evaluator )
+ return false;
+
+ node = node[ getSourceNodeFn ]( false, type, guard );
+ }
+
+ this.end();
+ return this.current = null;
+ }
+
+ function iterateToLast( rtl )
+ {
+ var node, last = null;
+
+ while ( ( node = iterate.call( this, rtl ) ) )
+ last = node;
+
+ return last;
+ }
+
+ CKEDITOR.dom.walker = CKEDITOR.tools.createClass(
+ {
+ /**
+ * Utility class to "walk" the DOM inside a range boundaries. If
+ * necessary, partially included nodes (text nodes) are broken to
+ * reflect the boundaries limits, so DOM and range changes may happen.
+ * Outside changes to the range may break the walker.
+ *
+ * The walker may return nodes that are not totaly included into the
+ * range boundaires. Let's take the following range representation,
+ * where the square brackets indicate the boundaries:
+ *
+ * [<p>Some <b>sample] text</b>
+ *
+ * While walking forward into the above range, the following nodes are
+ * returned: <p>, "Some ", <b> and "sample". Going
+ * backwards instead we have: "sample" and "Some ". So note that the
+ * walker always returns nodes when "entering" them, but not when
+ * "leaving" them. The guard function is instead called both when
+ * entering and leaving nodes.
+ *
+ * @constructor
+ * @param {CKEDITOR.dom.range} range The range within which walk.
+ */
+ $ : function( range )
+ {
+ this.range = range;
+
+ /**
+ * A function executed for every matched node, to check whether
+ * it's to be considered into the walk or not. If not provided, all
+ * matched nodes are considered good.
+ * If the function returns "false" the node is ignored.
+ * @name CKEDITOR.dom.walker.prototype.evaluator
+ * @property
+ * @type Function
+ */
+ // this.evaluator = null;
+
+ /**
+ * A function executed for every node the walk pass by to check
+ * whether the walk is to be finished. It's called when both
+ * entering and exiting nodes, as well as for the matched nodes.
+ * If this function returns "false", the walking ends and no more
+ * nodes are evaluated.
+ * @name CKEDITOR.dom.walker.prototype.guard
+ * @property
+ * @type Function
+ */
+ // this.guard = null;
+
+ /** @private */
+ this._ = {};
+ },
+
+// statics :
+// {
+// /* Creates a CKEDITOR.dom.walker instance to walk inside DOM boundaries set by nodes.
+// * @param {CKEDITOR.dom.node} startNode The node from wich the walk
+// * will start.
+// * @param {CKEDITOR.dom.node} [endNode] The last node to be considered
+// * in the walk. No more nodes are retrieved after touching or
+// * passing it. If not provided, the walker stops at the
+// * <body> closing boundary.
+// * @returns {CKEDITOR.dom.walker} A DOM walker for the nodes between the
+// * provided nodes.
+// */
+// createOnNodes : function( startNode, endNode, startInclusive, endInclusive )
+// {
+// var range = new CKEDITOR.dom.range();
+// if ( startNode )
+// range.setStartAt( startNode, startInclusive ? CKEDITOR.POSITION_BEFORE_START : CKEDITOR.POSITION_AFTER_END ) ;
+// else
+// range.setStartAt( startNode.getDocument().getBody(), CKEDITOR.POSITION_AFTER_START ) ;
+//
+// if ( endNode )
+// range.setEndAt( endNode, endInclusive ? CKEDITOR.POSITION_AFTER_END : CKEDITOR.POSITION_BEFORE_START ) ;
+// else
+// range.setEndAt( startNode.getDocument().getBody(), CKEDITOR.POSITION_BEFORE_END ) ;
+//
+// return new CKEDITOR.dom.walker( range );
+// }
+// },
+//
+ proto :
+ {
+ /**
+ * Stop walking. No more nodes are retrieved if this function gets
+ * called.
+ */
+ end : function()
+ {
+ this._.end = 1;
+ },
+
+ /**
+ * Retrieves the next node (at right).
+ * @returns {CKEDITOR.dom.node} The next node or null if no more
+ * nodes are available.
+ */
+ next : function()
+ {
+ return iterate.call( this );
+ },
+
+ /**
+ * Retrieves the previous node (at left).
+ * @returns {CKEDITOR.dom.node} The previous node or null if no more
+ * nodes are available.
+ */
+ previous : function()
+ {
+ return iterate.call( this, true );
+ },
+
+ /**
+ * Check all nodes at right, executing the evaluation fuction.
+ * @returns {Boolean} "false" if the evaluator function returned
+ * "false" for any of the matched nodes. Otherwise "true".
+ */
+ checkForward : function()
+ {
+ return iterate.call( this, false, true ) !== false;
+ },
+
+ /**
+ * Check all nodes at left, executing the evaluation fuction.
+ * @returns {Boolean} "false" if the evaluator function returned
+ * "false" for any of the matched nodes. Otherwise "true".
+ */
+ checkBackward : function()
+ {
+ return iterate.call( this, true, true ) !== false;
+ },
+
+ /**
+ * Executes a full walk forward (to the right), until no more nodes
+ * are available, returning the last valid node.
+ * @returns {CKEDITOR.dom.node} The last node at the right or null
+ * if no valid nodes are available.
+ */
+ lastForward : function()
+ {
+ return iterateToLast.call( this );
+ },
+
+ /**
+ * Executes a full walk backwards (to the left), until no more nodes
+ * are available, returning the last valid node.
+ * @returns {CKEDITOR.dom.node} The last node at the left or null
+ * if no valid nodes are available.
+ */
+ lastBackward : function()
+ {
+ return iterateToLast.call( this, true );
+ }
+
+ }
+ });
+
+ /*
+ * Anything whose display computed style is block, list-item, table,
+ * table-row-group, table-header-group, table-footer-group, table-row,
+ * table-column-group, table-column, table-cell, table-caption, or whose node
+ * name is hr, br (when enterMode is br only) is a block boundary.
+ */
+ var blockBoundaryDisplayMatch =
+ {
+ block : 1,
+ 'list-item' : 1,
+ table : 1,
+ 'table-row-group' : 1,
+ 'table-header-group' : 1,
+ 'table-footer-group' : 1,
+ 'table-row' : 1,
+ 'table-column-group' : 1,
+ 'table-column' : 1,
+ 'table-cell' : 1,
+ 'table-caption' : 1
+ },
+ blockBoundaryNodeNameMatch = { hr : 1 };
+
+ CKEDITOR.dom.element.prototype.isBlockBoundary = function( customNodeNames )
+ {
+ var nodeNameMatches = CKEDITOR.tools.extend( {},
+ blockBoundaryNodeNameMatch, customNodeNames || {} );
+
+ return blockBoundaryDisplayMatch[ this.getComputedStyle( 'display' ) ] ||
+ nodeNameMatches[ this.getName() ];
+ };
+
+ CKEDITOR.dom.walker.blockBoundary = function( customNodeNames )
+ {
+ return function( node , type )
+ {
+ return ! ( node.type == CKEDITOR.NODE_ELEMENT
+ && node.isBlockBoundary( customNodeNames ) );
+ };
+ };
+
+ CKEDITOR.dom.walker.listItemBoundary = function()
+ {
+ return this.blockBoundary( { br : 1 } );
+ };
+ /**
+ * Whether the node is a bookmark node's inner text node.
+ */
+ CKEDITOR.dom.walker.bookmarkContents = function( node )
+ {
+ },
+
+ /**
+ * Whether the to-be-evaluated node is a bookmark node OR bookmark node
+ * inner contents.
+ * @param {Boolean} contentOnly Whether only test againt the text content of
+ * bookmark node instead of the element itself(default).
+ * @param {Boolean} isReject Whether should return 'false' for the bookmark
+ * node instead of 'true'(default).
+ */
+ CKEDITOR.dom.walker.bookmark = function( contentOnly, isReject )
+ {
+ function isBookmarkNode( node )
+ {
+ return ( node && node.getName
+ && node.getName() == 'span'
+ && node.hasAttribute('_fck_bookmark') );
+ }
+
+ return function( node )
+ {
+ var retval, parent;
+ // Is bookmark inner text node?
+ retval = ( node && !node.getName && ( parent = node.getParent() )
+ && isBookmarkNode( parent ) );
+ // Is bookmark node?
+ retval = contentOnly ? retval : retval || isBookmarkNode( node );
+ return isReject ? !retval : !!retval;
+ };
+ };
+
+})();
Index: /CKEditor/branches/versions/3.0.x/_source/core/dom/window.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/dom/window.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/dom/window.js (revision 3751)
@@ -0,0 +1,93 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @fileOverview Defines the {@link CKEDITOR.dom.document} class, which
+ * represents a DOM document.
+ */
+
+/**
+ * Represents a DOM window.
+ * @constructor
+ * @augments CKEDITOR.dom.domObject
+ * @param {Object} domWindow A native DOM window.
+ * @example
+ * var document = new CKEDITOR.dom.window( window );
+ */
+CKEDITOR.dom.window = function( domWindow )
+{
+ CKEDITOR.dom.domObject.call( this, domWindow );
+};
+
+CKEDITOR.dom.window.prototype = new CKEDITOR.dom.domObject();
+
+CKEDITOR.tools.extend( CKEDITOR.dom.window.prototype,
+ /** @lends CKEDITOR.dom.window.prototype */
+ {
+ /**
+ * Moves the selection focus to this window.
+ * @function
+ * @example
+ * var win = new CKEDITOR.dom.window( window );
+ * win.focus();
+ */
+ focus : function()
+ {
+ this.$.focus();
+ },
+
+ /**
+ * Gets the width and height of this window's viewable area.
+ * @function
+ * @returns {Object} An object with the "width" and "height"
+ * properties containing the size.
+ * @example
+ * var win = new CKEDITOR.dom.window( window );
+ * var size = win.getViewPaneSize();
+ * alert( size.width );
+ * alert( size.height );
+ */
+ getViewPaneSize : function()
+ {
+ var doc = this.$.document,
+ stdMode = doc.compatMode == 'CSS1Compat';
+ return {
+ width : ( stdMode ? doc.documentElement.clientWidth : doc.body.clientWidth ) || 0,
+ height : ( stdMode ? doc.documentElement.clientHeight : doc.body.clientHeight ) || 0
+ };
+ },
+
+ /**
+ * Gets the current position of the window's scroll.
+ * @function
+ * @returns {Object} An object with the "x" and "y" properties
+ * containing the scroll position.
+ * @example
+ * var win = new CKEDITOR.dom.window( window );
+ * var pos = win.getScrollPosition();
+ * alert( pos.x );
+ * alert( pos.y );
+ */
+ getScrollPosition : function()
+ {
+ var $ = this.$;
+
+ if ( 'pageXOffset' in $ )
+ {
+ return {
+ x : $.pageXOffset || 0,
+ y : $.pageYOffset || 0
+ };
+ }
+ else
+ {
+ var doc = $.document;
+ return {
+ x : doc.documentElement.scrollLeft || doc.body.scrollLeft || 0,
+ y : doc.documentElement.scrollTop || doc.body.scrollTop || 0
+ };
+ }
+ }
+ });
Index: /CKEditor/branches/versions/3.0.x/_source/core/dtd.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/dtd.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/dtd.js (revision 3751)
@@ -0,0 +1,200 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @fileOverview Defines the {@link CKEDITOR.dtd} object, which holds the DTD
+ * mapping for XHTML 1.0 Transitional. This file was automatically
+ * generated from the file: xhtml1-transitional.dtd.
+ */
+
+/**
+ * Holds and object representation of the HTML DTD to be used by the editor in
+ * its internal operations.
+ *
+ * Each element in the DTD is represented by a
+ * property in this object. Each property contains the list of elements that
+ * can be contained by the element. Text is represented by the "#" property.
+ *
+ * Several special grouping properties are also available. Their names start
+ * with the "$" character.
+ * @namespace
+ * @example
+ * // Check if "div" can be contained in a "p" element.
+ * alert( !!CKEDITOR.dtd[ 'p' ][ 'div' ] ); "false"
+ * @example
+ * // Check if "p" can be contained in a "div" element.
+ * alert( !!CKEDITOR.dtd[ 'div' ][ 'p' ] ); "true"
+ * @example
+ * // Check if "p" is a block element.
+ * alert( !!CKEDITOR.dtd.$block[ 'p' ] ); "true"
+ */
+CKEDITOR.dtd = (function()
+{
+ var X = CKEDITOR.tools.extend,
+
+ A = {isindex:1,fieldset:1},
+ B = {input:1,button:1,select:1,textarea:1,label:1},
+ C = X({a:1},B),
+ D = X({iframe:1},C),
+ E = {hr:1,ul:1,menu:1,div:1,blockquote:1,noscript:1,table:1,center:1,address:1,dir:1,pre:1,h5:1,dl:1,h4:1,noframes:1,h6:1,ol:1,h1:1,h3:1,h2:1},
+ F = {ins:1,del:1,script:1},
+ G = X({b:1,acronym:1,bdo:1,'var':1,'#':1,abbr:1,code:1,br:1,i:1,cite:1,kbd:1,u:1,strike:1,s:1,tt:1,strong:1,q:1,samp:1,em:1,dfn:1,span:1},F),
+ H = X({sub:1,img:1,object:1,sup:1,basefont:1,map:1,applet:1,font:1,big:1,small:1},G),
+ I = X({p:1},H),
+ J = X({iframe:1},H,B),
+ K = {img:1,noscript:1,br:1,kbd:1,center:1,button:1,basefont:1,h5:1,h4:1,samp:1,h6:1,ol:1,h1:1,h3:1,h2:1,form:1,font:1,'#':1,select:1,menu:1,ins:1,abbr:1,label:1,code:1,table:1,script:1,cite:1,input:1,iframe:1,strong:1,textarea:1,noframes:1,big:1,small:1,span:1,hr:1,sub:1,bdo:1,'var':1,div:1,object:1,sup:1,strike:1,dir:1,map:1,dl:1,applet:1,del:1,isindex:1,fieldset:1,ul:1,b:1,acronym:1,a:1,blockquote:1,i:1,u:1,s:1,tt:1,address:1,q:1,pre:1,p:1,em:1,dfn:1},
+
+ L = X({a:1},J),
+ M = {tr:1},
+ N = {'#':1},
+ O = X({param:1},K),
+ P = X({form:1},A,D,E,I),
+ Q = {li:1};
+
+ var block = {address:1,blockquote:1,center:1,dir:1,div:1,dl:1,fieldset:1,form:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,hr:1,isindex:1,menu:1,noframes:1,ol:1,p:1,pre:1,table:1,ul:1};
+
+ return /** @lends CKEDITOR.dtd */ {
+
+ // The "$" items have been added manually.
+
+ /**
+ * List of block elements, like "p" or "div".
+ * @type Object
+ * @example
+ */
+ $block : block,
+
+ $body : X({script:1}, block),
+
+ $cdata : {script:1,style:1},
+
+ /**
+ * List of empty (self-closing) elements, like "br" or "img".
+ * @type Object
+ * @example
+ */
+ $empty : {area:1,base:1,br:1,col:1,hr:1,img:1,input:1,link:1,meta:1,param:1},
+
+ /**
+ * List of list item elements, like "li" or "dd".
+ * @type Object
+ * @example
+ */
+ $listItem : {dd:1,dt:1,li:1},
+
+ /**
+ * Elements that accept text nodes, but are not possible to edit into
+ * the browser.
+ * @type Object
+ * @example
+ */
+ $nonEditable : {applet:1,button:1,embed:1,iframe:1,map:1,object:1,option:1,script:1,textarea:1},
+
+ /**
+ * List of elements that can be ignored if empty, like "b" or "span".
+ * @type Object
+ * @example
+ */
+ $removeEmpty : {abbr:1,acronym:1,address:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,s:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,'var':1},
+
+ /**
+ * List of elements that have tabindex set to zero by default.
+ * @type Object
+ * @example
+ */
+ $tabIndex : {a:1,area:1,button:1,input:1,object:1,select:1,textarea:1},
+
+ /**
+ * List of elements used inside the "table" element, like "tbody" or "td".
+ * @type Object
+ * @example
+ */
+ $tableContent : {caption:1,col:1,colgroup:1,tbody:1,td:1,tfoot:1,th:1,thead:1,tr:1},
+
+ col : {},
+ tr : {td:1,th:1},
+ img : {},
+ colgroup : {col:1},
+ noscript : P,
+ td : P,
+ br : {},
+ th : P,
+ center : P,
+ kbd : L,
+ button : X(I,E),
+ basefont : {},
+ h5 : L,
+ h4 : L,
+ samp : L,
+ h6 : L,
+ ol : Q,
+ h1 : L,
+ h3 : L,
+ option : N,
+ h2 : L,
+ form : X(A,D,E,I),
+ select : {optgroup:1,option:1},
+ font : L,
+ ins : P,
+ menu : Q,
+ abbr : L,
+ label : L,
+ table : {thead:1,col:1,tbody:1,tr:1,colgroup:1,caption:1,tfoot:1},
+ code : L,
+ script : N,
+ tfoot : M,
+ cite : L,
+ li : P,
+ input : {},
+ iframe : P,
+ strong : L,
+ textarea : N,
+ noframes : P,
+ big : L,
+ small : L,
+ span : L,
+ hr : {},
+ dt : L,
+ sub : L,
+ optgroup : {option:1},
+ param : {},
+ bdo : L,
+ 'var' : L,
+ div : P,
+ object : O,
+ sup : L,
+ dd : P,
+ strike : L,
+ area : {},
+ dir : Q,
+ map : X({area:1,form:1,p:1},A,F,E),
+ applet : O,
+ dl : {dt:1,dd:1},
+ del : P,
+ isindex : {},
+ fieldset : X({legend:1},K),
+ thead : M,
+ ul : Q,
+ acronym : L,
+ b : L,
+ a : J,
+ blockquote : P,
+ caption : L,
+ i : L,
+ u : L,
+ tbody : M,
+ s : L,
+ address : X(D,I),
+ tt : L,
+ legend : L,
+ q : L,
+ pre : X(G,C),
+ p : L,
+ em : L,
+ dfn : L
+ };
+})();
+
+// PACKAGER_RENAME( CKEDITOR.dtd )
Index: /CKEditor/branches/versions/3.0.x/_source/core/editor.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/editor.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/editor.js (revision 3751)
@@ -0,0 +1,640 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @fileOverview Defines the {@link CKEDITOR.editor} class, which represents an
+ * editor instance.
+ */
+
+(function()
+{
+ // The counter for automatic instance names.
+ var nameCounter = 0;
+
+ var getNewName = function()
+ {
+ var name = 'editor' + ( ++nameCounter );
+ return ( CKEDITOR.instances && CKEDITOR.instances[ name ] ) ? getNewName() : name;
+ };
+
+ // ##### START: Config Privates
+
+ // These function loads custom configuration files and cache the
+ // CKEDITOR.editorConfig functions defined on them, so there is no need to
+ // download them more than once for several instances.
+ var loadConfigLoaded = {};
+ var loadConfig = function( editor )
+ {
+ var customConfig = editor.config.customConfig;
+
+ // Check if there is a custom config to load.
+ if ( !customConfig )
+ return false;
+
+ var loadedConfig = loadConfigLoaded[ customConfig ] || ( loadConfigLoaded[ customConfig ] = {} );
+
+ // If the custom config has already been downloaded, reuse it.
+ if ( loadedConfig.fn )
+ {
+ // Call the cached CKEDITOR.editorConfig defined in the custom
+ // config file for the editor instance depending on it.
+ loadedConfig.fn.call( editor, editor.config );
+
+ // If there is no other customConfig in the chain, fire the
+ // "configLoaded" event.
+ if ( editor.config.customConfig == customConfig || !loadConfig( editor ) )
+ editor.fireOnce( 'customConfigLoaded' );
+ }
+ else
+ {
+ // Load the custom configuration file.
+ CKEDITOR.scriptLoader.load( customConfig, function()
+ {
+ // If the CKEDITOR.editorConfig function has been properly
+ // defined in the custom configuration file, cache it.
+ if ( CKEDITOR.editorConfig )
+ loadedConfig.fn = CKEDITOR.editorConfig;
+ else
+ loadedConfig.fn = function(){};
+
+ // Call the load config again. This time the custom
+ // config is already cached and so it will get loaded.
+ loadConfig( editor );
+ });
+ }
+
+ return true;
+ };
+
+ var initConfig = function( editor, instanceConfig )
+ {
+ // Setup the lister for the "customConfigLoaded" event.
+ editor.on( 'customConfigLoaded', function()
+ {
+ if ( instanceConfig )
+ {
+ // Register the events that may have been set at the instance
+ // configuration object.
+ if ( instanceConfig.on )
+ {
+ for ( var eventName in instanceConfig.on )
+ {
+ editor.on( eventName, instanceConfig.on[ eventName ] );
+ }
+ }
+
+ // Overwrite the settings from the in-page config.
+ CKEDITOR.tools.extend( editor.config, instanceConfig, true );
+
+ delete editor.config.on;
+ }
+
+ onConfigLoaded( editor );
+ });
+
+ // The instance config may override the customConfig setting to avoid
+ // loading the default ~/config.js file.
+ if ( instanceConfig && instanceConfig.customConfig != undefined )
+ editor.config.customConfig = instanceConfig.customConfig;
+
+ // Load configs from the custom configuration files.
+ if ( !loadConfig( editor ) )
+ editor.fireOnce( 'customConfigLoaded' );
+ };
+
+ // ##### END: Config Privates
+
+ var onConfigLoaded = function( editor )
+ {
+ // Set config related properties.
+
+ var skin = editor.config.skin.split( ',' ),
+ skinName = skin[ 0 ],
+ skinPath = CKEDITOR.getUrl( skin[ 1 ] || (
+ '_source/' + // %REMOVE_LINE%
+ 'skins/' + skinName + '/' ) );
+
+ editor.skinName = skinName;
+ editor.skinPath = skinPath;
+ editor.skinClass = 'cke_skin_' + skinName;
+
+ // Fire the "configLoaded" event.
+ editor.fireOnce( 'configLoaded' );
+
+ // Load language file.
+ loadLang( editor );
+ };
+
+ var loadLang = function( editor )
+ {
+ CKEDITOR.lang.load( editor.config.language, editor.config.defaultLanguage, function( languageCode, lang )
+ {
+ editor.langCode = languageCode;
+
+ // As we'll be adding plugin specific entries that could come
+ // from different language code files, we need a copy of lang,
+ // not a direct reference to it.
+ editor.lang = CKEDITOR.tools.prototypedCopy( lang );
+
+ // We're not able to support RTL in Firefox 2 at this time.
+ if ( CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 && editor.lang.dir == 'rtl' )
+ editor.lang.dir = 'ltr';
+
+ loadPlugins( editor );
+ });
+ };
+
+ var loadPlugins = function( editor )
+ {
+ var config = editor.config,
+ plugins = config.plugins,
+ extraPlugins = config.extraPlugins,
+ removePlugins = config.removePlugins;
+
+ if ( extraPlugins )
+ {
+ // Remove them first to avoid duplications.
+ var removeRegex = new RegExp( '(?:^|,)(?:' + extraPlugins.replace( /\s*,\s*/g, '|' ) + ')(?=,|$)' , 'g' );
+ plugins = plugins.replace( removeRegex, '' );
+
+ plugins += ',' + extraPlugins;
+ }
+
+ if ( removePlugins )
+ {
+ removeRegex = new RegExp( '(?:^|,)(?:' + removePlugins.replace( /\s*,\s*/g, '|' ) + ')(?=,|$)' , 'g' );
+ plugins = plugins.replace( removeRegex, '' );
+ }
+
+ // Load all plugins defined in the "plugins" setting.
+ CKEDITOR.plugins.load( plugins.split( ',' ), function( plugins )
+ {
+ // The list of plugins.
+ var pluginsArray = [];
+
+ // The language code to get loaded for each plugin. Null
+ // entries will be appended for plugins with no language files.
+ var languageCodes = [];
+
+ // The list of URLs to language files.
+ var languageFiles = [];
+
+ // Cache the loaded plugin names.
+ editor.plugins = plugins;
+
+ // Loop through all plugins, to build the list of language
+ // files to get loaded.
+ for ( var pluginName in plugins )
+ {
+ var plugin = plugins[ pluginName ],
+ pluginLangs = plugin.lang,
+ pluginPath = CKEDITOR.plugins.getPath( pluginName ),
+ lang = null;
+
+ // Set the plugin path in the plugin.
+ plugin.path = pluginPath;
+
+ // If the plugin has "lang".
+ if ( pluginLangs )
+ {
+ // Resolve the plugin language. If the current language
+ // is not available, get the first one (default one).
+ lang = ( CKEDITOR.tools.indexOf( pluginLangs, editor.langCode ) >= 0 ? editor.langCode : pluginLangs[ 0 ] );
+
+ if ( !plugin.lang[ lang ] )
+ {
+ // Put the language file URL into the list of files to
+ // get downloaded.
+ languageFiles.push( CKEDITOR.getUrl( pluginPath + 'lang/' + lang + '.js' ) );
+ }
+ else
+ {
+ CKEDITOR.tools.extend( editor.lang, plugin.lang[ lang ] );
+ lang = null;
+ }
+ }
+
+ // Save the language code, so we know later which
+ // language has been resolved to this plugin.
+ languageCodes.push( lang );
+
+ pluginsArray.push( plugin );
+ }
+
+ // Load all plugin specific language files in a row.
+ CKEDITOR.scriptLoader.load( languageFiles, function()
+ {
+ // Initialize all plugins that have the "beforeInit" and "init" methods defined.
+ var methods = [ 'beforeInit', 'init', 'afterInit' ];
+ for ( var m = 0 ; m < methods.length ; m++ )
+ {
+ for ( var i = 0 ; i < pluginsArray.length ; i++ )
+ {
+ var plugin = pluginsArray[ i ];
+
+ // Uses the first loop to update the language entries also.
+ if ( m === 0 && languageCodes[ i ] && plugin.lang )
+ CKEDITOR.tools.extend( editor.lang, plugin.lang[ languageCodes[ i ] ] );
+
+ // Call the plugin method (beforeInit and init).
+ if ( plugin[ methods[ m ] ] )
+ plugin[ methods[ m ] ]( editor );
+ }
+ }
+
+ // Load the editor skin.
+ editor.fire( 'pluginsLoaded' );
+ loadSkin( editor );
+ });
+ });
+ };
+
+ var loadSkin = function( editor )
+ {
+ CKEDITOR.skins.load( editor, 'editor', function()
+ {
+ loadTheme( editor );
+ });
+ };
+
+ var loadTheme = function( editor )
+ {
+ var theme = editor.config.theme;
+ CKEDITOR.themes.load( theme, function()
+ {
+ var editorTheme = editor.theme = CKEDITOR.themes.get( theme );
+ editorTheme.path = CKEDITOR.themes.getPath( theme );
+ editorTheme.build( editor );
+
+ if ( editor.config.autoUpdateElement )
+ attachToForm( editor );
+ });
+ };
+
+ var attachToForm = function( editor )
+ {
+ var element = editor.element;
+
+ // If are replacing a textarea, we must
+ if ( editor.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE && element.is( 'textarea' ) )
+ {
+ var form = element.$.form && new CKEDITOR.dom.element( element.$.form );
+ if ( form )
+ {
+ form.on( 'submit', function()
+ {
+ editor.updateElement();
+ });
+
+ // Setup the submit function because it doesn't fire the
+ // "submit" event.
+ if ( !form.$.submit.nodeName )
+ {
+ form.$.submit = CKEDITOR.tools.override( form.$.submit, function( originalSubmit )
+ {
+ return function()
+ {
+ editor.updateElement();
+
+ // For IE, the DOM submit function is not a
+ // function, so we need thid check.
+ if ( originalSubmit.apply )
+ originalSubmit.apply( this, arguments );
+ else
+ originalSubmit();
+ };
+ });
+ }
+ }
+ }
+ };
+
+ function updateCommandsMode()
+ {
+ var command,
+ commands = this._.commands,
+ mode = this.mode;
+
+ for ( var name in commands )
+ {
+ command = commands[ name ];
+ command[ command.modes[ mode ] ? 'enable' : 'disable' ]();
+ }
+ }
+
+ /**
+ * Initializes the editor instance. This function is called by the editor
+ * contructor (editor_basic.js).
+ * @private
+ */
+ CKEDITOR.editor.prototype._init = function()
+ {
+ // Get the properties that have been saved in the editor_base
+ // implementation.
+ var element = CKEDITOR.dom.element.get( this._.element ),
+ instanceConfig = this._.instanceConfig;
+ delete this._.element;
+ delete this._.instanceConfig;
+
+ this._.commands = {};
+ this._.styles = [];
+
+ /**
+ * The DOM element that has been replaced by this editor instance. This
+ * element holds the editor data on load and post.
+ * @name CKEDITOR.editor.prototype.element
+ * @type CKEDITOR.dom.element
+ * @example
+ * var editor = CKEDITOR.instances.editor1;
+ * alert( editor.element.getName() ); "textarea"
+ */
+ this.element = element;
+
+ /**
+ * The editor instance name. It hay be the replaced element id, name or
+ * a default name using a progressive counter (editor1, editor2, ...).
+ * @name CKEDITOR.editor.prototype.name
+ * @type String
+ * @example
+ * var editor = CKEDITOR.instances.editor1;
+ * alert( editor.name ); "editor1"
+ */
+ this.name = ( element && ( this.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE )
+ && ( element.getId() || element.getNameAtt() ) )
+ || getNewName();
+
+ /**
+ * The configurations for this editor instance. It inherits all
+ * settings defined in (@link CKEDITOR.config}, combined with settings
+ * loaded from custom configuration files and those defined inline in
+ * the page when creating the editor.
+ * @name CKEDITOR.editor.prototype.config
+ * @type Object
+ * @example
+ * var editor = CKEDITOR.instances.editor1;
+ * alert( editor.config.theme ); "default" e.g.
+ */
+ this.config = CKEDITOR.tools.prototypedCopy( CKEDITOR.config );
+
+ /**
+ * Namespace containing UI features related to this editor instance.
+ * @name CKEDITOR.editor.prototype.ui
+ * @type CKEDITOR.ui
+ * @example
+ */
+ this.ui = new CKEDITOR.ui( this );
+
+ /**
+ * Controls the focus state of this editor instance. This property
+ * is rarely used for normal API operations. It is mainly
+ * destinated to developer adding UI elements to the editor interface.
+ * @name CKEDITOR.editor.prototype.focusManager
+ * @type CKEDITOR.focusManager
+ * @example
+ */
+ this.focusManager = new CKEDITOR.focusManager( this );
+
+ CKEDITOR.fire( 'instanceCreated', null, this );
+
+ this.on( 'mode', updateCommandsMode, null, null, 1 );
+
+ initConfig( this, instanceConfig );
+ };
+})();
+
+CKEDITOR.tools.extend( CKEDITOR.editor.prototype,
+ /** @lends CKEDITOR.editor.prototype */
+ {
+ /**
+ * Adds a command definition to the editor instance. Commands added with
+ * this function can be later executed with {@link #execCommand}.
+ * @param {String} commandName The indentifier name of the command.
+ * @param {CKEDITOR.commandDefinition} commandDefinition The command definition.
+ * @example
+ * editorInstance.addCommand( 'sample',
+ * {
+ * exec : function( editor )
+ * {
+ * alert( 'Executing a command for the editor name "' + editor.name + '"!' );
+ * }
+ * });
+ */
+ addCommand : function( commandName, commandDefinition )
+ {
+ return this._.commands[ commandName ] = new CKEDITOR.command( this, commandDefinition );
+ },
+
+ addCss : function( css )
+ {
+ this._.styles.push( css );
+ },
+
+ /**
+ * Destroys the editor instance, releasing all resources used by it.
+ * If the editor replaced an element, the element will be recovered.
+ * @param {Boolean} [noUpdate] If the instance is replacing a DOM
+ * element, this parameter indicates whether or not to update the
+ * element with the instance contents.
+ * @example
+ * alert( CKEDITOR.instances.editor1 ); e.g "object"
+ * CKEDITOR.instances.editor1.destroy();
+ * alert( CKEDITOR.instances.editor1 ); "undefined"
+ */
+ destroy : function( noUpdate )
+ {
+ if ( !noUpdate )
+ this.updateElement();
+
+ this.theme.destroy( this );
+ CKEDITOR.remove( this );
+ },
+
+ /**
+ * Executes a command.
+ * @param {String} commandName The indentifier name of the command.
+ * @param {Object} [data] Data to be passed to the command
+ * @returns {Boolean} "true" if the command has been successfuly
+ * executed, otherwise "false".
+ * @example
+ * editorInstance.execCommand( 'Bold' );
+ */
+ execCommand : function( commandName, data )
+ {
+ var command = this.getCommand( commandName );
+
+ var eventData =
+ {
+ name: commandName,
+ commandData: data,
+ command: command
+ };
+
+ if ( command && command.state != CKEDITOR.TRISTATE_DISABLED )
+ {
+ if ( this.fire( 'beforeCommandExec', eventData ) !== true )
+ {
+ eventData.returnValue = command.exec( eventData.commandData );
+
+ // Fire the 'afterCommandExec' immediately if command is synchronous.
+ if ( !command.async && this.fire( 'afterCommandExec', eventData ) !== true )
+ return eventData.returnValue;
+ }
+ }
+
+ // throw 'Unknown command name "' + commandName + '"';
+ return false;
+ },
+
+ /**
+ * Gets one of the registered commands. Note that, after registering a
+ * command definition with addCommand, it is transformed internally
+ * into an instance of {@link CKEDITOR.command}, which will be then
+ * returned by this function.
+ * @param {String} commandName The name of the command to be returned.
+ * This is the same used to register the command with addCommand.
+ * @returns {CKEDITOR.command} The command object identified by the
+ * provided name.
+ */
+ getCommand : function( commandName )
+ {
+ return this._.commands[ commandName ];
+ },
+
+ /**
+ * Gets the editor data. The data will be in raw format. It is the same
+ * data that is posted by the editor.
+ * @type String
+ * @returns (String) The editor data.
+ * @example
+ * if ( CKEDITOR.instances.editor1.getData() == '' )
+ * alert( 'There is no data available' );
+ */
+ getData : function()
+ {
+ this.fire( 'beforeGetData' );
+
+ var eventData = this._.data;
+
+ if ( typeof eventData != 'string' )
+ {
+ var element = this.element;
+ if ( element && this.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE )
+ eventData = element.is( 'textarea' ) ? element.getValue() : element.getHtml();
+ else
+ eventData = '';
+ }
+
+ eventData = { dataValue : eventData };
+
+ // Fire "getData" so data manipulation may happen.
+ this.fire( 'getData', eventData );
+
+ return eventData.dataValue;
+ },
+
+ getSnapshot : function()
+ {
+ var data = this.fire( 'getSnapshot' );
+
+ if ( typeof data != 'string' )
+ {
+ var element = this.element;
+ if ( element && this.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE )
+ data = element.is( 'textarea' ) ? element.getValue() : element.getHtml();
+ }
+
+ return data;
+ },
+
+ loadSnapshot : function( snapshot )
+ {
+ this.fire( 'loadSnapshot', snapshot );
+ },
+
+ /**
+ * Sets the editor data. The data must be provided in raw format.
+ * @param {String} data HTML code to replace the curent content in the editor.
+ * @example
+ * CKEDITOR.instances.editor1.setData( '<p>This is the editor data.</p>' );
+ */
+ setData : function( data )
+ {
+ // Fire "setData" so data manipulation may happen.
+ var eventData = { dataValue : data };
+ this.fire( 'setData', eventData );
+
+ this._.data = eventData.dataValue;
+
+ this.fire( 'afterSetData', eventData );
+ },
+
+ /**
+ * Inserts HTML into the currently selected position in the editor.
+ * @param {String} data HTML code to be inserted into the editor.
+ * @example
+ * CKEDITOR.instances.editor1.insertHtml( '<p>This is a new paragraph.</p>' );
+ */
+ insertHtml : function( data )
+ {
+ this.fire( 'insertHtml', data );
+ },
+
+ /**
+ * Inserts an element into the currently selected position in the
+ * editor.
+ * @param {CKEDITOR.dom.element} element The element to be inserted
+ * into the editor.
+ * @example
+ * var element = CKEDITOR.dom.element.createFromHtml( '<img src="hello.png" border="0" title="Hello" />' );
+ * CKEDITOR.instances.editor1.insertElement( element );
+ */
+ insertElement : function( element )
+ {
+ this.fire( 'insertElement', element );
+ },
+
+ checkDirty : function()
+ {
+ return ( this.mayBeDirty && this._.previousValue !== this.getSnapshot() );
+ },
+
+ resetDirty : function()
+ {
+ if ( this.mayBeDirty )
+ this._.previousValue = this.getSnapshot();
+ },
+
+ /**
+ * Updates the <textarea> element that has been replaced by the editor with
+ * the current data available in the editor.
+ * @example
+ * CKEDITOR.instances.editor1.updateElement();
+ * alert( document.getElementById( 'editor1' ).value ); // The current editor data.
+ */
+ updateElement : function()
+ {
+ var element = this.element;
+ if ( element && this.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE )
+ {
+ if ( element.is( 'textarea' ) )
+ element.setValue( this.getData() );
+ else
+ element.setHtml( this.getData() );
+ }
+ }
+ });
+
+CKEDITOR.on( 'loaded', function()
+ {
+ // Run the full initialization for pending editors.
+ var pending = CKEDITOR.editor._pending;
+ if ( pending )
+ {
+ delete CKEDITOR.editor._pending;
+
+ for ( var i = 0 ; i < pending.length ; i++ )
+ pending[ i ]._init();
+ }
+ });
Index: /CKEditor/branches/versions/3.0.x/_source/core/editor_basic.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/editor_basic.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/editor_basic.js (revision 3751)
@@ -0,0 +1,178 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+if ( !CKEDITOR.editor )
+{
+ /**
+ * No element is linked to the editor instance.
+ * @constant
+ * @example
+ */
+ CKEDITOR.ELEMENT_MODE_NONE = 0;
+
+ /**
+ * The element is to be replaced by the editor instance.
+ * @constant
+ * @example
+ */
+ CKEDITOR.ELEMENT_MODE_REPLACE = 1;
+
+ /**
+ * The editor is to be created inside the element.
+ * @constant
+ * @example
+ */
+ CKEDITOR.ELEMENT_MODE_APPENDTO = 2;
+
+ /**
+ * Represents an editor instance. This constructor should be rarely used,
+ * being the {@link CKEDITOR} methods preferible.
+ * @constructor
+ * @param {Object} instanceConfig Configuration values for this specific
+ * instance.
+ * @param {CKEDITOR.dom.element} [element] The element linked to this
+ * instance.
+ * @param {Number} [mode] The mode in which the element is linked to this
+ * instance.
+ * @augments CKEDITOR.event
+ * @example
+ */
+ CKEDITOR.editor = function( instanceConfig, element, mode )
+ {
+ this._ =
+ {
+ // Save the config to be processed later by the full core code.
+ instanceConfig : instanceConfig,
+ element : element
+ };
+
+ /**
+ * The mode in which the {@link #element} is linked to this editor
+ * instance. It can be any of the following values:
+ *
+ *
CKEDITOR.ELEMENT_MODE_NONE: No element is linked to the
+ * editor instance.
+ *
CKEDITOR.ELEMENT_MODE_REPLACE: The element is to be
+ * replaced by the editor instance.
+ *
CKEDITOR.ELEMENT_MODE_APPENDTO: The editor is to be
+ * created inside the element.
+ *
+ * @name CKEDITOR.editor.prototype.elementMode
+ * @type Number
+ * @example
+ * var editor = CKEDITOR.replace( 'editor1' );
+ * alert( editor.elementMode ); "1"
+ */
+ this.elementMode = mode || CKEDITOR.ELEMENT_MODE_NONE;
+
+ // Call the CKEDITOR.event constructor to initialize this instance.
+ CKEDITOR.event.call( this );
+
+ this._init();
+ };
+
+ /**
+ * Replaces a <textarea> or a DOM element (DIV) with a CKEditor
+ * instance. For textareas, the initial value in the editor will be the
+ * textarea value. For DOM elements, their innerHTML will be used
+ * instead. We recommend using TEXTAREA and DIV elements only. Do not use
+ * this function directly. Use {@link CKEDITOR.replace} instead.
+ * @param {Object|String} elementOrIdOrName The DOM element (textarea), its
+ * ID or name.
+ * @param {Object} [config] The specific configurations to apply to this
+ * editor instance. Configurations set here will override global CKEditor
+ * settings.
+ * @returns {CKEDITOR.editor} The editor instance created.
+ * @example
+ */
+ CKEDITOR.editor.replace = function( elementOrIdOrName, config )
+ {
+ var element = elementOrIdOrName;
+
+ if ( typeof element != 'object' )
+ {
+ // Look for the element by id. We accept any kind of element here.
+ element = document.getElementById( elementOrIdOrName );
+
+ // If not found, look for elements by name. In this case we accept only
+ // textareas.
+ if ( !element )
+ {
+ var i = 0,
+ textareasByName = document.getElementsByName( elementOrIdOrName );
+
+ while ( ( element = textareasByName[ i++ ] ) && element.tagName.toLowerCase() != 'textarea' )
+ { /*jsl:pass*/ }
+ }
+
+ if ( !element )
+ throw '[CKEDITOR.editor.replace] The element with id or name "' + elementOrIdOrName + '" was not found.';
+ }
+
+ // Do not replace the textarea right now, just hide it. The effective
+ // replacement will be done by the _init function.
+ element.style.visibility = 'hidden';
+
+ // Create the editor instance.
+ return new CKEDITOR.editor( config, element, CKEDITOR.ELEMENT_MODE_REPLACE );
+ };
+
+ /**
+ * Creates a new editor instance inside a specific DOM element. Do not use
+ * this function directly. Use {@link CKEDITOR.appendTo} instead.
+ * @param {Object|String} elementOrId The DOM element or its ID.
+ * @param {Object} [config] The specific configurations to apply to this
+ * editor instance. Configurations set here will override global CKEditor
+ * settings.
+ * @returns {CKEDITOR.editor} The editor instance created.
+ * @example
+ */
+ CKEDITOR.editor.appendTo = function( elementOrId, config )
+ {
+ if ( typeof elementOrId != 'object' )
+ {
+ elementOrId = document.getElementById( elementOrId );
+
+ if ( !elementOrId )
+ throw '[CKEDITOR.editor.appendTo] The element with id "' + elementOrId + '" was not found.';
+ }
+
+ // Create the editor instance.
+ return new CKEDITOR.editor( config, elementOrId, CKEDITOR.ELEMENT_MODE_APPENDTO );
+ };
+
+ CKEDITOR.editor.prototype =
+ {
+ /**
+ * Initializes the editor instance. This function will be overriden by the
+ * full CKEDITOR.editor implementation (editor.js).
+ * @private
+ */
+ _init : function()
+ {
+ var pending = CKEDITOR.editor._pending || ( CKEDITOR.editor._pending = [] );
+ pending.push( this );
+ },
+
+ // Both fire and fireOnce will always pass this editor instance as the
+ // "editor" param in CKEDITOR.event.fire. So, we override it to do that
+ // automaticaly.
+
+ /** @ignore */
+ fire : function( eventName, data )
+ {
+ return CKEDITOR.event.prototype.fire.call( this, eventName, data, this );
+ },
+
+ /** @ignore */
+ fireOnce : function( eventName, data )
+ {
+ return CKEDITOR.event.prototype.fireOnce.call( this, eventName, data, this );
+ }
+ };
+
+ // "Inherit" (copy actually) from CKEDITOR.event.
+ CKEDITOR.event.implementOn( CKEDITOR.editor.prototype, true );
+}
Index: /CKEditor/branches/versions/3.0.x/_source/core/env.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/env.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/env.js (revision 3751)
@@ -0,0 +1,219 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @fileOverview Defines the {@link CKEDITOR.env} object, which constains
+ * environment and browser information.
+ */
+
+if ( !CKEDITOR.env )
+{
+ /**
+ * Environment and browser information.
+ * @namespace
+ * @example
+ */
+ CKEDITOR.env = (function()
+ {
+ var agent = navigator.userAgent.toLowerCase();
+ var opera = window.opera;
+
+ var env =
+ /** @lends CKEDITOR.env */
+ {
+ /**
+ * Indicates that CKEditor is running on Internet Explorer.
+ * @type Boolean
+ * @example
+ * if ( CKEDITOR.env.ie )
+ * alert( "I'm on IE!" );
+ */
+ ie : /*@cc_on!@*/false,
+
+ /**
+ * Indicates that CKEditor is running on Opera.
+ * @type Boolean
+ * @example
+ * if ( CKEDITOR.env.opera )
+ * alert( "I'm on Opera!" );
+ */
+ opera : ( !!opera && opera.version ),
+
+ /**
+ * Indicates that CKEditor is running on a WebKit based browser, like
+ * Safari.
+ * @type Boolean
+ * @example
+ * if ( CKEDITOR.env.webkit )
+ * alert( "I'm on WebKit!" );
+ */
+ webkit : ( agent.indexOf( ' applewebkit/' ) > -1 ),
+
+ /**
+ * Indicates that CKEditor is running on Adobe AIR.
+ * @type Boolean
+ * @example
+ * if ( CKEDITOR.env.air )
+ * alert( "I'm on AIR!" );
+ */
+ air : ( agent.indexOf( ' adobeair/' ) > -1 ),
+
+ /**
+ * Indicates that CKEditor is running on Macintosh.
+ * @type Boolean
+ * @example
+ * if ( CKEDITOR.env.mac )
+ * alert( "I love apples!" );
+ */
+ mac : ( agent.indexOf( 'macintosh' ) > -1 ),
+
+ quirks : ( document.compatMode == 'BackCompat' ),
+
+ isCustomDomain : function()
+ {
+ return this.ie && document.domain != window.location.hostname;
+ }
+ };
+
+ /**
+ * Indicates that CKEditor is running on a Gecko based browser, like
+ * Firefox.
+ * @name CKEDITOR.env.gecko
+ * @type Boolean
+ * @example
+ * if ( CKEDITOR.env.gecko )
+ * alert( "I'm riding a gecko!" );
+ */
+ env.gecko = ( navigator.product == 'Gecko' && !env.webkit && !env.opera );
+
+ var version = 0;
+
+ // Internet Explorer 6.0+
+ if ( env.ie )
+ {
+ version = parseFloat( agent.match( /msie (\d+)/ )[1] );
+
+ /**
+ * Indicate IE8 browser.
+ */
+ env.ie8 = !!document.documentMode;
+
+ /**
+ * Indicte IE8 document mode.
+ */
+ env.ie8Compat = document.documentMode == 8;
+
+ /**
+ * Indicates that CKEditor is running on an IE7-like environment, which
+ * includes IE7 itself and IE8's IE7 document mode.
+ * @type Boolean
+ */
+ env.ie7Compat = ( ( version == 7 && !document.documentMode )
+ || document.documentMode == 7 );
+
+ /**
+ * Indicates that CKEditor is running on an IE6-like environment, which
+ * includes IE6 itself and IE7 and IE8 quirks mode.
+ * @type Boolean
+ * @example
+ * if ( CKEDITOR.env.ie6Compat )
+ * alert( "I'm on IE6 or quirks mode!" );
+ */
+ env.ie6Compat = ( version < 7 || env.quirks );
+
+ }
+
+ // Gecko.
+ if ( env.gecko )
+ {
+ var geckoRelease = agent.match( /rv:([\d\.]+)/ );
+ if ( geckoRelease )
+ {
+ geckoRelease = geckoRelease[1].split( '.' );
+ version = geckoRelease[0] * 10000 + ( geckoRelease[1] || 0 ) * 100 + ( geckoRelease[2] || 0 ) * 1;
+ }
+ }
+
+ // Opera 9.50+
+ if ( env.opera )
+ version = parseFloat( opera.version() );
+
+ // Adobe AIR 1.0+
+ // Checked before Safari because AIR have the WebKit rich text editor
+ // features from Safari 3.0.4, but the version reported is 420.
+ if ( env.air )
+ version = parseFloat( agent.match( / adobeair\/(\d+)/ )[1] );
+
+ // WebKit 522+ (Safari 3+)
+ if ( env.webkit )
+ version = parseFloat( agent.match( / applewebkit\/(\d+)/ )[1] );
+
+ /**
+ * Contains the browser version.
+ *
+ * For gecko based browsers (like Firefox) it contains the revision
+ * number with first three parts concatenated with a padding zero
+ * (e.g. for revision 1.9.0.2 we have 10900).
+ *
+ * For webkit based browser (like Safari and Chrome) it contains the
+ * WebKit build version (e.g. 522).
+ * @name CKEDITOR.env.version
+ * @type Boolean
+ * @example
+ * if ( CKEDITOR.env.ie && CKEDITOR.env.version <= 6 )
+ * alert( "Ouch!" );
+ */
+ env.version = version;
+
+ /**
+ * Indicates that CKEditor is running on a compatible browser.
+ * @name CKEDITOR.env.isCompatible
+ * @type Boolean
+ * @example
+ * if ( CKEDITOR.env.isCompatible )
+ * alert( "Your browser is pretty cool!" );
+ */
+ env.isCompatible =
+ ( env.ie && version >= 6 ) ||
+ ( env.gecko && version >= 10801 ) ||
+ ( env.opera && version >= 9.5 ) ||
+ ( env.air && version >= 1 ) ||
+ ( env.webkit && version >= 522 ) ||
+ false;
+
+ // The CSS class to be appended on the main UI containers, making it
+ // easy to apply browser specific styles to it.
+ env.cssClass =
+ 'cke_browser_' + (
+ env.ie ? 'ie' :
+ env.gecko ? 'gecko' :
+ env.opera ? 'opera' :
+ env.air ? 'air' :
+ env.webkit ? 'webkit' :
+ 'unknown' );
+
+ if ( env.quirks )
+ env.cssClass += ' cke_browser_quirks';
+
+ if ( env.ie )
+ {
+ env.cssClass += ' cke_browser_ie' + (
+ env.version < 7 ? '6' :
+ env.version >= 8 ? '8' :
+ '7' );
+
+ if ( env.quirks )
+ env.cssClass += ' cke_browser_iequirks';
+ }
+
+ if ( env.gecko && version < 10900 )
+ env.cssClass += ' cke_browser_gecko18';
+
+ return env;
+ })();
+}
+
+// PACKAGER_RENAME( CKEDITOR.env )
+// PACKAGER_RENAME( CKEDITOR.env.ie )
Index: /CKEditor/branches/versions/3.0.x/_source/core/event.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/event.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/event.js (revision 3751)
@@ -0,0 +1,335 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @fileOverview Defines the {@link CKEDITOR.event} class, which serves as the
+ * base for classes and objects that require event handling features.
+ */
+
+if ( !CKEDITOR.event )
+{
+ /**
+ * This is a base class for classes and objects that require event handling
+ * features.
+ * @constructor
+ * @example
+ */
+ CKEDITOR.event = function()
+ {};
+
+ /**
+ * Implements the {@link CKEDITOR.event} features in an object.
+ * @param {Object} targetObject The object in which implement the features.
+ * @example
+ * var myObject = { message : 'Example' };
+ * CKEDITOR.event.implementOn( myObject };
+ * myObject.on( 'testEvent', function()
+ * {
+ * alert( this.message ); // "Example"
+ * });
+ * myObject.fire( 'testEvent' );
+ */
+ CKEDITOR.event.implementOn = function( targetObject, isTargetPrototype )
+ {
+ var eventProto = CKEDITOR.event.prototype;
+
+ for ( var prop in eventProto )
+ {
+ if ( targetObject[ prop ] == undefined )
+ targetObject[ prop ] = eventProto[ prop ];
+ }
+ };
+
+ CKEDITOR.event.prototype = (function()
+ {
+ // Returns the private events object for a given object.
+ var getPrivate = function( obj )
+ {
+ var _ = ( obj.getPrivate && obj.getPrivate() ) || obj._ || ( obj._ = {} );
+ return _.events || ( _.events = {} );
+ };
+
+ var eventEntry = function( eventName )
+ {
+ this.name = eventName;
+ this.listeners = [];
+ };
+
+ eventEntry.prototype =
+ {
+ // Get the listener index for a specified function.
+ // Returns -1 if not found.
+ getListenerIndex : function( listenerFunction )
+ {
+ for ( var i = 0, listeners = this.listeners ; i < listeners.length ; i++ )
+ {
+ if ( listeners[i].fn == listenerFunction )
+ return i;
+ }
+ return -1;
+ }
+ };
+
+ return /** @lends CKEDITOR.event.prototype */ {
+ /**
+ * Registers a listener to a specific event in the current object.
+ * @param {String} eventName The event name to which listen.
+ * @param {Function} listenerFunction The function listening to the
+ * event.
+ * @param {Object} [scopeObj] The object used to scope the listener
+ * call (the this object. If omitted, the current object is used.
+ * @param {Object} [listenerData] Data to be sent as the
+ * {@link CKEDITOR.eventInfo#listenerData} when calling the
+ * listener.
+ * @param {Number} [priority] The listener priority. Lower priority
+ * listeners are called first. Listeners with the same priority
+ * value are called in registration order. Defaults to 10.
+ * @example
+ * someObject.on( 'someEvent', function()
+ * {
+ * alert( this == someObject ); // "true"
+ * });
+ * @example
+ * someObject.on( 'someEvent', function()
+ * {
+ * alert( this == anotherObject ); // "true"
+ * }
+ * , anotherObject );
+ * @example
+ * someObject.on( 'someEvent', function( event )
+ * {
+ * alert( event.listenerData ); // "Example"
+ * }
+ * , null, 'Example' );
+ * @example
+ * someObject.on( 'someEvent', function() { ... } ); // 2nd called
+ * someObject.on( 'someEvent', function() { ... }, null, null, 100 ); // 3rd called
+ * someObject.on( 'someEvent', function() { ... }, null, null, 1 ); // 1st called
+ */
+ on : function( eventName, listenerFunction, scopeObj, listenerData, priority )
+ {
+ // Get the event entry (create it if needed).
+ var events = getPrivate( this ),
+ event = events[ eventName ] || ( events[ eventName ] = new eventEntry( eventName ) );
+
+ if ( event.getListenerIndex( listenerFunction ) < 0 )
+ {
+ // Get the listeners.
+ var listeners = event.listeners;
+
+ // Fill the scope.
+ if ( !scopeObj )
+ scopeObj = this;
+
+ // Default the priority, if needed.
+ if ( isNaN( priority ) )
+ priority = 10;
+
+ var me = this;
+
+ // Create the function to be fired for this listener.
+ var listenerFirer = function( editor, publisherData, stopFn, cancelFn )
+ {
+ var ev =
+ {
+ name : eventName,
+ sender : this,
+ editor : editor,
+ data : publisherData,
+ listenerData : listenerData,
+ stop : stopFn,
+ cancel : cancelFn,
+ removeListener : function()
+ {
+ me.removeListener( eventName, listenerFunction );
+ }
+ };
+
+ listenerFunction.call( scopeObj, ev );
+
+ return ev.data;
+ };
+ listenerFirer.fn = listenerFunction;
+ listenerFirer.priority = priority;
+
+ // Search for the right position for this new listener, based on its
+ // priority.
+ for ( var i = listeners.length - 1 ; i >= 0 ; i-- )
+ {
+ // Find the item which should be before the new one.
+ if ( listeners[ i ].priority <= priority )
+ {
+ // Insert the listener in the array.
+ listeners.splice( i + 1, 0, listenerFirer );
+ return;
+ }
+ }
+
+ // If no position has been found (or zero length), put it in
+ // the front of list.
+ listeners.unshift( listenerFirer );
+ }
+ },
+
+ /**
+ * Fires an specific event in the object. All registered listeners are
+ * called at this point.
+ * @function
+ * @param {String} eventName The event name to fire.
+ * @param {Object} [data] Data to be sent as the
+ * {@link CKEDITOR.eventInfo#data} when calling the
+ * listeners.
+ * @param {CKEDITOR.editor} [editor] The editor instance to send as the
+ * {@link CKEDITOR.eventInfo#editor} when calling the
+ * listener.
+ * @returns {Boolean|Object} A booloan indicating that the event is to be
+ * canceled, or data returned by one of the listeners.
+ * @example
+ * someObject.on( 'someEvent', function() { ... } );
+ * someObject.on( 'someEvent', function() { ... } );
+ * someObject.fire( 'someEvent' ); // both listeners are called
+ * @example
+ * someObject.on( 'someEvent', function( event )
+ * {
+ * alert( event.data ); // "Example"
+ * });
+ * someObject.fire( 'someEvent', 'Example' );
+ */
+ fire : (function()
+ {
+ // Create the function that marks the event as stopped.
+ var stopped = false;
+ var stopEvent = function()
+ {
+ stopped = true;
+ };
+
+ // Create the function that marks the event as canceled.
+ var canceled = false;
+ var cancelEvent = function()
+ {
+ canceled = true;
+ };
+
+ return function( eventName, data, editor )
+ {
+ // Get the event entry.
+ var event = getPrivate( this )[ eventName ];
+
+ // Save the previous stopped and cancelled states. We may
+ // be nesting fire() calls.
+ var previousStopped = stopped,
+ previousCancelled = canceled;
+
+ // Reset the stopped and canceled flags.
+ stopped = canceled = false;
+
+ if ( event )
+ {
+ var listeners = event.listeners;
+
+ if ( listeners.length )
+ {
+ // As some listeners may remove themselves from the
+ // event, the original array length is dinamic. So,
+ // let's make a copy of all listeners, so we are
+ // sure we'll call all of them.
+ listeners = listeners.slice( 0 );
+
+ // Loop through all listeners.
+ for ( var i = 0 ; i < listeners.length ; i++ )
+ {
+ // Call the listener, passing the event data.
+ var retData = listeners[i].call( this, editor, data, stopEvent, cancelEvent );
+
+ if ( typeof retData != 'undefined' )
+ data = retData;
+
+ // No further calls is stopped or canceled.
+ if ( stopped || canceled )
+ break;
+ }
+ }
+ }
+
+ var ret = canceled || ( typeof data == 'undefined' ? false : data );
+
+ // Restore the previous stopped and canceled states.
+ stopped = previousStopped;
+ canceled = previousCancelled;
+
+ return ret;
+ };
+ })(),
+
+ /**
+ * Fires an specific event in the object, releasing all listeners
+ * registered to that event. The same listeners are not called again on
+ * successive calls of it or of {@link #fire}.
+ * @param {String} eventName The event name to fire.
+ * @param {Object} [data] Data to be sent as the
+ * {@link CKEDITOR.eventInfo#data} when calling the
+ * listeners.
+ * @param {CKEDITOR.editor} [editor] The editor instance to send as the
+ * {@link CKEDITOR.eventInfo#editor} when calling the
+ * listener.
+ * @returns {Boolean|Object} A booloan indicating that the event is to be
+ * canceled, or data returned by one of the listeners.
+ * @example
+ * someObject.on( 'someEvent', function() { ... } );
+ * someObject.fire( 'someEvent' ); // above listener called
+ * someObject.fireOnce( 'someEvent' ); // above listener called
+ * someObject.fire( 'someEvent' ); // no listeners called
+ */
+ fireOnce : function( eventName, data, editor )
+ {
+ var ret = this.fire( eventName, data, editor );
+ delete getPrivate( this )[ eventName ];
+ return ret;
+ },
+
+ /**
+ * Unregisters a listener function from being called at the specified
+ * event. No errors are thrown if the listener has not been
+ * registered previously.
+ * @param {String} eventName The event name.
+ * @param {Function} listenerFunction The listener function to unregister.
+ * @example
+ * var myListener = function() { ... };
+ * someObject.on( 'someEvent', myListener );
+ * someObject.fire( 'someEvent' ); // myListener called
+ * someObject.removeListener( 'someEvent', myListener );
+ * someObject.fire( 'someEvent' ); // myListener not called
+ */
+ removeListener : function( eventName, listenerFunction )
+ {
+ // Get the event entry.
+ var event = getPrivate( this )[ eventName ];
+
+ if ( event )
+ {
+ var index = event.getListenerIndex( listenerFunction );
+ if ( index >= 0 )
+ event.listeners.splice( index, 1 );
+ }
+ },
+
+ /**
+ * Checks if there is any listener registered to a given event.
+ * @param {String} eventName The event name.
+ * @example
+ * var myListener = function() { ... };
+ * someObject.on( 'someEvent', myListener );
+ * alert( someObject.hasListeners( 'someEvent' ) ); // "true"
+ * alert( someObject.hasListeners( 'noEvent' ) ); // "false"
+ */
+ hasListeners : function( eventName )
+ {
+ var event = getPrivate( this )[ eventName ];
+ return ( event && event.listeners.length > 0 ) ;
+ }
+ };
+ })();
+}
Index: /CKEditor/branches/versions/3.0.x/_source/core/eventInfo.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/eventInfo.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/eventInfo.js (revision 3751)
@@ -0,0 +1,120 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @fileOverview Defines the "virtual" {@link CKEDITOR.eventInfo} class, which
+ * contains the defintions of the event object passed to event listeners.
+ * This file is for documentation purposes only.
+ */
+
+/**
+ * This class is not really part of the API. It just illustrates the features
+ * of the event object passed to event listeners by a {@link CKEDITOR.event}
+ * based object.
+ * @name CKEDITOR.eventInfo
+ * @constructor
+ * @example
+ * // Do not do this.
+ * var myEvent = new CKEDITOR.eventInfo(); // Error: CKEDITOR.eventInfo is undefined
+ */
+
+/**
+ * The event name.
+ * @name CKEDITOR.eventInfo.prototype.name
+ * @field
+ * @type String
+ * @example
+ * someObject.on( 'someEvent', function( event )
+ * {
+ * alert( event.name ); // "someEvent"
+ * });
+ * someObject.fire( 'someEvent' );
+ */
+
+/**
+ * The object that publishes (sends) the event.
+ * @name CKEDITOR.eventInfo.prototype.sender
+ * @field
+ * @type Object
+ * @example
+ * someObject.on( 'someEvent', function( event )
+ * {
+ * alert( event.sender == someObject ); // "true"
+ * });
+ * someObject.fire( 'someEvent' );
+ */
+
+/**
+ * The editor instance that holds the sender. May be the same as sender. May be
+ * null if the sender is not part of an editor instance, like a component
+ * running in standalone mode.
+ * @name CKEDITOR.eventInfo.prototype.editor
+ * @field
+ * @type CKEDITOR.editor
+ * @example
+ * myButton.on( 'someEvent', function( event )
+ * {
+ * alert( event.editor == myEditor ); // "true"
+ * });
+ * myButton.fire( 'someEvent', null, myEditor );
+ */
+
+/**
+ * Any kind of additional data. Its format and usage is event dependent.
+ * @name CKEDITOR.eventInfo.prototype.data
+ * @field
+ * @type Object
+ * @example
+ * someObject.on( 'someEvent', function( event )
+ * {
+ * alert( event.data ); // "Example"
+ * });
+ * someObject.fire( 'someEvent', 'Example' );
+ */
+
+/**
+ * Any extra data appended during the listener registration.
+ * @name CKEDITOR.eventInfo.prototype.listenerData
+ * @field
+ * @type Object
+ * @example
+ * someObject.on( 'someEvent', function( event )
+ * {
+ * alert( event.listenerData ); // "Example"
+ * }
+ * , null, 'Example' );
+ */
+
+/**
+ * Indicates that no further listeners are to be called.
+ * @name CKEDITOR.eventInfo.prototype.stop
+ * @function
+ * @example
+ * someObject.on( 'someEvent', function( event )
+ * {
+ * event.stop();
+ * });
+ * someObject.on( 'someEvent', function( event )
+ * {
+ * // This one will not be called.
+ * });
+ * alert( someObject.fire( 'someEvent' ) ); // "false"
+ */
+
+/**
+ * Indicates that the event is to be cancelled (if cancelable).
+ * @name CKEDITOR.eventInfo.prototype.cancel
+ * @function
+ * @example
+ * someObject.on( 'someEvent', function( event )
+ * {
+ * event.cancel();
+ * });
+ * someObject.on( 'someEvent', function( event )
+ * {
+ * // This one will not be called.
+ * });
+ * alert( someObject.fire( 'someEvent' ) ); // "true"
+ */
Index: /CKEditor/branches/versions/3.0.x/_source/core/focusmanager.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/focusmanager.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/focusmanager.js (revision 3751)
@@ -0,0 +1,123 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @fileOverview Defines the {@link CKEDITOR.focusManager} class, which is used
+ * to handle the focus on editor instances..
+ */
+
+/**
+ * Manages the focus activity in an editor instance. This class is to be used
+ * mainly by UI elements coders when adding interface elements to CKEditor.
+ * @constructor
+ * @param {CKEDITOR.editor} editor The editor instance.
+ * @example
+ */
+CKEDITOR.focusManager = function( editor )
+{
+ if ( editor.focusManager )
+ return editor.focusManager;
+
+ /**
+ * Indicates that the editor instance has focus.
+ * @type Boolean
+ * @example
+ * alert( CKEDITOR.instances.editor1.focusManager.hasFocus ); // e.g "true"
+ */
+ this.hasFocus = false;
+
+ /**
+ * Object used to hold private stuff.
+ * @private
+ */
+ this._ =
+ {
+ editor : editor
+ };
+
+ return this;
+};
+
+CKEDITOR.focusManager.prototype =
+{
+ /**
+ * Indicates that the editor instance has the focus.
+ *
+ * This function is not used to set the focus in the editor. Use
+ * {@link CKEDITOR.editor#focus} for it instead.
+ * @example
+ * var editor = CKEDITOR.instances.editor1;
+ * editor.focusManager.focus();
+ */
+ focus : function()
+ {
+ if ( this._.timer )
+ clearTimeout( this._.timer );
+
+ if ( !this.hasFocus )
+ {
+ // If another editor has the current focus, we first "blur" it. In
+ // this way the events happen in a more logical sequence, like:
+ // "focus 1" > "blur 1" > "focus 2"
+ // ... instead of:
+ // "focus 1" > "focus 2" > "blur 1"
+ if ( CKEDITOR.currentInstance )
+ CKEDITOR.currentInstance.focusManager.forceBlur();
+
+ var editor = this._.editor;
+
+ editor.container.getFirst().addClass( 'cke_focus' );
+
+ this.hasFocus = true;
+ editor.fire( 'focus' );
+ }
+ },
+
+ /**
+ * Indicates that the editor instance has lost the focus. Note that this
+ * functions acts asynchronously with a delay of 100ms to avoid subsequent
+ * blur/focus effects. If you want the "blur" to happen immediately, use
+ * the {@link #forceBlur} function instead.
+ * @example
+ * var editor = CKEDITOR.instances.editor1;
+ * editor.focusManager.blur();
+ */
+ blur : function()
+ {
+ var focusManager = this;
+
+ if ( focusManager._.timer )
+ clearTimeout( focusManager._.timer );
+
+ focusManager._.timer = setTimeout(
+ function()
+ {
+ delete focusManager._.timer;
+ focusManager.forceBlur();
+ }
+ , 100 );
+ },
+
+ /**
+ * Indicates that the editor instance has lost the focus. Unlike
+ * {@link #blur}, this function is synchronous, marking the instance as
+ * "blured" immediately.
+ * @example
+ * var editor = CKEDITOR.instances.editor1;
+ * editor.focusManager.forceBlur();
+ */
+ forceBlur : function()
+ {
+ if ( this.hasFocus )
+ {
+ var editor = this._.editor;
+
+ editor.container.getFirst().removeClass( 'cke_focus' );
+
+ this.hasFocus = false;
+ editor.fire( 'blur' );
+ }
+ }
+};
Index: /CKEditor/branches/versions/3.0.x/_source/core/htmlparser.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/htmlparser.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/htmlparser.js (revision 3751)
@@ -0,0 +1,212 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * HTML text parser.
+ * @constructor
+ * @example
+ */
+CKEDITOR.htmlParser = function()
+{
+ this._ =
+ {
+ htmlPartsRegex : new RegExp( '<(?:(?:\\/([^>]+)>)|(?:!--([\\S|\\s]*?)-->)|(?:([^\\s>]+)\\s*((?:(?:[^"\'>]+)|(?:"[^"]*")|(?:\'[^\']*\'))*)\\/?>))', 'g' )
+ };
+};
+
+(function()
+{
+ var attribsRegex = /([\w:]+)(?:(?:\s*=\s*(?:(?:"([^"]*)")|(?:'([^']*)')|([^\s>]+)))|(?=\s|$))/g,
+ emptyAttribs = {checked:1,compact:1,declare:1,defer:1,disabled:1,ismap:1,multiple:1,nohref:1,noresize:1,noshade:1,nowrap:1,readonly:1,selected:1};
+
+ CKEDITOR.htmlParser.prototype =
+ {
+ /**
+ * Function to be fired when a tag opener is found. This function
+ * should be overriden when using this class.
+ * @param {String} tagName The tag name. The name is guarantted to be
+ * lowercased.
+ * @param {Object} attributes An object containing all tag attributes. Each
+ * property in this object represent and attribute name and its
+ * value is the attribute value.
+ * @param {Boolean} selfClosing true if the tag closes itself, false if the
+ * tag doesn't.
+ * @example
+ * var parser = new CKEDITOR.htmlParser();
+ * parser.onTagOpen = function( tagName, attributes, selfClosing )
+ * {
+ * alert( tagName ); // e.g. "b"
+ * });
+ * parser.parse( "<!-- Example --><b>Hello</b>" );
+ */
+ onTagOpen : function() {},
+
+ /**
+ * Function to be fired when a tag closer is found. This function
+ * should be overriden when using this class.
+ * @param {String} tagName The tag name. The name is guarantted to be
+ * lowercased.
+ * @example
+ * var parser = new CKEDITOR.htmlParser();
+ * parser.onTagClose = function( tagName )
+ * {
+ * alert( tagName ); // e.g. "b"
+ * });
+ * parser.parse( "<!-- Example --><b>Hello</b>" );
+ */
+ onTagClose : function() {},
+
+ /**
+ * Function to be fired when text is found. This function
+ * should be overriden when using this class.
+ * @param {String} text The text found.
+ * @example
+ * var parser = new CKEDITOR.htmlParser();
+ * parser.onText = function( text )
+ * {
+ * alert( text ); // e.g. "Hello"
+ * });
+ * parser.parse( "<!-- Example --><b>Hello</b>" );
+ */
+ onText : function() {},
+
+ /**
+ * Function to be fired when CDATA section is found. This function
+ * should be overriden when using this class.
+ * @param {String} cdata The CDATA been found.
+ * @example
+ * var parser = new CKEDITOR.htmlParser();
+ * parser.onCDATA = function( cdata )
+ * {
+ * alert( cdata ); // e.g. "var hello;"
+ * });
+ * parser.parse( "<script>var hello;</script>" );
+ */
+ onCDATA : function() {},
+
+ /**
+ * Function to be fired when a commend is found. This function
+ * should be overriden when using this class.
+ * @param {String} comment The comment text.
+ * @example
+ * var parser = new CKEDITOR.htmlParser();
+ * parser.onText = function( comment )
+ * {
+ * alert( comment ); // e.g. " Example "
+ * });
+ * parser.parse( "<!-- Example --><b>Hello</b>" );
+ */
+ onComment : function() {},
+
+ /**
+ * Parses text, looking for HTML tokens, like tag openers or closers,
+ * or comments. This function fires the onTagOpen, onTagClose, onText
+ * and onComment function during its execution.
+ * @param {String} html The HTML to be parsed.
+ * @example
+ * var parser = new CKEDITOR.htmlParser();
+ * // The onTagOpen, onTagClose, onText and onComment should be overriden
+ * // at this point.
+ * parser.parse( "<!-- Example --><b>Hello</b>" );
+ */
+ parse : function( html )
+ {
+ var parts,
+ tagName,
+ nextIndex = 0,
+ cdata; // The collected data inside a CDATA section.
+
+ while ( ( parts = this._.htmlPartsRegex.exec( html ) ) )
+ {
+ var tagIndex = parts.index;
+ if ( tagIndex > nextIndex )
+ {
+ var text = html.substring( nextIndex, tagIndex );
+
+ if ( cdata )
+ cdata.push( text );
+ else
+ this.onText( text );
+ }
+
+ nextIndex = this._.htmlPartsRegex.lastIndex;
+
+ /*
+ "parts" is an array with the following items:
+ 0 : The entire match for opening/closing tags and comments.
+ 1 : Group filled with the tag name for closing tags.
+ 2 : Group filled with the comment text.
+ 3 : Group filled with the tag name for opening tags.
+ 4 : Group filled with the attributes part of opening tags.
+ */
+
+ // Closing tag
+ if ( ( tagName = parts[ 1 ] ) )
+ {
+ tagName = tagName.toLowerCase();
+
+ if ( cdata && CKEDITOR.dtd.$cdata[ tagName ] )
+ {
+ // Send the CDATA data.
+ this.onCDATA( cdata.join('') );
+ cdata = null;
+ }
+
+ if ( !cdata )
+ {
+ this.onTagClose( tagName );
+ continue;
+ }
+ }
+
+ // If CDATA is enabled, just save the raw match.
+ if ( cdata )
+ {
+ cdata.push( parts[ 0 ] );
+ continue;
+ }
+
+ // Opening tag
+ if ( ( tagName = parts[ 3 ] ) )
+ {
+ tagName = tagName.toLowerCase();
+ var attribs = {},
+ attribMatch,
+ attribsPart = parts[ 4 ],
+ selfClosing = !!( attribsPart && attribsPart.charAt( attribsPart.length - 1 ) == '/' );
+
+ if ( attribsPart )
+ {
+ while ( ( attribMatch = attribsRegex.exec( attribsPart ) ) )
+ {
+ var attName = attribMatch[1].toLowerCase(),
+ attValue = attribMatch[2] || attribMatch[3] || attribMatch[4] || '';
+
+ if ( !attValue && emptyAttribs[ attName ] )
+ attribs[ attName ] = attName;
+ else
+ attribs[ attName ] = attValue;
+ }
+ }
+
+ this.onTagOpen( tagName, attribs, selfClosing );
+
+ // Open CDATA mode when finding the appropriate tags.
+ if ( !cdata && CKEDITOR.dtd.$cdata[ tagName ] )
+ cdata = [];
+
+ continue;
+ }
+
+ // Comment
+ if( ( tagName = parts[ 2 ] ) )
+ this.onComment( tagName );
+ }
+
+ if ( html.length > nextIndex )
+ this.onText( html.substring( nextIndex, html.length ) );
+ }
+ };
+})();
Index: /CKEditor/branches/versions/3.0.x/_source/core/htmlparser/basicwriter.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/htmlparser/basicwriter.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/htmlparser/basicwriter.js (revision 3751)
@@ -0,0 +1,140 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+CKEDITOR.htmlParser.basicWriter = CKEDITOR.tools.createClass(
+{
+ $ : function()
+ {
+ this._ =
+ {
+ output : []
+ };
+ },
+
+ proto :
+ {
+ /**
+ * Writes the tag opening part for a opener tag.
+ * @param {String} tagName The element name for this tag.
+ * @param {Object} attributes The attributes defined for this tag. The
+ * attributes could be used to inspect the tag.
+ * @example
+ * // Writes "<p".
+ * writer.openTag( 'p', { class : 'MyClass', id : 'MyId' } );
+ */
+ openTag : function( tagName, attributes )
+ {
+ this._.output.push( '<', tagName );
+ },
+
+ /**
+ * Writes the tag closing part for a opener tag.
+ * @param {String} tagName The element name for this tag.
+ * @param {Boolean} isSelfClose Indicates that this is a self-closing tag,
+ * like "br" or "img".
+ * @example
+ * // Writes ">".
+ * writer.openTagClose( 'p', false );
+ * @example
+ * // Writes " />".
+ * writer.openTagClose( 'br', true );
+ */
+ openTagClose : function( tagName, isSelfClose )
+ {
+ if ( isSelfClose )
+ this._.output.push( ' />' );
+ else
+ this._.output.push( '>' );
+ },
+
+ /**
+ * Writes an attribute. This function should be called after opening the
+ * tag with {@link #openTagClose}.
+ * @param {String} attName The attribute name.
+ * @param {String} attValue The attribute value.
+ * @example
+ * // Writes ' class="MyClass"'.
+ * writer.attribute( 'class', 'MyClass' );
+ */
+ attribute : function( attName, attValue )
+ {
+ this._.output.push( ' ', attName, '="', attValue, '"' );
+ },
+
+ /**
+ * Writes a closer tag.
+ * @param {String} tagName The element name for this tag.
+ * @example
+ * // Writes "</p>".
+ * writer.closeTag( 'p' );
+ */
+ closeTag : function( tagName )
+ {
+ this._.output.push( '', tagName, '>' );
+ },
+
+ /**
+ * Writes text.
+ * @param {String} text The text value
+ * @example
+ * // Writes "Hello Word".
+ * writer.text( 'Hello Word' );
+ */
+ text : function( text )
+ {
+ this._.output.push( text );
+ },
+
+ /**
+ * Writes a comment.
+ * @param {String} comment The comment text.
+ * @example
+ * // Writes "<!-- My comment -->".
+ * writer.comment( ' My comment ' );
+ */
+ comment : function( comment )
+ {
+ this._.output.push( '' );
+ },
+
+ /**
+ * Writes any kind of data to the ouput.
+ * @example
+ * writer.write( 'This is an <b>example</b>.' );
+ */
+ write : function( data )
+ {
+ this._.output.push( data );
+ },
+
+ /**
+ * Empties the current output buffer.
+ * @example
+ * writer.reset();
+ */
+ reset : function()
+ {
+ this._.output = [];
+ },
+
+ /**
+ * Empties the current output buffer.
+ * @param {Boolean} reset Indicates that the {@link reset} function is to
+ * be automatically called after retrieving the HTML.
+ * @returns {String} The HTML written to the writer so far.
+ * @example
+ * var html = writer.getHtml();
+ */
+ getHtml : function( reset )
+ {
+ var html = this._.output.join( '' );
+
+ if ( reset )
+ this.reset();
+
+ return html;
+ }
+ }
+});
Index: /CKEditor/branches/versions/3.0.x/_source/core/htmlparser/cdata.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/htmlparser/cdata.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/htmlparser/cdata.js (revision 3751)
@@ -0,0 +1,44 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+(function()
+{
+
+ /**
+ * A lightweight representation of HTML text.
+ * @constructor
+ * @example
+ */
+ CKEDITOR.htmlParser.cdata = function( value )
+ {
+ /**
+ * The CDATA value.
+ * @type String
+ * @example
+ */
+ this.value = value;
+
+ };
+
+ CKEDITOR.htmlParser.cdata.prototype =
+ {
+ /**
+ * CDATA has the same type as {@link CKEDITOR.htmlParser.text} This is
+ * a constant value set to {@link CKEDITOR.NODE_TEXT}.
+ * @type Number
+ * @example
+ */
+ type : CKEDITOR.NODE_TEXT,
+
+ /**
+ * Writes write the CDATA with no special manipulations.
+ * @param {CKEDITOR.htmlWriter} writer The writer to which write the HTML.
+ */
+ writeHtml : function( writer )
+ {
+ writer.write( this.value );
+ }
+ };
+})();
Index: /CKEditor/branches/versions/3.0.x/_source/core/htmlparser/comment.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/htmlparser/comment.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/htmlparser/comment.js (revision 3751)
@@ -0,0 +1,59 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * A lightweight representation of an HTML comment.
+ * @constructor
+ * @example
+ */
+CKEDITOR.htmlParser.comment = function( value )
+{
+ /**
+ * The comment text.
+ * @type String
+ * @example
+ */
+ this.value = value;
+
+ /** @private */
+ this._ =
+ {
+ isBlockLike : false
+ };
+};
+
+CKEDITOR.htmlParser.comment.prototype =
+{
+ /**
+ * The node type. This is a constant value set to {@link CKEDITOR.NODE_COMMENT}.
+ * @type Number
+ * @example
+ */
+ type : CKEDITOR.NODE_COMMENT,
+
+ /**
+ * Writes the HTML representation of this comment to a CKEDITOR.htmlWriter.
+ * @param {CKEDITOR.htmlWriter} writer The writer to which write the HTML.
+ * @example
+ */
+ writeHtml : function( writer, filter )
+ {
+ var comment = this.value;
+
+ if ( filter )
+ {
+ if ( !( comment = filter.onComment( comment ) ) )
+ return;
+
+ if ( typeof comment != 'string' )
+ {
+ comment.writeHtml( writer, filter );
+ return;
+ }
+ }
+
+ writer.comment( comment );
+ }
+};
Index: /CKEditor/branches/versions/3.0.x/_source/core/htmlparser/element.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/htmlparser/element.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/htmlparser/element.js (revision 3751)
@@ -0,0 +1,196 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * A lightweight representation of an HTML element.
+ * @param {String} name The element name.
+ * @param {Object} attributes And object holding all attributes defined for
+ * this element.
+ * @constructor
+ * @example
+ */
+CKEDITOR.htmlParser.element = function( name, attributes )
+{
+ /**
+ * The element name.
+ * @type String
+ * @example
+ */
+ this.name = name;
+
+ /**
+ * Holds the attributes defined for this element.
+ * @type Object
+ * @example
+ */
+ this.attributes = attributes;
+
+ /**
+ * The nodes that are direct children of this element.
+ * @type Array
+ * @example
+ */
+ this.children = [];
+
+ var dtd = CKEDITOR.dtd,
+ isBlockLike = !!( dtd.$block[ name ] || dtd.$listItem[ name ] || dtd.$tableContent[ name ] ),
+ isEmpty = !!dtd.$empty[ name ];
+
+ this.isEmpty = isEmpty;
+ this.isUnknown = !dtd[ name ];
+
+ /** @private */
+ this._ =
+ {
+ isBlockLike : isBlockLike,
+ hasInlineStarted : isEmpty || !isBlockLike
+ };
+};
+
+(function()
+{
+ // Used to sort attribute entries in an array, where the first element of
+ // each object is the attribute name.
+ var sortAttribs = function( a, b )
+ {
+ a = a[0];
+ b = b[0];
+ return a < b ? -1 : a > b ? 1 : 0;
+ };
+
+ CKEDITOR.htmlParser.element.prototype =
+ {
+ /**
+ * The node type. This is a constant value set to {@link CKEDITOR.NODE_ELEMENT}.
+ * @type Number
+ * @example
+ */
+ type : CKEDITOR.NODE_ELEMENT,
+
+ /**
+ * Adds a node to the element children list.
+ * @param {Object} node The node to be added. It can be any of of the
+ * following types: {@link CKEDITOR.htmlParser.element},
+ * {@link CKEDITOR.htmlParser.text} and
+ * {@link CKEDITOR.htmlParser.comment}.
+ * @function
+ * @example
+ */
+ add : CKEDITOR.htmlParser.fragment.prototype.add,
+
+ /**
+ * Clone this element.
+ * @returns {CKEDITOR.htmlParser.element} The element clone.
+ * @example
+ */
+ clone : function()
+ {
+ return new CKEDITOR.htmlParser.element( this.name, this.attributes );
+ },
+
+ /**
+ * Writes the element HTML to a CKEDITOR.htmlWriter.
+ * @param {CKEDITOR.htmlWriter} writer The writer to which write the HTML.
+ * @example
+ */
+ writeHtml : function( writer, filter )
+ {
+ var attributes = this.attributes;
+
+ // The "_cke_replacedata" indicates that this element is replacing
+ // a data snippet, which should be outputted as is.
+ if ( attributes._cke_replacedata )
+ {
+ writer.write( attributes._cke_replacedata );
+ return;
+ }
+
+ // Ignore cke: prefixes when writing HTML.
+ var element = this,
+ writeName = element.name,
+ a, value;
+
+ if ( filter )
+ {
+ while ( true )
+ {
+ if ( !( writeName = filter.onElementName( writeName ) ) )
+ return;
+
+ element.name = writeName;
+
+ if ( !( element = filter.onElement( element ) ) )
+ return;
+
+ if ( element.name == writeName )
+ break;
+
+ writeName = element.name;
+ if ( !writeName ) // Send children.
+ {
+ CKEDITOR.htmlParser.fragment.prototype.writeHtml.apply( element, arguments );
+ return;
+ }
+ }
+
+ // The element may have been changed, so update the local
+ // references.
+ attributes = element.attributes;
+ }
+
+ // Open element tag.
+ writer.openTag( writeName, attributes );
+
+ if ( writer.sortAttributes )
+ {
+ // Copy all attributes to an array.
+ var attribsArray = [];
+ for ( a in attributes )
+ {
+ value = attributes[ a ];
+
+ if ( filter && ( !( a = filter.onAttributeName( a ) ) || ( value = filter.onAttribute( element, a, value ) ) === false ) )
+ continue;
+
+ attribsArray.push( [ a, value ] );
+ }
+
+ // Sort the attributes by name.
+ attribsArray.sort( sortAttribs );
+
+ // Send the attributes.
+ for ( var i = 0, len = attribsArray.length ; i < len ; i++ )
+ {
+ var attrib = attribsArray[ i ];
+ writer.attribute( attrib[0], attrib[1] );
+ }
+ }
+ else
+ {
+ for ( a in attributes )
+ {
+ value = attributes[ a ];
+
+ if ( filter && ( !( a = filter.onAttributeName( a ) ) || ( value = filter.onAttribute( element, a, value ) ) === false ) )
+ continue;
+
+ writer.attribute( a, value );
+ }
+ }
+
+ // Close the tag.
+ writer.openTagClose( writeName, element.isEmpty );
+
+ if ( !element.isEmpty )
+ {
+ // Send children.
+ CKEDITOR.htmlParser.fragment.prototype.writeHtml.apply( element, arguments );
+
+ // Close the element.
+ writer.closeTag( writeName );
+ }
+ }
+ };
+})();
Index: /CKEditor/branches/versions/3.0.x/_source/core/htmlparser/filter.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/htmlparser/filter.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/htmlparser/filter.js (revision 3751)
@@ -0,0 +1,233 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+(function()
+{
+ CKEDITOR.htmlParser.filter = CKEDITOR.tools.createClass(
+ {
+ $ : function( rules )
+ {
+ this._ =
+ {
+ elementNames : [],
+ attributeNames : [],
+ elements : { $length : 0 },
+ attributes : { $length : 0 }
+ };
+
+ if ( rules )
+ this.addRules( rules, 10 );
+ },
+
+ proto :
+ {
+ addRules : function( rules, priority )
+ {
+ if ( typeof priority != 'number' )
+ priority = 10;
+
+ // Add the elementNames.
+ addItemsToList( this._.elementNames, rules.elementNames, priority );
+
+ // Add the attributeNames.
+ addItemsToList( this._.attributeNames, rules.attributeNames, priority );
+
+ // Add the elements.
+ addNamedItems( this._.elements, rules.elements, priority );
+
+ // Add the attributes.
+ addNamedItems( this._.attributes, rules.attributes, priority );
+
+ // Add the text.
+ this._.text = transformNamedItem( this._.text, rules.text, priority ) || this._.text;
+
+ // Add the comment.
+ this._.comment = transformNamedItem( this._.comment, rules.comment, priority ) || this._.comment;
+ },
+
+ onElementName : function( name )
+ {
+ return filterName( name, this._.elementNames );
+ },
+
+ onAttributeName : function( name )
+ {
+ return filterName( name, this._.attributeNames );
+ },
+
+ onText : function( text )
+ {
+ var textFilter = this._.text;
+ return textFilter ? textFilter.filter( text ) : text;
+ },
+
+ onComment : function( commentText )
+ {
+ var textFilter = this._.comment;
+ return textFilter ? textFilter.filter( commentText ) : commentText;
+ },
+
+ onElement : function( element )
+ {
+ // We must apply filters set to the specific element name as
+ // well as those set to the generic $ name. So, add both to an
+ // array and process them in a small loop.
+ var filters = [ this._.elements[ element.name ], this._.elements.$ ],
+ filter, ret;
+
+ for ( var i = 0 ; i < 2 ; i++ )
+ {
+ filter = filters[ i ];
+ if ( filter )
+ {
+ ret = filter.filter( element, this );
+
+ if ( ret === false )
+ return null;
+
+ if ( ret && ret != element )
+ return this.onElement( ret );
+ }
+ }
+
+ return element;
+ },
+
+ onAttribute : function( element, name, value )
+ {
+ var filter = this._.attributes[ name ];
+
+ if ( filter )
+ {
+ var ret = filter.filter( value, element, this );
+
+ if ( ret === false )
+ return false;
+
+ if ( typeof ret != 'undefined' )
+ return ret;
+ }
+
+ return value;
+ }
+ }
+ });
+
+ function filterName( name, filters )
+ {
+ for ( var i = 0 ; name && i < filters.length ; i++ )
+ {
+ var filter = filters[ i ];
+ name = name.replace( filter[ 0 ], filter[ 1 ] );
+ }
+ return name;
+ }
+
+ function addItemsToList( list, items, priority )
+ {
+ var i, j,
+ listLength = list.length,
+ itemsLength = items && items.length;
+
+ if ( itemsLength )
+ {
+ // Find the index to insert the items at.
+ for ( i = 0 ; i < listLength && list[ i ].pri < priority ; i++ )
+ { /*jsl:pass*/ }
+
+ // Add all new items to the list at the specific index.
+ for ( j = itemsLength - 1 ; j >= 0 ; j-- )
+ {
+ var item = items[ j ];
+ item.pri = priority;
+ list.splice( i, 0, item );
+ }
+ }
+ }
+
+ function addNamedItems( hashTable, items, priority )
+ {
+ if ( items )
+ {
+ for ( var name in items )
+ {
+ var current = hashTable[ name ];
+
+ hashTable[ name ] =
+ transformNamedItem(
+ current,
+ items[ name ],
+ priority );
+
+ if ( !current )
+ hashTable.$length++;
+ }
+ }
+ }
+
+ function transformNamedItem( current, item, priority )
+ {
+ if ( item )
+ {
+ item.pri = priority;
+
+ if ( current )
+ {
+ // If the current item is not an Array, transform it.
+ if ( !current.splice )
+ {
+ if ( current.pri > priority )
+ current = [ item, current ];
+ else
+ current = [ current, item ];
+
+ current.filter = callItems;
+ }
+ else
+ addItemsToList( current, item, priority );
+
+ return current;
+ }
+ else
+ {
+ item.filter = item;
+ return item;
+ }
+ }
+ }
+
+ function callItems( currentEntry )
+ {
+ var isObject = ( typeof currentEntry == 'object' );
+
+ for ( var i = 0 ; i < this.length ; i++ )
+ {
+ var item = this[ i ],
+ ret = item.apply( window, arguments );
+
+ if ( typeof ret != 'undefined' )
+ {
+ if ( ret === false )
+ return false;
+
+ if ( isObject && ret != currentEntry )
+ return ret;
+ }
+ }
+
+ return null;
+ }
+})();
+
+// "entities" plugin
+/*
+{
+ text : function( text )
+ {
+ // TODO : Process entities.
+ return text.toUpperCase();
+ }
+};
+*/
Index: /CKEditor/branches/versions/3.0.x/_source/core/htmlparser/fragment.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/htmlparser/fragment.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/htmlparser/fragment.js (revision 3751)
@@ -0,0 +1,417 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * A lightweight representation of an HTML DOM structure.
+ * @constructor
+ * @example
+ */
+CKEDITOR.htmlParser.fragment = function()
+{
+ /**
+ * The nodes contained in the root of this fragment.
+ * @type Array
+ * @example
+ * var fragment = CKEDITOR.htmlParser.fragment.fromHtml( 'Sample Text' );
+ * alert( fragment.children.length ); "2"
+ */
+ this.children = [];
+
+ /**
+ * Get the fragment parent. Should always be null.
+ * @type Object
+ * @default null
+ * @example
+ */
+ this.parent = null;
+
+ /** @private */
+ this._ =
+ {
+ isBlockLike : true,
+ hasInlineStarted : false
+ };
+};
+
+(function()
+{
+ // Elements which the end tag is marked as optional in the HTML 4.01 DTD
+ // (expect empty elements).
+ var optionalClose = {colgroup:1,dd:1,dt:1,li:1,option:1,p:1,td:1,tfoot:1,th:1,thead:1,tr:1};
+
+ // Block-level elements whose internal structure should be respected during
+ // parser fixing.
+ var nonBreakingBlocks = CKEDITOR.tools.extend(
+ {table:1,ul:1,ol:1,dl:1},
+ CKEDITOR.dtd.table, CKEDITOR.dtd.ul, CKEDITOR.dtd.ol, CKEDITOR.dtd.dl );
+
+ /**
+ * Creates a {@link CKEDITOR.htmlParser.fragment} from an HTML string.
+ * @param {String} fragmentHtml The HTML to be parsed, filling the fragment.
+ * @param {Number} [fixForBody=false] Wrap body with specified element if needed.
+ * @returns CKEDITOR.htmlParser.fragment The fragment created.
+ * @example
+ * var fragment = CKEDITOR.htmlParser.fragment.fromHtml( 'Sample Text' );
+ * alert( fragment.children[0].name ); "b"
+ * alert( fragment.children[1].value ); " Text"
+ */
+ CKEDITOR.htmlParser.fragment.fromHtml = function( fragmentHtml, fixForBody )
+ {
+ var parser = new CKEDITOR.htmlParser(),
+ html = [],
+ fragment = new CKEDITOR.htmlParser.fragment(),
+ pendingInline = [],
+ currentNode = fragment,
+ // Indicate we're inside a
element, spaces should be touched differently.
+ inPre = false,
+ returnPoint;
+
+ function checkPending( newTagName )
+ {
+ if ( pendingInline.length > 0 )
+ {
+ for ( var i = 0 ; i < pendingInline.length ; i++ )
+ {
+ var pendingElement = pendingInline[ i ],
+ pendingName = pendingElement.name,
+ pendingDtd = CKEDITOR.dtd[ pendingName ],
+ currentDtd = currentNode.name && CKEDITOR.dtd[ currentNode.name ];
+
+ if ( ( !currentDtd || currentDtd[ pendingName ] ) && ( !newTagName || !pendingDtd || pendingDtd[ newTagName ] || !CKEDITOR.dtd[ newTagName ] ) )
+ {
+ // Get a clone for the pending element.
+ pendingElement = pendingElement.clone();
+
+ // Add it to the current node and make it the current,
+ // so the new element will be added inside of it.
+ pendingElement.parent = currentNode;
+ currentNode = pendingElement;
+
+ // Remove the pending element (back the index by one
+ // to properly process the next entry).
+ pendingInline.splice( i, 1 );
+ i--;
+ }
+ }
+ }
+ }
+
+ function addElement( element, target, enforceCurrent )
+ {
+ target = target || currentNode || fragment;
+
+ // If the target is the fragment and this element can't go inside
+ // body (if fixForBody).
+ if ( fixForBody && !target.type && !CKEDITOR.dtd.$body[ element.name ] )
+ {
+ var savedCurrent = currentNode;
+
+ // Create a
in the fragment.
+ currentNode = target;
+ parser.onTagOpen( fixForBody, {} );
+
+ // The new target now is the
.
+ target = currentNode;
+
+ if ( enforceCurrent )
+ currentNode = savedCurrent;
+ }
+
+ // Rtrim empty spaces on block end boundary. (#3585)
+ if ( element._.isBlockLike
+ && !inPre )
+ {
+
+ var length = element.children.length,
+ lastChild = element.children[ length - 1 ],
+ text;
+ if ( lastChild && lastChild.type == CKEDITOR.NODE_TEXT )
+ {
+ if ( !( text = CKEDITOR.tools.rtrim( lastChild.value ) ) )
+ element.children.length = length -1;
+ else
+ lastChild.value = text;
+ }
+ }
+
+ target.add( element );
+
+ if ( element.returnPoint )
+ {
+ currentNode = element.returnPoint;
+ delete element.returnPoint;
+ }
+ }
+
+ parser.onTagOpen = function( tagName, attributes, selfClosing )
+ {
+ var element = new CKEDITOR.htmlParser.element( tagName, attributes );
+
+ // "isEmpty" will be always "false" for unknown elements, so we
+ // must force it if the parser has identified it as a selfClosing tag.
+ if ( element.isUnknown && selfClosing )
+ element.isEmpty = true;
+
+ // This is a tag to be removed if empty, so do not add it immediately.
+ if ( CKEDITOR.dtd.$removeEmpty[ tagName ] )
+ {
+ pendingInline.push( element );
+ return;
+ }
+ else if ( tagName == 'pre' )
+ inPre = true;
+ else if ( tagName == 'br' && inPre )
+ {
+ currentNode.add( new CKEDITOR.htmlParser.text( '\n' ) );
+ return;
+ }
+
+ var currentName = currentNode.name,
+ currentDtd = ( currentName && CKEDITOR.dtd[ currentName ] ) || ( currentNode._.isBlockLike ? CKEDITOR.dtd.div : CKEDITOR.dtd.span );
+
+ // If the element cannot be child of the current element.
+ if ( !element.isUnknown && !currentNode.isUnknown && !currentDtd[ tagName ] )
+ {
+ // If this is the fragment node, just ignore this tag and add
+ // its children.
+ if ( !currentName )
+ return;
+
+ var reApply = false;
+
+ // If the element name is the same as the current element name,
+ // then just close the current one and append the new one to the
+ // parent. This situation usually happens with
,
,
and
+ //
, specially in IE. Do not enter in this if block in this case.
+ if ( tagName == currentName )
+ {
+ addElement( currentNode, currentNode.parent );
+ }
+ else
+ {
+ if ( nonBreakingBlocks[ currentName ] )
+ {
+ if ( !returnPoint )
+ returnPoint = currentNode;
+ }
+ else
+ {
+ addElement( currentNode, currentNode.parent, true );
+
+ if ( !optionalClose[ currentName ] )
+ {
+ // The current element is an inline element, which
+ // cannot hold the new one. Put it in the pending list,
+ // and try adding the new one after it.
+ pendingInline.unshift( currentNode );
+ }
+ }
+
+ reApply = true;
+ }
+
+ // In any of the above cases, we'll be adding, or trying to
+ // add it to the parent.
+ currentNode = currentNode.returnPoint || currentNode.parent;
+
+ if ( reApply )
+ {
+ parser.onTagOpen.apply( this, arguments );
+ return;
+ }
+ }
+
+ checkPending( tagName );
+
+ element.parent = currentNode;
+ element.returnPoint = returnPoint;
+ returnPoint = 0;
+
+ if ( element.isEmpty )
+ addElement( element );
+ else
+ currentNode = element;
+ };
+
+ parser.onTagClose = function( tagName )
+ {
+ var index = 0,
+ pendingAdd = [],
+ candidate = currentNode;
+
+ while ( candidate.type && candidate.name != tagName )
+ {
+ // If this is an inline element, add it to the pending list, so
+ // it will continue after the closing tag.
+ if ( !candidate._.isBlockLike )
+ {
+ pendingInline.unshift( candidate );
+
+ // Increase the index, so it will not get checked again in
+ // the pending list check that follows.
+ index++;
+ }
+
+ // This node should be added to it's parent at this point. But,
+ // it should happen only if the closing tag is really closing
+ // one of the nodes. So, for now, we just cache it.
+ pendingAdd.push( candidate );
+
+ candidate = candidate.parent;
+ }
+
+ if ( candidate.type )
+ {
+ // Add all elements that have been found in the above loop.
+ for ( var i = 0 ; i < pendingAdd.length ; i++ )
+ {
+ var node = pendingAdd[ i ];
+ addElement( node, node.parent );
+ }
+
+ currentNode = candidate;
+
+ if( currentNode.name == 'pre' )
+ inPre = false;
+
+ addElement( candidate, candidate.parent );
+
+ // The parent should start receiving new nodes now, except if
+ // addElement changed the currentNode.
+ if ( candidate == currentNode )
+ currentNode = currentNode.parent;
+ }
+
+ // Check if there is any pending tag to be closed.
+ for ( ; index < pendingInline.length ; index++ )
+ {
+ // If found, just remove it from the list.
+ if ( tagName == pendingInline[ index ].name )
+ {
+ pendingInline.splice( index, 1 );
+
+ // Decrease the index so we continue from the next one.
+ index--;
+ }
+ }
+ };
+
+ parser.onText = function( text )
+ {
+ // Trim empty spaces at beginning of element contents except
.
+ if ( !currentNode._.hasInlineStarted && !inPre )
+ {
+ text = CKEDITOR.tools.ltrim( text );
+
+ if ( text.length === 0 )
+ return;
+ }
+
+ checkPending();
+
+ if ( fixForBody && !currentNode.type )
+ this.onTagOpen( fixForBody, {} );
+
+ // Shrinking consequential spaces into one single for all elements
+ // text contents.
+ if ( !inPre )
+ text = text.replace( /[\t\r\n ]{2,}|[\t\r\n]/g, ' ' );
+
+ currentNode.add( new CKEDITOR.htmlParser.text( text ) );
+ };
+
+ parser.onCDATA = function( cdata )
+ {
+ currentNode.add( new CKEDITOR.htmlParser.cdata( cdata ) );
+ };
+
+ parser.onComment = function( comment )
+ {
+ currentNode.add( new CKEDITOR.htmlParser.comment( comment ) );
+ };
+
+ // Parse it.
+ parser.parse( fragmentHtml );
+
+ // Close all pending nodes.
+ while ( currentNode.type )
+ {
+ var parent = currentNode.parent,
+ node = currentNode;
+
+ if ( fixForBody && !parent.type && !CKEDITOR.dtd.$body[ node.name ] )
+ {
+ currentNode = parent;
+ parser.onTagOpen( fixForBody, {} );
+ parent = currentNode;
+ }
+
+ parent.add( node );
+ currentNode = parent;
+ }
+
+ return fragment;
+ };
+
+ CKEDITOR.htmlParser.fragment.prototype =
+ {
+ /**
+ * Adds a node to this fragment.
+ * @param {Object} node The node to be added. It can be any of of the
+ * following types: {@link CKEDITOR.htmlParser.element},
+ * {@link CKEDITOR.htmlParser.text} and
+ * {@link CKEDITOR.htmlParser.comment}.
+ * @example
+ */
+ add : function( node )
+ {
+ var len = this.children.length,
+ previous = len > 0 && this.children[ len - 1 ] || null;
+
+ if ( previous )
+ {
+ // If the block to be appended is following text, trim spaces at
+ // the right of it.
+ if ( node._.isBlockLike && previous.type == CKEDITOR.NODE_TEXT )
+ {
+ previous.value = CKEDITOR.tools.rtrim( previous.value );
+
+ // If we have completely cleared the previous node.
+ if ( previous.value.length === 0 )
+ {
+ // Remove it from the list and add the node again.
+ this.children.pop();
+ this.add( node );
+ return;
+ }
+ }
+
+ previous.next = node;
+ }
+
+ node.previous = previous;
+ node.parent = this;
+
+ this.children.push( node );
+
+ this._.hasInlineStarted = node.type == CKEDITOR.NODE_TEXT || ( node.type == CKEDITOR.NODE_ELEMENT && !node._.isBlockLike );
+ },
+
+ /**
+ * Writes the fragment HTML to a CKEDITOR.htmlWriter.
+ * @param {CKEDITOR.htmlWriter} writer The writer to which write the HTML.
+ * @example
+ * var writer = new CKEDITOR.htmlWriter();
+ * var fragment = CKEDITOR.htmlParser.fragment.fromHtml( '<P><B>Example' );
+ * fragment.writeHtml( writer )
+ * alert( writer.getHtml() ); "<p><b>Example</b></p>"
+ */
+ writeHtml : function( writer, filter )
+ {
+ for ( var i = 0, len = this.children.length ; i < len ; i++ )
+ this.children[i].writeHtml( writer, filter );
+ }
+ };
+})();
Index: /CKEditor/branches/versions/3.0.x/_source/core/htmlparser/text.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/htmlparser/text.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/htmlparser/text.js (revision 3751)
@@ -0,0 +1,55 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+(function()
+{
+ var spacesRegex = /[\t\r\n ]{2,}|[\t\r\n]/g;
+
+ /**
+ * A lightweight representation of HTML text.
+ * @constructor
+ * @example
+ */
+ CKEDITOR.htmlParser.text = function( value )
+ {
+ /**
+ * The text value.
+ * @type String
+ * @example
+ */
+ this.value = value;
+
+ /** @private */
+ this._ =
+ {
+ isBlockLike : false
+ };
+ };
+
+ CKEDITOR.htmlParser.text.prototype =
+ {
+ /**
+ * The node type. This is a constant value set to {@link CKEDITOR.NODE_TEXT}.
+ * @type Number
+ * @example
+ */
+ type : CKEDITOR.NODE_TEXT,
+
+ /**
+ * Writes the HTML representation of this text to a CKEDITOR.htmlWriter.
+ * @param {CKEDITOR.htmlWriter} writer The writer to which write the HTML.
+ * @example
+ */
+ writeHtml : function( writer, filter )
+ {
+ var text = this.value;
+
+ if ( filter && !( text = filter.onText( text, this ) ) )
+ return;
+
+ writer.text( text );
+ }
+ };
+})();
Index: /CKEditor/branches/versions/3.0.x/_source/core/imagecacher.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/imagecacher.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/imagecacher.js (revision 3751)
@@ -0,0 +1,58 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+(function()
+{
+ var loaded = {};
+
+ var loadImage = function( image, callback )
+ {
+ var doCallback = function()
+ {
+ loaded[ image ] = 1;
+ callback();
+ };
+
+ var img = new CKEDITOR.dom.element( 'img' );
+ img.on( 'load', doCallback );
+ img.on( 'error', doCallback );
+ img.setAttribute( 'src', image );
+ };
+
+ /**
+ * Load images into the browser cache.
+ * @namespace
+ * @example
+ */
+ CKEDITOR.imageCacher =
+ {
+ /**
+ * Loads one or more images.
+ * @param {Array} images The URLs for the images to be loaded.
+ * @param {Function} callback The function to be called once all images
+ * are loaded.
+ */
+ load : function( images, callback )
+ {
+ var pendingCount = images.length;
+
+ var checkPending = function()
+ {
+ if ( --pendingCount === 0 )
+ callback();
+ };
+
+ for ( var i = 0 ; i < images.length ; i++ )
+ {
+ var image = images[ i ];
+
+ if ( loaded[ image ] )
+ checkPending();
+ else
+ loadImage( image, checkPending );
+ }
+ }
+ };
+})();
Index: /CKEditor/branches/versions/3.0.x/_source/core/lang.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/lang.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/lang.js (revision 3751)
@@ -0,0 +1,148 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+(function()
+{
+ var loadedLangs = {};
+
+ CKEDITOR.lang =
+ {
+ /**
+ * The list of languages available in the editor core.
+ * @type Object
+ * @example
+ * alert( CKEDITOR.lang.en ); // "true"
+ */
+ languages :
+ {
+ 'af' : 1,
+ 'ar' : 1,
+ 'bg' : 1,
+ 'bn' : 1,
+ 'bs' : 1,
+ 'ca' : 1,
+ 'cs' : 1,
+ 'da' : 1,
+ 'de' : 1,
+ 'el' : 1,
+ 'en-au' : 1,
+ 'en-ca' : 1,
+ 'en-uk' : 1,
+ 'en' : 1,
+ 'eo' : 1,
+ 'es' : 1,
+ 'et' : 1,
+ 'eu' : 1,
+ 'fa' : 1,
+ 'fi' : 1,
+ 'fo' : 1,
+ 'fr-ca' : 1,
+ 'fr' : 1,
+ 'gl' : 1,
+ 'gu' : 1,
+ 'he' : 1,
+ 'hi' : 1,
+ 'hr' : 1,
+ 'hu' : 1,
+ 'is' : 1,
+ 'it' : 1,
+ 'ja' : 1,
+ 'km' : 1,
+ 'ko' : 1,
+ 'lt' : 1,
+ 'lv' : 1,
+ 'mn' : 1,
+ 'ms' : 1,
+ 'nb' : 1,
+ 'nl' : 1,
+ 'no' : 1,
+ 'pl' : 1,
+ 'pt-br' : 1,
+ 'pt' : 1,
+ 'ro' : 1,
+ 'ru' : 1,
+ 'sk' : 1,
+ 'sl' : 1,
+ 'sr-latn' : 1,
+ 'sr' : 1,
+ 'sv' : 1,
+ 'th' : 1,
+ 'tr' : 1,
+ 'uk' : 1,
+ 'vi' : 1,
+ 'zh-cn' : 1,
+ 'zh' : 1
+ },
+
+ /**
+ * Loads a specific language file, or auto detect it. A callback is
+ * then called when the file gets loaded.
+ * @param {String} languageCode The code of the language file to be
+ * loaded. If "autoDetect" is set to true, this language will be
+ * used as the default one, if the detect language is not
+ * available in the core.
+ * @param {Boolean} autoDetect Indicates that the function must try to
+ * detect the user language and load it instead.
+ * @param {Function} callback The function to be called once the
+ * language file is loaded. Two parameters are passed to this
+ * function: the language code and the loaded language entries.
+ * @example
+ */
+ load : function( languageCode, defaultLanguage, callback )
+ {
+ if ( !languageCode )
+ languageCode = this.detect( defaultLanguage );
+
+ if ( !this[ languageCode ] )
+ {
+ CKEDITOR.scriptLoader.load( CKEDITOR.getUrl(
+ '_source/' + // %REMOVE_LINE%
+ 'lang/' + languageCode + '.js' ),
+ function()
+ {
+ callback( languageCode, this[ languageCode ] );
+ }
+ , this );
+ }
+ else
+ callback( languageCode, this[ languageCode ] );
+ },
+
+ /**
+ * Returns the language that best fit the user language. For example,
+ * suppose that the user language is "pt-br". If this language is
+ * supported by the editor, it is returned. Otherwise, if only "pt" is
+ * supported, it is returned instead. If none of the previous are
+ * supported, a default language is then returned.
+ * @param {String} defaultLanguage The default language to be returned
+ * if the user language is not supported.
+ * @returns {String} The detected language code.
+ * @example
+ * alert( CKEDITOR.lang.detect( 'en' ) ); // e.g., in a German browser: "de"
+ */
+ detect : function( defaultLanguage )
+ {
+ var languages = this.languages;
+
+ var parts = ( navigator.userLanguage || navigator.language )
+ .toLowerCase()
+ .match( /([a-z]+)(?:-([a-z]+))?/ ),
+ lang = parts[1],
+ locale = parts[2];
+
+ if ( languages[ lang + '-' + locale ] )
+ lang = lang + '-' + locale;
+ else if ( !languages[ lang ] )
+ lang = null;
+
+ CKEDITOR.lang.detect = lang ?
+ function() { return lang; } :
+ function( defaultLanguage ) { return defaultLanguage; };
+
+ return lang || defaultLanguage;
+ }
+ };
+
+})();
Index: /CKEditor/branches/versions/3.0.x/_source/core/loader.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/core/loader.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/core/loader.js (revision 3751)
@@ -0,0 +1,190 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @fileOverview Defines the {@link CKEDITOR.loader} objects, which is used to
+ * load core scripts and their dependencies from _source.
+ */
+
+if ( typeof CKEDITOR == 'undefined' )
+ CKEDITOR = {};
+
+if ( !CKEDITOR.loader )
+{
+ /**
+ * Load core scripts and their dependencies from _source.
+ * @namespace
+ * @example
+ */
+ CKEDITOR.loader = (function()
+ {
+ // Table of script names and their dependencies.
+ var scripts =
+ {
+ 'core/_bootstrap' : [ 'core/config', 'core/ckeditor', 'core/plugins', 'core/scriptloader', 'core/tools', /* The following are entries that we want to force loading at the end to avoid dependence recursion */ 'core/dom/elementpath', 'core/dom/text', 'core/dom/range' ],
+ 'core/ajax' : [ 'core/xml' ],
+ 'core/ckeditor' : [ 'core/ckeditor_basic', 'core/dom', 'core/dtd', 'core/dom/document', 'core/dom/element', 'core/editor', 'core/event', 'core/htmlparser', 'core/htmlparser/element', 'core/htmlparser/fragment', 'core/htmlparser/filter', 'core/htmlparser/basicwriter', 'core/tools' ],
+ 'core/ckeditor_base' : [],
+ 'core/ckeditor_basic' : [ 'core/editor_basic', 'core/env', 'core/event' ],
+ 'core/command' : [],
+ 'core/config' : [ 'core/ckeditor_base' ],
+ 'core/dom' : [],
+ 'core/dom/document' : [ 'core/dom', 'core/dom/domobject', 'core/dom/window' ],
+ 'core/dom/documentfragment' : [ 'core/dom/element' ],
+ 'core/dom/element' : [ 'core/dom', 'core/dom/document', 'core/dom/domobject', 'core/dom/node', 'core/dom/nodelist', 'core/tools' ],
+ 'core/dom/elementpath' : [ 'core/dom/element' ],
+ 'core/dom/event' : [],
+ 'core/dom/node' : [ 'core/dom/domobject', 'core/tools' ],
+ 'core/dom/nodelist' : [ 'core/dom/node' ],
+ 'core/dom/domobject' : [ 'core/dom/event' ],
+ 'core/dom/domwalker' : [ 'core/dom/node', 'core/dom/element', 'core/dom/document' ],
+ 'core/dom/range' : [ 'core/dom/document', 'core/dom/documentfragment', 'core/dom/element', 'core/dom/domwalker', 'core/dom/walker' ],
+ 'core/dom/text' : [ 'core/dom/node', 'core/dom/domobject' ],
+ 'core/dom/walker' : [ 'core/dom/node' ],
+ 'core/dom/window' : [ 'core/dom/domobject' ],
+ 'core/dtd' : [ 'core/tools' ],
+ 'core/editor' : [ 'core/command', 'core/config', 'core/editor_basic', 'core/focusmanager', 'core/lang', 'core/plugins', 'core/skins', 'core/themes', 'core/tools', 'core/ui' ],
+ 'core/editor_basic' : [ 'core/event' ],
+ 'core/env' : [],
+ 'core/event' : [],
+ 'core/focusmanager' : [],
+ 'core/htmlparser' : [],
+ 'core/htmlparser/comment' : [ 'core/htmlparser' ],
+ 'core/htmlparser/element' : [ 'core/htmlparser', 'core/htmlparser/fragment' ],
+ 'core/htmlparser/fragment' : [ 'core/htmlparser', 'core/htmlparser/comment', 'core/htmlparser/text', 'core/htmlparser/cdata' ],
+ 'core/htmlparser/text' : [ 'core/htmlparser' ],
+ 'core/htmlparser/cdata' : [ 'core/htmlparser' ],
+ 'core/htmlparser/filter' : [ 'core/htmlparser' ],
+ 'core/htmlparser/basicwriter': [ 'core/htmlparser' ],
+ 'core/imagecacher' : [ 'core/dom/element' ],
+ 'core/lang' : [],
+ 'core/plugins' : [ 'core/resourcemanager' ],
+ 'core/resourcemanager' : [ 'core/scriptloader', 'core/tools' ],
+ 'core/scriptloader' : [ 'core/dom/element', 'core/env' ],
+ 'core/skins' : [ 'core/imagecacher', 'core/scriptloader' ],
+ 'core/themes' : [ 'core/resourcemanager' ],
+ 'core/tools' : [ 'core/env' ],
+ 'core/ui' : [],
+ 'core/xml' : [ 'core/env' ]
+ };
+
+ var basePath = (function()
+ {
+ // This is a copy of CKEDITOR.basePath, but requires the script having
+ // "_source/core/loader.js".
+ if ( CKEDITOR && CKEDITOR.basePath )
+ return CKEDITOR.basePath;
+
+ // Find out the editor directory path, based on its ',
+
+ onShow : function()
+ {
+ if ( CKEDITOR.env.ie )
+ this.getParentEditor().document.getBody().$.contentEditable = 'false';
+
+ // FIREFOX BUG: Force the browser to render the dialog to make the to-be-
+ // inserted iframe editable. (#3366)
+ this.parts.dialog.$.offsetHeight;
+
+ var container = this.getContentElement( 'general', 'editing_area' ).getElement(),
+ iframe = CKEDITOR.dom.element.createFromHtml( '' );
+
+ var lang = this.getParentEditor().lang;
+
+ iframe.setStyles(
+ {
+ width : '346px',
+ height : '130px',
+ 'background-color' : 'white',
+ border : '1px solid black'
+ } );
+ iframe.setCustomData( 'dialog', this );
+
+ var accTitle = lang.editorTitle.replace( '%1', lang.clipboard.title );
+
+ if ( CKEDITOR.env.ie )
+ container.setHtml( '' );
+ else
+ {
+ container.setHtml( '' );
+ container.setAttributes(
+ {
+ role : 'region',
+ title : accTitle
+ } );
+ iframe.setAttributes(
+ {
+ role : 'region',
+ title : ' '
+ } );
+ }
+ container.append( iframe );
+ if ( CKEDITOR.env.ie )
+ container.setStyle( 'height', ( iframe.$.offsetHeight + 2 ) + 'px' );
+
+ if ( isCustomDomain )
+ {
+ CKEDITOR._cke_htmlToLoad = this.definition.htmlToLoad;
+ iframe.setAttribute( 'src',
+ 'javascript:void( (function(){' +
+ 'document.open();' +
+ 'document.domain="' + document.domain + '";' +
+ 'document.write( window.parent.CKEDITOR._cke_htmlToLoad );' +
+ 'delete window.parent.CKEDITOR._cke_htmlToLoad;' +
+ 'document.close();' +
+ '})() )' );
+ }
+ else
+ {
+ var doc = iframe.$.contentWindow.document;
+ doc.open();
+ doc.write( this.definition.htmlToLoad );
+ doc.close();
+ }
+ },
+
+ onHide : function()
+ {
+ if ( CKEDITOR.env.ie )
+ this.getParentEditor().document.getBody().$.contentEditable = 'true';
+ },
+
+ onOk : function()
+ {
+ var container = this.getContentElement( 'general', 'editing_area' ).getElement(),
+ iframe = container.getElementsByTag( 'iframe' ).getItem( 0 ),
+ editor = this.getParentEditor(),
+ html = iframe.$.contentWindow.document.body.innerHTML;
+
+ editor.insertHtml( html );
+
+ },
+
+ contents : [
+ {
+ id : 'general',
+ label : editor.lang.common.generalTab,
+ elements : [
+ {
+ type : 'html',
+ id : 'securityMsg',
+ html : '
' + editor.lang.clipboard.securityMsg + '
'
+ },
+ {
+ type : 'html',
+ id : 'pasteMsg',
+ html : '
'+editor.lang.clipboard.pasteMsg +'
'
+ },
+ {
+ type : 'html',
+ id : 'editing_area',
+ style : 'width: 100%; height: 100%;',
+ html : '
',
+ focus : function()
+ {
+ var div = this.getElement();
+ var iframe = div.getElementsByTag( 'iframe' );
+ if ( iframe.count() < 1 )
+ return;
+ iframe = iframe.getItem( 0 );
+
+ // #3291 : JAWS needs the 500ms delay to detect that the editor iframe
+ // iframe is no longer editable. So that it will put the focus into the
+ // Paste from Word dialog's editable area instead.
+ setTimeout( function()
+ {
+ iframe.$.contentWindow.focus();
+ }, 500 );
+ }
+ }
+ ]
+ }
+ ]
+ };
+});
Index: /CKEditor/branches/versions/3.0.x/_source/plugins/clipboard/plugin.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/plugins/clipboard/plugin.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/plugins/clipboard/plugin.js (revision 3751)
@@ -0,0 +1,208 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @file Clipboard support
+ */
+
+(function()
+{
+ // Tries to execute any of the paste, cut or copy commands in IE. Returns a
+ // boolean indicating that the operation succeeded.
+ var execIECommand = function( editor, command )
+ {
+ var doc = editor.document,
+ body = doc.getBody();
+
+ var enabled = false;
+ var onExec = function()
+ {
+ enabled = true;
+ };
+
+ // The following seems to be the only reliable way to detect that
+ // clipboard commands are enabled in IE. It will fire the
+ // onpaste/oncut/oncopy events only if the security settings allowed
+ // the command to execute.
+ body.on( command, onExec );
+
+ doc.$.execCommand( command );
+
+ body.removeListener( command, onExec );
+
+ return enabled;
+ };
+
+ // Attempts to execute the Cut and Copy operations.
+ var tryToCutCopy =
+ CKEDITOR.env.ie ?
+ function( editor, type )
+ {
+ return execIECommand( editor, type );
+ }
+ : // !IE.
+ function( editor, type )
+ {
+ try
+ {
+ // Other browsers throw an error if the command is disabled.
+ return editor.document.$.execCommand( type );
+ }
+ catch( e )
+ {
+ return false;
+ }
+ };
+
+ // A class that represents one of the cut or copy commands.
+ var cutCopyCmd = function( type )
+ {
+ this.type = type;
+ this.canUndo = ( this.type == 'cut' ); // We can't undo copy to clipboard.
+ };
+
+ cutCopyCmd.prototype =
+ {
+ exec : function( editor, data )
+ {
+ var success = tryToCutCopy( editor, this.type );
+
+ if ( !success )
+ alert( editor.lang.clipboard[ this.type + 'Error' ] ); // Show cutError or copyError.
+
+ return success;
+ }
+ };
+
+ // Paste command.
+ var pasteCmd =
+ CKEDITOR.env.ie ?
+ {
+ exec : function( editor, data )
+ {
+ // Prevent IE from pasting at the begining of the document.
+ editor.focus();
+
+ if ( !editor.fire( 'beforePaste' )
+ && !execIECommand( editor, 'paste' ) )
+ {
+ editor.openDialog( 'paste' );
+ }
+ }
+ }
+ :
+ {
+ exec : function( editor )
+ {
+ try
+ {
+ if ( !editor.fire( 'beforePaste' )
+ && !editor.document.$.execCommand( 'Paste', false, null ) )
+ {
+ throw 0;
+ }
+ }
+ catch ( e )
+ {
+ // Open the paste dialog.
+ editor.openDialog( 'paste' );
+ }
+ }
+ };
+
+ // Listens for some clipboard related keystrokes, so they get customized.
+ var onKey = function( event )
+ {
+ switch ( event.data.keyCode )
+ {
+ // Paste
+ case CKEDITOR.CTRL + 86 : // CTRL+V
+ case CKEDITOR.SHIFT + 45 : // SHIFT+INS
+
+ var editor = this;
+ editor.fire( 'saveSnapshot' ); // Save before paste
+
+ if ( editor.fire( 'beforePaste' ) )
+ event.cancel();
+
+ setTimeout( function()
+ {
+ editor.fire( 'saveSnapshot' ); // Save after paste
+ }, 0 );
+ return;
+
+ // Cut
+ case CKEDITOR.CTRL + 88 : // CTRL+X
+ case CKEDITOR.SHIFT + 46 : // SHIFT+DEL
+
+ // Save Undo snapshot.
+ editor = this;
+ editor.fire( 'saveSnapshot' ); // Save before paste
+ setTimeout( function()
+ {
+ editor.fire( 'saveSnapshot' ); // Save after paste
+ }, 0 );
+ }
+ };
+
+ // Register the plugin.
+ CKEDITOR.plugins.add( 'clipboard',
+ {
+ init : function( editor )
+ {
+ function addButtonCommand( buttonName, commandName, command, ctxMenuOrder )
+ {
+ var lang = editor.lang[ commandName ];
+
+ editor.addCommand( commandName, command );
+ editor.ui.addButton( buttonName,
+ {
+ label : lang,
+ command : commandName
+ });
+
+ // If the "menu" plugin is loaded, register the menu item.
+ if ( editor.addMenuItems )
+ {
+ editor.addMenuItem( commandName,
+ {
+ label : lang,
+ command : commandName,
+ group : 'clipboard',
+ order : ctxMenuOrder
+ });
+ }
+ }
+
+ addButtonCommand( 'Cut', 'cut', new cutCopyCmd( 'cut' ), 1 );
+ addButtonCommand( 'Copy', 'copy', new cutCopyCmd( 'copy' ), 4 );
+ addButtonCommand( 'Paste', 'paste', pasteCmd, 8 );
+
+ CKEDITOR.dialog.add( 'paste', CKEDITOR.getUrl( this.path + 'dialogs/paste.js' ) );
+
+ editor.on( 'key', onKey, editor );
+
+ // If the "contextmenu" plugin is loaded, register the listeners.
+ if ( editor.contextMenu )
+ {
+ function stateFromNamedCommand( command )
+ {
+ return editor.document.$.queryCommandEnabled( command ) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED;
+ }
+
+ editor.contextMenu.addListener( function()
+ {
+ return {
+ cut : stateFromNamedCommand( 'Cut' ),
+
+ // Browser bug: 'Cut' has the correct states for both Copy and Cut.
+ copy : stateFromNamedCommand( 'Cut' ),
+ paste : CKEDITOR.env.webkit ? CKEDITOR.TRISTATE_OFF : stateFromNamedCommand( 'Paste' )
+ };
+ });
+ }
+ }
+ });
+})();
Index: /CKEditor/branches/versions/3.0.x/_source/plugins/colorbutton/plugin.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/plugins/colorbutton/plugin.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/plugins/colorbutton/plugin.js (revision 3751)
@@ -0,0 +1,161 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+CKEDITOR.plugins.add( 'colorbutton',
+{
+ requires : [ 'panelbutton', 'floatpanel', 'styles' ],
+
+ init : function( editor )
+ {
+ var config = editor.config,
+ lang = editor.lang.colorButton;
+
+ var clickFn;
+
+ if ( !CKEDITOR.env.hc )
+ {
+ addButton( 'TextColor', 'fore', lang.textColorTitle );
+ addButton( 'BGColor', 'back', lang.bgColorTitle );
+ }
+
+ function addButton( name, type, title )
+ {
+ editor.ui.add( name, CKEDITOR.UI_PANELBUTTON,
+ {
+ label : title,
+ title : title,
+ className : 'cke_button_' + name.toLowerCase(),
+
+ panel :
+ {
+ css : [ CKEDITOR.getUrl( editor.skinPath + 'editor.css' ) ]
+ },
+
+ onBlock : function( panel, blockName )
+ {
+ var block = panel.addBlock( blockName );
+ block.autoSize = true;
+ block.element.addClass( 'cke_colorblock' );
+ block.element.setHtml( renderColors( panel, type ) );
+
+ var keys = block.keys;
+ keys[ 39 ] = 'next'; // ARROW-RIGHT
+ keys[ 9 ] = 'next'; // TAB
+ keys[ 37 ] = 'prev'; // ARROW-LEFT
+ keys[ CKEDITOR.SHIFT + 9 ] = 'prev'; // SHIFT + TAB
+ keys[ 32 ] = 'click'; // SPACE
+ }
+ });
+ }
+
+
+ function renderColors( panel, type )
+ {
+ var output = [],
+ colors = CKEDITOR.config.colorButton_colors.split( ',' );
+
+ var clickFn = CKEDITOR.tools.addFunction( function( color, type )
+ {
+ if ( color == '?' )
+ {
+ // TODO : Implement the colors dialog.
+ // editor.openDialog( '' );
+ return;
+ }
+
+ editor.focus();
+
+ panel.hide();
+
+ var style = new CKEDITOR.style( config['colorButton_' + type + 'Style'], color && { color : color } );
+
+ editor.fire( 'saveSnapshot' );
+ if ( color )
+ style.apply( editor.document );
+ else
+ style.remove( editor.document );
+ });
+
+ // Render the "Automatic" button.
+ output.push(
+ '' +
+ '
' +
+ '
' +
+ '
' +
+ '' +
+ '
' +
+ '
',
+ lang.auto,
+ '
' +
+ '
' +
+ '
' +
+ '' +
+ '
' );
+
+ // Render the color boxes.
+ for ( var i = 0 ; i < colors.length ; i++ )
+ {
+ if ( ( i % 8 ) === 0 )
+ output.push( '
' );
+
+ var colorCode = colors[ i ];
+ var colorLabel = editor.lang.colors[ colorCode ] || colorCode;
+ output.push(
+ '
id (Required) The id of the UI element. See {@link
+ * CKEDITOR.dialog#getContentElement}
+ *
type (Required) The type of the UI element. The
+ * value to this field specifies which UI element class will be used to
+ * generate the final widget.
+ *
title (Optional) The popup tooltip for the UI
+ * element.
+ *
hidden (Optional) A flag that tells if the element
+ * should be initially visible.
+ *
className (Optional) Additional CSS class names
+ * to add to the UI element. Separated by space.
+ *
style (Optional) Additional CSS inline styles
+ * to add to the UI element. A semicolon (;) is required after the last
+ * style declaration.
+ *
accessKey (Optional) The alphanumeric access key
+ * for this element. Access keys are automatically prefixed by CTRL.
+ *
on* (Optional) Any UI element definition field that
+ * starts with on followed immediately by a capital letter and
+ * probably more letters is an event handler. Event handlers may be further
+ * divided into registered event handlers and DOM event handlers. Please
+ * refer to {@link CKEDITOR.ui.dialog.uiElement#registerEvents} and
+ * {@link CKEDITOR.ui.dialog.uiElement#eventProcessors} for more
+ * information.
+ *
+ * @param {Array} htmlList
+ * List of HTML code to be added to the dialog's content area.
+ * @param {Function|String} nodeNameArg
+ * A function returning a string, or a simple string for the node name for
+ * the root DOM node. Default is 'div'.
+ * @param {Function|Object} stylesArg
+ * A function returning an object, or a simple object for CSS styles applied
+ * to the DOM node. Default is empty object.
+ * @param {Function|Object} attributesArg
+ * A fucntion returning an object, or a simple object for attributes applied
+ * to the DOM node. Default is empty object.
+ * @param {Function|String} contentsArg
+ * A function returning a string, or a simple string for the HTML code inside
+ * the root DOM node. Default is empty string.
+ * @example
+ */
+ uiElement : function( dialog, elementDefinition, htmlList, nodeNameArg, stylesArg, attributesArg, contentsArg )
+ {
+ if ( arguments.length < 4 )
+ return;
+
+ var nodeName = ( nodeNameArg.call ? nodeNameArg( elementDefinition ) : nodeNameArg ) || 'div',
+ html = [ '<', nodeName, ' ' ],
+ styles = ( stylesArg && stylesArg.call ? stylesArg( elementDefinition ) : stylesArg ) || {},
+ attributes = ( attributesArg && attributesArg.call ? attributesArg( elementDefinition ) : attributesArg ) || {},
+ innerHTML = ( contentsArg && contentsArg.call ? contentsArg( dialog, elementDefinition ) : contentsArg ) || '',
+ domId = this.domId = attributes.id || CKEDITOR.tools.getNextNumber() + '_uiElement',
+ id = this.id = elementDefinition.id,
+ i;
+
+ // Set the id, a unique id is required for getElement() to work.
+ attributes.id = domId;
+
+ // Set the type and definition CSS class names.
+ var classes = {};
+ if ( elementDefinition.type )
+ classes[ 'cke_dialog_ui_' + elementDefinition.type ] = 1;
+ if ( elementDefinition.className )
+ classes[ elementDefinition.className ] = 1;
+ var attributeClasses = ( attributes['class'] && attributes['class'].split ) ? attributes['class'].split( ' ' ) : [];
+ for ( i = 0 ; i < attributeClasses.length ; i++ )
+ {
+ if ( attributeClasses[i] )
+ classes[ attributeClasses[i] ] = 1;
+ }
+ var finalClasses = [];
+ for ( i in classes )
+ finalClasses.push( i );
+ attributes['class'] = finalClasses.join( ' ' );
+
+ // Set the popup tooltop.
+ if ( elementDefinition.title )
+ attributes.title = elementDefinition.title;
+
+ // Write the inline CSS styles.
+ var styleStr = ( elementDefinition.style || '' ).split( ';' );
+ for ( i in styles )
+ styleStr.push( i + ':' + styles[i] );
+ if ( elementDefinition.hidden )
+ styleStr.push( 'display:none' );
+ for ( i = styleStr.length - 1 ; i >= 0 ; i-- )
+ {
+ if ( styleStr[i] === '' )
+ styleStr.splice( i, 1 );
+ }
+ if ( styleStr.length > 0 )
+ attributes.style = ( attributes.style ? ( attributes.style + '; ' ) : '' ) + styleStr.join( '; ' );
+
+ // Write the attributes.
+ for ( i in attributes )
+ html.push( i + '="' + CKEDITOR.tools.htmlEncode( attributes[i] ) + '" ');
+
+ // Write the content HTML.
+ html.push( '>', innerHTML, '', nodeName, '>' );
+
+ // Add contents to the parent HTML array.
+ htmlList.push( html.join( '' ) );
+
+ ( this._ || ( this._ = {} ) ).dialog = dialog;
+
+ // Override isChanged if it is defined in element definition.
+ if ( typeof( elementDefinition.isChanged ) == 'boolean' )
+ this.isChanged = function(){ return elementDefinition.isChanged; };
+ if ( typeof( elementDefinition.isChanged ) == 'function' )
+ this.isChanged = elementDefinition.isChanged;
+
+ // Add events.
+ CKEDITOR.event.implementOn( this );
+
+ this.registerEvents( elementDefinition );
+ if ( this.accessKeyUp && this.accessKeyDown && elementDefinition.accessKey )
+ registerAccessKey( this, dialog, 'CTRL+' + elementDefinition.accessKey );
+
+ var me = this;
+ dialog.on( 'load', function()
+ {
+ if ( me.getInputElement() )
+ {
+ me.getInputElement().on( 'focus', function()
+ {
+ dialog._.tabBarMode = false;
+ dialog._.hasFocus = true;
+ me.fire( 'focus' );
+ }, me );
+ }
+ } );
+
+ // Register the object as a tab focus if it can be included.
+ if ( this.keyboardFocusable )
+ {
+ this.focusIndex = dialog._.focusList.push( this ) - 1;
+ this.on( 'focus', function()
+ {
+ dialog._.currentFocusIndex = me.focusIndex;
+ } );
+ }
+
+ // Completes this object with everything we have in the
+ // definition.
+ CKEDITOR.tools.extend( this, elementDefinition );
+ },
+
+ /**
+ * Horizontal layout box for dialog UI elements, auto-expends to available width of container.
+ * @constructor
+ * @extends CKEDITOR.ui.dialog.uiElement
+ * @param {CKEDITOR.dialog} dialog
+ * Parent dialog object.
+ * @param {Array} childObjList
+ * Array of {@link CKEDITOR.ui.dialog.uiElement} objects inside this
+ * container.
+ * @param {Array} childHtmlList
+ * Array of HTML code that correspond to the HTML output of all the
+ * objects in childObjList.
+ * @param {Array} htmlList
+ * Array of HTML code that this element will output to.
+ * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition
+ * The element definition. Accepted fields:
+ *
+ *
widths (Optional) The widths of child cells.
+ *
height (Optional) The height of the layout.
+ *
padding (Optional) The padding width inside child
+ * cells.
+ *
align (Optional) The alignment of the whole layout
+ *
' );
+ return html.join( '' );
+ };
+ CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition || { type : 'vbox' }, htmlList, 'div', null, null, innerHTML );
+ }
+ };
+ })();
+
+ CKEDITOR.ui.dialog.uiElement.prototype =
+ {
+ /**
+ * Gets the root DOM element of this dialog UI object.
+ * @returns {CKEDITOR.dom.element} Root DOM element of UI object.
+ * @example
+ * uiElement.getElement().hide();
+ */
+ getElement : function()
+ {
+ return CKEDITOR.document.getById( this.domId );
+ },
+
+ /**
+ * Gets the DOM element that the user inputs values.
+ * This function is used by setValue(), getValue() and focus(). It should
+ * be overrided in child classes where the input element isn't the root
+ * element.
+ * @returns {CKEDITOR.dom.element} The element where the user input values.
+ * @example
+ * var rawValue = textInput.getInputElement().$.value;
+ */
+ getInputElement : function()
+ {
+ return this.getElement();
+ },
+
+ /**
+ * Gets the parent dialog object containing this UI element.
+ * @returns {CKEDITOR.dialog} Parent dialog object.
+ * @example
+ * var dialog = uiElement.getDialog();
+ */
+ getDialog : function()
+ {
+ return this._.dialog;
+ },
+
+ /**
+ * Sets the value of this dialog UI object.
+ * @param {Object} value The new value.
+ * @returns {CKEDITOR.dialog.uiElement} The current UI element.
+ * @example
+ * uiElement.setValue( 'Dingo' );
+ */
+ setValue : function( value )
+ {
+ this.getInputElement().setValue( value );
+ this.fire( 'change', { value : value } );
+ return this;
+ },
+
+ /**
+ * Gets the current value of this dialog UI object.
+ * @returns {Object} The current value.
+ * @example
+ * var myValue = uiElement.getValue();
+ */
+ getValue : function()
+ {
+ return this.getInputElement().getValue();
+ },
+
+ /**
+ * Tells whether the UI object's value has changed.
+ * @returns {Boolean} true if changed, false if not changed.
+ * @example
+ * if ( uiElement.isChanged() )
+ * confirm( 'Value changed! Continue?' );
+ */
+ isChanged : function()
+ {
+ // Override in input classes.
+ return false;
+ },
+
+ /**
+ * Selects the parent tab of this element. Usually called by focus() or overridden focus() methods.
+ * @returns {CKEDITOR.dialog.uiElement} The current UI element.
+ * @example
+ * focus : function()
+ * {
+ * this.selectParentTab();
+ * // do something else.
+ * }
+ */
+ selectParentTab : function()
+ {
+ var element = this.getInputElement(),
+ cursor = element,
+ tabId;
+ while ( ( cursor = cursor.getParent() ) && cursor.$.className.search( 'cke_dialog_page_contents' ) == -1 )
+ { /*jsl:pass*/ }
+
+ // Some widgets don't have parent tabs (e.g. OK and Cancel buttons).
+ if ( !cursor )
+ return this;
+
+ tabId = cursor.getAttribute( 'name' );
+ // Avoid duplicate select.
+ if ( this._.dialog._.currentTabId != tabId )
+ this._.dialog.selectPage( tabId );
+ return this;
+ },
+
+ /**
+ * Puts the focus to the UI object. Switches tabs if the UI object isn't in the active tab page.
+ * @returns {CKEDITOR.dialog.uiElement} The current UI element.
+ * @example
+ * uiElement.focus();
+ */
+ focus : function()
+ {
+ this.selectParentTab().getInputElement().focus();
+ return this;
+ },
+
+ /**
+ * Registers the on* event handlers defined in the element definition.
+ * The default behavior of this function is:
+ *
+ *
+ * If the on* event is defined in the class's eventProcesors list,
+ * then the registration is delegated to the corresponding function
+ * in the eventProcessors list.
+ *
+ *
+ * If the on* event is not defined in the eventProcessors list, then
+ * register the event handler under the corresponding DOM event of
+ * the UI element's input DOM element (as defined by the return value
+ * of {@link CKEDITOR.ui.dialog.uiElement#getInputElement}).
+ *
+ *
+ * This function is only called at UI element instantiation, but can
+ * be overridded in child classes if they require more flexibility.
+ * @param {CKEDITOR.dialog.uiElementDefinition} definition The UI element
+ * definition.
+ * @returns {CKEDITOR.dialog.uiElement} The current UI element.
+ * @example
+ */
+ registerEvents : function( definition )
+ {
+ var regex = /^on([A-Z]\w+)/,
+ match;
+
+ var registerDomEvent = function( uiElement, dialog, eventName, func )
+ {
+ dialog.on( 'load', function()
+ {
+ uiElement.getInputElement().on( eventName, func, uiElement );
+ });
+ };
+
+ for ( var i in definition )
+ {
+ if ( !( match = i.match( regex ) ) )
+ continue;
+ if ( this.eventProcessors[i] )
+ this.eventProcessors[i].call( this, this._.dialog, definition[i] );
+ else
+ registerDomEvent( this, this._.dialog, match[1].toLowerCase(), definition[i] );
+ }
+
+ return this;
+ },
+
+ /**
+ * The event processor list used by
+ * {@link CKEDITOR.ui.dialog.uiElement#getInputElement} at UI element
+ * instantiation. The default list defines three on* events:
+ *
+ *
onLoad - Called when the element's parent dialog opens for the
+ * first time
+ *
onShow - Called whenever the element's parent dialog opens.
+ *
onHide - Called whenever the element's parent dialog closes.
+ *
+ * @field
+ * @type Object
+ * @example
+ * // This connects the 'click' event in CKEDITOR.ui.dialog.button to onClick
+ * // handlers in the UI element's definitions.
+ * CKEDITOR.ui.dialog.button.eventProcessors = CKEDITOR.tools.extend( {},
+ * CKEDITOR.ui.dialog.uiElement.prototype.eventProcessors,
+ * { onClick : function( dialog, func ) { this.on( 'click', func ); } },
+ * true );
+ */
+ eventProcessors :
+ {
+ onLoad : function( dialog, func )
+ {
+ dialog.on( 'load', func, this );
+ },
+
+ onShow : function( dialog, func )
+ {
+ dialog.on( 'show', func, this );
+ },
+
+ onHide : function( dialog, func )
+ {
+ dialog.on( 'hide', func, this );
+ }
+ },
+
+ /**
+ * The default handler for a UI element's access key down event, which
+ * tries to put focus to the UI element.
+ * Can be overridded in child classes for more sophisticaed behavior.
+ * @param {CKEDITOR.dialog} dialog The parent dialog object.
+ * @param {String} key The key combination pressed. Since access keys
+ * are defined to always include the CTRL key, its value should always
+ * include a 'CTRL+' prefix.
+ * @example
+ */
+ accessKeyDown : function( dialog, key )
+ {
+ this.focus();
+ },
+
+ /**
+ * The default handler for a UI element's access key up event, which
+ * does nothing.
+ * Can be overridded in child classes for more sophisticated behavior.
+ * @param {CKEDITOR.dialog} dialog The parent dialog object.
+ * @param {String} key The key combination pressed. Since access keys
+ * are defined to always include the CTRL key, its value should always
+ * include a 'CTRL+' prefix.
+ * @example
+ */
+ accessKeyUp : function( dialog, key )
+ {
+ },
+
+ /**
+ * Disables a UI element.
+ * @example
+ */
+ disable : function()
+ {
+ var element = this.getInputElement();
+ element.setAttribute( 'disabled', 'true' );
+ element.addClass( 'cke_disabled' );
+ },
+
+ /**
+ * Enables a UI element.
+ * @example
+ */
+ enable : function()
+ {
+ var element = this.getInputElement();
+ element.removeAttribute( 'disabled' );
+ element.removeClass( 'cke_disabled' );
+ },
+
+ /**
+ * Determines whether an UI element is enabled or not.
+ * @returns {Boolean} Whether the UI element is enabled.
+ * @example
+ */
+ isEnabled : function()
+ {
+ return !this.getInputElement().getAttribute( 'disabled' );
+ },
+
+ /**
+ * Determines whether an UI element is visible or not.
+ * @returns {Boolean} Whether the UI element is visible.
+ * @example
+ */
+ isVisible : function()
+ {
+ return !!this.getInputElement().$.offsetHeight;
+ },
+
+ /**
+ * Determines whether an UI element is focus-able or not.
+ * Focus-able is defined as being both visible and enabled.
+ * @returns {Boolean} Whether the UI element can be focused.
+ * @example
+ */
+ isFocusable : function()
+ {
+ if ( !this.isEnabled() || !this.isVisible() )
+ return false;
+ return true;
+ }
+ };
+
+ CKEDITOR.ui.dialog.hbox.prototype = CKEDITOR.tools.extend( new CKEDITOR.ui.dialog.uiElement,
+ /**
+ * @lends CKEDITOR.ui.dialog.hbox.prototype
+ */
+ {
+ /**
+ * Gets a child UI element inside this container.
+ * @param {Array|Number} indices An array or a single number to indicate the child's
+ * position in the container's descendant tree. Omit to get all the children in an array.
+ * @returns {Array|CKEDITOR.ui.dialog.uiElement} Array of all UI elements in the container
+ * if no argument given, or the specified UI element if indices is given.
+ * @example
+ * var checkbox = hbox.getChild( [0,1] );
+ * checkbox.setValue( true );
+ */
+ getChild : function( indices )
+ {
+ // If no arguments, return a clone of the children array.
+ if ( arguments.length < 1 )
+ return this._.children.concat();
+
+ // If indices isn't array, make it one.
+ if ( !indices.splice )
+ indices = [ indices ];
+
+ // Retrieve the child element according to tree position.
+ if ( indices.length < 2 )
+ return this._.children[ indices[0] ];
+ else
+ return ( this._.children[ indices[0] ] && this._.children[ indices[0] ].getChild ) ?
+ this._.children[ indices[0] ].getChild( indices.slice( 1, indices.length ) ) :
+ null;
+ }
+ }, true );
+
+ CKEDITOR.ui.dialog.vbox.prototype = new CKEDITOR.ui.dialog.hbox();
+
+
+
+ (function()
+ {
+ var commonBuilder = {
+ build : function( dialog, elementDefinition, output )
+ {
+ var children = elementDefinition.children,
+ child,
+ childHtmlList = [],
+ childObjList = [];
+ for ( var i = 0 ; ( i < children.length && ( child = children[i] ) ) ; i++ )
+ {
+ var childHtml = [];
+ childHtmlList.push( childHtml );
+ childObjList.push( CKEDITOR.dialog._.uiElementBuilders[ child.type ].build( dialog, child, childHtml ) );
+ }
+ return new CKEDITOR.ui.dialog[elementDefinition.type]( dialog, childObjList, childHtmlList, output, elementDefinition );
+ }
+ };
+
+ CKEDITOR.dialog.addUIElement( 'hbox', commonBuilder );
+ CKEDITOR.dialog.addUIElement( 'vbox', commonBuilder );
+ })();
+
+ /**
+ * Generic dialog command. It opens a specific dialog when executed.
+ * @constructor
+ * @augments CKEDITOR.commandDefinition
+ * @param {string} dialogName The name of the dialog to open when executing
+ * this command.
+ * @example
+ * // Register the "link" command, which opens the "link" dialog.
+ * editor.addCommand( 'link', new CKEDITOR.dialogCommand( 'link' ) );
+ */
+ CKEDITOR.dialogCommand = function( dialogName )
+ {
+ this.dialogName = dialogName;
+ };
+
+ CKEDITOR.dialogCommand.prototype =
+ {
+ /** @ignore */
+ exec : function( editor )
+ {
+ editor.openDialog( this.dialogName );
+ },
+ // Dialog commands just open a dialog ui, thus require no undo logic,
+ // undo support should dedicate to specific dialog implementation.
+ canUndo: false
+ };
+
+ (function()
+ {
+ var notEmptyRegex = /^([a]|[^a])+$/,
+ integerRegex = /^\d*$/,
+ numberRegex = /^\d*(?:\.\d+)?$/;
+
+ CKEDITOR.VALIDATE_OR = 1;
+ CKEDITOR.VALIDATE_AND = 2;
+
+ CKEDITOR.dialog.validate =
+ {
+ functions : function()
+ {
+ return function()
+ {
+ /**
+ * It's important for validate functions to be able to accept the value
+ * as argument in addition to this.getValue(), so that it is possible to
+ * combine validate functions together to make more sophisticated
+ * validators.
+ */
+ var value = this && this.getValue ? this.getValue() : arguments[0];
+
+ var msg = undefined,
+ relation = CKEDITOR.VALIDATE_AND,
+ functions = [], i;
+
+ for ( i = 0 ; i < arguments.length ; i++ )
+ {
+ if ( typeof( arguments[i] ) == 'function' )
+ functions.push( arguments[i] );
+ else
+ break;
+ }
+
+ if ( i < arguments.length && typeof( arguments[i] ) == 'string' )
+ {
+ msg = arguments[i];
+ i++;
+ }
+
+ if ( i < arguments.length && typeof( arguments[i]) == 'number' )
+ relation = arguments[i];
+
+ var passed = ( relation == CKEDITOR.VALIDATE_AND ? true : false );
+ for ( i = 0 ; i < functions.length ; i++ )
+ {
+ if ( relation == CKEDITOR.VALIDATE_AND )
+ passed = passed && functions[i]( value );
+ else
+ passed = passed || functions[i]( value );
+ }
+
+ if ( !passed )
+ {
+ if ( msg !== undefined )
+ alert( msg );
+ if ( this && ( this.select || this.focus ) )
+ ( this.select || this.focus )();
+ return false;
+ }
+
+ return true;
+ };
+ },
+
+ regex : function( regex, msg )
+ {
+ /*
+ * Can be greatly shortened by deriving from functions validator if code size
+ * turns out to be more important than performance.
+ */
+ return function()
+ {
+ var value = this && this.getValue ? this.getValue() : arguments[0];
+ if ( !regex.test( value ) )
+ {
+ if ( msg !== undefined )
+ alert( msg );
+ if ( this && ( this.select || this.focus ) )
+ {
+ if ( this.select )
+ this.select();
+ else
+ this.focus();
+ }
+ return false;
+ }
+ return true;
+ };
+ },
+
+ notEmpty : function( msg )
+ {
+ return this.regex( notEmptyRegex, msg );
+ },
+
+ integer : function( msg )
+ {
+ return this.regex( integerRegex, msg );
+ },
+
+ 'number' : function( msg )
+ {
+ return this.regex( numberRegex, msg );
+ },
+
+ equals : function( value, msg )
+ {
+ return this.functions( function( val ){ return val == value; }, msg );
+ },
+
+ notEqual : function( value, msg )
+ {
+ return this.functions( function( val ){ return val != value; }, msg );
+ }
+ };
+ })();
+
+ // Grab the margin data from skin definition and store it away.
+ CKEDITOR.skins.add = ( function()
+ {
+ var original = CKEDITOR.skins.add;
+ return function( skinName, skinDefinition )
+ {
+ skinData[ skinName ] = { margins : skinDefinition.margins };
+ return original.apply( this, arguments );
+ };
+ } )();
+})();
+
+// Extend the CKEDITOR.editor class with dialog specific functions.
+CKEDITOR.tools.extend( CKEDITOR.editor.prototype,
+ /** @lends CKEDITOR.editor.prototype */
+ {
+ /**
+ * Loads and opens a registered dialog.
+ * @param {String} dialogName The registered name of the dialog.
+ * @see CKEDITOR.dialog.add
+ * @example
+ * CKEDITOR.instances.editor1.openDialog( 'smiley' );
+ * @returns {CKEDITOR.dialog} The dialog object corresponding to the dialog displayed. null if the dialog name is not registered.
+ */
+ openDialog : function( dialogName )
+ {
+ var dialogDefinitions = CKEDITOR.dialog._.dialogDefinitions[ dialogName ];
+
+ // If the dialogDefinition is already loaded, open it immediately.
+ if ( typeof dialogDefinitions == 'function' )
+ {
+ var storedDialogs = this._.storedDialogs ||
+ ( this._.storedDialogs = {} );
+
+ var dialog = storedDialogs[ dialogName ] ||
+ ( storedDialogs[ dialogName ] = new CKEDITOR.dialog( this, dialogName ) );
+
+ dialog.show();
+
+ return dialog;
+ }
+ else if ( dialogDefinitions == 'failed' )
+ throw new Error( '[CKEDITOR.dialog.openDialog] Dialog "' + dialogName + '" failed when loading definition.' );
+
+ // Not loaded? Load the .js file first.
+ var body = CKEDITOR.document.getBody(),
+ cursor = body.$.style.cursor,
+ me = this;
+
+ body.setStyle( 'cursor', 'wait' );
+ CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( dialogDefinitions ), function()
+ {
+ // In case of plugin error, mark it as loading failed.
+ if ( typeof CKEDITOR.dialog._.dialogDefinitions[ dialogName ] != 'function' )
+ CKEDITOR.dialog._.dialogDefinitions[ dialogName ] = 'failed';
+ me.openDialog( dialogName );
+ body.setStyle( 'cursor', cursor );
+ } );
+
+ return null;
+ }
+ });
+
+// Dialog related configurations.
+
+/**
+ * The color of the dialog background cover. It should be a valid CSS color
+ * string.
+ * @type String
+ * @default white
+ * @example
+ * config.dialog_backgroundCoverColor = 'rgb(255, 254, 253)';
+ */
+CKEDITOR.config.dialog_backgroundCoverColor = 'white';
+
+/**
+ * The opacity of the dialog background cover. It should be a number within the
+ * range [0.0, 1.0].
+ * @type Number
+ * @default 0.5
+ * @example
+ * config.dialog_backgroundCoverOpacity = 0.7;
+ */
+CKEDITOR.config.dialog_backgroundCoverOpacity = 0.5;
+
+/**
+ * The distance of magnetic borders used in moving and resizing dialogs,
+ * measured in pixels.
+ * @type Number
+ * @default 20
+ * @example
+ * config.dialog_magnetDistance = 30;
+ */
+CKEDITOR.config.dialog_magnetDistance = 20;
Index: /CKEditor/branches/versions/3.0.x/_source/plugins/dialogui/plugin.js
===================================================================
--- /CKEditor/branches/versions/3.0.x/_source/plugins/dialogui/plugin.js (revision 3751)
+++ /CKEditor/branches/versions/3.0.x/_source/plugins/dialogui/plugin.js (revision 3751)
@@ -0,0 +1,1292 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/** @fileoverview The "dialogui" plugin. */
+
+CKEDITOR.plugins.add( 'dialogui' );
+
+(function()
+{
+ var initPrivateObject = function( elementDefinition )
+ {
+ this._ || ( this._ = {} );
+ this._['default'] = this._.initValue = elementDefinition['default'] || '';
+ var args = [ this._ ];
+ for ( var i = 1 ; i < arguments.length ; i++ )
+ args.push( arguments[i] );
+ args.push( true );
+ CKEDITOR.tools.extend.apply( CKEDITOR.tools, args );
+ return this._;
+ },
+ textBuilder =
+ {
+ build : function( dialog, elementDefinition, output )
+ {
+ return new CKEDITOR.ui.dialog.textInput( dialog, elementDefinition, output );
+ }
+ },
+ commonBuilder =
+ {
+ build : function( dialog, elementDefinition, output )
+ {
+ return new CKEDITOR.ui.dialog[elementDefinition.type]( dialog, elementDefinition, output );
+ }
+ },
+ commonPrototype =
+ {
+ isChanged : function()
+ {
+ return this.getValue() != this.getInitValue();
+ },
+
+ reset : function()
+ {
+ this.setValue( this.getInitValue() );
+ },
+
+ setInitValue : function()
+ {
+ this._.initValue = this.getValue();
+ },
+
+ resetInitValue : function()
+ {
+ this._.initValue = this._['default'];
+ },
+
+ getInitValue : function()
+ {
+ return this._.initValue;
+ }
+ },
+ commonEventProcessors = CKEDITOR.tools.extend( {}, CKEDITOR.ui.dialog.uiElement.prototype.eventProcessors,
+ {
+ onChange : function( dialog, func )
+ {
+ if ( !this._.domOnChangeRegistered )
+ {
+ dialog.on( 'load', function()
+ {
+ this.getInputElement().on( 'change', function(){ this.fire( 'change', { value : this.getValue() } ); }, this );
+ }, this );
+ this._.domOnChangeRegistered = true;
+ }
+
+ this.on( 'change', func );
+ }
+ }, true ),
+ eventRegex = /^on([A-Z]\w+)/,
+ cleanInnerDefinition = function( def )
+ {
+ // An inner UI element should not have the parent's type, title or events.
+ for ( var i in def )
+ {
+ if ( eventRegex.test( i ) || i == 'title' || i == 'type' )
+ delete def[i];
+ }
+ return def;
+ };
+
+ CKEDITOR.tools.extend( CKEDITOR.ui.dialog,
+ /** @lends CKEDITOR.ui.dialog */
+ {
+ /**
+ * Base class for all dialog elements with a textual label on the left.
+ * @constructor
+ * @example
+ * @extends CKEDITOR.ui.dialog.uiElement
+ * @param {CKEDITOR.dialog} dialog
+ * Parent dialog object.
+ * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition
+ * The element definition. Accepted fields:
+ *
+ *
label (Required) The label string.
+ *
labelLayout (Optional) Put 'horizontal' here if the
+ * label element is to be layed out horizontally. Otherwise a vertical
+ * layout will be used.
+ *
widths (Optional) This applies only for horizontal
+ * layouts - an 2-element array of lengths to specify the widths of the
+ * label and the content element.
+ *
+ * @param {Array} htmlList
+ * List of HTML code to output to.
+ * @param {Function} contentHtml
+ * A function returning the HTML code string to be added inside the content
+ * cell.
+ */
+ labeledElement : function( dialog, elementDefinition, htmlList, contentHtml )
+ {
+ if ( arguments.length < 4 )
+ return;
+
+ var _ = initPrivateObject.call( this, elementDefinition );
+ _.labelId = CKEDITOR.tools.getNextNumber() + '_label';
+ var children = this._.children = [];
+ /** @ignore */
+ var innerHTML = function()
+ {
+ var html = [];
+ if ( elementDefinition.labelLayout != 'horizontal' )
+ html.push( '
items (Required) An array of options. Each option
+ * is a 1- or 2-item array of format [ 'Description', 'Value' ]. If 'Value'
+ * is missing, then the value would be assumed to be the same as the
+ * description.
+ *
+ * @param {Array} htmlList
+ * List of HTML code to output to.
+ */
+ radio : function( dialog, elementDefinition, htmlList )
+ {
+ if ( arguments.length < 3)
+ return;
+
+ initPrivateObject.call( this, elementDefinition );
+ if ( !this._['default'] )
+ this._['default'] = this._.initValue = elementDefinition.items[0][1];
+ if ( elementDefinition.validate )
+ this.validate = elementDefinition.valdiate;
+ var children = [], me = this;
+
+ /** @ignore */
+ var innerHTML = function()
+ {
+ var inputHtmlList = [], html = [],
+ commonAttributes = { 'class' : 'cke_dialog_ui_radio_item' },
+ commonName = elementDefinition.id ? elementDefinition.id + '_radio' : CKEDITOR.tools.getNextNumber() + '_radio';
+ for ( var i = 0 ; i < elementDefinition.items.length ; i++ )
+ {
+ var item = elementDefinition.items[i],
+ title = item[2] !== undefined ? item[2] : item[0],
+ value = item[1] !== undefined ? item[1] : item[0],
+ inputDefinition = CKEDITOR.tools.extend( {}, elementDefinition,
+ {
+ id : CKEDITOR.tools.getNextNumber() + '_radio_input',
+ title : null,
+ type : null
+ }, true ),
+ labelDefinition = CKEDITOR.tools.extend( {}, inputDefinition,
+ {
+ id : null,
+ title : title
+ }, true ),
+ inputHtml = [],
+ inputAttributes =
+ {
+ type : 'radio',
+ 'class' : 'cke_dialog_ui_radio_input',
+ name : commonName,
+ value : value
+ };
+ if ( me._['default'] == value )
+ inputAttributes.checked = 'checked';
+ cleanInnerDefinition( inputDefinition );
+ cleanInnerDefinition( labelDefinition );
+ children.push( new CKEDITOR.ui.dialog.uiElement( dialog, inputDefinition, inputHtml, 'input', null, inputAttributes ) );
+ new CKEDITOR.ui.dialog.uiElement( dialog, labelDefinition, inputHtmlList, 'label', null, null,
+ inputHtml.join( '' ) + ' ' + item[0] );
+ }
+ new CKEDITOR.ui.dialog.hbox( dialog, [], inputHtmlList, html );
+ return html.join( '' );
+ };
+
+ CKEDITOR.ui.dialog.labeledElement.call( this, dialog, elementDefinition, htmlList, innerHTML );
+ this._.children = children;
+ },
+
+ /**
+ * A button with a label inside.
+ * @constructor
+ * @example
+ * @extends CKEDITOR.ui.dialog.uiElement
+ * @param {CKEDITOR.dialog} dialog
+ * Parent dialog object.
+ * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition
+ * The element definition. Accepted fields:
+ *
+ *
label (Required) The button label.
+ *
disabled (Optional) Set to true if you want the
+ * button to appear in disabled state.
items (Required) An array of options. Each option
+ * is a 1- or 2-item array of format [ 'Description', 'Value' ]. If 'Value'
+ * is missing, then the value would be assumed to be the same as the
+ * description.
+ *
multiple (Optional) Set this to true if you'd like
+ * to have a multiple-choice select box.
+ *
size (Optional) The number of items to display in
+ * the select box.
+ *
+ * If you set the 'filebrowser' attribute on any element other than
+ * 'fileButton', the 'Browse' action will be triggered.
+ *
+ * Example 2: (Quick Upload)
+ *
+ *
+ *
+ * If you set the 'filebrowser' attribute on a fileButton element, the
+ * 'QuickUpload' action will be executed.
+ *
+ * Filebrowser plugin also supports more advanced configuration (through
+ * javascript object).
+ *
+ * The following settings are supported:
+ *
+ *
+ * [action] - Browse or QuickUpload
+ * [target] - field to update, tabId:elementId
+ * [params] - additional arguments to be passed to the server connector (optional)
+ * [onSelect] - function to execute when file is selected/uploaded (optional)
+ * [url] - the URL to be called (optional)
+ *
+ *
+ * Suppose we have a file element with id 'myFile', text field with id
+ * 'elementId' and a fileButton. If filebowser.url is not specified explicitly,
+ * form action will be set to 'filebrowser[DialogName]UploadUrl' or, if not
+ * specified, to 'filebrowserUploadUrl'. Additional parameters from 'params'
+ * object will be added to the query string. It is possible to create your own
+ * uploadHandler and cancel the built-in updateTargetElement command.
+ *
+ * Example 4: (Browse)
+ *
+ *