Initial.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/external/__init__.py Mon Feb 20 15:10:53 2012 +0100
1.3 @@ -0,0 +1,1 @@
1.4 +
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/external/argparse.py Mon Feb 20 15:10:53 2012 +0100
2.3 @@ -0,0 +1,2312 @@
2.4 +# Author: Steven J. Bethard <steven.bethard@gmail.com>.
2.5 +
2.6 +"""Command-line parsing library
2.7 +
2.8 +This module is an optparse-inspired command-line parsing library that:
2.9 +
2.10 + - handles both optional and positional arguments
2.11 + - produces highly informative usage messages
2.12 + - supports parsers that dispatch to sub-parsers
2.13 +
2.14 +The following is a simple usage example that sums integers from the
2.15 +command-line and writes the result to a file::
2.16 +
2.17 + parser = argparse.ArgumentParser(
2.18 + description='sum the integers at the command line')
2.19 + parser.add_argument(
2.20 + 'integers', metavar='int', nargs='+', type=int,
2.21 + help='an integer to be summed')
2.22 + parser.add_argument(
2.23 + '--log', default=sys.stdout, type=argparse.FileType('w'),
2.24 + help='the file where the sum should be written')
2.25 + args = parser.parse_args()
2.26 + args.log.write('%s' % sum(args.integers))
2.27 + args.log.close()
2.28 +
2.29 +The module contains the following public classes:
2.30 +
2.31 + - ArgumentParser -- The main entry point for command-line parsing. As the
2.32 + example above shows, the add_argument() method is used to populate
2.33 + the parser with actions for optional and positional arguments. Then
2.34 + the parse_args() method is invoked to convert the args at the
2.35 + command-line into an object with attributes.
2.36 +
2.37 + - ArgumentError -- The exception raised by ArgumentParser objects when
2.38 + there are errors with the parser's actions. Errors raised while
2.39 + parsing the command-line are caught by ArgumentParser and emitted
2.40 + as command-line messages.
2.41 +
2.42 + - FileType -- A factory for defining types of files to be created. As the
2.43 + example above shows, instances of FileType are typically passed as
2.44 + the type= argument of add_argument() calls.
2.45 +
2.46 + - Action -- The base class for parser actions. Typically actions are
2.47 + selected by passing strings like 'store_true' or 'append_const' to
2.48 + the action= argument of add_argument(). However, for greater
2.49 + customization of ArgumentParser actions, subclasses of Action may
2.50 + be defined and passed as the action= argument.
2.51 +
2.52 + - HelpFormatter, RawDescriptionHelpFormatter, RawTextHelpFormatter,
2.53 + ArgumentDefaultsHelpFormatter -- Formatter classes which
2.54 + may be passed as the formatter_class= argument to the
2.55 + ArgumentParser constructor. HelpFormatter is the default,
2.56 + RawDescriptionHelpFormatter and RawTextHelpFormatter tell the parser
2.57 + not to change the formatting for help text, and
2.58 + ArgumentDefaultsHelpFormatter adds information about argument defaults
2.59 + to the help.
2.60 +
2.61 +All other classes in this module are considered implementation details.
2.62 +(Also note that HelpFormatter and RawDescriptionHelpFormatter are only
2.63 +considered public as object names -- the API of the formatter objects is
2.64 +still considered an implementation detail.)
2.65 +"""
2.66 +
2.67 +__version__ = '1.1'
2.68 +__all__ = [
2.69 + 'ArgumentParser',
2.70 + 'ArgumentError',
2.71 + 'Namespace',
2.72 + 'Action',
2.73 + 'FileType',
2.74 + 'HelpFormatter',
2.75 + 'RawDescriptionHelpFormatter',
2.76 + 'RawTextHelpFormatter',
2.77 + 'ArgumentDefaultsHelpFormatter',
2.78 +]
2.79 +
2.80 +
2.81 +import copy as _copy
2.82 +import os as _os
2.83 +import re as _re
2.84 +import sys as _sys
2.85 +import textwrap as _textwrap
2.86 +
2.87 +from gettext import gettext as _
2.88 +
2.89 +
2.90 +def _callable(obj):
2.91 + return hasattr(obj, '__call__') or hasattr(obj, '__bases__')
2.92 +
2.93 +
2.94 +SUPPRESS = '==SUPPRESS=='
2.95 +
2.96 +OPTIONAL = '?'
2.97 +ZERO_OR_MORE = '*'
2.98 +ONE_OR_MORE = '+'
2.99 +PARSER = 'A...'
2.100 +REMAINDER = '...'
2.101 +
2.102 +# =============================
2.103 +# Utility functions and classes
2.104 +# =============================
2.105 +
2.106 +class _AttributeHolder(object):
2.107 + """Abstract base class that provides __repr__.
2.108 +
2.109 + The __repr__ method returns a string in the format::
2.110 + ClassName(attr=name, attr=name, ...)
2.111 + The attributes are determined either by a class-level attribute,
2.112 + '_kwarg_names', or by inspecting the instance __dict__.
2.113 + """
2.114 +
2.115 + def __repr__(self):
2.116 + type_name = type(self).__name__
2.117 + arg_strings = []
2.118 + for arg in self._get_args():
2.119 + arg_strings.append(repr(arg))
2.120 + for name, value in self._get_kwargs():
2.121 + arg_strings.append('%s=%r' % (name, value))
2.122 + return '%s(%s)' % (type_name, ', '.join(arg_strings))
2.123 +
2.124 + def _get_kwargs(self):
2.125 + return sorted(self.__dict__.items())
2.126 +
2.127 + def _get_args(self):
2.128 + return []
2.129 +
2.130 +
2.131 +def _ensure_value(namespace, name, value):
2.132 + if getattr(namespace, name, None) is None:
2.133 + setattr(namespace, name, value)
2.134 + return getattr(namespace, name)
2.135 +
2.136 +
2.137 +# ===============
2.138 +# Formatting Help
2.139 +# ===============
2.140 +
2.141 +class HelpFormatter(object):
2.142 + """Formatter for generating usage messages and argument help strings.
2.143 +
2.144 + Only the name of this class is considered a public API. All the methods
2.145 + provided by the class are considered an implementation detail.
2.146 + """
2.147 +
2.148 + def __init__(self,
2.149 + prog,
2.150 + indent_increment=2,
2.151 + max_help_position=24,
2.152 + width=None):
2.153 +
2.154 + # default setting for width
2.155 + if width is None:
2.156 + try:
2.157 + width = int(_os.environ['COLUMNS'])
2.158 + except (KeyError, ValueError):
2.159 + width = 80
2.160 + width -= 2
2.161 +
2.162 + self._prog = prog
2.163 + self._indent_increment = indent_increment
2.164 + self._max_help_position = max_help_position
2.165 + self._width = width
2.166 +
2.167 + self._current_indent = 0
2.168 + self._level = 0
2.169 + self._action_max_length = 0
2.170 +
2.171 + self._root_section = self._Section(self, None)
2.172 + self._current_section = self._root_section
2.173 +
2.174 + self._whitespace_matcher = _re.compile(r'\s+')
2.175 + self._long_break_matcher = _re.compile(r'\n\n\n+')
2.176 +
2.177 + # ===============================
2.178 + # Section and indentation methods
2.179 + # ===============================
2.180 + def _indent(self):
2.181 + self._current_indent += self._indent_increment
2.182 + self._level += 1
2.183 +
2.184 + def _dedent(self):
2.185 + self._current_indent -= self._indent_increment
2.186 + assert self._current_indent >= 0, 'Indent decreased below 0.'
2.187 + self._level -= 1
2.188 +
2.189 + class _Section(object):
2.190 +
2.191 + def __init__(self, formatter, parent, heading=None):
2.192 + self.formatter = formatter
2.193 + self.parent = parent
2.194 + self.heading = heading
2.195 + self.items = []
2.196 +
2.197 + def format_help(self):
2.198 + # format the indented section
2.199 + if self.parent is not None:
2.200 + self.formatter._indent()
2.201 + join = self.formatter._join_parts
2.202 + for func, args in self.items:
2.203 + func(*args)
2.204 + item_help = join([func(*args) for func, args in self.items])
2.205 + if self.parent is not None:
2.206 + self.formatter._dedent()
2.207 +
2.208 + # return nothing if the section was empty
2.209 + if not item_help:
2.210 + return ''
2.211 +
2.212 + # add the heading if the section was non-empty
2.213 + if self.heading is not SUPPRESS and self.heading is not None:
2.214 + current_indent = self.formatter._current_indent
2.215 + heading = '%*s%s:\n' % (current_indent, '', self.heading)
2.216 + else:
2.217 + heading = ''
2.218 +
2.219 + # join the section-initial newline, the heading and the help
2.220 + return join(['\n', heading, item_help, '\n'])
2.221 +
2.222 + def _add_item(self, func, args):
2.223 + self._current_section.items.append((func, args))
2.224 +
2.225 + # ========================
2.226 + # Message building methods
2.227 + # ========================
2.228 + def start_section(self, heading):
2.229 + self._indent()
2.230 + section = self._Section(self, self._current_section, heading)
2.231 + self._add_item(section.format_help, [])
2.232 + self._current_section = section
2.233 +
2.234 + def end_section(self):
2.235 + self._current_section = self._current_section.parent
2.236 + self._dedent()
2.237 +
2.238 + def add_text(self, text):
2.239 + if text is not SUPPRESS and text is not None:
2.240 + self._add_item(self._format_text, [text])
2.241 +
2.242 + def add_usage(self, usage, actions, groups, prefix=None):
2.243 + if usage is not SUPPRESS:
2.244 + args = usage, actions, groups, prefix
2.245 + self._add_item(self._format_usage, args)
2.246 +
2.247 + def add_argument(self, action):
2.248 + if action.help is not SUPPRESS:
2.249 +
2.250 + # find all invocations
2.251 + get_invocation = self._format_action_invocation
2.252 + invocations = [get_invocation(action)]
2.253 + for subaction in self._iter_indented_subactions(action):
2.254 + invocations.append(get_invocation(subaction))
2.255 +
2.256 + # update the maximum item length
2.257 + invocation_length = max([len(s) for s in invocations])
2.258 + action_length = invocation_length + self._current_indent
2.259 + self._action_max_length = max(self._action_max_length,
2.260 + action_length)
2.261 +
2.262 + # add the item to the list
2.263 + self._add_item(self._format_action, [action])
2.264 +
2.265 + def add_arguments(self, actions):
2.266 + for action in actions:
2.267 + self.add_argument(action)
2.268 +
2.269 + # =======================
2.270 + # Help-formatting methods
2.271 + # =======================
2.272 + def format_help(self):
2.273 + help = self._root_section.format_help()
2.274 + if help:
2.275 + help = self._long_break_matcher.sub('\n\n', help)
2.276 + help = help.strip('\n') + '\n'
2.277 + return help
2.278 +
2.279 + def _join_parts(self, part_strings):
2.280 + return ''.join([part
2.281 + for part in part_strings
2.282 + if part and part is not SUPPRESS])
2.283 +
2.284 + def _format_usage(self, usage, actions, groups, prefix):
2.285 + if prefix is None:
2.286 + prefix = _('usage: ')
2.287 +
2.288 + # if usage is specified, use that
2.289 + if usage is not None:
2.290 + usage = usage % dict(prog=self._prog)
2.291 +
2.292 + # if no optionals or positionals are available, usage is just prog
2.293 + elif usage is None and not actions:
2.294 + usage = '%(prog)s' % dict(prog=self._prog)
2.295 +
2.296 + # if optionals and positionals are available, calculate usage
2.297 + elif usage is None:
2.298 + prog = '%(prog)s' % dict(prog=self._prog)
2.299 +
2.300 + # split optionals from positionals
2.301 + optionals = []
2.302 + positionals = []
2.303 + for action in actions:
2.304 + if action.option_strings:
2.305 + optionals.append(action)
2.306 + else:
2.307 + positionals.append(action)
2.308 +
2.309 + # build full usage string
2.310 + format = self._format_actions_usage
2.311 + action_usage = format(optionals + positionals, groups)
2.312 + usage = ' '.join([s for s in [prog, action_usage] if s])
2.313 +
2.314 + # wrap the usage parts if it's too long
2.315 + text_width = self._width - self._current_indent
2.316 + if len(prefix) + len(usage) > text_width:
2.317 +
2.318 + # break usage into wrappable parts
2.319 + part_regexp = r'\(.*?\)+|\[.*?\]+|\S+'
2.320 + opt_usage = format(optionals, groups)
2.321 + pos_usage = format(positionals, groups)
2.322 + opt_parts = _re.findall(part_regexp, opt_usage)
2.323 + pos_parts = _re.findall(part_regexp, pos_usage)
2.324 + assert ' '.join(opt_parts) == opt_usage
2.325 + assert ' '.join(pos_parts) == pos_usage
2.326 +
2.327 + # helper for wrapping lines
2.328 + def get_lines(parts, indent, prefix=None):
2.329 + lines = []
2.330 + line = []
2.331 + if prefix is not None:
2.332 + line_len = len(prefix) - 1
2.333 + else:
2.334 + line_len = len(indent) - 1
2.335 + for part in parts:
2.336 + if line_len + 1 + len(part) > text_width:
2.337 + lines.append(indent + ' '.join(line))
2.338 + line = []
2.339 + line_len = len(indent) - 1
2.340 + line.append(part)
2.341 + line_len += len(part) + 1
2.342 + if line:
2.343 + lines.append(indent + ' '.join(line))
2.344 + if prefix is not None:
2.345 + lines[0] = lines[0][len(indent):]
2.346 + return lines
2.347 +
2.348 + # if prog is short, follow it with optionals or positionals
2.349 + if len(prefix) + len(prog) <= 0.75 * text_width:
2.350 + indent = ' ' * (len(prefix) + len(prog) + 1)
2.351 + if opt_parts:
2.352 + lines = get_lines([prog] + opt_parts, indent, prefix)
2.353 + lines.extend(get_lines(pos_parts, indent))
2.354 + elif pos_parts:
2.355 + lines = get_lines([prog] + pos_parts, indent, prefix)
2.356 + else:
2.357 + lines = [prog]
2.358 +
2.359 + # if prog is long, put it on its own line
2.360 + else:
2.361 + indent = ' ' * len(prefix)
2.362 + parts = opt_parts + pos_parts
2.363 + lines = get_lines(parts, indent)
2.364 + if len(lines) > 1:
2.365 + lines = []
2.366 + lines.extend(get_lines(opt_parts, indent))
2.367 + lines.extend(get_lines(pos_parts, indent))
2.368 + lines = [prog] + lines
2.369 +
2.370 + # join lines into usage
2.371 + usage = '\n'.join(lines)
2.372 +
2.373 + # prefix with 'usage:'
2.374 + return '%s%s\n\n' % (prefix, usage)
2.375 +
2.376 + def _format_actions_usage(self, actions, groups):
2.377 + # find group indices and identify actions in groups
2.378 + group_actions = set()
2.379 + inserts = {}
2.380 + for group in groups:
2.381 + try:
2.382 + start = actions.index(group._group_actions[0])
2.383 + except ValueError:
2.384 + continue
2.385 + else:
2.386 + end = start + len(group._group_actions)
2.387 + if actions[start:end] == group._group_actions:
2.388 + for action in group._group_actions:
2.389 + group_actions.add(action)
2.390 + if not group.required:
2.391 + inserts[start] = '['
2.392 + inserts[end] = ']'
2.393 + else:
2.394 + inserts[start] = '('
2.395 + inserts[end] = ')'
2.396 + for i in range(start + 1, end):
2.397 + inserts[i] = '|'
2.398 +
2.399 + # collect all actions format strings
2.400 + parts = []
2.401 + for i, action in enumerate(actions):
2.402 +
2.403 + # suppressed arguments are marked with None
2.404 + # remove | separators for suppressed arguments
2.405 + if action.help is SUPPRESS:
2.406 + parts.append(None)
2.407 + if inserts.get(i) == '|':
2.408 + inserts.pop(i)
2.409 + elif inserts.get(i + 1) == '|':
2.410 + inserts.pop(i + 1)
2.411 +
2.412 + # produce all arg strings
2.413 + elif not action.option_strings:
2.414 + part = self._format_args(action, action.dest)
2.415 +
2.416 + # if it's in a group, strip the outer []
2.417 + if action in group_actions:
2.418 + if part[0] == '[' and part[-1] == ']':
2.419 + part = part[1:-1]
2.420 +
2.421 + # add the action string to the list
2.422 + parts.append(part)
2.423 +
2.424 + # produce the first way to invoke the option in brackets
2.425 + else:
2.426 + option_string = action.option_strings[0]
2.427 +
2.428 + # if the Optional doesn't take a value, format is:
2.429 + # -s or --long
2.430 + if action.nargs == 0:
2.431 + part = '%s' % option_string
2.432 +
2.433 + # if the Optional takes a value, format is:
2.434 + # -s ARGS or --long ARGS
2.435 + else:
2.436 + default = action.dest.upper()
2.437 + args_string = self._format_args(action, default)
2.438 + part = '%s %s' % (option_string, args_string)
2.439 +
2.440 + # make it look optional if it's not required or in a group
2.441 + if not action.required and action not in group_actions:
2.442 + part = '[%s]' % part
2.443 +
2.444 + # add the action string to the list
2.445 + parts.append(part)
2.446 +
2.447 + # insert things at the necessary indices
2.448 + for i in sorted(inserts, reverse=True):
2.449 + parts[i:i] = [inserts[i]]
2.450 +
2.451 + # join all the action items with spaces
2.452 + text = ' '.join([item for item in parts if item is not None])
2.453 +
2.454 + # clean up separators for mutually exclusive groups
2.455 + open = r'[\[(]'
2.456 + close = r'[\])]'
2.457 + text = _re.sub(r'(%s) ' % open, r'\1', text)
2.458 + text = _re.sub(r' (%s)' % close, r'\1', text)
2.459 + text = _re.sub(r'%s *%s' % (open, close), r'', text)
2.460 + text = _re.sub(r'\(([^|]*)\)', r'\1', text)
2.461 + text = text.strip()
2.462 +
2.463 + # return the text
2.464 + return text
2.465 +
2.466 + def _format_text(self, text):
2.467 + if '%(prog)' in text:
2.468 + text = text % dict(prog=self._prog)
2.469 + text_width = self._width - self._current_indent
2.470 + indent = ' ' * self._current_indent
2.471 + return self._fill_text(text, text_width, indent) + '\n\n'
2.472 +
2.473 + def _format_action(self, action):
2.474 + # determine the required width and the entry label
2.475 + help_position = min(self._action_max_length + 2,
2.476 + self._max_help_position)
2.477 + help_width = self._width - help_position
2.478 + action_width = help_position - self._current_indent - 2
2.479 + action_header = self._format_action_invocation(action)
2.480 +
2.481 + # ho nelp; start on same line and add a final newline
2.482 + if not action.help:
2.483 + tup = self._current_indent, '', action_header
2.484 + action_header = '%*s%s\n' % tup
2.485 +
2.486 + # short action name; start on the same line and pad two spaces
2.487 + elif len(action_header) <= action_width:
2.488 + tup = self._current_indent, '', action_width, action_header
2.489 + action_header = '%*s%-*s ' % tup
2.490 + indent_first = 0
2.491 +
2.492 + # long action name; start on the next line
2.493 + else:
2.494 + tup = self._current_indent, '', action_header
2.495 + action_header = '%*s%s\n' % tup
2.496 + indent_first = help_position
2.497 +
2.498 + # collect the pieces of the action help
2.499 + parts = [action_header]
2.500 +
2.501 + # if there was help for the action, add lines of help text
2.502 + if action.help:
2.503 + help_text = self._expand_help(action)
2.504 + help_lines = self._split_lines(help_text, help_width)
2.505 + parts.append('%*s%s\n' % (indent_first, '', help_lines[0]))
2.506 + for line in help_lines[1:]:
2.507 + parts.append('%*s%s\n' % (help_position, '', line))
2.508 +
2.509 + # or add a newline if the description doesn't end with one
2.510 + elif not action_header.endswith('\n'):
2.511 + parts.append('\n')
2.512 +
2.513 + # if there are any sub-actions, add their help as well
2.514 + for subaction in self._iter_indented_subactions(action):
2.515 + parts.append(self._format_action(subaction))
2.516 +
2.517 + # return a single string
2.518 + return self._join_parts(parts)
2.519 +
2.520 + def _format_action_invocation(self, action):
2.521 + if not action.option_strings:
2.522 + metavar, = self._metavar_formatter(action, action.dest)(1)
2.523 + return metavar
2.524 +
2.525 + else:
2.526 + parts = []
2.527 +
2.528 + # if the Optional doesn't take a value, format is:
2.529 + # -s, --long
2.530 + if action.nargs == 0:
2.531 + parts.extend(action.option_strings)
2.532 +
2.533 + # if the Optional takes a value, format is:
2.534 + # -s ARGS, --long ARGS
2.535 + else:
2.536 + default = action.dest.upper()
2.537 + args_string = self._format_args(action, default)
2.538 + for option_string in action.option_strings:
2.539 + parts.append('%s %s' % (option_string, args_string))
2.540 +
2.541 + return ', '.join(parts)
2.542 +
2.543 + def _metavar_formatter(self, action, default_metavar):
2.544 + if action.metavar is not None:
2.545 + result = action.metavar
2.546 + elif action.choices is not None:
2.547 + choice_strs = [str(choice) for choice in action.choices]
2.548 + result = '{%s}' % ','.join(choice_strs)
2.549 + else:
2.550 + result = default_metavar
2.551 +
2.552 + def format(tuple_size):
2.553 + if isinstance(result, tuple):
2.554 + return result
2.555 + else:
2.556 + return (result, ) * tuple_size
2.557 + return format
2.558 +
2.559 + def _format_args(self, action, default_metavar):
2.560 + get_metavar = self._metavar_formatter(action, default_metavar)
2.561 + if action.nargs is None:
2.562 + result = '%s' % get_metavar(1)
2.563 + elif action.nargs == OPTIONAL:
2.564 + result = '[%s]' % get_metavar(1)
2.565 + elif action.nargs == ZERO_OR_MORE:
2.566 + result = '[%s [%s ...]]' % get_metavar(2)
2.567 + elif action.nargs == ONE_OR_MORE:
2.568 + result = '%s [%s ...]' % get_metavar(2)
2.569 + elif action.nargs == REMAINDER:
2.570 + result = '...'
2.571 + elif action.nargs == PARSER:
2.572 + result = '%s ...' % get_metavar(1)
2.573 + else:
2.574 + formats = ['%s' for _ in range(action.nargs)]
2.575 + result = ' '.join(formats) % get_metavar(action.nargs)
2.576 + return result
2.577 +
2.578 + def _expand_help(self, action):
2.579 + params = dict(vars(action), prog=self._prog)
2.580 + for name in list(params):
2.581 + if params[name] is SUPPRESS:
2.582 + del params[name]
2.583 + for name in list(params):
2.584 + if hasattr(params[name], '__name__'):
2.585 + params[name] = params[name].__name__
2.586 + if params.get('choices') is not None:
2.587 + choices_str = ', '.join([str(c) for c in params['choices']])
2.588 + params['choices'] = choices_str
2.589 + return self._get_help_string(action) % params
2.590 +
2.591 + def _iter_indented_subactions(self, action):
2.592 + try:
2.593 + get_subactions = action._get_subactions
2.594 + except AttributeError:
2.595 + pass
2.596 + else:
2.597 + self._indent()
2.598 + for subaction in get_subactions():
2.599 + yield subaction
2.600 + self._dedent()
2.601 +
2.602 + def _split_lines(self, text, width):
2.603 + text = self._whitespace_matcher.sub(' ', text).strip()
2.604 + return _textwrap.wrap(text, width)
2.605 +
2.606 + def _fill_text(self, text, width, indent):
2.607 + text = self._whitespace_matcher.sub(' ', text).strip()
2.608 + return _textwrap.fill(text, width, initial_indent=indent,
2.609 + subsequent_indent=indent)
2.610 +
2.611 + def _get_help_string(self, action):
2.612 + return action.help
2.613 +
2.614 +
2.615 +class RawDescriptionHelpFormatter(HelpFormatter):
2.616 + """Help message formatter which retains any formatting in descriptions.
2.617 +
2.618 + Only the name of this class is considered a public API. All the methods
2.619 + provided by the class are considered an implementation detail.
2.620 + """
2.621 +
2.622 + def _fill_text(self, text, width, indent):
2.623 + return ''.join([indent + line for line in text.splitlines(True)])
2.624 +
2.625 +
2.626 +class RawTextHelpFormatter(RawDescriptionHelpFormatter):
2.627 + """Help message formatter which retains formatting of all help text.
2.628 +
2.629 + Only the name of this class is considered a public API. All the methods
2.630 + provided by the class are considered an implementation detail.
2.631 + """
2.632 +
2.633 + def _split_lines(self, text, width):
2.634 + return text.splitlines()
2.635 +
2.636 +
2.637 +class ArgumentDefaultsHelpFormatter(HelpFormatter):
2.638 + """Help message formatter which adds default values to argument help.
2.639 +
2.640 + Only the name of this class is considered a public API. All the methods
2.641 + provided by the class are considered an implementation detail.
2.642 + """
2.643 +
2.644 + def _get_help_string(self, action):
2.645 + help = action.help
2.646 + if '%(default)' not in action.help:
2.647 + if action.default is not SUPPRESS:
2.648 + defaulting_nargs = [OPTIONAL, ZERO_OR_MORE]
2.649 + if action.option_strings or action.nargs in defaulting_nargs:
2.650 + help += ' (default: %(default)s)'
2.651 + return help
2.652 +
2.653 +
2.654 +# =====================
2.655 +# Options and Arguments
2.656 +# =====================
2.657 +
2.658 +def _get_action_name(argument):
2.659 + if argument is None:
2.660 + return None
2.661 + elif argument.option_strings:
2.662 + return '/'.join(argument.option_strings)
2.663 + elif argument.metavar not in (None, SUPPRESS):
2.664 + return argument.metavar
2.665 + elif argument.dest not in (None, SUPPRESS):
2.666 + return argument.dest
2.667 + else:
2.668 + return None
2.669 +
2.670 +
2.671 +class ArgumentError(Exception):
2.672 + """An error from creating or using an argument (optional or positional).
2.673 +
2.674 + The string value of this exception is the message, augmented with
2.675 + information about the argument that caused it.
2.676 + """
2.677 +
2.678 + def __init__(self, argument, message):
2.679 + self.argument_name = _get_action_name(argument)
2.680 + self.message = message
2.681 +
2.682 + def __str__(self):
2.683 + if self.argument_name is None:
2.684 + format = '%(message)s'
2.685 + else:
2.686 + format = 'argument %(argument_name)s: %(message)s'
2.687 + return format % dict(message=self.message,
2.688 + argument_name=self.argument_name)
2.689 +
2.690 +
2.691 +class ArgumentTypeError(Exception):
2.692 + """An error from trying to convert a command line string to a type."""
2.693 + pass
2.694 +
2.695 +
2.696 +# ==============
2.697 +# Action classes
2.698 +# ==============
2.699 +
2.700 +class Action(_AttributeHolder):
2.701 + """Information about how to convert command line strings to Python objects.
2.702 +
2.703 + Action objects are used by an ArgumentParser to represent the information
2.704 + needed to parse a single argument from one or more strings from the
2.705 + command line. The keyword arguments to the Action constructor are also
2.706 + all attributes of Action instances.
2.707 +
2.708 + Keyword Arguments:
2.709 +
2.710 + - option_strings -- A list of command-line option strings which
2.711 + should be associated with this action.
2.712 +
2.713 + - dest -- The name of the attribute to hold the created object(s)
2.714 +
2.715 + - nargs -- The number of command-line arguments that should be
2.716 + consumed. By default, one argument will be consumed and a single
2.717 + value will be produced. Other values include:
2.718 + - N (an integer) consumes N arguments (and produces a list)
2.719 + - '?' consumes zero or one arguments
2.720 + - '*' consumes zero or more arguments (and produces a list)
2.721 + - '+' consumes one or more arguments (and produces a list)
2.722 + Note that the difference between the default and nargs=1 is that
2.723 + with the default, a single value will be produced, while with
2.724 + nargs=1, a list containing a single value will be produced.
2.725 +
2.726 + - const -- The value to be produced if the option is specified and the
2.727 + option uses an action that takes no values.
2.728 +
2.729 + - default -- The value to be produced if the option is not specified.
2.730 +
2.731 + - type -- The type which the command-line arguments should be converted
2.732 + to, should be one of 'string', 'int', 'float', 'complex' or a
2.733 + callable object that accepts a single string argument. If None,
2.734 + 'string' is assumed.
2.735 +
2.736 + - choices -- A container of values that should be allowed. If not None,
2.737 + after a command-line argument has been converted to the appropriate
2.738 + type, an exception will be raised if it is not a member of this
2.739 + collection.
2.740 +
2.741 + - required -- True if the action must always be specified at the
2.742 + command line. This is only meaningful for optional command-line
2.743 + arguments.
2.744 +
2.745 + - help -- The help string describing the argument.
2.746 +
2.747 + - metavar -- The name to be used for the option's argument with the
2.748 + help string. If None, the 'dest' value will be used as the name.
2.749 + """
2.750 +
2.751 + def __init__(self,
2.752 + option_strings,
2.753 + dest,
2.754 + nargs=None,
2.755 + const=None,
2.756 + default=None,
2.757 + type=None,
2.758 + choices=None,
2.759 + required=False,
2.760 + help=None,
2.761 + metavar=None):
2.762 + self.option_strings = option_strings
2.763 + self.dest = dest
2.764 + self.nargs = nargs
2.765 + self.const = const
2.766 + self.default = default
2.767 + self.type = type
2.768 + self.choices = choices
2.769 + self.required = required
2.770 + self.help = help
2.771 + self.metavar = metavar
2.772 +
2.773 + def _get_kwargs(self):
2.774 + names = [
2.775 + 'option_strings',
2.776 + 'dest',
2.777 + 'nargs',
2.778 + 'const',
2.779 + 'default',
2.780 + 'type',
2.781 + 'choices',
2.782 + 'help',
2.783 + 'metavar',
2.784 + ]
2.785 + return [(name, getattr(self, name)) for name in names]
2.786 +
2.787 + def __call__(self, parser, namespace, values, option_string=None):
2.788 + raise NotImplementedError(_('.__call__() not defined'))
2.789 +
2.790 +
2.791 +class _StoreAction(Action):
2.792 +
2.793 + def __init__(self,
2.794 + option_strings,
2.795 + dest,
2.796 + nargs=None,
2.797 + const=None,
2.798 + default=None,
2.799 + type=None,
2.800 + choices=None,
2.801 + required=False,
2.802 + help=None,
2.803 + metavar=None):
2.804 + if nargs == 0:
2.805 + raise ValueError('nargs for store actions must be > 0; if you '
2.806 + 'have nothing to store, actions such as store '
2.807 + 'true or store const may be more appropriate')
2.808 + if const is not None and nargs != OPTIONAL:
2.809 + raise ValueError('nargs must be %r to supply const' % OPTIONAL)
2.810 + super(_StoreAction, self).__init__(
2.811 + option_strings=option_strings,
2.812 + dest=dest,
2.813 + nargs=nargs,
2.814 + const=const,
2.815 + default=default,
2.816 + type=type,
2.817 + choices=choices,
2.818 + required=required,
2.819 + help=help,
2.820 + metavar=metavar)
2.821 +
2.822 + def __call__(self, parser, namespace, values, option_string=None):
2.823 + setattr(namespace, self.dest, values)
2.824 +
2.825 +
2.826 +class _StoreConstAction(Action):
2.827 +
2.828 + def __init__(self,
2.829 + option_strings,
2.830 + dest,
2.831 + const,
2.832 + default=None,
2.833 + required=False,
2.834 + help=None,
2.835 + metavar=None):
2.836 + super(_StoreConstAction, self).__init__(
2.837 + option_strings=option_strings,
2.838 + dest=dest,
2.839 + nargs=0,
2.840 + const=const,
2.841 + default=default,
2.842 + required=required,
2.843 + help=help)
2.844 +
2.845 + def __call__(self, parser, namespace, values, option_string=None):
2.846 + setattr(namespace, self.dest, self.const)
2.847 +
2.848 +
2.849 +class _StoreTrueAction(_StoreConstAction):
2.850 +
2.851 + def __init__(self,
2.852 + option_strings,
2.853 + dest,
2.854 + default=False,
2.855 + required=False,
2.856 + help=None):
2.857 + super(_StoreTrueAction, self).__init__(
2.858 + option_strings=option_strings,
2.859 + dest=dest,
2.860 + const=True,
2.861 + default=default,
2.862 + required=required,
2.863 + help=help)
2.864 +
2.865 +
2.866 +class _StoreFalseAction(_StoreConstAction):
2.867 +
2.868 + def __init__(self,
2.869 + option_strings,
2.870 + dest,
2.871 + default=True,
2.872 + required=False,
2.873 + help=None):
2.874 + super(_StoreFalseAction, self).__init__(
2.875 + option_strings=option_strings,
2.876 + dest=dest,
2.877 + const=False,
2.878 + default=default,
2.879 + required=required,
2.880 + help=help)
2.881 +
2.882 +
2.883 +class _AppendAction(Action):
2.884 +
2.885 + def __init__(self,
2.886 + option_strings,
2.887 + dest,
2.888 + nargs=None,
2.889 + const=None,
2.890 + default=None,
2.891 + type=None,
2.892 + choices=None,
2.893 + required=False,
2.894 + help=None,
2.895 + metavar=None):
2.896 + if nargs == 0:
2.897 + raise ValueError('nargs for append actions must be > 0; if arg '
2.898 + 'strings are not supplying the value to append, '
2.899 + 'the append const action may be more appropriate')
2.900 + if const is not None and nargs != OPTIONAL:
2.901 + raise ValueError('nargs must be %r to supply const' % OPTIONAL)
2.902 + super(_AppendAction, self).__init__(
2.903 + option_strings=option_strings,
2.904 + dest=dest,
2.905 + nargs=nargs,
2.906 + const=const,
2.907 + default=default,
2.908 + type=type,
2.909 + choices=choices,
2.910 + required=required,
2.911 + help=help,
2.912 + metavar=metavar)
2.913 +
2.914 + def __call__(self, parser, namespace, values, option_string=None):
2.915 + items = _copy.copy(_ensure_value(namespace, self.dest, []))
2.916 + items.append(values)
2.917 + setattr(namespace, self.dest, items)
2.918 +
2.919 +
2.920 +class _AppendConstAction(Action):
2.921 +
2.922 + def __init__(self,
2.923 + option_strings,
2.924 + dest,
2.925 + const,
2.926 + default=None,
2.927 + required=False,
2.928 + help=None,
2.929 + metavar=None):
2.930 + super(_AppendConstAction, self).__init__(
2.931 + option_strings=option_strings,
2.932 + dest=dest,
2.933 + nargs=0,
2.934 + const=const,
2.935 + default=default,
2.936 + required=required,
2.937 + help=help,
2.938 + metavar=metavar)
2.939 +
2.940 + def __call__(self, parser, namespace, values, option_string=None):
2.941 + items = _copy.copy(_ensure_value(namespace, self.dest, []))
2.942 + items.append(self.const)
2.943 + setattr(namespace, self.dest, items)
2.944 +
2.945 +
2.946 +class _CountAction(Action):
2.947 +
2.948 + def __init__(self,
2.949 + option_strings,
2.950 + dest,
2.951 + default=None,
2.952 + required=False,
2.953 + help=None):
2.954 + super(_CountAction, self).__init__(
2.955 + option_strings=option_strings,
2.956 + dest=dest,
2.957 + nargs=0,
2.958 + default=default,
2.959 + required=required,
2.960 + help=help)
2.961 +
2.962 + def __call__(self, parser, namespace, values, option_string=None):
2.963 + new_count = _ensure_value(namespace, self.dest, 0) + 1
2.964 + setattr(namespace, self.dest, new_count)
2.965 +
2.966 +
2.967 +class _HelpAction(Action):
2.968 +
2.969 + def __init__(self,
2.970 + option_strings,
2.971 + dest=SUPPRESS,
2.972 + default=SUPPRESS,
2.973 + help=None):
2.974 + super(_HelpAction, self).__init__(
2.975 + option_strings=option_strings,
2.976 + dest=dest,
2.977 + default=default,
2.978 + nargs=0,
2.979 + help=help)
2.980 +
2.981 + def __call__(self, parser, namespace, values, option_string=None):
2.982 + parser.print_help()
2.983 + parser.exit()
2.984 +
2.985 +
2.986 +class _VersionAction(Action):
2.987 +
2.988 + def __init__(self,
2.989 + option_strings,
2.990 + version=None,
2.991 + dest=SUPPRESS,
2.992 + default=SUPPRESS,
2.993 + help="show program's version number and exit"):
2.994 + super(_VersionAction, self).__init__(
2.995 + option_strings=option_strings,
2.996 + dest=dest,
2.997 + default=default,
2.998 + nargs=0,
2.999 + help=help)
2.1000 + self.version = version
2.1001 +
2.1002 + def __call__(self, parser, namespace, values, option_string=None):
2.1003 + version = self.version
2.1004 + if version is None:
2.1005 + version = parser.version
2.1006 + formatter = parser._get_formatter()
2.1007 + formatter.add_text(version)
2.1008 + parser.exit(message=formatter.format_help())
2.1009 +
2.1010 +
2.1011 +class _SubParsersAction(Action):
2.1012 +
2.1013 + class _ChoicesPseudoAction(Action):
2.1014 +
2.1015 + def __init__(self, name, help):
2.1016 + sup = super(_SubParsersAction._ChoicesPseudoAction, self)
2.1017 + sup.__init__(option_strings=[], dest=name, help=help)
2.1018 +
2.1019 + def __init__(self,
2.1020 + option_strings,
2.1021 + prog,
2.1022 + parser_class,
2.1023 + dest=SUPPRESS,
2.1024 + help=None,
2.1025 + metavar=None):
2.1026 +
2.1027 + self._prog_prefix = prog
2.1028 + self._parser_class = parser_class
2.1029 + self._name_parser_map = {}
2.1030 + self._choices_actions = []
2.1031 +
2.1032 + super(_SubParsersAction, self).__init__(
2.1033 + option_strings=option_strings,
2.1034 + dest=dest,
2.1035 + nargs=PARSER,
2.1036 + choices=self._name_parser_map,
2.1037 + help=help,
2.1038 + metavar=metavar)
2.1039 +
2.1040 + def add_parser(self, name, **kwargs):
2.1041 + # set prog from the existing prefix
2.1042 + if kwargs.get('prog') is None:
2.1043 + kwargs['prog'] = '%s %s' % (self._prog_prefix, name)
2.1044 +
2.1045 + # create a pseudo-action to hold the choice help
2.1046 + if 'help' in kwargs:
2.1047 + help = kwargs.pop('help')
2.1048 + choice_action = self._ChoicesPseudoAction(name, help)
2.1049 + self._choices_actions.append(choice_action)
2.1050 +
2.1051 + # create the parser and add it to the map
2.1052 + parser = self._parser_class(**kwargs)
2.1053 + self._name_parser_map[name] = parser
2.1054 + return parser
2.1055 +
2.1056 + def _get_subactions(self):
2.1057 + return self._choices_actions
2.1058 +
2.1059 + def __call__(self, parser, namespace, values, option_string=None):
2.1060 + parser_name = values[0]
2.1061 + arg_strings = values[1:]
2.1062 +
2.1063 + # set the parser name if requested
2.1064 + if self.dest is not SUPPRESS:
2.1065 + setattr(namespace, self.dest, parser_name)
2.1066 +
2.1067 + # select the parser
2.1068 + try:
2.1069 + parser = self._name_parser_map[parser_name]
2.1070 + except KeyError:
2.1071 + tup = parser_name, ', '.join(self._name_parser_map)
2.1072 + msg = _('unknown parser %r (choices: %s)' % tup)
2.1073 + raise ArgumentError(self, msg)
2.1074 +
2.1075 + # parse all the remaining options into the namespace
2.1076 + parser.parse_args(arg_strings, namespace)
2.1077 +
2.1078 +
2.1079 +# ==============
2.1080 +# Type classes
2.1081 +# ==============
2.1082 +
2.1083 +class FileType(object):
2.1084 + """Factory for creating file object types
2.1085 +
2.1086 + Instances of FileType are typically passed as type= arguments to the
2.1087 + ArgumentParser add_argument() method.
2.1088 +
2.1089 + Keyword Arguments:
2.1090 + - mode -- A string indicating how the file is to be opened. Accepts the
2.1091 + same values as the builtin open() function.
2.1092 + - bufsize -- The file's desired buffer size. Accepts the same values as
2.1093 + the builtin open() function.
2.1094 + """
2.1095 +
2.1096 + def __init__(self, mode='r', bufsize=None):
2.1097 + self._mode = mode
2.1098 + self._bufsize = bufsize
2.1099 +
2.1100 + def __call__(self, string):
2.1101 + # the special argument "-" means sys.std{in,out}
2.1102 + if string == '-':
2.1103 + if 'r' in self._mode:
2.1104 + return _sys.stdin
2.1105 + elif 'w' in self._mode:
2.1106 + return _sys.stdout
2.1107 + else:
2.1108 + msg = _('argument "-" with mode %r' % self._mode)
2.1109 + raise ValueError(msg)
2.1110 +
2.1111 + # all other arguments are used as file names
2.1112 + if self._bufsize:
2.1113 + return open(string, self._mode, self._bufsize)
2.1114 + else:
2.1115 + return open(string, self._mode)
2.1116 +
2.1117 + def __repr__(self):
2.1118 + args = [self._mode, self._bufsize]
2.1119 + args_str = ', '.join([repr(arg) for arg in args if arg is not None])
2.1120 + return '%s(%s)' % (type(self).__name__, args_str)
2.1121 +
2.1122 +# ===========================
2.1123 +# Optional and Positional Parsing
2.1124 +# ===========================
2.1125 +
2.1126 +class Namespace(_AttributeHolder):
2.1127 + """Simple object for storing attributes.
2.1128 +
2.1129 + Implements equality by attribute names and values, and provides a simple
2.1130 + string representation.
2.1131 + """
2.1132 +
2.1133 + def __init__(self, **kwargs):
2.1134 + for name in kwargs:
2.1135 + setattr(self, name, kwargs[name])
2.1136 +
2.1137 + def __eq__(self, other):
2.1138 + return vars(self) == vars(other)
2.1139 +
2.1140 + def __ne__(self, other):
2.1141 + return not (self == other)
2.1142 +
2.1143 + def __contains__(self, key):
2.1144 + return key in self.__dict__
2.1145 +
2.1146 +
2.1147 +class _ActionsContainer(object):
2.1148 +
2.1149 + def __init__(self,
2.1150 + description,
2.1151 + prefix_chars,
2.1152 + argument_default,
2.1153 + conflict_handler):
2.1154 + super(_ActionsContainer, self).__init__()
2.1155 +
2.1156 + self.description = description
2.1157 + self.argument_default = argument_default
2.1158 + self.prefix_chars = prefix_chars
2.1159 + self.conflict_handler = conflict_handler
2.1160 +
2.1161 + # set up registries
2.1162 + self._registries = {}
2.1163 +
2.1164 + # register actions
2.1165 + self.register('action', None, _StoreAction)
2.1166 + self.register('action', 'store', _StoreAction)
2.1167 + self.register('action', 'store_const', _StoreConstAction)
2.1168 + self.register('action', 'store_true', _StoreTrueAction)
2.1169 + self.register('action', 'store_false', _StoreFalseAction)
2.1170 + self.register('action', 'append', _AppendAction)
2.1171 + self.register('action', 'append_const', _AppendConstAction)
2.1172 + self.register('action', 'count', _CountAction)
2.1173 + self.register('action', 'help', _HelpAction)
2.1174 + self.register('action', 'version', _VersionAction)
2.1175 + self.register('action', 'parsers', _SubParsersAction)
2.1176 +
2.1177 + # raise an exception if the conflict handler is invalid
2.1178 + self._get_handler()
2.1179 +
2.1180 + # action storage
2.1181 + self._actions = []
2.1182 + self._option_string_actions = {}
2.1183 +
2.1184 + # groups
2.1185 + self._action_groups = []
2.1186 + self._mutually_exclusive_groups = []
2.1187 +
2.1188 + # defaults storage
2.1189 + self._defaults = {}
2.1190 +
2.1191 + # determines whether an "option" looks like a negative number
2.1192 + self._negative_number_matcher = _re.compile(r'^-\d+$|^-\d*\.\d+$')
2.1193 +
2.1194 + # whether or not there are any optionals that look like negative
2.1195 + # numbers -- uses a list so it can be shared and edited
2.1196 + self._has_negative_number_optionals = []
2.1197 +
2.1198 + # ====================
2.1199 + # Registration methods
2.1200 + # ====================
2.1201 + def register(self, registry_name, value, object):
2.1202 + registry = self._registries.setdefault(registry_name, {})
2.1203 + registry[value] = object
2.1204 +
2.1205 + def _registry_get(self, registry_name, value, default=None):
2.1206 + return self._registries[registry_name].get(value, default)
2.1207 +
2.1208 + # ==================================
2.1209 + # Namespace default accessor methods
2.1210 + # ==================================
2.1211 + def set_defaults(self, **kwargs):
2.1212 + self._defaults.update(kwargs)
2.1213 +
2.1214 + # if these defaults match any existing arguments, replace
2.1215 + # the previous default on the object with the new one
2.1216 + for action in self._actions:
2.1217 + if action.dest in kwargs:
2.1218 + action.default = kwargs[action.dest]
2.1219 +
2.1220 + def get_default(self, dest):
2.1221 + for action in self._actions:
2.1222 + if action.dest == dest and action.default is not None:
2.1223 + return action.default
2.1224 + return self._defaults.get(dest, None)
2.1225 +
2.1226 +
2.1227 + # =======================
2.1228 + # Adding argument actions
2.1229 + # =======================
2.1230 + def add_argument(self, *args, **kwargs):
2.1231 + """
2.1232 + add_argument(dest, ..., name=value, ...)
2.1233 + add_argument(option_string, option_string, ..., name=value, ...)
2.1234 + """
2.1235 +
2.1236 + # if no positional args are supplied or only one is supplied and
2.1237 + # it doesn't look like an option string, parse a positional
2.1238 + # argument
2.1239 + chars = self.prefix_chars
2.1240 + if not args or len(args) == 1 and args[0][0] not in chars:
2.1241 + if args and 'dest' in kwargs:
2.1242 + raise ValueError('dest supplied twice for positional argument')
2.1243 + kwargs = self._get_positional_kwargs(*args, **kwargs)
2.1244 +
2.1245 + # otherwise, we're adding an optional argument
2.1246 + else:
2.1247 + kwargs = self._get_optional_kwargs(*args, **kwargs)
2.1248 +
2.1249 + # if no default was supplied, use the parser-level default
2.1250 + if 'default' not in kwargs:
2.1251 + dest = kwargs['dest']
2.1252 + if dest in self._defaults:
2.1253 + kwargs['default'] = self._defaults[dest]
2.1254 + elif self.argument_default is not None:
2.1255 + kwargs['default'] = self.argument_default
2.1256 +
2.1257 + # create the action object, and add it to the parser
2.1258 + action_class = self._pop_action_class(kwargs)
2.1259 + if not _callable(action_class):
2.1260 + raise ValueError('unknown action "%s"' % action_class)
2.1261 + action = action_class(**kwargs)
2.1262 +
2.1263 + # raise an error if the action type is not callable
2.1264 + type_func = self._registry_get('type', action.type, action.type)
2.1265 + if not _callable(type_func):
2.1266 + raise ValueError('%r is not callable' % type_func)
2.1267 +
2.1268 + return self._add_action(action)
2.1269 +
2.1270 + def add_argument_group(self, *args, **kwargs):
2.1271 + group = _ArgumentGroup(self, *args, **kwargs)
2.1272 + self._action_groups.append(group)
2.1273 + return group
2.1274 +
2.1275 + def add_mutually_exclusive_group(self, **kwargs):
2.1276 + group = _MutuallyExclusiveGroup(self, **kwargs)
2.1277 + self._mutually_exclusive_groups.append(group)
2.1278 + return group
2.1279 +
2.1280 + def _add_action(self, action):
2.1281 + # resolve any conflicts
2.1282 + self._check_conflict(action)
2.1283 +
2.1284 + # add to actions list
2.1285 + self._actions.append(action)
2.1286 + action.container = self
2.1287 +
2.1288 + # index the action by any option strings it has
2.1289 + for option_string in action.option_strings:
2.1290 + self._option_string_actions[option_string] = action
2.1291 +
2.1292 + # set the flag if any option strings look like negative numbers
2.1293 + for option_string in action.option_strings:
2.1294 + if self._negative_number_matcher.match(option_string):
2.1295 + if not self._has_negative_number_optionals:
2.1296 + self._has_negative_number_optionals.append(True)
2.1297 +
2.1298 + # return the created action
2.1299 + return action
2.1300 +
2.1301 + def _remove_action(self, action):
2.1302 + self._actions.remove(action)
2.1303 +
2.1304 + def _add_container_actions(self, container):
2.1305 + # collect groups by titles
2.1306 + title_group_map = {}
2.1307 + for group in self._action_groups:
2.1308 + if group.title in title_group_map:
2.1309 + msg = _('cannot merge actions - two groups are named %r')
2.1310 + raise ValueError(msg % (group.title))
2.1311 + title_group_map[group.title] = group
2.1312 +
2.1313 + # map each action to its group
2.1314 + group_map = {}
2.1315 + for group in container._action_groups:
2.1316 +
2.1317 + # if a group with the title exists, use that, otherwise
2.1318 + # create a new group matching the container's group
2.1319 + if group.title not in title_group_map:
2.1320 + title_group_map[group.title] = self.add_argument_group(
2.1321 + title=group.title,
2.1322 + description=group.description,
2.1323 + conflict_handler=group.conflict_handler)
2.1324 +
2.1325 + # map the actions to their new group
2.1326 + for action in group._group_actions:
2.1327 + group_map[action] = title_group_map[group.title]
2.1328 +
2.1329 + # add container's mutually exclusive groups
2.1330 + # NOTE: if add_mutually_exclusive_group ever gains title= and
2.1331 + # description= then this code will need to be expanded as above
2.1332 + for group in container._mutually_exclusive_groups:
2.1333 + mutex_group = self.add_mutually_exclusive_group(
2.1334 + required=group.required)
2.1335 +
2.1336 + # map the actions to their new mutex group
2.1337 + for action in group._group_actions:
2.1338 + group_map[action] = mutex_group
2.1339 +
2.1340 + # add all actions to this container or their group
2.1341 + for action in container._actions:
2.1342 + group_map.get(action, self)._add_action(action)
2.1343 +
2.1344 + def _get_positional_kwargs(self, dest, **kwargs):
2.1345 + # make sure required is not specified
2.1346 + if 'required' in kwargs:
2.1347 + msg = _("'required' is an invalid argument for positionals")
2.1348 + raise TypeError(msg)
2.1349 +
2.1350 + # mark positional arguments as required if at least one is
2.1351 + # always required
2.1352 + if kwargs.get('nargs') not in [OPTIONAL, ZERO_OR_MORE]:
2.1353 + kwargs['required'] = True
2.1354 + if kwargs.get('nargs') == ZERO_OR_MORE and 'default' not in kwargs:
2.1355 + kwargs['required'] = True
2.1356 +
2.1357 + # return the keyword arguments with no option strings
2.1358 + return dict(kwargs, dest=dest, option_strings=[])
2.1359 +
2.1360 + def _get_optional_kwargs(self, *args, **kwargs):
2.1361 + # determine short and long option strings
2.1362 + option_strings = []
2.1363 + long_option_strings = []
2.1364 + for option_string in args:
2.1365 + # error on strings that don't start with an appropriate prefix
2.1366 + if not option_string[0] in self.prefix_chars:
2.1367 + msg = _('invalid option string %r: '
2.1368 + 'must start with a character %r')
2.1369 + tup = option_string, self.prefix_chars
2.1370 + raise ValueError(msg % tup)
2.1371 +
2.1372 + # strings starting with two prefix characters are long options
2.1373 + option_strings.append(option_string)
2.1374 + if option_string[0] in self.prefix_chars:
2.1375 + if len(option_string) > 1:
2.1376 + if option_string[1] in self.prefix_chars:
2.1377 + long_option_strings.append(option_string)
2.1378 +
2.1379 + # infer destination, '--foo-bar' -> 'foo_bar' and '-x' -> 'x'
2.1380 + dest = kwargs.pop('dest', None)
2.1381 + if dest is None:
2.1382 + if long_option_strings:
2.1383 + dest_option_string = long_option_strings[0]
2.1384 + else:
2.1385 + dest_option_string = option_strings[0]
2.1386 + dest = dest_option_string.lstrip(self.prefix_chars)
2.1387 + if not dest:
2.1388 + msg = _('dest= is required for options like %r')
2.1389 + raise ValueError(msg % option_string)
2.1390 + dest = dest.replace('-', '_')
2.1391 +
2.1392 + # return the updated keyword arguments
2.1393 + return dict(kwargs, dest=dest, option_strings=option_strings)
2.1394 +
2.1395 + def _pop_action_class(self, kwargs, default=None):
2.1396 + action = kwargs.pop('action', default)
2.1397 + return self._registry_get('action', action, action)
2.1398 +
2.1399 + def _get_handler(self):
2.1400 + # determine function from conflict handler string
2.1401 + handler_func_name = '_handle_conflict_%s' % self.conflict_handler
2.1402 + try:
2.1403 + return getattr(self, handler_func_name)
2.1404 + except AttributeError:
2.1405 + msg = _('invalid conflict_resolution value: %r')
2.1406 + raise ValueError(msg % self.conflict_handler)
2.1407 +
2.1408 + def _check_conflict(self, action):
2.1409 +
2.1410 + # find all options that conflict with this option
2.1411 + confl_optionals = []
2.1412 + for option_string in action.option_strings:
2.1413 + if option_string in self._option_string_actions:
2.1414 + confl_optional = self._option_string_actions[option_string]
2.1415 + confl_optionals.append((option_string, confl_optional))
2.1416 +
2.1417 + # resolve any conflicts
2.1418 + if confl_optionals:
2.1419 + conflict_handler = self._get_handler()
2.1420 + conflict_handler(action, confl_optionals)
2.1421 +
2.1422 + def _handle_conflict_error(self, action, conflicting_actions):
2.1423 + message = _('conflicting option string(s): %s')
2.1424 + conflict_string = ', '.join([option_string
2.1425 + for option_string, action
2.1426 + in conflicting_actions])
2.1427 + raise ArgumentError(action, message % conflict_string)
2.1428 +
2.1429 + def _handle_conflict_resolve(self, action, conflicting_actions):
2.1430 +
2.1431 + # remove all conflicting options
2.1432 + for option_string, action in conflicting_actions:
2.1433 +
2.1434 + # remove the conflicting option
2.1435 + action.option_strings.remove(option_string)
2.1436 + self._option_string_actions.pop(option_string, None)
2.1437 +
2.1438 + # if the option now has no option string, remove it from the
2.1439 + # container holding it
2.1440 + if not action.option_strings:
2.1441 + action.container._remove_action(action)
2.1442 +
2.1443 +
2.1444 +class _ArgumentGroup(_ActionsContainer):
2.1445 +
2.1446 + def __init__(self, container, title=None, description=None, **kwargs):
2.1447 + # add any missing keyword arguments by checking the container
2.1448 + update = kwargs.setdefault
2.1449 + update('conflict_handler', container.conflict_handler)
2.1450 + update('prefix_chars', container.prefix_chars)
2.1451 + update('argument_default', container.argument_default)
2.1452 + super_init = super(_ArgumentGroup, self).__init__
2.1453 + super_init(description=description, **kwargs)
2.1454 +
2.1455 + # group attributes
2.1456 + self.title = title
2.1457 + self._group_actions = []
2.1458 +
2.1459 + # share most attributes with the container
2.1460 + self._registries = container._registries
2.1461 + self._actions = container._actions
2.1462 + self._option_string_actions = container._option_string_actions
2.1463 + self._defaults = container._defaults
2.1464 + self._has_negative_number_optionals = \
2.1465 + container._has_negative_number_optionals
2.1466 +
2.1467 + def _add_action(self, action):
2.1468 + action = super(_ArgumentGroup, self)._add_action(action)
2.1469 + self._group_actions.append(action)
2.1470 + return action
2.1471 +
2.1472 + def _remove_action(self, action):
2.1473 + super(_ArgumentGroup, self)._remove_action(action)
2.1474 + self._group_actions.remove(action)
2.1475 +
2.1476 +
2.1477 +class _MutuallyExclusiveGroup(_ArgumentGroup):
2.1478 +
2.1479 + def __init__(self, container, required=False):
2.1480 + super(_MutuallyExclusiveGroup, self).__init__(container)
2.1481 + self.required = required
2.1482 + self._container = container
2.1483 +
2.1484 + def _add_action(self, action):
2.1485 + if action.required:
2.1486 + msg = _('mutually exclusive arguments must be optional')
2.1487 + raise ValueError(msg)
2.1488 + action = self._container._add_action(action)
2.1489 + self._group_actions.append(action)
2.1490 + return action
2.1491 +
2.1492 + def _remove_action(self, action):
2.1493 + self._container._remove_action(action)
2.1494 + self._group_actions.remove(action)
2.1495 +
2.1496 +
2.1497 +class ArgumentParser(_AttributeHolder, _ActionsContainer):
2.1498 + """Object for parsing command line strings into Python objects.
2.1499 +
2.1500 + Keyword Arguments:
2.1501 + - prog -- The name of the program (default: sys.argv[0])
2.1502 + - usage -- A usage message (default: auto-generated from arguments)
2.1503 + - description -- A description of what the program does
2.1504 + - epilog -- Text following the argument descriptions
2.1505 + - parents -- Parsers whose arguments should be copied into this one
2.1506 + - formatter_class -- HelpFormatter class for printing help messages
2.1507 + - prefix_chars -- Characters that prefix optional arguments
2.1508 + - fromfile_prefix_chars -- Characters that prefix files containing
2.1509 + additional arguments
2.1510 + - argument_default -- The default value for all arguments
2.1511 + - conflict_handler -- String indicating how to handle conflicts
2.1512 + - add_help -- Add a -h/-help option
2.1513 + """
2.1514 +
2.1515 + def __init__(self,
2.1516 + prog=None,
2.1517 + usage=None,
2.1518 + description=None,
2.1519 + epilog=None,
2.1520 + version=None,
2.1521 + parents=[],
2.1522 + formatter_class=HelpFormatter,
2.1523 + prefix_chars='-',
2.1524 + fromfile_prefix_chars=None,
2.1525 + argument_default=None,
2.1526 + conflict_handler='error',
2.1527 + add_help=True):
2.1528 +
2.1529 + if version is not None:
2.1530 + import warnings
2.1531 + warnings.warn(
2.1532 + """The "version" argument to ArgumentParser is deprecated. """
2.1533 + """Please use """
2.1534 + """"add_argument(..., action='version', version="N", ...)" """
2.1535 + """instead""", DeprecationWarning)
2.1536 +
2.1537 + superinit = super(ArgumentParser, self).__init__
2.1538 + superinit(description=description,
2.1539 + prefix_chars=prefix_chars,
2.1540 + argument_default=argument_default,
2.1541 + conflict_handler=conflict_handler)
2.1542 +
2.1543 + # default setting for prog
2.1544 + if prog is None:
2.1545 + prog = _os.path.basename(_sys.argv[0])
2.1546 +
2.1547 + self.prog = prog
2.1548 + self.usage = usage
2.1549 + self.epilog = epilog
2.1550 + self.version = version
2.1551 + self.formatter_class = formatter_class
2.1552 + self.fromfile_prefix_chars = fromfile_prefix_chars
2.1553 + self.add_help = add_help
2.1554 +
2.1555 + add_group = self.add_argument_group
2.1556 + self._positionals = add_group(_('positional arguments'))
2.1557 + self._optionals = add_group(_('optional arguments'))
2.1558 + self._subparsers = None
2.1559 +
2.1560 + # register types
2.1561 + def identity(string):
2.1562 + return string
2.1563 + self.register('type', None, identity)
2.1564 +
2.1565 + # add help and version arguments if necessary
2.1566 + # (using explicit default to override global argument_default)
2.1567 + default_prefix = '-' if '-' in prefix_chars else prefix_chars[0]
2.1568 + if self.add_help:
2.1569 + self.add_argument(
2.1570 + default_prefix+'h', default_prefix*2+'help',
2.1571 + action='help', default=SUPPRESS,
2.1572 + help=_('show this help message and exit'))
2.1573 + if self.version:
2.1574 + self.add_argument(
2.1575 + default_prefix+'v', default_prefix*2+'version',
2.1576 + action='version', default=SUPPRESS,
2.1577 + version=self.version,
2.1578 + help=_("show program's version number and exit"))
2.1579 +
2.1580 + # add parent arguments and defaults
2.1581 + for parent in parents:
2.1582 + self._add_container_actions(parent)
2.1583 + try:
2.1584 + defaults = parent._defaults
2.1585 + except AttributeError:
2.1586 + pass
2.1587 + else:
2.1588 + self._defaults.update(defaults)
2.1589 +
2.1590 + # =======================
2.1591 + # Pretty __repr__ methods
2.1592 + # =======================
2.1593 + def _get_kwargs(self):
2.1594 + names = [
2.1595 + 'prog',
2.1596 + 'usage',
2.1597 + 'description',
2.1598 + 'version',
2.1599 + 'formatter_class',
2.1600 + 'conflict_handler',
2.1601 + 'add_help',
2.1602 + ]
2.1603 + return [(name, getattr(self, name)) for name in names]
2.1604 +
2.1605 + # ==================================
2.1606 + # Optional/Positional adding methods
2.1607 + # ==================================
2.1608 + def add_subparsers(self, **kwargs):
2.1609 + if self._subparsers is not None:
2.1610 + self.error(_('cannot have multiple subparser arguments'))
2.1611 +
2.1612 + # add the parser class to the arguments if it's not present
2.1613 + kwargs.setdefault('parser_class', type(self))
2.1614 +
2.1615 + if 'title' in kwargs or 'description' in kwargs:
2.1616 + title = _(kwargs.pop('title', 'subcommands'))
2.1617 + description = _(kwargs.pop('description', None))
2.1618 + self._subparsers = self.add_argument_group(title, description)
2.1619 + else:
2.1620 + self._subparsers = self._positionals
2.1621 +
2.1622 + # prog defaults to the usage message of this parser, skipping
2.1623 + # optional arguments and with no "usage:" prefix
2.1624 + if kwargs.get('prog') is None:
2.1625 + formatter = self._get_formatter()
2.1626 + positionals = self._get_positional_actions()
2.1627 + groups = self._mutually_exclusive_groups
2.1628 + formatter.add_usage(self.usage, positionals, groups, '')
2.1629 + kwargs['prog'] = formatter.format_help().strip()
2.1630 +
2.1631 + # create the parsers action and add it to the positionals list
2.1632 + parsers_class = self._pop_action_class(kwargs, 'parsers')
2.1633 + action = parsers_class(option_strings=[], **kwargs)
2.1634 + self._subparsers._add_action(action)
2.1635 +
2.1636 + # return the created parsers action
2.1637 + return action
2.1638 +
2.1639 + def _add_action(self, action):
2.1640 + if action.option_strings:
2.1641 + self._optionals._add_action(action)
2.1642 + else:
2.1643 + self._positionals._add_action(action)
2.1644 + return action
2.1645 +
2.1646 + def _get_optional_actions(self):
2.1647 + return [action
2.1648 + for action in self._actions
2.1649 + if action.option_strings]
2.1650 +
2.1651 + def _get_positional_actions(self):
2.1652 + return [action
2.1653 + for action in self._actions
2.1654 + if not action.option_strings]
2.1655 +
2.1656 + # =====================================
2.1657 + # Command line argument parsing methods
2.1658 + # =====================================
2.1659 + def parse_args(self, args=None, namespace=None):
2.1660 + args, argv = self.parse_known_args(args, namespace)
2.1661 + if argv:
2.1662 + msg = _('unrecognized arguments: %s')
2.1663 + self.error(msg % ' '.join(argv))
2.1664 + return args
2.1665 +
2.1666 + def parse_known_args(self, args=None, namespace=None):
2.1667 + # args default to the system args
2.1668 + if args is None:
2.1669 + args = _sys.argv[1:]
2.1670 +
2.1671 + # default Namespace built from parser defaults
2.1672 + if namespace is None:
2.1673 + namespace = Namespace()
2.1674 +
2.1675 + # add any action defaults that aren't present
2.1676 + for action in self._actions:
2.1677 + if action.dest is not SUPPRESS:
2.1678 + if not hasattr(namespace, action.dest):
2.1679 + if action.default is not SUPPRESS:
2.1680 + default = action.default
2.1681 + if isinstance(action.default, str):
2.1682 + default = self._get_value(action, default)
2.1683 + setattr(namespace, action.dest, default)
2.1684 +
2.1685 + # add any parser defaults that aren't present
2.1686 + for dest in self._defaults:
2.1687 + if not hasattr(namespace, dest):
2.1688 + setattr(namespace, dest, self._defaults[dest])
2.1689 +
2.1690 + # parse the arguments and exit if there are any errors
2.1691 + try:
2.1692 + return self._parse_known_args(args, namespace)
2.1693 + except ArgumentError:
2.1694 + err = _sys.exc_info()[1]
2.1695 + self.error(str(err))
2.1696 +
2.1697 + def _parse_known_args(self, arg_strings, namespace):
2.1698 + # replace arg strings that are file references
2.1699 + if self.fromfile_prefix_chars is not None:
2.1700 + arg_strings = self._read_args_from_files(arg_strings)
2.1701 +
2.1702 + # map all mutually exclusive arguments to the other arguments
2.1703 + # they can't occur with
2.1704 + action_conflicts = {}
2.1705 + for mutex_group in self._mutually_exclusive_groups:
2.1706 + group_actions = mutex_group._group_actions
2.1707 + for i, mutex_action in enumerate(mutex_group._group_actions):
2.1708 + conflicts = action_conflicts.setdefault(mutex_action, [])
2.1709 + conflicts.extend(group_actions[:i])
2.1710 + conflicts.extend(group_actions[i + 1:])
2.1711 +
2.1712 + # find all option indices, and determine the arg_string_pattern
2.1713 + # which has an 'O' if there is an option at an index,
2.1714 + # an 'A' if there is an argument, or a '-' if there is a '--'
2.1715 + option_string_indices = {}
2.1716 + arg_string_pattern_parts = []
2.1717 + arg_strings_iter = iter(arg_strings)
2.1718 + for i, arg_string in enumerate(arg_strings_iter):
2.1719 +
2.1720 + # all args after -- are non-options
2.1721 + if arg_string == '--':
2.1722 + arg_string_pattern_parts.append('-')
2.1723 + for arg_string in arg_strings_iter:
2.1724 + arg_string_pattern_parts.append('A')
2.1725 +
2.1726 + # otherwise, add the arg to the arg strings
2.1727 + # and note the index if it was an option
2.1728 + else:
2.1729 + option_tuple = self._parse_optional(arg_string)
2.1730 + if option_tuple is None:
2.1731 + pattern = 'A'
2.1732 + else:
2.1733 + option_string_indices[i] = option_tuple
2.1734 + pattern = 'O'
2.1735 + arg_string_pattern_parts.append(pattern)
2.1736 +
2.1737 + # join the pieces together to form the pattern
2.1738 + arg_strings_pattern = ''.join(arg_string_pattern_parts)
2.1739 +
2.1740 + # converts arg strings to the appropriate and then takes the action
2.1741 + seen_actions = set()
2.1742 + seen_non_default_actions = set()
2.1743 +
2.1744 + def take_action(action, argument_strings, option_string=None):
2.1745 + seen_actions.add(action)
2.1746 + argument_values = self._get_values(action, argument_strings)
2.1747 +
2.1748 + # error if this argument is not allowed with other previously
2.1749 + # seen arguments, assuming that actions that use the default
2.1750 + # value don't really count as "present"
2.1751 + if argument_values is not action.default:
2.1752 + seen_non_default_actions.add(action)
2.1753 + for conflict_action in action_conflicts.get(action, []):
2.1754 + if conflict_action in seen_non_default_actions:
2.1755 + msg = _('not allowed with argument %s')
2.1756 + action_name = _get_action_name(conflict_action)
2.1757 + raise ArgumentError(action, msg % action_name)
2.1758 +
2.1759 + # take the action if we didn't receive a SUPPRESS value
2.1760 + # (e.g. from a default)
2.1761 + if argument_values is not SUPPRESS:
2.1762 + action(self, namespace, argument_values, option_string)
2.1763 +
2.1764 + # function to convert arg_strings into an optional action
2.1765 + def consume_optional(start_index):
2.1766 +
2.1767 + # get the optional identified at this index
2.1768 + option_tuple = option_string_indices[start_index]
2.1769 + action, option_string, explicit_arg = option_tuple
2.1770 +
2.1771 + # identify additional optionals in the same arg string
2.1772 + # (e.g. -xyz is the same as -x -y -z if no args are required)
2.1773 + match_argument = self._match_argument
2.1774 + action_tuples = []
2.1775 + while True:
2.1776 +
2.1777 + # if we found no optional action, skip it
2.1778 + if action is None:
2.1779 + extras.append(arg_strings[start_index])
2.1780 + return start_index + 1
2.1781 +
2.1782 + # if there is an explicit argument, try to match the
2.1783 + # optional's string arguments to only this
2.1784 + if explicit_arg is not None:
2.1785 + arg_count = match_argument(action, 'A')
2.1786 +
2.1787 + # if the action is a single-dash option and takes no
2.1788 + # arguments, try to parse more single-dash options out
2.1789 + # of the tail of the option string
2.1790 + chars = self.prefix_chars
2.1791 + if arg_count == 0 and option_string[1] not in chars:
2.1792 + action_tuples.append((action, [], option_string))
2.1793 + for char in self.prefix_chars:
2.1794 + option_string = char + explicit_arg[0]
2.1795 + explicit_arg = explicit_arg[1:] or None
2.1796 + optionals_map = self._option_string_actions
2.1797 + if option_string in optionals_map:
2.1798 + action = optionals_map[option_string]
2.1799 + break
2.1800 + else:
2.1801 + msg = _('ignored explicit argument %r')
2.1802 + raise ArgumentError(action, msg % explicit_arg)
2.1803 +
2.1804 + # if the action expect exactly one argument, we've
2.1805 + # successfully matched the option; exit the loop
2.1806 + elif arg_count == 1:
2.1807 + stop = start_index + 1
2.1808 + args = [explicit_arg]
2.1809 + action_tuples.append((action, args, option_string))
2.1810 + break
2.1811 +
2.1812 + # error if a double-dash option did not use the
2.1813 + # explicit argument
2.1814 + else:
2.1815 + msg = _('ignored explicit argument %r')
2.1816 + raise ArgumentError(action, msg % explicit_arg)
2.1817 +
2.1818 + # if there is no explicit argument, try to match the
2.1819 + # optional's string arguments with the following strings
2.1820 + # if successful, exit the loop
2.1821 + else:
2.1822 + start = start_index + 1
2.1823 + selected_patterns = arg_strings_pattern[start:]
2.1824 + arg_count = match_argument(action, selected_patterns)
2.1825 + stop = start + arg_count
2.1826 + args = arg_strings[start:stop]
2.1827 + action_tuples.append((action, args, option_string))
2.1828 + break
2.1829 +
2.1830 + # add the Optional to the list and return the index at which
2.1831 + # the Optional's string args stopped
2.1832 + assert action_tuples
2.1833 + for action, args, option_string in action_tuples:
2.1834 + take_action(action, args, option_string)
2.1835 + return stop
2.1836 +
2.1837 + # the list of Positionals left to be parsed; this is modified
2.1838 + # by consume_positionals()
2.1839 + positionals = self._get_positional_actions()
2.1840 +
2.1841 + # function to convert arg_strings into positional actions
2.1842 + def consume_positionals(start_index):
2.1843 + # match as many Positionals as possible
2.1844 + match_partial = self._match_arguments_partial
2.1845 + selected_pattern = arg_strings_pattern[start_index:]
2.1846 + arg_counts = match_partial(positionals, selected_pattern)
2.1847 +
2.1848 + # slice off the appropriate arg strings for each Positional
2.1849 + # and add the Positional and its args to the list
2.1850 + for action, arg_count in zip(positionals, arg_counts):
2.1851 + args = arg_strings[start_index: start_index + arg_count]
2.1852 + start_index += arg_count
2.1853 + take_action(action, args)
2.1854 +
2.1855 + # slice off the Positionals that we just parsed and return the
2.1856 + # index at which the Positionals' string args stopped
2.1857 + positionals[:] = positionals[len(arg_counts):]
2.1858 + return start_index
2.1859 +
2.1860 + # consume Positionals and Optionals alternately, until we have
2.1861 + # passed the last option string
2.1862 + extras = []
2.1863 + start_index = 0
2.1864 + if option_string_indices:
2.1865 + max_option_string_index = max(option_string_indices)
2.1866 + else:
2.1867 + max_option_string_index = -1
2.1868 + while start_index <= max_option_string_index:
2.1869 +
2.1870 + # consume any Positionals preceding the next option
2.1871 + next_option_string_index = min([
2.1872 + index
2.1873 + for index in option_string_indices
2.1874 + if index >= start_index])
2.1875 + if start_index != next_option_string_index:
2.1876 + positionals_end_index = consume_positionals(start_index)
2.1877 +
2.1878 + # only try to parse the next optional if we didn't consume
2.1879 + # the option string during the positionals parsing
2.1880 + if positionals_end_index > start_index:
2.1881 + start_index = positionals_end_index
2.1882 + continue
2.1883 + else:
2.1884 + start_index = positionals_end_index
2.1885 +
2.1886 + # if we consumed all the positionals we could and we're not
2.1887 + # at the index of an option string, there were extra arguments
2.1888 + if start_index not in option_string_indices:
2.1889 + strings = arg_strings[start_index:next_option_string_index]
2.1890 + extras.extend(strings)
2.1891 + start_index = next_option_string_index
2.1892 +
2.1893 + # consume the next optional and any arguments for it
2.1894 + start_index = consume_optional(start_index)
2.1895 +
2.1896 + # consume any positionals following the last Optional
2.1897 + stop_index = consume_positionals(start_index)
2.1898 +
2.1899 + # if we didn't consume all the argument strings, there were extras
2.1900 + extras.extend(arg_strings[stop_index:])
2.1901 +
2.1902 + # if we didn't use all the Positional objects, there were too few
2.1903 + # arg strings supplied.
2.1904 + if positionals:
2.1905 + self.error(_('too few arguments'))
2.1906 +
2.1907 + # make sure all required actions were present
2.1908 + for action in self._actions:
2.1909 + if action.required:
2.1910 + if action not in seen_actions:
2.1911 + name = _get_action_name(action)
2.1912 + self.error(_('argument %s is required') % name)
2.1913 +
2.1914 + # make sure all required groups had one option present
2.1915 + for group in self._mutually_exclusive_groups:
2.1916 + if group.required:
2.1917 + for action in group._group_actions:
2.1918 + if action in seen_non_default_actions:
2.1919 + break
2.1920 +
2.1921 + # if no actions were used, report the error
2.1922 + else:
2.1923 + names = [_get_action_name(action)
2.1924 + for action in group._group_actions
2.1925 + if action.help is not SUPPRESS]
2.1926 + msg = _('one of the arguments %s is required')
2.1927 + self.error(msg % ' '.join(names))
2.1928 +
2.1929 + # return the updated namespace and the extra arguments
2.1930 + return namespace, extras
2.1931 +
2.1932 + def _read_args_from_files(self, arg_strings):
2.1933 + # expand arguments referencing files
2.1934 + new_arg_strings = []
2.1935 + for arg_string in arg_strings:
2.1936 +
2.1937 + # for regular arguments, just add them back into the list
2.1938 + if arg_string[0] not in self.fromfile_prefix_chars:
2.1939 + new_arg_strings.append(arg_string)
2.1940 +
2.1941 + # replace arguments referencing files with the file content
2.1942 + else:
2.1943 + try:
2.1944 + args_file = open(arg_string[1:])
2.1945 + try:
2.1946 + arg_strings = []
2.1947 + for arg_line in args_file.read().splitlines():
2.1948 + for arg in self.convert_arg_line_to_args(arg_line):
2.1949 + arg_strings.append(arg)
2.1950 + arg_strings = self._read_args_from_files(arg_strings)
2.1951 + new_arg_strings.extend(arg_strings)
2.1952 + finally:
2.1953 + args_file.close()
2.1954 + except IOError:
2.1955 + err = _sys.exc_info()[1]
2.1956 + self.error(str(err))
2.1957 +
2.1958 + # return the modified argument list
2.1959 + return new_arg_strings
2.1960 +
2.1961 + def convert_arg_line_to_args(self, arg_line):
2.1962 + return [arg_line]
2.1963 +
2.1964 + def _match_argument(self, action, arg_strings_pattern):
2.1965 + # match the pattern for this action to the arg strings
2.1966 + nargs_pattern = self._get_nargs_pattern(action)
2.1967 + match = _re.match(nargs_pattern, arg_strings_pattern)
2.1968 +
2.1969 + # raise an exception if we weren't able to find a match
2.1970 + if match is None:
2.1971 + nargs_errors = {
2.1972 + None: _('expected one argument'),
2.1973 + OPTIONAL: _('expected at most one argument'),
2.1974 + ONE_OR_MORE: _('expected at least one argument'),
2.1975 + }
2.1976 + default = _('expected %s argument(s)') % action.nargs
2.1977 + msg = nargs_errors.get(action.nargs, default)
2.1978 + raise ArgumentError(action, msg)
2.1979 +
2.1980 + # return the number of arguments matched
2.1981 + return len(match.group(1))
2.1982 +
2.1983 + def _match_arguments_partial(self, actions, arg_strings_pattern):
2.1984 + # progressively shorten the actions list by slicing off the
2.1985 + # final actions until we find a match
2.1986 + result = []
2.1987 + for i in range(len(actions), 0, -1):
2.1988 + actions_slice = actions[:i]
2.1989 + pattern = ''.join([self._get_nargs_pattern(action)
2.1990 + for action in actions_slice])
2.1991 + match = _re.match(pattern, arg_strings_pattern)
2.1992 + if match is not None:
2.1993 + result.extend([len(string) for string in match.groups()])
2.1994 + break
2.1995 +
2.1996 + # return the list of arg string counts
2.1997 + return result
2.1998 +
2.1999 + def _parse_optional(self, arg_string):
2.2000 + # if it's an empty string, it was meant to be a positional
2.2001 + if not arg_string:
2.2002 + return None
2.2003 +
2.2004 + # if it doesn't start with a prefix, it was meant to be positional
2.2005 + if not arg_string[0] in self.prefix_chars:
2.2006 + return None
2.2007 +
2.2008 + # if the option string is present in the parser, return the action
2.2009 + if arg_string in self._option_string_actions:
2.2010 + action = self._option_string_actions[arg_string]
2.2011 + return action, arg_string, None
2.2012 +
2.2013 + # if it's just a single character, it was meant to be positional
2.2014 + if len(arg_string) == 1:
2.2015 + return None
2.2016 +
2.2017 + # if the option string before the "=" is present, return the action
2.2018 + if '=' in arg_string:
2.2019 + option_string, explicit_arg = arg_string.split('=', 1)
2.2020 + if option_string in self._option_string_actions:
2.2021 + action = self._option_string_actions[option_string]
2.2022 + return action, option_string, explicit_arg
2.2023 +
2.2024 + # search through all possible prefixes of the option string
2.2025 + # and all actions in the parser for possible interpretations
2.2026 + option_tuples = self._get_option_tuples(arg_string)
2.2027 +
2.2028 + # if multiple actions match, the option string was ambiguous
2.2029 + if len(option_tuples) > 1:
2.2030 + options = ', '.join([option_string
2.2031 + for action, option_string, explicit_arg in option_tuples])
2.2032 + tup = arg_string, options
2.2033 + self.error(_('ambiguous option: %s could match %s') % tup)
2.2034 +
2.2035 + # if exactly one action matched, this segmentation is good,
2.2036 + # so return the parsed action
2.2037 + elif len(option_tuples) == 1:
2.2038 + option_tuple, = option_tuples
2.2039 + return option_tuple
2.2040 +
2.2041 + # if it was not found as an option, but it looks like a negative
2.2042 + # number, it was meant to be positional
2.2043 + # unless there are negative-number-like options
2.2044 + if self._negative_number_matcher.match(arg_string):
2.2045 + if not self._has_negative_number_optionals:
2.2046 + return None
2.2047 +
2.2048 + # if it contains a space, it was meant to be a positional
2.2049 + if ' ' in arg_string:
2.2050 + return None
2.2051 +
2.2052 + # it was meant to be an optional but there is no such option
2.2053 + # in this parser (though it might be a valid option in a subparser)
2.2054 + return None, arg_string, None
2.2055 +
2.2056 + def _get_option_tuples(self, option_string):
2.2057 + result = []
2.2058 +
2.2059 + # option strings starting with two prefix characters are only
2.2060 + # split at the '='
2.2061 + chars = self.prefix_chars
2.2062 + if option_string[0] in chars and option_string[1] in chars:
2.2063 + if '=' in option_string:
2.2064 + option_prefix, explicit_arg = option_string.split('=', 1)
2.2065 + else:
2.2066 + option_prefix = option_string
2.2067 + explicit_arg = None
2.2068 + for option_string in self._option_string_actions:
2.2069 + if option_string.startswith(option_prefix):
2.2070 + action = self._option_string_actions[option_string]
2.2071 + tup = action, option_string, explicit_arg
2.2072 + result.append(tup)
2.2073 +
2.2074 + # single character options can be concatenated with their arguments
2.2075 + # but multiple character options always have to have their argument
2.2076 + # separate
2.2077 + elif option_string[0] in chars and option_string[1] not in chars:
2.2078 + option_prefix = option_string
2.2079 + explicit_arg = None
2.2080 + short_option_prefix = option_string[:2]
2.2081 + short_explicit_arg = option_string[2:]
2.2082 +
2.2083 + for option_string in self._option_string_actions:
2.2084 + if option_string == short_option_prefix:
2.2085 + action = self._option_string_actions[option_string]
2.2086 + tup = action, option_string, short_explicit_arg
2.2087 + result.append(tup)
2.2088 + elif option_string.startswith(option_prefix):
2.2089 + action = self._option_string_actions[option_string]
2.2090 + tup = action, option_string, explicit_arg
2.2091 + result.append(tup)
2.2092 +
2.2093 + # shouldn't ever get here
2.2094 + else:
2.2095 + self.error(_('unexpected option string: %s') % option_string)
2.2096 +
2.2097 + # return the collected option tuples
2.2098 + return result
2.2099 +
2.2100 + def _get_nargs_pattern(self, action):
2.2101 + # in all examples below, we have to allow for '--' args
2.2102 + # which are represented as '-' in the pattern
2.2103 + nargs = action.nargs
2.2104 +
2.2105 + # the default (None) is assumed to be a single argument
2.2106 + if nargs is None:
2.2107 + nargs_pattern = '(-*A-*)'
2.2108 +
2.2109 + # allow zero or one arguments
2.2110 + elif nargs == OPTIONAL:
2.2111 + nargs_pattern = '(-*A?-*)'
2.2112 +
2.2113 + # allow zero or more arguments
2.2114 + elif nargs == ZERO_OR_MORE:
2.2115 + nargs_pattern = '(-*[A-]*)'
2.2116 +
2.2117 + # allow one or more arguments
2.2118 + elif nargs == ONE_OR_MORE:
2.2119 + nargs_pattern = '(-*A[A-]*)'
2.2120 +
2.2121 + # allow any number of options or arguments
2.2122 + elif nargs == REMAINDER:
2.2123 + nargs_pattern = '([-AO]*)'
2.2124 +
2.2125 + # allow one argument followed by any number of options or arguments
2.2126 + elif nargs == PARSER:
2.2127 + nargs_pattern = '(-*A[-AO]*)'
2.2128 +
2.2129 + # all others should be integers
2.2130 + else:
2.2131 + nargs_pattern = '(-*%s-*)' % '-*'.join('A' * nargs)
2.2132 +
2.2133 + # if this is an optional action, -- is not allowed
2.2134 + if action.option_strings:
2.2135 + nargs_pattern = nargs_pattern.replace('-*', '')
2.2136 + nargs_pattern = nargs_pattern.replace('-', '')
2.2137 +
2.2138 + # return the pattern
2.2139 + return nargs_pattern
2.2140 +
2.2141 + # ========================
2.2142 + # Value conversion methods
2.2143 + # ========================
2.2144 + def _get_values(self, action, arg_strings):
2.2145 + # for everything but PARSER args, strip out '--'
2.2146 + if action.nargs not in [PARSER, REMAINDER]:
2.2147 + arg_strings = [s for s in arg_strings if s != '--']
2.2148 +
2.2149 + # optional argument produces a default when not present
2.2150 + if not arg_strings and action.nargs == OPTIONAL:
2.2151 + if action.option_strings:
2.2152 + value = action.const
2.2153 + else:
2.2154 + value = action.default
2.2155 + if isinstance(value, str):
2.2156 + value = self._get_value(action, value)
2.2157 + self._check_value(action, value)
2.2158 +
2.2159 + # when nargs='*' on a positional, if there were no command-line
2.2160 + # args, use the default if it is anything other than None
2.2161 + elif (not arg_strings and action.nargs == ZERO_OR_MORE and
2.2162 + not action.option_strings):
2.2163 + if action.default is not None:
2.2164 + value = action.default
2.2165 + else:
2.2166 + value = arg_strings
2.2167 + self._check_value(action, value)
2.2168 +
2.2169 + # single argument or optional argument produces a single value
2.2170 + elif len(arg_strings) == 1 and action.nargs in [None, OPTIONAL]:
2.2171 + arg_string, = arg_strings
2.2172 + value = self._get_value(action, arg_string)
2.2173 + self._check_value(action, value)
2.2174 +
2.2175 + # REMAINDER arguments convert all values, checking none
2.2176 + elif action.nargs == REMAINDER:
2.2177 + value = [self._get_value(action, v) for v in arg_strings]
2.2178 +
2.2179 + # PARSER arguments convert all values, but check only the first
2.2180 + elif action.nargs == PARSER:
2.2181 + value = [self._get_value(action, v) for v in arg_strings]
2.2182 + self._check_value(action, value[0])
2.2183 +
2.2184 + # all other types of nargs produce a list
2.2185 + else:
2.2186 + value = [self._get_value(action, v) for v in arg_strings]
2.2187 + for v in value:
2.2188 + self._check_value(action, v)
2.2189 +
2.2190 + # return the converted value
2.2191 + return value
2.2192 +
2.2193 + def _get_value(self, action, arg_string):
2.2194 + type_func = self._registry_get('type', action.type, action.type)
2.2195 + if not _callable(type_func):
2.2196 + msg = _('%r is not callable')
2.2197 + raise ArgumentError(action, msg % type_func)
2.2198 +
2.2199 + # convert the value to the appropriate type
2.2200 + try:
2.2201 + result = type_func(arg_string)
2.2202 +
2.2203 + # ArgumentTypeErrors indicate errors
2.2204 + except ArgumentTypeError:
2.2205 + name = getattr(action.type, '__name__', repr(action.type))
2.2206 + msg = str(_sys.exc_info()[1])
2.2207 + raise ArgumentError(action, msg)
2.2208 +
2.2209 + # TypeErrors or ValueErrors also indicate errors
2.2210 + except (TypeError, ValueError):
2.2211 + name = getattr(action.type, '__name__', repr(action.type))
2.2212 + msg = _('invalid %s value: %r')
2.2213 + raise ArgumentError(action, msg % (name, arg_string))
2.2214 +
2.2215 + # return the converted value
2.2216 + return result
2.2217 +
2.2218 + def _check_value(self, action, value):
2.2219 + # converted value must be one of the choices (if specified)
2.2220 + if action.choices is not None and value not in action.choices:
2.2221 + tup = value, ', '.join(map(repr, action.choices))
2.2222 + msg = _('invalid choice: %r (choose from %s)') % tup
2.2223 + raise ArgumentError(action, msg)
2.2224 +
2.2225 + # =======================
2.2226 + # Help-formatting methods
2.2227 + # =======================
2.2228 + def format_usage(self):
2.2229 + formatter = self._get_formatter()
2.2230 + formatter.add_usage(self.usage, self._actions,
2.2231 + self._mutually_exclusive_groups)
2.2232 + return formatter.format_help()
2.2233 +
2.2234 + def format_help(self):
2.2235 + formatter = self._get_formatter()
2.2236 +
2.2237 + # usage
2.2238 + formatter.add_usage(self.usage, self._actions,
2.2239 + self._mutually_exclusive_groups)
2.2240 +
2.2241 + # description
2.2242 + formatter.add_text(self.description)
2.2243 +
2.2244 + # positionals, optionals and user-defined groups
2.2245 + for action_group in self._action_groups:
2.2246 + formatter.start_section(action_group.title)
2.2247 + formatter.add_text(action_group.description)
2.2248 + formatter.add_arguments(action_group._group_actions)
2.2249 + formatter.end_section()
2.2250 +
2.2251 + # epilog
2.2252 + formatter.add_text(self.epilog)
2.2253 +
2.2254 + # determine help from format above
2.2255 + return formatter.format_help()
2.2256 +
2.2257 + def format_version(self):
2.2258 + import warnings
2.2259 + warnings.warn(
2.2260 + 'The format_version method is deprecated -- the "version" '
2.2261 + 'argument to ArgumentParser is no longer supported.',
2.2262 + DeprecationWarning)
2.2263 + formatter = self._get_formatter()
2.2264 + formatter.add_text(self.version)
2.2265 + return formatter.format_help()
2.2266 +
2.2267 + def _get_formatter(self):
2.2268 + return self.formatter_class(prog=self.prog)
2.2269 +
2.2270 + # =====================
2.2271 + # Help-printing methods
2.2272 + # =====================
2.2273 + def print_usage(self, file=None):
2.2274 + if file is None:
2.2275 + file = _sys.stdout
2.2276 + self._print_message(self.format_usage(), file)
2.2277 +
2.2278 + def print_help(self, file=None):
2.2279 + if file is None:
2.2280 + file = _sys.stdout
2.2281 + self._print_message(self.format_help(), file)
2.2282 +
2.2283 + def print_version(self, file=None):
2.2284 + import warnings
2.2285 + warnings.warn(
2.2286 + 'The print_version method is deprecated -- the "version" '
2.2287 + 'argument to ArgumentParser is no longer supported.',
2.2288 + DeprecationWarning)
2.2289 + self._print_message(self.format_version(), file)
2.2290 +
2.2291 + def _print_message(self, message, file=None):
2.2292 + if message:
2.2293 + if file is None:
2.2294 + file = _sys.stderr
2.2295 + file.write(message)
2.2296 +
2.2297 + # ===============
2.2298 + # Exiting methods
2.2299 + # ===============
2.2300 + def exit(self, status=0, message=None):
2.2301 + if message:
2.2302 + self._print_message(message, _sys.stderr)
2.2303 + _sys.exit(status)
2.2304 +
2.2305 + def error(self, message):
2.2306 + """error(message: string)
2.2307 +
2.2308 + Prints a usage message incorporating the message to stderr and
2.2309 + exits.
2.2310 +
2.2311 + If you override this in a subclass, it should not return -- it
2.2312 + should either exit or raise an exception.
2.2313 + """
2.2314 + self.print_usage(_sys.stderr)
2.2315 + self.exit(2, _('%s: error: %s\n') % (self.prog, message))
3.1 Binary file httpdocs/favicon.ico has changed
4.1 Binary file httpdocs/fonts/CPMono_v07_Bold-webfont.woff has changed
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/httpdocs/fonts/Freeware License.txt Mon Feb 20 15:10:53 2012 +0100
5.3 @@ -0,0 +1,5 @@
5.4 +This font was found on the internet and did not come with a license. While we try to make sure that all the fonts on fontsquirrel.com are properly licensed for commercial use, there are many fonts that have either been abandoned by their authors or the authors distribute their fonts without an explicit license.
5.5 +
5.6 +It is our opinion that if the unlicensed font is freely available for download from either the original source or from multiple free-font sites then we assume it to be safe to use the font commercially. This is no guarantee of such freedom, but there are so many unlicensed free fonts distributed by primary sources that the intentions must be read that the font is free to use how you like.
5.7 +
5.8 +We are not lawyers and don't pretend to be them on TV. Please report any errors/violations you know of. http://www.fontsquirrel.com/contact
5.9 \ No newline at end of file
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/httpdocs/fonts/SIL Open Font License 1.1.txt Mon Feb 20 15:10:53 2012 +0100
6.3 @@ -0,0 +1,91 @@
6.4 +This Font Software is licensed under the SIL Open Font License, Version 1.1.
6.5 +This license is copied below, and is also available with a FAQ at:
6.6 +http://scripts.sil.org/OFL
6.7 +
6.8 +
6.9 +-----------------------------------------------------------
6.10 +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
6.11 +-----------------------------------------------------------
6.12 +
6.13 +PREAMBLE
6.14 +The goals of the Open Font License (OFL) are to stimulate worldwide
6.15 +development of collaborative font projects, to support the font creation
6.16 +efforts of academic and linguistic communities, and to provide a free and
6.17 +open framework in which fonts may be shared and improved in partnership
6.18 +with others.
6.19 +
6.20 +The OFL allows the licensed fonts to be used, studied, modified and
6.21 +redistributed freely as long as they are not sold by themselves. The
6.22 +fonts, including any derivative works, can be bundled, embedded,
6.23 +redistributed and/or sold with any software provided that any reserved
6.24 +names are not used by derivative works. The fonts and derivatives,
6.25 +however, cannot be released under any other type of license. The
6.26 +requirement for fonts to remain under this license does not apply
6.27 +to any document created using the fonts or their derivatives.
6.28 +
6.29 +DEFINITIONS
6.30 +"Font Software" refers to the set of files released by the Copyright
6.31 +Holder(s) under this license and clearly marked as such. This may
6.32 +include source files, build scripts and documentation.
6.33 +
6.34 +"Reserved Font Name" refers to any names specified as such after the
6.35 +copyright statement(s).
6.36 +
6.37 +"Original Version" refers to the collection of Font Software components as
6.38 +distributed by the Copyright Holder(s).
6.39 +
6.40 +"Modified Version" refers to any derivative made by adding to, deleting,
6.41 +or substituting -- in part or in whole -- any of the components of the
6.42 +Original Version, by changing formats or by porting the Font Software to a
6.43 +new environment.
6.44 +
6.45 +"Author" refers to any designer, engineer, programmer, technical
6.46 +writer or other person who contributed to the Font Software.
6.47 +
6.48 +PERMISSION & CONDITIONS
6.49 +Permission is hereby granted, free of charge, to any person obtaining
6.50 +a copy of the Font Software, to use, study, copy, merge, embed, modify,
6.51 +redistribute, and sell modified and unmodified copies of the Font
6.52 +Software, subject to the following conditions:
6.53 +
6.54 +1) Neither the Font Software nor any of its individual components,
6.55 +in Original or Modified Versions, may be sold by itself.
6.56 +
6.57 +2) Original or Modified Versions of the Font Software may be bundled,
6.58 +redistributed and/or sold with any software, provided that each copy
6.59 +contains the above copyright notice and this license. These can be
6.60 +included either as stand-alone text files, human-readable headers or
6.61 +in the appropriate machine-readable metadata fields within text or
6.62 +binary files as long as those fields can be easily viewed by the user.
6.63 +
6.64 +3) No Modified Version of the Font Software may use the Reserved Font
6.65 +Name(s) unless explicit written permission is granted by the corresponding
6.66 +Copyright Holder. This restriction only applies to the primary font name as
6.67 +presented to the users.
6.68 +
6.69 +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
6.70 +Software shall not be used to promote, endorse or advertise any
6.71 +Modified Version, except to acknowledge the contribution(s) of the
6.72 +Copyright Holder(s) and the Author(s) or with their explicit written
6.73 +permission.
6.74 +
6.75 +5) The Font Software, modified or unmodified, in part or in whole,
6.76 +must be distributed entirely under this license, and must not be
6.77 +distributed under any other license. The requirement for fonts to
6.78 +remain under this license does not apply to any document created
6.79 +using the Font Software.
6.80 +
6.81 +TERMINATION
6.82 +This license becomes null and void if any of the above conditions are
6.83 +not met.
6.84 +
6.85 +DISCLAIMER
6.86 +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
6.87 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
6.88 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
6.89 +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
6.90 +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
6.91 +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
6.92 +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
6.93 +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
6.94 +OTHER DEALINGS IN THE FONT SOFTWARE.
6.95 \ No newline at end of file
7.1 Binary file httpdocs/fonts/TitilliumText22L001-webfont.woff has changed
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/httpdocs/index.html Mon Feb 20 15:10:53 2012 +0100
8.3 @@ -0,0 +1,32 @@
8.4 +<!DOCTYPE html>
8.5 +<html lang="en">
8.6 + <head>
8.7 + <title>Wordls</title>
8.8 + <meta name="description" content="pseudoword brawl" />
8.9 + <meta name="keywords" content="pseudoword neoglism" />
8.10 + <meta name="author" content="Eugen Sawin <sawine@me73.com>" />
8.11 + <script src="jquery.js" type="text/javascript"></script>
8.12 + <script src="jquery.cookie.js" type="text/javascript"></script>
8.13 + <script src="script.js" type="text/javascript"></script>
8.14 + <link rel="stylesheet" type="text/css" href="style.css" />
8.15 + </head>
8.16 + <body>
8.17 + <div id="wrap">
8.18 + <div id="title-area">Wordls</div>
8.19 + <div id="compare-area">
8.20 + <a href="javascript:select_left()">
8.21 + <div id="compare-left" class="hover-backlight padding-right">Left</div>
8.22 + </a>
8.23 + <a href="javascript:select_right()">
8.24 + <div id="compare-right" class="hover-backlight padding-left">Right</div>
8.25 + </a>
8.26 + </div>
8.27 + <div id="result-area">
8.28 + <div id="result-left" class="padding-right"></div>
8.29 + <div id="result-left-rating"></div>
8.30 + <div id="result-right-rating"></div>
8.31 + <div id="result-right" class="padding-left"></div>
8.32 + </div>
8.33 + </div>
8.34 + </body>
8.35 +</html>
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/httpdocs/jquery.cookie.js Mon Feb 20 15:10:53 2012 +0100
9.3 @@ -0,0 +1,47 @@
9.4 +/*!
9.5 + * jQuery Cookie Plugin
9.6 + * https://github.com/carhartl/jquery-cookie
9.7 + *
9.8 + * Copyright 2011, Klaus Hartl
9.9 + * Dual licensed under the MIT or GPL Version 2 licenses.
9.10 + * http://www.opensource.org/licenses/mit-license.php
9.11 + * http://www.opensource.org/licenses/GPL-2.0
9.12 + */
9.13 +(function($) {
9.14 + $.cookie = function(key, value, options) {
9.15 +
9.16 + // key and at least value given, set cookie...
9.17 + if (arguments.length > 1 && (!/Object/.test(Object.prototype.toString.call(value)) || value === null || value === undefined)) {
9.18 + options = $.extend({}, options);
9.19 +
9.20 + if (value === null || value === undefined) {
9.21 + options.expires = -1;
9.22 + }
9.23 +
9.24 + if (typeof options.expires === 'number') {
9.25 + var days = options.expires, t = options.expires = new Date();
9.26 + t.setDate(t.getDate() + days);
9.27 + }
9.28 +
9.29 + value = String(value);
9.30 +
9.31 + return (document.cookie = [
9.32 + encodeURIComponent(key), '=', options.raw ? value : encodeURIComponent(value),
9.33 + options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
9.34 + options.path ? '; path=' + options.path : '',
9.35 + options.domain ? '; domain=' + options.domain : '',
9.36 + options.secure ? '; secure' : ''
9.37 + ].join(''));
9.38 + }
9.39 +
9.40 + // key and possibly options given, get cookie...
9.41 + options = value || {};
9.42 + var decode = options.raw ? function(s) { return s; } : decodeURIComponent;
9.43 +
9.44 + var pairs = document.cookie.split('; ');
9.45 + for (var i = 0, pair; pair = pairs[i] && pairs[i].split('='); i++) {
9.46 + if (decode(pair[0]) === key) return decode(pair[1] || ''); // IE saves cookies with empty string as "c; ", e.g. without "=" as opposed to EOMB, thus pair[1] may be undefined
9.47 + }
9.48 + return null;
9.49 + };
9.50 +})(jQuery);
9.51 \ No newline at end of file
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/httpdocs/jquery.js Mon Feb 20 15:10:53 2012 +0100
10.3 @@ -0,0 +1,9046 @@
10.4 +/*!
10.5 + * jQuery JavaScript Library v1.6.4
10.6 + * http://jquery.com/
10.7 + *
10.8 + * Copyright 2011, John Resig
10.9 + * Dual licensed under the MIT or GPL Version 2 licenses.
10.10 + * http://jquery.org/license
10.11 + *
10.12 + * Includes Sizzle.js
10.13 + * http://sizzlejs.com/
10.14 + * Copyright 2011, The Dojo Foundation
10.15 + * Released under the MIT, BSD, and GPL Licenses.
10.16 + *
10.17 + * Date: Mon Sep 12 18:54:48 2011 -0400
10.18 + */
10.19 +(function( window, undefined ) {
10.20 +
10.21 +// Use the correct document accordingly with window argument (sandbox)
10.22 +var document = window.document,
10.23 + navigator = window.navigator,
10.24 + location = window.location;
10.25 +var jQuery = (function() {
10.26 +
10.27 +// Define a local copy of jQuery
10.28 +var jQuery = function( selector, context ) {
10.29 + // The jQuery object is actually just the init constructor 'enhanced'
10.30 + return new jQuery.fn.init( selector, context, rootjQuery );
10.31 + },
10.32 +
10.33 + // Map over jQuery in case of overwrite
10.34 + _jQuery = window.jQuery,
10.35 +
10.36 + // Map over the $ in case of overwrite
10.37 + _$ = window.$,
10.38 +
10.39 + // A central reference to the root jQuery(document)
10.40 + rootjQuery,
10.41 +
10.42 + // A simple way to check for HTML strings or ID strings
10.43 + // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
10.44 + quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
10.45 +
10.46 + // Check if a string has a non-whitespace character in it
10.47 + rnotwhite = /\S/,
10.48 +
10.49 + // Used for trimming whitespace
10.50 + trimLeft = /^\s+/,
10.51 + trimRight = /\s+$/,
10.52 +
10.53 + // Check for digits
10.54 + rdigit = /\d/,
10.55 +
10.56 + // Match a standalone tag
10.57 + rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
10.58 +
10.59 + // JSON RegExp
10.60 + rvalidchars = /^[\],:{}\s]*$/,
10.61 + rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
10.62 + rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
10.63 + rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
10.64 +
10.65 + // Useragent RegExp
10.66 + rwebkit = /(webkit)[ \/]([\w.]+)/,
10.67 + ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
10.68 + rmsie = /(msie) ([\w.]+)/,
10.69 + rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
10.70 +
10.71 + // Matches dashed string for camelizing
10.72 + rdashAlpha = /-([a-z]|[0-9])/ig,
10.73 + rmsPrefix = /^-ms-/,
10.74 +
10.75 + // Used by jQuery.camelCase as callback to replace()
10.76 + fcamelCase = function( all, letter ) {
10.77 + return ( letter + "" ).toUpperCase();
10.78 + },
10.79 +
10.80 + // Keep a UserAgent string for use with jQuery.browser
10.81 + userAgent = navigator.userAgent,
10.82 +
10.83 + // For matching the engine and version of the browser
10.84 + browserMatch,
10.85 +
10.86 + // The deferred used on DOM ready
10.87 + readyList,
10.88 +
10.89 + // The ready event handler
10.90 + DOMContentLoaded,
10.91 +
10.92 + // Save a reference to some core methods
10.93 + toString = Object.prototype.toString,
10.94 + hasOwn = Object.prototype.hasOwnProperty,
10.95 + push = Array.prototype.push,
10.96 + slice = Array.prototype.slice,
10.97 + trim = String.prototype.trim,
10.98 + indexOf = Array.prototype.indexOf,
10.99 +
10.100 + // [[Class]] -> type pairs
10.101 + class2type = {};
10.102 +
10.103 +jQuery.fn = jQuery.prototype = {
10.104 + constructor: jQuery,
10.105 + init: function( selector, context, rootjQuery ) {
10.106 + var match, elem, ret, doc;
10.107 +
10.108 + // Handle $(""), $(null), or $(undefined)
10.109 + if ( !selector ) {
10.110 + return this;
10.111 + }
10.112 +
10.113 + // Handle $(DOMElement)
10.114 + if ( selector.nodeType ) {
10.115 + this.context = this[0] = selector;
10.116 + this.length = 1;
10.117 + return this;
10.118 + }
10.119 +
10.120 + // The body element only exists once, optimize finding it
10.121 + if ( selector === "body" && !context && document.body ) {
10.122 + this.context = document;
10.123 + this[0] = document.body;
10.124 + this.selector = selector;
10.125 + this.length = 1;
10.126 + return this;
10.127 + }
10.128 +
10.129 + // Handle HTML strings
10.130 + if ( typeof selector === "string" ) {
10.131 + // Are we dealing with HTML string or an ID?
10.132 + if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
10.133 + // Assume that strings that start and end with <> are HTML and skip the regex check
10.134 + match = [ null, selector, null ];
10.135 +
10.136 + } else {
10.137 + match = quickExpr.exec( selector );
10.138 + }
10.139 +
10.140 + // Verify a match, and that no context was specified for #id
10.141 + if ( match && (match[1] || !context) ) {
10.142 +
10.143 + // HANDLE: $(html) -> $(array)
10.144 + if ( match[1] ) {
10.145 + context = context instanceof jQuery ? context[0] : context;
10.146 + doc = (context ? context.ownerDocument || context : document);
10.147 +
10.148 + // If a single string is passed in and it's a single tag
10.149 + // just do a createElement and skip the rest
10.150 + ret = rsingleTag.exec( selector );
10.151 +
10.152 + if ( ret ) {
10.153 + if ( jQuery.isPlainObject( context ) ) {
10.154 + selector = [ document.createElement( ret[1] ) ];
10.155 + jQuery.fn.attr.call( selector, context, true );
10.156 +
10.157 + } else {
10.158 + selector = [ doc.createElement( ret[1] ) ];
10.159 + }
10.160 +
10.161 + } else {
10.162 + ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
10.163 + selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes;
10.164 + }
10.165 +
10.166 + return jQuery.merge( this, selector );
10.167 +
10.168 + // HANDLE: $("#id")
10.169 + } else {
10.170 + elem = document.getElementById( match[2] );
10.171 +
10.172 + // Check parentNode to catch when Blackberry 4.6 returns
10.173 + // nodes that are no longer in the document #6963
10.174 + if ( elem && elem.parentNode ) {
10.175 + // Handle the case where IE and Opera return items
10.176 + // by name instead of ID
10.177 + if ( elem.id !== match[2] ) {
10.178 + return rootjQuery.find( selector );
10.179 + }
10.180 +
10.181 + // Otherwise, we inject the element directly into the jQuery object
10.182 + this.length = 1;
10.183 + this[0] = elem;
10.184 + }
10.185 +
10.186 + this.context = document;
10.187 + this.selector = selector;
10.188 + return this;
10.189 + }
10.190 +
10.191 + // HANDLE: $(expr, $(...))
10.192 + } else if ( !context || context.jquery ) {
10.193 + return (context || rootjQuery).find( selector );
10.194 +
10.195 + // HANDLE: $(expr, context)
10.196 + // (which is just equivalent to: $(context).find(expr)
10.197 + } else {
10.198 + return this.constructor( context ).find( selector );
10.199 + }
10.200 +
10.201 + // HANDLE: $(function)
10.202 + // Shortcut for document ready
10.203 + } else if ( jQuery.isFunction( selector ) ) {
10.204 + return rootjQuery.ready( selector );
10.205 + }
10.206 +
10.207 + if (selector.selector !== undefined) {
10.208 + this.selector = selector.selector;
10.209 + this.context = selector.context;
10.210 + }
10.211 +
10.212 + return jQuery.makeArray( selector, this );
10.213 + },
10.214 +
10.215 + // Start with an empty selector
10.216 + selector: "",
10.217 +
10.218 + // The current version of jQuery being used
10.219 + jquery: "1.6.4",
10.220 +
10.221 + // The default length of a jQuery object is 0
10.222 + length: 0,
10.223 +
10.224 + // The number of elements contained in the matched element set
10.225 + size: function() {
10.226 + return this.length;
10.227 + },
10.228 +
10.229 + toArray: function() {
10.230 + return slice.call( this, 0 );
10.231 + },
10.232 +
10.233 + // Get the Nth element in the matched element set OR
10.234 + // Get the whole matched element set as a clean array
10.235 + get: function( num ) {
10.236 + return num == null ?
10.237 +
10.238 + // Return a 'clean' array
10.239 + this.toArray() :
10.240 +
10.241 + // Return just the object
10.242 + ( num < 0 ? this[ this.length + num ] : this[ num ] );
10.243 + },
10.244 +
10.245 + // Take an array of elements and push it onto the stack
10.246 + // (returning the new matched element set)
10.247 + pushStack: function( elems, name, selector ) {
10.248 + // Build a new jQuery matched element set
10.249 + var ret = this.constructor();
10.250 +
10.251 + if ( jQuery.isArray( elems ) ) {
10.252 + push.apply( ret, elems );
10.253 +
10.254 + } else {
10.255 + jQuery.merge( ret, elems );
10.256 + }
10.257 +
10.258 + // Add the old object onto the stack (as a reference)
10.259 + ret.prevObject = this;
10.260 +
10.261 + ret.context = this.context;
10.262 +
10.263 + if ( name === "find" ) {
10.264 + ret.selector = this.selector + (this.selector ? " " : "") + selector;
10.265 + } else if ( name ) {
10.266 + ret.selector = this.selector + "." + name + "(" + selector + ")";
10.267 + }
10.268 +
10.269 + // Return the newly-formed element set
10.270 + return ret;
10.271 + },
10.272 +
10.273 + // Execute a callback for every element in the matched set.
10.274 + // (You can seed the arguments with an array of args, but this is
10.275 + // only used internally.)
10.276 + each: function( callback, args ) {
10.277 + return jQuery.each( this, callback, args );
10.278 + },
10.279 +
10.280 + ready: function( fn ) {
10.281 + // Attach the listeners
10.282 + jQuery.bindReady();
10.283 +
10.284 + // Add the callback
10.285 + readyList.done( fn );
10.286 +
10.287 + return this;
10.288 + },
10.289 +
10.290 + eq: function( i ) {
10.291 + return i === -1 ?
10.292 + this.slice( i ) :
10.293 + this.slice( i, +i + 1 );
10.294 + },
10.295 +
10.296 + first: function() {
10.297 + return this.eq( 0 );
10.298 + },
10.299 +
10.300 + last: function() {
10.301 + return this.eq( -1 );
10.302 + },
10.303 +
10.304 + slice: function() {
10.305 + return this.pushStack( slice.apply( this, arguments ),
10.306 + "slice", slice.call(arguments).join(",") );
10.307 + },
10.308 +
10.309 + map: function( callback ) {
10.310 + return this.pushStack( jQuery.map(this, function( elem, i ) {
10.311 + return callback.call( elem, i, elem );
10.312 + }));
10.313 + },
10.314 +
10.315 + end: function() {
10.316 + return this.prevObject || this.constructor(null);
10.317 + },
10.318 +
10.319 + // For internal use only.
10.320 + // Behaves like an Array's method, not like a jQuery method.
10.321 + push: push,
10.322 + sort: [].sort,
10.323 + splice: [].splice
10.324 +};
10.325 +
10.326 +// Give the init function the jQuery prototype for later instantiation
10.327 +jQuery.fn.init.prototype = jQuery.fn;
10.328 +
10.329 +jQuery.extend = jQuery.fn.extend = function() {
10.330 + var options, name, src, copy, copyIsArray, clone,
10.331 + target = arguments[0] || {},
10.332 + i = 1,
10.333 + length = arguments.length,
10.334 + deep = false;
10.335 +
10.336 + // Handle a deep copy situation
10.337 + if ( typeof target === "boolean" ) {
10.338 + deep = target;
10.339 + target = arguments[1] || {};
10.340 + // skip the boolean and the target
10.341 + i = 2;
10.342 + }
10.343 +
10.344 + // Handle case when target is a string or something (possible in deep copy)
10.345 + if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
10.346 + target = {};
10.347 + }
10.348 +
10.349 + // extend jQuery itself if only one argument is passed
10.350 + if ( length === i ) {
10.351 + target = this;
10.352 + --i;
10.353 + }
10.354 +
10.355 + for ( ; i < length; i++ ) {
10.356 + // Only deal with non-null/undefined values
10.357 + if ( (options = arguments[ i ]) != null ) {
10.358 + // Extend the base object
10.359 + for ( name in options ) {
10.360 + src = target[ name ];
10.361 + copy = options[ name ];
10.362 +
10.363 + // Prevent never-ending loop
10.364 + if ( target === copy ) {
10.365 + continue;
10.366 + }
10.367 +
10.368 + // Recurse if we're merging plain objects or arrays
10.369 + if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
10.370 + if ( copyIsArray ) {
10.371 + copyIsArray = false;
10.372 + clone = src && jQuery.isArray(src) ? src : [];
10.373 +
10.374 + } else {
10.375 + clone = src && jQuery.isPlainObject(src) ? src : {};
10.376 + }
10.377 +
10.378 + // Never move original objects, clone them
10.379 + target[ name ] = jQuery.extend( deep, clone, copy );
10.380 +
10.381 + // Don't bring in undefined values
10.382 + } else if ( copy !== undefined ) {
10.383 + target[ name ] = copy;
10.384 + }
10.385 + }
10.386 + }
10.387 + }
10.388 +
10.389 + // Return the modified object
10.390 + return target;
10.391 +};
10.392 +
10.393 +jQuery.extend({
10.394 + noConflict: function( deep ) {
10.395 + if ( window.$ === jQuery ) {
10.396 + window.$ = _$;
10.397 + }
10.398 +
10.399 + if ( deep && window.jQuery === jQuery ) {
10.400 + window.jQuery = _jQuery;
10.401 + }
10.402 +
10.403 + return jQuery;
10.404 + },
10.405 +
10.406 + // Is the DOM ready to be used? Set to true once it occurs.
10.407 + isReady: false,
10.408 +
10.409 + // A counter to track how many items to wait for before
10.410 + // the ready event fires. See #6781
10.411 + readyWait: 1,
10.412 +
10.413 + // Hold (or release) the ready event
10.414 + holdReady: function( hold ) {
10.415 + if ( hold ) {
10.416 + jQuery.readyWait++;
10.417 + } else {
10.418 + jQuery.ready( true );
10.419 + }
10.420 + },
10.421 +
10.422 + // Handle when the DOM is ready
10.423 + ready: function( wait ) {
10.424 + // Either a released hold or an DOMready/load event and not yet ready
10.425 + if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
10.426 + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
10.427 + if ( !document.body ) {
10.428 + return setTimeout( jQuery.ready, 1 );
10.429 + }
10.430 +
10.431 + // Remember that the DOM is ready
10.432 + jQuery.isReady = true;
10.433 +
10.434 + // If a normal DOM Ready event fired, decrement, and wait if need be
10.435 + if ( wait !== true && --jQuery.readyWait > 0 ) {
10.436 + return;
10.437 + }
10.438 +
10.439 + // If there are functions bound, to execute
10.440 + readyList.resolveWith( document, [ jQuery ] );
10.441 +
10.442 + // Trigger any bound ready events
10.443 + if ( jQuery.fn.trigger ) {
10.444 + jQuery( document ).trigger( "ready" ).unbind( "ready" );
10.445 + }
10.446 + }
10.447 + },
10.448 +
10.449 + bindReady: function() {
10.450 + if ( readyList ) {
10.451 + return;
10.452 + }
10.453 +
10.454 + readyList = jQuery._Deferred();
10.455 +
10.456 + // Catch cases where $(document).ready() is called after the
10.457 + // browser event has already occurred.
10.458 + if ( document.readyState === "complete" ) {
10.459 + // Handle it asynchronously to allow scripts the opportunity to delay ready
10.460 + return setTimeout( jQuery.ready, 1 );
10.461 + }
10.462 +
10.463 + // Mozilla, Opera and webkit nightlies currently support this event
10.464 + if ( document.addEventListener ) {
10.465 + // Use the handy event callback
10.466 + document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
10.467 +
10.468 + // A fallback to window.onload, that will always work
10.469 + window.addEventListener( "load", jQuery.ready, false );
10.470 +
10.471 + // If IE event model is used
10.472 + } else if ( document.attachEvent ) {
10.473 + // ensure firing before onload,
10.474 + // maybe late but safe also for iframes
10.475 + document.attachEvent( "onreadystatechange", DOMContentLoaded );
10.476 +
10.477 + // A fallback to window.onload, that will always work
10.478 + window.attachEvent( "onload", jQuery.ready );
10.479 +
10.480 + // If IE and not a frame
10.481 + // continually check to see if the document is ready
10.482 + var toplevel = false;
10.483 +
10.484 + try {
10.485 + toplevel = window.frameElement == null;
10.486 + } catch(e) {}
10.487 +
10.488 + if ( document.documentElement.doScroll && toplevel ) {
10.489 + doScrollCheck();
10.490 + }
10.491 + }
10.492 + },
10.493 +
10.494 + // See test/unit/core.js for details concerning isFunction.
10.495 + // Since version 1.3, DOM methods and functions like alert
10.496 + // aren't supported. They return false on IE (#2968).
10.497 + isFunction: function( obj ) {
10.498 + return jQuery.type(obj) === "function";
10.499 + },
10.500 +
10.501 + isArray: Array.isArray || function( obj ) {
10.502 + return jQuery.type(obj) === "array";
10.503 + },
10.504 +
10.505 + // A crude way of determining if an object is a window
10.506 + isWindow: function( obj ) {
10.507 + return obj && typeof obj === "object" && "setInterval" in obj;
10.508 + },
10.509 +
10.510 + isNaN: function( obj ) {
10.511 + return obj == null || !rdigit.test( obj ) || isNaN( obj );
10.512 + },
10.513 +
10.514 + type: function( obj ) {
10.515 + return obj == null ?
10.516 + String( obj ) :
10.517 + class2type[ toString.call(obj) ] || "object";
10.518 + },
10.519 +
10.520 + isPlainObject: function( obj ) {
10.521 + // Must be an Object.
10.522 + // Because of IE, we also have to check the presence of the constructor property.
10.523 + // Make sure that DOM nodes and window objects don't pass through, as well
10.524 + if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
10.525 + return false;
10.526 + }
10.527 +
10.528 + try {
10.529 + // Not own constructor property must be Object
10.530 + if ( obj.constructor &&
10.531 + !hasOwn.call(obj, "constructor") &&
10.532 + !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
10.533 + return false;
10.534 + }
10.535 + } catch ( e ) {
10.536 + // IE8,9 Will throw exceptions on certain host objects #9897
10.537 + return false;
10.538 + }
10.539 +
10.540 + // Own properties are enumerated firstly, so to speed up,
10.541 + // if last one is own, then all properties are own.
10.542 +
10.543 + var key;
10.544 + for ( key in obj ) {}
10.545 +
10.546 + return key === undefined || hasOwn.call( obj, key );
10.547 + },
10.548 +
10.549 + isEmptyObject: function( obj ) {
10.550 + for ( var name in obj ) {
10.551 + return false;
10.552 + }
10.553 + return true;
10.554 + },
10.555 +
10.556 + error: function( msg ) {
10.557 + throw msg;
10.558 + },
10.559 +
10.560 + parseJSON: function( data ) {
10.561 + if ( typeof data !== "string" || !data ) {
10.562 + return null;
10.563 + }
10.564 +
10.565 + // Make sure leading/trailing whitespace is removed (IE can't handle it)
10.566 + data = jQuery.trim( data );
10.567 +
10.568 + // Attempt to parse using the native JSON parser first
10.569 + if ( window.JSON && window.JSON.parse ) {
10.570 + return window.JSON.parse( data );
10.571 + }
10.572 +
10.573 + // Make sure the incoming data is actual JSON
10.574 + // Logic borrowed from http://json.org/json2.js
10.575 + if ( rvalidchars.test( data.replace( rvalidescape, "@" )
10.576 + .replace( rvalidtokens, "]" )
10.577 + .replace( rvalidbraces, "")) ) {
10.578 +
10.579 + return (new Function( "return " + data ))();
10.580 +
10.581 + }
10.582 + jQuery.error( "Invalid JSON: " + data );
10.583 + },
10.584 +
10.585 + // Cross-browser xml parsing
10.586 + parseXML: function( data ) {
10.587 + var xml, tmp;
10.588 + try {
10.589 + if ( window.DOMParser ) { // Standard
10.590 + tmp = new DOMParser();
10.591 + xml = tmp.parseFromString( data , "text/xml" );
10.592 + } else { // IE
10.593 + xml = new ActiveXObject( "Microsoft.XMLDOM" );
10.594 + xml.async = "false";
10.595 + xml.loadXML( data );
10.596 + }
10.597 + } catch( e ) {
10.598 + xml = undefined;
10.599 + }
10.600 + if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
10.601 + jQuery.error( "Invalid XML: " + data );
10.602 + }
10.603 + return xml;
10.604 + },
10.605 +
10.606 + noop: function() {},
10.607 +
10.608 + // Evaluates a script in a global context
10.609 + // Workarounds based on findings by Jim Driscoll
10.610 + // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
10.611 + globalEval: function( data ) {
10.612 + if ( data && rnotwhite.test( data ) ) {
10.613 + // We use execScript on Internet Explorer
10.614 + // We use an anonymous function so that context is window
10.615 + // rather than jQuery in Firefox
10.616 + ( window.execScript || function( data ) {
10.617 + window[ "eval" ].call( window, data );
10.618 + } )( data );
10.619 + }
10.620 + },
10.621 +
10.622 + // Convert dashed to camelCase; used by the css and data modules
10.623 + // Microsoft forgot to hump their vendor prefix (#9572)
10.624 + camelCase: function( string ) {
10.625 + return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
10.626 + },
10.627 +
10.628 + nodeName: function( elem, name ) {
10.629 + return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
10.630 + },
10.631 +
10.632 + // args is for internal usage only
10.633 + each: function( object, callback, args ) {
10.634 + var name, i = 0,
10.635 + length = object.length,
10.636 + isObj = length === undefined || jQuery.isFunction( object );
10.637 +
10.638 + if ( args ) {
10.639 + if ( isObj ) {
10.640 + for ( name in object ) {
10.641 + if ( callback.apply( object[ name ], args ) === false ) {
10.642 + break;
10.643 + }
10.644 + }
10.645 + } else {
10.646 + for ( ; i < length; ) {
10.647 + if ( callback.apply( object[ i++ ], args ) === false ) {
10.648 + break;
10.649 + }
10.650 + }
10.651 + }
10.652 +
10.653 + // A special, fast, case for the most common use of each
10.654 + } else {
10.655 + if ( isObj ) {
10.656 + for ( name in object ) {
10.657 + if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
10.658 + break;
10.659 + }
10.660 + }
10.661 + } else {
10.662 + for ( ; i < length; ) {
10.663 + if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
10.664 + break;
10.665 + }
10.666 + }
10.667 + }
10.668 + }
10.669 +
10.670 + return object;
10.671 + },
10.672 +
10.673 + // Use native String.trim function wherever possible
10.674 + trim: trim ?
10.675 + function( text ) {
10.676 + return text == null ?
10.677 + "" :
10.678 + trim.call( text );
10.679 + } :
10.680 +
10.681 + // Otherwise use our own trimming functionality
10.682 + function( text ) {
10.683 + return text == null ?
10.684 + "" :
10.685 + text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
10.686 + },
10.687 +
10.688 + // results is for internal usage only
10.689 + makeArray: function( array, results ) {
10.690 + var ret = results || [];
10.691 +
10.692 + if ( array != null ) {
10.693 + // The window, strings (and functions) also have 'length'
10.694 + // The extra typeof function check is to prevent crashes
10.695 + // in Safari 2 (See: #3039)
10.696 + // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
10.697 + var type = jQuery.type( array );
10.698 +
10.699 + if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
10.700 + push.call( ret, array );
10.701 + } else {
10.702 + jQuery.merge( ret, array );
10.703 + }
10.704 + }
10.705 +
10.706 + return ret;
10.707 + },
10.708 +
10.709 + inArray: function( elem, array ) {
10.710 + if ( !array ) {
10.711 + return -1;
10.712 + }
10.713 +
10.714 + if ( indexOf ) {
10.715 + return indexOf.call( array, elem );
10.716 + }
10.717 +
10.718 + for ( var i = 0, length = array.length; i < length; i++ ) {
10.719 + if ( array[ i ] === elem ) {
10.720 + return i;
10.721 + }
10.722 + }
10.723 +
10.724 + return -1;
10.725 + },
10.726 +
10.727 + merge: function( first, second ) {
10.728 + var i = first.length,
10.729 + j = 0;
10.730 +
10.731 + if ( typeof second.length === "number" ) {
10.732 + for ( var l = second.length; j < l; j++ ) {
10.733 + first[ i++ ] = second[ j ];
10.734 + }
10.735 +
10.736 + } else {
10.737 + while ( second[j] !== undefined ) {
10.738 + first[ i++ ] = second[ j++ ];
10.739 + }
10.740 + }
10.741 +
10.742 + first.length = i;
10.743 +
10.744 + return first;
10.745 + },
10.746 +
10.747 + grep: function( elems, callback, inv ) {
10.748 + var ret = [], retVal;
10.749 + inv = !!inv;
10.750 +
10.751 + // Go through the array, only saving the items
10.752 + // that pass the validator function
10.753 + for ( var i = 0, length = elems.length; i < length; i++ ) {
10.754 + retVal = !!callback( elems[ i ], i );
10.755 + if ( inv !== retVal ) {
10.756 + ret.push( elems[ i ] );
10.757 + }
10.758 + }
10.759 +
10.760 + return ret;
10.761 + },
10.762 +
10.763 + // arg is for internal usage only
10.764 + map: function( elems, callback, arg ) {
10.765 + var value, key, ret = [],
10.766 + i = 0,
10.767 + length = elems.length,
10.768 + // jquery objects are treated as arrays
10.769 + isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
10.770 +
10.771 + // Go through the array, translating each of the items to their
10.772 + if ( isArray ) {
10.773 + for ( ; i < length; i++ ) {
10.774 + value = callback( elems[ i ], i, arg );
10.775 +
10.776 + if ( value != null ) {
10.777 + ret[ ret.length ] = value;
10.778 + }
10.779 + }
10.780 +
10.781 + // Go through every key on the object,
10.782 + } else {
10.783 + for ( key in elems ) {
10.784 + value = callback( elems[ key ], key, arg );
10.785 +
10.786 + if ( value != null ) {
10.787 + ret[ ret.length ] = value;
10.788 + }
10.789 + }
10.790 + }
10.791 +
10.792 + // Flatten any nested arrays
10.793 + return ret.concat.apply( [], ret );
10.794 + },
10.795 +
10.796 + // A global GUID counter for objects
10.797 + guid: 1,
10.798 +
10.799 + // Bind a function to a context, optionally partially applying any
10.800 + // arguments.
10.801 + proxy: function( fn, context ) {
10.802 + if ( typeof context === "string" ) {
10.803 + var tmp = fn[ context ];
10.804 + context = fn;
10.805 + fn = tmp;
10.806 + }
10.807 +
10.808 + // Quick check to determine if target is callable, in the spec
10.809 + // this throws a TypeError, but we will just return undefined.
10.810 + if ( !jQuery.isFunction( fn ) ) {
10.811 + return undefined;
10.812 + }
10.813 +
10.814 + // Simulated bind
10.815 + var args = slice.call( arguments, 2 ),
10.816 + proxy = function() {
10.817 + return fn.apply( context, args.concat( slice.call( arguments ) ) );
10.818 + };
10.819 +
10.820 + // Set the guid of unique handler to the same of original handler, so it can be removed
10.821 + proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
10.822 +
10.823 + return proxy;
10.824 + },
10.825 +
10.826 + // Mutifunctional method to get and set values to a collection
10.827 + // The value/s can optionally be executed if it's a function
10.828 + access: function( elems, key, value, exec, fn, pass ) {
10.829 + var length = elems.length;
10.830 +
10.831 + // Setting many attributes
10.832 + if ( typeof key === "object" ) {
10.833 + for ( var k in key ) {
10.834 + jQuery.access( elems, k, key[k], exec, fn, value );
10.835 + }
10.836 + return elems;
10.837 + }
10.838 +
10.839 + // Setting one attribute
10.840 + if ( value !== undefined ) {
10.841 + // Optionally, function values get executed if exec is true
10.842 + exec = !pass && exec && jQuery.isFunction(value);
10.843 +
10.844 + for ( var i = 0; i < length; i++ ) {
10.845 + fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
10.846 + }
10.847 +
10.848 + return elems;
10.849 + }
10.850 +
10.851 + // Getting an attribute
10.852 + return length ? fn( elems[0], key ) : undefined;
10.853 + },
10.854 +
10.855 + now: function() {
10.856 + return (new Date()).getTime();
10.857 + },
10.858 +
10.859 + // Use of jQuery.browser is frowned upon.
10.860 + // More details: http://docs.jquery.com/Utilities/jQuery.browser
10.861 + uaMatch: function( ua ) {
10.862 + ua = ua.toLowerCase();
10.863 +
10.864 + var match = rwebkit.exec( ua ) ||
10.865 + ropera.exec( ua ) ||
10.866 + rmsie.exec( ua ) ||
10.867 + ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
10.868 + [];
10.869 +
10.870 + return { browser: match[1] || "", version: match[2] || "0" };
10.871 + },
10.872 +
10.873 + sub: function() {
10.874 + function jQuerySub( selector, context ) {
10.875 + return new jQuerySub.fn.init( selector, context );
10.876 + }
10.877 + jQuery.extend( true, jQuerySub, this );
10.878 + jQuerySub.superclass = this;
10.879 + jQuerySub.fn = jQuerySub.prototype = this();
10.880 + jQuerySub.fn.constructor = jQuerySub;
10.881 + jQuerySub.sub = this.sub;
10.882 + jQuerySub.fn.init = function init( selector, context ) {
10.883 + if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
10.884 + context = jQuerySub( context );
10.885 + }
10.886 +
10.887 + return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
10.888 + };
10.889 + jQuerySub.fn.init.prototype = jQuerySub.fn;
10.890 + var rootjQuerySub = jQuerySub(document);
10.891 + return jQuerySub;
10.892 + },
10.893 +
10.894 + browser: {}
10.895 +});
10.896 +
10.897 +// Populate the class2type map
10.898 +jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
10.899 + class2type[ "[object " + name + "]" ] = name.toLowerCase();
10.900 +});
10.901 +
10.902 +browserMatch = jQuery.uaMatch( userAgent );
10.903 +if ( browserMatch.browser ) {
10.904 + jQuery.browser[ browserMatch.browser ] = true;
10.905 + jQuery.browser.version = browserMatch.version;
10.906 +}
10.907 +
10.908 +// Deprecated, use jQuery.browser.webkit instead
10.909 +if ( jQuery.browser.webkit ) {
10.910 + jQuery.browser.safari = true;
10.911 +}
10.912 +
10.913 +// IE doesn't match non-breaking spaces with \s
10.914 +if ( rnotwhite.test( "\xA0" ) ) {
10.915 + trimLeft = /^[\s\xA0]+/;
10.916 + trimRight = /[\s\xA0]+$/;
10.917 +}
10.918 +
10.919 +// All jQuery objects should point back to these
10.920 +rootjQuery = jQuery(document);
10.921 +
10.922 +// Cleanup functions for the document ready method
10.923 +if ( document.addEventListener ) {
10.924 + DOMContentLoaded = function() {
10.925 + document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
10.926 + jQuery.ready();
10.927 + };
10.928 +
10.929 +} else if ( document.attachEvent ) {
10.930 + DOMContentLoaded = function() {
10.931 + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
10.932 + if ( document.readyState === "complete" ) {
10.933 + document.detachEvent( "onreadystatechange", DOMContentLoaded );
10.934 + jQuery.ready();
10.935 + }
10.936 + };
10.937 +}
10.938 +
10.939 +// The DOM ready check for Internet Explorer
10.940 +function doScrollCheck() {
10.941 + if ( jQuery.isReady ) {
10.942 + return;
10.943 + }
10.944 +
10.945 + try {
10.946 + // If IE is used, use the trick by Diego Perini
10.947 + // http://javascript.nwbox.com/IEContentLoaded/
10.948 + document.documentElement.doScroll("left");
10.949 + } catch(e) {
10.950 + setTimeout( doScrollCheck, 1 );
10.951 + return;
10.952 + }
10.953 +
10.954 + // and execute any waiting functions
10.955 + jQuery.ready();
10.956 +}
10.957 +
10.958 +return jQuery;
10.959 +
10.960 +})();
10.961 +
10.962 +
10.963 +var // Promise methods
10.964 + promiseMethods = "done fail isResolved isRejected promise then always pipe".split( " " ),
10.965 + // Static reference to slice
10.966 + sliceDeferred = [].slice;
10.967 +
10.968 +jQuery.extend({
10.969 + // Create a simple deferred (one callbacks list)
10.970 + _Deferred: function() {
10.971 + var // callbacks list
10.972 + callbacks = [],
10.973 + // stored [ context , args ]
10.974 + fired,
10.975 + // to avoid firing when already doing so
10.976 + firing,
10.977 + // flag to know if the deferred has been cancelled
10.978 + cancelled,
10.979 + // the deferred itself
10.980 + deferred = {
10.981 +
10.982 + // done( f1, f2, ...)
10.983 + done: function() {
10.984 + if ( !cancelled ) {
10.985 + var args = arguments,
10.986 + i,
10.987 + length,
10.988 + elem,
10.989 + type,
10.990 + _fired;
10.991 + if ( fired ) {
10.992 + _fired = fired;
10.993 + fired = 0;
10.994 + }
10.995 + for ( i = 0, length = args.length; i < length; i++ ) {
10.996 + elem = args[ i ];
10.997 + type = jQuery.type( elem );
10.998 + if ( type === "array" ) {
10.999 + deferred.done.apply( deferred, elem );
10.1000 + } else if ( type === "function" ) {
10.1001 + callbacks.push( elem );
10.1002 + }
10.1003 + }
10.1004 + if ( _fired ) {
10.1005 + deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
10.1006 + }
10.1007 + }
10.1008 + return this;
10.1009 + },
10.1010 +
10.1011 + // resolve with given context and args
10.1012 + resolveWith: function( context, args ) {
10.1013 + if ( !cancelled && !fired && !firing ) {
10.1014 + // make sure args are available (#8421)
10.1015 + args = args || [];
10.1016 + firing = 1;
10.1017 + try {
10.1018 + while( callbacks[ 0 ] ) {
10.1019 + callbacks.shift().apply( context, args );
10.1020 + }
10.1021 + }
10.1022 + finally {
10.1023 + fired = [ context, args ];
10.1024 + firing = 0;
10.1025 + }
10.1026 + }
10.1027 + return this;
10.1028 + },
10.1029 +
10.1030 + // resolve with this as context and given arguments
10.1031 + resolve: function() {
10.1032 + deferred.resolveWith( this, arguments );
10.1033 + return this;
10.1034 + },
10.1035 +
10.1036 + // Has this deferred been resolved?
10.1037 + isResolved: function() {
10.1038 + return !!( firing || fired );
10.1039 + },
10.1040 +
10.1041 + // Cancel
10.1042 + cancel: function() {
10.1043 + cancelled = 1;
10.1044 + callbacks = [];
10.1045 + return this;
10.1046 + }
10.1047 + };
10.1048 +
10.1049 + return deferred;
10.1050 + },
10.1051 +
10.1052 + // Full fledged deferred (two callbacks list)
10.1053 + Deferred: function( func ) {
10.1054 + var deferred = jQuery._Deferred(),
10.1055 + failDeferred = jQuery._Deferred(),
10.1056 + promise;
10.1057 + // Add errorDeferred methods, then and promise
10.1058 + jQuery.extend( deferred, {
10.1059 + then: function( doneCallbacks, failCallbacks ) {
10.1060 + deferred.done( doneCallbacks ).fail( failCallbacks );
10.1061 + return this;
10.1062 + },
10.1063 + always: function() {
10.1064 + return deferred.done.apply( deferred, arguments ).fail.apply( this, arguments );
10.1065 + },
10.1066 + fail: failDeferred.done,
10.1067 + rejectWith: failDeferred.resolveWith,
10.1068 + reject: failDeferred.resolve,
10.1069 + isRejected: failDeferred.isResolved,
10.1070 + pipe: function( fnDone, fnFail ) {
10.1071 + return jQuery.Deferred(function( newDefer ) {
10.1072 + jQuery.each( {
10.1073 + done: [ fnDone, "resolve" ],
10.1074 + fail: [ fnFail, "reject" ]
10.1075 + }, function( handler, data ) {
10.1076 + var fn = data[ 0 ],
10.1077 + action = data[ 1 ],
10.1078 + returned;
10.1079 + if ( jQuery.isFunction( fn ) ) {
10.1080 + deferred[ handler ](function() {
10.1081 + returned = fn.apply( this, arguments );
10.1082 + if ( returned && jQuery.isFunction( returned.promise ) ) {
10.1083 + returned.promise().then( newDefer.resolve, newDefer.reject );
10.1084 + } else {
10.1085 + newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
10.1086 + }
10.1087 + });
10.1088 + } else {
10.1089 + deferred[ handler ]( newDefer[ action ] );
10.1090 + }
10.1091 + });
10.1092 + }).promise();
10.1093 + },
10.1094 + // Get a promise for this deferred
10.1095 + // If obj is provided, the promise aspect is added to the object
10.1096 + promise: function( obj ) {
10.1097 + if ( obj == null ) {
10.1098 + if ( promise ) {
10.1099 + return promise;
10.1100 + }
10.1101 + promise = obj = {};
10.1102 + }
10.1103 + var i = promiseMethods.length;
10.1104 + while( i-- ) {
10.1105 + obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
10.1106 + }
10.1107 + return obj;
10.1108 + }
10.1109 + });
10.1110 + // Make sure only one callback list will be used
10.1111 + deferred.done( failDeferred.cancel ).fail( deferred.cancel );
10.1112 + // Unexpose cancel
10.1113 + delete deferred.cancel;
10.1114 + // Call given func if any
10.1115 + if ( func ) {
10.1116 + func.call( deferred, deferred );
10.1117 + }
10.1118 + return deferred;
10.1119 + },
10.1120 +
10.1121 + // Deferred helper
10.1122 + when: function( firstParam ) {
10.1123 + var args = arguments,
10.1124 + i = 0,
10.1125 + length = args.length,
10.1126 + count = length,
10.1127 + deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
10.1128 + firstParam :
10.1129 + jQuery.Deferred();
10.1130 + function resolveFunc( i ) {
10.1131 + return function( value ) {
10.1132 + args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
10.1133 + if ( !( --count ) ) {
10.1134 + // Strange bug in FF4:
10.1135 + // Values changed onto the arguments object sometimes end up as undefined values
10.1136 + // outside the $.when method. Cloning the object into a fresh array solves the issue
10.1137 + deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) );
10.1138 + }
10.1139 + };
10.1140 + }
10.1141 + if ( length > 1 ) {
10.1142 + for( ; i < length; i++ ) {
10.1143 + if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) {
10.1144 + args[ i ].promise().then( resolveFunc(i), deferred.reject );
10.1145 + } else {
10.1146 + --count;
10.1147 + }
10.1148 + }
10.1149 + if ( !count ) {
10.1150 + deferred.resolveWith( deferred, args );
10.1151 + }
10.1152 + } else if ( deferred !== firstParam ) {
10.1153 + deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
10.1154 + }
10.1155 + return deferred.promise();
10.1156 + }
10.1157 +});
10.1158 +
10.1159 +
10.1160 +
10.1161 +jQuery.support = (function() {
10.1162 +
10.1163 + var div = document.createElement( "div" ),
10.1164 + documentElement = document.documentElement,
10.1165 + all,
10.1166 + a,
10.1167 + select,
10.1168 + opt,
10.1169 + input,
10.1170 + marginDiv,
10.1171 + support,
10.1172 + fragment,
10.1173 + body,
10.1174 + testElementParent,
10.1175 + testElement,
10.1176 + testElementStyle,
10.1177 + tds,
10.1178 + events,
10.1179 + eventName,
10.1180 + i,
10.1181 + isSupported;
10.1182 +
10.1183 + // Preliminary tests
10.1184 + div.setAttribute("className", "t");
10.1185 + div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
10.1186 +
10.1187 +
10.1188 + all = div.getElementsByTagName( "*" );
10.1189 + a = div.getElementsByTagName( "a" )[ 0 ];
10.1190 +
10.1191 + // Can't get basic test support
10.1192 + if ( !all || !all.length || !a ) {
10.1193 + return {};
10.1194 + }
10.1195 +
10.1196 + // First batch of supports tests
10.1197 + select = document.createElement( "select" );
10.1198 + opt = select.appendChild( document.createElement("option") );
10.1199 + input = div.getElementsByTagName( "input" )[ 0 ];
10.1200 +
10.1201 + support = {
10.1202 + // IE strips leading whitespace when .innerHTML is used
10.1203 + leadingWhitespace: ( div.firstChild.nodeType === 3 ),
10.1204 +
10.1205 + // Make sure that tbody elements aren't automatically inserted
10.1206 + // IE will insert them into empty tables
10.1207 + tbody: !div.getElementsByTagName( "tbody" ).length,
10.1208 +
10.1209 + // Make sure that link elements get serialized correctly by innerHTML
10.1210 + // This requires a wrapper element in IE
10.1211 + htmlSerialize: !!div.getElementsByTagName( "link" ).length,
10.1212 +
10.1213 + // Get the style information from getAttribute
10.1214 + // (IE uses .cssText instead)
10.1215 + style: /top/.test( a.getAttribute("style") ),
10.1216 +
10.1217 + // Make sure that URLs aren't manipulated
10.1218 + // (IE normalizes it by default)
10.1219 + hrefNormalized: ( a.getAttribute( "href" ) === "/a" ),
10.1220 +
10.1221 + // Make sure that element opacity exists
10.1222 + // (IE uses filter instead)
10.1223 + // Use a regex to work around a WebKit issue. See #5145
10.1224 + opacity: /^0.55$/.test( a.style.opacity ),
10.1225 +
10.1226 + // Verify style float existence
10.1227 + // (IE uses styleFloat instead of cssFloat)
10.1228 + cssFloat: !!a.style.cssFloat,
10.1229 +
10.1230 + // Make sure that if no value is specified for a checkbox
10.1231 + // that it defaults to "on".
10.1232 + // (WebKit defaults to "" instead)
10.1233 + checkOn: ( input.value === "on" ),
10.1234 +
10.1235 + // Make sure that a selected-by-default option has a working selected property.
10.1236 + // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
10.1237 + optSelected: opt.selected,
10.1238 +
10.1239 + // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
10.1240 + getSetAttribute: div.className !== "t",
10.1241 +
10.1242 + // Will be defined later
10.1243 + submitBubbles: true,
10.1244 + changeBubbles: true,
10.1245 + focusinBubbles: false,
10.1246 + deleteExpando: true,
10.1247 + noCloneEvent: true,
10.1248 + inlineBlockNeedsLayout: false,
10.1249 + shrinkWrapBlocks: false,
10.1250 + reliableMarginRight: true
10.1251 + };
10.1252 +
10.1253 + // Make sure checked status is properly cloned
10.1254 + input.checked = true;
10.1255 + support.noCloneChecked = input.cloneNode( true ).checked;
10.1256 +
10.1257 + // Make sure that the options inside disabled selects aren't marked as disabled
10.1258 + // (WebKit marks them as disabled)
10.1259 + select.disabled = true;
10.1260 + support.optDisabled = !opt.disabled;
10.1261 +
10.1262 + // Test to see if it's possible to delete an expando from an element
10.1263 + // Fails in Internet Explorer
10.1264 + try {
10.1265 + delete div.test;
10.1266 + } catch( e ) {
10.1267 + support.deleteExpando = false;
10.1268 + }
10.1269 +
10.1270 + if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
10.1271 + div.attachEvent( "onclick", function() {
10.1272 + // Cloning a node shouldn't copy over any
10.1273 + // bound event handlers (IE does this)
10.1274 + support.noCloneEvent = false;
10.1275 + });
10.1276 + div.cloneNode( true ).fireEvent( "onclick" );
10.1277 + }
10.1278 +
10.1279 + // Check if a radio maintains it's value
10.1280 + // after being appended to the DOM
10.1281 + input = document.createElement("input");
10.1282 + input.value = "t";
10.1283 + input.setAttribute("type", "radio");
10.1284 + support.radioValue = input.value === "t";
10.1285 +
10.1286 + input.setAttribute("checked", "checked");
10.1287 + div.appendChild( input );
10.1288 + fragment = document.createDocumentFragment();
10.1289 + fragment.appendChild( div.firstChild );
10.1290 +
10.1291 + // WebKit doesn't clone checked state correctly in fragments
10.1292 + support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
10.1293 +
10.1294 + div.innerHTML = "";
10.1295 +
10.1296 + // Figure out if the W3C box model works as expected
10.1297 + div.style.width = div.style.paddingLeft = "1px";
10.1298 +
10.1299 + body = document.getElementsByTagName( "body" )[ 0 ];
10.1300 + // We use our own, invisible, body unless the body is already present
10.1301 + // in which case we use a div (#9239)
10.1302 + testElement = document.createElement( body ? "div" : "body" );
10.1303 + testElementStyle = {
10.1304 + visibility: "hidden",
10.1305 + width: 0,
10.1306 + height: 0,
10.1307 + border: 0,
10.1308 + margin: 0,
10.1309 + background: "none"
10.1310 + };
10.1311 + if ( body ) {
10.1312 + jQuery.extend( testElementStyle, {
10.1313 + position: "absolute",
10.1314 + left: "-1000px",
10.1315 + top: "-1000px"
10.1316 + });
10.1317 + }
10.1318 + for ( i in testElementStyle ) {
10.1319 + testElement.style[ i ] = testElementStyle[ i ];
10.1320 + }
10.1321 + testElement.appendChild( div );
10.1322 + testElementParent = body || documentElement;
10.1323 + testElementParent.insertBefore( testElement, testElementParent.firstChild );
10.1324 +
10.1325 + // Check if a disconnected checkbox will retain its checked
10.1326 + // value of true after appended to the DOM (IE6/7)
10.1327 + support.appendChecked = input.checked;
10.1328 +
10.1329 + support.boxModel = div.offsetWidth === 2;
10.1330 +
10.1331 + if ( "zoom" in div.style ) {
10.1332 + // Check if natively block-level elements act like inline-block
10.1333 + // elements when setting their display to 'inline' and giving
10.1334 + // them layout
10.1335 + // (IE < 8 does this)
10.1336 + div.style.display = "inline";
10.1337 + div.style.zoom = 1;
10.1338 + support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 );
10.1339 +
10.1340 + // Check if elements with layout shrink-wrap their children
10.1341 + // (IE 6 does this)
10.1342 + div.style.display = "";
10.1343 + div.innerHTML = "<div style='width:4px;'></div>";
10.1344 + support.shrinkWrapBlocks = ( div.offsetWidth !== 2 );
10.1345 + }
10.1346 +
10.1347 + div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
10.1348 + tds = div.getElementsByTagName( "td" );
10.1349 +
10.1350 + // Check if table cells still have offsetWidth/Height when they are set
10.1351 + // to display:none and there are still other visible table cells in a
10.1352 + // table row; if so, offsetWidth/Height are not reliable for use when
10.1353 + // determining if an element has been hidden directly using
10.1354 + // display:none (it is still safe to use offsets if a parent element is
10.1355 + // hidden; don safety goggles and see bug #4512 for more information).
10.1356 + // (only IE 8 fails this test)
10.1357 + isSupported = ( tds[ 0 ].offsetHeight === 0 );
10.1358 +
10.1359 + tds[ 0 ].style.display = "";
10.1360 + tds[ 1 ].style.display = "none";
10.1361 +
10.1362 + // Check if empty table cells still have offsetWidth/Height
10.1363 + // (IE < 8 fail this test)
10.1364 + support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
10.1365 + div.innerHTML = "";
10.1366 +
10.1367 + // Check if div with explicit width and no margin-right incorrectly
10.1368 + // gets computed margin-right based on width of container. For more
10.1369 + // info see bug #3333
10.1370 + // Fails in WebKit before Feb 2011 nightlies
10.1371 + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
10.1372 + if ( document.defaultView && document.defaultView.getComputedStyle ) {
10.1373 + marginDiv = document.createElement( "div" );
10.1374 + marginDiv.style.width = "0";
10.1375 + marginDiv.style.marginRight = "0";
10.1376 + div.appendChild( marginDiv );
10.1377 + support.reliableMarginRight =
10.1378 + ( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
10.1379 + }
10.1380 +
10.1381 + // Remove the body element we added
10.1382 + testElement.innerHTML = "";
10.1383 + testElementParent.removeChild( testElement );
10.1384 +
10.1385 + // Technique from Juriy Zaytsev
10.1386 + // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
10.1387 + // We only care about the case where non-standard event systems
10.1388 + // are used, namely in IE. Short-circuiting here helps us to
10.1389 + // avoid an eval call (in setAttribute) which can cause CSP
10.1390 + // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
10.1391 + if ( div.attachEvent ) {
10.1392 + for( i in {
10.1393 + submit: 1,
10.1394 + change: 1,
10.1395 + focusin: 1
10.1396 + } ) {
10.1397 + eventName = "on" + i;
10.1398 + isSupported = ( eventName in div );
10.1399 + if ( !isSupported ) {
10.1400 + div.setAttribute( eventName, "return;" );
10.1401 + isSupported = ( typeof div[ eventName ] === "function" );
10.1402 + }
10.1403 + support[ i + "Bubbles" ] = isSupported;
10.1404 + }
10.1405 + }
10.1406 +
10.1407 + // Null connected elements to avoid leaks in IE
10.1408 + testElement = fragment = select = opt = body = marginDiv = div = input = null;
10.1409 +
10.1410 + return support;
10.1411 +})();
10.1412 +
10.1413 +// Keep track of boxModel
10.1414 +jQuery.boxModel = jQuery.support.boxModel;
10.1415 +
10.1416 +
10.1417 +
10.1418 +
10.1419 +var rbrace = /^(?:\{.*\}|\[.*\])$/,
10.1420 + rmultiDash = /([A-Z])/g;
10.1421 +
10.1422 +jQuery.extend({
10.1423 + cache: {},
10.1424 +
10.1425 + // Please use with caution
10.1426 + uuid: 0,
10.1427 +
10.1428 + // Unique for each copy of jQuery on the page
10.1429 + // Non-digits removed to match rinlinejQuery
10.1430 + expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
10.1431 +
10.1432 + // The following elements throw uncatchable exceptions if you
10.1433 + // attempt to add expando properties to them.
10.1434 + noData: {
10.1435 + "embed": true,
10.1436 + // Ban all objects except for Flash (which handle expandos)
10.1437 + "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
10.1438 + "applet": true
10.1439 + },
10.1440 +
10.1441 + hasData: function( elem ) {
10.1442 + elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
10.1443 +
10.1444 + return !!elem && !isEmptyDataObject( elem );
10.1445 + },
10.1446 +
10.1447 + data: function( elem, name, data, pvt /* Internal Use Only */ ) {
10.1448 + if ( !jQuery.acceptData( elem ) ) {
10.1449 + return;
10.1450 + }
10.1451 +
10.1452 + var thisCache, ret,
10.1453 + internalKey = jQuery.expando,
10.1454 + getByName = typeof name === "string",
10.1455 +
10.1456 + // We have to handle DOM nodes and JS objects differently because IE6-7
10.1457 + // can't GC object references properly across the DOM-JS boundary
10.1458 + isNode = elem.nodeType,
10.1459 +
10.1460 + // Only DOM nodes need the global jQuery cache; JS object data is
10.1461 + // attached directly to the object so GC can occur automatically
10.1462 + cache = isNode ? jQuery.cache : elem,
10.1463 +
10.1464 + // Only defining an ID for JS objects if its cache already exists allows
10.1465 + // the code to shortcut on the same path as a DOM node with no cache
10.1466 + id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
10.1467 +
10.1468 + // Avoid doing any more work than we need to when trying to get data on an
10.1469 + // object that has no data at all
10.1470 + if ( (!id || (pvt && id && (cache[ id ] && !cache[ id ][ internalKey ]))) && getByName && data === undefined ) {
10.1471 + return;
10.1472 + }
10.1473 +
10.1474 + if ( !id ) {
10.1475 + // Only DOM nodes need a new unique ID for each element since their data
10.1476 + // ends up in the global cache
10.1477 + if ( isNode ) {
10.1478 + elem[ jQuery.expando ] = id = ++jQuery.uuid;
10.1479 + } else {
10.1480 + id = jQuery.expando;
10.1481 + }
10.1482 + }
10.1483 +
10.1484 + if ( !cache[ id ] ) {
10.1485 + cache[ id ] = {};
10.1486 +
10.1487 + // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
10.1488 + // metadata on plain JS objects when the object is serialized using
10.1489 + // JSON.stringify
10.1490 + if ( !isNode ) {
10.1491 + cache[ id ].toJSON = jQuery.noop;
10.1492 + }
10.1493 + }
10.1494 +
10.1495 + // An object can be passed to jQuery.data instead of a key/value pair; this gets
10.1496 + // shallow copied over onto the existing cache
10.1497 + if ( typeof name === "object" || typeof name === "function" ) {
10.1498 + if ( pvt ) {
10.1499 + cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
10.1500 + } else {
10.1501 + cache[ id ] = jQuery.extend(cache[ id ], name);
10.1502 + }
10.1503 + }
10.1504 +
10.1505 + thisCache = cache[ id ];
10.1506 +
10.1507 + // Internal jQuery data is stored in a separate object inside the object's data
10.1508 + // cache in order to avoid key collisions between internal data and user-defined
10.1509 + // data
10.1510 + if ( pvt ) {
10.1511 + if ( !thisCache[ internalKey ] ) {
10.1512 + thisCache[ internalKey ] = {};
10.1513 + }
10.1514 +
10.1515 + thisCache = thisCache[ internalKey ];
10.1516 + }
10.1517 +
10.1518 + if ( data !== undefined ) {
10.1519 + thisCache[ jQuery.camelCase( name ) ] = data;
10.1520 + }
10.1521 +
10.1522 + // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
10.1523 + // not attempt to inspect the internal events object using jQuery.data, as this
10.1524 + // internal data object is undocumented and subject to change.
10.1525 + if ( name === "events" && !thisCache[name] ) {
10.1526 + return thisCache[ internalKey ] && thisCache[ internalKey ].events;
10.1527 + }
10.1528 +
10.1529 + // Check for both converted-to-camel and non-converted data property names
10.1530 + // If a data property was specified
10.1531 + if ( getByName ) {
10.1532 +
10.1533 + // First Try to find as-is property data
10.1534 + ret = thisCache[ name ];
10.1535 +
10.1536 + // Test for null|undefined property data
10.1537 + if ( ret == null ) {
10.1538 +
10.1539 + // Try to find the camelCased property
10.1540 + ret = thisCache[ jQuery.camelCase( name ) ];
10.1541 + }
10.1542 + } else {
10.1543 + ret = thisCache;
10.1544 + }
10.1545 +
10.1546 + return ret;
10.1547 + },
10.1548 +
10.1549 + removeData: function( elem, name, pvt /* Internal Use Only */ ) {
10.1550 + if ( !jQuery.acceptData( elem ) ) {
10.1551 + return;
10.1552 + }
10.1553 +
10.1554 + var thisCache,
10.1555 +
10.1556 + // Reference to internal data cache key
10.1557 + internalKey = jQuery.expando,
10.1558 +
10.1559 + isNode = elem.nodeType,
10.1560 +
10.1561 + // See jQuery.data for more information
10.1562 + cache = isNode ? jQuery.cache : elem,
10.1563 +
10.1564 + // See jQuery.data for more information
10.1565 + id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
10.1566 +
10.1567 + // If there is already no cache entry for this object, there is no
10.1568 + // purpose in continuing
10.1569 + if ( !cache[ id ] ) {
10.1570 + return;
10.1571 + }
10.1572 +
10.1573 + if ( name ) {
10.1574 +
10.1575 + thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ];
10.1576 +
10.1577 + if ( thisCache ) {
10.1578 +
10.1579 + // Support interoperable removal of hyphenated or camelcased keys
10.1580 + if ( !thisCache[ name ] ) {
10.1581 + name = jQuery.camelCase( name );
10.1582 + }
10.1583 +
10.1584 + delete thisCache[ name ];
10.1585 +
10.1586 + // If there is no data left in the cache, we want to continue
10.1587 + // and let the cache object itself get destroyed
10.1588 + if ( !isEmptyDataObject(thisCache) ) {
10.1589 + return;
10.1590 + }
10.1591 + }
10.1592 + }
10.1593 +
10.1594 + // See jQuery.data for more information
10.1595 + if ( pvt ) {
10.1596 + delete cache[ id ][ internalKey ];
10.1597 +
10.1598 + // Don't destroy the parent cache unless the internal data object
10.1599 + // had been the only thing left in it
10.1600 + if ( !isEmptyDataObject(cache[ id ]) ) {
10.1601 + return;
10.1602 + }
10.1603 + }
10.1604 +
10.1605 + var internalCache = cache[ id ][ internalKey ];
10.1606 +
10.1607 + // Browsers that fail expando deletion also refuse to delete expandos on
10.1608 + // the window, but it will allow it on all other JS objects; other browsers
10.1609 + // don't care
10.1610 + // Ensure that `cache` is not a window object #10080
10.1611 + if ( jQuery.support.deleteExpando || !cache.setInterval ) {
10.1612 + delete cache[ id ];
10.1613 + } else {
10.1614 + cache[ id ] = null;
10.1615 + }
10.1616 +
10.1617 + // We destroyed the entire user cache at once because it's faster than
10.1618 + // iterating through each key, but we need to continue to persist internal
10.1619 + // data if it existed
10.1620 + if ( internalCache ) {
10.1621 + cache[ id ] = {};
10.1622 + // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
10.1623 + // metadata on plain JS objects when the object is serialized using
10.1624 + // JSON.stringify
10.1625 + if ( !isNode ) {
10.1626 + cache[ id ].toJSON = jQuery.noop;
10.1627 + }
10.1628 +
10.1629 + cache[ id ][ internalKey ] = internalCache;
10.1630 +
10.1631 + // Otherwise, we need to eliminate the expando on the node to avoid
10.1632 + // false lookups in the cache for entries that no longer exist
10.1633 + } else if ( isNode ) {
10.1634 + // IE does not allow us to delete expando properties from nodes,
10.1635 + // nor does it have a removeAttribute function on Document nodes;
10.1636 + // we must handle all of these cases
10.1637 + if ( jQuery.support.deleteExpando ) {
10.1638 + delete elem[ jQuery.expando ];
10.1639 + } else if ( elem.removeAttribute ) {
10.1640 + elem.removeAttribute( jQuery.expando );
10.1641 + } else {
10.1642 + elem[ jQuery.expando ] = null;
10.1643 + }
10.1644 + }
10.1645 + },
10.1646 +
10.1647 + // For internal use only.
10.1648 + _data: function( elem, name, data ) {
10.1649 + return jQuery.data( elem, name, data, true );
10.1650 + },
10.1651 +
10.1652 + // A method for determining if a DOM node can handle the data expando
10.1653 + acceptData: function( elem ) {
10.1654 + if ( elem.nodeName ) {
10.1655 + var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
10.1656 +
10.1657 + if ( match ) {
10.1658 + return !(match === true || elem.getAttribute("classid") !== match);
10.1659 + }
10.1660 + }
10.1661 +
10.1662 + return true;
10.1663 + }
10.1664 +});
10.1665 +
10.1666 +jQuery.fn.extend({
10.1667 + data: function( key, value ) {
10.1668 + var data = null;
10.1669 +
10.1670 + if ( typeof key === "undefined" ) {
10.1671 + if ( this.length ) {
10.1672 + data = jQuery.data( this[0] );
10.1673 +
10.1674 + if ( this[0].nodeType === 1 ) {
10.1675 + var attr = this[0].attributes, name;
10.1676 + for ( var i = 0, l = attr.length; i < l; i++ ) {
10.1677 + name = attr[i].name;
10.1678 +
10.1679 + if ( name.indexOf( "data-" ) === 0 ) {
10.1680 + name = jQuery.camelCase( name.substring(5) );
10.1681 +
10.1682 + dataAttr( this[0], name, data[ name ] );
10.1683 + }
10.1684 + }
10.1685 + }
10.1686 + }
10.1687 +
10.1688 + return data;
10.1689 +
10.1690 + } else if ( typeof key === "object" ) {
10.1691 + return this.each(function() {
10.1692 + jQuery.data( this, key );
10.1693 + });
10.1694 + }
10.1695 +
10.1696 + var parts = key.split(".");
10.1697 + parts[1] = parts[1] ? "." + parts[1] : "";
10.1698 +
10.1699 + if ( value === undefined ) {
10.1700 + data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
10.1701 +
10.1702 + // Try to fetch any internally stored data first
10.1703 + if ( data === undefined && this.length ) {
10.1704 + data = jQuery.data( this[0], key );
10.1705 + data = dataAttr( this[0], key, data );
10.1706 + }
10.1707 +
10.1708 + return data === undefined && parts[1] ?
10.1709 + this.data( parts[0] ) :
10.1710 + data;
10.1711 +
10.1712 + } else {
10.1713 + return this.each(function() {
10.1714 + var $this = jQuery( this ),
10.1715 + args = [ parts[0], value ];
10.1716 +
10.1717 + $this.triggerHandler( "setData" + parts[1] + "!", args );
10.1718 + jQuery.data( this, key, value );
10.1719 + $this.triggerHandler( "changeData" + parts[1] + "!", args );
10.1720 + });
10.1721 + }
10.1722 + },
10.1723 +
10.1724 + removeData: function( key ) {
10.1725 + return this.each(function() {
10.1726 + jQuery.removeData( this, key );
10.1727 + });
10.1728 + }
10.1729 +});
10.1730 +
10.1731 +function dataAttr( elem, key, data ) {
10.1732 + // If nothing was found internally, try to fetch any
10.1733 + // data from the HTML5 data-* attribute
10.1734 + if ( data === undefined && elem.nodeType === 1 ) {
10.1735 +
10.1736 + var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
10.1737 +
10.1738 + data = elem.getAttribute( name );
10.1739 +
10.1740 + if ( typeof data === "string" ) {
10.1741 + try {
10.1742 + data = data === "true" ? true :
10.1743 + data === "false" ? false :
10.1744 + data === "null" ? null :
10.1745 + !jQuery.isNaN( data ) ? parseFloat( data ) :
10.1746 + rbrace.test( data ) ? jQuery.parseJSON( data ) :
10.1747 + data;
10.1748 + } catch( e ) {}
10.1749 +
10.1750 + // Make sure we set the data so it isn't changed later
10.1751 + jQuery.data( elem, key, data );
10.1752 +
10.1753 + } else {
10.1754 + data = undefined;
10.1755 + }
10.1756 + }
10.1757 +
10.1758 + return data;
10.1759 +}
10.1760 +
10.1761 +// TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
10.1762 +// property to be considered empty objects; this property always exists in
10.1763 +// order to make sure JSON.stringify does not expose internal metadata
10.1764 +function isEmptyDataObject( obj ) {
10.1765 + for ( var name in obj ) {
10.1766 + if ( name !== "toJSON" ) {
10.1767 + return false;
10.1768 + }
10.1769 + }
10.1770 +
10.1771 + return true;
10.1772 +}
10.1773 +
10.1774 +
10.1775 +
10.1776 +
10.1777 +function handleQueueMarkDefer( elem, type, src ) {
10.1778 + var deferDataKey = type + "defer",
10.1779 + queueDataKey = type + "queue",
10.1780 + markDataKey = type + "mark",
10.1781 + defer = jQuery.data( elem, deferDataKey, undefined, true );
10.1782 + if ( defer &&
10.1783 + ( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) &&
10.1784 + ( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) {
10.1785 + // Give room for hard-coded callbacks to fire first
10.1786 + // and eventually mark/queue something else on the element
10.1787 + setTimeout( function() {
10.1788 + if ( !jQuery.data( elem, queueDataKey, undefined, true ) &&
10.1789 + !jQuery.data( elem, markDataKey, undefined, true ) ) {
10.1790 + jQuery.removeData( elem, deferDataKey, true );
10.1791 + defer.resolve();
10.1792 + }
10.1793 + }, 0 );
10.1794 + }
10.1795 +}
10.1796 +
10.1797 +jQuery.extend({
10.1798 +
10.1799 + _mark: function( elem, type ) {
10.1800 + if ( elem ) {
10.1801 + type = (type || "fx") + "mark";
10.1802 + jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true );
10.1803 + }
10.1804 + },
10.1805 +
10.1806 + _unmark: function( force, elem, type ) {
10.1807 + if ( force !== true ) {
10.1808 + type = elem;
10.1809 + elem = force;
10.1810 + force = false;
10.1811 + }
10.1812 + if ( elem ) {
10.1813 + type = type || "fx";
10.1814 + var key = type + "mark",
10.1815 + count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 );
10.1816 + if ( count ) {
10.1817 + jQuery.data( elem, key, count, true );
10.1818 + } else {
10.1819 + jQuery.removeData( elem, key, true );
10.1820 + handleQueueMarkDefer( elem, type, "mark" );
10.1821 + }
10.1822 + }
10.1823 + },
10.1824 +
10.1825 + queue: function( elem, type, data ) {
10.1826 + if ( elem ) {
10.1827 + type = (type || "fx") + "queue";
10.1828 + var q = jQuery.data( elem, type, undefined, true );
10.1829 + // Speed up dequeue by getting out quickly if this is just a lookup
10.1830 + if ( data ) {
10.1831 + if ( !q || jQuery.isArray(data) ) {
10.1832 + q = jQuery.data( elem, type, jQuery.makeArray(data), true );
10.1833 + } else {
10.1834 + q.push( data );
10.1835 + }
10.1836 + }
10.1837 + return q || [];
10.1838 + }
10.1839 + },
10.1840 +
10.1841 + dequeue: function( elem, type ) {
10.1842 + type = type || "fx";
10.1843 +
10.1844 + var queue = jQuery.queue( elem, type ),
10.1845 + fn = queue.shift(),
10.1846 + defer;
10.1847 +
10.1848 + // If the fx queue is dequeued, always remove the progress sentinel
10.1849 + if ( fn === "inprogress" ) {
10.1850 + fn = queue.shift();
10.1851 + }
10.1852 +
10.1853 + if ( fn ) {
10.1854 + // Add a progress sentinel to prevent the fx queue from being
10.1855 + // automatically dequeued
10.1856 + if ( type === "fx" ) {
10.1857 + queue.unshift("inprogress");
10.1858 + }
10.1859 +
10.1860 + fn.call(elem, function() {
10.1861 + jQuery.dequeue(elem, type);
10.1862 + });
10.1863 + }
10.1864 +
10.1865 + if ( !queue.length ) {
10.1866 + jQuery.removeData( elem, type + "queue", true );
10.1867 + handleQueueMarkDefer( elem, type, "queue" );
10.1868 + }
10.1869 + }
10.1870 +});
10.1871 +
10.1872 +jQuery.fn.extend({
10.1873 + queue: function( type, data ) {
10.1874 + if ( typeof type !== "string" ) {
10.1875 + data = type;
10.1876 + type = "fx";
10.1877 + }
10.1878 +
10.1879 + if ( data === undefined ) {
10.1880 + return jQuery.queue( this[0], type );
10.1881 + }
10.1882 + return this.each(function() {
10.1883 + var queue = jQuery.queue( this, type, data );
10.1884 +
10.1885 + if ( type === "fx" && queue[0] !== "inprogress" ) {
10.1886 + jQuery.dequeue( this, type );
10.1887 + }
10.1888 + });
10.1889 + },
10.1890 + dequeue: function( type ) {
10.1891 + return this.each(function() {
10.1892 + jQuery.dequeue( this, type );
10.1893 + });
10.1894 + },
10.1895 + // Based off of the plugin by Clint Helfers, with permission.
10.1896 + // http://blindsignals.com/index.php/2009/07/jquery-delay/
10.1897 + delay: function( time, type ) {
10.1898 + time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
10.1899 + type = type || "fx";
10.1900 +
10.1901 + return this.queue( type, function() {
10.1902 + var elem = this;
10.1903 + setTimeout(function() {
10.1904 + jQuery.dequeue( elem, type );
10.1905 + }, time );
10.1906 + });
10.1907 + },
10.1908 + clearQueue: function( type ) {
10.1909 + return this.queue( type || "fx", [] );
10.1910 + },
10.1911 + // Get a promise resolved when queues of a certain type
10.1912 + // are emptied (fx is the type by default)
10.1913 + promise: function( type, object ) {
10.1914 + if ( typeof type !== "string" ) {
10.1915 + object = type;
10.1916 + type = undefined;
10.1917 + }
10.1918 + type = type || "fx";
10.1919 + var defer = jQuery.Deferred(),
10.1920 + elements = this,
10.1921 + i = elements.length,
10.1922 + count = 1,
10.1923 + deferDataKey = type + "defer",
10.1924 + queueDataKey = type + "queue",
10.1925 + markDataKey = type + "mark",
10.1926 + tmp;
10.1927 + function resolve() {
10.1928 + if ( !( --count ) ) {
10.1929 + defer.resolveWith( elements, [ elements ] );
10.1930 + }
10.1931 + }
10.1932 + while( i-- ) {
10.1933 + if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
10.1934 + ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
10.1935 + jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
10.1936 + jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) {
10.1937 + count++;
10.1938 + tmp.done( resolve );
10.1939 + }
10.1940 + }
10.1941 + resolve();
10.1942 + return defer.promise();
10.1943 + }
10.1944 +});
10.1945 +
10.1946 +
10.1947 +
10.1948 +
10.1949 +var rclass = /[\n\t\r]/g,
10.1950 + rspace = /\s+/,
10.1951 + rreturn = /\r/g,
10.1952 + rtype = /^(?:button|input)$/i,
10.1953 + rfocusable = /^(?:button|input|object|select|textarea)$/i,
10.1954 + rclickable = /^a(?:rea)?$/i,
10.1955 + rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
10.1956 + nodeHook, boolHook;
10.1957 +
10.1958 +jQuery.fn.extend({
10.1959 + attr: function( name, value ) {
10.1960 + return jQuery.access( this, name, value, true, jQuery.attr );
10.1961 + },
10.1962 +
10.1963 + removeAttr: function( name ) {
10.1964 + return this.each(function() {
10.1965 + jQuery.removeAttr( this, name );
10.1966 + });
10.1967 + },
10.1968 +
10.1969 + prop: function( name, value ) {
10.1970 + return jQuery.access( this, name, value, true, jQuery.prop );
10.1971 + },
10.1972 +
10.1973 + removeProp: function( name ) {
10.1974 + name = jQuery.propFix[ name ] || name;
10.1975 + return this.each(function() {
10.1976 + // try/catch handles cases where IE balks (such as removing a property on window)
10.1977 + try {
10.1978 + this[ name ] = undefined;
10.1979 + delete this[ name ];
10.1980 + } catch( e ) {}
10.1981 + });
10.1982 + },
10.1983 +
10.1984 + addClass: function( value ) {
10.1985 + var classNames, i, l, elem,
10.1986 + setClass, c, cl;
10.1987 +
10.1988 + if ( jQuery.isFunction( value ) ) {
10.1989 + return this.each(function( j ) {
10.1990 + jQuery( this ).addClass( value.call(this, j, this.className) );
10.1991 + });
10.1992 + }
10.1993 +
10.1994 + if ( value && typeof value === "string" ) {
10.1995 + classNames = value.split( rspace );
10.1996 +
10.1997 + for ( i = 0, l = this.length; i < l; i++ ) {
10.1998 + elem = this[ i ];
10.1999 +
10.2000 + if ( elem.nodeType === 1 ) {
10.2001 + if ( !elem.className && classNames.length === 1 ) {
10.2002 + elem.className = value;
10.2003 +
10.2004 + } else {
10.2005 + setClass = " " + elem.className + " ";
10.2006 +
10.2007 + for ( c = 0, cl = classNames.length; c < cl; c++ ) {
10.2008 + if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
10.2009 + setClass += classNames[ c ] + " ";
10.2010 + }
10.2011 + }
10.2012 + elem.className = jQuery.trim( setClass );
10.2013 + }
10.2014 + }
10.2015 + }
10.2016 + }
10.2017 +
10.2018 + return this;
10.2019 + },
10.2020 +
10.2021 + removeClass: function( value ) {
10.2022 + var classNames, i, l, elem, className, c, cl;
10.2023 +
10.2024 + if ( jQuery.isFunction( value ) ) {
10.2025 + return this.each(function( j ) {
10.2026 + jQuery( this ).removeClass( value.call(this, j, this.className) );
10.2027 + });
10.2028 + }
10.2029 +
10.2030 + if ( (value && typeof value === "string") || value === undefined ) {
10.2031 + classNames = (value || "").split( rspace );
10.2032 +
10.2033 + for ( i = 0, l = this.length; i < l; i++ ) {
10.2034 + elem = this[ i ];
10.2035 +
10.2036 + if ( elem.nodeType === 1 && elem.className ) {
10.2037 + if ( value ) {
10.2038 + className = (" " + elem.className + " ").replace( rclass, " " );
10.2039 + for ( c = 0, cl = classNames.length; c < cl; c++ ) {
10.2040 + className = className.replace(" " + classNames[ c ] + " ", " ");
10.2041 + }
10.2042 + elem.className = jQuery.trim( className );
10.2043 +
10.2044 + } else {
10.2045 + elem.className = "";
10.2046 + }
10.2047 + }
10.2048 + }
10.2049 + }
10.2050 +
10.2051 + return this;
10.2052 + },
10.2053 +
10.2054 + toggleClass: function( value, stateVal ) {
10.2055 + var type = typeof value,
10.2056 + isBool = typeof stateVal === "boolean";
10.2057 +
10.2058 + if ( jQuery.isFunction( value ) ) {
10.2059 + return this.each(function( i ) {
10.2060 + jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
10.2061 + });
10.2062 + }
10.2063 +
10.2064 + return this.each(function() {
10.2065 + if ( type === "string" ) {
10.2066 + // toggle individual class names
10.2067 + var className,
10.2068 + i = 0,
10.2069 + self = jQuery( this ),
10.2070 + state = stateVal,
10.2071 + classNames = value.split( rspace );
10.2072 +
10.2073 + while ( (className = classNames[ i++ ]) ) {
10.2074 + // check each className given, space seperated list
10.2075 + state = isBool ? state : !self.hasClass( className );
10.2076 + self[ state ? "addClass" : "removeClass" ]( className );
10.2077 + }
10.2078 +
10.2079 + } else if ( type === "undefined" || type === "boolean" ) {
10.2080 + if ( this.className ) {
10.2081 + // store className if set
10.2082 + jQuery._data( this, "__className__", this.className );
10.2083 + }
10.2084 +
10.2085 + // toggle whole className
10.2086 + this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
10.2087 + }
10.2088 + });
10.2089 + },
10.2090 +
10.2091 + hasClass: function( selector ) {
10.2092 + var className = " " + selector + " ";
10.2093 + for ( var i = 0, l = this.length; i < l; i++ ) {
10.2094 + if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
10.2095 + return true;
10.2096 + }
10.2097 + }
10.2098 +
10.2099 + return false;
10.2100 + },
10.2101 +
10.2102 + val: function( value ) {
10.2103 + var hooks, ret,
10.2104 + elem = this[0];
10.2105 +
10.2106 + if ( !arguments.length ) {
10.2107 + if ( elem ) {
10.2108 + hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
10.2109 +
10.2110 + if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
10.2111 + return ret;
10.2112 + }
10.2113 +
10.2114 + ret = elem.value;
10.2115 +
10.2116 + return typeof ret === "string" ?
10.2117 + // handle most common string cases
10.2118 + ret.replace(rreturn, "") :
10.2119 + // handle cases where value is null/undef or number
10.2120 + ret == null ? "" : ret;
10.2121 + }
10.2122 +
10.2123 + return undefined;
10.2124 + }
10.2125 +
10.2126 + var isFunction = jQuery.isFunction( value );
10.2127 +
10.2128 + return this.each(function( i ) {
10.2129 + var self = jQuery(this), val;
10.2130 +
10.2131 + if ( this.nodeType !== 1 ) {
10.2132 + return;
10.2133 + }
10.2134 +
10.2135 + if ( isFunction ) {
10.2136 + val = value.call( this, i, self.val() );
10.2137 + } else {
10.2138 + val = value;
10.2139 + }
10.2140 +
10.2141 + // Treat null/undefined as ""; convert numbers to string
10.2142 + if ( val == null ) {
10.2143 + val = "";
10.2144 + } else if ( typeof val === "number" ) {
10.2145 + val += "";
10.2146 + } else if ( jQuery.isArray( val ) ) {
10.2147 + val = jQuery.map(val, function ( value ) {
10.2148 + return value == null ? "" : value + "";
10.2149 + });
10.2150 + }
10.2151 +
10.2152 + hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
10.2153 +
10.2154 + // If set returns undefined, fall back to normal setting
10.2155 + if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
10.2156 + this.value = val;
10.2157 + }
10.2158 + });
10.2159 + }
10.2160 +});
10.2161 +
10.2162 +jQuery.extend({
10.2163 + valHooks: {
10.2164 + option: {
10.2165 + get: function( elem ) {
10.2166 + // attributes.value is undefined in Blackberry 4.7 but
10.2167 + // uses .value. See #6932
10.2168 + var val = elem.attributes.value;
10.2169 + return !val || val.specified ? elem.value : elem.text;
10.2170 + }
10.2171 + },
10.2172 + select: {
10.2173 + get: function( elem ) {
10.2174 + var value,
10.2175 + index = elem.selectedIndex,
10.2176 + values = [],
10.2177 + options = elem.options,
10.2178 + one = elem.type === "select-one";
10.2179 +
10.2180 + // Nothing was selected
10.2181 + if ( index < 0 ) {
10.2182 + return null;
10.2183 + }
10.2184 +
10.2185 + // Loop through all the selected options
10.2186 + for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
10.2187 + var option = options[ i ];
10.2188 +
10.2189 + // Don't return options that are disabled or in a disabled optgroup
10.2190 + if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
10.2191 + (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
10.2192 +
10.2193 + // Get the specific value for the option
10.2194 + value = jQuery( option ).val();
10.2195 +
10.2196 + // We don't need an array for one selects
10.2197 + if ( one ) {
10.2198 + return value;
10.2199 + }
10.2200 +
10.2201 + // Multi-Selects return an array
10.2202 + values.push( value );
10.2203 + }
10.2204 + }
10.2205 +
10.2206 + // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
10.2207 + if ( one && !values.length && options.length ) {
10.2208 + return jQuery( options[ index ] ).val();
10.2209 + }
10.2210 +
10.2211 + return values;
10.2212 + },
10.2213 +
10.2214 + set: function( elem, value ) {
10.2215 + var values = jQuery.makeArray( value );
10.2216 +
10.2217 + jQuery(elem).find("option").each(function() {
10.2218 + this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
10.2219 + });
10.2220 +
10.2221 + if ( !values.length ) {
10.2222 + elem.selectedIndex = -1;
10.2223 + }
10.2224 + return values;
10.2225 + }
10.2226 + }
10.2227 + },
10.2228 +
10.2229 + attrFn: {
10.2230 + val: true,
10.2231 + css: true,
10.2232 + html: true,
10.2233 + text: true,
10.2234 + data: true,
10.2235 + width: true,
10.2236 + height: true,
10.2237 + offset: true
10.2238 + },
10.2239 +
10.2240 + attrFix: {
10.2241 + // Always normalize to ensure hook usage
10.2242 + tabindex: "tabIndex"
10.2243 + },
10.2244 +
10.2245 + attr: function( elem, name, value, pass ) {
10.2246 + var nType = elem.nodeType;
10.2247 +
10.2248 + // don't get/set attributes on text, comment and attribute nodes
10.2249 + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
10.2250 + return undefined;
10.2251 + }
10.2252 +
10.2253 + if ( pass && name in jQuery.attrFn ) {
10.2254 + return jQuery( elem )[ name ]( value );
10.2255 + }
10.2256 +
10.2257 + // Fallback to prop when attributes are not supported
10.2258 + if ( !("getAttribute" in elem) ) {
10.2259 + return jQuery.prop( elem, name, value );
10.2260 + }
10.2261 +
10.2262 + var ret, hooks,
10.2263 + notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
10.2264 +
10.2265 + // Normalize the name if needed
10.2266 + if ( notxml ) {
10.2267 + name = jQuery.attrFix[ name ] || name;
10.2268 +
10.2269 + hooks = jQuery.attrHooks[ name ];
10.2270 +
10.2271 + if ( !hooks ) {
10.2272 + // Use boolHook for boolean attributes
10.2273 + if ( rboolean.test( name ) ) {
10.2274 + hooks = boolHook;
10.2275 +
10.2276 + // Use nodeHook if available( IE6/7 )
10.2277 + } else if ( nodeHook ) {
10.2278 + hooks = nodeHook;
10.2279 + }
10.2280 + }
10.2281 + }
10.2282 +
10.2283 + if ( value !== undefined ) {
10.2284 +
10.2285 + if ( value === null ) {
10.2286 + jQuery.removeAttr( elem, name );
10.2287 + return undefined;
10.2288 +
10.2289 + } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
10.2290 + return ret;
10.2291 +
10.2292 + } else {
10.2293 + elem.setAttribute( name, "" + value );
10.2294 + return value;
10.2295 + }
10.2296 +
10.2297 + } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
10.2298 + return ret;
10.2299 +
10.2300 + } else {
10.2301 +
10.2302 + ret = elem.getAttribute( name );
10.2303 +
10.2304 + // Non-existent attributes return null, we normalize to undefined
10.2305 + return ret === null ?
10.2306 + undefined :
10.2307 + ret;
10.2308 + }
10.2309 + },
10.2310 +
10.2311 + removeAttr: function( elem, name ) {
10.2312 + var propName;
10.2313 + if ( elem.nodeType === 1 ) {
10.2314 + name = jQuery.attrFix[ name ] || name;
10.2315 +
10.2316 + jQuery.attr( elem, name, "" );
10.2317 + elem.removeAttribute( name );
10.2318 +
10.2319 + // Set corresponding property to false for boolean attributes
10.2320 + if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) {
10.2321 + elem[ propName ] = false;
10.2322 + }
10.2323 + }
10.2324 + },
10.2325 +
10.2326 + attrHooks: {
10.2327 + type: {
10.2328 + set: function( elem, value ) {
10.2329 + // We can't allow the type property to be changed (since it causes problems in IE)
10.2330 + if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
10.2331 + jQuery.error( "type property can't be changed" );
10.2332 + } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
10.2333 + // Setting the type on a radio button after the value resets the value in IE6-9
10.2334 + // Reset value to it's default in case type is set after value
10.2335 + // This is for element creation
10.2336 + var val = elem.value;
10.2337 + elem.setAttribute( "type", value );
10.2338 + if ( val ) {
10.2339 + elem.value = val;
10.2340 + }
10.2341 + return value;
10.2342 + }
10.2343 + }
10.2344 + },
10.2345 + // Use the value property for back compat
10.2346 + // Use the nodeHook for button elements in IE6/7 (#1954)
10.2347 + value: {
10.2348 + get: function( elem, name ) {
10.2349 + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
10.2350 + return nodeHook.get( elem, name );
10.2351 + }
10.2352 + return name in elem ?
10.2353 + elem.value :
10.2354 + null;
10.2355 + },
10.2356 + set: function( elem, value, name ) {
10.2357 + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
10.2358 + return nodeHook.set( elem, value, name );
10.2359 + }
10.2360 + // Does not return so that setAttribute is also used
10.2361 + elem.value = value;
10.2362 + }
10.2363 + }
10.2364 + },
10.2365 +
10.2366 + propFix: {
10.2367 + tabindex: "tabIndex",
10.2368 + readonly: "readOnly",
10.2369 + "for": "htmlFor",
10.2370 + "class": "className",
10.2371 + maxlength: "maxLength",
10.2372 + cellspacing: "cellSpacing",
10.2373 + cellpadding: "cellPadding",
10.2374 + rowspan: "rowSpan",
10.2375 + colspan: "colSpan",
10.2376 + usemap: "useMap",
10.2377 + frameborder: "frameBorder",
10.2378 + contenteditable: "contentEditable"
10.2379 + },
10.2380 +
10.2381 + prop: function( elem, name, value ) {
10.2382 + var nType = elem.nodeType;
10.2383 +
10.2384 + // don't get/set properties on text, comment and attribute nodes
10.2385 + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
10.2386 + return undefined;
10.2387 + }
10.2388 +
10.2389 + var ret, hooks,
10.2390 + notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
10.2391 +
10.2392 + if ( notxml ) {
10.2393 + // Fix name and attach hooks
10.2394 + name = jQuery.propFix[ name ] || name;
10.2395 + hooks = jQuery.propHooks[ name ];
10.2396 + }
10.2397 +
10.2398 + if ( value !== undefined ) {
10.2399 + if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
10.2400 + return ret;
10.2401 +
10.2402 + } else {
10.2403 + return (elem[ name ] = value);
10.2404 + }
10.2405 +
10.2406 + } else {
10.2407 + if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
10.2408 + return ret;
10.2409 +
10.2410 + } else {
10.2411 + return elem[ name ];
10.2412 + }
10.2413 + }
10.2414 + },
10.2415 +
10.2416 + propHooks: {
10.2417 + tabIndex: {
10.2418 + get: function( elem ) {
10.2419 + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
10.2420 + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
10.2421 + var attributeNode = elem.getAttributeNode("tabindex");
10.2422 +
10.2423 + return attributeNode && attributeNode.specified ?
10.2424 + parseInt( attributeNode.value, 10 ) :
10.2425 + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
10.2426 + 0 :
10.2427 + undefined;
10.2428 + }
10.2429 + }
10.2430 + }
10.2431 +});
10.2432 +
10.2433 +// Add the tabindex propHook to attrHooks for back-compat
10.2434 +jQuery.attrHooks.tabIndex = jQuery.propHooks.tabIndex;
10.2435 +
10.2436 +// Hook for boolean attributes
10.2437 +boolHook = {
10.2438 + get: function( elem, name ) {
10.2439 + // Align boolean attributes with corresponding properties
10.2440 + // Fall back to attribute presence where some booleans are not supported
10.2441 + var attrNode;
10.2442 + return jQuery.prop( elem, name ) === true || ( attrNode = elem.getAttributeNode( name ) ) && attrNode.nodeValue !== false ?
10.2443 + name.toLowerCase() :
10.2444 + undefined;
10.2445 + },
10.2446 + set: function( elem, value, name ) {
10.2447 + var propName;
10.2448 + if ( value === false ) {
10.2449 + // Remove boolean attributes when set to false
10.2450 + jQuery.removeAttr( elem, name );
10.2451 + } else {
10.2452 + // value is true since we know at this point it's type boolean and not false
10.2453 + // Set boolean attributes to the same name and set the DOM property
10.2454 + propName = jQuery.propFix[ name ] || name;
10.2455 + if ( propName in elem ) {
10.2456 + // Only set the IDL specifically if it already exists on the element
10.2457 + elem[ propName ] = true;
10.2458 + }
10.2459 +
10.2460 + elem.setAttribute( name, name.toLowerCase() );
10.2461 + }
10.2462 + return name;
10.2463 + }
10.2464 +};
10.2465 +
10.2466 +// IE6/7 do not support getting/setting some attributes with get/setAttribute
10.2467 +if ( !jQuery.support.getSetAttribute ) {
10.2468 +
10.2469 + // Use this for any attribute in IE6/7
10.2470 + // This fixes almost every IE6/7 issue
10.2471 + nodeHook = jQuery.valHooks.button = {
10.2472 + get: function( elem, name ) {
10.2473 + var ret;
10.2474 + ret = elem.getAttributeNode( name );
10.2475 + // Return undefined if nodeValue is empty string
10.2476 + return ret && ret.nodeValue !== "" ?
10.2477 + ret.nodeValue :
10.2478 + undefined;
10.2479 + },
10.2480 + set: function( elem, value, name ) {
10.2481 + // Set the existing or create a new attribute node
10.2482 + var ret = elem.getAttributeNode( name );
10.2483 + if ( !ret ) {
10.2484 + ret = document.createAttribute( name );
10.2485 + elem.setAttributeNode( ret );
10.2486 + }
10.2487 + return (ret.nodeValue = value + "");
10.2488 + }
10.2489 + };
10.2490 +
10.2491 + // Set width and height to auto instead of 0 on empty string( Bug #8150 )
10.2492 + // This is for removals
10.2493 + jQuery.each([ "width", "height" ], function( i, name ) {
10.2494 + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
10.2495 + set: function( elem, value ) {
10.2496 + if ( value === "" ) {
10.2497 + elem.setAttribute( name, "auto" );
10.2498 + return value;
10.2499 + }
10.2500 + }
10.2501 + });
10.2502 + });
10.2503 +}
10.2504 +
10.2505 +
10.2506 +// Some attributes require a special call on IE
10.2507 +if ( !jQuery.support.hrefNormalized ) {
10.2508 + jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
10.2509 + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
10.2510 + get: function( elem ) {
10.2511 + var ret = elem.getAttribute( name, 2 );
10.2512 + return ret === null ? undefined : ret;
10.2513 + }
10.2514 + });
10.2515 + });
10.2516 +}
10.2517 +
10.2518 +if ( !jQuery.support.style ) {
10.2519 + jQuery.attrHooks.style = {
10.2520 + get: function( elem ) {
10.2521 + // Return undefined in the case of empty string
10.2522 + // Normalize to lowercase since IE uppercases css property names
10.2523 + return elem.style.cssText.toLowerCase() || undefined;
10.2524 + },
10.2525 + set: function( elem, value ) {
10.2526 + return (elem.style.cssText = "" + value);
10.2527 + }
10.2528 + };
10.2529 +}
10.2530 +
10.2531 +// Safari mis-reports the default selected property of an option
10.2532 +// Accessing the parent's selectedIndex property fixes it
10.2533 +if ( !jQuery.support.optSelected ) {
10.2534 + jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
10.2535 + get: function( elem ) {
10.2536 + var parent = elem.parentNode;
10.2537 +
10.2538 + if ( parent ) {
10.2539 + parent.selectedIndex;
10.2540 +
10.2541 + // Make sure that it also works with optgroups, see #5701
10.2542 + if ( parent.parentNode ) {
10.2543 + parent.parentNode.selectedIndex;
10.2544 + }
10.2545 + }
10.2546 + return null;
10.2547 + }
10.2548 + });
10.2549 +}
10.2550 +
10.2551 +// Radios and checkboxes getter/setter
10.2552 +if ( !jQuery.support.checkOn ) {
10.2553 + jQuery.each([ "radio", "checkbox" ], function() {
10.2554 + jQuery.valHooks[ this ] = {
10.2555 + get: function( elem ) {
10.2556 + // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
10.2557 + return elem.getAttribute("value") === null ? "on" : elem.value;
10.2558 + }
10.2559 + };
10.2560 + });
10.2561 +}
10.2562 +jQuery.each([ "radio", "checkbox" ], function() {
10.2563 + jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
10.2564 + set: function( elem, value ) {
10.2565 + if ( jQuery.isArray( value ) ) {
10.2566 + return (elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0);
10.2567 + }
10.2568 + }
10.2569 + });
10.2570 +});
10.2571 +
10.2572 +
10.2573 +
10.2574 +
10.2575 +var rnamespaces = /\.(.*)$/,
10.2576 + rformElems = /^(?:textarea|input|select)$/i,
10.2577 + rperiod = /\./g,
10.2578 + rspaces = / /g,
10.2579 + rescape = /[^\w\s.|`]/g,
10.2580 + fcleanup = function( nm ) {
10.2581 + return nm.replace(rescape, "\\$&");
10.2582 + };
10.2583 +
10.2584 +/*
10.2585 + * A number of helper functions used for managing events.
10.2586 + * Many of the ideas behind this code originated from
10.2587 + * Dean Edwards' addEvent library.
10.2588 + */
10.2589 +jQuery.event = {
10.2590 +
10.2591 + // Bind an event to an element
10.2592 + // Original by Dean Edwards
10.2593 + add: function( elem, types, handler, data ) {
10.2594 + if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
10.2595 + return;
10.2596 + }
10.2597 +
10.2598 + if ( handler === false ) {
10.2599 + handler = returnFalse;
10.2600 + } else if ( !handler ) {
10.2601 + // Fixes bug #7229. Fix recommended by jdalton
10.2602 + return;
10.2603 + }
10.2604 +
10.2605 + var handleObjIn, handleObj;
10.2606 +
10.2607 + if ( handler.handler ) {
10.2608 + handleObjIn = handler;
10.2609 + handler = handleObjIn.handler;
10.2610 + }
10.2611 +
10.2612 + // Make sure that the function being executed has a unique ID
10.2613 + if ( !handler.guid ) {
10.2614 + handler.guid = jQuery.guid++;
10.2615 + }
10.2616 +
10.2617 + // Init the element's event structure
10.2618 + var elemData = jQuery._data( elem );
10.2619 +
10.2620 + // If no elemData is found then we must be trying to bind to one of the
10.2621 + // banned noData elements
10.2622 + if ( !elemData ) {
10.2623 + return;
10.2624 + }
10.2625 +
10.2626 + var events = elemData.events,
10.2627 + eventHandle = elemData.handle;
10.2628 +
10.2629 + if ( !events ) {
10.2630 + elemData.events = events = {};
10.2631 + }
10.2632 +
10.2633 + if ( !eventHandle ) {
10.2634 + elemData.handle = eventHandle = function( e ) {
10.2635 + // Discard the second event of a jQuery.event.trigger() and
10.2636 + // when an event is called after a page has unloaded
10.2637 + return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
10.2638 + jQuery.event.handle.apply( eventHandle.elem, arguments ) :
10.2639 + undefined;
10.2640 + };
10.2641 + }
10.2642 +
10.2643 + // Add elem as a property of the handle function
10.2644 + // This is to prevent a memory leak with non-native events in IE.
10.2645 + eventHandle.elem = elem;
10.2646 +
10.2647 + // Handle multiple events separated by a space
10.2648 + // jQuery(...).bind("mouseover mouseout", fn);
10.2649 + types = types.split(" ");
10.2650 +
10.2651 + var type, i = 0, namespaces;
10.2652 +
10.2653 + while ( (type = types[ i++ ]) ) {
10.2654 + handleObj = handleObjIn ?
10.2655 + jQuery.extend({}, handleObjIn) :
10.2656 + { handler: handler, data: data };
10.2657 +
10.2658 + // Namespaced event handlers
10.2659 + if ( type.indexOf(".") > -1 ) {
10.2660 + namespaces = type.split(".");
10.2661 + type = namespaces.shift();
10.2662 + handleObj.namespace = namespaces.slice(0).sort().join(".");
10.2663 +
10.2664 + } else {
10.2665 + namespaces = [];
10.2666 + handleObj.namespace = "";
10.2667 + }
10.2668 +
10.2669 + handleObj.type = type;
10.2670 + if ( !handleObj.guid ) {
10.2671 + handleObj.guid = handler.guid;
10.2672 + }
10.2673 +
10.2674 + // Get the current list of functions bound to this event
10.2675 + var handlers = events[ type ],
10.2676 + special = jQuery.event.special[ type ] || {};
10.2677 +
10.2678 + // Init the event handler queue
10.2679 + if ( !handlers ) {
10.2680 + handlers = events[ type ] = [];
10.2681 +
10.2682 + // Check for a special event handler
10.2683 + // Only use addEventListener/attachEvent if the special
10.2684 + // events handler returns false
10.2685 + if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
10.2686 + // Bind the global event handler to the element
10.2687 + if ( elem.addEventListener ) {
10.2688 + elem.addEventListener( type, eventHandle, false );
10.2689 +
10.2690 + } else if ( elem.attachEvent ) {
10.2691 + elem.attachEvent( "on" + type, eventHandle );
10.2692 + }
10.2693 + }
10.2694 + }
10.2695 +
10.2696 + if ( special.add ) {
10.2697 + special.add.call( elem, handleObj );
10.2698 +
10.2699 + if ( !handleObj.handler.guid ) {
10.2700 + handleObj.handler.guid = handler.guid;
10.2701 + }
10.2702 + }
10.2703 +
10.2704 + // Add the function to the element's handler list
10.2705 + handlers.push( handleObj );
10.2706 +
10.2707 + // Keep track of which events have been used, for event optimization
10.2708 + jQuery.event.global[ type ] = true;
10.2709 + }
10.2710 +
10.2711 + // Nullify elem to prevent memory leaks in IE
10.2712 + elem = null;
10.2713 + },
10.2714 +
10.2715 + global: {},
10.2716 +
10.2717 + // Detach an event or set of events from an element
10.2718 + remove: function( elem, types, handler, pos ) {
10.2719 + // don't do events on text and comment nodes
10.2720 + if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
10.2721 + return;
10.2722 + }
10.2723 +
10.2724 + if ( handler === false ) {
10.2725 + handler = returnFalse;
10.2726 + }
10.2727 +
10.2728 + var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
10.2729 + elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
10.2730 + events = elemData && elemData.events;
10.2731 +
10.2732 + if ( !elemData || !events ) {
10.2733 + return;
10.2734 + }
10.2735 +
10.2736 + // types is actually an event object here
10.2737 + if ( types && types.type ) {
10.2738 + handler = types.handler;
10.2739 + types = types.type;
10.2740 + }
10.2741 +
10.2742 + // Unbind all events for the element
10.2743 + if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
10.2744 + types = types || "";
10.2745 +
10.2746 + for ( type in events ) {
10.2747 + jQuery.event.remove( elem, type + types );
10.2748 + }
10.2749 +
10.2750 + return;
10.2751 + }
10.2752 +
10.2753 + // Handle multiple events separated by a space
10.2754 + // jQuery(...).unbind("mouseover mouseout", fn);
10.2755 + types = types.split(" ");
10.2756 +
10.2757 + while ( (type = types[ i++ ]) ) {
10.2758 + origType = type;
10.2759 + handleObj = null;
10.2760 + all = type.indexOf(".") < 0;
10.2761 + namespaces = [];
10.2762 +
10.2763 + if ( !all ) {
10.2764 + // Namespaced event handlers
10.2765 + namespaces = type.split(".");
10.2766 + type = namespaces.shift();
10.2767 +
10.2768 + namespace = new RegExp("(^|\\.)" +
10.2769 + jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
10.2770 + }
10.2771 +
10.2772 + eventType = events[ type ];
10.2773 +
10.2774 + if ( !eventType ) {
10.2775 + continue;
10.2776 + }
10.2777 +
10.2778 + if ( !handler ) {
10.2779 + for ( j = 0; j < eventType.length; j++ ) {
10.2780 + handleObj = eventType[ j ];
10.2781 +
10.2782 + if ( all || namespace.test( handleObj.namespace ) ) {
10.2783 + jQuery.event.remove( elem, origType, handleObj.handler, j );
10.2784 + eventType.splice( j--, 1 );
10.2785 + }
10.2786 + }
10.2787 +
10.2788 + continue;
10.2789 + }
10.2790 +
10.2791 + special = jQuery.event.special[ type ] || {};
10.2792 +
10.2793 + for ( j = pos || 0; j < eventType.length; j++ ) {
10.2794 + handleObj = eventType[ j ];
10.2795 +
10.2796 + if ( handler.guid === handleObj.guid ) {
10.2797 + // remove the given handler for the given type
10.2798 + if ( all || namespace.test( handleObj.namespace ) ) {
10.2799 + if ( pos == null ) {
10.2800 + eventType.splice( j--, 1 );
10.2801 + }
10.2802 +
10.2803 + if ( special.remove ) {
10.2804 + special.remove.call( elem, handleObj );
10.2805 + }
10.2806 + }
10.2807 +
10.2808 + if ( pos != null ) {
10.2809 + break;
10.2810 + }
10.2811 + }
10.2812 + }
10.2813 +
10.2814 + // remove generic event handler if no more handlers exist
10.2815 + if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
10.2816 + if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
10.2817 + jQuery.removeEvent( elem, type, elemData.handle );
10.2818 + }
10.2819 +
10.2820 + ret = null;
10.2821 + delete events[ type ];
10.2822 + }
10.2823 + }
10.2824 +
10.2825 + // Remove the expando if it's no longer used
10.2826 + if ( jQuery.isEmptyObject( events ) ) {
10.2827 + var handle = elemData.handle;
10.2828 + if ( handle ) {
10.2829 + handle.elem = null;
10.2830 + }
10.2831 +
10.2832 + delete elemData.events;
10.2833 + delete elemData.handle;
10.2834 +
10.2835 + if ( jQuery.isEmptyObject( elemData ) ) {
10.2836 + jQuery.removeData( elem, undefined, true );
10.2837 + }
10.2838 + }
10.2839 + },
10.2840 +
10.2841 + // Events that are safe to short-circuit if no handlers are attached.
10.2842 + // Native DOM events should not be added, they may have inline handlers.
10.2843 + customEvent: {
10.2844 + "getData": true,
10.2845 + "setData": true,
10.2846 + "changeData": true
10.2847 + },
10.2848 +
10.2849 + trigger: function( event, data, elem, onlyHandlers ) {
10.2850 + // Event object or event type
10.2851 + var type = event.type || event,
10.2852 + namespaces = [],
10.2853 + exclusive;
10.2854 +
10.2855 + if ( type.indexOf("!") >= 0 ) {
10.2856 + // Exclusive events trigger only for the exact event (no namespaces)
10.2857 + type = type.slice(0, -1);
10.2858 + exclusive = true;
10.2859 + }
10.2860 +
10.2861 + if ( type.indexOf(".") >= 0 ) {
10.2862 + // Namespaced trigger; create a regexp to match event type in handle()
10.2863 + namespaces = type.split(".");
10.2864 + type = namespaces.shift();
10.2865 + namespaces.sort();
10.2866 + }
10.2867 +
10.2868 + if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
10.2869 + // No jQuery handlers for this event type, and it can't have inline handlers
10.2870 + return;
10.2871 + }
10.2872 +
10.2873 + // Caller can pass in an Event, Object, or just an event type string
10.2874 + event = typeof event === "object" ?
10.2875 + // jQuery.Event object
10.2876 + event[ jQuery.expando ] ? event :
10.2877 + // Object literal
10.2878 + new jQuery.Event( type, event ) :
10.2879 + // Just the event type (string)
10.2880 + new jQuery.Event( type );
10.2881 +
10.2882 + event.type = type;
10.2883 + event.exclusive = exclusive;
10.2884 + event.namespace = namespaces.join(".");
10.2885 + event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
10.2886 +
10.2887 + // triggerHandler() and global events don't bubble or run the default action
10.2888 + if ( onlyHandlers || !elem ) {
10.2889 + event.preventDefault();
10.2890 + event.stopPropagation();
10.2891 + }
10.2892 +
10.2893 + // Handle a global trigger
10.2894 + if ( !elem ) {
10.2895 + // TODO: Stop taunting the data cache; remove global events and always attach to document
10.2896 + jQuery.each( jQuery.cache, function() {
10.2897 + // internalKey variable is just used to make it easier to find
10.2898 + // and potentially change this stuff later; currently it just
10.2899 + // points to jQuery.expando
10.2900 + var internalKey = jQuery.expando,
10.2901 + internalCache = this[ internalKey ];
10.2902 + if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
10.2903 + jQuery.event.trigger( event, data, internalCache.handle.elem );
10.2904 + }
10.2905 + });
10.2906 + return;
10.2907 + }
10.2908 +
10.2909 + // Don't do events on text and comment nodes
10.2910 + if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
10.2911 + return;
10.2912 + }
10.2913 +
10.2914 + // Clean up the event in case it is being reused
10.2915 + event.result = undefined;
10.2916 + event.target = elem;
10.2917 +
10.2918 + // Clone any incoming data and prepend the event, creating the handler arg list
10.2919 + data = data != null ? jQuery.makeArray( data ) : [];
10.2920 + data.unshift( event );
10.2921 +
10.2922 + var cur = elem,
10.2923 + // IE doesn't like method names with a colon (#3533, #8272)
10.2924 + ontype = type.indexOf(":") < 0 ? "on" + type : "";
10.2925 +
10.2926 + // Fire event on the current element, then bubble up the DOM tree
10.2927 + do {
10.2928 + var handle = jQuery._data( cur, "handle" );
10.2929 +
10.2930 + event.currentTarget = cur;
10.2931 + if ( handle ) {
10.2932 + handle.apply( cur, data );
10.2933 + }
10.2934 +
10.2935 + // Trigger an inline bound script
10.2936 + if ( ontype && jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) {
10.2937 + event.result = false;
10.2938 + event.preventDefault();
10.2939 + }
10.2940 +
10.2941 + // Bubble up to document, then to window
10.2942 + cur = cur.parentNode || cur.ownerDocument || cur === event.target.ownerDocument && window;
10.2943 + } while ( cur && !event.isPropagationStopped() );
10.2944 +
10.2945 + // If nobody prevented the default action, do it now
10.2946 + if ( !event.isDefaultPrevented() ) {
10.2947 + var old,
10.2948 + special = jQuery.event.special[ type ] || {};
10.2949 +
10.2950 + if ( (!special._default || special._default.call( elem.ownerDocument, event ) === false) &&
10.2951 + !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
10.2952 +
10.2953 + // Call a native DOM method on the target with the same name name as the event.
10.2954 + // Can't use an .isFunction)() check here because IE6/7 fails that test.
10.2955 + // IE<9 dies on focus to hidden element (#1486), may want to revisit a try/catch.
10.2956 + try {
10.2957 + if ( ontype && elem[ type ] ) {
10.2958 + // Don't re-trigger an onFOO event when we call its FOO() method
10.2959 + old = elem[ ontype ];
10.2960 +
10.2961 + if ( old ) {
10.2962 + elem[ ontype ] = null;
10.2963 + }
10.2964 +
10.2965 + jQuery.event.triggered = type;
10.2966 + elem[ type ]();
10.2967 + }
10.2968 + } catch ( ieError ) {}
10.2969 +
10.2970 + if ( old ) {
10.2971 + elem[ ontype ] = old;
10.2972 + }
10.2973 +
10.2974 + jQuery.event.triggered = undefined;
10.2975 + }
10.2976 + }
10.2977 +
10.2978 + return event.result;
10.2979 + },
10.2980 +
10.2981 + handle: function( event ) {
10.2982 + event = jQuery.event.fix( event || window.event );
10.2983 + // Snapshot the handlers list since a called handler may add/remove events.
10.2984 + var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []).slice(0),
10.2985 + run_all = !event.exclusive && !event.namespace,
10.2986 + args = Array.prototype.slice.call( arguments, 0 );
10.2987 +
10.2988 + // Use the fix-ed Event rather than the (read-only) native event
10.2989 + args[0] = event;
10.2990 + event.currentTarget = this;
10.2991 +
10.2992 + for ( var j = 0, l = handlers.length; j < l; j++ ) {
10.2993 + var handleObj = handlers[ j ];
10.2994 +
10.2995 + // Triggered event must 1) be non-exclusive and have no namespace, or
10.2996 + // 2) have namespace(s) a subset or equal to those in the bound event.
10.2997 + if ( run_all || event.namespace_re.test( handleObj.namespace ) ) {
10.2998 + // Pass in a reference to the handler function itself
10.2999 + // So that we can later remove it
10.3000 + event.handler = handleObj.handler;
10.3001 + event.data = handleObj.data;
10.3002 + event.handleObj = handleObj;
10.3003 +
10.3004 + var ret = handleObj.handler.apply( this, args );
10.3005 +
10.3006 + if ( ret !== undefined ) {
10.3007 + event.result = ret;
10.3008 + if ( ret === false ) {
10.3009 + event.preventDefault();
10.3010 + event.stopPropagation();
10.3011 + }
10.3012 + }
10.3013 +
10.3014 + if ( event.isImmediatePropagationStopped() ) {
10.3015 + break;
10.3016 + }
10.3017 + }
10.3018 + }
10.3019 + return event.result;
10.3020 + },
10.3021 +
10.3022 + props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
10.3023 +
10.3024 + fix: function( event ) {
10.3025 + if ( event[ jQuery.expando ] ) {
10.3026 + return event;
10.3027 + }
10.3028 +
10.3029 + // store a copy of the original event object
10.3030 + // and "clone" to set read-only properties
10.3031 + var originalEvent = event;
10.3032 + event = jQuery.Event( originalEvent );
10.3033 +
10.3034 + for ( var i = this.props.length, prop; i; ) {
10.3035 + prop = this.props[ --i ];
10.3036 + event[ prop ] = originalEvent[ prop ];
10.3037 + }
10.3038 +
10.3039 + // Fix target property, if necessary
10.3040 + if ( !event.target ) {
10.3041 + // Fixes #1925 where srcElement might not be defined either
10.3042 + event.target = event.srcElement || document;
10.3043 + }
10.3044 +
10.3045 + // check if target is a textnode (safari)
10.3046 + if ( event.target.nodeType === 3 ) {
10.3047 + event.target = event.target.parentNode;
10.3048 + }
10.3049 +
10.3050 + // Add relatedTarget, if necessary
10.3051 + if ( !event.relatedTarget && event.fromElement ) {
10.3052 + event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
10.3053 + }
10.3054 +
10.3055 + // Calculate pageX/Y if missing and clientX/Y available
10.3056 + if ( event.pageX == null && event.clientX != null ) {
10.3057 + var eventDocument = event.target.ownerDocument || document,
10.3058 + doc = eventDocument.documentElement,
10.3059 + body = eventDocument.body;
10.3060 +
10.3061 + event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
10.3062 + event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
10.3063 + }
10.3064 +
10.3065 + // Add which for key events
10.3066 + if ( event.which == null && (event.charCode != null || event.keyCode != null) ) {
10.3067 + event.which = event.charCode != null ? event.charCode : event.keyCode;
10.3068 + }
10.3069 +
10.3070 + // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
10.3071 + if ( !event.metaKey && event.ctrlKey ) {
10.3072 + event.metaKey = event.ctrlKey;
10.3073 + }
10.3074 +
10.3075 + // Add which for click: 1 === left; 2 === middle; 3 === right
10.3076 + // Note: button is not normalized, so don't use it
10.3077 + if ( !event.which && event.button !== undefined ) {
10.3078 + event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
10.3079 + }
10.3080 +
10.3081 + return event;
10.3082 + },
10.3083 +
10.3084 + // Deprecated, use jQuery.guid instead
10.3085 + guid: 1E8,
10.3086 +
10.3087 + // Deprecated, use jQuery.proxy instead
10.3088 + proxy: jQuery.proxy,
10.3089 +
10.3090 + special: {
10.3091 + ready: {
10.3092 + // Make sure the ready event is setup
10.3093 + setup: jQuery.bindReady,
10.3094 + teardown: jQuery.noop
10.3095 + },
10.3096 +
10.3097 + live: {
10.3098 + add: function( handleObj ) {
10.3099 + jQuery.event.add( this,
10.3100 + liveConvert( handleObj.origType, handleObj.selector ),
10.3101 + jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
10.3102 + },
10.3103 +
10.3104 + remove: function( handleObj ) {
10.3105 + jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj );
10.3106 + }
10.3107 + },
10.3108 +
10.3109 + beforeunload: {
10.3110 + setup: function( data, namespaces, eventHandle ) {
10.3111 + // We only want to do this special case on windows
10.3112 + if ( jQuery.isWindow( this ) ) {
10.3113 + this.onbeforeunload = eventHandle;
10.3114 + }
10.3115 + },
10.3116 +
10.3117 + teardown: function( namespaces, eventHandle ) {
10.3118 + if ( this.onbeforeunload === eventHandle ) {
10.3119 + this.onbeforeunload = null;
10.3120 + }
10.3121 + }
10.3122 + }
10.3123 + }
10.3124 +};
10.3125 +
10.3126 +jQuery.removeEvent = document.removeEventListener ?
10.3127 + function( elem, type, handle ) {
10.3128 + if ( elem.removeEventListener ) {
10.3129 + elem.removeEventListener( type, handle, false );
10.3130 + }
10.3131 + } :
10.3132 + function( elem, type, handle ) {
10.3133 + if ( elem.detachEvent ) {
10.3134 + elem.detachEvent( "on" + type, handle );
10.3135 + }
10.3136 + };
10.3137 +
10.3138 +jQuery.Event = function( src, props ) {
10.3139 + // Allow instantiation without the 'new' keyword
10.3140 + if ( !this.preventDefault ) {
10.3141 + return new jQuery.Event( src, props );
10.3142 + }
10.3143 +
10.3144 + // Event object
10.3145 + if ( src && src.type ) {
10.3146 + this.originalEvent = src;
10.3147 + this.type = src.type;
10.3148 +
10.3149 + // Events bubbling up the document may have been marked as prevented
10.3150 + // by a handler lower down the tree; reflect the correct value.
10.3151 + this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
10.3152 + src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
10.3153 +
10.3154 + // Event type
10.3155 + } else {
10.3156 + this.type = src;
10.3157 + }
10.3158 +
10.3159 + // Put explicitly provided properties onto the event object
10.3160 + if ( props ) {
10.3161 + jQuery.extend( this, props );
10.3162 + }
10.3163 +
10.3164 + // timeStamp is buggy for some events on Firefox(#3843)
10.3165 + // So we won't rely on the native value
10.3166 + this.timeStamp = jQuery.now();
10.3167 +
10.3168 + // Mark it as fixed
10.3169 + this[ jQuery.expando ] = true;
10.3170 +};
10.3171 +
10.3172 +function returnFalse() {
10.3173 + return false;
10.3174 +}
10.3175 +function returnTrue() {
10.3176 + return true;
10.3177 +}
10.3178 +
10.3179 +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
10.3180 +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
10.3181 +jQuery.Event.prototype = {
10.3182 + preventDefault: function() {
10.3183 + this.isDefaultPrevented = returnTrue;
10.3184 +
10.3185 + var e = this.originalEvent;
10.3186 + if ( !e ) {
10.3187 + return;
10.3188 + }
10.3189 +
10.3190 + // if preventDefault exists run it on the original event
10.3191 + if ( e.preventDefault ) {
10.3192 + e.preventDefault();
10.3193 +
10.3194 + // otherwise set the returnValue property of the original event to false (IE)
10.3195 + } else {
10.3196 + e.returnValue = false;
10.3197 + }
10.3198 + },
10.3199 + stopPropagation: function() {
10.3200 + this.isPropagationStopped = returnTrue;
10.3201 +
10.3202 + var e = this.originalEvent;
10.3203 + if ( !e ) {
10.3204 + return;
10.3205 + }
10.3206 + // if stopPropagation exists run it on the original event
10.3207 + if ( e.stopPropagation ) {
10.3208 + e.stopPropagation();
10.3209 + }
10.3210 + // otherwise set the cancelBubble property of the original event to true (IE)
10.3211 + e.cancelBubble = true;
10.3212 + },
10.3213 + stopImmediatePropagation: function() {
10.3214 + this.isImmediatePropagationStopped = returnTrue;
10.3215 + this.stopPropagation();
10.3216 + },
10.3217 + isDefaultPrevented: returnFalse,
10.3218 + isPropagationStopped: returnFalse,
10.3219 + isImmediatePropagationStopped: returnFalse
10.3220 +};
10.3221 +
10.3222 +// Checks if an event happened on an element within another element
10.3223 +// Used in jQuery.event.special.mouseenter and mouseleave handlers
10.3224 +var withinElement = function( event ) {
10.3225 +
10.3226 + // Check if mouse(over|out) are still within the same parent element
10.3227 + var related = event.relatedTarget,
10.3228 + inside = false,
10.3229 + eventType = event.type;
10.3230 +
10.3231 + event.type = event.data;
10.3232 +
10.3233 + if ( related !== this ) {
10.3234 +
10.3235 + if ( related ) {
10.3236 + inside = jQuery.contains( this, related );
10.3237 + }
10.3238 +
10.3239 + if ( !inside ) {
10.3240 +
10.3241 + jQuery.event.handle.apply( this, arguments );
10.3242 +
10.3243 + event.type = eventType;
10.3244 + }
10.3245 + }
10.3246 +},
10.3247 +
10.3248 +// In case of event delegation, we only need to rename the event.type,
10.3249 +// liveHandler will take care of the rest.
10.3250 +delegate = function( event ) {
10.3251 + event.type = event.data;
10.3252 + jQuery.event.handle.apply( this, arguments );
10.3253 +};
10.3254 +
10.3255 +// Create mouseenter and mouseleave events
10.3256 +jQuery.each({
10.3257 + mouseenter: "mouseover",
10.3258 + mouseleave: "mouseout"
10.3259 +}, function( orig, fix ) {
10.3260 + jQuery.event.special[ orig ] = {
10.3261 + setup: function( data ) {
10.3262 + jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
10.3263 + },
10.3264 + teardown: function( data ) {
10.3265 + jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
10.3266 + }
10.3267 + };
10.3268 +});
10.3269 +
10.3270 +// submit delegation
10.3271 +if ( !jQuery.support.submitBubbles ) {
10.3272 +
10.3273 + jQuery.event.special.submit = {
10.3274 + setup: function( data, namespaces ) {
10.3275 + if ( !jQuery.nodeName( this, "form" ) ) {
10.3276 + jQuery.event.add(this, "click.specialSubmit", function( e ) {
10.3277 + // Avoid triggering error on non-existent type attribute in IE VML (#7071)
10.3278 + var elem = e.target,
10.3279 + type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : "";
10.3280 +
10.3281 + if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
10.3282 + trigger( "submit", this, arguments );
10.3283 + }
10.3284 + });
10.3285 +
10.3286 + jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
10.3287 + var elem = e.target,
10.3288 + type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : "";
10.3289 +
10.3290 + if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
10.3291 + trigger( "submit", this, arguments );
10.3292 + }
10.3293 + });
10.3294 +
10.3295 + } else {
10.3296 + return false;
10.3297 + }
10.3298 + },
10.3299 +
10.3300 + teardown: function( namespaces ) {
10.3301 + jQuery.event.remove( this, ".specialSubmit" );
10.3302 + }
10.3303 + };
10.3304 +
10.3305 +}
10.3306 +
10.3307 +// change delegation, happens here so we have bind.
10.3308 +if ( !jQuery.support.changeBubbles ) {
10.3309 +
10.3310 + var changeFilters,
10.3311 +
10.3312 + getVal = function( elem ) {
10.3313 + var type = jQuery.nodeName( elem, "input" ) ? elem.type : "",
10.3314 + val = elem.value;
10.3315 +
10.3316 + if ( type === "radio" || type === "checkbox" ) {
10.3317 + val = elem.checked;
10.3318 +
10.3319 + } else if ( type === "select-multiple" ) {
10.3320 + val = elem.selectedIndex > -1 ?
10.3321 + jQuery.map( elem.options, function( elem ) {
10.3322 + return elem.selected;
10.3323 + }).join("-") :
10.3324 + "";
10.3325 +
10.3326 + } else if ( jQuery.nodeName( elem, "select" ) ) {
10.3327 + val = elem.selectedIndex;
10.3328 + }
10.3329 +
10.3330 + return val;
10.3331 + },
10.3332 +
10.3333 + testChange = function testChange( e ) {
10.3334 + var elem = e.target, data, val;
10.3335 +
10.3336 + if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
10.3337 + return;
10.3338 + }
10.3339 +
10.3340 + data = jQuery._data( elem, "_change_data" );
10.3341 + val = getVal(elem);
10.3342 +
10.3343 + // the current data will be also retrieved by beforeactivate
10.3344 + if ( e.type !== "focusout" || elem.type !== "radio" ) {
10.3345 + jQuery._data( elem, "_change_data", val );
10.3346 + }
10.3347 +
10.3348 + if ( data === undefined || val === data ) {
10.3349 + return;
10.3350 + }
10.3351 +
10.3352 + if ( data != null || val ) {
10.3353 + e.type = "change";
10.3354 + e.liveFired = undefined;
10.3355 + jQuery.event.trigger( e, arguments[1], elem );
10.3356 + }
10.3357 + };
10.3358 +
10.3359 + jQuery.event.special.change = {
10.3360 + filters: {
10.3361 + focusout: testChange,
10.3362 +
10.3363 + beforedeactivate: testChange,
10.3364 +
10.3365 + click: function( e ) {
10.3366 + var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
10.3367 +
10.3368 + if ( type === "radio" || type === "checkbox" || jQuery.nodeName( elem, "select" ) ) {
10.3369 + testChange.call( this, e );
10.3370 + }
10.3371 + },
10.3372 +
10.3373 + // Change has to be called before submit
10.3374 + // Keydown will be called before keypress, which is used in submit-event delegation
10.3375 + keydown: function( e ) {
10.3376 + var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
10.3377 +
10.3378 + if ( (e.keyCode === 13 && !jQuery.nodeName( elem, "textarea" ) ) ||
10.3379 + (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
10.3380 + type === "select-multiple" ) {
10.3381 + testChange.call( this, e );
10.3382 + }
10.3383 + },
10.3384 +
10.3385 + // Beforeactivate happens also before the previous element is blurred
10.3386 + // with this event you can't trigger a change event, but you can store
10.3387 + // information
10.3388 + beforeactivate: function( e ) {
10.3389 + var elem = e.target;
10.3390 + jQuery._data( elem, "_change_data", getVal(elem) );
10.3391 + }
10.3392 + },
10.3393 +
10.3394 + setup: function( data, namespaces ) {
10.3395 + if ( this.type === "file" ) {
10.3396 + return false;
10.3397 + }
10.3398 +
10.3399 + for ( var type in changeFilters ) {
10.3400 + jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
10.3401 + }
10.3402 +
10.3403 + return rformElems.test( this.nodeName );
10.3404 + },
10.3405 +
10.3406 + teardown: function( namespaces ) {
10.3407 + jQuery.event.remove( this, ".specialChange" );
10.3408 +
10.3409 + return rformElems.test( this.nodeName );
10.3410 + }
10.3411 + };
10.3412 +
10.3413 + changeFilters = jQuery.event.special.change.filters;
10.3414 +
10.3415 + // Handle when the input is .focus()'d
10.3416 + changeFilters.focus = changeFilters.beforeactivate;
10.3417 +}
10.3418 +
10.3419 +function trigger( type, elem, args ) {
10.3420 + // Piggyback on a donor event to simulate a different one.
10.3421 + // Fake originalEvent to avoid donor's stopPropagation, but if the
10.3422 + // simulated event prevents default then we do the same on the donor.
10.3423 + // Don't pass args or remember liveFired; they apply to the donor event.
10.3424 + var event = jQuery.extend( {}, args[ 0 ] );
10.3425 + event.type = type;
10.3426 + event.originalEvent = {};
10.3427 + event.liveFired = undefined;
10.3428 + jQuery.event.handle.call( elem, event );
10.3429 + if ( event.isDefaultPrevented() ) {
10.3430 + args[ 0 ].preventDefault();
10.3431 + }
10.3432 +}
10.3433 +
10.3434 +// Create "bubbling" focus and blur events
10.3435 +if ( !jQuery.support.focusinBubbles ) {
10.3436 + jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
10.3437 +
10.3438 + // Attach a single capturing handler while someone wants focusin/focusout
10.3439 + var attaches = 0;
10.3440 +
10.3441 + jQuery.event.special[ fix ] = {
10.3442 + setup: function() {
10.3443 + if ( attaches++ === 0 ) {
10.3444 + document.addEventListener( orig, handler, true );
10.3445 + }
10.3446 + },
10.3447 + teardown: function() {
10.3448 + if ( --attaches === 0 ) {
10.3449 + document.removeEventListener( orig, handler, true );
10.3450 + }
10.3451 + }
10.3452 + };
10.3453 +
10.3454 + function handler( donor ) {
10.3455 + // Donor event is always a native one; fix it and switch its type.
10.3456 + // Let focusin/out handler cancel the donor focus/blur event.
10.3457 + var e = jQuery.event.fix( donor );
10.3458 + e.type = fix;
10.3459 + e.originalEvent = {};
10.3460 + jQuery.event.trigger( e, null, e.target );
10.3461 + if ( e.isDefaultPrevented() ) {
10.3462 + donor.preventDefault();
10.3463 + }
10.3464 + }
10.3465 + });
10.3466 +}
10.3467 +
10.3468 +jQuery.each(["bind", "one"], function( i, name ) {
10.3469 + jQuery.fn[ name ] = function( type, data, fn ) {
10.3470 + var handler;
10.3471 +
10.3472 + // Handle object literals
10.3473 + if ( typeof type === "object" ) {
10.3474 + for ( var key in type ) {
10.3475 + this[ name ](key, data, type[key], fn);
10.3476 + }
10.3477 + return this;
10.3478 + }
10.3479 +
10.3480 + if ( arguments.length === 2 || data === false ) {
10.3481 + fn = data;
10.3482 + data = undefined;
10.3483 + }
10.3484 +
10.3485 + if ( name === "one" ) {
10.3486 + handler = function( event ) {
10.3487 + jQuery( this ).unbind( event, handler );
10.3488 + return fn.apply( this, arguments );
10.3489 + };
10.3490 + handler.guid = fn.guid || jQuery.guid++;
10.3491 + } else {
10.3492 + handler = fn;
10.3493 + }
10.3494 +
10.3495 + if ( type === "unload" && name !== "one" ) {
10.3496 + this.one( type, data, fn );
10.3497 +
10.3498 + } else {
10.3499 + for ( var i = 0, l = this.length; i < l; i++ ) {
10.3500 + jQuery.event.add( this[i], type, handler, data );
10.3501 + }
10.3502 + }
10.3503 +
10.3504 + return this;
10.3505 + };
10.3506 +});
10.3507 +
10.3508 +jQuery.fn.extend({
10.3509 + unbind: function( type, fn ) {
10.3510 + // Handle object literals
10.3511 + if ( typeof type === "object" && !type.preventDefault ) {
10.3512 + for ( var key in type ) {
10.3513 + this.unbind(key, type[key]);
10.3514 + }
10.3515 +
10.3516 + } else {
10.3517 + for ( var i = 0, l = this.length; i < l; i++ ) {
10.3518 + jQuery.event.remove( this[i], type, fn );
10.3519 + }
10.3520 + }
10.3521 +
10.3522 + return this;
10.3523 + },
10.3524 +
10.3525 + delegate: function( selector, types, data, fn ) {
10.3526 + return this.live( types, data, fn, selector );
10.3527 + },
10.3528 +
10.3529 + undelegate: function( selector, types, fn ) {
10.3530 + if ( arguments.length === 0 ) {
10.3531 + return this.unbind( "live" );
10.3532 +
10.3533 + } else {
10.3534 + return this.die( types, null, fn, selector );
10.3535 + }
10.3536 + },
10.3537 +
10.3538 + trigger: function( type, data ) {
10.3539 + return this.each(function() {
10.3540 + jQuery.event.trigger( type, data, this );
10.3541 + });
10.3542 + },
10.3543 +
10.3544 + triggerHandler: function( type, data ) {
10.3545 + if ( this[0] ) {
10.3546 + return jQuery.event.trigger( type, data, this[0], true );
10.3547 + }
10.3548 + },
10.3549 +
10.3550 + toggle: function( fn ) {
10.3551 + // Save reference to arguments for access in closure
10.3552 + var args = arguments,
10.3553 + guid = fn.guid || jQuery.guid++,
10.3554 + i = 0,
10.3555 + toggler = function( event ) {
10.3556 + // Figure out which function to execute
10.3557 + var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
10.3558 + jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
10.3559 +
10.3560 + // Make sure that clicks stop
10.3561 + event.preventDefault();
10.3562 +
10.3563 + // and execute the function
10.3564 + return args[ lastToggle ].apply( this, arguments ) || false;
10.3565 + };
10.3566 +
10.3567 + // link all the functions, so any of them can unbind this click handler
10.3568 + toggler.guid = guid;
10.3569 + while ( i < args.length ) {
10.3570 + args[ i++ ].guid = guid;
10.3571 + }
10.3572 +
10.3573 + return this.click( toggler );
10.3574 + },
10.3575 +
10.3576 + hover: function( fnOver, fnOut ) {
10.3577 + return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
10.3578 + }
10.3579 +});
10.3580 +
10.3581 +var liveMap = {
10.3582 + focus: "focusin",
10.3583 + blur: "focusout",
10.3584 + mouseenter: "mouseover",
10.3585 + mouseleave: "mouseout"
10.3586 +};
10.3587 +
10.3588 +jQuery.each(["live", "die"], function( i, name ) {
10.3589 + jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
10.3590 + var type, i = 0, match, namespaces, preType,
10.3591 + selector = origSelector || this.selector,
10.3592 + context = origSelector ? this : jQuery( this.context );
10.3593 +
10.3594 + if ( typeof types === "object" && !types.preventDefault ) {
10.3595 + for ( var key in types ) {
10.3596 + context[ name ]( key, data, types[key], selector );
10.3597 + }
10.3598 +
10.3599 + return this;
10.3600 + }
10.3601 +
10.3602 + if ( name === "die" && !types &&
10.3603 + origSelector && origSelector.charAt(0) === "." ) {
10.3604 +
10.3605 + context.unbind( origSelector );
10.3606 +
10.3607 + return this;
10.3608 + }
10.3609 +
10.3610 + if ( data === false || jQuery.isFunction( data ) ) {
10.3611 + fn = data || returnFalse;
10.3612 + data = undefined;
10.3613 + }
10.3614 +
10.3615 + types = (types || "").split(" ");
10.3616 +
10.3617 + while ( (type = types[ i++ ]) != null ) {
10.3618 + match = rnamespaces.exec( type );
10.3619 + namespaces = "";
10.3620 +
10.3621 + if ( match ) {
10.3622 + namespaces = match[0];
10.3623 + type = type.replace( rnamespaces, "" );
10.3624 + }
10.3625 +
10.3626 + if ( type === "hover" ) {
10.3627 + types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
10.3628 + continue;
10.3629 + }
10.3630 +
10.3631 + preType = type;
10.3632 +
10.3633 + if ( liveMap[ type ] ) {
10.3634 + types.push( liveMap[ type ] + namespaces );
10.3635 + type = type + namespaces;
10.3636 +
10.3637 + } else {
10.3638 + type = (liveMap[ type ] || type) + namespaces;
10.3639 + }
10.3640 +
10.3641 + if ( name === "live" ) {
10.3642 + // bind live handler
10.3643 + for ( var j = 0, l = context.length; j < l; j++ ) {
10.3644 + jQuery.event.add( context[j], "live." + liveConvert( type, selector ),
10.3645 + { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
10.3646 + }
10.3647 +
10.3648 + } else {
10.3649 + // unbind live handler
10.3650 + context.unbind( "live." + liveConvert( type, selector ), fn );
10.3651 + }
10.3652 + }
10.3653 +
10.3654 + return this;
10.3655 + };
10.3656 +});
10.3657 +
10.3658 +function liveHandler( event ) {
10.3659 + var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
10.3660 + elems = [],
10.3661 + selectors = [],
10.3662 + events = jQuery._data( this, "events" );
10.3663 +
10.3664 + // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911)
10.3665 + if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) {
10.3666 + return;
10.3667 + }
10.3668 +
10.3669 + if ( event.namespace ) {
10.3670 + namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
10.3671 + }
10.3672 +
10.3673 + event.liveFired = this;
10.3674 +
10.3675 + var live = events.live.slice(0);
10.3676 +
10.3677 + for ( j = 0; j < live.length; j++ ) {
10.3678 + handleObj = live[j];
10.3679 +
10.3680 + if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
10.3681 + selectors.push( handleObj.selector );
10.3682 +
10.3683 + } else {
10.3684 + live.splice( j--, 1 );
10.3685 + }
10.3686 + }
10.3687 +
10.3688 + match = jQuery( event.target ).closest( selectors, event.currentTarget );
10.3689 +
10.3690 + for ( i = 0, l = match.length; i < l; i++ ) {
10.3691 + close = match[i];
10.3692 +
10.3693 + for ( j = 0; j < live.length; j++ ) {
10.3694 + handleObj = live[j];
10.3695 +
10.3696 + if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) {
10.3697 + elem = close.elem;
10.3698 + related = null;
10.3699 +
10.3700 + // Those two events require additional checking
10.3701 + if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
10.3702 + event.type = handleObj.preType;
10.3703 + related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
10.3704 +
10.3705 + // Make sure not to accidentally match a child element with the same selector
10.3706 + if ( related && jQuery.contains( elem, related ) ) {
10.3707 + related = elem;
10.3708 + }
10.3709 + }
10.3710 +
10.3711 + if ( !related || related !== elem ) {
10.3712 + elems.push({ elem: elem, handleObj: handleObj, level: close.level });
10.3713 + }
10.3714 + }
10.3715 + }
10.3716 + }
10.3717 +
10.3718 + for ( i = 0, l = elems.length; i < l; i++ ) {
10.3719 + match = elems[i];
10.3720 +
10.3721 + if ( maxLevel && match.level > maxLevel ) {
10.3722 + break;
10.3723 + }
10.3724 +
10.3725 + event.currentTarget = match.elem;
10.3726 + event.data = match.handleObj.data;
10.3727 + event.handleObj = match.handleObj;
10.3728 +
10.3729 + ret = match.handleObj.origHandler.apply( match.elem, arguments );
10.3730 +
10.3731 + if ( ret === false || event.isPropagationStopped() ) {
10.3732 + maxLevel = match.level;
10.3733 +
10.3734 + if ( ret === false ) {
10.3735 + stop = false;
10.3736 + }
10.3737 + if ( event.isImmediatePropagationStopped() ) {
10.3738 + break;
10.3739 + }
10.3740 + }
10.3741 + }
10.3742 +
10.3743 + return stop;
10.3744 +}
10.3745 +
10.3746 +function liveConvert( type, selector ) {
10.3747 + return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspaces, "&");
10.3748 +}
10.3749 +
10.3750 +jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
10.3751 + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
10.3752 + "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
10.3753 +
10.3754 + // Handle event binding
10.3755 + jQuery.fn[ name ] = function( data, fn ) {
10.3756 + if ( fn == null ) {
10.3757 + fn = data;
10.3758 + data = null;
10.3759 + }
10.3760 +
10.3761 + return arguments.length > 0 ?
10.3762 + this.bind( name, data, fn ) :
10.3763 + this.trigger( name );
10.3764 + };
10.3765 +
10.3766 + if ( jQuery.attrFn ) {
10.3767 + jQuery.attrFn[ name ] = true;
10.3768 + }
10.3769 +});
10.3770 +
10.3771 +
10.3772 +
10.3773 +/*!
10.3774 + * Sizzle CSS Selector Engine
10.3775 + * Copyright 2011, The Dojo Foundation
10.3776 + * Released under the MIT, BSD, and GPL Licenses.
10.3777 + * More information: http://sizzlejs.com/
10.3778 + */
10.3779 +(function(){
10.3780 +
10.3781 +var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
10.3782 + done = 0,
10.3783 + toString = Object.prototype.toString,
10.3784 + hasDuplicate = false,
10.3785 + baseHasDuplicate = true,
10.3786 + rBackslash = /\\/g,
10.3787 + rNonWord = /\W/;
10.3788 +
10.3789 +// Here we check if the JavaScript engine is using some sort of
10.3790 +// optimization where it does not always call our comparision
10.3791 +// function. If that is the case, discard the hasDuplicate value.
10.3792 +// Thus far that includes Google Chrome.
10.3793 +[0, 0].sort(function() {
10.3794 + baseHasDuplicate = false;
10.3795 + return 0;
10.3796 +});
10.3797 +
10.3798 +var Sizzle = function( selector, context, results, seed ) {
10.3799 + results = results || [];
10.3800 + context = context || document;
10.3801 +
10.3802 + var origContext = context;
10.3803 +
10.3804 + if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
10.3805 + return [];
10.3806 + }
10.3807 +
10.3808 + if ( !selector || typeof selector !== "string" ) {
10.3809 + return results;
10.3810 + }
10.3811 +
10.3812 + var m, set, checkSet, extra, ret, cur, pop, i,
10.3813 + prune = true,
10.3814 + contextXML = Sizzle.isXML( context ),
10.3815 + parts = [],
10.3816 + soFar = selector;
10.3817 +
10.3818 + // Reset the position of the chunker regexp (start from head)
10.3819 + do {
10.3820 + chunker.exec( "" );
10.3821 + m = chunker.exec( soFar );
10.3822 +
10.3823 + if ( m ) {
10.3824 + soFar = m[3];
10.3825 +
10.3826 + parts.push( m[1] );
10.3827 +
10.3828 + if ( m[2] ) {
10.3829 + extra = m[3];
10.3830 + break;
10.3831 + }
10.3832 + }
10.3833 + } while ( m );
10.3834 +
10.3835 + if ( parts.length > 1 && origPOS.exec( selector ) ) {
10.3836 +
10.3837 + if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
10.3838 + set = posProcess( parts[0] + parts[1], context );
10.3839 +
10.3840 + } else {
10.3841 + set = Expr.relative[ parts[0] ] ?
10.3842 + [ context ] :
10.3843 + Sizzle( parts.shift(), context );
10.3844 +
10.3845 + while ( parts.length ) {
10.3846 + selector = parts.shift();
10.3847 +
10.3848 + if ( Expr.relative[ selector ] ) {
10.3849 + selector += parts.shift();
10.3850 + }
10.3851 +
10.3852 + set = posProcess( selector, set );
10.3853 + }
10.3854 + }
10.3855 +
10.3856 + } else {
10.3857 + // Take a shortcut and set the context if the root selector is an ID
10.3858 + // (but not if it'll be faster if the inner selector is an ID)
10.3859 + if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
10.3860 + Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
10.3861 +
10.3862 + ret = Sizzle.find( parts.shift(), context, contextXML );
10.3863 + context = ret.expr ?
10.3864 + Sizzle.filter( ret.expr, ret.set )[0] :
10.3865 + ret.set[0];
10.3866 + }
10.3867 +
10.3868 + if ( context ) {
10.3869 + ret = seed ?
10.3870 + { expr: parts.pop(), set: makeArray(seed) } :
10.3871 + Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
10.3872 +
10.3873 + set = ret.expr ?
10.3874 + Sizzle.filter( ret.expr, ret.set ) :
10.3875 + ret.set;
10.3876 +
10.3877 + if ( parts.length > 0 ) {
10.3878 + checkSet = makeArray( set );
10.3879 +
10.3880 + } else {
10.3881 + prune = false;
10.3882 + }
10.3883 +
10.3884 + while ( parts.length ) {
10.3885 + cur = parts.pop();
10.3886 + pop = cur;
10.3887 +
10.3888 + if ( !Expr.relative[ cur ] ) {
10.3889 + cur = "";
10.3890 + } else {
10.3891 + pop = parts.pop();
10.3892 + }
10.3893 +
10.3894 + if ( pop == null ) {
10.3895 + pop = context;
10.3896 + }
10.3897 +
10.3898 + Expr.relative[ cur ]( checkSet, pop, contextXML );
10.3899 + }
10.3900 +
10.3901 + } else {
10.3902 + checkSet = parts = [];
10.3903 + }
10.3904 + }
10.3905 +
10.3906 + if ( !checkSet ) {
10.3907 + checkSet = set;
10.3908 + }
10.3909 +
10.3910 + if ( !checkSet ) {
10.3911 + Sizzle.error( cur || selector );
10.3912 + }
10.3913 +
10.3914 + if ( toString.call(checkSet) === "[object Array]" ) {
10.3915 + if ( !prune ) {
10.3916 + results.push.apply( results, checkSet );
10.3917 +
10.3918 + } else if ( context && context.nodeType === 1 ) {
10.3919 + for ( i = 0; checkSet[i] != null; i++ ) {
10.3920 + if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
10.3921 + results.push( set[i] );
10.3922 + }
10.3923 + }
10.3924 +
10.3925 + } else {
10.3926 + for ( i = 0; checkSet[i] != null; i++ ) {
10.3927 + if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
10.3928 + results.push( set[i] );
10.3929 + }
10.3930 + }
10.3931 + }
10.3932 +
10.3933 + } else {
10.3934 + makeArray( checkSet, results );
10.3935 + }
10.3936 +
10.3937 + if ( extra ) {
10.3938 + Sizzle( extra, origContext, results, seed );
10.3939 + Sizzle.uniqueSort( results );
10.3940 + }
10.3941 +
10.3942 + return results;
10.3943 +};
10.3944 +
10.3945 +Sizzle.uniqueSort = function( results ) {
10.3946 + if ( sortOrder ) {
10.3947 + hasDuplicate = baseHasDuplicate;
10.3948 + results.sort( sortOrder );
10.3949 +
10.3950 + if ( hasDuplicate ) {
10.3951 + for ( var i = 1; i < results.length; i++ ) {
10.3952 + if ( results[i] === results[ i - 1 ] ) {
10.3953 + results.splice( i--, 1 );
10.3954 + }
10.3955 + }
10.3956 + }
10.3957 + }
10.3958 +
10.3959 + return results;
10.3960 +};
10.3961 +
10.3962 +Sizzle.matches = function( expr, set ) {
10.3963 + return Sizzle( expr, null, null, set );
10.3964 +};
10.3965 +
10.3966 +Sizzle.matchesSelector = function( node, expr ) {
10.3967 + return Sizzle( expr, null, null, [node] ).length > 0;
10.3968 +};
10.3969 +
10.3970 +Sizzle.find = function( expr, context, isXML ) {
10.3971 + var set;
10.3972 +
10.3973 + if ( !expr ) {
10.3974 + return [];
10.3975 + }
10.3976 +
10.3977 + for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
10.3978 + var match,
10.3979 + type = Expr.order[i];
10.3980 +
10.3981 + if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
10.3982 + var left = match[1];
10.3983 + match.splice( 1, 1 );
10.3984 +
10.3985 + if ( left.substr( left.length - 1 ) !== "\\" ) {
10.3986 + match[1] = (match[1] || "").replace( rBackslash, "" );
10.3987 + set = Expr.find[ type ]( match, context, isXML );
10.3988 +
10.3989 + if ( set != null ) {
10.3990 + expr = expr.replace( Expr.match[ type ], "" );
10.3991 + break;
10.3992 + }
10.3993 + }
10.3994 + }
10.3995 + }
10.3996 +
10.3997 + if ( !set ) {
10.3998 + set = typeof context.getElementsByTagName !== "undefined" ?
10.3999 + context.getElementsByTagName( "*" ) :
10.4000 + [];
10.4001 + }
10.4002 +
10.4003 + return { set: set, expr: expr };
10.4004 +};
10.4005 +
10.4006 +Sizzle.filter = function( expr, set, inplace, not ) {
10.4007 + var match, anyFound,
10.4008 + old = expr,
10.4009 + result = [],
10.4010 + curLoop = set,
10.4011 + isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
10.4012 +
10.4013 + while ( expr && set.length ) {
10.4014 + for ( var type in Expr.filter ) {
10.4015 + if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
10.4016 + var found, item,
10.4017 + filter = Expr.filter[ type ],
10.4018 + left = match[1];
10.4019 +
10.4020 + anyFound = false;
10.4021 +
10.4022 + match.splice(1,1);
10.4023 +
10.4024 + if ( left.substr( left.length - 1 ) === "\\" ) {
10.4025 + continue;
10.4026 + }
10.4027 +
10.4028 + if ( curLoop === result ) {
10.4029 + result = [];
10.4030 + }
10.4031 +
10.4032 + if ( Expr.preFilter[ type ] ) {
10.4033 + match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
10.4034 +
10.4035 + if ( !match ) {
10.4036 + anyFound = found = true;
10.4037 +
10.4038 + } else if ( match === true ) {
10.4039 + continue;
10.4040 + }
10.4041 + }
10.4042 +
10.4043 + if ( match ) {
10.4044 + for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
10.4045 + if ( item ) {
10.4046 + found = filter( item, match, i, curLoop );
10.4047 + var pass = not ^ !!found;
10.4048 +
10.4049 + if ( inplace && found != null ) {
10.4050 + if ( pass ) {
10.4051 + anyFound = true;
10.4052 +
10.4053 + } else {
10.4054 + curLoop[i] = false;
10.4055 + }
10.4056 +
10.4057 + } else if ( pass ) {
10.4058 + result.push( item );
10.4059 + anyFound = true;
10.4060 + }
10.4061 + }
10.4062 + }
10.4063 + }
10.4064 +
10.4065 + if ( found !== undefined ) {
10.4066 + if ( !inplace ) {
10.4067 + curLoop = result;
10.4068 + }
10.4069 +
10.4070 + expr = expr.replace( Expr.match[ type ], "" );
10.4071 +
10.4072 + if ( !anyFound ) {
10.4073 + return [];
10.4074 + }
10.4075 +
10.4076 + break;
10.4077 + }
10.4078 + }
10.4079 + }
10.4080 +
10.4081 + // Improper expression
10.4082 + if ( expr === old ) {
10.4083 + if ( anyFound == null ) {
10.4084 + Sizzle.error( expr );
10.4085 +
10.4086 + } else {
10.4087 + break;
10.4088 + }
10.4089 + }
10.4090 +
10.4091 + old = expr;
10.4092 + }
10.4093 +
10.4094 + return curLoop;
10.4095 +};
10.4096 +
10.4097 +Sizzle.error = function( msg ) {
10.4098 + throw "Syntax error, unrecognized expression: " + msg;
10.4099 +};
10.4100 +
10.4101 +var Expr = Sizzle.selectors = {
10.4102 + order: [ "ID", "NAME", "TAG" ],
10.4103 +
10.4104 + match: {
10.4105 + ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
10.4106 + CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
10.4107 + NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
10.4108 + ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
10.4109 + TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
10.4110 + CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
10.4111 + POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
10.4112 + PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
10.4113 + },
10.4114 +
10.4115 + leftMatch: {},
10.4116 +
10.4117 + attrMap: {
10.4118 + "class": "className",
10.4119 + "for": "htmlFor"
10.4120 + },
10.4121 +
10.4122 + attrHandle: {
10.4123 + href: function( elem ) {
10.4124 + return elem.getAttribute( "href" );
10.4125 + },
10.4126 + type: function( elem ) {
10.4127 + return elem.getAttribute( "type" );
10.4128 + }
10.4129 + },
10.4130 +
10.4131 + relative: {
10.4132 + "+": function(checkSet, part){
10.4133 + var isPartStr = typeof part === "string",
10.4134 + isTag = isPartStr && !rNonWord.test( part ),
10.4135 + isPartStrNotTag = isPartStr && !isTag;
10.4136 +
10.4137 + if ( isTag ) {
10.4138 + part = part.toLowerCase();
10.4139 + }
10.4140 +
10.4141 + for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
10.4142 + if ( (elem = checkSet[i]) ) {
10.4143 + while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
10.4144 +
10.4145 + checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
10.4146 + elem || false :
10.4147 + elem === part;
10.4148 + }
10.4149 + }
10.4150 +
10.4151 + if ( isPartStrNotTag ) {
10.4152 + Sizzle.filter( part, checkSet, true );
10.4153 + }
10.4154 + },
10.4155 +
10.4156 + ">": function( checkSet, part ) {
10.4157 + var elem,
10.4158 + isPartStr = typeof part === "string",
10.4159 + i = 0,
10.4160 + l = checkSet.length;
10.4161 +
10.4162 + if ( isPartStr && !rNonWord.test( part ) ) {
10.4163 + part = part.toLowerCase();
10.4164 +
10.4165 + for ( ; i < l; i++ ) {
10.4166 + elem = checkSet[i];
10.4167 +
10.4168 + if ( elem ) {
10.4169 + var parent = elem.parentNode;
10.4170 + checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
10.4171 + }
10.4172 + }
10.4173 +
10.4174 + } else {
10.4175 + for ( ; i < l; i++ ) {
10.4176 + elem = checkSet[i];
10.4177 +
10.4178 + if ( elem ) {
10.4179 + checkSet[i] = isPartStr ?
10.4180 + elem.parentNode :
10.4181 + elem.parentNode === part;
10.4182 + }
10.4183 + }
10.4184 +
10.4185 + if ( isPartStr ) {
10.4186 + Sizzle.filter( part, checkSet, true );
10.4187 + }
10.4188 + }
10.4189 + },
10.4190 +
10.4191 + "": function(checkSet, part, isXML){
10.4192 + var nodeCheck,
10.4193 + doneName = done++,
10.4194 + checkFn = dirCheck;
10.4195 +
10.4196 + if ( typeof part === "string" && !rNonWord.test( part ) ) {
10.4197 + part = part.toLowerCase();
10.4198 + nodeCheck = part;
10.4199 + checkFn = dirNodeCheck;
10.4200 + }
10.4201 +
10.4202 + checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
10.4203 + },
10.4204 +
10.4205 + "~": function( checkSet, part, isXML ) {
10.4206 + var nodeCheck,
10.4207 + doneName = done++,
10.4208 + checkFn = dirCheck;
10.4209 +
10.4210 + if ( typeof part === "string" && !rNonWord.test( part ) ) {
10.4211 + part = part.toLowerCase();
10.4212 + nodeCheck = part;
10.4213 + checkFn = dirNodeCheck;
10.4214 + }
10.4215 +
10.4216 + checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
10.4217 + }
10.4218 + },
10.4219 +
10.4220 + find: {
10.4221 + ID: function( match, context, isXML ) {
10.4222 + if ( typeof context.getElementById !== "undefined" && !isXML ) {
10.4223 + var m = context.getElementById(match[1]);
10.4224 + // Check parentNode to catch when Blackberry 4.6 returns
10.4225 + // nodes that are no longer in the document #6963
10.4226 + return m && m.parentNode ? [m] : [];
10.4227 + }
10.4228 + },
10.4229 +
10.4230 + NAME: function( match, context ) {
10.4231 + if ( typeof context.getElementsByName !== "undefined" ) {
10.4232 + var ret = [],
10.4233 + results = context.getElementsByName( match[1] );
10.4234 +
10.4235 + for ( var i = 0, l = results.length; i < l; i++ ) {
10.4236 + if ( results[i].getAttribute("name") === match[1] ) {
10.4237 + ret.push( results[i] );
10.4238 + }
10.4239 + }
10.4240 +
10.4241 + return ret.length === 0 ? null : ret;
10.4242 + }
10.4243 + },
10.4244 +
10.4245 + TAG: function( match, context ) {
10.4246 + if ( typeof context.getElementsByTagName !== "undefined" ) {
10.4247 + return context.getElementsByTagName( match[1] );
10.4248 + }
10.4249 + }
10.4250 + },
10.4251 + preFilter: {
10.4252 + CLASS: function( match, curLoop, inplace, result, not, isXML ) {
10.4253 + match = " " + match[1].replace( rBackslash, "" ) + " ";
10.4254 +
10.4255 + if ( isXML ) {
10.4256 + return match;
10.4257 + }
10.4258 +
10.4259 + for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
10.4260 + if ( elem ) {
10.4261 + if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
10.4262 + if ( !inplace ) {
10.4263 + result.push( elem );
10.4264 + }
10.4265 +
10.4266 + } else if ( inplace ) {
10.4267 + curLoop[i] = false;
10.4268 + }
10.4269 + }
10.4270 + }
10.4271 +
10.4272 + return false;
10.4273 + },
10.4274 +
10.4275 + ID: function( match ) {
10.4276 + return match[1].replace( rBackslash, "" );
10.4277 + },
10.4278 +
10.4279 + TAG: function( match, curLoop ) {
10.4280 + return match[1].replace( rBackslash, "" ).toLowerCase();
10.4281 + },
10.4282 +
10.4283 + CHILD: function( match ) {
10.4284 + if ( match[1] === "nth" ) {
10.4285 + if ( !match[2] ) {
10.4286 + Sizzle.error( match[0] );
10.4287 + }
10.4288 +
10.4289 + match[2] = match[2].replace(/^\+|\s*/g, '');
10.4290 +
10.4291 + // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
10.4292 + var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
10.4293 + match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
10.4294 + !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
10.4295 +
10.4296 + // calculate the numbers (first)n+(last) including if they are negative
10.4297 + match[2] = (test[1] + (test[2] || 1)) - 0;
10.4298 + match[3] = test[3] - 0;
10.4299 + }
10.4300 + else if ( match[2] ) {
10.4301 + Sizzle.error( match[0] );
10.4302 + }
10.4303 +
10.4304 + // TODO: Move to normal caching system
10.4305 + match[0] = done++;
10.4306 +
10.4307 + return match;
10.4308 + },
10.4309 +
10.4310 + ATTR: function( match, curLoop, inplace, result, not, isXML ) {
10.4311 + var name = match[1] = match[1].replace( rBackslash, "" );
10.4312 +
10.4313 + if ( !isXML && Expr.attrMap[name] ) {
10.4314 + match[1] = Expr.attrMap[name];
10.4315 + }
10.4316 +
10.4317 + // Handle if an un-quoted value was used
10.4318 + match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
10.4319 +
10.4320 + if ( match[2] === "~=" ) {
10.4321 + match[4] = " " + match[4] + " ";
10.4322 + }
10.4323 +
10.4324 + return match;
10.4325 + },
10.4326 +
10.4327 + PSEUDO: function( match, curLoop, inplace, result, not ) {
10.4328 + if ( match[1] === "not" ) {
10.4329 + // If we're dealing with a complex expression, or a simple one
10.4330 + if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
10.4331 + match[3] = Sizzle(match[3], null, null, curLoop);
10.4332 +
10.4333 + } else {
10.4334 + var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
10.4335 +
10.4336 + if ( !inplace ) {
10.4337 + result.push.apply( result, ret );
10.4338 + }
10.4339 +
10.4340 + return false;
10.4341 + }
10.4342 +
10.4343 + } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
10.4344 + return true;
10.4345 + }
10.4346 +
10.4347 + return match;
10.4348 + },
10.4349 +
10.4350 + POS: function( match ) {
10.4351 + match.unshift( true );
10.4352 +
10.4353 + return match;
10.4354 + }
10.4355 + },
10.4356 +
10.4357 + filters: {
10.4358 + enabled: function( elem ) {
10.4359 + return elem.disabled === false && elem.type !== "hidden";
10.4360 + },
10.4361 +
10.4362 + disabled: function( elem ) {
10.4363 + return elem.disabled === true;
10.4364 + },
10.4365 +
10.4366 + checked: function( elem ) {
10.4367 + return elem.checked === true;
10.4368 + },
10.4369 +
10.4370 + selected: function( elem ) {
10.4371 + // Accessing this property makes selected-by-default
10.4372 + // options in Safari work properly
10.4373 + if ( elem.parentNode ) {
10.4374 + elem.parentNode.selectedIndex;
10.4375 + }
10.4376 +
10.4377 + return elem.selected === true;
10.4378 + },
10.4379 +
10.4380 + parent: function( elem ) {
10.4381 + return !!elem.firstChild;
10.4382 + },
10.4383 +
10.4384 + empty: function( elem ) {
10.4385 + return !elem.firstChild;
10.4386 + },
10.4387 +
10.4388 + has: function( elem, i, match ) {
10.4389 + return !!Sizzle( match[3], elem ).length;
10.4390 + },
10.4391 +
10.4392 + header: function( elem ) {
10.4393 + return (/h\d/i).test( elem.nodeName );
10.4394 + },
10.4395 +
10.4396 + text: function( elem ) {
10.4397 + var attr = elem.getAttribute( "type" ), type = elem.type;
10.4398 + // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
10.4399 + // use getAttribute instead to test this case
10.4400 + return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
10.4401 + },
10.4402 +
10.4403 + radio: function( elem ) {
10.4404 + return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type;
10.4405 + },
10.4406 +
10.4407 + checkbox: function( elem ) {
10.4408 + return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type;
10.4409 + },
10.4410 +
10.4411 + file: function( elem ) {
10.4412 + return elem.nodeName.toLowerCase() === "input" && "file" === elem.type;
10.4413 + },
10.4414 +
10.4415 + password: function( elem ) {
10.4416 + return elem.nodeName.toLowerCase() === "input" && "password" === elem.type;
10.4417 + },
10.4418 +
10.4419 + submit: function( elem ) {
10.4420 + var name = elem.nodeName.toLowerCase();
10.4421 + return (name === "input" || name === "button") && "submit" === elem.type;
10.4422 + },
10.4423 +
10.4424 + image: function( elem ) {
10.4425 + return elem.nodeName.toLowerCase() === "input" && "image" === elem.type;
10.4426 + },
10.4427 +
10.4428 + reset: function( elem ) {
10.4429 + var name = elem.nodeName.toLowerCase();
10.4430 + return (name === "input" || name === "button") && "reset" === elem.type;
10.4431 + },
10.4432 +
10.4433 + button: function( elem ) {
10.4434 + var name = elem.nodeName.toLowerCase();
10.4435 + return name === "input" && "button" === elem.type || name === "button";
10.4436 + },
10.4437 +
10.4438 + input: function( elem ) {
10.4439 + return (/input|select|textarea|button/i).test( elem.nodeName );
10.4440 + },
10.4441 +
10.4442 + focus: function( elem ) {
10.4443 + return elem === elem.ownerDocument.activeElement;
10.4444 + }
10.4445 + },
10.4446 + setFilters: {
10.4447 + first: function( elem, i ) {
10.4448 + return i === 0;
10.4449 + },
10.4450 +
10.4451 + last: function( elem, i, match, array ) {
10.4452 + return i === array.length - 1;
10.4453 + },
10.4454 +
10.4455 + even: function( elem, i ) {
10.4456 + return i % 2 === 0;
10.4457 + },
10.4458 +
10.4459 + odd: function( elem, i ) {
10.4460 + return i % 2 === 1;
10.4461 + },
10.4462 +
10.4463 + lt: function( elem, i, match ) {
10.4464 + return i < match[3] - 0;
10.4465 + },
10.4466 +
10.4467 + gt: function( elem, i, match ) {
10.4468 + return i > match[3] - 0;
10.4469 + },
10.4470 +
10.4471 + nth: function( elem, i, match ) {
10.4472 + return match[3] - 0 === i;
10.4473 + },
10.4474 +
10.4475 + eq: function( elem, i, match ) {
10.4476 + return match[3] - 0 === i;
10.4477 + }
10.4478 + },
10.4479 + filter: {
10.4480 + PSEUDO: function( elem, match, i, array ) {
10.4481 + var name = match[1],
10.4482 + filter = Expr.filters[ name ];
10.4483 +
10.4484 + if ( filter ) {
10.4485 + return filter( elem, i, match, array );
10.4486 +
10.4487 + } else if ( name === "contains" ) {
10.4488 + return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;
10.4489 +
10.4490 + } else if ( name === "not" ) {
10.4491 + var not = match[3];
10.4492 +
10.4493 + for ( var j = 0, l = not.length; j < l; j++ ) {
10.4494 + if ( not[j] === elem ) {
10.4495 + return false;
10.4496 + }
10.4497 + }
10.4498 +
10.4499 + return true;
10.4500 +
10.4501 + } else {
10.4502 + Sizzle.error( name );
10.4503 + }
10.4504 + },
10.4505 +
10.4506 + CHILD: function( elem, match ) {
10.4507 + var type = match[1],
10.4508 + node = elem;
10.4509 +
10.4510 + switch ( type ) {
10.4511 + case "only":
10.4512 + case "first":
10.4513 + while ( (node = node.previousSibling) ) {
10.4514 + if ( node.nodeType === 1 ) {
10.4515 + return false;
10.4516 + }
10.4517 + }
10.4518 +
10.4519 + if ( type === "first" ) {
10.4520 + return true;
10.4521 + }
10.4522 +
10.4523 + node = elem;
10.4524 +
10.4525 + case "last":
10.4526 + while ( (node = node.nextSibling) ) {
10.4527 + if ( node.nodeType === 1 ) {
10.4528 + return false;
10.4529 + }
10.4530 + }
10.4531 +
10.4532 + return true;
10.4533 +
10.4534 + case "nth":
10.4535 + var first = match[2],
10.4536 + last = match[3];
10.4537 +
10.4538 + if ( first === 1 && last === 0 ) {
10.4539 + return true;
10.4540 + }
10.4541 +
10.4542 + var doneName = match[0],
10.4543 + parent = elem.parentNode;
10.4544 +
10.4545 + if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
10.4546 + var count = 0;
10.4547 +
10.4548 + for ( node = parent.firstChild; node; node = node.nextSibling ) {
10.4549 + if ( node.nodeType === 1 ) {
10.4550 + node.nodeIndex = ++count;
10.4551 + }
10.4552 + }
10.4553 +
10.4554 + parent.sizcache = doneName;
10.4555 + }
10.4556 +
10.4557 + var diff = elem.nodeIndex - last;
10.4558 +
10.4559 + if ( first === 0 ) {
10.4560 + return diff === 0;
10.4561 +
10.4562 + } else {
10.4563 + return ( diff % first === 0 && diff / first >= 0 );
10.4564 + }
10.4565 + }
10.4566 + },
10.4567 +
10.4568 + ID: function( elem, match ) {
10.4569 + return elem.nodeType === 1 && elem.getAttribute("id") === match;
10.4570 + },
10.4571 +
10.4572 + TAG: function( elem, match ) {
10.4573 + return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
10.4574 + },
10.4575 +
10.4576 + CLASS: function( elem, match ) {
10.4577 + return (" " + (elem.className || elem.getAttribute("class")) + " ")
10.4578 + .indexOf( match ) > -1;
10.4579 + },
10.4580 +
10.4581 + ATTR: function( elem, match ) {
10.4582 + var name = match[1],
10.4583 + result = Expr.attrHandle[ name ] ?
10.4584 + Expr.attrHandle[ name ]( elem ) :
10.4585 + elem[ name ] != null ?
10.4586 + elem[ name ] :
10.4587 + elem.getAttribute( name ),
10.4588 + value = result + "",
10.4589 + type = match[2],
10.4590 + check = match[4];
10.4591 +
10.4592 + return result == null ?
10.4593 + type === "!=" :
10.4594 + type === "=" ?
10.4595 + value === check :
10.4596 + type === "*=" ?
10.4597 + value.indexOf(check) >= 0 :
10.4598 + type === "~=" ?
10.4599 + (" " + value + " ").indexOf(check) >= 0 :
10.4600 + !check ?
10.4601 + value && result !== false :
10.4602 + type === "!=" ?
10.4603 + value !== check :
10.4604 + type === "^=" ?
10.4605 + value.indexOf(check) === 0 :
10.4606 + type === "$=" ?
10.4607 + value.substr(value.length - check.length) === check :
10.4608 + type === "|=" ?
10.4609 + value === check || value.substr(0, check.length + 1) === check + "-" :
10.4610 + false;
10.4611 + },
10.4612 +
10.4613 + POS: function( elem, match, i, array ) {
10.4614 + var name = match[2],
10.4615 + filter = Expr.setFilters[ name ];
10.4616 +
10.4617 + if ( filter ) {
10.4618 + return filter( elem, i, match, array );
10.4619 + }
10.4620 + }
10.4621 + }
10.4622 +};
10.4623 +
10.4624 +var origPOS = Expr.match.POS,
10.4625 + fescape = function(all, num){
10.4626 + return "\\" + (num - 0 + 1);
10.4627 + };
10.4628 +
10.4629 +for ( var type in Expr.match ) {
10.4630 + Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
10.4631 + Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
10.4632 +}
10.4633 +
10.4634 +var makeArray = function( array, results ) {
10.4635 + array = Array.prototype.slice.call( array, 0 );
10.4636 +
10.4637 + if ( results ) {
10.4638 + results.push.apply( results, array );
10.4639 + return results;
10.4640 + }
10.4641 +
10.4642 + return array;
10.4643 +};
10.4644 +
10.4645 +// Perform a simple check to determine if the browser is capable of
10.4646 +// converting a NodeList to an array using builtin methods.
10.4647 +// Also verifies that the returned array holds DOM nodes
10.4648 +// (which is not the case in the Blackberry browser)
10.4649 +try {
10.4650 + Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
10.4651 +
10.4652 +// Provide a fallback method if it does not work
10.4653 +} catch( e ) {
10.4654 + makeArray = function( array, results ) {
10.4655 + var i = 0,
10.4656 + ret = results || [];
10.4657 +
10.4658 + if ( toString.call(array) === "[object Array]" ) {
10.4659 + Array.prototype.push.apply( ret, array );
10.4660 +
10.4661 + } else {
10.4662 + if ( typeof array.length === "number" ) {
10.4663 + for ( var l = array.length; i < l; i++ ) {
10.4664 + ret.push( array[i] );
10.4665 + }
10.4666 +
10.4667 + } else {
10.4668 + for ( ; array[i]; i++ ) {
10.4669 + ret.push( array[i] );
10.4670 + }
10.4671 + }
10.4672 + }
10.4673 +
10.4674 + return ret;
10.4675 + };
10.4676 +}
10.4677 +
10.4678 +var sortOrder, siblingCheck;
10.4679 +
10.4680 +if ( document.documentElement.compareDocumentPosition ) {
10.4681 + sortOrder = function( a, b ) {
10.4682 + if ( a === b ) {
10.4683 + hasDuplicate = true;
10.4684 + return 0;
10.4685 + }
10.4686 +
10.4687 + if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
10.4688 + return a.compareDocumentPosition ? -1 : 1;
10.4689 + }
10.4690 +
10.4691 + return a.compareDocumentPosition(b) & 4 ? -1 : 1;
10.4692 + };
10.4693 +
10.4694 +} else {
10.4695 + sortOrder = function( a, b ) {
10.4696 + // The nodes are identical, we can exit early
10.4697 + if ( a === b ) {
10.4698 + hasDuplicate = true;
10.4699 + return 0;
10.4700 +
10.4701 + // Fallback to using sourceIndex (in IE) if it's available on both nodes
10.4702 + } else if ( a.sourceIndex && b.sourceIndex ) {
10.4703 + return a.sourceIndex - b.sourceIndex;
10.4704 + }
10.4705 +
10.4706 + var al, bl,
10.4707 + ap = [],
10.4708 + bp = [],
10.4709 + aup = a.parentNode,
10.4710 + bup = b.parentNode,
10.4711 + cur = aup;
10.4712 +
10.4713 + // If the nodes are siblings (or identical) we can do a quick check
10.4714 + if ( aup === bup ) {
10.4715 + return siblingCheck( a, b );
10.4716 +
10.4717 + // If no parents were found then the nodes are disconnected
10.4718 + } else if ( !aup ) {
10.4719 + return -1;
10.4720 +
10.4721 + } else if ( !bup ) {
10.4722 + return 1;
10.4723 + }
10.4724 +
10.4725 + // Otherwise they're somewhere else in the tree so we need
10.4726 + // to build up a full list of the parentNodes for comparison
10.4727 + while ( cur ) {
10.4728 + ap.unshift( cur );
10.4729 + cur = cur.parentNode;
10.4730 + }
10.4731 +
10.4732 + cur = bup;
10.4733 +
10.4734 + while ( cur ) {
10.4735 + bp.unshift( cur );
10.4736 + cur = cur.parentNode;
10.4737 + }
10.4738 +
10.4739 + al = ap.length;
10.4740 + bl = bp.length;
10.4741 +
10.4742 + // Start walking down the tree looking for a discrepancy
10.4743 + for ( var i = 0; i < al && i < bl; i++ ) {
10.4744 + if ( ap[i] !== bp[i] ) {
10.4745 + return siblingCheck( ap[i], bp[i] );
10.4746 + }
10.4747 + }
10.4748 +
10.4749 + // We ended someplace up the tree so do a sibling check
10.4750 + return i === al ?
10.4751 + siblingCheck( a, bp[i], -1 ) :
10.4752 + siblingCheck( ap[i], b, 1 );
10.4753 + };
10.4754 +
10.4755 + siblingCheck = function( a, b, ret ) {
10.4756 + if ( a === b ) {
10.4757 + return ret;
10.4758 + }
10.4759 +
10.4760 + var cur = a.nextSibling;
10.4761 +
10.4762 + while ( cur ) {
10.4763 + if ( cur === b ) {
10.4764 + return -1;
10.4765 + }
10.4766 +
10.4767 + cur = cur.nextSibling;
10.4768 + }
10.4769 +
10.4770 + return 1;
10.4771 + };
10.4772 +}
10.4773 +
10.4774 +// Utility function for retreiving the text value of an array of DOM nodes
10.4775 +Sizzle.getText = function( elems ) {
10.4776 + var ret = "", elem;
10.4777 +
10.4778 + for ( var i = 0; elems[i]; i++ ) {
10.4779 + elem = elems[i];
10.4780 +
10.4781 + // Get the text from text nodes and CDATA nodes
10.4782 + if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
10.4783 + ret += elem.nodeValue;
10.4784 +
10.4785 + // Traverse everything else, except comment nodes
10.4786 + } else if ( elem.nodeType !== 8 ) {
10.4787 + ret += Sizzle.getText( elem.childNodes );
10.4788 + }
10.4789 + }
10.4790 +
10.4791 + return ret;
10.4792 +};
10.4793 +
10.4794 +// Check to see if the browser returns elements by name when
10.4795 +// querying by getElementById (and provide a workaround)
10.4796 +(function(){
10.4797 + // We're going to inject a fake input element with a specified name
10.4798 + var form = document.createElement("div"),
10.4799 + id = "script" + (new Date()).getTime(),
10.4800 + root = document.documentElement;
10.4801 +
10.4802 + form.innerHTML = "<a name='" + id + "'/>";
10.4803 +
10.4804 + // Inject it into the root element, check its status, and remove it quickly
10.4805 + root.insertBefore( form, root.firstChild );
10.4806 +
10.4807 + // The workaround has to do additional checks after a getElementById
10.4808 + // Which slows things down for other browsers (hence the branching)
10.4809 + if ( document.getElementById( id ) ) {
10.4810 + Expr.find.ID = function( match, context, isXML ) {
10.4811 + if ( typeof context.getElementById !== "undefined" && !isXML ) {
10.4812 + var m = context.getElementById(match[1]);
10.4813 +
10.4814 + return m ?
10.4815 + m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
10.4816 + [m] :
10.4817 + undefined :
10.4818 + [];
10.4819 + }
10.4820 + };
10.4821 +
10.4822 + Expr.filter.ID = function( elem, match ) {
10.4823 + var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
10.4824 +
10.4825 + return elem.nodeType === 1 && node && node.nodeValue === match;
10.4826 + };
10.4827 + }
10.4828 +
10.4829 + root.removeChild( form );
10.4830 +
10.4831 + // release memory in IE
10.4832 + root = form = null;
10.4833 +})();
10.4834 +
10.4835 +(function(){
10.4836 + // Check to see if the browser returns only elements
10.4837 + // when doing getElementsByTagName("*")
10.4838 +
10.4839 + // Create a fake element
10.4840 + var div = document.createElement("div");
10.4841 + div.appendChild( document.createComment("") );
10.4842 +
10.4843 + // Make sure no comments are found
10.4844 + if ( div.getElementsByTagName("*").length > 0 ) {
10.4845 + Expr.find.TAG = function( match, context ) {
10.4846 + var results = context.getElementsByTagName( match[1] );
10.4847 +
10.4848 + // Filter out possible comments
10.4849 + if ( match[1] === "*" ) {
10.4850 + var tmp = [];
10.4851 +
10.4852 + for ( var i = 0; results[i]; i++ ) {
10.4853 + if ( results[i].nodeType === 1 ) {
10.4854 + tmp.push( results[i] );
10.4855 + }
10.4856 + }
10.4857 +
10.4858 + results = tmp;
10.4859 + }
10.4860 +
10.4861 + return results;
10.4862 + };
10.4863 + }
10.4864 +
10.4865 + // Check to see if an attribute returns normalized href attributes
10.4866 + div.innerHTML = "<a href='#'></a>";
10.4867 +
10.4868 + if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
10.4869 + div.firstChild.getAttribute("href") !== "#" ) {
10.4870 +
10.4871 + Expr.attrHandle.href = function( elem ) {
10.4872 + return elem.getAttribute( "href", 2 );
10.4873 + };
10.4874 + }
10.4875 +
10.4876 + // release memory in IE
10.4877 + div = null;
10.4878 +})();
10.4879 +
10.4880 +if ( document.querySelectorAll ) {
10.4881 + (function(){
10.4882 + var oldSizzle = Sizzle,
10.4883 + div = document.createElement("div"),
10.4884 + id = "__sizzle__";
10.4885 +
10.4886 + div.innerHTML = "<p class='TEST'></p>";
10.4887 +
10.4888 + // Safari can't handle uppercase or unicode characters when
10.4889 + // in quirks mode.
10.4890 + if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
10.4891 + return;
10.4892 + }
10.4893 +
10.4894 + Sizzle = function( query, context, extra, seed ) {
10.4895 + context = context || document;
10.4896 +
10.4897 + // Only use querySelectorAll on non-XML documents
10.4898 + // (ID selectors don't work in non-HTML documents)
10.4899 + if ( !seed && !Sizzle.isXML(context) ) {
10.4900 + // See if we find a selector to speed up
10.4901 + var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
10.4902 +
10.4903 + if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
10.4904 + // Speed-up: Sizzle("TAG")
10.4905 + if ( match[1] ) {
10.4906 + return makeArray( context.getElementsByTagName( query ), extra );
10.4907 +
10.4908 + // Speed-up: Sizzle(".CLASS")
10.4909 + } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
10.4910 + return makeArray( context.getElementsByClassName( match[2] ), extra );
10.4911 + }
10.4912 + }
10.4913 +
10.4914 + if ( context.nodeType === 9 ) {
10.4915 + // Speed-up: Sizzle("body")
10.4916 + // The body element only exists once, optimize finding it
10.4917 + if ( query === "body" && context.body ) {
10.4918 + return makeArray( [ context.body ], extra );
10.4919 +
10.4920 + // Speed-up: Sizzle("#ID")
10.4921 + } else if ( match && match[3] ) {
10.4922 + var elem = context.getElementById( match[3] );
10.4923 +
10.4924 + // Check parentNode to catch when Blackberry 4.6 returns
10.4925 + // nodes that are no longer in the document #6963
10.4926 + if ( elem && elem.parentNode ) {
10.4927 + // Handle the case where IE and Opera return items
10.4928 + // by name instead of ID
10.4929 + if ( elem.id === match[3] ) {
10.4930 + return makeArray( [ elem ], extra );
10.4931 + }
10.4932 +
10.4933 + } else {
10.4934 + return makeArray( [], extra );
10.4935 + }
10.4936 + }
10.4937 +
10.4938 + try {
10.4939 + return makeArray( context.querySelectorAll(query), extra );
10.4940 + } catch(qsaError) {}
10.4941 +
10.4942 + // qSA works strangely on Element-rooted queries
10.4943 + // We can work around this by specifying an extra ID on the root
10.4944 + // and working up from there (Thanks to Andrew Dupont for the technique)
10.4945 + // IE 8 doesn't work on object elements
10.4946 + } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
10.4947 + var oldContext = context,
10.4948 + old = context.getAttribute( "id" ),
10.4949 + nid = old || id,
10.4950 + hasParent = context.parentNode,
10.4951 + relativeHierarchySelector = /^\s*[+~]/.test( query );
10.4952 +
10.4953 + if ( !old ) {
10.4954 + context.setAttribute( "id", nid );
10.4955 + } else {
10.4956 + nid = nid.replace( /'/g, "\\$&" );
10.4957 + }
10.4958 + if ( relativeHierarchySelector && hasParent ) {
10.4959 + context = context.parentNode;
10.4960 + }
10.4961 +
10.4962 + try {
10.4963 + if ( !relativeHierarchySelector || hasParent ) {
10.4964 + return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
10.4965 + }
10.4966 +
10.4967 + } catch(pseudoError) {
10.4968 + } finally {
10.4969 + if ( !old ) {
10.4970 + oldContext.removeAttribute( "id" );
10.4971 + }
10.4972 + }
10.4973 + }
10.4974 + }
10.4975 +
10.4976 + return oldSizzle(query, context, extra, seed);
10.4977 + };
10.4978 +
10.4979 + for ( var prop in oldSizzle ) {
10.4980 + Sizzle[ prop ] = oldSizzle[ prop ];
10.4981 + }
10.4982 +
10.4983 + // release memory in IE
10.4984 + div = null;
10.4985 + })();
10.4986 +}
10.4987 +
10.4988 +(function(){
10.4989 + var html = document.documentElement,
10.4990 + matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
10.4991 +
10.4992 + if ( matches ) {
10.4993 + // Check to see if it's possible to do matchesSelector
10.4994 + // on a disconnected node (IE 9 fails this)
10.4995 + var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
10.4996 + pseudoWorks = false;
10.4997 +
10.4998 + try {
10.4999 + // This should fail with an exception
10.5000 + // Gecko does not error, returns false instead
10.5001 + matches.call( document.documentElement, "[test!='']:sizzle" );
10.5002 +
10.5003 + } catch( pseudoError ) {
10.5004 + pseudoWorks = true;
10.5005 + }
10.5006 +
10.5007 + Sizzle.matchesSelector = function( node, expr ) {
10.5008 + // Make sure that attribute selectors are quoted
10.5009 + expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
10.5010 +
10.5011 + if ( !Sizzle.isXML( node ) ) {
10.5012 + try {
10.5013 + if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
10.5014 + var ret = matches.call( node, expr );
10.5015 +
10.5016 + // IE 9's matchesSelector returns false on disconnected nodes
10.5017 + if ( ret || !disconnectedMatch ||
10.5018 + // As well, disconnected nodes are said to be in a document
10.5019 + // fragment in IE 9, so check for that
10.5020 + node.document && node.document.nodeType !== 11 ) {
10.5021 + return ret;
10.5022 + }
10.5023 + }
10.5024 + } catch(e) {}
10.5025 + }
10.5026 +
10.5027 + return Sizzle(expr, null, null, [node]).length > 0;
10.5028 + };
10.5029 + }
10.5030 +})();
10.5031 +
10.5032 +(function(){
10.5033 + var div = document.createElement("div");
10.5034 +
10.5035 + div.innerHTML = "<div class='test e'></div><div class='test'></div>";
10.5036 +
10.5037 + // Opera can't find a second classname (in 9.6)
10.5038 + // Also, make sure that getElementsByClassName actually exists
10.5039 + if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
10.5040 + return;
10.5041 + }
10.5042 +
10.5043 + // Safari caches class attributes, doesn't catch changes (in 3.2)
10.5044 + div.lastChild.className = "e";
10.5045 +
10.5046 + if ( div.getElementsByClassName("e").length === 1 ) {
10.5047 + return;
10.5048 + }
10.5049 +
10.5050 + Expr.order.splice(1, 0, "CLASS");
10.5051 + Expr.find.CLASS = function( match, context, isXML ) {
10.5052 + if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
10.5053 + return context.getElementsByClassName(match[1]);
10.5054 + }
10.5055 + };
10.5056 +
10.5057 + // release memory in IE
10.5058 + div = null;
10.5059 +})();
10.5060 +
10.5061 +function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
10.5062 + for ( var i = 0, l = checkSet.length; i < l; i++ ) {
10.5063 + var elem = checkSet[i];
10.5064 +
10.5065 + if ( elem ) {
10.5066 + var match = false;
10.5067 +
10.5068 + elem = elem[dir];
10.5069 +
10.5070 + while ( elem ) {
10.5071 + if ( elem.sizcache === doneName ) {
10.5072 + match = checkSet[elem.sizset];
10.5073 + break;
10.5074 + }
10.5075 +
10.5076 + if ( elem.nodeType === 1 && !isXML ){
10.5077 + elem.sizcache = doneName;
10.5078 + elem.sizset = i;
10.5079 + }
10.5080 +
10.5081 + if ( elem.nodeName.toLowerCase() === cur ) {
10.5082 + match = elem;
10.5083 + break;
10.5084 + }
10.5085 +
10.5086 + elem = elem[dir];
10.5087 + }
10.5088 +
10.5089 + checkSet[i] = match;
10.5090 + }
10.5091 + }
10.5092 +}
10.5093 +
10.5094 +function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
10.5095 + for ( var i = 0, l = checkSet.length; i < l; i++ ) {
10.5096 + var elem = checkSet[i];
10.5097 +
10.5098 + if ( elem ) {
10.5099 + var match = false;
10.5100 +
10.5101 + elem = elem[dir];
10.5102 +
10.5103 + while ( elem ) {
10.5104 + if ( elem.sizcache === doneName ) {
10.5105 + match = checkSet[elem.sizset];
10.5106 + break;
10.5107 + }
10.5108 +
10.5109 + if ( elem.nodeType === 1 ) {
10.5110 + if ( !isXML ) {
10.5111 + elem.sizcache = doneName;
10.5112 + elem.sizset = i;
10.5113 + }
10.5114 +
10.5115 + if ( typeof cur !== "string" ) {
10.5116 + if ( elem === cur ) {
10.5117 + match = true;
10.5118 + break;
10.5119 + }
10.5120 +
10.5121 + } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
10.5122 + match = elem;
10.5123 + break;
10.5124 + }
10.5125 + }
10.5126 +
10.5127 + elem = elem[dir];
10.5128 + }
10.5129 +
10.5130 + checkSet[i] = match;
10.5131 + }
10.5132 + }
10.5133 +}
10.5134 +
10.5135 +if ( document.documentElement.contains ) {
10.5136 + Sizzle.contains = function( a, b ) {
10.5137 + return a !== b && (a.contains ? a.contains(b) : true);
10.5138 + };
10.5139 +
10.5140 +} else if ( document.documentElement.compareDocumentPosition ) {
10.5141 + Sizzle.contains = function( a, b ) {
10.5142 + return !!(a.compareDocumentPosition(b) & 16);
10.5143 + };
10.5144 +
10.5145 +} else {
10.5146 + Sizzle.contains = function() {
10.5147 + return false;
10.5148 + };
10.5149 +}
10.5150 +
10.5151 +Sizzle.isXML = function( elem ) {
10.5152 + // documentElement is verified for cases where it doesn't yet exist
10.5153 + // (such as loading iframes in IE - #4833)
10.5154 + var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
10.5155 +
10.5156 + return documentElement ? documentElement.nodeName !== "HTML" : false;
10.5157 +};
10.5158 +
10.5159 +var posProcess = function( selector, context ) {
10.5160 + var match,
10.5161 + tmpSet = [],
10.5162 + later = "",
10.5163 + root = context.nodeType ? [context] : context;
10.5164 +
10.5165 + // Position selectors must be done after the filter
10.5166 + // And so must :not(positional) so we move all PSEUDOs to the end
10.5167 + while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
10.5168 + later += match[0];
10.5169 + selector = selector.replace( Expr.match.PSEUDO, "" );
10.5170 + }
10.5171 +
10.5172 + selector = Expr.relative[selector] ? selector + "*" : selector;
10.5173 +
10.5174 + for ( var i = 0, l = root.length; i < l; i++ ) {
10.5175 + Sizzle( selector, root[i], tmpSet );
10.5176 + }
10.5177 +
10.5178 + return Sizzle.filter( later, tmpSet );
10.5179 +};
10.5180 +
10.5181 +// EXPOSE
10.5182 +jQuery.find = Sizzle;
10.5183 +jQuery.expr = Sizzle.selectors;
10.5184 +jQuery.expr[":"] = jQuery.expr.filters;
10.5185 +jQuery.unique = Sizzle.uniqueSort;
10.5186 +jQuery.text = Sizzle.getText;
10.5187 +jQuery.isXMLDoc = Sizzle.isXML;
10.5188 +jQuery.contains = Sizzle.contains;
10.5189 +
10.5190 +
10.5191 +})();
10.5192 +
10.5193 +
10.5194 +var runtil = /Until$/,
10.5195 + rparentsprev = /^(?:parents|prevUntil|prevAll)/,
10.5196 + // Note: This RegExp should be improved, or likely pulled from Sizzle
10.5197 + rmultiselector = /,/,
10.5198 + isSimple = /^.[^:#\[\.,]*$/,
10.5199 + slice = Array.prototype.slice,
10.5200 + POS = jQuery.expr.match.POS,
10.5201 + // methods guaranteed to produce a unique set when starting from a unique set
10.5202 + guaranteedUnique = {
10.5203 + children: true,
10.5204 + contents: true,
10.5205 + next: true,
10.5206 + prev: true
10.5207 + };
10.5208 +
10.5209 +jQuery.fn.extend({
10.5210 + find: function( selector ) {
10.5211 + var self = this,
10.5212 + i, l;
10.5213 +
10.5214 + if ( typeof selector !== "string" ) {
10.5215 + return jQuery( selector ).filter(function() {
10.5216 + for ( i = 0, l = self.length; i < l; i++ ) {
10.5217 + if ( jQuery.contains( self[ i ], this ) ) {
10.5218 + return true;
10.5219 + }
10.5220 + }
10.5221 + });
10.5222 + }
10.5223 +
10.5224 + var ret = this.pushStack( "", "find", selector ),
10.5225 + length, n, r;
10.5226 +
10.5227 + for ( i = 0, l = this.length; i < l; i++ ) {
10.5228 + length = ret.length;
10.5229 + jQuery.find( selector, this[i], ret );
10.5230 +
10.5231 + if ( i > 0 ) {
10.5232 + // Make sure that the results are unique
10.5233 + for ( n = length; n < ret.length; n++ ) {
10.5234 + for ( r = 0; r < length; r++ ) {
10.5235 + if ( ret[r] === ret[n] ) {
10.5236 + ret.splice(n--, 1);
10.5237 + break;
10.5238 + }
10.5239 + }
10.5240 + }
10.5241 + }
10.5242 + }
10.5243 +
10.5244 + return ret;
10.5245 + },
10.5246 +
10.5247 + has: function( target ) {
10.5248 + var targets = jQuery( target );
10.5249 + return this.filter(function() {
10.5250 + for ( var i = 0, l = targets.length; i < l; i++ ) {
10.5251 + if ( jQuery.contains( this, targets[i] ) ) {
10.5252 + return true;
10.5253 + }
10.5254 + }
10.5255 + });
10.5256 + },
10.5257 +
10.5258 + not: function( selector ) {
10.5259 + return this.pushStack( winnow(this, selector, false), "not", selector);
10.5260 + },
10.5261 +
10.5262 + filter: function( selector ) {
10.5263 + return this.pushStack( winnow(this, selector, true), "filter", selector );
10.5264 + },
10.5265 +
10.5266 + is: function( selector ) {
10.5267 + return !!selector && ( typeof selector === "string" ?
10.5268 + jQuery.filter( selector, this ).length > 0 :
10.5269 + this.filter( selector ).length > 0 );
10.5270 + },
10.5271 +
10.5272 + closest: function( selectors, context ) {
10.5273 + var ret = [], i, l, cur = this[0];
10.5274 +
10.5275 + // Array
10.5276 + if ( jQuery.isArray( selectors ) ) {
10.5277 + var match, selector,
10.5278 + matches = {},
10.5279 + level = 1;
10.5280 +
10.5281 + if ( cur && selectors.length ) {
10.5282 + for ( i = 0, l = selectors.length; i < l; i++ ) {
10.5283 + selector = selectors[i];
10.5284 +
10.5285 + if ( !matches[ selector ] ) {
10.5286 + matches[ selector ] = POS.test( selector ) ?
10.5287 + jQuery( selector, context || this.context ) :
10.5288 + selector;
10.5289 + }
10.5290 + }
10.5291 +
10.5292 + while ( cur && cur.ownerDocument && cur !== context ) {
10.5293 + for ( selector in matches ) {
10.5294 + match = matches[ selector ];
10.5295 +
10.5296 + if ( match.jquery ? match.index( cur ) > -1 : jQuery( cur ).is( match ) ) {
10.5297 + ret.push({ selector: selector, elem: cur, level: level });
10.5298 + }
10.5299 + }
10.5300 +
10.5301 + cur = cur.parentNode;
10.5302 + level++;
10.5303 + }
10.5304 + }
10.5305 +
10.5306 + return ret;
10.5307 + }
10.5308 +
10.5309 + // String
10.5310 + var pos = POS.test( selectors ) || typeof selectors !== "string" ?
10.5311 + jQuery( selectors, context || this.context ) :
10.5312 + 0;
10.5313 +
10.5314 + for ( i = 0, l = this.length; i < l; i++ ) {
10.5315 + cur = this[i];
10.5316 +
10.5317 + while ( cur ) {
10.5318 + if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
10.5319 + ret.push( cur );
10.5320 + break;
10.5321 +
10.5322 + } else {
10.5323 + cur = cur.parentNode;
10.5324 + if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) {
10.5325 + break;
10.5326 + }
10.5327 + }
10.5328 + }
10.5329 + }
10.5330 +
10.5331 + ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
10.5332 +
10.5333 + return this.pushStack( ret, "closest", selectors );
10.5334 + },
10.5335 +
10.5336 + // Determine the position of an element within
10.5337 + // the matched set of elements
10.5338 + index: function( elem ) {
10.5339 +
10.5340 + // No argument, return index in parent
10.5341 + if ( !elem ) {
10.5342 + return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
10.5343 + }
10.5344 +
10.5345 + // index in selector
10.5346 + if ( typeof elem === "string" ) {
10.5347 + return jQuery.inArray( this[0], jQuery( elem ) );
10.5348 + }
10.5349 +
10.5350 + // Locate the position of the desired element
10.5351 + return jQuery.inArray(
10.5352 + // If it receives a jQuery object, the first element is used
10.5353 + elem.jquery ? elem[0] : elem, this );
10.5354 + },
10.5355 +
10.5356 + add: function( selector, context ) {
10.5357 + var set = typeof selector === "string" ?
10.5358 + jQuery( selector, context ) :
10.5359 + jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
10.5360 + all = jQuery.merge( this.get(), set );
10.5361 +
10.5362 + return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
10.5363 + all :
10.5364 + jQuery.unique( all ) );
10.5365 + },
10.5366 +
10.5367 + andSelf: function() {
10.5368 + return this.add( this.prevObject );
10.5369 + }
10.5370 +});
10.5371 +
10.5372 +// A painfully simple check to see if an element is disconnected
10.5373 +// from a document (should be improved, where feasible).
10.5374 +function isDisconnected( node ) {
10.5375 + return !node || !node.parentNode || node.parentNode.nodeType === 11;
10.5376 +}
10.5377 +
10.5378 +jQuery.each({
10.5379 + parent: function( elem ) {
10.5380 + var parent = elem.parentNode;
10.5381 + return parent && parent.nodeType !== 11 ? parent : null;
10.5382 + },
10.5383 + parents: function( elem ) {
10.5384 + return jQuery.dir( elem, "parentNode" );
10.5385 + },
10.5386 + parentsUntil: function( elem, i, until ) {
10.5387 + return jQuery.dir( elem, "parentNode", until );
10.5388 + },
10.5389 + next: function( elem ) {
10.5390 + return jQuery.nth( elem, 2, "nextSibling" );
10.5391 + },
10.5392 + prev: function( elem ) {
10.5393 + return jQuery.nth( elem, 2, "previousSibling" );
10.5394 + },
10.5395 + nextAll: function( elem ) {
10.5396 + return jQuery.dir( elem, "nextSibling" );
10.5397 + },
10.5398 + prevAll: function( elem ) {
10.5399 + return jQuery.dir( elem, "previousSibling" );
10.5400 + },
10.5401 + nextUntil: function( elem, i, until ) {
10.5402 + return jQuery.dir( elem, "nextSibling", until );
10.5403 + },
10.5404 + prevUntil: function( elem, i, until ) {
10.5405 + return jQuery.dir( elem, "previousSibling", until );
10.5406 + },
10.5407 + siblings: function( elem ) {
10.5408 + return jQuery.sibling( elem.parentNode.firstChild, elem );
10.5409 + },
10.5410 + children: function( elem ) {
10.5411 + return jQuery.sibling( elem.firstChild );
10.5412 + },
10.5413 + contents: function( elem ) {
10.5414 + return jQuery.nodeName( elem, "iframe" ) ?
10.5415 + elem.contentDocument || elem.contentWindow.document :
10.5416 + jQuery.makeArray( elem.childNodes );
10.5417 + }
10.5418 +}, function( name, fn ) {
10.5419 + jQuery.fn[ name ] = function( until, selector ) {
10.5420 + var ret = jQuery.map( this, fn, until ),
10.5421 + // The variable 'args' was introduced in
10.5422 + // https://github.com/jquery/jquery/commit/52a0238
10.5423 + // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
10.5424 + // http://code.google.com/p/v8/issues/detail?id=1050
10.5425 + args = slice.call(arguments);
10.5426 +
10.5427 + if ( !runtil.test( name ) ) {
10.5428 + selector = until;
10.5429 + }
10.5430 +
10.5431 + if ( selector && typeof selector === "string" ) {
10.5432 + ret = jQuery.filter( selector, ret );
10.5433 + }
10.5434 +
10.5435 + ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
10.5436 +
10.5437 + if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
10.5438 + ret = ret.reverse();
10.5439 + }
10.5440 +
10.5441 + return this.pushStack( ret, name, args.join(",") );
10.5442 + };
10.5443 +});
10.5444 +
10.5445 +jQuery.extend({
10.5446 + filter: function( expr, elems, not ) {
10.5447 + if ( not ) {
10.5448 + expr = ":not(" + expr + ")";
10.5449 + }
10.5450 +
10.5451 + return elems.length === 1 ?
10.5452 + jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
10.5453 + jQuery.find.matches(expr, elems);
10.5454 + },
10.5455 +
10.5456 + dir: function( elem, dir, until ) {
10.5457 + var matched = [],
10.5458 + cur = elem[ dir ];
10.5459 +
10.5460 + while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
10.5461 + if ( cur.nodeType === 1 ) {
10.5462 + matched.push( cur );
10.5463 + }
10.5464 + cur = cur[dir];
10.5465 + }
10.5466 + return matched;
10.5467 + },
10.5468 +
10.5469 + nth: function( cur, result, dir, elem ) {
10.5470 + result = result || 1;
10.5471 + var num = 0;
10.5472 +
10.5473 + for ( ; cur; cur = cur[dir] ) {
10.5474 + if ( cur.nodeType === 1 && ++num === result ) {
10.5475 + break;
10.5476 + }
10.5477 + }
10.5478 +
10.5479 + return cur;
10.5480 + },
10.5481 +
10.5482 + sibling: function( n, elem ) {
10.5483 + var r = [];
10.5484 +
10.5485 + for ( ; n; n = n.nextSibling ) {
10.5486 + if ( n.nodeType === 1 && n !== elem ) {
10.5487 + r.push( n );
10.5488 + }
10.5489 + }
10.5490 +
10.5491 + return r;
10.5492 + }
10.5493 +});
10.5494 +
10.5495 +// Implement the identical functionality for filter and not
10.5496 +function winnow( elements, qualifier, keep ) {
10.5497 +
10.5498 + // Can't pass null or undefined to indexOf in Firefox 4
10.5499 + // Set to 0 to skip string check
10.5500 + qualifier = qualifier || 0;
10.5501 +
10.5502 + if ( jQuery.isFunction( qualifier ) ) {
10.5503 + return jQuery.grep(elements, function( elem, i ) {
10.5504 + var retVal = !!qualifier.call( elem, i, elem );
10.5505 + return retVal === keep;
10.5506 + });
10.5507 +
10.5508 + } else if ( qualifier.nodeType ) {
10.5509 + return jQuery.grep(elements, function( elem, i ) {
10.5510 + return (elem === qualifier) === keep;
10.5511 + });
10.5512 +
10.5513 + } else if ( typeof qualifier === "string" ) {
10.5514 + var filtered = jQuery.grep(elements, function( elem ) {
10.5515 + return elem.nodeType === 1;
10.5516 + });
10.5517 +
10.5518 + if ( isSimple.test( qualifier ) ) {
10.5519 + return jQuery.filter(qualifier, filtered, !keep);
10.5520 + } else {
10.5521 + qualifier = jQuery.filter( qualifier, filtered );
10.5522 + }
10.5523 + }
10.5524 +
10.5525 + return jQuery.grep(elements, function( elem, i ) {
10.5526 + return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
10.5527 + });
10.5528 +}
10.5529 +
10.5530 +
10.5531 +
10.5532 +
10.5533 +var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
10.5534 + rleadingWhitespace = /^\s+/,
10.5535 + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
10.5536 + rtagName = /<([\w:]+)/,
10.5537 + rtbody = /<tbody/i,
10.5538 + rhtml = /<|&#?\w+;/,
10.5539 + rnocache = /<(?:script|object|embed|option|style)/i,
10.5540 + // checked="checked" or checked
10.5541 + rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
10.5542 + rscriptType = /\/(java|ecma)script/i,
10.5543 + rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/,
10.5544 + wrapMap = {
10.5545 + option: [ 1, "<select multiple='multiple'>", "</select>" ],
10.5546 + legend: [ 1, "<fieldset>", "</fieldset>" ],
10.5547 + thead: [ 1, "<table>", "</table>" ],
10.5548 + tr: [ 2, "<table><tbody>", "</tbody></table>" ],
10.5549 + td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
10.5550 + col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
10.5551 + area: [ 1, "<map>", "</map>" ],
10.5552 + _default: [ 0, "", "" ]
10.5553 + };
10.5554 +
10.5555 +wrapMap.optgroup = wrapMap.option;
10.5556 +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
10.5557 +wrapMap.th = wrapMap.td;
10.5558 +
10.5559 +// IE can't serialize <link> and <script> tags normally
10.5560 +if ( !jQuery.support.htmlSerialize ) {
10.5561 + wrapMap._default = [ 1, "div<div>", "</div>" ];
10.5562 +}
10.5563 +
10.5564 +jQuery.fn.extend({
10.5565 + text: function( text ) {
10.5566 + if ( jQuery.isFunction(text) ) {
10.5567 + return this.each(function(i) {
10.5568 + var self = jQuery( this );
10.5569 +
10.5570 + self.text( text.call(this, i, self.text()) );
10.5571 + });
10.5572 + }
10.5573 +
10.5574 + if ( typeof text !== "object" && text !== undefined ) {
10.5575 + return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
10.5576 + }
10.5577 +
10.5578 + return jQuery.text( this );
10.5579 + },
10.5580 +
10.5581 + wrapAll: function( html ) {
10.5582 + if ( jQuery.isFunction( html ) ) {
10.5583 + return this.each(function(i) {
10.5584 + jQuery(this).wrapAll( html.call(this, i) );
10.5585 + });
10.5586 + }
10.5587 +
10.5588 + if ( this[0] ) {
10.5589 + // The elements to wrap the target around
10.5590 + var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
10.5591 +
10.5592 + if ( this[0].parentNode ) {
10.5593 + wrap.insertBefore( this[0] );
10.5594 + }
10.5595 +
10.5596 + wrap.map(function() {
10.5597 + var elem = this;
10.5598 +
10.5599 + while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
10.5600 + elem = elem.firstChild;
10.5601 + }
10.5602 +
10.5603 + return elem;
10.5604 + }).append( this );
10.5605 + }
10.5606 +
10.5607 + return this;
10.5608 + },
10.5609 +
10.5610 + wrapInner: function( html ) {
10.5611 + if ( jQuery.isFunction( html ) ) {
10.5612 + return this.each(function(i) {
10.5613 + jQuery(this).wrapInner( html.call(this, i) );
10.5614 + });
10.5615 + }
10.5616 +
10.5617 + return this.each(function() {
10.5618 + var self = jQuery( this ),
10.5619 + contents = self.contents();
10.5620 +
10.5621 + if ( contents.length ) {
10.5622 + contents.wrapAll( html );
10.5623 +
10.5624 + } else {
10.5625 + self.append( html );
10.5626 + }
10.5627 + });
10.5628 + },
10.5629 +
10.5630 + wrap: function( html ) {
10.5631 + return this.each(function() {
10.5632 + jQuery( this ).wrapAll( html );
10.5633 + });
10.5634 + },
10.5635 +
10.5636 + unwrap: function() {
10.5637 + return this.parent().each(function() {
10.5638 + if ( !jQuery.nodeName( this, "body" ) ) {
10.5639 + jQuery( this ).replaceWith( this.childNodes );
10.5640 + }
10.5641 + }).end();
10.5642 + },
10.5643 +
10.5644 + append: function() {
10.5645 + return this.domManip(arguments, true, function( elem ) {
10.5646 + if ( this.nodeType === 1 ) {
10.5647 + this.appendChild( elem );
10.5648 + }
10.5649 + });
10.5650 + },
10.5651 +
10.5652 + prepend: function() {
10.5653 + return this.domManip(arguments, true, function( elem ) {
10.5654 + if ( this.nodeType === 1 ) {
10.5655 + this.insertBefore( elem, this.firstChild );
10.5656 + }
10.5657 + });
10.5658 + },
10.5659 +
10.5660 + before: function() {
10.5661 + if ( this[0] && this[0].parentNode ) {
10.5662 + return this.domManip(arguments, false, function( elem ) {
10.5663 + this.parentNode.insertBefore( elem, this );
10.5664 + });
10.5665 + } else if ( arguments.length ) {
10.5666 + var set = jQuery(arguments[0]);
10.5667 + set.push.apply( set, this.toArray() );
10.5668 + return this.pushStack( set, "before", arguments );
10.5669 + }
10.5670 + },
10.5671 +
10.5672 + after: function() {
10.5673 + if ( this[0] && this[0].parentNode ) {
10.5674 + return this.domManip(arguments, false, function( elem ) {
10.5675 + this.parentNode.insertBefore( elem, this.nextSibling );
10.5676 + });
10.5677 + } else if ( arguments.length ) {
10.5678 + var set = this.pushStack( this, "after", arguments );
10.5679 + set.push.apply( set, jQuery(arguments[0]).toArray() );
10.5680 + return set;
10.5681 + }
10.5682 + },
10.5683 +
10.5684 + // keepData is for internal use only--do not document
10.5685 + remove: function( selector, keepData ) {
10.5686 + for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
10.5687 + if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
10.5688 + if ( !keepData && elem.nodeType === 1 ) {
10.5689 + jQuery.cleanData( elem.getElementsByTagName("*") );
10.5690 + jQuery.cleanData( [ elem ] );
10.5691 + }
10.5692 +
10.5693 + if ( elem.parentNode ) {
10.5694 + elem.parentNode.removeChild( elem );
10.5695 + }
10.5696 + }
10.5697 + }
10.5698 +
10.5699 + return this;
10.5700 + },
10.5701 +
10.5702 + empty: function() {
10.5703 + for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
10.5704 + // Remove element nodes and prevent memory leaks
10.5705 + if ( elem.nodeType === 1 ) {
10.5706 + jQuery.cleanData( elem.getElementsByTagName("*") );
10.5707 + }
10.5708 +
10.5709 + // Remove any remaining nodes
10.5710 + while ( elem.firstChild ) {
10.5711 + elem.removeChild( elem.firstChild );
10.5712 + }
10.5713 + }
10.5714 +
10.5715 + return this;
10.5716 + },
10.5717 +
10.5718 + clone: function( dataAndEvents, deepDataAndEvents ) {
10.5719 + dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
10.5720 + deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
10.5721 +
10.5722 + return this.map( function () {
10.5723 + return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
10.5724 + });
10.5725 + },
10.5726 +
10.5727 + html: function( value ) {
10.5728 + if ( value === undefined ) {
10.5729 + return this[0] && this[0].nodeType === 1 ?
10.5730 + this[0].innerHTML.replace(rinlinejQuery, "") :
10.5731 + null;
10.5732 +
10.5733 + // See if we can take a shortcut and just use innerHTML
10.5734 + } else if ( typeof value === "string" && !rnocache.test( value ) &&
10.5735 + (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
10.5736 + !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
10.5737 +
10.5738 + value = value.replace(rxhtmlTag, "<$1></$2>");
10.5739 +
10.5740 + try {
10.5741 + for ( var i = 0, l = this.length; i < l; i++ ) {
10.5742 + // Remove element nodes and prevent memory leaks
10.5743 + if ( this[i].nodeType === 1 ) {
10.5744 + jQuery.cleanData( this[i].getElementsByTagName("*") );
10.5745 + this[i].innerHTML = value;
10.5746 + }
10.5747 + }
10.5748 +
10.5749 + // If using innerHTML throws an exception, use the fallback method
10.5750 + } catch(e) {
10.5751 + this.empty().append( value );
10.5752 + }
10.5753 +
10.5754 + } else if ( jQuery.isFunction( value ) ) {
10.5755 + this.each(function(i){
10.5756 + var self = jQuery( this );
10.5757 +
10.5758 + self.html( value.call(this, i, self.html()) );
10.5759 + });
10.5760 +
10.5761 + } else {
10.5762 + this.empty().append( value );
10.5763 + }
10.5764 +
10.5765 + return this;
10.5766 + },
10.5767 +
10.5768 + replaceWith: function( value ) {
10.5769 + if ( this[0] && this[0].parentNode ) {
10.5770 + // Make sure that the elements are removed from the DOM before they are inserted
10.5771 + // this can help fix replacing a parent with child elements
10.5772 + if ( jQuery.isFunction( value ) ) {
10.5773 + return this.each(function(i) {
10.5774 + var self = jQuery(this), old = self.html();
10.5775 + self.replaceWith( value.call( this, i, old ) );
10.5776 + });
10.5777 + }
10.5778 +
10.5779 + if ( typeof value !== "string" ) {
10.5780 + value = jQuery( value ).detach();
10.5781 + }
10.5782 +
10.5783 + return this.each(function() {
10.5784 + var next = this.nextSibling,
10.5785 + parent = this.parentNode;
10.5786 +
10.5787 + jQuery( this ).remove();
10.5788 +
10.5789 + if ( next ) {
10.5790 + jQuery(next).before( value );
10.5791 + } else {
10.5792 + jQuery(parent).append( value );
10.5793 + }
10.5794 + });
10.5795 + } else {
10.5796 + return this.length ?
10.5797 + this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
10.5798 + this;
10.5799 + }
10.5800 + },
10.5801 +
10.5802 + detach: function( selector ) {
10.5803 + return this.remove( selector, true );
10.5804 + },
10.5805 +
10.5806 + domManip: function( args, table, callback ) {
10.5807 + var results, first, fragment, parent,
10.5808 + value = args[0],
10.5809 + scripts = [];
10.5810 +
10.5811 + // We can't cloneNode fragments that contain checked, in WebKit
10.5812 + if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
10.5813 + return this.each(function() {
10.5814 + jQuery(this).domManip( args, table, callback, true );
10.5815 + });
10.5816 + }
10.5817 +
10.5818 + if ( jQuery.isFunction(value) ) {
10.5819 + return this.each(function(i) {
10.5820 + var self = jQuery(this);
10.5821 + args[0] = value.call(this, i, table ? self.html() : undefined);
10.5822 + self.domManip( args, table, callback );
10.5823 + });
10.5824 + }
10.5825 +
10.5826 + if ( this[0] ) {
10.5827 + parent = value && value.parentNode;
10.5828 +
10.5829 + // If we're in a fragment, just use that instead of building a new one
10.5830 + if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
10.5831 + results = { fragment: parent };
10.5832 +
10.5833 + } else {
10.5834 + results = jQuery.buildFragment( args, this, scripts );
10.5835 + }
10.5836 +
10.5837 + fragment = results.fragment;
10.5838 +
10.5839 + if ( fragment.childNodes.length === 1 ) {
10.5840 + first = fragment = fragment.firstChild;
10.5841 + } else {
10.5842 + first = fragment.firstChild;
10.5843 + }
10.5844 +
10.5845 + if ( first ) {
10.5846 + table = table && jQuery.nodeName( first, "tr" );
10.5847 +
10.5848 + for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) {
10.5849 + callback.call(
10.5850 + table ?
10.5851 + root(this[i], first) :
10.5852 + this[i],
10.5853 + // Make sure that we do not leak memory by inadvertently discarding
10.5854 + // the original fragment (which might have attached data) instead of
10.5855 + // using it; in addition, use the original fragment object for the last
10.5856 + // item instead of first because it can end up being emptied incorrectly
10.5857 + // in certain situations (Bug #8070).
10.5858 + // Fragments from the fragment cache must always be cloned and never used
10.5859 + // in place.
10.5860 + results.cacheable || (l > 1 && i < lastIndex) ?
10.5861 + jQuery.clone( fragment, true, true ) :
10.5862 + fragment
10.5863 + );
10.5864 + }
10.5865 + }
10.5866 +
10.5867 + if ( scripts.length ) {
10.5868 + jQuery.each( scripts, evalScript );
10.5869 + }
10.5870 + }
10.5871 +
10.5872 + return this;
10.5873 + }
10.5874 +});
10.5875 +
10.5876 +function root( elem, cur ) {
10.5877 + return jQuery.nodeName(elem, "table") ?
10.5878 + (elem.getElementsByTagName("tbody")[0] ||
10.5879 + elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
10.5880 + elem;
10.5881 +}
10.5882 +
10.5883 +function cloneCopyEvent( src, dest ) {
10.5884 +
10.5885 + if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
10.5886 + return;
10.5887 + }
10.5888 +
10.5889 + var internalKey = jQuery.expando,
10.5890 + oldData = jQuery.data( src ),
10.5891 + curData = jQuery.data( dest, oldData );
10.5892 +
10.5893 + // Switch to use the internal data object, if it exists, for the next
10.5894 + // stage of data copying
10.5895 + if ( (oldData = oldData[ internalKey ]) ) {
10.5896 + var events = oldData.events;
10.5897 + curData = curData[ internalKey ] = jQuery.extend({}, oldData);
10.5898 +
10.5899 + if ( events ) {
10.5900 + delete curData.handle;
10.5901 + curData.events = {};
10.5902 +
10.5903 + for ( var type in events ) {
10.5904 + for ( var i = 0, l = events[ type ].length; i < l; i++ ) {
10.5905 + jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data );
10.5906 + }
10.5907 + }
10.5908 + }
10.5909 + }
10.5910 +}
10.5911 +
10.5912 +function cloneFixAttributes( src, dest ) {
10.5913 + var nodeName;
10.5914 +
10.5915 + // We do not need to do anything for non-Elements
10.5916 + if ( dest.nodeType !== 1 ) {
10.5917 + return;
10.5918 + }
10.5919 +
10.5920 + // clearAttributes removes the attributes, which we don't want,
10.5921 + // but also removes the attachEvent events, which we *do* want
10.5922 + if ( dest.clearAttributes ) {
10.5923 + dest.clearAttributes();
10.5924 + }
10.5925 +
10.5926 + // mergeAttributes, in contrast, only merges back on the
10.5927 + // original attributes, not the events
10.5928 + if ( dest.mergeAttributes ) {
10.5929 + dest.mergeAttributes( src );
10.5930 + }
10.5931 +
10.5932 + nodeName = dest.nodeName.toLowerCase();
10.5933 +
10.5934 + // IE6-8 fail to clone children inside object elements that use
10.5935 + // the proprietary classid attribute value (rather than the type
10.5936 + // attribute) to identify the type of content to display
10.5937 + if ( nodeName === "object" ) {
10.5938 + dest.outerHTML = src.outerHTML;
10.5939 +
10.5940 + } else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) {
10.5941 + // IE6-8 fails to persist the checked state of a cloned checkbox
10.5942 + // or radio button. Worse, IE6-7 fail to give the cloned element
10.5943 + // a checked appearance if the defaultChecked value isn't also set
10.5944 + if ( src.checked ) {
10.5945 + dest.defaultChecked = dest.checked = src.checked;
10.5946 + }
10.5947 +
10.5948 + // IE6-7 get confused and end up setting the value of a cloned
10.5949 + // checkbox/radio button to an empty string instead of "on"
10.5950 + if ( dest.value !== src.value ) {
10.5951 + dest.value = src.value;
10.5952 + }
10.5953 +
10.5954 + // IE6-8 fails to return the selected option to the default selected
10.5955 + // state when cloning options
10.5956 + } else if ( nodeName === "option" ) {
10.5957 + dest.selected = src.defaultSelected;
10.5958 +
10.5959 + // IE6-8 fails to set the defaultValue to the correct value when
10.5960 + // cloning other types of input fields
10.5961 + } else if ( nodeName === "input" || nodeName === "textarea" ) {
10.5962 + dest.defaultValue = src.defaultValue;
10.5963 + }
10.5964 +
10.5965 + // Event data gets referenced instead of copied if the expando
10.5966 + // gets copied too
10.5967 + dest.removeAttribute( jQuery.expando );
10.5968 +}
10.5969 +
10.5970 +jQuery.buildFragment = function( args, nodes, scripts ) {
10.5971 + var fragment, cacheable, cacheresults, doc;
10.5972 +
10.5973 + // nodes may contain either an explicit document object,
10.5974 + // a jQuery collection or context object.
10.5975 + // If nodes[0] contains a valid object to assign to doc
10.5976 + if ( nodes && nodes[0] ) {
10.5977 + doc = nodes[0].ownerDocument || nodes[0];
10.5978 + }
10.5979 +
10.5980 + // Ensure that an attr object doesn't incorrectly stand in as a document object
10.5981 + // Chrome and Firefox seem to allow this to occur and will throw exception
10.5982 + // Fixes #8950
10.5983 + if ( !doc.createDocumentFragment ) {
10.5984 + doc = document;
10.5985 + }
10.5986 +
10.5987 + // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
10.5988 + // Cloning options loses the selected state, so don't cache them
10.5989 + // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
10.5990 + // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
10.5991 + if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document &&
10.5992 + args[0].charAt(0) === "<" && !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
10.5993 +
10.5994 + cacheable = true;
10.5995 +
10.5996 + cacheresults = jQuery.fragments[ args[0] ];
10.5997 + if ( cacheresults && cacheresults !== 1 ) {
10.5998 + fragment = cacheresults;
10.5999 + }
10.6000 + }
10.6001 +
10.6002 + if ( !fragment ) {
10.6003 + fragment = doc.createDocumentFragment();
10.6004 + jQuery.clean( args, doc, fragment, scripts );
10.6005 + }
10.6006 +
10.6007 + if ( cacheable ) {
10.6008 + jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
10.6009 + }
10.6010 +
10.6011 + return { fragment: fragment, cacheable: cacheable };
10.6012 +};
10.6013 +
10.6014 +jQuery.fragments = {};
10.6015 +
10.6016 +jQuery.each({
10.6017 + appendTo: "append",
10.6018 + prependTo: "prepend",
10.6019 + insertBefore: "before",
10.6020 + insertAfter: "after",
10.6021 + replaceAll: "replaceWith"
10.6022 +}, function( name, original ) {
10.6023 + jQuery.fn[ name ] = function( selector ) {
10.6024 + var ret = [],
10.6025 + insert = jQuery( selector ),
10.6026 + parent = this.length === 1 && this[0].parentNode;
10.6027 +
10.6028 + if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
10.6029 + insert[ original ]( this[0] );
10.6030 + return this;
10.6031 +
10.6032 + } else {
10.6033 + for ( var i = 0, l = insert.length; i < l; i++ ) {
10.6034 + var elems = (i > 0 ? this.clone(true) : this).get();
10.6035 + jQuery( insert[i] )[ original ]( elems );
10.6036 + ret = ret.concat( elems );
10.6037 + }
10.6038 +
10.6039 + return this.pushStack( ret, name, insert.selector );
10.6040 + }
10.6041 + };
10.6042 +});
10.6043 +
10.6044 +function getAll( elem ) {
10.6045 + if ( "getElementsByTagName" in elem ) {
10.6046 + return elem.getElementsByTagName( "*" );
10.6047 +
10.6048 + } else if ( "querySelectorAll" in elem ) {
10.6049 + return elem.querySelectorAll( "*" );
10.6050 +
10.6051 + } else {
10.6052 + return [];
10.6053 + }
10.6054 +}
10.6055 +
10.6056 +// Used in clean, fixes the defaultChecked property
10.6057 +function fixDefaultChecked( elem ) {
10.6058 + if ( elem.type === "checkbox" || elem.type === "radio" ) {
10.6059 + elem.defaultChecked = elem.checked;
10.6060 + }
10.6061 +}
10.6062 +// Finds all inputs and passes them to fixDefaultChecked
10.6063 +function findInputs( elem ) {
10.6064 + if ( jQuery.nodeName( elem, "input" ) ) {
10.6065 + fixDefaultChecked( elem );
10.6066 + } else if ( "getElementsByTagName" in elem ) {
10.6067 + jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
10.6068 + }
10.6069 +}
10.6070 +
10.6071 +jQuery.extend({
10.6072 + clone: function( elem, dataAndEvents, deepDataAndEvents ) {
10.6073 + var clone = elem.cloneNode(true),
10.6074 + srcElements,
10.6075 + destElements,
10.6076 + i;
10.6077 +
10.6078 + if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
10.6079 + (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
10.6080 + // IE copies events bound via attachEvent when using cloneNode.
10.6081 + // Calling detachEvent on the clone will also remove the events
10.6082 + // from the original. In order to get around this, we use some
10.6083 + // proprietary methods to clear the events. Thanks to MooTools
10.6084 + // guys for this hotness.
10.6085 +
10.6086 + cloneFixAttributes( elem, clone );
10.6087 +
10.6088 + // Using Sizzle here is crazy slow, so we use getElementsByTagName
10.6089 + // instead
10.6090 + srcElements = getAll( elem );
10.6091 + destElements = getAll( clone );
10.6092 +
10.6093 + // Weird iteration because IE will replace the length property
10.6094 + // with an element if you are cloning the body and one of the
10.6095 + // elements on the page has a name or id of "length"
10.6096 + for ( i = 0; srcElements[i]; ++i ) {
10.6097 + // Ensure that the destination node is not null; Fixes #9587
10.6098 + if ( destElements[i] ) {
10.6099 + cloneFixAttributes( srcElements[i], destElements[i] );
10.6100 + }
10.6101 + }
10.6102 + }
10.6103 +
10.6104 + // Copy the events from the original to the clone
10.6105 + if ( dataAndEvents ) {
10.6106 + cloneCopyEvent( elem, clone );
10.6107 +
10.6108 + if ( deepDataAndEvents ) {
10.6109 + srcElements = getAll( elem );
10.6110 + destElements = getAll( clone );
10.6111 +
10.6112 + for ( i = 0; srcElements[i]; ++i ) {
10.6113 + cloneCopyEvent( srcElements[i], destElements[i] );
10.6114 + }
10.6115 + }
10.6116 + }
10.6117 +
10.6118 + srcElements = destElements = null;
10.6119 +
10.6120 + // Return the cloned set
10.6121 + return clone;
10.6122 + },
10.6123 +
10.6124 + clean: function( elems, context, fragment, scripts ) {
10.6125 + var checkScriptType;
10.6126 +
10.6127 + context = context || document;
10.6128 +
10.6129 + // !context.createElement fails in IE with an error but returns typeof 'object'
10.6130 + if ( typeof context.createElement === "undefined" ) {
10.6131 + context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
10.6132 + }
10.6133 +
10.6134 + var ret = [], j;
10.6135 +
10.6136 + for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
10.6137 + if ( typeof elem === "number" ) {
10.6138 + elem += "";
10.6139 + }
10.6140 +
10.6141 + if ( !elem ) {
10.6142 + continue;
10.6143 + }
10.6144 +
10.6145 + // Convert html string into DOM nodes
10.6146 + if ( typeof elem === "string" ) {
10.6147 + if ( !rhtml.test( elem ) ) {
10.6148 + elem = context.createTextNode( elem );
10.6149 + } else {
10.6150 + // Fix "XHTML"-style tags in all browsers
10.6151 + elem = elem.replace(rxhtmlTag, "<$1></$2>");
10.6152 +
10.6153 + // Trim whitespace, otherwise indexOf won't work as expected
10.6154 + var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
10.6155 + wrap = wrapMap[ tag ] || wrapMap._default,
10.6156 + depth = wrap[0],
10.6157 + div = context.createElement("div");
10.6158 +
10.6159 + // Go to html and back, then peel off extra wrappers
10.6160 + div.innerHTML = wrap[1] + elem + wrap[2];
10.6161 +
10.6162 + // Move to the right depth
10.6163 + while ( depth-- ) {
10.6164 + div = div.lastChild;
10.6165 + }
10.6166 +
10.6167 + // Remove IE's autoinserted <tbody> from table fragments
10.6168 + if ( !jQuery.support.tbody ) {
10.6169 +
10.6170 + // String was a <table>, *may* have spurious <tbody>
10.6171 + var hasBody = rtbody.test(elem),
10.6172 + tbody = tag === "table" && !hasBody ?
10.6173 + div.firstChild && div.firstChild.childNodes :
10.6174 +
10.6175 + // String was a bare <thead> or <tfoot>
10.6176 + wrap[1] === "<table>" && !hasBody ?
10.6177 + div.childNodes :
10.6178 + [];
10.6179 +
10.6180 + for ( j = tbody.length - 1; j >= 0 ; --j ) {
10.6181 + if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
10.6182 + tbody[ j ].parentNode.removeChild( tbody[ j ] );
10.6183 + }
10.6184 + }
10.6185 + }
10.6186 +
10.6187 + // IE completely kills leading whitespace when innerHTML is used
10.6188 + if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
10.6189 + div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
10.6190 + }
10.6191 +
10.6192 + elem = div.childNodes;
10.6193 + }
10.6194 + }
10.6195 +
10.6196 + // Resets defaultChecked for any radios and checkboxes
10.6197 + // about to be appended to the DOM in IE 6/7 (#8060)
10.6198 + var len;
10.6199 + if ( !jQuery.support.appendChecked ) {
10.6200 + if ( elem[0] && typeof (len = elem.length) === "number" ) {
10.6201 + for ( j = 0; j < len; j++ ) {
10.6202 + findInputs( elem[j] );
10.6203 + }
10.6204 + } else {
10.6205 + findInputs( elem );
10.6206 + }
10.6207 + }
10.6208 +
10.6209 + if ( elem.nodeType ) {
10.6210 + ret.push( elem );
10.6211 + } else {
10.6212 + ret = jQuery.merge( ret, elem );
10.6213 + }
10.6214 + }
10.6215 +
10.6216 + if ( fragment ) {
10.6217 + checkScriptType = function( elem ) {
10.6218 + return !elem.type || rscriptType.test( elem.type );
10.6219 + };
10.6220 + for ( i = 0; ret[i]; i++ ) {
10.6221 + if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
10.6222 + scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
10.6223 +
10.6224 + } else {
10.6225 + if ( ret[i].nodeType === 1 ) {
10.6226 + var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), checkScriptType );
10.6227 +
10.6228 + ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
10.6229 + }
10.6230 + fragment.appendChild( ret[i] );
10.6231 + }
10.6232 + }
10.6233 + }
10.6234 +
10.6235 + return ret;
10.6236 + },
10.6237 +
10.6238 + cleanData: function( elems ) {
10.6239 + var data, id, cache = jQuery.cache, internalKey = jQuery.expando, special = jQuery.event.special,
10.6240 + deleteExpando = jQuery.support.deleteExpando;
10.6241 +
10.6242 + for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
10.6243 + if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
10.6244 + continue;
10.6245 + }
10.6246 +
10.6247 + id = elem[ jQuery.expando ];
10.6248 +
10.6249 + if ( id ) {
10.6250 + data = cache[ id ] && cache[ id ][ internalKey ];
10.6251 +
10.6252 + if ( data && data.events ) {
10.6253 + for ( var type in data.events ) {
10.6254 + if ( special[ type ] ) {
10.6255 + jQuery.event.remove( elem, type );
10.6256 +
10.6257 + // This is a shortcut to avoid jQuery.event.remove's overhead
10.6258 + } else {
10.6259 + jQuery.removeEvent( elem, type, data.handle );
10.6260 + }
10.6261 + }
10.6262 +
10.6263 + // Null the DOM reference to avoid IE6/7/8 leak (#7054)
10.6264 + if ( data.handle ) {
10.6265 + data.handle.elem = null;
10.6266 + }
10.6267 + }
10.6268 +
10.6269 + if ( deleteExpando ) {
10.6270 + delete elem[ jQuery.expando ];
10.6271 +
10.6272 + } else if ( elem.removeAttribute ) {
10.6273 + elem.removeAttribute( jQuery.expando );
10.6274 + }
10.6275 +
10.6276 + delete cache[ id ];
10.6277 + }
10.6278 + }
10.6279 + }
10.6280 +});
10.6281 +
10.6282 +function evalScript( i, elem ) {
10.6283 + if ( elem.src ) {
10.6284 + jQuery.ajax({
10.6285 + url: elem.src,
10.6286 + async: false,
10.6287 + dataType: "script"
10.6288 + });
10.6289 + } else {
10.6290 + jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "/*$0*/" ) );
10.6291 + }
10.6292 +
10.6293 + if ( elem.parentNode ) {
10.6294 + elem.parentNode.removeChild( elem );
10.6295 + }
10.6296 +}
10.6297 +
10.6298 +
10.6299 +
10.6300 +
10.6301 +var ralpha = /alpha\([^)]*\)/i,
10.6302 + ropacity = /opacity=([^)]*)/,
10.6303 + // fixed for IE9, see #8346
10.6304 + rupper = /([A-Z]|^ms)/g,
10.6305 + rnumpx = /^-?\d+(?:px)?$/i,
10.6306 + rnum = /^-?\d/,
10.6307 + rrelNum = /^([\-+])=([\-+.\de]+)/,
10.6308 +
10.6309 + cssShow = { position: "absolute", visibility: "hidden", display: "block" },
10.6310 + cssWidth = [ "Left", "Right" ],
10.6311 + cssHeight = [ "Top", "Bottom" ],
10.6312 + curCSS,
10.6313 +
10.6314 + getComputedStyle,
10.6315 + currentStyle;
10.6316 +
10.6317 +jQuery.fn.css = function( name, value ) {
10.6318 + // Setting 'undefined' is a no-op
10.6319 + if ( arguments.length === 2 && value === undefined ) {
10.6320 + return this;
10.6321 + }
10.6322 +
10.6323 + return jQuery.access( this, name, value, true, function( elem, name, value ) {
10.6324 + return value !== undefined ?
10.6325 + jQuery.style( elem, name, value ) :
10.6326 + jQuery.css( elem, name );
10.6327 + });
10.6328 +};
10.6329 +
10.6330 +jQuery.extend({
10.6331 + // Add in style property hooks for overriding the default
10.6332 + // behavior of getting and setting a style property
10.6333 + cssHooks: {
10.6334 + opacity: {
10.6335 + get: function( elem, computed ) {
10.6336 + if ( computed ) {
10.6337 + // We should always get a number back from opacity
10.6338 + var ret = curCSS( elem, "opacity", "opacity" );
10.6339 + return ret === "" ? "1" : ret;
10.6340 +
10.6341 + } else {
10.6342 + return elem.style.opacity;
10.6343 + }
10.6344 + }
10.6345 + }
10.6346 + },
10.6347 +
10.6348 + // Exclude the following css properties to add px
10.6349 + cssNumber: {
10.6350 + "fillOpacity": true,
10.6351 + "fontWeight": true,
10.6352 + "lineHeight": true,
10.6353 + "opacity": true,
10.6354 + "orphans": true,
10.6355 + "widows": true,
10.6356 + "zIndex": true,
10.6357 + "zoom": true
10.6358 + },
10.6359 +
10.6360 + // Add in properties whose names you wish to fix before
10.6361 + // setting or getting the value
10.6362 + cssProps: {
10.6363 + // normalize float css property
10.6364 + "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
10.6365 + },
10.6366 +
10.6367 + // Get and set the style property on a DOM Node
10.6368 + style: function( elem, name, value, extra ) {
10.6369 + // Don't set styles on text and comment nodes
10.6370 + if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
10.6371 + return;
10.6372 + }
10.6373 +
10.6374 + // Make sure that we're working with the right name
10.6375 + var ret, type, origName = jQuery.camelCase( name ),
10.6376 + style = elem.style, hooks = jQuery.cssHooks[ origName ];
10.6377 +
10.6378 + name = jQuery.cssProps[ origName ] || origName;
10.6379 +
10.6380 + // Check if we're setting a value
10.6381 + if ( value !== undefined ) {
10.6382 + type = typeof value;
10.6383 +
10.6384 + // convert relative number strings (+= or -=) to relative numbers. #7345
10.6385 + if ( type === "string" && (ret = rrelNum.exec( value )) ) {
10.6386 + value = ( +( ret[1] + 1) * +ret[2] ) + parseFloat( jQuery.css( elem, name ) );
10.6387 + // Fixes bug #9237
10.6388 + type = "number";
10.6389 + }
10.6390 +
10.6391 + // Make sure that NaN and null values aren't set. See: #7116
10.6392 + if ( value == null || type === "number" && isNaN( value ) ) {
10.6393 + return;
10.6394 + }
10.6395 +
10.6396 + // If a number was passed in, add 'px' to the (except for certain CSS properties)
10.6397 + if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
10.6398 + value += "px";
10.6399 + }
10.6400 +
10.6401 + // If a hook was provided, use that value, otherwise just set the specified value
10.6402 + if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {
10.6403 + // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
10.6404 + // Fixes bug #5509
10.6405 + try {
10.6406 + style[ name ] = value;
10.6407 + } catch(e) {}
10.6408 + }
10.6409 +
10.6410 + } else {
10.6411 + // If a hook was provided get the non-computed value from there
10.6412 + if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
10.6413 + return ret;
10.6414 + }
10.6415 +
10.6416 + // Otherwise just get the value from the style object
10.6417 + return style[ name ];
10.6418 + }
10.6419 + },
10.6420 +
10.6421 + css: function( elem, name, extra ) {
10.6422 + var ret, hooks;
10.6423 +
10.6424 + // Make sure that we're working with the right name
10.6425 + name = jQuery.camelCase( name );
10.6426 + hooks = jQuery.cssHooks[ name ];
10.6427 + name = jQuery.cssProps[ name ] || name;
10.6428 +
10.6429 + // cssFloat needs a special treatment
10.6430 + if ( name === "cssFloat" ) {
10.6431 + name = "float";
10.6432 + }
10.6433 +
10.6434 + // If a hook was provided get the computed value from there
10.6435 + if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
10.6436 + return ret;
10.6437 +
10.6438 + // Otherwise, if a way to get the computed value exists, use that
10.6439 + } else if ( curCSS ) {
10.6440 + return curCSS( elem, name );
10.6441 + }
10.6442 + },
10.6443 +
10.6444 + // A method for quickly swapping in/out CSS properties to get correct calculations
10.6445 + swap: function( elem, options, callback ) {
10.6446 + var old = {};
10.6447 +
10.6448 + // Remember the old values, and insert the new ones
10.6449 + for ( var name in options ) {
10.6450 + old[ name ] = elem.style[ name ];
10.6451 + elem.style[ name ] = options[ name ];
10.6452 + }
10.6453 +
10.6454 + callback.call( elem );
10.6455 +
10.6456 + // Revert the old values
10.6457 + for ( name in options ) {
10.6458 + elem.style[ name ] = old[ name ];
10.6459 + }
10.6460 + }
10.6461 +});
10.6462 +
10.6463 +// DEPRECATED, Use jQuery.css() instead
10.6464 +jQuery.curCSS = jQuery.css;
10.6465 +
10.6466 +jQuery.each(["height", "width"], function( i, name ) {
10.6467 + jQuery.cssHooks[ name ] = {
10.6468 + get: function( elem, computed, extra ) {
10.6469 + var val;
10.6470 +
10.6471 + if ( computed ) {
10.6472 + if ( elem.offsetWidth !== 0 ) {
10.6473 + return getWH( elem, name, extra );
10.6474 + } else {
10.6475 + jQuery.swap( elem, cssShow, function() {
10.6476 + val = getWH( elem, name, extra );
10.6477 + });
10.6478 + }
10.6479 +
10.6480 + return val;
10.6481 + }
10.6482 + },
10.6483 +
10.6484 + set: function( elem, value ) {
10.6485 + if ( rnumpx.test( value ) ) {
10.6486 + // ignore negative width and height values #1599
10.6487 + value = parseFloat( value );
10.6488 +
10.6489 + if ( value >= 0 ) {
10.6490 + return value + "px";
10.6491 + }
10.6492 +
10.6493 + } else {
10.6494 + return value;
10.6495 + }
10.6496 + }
10.6497 + };
10.6498 +});
10.6499 +
10.6500 +if ( !jQuery.support.opacity ) {
10.6501 + jQuery.cssHooks.opacity = {
10.6502 + get: function( elem, computed ) {
10.6503 + // IE uses filters for opacity
10.6504 + return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
10.6505 + ( parseFloat( RegExp.$1 ) / 100 ) + "" :
10.6506 + computed ? "1" : "";
10.6507 + },
10.6508 +
10.6509 + set: function( elem, value ) {
10.6510 + var style = elem.style,
10.6511 + currentStyle = elem.currentStyle,
10.6512 + opacity = jQuery.isNaN( value ) ? "" : "alpha(opacity=" + value * 100 + ")",
10.6513 + filter = currentStyle && currentStyle.filter || style.filter || "";
10.6514 +
10.6515 + // IE has trouble with opacity if it does not have layout
10.6516 + // Force it by setting the zoom level
10.6517 + style.zoom = 1;
10.6518 +
10.6519 + // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
10.6520 + if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" ) {
10.6521 +
10.6522 + // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
10.6523 + // if "filter:" is present at all, clearType is disabled, we want to avoid this
10.6524 + // style.removeAttribute is IE Only, but so apparently is this code path...
10.6525 + style.removeAttribute( "filter" );
10.6526 +
10.6527 + // if there there is no filter style applied in a css rule, we are done
10.6528 + if ( currentStyle && !currentStyle.filter ) {
10.6529 + return;
10.6530 + }
10.6531 + }
10.6532 +
10.6533 + // otherwise, set new filter values
10.6534 + style.filter = ralpha.test( filter ) ?
10.6535 + filter.replace( ralpha, opacity ) :
10.6536 + filter + " " + opacity;
10.6537 + }
10.6538 + };
10.6539 +}
10.6540 +
10.6541 +jQuery(function() {
10.6542 + // This hook cannot be added until DOM ready because the support test
10.6543 + // for it is not run until after DOM ready
10.6544 + if ( !jQuery.support.reliableMarginRight ) {
10.6545 + jQuery.cssHooks.marginRight = {
10.6546 + get: function( elem, computed ) {
10.6547 + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
10.6548 + // Work around by temporarily setting element display to inline-block
10.6549 + var ret;
10.6550 + jQuery.swap( elem, { "display": "inline-block" }, function() {
10.6551 + if ( computed ) {
10.6552 + ret = curCSS( elem, "margin-right", "marginRight" );
10.6553 + } else {
10.6554 + ret = elem.style.marginRight;
10.6555 + }
10.6556 + });
10.6557 + return ret;
10.6558 + }
10.6559 + };
10.6560 + }
10.6561 +});
10.6562 +
10.6563 +if ( document.defaultView && document.defaultView.getComputedStyle ) {
10.6564 + getComputedStyle = function( elem, name ) {
10.6565 + var ret, defaultView, computedStyle;
10.6566 +
10.6567 + name = name.replace( rupper, "-$1" ).toLowerCase();
10.6568 +
10.6569 + if ( !(defaultView = elem.ownerDocument.defaultView) ) {
10.6570 + return undefined;
10.6571 + }
10.6572 +
10.6573 + if ( (computedStyle = defaultView.getComputedStyle( elem, null )) ) {
10.6574 + ret = computedStyle.getPropertyValue( name );
10.6575 + if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
10.6576 + ret = jQuery.style( elem, name );
10.6577 + }
10.6578 + }
10.6579 +
10.6580 + return ret;
10.6581 + };
10.6582 +}
10.6583 +
10.6584 +if ( document.documentElement.currentStyle ) {
10.6585 + currentStyle = function( elem, name ) {
10.6586 + var left,
10.6587 + ret = elem.currentStyle && elem.currentStyle[ name ],
10.6588 + rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ],
10.6589 + style = elem.style;
10.6590 +
10.6591 + // From the awesome hack by Dean Edwards
10.6592 + // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
10.6593 +
10.6594 + // If we're not dealing with a regular pixel number
10.6595 + // but a number that has a weird ending, we need to convert it to pixels
10.6596 + if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
10.6597 + // Remember the original values
10.6598 + left = style.left;
10.6599 +
10.6600 + // Put in the new values to get a computed value out
10.6601 + if ( rsLeft ) {
10.6602 + elem.runtimeStyle.left = elem.currentStyle.left;
10.6603 + }
10.6604 + style.left = name === "fontSize" ? "1em" : (ret || 0);
10.6605 + ret = style.pixelLeft + "px";
10.6606 +
10.6607 + // Revert the changed values
10.6608 + style.left = left;
10.6609 + if ( rsLeft ) {
10.6610 + elem.runtimeStyle.left = rsLeft;
10.6611 + }
10.6612 + }
10.6613 +
10.6614 + return ret === "" ? "auto" : ret;
10.6615 + };
10.6616 +}
10.6617 +
10.6618 +curCSS = getComputedStyle || currentStyle;
10.6619 +
10.6620 +function getWH( elem, name, extra ) {
10.6621 +
10.6622 + // Start with offset property
10.6623 + var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
10.6624 + which = name === "width" ? cssWidth : cssHeight;
10.6625 +
10.6626 + if ( val > 0 ) {
10.6627 + if ( extra !== "border" ) {
10.6628 + jQuery.each( which, function() {
10.6629 + if ( !extra ) {
10.6630 + val -= parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
10.6631 + }
10.6632 + if ( extra === "margin" ) {
10.6633 + val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
10.6634 + } else {
10.6635 + val -= parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
10.6636 + }
10.6637 + });
10.6638 + }
10.6639 +
10.6640 + return val + "px";
10.6641 + }
10.6642 +
10.6643 + // Fall back to computed then uncomputed css if necessary
10.6644 + val = curCSS( elem, name, name );
10.6645 + if ( val < 0 || val == null ) {
10.6646 + val = elem.style[ name ] || 0;
10.6647 + }
10.6648 + // Normalize "", auto, and prepare for extra
10.6649 + val = parseFloat( val ) || 0;
10.6650 +
10.6651 + // Add padding, border, margin
10.6652 + if ( extra ) {
10.6653 + jQuery.each( which, function() {
10.6654 + val += parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
10.6655 + if ( extra !== "padding" ) {
10.6656 + val += parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
10.6657 + }
10.6658 + if ( extra === "margin" ) {
10.6659 + val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
10.6660 + }
10.6661 + });
10.6662 + }
10.6663 +
10.6664 + return val + "px";
10.6665 +}
10.6666 +
10.6667 +if ( jQuery.expr && jQuery.expr.filters ) {
10.6668 + jQuery.expr.filters.hidden = function( elem ) {
10.6669 + var width = elem.offsetWidth,
10.6670 + height = elem.offsetHeight;
10.6671 +
10.6672 + return (width === 0 && height === 0) || (!jQuery.support.reliableHiddenOffsets && (elem.style.display || jQuery.css( elem, "display" )) === "none");
10.6673 + };
10.6674 +
10.6675 + jQuery.expr.filters.visible = function( elem ) {
10.6676 + return !jQuery.expr.filters.hidden( elem );
10.6677 + };
10.6678 +}
10.6679 +
10.6680 +
10.6681 +
10.6682 +
10.6683 +var r20 = /%20/g,
10.6684 + rbracket = /\[\]$/,
10.6685 + rCRLF = /\r?\n/g,
10.6686 + rhash = /#.*$/,
10.6687 + rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
10.6688 + rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
10.6689 + // #7653, #8125, #8152: local protocol detection
10.6690 + rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
10.6691 + rnoContent = /^(?:GET|HEAD)$/,
10.6692 + rprotocol = /^\/\//,
10.6693 + rquery = /\?/,
10.6694 + rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
10.6695 + rselectTextarea = /^(?:select|textarea)/i,
10.6696 + rspacesAjax = /\s+/,
10.6697 + rts = /([?&])_=[^&]*/,
10.6698 + rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,
10.6699 +
10.6700 + // Keep a copy of the old load method
10.6701 + _load = jQuery.fn.load,
10.6702 +
10.6703 + /* Prefilters
10.6704 + * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
10.6705 + * 2) These are called:
10.6706 + * - BEFORE asking for a transport
10.6707 + * - AFTER param serialization (s.data is a string if s.processData is true)
10.6708 + * 3) key is the dataType
10.6709 + * 4) the catchall symbol "*" can be used
10.6710 + * 5) execution will start with transport dataType and THEN continue down to "*" if needed
10.6711 + */
10.6712 + prefilters = {},
10.6713 +
10.6714 + /* Transports bindings
10.6715 + * 1) key is the dataType
10.6716 + * 2) the catchall symbol "*" can be used
10.6717 + * 3) selection will start with transport dataType and THEN go to "*" if needed
10.6718 + */
10.6719 + transports = {},
10.6720 +
10.6721 + // Document location
10.6722 + ajaxLocation,
10.6723 +
10.6724 + // Document location segments
10.6725 + ajaxLocParts,
10.6726 +
10.6727 + // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
10.6728 + allTypes = ["*/"] + ["*"];
10.6729 +
10.6730 +// #8138, IE may throw an exception when accessing
10.6731 +// a field from window.location if document.domain has been set
10.6732 +try {
10.6733 + ajaxLocation = location.href;
10.6734 +} catch( e ) {
10.6735 + // Use the href attribute of an A element
10.6736 + // since IE will modify it given document.location
10.6737 + ajaxLocation = document.createElement( "a" );
10.6738 + ajaxLocation.href = "";
10.6739 + ajaxLocation = ajaxLocation.href;
10.6740 +}
10.6741 +
10.6742 +// Segment location into parts
10.6743 +ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
10.6744 +
10.6745 +// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
10.6746 +function addToPrefiltersOrTransports( structure ) {
10.6747 +
10.6748 + // dataTypeExpression is optional and defaults to "*"
10.6749 + return function( dataTypeExpression, func ) {
10.6750 +
10.6751 + if ( typeof dataTypeExpression !== "string" ) {
10.6752 + func = dataTypeExpression;
10.6753 + dataTypeExpression = "*";
10.6754 + }
10.6755 +
10.6756 + if ( jQuery.isFunction( func ) ) {
10.6757 + var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ),
10.6758 + i = 0,
10.6759 + length = dataTypes.length,
10.6760 + dataType,
10.6761 + list,
10.6762 + placeBefore;
10.6763 +
10.6764 + // For each dataType in the dataTypeExpression
10.6765 + for(; i < length; i++ ) {
10.6766 + dataType = dataTypes[ i ];
10.6767 + // We control if we're asked to add before
10.6768 + // any existing element
10.6769 + placeBefore = /^\+/.test( dataType );
10.6770 + if ( placeBefore ) {
10.6771 + dataType = dataType.substr( 1 ) || "*";
10.6772 + }
10.6773 + list = structure[ dataType ] = structure[ dataType ] || [];
10.6774 + // then we add to the structure accordingly
10.6775 + list[ placeBefore ? "unshift" : "push" ]( func );
10.6776 + }
10.6777 + }
10.6778 + };
10.6779 +}
10.6780 +
10.6781 +// Base inspection function for prefilters and transports
10.6782 +function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
10.6783 + dataType /* internal */, inspected /* internal */ ) {
10.6784 +
10.6785 + dataType = dataType || options.dataTypes[ 0 ];
10.6786 + inspected = inspected || {};
10.6787 +
10.6788 + inspected[ dataType ] = true;
10.6789 +
10.6790 + var list = structure[ dataType ],
10.6791 + i = 0,
10.6792 + length = list ? list.length : 0,
10.6793 + executeOnly = ( structure === prefilters ),
10.6794 + selection;
10.6795 +
10.6796 + for(; i < length && ( executeOnly || !selection ); i++ ) {
10.6797 + selection = list[ i ]( options, originalOptions, jqXHR );
10.6798 + // If we got redirected to another dataType
10.6799 + // we try there if executing only and not done already
10.6800 + if ( typeof selection === "string" ) {
10.6801 + if ( !executeOnly || inspected[ selection ] ) {
10.6802 + selection = undefined;
10.6803 + } else {
10.6804 + options.dataTypes.unshift( selection );
10.6805 + selection = inspectPrefiltersOrTransports(
10.6806 + structure, options, originalOptions, jqXHR, selection, inspected );
10.6807 + }
10.6808 + }
10.6809 + }
10.6810 + // If we're only executing or nothing was selected
10.6811 + // we try the catchall dataType if not done already
10.6812 + if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
10.6813 + selection = inspectPrefiltersOrTransports(
10.6814 + structure, options, originalOptions, jqXHR, "*", inspected );
10.6815 + }
10.6816 + // unnecessary when only executing (prefilters)
10.6817 + // but it'll be ignored by the caller in that case
10.6818 + return selection;
10.6819 +}
10.6820 +
10.6821 +// A special extend for ajax options
10.6822 +// that takes "flat" options (not to be deep extended)
10.6823 +// Fixes #9887
10.6824 +function ajaxExtend( target, src ) {
10.6825 + var key, deep,
10.6826 + flatOptions = jQuery.ajaxSettings.flatOptions || {};
10.6827 + for( key in src ) {
10.6828 + if ( src[ key ] !== undefined ) {
10.6829 + ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
10.6830 + }
10.6831 + }
10.6832 + if ( deep ) {
10.6833 + jQuery.extend( true, target, deep );
10.6834 + }
10.6835 +}
10.6836 +
10.6837 +jQuery.fn.extend({
10.6838 + load: function( url, params, callback ) {
10.6839 + if ( typeof url !== "string" && _load ) {
10.6840 + return _load.apply( this, arguments );
10.6841 +
10.6842 + // Don't do a request if no elements are being requested
10.6843 + } else if ( !this.length ) {
10.6844 + return this;
10.6845 + }
10.6846 +
10.6847 + var off = url.indexOf( " " );
10.6848 + if ( off >= 0 ) {
10.6849 + var selector = url.slice( off, url.length );
10.6850 + url = url.slice( 0, off );
10.6851 + }
10.6852 +
10.6853 + // Default to a GET request
10.6854 + var type = "GET";
10.6855 +
10.6856 + // If the second parameter was provided
10.6857 + if ( params ) {
10.6858 + // If it's a function
10.6859 + if ( jQuery.isFunction( params ) ) {
10.6860 + // We assume that it's the callback
10.6861 + callback = params;
10.6862 + params = undefined;
10.6863 +
10.6864 + // Otherwise, build a param string
10.6865 + } else if ( typeof params === "object" ) {
10.6866 + params = jQuery.param( params, jQuery.ajaxSettings.traditional );
10.6867 + type = "POST";
10.6868 + }
10.6869 + }
10.6870 +
10.6871 + var self = this;
10.6872 +
10.6873 + // Request the remote document
10.6874 + jQuery.ajax({
10.6875 + url: url,
10.6876 + type: type,
10.6877 + dataType: "html",
10.6878 + data: params,
10.6879 + // Complete callback (responseText is used internally)
10.6880 + complete: function( jqXHR, status, responseText ) {
10.6881 + // Store the response as specified by the jqXHR object
10.6882 + responseText = jqXHR.responseText;
10.6883 + // If successful, inject the HTML into all the matched elements
10.6884 + if ( jqXHR.isResolved() ) {
10.6885 + // #4825: Get the actual response in case
10.6886 + // a dataFilter is present in ajaxSettings
10.6887 + jqXHR.done(function( r ) {
10.6888 + responseText = r;
10.6889 + });
10.6890 + // See if a selector was specified
10.6891 + self.html( selector ?
10.6892 + // Create a dummy div to hold the results
10.6893 + jQuery("<div>")
10.6894 + // inject the contents of the document in, removing the scripts
10.6895 + // to avoid any 'Permission Denied' errors in IE
10.6896 + .append(responseText.replace(rscript, ""))
10.6897 +
10.6898 + // Locate the specified elements
10.6899 + .find(selector) :
10.6900 +
10.6901 + // If not, just inject the full result
10.6902 + responseText );
10.6903 + }
10.6904 +
10.6905 + if ( callback ) {
10.6906 + self.each( callback, [ responseText, status, jqXHR ] );
10.6907 + }
10.6908 + }
10.6909 + });
10.6910 +
10.6911 + return this;
10.6912 + },
10.6913 +
10.6914 + serialize: function() {
10.6915 + return jQuery.param( this.serializeArray() );
10.6916 + },
10.6917 +
10.6918 + serializeArray: function() {
10.6919 + return this.map(function(){
10.6920 + return this.elements ? jQuery.makeArray( this.elements ) : this;
10.6921 + })
10.6922 + .filter(function(){
10.6923 + return this.name && !this.disabled &&
10.6924 + ( this.checked || rselectTextarea.test( this.nodeName ) ||
10.6925 + rinput.test( this.type ) );
10.6926 + })
10.6927 + .map(function( i, elem ){
10.6928 + var val = jQuery( this ).val();
10.6929 +
10.6930 + return val == null ?
10.6931 + null :
10.6932 + jQuery.isArray( val ) ?
10.6933 + jQuery.map( val, function( val, i ){
10.6934 + return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
10.6935 + }) :
10.6936 + { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
10.6937 + }).get();
10.6938 + }
10.6939 +});
10.6940 +
10.6941 +// Attach a bunch of functions for handling common AJAX events
10.6942 +jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
10.6943 + jQuery.fn[ o ] = function( f ){
10.6944 + return this.bind( o, f );
10.6945 + };
10.6946 +});
10.6947 +
10.6948 +jQuery.each( [ "get", "post" ], function( i, method ) {
10.6949 + jQuery[ method ] = function( url, data, callback, type ) {
10.6950 + // shift arguments if data argument was omitted
10.6951 + if ( jQuery.isFunction( data ) ) {
10.6952 + type = type || callback;
10.6953 + callback = data;
10.6954 + data = undefined;
10.6955 + }
10.6956 +
10.6957 + return jQuery.ajax({
10.6958 + type: method,
10.6959 + url: url,
10.6960 + data: data,
10.6961 + success: callback,
10.6962 + dataType: type
10.6963 + });
10.6964 + };
10.6965 +});
10.6966 +
10.6967 +jQuery.extend({
10.6968 +
10.6969 + getScript: function( url, callback ) {
10.6970 + return jQuery.get( url, undefined, callback, "script" );
10.6971 + },
10.6972 +
10.6973 + getJSON: function( url, data, callback ) {
10.6974 + return jQuery.get( url, data, callback, "json" );
10.6975 + },
10.6976 +
10.6977 + // Creates a full fledged settings object into target
10.6978 + // with both ajaxSettings and settings fields.
10.6979 + // If target is omitted, writes into ajaxSettings.
10.6980 + ajaxSetup: function( target, settings ) {
10.6981 + if ( settings ) {
10.6982 + // Building a settings object
10.6983 + ajaxExtend( target, jQuery.ajaxSettings );
10.6984 + } else {
10.6985 + // Extending ajaxSettings
10.6986 + settings = target;
10.6987 + target = jQuery.ajaxSettings;
10.6988 + }
10.6989 + ajaxExtend( target, settings );
10.6990 + return target;
10.6991 + },
10.6992 +
10.6993 + ajaxSettings: {
10.6994 + url: ajaxLocation,
10.6995 + isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
10.6996 + global: true,
10.6997 + type: "GET",
10.6998 + contentType: "application/x-www-form-urlencoded",
10.6999 + processData: true,
10.7000 + async: true,
10.7001 + /*
10.7002 + timeout: 0,
10.7003 + data: null,
10.7004 + dataType: null,
10.7005 + username: null,
10.7006 + password: null,
10.7007 + cache: null,
10.7008 + traditional: false,
10.7009 + headers: {},
10.7010 + */
10.7011 +
10.7012 + accepts: {
10.7013 + xml: "application/xml, text/xml",
10.7014 + html: "text/html",
10.7015 + text: "text/plain",
10.7016 + json: "application/json, text/javascript",
10.7017 + "*": allTypes
10.7018 + },
10.7019 +
10.7020 + contents: {
10.7021 + xml: /xml/,
10.7022 + html: /html/,
10.7023 + json: /json/
10.7024 + },
10.7025 +
10.7026 + responseFields: {
10.7027 + xml: "responseXML",
10.7028 + text: "responseText"
10.7029 + },
10.7030 +
10.7031 + // List of data converters
10.7032 + // 1) key format is "source_type destination_type" (a single space in-between)
10.7033 + // 2) the catchall symbol "*" can be used for source_type
10.7034 + converters: {
10.7035 +
10.7036 + // Convert anything to text
10.7037 + "* text": window.String,
10.7038 +
10.7039 + // Text to html (true = no transformation)
10.7040 + "text html": true,
10.7041 +
10.7042 + // Evaluate text as a json expression
10.7043 + "text json": jQuery.parseJSON,
10.7044 +
10.7045 + // Parse text as xml
10.7046 + "text xml": jQuery.parseXML
10.7047 + },
10.7048 +
10.7049 + // For options that shouldn't be deep extended:
10.7050 + // you can add your own custom options here if
10.7051 + // and when you create one that shouldn't be
10.7052 + // deep extended (see ajaxExtend)
10.7053 + flatOptions: {
10.7054 + context: true,
10.7055 + url: true
10.7056 + }
10.7057 + },
10.7058 +
10.7059 + ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
10.7060 + ajaxTransport: addToPrefiltersOrTransports( transports ),
10.7061 +
10.7062 + // Main method
10.7063 + ajax: function( url, options ) {
10.7064 +
10.7065 + // If url is an object, simulate pre-1.5 signature
10.7066 + if ( typeof url === "object" ) {
10.7067 + options = url;
10.7068 + url = undefined;
10.7069 + }
10.7070 +
10.7071 + // Force options to be an object
10.7072 + options = options || {};
10.7073 +
10.7074 + var // Create the final options object
10.7075 + s = jQuery.ajaxSetup( {}, options ),
10.7076 + // Callbacks context
10.7077 + callbackContext = s.context || s,
10.7078 + // Context for global events
10.7079 + // It's the callbackContext if one was provided in the options
10.7080 + // and if it's a DOM node or a jQuery collection
10.7081 + globalEventContext = callbackContext !== s &&
10.7082 + ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
10.7083 + jQuery( callbackContext ) : jQuery.event,
10.7084 + // Deferreds
10.7085 + deferred = jQuery.Deferred(),
10.7086 + completeDeferred = jQuery._Deferred(),
10.7087 + // Status-dependent callbacks
10.7088 + statusCode = s.statusCode || {},
10.7089 + // ifModified key
10.7090 + ifModifiedKey,
10.7091 + // Headers (they are sent all at once)
10.7092 + requestHeaders = {},
10.7093 + requestHeadersNames = {},
10.7094 + // Response headers
10.7095 + responseHeadersString,
10.7096 + responseHeaders,
10.7097 + // transport
10.7098 + transport,
10.7099 + // timeout handle
10.7100 + timeoutTimer,
10.7101 + // Cross-domain detection vars
10.7102 + parts,
10.7103 + // The jqXHR state
10.7104 + state = 0,
10.7105 + // To know if global events are to be dispatched
10.7106 + fireGlobals,
10.7107 + // Loop variable
10.7108 + i,
10.7109 + // Fake xhr
10.7110 + jqXHR = {
10.7111 +
10.7112 + readyState: 0,
10.7113 +
10.7114 + // Caches the header
10.7115 + setRequestHeader: function( name, value ) {
10.7116 + if ( !state ) {
10.7117 + var lname = name.toLowerCase();
10.7118 + name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
10.7119 + requestHeaders[ name ] = value;
10.7120 + }
10.7121 + return this;
10.7122 + },
10.7123 +
10.7124 + // Raw string
10.7125 + getAllResponseHeaders: function() {
10.7126 + return state === 2 ? responseHeadersString : null;
10.7127 + },
10.7128 +
10.7129 + // Builds headers hashtable if needed
10.7130 + getResponseHeader: function( key ) {
10.7131 + var match;
10.7132 + if ( state === 2 ) {
10.7133 + if ( !responseHeaders ) {
10.7134 + responseHeaders = {};
10.7135 + while( ( match = rheaders.exec( responseHeadersString ) ) ) {
10.7136 + responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
10.7137 + }
10.7138 + }
10.7139 + match = responseHeaders[ key.toLowerCase() ];
10.7140 + }
10.7141 + return match === undefined ? null : match;
10.7142 + },
10.7143 +
10.7144 + // Overrides response content-type header
10.7145 + overrideMimeType: function( type ) {
10.7146 + if ( !state ) {
10.7147 + s.mimeType = type;
10.7148 + }
10.7149 + return this;
10.7150 + },
10.7151 +
10.7152 + // Cancel the request
10.7153 + abort: function( statusText ) {
10.7154 + statusText = statusText || "abort";
10.7155 + if ( transport ) {
10.7156 + transport.abort( statusText );
10.7157 + }
10.7158 + done( 0, statusText );
10.7159 + return this;
10.7160 + }
10.7161 + };
10.7162 +
10.7163 + // Callback for when everything is done
10.7164 + // It is defined here because jslint complains if it is declared
10.7165 + // at the end of the function (which would be more logical and readable)
10.7166 + function done( status, nativeStatusText, responses, headers ) {
10.7167 +
10.7168 + // Called once
10.7169 + if ( state === 2 ) {
10.7170 + return;
10.7171 + }
10.7172 +
10.7173 + // State is "done" now
10.7174 + state = 2;
10.7175 +
10.7176 + // Clear timeout if it exists
10.7177 + if ( timeoutTimer ) {
10.7178 + clearTimeout( timeoutTimer );
10.7179 + }
10.7180 +
10.7181 + // Dereference transport for early garbage collection
10.7182 + // (no matter how long the jqXHR object will be used)
10.7183 + transport = undefined;
10.7184 +
10.7185 + // Cache response headers
10.7186 + responseHeadersString = headers || "";
10.7187 +
10.7188 + // Set readyState
10.7189 + jqXHR.readyState = status > 0 ? 4 : 0;
10.7190 +
10.7191 + var isSuccess,
10.7192 + success,
10.7193 + error,
10.7194 + statusText = nativeStatusText,
10.7195 + response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined,
10.7196 + lastModified,
10.7197 + etag;
10.7198 +
10.7199 + // If successful, handle type chaining
10.7200 + if ( status >= 200 && status < 300 || status === 304 ) {
10.7201 +
10.7202 + // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
10.7203 + if ( s.ifModified ) {
10.7204 +
10.7205 + if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) {
10.7206 + jQuery.lastModified[ ifModifiedKey ] = lastModified;
10.7207 + }
10.7208 + if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) {
10.7209 + jQuery.etag[ ifModifiedKey ] = etag;
10.7210 + }
10.7211 + }
10.7212 +
10.7213 + // If not modified
10.7214 + if ( status === 304 ) {
10.7215 +
10.7216 + statusText = "notmodified";
10.7217 + isSuccess = true;
10.7218 +
10.7219 + // If we have data
10.7220 + } else {
10.7221 +
10.7222 + try {
10.7223 + success = ajaxConvert( s, response );
10.7224 + statusText = "success";
10.7225 + isSuccess = true;
10.7226 + } catch(e) {
10.7227 + // We have a parsererror
10.7228 + statusText = "parsererror";
10.7229 + error = e;
10.7230 + }
10.7231 + }
10.7232 + } else {
10.7233 + // We extract error from statusText
10.7234 + // then normalize statusText and status for non-aborts
10.7235 + error = statusText;
10.7236 + if( !statusText || status ) {
10.7237 + statusText = "error";
10.7238 + if ( status < 0 ) {
10.7239 + status = 0;
10.7240 + }
10.7241 + }
10.7242 + }
10.7243 +
10.7244 + // Set data for the fake xhr object
10.7245 + jqXHR.status = status;
10.7246 + jqXHR.statusText = "" + ( nativeStatusText || statusText );
10.7247 +
10.7248 + // Success/Error
10.7249 + if ( isSuccess ) {
10.7250 + deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
10.7251 + } else {
10.7252 + deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
10.7253 + }
10.7254 +
10.7255 + // Status-dependent callbacks
10.7256 + jqXHR.statusCode( statusCode );
10.7257 + statusCode = undefined;
10.7258 +
10.7259 + if ( fireGlobals ) {
10.7260 + globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
10.7261 + [ jqXHR, s, isSuccess ? success : error ] );
10.7262 + }
10.7263 +
10.7264 + // Complete
10.7265 + completeDeferred.resolveWith( callbackContext, [ jqXHR, statusText ] );
10.7266 +
10.7267 + if ( fireGlobals ) {
10.7268 + globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
10.7269 + // Handle the global AJAX counter
10.7270 + if ( !( --jQuery.active ) ) {
10.7271 + jQuery.event.trigger( "ajaxStop" );
10.7272 + }
10.7273 + }
10.7274 + }
10.7275 +
10.7276 + // Attach deferreds
10.7277 + deferred.promise( jqXHR );
10.7278 + jqXHR.success = jqXHR.done;
10.7279 + jqXHR.error = jqXHR.fail;
10.7280 + jqXHR.complete = completeDeferred.done;
10.7281 +
10.7282 + // Status-dependent callbacks
10.7283 + jqXHR.statusCode = function( map ) {
10.7284 + if ( map ) {
10.7285 + var tmp;
10.7286 + if ( state < 2 ) {
10.7287 + for( tmp in map ) {
10.7288 + statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
10.7289 + }
10.7290 + } else {
10.7291 + tmp = map[ jqXHR.status ];
10.7292 + jqXHR.then( tmp, tmp );
10.7293 + }
10.7294 + }
10.7295 + return this;
10.7296 + };
10.7297 +
10.7298 + // Remove hash character (#7531: and string promotion)
10.7299 + // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
10.7300 + // We also use the url parameter if available
10.7301 + s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
10.7302 +
10.7303 + // Extract dataTypes list
10.7304 + s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
10.7305 +
10.7306 + // Determine if a cross-domain request is in order
10.7307 + if ( s.crossDomain == null ) {
10.7308 + parts = rurl.exec( s.url.toLowerCase() );
10.7309 + s.crossDomain = !!( parts &&
10.7310 + ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
10.7311 + ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
10.7312 + ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
10.7313 + );
10.7314 + }
10.7315 +
10.7316 + // Convert data if not already a string
10.7317 + if ( s.data && s.processData && typeof s.data !== "string" ) {
10.7318 + s.data = jQuery.param( s.data, s.traditional );
10.7319 + }
10.7320 +
10.7321 + // Apply prefilters
10.7322 + inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
10.7323 +
10.7324 + // If request was aborted inside a prefiler, stop there
10.7325 + if ( state === 2 ) {
10.7326 + return false;
10.7327 + }
10.7328 +
10.7329 + // We can fire global events as of now if asked to
10.7330 + fireGlobals = s.global;
10.7331 +
10.7332 + // Uppercase the type
10.7333 + s.type = s.type.toUpperCase();
10.7334 +
10.7335 + // Determine if request has content
10.7336 + s.hasContent = !rnoContent.test( s.type );
10.7337 +
10.7338 + // Watch for a new set of requests
10.7339 + if ( fireGlobals && jQuery.active++ === 0 ) {
10.7340 + jQuery.event.trigger( "ajaxStart" );
10.7341 + }
10.7342 +
10.7343 + // More options handling for requests with no content
10.7344 + if ( !s.hasContent ) {
10.7345 +
10.7346 + // If data is available, append data to url
10.7347 + if ( s.data ) {
10.7348 + s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
10.7349 + // #9682: remove data so that it's not used in an eventual retry
10.7350 + delete s.data;
10.7351 + }
10.7352 +
10.7353 + // Get ifModifiedKey before adding the anti-cache parameter
10.7354 + ifModifiedKey = s.url;
10.7355 +
10.7356 + // Add anti-cache in url if needed
10.7357 + if ( s.cache === false ) {
10.7358 +
10.7359 + var ts = jQuery.now(),
10.7360 + // try replacing _= if it is there
10.7361 + ret = s.url.replace( rts, "$1_=" + ts );
10.7362 +
10.7363 + // if nothing was replaced, add timestamp to the end
10.7364 + s.url = ret + ( (ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
10.7365 + }
10.7366 + }
10.7367 +
10.7368 + // Set the correct header, if data is being sent
10.7369 + if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
10.7370 + jqXHR.setRequestHeader( "Content-Type", s.contentType );
10.7371 + }
10.7372 +
10.7373 + // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
10.7374 + if ( s.ifModified ) {
10.7375 + ifModifiedKey = ifModifiedKey || s.url;
10.7376 + if ( jQuery.lastModified[ ifModifiedKey ] ) {
10.7377 + jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
10.7378 + }
10.7379 + if ( jQuery.etag[ ifModifiedKey ] ) {
10.7380 + jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
10.7381 + }
10.7382 + }
10.7383 +
10.7384 + // Set the Accepts header for the server, depending on the dataType
10.7385 + jqXHR.setRequestHeader(
10.7386 + "Accept",
10.7387 + s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
10.7388 + s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
10.7389 + s.accepts[ "*" ]
10.7390 + );
10.7391 +
10.7392 + // Check for headers option
10.7393 + for ( i in s.headers ) {
10.7394 + jqXHR.setRequestHeader( i, s.headers[ i ] );
10.7395 + }
10.7396 +
10.7397 + // Allow custom headers/mimetypes and early abort
10.7398 + if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
10.7399 + // Abort if not done already
10.7400 + jqXHR.abort();
10.7401 + return false;
10.7402 +
10.7403 + }
10.7404 +
10.7405 + // Install callbacks on deferreds
10.7406 + for ( i in { success: 1, error: 1, complete: 1 } ) {
10.7407 + jqXHR[ i ]( s[ i ] );
10.7408 + }
10.7409 +
10.7410 + // Get transport
10.7411 + transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
10.7412 +
10.7413 + // If no transport, we auto-abort
10.7414 + if ( !transport ) {
10.7415 + done( -1, "No Transport" );
10.7416 + } else {
10.7417 + jqXHR.readyState = 1;
10.7418 + // Send global event
10.7419 + if ( fireGlobals ) {
10.7420 + globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
10.7421 + }
10.7422 + // Timeout
10.7423 + if ( s.async && s.timeout > 0 ) {
10.7424 + timeoutTimer = setTimeout( function(){
10.7425 + jqXHR.abort( "timeout" );
10.7426 + }, s.timeout );
10.7427 + }
10.7428 +
10.7429 + try {
10.7430 + state = 1;
10.7431 + transport.send( requestHeaders, done );
10.7432 + } catch (e) {
10.7433 + // Propagate exception as error if not done
10.7434 + if ( state < 2 ) {
10.7435 + done( -1, e );
10.7436 + // Simply rethrow otherwise
10.7437 + } else {
10.7438 + jQuery.error( e );
10.7439 + }
10.7440 + }
10.7441 + }
10.7442 +
10.7443 + return jqXHR;
10.7444 + },
10.7445 +
10.7446 + // Serialize an array of form elements or a set of
10.7447 + // key/values into a query string
10.7448 + param: function( a, traditional ) {
10.7449 + var s = [],
10.7450 + add = function( key, value ) {
10.7451 + // If value is a function, invoke it and return its value
10.7452 + value = jQuery.isFunction( value ) ? value() : value;
10.7453 + s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
10.7454 + };
10.7455 +
10.7456 + // Set traditional to true for jQuery <= 1.3.2 behavior.
10.7457 + if ( traditional === undefined ) {
10.7458 + traditional = jQuery.ajaxSettings.traditional;
10.7459 + }
10.7460 +
10.7461 + // If an array was passed in, assume that it is an array of form elements.
10.7462 + if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
10.7463 + // Serialize the form elements
10.7464 + jQuery.each( a, function() {
10.7465 + add( this.name, this.value );
10.7466 + });
10.7467 +
10.7468 + } else {
10.7469 + // If traditional, encode the "old" way (the way 1.3.2 or older
10.7470 + // did it), otherwise encode params recursively.
10.7471 + for ( var prefix in a ) {
10.7472 + buildParams( prefix, a[ prefix ], traditional, add );
10.7473 + }
10.7474 + }
10.7475 +
10.7476 + // Return the resulting serialization
10.7477 + return s.join( "&" ).replace( r20, "+" );
10.7478 + }
10.7479 +});
10.7480 +
10.7481 +function buildParams( prefix, obj, traditional, add ) {
10.7482 + if ( jQuery.isArray( obj ) ) {
10.7483 + // Serialize array item.
10.7484 + jQuery.each( obj, function( i, v ) {
10.7485 + if ( traditional || rbracket.test( prefix ) ) {
10.7486 + // Treat each array item as a scalar.
10.7487 + add( prefix, v );
10.7488 +
10.7489 + } else {
10.7490 + // If array item is non-scalar (array or object), encode its
10.7491 + // numeric index to resolve deserialization ambiguity issues.
10.7492 + // Note that rack (as of 1.0.0) can't currently deserialize
10.7493 + // nested arrays properly, and attempting to do so may cause
10.7494 + // a server error. Possible fixes are to modify rack's
10.7495 + // deserialization algorithm or to provide an option or flag
10.7496 + // to force array serialization to be shallow.
10.7497 + buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add );
10.7498 + }
10.7499 + });
10.7500 +
10.7501 + } else if ( !traditional && obj != null && typeof obj === "object" ) {
10.7502 + // Serialize object item.
10.7503 + for ( var name in obj ) {
10.7504 + buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
10.7505 + }
10.7506 +
10.7507 + } else {
10.7508 + // Serialize scalar item.
10.7509 + add( prefix, obj );
10.7510 + }
10.7511 +}
10.7512 +
10.7513 +// This is still on the jQuery object... for now
10.7514 +// Want to move this to jQuery.ajax some day
10.7515 +jQuery.extend({
10.7516 +
10.7517 + // Counter for holding the number of active queries
10.7518 + active: 0,
10.7519 +
10.7520 + // Last-Modified header cache for next request
10.7521 + lastModified: {},
10.7522 + etag: {}
10.7523 +
10.7524 +});
10.7525 +
10.7526 +/* Handles responses to an ajax request:
10.7527 + * - sets all responseXXX fields accordingly
10.7528 + * - finds the right dataType (mediates between content-type and expected dataType)
10.7529 + * - returns the corresponding response
10.7530 + */
10.7531 +function ajaxHandleResponses( s, jqXHR, responses ) {
10.7532 +
10.7533 + var contents = s.contents,
10.7534 + dataTypes = s.dataTypes,
10.7535 + responseFields = s.responseFields,
10.7536 + ct,
10.7537 + type,
10.7538 + finalDataType,
10.7539 + firstDataType;
10.7540 +
10.7541 + // Fill responseXXX fields
10.7542 + for( type in responseFields ) {
10.7543 + if ( type in responses ) {
10.7544 + jqXHR[ responseFields[type] ] = responses[ type ];
10.7545 + }
10.7546 + }
10.7547 +
10.7548 + // Remove auto dataType and get content-type in the process
10.7549 + while( dataTypes[ 0 ] === "*" ) {
10.7550 + dataTypes.shift();
10.7551 + if ( ct === undefined ) {
10.7552 + ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
10.7553 + }
10.7554 + }
10.7555 +
10.7556 + // Check if we're dealing with a known content-type
10.7557 + if ( ct ) {
10.7558 + for ( type in contents ) {
10.7559 + if ( contents[ type ] && contents[ type ].test( ct ) ) {
10.7560 + dataTypes.unshift( type );
10.7561 + break;
10.7562 + }
10.7563 + }
10.7564 + }
10.7565 +
10.7566 + // Check to see if we have a response for the expected dataType
10.7567 + if ( dataTypes[ 0 ] in responses ) {
10.7568 + finalDataType = dataTypes[ 0 ];
10.7569 + } else {
10.7570 + // Try convertible dataTypes
10.7571 + for ( type in responses ) {
10.7572 + if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
10.7573 + finalDataType = type;
10.7574 + break;
10.7575 + }
10.7576 + if ( !firstDataType ) {
10.7577 + firstDataType = type;
10.7578 + }
10.7579 + }
10.7580 + // Or just use first one
10.7581 + finalDataType = finalDataType || firstDataType;
10.7582 + }
10.7583 +
10.7584 + // If we found a dataType
10.7585 + // We add the dataType to the list if needed
10.7586 + // and return the corresponding response
10.7587 + if ( finalDataType ) {
10.7588 + if ( finalDataType !== dataTypes[ 0 ] ) {
10.7589 + dataTypes.unshift( finalDataType );
10.7590 + }
10.7591 + return responses[ finalDataType ];
10.7592 + }
10.7593 +}
10.7594 +
10.7595 +// Chain conversions given the request and the original response
10.7596 +function ajaxConvert( s, response ) {
10.7597 +
10.7598 + // Apply the dataFilter if provided
10.7599 + if ( s.dataFilter ) {
10.7600 + response = s.dataFilter( response, s.dataType );
10.7601 + }
10.7602 +
10.7603 + var dataTypes = s.dataTypes,
10.7604 + converters = {},
10.7605 + i,
10.7606 + key,
10.7607 + length = dataTypes.length,
10.7608 + tmp,
10.7609 + // Current and previous dataTypes
10.7610 + current = dataTypes[ 0 ],
10.7611 + prev,
10.7612 + // Conversion expression
10.7613 + conversion,
10.7614 + // Conversion function
10.7615 + conv,
10.7616 + // Conversion functions (transitive conversion)
10.7617 + conv1,
10.7618 + conv2;
10.7619 +
10.7620 + // For each dataType in the chain
10.7621 + for( i = 1; i < length; i++ ) {
10.7622 +
10.7623 + // Create converters map
10.7624 + // with lowercased keys
10.7625 + if ( i === 1 ) {
10.7626 + for( key in s.converters ) {
10.7627 + if( typeof key === "string" ) {
10.7628 + converters[ key.toLowerCase() ] = s.converters[ key ];
10.7629 + }
10.7630 + }
10.7631 + }
10.7632 +
10.7633 + // Get the dataTypes
10.7634 + prev = current;
10.7635 + current = dataTypes[ i ];
10.7636 +
10.7637 + // If current is auto dataType, update it to prev
10.7638 + if( current === "*" ) {
10.7639 + current = prev;
10.7640 + // If no auto and dataTypes are actually different
10.7641 + } else if ( prev !== "*" && prev !== current ) {
10.7642 +
10.7643 + // Get the converter
10.7644 + conversion = prev + " " + current;
10.7645 + conv = converters[ conversion ] || converters[ "* " + current ];
10.7646 +
10.7647 + // If there is no direct converter, search transitively
10.7648 + if ( !conv ) {
10.7649 + conv2 = undefined;
10.7650 + for( conv1 in converters ) {
10.7651 + tmp = conv1.split( " " );
10.7652 + if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {
10.7653 + conv2 = converters[ tmp[1] + " " + current ];
10.7654 + if ( conv2 ) {
10.7655 + conv1 = converters[ conv1 ];
10.7656 + if ( conv1 === true ) {
10.7657 + conv = conv2;
10.7658 + } else if ( conv2 === true ) {
10.7659 + conv = conv1;
10.7660 + }
10.7661 + break;
10.7662 + }
10.7663 + }
10.7664 + }
10.7665 + }
10.7666 + // If we found no converter, dispatch an error
10.7667 + if ( !( conv || conv2 ) ) {
10.7668 + jQuery.error( "No conversion from " + conversion.replace(" "," to ") );
10.7669 + }
10.7670 + // If found converter is not an equivalence
10.7671 + if ( conv !== true ) {
10.7672 + // Convert with 1 or 2 converters accordingly
10.7673 + response = conv ? conv( response ) : conv2( conv1(response) );
10.7674 + }
10.7675 + }
10.7676 + }
10.7677 + return response;
10.7678 +}
10.7679 +
10.7680 +
10.7681 +
10.7682 +
10.7683 +var jsc = jQuery.now(),
10.7684 + jsre = /(\=)\?(&|$)|\?\?/i;
10.7685 +
10.7686 +// Default jsonp settings
10.7687 +jQuery.ajaxSetup({
10.7688 + jsonp: "callback",
10.7689 + jsonpCallback: function() {
10.7690 + return jQuery.expando + "_" + ( jsc++ );
10.7691 + }
10.7692 +});
10.7693 +
10.7694 +// Detect, normalize options and install callbacks for jsonp requests
10.7695 +jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
10.7696 +
10.7697 + var inspectData = s.contentType === "application/x-www-form-urlencoded" &&
10.7698 + ( typeof s.data === "string" );
10.7699 +
10.7700 + if ( s.dataTypes[ 0 ] === "jsonp" ||
10.7701 + s.jsonp !== false && ( jsre.test( s.url ) ||
10.7702 + inspectData && jsre.test( s.data ) ) ) {
10.7703 +
10.7704 + var responseContainer,
10.7705 + jsonpCallback = s.jsonpCallback =
10.7706 + jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback,
10.7707 + previous = window[ jsonpCallback ],
10.7708 + url = s.url,
10.7709 + data = s.data,
10.7710 + replace = "$1" + jsonpCallback + "$2";
10.7711 +
10.7712 + if ( s.jsonp !== false ) {
10.7713 + url = url.replace( jsre, replace );
10.7714 + if ( s.url === url ) {
10.7715 + if ( inspectData ) {
10.7716 + data = data.replace( jsre, replace );
10.7717 + }
10.7718 + if ( s.data === data ) {
10.7719 + // Add callback manually
10.7720 + url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback;
10.7721 + }
10.7722 + }
10.7723 + }
10.7724 +
10.7725 + s.url = url;
10.7726 + s.data = data;
10.7727 +
10.7728 + // Install callback
10.7729 + window[ jsonpCallback ] = function( response ) {
10.7730 + responseContainer = [ response ];
10.7731 + };
10.7732 +
10.7733 + // Clean-up function
10.7734 + jqXHR.always(function() {
10.7735 + // Set callback back to previous value
10.7736 + window[ jsonpCallback ] = previous;
10.7737 + // Call if it was a function and we have a response
10.7738 + if ( responseContainer && jQuery.isFunction( previous ) ) {
10.7739 + window[ jsonpCallback ]( responseContainer[ 0 ] );
10.7740 + }
10.7741 + });
10.7742 +
10.7743 + // Use data converter to retrieve json after script execution
10.7744 + s.converters["script json"] = function() {
10.7745 + if ( !responseContainer ) {
10.7746 + jQuery.error( jsonpCallback + " was not called" );
10.7747 + }
10.7748 + return responseContainer[ 0 ];
10.7749 + };
10.7750 +
10.7751 + // force json dataType
10.7752 + s.dataTypes[ 0 ] = "json";
10.7753 +
10.7754 + // Delegate to script
10.7755 + return "script";
10.7756 + }
10.7757 +});
10.7758 +
10.7759 +
10.7760 +
10.7761 +
10.7762 +// Install script dataType
10.7763 +jQuery.ajaxSetup({
10.7764 + accepts: {
10.7765 + script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
10.7766 + },
10.7767 + contents: {
10.7768 + script: /javascript|ecmascript/
10.7769 + },
10.7770 + converters: {
10.7771 + "text script": function( text ) {
10.7772 + jQuery.globalEval( text );
10.7773 + return text;
10.7774 + }
10.7775 + }
10.7776 +});
10.7777 +
10.7778 +// Handle cache's special case and global
10.7779 +jQuery.ajaxPrefilter( "script", function( s ) {
10.7780 + if ( s.cache === undefined ) {
10.7781 + s.cache = false;
10.7782 + }
10.7783 + if ( s.crossDomain ) {
10.7784 + s.type = "GET";
10.7785 + s.global = false;
10.7786 + }
10.7787 +});
10.7788 +
10.7789 +// Bind script tag hack transport
10.7790 +jQuery.ajaxTransport( "script", function(s) {
10.7791 +
10.7792 + // This transport only deals with cross domain requests
10.7793 + if ( s.crossDomain ) {
10.7794 +
10.7795 + var script,
10.7796 + head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
10.7797 +
10.7798 + return {
10.7799 +
10.7800 + send: function( _, callback ) {
10.7801 +
10.7802 + script = document.createElement( "script" );
10.7803 +
10.7804 + script.async = "async";
10.7805 +
10.7806 + if ( s.scriptCharset ) {
10.7807 + script.charset = s.scriptCharset;
10.7808 + }
10.7809 +
10.7810 + script.src = s.url;
10.7811 +
10.7812 + // Attach handlers for all browsers
10.7813 + script.onload = script.onreadystatechange = function( _, isAbort ) {
10.7814 +
10.7815 + if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
10.7816 +
10.7817 + // Handle memory leak in IE
10.7818 + script.onload = script.onreadystatechange = null;
10.7819 +
10.7820 + // Remove the script
10.7821 + if ( head && script.parentNode ) {
10.7822 + head.removeChild( script );
10.7823 + }
10.7824 +
10.7825 + // Dereference the script
10.7826 + script = undefined;
10.7827 +
10.7828 + // Callback if not abort
10.7829 + if ( !isAbort ) {
10.7830 + callback( 200, "success" );
10.7831 + }
10.7832 + }
10.7833 + };
10.7834 + // Use insertBefore instead of appendChild to circumvent an IE6 bug.
10.7835 + // This arises when a base node is used (#2709 and #4378).
10.7836 + head.insertBefore( script, head.firstChild );
10.7837 + },
10.7838 +
10.7839 + abort: function() {
10.7840 + if ( script ) {
10.7841 + script.onload( 0, 1 );
10.7842 + }
10.7843 + }
10.7844 + };
10.7845 + }
10.7846 +});
10.7847 +
10.7848 +
10.7849 +
10.7850 +
10.7851 +var // #5280: Internet Explorer will keep connections alive if we don't abort on unload
10.7852 + xhrOnUnloadAbort = window.ActiveXObject ? function() {
10.7853 + // Abort all pending requests
10.7854 + for ( var key in xhrCallbacks ) {
10.7855 + xhrCallbacks[ key ]( 0, 1 );
10.7856 + }
10.7857 + } : false,
10.7858 + xhrId = 0,
10.7859 + xhrCallbacks;
10.7860 +
10.7861 +// Functions to create xhrs
10.7862 +function createStandardXHR() {
10.7863 + try {
10.7864 + return new window.XMLHttpRequest();
10.7865 + } catch( e ) {}
10.7866 +}
10.7867 +
10.7868 +function createActiveXHR() {
10.7869 + try {
10.7870 + return new window.ActiveXObject( "Microsoft.XMLHTTP" );
10.7871 + } catch( e ) {}
10.7872 +}
10.7873 +
10.7874 +// Create the request object
10.7875 +// (This is still attached to ajaxSettings for backward compatibility)
10.7876 +jQuery.ajaxSettings.xhr = window.ActiveXObject ?
10.7877 + /* Microsoft failed to properly
10.7878 + * implement the XMLHttpRequest in IE7 (can't request local files),
10.7879 + * so we use the ActiveXObject when it is available
10.7880 + * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
10.7881 + * we need a fallback.
10.7882 + */
10.7883 + function() {
10.7884 + return !this.isLocal && createStandardXHR() || createActiveXHR();
10.7885 + } :
10.7886 + // For all other browsers, use the standard XMLHttpRequest object
10.7887 + createStandardXHR;
10.7888 +
10.7889 +// Determine support properties
10.7890 +(function( xhr ) {
10.7891 + jQuery.extend( jQuery.support, {
10.7892 + ajax: !!xhr,
10.7893 + cors: !!xhr && ( "withCredentials" in xhr )
10.7894 + });
10.7895 +})( jQuery.ajaxSettings.xhr() );
10.7896 +
10.7897 +// Create transport if the browser can provide an xhr
10.7898 +if ( jQuery.support.ajax ) {
10.7899 +
10.7900 + jQuery.ajaxTransport(function( s ) {
10.7901 + // Cross domain only allowed if supported through XMLHttpRequest
10.7902 + if ( !s.crossDomain || jQuery.support.cors ) {
10.7903 +
10.7904 + var callback;
10.7905 +
10.7906 + return {
10.7907 + send: function( headers, complete ) {
10.7908 +
10.7909 + // Get a new xhr
10.7910 + var xhr = s.xhr(),
10.7911 + handle,
10.7912 + i;
10.7913 +
10.7914 + // Open the socket
10.7915 + // Passing null username, generates a login popup on Opera (#2865)
10.7916 + if ( s.username ) {
10.7917 + xhr.open( s.type, s.url, s.async, s.username, s.password );
10.7918 + } else {
10.7919 + xhr.open( s.type, s.url, s.async );
10.7920 + }
10.7921 +
10.7922 + // Apply custom fields if provided
10.7923 + if ( s.xhrFields ) {
10.7924 + for ( i in s.xhrFields ) {
10.7925 + xhr[ i ] = s.xhrFields[ i ];
10.7926 + }
10.7927 + }
10.7928 +
10.7929 + // Override mime type if needed
10.7930 + if ( s.mimeType && xhr.overrideMimeType ) {
10.7931 + xhr.overrideMimeType( s.mimeType );
10.7932 + }
10.7933 +
10.7934 + // X-Requested-With header
10.7935 + // For cross-domain requests, seeing as conditions for a preflight are
10.7936 + // akin to a jigsaw puzzle, we simply never set it to be sure.
10.7937 + // (it can always be set on a per-request basis or even using ajaxSetup)
10.7938 + // For same-domain requests, won't change header if already provided.
10.7939 + if ( !s.crossDomain && !headers["X-Requested-With"] ) {
10.7940 + headers[ "X-Requested-With" ] = "XMLHttpRequest";
10.7941 + }
10.7942 +
10.7943 + // Need an extra try/catch for cross domain requests in Firefox 3
10.7944 + try {
10.7945 + for ( i in headers ) {
10.7946 + xhr.setRequestHeader( i, headers[ i ] );
10.7947 + }
10.7948 + } catch( _ ) {}
10.7949 +
10.7950 + // Do send the request
10.7951 + // This may raise an exception which is actually
10.7952 + // handled in jQuery.ajax (so no try/catch here)
10.7953 + xhr.send( ( s.hasContent && s.data ) || null );
10.7954 +
10.7955 + // Listener
10.7956 + callback = function( _, isAbort ) {
10.7957 +
10.7958 + var status,
10.7959 + statusText,
10.7960 + responseHeaders,
10.7961 + responses,
10.7962 + xml;
10.7963 +
10.7964 + // Firefox throws exceptions when accessing properties
10.7965 + // of an xhr when a network error occured
10.7966 + // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
10.7967 + try {
10.7968 +
10.7969 + // Was never called and is aborted or complete
10.7970 + if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
10.7971 +
10.7972 + // Only called once
10.7973 + callback = undefined;
10.7974 +
10.7975 + // Do not keep as active anymore
10.7976 + if ( handle ) {
10.7977 + xhr.onreadystatechange = jQuery.noop;
10.7978 + if ( xhrOnUnloadAbort ) {
10.7979 + delete xhrCallbacks[ handle ];
10.7980 + }
10.7981 + }
10.7982 +
10.7983 + // If it's an abort
10.7984 + if ( isAbort ) {
10.7985 + // Abort it manually if needed
10.7986 + if ( xhr.readyState !== 4 ) {
10.7987 + xhr.abort();
10.7988 + }
10.7989 + } else {
10.7990 + status = xhr.status;
10.7991 + responseHeaders = xhr.getAllResponseHeaders();
10.7992 + responses = {};
10.7993 + xml = xhr.responseXML;
10.7994 +
10.7995 + // Construct response list
10.7996 + if ( xml && xml.documentElement /* #4958 */ ) {
10.7997 + responses.xml = xml;
10.7998 + }
10.7999 + responses.text = xhr.responseText;
10.8000 +
10.8001 + // Firefox throws an exception when accessing
10.8002 + // statusText for faulty cross-domain requests
10.8003 + try {
10.8004 + statusText = xhr.statusText;
10.8005 + } catch( e ) {
10.8006 + // We normalize with Webkit giving an empty statusText
10.8007 + statusText = "";
10.8008 + }
10.8009 +
10.8010 + // Filter status for non standard behaviors
10.8011 +
10.8012 + // If the request is local and we have data: assume a success
10.8013 + // (success with no data won't get notified, that's the best we
10.8014 + // can do given current implementations)
10.8015 + if ( !status && s.isLocal && !s.crossDomain ) {
10.8016 + status = responses.text ? 200 : 404;
10.8017 + // IE - #1450: sometimes returns 1223 when it should be 204
10.8018 + } else if ( status === 1223 ) {
10.8019 + status = 204;
10.8020 + }
10.8021 + }
10.8022 + }
10.8023 + } catch( firefoxAccessException ) {
10.8024 + if ( !isAbort ) {
10.8025 + complete( -1, firefoxAccessException );
10.8026 + }
10.8027 + }
10.8028 +
10.8029 + // Call complete if needed
10.8030 + if ( responses ) {
10.8031 + complete( status, statusText, responses, responseHeaders );
10.8032 + }
10.8033 + };
10.8034 +
10.8035 + // if we're in sync mode or it's in cache
10.8036 + // and has been retrieved directly (IE6 & IE7)
10.8037 + // we need to manually fire the callback
10.8038 + if ( !s.async || xhr.readyState === 4 ) {
10.8039 + callback();
10.8040 + } else {
10.8041 + handle = ++xhrId;
10.8042 + if ( xhrOnUnloadAbort ) {
10.8043 + // Create the active xhrs callbacks list if needed
10.8044 + // and attach the unload handler
10.8045 + if ( !xhrCallbacks ) {
10.8046 + xhrCallbacks = {};
10.8047 + jQuery( window ).unload( xhrOnUnloadAbort );
10.8048 + }
10.8049 + // Add to list of active xhrs callbacks
10.8050 + xhrCallbacks[ handle ] = callback;
10.8051 + }
10.8052 + xhr.onreadystatechange = callback;
10.8053 + }
10.8054 + },
10.8055 +
10.8056 + abort: function() {
10.8057 + if ( callback ) {
10.8058 + callback(0,1);
10.8059 + }
10.8060 + }
10.8061 + };
10.8062 + }
10.8063 + });
10.8064 +}
10.8065 +
10.8066 +
10.8067 +
10.8068 +
10.8069 +var elemdisplay = {},
10.8070 + iframe, iframeDoc,
10.8071 + rfxtypes = /^(?:toggle|show|hide)$/,
10.8072 + rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
10.8073 + timerId,
10.8074 + fxAttrs = [
10.8075 + // height animations
10.8076 + [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
10.8077 + // width animations
10.8078 + [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
10.8079 + // opacity animations
10.8080 + [ "opacity" ]
10.8081 + ],
10.8082 + fxNow;
10.8083 +
10.8084 +jQuery.fn.extend({
10.8085 + show: function( speed, easing, callback ) {
10.8086 + var elem, display;
10.8087 +
10.8088 + if ( speed || speed === 0 ) {
10.8089 + return this.animate( genFx("show", 3), speed, easing, callback);
10.8090 +
10.8091 + } else {
10.8092 + for ( var i = 0, j = this.length; i < j; i++ ) {
10.8093 + elem = this[i];
10.8094 +
10.8095 + if ( elem.style ) {
10.8096 + display = elem.style.display;
10.8097 +
10.8098 + // Reset the inline display of this element to learn if it is
10.8099 + // being hidden by cascaded rules or not
10.8100 + if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
10.8101 + display = elem.style.display = "";
10.8102 + }
10.8103 +
10.8104 + // Set elements which have been overridden with display: none
10.8105 + // in a stylesheet to whatever the default browser style is
10.8106 + // for such an element
10.8107 + if ( display === "" && jQuery.css( elem, "display" ) === "none" ) {
10.8108 + jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName));
10.8109 + }
10.8110 + }
10.8111 + }
10.8112 +
10.8113 + // Set the display of most of the elements in a second loop
10.8114 + // to avoid the constant reflow
10.8115 + for ( i = 0; i < j; i++ ) {
10.8116 + elem = this[i];
10.8117 +
10.8118 + if ( elem.style ) {
10.8119 + display = elem.style.display;
10.8120 +
10.8121 + if ( display === "" || display === "none" ) {
10.8122 + elem.style.display = jQuery._data(elem, "olddisplay") || "";
10.8123 + }
10.8124 + }
10.8125 + }
10.8126 +
10.8127 + return this;
10.8128 + }
10.8129 + },
10.8130 +
10.8131 + hide: function( speed, easing, callback ) {
10.8132 + if ( speed || speed === 0 ) {
10.8133 + return this.animate( genFx("hide", 3), speed, easing, callback);
10.8134 +
10.8135 + } else {
10.8136 + for ( var i = 0, j = this.length; i < j; i++ ) {
10.8137 + if ( this[i].style ) {
10.8138 + var display = jQuery.css( this[i], "display" );
10.8139 +
10.8140 + if ( display !== "none" && !jQuery._data( this[i], "olddisplay" ) ) {
10.8141 + jQuery._data( this[i], "olddisplay", display );
10.8142 + }
10.8143 + }
10.8144 + }
10.8145 +
10.8146 + // Set the display of the elements in a second loop
10.8147 + // to avoid the constant reflow
10.8148 + for ( i = 0; i < j; i++ ) {
10.8149 + if ( this[i].style ) {
10.8150 + this[i].style.display = "none";
10.8151 + }
10.8152 + }
10.8153 +
10.8154 + return this;
10.8155 + }
10.8156 + },
10.8157 +
10.8158 + // Save the old toggle function
10.8159 + _toggle: jQuery.fn.toggle,
10.8160 +
10.8161 + toggle: function( fn, fn2, callback ) {
10.8162 + var bool = typeof fn === "boolean";
10.8163 +
10.8164 + if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
10.8165 + this._toggle.apply( this, arguments );
10.8166 +
10.8167 + } else if ( fn == null || bool ) {
10.8168 + this.each(function() {
10.8169 + var state = bool ? fn : jQuery(this).is(":hidden");
10.8170 + jQuery(this)[ state ? "show" : "hide" ]();
10.8171 + });
10.8172 +
10.8173 + } else {
10.8174 + this.animate(genFx("toggle", 3), fn, fn2, callback);
10.8175 + }
10.8176 +
10.8177 + return this;
10.8178 + },
10.8179 +
10.8180 + fadeTo: function( speed, to, easing, callback ) {
10.8181 + return this.filter(":hidden").css("opacity", 0).show().end()
10.8182 + .animate({opacity: to}, speed, easing, callback);
10.8183 + },
10.8184 +
10.8185 + animate: function( prop, speed, easing, callback ) {
10.8186 + var optall = jQuery.speed(speed, easing, callback);
10.8187 +
10.8188 + if ( jQuery.isEmptyObject( prop ) ) {
10.8189 + return this.each( optall.complete, [ false ] );
10.8190 + }
10.8191 +
10.8192 + // Do not change referenced properties as per-property easing will be lost
10.8193 + prop = jQuery.extend( {}, prop );
10.8194 +
10.8195 + return this[ optall.queue === false ? "each" : "queue" ](function() {
10.8196 + // XXX 'this' does not always have a nodeName when running the
10.8197 + // test suite
10.8198 +
10.8199 + if ( optall.queue === false ) {
10.8200 + jQuery._mark( this );
10.8201 + }
10.8202 +
10.8203 + var opt = jQuery.extend( {}, optall ),
10.8204 + isElement = this.nodeType === 1,
10.8205 + hidden = isElement && jQuery(this).is(":hidden"),
10.8206 + name, val, p,
10.8207 + display, e,
10.8208 + parts, start, end, unit;
10.8209 +
10.8210 + // will store per property easing and be used to determine when an animation is complete
10.8211 + opt.animatedProperties = {};
10.8212 +
10.8213 + for ( p in prop ) {
10.8214 +
10.8215 + // property name normalization
10.8216 + name = jQuery.camelCase( p );
10.8217 + if ( p !== name ) {
10.8218 + prop[ name ] = prop[ p ];
10.8219 + delete prop[ p ];
10.8220 + }
10.8221 +
10.8222 + val = prop[ name ];
10.8223 +
10.8224 + // easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default)
10.8225 + if ( jQuery.isArray( val ) ) {
10.8226 + opt.animatedProperties[ name ] = val[ 1 ];
10.8227 + val = prop[ name ] = val[ 0 ];
10.8228 + } else {
10.8229 + opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing';
10.8230 + }
10.8231 +
10.8232 + if ( val === "hide" && hidden || val === "show" && !hidden ) {
10.8233 + return opt.complete.call( this );
10.8234 + }
10.8235 +
10.8236 + if ( isElement && ( name === "height" || name === "width" ) ) {
10.8237 + // Make sure that nothing sneaks out
10.8238 + // Record all 3 overflow attributes because IE does not
10.8239 + // change the overflow attribute when overflowX and
10.8240 + // overflowY are set to the same value
10.8241 + opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];
10.8242 +
10.8243 + // Set display property to inline-block for height/width
10.8244 + // animations on inline elements that are having width/height
10.8245 + // animated
10.8246 + if ( jQuery.css( this, "display" ) === "inline" &&
10.8247 + jQuery.css( this, "float" ) === "none" ) {
10.8248 + if ( !jQuery.support.inlineBlockNeedsLayout ) {
10.8249 + this.style.display = "inline-block";
10.8250 +
10.8251 + } else {
10.8252 + display = defaultDisplay( this.nodeName );
10.8253 +
10.8254 + // inline-level elements accept inline-block;
10.8255 + // block-level elements need to be inline with layout
10.8256 + if ( display === "inline" ) {
10.8257 + this.style.display = "inline-block";
10.8258 +
10.8259 + } else {
10.8260 + this.style.display = "inline";
10.8261 + this.style.zoom = 1;
10.8262 + }
10.8263 + }
10.8264 + }
10.8265 + }
10.8266 + }
10.8267 +
10.8268 + if ( opt.overflow != null ) {
10.8269 + this.style.overflow = "hidden";
10.8270 + }
10.8271 +
10.8272 + for ( p in prop ) {
10.8273 + e = new jQuery.fx( this, opt, p );
10.8274 + val = prop[ p ];
10.8275 +
10.8276 + if ( rfxtypes.test(val) ) {
10.8277 + e[ val === "toggle" ? hidden ? "show" : "hide" : val ]();
10.8278 +
10.8279 + } else {
10.8280 + parts = rfxnum.exec( val );
10.8281 + start = e.cur();
10.8282 +
10.8283 + if ( parts ) {
10.8284 + end = parseFloat( parts[2] );
10.8285 + unit = parts[3] || ( jQuery.cssNumber[ p ] ? "" : "px" );
10.8286 +
10.8287 + // We need to compute starting value
10.8288 + if ( unit !== "px" ) {
10.8289 + jQuery.style( this, p, (end || 1) + unit);
10.8290 + start = ((end || 1) / e.cur()) * start;
10.8291 + jQuery.style( this, p, start + unit);
10.8292 + }
10.8293 +
10.8294 + // If a +=/-= token was provided, we're doing a relative animation
10.8295 + if ( parts[1] ) {
10.8296 + end = ( (parts[ 1 ] === "-=" ? -1 : 1) * end ) + start;
10.8297 + }
10.8298 +
10.8299 + e.custom( start, end, unit );
10.8300 +
10.8301 + } else {
10.8302 + e.custom( start, val, "" );
10.8303 + }
10.8304 + }
10.8305 + }
10.8306 +
10.8307 + // For JS strict compliance
10.8308 + return true;
10.8309 + });
10.8310 + },
10.8311 +
10.8312 + stop: function( clearQueue, gotoEnd ) {
10.8313 + if ( clearQueue ) {
10.8314 + this.queue([]);
10.8315 + }
10.8316 +
10.8317 + this.each(function() {
10.8318 + var timers = jQuery.timers,
10.8319 + i = timers.length;
10.8320 + // clear marker counters if we know they won't be
10.8321 + if ( !gotoEnd ) {
10.8322 + jQuery._unmark( true, this );
10.8323 + }
10.8324 + while ( i-- ) {
10.8325 + if ( timers[i].elem === this ) {
10.8326 + if (gotoEnd) {
10.8327 + // force the next step to be the last
10.8328 + timers[i](true);
10.8329 + }
10.8330 +
10.8331 + timers.splice(i, 1);
10.8332 + }
10.8333 + }
10.8334 + });
10.8335 +
10.8336 + // start the next in the queue if the last step wasn't forced
10.8337 + if ( !gotoEnd ) {
10.8338 + this.dequeue();
10.8339 + }
10.8340 +
10.8341 + return this;
10.8342 + }
10.8343 +
10.8344 +});
10.8345 +
10.8346 +// Animations created synchronously will run synchronously
10.8347 +function createFxNow() {
10.8348 + setTimeout( clearFxNow, 0 );
10.8349 + return ( fxNow = jQuery.now() );
10.8350 +}
10.8351 +
10.8352 +function clearFxNow() {
10.8353 + fxNow = undefined;
10.8354 +}
10.8355 +
10.8356 +// Generate parameters to create a standard animation
10.8357 +function genFx( type, num ) {
10.8358 + var obj = {};
10.8359 +
10.8360 + jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
10.8361 + obj[ this ] = type;
10.8362 + });
10.8363 +
10.8364 + return obj;
10.8365 +}
10.8366 +
10.8367 +// Generate shortcuts for custom animations
10.8368 +jQuery.each({
10.8369 + slideDown: genFx("show", 1),
10.8370 + slideUp: genFx("hide", 1),
10.8371 + slideToggle: genFx("toggle", 1),
10.8372 + fadeIn: { opacity: "show" },
10.8373 + fadeOut: { opacity: "hide" },
10.8374 + fadeToggle: { opacity: "toggle" }
10.8375 +}, function( name, props ) {
10.8376 + jQuery.fn[ name ] = function( speed, easing, callback ) {
10.8377 + return this.animate( props, speed, easing, callback );
10.8378 + };
10.8379 +});
10.8380 +
10.8381 +jQuery.extend({
10.8382 + speed: function( speed, easing, fn ) {
10.8383 + var opt = speed && typeof speed === "object" ? jQuery.extend({}, speed) : {
10.8384 + complete: fn || !fn && easing ||
10.8385 + jQuery.isFunction( speed ) && speed,
10.8386 + duration: speed,
10.8387 + easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
10.8388 + };
10.8389 +
10.8390 + opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
10.8391 + opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[opt.duration] : jQuery.fx.speeds._default;
10.8392 +
10.8393 + // Queueing
10.8394 + opt.old = opt.complete;
10.8395 + opt.complete = function( noUnmark ) {
10.8396 + if ( jQuery.isFunction( opt.old ) ) {
10.8397 + opt.old.call( this );
10.8398 + }
10.8399 +
10.8400 + if ( opt.queue !== false ) {
10.8401 + jQuery.dequeue( this );
10.8402 + } else if ( noUnmark !== false ) {
10.8403 + jQuery._unmark( this );
10.8404 + }
10.8405 + };
10.8406 +
10.8407 + return opt;
10.8408 + },
10.8409 +
10.8410 + easing: {
10.8411 + linear: function( p, n, firstNum, diff ) {
10.8412 + return firstNum + diff * p;
10.8413 + },
10.8414 + swing: function( p, n, firstNum, diff ) {
10.8415 + return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
10.8416 + }
10.8417 + },
10.8418 +
10.8419 + timers: [],
10.8420 +
10.8421 + fx: function( elem, options, prop ) {
10.8422 + this.options = options;
10.8423 + this.elem = elem;
10.8424 + this.prop = prop;
10.8425 +
10.8426 + options.orig = options.orig || {};
10.8427 + }
10.8428 +
10.8429 +});
10.8430 +
10.8431 +jQuery.fx.prototype = {
10.8432 + // Simple function for setting a style value
10.8433 + update: function() {
10.8434 + if ( this.options.step ) {
10.8435 + this.options.step.call( this.elem, this.now, this );
10.8436 + }
10.8437 +
10.8438 + (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
10.8439 + },
10.8440 +
10.8441 + // Get the current size
10.8442 + cur: function() {
10.8443 + if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
10.8444 + return this.elem[ this.prop ];
10.8445 + }
10.8446 +
10.8447 + var parsed,
10.8448 + r = jQuery.css( this.elem, this.prop );
10.8449 + // Empty strings, null, undefined and "auto" are converted to 0,
10.8450 + // complex values such as "rotate(1rad)" are returned as is,
10.8451 + // simple values such as "10px" are parsed to Float.
10.8452 + return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
10.8453 + },
10.8454 +
10.8455 + // Start an animation from one number to another
10.8456 + custom: function( from, to, unit ) {
10.8457 + var self = this,
10.8458 + fx = jQuery.fx;
10.8459 +
10.8460 + this.startTime = fxNow || createFxNow();
10.8461 + this.start = from;
10.8462 + this.end = to;
10.8463 + this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
10.8464 + this.now = this.start;
10.8465 + this.pos = this.state = 0;
10.8466 +
10.8467 + function t( gotoEnd ) {
10.8468 + return self.step(gotoEnd);
10.8469 + }
10.8470 +
10.8471 + t.elem = this.elem;
10.8472 +
10.8473 + if ( t() && jQuery.timers.push(t) && !timerId ) {
10.8474 + timerId = setInterval( fx.tick, fx.interval );
10.8475 + }
10.8476 + },
10.8477 +
10.8478 + // Simple 'show' function
10.8479 + show: function() {
10.8480 + // Remember where we started, so that we can go back to it later
10.8481 + this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
10.8482 + this.options.show = true;
10.8483 +
10.8484 + // Begin the animation
10.8485 + // Make sure that we start at a small width/height to avoid any
10.8486 + // flash of content
10.8487 + this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
10.8488 +
10.8489 + // Start by showing the element
10.8490 + jQuery( this.elem ).show();
10.8491 + },
10.8492 +
10.8493 + // Simple 'hide' function
10.8494 + hide: function() {
10.8495 + // Remember where we started, so that we can go back to it later
10.8496 + this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
10.8497 + this.options.hide = true;
10.8498 +
10.8499 + // Begin the animation
10.8500 + this.custom(this.cur(), 0);
10.8501 + },
10.8502 +
10.8503 + // Each step of an animation
10.8504 + step: function( gotoEnd ) {
10.8505 + var t = fxNow || createFxNow(),
10.8506 + done = true,
10.8507 + elem = this.elem,
10.8508 + options = this.options,
10.8509 + i, n;
10.8510 +
10.8511 + if ( gotoEnd || t >= options.duration + this.startTime ) {
10.8512 + this.now = this.end;
10.8513 + this.pos = this.state = 1;
10.8514 + this.update();
10.8515 +
10.8516 + options.animatedProperties[ this.prop ] = true;
10.8517 +
10.8518 + for ( i in options.animatedProperties ) {
10.8519 + if ( options.animatedProperties[i] !== true ) {
10.8520 + done = false;
10.8521 + }
10.8522 + }
10.8523 +
10.8524 + if ( done ) {
10.8525 + // Reset the overflow
10.8526 + if ( options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
10.8527 +
10.8528 + jQuery.each( [ "", "X", "Y" ], function (index, value) {
10.8529 + elem.style[ "overflow" + value ] = options.overflow[index];
10.8530 + });
10.8531 + }
10.8532 +
10.8533 + // Hide the element if the "hide" operation was done
10.8534 + if ( options.hide ) {
10.8535 + jQuery(elem).hide();
10.8536 + }
10.8537 +
10.8538 + // Reset the properties, if the item has been hidden or shown
10.8539 + if ( options.hide || options.show ) {
10.8540 + for ( var p in options.animatedProperties ) {
10.8541 + jQuery.style( elem, p, options.orig[p] );
10.8542 + }
10.8543 + }
10.8544 +
10.8545 + // Execute the complete function
10.8546 + options.complete.call( elem );
10.8547 + }
10.8548 +
10.8549 + return false;
10.8550 +
10.8551 + } else {
10.8552 + // classical easing cannot be used with an Infinity duration
10.8553 + if ( options.duration == Infinity ) {
10.8554 + this.now = t;
10.8555 + } else {
10.8556 + n = t - this.startTime;
10.8557 + this.state = n / options.duration;
10.8558 +
10.8559 + // Perform the easing function, defaults to swing
10.8560 + this.pos = jQuery.easing[ options.animatedProperties[ this.prop ] ]( this.state, n, 0, 1, options.duration );
10.8561 + this.now = this.start + ((this.end - this.start) * this.pos);
10.8562 + }
10.8563 + // Perform the next step of the animation
10.8564 + this.update();
10.8565 + }
10.8566 +
10.8567 + return true;
10.8568 + }
10.8569 +};
10.8570 +
10.8571 +jQuery.extend( jQuery.fx, {
10.8572 + tick: function() {
10.8573 + for ( var timers = jQuery.timers, i = 0 ; i < timers.length ; ++i ) {
10.8574 + if ( !timers[i]() ) {
10.8575 + timers.splice(i--, 1);
10.8576 + }
10.8577 + }
10.8578 +
10.8579 + if ( !timers.length ) {
10.8580 + jQuery.fx.stop();
10.8581 + }
10.8582 + },
10.8583 +
10.8584 + interval: 13,
10.8585 +
10.8586 + stop: function() {
10.8587 + clearInterval( timerId );
10.8588 + timerId = null;
10.8589 + },
10.8590 +
10.8591 + speeds: {
10.8592 + slow: 600,
10.8593 + fast: 200,
10.8594 + // Default speed
10.8595 + _default: 400
10.8596 + },
10.8597 +
10.8598 + step: {
10.8599 + opacity: function( fx ) {
10.8600 + jQuery.style( fx.elem, "opacity", fx.now );
10.8601 + },
10.8602 +
10.8603 + _default: function( fx ) {
10.8604 + if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
10.8605 + fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
10.8606 + } else {
10.8607 + fx.elem[ fx.prop ] = fx.now;
10.8608 + }
10.8609 + }
10.8610 + }
10.8611 +});
10.8612 +
10.8613 +if ( jQuery.expr && jQuery.expr.filters ) {
10.8614 + jQuery.expr.filters.animated = function( elem ) {
10.8615 + return jQuery.grep(jQuery.timers, function( fn ) {
10.8616 + return elem === fn.elem;
10.8617 + }).length;
10.8618 + };
10.8619 +}
10.8620 +
10.8621 +// Try to restore the default display value of an element
10.8622 +function defaultDisplay( nodeName ) {
10.8623 +
10.8624 + if ( !elemdisplay[ nodeName ] ) {
10.8625 +
10.8626 + var body = document.body,
10.8627 + elem = jQuery( "<" + nodeName + ">" ).appendTo( body ),
10.8628 + display = elem.css( "display" );
10.8629 +
10.8630 + elem.remove();
10.8631 +
10.8632 + // If the simple way fails,
10.8633 + // get element's real default display by attaching it to a temp iframe
10.8634 + if ( display === "none" || display === "" ) {
10.8635 + // No iframe to use yet, so create it
10.8636 + if ( !iframe ) {
10.8637 + iframe = document.createElement( "iframe" );
10.8638 + iframe.frameBorder = iframe.width = iframe.height = 0;
10.8639 + }
10.8640 +
10.8641 + body.appendChild( iframe );
10.8642 +
10.8643 + // Create a cacheable copy of the iframe document on first call.
10.8644 + // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
10.8645 + // document to it; WebKit & Firefox won't allow reusing the iframe document.
10.8646 + if ( !iframeDoc || !iframe.createElement ) {
10.8647 + iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
10.8648 + iframeDoc.write( ( document.compatMode === "CSS1Compat" ? "<!doctype html>" : "" ) + "<html><body>" );
10.8649 + iframeDoc.close();
10.8650 + }
10.8651 +
10.8652 + elem = iframeDoc.createElement( nodeName );
10.8653 +
10.8654 + iframeDoc.body.appendChild( elem );
10.8655 +
10.8656 + display = jQuery.css( elem, "display" );
10.8657 +
10.8658 + body.removeChild( iframe );
10.8659 + }
10.8660 +
10.8661 + // Store the correct default display
10.8662 + elemdisplay[ nodeName ] = display;
10.8663 + }
10.8664 +
10.8665 + return elemdisplay[ nodeName ];
10.8666 +}
10.8667 +
10.8668 +
10.8669 +
10.8670 +
10.8671 +var rtable = /^t(?:able|d|h)$/i,
10.8672 + rroot = /^(?:body|html)$/i;
10.8673 +
10.8674 +if ( "getBoundingClientRect" in document.documentElement ) {
10.8675 + jQuery.fn.offset = function( options ) {
10.8676 + var elem = this[0], box;
10.8677 +
10.8678 + if ( options ) {
10.8679 + return this.each(function( i ) {
10.8680 + jQuery.offset.setOffset( this, options, i );
10.8681 + });
10.8682 + }
10.8683 +
10.8684 + if ( !elem || !elem.ownerDocument ) {
10.8685 + return null;
10.8686 + }
10.8687 +
10.8688 + if ( elem === elem.ownerDocument.body ) {
10.8689 + return jQuery.offset.bodyOffset( elem );
10.8690 + }
10.8691 +
10.8692 + try {
10.8693 + box = elem.getBoundingClientRect();
10.8694 + } catch(e) {}
10.8695 +
10.8696 + var doc = elem.ownerDocument,
10.8697 + docElem = doc.documentElement;
10.8698 +
10.8699 + // Make sure we're not dealing with a disconnected DOM node
10.8700 + if ( !box || !jQuery.contains( docElem, elem ) ) {
10.8701 + return box ? { top: box.top, left: box.left } : { top: 0, left: 0 };
10.8702 + }
10.8703 +
10.8704 + var body = doc.body,
10.8705 + win = getWindow(doc),
10.8706 + clientTop = docElem.clientTop || body.clientTop || 0,
10.8707 + clientLeft = docElem.clientLeft || body.clientLeft || 0,
10.8708 + scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop,
10.8709 + scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft,
10.8710 + top = box.top + scrollTop - clientTop,
10.8711 + left = box.left + scrollLeft - clientLeft;
10.8712 +
10.8713 + return { top: top, left: left };
10.8714 + };
10.8715 +
10.8716 +} else {
10.8717 + jQuery.fn.offset = function( options ) {
10.8718 + var elem = this[0];
10.8719 +
10.8720 + if ( options ) {
10.8721 + return this.each(function( i ) {
10.8722 + jQuery.offset.setOffset( this, options, i );
10.8723 + });
10.8724 + }
10.8725 +
10.8726 + if ( !elem || !elem.ownerDocument ) {
10.8727 + return null;
10.8728 + }
10.8729 +
10.8730 + if ( elem === elem.ownerDocument.body ) {
10.8731 + return jQuery.offset.bodyOffset( elem );
10.8732 + }
10.8733 +
10.8734 + jQuery.offset.initialize();
10.8735 +
10.8736 + var computedStyle,
10.8737 + offsetParent = elem.offsetParent,
10.8738 + prevOffsetParent = elem,
10.8739 + doc = elem.ownerDocument,
10.8740 + docElem = doc.documentElement,
10.8741 + body = doc.body,
10.8742 + defaultView = doc.defaultView,
10.8743 + prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
10.8744 + top = elem.offsetTop,
10.8745 + left = elem.offsetLeft;
10.8746 +
10.8747 + while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
10.8748 + if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
10.8749 + break;
10.8750 + }
10.8751 +
10.8752 + computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
10.8753 + top -= elem.scrollTop;
10.8754 + left -= elem.scrollLeft;
10.8755 +
10.8756 + if ( elem === offsetParent ) {
10.8757 + top += elem.offsetTop;
10.8758 + left += elem.offsetLeft;
10.8759 +
10.8760 + if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
10.8761 + top += parseFloat( computedStyle.borderTopWidth ) || 0;
10.8762 + left += parseFloat( computedStyle.borderLeftWidth ) || 0;
10.8763 + }
10.8764 +
10.8765 + prevOffsetParent = offsetParent;
10.8766 + offsetParent = elem.offsetParent;
10.8767 + }
10.8768 +
10.8769 + if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
10.8770 + top += parseFloat( computedStyle.borderTopWidth ) || 0;
10.8771 + left += parseFloat( computedStyle.borderLeftWidth ) || 0;
10.8772 + }
10.8773 +
10.8774 + prevComputedStyle = computedStyle;
10.8775 + }
10.8776 +
10.8777 + if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
10.8778 + top += body.offsetTop;
10.8779 + left += body.offsetLeft;
10.8780 + }
10.8781 +
10.8782 + if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
10.8783 + top += Math.max( docElem.scrollTop, body.scrollTop );
10.8784 + left += Math.max( docElem.scrollLeft, body.scrollLeft );
10.8785 + }
10.8786 +
10.8787 + return { top: top, left: left };
10.8788 + };
10.8789 +}
10.8790 +
10.8791 +jQuery.offset = {
10.8792 + initialize: function() {
10.8793 + var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.css(body, "marginTop") ) || 0,
10.8794 + html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
10.8795 +
10.8796 + jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
10.8797 +
10.8798 + container.innerHTML = html;
10.8799 + body.insertBefore( container, body.firstChild );
10.8800 + innerDiv = container.firstChild;
10.8801 + checkDiv = innerDiv.firstChild;
10.8802 + td = innerDiv.nextSibling.firstChild.firstChild;
10.8803 +
10.8804 + this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
10.8805 + this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
10.8806 +
10.8807 + checkDiv.style.position = "fixed";
10.8808 + checkDiv.style.top = "20px";
10.8809 +
10.8810 + // safari subtracts parent border width here which is 5px
10.8811 + this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
10.8812 + checkDiv.style.position = checkDiv.style.top = "";
10.8813 +
10.8814 + innerDiv.style.overflow = "hidden";
10.8815 + innerDiv.style.position = "relative";
10.8816 +
10.8817 + this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
10.8818 +
10.8819 + this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
10.8820 +
10.8821 + body.removeChild( container );
10.8822 + jQuery.offset.initialize = jQuery.noop;
10.8823 + },
10.8824 +
10.8825 + bodyOffset: function( body ) {
10.8826 + var top = body.offsetTop,
10.8827 + left = body.offsetLeft;
10.8828 +
10.8829 + jQuery.offset.initialize();
10.8830 +
10.8831 + if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
10.8832 + top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
10.8833 + left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
10.8834 + }
10.8835 +
10.8836 + return { top: top, left: left };
10.8837 + },
10.8838 +
10.8839 + setOffset: function( elem, options, i ) {
10.8840 + var position = jQuery.css( elem, "position" );
10.8841 +
10.8842 + // set position first, in-case top/left are set even on static elem
10.8843 + if ( position === "static" ) {
10.8844 + elem.style.position = "relative";
10.8845 + }
10.8846 +
10.8847 + var curElem = jQuery( elem ),
10.8848 + curOffset = curElem.offset(),
10.8849 + curCSSTop = jQuery.css( elem, "top" ),
10.8850 + curCSSLeft = jQuery.css( elem, "left" ),
10.8851 + calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
10.8852 + props = {}, curPosition = {}, curTop, curLeft;
10.8853 +
10.8854 + // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
10.8855 + if ( calculatePosition ) {
10.8856 + curPosition = curElem.position();
10.8857 + curTop = curPosition.top;
10.8858 + curLeft = curPosition.left;
10.8859 + } else {
10.8860 + curTop = parseFloat( curCSSTop ) || 0;
10.8861 + curLeft = parseFloat( curCSSLeft ) || 0;
10.8862 + }
10.8863 +
10.8864 + if ( jQuery.isFunction( options ) ) {
10.8865 + options = options.call( elem, i, curOffset );
10.8866 + }
10.8867 +
10.8868 + if (options.top != null) {
10.8869 + props.top = (options.top - curOffset.top) + curTop;
10.8870 + }
10.8871 + if (options.left != null) {
10.8872 + props.left = (options.left - curOffset.left) + curLeft;
10.8873 + }
10.8874 +
10.8875 + if ( "using" in options ) {
10.8876 + options.using.call( elem, props );
10.8877 + } else {
10.8878 + curElem.css( props );
10.8879 + }
10.8880 + }
10.8881 +};
10.8882 +
10.8883 +
10.8884 +jQuery.fn.extend({
10.8885 + position: function() {
10.8886 + if ( !this[0] ) {
10.8887 + return null;
10.8888 + }
10.8889 +
10.8890 + var elem = this[0],
10.8891 +
10.8892 + // Get *real* offsetParent
10.8893 + offsetParent = this.offsetParent(),
10.8894 +
10.8895 + // Get correct offsets
10.8896 + offset = this.offset(),
10.8897 + parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
10.8898 +
10.8899 + // Subtract element margins
10.8900 + // note: when an element has margin: auto the offsetLeft and marginLeft
10.8901 + // are the same in Safari causing offset.left to incorrectly be 0
10.8902 + offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
10.8903 + offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
10.8904 +
10.8905 + // Add offsetParent borders
10.8906 + parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
10.8907 + parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
10.8908 +
10.8909 + // Subtract the two offsets
10.8910 + return {
10.8911 + top: offset.top - parentOffset.top,
10.8912 + left: offset.left - parentOffset.left
10.8913 + };
10.8914 + },
10.8915 +
10.8916 + offsetParent: function() {
10.8917 + return this.map(function() {
10.8918 + var offsetParent = this.offsetParent || document.body;
10.8919 + while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
10.8920 + offsetParent = offsetParent.offsetParent;
10.8921 + }
10.8922 + return offsetParent;
10.8923 + });
10.8924 + }
10.8925 +});
10.8926 +
10.8927 +
10.8928 +// Create scrollLeft and scrollTop methods
10.8929 +jQuery.each( ["Left", "Top"], function( i, name ) {
10.8930 + var method = "scroll" + name;
10.8931 +
10.8932 + jQuery.fn[ method ] = function( val ) {
10.8933 + var elem, win;
10.8934 +
10.8935 + if ( val === undefined ) {
10.8936 + elem = this[ 0 ];
10.8937 +
10.8938 + if ( !elem ) {
10.8939 + return null;
10.8940 + }
10.8941 +
10.8942 + win = getWindow( elem );
10.8943 +
10.8944 + // Return the scroll offset
10.8945 + return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
10.8946 + jQuery.support.boxModel && win.document.documentElement[ method ] ||
10.8947 + win.document.body[ method ] :
10.8948 + elem[ method ];
10.8949 + }
10.8950 +
10.8951 + // Set the scroll offset
10.8952 + return this.each(function() {
10.8953 + win = getWindow( this );
10.8954 +
10.8955 + if ( win ) {
10.8956 + win.scrollTo(
10.8957 + !i ? val : jQuery( win ).scrollLeft(),
10.8958 + i ? val : jQuery( win ).scrollTop()
10.8959 + );
10.8960 +
10.8961 + } else {
10.8962 + this[ method ] = val;
10.8963 + }
10.8964 + });
10.8965 + };
10.8966 +});
10.8967 +
10.8968 +function getWindow( elem ) {
10.8969 + return jQuery.isWindow( elem ) ?
10.8970 + elem :
10.8971 + elem.nodeType === 9 ?
10.8972 + elem.defaultView || elem.parentWindow :
10.8973 + false;
10.8974 +}
10.8975 +
10.8976 +
10.8977 +
10.8978 +
10.8979 +// Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods
10.8980 +jQuery.each([ "Height", "Width" ], function( i, name ) {
10.8981 +
10.8982 + var type = name.toLowerCase();
10.8983 +
10.8984 + // innerHeight and innerWidth
10.8985 + jQuery.fn[ "inner" + name ] = function() {
10.8986 + var elem = this[0];
10.8987 + return elem && elem.style ?
10.8988 + parseFloat( jQuery.css( elem, type, "padding" ) ) :
10.8989 + null;
10.8990 + };
10.8991 +
10.8992 + // outerHeight and outerWidth
10.8993 + jQuery.fn[ "outer" + name ] = function( margin ) {
10.8994 + var elem = this[0];
10.8995 + return elem && elem.style ?
10.8996 + parseFloat( jQuery.css( elem, type, margin ? "margin" : "border" ) ) :
10.8997 + null;
10.8998 + };
10.8999 +
10.9000 + jQuery.fn[ type ] = function( size ) {
10.9001 + // Get window width or height
10.9002 + var elem = this[0];
10.9003 + if ( !elem ) {
10.9004 + return size == null ? null : this;
10.9005 + }
10.9006 +
10.9007 + if ( jQuery.isFunction( size ) ) {
10.9008 + return this.each(function( i ) {
10.9009 + var self = jQuery( this );
10.9010 + self[ type ]( size.call( this, i, self[ type ]() ) );
10.9011 + });
10.9012 + }
10.9013 +
10.9014 + if ( jQuery.isWindow( elem ) ) {
10.9015 + // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
10.9016 + // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
10.9017 + var docElemProp = elem.document.documentElement[ "client" + name ],
10.9018 + body = elem.document.body;
10.9019 + return elem.document.compatMode === "CSS1Compat" && docElemProp ||
10.9020 + body && body[ "client" + name ] || docElemProp;
10.9021 +
10.9022 + // Get document width or height
10.9023 + } else if ( elem.nodeType === 9 ) {
10.9024 + // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
10.9025 + return Math.max(
10.9026 + elem.documentElement["client" + name],
10.9027 + elem.body["scroll" + name], elem.documentElement["scroll" + name],
10.9028 + elem.body["offset" + name], elem.documentElement["offset" + name]
10.9029 + );
10.9030 +
10.9031 + // Get or set width or height on the element
10.9032 + } else if ( size === undefined ) {
10.9033 + var orig = jQuery.css( elem, type ),
10.9034 + ret = parseFloat( orig );
10.9035 +
10.9036 + return jQuery.isNaN( ret ) ? orig : ret;
10.9037 +
10.9038 + // Set the width or height on the element (default to pixels if value is unitless)
10.9039 + } else {
10.9040 + return this.css( type, typeof size === "string" ? size : size + "px" );
10.9041 + }
10.9042 + };
10.9043 +
10.9044 +});
10.9045 +
10.9046 +
10.9047 +// Expose jQuery to the global object
10.9048 +window.jQuery = window.$ = jQuery;
10.9049 +})(window);
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/httpdocs/script.js Mon Feb 20 15:10:53 2012 +0100
11.3 @@ -0,0 +1,54 @@
11.4 +var server = 'http://' + window.location.hostname + ':' + window.location.port;
11.5 +
11.6 +function request_words() {
11.7 + $.ajax({url: server + '/words',
11.8 + dataType: 'json',
11.9 + success: callback});
11.10 +}
11.11 +
11.12 +function select(better, worse) {
11.13 + $.ajax({url: server + '/rate',
11.14 + dataType: 'json',
11.15 + data: 'bn=' + better[0] + '&br=' + better[1]
11.16 + + '&wn=' + worse[0] + '&wr=' + worse[1],
11.17 + success: callback});
11.18 +}
11.19 +
11.20 +function select_left() {
11.21 + select(new Array($.cookie('left-word'), $.cookie('left-rank')),
11.22 + new Array($.cookie('right-word'), $.cookie('right-rank')));
11.23 +}
11.24 +
11.25 +function select_right() {
11.26 + select(new Array($.cookie('right-word'), $.cookie('right-rank')),
11.27 + new Array($.cookie('left-word'), $.cookie('left-rank')));
11.28 +}
11.29 +
11.30 +function callback(data, status, xhr) {
11.31 + $('#compare-left').text(data.words[0][0]);
11.32 + $('#compare-right').text(data.words[1][0]);
11.33 + if (data.words[2] && data.words[3]) {
11.34 + $('#result-left').text(data.words[2][0]);
11.35 + $('#result-left-rating').text(data.words[2][1]);
11.36 + $('#result-right').text(data.words[3][0]);
11.37 + $('#result-right-rating').text(data.words[3][1]);
11.38 + }
11.39 + $.cookie('left-word', data.words[0][0]);
11.40 + $.cookie('left-rank', data.words[0][1]);
11.41 + $.cookie('right-word', data.words[1][0]);
11.42 + $.cookie('right-rank', data.words[1][1]);
11.43 +}
11.44 +
11.45 +$(document).ready (
11.46 + function() {
11.47 + request_words();
11.48 + }
11.49 +);
11.50 +
11.51 +$(document).keypress (
11.52 + function(event) {
11.53 + if (event.which == 13) {
11.54 + event.preventDefault();
11.55 + }
11.56 + }
11.57 +);
11.58 \ No newline at end of file
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
12.2 +++ b/httpdocs/style.css Mon Feb 20 15:10:53 2012 +0100
12.3 @@ -0,0 +1,140 @@
12.4 +@font-face {
12.5 + font-family: TitilliumText1;
12.6 + src: url(fonts/TitilliumText22L001-webfont.woff);
12.7 +}
12.8 +
12.9 +@font-face {
12.10 + font-family: TitilliumText2;
12.11 + src: url(fonts/TitilliumText22L002-webfont.woff);
12.12 +}
12.13 +
12.14 +@font-face {
12.15 + font-family: TitilliumText3;
12.16 + src: url(fonts/TitilliumText22L003-webfont.woff);
12.17 +}
12.18 +
12.19 +@font-face {
12.20 + font-family: CPMonoBold;
12.21 + src: url(fonts/CPMono_v07_Bold-webfont.woff);
12.22 +}
12.23 +
12.24 +body {
12.25 + font-family: Helvetica Neue, Arial, Helvetica, 'Liberation Sans', FreeSans, sans-serif;
12.26 + padding: 0px;
12.27 + text-align: center;
12.28 + background-color: #222;
12.29 + color: #ddd;
12.30 + border-style: none;
12.31 +}
12.32 +
12.33 +#wrap {
12.34 + margin: 0px auto 0px auto;
12.35 + width: 400px;
12.36 + text-transform: uppercase;
12.37 +}
12.38 +
12.39 +#title-area {
12.40 + margin-top: 8%;
12.41 + color: #328EB5;
12.42 + font-size: 3em;
12.43 + font-family: TitilliumText1;
12.44 +}
12.45 +
12.46 +#compare-area {
12.47 + margin-top: 8%;
12.48 + height: 6em;
12.49 + font-size: 1.3em;
12.50 + font-weight: bold;
12.51 +}
12.52 +
12.53 +#compare-area #compare-left {
12.54 + position: relative;
12.55 + height: 100%;
12.56 + padding-top: 5em;
12.57 + right: 51%;
12.58 + text-align: right;
12.59 + background-color: #111;
12.60 +}
12.61 +
12.62 +#compare-area #compare-right {
12.63 + position: relative;
12.64 + height: 100%;
12.65 + padding-top: 5em;
12.66 + top: -11em;
12.67 + left: 51%;
12.68 + text-align: left;
12.69 + background-color: #111;
12.70 +}
12.71 +
12.72 +#result-area {
12.73 + margin-top: 30%;
12.74 + height: 3em;
12.75 + font-weight: bold;
12.76 +}
12.77 +
12.78 +#result-area #result-left {
12.79 + position: relative;
12.80 + height: 44px;
12.81 + padding-top: 28px;
12.82 + right: 51%;
12.83 + width: 61.5%;
12.84 + text-align: right;
12.85 + background-color: #151515;
12.86 + color: #222;
12.87 +}
12.88 +
12.89 +#result-area #result-left-rating {
12.90 + position: relative;
12.91 + height: 40px;
12.92 + padding-top: 26px;
12.93 + top: -72px;
12.94 + left: 30%;
12.95 + width: 18%;
12.96 + background-color: #3d910e;
12.97 + color: #222;
12.98 + font-family: CPMonoBold;
12.99 + border: solid 3px #151515;
12.100 +}
12.101 +
12.102 +#result-area #result-right-rating {
12.103 + position: relative;
12.104 + height: 40px;
12.105 + padding-top: 26px;
12.106 + top: -144px;
12.107 + left: 51%;
12.108 + width: 18%;
12.109 + background-color: #AC4810;
12.110 + color: #222;
12.111 + font-family: CPMonoBold;
12.112 + border: solid 3px #151515;
12.113 +}
12.114 +
12.115 +#result-area #result-right {
12.116 + position: relative;
12.117 + height: 44px;
12.118 + padding-top: 28px;
12.119 + top: -216px;
12.120 + left: 69.5%;
12.121 + width: 61.5%;
12.122 + text-align: left;
12.123 + background-color: #151515;
12.124 + color: #222;
12.125 +}
12.126 +
12.127 +.hover-backlight:hover {
12.128 + color: #5ad715;
12.129 + background-color: #0a0a0a ! important;
12.130 +}
12.131 +
12.132 +.padding-left {
12.133 + padding-left: 5em;
12.134 +}
12.135 +
12.136 +.padding-right {
12.137 + padding-right: 5em;
12.138 +}
12.139 +
12.140 +a:link {
12.141 + color: #ddd;
12.142 + text-decoration: none;
12.143 +}
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
13.2 +++ b/pseudoword.py Mon Feb 20 15:10:53 2012 +0100
13.3 @@ -0,0 +1,105 @@
13.4 +import shelve
13.5 +import random
13.6 +
13.7 +
13.8 +def main():
13.9 + return seed(10000, 13)
13.10 + db = Database('data/names')
13.11 + k = 0.1
13.12 + while True:
13.13 + w1, w2 = db.pick_words()
13.14 + uc = (input('\n(a) {0} vs (d) {1} ? '.format(w1[0], w2[0])))
13.15 + assert uc in {'a', 'd', 's', 'q'}
13.16 + if uc == 'q':
13.17 + break
13.18 + elif uc == 's':
13.19 + continue
13.20 + uc = 0 if uc == 'a' else 1
13.21 + ratio = k * 1.0 / (1 + (abs(w1[1] - w2[1])))
13.22 + # print(ratio)
13.23 + db[w1[0]] = w1[1] + (-1)**(uc) * ratio
13.24 + db[w2[0]] = w2[1] + (-1)**(1 - uc) * ratio
13.25 + print('{0} vs {1}'.format(db[w1[0]], db[w2[0]]))
13.26 + print(cross(w1[0], w2[0]))
13.27 + print(cross(w1[0], w2[0]))
13.28 + print(cross(w1[0], w2[0]))
13.29 + print(cross(w1[0], w2[0]))
13.30 + print(cross(w1[0], w2[0]))
13.31 + print(cross(w1[0], w2[0]))
13.32 +
13.33 +
13.34 +class Database:
13.35 +
13.36 + def __init__(self, name):
13.37 + self.db = shelve.open(name, 'c')
13.38 +
13.39 + def pick_words(self):
13.40 + words = list(self.db.items())
13.41 + w1 = random.choice(words)
13.42 + w2 = random.choice(words)
13.43 + while w1 == w2:
13.44 + w2 = random.choice(words)
13.45 + return w1, w2
13.46 +
13.47 + def rate(self, better, worse):
13.48 + better = [better, self.db[better]] if type(better) not in {tuple, list} else better
13.49 + worse = [worse, self.db[worse]] if type(worse) not in {tuple, list} else worse
13.50 + k = 0.1
13.51 + ratio = k * 1.0 / (1 + (abs(better[1] - worse[1])))
13.52 + better_rating = better[1] + ratio
13.53 + worse_rating = worse[1] - ratio
13.54 + self.db[better[0]] = better_rating
13.55 + self.db[worse[0]] = worse_rating
13.56 + return [[better[0], better_rating], [worse[0], worse_rating]]
13.57 +
13.58 +
13.59 +def seed(num, maxlen):
13.60 + db = shelve.open('data/names', 'c')
13.61 + db.clear()
13.62 + for i in range(num):
13.63 + db[randword(random.randint(2, maxlen))] = 0.0
13.64 +
13.65 +
13.66 +def cross(t1, t2):
13.67 + return randword(random.randint(min(len(t1), len(t2)),
13.68 + int((len(t1) + len(t2)) / 2 + 0.5)),
13.69 + #[c for c in set([ord(t) for t in t1 + t2])])
13.70 + [ord(t) for t in t1 + t2])
13.71 +
13.72 +
13.73 +char_values = list(range(ord('a'), ord('z') + 1))\
13.74 + # + list(range(ord('A'), ord('Z') + 1))
13.75 +
13.76 +vowels = frozenset([ord('a'), ord('e'), ord('h'), ord('i'), ord('o'), ord('y'),\
13.77 + ord('u')])
13.78 +
13.79 +def randword(size, chars=char_values):
13.80 +
13.81 + def filter(w):
13.82 +
13.83 + def is_vowel(c):
13.84 + return c in vowels
13.85 +
13.86 + assert len(w)
13.87 + max_seq = 2
13.88 + count = 0
13.89 + last = is_vowel(w[0])
13.90 + for o in w[1:]:
13.91 + now = is_vowel(o)
13.92 + count += int(last == now)
13.93 + if count >= max_seq:
13.94 + return False
13.95 + last = now
13.96 + return True
13.97 +
13.98 + def gen():
13.99 + return [random.choice(chars) for i in range(size)]
13.100 +
13.101 + ordw = gen()
13.102 + while not filter(ordw):
13.103 + ordw = gen()
13.104 + return ''.join([chr(c) for c in ordw])
13.105 +
13.106 +
13.107 +if __name__ == '__main__':
13.108 + main()
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
14.2 +++ b/server.py Mon Feb 20 15:10:53 2012 +0100
14.3 @@ -0,0 +1,165 @@
14.4 +#! /usr/bin/env python3
14.5 +"""
14.6 +Name:
14.7 +Author: Eugen Sawin <sawine@me73.com>
14.8 +"""
14.9 +
14.10 +import socketserver
14.11 +import logging
14.12 +import os
14.13 +import os.path
14.14 +import shelve
14.15 +import json
14.16 +import re
14.17 +import urllib.request
14.18 +import subprocess
14.19 +import time
14.20 +from operator import itemgetter
14.21 +from urllib.parse import urlparse
14.22 +from urllib.request import urlopen
14.23 +from tempfile import NamedTemporaryFile
14.24 +from http.server import BaseHTTPRequestHandler, HTTPServer
14.25 +from pseudoword import Database
14.26 +
14.27 +try:
14.28 + from argparse import ArgumentParser
14.29 +except ImportError:
14.30 + from external.argparse import ArgumentParser
14.31 +
14.32 +ENCODING = 'utf-8'
14.33 +
14.34 +def parse_args():
14.35 + parser = ArgumentParser(description='')
14.36 + parser.add_argument('-p', type=int, default=8080, help='port')
14.37 + parser.add_argument('-a', default='localhost', help='host address')
14.38 + parser.add_argument('-l', default='log/server.log', help='log file')
14.39 + parser.add_argument('-w', default='data/names', help='word database')
14.40 + parser.add_argument('-d', default='httpdocs', help='http docs path')
14.41 + return parser.parse_args()
14.42 +
14.43 +
14.44 +def main():
14.45 + args = parse_args()
14.46 + logging.basicConfig(filename=args.l, level=logging.DEBUG,
14.47 + format='[%(levelname)s@%(asctime)s] %(message)s',
14.48 + datefmt='%d.%m.%Y %I:%M:%S')
14.49 + db = Database(args.w)
14.50 + server = Server(args.a, args.p, args.d, db, GetHandler)
14.51 + server.run()
14.52 +
14.53 +
14.54 +class GetHandler(BaseHTTPRequestHandler):
14.55 +
14.56 + def do_GET(self):
14.57 + request = Request(self.path, self.server.docs_path, self.server.db)
14.58 + logging.info('Request: %s' % request)
14.59 + code, content_type, data = request()
14.60 + self.send_response(code)
14.61 + self.send_header('Content-type', content_type)
14.62 + self.end_headers()
14.63 + self.wfile.write(data)
14.64 +
14.65 + def log_message(self, format, *args):
14.66 + pass
14.67 +
14.68 +
14.69 +class Server(HTTPServer):
14.70 +
14.71 + def __init__(self, host, port, docs_path, db, handler):
14.72 + HTTPServer.__init__(self, (host, port), handler)
14.73 + self.host = host
14.74 + self.port = port
14.75 + self.docs_path = docs_path
14.76 + self.db = db
14.77 +
14.78 + def run(self):
14.79 + logging.info('Server ready and listening at port {0}.'.format(self.port))
14.80 + self.serve_forever()
14.81 +
14.82 +
14.83 +class Request:
14.84 +
14.85 + @classmethod
14.86 + def _content_type(cls, doc):
14.87 + if doc.endswith('.html'):
14.88 + return 'text/html'
14.89 + elif doc.endswith('.css'):
14.90 + return 'text/css'
14.91 + elif doc.endswith('.js'):
14.92 + return 'application/javascript'
14.93 + elif doc.endswith('.ttf'):
14.94 + return 'application/octet-stream'
14.95 + else:
14.96 + return 'text/plain'
14.97 +
14.98 + def __init__(self, query, docs_path, db):
14.99 + self.docs_path = docs_path
14.100 + self.db = db
14.101 + self.parsed = urlparse(query)
14.102 + self.args = dict()
14.103 + if len(self.parsed.query):
14.104 + self.args = dict([a.split('=') for a in self.parsed.query.split('&')])
14.105 + if self.parsed.path[1:] in commands:
14.106 + self.__class__ = commands[self.parsed.path[1:]]
14.107 + else:
14.108 + self.__class__ = WebRequest
14.109 + self.args['doc'] = self.parsed.path
14.110 +
14.111 + def __str__(self):
14.112 + return '{0}({1})'.format(str(self.__class__).partition('.')[-1].rstrip('">'),
14.113 + ', '.join(['{0}: {1}'.format(k, str(v))
14.114 + for k, v in self.args.items()]))
14.115 +
14.116 +
14.117 +def client_rating(rating):
14.118 + return int(rating * 1000)
14.119 +
14.120 +
14.121 +class WordsRequest(Request):
14.122 +
14.123 + def __call__(self):
14.124 + w1, w2 = self.db.pick_words()
14.125 + data = '{{"words":[["{w1}", {r1}], ["{w2}", {r2}]]}}'.format(w1=w1[0],
14.126 + r1=w1[1],
14.127 + w2=w2[0],
14.128 + r2=w2[1])
14.129 + return (200, 'application/javascript', bytes(data, ENCODING))
14.130 +
14.131 +
14.132 +class RateRequest(Request):
14.133 +
14.134 + def __call__(self):
14.135 + w3 = self.args['bn']
14.136 + w4 = self.args['wn']
14.137 + w3, w4 = self.db.rate(w3, w4)
14.138 + w1, w2 = self.db.pick_words()
14.139 + data = '{{"words":[["{w1}",{r1}],["{w2}",{r2}],'.format(w1=w1[0], r1=client_rating(w1[1]),
14.140 + w2=w2[0], r2=client_rating(w2[1]))
14.141 + data += '["{w3}",{r3}],["{w4}",{r4}]]}}'.format(w3=w3[0], r3=client_rating(w3[1]),
14.142 + w4=w4[0], r4=client_rating(w4[1]))
14.143 + return (200, 'application/javascript', bytes(data, ENCODING))
14.144 +
14.145 +
14.146 +commands = {'words': WordsRequest,
14.147 + 'rate': RateRequest}
14.148 +
14.149 +
14.150 +class WebRequest(Request):
14.151 +
14.152 + def __call__(self):
14.153 + if self.args['doc'] == '/':
14.154 + self.args['doc'] = '/index.html'
14.155 + content_type = self._content_type(self.args['doc'])
14.156 + data = bytes('', ENCODING)
14.157 + rel_path = self.docs_path + self.args['doc']
14.158 + if os.path.exists(rel_path):
14.159 + with open(rel_path, 'r+b') as f:
14.160 + data = f.read()
14.161 + code = 200
14.162 + else:
14.163 + code = 404
14.164 + return (code, content_type, data)
14.165 +
14.166 +
14.167 +if __name__ == '__main__':
14.168 + main()