From 476c09661f3c7d1ed75b5a8d41b04bd0d825f6e0 Mon Sep 17 00:00:00 2001 From: Emmanuel H Date: Sun, 17 Dec 2017 10:22:50 +0100 Subject: [PATCH 001/473] change labels of buttons to filter by day number AFTER : "1" NOW : "Day 1" --- www/templates/www/event.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/templates/www/event.html b/www/templates/www/event.html index 432aac35..7f06a84e 100644 --- a/www/templates/www/event.html +++ b/www/templates/www/event.html @@ -34,7 +34,7 @@

{{my_event.title}}{% if my_event.
{% for day in my_event.event_days_set.all %} - + {% endfor %}
From 6178b4b770aeb565b52e50125fc0508e41cce317 Mon Sep 17 00:00:00 2001 From: Maximilian Marx Date: Wed, 27 Dec 2017 12:44:00 +0100 Subject: [PATCH 002/473] Add script to convert to pad format from SBV captions --- pad_from_youtube.py | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 pad_from_youtube.py diff --git a/pad_from_youtube.py b/pad_from_youtube.py new file mode 100644 index 00000000..1ea48fc6 --- /dev/null +++ b/pad_from_youtube.py @@ -0,0 +1,48 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +import os +import sys +import re + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "subtitleStatus.settings") + +import django +django.setup() +from django.core.management.base import BaseCommand, CommandError +from django.db import transaction +from django.core.exceptions import ObjectDoesNotExist + +from www.models import Talk, Language, Subtitle + +def chunks(file): + """Read `file`, splitting it at doubled linebreaks""" + lines = [] + for line in file: + lines.append(re.sub(' {2,}', ' ', line.strip())) + return '\n'.join(lines).split('\n\n') + +if __name__ == '__main__': + if len(sys.argv) != 2: + sys.exit("usage: ./{} transcript.sbv".format(sys.argv[0])) + + transcript = [] + try: + with open(sys.argv[1], 'r') as file: + transcript = chunks(file) + except IOError as err: + sys.exit("Transcript not readable: {}").format(err) + + out = "" + + for chunk in transcript: + lines = chunk.split('\n') + + for line in lines[1:]: + if line[0] == '[' and line[-1] == ']': + # keep this as a separate line + out += '\n' + line + '\n' + else: + out += ' ' + line + + print(out) From 7cfd8b0a1a86e4dc90431d6bcf5f82d75d7e9440 Mon Sep 17 00:00:00 2001 From: Maximilian Marx Date: Wed, 27 Dec 2017 13:04:24 +0100 Subject: [PATCH 003/473] Fix handling of empty lines --- pad_from_youtube.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pad_from_youtube.py b/pad_from_youtube.py index 1ea48fc6..d9e332d0 100644 --- a/pad_from_youtube.py +++ b/pad_from_youtube.py @@ -39,10 +39,12 @@ def chunks(file): lines = chunk.split('\n') for line in lines[1:]: + if line == '': + continue if line[0] == '[' and line[-1] == ']': # keep this as a separate line out += '\n' + line + '\n' else: out += ' ' + line - print(out) + print(out.replace('\n\n', '\n')) From 80a6d6cbb63b046770c03d4d885429b64540942b Mon Sep 17 00:00:00 2001 From: Maximilian Marx Date: Wed, 27 Dec 2017 13:07:19 +0100 Subject: [PATCH 004/473] Clean up unused imports --- pad_from_youtube.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/pad_from_youtube.py b/pad_from_youtube.py index d9e332d0..f8c37231 100644 --- a/pad_from_youtube.py +++ b/pad_from_youtube.py @@ -1,20 +1,9 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -import os import sys import re -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "subtitleStatus.settings") - -import django -django.setup() -from django.core.management.base import BaseCommand, CommandError -from django.db import transaction -from django.core.exceptions import ObjectDoesNotExist - -from www.models import Talk, Language, Subtitle - def chunks(file): """Read `file`, splitting it at doubled linebreaks""" lines = [] From e78db40a35131aafb97053cd8cdfe8a1941bf997 Mon Sep 17 00:00:00 2001 From: Maximilian Marx Date: Wed, 27 Dec 2017 13:12:00 +0100 Subject: [PATCH 005/473] Add script to convert to pad format from trint SRT --- pad_from_trint.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 pad_from_trint.py diff --git a/pad_from_trint.py b/pad_from_trint.py new file mode 100644 index 00000000..763ab395 --- /dev/null +++ b/pad_from_trint.py @@ -0,0 +1,35 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +import sys +import re + +def chunks(file): + """Read `file`, splitting it at doubled linebreaks""" + lines = [] + for line in file: + lines.append(re.sub(' {2,}', ' ', line.strip())) + return '\n'.join(lines).split('\n\n') + +if __name__ == '__main__': + if len(sys.argv) != 2: + sys.exit("usage: ./{} transcript.sbv".format(sys.argv[0])) + + transcript = [] + try: + with open(sys.argv[1], 'r') as file: + transcript = chunks(file) + except IOError as err: + sys.exit("Transcript not readable: {}").format(err) + + out = "" + + for chunk in transcript: + lines = chunk.split('\n') + + for line in lines[2:]: + if line == '': + continue + out += ' ' + line + + print(out.replace('\n\n', '\n')) From 98b5d4c7f5bfdf5f9f3666a198ecb6bc9dffb2ac Mon Sep 17 00:00:00 2001 From: Maximilian Marx Date: Wed, 27 Dec 2017 15:30:00 +0100 Subject: [PATCH 006/473] Add script to convert pad format into timing format --- timing_from_pad.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 timing_from_pad.py diff --git a/timing_from_pad.py b/timing_from_pad.py new file mode 100644 index 00000000..f78760f8 --- /dev/null +++ b/timing_from_pad.py @@ -0,0 +1,27 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +import sys +import re +import textwrap + +if __name__ == '__main__': + if len(sys.argv) != 2: + sys.exit("usage: ./{} transcript".format(sys.argv[0])) + + transcript = [] + try: + with open(sys.argv[1], 'r') as file: + for line in file: + if line == '': + continue + elif line[0] == '*' and line[-1] == '*': + transcript.append(line) + else: + transcript.extend(textwrap.fill(line, width=42).split('\n')) + except IOError as err: + sys.exit("Transcript not readable: {}").format(err) + + chunks = ["\n".join([transcript[i], transcript[i + 1]]) for i in range(0, len(transcript), 2)] + + print("\n".join(chunks)) From c8cfbb32261befc46c443205838dccccf5b66867 Mon Sep 17 00:00:00 2001 From: Maximilian Marx Date: Wed, 27 Dec 2017 16:06:53 +0100 Subject: [PATCH 007/473] Fix linebreaks --- timing_from_pad.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/timing_from_pad.py b/timing_from_pad.py index f78760f8..a3988180 100644 --- a/timing_from_pad.py +++ b/timing_from_pad.py @@ -22,6 +22,6 @@ except IOError as err: sys.exit("Transcript not readable: {}").format(err) - chunks = ["\n".join([transcript[i], transcript[i + 1]]) for i in range(0, len(transcript), 2)] + chunks = ["\n".join([transcript[i], transcript[i + 1], '']) for i in range(0, len(transcript), 2)] print("\n".join(chunks)) From 6155a91447173773924615005c2151e5894f94a3 Mon Sep 17 00:00:00 2001 From: Maximilian Marx Date: Wed, 27 Dec 2017 17:05:04 +0100 Subject: [PATCH 008/473] Fix timing script --- timing_from_pad.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/timing_from_pad.py b/timing_from_pad.py index a3988180..26027270 100644 --- a/timing_from_pad.py +++ b/timing_from_pad.py @@ -22,6 +22,17 @@ except IOError as err: sys.exit("Transcript not readable: {}").format(err) - chunks = ["\n".join([transcript[i], transcript[i + 1], '']) for i in range(0, len(transcript), 2)] + length = len(transcript) + odd = False - print("\n".join(chunks)) + if length % 2 == 1: + length -= 1 + odd = True + + chunks = ["\n".join([transcript[i], transcript[i + 1], '']) + for i in range(0, length, 2)] + + if odd: + chunks.append(transcript[-1]) + + print("\n".join(chunks).replace("\n\n\n", "\n\n")) From 55ce17b5fbf924d6541aff803a8cbd22a0c77e62 Mon Sep 17 00:00:00 2001 From: Maximilian Marx Date: Fri, 29 Dec 2017 19:48:07 +0100 Subject: [PATCH 009/473] Fix typo --- www/templates/www/main.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/templates/www/main.html b/www/templates/www/main.html index b1db2cef..3a6221a6 100644 --- a/www/templates/www/main.html +++ b/www/templates/www/main.html @@ -54,7 +54,7 @@

Statistics:

{{every_statistics.language.display_name}}:
{{every_statistics.average_wpm | floatformat:-1}} wpm
{{every_statistics.average_spm | floatformat:-1}} spm
-
+
{% common_words_cloud item=every_statistics height="18em" container=event.pk %} From d2557500f55d1267867a269b9080ea7ef8fa2359 Mon Sep 17 00:00:00 2001 From: Jenny Danzmayr Date: Fri, 26 Jan 2018 23:36:25 +0100 Subject: [PATCH 010/473] added suport for external config file to settings.py --- .gitignore | 1 + subtitleStatus/settings.py | 30 +++++++++++++++++++---- subtitleStatus/subtitleStauts.cfg.example | 4 +++ 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 subtitleStatus/subtitleStauts.cfg.example diff --git a/.gitignore b/.gitignore index 0824dd8d..98e983cd 100755 --- a/.gitignore +++ b/.gitignore @@ -89,3 +89,4 @@ data_dump.py # Sync Folder subtitles_sync_folder subtitles_sync_folder/* +subtitleStatus/subtitleStauts.cfg diff --git a/subtitleStatus/settings.py b/subtitleStatus/settings.py index ca7a488b..572d3fb4 100755 --- a/subtitleStatus/settings.py +++ b/subtitleStatus/settings.py @@ -10,17 +10,37 @@ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os +import configparser +from django.utils.crypto import get_random_string + BASE_DIR = os.path.dirname(os.path.dirname(__file__)) PROJECT_ROOT = BASE_DIR TEMPLATE_DIRS = [PROJECT_ROOT+'/templates'] +config = configparser.RawConfigParser() +config.read([os.path.join(BASE_DIR, 'subtitleStatus.cfg'), '/etc/billing/subtitleStatus.cfg', + os.path.expanduser('~/.subtitleStatus.cfg'), + os.environ.get('SUBTITLESTATUS_CONFIG', 'subtitleStatus.cfg')], + encoding='utf-8') # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'YOUR SECRET KEY' +if config.has_option('django', 'secret'): + SECRET_KEY = config.get('django', 'secret') +else: + SECRET_FILE = os.path.join(os.path.dirname(__file__), '.secret') + if os.path.exists(SECRET_FILE): + with open(SECRET_FILE, 'r') as f: + SECRET_KEY = f.read().strip() + else: + SECRET_KEY = get_random_string(50, string.printable) + with open(SECRET_FILE, 'w') as f: + os.chmod(SECRET_FILE, 0o600) + os.chown(SECRET_FILE, os.getuid(), os.getgid()) + f.write(SECRET_KEY) # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False @@ -68,10 +88,10 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': 'subtitlestatus', - 'USER': 'subtitlestatus', - 'PASSWORD': 'YOUR PASWORD', - 'HOST': 'localhost' + 'NAME': config.get('sql', 'database', fallback='subtitlestatus'), + 'USER': config.get('sql', 'user', fallback='subtitlestatus'), + 'PASSWORD': config.get('sql', 'password'), + 'HOST': config.get('sql', 'host', fallback='localhost'), } } diff --git a/subtitleStatus/subtitleStauts.cfg.example b/subtitleStatus/subtitleStauts.cfg.example new file mode 100644 index 00000000..f9c2bcb8 --- /dev/null +++ b/subtitleStatus/subtitleStauts.cfg.example @@ -0,0 +1,4 @@ +[sql] +database=subtitlestatus +user=subtitlestatus +password=a_very_secure_password \ No newline at end of file From 14c30ef0d47c4d784f6a27113fafeb358567dde0 Mon Sep 17 00:00:00 2001 From: Jenny Danzmayr Date: Fri, 26 Jan 2018 23:53:45 +0100 Subject: [PATCH 011/473] fixed imports and path of config file in settings.py --- subtitleStatus/settings.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subtitleStatus/settings.py b/subtitleStatus/settings.py index 572d3fb4..9648954d 100755 --- a/subtitleStatus/settings.py +++ b/subtitleStatus/settings.py @@ -11,6 +11,7 @@ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os import configparser +import string from django.utils.crypto import get_random_string BASE_DIR = os.path.dirname(os.path.dirname(__file__)) @@ -19,7 +20,7 @@ TEMPLATE_DIRS = [PROJECT_ROOT+'/templates'] config = configparser.RawConfigParser() -config.read([os.path.join(BASE_DIR, 'subtitleStatus.cfg'), '/etc/billing/subtitleStatus.cfg', +config.read([os.path.join(os.path.dirname(__file__), 'subtitleStatus.cfg'), '/etc/billing/subtitleStatus.cfg', os.path.expanduser('~/.subtitleStatus.cfg'), os.environ.get('SUBTITLESTATUS_CONFIG', 'subtitleStatus.cfg')], encoding='utf-8') From 5f85828b118246f7f633f2521bc529580bdbea2c Mon Sep 17 00:00:00 2001 From: Jenny Danzmayr Date: Sat, 27 Jan 2018 00:04:18 +0100 Subject: [PATCH 012/473] added .secret file to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 98e983cd..274d159f 100755 --- a/.gitignore +++ b/.gitignore @@ -90,3 +90,4 @@ data_dump.py subtitles_sync_folder subtitles_sync_folder/* subtitleStatus/subtitleStauts.cfg +.secret From bc6302db81374bc8c9bdadb6e2fa631e05e3094c Mon Sep 17 00:00:00 2001 From: Jenny Danzmayr Date: Sat, 27 Jan 2018 00:05:26 +0100 Subject: [PATCH 013/473] added support for other database types in settings.py, fixed typo --- subtitleStatus/settings.py | 31 ++++++++++++++----- ...cfg.example => subtitleStatus.cfg.example} | 1 + 2 files changed, 25 insertions(+), 7 deletions(-) rename subtitleStatus/{subtitleStauts.cfg.example => subtitleStatus.cfg.example} (83%) diff --git a/subtitleStatus/settings.py b/subtitleStatus/settings.py index 9648954d..7781095e 100755 --- a/subtitleStatus/settings.py +++ b/subtitleStatus/settings.py @@ -86,15 +86,32 @@ # Database # https://docs.djangoproject.com/en/1.6/ref/settings/#databases -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': config.get('sql', 'database', fallback='subtitlestatus'), - 'USER': config.get('sql', 'user', fallback='subtitlestatus'), +# database configuration from config file +if config.get('sql', 'type', fallback='sqlite').lower() == 'sqlite': + DATABASES['default'] = { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'billing_db.sqlite3'), + } +elif config.get('sql', 'type').lower() == 'postgresql': + DATABASES['default'] = { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': config.get('sql', 'database'), + 'USER': config.get('sql', 'user'), + 'PASSWORD': config.get('sql', 'password'), + 'HOST': config.get('sql', 'host', fallback=''), + 'PORT': config.get('sql', 'port', fallback='') + } +elif config.get('sql', 'type').lower() == 'mysql': + DATABASES['default'] = { + 'ENGINE': 'django.db.backends.mysql', + 'NAME': config.get('sql', 'database'), + 'USER': config.get('sql', 'user'), 'PASSWORD': config.get('sql', 'password'), - 'HOST': config.get('sql', 'host', fallback='localhost'), + 'HOST': config.get('sql', 'host', fallback=''), + 'PORT': config.get('sql', 'port', fallback='') } -} +else: + raise ValueError('invalid database type "%s"' % config.get('sql', 'type').lower()) # Internationalization # https://docs.djangoproject.com/en/1.6/topics/i18n/ diff --git a/subtitleStatus/subtitleStauts.cfg.example b/subtitleStatus/subtitleStatus.cfg.example similarity index 83% rename from subtitleStatus/subtitleStauts.cfg.example rename to subtitleStatus/subtitleStatus.cfg.example index f9c2bcb8..810ea816 100644 --- a/subtitleStatus/subtitleStauts.cfg.example +++ b/subtitleStatus/subtitleStatus.cfg.example @@ -1,4 +1,5 @@ [sql] +type=postgresql database=subtitlestatus user=subtitlestatus password=a_very_secure_password \ No newline at end of file From 4a08d4ca1d7ea31024a16fac5bc20902c2ff2dc8 Mon Sep 17 00:00:00 2001 From: Jenny Danzmayr Date: Sat, 27 Jan 2018 00:09:17 +0100 Subject: [PATCH 014/473] fixed missing definition of DATABASES dict --- subtitleStatus/settings.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/subtitleStatus/settings.py b/subtitleStatus/settings.py index 7781095e..d6838783 100755 --- a/subtitleStatus/settings.py +++ b/subtitleStatus/settings.py @@ -86,6 +86,8 @@ # Database # https://docs.djangoproject.com/en/1.6/ref/settings/#databases +DATABASES = {} + # database configuration from config file if config.get('sql', 'type', fallback='sqlite').lower() == 'sqlite': DATABASES['default'] = { From d23b5d0e9771f0d740009295b8b664eada9d89b7 Mon Sep 17 00:00:00 2001 From: Jenny Danzmayr Date: Sat, 27 Jan 2018 00:16:06 +0100 Subject: [PATCH 015/473] fixed wrong postgres DB engine in settings.py --- subtitleStatus/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subtitleStatus/settings.py b/subtitleStatus/settings.py index d6838783..82c5af79 100755 --- a/subtitleStatus/settings.py +++ b/subtitleStatus/settings.py @@ -96,7 +96,7 @@ } elif config.get('sql', 'type').lower() == 'postgresql': DATABASES['default'] = { - 'ENGINE': 'django.db.backends.postgresql', + 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': config.get('sql', 'database'), 'USER': config.get('sql', 'user'), 'PASSWORD': config.get('sql', 'password'), From d771963568bc4c239811e57656d5a6c915e99669 Mon Sep 17 00:00:00 2001 From: percidae Date: Sun, 28 Jan 2018 22:21:36 +0100 Subject: [PATCH 016/473] New model 'Transcript' added and a ForeignKey in the model Talk to it --- www/models.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/www/models.py b/www/models.py index 8ab3fa2c..4aab5383 100755 --- a/www/models.py +++ b/www/models.py @@ -262,12 +262,9 @@ class Speaker_Links(BasisModell): url = models.URLField(blank = True) -""" -# Where is the Transcipt from +# Where is the Transcipt from, autogenerated or handmade class Transcript (BasisModell): - creator = models.CharField(max_length = 20, default = None, blank = True) # None, trint, youtube, scribie, handmade ... - -""" + creator = models.CharField(max_length = 20, blank = True, null = True) # None, trint, youtube, scribie, handmade ..., default with id=0 is None # Talk with all its data @@ -317,7 +314,7 @@ class Talk(BasisModell): n_most_frequent_words_speakers = models.TextField(default = "{}") # n most common words as json string transcript_from_trint = models.BooleanField(default = False) # If the transcript was from trint has_priority = models.BooleanField(default = False) # If the talk has priority because it was requested by someone - #transcript_by = models.ForeignKey(Transcript, default = 0) + transcript_by = models.ForeignKey(Transcript, default = 0) # Recalculate statistics data over the whole talk @transaction.atomic From 4f91b2148ef84a3c276ffcacb79dcb10475f01d6 Mon Sep 17 00:00:00 2001 From: percidae Date: Sun, 28 Jan 2018 22:22:34 +0100 Subject: [PATCH 017/473] New properties for 'Talk' trancripty_by...t, and flags in talk_small to show them --- www/models.py | 28 ++++++++++++++++++++++++++++ www/templates/www/talk_small.html | 31 +++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/www/models.py b/www/models.py index 4aab5383..a76e4db9 100755 --- a/www/models.py +++ b/www/models.py @@ -498,6 +498,34 @@ def has_original_subtitle_in_transcript_state(self): return True else: return False + + @property + def has_transcript_by_trint(self): + if self.transcript_by.id == 3: + return True + else: + return False + + @property + def has_transcript_by_scribie(self): + if self.transcript_by.id == 4: + return True + else: + return False + + @property + def has_transcript_by_youtube(self): + if self.transcript_by.id == 2: + return True + else: + return False + + @property + def has_transcript_by_human(self): + if self.transcript_by.id == 1: + return True + else: + return False @property def page_sub_titles(self): diff --git a/www/templates/www/talk_small.html b/www/templates/www/talk_small.html index 29cd72b2..cc707d95 100755 --- a/www/templates/www/talk_small.html +++ b/www/templates/www/talk_small.html @@ -33,7 +33,38 @@

{{talk.title}}

{% else %}

No subtitles yet in the language of the presentation.
Start working on them!

{% endif %} + +

+ {% if talk.has_priority %} + + {% endif %} + + {% if talk.has_transcript_by_trint %} + + {% endif %} + + {% if talk.has_transcript_by_scribie %} + + {% endif %} + + {% if talk.has_transcript_by_youtube %} + + {% endif %} +

+ + + + + {% comment %}
  • {{talk.title}}
  • From 19645c2f8e0f9f8a31a296eb33393f7f2e37816c Mon Sep 17 00:00:00 2001 From: percidae Date: Sun, 28 Jan 2018 23:04:55 +0100 Subject: [PATCH 018/473] Removed transcript_by_trint Flag from model Talk, no longer needed --- www/models.py | 1 - 1 file changed, 1 deletion(-) diff --git a/www/models.py b/www/models.py index a76e4db9..0e0589ee 100755 --- a/www/models.py +++ b/www/models.py @@ -312,7 +312,6 @@ class Talk(BasisModell): recalculate_speakers_statistics = models.BooleanField(default = False) n_most_frequent_words = models.TextField(default = "{}") # n most common words as json string n_most_frequent_words_speakers = models.TextField(default = "{}") # n most common words as json string - transcript_from_trint = models.BooleanField(default = False) # If the transcript was from trint has_priority = models.BooleanField(default = False) # If the talk has priority because it was requested by someone transcript_by = models.ForeignKey(Transcript, default = 0) From cb98910b4c92f295f8721af93c14052817b6cef5 Mon Sep 17 00:00:00 2001 From: percidae Date: Sun, 28 Jan 2018 23:05:36 +0100 Subject: [PATCH 019/473] Several new data fields for Talk to refactor the amara updates --- www/models.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/www/models.py b/www/models.py index 0e0589ee..411493dd 100755 --- a/www/models.py +++ b/www/models.py @@ -313,7 +313,12 @@ class Talk(BasisModell): n_most_frequent_words = models.TextField(default = "{}") # n most common words as json string n_most_frequent_words_speakers = models.TextField(default = "{}") # n most common words as json string has_priority = models.BooleanField(default = False) # If the talk has priority because it was requested by someone - transcript_by = models.ForeignKey(Transcript, default = 0) + transcript_by = models.ForeignKey(Transcript, default = 0) # Where is the Transcript from? Handmade, None, Youtube, Trint, Scribie... + amara_activity_last_checked = models.DateTimeField(default = datetime.min, blank = True) # Light check, only amara activity + amara_update_interval = models.TimeField(default = "00:10", blank = True) # How often is activity checked? + amara_complete_update_last_checked = models.DateTimeField(default = datetime.min, blank = True) # Everything checked, activity and data of every single subtitle + needs_complete_amara_update = models.BooleanField(default = False) + next_amara_activity_check = models.DateTimeField(default = datetime.min, blank = True) # Recalculate statistics data over the whole talk @transaction.atomic From 85075acf1622144673225d5f4b70a33973ed3ad8 Mon Sep 17 00:00:00 2001 From: percidae Date: Sun, 28 Jan 2018 23:10:40 +0100 Subject: [PATCH 020/473] New function for Talk 'reset_related_statistics_data' --- www/models.py | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/www/models.py b/www/models.py index 411493dd..e06eeb16 100755 --- a/www/models.py +++ b/www/models.py @@ -400,13 +400,48 @@ def recalculate_speakers_in_talk_statistics(self, force = False): self.n_most_frequent_words_speakers = "{}" self.save() - # Recalculate statistics-data @transaction.atomic def recalculate(self, force = False): self.recalculate_whole_talk_statistics(force) self.recalculate_speakers_in_talk_statistics(force) + # Reset statistics data related to this talk + # Is used for a original_subtitle update + # use hard_reset = True if a subtitle is reset from complete to not complete any more + @transaction.atomic + def reset_related_statistics_data(self, hard_reset = False): + # Set the recalculate flags no matter if hard_reset or not + self.recalculate_talk_statistics = True + self.recalculate_speakers_statistics = True + if hard_reset: + # Reset everything of the talk and directly related to the talk + self.average_spm = None + self.average_wpm = None + self.strokes = None + self.words = None + self.time_delta = None + self.speakers_average_spm = None + self.speakers_average_wpm = None + self.n_most_frequent_words = "{}" + self.n_most_frequent_words_speakers = "{}" + Statistics_Raw_Data.objects.filter(talk = self).update(recalculate_statistics = True, + time_delta = None, + words = None, + strokes = None) + Talk_Persons.objects.filter(talk = self).update(recalculate_statistics = True, + average_spm = None, + average_wpm = None, + words = None, + strokes = None, + time_delta = None, + n_most_frequent_words = "{}") + # If no hard_reset only also set the Statistics_Raw_Data to recalculate and the Talk_Persons Data + else: + Statistics_Raw_Data.objects.filter(talk = self).update(recalculate_statistics = True) + Talk_Persons.objects.filter(talk = self).update(recalculate_statistics = True) + self.save() + # Return the n most common words as dict @property def n_common_words(self): From 8fa30ecb84806360d851cfce82998284a378bc86 Mon Sep 17 00:00:00 2001 From: percidae Date: Sun, 28 Jan 2018 23:13:06 +0100 Subject: [PATCH 021/473] Added new property to talk 'calculated_time_delta' for easier use for amara updates refactoring --- www/models.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/www/models.py b/www/models.py index e06eeb16..0a8ab39c 100755 --- a/www/models.py +++ b/www/models.py @@ -442,6 +442,14 @@ def reset_related_statistics_data(self, hard_reset = False): Talk_Persons.objects.filter(talk = self).update(recalculate_statistics = True) self.save() + # Create a timedelta of the amara_update_interval, for much easier use + @property + def calculated_time_delta_for_activities(self): + return timedelta(seconds = self.amara_update_interval.second, + minutes = self.amara_update_interval.minute, + hours = self.amara_update_interval.hour, + microseconds = self.amara_update_interval.microsecond) + # Return the n most common words as dict @property def n_common_words(self): From 130b9cbc2ceacf1e680e2668ec1d87f5a837d954 Mon Sep 17 00:00:00 2001 From: percidae Date: Thu, 1 Feb 2018 22:52:48 +0100 Subject: [PATCH 022/473] Fixed spelling error --- subtitleStatus/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subtitleStatus/settings.py b/subtitleStatus/settings.py index 82c5af79..7acd972c 100755 --- a/subtitleStatus/settings.py +++ b/subtitleStatus/settings.py @@ -92,7 +92,7 @@ if config.get('sql', 'type', fallback='sqlite').lower() == 'sqlite': DATABASES['default'] = { 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'billing_db.sqlite3'), + 'NAME': os.path.join(BASE_DIR, 'subtitlestatus.sqlite3'), } elif config.get('sql', 'type').lower() == 'postgresql': DATABASES['default'] = { From 214fbfca899c5fa791e195d79b2b657eb2a07453 Mon Sep 17 00:00:00 2001 From: percidae Date: Thu, 1 Feb 2018 22:55:02 +0100 Subject: [PATCH 023/473] Class function for 'Subtitle' 'set_to_autotiming_in_progress' --- www/models.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/www/models.py b/www/models.py index 0a8ab39c..7bf70fcb 100755 --- a/www/models.py +++ b/www/models.py @@ -798,6 +798,28 @@ def remove_subtitle_from_sync_folder(self, force = False): self.save() + # Set to autotiming in progress + @transaction.atomic + def set_to_autotiming_in_progress(self): + # Stop if the subtitle is not the original language + if not self.is_original_lang: + return None + needs_save = False + if self.time_processed_transcribing != self.talk.video_duration: + self.time_processed_transcribing = self.talk.video_duration + needs_save = True + if self.blocked == False: + self.blocked = True + needs_save = True + if self.needs_automatic_syncing == False: + self.needs_automatic_syncing = True + needs_save = True + if self.state_id != 4: + self.state_id = 4 + needs_save = True + if needs_save: + self.save() + return needs_save # Links from the Fahrplan class Links(BasisModell): From ad4d2368abec1feebce95c7d69fec66d10e1b55e Mon Sep 17 00:00:00 2001 From: percidae Date: Thu, 1 Feb 2018 22:55:39 +0100 Subject: [PATCH 024/473] Minor fix --- www/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/models.py b/www/models.py index 7bf70fcb..d21b4725 100755 --- a/www/models.py +++ b/www/models.py @@ -586,7 +586,7 @@ def has_links(self): else: return True - # Override delete function + # Override delete function @transaction.atomic def delete(self, *args, **kwargs): # Delete related Talk_Persons datasets From ad7b6d14bbc331a22aa5cd24fb5930f5c6aedc83 Mon Sep 17 00:00:00 2001 From: percidae Date: Thu, 1 Feb 2018 22:57:51 +0100 Subject: [PATCH 025/473] Timezone and timedelta from datetime are also needed --- www/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/models.py b/www/models.py index d21b4725..a4b3efc2 100755 --- a/www/models.py +++ b/www/models.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from datetime import datetime +from datetime import datetime, timezone, timedelta from django.db import models from django.db.models import Sum, Q from django.core.urlresolvers import reverse From 7abbcfa3decc844e611df79434403243a66bb525 Mon Sep 17 00:00:00 2001 From: percidae Date: Thu, 1 Feb 2018 23:10:28 +0100 Subject: [PATCH 026/473] Minor change --- www/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/models.py b/www/models.py index a4b3efc2..67479294 100755 --- a/www/models.py +++ b/www/models.py @@ -7,6 +7,7 @@ from django.db import transaction from .statistics_helper import * import json +import credentials as cred # Basic model which provides a field for the creation and the last change timestamp class BasisModell(models.Model): @@ -599,7 +600,7 @@ def delete(self, *args, **kwargs): Statistics_Raw_Data.objects.filter(talk = self).delete() # Call super delete function - super(Talk, self).delete(*args, **kwargs) + super(Talk, self).delete(*args, **kwargs) # States for every subtitle like "complete" or "needs sync" From b447474223c64fb22c9cebb2a4a0fec6f8698f5b Mon Sep 17 00:00:00 2001 From: percidae Date: Thu, 1 Feb 2018 23:14:46 +0100 Subject: [PATCH 027/473] Moved the class Talk function 'calculated_time_delta_for_activities' --- www/models.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/www/models.py b/www/models.py index 67479294..d7862f93 100755 --- a/www/models.py +++ b/www/models.py @@ -443,14 +443,6 @@ def reset_related_statistics_data(self, hard_reset = False): Talk_Persons.objects.filter(talk = self).update(recalculate_statistics = True) self.save() - # Create a timedelta of the amara_update_interval, for much easier use - @property - def calculated_time_delta_for_activities(self): - return timedelta(seconds = self.amara_update_interval.second, - minutes = self.amara_update_interval.minute, - hours = self.amara_update_interval.hour, - microseconds = self.amara_update_interval.microsecond) - # Return the n most common words as dict @property def n_common_words(self): @@ -602,6 +594,14 @@ def delete(self, *args, **kwargs): # Call super delete function super(Talk, self).delete(*args, **kwargs) + # Create a timedelta of the amara_update_interval, for much easier use + @property + def calculated_time_delta_for_activities(self): + return timedelta(seconds = self.amara_update_interval.second, + minutes = self.amara_update_interval.minute, + hours = self.amara_update_interval.hour, + microseconds = self.amara_update_interval.microsecond) + # States for every subtitle like "complete" or "needs sync" class States(BasisModell): From ddf2d1f33c90b8f1a1935e24b723c9735a7d1f1b Mon Sep 17 00:00:00 2001 From: percidae Date: Thu, 1 Feb 2018 23:17:28 +0100 Subject: [PATCH 028/473] Added class Talk function 'check_activity_on_amara' --- www/models.py | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/www/models.py b/www/models.py index d7862f93..8c6259bd 100755 --- a/www/models.py +++ b/www/models.py @@ -602,6 +602,73 @@ def calculated_time_delta_for_activities(self): hours = self.amara_update_interval.hour, microseconds = self.amara_update_interval.microsecond) + # Check activity on amara + @transaction.atomic + def check_activity_on_amara(self, force = False): + # Take the timestamp for "last executed at" at the beginning of the function + start_timestamp = datetime.now(timezone.utc) + # Only proceed if forced or if the time delta for another query has passed + if force or (start_timestamp > self.next_amara_activity_check): + import requests + # Only check for new versions. New urls or other stuff is not interesting + # Check for changes after the last check + # If the check is forced, do not care about the last time the activity was checked + if force: + parameters = {'type': 'version-added'} + else: + parameters = {'type': 'version-added', + 'after': self.amara_activity_last_checked} + basis_url = "https://amara.org/api/videos/" + url = basis_url + self.amara_key + "/activity/" + results = {} + # Loop as long as not all new activity datasets have been checked + # The json result from amara includes a "next" field which has the url for the next query if not + # all results came with the first query + while url != None: + r = requests.get(url, headers = cred.AMARA_HEADER, params = parameters) + activities = json.loads(r.text) + url = activities["meta"]["next"] + # Get the results for any language separate + for any in activities["objects"]: + language = any["language"] + # Parse the date time string into a datetime object + timestamp = datetime.strptime(any["date"], '%Y-%m-%dT%H:%M:%SZ') + # Amara Timestamps are all in utc, they just don't know yet, so they need to be force told + timestamp = timestamp.replace(tzinfo = timezone.utc) + # Add the new key to the dictionary and only at insert set the timestamp + results.setdefault(language, timestamp) + # Keep the newest timestamp over all api queries + if results[language] < timestamp: + results[language] = timestamp + #print(results) + # check if subtitles are present and need new data.. + for any_language in results.keys(): + my_subtitles = Subtitle.objects.filter(talk = self, language__lang_amara_short = any_language) + # Set flag for big query, this means a subtitle is missing because it was recently new added + if my_subtitles.count() == 0: + # Set the big update flag + self.needs_complete_amara_update = True + my_language = Language.objects.get(lang_amara_short = any_language) + # Don't create a subtitle here, this will cause subtitles with revision = 0 + #my_subtitle, created = Subtitle.objects.get_or_create(talk = self, language = my_language, last_changed_on_amara = results[any_language]) + print("Talk id: ",self.id, " will get a new created subtitle") + elif my_subtitles.count() == 1: + # Only proceed if the last activity has changed + # The copy is a dirty workaround because saving in my_subtitles[0] did not work! + my_subtitle = my_subtitles[0] + if my_subtitle.last_changed_on_amara < results[any_language]: + my_subtitle.last_changed_on_amara = results[any_language] + # Set the big update flag + self.needs_complete_amara_update = True + my_subtitle.save() + print("Talk id: ",self.id, "Subtitle id: ", my_subtitle.id, " new last changes: ", my_subtitle.last_changed_on_amara ) + else: + print("Something wrong with talk", self.id, self.title) + # Save the timestamp of the start of the function as last checked activity on amara timestamp + self.amara_activity_last_checked = start_timestamp + self.next_amara_activity_check = start_timestamp + self.calculated_time_delta_for_activities + self.save() + # States for every subtitle like "complete" or "needs sync" class States(BasisModell): From 944de32b9dfc5eb456a41c8ff39e92fa5450981c Mon Sep 17 00:00:00 2001 From: percidae Date: Thu, 1 Feb 2018 23:20:20 +0100 Subject: [PATCH 029/473] Added Subtitle function 'set_all_sync_flags' --- www/models.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/www/models.py b/www/models.py index 8c6259bd..65e11e06 100755 --- a/www/models.py +++ b/www/models.py @@ -865,6 +865,15 @@ def remove_subtitle_from_sync_folder(self, force = False): self.needs_removal_from_sync_folder = False self.save() + # Set all flags for a sync to cdn, media frontend, YT ... + def set_all_sync_flags(self, save = False): + #self.needs_sync_to_ftp = True + #self.needs_sync_to_media = True + #self.needs_sync_to_YT = True + self.needs_sync_to_sync_folder = True + if save: + self.save() + # Set to autotiming in progress @transaction.atomic From 541fad1e642d563cd1e419b2b656f24809ba733b Mon Sep 17 00:00:00 2001 From: percidae Date: Thu, 1 Feb 2018 23:22:17 +0100 Subject: [PATCH 030/473] Added Subtitle function 'set_all_removal_flags' --- www/models.py | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/www/models.py b/www/models.py index 65e11e06..7790450a 100755 --- a/www/models.py +++ b/www/models.py @@ -669,6 +669,91 @@ def check_activity_on_amara(self, force = False): self.next_amara_activity_check = start_timestamp + self.calculated_time_delta_for_activities self.save() + # Check amara video-data + @transaction.atomic + def check_amara_video_data(self, force = False): + start_timestamp = datetime.now(timezone.utc) + # Only query amara if forced or flag is set + if force or self.needs_complete_amara_update: + url = "https://amara.org/api/videos/" + self.amara_key + "/languages/?format=json" + import requests + r = requests.get(url, headers = cred.AMARA_HEADER) + activities = json.loads(r.text) + for any_subtitle in activities["objects"]: + print("Talk_ID:", self.id, "Amara_key:", self.amara_key) + print("Language_code:", any_subtitle["language_code"]) + amara_subt_lang = any_subtitle["language_code"] + print("is_primary_audio_language = is_original:", any_subtitle["is_primary_audio_language"]) + amara_subt_is_original = any_subtitle["is_primary_audio_language"] + print("subtitles_complete:", any_subtitle["subtitles_complete"]) + amara_subt_is_complete = any_subtitle["subtitles_complete"] + print("versions:", len(any_subtitle["versions"])) + amara_subt_revision = len(any_subtitle["versions"]) + print("\n") + # Only proceed if the revision on amara is higher than zero + # Zero can exist if someone once clicked a language but didn't save anything + if amara_subt_revision > 0: + # Get the right subtitle dataset or create it, only if the version is not null + my_language = Language.objects.get(lang_amara_short = amara_subt_lang) + my_subtitle, created = Subtitle.objects.get_or_create(talk = self, language = my_language) + # Proceed if the version on amara has changed + if my_subtitle.revision != amara_subt_revision: + # If the subtitle was not complete and is not complete + if not my_subtitle.complete and not amara_subt_is_complete: + # Just update the data + my_subtitle.is_original_lang = amara_subt_is_original + my_subtitle.revision = amara_subt_revision + my_subtitle.save() + # If the subtitle was not complete but is complete now + elif not my_subtitle.complete and amara_subt_is_complete: + my_subtitle.complete = amara_subt_is_complete + my_subtitle.is_orignal_lang = amara_subt_is_original + my_subtitle.revision = amara_subt_revision + # This sets the sync flags and the tweet-flag + my_subtitle.set_complete(was_already_complete = False) + # If the talk also is in the original language, recalculate statistics + if my_subtitle.is_original_lang: + my_subtitle.talk.reset_related_statistics_data() + my_subtitle.save() + # If the subtitle was complete and is still complete + elif my_subtitle.complete and amara_subt_is_complete: + my_subtitle.complete = amara_subt_is_complete + my_subtitle.is_orignal_lang = amara_subt_is_original + my_subtitle.revision = amara_subt_revision + # This sets the sync flags and the tweet-flag + my_subtitle.set_complete(was_already_complete = True) + # If the talk also is in the original language, recalculate statistics + if my_subtitle.is_original_lang: + my_subtitle.talk.reset_related_statistics_data() + my_subtitle.save() + # If the subtitle was complete but isn't any more + elif my_subtitle.complete and not amara_subt_is_complete: + my_subtitle.complete = amara_subt_is_complete + my_subtitle.is_orignal_lang = amara_subt_is_original + my_subtitle.revision = amara_subt_revision + my_subtitle.reset_from_complete() + # If the talk also is in the original language, recalculate statistics + if my_subtitle.is_original_lang: + my_subtitle.talk.reset_related_statistics_data(hard_reset = True) + my_subtitle.save() + + # If the revision hasn't changed but the complete flag has changed, set the subtitle complete + elif my_subtitle.complete and not amara_subt_is_complete: + my_subtitle.set_complete() + if my_subtitle.is_original_lang: + my_subtitle.talk.reset_related_statistics_data() + # Set the right state if the default is still active on "1" + if my_subtitle.state_id == 1 and my_subtitle.is_original_lang: + my_subtitle.state_id = 2 + my_subtitle.save() + elif my_subtitle.state_id == 1 and not my_subtitle.is_original_lang: + my_subtitle.state_id = 11 + my_subtitle.save() + # Save the timestamp when this function was last used and reset the flag + self.amara_complete_update_last_checked = start_timestamp + self.needs_complete_amara_update = False + self.save() + # States for every subtitle like "complete" or "needs sync" class States(BasisModell): @@ -874,6 +959,15 @@ def set_all_sync_flags(self, save = False): if save: self.save() + # Set all flags for a removal from the cdn, media frontend, YT... + def set_all_removal_flags(self, save = False): + #self.needs_removal_from_ftp = True + #self.needs_removal_from_media = True + #self.needs_removal_from_YT = True + self.needs_removal_from_sync_folder = True + if save: + self.save() + # Set to autotiming in progress @transaction.atomic From 35929fac8fd131d5e1fbffe140c405c855819ef2 Mon Sep 17 00:00:00 2001 From: percidae Date: Thu, 1 Feb 2018 23:23:24 +0100 Subject: [PATCH 031/473] Added Subtitle function 'set_complete' --- www/models.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/www/models.py b/www/models.py index 7790450a..82e2a1f2 100755 --- a/www/models.py +++ b/www/models.py @@ -968,6 +968,25 @@ def set_all_removal_flags(self, save = False): if save: self.save() + # Set the subtitle complete + @transaction.atomic + def set_complete(self, was_already_complete = False): + if self.is_original_lang: + self.time_processed_transcribing = self.talk.video_duration + self.time_processed_syncing = self.talk.video_duration + self.time_quality_check_done = self.talk.video_duration + self.state_id = 8 + else: + self.time_processed_translating = self.talk.video_duration + self.state_id = 12 + # Only tweet if the file was not already complete + if not was_already_complete: + self.tweet = True + self.blocked = False + self.set_all_sync_flags() + self.needs_automatic_syncing = False + self.save() + # Set to autotiming in progress @transaction.atomic From 4b475a4afe207ea3c43e183cdbdbb84ce9ab2074 Mon Sep 17 00:00:00 2001 From: percidae Date: Thu, 1 Feb 2018 23:24:11 +0100 Subject: [PATCH 032/473] Added Subtitle function 'reset_from_complete' --- www/models.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/www/models.py b/www/models.py index 82e2a1f2..b01e950f 100755 --- a/www/models.py +++ b/www/models.py @@ -987,6 +987,21 @@ def set_complete(self, was_already_complete = False): self.needs_automatic_syncing = False self.save() + # Reset subtitle if it was complete but it is not any more + @transaction.atomic + def reset_from_complete(self): + self.time_processed_transcribing = "00:00:00" + self.time_processed_syncing = "00:00:00" + self.time_quality_check_done = "00:00:00" + self.time_processed_translating = "00:00:00" + if self.is_original_lang: + self.state_id = 2 + else: + self.state_id = 11 + self.set_all_removal_flags() + self.needs_automatic_syncing = False + self.blocked = False + self.save() # Set to autotiming in progress @transaction.atomic From 1b335ee01914a520fb64186b0add26e16c7cc80f Mon Sep 17 00:00:00 2001 From: percidae Date: Thu, 1 Feb 2018 23:25:16 +0100 Subject: [PATCH 033/473] Updated docu up subtitles update script --- update_subtitles_via_amara_import.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/update_subtitles_via_amara_import.py b/update_subtitles_via_amara_import.py index 517b480b..01f8a44c 100755 --- a/update_subtitles_via_amara_import.py +++ b/update_subtitles_via_amara_import.py @@ -2,12 +2,16 @@ # -*- coding: utf-8 -*- #============================================================================== -# This script checks for every talk with an amara key if there are updates or -# new subtitles for this talk and if so puts them in the database or updates -# them +# This script checks for every talk with an amara key if there were any +# "activities" since the last check +# If there was an activity it triggerts the "big" amara update # -# Currently missing: The setting of the corresponding timestamps because there -# is now way to read them from a nonfinished file +# If a talk didn't have a big amara update during the last 24h it forces also +# a big update for this talk to avoid missing a complete flag which can +# unfortunately be set without a change of revision which means the talk has +# no acitivity in the activity check +# +# This script is meant to be run as a cronjob #============================================================================== import os From 26430626c4bbdda0e2f28d646a56f892aa59f88f Mon Sep 17 00:00:00 2001 From: percidae Date: Thu, 1 Feb 2018 23:26:26 +0100 Subject: [PATCH 034/473] Updated amara update skript to the new class functions and activity check before 'big update' --- update_subtitles_via_amara_import.py | 334 +++------------------------ 1 file changed, 33 insertions(+), 301 deletions(-) diff --git a/update_subtitles_via_amara_import.py b/update_subtitles_via_amara_import.py index 01f8a44c..14ea3481 100755 --- a/update_subtitles_via_amara_import.py +++ b/update_subtitles_via_amara_import.py @@ -15,310 +15,42 @@ #============================================================================== import os -import sys -import json -import urllib.request -from datetime import datetime, timezone +from datetime import datetime, timezone, timedelta os.environ.setdefault("DJANGO_SETTINGS_MODULE", "subtitleStatus.settings") import django django.setup() -from django.core.management.base import BaseCommand, CommandError -from django.db import transaction -from django.core.exceptions import ObjectDoesNotExist -from www.models import Talk, Language, Subtitle, States, Statistics_Raw_Data, Talk_Persons - -import credentials as cred - - -# Function to completely reset an subtitle -# Used if a subtitle was formerly set to complete but isn't anymore -def reset_subtitle(my_subtitle): - # Stuff which needs to be done in any case, no matter if its a translation or not - my_subtitle.complete = False - my_subtitle.needs_removal_from_ftp = True - my_subtitle.needs_removal_from_YT = True - my_subtitle_needs_removal_from_sync_folder = True - my_subtitle.last_changed_on_amara = datetime.now(timezone.utc) - - # If the subtitle is the original language,reset all states to the start - if my_subtitle.is_original_lang: - my_subtitle.time_processed_transcribing = "00:00:00" - my_subtitle.time_processed_syncing = "00:00:00" - my_subtitle.time_quality_check_done = "00:00:00" - my_subtitle.state_id = 2 # Transcribed until - # Reset all related statistics data to None and do recalculate - # In the Talk model - my_talk = Talk.objects.get(id = my_subtitle.talk.id) - my_talk.recalculate_talk_statistics = True - my_talk.recalculate_speakers_statistics = True - my_talk.average_spm = None - my_talk.average_wpm = None - my_talk.strokes = None - my_talk.words = None - my_talk.time_delta = None - my_talk.speakers_average_spm = None - my_talk.speakers_average_wpm = None - my_talk.n_most_frequent_words = "{}" - my_talk.n_most_frequent_words_speakers = "{}" - my_talk.save() - # In the Statistics_Raw_Data model - my_statistics = Statistics_Raw_Data.objects.filter(talk = my_subtitle.talk) - for any_statistics in my_statistics: - any_statistics.recalculate_statistics = True - any_statistics.time_delta = None - any_statistics.words = None - any_statistics.strokes = None - any_statistics.save() - # In the Talk_Persons model - my_talk_persons = Talk_Persons.objects.filter(talk = my_talk) - for any in my_talk_persons: - any.average_spm = None - any.average_wpm = None - any.recalculate_statistics = True - any.strokes = None - any.time_delta = None - any.words = None - any.n_most_frequent_words = "{}" - any.save() - # TO DO: Statistics_Speaker reset and Statistics_Event reset - - - # If the subtitle is a translation.. - elif not my_subtitle.is_original_lang: - my_subtitle.state_id = 11 # Translated until... - my_subtitle.time_processed_translating = "00:00:00" - - my_subtitle.save() - - # Also reset statistics data - my_subtitle.talk.recalculate_talk_statistics = True - my_subtitle.talk.recalculate_speakers_statistics = True - my_subtitle.talk.save() - # In the Statistics model - my_statistics = Statistics_Raw_Data.objects.filter(talk = my_subtitle.talk) - for any_statistics in my_statistics: - any_statistics.recalculate_statistics = True - any_statistics.save() - - - - -# Set all states to complete and sync and sets the tweet-flags, only if not choosen otherwise -# - no matter if the subtitle is a translation or a original -def set_subtitle_complete(my_subtitle, tweet_about_it = True): - # Stuff which needs to be done anyway.. - my_subtitle.complete = True - # Only set the sync flags if the subtitle is not blacklisted - if not my_subtitle.blacklisted: - my_subtitle.needs_sync_to_YT = True - my_subtitle.needs_sync_to_ftp = True - my_subtitle.needs_sync_to_sync_folder = True - my_subtitle.last_changed_on_amara = datetime.now(timezone.utc) - - # Only tweet if it is not a rerelease - if tweet_about_it: - my_subtitle.tweet = True - else: - my_subtitle.tweet = False - # Don't tweet if the subtitle is blacklisted - if my_subtitle.blacklisted: - my_subtitle.tweet = False - - # Stuff only if the subtitle is the orignal language - if my_subtitle.is_original_lang: - my_subtitle.time_processed_transcribing = my_subtitle.talk.video_duration - my_subtitle.time_processed_syncing = my_subtitle.talk.video_duration - my_subtitle.time_quality_check_done = my_subtitle.talk.video_duration - my_subtitle.state_id = 8 # Complete - - # Stuff only if the subtitle is a translation - elif not my_subtitle.is_original_lang: - my_subtitle.time_processed_translating = my_subtitle.talk.video_duration - my_subtitle.state_id = 12 # Translation finished - - my_subtitle.save() - # Also reset statistics data - my_subtitle.talk.recalculate_talk_statistics = True - my_subtitle.talk.recalculate_speakers_statistics = True - my_subtitle.talk.save() - # In the Statistics model - my_statistics = Statistics_Raw_Data.objects.filter(talk = my_subtitle.talk) - for any_statistics in my_statistics: - any_statistics.recalculate_statistics = True - any_statistics.save() - - - -basis_url = "https://amara.org/api/videos/" -anti_bot_header = {'User-Agent': 'Mozilla/5.0, Opera/9.80 (Windows NT 6.1; WOW64; U; de) Presto/2.10.289 Version/12.01', - 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', - 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3', - 'Accept-Encoding': '', - 'Accept-Language': 'en-US,en;q=0.8', - 'Connection': 'keep-alive', - 'X-api-username': cred.AMARA_USER, - 'X-api-key': cred.AMARA_API_KEY} - -# Query for all talks who have an amara key -all_talks_with_amara_key = Talk.objects.exclude(amara_key__exact = "").order_by("-touched") -#print(all_talks_with_amara_key.count()) -for any_talk in all_talks_with_amara_key: - # Create URL depending on amara_key - url = basis_url+any_talk.amara_key+"/languages/?format=json" - print(url) - - # Get json file form amara and convert to dict - request = urllib.request.Request(url, headers = anti_bot_header) - response = urllib.request.urlopen(request) - encoding = response.info().get_param('charset', 'utf8') - amara_answer = json.loads(response.read().decode(encoding)) - - # Number of available subtitle languages, read from json output - number_of_available_subtitles = amara_answer["meta"]["total_count"] - - # Get necessary info from json file for one subtitle - subtitles_counter = 0 - while subtitles_counter < number_of_available_subtitles: - amara_num_versions = amara_answer["objects"][subtitles_counter]["num_versions"] - - # Ignore Subtitles with no saved revision - if amara_num_versions > 0: - print("version in json: ",amara_num_versions) - amara_language_code = amara_answer["objects"][subtitles_counter]["language_code"] - amara_is_original = amara_answer["objects"][subtitles_counter]["is_primary_audio_language"] - amara_subtitles_complete = amara_answer["objects"][subtitles_counter]["subtitles_complete"] - - language = Language.objects.get(lang_amara_short = amara_language_code) - - # Get or create subtitle entry from database - subtitle = Subtitle.objects.get_or_create(language = language , talk = any_talk)[0] - subtitle_was_already_complete = subtitle.complete - - # Almost only change something in the database if the version of the subtitle is not the same as before - if (subtitle.revision != amara_num_versions): - subtitle.is_original_lang = amara_is_original - subtitle.revision = amara_num_versions - subtitle.complete = amara_subtitles_complete - subtitle.last_changed_on_amara = datetime.now(timezone.utc) - subtitle.save() - # Also reset statistics data - any_talk.recalculate_talk_statistics = True - any_talk.recalculate_speakers_statistics = True - any_talk.save() - # In the Statistics model - my_statistics = Statistics_Raw_Data.objects.filter(talk = any_talk) - for any_statistics in my_statistics: - any_statistics.recalculate_statistics = True - any_statistics.save() - - # If subtitle is orignal and new inserted into the database, set state to transcribed until.. - if (subtitle.revision == "1" and subtitle.is_original_lang): - subtitle.state_id = 2 - subtitle.save() - # If subtitle is a translation and new inserted into the database set state to translated until.. - if (subtitle.revision == "1" and not subtitle.is_original_lang): - subtitle.state_id = 11 - subtitle.save() - - # If orignal or translation and finished set state to finished - if subtitle.complete and subtitle_was_already_complete: - set_subtitle_complete(subtitle, False) # Don't tweet about it - elif subtitle.complete and not subtitle_was_already_complete: - set_subtitle_complete(subtitle, True) # Tweet about it - - # If translation and not finished set state to translation in progress - elif (not subtitle.is_original_lang and not subtitle.complete): - # If the state was set to finished but isn't anymore, remove from ftp - # Server and reset the timestamp - if subtitle.state_id == 12: - reset_subtitle(subtitle) - # If orignal and not finished but was set to finished, reset to transcribed until - else: - # If the state was set to finished, reset to transcribed until - # Also reset the timestamps - if subtitle.state_id == 8: - reset_subtitle(subtitle) - - # If was set to finished but isn't any more, remove: - if (not subtitle.complete and subtitle_was_already_complete): - reset_subtitle(subtitle) - - # If the revision is the same, still check the complete-Flag! - if (subtitle.revision == amara_num_versions): - # If the saved subtitle on amara is not complete anymore but was complete - if not amara_subtitles_complete and subtitle.complete: - reset_subtitle(subtitle) - # If the saved subtitle is not complete but amara is complete, set to complete - if amara_subtitles_complete and not subtitle.complete: - set_subtitle_complete(subtitle, True) - - subtitles_counter += 1 - -print("Import Done!") - -print("Checking the states..") -my_subtitles = Subtitle.objects.all().order_by("-id")#.select_related("states").select_related("talk__video_duration") -# Check every Subtitle in the Database for the states if they fit the flags -for my_subtitle in my_subtitles: - # Original language - if my_subtitle.is_original_lang: - # Workaround for manual setting of the time transcribed to exact the video length - doesn't work! - if (my_subtitle.time_processed_transcribing == my_subtitle.talk.video_duration) \ - and (my_subtitle.time_processed_syncing == "00:00:00") \ - and (my_subtitle.time_quality_check_done == "00:00:00" ) \ - and (my_subtitle.blocked == False) \ - and (my_subtitle.state_id == 2): # Transcribed until.. - my_subtitle.state_id = 7 - my_subtitle.needs_automatic_syncing = True - my_subtitle.blocked = True - my_subtitle.save() - print("WTF") - # Still in transcribing process - if my_subtitle.transcription_in_progress: - if my_subtitle.state_id != 2: - my_subtitle.state_id = 2 # Transcribed until... - my_subtitle.save() - # Still in syncing procress - elif my_subtitle.syncing_in_progress: - if my_subtitle.state_id != 5: - my_subtitle.state_id = 5 # Synced until... - my_subtitle.save() - # Still in quality check procress - elif my_subtitle.quality_check_in_progress: - if my_subtitle.state_id != 7: - my_subtitle.state_id = 7 # Quality check done until... - my_subtitle.save() - # Finished, depending on the time stamps - elif my_subtitle.state_id != 2: - if my_subtitle.state_id != 8: - my_subtitle.state_id = 8 # Completed! - my_subtitle.save() - - - - # Translation - else: - # Still in translating process - if my_subtitle.translation_in_progress: - if my_subtitle.state_id != 11: - my_subtitle.state_id = 11 # Translated until... - my_subtitle.save() - # If time translated = videoduration, check if marked as finished or not - else: - # If marked as finished: - if my_subtitle.complete: - if my_subtitle.state_id != 12: - my_subtitle.state_id = 12 # Translation finished... - my_subtitle.save() - # If subtitle is not complete but time stamps tell the opposite reset them - else: - my_subtitle.time_processed_translating = "00:00:00" - my_subtitle.state_id = 11 - my_subtitle.needs_removal_from_ftp = True - my_subtitle.needs_removal_from_YT = True - my_subtitle.save() - -print(".. done!") +from www.models import Talk + +start = datetime.now(timezone.utc) + +print("Start: ", start) + +# Check activity on talks with the next_amara_activity_check in the past: +my_talks = Talk.objects.filter(next_amara_activity_check__lte = start, blacklisted = False) +print("Talks which need an activity update: ", my_talks.count()) +for any in my_talks: + any.check_activity_on_amara() + +# Check the "big" amara query for talks which had a new activity +my_talks = Talk.objects.filter(needs_complete_amara_update = True, blacklisted = False) +print("Talks which need a full amara update: ", my_talks.count()) +for any in my_talks: + any.check_amara_video_data() + +# Check the "big" amara query if there was no big query in the last 24h to find +# talks which have a changed complete flag without a new revision which can not +# be detected with the activity check on amara +time_delta = timedelta(seconds = 0, minutes = 0, hours = 24, microseconds = 0) +before_24h = datetime.now(timezone.utc) - time_delta +my_talks = Talk.objects.filter(amara_complete_update_last_checked__lte = before_24h, blacklisted = False) +print("Talks which need a forced amara update: ", my_talks.count()) +for any in my_talks: + # Force is necessary, if not it won't be checked because the flag is not set + any.check_amara_video_data(force = True) + +end = datetime.now(timezone.utc) +print("Start: ", start) +print("End: ", end, " Duration: ", end - start) \ No newline at end of file From f7ac6a42e13d4c4804b60083acc1ebaa98b1ddde Mon Sep 17 00:00:00 2001 From: percidae Date: Sun, 4 Feb 2018 12:17:38 +0100 Subject: [PATCH 035/473] Avoide to show the datetime.min var if a talk / subtitle doesn't have the real date and time for last_changed_on_amara yet --- www/templates/www/talk.html | 8 +++++- www/templates/www/talk_small.html | 12 ++++++-- www/views.py | 46 +++++++++++++++++-------------- 3 files changed, 42 insertions(+), 24 deletions(-) diff --git a/www/templates/www/talk.html b/www/templates/www/talk.html index 59f23dc0..d742a705 100755 --- a/www/templates/www/talk.html +++ b/www/templates/www/talk.html @@ -232,7 +232,13 @@

    The video is not yet available

    {{ sub.form|bootstrap }} {% csrf_token %} - Last revision: {{ sub.last_changed_on_amara|timesince }} ago + Last revision: + {% if sub.last_changed_on_amara.date != datetime_min.date %} + {{ sub.last_changed_on_amara|timesince }} ago + {% else %} + unknown + {% endif %} + {%if sub.form.quick_btn %} {% endif %} diff --git a/www/templates/www/talk_small.html b/www/templates/www/talk_small.html index cc707d95..9d292e6c 100755 --- a/www/templates/www/talk_small.html +++ b/www/templates/www/talk_small.html @@ -26,12 +26,18 @@

    {{talk.title}}

    - Last revision: {{ subtitle.last_changed_on_amara|timesince }} ago + Last revision: + {% if subtitle.last_changed_on_amara.date != datetime_min.date %} + {{ subtitle.last_changed_on_amara|timesince }} ago + {% else %} + unknown + {% endif %} + {% endfor %} - {% else %} -

    No subtitles yet in the language of the presentation.
    Start working on them!

    + {% else %} +

    No subtitles yet in the language of the presentation.
    Start working on them!

    {% endif %}

    diff --git a/www/views.py b/www/views.py index 7a6c318d..4f786e67 100755 --- a/www/views.py +++ b/www/views.py @@ -62,7 +62,9 @@ def event (request, event_acronym, *args, **kwargs): # Create cunk for the 3 columns display of talks on event page talks_per_line = 3 talks_chunk = [my_talks[x:x+talks_per_line] for x in range(0, len(my_talks), talks_per_line)] - + + datetime_min = datetime.datetime.min + except ObjectDoesNotExist: raise Http404 @@ -72,7 +74,8 @@ def event (request, event_acronym, *args, **kwargs): "my_langs" : my_langs, "page_sub_titles": my_event.page_sub_titles, "talks_chunk" : talks_chunk, - "request": request} ) + "request": request, + "datetime_min": datetime_min}) # Form to save the progress of a subtitle def get_subtitle_form(request, talk, sub): @@ -154,20 +157,23 @@ def talk(request, talk_id): my_subtitles = my_talk.subtitle_set.all().order_by("-is_original_lang","language__lang_amara_short") for s in my_subtitles: s.form = get_subtitle_form(request, my_talk, s) - + speakers_in_talk_statistics = Talk_Persons.objects.filter(talk = my_talk) - + show_pad = False if my_talk.link_to_writable_pad[0:1] != "#": show_pad = True + datetime_min = datetime.datetime.min + return render(request, "www/talk.html", {"talk" : my_talk, - "subtitles": my_subtitles, - "page_sub_titles": my_talk.page_sub_titles, - "talk_speakers_statistics": speakers_in_talk_statistics, - "show_etherpad": show_pad, - "request": request} ) #"speakers": my_speakers, + "subtitles": my_subtitles, + "page_sub_titles": my_talk.page_sub_titles, + "talk_speakers_statistics": speakers_in_talk_statistics, + "show_etherpad": show_pad, + "request": request, + "datetime_min": datetime_min}) def talk_by_frab(request, frab_id): @@ -243,9 +249,9 @@ def speaker(request, speaker_id): # If the speaker has an doppelgaenger, do a redirect to this site if my_speaker.doppelgaenger_of is not None : return redirect('speaker', speaker_id = my_speaker.doppelgaenger_of.id) - + my_talk_persons = Talk_Persons.objects.filter(speaker = my_speaker).order_by("-talk__date").select_related('talk', 'speaker').prefetch_related('talk__subtitle_set') - + my_speakers_statistics = Statistics_Speaker.objects.filter(speaker = my_speaker) \ .exclude(average_wpm = None, average_spm = None) \ .order_by("language__language_en") @@ -279,7 +285,7 @@ def speaker(request, speaker_id): first_flag = False else: my_events += ", " + any - + # All tracks the speaker spoke in my_tracks = "" first_flag = True @@ -289,7 +295,7 @@ def speaker(request, speaker_id): first_flag = False else: my_tracks += ", " + any - + # Get all languages the speaker spoke in and convert to a string with commas first_flag = True my_languages = "" @@ -299,7 +305,7 @@ def speaker(request, speaker_id): first_flag = False else: my_languages += ", " + any - + # Get all non blacklisted talks from the speaker my_talks = my_speaker.talk_set.all() my_talks = my_talks.filter(blacklisted = False).order_by("-date").prefetch_related("talk_persons_set") @@ -356,7 +362,7 @@ def _progress_bar(total, green=0.0, orange=0.0, red=0.0, precision=1): 'bar_synced': orange_amount, 'bar_transcribed': red_amount, 'bar_nothing': grey_amount, - } + } def progress_bar_for_talks(talks): transcribed = synced = checked = 0 @@ -399,7 +405,7 @@ def statistics_speakers_in_talks(request): my_talk_persons = Talk_Persons.objects.all().exclude(average_wpm = None).order_by("-average_spm") return render(request, "www/statistics_speakers_in_talks.html", {"talk_persons" : my_talk_persons}) - + # Test-View def test(request): @@ -428,8 +434,8 @@ def test(request): pass else: event_days[any.index] = 0 - - + + return render(request, "www/test.html", {"talk_persons" : my_talk_persons, "my_langs" : my_langs, @@ -484,8 +490,8 @@ def b_test(request): #return HttpResponseRedirect(reverse(text)) # If this is a GET (or any other method) create the default form. else: - my_form = BForm()#initial={"my_text":text,}) - + my_form = BForm()#initial={"my_text":text,}) + return render(request, "www/b_test.html", { "form" : my_form, From 16b35c3177685e467ae7515e550ead20ef086fe1 Mon Sep 17 00:00:00 2001 From: percidae Date: Sat, 7 Apr 2018 22:27:15 +0200 Subject: [PATCH 036/473] Minor Fix if Amara doesn't reply with valid json due to for exmaple the backend being down. --- www/models.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/www/models.py b/www/models.py index b01e950f..a6228f2c 100755 --- a/www/models.py +++ b/www/models.py @@ -626,7 +626,13 @@ def check_activity_on_amara(self, force = False): # all results came with the first query while url != None: r = requests.get(url, headers = cred.AMARA_HEADER, params = parameters) - activities = json.loads(r.text) + #print(r.text) + # If amara doesn't reply with a valid json create one. + try: + activities = json.loads(r.text) + except: + self.check_amara_video_data() + activities = json.loads('{"meta":{"previous":null,"next":null,"offset":0,"limit":20,"total_count":0},"objects":[]}') url = activities["meta"]["next"] # Get the results for any language separate for any in activities["objects"]: From 8fc89cdfdbad5a41b3a7b4938fd9d411138dbbab Mon Sep 17 00:00:00 2001 From: percidae Date: Sun, 8 Apr 2018 09:49:57 +0200 Subject: [PATCH 037/473] Fixed 'Talk.reset_related_statistics_data()' to also work for a hard reset --- www/models.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/www/models.py b/www/models.py index a6228f2c..4e8663b2 100755 --- a/www/models.py +++ b/www/models.py @@ -412,9 +412,8 @@ def recalculate(self, force = False): # use hard_reset = True if a subtitle is reset from complete to not complete any more @transaction.atomic def reset_related_statistics_data(self, hard_reset = False): - # Set the recalculate flags no matter if hard_reset or not - self.recalculate_talk_statistics = True - self.recalculate_speakers_statistics = True + # If hard reset, do reset the values but do not recalculate! + # Only the Speakers statistics data is not reset here because it would get recalculated anyway if hard_reset: # Reset everything of the talk and directly related to the talk self.average_spm = None @@ -426,21 +425,21 @@ def reset_related_statistics_data(self, hard_reset = False): self.speakers_average_wpm = None self.n_most_frequent_words = "{}" self.n_most_frequent_words_speakers = "{}" - Statistics_Raw_Data.objects.filter(talk = self).update(recalculate_statistics = True, - time_delta = None, + Statistics_Raw_Data.objects.filter(talk = self).update(time_delta = None, words = None, strokes = None) - Talk_Persons.objects.filter(talk = self).update(recalculate_statistics = True, - average_spm = None, + Talk_Persons.objects.filter(talk = self).update(average_spm = None, average_wpm = None, words = None, strokes = None, time_delta = None, n_most_frequent_words = "{}") - # If no hard_reset only also set the Statistics_Raw_Data to recalculate and the Talk_Persons Data + # If no hard_reset only set all recalculate flags else: Statistics_Raw_Data.objects.filter(talk = self).update(recalculate_statistics = True) Talk_Persons.objects.filter(talk = self).update(recalculate_statistics = True) + self.recalculate_talk_statistics = True + self.recalculate_speakers_statistics = True self.save() # Return the n most common words as dict From 42f7efa890607d88676d3da317775e03784a3d89 Mon Sep 17 00:00:00 2001 From: percidae Date: Sun, 8 Apr 2018 09:54:29 +0200 Subject: [PATCH 038/473] Subtitle update function for a complete reset also resets the related statistics data --- www/models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/www/models.py b/www/models.py index 4e8663b2..03d011f5 100755 --- a/www/models.py +++ b/www/models.py @@ -1001,6 +1001,8 @@ def reset_from_complete(self): self.time_processed_translating = "00:00:00" if self.is_original_lang: self.state_id = 2 + # Hard reset for the related statistics data + self.talk.reset_related_statistics_data(True) else: self.state_id = 11 self.set_all_removal_flags() From b9f38f2a1e3dfec8c0f15a35d75d242b471e654c Mon Sep 17 00:00:00 2001 From: percidae Date: Sun, 8 Apr 2018 10:10:09 +0200 Subject: [PATCH 039/473] Fixed 'Talk.check_amara_video_data()' to also take care of statistics recalculation if necessary --- www/models.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/www/models.py b/www/models.py index 03d011f5..194e39ca 100755 --- a/www/models.py +++ b/www/models.py @@ -709,12 +709,16 @@ def check_amara_video_data(self, force = False): my_subtitle.is_original_lang = amara_subt_is_original my_subtitle.revision = amara_subt_revision my_subtitle.save() + # If this is an subtitle which is the original language + # and is in a state which has already statistics, also recalculate them + if my_subtitle.is_original_lang and my_subtitle.state_id == (5 or 6 or 7): + self.reset_related_statistics_data() # If the subtitle was not complete but is complete now elif not my_subtitle.complete and amara_subt_is_complete: my_subtitle.complete = amara_subt_is_complete my_subtitle.is_orignal_lang = amara_subt_is_original my_subtitle.revision = amara_subt_revision - # This sets the sync flags and the tweet-flag + # This sets the sync flags and the tweet-flag and also lets the statistics to be recalculated my_subtitle.set_complete(was_already_complete = False) # If the talk also is in the original language, recalculate statistics if my_subtitle.is_original_lang: @@ -725,7 +729,7 @@ def check_amara_video_data(self, force = False): my_subtitle.complete = amara_subt_is_complete my_subtitle.is_orignal_lang = amara_subt_is_original my_subtitle.revision = amara_subt_revision - # This sets the sync flags and the tweet-flag + # This sets the sync flags and the tweet-flag and lets the statistics to be recalculated my_subtitle.set_complete(was_already_complete = True) # If the talk also is in the original language, recalculate statistics if my_subtitle.is_original_lang: @@ -736,10 +740,8 @@ def check_amara_video_data(self, force = False): my_subtitle.complete = amara_subt_is_complete my_subtitle.is_orignal_lang = amara_subt_is_original my_subtitle.revision = amara_subt_revision + # Resets the states and also the statistics if it is the original language my_subtitle.reset_from_complete() - # If the talk also is in the original language, recalculate statistics - if my_subtitle.is_original_lang: - my_subtitle.talk.reset_related_statistics_data(hard_reset = True) my_subtitle.save() # If the revision hasn't changed but the complete flag has changed, set the subtitle complete @@ -981,6 +983,8 @@ def set_complete(self, was_already_complete = False): self.time_processed_syncing = self.talk.video_duration self.time_quality_check_done = self.talk.video_duration self.state_id = 8 + # Let the related statistics data be recalculated + self.talk.reset_related_statistics_data() else: self.time_processed_translating = self.talk.video_duration self.state_id = 12 From 9653d6f325ffdca1900d43078915d2045a0f8362 Mon Sep 17 00:00:00 2001 From: percidae Date: Sun, 8 Apr 2018 15:42:50 +0200 Subject: [PATCH 040/473] Resetting a subtitle from blocked to quality control in progress also causes the statistics data to be calcualted --- reset_subtitle_from_blocked_to_quality_control.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reset_subtitle_from_blocked_to_quality_control.py b/reset_subtitle_from_blocked_to_quality_control.py index a1968195..6da9a999 100755 --- a/reset_subtitle_from_blocked_to_quality_control.py +++ b/reset_subtitle_from_blocked_to_quality_control.py @@ -34,8 +34,9 @@ subt.blocked = False subt.state_id = 7 # Quality control done until subt.tweet_autosync_done = True - subt.recalculate_talk_statistics = True subt.save() + # Let the related statistics be calculated + subt.talk.reset_related_statistics_data() print("Done") except: print("Fehler!") From 0233fbf3ff13e84134313080710932e40b20a549 Mon Sep 17 00:00:00 2001 From: percidae Date: Sun, 8 Apr 2018 18:13:45 +0200 Subject: [PATCH 041/473] If a user on the 'talk' page uses the progressbar and updates it, a complete amara update is triggered in the backend --- www/forms.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/www/forms.py b/www/forms.py index f585b020..b2dda1bd 100755 --- a/www/forms.py +++ b/www/forms.py @@ -23,6 +23,9 @@ def clean(self): self._errors['time_quality_check_done'] = self.error_class(['Time longer than the talk.']) if cleaned_data['time_processed_translating'] > my_obj.talk.video_duration: self._errors['time_processed_translating'] = self.error_class(['Time longer than the talk.']) + # Trigger a complete amara update + my_obj.talk.needs_complete_amara_update = True + my_obj.talk.save() return cleaned_data class TestForm(forms.Form): From 39c64f271e3635daa959b1585fa620fc4dca46b3 Mon Sep 17 00:00:00 2001 From: percidae Date: Sun, 8 Apr 2018 20:58:11 +0200 Subject: [PATCH 042/473] After a change in the progressbar amara acitivty and 'big update' is checked --- www/forms.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/www/forms.py b/www/forms.py index b2dda1bd..19401d04 100755 --- a/www/forms.py +++ b/www/forms.py @@ -1,6 +1,7 @@ from django import forms from .models import Subtitle, Event, Event_Days, Talk_Persons, Language #import django_filters +import datetime class SubtitleForm(forms.ModelForm): class Meta: @@ -24,6 +25,7 @@ def clean(self): if cleaned_data['time_processed_translating'] > my_obj.talk.video_duration: self._errors['time_processed_translating'] = self.error_class(['Time longer than the talk.']) # Trigger a complete amara update + my_obj.talk.next_amara_activity_check = datetime.datetime.now() my_obj.talk.needs_complete_amara_update = True my_obj.talk.save() return cleaned_data From 6ea163028c2b0660a5644c2445b17c1b2fca1986 Mon Sep 17 00:00:00 2001 From: percidae Date: Thu, 10 May 2018 16:31:09 +0200 Subject: [PATCH 043/473] Changed frab_id_talk from SmallInteger to Characters to use prefixes for non-congress events --- www/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/models.py b/www/models.py index 194e39ca..6e5fd303 100755 --- a/www/models.py +++ b/www/models.py @@ -270,7 +270,7 @@ class Transcript (BasisModell): # Talk with all its data class Talk(BasisModell): - frab_id_talk = models.PositiveSmallIntegerField(default = -1) + frab_id_talk = models.CharField(max_length = 10, default = "-1", blank = True) blacklisted = models.BooleanField(default=False, blank = True) day = models.ForeignKey(Event_Days, default = 1, blank = True) room = models.ForeignKey(Rooms, default = 15) From 99de7e6147225d5f1d2aa8aa63363cf231569008 Mon Sep 17 00:00:00 2001 From: Maximilian Marx Date: Wed, 26 Dec 2018 17:13:12 +0100 Subject: [PATCH 044/473] Add admin URIs --- www/urls.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/urls.py b/www/urls.py index 47a8fd12..4a34da8e 100755 --- a/www/urls.py +++ b/www/urls.py @@ -2,6 +2,7 @@ from . import views from django.core.urlresolvers import reverse_lazy from django.conf import settings +from django.contrib import admin urlpatterns = patterns('', url(r'^$', views.start, name="home"), @@ -23,8 +24,8 @@ url(r'^statistics/speakers_in_talks/$',views.statistics_speakers_in_talks), url(r'^test/$',views.test), url(r'^b_test/$',views.b_test), + url(r'^admin/',include(admin.site.urls)), ) if settings.DEBUG: urlpatterns += patterns('django.contrib.staticfiles.views', url(r'^static/(?P.*)$','serve')) - From b69e75d91d508dc9bfab3e4b1f906e7fe90998a2 Mon Sep 17 00:00:00 2001 From: Maximilian Marx Date: Fri, 28 Dec 2018 16:41:56 +0100 Subject: [PATCH 045/473] Start making the admin interface usable --- www/admin.py | 90 +++++++++++++++++++++++++++++++++++++++++++++++++-- www/models.py | 64 ++++++++++++++++++++---------------- 2 files changed, 124 insertions(+), 30 deletions(-) diff --git a/www/admin.py b/www/admin.py index 3d6051d4..911d03b6 100755 --- a/www/admin.py +++ b/www/admin.py @@ -10,17 +10,101 @@ from www.models import Event_Days from www.models import Rooms from www.models import Language +from www.models import Statistics_Raw_Data # Register your models here. -admin.site.register(Talk) + +class DayIndexFilter(admin.SimpleListFilter): + title = 'Day' + parameter_name = 'day' + + def lookups(self, request, model_admin): + indexes = {day.index for day in Event_Days.objects.all()} + + return ((index, 'Day {}'.format(index)) + for index in sorted(indexes)) + + def queryset(self, request, queryset): + index = self.value() + + if index is not None: + return queryset.filter(day__index=index) + else: + return queryset + + +@admin.register(Talk) +class TalkAdmin(admin.ModelAdmin): + date_hierarchy = 'date' + list_display = ('id', 'frab_id_talk', 'title', + 'event', 'day', 'start',) + list_filter = ('event', DayIndexFilter,) + search_fields = ('title', 'event__acronym', 'frab_id_talk',) + ordering = ('-event', 'date',) + + +@admin.register(Event) +class EventAdmin(admin.ModelAdmin): + date_hierarchy = 'start' + list_display = ('acronym', 'title', 'start', 'days', 'city', 'building',) + list_filter = ('city',) + + +class LanguageFilter(admin.SimpleListFilter): + title = 'Language' + parameter_name = 'language' + + + def lookups(self, request, model_admin): + return (('en', 'English'), + ('de', 'German'), + ('tlh', 'Klingon'), + ) + + def queryset(self, request, queryset): + lang = self.value() + + if lang is not None: + return queryset.filter(language__lang_amara_short=self.value()) + else: + return queryset + + +@admin.register(Subtitle) +class SubtitleAdmin(admin.ModelAdmin): + def status(self, obj): + stamp = None + + if obj.transcription_in_progress: + stamp = obj.time_processed_transcribing + elif obj.syncing_in_progress: + stamp = obj.time_processed_syncing + elif obj.quality_check_in_progress: + stamp = obj.time_quality_check_done + elif obj.translation_in_progress: + stamp = obj.time_processed_translating + + if stamp: + return '{} {}'.format(obj.state, stamp) + else: + return obj.state + + + list_display = ('id', 'talk', 'language', 'is_original_lang', + 'status', 'complete', 'blacklisted',) + list_filter = (LanguageFilter, 'is_original_lang', 'state', 'complete', + 'blacklisted', ) + raw_id_fields = ('talk',) + search_fields = ('talk__event__acronym', 'talk__title', 'talk__frab_id_talk',) + + admin.site.register(Tracks) admin.site.register(Links) admin.site.register(Type_of) admin.site.register(Speaker) -admin.site.register(Subtitle) admin.site.register(States) -admin.site.register(Event) admin.site.register(Event_Days) admin.site.register(Rooms) admin.site.register(Language) +admin.site.register(Statistics_Raw_Data) diff --git a/www/models.py b/www/models.py index 6e5fd303..2850dcf7 100755 --- a/www/models.py +++ b/www/models.py @@ -90,7 +90,7 @@ def has_statistics(self): return False else: return True - + # Save Fahrplan xml file with version in the name into ./www/static/ def save_fahrplan_xml_file(self): import datetime @@ -135,7 +135,10 @@ def save_speaker_json_file(self): file.close() return True - + def __str__(self): + return self.acronym + + # Days which belong to an event class Event_Days(BasisModell): event = models.ForeignKey(Event) @@ -144,6 +147,9 @@ class Event_Days(BasisModell): day_start = models.DateTimeField(default = "1970-01-01 00:00", blank = True) day_end = models.DateTimeField(default = "1970-01-01 00:00", blank = True) + def __str__(self): + return 'Day {}'.format(self.index) + # "Rooms" in which an event takes place, might also be outside class Rooms(BasisModell): @@ -176,7 +182,7 @@ def display_name(self): return "Original (mixed)" else: return self.language_en - + # Category of the talk, like "ethics" class Tracks(BasisModell): @@ -211,7 +217,7 @@ def has_statistics(self): if any.average_spm is not None: return True return False - + @property def has_links(self): speakers_links = Speaker_Links.objects.filter(speaker = self) @@ -254,19 +260,19 @@ def average_spm_in_one_talk(self, talk): @property def page_sub_titles(self): return ['Speaker', self.name] - + # Links from the Fahrplan class Speaker_Links(BasisModell): speaker = models.ForeignKey(Speaker, blank = True) title = models.CharField(max_length = 200, default = "", blank = True) url = models.URLField(blank = True) - + # Where is the Transcipt from, autogenerated or handmade class Transcript (BasisModell): creator = models.CharField(max_length = 20, blank = True, null = True) # None, trint, youtube, scribie, handmade ..., default with id=0 is None - + # Talk with all its data class Talk(BasisModell): @@ -320,7 +326,7 @@ class Talk(BasisModell): amara_complete_update_last_checked = models.DateTimeField(default = datetime.min, blank = True) # Everything checked, activity and data of every single subtitle needs_complete_amara_update = models.BooleanField(default = False) next_amara_activity_check = models.DateTimeField(default = datetime.min, blank = True) - + # Recalculate statistics data over the whole talk @transaction.atomic def recalculate_whole_talk_statistics(self, force = False): @@ -439,19 +445,19 @@ def reset_related_statistics_data(self, hard_reset = False): Statistics_Raw_Data.objects.filter(talk = self).update(recalculate_statistics = True) Talk_Persons.objects.filter(talk = self).update(recalculate_statistics = True) self.recalculate_talk_statistics = True - self.recalculate_speakers_statistics = True + self.recalculate_speakers_statistics = True self.save() # Return the n most common words as dict @property def n_common_words(self): return json.loads(self.n_most_frequent_words) - + # Return the n most common words of the speakers as dict @property def n_common_words_speakers(self): return json.loads(self.n_most_frequent_words_speakers) - + # Return the word_frequencies as dictionary @property def word_frequencies(self): @@ -530,14 +536,14 @@ def has_finished_original_subtitle(self): return True else: return False - + @property def has_original_subtitle_in_transcript_state(self): if self.subtitle_set.filter(is_original_lang = True, state_id = 2).count() >= 1: return True else: return False - + @property def has_transcript_by_trint(self): if self.transcript_by.id == 3: @@ -569,7 +575,7 @@ def has_transcript_by_human(self): @property def page_sub_titles(self): return self.event.page_sub_titles + [self.title] - + @property def has_links(self): talk_links = Links.objects.filter(talk = self) @@ -621,7 +627,7 @@ def check_activity_on_amara(self, force = False): url = basis_url + self.amara_key + "/activity/" results = {} # Loop as long as not all new activity datasets have been checked - # The json result from amara includes a "next" field which has the url for the next query if not + # The json result from amara includes a "next" field which has the url for the next query if not # all results came with the first query while url != None: r = requests.get(url, headers = cred.AMARA_HEADER, params = parameters) @@ -699,7 +705,7 @@ def check_amara_video_data(self, force = False): # Zero can exist if someone once clicked a language but didn't save anything if amara_subt_revision > 0: # Get the right subtitle dataset or create it, only if the version is not null - my_language = Language.objects.get(lang_amara_short = amara_subt_lang) + my_language = Language.objects.get(lang_amara_short = amara_subt_lang) my_subtitle, created = Subtitle.objects.get_or_create(talk = self, language = my_language) # Proceed if the version on amara has changed if my_subtitle.revision != amara_subt_revision: @@ -755,13 +761,17 @@ def check_amara_video_data(self, force = False): my_subtitle.save() elif my_subtitle.state_id == 1 and not my_subtitle.is_original_lang: my_subtitle.state_id = 11 - my_subtitle.save() + my_subtitle.save() # Save the timestamp when this function was last used and reset the flag self.amara_complete_update_last_checked = start_timestamp self.needs_complete_amara_update = False self.save() + def __str__(self): + return self.title + + # States for every subtitle like "complete" or "needs sync" class States(BasisModell): state_de = models.CharField(max_length = 100) @@ -774,7 +784,7 @@ def __str__(self): class Subtitle(BasisModell): talk = models.ForeignKey(Talk) language = models.ForeignKey(Language)#, to_field = "lang_amara_short") - is_original_lang = models.BooleanField(default = False) # Read from Amara, not from the Fahrplan! + is_original_lang = models.BooleanField(default = False, verbose_name='original language') # Read from Amara, not from the Fahrplan! revision = models.PositiveSmallIntegerField(default = 0) complete = models.BooleanField(default = False) state = models.ForeignKey(States, default = 1, blank = True) @@ -1146,7 +1156,7 @@ def recalculate(self, force = False): self.time_delta = time_delta self.average_wpm = calculate_per_minute(self.words, self.time_delta) self.average_spm = calculate_per_minute(self.strokes, self.time_delta) - + # Save the word frequencies into a json file if word_freq is not None and len(word_freq) > 0: save_word_dict_as_json(word_freq,"statistics_speaker", self.id) @@ -1160,11 +1170,11 @@ def recalculate(self, force = False): @property def word_frequencies(self): return read_word_dict_from_json("statistics_speaker", self.id) - + # Return the n most common words as dict @property def n_common_words(self): - return json.loads(self.n_most_frequent_words) + return json.loads(self.n_most_frequent_words) # Every Event can have different Statistic values for different languages @@ -1218,17 +1228,17 @@ def recalculate(self, force = False): self.n_most_frequent_words = "{}" self.recalculate_statistics = False self.save() - + # Return the word_frequencies as dictionary @property def word_frequencies(self): return read_word_dict_from_json("statistics_event", self.id) - + # Return the n most common words as dict @property def n_common_words(self): return json.loads(self.n_most_frequent_words) - + @property def has_statistics(self): if self.average_wpm is not None and self.average_spm is not None: @@ -1270,7 +1280,7 @@ def recalculate(self, force = False): else: self.average_wpm = calculate_per_minute(self.words, self.time_delta) self.average_spm = calculate_per_minute(self.strokes, self.time_delta) - + # Dictionary for the word freqiencies word_freq = {} # Merge all sub word_frequencies @@ -1284,12 +1294,12 @@ def recalculate(self, force = False): self.n_most_frequent_words = "{}" self.recalculate_statistics = False self.save() - + # Return the word_frequencies as dictionary @property def word_frequencies(self): return read_word_dict_from_json("talk_persons", self.id) - + # Return the n most common words as dict @property def n_common_words(self): From b7985ee32ca904ca79109c02e2db02738e029a5a Mon Sep 17 00:00:00 2001 From: Maximilian Marx Date: Fri, 28 Dec 2018 19:36:42 +0100 Subject: [PATCH 046/473] WIP: Add forms for common workflow tasks --- pad_from_trint.py | 21 +++------------ www/admin.py | 11 ++++++++ www/forms.py | 17 ++++++++---- www/templates/www/pad_from_trint.html | 27 +++++++++++++++++++ www/templates/www/pad_result.html | 30 +++++++++++++++++++++ www/transforms.py | 20 ++++++++++++++ www/urls.py | 1 + www/views.py | 39 ++++++++++++++++++++++++--- 8 files changed, 139 insertions(+), 27 deletions(-) create mode 100644 www/templates/www/pad_from_trint.html create mode 100644 www/templates/www/pad_result.html create mode 100644 www/transforms.py diff --git a/pad_from_trint.py b/pad_from_trint.py index 763ab395..faa12dc2 100644 --- a/pad_from_trint.py +++ b/pad_from_trint.py @@ -4,12 +4,7 @@ import sys import re -def chunks(file): - """Read `file`, splitting it at doubled linebreaks""" - lines = [] - for line in file: - lines.append(re.sub(' {2,}', ' ', line.strip())) - return '\n'.join(lines).split('\n\n') +from www.transforms import pad_from_trint if __name__ == '__main__': if len(sys.argv) != 2: @@ -18,18 +13,8 @@ def chunks(file): transcript = [] try: with open(sys.argv[1], 'r') as file: - transcript = chunks(file) + transcript = file.read() except IOError as err: sys.exit("Transcript not readable: {}").format(err) - out = "" - - for chunk in transcript: - lines = chunk.split('\n') - - for line in lines[2:]: - if line == '': - continue - out += ' ' + line - - print(out.replace('\n\n', '\n')) + print(pad_from_trint(transcript)) diff --git a/www/admin.py b/www/admin.py index 911d03b6..e7670c29 100755 --- a/www/admin.py +++ b/www/admin.py @@ -1,3 +1,5 @@ +from django.core.urlresolvers import reverse +from django.http import HttpResponseRedirect from django.contrib import admin from www.models import Talk from www.models import Tracks @@ -91,6 +93,15 @@ def status(self, obj): return obj.state + def pad_from_trint(self, request, queryset): + selected = request.POST.getlist(admin.ACTION_CHECKBOX_NAME) + first = selected[0] + rest = ','.join(selected[1:]) + return HttpResponseRedirect( + reverse('padFromTrint', args=[first, rest])) + + + actions = ['pad_from_trint'] list_display = ('id', 'talk', 'language', 'is_original_lang', 'status', 'complete', 'blacklisted',) list_filter = (LanguageFilter, 'is_original_lang', 'state', 'complete', diff --git a/www/forms.py b/www/forms.py index 19401d04..17d3a951 100755 --- a/www/forms.py +++ b/www/forms.py @@ -35,24 +35,31 @@ class TestForm(forms.Form): event_31c3 = forms.BooleanField(label = "31c3", required = False, initial = True) event_32c3 = forms.BooleanField(label = "32c3", required = False, initial = True) #event_33c3 = forms.BooleanField(label = "33c3", required = False, initial = True) - + lang_none = forms.BooleanField(label = "None", required = False, initial = True) lang_en = forms.BooleanField(label = "En", required = False, initial = True) lang_de = forms.BooleanField(label = "De", required = False, initial = True) - + day_1 = forms.BooleanField(label = "1", required = False, initial = True) day_2 = forms.BooleanField(label = "2", required = False, initial = True) day_3 = forms.BooleanField(label = "3", required = False, initial = True) day_4 = forms.BooleanField(label = "4", required = False, initial = True) - + sort_spm = forms.BooleanField(label = "sort by spm", required = False, initial = True) sort_asc = forms.BooleanField(label = "sort asc", required = False, initial = True) - + class BForm(forms.Form): my_text = forms.CharField(label="Zu konvertierender Text:", widget=forms.Textarea(attrs={'rows':30, 'cols':100})) - + def clean_my_text(self): data = self.cleaned_data["my_text"] #data = data + "Ätsch" return data + + +class SimplePasteForm(forms.Form): + text = forms.CharField(label='pad text', + min_length=1, + widget=forms.Textarea(attrs={'rows': 30, + 'cols': 100})) diff --git a/www/templates/www/pad_from_trint.html b/www/templates/www/pad_from_trint.html new file mode 100644 index 00000000..57ebb44c --- /dev/null +++ b/www/templates/www/pad_from_trint.html @@ -0,0 +1,27 @@ +{% extends "base.html" %} + +{% block title %}Convert trint transcript to pad contents{% endblock %} + +{% block content %} +

    {{talk.title}}

    +

    + {% if talk.subtitle_talk %} + {{ talk.subtitle_talk }} + {% endif %} +

    + + + +
    + + {{ form }} + + +
    + + {% csrf_token %}
    +
    + +{% endblock %} diff --git a/www/templates/www/pad_result.html b/www/templates/www/pad_result.html new file mode 100644 index 00000000..b7f0e7d6 --- /dev/null +++ b/www/templates/www/pad_result.html @@ -0,0 +1,30 @@ +{% extends "base.html" %} + +{% block title %}Convert trint transcript to pad contents{% endblock %} + +{% block content %} +

    {{talk.title}}

    +

    + {% if talk.subtitle_talk %} + {{ talk.subtitle_talk }} + {% endif %} +

    + + + +
    {{ result }}
    + +{% if first %} +

    + {% if rest %} + next + {% else %} + next + {% endif %} + +

    +{% endif %} + +{% endblock %} diff --git a/www/transforms.py b/www/transforms.py new file mode 100644 index 00000000..d8885565 --- /dev/null +++ b/www/transforms.py @@ -0,0 +1,20 @@ +def chunks(text): + """Read `text`, splitting it at doubled linebreaks""" + lines = [] + for line in text.split('\n'): + lines.append(re.sub(' {2,}', ' ', line.strip())) + return '\n'.join(lines).split('\n\n') + + +def pad_from_trint(text): + out = "" + + for chunk in chunks(text): + lines = chunk.split('\n') + + for line in lines[2:]: + if line == '': + continue + out += ' ' + line + + return out.replace('\n\n', '\n') diff --git a/www/urls.py b/www/urls.py index 4a34da8e..b8a52b9c 100755 --- a/www/urls.py +++ b/www/urls.py @@ -22,6 +22,7 @@ url(r'^statistics/talks/$',views.statistics_talks), url(r'^statistics/speakers/$',views.statistics_speakers), url(r'^statistics/speakers_in_talks/$',views.statistics_speakers_in_talks), + url(r'^workflow/pad-from-trint/(?P[0-9]+)/(?P[0-9]+(,[0-9]+)*)?$', views.pad_from_trint, name='padFromTrint'), url(r'^test/$',views.test), url(r'^b_test/$',views.b_test), url(r'^admin/',include(admin.site.urls)), diff --git a/www/views.py b/www/views.py index 4f786e67..680cbcaa 100755 --- a/www/views.py +++ b/www/views.py @@ -1,11 +1,13 @@ from django.shortcuts import render, redirect from django.http import HttpResponse, HttpResponseNotFound, Http404 from www.models import Event, Talk, Subtitle, Language, Speaker, Talk_Persons, Statistics_Event, Statistics_Speaker, Event_Days -from www.forms import SubtitleForm, BForm +from www.forms import SubtitleForm, BForm, SimplePasteForm from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import MultipleObjectsReturned from django.shortcuts import get_object_or_404, redirect from django.contrib import messages +from django.contrib.auth.decorators import login_required +from www import transforms import datetime #from django import forms #from copy import deepcopy @@ -241,7 +243,7 @@ def updateSubtitle(request, subtitle_id): def eventStatus(request, event): return render(request, 'status', {'eventname':event}) - + # Speaker summary website def speaker(request, speaker_id): # Check if the Speaker ID exists, if not return a 404 @@ -309,7 +311,7 @@ def speaker(request, speaker_id): # Get all non blacklisted talks from the speaker my_talks = my_speaker.talk_set.all() my_talks = my_talks.filter(blacklisted = False).order_by("-date").prefetch_related("talk_persons_set") - + # Create talk_chunks of 3 per line talks_per_line = 3 my_talks_chunk = [my_talks[x:x+talks_per_line] for x in range(0, my_talks.count(), talks_per_line)] @@ -408,7 +410,7 @@ def statistics_speakers_in_talks(request): # Test-View def test(request): - + if request.method == "POST": form = TestForm(request.POST) if form.is_valid(): @@ -497,3 +499,32 @@ def b_test(request): "form" : my_form, "my_text": text} ) + + +@login_required +def pad_from_trint(request, subtitle_id, next_ids): + if next_ids is None: + next_ids = '' + + nexts = next_ids.split(',') + first = nexts[0] + rest = nexts[1:] + + subtitle = get_object_or_404(Subtitle, pk=subtitle_id) + args = {'next_ids': next_ids, + 'subtitle': subtitle, + 'first': first, + 'rest': rest, + 'form': SimplePasteForm() + } + + if request.method == 'POST': + form = SimplePasteForm(request.POST) + if form.is_valid(): + args['form'] = form + args['result'] = transforms.pad_from_trint(form.cleaned_data['text']) + return render(request, 'www/pad_result.html', + args) + + return render(request, 'www/pad_from_trint.html', + args) From 4d987b511d857af2cf905d6b7c5c42b1ee672769 Mon Sep 17 00:00:00 2001 From: Maximilian Marx Date: Sat, 29 Dec 2018 14:27:23 +0100 Subject: [PATCH 047/473] Move text transforms into common module --- fix_sbv_linebreaks.py | 53 +++------------------- pad_from_trint.py | 2 +- timing_from_pad.py | 30 +++---------- www/transforms.py | 100 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+), 71 deletions(-) diff --git a/fix_sbv_linebreaks.py b/fix_sbv_linebreaks.py index d3bd9cf0..7402487d 100755 --- a/fix_sbv_linebreaks.py +++ b/fix_sbv_linebreaks.py @@ -10,18 +10,10 @@ # You will need the Transcript File and the sbv File #============================================================================== - -import os -import re import sys -def chunks(file): - """Read `file`, splitting it at doubled linebreaks""" - lines = [] - for line in file: - lines.append(re.sub(' {2,}', ' ', line.strip())) - return '\n'.join(lines).split('\n\n') +from www.transforms import fix_sbv_linebreaks if __name__ == '__main__': @@ -38,52 +30,19 @@ def chunks(file): # Check the Transcript File and read it in an array + transcript = '' try: with open(transcript_file, 'r') as f: - transcript_chunks = chunks(f) + transcript = f.read() except IOError as e: sys.exit("Transcript file is not readable or does not exist: {}".format(e)) # Check the sbv file and read it into an array + sbv = '' try: with open(sbv_file, 'r') as f: - chunks = chunks(f) - sbv_timestamps = [] - sbv_chunks = [] - - for chunk in chunks: - parts = chunk.split('\n') - sbv_timestamps += [parts[0]] * (len(parts) - 1) - sbv_chunks += parts[1:] + sbv = f.read() except IOError as e: sys.exit("SBV file is not readable or does not exist: {}".format(e)) - - lines = [] - current_chunk = 0 - total_sbv_chunks = len(sbv_chunks) - - for chunk in transcript_chunks: - if current_chunk >= total_sbv_chunks: - sys.exit("Garbage at end of Transcript file.") - - # collect all the SBV chunks that form this chunk - # we start at the timestamp of then first SBV chunk - timestamp_begin, timestamp = sbv_timestamps[current_chunk].split(',') - line = sbv_chunks[current_chunk] - current_chunk += 1 - - # append SBV chunks until we match the current transcript chunk - while chunk != line and current_chunk < total_sbv_chunks: - # separator may be a space or newline - #print(repr(chunk), repr(line), len(chunk), len(line)) - separator = chunk[len(line)] - line += separator + sbv_chunks[current_chunk] - # collect then timestamp, in case this is then last SBV chunk - timestamp = sbv_timestamps[current_chunk].split(',')[1] - current_chunk += 1 - - lines.append(("{},{}\n{}".format(timestamp_begin, timestamp, line))) - - - print('\n\n'.join(lines)) + print(fix_sbv_linebreaks(transcript, sbv)) diff --git a/pad_from_trint.py b/pad_from_trint.py index faa12dc2..007f3899 100644 --- a/pad_from_trint.py +++ b/pad_from_trint.py @@ -2,10 +2,10 @@ # -*- coding: utf-8 -*- import sys -import re from www.transforms import pad_from_trint + if __name__ == '__main__': if len(sys.argv) != 2: sys.exit("usage: ./{} transcript.sbv".format(sys.argv[0])) diff --git a/timing_from_pad.py b/timing_from_pad.py index 26027270..dbfbf8db 100644 --- a/timing_from_pad.py +++ b/timing_from_pad.py @@ -2,37 +2,21 @@ # -*- coding: utf-8 -*- import sys -import re -import textwrap + +from wwww.transforms import timing_from_pad + if __name__ == '__main__': if len(sys.argv) != 2: sys.exit("usage: ./{} transcript".format(sys.argv[0])) + print + transcript = [] try: with open(sys.argv[1], 'r') as file: - for line in file: - if line == '': - continue - elif line[0] == '*' and line[-1] == '*': - transcript.append(line) - else: - transcript.extend(textwrap.fill(line, width=42).split('\n')) + transcript = file.read() except IOError as err: sys.exit("Transcript not readable: {}").format(err) - length = len(transcript) - odd = False - - if length % 2 == 1: - length -= 1 - odd = True - - chunks = ["\n".join([transcript[i], transcript[i + 1], '']) - for i in range(0, length, 2)] - - if odd: - chunks.append(transcript[-1]) - - print("\n".join(chunks).replace("\n\n\n", "\n\n")) + print(timing_from_pad(transcript)) diff --git a/www/transforms.py b/www/transforms.py index d8885565..c8819177 100644 --- a/www/transforms.py +++ b/www/transforms.py @@ -1,3 +1,7 @@ +import re +import textwrap + + def chunks(text): """Read `text`, splitting it at doubled linebreaks""" lines = [] @@ -6,8 +10,38 @@ def chunks(text): return '\n'.join(lines).split('\n\n') +def groups(transcript): + result = [] + current = [] + + for line in transcript.split('\n'): + if line == '': + result.append(list(current)) + current = [] + else: + current.append(re.sub(' {2,}', ' ', line.strip())) + + if current: + result.append(current) + return result + + +def sbv_from_srt(transcript): + subtitles = groups(transcript) + result = '' + + for subtitle in subtitles: + group = [subtitle[1].replace(' --> ', ',')] + group += subtitle[2:] + group += ['', ''] + result += '\n'.join(group) + + return result + + def pad_from_trint(text): out = "" + text = sbv_from_srt(text).split('\n') for chunk in chunks(text): lines = chunk.split('\n') @@ -18,3 +52,69 @@ def pad_from_trint(text): out += ' ' + line return out.replace('\n\n', '\n') + + +def timing_from_pad(text): + transcript = [] + for line in text: + if line == '': + continue + elif line[0] == '*' and line[-1] == '*': + transcript.append(line) + else: + transcript.extend(textwrap.fill(line, width=42).split('\n')) + + length = len(transcript) + odd = False + + if length % 2 == 1: + length -= 1 + odd = True + + chunks = ["\n".join([transcript[i], transcript[i + 1], '']) + for i in range(0, length, 2)] + + if odd: + chunks.append(transcript[-1]) + + return '\n'.join(chunks).replace('\n\n\n', '\n\n').strip() + + +def fix_sbv_linebreaks(transcript, sbv): + chunks = chunks(f) + sbv_timestamps = [] + sbv_chunks = [] + + for chunk in chunks: + parts = chunk.split('\n') + sbv_timestamps += [parts[0]] * (len(parts) - 1) + sbv_chunks += parts[1:] + + + lines = [] + current_chunk = 0 + total_sbv_chunks = len(sbv_chunks) + + for chunk in transcript_chunks: + if current_chunk >= total_sbv_chunks: + raise ValueError("Garbage at end of Transcript file.") + + # collect all the SBV chunks that form this chunk + # we start at the timestamp of then first SBV chunk + timestamp_begin, timestamp = sbv_timestamps[current_chunk].split(',') + line = sbv_chunks[current_chunk] + current_chunk += 1 + + # append SBV chunks until we match the current transcript chunk + while chunk != line and current_chunk < total_sbv_chunks: + # separator may be a space or newline + separator = chunk[len(line)] + line += separator + sbv_chunks[current_chunk] + # collect the timestamp, in case this is then last SBV chunk + timestamp = sbv_timestamps[current_chunk].split(',')[1] + current_chunk += 1 + + lines.append(("{},{}\n{}".format(timestamp_begin, timestamp, line))) + + + return '\n\n'.join(lines) From cf2126d6010c7e6f3bf21d401e03a12cf6c18a6e Mon Sep 17 00:00:00 2001 From: Maximilian Marx Date: Sat, 29 Dec 2018 17:34:20 +0100 Subject: [PATCH 048/473] Make admin workflow forms more general --- www/admin.py | 59 +++++++++++++++---- www/models.py | 7 +++ .../{pad_from_trint.html => transforms.html} | 12 ++-- ...pad_result.html => transforms_result.html} | 4 +- www/transforms.py | 2 +- www/urls.py | 2 +- www/views.py | 57 ++++++++++++++++-- 7 files changed, 120 insertions(+), 23 deletions(-) rename www/templates/www/{pad_from_trint.html => transforms.html} (52%) rename www/templates/www/{pad_result.html => transforms_result.html} (75%) diff --git a/www/admin.py b/www/admin.py index e7670c29..a4b77dd8 100755 --- a/www/admin.py +++ b/www/admin.py @@ -40,7 +40,7 @@ def queryset(self, request, queryset): class TalkAdmin(admin.ModelAdmin): date_hierarchy = 'date' list_display = ('id', 'frab_id_talk', 'title', - 'event', 'day', 'start',) + 'event', 'day', 'start', 'transcript_by',) list_filter = ('event', DayIndexFilter,) search_fields = ('title', 'event__acronym', 'frab_id_talk',) ordering = ('-event', 'date',) @@ -73,6 +73,26 @@ def queryset(self, request, queryset): return queryset +class WorkflowFilter(admin.SimpleListFilter): + title = 'Needs Interaction' + parameter_name = 'workflow' + + def lookups(self, request, model_admin): + return (('yes', 'Needs interaction'), + #('new', 'Needs a transcript'), + ('no', 'Does not need interaction')) + + def queryset(self, request, queryset): + if self.value() is None: + return queryset + elif self.value() == 'yes': + return queryset.filter(state=4).exclude(blacklisted=True) + # elif self.value() == 'new': + # return queryset.filter(talk__transcript_by=None).exclude(blacklisted=True) + else: + return queryset.exclude(state=4) + + @admin.register(Subtitle) class SubtitleAdmin(admin.ModelAdmin): def status(self, obj): @@ -92,29 +112,48 @@ def status(self, obj): else: return obj.state + def reset_to_transcribing(self, request, queryset): + selected = request.POST.getlist(admin.ACTON_CHECKBOX_NAME) - def pad_from_trint(self, request, queryset): + for sid in selected: + subtitle = get_object_or_404(Subtitle, pk=sid) + subtitle.reset_from_complete() + reset_to_transcribing.short_description = 'Reset subtitle to transcribing' + + def transforms_dwim(self, request, queryset): selected = request.POST.getlist(admin.ACTION_CHECKBOX_NAME) - first = selected[0] - rest = ','.join(selected[1:]) - return HttpResponseRedirect( - reverse('padFromTrint', args=[first, rest])) - actions = ['pad_from_trint'] + ids = [subtitle.pk + for subtitle in Subtitle.objects.filter( + pk__in=selected + ).order_by('autotiming_step')] + + first = ids[0] + rest = ','.join(ids[1:]) + return HttpResponseRedirect( + reverse('workflowTransforms', args=[first, rest])) + transforms_dwim.short_description = 'Do-What-I-Mean (Text Transformation)' + + actions = ['transforms_dwim', 'reset_to_transcribing'] list_display = ('id', 'talk', 'language', 'is_original_lang', 'status', 'complete', 'blacklisted',) - list_filter = (LanguageFilter, 'is_original_lang', 'state', 'complete', - 'blacklisted', ) + list_filter = (WorkflowFilter, LanguageFilter, 'is_original_lang', + 'state', 'complete', 'blacklisted',) raw_id_fields = ('talk',) search_fields = ('talk__event__acronym', 'talk__title', 'talk__frab_id_talk',) +@admin.register(States) +class StatesAdmin(admin.ModelAdmin): + list_display = ('id', 'state_en',) + ordering = ('id',) + + admin.site.register(Tracks) admin.site.register(Links) admin.site.register(Type_of) admin.site.register(Speaker) -admin.site.register(States) admin.site.register(Event_Days) admin.site.register(Rooms) admin.site.register(Language) diff --git a/www/models.py b/www/models.py index 2850dcf7..72305ee4 100755 --- a/www/models.py +++ b/www/models.py @@ -273,6 +273,12 @@ class Speaker_Links(BasisModell): class Transcript (BasisModell): creator = models.CharField(max_length = 20, blank = True, null = True) # None, trint, youtube, scribie, handmade ..., default with id=0 is None + def __str__(self): + if self.creator is None: + return '(no transcript)' + else: + return self.creator + # Talk with all its data class Talk(BasisModell): @@ -806,6 +812,7 @@ class Subtitle(BasisModell): blacklisted = models.BooleanField(default = False) # If syncs to the cdn, and media or YT should be blocked needs_sync_to_sync_folder = models.BooleanField(default = False) needs_removal_from_sync_folder = models.BooleanField(default = False) + autotiming_step = models.PositiveSmallIntegerField(default=0) def _still_in_progress(self, timestamp, state, original_language=True): if original_language != self.is_original_lang: diff --git a/www/templates/www/pad_from_trint.html b/www/templates/www/transforms.html similarity index 52% rename from www/templates/www/pad_from_trint.html rename to www/templates/www/transforms.html index 57ebb44c..4e4f6adb 100644 --- a/www/templates/www/pad_from_trint.html +++ b/www/templates/www/transforms.html @@ -1,6 +1,6 @@ {% extends "base.html" %} -{% block title %}Convert trint transcript to pad contents{% endblock %} +{% block title %}{{ workflow_step }}{% endblock %} {% block content %}

    {{talk.title}}

    @@ -11,12 +11,16 @@

    -
    + - {{ form }} + {{ form }} + {% if step == 2 %} + {{ otherform }} + {% endif %} diff --git a/www/templates/www/pad_result.html b/www/templates/www/transforms_result.html similarity index 75% rename from www/templates/www/pad_result.html rename to www/templates/www/transforms_result.html index b7f0e7d6..3e0599a4 100644 --- a/www/templates/www/pad_result.html +++ b/www/templates/www/transforms_result.html @@ -19,9 +19,9 @@

    {% if first %}

    {% if rest %} - next + next: {{ next_title }} {% else %} - next + next: {{ next_title }} {% endif %}

    diff --git a/www/transforms.py b/www/transforms.py index c8819177..b027f732 100644 --- a/www/transforms.py +++ b/www/transforms.py @@ -41,7 +41,7 @@ def sbv_from_srt(transcript): def pad_from_trint(text): out = "" - text = sbv_from_srt(text).split('\n') + text = sbv_from_srt(text) for chunk in chunks(text): lines = chunk.split('\n') diff --git a/www/urls.py b/www/urls.py index b8a52b9c..68254977 100755 --- a/www/urls.py +++ b/www/urls.py @@ -22,7 +22,7 @@ url(r'^statistics/talks/$',views.statistics_talks), url(r'^statistics/speakers/$',views.statistics_speakers), url(r'^statistics/speakers_in_talks/$',views.statistics_speakers_in_talks), - url(r'^workflow/pad-from-trint/(?P[0-9]+)/(?P[0-9]+(,[0-9]+)*)?$', views.pad_from_trint, name='padFromTrint'), + url(r'^workflow/transforms/(?P[0-9]+)/(?P[0-9]+(,[0-9]+)*)?$', views.text_transforms_dwim, name='workflowTransforms'), url(r'^test/$',views.test), url(r'^b_test/$',views.b_test), url(r'^admin/',include(admin.site.urls)), diff --git a/www/views.py b/www/views.py index 680cbcaa..2148f7af 100755 --- a/www/views.py +++ b/www/views.py @@ -502,7 +502,16 @@ def b_test(request): @login_required -def pad_from_trint(request, subtitle_id, next_ids): +def text_transforms_dwim(request, subtitle_id, next_ids): + TRINT = 0 + TIMING = 1 + SBV = 2 + + STEPS = {0: 'Convert trint transcript to pad', + 1: 'Convert pad to timing input', + 2: 'Fix SBV linebreaks', + } + if next_ids is None: next_ids = '' @@ -515,16 +524,54 @@ def pad_from_trint(request, subtitle_id, next_ids): 'subtitle': subtitle, 'first': first, 'rest': rest, - 'form': SimplePasteForm() + 'form': SimplePasteForm(), + 'talk': subtitle.talk, } + if (subtitle.autotiming_step == 0 and + subtitle.transcription_in_progress and + subtitle.transcript_by.creator == 'Trint'): + args['step'] = 0 + elif (subtitle.autotiming_step == 0 and + not subtitle.transcription_in_progress): + args['step'] = 1 + elif subtitle.autotiming_step == 1: + args['step'] = 2 + args['otherform'] = SimplePasteForm(prefix='SBV') + + + args['workflow_step'] = STEPS[args['step']] + + if first: + next_subtitle = get_object_or_404(Subtitle, pk=first) + args['next_title'] = next_subtitle.title + if request.method == 'POST': form = SimplePasteForm(request.POST) if form.is_valid(): args['form'] = form - args['result'] = transforms.pad_from_trint(form.cleaned_data['text']) - return render(request, 'www/pad_result.html', + + resut = None + input = form.cleaned_data['text'] + + if args['step'] == TRINT: + result = transforms.pad_from_trint(input) + subtitle.autotiming_step = TIMING + subtitle.save() + elif args['step'] == TIMING: + result = transforms.timing_from_pad(input) + subtitle.autotiming_step = SBV + subtitle.save() + elif args['step'] == SBV: + otherform = SimplePasteForm(request.POST, prefix='SBV') + + if otherform.is_valid(): + result = transforms.fix_sbv_linebreaks(input, + otherform.cleaned_data['text']) + + args['result'] = result + return render(request, 'www/transforms_result.html', args) - return render(request, 'www/pad_from_trint.html', + return render(request, 'www/transforms.html', args) From b69aa6f274d269527c5bd394b4c521ae4a4aa59f Mon Sep 17 00:00:00 2001 From: percidae Date: Fri, 4 Jan 2019 10:58:21 +0100 Subject: [PATCH 049/473] Added feature to display the total amount of material length for every event --- data_dump.py | 5 +- pad_from_trint.py | 3 +- update_subtitles_via_amara_import.py | 5 +- www/models.py | 310 +++++++++++++++------------ www/templates/www/event.html | 2 +- www/templates/www/main.html | 2 +- www/urls.py | 2 +- www/views.py | 4 +- 8 files changed, 181 insertions(+), 152 deletions(-) diff --git a/data_dump.py b/data_dump.py index e2c9b0d7..9244c619 100755 --- a/data_dump.py +++ b/data_dump.py @@ -9,6 +9,7 @@ import sys from lxml import etree #from urllib import request +from time import strftime os.environ.setdefault("DJANGO_SETTINGS_MODULE", "subtitleStatus.settings") @@ -43,7 +44,7 @@ persons_string = persons_string + ", " + this_persons[counter].speaker.name counter += 1 #print(persons_string) - print("%s;%s;%s;%s;%s;%s;%s;%s;%s" % (any_talk.event.acronym, any_talk.frab_id_talk, any_talk.id, any_talk.day.index, any_talk.start, any_talk.duration, any_talk.orig_language.language_de[0:2], any_talk.title, persons_string)) + print("%s;%s;%s;%s;" + str(strftime("%H:%M", any_talk.start)) + ";" + str(strftime("%H:%M", any_talk.duration)) + ";%s;%s;%s" % (any_talk.event.acronym, any_talk.frab_id_talk, any_talk.id, any_talk.day.index, any_talk.orig_language.language_de[0:2], any_talk.title, persons_string)) """ # Für Translations! @@ -104,4 +105,4 @@ my_string += "\n" #print(this_subtitle.last_changed_on_amara) print(my_string) -""" \ No newline at end of file +""" diff --git a/pad_from_trint.py b/pad_from_trint.py index 007f3899..e13d3fae 100644 --- a/pad_from_trint.py +++ b/pad_from_trint.py @@ -6,9 +6,10 @@ from www.transforms import pad_from_trint + if __name__ == '__main__': if len(sys.argv) != 2: - sys.exit("usage: ./{} transcript.sbv".format(sys.argv[0])) + sys.exit("usage: ./{} transcript.srt".format(sys.argv[0])) transcript = [] try: diff --git a/update_subtitles_via_amara_import.py b/update_subtitles_via_amara_import.py index 14ea3481..e3b0ea64 100755 --- a/update_subtitles_via_amara_import.py +++ b/update_subtitles_via_amara_import.py @@ -32,7 +32,10 @@ my_talks = Talk.objects.filter(next_amara_activity_check__lte = start, blacklisted = False) print("Talks which need an activity update: ", my_talks.count()) for any in my_talks: +# try: any.check_activity_on_amara() +# except: +# pass # Check the "big" amara query for talks which had a new activity my_talks = Talk.objects.filter(needs_complete_amara_update = True, blacklisted = False) @@ -53,4 +56,4 @@ end = datetime.now(timezone.utc) print("Start: ", start) -print("End: ", end, " Duration: ", end - start) \ No newline at end of file +print("End: ", end, " Duration: ", end - start) diff --git a/www/models.py b/www/models.py index 72305ee4..be4c2727 100755 --- a/www/models.py +++ b/www/models.py @@ -91,6 +91,25 @@ def has_statistics(self): else: return True + @property + def complete_content_duration(self): + """ How 'long' is all material we have of an event """ + my_talks = Talk.objects.filter(blacklisted = False, event = self) + sum = 0 + for any in my_talks: + # Special case for talks who have no specific video_duration yet + if any.video_duration == "00:00:00": + sum += calculate_seconds_from_time(any.duration) + else: + sum += calculate_seconds_from_time(any.video_duration) + all_in_seconds = sum + hours = int(sum //3600) + sum -= 3600 * hours + minutes = int(sum // 60) + sum -= 60* minutes + seconds = int(sum) + return [all_in_seconds, hours, minutes, seconds] + # Save Fahrplan xml file with version in the name into ./www/static/ def save_fahrplan_xml_file(self): import datetime @@ -616,75 +635,79 @@ def calculated_time_delta_for_activities(self): # Check activity on amara @transaction.atomic def check_activity_on_amara(self, force = False): - # Take the timestamp for "last executed at" at the beginning of the function - start_timestamp = datetime.now(timezone.utc) - # Only proceed if forced or if the time delta for another query has passed - if force or (start_timestamp > self.next_amara_activity_check): - import requests - # Only check for new versions. New urls or other stuff is not interesting - # Check for changes after the last check - # If the check is forced, do not care about the last time the activity was checked - if force: - parameters = {'type': 'version-added'} - else: - parameters = {'type': 'version-added', - 'after': self.amara_activity_last_checked} - basis_url = "https://amara.org/api/videos/" - url = basis_url + self.amara_key + "/activity/" - results = {} - # Loop as long as not all new activity datasets have been checked - # The json result from amara includes a "next" field which has the url for the next query if not - # all results came with the first query - while url != None: - r = requests.get(url, headers = cred.AMARA_HEADER, params = parameters) - #print(r.text) - # If amara doesn't reply with a valid json create one. - try: - activities = json.loads(r.text) - except: - self.check_amara_video_data() - activities = json.loads('{"meta":{"previous":null,"next":null,"offset":0,"limit":20,"total_count":0},"objects":[]}') - url = activities["meta"]["next"] - # Get the results for any language separate - for any in activities["objects"]: - language = any["language"] - # Parse the date time string into a datetime object - timestamp = datetime.strptime(any["date"], '%Y-%m-%dT%H:%M:%SZ') - # Amara Timestamps are all in utc, they just don't know yet, so they need to be force told - timestamp = timestamp.replace(tzinfo = timezone.utc) - # Add the new key to the dictionary and only at insert set the timestamp - results.setdefault(language, timestamp) - # Keep the newest timestamp over all api queries - if results[language] < timestamp: - results[language] = timestamp - #print(results) - # check if subtitles are present and need new data.. - for any_language in results.keys(): - my_subtitles = Subtitle.objects.filter(talk = self, language__lang_amara_short = any_language) - # Set flag for big query, this means a subtitle is missing because it was recently new added - if my_subtitles.count() == 0: - # Set the big update flag - self.needs_complete_amara_update = True - my_language = Language.objects.get(lang_amara_short = any_language) - # Don't create a subtitle here, this will cause subtitles with revision = 0 - #my_subtitle, created = Subtitle.objects.get_or_create(talk = self, language = my_language, last_changed_on_amara = results[any_language]) - print("Talk id: ",self.id, " will get a new created subtitle") - elif my_subtitles.count() == 1: - # Only proceed if the last activity has changed - # The copy is a dirty workaround because saving in my_subtitles[0] did not work! - my_subtitle = my_subtitles[0] - if my_subtitle.last_changed_on_amara < results[any_language]: - my_subtitle.last_changed_on_amara = results[any_language] + # Only if the talk has an amara key + if self.amara_key != "": + # Take the timestamp for "last executed at" at the beginning of the function + start_timestamp = datetime.now(timezone.utc) + # Only proceed if forced or if the time delta for another query has passed + if force or (start_timestamp > self.next_amara_activity_check): + import requests + # Only check for new versions. New urls or other stuff is not interesting + # Check for changes after the last check + # If the check is forced, do not care about the last time the activity was checked + if force: + parameters = {'type': 'version-added'} + else: + parameters = {'type': 'version-added', + 'after': self.amara_activity_last_checked} + basis_url = "https://amara.org/api/videos/" + url = basis_url + self.amara_key + "/activity/" + results = {} + # Loop as long as not all new activity datasets have been checked + # Loop only if the talk has an amara_key + # The json result from amara includes a "next" field which has the url for the next query if not + # all results came with the first query + while (url != None) and (url != basis_url + "/activity/"): + r = requests.get(url, headers = cred.AMARA_HEADER, params = parameters) + #print(r.text) + # If amara doesn't reply with a valid json create one. + try: + activities = json.loads(r.text) + except: + self.check_amara_video_data() + activities = json.loads('{"meta":{"previous":null,"next":null,"offset":0,"limit":20,"total_count":0},"objects":[]}') + print(url) + url = activities["meta"]["next"] + # Get the results for any language separate + for any in activities["objects"]: + language = any["language"] + # Parse the date time string into a datetime object + timestamp = datetime.strptime(any["date"], '%Y-%m-%dT%H:%M:%SZ') + # Amara Timestamps are all in utc, they just don't know yet, so they need to be force told + timestamp = timestamp.replace(tzinfo = timezone.utc) + # Add the new key to the dictionary and only at insert set the timestamp + results.setdefault(language, timestamp) + # Keep the newest timestamp over all api queries + if results[language] < timestamp: + results[language] = timestamp + #print(results) + # check if subtitles are present and need new data.. + for any_language in results.keys(): + my_subtitles = Subtitle.objects.filter(talk = self, language__lang_amara_short = any_language) + # Set flag for big query, this means a subtitle is missing because it was recently new added + if my_subtitles.count() == 0: # Set the big update flag self.needs_complete_amara_update = True - my_subtitle.save() - print("Talk id: ",self.id, "Subtitle id: ", my_subtitle.id, " new last changes: ", my_subtitle.last_changed_on_amara ) - else: - print("Something wrong with talk", self.id, self.title) - # Save the timestamp of the start of the function as last checked activity on amara timestamp - self.amara_activity_last_checked = start_timestamp - self.next_amara_activity_check = start_timestamp + self.calculated_time_delta_for_activities - self.save() + my_language = Language.objects.get(lang_amara_short = any_language) + # Don't create a subtitle here, this will cause subtitles with revision = 0 + #my_subtitle, created = Subtitle.objects.get_or_create(talk = self, language = my_language, last_changed_on_amara = results[any_language]) + print("Talk id: ",self.id, " will get a new created subtitle") + elif my_subtitles.count() == 1: + # Only proceed if the last activity has changed + # The copy is a dirty workaround because saving in my_subtitles[0] did not work! + my_subtitle = my_subtitles[0] + if my_subtitle.last_changed_on_amara < results[any_language]: + my_subtitle.last_changed_on_amara = results[any_language] + # Set the big update flag + self.needs_complete_amara_update = True + my_subtitle.save() + print("Talk id: ",self.id, "Subtitle id: ", my_subtitle.id, " new last changes: ", my_subtitle.last_changed_on_amara ) + else: + print("Something wrong with talk", self.id, self.title) + # Save the timestamp of the start of the function as last checked activity on amara timestamp + self.amara_activity_last_checked = start_timestamp + self.next_amara_activity_check = start_timestamp + self.calculated_time_delta_for_activities + self.save() # Check amara video-data @transaction.atomic @@ -693,85 +716,86 @@ def check_amara_video_data(self, force = False): # Only query amara if forced or flag is set if force or self.needs_complete_amara_update: url = "https://amara.org/api/videos/" + self.amara_key + "/languages/?format=json" - import requests - r = requests.get(url, headers = cred.AMARA_HEADER) - activities = json.loads(r.text) - for any_subtitle in activities["objects"]: - print("Talk_ID:", self.id, "Amara_key:", self.amara_key) - print("Language_code:", any_subtitle["language_code"]) - amara_subt_lang = any_subtitle["language_code"] - print("is_primary_audio_language = is_original:", any_subtitle["is_primary_audio_language"]) - amara_subt_is_original = any_subtitle["is_primary_audio_language"] - print("subtitles_complete:", any_subtitle["subtitles_complete"]) - amara_subt_is_complete = any_subtitle["subtitles_complete"] - print("versions:", len(any_subtitle["versions"])) - amara_subt_revision = len(any_subtitle["versions"]) - print("\n") - # Only proceed if the revision on amara is higher than zero - # Zero can exist if someone once clicked a language but didn't save anything - if amara_subt_revision > 0: - # Get the right subtitle dataset or create it, only if the version is not null - my_language = Language.objects.get(lang_amara_short = amara_subt_lang) - my_subtitle, created = Subtitle.objects.get_or_create(talk = self, language = my_language) - # Proceed if the version on amara has changed - if my_subtitle.revision != amara_subt_revision: - # If the subtitle was not complete and is not complete - if not my_subtitle.complete and not amara_subt_is_complete: - # Just update the data - my_subtitle.is_original_lang = amara_subt_is_original - my_subtitle.revision = amara_subt_revision - my_subtitle.save() - # If this is an subtitle which is the original language - # and is in a state which has already statistics, also recalculate them - if my_subtitle.is_original_lang and my_subtitle.state_id == (5 or 6 or 7): - self.reset_related_statistics_data() - # If the subtitle was not complete but is complete now - elif not my_subtitle.complete and amara_subt_is_complete: - my_subtitle.complete = amara_subt_is_complete - my_subtitle.is_orignal_lang = amara_subt_is_original - my_subtitle.revision = amara_subt_revision - # This sets the sync flags and the tweet-flag and also lets the statistics to be recalculated - my_subtitle.set_complete(was_already_complete = False) - # If the talk also is in the original language, recalculate statistics - if my_subtitle.is_original_lang: - my_subtitle.talk.reset_related_statistics_data() - my_subtitle.save() - # If the subtitle was complete and is still complete - elif my_subtitle.complete and amara_subt_is_complete: - my_subtitle.complete = amara_subt_is_complete - my_subtitle.is_orignal_lang = amara_subt_is_original - my_subtitle.revision = amara_subt_revision - # This sets the sync flags and the tweet-flag and lets the statistics to be recalculated - my_subtitle.set_complete(was_already_complete = True) - # If the talk also is in the original language, recalculate statistics + if self.amara_key != "": + import requests + r = requests.get(url, headers = cred.AMARA_HEADER) + activities = json.loads(r.text) + for any_subtitle in activities["objects"]: + print("Talk_ID:", self.id, "Amara_key:", self.amara_key) + print("Language_code:", any_subtitle["language_code"]) + amara_subt_lang = any_subtitle["language_code"] + print("is_primary_audio_language = is_original:", any_subtitle["is_primary_audio_language"]) + amara_subt_is_original = any_subtitle["is_primary_audio_language"] + print("subtitles_complete:", any_subtitle["subtitles_complete"]) + amara_subt_is_complete = any_subtitle["subtitles_complete"] + print("versions:", len(any_subtitle["versions"])) + amara_subt_revision = len(any_subtitle["versions"]) + print("\n") + # Only proceed if the revision on amara is higher than zero + # Zero can exist if someone once clicked a language but didn't save anything + if amara_subt_revision > 0: + # Get the right subtitle dataset or create it, only if the version is not null + my_language = Language.objects.get(lang_amara_short = amara_subt_lang) + my_subtitle, created = Subtitle.objects.get_or_create(talk = self, language = my_language) + # Proceed if the version on amara has changed + if my_subtitle.revision != amara_subt_revision: + # If the subtitle was not complete and is not complete + if not my_subtitle.complete and not amara_subt_is_complete: + # Just update the data + my_subtitle.is_original_lang = amara_subt_is_original + my_subtitle.revision = amara_subt_revision + my_subtitle.save() + # If this is an subtitle which is the original language + # and is in a state which has already statistics, also recalculate them + if my_subtitle.is_original_lang and my_subtitle.state_id == (5 or 6 or 7): + self.reset_related_statistics_data() + # If the subtitle was not complete but is complete now + elif not my_subtitle.complete and amara_subt_is_complete: + my_subtitle.complete = amara_subt_is_complete + my_subtitle.is_orignal_lang = amara_subt_is_original + my_subtitle.revision = amara_subt_revision + # This sets the sync flags and the tweet-flag and also lets the statistics to be recalculated + my_subtitle.set_complete(was_already_complete = False) + # If the talk also is in the original language, recalculate statistics + if my_subtitle.is_original_lang: + my_subtitle.talk.reset_related_statistics_data() + my_subtitle.save() + # If the subtitle was complete and is still complete + elif my_subtitle.complete and amara_subt_is_complete: + my_subtitle.complete = amara_subt_is_complete + my_subtitle.is_orignal_lang = amara_subt_is_original + my_subtitle.revision = amara_subt_revision + # This sets the sync flags and the tweet-flag and lets the statistics to be recalculated + my_subtitle.set_complete(was_already_complete = True) + # If the talk also is in the original language, recalculate statistics + if my_subtitle.is_original_lang: + my_subtitle.talk.reset_related_statistics_data() + my_subtitle.save() + # If the subtitle was complete but isn't any more + elif my_subtitle.complete and not amara_subt_is_complete: + my_subtitle.complete = amara_subt_is_complete + my_subtitle.is_orignal_lang = amara_subt_is_original + my_subtitle.revision = amara_subt_revision + # Resets the states and also the statistics if it is the original language + my_subtitle.reset_from_complete() + my_subtitle.save() + + # If the revision hasn't changed but the complete flag has changed, set the subtitle complete + elif my_subtitle.complete and not amara_subt_is_complete: + my_subtitle.set_complete() if my_subtitle.is_original_lang: my_subtitle.talk.reset_related_statistics_data() + # Set the right state if the default is still active on "1" + if my_subtitle.state_id == 1 and my_subtitle.is_original_lang: + my_subtitle.state_id = 2 my_subtitle.save() - # If the subtitle was complete but isn't any more - elif my_subtitle.complete and not amara_subt_is_complete: - my_subtitle.complete = amara_subt_is_complete - my_subtitle.is_orignal_lang = amara_subt_is_original - my_subtitle.revision = amara_subt_revision - # Resets the states and also the statistics if it is the original language - my_subtitle.reset_from_complete() - my_subtitle.save() - - # If the revision hasn't changed but the complete flag has changed, set the subtitle complete - elif my_subtitle.complete and not amara_subt_is_complete: - my_subtitle.set_complete() - if my_subtitle.is_original_lang: - my_subtitle.talk.reset_related_statistics_data() - # Set the right state if the default is still active on "1" - if my_subtitle.state_id == 1 and my_subtitle.is_original_lang: - my_subtitle.state_id = 2 - my_subtitle.save() - elif my_subtitle.state_id == 1 and not my_subtitle.is_original_lang: - my_subtitle.state_id = 11 - my_subtitle.save() - # Save the timestamp when this function was last used and reset the flag - self.amara_complete_update_last_checked = start_timestamp - self.needs_complete_amara_update = False - self.save() + elif my_subtitle.state_id == 1 and not my_subtitle.is_original_lang: + my_subtitle.state_id = 11 + my_subtitle.save() + # Save the timestamp when this function was last used and reset the flag + self.amara_complete_update_last_checked = start_timestamp + self.needs_complete_amara_update = False + self.save() def __str__(self): diff --git a/www/templates/www/event.html b/www/templates/www/event.html index 7f06a84e..116edaf2 100755 --- a/www/templates/www/event.html +++ b/www/templates/www/event.html @@ -4,7 +4,7 @@ {% block title %}C3Subtitles{% endblock %} {% block content %} -

    {{my_event.title}}{% if my_event.has_statistics %} {% endif %}

    +

    {{my_event.title}}{% if my_event.has_statistics %} {% endif %}

    {% if my_event.has_statistics %} diff --git a/www/templates/www/main.html b/www/templates/www/main.html index 6bcd909c..0c5bfb18 100755 --- a/www/templates/www/main.html +++ b/www/templates/www/main.html @@ -36,7 +36,7 @@

    C3Subtitles

    {% if not event.blacklisted %}

    {{ event.title }} - +

    {{ event.start }} - {{ event.end }}

    diff --git a/www/urls.py b/www/urls.py index 68254977..9c5c65a5 100755 --- a/www/urls.py +++ b/www/urls.py @@ -6,7 +6,7 @@ urlpatterns = patterns('', url(r'^$', views.start, name="home"), - url(r'^hello/$',views.clock), + url(r'^hello/$', views.clock), url(r'^event/(?P\w+)/$', views.event), url(r'^event/(?P\w+)/day/(?P\d+)$', views.event), url(r'^event/(?P\w+)/day/(?P\d+)/lang/(?P\w+)$', views.event), diff --git a/www/views.py b/www/views.py index 2148f7af..86facf0a 100755 --- a/www/views.py +++ b/www/views.py @@ -45,8 +45,8 @@ def event (request, event_acronym, *args, **kwargs): "date", "start", "room__room") - # Special case for 34c4 - if my_event.id == 6: + # Special case for 35c3, only show the talks with all data complete + if my_event.id == 8: my_talks = my_talks.all().exclude(video_duration = "00:00:00").exclude(amara_key = "").exclude(filename = "") my_langs = Language.objects.filter(pk__in=[a['orig_language'] for a in my_talks.values('orig_language')]) if "day" in kwargs and int(kwargs.get("day")) > 0: From c9a0ce6e68ce08a4ad8f29dcf422a05176f2838c Mon Sep 17 00:00:00 2001 From: percidae Date: Fri, 4 Jan 2019 10:59:28 +0100 Subject: [PATCH 050/473] String representation of 'Speaker' added to see it in the admin interface --- www/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/www/models.py b/www/models.py index be4c2727..719dcbb2 100755 --- a/www/models.py +++ b/www/models.py @@ -245,6 +245,9 @@ def has_links(self): else: return True + def __str__(self): + return self.name + """ # Probably not needed any more.. def average_wpm_in_one_talk(self, talk): From 4e3d30e398c7c26ab459c625f15dd3209028a042 Mon Sep 17 00:00:00 2001 From: percidae Date: Sun, 6 Jan 2019 14:42:25 +0100 Subject: [PATCH 051/473] Some changes towards a database usable for different events, not only CCC congresses --- www/models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/www/models.py b/www/models.py index 719dcbb2..329e0811 100755 --- a/www/models.py +++ b/www/models.py @@ -48,6 +48,7 @@ class Event(BasisModell): blacklisted = models.BooleanField(default = False, blank = True) cdn_subtitles_root_folder = models.URLField(default = "", blank = True) subfolder_in_sync_folder = models.CharField(max_length = 100, default = "", blank = True) # For the rsync to the selfnet mirror, no slashes at the beginning and end + frab_id_prefix = models.CharField(max_length = 100, default = "", blank = True) # This allows other frab-id offsets of other events to be unique too in the database def isDifferent(id, xmlFile): with open("data/eventxml/{}.xml".format(id),'rb') as f: @@ -221,7 +222,7 @@ def __str__(self): # Speaker or Speakers of the Talk class Speaker(BasisModell): - frab_id = models.PositiveSmallIntegerField(default = -1) + frab_id = models.CharField(max_length = 12, default = "-1", blank = True) name = models.CharField(max_length = 50, default = "") doppelgaenger_of = models.ForeignKey('self', on_delete = models.SET_NULL, blank = True, null = True) abstract = models.TextField(default = "", blank = True, null = True) @@ -304,7 +305,7 @@ def __str__(self): # Talk with all its data class Talk(BasisModell): - frab_id_talk = models.CharField(max_length = 10, default = "-1", blank = True) + frab_id_talk = models.CharField(max_length = 12, default = "-1", blank = True) blacklisted = models.BooleanField(default=False, blank = True) day = models.ForeignKey(Event_Days, default = 1, blank = True) room = models.ForeignKey(Rooms, default = 15) From 5772d23208ad804814b9117c7d2f1a2453cbf1d3 Mon Sep 17 00:00:00 2001 From: percidae Date: Sun, 6 Jan 2019 15:33:20 +0100 Subject: [PATCH 052/473] Added Talk_Persons to the Django Admin views --- www/admin.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/www/admin.py b/www/admin.py index a4b77dd8..1bc71b1c 100755 --- a/www/admin.py +++ b/www/admin.py @@ -13,6 +13,7 @@ from www.models import Rooms from www.models import Language from www.models import Statistics_Raw_Data +from www.models import Talk_Persons # Register your models here. @@ -150,6 +151,16 @@ class StatesAdmin(admin.ModelAdmin): ordering = ('id',) +@admin.register(Talk_Persons) +class TalkPersonsAdmin(admin.ModelAdmin): + #date_hierarchy = 'id' + list_display = ('id', 'speaker', 'talk', 'created', 'touched', 'average_spm', + 'average_wpm', 'recalculate_statistics', 'strokes', 'time_delta', 'n_most_frequent_words',) + #list_filter = () + search_fields = ('talk', 'speaker',) + ordering = ('-id', ) + + admin.site.register(Tracks) admin.site.register(Links) admin.site.register(Type_of) From c2103bd789c929fc20c0954fe73f4ca63f36bfa6 Mon Sep 17 00:00:00 2001 From: percidae Date: Tue, 19 Nov 2019 20:17:22 +0100 Subject: [PATCH 053/473] Added italics to be removed from subtitles-text for statistics creation --- www/statistics_helper.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/www/statistics_helper.py b/www/statistics_helper.py index 8fd67a65..b55454de 100755 --- a/www/statistics_helper.py +++ b/www/statistics_helper.py @@ -48,7 +48,9 @@ [", ", " "], # To avoid the substitution in numbers ["\. ", " "], # To avoid the substitution in numbers [": ", " "], - [" - ", " "] + [" - ", " "], + ["", " "], + ["", " "] ] # The most n common words should appear in the word_frequencies @@ -382,4 +384,4 @@ def n_most_common_words(word_frequencies, as_json = False): if as_json: return json.dumps(return_dict, ensure_ascii = False) else: - return return_dict \ No newline at end of file + return return_dict From 507d39cdc611a77981b51bcde2dca89898944e8d Mon Sep 17 00:00:00 2001 From: percidae Date: Tue, 19 Nov 2019 20:18:58 +0100 Subject: [PATCH 054/473] Changed character length of some fields --- www/models.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/www/models.py b/www/models.py index 329e0811..c1ff6bc0 100755 --- a/www/models.py +++ b/www/models.py @@ -41,7 +41,7 @@ class Event(BasisModell): building = models.CharField(max_length = 30, default = "", blank = True) ftp_startfolder = models.CharField(max_length = 100, default = "", blank = True) ftp_subfolders_extensions = models.ManyToManyField(Folders_Extensions, default = None, blank = True) - hashtag = models.CharField(max_length = 10, default = "", blank = True) + hashtag = models.CharField(max_length = 20, default = "", blank = True) subfolder_to_find_the_filenames = models.CharField(max_length = 20, default = "", blank = True) # To find the right filenames via regex via frab-id speaker_json_link = models.URLField(blank = True, default = "") speaker_json_version = models.CharField(max_length = 50, default = "0.0", blank = True) @@ -214,7 +214,7 @@ def __str__(self): # How the talk is presented, like a workshop or a talk class Type_of(BasisModell): - type = models.CharField(max_length = 20, default = "") + type = models.CharField(max_length = 50, default = "") def __str__(self): return self.type @@ -222,7 +222,7 @@ def __str__(self): # Speaker or Speakers of the Talk class Speaker(BasisModell): - frab_id = models.CharField(max_length = 12, default = "-1", blank = True) + frab_id = models.CharField(max_length = 20, default = "-1", blank = True) name = models.CharField(max_length = 50, default = "") doppelgaenger_of = models.ForeignKey('self', on_delete = models.SET_NULL, blank = True, null = True) abstract = models.TextField(default = "", blank = True, null = True) @@ -305,7 +305,7 @@ def __str__(self): # Talk with all its data class Talk(BasisModell): - frab_id_talk = models.CharField(max_length = 12, default = "-1", blank = True) + frab_id_talk = models.CharField(max_length = 20, default = "-1", blank = True) blacklisted = models.BooleanField(default=False, blank = True) day = models.ForeignKey(Event_Days, default = 1, blank = True) room = models.ForeignKey(Rooms, default = 15) From 3cd083c03200c3bf7fbc2de35084d2c85d1260e1 Mon Sep 17 00:00:00 2001 From: percidae Date: Tue, 19 Nov 2019 20:20:15 +0100 Subject: [PATCH 055/473] Added a prefix to the frab number to be able to add events outside of CCC Congress --- update_speakers_via_speaker_json_import.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/update_speakers_via_speaker_json_import.py b/update_speakers_via_speaker_json_import.py index 0a0e2d05..d962a600 100755 --- a/update_speakers_via_speaker_json_import.py +++ b/update_speakers_via_speaker_json_import.py @@ -47,6 +47,7 @@ if event.speaker_json_version == result["schedule_speakers"]["version"]: print("Not doing anything here, there is no new version available!\n") continue + prefix = event.frab_id_prefix # Iterate over any speaker for any_speaker in result["schedule_speakers"]["speakers"]: #print(any_speaker["id"]) @@ -57,7 +58,7 @@ #print(any_link["title"]) #print(any_link["url"]) # Get or create a speaker with the same frab id - my_speaker, created = Speaker.objects.get_or_create(frab_id = any_speaker["id"]) + my_speaker, created = Speaker.objects.get_or_create(frab_id = prefix + any_speaker["id"]) # Only alter the entry if the name has changed if len(any_speaker["full_public_name"]) <= 50 and my_speaker.name != any_speaker["full_public_name"]: my_speaker.name = any_speaker["full_public_name"] From 8053e4114a3018c7c27502c1ce9d58e25bcceccf Mon Sep 17 00:00:00 2001 From: percidae Date: Tue, 19 Nov 2019 20:20:59 +0100 Subject: [PATCH 056/473] Added a prefix to the frab number to be able to add events outside of CCC Congress --- update_events_xml_schedule_import.py | 34 +++++++++++++++------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/update_events_xml_schedule_import.py b/update_events_xml_schedule_import.py index 2845ee78..4d29bce9 100755 --- a/update_events_xml_schedule_import.py +++ b/update_events_xml_schedule_import.py @@ -54,7 +54,7 @@ def error(message=""): # Reset everything ============================================================= def set_vars_empty(url = ""): global schedule_url, schedule_version, acronym, event_title, event_start - global event_end, event_days, timeslot_duration, day_index, day_date + global event_end, event_days, timeslot_duration, day_index, day_date#, event_frab_prefix global day_start, day_end, talk_room, talk, talk_frab_id, talk_date, talk_start, talk_duration global talk_slug, talk_optout, talk_title, talk_subtitle, talk_track, talk_type, talk_language, talk_abstract global talk_description, talk_persons, talk_links, talk_guid @@ -66,6 +66,7 @@ def set_vars_empty(url = ""): event_start = "" event_end = "" event_days = "" + event_frab_prefix = "" timeslot_duration = "" day_index = "" day_date = "" @@ -107,6 +108,7 @@ def set_vars_empty(url = ""): event_start = "" event_end = "" event_days = "" +#event_frab_prefix = "" timeslot_duration = "" day_index = "" day_date = "" @@ -146,10 +148,10 @@ def set_vars_empty(url = ""): #=============================================================================== # Main reading/writing function -def read_xml_and_save_to_database(): +def read_xml_and_save_to_database(event_frab_prefix): global url_to_this_fahrplan set_vars_empty(url_to_this_fahrplan) - global schedule_url, schedule_version, acronym, event_title, event_start + global schedule_url, schedule_version, acronym, event_title, event_start#, event_frab_prefix global event_end, event_days, timeslot_duration, day_index, day_date global day_start, day_end, talk_room, talk, talk_frab_id, talk_date, talk_start, talk_duration global talk_slug, talk_optout, talk_title, talk_subtitle, talk_track, talk_type, talk_language, talk_abstract @@ -204,7 +206,7 @@ def read_xml_and_save_to_database(): error("Problem with timeslot_duration") # Write event data to database - save_event_data() + save_event_data() # Loop around the day tags while (counter_day < len_day): @@ -239,7 +241,7 @@ def read_xml_and_save_to_database(): len_event = len(fahrplan[counter_day][counter_room]) counter_event = 0 - # Loop around the event tags (talks) + # Loop around the event tags (talks!) while (counter_event < len_event): # check how much subelements are available for this event (talk) len_of_tags = len(fahrplan[counter_day][counter_room][counter_event]) @@ -247,7 +249,7 @@ def read_xml_and_save_to_database(): # Read event/talk data # talk_frab_id if fahrplan[counter_day][counter_room][counter_event].tag == "event": - talk_frab_id = int(fahrplan[counter_day][counter_room][counter_event].get("id")) + talk_frab_id = fahrplan[counter_day][counter_room][counter_event].get("id") else: error("Problem with talk_frab_id") @@ -376,7 +378,7 @@ def read_xml_and_save_to_database(): error("Problem with persons id") # Write persons data to database - save_persons_data() + save_persons_data(event_frab_prefix) # links (on different positions depending on schedule version) talk_links = [] @@ -395,7 +397,7 @@ def read_xml_and_save_to_database(): error("Problem with links") # Write event/talk data to database - save_talk_data() + save_talk_data(event_frab_prefix) counter_event += 1 counter_room +=1 @@ -455,12 +457,12 @@ def save_room_data(): #my_room = Rooms.objects.get(room = talk_room) # Save the data of the speakers into the database -def save_persons_data (): - global talk_persons, my_persons +def save_persons_data (event_frab_prefix): + global talk_persons, my_persons#, event_frab_prefix my_persons = [] my_person = [] for someone in talk_persons: - my_person = Speaker.objects.get_or_create(frab_id = someone[0])[0] + my_person = Speaker.objects.get_or_create(frab_id = event_frab_prefix + str(someone[0]))[0] if my_person.name != someone[1]: my_person.name = someone[1] if len(my_person.name) > 50: @@ -485,8 +487,8 @@ def save_languages_data(): pass # Save the data of the event talk into the database -def save_talk_data (): - global schedule_url, schedule_version, acronym, event_title, event_start +def save_talk_data (event_frab_prefix): + global schedule_url, schedule_version, acronym, event_title, event_start#, event_frab_prefix global event_end, event_days, timeslot_duration, day_index, day_date global day_start, day_end, talk_room, talk, talk_frab_id, talk_date, talk_start, talk_duration global talk_slug, talk_optout, talk_title, talk_subtitle, talk_track, talk_type, talk_language, talk_abstract @@ -496,7 +498,7 @@ def save_talk_data (): my_language = Language.objects.get(lang_amara_short = talk_language) my_talk = [] - my_talk = Talk.objects.get_or_create(frab_id_talk = talk_frab_id)[0] + my_talk = Talk.objects.get_or_create(frab_id_talk = event_frab_prefix + str(talk_frab_id))[0] if my_talk.room != my_room: my_talk.room = my_room my_talk.save() @@ -580,7 +582,7 @@ def save_talk_data (): # For every fahrplan file for url_to_this_fahrplan in url_array: - response = request.urlopen(url_to_this_fahrplan) + response = request.urlopen(url_to_this_fahrplan) tree = etree.parse(response) fahrplan = tree.getroot() @@ -595,7 +597,7 @@ def save_talk_data (): #print("Debug: Version in DB: ", this_event.schedule_version,"\n\n") #Funktion für Fahrplan in Datenbank schubsen - read_xml_and_save_to_database() + read_xml_and_save_to_database(event_frab_prefix = this_event.frab_id_prefix) print ("Durch gelaufen, Error Code: ", error_code) print ("Fehler: ",error_string) From c0b973a78a7026890a401bc7149908b4aecf5a57 Mon Sep 17 00:00:00 2001 From: percidae Date: Tue, 19 Nov 2019 21:41:13 +0100 Subject: [PATCH 057/473] Added a visible tag for available statistics data and changed the glyphicon of the transcript tag --- www/templates/www/talk_small.html | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/www/templates/www/talk_small.html b/www/templates/www/talk_small.html index 9d292e6c..2c88b647 100755 --- a/www/templates/www/talk_small.html +++ b/www/templates/www/talk_small.html @@ -49,19 +49,28 @@

    {% if talk.has_transcript_by_trint %} {% endif %} {% if talk.has_transcript_by_scribie %} {% endif %} {% if talk.has_transcript_by_youtube %} + {% endif %} + {% if talk.has_speakers_statistics %} + + {% elif talk.has_statistics %} + {% endif %}

    From b040af834a79329b8f6f40dfece6a24408b77759 Mon Sep 17 00:00:00 2001 From: percidae Date: Sun, 22 Dec 2019 16:38:44 +0100 Subject: [PATCH 058/473] Mode dynamic reading of the current fahrplan version --- www/models.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/www/models.py b/www/models.py index c1ff6bc0..ae98a8c2 100755 --- a/www/models.py +++ b/www/models.py @@ -125,7 +125,13 @@ def save_fahrplan_xml_file(self): # Get the version from the xml tree = etree.parse(request.urlopen(self.schedule_xml_link)) fahrplan = tree.getroot() - fahrplan_version = fahrplan[0].text + i = 0 + while i < len(fahrplan): + if fahrplan[i].tag == "version": + fahrplan_version = fahrplan[i].text + break + else: + i+=1 # Create the filename and save folder = "./www/static/fahrplan_files/" filename = self.acronym + " fahrplan version " + fahrplan_version + " " + "{:%Y-%m-%d_%H:%M:%S}".format(datetime.datetime.now()) From 775edf7f60e65911e6de606b2080145f5685cf0f Mon Sep 17 00:00:00 2001 From: percidae Date: Sun, 22 Dec 2019 16:39:31 +0100 Subject: [PATCH 059/473] Extended the fields for title and url in the Speaker_Links model to save longer links and descriptions --- www/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/models.py b/www/models.py index ae98a8c2..62aa4c0b 100755 --- a/www/models.py +++ b/www/models.py @@ -294,7 +294,7 @@ def page_sub_titles(self): # Links from the Fahrplan class Speaker_Links(BasisModell): speaker = models.ForeignKey(Speaker, blank = True) - title = models.CharField(max_length = 200, default = "", blank = True) + title = models.CharField(max_length = 300, default = "", blank = True) url = models.URLField(blank = True) @@ -1091,7 +1091,7 @@ def set_to_autotiming_in_progress(self): # Links from the Fahrplan class Links(BasisModell): talk = models.ForeignKey(Talk, blank = True) - url = models.URLField(blank = True) + url = models.URLField(blank = True, max_length = 300) title = models.CharField(max_length = 200, default = "Link title", blank = True) From 2082d3ca67b5c23313b73d409ba628e7cd0ff5e2 Mon Sep 17 00:00:00 2001 From: percidae Date: Sun, 22 Dec 2019 16:40:13 +0100 Subject: [PATCH 060/473] Changed the frab_id from integer to text --- update_speakers_via_speaker_json_import.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_speakers_via_speaker_json_import.py b/update_speakers_via_speaker_json_import.py index d962a600..aa4186ca 100755 --- a/update_speakers_via_speaker_json_import.py +++ b/update_speakers_via_speaker_json_import.py @@ -58,7 +58,7 @@ #print(any_link["title"]) #print(any_link["url"]) # Get or create a speaker with the same frab id - my_speaker, created = Speaker.objects.get_or_create(frab_id = prefix + any_speaker["id"]) + my_speaker, created = Speaker.objects.get_or_create(frab_id = prefix + str(any_speaker["id"])) # Only alter the entry if the name has changed if len(any_speaker["full_public_name"]) <= 50 and my_speaker.name != any_speaker["full_public_name"]: my_speaker.name = any_speaker["full_public_name"] From de0387dd9b1bee595e1475d5f5c595d49740fcf8 Mon Sep 17 00:00:00 2001 From: percidae Date: Sun, 22 Dec 2019 18:07:46 +0100 Subject: [PATCH 061/473] Little helper to create the pad links for an event --- create_pad_links.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 create_pad_links.py diff --git a/create_pad_links.py b/create_pad_links.py new file mode 100755 index 00000000..66ea3d4a --- /dev/null +++ b/create_pad_links.py @@ -0,0 +1,42 @@ +''' +This script helps to set the pad Links for every talks of an event. +You need to set: +event_id = your event +short_id = Short ID for the event +overwrite = True or False +You NEED to manualy set the short_id for events other than "the" Congress, else there might be conflicts, sometimes the Fahrplanimport overwrites the specific acronym +You MIGHT need to change the creation of the link for events other than the congress, else the long frab_id_talk will be in the link, the link would have the event double +''' +import os +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "subtitleStatus.settings") +import django + +django.setup() +from django.core.management.base import BaseCommand, CommandError +from django.db import transaction +from django.core.exceptions import ObjectDoesNotExist + +from www.models import Talk, Links, Tracks, Type_of, Speaker, Event, Event_Days, Rooms, Language, Subtitle, States + +#36c3 +event_id = 11 +event = Event.objects.get(id=event_id) +overwrite = False + +short_id = event.acronym +#short_id = "36c3-chaoswest" +#short_id = "36c3-wikipaka" + +my_talks = Talk.objects.filter(event = event) +print(my_talks.count()) + +for any in my_talks: + if overwrite: + any.link_to_writable_pad = "https://subtitles.pads.ccc.de/" + short_id + "-talk-" + any.frab_id_talk.split("-")[-1] + print(any.link_to_writable_pad) + #any.save() + else: + if any.link_to_writable_pad == "": + any.link_to_writable_pad = "https://subtitles.pads.ccc.de/" + short_id + "-talk-" + any.frab_id_talk.split("-")[-1] + #any.save() + print(any.link_to_writable_pad) From 5da31307adb1c615237f662cd74810ea3b2820df Mon Sep 17 00:00:00 2001 From: percidae Date: Sun, 22 Dec 2019 18:15:46 +0100 Subject: [PATCH 062/473] Code reformating --- www/templates/www/event.html | 52 ++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/www/templates/www/event.html b/www/templates/www/event.html index 116edaf2..c6662a2c 100755 --- a/www/templates/www/event.html +++ b/www/templates/www/event.html @@ -4,6 +4,12 @@ {% block title %}C3Subtitles{% endblock %} {% block content %} + +{% if user.is_authenticated %} +

    Hello, you are logged in!

    + +{% endif %} +

    {{my_event.title}}{% if my_event.has_statistics %} {% endif %}

    @@ -13,20 +19,20 @@

    {{my_event.title}}{% if my_event.h {% for every_statistics in my_event.statistics_event_set.all %} {% if every_statistics.has_statistics %} -
    -
    -
    -
    -
    {{every_statistics.language.display_name}}:
    -
    {{every_statistics.average_wpm | floatformat:-1}} wpm
    -
    {{every_statistics.average_spm | floatformat:-1}} spm
    -
    -
    -
    - {% common_words_cloud item=every_statistics height="18em" container=my_event.pk %} -
    -
    -
    +
    +
    +
    +
    +
    {{every_statistics.language.display_name}}:
    +
    {{every_statistics.average_wpm | floatformat:-1}} wpm
    +
    {{every_statistics.average_spm | floatformat:-1}} spm
    +
    +
    +
    + {% common_words_cloud item=every_statistics height="18em" container=my_event.pk %} +
    +
    +
    {% endif %} {% endfor %}

    @@ -47,13 +53,13 @@

    {{my_event.title}}{% if my_event.h td div.progress { margin-bottom: 0px; } - {% for talks_line in talks_chunk %} -
    - {% for every_talk in talks_line %} -
    - {% include "www/talk_small.html" with talk=every_talk %} -
    - {% endfor %} -
    - {% endfor %} + {% for talks_line in talks_chunk %} +
    + {% for every_talk in talks_line %} +
    + {% include "www/talk_small.html" with talk=every_talk %} +
    + {% endfor %} +
    + {% endfor %} {% endblock %} From 62a4829e34ea8bfb1fbf51eb2f99b6dc4a91dc84 Mon Sep 17 00:00:00 2001 From: percidae Date: Sun, 22 Dec 2019 18:17:11 +0100 Subject: [PATCH 063/473] Refactored the script to be more flexible for the format of the XML --- update_events_xml_schedule_import.py | 146 +++++++++++++++++++-------- 1 file changed, 105 insertions(+), 41 deletions(-) diff --git a/update_events_xml_schedule_import.py b/update_events_xml_schedule_import.py index 4d29bce9..0b96dba2 100755 --- a/update_events_xml_schedule_import.py +++ b/update_events_xml_schedule_import.py @@ -28,6 +28,7 @@ from datetime import datetime import dateutil.parser + # Var for all urls in the database in the Event-model url_array = [] @@ -161,52 +162,95 @@ def read_xml_and_save_to_database(event_frab_prefix): global my_event, my_room, my_day, my_track, my_events, my_link, my_links, my_person, my_persons, my_type len_day = len(fahrplan) - counter_day = 2 + # Where in the XML start the "day" tags + counter_day = 0 + + i = 0 + while i < len(fahrplan): + if fahrplan[i].tag == "day": + counter_day = i + break + else: + i += 1 # Event title - if fahrplan[1][1].tag == "title": - event_title = fahrplan[1][1].text - else: - error("Problem with title") - + i = 0 + while i < len(fahrplan): + j = 0 + while j < len(fahrplan[i]): + if fahrplan[i][j].tag == "title": + event_title = fahrplan[i][j].text + break + j += 1 + i += 1 + # Event schedule version - if fahrplan[0].tag == "version": - schedule_version = fahrplan[0].text - else: - error("Problem with schedule_version") + i = 0 + while i < len(fahrplan): + if fahrplan[i].tag == "version": + schedule_version = fahrplan[i].text + break + else: + i+=1 # Event acronym - if fahrplan[1][0].tag == "acronym": - acronym = fahrplan[1][0].text - else: - error("Problem with acronym") + i = 0 + while i < len(fahrplan): + j = 0 + while j < len(fahrplan[i]): + if fahrplan[i][j].tag == "acronym": + acronym = fahrplan[i][j].text + break + j += 1 + i += 1 # Event start - if fahrplan[1][2].tag == "start": - event_start = fahrplan[1][2].text - else: - error("Problem with event start") + i = 0 + while i < len(fahrplan): + j = 0 + while j < len(fahrplan[i]): + if fahrplan[i][j].tag == "start": + event_start = fahrplan[i][j].text + break + j += 1 + i += 1 # Event end - if fahrplan[1][3].tag == "end": - event_end = fahrplan[1][3].text - else: - error("Problem with event end") - + i = 0 + while i < len(fahrplan): + j = 0 + while j < len(fahrplan[i]): + if fahrplan[i][j].tag == "end": + event_end = fahrplan[i][j].text + break + j += 1 + i += 1 + # Event days - if fahrplan[1][4].tag == "days": - event_days = int(fahrplan[1][4].text) - else: - error("Problem with event days") + i = 0 + while i < len(fahrplan): + j = 0 + while j < len(fahrplan[i]): + if fahrplan[i][j].tag == "days": + event_days = fahrplan[i][j].text + break + j += 1 + i += 1 # Event timeslot_duration - if fahrplan[1][5].tag == "timeslot_duration": - timeslot_duration = fahrplan[1][5].text - else: - error("Problem with timeslot_duration") + i = 0 + while i < len(fahrplan): + j = 0 + while j < len(fahrplan[i]): + if fahrplan[i][j].tag == "timeslot_duration": + timeslot_duration = fahrplan[i][j].text + break + j += 1 + i += 1 # Write event data to database save_event_data() + print("Event data saved") # Loop around the day tags while (counter_day < len_day): @@ -438,8 +482,9 @@ def save_event_data(): def save_day_data(): global my_event, my_day global day_index, day_date, day_start, day_end - - my_day = Event_Days.objects.get_or_create(event = my_event, index = day_index, date = day_date)[0] + my_day = Event_Days.objects.get_or_create(event = my_event,\ + index = day_index,\ + date = day_date)[0] if my_day.day_start != dateutil.parser.parse(day_start): my_day.day_start = day_start my_day.save() @@ -468,7 +513,7 @@ def save_persons_data (event_frab_prefix): if len(my_person.name) > 50: my_person.name = my_person.name[0:50] my_person.save() - + # Array to acces all linked speakers for the saving of the talk my_persons.append(my_person) @@ -558,13 +603,15 @@ def save_talk_data (event_frab_prefix): my_link = [] # Saving the links for some_link in talk_links: - my_link = Links.objects.get_or_create(url = some_link[0], title = some_link[1], talk = my_talk) - + my_link = Links.objects.get_or_create(url = some_link[0],\ + title = some_link[1],\ + talk = my_talk) + for any_person in my_persons: this_talk_persons, created = Talk_Persons.objects.get_or_create(talk = my_talk, speaker = any_person) #this_talk_persons.save() - - + + #=============================================================================== # Main #=============================================================================== @@ -588,11 +635,28 @@ def save_talk_data (event_frab_prefix): # Compare Fahrplanversion in the database and online, break if the same: this_event = Event.objects.get(schedule_xml_link = url_to_this_fahrplan) - if fahrplan[0].text == this_event.schedule_version: - print("In ",fahrplan[1][1].text," nichts geändert! Version ist: ",fahrplan[0].text) + i = 0 + while i < len(fahrplan): + if fahrplan[i].tag == "version": + fahrplan_version = fahrplan[i].text + break + else: + i+=1 + print(i) + i = 0 + while i < len(fahrplan): + j = 0 + while j < len(fahrplan[i]): + if fahrplan[i][j].tag == "title": + fahrplan_title = fahrplan[i][j].text + break + j += 1 + i += 1 + if fahrplan_version == this_event.schedule_version: + print("In ",fahrplan_title," nichts geändert! Version ist: ",fahrplan_version) continue else: - print("In ",fahrplan[1][1].text," etwas geändert!\nVon Version: \"",this_event.schedule_version,"\" to \"",fahrplan[0].text,"\"") + print("In ",fahrplan_title," etwas geändert!\nVon Version: \"",this_event.schedule_version,"\" to \"",fahrplan_version,"\"") #print("Debug Event:",fahrplan[1][0].text) #print("Debug: Version in DB: ", this_event.schedule_version,"\n\n") From 4c6f2b4b1d7bfd2daa049d14d916294614774948 Mon Sep 17 00:00:00 2001 From: Thore Date: Sat, 28 Dec 2019 21:45:02 +0100 Subject: [PATCH 064/473] Field for c3subtitles youtube key --- www/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/www/models.py b/www/models.py index 62aa4c0b..e389cdfc 100755 --- a/www/models.py +++ b/www/models.py @@ -334,6 +334,7 @@ class Talk(BasisModell): link_to_video_file = models.URLField(max_length = 200, default = "", blank = True) amara_key = models.CharField(max_length = 20, default = "", blank = True) youtube_key = models.CharField(max_length = 20, blank = True) + c3subtitles_youtube_key = models.CharField(max_length = 20, blank = True) video_duration = models.TimeField(default = "00:00", blank = True) slug = models.SlugField(max_length = 200, default = "", blank = True) youtube_key_t_1 = models.CharField(max_length = 20, blank = True, default = "") From 7fc250b71fa0e9175f0bec32775c9de0b202aa1d Mon Sep 17 00:00:00 2001 From: Sebastian Schrader Date: Sun, 29 Dec 2019 19:09:22 +0100 Subject: [PATCH 065/473] Add static assets --- static/admin/css/base.css | 850 ++ static/admin/css/changelists.css | 293 + static/admin/css/dashboard.css | 30 + static/admin/css/forms.css | 396 + static/admin/css/ie.css | 63 + static/admin/css/login.css | 60 + static/admin/css/rtl.css | 250 + static/admin/css/widgets.css | 592 + static/admin/img/changelist-bg.gif | Bin 0 -> 50 bytes static/admin/img/changelist-bg_rtl.gif | Bin 0 -> 75 bytes static/admin/img/default-bg-reverse.gif | Bin 0 -> 835 bytes static/admin/img/default-bg.gif | Bin 0 -> 836 bytes static/admin/img/deleted-overlay.gif | Bin 0 -> 45 bytes static/admin/img/gis/move_vertex_off.png | Bin 0 -> 711 bytes static/admin/img/gis/move_vertex_on.png | Bin 0 -> 506 bytes static/admin/img/icon-no.gif | Bin 0 -> 176 bytes static/admin/img/icon-unknown.gif | Bin 0 -> 130 bytes static/admin/img/icon-yes.gif | Bin 0 -> 299 bytes static/admin/img/icon_addlink.gif | Bin 0 -> 119 bytes static/admin/img/icon_alert.gif | Bin 0 -> 145 bytes static/admin/img/icon_calendar.gif | Bin 0 -> 192 bytes static/admin/img/icon_changelink.gif | Bin 0 -> 119 bytes static/admin/img/icon_clock.gif | Bin 0 -> 390 bytes static/admin/img/icon_deletelink.gif | Bin 0 -> 181 bytes static/admin/img/icon_error.gif | Bin 0 -> 319 bytes static/admin/img/icon_searchbox.png | Bin 0 -> 368 bytes static/admin/img/icon_success.gif | Bin 0 -> 341 bytes static/admin/img/inline-delete-8bit.png | Bin 0 -> 395 bytes static/admin/img/inline-delete.png | Bin 0 -> 707 bytes static/admin/img/inline-restore-8bit.png | Bin 0 -> 363 bytes static/admin/img/inline-restore.png | Bin 0 -> 557 bytes static/admin/img/inline-splitter-bg.gif | Bin 0 -> 94 bytes static/admin/img/nav-bg-grabber.gif | Bin 0 -> 116 bytes static/admin/img/nav-bg-reverse.gif | Bin 0 -> 178 bytes static/admin/img/nav-bg-selected.gif | Bin 0 -> 265 bytes static/admin/img/nav-bg.gif | Bin 0 -> 265 bytes static/admin/img/selector-icons.gif | Bin 0 -> 2771 bytes static/admin/img/selector-search.gif | Bin 0 -> 552 bytes static/admin/img/sorting-icons.gif | Bin 0 -> 369 bytes static/admin/img/tooltag-add.png | Bin 0 -> 119 bytes static/admin/img/tooltag-arrowright.png | Bin 0 -> 200 bytes static/admin/js/LICENSE-JQUERY.txt | 20 + static/admin/js/SelectBox.js | 114 + static/admin/js/SelectFilter2.js | 166 + static/admin/js/actions.js | 144 + static/admin/js/actions.min.js | 6 + static/admin/js/admin/DateTimeShortcuts.js | 357 + static/admin/js/admin/RelatedObjectLookups.js | 130 + static/admin/js/calendar.js | 169 + static/admin/js/collapse.js | 24 + static/admin/js/collapse.min.js | 2 + static/admin/js/core.js | 246 + static/admin/js/inlines.js | 272 + static/admin/js/inlines.min.js | 9 + static/admin/js/jquery.init.js | 7 + static/admin/js/jquery.js | 10346 ++++++++++++++++ static/admin/js/jquery.min.js | 4 + static/admin/js/prepopulate.js | 39 + static/admin/js/prepopulate.min.js | 1 + static/admin/js/related-widget-wrapper.js | 23 + static/admin/js/timeparse.js | 94 + static/admin/js/urlify.js | 147 + static/black.png | Bin 0 -> 6228 bytes static/css/abel.css | 6 + static/css/base.css | 40 +- static/css/bootstrap-theme.css | 470 + static/css/bootstrap-theme.css.map | 1 + static/css/bootstrap-theme.min.css | 5 + static/css/bootstrap.css | 6332 ++++++++++ static/css/bootstrap.css.map | 1 + static/css/bootstrap.min.css | 5 + static/css/jqcloud.min.css | 8 + .../css/jquery.autocomplete.css | 38 + static/django_extensions/img/indicator.gif | Bin 0 -> 1553 bytes .../django_extensions/js/jquery-1.7.2.min.js | 4 + .../django_extensions/js/jquery.ajaxQueue.js | 119 + .../js/jquery.autocomplete.js | 1152 ++ .../django_extensions/js/jquery.bgiframe.js | 39 + .../js/jquery.bgiframe.min.js | 10 + static/fonts/Abel-Regular.ttf | Bin 0 -> 36400 bytes static/fonts/OFL.txt | 92 + static/fonts/glyphicons-halflings-regular.eot | Bin 0 -> 20335 bytes static/fonts/glyphicons-halflings-regular.svg | 229 + static/fonts/glyphicons-halflings-regular.ttf | Bin 0 -> 41280 bytes .../fonts/glyphicons-halflings-regular.woff | Bin 0 -> 23320 bytes static/js/bootstrap.js | 2320 ++++ static/js/bootstrap.min.js | 7 + static/js/jqcloud.min.js | 8 + static/js/jquery-2.1.3.min.js | 4 + static/js/jquery-ui.min.js | 13 + static/js/npm.js | 13 + www/static/css/bootstrap-theme.css | 470 + www/static/css/bootstrap-theme.css.map | 1 + www/static/css/bootstrap-theme.min.css | 5 + www/static/css/bootstrap.css | 6332 ++++++++++ www/static/css/bootstrap.css.map | 1 + www/static/css/bootstrap.min.css | 5 + www/static/fonts/Abel-Regular.ttf | Bin 0 -> 36400 bytes www/static/fonts/OFL.txt | 92 + .../fonts/glyphicons-halflings-regular.eot | Bin 0 -> 20335 bytes .../fonts/glyphicons-halflings-regular.svg | 229 + .../fonts/glyphicons-halflings-regular.ttf | Bin 0 -> 41280 bytes .../fonts/glyphicons-halflings-regular.woff | Bin 0 -> 23320 bytes www/static/js/bootstrap.js | 2320 ++++ www/static/js/bootstrap.min.js | 7 + www/static/js/jquery-2.1.3.min.js | 4 + www/static/js/jquery-ui.min.js | 13 + www/static/js/npm.js | 13 + 108 files changed, 35227 insertions(+), 35 deletions(-) create mode 100644 static/admin/css/base.css create mode 100644 static/admin/css/changelists.css create mode 100644 static/admin/css/dashboard.css create mode 100644 static/admin/css/forms.css create mode 100644 static/admin/css/ie.css create mode 100644 static/admin/css/login.css create mode 100644 static/admin/css/rtl.css create mode 100644 static/admin/css/widgets.css create mode 100644 static/admin/img/changelist-bg.gif create mode 100644 static/admin/img/changelist-bg_rtl.gif create mode 100644 static/admin/img/default-bg-reverse.gif create mode 100644 static/admin/img/default-bg.gif create mode 100644 static/admin/img/deleted-overlay.gif create mode 100644 static/admin/img/gis/move_vertex_off.png create mode 100644 static/admin/img/gis/move_vertex_on.png create mode 100644 static/admin/img/icon-no.gif create mode 100644 static/admin/img/icon-unknown.gif create mode 100644 static/admin/img/icon-yes.gif create mode 100644 static/admin/img/icon_addlink.gif create mode 100644 static/admin/img/icon_alert.gif create mode 100644 static/admin/img/icon_calendar.gif create mode 100644 static/admin/img/icon_changelink.gif create mode 100644 static/admin/img/icon_clock.gif create mode 100644 static/admin/img/icon_deletelink.gif create mode 100644 static/admin/img/icon_error.gif create mode 100644 static/admin/img/icon_searchbox.png create mode 100644 static/admin/img/icon_success.gif create mode 100644 static/admin/img/inline-delete-8bit.png create mode 100644 static/admin/img/inline-delete.png create mode 100644 static/admin/img/inline-restore-8bit.png create mode 100644 static/admin/img/inline-restore.png create mode 100644 static/admin/img/inline-splitter-bg.gif create mode 100644 static/admin/img/nav-bg-grabber.gif create mode 100644 static/admin/img/nav-bg-reverse.gif create mode 100644 static/admin/img/nav-bg-selected.gif create mode 100644 static/admin/img/nav-bg.gif create mode 100644 static/admin/img/selector-icons.gif create mode 100644 static/admin/img/selector-search.gif create mode 100644 static/admin/img/sorting-icons.gif create mode 100644 static/admin/img/tooltag-add.png create mode 100644 static/admin/img/tooltag-arrowright.png create mode 100644 static/admin/js/LICENSE-JQUERY.txt create mode 100644 static/admin/js/SelectBox.js create mode 100644 static/admin/js/SelectFilter2.js create mode 100644 static/admin/js/actions.js create mode 100644 static/admin/js/actions.min.js create mode 100644 static/admin/js/admin/DateTimeShortcuts.js create mode 100644 static/admin/js/admin/RelatedObjectLookups.js create mode 100644 static/admin/js/calendar.js create mode 100644 static/admin/js/collapse.js create mode 100644 static/admin/js/collapse.min.js create mode 100644 static/admin/js/core.js create mode 100644 static/admin/js/inlines.js create mode 100644 static/admin/js/inlines.min.js create mode 100644 static/admin/js/jquery.init.js create mode 100644 static/admin/js/jquery.js create mode 100644 static/admin/js/jquery.min.js create mode 100644 static/admin/js/prepopulate.js create mode 100644 static/admin/js/prepopulate.min.js create mode 100644 static/admin/js/related-widget-wrapper.js create mode 100644 static/admin/js/timeparse.js create mode 100644 static/admin/js/urlify.js create mode 100644 static/black.png create mode 100644 static/css/abel.css mode change 100755 => 100644 static/css/base.css create mode 100644 static/css/bootstrap-theme.css create mode 100644 static/css/bootstrap-theme.css.map create mode 100644 static/css/bootstrap-theme.min.css create mode 100644 static/css/bootstrap.css create mode 100644 static/css/bootstrap.css.map create mode 100644 static/css/bootstrap.min.css create mode 100755 static/css/jqcloud.min.css create mode 100644 static/django_extensions/css/jquery.autocomplete.css create mode 100644 static/django_extensions/img/indicator.gif create mode 100755 static/django_extensions/js/jquery-1.7.2.min.js create mode 100644 static/django_extensions/js/jquery.ajaxQueue.js create mode 100644 static/django_extensions/js/jquery.autocomplete.js create mode 100644 static/django_extensions/js/jquery.bgiframe.js create mode 100755 static/django_extensions/js/jquery.bgiframe.min.js create mode 100644 static/fonts/Abel-Regular.ttf create mode 100644 static/fonts/OFL.txt create mode 100644 static/fonts/glyphicons-halflings-regular.eot create mode 100644 static/fonts/glyphicons-halflings-regular.svg create mode 100644 static/fonts/glyphicons-halflings-regular.ttf create mode 100644 static/fonts/glyphicons-halflings-regular.woff create mode 100644 static/js/bootstrap.js create mode 100644 static/js/bootstrap.min.js create mode 100755 static/js/jqcloud.min.js create mode 100644 static/js/jquery-2.1.3.min.js create mode 100644 static/js/jquery-ui.min.js create mode 100644 static/js/npm.js create mode 100755 www/static/css/bootstrap-theme.css create mode 100755 www/static/css/bootstrap-theme.css.map create mode 100755 www/static/css/bootstrap-theme.min.css create mode 100755 www/static/css/bootstrap.css create mode 100755 www/static/css/bootstrap.css.map create mode 100755 www/static/css/bootstrap.min.css create mode 100755 www/static/fonts/Abel-Regular.ttf create mode 100755 www/static/fonts/OFL.txt create mode 100755 www/static/fonts/glyphicons-halflings-regular.eot create mode 100755 www/static/fonts/glyphicons-halflings-regular.svg create mode 100755 www/static/fonts/glyphicons-halflings-regular.ttf create mode 100755 www/static/fonts/glyphicons-halflings-regular.woff create mode 100755 www/static/js/bootstrap.js create mode 100755 www/static/js/bootstrap.min.js create mode 100755 www/static/js/jquery-2.1.3.min.js create mode 100755 www/static/js/jquery-ui.min.js create mode 100755 www/static/js/npm.js diff --git a/static/admin/css/base.css b/static/admin/css/base.css new file mode 100644 index 00000000..47ac79b1 --- /dev/null +++ b/static/admin/css/base.css @@ -0,0 +1,850 @@ +/* + DJANGO Admin styles +*/ + +body { + margin: 0; + padding: 0; + font-size: 12px; + font-family: "Lucida Grande","DejaVu Sans","Bitstream Vera Sans",Verdana,Arial,sans-serif; + color: #333; + background: #fff; +} + +/* LINKS */ + +a:link, a:visited { + color: #5b80b2; + text-decoration: none; +} + +a:hover { + color: #036; +} + +a img { + border: none; +} + +a.section:link, a.section:visited { + color: #fff; + text-decoration: none; +} + +/* GLOBAL DEFAULTS */ + +p, ol, ul, dl { + margin: .2em 0 .8em 0; +} + +p { + padding: 0; + line-height: 140%; +} + +h1,h2,h3,h4,h5 { + font-weight: bold; +} + +h1 { + font-size: 18px; + color: #666; + padding: 0 6px 0 0; + margin: 0 0 .2em 0; +} + +h2 { + font-size: 16px; + margin: 1em 0 .5em 0; +} + +h2.subhead { + font-weight: normal; + margin-top: 0; +} + +h3 { + font-size: 14px; + margin: .8em 0 .3em 0; + color: #666; + font-weight: bold; +} + +h4 { + font-size: 12px; + margin: 1em 0 .8em 0; + padding-bottom: 3px; +} + +h5 { + font-size: 10px; + margin: 1.5em 0 .5em 0; + color: #666; + text-transform: uppercase; + letter-spacing: 1px; +} + +ul li { + list-style-type: square; + padding: 1px 0; +} + +ul.plainlist { + margin-left: 0 !important; +} + +ul.plainlist li { + list-style-type: none; +} + +li ul { + margin-bottom: 0; +} + +li, dt, dd { + font-size: 11px; + line-height: 14px; +} + +dt { + font-weight: bold; + margin-top: 4px; +} + +dd { + margin-left: 0; +} + +form { + margin: 0; + padding: 0; +} + +fieldset { + margin: 0; + padding: 0; +} + +blockquote { + font-size: 11px; + color: #777; + margin-left: 2px; + padding-left: 10px; + border-left: 5px solid #ddd; +} + +code, pre { + font-family: "Bitstream Vera Sans Mono", Monaco, "Courier New", Courier, monospace; + color: #666; + font-size: 11px; +} + +pre.literal-block { + margin: 10px; + background: #eee; + padding: 6px 8px; +} + +code strong { + color: #930; +} + +hr { + clear: both; + color: #eee; + background-color: #eee; + height: 1px; + border: none; + margin: 0; + padding: 0; + font-size: 1px; + line-height: 1px; +} + +/* TEXT STYLES & MODIFIERS */ + +.small { + font-size: 11px; +} + +.tiny { + font-size: 10px; +} + +p.tiny { + margin-top: -2px; +} + +.mini { + font-size: 9px; +} + +p.mini { + margin-top: -3px; +} + +.help, p.help { + font-size: 10px !important; + color: #999; +} + +img.help-tooltip { + cursor: help; +} + +p img, h1 img, h2 img, h3 img, h4 img, td img { + vertical-align: middle; +} + +.quiet, a.quiet:link, a.quiet:visited { + color: #999 !important; + font-weight: normal !important; +} + +.quiet strong { + font-weight: bold !important; +} + +.float-right { + float: right; +} + +.float-left { + float: left; +} + +.clear { + clear: both; +} + +.align-left { + text-align: left; +} + +.align-right { + text-align: right; +} + +.example { + margin: 10px 0; + padding: 5px 10px; + background: #efefef; +} + +.nowrap { + white-space: nowrap; +} + +/* TABLES */ + +table { + border-collapse: collapse; + border-color: #ccc; +} + +td, th { + font-size: 11px; + line-height: 13px; + border-bottom: 1px solid #eee; + vertical-align: top; + padding: 5px; + font-family: "Lucida Grande", Verdana, Arial, sans-serif; +} + +th { + text-align: left; + font-size: 12px; + font-weight: bold; +} + +thead th, +tfoot td { + color: #666; + padding: 2px 5px; + font-size: 11px; + background: #e1e1e1 url(../img/nav-bg.gif) top left repeat-x; + border-left: 1px solid #ddd; + border-bottom: 1px solid #ddd; +} + +tfoot td { + border-bottom: none; + border-top: 1px solid #ddd; +} + +thead th:first-child, +tfoot td:first-child { + border-left: none !important; +} + +thead th.optional { + font-weight: normal !important; +} + +fieldset table { + border-right: 1px solid #eee; +} + +tr.row-label td { + font-size: 9px; + padding-top: 2px; + padding-bottom: 0; + border-bottom: none; + color: #666; + margin-top: -1px; +} + +tr.alt { + background: #f6f6f6; +} + +.row1 { + background: #EDF3FE; +} + +.row2 { + background: #fff; +} + +/* SORTABLE TABLES */ + +thead th { + padding: 2px 5px; + line-height: normal; +} + +thead th a:link, thead th a:visited { + color: #666; +} + +thead th.sorted { + background: #c5c5c5 url(../img/nav-bg-selected.gif) top left repeat-x; +} + +thead th.sorted .text { + padding-right: 42px; +} + +table thead th .text span { + padding: 2px 5px; + display:block; +} + +table thead th .text a { + display: block; + cursor: pointer; + padding: 2px 5px; +} + +table thead th.sortable:hover { + background: #fff url(../img/nav-bg-reverse.gif) 0 -5px repeat-x; +} + +thead th.sorted a.sortremove { + visibility: hidden; +} + +table thead th.sorted:hover a.sortremove { + visibility: visible; +} + +table thead th.sorted .sortoptions { + display: block; + padding: 4px 5px 0 5px; + float: right; + text-align: right; +} + +table thead th.sorted .sortpriority { + font-size: .8em; + min-width: 12px; + text-align: center; + vertical-align: top; +} + +table thead th.sorted .sortoptions a { + width: 14px; + height: 12px; + display: inline-block; +} + +table thead th.sorted .sortoptions a.sortremove { + background: url(../img/sorting-icons.gif) -4px -5px no-repeat; +} + +table thead th.sorted .sortoptions a.sortremove:hover { + background: url(../img/sorting-icons.gif) -4px -27px no-repeat; +} + +table thead th.sorted .sortoptions a.ascending { + background: url(../img/sorting-icons.gif) -5px -50px no-repeat; +} + +table thead th.sorted .sortoptions a.ascending:hover { + background: url(../img/sorting-icons.gif) -5px -72px no-repeat; +} + +table thead th.sorted .sortoptions a.descending { + background: url(../img/sorting-icons.gif) -5px -94px no-repeat; +} + +table thead th.sorted .sortoptions a.descending:hover { + background: url(../img/sorting-icons.gif) -5px -115px no-repeat; +} + +/* ORDERABLE TABLES */ + +table.orderable tbody tr td:hover { + cursor: move; +} + +table.orderable tbody tr td:first-child { + padding-left: 14px; + background-image: url(../img/nav-bg-grabber.gif); + background-repeat: repeat-y; +} + +table.orderable-initalized .order-cell, body>tr>td.order-cell { + display: none; +} + +/* FORM DEFAULTS */ + +input, textarea, select, .form-row p, form .button { + margin: 2px 0; + padding: 2px 3px; + vertical-align: middle; + font-family: "Lucida Grande", Verdana, Arial, sans-serif; + font-weight: normal; + font-size: 11px; +} + +textarea { + vertical-align: top !important; +} + +input[type=text], input[type=password], input[type=email], input[type=url], input[type=number], +textarea, select, .vTextField { + border: 1px solid #ccc; +} + +/* FORM BUTTONS */ + +.button, input[type=submit], input[type=button], .submit-row input, a.button { + background: #fff url(../img/nav-bg.gif) bottom repeat-x; + padding: 3px 5px; + color: black; + border: 1px solid #bbb; + border-color: #ddd #aaa #aaa #ddd; +} + +a.button { + padding: 4px 5px; +} + +.button:active, input[type=submit]:active, input[type=button]:active { + background-image: url(../img/nav-bg-reverse.gif); + background-position: top; +} + +.button[disabled], input[type=submit][disabled], input[type=button][disabled] { + background-image: url(../img/nav-bg.gif); + background-position: bottom; + opacity: 0.4; +} + +.button.default, input[type=submit].default, .submit-row input.default { + border: 2px solid #5b80b2; + background: #7CA0C7 url(../img/default-bg.gif) bottom repeat-x; + font-weight: bold; + color: #fff; + float: right; +} + +.button.default:active, input[type=submit].default:active { + background-image: url(../img/default-bg-reverse.gif); + background-position: top; +} + +.button[disabled].default, input[type=submit][disabled].default, input[type=button][disabled].default { + background-image: url(../img/default-bg.gif); + background-position: bottom; + opacity: 0.4; +} + + +/* MODULES */ + +.module { + border: 1px solid #ccc; + margin-bottom: 5px; + background: #fff; +} + +.module p, .module ul, .module h3, .module h4, .module dl, .module pre { + padding-left: 10px; + padding-right: 10px; +} + +.module blockquote { + margin-left: 12px; +} + +.module ul, .module ol { + margin-left: 1.5em; +} + +.module h3 { + margin-top: .6em; +} + +.module h2, .module caption, .inline-group h2 { + margin: 0; + padding: 2px 5px 3px 5px; + font-size: 11px; + text-align: left; + font-weight: bold; + background: #7CA0C7 url(../img/default-bg.gif) top left repeat-x; + color: #fff; +} + +.module table { + border-collapse: collapse; +} + +/* MESSAGES & ERRORS */ + +ul.messagelist { + padding: 0; + margin: 0; +} + +ul.messagelist li { + font-size: 12px; + font-weight: bold; + display: block; + padding: 5px 5px 4px 25px; + margin: 0 0 3px 0; + border-bottom: 1px solid #ddd; + color: #666; + background: #dfd url(../img/icon_success.gif) 5px .3em no-repeat; +} + +ul.messagelist li.warning { + background: #ffc url(../img/icon_alert.gif) 5px .3em no-repeat; +} + +ul.messagelist li.error { + background: #ffefef url(../img/icon_error.gif) 5px .3em no-repeat; +} + +.errornote { + font-size: 12px !important; + font-weight: bold; + display: block; + padding: 5px 5px 4px 25px; + margin: 0 0 3px 0; + border: 1px solid #c22; + color: #c11; + background: #ffefef url(../img/icon_error.gif) 5px .38em no-repeat; +} + +.errornote, ul.errorlist { + border-radius: 1px; +} + +ul.errorlist { + margin: 0 0 4px !important; + padding: 0 !important; + color: #fff; + background: #c11; +} + +ul.errorlist li { + font-size: 12px !important; + display: block; + padding: 5px 5px 4px 7px; + margin: 3px 0 0 0; +} + +ul.errorlist li:first-child { + margin-top: 0; +} + +ul.errorlist li a { + color: #fff; + text-decoration: underline; +} + +td ul.errorlist { + margin: 0 !important; + padding: 0 !important; +} + +td ul.errorlist li { + margin: 0 !important; +} + +.errors, .form-row.errors { + background: #ffefef; +} + +.form-row.errors { + border: 1px solid #c22; + margin: -1px; +} + +.errors input, .errors select, .errors textarea { + border: 1px solid #c11; +} + +div.system-message { + background: #ffc; + margin: 10px; + padding: 6px 8px; + font-size: .8em; +} + +div.system-message p.system-message-title { + padding: 4px 5px 4px 25px; + margin: 0; + color: #c11; + background: #ffefef url(../img/icon_error.gif) 5px .3em no-repeat; +} + +.description { + font-size: 12px; + padding: 5px 0 0 12px; +} + +/* BREADCRUMBS */ + +div.breadcrumbs { + background: #fff url(../img/nav-bg-reverse.gif) 0 -10px repeat-x; + padding: 2px 8px 3px 8px; + font-size: 11px; + color: #999; + border-top: 1px solid #fff; + border-bottom: 1px solid #ddd; + text-align: left; +} + +/* ACTION ICONS */ + +.addlink { + padding-left: 12px; + background: url(../img/icon_addlink.gif) 0 .2em no-repeat; +} + +.changelink, .inlinechangelink { + padding-left: 12px; + background: url(../img/icon_changelink.gif) 0 .2em no-repeat; +} + +.deletelink { + padding-left: 12px; + background: url(../img/icon_deletelink.gif) 0 .25em no-repeat; +} + +a.deletelink:link, a.deletelink:visited { + color: #CC3434; +} + +a.deletelink:hover { + color: #993333; +} + +/* OBJECT TOOLS */ + +.object-tools { + font-size: 10px; + font-weight: bold; + font-family: Arial,Helvetica,sans-serif; + padding-left: 0; + float: right; + position: relative; + margin-top: -2.4em; + margin-bottom: -2em; +} + +.form-row .object-tools { + margin-top: 5px; + margin-bottom: 5px; + float: none; + height: 2em; + padding-left: 3.5em; +} + +.object-tools li { + display: block; + float: left; + margin-left: 5px; + height: 16px; +} + +.object-tools a { + border-radius: 15px; +} + +.object-tools a:link, .object-tools a:visited { + display: block; + float: left; + color: #fff; + padding: .2em 10px; + background: #999; +} + +.object-tools a:hover, .object-tools li:hover a { + background-color: #5b80b2; +} + +.object-tools a.viewsitelink, .object-tools a.golink { + background: #999 url(../img/tooltag-arrowright.png) 95% center no-repeat; + padding-right: 26px; +} + +.object-tools a.addlink { + background: #999 url(../img/tooltag-add.png) 95% center no-repeat; + padding-right: 26px; +} + +/* OBJECT HISTORY */ + +table#change-history { + width: 100%; +} + +table#change-history tbody th { + width: 16em; +} + +/* PAGE STRUCTURE */ + +#container { + position: relative; + width: 100%; + min-width: 760px; + padding: 0; +} + +#content { + margin: 10px 15px; +} + +#content-main { + float: left; + width: 100%; +} + +#content-related { + float: right; + width: 18em; + position: relative; + margin-right: -19em; +} + +#footer { + clear: both; + padding: 10px; +} + +/* COLUMN TYPES */ + +.colMS { + margin-right: 20em !important; +} + +.colSM { + margin-left: 20em !important; +} + +.colSM #content-related { + float: left; + margin-right: 0; + margin-left: -19em; +} + +.colSM #content-main { + float: right; +} + +.popup .colM { + width: 95%; +} + +.subcol { + float: left; + width: 46%; + margin-right: 15px; +} + +.dashboard #content { + width: 500px; +} + +/* HEADER */ + +#header { + width: 100%; + background: #417690; + color: #ffc; + overflow: hidden; +} + +#header a:link, #header a:visited { + color: #fff; +} + +#header a:hover { + text-decoration: underline; +} + +#branding { + float: left; +} +#branding h1 { + padding: 0 10px; + font-size: 18px; + margin: 8px 0; + font-weight: normal; +} + +#branding h1, #branding h1 a:link, #branding h1 a:visited { + color: #f4f379; +} + +#branding h2 { + padding: 0 10px; + font-size: 14px; + margin: -8px 0 8px 0; + font-weight: normal; + color: #ffc; +} + +#branding a:hover { + text-decoration: none; +} + +#user-tools { + float: right; + padding: 1.2em 10px; + font-size: 11px; + text-align: right; +} + +/* SIDEBAR */ + +#content-related h3 { + font-size: 12px; + color: #666; + margin-bottom: 3px; +} + +#content-related h4 { + font-size: 11px; +} + +#content-related .module h2 { + background: #eee url(../img/nav-bg.gif) bottom left repeat-x; + color: #666; +} diff --git a/static/admin/css/changelists.css b/static/admin/css/changelists.css new file mode 100644 index 00000000..28021d02 --- /dev/null +++ b/static/admin/css/changelists.css @@ -0,0 +1,293 @@ +/* CHANGELISTS */ + +#changelist { + position: relative; + width: 100%; +} + +#changelist table { + width: 100%; +} + +.change-list .hiddenfields { display:none; } + +.change-list .filtered table { + border-right: 1px solid #ddd; +} + +.change-list .filtered { + min-height: 400px; +} + +.change-list .filtered { + background: white url(../img/changelist-bg.gif) top right repeat-y !important; +} + +.change-list .filtered .results, .change-list .filtered .paginator, .filtered #toolbar, .filtered div.xfull { + margin-right: 160px !important; + width: auto !important; +} + +.change-list .filtered table tbody th { + padding-right: 1em; +} + +#changelist-form .results { + overflow-x: auto; +} + +#changelist .toplinks { + border-bottom: 1px solid #ccc !important; +} + +#changelist .paginator { + color: #666; + border-top: 1px solid #eee; + border-bottom: 1px solid #eee; + background: white url(../img/nav-bg.gif) 0 180% repeat-x; + overflow: hidden; +} + +.change-list .filtered .paginator { + border-right: 1px solid #ddd; +} + +/* CHANGELIST TABLES */ + +#changelist table thead th { + padding: 0; + white-space: nowrap; + vertical-align: middle; +} + +#changelist table thead th.action-checkbox-column { + width: 1.5em; + text-align: center; +} + +#changelist table tbody td, #changelist table tbody th { + border-left: 1px solid #ddd; +} + +#changelist table tbody td:first-child, #changelist table tbody th:first-child { + border-left: 0; + border-right: 1px solid #ddd; +} + +#changelist table tbody td.action-checkbox { + text-align:center; +} + +#changelist table tfoot { + color: #666; +} + +/* TOOLBAR */ + +#changelist #toolbar { + padding: 3px; + border-bottom: 1px solid #ddd; + background: #e1e1e1 url(../img/nav-bg.gif) top left repeat-x; + color: #666; +} + +#changelist #toolbar form input { + font-size: 11px; + padding: 1px 2px; +} + +#changelist #toolbar form #searchbar { + padding: 2px; +} + +#changelist #changelist-search img { + vertical-align: middle; +} + +/* FILTER COLUMN */ + +#changelist-filter { + position: absolute; + top: 0; + right: 0; + z-index: 1000; + width: 160px; + border-left: 1px solid #ddd; + background: #efefef; + margin: 0; +} + +#changelist-filter h2 { + font-size: 11px; + padding: 2px 5px; + border-bottom: 1px solid #ddd; +} + +#changelist-filter h3 { + font-size: 12px; + margin-bottom: 0; +} + +#changelist-filter ul { + padding-left: 0; + margin-left: 10px; +} + +#changelist-filter li { + list-style-type: none; + margin-left: 0; + padding-left: 0; +} + +#changelist-filter a { + color: #999; +} + +#changelist-filter a:hover { + color: #036; +} + +#changelist-filter li.selected { + border-left: 5px solid #ccc; + padding-left: 5px; + margin-left: -10px; +} + +#changelist-filter li.selected a { + color: #5b80b2 !important; +} + +/* DATE DRILLDOWN */ + +.change-list ul.toplinks { + display: block; + background: white url(../img/nav-bg-reverse.gif) 0 -10px repeat-x; + border-top: 1px solid white; + float: left; + padding: 0 !important; + margin: 0 !important; + width: 100%; +} + +.change-list ul.toplinks li { + padding: 3px 6px; + font-weight: bold; + list-style-type: none; + display: inline-block; +} + +.change-list ul.toplinks .date-back a { + color: #999; +} + +.change-list ul.toplinks .date-back a:hover { + color: #036; +} + +/* PAGINATOR */ + +.paginator { + font-size: 11px; + padding-top: 10px; + padding-bottom: 10px; + line-height: 22px; + margin: 0; + border-top: 1px solid #ddd; +} + +.paginator a:link, .paginator a:visited { + padding: 2px 6px; + border: solid 1px #ccc; + background: white; + text-decoration: none; +} + +.paginator a.showall { + padding: 0 !important; + border: none !important; +} + +.paginator a.showall:hover { + color: #036 !important; + background: transparent !important; +} + +.paginator .end { + border-width: 2px !important; + margin-right: 6px; +} + +.paginator .this-page { + padding: 2px 6px; + font-weight: bold; + font-size: 13px; + vertical-align: top; +} + +.paginator a:hover { + color: white; + background: #5b80b2; + border-color: #036; +} + +/* ACTIONS */ + +.filtered .actions { + margin-right: 160px !important; + border-right: 1px solid #ddd; +} + +#changelist table input { + margin: 0; +} + +#changelist table tbody tr.selected { + background-color: #FFFFCC; +} + +#changelist .actions { + color: #999; + padding: 3px; + border-top: 1px solid #fff; + border-bottom: 1px solid #ddd; + background: white url(../img/nav-bg-reverse.gif) 0 -10px repeat-x; +} + +#changelist .actions.selected { + background: #fffccf; + border-top: 1px solid #fffee8; + border-bottom: 1px solid #edecd6; +} + +#changelist .actions span.all, +#changelist .actions span.action-counter, +#changelist .actions span.clear, +#changelist .actions span.question { + font-size: 11px; + margin: 0 0.5em; + display: none; +} + +#changelist .actions:last-child { + border-bottom: none; +} + +#changelist .actions select { + border: 1px solid #aaa; + margin-left: 0.5em; + padding: 1px 2px; +} + +#changelist .actions label { + font-size: 11px; + margin-left: 0.5em; +} + +#changelist #action-toggle { + display: none; +} + +#changelist .actions .button { + font-size: 11px; + padding: 1px 2px; +} diff --git a/static/admin/css/dashboard.css b/static/admin/css/dashboard.css new file mode 100644 index 00000000..05808bcb --- /dev/null +++ b/static/admin/css/dashboard.css @@ -0,0 +1,30 @@ +/* DASHBOARD */ + +.dashboard .module table th { + width: 100%; +} + +.dashboard .module table td { + white-space: nowrap; +} + +.dashboard .module table td a { + display: block; + padding-right: .6em; +} + +/* RECENT ACTIONS MODULE */ + +.module ul.actionlist { + margin-left: 0; +} + +ul.actionlist li { + list-style-type: none; +} + +ul.actionlist li { + overflow: hidden; + text-overflow: ellipsis; + -o-text-overflow: ellipsis; +} diff --git a/static/admin/css/forms.css b/static/admin/css/forms.css new file mode 100644 index 00000000..b06bbba1 --- /dev/null +++ b/static/admin/css/forms.css @@ -0,0 +1,396 @@ +@import url('widgets.css'); + +/* FORM ROWS */ + +.form-row { + overflow: hidden; + padding: 8px 12px; + font-size: 11px; + border-bottom: 1px solid #eee; +} + +.form-row img, .form-row input { + vertical-align: middle; +} + +form .form-row p { + padding-left: 0; + font-size: 11px; +} + +.hidden { + display: none; +} + +/* FORM LABELS */ + +form h4 { + margin: 0 !important; + padding: 0 !important; + border: none !important; +} + +label { + font-weight: normal !important; + color: #666; + font-size: 12px; +} + +.required label, label.required { + font-weight: bold !important; + color: #333 !important; +} + +/* RADIO BUTTONS */ + +form ul.radiolist li { + list-style-type: none; +} + +form ul.radiolist label { + float: none; + display: inline; +} + +form ul.inline { + margin-left: 0; + padding: 0; +} + +form ul.inline li { + float: left; + padding-right: 7px; +} + +/* ALIGNED FIELDSETS */ + +.aligned label { + display: block; + padding: 3px 10px 0 0; + float: left; + width: 8em; + word-wrap: break-word; +} + +.aligned ul label { + display: inline; + float: none; + width: auto; +} + +.colMS .aligned .vLargeTextField, .colMS .aligned .vXMLLargeTextField { + width: 350px; +} + +form .aligned p, form .aligned ul { + margin-left: 7em; + padding-left: 30px; +} + +form .aligned table p { + margin-left: 0; + padding-left: 0; +} + +form .aligned p.help { + clear: left; + padding-left: 38px; +} + +.aligned .vCheckboxLabel { + float: none !important; + display: inline; + padding-left: 4px; +} + +.colM .aligned .vLargeTextField, .colM .aligned .vXMLLargeTextField { + width: 610px; +} + +.checkbox-row p.help { + margin-left: 0; + padding-left: 0 !important; +} + +fieldset .field-box { + float: left; + margin-right: 20px; +} + +/* WIDE FIELDSETS */ + +.wide label { + width: 15em !important; +} + +form .wide p { + margin-left: 15em; +} + +form .wide p.help { + padding-left: 38px; +} + +.colM fieldset.wide .vLargeTextField, .colM fieldset.wide .vXMLLargeTextField { + width: 450px; +} + +/* COLLAPSED FIELDSETS */ + +fieldset.collapsed * { + display: none; +} + +fieldset.collapsed h2, fieldset.collapsed { + display: block !important; +} + +fieldset.collapsed h2 { + background-image: url(../img/nav-bg.gif); + background-position: bottom left; + color: #999; +} + +fieldset.collapsed .collapse-toggle { + background: transparent; + display: inline !important; +} + +/* MONOSPACE TEXTAREAS */ + +fieldset.monospace textarea { + font-family: "Bitstream Vera Sans Mono",Monaco,"Courier New",Courier,monospace; +} + +/* SUBMIT ROW */ + +.submit-row { + padding: 5px 7px; + text-align: right; + background: white url(../img/nav-bg.gif) 0 100% repeat-x; + border: 1px solid #ccc; + margin: 5px 0; + overflow: hidden; +} + +body.popup .submit-row { + overflow: auto; +} + +.submit-row input { + margin: 0 0 0 5px; +} + +.submit-row p { + margin: 0.3em; +} + +.submit-row p.deletelink-box { + float: left; +} + +.submit-row .deletelink { + background: url(../img/icon_deletelink.gif) 0 50% no-repeat; + padding-left: 14px; +} + +/* CUSTOM FORM FIELDS */ + +.vSelectMultipleField { + vertical-align: top !important; +} + +.vCheckboxField { + border: none; +} + +.vDateField, .vTimeField { + margin-right: 2px; +} + +.vDateField { + min-width: 6.85em; +} + +.vTimeField { + min-width: 4.7em; +} + +.vURLField { + width: 30em; +} + +.vLargeTextField, .vXMLLargeTextField { + width: 48em; +} + +.flatpages-flatpage #id_content { + height: 40.2em; +} + +.module table .vPositiveSmallIntegerField { + width: 2.2em; +} + +.vTextField { + width: 20em; +} + +.vIntegerField { + width: 5em; +} + +.vBigIntegerField { + width: 10em; +} + +.vForeignKeyRawIdAdminField { + width: 5em; +} + +/* INLINES */ + +.inline-group { + padding: 0; + border: 1px solid #ccc; + margin: 10px 0; +} + +.inline-group .aligned label { + width: 8em; +} + +.inline-related { + position: relative; +} + +.inline-related h3 { + margin: 0; + color: #666; + padding: 3px 5px; + font-size: 11px; + background: #e1e1e1 url(../img/nav-bg.gif) top left repeat-x; + border-bottom: 1px solid #ddd; +} + +.inline-related h3 span.delete { + float: right; +} + +.inline-related h3 span.delete label { + margin-left: 2px; + font-size: 11px; +} + +.inline-related fieldset { + margin: 0; + background: #fff; + border: none; + width: 100%; +} + +.inline-related fieldset.module h3 { + margin: 0; + padding: 2px 5px 3px 5px; + font-size: 11px; + text-align: left; + font-weight: bold; + background: #bcd; + color: #fff; +} + +.inline-group .tabular fieldset.module { + border: none; + border-bottom: 1px solid #ddd; +} + +.inline-related.tabular fieldset.module table { + width: 100%; +} + +.last-related fieldset { + border: none; +} + +.inline-group .tabular tr.has_original td { + padding-top: 2em; +} + +.inline-group .tabular tr td.original { + padding: 2px 0 0 0; + width: 0; + _position: relative; +} + +.inline-group .tabular th.original { + width: 0px; + padding: 0; +} + +.inline-group .tabular td.original p { + position: absolute; + left: 0; + height: 1.1em; + padding: 2px 7px; + overflow: hidden; + font-size: 9px; + font-weight: bold; + color: #666; + _width: 700px; +} + +.inline-group ul.tools { + padding: 0; + margin: 0; + list-style: none; +} + +.inline-group ul.tools li { + display: inline; + padding: 0 5px; +} + +.inline-group div.add-row, +.inline-group .tabular tr.add-row td { + color: #666; + padding: 3px 5px; + border-bottom: 1px solid #ddd; + background: #e1e1e1 url(../img/nav-bg.gif) top left repeat-x; +} + +.inline-group .tabular tr.add-row td { + padding: 4px 5px 3px; + border-bottom: none; +} + +.inline-group ul.tools a.add, +.inline-group div.add-row a, +.inline-group .tabular tr.add-row td a { + background: url(../img/icon_addlink.gif) 0 50% no-repeat; + padding-left: 14px; + font-size: 11px; + outline: 0; /* Remove dotted border around link */ +} + +.empty-form { + display: none; +} + +/* RELATED FIELD ADD ONE / LOOKUP */ + +.add-another, .related-lookup { + margin-left: 5px; + display: inline-block; +} + +.add-another { + width: 10px; + height: 10px; + background-image: url(../img/icon_addlink.gif); +} + +.related-lookup { + width: 16px; + height: 16px; + background-image: url(../img/selector-search.gif); +} diff --git a/static/admin/css/ie.css b/static/admin/css/ie.css new file mode 100644 index 00000000..81990058 --- /dev/null +++ b/static/admin/css/ie.css @@ -0,0 +1,63 @@ +/* IE 6 & 7 */ + +/* Proper fixed width for dashboard in IE6 */ + +.dashboard #content { + *width: 768px; +} + +.dashboard #content-main { + *width: 535px; +} + +/* IE 6 ONLY */ + +/* Keep header from flowing off the page */ + +#container { + _position: static; +} + +/* Put the right sidebars back on the page */ + +.colMS #content-related { + _margin-right: 0; + _margin-left: 10px; + _position: static; +} + +/* Put the left sidebars back on the page */ + +.colSM #content-related { + _margin-right: 10px; + _margin-left: -115px; + _position: static; +} + +.form-row { + _height: 1%; +} + +/* Fix right margin for changelist filters in IE6 */ + +#changelist-filter ul { + _margin-right: -10px; +} + +/* IE ignores min-height, but treats height as if it were min-height */ + +.change-list .filtered { + _height: 400px; +} + +/* IE doesn't know alpha transparency in PNGs */ + +.inline-deletelink { + background: transparent url(../img/inline-delete-8bit.png) no-repeat; +} + +/* IE7 doesn't support inline-block */ +.change-list ul.toplinks li { + zoom: 1; + *display: inline; +} diff --git a/static/admin/css/login.css b/static/admin/css/login.css new file mode 100644 index 00000000..a91de117 --- /dev/null +++ b/static/admin/css/login.css @@ -0,0 +1,60 @@ +/* LOGIN FORM */ + +body.login { + background: #eee; +} + +.login #container { + background: white; + border: 1px solid #ccc; + width: 28em; + min-width: 300px; + margin-left: auto; + margin-right: auto; + margin-top: 100px; +} + +.login #content-main { + width: 100%; +} + +.login form { + margin-top: 1em; +} + +.login .form-row { + padding: 4px 0; + float: left; + width: 100%; +} + +.login .form-row label { + padding-right: 0.5em; + line-height: 2em; + font-size: 1em; + clear: both; + color: #333; +} + +.login .form-row #id_username, .login .form-row #id_password { + clear: both; + padding: 6px; + width: 100%; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +.login span.help { + font-size: 10px; + display: block; +} + +.login .submit-row { + clear: both; + padding: 1em 0 0 9.4em; +} + +.login .password-reset-link { + text-align: center; +} diff --git a/static/admin/css/rtl.css b/static/admin/css/rtl.css new file mode 100644 index 00000000..15db4015 --- /dev/null +++ b/static/admin/css/rtl.css @@ -0,0 +1,250 @@ +body { + direction: rtl; +} + +/* LOGIN */ + +.login .form-row { + float: right; +} + +.login .form-row label { + float: right; + padding-left: 0.5em; + padding-right: 0; + text-align: left; +} + +.login .submit-row { + clear: both; + padding: 1em 9.4em 0 0; +} + +/* GLOBAL */ + +th { + text-align: right; +} + +.module h2, .module caption { + text-align: right; +} + +.addlink, .changelink { + padding-left: 0px; + padding-right: 12px; + background-position: 100% 0.2em; +} + +.deletelink { + padding-left: 0px; + padding-right: 12px; + background-position: 100% 0.25em; +} + +.object-tools { + float: left; +} + +thead th:first-child, +tfoot td:first-child { + border-left: 1px solid #ddd !important; +} + +/* LAYOUT */ + +#user-tools { + right: auto; + left: 0; + text-align: left; +} + +div.breadcrumbs { + text-align: right; +} + +#content-main { + float: right; +} + +#content-related { + float: left; + margin-left: -19em; + margin-right: auto; +} + +.colMS { + margin-left: 20em !important; + margin-right: 10px !important; +} + +/* SORTABLE TABLES */ + +table thead th.sorted .sortoptions { + float: left; +} + +thead th.sorted .text { + padding-right: 0; + padding-left: 42px; +} + +/* dashboard styles */ + +.dashboard .module table td a { + padding-left: .6em; + padding-right: 12px; +} + +/* changelists styles */ + +.change-list .filtered { + background: white url(../img/changelist-bg_rtl.gif) top left repeat-y !important; +} + +.change-list .filtered table { + border-left: 1px solid #ddd; + border-right: 0px none; +} + +#changelist-filter { + right: auto; + left: 0; + border-left: 0px none; + border-right: 1px solid #ddd; +} + +.change-list .filtered .results, .change-list .filtered .paginator, .filtered #toolbar, .filtered div.xfull { + margin-right: 0px !important; + margin-left: 160px !important; +} + +#changelist-filter li.selected { + border-left: 0px none; + padding-left: 0px; + margin-left: 0; + border-right: 5px solid #ccc; + padding-right: 5px; + margin-right: -10px; +} + +.filtered .actions { + border-left:1px solid #DDDDDD; + margin-left:160px !important; + border-right: 0 none; + margin-right:0 !important; +} + +#changelist table tbody td:first-child, #changelist table tbody th:first-child { + border-right: 0; + border-left: 1px solid #ddd; +} + +/* FORMS */ + +.aligned label { + padding: 0 0 3px 1em; + float: right; +} + +.submit-row { + text-align: left +} + +.submit-row p.deletelink-box { + float: right; +} + +.submit-row .deletelink { + background: url(../img/icon_deletelink.gif) 0 50% no-repeat; + padding-right: 14px; +} + +.vDateField, .vTimeField { + margin-left: 2px; +} + +form ul.inline li { + float: right; + padding-right: 0; + padding-left: 7px; +} + +input[type=submit].default, .submit-row input.default { + float: left; +} + +fieldset .field-box { + float: right; + margin-left: 20px; + margin-right: 0; +} + +.errorlist li { + background-position: 100% .3em; + padding: 4px 25px 4px 5px; +} + +.errornote { + background-position: 100% .3em; + padding: 4px 25px 4px 5px; +} + +/* WIDGETS */ + +.calendarnav-previous { + top: 0; + left: auto; + right: 0; +} + +.calendarnav-next { + top: 0; + right: auto; + left: 0; +} + +.calendar caption, .calendarbox h2 { + text-align: center; +} + +.selector { + float: right; +} + +.selector .selector-filter { + text-align: right; +} + +.inline-deletelink { + float: left; +} + +/* MISC */ + +.inline-related h2, .inline-group h2 { + text-align: right +} + +.inline-related h3 span.delete { + padding-right: 20px; + padding-left: inherit; + left: 10px; + right: inherit; + float:left; +} + +.inline-related h3 span.delete label { + margin-left: inherit; + margin-right: 2px; +} + +/* IE7 specific bug fixes */ + +div.colM { + position: relative; +} + +.submit-row input { + float: left; +} diff --git a/static/admin/css/widgets.css b/static/admin/css/widgets.css new file mode 100644 index 00000000..3defc70d --- /dev/null +++ b/static/admin/css/widgets.css @@ -0,0 +1,592 @@ +/* SELECTOR (FILTER INTERFACE) */ + +.selector { + width: 840px; + float: left; +} + +.selector select { + width: 400px; + height: 17.2em; +} + +.selector-available, .selector-chosen { + float: left; + width: 400px; + text-align: center; + margin-bottom: 5px; +} + +.selector-chosen select { + border-top: none; +} + +.selector-available h2, .selector-chosen h2 { + border: 1px solid #ccc; +} + +.selector .selector-available h2 { + background: white url(../img/nav-bg.gif) bottom left repeat-x; + color: #666; +} + +.selector .selector-filter { + background: white; + border: 1px solid #ccc; + border-width: 0 1px; + padding: 3px; + color: #999; + font-size: 10px; + margin: 0; + text-align: left; +} + +.selector .selector-filter label, +.inline-group .aligned .selector .selector-filter label { + width: 16px; + padding: 2px; +} + +.selector .selector-available input { + width: 360px; +} + +.selector ul.selector-chooser { + float: left; + width: 22px; + background-color: #eee; + border-radius: 10px; + margin: 10em 5px 0 5px; + padding: 0; +} + +.selector-chooser li { + margin: 0; + padding: 3px; + list-style-type: none; +} + +.selector select { + margin-bottom: 10px; + margin-top: 0; +} + +.selector-add, .selector-remove { + width: 16px; + height: 16px; + display: block; + text-indent: -3000px; + overflow: hidden; +} + +.selector-add { + background: url(../img/selector-icons.gif) 0 -161px no-repeat; + cursor: default; + margin-bottom: 2px; +} + +.active.selector-add { + background: url(../img/selector-icons.gif) 0 -187px no-repeat; + cursor: pointer; +} + +.selector-remove { + background: url(../img/selector-icons.gif) 0 -109px no-repeat; + cursor: default; +} + +.active.selector-remove { + background: url(../img/selector-icons.gif) 0 -135px no-repeat; + cursor: pointer; +} + +a.selector-chooseall, a.selector-clearall { + display: inline-block; + text-align: left; + margin-left: auto; + margin-right: auto; + font-weight: bold; + color: #666; +} + +a.selector-chooseall { + padding: 3px 18px 3px 0; +} + +a.selector-clearall { + padding: 3px 0 3px 18px; +} + +a.active.selector-chooseall:hover, a.active.selector-clearall:hover { + color: #036; +} + +a.selector-chooseall { + background: url(../img/selector-icons.gif) right -263px no-repeat; + cursor: default; +} + +a.active.selector-chooseall { + background: url(../img/selector-icons.gif) right -289px no-repeat; + cursor: pointer; +} + +a.selector-clearall { + background: url(../img/selector-icons.gif) left -211px no-repeat; + cursor: default; +} + +a.active.selector-clearall { + background: url(../img/selector-icons.gif) left -237px no-repeat; + cursor: pointer; +} + +/* STACKED SELECTORS */ + +.stacked { + float: left; + width: 500px; +} + +.stacked select { + width: 480px; + height: 10.1em; +} + +.stacked .selector-available, .stacked .selector-chosen { + width: 480px; +} + +.stacked .selector-available { + margin-bottom: 0; +} + +.stacked .selector-available input { + width: 442px; +} + +.stacked ul.selector-chooser { + height: 22px; + width: 50px; + margin: 0 0 3px 40%; + background-color: #eee; + border-radius: 10px; +} + +.stacked .selector-chooser li { + float: left; + padding: 3px 3px 3px 5px; +} + +.stacked .selector-chooseall, .stacked .selector-clearall { + display: none; +} + +.stacked .selector-add { + background: url(../img/selector-icons.gif) 0 -57px no-repeat; + cursor: default; +} + +.stacked .active.selector-add { + background: url(../img/selector-icons.gif) 0 -83px no-repeat; + cursor: pointer; +} + +.stacked .selector-remove { + background: url(../img/selector-icons.gif) 0 -5px no-repeat; + cursor: default; +} + +.stacked .active.selector-remove { + background: url(../img/selector-icons.gif) 0 -31px no-repeat; + cursor: pointer; +} + +/* DATE AND TIME */ + +p.datetime { + line-height: 20px; + margin: 0; + padding: 0; + color: #666; + font-size: 11px; + font-weight: bold; +} + +.datetime span { + font-size: 11px; + color: #ccc; + font-weight: normal; + white-space: nowrap; +} + +table p.datetime { + font-size: 10px; + margin-left: 0; + padding-left: 0; +} + +/* URL */ + +p.url { + line-height: 20px; + margin: 0; + padding: 0; + color: #666; + font-size: 11px; + font-weight: bold; +} + +.url a { + font-weight: normal; +} + +/* FILE UPLOADS */ + +p.file-upload { + line-height: 20px; + margin: 0; + padding: 0; + color: #666; + font-size: 11px; + font-weight: bold; +} + +.file-upload a { + font-weight: normal; +} + +.file-upload .deletelink { + margin-left: 5px; +} + +span.clearable-file-input label { + color: #333; + font-size: 11px; + display: inline; + float: none; +} + +/* CALENDARS & CLOCKS */ + +.calendarbox, .clockbox { + margin: 5px auto; + font-size: 11px; + width: 16em; + text-align: center; + background: white; + position: relative; +} + +.clockbox { + width: auto; +} + +.calendar { + margin: 0; + padding: 0; +} + +.calendar table { + margin: 0; + padding: 0; + border-collapse: collapse; + background: white; + width: 100%; +} + +.calendar caption, .calendarbox h2 { + margin: 0; + font-size: 11px; + text-align: center; + border-top: none; +} + +.calendar th { + font-size: 10px; + color: #666; + padding: 2px 3px; + text-align: center; + background: #e1e1e1 url(../img/nav-bg.gif) 0 50% repeat-x; + border-bottom: 1px solid #ddd; +} + +.calendar td { + font-size: 11px; + text-align: center; + padding: 0; + border-top: 1px solid #eee; + border-bottom: none; +} + +.calendar td.selected a { + background: #C9DBED; +} + +.calendar td.nonday { + background: #efefef; +} + +.calendar td.today a { + background: #ffc; +} + +.calendar td a, .timelist a { + display: block; + font-weight: bold; + padding: 4px; + text-decoration: none; + color: #444; +} + +.calendar td a:hover, .timelist a:hover { + background: #5b80b2; + color: white; +} + +.calendar td a:active, .timelist a:active { + background: #036; + color: white; +} + +.calendarnav { + font-size: 10px; + text-align: center; + color: #ccc; + margin: 0; + padding: 1px 3px; +} + +.calendarnav a:link, #calendarnav a:visited, #calendarnav a:hover { + color: #999; +} + +.calendar-shortcuts { + background: white; + font-size: 10px; + line-height: 11px; + border-top: 1px solid #eee; + padding: 3px 0 4px; + color: #ccc; +} + +.calendarbox .calendarnav-previous, .calendarbox .calendarnav-next { + display: block; + position: absolute; + font-weight: bold; + font-size: 12px; + background: #C9DBED url(../img/default-bg.gif) bottom left repeat-x; + padding: 1px 4px 2px 4px; + color: white; +} + +.calendarnav-previous:hover, .calendarnav-next:hover { + background: #036; +} + +.calendarnav-previous { + top: 0; + left: 0; +} + +.calendarnav-next { + top: 0; + right: 0; +} + +.calendar-cancel { + margin: 0 !important; + padding: 0 !important; + font-size: 10px; + background: #e1e1e1 url(../img/nav-bg.gif) 0 50% repeat-x; + border-top: 1px solid #ddd; +} + +.calendar-cancel:hover { + background: #e1e1e1 url(../img/nav-bg-reverse.gif) 0 50% repeat-x; +} + +.calendar-cancel a { + color: black; + display: block; +} + +ul.timelist, .timelist li { + list-style-type: none; + margin: 0; + padding: 0; +} + +.timelist a { + padding: 2px; +} + +/* INLINE ORDERER */ + +ul.orderer { + position: relative; + padding: 0 !important; + margin: 0 !important; + list-style-type: none; +} + +ul.orderer li { + list-style-type: none; + display: block; + padding: 0; + margin: 0; + border: 1px solid #bbb; + border-width: 0 1px 1px 0; + white-space: nowrap; + overflow: hidden; + background: #e2e2e2 url(../img/nav-bg-grabber.gif) repeat-y; +} + +ul.orderer li:hover { + cursor: move; + background-color: #ddd; +} + +ul.orderer li a.selector { + margin-left: 12px; + overflow: hidden; + width: 83%; + font-size: 10px !important; + padding: 0.6em 0; +} + +ul.orderer li a:link, ul.orderer li a:visited { + color: #333; +} + +ul.orderer li .inline-deletelink { + position: absolute; + right: 4px; + margin-top: 0.6em; +} + +ul.orderer li.selected { + background-color: #f8f8f8; + border-right-color: #f8f8f8; +} + +ul.orderer li.deleted { + background: #bbb url(../img/deleted-overlay.gif); +} + +ul.orderer li.deleted a:link, ul.orderer li.deleted a:visited { + color: #888; +} + +ul.orderer li.deleted .inline-deletelink { + background-image: url(../img/inline-restore.png); +} + +ul.orderer li.deleted:hover, ul.orderer li.deleted a.selector:hover { + cursor: default; +} + +/* EDIT INLINE */ + +.inline-deletelink { + float: right; + text-indent: -9999px; + background: transparent url(../img/inline-delete.png) no-repeat; + width: 15px; + height: 15px; + border: 0px none; + outline: 0; /* Remove dotted border around link */ +} + +.inline-deletelink:hover { + background-position: -15px 0; + cursor: pointer; +} + +.editinline button.addlink { + border: 0px none; + color: #5b80b2; + font-size: 100%; + cursor: pointer; +} + +.editinline button.addlink:hover { + color: #036; + cursor: pointer; +} + +.editinline table .help { + text-align: right; + float: right; + padding-left: 2em; +} + +.editinline tfoot .addlink { + white-space: nowrap; +} + +.editinline table thead th:last-child { + border-left: none; +} + +.editinline tr.deleted { + background: #ddd url(../img/deleted-overlay.gif); +} + +.editinline tr.deleted .inline-deletelink { + background-image: url(../img/inline-restore.png); +} + +.editinline tr.deleted td:hover { + cursor: default; +} + +.editinline tr.deleted td:first-child { + background-image: none !important; +} + +/* EDIT INLINE - STACKED */ + +.editinline-stacked { + min-width: 758px; +} + +.editinline-stacked .inline-object { + margin-left: 210px; + background: white; +} + +.editinline-stacked .inline-source { + float: left; + width: 200px; + background: #f8f8f8; +} + +.editinline-stacked .inline-splitter { + float: left; + width: 9px; + background: #f8f8f8 url(../img/inline-splitter-bg.gif) 50% 50% no-repeat; + border-right: 1px solid #ccc; +} + +.editinline-stacked .controls { + clear: both; + background: #e1e1e1 url(../img/nav-bg.gif) top left repeat-x; + padding: 3px 4px; + font-size: 11px; + border-top: 1px solid #ddd; +} + +/* RELATED WIDGET WRAPPER */ +.related-widget-wrapper { + float: left; /* display properly in form rows with multiple fields */ + overflow: hidden; /* clear floated contents */ +} + +.related-widget-wrapper-link { + opacity: 0.3; +} + +.related-widget-wrapper-link:link { + opacity: 1; +} diff --git a/static/admin/img/changelist-bg.gif b/static/admin/img/changelist-bg.gif new file mode 100644 index 0000000000000000000000000000000000000000..94e09f7715e559bf199dc0bec756ae844baa8a6f GIT binary patch literal 50 zcmZ?wbh9u|T*$!0@PUEh{rmTK@7~p600NK*1Ct<6-^$Z(`4`XG5|y^@-k#s`q72pm D$4Cvt?bv=6id7ONcO70{{r%8=U|E literal 0 HcmV?d00001 diff --git a/static/admin/img/default-bg-reverse.gif b/static/admin/img/default-bg-reverse.gif new file mode 100644 index 0000000000000000000000000000000000000000..a28f4ad51a64131afbee7e2c3b6af352893c21e5 GIT binary patch literal 835 zcmV-J1HAl4Nk%v~VG#fy0QLX?ywd5g$>Wc((SfDPyV2;h%;kux&VHiEgQv@Yq{*Sa z+l{W!qQ2X>&*yuf#)zuThN#S(y4aey*L$GHimcC{yxF9{+^)ysgs01&yxO+S=DE=5 zq`=*$!rrpW%Ia#o)Ef<&3V-tHt57%Hx^1)~CYVyVB@=p~tMo;ew{h zv&!VG#o?8+)Qqmrnz+`6sm*|+$&#|ts>I*7&E~4Z;GetNkg(B_veJR3%8#$nw9VzU z&E=W6*PXi9oVwYCsLX|_%&NoRhN#WD(ddt_(zwp%xX$ON!QH9E;Dn~jv&-bS&gP%H z*|yE)hN;YZp~kn*=6s;Xx6kLIz1xql(y__nrNG^btIvL;$&0MdEC2ui01*Hm000O7 zfOifPgAR3s6N!Zm4lp*4BuykFJTOf*l}$X9EG!3~2cDpzoqh=-BB!URRtX8Ms!u=z zUbD1M1G%=j2p9;zy>Gw17{$G1Xb@%)%w}{DRc2LX%n%O-*9O`T+}qs-6yY>9I~3y- zJAD*?=sPhn3-R$WM@RDTQ%3>JcA0syKJpvRw!9yxMc>2a`&3xzovx=8UshKv*x zrBwWoF@=l|HCC*s;bR3396o&D2#Io}gqKQ&P@xj@r5G_1lt>sdX2ggH5q<(4L&hf= zpb;u$$grh?Ql=T4R*EFeIr5KLGLmcd%i6bbUe36dy_8@~t=1<8vdNG`N!QKH3#5}!MR z)_mbYfB-X2r#`*swCdC*JV5b~Bz9~MxJ{UV0|gEkBL#wo0UoA+5ir4%YY4HNd5A1o z;>^)NJp}VL4YJ!gaiT$Y@80pSX|Q3#jTWc((SfDPyV2;h%;kux&VHiEgQv@Yq{*Sa z+l{W!qQ2X>&*yuf#)zuThN#S(y4aey*L$GHimcC{yxF9{+^)ysgs01&yxO+S=DE=5 zq`=*$!rrpW%Ia#o)Ef<&3V-tHt57%Hx^1)~CYVyVB@=p~tMo;ew{h zv&!VG#o?8+)Qqmrnz+`6sm*|+$&#|ts>I*7&E~4Z;GetNkg(B_veJR3%8#$nw9VzU z&E=W6*PXi9oVwYCsLX|_%&NoRhN#WD(ddt_(zwp%xX$ON!QH9E;Dn~jv&-bS&gP%H z*|yE)hN;YZp~kn*=6s;Xx6kLIz1xql(y__nrNG^btIvL;$&0MdEC2ui01*Hm000O7 zfB=GngoT0x1WZIsh=@c4X^)Hq8yhz_C@7YhmN%6fC~FO)b|)tdr>LlSYz-PAudpFm zS#fh3xFN7$Mg_iMyEiEN27bWH6 z=HM3>ML{o4NKx(YFF{dAFGWZyZdf27DgX-9f+e7qGeUGM>CmP_hlM&i=nx`A;t~!V zesHj0A)^I895r&}pnw5`k|<3oSa~uJg9;fkY^eZKW(JxS@T~!jKv(R@CsZ0tXHsK5$_Dsx`$288T9sm2&pO+7vRWKDg+S zBgd5z~BMB}|@Q2`r zz!0M(GL*z*R@l?k*F|^NbkFEGAeD6Lr>o96_tdQ_$ug(M$DcUs_2^&rxr;JCKhN^= zGOMd=ghxm3IRAD|6i2K*dHVn8s@NajIqUTR2v1HTb!>_nqp27>`XK0!QyAbG8d0CA^F9Cx|8`Ux^7w#1hTk>)Z> z(jcFpXfa(;R1{={7MV5+3lFf?Vy&HYrCcdFs;KyOm=EBs5ygXBYq_}i>Vb?getdik z1axF^S%p;#RdeO?k9{10j>wELh)9l6DFO8@^|iIO1~iS#7=yKzIPTKvJS0t1(27OX zED#B9m7S%S$g~L?jj;#{HVN{sy_`*bwOnuSu)F(;!=n#WF@q^-d?WC=txYt`YI`}d z2t^e-aTlPLIkSRK-WXXWf($fM@8R|K&W*wM-t4jdY`u~wQq3Z~a_`|Sm6w7`<7)(N zm;x}jwK+A4Y2bAdf6y|d;Bv#1Ml-w-cwE`LQsme{%Sn7BN%F@irYVn1n{=2=V1=U# zEAT(0AgQYR^5Xdfcsfi#;r#0t!86r@QjICV%6p{_bOc97ED*c7B?{Ut#9L~0h(`w!0soRBa=!hZ`i3C(tMK-$w zq0zX*pg%xHYGQBoG7^Fp?f}pI6#xKNE*G6GrH2hC8gPGHzny?LP4i#C0l+j(@bfMu za~&je9lU;SE=0n!TuLi4l;uYlmIlMpLJ2Es7&hpF|OoMDi!f?u@=39aU~C_P=#aL^dh_Y z^LGv_IP*V9D>BBFd}#2i;VJgl&*=_EHTCD=-<4BqAQh@q7p&k5eY7C(@7f)D8DQ$7 zAQv>{)BVrv!0oKw@zG51AmyF|Q4~RQ;VNUzxj#fv1Xr)$IQmdWMruYncy8a%peRXj wVTV2;1d|B?Ap|@JEC~W)u~^{H-_Gvh3u9NM*1xcED*ylh07*qoM6N<$g2#E+6951J literal 0 HcmV?d00001 diff --git a/static/admin/img/icon-no.gif b/static/admin/img/icon-no.gif new file mode 100644 index 0000000000000000000000000000000000000000..1b4ee5814570885705399533f1182f8b0491c5fb GIT binary patch literal 176 zcmZ?wbhEHb`H-TFR%!C^)o_GDj!gPtK1gc27Dv@$SQ0{~`FJvsmY literal 0 HcmV?d00001 diff --git a/static/admin/img/icon-unknown.gif b/static/admin/img/icon-unknown.gif new file mode 100644 index 0000000000000000000000000000000000000000..cfd2b02ad91b3677dbe59111faaf4f437c362cb8 GIT binary patch literal 130 zcmV-|0Db>QNk%w1VF~~W0J9GO^z`(anwr7E!O_vts;a8Fxw+ur;K|9!=;-Lh#l`#k z`?0aH)z#IOmX?c)i~s-sA^8LW000jFEC2ui015yK000Cp@IAI#TTH&>x=&LlD2fp{ kltU;-pbSpsb&B9v9)J|xHP4tFtdrsVKoW`tBZ&Y2J8`5w82|tP literal 0 HcmV?d00001 diff --git a/static/admin/img/icon-yes.gif b/static/admin/img/icon-yes.gif new file mode 100644 index 0000000000000000000000000000000000000000..73992827403791d6c1a75a079880e41dce7e0214 GIT binary patch literal 299 zcmZ?wbhEHbb?NhTQ$x_deWPc4O)NkN2|oXRf%p{M+wuUw(Z# z`TWGXJ8Mf07p=Or^7yl3mtJ2C+~V)C-fh~&DX}}E_C4PF@Y93ee}B)tGUw-?pC_Il zZ#vO%{oS?y|Nqw=uUUR`+4?){5_iQh&Q{xM6OkFieY2o T4)tf0@^WEj=4)bdWUvMRbX#E6 literal 0 HcmV?d00001 diff --git a/static/admin/img/icon_addlink.gif b/static/admin/img/icon_addlink.gif new file mode 100644 index 0000000000000000000000000000000000000000..ee70e1adba52480cc6aedbee650000c5d55b0088 GIT binary patch literal 119 zcmZ?wbhEHb(s)E@aY^3 F)&O8RB1ZrK literal 0 HcmV?d00001 diff --git a/static/admin/img/icon_alert.gif b/static/admin/img/icon_alert.gif new file mode 100644 index 0000000000000000000000000000000000000000..a1dde2625445b76d041ae02ccfcb83481ca63c5e GIT binary patch literal 145 zcmV;C0B-+BNk%w1VGsZi0J9GO|G@+Q!3O`;RR7pu|IkAJ%Ps%YPXF0v|INcdJ{u&=}=IXLDhr+J%S1nrq(gCL;wIgri4F* literal 0 HcmV?d00001 diff --git a/static/admin/img/icon_calendar.gif b/static/admin/img/icon_calendar.gif new file mode 100644 index 0000000000000000000000000000000000000000..7587b305a4ee702cbed3bee1ae17c78feb85d00b GIT binary patch literal 192 zcmV;x06+gnNk%w1VGsZi0J8u9nVFf2iHY^~_4)bv@bK{4+uQ&D|FN{U?d|Qf&F0D5 z?Wd=w{QUgs>FMX^=l}ozA^8LW000jFEC2ui01yBW000DS@X1N*1UPGamH(iU1QH+` z43ii};vPZqm~L$+una7G@AI)4YnU1cj)Wk=I*&Aa=g_Vl48 zmH)wj0Spv>vM@3*@G|Itcpx(vSX4HgyeYC&>*nrB_bxSQsBGn6*)YRRaLr}Q6>6LJ P$Rx*~-FRR+2ZJ>L#Kbnb literal 0 HcmV?d00001 diff --git a/static/admin/img/icon_clock.gif b/static/admin/img/icon_clock.gif new file mode 100644 index 0000000000000000000000000000000000000000..ff2d57e0a3b6373b7bd9540e688b1b4c71081cb7 GIT binary patch literal 390 zcmV;10eSvMNk%w1VGsZi0M$DH{QUg>{{H#-`S$kq$lLA4+3fD_?(*{T{{H>?`uXqg z@BaV(?CkCH^Yi-p`u6wt#Mtch_4dHk>iGEh^7Hca^z*{j>crRU`1twz{QT_e?DqEc z$J*@b>gvMQ>+|&V$lC14+wAM>>;3)w@9*%!*X#51^1;{Z`}_OH+U@-O`^ehu#MkWU z>FEFe{^{xI#n|ld@$l~N@5kBgv9!0z+wHW?=G)ubr>Cd?|NohpnY8A@0000000000 z00000A^8LW0027xEC2ui01yBW000J~z@2cXD;jmfB(YW_ga{xGQmJF&uGa!=Dy-IU zx$q)@gRrJva4tXt05Uks30VcZ5F=VbfDzy%IyZGW2r3RV4+8@cI5vSg1UL%-4ihvL z4F?pBk1IFOZ1vml&CJGE4FE})gH$(*xI2#8t kA}zwiLpm2FSXaY=R2~vG+}zkoL`Ox%;6gX&=t@BVI|kg>kN^Mx literal 0 HcmV?d00001 diff --git a/static/admin/img/icon_deletelink.gif b/static/admin/img/icon_deletelink.gif new file mode 100644 index 0000000000000000000000000000000000000000..72523e3a3ba1446c8f768c157cea642119a02741 GIT binary patch literal 181 zcmZ?wbhEHbc&kkH2hg{xUB9fxq8%JG(R5 zT3?Eao`!{eDJnj1U~tLY{9|s;X>G0VWo1vp!yowhEs~V{|NlP&4xspxg^__loIwX9 z53-Yi)#yQKi;S#{{sX6 zi;Dh#`0#&e>3>Vh|D2rv=gC*q|>i-WM_<#QV|C1;G zS5*8rF!=rZ_kUyK|3JV%TcG%pg^__lo4aiRnY%vG=3p{kB40{i-Of=+@!=XF*PxeFcKRp5+{MAgNb8s5C%r0Nf+V(Fc^hI32V>!mF$oB=+5Fr} zS@EPfJ&q(r71kQJj|+D5gx-cdfOUJF*3qLUpX@fhwj2Z2NqP6D^+9o>vF~16iNV_P zex5r<@ABBawmM*6NbZs;Z(r0sJ19qig#gHWiPP;Qdj|l(`@h|k4Q2l`VT~qprl8mW O0000z_u719puq!NScSPpF zg#4pv1xM2>&lOf*D6TwP`0>{VkG0l*8=OKmdxUNAj@;&(aUeGLNb=vme}Ptmoj^XJ z_>+Z^fkBHw2V?}uPYi5D4pR#}bfiS5bS&9qz$LFSv4l%VM0VNAuq7M$%x`OYevyni z6y)sQCFr(n`AWsDVxcXCnHqNfPZgaKf;1I5H8q8UQ?&$wdD=UoSe-bM`a7eHH~@pX3AZUw**Q-a$B>F! ztrKr=Yc}9;F^sEP<>n$(`sY7?u41ok{?o=aDc_ikE__wyGB|VQ^y4}i)8{7jjRziW zWUGH=WYhPK*<`iF!A)ju@)o}Kg)K}zLYiIb+Pf7eGI?>na!@|xVkorHV+YfQ?MuAg z@|CcCdDQaSD5k#PP-zbv&$a)aU$%TM?7cSs{*JlDYX#Oi?a^KlyEQB$CcW%X`i6gI z?dKote=zN6@Xw<+-ygU)|H5tdm42e~0drUR>AA++`7K+t{M~&$wP%?>-X)!`lzy#O bcZ8c|t#ZiQiz<~spD}p4`njxgN@xNAak0;{ literal 0 HcmV?d00001 diff --git a/static/admin/img/inline-delete.png b/static/admin/img/inline-delete.png new file mode 100644 index 0000000000000000000000000000000000000000..c5fe53c4e3bbd5f2e349be9c87c896ab99f7b6c3 GIT binary patch literal 707 zcmeAS@N?(olHy`uVBq!ia0vp^3P8-y!3-of#o4MdFfg(P_=LCux&QzF2afeg65dw;$omkMMVXW?CtFZk`pIR1d({T}zkh%K{{83Apa1^-`}_AVkOX=^Bseb$ zXk1uHkY6w`V3=6hIXJnvdHDDRg+wJJrDYYA)wOi>^bL$m&CIQA?d%<#T)lmK{emN- zV&W1~QqwZB^9qZKYisN38@hTXOqe-)(UN5=R&O|P@X@QU-+%lB+H!Mm$rGT-;+`&! zAr-e;Cq{-Ja^PuYcU{#KefL!pw}wQabHGaP2^;l#oTg{~{$Jnq@=QSgz6$wC?Z4;F zncX5<*Znupk-2PZ*!}3avlz}rF0bBaJeT>JqK52Q%>_lhUgq6w8ghqKZ-z)2vqWtF z;bS)S-X1oY3Jwbf{&@-08`So>F$KEh-w1Np$hl76a{52nIT2@ex$F0|b{rP3S(9== zh(XZP$?gDGw7ZIu=Lz>aXBebCEu%l?lwsCvUAE-@q8|1er`{)A(RgVs@%7ZRNlR literal 0 HcmV?d00001 diff --git a/static/admin/img/inline-restore-8bit.png b/static/admin/img/inline-restore-8bit.png new file mode 100644 index 0000000000000000000000000000000000000000..d29fe1da636554080638326474fd122a52d2580a GIT binary patch literal 363 zcmeAS@N?(olHy`uVBq!ia0vp^3P8-y!3-of#o4L?DUSf35ZC|z|Ns8|`}_CrpFe+o z|Ni}}SFfHud-mwjqkH%6-MV$_+O=z!E?qiz?%dI%M-Lu6xOeZ~ty{Nl+_-V&%9RTi zESNE4#)JtI8X6jah8%q?0Ww;mB*-rq$i)U2&I;?j0;<{N>EaktajSLWZN3%-9+%Up zue-X;r~LnaIoDd^+gVS88J07rXkHa(d|>%Jbw&TBz*Cmx2cDnZ@@rMsQ?uBOjCps> z*dB`Pe^<@&kkRLnu#rib`1}cl5)ZB{7tlEpzTVC-+9TwF@;*(D17Ef6>R3IvHmDk~ zPr4m2S+yrw;pB{o7t$2moMtO>OfYB`s**6)Sm(6=vd9=Y0kbtDnm{r-UW|Qe3-Z literal 0 HcmV?d00001 diff --git a/static/admin/img/inline-restore.png b/static/admin/img/inline-restore.png new file mode 100644 index 0000000000000000000000000000000000000000..2a6778884027c4ec32dcadb1a06874549e3f7dc5 GIT binary patch literal 557 zcmeAS@N?(olHy`uVBq!ia0vp^3P8-y!3-of#o4L?sRIE%A+A9B|Ns9$a`1!w`}ZF` zdi3(;%TJ#^eevSO%a<>KF1J&*-Vb!TWl4}p~_mQGJnv%`q&x#~R-L{~x|2{j$-oNBdI0&7SLF-wH+rxxP#7 zuP1YPJbQii(Yq~dP3f;q_7ymM@$-|P&Q+m*ZIiNEIupx$mp2`2I28ol zEyZ+|jP^OIj@Aj>X>S{JXDn^bV=UatdgKOEd4O-t9mlDyRi6I^|6Sg>J7q`9{w&%0 qi*h}eZttiIyT8tSGt2p3-)FP?x|keocymf06y2V#elF{r5}E)*XPtQf literal 0 HcmV?d00001 diff --git a/static/admin/img/inline-splitter-bg.gif b/static/admin/img/inline-splitter-bg.gif new file mode 100644 index 0000000000000000000000000000000000000000..2fc918db98f2730cdf7660ab08bdc57f4a406f20 GIT binary patch literal 94 zcmZ?wbh9u|WMyDw_{_jyV{4#2a57-S&KT*C(G{DQl+NNW9y=`fHnu-v==- Ot=>b+CQo8uum%9*_Ae;_ literal 0 HcmV?d00001 diff --git a/static/admin/img/nav-bg-reverse.gif b/static/admin/img/nav-bg-reverse.gif new file mode 100644 index 0000000000000000000000000000000000000000..19913fb0b069276d27d11e90842792284ecc5cd8 GIT binary patch literal 178 zcmV;j08Rf#Nk%v~VG#fy0P_F<|NsB^`1t<*{`U6v@$vEd`}^(f?dRv`;^N}{{r&3d z>hA9DU$B!R9e*F0P^XD&Kym`~Lm=e{4X9 z0SG{LF|hV2sP&~}&dXS}F6Z^GaGmodx!1$iy|0P;dtku_cTK7O6OU3(=2%Uiw4%hT z*KOU6HQ%^iR_%ZAF4;$K_VK literal 0 HcmV?d00001 diff --git a/static/admin/img/nav-bg.gif b/static/admin/img/nav-bg.gif new file mode 100644 index 0000000000000000000000000000000000000000..d7e22ff1b3ba4c2e4c0995adf9e8defb8f9b32d7 GIT binary patch literal 265 zcmZ?wbh9u|6l9QR_`<;O{rmT~Z{I$D{`}ReSAYNh{q^hDhYue(@t*9{u_A=gpfpKY#xG_U+rVXV3oq`}hCvu4kkJBw+-!bOW0h%H;bV&yW+$#R@9*pI_UiEW z?CP?Ck95?C|R9>g4S7hI*~?c(b5<>~I>>hs{~^5^I0=I80; z=IGz%@8ag`<>lq%*5<_4=+e^C z#nk1*)a1g{=h4y8!qVf<&(F@z&b-j%ywK&%&CR~h<;={?xXN z&E(0+$+peq$jHdI%ip)m;Iz!+w9MqT%HPMw$F$4hwaenO%j2}k;Izu%vdZJM$=|Zc z;j_rz#Kgq1$KA2V-NVDftj6HN!otD9!KlRGz`(%2zrU)&+P=QNr@`C2yu78s+@-+W zroh{!z}uj}25$81 znTg4wKV*_V0SZ({QZjm6}T8>Lu zxjGjJ)+xulI<9B;qVJnt{R*M#&-Y#bxc995vnxO+na5sZdb#&&u1=qRmR%x-M3#sxVCMpF zM)_t4c82h#EK=5a=bwS9!2+Lmh7dxTW=hHBop%bsr7UTxAq1q7a#@O-V_v!d4{KVP zr4Xc&%0j7s=B=|F-c zK>^HRP9tb=A*~?X*zo{Cb_@eY8{Br=#w+&yb=oDHs5S!M>yn1Bo=p=wh%g8vwPz!3OK2&oU50>;X_7L=3TT*kpXd2@U|| zzzH-UgA6wKNQ2JFZsccxDd4oMPaN%ZBl8p-G`Jj% z!Xz!s6@Vx$Otk~qAx-e$zfEprRTWH%Oow9jPh8 z1m3CnV1VVRVZK`2id^Qo0RTv#I_8(frida+Fa-cpn7{6N>9W&KhwXC5Mh8%;t8RO2 zn#AV20U#K!i1CV{^7`vwfbjhDlL20OW~*Vg8RCjeKKb&83v@RsqKA%(YX!mGJ1TX% z?f(1lGgQMQ!renoAu;r|(vAV(bxFp%-Y;(rJ{gEC?ykUGS|MQ1SAGh$SO z`xWAXPPo7YH&}@5bO=LEFu({nbfIUQ;T~1f0#h!)!a`83KmM4(K z$ic%{Fl7Wlj0F$>$zh=(l4BAgG~y8JPy_OqXA&}4j}D{5KL*8uLCO%IK*sY7t65Ep z1+1dglyQ#%8f1R;yI=m|$Hq3s4+&9X3zc|akPuuV6QpWE3nZ0^OE6#{A&>>DT9v9* z5fW8>+y@dep(X~jU`&~4K`GRv1_m%7Q)=j=Ah~48PF`|LnE(`9w&cl93PFyt7-c0( z$$(6TGL>ynR0ulh%21X~)kfJQsE zvX+74Wih*%%u-+go5?I^I~!WhWFR!36>T3!bDA(#;WVfTL~35F8rHP753YF)Y+@r@ zLCl6WdUP|JNKL9z3lf7sKm!_qhyg+fpax)wp$J6~12EJ;0E4K35;e)e5h$UCg3KTp zUP$W^Brt=tCSwK!Q3NQc0)(;XfGVI+1VOAZ3r4Jf0Du(&D+X(gy*A?y82~H+l#qxkpsX!!5Wy=>p*6(4T*qa3J3^-M79A}f~Wx&T&hA4PFvQ3P}LZ8=m{N+ z!BvF+%s>&;poSt!yVTzL_P4#U0Vc#D4ouhpAqkM0FZQqpUx>pF2{4Eqd=ZA~Vxb9P z@P)bvVgqq7cMn*ozz&!zj^hpl6TZL%CYq3d1nfY)=_QCb(rbhECZGwv$geo$I}J>5 zz`jkGhJg2bUU`UP8arq&7KkekOmJ5o0-i<~?kiw^xt(K0HGWe3p!hdNxXX?bKL8&QBj8J?XD3l~Ic!Z5=ll-6NG+o2uB Zpam_8(T+!#coX3W$0kPo=cNV&06TG~#AN^g literal 0 HcmV?d00001 diff --git a/static/admin/img/selector-search.gif b/static/admin/img/selector-search.gif new file mode 100644 index 0000000000000000000000000000000000000000..6d5f4c74923af2daba13baa484364380fb1614b9 GIT binary patch literal 552 zcmZ?wbhEHb6krfwc*ekR;r}fg8=Jp>|9X0Qe){yu!NI}X+uO&-$I8koH8s`3!otqZ z?(W^YSy@?TW@e{PpT2zg^6J&ABO)T)-Q5!s60Tjl=Ire3>gqaW%9PsL+PQP*Ha9mX zCnrZoN9W|^#K*^f{rYv@ym@clym|8E$=&V_@LPJBVtE(?uxDXW;RaaLxbLLEYd;7Mww%N01*VNRUKY#wgg9n+J znUg0^j*E-y=;*j{51X2rQc_ZG-@bkS{(VPBM~0yT6o0ZXf?TTuB0zD%z~0)x z(A3=0+M*~cF2*k1)@;Hotjo#FYS$;lCc@9cB5K1e*(T4%&$OJ0N1L&YotI^~f{vr% zn$~qnssdI5qW0Tb4Ak_r)E!)0jSnm~~hECZvY5o%BVqvfb0K*)eZU6uP literal 0 HcmV?d00001 diff --git a/static/admin/img/sorting-icons.gif b/static/admin/img/sorting-icons.gif new file mode 100644 index 0000000000000000000000000000000000000000..451aae59874c795763cee9b044bf2c487f15a853 GIT binary patch literal 369 zcmZ?wbhEHb6k}*%IKsg2;>C++&z_w!(hg+Pin}?%lgLZrnIy)1g(XR`svm zGk^a4IdkUBoH=vGj2X$3R|a-2{Qv(y1JOY7CkrDxgCK(rNC(JH2G(~8Dt#%L^DAd!+Lo{0I{PlaWBPvS zl4w&vYiXCFU#`t13Om+FTO9ns`tXZiGLm(GX1Uw7}z rTlY@?-zz3A8IKJL+X^m4Dfq0|aN9iZ(F((o&leUP?N)YTV6X-NKX0r` literal 0 HcmV?d00001 diff --git a/static/admin/img/tooltag-add.png b/static/admin/img/tooltag-add.png new file mode 100644 index 0000000000000000000000000000000000000000..1488ecf2ef9be1d5ba1541904b0761831eacf942 GIT binary patch literal 119 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJTYyi9>who^t@)Y*6k#k0@(X5g zcy=QV$dUJSaSW-rwe;*lMj)@r;OGC$*+-Xki)?Au7Z81S`izJHgX-)r-*y8f89ZJ6 KT-G@yGywo`GbQ~1 literal 0 HcmV?d00001 diff --git a/static/admin/img/tooltag-arrowright.png b/static/admin/img/tooltag-arrowright.png new file mode 100644 index 0000000000000000000000000000000000000000..2f05598f53be50627daf5265ce2fa3c7fc48b3cf GIT binary patch literal 200 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`{hlt4Ar-gIUf#&r>>$#R*xah< z%NF1bP0l+XkKCcREV literal 0 HcmV?d00001 diff --git a/static/admin/js/LICENSE-JQUERY.txt b/static/admin/js/LICENSE-JQUERY.txt new file mode 100644 index 00000000..a4c5bd76 --- /dev/null +++ b/static/admin/js/LICENSE-JQUERY.txt @@ -0,0 +1,20 @@ +Copyright (c) 2010 John Resig, http://jquery.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 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. \ No newline at end of file diff --git a/static/admin/js/SelectBox.js b/static/admin/js/SelectBox.js new file mode 100644 index 00000000..db3206cc --- /dev/null +++ b/static/admin/js/SelectBox.js @@ -0,0 +1,114 @@ +var SelectBox = { + cache: new Object(), + init: function(id) { + var box = document.getElementById(id); + var node; + SelectBox.cache[id] = new Array(); + var cache = SelectBox.cache[id]; + for (var i = 0; (node = box.options[i]); i++) { + cache.push({value: node.value, text: node.text, displayed: 1}); + } + }, + redisplay: function(id) { + // Repopulate HTML select box from cache + var box = document.getElementById(id); + box.options.length = 0; // clear all options + for (var i = 0, j = SelectBox.cache[id].length; i < j; i++) { + var node = SelectBox.cache[id][i]; + if (node.displayed) { + var new_option = new Option(node.text, node.value, false, false); + // Shows a tooltip when hovering over the option + new_option.setAttribute("title", node.text); + box.options[box.options.length] = new_option; + } + } + }, + filter: function(id, text) { + // Redisplay the HTML select box, displaying only the choices containing ALL + // the words in text. (It's an AND search.) + var tokens = text.toLowerCase().split(/\s+/); + var node, token; + for (var i = 0; (node = SelectBox.cache[id][i]); i++) { + node.displayed = 1; + for (var j = 0; (token = tokens[j]); j++) { + if (node.text.toLowerCase().indexOf(token) == -1) { + node.displayed = 0; + } + } + } + SelectBox.redisplay(id); + }, + delete_from_cache: function(id, value) { + var node, delete_index = null; + for (var i = 0; (node = SelectBox.cache[id][i]); i++) { + if (node.value == value) { + delete_index = i; + break; + } + } + var j = SelectBox.cache[id].length - 1; + for (var i = delete_index; i < j; i++) { + SelectBox.cache[id][i] = SelectBox.cache[id][i+1]; + } + SelectBox.cache[id].length--; + }, + add_to_cache: function(id, option) { + SelectBox.cache[id].push({value: option.value, text: option.text, displayed: 1}); + }, + cache_contains: function(id, value) { + // Check if an item is contained in the cache + var node; + for (var i = 0; (node = SelectBox.cache[id][i]); i++) { + if (node.value == value) { + return true; + } + } + return false; + }, + move: function(from, to) { + var from_box = document.getElementById(from); + var to_box = document.getElementById(to); + var option; + for (var i = 0; (option = from_box.options[i]); i++) { + if (option.selected && SelectBox.cache_contains(from, option.value)) { + SelectBox.add_to_cache(to, {value: option.value, text: option.text, displayed: 1}); + SelectBox.delete_from_cache(from, option.value); + } + } + SelectBox.redisplay(from); + SelectBox.redisplay(to); + }, + move_all: function(from, to) { + var from_box = document.getElementById(from); + var to_box = document.getElementById(to); + var option; + for (var i = 0; (option = from_box.options[i]); i++) { + if (SelectBox.cache_contains(from, option.value)) { + SelectBox.add_to_cache(to, {value: option.value, text: option.text, displayed: 1}); + SelectBox.delete_from_cache(from, option.value); + } + } + SelectBox.redisplay(from); + SelectBox.redisplay(to); + }, + sort: function(id) { + SelectBox.cache[id].sort( function(a, b) { + a = a.text.toLowerCase(); + b = b.text.toLowerCase(); + try { + if (a > b) return 1; + if (a < b) return -1; + } + catch (e) { + // silently fail on IE 'unknown' exception + } + return 0; + } ); + }, + select_all: function(id) { + var box = document.getElementById(id); + for (var i = 0; i < box.options.length; i++) { + box.options[i].selected = 'selected'; + } + } +} diff --git a/static/admin/js/SelectFilter2.js b/static/admin/js/SelectFilter2.js new file mode 100644 index 00000000..6c8a4b44 --- /dev/null +++ b/static/admin/js/SelectFilter2.js @@ -0,0 +1,166 @@ +/* +SelectFilter2 - Turns a multiple-select box into a filter interface. + +Requires core.js, SelectBox.js and addevent.js. +*/ +(function($) { +function findForm(node) { + // returns the node of the form containing the given node + if (node.tagName.toLowerCase() != 'form') { + return findForm(node.parentNode); + } + return node; +} + +window.SelectFilter = { + init: function(field_id, field_name, is_stacked, admin_static_prefix) { + if (field_id.match(/__prefix__/)){ + // Don't initialize on empty forms. + return; + } + var from_box = document.getElementById(field_id); + from_box.id += '_from'; // change its ID + from_box.className = 'filtered'; + + var ps = from_box.parentNode.getElementsByTagName('p'); + for (var i=0; i, because it just gets in the way. + from_box.parentNode.removeChild(ps[i]); + } else if (ps[i].className.indexOf("help") != -1) { + // Move help text up to the top so it isn't below the select + // boxes or wrapped off on the side to the right of the add + // button: + from_box.parentNode.insertBefore(ps[i], from_box.parentNode.firstChild); + } + } + + //
    or
    + var selector_div = quickElement('div', from_box.parentNode); + selector_div.className = is_stacked ? 'selector stacked' : 'selector'; + + //
    + var selector_available = quickElement('div', selector_div); + selector_available.className = 'selector-available'; + var title_available = quickElement('h2', selector_available, interpolate(gettext('Available %s') + ' ', [field_name])); + quickElement('img', title_available, '', 'src', admin_static_prefix + 'img/icon-unknown.gif', 'width', '10', 'height', '10', 'class', 'help help-tooltip', 'title', interpolate(gettext('This is the list of available %s. You may choose some by selecting them in the box below and then clicking the "Choose" arrow between the two boxes.'), [field_name])); + + var filter_p = quickElement('p', selector_available, '', 'id', field_id + '_filter'); + filter_p.className = 'selector-filter'; + + var search_filter_label = quickElement('label', filter_p, '', 'for', field_id + "_input"); + + var search_selector_img = quickElement('img', search_filter_label, '', 'src', admin_static_prefix + 'img/selector-search.gif', 'class', 'help-tooltip', 'alt', '', 'title', interpolate(gettext("Type into this box to filter down the list of available %s."), [field_name])); + + filter_p.appendChild(document.createTextNode(' ')); + + var filter_input = quickElement('input', filter_p, '', 'type', 'text', 'placeholder', gettext("Filter")); + filter_input.id = field_id + '_input'; + + selector_available.appendChild(from_box); + var choose_all = quickElement('a', selector_available, gettext('Choose all'), 'title', interpolate(gettext('Click to choose all %s at once.'), [field_name]), 'href', 'javascript: (function(){ SelectBox.move_all("' + field_id + '_from", "' + field_id + '_to"); SelectFilter.refresh_icons("' + field_id + '");})()', 'id', field_id + '_add_all_link'); + choose_all.className = 'selector-chooseall'; + + //
      + var selector_chooser = quickElement('ul', selector_div); + selector_chooser.className = 'selector-chooser'; + var add_link = quickElement('a', quickElement('li', selector_chooser), gettext('Choose'), 'title', gettext('Choose'), 'href', 'javascript: (function(){ SelectBox.move("' + field_id + '_from","' + field_id + '_to"); SelectFilter.refresh_icons("' + field_id + '");})()', 'id', field_id + '_add_link'); + add_link.className = 'selector-add'; + var remove_link = quickElement('a', quickElement('li', selector_chooser), gettext('Remove'), 'title', gettext('Remove'), 'href', 'javascript: (function(){ SelectBox.move("' + field_id + '_to","' + field_id + '_from"); SelectFilter.refresh_icons("' + field_id + '");})()', 'id', field_id + '_remove_link'); + remove_link.className = 'selector-remove'; + + //
      + var selector_chosen = quickElement('div', selector_div); + selector_chosen.className = 'selector-chosen'; + var title_chosen = quickElement('h2', selector_chosen, interpolate(gettext('Chosen %s') + ' ', [field_name])); + quickElement('img', title_chosen, '', 'src', admin_static_prefix + 'img/icon-unknown.gif', 'width', '10', 'height', '10', 'class', 'help help-tooltip', 'title', interpolate(gettext('This is the list of chosen %s. You may remove some by selecting them in the box below and then clicking the "Remove" arrow between the two boxes.'), [field_name])); + + var to_box = quickElement('select', selector_chosen, '', 'id', field_id + '_to', 'multiple', 'multiple', 'size', from_box.size, 'name', from_box.getAttribute('name')); + to_box.className = 'filtered'; + var clear_all = quickElement('a', selector_chosen, gettext('Remove all'), 'title', interpolate(gettext('Click to remove all chosen %s at once.'), [field_name]), 'href', 'javascript: (function() { SelectBox.move_all("' + field_id + '_to", "' + field_id + '_from"); SelectFilter.refresh_icons("' + field_id + '");})()', 'id', field_id + '_remove_all_link'); + clear_all.className = 'selector-clearall'; + + from_box.setAttribute('name', from_box.getAttribute('name') + '_old'); + + // Set up the JavaScript event handlers for the select box filter interface + addEvent(filter_input, 'keypress', function(e) { SelectFilter.filter_key_press(e, field_id); }); + addEvent(filter_input, 'keyup', function(e) { SelectFilter.filter_key_up(e, field_id); }); + addEvent(filter_input, 'keydown', function(e) { SelectFilter.filter_key_down(e, field_id); }); + addEvent(from_box, 'change', function(e) { SelectFilter.refresh_icons(field_id) }); + addEvent(to_box, 'change', function(e) { SelectFilter.refresh_icons(field_id) }); + addEvent(from_box, 'dblclick', function() { SelectBox.move(field_id + '_from', field_id + '_to'); SelectFilter.refresh_icons(field_id); }); + addEvent(to_box, 'dblclick', function() { SelectBox.move(field_id + '_to', field_id + '_from'); SelectFilter.refresh_icons(field_id); }); + addEvent(findForm(from_box), 'submit', function() { SelectBox.select_all(field_id + '_to'); }); + SelectBox.init(field_id + '_from'); + SelectBox.init(field_id + '_to'); + // Move selected from_box options to to_box + SelectBox.move(field_id + '_from', field_id + '_to'); + + if (!is_stacked) { + // In horizontal mode, give the same height to the two boxes. + var j_from_box = $(from_box); + var j_to_box = $(to_box); + var resize_filters = function() { j_to_box.height($(filter_p).outerHeight() + j_from_box.outerHeight()); } + if (j_from_box.outerHeight() > 0) { + resize_filters(); // This fieldset is already open. Resize now. + } else { + // This fieldset is probably collapsed. Wait for its 'show' event. + j_to_box.closest('fieldset').one('show.fieldset', resize_filters); + } + } + + // Initial icon refresh + SelectFilter.refresh_icons(field_id); + }, + refresh_icons: function(field_id) { + var from = $('#' + field_id + '_from'); + var to = $('#' + field_id + '_to'); + var is_from_selected = from.find('option:selected').length > 0; + var is_to_selected = to.find('option:selected').length > 0; + // Active if at least one item is selected + $('#' + field_id + '_add_link').toggleClass('active', is_from_selected); + $('#' + field_id + '_remove_link').toggleClass('active', is_to_selected); + // Active if the corresponding box isn't empty + $('#' + field_id + '_add_all_link').toggleClass('active', from.find('option').length > 0); + $('#' + field_id + '_remove_all_link').toggleClass('active', to.find('option').length > 0); + }, + filter_key_press: function(event, field_id) { + var from = document.getElementById(field_id + '_from'); + // don't submit form if user pressed Enter + if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) { + from.selectedIndex = 0; + SelectBox.move(field_id + '_from', field_id + '_to'); + from.selectedIndex = 0; + event.preventDefault() + return false; + } + }, + filter_key_up: function(event, field_id) { + var from = document.getElementById(field_id + '_from'); + var temp = from.selectedIndex; + SelectBox.filter(field_id + '_from', document.getElementById(field_id + '_input').value); + from.selectedIndex = temp; + return true; + }, + filter_key_down: function(event, field_id) { + var from = document.getElementById(field_id + '_from'); + // right arrow -- move across + if ((event.which && event.which == 39) || (event.keyCode && event.keyCode == 39)) { + var old_index = from.selectedIndex; + SelectBox.move(field_id + '_from', field_id + '_to'); + from.selectedIndex = (old_index == from.length) ? from.length - 1 : old_index; + return false; + } + // down arrow -- wrap around + if ((event.which && event.which == 40) || (event.keyCode && event.keyCode == 40)) { + from.selectedIndex = (from.length == from.selectedIndex + 1) ? 0 : from.selectedIndex + 1; + } + // up arrow -- wrap around + if ((event.which && event.which == 38) || (event.keyCode && event.keyCode == 38)) { + from.selectedIndex = (from.selectedIndex == 0) ? from.length - 1 : from.selectedIndex - 1; + } + return true; + } +} + +})(django.jQuery); diff --git a/static/admin/js/actions.js b/static/admin/js/actions.js new file mode 100644 index 00000000..58f572f2 --- /dev/null +++ b/static/admin/js/actions.js @@ -0,0 +1,144 @@ +(function($) { + var lastChecked; + + $.fn.actions = function(opts) { + var options = $.extend({}, $.fn.actions.defaults, opts); + var actionCheckboxes = $(this); + var list_editable_changed = false; + var checker = function(checked) { + if (checked) { + showQuestion(); + } else { + reset(); + } + $(actionCheckboxes).prop("checked", checked) + .parent().parent().toggleClass(options.selectedClass, checked); + }, + updateCounter = function() { + var sel = $(actionCheckboxes).filter(":checked").length; + // _actions_icnt is defined in the generated HTML + // and contains the total amount of objects in the queryset + $(options.counterContainer).html(interpolate( + ngettext('%(sel)s of %(cnt)s selected', '%(sel)s of %(cnt)s selected', sel), { + sel: sel, + cnt: _actions_icnt + }, true)); + $(options.allToggle).prop("checked", function() { + var value; + if (sel == actionCheckboxes.length) { + value = true; + showQuestion(); + } else { + value = false; + clearAcross(); + } + return value; + }); + }, + showQuestion = function() { + $(options.acrossClears).hide(); + $(options.acrossQuestions).show(); + $(options.allContainer).hide(); + }, + showClear = function() { + $(options.acrossClears).show(); + $(options.acrossQuestions).hide(); + $(options.actionContainer).toggleClass(options.selectedClass); + $(options.allContainer).show(); + $(options.counterContainer).hide(); + }, + reset = function() { + $(options.acrossClears).hide(); + $(options.acrossQuestions).hide(); + $(options.allContainer).hide(); + $(options.counterContainer).show(); + }, + clearAcross = function() { + reset(); + $(options.acrossInput).val(0); + $(options.actionContainer).removeClass(options.selectedClass); + }; + // Show counter by default + $(options.counterContainer).show(); + // Check state of checkboxes and reinit state if needed + $(this).filter(":checked").each(function(i) { + $(this).parent().parent().toggleClass(options.selectedClass); + updateCounter(); + if ($(options.acrossInput).val() == 1) { + showClear(); + } + }); + $(options.allToggle).show().click(function() { + checker($(this).prop("checked")); + updateCounter(); + }); + $("a", options.acrossQuestions).click(function(event) { + event.preventDefault(); + $(options.acrossInput).val(1); + showClear(); + }); + $("a", options.acrossClears).click(function(event) { + event.preventDefault(); + $(options.allToggle).prop("checked", false); + clearAcross(); + checker(0); + updateCounter(); + }); + lastChecked = null; + $(actionCheckboxes).click(function(event) { + if (!event) { event = window.event; } + var target = event.target ? event.target : event.srcElement; + if (lastChecked && $.data(lastChecked) != $.data(target) && event.shiftKey === true) { + var inrange = false; + $(lastChecked).prop("checked", target.checked) + .parent().parent().toggleClass(options.selectedClass, target.checked); + $(actionCheckboxes).each(function() { + if ($.data(this) == $.data(lastChecked) || $.data(this) == $.data(target)) { + inrange = (inrange) ? false : true; + } + if (inrange) { + $(this).prop("checked", target.checked) + .parent().parent().toggleClass(options.selectedClass, target.checked); + } + }); + } + $(target).parent().parent().toggleClass(options.selectedClass, target.checked); + lastChecked = target; + updateCounter(); + }); + $('form#changelist-form table#result_list tr').find('td:gt(0) :input').change(function() { + list_editable_changed = true; + }); + $('form#changelist-form button[name="index"]').click(function(event) { + if (list_editable_changed) { + return confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost.")); + } + }); + $('form#changelist-form input[name="_save"]').click(function(event) { + var action_changed = false; + $('select option:selected', options.actionContainer).each(function() { + if ($(this).val()) { + action_changed = true; + } + }); + if (action_changed) { + if (list_editable_changed) { + return confirm(gettext("You have selected an action, but you haven't saved your changes to individual fields yet. Please click OK to save. You'll need to re-run the action.")); + } else { + return confirm(gettext("You have selected an action, and you haven't made any changes on individual fields. You're probably looking for the Go button rather than the Save button.")); + } + } + }); + }; + /* Setup plugin defaults */ + $.fn.actions.defaults = { + actionContainer: "div.actions", + counterContainer: "span.action-counter", + allContainer: "div.actions span.all", + acrossInput: "div.actions input.select-across", + acrossQuestions: "div.actions span.question", + acrossClears: "div.actions span.clear", + allToggle: "#action-toggle", + selectedClass: "selected" + }; +})(django.jQuery); diff --git a/static/admin/js/actions.min.js b/static/admin/js/actions.min.js new file mode 100644 index 00000000..0dd6683f --- /dev/null +++ b/static/admin/js/actions.min.js @@ -0,0 +1,6 @@ +(function(a){var f;a.fn.actions=function(q){var b=a.extend({},a.fn.actions.defaults,q),g=a(this),e=!1,m=function(c){c?k():l();a(g).prop("checked",c).parent().parent().toggleClass(b.selectedClass,c)},h=function(){var c=a(g).filter(":checked").length;a(b.counterContainer).html(interpolate(ngettext("%(sel)s of %(cnt)s selected","%(sel)s of %(cnt)s selected",c),{sel:c,cnt:_actions_icnt},!0));a(b.allToggle).prop("checked",function(){var a;c==g.length?(a=!0,k()):(a=!1,n());return a})},k=function(){a(b.acrossClears).hide(); +a(b.acrossQuestions).show();a(b.allContainer).hide()},p=function(){a(b.acrossClears).show();a(b.acrossQuestions).hide();a(b.actionContainer).toggleClass(b.selectedClass);a(b.allContainer).show();a(b.counterContainer).hide()},l=function(){a(b.acrossClears).hide();a(b.acrossQuestions).hide();a(b.allContainer).hide();a(b.counterContainer).show()},n=function(){l();a(b.acrossInput).val(0);a(b.actionContainer).removeClass(b.selectedClass)};a(b.counterContainer).show();a(this).filter(":checked").each(function(c){a(this).parent().parent().toggleClass(b.selectedClass); +h();1==a(b.acrossInput).val()&&p()});a(b.allToggle).show().click(function(){m(a(this).prop("checked"));h()});a("a",b.acrossQuestions).click(function(c){c.preventDefault();a(b.acrossInput).val(1);p()});a("a",b.acrossClears).click(function(c){c.preventDefault();a(b.allToggle).prop("checked",!1);n();m(0);h()});f=null;a(g).click(function(c){c||(c=window.event);var d=c.target?c.target:c.srcElement;if(f&&a.data(f)!=a.data(d)&&!0===c.shiftKey){var e=!1;a(f).prop("checked",d.checked).parent().parent().toggleClass(b.selectedClass, +d.checked);a(g).each(function(){if(a.data(this)==a.data(f)||a.data(this)==a.data(d))e=e?!1:!0;e&&a(this).prop("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked)})}a(d).parent().parent().toggleClass(b.selectedClass,d.checked);f=d;h()});a("form#changelist-form table#result_list tr").find("td:gt(0) :input").change(function(){e=!0});a('form#changelist-form button[name="index"]').click(function(a){if(e)return confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost."))}); +a('form#changelist-form input[name="_save"]').click(function(c){var d=!1;a("select option:selected",b.actionContainer).each(function(){a(this).val()&&(d=!0)});if(d)return e?confirm(gettext("You have selected an action, but you haven't saved your changes to individual fields yet. Please click OK to save. You'll need to re-run the action.")):confirm(gettext("You have selected an action, and you haven't made any changes on individual fields. You're probably looking for the Go button rather than the Save button."))})}; +a.fn.actions.defaults={actionContainer:"div.actions",counterContainer:"span.action-counter",allContainer:"div.actions span.all",acrossInput:"div.actions input.select-across",acrossQuestions:"div.actions span.question",acrossClears:"div.actions span.clear",allToggle:"#action-toggle",selectedClass:"selected"}})(django.jQuery); diff --git a/static/admin/js/admin/DateTimeShortcuts.js b/static/admin/js/admin/DateTimeShortcuts.js new file mode 100644 index 00000000..faec5a49 --- /dev/null +++ b/static/admin/js/admin/DateTimeShortcuts.js @@ -0,0 +1,357 @@ +// Inserts shortcut buttons after all of the following: +// +// + +var DateTimeShortcuts = { + calendars: [], + calendarInputs: [], + clockInputs: [], + dismissClockFunc: [], + dismissCalendarFunc: [], + calendarDivName1: 'calendarbox', // name of calendar
      that gets toggled + calendarDivName2: 'calendarin', // name of
      that contains calendar + calendarLinkName: 'calendarlink',// name of the link that is used to toggle + clockDivName: 'clockbox', // name of clock
      that gets toggled + clockLinkName: 'clocklink', // name of the link that is used to toggle + shortCutsClass: 'datetimeshortcuts', // class of the clock and cal shortcuts + timezoneWarningClass: 'timezonewarning', // class of the warning for timezone mismatch + timezoneOffset: 0, + admin_media_prefix: '', + init: function() { + // Get admin_media_prefix by grabbing it off the window object. It's + // set in the admin/base.html template, so if it's not there, someone's + // overridden the template. In that case, we'll set a clearly-invalid + // value in the hopes that someone will examine HTTP requests and see it. + if (window.__admin_media_prefix__ != undefined) { + DateTimeShortcuts.admin_media_prefix = window.__admin_media_prefix__; + } else { + DateTimeShortcuts.admin_media_prefix = '/missing-admin-media-prefix/'; + } + + if (window.__admin_utc_offset__ != undefined) { + var serverOffset = window.__admin_utc_offset__; + var localOffset = new Date().getTimezoneOffset() * -60; + DateTimeShortcuts.timezoneOffset = localOffset - serverOffset; + } + + var inputs = document.getElementsByTagName('input'); + for (i=0; i 0) { + message = ngettext( + 'Note: You are %s hour ahead of server time.', + 'Note: You are %s hours ahead of server time.', + timezoneOffset + ); + } + else { + timezoneOffset *= -1 + message = ngettext( + 'Note: You are %s hour behind server time.', + 'Note: You are %s hours behind server time.', + timezoneOffset + ); + } + message = interpolate(message, [timezoneOffset]); + + var $warning = $(''); + $warning.attr('class', warningClass); + $warning.text(message); + + $(inp).parent() + .append($('
      ')) + .append($warning) + }, + // Add clock widget to a given field + addClock: function(inp) { + var num = DateTimeShortcuts.clockInputs.length; + DateTimeShortcuts.clockInputs[num] = inp; + DateTimeShortcuts.dismissClockFunc[num] = function() { DateTimeShortcuts.dismissClock(num); return true; }; + + // Shortcut links (clock icon and "Now" link) + var shortcuts_span = document.createElement('span'); + shortcuts_span.className = DateTimeShortcuts.shortCutsClass; + inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling); + var now_link = document.createElement('a'); + now_link.setAttribute('href', "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", -1);"); + now_link.appendChild(document.createTextNode(gettext('Now'))); + var clock_link = document.createElement('a'); + clock_link.setAttribute('href', 'javascript:DateTimeShortcuts.openClock(' + num + ');'); + clock_link.id = DateTimeShortcuts.clockLinkName + num; + quickElement('img', clock_link, '', 'src', DateTimeShortcuts.admin_media_prefix + 'img/icon_clock.gif', 'alt', gettext('Clock')); + shortcuts_span.appendChild(document.createTextNode('\240')); + shortcuts_span.appendChild(now_link); + shortcuts_span.appendChild(document.createTextNode('\240|\240')); + shortcuts_span.appendChild(clock_link); + + // Create clock link div + // + // Markup looks like: + //
      + //

      Choose a time

      + // + //

      Cancel

      + //
      + + var clock_box = document.createElement('div'); + clock_box.style.display = 'none'; + clock_box.style.position = 'absolute'; + clock_box.className = 'clockbox module'; + clock_box.setAttribute('id', DateTimeShortcuts.clockDivName + num); + document.body.appendChild(clock_box); + addEvent(clock_box, 'click', cancelEventPropagation); + + quickElement('h2', clock_box, gettext('Choose a time')); + var time_list = quickElement('ul', clock_box); + time_list.className = 'timelist'; + quickElement("a", quickElement("li", time_list), gettext("Now"), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", -1);"); + quickElement("a", quickElement("li", time_list), gettext("Midnight"), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", 0);"); + quickElement("a", quickElement("li", time_list), gettext("6 a.m."), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", 6);"); + quickElement("a", quickElement("li", time_list), gettext("Noon"), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", 12);"); + + var cancel_p = quickElement('p', clock_box); + cancel_p.className = 'calendar-cancel'; + quickElement('a', cancel_p, gettext('Cancel'), 'href', 'javascript:DateTimeShortcuts.dismissClock(' + num + ');'); + django.jQuery(document).bind('keyup', function(event) { + if (event.which == 27) { + // ESC key closes popup + DateTimeShortcuts.dismissClock(num); + event.preventDefault(); + } + }); + }, + openClock: function(num) { + var clock_box = document.getElementById(DateTimeShortcuts.clockDivName+num) + var clock_link = document.getElementById(DateTimeShortcuts.clockLinkName+num) + + // Recalculate the clockbox position + // is it left-to-right or right-to-left layout ? + if (getStyle(document.body,'direction')!='rtl') { + clock_box.style.left = findPosX(clock_link) + 17 + 'px'; + } + else { + // since style's width is in em, it'd be tough to calculate + // px value of it. let's use an estimated px for now + // TODO: IE returns wrong value for findPosX when in rtl mode + // (it returns as it was left aligned), needs to be fixed. + clock_box.style.left = findPosX(clock_link) - 110 + 'px'; + } + clock_box.style.top = Math.max(0, findPosY(clock_link) - 30) + 'px'; + + // Show the clock box + clock_box.style.display = 'block'; + addEvent(document, 'click', DateTimeShortcuts.dismissClockFunc[num]); + }, + dismissClock: function(num) { + document.getElementById(DateTimeShortcuts.clockDivName + num).style.display = 'none'; + removeEvent(document, 'click', DateTimeShortcuts.dismissClockFunc[num]); + }, + handleClockQuicklink: function(num, val) { + var d; + if (val == -1) { + d = DateTimeShortcuts.now(); + } + else { + d = new Date(1970, 1, 1, val, 0, 0, 0) + } + DateTimeShortcuts.clockInputs[num].value = d.strftime(get_format('TIME_INPUT_FORMATS')[0]); + DateTimeShortcuts.clockInputs[num].focus(); + DateTimeShortcuts.dismissClock(num); + }, + // Add calendar widget to a given field. + addCalendar: function(inp) { + var num = DateTimeShortcuts.calendars.length; + + DateTimeShortcuts.calendarInputs[num] = inp; + DateTimeShortcuts.dismissCalendarFunc[num] = function() { DateTimeShortcuts.dismissCalendar(num); return true; }; + + // Shortcut links (calendar icon and "Today" link) + var shortcuts_span = document.createElement('span'); + shortcuts_span.className = DateTimeShortcuts.shortCutsClass; + inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling); + var today_link = document.createElement('a'); + today_link.setAttribute('href', 'javascript:DateTimeShortcuts.handleCalendarQuickLink(' + num + ', 0);'); + today_link.appendChild(document.createTextNode(gettext('Today'))); + var cal_link = document.createElement('a'); + cal_link.setAttribute('href', 'javascript:DateTimeShortcuts.openCalendar(' + num + ');'); + cal_link.id = DateTimeShortcuts.calendarLinkName + num; + quickElement('img', cal_link, '', 'src', DateTimeShortcuts.admin_media_prefix + 'img/icon_calendar.gif', 'alt', gettext('Calendar')); + shortcuts_span.appendChild(document.createTextNode('\240')); + shortcuts_span.appendChild(today_link); + shortcuts_span.appendChild(document.createTextNode('\240|\240')); + shortcuts_span.appendChild(cal_link); + + // Create calendarbox div. + // + // Markup looks like: + // + //
      + //

      + // + // February 2003 + //

      + //
      + // + //
      + //
      + // Yesterday | Today | Tomorrow + //
      + //

      Cancel

      + //
      + var cal_box = document.createElement('div'); + cal_box.style.display = 'none'; + cal_box.style.position = 'absolute'; + cal_box.className = 'calendarbox module'; + cal_box.setAttribute('id', DateTimeShortcuts.calendarDivName1 + num); + document.body.appendChild(cal_box); + addEvent(cal_box, 'click', cancelEventPropagation); + + // next-prev links + var cal_nav = quickElement('div', cal_box); + var cal_nav_prev = quickElement('a', cal_nav, '<', 'href', 'javascript:DateTimeShortcuts.drawPrev('+num+');'); + cal_nav_prev.className = 'calendarnav-previous'; + var cal_nav_next = quickElement('a', cal_nav, '>', 'href', 'javascript:DateTimeShortcuts.drawNext('+num+');'); + cal_nav_next.className = 'calendarnav-next'; + + // main box + var cal_main = quickElement('div', cal_box, '', 'id', DateTimeShortcuts.calendarDivName2 + num); + cal_main.className = 'calendar'; + DateTimeShortcuts.calendars[num] = new Calendar(DateTimeShortcuts.calendarDivName2 + num, DateTimeShortcuts.handleCalendarCallback(num)); + DateTimeShortcuts.calendars[num].drawCurrent(); + + // calendar shortcuts + var shortcuts = quickElement('div', cal_box); + shortcuts.className = 'calendar-shortcuts'; + quickElement('a', shortcuts, gettext('Yesterday'), 'href', 'javascript:DateTimeShortcuts.handleCalendarQuickLink(' + num + ', -1);'); + shortcuts.appendChild(document.createTextNode('\240|\240')); + quickElement('a', shortcuts, gettext('Today'), 'href', 'javascript:DateTimeShortcuts.handleCalendarQuickLink(' + num + ', 0);'); + shortcuts.appendChild(document.createTextNode('\240|\240')); + quickElement('a', shortcuts, gettext('Tomorrow'), 'href', 'javascript:DateTimeShortcuts.handleCalendarQuickLink(' + num + ', +1);'); + + // cancel bar + var cancel_p = quickElement('p', cal_box); + cancel_p.className = 'calendar-cancel'; + quickElement('a', cancel_p, gettext('Cancel'), 'href', 'javascript:DateTimeShortcuts.dismissCalendar(' + num + ');'); + django.jQuery(document).bind('keyup', function(event) { + if (event.which == 27) { + // ESC key closes popup + DateTimeShortcuts.dismissCalendar(num); + event.preventDefault(); + } + }); + }, + openCalendar: function(num) { + var cal_box = document.getElementById(DateTimeShortcuts.calendarDivName1+num) + var cal_link = document.getElementById(DateTimeShortcuts.calendarLinkName+num) + var inp = DateTimeShortcuts.calendarInputs[num]; + + // Determine if the current value in the input has a valid date. + // If so, draw the calendar with that date's year and month. + if (inp.value) { + var format = get_format('DATE_INPUT_FORMATS')[0]; + var selected = inp.value.strptime(format); + var year = selected.getFullYear(); + var month = selected.getMonth() + 1; + var re = /\d{4}/ + if (re.test(year.toString()) && month >= 1 && month <= 12) { + DateTimeShortcuts.calendars[num].drawDate(month, year, selected); + } + } + + // Recalculate the clockbox position + // is it left-to-right or right-to-left layout ? + if (getStyle(document.body,'direction')!='rtl') { + cal_box.style.left = findPosX(cal_link) + 17 + 'px'; + } + else { + // since style's width is in em, it'd be tough to calculate + // px value of it. let's use an estimated px for now + // TODO: IE returns wrong value for findPosX when in rtl mode + // (it returns as it was left aligned), needs to be fixed. + cal_box.style.left = findPosX(cal_link) - 180 + 'px'; + } + cal_box.style.top = Math.max(0, findPosY(cal_link) - 75) + 'px'; + + cal_box.style.display = 'block'; + addEvent(document, 'click', DateTimeShortcuts.dismissCalendarFunc[num]); + }, + dismissCalendar: function(num) { + document.getElementById(DateTimeShortcuts.calendarDivName1+num).style.display = 'none'; + removeEvent(document, 'click', DateTimeShortcuts.dismissCalendarFunc[num]); + }, + drawPrev: function(num) { + DateTimeShortcuts.calendars[num].drawPreviousMonth(); + }, + drawNext: function(num) { + DateTimeShortcuts.calendars[num].drawNextMonth(); + }, + handleCalendarCallback: function(num) { + var format = get_format('DATE_INPUT_FORMATS')[0]; + // the format needs to be escaped a little + format = format.replace('\\', '\\\\'); + format = format.replace('\r', '\\r'); + format = format.replace('\n', '\\n'); + format = format.replace('\t', '\\t'); + format = format.replace("'", "\\'"); + return ["function(y, m, d) { DateTimeShortcuts.calendarInputs[", + num, + "].value = new Date(y, m-1, d).strftime('", + format, + "');DateTimeShortcuts.calendarInputs[", + num, + "].focus();document.getElementById(DateTimeShortcuts.calendarDivName1+", + num, + ").style.display='none';}"].join(''); + }, + handleCalendarQuickLink: function(num, offset) { + var d = DateTimeShortcuts.now(); + d.setDate(d.getDate() + offset) + DateTimeShortcuts.calendarInputs[num].value = d.strftime(get_format('DATE_INPUT_FORMATS')[0]); + DateTimeShortcuts.calendarInputs[num].focus(); + DateTimeShortcuts.dismissCalendar(num); + } +} + +addEvent(window, 'load', DateTimeShortcuts.init); diff --git a/static/admin/js/admin/RelatedObjectLookups.js b/static/admin/js/admin/RelatedObjectLookups.js new file mode 100644 index 00000000..ffba7cdf --- /dev/null +++ b/static/admin/js/admin/RelatedObjectLookups.js @@ -0,0 +1,130 @@ +// Handles related-objects functionality: lookup link for raw_id_fields +// and Add Another links. + +function html_unescape(text) { + // Unescape a string that was escaped using django.utils.html.escape. + text = text.replace(/</g, '<'); + text = text.replace(/>/g, '>'); + text = text.replace(/"/g, '"'); + text = text.replace(/'/g, "'"); + text = text.replace(/&/g, '&'); + return text; +} + +// IE doesn't accept periods or dashes in the window name, but the element IDs +// we use to generate popup window names may contain them, therefore we map them +// to allowed characters in a reversible way so that we can locate the correct +// element when the popup window is dismissed. +function id_to_windowname(text) { + text = text.replace(/\./g, '__dot__'); + text = text.replace(/\-/g, '__dash__'); + return text; +} + +function windowname_to_id(text) { + text = text.replace(/__dot__/g, '.'); + text = text.replace(/__dash__/g, '-'); + return text; +} + +function showAdminPopup(triggeringLink, name_regexp) { + var name = triggeringLink.id.replace(name_regexp, ''); + name = id_to_windowname(name); + var href = triggeringLink.href; + if (href.indexOf('?') == -1) { + href += '?_popup=1'; + } else { + href += '&_popup=1'; + } + var win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes'); + win.focus(); + return false; +} + +function showRelatedObjectLookupPopup(triggeringLink) { + return showAdminPopup(triggeringLink, /^lookup_/); +} + +function dismissRelatedLookupPopup(win, chosenId) { + var name = windowname_to_id(win.name); + var elem = document.getElementById(name); + if (elem.className.indexOf('vManyToManyRawIdAdminField') != -1 && elem.value) { + elem.value += ',' + chosenId; + } else { + document.getElementById(name).value = chosenId; + } + win.close(); +} + +function showRelatedObjectPopup(triggeringLink) { + var name = triggeringLink.id.replace(/^(change|add|delete)_/, ''); + name = id_to_windowname(name); + var href = triggeringLink.href; + var win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes'); + win.focus(); + return false; +} + +function dismissAddRelatedObjectPopup(win, newId, newRepr) { + // newId and newRepr are expected to have previously been escaped by + // django.utils.html.escape. + newId = html_unescape(newId); + newRepr = html_unescape(newRepr); + var name = windowname_to_id(win.name); + var elem = document.getElementById(name); + var o; + if (elem) { + var elemName = elem.nodeName.toUpperCase(); + if (elemName == 'SELECT') { + o = new Option(newRepr, newId); + elem.options[elem.options.length] = o; + o.selected = true; + } else if (elemName == 'INPUT') { + if (elem.className.indexOf('vManyToManyRawIdAdminField') != -1 && elem.value) { + elem.value += ',' + newId; + } else { + elem.value = newId; + } + } + // Trigger a change event to update related links if required. + django.jQuery(elem).trigger('change'); + } else { + var toId = name + "_to"; + o = new Option(newRepr, newId); + SelectBox.add_to_cache(toId, o); + SelectBox.redisplay(toId); + } + win.close(); +} + +function dismissChangeRelatedObjectPopup(win, objId, newRepr, newId) { + objId = html_unescape(objId); + newRepr = html_unescape(newRepr); + var id = windowname_to_id(win.name).replace(/^edit_/, ''); + var selectsSelector = interpolate('#%s, #%s_from, #%s_to', [id, id, id]); + var selects = django.jQuery(selectsSelector); + selects.find('option').each(function() { + if (this.value == objId) { + this.innerHTML = newRepr; + this.value = newId; + } + }); + win.close(); +}; + +function dismissDeleteRelatedObjectPopup(win, objId) { + objId = html_unescape(objId); + var id = windowname_to_id(win.name).replace(/^delete_/, ''); + var selectsSelector = interpolate('#%s, #%s_from, #%s_to', [id, id, id]); + var selects = django.jQuery(selectsSelector); + selects.find('option').each(function() { + if (this.value == objId) { + django.jQuery(this).remove(); + } + }).trigger('change'); + win.close(); +}; + +// Kept for backward compatibility +showAddAnotherPopup = showRelatedObjectPopup; +dismissAddAnotherPopup = dismissAddRelatedObjectPopup; diff --git a/static/admin/js/calendar.js b/static/admin/js/calendar.js new file mode 100644 index 00000000..458eece9 --- /dev/null +++ b/static/admin/js/calendar.js @@ -0,0 +1,169 @@ +/* +calendar.js - Calendar functions by Adrian Holovaty +depends on core.js for utility functions like removeChildren or quickElement +*/ + +// CalendarNamespace -- Provides a collection of HTML calendar-related helper functions +var CalendarNamespace = { + monthsOfYear: gettext('January February March April May June July August September October November December').split(' '), + daysOfWeek: gettext('S M T W T F S').split(' '), + firstDayOfWeek: parseInt(get_format('FIRST_DAY_OF_WEEK')), + isLeapYear: function(year) { + return (((year % 4)==0) && ((year % 100)!=0) || ((year % 400)==0)); + }, + getDaysInMonth: function(month,year) { + var days; + if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12) { + days = 31; + } + else if (month==4 || month==6 || month==9 || month==11) { + days = 30; + } + else if (month==2 && CalendarNamespace.isLeapYear(year)) { + days = 29; + } + else { + days = 28; + } + return days; + }, + draw: function(month, year, div_id, callback, selected) { // month = 1-12, year = 1-9999 + var today = new Date(); + var todayDay = today.getDate(); + var todayMonth = today.getMonth()+1; + var todayYear = today.getFullYear(); + var todayClass = ''; + + // Use UTC functions here because the date field does not contain time + // and using the UTC function variants prevent the local time offset + // from altering the date, specifically the day field. For example: + // + // ``` + // var x = new Date('2013-10-02'); + // var day = x.getDate(); + // ``` + // + // The day variable above will be 1 instead of 2 in, say, US Pacific time + // zone. + var isSelectedMonth = false; + if (typeof selected != 'undefined') { + isSelectedMonth = (selected.getUTCFullYear() == year && (selected.getUTCMonth()+1) == month); + } + + month = parseInt(month); + year = parseInt(year); + var calDiv = document.getElementById(div_id); + removeChildren(calDiv); + var calTable = document.createElement('table'); + quickElement('caption', calTable, CalendarNamespace.monthsOfYear[month-1] + ' ' + year); + var tableBody = quickElement('tbody', calTable); + + // Draw days-of-week header + var tableRow = quickElement('tr', tableBody); + for (var i = 0; i < 7; i++) { + quickElement('th', tableRow, CalendarNamespace.daysOfWeek[(i + CalendarNamespace.firstDayOfWeek) % 7]); + } + + var startingPos = new Date(year, month-1, 1 - CalendarNamespace.firstDayOfWeek).getDay(); + var days = CalendarNamespace.getDaysInMonth(month, year); + + // Draw blanks before first of month + tableRow = quickElement('tr', tableBody); + for (var i = 0; i < startingPos; i++) { + var _cell = quickElement('td', tableRow, ' '); + _cell.className = "nonday"; + } + + // Draw days of month + var currentDay = 1; + for (var i = startingPos; currentDay <= days; i++) { + if (i%7 == 0 && currentDay != 1) { + tableRow = quickElement('tr', tableBody); + } + if ((currentDay==todayDay) && (month==todayMonth) && (year==todayYear)) { + todayClass='today'; + } else { + todayClass=''; + } + + // use UTC function; see above for explanation. + if (isSelectedMonth && currentDay == selected.getUTCDate()) { + if (todayClass != '') todayClass += " "; + todayClass += "selected"; + } + + var cell = quickElement('td', tableRow, '', 'class', todayClass); + + quickElement('a', cell, currentDay, 'href', 'javascript:void(' + callback + '('+year+','+month+','+currentDay+'));'); + currentDay++; + } + + // Draw blanks after end of month (optional, but makes for valid code) + while (tableRow.childNodes.length < 7) { + var _cell = quickElement('td', tableRow, ' '); + _cell.className = "nonday"; + } + + calDiv.appendChild(calTable); + } +} + +// Calendar -- A calendar instance +function Calendar(div_id, callback, selected) { + // div_id (string) is the ID of the element in which the calendar will + // be displayed + // callback (string) is the name of a JavaScript function that will be + // called with the parameters (year, month, day) when a day in the + // calendar is clicked + this.div_id = div_id; + this.callback = callback; + this.today = new Date(); + this.currentMonth = this.today.getMonth() + 1; + this.currentYear = this.today.getFullYear(); + if (typeof selected != 'undefined') { + this.selected = selected; + } +} +Calendar.prototype = { + drawCurrent: function() { + CalendarNamespace.draw(this.currentMonth, this.currentYear, this.div_id, this.callback, this.selected); + }, + drawDate: function(month, year, selected) { + this.currentMonth = month; + this.currentYear = year; + + if(selected) { + this.selected = selected; + } + + this.drawCurrent(); + }, + drawPreviousMonth: function() { + if (this.currentMonth == 1) { + this.currentMonth = 12; + this.currentYear--; + } + else { + this.currentMonth--; + } + this.drawCurrent(); + }, + drawNextMonth: function() { + if (this.currentMonth == 12) { + this.currentMonth = 1; + this.currentYear++; + } + else { + this.currentMonth++; + } + this.drawCurrent(); + }, + drawPreviousYear: function() { + this.currentYear--; + this.drawCurrent(); + }, + drawNextYear: function() { + this.currentYear++; + this.drawCurrent(); + } +} diff --git a/static/admin/js/collapse.js b/static/admin/js/collapse.js new file mode 100644 index 00000000..3b1f31bd --- /dev/null +++ b/static/admin/js/collapse.js @@ -0,0 +1,24 @@ +(function($) { + $(document).ready(function() { + // Add anchor tag for Show/Hide link + $("fieldset.collapse").each(function(i, elem) { + // Don't hide if fields in this fieldset have errors + if ($(elem).find("div.errors").length == 0) { + $(elem).addClass("collapsed").find("h2").first().append(' (' + gettext("Show") + + ')'); + } + }); + // Add toggle to anchor tag + $("fieldset.collapse a.collapse-toggle").click(function(ev) { + if ($(this).closest("fieldset").hasClass("collapsed")) { + // Show + $(this).text(gettext("Hide")).closest("fieldset").removeClass("collapsed").trigger("show.fieldset", [$(this).attr("id")]); + } else { + // Hide + $(this).text(gettext("Show")).closest("fieldset").addClass("collapsed").trigger("hide.fieldset", [$(this).attr("id")]); + } + return false; + }); + }); +})(django.jQuery); diff --git a/static/admin/js/collapse.min.js b/static/admin/js/collapse.min.js new file mode 100644 index 00000000..0a8c20ea --- /dev/null +++ b/static/admin/js/collapse.min.js @@ -0,0 +1,2 @@ +(function(a){a(document).ready(function(){a("fieldset.collapse").each(function(c,b){a(b).find("div.errors").length==0&&a(b).addClass("collapsed").find("h2").first().append(' ('+gettext("Show")+")")});a("fieldset.collapse a.collapse-toggle").click(function(){a(this).closest("fieldset").hasClass("collapsed")?a(this).text(gettext("Hide")).closest("fieldset").removeClass("collapsed").trigger("show.fieldset",[a(this).attr("id")]):a(this).text(gettext("Show")).closest("fieldset").addClass("collapsed").trigger("hide.fieldset", +[a(this).attr("id")]);return false})})})(django.jQuery); diff --git a/static/admin/js/core.js b/static/admin/js/core.js new file mode 100644 index 00000000..2c096aac --- /dev/null +++ b/static/admin/js/core.js @@ -0,0 +1,246 @@ +// Core javascript helper functions + +// basic browser identification & version +var isOpera = (navigator.userAgent.indexOf("Opera")>=0) && parseFloat(navigator.appVersion); +var isIE = ((document.all) && (!isOpera)) && parseFloat(navigator.appVersion.split("MSIE ")[1].split(";")[0]); + +// Cross-browser event handlers. +function addEvent(obj, evType, fn) { + if (obj.addEventListener) { + obj.addEventListener(evType, fn, false); + return true; + } else if (obj.attachEvent) { + var r = obj.attachEvent("on" + evType, fn); + return r; + } else { + return false; + } +} + +function removeEvent(obj, evType, fn) { + if (obj.removeEventListener) { + obj.removeEventListener(evType, fn, false); + return true; + } else if (obj.detachEvent) { + obj.detachEvent("on" + evType, fn); + return true; + } else { + return false; + } +} + +function cancelEventPropagation(e) { + if (!e) e = window.event; + e.cancelBubble = true; + if (e.stopPropagation) e.stopPropagation(); +} + +// quickElement(tagType, parentReference [, textInChildNode, attribute, attributeValue ...]); +function quickElement() { + var obj = document.createElement(arguments[0]); + if (arguments[2]) { + var textNode = document.createTextNode(arguments[2]); + obj.appendChild(textNode); + } + var len = arguments.length; + for (var i = 3; i < len; i += 2) { + obj.setAttribute(arguments[i], arguments[i+1]); + } + arguments[1].appendChild(obj); + return obj; +} + +// "a" is reference to an object +function removeChildren(a) { + while (a.hasChildNodes()) a.removeChild(a.lastChild); +} + +// ---------------------------------------------------------------------------- +// Cross-browser xmlhttp object +// from http://jibbering.com/2002/4/httprequest.html +// ---------------------------------------------------------------------------- +var xmlhttp; +/*@cc_on @*/ +/*@if (@_jscript_version >= 5) + try { + xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (E) { + xmlhttp = false; + } + } +@else + xmlhttp = false; +@end @*/ +if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { + xmlhttp = new XMLHttpRequest(); +} + +// ---------------------------------------------------------------------------- +// Find-position functions by PPK +// See http://www.quirksmode.org/js/findpos.html +// ---------------------------------------------------------------------------- +function findPosX(obj) { + var curleft = 0; + if (obj.offsetParent) { + while (obj.offsetParent) { + curleft += obj.offsetLeft - ((isOpera) ? 0 : obj.scrollLeft); + obj = obj.offsetParent; + } + // IE offsetParent does not include the top-level + if (isIE && obj.parentElement){ + curleft += obj.offsetLeft - obj.scrollLeft; + } + } else if (obj.x) { + curleft += obj.x; + } + return curleft; +} + +function findPosY(obj) { + var curtop = 0; + if (obj.offsetParent) { + while (obj.offsetParent) { + curtop += obj.offsetTop - ((isOpera) ? 0 : obj.scrollTop); + obj = obj.offsetParent; + } + // IE offsetParent does not include the top-level + if (isIE && obj.parentElement){ + curtop += obj.offsetTop - obj.scrollTop; + } + } else if (obj.y) { + curtop += obj.y; + } + return curtop; +} + +//----------------------------------------------------------------------------- +// Date object extensions +// ---------------------------------------------------------------------------- + +Date.prototype.getTwelveHours = function() { + hours = this.getHours(); + if (hours == 0) { + return 12; + } + else { + return hours <= 12 ? hours : hours-12 + } +} + +Date.prototype.getTwoDigitMonth = function() { + return (this.getMonth() < 9) ? '0' + (this.getMonth()+1) : (this.getMonth()+1); +} + +Date.prototype.getTwoDigitDate = function() { + return (this.getDate() < 10) ? '0' + this.getDate() : this.getDate(); +} + +Date.prototype.getTwoDigitTwelveHour = function() { + return (this.getTwelveHours() < 10) ? '0' + this.getTwelveHours() : this.getTwelveHours(); +} + +Date.prototype.getTwoDigitHour = function() { + return (this.getHours() < 10) ? '0' + this.getHours() : this.getHours(); +} + +Date.prototype.getTwoDigitMinute = function() { + return (this.getMinutes() < 10) ? '0' + this.getMinutes() : this.getMinutes(); +} + +Date.prototype.getTwoDigitSecond = function() { + return (this.getSeconds() < 10) ? '0' + this.getSeconds() : this.getSeconds(); +} + +Date.prototype.getHourMinute = function() { + return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute(); +} + +Date.prototype.getHourMinuteSecond = function() { + return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute() + ':' + this.getTwoDigitSecond(); +} + +Date.prototype.strftime = function(format) { + var fields = { + c: this.toString(), + d: this.getTwoDigitDate(), + H: this.getTwoDigitHour(), + I: this.getTwoDigitTwelveHour(), + m: this.getTwoDigitMonth(), + M: this.getTwoDigitMinute(), + p: (this.getHours() >= 12) ? 'PM' : 'AM', + S: this.getTwoDigitSecond(), + w: '0' + this.getDay(), + x: this.toLocaleDateString(), + X: this.toLocaleTimeString(), + y: ('' + this.getFullYear()).substr(2, 4), + Y: '' + this.getFullYear(), + '%' : '%' + }; + var result = '', i = 0; + while (i < format.length) { + if (format.charAt(i) === '%') { + result = result + fields[format.charAt(i + 1)]; + ++i; + } + else { + result = result + format.charAt(i); + } + ++i; + } + return result; +} + +// ---------------------------------------------------------------------------- +// String object extensions +// ---------------------------------------------------------------------------- +String.prototype.pad_left = function(pad_length, pad_string) { + var new_string = this; + for (var i = 0; new_string.length < pad_length; i++) { + new_string = pad_string + new_string; + } + return new_string; +} + +String.prototype.strptime = function(format) { + var split_format = format.split(/[.\-/]/); + var date = this.split(/[.\-/]/); + var i = 0; + while (i < split_format.length) { + switch (split_format[i]) { + case "%d": + var day = date[i]; + break; + case "%m": + var month = date[i] - 1; + break; + case "%Y": + var year = date[i]; + break; + case "%y": + var year = date[i]; + break; + } + ++i; + }; + return new Date(year, month, day); +} + +// ---------------------------------------------------------------------------- +// Get the computed style for and element +// ---------------------------------------------------------------------------- +function getStyle(oElm, strCssRule){ + var strValue = ""; + if(document.defaultView && document.defaultView.getComputedStyle){ + strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule); + } + else if(oElm.currentStyle){ + strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){ + return p1.toUpperCase(); + }); + strValue = oElm.currentStyle[strCssRule]; + } + return strValue; +} diff --git a/static/admin/js/inlines.js b/static/admin/js/inlines.js new file mode 100644 index 00000000..0bfcd341 --- /dev/null +++ b/static/admin/js/inlines.js @@ -0,0 +1,272 @@ +/** + * Django admin inlines + * + * Based on jQuery Formset 1.1 + * @author Stanislaus Madueke (stan DOT madueke AT gmail DOT com) + * @requires jQuery 1.2.6 or later + * + * Copyright (c) 2009, Stanislaus Madueke + * All rights reserved. + * + * Spiced up with Code from Zain Memon's GSoC project 2009 + * and modified for Django by Jannis Leidel, Travis Swicegood and Julien Phalip. + * + * Licensed under the New BSD License + * See: http://www.opensource.org/licenses/bsd-license.php + */ +(function($) { + $.fn.formset = function(opts) { + var options = $.extend({}, $.fn.formset.defaults, opts); + var $this = $(this); + var $parent = $this.parent(); + var updateElementIndex = function(el, prefix, ndx) { + var id_regex = new RegExp("(" + prefix + "-(\\d+|__prefix__))"); + var replacement = prefix + "-" + ndx; + if ($(el).prop("for")) { + $(el).prop("for", $(el).prop("for").replace(id_regex, replacement)); + } + if (el.id) { + el.id = el.id.replace(id_regex, replacement); + } + if (el.name) { + el.name = el.name.replace(id_regex, replacement); + } + }; + var totalForms = $("#id_" + options.prefix + "-TOTAL_FORMS").prop("autocomplete", "off"); + var nextIndex = parseInt(totalForms.val(), 10); + var maxForms = $("#id_" + options.prefix + "-MAX_NUM_FORMS").prop("autocomplete", "off"); + // only show the add button if we are allowed to add more items, + // note that max_num = None translates to a blank string. + var showAddButton = maxForms.val() === '' || (maxForms.val()-totalForms.val()) > 0; + $this.each(function(i) { + $(this).not("." + options.emptyCssClass).addClass(options.formCssClass); + }); + if ($this.length && showAddButton) { + var addButton; + if ($this.prop("tagName") == "TR") { + // If forms are laid out as table rows, insert the + // "add" button in a new table row: + var numCols = this.eq(-1).children().length; + $parent.append('

    "); + addButton = $parent.find("tr:last a"); + } else { + // Otherwise, insert it immediately after the last form: + $this.filter(":last").after('"); + addButton = $this.filter(":last").next().find("a"); + } + addButton.click(function(e) { + e.preventDefault(); + var totalForms = $("#id_" + options.prefix + "-TOTAL_FORMS"); + var template = $("#" + options.prefix + "-empty"); + var row = template.clone(true); + row.removeClass(options.emptyCssClass) + .addClass(options.formCssClass) + .attr("id", options.prefix + "-" + nextIndex); + if (row.is("tr")) { + // If the forms are laid out in table rows, insert + // the remove button into the last table cell: + row.children(":last").append('"); + } else if (row.is("ul") || row.is("ol")) { + // If they're laid out as an ordered/unordered list, + // insert an
  • after the last list item: + row.append('
  • ' + options.deleteText + "
  • "); + } else { + // Otherwise, just insert the remove button as the + // last child element of the form's container: + row.children(":first").append('' + options.deleteText + ""); + } + row.find("*").each(function() { + updateElementIndex(this, options.prefix, totalForms.val()); + }); + // Insert the new form when it has been fully edited + row.insertBefore($(template)); + // Update number of total forms + $(totalForms).val(parseInt(totalForms.val(), 10) + 1); + nextIndex += 1; + // Hide add button in case we've hit the max, except we want to add infinitely + if ((maxForms.val() !== '') && (maxForms.val()-totalForms.val()) <= 0) { + addButton.parent().hide(); + } + // The delete button of each row triggers a bunch of other things + row.find("a." + options.deleteCssClass).click(function(e) { + e.preventDefault(); + // Remove the parent form containing this button: + var row = $(this).parents("." + options.formCssClass); + row.remove(); + nextIndex -= 1; + // If a post-delete callback was provided, call it with the deleted form: + if (options.removed) { + options.removed(row); + } + // Update the TOTAL_FORMS form count. + var forms = $("." + options.formCssClass); + $("#id_" + options.prefix + "-TOTAL_FORMS").val(forms.length); + // Show add button again once we drop below max + if ((maxForms.val() === '') || (maxForms.val()-forms.length) > 0) { + addButton.parent().show(); + } + // Also, update names and ids for all remaining form controls + // so they remain in sequence: + for (var i=0, formCount=forms.length; i0;i.each(function(){a(this).not("."+ +b.emptyCssClass).addClass(b.formCssClass)});if(i.length&&l){var f;if(i.prop("tagName")=="TR"){i=this.eq(-1).children().length;g.append('
    ");f=g.find("tr:last a")}else{i.filter(":last").after('");f=i.filter(":last").next().find("a")}f.click(function(e){e.preventDefault();var k=a("#id_"+b.prefix+"-TOTAL_FORMS");e=a("#"+ +b.prefix+"-empty");var h=e.clone(true);h.removeClass(b.emptyCssClass).addClass(b.formCssClass).attr("id",b.prefix+"-"+d);if(h.is("tr"))h.children(":last").append('");else h.is("ul")||h.is("ol")?h.append('
  • '+b.deleteText+"
  • "):h.children(":first").append(''+b.deleteText+""); +h.find("*").each(function(){m(this,b.prefix,k.val())});h.insertBefore(a(e));a(k).val(parseInt(k.val(),10)+1);d+=1;c.val()!==""&&c.val()-k.val()<=0&&f.parent().hide();h.find("a."+b.deleteCssClass).click(function(j){j.preventDefault();j=a(this).parents("."+b.formCssClass);j.remove();d-=1;b.removed&&b.removed(j);j=a("."+b.formCssClass);a("#id_"+b.prefix+"-TOTAL_FORMS").val(j.length);if(c.val()===""||c.val()-j.length>0)f.parent().show();for(var n=0,o=j.length;n= 0 && j < len ? [ this[j] ] : [] ); + }, + + 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: deletedIds.sort, + splice: deletedIds.splice +}; + +jQuery.extend = jQuery.fn.extend = function() { + var src, copyIsArray, copy, name, options, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + + // skip the boolean and the target + target = arguments[ i ] || {}; + i++; + } + + // 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 ( i === length ) { + 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({ + // Unique for each copy of jQuery on the page + expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), + + // Assume jQuery is ready without the ready module + isReady: true, + + error: function( msg ) { + throw new Error( msg ); + }, + + noop: function() {}, + + // 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"; + }, + + isWindow: function( obj ) { + /* jshint eqeqeq: false */ + return obj != null && obj == obj.window; + }, + + isNumeric: function( obj ) { + // parseFloat NaNs numeric-cast false positives (null|true|false|"") + // ...but misinterprets leading-number strings, particularly hex literals ("0x...") + // subtraction forces infinities to NaN + // adding 1 corrects loss of precision from parseFloat (#15100) + return !jQuery.isArray( obj ) && (obj - parseFloat( obj ) + 1) >= 0; + }, + + isEmptyObject: function( obj ) { + var name; + for ( name in obj ) { + return false; + } + return true; + }, + + isPlainObject: function( obj ) { + var key; + + // 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; + } + + try { + // Not own constructor property must be Object + if ( obj.constructor && + !hasOwn.call(obj, "constructor") && + !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { + return false; + } + } catch ( e ) { + // IE8,9 Will throw exceptions on certain host objects #9897 + return false; + } + + // Support: IE<9 + // Handle iteration over inherited properties before own properties. + if ( support.ownLast ) { + for ( key in obj ) { + return hasOwn.call( obj, key ); + } + } + + // Own properties are enumerated firstly, so to speed up, + // if last one is own, then all properties are own. + for ( key in obj ) {} + + return key === undefined || hasOwn.call( obj, key ); + }, + + type: function( obj ) { + if ( obj == null ) { + return obj + ""; + } + return typeof obj === "object" || typeof obj === "function" ? + class2type[ toString.call(obj) ] || "object" : + typeof obj; + }, + + // 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 && jQuery.trim( 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 ); + } + }, + + // Convert dashed to camelCase; used by the css and data modules + // Microsoft forgot to hump their vendor prefix (#9572) + camelCase: function( string ) { + return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); + }, + + nodeName: function( elem, name ) { + return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); + }, + + // args is for internal usage only + each: function( obj, callback, args ) { + var value, + i = 0, + length = obj.length, + isArray = isArraylike( obj ); + + if ( args ) { + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback.apply( obj[ i ], args ); + + if ( value === false ) { + break; + } + } + } else { + for ( i in obj ) { + value = callback.apply( obj[ i ], args ); + + if ( value === false ) { + break; + } + } + } + + // A special, fast, case for the most common use of each + } else { + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback.call( obj[ i ], i, obj[ i ] ); + + if ( value === false ) { + break; + } + } + } else { + for ( i in obj ) { + value = callback.call( obj[ i ], i, obj[ i ] ); + + if ( value === false ) { + break; + } + } + } + } + + return obj; + }, + + // Support: Android<4.1, IE<9 + trim: function( text ) { + return text == null ? + "" : + ( text + "" ).replace( rtrim, "" ); + }, + + // results is for internal usage only + makeArray: function( arr, results ) { + var ret = results || []; + + if ( arr != null ) { + if ( isArraylike( Object(arr) ) ) { + jQuery.merge( ret, + typeof arr === "string" ? + [ arr ] : arr + ); + } else { + push.call( ret, arr ); + } + } + + return ret; + }, + + inArray: function( elem, arr, i ) { + var len; + + if ( arr ) { + if ( indexOf ) { + return indexOf.call( arr, elem, i ); + } + + len = arr.length; + i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; + + for ( ; i < len; i++ ) { + // Skip accessing in sparse arrays + if ( i in arr && arr[ i ] === elem ) { + return i; + } + } + } + + return -1; + }, + + merge: function( first, second ) { + var len = +second.length, + j = 0, + i = first.length; + + while ( j < len ) { + first[ i++ ] = second[ j++ ]; + } + + // Support: IE<9 + // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists) + if ( len !== len ) { + while ( second[j] !== undefined ) { + first[ i++ ] = second[ j++ ]; + } + } + + first.length = i; + + return first; + }, + + grep: function( elems, callback, invert ) { + var callbackInverse, + matches = [], + i = 0, + length = elems.length, + callbackExpect = !invert; + + // Go through the array, only saving the items + // that pass the validator function + for ( ; i < length; i++ ) { + callbackInverse = !callback( elems[ i ], i ); + if ( callbackInverse !== callbackExpect ) { + matches.push( elems[ i ] ); + } + } + + return matches; + }, + + // arg is for internal usage only + map: function( elems, callback, arg ) { + var value, + i = 0, + length = elems.length, + isArray = isArraylike( elems ), + ret = []; + + // Go through the array, translating each of the items to their new values + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret.push( value ); + } + } + + // Go through every key on the object, + } else { + for ( i in elems ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret.push( value ); + } + } + } + + // Flatten any nested arrays + return 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 ) { + var args, proxy, tmp; + + if ( typeof context === "string" ) { + 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 + args = slice.call( arguments, 2 ); + proxy = function() { + return fn.apply( context || this, 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 || jQuery.guid++; + + return proxy; + }, + + now: function() { + return +( new Date() ); + }, + + // jQuery.support is not used in Core but other projects attach their + // properties to it so it needs to exist. + support: support +}); + +// Populate the class2type map +jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); +}); + +function isArraylike( obj ) { + var length = obj.length, + type = jQuery.type( obj ); + + if ( type === "function" || jQuery.isWindow( obj ) ) { + return false; + } + + if ( obj.nodeType === 1 && length ) { + return true; + } + + return type === "array" || length === 0 || + typeof length === "number" && length > 0 && ( length - 1 ) in obj; +} +var Sizzle = +/*! + * Sizzle CSS Selector Engine v2.2.0-pre + * http://sizzlejs.com/ + * + * Copyright 2008, 2014 jQuery Foundation, Inc. and other contributors + * Released under the MIT license + * http://jquery.org/license + * + * Date: 2014-12-16 + */ +(function( window ) { + +var i, + support, + Expr, + getText, + isXML, + tokenize, + compile, + select, + outermostContext, + sortInput, + hasDuplicate, + + // Local document vars + setDocument, + document, + docElem, + documentIsHTML, + rbuggyQSA, + rbuggyMatches, + matches, + contains, + + // Instance-specific data + expando = "sizzle" + 1 * new Date(), + preferredDoc = window.document, + dirruns = 0, + done = 0, + classCache = createCache(), + tokenCache = createCache(), + compilerCache = createCache(), + sortOrder = function( a, b ) { + if ( a === b ) { + hasDuplicate = true; + } + return 0; + }, + + // General-purpose constants + MAX_NEGATIVE = 1 << 31, + + // Instance methods + hasOwn = ({}).hasOwnProperty, + arr = [], + pop = arr.pop, + push_native = arr.push, + push = arr.push, + slice = arr.slice, + // Use a stripped-down indexOf as it's faster than native + // http://jsperf.com/thor-indexof-vs-for/5 + indexOf = function( list, elem ) { + var i = 0, + len = list.length; + for ( ; i < len; i++ ) { + if ( list[i] === elem ) { + return i; + } + } + return -1; + }, + + booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", + + // Regular expressions + + // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace + whitespace = "[\\x20\\t\\r\\n\\f]", + // http://www.w3.org/TR/css3-syntax/#characters + characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", + + // Loosely modeled on CSS identifier characters + // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors + // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier + identifier = characterEncoding.replace( "w", "w#" ), + + // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors + attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace + + // Operator (capture 2) + "*([*^$|!~]?=)" + whitespace + + // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" + "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + + "*\\]", + + pseudos = ":(" + characterEncoding + ")(?:\\((" + + // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: + // 1. quoted (capture 3; capture 4 or capture 5) + "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + + // 2. simple (capture 6) + "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + + // 3. anything else (capture 2) + ".*" + + ")\\)|)", + + // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter + rwhitespace = new RegExp( whitespace + "+", "g" ), + rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), + + rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), + rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), + + rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ), + + rpseudo = new RegExp( pseudos ), + ridentifier = new RegExp( "^" + identifier + "$" ), + + matchExpr = { + "ID": new RegExp( "^#(" + characterEncoding + ")" ), + "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ), + "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ), + "ATTR": new RegExp( "^" + attributes ), + "PSEUDO": new RegExp( "^" + pseudos ), + "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), + "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), + // For use in libraries implementing .is() + // We use this for POS matching in `select` + "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + + whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) + }, + + rinputs = /^(?:input|select|textarea|button)$/i, + rheader = /^h\d$/i, + + rnative = /^[^{]+\{\s*\[native \w/, + + // Easily-parseable/retrievable ID or TAG or CLASS selectors + rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, + + rsibling = /[+~]/, + rescape = /'|\\/g, + + // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters + runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), + funescape = function( _, escaped, escapedWhitespace ) { + var high = "0x" + escaped - 0x10000; + // NaN means non-codepoint + // Support: Firefox<24 + // Workaround erroneous numeric interpretation of +"0x" + return high !== high || escapedWhitespace ? + escaped : + high < 0 ? + // BMP codepoint + String.fromCharCode( high + 0x10000 ) : + // Supplemental Plane codepoint (surrogate pair) + String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); + }, + + // Used for iframes + // See setDocument() + // Removing the function wrapper causes a "Permission Denied" + // error in IE + unloadHandler = function() { + setDocument(); + }; + +// Optimize for push.apply( _, NodeList ) +try { + push.apply( + (arr = slice.call( preferredDoc.childNodes )), + preferredDoc.childNodes + ); + // Support: Android<4.0 + // Detect silently failing push.apply + arr[ preferredDoc.childNodes.length ].nodeType; +} catch ( e ) { + push = { apply: arr.length ? + + // Leverage slice if possible + function( target, els ) { + push_native.apply( target, slice.call(els) ); + } : + + // Support: IE<9 + // Otherwise append directly + function( target, els ) { + var j = target.length, + i = 0; + // Can't trust NodeList.length + while ( (target[j++] = els[i++]) ) {} + target.length = j - 1; + } + }; +} + +function Sizzle( selector, context, results, seed ) { + var match, elem, m, nodeType, + // QSA vars + i, groups, old, nid, newContext, newSelector; + + if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { + setDocument( context ); + } + + context = context || document; + results = results || []; + nodeType = context.nodeType; + + if ( typeof selector !== "string" || !selector || + nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { + + return results; + } + + if ( !seed && documentIsHTML ) { + + // Try to shortcut find operations when possible (e.g., not under DocumentFragment) + if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) { + // Speed-up: Sizzle("#ID") + if ( (m = match[1]) ) { + if ( nodeType === 9 ) { + elem = context.getElementById( m ); + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document (jQuery #6963) + if ( elem && elem.parentNode ) { + // Handle the case where IE, Opera, and Webkit return items + // by name instead of ID + if ( elem.id === m ) { + results.push( elem ); + return results; + } + } else { + return results; + } + } else { + // Context is not a document + if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) && + contains( context, elem ) && elem.id === m ) { + results.push( elem ); + return results; + } + } + + // Speed-up: Sizzle("TAG") + } else if ( match[2] ) { + push.apply( results, context.getElementsByTagName( selector ) ); + return results; + + // Speed-up: Sizzle(".CLASS") + } else if ( (m = match[3]) && support.getElementsByClassName ) { + push.apply( results, context.getElementsByClassName( m ) ); + return results; + } + } + + // QSA path + if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { + nid = old = expando; + newContext = context; + newSelector = nodeType !== 1 && selector; + + // 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 + if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { + groups = tokenize( selector ); + + if ( (old = context.getAttribute("id")) ) { + nid = old.replace( rescape, "\\$&" ); + } else { + context.setAttribute( "id", nid ); + } + nid = "[id='" + nid + "'] "; + + i = groups.length; + while ( i-- ) { + groups[i] = nid + toSelector( groups[i] ); + } + newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context; + newSelector = groups.join(","); + } + + if ( newSelector ) { + try { + push.apply( results, + newContext.querySelectorAll( newSelector ) + ); + return results; + } catch(qsaError) { + } finally { + if ( !old ) { + context.removeAttribute("id"); + } + } + } + } + } + + // All others + return select( selector.replace( rtrim, "$1" ), context, results, seed ); +} + +/** + * Create key-value caches of limited size + * @returns {Function(string, Object)} Returns the Object data after storing it on itself with + * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) + * deleting the oldest entry + */ +function createCache() { + var keys = []; + + function cache( key, value ) { + // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) + if ( keys.push( key + " " ) > Expr.cacheLength ) { + // Only keep the most recent entries + delete cache[ keys.shift() ]; + } + return (cache[ key + " " ] = value); + } + return cache; +} + +/** + * Mark a function for special use by Sizzle + * @param {Function} fn The function to mark + */ +function markFunction( fn ) { + fn[ expando ] = true; + return fn; +} + +/** + * Support testing using an element + * @param {Function} fn Passed the created div and expects a boolean result + */ +function assert( fn ) { + var div = document.createElement("div"); + + try { + return !!fn( div ); + } catch (e) { + return false; + } finally { + // Remove from its parent by default + if ( div.parentNode ) { + div.parentNode.removeChild( div ); + } + // release memory in IE + div = null; + } +} + +/** + * Adds the same handler for all of the specified attrs + * @param {String} attrs Pipe-separated list of attributes + * @param {Function} handler The method that will be applied + */ +function addHandle( attrs, handler ) { + var arr = attrs.split("|"), + i = attrs.length; + + while ( i-- ) { + Expr.attrHandle[ arr[i] ] = handler; + } +} + +/** + * Checks document order of two siblings + * @param {Element} a + * @param {Element} b + * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b + */ +function siblingCheck( a, b ) { + var cur = b && a, + diff = cur && a.nodeType === 1 && b.nodeType === 1 && + ( ~b.sourceIndex || MAX_NEGATIVE ) - + ( ~a.sourceIndex || MAX_NEGATIVE ); + + // Use IE sourceIndex if available on both nodes + if ( diff ) { + return diff; + } + + // Check if b follows a + if ( cur ) { + while ( (cur = cur.nextSibling) ) { + if ( cur === b ) { + return -1; + } + } + } + + return a ? 1 : -1; +} + +/** + * Returns a function to use in pseudos for input types + * @param {String} type + */ +function createInputPseudo( type ) { + return function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === type; + }; +} + +/** + * Returns a function to use in pseudos for buttons + * @param {String} type + */ +function createButtonPseudo( type ) { + return function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && elem.type === type; + }; +} + +/** + * Returns a function to use in pseudos for positionals + * @param {Function} fn + */ +function createPositionalPseudo( fn ) { + return markFunction(function( argument ) { + argument = +argument; + return markFunction(function( seed, matches ) { + var j, + matchIndexes = fn( [], seed.length, argument ), + i = matchIndexes.length; + + // Match elements found at the specified indexes + while ( i-- ) { + if ( seed[ (j = matchIndexes[i]) ] ) { + seed[j] = !(matches[j] = seed[j]); + } + } + }); + }); +} + +/** + * Checks a node for validity as a Sizzle context + * @param {Element|Object=} context + * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value + */ +function testContext( context ) { + return context && typeof context.getElementsByTagName !== "undefined" && context; +} + +// Expose support vars for convenience +support = Sizzle.support = {}; + +/** + * Detects XML nodes + * @param {Element|Object} elem An element or a document + * @returns {Boolean} True iff elem is a non-HTML XML node + */ +isXML = 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).documentElement; + return documentElement ? documentElement.nodeName !== "HTML" : false; +}; + +/** + * Sets document-related variables once based on the current document + * @param {Element|Object} [doc] An element or document object to use to set the document + * @returns {Object} Returns the current document + */ +setDocument = Sizzle.setDocument = function( node ) { + var hasCompare, parent, + doc = node ? node.ownerDocument || node : preferredDoc; + + // If no document and documentElement is available, return + if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { + return document; + } + + // Set our document + document = doc; + docElem = doc.documentElement; + parent = doc.defaultView; + + // Support: IE>8 + // If iframe document is assigned to "document" variable and if iframe has been reloaded, + // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936 + // IE6-8 do not support the defaultView property so parent will be undefined + if ( parent && parent !== parent.top ) { + // IE11 does not have attachEvent, so all must suffer + if ( parent.addEventListener ) { + parent.addEventListener( "unload", unloadHandler, false ); + } else if ( parent.attachEvent ) { + parent.attachEvent( "onunload", unloadHandler ); + } + } + + /* Support tests + ---------------------------------------------------------------------- */ + documentIsHTML = !isXML( doc ); + + /* Attributes + ---------------------------------------------------------------------- */ + + // Support: IE<8 + // Verify that getAttribute really returns attributes and not properties + // (excepting IE8 booleans) + support.attributes = assert(function( div ) { + div.className = "i"; + return !div.getAttribute("className"); + }); + + /* getElement(s)By* + ---------------------------------------------------------------------- */ + + // Check if getElementsByTagName("*") returns only elements + support.getElementsByTagName = assert(function( div ) { + div.appendChild( doc.createComment("") ); + return !div.getElementsByTagName("*").length; + }); + + // Support: IE<9 + support.getElementsByClassName = rnative.test( doc.getElementsByClassName ); + + // Support: IE<10 + // Check if getElementById returns elements by name + // The broken getElementById methods don't pick up programatically-set names, + // so use a roundabout getElementsByName test + support.getById = assert(function( div ) { + docElem.appendChild( div ).id = expando; + return !doc.getElementsByName || !doc.getElementsByName( expando ).length; + }); + + // ID find and filter + if ( support.getById ) { + Expr.find["ID"] = function( id, context ) { + if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { + var m = context.getElementById( id ); + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + return m && m.parentNode ? [ m ] : []; + } + }; + Expr.filter["ID"] = function( id ) { + var attrId = id.replace( runescape, funescape ); + return function( elem ) { + return elem.getAttribute("id") === attrId; + }; + }; + } else { + // Support: IE6/7 + // getElementById is not reliable as a find shortcut + delete Expr.find["ID"]; + + Expr.filter["ID"] = function( id ) { + var attrId = id.replace( runescape, funescape ); + return function( elem ) { + var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); + return node && node.value === attrId; + }; + }; + } + + // Tag + Expr.find["TAG"] = support.getElementsByTagName ? + function( tag, context ) { + if ( typeof context.getElementsByTagName !== "undefined" ) { + return context.getElementsByTagName( tag ); + + // DocumentFragment nodes don't have gEBTN + } else if ( support.qsa ) { + return context.querySelectorAll( tag ); + } + } : + + function( tag, context ) { + var elem, + tmp = [], + i = 0, + // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too + results = context.getElementsByTagName( tag ); + + // Filter out possible comments + if ( tag === "*" ) { + while ( (elem = results[i++]) ) { + if ( elem.nodeType === 1 ) { + tmp.push( elem ); + } + } + + return tmp; + } + return results; + }; + + // Class + Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { + if ( documentIsHTML ) { + return context.getElementsByClassName( className ); + } + }; + + /* QSA/matchesSelector + ---------------------------------------------------------------------- */ + + // QSA and matchesSelector support + + // matchesSelector(:active) reports false when true (IE9/Opera 11.5) + rbuggyMatches = []; + + // qSa(:focus) reports false when true (Chrome 21) + // We allow this because of a bug in IE8/9 that throws an error + // whenever `document.activeElement` is accessed on an iframe + // So, we allow :focus to pass through QSA all the time to avoid the IE error + // See http://bugs.jquery.com/ticket/13378 + rbuggyQSA = []; + + if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) { + // Build QSA regex + // Regex strategy adopted from Diego Perini + assert(function( div ) { + // Select is set to empty string on purpose + // This is to test IE's treatment of not explicitly + // setting a boolean content attribute, + // since its presence should be enough + // http://bugs.jquery.com/ticket/12359 + docElem.appendChild( div ).innerHTML = "" + + ""; + + // Support: IE8, Opera 11-12.16 + // Nothing should be selected when empty strings follow ^= or $= or *= + // The test attribute must be unknown in Opera but "safe" for WinRT + // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section + if ( div.querySelectorAll("[msallowcapture^='']").length ) { + rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); + } + + // Support: IE8 + // Boolean attributes and "value" are not treated correctly + if ( !div.querySelectorAll("[selected]").length ) { + rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); + } + + // Support: Chrome<29, Android<4.2+, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.7+ + if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) { + rbuggyQSA.push("~="); + } + + // Webkit/Opera - :checked should return selected option elements + // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked + // IE8 throws error here and will not see later tests + if ( !div.querySelectorAll(":checked").length ) { + rbuggyQSA.push(":checked"); + } + + // Support: Safari 8+, iOS 8+ + // https://bugs.webkit.org/show_bug.cgi?id=136851 + // In-page `selector#id sibing-combinator selector` fails + if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) { + rbuggyQSA.push(".#.+[+~]"); + } + }); + + assert(function( div ) { + // Support: Windows 8 Native Apps + // The type and name attributes are restricted during .innerHTML assignment + var input = doc.createElement("input"); + input.setAttribute( "type", "hidden" ); + div.appendChild( input ).setAttribute( "name", "D" ); + + // Support: IE8 + // Enforce case-sensitivity of name attribute + if ( div.querySelectorAll("[name=d]").length ) { + rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); + } + + // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) + // IE8 throws error here and will not see later tests + if ( !div.querySelectorAll(":enabled").length ) { + rbuggyQSA.push( ":enabled", ":disabled" ); + } + + // Opera 10-11 does not throw on post-comma invalid pseudos + div.querySelectorAll("*,:x"); + rbuggyQSA.push(",.*:"); + }); + } + + if ( (support.matchesSelector = rnative.test( (matches = docElem.matches || + docElem.webkitMatchesSelector || + docElem.mozMatchesSelector || + docElem.oMatchesSelector || + docElem.msMatchesSelector) )) ) { + + assert(function( div ) { + // Check to see if it's possible to do matchesSelector + // on a disconnected node (IE 9) + support.disconnectedMatch = matches.call( div, "div" ); + + // This should fail with an exception + // Gecko does not error, returns false instead + matches.call( div, "[s!='']:x" ); + rbuggyMatches.push( "!=", pseudos ); + }); + } + + rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); + rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); + + /* Contains + ---------------------------------------------------------------------- */ + hasCompare = rnative.test( docElem.compareDocumentPosition ); + + // Element contains another + // Purposefully does not implement inclusive descendent + // As in, an element does not contain itself + contains = hasCompare || rnative.test( docElem.contains ) ? + function( a, b ) { + var adown = a.nodeType === 9 ? a.documentElement : a, + bup = b && b.parentNode; + return a === bup || !!( bup && bup.nodeType === 1 && ( + adown.contains ? + adown.contains( bup ) : + a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 + )); + } : + function( a, b ) { + if ( b ) { + while ( (b = b.parentNode) ) { + if ( b === a ) { + return true; + } + } + } + return false; + }; + + /* Sorting + ---------------------------------------------------------------------- */ + + // Document order sorting + sortOrder = hasCompare ? + function( a, b ) { + + // Flag for duplicate removal + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + // Sort on method existence if only one input has compareDocumentPosition + var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; + if ( compare ) { + return compare; + } + + // Calculate position if both inputs belong to the same document + compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? + a.compareDocumentPosition( b ) : + + // Otherwise we know they are disconnected + 1; + + // Disconnected nodes + if ( compare & 1 || + (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { + + // Choose the first element that is related to our preferred document + if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { + return -1; + } + if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { + return 1; + } + + // Maintain original order + return sortInput ? + ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : + 0; + } + + return compare & 4 ? -1 : 1; + } : + function( a, b ) { + // Exit early if the nodes are identical + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + var cur, + i = 0, + aup = a.parentNode, + bup = b.parentNode, + ap = [ a ], + bp = [ b ]; + + // Parentless nodes are either documents or disconnected + if ( !aup || !bup ) { + return a === doc ? -1 : + b === doc ? 1 : + aup ? -1 : + bup ? 1 : + sortInput ? + ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : + 0; + + // If the nodes are siblings, we can do a quick check + } else if ( aup === bup ) { + return siblingCheck( a, b ); + } + + // Otherwise we need full lists of their ancestors for comparison + cur = a; + while ( (cur = cur.parentNode) ) { + ap.unshift( cur ); + } + cur = b; + while ( (cur = cur.parentNode) ) { + bp.unshift( cur ); + } + + // Walk down the tree looking for a discrepancy + while ( ap[i] === bp[i] ) { + i++; + } + + return i ? + // Do a sibling check if the nodes have a common ancestor + siblingCheck( ap[i], bp[i] ) : + + // Otherwise nodes in our document sort first + ap[i] === preferredDoc ? -1 : + bp[i] === preferredDoc ? 1 : + 0; + }; + + return doc; +}; + +Sizzle.matches = function( expr, elements ) { + return Sizzle( expr, null, null, elements ); +}; + +Sizzle.matchesSelector = function( elem, expr ) { + // Set document vars if needed + if ( ( elem.ownerDocument || elem ) !== document ) { + setDocument( elem ); + } + + // Make sure that attribute selectors are quoted + expr = expr.replace( rattributeQuotes, "='$1']" ); + + if ( support.matchesSelector && documentIsHTML && + ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && + ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { + + try { + var ret = matches.call( elem, expr ); + + // IE 9's matchesSelector returns false on disconnected nodes + if ( ret || support.disconnectedMatch || + // As well, disconnected nodes are said to be in a document + // fragment in IE 9 + elem.document && elem.document.nodeType !== 11 ) { + return ret; + } + } catch (e) {} + } + + return Sizzle( expr, document, null, [ elem ] ).length > 0; +}; + +Sizzle.contains = function( context, elem ) { + // Set document vars if needed + if ( ( context.ownerDocument || context ) !== document ) { + setDocument( context ); + } + return contains( context, elem ); +}; + +Sizzle.attr = function( elem, name ) { + // Set document vars if needed + if ( ( elem.ownerDocument || elem ) !== document ) { + setDocument( elem ); + } + + var fn = Expr.attrHandle[ name.toLowerCase() ], + // Don't get fooled by Object.prototype properties (jQuery #13807) + val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? + fn( elem, name, !documentIsHTML ) : + undefined; + + return val !== undefined ? + val : + support.attributes || !documentIsHTML ? + elem.getAttribute( name ) : + (val = elem.getAttributeNode(name)) && val.specified ? + val.value : + null; +}; + +Sizzle.error = function( msg ) { + throw new Error( "Syntax error, unrecognized expression: " + msg ); +}; + +/** + * Document sorting and removing duplicates + * @param {ArrayLike} results + */ +Sizzle.uniqueSort = function( results ) { + var elem, + duplicates = [], + j = 0, + i = 0; + + // Unless we *know* we can detect duplicates, assume their presence + hasDuplicate = !support.detectDuplicates; + sortInput = !support.sortStable && results.slice( 0 ); + results.sort( sortOrder ); + + if ( hasDuplicate ) { + while ( (elem = results[i++]) ) { + if ( elem === results[ i ] ) { + j = duplicates.push( i ); + } + } + while ( j-- ) { + results.splice( duplicates[ j ], 1 ); + } + } + + // Clear input after sorting to release objects + // See https://github.com/jquery/sizzle/pull/225 + sortInput = null; + + return results; +}; + +/** + * Utility function for retrieving the text value of an array of DOM nodes + * @param {Array|Element} elem + */ +getText = Sizzle.getText = function( elem ) { + var node, + ret = "", + i = 0, + nodeType = elem.nodeType; + + if ( !nodeType ) { + // If no nodeType, this is expected to be an array + while ( (node = elem[i++]) ) { + // Do not traverse comment nodes + ret += getText( node ); + } + } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { + // Use textContent for elements + // innerText usage removed for consistency of new lines (jQuery #11153) + if ( typeof elem.textContent === "string" ) { + return elem.textContent; + } else { + // Traverse its children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { + ret += getText( elem ); + } + } + } else if ( nodeType === 3 || nodeType === 4 ) { + return elem.nodeValue; + } + // Do not include comment or processing instruction nodes + + return ret; +}; + +Expr = Sizzle.selectors = { + + // Can be adjusted by the user + cacheLength: 50, + + createPseudo: markFunction, + + match: matchExpr, + + attrHandle: {}, + + find: {}, + + relative: { + ">": { dir: "parentNode", first: true }, + " ": { dir: "parentNode" }, + "+": { dir: "previousSibling", first: true }, + "~": { dir: "previousSibling" } + }, + + preFilter: { + "ATTR": function( match ) { + match[1] = match[1].replace( runescape, funescape ); + + // Move the given value to match[3] whether quoted or unquoted + match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape ); + + if ( match[2] === "~=" ) { + match[3] = " " + match[3] + " "; + } + + return match.slice( 0, 4 ); + }, + + "CHILD": function( match ) { + /* matches from matchExpr["CHILD"] + 1 type (only|nth|...) + 2 what (child|of-type) + 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) + 4 xn-component of xn+y argument ([+-]?\d*n|) + 5 sign of xn-component + 6 x of xn-component + 7 sign of y-component + 8 y of y-component + */ + match[1] = match[1].toLowerCase(); + + if ( match[1].slice( 0, 3 ) === "nth" ) { + // nth-* requires argument + if ( !match[3] ) { + Sizzle.error( match[0] ); + } + + // numeric x and y parameters for Expr.filter.CHILD + // remember that false/true cast respectively to 0/1 + match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); + match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); + + // other types prohibit arguments + } else if ( match[3] ) { + Sizzle.error( match[0] ); + } + + return match; + }, + + "PSEUDO": function( match ) { + var excess, + unquoted = !match[6] && match[2]; + + if ( matchExpr["CHILD"].test( match[0] ) ) { + return null; + } + + // Accept quoted arguments as-is + if ( match[3] ) { + match[2] = match[4] || match[5] || ""; + + // Strip excess characters from unquoted arguments + } else if ( unquoted && rpseudo.test( unquoted ) && + // Get excess from tokenize (recursively) + (excess = tokenize( unquoted, true )) && + // advance to the next closing parenthesis + (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { + + // excess is a negative index + match[0] = match[0].slice( 0, excess ); + match[2] = unquoted.slice( 0, excess ); + } + + // Return only captures needed by the pseudo filter method (type and argument) + return match.slice( 0, 3 ); + } + }, + + filter: { + + "TAG": function( nodeNameSelector ) { + var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); + return nodeNameSelector === "*" ? + function() { return true; } : + function( elem ) { + return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; + }; + }, + + "CLASS": function( className ) { + var pattern = classCache[ className + " " ]; + + return pattern || + (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && + classCache( className, function( elem ) { + return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" ); + }); + }, + + "ATTR": function( name, operator, check ) { + return function( elem ) { + var result = Sizzle.attr( elem, name ); + + if ( result == null ) { + return operator === "!="; + } + if ( !operator ) { + return true; + } + + result += ""; + + return operator === "=" ? result === check : + operator === "!=" ? result !== check : + operator === "^=" ? check && result.indexOf( check ) === 0 : + operator === "*=" ? check && result.indexOf( check ) > -1 : + operator === "$=" ? check && result.slice( -check.length ) === check : + operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : + operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : + false; + }; + }, + + "CHILD": function( type, what, argument, first, last ) { + var simple = type.slice( 0, 3 ) !== "nth", + forward = type.slice( -4 ) !== "last", + ofType = what === "of-type"; + + return first === 1 && last === 0 ? + + // Shortcut for :nth-*(n) + function( elem ) { + return !!elem.parentNode; + } : + + function( elem, context, xml ) { + var cache, outerCache, node, diff, nodeIndex, start, + dir = simple !== forward ? "nextSibling" : "previousSibling", + parent = elem.parentNode, + name = ofType && elem.nodeName.toLowerCase(), + useCache = !xml && !ofType; + + if ( parent ) { + + // :(first|last|only)-(child|of-type) + if ( simple ) { + while ( dir ) { + node = elem; + while ( (node = node[ dir ]) ) { + if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) { + return false; + } + } + // Reverse direction for :only-* (if we haven't yet done so) + start = dir = type === "only" && !start && "nextSibling"; + } + return true; + } + + start = [ forward ? parent.firstChild : parent.lastChild ]; + + // non-xml :nth-child(...) stores cache data on `parent` + if ( forward && useCache ) { + // Seek `elem` from a previously-cached index + outerCache = parent[ expando ] || (parent[ expando ] = {}); + cache = outerCache[ type ] || []; + nodeIndex = cache[0] === dirruns && cache[1]; + diff = cache[0] === dirruns && cache[2]; + node = nodeIndex && parent.childNodes[ nodeIndex ]; + + while ( (node = ++nodeIndex && node && node[ dir ] || + + // Fallback to seeking `elem` from the start + (diff = nodeIndex = 0) || start.pop()) ) { + + // When found, cache indexes on `parent` and break + if ( node.nodeType === 1 && ++diff && node === elem ) { + outerCache[ type ] = [ dirruns, nodeIndex, diff ]; + break; + } + } + + // Use previously-cached element index if available + } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) { + diff = cache[1]; + + // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...) + } else { + // Use the same loop as above to seek `elem` from the start + while ( (node = ++nodeIndex && node && node[ dir ] || + (diff = nodeIndex = 0) || start.pop()) ) { + + if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) { + // Cache the index of each encountered element + if ( useCache ) { + (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ]; + } + + if ( node === elem ) { + break; + } + } + } + } + + // Incorporate the offset, then check against cycle size + diff -= last; + return diff === first || ( diff % first === 0 && diff / first >= 0 ); + } + }; + }, + + "PSEUDO": function( pseudo, argument ) { + // pseudo-class names are case-insensitive + // http://www.w3.org/TR/selectors/#pseudo-classes + // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters + // Remember that setFilters inherits from pseudos + var args, + fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || + Sizzle.error( "unsupported pseudo: " + pseudo ); + + // The user may use createPseudo to indicate that + // arguments are needed to create the filter function + // just as Sizzle does + if ( fn[ expando ] ) { + return fn( argument ); + } + + // But maintain support for old signatures + if ( fn.length > 1 ) { + args = [ pseudo, pseudo, "", argument ]; + return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? + markFunction(function( seed, matches ) { + var idx, + matched = fn( seed, argument ), + i = matched.length; + while ( i-- ) { + idx = indexOf( seed, matched[i] ); + seed[ idx ] = !( matches[ idx ] = matched[i] ); + } + }) : + function( elem ) { + return fn( elem, 0, args ); + }; + } + + return fn; + } + }, + + pseudos: { + // Potentially complex pseudos + "not": markFunction(function( selector ) { + // Trim the selector passed to compile + // to avoid treating leading and trailing + // spaces as combinators + var input = [], + results = [], + matcher = compile( selector.replace( rtrim, "$1" ) ); + + return matcher[ expando ] ? + markFunction(function( seed, matches, context, xml ) { + var elem, + unmatched = matcher( seed, null, xml, [] ), + i = seed.length; + + // Match elements unmatched by `matcher` + while ( i-- ) { + if ( (elem = unmatched[i]) ) { + seed[i] = !(matches[i] = elem); + } + } + }) : + function( elem, context, xml ) { + input[0] = elem; + matcher( input, null, xml, results ); + // Don't keep the element (issue #299) + input[0] = null; + return !results.pop(); + }; + }), + + "has": markFunction(function( selector ) { + return function( elem ) { + return Sizzle( selector, elem ).length > 0; + }; + }), + + "contains": markFunction(function( text ) { + text = text.replace( runescape, funescape ); + return function( elem ) { + return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; + }; + }), + + // "Whether an element is represented by a :lang() selector + // is based solely on the element's language value + // being equal to the identifier C, + // or beginning with the identifier C immediately followed by "-". + // The matching of C against the element's language value is performed case-insensitively. + // The identifier C does not have to be a valid language name." + // http://www.w3.org/TR/selectors/#lang-pseudo + "lang": markFunction( function( lang ) { + // lang value must be a valid identifier + if ( !ridentifier.test(lang || "") ) { + Sizzle.error( "unsupported lang: " + lang ); + } + lang = lang.replace( runescape, funescape ).toLowerCase(); + return function( elem ) { + var elemLang; + do { + if ( (elemLang = documentIsHTML ? + elem.lang : + elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { + + elemLang = elemLang.toLowerCase(); + return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; + } + } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); + return false; + }; + }), + + // Miscellaneous + "target": function( elem ) { + var hash = window.location && window.location.hash; + return hash && hash.slice( 1 ) === elem.id; + }, + + "root": function( elem ) { + return elem === docElem; + }, + + "focus": function( elem ) { + return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); + }, + + // Boolean properties + "enabled": function( elem ) { + return elem.disabled === false; + }, + + "disabled": function( elem ) { + return elem.disabled === true; + }, + + "checked": function( elem ) { + // In CSS3, :checked should return both checked and selected elements + // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked + var nodeName = elem.nodeName.toLowerCase(); + return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); + }, + + "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; + }, + + // Contents + "empty": function( elem ) { + // http://www.w3.org/TR/selectors/#empty-pseudo + // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), + // but not by others (comment: 8; processing instruction: 7; etc.) + // nodeType < 6 works because attributes (2) do not appear as children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { + if ( elem.nodeType < 6 ) { + return false; + } + } + return true; + }, + + "parent": function( elem ) { + return !Expr.pseudos["empty"]( elem ); + }, + + // Element/input types + "header": function( elem ) { + return rheader.test( elem.nodeName ); + }, + + "input": function( elem ) { + return rinputs.test( elem.nodeName ); + }, + + "button": function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === "button" || name === "button"; + }, + + "text": function( elem ) { + var attr; + return elem.nodeName.toLowerCase() === "input" && + elem.type === "text" && + + // Support: IE<8 + // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" + ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); + }, + + // Position-in-collection + "first": createPositionalPseudo(function() { + return [ 0 ]; + }), + + "last": createPositionalPseudo(function( matchIndexes, length ) { + return [ length - 1 ]; + }), + + "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { + return [ argument < 0 ? argument + length : argument ]; + }), + + "even": createPositionalPseudo(function( matchIndexes, length ) { + var i = 0; + for ( ; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), + + "odd": createPositionalPseudo(function( matchIndexes, length ) { + var i = 1; + for ( ; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), + + "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { + var i = argument < 0 ? argument + length : argument; + for ( ; --i >= 0; ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), + + "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { + var i = argument < 0 ? argument + length : argument; + for ( ; ++i < length; ) { + matchIndexes.push( i ); + } + return matchIndexes; + }) + } +}; + +Expr.pseudos["nth"] = Expr.pseudos["eq"]; + +// Add button/input type pseudos +for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { + Expr.pseudos[ i ] = createInputPseudo( i ); +} +for ( i in { submit: true, reset: true } ) { + Expr.pseudos[ i ] = createButtonPseudo( i ); +} + +// Easy API for creating new setFilters +function setFilters() {} +setFilters.prototype = Expr.filters = Expr.pseudos; +Expr.setFilters = new setFilters(); + +tokenize = Sizzle.tokenize = function( selector, parseOnly ) { + var matched, match, tokens, type, + soFar, groups, preFilters, + cached = tokenCache[ selector + " " ]; + + if ( cached ) { + return parseOnly ? 0 : cached.slice( 0 ); + } + + soFar = selector; + groups = []; + preFilters = Expr.preFilter; + + while ( soFar ) { + + // Comma and first run + if ( !matched || (match = rcomma.exec( soFar )) ) { + if ( match ) { + // Don't consume trailing commas as valid + soFar = soFar.slice( match[0].length ) || soFar; + } + groups.push( (tokens = []) ); + } + + matched = false; + + // Combinators + if ( (match = rcombinators.exec( soFar )) ) { + matched = match.shift(); + tokens.push({ + value: matched, + // Cast descendant combinators to space + type: match[0].replace( rtrim, " " ) + }); + soFar = soFar.slice( matched.length ); + } + + // Filters + for ( type in Expr.filter ) { + if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || + (match = preFilters[ type ]( match ))) ) { + matched = match.shift(); + tokens.push({ + value: matched, + type: type, + matches: match + }); + soFar = soFar.slice( matched.length ); + } + } + + if ( !matched ) { + break; + } + } + + // Return the length of the invalid excess + // if we're just parsing + // Otherwise, throw an error or return tokens + return parseOnly ? + soFar.length : + soFar ? + Sizzle.error( selector ) : + // Cache the tokens + tokenCache( selector, groups ).slice( 0 ); +}; + +function toSelector( tokens ) { + var i = 0, + len = tokens.length, + selector = ""; + for ( ; i < len; i++ ) { + selector += tokens[i].value; + } + return selector; +} + +function addCombinator( matcher, combinator, base ) { + var dir = combinator.dir, + checkNonElements = base && dir === "parentNode", + doneName = done++; + + return combinator.first ? + // Check against closest ancestor/preceding element + function( elem, context, xml ) { + while ( (elem = elem[ dir ]) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + return matcher( elem, context, xml ); + } + } + } : + + // Check against all ancestor/preceding elements + function( elem, context, xml ) { + var oldCache, outerCache, + newCache = [ dirruns, doneName ]; + + // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching + if ( xml ) { + while ( (elem = elem[ dir ]) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + if ( matcher( elem, context, xml ) ) { + return true; + } + } + } + } else { + while ( (elem = elem[ dir ]) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + outerCache = elem[ expando ] || (elem[ expando ] = {}); + if ( (oldCache = outerCache[ dir ]) && + oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { + + // Assign to newCache so results back-propagate to previous elements + return (newCache[ 2 ] = oldCache[ 2 ]); + } else { + // Reuse newcache so results back-propagate to previous elements + outerCache[ dir ] = newCache; + + // A match means we're done; a fail means we have to keep checking + if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { + return true; + } + } + } + } + } + }; +} + +function elementMatcher( matchers ) { + return matchers.length > 1 ? + function( elem, context, xml ) { + var i = matchers.length; + while ( i-- ) { + if ( !matchers[i]( elem, context, xml ) ) { + return false; + } + } + return true; + } : + matchers[0]; +} + +function multipleContexts( selector, contexts, results ) { + var i = 0, + len = contexts.length; + for ( ; i < len; i++ ) { + Sizzle( selector, contexts[i], results ); + } + return results; +} + +function condense( unmatched, map, filter, context, xml ) { + var elem, + newUnmatched = [], + i = 0, + len = unmatched.length, + mapped = map != null; + + for ( ; i < len; i++ ) { + if ( (elem = unmatched[i]) ) { + if ( !filter || filter( elem, context, xml ) ) { + newUnmatched.push( elem ); + if ( mapped ) { + map.push( i ); + } + } + } + } + + return newUnmatched; +} + +function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { + if ( postFilter && !postFilter[ expando ] ) { + postFilter = setMatcher( postFilter ); + } + if ( postFinder && !postFinder[ expando ] ) { + postFinder = setMatcher( postFinder, postSelector ); + } + return markFunction(function( seed, results, context, xml ) { + var temp, i, elem, + preMap = [], + postMap = [], + preexisting = results.length, + + // Get initial elements from seed or context + elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), + + // Prefilter to get matcher input, preserving a map for seed-results synchronization + matcherIn = preFilter && ( seed || !selector ) ? + condense( elems, preMap, preFilter, context, xml ) : + elems, + + matcherOut = matcher ? + // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, + postFinder || ( seed ? preFilter : preexisting || postFilter ) ? + + // ...intermediate processing is necessary + [] : + + // ...otherwise use results directly + results : + matcherIn; + + // Find primary matches + if ( matcher ) { + matcher( matcherIn, matcherOut, context, xml ); + } + + // Apply postFilter + if ( postFilter ) { + temp = condense( matcherOut, postMap ); + postFilter( temp, [], context, xml ); + + // Un-match failing elements by moving them back to matcherIn + i = temp.length; + while ( i-- ) { + if ( (elem = temp[i]) ) { + matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); + } + } + } + + if ( seed ) { + if ( postFinder || preFilter ) { + if ( postFinder ) { + // Get the final matcherOut by condensing this intermediate into postFinder contexts + temp = []; + i = matcherOut.length; + while ( i-- ) { + if ( (elem = matcherOut[i]) ) { + // Restore matcherIn since elem is not yet a final match + temp.push( (matcherIn[i] = elem) ); + } + } + postFinder( null, (matcherOut = []), temp, xml ); + } + + // Move matched elements from seed to results to keep them synchronized + i = matcherOut.length; + while ( i-- ) { + if ( (elem = matcherOut[i]) && + (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) { + + seed[temp] = !(results[temp] = elem); + } + } + } + + // Add elements to results, through postFinder if defined + } else { + matcherOut = condense( + matcherOut === results ? + matcherOut.splice( preexisting, matcherOut.length ) : + matcherOut + ); + if ( postFinder ) { + postFinder( null, results, matcherOut, xml ); + } else { + push.apply( results, matcherOut ); + } + } + }); +} + +function matcherFromTokens( tokens ) { + var checkContext, matcher, j, + len = tokens.length, + leadingRelative = Expr.relative[ tokens[0].type ], + implicitRelative = leadingRelative || Expr.relative[" "], + i = leadingRelative ? 1 : 0, + + // The foundational matcher ensures that elements are reachable from top-level context(s) + matchContext = addCombinator( function( elem ) { + return elem === checkContext; + }, implicitRelative, true ), + matchAnyContext = addCombinator( function( elem ) { + return indexOf( checkContext, elem ) > -1; + }, implicitRelative, true ), + matchers = [ function( elem, context, xml ) { + var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( + (checkContext = context).nodeType ? + matchContext( elem, context, xml ) : + matchAnyContext( elem, context, xml ) ); + // Avoid hanging onto element (issue #299) + checkContext = null; + return ret; + } ]; + + for ( ; i < len; i++ ) { + if ( (matcher = Expr.relative[ tokens[i].type ]) ) { + matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; + } else { + matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); + + // Return special upon seeing a positional matcher + if ( matcher[ expando ] ) { + // Find the next relative operator (if any) for proper handling + j = ++i; + for ( ; j < len; j++ ) { + if ( Expr.relative[ tokens[j].type ] ) { + break; + } + } + return setMatcher( + i > 1 && elementMatcher( matchers ), + i > 1 && toSelector( + // If the preceding token was a descendant combinator, insert an implicit any-element `*` + tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) + ).replace( rtrim, "$1" ), + matcher, + i < j && matcherFromTokens( tokens.slice( i, j ) ), + j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), + j < len && toSelector( tokens ) + ); + } + matchers.push( matcher ); + } + } + + return elementMatcher( matchers ); +} + +function matcherFromGroupMatchers( elementMatchers, setMatchers ) { + var bySet = setMatchers.length > 0, + byElement = elementMatchers.length > 0, + superMatcher = function( seed, context, xml, results, outermost ) { + var elem, j, matcher, + matchedCount = 0, + i = "0", + unmatched = seed && [], + setMatched = [], + contextBackup = outermostContext, + // We must always have either seed elements or outermost context + elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), + // Use integer dirruns iff this is the outermost matcher + dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), + len = elems.length; + + if ( outermost ) { + outermostContext = context !== document && context; + } + + // Add elements passing elementMatchers directly to results + // Keep `i` a string if there are no elements so `matchedCount` will be "00" below + // Support: IE<9, Safari + // Tolerate NodeList properties (IE: "length"; Safari: ) matching elements by id + for ( ; i !== len && (elem = elems[i]) != null; i++ ) { + if ( byElement && elem ) { + j = 0; + while ( (matcher = elementMatchers[j++]) ) { + if ( matcher( elem, context, xml ) ) { + results.push( elem ); + break; + } + } + if ( outermost ) { + dirruns = dirrunsUnique; + } + } + + // Track unmatched elements for set filters + if ( bySet ) { + // They will have gone through all possible matchers + if ( (elem = !matcher && elem) ) { + matchedCount--; + } + + // Lengthen the array for every element, matched or not + if ( seed ) { + unmatched.push( elem ); + } + } + } + + // Apply set filters to unmatched elements + matchedCount += i; + if ( bySet && i !== matchedCount ) { + j = 0; + while ( (matcher = setMatchers[j++]) ) { + matcher( unmatched, setMatched, context, xml ); + } + + if ( seed ) { + // Reintegrate element matches to eliminate the need for sorting + if ( matchedCount > 0 ) { + while ( i-- ) { + if ( !(unmatched[i] || setMatched[i]) ) { + setMatched[i] = pop.call( results ); + } + } + } + + // Discard index placeholder values to get only actual matches + setMatched = condense( setMatched ); + } + + // Add matches to results + push.apply( results, setMatched ); + + // Seedless set matches succeeding multiple successful matchers stipulate sorting + if ( outermost && !seed && setMatched.length > 0 && + ( matchedCount + setMatchers.length ) > 1 ) { + + Sizzle.uniqueSort( results ); + } + } + + // Override manipulation of globals by nested matchers + if ( outermost ) { + dirruns = dirrunsUnique; + outermostContext = contextBackup; + } + + return unmatched; + }; + + return bySet ? + markFunction( superMatcher ) : + superMatcher; +} + +compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { + var i, + setMatchers = [], + elementMatchers = [], + cached = compilerCache[ selector + " " ]; + + if ( !cached ) { + // Generate a function of recursive functions that can be used to check each element + if ( !match ) { + match = tokenize( selector ); + } + i = match.length; + while ( i-- ) { + cached = matcherFromTokens( match[i] ); + if ( cached[ expando ] ) { + setMatchers.push( cached ); + } else { + elementMatchers.push( cached ); + } + } + + // Cache the compiled function + cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); + + // Save selector and tokenization + cached.selector = selector; + } + return cached; +}; + +/** + * A low-level selection function that works with Sizzle's compiled + * selector functions + * @param {String|Function} selector A selector or a pre-compiled + * selector function built with Sizzle.compile + * @param {Element} context + * @param {Array} [results] + * @param {Array} [seed] A set of elements to match against + */ +select = Sizzle.select = function( selector, context, results, seed ) { + var i, tokens, token, type, find, + compiled = typeof selector === "function" && selector, + match = !seed && tokenize( (selector = compiled.selector || selector) ); + + results = results || []; + + // Try to minimize operations if there is no seed and only one group + if ( match.length === 1 ) { + + // Take a shortcut and set the context if the root selector is an ID + tokens = match[0] = match[0].slice( 0 ); + if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && + support.getById && context.nodeType === 9 && documentIsHTML && + Expr.relative[ tokens[1].type ] ) { + + context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; + if ( !context ) { + return results; + + // Precompiled matchers will still verify ancestry, so step up a level + } else if ( compiled ) { + context = context.parentNode; + } + + selector = selector.slice( tokens.shift().value.length ); + } + + // Fetch a seed set for right-to-left matching + i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; + while ( i-- ) { + token = tokens[i]; + + // Abort if we hit a combinator + if ( Expr.relative[ (type = token.type) ] ) { + break; + } + if ( (find = Expr.find[ type ]) ) { + // Search, expanding context for leading sibling combinators + if ( (seed = find( + token.matches[0].replace( runescape, funescape ), + rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context + )) ) { + + // If seed is empty or no tokens remain, we can return early + tokens.splice( i, 1 ); + selector = seed.length && toSelector( tokens ); + if ( !selector ) { + push.apply( results, seed ); + return results; + } + + break; + } + } + } + } + + // Compile and execute a filtering function if one is not provided + // Provide `match` to avoid retokenization if we modified the selector above + ( compiled || compile( selector, match ) )( + seed, + context, + !documentIsHTML, + results, + rsibling.test( selector ) && testContext( context.parentNode ) || context + ); + return results; +}; + +// One-time assignments + +// Sort stability +support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; + +// Support: Chrome 14-35+ +// Always assume duplicates if they aren't passed to the comparison function +support.detectDuplicates = !!hasDuplicate; + +// Initialize against the default document +setDocument(); + +// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) +// Detached nodes confoundingly follow *each other* +support.sortDetached = assert(function( div1 ) { + // Should return 1, but returns 4 (following) + return div1.compareDocumentPosition( document.createElement("div") ) & 1; +}); + +// Support: IE<8 +// Prevent attribute/property "interpolation" +// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx +if ( !assert(function( div ) { + div.innerHTML = ""; + return div.firstChild.getAttribute("href") === "#" ; +}) ) { + addHandle( "type|href|height|width", function( elem, name, isXML ) { + if ( !isXML ) { + return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); + } + }); +} + +// Support: IE<9 +// Use defaultValue in place of getAttribute("value") +if ( !support.attributes || !assert(function( div ) { + div.innerHTML = ""; + div.firstChild.setAttribute( "value", "" ); + return div.firstChild.getAttribute( "value" ) === ""; +}) ) { + addHandle( "value", function( elem, name, isXML ) { + if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { + return elem.defaultValue; + } + }); +} + +// Support: IE<9 +// Use getAttributeNode to fetch booleans when getAttribute lies +if ( !assert(function( div ) { + return div.getAttribute("disabled") == null; +}) ) { + addHandle( booleans, function( elem, name, isXML ) { + var val; + if ( !isXML ) { + return elem[ name ] === true ? name.toLowerCase() : + (val = elem.getAttributeNode( name )) && val.specified ? + val.value : + null; + } + }); +} + +return Sizzle; + +})( window ); + + + +jQuery.find = Sizzle; +jQuery.expr = Sizzle.selectors; +jQuery.expr[":"] = jQuery.expr.pseudos; +jQuery.unique = Sizzle.uniqueSort; +jQuery.text = Sizzle.getText; +jQuery.isXMLDoc = Sizzle.isXML; +jQuery.contains = Sizzle.contains; + + + +var rneedsContext = jQuery.expr.match.needsContext; + +var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/); + + + +var risSimple = /^.[^:#\[\.,]*$/; + +// Implement the identical functionality for filter and not +function winnow( elements, qualifier, not ) { + if ( jQuery.isFunction( qualifier ) ) { + return jQuery.grep( elements, function( elem, i ) { + /* jshint -W018 */ + return !!qualifier.call( elem, i, elem ) !== not; + }); + + } + + if ( qualifier.nodeType ) { + return jQuery.grep( elements, function( elem ) { + return ( elem === qualifier ) !== not; + }); + + } + + if ( typeof qualifier === "string" ) { + if ( risSimple.test( qualifier ) ) { + return jQuery.filter( qualifier, elements, not ); + } + + qualifier = jQuery.filter( qualifier, elements ); + } + + return jQuery.grep( elements, function( elem ) { + return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not; + }); +} + +jQuery.filter = function( expr, elems, not ) { + var elem = elems[ 0 ]; + + if ( not ) { + expr = ":not(" + expr + ")"; + } + + return elems.length === 1 && elem.nodeType === 1 ? + jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : + jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { + return elem.nodeType === 1; + })); +}; + +jQuery.fn.extend({ + find: function( selector ) { + var i, + ret = [], + self = this, + len = self.length; + + if ( typeof selector !== "string" ) { + return this.pushStack( jQuery( selector ).filter(function() { + for ( i = 0; i < len; i++ ) { + if ( jQuery.contains( self[ i ], this ) ) { + return true; + } + } + }) ); + } + + for ( i = 0; i < len; i++ ) { + jQuery.find( selector, self[ i ], ret ); + } + + // Needed because $( selector, context ) becomes $( context ).find( selector ) + ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); + ret.selector = this.selector ? this.selector + " " + selector : selector; + return ret; + }, + filter: function( selector ) { + return this.pushStack( winnow(this, selector || [], false) ); + }, + not: function( selector ) { + return this.pushStack( winnow(this, selector || [], true) ); + }, + is: function( selector ) { + return !!winnow( + this, + + // If this is a positional/relative selector, check membership in the returned set + // so $("p:first").is("p:last") won't return true for a doc with two "p". + typeof selector === "string" && rneedsContext.test( selector ) ? + jQuery( selector ) : + selector || [], + false + ).length; + } +}); + + +// Initialize a jQuery object + + +// A central reference to the root jQuery(document) +var rootjQuery, + + // Use the correct document accordingly with window argument (sandbox) + document = window.document, + + // A simple way to check for HTML strings + // Prioritize #id over to avoid XSS via location.hash (#9521) + // Strict HTML recognition (#11290: must start with <) + rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, + + init = jQuery.fn.init = function( selector, context ) { + var match, elem; + + // HANDLE: $(""), $(null), $(undefined), $(false) + if ( !selector ) { + return this; + } + + // Handle HTML strings + if ( typeof selector === "string" ) { + 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 = rquickExpr.exec( selector ); + } + + // Match html or make sure no context is specified for #id + if ( match && (match[1] || !context) ) { + + // HANDLE: $(html) -> $(array) + if ( match[1] ) { + context = context instanceof jQuery ? context[0] : context; + + // scripts is true for back-compat + // Intentionally let the error be thrown if parseHTML is not present + jQuery.merge( this, jQuery.parseHTML( + match[1], + context && context.nodeType ? context.ownerDocument || context : document, + true + ) ); + + // HANDLE: $(html, props) + if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { + for ( match in context ) { + // Properties of context are called as methods if possible + if ( jQuery.isFunction( this[ match ] ) ) { + this[ match ]( context[ match ] ); + + // ...and otherwise set as attributes + } else { + this.attr( match, context[ match ] ); + } + } + } + + return this; + + // 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: $(DOMElement) + } else if ( selector.nodeType ) { + this.context = this[0] = selector; + this.length = 1; + return this; + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) { + return typeof rootjQuery.ready !== "undefined" ? + rootjQuery.ready( selector ) : + // Execute immediately if ready is not present + selector( jQuery ); + } + + if ( selector.selector !== undefined ) { + this.selector = selector.selector; + this.context = selector.context; + } + + return jQuery.makeArray( selector, this ); + }; + +// Give the init function the jQuery prototype for later instantiation +init.prototype = jQuery.fn; + +// Initialize central reference +rootjQuery = jQuery( document ); + + +var rparentsprev = /^(?:parents|prev(?:Until|All))/, + // methods guaranteed to produce a unique set when starting from a unique set + guaranteedUnique = { + children: true, + contents: true, + next: true, + prev: true + }; + +jQuery.extend({ + 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; + }, + + sibling: function( n, elem ) { + var r = []; + + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType === 1 && n !== elem ) { + r.push( n ); + } + } + + return r; + } +}); + +jQuery.fn.extend({ + has: function( target ) { + var i, + targets = jQuery( target, this ), + len = targets.length; + + return this.filter(function() { + for ( i = 0; i < len; i++ ) { + if ( jQuery.contains( this, targets[i] ) ) { + return true; + } + } + }); + }, + + closest: function( selectors, context ) { + var cur, + i = 0, + l = this.length, + matched = [], + pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? + jQuery( selectors, context || this.context ) : + 0; + + for ( ; i < l; i++ ) { + for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) { + // Always skip document fragments + if ( cur.nodeType < 11 && (pos ? + pos.index(cur) > -1 : + + // Don't pass non-elements to Sizzle + cur.nodeType === 1 && + jQuery.find.matchesSelector(cur, selectors)) ) { + + matched.push( cur ); + break; + } + } + } + + return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched ); + }, + + // Determine the position of an element within + // the matched set of elements + index: function( elem ) { + + // No argument, return index in parent + if ( !elem ) { + return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1; + } + + // index in selector + if ( typeof elem === "string" ) { + return jQuery.inArray( this[0], jQuery( elem ) ); + } + + // 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 ) { + return this.pushStack( + jQuery.unique( + jQuery.merge( this.get(), jQuery( selector, context ) ) + ) + ); + }, + + addBack: function( selector ) { + return this.add( selector == null ? + this.prevObject : this.prevObject.filter(selector) + ); + } +}); + +function sibling( cur, dir ) { + do { + cur = cur[ dir ]; + } while ( cur && cur.nodeType !== 1 ); + + return cur; +} + +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 sibling( elem, "nextSibling" ); + }, + prev: function( elem ) { + return sibling( elem, "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.merge( [], elem.childNodes ); + } +}, function( name, fn ) { + jQuery.fn[ name ] = function( until, selector ) { + var ret = jQuery.map( this, fn, until ); + + if ( name.slice( -5 ) !== "Until" ) { + selector = until; + } + + if ( selector && typeof selector === "string" ) { + ret = jQuery.filter( selector, ret ); + } + + if ( this.length > 1 ) { + // Remove duplicates + if ( !guaranteedUnique[ name ] ) { + ret = jQuery.unique( ret ); + } + + // Reverse order for parents* and prev-derivatives + if ( rparentsprev.test( name ) ) { + ret = ret.reverse(); + } + } + + return this.pushStack( ret ); + }; +}); +var rnotwhite = (/\S+/g); + + + +// String to Object options format cache +var optionsCache = {}; + +// Convert String-formatted options into Object-formatted ones and store in cache +function createOptions( options ) { + var object = optionsCache[ options ] = {}; + jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) { + object[ flag ] = true; + }); + return object; +} + +/* + * Create a callback list using the following parameters: + * + * options: an optional list of space-separated options that will change how + * the callback list behaves or a more traditional option object + * + * By default a callback list will act like an event callback list and can be + * "fired" multiple times. + * + * Possible options: + * + * once: will ensure the callback list can only be fired once (like a Deferred) + * + * memory: will keep track of previous values and will call any callback added + * after the list has been fired right away with the latest "memorized" + * values (like a Deferred) + * + * unique: will ensure a callback can only be added once (no duplicate in the list) + * + * stopOnFalse: interrupt callings when a callback returns false + * + */ +jQuery.Callbacks = function( options ) { + + // Convert options from String-formatted to Object-formatted if needed + // (we check in cache first) + options = typeof options === "string" ? + ( optionsCache[ options ] || createOptions( options ) ) : + jQuery.extend( {}, options ); + + var // Flag to know if list is currently firing + firing, + // Last fire value (for non-forgettable lists) + memory, + // Flag to know if list was already fired + fired, + // End of the loop when firing + firingLength, + // Index of currently firing callback (modified by remove if needed) + firingIndex, + // First callback to fire (used internally by add and fireWith) + firingStart, + // Actual callback list + list = [], + // Stack of fire calls for repeatable lists + stack = !options.once && [], + // Fire callbacks + fire = function( data ) { + memory = options.memory && data; + fired = true; + firingIndex = firingStart || 0; + firingStart = 0; + firingLength = list.length; + firing = true; + for ( ; list && firingIndex < firingLength; firingIndex++ ) { + if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { + memory = false; // To prevent further calls using add + break; + } + } + firing = false; + if ( list ) { + if ( stack ) { + if ( stack.length ) { + fire( stack.shift() ); + } + } else if ( memory ) { + list = []; + } else { + self.disable(); + } + } + }, + // Actual Callbacks object + self = { + // Add a callback or a collection of callbacks to the list + add: function() { + if ( list ) { + // First, we save the current length + var start = list.length; + (function add( args ) { + jQuery.each( args, function( _, arg ) { + var type = jQuery.type( arg ); + if ( type === "function" ) { + if ( !options.unique || !self.has( arg ) ) { + list.push( arg ); + } + } else if ( arg && arg.length && type !== "string" ) { + // Inspect recursively + add( arg ); + } + }); + })( arguments ); + // Do we need to add the callbacks to the + // current firing batch? + if ( firing ) { + firingLength = list.length; + // With memory, if we're not firing then + // we should call right away + } else if ( memory ) { + firingStart = start; + fire( memory ); + } + } + return this; + }, + // Remove a callback from the list + remove: function() { + if ( list ) { + jQuery.each( arguments, function( _, arg ) { + var index; + while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { + list.splice( index, 1 ); + // Handle firing indexes + if ( firing ) { + if ( index <= firingLength ) { + firingLength--; + } + if ( index <= firingIndex ) { + firingIndex--; + } + } + } + }); + } + return this; + }, + // Check if a given callback is in the list. + // If no argument is given, return whether or not list has callbacks attached. + has: function( fn ) { + return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length ); + }, + // Remove all callbacks from the list + empty: function() { + list = []; + firingLength = 0; + return this; + }, + // Have the list do nothing anymore + disable: function() { + list = stack = memory = undefined; + return this; + }, + // Is it disabled? + disabled: function() { + return !list; + }, + // Lock the list in its current state + lock: function() { + stack = undefined; + if ( !memory ) { + self.disable(); + } + return this; + }, + // Is it locked? + locked: function() { + return !stack; + }, + // Call all callbacks with the given context and arguments + fireWith: function( context, args ) { + if ( list && ( !fired || stack ) ) { + args = args || []; + args = [ context, args.slice ? args.slice() : args ]; + if ( firing ) { + stack.push( args ); + } else { + fire( args ); + } + } + return this; + }, + // Call all the callbacks with the given arguments + fire: function() { + self.fireWith( this, arguments ); + return this; + }, + // To know if the callbacks have already been called at least once + fired: function() { + return !!fired; + } + }; + + return self; +}; + + +jQuery.extend({ + + Deferred: function( func ) { + var tuples = [ + // action, add listener, listener list, final state + [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], + [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], + [ "notify", "progress", jQuery.Callbacks("memory") ] + ], + state = "pending", + promise = { + state: function() { + return state; + }, + always: function() { + deferred.done( arguments ).fail( arguments ); + return this; + }, + then: function( /* fnDone, fnFail, fnProgress */ ) { + var fns = arguments; + return jQuery.Deferred(function( newDefer ) { + jQuery.each( tuples, function( i, tuple ) { + var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; + // deferred[ done | fail | progress ] for forwarding actions to newDefer + deferred[ tuple[1] ](function() { + var returned = fn && fn.apply( this, arguments ); + if ( returned && jQuery.isFunction( returned.promise ) ) { + returned.promise() + .done( newDefer.resolve ) + .fail( newDefer.reject ) + .progress( newDefer.notify ); + } else { + newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments ); + } + }); + }); + fns = null; + }).promise(); + }, + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj ) { + return obj != null ? jQuery.extend( obj, promise ) : promise; + } + }, + deferred = {}; + + // Keep pipe for back-compat + promise.pipe = promise.then; + + // Add list-specific methods + jQuery.each( tuples, function( i, tuple ) { + var list = tuple[ 2 ], + stateString = tuple[ 3 ]; + + // promise[ done | fail | progress ] = list.add + promise[ tuple[1] ] = list.add; + + // Handle state + if ( stateString ) { + list.add(function() { + // state = [ resolved | rejected ] + state = stateString; + + // [ reject_list | resolve_list ].disable; progress_list.lock + }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); + } + + // deferred[ resolve | reject | notify ] + deferred[ tuple[0] ] = function() { + deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments ); + return this; + }; + deferred[ tuple[0] + "With" ] = list.fireWith; + }); + + // Make the deferred a promise + promise.promise( deferred ); + + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); + } + + // All done! + return deferred; + }, + + // Deferred helper + when: function( subordinate /* , ..., subordinateN */ ) { + var i = 0, + resolveValues = slice.call( arguments ), + length = resolveValues.length, + + // the count of uncompleted subordinates + remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, + + // the master Deferred. If resolveValues consist of only a single Deferred, just use that. + deferred = remaining === 1 ? subordinate : jQuery.Deferred(), + + // Update function for both resolve and progress values + updateFunc = function( i, contexts, values ) { + return function( value ) { + contexts[ i ] = this; + values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; + if ( values === progressValues ) { + deferred.notifyWith( contexts, values ); + + } else if ( !(--remaining) ) { + deferred.resolveWith( contexts, values ); + } + }; + }, + + progressValues, progressContexts, resolveContexts; + + // add listeners to Deferred subordinates; treat others as resolved + if ( length > 1 ) { + progressValues = new Array( length ); + progressContexts = new Array( length ); + resolveContexts = new Array( length ); + for ( ; i < length; i++ ) { + if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { + resolveValues[ i ].promise() + .done( updateFunc( i, resolveContexts, resolveValues ) ) + .fail( deferred.reject ) + .progress( updateFunc( i, progressContexts, progressValues ) ); + } else { + --remaining; + } + } + } + + // if we're not waiting on anything, resolve the master + if ( !remaining ) { + deferred.resolveWith( resolveContexts, resolveValues ); + } + + return deferred.promise(); + } +}); + + +// The deferred used on DOM ready +var readyList; + +jQuery.fn.ready = function( fn ) { + // Add the callback + jQuery.ready.promise().done( fn ); + + return this; +}; + +jQuery.extend({ + // 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 ) { + + // Abort if there are pending holds or we're already ready + if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { + return; + } + + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( !document.body ) { + return setTimeout( jQuery.ready ); + } + + // 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.triggerHandler ) { + jQuery( document ).triggerHandler( "ready" ); + jQuery( document ).off( "ready" ); + } + } +}); + +/** + * Clean-up method for dom ready events + */ +function detach() { + if ( document.addEventListener ) { + document.removeEventListener( "DOMContentLoaded", completed, false ); + window.removeEventListener( "load", completed, false ); + + } else { + document.detachEvent( "onreadystatechange", completed ); + window.detachEvent( "onload", completed ); + } +} + +/** + * The ready event handler and self cleanup method + */ +function completed() { + // readyState === "complete" is good enough for us to call the dom ready in oldIE + if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) { + detach(); + jQuery.ready(); + } +} + +jQuery.ready.promise = function( obj ) { + if ( !readyList ) { + + readyList = jQuery.Deferred(); + + // Catch cases where $(document).ready() is called after the browser event has already occurred. + // we once tried to use readyState "interactive" here, but it caused issues like the one + // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 + if ( document.readyState === "complete" ) { + // Handle it asynchronously to allow scripts the opportunity to delay ready + setTimeout( jQuery.ready ); + + // Standards-based browsers support DOMContentLoaded + } else if ( document.addEventListener ) { + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", completed, false ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", completed, false ); + + // If IE event model is used + } else { + // Ensure firing before onload, maybe late but safe also for iframes + document.attachEvent( "onreadystatechange", completed ); + + // A fallback to window.onload, that will always work + window.attachEvent( "onload", completed ); + + // If IE and not a frame + // continually check to see if the document is ready + var top = false; + + try { + top = window.frameElement == null && document.documentElement; + } catch(e) {} + + if ( top && top.doScroll ) { + (function doScrollCheck() { + if ( !jQuery.isReady ) { + + try { + // Use the trick by Diego Perini + // http://javascript.nwbox.com/IEContentLoaded/ + top.doScroll("left"); + } catch(e) { + return setTimeout( doScrollCheck, 50 ); + } + + // detach all dom ready events + detach(); + + // and execute any waiting functions + jQuery.ready(); + } + })(); + } + } + } + return readyList.promise( obj ); +}; + + +var strundefined = typeof undefined; + + + +// Support: IE<9 +// Iteration over object's inherited properties before its own +var i; +for ( i in jQuery( support ) ) { + break; +} +support.ownLast = i !== "0"; + +// Note: most support tests are defined in their respective modules. +// false until the test is run +support.inlineBlockNeedsLayout = false; + +// Execute ASAP in case we need to set body.style.zoom +jQuery(function() { + // Minified: var a,b,c,d + var val, div, body, container; + + body = document.getElementsByTagName( "body" )[ 0 ]; + if ( !body || !body.style ) { + // Return for frameset docs that don't have a body + return; + } + + // Setup + div = document.createElement( "div" ); + container = document.createElement( "div" ); + container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px"; + body.appendChild( container ).appendChild( div ); + + if ( typeof div.style.zoom !== strundefined ) { + // Support: IE<8 + // Check if natively block-level elements act like inline-block + // elements when setting their display to 'inline' and giving + // them layout + div.style.cssText = "display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1"; + + support.inlineBlockNeedsLayout = val = div.offsetWidth === 3; + if ( val ) { + // Prevent IE 6 from affecting layout for positioned elements #11048 + // Prevent IE from shrinking the body in IE 7 mode #12869 + // Support: IE<8 + body.style.zoom = 1; + } + } + + body.removeChild( container ); +}); + + + + +(function() { + var div = document.createElement( "div" ); + + // Execute the test only if not already executed in another module. + if (support.deleteExpando == null) { + // Support: IE<9 + support.deleteExpando = true; + try { + delete div.test; + } catch( e ) { + support.deleteExpando = false; + } + } + + // Null elements to avoid leaks in IE. + div = null; +})(); + + +/** + * Determines whether an object can have data + */ +jQuery.acceptData = function( elem ) { + var noData = jQuery.noData[ (elem.nodeName + " ").toLowerCase() ], + nodeType = +elem.nodeType || 1; + + // Do not set data on non-element DOM nodes because it will not be cleared (#8335). + return nodeType !== 1 && nodeType !== 9 ? + false : + + // Nodes accept data unless otherwise specified; rejection can be conditional + !noData || noData !== true && elem.getAttribute("classid") === noData; +}; + + +var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, + rmultiDash = /([A-Z])/g; + +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" ).toLowerCase(); + + data = elem.getAttribute( name ); + + if ( typeof data === "string" ) { + try { + data = data === "true" ? true : + data === "false" ? false : + data === "null" ? null : + // Only convert to a number if it doesn't change the string + +data + "" === data ? +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; +} + +// checks a cache object for emptiness +function isEmptyDataObject( obj ) { + var name; + for ( name in obj ) { + + // if the public data object is empty, the private is still empty + if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { + continue; + } + if ( name !== "toJSON" ) { + return false; + } + } + + return true; +} + +function internalData( elem, name, data, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var ret, thisCache, + internalKey = jQuery.expando, + + // 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[ internalKey ] : elem[ internalKey ] && internalKey; + + // 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 || !cache[id] || (!pvt && !cache[id].data)) && data === undefined && typeof name === "string" ) { + 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 ) { + id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++; + } else { + id = internalKey; + } + } + + if ( !cache[ id ] ) { + // Avoid exposing jQuery metadata on plain JS objects when the object + // is serialized using JSON.stringify + cache[ id ] = isNode ? {} : { 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 ] = jQuery.extend( cache[ id ], name ); + } else { + cache[ id ].data = jQuery.extend( cache[ id ].data, name ); + } + } + + thisCache = cache[ id ]; + + // jQuery data() is stored in a separate object inside the object's internal data + // cache in order to avoid key collisions between internal data and user-defined + // data. + if ( !pvt ) { + if ( !thisCache.data ) { + thisCache.data = {}; + } + + thisCache = thisCache.data; + } + + if ( data !== undefined ) { + thisCache[ jQuery.camelCase( name ) ] = data; + } + + // Check for both converted-to-camel and non-converted data property names + // If a data property was specified + if ( typeof name === "string" ) { + + // First Try to find as-is property data + ret = thisCache[ name ]; + + // Test for null|undefined property data + if ( ret == null ) { + + // Try to find the camelCased property + ret = thisCache[ jQuery.camelCase( name ) ]; + } + } else { + ret = thisCache; + } + + return ret; +} + +function internalRemoveData( elem, name, pvt ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var thisCache, i, + isNode = elem.nodeType, + + // See jQuery.data for more information + cache = isNode ? jQuery.cache : elem, + 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 ) { + + thisCache = pvt ? cache[ id ] : cache[ id ].data; + + if ( thisCache ) { + + // Support array or space separated string names for data keys + if ( !jQuery.isArray( name ) ) { + + // try the string as a key before any manipulation + if ( name in thisCache ) { + name = [ name ]; + } else { + + // split the camel cased version by spaces unless a key with the spaces exists + name = jQuery.camelCase( name ); + if ( name in thisCache ) { + name = [ name ]; + } else { + name = name.split(" "); + } + } + } else { + // If "name" is an array of keys... + // When data is initially created, via ("key", "val") signature, + // keys will be converted to camelCase. + // Since there is no way to tell _how_ a key was added, remove + // both plain key and camelCase key. #12786 + // This will only penalize the array argument path. + name = name.concat( jQuery.map( name, jQuery.camelCase ) ); + } + + i = name.length; + while ( i-- ) { + delete thisCache[ name[i] ]; + } + + // If there is no data left in the cache, we want to continue + // and let the cache object itself get destroyed + if ( pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache) ) { + return; + } + } + } + + // See jQuery.data for more information + if ( !pvt ) { + delete cache[ id ].data; + + // Don't destroy the parent cache unless the internal data object + // had been the only thing left in it + if ( !isEmptyDataObject( cache[ id ] ) ) { + return; + } + } + + // Destroy the cache + if ( isNode ) { + jQuery.cleanData( [ elem ], true ); + + // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080) + /* jshint eqeqeq: false */ + } else if ( support.deleteExpando || cache != cache.window ) { + /* jshint eqeqeq: true */ + delete cache[ id ]; + + // When all else fails, null + } else { + cache[ id ] = null; + } +} + +jQuery.extend({ + cache: {}, + + // The following elements (space-suffixed to avoid Object.prototype collisions) + // throw uncatchable exceptions if you attempt to set expando properties + noData: { + "applet ": true, + "embed ": true, + // ...but Flash objects (which have this classid) *can* handle expandos + "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" + }, + + hasData: function( elem ) { + elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; + return !!elem && !isEmptyDataObject( elem ); + }, + + data: function( elem, name, data ) { + return internalData( elem, name, data ); + }, + + removeData: function( elem, name ) { + return internalRemoveData( elem, name ); + }, + + // For internal use only. + _data: function( elem, name, data ) { + return internalData( elem, name, data, true ); + }, + + _removeData: function( elem, name ) { + return internalRemoveData( elem, name, true ); + } +}); + +jQuery.fn.extend({ + data: function( key, value ) { + var i, name, data, + elem = this[0], + attrs = elem && elem.attributes; + + // Special expections of .data basically thwart jQuery.access, + // so implement the relevant behavior ourselves + + // Gets all values + if ( key === undefined ) { + if ( this.length ) { + data = jQuery.data( elem ); + + if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) { + i = attrs.length; + while ( i-- ) { + + // Support: IE11+ + // The attrs elements can be null (#14894) + if ( attrs[ i ] ) { + name = attrs[ i ].name; + if ( name.indexOf( "data-" ) === 0 ) { + name = jQuery.camelCase( name.slice(5) ); + dataAttr( elem, name, data[ name ] ); + } + } + } + jQuery._data( elem, "parsedAttrs", true ); + } + } + + return data; + } + + // Sets multiple values + if ( typeof key === "object" ) { + return this.each(function() { + jQuery.data( this, key ); + }); + } + + return arguments.length > 1 ? + + // Sets one value + this.each(function() { + jQuery.data( this, key, value ); + }) : + + // Gets one value + // Try to fetch any internally stored data first + elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined; + }, + + removeData: function( key ) { + return this.each(function() { + jQuery.removeData( this, key ); + }); + } +}); + + +jQuery.extend({ + queue: function( elem, type, data ) { + var queue; + + if ( elem ) { + type = ( type || "fx" ) + "queue"; + queue = jQuery._data( elem, type ); + + // Speed up dequeue by getting out quickly if this is just a lookup + if ( data ) { + if ( !queue || jQuery.isArray(data) ) { + queue = jQuery._data( elem, type, jQuery.makeArray(data) ); + } else { + queue.push( data ); + } + } + return queue || []; + } + }, + + dequeue: function( elem, type ) { + type = type || "fx"; + + var queue = jQuery.queue( elem, type ), + startLength = queue.length, + fn = queue.shift(), + hooks = jQuery._queueHooks( elem, type ), + next = function() { + jQuery.dequeue( elem, type ); + }; + + // If the fx queue is dequeued, always remove the progress sentinel + if ( fn === "inprogress" ) { + fn = queue.shift(); + startLength--; + } + + if ( fn ) { + + // Add a progress sentinel to prevent the fx queue from being + // automatically dequeued + if ( type === "fx" ) { + queue.unshift( "inprogress" ); + } + + // clear up the last queue stop function + delete hooks.stop; + fn.call( elem, next, hooks ); + } + + if ( !startLength && hooks ) { + hooks.empty.fire(); + } + }, + + // not intended for public consumption - generates a queueHooks object, or returns the current one + _queueHooks: function( elem, type ) { + var key = type + "queueHooks"; + return jQuery._data( elem, key ) || jQuery._data( elem, key, { + empty: jQuery.Callbacks("once memory").add(function() { + jQuery._removeData( elem, type + "queue" ); + jQuery._removeData( elem, key ); + }) + }); + } +}); + +jQuery.fn.extend({ + queue: function( type, data ) { + var setter = 2; + + if ( typeof type !== "string" ) { + data = type; + type = "fx"; + setter--; + } + + if ( arguments.length < setter ) { + return jQuery.queue( this[0], type ); + } + + return data === undefined ? + this : + this.each(function() { + var queue = jQuery.queue( this, type, data ); + + // ensure a hooks for this queue + jQuery._queueHooks( this, type ); + + if ( type === "fx" && queue[0] !== "inprogress" ) { + jQuery.dequeue( this, type ); + } + }); + }, + dequeue: function( type ) { + return this.each(function() { + jQuery.dequeue( this, type ); + }); + }, + 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, obj ) { + var tmp, + count = 1, + defer = jQuery.Deferred(), + elements = this, + i = this.length, + resolve = function() { + if ( !( --count ) ) { + defer.resolveWith( elements, [ elements ] ); + } + }; + + if ( typeof type !== "string" ) { + obj = type; + type = undefined; + } + type = type || "fx"; + + while ( i-- ) { + tmp = jQuery._data( elements[ i ], type + "queueHooks" ); + if ( tmp && tmp.empty ) { + count++; + tmp.empty.add( resolve ); + } + } + resolve(); + return defer.promise( obj ); + } +}); +var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source; + +var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; + +var isHidden = function( elem, el ) { + // isHidden might be called from jQuery#filter function; + // in that case, element will be second argument + elem = el || elem; + return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); + }; + + + +// Multifunctional method to get and set values of a collection +// The value/s can optionally be executed if it's a function +var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) { + var i = 0, + length = elems.length, + bulk = key == null; + + // Sets many values + if ( jQuery.type( key ) === "object" ) { + chainable = true; + for ( i in key ) { + jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); + } + + // Sets one value + } else if ( value !== undefined ) { + chainable = true; + + if ( !jQuery.isFunction( value ) ) { + raw = true; + } + + if ( bulk ) { + // Bulk operations run against the entire set + if ( raw ) { + fn.call( elems, value ); + fn = null; + + // ...except when executing function values + } else { + bulk = fn; + fn = function( elem, key, value ) { + return bulk.call( jQuery( elem ), value ); + }; + } + } + + if ( fn ) { + for ( ; i < length; i++ ) { + fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) ); + } + } + } + + return chainable ? + elems : + + // Gets + bulk ? + fn.call( elems ) : + length ? fn( elems[0], key ) : emptyGet; +}; +var rcheckableType = (/^(?:checkbox|radio)$/i); + + + +(function() { + // Minified: var a,b,c + var input = document.createElement( "input" ), + div = document.createElement( "div" ), + fragment = document.createDocumentFragment(); + + // Setup + div.innerHTML = "
    {% csrf_token %}
    ' + options.addText + "
    '+b.addText+"
    a"; + + // IE strips leading whitespace when .innerHTML is used + support.leadingWhitespace = div.firstChild.nodeType === 3; + + // Make sure that tbody elements aren't automatically inserted + // IE will insert them into empty tables + support.tbody = !div.getElementsByTagName( "tbody" ).length; + + // Make sure that link elements get serialized correctly by innerHTML + // This requires a wrapper element in IE + support.htmlSerialize = !!div.getElementsByTagName( "link" ).length; + + // Makes sure cloning an html5 element does not cause problems + // Where outerHTML is undefined, this still works + support.html5Clone = + document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav>"; + + // Check if a disconnected checkbox will retain its checked + // value of true after appended to the DOM (IE6/7) + input.type = "checkbox"; + input.checked = true; + fragment.appendChild( input ); + support.appendChecked = input.checked; + + // Make sure textarea (and checkbox) defaultValue is properly cloned + // Support: IE6-IE11+ + div.innerHTML = ""; + support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; + + // #11217 - WebKit loses check when the name is after the checked attribute + fragment.appendChild( div ); + div.innerHTML = ""; + + // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3 + // old WebKit doesn't clone checked state correctly in fragments + support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; + + // Support: IE<9 + // Opera does not clone events (and typeof div.attachEvent === undefined). + // IE9-10 clones events bound via attachEvent, but they don't trigger with .click() + support.noCloneEvent = true; + if ( div.attachEvent ) { + div.attachEvent( "onclick", function() { + support.noCloneEvent = false; + }); + + div.cloneNode( true ).click(); + } + + // Execute the test only if not already executed in another module. + if (support.deleteExpando == null) { + // Support: IE<9 + support.deleteExpando = true; + try { + delete div.test; + } catch( e ) { + support.deleteExpando = false; + } + } +})(); + + +(function() { + var i, eventName, + div = document.createElement( "div" ); + + // Support: IE<9 (lack submit/change bubble), Firefox 23+ (lack focusin event) + for ( i in { submit: true, change: true, focusin: true }) { + eventName = "on" + i; + + if ( !(support[ i + "Bubbles" ] = eventName in window) ) { + // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP) + div.setAttribute( eventName, "t" ); + support[ i + "Bubbles" ] = div.attributes[ eventName ].expando === false; + } + } + + // Null elements to avoid leaks in IE. + div = null; +})(); + + +var rformElems = /^(?:input|select|textarea)$/i, + rkeyEvent = /^key/, + rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/, + rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, + rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; + +function returnTrue() { + return true; +} + +function returnFalse() { + return false; +} + +function safeActiveElement() { + try { + return document.activeElement; + } catch ( err ) { } +} + +/* + * Helper functions for managing events -- not part of the public interface. + * Props to Dean Edwards' addEvent library for many of the ideas. + */ +jQuery.event = { + + global: {}, + + add: function( elem, types, handler, data, selector ) { + var tmp, events, t, handleObjIn, + special, eventHandle, handleObj, + handlers, type, namespaces, origType, + elemData = jQuery._data( elem ); + + // Don't attach events to noData or text/comment nodes (but allow plain objects) + if ( !elemData ) { + return; + } + + // Caller can pass in an object of custom data in lieu of the handler + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + selector = handleObjIn.selector; + } + + // Make sure that the handler has a unique ID, used to find/remove it later + if ( !handler.guid ) { + handler.guid = jQuery.guid++; + } + + // Init the element's event structure and main handler, if this is the first + if ( !(events = elemData.events) ) { + events = elemData.events = {}; + } + if ( !(eventHandle = elemData.handle) ) { + eventHandle = elemData.handle = 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 !== strundefined && (!e || jQuery.event.triggered !== e.type) ? + jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : + undefined; + }; + // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events + eventHandle.elem = elem; + } + + // Handle multiple events separated by a space + types = ( types || "" ).match( rnotwhite ) || [ "" ]; + t = types.length; + while ( t-- ) { + tmp = rtypenamespace.exec( types[t] ) || []; + type = origType = tmp[1]; + namespaces = ( tmp[2] || "" ).split( "." ).sort(); + + // There *must* be a type, no attaching namespace-only handlers + if ( !type ) { + continue; + } + + // If event changes its type, use the special event handlers for the changed type + special = jQuery.event.special[ type ] || {}; + + // If selector defined, determine special event api type, otherwise given type + type = ( selector ? special.delegateType : special.bindType ) || type; + + // Update special based on newly reset type + special = jQuery.event.special[ type ] || {}; + + // handleObj is passed to all event handlers + handleObj = jQuery.extend({ + type: type, + origType: origType, + data: data, + handler: handler, + guid: handler.guid, + selector: selector, + needsContext: selector && jQuery.expr.match.needsContext.test( selector ), + namespace: namespaces.join(".") + }, handleObjIn ); + + // Init the event handler queue if we're the first + if ( !(handlers = events[ type ]) ) { + handlers = events[ type ] = []; + handlers.delegateCount = 0; + + // 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 to the element's handler list, delegates in front + if ( selector ) { + handlers.splice( handlers.delegateCount++, 0, handleObj ); + } else { + handlers.push( handleObj ); + } + + // Keep track of which events have ever been used, for event optimization + jQuery.event.global[ type ] = true; + } + + // Nullify elem to prevent memory leaks in IE + elem = null; + }, + + // Detach an event or set of events from an element + remove: function( elem, types, handler, selector, mappedTypes ) { + var j, handleObj, tmp, + origCount, t, events, + special, handlers, type, + namespaces, origType, + elemData = jQuery.hasData( elem ) && jQuery._data( elem ); + + if ( !elemData || !(events = elemData.events) ) { + return; + } + + // Once for each type.namespace in types; type may be omitted + types = ( types || "" ).match( rnotwhite ) || [ "" ]; + t = types.length; + while ( t-- ) { + tmp = rtypenamespace.exec( types[t] ) || []; + type = origType = tmp[1]; + namespaces = ( tmp[2] || "" ).split( "." ).sort(); + + // Unbind all events (on this namespace, if provided) for the element + if ( !type ) { + for ( type in events ) { + jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); + } + continue; + } + + special = jQuery.event.special[ type ] || {}; + type = ( selector ? special.delegateType : special.bindType ) || type; + handlers = events[ type ] || []; + tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ); + + // Remove matching events + origCount = j = handlers.length; + while ( j-- ) { + handleObj = handlers[ j ]; + + if ( ( mappedTypes || origType === handleObj.origType ) && + ( !handler || handler.guid === handleObj.guid ) && + ( !tmp || tmp.test( handleObj.namespace ) ) && + ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { + handlers.splice( j, 1 ); + + if ( handleObj.selector ) { + handlers.delegateCount--; + } + if ( special.remove ) { + special.remove.call( elem, handleObj ); + } + } + } + + // Remove generic event handler if we removed something and no more handlers exist + // (avoids potential for endless recursion during removal of special event handlers) + if ( origCount && !handlers.length ) { + if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { + jQuery.removeEvent( elem, type, elemData.handle ); + } + + delete events[ type ]; + } + } + + // Remove the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + delete elemData.handle; + + // removeData also checks for emptiness and clears the expando if empty + // so use it instead of delete + jQuery._removeData( elem, "events" ); + } + }, + + trigger: function( event, data, elem, onlyHandlers ) { + var handle, ontype, cur, + bubbleType, special, tmp, i, + eventPath = [ elem || document ], + type = hasOwn.call( event, "type" ) ? event.type : event, + namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : []; + + cur = tmp = elem = elem || document; + + // Don't do events on text and comment nodes + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + return; + } + + // focus/blur morphs to focusin/out; ensure we're not firing them right now + if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { + return; + } + + if ( type.indexOf(".") >= 0 ) { + // Namespaced trigger; create a regexp to match event type in handle() + namespaces = type.split("."); + type = namespaces.shift(); + namespaces.sort(); + } + ontype = type.indexOf(":") < 0 && "on" + type; + + // Caller can pass in a jQuery.Event object, Object, or just an event type string + event = event[ jQuery.expando ] ? + event : + new jQuery.Event( type, typeof event === "object" && event ); + + // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) + event.isTrigger = onlyHandlers ? 2 : 3; + event.namespace = namespaces.join("."); + event.namespace_re = event.namespace ? + new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) : + null; + + // Clean up the event in case it is being reused + event.result = undefined; + if ( !event.target ) { + event.target = elem; + } + + // Clone any incoming data and prepend the event, creating the handler arg list + data = data == null ? + [ event ] : + jQuery.makeArray( data, [ event ] ); + + // Allow special events to draw outside the lines + special = jQuery.event.special[ type ] || {}; + if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { + return; + } + + // Determine event propagation path in advance, per W3C events spec (#9951) + // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) + if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { + + bubbleType = special.delegateType || type; + if ( !rfocusMorph.test( bubbleType + type ) ) { + cur = cur.parentNode; + } + for ( ; cur; cur = cur.parentNode ) { + eventPath.push( cur ); + tmp = cur; + } + + // Only add window if we got to document (e.g., not plain obj or detached DOM) + if ( tmp === (elem.ownerDocument || document) ) { + eventPath.push( tmp.defaultView || tmp.parentWindow || window ); + } + } + + // Fire handlers on the event path + i = 0; + while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) { + + event.type = i > 1 ? + bubbleType : + special.bindType || type; + + // jQuery handler + handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); + if ( handle ) { + handle.apply( cur, data ); + } + + // Native handler + handle = ontype && cur[ ontype ]; + if ( handle && handle.apply && jQuery.acceptData( cur ) ) { + event.result = handle.apply( cur, data ); + if ( event.result === false ) { + event.preventDefault(); + } + } + } + event.type = type; + + // If nobody prevented the default action, do it now + if ( !onlyHandlers && !event.isDefaultPrevented() ) { + + if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) && + 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. + // Don't do default actions on window, that's where global variables be (#6170) + if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) { + + // Don't re-trigger an onFOO event when we call its FOO() method + tmp = elem[ ontype ]; + + if ( tmp ) { + elem[ ontype ] = null; + } + + // Prevent re-triggering of the same event, since we already bubbled it above + jQuery.event.triggered = type; + try { + elem[ type ](); + } catch ( e ) { + // IE<9 dies on focus/blur to hidden element (#1486,#12518) + // only reproducible on winXP IE8 native, not IE9 in IE8 mode + } + jQuery.event.triggered = undefined; + + if ( tmp ) { + elem[ ontype ] = tmp; + } + } + } + } + + return event.result; + }, + + dispatch: function( event ) { + + // Make a writable jQuery.Event from the native event object + event = jQuery.event.fix( event ); + + var i, ret, handleObj, matched, j, + handlerQueue = [], + args = slice.call( arguments ), + handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [], + special = jQuery.event.special[ event.type ] || {}; + + // Use the fix-ed jQuery.Event rather than the (read-only) native event + args[0] = event; + event.delegateTarget = this; + + // Call the preDispatch hook for the mapped type, and let it bail if desired + if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { + return; + } + + // Determine handlers + handlerQueue = jQuery.event.handlers.call( this, event, handlers ); + + // Run delegates first; they may want to stop propagation beneath us + i = 0; + while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) { + event.currentTarget = matched.elem; + + j = 0; + while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) { + + // Triggered event must either 1) have no namespace, or + // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). + if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) { + + event.handleObj = handleObj; + event.data = handleObj.data; + + ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) + .apply( matched.elem, args ); + + if ( ret !== undefined ) { + if ( (event.result = ret) === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + } + } + } + + // Call the postDispatch hook for the mapped type + if ( special.postDispatch ) { + special.postDispatch.call( this, event ); + } + + return event.result; + }, + + handlers: function( event, handlers ) { + var sel, handleObj, matches, i, + handlerQueue = [], + delegateCount = handlers.delegateCount, + cur = event.target; + + // Find delegate handlers + // Black-hole SVG instance trees (#13180) + // Avoid non-left-click bubbling in Firefox (#3861) + if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) { + + /* jshint eqeqeq: false */ + for ( ; cur != this; cur = cur.parentNode || this ) { + /* jshint eqeqeq: true */ + + // Don't check non-elements (#13208) + // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) + if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) { + matches = []; + for ( i = 0; i < delegateCount; i++ ) { + handleObj = handlers[ i ]; + + // Don't conflict with Object.prototype properties (#13203) + sel = handleObj.selector + " "; + + if ( matches[ sel ] === undefined ) { + matches[ sel ] = handleObj.needsContext ? + jQuery( sel, this ).index( cur ) >= 0 : + jQuery.find( sel, this, null, [ cur ] ).length; + } + if ( matches[ sel ] ) { + matches.push( handleObj ); + } + } + if ( matches.length ) { + handlerQueue.push({ elem: cur, handlers: matches }); + } + } + } + } + + // Add the remaining (directly-bound) handlers + if ( delegateCount < handlers.length ) { + handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) }); + } + + return handlerQueue; + }, + + fix: function( event ) { + if ( event[ jQuery.expando ] ) { + return event; + } + + // Create a writable copy of the event object and normalize some properties + var i, prop, copy, + type = event.type, + originalEvent = event, + fixHook = this.fixHooks[ type ]; + + if ( !fixHook ) { + this.fixHooks[ type ] = fixHook = + rmouseEvent.test( type ) ? this.mouseHooks : + rkeyEvent.test( type ) ? this.keyHooks : + {}; + } + copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; + + event = new jQuery.Event( originalEvent ); + + i = copy.length; + while ( i-- ) { + prop = copy[ i ]; + event[ prop ] = originalEvent[ prop ]; + } + + // Support: IE<9 + // Fix target property (#1925) + if ( !event.target ) { + event.target = originalEvent.srcElement || document; + } + + // Support: Chrome 23+, Safari? + // Target should not be a text node (#504, #13143) + if ( event.target.nodeType === 3 ) { + event.target = event.target.parentNode; + } + + // Support: IE<9 + // For mouse/key events, metaKey==false if it's undefined (#3368, #11328) + event.metaKey = !!event.metaKey; + + return fixHook.filter ? fixHook.filter( event, originalEvent ) : event; + }, + + // Includes some event props shared by KeyEvent and MouseEvent + props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), + + fixHooks: {}, + + keyHooks: { + props: "char charCode key keyCode".split(" "), + filter: function( event, original ) { + + // Add which for key events + if ( event.which == null ) { + event.which = original.charCode != null ? original.charCode : original.keyCode; + } + + return event; + } + }, + + mouseHooks: { + props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), + filter: function( event, original ) { + var body, eventDoc, doc, + button = original.button, + fromElement = original.fromElement; + + // Calculate pageX/Y if missing and clientX/Y available + if ( event.pageX == null && original.clientX != null ) { + eventDoc = event.target.ownerDocument || document; + doc = eventDoc.documentElement; + body = eventDoc.body; + + event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); + event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); + } + + // Add relatedTarget, if necessary + if ( !event.relatedTarget && fromElement ) { + event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; + } + + // Add which for click: 1 === left; 2 === middle; 3 === right + // Note: button is not normalized, so don't use it + if ( !event.which && button !== undefined ) { + event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); + } + + return event; + } + }, + + special: { + load: { + // Prevent triggered image.load events from bubbling to window.load + noBubble: true + }, + focus: { + // Fire native event if possible so blur/focus sequence is correct + trigger: function() { + if ( this !== safeActiveElement() && this.focus ) { + try { + this.focus(); + return false; + } catch ( e ) { + // Support: IE<9 + // If we error on focus to hidden element (#1486, #12518), + // let .trigger() run the handlers + } + } + }, + delegateType: "focusin" + }, + blur: { + trigger: function() { + if ( this === safeActiveElement() && this.blur ) { + this.blur(); + return false; + } + }, + delegateType: "focusout" + }, + click: { + // For checkbox, fire native event so checked state will be right + trigger: function() { + if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) { + this.click(); + return false; + } + }, + + // For cross-browser consistency, don't fire native .click() on links + _default: function( event ) { + return jQuery.nodeName( event.target, "a" ); + } + }, + + beforeunload: { + postDispatch: function( event ) { + + // Support: Firefox 20+ + // Firefox doesn't alert if the returnValue field is not set. + if ( event.result !== undefined && event.originalEvent ) { + event.originalEvent.returnValue = event.result; + } + } + } + }, + + simulate: function( type, elem, event, bubble ) { + // 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. + var e = jQuery.extend( + new jQuery.Event(), + event, + { + type: type, + isSimulated: true, + originalEvent: {} + } + ); + if ( bubble ) { + jQuery.event.trigger( e, null, elem ); + } else { + jQuery.event.dispatch.call( elem, e ); + } + if ( e.isDefaultPrevented() ) { + event.preventDefault(); + } + } +}; + +jQuery.removeEvent = document.removeEventListener ? + function( elem, type, handle ) { + if ( elem.removeEventListener ) { + elem.removeEventListener( type, handle, false ); + } + } : + function( elem, type, handle ) { + var name = "on" + type; + + if ( elem.detachEvent ) { + + // #8545, #7054, preventing memory leaks for custom events in IE6-8 + // detachEvent needed property on element, by name of that event, to properly expose it to GC + if ( typeof elem[ name ] === strundefined ) { + elem[ name ] = null; + } + + elem.detachEvent( name, handle ); + } + }; + +jQuery.Event = function( src, props ) { + // Allow instantiation without the 'new' keyword + if ( !(this instanceof jQuery.Event) ) { + 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.defaultPrevented === undefined && + // Support: IE < 9, Android < 4.0 + src.returnValue === false ? + returnTrue : + returnFalse; + + // Event type + } else { + this.type = src; + } + + // Put explicitly provided properties onto the event object + if ( props ) { + jQuery.extend( this, props ); + } + + // Create a timestamp if incoming event doesn't have one + this.timeStamp = src && src.timeStamp || jQuery.now(); + + // Mark it as fixed + this[ jQuery.expando ] = 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 = { + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse, + + preventDefault: function() { + var e = this.originalEvent; + + this.isDefaultPrevented = returnTrue; + if ( !e ) { + return; + } + + // If preventDefault exists, run it on the original event + if ( e.preventDefault ) { + e.preventDefault(); + + // Support: IE + // Otherwise set the returnValue property of the original event to false + } else { + e.returnValue = false; + } + }, + stopPropagation: function() { + var e = this.originalEvent; + + this.isPropagationStopped = returnTrue; + if ( !e ) { + return; + } + // If stopPropagation exists, run it on the original event + if ( e.stopPropagation ) { + e.stopPropagation(); + } + + // Support: IE + // Set the cancelBubble property of the original event to true + e.cancelBubble = true; + }, + stopImmediatePropagation: function() { + var e = this.originalEvent; + + this.isImmediatePropagationStopped = returnTrue; + + if ( e && e.stopImmediatePropagation ) { + e.stopImmediatePropagation(); + } + + this.stopPropagation(); + } +}; + +// Create mouseenter/leave events using mouseover/out and event-time checks +jQuery.each({ + mouseenter: "mouseover", + mouseleave: "mouseout", + pointerenter: "pointerover", + pointerleave: "pointerout" +}, function( orig, fix ) { + jQuery.event.special[ orig ] = { + delegateType: fix, + bindType: fix, + + handle: function( event ) { + var ret, + target = this, + related = event.relatedTarget, + handleObj = event.handleObj; + + // For mousenter/leave call the handler if related is outside the target. + // NB: No relatedTarget if the mouse left/entered the browser window + if ( !related || (related !== target && !jQuery.contains( target, related )) ) { + event.type = handleObj.origType; + ret = handleObj.handler.apply( this, arguments ); + event.type = fix; + } + return ret; + } + }; +}); + +// IE submit delegation +if ( !support.submitBubbles ) { + + jQuery.event.special.submit = { + setup: function() { + // Only need this for delegated form submit events + if ( jQuery.nodeName( this, "form" ) ) { + return false; + } + + // Lazy-add a submit handler when a descendant form may potentially be submitted + jQuery.event.add( this, "click._submit keypress._submit", function( e ) { + // Node name check avoids a VML-related crash in IE (#9807) + var elem = e.target, + form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; + if ( form && !jQuery._data( form, "submitBubbles" ) ) { + jQuery.event.add( form, "submit._submit", function( event ) { + event._submit_bubble = true; + }); + jQuery._data( form, "submitBubbles", true ); + } + }); + // return undefined since we don't need an event listener + }, + + postDispatch: function( event ) { + // If form was submitted by the user, bubble the event up the tree + if ( event._submit_bubble ) { + delete event._submit_bubble; + if ( this.parentNode && !event.isTrigger ) { + jQuery.event.simulate( "submit", this.parentNode, event, true ); + } + } + }, + + teardown: function() { + // Only need this for delegated form submit events + if ( jQuery.nodeName( this, "form" ) ) { + return false; + } + + // Remove delegated handlers; cleanData eventually reaps submit handlers attached above + jQuery.event.remove( this, "._submit" ); + } + }; +} + +// IE change delegation and checkbox/radio fix +if ( !support.changeBubbles ) { + + jQuery.event.special.change = { + + setup: function() { + + if ( rformElems.test( this.nodeName ) ) { + // IE doesn't fire change on a check/radio until blur; trigger it on click + // after a propertychange. Eat the blur-change in special.change.handle. + // This still fires onchange a second time for check/radio after blur. + if ( this.type === "checkbox" || this.type === "radio" ) { + jQuery.event.add( this, "propertychange._change", function( event ) { + if ( event.originalEvent.propertyName === "checked" ) { + this._just_changed = true; + } + }); + jQuery.event.add( this, "click._change", function( event ) { + if ( this._just_changed && !event.isTrigger ) { + this._just_changed = false; + } + // Allow triggered, simulated change events (#11500) + jQuery.event.simulate( "change", this, event, true ); + }); + } + return false; + } + // Delegated event; lazy-add a change handler on descendant inputs + jQuery.event.add( this, "beforeactivate._change", function( e ) { + var elem = e.target; + + if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) { + jQuery.event.add( elem, "change._change", function( event ) { + if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { + jQuery.event.simulate( "change", this.parentNode, event, true ); + } + }); + jQuery._data( elem, "changeBubbles", true ); + } + }); + }, + + handle: function( event ) { + var elem = event.target; + + // Swallow native change events from checkbox/radio, we already triggered them above + if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { + return event.handleObj.handler.apply( this, arguments ); + } + }, + + teardown: function() { + jQuery.event.remove( this, "._change" ); + + return !rformElems.test( this.nodeName ); + } + }; +} + +// Create "bubbling" focus and blur events +if ( !support.focusinBubbles ) { + jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { + + // Attach a single capturing handler on the document while someone wants focusin/focusout + var handler = function( event ) { + jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); + }; + + jQuery.event.special[ fix ] = { + setup: function() { + var doc = this.ownerDocument || this, + attaches = jQuery._data( doc, fix ); + + if ( !attaches ) { + doc.addEventListener( orig, handler, true ); + } + jQuery._data( doc, fix, ( attaches || 0 ) + 1 ); + }, + teardown: function() { + var doc = this.ownerDocument || this, + attaches = jQuery._data( doc, fix ) - 1; + + if ( !attaches ) { + doc.removeEventListener( orig, handler, true ); + jQuery._removeData( doc, fix ); + } else { + jQuery._data( doc, fix, attaches ); + } + } + }; + }); +} + +jQuery.fn.extend({ + + on: function( types, selector, data, fn, /*INTERNAL*/ one ) { + var type, origFn; + + // Types can be a map of types/handlers + if ( typeof types === "object" ) { + // ( types-Object, selector, data ) + if ( typeof selector !== "string" ) { + // ( types-Object, data ) + data = data || selector; + selector = undefined; + } + for ( type in types ) { + this.on( type, selector, data, types[ type ], one ); + } + return this; + } + + if ( data == null && fn == null ) { + // ( types, fn ) + fn = selector; + data = selector = undefined; + } else if ( fn == null ) { + if ( typeof selector === "string" ) { + // ( types, selector, fn ) + fn = data; + data = undefined; + } else { + // ( types, data, fn ) + fn = data; + data = selector; + selector = undefined; + } + } + if ( fn === false ) { + fn = returnFalse; + } else if ( !fn ) { + return this; + } + + if ( one === 1 ) { + origFn = fn; + fn = function( event ) { + // Can use an empty set, since event contains the info + jQuery().off( event ); + return origFn.apply( this, arguments ); + }; + // Use same guid so caller can remove using origFn + fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); + } + return this.each( function() { + jQuery.event.add( this, types, fn, data, selector ); + }); + }, + one: function( types, selector, data, fn ) { + return this.on( types, selector, data, fn, 1 ); + }, + off: function( types, selector, fn ) { + var handleObj, type; + if ( types && types.preventDefault && types.handleObj ) { + // ( event ) dispatched jQuery.Event + handleObj = types.handleObj; + jQuery( types.delegateTarget ).off( + handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, + handleObj.selector, + handleObj.handler + ); + return this; + } + if ( typeof types === "object" ) { + // ( types-object [, selector] ) + for ( type in types ) { + this.off( type, selector, types[ type ] ); + } + return this; + } + if ( selector === false || typeof selector === "function" ) { + // ( types [, fn] ) + fn = selector; + selector = undefined; + } + if ( fn === false ) { + fn = returnFalse; + } + return this.each(function() { + jQuery.event.remove( this, types, fn, selector ); + }); + }, + + trigger: function( type, data ) { + return this.each(function() { + jQuery.event.trigger( type, data, this ); + }); + }, + triggerHandler: function( type, data ) { + var elem = this[0]; + if ( elem ) { + return jQuery.event.trigger( type, data, elem, true ); + } + } +}); + + +function createSafeFragment( document ) { + var list = nodeNames.split( "|" ), + safeFrag = document.createDocumentFragment(); + + if ( safeFrag.createElement ) { + while ( list.length ) { + safeFrag.createElement( + list.pop() + ); + } + } + return safeFrag; +} + +var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" + + "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", + rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g, + rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"), + rleadingWhitespace = /^\s+/, + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, + rtagName = /<([\w:]+)/, + rtbody = /\s*$/g, + + // We have to close these tags to support XHTML (#13200) + wrapMap = { + option: [ 1, "" ], + legend: [ 1, "
    ", "
    " ], + area: [ 1, "", "" ], + param: [ 1, "", "" ], + thead: [ 1, "", "
    " ], + tr: [ 2, "", "
    " ], + col: [ 2, "", "
    " ], + td: [ 3, "", "
    " ], + + // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags, + // unless wrapped in a div with non-breaking characters in front of it. + _default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X
    ", "
    " ] + }, + safeFragment = createSafeFragment( document ), + fragmentDiv = safeFragment.appendChild( document.createElement("div") ); + +wrapMap.optgroup = wrapMap.option; +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; +wrapMap.th = wrapMap.td; + +function getAll( context, tag ) { + var elems, elem, + i = 0, + found = typeof context.getElementsByTagName !== strundefined ? context.getElementsByTagName( tag || "*" ) : + typeof context.querySelectorAll !== strundefined ? context.querySelectorAll( tag || "*" ) : + undefined; + + if ( !found ) { + for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) { + if ( !tag || jQuery.nodeName( elem, tag ) ) { + found.push( elem ); + } else { + jQuery.merge( found, getAll( elem, tag ) ); + } + } + } + + return tag === undefined || tag && jQuery.nodeName( context, tag ) ? + jQuery.merge( [ context ], found ) : + found; +} + +// Used in buildFragment, fixes the defaultChecked property +function fixDefaultChecked( elem ) { + if ( rcheckableType.test( elem.type ) ) { + elem.defaultChecked = elem.checked; + } +} + +// Support: IE<8 +// Manipulating tables requires a tbody +function manipulationTarget( elem, content ) { + return jQuery.nodeName( elem, "table" ) && + jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ? + + elem.getElementsByTagName("tbody")[0] || + elem.appendChild( elem.ownerDocument.createElement("tbody") ) : + elem; +} + +// Replace/restore the type attribute of script elements for safe DOM manipulation +function disableScript( elem ) { + elem.type = (jQuery.find.attr( elem, "type" ) !== null) + "/" + elem.type; + return elem; +} +function restoreScript( elem ) { + var match = rscriptTypeMasked.exec( elem.type ); + if ( match ) { + elem.type = match[1]; + } else { + elem.removeAttribute("type"); + } + return elem; +} + +// Mark scripts as having already been evaluated +function setGlobalEval( elems, refElements ) { + var elem, + i = 0; + for ( ; (elem = elems[i]) != null; i++ ) { + jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) ); + } +} + +function cloneCopyEvent( src, dest ) { + + if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) { + return; + } + + var type, i, l, + oldData = jQuery._data( src ), + curData = jQuery._data( dest, oldData ), + events = oldData.events; + + if ( events ) { + delete curData.handle; + curData.events = {}; + + for ( type in events ) { + for ( i = 0, l = events[ type ].length; i < l; i++ ) { + jQuery.event.add( dest, type, events[ type ][ i ] ); + } + } + } + + // make the cloned public data object a copy from the original + if ( curData.data ) { + curData.data = jQuery.extend( {}, curData.data ); + } +} + +function fixCloneNodeIssues( src, dest ) { + var nodeName, e, data; + + // We do not need to do anything for non-Elements + if ( dest.nodeType !== 1 ) { + return; + } + + nodeName = dest.nodeName.toLowerCase(); + + // IE6-8 copies events bound via attachEvent when using cloneNode. + if ( !support.noCloneEvent && dest[ jQuery.expando ] ) { + data = jQuery._data( dest ); + + for ( e in data.events ) { + jQuery.removeEvent( dest, e, data.handle ); + } + + // Event data gets referenced instead of copied if the expando gets copied too + dest.removeAttribute( jQuery.expando ); + } + + // IE blanks contents when cloning scripts, and tries to evaluate newly-set text + if ( nodeName === "script" && dest.text !== src.text ) { + disableScript( dest ).text = src.text; + restoreScript( dest ); + + // IE6-10 improperly clones children of object elements using classid. + // IE10 throws NoModificationAllowedError if parent is null, #12132. + } else if ( nodeName === "object" ) { + if ( dest.parentNode ) { + dest.outerHTML = src.outerHTML; + } + + // This path appears unavoidable for IE9. When cloning an object + // element in IE9, the outerHTML strategy above is not sufficient. + // If the src has innerHTML and the destination does not, + // copy the src.innerHTML into the dest.innerHTML. #10324 + if ( support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) { + dest.innerHTML = src.innerHTML; + } + + } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) { + // IE6-8 fails to persist the checked state of a cloned checkbox + // or radio button. Worse, IE6-7 fail to give the cloned element + // a checked appearance if the defaultChecked value isn't also set + + dest.defaultChecked = dest.checked = src.checked; + + // IE6-7 get confused and end up setting the value of a cloned + // checkbox/radio button to an empty string instead of "on" + if ( dest.value !== src.value ) { + dest.value = src.value; + } + + // IE6-8 fails to return the selected option to the default selected + // state when cloning options + } else if ( nodeName === "option" ) { + dest.defaultSelected = dest.selected = src.defaultSelected; + + // IE6-8 fails to set the defaultValue to the correct value when + // cloning other types of input fields + } else if ( nodeName === "input" || nodeName === "textarea" ) { + dest.defaultValue = src.defaultValue; + } +} + +jQuery.extend({ + clone: function( elem, dataAndEvents, deepDataAndEvents ) { + var destElements, node, clone, i, srcElements, + inPage = jQuery.contains( elem.ownerDocument, elem ); + + if ( support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) { + clone = elem.cloneNode( true ); + + // IE<=8 does not properly clone detached, unknown element nodes + } else { + fragmentDiv.innerHTML = elem.outerHTML; + fragmentDiv.removeChild( clone = fragmentDiv.firstChild ); + } + + if ( (!support.noCloneEvent || !support.noCloneChecked) && + (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { + + // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 + destElements = getAll( clone ); + srcElements = getAll( elem ); + + // Fix all IE cloning issues + for ( i = 0; (node = srcElements[i]) != null; ++i ) { + // Ensure that the destination node is not null; Fixes #9587 + if ( destElements[i] ) { + fixCloneNodeIssues( node, destElements[i] ); + } + } + } + + // Copy the events from the original to the clone + if ( dataAndEvents ) { + if ( deepDataAndEvents ) { + srcElements = srcElements || getAll( elem ); + destElements = destElements || getAll( clone ); + + for ( i = 0; (node = srcElements[i]) != null; i++ ) { + cloneCopyEvent( node, destElements[i] ); + } + } else { + cloneCopyEvent( elem, clone ); + } + } + + // Preserve script evaluation history + destElements = getAll( clone, "script" ); + if ( destElements.length > 0 ) { + setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); + } + + destElements = srcElements = node = null; + + // Return the cloned set + return clone; + }, + + buildFragment: function( elems, context, scripts, selection ) { + var j, elem, contains, + tmp, tag, tbody, wrap, + l = elems.length, + + // Ensure a safe fragment + safe = createSafeFragment( context ), + + nodes = [], + i = 0; + + for ( ; i < l; i++ ) { + elem = elems[ i ]; + + if ( elem || elem === 0 ) { + + // Add nodes directly + if ( jQuery.type( elem ) === "object" ) { + jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); + + // Convert non-html into a text node + } else if ( !rhtml.test( elem ) ) { + nodes.push( context.createTextNode( elem ) ); + + // Convert html into DOM nodes + } else { + tmp = tmp || safe.appendChild( context.createElement("div") ); + + // Deserialize a standard representation + tag = (rtagName.exec( elem ) || [ "", "" ])[ 1 ].toLowerCase(); + wrap = wrapMap[ tag ] || wrapMap._default; + + tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1>" ) + wrap[2]; + + // Descend through wrappers to the right content + j = wrap[0]; + while ( j-- ) { + tmp = tmp.lastChild; + } + + // Manually add leading whitespace removed by IE + if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { + nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) ); + } + + // Remove IE's autoinserted from table fragments + if ( !support.tbody ) { + + // String was a , *may* have spurious + elem = tag === "table" && !rtbody.test( elem ) ? + tmp.firstChild : + + // String was a bare or + wrap[1] === "
    " && !rtbody.test( elem ) ? + tmp : + 0; + + j = elem && elem.childNodes.length; + while ( j-- ) { + if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) { + elem.removeChild( tbody ); + } + } + } + + jQuery.merge( nodes, tmp.childNodes ); + + // Fix #12392 for WebKit and IE > 9 + tmp.textContent = ""; + + // Fix #12392 for oldIE + while ( tmp.firstChild ) { + tmp.removeChild( tmp.firstChild ); + } + + // Remember the top-level container for proper cleanup + tmp = safe.lastChild; + } + } + } + + // Fix #11356: Clear elements from fragment + if ( tmp ) { + safe.removeChild( tmp ); + } + + // Reset defaultChecked for any radios and checkboxes + // about to be appended to the DOM in IE 6/7 (#8060) + if ( !support.appendChecked ) { + jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked ); + } + + i = 0; + while ( (elem = nodes[ i++ ]) ) { + + // #4087 - If origin and destination elements are the same, and this is + // that element, do not do anything + if ( selection && jQuery.inArray( elem, selection ) !== -1 ) { + continue; + } + + contains = jQuery.contains( elem.ownerDocument, elem ); + + // Append to fragment + tmp = getAll( safe.appendChild( elem ), "script" ); + + // Preserve script evaluation history + if ( contains ) { + setGlobalEval( tmp ); + } + + // Capture executables + if ( scripts ) { + j = 0; + while ( (elem = tmp[ j++ ]) ) { + if ( rscriptType.test( elem.type || "" ) ) { + scripts.push( elem ); + } + } + } + } + + tmp = null; + + return safe; + }, + + cleanData: function( elems, /* internal */ acceptData ) { + var elem, type, id, data, + i = 0, + internalKey = jQuery.expando, + cache = jQuery.cache, + deleteExpando = support.deleteExpando, + special = jQuery.event.special; + + for ( ; (elem = elems[i]) != null; i++ ) { + if ( acceptData || jQuery.acceptData( elem ) ) { + + id = elem[ internalKey ]; + data = id && cache[ id ]; + + if ( data ) { + if ( data.events ) { + for ( type in data.events ) { + if ( special[ type ] ) { + jQuery.event.remove( elem, type ); + + // This is a shortcut to avoid jQuery.event.remove's overhead + } else { + jQuery.removeEvent( elem, type, data.handle ); + } + } + } + + // Remove cache only if it was not already removed by jQuery.event.remove + if ( cache[ id ] ) { + + delete cache[ id ]; + + // 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 ( deleteExpando ) { + delete elem[ internalKey ]; + + } else if ( typeof elem.removeAttribute !== strundefined ) { + elem.removeAttribute( internalKey ); + + } else { + elem[ internalKey ] = null; + } + + deletedIds.push( id ); + } + } + } + } + } +}); + +jQuery.fn.extend({ + text: function( value ) { + return access( this, function( value ) { + return value === undefined ? + jQuery.text( this ) : + this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) ); + }, null, value, arguments.length ); + }, + + append: function() { + return this.domManip( arguments, function( elem ) { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + var target = manipulationTarget( this, elem ); + target.appendChild( elem ); + } + }); + }, + + prepend: function() { + return this.domManip( arguments, function( elem ) { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + var target = manipulationTarget( this, elem ); + target.insertBefore( elem, target.firstChild ); + } + }); + }, + + before: function() { + return this.domManip( arguments, function( elem ) { + if ( this.parentNode ) { + this.parentNode.insertBefore( elem, this ); + } + }); + }, + + after: function() { + return this.domManip( arguments, function( elem ) { + if ( this.parentNode ) { + this.parentNode.insertBefore( elem, this.nextSibling ); + } + }); + }, + + remove: function( selector, keepData /* Internal Use Only */ ) { + var elem, + elems = selector ? jQuery.filter( selector, this ) : this, + i = 0; + + for ( ; (elem = elems[i]) != null; i++ ) { + + if ( !keepData && elem.nodeType === 1 ) { + jQuery.cleanData( getAll( elem ) ); + } + + if ( elem.parentNode ) { + if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) { + setGlobalEval( getAll( elem, "script" ) ); + } + elem.parentNode.removeChild( elem ); + } + } + + return this; + }, + + empty: function() { + var elem, + i = 0; + + for ( ; (elem = this[i]) != null; i++ ) { + // Remove element nodes and prevent memory leaks + if ( elem.nodeType === 1 ) { + jQuery.cleanData( getAll( elem, false ) ); + } + + // Remove any remaining nodes + while ( elem.firstChild ) { + elem.removeChild( elem.firstChild ); + } + + // If this is a select, ensure that it displays empty (#12336) + // Support: IE<9 + if ( elem.options && jQuery.nodeName( elem, "select" ) ) { + elem.options.length = 0; + } + } + + return this; + }, + + clone: function( dataAndEvents, deepDataAndEvents ) { + dataAndEvents = dataAndEvents == null ? false : dataAndEvents; + deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; + + return this.map(function() { + return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); + }); + }, + + html: function( value ) { + return access( this, function( value ) { + var elem = this[ 0 ] || {}, + i = 0, + l = this.length; + + if ( value === undefined ) { + return elem.nodeType === 1 ? + elem.innerHTML.replace( rinlinejQuery, "" ) : + undefined; + } + + // See if we can take a shortcut and just use innerHTML + if ( typeof value === "string" && !rnoInnerhtml.test( value ) && + ( support.htmlSerialize || !rnoshimcache.test( value ) ) && + ( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) && + !wrapMap[ (rtagName.exec( value ) || [ "", "" ])[ 1 ].toLowerCase() ] ) { + + value = value.replace( rxhtmlTag, "<$1>" ); + + try { + for (; i < l; i++ ) { + // Remove element nodes and prevent memory leaks + elem = this[i] || {}; + if ( elem.nodeType === 1 ) { + jQuery.cleanData( getAll( elem, false ) ); + elem.innerHTML = value; + } + } + + elem = 0; + + // If using innerHTML throws an exception, use the fallback method + } catch(e) {} + } + + if ( elem ) { + this.empty().append( value ); + } + }, null, value, arguments.length ); + }, + + replaceWith: function() { + var arg = arguments[ 0 ]; + + // Make the changes, replacing each context element with the new content + this.domManip( arguments, function( elem ) { + arg = this.parentNode; + + jQuery.cleanData( getAll( this ) ); + + if ( arg ) { + arg.replaceChild( elem, this ); + } + }); + + // Force removal if there was no new content (e.g., from empty arguments) + return arg && (arg.length || arg.nodeType) ? this : this.remove(); + }, + + detach: function( selector ) { + return this.remove( selector, true ); + }, + + domManip: function( args, callback ) { + + // Flatten any nested arrays + args = concat.apply( [], args ); + + var first, node, hasScripts, + scripts, doc, fragment, + i = 0, + l = this.length, + set = this, + iNoClone = l - 1, + value = args[0], + isFunction = jQuery.isFunction( value ); + + // We can't cloneNode fragments that contain checked, in WebKit + if ( isFunction || + ( l > 1 && typeof value === "string" && + !support.checkClone && rchecked.test( value ) ) ) { + return this.each(function( index ) { + var self = set.eq( index ); + if ( isFunction ) { + args[0] = value.call( this, index, self.html() ); + } + self.domManip( args, callback ); + }); + } + + if ( l ) { + fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this ); + first = fragment.firstChild; + + if ( fragment.childNodes.length === 1 ) { + fragment = first; + } + + if ( first ) { + scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); + hasScripts = scripts.length; + + // Use the original fragment for the last item instead of the first because it can end up + // being emptied incorrectly in certain situations (#8070). + for ( ; i < l; i++ ) { + node = fragment; + + if ( i !== iNoClone ) { + node = jQuery.clone( node, true, true ); + + // Keep references to cloned scripts for later restoration + if ( hasScripts ) { + jQuery.merge( scripts, getAll( node, "script" ) ); + } + } + + callback.call( this[i], node, i ); + } + + if ( hasScripts ) { + doc = scripts[ scripts.length - 1 ].ownerDocument; + + // Reenable scripts + jQuery.map( scripts, restoreScript ); + + // Evaluate executable scripts on first document insertion + for ( i = 0; i < hasScripts; i++ ) { + node = scripts[ i ]; + if ( rscriptType.test( node.type || "" ) && + !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) { + + if ( node.src ) { + // Optional AJAX dependency, but won't run scripts if not present + if ( jQuery._evalUrl ) { + jQuery._evalUrl( node.src ); + } + } else { + jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) ); + } + } + } + } + + // Fix #11809: Avoid leaking memory + fragment = first = null; + } + } + + return this; + } +}); + +jQuery.each({ + appendTo: "append", + prependTo: "prepend", + insertBefore: "before", + insertAfter: "after", + replaceAll: "replaceWith" +}, function( name, original ) { + jQuery.fn[ name ] = function( selector ) { + var elems, + i = 0, + ret = [], + insert = jQuery( selector ), + last = insert.length - 1; + + for ( ; i <= last; i++ ) { + elems = i === last ? this : this.clone(true); + jQuery( insert[i] )[ original ]( elems ); + + // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get() + push.apply( ret, elems.get() ); + } + + return this.pushStack( ret ); + }; +}); + + +var iframe, + elemdisplay = {}; + +/** + * Retrieve the actual display of a element + * @param {String} name nodeName of the element + * @param {Object} doc Document object + */ +// Called only from within defaultDisplay +function actualDisplay( name, doc ) { + var style, + elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), + + // getDefaultComputedStyle might be reliably used only on attached element + display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ? + + // Use of this method is a temporary fix (more like optmization) until something better comes along, + // since it was removed from specification and supported only in FF + style.display : jQuery.css( elem[ 0 ], "display" ); + + // We don't have any data stored on the element, + // so use "detach" method as fast way to get rid of the element + elem.detach(); + + return display; +} + +/** + * Try to determine the default display value of an element + * @param {String} nodeName + */ +function defaultDisplay( nodeName ) { + var doc = document, + display = elemdisplay[ nodeName ]; + + if ( !display ) { + display = actualDisplay( nodeName, doc ); + + // If the simple way fails, read from inside an iframe + if ( display === "none" || !display ) { + + // Use the already-created iframe if possible + iframe = (iframe || jQuery( "