Index: wp-admin/css/nestedsortablewidget.css =================================================================== --- wp-admin/css/nestedsortablewidget.css (revision 0) +++ wp-admin/css/nestedsortablewidget.css (revision 0) @@ -0,0 +1,138 @@ +/*##################################*/ +/*Units are written in em, considering a font size of 13px*/ + + +.nsw-list-wrap { + padding: 0em 1em 1em 1em; +} + +.nsw-header-wrap { + padding: 1em 1em 0em 1em; +} + +.nsw-wrap { + border:1px solid #BBBBBB; + padding: 1em 1em 1em 1em; +} + +.nsw-drop { + background: #F0F8FF; + color: #A0A0A0; + text-align: center; + margin: 0.5em 0 0.5em 0; + padding: 1em 0 1em 0; + border-color: #F2F2F2 rgb(232, 232, 232) rgb(232, 232, 232) rgb(242, 242, 242); + border-style: solid; + border-width: 1px; +} + +.nsw-active-drop { + background: yellow; +} + +.nsw-nav-previous { +float:left; +} +.nsw-nav-next { +float:right; +} +.nsw-nav-links { +display:block; +margin-bottom:1em; +margin-top:1em; +text-align:center; +clear: both; +float: none; +} + +.nsw-list-holder, .nsw-header { + list-style: none; + margin: 0; + padding: 0; +} + +.nsw-clear { + clear: both; +} + +.nsw-item , .nsw-header-item{ + margin: 0; + padding: 0; +} + +.nsw-alt-cell{ + background: #f1f1f1 !important; +} + +.nsw-item div div { + background: #f8f8f8; +} + +.nsw-header-item div div { + background: #DFDFDF; + font-weight: bold; +} + +.nsw-save-button, +.nsw-disabled-save-button, +.nsw-disabled-save-button:focus, +.nsw-disabled-save-button:active, +.nsw-save-button:focus { + background: url( ../images/fade-butt.png ); + background-color: #F2F2F2; + border-color:#CCCCCC rgb(153, 153, 153) rgb(153, 153, 153) rgb(204, 204, 204); + border-style:double; + border-width:3px; + color:#333333; + padding:0.25em; + float:right; +} + +.nsw-disabled-save-button, +.nsw-disabled-save-button:focus, +.nsw-disabled-save-button:active { + color: #AAAAAA; +} + +.nsw-save-button:active { + background:#F4F4F4 none repeat scroll 0%; + border-color:#999999 rgb(204, 204, 204) rgb(204, 204, 204) rgb(153, 153, 153); + border-style:double; + border-width:3px; +} + +.nsw-progress { + background: center url(../images/progress_indicator.gif) no-repeat; + width:16px; + height:16px; + left: 50%; + top: 0.5em; + position: absolute; +} + +.nsw-warning { + left: 30%; + top: 0.5em; + width: 40%; + position: absolute; + background: yellow; + border: solid 1px; + border-color:#CCCCCC rgb(153, 153, 153) rgb(153, 153, 153) rgb(204, 204, 204); + text-align: center; +} + +.nsw-save-progress-wrap { + position: static; +} + +.nsw-progress-warning-wrap { + position: relative; +} + +.nsw-handle { + font-weight: bold; +} + +.nsw-helper { +border:2px dashed #777777; +} Index: wp-admin/edit-pages.php =================================================================== --- wp-admin/edit-pages.php (revision 6010) +++ wp-admin/edit-pages.php (working copy) @@ -3,6 +3,8 @@ $title = __('Pages'); $parent_file = 'edit.php'; wp_enqueue_script( 'listman' ); +wp_admin_css('css/nestedsortablewidget'); +wp_enqueue_script( 'edit-page-order' ); require_once('admin-header.php'); $post_stati = array( // array( adj, noun ) Index: wp-admin/images/progress_indicator.gif =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: wp-admin\images\progress_indicator.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Index: wp-admin/includes/JSON.php =================================================================== --- wp-admin/includes/JSON.php (revision 0) +++ wp-admin/includes/JSON.php (revision 0) @@ -0,0 +1,806 @@ + + * @author Matt Knapp + * @author Brett Stimmerman + * @copyright 2005 Michal Migurski + * @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $ + * @license http://www.opensource.org/licenses/bsd-license.php + * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198 + */ + +/** + * Marker constant for Services_JSON::decode(), used to flag stack state + */ +define('SERVICES_JSON_SLICE', 1); + +/** + * Marker constant for Services_JSON::decode(), used to flag stack state + */ +define('SERVICES_JSON_IN_STR', 2); + +/** + * Marker constant for Services_JSON::decode(), used to flag stack state + */ +define('SERVICES_JSON_IN_ARR', 3); + +/** + * Marker constant for Services_JSON::decode(), used to flag stack state + */ +define('SERVICES_JSON_IN_OBJ', 4); + +/** + * Marker constant for Services_JSON::decode(), used to flag stack state + */ +define('SERVICES_JSON_IN_CMT', 5); + +/** + * Behavior switch for Services_JSON::decode() + */ +define('SERVICES_JSON_LOOSE_TYPE', 16); + +/** + * Behavior switch for Services_JSON::decode() + */ +define('SERVICES_JSON_SUPPRESS_ERRORS', 32); + +/** + * Converts to and from JSON format. + * + * Brief example of use: + * + * + * // create a new instance of Services_JSON + * $json = new Services_JSON(); + * + * // convert a complexe value to JSON notation, and send it to the browser + * $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4))); + * $output = $json->encode($value); + * + * print($output); + * // prints: ["foo","bar",[1,2,"baz"],[3,[4]]] + * + * // accept incoming POST data, assumed to be in JSON notation + * $input = file_get_contents('php://input', 1000000); + * $value = $json->decode($input); + * + */ +class Services_JSON +{ + /** + * constructs a new JSON instance + * + * @param int $use object behavior flags; combine with boolean-OR + * + * possible values: + * - SERVICES_JSON_LOOSE_TYPE: loose typing. + * "{...}" syntax creates associative arrays + * instead of objects in decode(). + * - SERVICES_JSON_SUPPRESS_ERRORS: error suppression. + * Values which can't be encoded (e.g. resources) + * appear as NULL instead of throwing errors. + * By default, a deeply-nested resource will + * bubble up with an error, so all return values + * from encode() should be checked with isError() + */ + function Services_JSON($use = 0) + { + $this->use = $use; + } + + /** + * convert a string from one UTF-16 char to one UTF-8 char + * + * Normally should be handled by mb_convert_encoding, but + * provides a slower PHP-only method for installations + * that lack the multibye string extension. + * + * @param string $utf16 UTF-16 character + * @return string UTF-8 character + * @access private + */ + function utf162utf8($utf16) + { + // oh please oh please oh please oh please oh please + if(function_exists('mb_convert_encoding')) { + return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16'); + } + + $bytes = (ord($utf16{0}) << 8) | ord($utf16{1}); + + switch(true) { + case ((0x7F & $bytes) == $bytes): + // this case should never be reached, because we are in ASCII range + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr(0x7F & $bytes); + + case (0x07FF & $bytes) == $bytes: + // return a 2-byte UTF-8 character + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr(0xC0 | (($bytes >> 6) & 0x1F)) + . chr(0x80 | ($bytes & 0x3F)); + + case (0xFFFF & $bytes) == $bytes: + // return a 3-byte UTF-8 character + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr(0xE0 | (($bytes >> 12) & 0x0F)) + . chr(0x80 | (($bytes >> 6) & 0x3F)) + . chr(0x80 | ($bytes & 0x3F)); + } + + // ignoring UTF-32 for now, sorry + return ''; + } + + /** + * convert a string from one UTF-8 char to one UTF-16 char + * + * Normally should be handled by mb_convert_encoding, but + * provides a slower PHP-only method for installations + * that lack the multibye string extension. + * + * @param string $utf8 UTF-8 character + * @return string UTF-16 character + * @access private + */ + function utf82utf16($utf8) + { + // oh please oh please oh please oh please oh please + if(function_exists('mb_convert_encoding')) { + return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); + } + + switch(strlen($utf8)) { + case 1: + // this case should never be reached, because we are in ASCII range + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return $utf8; + + case 2: + // return a UTF-16 character from a 2-byte UTF-8 char + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr(0x07 & (ord($utf8{0}) >> 2)) + . chr((0xC0 & (ord($utf8{0}) << 6)) + | (0x3F & ord($utf8{1}))); + + case 3: + // return a UTF-16 character from a 3-byte UTF-8 char + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr((0xF0 & (ord($utf8{0}) << 4)) + | (0x0F & (ord($utf8{1}) >> 2))) + . chr((0xC0 & (ord($utf8{1}) << 6)) + | (0x7F & ord($utf8{2}))); + } + + // ignoring UTF-32 for now, sorry + return ''; + } + + /** + * encodes an arbitrary variable into JSON format + * + * @param mixed $var any number, boolean, string, array, or object to be encoded. + * see argument 1 to Services_JSON() above for array-parsing behavior. + * if var is a strng, note that encode() always expects it + * to be in ASCII or UTF-8 format! + * + * @return mixed JSON string representation of input var or an error if a problem occurs + * @access public + */ + function encode($var) + { + switch (gettype($var)) { + case 'boolean': + return $var ? 'true' : 'false'; + + case 'NULL': + return 'null'; + + case 'integer': + return (int) $var; + + case 'double': + case 'float': + return (float) $var; + + case 'string': + // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT + $ascii = ''; + $strlen_var = strlen($var); + + /* + * Iterate over every character in the string, + * escaping with a slash or encoding to UTF-8 where necessary + */ + for ($c = 0; $c < $strlen_var; ++$c) { + + $ord_var_c = ord($var{$c}); + + switch (true) { + case $ord_var_c == 0x08: + $ascii .= '\b'; + break; + case $ord_var_c == 0x09: + $ascii .= '\t'; + break; + case $ord_var_c == 0x0A: + $ascii .= '\n'; + break; + case $ord_var_c == 0x0C: + $ascii .= '\f'; + break; + case $ord_var_c == 0x0D: + $ascii .= '\r'; + break; + + case $ord_var_c == 0x22: + case $ord_var_c == 0x2F: + case $ord_var_c == 0x5C: + // double quote, slash, slosh + $ascii .= '\\'.$var{$c}; + break; + + case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): + // characters U-00000000 - U-0000007F (same as ASCII) + $ascii .= $var{$c}; + break; + + case (($ord_var_c & 0xE0) == 0xC0): + // characters U-00000080 - U-000007FF, mask 110XXXXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, ord($var{$c + 1})); + $c += 1; + $utf16 = $this->utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xF0) == 0xE0): + // characters U-00000800 - U-0000FFFF, mask 1110XXXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, + ord($var{$c + 1}), + ord($var{$c + 2})); + $c += 2; + $utf16 = $this->utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xF8) == 0xF0): + // characters U-00010000 - U-001FFFFF, mask 11110XXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, + ord($var{$c + 1}), + ord($var{$c + 2}), + ord($var{$c + 3})); + $c += 3; + $utf16 = $this->utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xFC) == 0xF8): + // characters U-00200000 - U-03FFFFFF, mask 111110XX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, + ord($var{$c + 1}), + ord($var{$c + 2}), + ord($var{$c + 3}), + ord($var{$c + 4})); + $c += 4; + $utf16 = $this->utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xFE) == 0xFC): + // characters U-04000000 - U-7FFFFFFF, mask 1111110X + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, + ord($var{$c + 1}), + ord($var{$c + 2}), + ord($var{$c + 3}), + ord($var{$c + 4}), + ord($var{$c + 5})); + $c += 5; + $utf16 = $this->utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + } + } + + return '"'.$ascii.'"'; + + case 'array': + /* + * As per JSON spec if any array key is not an integer + * we must treat the the whole array as an object. We + * also try to catch a sparsely populated associative + * array with numeric keys here because some JS engines + * will create an array with empty indexes up to + * max_index which can cause memory issues and because + * the keys, which may be relevant, will be remapped + * otherwise. + * + * As per the ECMA and JSON specification an object may + * have any string as a property. Unfortunately due to + * a hole in the ECMA specification if the key is a + * ECMA reserved word or starts with a digit the + * parameter is only accessible using ECMAScript's + * bracket notation. + */ + + // treat as a JSON object + if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) { + $properties = array_map(array($this, 'name_value'), + array_keys($var), + array_values($var)); + + foreach($properties as $property) { + if(Services_JSON::isError($property)) { + return $property; + } + } + + return '{' . join(',', $properties) . '}'; + } + + // treat it like a regular array + $elements = array_map(array($this, 'encode'), $var); + + foreach($elements as $element) { + if(Services_JSON::isError($element)) { + return $element; + } + } + + return '[' . join(',', $elements) . ']'; + + case 'object': + $vars = get_object_vars($var); + + $properties = array_map(array($this, 'name_value'), + array_keys($vars), + array_values($vars)); + + foreach($properties as $property) { + if(Services_JSON::isError($property)) { + return $property; + } + } + + return '{' . join(',', $properties) . '}'; + + default: + return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS) + ? 'null' + : new Services_JSON_Error(gettype($var)." can not be encoded as JSON string"); + } + } + + /** + * array-walking function for use in generating JSON-formatted name-value pairs + * + * @param string $name name of key to use + * @param mixed $value reference to an array element to be encoded + * + * @return string JSON-formatted name-value pair, like '"name":value' + * @access private + */ + function name_value($name, $value) + { + $encoded_value = $this->encode($value); + + if(Services_JSON::isError($encoded_value)) { + return $encoded_value; + } + + return $this->encode(strval($name)) . ':' . $encoded_value; + } + + /** + * reduce a string by removing leading and trailing comments and whitespace + * + * @param $str string string value to strip of comments and whitespace + * + * @return string string value stripped of comments and whitespace + * @access private + */ + function reduce_string($str) + { + $str = preg_replace(array( + + // eliminate single line comments in '// ...' form + '#^\s*//(.+)$#m', + + // eliminate multi-line comments in '/* ... */' form, at start of string + '#^\s*/\*(.+)\*/#Us', + + // eliminate multi-line comments in '/* ... */' form, at end of string + '#/\*(.+)\*/\s*$#Us' + + ), '', $str); + + // eliminate extraneous space + return trim($str); + } + + /** + * decodes a JSON string into appropriate variable + * + * @param string $str JSON-formatted string + * + * @return mixed number, boolean, string, array, or object + * corresponding to given JSON input string. + * See argument 1 to Services_JSON() above for object-output behavior. + * Note that decode() always returns strings + * in ASCII or UTF-8 format! + * @access public + */ + function decode($str) + { + $str = $this->reduce_string($str); + + switch (strtolower($str)) { + case 'true': + return true; + + case 'false': + return false; + + case 'null': + return null; + + default: + $m = array(); + + if (is_numeric($str)) { + // Lookie-loo, it's a number + + // This would work on its own, but I'm trying to be + // good about returning integers where appropriate: + // return (float)$str; + + // Return float or int, as appropriate + return ((float)$str == (integer)$str) + ? (integer)$str + : (float)$str; + + } elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) { + // STRINGS RETURNED IN UTF-8 FORMAT + $delim = substr($str, 0, 1); + $chrs = substr($str, 1, -1); + $utf8 = ''; + $strlen_chrs = strlen($chrs); + + for ($c = 0; $c < $strlen_chrs; ++$c) { + + $substr_chrs_c_2 = substr($chrs, $c, 2); + $ord_chrs_c = ord($chrs{$c}); + + switch (true) { + case $substr_chrs_c_2 == '\b': + $utf8 .= chr(0x08); + ++$c; + break; + case $substr_chrs_c_2 == '\t': + $utf8 .= chr(0x09); + ++$c; + break; + case $substr_chrs_c_2 == '\n': + $utf8 .= chr(0x0A); + ++$c; + break; + case $substr_chrs_c_2 == '\f': + $utf8 .= chr(0x0C); + ++$c; + break; + case $substr_chrs_c_2 == '\r': + $utf8 .= chr(0x0D); + ++$c; + break; + + case $substr_chrs_c_2 == '\\"': + case $substr_chrs_c_2 == '\\\'': + case $substr_chrs_c_2 == '\\\\': + case $substr_chrs_c_2 == '\\/': + if (($delim == '"' && $substr_chrs_c_2 != '\\\'') || + ($delim == "'" && $substr_chrs_c_2 != '\\"')) { + $utf8 .= $chrs{++$c}; + } + break; + + case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)): + // single, escaped unicode character + $utf16 = chr(hexdec(substr($chrs, ($c + 2), 2))) + . chr(hexdec(substr($chrs, ($c + 4), 2))); + $utf8 .= $this->utf162utf8($utf16); + $c += 5; + break; + + case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F): + $utf8 .= $chrs{$c}; + break; + + case ($ord_chrs_c & 0xE0) == 0xC0: + // characters U-00000080 - U-000007FF, mask 110XXXXX + //see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $utf8 .= substr($chrs, $c, 2); + ++$c; + break; + + case ($ord_chrs_c & 0xF0) == 0xE0: + // characters U-00000800 - U-0000FFFF, mask 1110XXXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $utf8 .= substr($chrs, $c, 3); + $c += 2; + break; + + case ($ord_chrs_c & 0xF8) == 0xF0: + // characters U-00010000 - U-001FFFFF, mask 11110XXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $utf8 .= substr($chrs, $c, 4); + $c += 3; + break; + + case ($ord_chrs_c & 0xFC) == 0xF8: + // characters U-00200000 - U-03FFFFFF, mask 111110XX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $utf8 .= substr($chrs, $c, 5); + $c += 4; + break; + + case ($ord_chrs_c & 0xFE) == 0xFC: + // characters U-04000000 - U-7FFFFFFF, mask 1111110X + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $utf8 .= substr($chrs, $c, 6); + $c += 5; + break; + + } + + } + + return $utf8; + + } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) { + // array, or object notation + + if ($str{0} == '[') { + $stk = array(SERVICES_JSON_IN_ARR); + $arr = array(); + } else { + if ($this->use & SERVICES_JSON_LOOSE_TYPE) { + $stk = array(SERVICES_JSON_IN_OBJ); + $obj = array(); + } else { + $stk = array(SERVICES_JSON_IN_OBJ); + $obj = new stdClass(); + } + } + + array_push($stk, array('what' => SERVICES_JSON_SLICE, + 'where' => 0, + 'delim' => false)); + + $chrs = substr($str, 1, -1); + $chrs = $this->reduce_string($chrs); + + if ($chrs == '') { + if (reset($stk) == SERVICES_JSON_IN_ARR) { + return $arr; + + } else { + return $obj; + + } + } + + //print("\nparsing {$chrs}\n"); + + $strlen_chrs = strlen($chrs); + + for ($c = 0; $c <= $strlen_chrs; ++$c) { + + $top = end($stk); + $substr_chrs_c_2 = substr($chrs, $c, 2); + + if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) { + // found a comma that is not inside a string, array, etc., + // OR we've reached the end of the character list + $slice = substr($chrs, $top['where'], ($c - $top['where'])); + array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false)); + //print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); + + if (reset($stk) == SERVICES_JSON_IN_ARR) { + // we are in an array, so just push an element onto the stack + array_push($arr, $this->decode($slice)); + + } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) { + // we are in an object, so figure + // out the property name and set an + // element in an associative array, + // for now + $parts = array(); + + if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) { + // "name":value pair + $key = $this->decode($parts[1]); + $val = $this->decode($parts[2]); + + if ($this->use & SERVICES_JSON_LOOSE_TYPE) { + $obj[$key] = $val; + } else { + $obj->$key = $val; + } + } elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) { + // name:value pair, where name is unquoted + $key = $parts[1]; + $val = $this->decode($parts[2]); + + if ($this->use & SERVICES_JSON_LOOSE_TYPE) { + $obj[$key] = $val; + } else { + $obj->$key = $val; + } + } + + } + + } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) { + // found a quote, and we are not inside a string + array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c})); + //print("Found start of string at {$c}\n"); + + } elseif (($chrs{$c} == $top['delim']) && + ($top['what'] == SERVICES_JSON_IN_STR) && + ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) { + // found a quote, we're in a string, and it's not escaped + // we know that it's not escaped becase there is _not_ an + // odd number of backslashes at the end of the string so far + array_pop($stk); + //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n"); + + } elseif (($chrs{$c} == '[') && + in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { + // found a left-bracket, and we are in an array, object, or slice + array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false)); + //print("Found start of array at {$c}\n"); + + } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) { + // found a right-bracket, and we're in an array + array_pop($stk); + //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); + + } elseif (($chrs{$c} == '{') && + in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { + // found a left-brace, and we are in an array, object, or slice + array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false)); + //print("Found start of object at {$c}\n"); + + } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) { + // found a right-brace, and we're in an object + array_pop($stk); + //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); + + } elseif (($substr_chrs_c_2 == '/*') && + in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { + // found a comment start, and we are in an array, object, or slice + array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false)); + $c++; + //print("Found start of comment at {$c}\n"); + + } elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) { + // found a comment end, and we're in one now + array_pop($stk); + $c++; + + for ($i = $top['where']; $i <= $c; ++$i) + $chrs = substr_replace($chrs, ' ', $i, 1); + + //print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); + + } + + } + + if (reset($stk) == SERVICES_JSON_IN_ARR) { + return $arr; + + } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) { + return $obj; + + } + + } + } + } + + /** + * @todo Ultimately, this should just call PEAR::isError() + */ + function isError($data, $code = null) + { + if (class_exists('pear')) { + return PEAR::isError($data, $code); + } elseif (is_object($data) && (get_class($data) == 'services_json_error' || + is_subclass_of($data, 'services_json_error'))) { + return true; + } + + return false; + } +} + +if (class_exists('PEAR_Error')) { + + class Services_JSON_Error extends PEAR_Error + { + function Services_JSON_Error($message = 'unknown error', $code = null, + $mode = null, $options = null, $userinfo = null) + { + parent::PEAR_Error($message, $code, $mode, $options, $userinfo); + } + } + +} else { + + /** + * @todo Ultimately, this class shall be descended from PEAR_Error + */ + class Services_JSON_Error + { + function Services_JSON_Error($message = 'unknown error', $code = null, + $mode = null, $options = null, $userinfo = null) + { + + } + } + +} + +?> Index: wp-admin/js/edit-page-order.js =================================================================== --- wp-admin/js/edit-page-order.js (revision 0) +++ wp-admin/js/edit-page-order.js (revision 0) @@ -0,0 +1,53 @@ +jQuery( function($){ + + var addEditButtonEvent = function(button) { + wasSaved = false; + button.one ( + "click", + function() { + $('table.widefat').hide(); + $('#ajax-response').NestedSortableWidget({ + loadUrl: "page-order-ajax.php", + text: editPageOrderL10n, + paginate: true, + itemsPerPage: 10, + transitionAnim: 'slide', + nestedSortCfg: { + opacity: 0.6, + fx:400, + revert: true + }, + onInitialLoad: function() { + var widget = this; + button.attr("value", editPageOrderL10n.cancelButton).one ( + "click", + function() { + if (wasSaved) { + window.location.reload(); + } else { + $('table.widefat').show(); + $(widget).NestedSortableWidgetDestroy(); + button.attr("value", editPageOrderL10n.editButton); + addEditButtonEvent(button); + } + } + ); + }, + onLoadError: function() { + addEditButtonEvent(button); + }, + onSave: function() { + wasSaved = true; + } + }); + } + ); + }; + + + var editButton = $(''); + $('#ajax-response') + .after($('

').append(editButton)); + addEditButtonEvent(editButton); +} +); \ No newline at end of file Index: wp-admin/page-order-ajax.php =================================================================== --- wp-admin/page-order-ajax.php (revision 0) +++ wp-admin/page-order-ajax.php (revision 0) @@ -0,0 +1,222 @@ +_fetch_page_list(); + if($firstIndex === null || $count === null) { + return $this->completeHash; + } else { + $firstIndex = (int)$firstIndex; + $count = (int)$count; + $return = array( + "requestFirstIndex"=> $firstIndex, + "columns"=> $this->completeHash['columns'], + "totalCount" => $this->completeHash['totalCount'] + ); + + + $first = null; + $last = null; + $curPos = 0; + foreach ($this->completeHash['items'] as $key => $value) { + $nextPos = $this->_count_items($value) + 1 + $curPos; + if($first === null && $firstIndex === $curPos) { + $newFirstIndex = $curPos; + $first = $key; + } + if ($first === null && $nextPos > $firstIndex) { + $first = $key + 1; + $newFirstIndex = $nextPos; + } + if( $last === null && + $newFirstIndex!==null && + ($nextPos >= $newFirstIndex + $count || $nextPos >= $return['totalCount'] ) ) + { + $last = $key; //the root element where the item with the last index is + $newCount = $nextPos - $newFirstIndex; + break; //we are done if we got here + } + $curPos = $nextPos; + } + + $return['firstIndex'] = $newFirstIndex; + $return['count'] = $newCount; + $return['items'] = array_slice($this->completeHash['items'], $first, $last - $first + 1); + + return $return; + } + } + + + /** + * Saves the page order. + * + * This function calls itself recursivelly to save the order of its child pages. + * + * @param array $pages_array Array with the page ids organized in order and hiearachically. + * @param integer $parent_id The db index of the page which is the parent of all the passed in pages. + */ + function save_page_order($pages_array, $parent_id = 0) { + global $wpdb; + $first_page = $wpdb->escape($pages_array[0]['id']); + $current_menu_order = get_post_field('menu_order', $first_page, 'db'); + if(is_wp_error($current_menu_order)) return false; + if($parent_id === 0) { + //shifts the menu order for all the root pages after the ones we + //will alter + $num_root_pages = count($pages_array); + $query_ret = $wpdb->query("UPDATE $wpdb->posts SET menu_order = menu_order + $num_root_pages WHERE post_type = 'page' AND post_parent = 0 AND menu_order > $current_menu_order"); + if($query_ret === false) return false; + } + foreach ($pages_array as $index => $page) { + $page_id = $wpdb->escape($page['id']); + + $query_ret = $wpdb->query("UPDATE $wpdb->posts SET post_parent = '$parent_id', menu_order = '$current_menu_order' WHERE id ='$page_id'"); + + if($query_ret === false) return false; + + $current_menu_order++; + if (is_array($page['children'])) { + //does it for the children as well + if (!$this->save_page_order($page['children'], $page_id)) return false; + } + } + + return true; + } + + function _fetch_page_list() { + wp("post_type=page&orderby=menu_order&what_to_show=posts&posts_per_page=-1&posts_per_archive_page=-1&order=asc"); + if($GLOBALS['posts']) { + $this->items = $this->_build_items_array(0, 0, $GLOBALS['posts']); + $this->completeHash = array( + "requestFirstIndex" => 0, + "firstIndex" => 0, + "count" => $this->count, + "totalCount" => $this->count, + "columns" => array("Title (ID)", "Owner", "Updated"), + "items" => $this->items + ); + } + } + + function _count_items($item) { + $cur_count = 0; + + if($item['children']) { + foreach ($item['children'] as $i) { + $cur_count++; + $cur_count += $this->_count_items($i); + } + } + + return $cur_count; + } + + function _build_items_array( $parent = 0, $level = 0, $pages = 0, $hierarchy = true ) { + //this is not the neatest of the algorithms, a lot of waste here + //based on get_pages() + global $wpdb, $post; + + if (!$pages ) + $pages = get_pages( 'sort_column=menu_order' ); + + if (! $pages ) + return false; + + $ret_array = array(); + foreach ( $pages as $post ) { + setup_postdata( $post); + if ( $hierarchy && ($post->post_parent != $parent) ) + continue; + $cur_index = count($ret_array); + $post->post_title = wp_specialchars( $post->post_title ); + $id = (int) $post->ID; + $ret_array[$cur_index] = array( + "id" => $id, + "info" => array(get_the_title() . " (" . $id .")", get_the_author(), ( '0000-00-00 00:00:00' ==$post->post_modified ) ? __('Unpublished'): mysql2date( __('Y-m-d g:i a'), $post->post_modified )) + ); + + $this->count ++; + + if ( $hierarchy ) { + $children = $this->_build_items_array( $id, $level + 1, $pages ); + if ( $children ) { + $ret_array[$cur_index]['children'] = $children; + } + } + } + + return $ret_array; + } + +} + +$wppo = new WP_Page_Order(); + +if($_SERVER['REQUEST_METHOD'] == "GET") { + //FETCHING DATA FROM THE SERVER + $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); + + $firstReq = $_GET['firstIndex']; + + $count = $_GET['count']; + + $hash = $wppo->get_paginated_pages($firstReq, $count); + + $retJson = $json->encode($hash); + + echo $retJson; +} else { + //SENDING DATA TO THE SERVER + + + if(isset($_POST['nested-sortable-widget']) && is_array($_POST['nested-sortable-widget']['items'])) { + //if there is only one chunk of data + $page_chunks = array($_POST['nested-sortable-widget']); + } elseif (isset($_POST['nested-sortable-widget'][0]) && is_array($_POST['nested-sortable-widget'][0]['items'])) { + //more than one chunk + $page_chunks = $_POST['nested-sortable-widget']; + } else { + header("HTTP/1.0 400 Bad Request"); + exit; + } + + foreach($page_chunks as $key => $chunk) { + if(!$wppo->save_page_order($chunk['items'])) { + $return_error = true; + } + } + + if(!$return_error) { + echo "SUCCESS"; + } else { + header("HTTP/1.0 500 Internal Server Error"); + exit; + } +} + +?> \ No newline at end of file Index: wp-includes/js/jquery/inestedsortable.js =================================================================== --- wp-includes/js/jquery/inestedsortable.js (revision 0) +++ wp-includes/js/jquery/inestedsortable.js (revision 0) @@ -0,0 +1,497 @@ +/** + * + * Nested Sortable Plugin for jQuery/Interface. + * + * Copyright (c) 2007 Bernardo de Pádua dos Santos + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + */ +jQuery.iNestedSortable = { + /* + * Called when an item is being dragged. Puts the sort helper in the proper place. + * The "e" argument passed in is the Sortable element. + */ + checkHover : function(e,o) { + if(e.isNestedSortable){ + //A brand new NestedSortable hovering check + jQuery.iNestedSortable.scroll(e); + return jQuery.iNestedSortable.newCheckHover(e); + } else { + //The legacy hovering check performed by plain Sortables + //I don't think "o" is even used, but it is in the function declaration + return jQuery.iNestedSortable.oldCheckHover(e,o); + } + }, + oldCheckHover : jQuery.iSort.checkhover, + newCheckHover : function (e) { + if (!jQuery.iDrag.dragged) + return; + + if ( !(e.dropCfg.el.size() > 0) ) + return; + + //we need to recalculate the position of the sortables, + //or there will be some mismatches + if(!e.nestedSortCfg.remeasured) { + jQuery.iSort.measure(e); + e.nestedSortCfg.remeasured = true; + } + + //finds item that is on top of the one being dragged, + //and in a compatible nesting level + var precItem = jQuery.iNestedSortable.findPrecedingItem(e); + + var shouldNest = jQuery.iNestedSortable.shouldNestItem(e, precItem); + var touchingFirst = (!precItem) ? jQuery.iNestedSortable.isTouchingFirstItem(e) : false; + var quit = false; + + //avoids doing things more than once + if(precItem) { + if(e.nestedSortCfg.lastPrecedingItem === precItem && e.nestedSortCfg.lastShouldNest === shouldNest) { + quit = true; + } + } + else if(e.nestedSortCfg.lastPrecedingItem === precItem && e.nestedSortCfg.lastTouchingFirst === touchingFirst) { + quit = true; + } + e.nestedSortCfg.lastPrecedingItem = precItem; + e.nestedSortCfg.lastShouldNest = shouldNest; + e.nestedSortCfg.lastTouchingFirst = touchingFirst; + if(quit) {return;} + + if (precItem !== null) { + //there is an element on top of this one + //on the same nesting, or smaller + if (shouldNest) { + jQuery.iNestedSortable.nestItem(e, precItem); + } else { + jQuery.iNestedSortable.appendItem(e, precItem); + } + } else if (touchingFirst) { + //no element on top, but touches the first item on the list + jQuery.iNestedSortable.insertOnTop(e); + } + + }, + /* + * Auto scrolls the page when we are dragging an element. + */ + scroll: function(e) { + + //return false; + var sensitivity = e.nestedSortCfg.scrollSensitivity; + var speed = e.nestedSortCfg.scrollSpeed; + var pointer = jQuery.iDrag.dragged.dragCfg.currentPointer; + var docDim = jQuery.iUtil.getScroll(document.body); + if((pointer.y - docDim.ih) - docDim.t > -sensitivity) window.scrollBy(0,speed); + if(pointer.y - docDim.t < sensitivity) window.scrollBy(0,-speed); + if((pointer.x - docDim.iw) - docDim.l > -sensitivity) window.scrollBy(speed,0); + if(pointer.x - docDim.l < sensitivity) window.scrollBy(-speed,0); + + }, + /* + * Called when the item is released after a drag. + * The argument passed in is the dragged element released. + */ + check : function(dragged) { + //A brand new NestedSortable release check + jQuery.iNestedSortable.newCheck(dragged); + + //The legacy release check performed by plain Sortables + return jQuery.iNestedSortable.oldCheck(dragged); + }, + oldCheck : jQuery.iSort.check, + newCheck : function(dragged) { + //removes nesting styling + if (jQuery.iNestedSortable.latestNestingClass && + jQuery.iNestedSortable.currentNesting) + { + jQuery.iNestedSortable.currentNesting + .removeClass(jQuery.iNestedSortable.latestNestingClass); + jQuery.iNestedSortable.currentNesting = null; + jQuery.iNestedSortable.latestNestingClass = ""; + } + + if(jQuery.iDrop.overzone.isNestedSortable) { + jQuery.iDrop.overzone.nestedSortCfg.remeasured = false; + } + + }, + /* + * Called when there is a need to serialize the + * NestedSortable, to send back to the server. The + * parameter is a string with the id of the NestedSortable + * element, or an array of ids. If no parameter is passed, + * all nested sortables in the page will be serialized. The + * return value is an object with a 'hash' parameter, that + * contains a string for use in GET or POST, and a 'o' parameter, + * with contains a JavaScript object representation + * of the item order. + */ + serialize: function(s) { + if(jQuery('#' + s).get(0).isNestedSortable){ + //A brand new NestedSortable serialization + return jQuery.iNestedSortable.newSerialize(s); + } else { + //The legacy serialization + return jQuery.iNestedSortable.oldSerialize(s); + } + }, + oldSerialize: jQuery.iSort.serialize, + newSerialize: function (s) { + var i; + var h = ''; //url get string that represents the element order + var currentPath = ''; //used so the recursive function can build h + var o = {}; //json object that represents the element order + var e; //NestedSortable element being worked on + /* + * This recursive function will build the get string (h) + * and return the object (o) for a given NestedSortable. + */ + var buildHierarchySer = function(context) { + var retVal = []; + thisChildren = jQuery(context).children('.' + jQuery.iSort.collected[s]); + thisChildren.each( function(i) { + + //Extracts part of the HTML element ID that + //will be shown in the serialization, using a RegExp. + var serId = jQuery.attr(this,'id') + if(serId && serId.match) { + serId = serId.match(e.nestedSortCfg.serializeRegExp)[0] + } + + + if (h.length > 0) { + h += '&'; + } + h += s + currentPath + '['+i+'][id]=' + serId; + retVal[i] = {id: serId} + var newContext = jQuery(this).children(e.nestedSortCfg.nestingTag + "." + e.nestedSortCfg.nestingTagClass.split(" ").join(".")).get(0); + var oldPath = currentPath; + currentPath += '['+i+'][children]'; + var thisChildren = buildHierarchySer(newContext) + if (thisChildren.length > 0) { + retVal[i].children = thisChildren; + } + currentPath = oldPath; + }); + return retVal; + }; + + //analises the parameter passed in + if (s) { + if (jQuery.iSort.collected[s] ) { + //when only one NestedSortable id was passed in + e = jQuery('#' + s).get(0); + o[s] = buildHierarchySer(e); + } else { + for ( a in s) { + //when an array of NestedSortables ids was passed in + if (jQuery.iSort.collected[s[a]] ) { + e = jQuery('#' + s[a]).get(0); + o[s[a]] = buildHierarchySer(e); + } + } + } + } else { + //when nothing was passed in (we will serialize all) + for ( i in jQuery.iSort.collected){ + e = jQuery('#' + i).get(0); + o[i] = buildHierarchySer(e); + } + } + return {hash:h, o:o}; + }, + + /* + * Finds the sortable item that is on top of the one being dragged, + * and in a compatible nesting level. Returns null if none was found. + */ + findPrecedingItem : function (e) { + var largestY = 0; + var preceding = jQuery.grep(e.dropCfg.el, function(i) { + //needs to be on top of the one being dragged + var isOnTop = (i.pos.y < jQuery.iDrag.dragged.dragCfg.ny) && (i.pos.y > largestY); + if(!isOnTop) + return false; + + //needs to be on the same nesting level or a "child" level + var isSameLevel; + if(e.nestedSortCfg.rightToLeft) + isSameLevel = (i.pos.x + i.pos.wb + e.nestedSortCfg.snapTolerance > jQuery.iDrag.dragged.dragCfg.nx + jQuery.iDrag.dragged.dragCfg.oC.wb); + else + isSameLevel = (i.pos.x - e.nestedSortCfg.snapTolerance < jQuery.iDrag.dragged.dragCfg.nx); + if(!isSameLevel) + return false; + + //can't be an element that is being dragged + var isBeingDragged = jQuery.iNestedSortable.isBeingDragged(e, i); + if(isBeingDragged) + return false; + + //got here because it is a match + largestY = i.pos.y; + return true; + }); + + if ( preceding.length > 0 ) { + //the last one should be it + return preceding[(preceding.length-1)]; + } else { + //nothing above it + return null; + } + }, + /* + * Checks if the item being dragged is on top and touching the first item on the list. + * Returns true or false. + */ + isTouchingFirstItem : function (e) { + var lowestY; + var firstItem = jQuery.grep(e.dropCfg.el, function(i) { + //needs to be on top of all elements already looked up + var isBefore = (lowestY === undefined || i.pos.y < lowestY); + if (!isBefore) + return false; + + //can't be an element that is being dragged + var isBeingDragged = jQuery.iNestedSortable.isBeingDragged(e, i); + if(isBeingDragged) + return false; + + //got here because it is a match + lowestY = i.pos.y; + return true; + }); + if ( firstItem.length > 0 ) { + //the last one should be it + firstItem = firstItem[(firstItem.length-1)]; + return firstItem.pos.y < jQuery.iDrag.dragged.dragCfg.ny + jQuery.iDrag.dragged.dragCfg.oC.hb && + firstItem.pos.y > jQuery.iDrag.dragged.dragCfg.ny; + } else { + return false; + } + }, + /* + * Checks to see if an element is being dragged. + * You may de dragging an element by itself or by one of his ancestors. + * Returns true or false. + */ + isBeingDragged : function (e, elem) { + var dragged = jQuery.iDrag.dragged; + + //nothing being dragged + if(!dragged) + return false; + + //trivial case + if(elem == dragged) + return true; + + //looks for its ancestors + if ( + jQuery(elem) + .parents("." + e.sortCfg.accept.split(" ").join(".")) + .filter(function() {return this == dragged}).length != 0 + ) + return true; + else + return false; + }, + shouldNestItem : function(e, precedingItem ) { + //there should be a preceding item to be able to nest + if(!precedingItem) return false; + + //This code is to limit the levels of nesting that can be achieved + //Development of this is currently halted. + /* + if( e.nestedSortCfg.nestingLimit !== false) { + //nesting level of the preceding item + var nLevelPrec = jQuery(precedingItem) + .parents("." + e.sortCfg.accept.split(" ").join(".")) + .length; + + //don't allow nesting + if (nLevelPrec >= e.nestedSortCfg.nestingLimit) return false; + + //will hold the maximum level of nesting in the element being dragged + var nLevelDrag = 0; + + //for each leaf element inside the dragged element (that have no elements nested to it) + jQuery(e.nestedSortCfg.nestingTag + "." + e.nestedSortCfg.nestingTagClass.split(" ").join(".") + " > ." + e.sortCfg.accept.split(" ").join(".") + ":first-child", jQuery.iDrag.dragged) + .not("*["+e.nestedSortCfg.nestingTag + "." + e.nestedSortCfg.nestingTagClass.split(" ").join(".")+"]") + .each( function(i) { + var draggedIndex = 0; + //finds out + var parentLength = jQuery(this).parents("." + e.sortCfg.accept.split(" ").join(".")).each( + function(i) { + draggedIndex = i; + return this == jQuery.iDrag.dragged; + } + ).length; + + //here dradraggedIndex holds the index + //of the dragged element in the ancestors array of the leaf element + var thisLevel = parentLength - draggedIndex; + if (thisLevel > nLevelDrag ) + nLevelDrag = thisLevel; + } + ); + + //don't allow nesting + if (nLevelPrec + nLevelDrag > e.nestedSortCfg.nestingLimit) return false; + }*/ + + if (e.nestedSortCfg.rightToLeft) { + return precedingItem.pos.x + precedingItem.pos.wb - (e.nestedSortCfg.nestingPxSpace - e.nestedSortCfg.snapTolerance) > jQuery.iDrag.dragged.dragCfg.nx + jQuery.iDrag.dragged.dragCfg.oC.wb; + } else { + return precedingItem.pos.x + (e.nestedSortCfg.nestingPxSpace - e.nestedSortCfg.snapTolerance) < jQuery.iDrag.dragged.dragCfg.nx; + } + }, + nestItem: function(e, parent) { + //selects the nesting tag inside the parent + var parentNesting = jQuery(parent).children(e.nestedSortCfg.nestingTag + "." + e.nestedSortCfg.nestingTagClass.split(" ").join(".") ); + var helper = jQuery.iSort.helper; + styleHelper = helper.get(0).style; + styleHelper.width = 'auto'; //makes sure helper gets resized properly + + //if there is none, creates it + if ( !parentNesting.size()) { + var newUl = "<" + e.nestedSortCfg.nestingTag + " class='"+e.nestedSortCfg.nestingTagClass+"'>"; + // Place new nesting tag and adds style + parentNesting = jQuery(parent).append(newUl).children(e.nestedSortCfg.nestingTag).css(e.nestedSortCfg.styleToAttach); + } + + //styles the nesting + jQuery.iNestedSortable.updateCurrentNestingClass(e, parentNesting ); + + //does stuff before the helper is removed + jQuery.iNestedSortable.beforeHelperRemove(e); + + //puts the helper in the proper place. + parentNesting.prepend(helper.get(0)); + + //does stuff after the helper is inserted + jQuery.iNestedSortable.afterHelperInsert(e); + }, + appendItem: function(e, itemBefore) { + jQuery.iNestedSortable.updateCurrentNestingClass(e, jQuery(itemBefore).parent() ); + jQuery.iNestedSortable.beforeHelperRemove(e); + jQuery(itemBefore).after(jQuery.iSort.helper.get(0)); + jQuery.iNestedSortable.afterHelperInsert(e); + }, + insertOnTop: function (e) { + jQuery.iNestedSortable.updateCurrentNestingClass(e, e); + jQuery.iNestedSortable.beforeHelperRemove(e); + jQuery(e).prepend(jQuery.iSort.helper.get(0)); + jQuery.iNestedSortable.afterHelperInsert(e); + }, + beforeHelperRemove : function (e) { + //hides the nesting when it becomes empty + var parent = jQuery.iSort.helper.parent(e.nestedSortCfg.nestingTag + "." + e.nestedSortCfg.nestingTagClass.split(" ").join(".")); + var numSiblings = parent + .children("." + e.sortCfg.accept.split(" ").join(".") + ":visible") + .size(); + if(numSiblings === 0 && parent.get(0) !== e) { + parent.hide(); + } + }, + afterHelperInsert : function (e) { + //displays the nesting after something is inserted + jQuery.iSort.helper + .parent() + .show(); + e.nestedSortCfg.remeasured = false; + }, + updateCurrentNestingClass : function(e, nestingElem) { + + var nesting = jQuery(nestingElem); + + if ((e.nestedSortCfg.currentNestingClass) && //makes sure a special class is desired + (!jQuery.iNestedSortable.currentNesting || nesting.get(0) != jQuery.iNestedSortable.currentNesting.get(0)) ){ //avoids doing it on the same elem + + //removes from last nesting + if(jQuery.iNestedSortable.currentNesting) { + jQuery.iNestedSortable.currentNesting + .removeClass(e.nestedSortCfg.currentNestingClass); + } + + if(nesting.get(0) != e) { //not root nesting + jQuery.iNestedSortable.currentNesting = nesting; + + //adds to this one + nesting.addClass(e.nestedSortCfg.currentNestingClass); + + //this is need to remove the styling on "check" + jQuery.iNestedSortable.latestNestingClass = e.nestedSortCfg.currentNestingClass; + } else { + //don't style the "root nesting" + + //cleans up + jQuery.iNestedSortable.currentNesting = null; + jQuery.iNestedSortable.latestNestingClass = ""; + } + } + }, + destroy: function () { + return this.each( + function () { + if(this.isNestedSortable) { + this.nestedSortCfg = null; + this.isNestedSortable = null; + jQuery(this).SortableDestroy(); + } + } + ); + }, + build: function(conf) { + if (conf.accept && jQuery.iUtil && jQuery.iDrag && jQuery.iDrop && jQuery.iSort) + { + this.each( + function() { + this.isNestedSortable = true; + this.nestedSortCfg = { + rightToLeft : conf.rightToLeft ? true : false , + nestingPxSpace : parseInt(conf.nestingPxSpace, 10) || 30 , + currentNestingClass : conf.currentNestingClass ? conf.currentNestingClass : "", + currentParentClass : conf.currentParentClass ? conf.currentParentClass : "", + nestingLimit : conf.nestingLimit ? conf.nestingLimit : false, + scrollSensitivity: conf.scrollSensitivity ? conf.scrollSensitivity : 20, + scrollSpeed: conf.scrollSpeed ? conf.scrollSpeed : 20, + serializeRegExp : conf.serializeRegExp ? conf.serializeRegExp : /[^\-]*$/ + }; + + //a "do nothing" tolerance when nesting/un-nesting, to stop things from jumping up too quickly + this.nestedSortCfg.snapTolerance = parseInt(this.nestedSortCfg.nestingPxSpace * 0.4, 10); + + //the tag that will be used to nest items to parent items + this.nestedSortCfg.nestingTag = this.tagName; + this.nestedSortCfg.nestingTagClass = this.className; + + //style that makes nested elements be padded to the right or to the left + this.nestedSortCfg.styleToAttach = (this.nestedSortCfg.rightToLeft) ? + {"padding-left":0, "padding-right": this.nestedSortCfg.nestingPxSpace + 'px' } + :{"padding-left": this.nestedSortCfg.nestingPxSpace + 'px', "padding-right": 0 }; + jQuery(this.nestedSortCfg.nestingTag, this) + .css(this.nestedSortCfg.styleToAttach); + + } + ); + + //overides checkhover, check and serialize, without losing backwards compatilibity (eg. plain Sortables can stil be used) + jQuery.iSort.checkhover = jQuery.iNestedSortable.checkHover; + jQuery.iSort.check = jQuery.iNestedSortable.check; + jQuery.iSort.serialize = jQuery.iNestedSortable.serialize; + } + + return this.Sortable(conf); + } +} + +//Extends jQuery to add the plugin. +jQuery.fn.extend( + { + NestedSortable : jQuery.iNestedSortable.build, + NestedSortableDestroy: jQuery.iNestedSortable.destroy + } +); \ No newline at end of file Index: wp-includes/js/jquery/interface/ifxslide.js =================================================================== --- wp-includes/js/jquery/interface/ifxslide.js (revision 0) +++ wp-includes/js/jquery/interface/ifxslide.js (revision 0) @@ -0,0 +1,349 @@ +/** + * Interface Elements for jQuery + * FX - slide + * + * http://interface.eyecon.ro + * + * Copyright (c) 2006 Stefan Petre + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * + */ + +/** + * Slides the element + */ +jQuery.fn.extend( + { + /** + * @name SlideInUp + * @description slides the element in up + * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast'] + * @param Function callback (optional) A function to be executed whenever the animation completes. + * @param String easing (optional) The name of the easing effect that you want to use. + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ + SlideInUp : function (speed,callback, easing) + { + return this.queue('interfaceFX', function(){ + new jQuery.fx.slide(this, speed, callback, 'up', 'in', easing); + }); + }, + + /** + * @name SlideOutUp + * @description slides the element out up + * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast'] + * @param Function callback (optional) A function to be executed whenever the animation completes. + * @param String easing (optional) The name of the easing effect that you want to use. + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ + SlideOutUp : function (speed,callback, easing) + { + return this.queue('interfaceFX', function(){ + new jQuery.fx.slide(this, speed, callback, 'up', 'out', easing); + }); + }, + + /** + * @name SlideToggleUp + * @description slides the element in/out up + * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast'] + * @param Function callback (optional) A function to be executed whenever the animation completes. + * @param String easing (optional) The name of the easing effect that you want to use. + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ + SlideToggleUp : function (speed,callback, easing) + { + return this.queue('interfaceFX', function(){ + new jQuery.fx.slide(this, speed, callback, 'up', 'toggle', easing); + }); + }, + + /** + * @name SlideInDown + * @description slides the element in down + * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast'] + * @param Function callback (optional) A function to be executed whenever the animation completes. + * @param String easing (optional) The name of the easing effect that you want to use. + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ + SlideInDown : function (speed,callback, easing) + { + return this.queue('interfaceFX', function(){ + new jQuery.fx.slide(this, speed, callback, 'down', 'in', easing); + }); + }, + + /** + * @name SlideOutDown + * @description slides the element out down + * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast'] + * @param Function callback (optional) A function to be executed whenever the animation completes. + * @param String easing (optional) The name of the easing effect that you want to use. + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ + SlideOutDown : function (speed,callback, easing) + { + return this.queue('interfaceFX', function(){ + new jQuery.fx.slide(this, speed, callback, 'down', 'out', easing); + }); + }, + + /** + * @name SlideToggleDown + * @description slides the element in/out down + * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast'] + * @param Function callback (optional) A function to be executed whenever the animation completes. + * @param String easing (optional) The name of the easing effect that you want to use. + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ + SlideToggleDown : function (speed,callback, easing) + { + return this.queue('interfaceFX', function(){ + new jQuery.fx.slide(this, speed, callback, 'down', 'toggle', easing); + }); + }, + + /** + * @name SlideInLeft + * @description slides the element in left + * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast'] + * @param Function callback (optional) A function to be executed whenever the animation completes. + * @param String easing (optional) The name of the easing effect that you want to use. + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ + SlideInLeft : function (speed,callback, easing) + { + return this.queue('interfaceFX', function(){ + new jQuery.fx.slide(this, speed, callback, 'left', 'in', easing); + }); + }, + + /** + * @name SlideOutLeft + * @description slides the element out left + * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast'] + * @param Function callback (optional) A function to be executed whenever the animation completes. + * @param String easing (optional) The name of the easing effect that you want to use. + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ + SlideOutLeft : function (speed,callback, easing) + { + return this.queue('interfaceFX', function(){ + new jQuery.fx.slide(this, speed, callback, 'left', 'out', easing); + }); + }, + + /** + * @name SlideToggleLeft + * @description slides the element in/out left + * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast'] + * @param Function callback (optional) A function to be executed whenever the animation completes. + * @param String easing (optional) The name of the easing effect that you want to use. + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ + SlideToggleLeft : function (speed,callback, easing) + { + return this.queue('interfaceFX', function(){ + new jQuery.fx.slide(this, speed, callback, 'left', 'toggle', easing); + }); + }, + + /** + * @name SlideInRight + * @description slides the element in right + * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast'] + * @param Function callback (optional) A function to be executed whenever the animation completes. + * @param String easing (optional) The name of the easing effect that you want to use. + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ + SlideInRight : function (speed,callback, easing) + { + return this.queue('interfaceFX', function(){ + new jQuery.fx.slide(this, speed, callback, 'right', 'in', easing); + }); + }, + + /** + * @name SlideOutRight + * @description slides the element out right + * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast'] + * @param Function callback (optional) A function to be executed whenever the animation completes. + * @param String easing (optional) The name of the easing effect that you want to use. + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ + SlideOutRight : function (speed,callback, easing) + { + return this.queue('interfaceFX', function(){ + new jQuery.fx.slide(this, speed, callback, 'right', 'out', easing); + }); + }, + + /** + * @name SlideToggleRight + * @description slides the element in/out right + * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast'] + * @param Function callback (optional) A function to be executed whenever the animation completes. + * @param String easing (optional) The name of the easing effect that you want to use. + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ + SlideToggleRight : function (speed,callback, easing) + { + return this.queue('interfaceFX', function(){ + new jQuery.fx.slide(this, speed, callback, 'right', 'toggle', easing); + }); + } + } +); + +jQuery.fx.slide = function(e, speed, callback, direction, type, easing) +{ + if (!jQuery.fxCheckTag(e)) { + jQuery.dequeue(e, 'interfaceFX'); + return false; + } + var z = this; + z.el = jQuery(e); + z.easing = typeof callback == 'string' ? callback : easing||null; + z.callback = typeof callback == 'function' ? callback : null; + if ( type == 'toggle') { + type = z.el.css('display') == 'none' ? 'in' : 'out'; + } + if (!e.ifxFirstDisplay) + e.ifxFirstDisplay = z.el.css('display'); + z.el.show(); + + z.speed = speed; + z.fx = jQuery.fx.buildWrapper(e); + + z.type = type; + z.direction = direction; + z.complete = function() + { + if(z.type == 'out') + z.el.css('visibility', 'hidden'); + jQuery.fx.destroyWrapper(z.fx.wrapper.get(0), z.fx.oldStyle); + if(z.type == 'in'){ + z.el.css('display', z.el.get(0).ifxFirstDisplay == 'none' ? 'block' : z.el.get(0).ifxFirstDisplay); + } else { + z.el.css('display', 'none'); + z.el.css('visibility', 'visible'); + } + if (z.callback && z.callback.constructor == Function) { + z.callback.apply(z.el.get(0)); + } + jQuery.dequeue(z.el.get(0), 'interfaceFX'); + }; + switch (z.direction) { + case 'up': + z.ef = new jQuery.fx( + z.el.get(0), + jQuery.speed( + z.speed, + z.easing, + z.complete + ), + 'top' + ); + z.efx = new jQuery.fx( + z.fx.wrapper.get(0), + jQuery.speed( + z.speed, + z.easing + ), + 'height' + ); + if (z.type == 'in') { + z.ef.custom (-z.fx.oldStyle.sizes.hb, 0); + z.efx.custom(0, z.fx.oldStyle.sizes.hb); + } else { + z.ef.custom (0, -z.fx.oldStyle.sizes.hb); + z.efx.custom (z.fx.oldStyle.sizes.hb, 0); + } + break; + case 'down': + z.ef = new jQuery.fx( + z.el.get(0), + jQuery.speed( + z.speed, + z.easing, + z.complete + ), + 'top' + ); + if (z.type == 'in') { + z.ef.custom (z.fx.oldStyle.sizes.hb, 0); + } else { + z.ef.custom (0, z.fx.oldStyle.sizes.hb); + } + break; + case 'left': + z.ef = new jQuery.fx( + z.el.get(0), + jQuery.speed( + z.speed, + z.easing, + z.complete + ), + 'left' + ); + z.efx = new jQuery.fx( + z.fx.wrapper.get(0), + jQuery.speed( + z.speed, + z.easing + ), + 'width' + ); + if (z.type == 'in') { + z.ef.custom (-z.fx.oldStyle.sizes.wb, 0); + z.efx.custom (0, z.fx.oldStyle.sizes.wb); + } else { + z.ef.custom (0, -z.fx.oldStyle.sizes.wb); + z.efx.custom (z.fx.oldStyle.sizes.wb, 0); + } + break; + case 'right': + z.ef = new jQuery.fx( + z.el.get(0), + jQuery.speed( + z.speed, + z.easing, + z.complete + ), + 'left' + ); + if (z.type == 'in') { + z.ef.custom (z.fx.oldStyle.sizes.wb, 0); + } else { + z.ef.custom (0, z.fx.oldStyle.sizes.wb); + } + break; + } +}; Index: wp-includes/js/jquery/interface/ifxscrollto.js =================================================================== --- wp-includes/js/jquery/interface/ifxscrollto.js (revision 0) +++ wp-includes/js/jquery/interface/ifxscrollto.js (revision 0) @@ -0,0 +1,111 @@ +/** + * Interface Elements for jQuery + * FX - scroll to + * + * http://interface.eyecon.ro + * + * Copyright (c) 2006 Stefan Petre + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * + */ +/** + * Applies a scrolling effect to document until the element gets into viewport + */ +jQuery.fn.extend ( + { + /** + * @name ScrollTo + * @description scrolls the document until the lement gets into viewport + * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast'] + * @param String axis (optional) whatever to scroll on vertical, horizontal or both axis ['vertical'|'horizontal'|null] + * @param String easing (optional) The name of the easing effect that you want to use. + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ + ScrollTo : function(speed, axis, easing) { + o = jQuery.speed(speed); + return this.queue('interfaceFX',function(){ + new jQuery.fx.ScrollTo(this, o, axis, easing); + }); + }, + /** + * @name ScrollToAnchors + * @description all links to '#elementId' will animate scroll + * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast'] + * @param String axis (optional) whatever to scroll on vertical, horizontal or both axis ['vertical'|'horizontal'|null] + * @param String easing (optional) The name of the easing effect that you want to use. + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ + /*inspired by David Maciejewski www.macx.de*/ + ScrollToAnchors : function(speed, axis, easing) { + return this.each( + function() + { + jQuery('a[@href*="#"]', this).click( + function(e) + { + parts = this.href.split('#'); + jQuery('#' + parts[1]).ScrollTo(speed, axis, easing); + return false; + } + ); + } + ) + } + } +); + +jQuery.fx.ScrollTo = function (e, o, axis, easing) +{ + var z = this; + z.o = o; + z.e = e; + z.axis = /vertical|horizontal/.test(axis) ? axis : false; + z.easing = easing; + p = jQuery.iUtil.getPosition(e); + s = jQuery.iUtil.getScroll(); + z.clear = function(){clearInterval(z.timer);z.timer=null;jQuery.dequeue(z.e, 'interfaceFX');}; + z.t=(new Date).getTime(); + s.h = s.h > s.ih ? (s.h - s.ih) : s.h; + s.w = s.w > s.iw ? (s.w - s.iw) : s.w; + z.endTop = p.y > s.h ? s.h : p.y; + z.endLeft = p.x > s.w ? s.w : p.x; + z.startTop = s.t; + z.startLeft = s.l; + z.step = function(){ + var t = (new Date).getTime(); + var n = t - z.t; + var p = n / z.o.duration; + if (t >= z.o.duration+z.t) { + z.clear(); + setTimeout(function(){z.scroll(z.endTop, z.endLeft)},13); + } else { + if (!z.axis || z.axis == 'vertical') { + if (!jQuery.easing || !jQuery.easing[z.easing]) { + st = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.endTop-z.startTop) + z.startTop; + } else { + st = jQuery.easing[z.easing](p, n, z.startTop, (z.endTop - z.startTop), z.o.duration); + } + } else { + st = z.startTop; + } + if (!z.axis || z.axis == 'horizontal') { + if (!jQuery.easing || !jQuery.easing[z.easing]) { + sl = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.endLeft-z.startLeft) + z.startLeft; + } else { + sl = jQuery.easing[z.easing](p, n, z.startLeft, (z.endLeft - z.startLeft), z.o.duration); + } + } else { + sl = z.startLeft; + } + z.scroll(st, sl); + } + }; + z.scroll = function (t, l){window.scrollTo(l, t);}; + z.timer=setInterval(function(){z.step();},13); +}; \ No newline at end of file Index: wp-includes/js/jquery/interface/islideshow.js =================================================================== --- wp-includes/js/jquery/interface/islideshow.js (revision 0) +++ wp-includes/js/jquery/interface/islideshow.js (revision 0) @@ -0,0 +1,422 @@ +/** + * Interface Elements for jQuery + * Slideshow + * + * http://interface.eyecon.ro + * + * Copyright (c) 2006 Stefan Petre + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + */ + + +/** + * Creates an image slideshow. The slideshow can autoplay slides, each image can have caption, navigation links: next, prev, each slide. A page may have more then one slideshow, eachone working independently. Each slide can be bookmarked. The source images can be defined by JavaScript in slideshow options or by HTML placing images inside container. + * + * + * + * @name Slideshow + * @description Creates an image slideshow. The slideshow can autoplay slides, each image can have caption, navigation links: next, prev, each slide. A page may have more then one slideshow, eachone working independently. Each slide can be bookmarked. The source images can be defined by JavaScript in slideshow options or by HTML placing images inside container. + * @param Hash hash A hash of parameters + * @option String container container ID + * @option String loader path to loading indicator image + * @option String linksPosition (optional) images links position ['top'|'bottom'|null] + * @option String linksClass (optional) images links cssClass + * @option String linksSeparator (optional) images links separator + * @option Integer fadeDuration fade animation duration in miliseconds + * @option String activeLinkClass (optional) active image link CSS class + * @option String nextslideClass (optional) next image CSS class + * @option String prevslideClass (optional) previous image CSS class + * @option String captionPosition (optional) image caption position ['top'|'bottom'|null] + * @option String captionClass (optional) image caption CSS class + * @option String autoplay (optional) seconds to wait untill next images is displayed. This option will make the slideshow to autoplay. + * @option String random (optional) if slideshow autoplayes the images can be randomized + * @option Array images (optional) array of hash with keys 'src' (path to image) and 'cation' (image caption) for images + * + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ +jQuery.islideshow = { + slideshows: [], + gonext : function() + { + this.blur(); + slideshow = this.parentNode; + id = jQuery.attr(slideshow, 'id'); + if (jQuery.islideshow.slideshows[id] != null) { + window.clearInterval(jQuery.islideshow.slideshows[id]); + } + slide = slideshow.ss.currentslide + 1; + if (slideshow.ss.images.length < slide) { + slide = 1; + } + images = jQuery('img', slideshow.ss.holder); + slideshow.ss.currentslide = slide; + if (images.size() > 0) { + images.fadeOut( + slideshow.ss.fadeDuration, + jQuery.islideshow.showImage + ); + } + }, + goprev : function() + { + this.blur(); + slideshow = this.parentNode; + id = jQuery.attr(slideshow, 'id'); + if (jQuery.islideshow.slideshows[id] != null) { + window.clearInterval(jQuery.islideshow.slideshows[id]); + } + slide = slideshow.ss.currentslide - 1; + images = jQuery('img', slideshow.ss.holder); + if (slide < 1) { + slide = slideshow.ss.images.length ; + } + slideshow.ss.currentslide = slide; + if (images.size() > 0) { + images.fadeOut( + slideshow.ss.fadeDuration, + jQuery.islideshow.showImage + ); + } + }, + timer : function (c) + { + slideshow = document.getElementById(c); + if (slideshow.ss.random) { + slide = slideshow.ss.currentslide; + while(slide == slideshow.ss.currentslide) { + slide = 1 + parseInt(Math.random() * slideshow.ss.images.length); + } + } else { + slide = slideshow.ss.currentslide + 1; + if (slideshow.ss.images.length < slide) { + slide = 1; + } + } + images = jQuery('img', slideshow.ss.holder); + slideshow.ss.currentslide = slide; + if (images.size() > 0) { + images.fadeOut( + slideshow.ss.fadeDuration, + jQuery.islideshow.showImage + ); + } + }, + go : function(o) + { + var slideshow; + if (o && o.constructor == Object) { + if (o.loader) { + slideshow = document.getElementById(o.loader.slideshow); + url = window.location.href.split("#"); + o.loader.onload = null; + if (url.length == 2) { + slide = parseInt(url[1]); + show = url[1].replace(slide,''); + if (jQuery.attr(slideshow,'id') != show) { + slide = 1; + } + } else { + slide = 1; + } + } + if(o.link) { + o.link.blur(); + slideshow = o.link.parentNode.parentNode; + id = jQuery.attr(slideshow, 'id'); + if (jQuery.islideshow.slideshows[id] != null) { + window.clearInterval(jQuery.islideshow.slideshows[id]); + } + url = o.link.href.split("#"); + slide = parseInt(url[1]); + show = url[1].replace(slide,''); + if (jQuery.attr(slideshow,'id') != show) { + slide = 1; + } + } + if (slideshow.ss.images.length < slide || slide < 1) { + slide = 1; + } + slideshow.ss.currentslide = slide; + slidePos = jQuery.iUtil.getSize(slideshow); + slidePad = jQuery.iUtil.getPadding(slideshow); + slideBor = jQuery.iUtil.getBorder(slideshow); + if (slideshow.ss.prevslide) { + slideshow.ss.prevslide.o.css('display', 'none'); + } + if (slideshow.ss.nextslide) { + slideshow.ss.nextslide.o.css('display', 'none'); + } + + //center loader + if (slideshow.ss.loader) { + y = parseInt(slidePad.t) + parseInt(slideBor.t); + if (slideshow.ss.slideslinks) { + if (slideshow.ss.slideslinks.linksPosition == 'top') { + y += slideshow.ss.slideslinks.dimm.hb; + } else { + slidePos.h -= slideshow.ss.slideslinks.dimm.hb; + } + } + if (slideshow.ss.slideCaption) { + if (slideshow.ss.slideCaption && slideshow.ss.slideCaption.captionPosition == 'top') { + y += slideshow.ss.slideCaption.dimm.hb; + } else { + slidePos.h -= slideshow.ss.slideCaption.dimm.hb; + } + } + if (!slideshow.ss.loaderWidth) { + slideshow.ss.loaderHeight = o.loader ? o.loader.height : (parseInt(slideshow.ss.loader.css('height'))||0); + slideshow.ss.loaderWidth = o.loader ? o.loader.width : (parseInt(slideshow.ss.loader.css('width'))||0); + } + + slideshow.ss.loader.css('top', y + (slidePos.h - slideshow.ss.loaderHeight)/2 + 'px'); + slideshow.ss.loader.css('left', (slidePos.wb - slideshow.ss.loaderWidth)/2 + 'px'); + slideshow.ss.loader.css('display', 'block'); + } + + //getimage + images = jQuery('img', slideshow.ss.holder); + if (images.size() > 0) { + images.fadeOut( + slideshow.ss.fadeDuration, + jQuery.islideshow.showImage + ); + } else { + lnk = jQuery('a', slideshow.ss.slideslinks.o).get(slide-1); + jQuery(lnk).addClass(slideshow.ss.slideslinks.activeLinkClass); + var img = new Image(); + img.slideshow = jQuery.attr(slideshow,'id'); + img.slide = slide-1; + img.src = slideshow.ss.images[slideshow.ss.currentslide-1].src ; + if (img.complete) { + img.onload = null; + jQuery.islideshow.display.apply(img); + } else { + img.onload = jQuery.islideshow.display; + } + //slideshow.ss.holder.html(''); + if (slideshow.ss.slideCaption) { + slideshow.ss.slideCaption.o.html(slideshow.ss.images[slide-1].caption); + } + //jQuery('img', slideshow.ss.holder).bind('load',jQuery.slideshowDisplay); + } + } + }, + showImage : function() + { + slideshow = this.parentNode.parentNode; + slideshow.ss.holder.css('display','none'); + if (slideshow.ss.slideslinks.activeLinkClass) { + lnk = jQuery('a', slideshow.ss.slideslinks.o).removeClass(slideshow.ss.slideslinks.activeLinkClass).get(slideshow.ss.currentslide - 1); + jQuery(lnk).addClass(slideshow.ss.slideslinks.activeLinkClass); + } + //slideshow.ss.holder.html(''); + + var img = new Image(); + img.slideshow = jQuery.attr(slideshow,'id'); + img.slide = slideshow.ss.currentslide - 1; + img.src = slideshow.ss.images[slideshow.ss.currentslide - 1].src ; + if (img.complete) { + img.onload = null; + jQuery.islideshow.display.apply(img); + } else { + img.onload = jQuery.islideshow.display; + } + if (slideshow.ss.slideCaption) { + slideshow.ss.slideCaption.o.html(slideshow.ss.images[slideshow.ss.currentslide-1].caption); + } + //jQuery('img', slideshow.ss.holder).bind('load',jQuery.slideshowDisplay); + }, + display : function () + { + slideshow = document.getElementById(this.slideshow); + if (slideshow.ss.prevslide) { + slideshow.ss.prevslide.o.css('display', 'none'); + } + if (slideshow.ss.nextslide) { + slideshow.ss.nextslide.o.css('display', 'none'); + } + slidePos = jQuery.iUtil.getSize(slideshow); + y = 0; + if (slideshow.ss.slideslinks) { + if (slideshow.ss.slideslinks.linksPosition == 'top') { + y += slideshow.ss.slideslinks.dimm.hb; + } else { + slidePos.h -= slideshow.ss.slideslinks.dimm.hb; + } + } + if (slideshow.ss.slideCaption) { + if (slideshow.ss.slideCaption && slideshow.ss.slideCaption.captionPosition == 'top') { + y += slideshow.ss.slideCaption.dimm.hb; + } else { + slidePos.h -= slideshow.ss.slideCaption.dimm.hb; + } + } + par = jQuery('.slideshowHolder', slideshow); + y = y + (slidePos.h - this.height)/2 ; + x = (slidePos.wb - this.width)/2; + slideshow.ss.holder.css('top', y + 'px').css('left', x + 'px').html(''); + slideshow.ss.holder.fadeIn(slideshow.ss.fadeDuration); + nextslide = slideshow.ss.currentslide + 1; + if (nextslide > slideshow.ss.images.length) { + nextslide = 1; + } + prevslide = slideshow.ss.currentslide - 1; + if (prevslide < 1) { + prevslide = slideshow.ss.images.length; + } + slideshow.ss.nextslide.o + .css('display','block') + .css('top', y + 'px') + .css('left', x + 2 * this.width/3 + 'px') + .css('width', this.width/3 + 'px') + .css('height', this.height + 'px') + .attr('title', slideshow.ss.images[nextslide-1].caption); + slideshow.ss.nextslide.o.get(0).href = '#' + nextslide + jQuery.attr(slideshow, 'id'); + slideshow.ss.prevslide.o + .css('display','block') + .css('top', y + 'px') + .css('left', x + 'px') + .css('width', this.width/3 + 'px') + .css('height', this.height + 'px') + .attr('title', slideshow.ss.images[prevslide-1].caption); + slideshow.ss.prevslide.o.get(0).href = '#' + prevslide + jQuery.attr(slideshow, 'id'); + }, + build : function(o) + { + if (!o || !o.container || jQuery.islideshow.slideshows[o.container]) + return; + var container = jQuery('#' + o.container); + var el = container.get(0); + + if (el.style.position != 'absolute' && el.style.position != 'relative') { + el.style.position = 'relative'; + } + el.style.overflow = 'hidden'; + if (container.size() == 0) + return; + el.ss = {}; + + el.ss.images = o.images ? o.images : []; + el.ss.random = o.random && o.random == true || false; + imgs = el.getElementsByTagName('IMG'); + for(i = 0; i< imgs.length; i++) { + indic = el.ss.images.length; + el.ss.images[indic] = {src:imgs[i].src, caption:imgs[i].title||imgs[i].alt||''}; + } + + if (el.ss.images.length == 0) { + return; + } + + el.ss.oP = jQuery.extend( + jQuery.iUtil.getPosition(el), + jQuery.iUtil.getSize(el) + ); + el.ss.oPad = jQuery.iUtil.getPadding(el); + el.ss.oBor = jQuery.iUtil.getBorder(el); + t = parseInt(el.ss.oPad.t) + parseInt(el.ss.oBor.t); + b = parseInt(el.ss.oPad.b) + parseInt(el.ss.oBor.b); + jQuery('img', el).remove(); + el.ss.fadeDuration = o.fadeDuration ? o.fadeDuration : 500; + if (o.linksPosition || o.linksClass || o.activeLinkClass) { + el.ss.slideslinks = {}; + container.append(''); + el.ss.slideslinks.o = jQuery('.slideshowLinks', el); + if (o.linksClass) { + el.ss.slideslinks.linksClass = o.linksClass; + el.ss.slideslinks.o.addClass(o.linksClass); + } + if (o.activeLinkClass) { + el.ss.slideslinks.activeLinkClass = o.activeLinkClass; + } + el.ss.slideslinks.o.css('position','absolute').css('width', el.ss.oP.w + 'px'); + if (o.linksPosition && o.linksPosition == 'top') { + el.ss.slideslinks.linksPosition = 'top'; + el.ss.slideslinks.o.css('top',t + 'px'); + } else { + el.ss.slideslinks.linksPosition = 'bottom'; + el.ss.slideslinks.o.css('bottom',b + 'px'); + } + el.ss.slideslinks.linksSeparator = o.linksSeparator ? o.linksSeparator : ' '; + for (var i=0; i' + indic + '' + (indic != el.ss.images.length ? el.ss.slideslinks.linksSeparator : '')); + } + jQuery('a', el.ss.slideslinks.o).bind( + 'click', + function() + { + jQuery.islideshow.go({link:this}) + } + ); + el.ss.slideslinks.dimm = jQuery.iUtil.getSize(el.ss.slideslinks.o.get(0)); + } + if (o.captionPosition || o.captionClass) { + el.ss.slideCaption = {}; + container.append('
 
'); + el.ss.slideCaption.o = jQuery('.slideshowCaption', el); + if (o.captionClass) { + el.ss.slideCaption.captionClass = o.captionClass; + el.ss.slideCaption.o.addClass(o.captionClass); + } + el.ss.slideCaption.o.css('position','absolute').css('width', el.ss.oP.w + 'px'); + if (o.captionPosition&& o.captionPosition == 'top') { + el.ss.slideCaption.captionPosition = 'top'; + el.ss.slideCaption.o.css('top', (el.ss.slideslinks && el.ss.slideslinks.linksPosition == 'top' ? el.ss.slideslinks.dimm.hb + t : t) + 'px'); + } else { + el.ss.slideCaption.captionPosition = 'bottom'; + el.ss.slideCaption.o.css('bottom', (el.ss.slideslinks && el.ss.slideslinks.linksPosition == 'bottom' ? el.ss.slideslinks.dimm.hb + b : b) + 'px'); + } + el.ss.slideCaption.dimm = jQuery.iUtil.getSize(el.ss.slideCaption.o.get(0)); + } + + if (o.nextslideClass) { + el.ss.nextslide = {nextslideClass:o.nextslideClass}; + container.append(' '); + el.ss.nextslide.o = jQuery('.slideshowNextSlide', el); + el.ss.nextslide.o.css('position', 'absolute').css('display', 'none').css('overflow','hidden').css('fontSize', '30px').addClass(el.ss.nextslide.nextslideClass); + el.ss.nextslide.o.bind('click', jQuery.islideshow.gonext); + } + if (o.prevslideClass) { + el.ss.prevslide= {prevslideClass:o.prevslideClass}; + container.append(' '); + el.ss.prevslide.o = jQuery('.slideshowPrevslide', el); + el.ss.prevslide.o.css('position', 'absolute').css('display', 'none').css('overflow','hidden').css('fontSize', '30px').addClass(el.ss.prevslide.prevslideClass); + el.ss.prevslide.o.bind('click', jQuery.islideshow.goprev); + } + + container.prepend('
'); + el.ss.holder = jQuery('.slideshowHolder', el); + el.ss.holder.css('position','absolute').css('top','0px').css('left','0px').css('display', 'none'); + if (o.loader) { + container.prepend(''); + el.ss.loader = jQuery('.slideshowLoader', el); + el.ss.loader.css('position', 'absolute'); + var img = new Image(); + img.slideshow = o.container; + img.src = o.loader; + if (img.complete) { + img.onload = null; + jQuery.islideshow.go({loader:img}); + } else { + img.onload = function() + { + jQuery.islideshow.go({loader:this}); + }; + } + } else { + jQuery.islideshow.go({container:el}); + } + + if(o.autoplay) { + time = parseInt(o.autoplay) * 1000; + } + jQuery.islideshow.slideshows[o.container] = o.autoplay ? window.setInterval('jQuery.islideshow.timer(\'' + o.container + '\')', time) : null; + } +}; +jQuery.slideshow = jQuery.islideshow.build; \ No newline at end of file Index: wp-includes/js/jquery/interface/carousel.js =================================================================== --- wp-includes/js/jquery/interface/carousel.js (revision 0) +++ wp-includes/js/jquery/interface/carousel.js (revision 0) @@ -0,0 +1,257 @@ +/** + * Interface Elements for jQuery + * 3D Carousel + * + * http://interface.eyecon.ro + * + * Copyright (c) 2006 Stefan Petre + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + */ +/** + * Created a 3D Carousel from a list of images, with reflections and animated by mouse position + * + * @example window.onload = + * function() + * { + * $('#carousel').Carousel( + * { + * itemWidth: 110, + * itemHeight: 62, + * itemMinWidth: 50, + * items: 'a', + * reflections: .5, + * rotationSpeed: 1.8 + * } + * ); + * } + * HTML + * + * CSS + * #carousel + * { + * width: 700px; + * height: 150px; + * background-color: #111; + * position: absolute; + * top: 200px; + * left: 100px; + * } + * #carousel a + * { + * position: absolute; + * width: 110px; + * } + * + * @desc Creates a 3D carousel from all images inside div tag with id 'carousel' + * + * + * @name 3D Carousel + * @description Created a 3D Carousel from a list of images, with reflections and animated by mouse position + * @param Hash hash A hash of parameters + * @option String items items selection + * @option Integer itemWidth the max width for each item + * @option Integer itemHeight the max height for each item + * @option Integer itemMinWidth the minimum width for each item, the height is automaticaly calculated to keep proportions + * @option Float rotationSpeed the speed for rotation animation + * @option Float reflectionSize the reflection size a fraction from items' height + * + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ +jQuery.iCarousel = { + + build : function(options) + { + return this.each( + function() + { + var el = this; + var increment = 2*Math.PI/360; + var maxRotation = 2*Math.PI; + if(jQuery(el).css('position') != 'relative' && jQuery(el).css('position') != 'absolute') { + jQuery(el).css('position', 'relative'); + } + el.carouselCfg = { + items : jQuery(options.items, this), + itemWidth : options.itemWidth, + itemHeight : options.itemHeight, + itemMinWidth : options.itemMinWidth, + maxRotation : maxRotation, + size : jQuery.iUtil.getSize(this), + position : jQuery.iUtil.getPosition(this), + start : Math.PI/2, + rotationSpeed : options.rotationSpeed, + reflectionSize : options.reflections, + reflections : [], + protectRotation : false, + increment: 2*Math.PI/360 + }; + el.carouselCfg.radiusX = (el.carouselCfg.size.w - el.carouselCfg.itemWidth)/2; + el.carouselCfg.radiusY = (el.carouselCfg.size.h - el.carouselCfg.itemHeight - el.carouselCfg.itemHeight * el.carouselCfg.reflectionSize)/2; + el.carouselCfg.step = 2*Math.PI/el.carouselCfg.items.size(); + el.carouselCfg.paddingX = el.carouselCfg.size.w/2; + el.carouselCfg.paddingY = el.carouselCfg.size.h/2 - el.carouselCfg.itemHeight * el.carouselCfg.reflectionSize; + var reflexions = document.createElement('div'); + jQuery(reflexions) + .css( + { + position: 'absolute', + zIndex: 1, + top: 0, + left: 0 + } + ); + jQuery(el).append(reflexions); + el.carouselCfg.items + .each( + function(nr) + { + image = jQuery('img', this).get(0); + height = parseInt(el.carouselCfg.itemHeight*el.carouselCfg.reflectionSize); + if (jQuery.browser.msie) { + canvas = document.createElement('img'); + jQuery(canvas).css('position', 'absolute'); + canvas.src = image.src; + canvas.style.filter = 'flipv progid:DXImageTransform.Microsoft.Alpha(opacity=60, style=1, finishOpacity=0, startx=0, starty=0, finishx=0)'; + + } else { + canvas = document.createElement('canvas'); + if (canvas.getContext) { + context = canvas.getContext("2d"); + canvas.style.position = 'absolute'; + canvas.style.height = height +'px'; + canvas.style.width = el.carouselCfg.itemWidth+'px'; + canvas.height = height; + canvas.width = el.carouselCfg.itemWidth; + context.save(); + + context.translate(0,height); + context.scale(1,-1); + + context.drawImage( + image, + 0, + 0, + el.carouselCfg.itemWidth, + height + ); + + context.restore(); + + context.globalCompositeOperation = "destination-out"; + var gradient = context.createLinearGradient( + 0, + 0, + 0, + height + ); + + gradient.addColorStop(1, "rgba(255, 255, 255, 1)"); + gradient.addColorStop(0, "rgba(255, 255, 255, 0.6)"); + + context.fillStyle = gradient; + if (navigator.appVersion.indexOf('WebKit') != -1) { + context.fill(); + } else { + context.fillRect( + 0, + 0, + el.carouselCfg.itemWidth, + height + ); + } + } + } + + el.carouselCfg.reflections[nr] = canvas; + jQuery(reflexions).append(canvas); + } + ) + .bind( + 'mouseover', + function(e) + { + el.carouselCfg.protectRotation = true; + el.carouselCfg.speed = el.carouselCfg.increment*0.1 * el.carouselCfg.speed / Math.abs(el.carouselCfg.speed); + return false; + } + ) + .bind( + 'mouseout', + function(e) + { + el.carouselCfg.protectRotation = false; + return false; + } + ); + jQuery.iCarousel.positionItems(el); + el.carouselCfg.speed = el.carouselCfg.increment*0.2; + el.carouselCfg.rotationTimer = window.setInterval( + function() + { + el.carouselCfg.start += el.carouselCfg.speed; + if (el.carouselCfg.start > maxRotation) + el.carouselCfg.start = 0; + jQuery.iCarousel.positionItems(el); + }, + 20 + ); + jQuery(el) + .bind( + 'mouseout', + function() + { + el.carouselCfg.speed = el.carouselCfg.increment*0.2 * el.carouselCfg.speed / Math.abs(el.carouselCfg.speed); + } + ) + .bind( + 'mousemove', + function(e) + { + if (el.carouselCfg.protectRotation == false) { + pointer = jQuery.iUtil.getPointer(e); + mousex = el.carouselCfg.size.w - pointer.x + el.carouselCfg.position.x; + el.carouselCfg.speed = el.carouselCfg.rotationSpeed * el.carouselCfg.increment * (el.carouselCfg.size.w/2 - mousex) / (el.carouselCfg.size.w/2); + } + } + ); + } + ); + }, + + positionItems : function(el) + { + el.carouselCfg.items.each( + function (nr) + { + angle = el.carouselCfg.start+nr*el.carouselCfg.step; + x = el.carouselCfg.radiusX*Math.cos(angle); + y = el.carouselCfg.radiusY*Math.sin(angle) ; + itemZIndex = parseInt(100*(el.carouselCfg.radiusY+y)/(2*el.carouselCfg.radiusY)); + parte = (el.carouselCfg.radiusY+y)/(2*el.carouselCfg.radiusY); + + width = parseInt((el.carouselCfg.itemWidth - el.carouselCfg.itemMinWidth) * parte + el.carouselCfg.itemMinWidth); + height = parseInt(width * el.carouselCfg.itemHeight / el.carouselCfg.itemWidth); + this.style.top = el.carouselCfg.paddingY + y - height/2 + "px"; + this.style.left = el.carouselCfg.paddingX + x - width/2 + "px"; + this.style.width = width + "px"; + this.style.height = height + "px"; + this.style.zIndex = itemZIndex; + el.carouselCfg.reflections[nr].style.top = parseInt(el.carouselCfg.paddingY + y + height - 1 - height/2) + "px"; + el.carouselCfg.reflections[nr].style.left = parseInt(el.carouselCfg.paddingX + x - width/2) + "px"; + el.carouselCfg.reflections[nr].style.width = width + "px"; + el.carouselCfg.reflections[nr].style.height = parseInt(height * el.carouselCfg.reflectionSize) + "px"; + } + ); + } +}; +jQuery.fn.Carousel = jQuery.iCarousel.build; \ No newline at end of file Index: wp-includes/js/jquery/interface/idrop.js =================================================================== --- wp-includes/js/jquery/interface/idrop.js (revision 0) +++ wp-includes/js/jquery/interface/idrop.js (revision 0) @@ -0,0 +1,323 @@ +/** + * Interface Elements for jQuery + * Droppables + * + * http://interface.eyecon.ro + * + * Copyright (c) 2006 Stefan Petre + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * + */ + +/** + * With the Draggables plugin, Droppable allows you to create drop zones for draggable elements. + * + * @name Droppable + * @cat Plugins/Interface + * @param Hash options A hash of options + * @option String accept The class name for draggables to get accepted by the droppable (mandatory) + * @option String activeclass When an acceptable draggable is moved, the droppable gets this class + * @option String hoverclass When an acceptable draggable is inside the droppable, the droppable gets + * this class + * @option String tolerance Choose from 'pointer', 'intersect', or 'fit'. The pointer options means + * that the pointer must be inside the droppable in order for the draggable + * to be dropped. The intersect option means that the draggable must intersect + * the droppable. The fit option means that the entire draggable must be + * inside the droppable. + * @option Function onDrop When an acceptable draggable is dropped on a droppable, this callback is + * called. It passes the draggable DOMElement as a parameter. + * @option Function onHover When an acceptable draggable is hovered over a droppable, this callback + * is called. It passes the draggable DOMElement as a parameter. + * @option Function onOut When an acceptable draggable leaves a droppable, this callback is called. + * It passes the draggable DOMElement as a parameter. + * @example $('#dropzone1').Droppable( + * { + * accept : 'dropaccept', + * activeclass: 'dropzoneactive', + * hoverclass: 'dropzonehover', + * ondrop: function (drag) { + * alert(this); //the droppable + * alert(drag); //the draggable + * }, + * fit: true + * } + * ) + */ + +jQuery.iDrop = { + fit : function (zonex, zoney, zonew, zoneh) + { + return zonex <= jQuery.iDrag.dragged.dragCfg.nx && + (zonex + zonew) >= (jQuery.iDrag.dragged.dragCfg.nx + jQuery.iDrag.dragged.dragCfg.oC.w) && + zoney <= jQuery.iDrag.dragged.dragCfg.ny && + (zoney + zoneh) >= (jQuery.iDrag.dragged.dragCfg.ny + jQuery.iDrag.dragged.dragCfg.oC.h) ? true :false; + }, + intersect : function (zonex, zoney, zonew, zoneh) + { + return ! ( zonex > (jQuery.iDrag.dragged.dragCfg.nx + jQuery.iDrag.dragged.dragCfg.oC.w) + || (zonex + zonew) < jQuery.iDrag.dragged.dragCfg.nx + || zoney > (jQuery.iDrag.dragged.dragCfg.ny + jQuery.iDrag.dragged.dragCfg.oC.h) + || (zoney + zoneh) < jQuery.iDrag.dragged.dragCfg.ny + ) ? true :false; + }, + pointer : function (zonex, zoney, zonew, zoneh) + { + return zonex < jQuery.iDrag.dragged.dragCfg.currentPointer.x + && (zonex + zonew) > jQuery.iDrag.dragged.dragCfg.currentPointer.x + && zoney < jQuery.iDrag.dragged.dragCfg.currentPointer.y + && (zoney + zoneh) > jQuery.iDrag.dragged.dragCfg.currentPointer.y + ? true :false; + }, + overzone : false, + highlighted : {}, + count : 0, + zones : {}, + + highlight : function (elm) + { + if (jQuery.iDrag.dragged == null) { + return; + } + var i; + jQuery.iDrop.highlighted = {}; + var oneIsSortable = false; + for (i in jQuery.iDrop.zones) { + if (jQuery.iDrop.zones[i] != null) { + var iEL = jQuery.iDrop.zones[i].get(0); + if (jQuery(jQuery.iDrag.dragged).is('.' + iEL.dropCfg.a)) { + if (iEL.dropCfg.m == false) { + iEL.dropCfg.p = jQuery.extend( + jQuery.iUtil.getPosition(iEL), + jQuery.iUtil.getSizeLite(iEL) + );//jQuery.iUtil.getPos(iEL); + iEL.dropCfg.m = true; + } + if (iEL.dropCfg.ac) { + jQuery.iDrop.zones[i].addClass(iEL.dropCfg.ac); + } + jQuery.iDrop.highlighted[i] = jQuery.iDrop.zones[i]; + //if (jQuery.iSort && jQuery.iDrag.dragged.dragCfg.so) { + if (jQuery.iSort && iEL.dropCfg.s && jQuery.iDrag.dragged.dragCfg.so) { + iEL.dropCfg.el = jQuery('.' + iEL.dropCfg.a, iEL); + elm.style.display = 'none'; + jQuery.iSort.measure(iEL); + iEL.dropCfg.os = jQuery.iSort.serialize(jQuery.attr(iEL, 'id')).hash; + elm.style.display = elm.dragCfg.oD; + oneIsSortable = true; + } + if (iEL.dropCfg.onActivate) { + iEL.dropCfg.onActivate.apply(jQuery.iDrop.zones[i].get(0), [jQuery.iDrag.dragged]); + } + } + } + } + //if (jQuery.iSort && jQuery.iDrag.dragged.dragCfg.so) { + if (oneIsSortable) { + jQuery.iSort.start(); + } + }, + /** + * remeasure the droppable + * + * useful when the positions/dimensions for droppables + * are changed while dragging a element + * + * this works for sortables too but with a greate processor + * penality because remeasures each sort items too + */ + remeasure : function() + { + jQuery.iDrop.highlighted = {}; + for (i in jQuery.iDrop.zones) { + if (jQuery.iDrop.zones[i] != null) { + var iEL = jQuery.iDrop.zones[i].get(0); + if (jQuery(jQuery.iDrag.dragged).is('.' + iEL.dropCfg.a)) { + iEL.dropCfg.p = jQuery.extend( + jQuery.iUtil.getPosition(iEL), + jQuery.iUtil.getSizeLite(iEL) + ); + if (iEL.dropCfg.ac) { + jQuery.iDrop.zones[i].addClass(iEL.dropCfg.ac); + } + jQuery.iDrop.highlighted[i] = jQuery.iDrop.zones[i]; + + if (jQuery.iSort && iEL.dropCfg.s && jQuery.iDrag.dragged.dragCfg.so) { + iEL.dropCfg.el = jQuery('.' + iEL.dropCfg.a, iEL); + elm.style.display = 'none'; + jQuery.iSort.measure(iEL); + elm.style.display = elm.dragCfg.oD; + } + } + } + } + }, + + checkhover : function (e) + { + if (jQuery.iDrag.dragged == null) { + return; + } + jQuery.iDrop.overzone = false; + var i; + var applyOnHover = false; + var hlt = 0; + for (i in jQuery.iDrop.highlighted) + { + var iEL = jQuery.iDrop.highlighted[i].get(0); + if ( + jQuery.iDrop.overzone == false + && + jQuery.iDrop[iEL.dropCfg.t]( + iEL.dropCfg.p.x, + iEL.dropCfg.p.y, + iEL.dropCfg.p.wb, + iEL.dropCfg.p.hb + ) + + ) { + if (iEL.dropCfg.hc && iEL.dropCfg.h == false) { + jQuery.iDrop.highlighted[i].addClass(iEL.dropCfg.hc); + } + //chec if onHover function has to be called + if (iEL.dropCfg.h == false &&iEL.dropCfg.onHover) { + applyOnHover = true; + } + iEL.dropCfg.h = true; + jQuery.iDrop.overzone = iEL; + //if(jQuery.iSort && jQuery.iDrag.dragged.dragCfg.so) { + if(jQuery.iSort && iEL.dropCfg.s && jQuery.iDrag.dragged.dragCfg.so) { + jQuery.iSort.helper.get(0).className = iEL.dropCfg.shc; + jQuery.iSort.checkhover(iEL); + } + hlt ++; + } else if(iEL.dropCfg.h == true) { + //onOut function + if (iEL.dropCfg.onOut) { + iEL.dropCfg.onOut.apply(iEL, [e, jQuery.iDrag.helper.get(0).firstChild, iEL.dropCfg.fx]); + } + if (iEL.dropCfg.hc) { + jQuery.iDrop.highlighted[i].removeClass(iEL.dropCfg.hc); + } + iEL.dropCfg.h = false; + } + } + if (jQuery.iSort && !jQuery.iDrop.overzone && jQuery.iDrag.dragged.so) { + jQuery.iSort.helper.get(0).style.display = 'none'; + //jQuery('body').append(jQuery.iSort.helper.get(0)); + } + //call onhover + if(applyOnHover) { + jQuery.iDrop.overzone.dropCfg.onHover.apply(jQuery.iDrop.overzone, [e, jQuery.iDrag.helper.get(0).firstChild]); + } + }, + checkdrop : function (e) + { + var i; + for (i in jQuery.iDrop.highlighted) { + var iEL = jQuery.iDrop.highlighted[i].get(0); + if (iEL.dropCfg.ac) { + jQuery.iDrop.highlighted[i].removeClass(iEL.dropCfg.ac); + } + if (iEL.dropCfg.hc) { + jQuery.iDrop.highlighted[i].removeClass(iEL.dropCfg.hc); + } + if(iEL.dropCfg.s) { + jQuery.iSort.changed[jQuery.iSort.changed.length] = i; + } + if (iEL.dropCfg.onDrop && iEL.dropCfg.h == true) { + iEL.dropCfg.h = false; + iEL.dropCfg.onDrop.apply(iEL, [e, iEL.dropCfg.fx]); + } + iEL.dropCfg.m = false; + iEL.dropCfg.h = false; + } + jQuery.iDrop.highlighted = {}; + }, + destroy : function() + { + return this.each( + function() + { + if (this.isDroppable) { + if (this.dropCfg.s) { + id = jQuery.attr(this,'id'); + jQuery.iSort.collected[id] = null; + jQuery('.' + this.dropCfg.a, this).DraggableDestroy(); + } + jQuery.iDrop.zones['d' + this.idsa] = null; + this.isDroppable = false; + this.f = null; + } + } + ); + }, + build : function (o) + { + return this.each( + function() + { + if (this.isDroppable == true || !o.accept || !jQuery.iUtil || !jQuery.iDrag){ + return; + } + this.dropCfg = { + a : o.accept, + ac: o.activeclass||false, + hc: o.hoverclass||false, + shc: o.helperclass||false, + onDrop: o.ondrop||o.onDrop||false, + onHover: o.onHover||o.onhover||false, + onOut: o.onOut||o.onout||false, + onActivate: o.onActivate||false, + t: o.tolerance && ( o.tolerance == 'fit' || o.tolerance == 'intersect') ? o.tolerance : 'pointer', + fx: o.fx ? o.fx : false, + m: false, + h: false + }; + if (o.sortable == true && jQuery.iSort) { + id = jQuery.attr(this,'id'); + jQuery.iSort.collected[id] = this.dropCfg.a; + this.dropCfg.s = true; + if(o.onChange) { + this.dropCfg.onChange = o.onChange; + this.dropCfg.os = jQuery.iSort.serialize(id).hash; + } + } + this.isDroppable = true; + this.idsa = parseInt(Math.random() * 10000); + jQuery.iDrop.zones['d' + this.idsa] = jQuery(this); + jQuery.iDrop.count ++; + } + ); + } +}; + +/** + * Destroy an existing droppable on a collection of elements + * + * @name DroppableDestroy + * @descr Destroy a droppable + * @type jQuery + * @cat Plugins/Interface + * @example $('#drag2').DroppableDestroy(); + */ + +jQuery.fn.extend( + { + DroppableDestroy : jQuery.iDrop.destroy, + Droppable : jQuery.iDrop.build + } +); + + +/** + * Recalculate all Droppables + * + * @name $.recallDroppables + * @type jQuery + * @cat Plugins/Interface + * @example $.recallDroppable(); + */ + +jQuery.recallDroppables = jQuery.iDrop.remeasure; \ No newline at end of file Index: wp-includes/js/jquery/interface/ifxhighlight.js =================================================================== --- wp-includes/js/jquery/interface/ifxhighlight.js (revision 0) +++ wp-includes/js/jquery/interface/ifxhighlight.js (revision 0) @@ -0,0 +1,62 @@ +/** + * Interface Elements for jQuery + * FX - Highlight + * + * http://interface.eyecon.ro + * + * Copyright (c) 2006 Stefan Petre + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * + */ + + +/** + * @name Highlight + * @description Animates the backgroudn color to create a highlight animation + * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast'] + * @param String color color to highlight from + * @param Function callback (optional) A function to be executed whenever the animation completes. + * @param String easing (optional) The name of the easing effect that you want to use. + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ +jQuery.fn.Highlight = function(speed, color, callback, easing) { + return this.queue( + 'interfaceColorFX', + function() + { + this.oldStyleAttr = jQuery(this).attr("style") || ''; + easing = typeof callback == 'string' ? callback : easing||null; + callback = typeof callback == 'function' ? callback : null; + var oldColor = jQuery(this).css('backgroundColor'); + var parentEl = this.parentNode; + while(oldColor == 'transparent' && parentEl && parentEl.nodeType !== 1) { + oldColor = jQuery(parentEl).css('backgroundColor'); + parentEl = parentEl.parentNode; + } + + /* In IE, style is a object.. */ + if(typeof this.oldStyleAttr == 'object') this.oldStyleAttr = this.oldStyleAttr["cssText"]; + + jQuery(this).css('backgroundColor', color).animate( + {'backgroundColor':oldColor}, + speed, + easing, + function() { + jQuery.dequeue(this, 'interfaceColorFX'); + if(typeof jQuery(this).attr("style") == 'object') { + jQuery(this).attr("style")["cssText"] = ""; + jQuery(this).attr("style")["cssText"] = this.oldStyleAttr; + } else { + jQuery(this).attr("style", this.oldStyleAttr); + } + if (callback) + callback.apply(this); + } + ); + } + ); +}; \ No newline at end of file Index: wp-includes/js/jquery/interface/iexpander.js =================================================================== --- wp-includes/js/jquery/interface/iexpander.js (revision 0) +++ wp-includes/js/jquery/interface/iexpander.js (revision 0) @@ -0,0 +1,114 @@ +/** + * Interface Elements for jQuery + * Expander + * + * http://interface.eyecon.ro + * + * Copyright (c) 2006 Stefan Petre + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * + */ + +/** + * Expands text and textarea elements while new characters are typed to the a miximum width + * + * @name Expander + * @description Expands text and textarea elements while new characters are typed to the a miximum width + * @param Mixed limit integer if only expands in width, array if expands in width and height + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ + +jQuery.iExpander = +{ + helper : null, + expand : function() + { + + text = this.value; + if (!text) + return; + style = { + fontFamily: jQuery(this).css('fontFamily')||'', + fontSize: jQuery(this).css('fontSize')||'', + fontWeight: jQuery(this).css('fontWeight')||'', + fontStyle: jQuery(this).css('fontStyle')||'', + fontStretch: jQuery(this).css('fontStretch')||'', + fontVariant: jQuery(this).css('fontVariant')||'', + letterSpacing: jQuery(this).css('letterSpacing')||'', + wordSpacing: jQuery(this).css('wordSpacing')||'' + }; + jQuery.iExpander.helper.css(style); + html = jQuery.iExpander.htmlEntities(text); + html = html.replace(new RegExp( "\\n", "g" ), "
"); + jQuery.iExpander.helper.html('pW'); + spacer = jQuery.iExpander.helper.get(0).offsetWidth; + jQuery.iExpander.helper.html(html); + width = jQuery.iExpander.helper.get(0).offsetWidth + spacer; + if (this.Expander.limit && width > this.Expander.limit[0]) { + width = this.Expander.limit[0]; + } + this.style.width = width + 'px'; + if (this.tagName == 'TEXTAREA') { + height = jQuery.iExpander.helper.get(0).offsetHeight + spacer; + if (this.Expander.limit && height > this.Expander.limit[1]) { + height = this.Expander.limit[1]; + } + this.style.height = height + 'px'; + } + }, + htmlEntities : function(text) + { + entities = { + '&':'&', + '<':'<', + '>':'>', + '"':'"' + }; + for(i in entities) { + text = text.replace(new RegExp(i,'g'),entities[i]); + } + return text; + }, + build : function(limit) + { + if (jQuery.iExpander.helper == null) { + jQuery('body', document).append(''); + jQuery.iExpander.helper = jQuery('#expanderHelper'); + } + return this.each( + function() + { + if (/TEXTAREA|INPUT/.test(this.tagName)) { + if (this.tagName == 'INPUT') { + elType = this.getAttribute('type'); + if (!/text|password/.test(elType)) { + return; + } + } + if (limit && (limit.constructor == Number || (limit.constructor == Array && limit.length == 2))) { + if (limit.constructor == Number) + limit = [limit, limit]; + else { + limit[0] = parseInt(limit[0])||400; + limit[1] = parseInt(limit[1])||400; + } + this.Expander = { + limit : limit + }; + } + jQuery(this) + .blur(jQuery.iExpander.expand) + .keyup(jQuery.iExpander.expand) + .keypress(jQuery.iExpander.expand); + jQuery.iExpander.expand.apply(this); + } + } + ); + } +}; + +jQuery.fn.Autoexpand = jQuery.iExpander.build; \ No newline at end of file Index: wp-includes/js/jquery/interface/ifxpulsate.js =================================================================== --- wp-includes/js/jquery/interface/ifxpulsate.js (revision 0) +++ wp-includes/js/jquery/interface/ifxpulsate.js (revision 0) @@ -0,0 +1,77 @@ +/** + * Interface Elements for jQuery + * FX - pulsate + * + * http://interface.eyecon.ro + * + * Copyright (c) 2006 Stefan Petre + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * + */ + +/** + * @name Bounce + * @description makes the element to pulsate + * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast'] + * @param Integer times how many times to pulsate + * @param Function callback (optional) A function to be executed whenever the animation completes. + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ +jQuery.fn.Pulsate = function(speed, times, callback) { + return this.queue('interfaceFX',function(){ + if (!jQuery.fxCheckTag(this)) { + jQuery.dequeue(this, 'interfaceFX'); + return false; + } + var fx = new jQuery.fx.Pulsate(this, speed, times, callback); + fx.pulse(); + }); +}; + +jQuery.fx.Pulsate = function (el, speed, times, callback) +{ + var z = this; + z.times = times; + z.cnt = 1; + z.el = el; + z.speed = speed; + z.callback = callback; + jQuery(z.el).show(); + z.pulse = function() + { + z.cnt ++; + z.e = new jQuery.fx( + z.el, + jQuery.speed( + z.speed, + function(){ + z.ef = new jQuery.fx( + z.el, + jQuery.speed( + z.speed, + function() + { + if (z.cnt <= z.times) + z.pulse(); + else { + jQuery.dequeue(z.el, 'interfaceFX'); + if (z.callback && z.callback.constructor == Function) { + z.callback.apply(z.el); + } + } + } + ), + 'opacity' + ); + z.ef.custom(0,1); + } + ), + 'opacity' + ); + z.e.custom(1,0); + }; +}; Index: wp-includes/js/jquery/interface/icassistant.js =================================================================== --- wp-includes/js/jquery/interface/icassistant.js (revision 0) +++ wp-includes/js/jquery/interface/icassistant.js (revision 0) @@ -0,0 +1,42 @@ +jQuery.icA = { + helper: null, + move: function(e) + { + var pointer = jQuery.iUtil.getPointer(e); + jQuery.icA.helper.css( + { + top: pointer.y + 12 +'px', + left: pointer.x + 12 +'px' + } + ); + }, + html: function(html) + { + jQuery.icA.helper.html(html); + }, + empty: function() + { + jQuery.icA.helper.empty(); + }, + show: function() + { + jQuery.icA.helper.show(); + }, + hide: function() + { + jQuery.icA.helper.hide(); + }, + className: function(className) + { + jQuery.icA.helper.get(0).className = className; + }, + init: function() { + if (!jQuery.icA.helper) { + jQuery('body').append('
'); + jQuery.icA.helper = jQuery('#cAssistentHelper'); + jQuery(document) + .bind('mousemove', jQuery.icA.move); + } + } +}; +jQuery(document).ready(function(){jQuery.icA.init()}); \ No newline at end of file Index: wp-includes/js/jquery/interface/idrag.js =================================================================== --- wp-includes/js/jquery/interface/idrag.js (revision 0) +++ wp-includes/js/jquery/interface/idrag.js (revision 0) @@ -0,0 +1,588 @@ +/** + * Interface Elements for jQuery + * Draggable + * + * http://interface.eyecon.ro + * + * Copyright (c) 2006 Stefan Petre + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + */ + +/** + * Create a draggable element with a number of advanced options including callback, Google Maps type draggables, + * reversion, ghosting, and grid dragging. + * + * @name Draggable + * @descr Creates draggable elements that can be moved across the page. + * @param Hash hash A hash of parameters. All parameters are optional. + * @option String handle (optional) The jQuery selector matching the handle that starts the draggable + * @option DOMElement handle (optional) The DOM Element of the handle that starts the draggable + * @option Boolean revert (optional) When true, on stop-drag the element returns to initial position + * @option Boolean ghosting (optional) When true, a copy of the element is moved + * @option Integer zIndex (optional) zIndex depth for the element while it is being dragged + * @option Float opacity (optional) A number between 0 and 1 that indicates the opacity of the element while being dragged + * @option Integer grid (optional) (optional) A number of pixels indicating the grid that the element should snap to + * @option Array grid (optional) A number of x-pixels and y-pixels indicating the grid that the element should snap to + * @option Integer fx (optional) Duration for the effect (like ghosting or revert) applied to the draggable + * @option String containment (optional) Define the zone where the draggable can be moved. 'parent' moves it inside parent + * element, while 'document' prevents it from leaving the document and forcing additional + * scrolling + * @option Array containment An 4-element array (left, top, width, height) indicating the containment of the element + * @option String axis (optional) Set an axis: vertical (with 'vertically') or horizontal (with 'horizontally') + * @option Function onStart (optional) Callback function triggered when the dragging starts + * @option Function onStop (optional) Callback function triggered when the dragging stops + * @option Function onChange (optional) Callback function triggered when the dragging stop *and* the element was moved at least + * one pixel + * @option Function onDrag (optional) Callback function triggered while the element is dragged. Receives two parameters: x and y + * coordinates. You can return an object with new coordinates {x: x, y: y} so this way you can + * interact with the dragging process (for instance, build your containment) + * @option Boolean insideParent Forces the element to remain inside its parent when being dragged (like Google Maps) + * @option Integer snapDistance (optional) The element is not moved unless it is dragged more than snapDistance. You can prevent + * accidental dragging and keep regular clicking enabled (for links or form elements, + * for instance) + * @option Object cursorAt (optional) The dragged element is moved to the cursor position with the offset specified. Accepts value + * for top, left, right and bottom offset. Basically, this forces the cursor to a particular + * position during the entire drag operation. + * @option Boolean autoSize (optional) When true, the drag helper is resized to its content, instead of the dragged element's sizes + * @option String frameClass (optional) When is set the cloned element is hidden so only a frame is dragged + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ + +jQuery.iDrag = { + helper : null, + dragged: null, + destroy : function() + { + return this.each( + function () + { + if (this.isDraggable) { + this.dragCfg.dhe.unbind('mousedown', jQuery.iDrag.draginit); + this.dragCfg = null; + this.isDraggable = false; + if(jQuery.browser.msie) { + this.unselectable = "off"; + } else { + this.style.MozUserSelect = ''; + this.style.KhtmlUserSelect = ''; + this.style.userSelect = ''; + } + } + } + ); + }, + draginit : function (e) + { + if (jQuery.iDrag.dragged != null) { + jQuery.iDrag.dragstop(e); + return false; + } + var elm = this.dragElem; + jQuery(document) + .bind('mousemove', jQuery.iDrag.dragmove) + .bind('mouseup', jQuery.iDrag.dragstop); + elm.dragCfg.pointer = jQuery.iUtil.getPointer(e); + elm.dragCfg.currentPointer = elm.dragCfg.pointer; + elm.dragCfg.init = false; + elm.dragCfg.fromHandler = this != this.dragElem; + jQuery.iDrag.dragged = elm; + if (elm.dragCfg.si && this != this.dragElem) { + parentPos = jQuery.iUtil.getPosition(elm.parentNode); + sliderSize = jQuery.iUtil.getSize(elm); + sliderPos = { + x : parseInt(jQuery.css(elm,'left')) || 0, + y : parseInt(jQuery.css(elm,'top')) || 0 + }; + dx = elm.dragCfg.currentPointer.x - parentPos.x - sliderSize.wb/2 - sliderPos.x; + dy = elm.dragCfg.currentPointer.y - parentPos.y - sliderSize.hb/2 - sliderPos.y; + jQuery.iSlider.dragmoveBy(elm, [dx, dy]); + } + return jQuery.selectKeyHelper||false; + }, + + dragstart : function(e) + { + var elm = jQuery.iDrag.dragged; + elm.dragCfg.init = true; + + var dEs = elm.style; + + elm.dragCfg.oD = jQuery.css(elm,'display'); + elm.dragCfg.oP = jQuery.css(elm,'position'); + if (!elm.dragCfg.initialPosition) + elm.dragCfg.initialPosition = elm.dragCfg.oP; + + elm.dragCfg.oR = { + x : parseInt(jQuery.css(elm,'left')) || 0, + y : parseInt(jQuery.css(elm,'top')) || 0 + }; + elm.dragCfg.diffX = 0; + elm.dragCfg.diffY = 0; + if (jQuery.browser.msie) { + var oldBorder = jQuery.iUtil.getBorder(elm, true); + elm.dragCfg.diffX = oldBorder.l||0; + elm.dragCfg.diffY = oldBorder.t||0; + } + + elm.dragCfg.oC = jQuery.extend( + jQuery.iUtil.getPosition(elm), + jQuery.iUtil.getSize(elm) + ); + if (elm.dragCfg.oP != 'relative' && elm.dragCfg.oP != 'absolute') { + dEs.position = 'relative'; + } + + jQuery.iDrag.helper.empty(); + var clonedEl = elm.cloneNode(true); + + jQuery(clonedEl).css( + { + display: 'block', + left: '0px', + top: '0px' + } + ); + clonedEl.style.marginTop = '0'; + clonedEl.style.marginRight = '0'; + clonedEl.style.marginBottom = '0'; + clonedEl.style.marginLeft = '0'; + jQuery.iDrag.helper.append(clonedEl); + + var dhs = jQuery.iDrag.helper.get(0).style; + + if (elm.dragCfg.autoSize) { + dhs.width = 'auto'; + dhs.height = 'auto'; + } else { + dhs.height = elm.dragCfg.oC.hb + 'px'; + dhs.width = elm.dragCfg.oC.wb + 'px'; + } + + dhs.display = 'block'; + dhs.marginTop = '0px'; + dhs.marginRight = '0px'; + dhs.marginBottom = '0px'; + dhs.marginLeft = '0px'; + + //remeasure the clone to check if the size was changed by user's functions + jQuery.extend( + elm.dragCfg.oC, + jQuery.iUtil.getSize(clonedEl) + ); + + if (elm.dragCfg.cursorAt) { + if (elm.dragCfg.cursorAt.left) { + elm.dragCfg.oR.x += elm.dragCfg.pointer.x - elm.dragCfg.oC.x - elm.dragCfg.cursorAt.left; + elm.dragCfg.oC.x = elm.dragCfg.pointer.x - elm.dragCfg.cursorAt.left; + } + if (elm.dragCfg.cursorAt.top) { + elm.dragCfg.oR.y += elm.dragCfg.pointer.y - elm.dragCfg.oC.y - elm.dragCfg.cursorAt.top; + elm.dragCfg.oC.y = elm.dragCfg.pointer.y - elm.dragCfg.cursorAt.top; + } + if (elm.dragCfg.cursorAt.right) { + elm.dragCfg.oR.x += elm.dragCfg.pointer.x - elm.dragCfg.oC.x -elm.dragCfg.oC.hb + elm.dragCfg.cursorAt.right; + elm.dragCfg.oC.x = elm.dragCfg.pointer.x - elm.dragCfg.oC.wb + elm.dragCfg.cursorAt.right; + } + if (elm.dragCfg.cursorAt.bottom) { + elm.dragCfg.oR.y += elm.dragCfg.pointer.y - elm.dragCfg.oC.y - elm.dragCfg.oC.hb + elm.dragCfg.cursorAt.bottom; + elm.dragCfg.oC.y = elm.dragCfg.pointer.y - elm.dragCfg.oC.hb + elm.dragCfg.cursorAt.bottom; + } + } + elm.dragCfg.nx = elm.dragCfg.oR.x; + elm.dragCfg.ny = elm.dragCfg.oR.y; + + if (elm.dragCfg.insideParent || elm.dragCfg.containment == 'parent') { + parentBorders = jQuery.iUtil.getBorder(elm.parentNode, true); + elm.dragCfg.oC.x = elm.offsetLeft + (jQuery.browser.msie ? 0 : jQuery.browser.opera ? -parentBorders.l : parentBorders.l); + elm.dragCfg.oC.y = elm.offsetTop + (jQuery.browser.msie ? 0 : jQuery.browser.opera ? -parentBorders.t : parentBorders.t); + jQuery(elm.parentNode).append(jQuery.iDrag.helper.get(0)); + } + if (elm.dragCfg.containment) { + jQuery.iDrag.getContainment(elm); + elm.dragCfg.onDragModifier.containment = jQuery.iDrag.fitToContainer; + } + + if (elm.dragCfg.si) { + jQuery.iSlider.modifyContainer(elm); + } + + dhs.left = elm.dragCfg.oC.x - elm.dragCfg.diffX + 'px'; + dhs.top = elm.dragCfg.oC.y - elm.dragCfg.diffY + 'px'; + //resize the helper to fit the clone + dhs.width = elm.dragCfg.oC.wb + 'px'; + dhs.height = elm.dragCfg.oC.hb + 'px'; + + jQuery.iDrag.dragged.dragCfg.prot = false; + + if (elm.dragCfg.gx) { + elm.dragCfg.onDragModifier.grid = jQuery.iDrag.snapToGrid; + } + if (elm.dragCfg.zIndex != false) { + jQuery.iDrag.helper.css('zIndex', elm.dragCfg.zIndex); + } + if (elm.dragCfg.opacity) { + jQuery.iDrag.helper.css('opacity', elm.dragCfg.opacity); + if (window.ActiveXObject) { + jQuery.iDrag.helper.css('filter', 'alpha(opacity=' + elm.dragCfg.opacity * 100 + ')'); + } + } + + if(elm.dragCfg.frameClass) { + jQuery.iDrag.helper.addClass(elm.dragCfg.frameClass); + jQuery.iDrag.helper.get(0).firstChild.style.display = 'none'; + } + if (elm.dragCfg.onStart) + elm.dragCfg.onStart.apply(elm, [clonedEl, elm.dragCfg.oR.x, elm.dragCfg.oR.y]); + if (jQuery.iDrop && jQuery.iDrop.count > 0 ){ + jQuery.iDrop.highlight(elm); + } + if (elm.dragCfg.ghosting == false) { + dEs.display = 'none'; + } + return false; + }, + + getContainment : function(elm) + { + if (elm.dragCfg.containment.constructor == String) { + if (elm.dragCfg.containment == 'parent') { + elm.dragCfg.cont = jQuery.extend( + {x:0,y:0}, + jQuery.iUtil.getSize(elm.parentNode) + ); + var contBorders = jQuery.iUtil.getBorder(elm.parentNode, true); + elm.dragCfg.cont.w = elm.dragCfg.cont.wb - contBorders.l - contBorders.r; + elm.dragCfg.cont.h = elm.dragCfg.cont.hb - contBorders.t - contBorders.b; + } else if (elm.dragCfg.containment == 'document') { + var clnt = jQuery.iUtil.getClient(); + elm.dragCfg.cont = { + x : 0, + y : 0, + w : clnt.w, + h : clnt.h + }; + } + } else if (elm.dragCfg.containment.constructor == Array) { + elm.dragCfg.cont = { + x : parseInt(elm.dragCfg.containment[0])||0, + y : parseInt(elm.dragCfg.containment[1])||0, + w : parseInt(elm.dragCfg.containment[2])||0, + h : parseInt(elm.dragCfg.containment[3])||0 + }; + } + elm.dragCfg.cont.dx = elm.dragCfg.cont.x - elm.dragCfg.oC.x; + elm.dragCfg.cont.dy = elm.dragCfg.cont.y - elm.dragCfg.oC.y; + }, + + hidehelper : function(dragged) + { + if (dragged.dragCfg.insideParent || dragged.dragCfg.containment == 'parent') { + jQuery('body', document).append(jQuery.iDrag.helper.get(0)); + } + jQuery.iDrag.helper.empty().hide().css('opacity', 1); + if (window.ActiveXObject) { + jQuery.iDrag.helper.css('filter', 'alpha(opacity=100)'); + } + }, + + dragstop : function(e) + { + + jQuery(document) + .unbind('mousemove', jQuery.iDrag.dragmove) + .unbind('mouseup', jQuery.iDrag.dragstop); + + if (jQuery.iDrag.dragged == null) { + return; + } + var dragged = jQuery.iDrag.dragged; + + jQuery.iDrag.dragged = null; + + if (dragged.dragCfg.init == false) { + return false; + } + if (dragged.dragCfg.so == true) { + jQuery(dragged).css('position', dragged.dragCfg.oP); + } + var dEs = dragged.style; + + if (dragged.si) { + jQuery.iDrag.helper.css('cursor', 'move'); + } + if(dragged.dragCfg.frameClass) { + jQuery.iDrag.helper.removeClass(dragged.dragCfg.frameClass); + } + + if (dragged.dragCfg.revert == false) { + if (dragged.dragCfg.fx > 0) { + if (!dragged.dragCfg.axis || dragged.dragCfg.axis == 'horizontally') { + var x = new jQuery.fx(dragged,{duration:dragged.dragCfg.fx}, 'left'); + x.custom(dragged.dragCfg.oR.x,dragged.dragCfg.nRx); + } + if (!dragged.dragCfg.axis || dragged.dragCfg.axis == 'vertically') { + var y = new jQuery.fx(dragged,{duration:dragged.dragCfg.fx}, 'top'); + y.custom(dragged.dragCfg.oR.y,dragged.dragCfg.nRy); + } + } else { + if (!dragged.dragCfg.axis || dragged.dragCfg.axis == 'horizontally') + dragged.style.left = dragged.dragCfg.nRx + 'px'; + if (!dragged.dragCfg.axis || dragged.dragCfg.axis == 'vertically') + dragged.style.top = dragged.dragCfg.nRy + 'px'; + } + jQuery.iDrag.hidehelper(dragged); + if (dragged.dragCfg.ghosting == false) { + jQuery(dragged).css('display', dragged.dragCfg.oD); + } + } else if (dragged.dragCfg.fx > 0) { + dragged.dragCfg.prot = true; + var dh = false; + if(jQuery.iDrop && jQuery.iSort && dragged.dragCfg.so) { + dh = jQuery.iUtil.getPosition(jQuery.iSort.helper.get(0)); + } + jQuery.iDrag.helper.animate( + { + left : dh ? dh.x : dragged.dragCfg.oC.x, + top : dh ? dh.y : dragged.dragCfg.oC.y + }, + dragged.dragCfg.fx, + function() + { + dragged.dragCfg.prot = false; + if (dragged.dragCfg.ghosting == false) { + dragged.style.display = dragged.dragCfg.oD; + } + jQuery.iDrag.hidehelper(dragged); + } + ); + } else { + jQuery.iDrag.hidehelper(dragged); + if (dragged.dragCfg.ghosting == false) { + jQuery(dragged).css('display', dragged.dragCfg.oD); + } + } + + if (jQuery.iDrop && jQuery.iDrop.count > 0 ){ + jQuery.iDrop.checkdrop(dragged); + } + if (jQuery.iSort && dragged.dragCfg.so) { + jQuery.iSort.check(dragged); + } + if (dragged.dragCfg.onChange && (dragged.dragCfg.nRx != dragged.dragCfg.oR.x || dragged.dragCfg.nRy != dragged.dragCfg.oR.y)){ + dragged.dragCfg.onChange.apply(dragged, dragged.dragCfg.lastSi||[0,0,dragged.dragCfg.nRx,dragged.dragCfg.nRy]); + } + if (dragged.dragCfg.onStop) + dragged.dragCfg.onStop.apply(dragged); + return false; + }, + + snapToGrid : function(x, y, dx, dy) + { + if (dx != 0) + dx = parseInt((dx + (this.dragCfg.gx * dx/Math.abs(dx))/2)/this.dragCfg.gx) * this.dragCfg.gx; + if (dy != 0) + dy = parseInt((dy + (this.dragCfg.gy * dy/Math.abs(dy))/2)/this.dragCfg.gy) * this.dragCfg.gy; + return { + dx : dx, + dy : dy, + x: 0, + y: 0 + }; + }, + + fitToContainer : function(x, y, dx, dy) + { + dx = Math.min( + Math.max(dx,this.dragCfg.cont.dx), + this.dragCfg.cont.w + this.dragCfg.cont.dx - this.dragCfg.oC.wb + ); + dy = Math.min( + Math.max(dy,this.dragCfg.cont.dy), + this.dragCfg.cont.h + this.dragCfg.cont.dy - this.dragCfg.oC.hb + ); + + return { + dx : dx, + dy : dy, + x: 0, + y: 0 + } + }, + + dragmove : function(e) + { + if (jQuery.iDrag.dragged == null || jQuery.iDrag.dragged.dragCfg.prot == true) { + return; + } + + var dragged = jQuery.iDrag.dragged; + + dragged.dragCfg.currentPointer = jQuery.iUtil.getPointer(e); + if (dragged.dragCfg.init == false) { + distance = Math.sqrt(Math.pow(dragged.dragCfg.pointer.x - dragged.dragCfg.currentPointer.x, 2) + Math.pow(dragged.dragCfg.pointer.y - dragged.dragCfg.currentPointer.y, 2)); + if (distance < dragged.dragCfg.snapDistance){ + return; + } else { + jQuery.iDrag.dragstart(e); + } + } + + var dx = dragged.dragCfg.currentPointer.x - dragged.dragCfg.pointer.x; + var dy = dragged.dragCfg.currentPointer.y - dragged.dragCfg.pointer.y; + + for (var i in dragged.dragCfg.onDragModifier) { + var newCoords = dragged.dragCfg.onDragModifier[i].apply(dragged, [dragged.dragCfg.oR.x + dx, dragged.dragCfg.oR.y + dy, dx, dy]); + if (newCoords && newCoords.constructor == Object) { + dx = i != 'user' ? newCoords.dx : (newCoords.x - dragged.dragCfg.oR.x); + dy = i != 'user' ? newCoords.dy : (newCoords.y - dragged.dragCfg.oR.y); + } + } + + dragged.dragCfg.nx = dragged.dragCfg.oC.x + dx - dragged.dragCfg.diffX; + dragged.dragCfg.ny = dragged.dragCfg.oC.y + dy - dragged.dragCfg.diffY; + + if (dragged.dragCfg.si && (dragged.dragCfg.onSlide || dragged.dragCfg.onChange)) { + jQuery.iSlider.onSlide(dragged, dragged.dragCfg.nx, dragged.dragCfg.ny); + } + + if(dragged.dragCfg.onDrag) + dragged.dragCfg.onDrag.apply(dragged, [dragged.dragCfg.oR.x + dx, dragged.dragCfg.oR.y + dy]); + + if (!dragged.dragCfg.axis || dragged.dragCfg.axis == 'horizontally') { + dragged.dragCfg.nRx = dragged.dragCfg.oR.x + dx; + jQuery.iDrag.helper.get(0).style.left = dragged.dragCfg.nx + 'px'; + } + if (!dragged.dragCfg.axis || dragged.dragCfg.axis == 'vertically') { + dragged.dragCfg.nRy = dragged.dragCfg.oR.y + dy; + jQuery.iDrag.helper.get(0).style.top = dragged.dragCfg.ny + 'px'; + } + + if (jQuery.iDrop && jQuery.iDrop.count > 0 ){ + jQuery.iDrop.checkhover(dragged); + } + return false; + }, + + build : function(o) + { + if (!jQuery.iDrag.helper) { + jQuery('body',document).append('
'); + jQuery.iDrag.helper = jQuery('#dragHelper'); + var el = jQuery.iDrag.helper.get(0); + var els = el.style; + els.position = 'absolute'; + els.display = 'none'; + els.cursor = 'move'; + els.listStyle = 'none'; + els.overflow = 'hidden'; + if (window.ActiveXObject) { + el.unselectable = "on"; + } else { + els.mozUserSelect = 'none'; + els.userSelect = 'none'; + els.KhtmlUserSelect = 'none'; + } + } + if (!o) { + o = {}; + } + return this.each( + function() + { + if (this.isDraggable || !jQuery.iUtil) + return; + if (window.ActiveXObject) { + this.onselectstart = function(){return false;}; + this.ondragstart = function(){return false;}; + } + var el = this; + var dhe = o.handle ? jQuery(this).find(o.handle) : jQuery(this); + if(jQuery.browser.msie) { + dhe.each( + function() + { + this.unselectable = "on"; + } + ); + } else { + dhe.css('-moz-user-select', 'none'); + dhe.css('user-select', 'none'); + dhe.css('-khtml-user-select', 'none'); + } + this.dragCfg = { + dhe: dhe, + revert : o.revert ? true : false, + ghosting : o.ghosting ? true : false, + so : o.so ? o.so : false, + si : o.si ? o.si : false, + insideParent : o.insideParent ? o.insideParent : false, + zIndex : o.zIndex ? parseInt(o.zIndex)||0 : false, + opacity : o.opacity ? parseFloat(o.opacity) : false, + fx : parseInt(o.fx)||null, + hpc : o.hpc ? o.hpc : false, + onDragModifier : {}, + pointer : {}, + onStart : o.onStart && o.onStart.constructor == Function ? o.onStart : false, + onStop : o.onStop && o.onStop.constructor == Function ? o.onStop : false, + onChange : o.onChange && o.onChange.constructor == Function ? o.onChange : false, + axis : /vertically|horizontally/.test(o.axis) ? o.axis : false, + snapDistance : o.snapDistance ? parseInt(o.snapDistance)||0 : 0, + cursorAt: o.cursorAt ? o.cursorAt : false, + autoSize : o.autoSize ? true : false, + frameClass : o.frameClass || false + + }; + if (o.onDragModifier && o.onDragModifier.constructor == Function) + this.dragCfg.onDragModifier.user = o.onDragModifier; + if (o.onDrag && o.onDrag.constructor == Function) + this.dragCfg.onDrag = o.onDrag; + if (o.containment && ((o.containment.constructor == String && (o.containment == 'parent' || o.containment == 'document')) || (o.containment.constructor == Array && o.containment.length == 4) )) { + this.dragCfg.containment = o.containment; + } + if(o.fractions) { + this.dragCfg.fractions = o.fractions; + } + if(o.grid){ + if(typeof o.grid == 'number'){ + this.dragCfg.gx = parseInt(o.grid)||1; + this.dragCfg.gy = parseInt(o.grid)||1; + } else if (o.grid.length == 2) { + this.dragCfg.gx = parseInt(o.grid[0])||1; + this.dragCfg.gy = parseInt(o.grid[1])||1; + } + } + if (o.onSlide && o.onSlide.constructor == Function) { + this.dragCfg.onSlide = o.onSlide; + } + + this.isDraggable = true; + dhe.each( + function(){ + this.dragElem = el; + } + ); + dhe.bind('mousedown', jQuery.iDrag.draginit); + } + ) + } +}; + +/** + * Destroy an existing draggable on a collection of elements + * + * @name DraggableDestroy + * @descr Destroy a draggable + * @type jQuery + * @cat Plugins/Interface + * @example $('#drag2').DraggableDestroy(); + */ + +jQuery.fn.extend( + { + DraggableDestroy : jQuery.iDrag.destroy, + Draggable : jQuery.iDrag.build + } +); \ No newline at end of file Index: wp-includes/js/jquery/interface/ittabs.js =================================================================== --- wp-includes/js/jquery/interface/ittabs.js (revision 0) +++ wp-includes/js/jquery/interface/ittabs.js (revision 0) @@ -0,0 +1,92 @@ +/** + * Interface Elements for jQuery + * TTabs + * + * http://interface.eyecon.ro + * + * Copyright (c) 2006 Stefan Petre + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * + * + */ + +jQuery.iTTabs = +{ + doTab : function(e) + { + pressedKey = e.charCode || e.keyCode || -1; + if (pressedKey == 9) { + if (window.event) { + window.event.cancelBubble = true; + window.event.returnValue = false; + } else { + e.preventDefault(); + e.stopPropagation(); + } + if (this.createTextRange) { + document.selection.createRange().text="\t"; + this.onblur = function() { this.focus(); this.onblur = null; }; + } else if (this.setSelectionRange) { + start = this.selectionStart; + end = this.selectionEnd; + this.value = this.value.substring(0, start) + "\t" + this.value.substr(end); + this.setSelectionRange(start + 1, start + 1); + this.focus(); + } + return false; + } + }, + destroy : function() + { + return this.each( + function() + { + if (this.hasTabsEnabled && this.hasTabsEnabled == true) { + jQuery(this).unbind('keydown', jQuery.iTTabs.doTab); + this.hasTabsEnabled = false; + } + } + ); + }, + build : function() + { + return this.each( + function() + { + if (this.tagName == 'TEXTAREA' && (!this.hasTabsEnabled || this.hasTabsEnabled == false)) { + jQuery(this).bind('keydown', jQuery.iTTabs.doTab); + this.hasTabsEnabled = true; + } + } + ); + } +}; + +jQuery.fn.extend ( + { + /** + * Enable tabs in textareas + * + * @name EnableTabs + * @description Enable tabs in textareas + * + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ + EnableTabs : jQuery.iTTabs.build, + /** + * Disable tabs in textareas + * + * @name DisableTabs + * @description Disable tabs in textareas + * + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ + DisableTabs : jQuery.iTTabs.destroy + } +); \ No newline at end of file Index: wp-includes/js/jquery/interface/iutil.js =================================================================== --- wp-includes/js/jquery/interface/iutil.js (revision 0) +++ wp-includes/js/jquery/interface/iutil.js (revision 0) @@ -0,0 +1,245 @@ +/** + * Interface Elements for jQuery + * utility function + * + * http://interface.eyecon.ro + * + * Copyright (c) 2006 Stefan Petre + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * + */ + +jQuery.iUtil = { + getPosition : function(e) + { + var x = 0; + var y = 0; + var restoreStyle = false; + var es = e.style; + if (jQuery(e).css('display') == 'none') { + oldVisibility = es.visibility; + oldPosition = es.position; + es.visibility = 'hidden'; + es.display = 'block'; + es.position = 'absolute'; + restoreStyle = true; + } + var el = e; + while (el){ + x += el.offsetLeft + (el.currentStyle && !jQuery.browser.opera ?parseInt(el.currentStyle.borderLeftWidth)||0:0); + y += el.offsetTop + (el.currentStyle && !jQuery.browser.opera ?parseInt(el.currentStyle.borderTopWidth)||0:0); + el = el.offsetParent; + } + el = e; + while (el && el.tagName && el.tagName.toLowerCase() != 'body') + { + x -= el.scrollLeft||0; + y -= el.scrollTop||0; + el = el.parentNode; + } + if (restoreStyle) { + es.display = 'none'; + es.position = oldPosition; + es.visibility = oldVisibility; + } + return {x:x, y:y}; + }, + getPositionLite : function(el) + { + var x = 0, y = 0; + while(el) { + x += el.offsetLeft || 0; + y += el.offsetTop || 0; + el = el.offsetParent; + } + return {x:x, y:y}; + }, + getSize : function(e) + { + var w = jQuery.css(e,'width'); + var h = jQuery.css(e,'height'); + var wb = 0; + var hb = 0; + var es = e.style; + if (jQuery(e).css('display') != 'none') { + wb = e.offsetWidth; + hb = e.offsetHeight; + } else { + oldVisibility = es.visibility; + oldPosition = es.position; + es.visibility = 'hidden'; + es.display = 'block'; + es.position = 'absolute'; + wb = e.offsetWidth; + hb = e.offsetHeight; + es.display = 'none'; + es.position = oldPosition; + es.visibility = oldVisibility; + } + return {w:w, h:h, wb:wb, hb:hb}; + }, + getSizeLite : function(el) + { + return { + wb:el.offsetWidth||0, + hb:el.offsetHeight||0 + }; + }, + getClient : function(e) + { + var h, w, de; + if (e) { + w = e.clientWidth; + h = e.clientHeight; + } else { + de = document.documentElement; + w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth; + h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight; + } + return {w:w,h:h}; + }, + getScroll : function (e) + { + var t, l, w, h, iw, ih; + if (e && e.nodeName.toLowerCase() != 'body') { + t = e.scrollTop; + l = e.scrollLeft; + w = e.scrollWidth; + h = e.scrollHeight; + iw = 0; + ih = 0; + } else { + if (document.documentElement && document.documentElement.scrollTop) { + t = document.documentElement.scrollTop; + l = document.documentElement.scrollLeft; + w = document.documentElement.scrollWidth; + h = document.documentElement.scrollHeight; + } else if (document.body) { + t = document.body.scrollTop; + l = document.body.scrollLeft; + w = document.body.scrollWidth; + h = document.body.scrollHeight; + } + iw = self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0; + ih = self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0; + } + return { t: t, l: l, w: w, h: h, iw: iw, ih: ih }; + }, + getMargins : function(e, toInteger) + { + var el = jQuery(e); + var t = el.css('marginTop') || ''; + var r = el.css('marginRight') || ''; + var b = el.css('marginBottom') || ''; + var l = el.css('marginLeft') || ''; + if (toInteger) + return { + t: parseInt(t)||0, + r: parseInt(r)||0, + b: parseInt(b)||0, + l: parseInt(l) + }; + else + return {t: t, r: r, b: b, l: l}; + }, + getPadding : function(e, toInteger) + { + var el = jQuery(e); + var t = el.css('paddingTop') || ''; + var r = el.css('paddingRight') || ''; + var b = el.css('paddingBottom') || ''; + var l = el.css('paddingLeft') || ''; + if (toInteger) + return { + t: parseInt(t)||0, + r: parseInt(r)||0, + b: parseInt(b)||0, + l: parseInt(l) + }; + else + return {t: t, r: r, b: b, l: l}; + }, + getBorder : function(e, toInteger) + { + var el = jQuery(e); + var t = el.css('borderTopWidth') || ''; + var r = el.css('borderRightWidth') || ''; + var b = el.css('borderBottomWidth') || ''; + var l = el.css('borderLeftWidth') || ''; + if (toInteger) + return { + t: parseInt(t)||0, + r: parseInt(r)||0, + b: parseInt(b)||0, + l: parseInt(l)||0 + }; + else + return {t: t, r: r, b: b, l: l}; + }, + getPointer : function(event) + { + var x = event.pageX || (event.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft)) || 0; + var y = event.pageY || (event.clientY + (document.documentElement.scrollTop || document.body.scrollTop)) || 0; + return {x:x, y:y}; + }, + traverseDOM : function(nodeEl, func) + { + func(nodeEl); + nodeEl = nodeEl.firstChild; + while(nodeEl){ + jQuery.iUtil.traverseDOM(nodeEl, func); + nodeEl = nodeEl.nextSibling; + } + }, + purgeEvents : function(nodeEl) + { + jQuery.iUtil.traverseDOM( + nodeEl, + function(el) + { + for(var attr in el){ + if(typeof el[attr] === 'function') { + el[attr] = null; + } + } + } + ); + }, + centerEl : function(el, axis) + { + var clientScroll = $.iUtil.getScroll(); + var windowSize = $.iUtil.getSize(el); + if (!axis || axis == 'vertically') + $(el).css( + { + top: clientScroll.t + ((Math.max(clientScroll.h,clientScroll.ih) - clientScroll.t - windowSize.hb)/2) + 'px' + } + ); + if (!axis || axis == 'horizontally') + $(el).css( + { + left: clientScroll.l + ((Math.max(clientScroll.w,clientScroll.iw) - clientScroll.l - windowSize.wb)/2) + 'px' + } + ); + }, + fixPNG : function (el, emptyGIF) { + var images = $('img[@src*="png"]', el||document), png; + images.each( function() { + png = this.src; + this.src = emptyGIF; + this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + png + "')"; + }); + } +}; + +// Helper function to support older browsers! +[].indexOf || (Array.prototype.indexOf = function(v, n){ + n = (n == null) ? 0 : n; + var m = this.length; + for (var i=n; i 0 && pointer.y - 20 < this.scrollTop) { + var diff = Math.min(scr.t, 10); + sy -= diff; + sh += diff; + this.scrollTop -= diff; + } else if (this.scrollTop+ this.f.pos.h < this.f.scr.h && pointer.y + 20 > this.scrollTop + this.f.pos.h) { + var diff = Math.min(this.f.scr.h - this.scrollTop, 10); + this.scrollTop += diff; + if (this.scrollTop != scr.t) + sh += diff; + } + if (this.scrollLeft > 0 && pointer.x - 20 < this.scrollLeft) { + var diff = Math.min(scr.l, 10); + sx -= diff; + sw += diff; + this.scrollLeft -= diff; + } else if (this.scrollLeft+ this.f.pos.w < this.f.scr.w && pointer.x + 20 > this.scrollLeft + this.f.pos.w) { + var diff = Math.min(this.f.scr.w - this.scrollLeft, 10); + this.scrollLeft += diff; + if (this.scrollLeft != scr.l) + sw += diff; + } + jQuery.selectHelper.css( + { + left: sx + 'px', + top: sy + 'px', + width: sw - (this.f.selectBorders.l + this.f.selectBorders.r) + 'px', + height: sh - (this.f.selectBorders.t + this.f.selectBorders.b) + 'px' + } + ); + jQuery.selectHelper.l = sx + this.f.scr.l; + jQuery.selectHelper.t = sy + this.f.scr.t; + jQuery.selectHelper.r = jQuery.selectHelper.l + sw; + jQuery.selectHelper.b = jQuery.selectHelper.t + sh; + jQuery.selectedone = false; + this.f.el.each( + function () { + // Locate the current element in the current selection + iIndex = jQuery.selectCurrent.indexOf(jQuery.attr(this, 'id')); + // In case we are currently OVER an item + if ( + ! ( this.pos.x > jQuery.selectHelper.r + || (this.pos.x + this.pos.wb) < jQuery.selectHelper.l + || this.pos.y > jQuery.selectHelper.b + || (this.pos.y + this.pos.hb) < jQuery.selectHelper.t + ) + ) + { + jQuery.selectedone = true; + if (this.s != true) { + this.s = true; + jQuery(this).addClass(jQuery.selectdrug.f.sc); + } + + // Check to see if this item was previously selected, if so, unselect it + if (iIndex != -1) { + this.s = false; + jQuery(this).removeClass(jQuery.selectdrug.f.sc); + } + } else if ( + (this.s == true) && + (iIndex == -1) + ) { + // If the item was marked as selected, but it was not selected when you started dragging unselect it. + this.s = false; + jQuery(this).removeClass(jQuery.selectdrug.f.sc); + } else if ( + (!this.s) && + (jQuery.selectKeyHelper == true) && + (iIndex != -1) + ) { + // Reselect the item if: + // - we ARE multiselecting, + // - dragged over an allready selected object (so it got unselected) + // - But then dragged the selection out of it again. + this.s = true; + jQuery(this).addClass(jQuery.selectdrug.f.sc); + } + } + ); + return false; +}; +jQuery.selectstop = function(e) +{ + if(!jQuery.selectdrug) + return; + jQuery.selectstopApply.apply(jQuery.selectdrug, [e]); +}; +jQuery.selectstopApply = function(e) +{ + jQuery(document) + .unbind('mousemove', jQuery.selectcheck) + .unbind('mouseup', jQuery.selectstop); + if(!jQuery.selectdrug) + return; + jQuery.selectHelper.css('display','none'); + if (this.f.hc) + jQuery.selectHelper.removeClass(this.f.hc); + jQuery.selectdrug = false; + jQuery('body').append(jQuery.selectHelper.get(0)); + // + // In case we have selected some new items.. + if (jQuery.selectedone == true) { + if (this.f.onselect) + this.f.onselect(jQuery.Selectserialize(jQuery.attr(this,'id'))); + } else { + if (this.f.onselectstop) + this.f.onselectstop(jQuery.Selectserialize(jQuery.attr(this,'id'))); + } + // Reset current selection + jQuery.selectCurrent = []; +}; + +jQuery.Selectserialize = function(s) +{ + var h = ''; + var o = []; + if (a = jQuery('#' + s)) { + a.get(0).f.el.each( + function () + { + if (this.s == true) { + if (h.length > 0) { + h += '&'; + } + h += s + '[]=' + jQuery.attr(this,'id'); + o[o.length] = jQuery.attr(this,'id'); + } + } + ); + } + return {hash:h, o:o}; +}; +jQuery.fn.Selectable = function(o) +{ + if (!jQuery.selectHelper) { + jQuery('body',document).append('
').bind('keydown', jQuery.selectKeyDown).bind('keyup', jQuery.selectKeyUp); + jQuery.selectHelper = jQuery('#selectHelper'); + jQuery.selectHelper.css( + { + position: 'absolute', + display: 'none' + } + ); + + if (window.event) { + jQuery('body',document).bind('keydown', jQuery.selectKeyDown).bind('keyup', jQuery.selectKeyUp); + } else { + jQuery(document).bind('keydown', jQuery.selectKeyDown).bind('keyup', jQuery.selectKeyUp); + } + } + + if (!o) { + o = {}; + } + return this.each( + function() + { + if (this.isSelectable) + return; + this.isSelectable = true; + this.f = { + a : o.accept, + o : o.opacity ? parseFloat(o.opacity) : false, + sc : o.selectedclass ? o.selectedclass : false, + hc : o.helperclass ? o.helperclass : false, + onselect : o.onselect ? o.onselect : false, + onselectstop : o.onselectstop ? o.onselectstop : false + }; + this.f.el = jQuery('.' + o.accept); + jQuery(this).bind('mousedown', jQuery.selectstart); + } + ); +}; \ No newline at end of file Index: wp-includes/js/jquery/interface/ifxtransfer.js =================================================================== --- wp-includes/js/jquery/interface/ifxtransfer.js (revision 0) +++ wp-includes/js/jquery/interface/ifxtransfer.js (revision 0) @@ -0,0 +1,108 @@ +/** + * Interface Elements for jQuery + * FX - transfer + * + * http://interface.eyecon.ro + * + * Copyright (c) 2006 Stefan Petre + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * + */ + +jQuery.transferHelper = null; +/** + * + * @name TransferTo + * @description Animates an new build element to simulate a transfer action from one element to other + * @param Hash hash A hash of parameters + * @option Mixed to DOMElement or element ID to transfer to + * @option String className CSS class to apply to transfer element + * @option String duration animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast'] + * @option Function callback (optional) A function to be executed whenever the animation completes. + * + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ +jQuery.fn.TransferTo = function(o) +{ + return this.each(function(){ + if(!o || !o.to) { + return; + } + var el = this; + jQuery(o.to).each(function() { + new jQuery.fx.itransferTo(el, this, o); + }); + }); +}; +jQuery.fx.itransferTo = function(e, targetEl, o) +{ + var z = this; + z.el = jQuery(e); + z.targetEl = targetEl; + z.transferEl = document.createElement('div'); + jQuery(z.transferEl) + .css({ + position: 'absolute' + }).addClass(o.className); + + if (!o.duration) { + o.duration = 500; + } + z.duration = o.duration; + z.complete = o.complete; + z.diffWidth = 0; + z.diffHeight = 0; + + if(jQuery.boxModel) { + z.diffWidth = (parseInt(jQuery.curCSS(z.transferEl, 'borderLeftWidth')) || 0 ) + + (parseInt(jQuery.curCSS(z.transferEl, 'borderRightWidth')) || 0) + + (parseInt(jQuery.curCSS(z.transferEl, 'paddingLeft')) || 0) + + (parseInt(jQuery.curCSS(z.transferEl, 'paddingRight')) || 0); + z.diffHeight = (parseInt(jQuery.curCSS(z.transferEl, 'borderTopWidth')) || 0 ) + + (parseInt(jQuery.curCSS(z.transferEl, 'borderBottomWidth')) || 0) + + (parseInt(jQuery.curCSS(z.transferEl, 'paddingTop')) || 0) + + (parseInt(jQuery.curCSS(z.transferEl, 'paddingBottom')) || 0); + } + z.start = jQuery.extend( + jQuery.iUtil.getPosition(z.el.get(0)), + jQuery.iUtil.getSize(z.el.get(0)) + ); + z.end = jQuery.extend( + jQuery.iUtil.getPosition(z.targetEl), + jQuery.iUtil.getSize(z.targetEl) + ); + z.start.wb -= z.diffWidth; + z.start.hb -= z.diffHeight; + z.end.wb -= z.diffWidth; + z.end.hb -= z.diffHeight; + z.callback = o.complete; + jQuery('body').append(z.transferEl); + // Execute the transfer + jQuery(z.transferEl) + .css('width', z.start.wb + 'px') + .css('height', z.start.hb + 'px') + .css('top', z.start.y + 'px') + .css('left', z.start.x + 'px') + .animate( + { + top: z.end.y, + left: z.end.x, + width: z.end.wb, + height: z.end.hb + }, + z.duration, + function() + { + jQuery(z.transferEl).remove(); + + // Callback + if (z.complete && z.complete.constructor == Function) { + z.complete.apply(z.el.get(0), [z.to]); + } + } + ); +}; \ No newline at end of file Index: wp-includes/js/jquery/interface/islider.js =================================================================== --- wp-includes/js/jquery/interface/islider.js (revision 0) +++ wp-includes/js/jquery/interface/islider.js (revision 0) @@ -0,0 +1,301 @@ +/** + * Interface Elements for jQuery + * Slider + * + * http://interface.eyecon.ro + * + * Copyright (c) 2006 Stefan Petre + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * + */ + +jQuery.iSlider = { + tabindex : 1, + set : function (values) + { + var values = values; + return this.each( + function() + { + this.slideCfg.sliders.each( + function (key) + { + jQuery.iSlider.dragmoveBy(this,values[key]); + } + ); + } + ); + }, + + get : function() + { + var values = []; + this.each( + function(slider) + { + if (this.isSlider) { + values[slider] = []; + var elm = this; + var sizes = jQuery.iUtil.getSize(this); + this.slideCfg.sliders.each( + function (key) + { + var x = this.offsetLeft; + var y = this.offsetTop; + xproc = parseInt(x * 100 / (sizes.w - this.offsetWidth)); + yproc = parseInt(y * 100 / (sizes.h - this.offsetHeight)); + values[slider][key] = [xproc||0, yproc||0, x||0, y||0]; + } + ); + } + } + ); + return values; + }, + + modifyContainer : function (elm) + { + elm.dragCfg.containerMaxx = elm.dragCfg.cont.w - elm.dragCfg.oC.wb; + elm.dragCfg.containerMaxy = elm.dragCfg.cont.h - elm.dragCfg.oC.hb; + if (elm.SliderContainer.slideCfg.restricted ) { + next = elm.SliderContainer.slideCfg.sliders.get(elm.SliderIteration+1); + if (next) { + elm.dragCfg.cont.w = (parseInt(jQuery(next).css('left'))||0) + elm.dragCfg.oC.wb; + elm.dragCfg.cont.h = (parseInt(jQuery(next).css('top'))||0) + elm.dragCfg.oC.hb; + } + prev = elm.SliderContainer.slideCfg.sliders.get(elm.SliderIteration-1); + if (prev) { + var prevLeft = parseInt(jQuery(prev).css('left'))||0; + var prevTop = parseInt(jQuery(prev).css('left'))||0; + elm.dragCfg.cont.x += prevLeft; + elm.dragCfg.cont.y += prevTop; + elm.dragCfg.cont.w -= prevLeft; + elm.dragCfg.cont.h -= prevTop; + } + } + elm.dragCfg.maxx = elm.dragCfg.cont.w - elm.dragCfg.oC.wb; + elm.dragCfg.maxy = elm.dragCfg.cont.h - elm.dragCfg.oC.hb; + if(elm.dragCfg.fractions) { + elm.dragCfg.gx = ((elm.dragCfg.cont.w - elm.dragCfg.oC.wb)/elm.dragCfg.fractions) || 1; + elm.dragCfg.gy = ((elm.dragCfg.cont.h - elm.dragCfg.oC.hb)/elm.dragCfg.fractions) || 1; + elm.dragCfg.fracW = elm.dragCfg.maxx / elm.dragCfg.fractions; + elm.dragCfg.fracH = elm.dragCfg.maxy / elm.dragCfg.fractions; + } + + elm.dragCfg.cont.dx = elm.dragCfg.cont.x - elm.dragCfg.oR.x; + elm.dragCfg.cont.dy = elm.dragCfg.cont.y - elm.dragCfg.oR.y; + + jQuery.iDrag.helper.css('cursor', 'default'); + }, + + onSlide : function(elm, x, y) + { + if (elm.dragCfg.fractions) { + xfrac = parseInt(x/elm.dragCfg.fracW); + xproc = xfrac * 100 / elm.dragCfg.fractions; + yfrac = parseInt(y/elm.dragCfg.fracH); + yproc = yfrac * 100 / elm.dragCfg.fractions; + } else { + xproc = parseInt(x * 100 / elm.dragCfg.containerMaxx); + yproc = parseInt(y * 100 / elm.dragCfg.containerMaxy); + } + elm.dragCfg.lastSi = [xproc||0, yproc||0, x||0, y||0]; + if (elm.dragCfg.onSlide) + elm.dragCfg.onSlide.apply(elm, elm.dragCfg.lastSi); + }, + + dragmoveByKey : function (event) + { + pressedKey = event.charCode || event.keyCode || -1; + + switch (pressedKey) + { + //end + case 35: + jQuery.iSlider.dragmoveBy(this.dragElem, [2000, 2000] ); + break; + //home + case 36: + jQuery.iSlider.dragmoveBy(this.dragElem, [-2000, -2000] ); + break; + //left + case 37: + jQuery.iSlider.dragmoveBy(this.dragElem, [-this.dragElem.dragCfg.gx||-1, 0] ); + break; + //up + case 38: + jQuery.iSlider.dragmoveBy(this.dragElem, [0, -this.dragElem.dragCfg.gy||-1] ); + break; + //right + case 39: + jQuery.iSlider.dragmoveBy(this.dragElem, [this.dragElem.dragCfg.gx||1, 0] ); + break; + //down; + case 40: + jQuery.iDrag.dragmoveBy(this.dragElem, [0, this.dragElem.dragCfg.gy||1] ); + break; + } + }, + + dragmoveBy : function (elm, position) + { + if (!elm.dragCfg) { + return; + } + + elm.dragCfg.oC = jQuery.extend( + jQuery.iUtil.getPosition(elm), + jQuery.iUtil.getSize(elm) + ); + + elm.dragCfg.oR = { + x : parseInt(jQuery.css(elm, 'left'))||0, + y : parseInt(jQuery.css(elm, 'top'))||0 + }; + + elm.dragCfg.oP = jQuery.css(elm, 'position'); + if (elm.dragCfg.oP != 'relative' && elm.dragCfg.oP != 'absolute') { + elm.style.position = 'relative'; + } + + jQuery.iDrag.getContainment(elm); + jQuery.iSlider.modifyContainer(elm); + + dx = parseInt(position[0]) || 0; + dy = parseInt(position[1]) || 0; + + nx = elm.dragCfg.oR.x + dx; + ny = elm.dragCfg.oR.y + dy; + if(elm.dragCfg.fractions) { + newCoords = jQuery.iDrag.snapToGrid.apply(elm, [nx, ny, dx, dy]); + if (newCoords.constructor == Object) { + dx = newCoords.dx; + dy = newCoords.dy; + } + nx = elm.dragCfg.oR.x + dx; + ny = elm.dragCfg.oR.y + dy; + } + + newCoords = jQuery.iDrag.fitToContainer.apply(elm, [nx, ny, dx, dy]); + if (newCoords && newCoords.constructor == Object) { + dx = newCoords.dx; + dy = newCoords.dy; + } + + nx = elm.dragCfg.oR.x + dx; + ny = elm.dragCfg.oR.y + dy; + + if (elm.dragCfg.si && (elm.dragCfg.onSlide || elm.dragCfg.onChange)) { + jQuery.iSlider.onSlide(elm, nx, ny); + } + nx = !elm.dragCfg.axis || elm.dragCfg.axis == 'horizontally' ? nx : elm.dragCfg.oR.x||0; + ny = !elm.dragCfg.axis || elm.dragCfg.axis == 'vertically' ? ny : elm.dragCfg.oR.y||0; + elm.style.left = nx + 'px'; + elm.style.top = ny + 'px'; + }, + + build : function(o) { + return this.each( + function() + { + if (this.isSlider == true || !o.accept || !jQuery.iUtil || !jQuery.iDrag || !jQuery.iDrop){ + return; + } + toDrag = jQuery(o.accept, this); + if (toDrag.size() == 0) { + return; + } + var params = { + containment: 'parent', + si : true, + onSlide : o.onSlide && o.onSlide.constructor == Function ? o.onSlide : null, + onChange : o.onChange && o.onChange.constructor == Function ? o.onChange : null, + handle: this, + opacity: o.opacity||false + }; + if (o.fractions && parseInt(o.fractions)) { + params.fractions = parseInt(o.fractions)||1; + params.fractions = params.fractions > 0 ? params.fractions : 1; + } + if (toDrag.size() == 1) + toDrag.Draggable(params); + else { + jQuery(toDrag.get(0)).Draggable(params); + params.handle = null; + toDrag.Draggable(params); + } + toDrag.keydown(jQuery.iSlider.dragmoveByKey); + toDrag.attr('tabindex',jQuery.iSlider.tabindex++); + + this.isSlider = true; + this.slideCfg = {}; + this.slideCfg.onslide = params.onslide; + this.slideCfg.fractions = params.fractions; + this.slideCfg.sliders = toDrag; + this.slideCfg.restricted = o.restricted ? true : false; + sliderEl = this; + sliderEl.slideCfg.sliders.each( + function(nr) + { + this.SliderIteration = nr; + this.SliderContainer = sliderEl; + } + ); + if (o.values && o.values.constructor == Array) { + for (i = o.values.length -1; i>=0;i--) { + if (o.values[i].constructor == Array && o.values[i].length == 2) { + el = this.slideCfg.sliders.get(i); + if (el.tagName) { + jQuery.iSlider.dragmoveBy(el, o.values[i]); + } + } + } + } + } + ); + } +}; +jQuery.fn.extend( + { + /** + * Create a slider width options + * + * @name Slider + * @description Create a slider width options + * @param Hash hash A hash of parameters. All parameters are optional. + * @option Mixed accepts string to select slider indicators or DOMElement slider indicator + * @option Integer factions (optional) number of sgments to divide and snap slider + * @option Function onSlide (optional) A function to be executed whenever slider indicator it is moved + * @option Function onChanged (optional) A function to be executed whenever slider indicator was moved + * @option Array values (optional) Initial values for slider indicators + * @option Boolean restricted (optional) if true the slider indicator can not be moved beyond adjacent indicators + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ + Slider : jQuery.iSlider.build, + /** + * Set value/position for slider indicators + * + * @name SliderSetValues + * @description Set value/position for slider indicators + * @param Array values array width values for each indicator + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ + SliderSetValues : jQuery.iSlider.set, + /** + * Get value/position for slider indicators + * + * @name SliderSetValues + * @description Get value/position for slider indicators + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ + SliderGetValues : jQuery.iSlider.get + } +); \ No newline at end of file Index: wp-includes/js/jquery/interface/imagebox.js =================================================================== --- wp-includes/js/jquery/interface/imagebox.js (revision 0) +++ wp-includes/js/jquery/interface/imagebox.js (revision 0) @@ -0,0 +1,595 @@ +/** + * Interface Elements for jQuery + * ImageBox + * + * http://interface.eyecon.ro + * + * Copyright (c) 2006 Stefan Petre + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + */ + +/** + * This a jQuery equivalent for Lightbox2. Alternative to image popups that will display images in an overlay. All links that have attribute 'rel' starting with 'imagebox' and link to an image will display the image inside the page. Galleries can by build buy giving the value 'imagebox-galname' to attribute 'rel'. Attribute 'title' will be used as caption. + * Keyboard navigation: + * - next image: arrow right, page down, 'n' key, space + * - previous image: arrow left, page up, 'p' key, backspace + * - close: escape + * + * CSS + * #ImageBoxOverlay + * { + * background-color: #000; + * } + * #ImageBoxCaption + * { + * background-color: #F4F4EC; + * } + * #ImageBoxContainer + * { + * width: 250px; + * height: 250px; + * background-color: #F4F4EC; + * } + * #ImageBoxCaptionText + * { + * font-weight: bold; + * padding-bottom: 5px; + * font-size: 13px; + * color: #000; + * } + * #ImageBoxCaptionImages + * { + * margin: 0; + * } + * #ImageBoxNextImage + * { + * background-image: url(images/imagebox/spacer.gif); + * background-color: transparent; + * } + * #ImageBoxPrevImage + * { + * background-image: url(images/imagebox/spacer.gif); + * background-color: transparent; + * } + * #ImageBoxNextImage:hover + * { + * background-image: url(images/imagebox/next_image.jpg); + * background-repeat: no-repeat; + * background-position: right top; + * } + * #ImageBoxPrevImage:hover + * { + * background-image: url(images/imagebox/prev_image.jpg); + * background-repeat: no-repeat; + * background-position: left bottom; + * } + * + * @name Imagebox + * @description This a jQuery equivalent for Lightbox2. Alternative to image popups that will display images in an overlay. All links that have attribute 'rel' starting with 'imagebox' and link to an image will display the image inside the page. Galleries can by build buy giving the value 'imagebox-galname' to attribute 'rel'. Attribute 'title' will be used as caption. + * @param Hash hash A hash of parameters + * @option Integer border border width + * @option String loaderSRC path to loading image + * @option String closeHTML path to close overlay image + * @option Float overlayOpacity opacity for overlay + * @option String textImage when a galalry it is build then the iteration is displayed + * @option String textImageFrom when a galalry it is build then the iteration is displayed + * @option Integer fadeDuration fade duration in miliseconds + * + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ +jQuery.ImageBox = { + options : { + border : 10, + loaderSRC : 'images/loading.gif', + closeHTML : '', + overlayOpacity : 0.8, + textImage : 'Showing image', + textImageFrom : 'from', + fadeDuration : 400 + }, + imageLoaded : false, + firstResize : false, + currentRel : null, + animationInProgress : false, + opened : false, + + keyPressed : function(event) + { + if(!jQuery.ImageBox.opened || jQuery.ImageBox.animationInProgress) + return; + var pressedKey = event.charCode || event.keyCode || -1; + switch (pressedKey) + { + //end + case 35: + if (jQuery.ImageBox.currentRel) + jQuery.ImageBox.start(null, jQuery('a[@rel=' + jQuery.ImageBox.currentRel+ ']:last').get(0)); + break; + //home + case 36: + if (jQuery.ImageBox.currentRel) + jQuery.ImageBox.start(null, jQuery('a[@rel=' + jQuery.ImageBox.currentRel+ ']:first').get(0)); + break; + //left + case 37: + //backspace + case 8: + //page up + case 33: + //p + case 80: + case 112: + var prevEl = jQuery('#ImageBoxPrevImage'); + if(prevEl.get(0).onclick != null) { + prevEl.get(0).onclick.apply(prevEl.get(0)); + } + break; + //up + case 38: + break; + //right + case 39: + //page down + case 34: + //space + case 32: + //n + case 110: + case 78: + var nextEl = jQuery('#ImageBoxNextImage'); + if(nextEl.get(0).onclick != null) { + nextEl.get(0).onclick.apply(nextEl.get(0)); + } + break; + //down; + case 40: + break; + //escape + case 27: + jQuery.ImageBox.hideImage(); + break; + } + }, + + init : function(options) + { + if (options) + jQuery.extend(jQuery.ImageBox.options, options); + if (window.event) { + jQuery('body',document).bind('keyup', jQuery.ImageBox.keyPressed); + } else { + jQuery(document).bind('keyup', jQuery.ImageBox.keyPressed); + } + jQuery('a').each( + function() + { + el = jQuery(this); + relAttr = el.attr('rel')||''; + hrefAttr = el.attr('href')||''; + imageTypes = /\.jpg|\.jpeg|\.png|\.gif|\.bmp/g; + if (hrefAttr.toLowerCase().match(imageTypes) != null && relAttr.toLowerCase().indexOf('imagebox') == 0) { + el.bind('click', jQuery.ImageBox.start); + } + } + ); + if (jQuery.browser.msie) { + iframe = document.createElement('iframe'); + jQuery(iframe) + .attr( + { + id : 'ImageBoxIframe', + src : 'javascript:false;', + frameborder : 'no', + scrolling : 'no' + } + ) + .css ( + { + display : 'none', + position : 'absolute', + top : '0', + left : '0', + filter : 'progid:DXImageTransform.Microsoft.Alpha(opacity=0)' + } + ); + jQuery('body').append(iframe); + } + + overlay = document.createElement('div'); + jQuery(overlay) + .attr('id', 'ImageBoxOverlay') + .css( + { + position : 'absolute', + display : 'none', + top : '0', + left : '0', + opacity : 0 + } + ) + .append(document.createTextNode(' ')) + .bind('click', jQuery.ImageBox.hideImage); + + captionText = document.createElement('div'); + jQuery(captionText) + .attr('id', 'ImageBoxCaptionText') + .css( + { + paddingLeft : jQuery.ImageBox.options.border + 'px' + } + ) + .append(document.createTextNode(' ')); + + captionImages = document.createElement('div'); + jQuery(captionImages) + .attr('id', 'ImageBoxCaptionImages') + .css( + { + paddingLeft : jQuery.ImageBox.options.border + 'px', + paddingBottom : jQuery.ImageBox.options.border + 'px' + } + ) + .append(document.createTextNode(' ')); + + closeEl = document.createElement('a'); + jQuery(closeEl) + .attr( + { + id : 'ImageBoxClose', + href : '#' + } + ) + .css( + { + position : 'absolute', + right : jQuery.ImageBox.options.border + 'px', + top : '0' + } + ) + .append(jQuery.ImageBox.options.closeHTML) + .bind('click', jQuery.ImageBox.hideImage); + + captionEl = document.createElement('div'); + jQuery(captionEl) + .attr('id', 'ImageBoxCaption') + .css( + { + position : 'relative', + textAlign : 'left', + margin : '0 auto', + zIndex : 1 + } + ) + .append(captionText) + .append(captionImages) + .append(closeEl); + + loader = document.createElement('img'); + loader.src = jQuery.ImageBox.options.loaderSRC; + jQuery(loader) + .attr('id', 'ImageBoxLoader') + .css( + { + position : 'absolute' + } + ); + + prevImage = document.createElement('a'); + jQuery(prevImage) + .attr( + { + id : 'ImageBoxPrevImage', + href : '#' + } + ) + .css( + { + position : 'absolute', + display : 'none', + overflow : 'hidden', + textDecoration : 'none' + } + ) + .append(document.createTextNode(' ')); + + nextImage = document.createElement('a'); + jQuery(nextImage) + .attr( + { + id : 'ImageBoxNextImage', + href : '#' + } + ) + .css( + { + position : 'absolute', + overflow : 'hidden', + textDecoration : 'none' + } + ) + .append(document.createTextNode(' ')); + + container = document.createElement('div'); + jQuery(container) + .attr('id', 'ImageBoxContainer') + .css( + { + display : 'none', + position : 'relative', + overflow : 'hidden', + textAlign : 'left', + margin : '0 auto', + top : '0', + left : '0', + zIndex : 2 + } + ) + .append([loader, prevImage, nextImage]); + + outerContainer = document.createElement('div'); + jQuery(outerContainer) + .attr('id', 'ImageBoxOuterContainer') + .css( + { + display : 'none', + position : 'absolute', + overflow : 'hidden', + top : '0', + left : '0', + textAlign : 'center', + backgroundColor : 'transparent', + lineHeigt : '0' + } + ) + .append([container,captionEl]); + + jQuery('body') + .append(overlay) + .append(outerContainer); + }, + + start : function(e, elm) + { + el = elm ? jQuery(elm) : jQuery(this); + linkRel = el.attr('rel'); + var totalImages, iteration, prevImage, nextImage; + if (linkRel != 'imagebox') { + jQuery.ImageBox.currentRel = linkRel; + gallery = jQuery('a[@rel=' + linkRel + ']'); + totalImages = gallery.size(); + iteration = gallery.index(elm ? elm : this); + prevImage = gallery.get(iteration - 1); + nextImage = gallery.get(iteration + 1); + } + imageSrc = el.attr('href'); + captionText = el.attr('title'); + pageSize = jQuery.iUtil.getScroll(); + overlay = jQuery('#ImageBoxOverlay'); + if (!jQuery.ImageBox.opened) { + jQuery.ImageBox.opened = true; + if (jQuery.browser.msie) { + jQuery('#ImageBoxIframe') + .css ('height', Math.max(pageSize.ih,pageSize.h) + 'px') + .css ('width', Math.max(pageSize.iw,pageSize.w) + 'px') + .show(); + } + overlay + .css ('height', Math.max(pageSize.ih,pageSize.h) + 'px') + .css ('width', Math.max(pageSize.iw,pageSize.w) + 'px') + .show() + .fadeTo( + 300, + jQuery.ImageBox.options.overlayOpacity, + function() + { + jQuery.ImageBox.loadImage( + imageSrc, + captionText, + pageSize, + totalImages, + iteration, + prevImage, + nextImage + ); + } + ); + jQuery('#ImageBoxOuterContainer').css ('width', Math.max(pageSize.iw,pageSize.w) + 'px'); + } else { + jQuery('#ImageBoxPrevImage').get(0).onclick = null; + jQuery('#ImageBoxNextImage').get(0).onclick = null; + jQuery.ImageBox.loadImage( + imageSrc, + captionText, + pageSize, + totalImages, + iteration, + prevImage, + nextImage + ); + } + return false; + }, + + loadImage : function(imageSrc, captiontext, pageSize, totalImages, iteration, prevImage, nextImage) + { + jQuery('#ImageBoxCurrentImage').remove(); + prevImageEl = jQuery('#ImageBoxPrevImage'); + prevImageEl.hide(); + nextImageEl = jQuery('#ImageBoxNextImage'); + nextImageEl.hide(); + loader = jQuery('#ImageBoxLoader'); + container = jQuery('#ImageBoxContainer'); + outerContainer = jQuery('#ImageBoxOuterContainer'); + captionEl = jQuery('#ImageBoxCaption').css('visibility', 'hidden'); + jQuery('#ImageBoxCaptionText').html(captionText); + jQuery.ImageBox.animationInProgress = true; + if (totalImages) + jQuery('#ImageBoxCaptionImages').html( + jQuery.ImageBox.options.textImage + + ' ' + (iteration + 1) + ' ' + + jQuery.ImageBox.options.textImageFrom + + ' ' + totalImages + ); + if (prevImage) { + prevImageEl.get(0).onclick = function() + { + this.blur(); + jQuery.ImageBox.start(null, prevImage); + return false; + }; + } + if (nextImage) { + nextImageEl.get(0).onclick =function() + { + this.blur(); + jQuery.ImageBox.start(null, nextImage); + return false; + }; + } + loader.show(); + containerSize = jQuery.iUtil.getSize(container.get(0)); + containerW = Math.max(containerSize.wb, loader.get(0).width + jQuery.ImageBox.options.border * 2); + containerH = Math.max(containerSize.hb, loader.get(0).height + jQuery.ImageBox.options.border * 2); + loader + .css( + { + left : (containerW - loader.get(0).width)/2 + 'px', + top : (containerH - loader.get(0).height)/2 + 'px' + } + ); + container + .css( + { + width : containerW + 'px', + height : containerH + 'px' + } + ) + .show(); + clientSize = jQuery.iUtil.getClient(); + outerContainer + .css('top', pageSize.t + (clientSize.h / 15) + 'px'); + if (outerContainer.css('display') == 'none') { + outerContainer + .show() + .fadeIn( + jQuery.ImageBox.options.fadeDuration + ); + } + imageEl = new Image; + jQuery(imageEl) + .attr('id', 'ImageBoxCurrentImage') + .bind('load', + function() + { + containerW = imageEl.width + jQuery.ImageBox.options.border * 2; + containerH = imageEl.height + jQuery.ImageBox.options.border * 2; + loader.hide(); + container.animate( + { + height : containerH + }, + containerSize.hb != containerH ? jQuery.ImageBox.options.fadeDuration : 1, + function() + { + container.animate( + { + width : containerW + }, + containerSize.wb != containerW ? jQuery.ImageBox.options.fadeDuration : 1, + function() + { + container.prepend(imageEl); + jQuery(imageEl) + .css( + { + position : 'absolute', + left : jQuery.ImageBox.options.border + 'px', + top : jQuery.ImageBox.options.border + 'px' + } + ) + .fadeIn( + jQuery.ImageBox.options.fadeDuration, + function() + { + captionSize = jQuery.iUtil.getSize(captionEl.get(0)); + if (prevImage) { + prevImageEl + .css( + { + left : jQuery.ImageBox.options.border + 'px', + top : jQuery.ImageBox.options.border + 'px', + width : containerW/2 - jQuery.ImageBox.options.border * 3 + 'px', + height : containerH - jQuery.ImageBox.options.border * 2 + 'px' + } + ) + .show(); + } + if (nextImage) { + nextImageEl + .css( + { + left : containerW/2 + jQuery.ImageBox.options.border * 2 + 'px', + top : jQuery.ImageBox.options.border + 'px', + width : containerW/2 - jQuery.ImageBox.options.border * 3 + 'px', + height : containerH - jQuery.ImageBox.options.border * 2 + 'px' + } + ) + .show(); + } + captionEl + .css( + { + width : containerW + 'px', + top : - captionSize.hb + 'px', + visibility : 'visible' + } + ) + .animate( + { + top : -1 + }, + jQuery.ImageBox.options.fadeDuration, + function() + { + jQuery.ImageBox.animationInProgress = false; + } + ); + } + ); + } + ); + } + ); + } + ); + imageEl.src = imageSrc; + + }, + + hideImage : function() + { + jQuery('#ImageBoxCurrentImage').remove(); + jQuery('#ImageBoxOuterContainer').hide(); + jQuery('#ImageBoxCaption').css('visibility', 'hidden'); + jQuery('#ImageBoxOverlay').fadeTo( + 300, + 0, + function(){ + jQuery(this).hide(); + if (jQuery.browser.msie) { + jQuery('#ImageBoxIframe').hide(); + } + } + ); + jQuery('#ImageBoxPrevImage').get(0).onclick = null; + jQuery('#ImageBoxNextImage').get(0).onclick = null; + jQuery.ImageBox.currentRel = null; + jQuery.ImageBox.opened = false; + jQuery.ImageBox.animationInProgress = false; + return false; + } +}; \ No newline at end of file Index: wp-includes/js/jquery/interface/iautocompleter.js =================================================================== --- wp-includes/js/jquery/interface/iautocompleter.js (revision 0) +++ wp-includes/js/jquery/interface/iautocompleter.js (revision 0) @@ -0,0 +1,536 @@ +/** + * Interface Elements for jQuery + * Autocompleter + * + * http://interface.eyecon.ro + * + * Copyright (c) 2006 Stefan Petre + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + */ + +/** + * Attach AJAX driven autocomplete/sugestion box to text input fields. + * + * + * + * @name Autocomplete + * @description Attach AJAX driven autocomplete/sugestion box to text input fields. + * @param Hash hash A hash of parameters + * @option String source the URL to request + * @option Integer delay (optional) the delayed time to start the AJAX request + * @option Boolean autofill (optional) when true the first sugested value fills the input + * @option String helperClass (optional) the CSS class applied to sugestion box + * @option String selectClass (optional) the CSS class applied to selected/hovered item + * @option Integer minchars (optional) the number of characters needed before starting AJAX request + * @option Hash fx (optional) {type:[slide|blind|fade]; duration: integer} the fx type to apply to sugestion box and duration for that fx + * @option Function onSelect (optional) A function to be executed whenever an item it is selected + * @option Function onShow (optional) A function to be executed whenever the suggection box is displayed + * @option Function onHide (optional) A function to be executed whenever the suggection box is hidden + * @option Function onHighlight (optional) A function to be executed whenever an item it is highlighted + * + * @type jQuery + * @cat Plugins/Interface + * @author Stefan Petre + */ +jQuery.iAuto = { + helper : null, + content : null, + iframe: null, + timer : null, + lastValue: null, + currentValue: null, + subject: null, + selectedItem : null, + items: null, + + empty : function() + { + jQuery.iAuto.content.empty(); + if (jQuery.iAuto.iframe) { + jQuery.iAuto.iframe.hide(); + } + }, + + clear : function() + { + jQuery.iAuto.items = null; + jQuery.iAuto.selectedItem = null; + jQuery.iAuto.lastValue = jQuery.iAuto.subject.value; + if(jQuery.iAuto.helper.css('display') == 'block') { + if (jQuery.iAuto.subject.autoCFG.fx) { + switch(jQuery.iAuto.subject.autoCFG.fx.type) { + case 'fade': + jQuery.iAuto.helper.fadeOut(jQuery.iAuto.subject.autoCFG.fx.duration, jQuery.iAuto.empty); + break; + case 'slide': + jQuery.iAuto.helper.SlideOutUp(jQuery.iAuto.subject.autoCFG.fx.duration, jQuery.iAuto.empty); + break; + case 'blind': + jQuery.iAuto.helper.BlindUp(jQuery.iAuto.subject.autoCFG.fx.duration, jQuery.iAuto.empty); + break; + } + } else { + jQuery.iAuto.helper.hide(); + } + if (jQuery.iAuto.subject.autoCFG.onHide) + jQuery.iAuto.subject.autoCFG.onHide.apply(jQuery.iAuto.subject, [jQuery.iAuto.helper, jQuery.iAuto.iframe]); + } else { + jQuery.iAuto.empty(); + } + window.clearTimeout(jQuery.iAuto.timer); + }, + + update : function () + { + var subject = jQuery.iAuto.subject; + var subjectValue = jQuery.iAuto.getFieldValues(subject); + //var selectionStart = jQuery.iAuto.getSelectionStart(subject); + if (subject && subjectValue.item != jQuery.iAuto.lastValue && subjectValue.item.length >= subject.autoCFG.minchars) { + jQuery.iAuto.lastValue = subjectValue.item; + jQuery.iAuto.currentValue = subjectValue.item; + + data = { + field: jQuery(subject).attr('name')||'field', + value: subjectValue.item + }; + + jQuery.ajax( + { + type: 'POST', + data: jQuery.param(data), + success: function(xml) + { + subject.autoCFG.lastSuggestion = jQuery('item',xml); + size = subject.autoCFG.lastSuggestion.size(); + if (size > 0) { + var toWrite = ''; + subject.autoCFG.lastSuggestion.each( + function(nr) + { + toWrite += '
  • ' + jQuery('text', this).text() + '
  • '; + } + ); + if (subject.autoCFG.autofill) { + var valueToAdd = jQuery('value', subject.autoCFG.lastSuggestion.get(0)).text(); + subject.value = subjectValue.pre + valueToAdd + subject.autoCFG.multipleSeparator + subjectValue.post; + jQuery.iAuto.selection( + subject, + subjectValue.item.length != valueToAdd.length ? (subjectValue.pre.length + subjectValue.item.length) : valueToAdd.length, + subjectValue.item.length != valueToAdd.length ? (subjectValue.pre.length + valueToAdd.length) : valueToAdd.length + ); + } + + if (size > 0) { + jQuery.iAuto.writeItems(subject, toWrite); + } else { + jQuery.iAuto.clear(); + } + } else { + jQuery.iAuto.clear(); + } + }, + url : subject.autoCFG.source + } + ); + } + }, + + writeItems : function(subject, toWrite) + { + jQuery.iAuto.content.html(toWrite); + jQuery.iAuto.items = jQuery('li', jQuery.iAuto.content.get(0)); + jQuery.iAuto.items + .mouseover(jQuery.iAuto.hoverItem) + .bind('click', jQuery.iAuto.clickItem); + var position = jQuery.iUtil.getPosition(subject); + var size = jQuery.iUtil.getSize(subject); + jQuery.iAuto.helper + .css('top', position.y + size.hb + 'px') + .css('left', position.x + 'px') + .addClass(subject.autoCFG.helperClass); + if (jQuery.iAuto.iframe) { + jQuery.iAuto.iframe + .css('display', 'block') + .css('top', position.y + size.hb + 'px') + .css('left', position.x + 'px') + .css('width', jQuery.iAuto.helper.css('width')) + .css('height', jQuery.iAuto.helper.css('height')); + } + jQuery.iAuto.selectedItem = 0; + jQuery.iAuto.items.get(0).className = subject.autoCFG.selectClass; + jQuery.iAuto.applyOn(subject,subject.autoCFG.lastSuggestion.get(0), 'onHighlight'); + + if (jQuery.iAuto.helper.css('display') == 'none') { + if (subject.autoCFG.inputWidth) { + var borders = jQuery.iUtil.getPadding(subject, true); + var paddings = jQuery.iUtil.getBorder(subject, true); + jQuery.iAuto.helper.css('width', subject.offsetWidth - (jQuery.boxModel ? (borders.l + borders.r + paddings.l + paddings.r) : 0 ) + 'px'); + } + if (subject.autoCFG.fx) { + switch(subject.autoCFG.fx.type) { + case 'fade': + jQuery.iAuto.helper.fadeIn(subject.autoCFG.fx.duration); + break; + case 'slide': + jQuery.iAuto.helper.SlideInUp(subject.autoCFG.fx.duration); + break; + case 'blind': + jQuery.iAuto.helper.BlindDown(subject.autoCFG.fx.duration); + break; + } + } else { + jQuery.iAuto.helper.show(); + } + + if (jQuery.iAuto.subject.autoCFG.onShow) + jQuery.iAuto.subject.autoCFG.onShow.apply(jQuery.iAuto.subject, [jQuery.iAuto.helper, jQuery.iAuto.iframe]); + } + }, + + checkCache : function() + { + var subject = this; + if (subject.autoCFG.lastSuggestion) { + + jQuery.iAuto.lastValue = subject.value; + jQuery.iAuto.currentValue = subject.value; + + var toWrite = ''; + subject.autoCFG.lastSuggestion.each( + function(nr) + { + value = jQuery('value', this).text().toLowerCase(); + inputValue = subject.value.toLowerCase(); + if (value.indexOf(inputValue) == 0) { + toWrite += '
  • ' + jQuery('text', this).text() + '
  • '; + } + } + ); + + if (toWrite != '') { + jQuery.iAuto.writeItems(subject, toWrite); + + this.autoCFG.inCache = true; + return; + } + } + subject.autoCFG.lastSuggestion = null; + this.autoCFG.inCache = false; + }, + + selection : function(field, start, end) + { + if (field.createTextRange) { + var selRange = field.createTextRange(); + selRange.collapse(true); + selRange.moveStart("character", start); + selRange.moveEnd("character", - end + start); + selRange.select(); + } else if (field.setSelectionRange) { + field.setSelectionRange(start, end); + } else { + if (field.selectionStart) { + field.selectionStart = start; + field.selectionEnd = end; + } + } + field.focus(); + }, + + getSelectionStart : function(field) + { + if (field.selectionStart) + return field.selectionStart; + else if(field.createTextRange) { + var selRange = document.selection.createRange(); + var selRange2 = selRange.duplicate(); + return 0 - selRange2.moveStart('character', -100000); + //result.end = result.start + range.text.length; + /*var selRange = document.selection.createRange(); + var isCollapsed = selRange.compareEndPoints("StartToEnd", selRange) == 0; + if (!isCollapsed) + selRange.collapse(true); + var bookmark = selRange.getBookmark(); + return bookmark.charCodeAt(2) - 2;*/ + } + }, + + getFieldValues : function(field) + { + var fieldData = { + value: field.value, + pre: '', + post: '', + item: '' + }; + + if(field.autoCFG.multiple) { + var finishedPre = false; + var selectionStart = jQuery.iAuto.getSelectionStart(field)||0; + var chunks = fieldData.value.split(field.autoCFG.multipleSeparator); + for (var i=0; i= selectionStart + || + selectionStart == 0) + && + !finishedPre + ) { + if (fieldData.pre.length <= selectionStart) + fieldData.item = chunks[i]; + else + fieldData.post += chunks[i] + (chunks[i] != '' ? field.autoCFG.multipleSeparator : ''); + finishedPre = true; + } else if (finishedPre){ + fieldData.post += chunks[i] + (chunks[i] != '' ? field.autoCFG.multipleSeparator : ''); + } + if(!finishedPre) { + fieldData.pre += chunks[i] + (chunks.length > 1 ? field.autoCFG.multipleSeparator : ''); + } + } + } else { + fieldData.item = fieldData.value; + } + return fieldData; + }, + + autocomplete : function(e) + { + window.clearTimeout(jQuery.iAuto.timer); + var subject = jQuery.iAuto.getFieldValues(this); + + var pressedKey = e.charCode || e.keyCode || -1; + if (/^13$|27$|35$|36$|38$|40$|^9$/.test(pressedKey) && jQuery.iAuto.items) { + if (window.event) { + window.event.cancelBubble = true; + window.event.returnValue = false; + } else { + e.preventDefault(); + e.stopPropagation(); + } + if (jQuery.iAuto.selectedItem != null) + jQuery.iAuto.items.get(jQuery.iAuto.selectedItem||0).className = ''; + else + jQuery.iAuto.selectedItem = -1; + switch(pressedKey) { + //enter + case 9: + case 13: + if (jQuery.iAuto.selectedItem == -1) + jQuery.iAuto.selectedItem = 0; + var selectedItem = jQuery.iAuto.items.get(jQuery.iAuto.selectedItem||0); + var valueToAdd = selectedItem.getAttribute('rel'); + this.value = subject.pre + valueToAdd + this.autoCFG.multipleSeparator + subject.post; + jQuery.iAuto.lastValue = subject.item; + jQuery.iAuto.selection( + this, + subject.pre.length + valueToAdd.length + this.autoCFG.multipleSeparator.length, + subject.pre.length + valueToAdd.length + this.autoCFG.multipleSeparator.length + ); + jQuery.iAuto.clear(); + if (this.autoCFG.onSelect) { + iteration = parseInt(selectedItem.getAttribute('dir'))||0; + jQuery.iAuto.applyOn(this,this.autoCFG.lastSuggestion.get(iteration), 'onSelect'); + } + if (this.scrollIntoView) + this.scrollIntoView(false); + return pressedKey != 13; + break; + //escape + case 27: + this.value = subject.pre + jQuery.iAuto.lastValue + this.autoCFG.multipleSeparator + subject.post; + this.autoCFG.lastSuggestion = null; + jQuery.iAuto.clear(); + if (this.scrollIntoView) + this.scrollIntoView(false); + return false; + break; + //end + case 35: + jQuery.iAuto.selectedItem = jQuery.iAuto.items.size() - 1; + break; + //home + case 36: + jQuery.iAuto.selectedItem = 0; + break; + //up + case 38: + jQuery.iAuto.selectedItem --; + if (jQuery.iAuto.selectedItem < 0) + jQuery.iAuto.selectedItem = jQuery.iAuto.items.size() - 1; + break; + case 40: + jQuery.iAuto.selectedItem ++; + if (jQuery.iAuto.selectedItem == jQuery.iAuto.items.size()) + jQuery.iAuto.selectedItem = 0; + break; + } + jQuery.iAuto.applyOn(this,this.autoCFG.lastSuggestion.get(jQuery.iAuto.selectedItem||0), 'onHighlight'); + jQuery.iAuto.items.get(jQuery.iAuto.selectedItem||0).className = this.autoCFG.selectClass; + if (jQuery.iAuto.items.get(jQuery.iAuto.selectedItem||0).scrollIntoView) + jQuery.iAuto.items.get(jQuery.iAuto.selectedItem||0).scrollIntoView(false); + if(this.autoCFG.autofill) { + var valToAdd = jQuery.iAuto.items.get(jQuery.iAuto.selectedItem||0).getAttribute('rel'); + this.value = subject.pre + valToAdd + this.autoCFG.multipleSeparator + subject.post; + if(jQuery.iAuto.lastValue.length != valToAdd.length) + jQuery.iAuto.selection( + this, + subject.pre.length + jQuery.iAuto.lastValue.length, + subject.pre.length + valToAdd.length + ); + } + return false; + } + jQuery.iAuto.checkCache.apply(this); + + if (this.autoCFG.inCache == false) { + if (subject.item != jQuery.iAuto.lastValue && subject.item.length >= this.autoCFG.minchars) + jQuery.iAuto.timer = window.setTimeout(jQuery.iAuto.update, this.autoCFG.delay); + if (jQuery.iAuto.items) { + jQuery.iAuto.clear(); + } + } + return true; + }, + + applyOn: function(field, item, type) + { + if (field.autoCFG[type]) { + var data = {}; + childs = item.getElementsByTagName('*'); + for(i=0; i