From d3804e32651ebac827a2b11416b1c71f6c6bc06a Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Mon, 7 Nov 2011 09:35:51 -0800 Subject: [PATCH] JS is now complete. Need to fix css embeds. --- assets.yml | 75 +- compress/__init__.py | 0 compress/conf/__init__.py | 0 compress/conf/settings.py | 20 - compress/filter_base.py | 14 - compress/filters/__init__.py | 0 compress/filters/csstidy/__init__.py | 33 - compress/filters/csstidy_python/__init__.py | 19 - compress/filters/csstidy_python/csstidy.py | 636 -- compress/filters/csstidy_python/data.py | 421 - compress/filters/csstidy_python/optimizer.py | 383 - compress/filters/csstidy_python/output.py | 101 - compress/filters/csstidy_python/tools.py | 109 - compress/filters/jsmin/__init__.py | 6 - compress/filters/jsmin/jsmin.py | 218 - compress/filters/yui/__init__.py | 44 - compress/management/__init__.py | 0 compress/management/commands/__init__.py | 0 compress/management/commands/synccompress.py | 58 - compress/models.py | 0 compress/signals.py | 4 - compress/templates/compress/css.html | 1 - compress/templates/compress/css_ie.html | 1 - compress/templates/compress/js.html | 1 - compress/templates/compress/js_ie.html | 1 - compress/templatetags/__init__.py | 0 compress/templatetags/compressed.py | 123 - compress/utils.py | 133 - compress/versioning/__init__.py | 0 compress/versioning/base.py | 13 - compress/versioning/hash/__init__.py | 47 - compress/versioning/mtime/__init__.py | 19 - media/js/jquery-1.6.1.js | 8936 ------------------ settings.py | 5 +- templates/base.html | 4 +- templates/mobile/mobile_workspace.xhtml | 4 +- templates/reader/paypal_return.xhtml | 4 +- urls.py | 4 + utils/jammit.py | 8 +- utils/templatetags/utils_tags.py | 16 +- 40 files changed, 96 insertions(+), 11365 deletions(-) delete mode 100644 compress/__init__.py delete mode 100644 compress/conf/__init__.py delete mode 100644 compress/conf/settings.py delete mode 100644 compress/filter_base.py delete mode 100644 compress/filters/__init__.py delete mode 100644 compress/filters/csstidy/__init__.py delete mode 100644 compress/filters/csstidy_python/__init__.py delete mode 100644 compress/filters/csstidy_python/csstidy.py delete mode 100644 compress/filters/csstidy_python/data.py delete mode 100644 compress/filters/csstidy_python/optimizer.py delete mode 100644 compress/filters/csstidy_python/output.py delete mode 100644 compress/filters/csstidy_python/tools.py delete mode 100644 compress/filters/jsmin/__init__.py delete mode 100644 compress/filters/jsmin/jsmin.py delete mode 100644 compress/filters/yui/__init__.py delete mode 100644 compress/management/__init__.py delete mode 100644 compress/management/commands/__init__.py delete mode 100644 compress/management/commands/synccompress.py delete mode 100644 compress/models.py delete mode 100644 compress/signals.py delete mode 100644 compress/templates/compress/css.html delete mode 100644 compress/templates/compress/css_ie.html delete mode 100644 compress/templates/compress/js.html delete mode 100644 compress/templates/compress/js_ie.html delete mode 100644 compress/templatetags/__init__.py delete mode 100644 compress/templatetags/compressed.py delete mode 100644 compress/utils.py delete mode 100644 compress/versioning/__init__.py delete mode 100644 compress/versioning/base.py delete mode 100644 compress/versioning/hash/__init__.py delete mode 100644 compress/versioning/mtime/__init__.py delete mode 100644 media/js/jquery-1.6.1.js diff --git a/assets.yml b/assets.yml index 5762d063d..72ad37d9b 100644 --- a/assets.yml +++ b/assets.yml @@ -22,8 +22,79 @@ compress_assets: on javascripts: common: - - media/js/jquery-*.js - + - media/js/jquery-1.7.js + - media/js/jquery.json.js + - media/js/jquery.easing.js + - media/js/jquery.newsblur.js + - media/js/jquery.scrollTo.js + - media/js/jquery.corners.js + - media/js/jquery.hotkeys.js + - media/js/jquery.ajaxupload.js + - media/js/jquery.ajaxmanager.3.js + - media/js/jquery.simplemodal-1.3.js + - media/js/jquery.color.js + - media/js/jquery.rightclick.js + - media/js/jquery.ui.core.js + - media/js/jquery.ui.widget.js + - media/js/jquery.ui.mouse.js + - media/js/jquery.ui.position.js + - media/js/jquery.ui.draggable.js + - media/js/jquery.ui.sortable.js + - media/js/jquery.ui.slider.js + - media/js/jquery.ui.autocomplete.js + - media/js/jquery.ui.progressbar.js + - media/js/jquery.layout.js + - media/js/jquery.tinysort.js + - media/js/jquery.fieldselection.js + - media/js/jquery.flot.js + - media/js/jquery.tipsy.js + # media/'js/socket.io-client.0.8.7.js', + - media/js/inflector.js + - media/js/underscore.js + - media/js/underscore.string.js + - media/js/newsblur/reader_utils.js + - media/js/newsblur/assetmodel.js + - media/js/newsblur/reader.js + - media/js/newsblur/generate_bookmarklet.js + - media/js/newsblur/modal.js + - media/js/newsblur/reader_classifier.js + - media/js/newsblur/reader_add_feed.js + - media/js/newsblur/reader_mark_read.js + - media/js/newsblur/reader_goodies.js + - media/js/newsblur/reader_preferences.js + - media/js/newsblur/reader_account.js + - media/js/newsblur/reader_feedchooser.js + - media/js/newsblur/reader_statistics.js + - media/js/newsblur/reader_feed_exception.js + - media/js/newsblur/reader_keyboard.js + - media/js/newsblur/reader_recommend_feed.js + - media/js/newsblur/reader_send_email.js + - media/js/newsblur/reader_tutorial.js + - media/js/newsblur/about.js + - media/js/newsblur/faq.js + mobile: + - media/js/jquery-1.7.js + - media/js/mobile/jquery.mobile-1.0b1.js + - media/js/jquery.ajaxmanager.3.js + - media/js/underscore.js + - media/js/underscore.string.js + - media/js/inflector.js + - media/js/jquery.json.js + - media/js/jquery.easing.js + - media/js/jquery.newsblur.js + - media/js/newsblur/reader_utils.js + - media/js/newsblur/assetmodel.js + - media/js/mobile/newsblur/mobile_workspace.js + paypal: + - media/js/newsblur/paypal_return.js + bookmarklet: + - media/js/jquery-1.5.1.min.js + - media/js/jquery.noConflict.js + - media/js/jquery.newsblur.js + - media/js/jquery.tinysort.js + - media/js/jquery.simplemodal-1.3.js + - media/js/jquery.corners.js + stylesheets: common: - media/css/*.css diff --git a/compress/__init__.py b/compress/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/compress/conf/__init__.py b/compress/conf/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/compress/conf/settings.py b/compress/conf/settings.py deleted file mode 100644 index 4c71561e1..000000000 --- a/compress/conf/settings.py +++ /dev/null @@ -1,20 +0,0 @@ -from django.core.exceptions import ImproperlyConfigured -from django.conf import settings - -COMPRESS = getattr(settings, 'COMPRESS', not settings.DEBUG) -COMPRESS_AUTO = getattr(settings, 'COMPRESS_AUTO', True) -COMPRESS_VERSION = getattr(settings, 'COMPRESS_VERSION', False) -COMPRESS_VERSION_PLACEHOLDER = getattr(settings, 'COMPRESS_VERSION_PLACEHOLDER', '?') -COMPRESS_VERSION_DEFAULT = getattr(settings, 'COMPRESS_VERSION_DEFAULT', '0') -COMPRESS_VERSIONING = getattr(settings, 'COMPRESS_VERSIONING', 'compress.versioning.mtime.MTimeVersioning') - -COMPRESS_CSS_FILTERS = getattr(settings, 'COMPRESS_CSS_FILTERS', ['compress.filters.csstidy.CSSTidyFilter']) -COMPRESS_JS_FILTERS = getattr(settings, 'COMPRESS_JS_FILTERS', ['compress.filters.jsmin.JSMinFilter']) -COMPRESS_CSS = getattr(settings, 'COMPRESS_CSS', {}) -COMPRESS_JS = getattr(settings, 'COMPRESS_JS', {}) - -if COMPRESS_CSS_FILTERS is None: - COMPRESS_CSS_FILTERS = [] - -if COMPRESS_JS_FILTERS is None: - COMPRESS_JS_FILTERS = [] diff --git a/compress/filter_base.py b/compress/filter_base.py deleted file mode 100644 index 9b98531b6..000000000 --- a/compress/filter_base.py +++ /dev/null @@ -1,14 +0,0 @@ -class FilterBase: - def __init__(self, verbose): - self.verbose = verbose - - def filter_css(self, css): - raise NotImplementedError - def filter_js(self, js): - raise NotImplementedError - -class FilterError(Exception): - """ - This exception is raised when a filter fails - """ - pass \ No newline at end of file diff --git a/compress/filters/__init__.py b/compress/filters/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/compress/filters/csstidy/__init__.py b/compress/filters/csstidy/__init__.py deleted file mode 100644 index d40e8eebb..000000000 --- a/compress/filters/csstidy/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -import os -import warnings -import tempfile - -from django.conf import settings - -from compress.filter_base import FilterBase - -BINARY = getattr(settings, 'CSSTIDY_BINARY', 'csstidy') -ARGUMENTS = getattr(settings, 'CSSTIDY_ARGUMENTS', '--template=highest') - -warnings.simplefilter('ignore', RuntimeWarning) - -class CSSTidyFilter(FilterBase): - def filter_css(self, css): - tmp_file = tempfile.NamedTemporaryFile(mode='w+b') - tmp_file.write(css) - tmp_file.flush() - - output_file = tempfile.NamedTemporaryFile(mode='w+b') - - command = '%s %s %s %s' % (BINARY, tmp_file.name, ARGUMENTS, output_file.name) - - command_output = os.popen(command).read() - - filtered_css = output_file.read() - output_file.close() - tmp_file.close() - - if self.verbose: - print command_output - - return filtered_css diff --git a/compress/filters/csstidy_python/__init__.py b/compress/filters/csstidy_python/__init__.py deleted file mode 100644 index 7d581ed43..000000000 --- a/compress/filters/csstidy_python/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -from django.conf import settings - -from compress.filter_base import FilterBase -from compress.filters.csstidy_python.csstidy import CSSTidy - -COMPRESS_CSSTIDY_SETTINGS = getattr(settings, 'COMPRESS_CSSTIDY_SETTINGS', {}) - -class CSSTidyFilter(FilterBase): - def filter_css(self, css): - tidy = CSSTidy() - - for k, v in COMPRESS_CSSTIDY_SETTINGS.items(): - tidy.setSetting(k, v) - - tidy.parse(css) - - r = tidy.Output('string') - - return r diff --git a/compress/filters/csstidy_python/csstidy.py b/compress/filters/csstidy_python/csstidy.py deleted file mode 100644 index 6ae8dc732..000000000 --- a/compress/filters/csstidy_python/csstidy.py +++ /dev/null @@ -1,636 +0,0 @@ -# CSSTidy - CSS Parse -# -# CSS Parser class -# -# This file is part of CSSTidy. -# -# CSSTidy is free software you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation either version 2 of the License, or -# (at your option) any later version. -# -# CSSTidy is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with CSSTidy if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# -# @license http://opensource.org/licenses/gpl-license.php GNU Public License -# @package csstidy -# @author Dj Gilcrease (digitalxero at gmail dot com) 2005-2006 - -import re - -from optimizer import CSSOptimizer -from output import CSSPrinter -import data -from tools import SortedDict - -class CSSTidy(object): - #Saves the parsed CSS - _css = "" - _raw_css = SortedDict() - _optimized_css = SortedDict() - - #List of Tokens - _tokens = [] - - #Printer class - _output = None - - #Optimiser class - _optimizer = None - - #Saves the CSS charset (@charset) - _charset = '' - - #Saves all @import URLs - _import = [] - - #Saves the namespace - _namespace = '' - - #Contains the version of csstidy - _version = '1.3' - - #Stores the settings - _settings = {} - - # Saves the parser-status. - # - # Possible values: - # - is = in selector - # - ip = in property - # - iv = in value - # - instr = in string (started at " or ' or ( ) - # - ic = in comment (ignore everything) - # - at = in @-block - _status = 'is' - - #Saves the current at rule (@media) - _at = '' - - #Saves the current selector - _selector = '' - - #Saves the current property - _property = '' - - #Saves the position of , in selectors - _sel_separate = [] - - #Saves the current value - _value = '' - - #Saves the current sub-value - _sub_value = '' - - #Saves all subvalues for a property. - _sub_value_arr = [] - - #Saves the char which opened the last string - _str_char = '' - _cur_string = '' - - #Status from which the parser switched to ic or instr - _from = '' - - #Variable needed to manage string-in-strings, for example url("foo.png") - _str_in_str = False - - #=True if in invalid at-rule - _invalid_at = False - - #=True if something has been added to the current selector - _added = False - - #Saves the message log - _log = SortedDict() - - #Saves the line number - _line = 1 - - def __init__(self): - self._settings['remove_bslash'] = True - self._settings['compress_colors'] = True - self._settings['compress_font-weight'] = True - self._settings['lowercase_s'] = False - self._settings['optimise_shorthands'] = 2 - self._settings['remove_last_'] = False - self._settings['case_properties'] = 1 - self._settings['sort_properties'] = False - self._settings['sort_selectors'] = False - self._settings['merge_selectors'] = 2 - self._settings['discard_invalid_properties'] = False - self._settings['css_level'] = 'CSS2.1' - self._settings['preserve_css'] = False - self._settings['timestamp'] = False - self._settings['template'] = 'highest_compression' - - #Maps self._status to methods - self.__statusMethod = {'is':self.__parseStatus_is, 'ip': self.__parseStatus_ip, 'iv':self.__parseStatus_iv, 'instr':self.__parseStatus_instr, 'ic':self.__parseStatus_ic, 'at':self.__parseStatus_at} - - self._output = CSSPrinter(self) - self._optimizer = CSSOptimizer(self) - - #Public Methods - def getSetting(self, setting): - return self._settings.get(setting, False) - - #Set the value of a setting. - def setSetting(self, setting, value): - self._settings[setting] = value - return True - - def log(self, message, ttype, line = -1): - if line == -1: - line = self._line - - line = int(line) - - add = {'m': message, 't': ttype} - - if not self._log.has_key(line): - self._log[line] = [] - self._log[line].append(add) - elif add not in self._log[line]: - self._log[line].append(add) - - - #Checks if a character is escaped (and returns True if it is) - def escaped(self, string, pos): - return not (string[pos-1] != '\\' or self.escaped(string, pos-1)) - - #Adds CSS to an existing media/selector - def merge_css_blocks(self, media, selector, css_add): - for prop, value in css_add.iteritems(): - self.__css_add_property(media, selector, prop, value, False) - - #Checks if $value is !important. - def is_important(self, value): - return '!important' in value.lower() - - #Returns a value without !important - def gvw_important(self, value): - if self.is_important(value): - ret = value.strip() - ret = ret[0:-9] - ret = ret.strip() - ret = ret[0:-1] - ret = ret.strip() - return ret - - return value - - def parse(self, cssString): - #Switch from \r\n to \n - self._css = cssString.replace("\r\n", "\n") + ' ' - self._raw_css = {} - self._optimized_css = {} - self._curComment = '' - - #Start Parsing - i = 0 - while i < len(cssString): - if self._css[i] == "\n" or self._css[i] == "\r": - self._line += 1 - - i += self.__statusMethod[self._status](i) - - i += 1; - - self._optimized_css = self._optimizer.optimize(self._raw_css) - - def parseFile(self, filename): - try: - f = open(filename, "r") - self.parse(f.read()) - finally: - f.close() - - #Private Methods - def __parseStatus_is(self, idx): - """ - Parse in Selector - """ - ret = 0 - - if self.__is_token(self._css, idx): - if self._css[idx] == '/' and self._css[idx+1] == '*' and self._selector.strip() == '': - self._status = 'ic' - self._from = 'is' - return 1 - - elif self._css[idx] == '@' and self._selector.strip() == '': - #Check for at-rule - self._invalid_at = True - - for name, ttype in data.at_rules.iteritems(): - if self._css[idx+1:len(name)].lower() == name.lower(): - if ttype == 'at': - self._at = '@' + name - else: - self._selector = '@' + name - - self._status = ttype - self._invalid_at = False - ret += len(name) - - if self._invalid_at: - self._selector = '@' - invalid_at_name = '' - for j in xrange(idx+1, len(self._css)): - if not self._css[j].isalpha(): - break; - - invalid_at_name += self._css[j] - - self.log('Invalid @-rule: ' + invalid_at_name + ' (removed)', 'Warning') - - elif self._css[idx] == '"' or self._css[idx] == "'": - self._cur_string = self._css[idx] - self._status = 'instr' - self._str_char = self._css[idx] - self._from = 'is' - - elif self._invalid_at and self._css[idx] == ';': - self._invalid_at = False - self._status = 'is' - - elif self._css[idx] == '{': - self._status = 'ip' - self.__add_token(data.SEL_START, self._selector) - self._added = False; - - elif self._css[idx] == '}': - self.__add_token(data.AT_END, self._at) - self._at = '' - self._selector = '' - self._sel_separate = [] - - elif self._css[idx] == ',': - self._selector = self._selector.strip() + ',' - self._sel_separate.append(len(self._selector)) - - elif self._css[idx] == '\\': - self._selector += self.__unicode(idx) - - #remove unnecessary universal selector, FS#147 - elif not (self._css[idx] == '*' and self._css[idx+1] in ('.', '#', '[', ':')): - self._selector += self._css[idx] - - else: - lastpos = len(self._selector)-1 - - if lastpos == -1 or not ((self._selector[lastpos].isspace() or self.__is_token(self._selector, lastpos) and self._selector[lastpos] == ',') and self._css[idx].isspace()): - self._selector += self._css[idx] - - return ret - - def __parseStatus_ip(self, idx): - """ - Parse in property - """ - if self.__is_token(self._css, idx): - if (self._css[idx] == ':' or self._css[idx] == '=') and self._property != '': - self._status = 'iv' - - if not self.getSetting('discard_invalid_properties') or self.__property_is_valid(self._property): - self.__add_token(data.PROPERTY, self._property) - - elif self._css[idx] == '/' and self._css[idx+1] == '*' and self._property == '': - self._status = 'ic' - self._from = 'ip' - return 1 - - elif self._css[idx] == '}': - self.__explode_selectors() - self._status = 'is' - self._invalid_at = False - self.__add_token(data.SEL_END, self._selector) - self._selector = '' - self._property = '' - - elif self._css[idx] == ';': - self._property = '' - - elif self._css[idx] == '\\': - self._property += self.__unicode(idx) - - elif not self._css[idx].isspace(): - self._property += self._css[idx] - - return 0 - - def __parseStatus_iv(self, idx): - """ - Parse in value - """ - pn = (( self._css[idx] == "\n" or self._css[idx] == "\r") and self.__property_is_next(idx+1) or idx == len(self._css)) #CHECK# - if self.__is_token(self._css, idx) or pn: - if self._css[idx] == '/' and self._css[idx+1] == '*': - self._status = 'ic' - self._from = 'iv' - return 1 - - elif self._css[idx] == '"' or self._css[idx] == "'" or self._css[idx] == '(': - self._cur_string = self._css[idx] - self._str_char = ')' if self._css[idx] == '(' else self._css[idx] - self._status = 'instr' - self._from = 'iv' - - elif self._css[idx] == ',': - self._sub_value = self._sub_value.strip() + ',' - - elif self._css[idx] == '\\': - self._sub_value += self.__unicode(idx) - - elif self._css[idx] == ';' or pn: - if len(self._selector) > 0 and self._selector[0] == '@' and data.at_rules.has_key(self._selector[1:]) and data.at_rules[self._selector[1:]] == 'iv': - self._sub_value_arr.append(self._sub_value.strip()) - - self._status = 'is' - - if '@charset' in self._selector: - self._charset = self._sub_value_arr[0] - - elif '@namespace' in self._selector: - self._namespace = ' '.join(self._sub_value_arr) - - elif '@import' in self._selector: - self._import.append(' '.join(self._sub_value_arr)) - - - self._sub_value_arr = [] - self._sub_value = '' - self._selector = '' - self._sel_separate = [] - - else: - self._status = 'ip' - - elif self._css[idx] != '}': - self._sub_value += self._css[idx] - - if (self._css[idx] == '}' or self._css[idx] == ';' or pn) and self._selector != '': - if self._at == '': - self._at = data.DEFAULT_AT - - #case settings - if self.getSetting('lowercase_s'): - self._selector = self._selector.lower() - - self._property = self._property.lower() - - if self._sub_value != '': - self._sub_value_arr.append(self._sub_value) - self._sub_value = '' - - self._value = ' '.join(self._sub_value_arr) - - - self._selector = self._selector.strip() - - valid = self.__property_is_valid(self._property) - - if (not self._invalid_at or self.getSetting('preserve_css')) and (not self.getSetting('discard_invalid_properties') or valid): - self.__css_add_property(self._at, self._selector, self._property, self._value) - self.__add_token(data.VALUE, self._value) - - if not valid: - if self.getSetting('discard_invalid_properties'): - self.log('Removed invalid property: ' + self._property, 'Warning') - - else: - self.log('Invalid property in ' + self.getSetting('css_level').upper() + ': ' + self._property, 'Warning') - - self._property = ''; - self._sub_value_arr = [] - self._value = '' - - if self._css[idx] == '}': - self.__explode_selectors() - self.__add_token(data.SEL_END, self._selector) - self._status = 'is' - self._invalid_at = False - self._selector = '' - - elif not pn: - self._sub_value += self._css[idx] - - if self._css[idx].isspace(): - if self._sub_value != '': - self._sub_value_arr.append(self._sub_value) - self._sub_value = '' - - return 0 - - def __parseStatus_instr(self, idx): - """ - Parse in String - """ - if self._str_char == ')' and (self._css[idx] == '"' or self._css[idx] == "'") and not self.escaped(self._css, idx): - self._str_in_str = not self._str_in_str - - temp_add = self._css[idx] # ...and no not-escaped backslash at the previous position - if (self._css[idx] == "\n" or self._css[idx] == "\r") and not (self._css[idx-1] == '\\' and not self.escaped(self._css, idx-1)): - temp_add = "\\A " - self.log('Fixed incorrect newline in string', 'Warning') - - if not (self._str_char == ')' and self._css[idx].isspace() and not self._str_in_str): - self._cur_string += temp_add - - if self._css[idx] == self._str_char and not self.escaped(self._css, idx) and not self._str_in_str: - self._status = self._from - regex = re.compile(r'([\s]+)', re.I | re.U | re.S) - if regex.match(self._cur_string) is None and self._property != 'content': - if self._str_char == '"' or self._str_char == "'": - self._cur_string = self._cur_string[1:-1] - - elif len(self._cur_string) > 3 and (self._cur_string[1] == '"' or self._cur_string[1] == "'"): - self._cur_string = self._cur_string[0] + self._cur_string[2:-2] + self._cur_string[-1] - - if self._from == 'iv': - self._sub_value += self._cur_string - - elif self._from == 'is': - self._selector += self._cur_string - - return 0 - - def __parseStatus_ic(self, idx): - """ - Parse css In Comment - """ - if self._css[idx] == '*' and self._css[idx+1] == '/': - self._status = self._from - self.__add_token(data.COMMENT, self._curComment) - self._curComment = '' - return 1 - - else: - self._curComment += self._css[idx] - - return 0 - - def __parseStatus_at(self, idx): - """ - Parse in at-block - """ - if self.__is_token(string, idx): - if self._css[idx] == '/' and self._css[idx+1] == '*': - self._status = 'ic' - self._from = 'at' - return 1 - - elif self._css[i] == '{': - self._status = 'is' - self.__add_token(data.AT_START, self._at) - - elif self._css[i] == ',': - self._at = self._at.strip() + ',' - - elif self._css[i] == '\\': - self._at += self.__unicode(i) - else: - lastpos = len(self._at)-1 - if not (self._at[lastpos].isspace() or self.__is_token(self._at, lastpos) and self._at[lastpos] == ',') and self._css[i].isspace(): - self._at += self._css[i] - - return 0 - - def __explode_selectors(self): - #Explode multiple selectors - if self.getSetting('merge_selectors') == 1: - new_sels = [] - lastpos = 0; - self._sel_separate.append(len(self._selector)) - - for num in xrange(len(self._sel_separate)): - pos = self._sel_separate[num] - if num == (len(self._sel_separate)): #CHECK# - pos += 1 - - new_sels.append(self._selector[lastpos:(pos-lastpos-1)]) - lastpos = pos - - if len(new_sels) > 1: - for selector in new_sels: - self.merge_css_blocks(self._at, selector, self._raw_css[self._at][self._selector]) - - del self._raw_css[self._at][self._selector] - - self._sel_separate = [] - - #Adds a property with value to the existing CSS code - def __css_add_property(self, media, selector, prop, new_val): - if self.getSetting('preserve_css') or new_val.strip() == '': - return - - if not self._raw_css.has_key(media): - self._raw_css[media] = SortedDict() - - if not self._raw_css[media].has_key(selector): - self._raw_css[media][selector] = SortedDict() - - self._added = True - if self._raw_css[media][selector].has_key(prop): - if (self.is_important(self._raw_css[media][selector][prop]) and self.is_important(new_val)) or not self.is_important(self._raw_css[media][selector][prop]): - del self._raw_css[media][selector][prop] - self._raw_css[media][selector][prop] = new_val.strip() - - else: - self._raw_css[media][selector][prop] = new_val.strip() - - #Checks if the next word in a string from pos is a CSS property - def __property_is_next(self, pos): - istring = self._css[pos: len(self._css)] - pos = istring.find(':') - if pos == -1: - return False; - - istring = istring[:pos].strip().lower() - if data.all_properties.has_key(istring): - self.log('Added semicolon to the end of declaration', 'Warning') - return True - - return False; - - #Checks if a property is valid - def __property_is_valid(self, prop): - return (data.all_properties.has_key(prop) and data.all_properties[prop].find(self.getSetting('css_level').upper()) != -1) - - #Adds a token to self._tokens - def __add_token(self, ttype, cssdata, do=False): - if self.getSetting('preserve_css') or do: - if ttype == data.COMMENT: - token = [ttype, cssdata] - else: - token = [ttype, cssdata.strip()] - - self._tokens.append(token) - - #Parse unicode notations and find a replacement character - def __unicode(self, idx): - ##FIX## - return '' - - #Starts parsing from URL - ##USED? - def __parse_from_url(self, url): - try: - if "http" in url.lower() or "https" in url.lower(): - f = urllib.urlopen(url) - else: - f = open(url) - - data = f.read() - return self.parse(data) - finally: - f.close() - - #Checks if there is a token at the current position - def __is_token(self, string, idx): - return (string[idx] in data.tokens and not self.escaped(string, idx)) - - - #Property Methods - def _getOutput(self): - self._output.prepare(self._optimized_css) - return self._output.render - - def _getLog(self): - ret = "" - ks = self._log.keys() - ks.sort() - for line in ks: - for msg in self._log[line]: - ret += "Type: " + msg['t'] + "\n" - ret += "Message: " + msg['m'] + "\n" - ret += "\n" - - return ret - - def _getCSS(self): - return self._css - - - #Properties - Output = property(_getOutput, None) - Log = property(_getLog, None) - CSS = property(_getCSS, None) - - -if __name__ == '__main__': - import sys - tidy = CSSTidy() - f = open(sys.argv[1], "r") - css = f.read() - f.close() - tidy.parse(css) - tidy.Output('file', filename="Stylesheet.min.css") - print tidy.Output() - #print tidy._import \ No newline at end of file diff --git a/compress/filters/csstidy_python/data.py b/compress/filters/csstidy_python/data.py deleted file mode 100644 index bd728cbaa..000000000 --- a/compress/filters/csstidy_python/data.py +++ /dev/null @@ -1,421 +0,0 @@ -# Various CSS Data for CSSTidy -# -# This file is part of CSSTidy. -# -# CSSTidy is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# CSSTidy is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with CSSTidy; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# -# @license http://opensource.org/licenses/gpl-license.php GNU Public License -# @package csstidy -# @author Florian Schmitz (floele at gmail dot com) 2005 - -AT_START = 1 -AT_END = 2 -SEL_START = 3 -SEL_END = 4 -PROPERTY = 5 -VALUE = 6 -COMMENT = 7 -DEFAULT_AT = 41 - -# All whitespace allowed in CSS -# -# @global array whitespace -# @version 1.0 -whitespace = frozenset([' ',"\n","\t","\r","\x0B"]) - -# All CSS tokens used by csstidy -# -# @global string tokens -# @version 1.0 -tokens = '/@}{;:=\'"(,\\!$%&)#+.<>?[]^`|~' - -# All CSS units (CSS 3 units included) -# -# @see compress_numbers() -# @global array units -# @version 1.0 -units = frozenset(['in','cm','mm','pt','pc','px','rem','em','%','ex','gd','vw','vh','vm','deg','grad','rad','ms','s','khz','hz']) - -# Available at-rules -# -# @global array at_rules -# @version 1.0 -at_rules = {'page':'is', 'font-face':'is', 'charset':'iv', 'import':'iv', 'namespace':'iv', 'media':'at'} - -# Properties that need a value with unit -# -# @todo CSS3 properties -# @see compress_numbers() -# @global array unit_values -# @version 1.2 -unit_values = frozenset(['background', 'background-position', 'border', 'border-top', 'border-right', 'border-bottom', - 'border-left', 'border-width', 'border-top-width', 'border-right-width', 'border-left-width', - 'border-bottom-width', 'bottom', 'border-spacing', 'font-size','height', 'left', 'margin', 'margin-top', - 'margin-right', 'margin-bottom', 'margin-left', 'max-height', 'max-width', 'min-height', 'min-width', - 'outline-width', 'padding', 'padding-top', 'padding-right', 'padding-bottom', 'padding-left','position', - 'right', 'top', 'text-indent', 'letter-spacing', 'word-spacing', 'width' - ]) - - -# Properties that allow as value -# -# @todo CSS3 properties -# @see compress_numbers() -# @global array color_values -# @version 1.0 -color_values = frozenset(['background-color', 'border-color', 'border-top-color', 'border-right-color', - 'border-bottom-color', 'border-left-color', 'color', 'outline-color']) - - -# Default values for the background properties -# -# @todo Possibly property names will change during CSS3 development -# @global array background_prop_default -# @see dissolve_short_bg() -# @see merge_bg() -# @version 1.0 -background_prop_default = {} -background_prop_default['background-image'] = 'none' -background_prop_default['background-size'] = 'auto' -background_prop_default['background-repeat'] = 'repeat' -background_prop_default['background-position'] = '0 0' -background_prop_default['background-attachment'] = 'scroll' -background_prop_default['background-clip'] = 'border' -background_prop_default['background-origin'] = 'padding' -background_prop_default['background-color'] = 'transparent' - -# A list of non-W3C color names which get replaced by their hex-codes -# -# @global array replace_colors -# @see cut_color() -# @version 1.0 -replace_colors = {} -replace_colors['aliceblue'] = '#F0F8FF' -replace_colors['antiquewhite'] = '#FAEBD7' -replace_colors['aquamarine'] = '#7FFFD4' -replace_colors['azure'] = '#F0FFFF' -replace_colors['beige'] = '#F5F5DC' -replace_colors['bisque'] = '#FFE4C4' -replace_colors['blanchedalmond'] = '#FFEBCD' -replace_colors['blueviolet'] = '#8A2BE2' -replace_colors['brown'] = '#A52A2A' -replace_colors['burlywood'] = '#DEB887' -replace_colors['cadetblue'] = '#5F9EA0' -replace_colors['chartreuse'] = '#7FFF00' -replace_colors['chocolate'] = '#D2691E' -replace_colors['coral'] = '#FF7F50' -replace_colors['cornflowerblue'] = '#6495ED' -replace_colors['cornsilk'] = '#FFF8DC' -replace_colors['crimson'] = '#DC143C' -replace_colors['cyan'] = '#00FFFF' -replace_colors['darkblue'] = '#00008B' -replace_colors['darkcyan'] = '#008B8B' -replace_colors['darkgoldenrod'] = '#B8860B' -replace_colors['darkgray'] = '#A9A9A9' -replace_colors['darkgreen'] = '#006400' -replace_colors['darkkhaki'] = '#BDB76B' -replace_colors['darkmagenta'] = '#8B008B' -replace_colors['darkolivegreen'] = '#556B2F' -replace_colors['darkorange'] = '#FF8C00' -replace_colors['darkorchid'] = '#9932CC' -replace_colors['darkred'] = '#8B0000' -replace_colors['darksalmon'] = '#E9967A' -replace_colors['darkseagreen'] = '#8FBC8F' -replace_colors['darkslateblue'] = '#483D8B' -replace_colors['darkslategray'] = '#2F4F4F' -replace_colors['darkturquoise'] = '#00CED1' -replace_colors['darkviolet'] = '#9400D3' -replace_colors['deeppink'] = '#FF1493' -replace_colors['deepskyblue'] = '#00BFFF' -replace_colors['dimgray'] = '#696969' -replace_colors['dodgerblue'] = '#1E90FF' -replace_colors['feldspar'] = '#D19275' -replace_colors['firebrick'] = '#B22222' -replace_colors['floralwhite'] = '#FFFAF0' -replace_colors['forestgreen'] = '#228B22' -replace_colors['gainsboro'] = '#DCDCDC' -replace_colors['ghostwhite'] = '#F8F8FF' -replace_colors['gold'] = '#FFD700' -replace_colors['goldenrod'] = '#DAA520' -replace_colors['greenyellow'] = '#ADFF2F' -replace_colors['honeydew'] = '#F0FFF0' -replace_colors['hotpink'] = '#FF69B4' -replace_colors['indianred'] = '#CD5C5C' -replace_colors['indigo'] = '#4B0082' -replace_colors['ivory'] = '#FFFFF0' -replace_colors['khaki'] = '#F0E68C' -replace_colors['lavender'] = '#E6E6FA' -replace_colors['lavenderblush'] = '#FFF0F5' -replace_colors['lawngreen'] = '#7CFC00' -replace_colors['lemonchiffon'] = '#FFFACD' -replace_colors['lightblue'] = '#ADD8E6' -replace_colors['lightcoral'] = '#F08080' -replace_colors['lightcyan'] = '#E0FFFF' -replace_colors['lightgoldenrodyellow'] = '#FAFAD2' -replace_colors['lightgrey'] = '#D3D3D3' -replace_colors['lightgreen'] = '#90EE90' -replace_colors['lightpink'] = '#FFB6C1' -replace_colors['lightsalmon'] = '#FFA07A' -replace_colors['lightseagreen'] = '#20B2AA' -replace_colors['lightskyblue'] = '#87CEFA' -replace_colors['lightslateblue'] = '#8470FF' -replace_colors['lightslategray'] = '#778899' -replace_colors['lightsteelblue'] = '#B0C4DE' -replace_colors['lightyellow'] = '#FFFFE0' -replace_colors['limegreen'] = '#32CD32' -replace_colors['linen'] = '#FAF0E6' -replace_colors['magenta'] = '#FF00FF' -replace_colors['mediumaquamarine'] = '#66CDAA' -replace_colors['mediumblue'] = '#0000CD' -replace_colors['mediumorchid'] = '#BA55D3' -replace_colors['mediumpurple'] = '#9370D8' -replace_colors['mediumseagreen'] = '#3CB371' -replace_colors['mediumslateblue'] = '#7B68EE' -replace_colors['mediumspringgreen'] = '#00FA9A' -replace_colors['mediumturquoise'] = '#48D1CC' -replace_colors['mediumvioletred'] = '#C71585' -replace_colors['midnightblue'] = '#191970' -replace_colors['mintcream'] = '#F5FFFA' -replace_colors['mistyrose'] = '#FFE4E1' -replace_colors['moccasin'] = '#FFE4B5' -replace_colors['navajowhite'] = '#FFDEAD' -replace_colors['oldlace'] = '#FDF5E6' -replace_colors['olivedrab'] = '#6B8E23' -replace_colors['orangered'] = '#FF4500' -replace_colors['orchid'] = '#DA70D6' -replace_colors['palegoldenrod'] = '#EEE8AA' -replace_colors['palegreen'] = '#98FB98' -replace_colors['paleturquoise'] = '#AFEEEE' -replace_colors['palevioletred'] = '#D87093' -replace_colors['papayawhip'] = '#FFEFD5' -replace_colors['peachpuff'] = '#FFDAB9' -replace_colors['peru'] = '#CD853F' -replace_colors['pink'] = '#FFC0CB' -replace_colors['plum'] = '#DDA0DD' -replace_colors['powderblue'] = '#B0E0E6' -replace_colors['rosybrown'] = '#BC8F8F' -replace_colors['royalblue'] = '#4169E1' -replace_colors['saddlebrown'] = '#8B4513' -replace_colors['salmon'] = '#FA8072' -replace_colors['sandybrown'] = '#F4A460' -replace_colors['seagreen'] = '#2E8B57' -replace_colors['seashell'] = '#FFF5EE' -replace_colors['sienna'] = '#A0522D' -replace_colors['skyblue'] = '#87CEEB' -replace_colors['slateblue'] = '#6A5ACD' -replace_colors['slategray'] = '#708090' -replace_colors['snow'] = '#FFFAFA' -replace_colors['springgreen'] = '#00FF7F' -replace_colors['steelblue'] = '#4682B4' -replace_colors['tan'] = '#D2B48C' -replace_colors['thistle'] = '#D8BFD8' -replace_colors['tomato'] = '#FF6347' -replace_colors['turquoise'] = '#40E0D0' -replace_colors['violet'] = '#EE82EE' -replace_colors['violetred'] = '#D02090' -replace_colors['wheat'] = '#F5DEB3' -replace_colors['whitesmoke'] = '#F5F5F5' -replace_colors['yellowgreen'] = '#9ACD32' - -#A list of optimized colors -optimize_colors = {} -optimize_colors['black'] = '#000' -optimize_colors['fuchsia'] = '#F0F' -optimize_colors['white'] = '#FFF' -optimize_colors['yellow'] = '#FF0' -optimize_colors['cyan'] = '#0FF' -optimize_colors['magenta'] = '#F0F' -optimize_colors['lightslategray'] = '#789' - -optimize_colors['#800000'] = 'maroon' -optimize_colors['#FFA500'] = 'orange' -optimize_colors['#808000'] = 'olive' -optimize_colors['#800080'] = 'purple' -optimize_colors['#008000'] = 'green' -optimize_colors['#000080'] = 'navy' -optimize_colors['#008080'] = 'teal' -optimize_colors['#C0C0C0'] = 'silver' -optimize_colors['#808080'] = 'gray' -optimize_colors['#4B0082'] = 'indigo' -optimize_colors['#FFD700'] = 'gold' -optimize_colors['#A52A2A'] = 'brown' -optimize_colors['#00FFFF'] = 'cyan' -optimize_colors['#EE82EE'] = 'violet' -optimize_colors['#DA70D6'] = 'orchid' -optimize_colors['#FFE4C4'] = 'bisque' -optimize_colors['#F0E68C'] = 'khaki' -optimize_colors['#F5DEB3'] = 'wheat' -optimize_colors['#FF7F50'] = 'coral' -optimize_colors['#F5F5DC'] = 'beige' -optimize_colors['#F0FFFF'] = 'azure' -optimize_colors['#A0522D'] = 'sienna' -optimize_colors['#CD853F'] = 'peru' -optimize_colors['#FFFFF0'] = 'ivory' -optimize_colors['#DDA0DD'] = 'plum' -optimize_colors['#D2B48C'] = 'tan' -optimize_colors['#FFC0CB'] = 'pink' -optimize_colors['#FFFAFA'] = 'snow' -optimize_colors['#FA8072'] = 'salmon' -optimize_colors['#FF6347'] = 'tomato' -optimize_colors['#FAF0E6'] = 'linen' -optimize_colors['#F00'] = 'red' - - -# A list of all shorthand properties that are devided into four properties and/or have four subvalues -# -# @global array shorthands -# @todo Are there new ones in CSS3? -# @see dissolve_4value_shorthands() -# @see merge_4value_shorthands() -# @version 1.0 -shorthands = {} -shorthands['border-color'] = ['border-top-color','border-right-color','border-bottom-color','border-left-color'] -shorthands['border-style'] = ['border-top-style','border-right-style','border-bottom-style','border-left-style'] -shorthands['border-width'] = ['border-top-width','border-right-width','border-bottom-width','border-left-width'] -shorthands['margin'] = ['margin-top','margin-right','margin-bottom','margin-left'] -shorthands['padding'] = ['padding-top','padding-right','padding-bottom','padding-left'] -shorthands['-moz-border-radius'] = 0 - -# All CSS Properties. Needed for csstidy::property_is_next() -# -# @global array all_properties -# @todo Add CSS3 properties -# @version 1.0 -# @see csstidy::property_is_next() -all_properties = {} -all_properties['background'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['background-color'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['background-image'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['background-repeat'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['background-attachment'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['background-position'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['border'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['border-top'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['border-right'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['border-bottom'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['border-left'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['border-color'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['border-top-color'] = 'CSS2.0,CSS2.1' -all_properties['border-bottom-color'] = 'CSS2.0,CSS2.1' -all_properties['border-left-color'] = 'CSS2.0,CSS2.1' -all_properties['border-right-color'] = 'CSS2.0,CSS2.1' -all_properties['border-style'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['border-top-style'] = 'CSS2.0,CSS2.1' -all_properties['border-right-style'] = 'CSS2.0,CSS2.1' -all_properties['border-left-style'] = 'CSS2.0,CSS2.1' -all_properties['border-bottom-style'] = 'CSS2.0,CSS2.1' -all_properties['border-width'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['border-top-width'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['border-right-width'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['border-left-width'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['border-bottom-width'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['border-collapse'] = 'CSS2.0,CSS2.1' -all_properties['border-spacing'] = 'CSS2.0,CSS2.1' -all_properties['bottom'] = 'CSS2.0,CSS2.1' -all_properties['caption-side'] = 'CSS2.0,CSS2.1' -all_properties['content'] = 'CSS2.0,CSS2.1' -all_properties['clear'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['clip'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['color'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['counter-reset'] = 'CSS2.0,CSS2.1' -all_properties['counter-increment'] = 'CSS2.0,CSS2.1' -all_properties['cursor'] = 'CSS2.0,CSS2.1' -all_properties['empty-cells'] = 'CSS2.0,CSS2.1' -all_properties['display'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['direction'] = 'CSS2.0,CSS2.1' -all_properties['float'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['font'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['font-family'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['font-style'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['font-variant'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['font-weight'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['font-stretch'] = 'CSS2.0' -all_properties['font-size-adjust'] = 'CSS2.0' -all_properties['font-size'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['height'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['left'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['line-height'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['list-style'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['list-style-type'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['list-style-image'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['list-style-position'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['margin'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['margin-top'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['margin-right'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['margin-bottom'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['margin-left'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['marks'] = 'CSS1.0,CSS2.0' -all_properties['marker-offset'] = 'CSS2.0' -all_properties['max-height'] = 'CSS2.0,CSS2.1' -all_properties['max-width'] = 'CSS2.0,CSS2.1' -all_properties['min-height'] = 'CSS2.0,CSS2.1' -all_properties['min-width'] = 'CSS2.0,CSS2.1' -all_properties['overflow'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['orphans'] = 'CSS2.0,CSS2.1' -all_properties['outline'] = 'CSS2.0,CSS2.1' -all_properties['outline-width'] = 'CSS2.0,CSS2.1' -all_properties['outline-style'] = 'CSS2.0,CSS2.1' -all_properties['outline-color'] = 'CSS2.0,CSS2.1' -all_properties['padding'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['padding-top'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['padding-right'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['padding-bottom'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['padding-left'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['page-break-before'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['page-break-after'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['page-break-inside'] = 'CSS2.0,CSS2.1' -all_properties['page'] = 'CSS2.0' -all_properties['position'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['quotes'] = 'CSS2.0,CSS2.1' -all_properties['right'] = 'CSS2.0,CSS2.1' -all_properties['size'] = 'CSS1.0,CSS2.0' -all_properties['speak-header'] = 'CSS2.0,CSS2.1' -all_properties['table-layout'] = 'CSS2.0,CSS2.1' -all_properties['top'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['text-indent'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['text-align'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['text-decoration'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['text-shadow'] = 'CSS2.0' -all_properties['letter-spacing'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['word-spacing'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['text-transform'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['white-space'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['unicode-bidi'] = 'CSS2.0,CSS2.1' -all_properties['vertical-align'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['visibility'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['width'] = 'CSS1.0,CSS2.0,CSS2.1' -all_properties['widows'] = 'CSS2.0,CSS2.1' -all_properties['z-index'] = 'CSS1.0,CSS2.0,CSS2.1' - -# Speech # -all_properties['volume'] = 'CSS2.0,CSS2.1' -all_properties['speak'] = 'CSS2.0,CSS2.1' -all_properties['pause'] = 'CSS2.0,CSS2.1' -all_properties['pause-before'] = 'CSS2.0,CSS2.1' -all_properties['pause-after'] = 'CSS2.0,CSS2.1' -all_properties['cue'] = 'CSS2.0,CSS2.1' -all_properties['cue-before'] = 'CSS2.0,CSS2.1' -all_properties['cue-after'] = 'CSS2.0,CSS2.1' -all_properties['play-during'] = 'CSS2.0,CSS2.1' -all_properties['azimuth'] = 'CSS2.0,CSS2.1' -all_properties['elevation'] = 'CSS2.0,CSS2.1' -all_properties['speech-rate'] = 'CSS2.0,CSS2.1' -all_properties['voice-family'] = 'CSS2.0,CSS2.1' -all_properties['pitch'] = 'CSS2.0,CSS2.1' -all_properties['pitch-range'] = 'CSS2.0,CSS2.1' -all_properties['stress'] = 'CSS2.0,CSS2.1' -all_properties['richness'] = 'CSS2.0,CSS2.1' -all_properties['speak-punctuation'] = 'CSS2.0,CSS2.1' -all_properties['speak-numeral'] = 'CSS2.0,CSS2.1' \ No newline at end of file diff --git a/compress/filters/csstidy_python/optimizer.py b/compress/filters/csstidy_python/optimizer.py deleted file mode 100644 index 7cd284cfc..000000000 --- a/compress/filters/csstidy_python/optimizer.py +++ /dev/null @@ -1,383 +0,0 @@ -# CSSTidy - CSS Optimizer -# -# CSS Optimizer class -# -# This file is part of CSSTidy. -# -# CSSTidy is free software you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation either version 2 of the License, or -# (at your option) any later version. -# -# CSSTidy is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with CSSTidy if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# -# @license http://opensource.org/licenses/gpl-license.php GNU Public License -# @package csstidy -# @author Dj Gilcrease (digitalxero at gmail dot com) 2005-2006 - -import data -from tools import SortedDict - - -class CSSOptimizer(object): - def __init__(self, parser): - #raw_css is a dict - self.parser = parser - self._optimized_css = SortedDict - - -#PUBLIC METHODS - def optimize(self, raw_css): - if self.parser.getSetting('preserve_css'): - return raw_css - - self._optimized_css = raw_css - - if self.parser.getSetting('merge_selectors') == 2: - self.__merge_selectors() - - ##OPTIMIZE## - for media, css in self._optimized_css.iteritems(): - for selector, cssdata in css.iteritems(): - if self.parser.getSetting('optimise_shorthands') >= 1: - cssdata = self.__merge_4value_shorthands(cssdata) - - if self.parser.getSetting('optimise_shorthands') >= 2: - cssdata = self.__merge_bg(cssdata) - - for item, value in cssdata.iteritems(): - value = self.__compress_numbers(item, value) - value = self.__compress_important(value) - - if item in data.color_values and self.parser.getSetting('compress_colors'): - old = value[:] - value = self.__compress_color(value) - if old != value: - self.parser.log('In "' + selector + '" Optimised ' + item + ': Changed ' + old + ' to ' + value, 'Information') - - if item == 'font-weight' and self.parser.getSetting('compress_font-weight'): - if value == 'bold': - value = '700' - self.parser.log('In "' + selector + '" Optimised font-weight: Changed "bold" to "700"', 'Information') - - elif value == 'normal': - value = '400' - self.parser.log('In "' + selector + '" Optimised font-weight: Changed "normal" to "400"', 'Information') - - self._optimized_css[media][selector][item] = value - - - return self._optimized_css - - -#PRIVATE METHODS - def __merge_bg(self, cssdata): - """ - Merges all background properties - @cssdata (dict) is a dictionary of the selector properties - """ - #Max number of background images. CSS3 not yet fully implemented - img = 1 - clr = 1 - bg_img_list = [] - if cssdata.has_key('background-image'): - img = len(cssdata['background-image'].split(',')) - bg_img_list = self.parser.gvw_important(cssdata['background-image']).split(',') - - elif cssdata.has_key('background-color'): - clr = len(cssdata['background-color'].split(',')) - - - number_of_values = max(img, clr, 1) - - new_bg_value = '' - important = '' - - for i in xrange(number_of_values): - for bg_property, default_value in data.background_prop_default.iteritems(): - #Skip if property does not exist - if not cssdata.has_key(bg_property): - continue - - cur_value = cssdata[bg_property] - - #Skip some properties if there is no background image - if (len(bg_img_list) > i and bg_img_list[i] == 'none') and bg_property in frozenset(['background-size', 'background-position', 'background-attachment', 'background-repeat']): - continue - - #Remove !important - if self.parser.is_important(cur_value): - important = ' !important' - cur_value = self.parser.gvw_important(cur_value) - - #Do not add default values - if cur_value == default_value: - continue - - temp = cur_value.split(',') - - if len(temp) > i: - if bg_property == 'background-size': - new_bg_value += '(' + temp[i] + ') ' - - else: - new_bg_value += temp[i] + ' ' - - new_bg_value = new_bg_value.strip() - if i != (number_of_values-1): - new_bg_value += ',' - - #Delete all background-properties - for bg_property, default_value in data.background_prop_default.iteritems(): - try: - del cssdata[bg_property] - except: - pass - - #Add new background property - if new_bg_value != '': - cssdata['background'] = new_bg_value + important - - return cssdata - - def __merge_4value_shorthands(self, cssdata): - """ - Merges Shorthand properties again, the opposite of dissolve_4value_shorthands() - @cssdata (dict) is a dictionary of the selector properties - """ - for key, value in data.shorthands.iteritems(): - important = '' - if value != 0 and cssdata.has_key(value[0]) and cssdata.has_key(value[1]) and cssdata.has_key(value[2]) and cssdata.has_key(value[3]): - cssdata[key] = '' - - for i in xrange(4): - val = cssdata[value[i]] - if self.parser.is_important(val): - important = '!important' - cssdata[key] += self.parser.gvw_important(val) + ' ' - - else: - cssdata[key] += val + ' ' - - del cssdata[value[i]] - if cssdata.has_key(key): - cssdata[key] = self.__shorthand(cssdata[key] + important.strip()) - - return cssdata - - - def __merge_selectors(self): - """ - Merges selectors with same properties. Example: a{color:red} b{color:red} . a,b{color:red} - Very basic and has at least one bug. Hopefully there is a replacement soon. - @selector_one (string) is the current selector - @value_one (dict) is a dictionary of the selector properties - Note: Currently is the elements of a selector are identical, but in a different order, they are not merged - """ - - ##OPTIMIZE## - ##FIX## - - raw_css = self._optimized_css.copy() - delete = [] - add = SortedDict() - for media, css in raw_css.iteritems(): - for selector_one, value_one in css.iteritems(): - newsel = selector_one - - for selector_two, value_two in css.iteritems(): - if selector_one == selector_two: - #We need to skip self - continue - - if value_one == value_two: - #Ok, we need to merge these two selectors - newsel += ', ' + selector_two - delete.append((media, selector_two)) - - - if not add.has_key(media): - add[media] = SortedDict() - - add[media][newsel] = value_one - delete.append((media, selector_one)) - - for item in delete: - try: - del self._optimized_css[item[0]][item[1]] - except: - #Must have already been deleted - continue - - for media, css in add.iteritems(): - self._optimized_css[media].update(css) - - - - def __shorthand(self, value): - """ - Compresses shorthand values. Example: margin:1px 1px 1px 1px . margin:1px - @value (string) - """ - - ##FIX## - - important = ''; - if self.parser.is_important(value): - value_list = self.parser.gvw_important(value) - important = '!important' - else: - value_list = value - - ret = value - value_list = value_list.split(' ') - - if len(value_list) == 4: - if value_list[0] == value_list[1] and value_list[0] == value_list[2] and value_list[0] == value_list[3]: - ret = value_list[0] + important - - elif value_list[1] == value_list[3] and value_list[0] == value_list[2]: - ret = value_list[0] + ' ' + value_list[1] + important - - elif value_list[1] == value_list[3]: - ret = value_list[0] + ' ' + value_list[1] + ' ' + value_list[2] + important - - elif len(value_list) == 3: - if value_list[0] == value_list[1] and value_list[0] == value_list[2]: - ret = value_list[0] + important - - elif value_list[0] == value_list[2]: - return value_list[0] + ' ' + value_list[1] + important - - elif len(value_list) == 2: - if value_list[0] == value_list[1]: - ret = value_list[0] + important - - if ret != value: - self.parser.log('Optimised shorthand notation: Changed "' + value + '" to "' + ret + '"', 'Information') - - return ret - - def __compress_important(self, value): - """ - Removes unnecessary whitespace in ! important - @value (string) - """ - if self.parser.is_important(value): - value = self.parser.gvw_important(value) + '!important' - - return value - - def __compress_numbers(self, prop, value): - """ - Compresses numbers (ie. 1.0 becomes 1 or 1.100 becomes 1.1 ) - @value (string) is the posible number to be compressed - """ - - ##FIX## - - value = value.split('/') - - for l in xrange(len(value)): - #continue if no numeric value - if not (len(value[l]) > 0 and (value[l][0].isdigit() or value[l][0] in ('+', '-') )): - continue - - #Fix bad colors - if prop in data.color_values: - value[l] = '#' + value[l] - - is_floatable = False - try: - float(value[l]) - is_floatable = True - except: - pass - - if is_floatable and float(value[l]) == 0: - value[l] = '0' - - elif value[l][0] != '#': - unit_found = False - for unit in data.units: - pos = value[l].lower().find(unit) - if pos != -1 and prop not in data.shorthands: - value[l] = self.__remove_leading_zeros(float(value[l][:pos])) + unit - unit_found = True - break; - - if not unit_found and prop in data.unit_values and prop not in data.shorthands: - value[l] = self.__remove_leading_zeros(float(value[l])) + 'px' - - elif not unit_found and prop not in data.shorthands: - value[l] = self.__remove_leading_zeros(float(value[l])) - - - if len(value) > 1: - return '/'.join(value) - - return value[0] - - def __remove_leading_zeros(self, float_val): - """ - Removes the leading zeros from a float value - @float_val (float) - @returns (string) - """ - #Remove leading zero - if abs(float_val) < 1: - if float_val < 0: - float_val = '-' . str(float_val)[2:] - else: - float_val = str(float_val)[1:] - - return str(float_val) - - def __compress_color(self, color): - """ - Color compression function. Converts all rgb() values to #-values and uses the short-form if possible. Also replaces 4 color names by #-values. - @color (string) the {posible} color to change - """ - - #rgb(0,0,0) . #000000 (or #000 in this case later) - if color[:4].lower() == 'rgb(': - color_tmp = color[4:(len(color)-5)] - color_tmp = color_tmp.split(',') - - for c in color_tmp: - c = c.strip() - if c[:-1] == '%': - c = round((255*color_tmp[i])/100) - - if color_tmp[i] > 255: - color_tmp[i] = 255 - - color = '#' - - for i in xrange(3): - if color_tmp[i] < 16: - color += '0' + str(hex(color_tmp[i])).replace('0x', '') - else: - color += str(hex(color_tmp[i])).replace('0x', '') - - #Fix bad color names - if data.replace_colors.has_key(color.lower()): - color = data.replace_colors[color.lower()] - - #aabbcc . #abc - if len(color) == 7: - color_temp = color.lower() - if color_temp[0] == '#' and color_temp[1] == color_temp[2] and color_temp[3] == color_temp[4] and color_temp[5] == color_temp[6]: - color = '#' + color[1] + color[3] + color[5] - - if data.optimize_colors.has_key(color.lower()): - color = data.optimize_colors[color.lower()] - - return color \ No newline at end of file diff --git a/compress/filters/csstidy_python/output.py b/compress/filters/csstidy_python/output.py deleted file mode 100644 index 795a0d050..000000000 --- a/compress/filters/csstidy_python/output.py +++ /dev/null @@ -1,101 +0,0 @@ -# CSSTidy - CSS Printer -# -# CSS Printer class -# -# This file is part of CSSTidy. -# -# CSSTidy is free software you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation either version 2 of the License, or -# (at your option) any later version. -# -# CSSTidy is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with CSSTidy if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# -# @license http://opensource.org/licenses/gpl-license.php GNU Public License -# @package csstidy -# @author Dj Gilcrease (digitalxero at gmail dot com) 2005-2006 - -import data - -class CSSPrinter(object): - def __init__(self, parser): - self.parser = parser - self._css = {} - self.__renderMethods = {'string': self.__renderString, 'file': self.__renderFile} - -#PUBLIC METHODS - def prepare(self, css): - self._css = css - - def render(self, output="string", *args, **kwargs): - return self.__renderMethods[output](*args, **kwargs) - -#PRIVATE METHODS - def __renderString(self, *args, **kwargs): - ##OPTIMIZE## - template = self.parser.getSetting('template') - ret = "" - - if template == 'highest_compression': - top_line_end = "" - iner_line_end = "" - bottom_line_end = "" - indent = "" - - elif template == 'high_compression': - top_line_end = "\n" - iner_line_end = "" - bottom_line_end = "\n" - indent = "" - - elif template == 'default': - top_line_end = "\n" - iner_line_end = "\n" - bottom_line_end = "\n\n" - indent = "" - - elif template == 'low_compression': - top_line_end = "\n" - iner_line_end = "\n" - bottom_line_end = "\n\n" - indent = " " - - if self.parser.getSetting('timestamp'): - ret += '/# CSSTidy ' + self.parser.version + ': ' + datetime.now().strftime("%a, %d %b %Y %H:%M:%S +0000") + ' #/' + top_line_end - - for item in self.parser._import: - ret += '@import(' + item + ');' + top_line_end - - for item in self.parser._charset: - ret += '@charset(' + item + ');' + top_line_end - - for item in self.parser._namespace: - ret += '@namespace(' + item + ');' + top_line_end - - for media, css in self._css.iteritems(): - for selector, cssdata in css.iteritems(): - ret += selector + '{' + top_line_end - - for item, value in cssdata.iteritems(): - ret += indent + item + ':' + value + ';' + iner_line_end - - ret += '}' + bottom_line_end - - return ret - - def __renderFile(self, filename=None, *args, **kwargs): - if filename is None: - return self.__renderString() - - try: - f = open(filename, "w") - f.write(self.__renderString()) - finally: - f.close() \ No newline at end of file diff --git a/compress/filters/csstidy_python/tools.py b/compress/filters/csstidy_python/tools.py deleted file mode 100644 index e62faef2c..000000000 --- a/compress/filters/csstidy_python/tools.py +++ /dev/null @@ -1,109 +0,0 @@ - -class SortedDict(dict): - """ - A dictionary that keeps its keys in the order in which they're inserted. - """ - def __init__(self, data=None): - if data is None: - data = {} - super(SortedDict, self).__init__(data) - if isinstance(data, dict): - self.keyOrder = data.keys() - else: - self.keyOrder = [] - for key, value in data: - if key not in self.keyOrder: - self.keyOrder.append(key) - - def __deepcopy__(self, memo): - from copy import deepcopy - return self.__class__([(key, deepcopy(value, memo)) - for key, value in self.iteritems()]) - - def __setitem__(self, key, value): - super(SortedDict, self).__setitem__(key, value) - if key not in self.keyOrder: - self.keyOrder.append(key) - - def __delitem__(self, key): - super(SortedDict, self).__delitem__(key) - self.keyOrder.remove(key) - - def __iter__(self): - for k in self.keyOrder: - yield k - - def pop(self, k, *args): - result = super(SortedDict, self).pop(k, *args) - try: - self.keyOrder.remove(k) - except ValueError: - # Key wasn't in the dictionary in the first place. No problem. - pass - return result - - def popitem(self): - result = super(SortedDict, self).popitem() - self.keyOrder.remove(result[0]) - return result - - def items(self): - return zip(self.keyOrder, self.values()) - - def iteritems(self): - for key in self.keyOrder: - yield key, super(SortedDict, self).__getitem__(key) - - def keys(self): - return self.keyOrder[:] - - def iterkeys(self): - return iter(self.keyOrder) - - def values(self): - return [super(SortedDict, self).__getitem__(k) for k in self.keyOrder] - - def itervalues(self): - for key in self.keyOrder: - yield super(SortedDict, self).__getitem__(key) - - def update(self, dict_): - for k, v in dict_.items(): - self.__setitem__(k, v) - - def setdefault(self, key, default): - if key not in self.keyOrder: - self.keyOrder.append(key) - return super(SortedDict, self).setdefault(key, default) - - def value_for_index(self, index): - """Returns the value of the item at the given zero-based index.""" - return self[self.keyOrder[index]] - - def insert(self, index, key, value): - """Inserts the key, value pair before the item with the given index.""" - if key in self.keyOrder: - n = self.keyOrder.index(key) - del self.keyOrder[n] - if n < index: - index -= 1 - self.keyOrder.insert(index, key) - super(SortedDict, self).__setitem__(key, value) - - def copy(self): - """Returns a copy of this object.""" - # This way of initializing the copy means it works for subclasses, too. - obj = self.__class__(self) - obj.keyOrder = self.keyOrder[:] - return obj - - def __repr__(self): - """ - Replaces the normal dict.__repr__ with a version that returns the keys - in their sorted order. - """ - return '{%s}' % ', '.join(['%r: %r' % (k, v) for k, v in self.items()]) - - def clear(self): - super(SortedDict, self).clear() - self.keyOrder = [] \ No newline at end of file diff --git a/compress/filters/jsmin/__init__.py b/compress/filters/jsmin/__init__.py deleted file mode 100644 index d22620081..000000000 --- a/compress/filters/jsmin/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -from compress.filters.jsmin.jsmin import jsmin -from compress.filter_base import FilterBase - -class JSMinFilter(FilterBase): - def filter_js(self, js): - return jsmin(js) \ No newline at end of file diff --git a/compress/filters/jsmin/jsmin.py b/compress/filters/jsmin/jsmin.py deleted file mode 100644 index 4f9d384f1..000000000 --- a/compress/filters/jsmin/jsmin.py +++ /dev/null @@ -1,218 +0,0 @@ -#!/usr/bin/python - -# This code is original from jsmin by Douglas Crockford, it was translated to -# Python by Baruch Even. The original code had the following copyright and -# license. -# -# /* jsmin.c -# 2007-05-22 -# -# Copyright (c) 2002 Douglas Crockford (www.crockford.com) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in -# the Software without restriction, including without limitation the rights to -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -# of the Software, and to permit persons to whom the Software is furnished to do -# so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# The Software shall be used for Good, not Evil. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# */ - -from StringIO import StringIO - -def jsmin(js): - ins = StringIO(js) - outs = StringIO() - JavascriptMinify().minify(ins, outs) - str = outs.getvalue() - if len(str) > 0 and str[0] == '\n': - str = str[1:] - return str - -def isAlphanum(c): - """return true if the character is a letter, digit, underscore, - dollar sign, or non-ASCII character. - """ - return ((c >= 'a' and c <= 'z') or (c >= '0' and c <= '9') or - (c >= 'A' and c <= 'Z') or c == '_' or c == '$' or c == '\\' or (c is not None and ord(c) > 126)); - -class UnterminatedComment(Exception): - pass - -class UnterminatedStringLiteral(Exception): - pass - -class UnterminatedRegularExpression(Exception): - pass - -class JavascriptMinify(object): - - def _outA(self): - self.outstream.write(self.theA) - def _outB(self): - self.outstream.write(self.theB) - - def _get(self): - """return the next character from stdin. Watch out for lookahead. If - the character is a control character, translate it to a space or - linefeed. - """ - c = self.theLookahead - self.theLookahead = None - if c == None: - c = self.instream.read(1) - if c >= ' ' or c == '\n': - return c - if c == '': # EOF - return '\000' - if c == '\r': - return '\n' - return ' ' - - def _peek(self): - self.theLookahead = self._get() - return self.theLookahead - - def _next(self): - """get the next character, excluding comments. peek() is used to see - if a '/' is followed by a '/' or '*'. - """ - c = self._get() - if c == '/': - p = self._peek() - if p == '/': - c = self._get() - while c > '\n': - c = self._get() - return c - if p == '*': - c = self._get() - while 1: - c = self._get() - if c == '*': - if self._peek() == '/': - self._get() - return ' ' - if c == '\000': - raise UnterminatedComment() - - return c - - def _action(self, action): - """do something! What you do is determined by the argument: - 1 Output A. Copy B to A. Get the next B. - 2 Copy B to A. Get the next B. (Delete A). - 3 Get the next B. (Delete B). - action treats a string as a single character. Wow! - action recognizes a regular expression if it is preceded by ( or , or =. - """ - if action <= 1: - self._outA() - - if action <= 2: - self.theA = self.theB - if self.theA == "'" or self.theA == '"': - while 1: - self._outA() - self.theA = self._get() - if self.theA == self.theB: - break - if self.theA <= '\n': - raise UnterminatedStringLiteral() - if self.theA == '\\': - self._outA() - self.theA = self._get() - - - if action <= 3: - self.theB = self._next() - if self.theB == '/' and (self.theA == '(' or self.theA == ',' or - self.theA == '=' or self.theA == ':' or - self.theA == '[' or self.theA == '?' or - self.theA == '!' or self.theA == '&' or - self.theA == '|' or self.theA == ';' or - self.theA == '{' or self.theA == '}' or - self.theA == '\n'): - self._outA() - self._outB() - while 1: - self.theA = self._get() - if self.theA == '/': - break - elif self.theA == '\\': - self._outA() - self.theA = self._get() - elif self.theA <= '\n': - raise UnterminatedRegularExpression() - self._outA() - self.theB = self._next() - - - def _jsmin(self): - """Copy the input to the output, deleting the characters which are - insignificant to JavaScript. Comments will be removed. Tabs will be - replaced with spaces. Carriage returns will be replaced with linefeeds. - Most spaces and linefeeds will be removed. - """ - self.theA = '\n' - self._action(3) - - while self.theA != '\000': - if self.theA == ' ': - if isAlphanum(self.theB): - self._action(1) - else: - self._action(2) - elif self.theA == '\n': - if self.theB in ['{', '[', '(', '+', '-']: - self._action(1) - elif self.theB == ' ': - self._action(3) - else: - if isAlphanum(self.theB): - self._action(1) - else: - self._action(2) - else: - if self.theB == ' ': - if isAlphanum(self.theA): - self._action(1) - else: - self._action(3) - elif self.theB == '\n': - if self.theA in ['}', ']', ')', '+', '-', '"', '\'']: - self._action(1) - else: - if isAlphanum(self.theA): - self._action(1) - else: - self._action(3) - else: - self._action(1) - - def minify(self, instream, outstream): - self.instream = instream - self.outstream = outstream - self.theA = '\n' - self.theB = None - self.theLookahead = None - - self._jsmin() - self.instream.close() - -if __name__ == '__main__': - import sys - jsm = JavascriptMinify() - jsm.minify(sys.stdin, sys.stdout) \ No newline at end of file diff --git a/compress/filters/yui/__init__.py b/compress/filters/yui/__init__.py deleted file mode 100644 index 1e2e711fd..000000000 --- a/compress/filters/yui/__init__.py +++ /dev/null @@ -1,44 +0,0 @@ -import subprocess - -from django.conf import settings - -from compress.filter_base import FilterBase, FilterError - -BINARY = getattr(settings, 'COMPRESS_YUI_BINARY', 'java -jar yuicompressor.jar') -CSS_ARGUMENTS = getattr(settings, 'COMPRESS_YUI_CSS_ARGUMENTS', '') -JS_ARGUMENTS = getattr(settings, 'COMPRESS_YUI_JS_ARGUMENTS', '') - -class YUICompressorFilter(FilterBase): - - def filter_common(self, content, type_, arguments): - command = '%s --type=%s %s' % (BINARY, type_, arguments) - - if self.verbose: - command += ' --verbose' - - p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE) - p.stdin.write(content) - p.stdin.close() - - filtered_css = p.stdout.read() - p.stdout.close() - - err = p.stderr.read() - p.stderr.close() - - if p.wait() != 0: - if not err: - err = 'Unable to apply YUI Compressor filter' - - raise FilterError(err) - - if self.verbose: - print err - - return filtered_css - - def filter_js(self, js): - return self.filter_common(js, 'js', JS_ARGUMENTS) - - def filter_css(self, css): - return self.filter_common(css, 'css', CSS_ARGUMENTS) \ No newline at end of file diff --git a/compress/management/__init__.py b/compress/management/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/compress/management/commands/__init__.py b/compress/management/commands/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/compress/management/commands/synccompress.py b/compress/management/commands/synccompress.py deleted file mode 100644 index 8217979dd..000000000 --- a/compress/management/commands/synccompress.py +++ /dev/null @@ -1,58 +0,0 @@ -from django.core.management.base import NoArgsCommand -from optparse import make_option - -from django.conf import settings - -class Command(NoArgsCommand): - option_list = NoArgsCommand.option_list + ( - make_option('--force', action='store_true', default=False, help='Force update of all files, even if the source files are older than the current compressed file.'), - ) - help = 'Updates and compresses CSS and JavsScript on-demand, without restarting Django' - args = '' - - def handle_noargs(self, **options): - - force = options.get('force', False) - verbosity = int(options.get('verbosity', 1)) - - from compress.utils import needs_update, filter_css, filter_js - - for name, css in settings.COMPRESS_CSS.items(): - u, version = needs_update(css['output_filename'], - css['source_filenames']) - - if (force or u) or verbosity >= 2: - msg = 'CSS Group \'%s\'' % name - print msg - print len(msg) * '-' - print "Version: %s" % version - - if force or u: - filter_css(css, verbosity) - - if (force or u) or verbosity >= 2: - print - - for name, js in settings.COMPRESS_JS.items(): - u, version = needs_update(js['output_filename'], - js['source_filenames']) - - if (force or u) or verbosity >= 2: - msg = 'JavaScript Group \'%s\'' % name - print msg - print len(msg) * '-' - print "Version: %s" % version - - if force or u: - filter_js(js, verbosity) - - if (force or u) or verbosity >= 2: - print - -# Backwards compatibility for Django r9110 -if not [opt for opt in Command.option_list if opt.dest=='verbosity']: - Command.option_list += ( - make_option('--verbosity', '-v', action="store", dest="verbosity", - default='1', type='choice', choices=['0', '1', '2'], - help="Verbosity level; 0=minimal output, 1=normal output, 2=all output"), - ) diff --git a/compress/models.py b/compress/models.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/compress/signals.py b/compress/signals.py deleted file mode 100644 index bd76a76e7..000000000 --- a/compress/signals.py +++ /dev/null @@ -1,4 +0,0 @@ -from django.dispatch import Signal - -css_filtered = Signal() -js_filtered = Signal() diff --git a/compress/templates/compress/css.html b/compress/templates/compress/css.html deleted file mode 100644 index 3751a4a07..000000000 --- a/compress/templates/compress/css.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/compress/templates/compress/css_ie.html b/compress/templates/compress/css_ie.html deleted file mode 100644 index 2e244ee9e..000000000 --- a/compress/templates/compress/css_ie.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/compress/templates/compress/js.html b/compress/templates/compress/js.html deleted file mode 100644 index 8419c20a1..000000000 --- a/compress/templates/compress/js.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/compress/templates/compress/js_ie.html b/compress/templates/compress/js_ie.html deleted file mode 100644 index ef1a37c7c..000000000 --- a/compress/templates/compress/js_ie.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/compress/templatetags/__init__.py b/compress/templatetags/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/compress/templatetags/compressed.py b/compress/templatetags/compressed.py deleted file mode 100644 index 0b236e37c..000000000 --- a/compress/templatetags/compressed.py +++ /dev/null @@ -1,123 +0,0 @@ -import os - -from django import template - -from django.conf import settings as django_settings - -from compress.conf import settings -from compress.utils import media_root, media_url, needs_update, filter_css, filter_js, get_output_filename, get_version, get_version_from_file - -register = template.Library() - -def render_common(template_name, obj, filename, version): - if settings.COMPRESS: - filename = get_output_filename(filename, version) - - context = obj.get('extra_context', {}) - if filename.startswith('http://'): - context['url'] = filename - else: - context['url'] = media_url(filename) - - return template.loader.render_to_string(template_name, context) - -def render_css(css, filename, version=None): - return render_common(css.get('template_name', 'compress/css.html'), css, filename, version) - -def render_js(js, filename, version=None): - return render_common(js.get('template_name', 'compress/js.html'), js, filename, version) - -class CompressedCSSNode(template.Node): - def __init__(self, name): - self.name = name - - def render(self, context): - css_name = template.Variable(self.name).resolve(context) - - try: - css = settings.COMPRESS_CSS[css_name] - except KeyError: - return '' # fail silently, do not return anything if an invalid group is specified - - if settings.COMPRESS: - - version = None - - if settings.COMPRESS_AUTO: - u, version = needs_update(css['output_filename'], - css['source_filenames']) - if u: - filter_css(css) - else: - filename_base, filename = os.path.split(css['output_filename']) - path_name = media_root(filename_base) - version = get_version_from_file(path_name, filename) - - return render_css(css, css['output_filename'], version) - else: - # output source files - r = '' - for source_file in css['source_filenames']: - r += render_css(css, source_file) - - return r - -class CompressedJSNode(template.Node): - def __init__(self, name): - self.name = name - - def render(self, context): - js_name = template.Variable(self.name).resolve(context) - - try: - js = settings.COMPRESS_JS[js_name] - except KeyError: - return '' # fail silently, do not return anything if an invalid group is specified - - if 'external_urls' in js: - r = '' - for url in js['external_urls']: - r += render_js(js, url) - return r - - if settings.COMPRESS: - - version = None - - if settings.COMPRESS_AUTO: - u, version = needs_update(js['output_filename'], - js['source_filenames']) - if u: - filter_js(js) - else: - filename_base, filename = os.path.split(js['output_filename']) - path_name = media_root(filename_base) - version = get_version_from_file(path_name, filename) - - return render_js(js, js['output_filename'], version) - else: - # output source files - r = '' - for source_file in js['source_filenames']: - r += render_js(js, source_file) - return r - -#@register.tag -def compressed_css(parser, token): - try: - tag_name, name = token.split_contents() - except ValueError: - raise template.TemplateSyntaxError, '%r requires exactly one argument: the name of a group in the COMPRESS_CSS setting' % token.split_contents()[0] - - return CompressedCSSNode(name) -compressed_css = register.tag(compressed_css) - -#@register.tag -def compressed_js(parser, token): - try: - tag_name, name = token.split_contents() - except ValueError: - raise template.TemplateSyntaxError, '%r requires exactly one argument: the name of a group in the COMPRESS_JS setting' % token.split_contents()[0] - - return CompressedJSNode(name) -compressed_js = register.tag(compressed_js) diff --git a/compress/utils.py b/compress/utils.py deleted file mode 100644 index 6fd21c1d2..000000000 --- a/compress/utils.py +++ /dev/null @@ -1,133 +0,0 @@ -import os -import re -import tempfile - -from django.conf import settings as django_settings -from django.utils.http import urlquote -from django.dispatch import dispatcher - -from compress.conf import settings -from compress.signals import css_filtered, js_filtered - -def get_class(class_string): - """ - Convert a string version of a function name to the callable object. - """ - - if not hasattr(class_string, '__bases__'): - - try: - class_string = class_string.encode('ascii') - mod_name, class_name = get_mod_func(class_string) - if class_name != '': - class_string = getattr(__import__(mod_name, {}, {}, ['']), class_name) - except (ImportError, AttributeError): - raise Exception('Failed to import filter %s' % class_string) - - return class_string - -def get_mod_func(callback): - """ - Converts 'django.views.news.stories.story_detail' to - ('django.views.news.stories', 'story_detail') - """ - - try: - dot = callback.rindex('.') - except ValueError: - return callback, '' - return callback[:dot], callback[dot+1:] - -def needs_update(output_file, source_files, verbosity=0): - """ - Scan the source files for changes and returns True if the output_file needs to be updated. - """ - - version = get_version(source_files) - - on = get_output_filename(output_file, version) - compressed_file_full = media_root(on) - - if not os.path.exists(compressed_file_full): - return True, version - - update_needed = getattr(get_class(settings.COMPRESS_VERSIONING)(), 'needs_update')(output_file, source_files, version) - return update_needed - -def media_root(filename): - """ - Return the full path to ``filename``. ``filename`` is a relative path name in MEDIA_ROOT - """ - return os.path.join(django_settings.MEDIA_ROOT, filename) - -def media_url(url): - return django_settings.MEDIA_URL + urlquote(url) - -def concat(filenames, separator=''): - """ - Concatenate the files from the list of the ``filenames``, ouput separated with ``separator``. - """ - r = '' - for filename in filenames: - fd = open(media_root(filename), 'rb') - r += fd.read() - r += separator - fd.close() - return r - -def max_mtime(files): - return int(max([os.stat(media_root(f)).st_mtime for f in files])) - -def save_file(filename, contents): - fd = open(media_root(filename), 'wb+') - fd.write(contents) - fd.close() - -def get_output_filename(filename, version): - if settings.COMPRESS_VERSION and version is not None: - return filename.replace(settings.COMPRESS_VERSION_PLACEHOLDER, version) - else: - return filename.replace(settings.COMPRESS_VERSION_PLACEHOLDER, settings.COMPRESS_VERSION_DEFAULT) - -def get_version(source_files, verbosity=0): - version = getattr(get_class(settings.COMPRESS_VERSIONING)(), 'get_version')(source_files) - return version - -def get_version_from_file(path, filename): - regex = re.compile(r'^%s$' % (get_output_filename(settings.COMPRESS_VERSION_PLACEHOLDER.join([re.escape(part) for part in filename.split(settings.COMPRESS_VERSION_PLACEHOLDER)]), r'([A-Za-z0-9]+)'))) - for f in os.listdir(path): - result = regex.match(f) - if result and result.groups(): - return result.groups()[0] - -def remove_files(path, filename, verbosity=0): - regex = re.compile(r'^%s$' % (os.path.basename(get_output_filename(settings.COMPRESS_VERSION_PLACEHOLDER.join([re.escape(part) for part in filename.split(settings.COMPRESS_VERSION_PLACEHOLDER)]), r'[A-Za-z0-9]+')))) - for f in os.listdir(path): - if regex.match(f): - if verbosity >= 1: - print "Removing outdated file %s" % f - - os.unlink(os.path.join(path, f)) - -def filter_common(obj, verbosity, filters, attr, separator, signal): - output = concat(obj['source_filenames'], separator) - - filename = get_output_filename(obj['output_filename'], get_version(obj['source_filenames'])) - - if settings.COMPRESS_VERSION: - remove_files(os.path.dirname(media_root(filename)), obj['output_filename'], verbosity) - - if verbosity >= 1: - print "Saving %s" % filename - - for f in filters: - output = getattr(get_class(f)(verbose=(verbosity >= 2)), attr)(output) - - save_file(filename, output) - signal.send(None) - -def filter_css(css, verbosity=0): - return filter_common(css, verbosity, filters=settings.COMPRESS_CSS_FILTERS, attr='filter_css', separator='', signal=css_filtered) - -def filter_js(js, verbosity=0): - return filter_common(js, verbosity, filters=settings.COMPRESS_JS_FILTERS, attr='filter_js', separator='', signal=js_filtered) diff --git a/compress/versioning/__init__.py b/compress/versioning/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/compress/versioning/base.py b/compress/versioning/base.py deleted file mode 100644 index 8b8151960..000000000 --- a/compress/versioning/base.py +++ /dev/null @@ -1,13 +0,0 @@ -class VersioningBase(object): - - def get_version(self, source_files): - raise NotImplementedError - - def needs_update(self, output_file, source_files, version): - raise NotImplementedError - -class VersioningError(Exception): - """ - This exception is raised when version creation fails - """ - pass \ No newline at end of file diff --git a/compress/versioning/hash/__init__.py b/compress/versioning/hash/__init__.py deleted file mode 100644 index 74721fe0d..000000000 --- a/compress/versioning/hash/__init__.py +++ /dev/null @@ -1,47 +0,0 @@ -import cStringIO -from hashlib import md5, sha1 -import os - -from compress.conf import settings -from compress.utils import concat, get_output_filename -from compress.versioning.base import VersioningBase - -class HashVersioningBase(VersioningBase): - def __init__(self, hash_method): - self.hash_method = hash_method - - def needs_update(self, output_file, source_files, version): - output_file_name = get_output_filename(output_file, version) - ph = settings.COMPRESS_VERSION_PLACEHOLDER - of = output_file - try: - phi = of.index(ph) - old_version = output_file_name[phi:phi+len(ph)-len(of)] - return (version != old_version), version - except ValueError: - # no placeholder found, do not update, manual update if needed - return False, version - - def get_version(self, source_files): - buf = concat(source_files) - s = cStringIO.StringIO(buf) - version = self.get_hash(s) - s.close() - return version - - def get_hash(self, f, CHUNK=2**16): - m = self.hash_method() - while 1: - chunk = f.read(CHUNK) - if not chunk: - break - m.update(chunk) - return m.hexdigest() - -class MD5Versioning(HashVersioningBase): - def __init__(self): - super(MD5Versioning, self).__init__(md5) - -class SHA1Versioning(HashVersioningBase): - def __init__(self): - super(SHA1Versioning, self).__init__(sha1) \ No newline at end of file diff --git a/compress/versioning/mtime/__init__.py b/compress/versioning/mtime/__init__.py deleted file mode 100644 index 31b9d0b93..000000000 --- a/compress/versioning/mtime/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -import os - -from compress.utils import get_output_filename, media_root -from compress.versioning.base import VersioningBase - -class MTimeVersioning(VersioningBase): - - def get_version(self, source_files): - - # Return the modification time for the newest source file - return str(max([int(os.stat(media_root(f)).st_mtime) for f in source_files])) - - def needs_update(self, output_file, source_files, version): - - output_file_name = get_output_filename(output_file, version) - compressed_file_full = media_root(output_file_name) - - return (int(os.stat(compressed_file_full).st_mtime) < int(version)), version - diff --git a/media/js/jquery-1.6.1.js b/media/js/jquery-1.6.1.js deleted file mode 100644 index a2bf53029..000000000 --- a/media/js/jquery-1.6.1.js +++ /dev/null @@ -1,8936 +0,0 @@ -/*! - * jQuery JavaScript Library v1.6.1 - * http://jquery.com/ - * - * Copyright 2011, John Resig - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * Includes Sizzle.js - * http://sizzlejs.com/ - * Copyright 2011, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * - * Date: Thu May 12 15:04:36 2011 -0400 - */ -(function( window, undefined ) { - -// Use the correct document accordingly with window argument (sandbox) -var document = window.document, - navigator = window.navigator, - location = window.location; -var jQuery = (function() { - -// Define a local copy of jQuery -var jQuery = function( selector, context ) { - // The jQuery object is actually just the init constructor 'enhanced' - return new jQuery.fn.init( selector, context, rootjQuery ); - }, - - // Map over jQuery in case of overwrite - _jQuery = window.jQuery, - - // Map over the $ in case of overwrite - _$ = window.$, - - // A central reference to the root jQuery(document) - rootjQuery, - - // A simple way to check for HTML strings or ID strings - // (both of which we optimize for) - quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, - - // Check if a string has a non-whitespace character in it - rnotwhite = /\S/, - - // Used for trimming whitespace - trimLeft = /^\s+/, - trimRight = /\s+$/, - - // Check for digits - rdigit = /\d/, - - // Match a standalone tag - rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, - - // JSON RegExp - rvalidchars = /^[\],:{}\s]*$/, - rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, - rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, - rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, - - // Useragent RegExp - rwebkit = /(webkit)[ \/]([\w.]+)/, - ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/, - rmsie = /(msie) ([\w.]+)/, - rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/, - - // Keep a UserAgent string for use with jQuery.browser - userAgent = navigator.userAgent, - - // For matching the engine and version of the browser - browserMatch, - - // The deferred used on DOM ready - readyList, - - // The ready event handler - DOMContentLoaded, - - // Save a reference to some core methods - toString = Object.prototype.toString, - hasOwn = Object.prototype.hasOwnProperty, - push = Array.prototype.push, - slice = Array.prototype.slice, - trim = String.prototype.trim, - indexOf = Array.prototype.indexOf, - - // [[Class]] -> type pairs - class2type = {}; - -jQuery.fn = jQuery.prototype = { - constructor: jQuery, - init: function( selector, context, rootjQuery ) { - var match, elem, ret, doc; - - // Handle $(""), $(null), or $(undefined) - if ( !selector ) { - return this; - } - - // Handle $(DOMElement) - if ( selector.nodeType ) { - this.context = this[0] = selector; - this.length = 1; - return this; - } - - // The body element only exists once, optimize finding it - if ( selector === "body" && !context && document.body ) { - this.context = document; - this[0] = document.body; - this.selector = selector; - this.length = 1; - return this; - } - - // Handle HTML strings - if ( typeof selector === "string" ) { - // Are we dealing with HTML string or an ID? - if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { - // Assume that strings that start and end with <> are HTML and skip the regex check - match = [ null, selector, null ]; - - } else { - match = quickExpr.exec( selector ); - } - - // Verify a match, and that no context was specified for #id - if ( match && (match[1] || !context) ) { - - // HANDLE: $(html) -> $(array) - if ( match[1] ) { - context = context instanceof jQuery ? context[0] : context; - doc = (context ? context.ownerDocument || context : document); - - // If a single string is passed in and it's a single tag - // just do a createElement and skip the rest - ret = rsingleTag.exec( selector ); - - if ( ret ) { - if ( jQuery.isPlainObject( context ) ) { - selector = [ document.createElement( ret[1] ) ]; - jQuery.fn.attr.call( selector, context, true ); - - } else { - selector = [ doc.createElement( ret[1] ) ]; - } - - } else { - ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); - selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes; - } - - return jQuery.merge( this, selector ); - - // HANDLE: $("#id") - } else { - elem = document.getElementById( match[2] ); - - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - if ( elem && elem.parentNode ) { - // Handle the case where IE and Opera return items - // by name instead of ID - if ( elem.id !== match[2] ) { - return rootjQuery.find( selector ); - } - - // Otherwise, we inject the element directly into the jQuery object - this.length = 1; - this[0] = elem; - } - - this.context = document; - this.selector = selector; - return this; - } - - // HANDLE: $(expr, $(...)) - } else if ( !context || context.jquery ) { - return (context || rootjQuery).find( selector ); - - // HANDLE: $(expr, context) - // (which is just equivalent to: $(context).find(expr) - } else { - return this.constructor( context ).find( selector ); - } - - // HANDLE: $(function) - // Shortcut for document ready - } else if ( jQuery.isFunction( selector ) ) { - return rootjQuery.ready( selector ); - } - - if (selector.selector !== undefined) { - this.selector = selector.selector; - this.context = selector.context; - } - - return jQuery.makeArray( selector, this ); - }, - - // Start with an empty selector - selector: "", - - // The current version of jQuery being used - jquery: "1.6.1", - - // The default length of a jQuery object is 0 - length: 0, - - // The number of elements contained in the matched element set - size: function() { - return this.length; - }, - - toArray: function() { - return slice.call( this, 0 ); - }, - - // Get the Nth element in the matched element set OR - // Get the whole matched element set as a clean array - get: function( num ) { - return num == null ? - - // Return a 'clean' array - this.toArray() : - - // Return just the object - ( num < 0 ? this[ this.length + num ] : this[ num ] ); - }, - - // Take an array of elements and push it onto the stack - // (returning the new matched element set) - pushStack: function( elems, name, selector ) { - // Build a new jQuery matched element set - var ret = this.constructor(); - - if ( jQuery.isArray( elems ) ) { - push.apply( ret, elems ); - - } else { - jQuery.merge( ret, elems ); - } - - // Add the old object onto the stack (as a reference) - ret.prevObject = this; - - ret.context = this.context; - - if ( name === "find" ) { - ret.selector = this.selector + (this.selector ? " " : "") + selector; - } else if ( name ) { - ret.selector = this.selector + "." + name + "(" + selector + ")"; - } - - // Return the newly-formed element set - return ret; - }, - - // Execute a callback for every element in the matched set. - // (You can seed the arguments with an array of args, but this is - // only used internally.) - each: function( callback, args ) { - return jQuery.each( this, callback, args ); - }, - - ready: function( fn ) { - // Attach the listeners - jQuery.bindReady(); - - // Add the callback - readyList.done( fn ); - - return this; - }, - - eq: function( i ) { - return i === -1 ? - this.slice( i ) : - this.slice( i, +i + 1 ); - }, - - first: function() { - return this.eq( 0 ); - }, - - last: function() { - return this.eq( -1 ); - }, - - slice: function() { - return this.pushStack( slice.apply( this, arguments ), - "slice", slice.call(arguments).join(",") ); - }, - - map: function( callback ) { - return this.pushStack( jQuery.map(this, function( elem, i ) { - return callback.call( elem, i, elem ); - })); - }, - - end: function() { - return this.prevObject || this.constructor(null); - }, - - // For internal use only. - // Behaves like an Array's method, not like a jQuery method. - push: push, - sort: [].sort, - splice: [].splice -}; - -// Give the init function the jQuery prototype for later instantiation -jQuery.fn.init.prototype = jQuery.fn; - -jQuery.extend = jQuery.fn.extend = function() { - var options, name, src, copy, copyIsArray, clone, - target = arguments[0] || {}, - i = 1, - length = arguments.length, - deep = false; - - // Handle a deep copy situation - if ( typeof target === "boolean" ) { - deep = target; - target = arguments[1] || {}; - // skip the boolean and the target - i = 2; - } - - // Handle case when target is a string or something (possible in deep copy) - if ( typeof target !== "object" && !jQuery.isFunction(target) ) { - target = {}; - } - - // extend jQuery itself if only one argument is passed - if ( length === i ) { - target = this; - --i; - } - - for ( ; i < length; i++ ) { - // Only deal with non-null/undefined values - if ( (options = arguments[ i ]) != null ) { - // Extend the base object - for ( name in options ) { - src = target[ name ]; - copy = options[ name ]; - - // Prevent never-ending loop - if ( target === copy ) { - continue; - } - - // Recurse if we're merging plain objects or arrays - if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { - if ( copyIsArray ) { - copyIsArray = false; - clone = src && jQuery.isArray(src) ? src : []; - - } else { - clone = src && jQuery.isPlainObject(src) ? src : {}; - } - - // Never move original objects, clone them - target[ name ] = jQuery.extend( deep, clone, copy ); - - // Don't bring in undefined values - } else if ( copy !== undefined ) { - target[ name ] = copy; - } - } - } - } - - // Return the modified object - return target; -}; - -jQuery.extend({ - noConflict: function( deep ) { - if ( window.$ === jQuery ) { - window.$ = _$; - } - - if ( deep && window.jQuery === jQuery ) { - window.jQuery = _jQuery; - } - - return jQuery; - }, - - // Is the DOM ready to be used? Set to true once it occurs. - isReady: false, - - // A counter to track how many items to wait for before - // the ready event fires. See #6781 - readyWait: 1, - - // Hold (or release) the ready event - holdReady: function( hold ) { - if ( hold ) { - jQuery.readyWait++; - } else { - jQuery.ready( true ); - } - }, - - // Handle when the DOM is ready - ready: function( wait ) { - // Either a released hold or an DOMready/load event and not yet ready - if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) { - // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). - if ( !document.body ) { - return setTimeout( jQuery.ready, 1 ); - } - - // Remember that the DOM is ready - jQuery.isReady = true; - - // If a normal DOM Ready event fired, decrement, and wait if need be - if ( wait !== true && --jQuery.readyWait > 0 ) { - return; - } - - // If there are functions bound, to execute - readyList.resolveWith( document, [ jQuery ] ); - - // Trigger any bound ready events - if ( jQuery.fn.trigger ) { - jQuery( document ).trigger( "ready" ).unbind( "ready" ); - } - } - }, - - bindReady: function() { - if ( readyList ) { - return; - } - - readyList = jQuery._Deferred(); - - // Catch cases where $(document).ready() is called after the - // browser event has already occurred. - if ( document.readyState === "complete" ) { - // Handle it asynchronously to allow scripts the opportunity to delay ready - return setTimeout( jQuery.ready, 1 ); - } - - // Mozilla, Opera and webkit nightlies currently support this event - if ( document.addEventListener ) { - // Use the handy event callback - document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); - - // A fallback to window.onload, that will always work - window.addEventListener( "load", jQuery.ready, false ); - - // If IE event model is used - } else if ( document.attachEvent ) { - // ensure firing before onload, - // maybe late but safe also for iframes - document.attachEvent( "onreadystatechange", DOMContentLoaded ); - - // A fallback to window.onload, that will always work - window.attachEvent( "onload", jQuery.ready ); - - // If IE and not a frame - // continually check to see if the document is ready - var toplevel = false; - - try { - toplevel = window.frameElement == null; - } catch(e) {} - - if ( document.documentElement.doScroll && toplevel ) { - doScrollCheck(); - } - } - }, - - // See test/unit/core.js for details concerning isFunction. - // Since version 1.3, DOM methods and functions like alert - // aren't supported. They return false on IE (#2968). - isFunction: function( obj ) { - return jQuery.type(obj) === "function"; - }, - - isArray: Array.isArray || function( obj ) { - return jQuery.type(obj) === "array"; - }, - - // A crude way of determining if an object is a window - isWindow: function( obj ) { - return obj && typeof obj === "object" && "setInterval" in obj; - }, - - isNaN: function( obj ) { - return obj == null || !rdigit.test( obj ) || isNaN( obj ); - }, - - type: function( obj ) { - return obj == null ? - String( obj ) : - class2type[ toString.call(obj) ] || "object"; - }, - - isPlainObject: function( obj ) { - // Must be an Object. - // Because of IE, we also have to check the presence of the constructor property. - // Make sure that DOM nodes and window objects don't pass through, as well - if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { - return false; - } - - // Not own constructor property must be Object - if ( obj.constructor && - !hasOwn.call(obj, "constructor") && - !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { - return false; - } - - // Own properties are enumerated firstly, so to speed up, - // if last one is own, then all properties are own. - - var key; - for ( key in obj ) {} - - return key === undefined || hasOwn.call( obj, key ); - }, - - isEmptyObject: function( obj ) { - for ( var name in obj ) { - return false; - } - return true; - }, - - error: function( msg ) { - throw msg; - }, - - parseJSON: function( data ) { - if ( typeof data !== "string" || !data ) { - return null; - } - - // Make sure leading/trailing whitespace is removed (IE can't handle it) - data = jQuery.trim( data ); - - // Attempt to parse using the native JSON parser first - if ( window.JSON && window.JSON.parse ) { - return window.JSON.parse( data ); - } - - // Make sure the incoming data is actual JSON - // Logic borrowed from http://json.org/json2.js - if ( rvalidchars.test( data.replace( rvalidescape, "@" ) - .replace( rvalidtokens, "]" ) - .replace( rvalidbraces, "")) ) { - - return (new Function( "return " + data ))(); - - } - jQuery.error( "Invalid JSON: " + data ); - }, - - // Cross-browser xml parsing - // (xml & tmp used internally) - parseXML: function( data , xml , tmp ) { - - if ( window.DOMParser ) { // Standard - tmp = new DOMParser(); - xml = tmp.parseFromString( data , "text/xml" ); - } else { // IE - xml = new ActiveXObject( "Microsoft.XMLDOM" ); - xml.async = "false"; - xml.loadXML( data ); - } - - tmp = xml.documentElement; - - if ( ! tmp || ! tmp.nodeName || tmp.nodeName === "parsererror" ) { - jQuery.error( "Invalid XML: " + data ); - } - - return xml; - }, - - noop: function() {}, - - // Evaluates a script in a global context - // Workarounds based on findings by Jim Driscoll - // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context - globalEval: function( data ) { - if ( data && rnotwhite.test( data ) ) { - // We use execScript on Internet Explorer - // We use an anonymous function so that context is window - // rather than jQuery in Firefox - ( window.execScript || function( data ) { - window[ "eval" ].call( window, data ); - } )( data ); - } - }, - - nodeName: function( elem, name ) { - return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); - }, - - // args is for internal usage only - each: function( object, callback, args ) { - var name, i = 0, - length = object.length, - isObj = length === undefined || jQuery.isFunction( object ); - - if ( args ) { - if ( isObj ) { - for ( name in object ) { - if ( callback.apply( object[ name ], args ) === false ) { - break; - } - } - } else { - for ( ; i < length; ) { - if ( callback.apply( object[ i++ ], args ) === false ) { - break; - } - } - } - - // A special, fast, case for the most common use of each - } else { - if ( isObj ) { - for ( name in object ) { - if ( callback.call( object[ name ], name, object[ name ] ) === false ) { - break; - } - } - } else { - for ( ; i < length; ) { - if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) { - break; - } - } - } - } - - return object; - }, - - // Use native String.trim function wherever possible - trim: trim ? - function( text ) { - return text == null ? - "" : - trim.call( text ); - } : - - // Otherwise use our own trimming functionality - function( text ) { - return text == null ? - "" : - text.toString().replace( trimLeft, "" ).replace( trimRight, "" ); - }, - - // results is for internal usage only - makeArray: function( array, results ) { - var ret = results || []; - - if ( array != null ) { - // The window, strings (and functions) also have 'length' - // The extra typeof function check is to prevent crashes - // in Safari 2 (See: #3039) - // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 - var type = jQuery.type( array ); - - if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) { - push.call( ret, array ); - } else { - jQuery.merge( ret, array ); - } - } - - return ret; - }, - - inArray: function( elem, array ) { - - if ( indexOf ) { - return indexOf.call( array, elem ); - } - - for ( var i = 0, length = array.length; i < length; i++ ) { - if ( array[ i ] === elem ) { - return i; - } - } - - return -1; - }, - - merge: function( first, second ) { - var i = first.length, - j = 0; - - if ( typeof second.length === "number" ) { - for ( var l = second.length; j < l; j++ ) { - first[ i++ ] = second[ j ]; - } - - } else { - while ( second[j] !== undefined ) { - first[ i++ ] = second[ j++ ]; - } - } - - first.length = i; - - return first; - }, - - grep: function( elems, callback, inv ) { - var ret = [], retVal; - inv = !!inv; - - // Go through the array, only saving the items - // that pass the validator function - for ( var i = 0, length = elems.length; i < length; i++ ) { - retVal = !!callback( elems[ i ], i ); - if ( inv !== retVal ) { - ret.push( elems[ i ] ); - } - } - - return ret; - }, - - // arg is for internal usage only - map: function( elems, callback, arg ) { - var value, key, ret = [], - i = 0, - length = elems.length, - // jquery objects are treated as arrays - isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ; - - // Go through the array, translating each of the items to their - if ( isArray ) { - for ( ; i < length; i++ ) { - value = callback( elems[ i ], i, arg ); - - if ( value != null ) { - ret[ ret.length ] = value; - } - } - - // Go through every key on the object, - } else { - for ( key in elems ) { - value = callback( elems[ key ], key, arg ); - - if ( value != null ) { - ret[ ret.length ] = value; - } - } - } - - // Flatten any nested arrays - return ret.concat.apply( [], ret ); - }, - - // A global GUID counter for objects - guid: 1, - - // Bind a function to a context, optionally partially applying any - // arguments. - proxy: function( fn, context ) { - if ( typeof context === "string" ) { - var tmp = fn[ context ]; - context = fn; - fn = tmp; - } - - // Quick check to determine if target is callable, in the spec - // this throws a TypeError, but we will just return undefined. - if ( !jQuery.isFunction( fn ) ) { - return undefined; - } - - // Simulated bind - var args = slice.call( arguments, 2 ), - proxy = function() { - return fn.apply( context, args.concat( slice.call( arguments ) ) ); - }; - - // Set the guid of unique handler to the same of original handler, so it can be removed - proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; - - return proxy; - }, - - // Mutifunctional method to get and set values to a collection - // The value/s can be optionally by executed if its a function - access: function( elems, key, value, exec, fn, pass ) { - var length = elems.length; - - // Setting many attributes - if ( typeof key === "object" ) { - for ( var k in key ) { - jQuery.access( elems, k, key[k], exec, fn, value ); - } - return elems; - } - - // Setting one attribute - if ( value !== undefined ) { - // Optionally, function values get executed if exec is true - exec = !pass && exec && jQuery.isFunction(value); - - for ( var i = 0; i < length; i++ ) { - fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); - } - - return elems; - } - - // Getting an attribute - return length ? fn( elems[0], key ) : undefined; - }, - - now: function() { - return (new Date()).getTime(); - }, - - // Use of jQuery.browser is frowned upon. - // More details: http://docs.jquery.com/Utilities/jQuery.browser - uaMatch: function( ua ) { - ua = ua.toLowerCase(); - - var match = rwebkit.exec( ua ) || - ropera.exec( ua ) || - rmsie.exec( ua ) || - ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) || - []; - - return { browser: match[1] || "", version: match[2] || "0" }; - }, - - sub: function() { - function jQuerySub( selector, context ) { - return new jQuerySub.fn.init( selector, context ); - } - jQuery.extend( true, jQuerySub, this ); - jQuerySub.superclass = this; - jQuerySub.fn = jQuerySub.prototype = this(); - jQuerySub.fn.constructor = jQuerySub; - jQuerySub.sub = this.sub; - jQuerySub.fn.init = function init( selector, context ) { - if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { - context = jQuerySub( context ); - } - - return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); - }; - jQuerySub.fn.init.prototype = jQuerySub.fn; - var rootjQuerySub = jQuerySub(document); - return jQuerySub; - }, - - browser: {} -}); - -// Populate the class2type map -jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { - class2type[ "[object " + name + "]" ] = name.toLowerCase(); -}); - -browserMatch = jQuery.uaMatch( userAgent ); -if ( browserMatch.browser ) { - jQuery.browser[ browserMatch.browser ] = true; - jQuery.browser.version = browserMatch.version; -} - -// Deprecated, use jQuery.browser.webkit instead -if ( jQuery.browser.webkit ) { - jQuery.browser.safari = true; -} - -// IE doesn't match non-breaking spaces with \s -if ( rnotwhite.test( "\xA0" ) ) { - trimLeft = /^[\s\xA0]+/; - trimRight = /[\s\xA0]+$/; -} - -// All jQuery objects should point back to these -rootjQuery = jQuery(document); - -// Cleanup functions for the document ready method -if ( document.addEventListener ) { - DOMContentLoaded = function() { - document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); - jQuery.ready(); - }; - -} else if ( document.attachEvent ) { - DOMContentLoaded = function() { - // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). - if ( document.readyState === "complete" ) { - document.detachEvent( "onreadystatechange", DOMContentLoaded ); - jQuery.ready(); - } - }; -} - -// The DOM ready check for Internet Explorer -function doScrollCheck() { - if ( jQuery.isReady ) { - return; - } - - try { - // If IE is used, use the trick by Diego Perini - // http://javascript.nwbox.com/IEContentLoaded/ - document.documentElement.doScroll("left"); - } catch(e) { - setTimeout( doScrollCheck, 1 ); - return; - } - - // and execute any waiting functions - jQuery.ready(); -} - -// Expose jQuery to the global object -return jQuery; - -})(); - - -var // Promise methods - promiseMethods = "done fail isResolved isRejected promise then always pipe".split( " " ), - // Static reference to slice - sliceDeferred = [].slice; - -jQuery.extend({ - // Create a simple deferred (one callbacks list) - _Deferred: function() { - var // callbacks list - callbacks = [], - // stored [ context , args ] - fired, - // to avoid firing when already doing so - firing, - // flag to know if the deferred has been cancelled - cancelled, - // the deferred itself - deferred = { - - // done( f1, f2, ...) - done: function() { - if ( !cancelled ) { - var args = arguments, - i, - length, - elem, - type, - _fired; - if ( fired ) { - _fired = fired; - fired = 0; - } - for ( i = 0, length = args.length; i < length; i++ ) { - elem = args[ i ]; - type = jQuery.type( elem ); - if ( type === "array" ) { - deferred.done.apply( deferred, elem ); - } else if ( type === "function" ) { - callbacks.push( elem ); - } - } - if ( _fired ) { - deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] ); - } - } - return this; - }, - - // resolve with given context and args - resolveWith: function( context, args ) { - if ( !cancelled && !fired && !firing ) { - // make sure args are available (#8421) - args = args || []; - firing = 1; - try { - while( callbacks[ 0 ] ) { - callbacks.shift().apply( context, args ); - } - } - finally { - fired = [ context, args ]; - firing = 0; - } - } - return this; - }, - - // resolve with this as context and given arguments - resolve: function() { - deferred.resolveWith( this, arguments ); - return this; - }, - - // Has this deferred been resolved? - isResolved: function() { - return !!( firing || fired ); - }, - - // Cancel - cancel: function() { - cancelled = 1; - callbacks = []; - return this; - } - }; - - return deferred; - }, - - // Full fledged deferred (two callbacks list) - Deferred: function( func ) { - var deferred = jQuery._Deferred(), - failDeferred = jQuery._Deferred(), - promise; - // Add errorDeferred methods, then and promise - jQuery.extend( deferred, { - then: function( doneCallbacks, failCallbacks ) { - deferred.done( doneCallbacks ).fail( failCallbacks ); - return this; - }, - always: function() { - return deferred.done.apply( deferred, arguments ).fail.apply( this, arguments ); - }, - fail: failDeferred.done, - rejectWith: failDeferred.resolveWith, - reject: failDeferred.resolve, - isRejected: failDeferred.isResolved, - pipe: function( fnDone, fnFail ) { - return jQuery.Deferred(function( newDefer ) { - jQuery.each( { - done: [ fnDone, "resolve" ], - fail: [ fnFail, "reject" ] - }, function( handler, data ) { - var fn = data[ 0 ], - action = data[ 1 ], - returned; - if ( jQuery.isFunction( fn ) ) { - deferred[ handler ](function() { - returned = fn.apply( this, arguments ); - if ( returned && jQuery.isFunction( returned.promise ) ) { - returned.promise().then( newDefer.resolve, newDefer.reject ); - } else { - newDefer[ action ]( returned ); - } - }); - } else { - deferred[ handler ]( newDefer[ action ] ); - } - }); - }).promise(); - }, - // Get a promise for this deferred - // If obj is provided, the promise aspect is added to the object - promise: function( obj ) { - if ( obj == null ) { - if ( promise ) { - return promise; - } - promise = obj = {}; - } - var i = promiseMethods.length; - while( i-- ) { - obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ]; - } - return obj; - } - }); - // Make sure only one callback list will be used - deferred.done( failDeferred.cancel ).fail( deferred.cancel ); - // Unexpose cancel - delete deferred.cancel; - // Call given func if any - if ( func ) { - func.call( deferred, deferred ); - } - return deferred; - }, - - // Deferred helper - when: function( firstParam ) { - var args = arguments, - i = 0, - length = args.length, - count = length, - deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ? - firstParam : - jQuery.Deferred(); - function resolveFunc( i ) { - return function( value ) { - args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; - if ( !( --count ) ) { - // Strange bug in FF4: - // Values changed onto the arguments object sometimes end up as undefined values - // outside the $.when method. Cloning the object into a fresh array solves the issue - deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) ); - } - }; - } - if ( length > 1 ) { - for( ; i < length; i++ ) { - if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) { - args[ i ].promise().then( resolveFunc(i), deferred.reject ); - } else { - --count; - } - } - if ( !count ) { - deferred.resolveWith( deferred, args ); - } - } else if ( deferred !== firstParam ) { - deferred.resolveWith( deferred, length ? [ firstParam ] : [] ); - } - return deferred.promise(); - } -}); - - - -jQuery.support = (function() { - - var div = document.createElement( "div" ), - documentElement = document.documentElement, - all, - a, - select, - opt, - input, - marginDiv, - support, - fragment, - body, - bodyStyle, - tds, - events, - eventName, - i, - isSupported; - - // Preliminary tests - div.setAttribute("className", "t"); - div.innerHTML = "
a"; - - all = div.getElementsByTagName( "*" ); - a = div.getElementsByTagName( "a" )[ 0 ]; - - // Can't get basic test support - if ( !all || !all.length || !a ) { - return {}; - } - - // First batch of supports tests - select = document.createElement( "select" ); - opt = select.appendChild( document.createElement("option") ); - input = div.getElementsByTagName( "input" )[ 0 ]; - - support = { - // IE strips leading whitespace when .innerHTML is used - leadingWhitespace: ( div.firstChild.nodeType === 3 ), - - // Make sure that tbody elements aren't automatically inserted - // IE will insert them into empty tables - tbody: !div.getElementsByTagName( "tbody" ).length, - - // Make sure that link elements get serialized correctly by innerHTML - // This requires a wrapper element in IE - htmlSerialize: !!div.getElementsByTagName( "link" ).length, - - // Get the style information from getAttribute - // (IE uses .cssText instead) - style: /top/.test( a.getAttribute("style") ), - - // Make sure that URLs aren't manipulated - // (IE normalizes it by default) - hrefNormalized: ( a.getAttribute( "href" ) === "/a" ), - - // Make sure that element opacity exists - // (IE uses filter instead) - // Use a regex to work around a WebKit issue. See #5145 - opacity: /^0.55$/.test( a.style.opacity ), - - // Verify style float existence - // (IE uses styleFloat instead of cssFloat) - cssFloat: !!a.style.cssFloat, - - // Make sure that if no value is specified for a checkbox - // that it defaults to "on". - // (WebKit defaults to "" instead) - checkOn: ( input.value === "on" ), - - // Make sure that a selected-by-default option has a working selected property. - // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) - optSelected: opt.selected, - - // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) - getSetAttribute: div.className !== "t", - - // Will be defined later - submitBubbles: true, - changeBubbles: true, - focusinBubbles: false, - deleteExpando: true, - noCloneEvent: true, - inlineBlockNeedsLayout: false, - shrinkWrapBlocks: false, - reliableMarginRight: true - }; - - // Make sure checked status is properly cloned - input.checked = true; - support.noCloneChecked = input.cloneNode( true ).checked; - - // Make sure that the options inside disabled selects aren't marked as disabled - // (WebKit marks them as disabled) - select.disabled = true; - support.optDisabled = !opt.disabled; - - // Test to see if it's possible to delete an expando from an element - // Fails in Internet Explorer - try { - delete div.test; - } catch( e ) { - support.deleteExpando = false; - } - - if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { - div.attachEvent( "onclick", function click() { - // Cloning a node shouldn't copy over any - // bound event handlers (IE does this) - support.noCloneEvent = false; - div.detachEvent( "onclick", click ); - }); - div.cloneNode( true ).fireEvent( "onclick" ); - } - - // Check if a radio maintains it's value - // after being appended to the DOM - input = document.createElement("input"); - input.value = "t"; - input.setAttribute("type", "radio"); - support.radioValue = input.value === "t"; - - input.setAttribute("checked", "checked"); - div.appendChild( input ); - fragment = document.createDocumentFragment(); - fragment.appendChild( div.firstChild ); - - // WebKit doesn't clone checked state correctly in fragments - support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; - - div.innerHTML = ""; - - // Figure out if the W3C box model works as expected - div.style.width = div.style.paddingLeft = "1px"; - - // We use our own, invisible, body - body = document.createElement( "body" ); - bodyStyle = { - visibility: "hidden", - width: 0, - height: 0, - border: 0, - margin: 0, - // Set background to avoid IE crashes when removing (#9028) - background: "none" - }; - for ( i in bodyStyle ) { - body.style[ i ] = bodyStyle[ i ]; - } - body.appendChild( div ); - documentElement.insertBefore( body, documentElement.firstChild ); - - // Check if a disconnected checkbox will retain its checked - // value of true after appended to the DOM (IE6/7) - support.appendChecked = input.checked; - - support.boxModel = div.offsetWidth === 2; - - if ( "zoom" in div.style ) { - // Check if natively block-level elements act like inline-block - // elements when setting their display to 'inline' and giving - // them layout - // (IE < 8 does this) - div.style.display = "inline"; - div.style.zoom = 1; - support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 ); - - // Check if elements with layout shrink-wrap their children - // (IE 6 does this) - div.style.display = ""; - div.innerHTML = "
"; - support.shrinkWrapBlocks = ( div.offsetWidth !== 2 ); - } - - div.innerHTML = "
t
"; - tds = div.getElementsByTagName( "td" ); - - // Check if table cells still have offsetWidth/Height when they are set - // to display:none and there are still other visible table cells in a - // table row; if so, offsetWidth/Height are not reliable for use when - // determining if an element has been hidden directly using - // display:none (it is still safe to use offsets if a parent element is - // hidden; don safety goggles and see bug #4512 for more information). - // (only IE 8 fails this test) - isSupported = ( tds[ 0 ].offsetHeight === 0 ); - - tds[ 0 ].style.display = ""; - tds[ 1 ].style.display = "none"; - - // Check if empty table cells still have offsetWidth/Height - // (IE < 8 fail this test) - support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); - div.innerHTML = ""; - - // Check if div with explicit width and no margin-right incorrectly - // gets computed margin-right based on width of container. For more - // info see bug #3333 - // Fails in WebKit before Feb 2011 nightlies - // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right - if ( document.defaultView && document.defaultView.getComputedStyle ) { - marginDiv = document.createElement( "div" ); - marginDiv.style.width = "0"; - marginDiv.style.marginRight = "0"; - div.appendChild( marginDiv ); - support.reliableMarginRight = - ( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0; - } - - // Remove the body element we added - body.innerHTML = ""; - documentElement.removeChild( body ); - - // Technique from Juriy Zaytsev - // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/ - // We only care about the case where non-standard event systems - // are used, namely in IE. Short-circuiting here helps us to - // avoid an eval call (in setAttribute) which can cause CSP - // to go haywire. See: https://developer.mozilla.org/en/Security/CSP - if ( div.attachEvent ) { - for( i in { - submit: 1, - change: 1, - focusin: 1 - } ) { - eventName = "on" + i; - isSupported = ( eventName in div ); - if ( !isSupported ) { - div.setAttribute( eventName, "return;" ); - isSupported = ( typeof div[ eventName ] === "function" ); - } - support[ i + "Bubbles" ] = isSupported; - } - } - - return support; -})(); - -// Keep track of boxModel -jQuery.boxModel = jQuery.support.boxModel; - - - - -var rbrace = /^(?:\{.*\}|\[.*\])$/, - rmultiDash = /([a-z])([A-Z])/g; - -jQuery.extend({ - cache: {}, - - // Please use with caution - uuid: 0, - - // Unique for each copy of jQuery on the page - // Non-digits removed to match rinlinejQuery - expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), - - // The following elements throw uncatchable exceptions if you - // attempt to add expando properties to them. - noData: { - "embed": true, - // Ban all objects except for Flash (which handle expandos) - "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", - "applet": true - }, - - hasData: function( elem ) { - elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; - - return !!elem && !isEmptyDataObject( elem ); - }, - - data: function( elem, name, data, pvt /* Internal Use Only */ ) { - if ( !jQuery.acceptData( elem ) ) { - return; - } - - var internalKey = jQuery.expando, getByName = typeof name === "string", thisCache, - - // We have to handle DOM nodes and JS objects differently because IE6-7 - // can't GC object references properly across the DOM-JS boundary - isNode = elem.nodeType, - - // Only DOM nodes need the global jQuery cache; JS object data is - // attached directly to the object so GC can occur automatically - cache = isNode ? jQuery.cache : elem, - - // Only defining an ID for JS objects if its cache already exists allows - // the code to shortcut on the same path as a DOM node with no cache - id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando; - - // Avoid doing any more work than we need to when trying to get data on an - // object that has no data at all - if ( (!id || (pvt && id && !cache[ id ][ internalKey ])) && getByName && data === undefined ) { - return; - } - - if ( !id ) { - // Only DOM nodes need a new unique ID for each element since their data - // ends up in the global cache - if ( isNode ) { - elem[ jQuery.expando ] = id = ++jQuery.uuid; - } else { - id = jQuery.expando; - } - } - - if ( !cache[ id ] ) { - cache[ id ] = {}; - - // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery - // metadata on plain JS objects when the object is serialized using - // JSON.stringify - if ( !isNode ) { - cache[ id ].toJSON = jQuery.noop; - } - } - - // An object can be passed to jQuery.data instead of a key/value pair; this gets - // shallow copied over onto the existing cache - if ( typeof name === "object" || typeof name === "function" ) { - if ( pvt ) { - cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name); - } else { - cache[ id ] = jQuery.extend(cache[ id ], name); - } - } - - thisCache = cache[ id ]; - - // Internal jQuery data is stored in a separate object inside the object's data - // cache in order to avoid key collisions between internal data and user-defined - // data - if ( pvt ) { - if ( !thisCache[ internalKey ] ) { - thisCache[ internalKey ] = {}; - } - - thisCache = thisCache[ internalKey ]; - } - - if ( data !== undefined ) { - thisCache[ jQuery.camelCase( name ) ] = data; - } - - // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should - // not attempt to inspect the internal events object using jQuery.data, as this - // internal data object is undocumented and subject to change. - if ( name === "events" && !thisCache[name] ) { - return thisCache[ internalKey ] && thisCache[ internalKey ].events; - } - - return getByName ? thisCache[ jQuery.camelCase( name ) ] : thisCache; - }, - - removeData: function( elem, name, pvt /* Internal Use Only */ ) { - if ( !jQuery.acceptData( elem ) ) { - return; - } - - var internalKey = jQuery.expando, isNode = elem.nodeType, - - // See jQuery.data for more information - cache = isNode ? jQuery.cache : elem, - - // See jQuery.data for more information - id = isNode ? elem[ jQuery.expando ] : jQuery.expando; - - // If there is already no cache entry for this object, there is no - // purpose in continuing - if ( !cache[ id ] ) { - return; - } - - if ( name ) { - var thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ]; - - if ( thisCache ) { - delete thisCache[ name ]; - - // If there is no data left in the cache, we want to continue - // and let the cache object itself get destroyed - if ( !isEmptyDataObject(thisCache) ) { - return; - } - } - } - - // See jQuery.data for more information - if ( pvt ) { - delete cache[ id ][ internalKey ]; - - // Don't destroy the parent cache unless the internal data object - // had been the only thing left in it - if ( !isEmptyDataObject(cache[ id ]) ) { - return; - } - } - - var internalCache = cache[ id ][ internalKey ]; - - // Browsers that fail expando deletion also refuse to delete expandos on - // the window, but it will allow it on all other JS objects; other browsers - // don't care - if ( jQuery.support.deleteExpando || cache != window ) { - delete cache[ id ]; - } else { - cache[ id ] = null; - } - - // We destroyed the entire user cache at once because it's faster than - // iterating through each key, but we need to continue to persist internal - // data if it existed - if ( internalCache ) { - cache[ id ] = {}; - // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery - // metadata on plain JS objects when the object is serialized using - // JSON.stringify - if ( !isNode ) { - cache[ id ].toJSON = jQuery.noop; - } - - cache[ id ][ internalKey ] = internalCache; - - // Otherwise, we need to eliminate the expando on the node to avoid - // false lookups in the cache for entries that no longer exist - } else if ( isNode ) { - // IE does not allow us to delete expando properties from nodes, - // nor does it have a removeAttribute function on Document nodes; - // we must handle all of these cases - if ( jQuery.support.deleteExpando ) { - delete elem[ jQuery.expando ]; - } else if ( elem.removeAttribute ) { - elem.removeAttribute( jQuery.expando ); - } else { - elem[ jQuery.expando ] = null; - } - } - }, - - // For internal use only. - _data: function( elem, name, data ) { - return jQuery.data( elem, name, data, true ); - }, - - // A method for determining if a DOM node can handle the data expando - acceptData: function( elem ) { - if ( elem.nodeName ) { - var match = jQuery.noData[ elem.nodeName.toLowerCase() ]; - - if ( match ) { - return !(match === true || elem.getAttribute("classid") !== match); - } - } - - return true; - } -}); - -jQuery.fn.extend({ - data: function( key, value ) { - var data = null; - - if ( typeof key === "undefined" ) { - if ( this.length ) { - data = jQuery.data( this[0] ); - - if ( this[0].nodeType === 1 ) { - var attr = this[0].attributes, name; - for ( var i = 0, l = attr.length; i < l; i++ ) { - name = attr[i].name; - - if ( name.indexOf( "data-" ) === 0 ) { - name = jQuery.camelCase( name.substring(5) ); - - dataAttr( this[0], name, data[ name ] ); - } - } - } - } - - return data; - - } else if ( typeof key === "object" ) { - return this.each(function() { - jQuery.data( this, key ); - }); - } - - var parts = key.split("."); - parts[1] = parts[1] ? "." + parts[1] : ""; - - if ( value === undefined ) { - data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); - - // Try to fetch any internally stored data first - if ( data === undefined && this.length ) { - data = jQuery.data( this[0], key ); - data = dataAttr( this[0], key, data ); - } - - return data === undefined && parts[1] ? - this.data( parts[0] ) : - data; - - } else { - return this.each(function() { - var $this = jQuery( this ), - args = [ parts[0], value ]; - - $this.triggerHandler( "setData" + parts[1] + "!", args ); - jQuery.data( this, key, value ); - $this.triggerHandler( "changeData" + parts[1] + "!", args ); - }); - } - }, - - removeData: function( key ) { - return this.each(function() { - jQuery.removeData( this, key ); - }); - } -}); - -function dataAttr( elem, key, data ) { - // If nothing was found internally, try to fetch any - // data from the HTML5 data-* attribute - if ( data === undefined && elem.nodeType === 1 ) { - var name = "data-" + key.replace( rmultiDash, "$1-$2" ).toLowerCase(); - - data = elem.getAttribute( name ); - - if ( typeof data === "string" ) { - try { - data = data === "true" ? true : - data === "false" ? false : - data === "null" ? null : - !jQuery.isNaN( data ) ? parseFloat( data ) : - rbrace.test( data ) ? jQuery.parseJSON( data ) : - data; - } catch( e ) {} - - // Make sure we set the data so it isn't changed later - jQuery.data( elem, key, data ); - - } else { - data = undefined; - } - } - - return data; -} - -// TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON -// property to be considered empty objects; this property always exists in -// order to make sure JSON.stringify does not expose internal metadata -function isEmptyDataObject( obj ) { - for ( var name in obj ) { - if ( name !== "toJSON" ) { - return false; - } - } - - return true; -} - - - - -function handleQueueMarkDefer( elem, type, src ) { - var deferDataKey = type + "defer", - queueDataKey = type + "queue", - markDataKey = type + "mark", - defer = jQuery.data( elem, deferDataKey, undefined, true ); - if ( defer && - ( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) && - ( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) { - // Give room for hard-coded callbacks to fire first - // and eventually mark/queue something else on the element - setTimeout( function() { - if ( !jQuery.data( elem, queueDataKey, undefined, true ) && - !jQuery.data( elem, markDataKey, undefined, true ) ) { - jQuery.removeData( elem, deferDataKey, true ); - defer.resolve(); - } - }, 0 ); - } -} - -jQuery.extend({ - - _mark: function( elem, type ) { - if ( elem ) { - type = (type || "fx") + "mark"; - jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true ); - } - }, - - _unmark: function( force, elem, type ) { - if ( force !== true ) { - type = elem; - elem = force; - force = false; - } - if ( elem ) { - type = type || "fx"; - var key = type + "mark", - count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 ); - if ( count ) { - jQuery.data( elem, key, count, true ); - } else { - jQuery.removeData( elem, key, true ); - handleQueueMarkDefer( elem, type, "mark" ); - } - } - }, - - queue: function( elem, type, data ) { - if ( elem ) { - type = (type || "fx") + "queue"; - var q = jQuery.data( elem, type, undefined, true ); - // Speed up dequeue by getting out quickly if this is just a lookup - if ( data ) { - if ( !q || jQuery.isArray(data) ) { - q = jQuery.data( elem, type, jQuery.makeArray(data), true ); - } else { - q.push( data ); - } - } - return q || []; - } - }, - - dequeue: function( elem, type ) { - type = type || "fx"; - - var queue = jQuery.queue( elem, type ), - fn = queue.shift(), - defer; - - // If the fx queue is dequeued, always remove the progress sentinel - if ( fn === "inprogress" ) { - fn = queue.shift(); - } - - if ( fn ) { - // Add a progress sentinel to prevent the fx queue from being - // automatically dequeued - if ( type === "fx" ) { - queue.unshift("inprogress"); - } - - fn.call(elem, function() { - jQuery.dequeue(elem, type); - }); - } - - if ( !queue.length ) { - jQuery.removeData( elem, type + "queue", true ); - handleQueueMarkDefer( elem, type, "queue" ); - } - } -}); - -jQuery.fn.extend({ - queue: function( type, data ) { - if ( typeof type !== "string" ) { - data = type; - type = "fx"; - } - - if ( data === undefined ) { - return jQuery.queue( this[0], type ); - } - return this.each(function() { - var queue = jQuery.queue( this, type, data ); - - if ( type === "fx" && queue[0] !== "inprogress" ) { - jQuery.dequeue( this, type ); - } - }); - }, - dequeue: function( type ) { - return this.each(function() { - jQuery.dequeue( this, type ); - }); - }, - // Based off of the plugin by Clint Helfers, with permission. - // http://blindsignals.com/index.php/2009/07/jquery-delay/ - delay: function( time, type ) { - time = jQuery.fx ? jQuery.fx.speeds[time] || time : time; - type = type || "fx"; - - return this.queue( type, function() { - var elem = this; - setTimeout(function() { - jQuery.dequeue( elem, type ); - }, time ); - }); - }, - clearQueue: function( type ) { - return this.queue( type || "fx", [] ); - }, - // Get a promise resolved when queues of a certain type - // are emptied (fx is the type by default) - promise: function( type, object ) { - if ( typeof type !== "string" ) { - object = type; - type = undefined; - } - type = type || "fx"; - var defer = jQuery.Deferred(), - elements = this, - i = elements.length, - count = 1, - deferDataKey = type + "defer", - queueDataKey = type + "queue", - markDataKey = type + "mark", - tmp; - function resolve() { - if ( !( --count ) ) { - defer.resolveWith( elements, [ elements ] ); - } - } - while( i-- ) { - if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) || - ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) || - jQuery.data( elements[ i ], markDataKey, undefined, true ) ) && - jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) { - count++; - tmp.done( resolve ); - } - } - resolve(); - return defer.promise(); - } -}); - - - - -var rclass = /[\n\t\r]/g, - rspace = /\s+/, - rreturn = /\r/g, - rtype = /^(?:button|input)$/i, - rfocusable = /^(?:button|input|object|select|textarea)$/i, - rclickable = /^a(?:rea)?$/i, - rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, - rinvalidChar = /\:/, - formHook, boolHook; - -jQuery.fn.extend({ - attr: function( name, value ) { - return jQuery.access( this, name, value, true, jQuery.attr ); - }, - - removeAttr: function( name ) { - return this.each(function() { - jQuery.removeAttr( this, name ); - }); - }, - - prop: function( name, value ) { - return jQuery.access( this, name, value, true, jQuery.prop ); - }, - - removeProp: function( name ) { - name = jQuery.propFix[ name ] || name; - return this.each(function() { - // try/catch handles cases where IE balks (such as removing a property on window) - try { - this[ name ] = undefined; - delete this[ name ]; - } catch( e ) {} - }); - }, - - addClass: function( value ) { - if ( jQuery.isFunction( value ) ) { - return this.each(function(i) { - var self = jQuery(this); - self.addClass( value.call(this, i, self.attr("class") || "") ); - }); - } - - if ( value && typeof value === "string" ) { - var classNames = (value || "").split( rspace ); - - for ( var i = 0, l = this.length; i < l; i++ ) { - var elem = this[i]; - - if ( elem.nodeType === 1 ) { - if ( !elem.className ) { - elem.className = value; - - } else { - var className = " " + elem.className + " ", - setClass = elem.className; - - for ( var c = 0, cl = classNames.length; c < cl; c++ ) { - if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) { - setClass += " " + classNames[c]; - } - } - elem.className = jQuery.trim( setClass ); - } - } - } - } - - return this; - }, - - removeClass: function( value ) { - if ( jQuery.isFunction(value) ) { - return this.each(function(i) { - var self = jQuery(this); - self.removeClass( value.call(this, i, self.attr("class")) ); - }); - } - - if ( (value && typeof value === "string") || value === undefined ) { - var classNames = (value || "").split( rspace ); - - for ( var i = 0, l = this.length; i < l; i++ ) { - var elem = this[i]; - - if ( elem.nodeType === 1 && elem.className ) { - if ( value ) { - var className = (" " + elem.className + " ").replace(rclass, " "); - for ( var c = 0, cl = classNames.length; c < cl; c++ ) { - className = className.replace(" " + classNames[c] + " ", " "); - } - elem.className = jQuery.trim( className ); - - } else { - elem.className = ""; - } - } - } - } - - return this; - }, - - toggleClass: function( value, stateVal ) { - var type = typeof value, - isBool = typeof stateVal === "boolean"; - - if ( jQuery.isFunction( value ) ) { - return this.each(function(i) { - var self = jQuery(this); - self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal ); - }); - } - - return this.each(function() { - if ( type === "string" ) { - // toggle individual class names - var className, - i = 0, - self = jQuery( this ), - state = stateVal, - classNames = value.split( rspace ); - - while ( (className = classNames[ i++ ]) ) { - // check each className given, space seperated list - state = isBool ? state : !self.hasClass( className ); - self[ state ? "addClass" : "removeClass" ]( className ); - } - - } else if ( type === "undefined" || type === "boolean" ) { - if ( this.className ) { - // store className if set - jQuery._data( this, "__className__", this.className ); - } - - // toggle whole className - this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; - } - }); - }, - - hasClass: function( selector ) { - var className = " " + selector + " "; - for ( var i = 0, l = this.length; i < l; i++ ) { - if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { - return true; - } - } - - return false; - }, - - val: function( value ) { - var hooks, ret, - elem = this[0]; - - if ( !arguments.length ) { - if ( elem ) { - hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ]; - - if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { - return ret; - } - - return (elem.value || "").replace(rreturn, ""); - } - - return undefined; - } - - var isFunction = jQuery.isFunction( value ); - - return this.each(function( i ) { - var self = jQuery(this), val; - - if ( this.nodeType !== 1 ) { - return; - } - - if ( isFunction ) { - val = value.call( this, i, self.val() ); - } else { - val = value; - } - - // Treat null/undefined as ""; convert numbers to string - if ( val == null ) { - val = ""; - } else if ( typeof val === "number" ) { - val += ""; - } else if ( jQuery.isArray( val ) ) { - val = jQuery.map(val, function ( value ) { - return value == null ? "" : value + ""; - }); - } - - hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ]; - - // If set returns undefined, fall back to normal setting - if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { - this.value = val; - } - }); - } -}); - -jQuery.extend({ - valHooks: { - option: { - get: function( elem ) { - // attributes.value is undefined in Blackberry 4.7 but - // uses .value. See #6932 - var val = elem.attributes.value; - return !val || val.specified ? elem.value : elem.text; - } - }, - select: { - get: function( elem ) { - var value, - index = elem.selectedIndex, - values = [], - options = elem.options, - one = elem.type === "select-one"; - - // Nothing was selected - if ( index < 0 ) { - return null; - } - - // Loop through all the selected options - for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { - var option = options[ i ]; - - // Don't return options that are disabled or in a disabled optgroup - if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && - (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { - - // Get the specific value for the option - value = jQuery( option ).val(); - - // We don't need an array for one selects - if ( one ) { - return value; - } - - // Multi-Selects return an array - values.push( value ); - } - } - - // Fixes Bug #2551 -- select.val() broken in IE after form.reset() - if ( one && !values.length && options.length ) { - return jQuery( options[ index ] ).val(); - } - - return values; - }, - - set: function( elem, value ) { - var values = jQuery.makeArray( value ); - - jQuery(elem).find("option").each(function() { - this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; - }); - - if ( !values.length ) { - elem.selectedIndex = -1; - } - return values; - } - } - }, - - attrFn: { - val: true, - css: true, - html: true, - text: true, - data: true, - width: true, - height: true, - offset: true - }, - - attrFix: { - // Always normalize to ensure hook usage - tabindex: "tabIndex" - }, - - attr: function( elem, name, value, pass ) { - var nType = elem.nodeType; - - // don't get/set attributes on text, comment and attribute nodes - if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { - return undefined; - } - - if ( pass && name in jQuery.attrFn ) { - return jQuery( elem )[ name ]( value ); - } - - // Fallback to prop when attributes are not supported - if ( !("getAttribute" in elem) ) { - return jQuery.prop( elem, name, value ); - } - - var ret, hooks, - notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); - - // Normalize the name if needed - name = notxml && jQuery.attrFix[ name ] || name; - - hooks = jQuery.attrHooks[ name ]; - - if ( !hooks ) { - // Use boolHook for boolean attributes - if ( rboolean.test( name ) && - (typeof value === "boolean" || value === undefined || value.toLowerCase() === name.toLowerCase()) ) { - - hooks = boolHook; - - // Use formHook for forms and if the name contains certain characters - } else if ( formHook && (jQuery.nodeName( elem, "form" ) || rinvalidChar.test( name )) ) { - hooks = formHook; - } - } - - if ( value !== undefined ) { - - if ( value === null ) { - jQuery.removeAttr( elem, name ); - return undefined; - - } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { - return ret; - - } else { - elem.setAttribute( name, "" + value ); - return value; - } - - } else if ( hooks && "get" in hooks && notxml ) { - return hooks.get( elem, name ); - - } else { - - ret = elem.getAttribute( name ); - - // Non-existent attributes return null, we normalize to undefined - return ret === null ? - undefined : - ret; - } - }, - - removeAttr: function( elem, name ) { - var propName; - if ( elem.nodeType === 1 ) { - name = jQuery.attrFix[ name ] || name; - - if ( jQuery.support.getSetAttribute ) { - // Use removeAttribute in browsers that support it - elem.removeAttribute( name ); - } else { - jQuery.attr( elem, name, "" ); - elem.removeAttributeNode( elem.getAttributeNode( name ) ); - } - - // Set corresponding property to false for boolean attributes - if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) { - elem[ propName ] = false; - } - } - }, - - attrHooks: { - type: { - set: function( elem, value ) { - // We can't allow the type property to be changed (since it causes problems in IE) - if ( rtype.test( elem.nodeName ) && elem.parentNode ) { - jQuery.error( "type property can't be changed" ); - } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { - // Setting the type on a radio button after the value resets the value in IE6-9 - // Reset value to it's default in case type is set after value - // This is for element creation - var val = elem.value; - elem.setAttribute( "type", value ); - if ( val ) { - elem.value = val; - } - return value; - } - } - }, - tabIndex: { - get: function( elem ) { - // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set - // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ - var attributeNode = elem.getAttributeNode("tabIndex"); - - return attributeNode && attributeNode.specified ? - parseInt( attributeNode.value, 10 ) : - rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? - 0 : - undefined; - } - } - }, - - propFix: { - tabindex: "tabIndex", - readonly: "readOnly", - "for": "htmlFor", - "class": "className", - maxlength: "maxLength", - cellspacing: "cellSpacing", - cellpadding: "cellPadding", - rowspan: "rowSpan", - colspan: "colSpan", - usemap: "useMap", - frameborder: "frameBorder", - contenteditable: "contentEditable" - }, - - prop: function( elem, name, value ) { - var nType = elem.nodeType; - - // don't get/set properties on text, comment and attribute nodes - if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { - return undefined; - } - - var ret, hooks, - notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); - - // Try to normalize/fix the name - name = notxml && jQuery.propFix[ name ] || name; - - hooks = jQuery.propHooks[ name ]; - - if ( value !== undefined ) { - if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { - return ret; - - } else { - return (elem[ name ] = value); - } - - } else { - if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== undefined ) { - return ret; - - } else { - return elem[ name ]; - } - } - }, - - propHooks: {} -}); - -// Hook for boolean attributes -boolHook = { - get: function( elem, name ) { - // Align boolean attributes with corresponding properties - return elem[ jQuery.propFix[ name ] || name ] ? - name.toLowerCase() : - undefined; - }, - set: function( elem, value, name ) { - var propName; - if ( value === false ) { - // Remove boolean attributes when set to false - jQuery.removeAttr( elem, name ); - } else { - // value is true since we know at this point it's type boolean and not false - // Set boolean attributes to the same name and set the DOM property - propName = jQuery.propFix[ name ] || name; - if ( propName in elem ) { - // Only set the IDL specifically if it already exists on the element - elem[ propName ] = value; - } - - elem.setAttribute( name, name.toLowerCase() ); - } - return name; - } -}; - -// Use the value property for back compat -// Use the formHook for button elements in IE6/7 (#1954) -jQuery.attrHooks.value = { - get: function( elem, name ) { - if ( formHook && jQuery.nodeName( elem, "button" ) ) { - return formHook.get( elem, name ); - } - return elem.value; - }, - set: function( elem, value, name ) { - if ( formHook && jQuery.nodeName( elem, "button" ) ) { - return formHook.set( elem, value, name ); - } - // Does not return so that setAttribute is also used - elem.value = value; - } -}; - -// IE6/7 do not support getting/setting some attributes with get/setAttribute -if ( !jQuery.support.getSetAttribute ) { - - // propFix is more comprehensive and contains all fixes - jQuery.attrFix = jQuery.propFix; - - // Use this for any attribute on a form in IE6/7 - formHook = jQuery.attrHooks.name = jQuery.valHooks.button = { - get: function( elem, name ) { - var ret; - ret = elem.getAttributeNode( name ); - // Return undefined if nodeValue is empty string - return ret && ret.nodeValue !== "" ? - ret.nodeValue : - undefined; - }, - set: function( elem, value, name ) { - // Check form objects in IE (multiple bugs related) - // Only use nodeValue if the attribute node exists on the form - var ret = elem.getAttributeNode( name ); - if ( ret ) { - ret.nodeValue = value; - return value; - } - } - }; - - // Set width and height to auto instead of 0 on empty string( Bug #8150 ) - // This is for removals - jQuery.each([ "width", "height" ], function( i, name ) { - jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { - set: function( elem, value ) { - if ( value === "" ) { - elem.setAttribute( name, "auto" ); - return value; - } - } - }); - }); -} - - -// Some attributes require a special call on IE -if ( !jQuery.support.hrefNormalized ) { - jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { - jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { - get: function( elem ) { - var ret = elem.getAttribute( name, 2 ); - return ret === null ? undefined : ret; - } - }); - }); -} - -if ( !jQuery.support.style ) { - jQuery.attrHooks.style = { - get: function( elem ) { - // Return undefined in the case of empty string - // Normalize to lowercase since IE uppercases css property names - return elem.style.cssText.toLowerCase() || undefined; - }, - set: function( elem, value ) { - return (elem.style.cssText = "" + value); - } - }; -} - -// Safari mis-reports the default selected property of an option -// Accessing the parent's selectedIndex property fixes it -if ( !jQuery.support.optSelected ) { - jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { - get: function( elem ) { - var parent = elem.parentNode; - - if ( parent ) { - parent.selectedIndex; - - // Make sure that it also works with optgroups, see #5701 - if ( parent.parentNode ) { - parent.parentNode.selectedIndex; - } - } - } - }); -} - -// Radios and checkboxes getter/setter -if ( !jQuery.support.checkOn ) { - jQuery.each([ "radio", "checkbox" ], function() { - jQuery.valHooks[ this ] = { - get: function( elem ) { - // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified - return elem.getAttribute("value") === null ? "on" : elem.value; - } - }; - }); -} -jQuery.each([ "radio", "checkbox" ], function() { - jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { - set: function( elem, value ) { - if ( jQuery.isArray( value ) ) { - return (elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0); - } - } - }); -}); - - - - -var hasOwn = Object.prototype.hasOwnProperty, - rnamespaces = /\.(.*)$/, - rformElems = /^(?:textarea|input|select)$/i, - rperiod = /\./g, - rspaces = / /g, - rescape = /[^\w\s.|`]/g, - fcleanup = function( nm ) { - return nm.replace(rescape, "\\$&"); - }; - -/* - * A number of helper functions used for managing events. - * Many of the ideas behind this code originated from - * Dean Edwards' addEvent library. - */ -jQuery.event = { - - // Bind an event to an element - // Original by Dean Edwards - add: function( elem, types, handler, data ) { - if ( elem.nodeType === 3 || elem.nodeType === 8 ) { - return; - } - - if ( handler === false ) { - handler = returnFalse; - } else if ( !handler ) { - // Fixes bug #7229. Fix recommended by jdalton - return; - } - - var handleObjIn, handleObj; - - if ( handler.handler ) { - handleObjIn = handler; - handler = handleObjIn.handler; - } - - // Make sure that the function being executed has a unique ID - if ( !handler.guid ) { - handler.guid = jQuery.guid++; - } - - // Init the element's event structure - var elemData = jQuery._data( elem ); - - // If no elemData is found then we must be trying to bind to one of the - // banned noData elements - if ( !elemData ) { - return; - } - - var events = elemData.events, - eventHandle = elemData.handle; - - if ( !events ) { - elemData.events = events = {}; - } - - if ( !eventHandle ) { - elemData.handle = eventHandle = function( e ) { - // Discard the second event of a jQuery.event.trigger() and - // when an event is called after a page has unloaded - return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? - jQuery.event.handle.apply( eventHandle.elem, arguments ) : - undefined; - }; - } - - // Add elem as a property of the handle function - // This is to prevent a memory leak with non-native events in IE. - eventHandle.elem = elem; - - // Handle multiple events separated by a space - // jQuery(...).bind("mouseover mouseout", fn); - types = types.split(" "); - - var type, i = 0, namespaces; - - while ( (type = types[ i++ ]) ) { - handleObj = handleObjIn ? - jQuery.extend({}, handleObjIn) : - { handler: handler, data: data }; - - // Namespaced event handlers - if ( type.indexOf(".") > -1 ) { - namespaces = type.split("."); - type = namespaces.shift(); - handleObj.namespace = namespaces.slice(0).sort().join("."); - - } else { - namespaces = []; - handleObj.namespace = ""; - } - - handleObj.type = type; - if ( !handleObj.guid ) { - handleObj.guid = handler.guid; - } - - // Get the current list of functions bound to this event - var handlers = events[ type ], - special = jQuery.event.special[ type ] || {}; - - // Init the event handler queue - if ( !handlers ) { - handlers = events[ type ] = []; - - // Check for a special event handler - // Only use addEventListener/attachEvent if the special - // events handler returns false - if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { - // Bind the global event handler to the element - if ( elem.addEventListener ) { - elem.addEventListener( type, eventHandle, false ); - - } else if ( elem.attachEvent ) { - elem.attachEvent( "on" + type, eventHandle ); - } - } - } - - if ( special.add ) { - special.add.call( elem, handleObj ); - - if ( !handleObj.handler.guid ) { - handleObj.handler.guid = handler.guid; - } - } - - // Add the function to the element's handler list - handlers.push( handleObj ); - - // Keep track of which events have been used, for event optimization - jQuery.event.global[ type ] = true; - } - - // Nullify elem to prevent memory leaks in IE - elem = null; - }, - - global: {}, - - // Detach an event or set of events from an element - remove: function( elem, types, handler, pos ) { - // don't do events on text and comment nodes - if ( elem.nodeType === 3 || elem.nodeType === 8 ) { - return; - } - - if ( handler === false ) { - handler = returnFalse; - } - - var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType, - elemData = jQuery.hasData( elem ) && jQuery._data( elem ), - events = elemData && elemData.events; - - if ( !elemData || !events ) { - return; - } - - // types is actually an event object here - if ( types && types.type ) { - handler = types.handler; - types = types.type; - } - - // Unbind all events for the element - if ( !types || typeof types === "string" && types.charAt(0) === "." ) { - types = types || ""; - - for ( type in events ) { - jQuery.event.remove( elem, type + types ); - } - - return; - } - - // Handle multiple events separated by a space - // jQuery(...).unbind("mouseover mouseout", fn); - types = types.split(" "); - - while ( (type = types[ i++ ]) ) { - origType = type; - handleObj = null; - all = type.indexOf(".") < 0; - namespaces = []; - - if ( !all ) { - // Namespaced event handlers - namespaces = type.split("."); - type = namespaces.shift(); - - namespace = new RegExp("(^|\\.)" + - jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)"); - } - - eventType = events[ type ]; - - if ( !eventType ) { - continue; - } - - if ( !handler ) { - for ( j = 0; j < eventType.length; j++ ) { - handleObj = eventType[ j ]; - - if ( all || namespace.test( handleObj.namespace ) ) { - jQuery.event.remove( elem, origType, handleObj.handler, j ); - eventType.splice( j--, 1 ); - } - } - - continue; - } - - special = jQuery.event.special[ type ] || {}; - - for ( j = pos || 0; j < eventType.length; j++ ) { - handleObj = eventType[ j ]; - - if ( handler.guid === handleObj.guid ) { - // remove the given handler for the given type - if ( all || namespace.test( handleObj.namespace ) ) { - if ( pos == null ) { - eventType.splice( j--, 1 ); - } - - if ( special.remove ) { - special.remove.call( elem, handleObj ); - } - } - - if ( pos != null ) { - break; - } - } - } - - // remove generic event handler if no more handlers exist - if ( eventType.length === 0 || pos != null && eventType.length === 1 ) { - if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { - jQuery.removeEvent( elem, type, elemData.handle ); - } - - ret = null; - delete events[ type ]; - } - } - - // Remove the expando if it's no longer used - if ( jQuery.isEmptyObject( events ) ) { - var handle = elemData.handle; - if ( handle ) { - handle.elem = null; - } - - delete elemData.events; - delete elemData.handle; - - if ( jQuery.isEmptyObject( elemData ) ) { - jQuery.removeData( elem, undefined, true ); - } - } - }, - - // Events that are safe to short-circuit if no handlers are attached. - // Native DOM events should not be added, they may have inline handlers. - customEvent: { - "getData": true, - "setData": true, - "changeData": true - }, - - trigger: function( event, data, elem, onlyHandlers ) { - // Event object or event type - var type = event.type || event, - namespaces = [], - exclusive; - - if ( type.indexOf("!") >= 0 ) { - // Exclusive events trigger only for the exact event (no namespaces) - type = type.slice(0, -1); - exclusive = true; - } - - if ( type.indexOf(".") >= 0 ) { - // Namespaced trigger; create a regexp to match event type in handle() - namespaces = type.split("."); - type = namespaces.shift(); - namespaces.sort(); - } - - if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) { - // No jQuery handlers for this event type, and it can't have inline handlers - return; - } - - // Caller can pass in an Event, Object, or just an event type string - event = typeof event === "object" ? - // jQuery.Event object - event[ jQuery.expando ] ? event : - // Object literal - new jQuery.Event( type, event ) : - // Just the event type (string) - new jQuery.Event( type ); - - event.type = type; - event.exclusive = exclusive; - event.namespace = namespaces.join("."); - event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)"); - - // triggerHandler() and global events don't bubble or run the default action - if ( onlyHandlers || !elem ) { - event.preventDefault(); - event.stopPropagation(); - } - - // Handle a global trigger - if ( !elem ) { - // TODO: Stop taunting the data cache; remove global events and always attach to document - jQuery.each( jQuery.cache, function() { - // internalKey variable is just used to make it easier to find - // and potentially change this stuff later; currently it just - // points to jQuery.expando - var internalKey = jQuery.expando, - internalCache = this[ internalKey ]; - if ( internalCache && internalCache.events && internalCache.events[ type ] ) { - jQuery.event.trigger( event, data, internalCache.handle.elem ); - } - }); - return; - } - - // Don't do events on text and comment nodes - if ( elem.nodeType === 3 || elem.nodeType === 8 ) { - return; - } - - // Clean up the event in case it is being reused - event.result = undefined; - event.target = elem; - - // Clone any incoming data and prepend the event, creating the handler arg list - data = data ? jQuery.makeArray( data ) : []; - data.unshift( event ); - - var cur = elem, - // IE doesn't like method names with a colon (#3533, #8272) - ontype = type.indexOf(":") < 0 ? "on" + type : ""; - - // Fire event on the current element, then bubble up the DOM tree - do { - var handle = jQuery._data( cur, "handle" ); - - event.currentTarget = cur; - if ( handle ) { - handle.apply( cur, data ); - } - - // Trigger an inline bound script - if ( ontype && jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) { - event.result = false; - event.preventDefault(); - } - - // Bubble up to document, then to window - cur = cur.parentNode || cur.ownerDocument || cur === event.target.ownerDocument && window; - } while ( cur && !event.isPropagationStopped() ); - - // If nobody prevented the default action, do it now - if ( !event.isDefaultPrevented() ) { - var old, - special = jQuery.event.special[ type ] || {}; - - if ( (!special._default || special._default.call( elem.ownerDocument, event ) === false) && - !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { - - // Call a native DOM method on the target with the same name name as the event. - // Can't use an .isFunction)() check here because IE6/7 fails that test. - // IE<9 dies on focus to hidden element (#1486), may want to revisit a try/catch. - try { - if ( ontype && elem[ type ] ) { - // Don't re-trigger an onFOO event when we call its FOO() method - old = elem[ ontype ]; - - if ( old ) { - elem[ ontype ] = null; - } - - jQuery.event.triggered = type; - elem[ type ](); - } - } catch ( ieError ) {} - - if ( old ) { - elem[ ontype ] = old; - } - - jQuery.event.triggered = undefined; - } - } - - return event.result; - }, - - handle: function( event ) { - event = jQuery.event.fix( event || window.event ); - // Snapshot the handlers list since a called handler may add/remove events. - var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []).slice(0), - run_all = !event.exclusive && !event.namespace, - args = Array.prototype.slice.call( arguments, 0 ); - - // Use the fix-ed Event rather than the (read-only) native event - args[0] = event; - event.currentTarget = this; - - for ( var j = 0, l = handlers.length; j < l; j++ ) { - var handleObj = handlers[ j ]; - - // Triggered event must 1) be non-exclusive and have no namespace, or - // 2) have namespace(s) a subset or equal to those in the bound event. - if ( run_all || event.namespace_re.test( handleObj.namespace ) ) { - // Pass in a reference to the handler function itself - // So that we can later remove it - event.handler = handleObj.handler; - event.data = handleObj.data; - event.handleObj = handleObj; - - var ret = handleObj.handler.apply( this, args ); - - if ( ret !== undefined ) { - event.result = ret; - if ( ret === false ) { - event.preventDefault(); - event.stopPropagation(); - } - } - - if ( event.isImmediatePropagationStopped() ) { - break; - } - } - } - return event.result; - }, - - 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(" "), - - fix: function( event ) { - if ( event[ jQuery.expando ] ) { - return event; - } - - // store a copy of the original event object - // and "clone" to set read-only properties - var originalEvent = event; - event = jQuery.Event( originalEvent ); - - for ( var i = this.props.length, prop; i; ) { - prop = this.props[ --i ]; - event[ prop ] = originalEvent[ prop ]; - } - - // Fix target property, if necessary - if ( !event.target ) { - // Fixes #1925 where srcElement might not be defined either - event.target = event.srcElement || document; - } - - // check if target is a textnode (safari) - if ( event.target.nodeType === 3 ) { - event.target = event.target.parentNode; - } - - // Add relatedTarget, if necessary - if ( !event.relatedTarget && event.fromElement ) { - event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement; - } - - // Calculate pageX/Y if missing and clientX/Y available - if ( event.pageX == null && event.clientX != null ) { - var eventDocument = event.target.ownerDocument || document, - doc = eventDocument.documentElement, - body = eventDocument.body; - - event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); - event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); - } - - // Add which for key events - if ( event.which == null && (event.charCode != null || event.keyCode != null) ) { - event.which = event.charCode != null ? event.charCode : event.keyCode; - } - - // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs) - if ( !event.metaKey && event.ctrlKey ) { - event.metaKey = event.ctrlKey; - } - - // Add which for click: 1 === left; 2 === middle; 3 === right - // Note: button is not normalized, so don't use it - if ( !event.which && event.button !== undefined ) { - event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); - } - - return event; - }, - - // Deprecated, use jQuery.guid instead - guid: 1E8, - - // Deprecated, use jQuery.proxy instead - proxy: jQuery.proxy, - - special: { - ready: { - // Make sure the ready event is setup - setup: jQuery.bindReady, - teardown: jQuery.noop - }, - - live: { - add: function( handleObj ) { - jQuery.event.add( this, - liveConvert( handleObj.origType, handleObj.selector ), - jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) ); - }, - - remove: function( handleObj ) { - jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj ); - } - }, - - beforeunload: { - setup: function( data, namespaces, eventHandle ) { - // We only want to do this special case on windows - if ( jQuery.isWindow( this ) ) { - this.onbeforeunload = eventHandle; - } - }, - - teardown: function( namespaces, eventHandle ) { - if ( this.onbeforeunload === eventHandle ) { - this.onbeforeunload = null; - } - } - } - } -}; - -jQuery.removeEvent = document.removeEventListener ? - function( elem, type, handle ) { - if ( elem.removeEventListener ) { - elem.removeEventListener( type, handle, false ); - } - } : - function( elem, type, handle ) { - if ( elem.detachEvent ) { - elem.detachEvent( "on" + type, handle ); - } - }; - -jQuery.Event = function( src, props ) { - // Allow instantiation without the 'new' keyword - if ( !this.preventDefault ) { - return new jQuery.Event( src, props ); - } - - // Event object - if ( src && src.type ) { - this.originalEvent = src; - this.type = src.type; - - // Events bubbling up the document may have been marked as prevented - // by a handler lower down the tree; reflect the correct value. - this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false || - src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse; - - // Event type - } else { - this.type = src; - } - - // Put explicitly provided properties onto the event object - if ( props ) { - jQuery.extend( this, props ); - } - - // timeStamp is buggy for some events on Firefox(#3843) - // So we won't rely on the native value - this.timeStamp = jQuery.now(); - - // Mark it as fixed - this[ jQuery.expando ] = true; -}; - -function returnFalse() { - return false; -} -function returnTrue() { - return true; -} - -// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding -// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html -jQuery.Event.prototype = { - preventDefault: function() { - this.isDefaultPrevented = returnTrue; - - var e = this.originalEvent; - if ( !e ) { - return; - } - - // if preventDefault exists run it on the original event - if ( e.preventDefault ) { - e.preventDefault(); - - // otherwise set the returnValue property of the original event to false (IE) - } else { - e.returnValue = false; - } - }, - stopPropagation: function() { - this.isPropagationStopped = returnTrue; - - var e = this.originalEvent; - if ( !e ) { - return; - } - // if stopPropagation exists run it on the original event - if ( e.stopPropagation ) { - e.stopPropagation(); - } - // otherwise set the cancelBubble property of the original event to true (IE) - e.cancelBubble = true; - }, - stopImmediatePropagation: function() { - this.isImmediatePropagationStopped = returnTrue; - this.stopPropagation(); - }, - isDefaultPrevented: returnFalse, - isPropagationStopped: returnFalse, - isImmediatePropagationStopped: returnFalse -}; - -// Checks if an event happened on an element within another element -// Used in jQuery.event.special.mouseenter and mouseleave handlers -var withinElement = function( event ) { - // Check if mouse(over|out) are still within the same parent element - var parent = event.relatedTarget; - - // set the correct event type - event.type = event.data; - - // Firefox sometimes assigns relatedTarget a XUL element - // which we cannot access the parentNode property of - try { - - // Chrome does something similar, the parentNode property - // can be accessed but is null. - if ( parent && parent !== document && !parent.parentNode ) { - return; - } - - // Traverse up the tree - while ( parent && parent !== this ) { - parent = parent.parentNode; - } - - if ( parent !== this ) { - // handle event if we actually just moused on to a non sub-element - jQuery.event.handle.apply( this, arguments ); - } - - // assuming we've left the element since we most likely mousedover a xul element - } catch(e) { } -}, - -// In case of event delegation, we only need to rename the event.type, -// liveHandler will take care of the rest. -delegate = function( event ) { - event.type = event.data; - jQuery.event.handle.apply( this, arguments ); -}; - -// Create mouseenter and mouseleave events -jQuery.each({ - mouseenter: "mouseover", - mouseleave: "mouseout" -}, function( orig, fix ) { - jQuery.event.special[ orig ] = { - setup: function( data ) { - jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig ); - }, - teardown: function( data ) { - jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement ); - } - }; -}); - -// submit delegation -if ( !jQuery.support.submitBubbles ) { - - jQuery.event.special.submit = { - setup: function( data, namespaces ) { - if ( !jQuery.nodeName( this, "form" ) ) { - jQuery.event.add(this, "click.specialSubmit", function( e ) { - var elem = e.target, - type = elem.type; - - if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) { - trigger( "submit", this, arguments ); - } - }); - - jQuery.event.add(this, "keypress.specialSubmit", function( e ) { - var elem = e.target, - type = elem.type; - - if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) { - trigger( "submit", this, arguments ); - } - }); - - } else { - return false; - } - }, - - teardown: function( namespaces ) { - jQuery.event.remove( this, ".specialSubmit" ); - } - }; - -} - -// change delegation, happens here so we have bind. -if ( !jQuery.support.changeBubbles ) { - - var changeFilters, - - getVal = function( elem ) { - var type = elem.type, val = elem.value; - - if ( type === "radio" || type === "checkbox" ) { - val = elem.checked; - - } else if ( type === "select-multiple" ) { - val = elem.selectedIndex > -1 ? - jQuery.map( elem.options, function( elem ) { - return elem.selected; - }).join("-") : - ""; - - } else if ( jQuery.nodeName( elem, "select" ) ) { - val = elem.selectedIndex; - } - - return val; - }, - - testChange = function testChange( e ) { - var elem = e.target, data, val; - - if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) { - return; - } - - data = jQuery._data( elem, "_change_data" ); - val = getVal(elem); - - // the current data will be also retrieved by beforeactivate - if ( e.type !== "focusout" || elem.type !== "radio" ) { - jQuery._data( elem, "_change_data", val ); - } - - if ( data === undefined || val === data ) { - return; - } - - if ( data != null || val ) { - e.type = "change"; - e.liveFired = undefined; - jQuery.event.trigger( e, arguments[1], elem ); - } - }; - - jQuery.event.special.change = { - filters: { - focusout: testChange, - - beforedeactivate: testChange, - - click: function( e ) { - var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : ""; - - if ( type === "radio" || type === "checkbox" || jQuery.nodeName( elem, "select" ) ) { - testChange.call( this, e ); - } - }, - - // Change has to be called before submit - // Keydown will be called before keypress, which is used in submit-event delegation - keydown: function( e ) { - var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : ""; - - if ( (e.keyCode === 13 && !jQuery.nodeName( elem, "textarea" ) ) || - (e.keyCode === 32 && (type === "checkbox" || type === "radio")) || - type === "select-multiple" ) { - testChange.call( this, e ); - } - }, - - // Beforeactivate happens also before the previous element is blurred - // with this event you can't trigger a change event, but you can store - // information - beforeactivate: function( e ) { - var elem = e.target; - jQuery._data( elem, "_change_data", getVal(elem) ); - } - }, - - setup: function( data, namespaces ) { - if ( this.type === "file" ) { - return false; - } - - for ( var type in changeFilters ) { - jQuery.event.add( this, type + ".specialChange", changeFilters[type] ); - } - - return rformElems.test( this.nodeName ); - }, - - teardown: function( namespaces ) { - jQuery.event.remove( this, ".specialChange" ); - - return rformElems.test( this.nodeName ); - } - }; - - changeFilters = jQuery.event.special.change.filters; - - // Handle when the input is .focus()'d - changeFilters.focus = changeFilters.beforeactivate; -} - -function trigger( type, elem, args ) { - // Piggyback on a donor event to simulate a different one. - // Fake originalEvent to avoid donor's stopPropagation, but if the - // simulated event prevents default then we do the same on the donor. - // Don't pass args or remember liveFired; they apply to the donor event. - var event = jQuery.extend( {}, args[ 0 ] ); - event.type = type; - event.originalEvent = {}; - event.liveFired = undefined; - jQuery.event.handle.call( elem, event ); - if ( event.isDefaultPrevented() ) { - args[ 0 ].preventDefault(); - } -} - -// Create "bubbling" focus and blur events -if ( !jQuery.support.focusinBubbles ) { - jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { - - // Attach a single capturing handler while someone wants focusin/focusout - var attaches = 0; - - jQuery.event.special[ fix ] = { - setup: function() { - if ( attaches++ === 0 ) { - document.addEventListener( orig, handler, true ); - } - }, - teardown: function() { - if ( --attaches === 0 ) { - document.removeEventListener( orig, handler, true ); - } - } - }; - - function handler( donor ) { - // Donor event is always a native one; fix it and switch its type. - // Let focusin/out handler cancel the donor focus/blur event. - var e = jQuery.event.fix( donor ); - e.type = fix; - e.originalEvent = {}; - jQuery.event.trigger( e, null, e.target ); - if ( e.isDefaultPrevented() ) { - donor.preventDefault(); - } - } - }); -} - -jQuery.each(["bind", "one"], function( i, name ) { - jQuery.fn[ name ] = function( type, data, fn ) { - var handler; - - // Handle object literals - if ( typeof type === "object" ) { - for ( var key in type ) { - this[ name ](key, data, type[key], fn); - } - return this; - } - - if ( arguments.length === 2 || data === false ) { - fn = data; - data = undefined; - } - - if ( name === "one" ) { - handler = function( event ) { - jQuery( this ).unbind( event, handler ); - return fn.apply( this, arguments ); - }; - handler.guid = fn.guid || jQuery.guid++; - } else { - handler = fn; - } - - if ( type === "unload" && name !== "one" ) { - this.one( type, data, fn ); - - } else { - for ( var i = 0, l = this.length; i < l; i++ ) { - jQuery.event.add( this[i], type, handler, data ); - } - } - - return this; - }; -}); - -jQuery.fn.extend({ - unbind: function( type, fn ) { - // Handle object literals - if ( typeof type === "object" && !type.preventDefault ) { - for ( var key in type ) { - this.unbind(key, type[key]); - } - - } else { - for ( var i = 0, l = this.length; i < l; i++ ) { - jQuery.event.remove( this[i], type, fn ); - } - } - - return this; - }, - - delegate: function( selector, types, data, fn ) { - return this.live( types, data, fn, selector ); - }, - - undelegate: function( selector, types, fn ) { - if ( arguments.length === 0 ) { - return this.unbind( "live" ); - - } else { - return this.die( types, null, fn, selector ); - } - }, - - trigger: function( type, data ) { - return this.each(function() { - jQuery.event.trigger( type, data, this ); - }); - }, - - triggerHandler: function( type, data ) { - if ( this[0] ) { - return jQuery.event.trigger( type, data, this[0], true ); - } - }, - - toggle: function( fn ) { - // Save reference to arguments for access in closure - var args = arguments, - guid = fn.guid || jQuery.guid++, - i = 0, - toggler = function( event ) { - // Figure out which function to execute - var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i; - jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 ); - - // Make sure that clicks stop - event.preventDefault(); - - // and execute the function - return args[ lastToggle ].apply( this, arguments ) || false; - }; - - // link all the functions, so any of them can unbind this click handler - toggler.guid = guid; - while ( i < args.length ) { - args[ i++ ].guid = guid; - } - - return this.click( toggler ); - }, - - hover: function( fnOver, fnOut ) { - return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); - } -}); - -var liveMap = { - focus: "focusin", - blur: "focusout", - mouseenter: "mouseover", - mouseleave: "mouseout" -}; - -jQuery.each(["live", "die"], function( i, name ) { - jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) { - var type, i = 0, match, namespaces, preType, - selector = origSelector || this.selector, - context = origSelector ? this : jQuery( this.context ); - - if ( typeof types === "object" && !types.preventDefault ) { - for ( var key in types ) { - context[ name ]( key, data, types[key], selector ); - } - - return this; - } - - if ( name === "die" && !types && - origSelector && origSelector.charAt(0) === "." ) { - - context.unbind( origSelector ); - - return this; - } - - if ( data === false || jQuery.isFunction( data ) ) { - fn = data || returnFalse; - data = undefined; - } - - types = (types || "").split(" "); - - while ( (type = types[ i++ ]) != null ) { - match = rnamespaces.exec( type ); - namespaces = ""; - - if ( match ) { - namespaces = match[0]; - type = type.replace( rnamespaces, "" ); - } - - if ( type === "hover" ) { - types.push( "mouseenter" + namespaces, "mouseleave" + namespaces ); - continue; - } - - preType = type; - - if ( liveMap[ type ] ) { - types.push( liveMap[ type ] + namespaces ); - type = type + namespaces; - - } else { - type = (liveMap[ type ] || type) + namespaces; - } - - if ( name === "live" ) { - // bind live handler - for ( var j = 0, l = context.length; j < l; j++ ) { - jQuery.event.add( context[j], "live." + liveConvert( type, selector ), - { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } ); - } - - } else { - // unbind live handler - context.unbind( "live." + liveConvert( type, selector ), fn ); - } - } - - return this; - }; -}); - -function liveHandler( event ) { - var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret, - elems = [], - selectors = [], - events = jQuery._data( this, "events" ); - - // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911) - if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) { - return; - } - - if ( event.namespace ) { - namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)"); - } - - event.liveFired = this; - - var live = events.live.slice(0); - - for ( j = 0; j < live.length; j++ ) { - handleObj = live[j]; - - if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) { - selectors.push( handleObj.selector ); - - } else { - live.splice( j--, 1 ); - } - } - - match = jQuery( event.target ).closest( selectors, event.currentTarget ); - - for ( i = 0, l = match.length; i < l; i++ ) { - close = match[i]; - - for ( j = 0; j < live.length; j++ ) { - handleObj = live[j]; - - if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) { - elem = close.elem; - related = null; - - // Those two events require additional checking - if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) { - event.type = handleObj.preType; - related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0]; - - // Make sure not to accidentally match a child element with the same selector - if ( related && jQuery.contains( elem, related ) ) { - related = elem; - } - } - - if ( !related || related !== elem ) { - elems.push({ elem: elem, handleObj: handleObj, level: close.level }); - } - } - } - } - - for ( i = 0, l = elems.length; i < l; i++ ) { - match = elems[i]; - - if ( maxLevel && match.level > maxLevel ) { - break; - } - - event.currentTarget = match.elem; - event.data = match.handleObj.data; - event.handleObj = match.handleObj; - - ret = match.handleObj.origHandler.apply( match.elem, arguments ); - - if ( ret === false || event.isPropagationStopped() ) { - maxLevel = match.level; - - if ( ret === false ) { - stop = false; - } - if ( event.isImmediatePropagationStopped() ) { - break; - } - } - } - - return stop; -} - -function liveConvert( type, selector ) { - return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspaces, "&"); -} - -jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + - "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + - "change select submit keydown keypress keyup error").split(" "), function( i, name ) { - - // Handle event binding - jQuery.fn[ name ] = function( data, fn ) { - if ( fn == null ) { - fn = data; - data = null; - } - - return arguments.length > 0 ? - this.bind( name, data, fn ) : - this.trigger( name ); - }; - - if ( jQuery.attrFn ) { - jQuery.attrFn[ name ] = true; - } -}); - - - -/*! - * Sizzle CSS Selector Engine - * Copyright 2011, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * More information: http://sizzlejs.com/ - */ -(function(){ - -var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, - done = 0, - toString = Object.prototype.toString, - hasDuplicate = false, - baseHasDuplicate = true, - rBackslash = /\\/g, - rNonWord = /\W/; - -// Here we check if the JavaScript engine is using some sort of -// optimization where it does not always call our comparision -// function. If that is the case, discard the hasDuplicate value. -// Thus far that includes Google Chrome. -[0, 0].sort(function() { - baseHasDuplicate = false; - return 0; -}); - -var Sizzle = function( selector, context, results, seed ) { - results = results || []; - context = context || document; - - var origContext = context; - - if ( context.nodeType !== 1 && context.nodeType !== 9 ) { - return []; - } - - if ( !selector || typeof selector !== "string" ) { - return results; - } - - var m, set, checkSet, extra, ret, cur, pop, i, - prune = true, - contextXML = Sizzle.isXML( context ), - parts = [], - soFar = selector; - - // Reset the position of the chunker regexp (start from head) - do { - chunker.exec( "" ); - m = chunker.exec( soFar ); - - if ( m ) { - soFar = m[3]; - - parts.push( m[1] ); - - if ( m[2] ) { - extra = m[3]; - break; - } - } - } while ( m ); - - if ( parts.length > 1 && origPOS.exec( selector ) ) { - - if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { - set = posProcess( parts[0] + parts[1], context ); - - } else { - set = Expr.relative[ parts[0] ] ? - [ context ] : - Sizzle( parts.shift(), context ); - - while ( parts.length ) { - selector = parts.shift(); - - if ( Expr.relative[ selector ] ) { - selector += parts.shift(); - } - - set = posProcess( selector, set ); - } - } - - } else { - // Take a shortcut and set the context if the root selector is an ID - // (but not if it'll be faster if the inner selector is an ID) - if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && - Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { - - ret = Sizzle.find( parts.shift(), context, contextXML ); - context = ret.expr ? - Sizzle.filter( ret.expr, ret.set )[0] : - ret.set[0]; - } - - if ( context ) { - ret = seed ? - { expr: parts.pop(), set: makeArray(seed) } : - Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); - - set = ret.expr ? - Sizzle.filter( ret.expr, ret.set ) : - ret.set; - - if ( parts.length > 0 ) { - checkSet = makeArray( set ); - - } else { - prune = false; - } - - while ( parts.length ) { - cur = parts.pop(); - pop = cur; - - if ( !Expr.relative[ cur ] ) { - cur = ""; - } else { - pop = parts.pop(); - } - - if ( pop == null ) { - pop = context; - } - - Expr.relative[ cur ]( checkSet, pop, contextXML ); - } - - } else { - checkSet = parts = []; - } - } - - if ( !checkSet ) { - checkSet = set; - } - - if ( !checkSet ) { - Sizzle.error( cur || selector ); - } - - if ( toString.call(checkSet) === "[object Array]" ) { - if ( !prune ) { - results.push.apply( results, checkSet ); - - } else if ( context && context.nodeType === 1 ) { - for ( i = 0; checkSet[i] != null; i++ ) { - if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) { - results.push( set[i] ); - } - } - - } else { - for ( i = 0; checkSet[i] != null; i++ ) { - if ( checkSet[i] && checkSet[i].nodeType === 1 ) { - results.push( set[i] ); - } - } - } - - } else { - makeArray( checkSet, results ); - } - - if ( extra ) { - Sizzle( extra, origContext, results, seed ); - Sizzle.uniqueSort( results ); - } - - return results; -}; - -Sizzle.uniqueSort = function( results ) { - if ( sortOrder ) { - hasDuplicate = baseHasDuplicate; - results.sort( sortOrder ); - - if ( hasDuplicate ) { - for ( var i = 1; i < results.length; i++ ) { - if ( results[i] === results[ i - 1 ] ) { - results.splice( i--, 1 ); - } - } - } - } - - return results; -}; - -Sizzle.matches = function( expr, set ) { - return Sizzle( expr, null, null, set ); -}; - -Sizzle.matchesSelector = function( node, expr ) { - return Sizzle( expr, null, null, [node] ).length > 0; -}; - -Sizzle.find = function( expr, context, isXML ) { - var set; - - if ( !expr ) { - return []; - } - - for ( var i = 0, l = Expr.order.length; i < l; i++ ) { - var match, - type = Expr.order[i]; - - if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { - var left = match[1]; - match.splice( 1, 1 ); - - if ( left.substr( left.length - 1 ) !== "\\" ) { - match[1] = (match[1] || "").replace( rBackslash, "" ); - set = Expr.find[ type ]( match, context, isXML ); - - if ( set != null ) { - expr = expr.replace( Expr.match[ type ], "" ); - break; - } - } - } - } - - if ( !set ) { - set = typeof context.getElementsByTagName !== "undefined" ? - context.getElementsByTagName( "*" ) : - []; - } - - return { set: set, expr: expr }; -}; - -Sizzle.filter = function( expr, set, inplace, not ) { - var match, anyFound, - old = expr, - result = [], - curLoop = set, - isXMLFilter = set && set[0] && Sizzle.isXML( set[0] ); - - while ( expr && set.length ) { - for ( var type in Expr.filter ) { - if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { - var found, item, - filter = Expr.filter[ type ], - left = match[1]; - - anyFound = false; - - match.splice(1,1); - - if ( left.substr( left.length - 1 ) === "\\" ) { - continue; - } - - if ( curLoop === result ) { - result = []; - } - - if ( Expr.preFilter[ type ] ) { - match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); - - if ( !match ) { - anyFound = found = true; - - } else if ( match === true ) { - continue; - } - } - - if ( match ) { - for ( var i = 0; (item = curLoop[i]) != null; i++ ) { - if ( item ) { - found = filter( item, match, i, curLoop ); - var pass = not ^ !!found; - - if ( inplace && found != null ) { - if ( pass ) { - anyFound = true; - - } else { - curLoop[i] = false; - } - - } else if ( pass ) { - result.push( item ); - anyFound = true; - } - } - } - } - - if ( found !== undefined ) { - if ( !inplace ) { - curLoop = result; - } - - expr = expr.replace( Expr.match[ type ], "" ); - - if ( !anyFound ) { - return []; - } - - break; - } - } - } - - // Improper expression - if ( expr === old ) { - if ( anyFound == null ) { - Sizzle.error( expr ); - - } else { - break; - } - } - - old = expr; - } - - return curLoop; -}; - -Sizzle.error = function( msg ) { - throw "Syntax error, unrecognized expression: " + msg; -}; - -var Expr = Sizzle.selectors = { - order: [ "ID", "NAME", "TAG" ], - - match: { - ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, - CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, - NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, - ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, - TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, - CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, - POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, - PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ - }, - - leftMatch: {}, - - attrMap: { - "class": "className", - "for": "htmlFor" - }, - - attrHandle: { - href: function( elem ) { - return elem.getAttribute( "href" ); - }, - type: function( elem ) { - return elem.getAttribute( "type" ); - } - }, - - relative: { - "+": function(checkSet, part){ - var isPartStr = typeof part === "string", - isTag = isPartStr && !rNonWord.test( part ), - isPartStrNotTag = isPartStr && !isTag; - - if ( isTag ) { - part = part.toLowerCase(); - } - - for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { - if ( (elem = checkSet[i]) ) { - while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} - - checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? - elem || false : - elem === part; - } - } - - if ( isPartStrNotTag ) { - Sizzle.filter( part, checkSet, true ); - } - }, - - ">": function( checkSet, part ) { - var elem, - isPartStr = typeof part === "string", - i = 0, - l = checkSet.length; - - if ( isPartStr && !rNonWord.test( part ) ) { - part = part.toLowerCase(); - - for ( ; i < l; i++ ) { - elem = checkSet[i]; - - if ( elem ) { - var parent = elem.parentNode; - checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; - } - } - - } else { - for ( ; i < l; i++ ) { - elem = checkSet[i]; - - if ( elem ) { - checkSet[i] = isPartStr ? - elem.parentNode : - elem.parentNode === part; - } - } - - if ( isPartStr ) { - Sizzle.filter( part, checkSet, true ); - } - } - }, - - "": function(checkSet, part, isXML){ - var nodeCheck, - doneName = done++, - checkFn = dirCheck; - - if ( typeof part === "string" && !rNonWord.test( part ) ) { - part = part.toLowerCase(); - nodeCheck = part; - checkFn = dirNodeCheck; - } - - checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML ); - }, - - "~": function( checkSet, part, isXML ) { - var nodeCheck, - doneName = done++, - checkFn = dirCheck; - - if ( typeof part === "string" && !rNonWord.test( part ) ) { - part = part.toLowerCase(); - nodeCheck = part; - checkFn = dirNodeCheck; - } - - checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML ); - } - }, - - find: { - ID: function( match, context, isXML ) { - if ( typeof context.getElementById !== "undefined" && !isXML ) { - var m = context.getElementById(match[1]); - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - return m && m.parentNode ? [m] : []; - } - }, - - NAME: function( match, context ) { - if ( typeof context.getElementsByName !== "undefined" ) { - var ret = [], - results = context.getElementsByName( match[1] ); - - for ( var i = 0, l = results.length; i < l; i++ ) { - if ( results[i].getAttribute("name") === match[1] ) { - ret.push( results[i] ); - } - } - - return ret.length === 0 ? null : ret; - } - }, - - TAG: function( match, context ) { - if ( typeof context.getElementsByTagName !== "undefined" ) { - return context.getElementsByTagName( match[1] ); - } - } - }, - preFilter: { - CLASS: function( match, curLoop, inplace, result, not, isXML ) { - match = " " + match[1].replace( rBackslash, "" ) + " "; - - if ( isXML ) { - return match; - } - - for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { - if ( elem ) { - if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) { - if ( !inplace ) { - result.push( elem ); - } - - } else if ( inplace ) { - curLoop[i] = false; - } - } - } - - return false; - }, - - ID: function( match ) { - return match[1].replace( rBackslash, "" ); - }, - - TAG: function( match, curLoop ) { - return match[1].replace( rBackslash, "" ).toLowerCase(); - }, - - CHILD: function( match ) { - if ( match[1] === "nth" ) { - if ( !match[2] ) { - Sizzle.error( match[0] ); - } - - match[2] = match[2].replace(/^\+|\s*/g, ''); - - // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' - var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( - match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || - !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); - - // calculate the numbers (first)n+(last) including if they are negative - match[2] = (test[1] + (test[2] || 1)) - 0; - match[3] = test[3] - 0; - } - else if ( match[2] ) { - Sizzle.error( match[0] ); - } - - // TODO: Move to normal caching system - match[0] = done++; - - return match; - }, - - ATTR: function( match, curLoop, inplace, result, not, isXML ) { - var name = match[1] = match[1].replace( rBackslash, "" ); - - if ( !isXML && Expr.attrMap[name] ) { - match[1] = Expr.attrMap[name]; - } - - // Handle if an un-quoted value was used - match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" ); - - if ( match[2] === "~=" ) { - match[4] = " " + match[4] + " "; - } - - return match; - }, - - PSEUDO: function( match, curLoop, inplace, result, not ) { - if ( match[1] === "not" ) { - // If we're dealing with a complex expression, or a simple one - if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { - match[3] = Sizzle(match[3], null, null, curLoop); - - } else { - var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); - - if ( !inplace ) { - result.push.apply( result, ret ); - } - - return false; - } - - } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { - return true; - } - - return match; - }, - - POS: function( match ) { - match.unshift( true ); - - return match; - } - }, - - filters: { - enabled: function( elem ) { - return elem.disabled === false && elem.type !== "hidden"; - }, - - disabled: function( elem ) { - return elem.disabled === true; - }, - - checked: function( elem ) { - return elem.checked === true; - }, - - selected: function( elem ) { - // Accessing this property makes selected-by-default - // options in Safari work properly - if ( elem.parentNode ) { - elem.parentNode.selectedIndex; - } - - return elem.selected === true; - }, - - parent: function( elem ) { - return !!elem.firstChild; - }, - - empty: function( elem ) { - return !elem.firstChild; - }, - - has: function( elem, i, match ) { - return !!Sizzle( match[3], elem ).length; - }, - - header: function( elem ) { - return (/h\d/i).test( elem.nodeName ); - }, - - text: function( elem ) { - var attr = elem.getAttribute( "type" ), type = elem.type; - // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) - // use getAttribute instead to test this case - return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); - }, - - radio: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type; - }, - - checkbox: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type; - }, - - file: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "file" === elem.type; - }, - - password: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "password" === elem.type; - }, - - submit: function( elem ) { - var name = elem.nodeName.toLowerCase(); - return (name === "input" || name === "button") && "submit" === elem.type; - }, - - image: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "image" === elem.type; - }, - - reset: function( elem ) { - var name = elem.nodeName.toLowerCase(); - return (name === "input" || name === "button") && "reset" === elem.type; - }, - - button: function( elem ) { - var name = elem.nodeName.toLowerCase(); - return name === "input" && "button" === elem.type || name === "button"; - }, - - input: function( elem ) { - return (/input|select|textarea|button/i).test( elem.nodeName ); - }, - - focus: function( elem ) { - return elem === elem.ownerDocument.activeElement; - } - }, - setFilters: { - first: function( elem, i ) { - return i === 0; - }, - - last: function( elem, i, match, array ) { - return i === array.length - 1; - }, - - even: function( elem, i ) { - return i % 2 === 0; - }, - - odd: function( elem, i ) { - return i % 2 === 1; - }, - - lt: function( elem, i, match ) { - return i < match[3] - 0; - }, - - gt: function( elem, i, match ) { - return i > match[3] - 0; - }, - - nth: function( elem, i, match ) { - return match[3] - 0 === i; - }, - - eq: function( elem, i, match ) { - return match[3] - 0 === i; - } - }, - filter: { - PSEUDO: function( elem, match, i, array ) { - var name = match[1], - filter = Expr.filters[ name ]; - - if ( filter ) { - return filter( elem, i, match, array ); - - } else if ( name === "contains" ) { - return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0; - - } else if ( name === "not" ) { - var not = match[3]; - - for ( var j = 0, l = not.length; j < l; j++ ) { - if ( not[j] === elem ) { - return false; - } - } - - return true; - - } else { - Sizzle.error( name ); - } - }, - - CHILD: function( elem, match ) { - var type = match[1], - node = elem; - - switch ( type ) { - case "only": - case "first": - while ( (node = node.previousSibling) ) { - if ( node.nodeType === 1 ) { - return false; - } - } - - if ( type === "first" ) { - return true; - } - - node = elem; - - case "last": - while ( (node = node.nextSibling) ) { - if ( node.nodeType === 1 ) { - return false; - } - } - - return true; - - case "nth": - var first = match[2], - last = match[3]; - - if ( first === 1 && last === 0 ) { - return true; - } - - var doneName = match[0], - parent = elem.parentNode; - - if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { - var count = 0; - - for ( node = parent.firstChild; node; node = node.nextSibling ) { - if ( node.nodeType === 1 ) { - node.nodeIndex = ++count; - } - } - - parent.sizcache = doneName; - } - - var diff = elem.nodeIndex - last; - - if ( first === 0 ) { - return diff === 0; - - } else { - return ( diff % first === 0 && diff / first >= 0 ); - } - } - }, - - ID: function( elem, match ) { - return elem.nodeType === 1 && elem.getAttribute("id") === match; - }, - - TAG: function( elem, match ) { - return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match; - }, - - CLASS: function( elem, match ) { - return (" " + (elem.className || elem.getAttribute("class")) + " ") - .indexOf( match ) > -1; - }, - - ATTR: function( elem, match ) { - var name = match[1], - result = Expr.attrHandle[ name ] ? - Expr.attrHandle[ name ]( elem ) : - elem[ name ] != null ? - elem[ name ] : - elem.getAttribute( name ), - value = result + "", - type = match[2], - check = match[4]; - - return result == null ? - type === "!=" : - type === "=" ? - value === check : - type === "*=" ? - value.indexOf(check) >= 0 : - type === "~=" ? - (" " + value + " ").indexOf(check) >= 0 : - !check ? - value && result !== false : - type === "!=" ? - value !== check : - type === "^=" ? - value.indexOf(check) === 0 : - type === "$=" ? - value.substr(value.length - check.length) === check : - type === "|=" ? - value === check || value.substr(0, check.length + 1) === check + "-" : - false; - }, - - POS: function( elem, match, i, array ) { - var name = match[2], - filter = Expr.setFilters[ name ]; - - if ( filter ) { - return filter( elem, i, match, array ); - } - } - } -}; - -var origPOS = Expr.match.POS, - fescape = function(all, num){ - return "\\" + (num - 0 + 1); - }; - -for ( var type in Expr.match ) { - Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) ); - Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) ); -} - -var makeArray = function( array, results ) { - array = Array.prototype.slice.call( array, 0 ); - - if ( results ) { - results.push.apply( results, array ); - return results; - } - - return array; -}; - -// Perform a simple check to determine if the browser is capable of -// converting a NodeList to an array using builtin methods. -// Also verifies that the returned array holds DOM nodes -// (which is not the case in the Blackberry browser) -try { - Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; - -// Provide a fallback method if it does not work -} catch( e ) { - makeArray = function( array, results ) { - var i = 0, - ret = results || []; - - if ( toString.call(array) === "[object Array]" ) { - Array.prototype.push.apply( ret, array ); - - } else { - if ( typeof array.length === "number" ) { - for ( var l = array.length; i < l; i++ ) { - ret.push( array[i] ); - } - - } else { - for ( ; array[i]; i++ ) { - ret.push( array[i] ); - } - } - } - - return ret; - }; -} - -var sortOrder, siblingCheck; - -if ( document.documentElement.compareDocumentPosition ) { - sortOrder = function( a, b ) { - if ( a === b ) { - hasDuplicate = true; - return 0; - } - - if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { - return a.compareDocumentPosition ? -1 : 1; - } - - return a.compareDocumentPosition(b) & 4 ? -1 : 1; - }; - -} else { - sortOrder = function( a, b ) { - // The nodes are identical, we can exit early - if ( a === b ) { - hasDuplicate = true; - return 0; - - // Fallback to using sourceIndex (in IE) if it's available on both nodes - } else if ( a.sourceIndex && b.sourceIndex ) { - return a.sourceIndex - b.sourceIndex; - } - - var al, bl, - ap = [], - bp = [], - aup = a.parentNode, - bup = b.parentNode, - cur = aup; - - // If the nodes are siblings (or identical) we can do a quick check - if ( aup === bup ) { - return siblingCheck( a, b ); - - // If no parents were found then the nodes are disconnected - } else if ( !aup ) { - return -1; - - } else if ( !bup ) { - return 1; - } - - // Otherwise they're somewhere else in the tree so we need - // to build up a full list of the parentNodes for comparison - while ( cur ) { - ap.unshift( cur ); - cur = cur.parentNode; - } - - cur = bup; - - while ( cur ) { - bp.unshift( cur ); - cur = cur.parentNode; - } - - al = ap.length; - bl = bp.length; - - // Start walking down the tree looking for a discrepancy - for ( var i = 0; i < al && i < bl; i++ ) { - if ( ap[i] !== bp[i] ) { - return siblingCheck( ap[i], bp[i] ); - } - } - - // We ended someplace up the tree so do a sibling check - return i === al ? - siblingCheck( a, bp[i], -1 ) : - siblingCheck( ap[i], b, 1 ); - }; - - siblingCheck = function( a, b, ret ) { - if ( a === b ) { - return ret; - } - - var cur = a.nextSibling; - - while ( cur ) { - if ( cur === b ) { - return -1; - } - - cur = cur.nextSibling; - } - - return 1; - }; -} - -// Utility function for retreiving the text value of an array of DOM nodes -Sizzle.getText = function( elems ) { - var ret = "", elem; - - for ( var i = 0; elems[i]; i++ ) { - elem = elems[i]; - - // Get the text from text nodes and CDATA nodes - if ( elem.nodeType === 3 || elem.nodeType === 4 ) { - ret += elem.nodeValue; - - // Traverse everything else, except comment nodes - } else if ( elem.nodeType !== 8 ) { - ret += Sizzle.getText( elem.childNodes ); - } - } - - return ret; -}; - -// Check to see if the browser returns elements by name when -// querying by getElementById (and provide a workaround) -(function(){ - // We're going to inject a fake input element with a specified name - var form = document.createElement("div"), - id = "script" + (new Date()).getTime(), - root = document.documentElement; - - form.innerHTML = ""; - - // Inject it into the root element, check its status, and remove it quickly - root.insertBefore( form, root.firstChild ); - - // The workaround has to do additional checks after a getElementById - // Which slows things down for other browsers (hence the branching) - if ( document.getElementById( id ) ) { - Expr.find.ID = function( match, context, isXML ) { - if ( typeof context.getElementById !== "undefined" && !isXML ) { - var m = context.getElementById(match[1]); - - return m ? - m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? - [m] : - undefined : - []; - } - }; - - Expr.filter.ID = function( elem, match ) { - var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); - - return elem.nodeType === 1 && node && node.nodeValue === match; - }; - } - - root.removeChild( form ); - - // release memory in IE - root = form = null; -})(); - -(function(){ - // Check to see if the browser returns only elements - // when doing getElementsByTagName("*") - - // Create a fake element - var div = document.createElement("div"); - div.appendChild( document.createComment("") ); - - // Make sure no comments are found - if ( div.getElementsByTagName("*").length > 0 ) { - Expr.find.TAG = function( match, context ) { - var results = context.getElementsByTagName( match[1] ); - - // Filter out possible comments - if ( match[1] === "*" ) { - var tmp = []; - - for ( var i = 0; results[i]; i++ ) { - if ( results[i].nodeType === 1 ) { - tmp.push( results[i] ); - } - } - - results = tmp; - } - - return results; - }; - } - - // Check to see if an attribute returns normalized href attributes - div.innerHTML = ""; - - if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && - div.firstChild.getAttribute("href") !== "#" ) { - - Expr.attrHandle.href = function( elem ) { - return elem.getAttribute( "href", 2 ); - }; - } - - // release memory in IE - div = null; -})(); - -if ( document.querySelectorAll ) { - (function(){ - var oldSizzle = Sizzle, - div = document.createElement("div"), - id = "__sizzle__"; - - div.innerHTML = "

"; - - // Safari can't handle uppercase or unicode characters when - // in quirks mode. - if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { - return; - } - - Sizzle = function( query, context, extra, seed ) { - context = context || document; - - // Only use querySelectorAll on non-XML documents - // (ID selectors don't work in non-HTML documents) - if ( !seed && !Sizzle.isXML(context) ) { - // See if we find a selector to speed up - var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); - - if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { - // Speed-up: Sizzle("TAG") - if ( match[1] ) { - return makeArray( context.getElementsByTagName( query ), extra ); - - // Speed-up: Sizzle(".CLASS") - } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { - return makeArray( context.getElementsByClassName( match[2] ), extra ); - } - } - - if ( context.nodeType === 9 ) { - // Speed-up: Sizzle("body") - // The body element only exists once, optimize finding it - if ( query === "body" && context.body ) { - return makeArray( [ context.body ], extra ); - - // Speed-up: Sizzle("#ID") - } else if ( match && match[3] ) { - var elem = context.getElementById( match[3] ); - - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - if ( elem && elem.parentNode ) { - // Handle the case where IE and Opera return items - // by name instead of ID - if ( elem.id === match[3] ) { - return makeArray( [ elem ], extra ); - } - - } else { - return makeArray( [], extra ); - } - } - - try { - return makeArray( context.querySelectorAll(query), extra ); - } catch(qsaError) {} - - // qSA works strangely on Element-rooted queries - // We can work around this by specifying an extra ID on the root - // and working up from there (Thanks to Andrew Dupont for the technique) - // IE 8 doesn't work on object elements - } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { - var oldContext = context, - old = context.getAttribute( "id" ), - nid = old || id, - hasParent = context.parentNode, - relativeHierarchySelector = /^\s*[+~]/.test( query ); - - if ( !old ) { - context.setAttribute( "id", nid ); - } else { - nid = nid.replace( /'/g, "\\$&" ); - } - if ( relativeHierarchySelector && hasParent ) { - context = context.parentNode; - } - - try { - if ( !relativeHierarchySelector || hasParent ) { - return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra ); - } - - } catch(pseudoError) { - } finally { - if ( !old ) { - oldContext.removeAttribute( "id" ); - } - } - } - } - - return oldSizzle(query, context, extra, seed); - }; - - for ( var prop in oldSizzle ) { - Sizzle[ prop ] = oldSizzle[ prop ]; - } - - // release memory in IE - div = null; - })(); -} - -(function(){ - var html = document.documentElement, - matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector; - - if ( matches ) { - // Check to see if it's possible to do matchesSelector - // on a disconnected node (IE 9 fails this) - var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ), - pseudoWorks = false; - - try { - // This should fail with an exception - // Gecko does not error, returns false instead - matches.call( document.documentElement, "[test!='']:sizzle" ); - - } catch( pseudoError ) { - pseudoWorks = true; - } - - Sizzle.matchesSelector = function( node, expr ) { - // Make sure that attribute selectors are quoted - expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); - - if ( !Sizzle.isXML( node ) ) { - try { - if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { - var ret = matches.call( node, expr ); - - // IE 9's matchesSelector returns false on disconnected nodes - if ( ret || !disconnectedMatch || - // As well, disconnected nodes are said to be in a document - // fragment in IE 9, so check for that - node.document && node.document.nodeType !== 11 ) { - return ret; - } - } - } catch(e) {} - } - - return Sizzle(expr, null, null, [node]).length > 0; - }; - } -})(); - -(function(){ - var div = document.createElement("div"); - - div.innerHTML = "
"; - - // Opera can't find a second classname (in 9.6) - // Also, make sure that getElementsByClassName actually exists - if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) { - return; - } - - // Safari caches class attributes, doesn't catch changes (in 3.2) - div.lastChild.className = "e"; - - if ( div.getElementsByClassName("e").length === 1 ) { - return; - } - - Expr.order.splice(1, 0, "CLASS"); - Expr.find.CLASS = function( match, context, isXML ) { - if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { - return context.getElementsByClassName(match[1]); - } - }; - - // release memory in IE - div = null; -})(); - -function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { - for ( var i = 0, l = checkSet.length; i < l; i++ ) { - var elem = checkSet[i]; - - if ( elem ) { - var match = false; - - elem = elem[dir]; - - while ( elem ) { - if ( elem.sizcache === doneName ) { - match = checkSet[elem.sizset]; - break; - } - - if ( elem.nodeType === 1 && !isXML ){ - elem.sizcache = doneName; - elem.sizset = i; - } - - if ( elem.nodeName.toLowerCase() === cur ) { - match = elem; - break; - } - - elem = elem[dir]; - } - - checkSet[i] = match; - } - } -} - -function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { - for ( var i = 0, l = checkSet.length; i < l; i++ ) { - var elem = checkSet[i]; - - if ( elem ) { - var match = false; - - elem = elem[dir]; - - while ( elem ) { - if ( elem.sizcache === doneName ) { - match = checkSet[elem.sizset]; - break; - } - - if ( elem.nodeType === 1 ) { - if ( !isXML ) { - elem.sizcache = doneName; - elem.sizset = i; - } - - if ( typeof cur !== "string" ) { - if ( elem === cur ) { - match = true; - break; - } - - } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { - match = elem; - break; - } - } - - elem = elem[dir]; - } - - checkSet[i] = match; - } - } -} - -if ( document.documentElement.contains ) { - Sizzle.contains = function( a, b ) { - return a !== b && (a.contains ? a.contains(b) : true); - }; - -} else if ( document.documentElement.compareDocumentPosition ) { - Sizzle.contains = function( a, b ) { - return !!(a.compareDocumentPosition(b) & 16); - }; - -} else { - Sizzle.contains = function() { - return false; - }; -} - -Sizzle.isXML = function( elem ) { - // documentElement is verified for cases where it doesn't yet exist - // (such as loading iframes in IE - #4833) - var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; - - return documentElement ? documentElement.nodeName !== "HTML" : false; -}; - -var posProcess = function( selector, context ) { - var match, - tmpSet = [], - later = "", - root = context.nodeType ? [context] : context; - - // Position selectors must be done after the filter - // And so must :not(positional) so we move all PSEUDOs to the end - while ( (match = Expr.match.PSEUDO.exec( selector )) ) { - later += match[0]; - selector = selector.replace( Expr.match.PSEUDO, "" ); - } - - selector = Expr.relative[selector] ? selector + "*" : selector; - - for ( var i = 0, l = root.length; i < l; i++ ) { - Sizzle( selector, root[i], tmpSet ); - } - - return Sizzle.filter( later, tmpSet ); -}; - -// EXPOSE -jQuery.find = Sizzle; -jQuery.expr = Sizzle.selectors; -jQuery.expr[":"] = jQuery.expr.filters; -jQuery.unique = Sizzle.uniqueSort; -jQuery.text = Sizzle.getText; -jQuery.isXMLDoc = Sizzle.isXML; -jQuery.contains = Sizzle.contains; - - -})(); - - -var runtil = /Until$/, - rparentsprev = /^(?:parents|prevUntil|prevAll)/, - // Note: This RegExp should be improved, or likely pulled from Sizzle - rmultiselector = /,/, - isSimple = /^.[^:#\[\.,]*$/, - slice = Array.prototype.slice, - POS = jQuery.expr.match.POS, - // methods guaranteed to produce a unique set when starting from a unique set - guaranteedUnique = { - children: true, - contents: true, - next: true, - prev: true - }; - -jQuery.fn.extend({ - find: function( selector ) { - var self = this, - i, l; - - if ( typeof selector !== "string" ) { - return jQuery( selector ).filter(function() { - for ( i = 0, l = self.length; i < l; i++ ) { - if ( jQuery.contains( self[ i ], this ) ) { - return true; - } - } - }); - } - - var ret = this.pushStack( "", "find", selector ), - length, n, r; - - for ( i = 0, l = this.length; i < l; i++ ) { - length = ret.length; - jQuery.find( selector, this[i], ret ); - - if ( i > 0 ) { - // Make sure that the results are unique - for ( n = length; n < ret.length; n++ ) { - for ( r = 0; r < length; r++ ) { - if ( ret[r] === ret[n] ) { - ret.splice(n--, 1); - break; - } - } - } - } - } - - return ret; - }, - - has: function( target ) { - var targets = jQuery( target ); - return this.filter(function() { - for ( var i = 0, l = targets.length; i < l; i++ ) { - if ( jQuery.contains( this, targets[i] ) ) { - return true; - } - } - }); - }, - - not: function( selector ) { - return this.pushStack( winnow(this, selector, false), "not", selector); - }, - - filter: function( selector ) { - return this.pushStack( winnow(this, selector, true), "filter", selector ); - }, - - is: function( selector ) { - return !!selector && ( typeof selector === "string" ? - jQuery.filter( selector, this ).length > 0 : - this.filter( selector ).length > 0 ); - }, - - closest: function( selectors, context ) { - var ret = [], i, l, cur = this[0]; - - // Array - if ( jQuery.isArray( selectors ) ) { - var match, selector, - matches = {}, - level = 1; - - if ( cur && selectors.length ) { - for ( i = 0, l = selectors.length; i < l; i++ ) { - selector = selectors[i]; - - if ( !matches[ selector ] ) { - matches[ selector ] = POS.test( selector ) ? - jQuery( selector, context || this.context ) : - selector; - } - } - - while ( cur && cur.ownerDocument && cur !== context ) { - for ( selector in matches ) { - match = matches[ selector ]; - - if ( match.jquery ? match.index( cur ) > -1 : jQuery( cur ).is( match ) ) { - ret.push({ selector: selector, elem: cur, level: level }); - } - } - - cur = cur.parentNode; - level++; - } - } - - return ret; - } - - // String - var pos = POS.test( selectors ) || typeof selectors !== "string" ? - jQuery( selectors, context || this.context ) : - 0; - - for ( i = 0, l = this.length; i < l; i++ ) { - cur = this[i]; - - while ( cur ) { - if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { - ret.push( cur ); - break; - - } else { - cur = cur.parentNode; - if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) { - break; - } - } - } - } - - ret = ret.length > 1 ? jQuery.unique( ret ) : ret; - - return this.pushStack( ret, "closest", selectors ); - }, - - // Determine the position of an element within - // the matched set of elements - index: function( elem ) { - if ( !elem || typeof elem === "string" ) { - return jQuery.inArray( this[0], - // If it receives a string, the selector is used - // If it receives nothing, the siblings are used - elem ? jQuery( elem ) : this.parent().children() ); - } - // Locate the position of the desired element - return jQuery.inArray( - // If it receives a jQuery object, the first element is used - elem.jquery ? elem[0] : elem, this ); - }, - - add: function( selector, context ) { - var set = typeof selector === "string" ? - jQuery( selector, context ) : - jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), - all = jQuery.merge( this.get(), set ); - - return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? - all : - jQuery.unique( all ) ); - }, - - andSelf: function() { - return this.add( this.prevObject ); - } -}); - -// A painfully simple check to see if an element is disconnected -// from a document (should be improved, where feasible). -function isDisconnected( node ) { - return !node || !node.parentNode || node.parentNode.nodeType === 11; -} - -jQuery.each({ - parent: function( elem ) { - var parent = elem.parentNode; - return parent && parent.nodeType !== 11 ? parent : null; - }, - parents: function( elem ) { - return jQuery.dir( elem, "parentNode" ); - }, - parentsUntil: function( elem, i, until ) { - return jQuery.dir( elem, "parentNode", until ); - }, - next: function( elem ) { - return jQuery.nth( elem, 2, "nextSibling" ); - }, - prev: function( elem ) { - return jQuery.nth( elem, 2, "previousSibling" ); - }, - nextAll: function( elem ) { - return jQuery.dir( elem, "nextSibling" ); - }, - prevAll: function( elem ) { - return jQuery.dir( elem, "previousSibling" ); - }, - nextUntil: function( elem, i, until ) { - return jQuery.dir( elem, "nextSibling", until ); - }, - prevUntil: function( elem, i, until ) { - return jQuery.dir( elem, "previousSibling", until ); - }, - siblings: function( elem ) { - return jQuery.sibling( elem.parentNode.firstChild, elem ); - }, - children: function( elem ) { - return jQuery.sibling( elem.firstChild ); - }, - contents: function( elem ) { - return jQuery.nodeName( elem, "iframe" ) ? - elem.contentDocument || elem.contentWindow.document : - jQuery.makeArray( elem.childNodes ); - } -}, function( name, fn ) { - jQuery.fn[ name ] = function( until, selector ) { - var ret = jQuery.map( this, fn, until ), - // The variable 'args' was introduced in - // https://github.com/jquery/jquery/commit/52a0238 - // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed. - // http://code.google.com/p/v8/issues/detail?id=1050 - args = slice.call(arguments); - - if ( !runtil.test( name ) ) { - selector = until; - } - - if ( selector && typeof selector === "string" ) { - ret = jQuery.filter( selector, ret ); - } - - ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; - - if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { - ret = ret.reverse(); - } - - return this.pushStack( ret, name, args.join(",") ); - }; -}); - -jQuery.extend({ - filter: function( expr, elems, not ) { - if ( not ) { - expr = ":not(" + expr + ")"; - } - - return elems.length === 1 ? - jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : - jQuery.find.matches(expr, elems); - }, - - dir: function( elem, dir, until ) { - var matched = [], - cur = elem[ dir ]; - - while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { - if ( cur.nodeType === 1 ) { - matched.push( cur ); - } - cur = cur[dir]; - } - return matched; - }, - - nth: function( cur, result, dir, elem ) { - result = result || 1; - var num = 0; - - for ( ; cur; cur = cur[dir] ) { - if ( cur.nodeType === 1 && ++num === result ) { - break; - } - } - - return cur; - }, - - sibling: function( n, elem ) { - var r = []; - - for ( ; n; n = n.nextSibling ) { - if ( n.nodeType === 1 && n !== elem ) { - r.push( n ); - } - } - - return r; - } -}); - -// Implement the identical functionality for filter and not -function winnow( elements, qualifier, keep ) { - - // Can't pass null or undefined to indexOf in Firefox 4 - // Set to 0 to skip string check - qualifier = qualifier || 0; - - if ( jQuery.isFunction( qualifier ) ) { - return jQuery.grep(elements, function( elem, i ) { - var retVal = !!qualifier.call( elem, i, elem ); - return retVal === keep; - }); - - } else if ( qualifier.nodeType ) { - return jQuery.grep(elements, function( elem, i ) { - return (elem === qualifier) === keep; - }); - - } else if ( typeof qualifier === "string" ) { - var filtered = jQuery.grep(elements, function( elem ) { - return elem.nodeType === 1; - }); - - if ( isSimple.test( qualifier ) ) { - return jQuery.filter(qualifier, filtered, !keep); - } else { - qualifier = jQuery.filter( qualifier, filtered ); - } - } - - return jQuery.grep(elements, function( elem, i ) { - return (jQuery.inArray( elem, qualifier ) >= 0) === keep; - }); -} - - - - -var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, - rleadingWhitespace = /^\s+/, - rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig, - rtagName = /<([\w:]+)/, - rtbody = /", "" ], - legend: [ 1, "
", "
" ], - thead: [ 1, "", "
" ], - tr: [ 2, "", "
" ], - td: [ 3, "", "
" ], - col: [ 2, "", "
" ], - area: [ 1, "", "" ], - _default: [ 0, "", "" ] - }; - -wrapMap.optgroup = wrapMap.option; -wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; -wrapMap.th = wrapMap.td; - -// IE can't serialize and - {% include_stylehseets "common" %} + {% include_stylesheets "common" %} {% block head_js %} {% include_javascripts "common" %} {% endblock head_js %} diff --git a/templates/mobile/mobile_workspace.xhtml b/templates/mobile/mobile_workspace.xhtml index fa7826edd..f0468aaf0 100644 --- a/templates/mobile/mobile_workspace.xhtml +++ b/templates/mobile/mobile_workspace.xhtml @@ -1,4 +1,4 @@ -{% load compressed utils_tags %} +{% load utils_tags %} @@ -32,7 +32,7 @@ }; - {% include_stylehseets "mobile" %} + {% include_stylesheets "mobile" %} {% block head_js %} {% include_javascripts "mobile" %} {% endblock head_js %} diff --git a/templates/reader/paypal_return.xhtml b/templates/reader/paypal_return.xhtml index 2709e22f4..b83374bf4 100644 --- a/templates/reader/paypal_return.xhtml +++ b/templates/reader/paypal_return.xhtml @@ -1,9 +1,9 @@ {% extends 'base.html' %} -{% load typogrify_tags compressed %} +{% load typogrify_tags utils_tags %} {% block extra_head_js %} - {% include_stylehseets "paypal" %} + {% include_stylesheets "paypal" %} {% include_javascripts "paypal" %} {% endblock %} diff --git a/urls.py b/urls.py index 03d72857b..948c5d1e7 100644 --- a/urls.py +++ b/urls.py @@ -27,3 +27,7 @@ if settings.DEVELOPMENT: (r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), ) + urlpatterns += patterns('', + (r'^static/(?P.*)$', 'django.views.static.serve', + {'document_root': settings.STATIC_ROOT}), + ) diff --git a/utils/jammit.py b/utils/jammit.py index 4fb215fae..1743ce121 100644 --- a/utils/jammit.py +++ b/utils/jammit.py @@ -34,7 +34,7 @@ class JammitAssets: `use_compressed_assets` profile setting. """ tags = [] - if settings.DEBUG: + if not settings.DEBUG: if asset_type == 'javascripts': asset_type_ext = 'js' elif asset_type == 'stylesheets': @@ -75,7 +75,7 @@ class JammitAssets: return '' % path def javascript_tag_compressed(self, asset_package, asset_type_ext): - filename = 'static/assets/%s.%s' % (asset_package, asset_type_ext) + filename = 'static/%s.%s' % (asset_package, asset_type_ext) asset_mtime = int(os.path.getmtime(filename)) path = '/%s?%s' % (filename, asset_mtime) return self.javascript_tag(path) @@ -84,8 +84,8 @@ class JammitAssets: return '' % path def stylesheet_tag_compressed(self, asset_package, asset_type_ext): - datauri_filename = 'static/assets/%s-datauri.%s' % (asset_package, asset_type_ext) - original_filename = 'static/assets/%s.%s' % (asset_package, asset_type_ext) + datauri_filename = 'static/%s-datauri.%s' % (asset_package, asset_type_ext) + original_filename = 'static/%s.%s' % (asset_package, asset_type_ext) asset_mtime = int(os.path.getmtime(datauri_filename)) datauri_path = '/%s?%s' % (datauri_filename, asset_mtime) original_path = '/%s?%s' % (original_filename, asset_mtime) diff --git a/utils/templatetags/utils_tags.py b/utils/templatetags/utils_tags.py index 3693e99a1..ecc06aead 100644 --- a/utils/templatetags/utils_tags.py +++ b/utils/templatetags/utils_tags.py @@ -80,18 +80,14 @@ def commify(n): @register.simple_tag -def include_javascripts(): +def include_javascripts(asset_package): """Prints out a template of