diff options
author | John McLear <john@mclear.co.uk> | 2013-03-05 13:39:53 +0000 |
---|---|---|
committer | John McLear <john@mclear.co.uk> | 2013-03-05 13:39:53 +0000 |
commit | cb2d148734a797636778d92237a736b659bae474 (patch) | |
tree | 6c63f0e5c4fae215946bbd79dc898383bb8417ee /src | |
parent | 7a0ad3235a5d97a4a4c0a677bd480da7bfac0721 (diff) | |
parent | 2b5cb2989c3cee71ee10955bb5ff08a253ec66af (diff) | |
download | etherpad-lite-cb2d148734a797636778d92237a736b659bae474.zip |
Merge branch 'release/1.2.8'
Diffstat (limited to 'src')
76 files changed, 6889 insertions, 6572 deletions
diff --git a/src/README.md b/src/README.md new file mode 100644 index 00000000..80109965 --- /dev/null +++ b/src/README.md @@ -0,0 +1 @@ +Ignore this file and see the file in the base installation folder diff --git a/src/locales/bn.json b/src/locales/bn.json index dba1c215..2d12528b 100644 --- a/src/locales/bn.json +++ b/src/locales/bn.json @@ -2,26 +2,60 @@ "@metadata": { "authors": [ "Bellayet", - "Nasir8891" + "Nasir8891", + "Sankarshan" ] }, "index.newPad": "\u09a8\u09a4\u09c1\u09a8 \u09aa\u09cd\u09af\u09be\u09a1", "index.createOpenPad": "\u0985\u09a5\u09ac\u09be \u09a8\u09be\u09ae \u09b2\u09bf\u0996\u09c7 \u09aa\u09cd\u09af\u09be\u09a1 \u0996\u09c1\u09b2\u09c1\u09a8\/\u09a4\u09c8\u09b0\u09c0 \u0995\u09b0\u09c1\u09a8:", "pad.toolbar.bold.title": "\u0997\u09be\u09a1\u09bc \u0995\u09b0\u09be (Ctrl-B)", "pad.toolbar.italic.title": "\u09ac\u09be\u0981\u0995\u09be \u0995\u09b0\u09be (Ctrl-I)", + "pad.toolbar.underline.title": "\u0986\u09a8\u09cd\u09a1\u09be\u09b0\u09b2\u09be\u0987\u09a8 (Ctrl-U)", + "pad.toolbar.ol.title": "\u09b8\u09be\u09b0\u09bf\u09ac\u09a6\u09cd\u09a7 \u09a4\u09be\u09b2\u09bf\u0995\u09be", "pad.toolbar.indent.title": "\u09aa\u09cd\u09b0\u09be\u09a8\u09cd\u09a4\u09bf\u0995\u0995\u09b0\u09a3", + "pad.toolbar.unindent.title": "\u0986\u0989\u099f\u09a1\u09c7\u09a8\u09cd\u099f", + "pad.toolbar.undo.title": "\u09ac\u09be\u09a4\u09bf\u09b2 \u0995\u09b0\u09c1\u09a8 (Ctrl-Z)", + "pad.toolbar.redo.title": "\u09aa\u09c1\u09a8\u09b0\u09be\u09af\u09bc \u0995\u09b0\u09c1\u09a8 (Ctrl-Y)", + "pad.toolbar.clearAuthorship.title": "\u0995\u09c3\u09a4\u09bf \u09b0\u0982 \u09aa\u09b0\u09bf\u09b7\u09cd\u0995\u09be\u09b0 \u0995\u09b0\u09c1\u09a8", + "pad.toolbar.timeslider.title": "\u099f\u09be\u0987\u09ae\u09b8\u09cd\u09b2\u09be\u0987\u09a1\u09be\u09b0", + "pad.toolbar.savedRevision.title": "\u09b8\u0982\u09b8\u09cd\u0995\u09b0\u09a3 \u09b8\u0982\u09b0\u0995\u09cd\u09b7\u09a3 \u0995\u09b0\u09c1\u09a8", "pad.toolbar.settings.title": "\u09b8\u09c7\u099f\u09bf\u0982", + "pad.toolbar.embed.title": "\u098f\u0987 \u09aa\u09cd\u09af\u09be\u09a1-\u099f\u09bf \u098f\u09ae\u09cd\u09ac\u09c7\u09a1 \u0995\u09b0\u09c1\u09a8", + "pad.toolbar.showusers.title": "\u098f\u0987 \u09aa\u09cd\u09af\u09be\u09a1\u09c7\u09b0 \u09ac\u09cd\u09af\u09ac\u09b9\u09be\u09b0\u0995\u09be\u09b0\u09c0\u09a6\u09c7\u09b0 \u09a6\u09c7\u0996\u09be\u09a8", "pad.colorpicker.save": "\u09b8\u0982\u09b0\u0995\u09cd\u09b7\u09a3", "pad.colorpicker.cancel": "\u09ac\u09be\u09a4\u09bf\u09b2", "pad.loading": "\u09b2\u09cb\u09a1\u09bf\u0982...", + "pad.passwordRequired": "\u098f\u0987 \u09aa\u09cd\u09af\u09be\u09a1-\u099f\u09bf \u09a6\u09c7\u0996\u09be\u09b0 \u099c\u09a8\u09cd\u09af \u0986\u09aa\u09a8\u09be\u0995\u09c7 \u09aa\u09be\u09b8\u0993\u09af\u09bc\u09be\u09b0\u09cd\u09a1 \u09ac\u09cd\u09af\u09ac\u09b9\u09be\u09b0 \u0995\u09b0\u09a4\u09c7 \u09b9\u09ac\u09c7", + "pad.permissionDenied": "\u09a6\u09c1\u0983\u0996\u09bf\u09a4, \u098f \u09aa\u09cd\u09af\u09be\u09a1-\u099f\u09bf \u09a6\u09c7\u0996\u09be\u09b0 \u0985\u09a7\u09bf\u0995\u09be\u09b0 \u0986\u09aa\u09a8\u09be\u09b0 \u09a8\u09c7\u0987", + "pad.wrongPassword": "\u0986\u09aa\u09a8\u09be\u09b0 \u09aa\u09be\u09b8\u0993\u09af\u09bc\u09be\u09b0\u09cd\u09a1 \u09b8\u09a0\u09bf\u0995 \u09a8\u09af\u09bc", + "pad.settings.padSettings": "\u09aa\u09cd\u09af\u09be\u09a1\u09c7\u09b0 \u09b8\u09cd\u09a5\u09be\u09aa\u09a8", + "pad.settings.myView": "\u0986\u09ae\u09be\u09b0 \u09a6\u09c3\u09b6\u09cd\u09af", + "pad.settings.stickychat": "\u099a\u09cd\u09af\u09be\u099f \u09b8\u0995\u09cd\u09b0\u09c0\u09a8\u09c7 \u09aa\u09cd\u09b0\u09a6\u09b0\u09cd\u09b6\u09a8 \u0995\u09b0\u09be \u09b9\u09ac\u09c7", + "pad.settings.colorcheck": "\u09b2\u09c7\u0996\u0995\u09a6\u09c7\u09b0 \u09a8\u09bf\u099c\u09b8\u09cd\u09ac \u09a8\u09bf\u09b0\u09cd\u09ac\u09be\u099a\u09bf\u09a4 \u09b0\u0982", + "pad.settings.linenocheck": "\u09b2\u09be\u0987\u09a8 \u09a8\u09ae\u09cd\u09ac\u09b0", + "pad.settings.fontType": "\u09ab\u09a8\u09cd\u099f-\u098f\u09b0 \u09aa\u09cd\u09b0\u0995\u09be\u09b0:", "pad.settings.fontType.normal": "\u09b8\u09be\u09a7\u09be\u09b0\u09a3", + "pad.settings.fontType.monospaced": "Monospace", + "pad.settings.globalView": "\u09b8\u09b0\u09cd\u09ac\u09ac\u09cd\u09af\u09be\u09aa\u09c0 \u09a6\u09c3\u09b6\u09cd\u09af", "pad.settings.language": "\u09ad\u09be\u09b7\u09be:", + "pad.importExport.import_export": "\u0987\u09ae\u09cd\u09aa\u09cb\u09b0\u099f\/\u098f\u0995\u09cd\u09b8\u09aa\u09cb\u09b0\u09cd\u099f", + "pad.importExport.import": "\u0995\u09cb\u09a8 \u099f\u09c7\u0995\u09cd\u09b8\u099f \u09ab\u09be\u0987\u09b2 \u09ac\u09be \u09a1\u0995\u09c1\u09ae\u09c7\u09a8\u09cd\u099f \u0986\u09aa\u09b2\u09cb\u09a1 \u0995\u09b0\u09c1\u09a8", + "pad.importExport.importSuccessful": "\u09b8\u09ab\u09b2!", "pad.importExport.export": "\u098f\u0987 \u09aa\u09cd\u09af\u09be\u09a1\u099f\u09bf \u098f\u0995\u09cd\u09b8\u09aa\u09cb\u09b0\u09cd\u099f \u0995\u09b0\u09c1\u09a8", "pad.importExport.exporthtml": "\u098f\u0987\u099a\u099f\u09bf\u098f\u09ae\u098f\u09b2", "pad.importExport.exportplain": "\u09b8\u09be\u09a7\u09be\u09b0\u09a3 \u09b2\u09c7\u0996\u09be", "pad.importExport.exportword": "\u09ae\u09be\u0987\u0995\u09cd\u09b0\u09cb\u09b8\u09ab\u099f \u0993\u09af\u09bc\u09be\u09b0\u09cd\u09a1", "pad.importExport.exportpdf": "\u09aa\u09bf\u09a1\u09bf\u098f\u09ab", "pad.importExport.exportopen": "\u0993\u09a1\u09bf\u098f\u09ab (\u0993\u09aa\u09c7\u09a8 \u09a1\u0995\u09c1\u09ae\u09c7\u09a8\u09cd\u099f \u09ab\u09b0\u09ae\u09cd\u09af\u09be\u099f)", + "pad.importExport.exportdokuwiki": "DokuWiki", + "pad.modals.connected": "\u09af\u09cb\u0997\u09be\u09af\u09cb\u0997 \u09b8\u09ab\u09b2", + "pad.modals.reconnecting": "\u0986\u09aa\u09a8\u09be\u09b0 \u09aa\u09cd\u09af\u09be\u09a1\u09c7\u09b0 \u09b8\u09be\u09a5\u09c7 \u09b8\u0982\u09af\u09cb\u0997\u09b8\u09cd\u09a5\u09be\u09aa\u09a8 \u0995\u09b0\u09be \u09b9\u099a\u09cd\u099b\u09c7..", + "pad.modals.forcereconnect": "\u09aa\u09c1\u09a8\u09b0\u09be\u09af\u09bc \u09b8\u0982\u09af\u09cb\u0997\u09b8\u09cd\u09a5\u09be\u09aa\u09a8\u09c7\u09b0 \u099a\u09c7\u09b7\u09cd\u099f\u09be", + "pad.modals.userdup": "\u0985\u09a8\u09cd\u09af \u0989\u0987\u09a8\u09cd\u09a1\u09cb-\u09a4\u09c7 \u0996\u09cb\u09b2\u09be \u09b9\u09af\u09bc\u09c7\u099b\u09c7", + "pad.modals.unauth": "\u0986\u09aa\u09a8\u09be\u09b0 \u0985\u09a7\u09bf\u0995\u09be\u09b0 \u09a8\u09c7\u0987", + "pad.modals.looping": "\u09af\u09cb\u0997\u09be\u09af\u09cb\u0997 \u09ac\u09bf\u099a\u09cd\u099b\u09bf\u09a8\u09cd\u09a8", + "pad.modals.initsocketfail": "\u09b8\u09be\u09b0\u09cd\u09ad\u09be\u09b0-\u098f\u09b0 \u09b8\u09be\u09a5\u09c7 \u09af\u09cb\u0997\u09be\u09af\u09cb\u0997 \u0995\u09b0\u09a4\u09c7 \u0985\u09b8\u0995\u09cd\u09b7\u09ae\u0964", + "pad.modals.slowcommit": "\u09af\u09cb\u0997\u09be\u09af\u09cb\u0997 \u09ac\u09bf\u099a\u09cd\u099b\u09bf\u09a8\u09cd\u09a8", "pad.modals.deleted": "\u0985\u09aa\u09b8\u09be\u09b0\u09bf\u09a4\u0964", "pad.modals.deleted.explanation": "\u098f\u0987 \u09aa\u09cd\u09af\u09be\u09a1\u099f\u09bf \u0985\u09aa\u09b8\u09be\u09b0\u09a3 \u0995\u09b0\u09be \u09b9\u09af\u09bc\u09c7\u099b\u09c7\u0964", "pad.modals.disconnected.explanation": "\u09b8\u09be\u09b0\u09cd\u09ad\u09be\u09b0\u09c7\u09b0 \u09b8\u09be\u09a5\u09c7 \u09af\u09cb\u0997\u09be\u09af\u09cb\u0997 \u0995\u09b0\u09be \u09af\u09be\u099a\u09cd\u099b\u09c7 \u09a8\u09be", @@ -34,6 +68,7 @@ "timeslider.toolbar.authors": "\u09b2\u09c7\u0996\u0995\u0997\u09a3:", "timeslider.toolbar.authorsList": "\u0995\u09cb\u09a8\u09cb \u09b2\u09c7\u0996\u0995 \u09a8\u09c7\u0987", "timeslider.exportCurrent": "\u09ac\u09b0\u09cd\u09a4\u09ae\u09be\u09a8 \u09b8\u0982\u09b8\u09cd\u0995\u09b0\u09a3\u099f\u09bf \u098f\u0995\u09cd\u09b8\u09aa\u09cb\u09b0\u09cd\u099f \u0995\u09b0\u09c1\u09a8:", + "timeslider.dateformat": "{{month}}\/{{day}}\/{{year}} {{hours}}:{{minutes}}:{{seconds}}", "timeslider.month.january": "\u099c\u09be\u09a8\u09c1\u09af\u09bc\u09be\u09b0\u09bf", "timeslider.month.february": "\u09ab\u09c7\u09ac\u09cd\u09b0\u09c1\u09af\u09bc\u09be\u09b0\u09bf", "timeslider.month.march": "\u09ae\u09be\u09b0\u09cd\u099a", @@ -45,5 +80,12 @@ "timeslider.month.september": "\u09b8\u09c7\u09aa\u09cd\u099f\u09c7\u09ae\u09cd\u09ac\u09b0", "timeslider.month.october": "\u0985\u0995\u09cd\u099f\u09cb\u09ac\u09b0", "timeslider.month.november": "\u09a8\u09ad\u09c7\u09ae\u09cd\u09ac\u09b0", - "timeslider.month.december": "\u09a1\u09bf\u09b8\u09c7\u09ae\u09cd\u09ac\u09b0" + "timeslider.month.december": "\u09a1\u09bf\u09b8\u09c7\u09ae\u09cd\u09ac\u09b0", + "pad.userlist.entername": "\u0986\u09aa\u09a8\u09be\u09b0 \u09a8\u09be\u09ae", + "pad.userlist.unnamed": "\u0995\u09cb\u09a8 \u09a8\u09be\u09ae \u09a8\u09bf\u09b0\u09cd\u09ac\u09be\u099a\u09a8 \u0995\u09b0\u09be \u09b9\u09af\u09bc\u09a8\u09bf", + "pad.userlist.guest": "\u0985\u09a4\u09bf\u09a5\u09bf", + "pad.userlist.approve": "\u0985\u09a8\u09c1\u09ae\u09cb\u09a6\u09bf\u09a4", + "pad.impexp.importbutton": "\u098f\u0996\u09a8 \u0987\u09ae\u09cd\u09aa\u09cb\u09b0\u09cd\u099f \u0995\u09b0\u09c1\u09a8", + "pad.impexp.importing": "\u0987\u09ae\u09cd\u09aa\u09cb\u09b0\u09cd\u099f \u099a\u09b2\u099b\u09c7...", + "pad.impexp.importfailed": "\u0987\u09ae\u09cd\u09aa\u09cb\u09b0\u09cd\u099f \u0985\u09b8\u0995\u09cd\u09b7\u09ae" }
\ No newline at end of file diff --git a/src/locales/br.json b/src/locales/br.json new file mode 100644 index 00000000..1197f0d6 --- /dev/null +++ b/src/locales/br.json @@ -0,0 +1,123 @@ +{ + "@metadata": { + "authors": [ + "Fohanno", + "Fulup", + "Gwenn-Ael", + "Y-M D" + ] + }, + "index.newPad": "Pad nevez", + "index.createOpenPad": "pe kroui\u00f1\/digeri\u00f1 ur pad gant an anv :", + "pad.toolbar.bold.title": "Tev (Ctrl-B)", + "pad.toolbar.italic.title": "Italek (Ctrl-I)", + "pad.toolbar.underline.title": "Islinenna\u00f1 (Ctrl-U)", + "pad.toolbar.strikethrough.title": "Barrennet", + "pad.toolbar.ol.title": "Roll urzhiet", + "pad.toolbar.ul.title": "Roll en dizurzh", + "pad.toolbar.indent.title": "Endanta\u00f1", + "pad.toolbar.unindent.title": "Diendanta\u00f1", + "pad.toolbar.undo.title": "Dizober (Ktrl-Z)", + "pad.toolbar.redo.title": "Adober (Ktrl-Y)", + "pad.toolbar.clearAuthorship.title": "Diverka\u00f1 al livio\u00f9 oc'h anaout an aozerien", + "pad.toolbar.import_export.title": "Enporzhia\u00f1\/Ezporzhia\u00f1 eus\/war-zu ur furmad restr dishe\u00f1vel", + "pad.toolbar.timeslider.title": "Istor dinamek", + "pad.toolbar.savedRevision.title": "Doareo\u00f9 enrollet", + "pad.toolbar.settings.title": "Arventenno\u00f9", + "pad.toolbar.embed.title": "Enframma\u00f1 ar pad-ma\u00f1", + "pad.toolbar.showusers.title": "Diskwelet implijerien ar Pad", + "pad.colorpicker.save": "Enrolla\u00f1", + "pad.colorpicker.cancel": "Nulla\u00f1", + "pad.loading": "O karga\u00f1...", + "pad.passwordRequired": "Ezhomm ho peus ur ger-tremen evit mont d'ar Pad-se", + "pad.permissionDenied": "\nN'oc'h ket aotreet da vont d'ar pad-ma\u00f1", + "pad.wrongPassword": "Fazius e oa ho ker-tremen", + "pad.settings.padSettings": "Arventenno\u00f9 Pad", + "pad.settings.myView": "Ma diskwel", + "pad.settings.stickychat": "Diskwel ar flap bepred", + "pad.settings.colorcheck": "Livio\u00f9 anaout", + "pad.settings.linenocheck": "Niverenno\u00f9 linenno\u00f9", + "pad.settings.fontType": "Seurt font :", + "pad.settings.fontType.normal": "Reizh", + "pad.settings.fontType.monospaced": "Monospas", + "pad.settings.globalView": "Gwel dre vras", + "pad.settings.language": "Yezh :", + "pad.importExport.import_export": "Enporzhia\u00f1\/Ezporzhia\u00f1", + "pad.importExport.import": "Enkarga\u00f1 un destenn pe ur restr", + "pad.importExport.importSuccessful": "Deuet eo ganeoc'h !", + "pad.importExport.export": "Ezporzhia\u00f1 ar pad brema\u00f1 evel :", + "pad.importExport.exporthtml": "HTML", + "pad.importExport.exportplain": "Testenn blaen", + "pad.importExport.exportword": "Microsoft Word", + "pad.importExport.exportpdf": "PDF", + "pad.importExport.exportopen": "ODF (Open Document Format)", + "pad.importExport.exportdokuwiki": "DokuWiki", + "pad.importExport.abiword.innerHTML": "Ne c'hallit ket emporzjia\u00f1 furmado\u00f9 testenno\u00f9 kriz pe html. Evit arc'hwelio\u00f9 enporzhia\u00f1 emdroetoc'h, staliit <a href=\"https:\/\/github.com\/ether\/etherpad-lite\/wiki\/How-to-enable-importing-and-exporting-different-file-formats-in-Ubuntu-or-OpenSuse-or-SLES-with-AbiWord\">abiword<\/a> mar plij.", + "pad.modals.connected": "Kevreet.", + "pad.modals.reconnecting": "Adkevrea\u00f1 war-zu ho pad...", + "pad.modals.forcereconnect": "Adkevrea\u00f1 dre heg", + "pad.modals.userdup": "Digor en ur prenestr all", + "pad.modals.userdup.explanation": "Digor eo ho pad, war a seblant, e meur a brenestr eus ho merdeer en urzhiataer-ma\u00f1.", + "pad.modals.userdup.advice": "Kevrea\u00f1 en ur implijout ar prenestr-ma\u00f1.", + "pad.modals.unauth": "N'eo ket aotreet", + "pad.modals.unauth.explanation": "Kemmet e vo hoc'h aotreo\u00f9 pa vo diskwelet ar bajenn.-ma\u00f1 Klaskit kevrea\u00f1 en-dro.", + "pad.modals.looping": "Digevreet.", + "pad.modals.looping.explanation": "Kudenno\u00f9 kehenti\u00f1 zo gant ar servijer sinkronelekaat.", + "pad.modals.looping.cause": "Posupl eo e vefe gwarezet ho kevreadur gant ur maltouter diembreget pe ur servijer proksi", + "pad.modals.initsocketfail": "Ne c'haller ket tizhout ar servijer.", + "pad.modals.initsocketfail.explanation": "Ne c'haller ket kevrea\u00f1 ouzh ar servijer sinkronelaat.", + "pad.modals.initsocketfail.cause": "Gallout a ra ar gudenn dont eus ho merdeer Web pe eus ho kevreadur Internet.", + "pad.modals.slowcommit": "Digevreet.", + "pad.modals.slowcommit.explanation": "Ne respont ket ar serveur.", + "pad.modals.slowcommit.cause": "Gallout a ra dont diwar kudenno\u00f9 kevrea\u00f1 gant ar rouedad.", + "pad.modals.deleted": "Dilamet.", + "pad.modals.deleted.explanation": "Lamet eo bet ar pad-ma\u00f1.", + "pad.modals.disconnected": "Digevreet oc'h bet.", + "pad.modals.disconnected.explanation": "Kollet eo bet ar c'hevreadur gant ar servijer", + "pad.modals.disconnected.cause": "Dizimplijadus eo ar servijer marteze. Kelaouit ac'hanomp ma pad ar gudenn.", + "pad.share": "Ranna\u00f1 ar pad-ma\u00f1.", + "pad.share.readonly": "Lenn hepken", + "pad.share.link": "Liamm", + "pad.share.emebdcode": "Enframma\u00f1 an URL", + "pad.chat": "Flap", + "pad.chat.title": "Digeri\u00f1 ar flap kevelet gant ar pad-ma\u00f1.", + "pad.chat.loadmessages": "Karga\u00f1 muioc'h a gemennadenno\u00f9", + "timeslider.pageTitle": "Istor dinamek eus {{appTitle}}", + "timeslider.toolbar.returnbutton": "Distrei\u00f1 d'ar pad-ma\u00f1.", + "timeslider.toolbar.authors": "Aozerien :", + "timeslider.toolbar.authorsList": "Aozer ebet", + "timeslider.toolbar.exportlink.title": "Ezporzhia\u00f1", + "timeslider.exportCurrent": "Ezporzhia\u00f1 an doare brema\u00f1 evel :", + "timeslider.version": "Stumm {{version}}", + "timeslider.saved": "Enrolla\u00f1 {{day}} {{month}} {{year}}", + "timeslider.dateformat": "{{month}}\/{{day}}\/{{year}} {{hours}}:{{minutes}}:{{seconds}}", + "timeslider.month.january": "Genver", + "timeslider.month.february": "C'hwevrer", + "timeslider.month.march": "Meurzh", + "timeslider.month.april": "Ebrel", + "timeslider.month.may": "Mae", + "timeslider.month.june": "Mezheven", + "timeslider.month.july": "Gouere", + "timeslider.month.august": "Eost", + "timeslider.month.september": "Gwengolo", + "timeslider.month.october": "Here", + "timeslider.month.november": "Du", + "timeslider.month.december": "Kerzu", + "timeslider.unnamedauthor": "{{niver}} aozer dianav", + "timeslider.unnamedauthors": "Aozerien dianav", + "pad.savedrevs.marked": "Merket eo an adweladenn-ma\u00f1 evel adweladenn gwiriet", + "pad.userlist.entername": "Ebarzhit hoc'h anv", + "pad.userlist.unnamed": "dizanv", + "pad.userlist.guest": "Den pedet", + "pad.userlist.deny": "Nac'h", + "pad.userlist.approve": "Aproui\u00f1", + "pad.editbar.clearcolors": "Diverka\u00f1 al livio\u00f9 stag ouzh an aozerien en teul a-bezh ?", + "pad.impexp.importbutton": "Enporzhia\u00f1 brema\u00f1", + "pad.impexp.importing": "Oc'h enporzhia\u00f1...", + "pad.impexp.confirmimport": "Ma vez enporzhiet ur restr e vo diverket ar pezh zo en teul a-vrema\u00f1. Ha sur oc'h e fell deoc'h mont betek penn ?", + "pad.impexp.convertFailed": "N'eus ket bet gallet enporzhia\u00f1 ar restr. Ober gant ur furmad teul all pe eila\u00f1\/pega\u00f1 gant an dorn.", + "pad.impexp.uploadFailed": "C'hwitet eo bet an enporzhia\u00f1. Klaskit en-dro.", + "pad.impexp.importfailed": "C'hwitet eo an enporzhiadenn", + "pad.impexp.copypaste": "Eilit\/pegit, mar plij", + "pad.impexp.exportdisabled": "Diweredekaet eo ezporzhia\u00f1 d'ar furmad {{type}}. Kit e darempred gant merour ar reizhiad evit gouzout hiroc'h." +}
\ No newline at end of file diff --git a/src/locales/ca.json b/src/locales/ca.json index ca4d3f19..ec521eca 100644 --- a/src/locales/ca.json +++ b/src/locales/ca.json @@ -17,7 +17,7 @@ "pad.toolbar.undo.title": "Desf\u00e9s (Ctrl-Z)", "pad.toolbar.redo.title": "Ref\u00e9s (Ctrl-Y)", "pad.toolbar.clearAuthorship.title": "Neteja els colors d'autoria", - "pad.toolbar.savedRevision.title": "Revisions desades", + "pad.toolbar.savedRevision.title": "Desa la revisi\u00f3", "pad.toolbar.settings.title": "Configuraci\u00f3", "pad.toolbar.showusers.title": "Mostra els usuaris d\u2019aquest pad", "pad.colorpicker.save": "Desa", @@ -25,18 +25,25 @@ "pad.loading": "S'est\u00e0 carregant...", "pad.wrongPassword": "La contrasenya \u00e9s incorrecta", "pad.settings.myView": "La meva vista", + "pad.settings.stickychat": "Xateja sempre a la pantalla", + "pad.settings.colorcheck": "Colors d'autoria", "pad.settings.linenocheck": "N\u00fameros de l\u00ednia", "pad.settings.fontType": "Tipus de lletra:", "pad.settings.fontType.normal": "Normal", + "pad.settings.fontType.monospaced": "D'amplada fixa", "pad.settings.globalView": "Vista global", "pad.settings.language": "Llengua:", "pad.importExport.import_export": "Importaci\u00f3\/exportaci\u00f3", "pad.importExport.import": "Puja qualsevol fitxer de text o document", "pad.importExport.exporthtml": "HTML", "pad.importExport.exportplain": "Text net", + "pad.importExport.exportpdf": "PDF", + "pad.importExport.exportopen": "ODF (Open Document Format)", + "pad.importExport.exportdokuwiki": "DokuWiki", "pad.modals.connected": "Connectat.", "pad.modals.forcereconnect": "For\u00e7a tornar a connectar", "pad.modals.unauth": "No autoritzat", + "pad.modals.unauth.explanation": "Els vostres permisos han canviat mentre es visualitzava la p\u00e0gina. Proveu de reconnectar-vos.", "pad.modals.looping": "Desconnectat.", "pad.modals.initsocketfail": "El servidor no \u00e9s accessible.", "pad.modals.initsocketfail.explanation": "No s'ha pogut connectar amb el servidor de sincronitzaci\u00f3.", @@ -44,6 +51,7 @@ "pad.modals.slowcommit.explanation": "El servidor no respon.", "pad.modals.deleted": "Suprimit.", "pad.modals.disconnected": "Heu estat desconnectat.", + "pad.modals.disconnected.cause": "El servidor sembla que no est\u00e0 disponible. Notifiqueu-nos si continua passant.", "pad.share.readonly": "Nom\u00e9s de lectura", "pad.share.link": "Enlla\u00e7", "pad.chat": "Xat", @@ -52,6 +60,8 @@ "timeslider.toolbar.exportlink.title": "Exporta", "timeslider.exportCurrent": "Exporta la versi\u00f3 actual com a:", "timeslider.version": "Versi\u00f3 {{version}}", + "timeslider.saved": "Desat {{month}} {{day}}, {{year}}", + "timeslider.dateformat": "{{month}}\/{{day}}\/{{year}} {{hours}}:{{minutes}}:{{seconds}}", "timeslider.month.january": "Gener", "timeslider.month.february": "Febrer", "timeslider.month.march": "Mar\u00e7", @@ -69,9 +79,11 @@ "pad.userlist.guest": "Convidat", "pad.userlist.deny": "Refusa", "pad.userlist.approve": "Aprova", + "pad.editbar.clearcolors": "Voleu netejar els colors d'autor del document sencer?", "pad.impexp.importbutton": "Importa ara", "pad.impexp.importing": "Important...", "pad.impexp.convertFailed": "No \u00e9s possible d'importar aquest fitxer. Si us plau, podeu provar d'utilitzar un format diferent o copiar i enganxar manualment.", + "pad.impexp.uploadFailed": "Ha fallat la c\u00e0rrega. Torneu-ho a provar", "pad.impexp.importfailed": "Ha fallat la importaci\u00f3", "pad.impexp.copypaste": "Si us plau, copieu i enganxeu" }
\ No newline at end of file diff --git a/src/locales/da.json b/src/locales/da.json index dc6c0f25..e7cde1f5 100644 --- a/src/locales/da.json +++ b/src/locales/da.json @@ -1,7 +1,8 @@ { "@metadata": { "authors": [ - "Christian List" + "Christian List", + "Peter Alberti" ] }, "index.newPad": "Ny Pad", @@ -100,6 +101,8 @@ "timeslider.month.october": "oktober", "timeslider.month.november": "november", "timeslider.month.december": "december", + "timeslider.unnamedauthor": "{{num}} unavngiven forfatter", + "timeslider.unnamedauthors": "{{num}} unavngivne forfattere", "pad.savedrevs.marked": "Denne revision er nu markeret som en gemt revision", "pad.userlist.entername": "Indtast dit navn", "pad.userlist.unnamed": "ikke-navngivet", diff --git a/src/locales/de.json b/src/locales/de.json index 7c51fa91..20938422 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -22,7 +22,7 @@ "pad.toolbar.clearAuthorship.title": "Autorenfarben zur\u00fccksetzen", "pad.toolbar.import_export.title": "Import\/Export in verschiedenen Dateiformaten", "pad.toolbar.timeslider.title": "Pad-Versionsgeschichte anzeigen", - "pad.toolbar.savedRevision.title": "Diese Revision markieren", + "pad.toolbar.savedRevision.title": "Version speichern", "pad.toolbar.settings.title": "Einstellungen", "pad.toolbar.embed.title": "Dieses Pad teilen oder einbetten", "pad.toolbar.showusers.title": "Aktuell verbundene Benutzer anzeigen", diff --git a/src/locales/el.json b/src/locales/el.json index 33cb6c21..f33865e6 100644 --- a/src/locales/el.json +++ b/src/locales/el.json @@ -22,7 +22,7 @@ "pad.toolbar.clearAuthorship.title": "\u039a\u03b1\u03b8\u03b1\u03c1\u03b9\u03c3\u03bc\u03cc\u03c2 \u03a7\u03c1\u03c9\u03bc\u03ac\u03c4\u03c9\u03bd \u03a3\u03c5\u03bd\u03c4\u03b1\u03ba\u03c4\u03ce\u03bd", "pad.toolbar.import_export.title": "\u0395\u03b9\u03c3\u03b1\u03b3\u03c9\u03b3\u03ae\/\u0395\u03be\u03b1\u03b3\u03c9\u03b3\u03ae \u03b1\u03c0\u03cc\/\u03c3\u03b5 \u03b4\u03b9\u03b1\u03c6\u03bf\u03c1\u03b5\u03c4\u03b9\u03ba\u03bf\u03cd\u03c2 \u03c4\u03cd\u03c0\u03bf\u03c5\u03c2 \u03b1\u03c1\u03c7\u03b5\u03af\u03c9\u03bd", "pad.toolbar.timeslider.title": "\u03a7\u03c1\u03bf\u03bd\u03bf\u03b4\u03b9\u03ac\u03b3\u03c1\u03b1\u03bc\u03bc\u03b1", - "pad.toolbar.savedRevision.title": "\u0391\u03c0\u03bf\u03b8\u03ae\u03ba\u03b5\u03c5\u03c3\u03b7 \u0388\u03ba\u03b4\u03bf\u03c3\u03b7\u03c2", + "pad.toolbar.savedRevision.title": "\u0391\u03c0\u03bf\u03b8\u03b7\u03ba\u03b5\u03c5\u03bc\u03ad\u03bd\u03b5\u03c2 \u0391\u03bd\u03b1\u03b8\u03b5\u03c9\u03c1\u03ae\u03c3\u03b5\u03b9\u03c2", "pad.toolbar.settings.title": "\u03a1\u03c5\u03b8\u03bc\u03af\u03c3\u03b5\u03b9\u03c2", "pad.toolbar.embed.title": "\u0395\u03bd\u03c3\u03c9\u03bc\u03ac\u03c4\u03c9\u03c3\u03b7 \u03c4\u03bf\u03c5 pad", "pad.toolbar.showusers.title": "\u0395\u03bc\u03c6\u03ac\u03bd\u03b9\u03c3\u03b7 \u03c4\u03c9\u03bd \u03c7\u03c1\u03b7\u03c3\u03c4\u03ce\u03bd \u03b1\u03c5\u03c4\u03bf\u03cd \u03c4\u03bf\u03c5 pad", @@ -81,6 +81,7 @@ "pad.share.emebdcode": "URL \u03b5\u03bd\u03c3\u03c9\u03bc\u03ac\u03c4\u03c9\u03c3\u03b7\u03c2", "pad.chat": "\u03a3\u03c5\u03bd\u03bf\u03bc\u03b9\u03bb\u03af\u03b1", "pad.chat.title": "\u0386\u03bd\u03bf\u03b9\u03b3\u03bc\u03b1 \u03c4\u03b7\u03c2 \u03c3\u03c5\u03bd\u03bf\u03bc\u03b9\u03bb\u03af\u03b1\u03c2 \u03b3\u03b9\u03b1 \u03b1\u03c5\u03c4\u03cc \u03c4\u03bf pad.", + "pad.chat.loadmessages": "\u03a6\u03cc\u03c1\u03c4\u03c9\u03c3\u03b7 \u03c0\u03b5\u03c1\u03b9\u03c3\u03c3\u03cc\u03c4\u03b5\u03c1\u03c9\u03bd \u03bc\u03b7\u03bd\u03c5\u03bc\u03ac\u03c4\u03c9\u03bd", "timeslider.pageTitle": "{{appTitle}} \u03a7\u03c1\u03bf\u03bd\u03bf\u03b4\u03b9\u03ac\u03b3\u03c1\u03b1\u03bc\u03bc\u03b1", "timeslider.toolbar.returnbutton": "\u0395\u03c0\u03b9\u03c3\u03c4\u03c1\u03bf\u03c6\u03ae \u03c3\u03c4\u03bf pad", "timeslider.toolbar.authors": "\u03a3\u03c5\u03bd\u03c4\u03ac\u03ba\u03c4\u03b5\u03c2:", @@ -88,7 +89,7 @@ "timeslider.toolbar.exportlink.title": "\u0395\u03be\u03b1\u03b3\u03c9\u03b3\u03ae", "timeslider.exportCurrent": "\u0395\u03be\u03b1\u03b3\u03c9\u03b3\u03ae \u03c4\u03c1\u03ad\u03c7\u03bf\u03c5\u03c3\u03b1\u03c2 \u03ad\u03ba\u03b4\u03bf\u03c3\u03b7\u03c2 \u03c9\u03c2:", "timeslider.version": "\u0388\u03ba\u03b4\u03bf\u03c3\u03b7 {{version}}", - "timeslider.saved": "\u0391\u03c0\u03bf\u03b8\u03b7\u03ba\u03b5\u03cd\u03c4\u03b7\u03ba\u03b5 {{day}} {{month}}, {{year}}", + "timeslider.saved": "\u0391\u03c0\u03bf\u03b8\u03b7\u03ba\u03b5\u03cd\u03c4\u03b7\u03ba\u03b5 \u03c3\u03c4\u03b9\u03c2 {{day}} {{month}} {{year}}", "timeslider.dateformat": "{{day}}\/{{month}}\/{{year}} {{hours}}:{{minutes}}:{{seconds}}", "timeslider.month.january": "\u0399\u03b1\u03bd\u03bf\u03c5\u03b1\u03c1\u03af\u03bf\u03c5", "timeslider.month.february": "\u03a6\u03b5\u03b2\u03c1\u03bf\u03c5\u03b1\u03c1\u03af\u03bf\u03c5", @@ -102,6 +103,8 @@ "timeslider.month.october": "\u039f\u03ba\u03c4\u03c9\u03b2\u03c1\u03af\u03bf\u03c5", "timeslider.month.november": "\u039d\u03bf\u03b5\u03bc\u03b2\u03c1\u03af\u03bf\u03c5", "timeslider.month.december": "\u0394\u03b5\u03ba\u03b5\u03bc\u03b2\u03c1\u03af\u03bf\u03c5", + "timeslider.unnamedauthor": "{{num}} \u03b1\u03bd\u03ce\u03bd\u03c5\u03bc\u03bf\u03c2 \u03c3\u03c5\u03b3\u03b3\u03c1\u03b1\u03c6\u03ad\u03b1\u03c2", + "timeslider.unnamedauthors": "{{num}} \u03b1\u03bd\u03ce\u03bd\u03c5\u03bc\u03bf\u03b9 \u03c3\u03c5\u03b3\u03b3\u03c1\u03b1\u03c6\u03b5\u03af\u03c2", "pad.savedrevs.marked": "\u0391\u03c5\u03c4\u03ae \u03b7 \u03ad\u03ba\u03b4\u03bf\u03c3\u03b7 \u03b5\u03c0\u03b9\u03c3\u03b7\u03bc\u03ac\u03bd\u03b8\u03b7\u03ba\u03b5 \u03c9\u03c2 \u03b1\u03c0\u03bf\u03b8\u03b7\u03ba\u03b5\u03c5\u03bc\u03ad\u03bd\u03b7 \u03ad\u03ba\u03b4\u03bf\u03c3\u03b7", "pad.userlist.entername": "\u0395\u03b9\u03c3\u03ac\u03b3\u03b5\u03c4\u03b5 \u03c4\u03bf \u03cc\u03bd\u03bf\u03bc\u03ac \u03c3\u03b1\u03c2", "pad.userlist.unnamed": "\u03b1\u03bd\u03ce\u03bd\u03c5\u03bc\u03bf\u03c2", diff --git a/src/locales/es.json b/src/locales/es.json index f0358a90..187f3637 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -4,8 +4,9 @@ "0": "Armando-Martin", "1": "Jacobo", "2": "Joker", - "4": "Vivaelcelta", - "5": "Xuacu" + "3": "Rubenwap", + "5": "Vivaelcelta", + "6": "Xuacu" } }, "index.newPad": "Nuevo Pad", @@ -104,6 +105,8 @@ "timeslider.month.october": "Octubre", "timeslider.month.november": "Noviembre", "timeslider.month.december": "Diciembre", + "timeslider.unnamedauthor": "{{num}} autor desconocido", + "timeslider.unnamedauthors": "{{num}} autores desconocidos", "pad.savedrevs.marked": "Revisi\u00f3n guardada", "pad.userlist.entername": "Escribe tu nombre", "pad.userlist.unnamed": "an\u00f3nimo", diff --git a/src/locales/fi.json b/src/locales/fi.json index 74f7e36c..eeb4cb16 100644 --- a/src/locales/fi.json +++ b/src/locales/fi.json @@ -24,7 +24,7 @@ "pad.toolbar.clearAuthorship.title": "Poista kirjoittajav\u00e4rit", "pad.toolbar.import_export.title": "Tuo tai vie eri tiedostomuodoista tai -muotoihin", "pad.toolbar.timeslider.title": "Aikajana", - "pad.toolbar.savedRevision.title": "Tallennetut versiot", + "pad.toolbar.savedRevision.title": "Tallenna muutos", "pad.toolbar.settings.title": "Asetukset", "pad.toolbar.embed.title": "Upota muistio", "pad.toolbar.showusers.title": "N\u00e4yt\u00e4 muistion k\u00e4ytt\u00e4j\u00e4t", @@ -105,6 +105,8 @@ "timeslider.month.october": "lokakuu", "timeslider.month.november": "marraskuu", "timeslider.month.december": "joulukuu", + "timeslider.unnamedauthor": "{{num}} nimet\u00f6n tekij\u00e4", + "timeslider.unnamedauthors": "{{num}} nimet\u00f6nt\u00e4 tekij\u00e4\u00e4", "pad.savedrevs.marked": "T\u00e4m\u00e4 versio on nyt merkitty tallennetuksi versioksi", "pad.userlist.entername": "Kirjoita nimesi", "pad.userlist.unnamed": "nimet\u00f6n", diff --git a/src/locales/fr.json b/src/locales/fr.json index 05ec1ab3..4131c723 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -109,6 +109,8 @@ "timeslider.month.october": "Octobre", "timeslider.month.november": "Novembre", "timeslider.month.december": "D\u00e9cembre", + "timeslider.unnamedauthor": "{{num}} auteur anonyme", + "timeslider.unnamedauthors": "{{num}} auteurs anonymes", "pad.savedrevs.marked": "Cette r\u00e9vision est maintenant marqu\u00e9e comme r\u00e9vision enregistr\u00e9e", "pad.userlist.entername": "Entrez votre nom", "pad.userlist.unnamed": "sans nom", diff --git a/src/locales/gl.json b/src/locales/gl.json index 7f2e5a56..261d28ef 100644 --- a/src/locales/gl.json +++ b/src/locales/gl.json @@ -100,6 +100,8 @@ "timeslider.month.october": "outubro", "timeslider.month.november": "novembro", "timeslider.month.december": "decembro", + "timeslider.unnamedauthor": "{{num}} autor an\u00f3nimo", + "timeslider.unnamedauthors": "{{num}} autores an\u00f3nimos", "pad.savedrevs.marked": "Esta revisi\u00f3n est\u00e1 agora marcada como revisi\u00f3n gardada", "pad.userlist.entername": "Insira o seu nome", "pad.userlist.unnamed": "an\u00f3nimo", diff --git a/src/locales/he.json b/src/locales/he.json index 75ebff1b..7e5f3b04 100644 --- a/src/locales/he.json +++ b/src/locales/he.json @@ -79,6 +79,7 @@ "pad.share.emebdcode": "\u05d4\u05d8\u05de\u05e2\u05ea \u05e7\u05d9\u05e9\u05d5\u05e8", "pad.chat": "\u05e9\u05d9\u05d7\u05d4", "pad.chat.title": "\u05e4\u05ea\u05d9\u05d7\u05ea \u05d4\u05e9\u05d9\u05d7\u05d4 \u05e9\u05dc \u05d4\u05e4\u05e0\u05e7\u05e1 \u05d4\u05d6\u05d4.", + "pad.chat.loadmessages": "\u05d8\u05e2\u05d9\u05e0\u05ea \u05d4\u05d5\u05d3\u05e2\u05d5\u05ea \u05e0\u05d5\u05e1\u05e4\u05d5\u05ea", "timeslider.pageTitle": "\u05d2\u05d5\u05dc\u05dc \u05d6\u05de\u05df \u05e9\u05dc {{appTitle}}", "timeslider.toolbar.returnbutton": "\u05d7\u05d6\u05e8\u05d4 \u05d0\u05dc \u05d4\u05e4\u05e0\u05e7\u05e1", "timeslider.toolbar.authors": "\u05db\u05d5\u05ea\u05d1\u05d9\u05dd:", @@ -100,6 +101,8 @@ "timeslider.month.october": "\u05d0\u05d5\u05e7\u05d8\u05d5\u05d1\u05e8", "timeslider.month.november": "\u05e0\u05d5\u05d1\u05de\u05d1\u05e8", "timeslider.month.december": "\u05d3\u05e6\u05de\u05d1\u05e8", + "timeslider.unnamedauthor": "\u05db\u05d5\u05ea\u05d1 \u05d7\u05e1\u05e8\u05be\u05e9\u05dd \u05d0\u05d7\u05d3", + "timeslider.unnamedauthors": "{{num}} \u05db\u05d5\u05ea\u05d1\u05d9\u05dd \u05d7\u05e1\u05e8\u05d9\u05be\u05e9\u05dd", "pad.savedrevs.marked": "\u05d2\u05e8\u05e1\u05d4 \u05d6\u05d5 \u05de\u05e1\u05d5\u05de\u05e0\u05ea \u05db\u05d2\u05e8\u05e1\u05d4 \u05e9\u05de\u05d5\u05e8\u05d4", "pad.userlist.entername": "\u05e0\u05d0 \u05dc\u05d4\u05d6\u05d9\u05df \u05d0\u05ea \u05e9\u05de\u05da", "pad.userlist.unnamed": "\u05dc\u05dc\u05d0 \u05e9\u05dd", diff --git a/src/locales/it.json b/src/locales/it.json index c60678db..05569a32 100644 --- a/src/locales/it.json +++ b/src/locales/it.json @@ -103,6 +103,8 @@ "timeslider.month.october": "ottobre", "timeslider.month.november": "novembre", "timeslider.month.december": "dicembre", + "timeslider.unnamedauthor": "{{num}} autore senza nome", + "timeslider.unnamedauthors": "{{num}} autori senza nome", "pad.savedrevs.marked": "Questa revisione \u00e8 ora contrassegnata come una versione salvata", "pad.userlist.entername": "Inserisci il tuo nome", "pad.userlist.unnamed": "senza nome", diff --git a/src/locales/ja.json b/src/locales/ja.json index 1954b979..f7173dd4 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -19,7 +19,7 @@ "pad.toolbar.clearAuthorship.title": "\u4f5c\u8005\u306e\u8272\u5206\u3051\u3092\u6d88\u53bb", "pad.toolbar.import_export.title": "\u4ed6\u306e\u5f62\u5f0f\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u30a4\u30f3\u30dd\u30fc\u30c8\/\u30a8\u30af\u30b9\u30dd\u30fc\u30c8", "pad.toolbar.timeslider.title": "\u30bf\u30a4\u30e0\u30b9\u30e9\u30a4\u30c0\u30fc", - "pad.toolbar.savedRevision.title": "\u4fdd\u5b58\u6e08\u307f\u306e\u7248", + "pad.toolbar.savedRevision.title": "\u7248\u3092\u4fdd\u5b58", "pad.toolbar.settings.title": "\u8a2d\u5b9a", "pad.toolbar.embed.title": "\u3053\u306e\u30d1\u30c3\u30c9\u3092\u57cb\u3081\u8fbc\u3080", "pad.toolbar.showusers.title": "\u3053\u306e\u30d1\u30c3\u30c9\u306e\u30e6\u30fc\u30b6\u30fc\u3092\u8868\u793a", @@ -87,7 +87,7 @@ "timeslider.exportCurrent": "\u73fe\u5728\u306e\u7248\u3092\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u3059\u308b\u5f62\u5f0f:", "timeslider.version": "\u30d0\u30fc\u30b8\u30e7\u30f3 {{version}}", "timeslider.saved": "| {{year}}\u5e74{{month}}{{day}}\u65e5\u306b\u4fdd\u5b58", - "timeslider.dateformat": "{{year}}\u5e74{{month}}{{day}}\u65e5 {{hours}}:{{minutes}}:{{seconds}}", + "timeslider.dateformat": "{{year}}\u5e74{{month}}\u6708{{day}}\u65e5 {{hours}}:{{minutes}}:{{seconds}}", "timeslider.month.january": "1\u6708", "timeslider.month.february": "2\u6708", "timeslider.month.march": "3\u6708", @@ -100,6 +100,8 @@ "timeslider.month.october": "10\u6708", "timeslider.month.november": "11\u6708", "timeslider.month.december": "12\u6708", + "timeslider.unnamedauthor": "{{num}} \u4eba\u306e\u533f\u540d\u306e\u4f5c\u8005", + "timeslider.unnamedauthors": "{{num}} \u4eba\u306e\u533f\u540d\u306e\u4f5c\u8005", "pad.savedrevs.marked": "\u3053\u306e\u7248\u3092\u3001\u4fdd\u5b58\u6e08\u307f\u306e\u7248\u3068\u3057\u3066\u30de\u30fc\u30af\u3057\u307e\u3057\u305f\u3002", "pad.userlist.entername": "\u540d\u524d\u3092\u5165\u529b", "pad.userlist.unnamed": "\u540d\u524d\u306a\u3057", diff --git a/src/locales/ko.json b/src/locales/ko.json index 9e436b0c..ccd7705c 100644 --- a/src/locales/ko.json +++ b/src/locales/ko.json @@ -100,6 +100,8 @@ "timeslider.month.october": "10\uc6d4", "timeslider.month.november": "11\uc6d4", "timeslider.month.december": "12\uc6d4", + "timeslider.unnamedauthor": "\uc774\ub984 \uc5c6\ub294 \uc800\uc790 {{num}}\uba85", + "timeslider.unnamedauthors": "\uc774\ub984 \uc5c6\ub294 \uc800\uc790 {{num}}\uba85", "pad.savedrevs.marked": "\uc774 \ud310\uc740 \uc774\uc81c \uc800\uc7a5\ud55c \ud310\uc73c\ub85c \ud45c\uc2dc\ud569\ub2c8\ub2e4.", "pad.userlist.entername": "\uc774\ub984\uc744 \uc785\ub825\ud558\uc138\uc694", "pad.userlist.unnamed": "\uc774\ub984\uc5c6\uc74c", diff --git a/src/locales/ksh.json b/src/locales/ksh.json index e4557e85..648f9506 100644 --- a/src/locales/ksh.json +++ b/src/locales/ksh.json @@ -19,13 +19,16 @@ "pad.toolbar.clearAuthorship.title": "d\u00e4 Schriiver ier F\u00e4rve fottn\u00e4mme", "pad.toolbar.import_export.title": "Vun ongerscheidlijje Dattei_Fommaate empotteere udder \u00e4xpotteere", "pad.toolbar.timeslider.title": "Verjangeheid afschpelle", - "pad.toolbar.savedRevision.title": "Fa\u00dfjehallde Versione", + "pad.toolbar.savedRevision.title": "de Versjohn fa\u00dfhallde", "pad.toolbar.settings.title": "Enscht\u00e4llonge", "pad.toolbar.embed.title": "Donn dat Padd enbenge", "pad.toolbar.showusers.title": "Verbonge Metschriiver aanzeije", "pad.colorpicker.save": "Fa\u00dfhallde", "pad.colorpicker.cancel": "Oph\u00fc\u00fcre", "pad.loading": "Aam Laade …", + "pad.passwordRequired": "Do bruchs e Pa\u00dfwoot f\u00f6r heh dat P\u00e4dd.", + "pad.permissionDenied": "Do h\u00e4s nit dat R\u00e4\u00e4sch, op heh dat P\u00e4dd zohzejriife.", + "pad.wrongPassword": "Ding Pa\u00dfwoot wohr verkeht.", "pad.settings.padSettings": "Dam P\u00e4dd sin Enscht\u00e4llonge", "pad.settings.myView": "Anseesch", "pad.settings.stickychat": "Donn der Klaaf emmer aanzeije", @@ -38,6 +41,7 @@ "pad.settings.language": "Schprooch:", "pad.importExport.import_export": "Empoot\/\u00c4xpoot", "pad.importExport.import": "Donn jeede T\u00e4x udder jeede Zoot Dokem\u00e4nt huhlaade", + "pad.importExport.importSuccessful": "Jeschaff!", "pad.importExport.export": "Don dat P\u00e4dd \u00e4xpoteere al\u00df:", "pad.importExport.exporthtml": "HTML", "pad.importExport.exportplain": "Eijfach T\u00e4x", @@ -45,9 +49,11 @@ "pad.importExport.exportpdf": "PDF (Poteerbaa Dokem\u00e4nte Fommaat)", "pad.importExport.exportopen": "ODF (Offe Dokem\u00e4nte-Fommaat)", "pad.importExport.exportdokuwiki": "DokuWiki", + "pad.importExport.abiword.innerHTML": "Mer k\u00fcnne blo\u00df eijfaache T\u00e4xte udder HTML_Fommaate empoteere. Opw\u00e4ndejere M\u00fcjjeleschkeite f\u00f6 der Empoot jon och, dof\u00f6r bruch mer en <a href=\"https:\/\/github.com\/ether\/etherpad-lite\/wiki\/How-to-enable-importing-and-exporting-different-file-formats-in-Ubuntu-or-OpenSuse-or-SLES-with-AbiWord\">Enschtallazjuhn met <i lang=\"en\">Abiword<\/i><\/a>.", "pad.modals.connected": "Verbonge.", "pad.modals.reconnecting": "Ben wider aam Verbenge …", "pad.modals.forcereconnect": "Wider verbenge", + "pad.modals.userdup": "En enem andere Finster en \u00c4rbeid", "pad.modals.userdup.explanation": "Heh dat Padd schingk en mieh wi einem Finster vun enem Brauser op heh d\u00e4m R\u00e4\u00e4schner op ze sin.", "pad.modals.userdup.advice": "En heh d\u00e4m Finster wider verbenge.", "pad.modals.unauth": "Nit ber\u00e4\u00e4schtesch", @@ -72,10 +78,12 @@ "pad.share.emebdcode": "URL enboue", "pad.chat": "Klaaf", "pad.chat.title": "Maach d\u00e4 Klaaf f\u00f6r heh dat P\u00e4dd op", + "pad.chat.loadmessages": "Mieh Nohresschte laade...", "timeslider.pageTitle": "{{appTitle}} - Verjangeheid affschpelle", "timeslider.toolbar.returnbutton": "Jangk retuur nohm P\u00e4dd", "timeslider.toolbar.authors": "Schriiver:", "timeslider.toolbar.authorsList": "Kein Schriivere", + "timeslider.toolbar.exportlink.title": "\u00c4xpoot", "timeslider.exportCurrent": "Donn de meu\u00dfte V\u00e4sjohn \u00e4xpotteere al\u00df:", "timeslider.version": "V\u00e4sjon {{version}}", "timeslider.saved": "Fa\u00dfjehallde aam {{day}}. {{month}} {{year}}", @@ -92,11 +100,19 @@ "timeslider.month.october": "Oktoober", "timeslider.month.november": "Nov\u00e4mber", "timeslider.month.december": "Dez\u00e4mber", + "timeslider.unnamedauthor": "{{num}} naameloose Schriever", + "timeslider.unnamedauthors": "{{num}} naameloose Schriever", + "pad.savedrevs.marked": "Heh di V\u00e4sjohn es j\u00e4z fa\u00dfjehallde.", "pad.userlist.entername": "Jif Dinge Naame en", "pad.userlist.unnamed": "naamelo\u00df\u00df", "pad.userlist.guest": "Ja\u00df\u00df", "pad.userlist.deny": "Aflehne", + "pad.userlist.approve": "Joodhei\u00dfe", + "pad.editbar.clearcolors": "Sulle mer de F\u00e4rve f\u00f6r de Schriiver uss_em janze T\u00e4x fott maache?", + "pad.impexp.importbutton": "J\u00e4z empoteere", "pad.impexp.importing": "Ben aam Empotteere …", + "pad.impexp.confirmimport": "En Dattei ze empotteere m\u00e4\u00e4t der janze T\u00e4x em P\u00e4dd fott. Wess De dat verfaftesch hann?", + "pad.impexp.convertFailed": "Mer kunnte di Dattei nit empoteere. Nemm en ander Dattei-Fommaat udder donn d\u00e4 T\u00e4x vun Hand kopeere un ennf\u00f6\u00f6je.", "pad.impexp.uploadFailed": "Et Huhlaade es don\u00e4vve jejange, bes esu jood un probeer et norr_ens", "pad.impexp.importfailed": "Et Empoteere es don\u00e4vve jejange", "pad.impexp.copypaste": "Bes esu jood un donn et koppeere un enf\u00f6\u00f6je", diff --git a/src/locales/mk.json b/src/locales/mk.json index 9dd5e725..94d73bd8 100644 --- a/src/locales/mk.json +++ b/src/locales/mk.json @@ -101,6 +101,8 @@ "timeslider.month.october": "\u043e\u043a\u0442\u043e\u043c\u0432\u0440\u0438", "timeslider.month.november": "\u043d\u043e\u0435\u043c\u0432\u0440\u0438", "timeslider.month.december": "\u0434\u0435\u043a\u0435\u043c\u0432\u0440\u0438", + "timeslider.unnamedauthor": "{{num}} \u043d\u0435\u0438\u043c\u0435\u043d\u0443\u0432\u0430\u043d \u0430\u0432\u0442\u043e\u0440", + "timeslider.unnamedauthors": "{{num}} \u043d\u0435\u0438\u043c\u0435\u043d\u0443\u0432\u0430\u043d\u0438 \u0430\u0432\u0442\u043e\u0440\u0438", "pad.savedrevs.marked": "\u041e\u0432\u0430\u0430 \u0440\u0435\u0432\u0438\u0437\u0438\u0458\u0430 \u0441\u0435\u0433\u0430 \u0435 \u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u043a\u0430\u043a\u043e \u0437\u0430\u0447\u0443\u0432\u0430\u043d\u0430", "pad.userlist.entername": "\u0412\u043d\u0435\u0441\u0435\u0442\u0435 \u0433\u043e \u0432\u0430\u0448\u0435\u0442\u043e \u0438\u043c\u0435", "pad.userlist.unnamed": "\u0431\u0435\u0437 \u0438\u043c\u0435", diff --git a/src/locales/ml.json b/src/locales/ml.json index 4741fe77..e8250434 100644 --- a/src/locales/ml.json +++ b/src/locales/ml.json @@ -79,6 +79,7 @@ "pad.share.emebdcode": "\u0d0e\u0d02\u0d2c\u0d46\u0d21\u0d4d \u0d2f\u0d41.\u0d06\u0d7c.\u0d0e\u0d7d.", "pad.chat": "\u0d24\u0d24\u0d4d\u0d38\u0d2e\u0d2f\u0d38\u0d02\u0d35\u0d3e\u0d26\u0d02", "pad.chat.title": "\u0d08 \u0d2a\u0d3e\u0d21\u0d3f\u0d28\u0d4d\u0d31\u0d46 \u0d24\u0d24\u0d4d\u0d38\u0d2e\u0d2f\u0d38\u0d02\u0d35\u0d3e\u0d26\u0d02 \u0d24\u0d41\u0d31\u0d15\u0d4d\u0d15\u0d41\u0d15.", + "pad.chat.loadmessages": "\u0d15\u0d42\u0d1f\u0d41\u0d24\u0d7d \u0d38\u0d28\u0d4d\u0d26\u0d47\u0d36\u0d19\u0d4d\u0d19\u0d7e \u0d0e\u0d1f\u0d41\u0d15\u0d4d\u0d15\u0d41\u0d15", "timeslider.pageTitle": "{{appTitle}} \u0d38\u0d2e\u0d2f\u0d30\u0d47\u0d16", "timeslider.toolbar.returnbutton": "\u0d2a\u0d3e\u0d21\u0d3f\u0d32\u0d47\u0d15\u0d4d\u0d15\u0d4d \u0d24\u0d3f\u0d30\u0d3f\u0d1a\u0d4d\u0d1a\u0d41\u0d2a\u0d4b\u0d35\u0d41\u0d15", "timeslider.toolbar.authors": "\u0d30\u0d1a\u0d2f\u0d3f\u0d24\u0d3e\u0d15\u0d4d\u0d15\u0d7e:", diff --git a/src/locales/ms.json b/src/locales/ms.json index b2d95387..04055d26 100644 --- a/src/locales/ms.json +++ b/src/locales/ms.json @@ -78,6 +78,7 @@ "pad.share.emebdcode": "Benamkan URL", "pad.chat": "Sembang", "pad.chat.title": "Buka ruang sembang untuk pad ini.", + "pad.chat.loadmessages": "Muatkan banyak lagi pesanan", "timeslider.pageTitle": "Gelangsar Masa {{appTitle}}", "timeslider.toolbar.returnbutton": "Kembali ke pad", "timeslider.toolbar.authors": "Pengarang:", @@ -99,6 +100,8 @@ "timeslider.month.october": "Oktober", "timeslider.month.november": "November", "timeslider.month.december": "Disember", + "timeslider.unnamedauthor": "{{num}} orang pengarang awanama", + "timeslider.unnamedauthors": "{{num}} orang pengarang awanama", "pad.savedrevs.marked": "Semakan ini telah ditandai sebagai semakan tersimpan", "pad.userlist.entername": "Taipkan nama anda", "pad.userlist.unnamed": "tanpa nama", diff --git a/src/locales/nl.json b/src/locales/nl.json index 9b1c773b..4142cc33 100644 --- a/src/locales/nl.json +++ b/src/locales/nl.json @@ -19,7 +19,7 @@ "pad.toolbar.clearAuthorship.title": "Kleuren auteurs wissen", "pad.toolbar.import_export.title": "Naar\/van andere opmaak exporteren\/importeren", "pad.toolbar.timeslider.title": "Tijdlijn", - "pad.toolbar.savedRevision.title": "Opgeslagen versies", + "pad.toolbar.savedRevision.title": "Versie opslaan", "pad.toolbar.settings.title": "Instellingen", "pad.toolbar.embed.title": "Pad insluiten", "pad.toolbar.showusers.title": "Gebruikers van dit pad weergeven", diff --git a/src/locales/os.json b/src/locales/os.json index 4acfad7e..64b3ea2a 100644 --- a/src/locales/os.json +++ b/src/locales/os.json @@ -19,7 +19,7 @@ "pad.toolbar.clearAuthorship.title": "\u0424\u044b\u0441\u0441\u04d5\u0434\u0436\u044b \u043d\u044b\u0441\u04d5\u043d\u0442\u0442\u04d5 \u0430\u0439\u0441\u044b\u043d\u04d5\u043d", "pad.toolbar.import_export.title": "\u0418\u043c\u043f\u043e\u0440\u0442\/\u044d\u043a\u0441\u043f\u043e\u0440\u0442 \u04d5\u043d\u0434\u04d5\u0440 \u0444\u0430\u0439\u043b\u044b \u0444\u043e\u0440\u043c\u0430\u0442\u0442\u04d5\u0439\/\u0444\u043e\u0440\u043c\u0430\u0442\u0442\u04d5\u043c", "pad.toolbar.timeslider.title": "\u0420\u04d5\u0441\u0442\u04d5\u0434\u0436\u044b \u0445\u0430\u0445\u0445", - "pad.toolbar.savedRevision.title": "\u04d4\u0432\u04d5\u0440\u0434 \u0444\u04d5\u043b\u0442\u04d5\u0440\u0442\u04d5", + "pad.toolbar.savedRevision.title": "\u0424\u04d5\u043b\u0442\u04d5\u0440 \u0431\u0430\u0432\u04d5\u0440\u044b\u043d\u04d5\u043d", "pad.toolbar.settings.title": "\u0423\u0430\u0433\u04d5\u0432\u04d5\u0440\u0434\u0442\u04d5", "pad.toolbar.embed.title": "\u0410\u0446\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u0431\u0430\u0444\u0442\u0430\u0443\u044b\u043d", "pad.toolbar.showusers.title": "\u0410\u0446\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u0430\u0440\u0445\u0430\u0439\u0434\u0436\u044b\u0442\u044b \u0440\u0430\u0432\u0434\u0438\u0441\u044b\u043d", @@ -78,6 +78,7 @@ "pad.share.emebdcode": "URL \u0431\u0430\u0432\u04d5\u0440\u044b\u043d", "pad.chat": "\u041d\u044b\u0445\u0430\u0441", "pad.chat.title": "\u041e\u0446\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u04d5\u043d \u0447\u0430\u0442 \u0431\u0430\u043a\u04d5\u043d.", + "pad.chat.loadmessages": "\u0424\u044b\u043b\u0434\u04d5\u0440 \u0444\u044b\u0441\u0442\u04d5\u0433 \u0440\u0430\u0432\u0433\u04d5\u043d\u044b\u043d", "timeslider.pageTitle": "{{appTitle}}-\u044b \u0440\u04d5\u0442\u04d5\u0434\u0436\u044b \u0445\u0430\u0445\u0445", "timeslider.toolbar.returnbutton": "\u0424\u04d5\u0441\u0442\u04d5\u043c\u04d5, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043c\u04d5", "timeslider.toolbar.authors": "\u0424\u044b\u0441\u0441\u04d5\u0434\u0436\u044b\u0442\u04d5:", @@ -99,6 +100,8 @@ "timeslider.month.october": "\u043e\u043a\u0442\u044f\u0431\u0440\u044c", "timeslider.month.november": "\u043d\u043e\u044f\u0431\u0440\u044c", "timeslider.month.december": "\u0434\u0435\u043a\u0430\u0431\u0440\u044c", + "timeslider.unnamedauthor": "{{num}} \u04d5\u043d\u04d5\u043d\u043e\u043c \u0444\u044b\u0441\u0441\u04d5\u0433", + "timeslider.unnamedauthors": "{{num}} \u04d5\u043d\u04d5\u043d\u043e\u043c \u0444\u044b\u0441\u0441\u04d5\u0434\u0436\u044b", "pad.savedrevs.marked": "\u0410\u0446\u044b \u0444\u04d5\u043b\u0442\u04d5\u0440 \u043d\u044b\u0440 \u043a\u0443\u044b\u0434 \u04d5\u0432\u04d5\u0440\u0434 \u0444\u04d5\u043b\u0442\u04d5\u0440 \u043d\u044b\u0441\u0430\u043d\u0433\u043e\u043d\u0434 \u04d5\u0440\u0446\u044b\u0434", "pad.userlist.entername": "\u0414\u04d5 \u043d\u043e\u043c \u0431\u0430\u0444\u044b\u0441\u0441", "pad.userlist.unnamed": "\u04d5\u043d\u04d5\u043d\u043e\u043c", diff --git a/src/locales/pl.json b/src/locales/pl.json index 3481cafc..6a46dd77 100644 --- a/src/locales/pl.json +++ b/src/locales/pl.json @@ -21,7 +21,7 @@ "pad.toolbar.clearAuthorship.title": "Usu\u0144 kolory autor\u00f3w", "pad.toolbar.import_export.title": "Import\/eksport z\/do r\u00f3\u017cnych format\u00f3w plik\u00f3w", "pad.toolbar.timeslider.title": "O\u015b czasu", - "pad.toolbar.savedRevision.title": "Zapisane wersje", + "pad.toolbar.savedRevision.title": "Zapisz wersj\u0119", "pad.toolbar.settings.title": "Ustawienia", "pad.toolbar.embed.title": "Umie\u015b\u0107 ten Notatnik", "pad.toolbar.showusers.title": "Poka\u017c u\u017cytkownik\u00f3w", @@ -102,6 +102,8 @@ "timeslider.month.october": "Pa\u017adziernik", "timeslider.month.november": "Listopad", "timeslider.month.december": "Grudzie\u0144", + "timeslider.unnamedauthor": "{{num}} nienazwany autor", + "timeslider.unnamedauthors": "{{num}} autor\u00f3w bez nazw", "pad.savedrevs.marked": "Ta wersja zosta\u0142a w\u0142a\u015bnie oznaczona jako zapisana.", "pad.userlist.entername": "Wprowad\u017a swoj\u0105 nazw\u0119", "pad.userlist.unnamed": "bez nazwy", diff --git a/src/locales/ps.json b/src/locales/ps.json index 6589c77f..b992a56a 100644 --- a/src/locales/ps.json +++ b/src/locales/ps.json @@ -17,7 +17,9 @@ "pad.settings.fontType": "\u0644\u064a\u06a9\u0628\u06bc\u06d0 \u0689\u0648\u0644:", "pad.settings.fontType.normal": "\u0646\u0648\u0631\u0645\u0627\u0644", "pad.settings.fontType.monospaced": "\u0645\u0648\u0646\u0648\u0633\u067e\u06d0\u0633", + "pad.settings.globalView": "\u0646\u0693\u06d0\u0648\u0627\u0644\u0647 \u069a\u06a9\u0627\u0631\u06d0\u062f\u0646\u0647", "pad.settings.language": "\u0698\u0628\u0647:", + "pad.importExport.importSuccessful": "\u0628\u0631\u064a\u0627\u0644\u06cc \u0634\u0648!", "pad.importExport.exporthtml": "\u0627\u0686 \u067c\u064a \u0627\u0645 \u0627\u06d0\u0644", "pad.importExport.exportplain": "\u0633\u0627\u062f\u0647 \u0645\u062a\u0646", "pad.importExport.exportword": "\u0645\u0627\u064a\u06a9\u0631\u0648\u0633\u0627\u0641\u067c \u0648\u0631\u0689", diff --git a/src/locales/pt-br.json b/src/locales/pt-br.json index 6562681a..e029165d 100644 --- a/src/locales/pt-br.json +++ b/src/locales/pt-br.json @@ -19,7 +19,7 @@ "pad.toolbar.clearAuthorship.title": "Limpar as cores de identifica\u00e7\u00e3o de autoria", "pad.toolbar.import_export.title": "Importar\/Exportar de\/para diferentes formatos de arquivo", "pad.toolbar.timeslider.title": "Linha do tempo", - "pad.toolbar.savedRevision.title": "Revis\u00f5es Salvas", + "pad.toolbar.savedRevision.title": "Salvar revis\u00e3o", "pad.toolbar.settings.title": "Configura\u00e7\u00f5es", "pad.toolbar.embed.title": "Incorporar esta Nota", "pad.toolbar.showusers.title": "Mostrar os usuarios nesta Nota", @@ -100,6 +100,8 @@ "timeslider.month.october": "Outubro", "timeslider.month.november": "Novembro", "timeslider.month.december": "Dezembro", + "timeslider.unnamedauthor": "{{num}} autor desconhecido", + "timeslider.unnamedauthors": "{{num}} autores desconhecidos", "pad.savedrevs.marked": "Esta revis\u00e3o foi marcada como salva", "pad.userlist.entername": "Insira o seu nome", "pad.userlist.unnamed": "Sem t\u00edtulo", diff --git a/src/locales/ru.json b/src/locales/ru.json index 1f2fbda6..4e4c4050 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -103,6 +103,8 @@ "timeslider.month.october": "\u043e\u043a\u0442\u044f\u0431\u0440\u044c", "timeslider.month.november": "\u043d\u043e\u044f\u0431\u0440\u044c", "timeslider.month.december": "\u0434\u0435\u043a\u0430\u0431\u0440\u044c", + "timeslider.unnamedauthor": "{{num}} \u0431\u0435\u0437\u044b\u043c\u044f\u043d\u043d\u044b\u0439 \u0430\u0432\u0442\u043e\u0440", + "timeslider.unnamedauthors": "\u0431\u0435\u0437\u044b\u043c\u044f\u043d\u043d\u044b\u0445 \u0430\u0432\u0442\u043e\u0440\u043e\u0432: {{num}}", "pad.savedrevs.marked": "\u042d\u0442\u0430 \u0432\u0435\u0440\u0441\u0438\u044f \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u0430 \u043a\u0430\u043a \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u0430\u044f", "pad.userlist.entername": "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432\u0430\u0448\u0435 \u0438\u043c\u044f", "pad.userlist.unnamed": "\u0431\u0435\u0437\u044b\u043c\u044f\u043d\u043d\u044b\u0439", diff --git a/src/locales/sl.json b/src/locales/sl.json index c7cffa6f..edfa68c0 100644 --- a/src/locales/sl.json +++ b/src/locales/sl.json @@ -100,6 +100,8 @@ "timeslider.month.october": "Oktober", "timeslider.month.november": "November", "timeslider.month.december": "December", + "timeslider.unnamedauthor": "neimenovani avtor {{num}}", + "timeslider.unnamedauthors": "{{num}} neimenovani avtorji", "pad.savedrevs.marked": "Ta predelava je ozna\u010dena kot shranjena predelava.", "pad.userlist.entername": "Vpi\u0161ite ime", "pad.userlist.unnamed": "neimenovana oseba", diff --git a/src/locales/sv.json b/src/locales/sv.json index fa493bfe..8c6c2d86 100644 --- a/src/locales/sv.json +++ b/src/locales/sv.json @@ -100,6 +100,8 @@ "timeslider.month.october": "oktober", "timeslider.month.november": "november", "timeslider.month.december": "december", + "timeslider.unnamedauthor": "{{num}} namnl\u00f6s f\u00f6rfattare", + "timeslider.unnamedauthors": "{{num}} namnl\u00f6sa f\u00f6rfattare", "pad.savedrevs.marked": "Denna revision \u00e4r nu markerad som en sparad revision", "pad.userlist.entername": "Ange ditt namn", "pad.userlist.unnamed": "namnl\u00f6s", diff --git a/src/locales/te.json b/src/locales/te.json index 7e18b7a4..666a40aa 100644 --- a/src/locales/te.json +++ b/src/locales/te.json @@ -38,6 +38,7 @@ "pad.settings.language": "\u0c2d\u0c3e\u0c37", "pad.importExport.import_export": "\u0c26\u0c3f\u0c17\u0c41\u0c2e\u0c24\u0c3f\/\u0c0e\u0c17\u0c41\u0c2e\u0c24\u0c3f", "pad.importExport.import": "\u0c2a\u0c3e\u0c20\u0c2e\u0c41 \u0c26\u0c38\u0c4d\u0c24\u0c4d\u0c30\u0c2e\u0c41 \u0c32\u0c47\u0c26\u0c3e \u0c2a\u0c24\u0c4d\u0c30\u0c2e\u0c41\u0c28\u0c41 \u0c26\u0c3f\u0c17\u0c41\u0c2e\u0c24\u0c3f \u0c1a\u0c47\u0c2f\u0c41\u0c2e\u0c41", + "pad.importExport.importSuccessful": "\u0c35\u0c3f\u0c1c\u0c2f\u0c35\u0c02\u0c24\u0c02!", "pad.importExport.export": "\u0c2a\u0c4d\u0c30\u0c38\u0c4d\u0c24\u0c41\u0c24 \u0c2a\u0c32\u0c15\u0c28\u0c3f \u0c08 \u0c35\u0c3f\u0c27\u0c2e\u0c41\u0c17\u0c3e \u0c0e\u0c17\u0c41\u0c2e\u0c24\u0c3f \u0c1a\u0c47\u0c2f\u0c41\u0c2e\u0c41:", "pad.importExport.exporthtml": "\u0c39\u0c46\u0c1a\u0c4d \u0c1f\u0c3f \u0c0e\u0c02 \u0c0e\u0c32\u0c4d", "pad.importExport.exportplain": "\u0c38\u0c3e\u0c26\u0c3e \u0c2a\u0c3e\u0c20\u0c4d\u0c2f\u0c02", diff --git a/src/locales/uk.json b/src/locales/uk.json index ae6cbbb6..0da478cc 100644 --- a/src/locales/uk.json +++ b/src/locales/uk.json @@ -102,6 +102,8 @@ "timeslider.month.october": "\u0416\u043e\u0432\u0442\u0435\u043d\u044c", "timeslider.month.november": "\u041b\u0438\u0441\u0442\u043e\u043f\u0430\u0434", "timeslider.month.december": "\u0413\u0440\u0443\u0434\u0435\u043d\u044c", + "timeslider.unnamedauthor": "{{num}} \u0431\u0435\u0437\u0456\u043c\u0435\u043d\u043d\u0438\u0439 \u0430\u0432\u0442\u043e\u0440", + "timeslider.unnamedauthors": "\u0431\u0435\u0437\u0456\u043c\u0435\u043d\u043d\u0438\u0445 \u0430\u0432\u0442\u043e\u0440\u043e\u0432: {{num}}", "pad.savedrevs.marked": "\u0426\u044e \u0432\u0435\u0440\u0441\u0456\u044e \u043f\u043e\u043c\u0456\u0447\u0435\u043d\u043e \u0437\u0431\u0435\u0440\u0435\u0436\u0435\u043d\u043e\u044e \u0432\u0435\u0440\u0441\u0456\u0454\u044e", "pad.userlist.entername": "\u0412\u0432\u0435\u0434\u0456\u0442\u044c \u0412\u0430\u0448\u0435 \u0456\u043c'\u044f", "pad.userlist.unnamed": "\u0431\u0435\u0437\u0456\u043c\u0435\u043d\u043d\u0438\u0439", diff --git a/src/locales/zh-hans.json b/src/locales/zh-hans.json index 4e394e91..a98ebfce 100644 --- a/src/locales/zh-hans.json +++ b/src/locales/zh-hans.json @@ -3,6 +3,8 @@ "authors": [ "Dimension", "Hydra", + "Yfdyh000", + "\u4e4c\u62c9\u8de8\u6c2a", "\u71c3\u7389" ] }, @@ -18,8 +20,9 @@ "pad.toolbar.undo.title": "\u64a4\u6d88 (Ctrl-Z)", "pad.toolbar.redo.title": "\u91cd\u505a (Ctrl-Y)", "pad.toolbar.clearAuthorship.title": "\u6e05\u9664\u4f5c\u540d\u989c\u8272", + "pad.toolbar.import_export.title": "\u4ee5\u5176\u4ed6\u6587\u4ef6\u683c\u5f0f\u5bfc\u5165\/\u5bfc\u51fa", "pad.toolbar.timeslider.title": "\u65f6\u95f4\u8f74", - "pad.toolbar.savedRevision.title": "\u5df2\u4fdd\u5b58\u7684\u4fee\u8ba2", + "pad.toolbar.savedRevision.title": "\u4fdd\u5b58\u4fee\u8ba2", "pad.toolbar.settings.title": "\u8bbe\u7f6e", "pad.toolbar.embed.title": "\u5d4c\u5165\u6b64\u8bb0\u4e8b\u672c", "pad.toolbar.showusers.title": "\u663e\u793a\u6b64\u8bb0\u4e8b\u672c\u7684\u7528\u6237", @@ -30,12 +33,19 @@ "pad.permissionDenied": "\u60a8\u6ca1\u6709\u89c2\u770b\u8fd9\u4e2a\u8bb0\u4e8b\u672c\u7684\u6743\u9650", "pad.wrongPassword": "\u60a8\u7684\u5bc6\u7801\u9519\u4e86", "pad.settings.padSettings": "\u8bb0\u4e8b\u672c\u8bbe\u7f6e", + "pad.settings.myView": "\u6211\u7684\u89c6\u7a97", + "pad.settings.stickychat": "\u603b\u662f\u5728\u5c4f\u5e55\u4e0a\u663e\u793a\u804a\u5929", + "pad.settings.colorcheck": "\u4f5c\u8005\u989c\u8272", "pad.settings.linenocheck": "\u884c\u53f7", "pad.settings.fontType": "\u5b57\u4f53\u7c7b\u578b\uff1a", "pad.settings.fontType.normal": "\u6b63\u5e38", + "pad.settings.fontType.monospaced": "\u7b49\u5bbd\u5b57\u4f53", + "pad.settings.globalView": "\u6240\u6709\u4eba\u7684\u89c6\u7a97", "pad.settings.language": "\u8bed\u8a00\uff1a", "pad.importExport.import_export": "\u5bfc\u5165\/\u5bfc\u51fa", + "pad.importExport.import": "\u4e0a\u8f7d\u4efb\u4f55\u6587\u5b57\u6863\u6216\u6587\u6863", "pad.importExport.importSuccessful": "\u6210\u529f\uff01", + "pad.importExport.export": "\u5bfc\u51fa\u76ee\u524d\u7684\u8bb0\u4e8b\u7c3f\u4e3a\uff1a", "pad.importExport.exporthtml": "HTML", "pad.importExport.exportplain": "\u7eaf\u6587\u672c", "pad.importExport.exportword": "Microsoft Word", @@ -43,21 +53,36 @@ "pad.importExport.exportopen": "ODF\uff08\u5f00\u653e\u6587\u6863\u683c\u5f0f\uff09", "pad.importExport.exportdokuwiki": "DokuWiki", "pad.modals.connected": "\u5df2\u8fde\u63a5\u3002", + "pad.modals.reconnecting": "\u91cd\u65b0\u8fde\u63a5\u5230\u60a8\u7684\u8bb0\u4e8b\u7c3f...", "pad.modals.forcereconnect": "\u5f3a\u5236\u91cd\u65b0\u8fde\u63a5", + "pad.modals.userdup": "\u5728\u53e6\u4e00\u4e2a\u89c6\u7a97\u4e2d\u6253\u5f00", + "pad.modals.userdup.explanation": "\u6b64\u8bb0\u4e8b\u7c3f\u4f3c\u4e4e\u5728\u6b64\u7535\u8111\u4e0a\u5728\u591a\u4e2a\u6d4f\u89c8\u5668\u89c6\u7a97\u4e2d\u6253\u5f00\u3002", + "pad.modals.userdup.advice": "\u91cd\u65b0\u8fde\u63a5\u5230\u6b64\u89c6\u7a97\u3002", "pad.modals.unauth": "\u672a\u6388\u6743", "pad.modals.looping": "\u5df2\u79bb\u7ebf\u3002", + "pad.modals.initsocketfail": "\u65e0\u6cd5\u8bbf\u95ee\u670d\u52a1\u5668\u3002", + "pad.modals.initsocketfail.explanation": "\u65e0\u6cd5\u8fde\u63a5\u5230\u540c\u6b65\u670d\u52a1\u5668\u3002", + "pad.modals.initsocketfail.cause": "\u8fd9\u53ef\u80fd\u662f\u7531\u4e8e\u60a8\u7684\u6d4f\u89c8\u5668\u6216\u60a8\u7684\u4e92\u8054\u7f51\u8fde\u63a5\u7684\u95ee\u9898\u3002", "pad.modals.slowcommit": "\u5df2\u79bb\u7ebf\u3002", + "pad.modals.slowcommit.explanation": "\u670d\u52a1\u5668\u6ca1\u6709\u54cd\u5e94\u3002", + "pad.modals.slowcommit.cause": "\u8fd9\u53ef\u80fd\u662f\u7531\u4e8e\u7f51\u7edc\u8fde\u63a5\u95ee\u9898\u3002", "pad.modals.deleted": "\u5df2\u522a\u9664\u3002", "pad.modals.deleted.explanation": "\u6b64\u8bb0\u4e8b\u672c\u5df2\u88ab\u79fb\u9664\u3002", "pad.modals.disconnected": "\u60a8\u5df2\u88ab\u79bb\u7ebf\u3002", + "pad.modals.disconnected.explanation": "\u5230\u670d\u52a1\u5668\u7684\u8fde\u63a5\u5df2\u4e22\u5931", + "pad.modals.disconnected.cause": "\u670d\u52a1\u5668\u53ef\u80fd\u65e0\u6cd5\u4f7f\u7528\u3002\u82e5\u6b64\u60c5\u51b5\u6301\u7eed\u53d1\u751f\uff0c\u8bf7\u901a\u77e5\u6211\u4eec\u3002", "pad.share": "\u5206\u4eab\u6b64\u8bb0\u4e8b\u672c", "pad.share.readonly": "\u53ea\u80fd\u8bfb", "pad.share.link": "\u94fe\u63a5", "pad.share.emebdcode": "\u5d4c\u5165\u7f51\u5740", "pad.chat": "\u804a\u5929", + "pad.chat.title": "\u6253\u5f00\u6b64\u8bb0\u4e8b\u7c3f\u7684\u804a\u5929\u3002", + "pad.chat.loadmessages": "\u52a0\u8f7d\u66f4\u591a\u4fe1\u606f", "timeslider.toolbar.returnbutton": "\u8fd4\u56de\u8bb0\u4e8b\u672c", "timeslider.toolbar.authors": "\u4f5c\u8005\uff1a", "timeslider.toolbar.authorsList": "\u6ca1\u6709\u4f5c\u8005", + "timeslider.toolbar.exportlink.title": "\u5bfc\u51fa", + "timeslider.exportCurrent": "\u5bfc\u51fa\u76ee\u524d\u7248\u672c\u4e3a\uff1a", "timeslider.version": "\u7b2c {{version}} \u7248\u672c", "timeslider.saved": "\u5728{{year}}\u5e74{{month}}{{day}}\u65e5\u4fdd\u5b58", "timeslider.month.january": "\u4e00\u6708", @@ -72,13 +97,20 @@ "timeslider.month.october": "\u5341\u6708", "timeslider.month.november": "\u5341\u4e00\u6708", "timeslider.month.december": "\u5341\u4e8c\u6708", + "timeslider.unnamedauthor": "{{num}}\u533f\u540d\u4f5c\u8005", + "timeslider.unnamedauthors": "{{num}}\u533f\u540d\u4f5c\u8005", + "pad.savedrevs.marked": "\u6b64\u4fee\u8ba2\u5df2\u6807\u8bb0\u4e3a\u4fdd\u5b58\u4fee\u8ba2", "pad.userlist.entername": "\u8f93\u5165\u60a8\u7684\u59d3\u540d", "pad.userlist.unnamed": "\u65e0\u540d", "pad.userlist.guest": "\u8bbf\u5ba2", "pad.userlist.deny": "\u62d2\u7edd", "pad.userlist.approve": "\u6279\u51c6", + "pad.editbar.clearcolors": "\u6e05\u9664\u6574\u4e2a\u6587\u6863\u7684\u4f5c\u8005\u989c\u8272\u5417\uff1f", "pad.impexp.importbutton": "\u73b0\u5728\u5bfc\u5165", "pad.impexp.importing": "\u6b63\u5728\u5bfc\u5165...", + "pad.impexp.convertFailed": "\u6211\u4eec\u65e0\u6cd5\u5bfc\u5165\u6b64\u6587\u6863\u3002\u8bf7\u4f7f\u7528\u4ed6\u6587\u6863\u683c\u5f0f\u6216\u624b\u52a8\u590d\u5236\u8d34\u4e0a\u3002", "pad.impexp.uploadFailed": "\u4e0a\u8f7d\u5931\u8d25\uff0c\u8bf7\u91cd\u8bd5", - "pad.impexp.importfailed": "\u5bfc\u5165\u5931\u8d25" + "pad.impexp.importfailed": "\u5bfc\u5165\u5931\u8d25", + "pad.impexp.copypaste": "\u8bf7\u590d\u5236\u7c98\u8d34", + "pad.impexp.exportdisabled": "{{type}} \u683c\u5f0f\u7684\u5bfc\u51fa\u88ab\u7981\u7528\u3002\u6709\u5173\u8be6\u60c5\uff0c\u8bf7\u4e0e\u60a8\u7684\u7cfb\u7edf\u7ba1\u7406\u5458\u8054\u7cfb\u3002" }
\ No newline at end of file diff --git a/src/locales/zh-hant.json b/src/locales/zh-hant.json index 6ee1e377..efe4da61 100644 --- a/src/locales/zh-hant.json +++ b/src/locales/zh-hant.json @@ -1,7 +1,8 @@ { "@metadata": { "authors": { - "1": "Simon Shek" + "0": "Shirayuki", + "2": "Simon Shek" } }, "index.newPad": "\u65b0Pad", @@ -19,7 +20,7 @@ "pad.toolbar.clearAuthorship.title": "\u6e05\u9664\u4f5c\u540d\u984f\u8272", "pad.toolbar.import_export.title": "\u4ee5\u5176\u4ed6\u6a94\u6848\u683c\u5f0f\u5c0e\u5165\uff0f\u532f\u51fa", "pad.toolbar.timeslider.title": "\u6642\u9593\u8ef8", - "pad.toolbar.savedRevision.title": "\u5df2\u5132\u5b58\u7684\u4fee\u8a02", + "pad.toolbar.savedRevision.title": "\u5132\u5b58\u4fee\u8a02", "pad.toolbar.settings.title": "\u8a2d\u5b9a", "pad.toolbar.embed.title": "\u5d4c\u5165\u6b64pad", "pad.toolbar.showusers.title": "\u986f\u793a\u6b64pad\u7684\u7528\u6236", @@ -86,8 +87,8 @@ "timeslider.toolbar.exportlink.title": "\u532f\u51fa", "timeslider.exportCurrent": "\u532f\u51fa\u7576\u524d\u7248\u672c\u70ba\uff1a", "timeslider.version": "\u7248\u672c{{version}}", - "timeslider.saved": "{{year}}{{month}}{{day}}\u4fdd\u5b58", - "timeslider.dateformat": "{{year}}{{month}}{{day}} {{hours}}:{{minutes}}:{{seconds}}", + "timeslider.saved": "{{year}}\u5e74{{month}}{{day}}\u65e5\u4fdd\u5b58", + "timeslider.dateformat": "{{year}}\u5e74{{month}}\u6708{{day}}\u65e5 {{hours}}:{{minutes}}:{{seconds}}", "timeslider.month.january": "1\u6708", "timeslider.month.february": "2\u6708", "timeslider.month.march": "3\u6708", @@ -100,6 +101,8 @@ "timeslider.month.october": "10\u6708", "timeslider.month.november": "11\u6708", "timeslider.month.december": "12\u6708", + "timeslider.unnamedauthor": "{{num}} \u533f\u540d\u4f5c\u8005", + "timeslider.unnamedauthors": "{{num}} \u533f\u540d\u4f5c\u8005", "pad.savedrevs.marked": "\u6b64\u4fee\u8a02\u5df2\u6a19\u8a18\u70ba\u5df2\u4fdd\u5b58\u3002", "pad.userlist.entername": "\u8f38\u5165\u60a8\u7684\u59d3\u540d", "pad.userlist.unnamed": "\u672a\u547d\u540d", diff --git a/src/node/db/API.js b/src/node/db/API.js index f99a43af..3955d495 100644 --- a/src/node/db/API.js +++ b/src/node/db/API.js @@ -253,9 +253,7 @@ exports.getHTML = function(padID, rev, callback) exportHtml.getPadHTML(pad, undefined, function (err, html) { if(ERR(err, callback)) return; - data = {html: html}; - callback(null, data); }); } @@ -325,17 +323,17 @@ exports.getChatHistory = function(padID, start, end, callback) if(!start ||Â !end) { start = 0; - end = pad.chatHead - 1; + end = pad.chatHead; } - if(start >= chatHead) + if(start >= chatHead && chatHead > 0) { callback(new customError("start is higher or equal to the current chatHead","apierror")); return; } - if(end >= chatHead) + if(end > chatHead) { - callback(new customError("end is higher or equal to the current chatHead","apierror")); + callback(new customError("end is higher than the current chatHead","apierror")); return; } diff --git a/src/node/db/PadManager.js b/src/node/db/PadManager.js index 5e0af464..7d546fc7 100644 --- a/src/node/db/PadManager.js +++ b/src/node/db/PadManager.js @@ -146,12 +146,11 @@ exports.getPad = function(id, text, callback) else { pad = new Pad(id); - + //initalize the pad pad.init(text, function(err) { if(ERR(err, callback)) return; - globalPads.set(id, pad); callback(null, pad); }); diff --git a/src/node/db/SessionManager.js b/src/node/db/SessionManager.js index 5ce4f748..60e0a7ac 100644 --- a/src/node/db/SessionManager.js +++ b/src/node/db/SessionManager.js @@ -1,5 +1,5 @@ /** - * The Session Manager provides functions to manage session in the database + * The Session Manager provides functions to manage session in the database, it only provides session management for sessions created by the API */ /* diff --git a/src/node/db/SessionStore.js b/src/node/db/SessionStore.js new file mode 100644 index 00000000..09ea7333 --- /dev/null +++ b/src/node/db/SessionStore.js @@ -0,0 +1,82 @@ + /* + * Stores session data in the database + * Source; https://github.com/edy-b/SciFlowWriter/blob/develop/available_plugins/ep_sciflowwriter/db/DirtyStore.js + * This is not used for authors that are created via the API at current + */ + +var Store = require('ep_etherpad-lite/node_modules/connect/lib/middleware/session/store'), + utils = require('ep_etherpad-lite/node_modules/connect/lib/utils'), + Session = require('ep_etherpad-lite/node_modules/connect/lib/middleware/session/session'), + db = require('ep_etherpad-lite/node/db/DB').db, + log4js = require('ep_etherpad-lite/node_modules/log4js'), + messageLogger = log4js.getLogger("SessionStore"); + +var SessionStore = module.exports = function SessionStore() {}; + +SessionStore.prototype.__proto__ = Store.prototype; + +SessionStore.prototype.get = function(sid, fn){ + messageLogger.debug('GET ' + sid); + var self = this; + db.get("sessionstorage:" + sid, function (err, sess) + { + if (sess) { + sess.cookie.expires = 'string' == typeof sess.cookie.expires ? new Date(sess.cookie.expires) : sess.cookie.expires; + if (!sess.cookie.expires || new Date() < expires) { + fn(null, sess); + } else { + self.destroy(sid, fn); + } + } else { + fn(); + } + }); +}; + +SessionStore.prototype.set = function(sid, sess, fn){ + messageLogger.debug('SET ' + sid); + db.set("sessionstorage:" + sid, sess); + process.nextTick(function(){ + if(fn) fn(); + }); +}; + +SessionStore.prototype.destroy = function(sid, fn){ + messageLogger.debug('DESTROY ' + sid); + db.remove("sessionstorage:" + sid); + process.nextTick(function(){ + if(fn) fn(); + }); +}; + +SessionStore.prototype.all = function(fn){ + messageLogger.debug('ALL'); + var sessions = []; + db.forEach(function(key, value){ + if (key.substr(0,15) === "sessionstorage:") { + sessions.push(value); + } + }); + fn(null, sessions); +}; + +SessionStore.prototype.clear = function(fn){ + messageLogger.debug('CLEAR'); + db.forEach(function(key, value){ + if (key.substr(0,15) === "sessionstorage:") { + db.db.remove("session:" + key); + } + }); + if(fn) fn(); +}; + +SessionStore.prototype.length = function(fn){ + messageLogger.debug('LENGTH'); + var i = 0; + db.forEach(function(key, value){ + if (key.substr(0,15) === "sessionstorage:") { + i++; + } + }); + fn(null, i); +}; diff --git a/src/node/handler/APIHandler.js b/src/node/handler/APIHandler.js index 9f86277a..8be5b5fe 100644 --- a/src/node/handler/APIHandler.js +++ b/src/node/handler/APIHandler.js @@ -216,6 +216,9 @@ var version = } }; +// set the latest available API version here +exports.latestApiVersion = '1.2.7'; + /** * Handles a HTTP API call * @param functionName the name of the called function diff --git a/src/node/handler/ExportHandler.js b/src/node/handler/ExportHandler.js index 1b7fcc26..8ff5bc48 100644 --- a/src/node/handler/ExportHandler.js +++ b/src/node/handler/ExportHandler.js @@ -20,6 +20,7 @@ var ERR = require("async-stacktrace"); var exporthtml = require("../utils/ExportHtml"); +var exporttxt = require("../utils/ExportTxt"); var exportdokuwiki = require("../utils/ExportDokuWiki"); var padManager = require("../db/PadManager"); var async = require("async"); @@ -48,22 +49,75 @@ exports.doExport = function(req, res, padId, type) res.attachment(padId + "." + type); //if this is a plain text export, we can do this directly + // We have to over engineer this because tabs are stored as attributes and not plain text + if(type == "txt") { - padManager.getPad(padId, function(err, pad) - { - ERR(err); - if(req.params.rev){ - pad.getInternalRevisionAText(req.params.rev, function(junk, text) + var txt; + var randNum; + var srcFile, destFile; + + async.series([ + //render the txt document + function(callback) + { + exporttxt.getPadTXTDocument(padId, req.params.rev, false, function(err, _txt) { - res.send(text.text ? text.text : null); + if(ERR(err, callback)) return; + txt = _txt; + callback(); }); - } - else + }, + //decide what to do with the txt export + function(callback) + { + //if this is a txt export, we can send this from here directly + res.send(txt); + callback("stop"); + }, + //send the convert job to abiword + function(callback) + { + //ensure html can be collected by the garbage collector + txt = null; + + destFile = tempDirectory + "/eplite_export_" + randNum + "." + type; + abiword.convertFile(srcFile, destFile, type, callback); + }, + //send the file + function(callback) { - res.send(pad.text()); + res.sendfile(destFile, null, callback); + }, + //clean up temporary files + function(callback) + { + async.parallel([ + function(callback) + { + fs.unlink(srcFile, callback); + }, + function(callback) + { + //100ms delay to accomidate for slow windows fs + if(os.type().indexOf("Windows") > -1) + { + setTimeout(function() + { + fs.unlink(destFile, callback); + }, 100); + } + else + { + fs.unlink(destFile, callback); + } + } + ], callback); } - }); + ], function(err) + { + if(err && err != "stop") ERR(err); + }) } else if(type == 'dokuwiki') { diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index 6781cd88..15a9b8ea 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -32,15 +32,11 @@ var securityManager = require("../db/SecurityManager"); var plugins = require("ep_etherpad-lite/static/js/pluginfw/plugins.js"); var log4js = require('log4js'); var messageLogger = log4js.getLogger("message"); +var accessLogger = log4js.getLogger("access"); var _ = require('underscore'); var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks.js"); /** - * A associative array that saves which sessions belong to a pad - */ -var pad2sessions = {}; - -/** * A associative array that saves informations about a session * key = sessionId * values = padId, readonlyPadId, readonly, author, rev @@ -83,14 +79,11 @@ exports.handleConnect = function(client) exports.kickSessionsFromPad = function(padID) { //skip if there is nobody on this pad - if(!pad2sessions[padID]) + if(socketio.sockets.clients(padID).length == 0) return; //disconnect everyone from this pad - for(var i in pad2sessions[padID]) - { - socketio.sockets.sockets[pad2sessions[padID][i]].json.send({disconnect:"deleted"}); - } + socketio.sockets.in(padID).json.send({disconnect:"deleted"}); } /** @@ -100,15 +93,13 @@ exports.kickSessionsFromPad = function(padID) exports.handleDisconnect = function(client) { //save the padname of this session - var sessionPad=sessioninfos[client.id].padId; + var session = sessioninfos[client.id]; //if this connection was already etablished with a handshake, send a disconnect message to the others - if(sessioninfos[client.id] && sessioninfos[client.id].author) + if(session && session.author) { - var author = sessioninfos[client.id].author; - //get the author color out of the db - authorManager.getAuthorColorId(author, function(err, color) + authorManager.getAuthorColorId(session.author, function(err, color) { ERR(err); @@ -121,32 +112,19 @@ exports.handleDisconnect = function(client) "ip": "127.0.0.1", "colorId": color, "userAgent": "Anonymous", - "userId": author + "userId": session.author } } }; //Go trough all user that are still on the pad, and send them the USER_LEAVE message - for(i in pad2sessions[sessionPad]) - { - var socket = socketio.sockets.sockets[pad2sessions[sessionPad][i]]; - if(socket !== undefined){ - socket.json.send(messageToTheOtherUsers); - } - - } + client.broadcast.to(session.padId).json.send(messageToTheOtherUsers); }); } - //Go trough all sessions of this pad, search and destroy the entry of this client - for(i in pad2sessions[sessionPad]) - { - if(pad2sessions[sessionPad][i] == client.id) - { - pad2sessions[sessionPad].splice(i, 1); - break; - } - } + client.get('remoteAddress', function(er, ip) { + accessLogger.info('[LEAVE] Pad "'+session.padId+'": Author "'+session.author+'" on client '+client.id+' with IP "'+ip+'" left the pad') + }) //Delete the sessioninfos entrys of this session delete sessioninfos[client.id]; @@ -228,11 +206,10 @@ exports.handleMessage = function(client, message) function(callback) { - if(!message.padId){ - // If the message has a padId we assume the client is already known to the server and needs no re-authorization - callback(); - return; - } + // If the message has a padId we assume the client is already known to the server and needs no re-authorization + if(!message.padId) + return callback(); + // Note: message.sessionID is an entirely different kind of // session from the sessions we use here! Beware! FIXME: Call // our "sessions" "connections". @@ -292,9 +269,7 @@ exports.handleCustomMessage = function (padID, msg, cb) { time: time } }; - for (var i in pad2sessions[padID]) { - socketio.sockets.sockets[pad2sessions[padID][i]].json.send(msg); - } + socketio.sockets.in(padID).json.send(msg); cb(null, {}); } @@ -352,10 +327,7 @@ function handleChatMessage(client, message) }; //broadcast the chat message to everyone on the pad - for(var i in pad2sessions[padId]) - { - socketio.sockets.sockets[pad2sessions[padId][i]].json.send(msg); - } + socketio.sockets.in(padId).json.send(msg); callback(); } @@ -413,23 +385,16 @@ function handleGetChatMessages(client, message) { if(ERR(err, callback)) return; - var infoMsg = { - type: "COLLABROOM", - data: { - type: "CHAT_MESSAGES", - messages: chatMessages - } - }; - - // send the messages back to the client - for(var i in pad2sessions[padId]) - { - if(pad2sessions[padId][i] == client.id) - { - socketio.sockets.sockets[pad2sessions[padId][i]].json.send(infoMsg); - break; + var infoMsg = { + type: "COLLABROOM", + data: { + type: "CHAT_MESSAGES", + messages: chatMessages } - } + }; + + // send the messages back to the client + client.json.send(infoMsg); }); }]); } @@ -453,14 +418,14 @@ function handleSuggestUserName(client, message) return; } - var padId = sessioninfos[client.id].padId; + var padId = sessioninfos[client.id].padId, + clients = socketio.sockets.clients(padId); //search the author and send him this message - for(var i in pad2sessions[padId]) - { - if(sessioninfos[pad2sessions[padId][i]].author == message.data.payload.unnamedId) - { - socketio.sockets.sockets[pad2sessions[padId][i]].send(message); + for(var i = 0; i < clients.length; i++) { + var session = sessioninfos[clients[i].id]; + if(session && session.author == message.data.payload.unnamedId) { + clients[i].json.send(message); break; } } @@ -501,7 +466,8 @@ function handleUserInfoUpdate(client, message) type: "USER_NEWINFO", userInfo: { userId: author, - name: message.data.userInfo.name, + //set a null name, when there is no name set. cause the client wants it null + name: message.data.userInfo.name || null, colorId: message.data.userInfo.colorId, userAgent: "Anonymous", ip: "127.0.0.1", @@ -509,20 +475,8 @@ function handleUserInfoUpdate(client, message) } }; - //set a null name, when there is no name set. cause the client wants it null - if(infoMsg.data.userInfo.name == null) - { - infoMsg.data.userInfo.name = null; - } - //Send the other clients on the pad the update message - for(var i in pad2sessions[padId]) - { - if(pad2sessions[padId][i] != client.id) - { - socketio.sockets.sockets[pad2sessions[padId][i]].json.send(infoMsg); - } - } + client.broadcast.to(padId).json.send(infoMsg); } /** @@ -632,7 +586,14 @@ function handleUserChanges(client, message) // client) are relative to revision r - 1. The follow function // rebases "changeset" so that it is relative to revision r // and can be applied after "c". - changeset = Changeset.follow(c, changeset, false, apool); + try + { + changeset = Changeset.follow(c, changeset, false, apool); + }catch(e){ + console.warn("Can't apply USER_CHANGES "+changeset+", possibly because of mismatched follow error"); + client.json.send({disconnect:"badChangeset"}); + return; + } if ((r - baseRev) % 200 == 0) { // don't let the stack get too deep async.nextTick(callback); @@ -682,90 +643,76 @@ function handleUserChanges(client, message) exports.updatePadClients = function(pad, callback) { //skip this step if noone is on this pad - if(!pad2sessions[pad.id]) - { - callback(); - return; - } + var roomClients = socketio.sockets.clients(pad.id); + if(roomClients.length==0) + return callback(); + // since all clients usually get the same set of changesets, store them in local cache + // to remove unnecessary roundtrip to the datalayer + // TODO: in REAL world, if we're working without datalayer cache, all requests to revisions will be fired + // BEFORE first result will be landed to our cache object. The solution is to replace parallel processing + // via async.forEach with sequential for() loop. There is no real benefits of running this in parallel, + // but benefit of reusing cached revision object is HUGE + var revCache = {}; + //go trough all sessions on this pad - async.forEach(pad2sessions[pad.id], function(session, callback) + async.forEach(roomClients, function(client, callback) { + var sid = client.id; //https://github.com/caolan/async#whilst //send them all new changesets async.whilst( - function (){ return sessioninfos[session] && sessioninfos[session].rev < pad.getHeadRevisionNumber()}, + function (){ return sessioninfos[sid] && sessioninfos[sid].rev < pad.getHeadRevisionNumber()}, function(callback) { - var author, revChangeset, currentTime; - var r = sessioninfos[session].rev + 1; - - async.parallel([ - function (callback) - { - pad.getRevisionAuthor(r, function(err, value) - { - if(ERR(err, callback)) return; - author = value; - callback(); - }); - }, - function (callback) + var r = sessioninfos[sid].rev + 1; + + async.waterfall([ + function(callback) { + if(revCache[r]) + callback(null, revCache[r]); + else + pad.getRevision(r, callback); + }, + function(revision, callback) { - pad.getRevisionChangeset(r, function(err, value) + revCache[r] = revision; + + var author = revision.meta.author, + revChangeset = revision.changeset, + currentTime = revision.meta.timestamp; + + // next if session has not been deleted + if(sessioninfos[sid] == null) + return callback(null); + + if(author == sessioninfos[sid].author) { - if(ERR(err, callback)) return; - revChangeset = value; - callback(); - }); - }, - function (callback) - { - pad.getRevisionDate(r, function(err, date) + client.json.send({"type":"COLLABROOM","data":{type:"ACCEPT_COMMIT", newRev:r}}); + } + else { - if(ERR(err, callback)) return; - currentTime = date; - callback(); - }); - } - ], function(err) - { - if(ERR(err, callback)) return; - // next if session has not been deleted - if(sessioninfos[session] == null) - { + var forWire = Changeset.prepareForWire(revChangeset, pad.pool); + var wireMsg = {"type":"COLLABROOM", + "data":{type:"NEW_CHANGES", + newRev:r, + changeset: forWire.translated, + apool: forWire.pool, + author: author, + currentTime: currentTime, + timeDelta: currentTime - sessioninfos[sid].time + }}; + + client.json.send(wireMsg); + } + + sessioninfos[sid].time = currentTime; + sessioninfos[sid].rev = r; + callback(null); - return; } - if(author == sessioninfos[session].author) - { - socketio.sockets.sockets[session].json.send({"type":"COLLABROOM","data":{type:"ACCEPT_COMMIT", newRev:r}}); - } - else - { - var forWire = Changeset.prepareForWire(revChangeset, pad.pool); - var wireMsg = {"type":"COLLABROOM", - "data":{type:"NEW_CHANGES", - newRev:r, - changeset: forWire.translated, - apool: forWire.pool, - author: author, - currentTime: currentTime, - timeDelta: currentTime - sessioninfos[session].time - }}; - - socketio.sockets.sockets[session].json.send(wireMsg); - } - - if(sessioninfos[session] != null) - { - sessioninfos[session].time = currentTime; - sessioninfos[session].rev = r; - } - - callback(null); - }); + ], callback); }, callback ); @@ -895,23 +842,14 @@ function handleClientReady(client, message) function(callback) { async.parallel([ - //get colorId + //get colorId and name function(callback) { - authorManager.getAuthorColorId(author, function(err, value) + authorManager.getAuthor(author, function(err, value) { if(ERR(err, callback)) return; - authorColorId = value; - callback(); - }); - }, - //get author name - function(callback) - { - authorManager.getAuthorName(author, function(err, value) - { - if(ERR(err, callback)) return; - authorName = value; + authorColorId = value.colorId; + authorName = value.name; callback(); }); }, @@ -965,21 +903,17 @@ function handleClientReady(client, message) { //Check that the client is still here. It might have disconnected between callbacks. if(sessioninfos[client.id] === undefined) - { - callback(); - return; - } + return callback(); //Check if this author is already on the pad, if yes, kick the other sessions! - if(pad2sessions[padIds.padId]) - { - for(var i in pad2sessions[padIds.padId]) - { - if(sessioninfos[pad2sessions[padIds.padId][i]] && sessioninfos[pad2sessions[padIds.padId][i]].author == author) - { - var socket = socketio.sockets.sockets[pad2sessions[padIds.padId][i]]; - if(socket) socket.json.send({disconnect:"userdup"}); - } + var roomClients = socketio.sockets.clients(padIds.padId); + for(var i = 0; i < roomClients.length; i++) { + var sinfo = sessioninfos[roomClients[i].id]; + if(sinfo && sinfo.author == author) { + // fix user's counter, works on page refresh or if user closes browser window and then rejoins + sessioninfos[roomClients[i].id] = {}; + roomClients[i].leave(padIds.padId); + roomClients[i].json.send({disconnect:"userdup"}); } } @@ -988,18 +922,21 @@ function handleClientReady(client, message) sessioninfos[client.id].readOnlyPadId = padIds.readOnlyPadId; sessioninfos[client.id].readonly = padIds.readonly; - //check if there is already a pad2sessions entry, if not, create one - if(!pad2sessions[padIds.padId]) - { - pad2sessions[padIds.padId] = []; - } - - //Saves in pad2sessions that this session belongs to this pad - pad2sessions[padIds.padId].push(client.id); - + //Log creation/(re-)entering of a pad + client.get('remoteAddress', function(er, ip) { + if(pad.head > 0) { + accessLogger.info('[ENTER] Pad "'+padIds.padId+'": Client '+client.id+' with IP "'+ip+'" entered the pad'); + } + else if(pad.head == 0) { + accessLogger.info('[CREATE] Pad "'+padIds.padId+'": Client '+client.id+' with IP "'+ip+'" created the pad'); + } + }) + //If this is a reconnect, we don't have to send the client the ClientVars again if(message.reconnect == true) { + //Join the pad and start receiving updates + client.join(padIds.padId); //Save the revision in sessioninfos, we take the revision from the info the client send to us sessioninfos[client.id].rev = message.client_rev; } @@ -1044,17 +981,12 @@ function handleClientReady(client, message) // tell the client the number of the latest chat-message, which will be // used to request the latest 100 chat-messages later (GET_CHAT_MESSAGES) "chatHead": pad.chatHead, - "numConnectedUsers": pad2sessions[padIds.padId].length, - "isProPad": false, + "numConnectedUsers": roomClients.length, "readOnlyId": padIds.readOnlyPadId, "readonly": padIds.readonly, "serverTimestamp": new Date().getTime(), "globalPadId": message.padId, "userId": author, - "cookiePrefsToSet": { - "fullWidth": false, - "hideSidebar": false - }, "abiwordAvailable": settings.abiwordAvailable(), "plugins": { "plugins": plugins.plugins, @@ -1080,6 +1012,8 @@ function handleClientReady(client, message) } }); + //Join the pad and start receiving updates + client.join(padIds.padId); //Send the clientVars to the Client client.json.send({type: "CLIENT_VARS", data: clientVars}); //Save the current revision in sessioninfos, should be the same as in clientVars @@ -1108,74 +1042,56 @@ function handleClientReady(client, message) { messageToTheOtherUsers.data.userInfo.name = authorName; } + + // notify all existing users about new user + client.broadcast.to(padIds.padId).json.send(messageToTheOtherUsers); //Run trough all sessions of this pad - async.forEach(pad2sessions[padIds.padId], function(sessionID, callback) + async.forEach(socketio.sockets.clients(padIds.padId), function(roomClient, callback) { - var author, socket, sessionAuthorName, sessionAuthorColorId; + var author; + + //Jump over, if this session is the connection session + if(roomClient.id == client.id) + return callback(); + //Since sessioninfos might change while being enumerated, check if the //sessionID is still assigned to a valid session - if(sessioninfos[sessionID] !== undefined && - socketio.sockets.sockets[sessionID] !== undefined){ - author = sessioninfos[sessionID].author; - socket = socketio.sockets.sockets[sessionID]; - }else { - // If the sessionID is not valid, callback(); - callback(); - return; - } - async.series([ + if(sessioninfos[roomClient.id] !== undefined) + author = sessioninfos[roomClient.id].author; + else // If the client id is not valid, callback(); + return callback(); + + async.waterfall([ //get the authorname & colorId function(callback) { - async.parallel([ - function(callback) - { - authorManager.getAuthorColorId(author, function(err, value) - { - if(ERR(err, callback)) return; - sessionAuthorColorId = value; - callback(); - }) - }, - function(callback) - { - authorManager.getAuthorName(author, function(err, value) - { - if(ERR(err, callback)) return; - sessionAuthorName = value; - callback(); - }) - } - ],callback); + // reuse previously created cache of author's data + if(historicalAuthorData[author]) + callback(null, historicalAuthorData[author]); + else + authorManager.getAuthor(author, callback); }, - function (callback) + function (authorInfo, callback) { - //Jump over, if this session is the connection session - if(sessionID != client.id) - { - //Send this Session the Notification about the new user - socket.json.send(messageToTheOtherUsers); - - //Send the new User a Notification about this other user - var messageToNotifyTheClientAboutTheOthers = { - "type": "COLLABROOM", - "data": { - type: "USER_NEWINFO", - userInfo: { - "ip": "127.0.0.1", - "colorId": sessionAuthorColorId, - "name": sessionAuthorName, - "userAgent": "Anonymous", - "userId": author - } + //Send the new User a Notification about this other user + var msg = { + "type": "COLLABROOM", + "data": { + type: "USER_NEWINFO", + userInfo: { + "ip": "127.0.0.1", + "colorId": authorInfo.colorId, + "name": authorInfo.name, + "userAgent": "Anonymous", + "userId": author } - }; - client.json.send(messageToNotifyTheClientAboutTheOthers); - } + } + }; + client.json.send(msg); } - ], callback); + ], callback); }, callback); } ],function(err) @@ -1521,33 +1437,30 @@ function composePadChangesets(padId, startNum, endNum, callback) * Get the number of users in a pad */ exports.padUsersCount = function (padID, callback) { - if (!pad2sessions[padID] || typeof pad2sessions[padID] != typeof []) { - callback(null, {padUsersCount: 0}); - } else { - callback(null, {padUsersCount: pad2sessions[padID].length}); - } + callback(null, { + padUsersCount: socketio.sockets.clients(padID).length + }); } /** * Get the list of users in a pad */ exports.padUsers = function (padID, callback) { - if (!pad2sessions[padID] || typeof pad2sessions[padID] != typeof []) { - callback(null, {padUsers: []}); - } else { - var authors = []; - for ( var ix in sessioninfos ) { - if ( sessioninfos[ix].padId !== padID ) { - continue; - } - var aid = sessioninfos[ix].author; - authorManager.getAuthor( aid, function ( err, author ) { - author.id = aid; - authors.push( author ); - if ( authors.length === pad2sessions[padID].length ) { - callback(null, {padUsers: authors}); - } - } ); + var result = []; + + async.forEach(socketio.sockets.clients(padId), function(roomClient, callback) { + var s = sessioninfos[roomClient.id]; + if(s) { + authorManager.getAuthor(s.author, function(err, author) { + if(ERR(err, callback)) return; + + author.id = s.author; + result.push(author); + }); } - } + }, function(err) { + if(ERR(err, callback)) return; + + callback(null, {padUsers: result}); + }); } diff --git a/src/node/handler/SocketIORouter.js b/src/node/handler/SocketIORouter.js index f3b82b8c..483bb1d1 100644 --- a/src/node/handler/SocketIORouter.js +++ b/src/node/handler/SocketIORouter.js @@ -55,13 +55,14 @@ exports.setSocketIO = function(_socket) socket.sockets.on('connection', function(client) { + client.set('remoteAddress', client.handshake.address.address); var clientAuthorized = false; //wrap the original send function to log the messages client._send = client.send; client.send = function(message) { - messageLogger.info("to " + client.id + ": " + stringifyWithoutPassword(message)); + messageLogger.debug("to " + client.id + ": " + stringifyWithoutPassword(message)); client._send(message); } @@ -79,7 +80,7 @@ exports.setSocketIO = function(_socket) //check if component is registered in the components array if(components[message.component]) { - messageLogger.info("from " + client.id + ": " + stringifyWithoutPassword(message)); + messageLogger.debug("from " + client.id + ": " + stringifyWithoutPassword(message)); components[message.component].handleMessage(client, message); } } diff --git a/src/node/hooks/express/apicalls.js b/src/node/hooks/express/apicalls.js index e57e1d35..0971a877 100644 --- a/src/node/hooks/express/apicalls.js +++ b/src/node/hooks/express/apicalls.js @@ -57,4 +57,9 @@ exports.expressCreateServer = function (hook_name, args, cb) { res.end("OK"); }); }); + + //Provide a possibility to query the latest available API version + args.app.get('/api', function (req, res) { + res.json({"currentVersion" : apiHandler.latestApiVersion}); + }); } diff --git a/src/node/hooks/express/tests.js b/src/node/hooks/express/tests.js index 94cd5fb6..3157d68e 100644 --- a/src/node/hooks/express/tests.js +++ b/src/node/hooks/express/tests.js @@ -1,14 +1,26 @@ var path = require("path") , npm = require("npm") - , fs = require("fs"); + , fs = require("fs") + , async = require("async"); exports.expressCreateServer = function (hook_name, args, cb) { args.app.get('/tests/frontend/specs_list.js', function(req, res){ - fs.readdir('tests/frontend/specs', function(err, files){ - if(err){ return res.send(500); } - res.send("var specs_list = " + JSON.stringify(files.sort()) + ";\n"); + async.parallel({ + coreSpecs: function(callback){ + exports.getCoreTests(callback); + }, + pluginSpecs: function(callback){ + exports.getPluginTests(callback); + } + }, + function(err, results){ + var files = results.coreSpecs; // push the core specs to a file object + files = files.concat(results.pluginSpecs); // add the plugin Specs to the core specs + console.debug("Sent browser the following test specs:", files.sort()); + res.send("var specs_list = " + JSON.stringify(files.sort()) + ";\n"); }); + }); var url2FilePath = function(url){ @@ -44,4 +56,29 @@ exports.expressCreateServer = function (hook_name, args, cb) { args.app.get('/tests/frontend', function (req, res) { res.redirect('/tests/frontend/'); }); -}
\ No newline at end of file +} + +exports.getPluginTests = function(callback){ + var pluginSpecs = []; + var plugins = fs.readdirSync('node_modules'); + plugins.forEach(function(plugin){ + if(fs.existsSync("node_modules/"+plugin+"/static/tests/frontend/specs")){ // if plugins exists + var specFiles = fs.readdirSync("node_modules/"+plugin+"/static/tests/frontend/specs/"); + async.forEach(specFiles, function(spec){ // for each specFile push it to pluginSpecs + pluginSpecs.push("/static/plugins/"+plugin+"/static/tests/frontend/specs/" + spec); + }, + function(err){ + // blow up if something bad happens! + }); + } + }); + callback(null, pluginSpecs); +} + +exports.getCoreTests = function(callback){ + fs.readdir('tests/frontend/specs', function(err, coreSpecs){ // get the core test specs + if(err){ return res.send(500); } + callback(null, coreSpecs); + }); +} + diff --git a/src/node/hooks/express/webaccess.js b/src/node/hooks/express/webaccess.js index 50323ef6..c39f91da 100644 --- a/src/node/hooks/express/webaccess.js +++ b/src/node/hooks/express/webaccess.js @@ -4,7 +4,7 @@ var httpLogger = log4js.getLogger("http"); var settings = require('../../utils/Settings'); var randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString; var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks'); - +var ueberStore = require('../../db/SessionStore'); //checks for basic http auth exports.basicAuth = function (req, res, next) { @@ -102,15 +102,14 @@ exports.expressConfigure = function (hook_name, args, cb) { * handling it cleaner :) */ if (!exports.sessionStore) { - exports.sessionStore = new express.session.MemoryStore(); - exports.secret = randomString(32); + exports.sessionStore = new ueberStore(); + exports.secret = settings.sessionKey; // Isn't this being reset each time the server spawns? } - - args.app.use(express.cookieParser(exports.secret)); + args.app.use(express.cookieParser(exports.secret)); args.app.sessionStore = exports.sessionStore; - args.app.use(express.session({store: args.app.sessionStore, - key: 'express_sid' })); + args.app.use(express.session({secret: exports.secret, store: args.app.sessionStore, key: 'express_sid' })); args.app.use(exports.basicAuth); } + diff --git a/src/node/utils/ExportHelper.js b/src/node/utils/ExportHelper.js new file mode 100644 index 00000000..a939a8b6 --- /dev/null +++ b/src/node/utils/ExportHelper.js @@ -0,0 +1,87 @@ +/** + * Helpers for export requests + */ + +/* + * 2011 Peter 'Pita' Martischka (Primary Technology Ltd) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var async = require("async"); +var Changeset = require("ep_etherpad-lite/static/js/Changeset"); +var padManager = require("../db/PadManager"); +var ERR = require("async-stacktrace"); +var Security = require('ep_etherpad-lite/static/js/security'); +var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks'); + +exports.getPadPlainText = function(pad, revNum){ + var atext = ((revNum !== undefined) ? pad.getInternalRevisionAText(revNum) : pad.atext()); + var textLines = atext.text.slice(0, -1).split('\n'); + var attribLines = Changeset.splitAttributionLines(atext.attribs, atext.text); + var apool = pad.pool(); + + var pieces = []; + for (var i = 0; i < textLines.length; i++){ + var line = _analyzeLine(textLines[i], attribLines[i], apool); + if (line.listLevel){ + var numSpaces = line.listLevel * 2 - 1; + var bullet = '*'; + pieces.push(new Array(numSpaces + 1).join(' '), bullet, ' ', line.text, '\n'); + } + else{ + pieces.push(line.text, '\n'); + } + } + + return pieces.join(''); +} + + +exports._analyzeLine = function(text, aline, apool){ + var line = {}; + + // identify list + var lineMarker = 0; + line.listLevel = 0; + if (aline){ + var opIter = Changeset.opIterator(aline); + if (opIter.hasNext()){ + var listType = Changeset.opAttributeValue(opIter.next(), 'list', apool); + if (listType){ + lineMarker = 1; + listType = /([a-z]+)([12345678])/.exec(listType); + if (listType){ + line.listTypeName = listType[1]; + line.listLevel = Number(listType[2]); + } + } + } + } + if (lineMarker){ + line.text = text.substring(1); + line.aline = Changeset.subattribution(aline, 1); + } + else{ + line.text = text; + line.aline = aline; + } + return line; +} + + +exports._encodeWhitespace = function(s){ + return s.replace(/[^\x21-\x7E\s\t\n\r]/g, function(c){ + return "&#" +c.charCodeAt(0) + ";" + }); +} diff --git a/src/node/utils/ExportHtml.js b/src/node/utils/ExportHtml.js index 06919488..585694d4 100644 --- a/src/node/utils/ExportHtml.js +++ b/src/node/utils/ExportHtml.js @@ -21,31 +21,9 @@ var padManager = require("../db/PadManager"); var ERR = require("async-stacktrace"); var Security = require('ep_etherpad-lite/static/js/security'); var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks'); -function getPadPlainText(pad, revNum) -{ - var atext = ((revNum !== undefined) ? pad.getInternalRevisionAText(revNum) : pad.atext()); - var textLines = atext.text.slice(0, -1).split('\n'); - var attribLines = Changeset.splitAttributionLines(atext.attribs, atext.text); - var apool = pad.pool(); - - var pieces = []; - for (var i = 0; i < textLines.length; i++) - { - var line = _analyzeLine(textLines[i], attribLines[i], apool); - if (line.listLevel) - { - var numSpaces = line.listLevel * 2 - 1; - var bullet = '*'; - pieces.push(new Array(numSpaces + 1).join(' '), bullet, ' ', line.text, '\n'); - } - else - { - pieces.push(line.text, '\n'); - } - } - - return pieces.join(''); -} +var getPadPlainText = require('./ExportHelper').getPadPlainText +var _analyzeLine = require('./ExportHelper')._analyzeLine; +var _encodeWhitespace = require('./ExportHelper')._encodeWhitespace; function getPadHTML(pad, revNum, callback) { @@ -503,45 +481,6 @@ function getHTMLFromAtext(pad, atext, authorColors) return pieces.join(''); } -function _analyzeLine(text, aline, apool) -{ - var line = {}; - - // identify list - var lineMarker = 0; - line.listLevel = 0; - if (aline) - { - var opIter = Changeset.opIterator(aline); - if (opIter.hasNext()) - { - var listType = Changeset.opAttributeValue(opIter.next(), 'list', apool); - if (listType) - { - lineMarker = 1; - listType = /([a-z]+)([12345678])/.exec(listType); - if (listType) - { - line.listTypeName = listType[1]; - line.listLevel = Number(listType[2]); - } - } - } - } - if (lineMarker) - { - line.text = text.substring(1); - line.aline = Changeset.subattribution(aline, 1); - } - else - { - line.text = text; - line.aline = aline; - } - - return line; -} - exports.getPadHTMLDocument = function (padId, revNum, noDocType, callback) { padManager.getPad(padId, function (err, pad) @@ -578,72 +517,78 @@ exports.getPadHTMLDocument = function (padId, revNum, noDocType, callback) }); } -function _encodeWhitespace(s) { - return s.replace(/[^\x21-\x7E\s\t\n\r]/g, function(c) - { - return "&#" +c.charCodeAt(0) + ";" - }); -} // copied from ACE +var _REGEX_WORDCHAR = /[\u0030-\u0039\u0041-\u005A\u0061-\u007A\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\u1FFF\u3040-\u9FFF\uF900-\uFDFF\uFE70-\uFEFE\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFDC]/; +var _REGEX_SPACE = /\s/; +var _REGEX_URLCHAR = new RegExp('(' + /[-:@a-zA-Z0-9_.,~%+\/\\?=&#;()$]/.source + '|' + _REGEX_WORDCHAR.source + ')'); +var _REGEX_URL = new RegExp(/(?:(?:https?|s?ftp|ftps|file|smb|afp|nfs|(x-)?man|gopher|txmt):\/\/|mailto:)/.source + _REGEX_URLCHAR.source + '*(?![:.,;])' + _REGEX_URLCHAR.source, 'g'); + +// returns null if no URLs, or [[startIndex1, url1], [startIndex2, url2], ...] -function _processSpaces(s) +function _findURLs(text) { - var doesWrap = true; - if (s.indexOf("<") < 0 && !doesWrap) + _REGEX_URL.lastIndex = 0; + var urls = null; + var execResult; + while ((execResult = _REGEX_URL.exec(text))) { + urls = (urls || []); + var startIndex = execResult.index; + var url = execResult[0]; + urls.push([startIndex, url]); + } + + return urls; +} + + +// copied from ACE +function _processSpaces(s){ + var doesWrap = true; + if (s.indexOf("<") < 0 && !doesWrap){ // short-cut return s.replace(/ /g, ' '); } var parts = []; - s.replace(/<[^>]*>?| |[^ <]+/g, function (m) - { + s.replace(/<[^>]*>?| |[^ <]+/g, function (m){ parts.push(m); }); - if (doesWrap) - { + if (doesWrap){ var endOfLine = true; var beforeSpace = false; // last space in a run is normal, others are nbsp, // end of line is nbsp - for (var i = parts.length - 1; i >= 0; i--) - { + for (var i = parts.length - 1; i >= 0; i--){ var p = parts[i]; - if (p == " ") - { + if (p == " "){ if (endOfLine || beforeSpace) parts[i] = ' '; endOfLine = false; beforeSpace = true; } - else if (p.charAt(0) != "<") - { + else if (p.charAt(0) != "<"){ endOfLine = false; beforeSpace = false; } } // beginning of line is nbsp - for (var i = 0; i < parts.length; i++) - { + for (var i = 0; i < parts.length; i++){ var p = parts[i]; - if (p == " ") - { + if (p == " "){ parts[i] = ' '; break; } - else if (p.charAt(0) != "<") - { + else if (p.charAt(0) != "<"){ break; } } } else { - for (var i = 0; i < parts.length; i++) - { + for (var i = 0; i < parts.length; i++){ var p = parts[i]; - if (p == " ") - { + if (p == " "){ parts[i] = ' '; } } @@ -651,28 +596,3 @@ function _processSpaces(s) return parts.join(''); } - -// copied from ACE -var _REGEX_WORDCHAR = /[\u0030-\u0039\u0041-\u005A\u0061-\u007A\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\u1FFF\u3040-\u9FFF\uF900-\uFDFF\uFE70-\uFEFE\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFDC]/; -var _REGEX_SPACE = /\s/; -var _REGEX_URLCHAR = new RegExp('(' + /[-:@a-zA-Z0-9_.,~%+\/\\?=&#;()$]/.source + '|' + _REGEX_WORDCHAR.source + ')'); -var _REGEX_URL = new RegExp(/(?:(?:https?|s?ftp|ftps|file|smb|afp|nfs|(x-)?man|gopher|txmt):\/\/|mailto:)/.source + _REGEX_URLCHAR.source + '*(?![:.,;])' + _REGEX_URLCHAR.source, 'g'); - -// returns null if no URLs, or [[startIndex1, url1], [startIndex2, url2], ...] - - -function _findURLs(text) -{ - _REGEX_URL.lastIndex = 0; - var urls = null; - var execResult; - while ((execResult = _REGEX_URL.exec(text))) - { - urls = (urls || []); - var startIndex = execResult.index; - var url = execResult[0]; - urls.push([startIndex, url]); - } - - return urls; -} diff --git a/src/node/utils/ExportTxt.js b/src/node/utils/ExportTxt.js new file mode 100644 index 00000000..c57424f1 --- /dev/null +++ b/src/node/utils/ExportTxt.js @@ -0,0 +1,293 @@ +/** + * TXT export + */ + +/* + * 2013 John McLear + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var async = require("async"); +var Changeset = require("ep_etherpad-lite/static/js/Changeset"); +var padManager = require("../db/PadManager"); +var ERR = require("async-stacktrace"); +var Security = require('ep_etherpad-lite/static/js/security'); +var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks'); +var getPadPlainText = require('./ExportHelper').getPadPlainText; +var _analyzeLine = require('./ExportHelper')._analyzeLine; + +// This is slightly different than the HTML method as it passes the output to getTXTFromAText +function getPadTXT(pad, revNum, callback) +{ + var atext = pad.atext; + var html; + async.waterfall([ + // fetch revision atext + + + function (callback) + { + if (revNum != undefined) + { + pad.getInternalRevisionAText(revNum, function (err, revisionAtext) + { + if(ERR(err, callback)) return; + atext = revisionAtext; + callback(); + }); + } + else + { + callback(null); + } + }, + + // convert atext to html + + + function (callback) + { + html = getTXTFromAtext(pad, atext); // only this line is different to the HTML function + callback(null); + }], + // run final callback + + + function (err) + { + if(ERR(err, callback)) return; + callback(null, html); + }); +} + +exports.getPadTXT = getPadTXT; + + +// This is different than the functionality provided in ExportHtml as it provides formatting +// functionality that is designed specifically for TXT exports +function getTXTFromAtext(pad, atext, authorColors) +{ + var apool = pad.apool(); + var textLines = atext.text.slice(0, -1).split('\n'); + var attribLines = Changeset.splitAttributionLines(atext.attribs, atext.text); + + var tags = ['h1', 'h2', 'strong', 'em', 'u', 's']; + var props = ['heading1', 'heading2', 'bold', 'italic', 'underline', 'strikethrough']; + var anumMap = {}; + var css = ""; + + props.forEach(function (propName, i) + { + var propTrueNum = apool.putAttrib([propName, true], true); + if (propTrueNum >= 0) + { + anumMap[propTrueNum] = i; + } + }); + + function getLineTXT(text, attribs) + { + var propVals = [false, false, false]; + var ENTER = 1; + var STAY = 2; + var LEAVE = 0; + + // Use order of tags (b/i/u) as order of nesting, for simplicity + // and decent nesting. For example, + // <b>Just bold<b> <b><i>Bold and italics</i></b> <i>Just italics</i> + // becomes + // <b>Just bold <i>Bold and italics</i></b> <i>Just italics</i> + var taker = Changeset.stringIterator(text); + var assem = Changeset.stringAssembler(); + var openTags = []; + + var idx = 0; + + function processNextChars(numChars) + { + if (numChars <= 0) + { + return; + } + + var iter = Changeset.opIterator(Changeset.subattribution(attribs, idx, idx + numChars)); + idx += numChars; + + while (iter.hasNext()) + { + var o = iter.next(); + var propChanged = false; + Changeset.eachAttribNumber(o.attribs, function (a) + { + if (a in anumMap) + { + var i = anumMap[a]; // i = 0 => bold, etc. + if (!propVals[i]) + { + propVals[i] = ENTER; + propChanged = true; + } + else + { + propVals[i] = STAY; + } + } + }); + for (var i = 0; i < propVals.length; i++) + { + if (propVals[i] === true) + { + propVals[i] = LEAVE; + propChanged = true; + } + else if (propVals[i] === STAY) + { + propVals[i] = true; // set it back + } + } + // now each member of propVal is in {false,LEAVE,ENTER,true} + // according to what happens at start of span + if (propChanged) + { + // leaving bold (e.g.) also leaves italics, etc. + var left = false; + for (var i = 0; i < propVals.length; i++) + { + var v = propVals[i]; + if (!left) + { + if (v === LEAVE) + { + left = true; + } + } + else + { + if (v === true) + { + propVals[i] = STAY; // tag will be closed and re-opened + } + } + } + + var tags2close = []; + + for (var i = propVals.length - 1; i >= 0; i--) + { + if (propVals[i] === LEAVE) + { + //emitCloseTag(i); + tags2close.push(i); + propVals[i] = false; + } + else if (propVals[i] === STAY) + { + //emitCloseTag(i); + tags2close.push(i); + } + } + + for (var i = 0; i < propVals.length; i++) + { + if (propVals[i] === ENTER || propVals[i] === STAY) + { + propVals[i] = true; + } + } + // propVals is now all {true,false} again + } // end if (propChanged) + + var chars = o.chars; + if (o.lines) + { + chars--; // exclude newline at end of line, if present + } + + var s = taker.take(chars); + + // removes the characters with the code 12. Don't know where they come + // from but they break the abiword parser and are completly useless + // s = s.replace(String.fromCharCode(12), ""); + + // remove * from s, it's just not needed on a blank line.. This stops + // plugins from being able to display * at the beginning of a line + // s = s.replace("*", ""); // Then remove it + + assem.append(s); + } // end iteration over spans in line + + var tags2close = []; + for (var i = propVals.length - 1; i >= 0; i--) + { + if (propVals[i]) + { + tags2close.push(i); + propVals[i] = false; + } + } + + } // end processNextChars + processNextChars(text.length - idx); + return(assem.toString()); + } // end getLineHTML + var pieces = [css]; + + // Need to deal with constraints imposed on HTML lists; can + // only gain one level of nesting at once, can't change type + // mid-list, etc. + // People might use weird indenting, e.g. skip a level, + // so we want to do something reasonable there. We also + // want to deal gracefully with blank lines. + // => keeps track of the parents level of indentation + var lists = []; // e.g. [[1,'bullet'], [3,'bullet'], ...] + for (var i = 0; i < textLines.length; i++) + { + var line = _analyzeLine(textLines[i], attribLines[i], apool); + var lineContent = getLineTXT(line.text, line.aline); + if(line.listTypeName == "bullet"){ + lineContent = "* " + lineContent; // add a bullet + } + if(line.listLevel > 0){ + for (var j = line.listLevel - 1; j >= 0; j--){ + pieces.push('\t'); + } + if(line.listTypeName == "number"){ + pieces.push(line.listLevel + ". "); + // This is bad because it doesn't truly reflect what the user + // sees because browsers do magic on nested <ol><li>s + } + pieces.push(lineContent, '\n'); + }else{ + pieces.push(lineContent, '\n'); + } + } + + return pieces.join(''); +} +exports.getTXTFromAtext = getTXTFromAtext; + +exports.getPadTXTDocument = function (padId, revNum, noDocType, callback) +{ + padManager.getPad(padId, function (err, pad) + { + if(ERR(err, callback)) return; + + getPadTXT(pad, revNum, function (err, html) + { + if(ERR(err, callback)) return; + callback(null, html); + }); + }); +} + diff --git a/src/node/utils/Settings.js b/src/node/utils/Settings.js index 8435ab2c..45f81aa5 100644 --- a/src/node/utils/Settings.js +++ b/src/node/utils/Settings.js @@ -26,6 +26,8 @@ var argv = require('./Cli').argv; var npm = require("npm/lib/npm.js"); var vm = require('vm'); var log4js = require("log4js"); +var randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString; + /* Root path of the installation */ exports.root = path.normalize(path.join(npm.dir, "..")); @@ -112,6 +114,11 @@ exports.loglevel = "INFO"; */ exports.logconfig = { appenders: [{ type: "console" }]}; +/* +* Session Key, do not sure this. +*/ +exports.sessionKey = false; + /* This setting is used if you need authentication and/or * authorization. Note: /admin always requires authentication, and * either authorization by a module, or a user with is_admin set */ @@ -132,8 +139,6 @@ exports.abiwordAvailable = function() } } - - exports.reloadSettings = function reloadSettings() { // Discover where the settings file lives var settingsFilename = argv.settings || "settings.json"; @@ -152,6 +157,7 @@ exports.reloadSettings = function reloadSettings() { try { if(settingsStr) { settings = vm.runInContext('exports = '+settingsStr, vm.createContext(), "settings.json"); + settings = JSON.parse(JSON.stringify(settings)) // fix objects having constructors of other vm.context } }catch(e){ console.error('There was an error processing your settings.json file: '+e.message); @@ -184,6 +190,11 @@ exports.reloadSettings = function reloadSettings() { log4js.setGlobalLogLevel(exports.loglevel);//set loglevel log4js.replaceConsole(); + if(!exports.sessionKey){ // If the secretKey isn't set we also create yet another unique value here + exports.sessionKey = randomString(32); + console.warn("You need to set a sessionKey value in settings.json, this will allow your users to reconnect to your Etherpad Instance if your instance restarts"); + } + if(exports.dbType === "dirty"){ console.warn("DirtyDB is used. This is fine for testing but not recommended for production.") } diff --git a/src/package.json b/src/package.json index 6d05e6a2..44d03d80 100644 --- a/src/package.json +++ b/src/package.json @@ -16,7 +16,7 @@ "require-kernel" : "1.0.5", "resolve" : "0.2.x", "socket.io" : "0.9.x", - "ueberDB" : "0.1.9", + "ueberDB" : "0.1.94", "async" : "0.1.x", "express" : "3.x", "connect" : "2.4.x", @@ -40,11 +40,10 @@ }, "bin": { "etherpad-lite": "./node/server.js" }, "devDependencies": { - "jshint" : "*", - "wd" : "0.0.26" + "wd" : "0.0.31" }, - "engines" : { "node" : ">=0.6.0", + "engines" : { "node" : ">=0.6.3", "npm" : ">=1.0" }, - "version" : "1.2.7" + "version" : "1.2.8" } diff --git a/src/static/css/admin.css b/src/static/css/admin.css index 3a729151..b6823842 100644 --- a/src/static/css/admin.css +++ b/src/static/css/admin.css @@ -1,65 +1,59 @@ +html, body {
+ height: 100%;
+ box-sizing: border-box;
+}
+
body {
margin: 0;
color: #333;
font: 14px helvetica, sans-serif;
- background: #ddd;
- background: -webkit-radial-gradient(circle,#aaa,#eee 60%) center fixed;
- background: -moz-radial-gradient(circle,#aaa,#eee 60%) center fixed;
- background: -ms-radial-gradient(circle,#aaa,#eee 60%) center fixed;
- background: -o-radial-gradient(circle,#aaa,#eee 60%) center fixed;
+ background: #eee;
}
-#topborder {
- border-top: 8px solid rgba(51, 51, 51, 0.8);
- position: fixed;
- top: 0px;
- width: 100%;
+div.menu {
+ height: 100%;
+ padding: 15px;
+ width: 220px;
+ border-right: 1px solid #ccc;
+ position: fixed;
}
-div.menu {
- background: none repeat scroll 0% 0% rgba(255, 255, 255, 0.75);
- box-shadow: 0px -4px 4px rgba(0, 0, 0, 0.3);
- display: block;
- float: left;
- height: 100%;
- padding: 15px;
- position: fixed;
- width: 220px;
+div.menu ul {
+ padding: 0;
}
div.menu li {
list-style: none;
margin-left: 3px;
- line-height: 1.6
+ line-height: 3;
+ border-top: 1px solid #ccc;
+}
+
+div.menu li:last-child {
+ border-bottom: 1px solid #ccc;
}
div.innerwrapper {
- display: block;
- float: right;
- opacity: 0.9;
padding: 15px;
- max-width: 860px;
- border-radius: 0 0 7px 7px;
- margin-left:250px;
- min-width:400px;
+ padding-left: 265px;
}
#wrapper {
background: none repeat scroll 0px 0px #FFFFFF;
- box-shadow: 0px 1px 8px rgba(0, 0, 0, 0.3);
+ box-shadow: 0px 1px 10px rgba(0, 0, 0, 0.2);
margin: auto;
max-width: 1150px;
min-height: 100%;
- overflow: auto;
- padding-left: 15px;
- opacity: .9;
}
+
h1 {
font-size: 29px;
}
+
h2 {
font-size: 24px;
}
+
.separator {
margin: 10px 0;
height: 1px;
@@ -69,37 +63,45 @@ h2 { background: -ms-linear-gradient(left, #fff, #aaa 20%, #aaa 80%, #fff);
background: -o-linear-gradient(left, #fff, #aaa 20%, #aaa 80%, #fff);
}
+
form {
margin-bottom: 0;
}
+
#inner {
width: 300px;
margin: 0 auto;
}
+
input {
font-weight: bold;
font-size: 15px;
}
+
input[type="button"] {
padding: 4px 6px;
margin: 0;
}
+
table input[type="button"] {
float: right;
width: 100px;
}
+
input[type="text"] {
border-radius: 3px;
box-sizing: border-box;
-moz-box-sizing: border-box;
padding: 10px;
- *padding: 0; /* IE7 hack */
+ *padding: 0;
+ /* IE7 hack */
width: 100%;
outline: none;
border: 1px solid #ddd;
margin: 0 0 5px 0;
max-width: 500px;
}
+
table {
border: 1px solid #ddd;
border-radius: 3px;
@@ -107,34 +109,112 @@ table { width: 100%;
margin: 20px 0;
}
+
table thead tr {
background: #eee;
}
+
td, th {
padding: 5px;
}
+
.template {
display: none;
}
+
#progress {
position: absolute;
bottom: 50px;
}
+
+#progress img {
+ vertical-align: top;
+}
+
.settings {
- margin-top:10px;
- width:100%;
- min-height:600px;
+ outline: none;
+ width: 100%;
+ min-height: 500px;
}
-#response{
- display:inline;
+
+#response {
+ display: inline;
}
a:link, a:visited, a:hover, a:focus {
color: #333333;
text-decoration: none;
- border-bottom: #333333 1px dotted;
}
a:focus, a:hover {
border-bottom: #333333 1px solid;
}
+
+pre {
+ white-space: pre-wrap;
+ word-wrap: break-word;
+}
+
+@media (max-width: 720px) {
+ div.innerwrapper {
+ padding: 0 15px 15px 15px;
+ }
+
+ div.menu {
+ padding: 1px 15px 0 15px;
+ position: static;
+ height: auto;
+ border-right: none;
+ width: auto;
+ }
+
+ table {
+ border: none;
+ }
+
+ table, thead, tbody, td, tr {
+ display: block;
+ }
+
+ thead tr {
+ display: none;
+ }
+
+ tr {
+ border: 1px solid #ccc;
+ margin-bottom: 5px;
+ border-radius: 3px;
+ }
+
+ td {
+ border: none;
+ border-bottom: 1px solid #eee;
+ position: relative;
+ padding-left: 50%;
+ white-space: normal;
+ text-align: left;
+ }
+
+ td.name {
+ word-wrap: break-word;
+ }
+
+ td:before {
+ position: absolute;
+ top: 6px;
+ left: 6px;
+ text-align: left;
+ padding-right: 10px;
+ white-space: nowrap;
+ font-weight: bold;
+ content: attr(data-label);
+ }
+
+ td:last-child {
+ border-bottom: none;
+ }
+
+ table input[type="button"] {
+ float: none;
+ }
+}
\ No newline at end of file diff --git a/src/static/css/iframe_editor.css b/src/static/css/iframe_editor.css index 5134fcdb..3e19cbbe 100644 --- a/src/static/css/iframe_editor.css +++ b/src/static/css/iframe_editor.css @@ -176,3 +176,11 @@ p { } #overlaysdiv { position: absolute; left: -1000px; top: -1000px; } + +/* Stops super long lines without being spaces such as aaaaaaaaaaaaaa*100 breaking the editor + Commented out because it stops IE from being able to render the document, crazy IE bug is crazy. */ +/* +.ace-line{ + overflow:hidden; +} +*/ diff --git a/src/static/js/ace2_common.js b/src/static/js/ace2_common.js index 8a7d16ee..7ad7ba0f 100644 --- a/src/static/js/ace2_common.js +++ b/src/static/js/ace2_common.js @@ -1,5 +1,5 @@ /** - * This code is mostly from the old Etherpad. Please help us to comment this code. + * This code is mostly from the old Etherpad. Please help us to comment this code. * This helps other people to understand this code better and helps them to improve it. * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED */ @@ -33,19 +33,6 @@ function object(o) f.prototype = o; return new f(); } -var userAgent = (((function () {return this;})().navigator || {}).userAgent || 'node-js').toLowerCase(); - -// Figure out what browser is being used (stolen from jquery 1.2.1) -var browser = { - version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1], - safari: /webkit/.test(userAgent), - opera: /opera/.test(userAgent), - msie: /msie/.test(userAgent) && !/opera/.test(userAgent), - mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent), - windows: /windows/.test(userAgent), - mobile: /mobile/.test(userAgent) || /android/.test(userAgent) -}; - function getAssoc(obj, name) { @@ -97,7 +84,6 @@ var noop = function(){}; exports.isNodeText = isNodeText; exports.object = object; -exports.browser = browser; exports.getAssoc = getAssoc; exports.setAssoc = setAssoc; exports.binarySearch = binarySearch; diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index da8dea85..ddb614be 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -28,7 +28,7 @@ $ = jQuery = require('./rjquery').$; _ = require("./underscore"); var isNodeText = Ace2Common.isNodeText, - browser = Ace2Common.browser, + browser = $.browser, getAssoc = Ace2Common.getAssoc, setAssoc = Ace2Common.setAssoc, isTextNode = Ace2Common.isTextNode, @@ -154,7 +154,8 @@ function Ace2Inner(){ var dmesg = noop; window.dmesg = noop; - var scheduler = parent; + + var scheduler = parent; // hack for opera required var textFace = 'monospace'; var textSize = 12; @@ -1621,9 +1622,17 @@ function Ace2Inner(){ lines = ccData.lines; var lineAttribs = ccData.lineAttribs; var linesWrapped = ccData.linesWrapped; + var scrollToTheLeftNeeded = false; if (linesWrapped > 0) { + if(!browser.ie){ + // chrome decides in it's infinite wisdom that its okay to put the browsers visisble window in the middle of the span + // an outcome of this is that the first chars of the string are no longer visible to the user.. Yay chrome.. + // Move the browsers visible area to the left hand side of the span + // Firefox isn't quite so bad, but it's still pretty quirky. + var scrollToTheLeftNeeded = true; + } // console.log("Editor warning: " + linesWrapped + " long line" + (linesWrapped == 1 ? " was" : "s were") + " hard-wrapped into " + ccData.numLinesAfter + " lines."); } @@ -1691,6 +1700,10 @@ function Ace2Inner(){ //console.log("removed: "+id); }); + if(scrollToTheLeftNeeded){ // needed to stop chrome from breaking the ui when long strings without spaces are pasted + $("#innerdocbody").scrollLeft(0); + } + p.mark("findsel"); // if the nodes that define the selection weren't encountered during // content collection, figure out where those nodes are now. @@ -1896,7 +1909,7 @@ function Ace2Inner(){ var prevLine = rep.lines.prev(thisLine); var prevLineText = prevLine.text; var theIndent = /^ *(?:)/.exec(prevLineText)[0]; - if (/[\[\(\{]\s*$/.exec(prevLineText)) theIndent += THE_TAB; + if (/[\[\(\:\{]\s*$/.exec(prevLineText)) theIndent += THE_TAB; var cs = Changeset.builder(rep.lines.totalWidth()).keep( rep.lines.offsetOfIndex(lineNum), lineNum).insert( theIndent, [ @@ -2817,7 +2830,6 @@ function Ace2Inner(){ rep.selStart = selectStart; rep.selEnd = selectEnd; rep.selFocusAtStart = newSelFocusAtStart; - if (mozillaFakeArrows) mozillaFakeArrows.notifySelectionChanged(); currentCallStack.repChanged = true; return true; @@ -3287,7 +3299,7 @@ function Ace2Inner(){ listType = /([a-z]+)([12345678])/.exec(listType); var type = listType[1]; var level = Number(listType[2]); - + //detect empty list item; exclude indentation if(text === '*' && type !== "indent") { @@ -3317,8 +3329,10 @@ function Ace2Inner(){ function doIndentOutdent(isOut) { - if (!(rep.selStart && rep.selEnd) || - ((rep.selStart[0] == rep.selEnd[0]) && (rep.selStart[1] == rep.selEnd[1]) && rep.selEnd[1] > 1)) + if (!((rep.selStart && rep.selEnd) || + ((rep.selStart[0] == rep.selEnd[0]) && (rep.selStart[1] == rep.selEnd[1]) && rep.selEnd[1] > 1)) && + (isOut != true) + ) { return false; } @@ -3326,7 +3340,6 @@ function Ace2Inner(){ var firstLine, lastLine; firstLine = rep.selStart[0]; lastLine = Math.max(firstLine, rep.selEnd[0] - ((rep.selEnd[1] === 0) ? 1 : 0)); - var mods = []; for (var n = firstLine; n <= lastLine; n++) { @@ -3539,7 +3552,6 @@ function Ace2Inner(){ { // if (DEBUG && window.DONT_INCORP) return; if (!isEditable) return; - var type = evt.type; var charCode = evt.charCode; var keyCode = evt.keyCode; @@ -3561,6 +3573,11 @@ function Ace2Inner(){ var isModKey = ((!charCode) && ((type == "keyup") || (type == "keydown")) && (keyCode == 16 || keyCode == 17 || keyCode == 18 || keyCode == 20 || keyCode == 224 || keyCode == 91)); if (isModKey) return; + // If the key is a keypress and the browser is opera and the key is enter, do nothign at all as this fires twice. + if (keyCode == 13 && browser.opera && (type == "keypress")){ + return; // This stops double enters in Opera but double Tabs still show on single tab keypress, adding keyCode == 9 to this doesn't help as the event is fired twice + } + var specialHandled = false; var isTypeForSpecialKey = ((browser.msie || browser.safari) ? (type == "keydown") : (type == "keypress")); var isTypeForCmdKey = ((browser.msie || browser.safari) ? (type == "keydown") : (type == "keypress")); @@ -3690,12 +3707,73 @@ function Ace2Inner(){ doDeleteKey(); specialHandled = true; } + if((evt.which == 33 || evt.which == 34) && type == 'keydown'){ + var oldVisibleLineRange = getVisibleLineRange(); + var topOffset = rep.selStart[0] - oldVisibleLineRange[0]; + if(topOffset < 0 ){ + topOffset = 0; + } + + var isPageDown = evt.which === 34; + var isPageUp = evt.which === 33; + + scheduler.setTimeout(function(){ + var newVisibleLineRange = getVisibleLineRange(); + var linesCount = rep.lines.length(); + + var newCaretRow = rep.selStart[0]; + if(isPageUp){ + newCaretRow = oldVisibleLineRange[0]; + } + + if(isPageDown){ + newCaretRow = newVisibleLineRange[0] + topOffset; + } + + //ensure min and max + if(newCaretRow < 0){ + newCaretRow = 0; + } + if(newCaretRow >= linesCount){ + newCaretRow = linesCount-1; + } + + rep.selStart[0] = newCaretRow; + rep.selEnd[0] = newCaretRow; + updateBrowserSelectionFromRep(); + }, 200); + } + + /* Attempt to apply some sanity to cursor handling in Chrome after a copy / paste event + We have to do this the way we do because rep. doesn't hold the value for keyheld events IE if the user + presses and holds the arrow key */ + if((evt.which == 37 || evt.which == 38 || evt.which == 39 || evt.which == 40) && $.browser.chrome){ + + var newVisibleLineRange = getVisibleLineRange(); // get the current visible range -- This works great. + var lineHeight = textLineHeight(); // what Is the height of each line? + var myselection = document.getSelection(); // get the current caret selection, can't use rep. here because that only gives us the start position not the current + var caretOffsetTop = myselection.focusNode.parentNode.offsetTop; // get the carets selection offset in px IE 214 + + if(caretOffsetTop){ // sometimes caretOffsetTop bugs out and returns 0, not sure why, possible Chrome bug? Either way if it does we don't wanna mess with it + var lineNum = Math.round(caretOffsetTop / lineHeight) ; // Get the current Line Number IE 84 + newVisibleLineRange[1] = newVisibleLineRange[1]-1; + var caretIsVisible = (lineNum > newVisibleLineRange[0] && lineNum < newVisibleLineRange[1]); // Is the cursor in the visible Range IE ie 84 > 14 and 84 < 90? + + if(!caretIsVisible){ // is the cursor no longer visible to the user? + // Oh boy the caret is out of the visible area, I need to scroll the browser window to lineNum. + // Get the new Y by getting the line number and multiplying by the height of each line. + if(evt.which == 37 || evt.which == 38){ // If left or up + var newY = lineHeight * (lineNum -1); // -1 to go to the line above + }else if(evt.which == 39 || evt.which == 40){ // if down or right + var newY = getScrollY() + (lineHeight*3); // the offset and one additional line + } + setScrollY(newY); // set the scroll height of the browser + } + + } - if (mozillaFakeArrows && mozillaFakeArrows.handleKeyEvent(evt)) - { - evt.preventDefault(); - specialHandled = true; } + } if (type == "keydown") @@ -3801,7 +3879,6 @@ function Ace2Inner(){ selection.endPoint = getPointForLineAndChar(se); selection.focusAtStart = !! rep.selFocusAtStart; - setSelection(selection); } @@ -4119,6 +4196,11 @@ function Ace2Inner(){ selection.startPoint = pointFromRangeBound(range.startContainer, range.startOffset); selection.endPoint = pointFromRangeBound(range.endContainer, range.endOffset); selection.focusAtStart = (((range.startContainer != range.endContainer) || (range.startOffset != range.endOffset)) && browserSelection.anchorNode && (browserSelection.anchorNode == range.endContainer) && (browserSelection.anchorOffset == range.endOffset)); + + if(selection.startPoint.node.ownerDocument !== window.document){ + return null; + } + return selection; } else return null; @@ -5032,331 +5114,6 @@ function Ace2Inner(){ } editorInfo.ace_doInsertUnorderedList = doInsertUnorderedList; editorInfo.ace_doInsertOrderedList = doInsertOrderedList; - - var mozillaFakeArrows = (browser.mozilla && (function() - { - // In Firefox 2, arrow keys are unstable while DOM-manipulating - // operations are going on. Specifically, if an operation - // (computation that ties up the event queue) is going on (in the - // call-stack of some event, like a timeout) that at some point - // mutates nodes involved in the selection, then the arrow - // keypress may (randomly) move the caret to the beginning or end - // of the document. If the operation also mutates the selection - // range, the old selection or the new selection may be used, or - // neither. - // As long as the arrow is pressed during the busy operation, it - // doesn't seem to matter that the keydown and keypress events - // aren't generated until afterwards, or that the arrow movement - // can still be stopped (meaning it hasn't been performed yet); - // Firefox must be preserving some old information about the - // selection or the DOM from when the key was initially pressed. - // However, it also doesn't seem to matter when the key was - // actually pressed relative to the time of the mutation within - // the prolonged operation. Also, even in very controlled tests - // (like a mutation followed by a long period of busyWaiting), the - // problem shows up often but not every time, with no discernable - // pattern. Who knows, it could have something to do with the - // caret-blinking timer, or DOM changes not being applied - // immediately. - // This problem, mercifully, does not show up at all in IE or - // Safari. My solution is to have my own, full-featured arrow-key - // implementation for Firefox. - // Note that the problem addressed here is potentially very subtle, - // especially if the operation is quick and is timed to usually happen - // when the user is idle. - // features: - // - 'up' and 'down' arrows preserve column when passing through shorter lines - // - shift-arrows extend the "focus" point, which may be start or end of range - // - the focus point is kept horizontally and vertically scrolled into view - // - arrows without shift cause caret to move to beginning or end of selection (left,right) - // or move focus point up or down a line (up,down) - // - command-(left,right,up,down) on Mac acts like (line-start, line-end, doc-start, doc-end) - // - takes wrapping into account when doesWrap is true, i.e. up-arrow and down-arrow move - // between the virtual lines within a wrapped line; this was difficult, and unfortunately - // requires mutating the DOM to get the necessary information - var savedFocusColumn = 0; // a value of 0 has no effect - var updatingSelectionNow = false; - - function getVirtualLineView(lineNum) - { - var lineNode = rep.lines.atIndex(lineNum).lineNode; - while (lineNode.firstChild && isBlockElement(lineNode.firstChild)) - { - lineNode = lineNode.firstChild; - } - return makeVirtualLineView(lineNode); - } - - function markerlessLineAndChar(line, chr) - { - return [line, chr - rep.lines.atIndex(line).lineMarker]; - } - - function markerfulLineAndChar(line, chr) - { - return [line, chr + rep.lines.atIndex(line).lineMarker]; - } - - return { - notifySelectionChanged: function() - { - if (!updatingSelectionNow) - { - savedFocusColumn = 0; - } - }, - handleKeyEvent: function(evt) - { - // returns "true" if handled - if (evt.type != "keypress") return false; - var keyCode = evt.keyCode; - if (keyCode < 37 || keyCode > 40) return false; - incorporateUserChanges(); - - if (!(rep.selStart && rep.selEnd)) return true; - - // {byWord,toEnd,normal} - var moveMode = (evt.altKey ? "byWord" : (evt.ctrlKey ? "byWord" : (evt.metaKey ? "toEnd" : "normal"))); - - var anchorCaret = markerlessLineAndChar(rep.selStart[0], rep.selStart[1]); - var focusCaret = markerlessLineAndChar(rep.selEnd[0], rep.selEnd[1]); - var wasCaret = isCaret(); - if (rep.selFocusAtStart) - { - var tmp = anchorCaret; - anchorCaret = focusCaret; - focusCaret = tmp; - } - var K_UP = 38, - K_DOWN = 40, - K_LEFT = 37, - K_RIGHT = 39; - var dontMove = false; - if (wasCaret && !evt.shiftKey) - { - // collapse, will mutate both together - anchorCaret = focusCaret; - } - else if ((!wasCaret) && (!evt.shiftKey)) - { - if (keyCode == K_LEFT) - { - // place caret at beginning - if (rep.selFocusAtStart) anchorCaret = focusCaret; - else focusCaret = anchorCaret; - if (moveMode == "normal") dontMove = true; - } - else if (keyCode == K_RIGHT) - { - // place caret at end - if (rep.selFocusAtStart) focusCaret = anchorCaret; - else anchorCaret = focusCaret; - if (moveMode == "normal") dontMove = true; - } - else - { - // collapse, will mutate both together - anchorCaret = focusCaret; - } - } - if (!dontMove) - { - function lineLength(i) - { - var entry = rep.lines.atIndex(i); - return entry.text.length - entry.lineMarker; - } - - function lineText(i) - { - var entry = rep.lines.atIndex(i); - return entry.text.substring(entry.lineMarker); - } - - if (keyCode == K_UP || keyCode == K_DOWN) - { - var up = (keyCode == K_UP); - var canChangeLines = ((up && focusCaret[0]) || ((!up) && focusCaret[0] < rep.lines.length() - 1)); - var virtualLineView, virtualLineSpot, canChangeVirtualLines = false; - if (doesWrap) - { - virtualLineView = getVirtualLineView(focusCaret[0]); - virtualLineSpot = virtualLineView.getVLineAndOffsetForChar(focusCaret[1]); - canChangeVirtualLines = ((up && virtualLineSpot.vline > 0) || ((!up) && virtualLineSpot.vline < ( - virtualLineView.getNumVirtualLines() - 1))); - } - var newColByVirtualLineChange; - if (moveMode == "toEnd") - { - if (up) - { - focusCaret[0] = 0; - focusCaret[1] = 0; - } - else - { - focusCaret[0] = rep.lines.length() - 1; - focusCaret[1] = lineLength(focusCaret[0]); - } - } - else if (moveMode == "byWord") - { - // move by "paragraph", a feature that Firefox lacks but IE and Safari both have - if (up) - { - if (focusCaret[1] === 0 && canChangeLines) - { - focusCaret[0]--; - focusCaret[1] = 0; - } - else focusCaret[1] = 0; - } - else - { - var lineLen = lineLength(focusCaret[0]); - if (browser.windows) - { - if (canChangeLines) - { - focusCaret[0]++; - focusCaret[1] = 0; - } - else - { - focusCaret[1] = lineLen; - } - } - else - { - if (focusCaret[1] == lineLen && canChangeLines) - { - focusCaret[0]++; - focusCaret[1] = lineLength(focusCaret[0]); - } - else - { - focusCaret[1] = lineLen; - } - } - } - savedFocusColumn = 0; - } - else if (canChangeVirtualLines) - { - var vline = virtualLineSpot.vline; - var offset = virtualLineSpot.offset; - if (up) vline--; - else vline++; - if (savedFocusColumn > offset) offset = savedFocusColumn; - else - { - savedFocusColumn = offset; - } - var newSpot = virtualLineView.getCharForVLineAndOffset(vline, offset); - focusCaret[1] = newSpot.lineChar; - } - else if (canChangeLines) - { - if (up) focusCaret[0]--; - else focusCaret[0]++; - var offset = focusCaret[1]; - if (doesWrap) - { - offset = virtualLineSpot.offset; - } - if (savedFocusColumn > offset) offset = savedFocusColumn; - else - { - savedFocusColumn = offset; - } - if (doesWrap) - { - var newLineView = getVirtualLineView(focusCaret[0]); - var vline = (up ? newLineView.getNumVirtualLines() - 1 : 0); - var newSpot = newLineView.getCharForVLineAndOffset(vline, offset); - focusCaret[1] = newSpot.lineChar; - } - else - { - var lineLen = lineLength(focusCaret[0]); - if (offset > lineLen) offset = lineLen; - focusCaret[1] = offset; - } - } - else - { - if (up) focusCaret[1] = 0; - else focusCaret[1] = lineLength(focusCaret[0]); - savedFocusColumn = 0; - } - } - else if (keyCode == K_LEFT || keyCode == K_RIGHT) - { - var left = (keyCode == K_LEFT); - if (left) - { - if (moveMode == "toEnd") focusCaret[1] = 0; - else if (focusCaret[1] > 0) - { - if (moveMode == "byWord") - { - focusCaret[1] = moveByWordInLine(lineText(focusCaret[0]), focusCaret[1], false); - } - else - { - focusCaret[1]--; - } - } - else if (focusCaret[0] > 0) - { - focusCaret[0]--; - focusCaret[1] = lineLength(focusCaret[0]); - if (moveMode == "byWord") - { - focusCaret[1] = moveByWordInLine(lineText(focusCaret[0]), focusCaret[1], false); - } - } - } - else - { - var lineLen = lineLength(focusCaret[0]); - if (moveMode == "toEnd") focusCaret[1] = lineLen; - else if (focusCaret[1] < lineLen) - { - if (moveMode == "byWord") - { - focusCaret[1] = moveByWordInLine(lineText(focusCaret[0]), focusCaret[1], true); - } - else - { - focusCaret[1]++; - } - } - else if (focusCaret[0] < rep.lines.length() - 1) - { - focusCaret[0]++; - focusCaret[1] = 0; - if (moveMode == "byWord") - { - focusCaret[1] = moveByWordInLine(lineText(focusCaret[0]), focusCaret[1], true); - } - } - } - savedFocusColumn = 0; - } - } - - var newSelFocusAtStart = ((focusCaret[0] < anchorCaret[0]) || (focusCaret[0] == anchorCaret[0] && focusCaret[1] < anchorCaret[1])); - var newSelStart = (newSelFocusAtStart ? focusCaret : anchorCaret); - var newSelEnd = (newSelFocusAtStart ? anchorCaret : focusCaret); - updatingSelectionNow = true; - performSelectionChange(markerfulLineAndChar(newSelStart[0], newSelStart[1]), markerfulLineAndChar(newSelEnd[0], newSelEnd[1]), newSelFocusAtStart); - updatingSelectionNow = false; - currentCallStack.userChangedSelection = true; - return true; - } - }; - })()); var lineNumbersShown; var sideDivInner; diff --git a/src/static/js/broadcast_slider.js b/src/static/js/broadcast_slider.js index 08ac08b5..9427c191 100644 --- a/src/static/js/broadcast_slider.js +++ b/src/static/js/broadcast_slider.js @@ -107,12 +107,16 @@ function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded) { newpos = Number(newpos); if (newpos < 0 || newpos > sliderLength) return; + if(!newpos){ + newpos = 0; // stops it from displaying NaN if newpos isn't set + } window.location.hash = "#" + newpos; $("#ui-slider-handle").css('left', newpos * ($("#ui-slider-bar").width() - 2) / (sliderLength * 1.0)); $("a.tlink").map(function() { $(this).attr('href', $(this).attr('thref').replace("%revision%", newpos)); }); + $("#revision_label").html(html10n.get("timeslider.version", { "version": newpos})); if (newpos == 0) @@ -456,31 +460,6 @@ function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded) if (clientVars) { - if (clientVars.fullWidth) - { - $("#padpage").css('width', '100%'); - $("#revision").css('position', "absolute") - $("#revision").css('right', "20px") - $("#revision").css('top', "20px") - $("#padmain").css('left', '0px'); - $("#padmain").css('right', '197px'); - $("#padmain").css('width', 'auto'); - $("#rightbars").css('right', '7px'); - $("#rightbars").css('margin-right', '0px'); - $("#timeslider").css('width', 'auto'); - } - - if (clientVars.disableRightBar) - { - $("#rightbars").css('display', 'none'); - $('#padmain').css('width', 'auto'); - if (clientVars.fullWidth) $("#padmain").css('right', '7px'); - else $("#padmain").css('width', '860px'); - $("#revision").css('position', "absolute"); - $("#revision").css('right', "20px"); - $("#revision").css('top', "20px"); - } - $("#timeslider").show(); var startPos = clientVars.collab_client_vars.rev; diff --git a/src/static/js/collab_client.js b/src/static/js/collab_client.js index 7df0b711..94149123 100644 --- a/src/static/js/collab_client.js +++ b/src/static/js/collab_client.js @@ -294,8 +294,8 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) if (newRev != (oldRev + 1)) { - dmesg("bad message revision on NEW_CHANGES: " + newRev + " not " + (oldRev + 1)); - setChannelState("DISCONNECTED", "badmessage_newchanges"); + top.console.warn("bad message revision on NEW_CHANGES: " + newRev + " not " + (oldRev + 1)); + // setChannelState("DISCONNECTED", "badmessage_newchanges"); return; } msgQueue.push(msg); @@ -304,8 +304,8 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) if (newRev != (rev + 1)) { - dmesg("bad message revision on NEW_CHANGES: " + newRev + " not " + (rev + 1)); - setChannelState("DISCONNECTED", "badmessage_newchanges"); + top.console.warn("bad message revision on NEW_CHANGES: " + newRev + " not " + (rev + 1)); + // setChannelState("DISCONNECTED", "badmessage_newchanges"); return; } rev = newRev; @@ -318,8 +318,8 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) { if (newRev != (msgQueue[msgQueue.length - 1].newRev + 1)) { - dmesg("bad message revision on ACCEPT_COMMIT: " + newRev + " not " + (msgQueue[msgQueue.length - 1][0] + 1)); - setChannelState("DISCONNECTED", "badmessage_acceptcommit"); + top.console.warn("bad message revision on ACCEPT_COMMIT: " + newRev + " not " + (msgQueue[msgQueue.length - 1][0] + 1)); + // setChannelState("DISCONNECTED", "badmessage_acceptcommit"); return; } msgQueue.push(msg); @@ -328,8 +328,8 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) if (newRev != (rev + 1)) { - dmesg("bad message revision on ACCEPT_COMMIT: " + newRev + " not " + (rev + 1)); - setChannelState("DISCONNECTED", "badmessage_acceptcommit"); + top.console.warn("bad message revision on ACCEPT_COMMIT: " + newRev + " not " + (rev + 1)); + // setChannelState("DISCONNECTED", "badmessage_acceptcommit"); return; } rev = newRev; diff --git a/src/static/js/domline.js b/src/static/js/domline.js index 1be0f4ee..43b5f21a 100644 --- a/src/static/js/domline.js +++ b/src/static/js/domline.js @@ -30,8 +30,7 @@ var Security = require('./security'); var hooks = require('./pluginfw/hooks'); var _ = require('./underscore'); var lineAttributeMarker = require('./linestylefilter').lineAttributeMarker; -var Ace2Common = require('./ace2_common'); -var noop = Ace2Common.noop; +var noop = function(){}; var domline = {}; diff --git a/src/static/js/html10n.js b/src/static/js/html10n.js index d0d14814..e1c025c4 100644 --- a/src/static/js/html10n.js +++ b/src/static/js/html10n.js @@ -23,27 +23,27 @@ window.html10n = (function(window, document, undefined) { // fix console - var console = window.console + var console = window.console; function interceptConsole(method){ - if (!console) return function() {} + if (!console) return function() {}; - var original = console[method] + var original = console[method]; // do sneaky stuff if (original.bind){ // Do this for normal browsers - return original.bind(console) + return original.bind(console); }else{ return function() { // Do this for IE - var message = Array.prototype.slice.apply(arguments).join(' ') - original(message) + var message = Array.prototype.slice.apply(arguments).join(' '); + original(message); } } } var consoleLog = interceptConsole('log') , consoleWarn = interceptConsole('warn') - , consoleError = interceptConsole('warn') + , consoleError = interceptConsole('warn'); // fix Array.prototype.instanceOf in, guess what, IE! <3 @@ -84,14 +84,14 @@ window.html10n = (function(window, document, undefined) { * MicroEvent - to make any js object an event emitter (server or browser) */ - var MicroEvent = function(){} + var MicroEvent = function(){} MicroEvent.prototype = { - bind : function(event, fct){ + bind : function(event, fct){ this._events = this._events || {}; this._events[event] = this._events[event] || []; this._events[event].push(fct); }, - unbind : function(event, fct){ + unbind : function(event, fct){ this._events = this._events || {}; if( event in this._events === false ) return; this._events[event].splice(this._events[event].indexOf(fct), 1); @@ -100,7 +100,7 @@ window.html10n = (function(window, document, undefined) { this._events = this._events || {}; if( event in this._events === false ) return; for(var i = 0; i < this._events[event].length; i++){ - this._events[event][i].apply(this, Array.prototype.slice.call(arguments, 1)) + this._events[event][i].apply(this, Array.prototype.slice.call(arguments, 1)); } } }; @@ -122,50 +122,50 @@ window.html10n = (function(window, document, undefined) { * and caching all necessary resources */ function Loader(resources) { - this.resources = resources - this.cache = {} // file => contents - this.langs = {} // lang => strings + this.resources = resources; + this.cache = {}; // file => contents + this.langs = {}; // lang => strings } Loader.prototype.load = function(lang, cb) { - if(this.langs[lang]) return cb() + if(this.langs[lang]) return cb(); if (this.resources.length > 0) { var reqs = 0; for (var i=0, n=this.resources.length; i < n; i++) { this.fetch(this.resources[i], lang, function(e) { reqs++; - if(e) return setTimeout(function(){ throw e }, 0) + if(e) return setTimeout(function(){ throw e }, 0); if (reqs < n) return;// Call back once all reqs are completed - cb && cb() + cb && cb(); }) } } } Loader.prototype.fetch = function(href, lang, cb) { - var that = this + var that = this; if (this.cache[href]) { this.parse(lang, href, this.cache[href], cb) return; } - var xhr = new XMLHttpRequest() - xhr.open('GET', href, /*async: */true) + var xhr = new XMLHttpRequest(); + xhr.open('GET', href, /*async: */true); if (xhr.overrideMimeType) { xhr.overrideMimeType('application/json; charset=utf-8'); } xhr.onreadystatechange = function() { if (xhr.readyState == 4) { if (xhr.status == 200 || xhr.status === 0) { - var data = JSON.parse(xhr.responseText) - that.cache[href] = data + var data = JSON.parse(xhr.responseText); + that.cache[href] = data; // Pass on the contents for parsing - that.parse(lang, href, data, cb) + that.parse(lang, href, data, cb); } else { - cb(new Error('Failed to load '+href)) + cb(new Error('Failed to load '+href)); } } }; @@ -174,39 +174,39 @@ window.html10n = (function(window, document, undefined) { Loader.prototype.parse = function(lang, currHref, data, cb) { if ('object' != typeof data) { - cb(new Error('A file couldn\'t be parsed as json.')) - return + cb(new Error('A file couldn\'t be parsed as json.')); + return; } - if (!data[lang]) lang = lang.substr(0, lang.indexOf('-') == -1? lang.length : lang.indexOf('-')) + if (!data[lang]) lang = lang.substr(0, lang.indexOf('-') == -1? lang.length : lang.indexOf('-')); if (!data[lang]) { - cb(new Error('Couldn\'t find translations for '+lang)) - return + cb(new Error('Couldn\'t find translations for '+lang)); + return; } if ('string' == typeof data[lang]) { // Import rule // absolute path - var importUrl = data[lang] + var importUrl = data[lang]; // relative path if(data[lang].indexOf("http") != 0 && data[lang].indexOf("/") != 0) { - importUrl = currHref+"/../"+data[lang] + importUrl = currHref+"/../"+data[lang]; } - this.fetch(importUrl, lang, cb) - return + this.fetch(importUrl, lang, cb); + return; } if ('object' != typeof data[lang]) { - cb(new Error('Translations should be specified as JSON objects!')) - return + cb(new Error('Translations should be specified as JSON objects!')); + return; } - this.langs[lang] = data[lang] + this.langs[lang] = data[lang]; // TODO: Also store accompanying langs - cb() + cb(); } @@ -216,11 +216,11 @@ window.html10n = (function(window, document, undefined) { var html10n = { language : null } - MicroEvent.mixin(html10n) + MicroEvent.mixin(html10n); - html10n.macros = {} + html10n.macros = {}; - html10n.rtl = ["ar","dv","fa","ha","he","ks","ku","ps","ur","yi"] + html10n.rtl = ["ar","dv","fa","ha","he","ks","ku","ps","ur","yi"]; /** * Get rules for plural forms (shared with JetPack), see: @@ -664,14 +664,14 @@ window.html10n = (function(window, document, undefined) { * @param langs An array of lang codes defining fallbacks */ html10n.localize = function(langs) { - var that = this + var that = this; // if only one string => create an array - if ('string' == typeof langs) langs = [langs] + if ('string' == typeof langs) langs = [langs]; this.build(langs, function(er, translations) { - html10n.translations = translations - html10n.translateElement(translations) - that.trigger('localized') + html10n.translations = translations; + html10n.translateElement(translations); + that.trigger('localized'); }) } @@ -682,78 +682,78 @@ window.html10n = (function(window, document, undefined) { * @param element A DOM element, if omitted, the document element will be used */ html10n.translateElement = function(translations, element) { - element = element || document.documentElement + element = element || document.documentElement; var children = element? getTranslatableChildren(element) : document.childNodes; for (var i=0, n=children.length; i < n; i++) { - this.translateNode(translations, children[i]) + this.translateNode(translations, children[i]); } // translate element itself if necessary - this.translateNode(translations, element) + this.translateNode(translations, element); } function asyncForEach(list, iterator, cb) { var i = 0 - , n = list.length + , n = list.length; iterator(list[i], i, function each(err) { - if(err) consoleLog(err) - i++ + if(err) consoleLog(err); + i++; if (i < n) return iterator(list[i],i, each); - cb() + cb(); }) } function getTranslatableChildren(element) { if(!document.querySelectorAll) { - if (!element) return [] + if (!element) return []; var nodes = element.getElementsByTagName('*') - , l10nElements = [] + , l10nElements = []; for (var i=0, n=nodes.length; i < n; i++) { if (nodes[i].getAttribute('data-l10n-id')) l10nElements.push(nodes[i]); } - return l10nElements + return l10nElements; } - return element.querySelectorAll('*[data-l10n-id]') + return element.querySelectorAll('*[data-l10n-id]'); } html10n.get = function(id, args) { - var translations = html10n.translations - if(!translations) return consoleWarn('No translations available (yet)') - if(!translations[id]) return consoleWarn('Could not find string '+id) + var translations = html10n.translations; + if(!translations) return consoleWarn('No translations available (yet)'); + if(!translations[id]) return consoleWarn('Could not find string '+id); // apply args - var str = substArguments(translations[id], args) + var str = substArguments(translations[id], args); // apply macros - return substMacros(id, str, args) + return substMacros(id, str, args); // replace {{arguments}} with their values or the // associated translation string (based on its key) function substArguments(str, args) { var reArgs = /\{\{\s*([a-zA-Z\.]+)\s*\}\}/ - , match + , match; while (match = reArgs.exec(str)) { if (!match || match.length < 2) - return str // argument key not found + return str; // argument key not found var arg = match[1] - , sub = '' + , sub = ''; if (arg in args) { - sub = args[arg] + sub = args[arg]; } else if (arg in translations) { - sub = translations[arg] + sub = translations[arg]; } else { - consoleWarn('Could not find argument {{' + arg + '}}') - return str + consoleWarn('Could not find argument {{' + arg + '}}'); + return str; } - str = str.substring(0, match.index) + sub + str.substr(match.index + match[0].length) + str = str.substring(0, match.index) + sub + str.substr(match.index + match[0].length); } - return str + return str; } // replace {[macros]} with their values @@ -766,21 +766,21 @@ window.html10n = (function(window, document, undefined) { // a macro has been found // Note: at the moment, only one parameter is supported var macroName = reMatch[1] - , paramName = reMatch[2] + , paramName = reMatch[2]; - if (!(macroName in gMacros)) return str + if (!(macroName in gMacros)) return str; - var param + var param; if (args && paramName in args) { - param = args[paramName] + param = args[paramName]; } else if (paramName in translations) { - param = translations[paramName] + param = translations[paramName]; } // there's no macro parser yet: it has to be defined in gMacros - var macro = html10n.macros[macroName] - str = macro(translations, key, str, param) - return str + var macro = html10n.macros[macroName]; + str = macro(translations, key, str, param); + return str; } } @@ -788,26 +788,26 @@ window.html10n = (function(window, document, undefined) { * Applies translations to a DOM node (recursive) */ html10n.translateNode = function(translations, node) { - var str = {} + var str = {}; // get id - str.id = node.getAttribute('data-l10n-id') - if (!str.id) return + str.id = node.getAttribute('data-l10n-id'); + if (!str.id) return; - if(!translations[str.id]) return consoleWarn('Couldn\'t find translation key '+str.id) + if(!translations[str.id]) return consoleWarn('Couldn\'t find translation key '+str.id); // get args if(window.JSON) { - str.args = JSON.parse(node.getAttribute('data-l10n-args')) + str.args = JSON.parse(node.getAttribute('data-l10n-args')); }else{ try{ - str.args = eval(node.getAttribute('data-l10n-args')) + str.args = eval(node.getAttribute('data-l10n-args')); }catch(e) { - consoleWarn('Couldn\'t parse args for '+str.id) + consoleWarn('Couldn\'t parse args for '+str.id); } } - str.str = html10n.get(str.id, str.args) + str.str = html10n.get(str.id, str.args); // get attribute name to apply str to var prop @@ -817,31 +817,31 @@ window.html10n = (function(window, document, undefined) { , "innerHTML": 1 , "alt": 1 , "textContent": 1 - } + }; if (index > 0 && str.id.substr(index + 1) in attrList) { // an attribute has been specified - prop = str.id.substr(index + 1) + prop = str.id.substr(index + 1); } else { // no attribute: assuming text content by default - prop = document.body.textContent ? 'textContent' : 'innerText' + prop = document.body.textContent ? 'textContent' : 'innerText'; } // Apply translation if (node.children.length === 0 || prop != 'textContent') { - node[prop] = str.str + node[prop] = str.str; } else { var children = node.childNodes, - found = false + found = false; for (var i=0, n=children.length; i < n; i++) { if (children[i].nodeType === 3 && /\S/.test(children[i].textContent)) { if (!found) { - children[i].nodeValue = str.str - found = true + children[i].nodeValue = str.str; + found = true; } else { - children[i].nodeValue = '' + children[i].nodeValue = ''; } } } if (!found) { - consoleWarn('Unexpected error: could not translate element content for key '+str.id, node) + consoleWarn('Unexpected error: could not translate element content for key '+str.id, node); } } } @@ -852,32 +852,32 @@ window.html10n = (function(window, document, undefined) { */ html10n.build = function(langs, cb) { var that = this - , build = {} + , build = {}; asyncForEach(langs, function (lang, i, next) { if(!lang) return next(); - that.loader.load(lang, next) + that.loader.load(lang, next); }, function() { - var lang - langs.reverse() + var lang; + langs.reverse(); // loop through priority array... for (var i=0, n=langs.length; i < n; i++) { - lang = langs[i] + lang = langs[i]; if(!lang || !(lang in that.loader.langs)) continue; // ... and apply all strings of the current lang in the list // to our build object for (var string in that.loader.langs[lang]) { - build[string] = that.loader.langs[lang][string] + build[string] = that.loader.langs[lang][string]; } // the last applied lang will be exposed as the // lang the page was translated to - that.language = lang + that.language = lang; } - cb(null, build) + cb(null, build); }) } @@ -893,8 +893,8 @@ window.html10n = (function(window, document, undefined) { * Returns the direction of the language returned be html10n#getLanguage */ html10n.getDirection = function() { - var langCode = this.language.indexOf('-') == -1? this.language : this.language.substr(0, this.language.indexOf('-')) - return html10n.rtl.indexOf(langCode) == -1? 'ltr' : 'rtl' + var langCode = this.language.indexOf('-') == -1? this.language : this.language.substr(0, this.language.indexOf('-')); + return html10n.rtl.indexOf(langCode) == -1? 'ltr' : 'rtl'; } /** @@ -903,28 +903,28 @@ window.html10n = (function(window, document, undefined) { html10n.index = function () { // Find all <link>s var links = document.getElementsByTagName('link') - , resources = [] + , resources = []; for (var i=0, n=links.length; i < n; i++) { if (links[i].type != 'application/l10n+json') continue; - resources.push(links[i].href) + resources.push(links[i].href); } - this.loader = new Loader(resources) - this.trigger('indexed') + this.loader = new Loader(resources); + this.trigger('indexed'); } if (document.addEventListener) // modern browsers and IE9+ document.addEventListener('DOMContentLoaded', function() { - html10n.index() - }, false) + html10n.index(); + }, false); else if (window.attachEvent) window.attachEvent('onload', function() { - html10n.index() - }, false) + html10n.index(); + }, false); // gettext-like shortcut if (window._ === undefined) window._ = html10n.get; - return html10n -})(window, document)
\ No newline at end of file + return html10n; +})(window, document); diff --git a/src/static/js/jquery.js b/src/static/js/jquery.js index 8ccd0ea7..e2c203fe 100644 --- a/src/static/js/jquery.js +++ b/src/static/js/jquery.js @@ -1,31 +1,37 @@ /*! - * jQuery JavaScript Library v1.7.1 + * jQuery JavaScript Library v1.9.1 * http://jquery.com/ * - * Copyright 2011, John Resig - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * * Includes Sizzle.js * http://sizzlejs.com/ - * Copyright 2011, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. * - * Date: Mon Nov 21 21:11:03 2011 -0500 + * Copyright 2005, 2012 jQuery Foundation, Inc. and other contributors + * Released under the MIT license + * http://jquery.org/license + * + * Date: 2013-2-4 */ (function( window, undefined ) { -// Use the correct document accordingly with window argument (sandbox) -var document = window.document, - navigator = window.navigator, - location = window.location; -var jQuery = (function() { +// Can't do this because several apps including ASP.NET trace +// the stack via arguments.caller.callee and Firefox dies if +// you try to trace through "use strict" call chains. (#13335) +// Support: Firefox 18+ +//"use strict"; +var + // The deferred used on DOM ready + readyList, + + // A central reference to the root jQuery(document) + rootjQuery, -// Define a local copy of jQuery -var jQuery = function( selector, context ) { - // The jQuery object is actually just the init constructor 'enhanced' - return new jQuery.fn.init( selector, context, rootjQuery ); - }, + // Support: IE<9 + // For `typeof node.method` instead of `node.method !== undefined` + core_strundefined = typeof undefined, + + // Use the correct document accordingly with window argument (sandbox) + document = window.document, + location = window.location, // Map over jQuery in case of overwrite _jQuery = window.jQuery, @@ -33,133 +39,136 @@ var jQuery = function( selector, context ) { // Map over the $ in case of overwrite _$ = window.$, - // A central reference to the root jQuery(document) - rootjQuery, + // [[Class]] -> type pairs + class2type = {}, - // A simple way to check for HTML strings or ID strings - // Prioritize #id over <tag> to avoid XSS via location.hash (#9521) - quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, + // List of deleted data cache ids, so we can reuse them + core_deletedIds = [], + + core_version = "1.9.1", + + // Save a reference to some core methods + core_concat = core_deletedIds.concat, + core_push = core_deletedIds.push, + core_slice = core_deletedIds.slice, + core_indexOf = core_deletedIds.indexOf, + core_toString = class2type.toString, + core_hasOwn = class2type.hasOwnProperty, + core_trim = core_version.trim, + + // Define a local copy of jQuery + jQuery = function( selector, context ) { + // The jQuery object is actually just the init constructor 'enhanced' + return new jQuery.fn.init( selector, context, rootjQuery ); + }, + + // Used for matching numbers + core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source, - // Check if a string has a non-whitespace character in it - rnotwhite = /\S/, + // Used for splitting on whitespace + core_rnotwhite = /\S+/g, - // Used for trimming whitespace - trimLeft = /^\s+/, - trimRight = /\s+$/, + // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE) + rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, + + // A simple way to check for HTML strings + // Prioritize #id over <tag> to avoid XSS via location.hash (#9521) + // Strict HTML recognition (#11290: must start with <) + rquickExpr = /^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/, // Match a standalone tag - rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, + rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, // JSON RegExp rvalidchars = /^[\],:{}\s]*$/, - rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, - rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, - - // Useragent RegExp - rwebkit = /(webkit)[ \/]([\w.]+)/, - ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/, - rmsie = /(msie) ([\w.]+)/, - rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/, + rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g, + rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g, // Matches dashed string for camelizing - rdashAlpha = /-([a-z]|[0-9])/ig, rmsPrefix = /^-ms-/, + rdashAlpha = /-([\da-z])/gi, // Used by jQuery.camelCase as callback to replace() fcamelCase = function( all, letter ) { - return ( letter + "" ).toUpperCase(); + return letter.toUpperCase(); }, - // Keep a UserAgent string for use with jQuery.browser - userAgent = navigator.userAgent, - - // For matching the engine and version of the browser - browserMatch, - - // The deferred used on DOM ready - readyList, - // The ready event handler - DOMContentLoaded, + completed = function( event ) { - // Save a reference to some core methods - toString = Object.prototype.toString, - hasOwn = Object.prototype.hasOwnProperty, - push = Array.prototype.push, - slice = Array.prototype.slice, - trim = String.prototype.trim, - indexOf = Array.prototype.indexOf, + // 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(); + } + }, + // Clean-up method for dom ready events + detach = function() { + if ( document.addEventListener ) { + document.removeEventListener( "DOMContentLoaded", completed, false ); + window.removeEventListener( "load", completed, false ); - // [[Class]] -> type pairs - class2type = {}; + } else { + document.detachEvent( "onreadystatechange", completed ); + window.detachEvent( "onload", completed ); + } + }; jQuery.fn = jQuery.prototype = { + // The current version of jQuery being used + jquery: core_version, + constructor: jQuery, init: function( selector, context, rootjQuery ) { - var match, elem, ret, doc; + var match, elem; - // Handle $(""), $(null), or $(undefined) + // HANDLE: $(""), $(null), $(undefined), $(false) if ( !selector ) { return this; } - // Handle $(DOMElement) - if ( selector.nodeType ) { - this.context = this[0] = selector; - this.length = 1; - return this; - } - - // The body element only exists once, optimize finding it - if ( selector === "body" && !context && document.body ) { - this.context = document; - this[0] = document.body; - this.selector = selector; - this.length = 1; - return this; - } - // Handle HTML strings if ( typeof selector === "string" ) { - // Are we dealing with HTML string or an ID? if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { // Assume that strings that start and end with <> are HTML and skip the regex check match = [ null, selector, null ]; } else { - match = quickExpr.exec( selector ); + match = rquickExpr.exec( selector ); } - // Verify a match, and that no context was specified for #id + // 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; - doc = ( context ? context.ownerDocument || context : document ); - - // If a single string is passed in and it's a single tag - // just do a createElement and skip the rest - ret = rsingleTag.exec( selector ); - - if ( ret ) { - if ( jQuery.isPlainObject( context ) ) { - selector = [ document.createElement( ret[1] ) ]; - jQuery.fn.attr.call( selector, context, true ); - } else { - selector = [ doc.createElement( ret[1] ) ]; + // scripts is true for back-compat + 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 ] ); + } } - - } else { - ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); - selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes; } - return jQuery.merge( this, selector ); + return this; - // HANDLE: $("#id") + // HANDLE: $(#id) } else { elem = document.getElementById( match[2] ); @@ -192,6 +201,12 @@ jQuery.fn = jQuery.prototype = { 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 ) ) { @@ -209,9 +224,6 @@ jQuery.fn = jQuery.prototype = { // Start with an empty selector selector: "", - // The current version of jQuery being used - jquery: "1.7.1", - // The default length of a jQuery object is 0 length: 0, @@ -221,7 +233,7 @@ jQuery.fn = jQuery.prototype = { }, toArray: function() { - return slice.call( this, 0 ); + return core_slice.call( this ); }, // Get the Nth element in the matched element set OR @@ -238,28 +250,15 @@ jQuery.fn = jQuery.prototype = { // Take an array of elements and push it onto the stack // (returning the new matched element set) - pushStack: function( elems, name, selector ) { - // Build a new jQuery matched element set - var ret = this.constructor(); - - if ( jQuery.isArray( elems ) ) { - push.apply( ret, elems ); + pushStack: function( elems ) { - } else { - jQuery.merge( ret, elems ); - } + // Build a new jQuery matched element set + var ret = jQuery.merge( this.constructor(), elems ); // Add the old object onto the stack (as a reference) ret.prevObject = this; - ret.context = this.context; - if ( name === "find" ) { - ret.selector = this.selector + ( this.selector ? " " : "" ) + selector; - } else if ( name ) { - ret.selector = this.selector + "." + name + "(" + selector + ")"; - } - // Return the newly-formed element set return ret; }, @@ -272,20 +271,14 @@ jQuery.fn = jQuery.prototype = { }, ready: function( fn ) { - // Attach the listeners - jQuery.bindReady(); - // Add the callback - readyList.add( fn ); + jQuery.ready.promise().done( fn ); return this; }, - eq: function( i ) { - i = +i; - return i === -1 ? - this.slice( i ) : - this.slice( i, i + 1 ); + slice: function() { + return this.pushStack( core_slice.apply( this, arguments ) ); }, first: function() { @@ -296,9 +289,10 @@ jQuery.fn = jQuery.prototype = { return this.eq( -1 ); }, - slice: function() { - return this.pushStack( slice.apply( this, arguments ), - "slice", slice.call(arguments).join(",") ); + eq: function( i ) { + var len = this.length, + j = +i + ( i < 0 ? len : 0 ); + return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] ); }, map: function( callback ) { @@ -313,7 +307,7 @@ jQuery.fn = jQuery.prototype = { // For internal use only. // Behaves like an Array's method, not like a jQuery method. - push: push, + push: core_push, sort: [].sort, splice: [].splice }; @@ -322,7 +316,7 @@ jQuery.fn = jQuery.prototype = { jQuery.fn.init.prototype = jQuery.fn; jQuery.extend = jQuery.fn.extend = function() { - var options, name, src, copy, copyIsArray, clone, + var src, copyIsArray, copy, name, options, clone, target = arguments[0] || {}, i = 1, length = arguments.length, @@ -416,73 +410,31 @@ jQuery.extend({ // Handle when the DOM is ready ready: function( wait ) { - // Either a released hold or an DOMready/load event and not yet ready - if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) { - // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). - if ( !document.body ) { - return setTimeout( jQuery.ready, 1 ); - } - - // Remember that the DOM is ready - jQuery.isReady = true; - - // If a normal DOM Ready event fired, decrement, and wait if need be - if ( wait !== true && --jQuery.readyWait > 0 ) { - return; - } - // If there are functions bound, to execute - readyList.fireWith( document, [ jQuery ] ); - - // Trigger any bound ready events - if ( jQuery.fn.trigger ) { - jQuery( document ).trigger( "ready" ).off( "ready" ); - } - } - }, - - bindReady: function() { - if ( readyList ) { + // Abort if there are pending holds or we're already ready + if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { return; } - readyList = jQuery.Callbacks( "once memory" ); - - // Catch cases where $(document).ready() is called after the - // browser event has already occurred. - if ( document.readyState === "complete" ) { - // Handle it asynchronously to allow scripts the opportunity to delay ready - return setTimeout( jQuery.ready, 1 ); + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( !document.body ) { + return setTimeout( jQuery.ready ); } - // Mozilla, Opera and webkit nightlies currently support this event - if ( document.addEventListener ) { - // Use the handy event callback - document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); - - // A fallback to window.onload, that will always work - window.addEventListener( "load", jQuery.ready, false ); - - // If IE event model is used - } else if ( document.attachEvent ) { - // ensure firing before onload, - // maybe late but safe also for iframes - document.attachEvent( "onreadystatechange", DOMContentLoaded ); - - // A fallback to window.onload, that will always work - window.attachEvent( "onload", jQuery.ready ); + // Remember that the DOM is ready + jQuery.isReady = true; - // If IE and not a frame - // continually check to see if the document is ready - var toplevel = false; + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } - try { - toplevel = window.frameElement == null; - } catch(e) {} + // If there are functions bound, to execute + readyList.resolveWith( document, [ jQuery ] ); - if ( document.documentElement.doScroll && toplevel ) { - doScrollCheck(); - } + // Trigger any bound ready events + if ( jQuery.fn.trigger ) { + jQuery( document ).trigger("ready").off("ready"); } }, @@ -497,9 +449,8 @@ jQuery.extend({ return jQuery.type(obj) === "array"; }, - // A crude way of determining if an object is a window isWindow: function( obj ) { - return obj && typeof obj === "object" && "setInterval" in obj; + return obj != null && obj == obj.window; }, isNumeric: function( obj ) { @@ -507,9 +458,12 @@ jQuery.extend({ }, type: function( obj ) { - return obj == null ? - String( obj ) : - class2type[ toString.call(obj) ] || "object"; + if ( obj == null ) { + return String( obj ); + } + return typeof obj === "object" || typeof obj === "function" ? + class2type[ core_toString.call(obj) ] || "object" : + typeof obj; }, isPlainObject: function( obj ) { @@ -523,8 +477,8 @@ jQuery.extend({ try { // Not own constructor property must be Object if ( obj.constructor && - !hasOwn.call(obj, "constructor") && - !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { + !core_hasOwn.call(obj, "constructor") && + !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { return false; } } catch ( e ) { @@ -538,11 +492,12 @@ jQuery.extend({ var key; for ( key in obj ) {} - return key === undefined || hasOwn.call( obj, key ); + return key === undefined || core_hasOwn.call( obj, key ); }, isEmptyObject: function( obj ) { - for ( var name in obj ) { + var name; + for ( name in obj ) { return false; } return true; @@ -552,34 +507,70 @@ jQuery.extend({ throw new Error( msg ); }, - parseJSON: function( data ) { - if ( typeof data !== "string" || !data ) { + // data: string of html + // context (optional): If specified, the fragment will be created in this context, defaults to document + // keepScripts (optional): If true, will include scripts passed in the html string + parseHTML: function( data, context, keepScripts ) { + if ( !data || typeof data !== "string" ) { return null; } + if ( typeof context === "boolean" ) { + keepScripts = context; + context = false; + } + context = context || document; + + var parsed = rsingleTag.exec( data ), + scripts = !keepScripts && []; + + // Single tag + if ( parsed ) { + return [ context.createElement( parsed[1] ) ]; + } - // Make sure leading/trailing whitespace is removed (IE can't handle it) - data = jQuery.trim( data ); + parsed = jQuery.buildFragment( [ data ], context, scripts ); + if ( scripts ) { + jQuery( scripts ).remove(); + } + return jQuery.merge( [], parsed.childNodes ); + }, + parseJSON: function( data ) { // Attempt to parse using the native JSON parser first if ( window.JSON && window.JSON.parse ) { return window.JSON.parse( data ); } - // Make sure the incoming data is actual JSON - // Logic borrowed from http://json.org/json2.js - if ( rvalidchars.test( data.replace( rvalidescape, "@" ) - .replace( rvalidtokens, "]" ) - .replace( rvalidbraces, "")) ) { + if ( data === null ) { + return data; + } + + if ( typeof data === "string" ) { + + // Make sure leading/trailing whitespace is removed (IE can't handle it) + data = jQuery.trim( data ); - return ( new Function( "return " + data ) )(); + if ( data ) { + // Make sure the incoming data is actual JSON + // Logic borrowed from http://json.org/json2.js + if ( rvalidchars.test( data.replace( rvalidescape, "@" ) + .replace( rvalidtokens, "]" ) + .replace( rvalidbraces, "")) ) { + return ( new Function( "return " + data ) )(); + } + } } + jQuery.error( "Invalid JSON: " + data ); }, // Cross-browser xml parsing parseXML: function( data ) { var xml, tmp; + if ( !data || typeof data !== "string" ) { + return null; + } try { if ( window.DOMParser ) { // Standard tmp = new DOMParser(); @@ -604,7 +595,7 @@ jQuery.extend({ // Workarounds based on findings by Jim Driscoll // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context globalEval: function( data ) { - if ( data && rnotwhite.test( data ) ) { + 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 @@ -621,25 +612,30 @@ jQuery.extend({ }, nodeName: function( elem, name ) { - return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); + return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); }, // args is for internal usage only - each: function( object, callback, args ) { - var name, i = 0, - length = object.length, - isObj = length === undefined || jQuery.isFunction( object ); + each: function( obj, callback, args ) { + var value, + i = 0, + length = obj.length, + isArray = isArraylike( obj ); if ( args ) { - if ( isObj ) { - for ( name in object ) { - if ( callback.apply( object[ name ], args ) === false ) { + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback.apply( obj[ i ], args ); + + if ( value === false ) { break; } } } else { - for ( ; i < length; ) { - if ( callback.apply( object[ i++ ], args ) === false ) { + for ( i in obj ) { + value = callback.apply( obj[ i ], args ); + + if ( value === false ) { break; } } @@ -647,72 +643,75 @@ jQuery.extend({ // A special, fast, case for the most common use of each } else { - if ( isObj ) { - for ( name in object ) { - if ( callback.call( object[ name ], name, object[ name ] ) === false ) { + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback.call( obj[ i ], i, obj[ i ] ); + + if ( value === false ) { break; } } } else { - for ( ; i < length; ) { - if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) { + for ( i in obj ) { + value = callback.call( obj[ i ], i, obj[ i ] ); + + if ( value === false ) { break; } } } } - return object; + return obj; }, // Use native String.trim function wherever possible - trim: trim ? + trim: core_trim && !core_trim.call("\uFEFF\xA0") ? function( text ) { return text == null ? "" : - trim.call( text ); + core_trim.call( text ); } : // Otherwise use our own trimming functionality function( text ) { return text == null ? "" : - text.toString().replace( trimLeft, "" ).replace( trimRight, "" ); + ( text + "" ).replace( rtrim, "" ); }, // results is for internal usage only - makeArray: function( array, results ) { + makeArray: function( arr, results ) { var ret = results || []; - if ( array != null ) { - // The window, strings (and functions) also have 'length' - // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 - var type = jQuery.type( array ); - - if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) { - push.call( ret, array ); + if ( arr != null ) { + if ( isArraylike( Object(arr) ) ) { + jQuery.merge( ret, + typeof arr === "string" ? + [ arr ] : arr + ); } else { - jQuery.merge( ret, array ); + core_push.call( ret, arr ); } } return ret; }, - inArray: function( elem, array, i ) { + inArray: function( elem, arr, i ) { var len; - if ( array ) { - if ( indexOf ) { - return indexOf.call( array, elem, i ); + if ( arr ) { + if ( core_indexOf ) { + return core_indexOf.call( arr, elem, i ); } - len = array.length; + 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 array && array[ i ] === elem ) { + if ( i in arr && arr[ i ] === elem ) { return i; } } @@ -722,14 +721,14 @@ jQuery.extend({ }, merge: function( first, second ) { - var i = first.length, + var l = second.length, + i = first.length, j = 0; - if ( typeof second.length === "number" ) { - for ( var l = second.length; j < l; j++ ) { + if ( typeof l === "number" ) { + for ( ; j < l; j++ ) { first[ i++ ] = second[ j ]; } - } else { while ( second[j] !== undefined ) { first[ i++ ] = second[ j++ ]; @@ -742,12 +741,15 @@ jQuery.extend({ }, grep: function( elems, callback, inv ) { - var ret = [], retVal; + var retVal, + ret = [], + i = 0, + length = elems.length; inv = !!inv; // Go through the array, only saving the items // that pass the validator function - for ( var i = 0, length = elems.length; i < length; i++ ) { + for ( ; i < length; i++ ) { retVal = !!callback( elems[ i ], i ); if ( inv !== retVal ) { ret.push( elems[ i ] ); @@ -759,11 +761,11 @@ jQuery.extend({ // arg is for internal usage only map: function( elems, callback, arg ) { - var value, key, ret = [], + var value, i = 0, length = elems.length, - // jquery objects are treated as arrays - isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ; + isArray = isArraylike( elems ), + ret = []; // Go through the array, translating each of the items to their if ( isArray ) { @@ -777,8 +779,8 @@ jQuery.extend({ // Go through every key on the object, } else { - for ( key in elems ) { - value = callback( elems[ key ], key, arg ); + for ( i in elems ) { + value = callback( elems[ i ], i, arg ); if ( value != null ) { ret[ ret.length ] = value; @@ -787,7 +789,7 @@ jQuery.extend({ } // Flatten any nested arrays - return ret.concat.apply( [], ret ); + return core_concat.apply( [], ret ); }, // A global GUID counter for objects @@ -796,8 +798,10 @@ jQuery.extend({ // Bind a function to a context, optionally partially applying any // arguments. proxy: function( fn, context ) { + var args, proxy, tmp; + if ( typeof context === "string" ) { - var tmp = fn[ context ]; + tmp = fn[ context ]; context = fn; fn = tmp; } @@ -809,178 +813,182 @@ jQuery.extend({ } // Simulated bind - var args = slice.call( arguments, 2 ), - proxy = function() { - return fn.apply( context, args.concat( slice.call( arguments ) ) ); - }; + args = core_slice.call( arguments, 2 ); + proxy = function() { + return fn.apply( context || this, args.concat( core_slice.call( arguments ) ) ); + }; // Set the guid of unique handler to the same of original handler, so it can be removed - proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; + proxy.guid = fn.guid = fn.guid || jQuery.guid++; return proxy; }, - // Mutifunctional method to get and set values to a collection + // Multifunctional method to get and set values of a collection // The value/s can optionally be executed if it's a function - access: function( elems, key, value, exec, fn, pass ) { - var length = elems.length; + access: function( elems, fn, key, value, chainable, emptyGet, raw ) { + var i = 0, + length = elems.length, + bulk = key == null; - // Setting many attributes - if ( typeof key === "object" ) { - for ( var k in key ) { - jQuery.access( elems, k, key[k], exec, fn, value ); + // Sets many values + if ( jQuery.type( key ) === "object" ) { + chainable = true; + for ( i in key ) { + jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); } - return elems; - } - // Setting one attribute - if ( value !== undefined ) { - // Optionally, function values get executed if exec is true - exec = !pass && exec && jQuery.isFunction(value); + // Sets one value + } else if ( value !== undefined ) { + chainable = true; + + if ( !jQuery.isFunction( value ) ) { + raw = true; + } - for ( var i = 0; i < length; i++ ) { - fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); + 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 ); + }; + } } - return elems; + if ( fn ) { + for ( ; i < length; i++ ) { + fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) ); + } + } } - // Getting an attribute - return length ? fn( elems[0], key ) : undefined; + return chainable ? + elems : + + // Gets + bulk ? + fn.call( elems ) : + length ? fn( elems[0], key ) : emptyGet; }, now: function() { return ( new Date() ).getTime(); - }, + } +}); - // Use of jQuery.browser is frowned upon. - // More details: http://docs.jquery.com/Utilities/jQuery.browser - uaMatch: function( ua ) { - ua = ua.toLowerCase(); +jQuery.ready.promise = function( obj ) { + if ( !readyList ) { - var match = rwebkit.exec( ua ) || - ropera.exec( ua ) || - rmsie.exec( ua ) || - ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) || - []; + readyList = jQuery.Deferred(); - return { browser: match[1] || "", version: match[2] || "0" }; - }, + // 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 ); - sub: function() { - function jQuerySub( selector, context ) { - return new jQuerySub.fn.init( selector, context ); - } - jQuery.extend( true, jQuerySub, this ); - jQuerySub.superclass = this; - jQuerySub.fn = jQuerySub.prototype = this(); - jQuerySub.fn.constructor = jQuerySub; - jQuerySub.sub = this.sub; - jQuerySub.fn.init = function init( selector, context ) { - if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { - context = jQuerySub( context ); - } + // Standards-based browsers support DOMContentLoaded + } else if ( document.addEventListener ) { + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", completed, false ); - return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); - }; - jQuerySub.fn.init.prototype = jQuerySub.fn; - var rootjQuerySub = jQuerySub(document); - return jQuerySub; - }, + // A fallback to window.onload, that will always work + window.addEventListener( "load", completed, false ); - browser: {} -}); + // If IE event model is used + } else { + // Ensure firing before onload, maybe late but safe also for iframes + document.attachEvent( "onreadystatechange", completed ); -// Populate the class2type map -jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { - class2type[ "[object " + name + "]" ] = name.toLowerCase(); -}); + // A fallback to window.onload, that will always work + window.attachEvent( "onload", completed ); -browserMatch = jQuery.uaMatch( userAgent ); -if ( browserMatch.browser ) { - jQuery.browser[ browserMatch.browser ] = true; - jQuery.browser.version = browserMatch.version; -} + // If IE and not a frame + // continually check to see if the document is ready + var top = false; -// Deprecated, use jQuery.browser.webkit instead -if ( jQuery.browser.webkit ) { - jQuery.browser.safari = true; -} + try { + top = window.frameElement == null && document.documentElement; + } catch(e) {} -// IE doesn't match non-breaking spaces with \s -if ( rnotwhite.test( "\xA0" ) ) { - trimLeft = /^[\s\xA0]+/; - trimRight = /[\s\xA0]+$/; -} + if ( top && top.doScroll ) { + (function doScrollCheck() { + if ( !jQuery.isReady ) { -// All jQuery objects should point back to these -rootjQuery = jQuery(document); + try { + // Use the trick by Diego Perini + // http://javascript.nwbox.com/IEContentLoaded/ + top.doScroll("left"); + } catch(e) { + return setTimeout( doScrollCheck, 50 ); + } -// Cleanup functions for the document ready method -if ( document.addEventListener ) { - DOMContentLoaded = function() { - document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); - jQuery.ready(); - }; + // detach all dom ready events + detach(); -} else if ( document.attachEvent ) { - DOMContentLoaded = function() { - // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). - if ( document.readyState === "complete" ) { - document.detachEvent( "onreadystatechange", DOMContentLoaded ); - jQuery.ready(); + // and execute any waiting functions + jQuery.ready(); + } + })(); + } } - }; -} - -// The DOM ready check for Internet Explorer -function doScrollCheck() { - if ( jQuery.isReady ) { - return; - } - - try { - // If IE is used, use the trick by Diego Perini - // http://javascript.nwbox.com/IEContentLoaded/ - document.documentElement.doScroll("left"); - } catch(e) { - setTimeout( doScrollCheck, 1 ); - return; } + return readyList.promise( obj ); +}; - // and execute any waiting functions - jQuery.ready(); -} +// Populate the class2type map +jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); +}); -return jQuery; +function isArraylike( obj ) { + var length = obj.length, + type = jQuery.type( obj ); -})(); + if ( jQuery.isWindow( obj ) ) { + return false; + } + if ( obj.nodeType === 1 && length ) { + return true; + } -// String to Object flags format cache -var flagsCache = {}; + return type === "array" || type !== "function" && + ( length === 0 || + typeof length === "number" && length > 0 && ( length - 1 ) in obj ); +} -// Convert String-formatted flags into Object-formatted ones and store in cache -function createFlags( flags ) { - var object = flagsCache[ flags ] = {}, - i, length; - flags = flags.split( /\s+/ ); - for ( i = 0, length = flags.length; i < length; i++ ) { - object[ flags[i] ] = true; - } +// All jQuery objects should point back to these +rootjQuery = jQuery(document); +// 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( core_rnotwhite ) || [], function( _, flag ) { + object[ flag ] = true; + }); return object; } /* * Create a callback list using the following parameters: * - * flags: an optional list of space-separated flags that will change how - * the callback list behaves + * 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 flags: + * Possible options: * * once: will ensure the callback list can only be fired once (like a Deferred) * @@ -993,72 +1001,54 @@ function createFlags( flags ) { * stopOnFalse: interrupt callings when a callback returns false * */ -jQuery.Callbacks = function( flags ) { +jQuery.Callbacks = function( options ) { - // Convert flags from String-formatted to Object-formatted + // Convert options from String-formatted to Object-formatted if needed // (we check in cache first) - flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {}; + options = typeof options === "string" ? + ( optionsCache[ options ] || createOptions( options ) ) : + jQuery.extend( {}, options ); - var // Actual callback list - list = [], - // Stack of fire calls for repeatable lists - stack = [], + var // Flag to know if list is currently firing + firing, // Last fire value (for non-forgettable lists) memory, - // Flag to know if list is currently firing - firing, - // First callback to fire (used internally by add and fireWith) - firingStart, + // 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, - // Add one or several callbacks to the list - add = function( args ) { - var i, - length, - elem, - type, - actual; - for ( i = 0, length = args.length; i < length; i++ ) { - elem = args[ i ]; - type = jQuery.type( elem ); - if ( type === "array" ) { - // Inspect recursively - add( elem ); - } else if ( type === "function" ) { - // Add if not in unique mode and callback is not in - if ( !flags.unique || !self.has( elem ) ) { - list.push( elem ); - } - } - } - }, + // 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( context, args ) { - args = args || []; - memory = !flags.memory || [ context, args ]; - firing = true; + 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( context, args ) === false && flags.stopOnFalse ) { - memory = true; // Mark as halted + 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 ( !flags.once ) { - if ( stack && stack.length ) { - memory = stack.shift(); - self.fireWith( memory[ 0 ], memory[ 1 ] ); + if ( stack ) { + if ( stack.length ) { + fire( stack.shift() ); } - } else if ( memory === true ) { - self.disable(); - } else { + } else if ( memory ) { list = []; + } else { + self.disable(); } } }, @@ -1067,18 +1057,30 @@ jQuery.Callbacks = function( flags ) { // Add a callback or a collection of callbacks to the list add: function() { if ( list ) { - var length = list.length; - add( arguments ); + // 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, unless previous - // firing was halted (stopOnFalse) - } else if ( memory && memory !== true ) { - firingStart = length; - fire( memory[ 0 ], memory[ 1 ] ); + // we should call right away + } else if ( memory ) { + firingStart = start; + fire( memory ); } } return this; @@ -1086,46 +1088,28 @@ jQuery.Callbacks = function( flags ) { // Remove a callback from the list remove: function() { if ( list ) { - var args = arguments, - argIndex = 0, - argLength = args.length; - for ( ; argIndex < argLength ; argIndex++ ) { - for ( var i = 0; i < list.length; i++ ) { - if ( args[ argIndex ] === list[ i ] ) { - // Handle firingIndex and firingLength - if ( firing ) { - if ( i <= firingLength ) { - firingLength--; - if ( i <= firingIndex ) { - firingIndex--; - } - } + 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--; } - // Remove the element - list.splice( i--, 1 ); - // If we have some unicity property then - // we only need to do this once - if ( flags.unique ) { - break; + if ( index <= firingIndex ) { + firingIndex--; } } } - } + }); } return this; }, - // Control if a given callback is in the list + // 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 ) { - if ( list ) { - var i = 0, - length = list.length; - for ( ; i < length; i++ ) { - if ( fn === list[ i ] ) { - return true; - } - } - } - return false; + return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length ); }, // Remove all callbacks from the list empty: function() { @@ -1144,7 +1128,7 @@ jQuery.Callbacks = function( flags ) { // Lock the list in its current state lock: function() { stack = undefined; - if ( !memory || memory === true ) { + if ( !memory ) { self.disable(); } return this; @@ -1155,13 +1139,13 @@ jQuery.Callbacks = function( flags ) { }, // Call all callbacks with the given context and arguments fireWith: function( context, args ) { - if ( stack ) { + args = args || []; + args = [ context, args.slice ? args.slice() : args ]; + if ( list && ( !fired || stack ) ) { if ( firing ) { - if ( !flags.once ) { - stack.push( [ context, args ] ); - } - } else if ( !( flags.once && memory ) ) { - fire( context, args ); + stack.push( args ); + } else { + fire( args ); } } return this; @@ -1173,104 +1157,91 @@ jQuery.Callbacks = function( flags ) { }, // To know if the callbacks have already been called at least once fired: function() { - return !!memory; + return !!fired; } }; return self; }; - - - - -var // Static reference to slice - sliceDeferred = [].slice; - jQuery.extend({ Deferred: function( func ) { - var doneList = jQuery.Callbacks( "once memory" ), - failList = jQuery.Callbacks( "once memory" ), - progressList = jQuery.Callbacks( "memory" ), + 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", - lists = { - resolve: doneList, - reject: failList, - notify: progressList - }, promise = { - done: doneList.add, - fail: failList.add, - progress: progressList.add, - state: function() { return state; }, - - // Deprecated - isResolved: doneList.fired, - isRejected: failList.fired, - - then: function( doneCallbacks, failCallbacks, progressCallbacks ) { - deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks ); - return this; - }, always: function() { - deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments ); + deferred.done( arguments ).fail( arguments ); return this; }, - pipe: function( fnDone, fnFail, fnProgress ) { + then: function( /* fnDone, fnFail, fnProgress */ ) { + var fns = arguments; return jQuery.Deferred(function( newDefer ) { - jQuery.each( { - done: [ fnDone, "resolve" ], - fail: [ fnFail, "reject" ], - progress: [ fnProgress, "notify" ] - }, function( handler, data ) { - var fn = data[ 0 ], - action = data[ 1 ], - returned; - if ( jQuery.isFunction( fn ) ) { - deferred[ handler ](function() { - returned = fn.apply( this, arguments ); - if ( returned && jQuery.isFunction( returned.promise ) ) { - returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify ); - } else { - newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] ); - } - }); - } else { - deferred[ handler ]( newDefer[ action ] ); - } + jQuery.each( tuples, function( i, tuple ) { + var action = tuple[ 0 ], + 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[ action + "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 ) { - if ( obj == null ) { - obj = promise; - } else { - for ( var key in promise ) { - obj[ key ] = promise[ key ]; - } - } - return obj; + return obj != null ? jQuery.extend( obj, promise ) : promise; } }, - deferred = promise.promise({}), - key; + deferred = {}; - for ( key in lists ) { - deferred[ key ] = lists[ key ].fire; - deferred[ key + "With" ] = lists[ key ].fireWith; - } + // 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 ]; - // Handle state - deferred.done( function() { - state = "resolved"; - }, failList.disable, progressList.lock ).fail( function() { - state = "rejected"; - }, doneList.disable, progressList.lock ); + // 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 ) { @@ -1282,90 +1253,87 @@ jQuery.extend({ }, // Deferred helper - when: function( firstParam ) { - var args = sliceDeferred.call( arguments, 0 ), - i = 0, - length = args.length, - pValues = new Array( length ), - count = length, - pCount = length, - deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ? - firstParam : - jQuery.Deferred(), - promise = deferred.promise(); - function resolveFunc( i ) { - return function( value ) { - args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; - if ( !( --count ) ) { - deferred.resolveWith( deferred, args ); - } - }; - } - function progressFunc( i ) { - return function( value ) { - pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; - deferred.notifyWith( promise, pValues ); - }; - } + when: function( subordinate /* , ..., subordinateN */ ) { + var i = 0, + resolveValues = core_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 ? core_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 ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) { - args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(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 { - --count; + --remaining; } } - if ( !count ) { - deferred.resolveWith( deferred, args ); - } - } else if ( deferred !== firstParam ) { - deferred.resolveWith( deferred, length ? [ firstParam ] : [] ); } - return promise; - } -}); + // if we're not waiting on anything, resolve the master + if ( !remaining ) { + deferred.resolveWith( resolveContexts, resolveValues ); + } + return deferred.promise(); + } +}); +jQuery.support = (function() { + var support, all, a, + input, select, fragment, + opt, eventName, isSupported, i, + div = document.createElement("div"); -jQuery.support = (function() { + // Setup + div.setAttribute( "className", "t" ); + div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>"; - var support, - all, - a, - select, - opt, - input, - marginDiv, - fragment, - tds, - events, - eventName, - i, - isSupported, - div = document.createElement( "div" ), - documentElement = document.documentElement; - - // Preliminary tests - div.setAttribute("className", "t"); - div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>"; - - all = div.getElementsByTagName( "*" ); - a = div.getElementsByTagName( "a" )[ 0 ]; - - // Can't get basic test support - if ( !all || !all.length || !a ) { + // Support tests won't run in some limited or non-browser environments + all = div.getElementsByTagName("*"); + a = div.getElementsByTagName("a")[ 0 ]; + if ( !all || !a || !all.length ) { return {}; } - // First batch of supports tests - select = document.createElement( "select" ); + // First batch of tests + select = document.createElement("select"); opt = select.appendChild( document.createElement("option") ); - input = div.getElementsByTagName( "input" )[ 0 ]; + input = div.getElementsByTagName("input")[ 0 ]; + a.style.cssText = "top:1px;float:left;opacity:.5"; support = { + // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) + getSetAttribute: div.className !== "t", + // IE strips leading whitespace when .innerHTML is used - leadingWhitespace: ( div.firstChild.nodeType === 3 ), + leadingWhitespace: div.firstChild.nodeType === 3, // Make sure that tbody elements aren't automatically inserted // IE will insert them into empty tables @@ -1381,45 +1349,42 @@ jQuery.support = (function() { // Make sure that URLs aren't manipulated // (IE normalizes it by default) - hrefNormalized: ( a.getAttribute("href") === "/a" ), + hrefNormalized: a.getAttribute("href") === "/a", // Make sure that element opacity exists // (IE uses filter instead) // Use a regex to work around a WebKit issue. See #5145 - opacity: /^0.55/.test( a.style.opacity ), + opacity: /^0.5/.test( a.style.opacity ), // Verify style float existence // (IE uses styleFloat instead of cssFloat) cssFloat: !!a.style.cssFloat, - // Make sure that if no value is specified for a checkbox - // that it defaults to "on". - // (WebKit defaults to "" instead) - checkOn: ( input.value === "on" ), + // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere) + checkOn: !!input.value, // Make sure that a selected-by-default option has a working selected property. // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) optSelected: opt.selected, - // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) - getSetAttribute: div.className !== "t", - - // Tests for enctype support on a form(#6743) + // Tests for enctype support on a form (#6743) enctype: !!document.createElement("form").enctype, // Makes sure cloning an html5 element does not cause problems // Where outerHTML is undefined, this still works html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>", + // jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode + boxModel: document.compatMode === "CSS1Compat", + // Will be defined later - submitBubbles: true, - changeBubbles: true, - focusinBubbles: false, deleteExpando: true, noCloneEvent: true, inlineBlockNeedsLayout: false, shrinkWrapBlocks: false, - reliableMarginRight: true + reliableMarginRight: true, + boxSizingReliable: true, + pixelPosition: false }; // Make sure checked status is properly cloned @@ -1431,93 +1396,64 @@ jQuery.support = (function() { select.disabled = true; support.optDisabled = !opt.disabled; - // Test to see if it's possible to delete an expando from an element - // Fails in Internet Explorer + // Support: IE<9 try { delete div.test; } catch( e ) { support.deleteExpando = false; } - if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { - div.attachEvent( "onclick", function() { - // Cloning a node shouldn't copy over any - // bound event handlers (IE does this) - support.noCloneEvent = false; - }); - div.cloneNode( true ).fireEvent( "onclick" ); - } - - // Check if a radio maintains its value - // after being appended to the DOM + // Check if we can trust getAttribute("value") input = document.createElement("input"); + input.setAttribute( "value", "" ); + support.input = input.getAttribute( "value" ) === ""; + + // Check if an input maintains its value after becoming a radio input.value = "t"; - input.setAttribute("type", "radio"); + input.setAttribute( "type", "radio" ); support.radioValue = input.value === "t"; - input.setAttribute("checked", "checked"); - div.appendChild( input ); - fragment = document.createDocumentFragment(); - fragment.appendChild( div.lastChild ); + // #11217 - WebKit loses check when the name is after the checked attribute + input.setAttribute( "checked", "t" ); + input.setAttribute( "name", "t" ); - // WebKit doesn't clone checked state correctly in fragments - support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; + fragment = document.createDocumentFragment(); + fragment.appendChild( input ); // Check if a disconnected checkbox will retain its checked // value of true after appended to the DOM (IE6/7) support.appendChecked = input.checked; - fragment.removeChild( input ); - fragment.appendChild( div ); - - div.innerHTML = ""; - - // Check if div with explicit width and no margin-right incorrectly - // gets computed margin-right based on width of container. For more - // info see bug #3333 - // Fails in WebKit before Feb 2011 nightlies - // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right - if ( window.getComputedStyle ) { - marginDiv = document.createElement( "div" ); - marginDiv.style.width = "0"; - marginDiv.style.marginRight = "0"; - div.style.width = "2px"; - div.appendChild( marginDiv ); - support.reliableMarginRight = - ( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0; - } - - // Technique from Juriy Zaytsev - // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ - // We only care about the case where non-standard event systems - // are used, namely in IE. Short-circuiting here helps us to - // avoid an eval call (in setAttribute) which can cause CSP - // to go haywire. See: https://developer.mozilla.org/en/Security/CSP + // WebKit doesn't clone checked state correctly in fragments + support.checkClone = fragment.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() if ( div.attachEvent ) { - for( i in { - submit: 1, - change: 1, - focusin: 1 - }) { - eventName = "on" + i; - isSupported = ( eventName in div ); - if ( !isSupported ) { - div.setAttribute( eventName, "return;" ); - isSupported = ( typeof div[ eventName ] === "function" ); - } - support[ i + "Bubbles" ] = isSupported; - } + div.attachEvent( "onclick", function() { + support.noCloneEvent = false; + }); + + div.cloneNode( true ).click(); } - fragment.removeChild( div ); + // Support: IE<9 (lack submit/change bubble), Firefox 17+ (lack focusin event) + // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP), test/csp.php + for ( i in { submit: true, change: true, focusin: true }) { + div.setAttribute( eventName = "on" + i, "t" ); - // Null elements to avoid leaks in IE - fragment = select = opt = marginDiv = div = input = null; + support[ i + "Bubbles" ] = eventName in window || div.attributes[ eventName ].expando === false; + } + + div.style.backgroundClip = "content-box"; + div.cloneNode( true ).style.backgroundClip = ""; + support.clearCloneStyle = div.style.backgroundClip === "content-box"; // Run tests that need a body at doc ready jQuery(function() { - var container, outer, inner, table, td, offsetSupport, - conMarginTop, ptlm, vb, style, html, + var container, marginDiv, tds, + divReset = "padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;", body = document.getElementsByTagName("body")[0]; if ( !body ) { @@ -1525,400 +1461,374 @@ jQuery.support = (function() { return; } - conMarginTop = 1; - ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;"; - vb = "visibility:hidden;border:0;"; - style = "style='" + ptlm + "border:5px solid #000;padding:0;'"; - html = "<div " + style + "><div></div></div>" + - "<table " + style + " cellpadding='0' cellspacing='0'>" + - "<tr><td></td></tr></table>"; - container = document.createElement("div"); - container.style.cssText = vb + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px"; - body.insertBefore( container, body.firstChild ); + container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px"; - // Construct the test element - div = document.createElement("div"); - container.appendChild( div ); + body.appendChild( container ).appendChild( div ); + // Support: IE8 // Check if table cells still have offsetWidth/Height when they are set // to display:none and there are still other visible table cells in a // table row; if so, offsetWidth/Height are not reliable for use when // determining if an element has been hidden directly using // display:none (it is still safe to use offsets if a parent element is // hidden; don safety goggles and see bug #4512 for more information). - // (only IE 8 fails this test) - div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>"; - tds = div.getElementsByTagName( "td" ); + div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>"; + tds = div.getElementsByTagName("td"); + tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none"; isSupported = ( tds[ 0 ].offsetHeight === 0 ); tds[ 0 ].style.display = ""; tds[ 1 ].style.display = "none"; + // Support: IE8 // Check if empty table cells still have offsetWidth/Height - // (IE <= 8 fail this test) support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); - // Figure out if the W3C box model works as expected + // Check box-sizing and margin behavior div.innerHTML = ""; - div.style.width = div.style.paddingLeft = "1px"; - jQuery.boxModel = support.boxModel = div.offsetWidth === 2; - - if ( typeof div.style.zoom !== "undefined" ) { + div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;"; + support.boxSizing = ( div.offsetWidth === 4 ); + support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 ); + + // Use window.getComputedStyle because jsdom on node.js will break without it. + if ( window.getComputedStyle ) { + support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%"; + support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px"; + + // Check if div with explicit width and no margin-right incorrectly + // gets computed margin-right based on width of container. (#3333) + // Fails in WebKit before Feb 2011 nightlies + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right + marginDiv = div.appendChild( document.createElement("div") ); + marginDiv.style.cssText = div.style.cssText = divReset; + marginDiv.style.marginRight = marginDiv.style.width = "0"; + div.style.width = "1px"; + + support.reliableMarginRight = + !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight ); + } + + if ( typeof div.style.zoom !== core_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 - // (IE < 8 does this) - div.style.display = "inline"; - div.style.zoom = 1; - support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 ); + div.innerHTML = ""; + div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1"; + support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 ); + // Support: IE6 // Check if elements with layout shrink-wrap their children - // (IE 6 does this) - div.style.display = ""; - div.innerHTML = "<div style='width:4px;'></div>"; - support.shrinkWrapBlocks = ( div.offsetWidth !== 2 ); - } - - div.style.cssText = ptlm + vb; - div.innerHTML = html; - - outer = div.firstChild; - inner = outer.firstChild; - td = outer.nextSibling.firstChild.firstChild; + div.style.display = "block"; + div.innerHTML = "<div></div>"; + div.firstChild.style.width = "5px"; + support.shrinkWrapBlocks = ( div.offsetWidth !== 3 ); - offsetSupport = { - doesNotAddBorder: ( inner.offsetTop !== 5 ), - doesAddBorderForTableAndCells: ( td.offsetTop === 5 ) - }; - - inner.style.position = "fixed"; - inner.style.top = "20px"; - - // safari subtracts parent border width here which is 5px - offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 ); - inner.style.position = inner.style.top = ""; - - outer.style.overflow = "hidden"; - outer.style.position = "relative"; - - offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 ); - offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop ); + if ( support.inlineBlockNeedsLayout ) { + // 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 ); - div = container = null; - jQuery.extend( support, offsetSupport ); + // Null elements to avoid leaks in IE + container = div = tds = marginDiv = null; }); + // Null elements to avoid leaks in IE + all = select = fragment = opt = a = input = null; + return support; })(); - - - -var rbrace = /^(?:\{.*\}|\[.*\])$/, +var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/, rmultiDash = /([A-Z])/g; -jQuery.extend({ - cache: {}, - - // Please use with caution - uuid: 0, - - // Unique for each copy of jQuery on the page - // Non-digits removed to match rinlinejQuery - expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), - - // The following elements throw uncatchable exceptions if you - // attempt to add expando properties to them. - noData: { - "embed": true, - // Ban all objects except for Flash (which handle expandos) - "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", - "applet": true - }, - - hasData: function( elem ) { - elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; - return !!elem && !isEmptyDataObject( elem ); - }, - - data: function( elem, name, data, pvt /* Internal Use Only */ ) { - if ( !jQuery.acceptData( elem ) ) { - return; - } +function internalData( elem, name, data, pvt /* Internal Use Only */ ){ + if ( !jQuery.acceptData( elem ) ) { + return; + } - var privateCache, thisCache, ret, - internalKey = jQuery.expando, - getByName = typeof name === "string", + var thisCache, ret, + internalKey = jQuery.expando, + getByName = typeof name === "string", - // 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, + // 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 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, - isEvents = name === "events"; + // 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] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) { - return; - } + // 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)) && getByName && data === undefined ) { + return; + } - if ( !id ) { - // Only DOM nodes need a new unique ID for each element since their data - // ends up in the global cache - if ( isNode ) { - elem[ internalKey ] = id = ++jQuery.uuid; - } else { - id = internalKey; - } + if ( !id ) { + // Only DOM nodes need a new unique ID for each element since their data + // ends up in the global cache + if ( isNode ) { + elem[ internalKey ] = id = core_deletedIds.pop() || jQuery.guid++; + } else { + id = internalKey; } + } - if ( !cache[ id ] ) { - cache[ id ] = {}; - - // Avoids exposing jQuery metadata on plain JS objects when the object - // is serialized using JSON.stringify - if ( !isNode ) { - cache[ id ].toJSON = jQuery.noop; - } - } + if ( !cache[ id ] ) { + cache[ id ] = {}; - // 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 ); - } + // Avoids exposing jQuery metadata on plain JS objects when the object + // is serialized using JSON.stringify + if ( !isNode ) { + cache[ id ].toJSON = jQuery.noop; } + } - privateCache = 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; + // 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 ); } + } - if ( data !== undefined ) { - thisCache[ jQuery.camelCase( name ) ] = data; - } + thisCache = cache[ id ]; - // Users should not attempt to inspect the internal events object using jQuery.data, - // it is undocumented and subject to change. But does anyone listen? No. - if ( isEvents && !thisCache[ name ] ) { - return privateCache.events; + // 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 = {}; } - // Check for both converted-to-camel and non-converted data property names - // If a data property was specified - if ( getByName ) { + thisCache = thisCache.data; + } - // First Try to find as-is property data - ret = thisCache[ name ]; + if ( data !== undefined ) { + thisCache[ jQuery.camelCase( name ) ] = data; + } - // Test for null|undefined property data - if ( ret == null ) { + // Check for both converted-to-camel and non-converted data property names + // If a data property was specified + if ( getByName ) { - // Try to find the camelCased property - ret = thisCache[ jQuery.camelCase( name ) ]; - } - } else { - ret = thisCache; - } + // First Try to find as-is property data + ret = thisCache[ name ]; - return ret; - }, + // Test for null|undefined property data + if ( ret == null ) { - removeData: function( elem, name, pvt /* Internal Use Only */ ) { - if ( !jQuery.acceptData( elem ) ) { - return; + // Try to find the camelCased property + ret = thisCache[ jQuery.camelCase( name ) ]; } + } else { + ret = thisCache; + } - var thisCache, i, l, + return ret; +} - // Reference to internal data cache key - internalKey = jQuery.expando, +function internalRemoveData( elem, name, pvt ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } - isNode = elem.nodeType, + var i, l, thisCache, + isNode = elem.nodeType, - // See jQuery.data for more information - cache = isNode ? jQuery.cache : elem, + // See jQuery.data for more information + cache = isNode ? jQuery.cache : elem, + id = isNode ? elem[ jQuery.expando ] : jQuery.expando; - // See jQuery.data for more information - id = isNode ? elem[ internalKey ] : internalKey; + // If there is already no cache entry for this object, there is no + // purpose in continuing + if ( !cache[ id ] ) { + return; + } - // If there is already no cache entry for this object, there is no - // purpose in continuing - if ( !cache[ id ] ) { - return; - } + if ( name ) { - if ( name ) { + thisCache = pvt ? cache[ id ] : cache[ id ].data; - thisCache = pvt ? cache[ id ] : cache[ id ].data; + if ( thisCache ) { - if ( thisCache ) { + // Support array or space separated string names for data keys + if ( !jQuery.isArray( name ) ) { - // 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 { - // try the string as a key before any manipulation + // 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 { - - // 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( " " ); - } + name = name.split(" "); } } - - for ( i = 0, l = name.length; i < l; 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 : jQuery.isEmptyObject )( thisCache ) ) { - return; - } + } 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 ) ); } - } - // See jQuery.data for more information - if ( !pvt ) { - delete cache[ id ].data; + for ( i = 0, l = name.length; i < l; i++ ) { + delete thisCache[ name[i] ]; + } - // Don't destroy the parent cache unless the internal data object - // had been the only thing left in it - if ( !isEmptyDataObject(cache[ id ]) ) { + // If there is no data left in the cache, we want to continue + // and let the cache object itself get destroyed + if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) { return; } } + } - // Browsers that fail expando deletion also refuse to delete expandos on - // the window, but it will allow it on all other JS objects; other browsers - // don't care - // Ensure that `cache` is not a window object #10080 - if ( jQuery.support.deleteExpando || !cache.setInterval ) { - delete cache[ id ]; - } else { - cache[ id ] = null; - } + // See jQuery.data for more information + if ( !pvt ) { + delete cache[ id ].data; - // We destroyed the cache and need to eliminate the expando on the node to avoid - // false lookups in the cache for entries that no longer exist - if ( isNode ) { - // IE does not allow us to delete expando properties from nodes, - // nor does it have a removeAttribute function on Document nodes; - // we must handle all of these cases - if ( jQuery.support.deleteExpando ) { - delete elem[ internalKey ]; - } else if ( elem.removeAttribute ) { - elem.removeAttribute( internalKey ); - } else { - elem[ internalKey ] = null; - } + // 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) + } else if ( jQuery.support.deleteExpando || cache != cache.window ) { + delete cache[ id ]; + + // When all else fails, null + } else { + cache[ id ] = null; + } +} + +jQuery.extend({ + cache: {}, + + // Unique for each copy of jQuery on the page + // Non-digits removed to match rinlinejQuery + expando: "jQuery" + ( core_version + Math.random() ).replace( /\D/g, "" ), + + // The following elements throw uncatchable exceptions if you + // attempt to add expando properties to them. + noData: { + "embed": true, + // Ban all objects except for Flash (which handle expandos) + "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", + "applet": true + }, + + hasData: function( elem ) { + elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; + return !!elem && !isEmptyDataObject( elem ); + }, + + data: function( elem, name, data ) { + return internalData( elem, name, data ); + }, + + removeData: function( elem, name ) { + return internalRemoveData( elem, name ); }, // For internal use only. _data: function( elem, name, data ) { - return jQuery.data( elem, name, data, true ); + return internalData( elem, name, data, true ); + }, + + _removeData: function( elem, name ) { + return internalRemoveData( elem, name, true ); }, // A method for determining if a DOM node can handle the data expando acceptData: function( elem ) { - if ( elem.nodeName ) { - var match = jQuery.noData[ elem.nodeName.toLowerCase() ]; - - if ( match ) { - return !(match === true || elem.getAttribute("classid") !== match); - } + // Do not set data on non-element because it will not be cleared (#8335). + if ( elem.nodeType && elem.nodeType !== 1 && elem.nodeType !== 9 ) { + return false; } - return true; + var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ]; + + // nodes accept data unless otherwise specified; rejection can be conditional + return !noData || noData !== true && elem.getAttribute("classid") === noData; } }); jQuery.fn.extend({ data: function( key, value ) { - var parts, attr, name, + var attrs, name, + elem = this[0], + i = 0, data = null; - if ( typeof key === "undefined" ) { + // Gets all values + if ( key === undefined ) { if ( this.length ) { - data = jQuery.data( this[0] ); + data = jQuery.data( elem ); - if ( this[0].nodeType === 1 && !jQuery._data( this[0], "parsedAttrs" ) ) { - attr = this[0].attributes; - for ( var i = 0, l = attr.length; i < l; i++ ) { - name = attr[i].name; + if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) { + attrs = elem.attributes; + for ( ; i < attrs.length; i++ ) { + name = attrs[i].name; - if ( name.indexOf( "data-" ) === 0 ) { - name = jQuery.camelCase( name.substring(5) ); + if ( !name.indexOf( "data-" ) ) { + name = jQuery.camelCase( name.slice(5) ); - dataAttr( this[0], name, data[ name ] ); + dataAttr( elem, name, data[ name ] ); } } - jQuery._data( this[0], "parsedAttrs", true ); + jQuery._data( elem, "parsedAttrs", true ); } } return data; + } - } else if ( typeof key === "object" ) { + // Sets multiple values + if ( typeof key === "object" ) { return this.each(function() { jQuery.data( this, key ); }); } - parts = key.split("."); - parts[1] = parts[1] ? "." + parts[1] : ""; - - if ( value === undefined ) { - data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); + return jQuery.access( this, function( value ) { - // Try to fetch any internally stored data first - if ( data === undefined && this.length ) { - data = jQuery.data( this[0], key ); - data = dataAttr( this[0], key, data ); + if ( value === undefined ) { + // Try to fetch any internally stored data first + return elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : null; } - return data === undefined && parts[1] ? - this.data( parts[0] ) : - data; - - } else { - return this.each(function() { - var self = jQuery( this ), - args = [ parts[0], value ]; - - self.triggerHandler( "setData" + parts[1] + "!", args ); + this.each(function() { jQuery.data( this, key, value ); - self.triggerHandler( "changeData" + parts[1] + "!", args ); }); - } + }, null, value, arguments.length > 1, null, true ); }, removeData: function( key ) { @@ -1940,11 +1850,12 @@ function dataAttr( elem, key, data ) { if ( typeof data === "string" ) { try { data = data === "true" ? true : - data === "false" ? false : - data === "null" ? null : - jQuery.isNumeric( data ) ? parseFloat( data ) : + 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; + data; } catch( e ) {} // Make sure we set the data so it isn't changed later @@ -1960,7 +1871,8 @@ function dataAttr( elem, key, data ) { // checks a cache object for emptiness function isEmptyDataObject( obj ) { - for ( var name in 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] ) ) { @@ -1973,73 +1885,23 @@ function isEmptyDataObject( obj ) { return true; } - - - - -function handleQueueMarkDefer( elem, type, src ) { - var deferDataKey = type + "defer", - queueDataKey = type + "queue", - markDataKey = type + "mark", - defer = jQuery._data( elem, deferDataKey ); - if ( defer && - ( src === "queue" || !jQuery._data(elem, queueDataKey) ) && - ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) { - // Give room for hard-coded callbacks to fire first - // and eventually mark/queue something else on the element - setTimeout( function() { - if ( !jQuery._data( elem, queueDataKey ) && - !jQuery._data( elem, markDataKey ) ) { - jQuery.removeData( elem, deferDataKey, true ); - defer.fire(); - } - }, 0 ); - } -} - jQuery.extend({ - - _mark: function( elem, type ) { - if ( elem ) { - type = ( type || "fx" ) + "mark"; - jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 ); - } - }, - - _unmark: function( force, elem, type ) { - if ( force !== true ) { - type = elem; - elem = force; - force = false; - } - if ( elem ) { - type = type || "fx"; - var key = type + "mark", - count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 ); - if ( count ) { - jQuery._data( elem, key, count ); - } else { - jQuery.removeData( elem, key, true ); - handleQueueMarkDefer( elem, type, "mark" ); - } - } - }, - queue: function( elem, type, data ) { - var q; + var queue; + if ( elem ) { type = ( type || "fx" ) + "queue"; - q = jQuery._data( elem, type ); + queue = jQuery._data( elem, type ); // Speed up dequeue by getting out quickly if this is just a lookup if ( data ) { - if ( !q || jQuery.isArray(data) ) { - q = jQuery._data( elem, type, jQuery.makeArray(data) ); + if ( !queue || jQuery.isArray(data) ) { + queue = jQuery._data( elem, type, jQuery.makeArray(data) ); } else { - q.push( data ); + queue.push( data ); } } - return q || []; + return queue || []; } }, @@ -2047,51 +1909,76 @@ jQuery.extend({ type = type || "fx"; var queue = jQuery.queue( elem, type ), + startLength = queue.length, fn = queue.shift(), - hooks = {}; + 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--; } + hooks.cur = fn; if ( fn ) { + // Add a progress sentinel to prevent the fx queue from being // automatically dequeued if ( type === "fx" ) { queue.unshift( "inprogress" ); } - jQuery._data( elem, type + ".run", hooks ); - fn.call( elem, function() { - jQuery.dequeue( elem, type ); - }, hooks ); + // clear up the last queue stop function + delete hooks.stop; + fn.call( elem, next, hooks ); } - if ( !queue.length ) { - jQuery.removeData( elem, type + "queue " + type + ".run", true ); - handleQueueMarkDefer( elem, type, "queue" ); + 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 ( data === undefined ) { + if ( arguments.length < setter ) { return jQuery.queue( this[0], type ); } - return this.each(function() { - var queue = jQuery.queue( this, type, data ); - if ( type === "fx" && queue[0] !== "inprogress" ) { - jQuery.dequeue( this, type ); - } - }); + 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() { @@ -2116,55 +2003,48 @@ jQuery.fn.extend({ }, // Get a promise resolved when queues of a certain type // are emptied (fx is the type by default) - promise: function( type, object ) { + 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" ) { - object = type; + obj = type; type = undefined; } type = type || "fx"; - var defer = jQuery.Deferred(), - elements = this, - i = elements.length, - count = 1, - deferDataKey = type + "defer", - queueDataKey = type + "queue", - markDataKey = type + "mark", - tmp; - function resolve() { - if ( !( --count ) ) { - defer.resolveWith( elements, [ elements ] ); - } - } + while( i-- ) { - if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) || - ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) || - jQuery.data( elements[ i ], markDataKey, undefined, true ) ) && - jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) { + tmp = jQuery._data( elements[ i ], type + "queueHooks" ); + if ( tmp && tmp.empty ) { count++; - tmp.add( resolve ); + tmp.empty.add( resolve ); } } resolve(); - return defer.promise(); + return defer.promise( obj ); } }); - - - - -var rclass = /[\n\t\r]/g, - rspace = /\s+/, +var nodeHook, boolHook, + rclass = /[\t\r\n]/g, rreturn = /\r/g, - rtype = /^(?:button|input)$/i, - rfocusable = /^(?:button|input|object|select|textarea)$/i, - rclickable = /^a(?:rea)?$/i, - rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, + rfocusable = /^(?:input|select|textarea|button|object)$/i, + rclickable = /^(?:a|area)$/i, + rboolean = /^(?:checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i, + ruseDefault = /^(?:checked|selected)$/i, getSetAttribute = jQuery.support.getSetAttribute, - nodeHook, boolHook, fixSpecified; + getSetInput = jQuery.support.input; jQuery.fn.extend({ attr: function( name, value ) { - return jQuery.access( this, name, value, true, jQuery.attr ); + return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 ); }, removeAttr: function( name ) { @@ -2174,7 +2054,7 @@ jQuery.fn.extend({ }, prop: function( name, value ) { - return jQuery.access( this, name, value, true, jQuery.prop ); + return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 ); }, removeProp: function( name ) { @@ -2189,35 +2069,37 @@ jQuery.fn.extend({ }, addClass: function( value ) { - var classNames, i, l, elem, - setClass, c, cl; + var classes, elem, cur, clazz, j, + i = 0, + len = this.length, + proceed = typeof value === "string" && value; if ( jQuery.isFunction( value ) ) { return this.each(function( j ) { - jQuery( this ).addClass( value.call(this, j, this.className) ); + jQuery( this ).addClass( value.call( this, j, this.className ) ); }); } - if ( value && typeof value === "string" ) { - classNames = value.split( rspace ); + if ( proceed ) { + // The disjunction here is for better compressibility (see removeClass) + classes = ( value || "" ).match( core_rnotwhite ) || []; - for ( i = 0, l = this.length; i < l; i++ ) { + for ( ; i < len; i++ ) { elem = this[ i ]; + cur = elem.nodeType === 1 && ( elem.className ? + ( " " + elem.className + " " ).replace( rclass, " " ) : + " " + ); - if ( elem.nodeType === 1 ) { - if ( !elem.className && classNames.length === 1 ) { - elem.className = value; - - } else { - setClass = " " + elem.className + " "; - - for ( c = 0, cl = classNames.length; c < cl; c++ ) { - if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) { - setClass += classNames[ c ] + " "; - } + if ( cur ) { + j = 0; + while ( (clazz = classes[j++]) ) { + if ( cur.indexOf( " " + clazz + " " ) < 0 ) { + cur += clazz + " "; } - elem.className = jQuery.trim( setClass ); } + elem.className = jQuery.trim( cur ); + } } } @@ -2226,31 +2108,36 @@ jQuery.fn.extend({ }, removeClass: function( value ) { - var classNames, i, l, elem, className, c, cl; + var classes, elem, cur, clazz, j, + i = 0, + len = this.length, + proceed = arguments.length === 0 || typeof value === "string" && value; if ( jQuery.isFunction( value ) ) { return this.each(function( j ) { - jQuery( this ).removeClass( value.call(this, j, this.className) ); + jQuery( this ).removeClass( value.call( this, j, this.className ) ); }); } + if ( proceed ) { + classes = ( value || "" ).match( core_rnotwhite ) || []; - if ( (value && typeof value === "string") || value === undefined ) { - classNames = ( value || "" ).split( rspace ); - - for ( i = 0, l = this.length; i < l; i++ ) { + for ( ; i < len; i++ ) { elem = this[ i ]; + // This expression is here for better compressibility (see addClass) + cur = elem.nodeType === 1 && ( elem.className ? + ( " " + elem.className + " " ).replace( rclass, " " ) : + "" + ); - if ( elem.nodeType === 1 && elem.className ) { - if ( value ) { - className = (" " + elem.className + " ").replace( rclass, " " ); - for ( c = 0, cl = classNames.length; c < cl; c++ ) { - className = className.replace(" " + classNames[ c ] + " ", " "); + if ( cur ) { + j = 0; + while ( (clazz = classes[j++]) ) { + // Remove *all* instances + while ( cur.indexOf( " " + clazz + " " ) >= 0 ) { + cur = cur.replace( " " + clazz + " ", " " ); } - elem.className = jQuery.trim( className ); - - } else { - elem.className = ""; } + elem.className = value ? jQuery.trim( cur ) : ""; } } } @@ -2275,21 +2162,25 @@ jQuery.fn.extend({ i = 0, self = jQuery( this ), state = stateVal, - classNames = value.split( rspace ); + classNames = value.match( core_rnotwhite ) || []; while ( (className = classNames[ i++ ]) ) { - // check each className given, space seperated list + // check each className given, space separated list state = isBool ? state : !self.hasClass( className ); self[ state ? "addClass" : "removeClass" ]( className ); } - } else if ( type === "undefined" || type === "boolean" ) { + // Toggle whole class name + } else if ( type === core_strundefined || type === "boolean" ) { if ( this.className ) { // store className if set jQuery._data( this, "__className__", this.className ); } - // toggle whole className + // If the element has a class name or if we're passed "false", + // then remove the whole classname (if there was one, the above saved it). + // Otherwise bring back whatever was previously saved (if anything), + // falling back to the empty string if nothing was stored. this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; } }); @@ -2300,7 +2191,7 @@ jQuery.fn.extend({ i = 0, l = this.length; for ( ; i < l; i++ ) { - if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { + if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) { return true; } } @@ -2309,12 +2200,12 @@ jQuery.fn.extend({ }, val: function( value ) { - var hooks, ret, isFunction, + var ret, hooks, isFunction, elem = this[0]; if ( !arguments.length ) { if ( elem ) { - hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ]; + hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { return ret; @@ -2335,7 +2226,8 @@ jQuery.fn.extend({ isFunction = jQuery.isFunction( value ); return this.each(function( i ) { - var self = jQuery(this), val; + var val, + self = jQuery(this); if ( this.nodeType !== 1 ) { return; @@ -2358,7 +2250,7 @@ jQuery.fn.extend({ }); } - hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ]; + hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; // If set returns undefined, fall back to normal setting if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { @@ -2380,26 +2272,25 @@ jQuery.extend({ }, select: { get: function( elem ) { - var value, i, max, option, - index = elem.selectedIndex, - values = [], + var value, option, options = elem.options, - one = elem.type === "select-one"; - - // Nothing was selected - if ( index < 0 ) { - return null; - } + index = elem.selectedIndex, + one = elem.type === "select-one" || index < 0, + values = one ? null : [], + max = one ? index + 1 : options.length, + i = index < 0 ? + max : + one ? index : 0; // Loop through all the selected options - i = one ? index : 0; - max = one ? index + 1 : options.length; for ( ; i < max; i++ ) { option = options[ i ]; - // Don't return options that are disabled or in a disabled optgroup - if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && - (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { + // oldIE doesn't update selected after form reset (#2551) + if ( ( option.selected || i === index ) && + // Don't return options that are disabled or in a disabled optgroup + ( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) && + ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { // Get the specific value for the option value = jQuery( option ).val(); @@ -2414,11 +2305,6 @@ jQuery.extend({ } } - // Fixes Bug #2551 -- select.val() broken in IE after form.reset() - if ( one && !values.length && options.length ) { - return jQuery( options[ index ] ).val(); - } - return values; }, @@ -2437,19 +2323,8 @@ jQuery.extend({ } }, - attrFn: { - val: true, - css: true, - html: true, - text: true, - data: true, - width: true, - height: true, - offset: true - }, - - attr: function( elem, name, value, pass ) { - var ret, hooks, notxml, + attr: function( elem, name, value ) { + var hooks, notxml, ret, nType = elem.nodeType; // don't get/set attributes on text, comment and attribute nodes @@ -2457,12 +2332,8 @@ jQuery.extend({ return; } - if ( pass && name in jQuery.attrFn ) { - return jQuery( elem )[ name ]( value ); - } - // Fallback to prop when attributes are not supported - if ( typeof elem.getAttribute === "undefined" ) { + if ( typeof elem.getAttribute === core_strundefined ) { return jQuery.prop( elem, name, value ); } @@ -2479,53 +2350,59 @@ jQuery.extend({ if ( value === null ) { jQuery.removeAttr( elem, name ); - return; - } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { + } else if ( hooks && notxml && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { return ret; } else { - elem.setAttribute( name, "" + value ); + elem.setAttribute( name, value + "" ); return value; } - } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) { + } else if ( hooks && notxml && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { return ret; } else { - ret = elem.getAttribute( name ); + // In IE9+, Flash objects don't have .getAttribute (#12945) + // Support: IE9+ + if ( typeof elem.getAttribute !== core_strundefined ) { + ret = elem.getAttribute( name ); + } // Non-existent attributes return null, we normalize to undefined - return ret === null ? + return ret == null ? undefined : ret; } }, removeAttr: function( elem, value ) { - var propName, attrNames, name, l, - i = 0; - - if ( value && elem.nodeType === 1 ) { - attrNames = value.toLowerCase().split( rspace ); - l = attrNames.length; - - for ( ; i < l; i++ ) { - name = attrNames[ i ]; - - if ( name ) { - propName = jQuery.propFix[ name ] || name; + var name, propName, + i = 0, + attrNames = value && value.match( core_rnotwhite ); - // See #9699 for explanation of this approach (setting first, then removal) - jQuery.attr( elem, name, "" ); - elem.removeAttribute( getSetAttribute ? name : propName ); + if ( attrNames && elem.nodeType === 1 ) { + while ( (name = attrNames[i++]) ) { + propName = jQuery.propFix[ name ] || name; + // Boolean attributes get special treatment (#10870) + if ( rboolean.test( name ) ) { // Set corresponding property to false for boolean attributes - if ( rboolean.test( name ) && propName in elem ) { + // Also clear defaultChecked/defaultSelected (if appropriate) for IE<8 + if ( !getSetAttribute && ruseDefault.test( name ) ) { + elem[ jQuery.camelCase( "default-" + name ) ] = + elem[ propName ] = false; + } else { elem[ propName ] = false; } + + // See #9699 for explanation of this approach (setting first, then removal) + } else { + jQuery.attr( elem, name, "" ); } + + elem.removeAttribute( getSetAttribute ? name : propName ); } } }, @@ -2533,13 +2410,9 @@ jQuery.extend({ attrHooks: { type: { set: function( elem, value ) { - // We can't allow the type property to be changed (since it causes problems in IE) - if ( rtype.test( elem.nodeName ) && elem.parentNode ) { - jQuery.error( "type property can't be changed" ); - } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { + if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { // Setting the type on a radio button after the value resets the value in IE6-9 - // Reset value to it's default in case type is set after value - // This is for element creation + // Reset value to default in case type is set after value during creation var val = elem.value; elem.setAttribute( "type", value ); if ( val ) { @@ -2548,25 +2421,6 @@ jQuery.extend({ return value; } } - }, - // Use the value property for back compat - // Use the nodeHook for button elements in IE6/7 (#1954) - value: { - get: function( elem, name ) { - if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { - return nodeHook.get( elem, name ); - } - return name in elem ? - elem.value : - null; - }, - set: function( elem, value, name ) { - if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { - return nodeHook.set( elem, value, name ); - } - // Does not return so that setAttribute is also used - elem.value = value; - } } }, @@ -2637,71 +2491,111 @@ jQuery.extend({ } }); -// Add the tabIndex propHook to attrHooks for back-compat (different case is intentional) -jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex; - // Hook for boolean attributes boolHook = { get: function( elem, name ) { - // Align boolean attributes with corresponding properties - // Fall back to attribute presence where some booleans are not supported - var attrNode, - property = jQuery.prop( elem, name ); - return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? + var + // Use .prop to determine if this attribute is understood as boolean + prop = jQuery.prop( elem, name ), + + // Fetch it accordingly + attr = typeof prop === "boolean" && elem.getAttribute( name ), + detail = typeof prop === "boolean" ? + + getSetInput && getSetAttribute ? + attr != null : + // oldIE fabricates an empty string for missing boolean attributes + // and conflates checked/selected into attroperties + ruseDefault.test( name ) ? + elem[ jQuery.camelCase( "default-" + name ) ] : + !!attr : + + // fetch an attribute node for properties not recognized as boolean + elem.getAttributeNode( name ); + + return detail && detail.value !== false ? name.toLowerCase() : undefined; }, set: function( elem, value, name ) { - var propName; if ( value === false ) { // Remove boolean attributes when set to false jQuery.removeAttr( elem, name ); - } else { - // value is true since we know at this point it's type boolean and not false - // Set boolean attributes to the same name and set the DOM property - propName = jQuery.propFix[ name ] || name; - if ( propName in elem ) { - // Only set the IDL specifically if it already exists on the element - elem[ propName ] = true; - } + } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) { + // IE<8 needs the *property* name + elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name ); - elem.setAttribute( name, name.toLowerCase() ); + // Use defaultChecked and defaultSelected for oldIE + } else { + elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true; } + return name; } }; -// IE6/7 do not support getting/setting some attributes with get/setAttribute -if ( !getSetAttribute ) { +// fix oldIE value attroperty +if ( !getSetInput || !getSetAttribute ) { + jQuery.attrHooks.value = { + get: function( elem, name ) { + var ret = elem.getAttributeNode( name ); + return jQuery.nodeName( elem, "input" ) ? + + // Ignore the value *property* by using defaultValue + elem.defaultValue : - fixSpecified = { - name: true, - id: true + ret && ret.specified ? ret.value : undefined; + }, + set: function( elem, value, name ) { + if ( jQuery.nodeName( elem, "input" ) ) { + // Does not return so that setAttribute is also used + elem.defaultValue = value; + } else { + // Use nodeHook if defined (#1954); otherwise setAttribute is fine + return nodeHook && nodeHook.set( elem, value, name ); + } + } }; +} + +// IE6/7 do not support getting/setting some attributes with get/setAttribute +if ( !getSetAttribute ) { // Use this for any attribute in IE6/7 // This fixes almost every IE6/7 issue nodeHook = jQuery.valHooks.button = { get: function( elem, name ) { - var ret; - ret = elem.getAttributeNode( name ); - return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ? - ret.nodeValue : + var ret = elem.getAttributeNode( name ); + return ret && ( name === "id" || name === "name" || name === "coords" ? ret.value !== "" : ret.specified ) ? + ret.value : undefined; }, set: function( elem, value, name ) { // Set the existing or create a new attribute node var ret = elem.getAttributeNode( name ); if ( !ret ) { - ret = document.createAttribute( name ); - elem.setAttributeNode( ret ); + elem.setAttributeNode( + (ret = elem.ownerDocument.createAttribute( name )) + ); } - return ( ret.nodeValue = value + "" ); + + ret.value = value += ""; + + // Break association with cloned elements by also using setAttribute (#9646) + return name === "value" || value === elem.getAttribute( name ) ? + value : + undefined; } }; - // Apply the nodeHook to tabindex - jQuery.attrHooks.tabindex.set = nodeHook.set; + // Set contenteditable to false on removals(#10429) + // Setting to empty string throws an error as an invalid value + jQuery.attrHooks.contenteditable = { + get: nodeHook.get, + set: function( elem, value, name ) { + nodeHook.set( elem, value === "" ? false : value, name ); + } + }; // Set width and height to auto instead of 0 on empty string( Bug #8150 ) // This is for removals @@ -2715,42 +2609,41 @@ if ( !getSetAttribute ) { } }); }); - - // Set contenteditable to false on removals(#10429) - // Setting to empty string throws an error as an invalid value - jQuery.attrHooks.contenteditable = { - get: nodeHook.get, - set: function( elem, value, name ) { - if ( value === "" ) { - value = "false"; - } - nodeHook.set( elem, value, name ); - } - }; } // Some attributes require a special call on IE +// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx if ( !jQuery.support.hrefNormalized ) { jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { get: function( elem ) { var ret = elem.getAttribute( name, 2 ); - return ret === null ? undefined : ret; + return ret == null ? undefined : ret; } }); }); + + // href/src property should get the full normalized URL (#10299/#12915) + jQuery.each([ "href", "src" ], function( i, name ) { + jQuery.propHooks[ name ] = { + get: function( elem ) { + return elem.getAttribute( name, 4 ); + } + }; + }); } if ( !jQuery.support.style ) { jQuery.attrHooks.style = { get: function( elem ) { // Return undefined in the case of empty string - // Normalize to lowercase since IE uppercases css property names - return elem.style.cssText.toLowerCase() || undefined; + // Note: IE uppercases css property names, but if we were to .toLowerCase() + // .cssText, that would destroy case senstitivity in URL's, like in "background" + return elem.style.cssText || undefined; }, set: function( elem, value ) { - return ( elem.style.cssText = "" + value ); + return ( elem.style.cssText = value + "" ); } }; } @@ -2800,38 +2693,19 @@ jQuery.each([ "radio", "checkbox" ], function() { } }); }); - - - - -var rformElems = /^(?:textarea|input|select)$/i, - rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/, - rhoverHack = /\bhover(\.\S+)?\b/, +var rformElems = /^(?:input|select|textarea)$/i, rkeyEvent = /^key/, rmouseEvent = /^(?:mouse|contextmenu)|click/, rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, - rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/, - quickParse = function( selector ) { - var quick = rquickIs.exec( selector ); - if ( quick ) { - // 0 1 2 3 - // [ _, tag, id, class ] - quick[1] = ( quick[1] || "" ).toLowerCase(); - quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" ); - } - return quick; - }, - quickIs = function( elem, m ) { - var attrs = elem.attributes || {}; - return ( - (!m[1] || elem.nodeName.toLowerCase() === m[1]) && - (!m[2] || (attrs.id || {}).value === m[2]) && - (!m[3] || m[3].test( (attrs[ "class" ] || {}).value )) - ); - }, - hoverHack = function( events ) { - return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); - }; + rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; + +function returnTrue() { + return true; +} + +function returnFalse() { + return false; +} /* * Helper functions for managing events -- not part of the public interface. @@ -2839,14 +2713,16 @@ var rformElems = /^(?:textarea|input|select)$/i, */ jQuery.event = { - add: function( elem, types, handler, data, selector ) { + global: {}, - var elemData, eventHandle, events, - t, tns, type, namespaces, handleObj, - handleObjIn, quick, handlers, special; + 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 (allow plain objects tho) - if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) { + // Don't attach events to noData or text/comment nodes (but allow plain objects) + if ( !elemData ) { return; } @@ -2854,6 +2730,7 @@ jQuery.event = { 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 @@ -2862,16 +2739,14 @@ jQuery.event = { } // Init the element's event structure and main handler, if this is the first - events = elemData.events; - if ( !events ) { - elemData.events = events = {}; + if ( !(events = elemData.events) ) { + events = elemData.events = {}; } - eventHandle = elemData.handle; - if ( !eventHandle ) { - elemData.handle = eventHandle = function( e ) { + 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 !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? + return typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ? jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : undefined; }; @@ -2881,12 +2756,12 @@ jQuery.event = { // Handle multiple events separated by a space // jQuery(...).bind("mouseover mouseout", fn); - types = jQuery.trim( hoverHack(types) ).split( " " ); - for ( t = 0; t < types.length; t++ ) { - - tns = rtypenamespace.exec( types[t] ) || []; - type = tns[1]; - namespaces = ( tns[2] || "" ).split( "." ).sort(); + types = ( types || "" ).match( core_rnotwhite ) || [""]; + t = types.length; + while ( t-- ) { + tmp = rtypenamespace.exec( types[t] ) || []; + type = origType = tmp[1]; + namespaces = ( tmp[2] || "" ).split( "." ).sort(); // If event changes its type, use the special event handlers for the changed type special = jQuery.event.special[ type ] || {}; @@ -2900,18 +2775,17 @@ jQuery.event = { // handleObj is passed to all event handlers handleObj = jQuery.extend({ type: type, - origType: tns[1], + origType: origType, data: data, handler: handler, guid: handler.guid, selector: selector, - quick: quickParse( selector ), + needsContext: selector && jQuery.expr.match.needsContext.test( selector ), namespace: namespaces.join(".") }, handleObjIn ); // Init the event handler queue if we're the first - handlers = events[ type ]; - if ( !handlers ) { + if ( !(handlers = events[ type ]) ) { handlers = events[ type ] = []; handlers.delegateCount = 0; @@ -2950,25 +2824,25 @@ jQuery.event = { elem = null; }, - global: {}, - // Detach an event or set of events from an element remove: function( elem, types, handler, selector, mappedTypes ) { - - var elemData = jQuery.hasData( elem ) && jQuery._data( elem ), - t, tns, type, origType, namespaces, origCount, - j, events, special, handle, eventType, handleObj; + 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 = jQuery.trim( hoverHack( types || "" ) ).split(" "); - for ( t = 0; t < types.length; t++ ) { - tns = rtypenamespace.exec( types[t] ) || []; - type = origType = tns[1]; - namespaces = tns[2]; + types = ( types || "" ).match( core_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 ) { @@ -2979,23 +2853,23 @@ jQuery.event = { } special = jQuery.event.special[ type ] || {}; - type = ( selector? special.delegateType : special.bindType ) || type; - eventType = events[ type ] || []; - origCount = eventType.length; - namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null; + type = ( selector ? special.delegateType : special.bindType ) || type; + handlers = events[ type ] || []; + tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ); // Remove matching events - for ( j = 0; j < eventType.length; j++ ) { - handleObj = eventType[ j ]; + origCount = j = handlers.length; + while ( j-- ) { + handleObj = handlers[ j ]; if ( ( mappedTypes || origType === handleObj.origType ) && - ( !handler || handler.guid === handleObj.guid ) && - ( !namespaces || namespaces.test( handleObj.namespace ) ) && - ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { - eventType.splice( j--, 1 ); + ( !handler || handler.guid === handleObj.guid ) && + ( !tmp || tmp.test( handleObj.namespace ) ) && + ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { + handlers.splice( j, 1 ); if ( handleObj.selector ) { - eventType.delegateCount--; + handlers.delegateCount--; } if ( special.remove ) { special.remove.call( elem, handleObj ); @@ -3005,8 +2879,8 @@ jQuery.event = { // 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 ( eventType.length === 0 && origCount !== eventType.length ) { - if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { + if ( origCount && !handlers.length ) { + if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { jQuery.removeEvent( elem, type, elemData.handle ); } @@ -3016,87 +2890,51 @@ jQuery.event = { // Remove the expando if it's no longer used if ( jQuery.isEmptyObject( events ) ) { - handle = elemData.handle; - if ( handle ) { - handle.elem = null; - } + delete elemData.handle; // removeData also checks for emptiness and clears the expando if empty // so use it instead of delete - jQuery.removeData( elem, [ "events", "handle" ], true ); + jQuery._removeData( elem, "events" ); } }, - // Events that are safe to short-circuit if no handlers are attached. - // Native DOM events should not be added, they may have inline handlers. - customEvent: { - "getData": true, - "setData": true, - "changeData": true - }, - trigger: function( event, data, elem, onlyHandlers ) { + var handle, ontype, cur, + bubbleType, special, tmp, i, + eventPath = [ elem || document ], + type = core_hasOwn.call( event, "type" ) ? event.type : event, + namespaces = core_hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : []; + + cur = tmp = elem = elem || document; + // Don't do events on text and comment nodes - if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) { + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { return; } - // Event object or event type - var type = event.type || event, - namespaces = [], - cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType; - // 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 ) { - // Exclusive events trigger only for the exact event (no namespaces) - type = type.slice(0, -1); - exclusive = true; - } - - if ( type.indexOf( "." ) >= 0 ) { + 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; - if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) { - // No jQuery handlers for this event type, and it can't have inline handlers - return; - } + // Caller can pass in a jQuery.Event object, Object, or just an event type string + event = event[ jQuery.expando ] ? + event : + new jQuery.Event( type, typeof event === "object" && event ); - // Caller can pass in an Event, Object, or just an event type string - event = typeof event === "object" ? - // jQuery.Event object - event[ jQuery.expando ] ? event : - // Object literal - new jQuery.Event( type, event ) : - // Just the event type (string) - new jQuery.Event( type ); - - event.type = type; event.isTrigger = true; - event.exclusive = exclusive; - event.namespace = namespaces.join( "." ); - event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null; - ontype = type.indexOf( ":" ) < 0 ? "on" + type : ""; - - // Handle a global trigger - if ( !elem ) { - - // TODO: Stop taunting the data cache; remove global events and always attach to document - cache = jQuery.cache; - for ( i in cache ) { - if ( cache[ i ].events && cache[ i ].events[ type ] ) { - jQuery.event.trigger( event, data, cache[ i ].handle.elem, true ); - } - } - return; - } + 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; @@ -3105,47 +2943,52 @@ jQuery.event = { } // Clone any incoming data and prepend the event, creating the handler arg list - data = data != null ? jQuery.makeArray( data ) : []; - data.unshift( event ); + data = data == null ? + [ event ] : + jQuery.makeArray( data, [ event ] ); // Allow special events to draw outside the lines special = jQuery.event.special[ type ] || {}; - if ( special.trigger && special.trigger.apply( elem, data ) === false ) { + 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) - eventPath = [[ elem, special.bindType || type ]]; if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { bubbleType = special.delegateType || type; - cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode; - old = null; + if ( !rfocusMorph.test( bubbleType + type ) ) { + cur = cur.parentNode; + } for ( ; cur; cur = cur.parentNode ) { - eventPath.push([ cur, bubbleType ]); - old = cur; + eventPath.push( cur ); + tmp = cur; } // Only add window if we got to document (e.g., not plain obj or detached DOM) - if ( old && old === elem.ownerDocument ) { - eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]); + if ( tmp === (elem.ownerDocument || document) ) { + eventPath.push( tmp.defaultView || tmp.parentWindow || window ); } } // Fire handlers on the event path - for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) { + i = 0; + while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) { - cur = eventPath[i][0]; - event.type = eventPath[i][1]; + 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 ); } - // Note that this is a bare JS function and not a jQuery handler + + // Native handler handle = ontype && cur[ ontype ]; - if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) { + if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) { event.preventDefault(); } } @@ -3160,23 +3003,27 @@ jQuery.event = { // 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) - // IE<9 dies on focus/blur to hidden element (#1486) - if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) { + if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) { // Don't re-trigger an onFOO event when we call its FOO() method - old = elem[ ontype ]; + tmp = elem[ ontype ]; - if ( old ) { + if ( tmp ) { elem[ ontype ] = null; } // Prevent re-triggering of the same event, since we already bubbled it above jQuery.event.triggered = type; - elem[ 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 ( old ) { - elem[ ontype ] = old; + if ( tmp ) { + elem[ ontype ] = tmp; } } } @@ -3188,76 +3035,46 @@ jQuery.event = { dispatch: function( event ) { // Make a writable jQuery.Event from the native event object - event = jQuery.event.fix( event || window.event ); + event = jQuery.event.fix( event ); - var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []), - delegateCount = handlers.delegateCount, - args = [].slice.call( arguments, 0 ), - run_all = !event.exclusive && !event.namespace, + var i, ret, handleObj, matched, j, handlerQueue = [], - i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related; + args = core_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; - // Determine handlers that should run if there are delegated events - // Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861) - if ( delegateCount && !event.target.disabled && !(event.button && event.type === "click") ) { - - // Pregenerate a single jQuery object for reuse with .is() - jqcur = jQuery(this); - jqcur.context = this.ownerDocument || this; - - for ( cur = event.target; cur != this; cur = cur.parentNode || this ) { - selMatch = {}; - matches = []; - jqcur[0] = cur; - for ( i = 0; i < delegateCount; i++ ) { - handleObj = handlers[ i ]; - sel = handleObj.selector; - - if ( selMatch[ sel ] === undefined ) { - selMatch[ sel ] = ( - handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel ) - ); - } - if ( selMatch[ sel ] ) { - matches.push( handleObj ); - } - } - if ( matches.length ) { - handlerQueue.push({ elem: cur, matches: matches }); - } - } + // Call the preDispatch hook for the mapped type, and let it bail if desired + if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { + return; } - // Add the remaining (directly-bound) handlers - if ( handlers.length > delegateCount ) { - handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) }); - } + // Determine handlers + handlerQueue = jQuery.event.handlers.call( this, event, handlers ); // Run delegates first; they may want to stop propagation beneath us - for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) { - matched = handlerQueue[ i ]; + i = 0; + while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) { event.currentTarget = matched.elem; - for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) { - handleObj = matched.matches[ j ]; + j = 0; + while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) { - // Triggered event must either 1) be non-exclusive and have no namespace, or + // 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 ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) { + if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) { - event.data = handleObj.data; event.handleObj = handleObj; + event.data = handleObj.data; ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) .apply( matched.elem, args ); if ( ret !== undefined ) { - event.result = ret; - if ( ret === false ) { + if ( (event.result = ret) === false ) { event.preventDefault(); event.stopPropagation(); } @@ -3266,12 +3083,109 @@ jQuery.event = { } } + // 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 <use> instance trees (#13180) + // Avoid non-left-click bubbling in Firefox (#3861) + if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) { + + for ( ; cur != this; cur = cur.parentNode || this ) { + + // 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 - // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 *** - props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), + props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), fixHooks: {}, @@ -3291,7 +3205,7 @@ jQuery.event = { mouseHooks: { props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), filter: function( event, original ) { - var eventDoc, doc, body, + var body, eventDoc, doc, button = original.button, fromElement = original.fromElement; @@ -3320,71 +3234,52 @@ jQuery.event = { } }, - fix: function( event ) { - if ( event[ jQuery.expando ] ) { - return event; - } - - // Create a writable copy of the event object and normalize some properties - var i, prop, - originalEvent = event, - fixHook = jQuery.event.fixHooks[ event.type ] || {}, - copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; - - event = jQuery.Event( originalEvent ); - - for ( i = copy.length; i; ) { - prop = copy[ --i ]; - event[ prop ] = originalEvent[ prop ]; - } - - // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2) - if ( !event.target ) { - event.target = originalEvent.srcElement || document; - } - - // Target should not be a text node (#504, Safari) - if ( event.target.nodeType === 3 ) { - event.target = event.target.parentNode; - } - - // For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8) - if ( event.metaKey === undefined ) { - event.metaKey = event.ctrlKey; - } - - return fixHook.filter? fixHook.filter( event, originalEvent ) : event; - }, - special: { - ready: { - // Make sure the ready event is setup - setup: jQuery.bindReady - }, - load: { // Prevent triggered image.load events from bubbling to window.load noBubble: true }, - + 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; + } + } + }, focus: { + // Fire native event if possible so blur/focus sequence is correct + trigger: function() { + if ( this !== document.activeElement && 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 === document.activeElement && this.blur ) { + this.blur(); + return false; + } + }, delegateType: "focusout" }, beforeunload: { - setup: function( data, namespaces, eventHandle ) { - // We only want to do this special case on windows - if ( jQuery.isWindow( this ) ) { - this.onbeforeunload = eventHandle; - } - }, + postDispatch: function( event ) { - teardown: function( namespaces, eventHandle ) { - if ( this.onbeforeunload === eventHandle ) { - this.onbeforeunload = null; + // Even when returnValue equals to undefined Firefox will still show alert + if ( event.result !== undefined ) { + event.originalEvent.returnValue = event.result; } } } @@ -3413,10 +3308,6 @@ jQuery.event = { } }; -// Some plugins are using, but it's undocumented/deprecated and will be removed. -// The 1.7 special event interface should provide all the hooks needed now. -jQuery.event.handle = jQuery.event.dispatch; - jQuery.removeEvent = document.removeEventListener ? function( elem, type, handle ) { if ( elem.removeEventListener ) { @@ -3424,8 +3315,17 @@ jQuery.removeEvent = document.removeEventListener ? } } : function( elem, type, handle ) { + var name = "on" + type; + if ( elem.detachEvent ) { - elem.detachEvent( "on" + type, handle ); + + // #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 ] === core_strundefined ) { + elem[ name ] = null; + } + + elem.detachEvent( name, handle ); } }; @@ -3462,54 +3362,51 @@ jQuery.Event = function( src, props ) { this[ jQuery.expando ] = true; }; -function returnFalse() { - return false; -} -function returnTrue() { - return true; -} - // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html jQuery.Event.prototype = { - preventDefault: function() { - this.isDefaultPrevented = returnTrue; + 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 preventDefault exists, run it on the original event if ( e.preventDefault ) { e.preventDefault(); - // otherwise set the returnValue property of the original event to false (IE) + // Support: IE + // Otherwise set the returnValue property of the original event to false } else { e.returnValue = false; } }, stopPropagation: function() { - this.isPropagationStopped = returnTrue; - var e = this.originalEvent; + + this.isPropagationStopped = returnTrue; if ( !e ) { return; } - // if stopPropagation exists run it on the original event + // If stopPropagation exists, run it on the original event if ( e.stopPropagation ) { e.stopPropagation(); } - // otherwise set the cancelBubble property of the original event to true (IE) + + // Support: IE + // Set the cancelBubble property of the original event to true e.cancelBubble = true; }, stopImmediatePropagation: function() { this.isImmediatePropagationStopped = returnTrue; this.stopPropagation(); - }, - isDefaultPrevented: returnFalse, - isPropagationStopped: returnFalse, - isImmediatePropagationStopped: returnFalse + } }; // Create mouseenter/leave events using mouseover/out and event-time checks @@ -3522,11 +3419,10 @@ jQuery.each({ bindType: fix, handle: function( event ) { - var target = this, + var ret, + target = this, related = event.relatedTarget, - handleObj = event.handleObj, - selector = handleObj.selector, - ret; + 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 @@ -3555,19 +3451,26 @@ if ( !jQuery.support.submitBubbles ) { // 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 && !form._submit_attached ) { + if ( form && !jQuery._data( form, "submitBubbles" ) ) { jQuery.event.add( form, "submit._submit", function( event ) { - // If form was submitted by the user, bubble the event up the tree - if ( this.parentNode && !event.isTrigger ) { - jQuery.event.simulate( "submit", this.parentNode, event, true ); - } + event._submit_bubble = true; }); - form._submit_attached = 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" ) ) { @@ -3600,8 +3503,9 @@ if ( !jQuery.support.changeBubbles ) { jQuery.event.add( this, "click._change", function( event ) { if ( this._just_changed && !event.isTrigger ) { this._just_changed = false; - jQuery.event.simulate( "change", this, event, true ); } + // Allow triggered, simulated change events (#11500) + jQuery.event.simulate( "change", this, event, true ); }); } return false; @@ -3610,13 +3514,13 @@ if ( !jQuery.support.changeBubbles ) { jQuery.event.add( this, "beforeactivate._change", function( e ) { var elem = e.target; - if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) { + 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 ); } }); - elem._change_attached = true; + jQuery._data( elem, "changeBubbles", true ); } }); }, @@ -3633,7 +3537,7 @@ if ( !jQuery.support.changeBubbles ) { teardown: function() { jQuery.event.remove( this, "._change" ); - return rformElems.test( this.nodeName ); + return !rformElems.test( this.nodeName ); } }; } @@ -3666,14 +3570,14 @@ if ( !jQuery.support.focusinBubbles ) { jQuery.fn.extend({ on: function( types, selector, data, fn, /*INTERNAL*/ one ) { - var origFn, type; + 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 = selector; + data = data || selector; selector = undefined; } for ( type in types ) { @@ -3719,14 +3623,15 @@ jQuery.fn.extend({ }); }, one: function( types, selector, data, fn ) { - return this.on.call( this, types, selector, data, fn, 1 ); + 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 - var handleObj = types.handleObj; + handleObj = types.handleObj; jQuery( types.delegateTarget ).off( - handleObj.namespace? handleObj.type + "." + handleObj.namespace : handleObj.type, + handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, handleObj.selector, handleObj.handler ); @@ -3734,7 +3639,7 @@ jQuery.fn.extend({ } if ( typeof types === "object" ) { // ( types-object [, selector] ) - for ( var type in types ) { + for ( type in types ) { this.off( type, selector, types[ type ] ); } return this; @@ -3759,21 +3664,12 @@ jQuery.fn.extend({ return this.off( types, null, fn ); }, - live: function( types, data, fn ) { - jQuery( this.context ).on( types, this.selector, data, fn ); - return this; - }, - die: function( types, fn ) { - jQuery( this.context ).off( types, this.selector || "**", fn ); - return this; - }, - delegate: function( selector, types, data, fn ) { return this.on( types, selector, data, fn ); }, undelegate: function( selector, types, fn ) { // ( namespace ) or ( selector, types [, fn] ) - return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector, fn ); + return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn ); }, trigger: function( type, data ) { @@ -3782,1532 +3678,1875 @@ jQuery.fn.extend({ }); }, triggerHandler: function( type, data ) { - if ( this[0] ) { - return jQuery.event.trigger( type, data, this[0], true ); + var elem = this[0]; + if ( elem ) { + return jQuery.event.trigger( type, data, elem, true ); } - }, - - toggle: function( fn ) { - // Save reference to arguments for access in closure - var args = arguments, - guid = fn.guid || jQuery.guid++, - i = 0, - toggler = function( event ) { - // Figure out which function to execute - var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; - jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); - - // Make sure that clicks stop - event.preventDefault(); - - // and execute the function - return args[ lastToggle ].apply( this, arguments ) || false; - }; + } +}); +/*! + * Sizzle CSS Selector Engine + * Copyright 2012 jQuery Foundation and other contributors + * Released under the MIT license + * http://sizzlejs.com/ + */ +(function( window, undefined ) { - // link all the functions, so any of them can unbind this click handler - toggler.guid = guid; - while ( i < args.length ) { - args[ i++ ].guid = guid; +var i, + cachedruns, + Expr, + getText, + isXML, + compile, + hasDuplicate, + outermostContext, + + // Local document vars + setDocument, + document, + docElem, + documentIsXML, + rbuggyQSA, + rbuggyMatches, + matches, + contains, + sortOrder, + + // Instance-specific data + expando = "sizzle" + -(new Date()), + preferredDoc = window.document, + support = {}, + dirruns = 0, + done = 0, + classCache = createCache(), + tokenCache = createCache(), + compilerCache = createCache(), + + // General-purpose constants + strundefined = typeof undefined, + MAX_NEGATIVE = 1 << 31, + + // Array methods + arr = [], + pop = arr.pop, + push = arr.push, + slice = arr.slice, + // Use a stripped-down indexOf if we can't use a native one + indexOf = arr.indexOf || function( elem ) { + var i = 0, + len = this.length; + for ( ; i < len; i++ ) { + if ( this[i] === elem ) { + return i; + } } - - return this.click( toggler ); + return -1; }, - hover: function( fnOver, fnOut ) { - return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); - } -}); -jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + - "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + - "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { + // 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#" ), + + // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors + operators = "([*^$|!~]?=)", + attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace + + "*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]", + + // Prefer arguments quoted, + // then not containing pseudos/brackets, + // then attribute selectors/non-parenthetical expressions, + // then anything else + // These preferences are here to reduce the number of selectors + // needing tokenize in the PSEUDO preFilter + pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)", + + // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter + rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), + + rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), + rcombinators = new RegExp( "^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*" ), + rpseudo = new RegExp( pseudos ), + ridentifier = new RegExp( "^" + identifier + "$" ), + + matchExpr = { + "ID": new RegExp( "^#(" + characterEncoding + ")" ), + "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ), + "NAME": new RegExp( "^\\[name=['\"]?(" + 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" ), + // 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" ) + }, + + rsibling = /[\x20\t\r\n\f]*[+~]/, + + rnative = /^[^{]+\{\s*\[native code/, + + // Easily-parseable/retrievable ID or TAG or CLASS selectors + rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, + + rinputs = /^(?:input|select|textarea|button)$/i, + rheader = /^h\d$/i, + + rescape = /'|\\/g, + rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g, + + // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters + runescape = /\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g, + funescape = function( _, escaped ) { + var high = "0x" + escaped - 0x10000; + // NaN means non-codepoint + return high !== high ? + escaped : + // BMP codepoint + high < 0 ? + String.fromCharCode( high + 0x10000 ) : + // Supplemental Plane codepoint (surrogate pair) + String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); + }; - // Handle event binding - jQuery.fn[ name ] = function( data, fn ) { - if ( fn == null ) { - fn = data; - data = null; +// Use a stripped-down slice if we can't use a native one +try { + slice.call( preferredDoc.documentElement.childNodes, 0 )[0].nodeType; +} catch ( e ) { + slice = function( i ) { + var elem, + results = []; + while ( (elem = this[i++]) ) { + results.push( elem ); } - - return arguments.length > 0 ? - this.on( name, null, data, fn ) : - this.trigger( name ); + return results; }; +} - if ( jQuery.attrFn ) { - jQuery.attrFn[ name ] = true; - } - - if ( rkeyEvent.test( name ) ) { - jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks; - } - - if ( rmouseEvent.test( name ) ) { - jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks; - } -}); +/** + * For feature detection + * @param {Function} fn The function to test for native support + */ +function isNative( fn ) { + return rnative.test( fn + "" ); +} +/** + * 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 cache, + keys = []; + return (cache = function( 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); + }); +} -/*! - * Sizzle CSS Selector Engine - * Copyright 2011, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * More information: http://sizzlejs.com/ +/** + * Mark a function for special use by Sizzle + * @param {Function} fn The function to mark */ -(function(){ +function markFunction( fn ) { + fn[ expando ] = true; + return fn; +} -var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, - expando = "sizcache" + (Math.random() + '').replace('.', ''), - done = 0, - toString = Object.prototype.toString, - hasDuplicate = false, - baseHasDuplicate = true, - rBackslash = /\\/g, - rReturn = /\r\n/g, - rNonWord = /\W/; - -// Here we check if the JavaScript engine is using some sort of -// optimization where it does not always call our comparision -// function. If that is the case, discard the hasDuplicate value. -// Thus far that includes Google Chrome. -[0, 0].sort(function() { - baseHasDuplicate = false; - return 0; -}); +/** + * 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"); -var Sizzle = function( selector, context, results, seed ) { - results = results || []; - context = context || document; + try { + return fn( div ); + } catch (e) { + return false; + } finally { + // release memory in IE + div = null; + } +} - var origContext = context; +function Sizzle( selector, context, results, seed ) { + var match, elem, m, nodeType, + // QSA vars + i, groups, old, nid, newContext, newSelector; - if ( context.nodeType !== 1 && context.nodeType !== 9 ) { - return []; + if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { + setDocument( context ); } - + + context = context || document; + results = results || []; + if ( !selector || typeof selector !== "string" ) { return results; } - var m, set, checkSet, extra, ret, cur, pop, i, - prune = true, - contextXML = Sizzle.isXML( context ), - parts = [], - soFar = selector; - - // Reset the position of the chunker regexp (start from head) - do { - chunker.exec( "" ); - m = chunker.exec( soFar ); - - if ( m ) { - soFar = m[3]; - - parts.push( m[1] ); - - if ( m[2] ) { - extra = m[3]; - break; + if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) { + return []; + } + + if ( !documentIsXML && !seed ) { + + // Shortcuts + if ( (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 #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, slice.call(context.getElementsByTagName( selector ), 0) ); + return results; + + // Speed-up: Sizzle(".CLASS") + } else if ( (m = match[3]) && support.getByClassName && context.getElementsByClassName ) { + push.apply( results, slice.call(context.getElementsByClassName( m ), 0) ); + return results; } } - } while ( m ); - if ( parts.length > 1 && origPOS.exec( selector ) ) { + // QSA path + if ( support.qsa && !rbuggyQSA.test(selector) ) { + old = true; + nid = expando; + newContext = context; + newSelector = nodeType === 9 && selector; - if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { - set = posProcess( parts[0] + parts[1], context, seed ); + // 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 ); - } else { - set = Expr.relative[ parts[0] ] ? - [ context ] : - Sizzle( parts.shift(), context ); + if ( (old = context.getAttribute("id")) ) { + nid = old.replace( rescape, "\\$&" ); + } else { + context.setAttribute( "id", nid ); + } + nid = "[id='" + nid + "'] "; - while ( parts.length ) { - selector = parts.shift(); + i = groups.length; + while ( i-- ) { + groups[i] = nid + toSelector( groups[i] ); + } + newContext = rsibling.test( selector ) && context.parentNode || context; + newSelector = groups.join(","); + } - if ( Expr.relative[ selector ] ) { - selector += parts.shift(); + if ( newSelector ) { + try { + push.apply( results, slice.call( newContext.querySelectorAll( + newSelector + ), 0 ) ); + return results; + } catch(qsaError) { + } finally { + if ( !old ) { + context.removeAttribute("id"); + } } - - set = posProcess( selector, set, seed ); } } + } - } else { - // Take a shortcut and set the context if the root selector is an ID - // (but not if it'll be faster if the inner selector is an ID) - if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && - Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { + // All others + return select( selector.replace( rtrim, "$1" ), context, results, seed ); +} - ret = Sizzle.find( parts.shift(), context, contextXML ); - context = ret.expr ? - Sizzle.filter( ret.expr, ret.set )[0] : - ret.set[0]; +/** + * Detect xml + * @param {Element|Object} elem An element or a document + */ +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 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; + + // Support tests + documentIsXML = isXML( doc ); + + // Check if getElementsByTagName("*") returns only elements + support.tagNameNoComments = assert(function( div ) { + div.appendChild( doc.createComment("") ); + return !div.getElementsByTagName("*").length; + }); + + // Check if attributes should be retrieved by attribute nodes + support.attributes = assert(function( div ) { + div.innerHTML = "<select></select>"; + var type = typeof div.lastChild.getAttribute("multiple"); + // IE8 returns a string for some attributes even when not present + return type !== "boolean" && type !== "string"; + }); + + // Check if getElementsByClassName can be trusted + support.getByClassName = assert(function( div ) { + // Opera can't find a second classname (in 9.6) + div.innerHTML = "<div class='hidden e'></div><div class='hidden'></div>"; + if ( !div.getElementsByClassName || !div.getElementsByClassName("e").length ) { + return false; } - if ( context ) { - ret = seed ? - { expr: parts.pop(), set: makeArray(seed) } : - Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); + // Safari 3.2 caches class attributes and doesn't catch changes + div.lastChild.className = "e"; + return div.getElementsByClassName("e").length === 2; + }); - set = ret.expr ? - Sizzle.filter( ret.expr, ret.set ) : - ret.set; + // Check if getElementById returns elements by name + // Check if getElementsByName privileges form controls or returns elements by ID + support.getByName = assert(function( div ) { + // Inject content + div.id = expando + 0; + div.innerHTML = "<a name='" + expando + "'></a><div name='" + expando + "'></div>"; + docElem.insertBefore( div, docElem.firstChild ); + + // Test + var pass = doc.getElementsByName && + // buggy browsers will return fewer than the correct 2 + doc.getElementsByName( expando ).length === 2 + + // buggy browsers will return more than the correct 0 + doc.getElementsByName( expando + 0 ).length; + support.getIdNotName = !doc.getElementById( expando ); + + // Cleanup + docElem.removeChild( div ); + + return pass; + }); - if ( parts.length > 0 ) { - checkSet = makeArray( set ); + // IE6/7 return modified attributes + Expr.attrHandle = assert(function( div ) { + div.innerHTML = "<a href='#'></a>"; + return div.firstChild && typeof div.firstChild.getAttribute !== strundefined && + div.firstChild.getAttribute("href") === "#"; + }) ? + {} : + { + "href": function( elem ) { + return elem.getAttribute( "href", 2 ); + }, + "type": function( elem ) { + return elem.getAttribute("type"); + } + }; - } else { - prune = false; + // ID find and filter + if ( support.getIdNotName ) { + Expr.find["ID"] = function( id, context ) { + if ( typeof context.getElementById !== strundefined && !documentIsXML ) { + 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 { + Expr.find["ID"] = function( id, context ) { + if ( typeof context.getElementById !== strundefined && !documentIsXML ) { + var m = context.getElementById( id ); - while ( parts.length ) { - cur = parts.pop(); - pop = cur; + return m ? + m.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode("id").value === id ? + [m] : + undefined : + []; + } + }; + Expr.filter["ID"] = function( id ) { + var attrId = id.replace( runescape, funescape ); + return function( elem ) { + var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id"); + return node && node.value === attrId; + }; + }; + } - if ( !Expr.relative[ cur ] ) { - cur = ""; - } else { - pop = parts.pop(); - } + // Tag + Expr.find["TAG"] = support.tagNameNoComments ? + function( tag, context ) { + if ( typeof context.getElementsByTagName !== strundefined ) { + return context.getElementsByTagName( tag ); + } + } : + function( tag, context ) { + var elem, + tmp = [], + i = 0, + results = context.getElementsByTagName( tag ); - if ( pop == null ) { - pop = context; + // Filter out possible comments + if ( tag === "*" ) { + while ( (elem = results[i++]) ) { + if ( elem.nodeType === 1 ) { + tmp.push( elem ); + } } - Expr.relative[ cur ]( checkSet, pop, contextXML ); + return tmp; } + return results; + }; - } else { - checkSet = parts = []; + // Name + Expr.find["NAME"] = support.getByName && function( tag, context ) { + if ( typeof context.getElementsByName !== strundefined ) { + return context.getElementsByName( name ); } - } + }; - if ( !checkSet ) { - checkSet = set; - } + // Class + Expr.find["CLASS"] = support.getByClassName && function( className, context ) { + if ( typeof context.getElementsByClassName !== strundefined && !documentIsXML ) { + return context.getElementsByClassName( className ); + } + }; - if ( !checkSet ) { - Sizzle.error( cur || selector ); - } + // QSA and matchesSelector support - if ( toString.call(checkSet) === "[object Array]" ) { - if ( !prune ) { - results.push.apply( results, checkSet ); + // matchesSelector(:active) reports false when true (IE9/Opera 11.5) + rbuggyMatches = []; - } else if ( context && context.nodeType === 1 ) { - for ( i = 0; checkSet[i] != null; i++ ) { - if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) { - results.push( set[i] ); - } + // qSa(:focus) reports false when true (Chrome 21), + // no need to also add to buggyMatches since matches checks buggyQSA + // A support test would require too much code (would include document ready) + rbuggyQSA = [ ":focus" ]; + + if ( (support.qsa = isNative(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 explictly + // setting a boolean content attribute, + // since its presence should be enough + // http://bugs.jquery.com/ticket/12359 + div.innerHTML = "<select><option selected=''></option></select>"; + + // IE8 - Some boolean attributes are not treated correctly + if ( !div.querySelectorAll("[selected]").length ) { + rbuggyQSA.push( "\\[" + whitespace + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)" ); } - } else { - for ( i = 0; checkSet[i] != null; i++ ) { - if ( checkSet[i] && checkSet[i].nodeType === 1 ) { - results.push( set[i] ); - } + // 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"); } - } + }); - } else { - makeArray( checkSet, results ); - } + assert(function( div ) { + + // Opera 10-12/IE8 - ^= $= *= and empty values + // Should not select anything + div.innerHTML = "<input type='hidden' i=''/>"; + if ( div.querySelectorAll("[i^='']").length ) { + rbuggyQSA.push( "[*^$]=" + 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" ); + } - if ( extra ) { - Sizzle( extra, origContext, results, seed ); - Sizzle.uniqueSort( results ); + // Opera 10-11 does not throw on post-comma invalid pseudos + div.querySelectorAll("*,:x"); + rbuggyQSA.push(",.*:"); + }); } - return results; -}; + if ( (support.matchesSelector = isNative( (matches = docElem.matchesSelector || + docElem.mozMatchesSelector || + docElem.webkitMatchesSelector || + docElem.oMatchesSelector || + docElem.msMatchesSelector) )) ) { -Sizzle.uniqueSort = function( results ) { - if ( sortOrder ) { - hasDuplicate = baseHasDuplicate; - results.sort( sortOrder ); + 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" ); - if ( hasDuplicate ) { - for ( var i = 1; i < results.length; i++ ) { - if ( results[i] === results[ i - 1 ] ) { - results.splice( i--, 1 ); + // This should fail with an exception + // Gecko does not error, returns false instead + matches.call( div, "[s!='']:x" ); + rbuggyMatches.push( "!=", pseudos ); + }); + } + + rbuggyQSA = new RegExp( rbuggyQSA.join("|") ); + rbuggyMatches = new RegExp( rbuggyMatches.join("|") ); + + // Element contains another + // Purposefully does not implement inclusive descendent + // As in, an element does not contain itself + contains = isNative(docElem.contains) || docElem.compareDocumentPosition ? + 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; + }; - return results; -}; + // Document order sorting + sortOrder = docElem.compareDocumentPosition ? + function( a, b ) { + var compare; -Sizzle.matches = function( expr, set ) { - return Sizzle( expr, null, null, set ); -}; + if ( a === b ) { + hasDuplicate = true; + return 0; + } -Sizzle.matchesSelector = function( node, expr ) { - return Sizzle( expr, null, null, [node] ).length > 0; -}; + if ( (compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b )) ) { + if ( compare & 1 || a.parentNode && a.parentNode.nodeType === 11 ) { + if ( a === doc || contains( preferredDoc, a ) ) { + return -1; + } + if ( b === doc || contains( preferredDoc, b ) ) { + return 1; + } + return 0; + } + return compare & 4 ? -1 : 1; + } -Sizzle.find = function( expr, context, isXML ) { - var set, i, len, match, type, left; + return a.compareDocumentPosition ? -1 : 1; + } : + function( a, b ) { + var cur, + i = 0, + aup = a.parentNode, + bup = b.parentNode, + ap = [ a ], + bp = [ b ]; - if ( !expr ) { - return []; - } + // Exit early if the nodes are identical + if ( a === b ) { + hasDuplicate = true; + return 0; - for ( i = 0, len = Expr.order.length; i < len; i++ ) { - type = Expr.order[i]; - - if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { - left = match[1]; - match.splice( 1, 1 ); + // Parentless nodes are either documents or disconnected + } else if ( !aup || !bup ) { + return a === doc ? -1 : + b === doc ? 1 : + aup ? -1 : + bup ? 1 : + 0; - if ( left.substr( left.length - 1 ) !== "\\" ) { - match[1] = (match[1] || "").replace( rBackslash, "" ); - set = Expr.find[ type ]( match, context, isXML ); + // If the nodes are siblings, we can do a quick check + } else if ( aup === bup ) { + return siblingCheck( a, b ); + } - if ( set != null ) { - expr = expr.replace( Expr.match[ type ], "" ); - break; - } - } + // 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 ); } - } - if ( !set ) { - set = typeof context.getElementsByTagName !== "undefined" ? - context.getElementsByTagName( "*" ) : - []; - } + // Walk down the tree looking for a discrepancy + while ( ap[i] === bp[i] ) { + i++; + } - return { set: set, expr: expr }; -}; + return i ? + // Do a sibling check if the nodes have a common ancestor + siblingCheck( ap[i], bp[i] ) : -Sizzle.filter = function( expr, set, inplace, not ) { - var match, anyFound, - type, found, item, filter, left, - i, pass, - old = expr, - result = [], - curLoop = set, - isXMLFilter = set && set[0] && Sizzle.isXML( set[0] ); + // Otherwise nodes in our document sort first + ap[i] === preferredDoc ? -1 : + bp[i] === preferredDoc ? 1 : + 0; + }; - while ( expr && set.length ) { - for ( type in Expr.filter ) { - if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { - filter = Expr.filter[ type ]; - left = match[1]; + // Always assume the presence of duplicates if sort doesn't + // pass them to our comparison function (as in Google Chrome). + hasDuplicate = false; + [0, 0].sort( sortOrder ); + support.detectDuplicates = hasDuplicate; - anyFound = false; + return document; +}; - match.splice(1,1); +Sizzle.matches = function( expr, elements ) { + return Sizzle( expr, null, null, elements ); +}; - if ( left.substr( left.length - 1 ) === "\\" ) { - continue; - } +Sizzle.matchesSelector = function( elem, expr ) { + // Set document vars if needed + if ( ( elem.ownerDocument || elem ) !== document ) { + setDocument( elem ); + } - if ( curLoop === result ) { - result = []; - } + // Make sure that attribute selectors are quoted + expr = expr.replace( rattributeQuotes, "='$1']" ); - if ( Expr.preFilter[ type ] ) { - match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); + // rbuggyQSA always contains :focus, so no need for an existence check + if ( support.matchesSelector && !documentIsXML && (!rbuggyMatches || !rbuggyMatches.test(expr)) && !rbuggyQSA.test(expr) ) { + try { + var ret = matches.call( elem, expr ); - if ( !match ) { - anyFound = found = true; + // 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) {} + } - } else if ( match === true ) { - continue; - } - } + return Sizzle( expr, document, null, [elem] ).length > 0; +}; - if ( match ) { - for ( i = 0; (item = curLoop[i]) != null; i++ ) { - if ( item ) { - found = filter( item, match, i, curLoop ); - pass = not ^ found; +Sizzle.contains = function( context, elem ) { + // Set document vars if needed + if ( ( context.ownerDocument || context ) !== document ) { + setDocument( context ); + } + return contains( context, elem ); +}; - if ( inplace && found != null ) { - if ( pass ) { - anyFound = true; +Sizzle.attr = function( elem, name ) { + var val; - } else { - curLoop[i] = false; - } + // Set document vars if needed + if ( ( elem.ownerDocument || elem ) !== document ) { + setDocument( elem ); + } - } else if ( pass ) { - result.push( item ); - anyFound = true; - } - } - } - } + if ( !documentIsXML ) { + name = name.toLowerCase(); + } + if ( (val = Expr.attrHandle[ name ]) ) { + return val( elem ); + } + if ( documentIsXML || support.attributes ) { + return elem.getAttribute( name ); + } + return ( (val = elem.getAttributeNode( name )) || elem.getAttribute( name ) ) && elem[ name ] === true ? + name : + val && val.specified ? val.value : null; +}; - if ( found !== undefined ) { - if ( !inplace ) { - curLoop = result; - } +Sizzle.error = function( msg ) { + throw new Error( "Syntax error, unrecognized expression: " + msg ); +}; - expr = expr.replace( Expr.match[ type ], "" ); +// Document sorting and removing duplicates +Sizzle.uniqueSort = function( results ) { + var elem, + duplicates = [], + i = 1, + j = 0; - if ( !anyFound ) { - return []; - } + // Unless we *know* we can detect duplicates, assume their presence + hasDuplicate = !support.detectDuplicates; + results.sort( sortOrder ); - break; - } + if ( hasDuplicate ) { + for ( ; (elem = results[i]); i++ ) { + if ( elem === results[ i - 1 ] ) { + j = duplicates.push( i ); } } + while ( j-- ) { + results.splice( duplicates[ j ], 1 ); + } + } - // Improper expression - if ( expr === old ) { - if ( anyFound == null ) { - Sizzle.error( expr ); + return results; +}; - } else { - break; +function siblingCheck( a, b ) { + var cur = b && a, + diff = cur && ( ~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; } } - - old = expr; } - return curLoop; -}; + return a ? 1 : -1; +} -Sizzle.error = function( msg ) { - throw new Error( "Syntax error, unrecognized expression: " + msg ); -}; +// Returns a function to use in pseudos for input types +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 +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 +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]); + } + } + }); + }); +} /** - * Utility function for retreiving the text value of an array of DOM nodes + * Utility function for retrieving the text value of an array of DOM nodes * @param {Array|Element} elem */ -var getText = Sizzle.getText = function( elem ) { - var i, node, - nodeType = elem.nodeType, - ret = ""; - - if ( nodeType ) { - if ( nodeType === 1 || nodeType === 9 ) { - // Use textContent || innerText for elements - if ( typeof elem.textContent === 'string' ) { - return elem.textContent; - } else if ( typeof elem.innerText === 'string' ) { - // Replace IE's carriage returns - return elem.innerText.replace( rReturn, '' ); - } else { - // Traverse it's children - for ( elem = elem.firstChild; elem; elem = elem.nextSibling) { - ret += getText( elem ); - } - } - } else if ( nodeType === 3 || nodeType === 4 ) { - return elem.nodeValue; - } - } else { +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 - for ( i = 0; (node = elem[i]); i++ ) { + for ( ; (node = elem[i]); i++ ) { // Do not traverse comment nodes - if ( node.nodeType !== 8 ) { - ret += getText( node ); + ret += getText( node ); + } + } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { + // Use textContent for elements + // innerText usage removed for consistency of new lines (see #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; }; -var Expr = Sizzle.selectors = { - order: [ "ID", "NAME", "TAG" ], +Expr = Sizzle.selectors = { - match: { - ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, - CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, - NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, - ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, - TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, - CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, - POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, - PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ - }, + // Can be adjusted by the user + cacheLength: 50, - leftMatch: {}, + createPseudo: markFunction, - attrMap: { - "class": "className", - "for": "htmlFor" - }, + match: matchExpr, - attrHandle: { - href: function( elem ) { - return elem.getAttribute( "href" ); - }, - type: function( elem ) { - return elem.getAttribute( "type" ); - } - }, + find: {}, relative: { - "+": function(checkSet, part){ - var isPartStr = typeof part === "string", - isTag = isPartStr && !rNonWord.test( part ), - isPartStrNotTag = isPartStr && !isTag; + ">": { dir: "parentNode", first: true }, + " ": { dir: "parentNode" }, + "+": { dir: "previousSibling", first: true }, + "~": { dir: "previousSibling" } + }, - if ( isTag ) { - part = part.toLowerCase(); - } + preFilter: { + "ATTR": function( match ) { + match[1] = match[1].replace( runescape, funescape ); - for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { - if ( (elem = checkSet[i]) ) { - while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} + // Move the given value to match[3] whether quoted or unquoted + match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape ); - checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? - elem || false : - elem === part; - } + if ( match[2] === "~=" ) { + match[3] = " " + match[3] + " "; } - if ( isPartStrNotTag ) { - Sizzle.filter( part, checkSet, true ); - } + return match.slice( 0, 4 ); }, - ">": function( checkSet, part ) { - var elem, - isPartStr = typeof part === "string", - i = 0, - l = checkSet.length; - - if ( isPartStr && !rNonWord.test( part ) ) { - part = part.toLowerCase(); - - for ( ; i < l; i++ ) { - elem = checkSet[i]; - - if ( elem ) { - var parent = elem.parentNode; - checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; - } - } - - } else { - for ( ; i < l; i++ ) { - elem = checkSet[i]; - - if ( elem ) { - checkSet[i] = isPartStr ? - elem.parentNode : - elem.parentNode === part; - } - } - - if ( isPartStr ) { - Sizzle.filter( part, checkSet, true ); + "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] ); } - } - }, - "": function(checkSet, part, isXML){ - var nodeCheck, - doneName = done++, - checkFn = dirCheck; + // 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" ); - if ( typeof part === "string" && !rNonWord.test( part ) ) { - part = part.toLowerCase(); - nodeCheck = part; - checkFn = dirNodeCheck; + // other types prohibit arguments + } else if ( match[3] ) { + Sizzle.error( match[0] ); } - checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML ); + return match; }, - "~": function( checkSet, part, isXML ) { - var nodeCheck, - doneName = done++, - checkFn = dirCheck; - - if ( typeof part === "string" && !rNonWord.test( part ) ) { - part = part.toLowerCase(); - nodeCheck = part; - checkFn = dirNodeCheck; - } - - checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML ); - } - }, + "PSEUDO": function( match ) { + var excess, + unquoted = !match[5] && match[2]; - find: { - ID: function( match, context, isXML ) { - if ( typeof context.getElementById !== "undefined" && !isXML ) { - var m = context.getElementById(match[1]); - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - return m && m.parentNode ? [m] : []; + if ( matchExpr["CHILD"].test( match[0] ) ) { + return null; } - }, - NAME: function( match, context ) { - if ( typeof context.getElementsByName !== "undefined" ) { - var ret = [], - results = context.getElementsByName( match[1] ); + // Accept quoted arguments as-is + if ( match[4] ) { + match[2] = match[4]; - for ( var i = 0, l = results.length; i < l; i++ ) { - if ( results[i].getAttribute("name") === match[1] ) { - ret.push( results[i] ); - } - } + // 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) ) { - return ret.length === 0 ? null : ret; + // excess is a negative index + match[0] = match[0].slice( 0, excess ); + match[2] = unquoted.slice( 0, excess ); } - }, - TAG: function( match, context ) { - if ( typeof context.getElementsByTagName !== "undefined" ) { - return context.getElementsByTagName( match[1] ); - } + // Return only captures needed by the pseudo filter method (type and argument) + return match.slice( 0, 3 ); } }, - preFilter: { - CLASS: function( match, curLoop, inplace, result, not, isXML ) { - match = " " + match[1].replace( rBackslash, "" ) + " "; - - if ( isXML ) { - return match; - } - for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { - if ( elem ) { - if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) { - if ( !inplace ) { - result.push( elem ); - } + filter: { - } else if ( inplace ) { - curLoop[i] = false; - } - } + "TAG": function( nodeName ) { + if ( nodeName === "*" ) { + return function() { return true; }; } - return false; + nodeName = nodeName.replace( runescape, funescape ).toLowerCase(); + return function( elem ) { + return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; + }; }, - ID: function( match ) { - return match[1].replace( rBackslash, "" ); - }, + "CLASS": function( className ) { + var pattern = classCache[ className + " " ]; - TAG: function( match, curLoop ) { - return match[1].replace( rBackslash, "" ).toLowerCase(); + return pattern || + (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && + classCache( className, function( elem ) { + return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" ); + }); }, - CHILD: function( match ) { - if ( match[1] === "nth" ) { - if ( !match[2] ) { - Sizzle.error( match[0] ); + "ATTR": function( name, operator, check ) { + return function( elem ) { + var result = Sizzle.attr( elem, name ); + + if ( result == null ) { + return operator === "!="; + } + if ( !operator ) { + return true; } - match[2] = match[2].replace(/^\+|\s*/g, ''); + result += ""; - // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' - var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( - match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || - !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); + 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 + " " ).indexOf( check ) > -1 : + operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : + false; + }; + }, - // calculate the numbers (first)n+(last) including if they are negative - match[2] = (test[1] + (test[2] || 1)) - 0; - match[3] = test[3] - 0; - } - else if ( match[2] ) { - Sizzle.error( match[0] ); - } + "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; + } - // TODO: Move to normal caching system - match[0] = done++; + start = [ forward ? parent.firstChild : parent.lastChild ]; - return match; - }, + // 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 ]; - ATTR: function( match, curLoop, inplace, result, not, isXML ) { - var name = match[1] = match[1].replace( rBackslash, "" ); - - if ( !isXML && Expr.attrMap[name] ) { - match[1] = Expr.attrMap[name]; - } + while ( (node = ++nodeIndex && node && node[ dir ] || - // Handle if an un-quoted value was used - match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" ); + // Fallback to seeking `elem` from the start + (diff = nodeIndex = 0) || start.pop()) ) { - if ( match[2] === "~=" ) { - match[4] = " " + match[4] + " "; - } + // When found, cache indexes on `parent` and break + if ( node.nodeType === 1 && ++diff && node === elem ) { + outerCache[ type ] = [ dirruns, nodeIndex, diff ]; + break; + } + } - return match; - }, + // Use previously-cached element index if available + } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) { + diff = cache[1]; - PSEUDO: function( match, curLoop, inplace, result, not ) { - if ( match[1] === "not" ) { - // If we're dealing with a complex expression, or a simple one - if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { - match[3] = Sizzle(match[3], null, null, curLoop); + // 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 ]; + } - } else { - var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); + if ( node === elem ) { + break; + } + } + } + } - if ( !inplace ) { - result.push.apply( result, ret ); + // Incorporate the offset, then check against cycle size + diff -= last; + return diff === first || ( diff % first === 0 && diff / first >= 0 ); } - - return false; - } - - } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { - return true; - } - - return match; + }; }, - POS: function( match ) { - match.unshift( true ); + "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.call( seed, matched[i] ); + seed[ idx ] = !( matches[ idx ] = matched[i] ); + } + }) : + function( elem ) { + return fn( elem, 0, args ); + }; + } - return match; + return fn; } }, - - filters: { - enabled: function( elem ) { - return elem.disabled === false && elem.type !== "hidden"; - }, - - disabled: function( elem ) { - return elem.disabled === true; - }, - - checked: function( elem ) { - return elem.checked === true; - }, - - selected: function( elem ) { - // Accessing this property makes selected-by-default - // options in Safari work properly - if ( elem.parentNode ) { - elem.parentNode.selectedIndex; - } - - return elem.selected === true; - }, - - parent: function( elem ) { - return !!elem.firstChild; - }, - empty: function( elem ) { - return !elem.firstChild; - }, - - has: function( elem, i, match ) { - return !!Sizzle( match[3], elem ).length; - }, + 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" ) ); - header: function( elem ) { - return (/h\d/i).test( elem.nodeName ); - }, + return matcher[ expando ] ? + markFunction(function( seed, matches, context, xml ) { + var elem, + unmatched = matcher( seed, null, xml, [] ), + i = seed.length; - text: function( elem ) { - var attr = elem.getAttribute( "type" ), type = elem.type; - // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) - // use getAttribute instead to test this case - return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); - }, + // 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 ); + return !results.pop(); + }; + }), - radio: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type; - }, + "has": markFunction(function( selector ) { + return function( elem ) { + return Sizzle( selector, elem ).length > 0; + }; + }), - checkbox: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type; - }, + "contains": markFunction(function( text ) { + 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 identifider + if ( !ridentifier.test(lang || "") ) { + Sizzle.error( "unsupported lang: " + lang ); + } + lang = lang.replace( runescape, funescape ).toLowerCase(); + return function( elem ) { + var elemLang; + do { + if ( (elemLang = documentIsXML ? + elem.getAttribute("xml:lang") || elem.getAttribute("lang") : + elem.lang) ) { + + elemLang = elemLang.toLowerCase(); + return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; + } + } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); + return false; + }; + }), - file: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "file" === elem.type; + // Miscellaneous + "target": function( elem ) { + var hash = window.location && window.location.hash; + return hash && hash.slice( 1 ) === elem.id; }, - password: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "password" === elem.type; + "root": function( elem ) { + return elem === docElem; }, - submit: function( elem ) { - var name = elem.nodeName.toLowerCase(); - return (name === "input" || name === "button") && "submit" === elem.type; + "focus": function( elem ) { + return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); }, - image: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "image" === elem.type; + // Boolean properties + "enabled": function( elem ) { + return elem.disabled === false; }, - reset: function( elem ) { - var name = elem.nodeName.toLowerCase(); - return (name === "input" || name === "button") && "reset" === elem.type; + "disabled": function( elem ) { + return elem.disabled === true; }, - button: function( elem ) { - var name = elem.nodeName.toLowerCase(); - return name === "input" && "button" === elem.type || name === "button"; + "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); }, - input: function( elem ) { - return (/input|select|textarea|button/i).test( elem.nodeName ); - }, + "selected": function( elem ) { + // Accessing this property makes selected-by-default + // options in Safari work properly + if ( elem.parentNode ) { + elem.parentNode.selectedIndex; + } - focus: function( elem ) { - return elem === elem.ownerDocument.activeElement; - } - }, - setFilters: { - first: function( elem, i ) { - return i === 0; + return elem.selected === true; }, - last: function( elem, i, match, array ) { - return i === array.length - 1; + // Contents + "empty": function( elem ) { + // http://www.w3.org/TR/selectors/#empty-pseudo + // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)), + // not comment, processing instructions, or others + // Thanks to Diego Perini for the nodeName shortcut + // Greater than "@" means alpha characters (specifically not starting with "#" or "?") + for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { + if ( elem.nodeName > "@" || elem.nodeType === 3 || elem.nodeType === 4 ) { + return false; + } + } + return true; }, - even: function( elem, i ) { - return i % 2 === 0; + "parent": function( elem ) { + return !Expr.pseudos["empty"]( elem ); }, - odd: function( elem, i ) { - return i % 2 === 1; + // Element/input types + "header": function( elem ) { + return rheader.test( elem.nodeName ); }, - lt: function( elem, i, match ) { - return i < match[3] - 0; + "input": function( elem ) { + return rinputs.test( elem.nodeName ); }, - gt: function( elem, i, match ) { - return i > match[3] - 0; + "button": function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === "button" || name === "button"; }, - nth: function( elem, i, match ) { - return match[3] - 0 === i; + "text": function( elem ) { + var attr; + // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) + // use getAttribute instead to test this case + return elem.nodeName.toLowerCase() === "input" && + elem.type === "text" && + ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === elem.type ); }, - eq: function( elem, i, match ) { - return match[3] - 0 === i; - } - }, - filter: { - PSEUDO: function( elem, match, i, array ) { - var name = match[1], - filter = Expr.filters[ name ]; - - if ( filter ) { - return filter( elem, i, match, array ); + // Position-in-collection + "first": createPositionalPseudo(function() { + return [ 0 ]; + }), - } else if ( name === "contains" ) { - return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0; - - } else if ( name === "not" ) { - var not = match[3]; - - for ( var j = 0, l = not.length; j < l; j++ ) { - if ( not[j] === elem ) { - return false; - } - } + "last": createPositionalPseudo(function( matchIndexes, length ) { + return [ length - 1 ]; + }), - return true; + "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { + return [ argument < 0 ? argument + length : argument ]; + }), - } else { - Sizzle.error( name ); + "even": createPositionalPseudo(function( matchIndexes, length ) { + var i = 0; + for ( ; i < length; i += 2 ) { + matchIndexes.push( i ); } - }, + return matchIndexes; + }), - CHILD: function( elem, match ) { - var first, last, - doneName, parent, cache, - count, diff, - type = match[1], - node = elem; - - switch ( type ) { - case "only": - case "first": - while ( (node = node.previousSibling) ) { - if ( node.nodeType === 1 ) { - return false; - } - } - - if ( type === "first" ) { - return true; - } + "odd": createPositionalPseudo(function( matchIndexes, length ) { + var i = 1; + for ( ; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), - node = elem; + "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { + var i = argument < 0 ? argument + length : argument; + for ( ; --i >= 0; ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), - case "last": - while ( (node = node.nextSibling) ) { - if ( node.nodeType === 1 ) { - return false; - } - } + "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { + var i = argument < 0 ? argument + length : argument; + for ( ; ++i < length; ) { + matchIndexes.push( i ); + } + return matchIndexes; + }) + } +}; - return true; +// 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 ); +} - case "nth": - first = match[2]; - last = match[3]; +function tokenize( selector, parseOnly ) { + var matched, match, tokens, type, + soFar, groups, preFilters, + cached = tokenCache[ selector + " " ]; - if ( first === 1 && last === 0 ) { - return true; - } - - doneName = match[0]; - parent = elem.parentNode; - - if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) { - count = 0; - - for ( node = parent.firstChild; node; node = node.nextSibling ) { - if ( node.nodeType === 1 ) { - node.nodeIndex = ++count; - } - } + if ( cached ) { + return parseOnly ? 0 : cached.slice( 0 ); + } - parent[ expando ] = doneName; - } - - diff = elem.nodeIndex - last; + soFar = selector; + groups = []; + preFilters = Expr.preFilter; - if ( first === 0 ) { - return diff === 0; + while ( soFar ) { - } else { - return ( diff % first === 0 && diff / first >= 0 ); - } + // 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; } - }, - - ID: function( elem, match ) { - return elem.nodeType === 1 && elem.getAttribute("id") === match; - }, - - TAG: function( elem, match ) { - return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match; - }, - - CLASS: function( elem, match ) { - return (" " + (elem.className || elem.getAttribute("class")) + " ") - .indexOf( match ) > -1; - }, + groups.push( tokens = [] ); + } - ATTR: function( elem, match ) { - var name = match[1], - result = Sizzle.attr ? - Sizzle.attr( elem, name ) : - Expr.attrHandle[ name ] ? - Expr.attrHandle[ name ]( elem ) : - elem[ name ] != null ? - elem[ name ] : - elem.getAttribute( name ), - value = result + "", - type = match[2], - check = match[4]; - - return result == null ? - type === "!=" : - !type && Sizzle.attr ? - result != null : - type === "=" ? - value === check : - type === "*=" ? - value.indexOf(check) >= 0 : - type === "~=" ? - (" " + value + " ").indexOf(check) >= 0 : - !check ? - value && result !== false : - type === "!=" ? - value !== check : - type === "^=" ? - value.indexOf(check) === 0 : - type === "$=" ? - value.substr(value.length - check.length) === check : - type === "|=" ? - value === check || value.substr(0, check.length + 1) === check + "-" : - false; - }, + matched = false; - POS: function( elem, match, i, array ) { - var name = match[2], - filter = Expr.setFilters[ name ]; + // 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 ); + } - if ( filter ) { - return filter( elem, i, match, array ); + // 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 ); } } - } -}; -var origPOS = Expr.match.POS, - fescape = function(all, num){ - return "\\" + (num - 0 + 1); - }; + if ( !matched ) { + break; + } + } -for ( var type in Expr.match ) { - Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) ); - Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) ); + // 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 ); } -var makeArray = function( array, results ) { - array = Array.prototype.slice.call( array, 0 ); - - if ( results ) { - results.push.apply( results, array ); - return results; +function toSelector( tokens ) { + var i = 0, + len = tokens.length, + selector = ""; + for ( ; i < len; i++ ) { + selector += tokens[i].value; } - - return array; -}; + return selector; +} -// Perform a simple check to determine if the browser is capable of -// converting a NodeList to an array using builtin methods. -// Also verifies that the returned array holds DOM nodes -// (which is not the case in the Blackberry browser) -try { - Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; +function addCombinator( matcher, combinator, base ) { + var dir = combinator.dir, + checkNonElements = base && dir === "parentNode", + doneName = done++; -// Provide a fallback method if it does not work -} catch( e ) { - makeArray = function( array, results ) { - var i = 0, - ret = results || []; + 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 ); + } + } + } : - if ( toString.call(array) === "[object Array]" ) { - Array.prototype.push.apply( ret, array ); + // Check against all ancestor/preceding elements + function( elem, context, xml ) { + var data, cache, outerCache, + dirkey = dirruns + " " + doneName; - } else { - if ( typeof array.length === "number" ) { - for ( var l = array.length; i < l; i++ ) { - ret.push( array[i] ); + // 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 { - for ( ; array[i]; i++ ) { - ret.push( array[i] ); + while ( (elem = elem[ dir ]) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + outerCache = elem[ expando ] || (elem[ expando ] = {}); + if ( (cache = outerCache[ dir ]) && cache[0] === dirkey ) { + if ( (data = cache[1]) === true || data === cachedruns ) { + return data === true; + } + } else { + cache = outerCache[ dir ] = [ dirkey ]; + cache[1] = matcher( elem, context, xml ) || cachedruns; + if ( cache[1] === true ) { + return true; + } + } + } } } - } - - return ret; - }; + }; } -var sortOrder, siblingCheck; +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]; +} -if ( document.documentElement.compareDocumentPosition ) { - sortOrder = function( a, b ) { - if ( a === b ) { - hasDuplicate = true; - return 0; - } +function condense( unmatched, map, filter, context, xml ) { + var elem, + newUnmatched = [], + i = 0, + len = unmatched.length, + mapped = map != null; - if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { - return a.compareDocumentPosition ? -1 : 1; + for ( ; i < len; i++ ) { + if ( (elem = unmatched[i]) ) { + if ( !filter || filter( elem, context, xml ) ) { + newUnmatched.push( elem ); + if ( mapped ) { + map.push( i ); + } + } } + } - return a.compareDocumentPosition(b) & 4 ? -1 : 1; - }; - -} else { - sortOrder = function( a, b ) { - // The nodes are identical, we can exit early - if ( a === b ) { - hasDuplicate = true; - return 0; - - // Fallback to using sourceIndex (in IE) if it's available on both nodes - } else if ( a.sourceIndex && b.sourceIndex ) { - return a.sourceIndex - b.sourceIndex; - } + return newUnmatched; +} - var al, bl, - ap = [], - bp = [], - aup = a.parentNode, - bup = b.parentNode, - cur = aup; +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, - // If the nodes are siblings (or identical) we can do a quick check - if ( aup === bup ) { - return siblingCheck( a, b ); + // Get initial elements from seed or context + elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), - // If no parents were found then the nodes are disconnected - } else if ( !aup ) { - return -1; + // Prefilter to get matcher input, preserving a map for seed-results synchronization + matcherIn = preFilter && ( seed || !selector ) ? + condense( elems, preMap, preFilter, context, xml ) : + elems, - } else if ( !bup ) { - return 1; - } + matcherOut = matcher ? + // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, + postFinder || ( seed ? preFilter : preexisting || postFilter ) ? - // Otherwise they're somewhere else in the tree so we need - // to build up a full list of the parentNodes for comparison - while ( cur ) { - ap.unshift( cur ); - cur = cur.parentNode; - } + // ...intermediate processing is necessary + [] : - cur = bup; + // ...otherwise use results directly + results : + matcherIn; - while ( cur ) { - bp.unshift( cur ); - cur = cur.parentNode; + // Find primary matches + if ( matcher ) { + matcher( matcherIn, matcherOut, context, xml ); } - al = ap.length; - bl = bp.length; + // Apply postFilter + if ( postFilter ) { + temp = condense( matcherOut, postMap ); + postFilter( temp, [], context, xml ); - // Start walking down the tree looking for a discrepancy - for ( var i = 0; i < al && i < bl; i++ ) { - if ( ap[i] !== bp[i] ) { - return siblingCheck( ap[i], bp[i] ); + // 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); + } } } - // We ended someplace up the tree so do a sibling check - return i === al ? - siblingCheck( a, bp[i], -1 ) : - siblingCheck( ap[i], b, 1 ); - }; - - siblingCheck = function( a, b, ret ) { - if ( a === b ) { - return ret; - } + 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 ); + } - var cur = a.nextSibling; + // Move matched elements from seed to results to keep them synchronized + i = matcherOut.length; + while ( i-- ) { + if ( (elem = matcherOut[i]) && + (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) { - while ( cur ) { - if ( cur === b ) { - return -1; + seed[temp] = !(results[temp] = elem); + } + } } - cur = cur.nextSibling; + // 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 ); + } } - - return 1; - }; + }); } -// Check to see if the browser returns elements by name when -// querying by getElementById (and provide a workaround) -(function(){ - // We're going to inject a fake input element with a specified name - var form = document.createElement("div"), - id = "script" + (new Date()).getTime(), - root = document.documentElement; - - form.innerHTML = "<a name='" + id + "'/>"; - - // Inject it into the root element, check its status, and remove it quickly - root.insertBefore( form, root.firstChild ); - - // The workaround has to do additional checks after a getElementById - // Which slows things down for other browsers (hence the branching) - if ( document.getElementById( id ) ) { - Expr.find.ID = function( match, context, isXML ) { - if ( typeof context.getElementById !== "undefined" && !isXML ) { - var m = context.getElementById(match[1]); - - return m ? - m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? - [m] : - undefined : - []; - } - }; - - Expr.filter.ID = function( elem, match ) { - var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); - - return elem.nodeType === 1 && node && node.nodeValue === match; - }; - } - - root.removeChild( form ); - - // release memory in IE - root = form = null; -})(); - -(function(){ - // Check to see if the browser returns only elements - // when doing getElementsByTagName("*") - - // Create a fake element - var div = document.createElement("div"); - div.appendChild( document.createComment("") ); - - // Make sure no comments are found - if ( div.getElementsByTagName("*").length > 0 ) { - Expr.find.TAG = function( match, context ) { - var results = context.getElementsByTagName( match[1] ); - - // Filter out possible comments - if ( match[1] === "*" ) { - var tmp = []; - - for ( var i = 0; results[i]; i++ ) { - if ( results[i].nodeType === 1 ) { - tmp.push( results[i] ); +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.call( checkContext, elem ) > -1; + }, implicitRelative, true ), + matchers = [ function( elem, context, xml ) { + return ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( + (checkContext = context).nodeType ? + matchContext( elem, context, xml ) : + matchAnyContext( elem, context, xml ) ); + } ]; + + 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; } } - - results = tmp; + return setMatcher( + i > 1 && elementMatcher( matchers ), + i > 1 && toSelector( tokens.slice( 0, i - 1 ) ).replace( rtrim, "$1" ), + matcher, + i < j && matcherFromTokens( tokens.slice( i, j ) ), + j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), + j < len && toSelector( tokens ) + ); } - - return results; - }; - } - - // Check to see if an attribute returns normalized href attributes - div.innerHTML = "<a href='#'></a>"; - - if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && - div.firstChild.getAttribute("href") !== "#" ) { - - Expr.attrHandle.href = function( elem ) { - return elem.getAttribute( "href", 2 ); - }; + matchers.push( matcher ); + } } - // release memory in IE - div = null; -})(); - -if ( document.querySelectorAll ) { - (function(){ - var oldSizzle = Sizzle, - div = document.createElement("div"), - id = "__sizzle__"; - - div.innerHTML = "<p class='TEST'></p>"; + return elementMatcher( matchers ); +} - // Safari can't handle uppercase or unicode characters when - // in quirks mode. - if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { - return; - } - - Sizzle = function( query, context, extra, seed ) { - context = context || document; - - // Only use querySelectorAll on non-XML documents - // (ID selectors don't work in non-HTML documents) - if ( !seed && !Sizzle.isXML(context) ) { - // See if we find a selector to speed up - var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); - - if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { - // Speed-up: Sizzle("TAG") - if ( match[1] ) { - return makeArray( context.getElementsByTagName( query ), extra ); - - // Speed-up: Sizzle(".CLASS") - } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { - return makeArray( context.getElementsByClassName( match[2] ), extra ); - } - } - - if ( context.nodeType === 9 ) { - // Speed-up: Sizzle("body") - // The body element only exists once, optimize finding it - if ( query === "body" && context.body ) { - return makeArray( [ context.body ], extra ); - - // Speed-up: Sizzle("#ID") - } else if ( match && match[3] ) { - var elem = context.getElementById( match[3] ); - - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - if ( elem && elem.parentNode ) { - // Handle the case where IE and Opera return items - // by name instead of ID - if ( elem.id === match[3] ) { - return makeArray( [ elem ], extra ); - } - - } else { - return makeArray( [], extra ); +function matcherFromGroupMatchers( elementMatchers, setMatchers ) { + // A counter to specify which element is currently being matched + var matcherCachedRuns = 0, + bySet = setMatchers.length > 0, + byElement = elementMatchers.length > 0, + superMatcher = function( seed, context, xml, results, expandContext ) { + var elem, j, matcher, + setMatched = [], + matchedCount = 0, + i = "0", + unmatched = seed && [], + outermost = expandContext != null, + contextBackup = outermostContext, + // We must always have either seed elements or context + elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ), + // Use integer dirruns iff this is the outermost matcher + dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1); + + if ( outermost ) { + outermostContext = context !== document && context; + cachedruns = matcherCachedRuns; + } + + // Add elements passing elementMatchers directly to results + // Keep `i` a string if there are no elements so `matchedCount` will be "00" below + for ( ; (elem = elems[i]) != null; i++ ) { + if ( byElement && elem ) { + j = 0; + while ( (matcher = elementMatchers[j++]) ) { + if ( matcher( elem, context, xml ) ) { + results.push( elem ); + break; } } - - try { - return makeArray( context.querySelectorAll(query), extra ); - } catch(qsaError) {} - - // qSA works strangely on Element-rooted queries - // We can work around this by specifying an extra ID on the root - // and working up from there (Thanks to Andrew Dupont for the technique) - // IE 8 doesn't work on object elements - } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { - var oldContext = context, - old = context.getAttribute( "id" ), - nid = old || id, - hasParent = context.parentNode, - relativeHierarchySelector = /^\s*[+~]/.test( query ); + if ( outermost ) { + dirruns = dirrunsUnique; + cachedruns = ++matcherCachedRuns; + } + } - if ( !old ) { - context.setAttribute( "id", nid ); - } else { - nid = nid.replace( /'/g, "\\$&" ); + // Track unmatched elements for set filters + if ( bySet ) { + // They will have gone through all possible matchers + if ( (elem = !matcher && elem) ) { + matchedCount--; } - if ( relativeHierarchySelector && hasParent ) { - context = context.parentNode; + + // Lengthen the array for every element, matched or not + if ( seed ) { + unmatched.push( elem ); } + } + } - try { - if ( !relativeHierarchySelector || hasParent ) { - return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra ); - } + // Apply set filters to unmatched elements + matchedCount += i; + if ( bySet && i !== matchedCount ) { + j = 0; + while ( (matcher = setMatchers[j++]) ) { + matcher( unmatched, setMatched, context, xml ); + } - } catch(pseudoError) { - } finally { - if ( !old ) { - oldContext.removeAttribute( "id" ); + 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 ); } - } - - return oldSizzle(query, context, extra, seed); - }; - for ( var prop in oldSizzle ) { - Sizzle[ prop ] = oldSizzle[ prop ]; - } + // Add matches to results + push.apply( results, setMatched ); - // release memory in IE - div = null; - })(); -} - -(function(){ - var html = document.documentElement, - matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector; + // Seedless set matches succeeding multiple successful matchers stipulate sorting + if ( outermost && !seed && setMatched.length > 0 && + ( matchedCount + setMatchers.length ) > 1 ) { - if ( matches ) { - // Check to see if it's possible to do matchesSelector - // on a disconnected node (IE 9 fails this) - var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ), - pseudoWorks = false; + Sizzle.uniqueSort( results ); + } + } - try { - // This should fail with an exception - // Gecko does not error, returns false instead - matches.call( document.documentElement, "[test!='']:sizzle" ); - - } catch( pseudoError ) { - pseudoWorks = true; - } - - Sizzle.matchesSelector = function( node, expr ) { - // Make sure that attribute selectors are quoted - expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); - - if ( !Sizzle.isXML( node ) ) { - try { - if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { - var ret = matches.call( node, expr ); - - // IE 9's matchesSelector returns false on disconnected nodes - if ( ret || !disconnectedMatch || - // As well, disconnected nodes are said to be in a document - // fragment in IE 9, so check for that - node.document && node.document.nodeType !== 11 ) { - return ret; - } - } - } catch(e) {} + // Override manipulation of globals by nested matchers + if ( outermost ) { + dirruns = dirrunsUnique; + outermostContext = contextBackup; } - return Sizzle(expr, null, null, [node]).length > 0; + return unmatched; }; - } -})(); -(function(){ - var div = document.createElement("div"); + return bySet ? + markFunction( superMatcher ) : + superMatcher; +} - div.innerHTML = "<div class='test e'></div><div class='test'></div>"; +compile = Sizzle.compile = function( selector, group /* 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 ( !group ) { + group = tokenize( selector ); + } + i = group.length; + while ( i-- ) { + cached = matcherFromTokens( group[i] ); + if ( cached[ expando ] ) { + setMatchers.push( cached ); + } else { + elementMatchers.push( cached ); + } + } - // Opera can't find a second classname (in 9.6) - // Also, make sure that getElementsByClassName actually exists - if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) { - return; + // Cache the compiled function + cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); } + return cached; +}; - // Safari caches class attributes, doesn't catch changes (in 3.2) - div.lastChild.className = "e"; - - if ( div.getElementsByClassName("e").length === 1 ) { - return; +function multipleContexts( selector, contexts, results ) { + var i = 0, + len = contexts.length; + for ( ; i < len; i++ ) { + Sizzle( selector, contexts[i], results ); } - - Expr.order.splice(1, 0, "CLASS"); - Expr.find.CLASS = function( match, context, isXML ) { - if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { - return context.getElementsByClassName(match[1]); - } - }; - - // release memory in IE - div = null; -})(); - -function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { - for ( var i = 0, l = checkSet.length; i < l; i++ ) { - var elem = checkSet[i]; - - if ( elem ) { - var match = false; + return results; +} - elem = elem[dir]; +function select( selector, context, results, seed ) { + var i, tokens, token, type, find, + match = tokenize( selector ); - while ( elem ) { - if ( elem[ expando ] === doneName ) { - match = checkSet[elem.sizset]; - break; - } + if ( !seed ) { + // Try to minimize operations if there is only one group + if ( match.length === 1 ) { - if ( elem.nodeType === 1 && !isXML ){ - elem[ expando ] = doneName; - elem.sizset = i; - } + // 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" && + context.nodeType === 9 && !documentIsXML && + Expr.relative[ tokens[1].type ] ) { - if ( elem.nodeName.toLowerCase() === cur ) { - match = elem; - break; + context = Expr.find["ID"]( token.matches[0].replace( runescape, funescape ), context )[0]; + if ( !context ) { + return results; } - elem = elem[dir]; + selector = selector.slice( tokens.shift().value.length ); } - checkSet[i] = match; - } - } -} - -function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { - for ( var i = 0, l = checkSet.length; i < l; i++ ) { - var elem = checkSet[i]; - - if ( elem ) { - var match = false; - - elem = elem[dir]; + // Fetch a seed set for right-to-left matching + i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; + while ( i-- ) { + token = tokens[i]; - while ( elem ) { - if ( elem[ expando ] === doneName ) { - match = checkSet[elem.sizset]; + // Abort if we hit a combinator + if ( Expr.relative[ (type = token.type) ] ) { break; } - - if ( elem.nodeType === 1 ) { - if ( !isXML ) { - elem[ expando ] = doneName; - elem.sizset = i; - } - - if ( typeof cur !== "string" ) { - if ( elem === cur ) { - match = true; - 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 ) && 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, slice.call( seed, 0 ) ); + return results; } - } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { - match = elem; break; } } - - elem = elem[dir]; } - - checkSet[i] = match; } } -} - -if ( document.documentElement.contains ) { - Sizzle.contains = function( a, b ) { - return a !== b && (a.contains ? a.contains(b) : true); - }; -} else if ( document.documentElement.compareDocumentPosition ) { - Sizzle.contains = function( a, b ) { - return !!(a.compareDocumentPosition(b) & 16); - }; - -} else { - Sizzle.contains = function() { - return false; - }; + // Compile and execute a filtering function + // Provide `match` to avoid retokenization if we modified the selector above + compile( selector, match )( + seed, + context, + documentIsXML, + results, + rsibling.test( selector ) + ); + return results; } -Sizzle.isXML = function( elem ) { - // documentElement is verified for cases where it doesn't yet exist - // (such as loading iframes in IE - #4833) - var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; +// Deprecated +Expr.pseudos["nth"] = Expr.pseudos["eq"]; - return documentElement ? documentElement.nodeName !== "HTML" : false; -}; +// Easy API for creating new setFilters +function setFilters() {} +Expr.filters = setFilters.prototype = Expr.pseudos; +Expr.setFilters = new setFilters(); -var posProcess = function( selector, context, seed ) { - var match, - tmpSet = [], - later = "", - root = context.nodeType ? [context] : context; +// Initialize with the default document +setDocument(); - // Position selectors must be done after the filter - // And so must :not(positional) so we move all PSEUDOs to the end - while ( (match = Expr.match.PSEUDO.exec( selector )) ) { - later += match[0]; - selector = selector.replace( Expr.match.PSEUDO, "" ); - } - - selector = Expr.relative[selector] ? selector + "*" : selector; - - for ( var i = 0, l = root.length; i < l; i++ ) { - Sizzle( selector, root[i], tmpSet, seed ); - } - - return Sizzle.filter( later, tmpSet ); -}; - -// EXPOSE // Override sizzle attribute retrieval Sizzle.attr = jQuery.attr; -Sizzle.selectors.attrMap = {}; jQuery.find = Sizzle; jQuery.expr = Sizzle.selectors; -jQuery.expr[":"] = jQuery.expr.filters; +jQuery.expr[":"] = jQuery.expr.pseudos; jQuery.unique = Sizzle.uniqueSort; jQuery.text = Sizzle.getText; jQuery.isXMLDoc = Sizzle.isXML; jQuery.contains = Sizzle.contains; -})(); - - +})( window ); var runtil = /Until$/, - rparentsprev = /^(?:parents|prevUntil|prevAll)/, - // Note: This RegExp should be improved, or likely pulled from Sizzle - rmultiselector = /,/, + rparentsprev = /^(?:parents|prev(?:Until|All))/, isSimple = /^.[^:#\[\.,]*$/, - slice = Array.prototype.slice, - POS = jQuery.expr.match.POS, + rneedsContext = jQuery.expr.match.needsContext, // methods guaranteed to produce a unique set when starting from a unique set guaranteedUnique = { children: true, @@ -5318,46 +5557,38 @@ var runtil = /Until$/, jQuery.fn.extend({ find: function( selector ) { - var self = this, - i, l; + var i, ret, self, + len = this.length; if ( typeof selector !== "string" ) { - return jQuery( selector ).filter(function() { - for ( i = 0, l = self.length; i < l; i++ ) { + self = this; + return this.pushStack( jQuery( selector ).filter(function() { + for ( i = 0; i < len; i++ ) { if ( jQuery.contains( self[ i ], this ) ) { return true; } } - }); + }) ); } - var ret = this.pushStack( "", "find", selector ), - length, n, r; - - for ( i = 0, l = this.length; i < l; i++ ) { - length = ret.length; - jQuery.find( selector, this[i], ret ); - - if ( i > 0 ) { - // Make sure that the results are unique - for ( n = length; n < ret.length; n++ ) { - for ( r = 0; r < length; r++ ) { - if ( ret[r] === ret[n] ) { - ret.splice(n--, 1); - break; - } - } - } - } + ret = []; + for ( i = 0; i < len; i++ ) { + jQuery.find( selector, this[ 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; return ret; }, has: function( target ) { - var targets = jQuery( target ); + var i, + targets = jQuery( target, this ), + len = targets.length; + return this.filter(function() { - for ( var i = 0, l = targets.length; i < l; i++ ) { + for ( i = 0; i < len; i++ ) { if ( jQuery.contains( this, targets[i] ) ) { return true; } @@ -5366,71 +5597,46 @@ jQuery.fn.extend({ }, not: function( selector ) { - return this.pushStack( winnow(this, selector, false), "not", selector); + return this.pushStack( winnow(this, selector, false) ); }, filter: function( selector ) { - return this.pushStack( winnow(this, selector, true), "filter", selector ); + return this.pushStack( winnow(this, selector, true) ); }, is: function( selector ) { - return !!selector && ( + return !!selector && ( typeof selector === "string" ? - // If this is a positional selector, check membership in the returned set + // 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". - POS.test( selector ) ? + rneedsContext.test( selector ) ? jQuery( selector, this.context ).index( this[0] ) >= 0 : jQuery.filter( selector, this ).length > 0 : this.filter( selector ).length > 0 ); }, closest: function( selectors, context ) { - var ret = [], i, l, cur = this[0]; - - // Array (deprecated as of jQuery 1.7) - if ( jQuery.isArray( selectors ) ) { - var level = 1; - - while ( cur && cur.ownerDocument && cur !== context ) { - for ( i = 0; i < selectors.length; i++ ) { - - if ( jQuery( cur ).is( selectors[ i ] ) ) { - ret.push({ selector: selectors[ i ], elem: cur, level: level }); - } - } - - cur = cur.parentNode; - level++; - } - - return ret; - } - - // String - var pos = POS.test( selectors ) || typeof selectors !== "string" ? + var cur, + i = 0, + l = this.length, + ret = [], + pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? jQuery( selectors, context || this.context ) : 0; - for ( i = 0, l = this.length; i < l; i++ ) { + for ( ; i < l; i++ ) { cur = this[i]; - while ( cur ) { + while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) { if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { ret.push( cur ); break; - - } else { - cur = cur.parentNode; - if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) { - break; - } } + cur = cur.parentNode; } } - ret = ret.length > 1 ? jQuery.unique( ret ) : ret; - - return this.pushStack( ret, "closest", selectors ); + return this.pushStack( ret.length > 1 ? jQuery.unique( ret ) : ret ); }, // Determine the position of an element within @@ -5439,7 +5645,7 @@ jQuery.fn.extend({ // No argument, return index in parent if ( !elem ) { - return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1; + return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1; } // index in selector @@ -5459,20 +5665,24 @@ jQuery.fn.extend({ jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), all = jQuery.merge( this.get(), set ); - return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? - all : - jQuery.unique( all ) ); + return this.pushStack( jQuery.unique(all) ); }, - andSelf: function() { - return this.add( this.prevObject ); + addBack: function( selector ) { + return this.add( selector == null ? + this.prevObject : this.prevObject.filter(selector) + ); } }); -// A painfully simple check to see if an element is disconnected -// from a document (should be improved, where feasible). -function isDisconnected( node ) { - return !node || !node.parentNode || node.parentNode.nodeType === 11; +jQuery.fn.andSelf = jQuery.fn.addBack; + +function sibling( cur, dir ) { + do { + cur = cur[ dir ]; + } while ( cur && cur.nodeType !== 1 ); + + return cur; } jQuery.each({ @@ -5487,10 +5697,10 @@ jQuery.each({ return jQuery.dir( elem, "parentNode", until ); }, next: function( elem ) { - return jQuery.nth( elem, 2, "nextSibling" ); + return sibling( elem, "nextSibling" ); }, prev: function( elem ) { - return jQuery.nth( elem, 2, "previousSibling" ); + return sibling( elem, "previousSibling" ); }, nextAll: function( elem ) { return jQuery.dir( elem, "nextSibling" ); @@ -5505,7 +5715,7 @@ jQuery.each({ return jQuery.dir( elem, "previousSibling", until ); }, siblings: function( elem ) { - return jQuery.sibling( elem.parentNode.firstChild, elem ); + return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); }, children: function( elem ) { return jQuery.sibling( elem.firstChild ); @@ -5513,7 +5723,7 @@ jQuery.each({ contents: function( elem ) { return jQuery.nodeName( elem, "iframe" ) ? elem.contentDocument || elem.contentWindow.document : - jQuery.makeArray( elem.childNodes ); + jQuery.merge( [], elem.childNodes ); } }, function( name, fn ) { jQuery.fn[ name ] = function( until, selector ) { @@ -5529,11 +5739,11 @@ jQuery.each({ ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; - if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { + if ( this.length > 1 && rparentsprev.test( name ) ) { ret = ret.reverse(); } - return this.pushStack( ret, name, slice.call( arguments ).join(",") ); + return this.pushStack( ret ); }; }); @@ -5561,19 +5771,6 @@ jQuery.extend({ return matched; }, - nth: function( cur, result, dir, elem ) { - result = result || 1; - var num = 0; - - for ( ; cur; cur = cur[dir] ) { - if ( cur.nodeType === 1 && ++num === result ) { - break; - } - } - - return cur; - }, - sibling: function( n, elem ) { var r = []; @@ -5601,7 +5798,7 @@ function winnow( elements, qualifier, keep ) { }); } else if ( qualifier.nodeType ) { - return jQuery.grep(elements, function( elem, i ) { + return jQuery.grep(elements, function( elem ) { return ( elem === qualifier ) === keep; }); @@ -5617,17 +5814,13 @@ function winnow( elements, qualifier, keep ) { } } - return jQuery.grep(elements, function( elem, i ) { + return jQuery.grep(elements, function( elem ) { return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; }); } - - - - function createSafeFragment( document ) { var list = nodeNames.split( "|" ), - safeFrag = document.createDocumentFragment(); + safeFrag = document.createDocumentFragment(); if ( safeFrag.createElement ) { while ( list.length ) { @@ -5639,57 +5832,52 @@ function createSafeFragment( document ) { return safeFrag; } -var nodeNames = "abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|" + +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+="(?:\d+|null)"/g, + 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:]+)[^>]*)\/>/ig, + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, rtagName = /<([\w:]+)/, rtbody = /<tbody/i, rhtml = /<|&#?\w+;/, - rnoInnerhtml = /<(?:script|style)/i, - rnocache = /<(?:script|object|embed|option|style)/i, - rnoshimcache = new RegExp("<(?:" + nodeNames + ")", "i"), + rnoInnerhtml = /<(?:script|style|link)/i, + manipulation_rcheckableType = /^(?:checkbox|radio)$/i, // checked="checked" or checked rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, - rscriptType = /\/(java|ecma)script/i, - rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/, + rscriptType = /^$|\/(?:java|ecma)script/i, + rscriptTypeMasked = /^true\/(.*)/, + rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g, + + // We have to close these tags to support XHTML (#13200) wrapMap = { option: [ 1, "<select multiple='multiple'>", "</select>" ], legend: [ 1, "<fieldset>", "</fieldset>" ], + area: [ 1, "<map>", "</map>" ], + param: [ 1, "<object>", "</object>" ], thead: [ 1, "<table>", "</table>" ], tr: [ 2, "<table><tbody>", "</tbody></table>" ], - td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ], - area: [ 1, "<map>", "</map>" ], - _default: [ 0, "", "" ] + td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], + + // 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: jQuery.support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ] }, - safeFragment = createSafeFragment( document ); + 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; -// IE can't serialize <link> and <script> tags normally -if ( !jQuery.support.htmlSerialize ) { - wrapMap._default = [ 1, "div<div>", "</div>" ]; -} - jQuery.fn.extend({ - text: function( text ) { - if ( jQuery.isFunction(text) ) { - return this.each(function(i) { - var self = jQuery( this ); - - self.text( text.call(this, i, self.text()) ); - }); - } - - if ( typeof text !== "object" && text !== undefined ) { - return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); - } - - return jQuery.text( this ); + text: function( value ) { + return jQuery.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 ); }, wrapAll: function( html ) { @@ -5759,7 +5947,7 @@ jQuery.fn.extend({ append: function() { return this.domManip(arguments, true, function( elem ) { - if ( this.nodeType === 1 ) { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { this.appendChild( elem ); } }); @@ -5767,46 +5955,43 @@ jQuery.fn.extend({ prepend: function() { return this.domManip(arguments, true, function( elem ) { - if ( this.nodeType === 1 ) { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { this.insertBefore( elem, this.firstChild ); } }); }, before: function() { - if ( this[0] && this[0].parentNode ) { - return this.domManip(arguments, false, function( elem ) { + return this.domManip( arguments, false, function( elem ) { + if ( this.parentNode ) { this.parentNode.insertBefore( elem, this ); - }); - } else if ( arguments.length ) { - var set = jQuery.clean( arguments ); - set.push.apply( set, this.toArray() ); - return this.pushStack( set, "before", arguments ); - } + } + }); }, after: function() { - if ( this[0] && this[0].parentNode ) { - return this.domManip(arguments, false, function( elem ) { + return this.domManip( arguments, false, function( elem ) { + if ( this.parentNode ) { this.parentNode.insertBefore( elem, this.nextSibling ); - }); - } else if ( arguments.length ) { - var set = this.pushStack( this, "after", arguments ); - set.push.apply( set, jQuery.clean(arguments) ); - return set; - } + } + }); }, // keepData is for internal use only--do not document remove: function( selector, keepData ) { - for ( var i = 0, elem; (elem = this[i]) != null; i++ ) { - if ( !selector || jQuery.filter( selector, [ elem ] ).length ) { + var elem, + i = 0; + + for ( ; (elem = this[i]) != null; i++ ) { + if ( !selector || jQuery.filter( selector, [ elem ] ).length > 0 ) { if ( !keepData && elem.nodeType === 1 ) { - jQuery.cleanData( elem.getElementsByTagName("*") ); - jQuery.cleanData( [ elem ] ); + jQuery.cleanData( getAll( elem ) ); } if ( elem.parentNode ) { + if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) { + setGlobalEval( getAll( elem, "script" ) ); + } elem.parentNode.removeChild( elem ); } } @@ -5816,16 +6001,25 @@ jQuery.fn.extend({ }, empty: function() { - for ( var i = 0, elem; (elem = this[i]) != null; i++ ) { + var elem, + i = 0; + + for ( ; (elem = this[i]) != null; i++ ) { // Remove element nodes and prevent memory leaks if ( elem.nodeType === 1 ) { - jQuery.cleanData( elem.getElementsByTagName("*") ); + 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; @@ -5841,78 +6035,65 @@ jQuery.fn.extend({ }, html: function( value ) { - if ( value === undefined ) { - return this[0] && this[0].nodeType === 1 ? - this[0].innerHTML.replace(rinlinejQuery, "") : - null; + return jQuery.access( this, function( value ) { + var elem = this[0] || {}, + i = 0, + l = this.length; - // See if we can take a shortcut and just use innerHTML - } else if ( typeof value === "string" && !rnoInnerhtml.test( value ) && - (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) && - !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) { + if ( value === undefined ) { + return elem.nodeType === 1 ? + elem.innerHTML.replace( rinlinejQuery, "" ) : + undefined; + } - value = value.replace(rxhtmlTag, "<$1></$2>"); + // See if we can take a shortcut and just use innerHTML + if ( typeof value === "string" && !rnoInnerhtml.test( value ) && + ( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) && + ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) && + !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) { - try { - for ( var i = 0, l = this.length; i < l; i++ ) { - // Remove element nodes and prevent memory leaks - if ( this[i].nodeType === 1 ) { - jQuery.cleanData( this[i].getElementsByTagName("*") ); - this[i].innerHTML = value; - } - } + value = value.replace( rxhtmlTag, "<$1></$2>" ); - // If using innerHTML throws an exception, use the fallback method - } catch(e) { - this.empty().append( value ); - } - - } else if ( jQuery.isFunction( value ) ) { - this.each(function(i){ - var self = jQuery( this ); + 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; + } + } - self.html( value.call(this, i, self.html()) ); - }); + elem = 0; - } else { - this.empty().append( value ); - } + // If using innerHTML throws an exception, use the fallback method + } catch(e) {} + } - return this; + if ( elem ) { + this.empty().append( value ); + } + }, null, value, arguments.length ); }, replaceWith: function( value ) { - if ( this[0] && this[0].parentNode ) { - // Make sure that the elements are removed from the DOM before they are inserted - // this can help fix replacing a parent with child elements - if ( jQuery.isFunction( value ) ) { - return this.each(function(i) { - var self = jQuery(this), old = self.html(); - self.replaceWith( value.call( this, i, old ) ); - }); - } + var isFunc = jQuery.isFunction( value ); - if ( typeof value !== "string" ) { - value = jQuery( value ).detach(); - } + // Make sure that the elements are removed from the DOM before they are inserted + // this can help fix replacing a parent with child elements + if ( !isFunc && typeof value !== "string" ) { + value = jQuery( value ).not( this ).detach(); + } - return this.each(function() { - var next = this.nextSibling, - parent = this.parentNode; + return this.domManip( [ value ], true, function( elem ) { + var next = this.nextSibling, + parent = this.parentNode; + if ( parent ) { jQuery( this ).remove(); - - if ( next ) { - jQuery(next).before( value ); - } else { - jQuery(parent).append( value ); - } - }); - } else { - return this.length ? - this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) : - this; - } + parent.insertBefore( elem, next ); + } + }); }, detach: function( selector ) { @@ -5920,68 +6101,97 @@ jQuery.fn.extend({ }, domManip: function( args, table, callback ) { - var results, first, fragment, parent, + + // Flatten any nested arrays + args = core_concat.apply( [], args ); + + var first, node, hasScripts, + scripts, doc, fragment, + i = 0, + l = this.length, + set = this, + iNoClone = l - 1, value = args[0], - scripts = []; + isFunction = jQuery.isFunction( value ); // We can't cloneNode fragments that contain checked, in WebKit - if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) { - return this.each(function() { - jQuery(this).domManip( args, table, callback, true ); - }); - } - - if ( jQuery.isFunction(value) ) { - return this.each(function(i) { - var self = jQuery(this); - args[0] = value.call(this, i, table ? self.html() : undefined); + if ( isFunction || !( l <= 1 || typeof value !== "string" || jQuery.support.checkClone || !rchecked.test( value ) ) ) { + return this.each(function( index ) { + var self = set.eq( index ); + if ( isFunction ) { + args[0] = value.call( this, index, table ? self.html() : undefined ); + } self.domManip( args, table, callback ); }); } - if ( this[0] ) { - parent = value && value.parentNode; - - // If we're in a fragment, just use that instead of building a new one - if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) { - results = { fragment: parent }; - - } else { - results = jQuery.buildFragment( args, this, scripts ); - } - - fragment = results.fragment; + if ( l ) { + fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this ); + first = fragment.firstChild; if ( fragment.childNodes.length === 1 ) { - first = fragment = fragment.firstChild; - } else { - first = fragment.firstChild; + fragment = first; } if ( first ) { table = table && jQuery.nodeName( first, "tr" ); + 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" ) ); + } + } - for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) { callback.call( - table ? - root(this[i], first) : + table && jQuery.nodeName( this[i], "table" ) ? + findOrAppend( this[i], "tbody" ) : this[i], - // Make sure that we do not leak memory by inadvertently discarding - // the original fragment (which might have attached data) instead of - // using it; in addition, use the original fragment object for the last - // item instead of first because it can end up being emptied incorrectly - // in certain situations (Bug #8070). - // Fragments from the fragment cache must always be cloned and never used - // in place. - results.cacheable || ( l > 1 && i < lastIndex ) ? - jQuery.clone( fragment, true, true ) : - fragment + node, + i ); } - } - if ( scripts.length ) { - jQuery.each( scripts, evalScript ); + 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 ) { + // Hope ajax is available... + jQuery.ajax({ + url: node.src, + type: "GET", + dataType: "script", + async: false, + global: false, + "throws": true + }); + } else { + jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) ); + } + } + } + } + + // Fix #11809: Avoid leaking memory + fragment = first = null; } } @@ -5989,11 +6199,33 @@ jQuery.fn.extend({ } }); -function root( elem, cur ) { - return jQuery.nodeName(elem, "table") ? - (elem.getElementsByTagName("tbody")[0] || - elem.appendChild(elem.ownerDocument.createElement("tbody"))) : - elem; +function findOrAppend( elem, tag ) { + return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) ); +} + +// Replace/restore the type attribute of script elements for safe DOM manipulation +function disableScript( elem ) { + var attr = elem.getAttributeNode("type"); + elem.type = ( attr && attr.specified ) + "/" + 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 ) { @@ -6013,7 +6245,7 @@ function cloneCopyEvent( src, dest ) { for ( type in events ) { for ( i = 0, l = events[ type ].length; i < l; i++ ) { - jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data ); + jQuery.event.add( dest, type, events[ type ][ i ] ); } } } @@ -6024,41 +6256,54 @@ function cloneCopyEvent( src, dest ) { } } -function cloneFixAttributes( src, dest ) { - var nodeName; +function fixCloneNodeIssues( src, dest ) { + var nodeName, e, data; // We do not need to do anything for non-Elements if ( dest.nodeType !== 1 ) { return; } - // clearAttributes removes the attributes, which we don't want, - // but also removes the attachEvent events, which we *do* want - if ( dest.clearAttributes ) { - dest.clearAttributes(); - } + nodeName = dest.nodeName.toLowerCase(); + + // IE6-8 copies events bound via attachEvent when using cloneNode. + if ( !jQuery.support.noCloneEvent && dest[ jQuery.expando ] ) { + data = jQuery._data( dest ); + + for ( e in data.events ) { + jQuery.removeEvent( dest, e, data.handle ); + } - // mergeAttributes, in contrast, only merges back on the - // original attributes, not the events - if ( dest.mergeAttributes ) { - dest.mergeAttributes( src ); + // Event data gets referenced instead of copied if the expando gets copied too + dest.removeAttribute( jQuery.expando ); } - nodeName = dest.nodeName.toLowerCase(); + // 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; + } - // IE6-8 fail to clone children inside object elements that use - // the proprietary classid attribute value (rather than the type - // attribute) to identify the type of content to display - if ( nodeName === "object" ) { - 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 ( jQuery.support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) { + dest.innerHTML = src.innerHTML; + } - } else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) { + } else if ( nodeName === "input" && manipulation_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 - if ( src.checked ) { - dest.defaultChecked = dest.checked = src.checked; - } + + 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" @@ -6069,69 +6314,15 @@ function cloneFixAttributes( src, dest ) { // IE6-8 fails to return the selected option to the default selected // state when cloning options } else if ( nodeName === "option" ) { - dest.selected = src.defaultSelected; + 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; } - - // Event data gets referenced instead of copied if the expando - // gets copied too - dest.removeAttribute( jQuery.expando ); } -jQuery.buildFragment = function( args, nodes, scripts ) { - var fragment, cacheable, cacheresults, doc, - first = args[ 0 ]; - - // nodes may contain either an explicit document object, - // a jQuery collection or context object. - // If nodes[0] contains a valid object to assign to doc - if ( nodes && nodes[0] ) { - doc = nodes[0].ownerDocument || nodes[0]; - } - - // Ensure that an attr object doesn't incorrectly stand in as a document object - // Chrome and Firefox seem to allow this to occur and will throw exception - // Fixes #8950 - if ( !doc.createDocumentFragment ) { - doc = document; - } - - // Only cache "small" (1/2 KB) HTML strings that are associated with the main document - // Cloning options loses the selected state, so don't cache them - // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment - // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache - // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501 - if ( args.length === 1 && typeof first === "string" && first.length < 512 && doc === document && - first.charAt(0) === "<" && !rnocache.test( first ) && - (jQuery.support.checkClone || !rchecked.test( first )) && - (jQuery.support.html5Clone || !rnoshimcache.test( first )) ) { - - cacheable = true; - - cacheresults = jQuery.fragments[ first ]; - if ( cacheresults && cacheresults !== 1 ) { - fragment = cacheresults; - } - } - - if ( !fragment ) { - fragment = doc.createDocumentFragment(); - jQuery.clean( args, doc, fragment, scripts ); - } - - if ( cacheable ) { - jQuery.fragments[ first ] = cacheresults ? fragment : 1; - } - - return { fragment: fragment, cacheable: cacheable }; -}; - -jQuery.fragments = {}; - jQuery.each({ appendTo: "append", prependTo: "prepend", @@ -6140,335 +6331,436 @@ jQuery.each({ replaceAll: "replaceWith" }, function( name, original ) { jQuery.fn[ name ] = function( selector ) { - var ret = [], + var elems, + i = 0, + ret = [], insert = jQuery( selector ), - parent = this.length === 1 && this[0].parentNode; - - if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) { - insert[ original ]( this[0] ); - return this; + last = insert.length - 1; - } else { - for ( var i = 0, l = insert.length; i < l; i++ ) { - var elems = ( i > 0 ? this.clone(true) : this ).get(); - jQuery( insert[i] )[ original ]( elems ); - ret = ret.concat( elems ); - } + for ( ; i <= last; i++ ) { + elems = i === last ? this : this.clone(true); + jQuery( insert[i] )[ original ]( elems ); - return this.pushStack( ret, name, insert.selector ); + // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get() + core_push.apply( ret, elems.get() ); } + + return this.pushStack( ret ); }; }); -function getAll( elem ) { - if ( typeof elem.getElementsByTagName !== "undefined" ) { - return elem.getElementsByTagName( "*" ); - - } else if ( typeof elem.querySelectorAll !== "undefined" ) { - return elem.querySelectorAll( "*" ); +function getAll( context, tag ) { + var elems, elem, + i = 0, + found = typeof context.getElementsByTagName !== core_strundefined ? context.getElementsByTagName( tag || "*" ) : + typeof context.querySelectorAll !== core_strundefined ? context.querySelectorAll( tag || "*" ) : + undefined; - } else { - return []; + 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 clean, fixes the defaultChecked property +// Used in buildFragment, fixes the defaultChecked property function fixDefaultChecked( elem ) { - if ( elem.type === "checkbox" || elem.type === "radio" ) { + if ( manipulation_rcheckableType.test( elem.type ) ) { elem.defaultChecked = elem.checked; } } -// Finds all inputs and passes them to fixDefaultChecked -function findInputs( elem ) { - var nodeName = ( elem.nodeName || "" ).toLowerCase(); - if ( nodeName === "input" ) { - fixDefaultChecked( elem ); - // Skip scripts, get other children - } else if ( nodeName !== "script" && typeof elem.getElementsByTagName !== "undefined" ) { - jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked ); - } -} - -// Derived From: http://www.iecss.com/shimprove/javascript/shimprove.1-0-1.js -function shimCloneNode( elem ) { - var div = document.createElement( "div" ); - safeFragment.appendChild( div ); - - div.innerHTML = elem.outerHTML; - return div.firstChild; -} jQuery.extend({ clone: function( elem, dataAndEvents, deepDataAndEvents ) { - var srcElements, - destElements, - i, - // IE<=8 does not properly clone detached, unknown element nodes - clone = jQuery.support.html5Clone || !rnoshimcache.test( "<" + elem.nodeName ) ? - elem.cloneNode( true ) : - shimCloneNode( elem ); + var destElements, node, clone, i, srcElements, + inPage = jQuery.contains( elem.ownerDocument, elem ); + + if ( jQuery.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 ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) && (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { - // IE copies events bound via attachEvent when using cloneNode. - // Calling detachEvent on the clone will also remove the events - // from the original. In order to get around this, we use some - // proprietary methods to clear the events. Thanks to MooTools - // guys for this hotness. - - cloneFixAttributes( elem, clone ); - // Using Sizzle here is crazy slow, so we use getElementsByTagName instead - srcElements = getAll( elem ); + // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 destElements = getAll( clone ); + srcElements = getAll( elem ); - // Weird iteration because IE will replace the length property - // with an element if you are cloning the body and one of the - // elements on the page has a name or id of "length" - for ( i = 0; srcElements[i]; ++i ) { + // 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] ) { - cloneFixAttributes( srcElements[i], destElements[i] ); + fixCloneNodeIssues( node, destElements[i] ); } } } // Copy the events from the original to the clone if ( dataAndEvents ) { - cloneCopyEvent( elem, clone ); - if ( deepDataAndEvents ) { - srcElements = getAll( elem ); - destElements = getAll( clone ); + srcElements = srcElements || getAll( elem ); + destElements = destElements || getAll( clone ); - for ( i = 0; srcElements[i]; ++i ) { - cloneCopyEvent( srcElements[i], destElements[i] ); + for ( i = 0; (node = srcElements[i]) != null; i++ ) { + cloneCopyEvent( node, destElements[i] ); } + } else { + cloneCopyEvent( elem, clone ); } } - srcElements = destElements = null; + // 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; }, - clean: function( elems, context, fragment, scripts ) { - var checkScriptType; + buildFragment: function( elems, context, scripts, selection ) { + var j, elem, contains, + tmp, tag, tbody, wrap, + l = elems.length, - context = context || document; + // Ensure a safe fragment + safe = createSafeFragment( context ), - // !context.createElement fails in IE with an error but returns typeof 'object' - if ( typeof context.createElement === "undefined" ) { - context = context.ownerDocument || context[0] && context[0].ownerDocument || document; - } + nodes = [], + i = 0; - var ret = [], j; + for ( ; i < l; i++ ) { + elem = elems[ i ]; - for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { - if ( typeof elem === "number" ) { - elem += ""; - } + if ( elem || elem === 0 ) { - if ( !elem ) { - continue; - } + // 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 string into DOM nodes - if ( typeof elem === "string" ) { - if ( !rhtml.test( elem ) ) { - elem = context.createTextNode( elem ); + // Convert html into DOM nodes } else { - // Fix "XHTML"-style tags in all browsers - elem = elem.replace(rxhtmlTag, "<$1></$2>"); - - // Trim whitespace, otherwise indexOf won't work as expected - var tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(), - wrap = wrapMap[ tag ] || wrapMap._default, - depth = wrap[0], - div = context.createElement("div"); - - // Append wrapper element to unknown element safe doc fragment - if ( context === document ) { - // Use the fragment we've already created for this document - safeFragment.appendChild( div ); - } else { - // Use a fragment created with the owner document - createSafeFragment( context ).appendChild( div ); - } + 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></$2>" ) + wrap[2]; - // Go to html and back, then peel off extra wrappers - div.innerHTML = wrap[1] + elem + wrap[2]; + // Descend through wrappers to the right content + j = wrap[0]; + while ( j-- ) { + tmp = tmp.lastChild; + } - // Move to the right depth - while ( depth-- ) { - div = div.lastChild; + // Manually add leading whitespace removed by IE + if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { + nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) ); } // Remove IE's autoinserted <tbody> from table fragments if ( !jQuery.support.tbody ) { // String was a <table>, *may* have spurious <tbody> - var hasBody = rtbody.test(elem), - tbody = tag === "table" && !hasBody ? - div.firstChild && div.firstChild.childNodes : - - // String was a bare <thead> or <tfoot> - wrap[1] === "<table>" && !hasBody ? - div.childNodes : - []; - - for ( j = tbody.length - 1; j >= 0 ; --j ) { - if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) { - tbody[ j ].parentNode.removeChild( tbody[ j ] ); + elem = tag === "table" && !rtbody.test( elem ) ? + tmp.firstChild : + + // String was a bare <thead> or <tfoot> + wrap[1] === "<table>" && !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 ); } } } - // IE completely kills leading whitespace when innerHTML is used - if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { - div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild ); - } + jQuery.merge( nodes, tmp.childNodes ); - elem = div.childNodes; - } - } + // Fix #12392 for WebKit and IE > 9 + tmp.textContent = ""; - // Resets defaultChecked for any radios and checkboxes - // about to be appended to the DOM in IE 6/7 (#8060) - var len; - if ( !jQuery.support.appendChecked ) { - if ( elem[0] && typeof (len = elem.length) === "number" ) { - for ( j = 0; j < len; j++ ) { - findInputs( elem[j] ); + // Fix #12392 for oldIE + while ( tmp.firstChild ) { + tmp.removeChild( tmp.firstChild ); } - } else { - findInputs( elem ); + + // Remember the top-level container for proper cleanup + tmp = safe.lastChild; } } + } - if ( elem.nodeType ) { - ret.push( elem ); - } else { - ret = jQuery.merge( ret, elem ); - } + // Fix #11356: Clear elements from fragment + if ( tmp ) { + safe.removeChild( tmp ); } - if ( fragment ) { - checkScriptType = function( elem ) { - return !elem.type || rscriptType.test( elem.type ); - }; - for ( i = 0; ret[i]; i++ ) { - if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { - scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); + // Reset defaultChecked for any radios and checkboxes + // about to be appended to the DOM in IE 6/7 (#8060) + if ( !jQuery.support.appendChecked ) { + jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked ); + } - } else { - if ( ret[i].nodeType === 1 ) { - var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), checkScriptType ); + 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 ); + } - ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) ); + // Capture executables + if ( scripts ) { + j = 0; + while ( (elem = tmp[ j++ ]) ) { + if ( rscriptType.test( elem.type || "" ) ) { + scripts.push( elem ); } - fragment.appendChild( ret[i] ); } } } - return ret; + tmp = null; + + return safe; }, - cleanData: function( elems ) { - var data, id, + cleanData: function( elems, /* internal */ acceptData ) { + var elem, type, id, data, + i = 0, + internalKey = jQuery.expando, cache = jQuery.cache, - special = jQuery.event.special, - deleteExpando = jQuery.support.deleteExpando; + deleteExpando = jQuery.support.deleteExpando, + special = jQuery.event.special; - for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { - if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) { - continue; - } + for ( ; (elem = elems[i]) != null; i++ ) { - id = elem[ jQuery.expando ]; + if ( acceptData || jQuery.acceptData( elem ) ) { - if ( id ) { - data = cache[ id ]; + id = elem[ internalKey ]; + data = id && cache[ id ]; - if ( data && data.events ) { - for ( var type in data.events ) { - if ( special[ type ] ) { - jQuery.event.remove( elem, type ); + 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 ); + // This is a shortcut to avoid jQuery.event.remove's overhead + } else { + jQuery.removeEvent( elem, type, data.handle ); + } } } - // Null the DOM reference to avoid IE6/7/8 leak (#7054) - if ( data.handle ) { - data.handle.elem = null; - } - } + // Remove cache only if it was not already removed by jQuery.event.remove + if ( cache[ id ] ) { - if ( deleteExpando ) { - delete elem[ jQuery.expando ]; + delete cache[ id ]; - } else if ( elem.removeAttribute ) { - elem.removeAttribute( jQuery.expando ); - } + // 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 ]; - delete cache[ id ]; + } else if ( typeof elem.removeAttribute !== core_strundefined ) { + elem.removeAttribute( internalKey ); + + } else { + elem[ internalKey ] = null; + } + + core_deletedIds.push( id ); + } + } } } } }); +var iframe, getStyles, curCSS, + ralpha = /alpha\([^)]*\)/i, + ropacity = /opacity\s*=\s*([^)]*)/, + rposition = /^(top|right|bottom|left)$/, + // swappable if display is none or starts with table except "table", "table-cell", or "table-caption" + // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display + rdisplayswap = /^(none|table(?!-c[ea]).+)/, + rmargin = /^margin/, + rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ), + rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ), + rrelNum = new RegExp( "^([+-])=(" + core_pnum + ")", "i" ), + elemdisplay = { BODY: "block" }, -function evalScript( i, elem ) { - if ( elem.src ) { - jQuery.ajax({ - url: elem.src, - async: false, - dataType: "script" - }); - } else { - jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "/*$0*/" ) ); + cssShow = { position: "absolute", visibility: "hidden", display: "block" }, + cssNormalTransform = { + letterSpacing: 0, + fontWeight: 400 + }, + + cssExpand = [ "Top", "Right", "Bottom", "Left" ], + cssPrefixes = [ "Webkit", "O", "Moz", "ms" ]; + +// return a css property mapped to a potentially vendor prefixed property +function vendorPropName( style, name ) { + + // shortcut for names that are not vendor prefixed + if ( name in style ) { + return name; } - if ( elem.parentNode ) { - elem.parentNode.removeChild( elem ); + // check for vendor prefixed names + var capName = name.charAt(0).toUpperCase() + name.slice(1), + origName = name, + i = cssPrefixes.length; + + while ( i-- ) { + name = cssPrefixes[ i ] + capName; + if ( name in style ) { + return name; + } } + + return origName; } +function isHidden( 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 ); +} +function showHide( elements, show ) { + var display, elem, hidden, + values = [], + index = 0, + length = elements.length; + for ( ; index < length; index++ ) { + elem = elements[ index ]; + if ( !elem.style ) { + continue; + } -var ralpha = /alpha\([^)]*\)/i, - ropacity = /opacity=([^)]*)/, - // fixed for IE9, see #8346 - rupper = /([A-Z]|^ms)/g, - rnumpx = /^-?\d+(?:px)?$/i, - rnum = /^-?\d/, - rrelNum = /^([\-+])=([\-+.\de]+)/, + values[ index ] = jQuery._data( elem, "olddisplay" ); + display = elem.style.display; + if ( show ) { + // Reset the inline display of this element to learn if it is + // being hidden by cascaded rules or not + if ( !values[ index ] && display === "none" ) { + elem.style.display = ""; + } - cssShow = { position: "absolute", visibility: "hidden", display: "block" }, - cssWidth = [ "Left", "Right" ], - cssHeight = [ "Top", "Bottom" ], - curCSS, + // Set elements which have been overridden with display: none + // in a stylesheet to whatever the default browser style is + // for such an element + if ( elem.style.display === "" && isHidden( elem ) ) { + values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) ); + } + } else { - getComputedStyle, - currentStyle; + if ( !values[ index ] ) { + hidden = isHidden( elem ); -jQuery.fn.css = function( name, value ) { - // Setting 'undefined' is a no-op - if ( arguments.length === 2 && value === undefined ) { - return this; + if ( display && display !== "none" || !hidden ) { + jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) ); + } + } + } } - return jQuery.access( this, name, value, true, function( elem, name, value ) { - return value !== undefined ? - jQuery.style( elem, name, value ) : - jQuery.css( elem, name ); - }); -}; + // Set the display of most of the elements in a second loop + // to avoid the constant reflow + for ( index = 0; index < length; index++ ) { + elem = elements[ index ]; + if ( !elem.style ) { + continue; + } + if ( !show || elem.style.display === "none" || elem.style.display === "" ) { + elem.style.display = show ? values[ index ] || "" : "none"; + } + } + + return elements; +} + +jQuery.fn.extend({ + css: function( name, value ) { + return jQuery.access( this, function( elem, name, value ) { + var len, styles, + map = {}, + i = 0; + + if ( jQuery.isArray( name ) ) { + styles = getStyles( elem ); + len = name.length; + + for ( ; i < len; i++ ) { + map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); + } + + return map; + } + + return value !== undefined ? + jQuery.style( elem, name, value ) : + jQuery.css( elem, name ); + }, name, value, arguments.length > 1 ); + }, + show: function() { + return showHide( this, true ); + }, + hide: function() { + return showHide( this ); + }, + toggle: function( state ) { + var bool = typeof state === "boolean"; + + return this.each(function() { + if ( bool ? state : isHidden( this ) ) { + jQuery( this ).show(); + } else { + jQuery( this ).hide(); + } + }); + } +}); jQuery.extend({ // Add in style property hooks for overriding the default @@ -6478,11 +6770,8 @@ jQuery.extend({ get: function( elem, computed ) { if ( computed ) { // We should always get a number back from opacity - var ret = curCSS( elem, "opacity", "opacity" ); + var ret = curCSS( elem, "opacity" ); return ret === "" ? "1" : ret; - - } else { - return elem.style.opacity; } } } @@ -6490,6 +6779,7 @@ jQuery.extend({ // Exclude the following css properties to add px cssNumber: { + "columnCount": true, "fillOpacity": true, "fontWeight": true, "lineHeight": true, @@ -6515,10 +6805,15 @@ jQuery.extend({ } // Make sure that we're working with the right name - var ret, type, origName = jQuery.camelCase( name ), - style = elem.style, hooks = jQuery.cssHooks[ origName ]; + var ret, type, hooks, + origName = jQuery.camelCase( name ), + style = elem.style; + + name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) ); - name = jQuery.cssProps[ origName ] || origName; + // gets hook for the prefixed version + // followed by the unprefixed version + hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; // Check if we're setting a value if ( value !== undefined ) { @@ -6526,7 +6821,7 @@ jQuery.extend({ // convert relative number strings (+= or -=) to relative numbers. #7345 if ( type === "string" && (ret = rrelNum.exec( value )) ) { - value = ( +( ret[1] + 1) * +ret[2] ) + parseFloat( jQuery.css( elem, name ) ); + value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) ); // Fixes bug #9237 type = "number"; } @@ -6541,8 +6836,15 @@ jQuery.extend({ value += "px"; } + // Fixes #8908, it can be done more correctly by specifing setters in cssHooks, + // but it would mean to define eight (for every problematic property) identical functions + if ( !jQuery.support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) { + style[ name ] = "inherit"; + } + // If a hook was provided, use that value, otherwise just set the specified value - if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) { + if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) { + // Wrapped to prevent IE from throwing errors when 'invalid' values are provided // Fixes bug #5509 try { @@ -6561,82 +6863,312 @@ jQuery.extend({ } }, - css: function( elem, name, extra ) { - var ret, hooks; + css: function( elem, name, extra, styles ) { + var num, val, hooks, + origName = jQuery.camelCase( name ); // Make sure that we're working with the right name - name = jQuery.camelCase( name ); - hooks = jQuery.cssHooks[ name ]; - name = jQuery.cssProps[ name ] || name; + name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) ); - // cssFloat needs a special treatment - if ( name === "cssFloat" ) { - name = "float"; - } + // gets hook for the prefixed version + // followed by the unprefixed version + hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; // If a hook was provided get the computed value from there - if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) { - return ret; + if ( hooks && "get" in hooks ) { + val = hooks.get( elem, true, extra ); + } // Otherwise, if a way to get the computed value exists, use that - } else if ( curCSS ) { - return curCSS( elem, name ); + if ( val === undefined ) { + val = curCSS( elem, name, styles ); + } + + //convert "normal" to computed value + if ( val === "normal" && name in cssNormalTransform ) { + val = cssNormalTransform[ name ]; } + + // Return, converting to number if forced or a qualifier was provided and val looks numeric + if ( extra === "" || extra ) { + num = parseFloat( val ); + return extra === true || jQuery.isNumeric( num ) ? num || 0 : val; + } + return val; }, // A method for quickly swapping in/out CSS properties to get correct calculations - swap: function( elem, options, callback ) { - var old = {}; + swap: function( elem, options, callback, args ) { + var ret, name, + old = {}; // Remember the old values, and insert the new ones - for ( var name in options ) { + for ( name in options ) { old[ name ] = elem.style[ name ]; elem.style[ name ] = options[ name ]; } - callback.call( elem ); + ret = callback.apply( elem, args || [] ); // Revert the old values for ( name in options ) { elem.style[ name ] = old[ name ]; } + + return ret; } }); -// DEPRECATED, Use jQuery.css() instead -jQuery.curCSS = jQuery.css; +// NOTE: we've included the "window" in window.getComputedStyle +// because jsdom on node.js will break without it. +if ( window.getComputedStyle ) { + getStyles = function( elem ) { + return window.getComputedStyle( elem, null ); + }; + + curCSS = function( elem, name, _computed ) { + var width, minWidth, maxWidth, + computed = _computed || getStyles( elem ), -jQuery.each(["height", "width"], function( i, name ) { - jQuery.cssHooks[ name ] = { - get: function( elem, computed, extra ) { - var val; + // getPropertyValue is only needed for .css('filter') in IE9, see #12537 + ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined, + style = elem.style; - if ( computed ) { - if ( elem.offsetWidth !== 0 ) { - return getWH( elem, name, extra ); - } else { - jQuery.swap( elem, cssShow, function() { - val = getWH( elem, name, extra ); - }); - } + if ( computed ) { - return val; + if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { + ret = jQuery.style( elem, name ); } - }, - set: function( elem, value ) { - if ( rnumpx.test( value ) ) { - // ignore negative width and height values #1599 - value = parseFloat( value ); + // A tribute to the "awesome hack by Dean Edwards" + // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right + // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels + // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values + if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { - if ( value >= 0 ) { - return value + "px"; - } + // Remember the original values + width = style.width; + minWidth = style.minWidth; + maxWidth = style.maxWidth; - } else { - return value; + // Put in the new values to get a computed value out + style.minWidth = style.maxWidth = style.width = ret; + ret = computed.width; + + // Revert the changed values + style.width = width; + style.minWidth = minWidth; + style.maxWidth = maxWidth; } } + + return ret; + }; +} else if ( document.documentElement.currentStyle ) { + getStyles = function( elem ) { + return elem.currentStyle; + }; + + curCSS = function( elem, name, _computed ) { + var left, rs, rsLeft, + computed = _computed || getStyles( elem ), + ret = computed ? computed[ name ] : undefined, + style = elem.style; + + // Avoid setting ret to empty string here + // so we don't default to auto + if ( ret == null && style && style[ name ] ) { + ret = style[ name ]; + } + + // From the awesome hack by Dean Edwards + // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 + + // If we're not dealing with a regular pixel number + // but a number that has a weird ending, we need to convert it to pixels + // but not position css attributes, as those are proportional to the parent element instead + // and we can't measure the parent instead because it might trigger a "stacking dolls" problem + if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) { + + // Remember the original values + left = style.left; + rs = elem.runtimeStyle; + rsLeft = rs && rs.left; + + // Put in the new values to get a computed value out + if ( rsLeft ) { + rs.left = elem.currentStyle.left; + } + style.left = name === "fontSize" ? "1em" : ret; + ret = style.pixelLeft + "px"; + + // Revert the changed values + style.left = left; + if ( rsLeft ) { + rs.left = rsLeft; + } + } + + return ret === "" ? "auto" : ret; + }; +} + +function setPositiveNumber( elem, value, subtract ) { + var matches = rnumsplit.exec( value ); + return matches ? + // Guard against undefined "subtract", e.g., when used as in cssHooks + Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) : + value; +} + +function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { + var i = extra === ( isBorderBox ? "border" : "content" ) ? + // If we already have the right measurement, avoid augmentation + 4 : + // Otherwise initialize for horizontal or vertical properties + name === "width" ? 1 : 0, + + val = 0; + + for ( ; i < 4; i += 2 ) { + // both box models exclude margin, so add it if we want it + if ( extra === "margin" ) { + val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); + } + + if ( isBorderBox ) { + // border-box includes padding, so remove it if we want content + if ( extra === "content" ) { + val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); + } + + // at this point, extra isn't border nor margin, so remove border + if ( extra !== "margin" ) { + val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); + } + } else { + // at this point, extra isn't content, so add padding + val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); + + // at this point, extra isn't content nor padding, so add border + if ( extra !== "padding" ) { + val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); + } + } + } + + return val; +} + +function getWidthOrHeight( elem, name, extra ) { + + // Start with offset property, which is equivalent to the border-box value + var valueIsBorderBox = true, + val = name === "width" ? elem.offsetWidth : elem.offsetHeight, + styles = getStyles( elem ), + isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; + + // some non-html elements return undefined for offsetWidth, so check for null/undefined + // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 + // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 + if ( val <= 0 || val == null ) { + // Fall back to computed then uncomputed css if necessary + val = curCSS( elem, name, styles ); + if ( val < 0 || val == null ) { + val = elem.style[ name ]; + } + + // Computed unit is not pixels. Stop here and return. + if ( rnumnonpx.test(val) ) { + return val; + } + + // we need the check for style in case a browser which returns unreliable values + // for getComputedStyle silently falls back to the reliable elem.style + valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] ); + + // Normalize "", auto, and prepare for extra + val = parseFloat( val ) || 0; + } + + // use the active box-sizing model to add/subtract irrelevant styles + return ( val + + augmentWidthOrHeight( + elem, + name, + extra || ( isBorderBox ? "border" : "content" ), + valueIsBorderBox, + styles + ) + ) + "px"; +} + +// Try to determine the default display value of an element +function css_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("<iframe frameborder='0' width='0' height='0'/>") + .css( "cssText", "display:block !important" ) + ).appendTo( doc.documentElement ); + + // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse + doc = ( iframe[0].contentWindow || iframe[0].contentDocument ).document; + doc.write("<!doctype html><html><body>"); + doc.close(); + + display = actualDisplay( nodeName, doc ); + iframe.detach(); + } + + // Store the correct default display + elemdisplay[ nodeName ] = display; + } + + return display; +} + +// Called ONLY from within css_defaultDisplay +function actualDisplay( name, doc ) { + var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), + display = jQuery.css( elem[0], "display" ); + elem.remove(); + return display; +} + +jQuery.each([ "height", "width" ], function( i, name ) { + jQuery.cssHooks[ name ] = { + get: function( elem, computed, extra ) { + if ( computed ) { + // certain elements can have dimension info if we invisibly show them + // however, it must have a current display style that would benefit from this + return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ? + jQuery.swap( elem, cssShow, function() { + return getWidthOrHeight( elem, name, extra ); + }) : + getWidthOrHeight( elem, name, extra ); + } + }, + + set: function( elem, value, extra ) { + var styles = extra && getStyles( elem ); + return setPositiveNumber( elem, value, extra ? + augmentWidthOrHeight( + elem, + name, + extra, + jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box", + styles + ) : 0 + ); + } }; }); @@ -6645,7 +7177,7 @@ if ( !jQuery.support.opacity ) { get: function( elem, computed ) { // IE uses filters for opacity return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ? - ( parseFloat( RegExp.$1 ) / 100 ) + "" : + ( 0.01 * parseFloat( RegExp.$1 ) ) + "" : computed ? "1" : ""; }, @@ -6660,15 +7192,18 @@ if ( !jQuery.support.opacity ) { style.zoom = 1; // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652 - if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" ) { + // if value === "", then remove inline opacity #12685 + if ( ( value >= 1 || value === "" ) && + jQuery.trim( filter.replace( ralpha, "" ) ) === "" && + style.removeAttribute ) { // Setting style.filter to null, "" & " " still leave "filter:" in the cssText // if "filter:" is present at all, clearType is disabled, we want to avoid this // style.removeAttribute is IE Only, but so apparently is this code path... style.removeAttribute( "filter" ); - // if there there is no filter style applied in a css rule, we are done - if ( currentStyle && !currentStyle.filter ) { + // if there is no filter style applied in a css rule or unset inline opacity, we are done + if ( value === "" || currentStyle && !currentStyle.filter ) { return; } } @@ -6681,170 +7216,212 @@ if ( !jQuery.support.opacity ) { }; } +// These hooks cannot be added until DOM ready because the support test +// for it is not run until after DOM ready jQuery(function() { - // This hook cannot be added until DOM ready because the support test - // for it is not run until after DOM ready if ( !jQuery.support.reliableMarginRight ) { jQuery.cssHooks.marginRight = { get: function( elem, computed ) { - // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right - // Work around by temporarily setting element display to inline-block - var ret; - jQuery.swap( elem, { "display": "inline-block" }, function() { - if ( computed ) { - ret = curCSS( elem, "margin-right", "marginRight" ); - } else { - ret = elem.style.marginRight; - } - }); - return ret; + if ( computed ) { + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right + // Work around by temporarily setting element display to inline-block + return jQuery.swap( elem, { "display": "inline-block" }, + curCSS, [ elem, "marginRight" ] ); + } } }; } -}); -if ( document.defaultView && document.defaultView.getComputedStyle ) { - getComputedStyle = function( elem, name ) { - var ret, defaultView, computedStyle; + // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 + // getComputedStyle returns percent when specified for top/left/bottom/right + // rather than make the css module depend on the offset module, we just check for it here + if ( !jQuery.support.pixelPosition && jQuery.fn.position ) { + jQuery.each( [ "top", "left" ], function( i, prop ) { + jQuery.cssHooks[ prop ] = { + get: function( elem, computed ) { + if ( computed ) { + computed = curCSS( elem, prop ); + // if curCSS returns percentage, fallback to offset + return rnumnonpx.test( computed ) ? + jQuery( elem ).position()[ prop ] + "px" : + computed; + } + } + }; + }); + } - name = name.replace( rupper, "-$1" ).toLowerCase(); +}); - if ( (defaultView = elem.ownerDocument.defaultView) && - (computedStyle = defaultView.getComputedStyle( elem, null )) ) { - ret = computedStyle.getPropertyValue( name ); - if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) { - ret = jQuery.style( elem, name ); - } - } +if ( jQuery.expr && jQuery.expr.filters ) { + jQuery.expr.filters.hidden = function( elem ) { + // Support: Opera <= 12.12 + // Opera reports offsetWidths and offsetHeights less than zero on some elements + return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 || + (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none"); + }; - return ret; + jQuery.expr.filters.visible = function( elem ) { + return !jQuery.expr.filters.hidden( elem ); }; } -if ( document.documentElement.currentStyle ) { - currentStyle = function( elem, name ) { - var left, rsLeft, uncomputed, - ret = elem.currentStyle && elem.currentStyle[ name ], - style = elem.style; - - // Avoid setting ret to empty string here - // so we don't default to auto - if ( ret === null && style && (uncomputed = style[ name ]) ) { - ret = uncomputed; - } - - // From the awesome hack by Dean Edwards - // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 - - // If we're not dealing with a regular pixel number - // but a number that has a weird ending, we need to convert it to pixels - if ( !rnumpx.test( ret ) && rnum.test( ret ) ) { +// These hooks are used by animate to expand properties +jQuery.each({ + margin: "", + padding: "", + border: "Width" +}, function( prefix, suffix ) { + jQuery.cssHooks[ prefix + suffix ] = { + expand: function( value ) { + var i = 0, + expanded = {}, - // Remember the original values - left = style.left; - rsLeft = elem.runtimeStyle && elem.runtimeStyle.left; + // assumes a single number if not a string + parts = typeof value === "string" ? value.split(" ") : [ value ]; - // Put in the new values to get a computed value out - if ( rsLeft ) { - elem.runtimeStyle.left = elem.currentStyle.left; + for ( ; i < 4; i++ ) { + expanded[ prefix + cssExpand[ i ] + suffix ] = + parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; } - style.left = name === "fontSize" ? "1em" : ( ret || 0 ); - ret = style.pixelLeft + "px"; - // Revert the changed values - style.left = left; - if ( rsLeft ) { - elem.runtimeStyle.left = rsLeft; - } + return expanded; } - - return ret === "" ? "auto" : ret; }; -} -curCSS = getComputedStyle || currentStyle; + if ( !rmargin.test( prefix ) ) { + jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; + } +}); +var r20 = /%20/g, + rbracket = /\[\]$/, + rCRLF = /\r?\n/g, + rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, + rsubmittable = /^(?:input|select|textarea|keygen)/i; -function getWH( elem, name, extra ) { +jQuery.fn.extend({ + serialize: function() { + return jQuery.param( this.serializeArray() ); + }, + serializeArray: function() { + return this.map(function(){ + // Can add propHook for "elements" to filter or add form elements + var elements = jQuery.prop( this, "elements" ); + return elements ? jQuery.makeArray( elements ) : this; + }) + .filter(function(){ + var type = this.type; + // Use .is(":disabled") so that fieldset[disabled] works + return this.name && !jQuery( this ).is( ":disabled" ) && + rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && + ( this.checked || !manipulation_rcheckableType.test( type ) ); + }) + .map(function( i, elem ){ + var val = jQuery( this ).val(); - // Start with offset property - var val = name === "width" ? elem.offsetWidth : elem.offsetHeight, - which = name === "width" ? cssWidth : cssHeight, - i = 0, - len = which.length; + return val == null ? + null : + jQuery.isArray( val ) ? + jQuery.map( val, function( val ){ + return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; + }) : + { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; + }).get(); + } +}); - if ( val > 0 ) { - if ( extra !== "border" ) { - for ( ; i < len; i++ ) { - if ( !extra ) { - val -= parseFloat( jQuery.css( elem, "padding" + which[ i ] ) ) || 0; - } - if ( extra === "margin" ) { - val += parseFloat( jQuery.css( elem, extra + which[ i ] ) ) || 0; - } else { - val -= parseFloat( jQuery.css( elem, "border" + which[ i ] + "Width" ) ) || 0; - } - } - } +//Serialize an array of form elements or a set of +//key/values into a query string +jQuery.param = function( a, traditional ) { + var prefix, + s = [], + add = function( key, value ) { + // If value is a function, invoke it and return its value + value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value ); + s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); + }; - return val + "px"; + // Set traditional to true for jQuery <= 1.3.2 behavior. + if ( traditional === undefined ) { + traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; } - // Fall back to computed then uncomputed css if necessary - val = curCSS( elem, name, name ); - if ( val < 0 || val == null ) { - val = elem.style[ name ] || 0; - } - // Normalize "", auto, and prepare for extra - val = parseFloat( val ) || 0; + // If an array was passed in, assume that it is an array of form elements. + if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { + // Serialize the form elements + jQuery.each( a, function() { + add( this.name, this.value ); + }); - // Add padding, border, margin - if ( extra ) { - for ( ; i < len; i++ ) { - val += parseFloat( jQuery.css( elem, "padding" + which[ i ] ) ) || 0; - if ( extra !== "padding" ) { - val += parseFloat( jQuery.css( elem, "border" + which[ i ] + "Width" ) ) || 0; - } - if ( extra === "margin" ) { - val += parseFloat( jQuery.css( elem, extra + which[ i ] ) ) || 0; - } + } else { + // If traditional, encode the "old" way (the way 1.3.2 or older + // did it), otherwise encode params recursively. + for ( prefix in a ) { + buildParams( prefix, a[ prefix ], traditional, add ); } } - return val + "px"; -} + // Return the resulting serialization + return s.join( "&" ).replace( r20, "+" ); +}; -if ( jQuery.expr && jQuery.expr.filters ) { - jQuery.expr.filters.hidden = function( elem ) { - var width = elem.offsetWidth, - height = elem.offsetHeight; +function buildParams( prefix, obj, traditional, add ) { + var name; - return ( width === 0 && height === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none"); - }; + if ( jQuery.isArray( obj ) ) { + // Serialize array item. + jQuery.each( obj, function( i, v ) { + if ( traditional || rbracket.test( prefix ) ) { + // Treat each array item as a scalar. + add( prefix, v ); - jQuery.expr.filters.visible = function( elem ) { - return !jQuery.expr.filters.hidden( elem ); - }; -} + } else { + // Item is non-scalar (array or object), encode its numeric index. + buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add ); + } + }); + } else if ( !traditional && jQuery.type( obj ) === "object" ) { + // Serialize object item. + for ( name in obj ) { + buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); + } + } else { + // Serialize scalar item. + add( prefix, obj ); + } +} +jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + + "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { + // Handle event binding + jQuery.fn[ name ] = function( data, fn ) { + return arguments.length > 0 ? + this.on( name, null, data, fn ) : + this.trigger( name ); + }; +}); -var r20 = /%20/g, - rbracket = /\[\]$/, - rCRLF = /\r?\n/g, +jQuery.fn.hover = function( fnOver, fnOut ) { + return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); +}; +var + // Document location + ajaxLocParts, + ajaxLocation, + ajax_nonce = jQuery.now(), + + ajax_rquery = /\?/, rhash = /#.*$/, + rts = /([?&])_=[^&]*/, rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL - rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i, // #7653, #8125, #8152: local protocol detection - rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/, + rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, rnoContent = /^(?:GET|HEAD)$/, rprotocol = /^\/\//, - rquery = /\?/, - rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, - rselectTextarea = /^(?:select|textarea)/i, - rspacesAjax = /\s+/, - rts = /([?&])_=[^&]*/, - rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/, + rurl = /^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/, // Keep a copy of the old load method _load = jQuery.fn.load, @@ -6867,14 +7444,8 @@ var r20 = /%20/g, */ transports = {}, - // Document location - ajaxLocation, - - // Document location segments - ajaxLocParts, - // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression - allTypes = ["*/"] + ["*"]; + allTypes = "*/".concat("*"); // #8138, IE may throw an exception when accessing // a field from window.location if document.domain has been set @@ -6902,195 +7473,132 @@ function addToPrefiltersOrTransports( structure ) { dataTypeExpression = "*"; } - if ( jQuery.isFunction( func ) ) { - var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ), - i = 0, - length = dataTypes.length, - dataType, - list, - placeBefore; + var dataType, + i = 0, + dataTypes = dataTypeExpression.toLowerCase().match( core_rnotwhite ) || []; + if ( jQuery.isFunction( func ) ) { // For each dataType in the dataTypeExpression - for ( ; i < length; i++ ) { - dataType = dataTypes[ i ]; - // We control if we're asked to add before - // any existing element - placeBefore = /^\+/.test( dataType ); - if ( placeBefore ) { - dataType = dataType.substr( 1 ) || "*"; + while ( (dataType = dataTypes[i++]) ) { + // Prepend if requested + if ( dataType[0] === "+" ) { + dataType = dataType.slice( 1 ) || "*"; + (structure[ dataType ] = structure[ dataType ] || []).unshift( func ); + + // Otherwise append + } else { + (structure[ dataType ] = structure[ dataType ] || []).push( func ); } - list = structure[ dataType ] = structure[ dataType ] || []; - // then we add to the structure accordingly - list[ placeBefore ? "unshift" : "push" ]( func ); } } }; } // Base inspection function for prefilters and transports -function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR, - dataType /* internal */, inspected /* internal */ ) { - - dataType = dataType || options.dataTypes[ 0 ]; - inspected = inspected || {}; - - inspected[ dataType ] = true; - - var list = structure[ dataType ], - i = 0, - length = list ? list.length : 0, - executeOnly = ( structure === prefilters ), - selection; - - for ( ; i < length && ( executeOnly || !selection ); i++ ) { - selection = list[ i ]( options, originalOptions, jqXHR ); - // If we got redirected to another dataType - // we try there if executing only and not done already - if ( typeof selection === "string" ) { - if ( !executeOnly || inspected[ selection ] ) { - selection = undefined; - } else { - options.dataTypes.unshift( selection ); - selection = inspectPrefiltersOrTransports( - structure, options, originalOptions, jqXHR, selection, inspected ); +function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) { + + var inspected = {}, + seekingTransport = ( structure === transports ); + + function inspect( dataType ) { + var selected; + inspected[ dataType ] = true; + jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { + var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); + if( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) { + options.dataTypes.unshift( dataTypeOrTransport ); + inspect( dataTypeOrTransport ); + return false; + } else if ( seekingTransport ) { + return !( selected = dataTypeOrTransport ); } - } - } - // If we're only executing or nothing was selected - // we try the catchall dataType if not done already - if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) { - selection = inspectPrefiltersOrTransports( - structure, options, originalOptions, jqXHR, "*", inspected ); + }); + return selected; } - // unnecessary when only executing (prefilters) - // but it'll be ignored by the caller in that case - return selection; + + return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" ); } // A special extend for ajax options // that takes "flat" options (not to be deep extended) // Fixes #9887 function ajaxExtend( target, src ) { - var key, deep, + var deep, key, flatOptions = jQuery.ajaxSettings.flatOptions || {}; + for ( key in src ) { if ( src[ key ] !== undefined ) { - ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; + ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ]; } } if ( deep ) { jQuery.extend( true, target, deep ); } -} -jQuery.fn.extend({ - load: function( url, params, callback ) { - if ( typeof url !== "string" && _load ) { - return _load.apply( this, arguments ); + return target; +} - // Don't do a request if no elements are being requested - } else if ( !this.length ) { - return this; - } +jQuery.fn.load = function( url, params, callback ) { + if ( typeof url !== "string" && _load ) { + return _load.apply( this, arguments ); + } - var off = url.indexOf( " " ); - if ( off >= 0 ) { - var selector = url.slice( off, url.length ); - url = url.slice( 0, off ); - } + var selector, response, type, + self = this, + off = url.indexOf(" "); - // Default to a GET request - var type = "GET"; + if ( off >= 0 ) { + selector = url.slice( off, url.length ); + url = url.slice( 0, off ); + } - // If the second parameter was provided - if ( params ) { - // If it's a function - if ( jQuery.isFunction( params ) ) { - // We assume that it's the callback - callback = params; - params = undefined; + // If it's a function + if ( jQuery.isFunction( params ) ) { - // Otherwise, build a param string - } else if ( typeof params === "object" ) { - params = jQuery.param( params, jQuery.ajaxSettings.traditional ); - type = "POST"; - } - } + // We assume that it's the callback + callback = params; + params = undefined; - var self = this; + // Otherwise, build a param string + } else if ( params && typeof params === "object" ) { + type = "POST"; + } - // Request the remote document + // If we have elements to modify, make the request + if ( self.length > 0 ) { jQuery.ajax({ url: url, + + // if "type" variable is undefined, then "GET" method will be used type: type, dataType: "html", - data: params, - // Complete callback (responseText is used internally) - complete: function( jqXHR, status, responseText ) { - // Store the response as specified by the jqXHR object - responseText = jqXHR.responseText; - // If successful, inject the HTML into all the matched elements - if ( jqXHR.isResolved() ) { - // #4825: Get the actual response in case - // a dataFilter is present in ajaxSettings - jqXHR.done(function( r ) { - responseText = r; - }); - // See if a selector was specified - self.html( selector ? - // Create a dummy div to hold the results - jQuery("<div>") - // inject the contents of the document in, removing the scripts - // to avoid any 'Permission Denied' errors in IE - .append(responseText.replace(rscript, "")) - - // Locate the specified elements - .find(selector) : - - // If not, just inject the full result - responseText ); - } + data: params + }).done(function( responseText ) { - if ( callback ) { - self.each( callback, [ responseText, status, jqXHR ] ); - } - } - }); + // Save response for use in complete callback + response = arguments; - return this; - }, + self.html( selector ? - serialize: function() { - return jQuery.param( this.serializeArray() ); - }, + // If a selector was specified, locate the right elements in a dummy div + // Exclude scripts to avoid IE 'Permission Denied' errors + jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) : - serializeArray: function() { - return this.map(function(){ - return this.elements ? jQuery.makeArray( this.elements ) : this; - }) - .filter(function(){ - return this.name && !this.disabled && - ( this.checked || rselectTextarea.test( this.nodeName ) || - rinput.test( this.type ) ); - }) - .map(function( i, elem ){ - var val = jQuery( this ).val(); + // Otherwise use the full result + responseText ); - return val == null ? - null : - jQuery.isArray( val ) ? - jQuery.map( val, function( val, i ){ - return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; - }) : - { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; - }).get(); + }).complete( callback && function( jqXHR, status ) { + self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] ); + }); } -}); + + return this; +}; // Attach a bunch of functions for handling common AJAX events -jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){ - jQuery.fn[ o ] = function( f ){ - return this.on( o, f ); +jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ){ + jQuery.fn[ type ] = function( fn ){ + return this.on( type, fn ); }; }); @@ -7104,49 +7612,32 @@ jQuery.each( [ "get", "post" ], function( i, method ) { } return jQuery.ajax({ - type: method, url: url, + type: method, + dataType: type, data: data, - success: callback, - dataType: type + success: callback }); }; }); jQuery.extend({ - getScript: function( url, callback ) { - return jQuery.get( url, undefined, callback, "script" ); - }, - - getJSON: function( url, data, callback ) { - return jQuery.get( url, data, callback, "json" ); - }, + // Counter for holding the number of active queries + active: 0, - // Creates a full fledged settings object into target - // with both ajaxSettings and settings fields. - // If target is omitted, writes into ajaxSettings. - ajaxSetup: function( target, settings ) { - if ( settings ) { - // Building a settings object - ajaxExtend( target, jQuery.ajaxSettings ); - } else { - // Extending ajaxSettings - settings = target; - target = jQuery.ajaxSettings; - } - ajaxExtend( target, settings ); - return target; - }, + // Last-Modified header cache for next request + lastModified: {}, + etag: {}, ajaxSettings: { url: ajaxLocation, + type: "GET", isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ), global: true, - type: "GET", - contentType: "application/x-www-form-urlencoded", processData: true, async: true, + contentType: "application/x-www-form-urlencoded; charset=UTF-8", /* timeout: 0, data: null, @@ -7154,16 +7645,17 @@ jQuery.extend({ username: null, password: null, cache: null, + throws: false, traditional: false, headers: {}, */ accepts: { - xml: "application/xml, text/xml", - html: "text/html", + "*": allTypes, text: "text/plain", - json: "application/json, text/javascript", - "*": allTypes + html: "text/html", + xml: "application/xml, text/xml", + json: "application/json, text/javascript" }, contents: { @@ -7177,9 +7669,8 @@ jQuery.extend({ text: "responseText" }, - // List of data converters - // 1) key format is "source_type destination_type" (a single space in-between) - // 2) the catchall symbol "*" can be used for source_type + // Data converters + // Keys separate source (or catchall "*") and destination types with a single space converters: { // Convert anything to text @@ -7200,11 +7691,24 @@ jQuery.extend({ // and when you create one that shouldn't be // deep extended (see ajaxExtend) flatOptions: { - context: true, - url: true + url: true, + context: true } }, + // Creates a full fledged settings object into target + // with both ajaxSettings and settings fields. + // If target is omitted, writes into ajaxSettings. + ajaxSetup: function( target, settings ) { + return settings ? + + // Building a settings object + ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) : + + // Extending ajaxSettings + ajaxExtend( jQuery.ajaxSettings, target ); + }, + ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), ajaxTransport: addToPrefiltersOrTransports( transports ), @@ -7220,74 +7724,75 @@ jQuery.extend({ // Force options to be an object options = options || {}; - var // Create the final options object + var // Cross-domain detection vars + parts, + // Loop variable + i, + // URL without anti-cache param + cacheURL, + // Response headers as string + responseHeadersString, + // timeout handle + timeoutTimer, + + // To know if global events are to be dispatched + fireGlobals, + + transport, + // Response headers + responseHeaders, + // Create the final options object s = jQuery.ajaxSetup( {}, options ), // Callbacks context callbackContext = s.context || s, - // Context for global events - // It's the callbackContext if one was provided in the options - // and if it's a DOM node or a jQuery collection - globalEventContext = callbackContext !== s && - ( callbackContext.nodeType || callbackContext instanceof jQuery ) ? - jQuery( callbackContext ) : jQuery.event, + // Context for global events is callbackContext if it is a DOM node or jQuery collection + globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ? + jQuery( callbackContext ) : + jQuery.event, // Deferreds deferred = jQuery.Deferred(), - completeDeferred = jQuery.Callbacks( "once memory" ), + completeDeferred = jQuery.Callbacks("once memory"), // Status-dependent callbacks statusCode = s.statusCode || {}, - // ifModified key - ifModifiedKey, // Headers (they are sent all at once) requestHeaders = {}, requestHeadersNames = {}, - // Response headers - responseHeadersString, - responseHeaders, - // transport - transport, - // timeout handle - timeoutTimer, - // Cross-domain detection vars - parts, // The jqXHR state state = 0, - // To know if global events are to be dispatched - fireGlobals, - // Loop variable - i, + // Default abort message + strAbort = "canceled", // Fake xhr jqXHR = { - readyState: 0, - // Caches the header - setRequestHeader: function( name, value ) { - if ( !state ) { - var lname = name.toLowerCase(); - name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name; - requestHeaders[ name ] = value; - } - return this; - }, - - // Raw string - getAllResponseHeaders: function() { - return state === 2 ? responseHeadersString : null; - }, - // Builds headers hashtable if needed getResponseHeader: function( key ) { var match; if ( state === 2 ) { if ( !responseHeaders ) { responseHeaders = {}; - while( ( match = rheaders.exec( responseHeadersString ) ) ) { + while ( (match = rheaders.exec( responseHeadersString )) ) { responseHeaders[ match[1].toLowerCase() ] = match[ 2 ]; } } match = responseHeaders[ key.toLowerCase() ]; } - return match === undefined ? null : match; + return match == null ? null : match; + }, + + // Raw string + getAllResponseHeaders: function() { + return state === 2 ? responseHeadersString : null; + }, + + // Caches the header + setRequestHeader: function( name, value ) { + var lname = name.toLowerCase(); + if ( !state ) { + name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name; + requestHeaders[ name ] = value; + } + return this; }, // Overrides response content-type header @@ -7298,165 +7803,56 @@ jQuery.extend({ return this; }, + // Status-dependent callbacks + statusCode: function( map ) { + var code; + if ( map ) { + if ( state < 2 ) { + for ( code in map ) { + // Lazy-add the new callback in a way that preserves old ones + statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; + } + } else { + // Execute the appropriate callbacks + jqXHR.always( map[ jqXHR.status ] ); + } + } + return this; + }, + // Cancel the request abort: function( statusText ) { - statusText = statusText || "abort"; + var finalText = statusText || strAbort; if ( transport ) { - transport.abort( statusText ); + transport.abort( finalText ); } - done( 0, statusText ); + done( 0, finalText ); return this; } }; - // Callback for when everything is done - // It is defined here because jslint complains if it is declared - // at the end of the function (which would be more logical and readable) - function done( status, nativeStatusText, responses, headers ) { - - // Called once - if ( state === 2 ) { - return; - } - - // State is "done" now - state = 2; - - // Clear timeout if it exists - if ( timeoutTimer ) { - clearTimeout( timeoutTimer ); - } - - // Dereference transport for early garbage collection - // (no matter how long the jqXHR object will be used) - transport = undefined; - - // Cache response headers - responseHeadersString = headers || ""; - - // Set readyState - jqXHR.readyState = status > 0 ? 4 : 0; - - var isSuccess, - success, - error, - statusText = nativeStatusText, - response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined, - lastModified, - etag; - - // If successful, handle type chaining - if ( status >= 200 && status < 300 || status === 304 ) { - - // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. - if ( s.ifModified ) { - - if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) { - jQuery.lastModified[ ifModifiedKey ] = lastModified; - } - if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) { - jQuery.etag[ ifModifiedKey ] = etag; - } - } - - // If not modified - if ( status === 304 ) { - - statusText = "notmodified"; - isSuccess = true; - - // If we have data - } else { - - try { - success = ajaxConvert( s, response ); - statusText = "success"; - isSuccess = true; - } catch(e) { - // We have a parsererror - statusText = "parsererror"; - error = e; - } - } - } else { - // We extract error from statusText - // then normalize statusText and status for non-aborts - error = statusText; - if ( !statusText || status ) { - statusText = "error"; - if ( status < 0 ) { - status = 0; - } - } - } - - // Set data for the fake xhr object - jqXHR.status = status; - jqXHR.statusText = "" + ( nativeStatusText || statusText ); - - // Success/Error - if ( isSuccess ) { - deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); - } else { - deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); - } - - // Status-dependent callbacks - jqXHR.statusCode( statusCode ); - statusCode = undefined; - - if ( fireGlobals ) { - globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ), - [ jqXHR, s, isSuccess ? success : error ] ); - } - - // Complete - completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); - - if ( fireGlobals ) { - globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); - // Handle the global AJAX counter - if ( !( --jQuery.active ) ) { - jQuery.event.trigger( "ajaxStop" ); - } - } - } - // Attach deferreds - deferred.promise( jqXHR ); + deferred.promise( jqXHR ).complete = completeDeferred.add; jqXHR.success = jqXHR.done; jqXHR.error = jqXHR.fail; - jqXHR.complete = completeDeferred.add; - - // Status-dependent callbacks - jqXHR.statusCode = function( map ) { - if ( map ) { - var tmp; - if ( state < 2 ) { - for ( tmp in map ) { - statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ]; - } - } else { - tmp = map[ jqXHR.status ]; - jqXHR.then( tmp, tmp ); - } - } - return this; - }; // Remove hash character (#7531: and string promotion) // Add protocol if not provided (#5866: IE7 issue with protocol-less urls) + // Handle falsy url in the settings object (#10093: consistency with old signature) // We also use the url parameter if available - s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); + s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); + + // Alias method option to type as per ticket #12004 + s.type = options.method || options.type || s.method || s.type; // Extract dataTypes list - s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax ); + s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( core_rnotwhite ) || [""]; - // Determine if a cross-domain request is in order + // A cross-domain request is in order when we have a protocol:host:port mismatch if ( s.crossDomain == null ) { parts = rurl.exec( s.url.toLowerCase() ); s.crossDomain = !!( parts && - ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] || + ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] || ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) != ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) ) ); @@ -7470,66 +7866,66 @@ jQuery.extend({ // Apply prefilters inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); - // If request was aborted inside a prefiler, stop there + // If request was aborted inside a prefilter, stop there if ( state === 2 ) { - return false; + return jqXHR; } // We can fire global events as of now if asked to fireGlobals = s.global; + // Watch for a new set of requests + if ( fireGlobals && jQuery.active++ === 0 ) { + jQuery.event.trigger("ajaxStart"); + } + // Uppercase the type s.type = s.type.toUpperCase(); // Determine if request has content s.hasContent = !rnoContent.test( s.type ); - // Watch for a new set of requests - if ( fireGlobals && jQuery.active++ === 0 ) { - jQuery.event.trigger( "ajaxStart" ); - } + // Save the URL in case we're toying with the If-Modified-Since + // and/or If-None-Match header later on + cacheURL = s.url; // More options handling for requests with no content if ( !s.hasContent ) { // If data is available, append data to url if ( s.data ) { - s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data; + cacheURL = ( s.url += ( ajax_rquery.test( cacheURL ) ? "&" : "?" ) + s.data ); // #9682: remove data so that it's not used in an eventual retry delete s.data; } - // Get ifModifiedKey before adding the anti-cache parameter - ifModifiedKey = s.url; - // Add anti-cache in url if needed if ( s.cache === false ) { + s.url = rts.test( cacheURL ) ? - var ts = jQuery.now(), - // try replacing _= if it is there - ret = s.url.replace( rts, "$1_=" + ts ); + // If there is already a '_' parameter, set its value + cacheURL.replace( rts, "$1_=" + ajax_nonce++ ) : - // if nothing was replaced, add timestamp to the end - s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" ); + // Otherwise add one to the end + cacheURL + ( ajax_rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ajax_nonce++; } } - // Set the correct header, if data is being sent - if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { - jqXHR.setRequestHeader( "Content-Type", s.contentType ); - } - // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. if ( s.ifModified ) { - ifModifiedKey = ifModifiedKey || s.url; - if ( jQuery.lastModified[ ifModifiedKey ] ) { - jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] ); + if ( jQuery.lastModified[ cacheURL ] ) { + jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] ); } - if ( jQuery.etag[ ifModifiedKey ] ) { - jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] ); + if ( jQuery.etag[ cacheURL ] ) { + jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] ); } } + // Set the correct header, if data is being sent + if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { + jqXHR.setRequestHeader( "Content-Type", s.contentType ); + } + // Set the Accepts header for the server, depending on the dataType jqXHR.setRequestHeader( "Accept", @@ -7545,12 +7941,13 @@ jQuery.extend({ // Allow custom headers/mimetypes and early abort if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { - // Abort if not done already - jqXHR.abort(); - return false; - + // Abort if not done already and return + return jqXHR.abort(); } + // aborting is no longer a cancellation + strAbort = "abort"; + // Install callbacks on deferreds for ( i in { success: 1, error: 1, complete: 1 } ) { jqXHR[ i ]( s[ i ] ); @@ -7564,21 +7961,22 @@ jQuery.extend({ done( -1, "No Transport" ); } else { jqXHR.readyState = 1; + // Send global event if ( fireGlobals ) { globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); } // Timeout if ( s.async && s.timeout > 0 ) { - timeoutTimer = setTimeout( function(){ - jqXHR.abort( "timeout" ); + timeoutTimer = setTimeout(function() { + jqXHR.abort("timeout"); }, s.timeout ); } try { state = 1; transport.send( requestHeaders, done ); - } catch (e) { + } catch ( e ) { // Propagate exception as error if not done if ( state < 2 ) { done( -1, e ); @@ -7589,87 +7987,126 @@ jQuery.extend({ } } - return jqXHR; - }, + // Callback for when everything is done + function done( status, nativeStatusText, responses, headers ) { + var isSuccess, success, error, response, modified, + statusText = nativeStatusText; - // Serialize an array of form elements or a set of - // key/values into a query string - param: function( a, traditional ) { - var s = [], - add = function( key, value ) { - // If value is a function, invoke it and return its value - value = jQuery.isFunction( value ) ? value() : value; - s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); - }; + // Called once + if ( state === 2 ) { + return; + } - // Set traditional to true for jQuery <= 1.3.2 behavior. - if ( traditional === undefined ) { - traditional = jQuery.ajaxSettings.traditional; - } + // State is "done" now + state = 2; - // If an array was passed in, assume that it is an array of form elements. - if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { - // Serialize the form elements - jQuery.each( a, function() { - add( this.name, this.value ); - }); + // Clear timeout if it exists + if ( timeoutTimer ) { + clearTimeout( timeoutTimer ); + } - } else { - // If traditional, encode the "old" way (the way 1.3.2 or older - // did it), otherwise encode params recursively. - for ( var prefix in a ) { - buildParams( prefix, a[ prefix ], traditional, add ); + // Dereference transport for early garbage collection + // (no matter how long the jqXHR object will be used) + transport = undefined; + + // Cache response headers + responseHeadersString = headers || ""; + + // Set readyState + jqXHR.readyState = status > 0 ? 4 : 0; + + // Get response data + if ( responses ) { + response = ajaxHandleResponses( s, jqXHR, responses ); } - } - // Return the resulting serialization - return s.join( "&" ).replace( r20, "+" ); - } -}); + // If successful, handle type chaining + if ( status >= 200 && status < 300 || status === 304 ) { -function buildParams( prefix, obj, traditional, add ) { - if ( jQuery.isArray( obj ) ) { - // Serialize array item. - jQuery.each( obj, function( i, v ) { - if ( traditional || rbracket.test( prefix ) ) { - // Treat each array item as a scalar. - add( prefix, v ); + // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. + if ( s.ifModified ) { + modified = jqXHR.getResponseHeader("Last-Modified"); + if ( modified ) { + jQuery.lastModified[ cacheURL ] = modified; + } + modified = jqXHR.getResponseHeader("etag"); + if ( modified ) { + jQuery.etag[ cacheURL ] = modified; + } + } + + // if no content + if ( status === 204 ) { + isSuccess = true; + statusText = "nocontent"; + + // if not modified + } else if ( status === 304 ) { + isSuccess = true; + statusText = "notmodified"; + // If we have data, let's convert it + } else { + isSuccess = ajaxConvert( s, response ); + statusText = isSuccess.state; + success = isSuccess.data; + error = isSuccess.error; + isSuccess = !error; + } } else { - // If array item is non-scalar (array or object), encode its - // numeric index to resolve deserialization ambiguity issues. - // Note that rack (as of 1.0.0) can't currently deserialize - // nested arrays properly, and attempting to do so may cause - // a server error. Possible fixes are to modify rack's - // deserialization algorithm or to provide an option or flag - // to force array serialization to be shallow. - buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add ); + // We extract error from statusText + // then normalize statusText and status for non-aborts + error = statusText; + if ( status || !statusText ) { + statusText = "error"; + if ( status < 0 ) { + status = 0; + } + } } - }); - } else if ( !traditional && obj != null && typeof obj === "object" ) { - // Serialize object item. - for ( var name in obj ) { - buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); - } + // Set data for the fake xhr object + jqXHR.status = status; + jqXHR.statusText = ( nativeStatusText || statusText ) + ""; - } else { - // Serialize scalar item. - add( prefix, obj ); - } -} + // Success/Error + if ( isSuccess ) { + deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); + } else { + deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); + } -// This is still on the jQuery object... for now -// Want to move this to jQuery.ajax some day -jQuery.extend({ + // Status-dependent callbacks + jqXHR.statusCode( statusCode ); + statusCode = undefined; - // Counter for holding the number of active queries - active: 0, + if ( fireGlobals ) { + globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError", + [ jqXHR, s, isSuccess ? success : error ] ); + } - // Last-Modified header cache for next request - lastModified: {}, - etag: {} + // Complete + completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); + + if ( fireGlobals ) { + globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); + // Handle the global AJAX counter + if ( !( --jQuery.active ) ) { + jQuery.event.trigger("ajaxStop"); + } + } + } + + return jqXHR; + }, + + getScript: function( url, callback ) { + return jQuery.get( url, undefined, callback, "script" ); + }, + getJSON: function( url, data, callback ) { + return jQuery.get( url, data, callback, "json" ); + } }); /* Handles responses to an ajax request: @@ -7678,14 +8115,10 @@ jQuery.extend({ * - returns the corresponding response */ function ajaxHandleResponses( s, jqXHR, responses ) { - - var contents = s.contents, + var firstDataType, ct, finalDataType, type, + contents = s.contents, dataTypes = s.dataTypes, - responseFields = s.responseFields, - ct, - type, - finalDataType, - firstDataType; + responseFields = s.responseFields; // Fill responseXXX fields for ( type in responseFields ) { @@ -7698,7 +8131,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) { while( dataTypes[ 0 ] === "*" ) { dataTypes.shift(); if ( ct === undefined ) { - ct = s.mimeType || jqXHR.getResponseHeader( "content-type" ); + ct = s.mimeType || jqXHR.getResponseHeader("Content-Type"); } } @@ -7743,178 +8176,95 @@ function ajaxHandleResponses( s, jqXHR, responses ) { // Chain conversions given the request and the original response function ajaxConvert( s, response ) { + var conv2, current, conv, tmp, + converters = {}, + i = 0, + // Work with a copy of dataTypes in case we need to modify it for conversion + dataTypes = s.dataTypes.slice(), + prev = dataTypes[ 0 ]; // Apply the dataFilter if provided if ( s.dataFilter ) { response = s.dataFilter( response, s.dataType ); } - var dataTypes = s.dataTypes, - converters = {}, - i, - key, - length = dataTypes.length, - tmp, - // Current and previous dataTypes - current = dataTypes[ 0 ], - prev, - // Conversion expression - conversion, - // Conversion function - conv, - // Conversion functions (transitive conversion) - conv1, - conv2; - - // For each dataType in the chain - for ( i = 1; i < length; i++ ) { - - // Create converters map - // with lowercased keys - if ( i === 1 ) { - for ( key in s.converters ) { - if ( typeof key === "string" ) { - converters[ key.toLowerCase() ] = s.converters[ key ]; - } - } - } - - // Get the dataTypes - prev = current; - current = dataTypes[ i ]; - - // If current is auto dataType, update it to prev - if ( current === "*" ) { - current = prev; - // If no auto and dataTypes are actually different - } else if ( prev !== "*" && prev !== current ) { - - // Get the converter - conversion = prev + " " + current; - conv = converters[ conversion ] || converters[ "* " + current ]; - - // If there is no direct converter, search transitively - if ( !conv ) { - conv2 = undefined; - for ( conv1 in converters ) { - tmp = conv1.split( " " ); - if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) { - conv2 = converters[ tmp[1] + " " + current ]; - if ( conv2 ) { - conv1 = converters[ conv1 ]; - if ( conv1 === true ) { - conv = conv2; - } else if ( conv2 === true ) { - conv = conv1; - } - break; - } - } - } - } - // If we found no converter, dispatch an error - if ( !( conv || conv2 ) ) { - jQuery.error( "No conversion from " + conversion.replace(" "," to ") ); - } - // If found converter is not an equivalence - if ( conv !== true ) { - // Convert with 1 or 2 converters accordingly - response = conv ? conv( response ) : conv2( conv1(response) ); - } + // Create converters map with lowercased keys + if ( dataTypes[ 1 ] ) { + for ( conv in s.converters ) { + converters[ conv.toLowerCase() ] = s.converters[ conv ]; } } - return response; -} + // Convert to each sequential dataType, tolerating list modification + for ( ; (current = dataTypes[++i]); ) { + // There's only work to do if current dataType is non-auto + if ( current !== "*" ) { + // Convert response if prev dataType is non-auto and differs from current + if ( prev !== "*" && prev !== current ) { -var jsc = jQuery.now(), - jsre = /(\=)\?(&|$)|\?\?/i; + // Seek a direct converter + conv = converters[ prev + " " + current ] || converters[ "* " + current ]; -// Default jsonp settings -jQuery.ajaxSetup({ - jsonp: "callback", - jsonpCallback: function() { - return jQuery.expando + "_" + ( jsc++ ); - } -}); + // If none found, seek a pair + if ( !conv ) { + for ( conv2 in converters ) { -// Detect, normalize options and install callbacks for jsonp requests -jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { - - var inspectData = s.contentType === "application/x-www-form-urlencoded" && - ( typeof s.data === "string" ); + // If conv2 outputs current + tmp = conv2.split(" "); + if ( tmp[ 1 ] === current ) { - if ( s.dataTypes[ 0 ] === "jsonp" || - s.jsonp !== false && ( jsre.test( s.url ) || - inspectData && jsre.test( s.data ) ) ) { + // If prev can be converted to accepted input + conv = converters[ prev + " " + tmp[ 0 ] ] || + converters[ "* " + tmp[ 0 ] ]; + if ( conv ) { + // Condense equivalence converters + if ( conv === true ) { + conv = converters[ conv2 ]; - var responseContainer, - jsonpCallback = s.jsonpCallback = - jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback, - previous = window[ jsonpCallback ], - url = s.url, - data = s.data, - replace = "$1" + jsonpCallback + "$2"; + // Otherwise, insert the intermediate dataType + } else if ( converters[ conv2 ] !== true ) { + current = tmp[ 0 ]; + dataTypes.splice( i--, 0, current ); + } - if ( s.jsonp !== false ) { - url = url.replace( jsre, replace ); - if ( s.url === url ) { - if ( inspectData ) { - data = data.replace( jsre, replace ); - } - if ( s.data === data ) { - // Add callback manually - url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback; + break; + } + } + } } - } - } - - s.url = url; - s.data = data; - - // Install callback - window[ jsonpCallback ] = function( response ) { - responseContainer = [ response ]; - }; - // Clean-up function - jqXHR.always(function() { - // Set callback back to previous value - window[ jsonpCallback ] = previous; - // Call if it was a function and we have a response - if ( responseContainer && jQuery.isFunction( previous ) ) { - window[ jsonpCallback ]( responseContainer[ 0 ] ); - } - }); + // Apply converter (if not an equivalence) + if ( conv !== true ) { - // Use data converter to retrieve json after script execution - s.converters["script json"] = function() { - if ( !responseContainer ) { - jQuery.error( jsonpCallback + " was not called" ); + // Unless errors are allowed to bubble, catch and return them + if ( conv && s["throws"] ) { + response = conv( response ); + } else { + try { + response = conv( response ); + } catch ( e ) { + return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current }; + } + } + } } - return responseContainer[ 0 ]; - }; - // force json dataType - s.dataTypes[ 0 ] = "json"; - - // Delegate to script - return "script"; + // Update prev for next iteration + prev = current; + } } -}); - - - + return { state: "success", data: response }; +} // Install script dataType jQuery.ajaxSetup({ accepts: { script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" }, contents: { - script: /javascript|ecmascript/ + script: /(?:java|ecma)script/ }, converters: { "text script": function( text ) { @@ -7942,15 +8292,15 @@ jQuery.ajaxTransport( "script", function(s) { if ( s.crossDomain ) { var script, - head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement; + head = document.head || jQuery("head")[0] || document.documentElement; return { send: function( _, callback ) { - script = document.createElement( "script" ); + script = document.createElement("script"); - script.async = "async"; + script.async = true; if ( s.scriptCharset ) { script.charset = s.scriptCharset; @@ -7967,12 +8317,12 @@ jQuery.ajaxTransport( "script", function(s) { script.onload = script.onreadystatechange = null; // Remove the script - if ( head && script.parentNode ) { - head.removeChild( script ); + if ( script.parentNode ) { + script.parentNode.removeChild( script ); } // Dereference the script - script = undefined; + script = null; // Callback if not abort if ( !isAbort ) { @@ -7980,32 +8330,110 @@ jQuery.ajaxTransport( "script", function(s) { } } }; - // Use insertBefore instead of appendChild to circumvent an IE6 bug. - // This arises when a base node is used (#2709 and #4378). + + // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending + // Use native DOM manipulation to avoid our domManip AJAX trickery head.insertBefore( script, head.firstChild ); }, abort: function() { if ( script ) { - script.onload( 0, 1 ); + script.onload( undefined, true ); } } }; } }); +var oldCallbacks = [], + rjsonp = /(=)\?(?=&|$)|\?\?/; +// Default jsonp settings +jQuery.ajaxSetup({ + jsonp: "callback", + jsonpCallback: function() { + var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( ajax_nonce++ ) ); + this[ callback ] = true; + return callback; + } +}); +// Detect, normalize options and install callbacks for jsonp requests +jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { + var callbackName, overwritten, responseContainer, + jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? + "url" : + typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data" + ); -var // #5280: Internet Explorer will keep connections alive if we don't abort on unload - xhrOnUnloadAbort = window.ActiveXObject ? function() { - // Abort all pending requests - for ( var key in xhrCallbacks ) { - xhrCallbacks[ key ]( 0, 1 ); + // Handle iff the expected data type is "jsonp" or we have a parameter to set + if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { + + // Get callback name, remembering preexisting value associated with it + callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? + s.jsonpCallback() : + s.jsonpCallback; + + // Insert callback into url or form data + if ( jsonProp ) { + s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); + } else if ( s.jsonp !== false ) { + s.url += ( ajax_rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; } - } : false, + + // Use data converter to retrieve json after script execution + s.converters["script json"] = function() { + if ( !responseContainer ) { + jQuery.error( callbackName + " was not called" ); + } + return responseContainer[ 0 ]; + }; + + // force json dataType + s.dataTypes[ 0 ] = "json"; + + // Install callback + overwritten = window[ callbackName ]; + window[ callbackName ] = function() { + responseContainer = arguments; + }; + + // Clean-up function (fires after converters) + jqXHR.always(function() { + // Restore preexisting value + window[ callbackName ] = overwritten; + + // Save back as free + if ( s[ callbackName ] ) { + // make sure that re-using the options doesn't screw things around + s.jsonpCallback = originalSettings.jsonpCallback; + + // save the callback name for future use + oldCallbacks.push( callbackName ); + } + + // Call if it was a function and we have a response + if ( responseContainer && jQuery.isFunction( overwritten ) ) { + overwritten( responseContainer[ 0 ] ); + } + + responseContainer = overwritten = undefined; + }); + + // Delegate to script + return "script"; + } +}); +var xhrCallbacks, xhrSupported, xhrId = 0, - xhrCallbacks; + // #5280: Internet Explorer will keep connections alive if we don't abort on unload + xhrOnUnloadAbort = window.ActiveXObject && function() { + // Abort all pending requests + var key; + for ( key in xhrCallbacks ) { + xhrCallbacks[ key ]( undefined, true ); + } + }; // Functions to create xhrs function createStandardXHR() { @@ -8016,7 +8444,7 @@ function createStandardXHR() { function createActiveXHR() { try { - return new window.ActiveXObject( "Microsoft.XMLHTTP" ); + return new window.ActiveXObject("Microsoft.XMLHTTP"); } catch( e ) {} } @@ -8036,15 +8464,12 @@ jQuery.ajaxSettings.xhr = window.ActiveXObject ? createStandardXHR; // Determine support properties -(function( xhr ) { - jQuery.extend( jQuery.support, { - ajax: !!xhr, - cors: !!xhr && ( "withCredentials" in xhr ) - }); -})( jQuery.ajaxSettings.xhr() ); +xhrSupported = jQuery.ajaxSettings.xhr(); +jQuery.support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); +xhrSupported = jQuery.support.ajax = !!xhrSupported; // Create transport if the browser can provide an xhr -if ( jQuery.support.ajax ) { +if ( xhrSupported ) { jQuery.ajaxTransport(function( s ) { // Cross domain only allowed if supported through XMLHttpRequest @@ -8056,9 +8481,8 @@ if ( jQuery.support.ajax ) { send: function( headers, complete ) { // Get a new xhr - var xhr = s.xhr(), - handle, - i; + var handle, i, + xhr = s.xhr(); // Open the socket // Passing null username, generates a login popup on Opera (#2865) @@ -8086,7 +8510,7 @@ if ( jQuery.support.ajax ) { // (it can always be set on a per-request basis or even using ajaxSetup) // For same-domain requests, won't change header if already provided. if ( !s.crossDomain && !headers["X-Requested-With"] ) { - headers[ "X-Requested-With" ] = "XMLHttpRequest"; + headers["X-Requested-With"] = "XMLHttpRequest"; } // Need an extra try/catch for cross domain requests in Firefox 3 @@ -8094,7 +8518,7 @@ if ( jQuery.support.ajax ) { for ( i in headers ) { xhr.setRequestHeader( i, headers[ i ] ); } - } catch( _ ) {} + } catch( err ) {} // Do send the request // This may raise an exception which is actually @@ -8103,15 +8527,10 @@ if ( jQuery.support.ajax ) { // Listener callback = function( _, isAbort ) { - - var status, - statusText, - responseHeaders, - responses, - xml; + var status, responseHeaders, statusText, responses; // Firefox throws exceptions when accessing properties - // of an xhr when a network error occured + // of an xhr when a network error occurred // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE) try { @@ -8136,16 +8555,15 @@ if ( jQuery.support.ajax ) { xhr.abort(); } } else { + responses = {}; status = xhr.status; responseHeaders = xhr.getAllResponseHeaders(); - responses = {}; - xml = xhr.responseXML; - // Construct response list - if ( xml && xml.documentElement /* #4958 */ ) { - responses.xml = xml; + // When requesting binary data, IE6-9 will throw an exception + // on any attempt to access responseText (#11426) + if ( typeof xhr.responseText === "string" ) { + responses.text = xhr.responseText; } - responses.text = xhr.responseText; // Firefox throws an exception when accessing // statusText for faulty cross-domain requests @@ -8181,11 +8599,13 @@ if ( jQuery.support.ajax ) { } }; - // if we're in sync mode or it's in cache - // and has been retrieved directly (IE6 & IE7) - // we need to manually fire the callback - if ( !s.async || xhr.readyState === 4 ) { + if ( !s.async ) { + // if we're in sync mode we fire the callback callback(); + } else if ( xhr.readyState === 4 ) { + // (IE6 & IE7) if it's in cache and has been + // retrieved directly we need to fire the callback + setTimeout( callback ); } else { handle = ++xhrId; if ( xhrOnUnloadAbort ) { @@ -8204,271 +8624,522 @@ if ( jQuery.support.ajax ) { abort: function() { if ( callback ) { - callback(0,1); + callback( undefined, true ); } } }; } }); } - - - - -var elemdisplay = {}, - iframe, iframeDoc, +var fxNow, timerId, rfxtypes = /^(?:toggle|show|hide)$/, - rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i, - timerId, - fxAttrs = [ - // height animations - [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ], - // width animations - [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ], - // opacity animations - [ "opacity" ] - ], - fxNow; + rfxnum = new RegExp( "^(?:([+-])=|)(" + core_pnum + ")([a-z%]*)$", "i" ), + rrun = /queueHooks$/, + animationPrefilters = [ defaultPrefilter ], + tweeners = { + "*": [function( prop, value ) { + var end, unit, + tween = this.createTween( prop, value ), + parts = rfxnum.exec( value ), + target = tween.cur(), + start = +target || 0, + scale = 1, + maxIterations = 20; + + if ( parts ) { + end = +parts[2]; + unit = parts[3] || ( jQuery.cssNumber[ prop ] ? "" : "px" ); + + // We need to compute starting value + if ( unit !== "px" && start ) { + // Iteratively approximate from a nonzero starting point + // Prefer the current property, because this process will be trivial if it uses the same units + // Fallback to end or a simple constant + start = jQuery.css( tween.elem, prop, true ) || end || 1; + + do { + // If previous iteration zeroed out, double until we get *something* + // Use a string for doubling factor so we don't accidentally see scale as unchanged below + scale = scale || ".5"; + + // Adjust and apply + start = start / scale; + jQuery.style( tween.elem, prop, start + unit ); + + // Update scale, tolerating zero or NaN from tween.cur() + // And breaking the loop if scale is unchanged or perfect, or if we've just had enough + } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations ); + } + + tween.unit = unit; + tween.start = start; + // If a +=/-= token was provided, we're doing a relative animation + tween.end = parts[1] ? start + ( parts[1] + 1 ) * end : end; + } + return tween; + }] + }; -jQuery.fn.extend({ - show: function( speed, easing, callback ) { - var elem, display; +// Animations created synchronously will run synchronously +function createFxNow() { + setTimeout(function() { + fxNow = undefined; + }); + return ( fxNow = jQuery.now() ); +} - if ( speed || speed === 0 ) { - return this.animate( genFx("show", 3), speed, easing, callback ); +function createTweens( animation, props ) { + jQuery.each( props, function( prop, value ) { + var collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ), + index = 0, + length = collection.length; + for ( ; index < length; index++ ) { + if ( collection[ index ].call( animation, prop, value ) ) { - } else { - for ( var i = 0, j = this.length; i < j; i++ ) { - elem = this[ i ]; - - if ( elem.style ) { - display = elem.style.display; + // we're done with this property + return; + } + } + }); +} - // Reset the inline display of this element to learn if it is - // being hidden by cascaded rules or not - if ( !jQuery._data(elem, "olddisplay") && display === "none" ) { - display = elem.style.display = ""; - } +function Animation( elem, properties, options ) { + var result, + stopped, + index = 0, + length = animationPrefilters.length, + deferred = jQuery.Deferred().always( function() { + // don't match elem in the :animated selector + delete tick.elem; + }), + tick = function() { + if ( stopped ) { + return false; + } + var currentTime = fxNow || createFxNow(), + remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), + // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497) + temp = remaining / animation.duration || 0, + percent = 1 - temp, + index = 0, + length = animation.tweens.length; - // Set elements which have been overridden with display: none - // in a stylesheet to whatever the default browser style is - // for such an element - if ( display === "" && jQuery.css(elem, "display") === "none" ) { - jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) ); - } - } + for ( ; index < length ; index++ ) { + animation.tweens[ index ].run( percent ); } - // Set the display of most of the elements in a second loop - // to avoid the constant reflow - for ( i = 0; i < j; i++ ) { - elem = this[ i ]; + deferred.notifyWith( elem, [ animation, percent, remaining ]); - if ( elem.style ) { - display = elem.style.display; + if ( percent < 1 && length ) { + return remaining; + } else { + deferred.resolveWith( elem, [ animation ] ); + return false; + } + }, + animation = deferred.promise({ + elem: elem, + props: jQuery.extend( {}, properties ), + opts: jQuery.extend( true, { specialEasing: {} }, options ), + originalProperties: properties, + originalOptions: options, + startTime: fxNow || createFxNow(), + duration: options.duration, + tweens: [], + createTween: function( prop, end ) { + var tween = jQuery.Tween( elem, animation.opts, prop, end, + animation.opts.specialEasing[ prop ] || animation.opts.easing ); + animation.tweens.push( tween ); + return tween; + }, + stop: function( gotoEnd ) { + var index = 0, + // if we are going to the end, we want to run all the tweens + // otherwise we skip this part + length = gotoEnd ? animation.tweens.length : 0; + if ( stopped ) { + return this; + } + stopped = true; + for ( ; index < length ; index++ ) { + animation.tweens[ index ].run( 1 ); + } - if ( display === "" || display === "none" ) { - elem.style.display = jQuery._data( elem, "olddisplay" ) || ""; - } + // resolve when we played the last frame + // otherwise, reject + if ( gotoEnd ) { + deferred.resolveWith( elem, [ animation, gotoEnd ] ); + } else { + deferred.rejectWith( elem, [ animation, gotoEnd ] ); } + return this; } + }), + props = animation.props; - return this; + propFilter( props, animation.opts.specialEasing ); + + for ( ; index < length ; index++ ) { + result = animationPrefilters[ index ].call( animation, elem, props, animation.opts ); + if ( result ) { + return result; } - }, + } - hide: function( speed, easing, callback ) { - if ( speed || speed === 0 ) { - return this.animate( genFx("hide", 3), speed, easing, callback); + createTweens( animation, props ); - } else { - var elem, display, - i = 0, - j = this.length; + if ( jQuery.isFunction( animation.opts.start ) ) { + animation.opts.start.call( elem, animation ); + } - for ( ; i < j; i++ ) { - elem = this[i]; - if ( elem.style ) { - display = jQuery.css( elem, "display" ); + jQuery.fx.timer( + jQuery.extend( tick, { + elem: elem, + anim: animation, + queue: animation.opts.queue + }) + ); - if ( display !== "none" && !jQuery._data( elem, "olddisplay" ) ) { - jQuery._data( elem, "olddisplay", display ); - } - } - } + // attach callbacks from options + return animation.progress( animation.opts.progress ) + .done( animation.opts.done, animation.opts.complete ) + .fail( animation.opts.fail ) + .always( animation.opts.always ); +} - // Set the display of the elements in a second loop - // to avoid the constant reflow - for ( i = 0; i < j; i++ ) { - if ( this[i].style ) { - this[i].style.display = "none"; - } - } +function propFilter( props, specialEasing ) { + var value, name, index, easing, hooks; - return this; + // camelCase, specialEasing and expand cssHook pass + for ( index in props ) { + name = jQuery.camelCase( index ); + easing = specialEasing[ name ]; + value = props[ index ]; + if ( jQuery.isArray( value ) ) { + easing = value[ 1 ]; + value = props[ index ] = value[ 0 ]; } - }, - // Save the old toggle function - _toggle: jQuery.fn.toggle, + if ( index !== name ) { + props[ name ] = value; + delete props[ index ]; + } - toggle: function( fn, fn2, callback ) { - var bool = typeof fn === "boolean"; + hooks = jQuery.cssHooks[ name ]; + if ( hooks && "expand" in hooks ) { + value = hooks.expand( value ); + delete props[ name ]; - if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) { - this._toggle.apply( this, arguments ); + // not quite $.extend, this wont overwrite keys already present. + // also - reusing 'index' from above because we have the correct "name" + for ( index in value ) { + if ( !( index in props ) ) { + props[ index ] = value[ index ]; + specialEasing[ index ] = easing; + } + } + } else { + specialEasing[ name ] = easing; + } + } +} - } else if ( fn == null || bool ) { - this.each(function() { - var state = bool ? fn : jQuery(this).is(":hidden"); - jQuery(this)[ state ? "show" : "hide" ](); - }); +jQuery.Animation = jQuery.extend( Animation, { + tweener: function( props, callback ) { + if ( jQuery.isFunction( props ) ) { + callback = props; + props = [ "*" ]; } else { - this.animate(genFx("toggle", 3), fn, fn2, callback); + props = props.split(" "); } - return this; - }, + var prop, + index = 0, + length = props.length; - fadeTo: function( speed, to, easing, callback ) { - return this.filter(":hidden").css("opacity", 0).show().end() - .animate({opacity: to}, speed, easing, callback); + for ( ; index < length ; index++ ) { + prop = props[ index ]; + tweeners[ prop ] = tweeners[ prop ] || []; + tweeners[ prop ].unshift( callback ); + } }, - animate: function( prop, speed, easing, callback ) { - var optall = jQuery.speed( speed, easing, callback ); + prefilter: function( callback, prepend ) { + if ( prepend ) { + animationPrefilters.unshift( callback ); + } else { + animationPrefilters.push( callback ); + } + } +}); - if ( jQuery.isEmptyObject( prop ) ) { - return this.each( optall.complete, [ false ] ); +function defaultPrefilter( elem, props, opts ) { + /*jshint validthis:true */ + var prop, index, length, + value, dataShow, toggle, + tween, hooks, oldfire, + anim = this, + style = elem.style, + orig = {}, + handled = [], + hidden = elem.nodeType && isHidden( elem ); + + // handle queue: false promises + if ( !opts.queue ) { + hooks = jQuery._queueHooks( elem, "fx" ); + if ( hooks.unqueued == null ) { + hooks.unqueued = 0; + oldfire = hooks.empty.fire; + hooks.empty.fire = function() { + if ( !hooks.unqueued ) { + oldfire(); + } + }; } + hooks.unqueued++; + + anim.always(function() { + // doing this makes sure that the complete handler will be called + // before this completes + anim.always(function() { + hooks.unqueued--; + if ( !jQuery.queue( elem, "fx" ).length ) { + hooks.empty.fire(); + } + }); + }); + } - // Do not change referenced properties as per-property easing will be lost - prop = jQuery.extend( {}, prop ); + // height/width overflow pass + if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) { + // Make sure that nothing sneaks out + // Record all 3 overflow attributes because IE does not + // change the overflow attribute when overflowX and + // overflowY are set to the same value + opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; - function doAnimation() { - // XXX 'this' does not always have a nodeName when running the - // test suite + // Set display property to inline-block for height/width + // animations on inline elements that are having width/height animated + if ( jQuery.css( elem, "display" ) === "inline" && + jQuery.css( elem, "float" ) === "none" ) { - if ( optall.queue === false ) { - jQuery._mark( this ); + // inline-level elements accept inline-block; + // block-level elements need to be inline with layout + if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) { + style.display = "inline-block"; + + } else { + style.zoom = 1; } + } + } - var opt = jQuery.extend( {}, optall ), - isElement = this.nodeType === 1, - hidden = isElement && jQuery(this).is(":hidden"), - name, val, p, e, - parts, start, end, unit, - method; + if ( opts.overflow ) { + style.overflow = "hidden"; + if ( !jQuery.support.shrinkWrapBlocks ) { + anim.always(function() { + style.overflow = opts.overflow[ 0 ]; + style.overflowX = opts.overflow[ 1 ]; + style.overflowY = opts.overflow[ 2 ]; + }); + } + } - // will store per property easing and be used to determine when an animation is complete - opt.animatedProperties = {}; - for ( p in prop ) { + // show/hide pass + for ( index in props ) { + value = props[ index ]; + if ( rfxtypes.exec( value ) ) { + delete props[ index ]; + toggle = toggle || value === "toggle"; + if ( value === ( hidden ? "hide" : "show" ) ) { + continue; + } + handled.push( index ); + } + } - // property name normalization - name = jQuery.camelCase( p ); - if ( p !== name ) { - prop[ name ] = prop[ p ]; - delete prop[ p ]; - } + length = handled.length; + if ( length ) { + dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} ); + if ( "hidden" in dataShow ) { + hidden = dataShow.hidden; + } - val = prop[ name ]; + // store state if its toggle - enables .stop().toggle() to "reverse" + if ( toggle ) { + dataShow.hidden = !hidden; + } + if ( hidden ) { + jQuery( elem ).show(); + } else { + anim.done(function() { + jQuery( elem ).hide(); + }); + } + anim.done(function() { + var prop; + jQuery._removeData( elem, "fxshow" ); + for ( prop in orig ) { + jQuery.style( elem, prop, orig[ prop ] ); + } + }); + for ( index = 0 ; index < length ; index++ ) { + prop = handled[ index ]; + tween = anim.createTween( prop, hidden ? dataShow[ prop ] : 0 ); + orig[ prop ] = dataShow[ prop ] || jQuery.style( elem, prop ); - // easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default) - if ( jQuery.isArray( val ) ) { - opt.animatedProperties[ name ] = val[ 1 ]; - val = prop[ name ] = val[ 0 ]; - } else { - opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing'; + if ( !( prop in dataShow ) ) { + dataShow[ prop ] = tween.start; + if ( hidden ) { + tween.end = tween.start; + tween.start = prop === "width" || prop === "height" ? 1 : 0; } + } + } + } +} - if ( val === "hide" && hidden || val === "show" && !hidden ) { - return opt.complete.call( this ); - } +function Tween( elem, options, prop, end, easing ) { + return new Tween.prototype.init( elem, options, prop, end, easing ); +} +jQuery.Tween = Tween; - if ( isElement && ( name === "height" || name === "width" ) ) { - // Make sure that nothing sneaks out - // Record all 3 overflow attributes because IE does not - // change the overflow attribute when overflowX and - // overflowY are set to the same value - opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ]; +Tween.prototype = { + constructor: Tween, + init: function( elem, options, prop, end, easing, unit ) { + this.elem = elem; + this.prop = prop; + this.easing = easing || "swing"; + this.options = options; + this.start = this.now = this.cur(); + this.end = end; + this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); + }, + cur: function() { + var hooks = Tween.propHooks[ this.prop ]; - // Set display property to inline-block for height/width - // animations on inline elements that are having width/height animated - if ( jQuery.css( this, "display" ) === "inline" && - jQuery.css( this, "float" ) === "none" ) { + return hooks && hooks.get ? + hooks.get( this ) : + Tween.propHooks._default.get( this ); + }, + run: function( percent ) { + var eased, + hooks = Tween.propHooks[ this.prop ]; - // inline-level elements accept inline-block; - // block-level elements need to be inline with layout - if ( !jQuery.support.inlineBlockNeedsLayout || defaultDisplay( this.nodeName ) === "inline" ) { - this.style.display = "inline-block"; + if ( this.options.duration ) { + this.pos = eased = jQuery.easing[ this.easing ]( + percent, this.options.duration * percent, 0, 1, this.options.duration + ); + } else { + this.pos = eased = percent; + } + this.now = ( this.end - this.start ) * eased + this.start; - } else { - this.style.zoom = 1; - } - } - } - } + if ( this.options.step ) { + this.options.step.call( this.elem, this.now, this ); + } + + if ( hooks && hooks.set ) { + hooks.set( this ); + } else { + Tween.propHooks._default.set( this ); + } + return this; + } +}; + +Tween.prototype.init.prototype = Tween.prototype; + +Tween.propHooks = { + _default: { + get: function( tween ) { + var result; - if ( opt.overflow != null ) { - this.style.overflow = "hidden"; + if ( tween.elem[ tween.prop ] != null && + (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) { + return tween.elem[ tween.prop ]; } - for ( p in prop ) { - e = new jQuery.fx( this, opt, p ); - val = prop[ p ]; + // passing an empty string as a 3rd parameter to .css will automatically + // attempt a parseFloat and fallback to a string if the parse fails + // so, simple values such as "10px" are parsed to Float. + // complex values such as "rotate(1rad)" are returned as is. + result = jQuery.css( tween.elem, tween.prop, "" ); + // Empty strings, null, undefined and "auto" are converted to 0. + return !result || result === "auto" ? 0 : result; + }, + set: function( tween ) { + // use step hook for back compat - use cssHook if its there - use .style if its + // available and use plain properties where available + if ( jQuery.fx.step[ tween.prop ] ) { + jQuery.fx.step[ tween.prop ]( tween ); + } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) { + jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); + } else { + tween.elem[ tween.prop ] = tween.now; + } + } + } +}; - if ( rfxtypes.test( val ) ) { +// Remove in 2.0 - this supports IE8's panic based approach +// to setting things on disconnected nodes - // Tracks whether to show or hide based on private - // data attached to the element - method = jQuery._data( this, "toggle" + p ) || ( val === "toggle" ? hidden ? "show" : "hide" : 0 ); - if ( method ) { - jQuery._data( this, "toggle" + p, method === "show" ? "hide" : "show" ); - e[ method ](); - } else { - e[ val ](); - } +Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { + set: function( tween ) { + if ( tween.elem.nodeType && tween.elem.parentNode ) { + tween.elem[ tween.prop ] = tween.now; + } + } +}; - } else { - parts = rfxnum.exec( val ); - start = e.cur(); - - if ( parts ) { - end = parseFloat( parts[2] ); - unit = parts[3] || ( jQuery.cssNumber[ p ] ? "" : "px" ); - - // We need to compute starting value - if ( unit !== "px" ) { - jQuery.style( this, p, (end || 1) + unit); - start = ( (end || 1) / e.cur() ) * start; - jQuery.style( this, p, start + unit); - } +jQuery.each([ "toggle", "show", "hide" ], function( i, name ) { + var cssFn = jQuery.fn[ name ]; + jQuery.fn[ name ] = function( speed, easing, callback ) { + return speed == null || typeof speed === "boolean" ? + cssFn.apply( this, arguments ) : + this.animate( genFx( name, true ), speed, easing, callback ); + }; +}); - // If a +=/-= token was provided, we're doing a relative animation - if ( parts[1] ) { - end = ( (parts[ 1 ] === "-=" ? -1 : 1) * end ) + start; - } +jQuery.fn.extend({ + fadeTo: function( speed, to, easing, callback ) { - e.custom( start, end, unit ); + // show any hidden elements after setting opacity to 0 + return this.filter( isHidden ).css( "opacity", 0 ).show() - } else { - e.custom( start, val, "" ); - } + // animate to the value specified + .end().animate({ opacity: to }, speed, easing, callback ); + }, + animate: function( prop, speed, easing, callback ) { + var empty = jQuery.isEmptyObject( prop ), + optall = jQuery.speed( speed, easing, callback ), + doAnimation = function() { + // Operate on a copy of prop so per-property easing won't be lost + var anim = Animation( this, jQuery.extend( {}, prop ), optall ); + doAnimation.finish = function() { + anim.stop( true ); + }; + // Empty animations, or finishing resolves immediately + if ( empty || jQuery._data( this, "finish" ) ) { + anim.stop( true ); } - } - - // For JS strict compliance - return true; - } + }; + doAnimation.finish = doAnimation; - return optall.queue === false ? + return empty || optall.queue === false ? this.each( doAnimation ) : this.queue( optall.queue, doAnimation ); }, - stop: function( type, clearQueue, gotoEnd ) { + var stopQueue = function( hooks ) { + var stop = hooks.stop; + delete hooks.stop; + stop( gotoEnd ); + }; + if ( typeof type !== "string" ) { gotoEnd = clearQueue; clearQueue = type; @@ -8479,42 +9150,27 @@ jQuery.fn.extend({ } return this.each(function() { - var index, - hadTimers = false, + var dequeue = true, + index = type != null && type + "queueHooks", timers = jQuery.timers, data = jQuery._data( this ); - // clear marker counters if we know they won't be - if ( !gotoEnd ) { - jQuery._unmark( true, this ); - } - - function stopQueue( elem, data, index ) { - var hooks = data[ index ]; - jQuery.removeData( elem, index, true ); - hooks.stop( gotoEnd ); - } - - if ( type == null ) { + if ( index ) { + if ( data[ index ] && data[ index ].stop ) { + stopQueue( data[ index ] ); + } + } else { for ( index in data ) { - if ( data[ index ] && data[ index ].stop && index.indexOf(".run") === index.length - 4 ) { - stopQueue( this, data, index ); + if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { + stopQueue( data[ index ] ); } } - } else if ( data[ index = type + ".run" ] && data[ index ].stop ){ - stopQueue( this, data, index ); } for ( index = timers.length; index--; ) { if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) { - if ( gotoEnd ) { - - // force the next step to be the last - timers[ index ]( true ); - } else { - timers[ index ].saveState(); - } - hadTimers = true; + timers[ index ].anim.stop( gotoEnd ); + dequeue = false; timers.splice( index, 1 ); } } @@ -8522,40 +9178,80 @@ jQuery.fn.extend({ // start the next in the queue if the last step wasn't forced // timers currently will call their complete callbacks, which will dequeue // but only if they were gotoEnd - if ( !( gotoEnd && hadTimers ) ) { + if ( dequeue || !gotoEnd ) { jQuery.dequeue( this, type ); } }); - } + }, + finish: function( type ) { + if ( type !== false ) { + type = type || "fx"; + } + return this.each(function() { + var index, + data = jQuery._data( this ), + queue = data[ type + "queue" ], + hooks = data[ type + "queueHooks" ], + timers = jQuery.timers, + length = queue ? queue.length : 0; -}); + // enable finishing flag on private data + data.finish = true; -// Animations created synchronously will run synchronously -function createFxNow() { - setTimeout( clearFxNow, 0 ); - return ( fxNow = jQuery.now() ); -} + // empty the queue first + jQuery.queue( this, type, [] ); -function clearFxNow() { - fxNow = undefined; -} + if ( hooks && hooks.cur && hooks.cur.finish ) { + hooks.cur.finish.call( this ); + } + + // look for any active animations, and finish them + for ( index = timers.length; index--; ) { + if ( timers[ index ].elem === this && timers[ index ].queue === type ) { + timers[ index ].anim.stop( true ); + timers.splice( index, 1 ); + } + } + + // look for any animations in the old queue and finish them + for ( index = 0; index < length; index++ ) { + if ( queue[ index ] && queue[ index ].finish ) { + queue[ index ].finish.call( this ); + } + } + + // turn off finishing flag + delete data.finish; + }); + } +}); // Generate parameters to create a standard animation -function genFx( type, num ) { - var obj = {}; +function genFx( type, includeWidth ) { + var which, + attrs = { height: type }, + i = 0; + + // if we include width, step value is 1 to do all cssExpand values, + // if we don't include width, step value is 2 to skip over Left and Right + includeWidth = includeWidth? 1 : 0; + for( ; i < 4 ; i += 2 - includeWidth ) { + which = cssExpand[ i ]; + attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; + } - jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice( 0, num )), function() { - obj[ this ] = type; - }); + if ( includeWidth ) { + attrs.opacity = attrs.width = type; + } - return obj; + return attrs; } // Generate shortcuts for custom animations jQuery.each({ - slideDown: genFx( "show", 1 ), - slideUp: genFx( "hide", 1 ), - slideToggle: genFx( "toggle", 1 ), + slideDown: genFx("show"), + slideUp: genFx("hide"), + slideToggle: genFx("toggle"), fadeIn: { opacity: "show" }, fadeOut: { opacity: "hide" }, fadeToggle: { opacity: "toggle" } @@ -8565,279 +9261,98 @@ jQuery.each({ }; }); -jQuery.extend({ - speed: function( speed, easing, fn ) { - var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { - complete: fn || !fn && easing || - jQuery.isFunction( speed ) && speed, - duration: speed, - easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing - }; - - opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : - opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; - - // normalize opt.queue - true/undefined/null -> "fx" - if ( opt.queue == null || opt.queue === true ) { - opt.queue = "fx"; - } - - // Queueing - opt.old = opt.complete; - - opt.complete = function( noUnmark ) { - if ( jQuery.isFunction( opt.old ) ) { - opt.old.call( this ); - } - - if ( opt.queue ) { - jQuery.dequeue( this, opt.queue ); - } else if ( noUnmark !== false ) { - jQuery._unmark( this ); - } - }; - - return opt; - }, - - easing: { - linear: function( p, n, firstNum, diff ) { - return firstNum + diff * p; - }, - swing: function( p, n, firstNum, diff ) { - return ( ( -Math.cos( p*Math.PI ) / 2 ) + 0.5 ) * diff + firstNum; - } - }, - - timers: [], +jQuery.speed = function( speed, easing, fn ) { + var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { + complete: fn || !fn && easing || + jQuery.isFunction( speed ) && speed, + duration: speed, + easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing + }; - fx: function( elem, options, prop ) { - this.options = options; - this.elem = elem; - this.prop = prop; + opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : + opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; - options.orig = options.orig || {}; + // normalize opt.queue - true/undefined/null -> "fx" + if ( opt.queue == null || opt.queue === true ) { + opt.queue = "fx"; } -}); + // Queueing + opt.old = opt.complete; -jQuery.fx.prototype = { - // Simple function for setting a style value - update: function() { - if ( this.options.step ) { - this.options.step.call( this.elem, this.now, this ); + opt.complete = function() { + if ( jQuery.isFunction( opt.old ) ) { + opt.old.call( this ); } - ( jQuery.fx.step[ this.prop ] || jQuery.fx.step._default )( this ); - }, - - // Get the current size - cur: function() { - if ( this.elem[ this.prop ] != null && (!this.elem.style || this.elem.style[ this.prop ] == null) ) { - return this.elem[ this.prop ]; - } - - var parsed, - r = jQuery.css( this.elem, this.prop ); - // Empty strings, null, undefined and "auto" are converted to 0, - // complex values such as "rotate(1rad)" are returned as is, - // simple values such as "10px" are parsed to Float. - return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed; - }, - - // Start an animation from one number to another - custom: function( from, to, unit ) { - var self = this, - fx = jQuery.fx; - - this.startTime = fxNow || createFxNow(); - this.end = to; - this.now = this.start = from; - this.pos = this.state = 0; - this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" ); - - function t( gotoEnd ) { - return self.step( gotoEnd ); + if ( opt.queue ) { + jQuery.dequeue( this, opt.queue ); } + }; - t.queue = this.options.queue; - t.elem = this.elem; - t.saveState = function() { - if ( self.options.hide && jQuery._data( self.elem, "fxshow" + self.prop ) === undefined ) { - jQuery._data( self.elem, "fxshow" + self.prop, self.start ); - } - }; - - if ( t() && jQuery.timers.push(t) && !timerId ) { - timerId = setInterval( fx.tick, fx.interval ); - } - }, - - // Simple 'show' function - show: function() { - var dataShow = jQuery._data( this.elem, "fxshow" + this.prop ); - - // Remember where we started, so that we can go back to it later - this.options.orig[ this.prop ] = dataShow || jQuery.style( this.elem, this.prop ); - this.options.show = true; - - // Begin the animation - // Make sure that we start at a small width/height to avoid any flash of content - if ( dataShow !== undefined ) { - // This show is picking up where a previous hide or show left off - this.custom( this.cur(), dataShow ); - } else { - this.custom( this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur() ); - } - - // Start by showing the element - jQuery( this.elem ).show(); - }, - - // Simple 'hide' function - hide: function() { - // Remember where we started, so that we can go back to it later - this.options.orig[ this.prop ] = jQuery._data( this.elem, "fxshow" + this.prop ) || jQuery.style( this.elem, this.prop ); - this.options.hide = true; + return opt; +}; - // Begin the animation - this.custom( this.cur(), 0 ); +jQuery.easing = { + linear: function( p ) { + return p; }, + swing: function( p ) { + return 0.5 - Math.cos( p*Math.PI ) / 2; + } +}; - // Each step of an animation - step: function( gotoEnd ) { - var p, n, complete, - t = fxNow || createFxNow(), - done = true, - elem = this.elem, - options = this.options; - - if ( gotoEnd || t >= options.duration + this.startTime ) { - this.now = this.end; - this.pos = this.state = 1; - this.update(); - - options.animatedProperties[ this.prop ] = true; - - for ( p in options.animatedProperties ) { - if ( options.animatedProperties[ p ] !== true ) { - done = false; - } - } - - if ( done ) { - // Reset the overflow - if ( options.overflow != null && !jQuery.support.shrinkWrapBlocks ) { - - jQuery.each( [ "", "X", "Y" ], function( index, value ) { - elem.style[ "overflow" + value ] = options.overflow[ index ]; - }); - } - - // Hide the element if the "hide" operation was done - if ( options.hide ) { - jQuery( elem ).hide(); - } - - // Reset the properties, if the item has been hidden or shown - if ( options.hide || options.show ) { - for ( p in options.animatedProperties ) { - jQuery.style( elem, p, options.orig[ p ] ); - jQuery.removeData( elem, "fxshow" + p, true ); - // Toggle data is no longer needed - jQuery.removeData( elem, "toggle" + p, true ); - } - } - - // Execute the complete function - // in the event that the complete function throws an exception - // we must ensure it won't be called twice. #5684 - - complete = options.complete; - if ( complete ) { - - options.complete = false; - complete.call( elem ); - } - } - - return false; +jQuery.timers = []; +jQuery.fx = Tween.prototype.init; +jQuery.fx.tick = function() { + var timer, + timers = jQuery.timers, + i = 0; - } else { - // classical easing cannot be used with an Infinity duration - if ( options.duration == Infinity ) { - this.now = t; - } else { - n = t - this.startTime; - this.state = n / options.duration; + fxNow = jQuery.now(); - // Perform the easing function, defaults to swing - this.pos = jQuery.easing[ options.animatedProperties[this.prop] ]( this.state, n, 0, 1, options.duration ); - this.now = this.start + ( (this.end - this.start) * this.pos ); - } - // Perform the next step of the animation - this.update(); + for ( ; i < timers.length; i++ ) { + timer = timers[ i ]; + // Checks the timer has not already been removed + if ( !timer() && timers[ i ] === timer ) { + timers.splice( i--, 1 ); } + } - return true; + if ( !timers.length ) { + jQuery.fx.stop(); } + fxNow = undefined; }; -jQuery.extend( jQuery.fx, { - tick: function() { - var timer, - timers = jQuery.timers, - i = 0; - - for ( ; i < timers.length; i++ ) { - timer = timers[ i ]; - // Checks the timer has not already been removed - if ( !timer() && timers[ i ] === timer ) { - timers.splice( i--, 1 ); - } - } - - if ( !timers.length ) { - jQuery.fx.stop(); - } - }, - - interval: 13, +jQuery.fx.timer = function( timer ) { + if ( timer() && jQuery.timers.push( timer ) ) { + jQuery.fx.start(); + } +}; - stop: function() { - clearInterval( timerId ); - timerId = null; - }, +jQuery.fx.interval = 13; - speeds: { - slow: 600, - fast: 200, - // Default speed - _default: 400 - }, +jQuery.fx.start = function() { + if ( !timerId ) { + timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval ); + } +}; - step: { - opacity: function( fx ) { - jQuery.style( fx.elem, "opacity", fx.now ); - }, +jQuery.fx.stop = function() { + clearInterval( timerId ); + timerId = null; +}; - _default: function( fx ) { - if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) { - fx.elem.style[ fx.prop ] = fx.now + fx.unit; - } else { - fx.elem[ fx.prop ] = fx.now; - } - } - } -}); +jQuery.fx.speeds = { + slow: 600, + fast: 200, + // Default speed + _default: 400 +}; -// Adds width/height step functions -// Do not set anything below 0 -jQuery.each([ "width", "height" ], function( i, prop ) { - jQuery.fx.step[ prop ] = function( fx ) { - jQuery.style( fx.elem, prop, Math.max(0, fx.now) + fx.unit ); - }; -}); +// Back Compat <1.8 extension point +jQuery.fx.step = {}; if ( jQuery.expr && jQuery.expr.filters ) { jQuery.expr.filters.animated = function( elem ) { @@ -8846,187 +9361,45 @@ if ( jQuery.expr && jQuery.expr.filters ) { }).length; }; } - -// Try to restore the default display value of an element -function defaultDisplay( nodeName ) { - - if ( !elemdisplay[ nodeName ] ) { - - var body = document.body, - elem = jQuery( "<" + nodeName + ">" ).appendTo( body ), - display = elem.css( "display" ); - elem.remove(); - - // If the simple way fails, - // get element's real default display by attaching it to a temp iframe - if ( display === "none" || display === "" ) { - // No iframe to use yet, so create it - if ( !iframe ) { - iframe = document.createElement( "iframe" ); - iframe.frameBorder = iframe.width = iframe.height = 0; - } - - body.appendChild( iframe ); - - // Create a cacheable copy of the iframe document on first call. - // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML - // document to it; WebKit & Firefox won't allow reusing the iframe document. - if ( !iframeDoc || !iframe.createElement ) { - iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document; - iframeDoc.write( ( document.compatMode === "CSS1Compat" ? "<!doctype html>" : "" ) + "<html><body>" ); - iframeDoc.close(); - } - - elem = iframeDoc.createElement( nodeName ); - - iframeDoc.body.appendChild( elem ); - - display = jQuery.css( elem, "display" ); - body.removeChild( iframe ); - } - - // Store the correct default display - elemdisplay[ nodeName ] = display; - } - - return elemdisplay[ nodeName ]; -} - - - - -var rtable = /^t(?:able|d|h)$/i, - rroot = /^(?:body|html)$/i; - -if ( "getBoundingClientRect" in document.documentElement ) { - jQuery.fn.offset = function( options ) { - var elem = this[0], box; - - if ( options ) { - return this.each(function( i ) { +jQuery.fn.offset = function( options ) { + if ( arguments.length ) { + return options === undefined ? + this : + this.each(function( i ) { jQuery.offset.setOffset( this, options, i ); }); - } - - if ( !elem || !elem.ownerDocument ) { - return null; - } - - if ( elem === elem.ownerDocument.body ) { - return jQuery.offset.bodyOffset( elem ); - } - - try { - box = elem.getBoundingClientRect(); - } catch(e) {} - - var doc = elem.ownerDocument, - docElem = doc.documentElement; - - // Make sure we're not dealing with a disconnected DOM node - if ( !box || !jQuery.contains( docElem, elem ) ) { - return box ? { top: box.top, left: box.left } : { top: 0, left: 0 }; - } - - var body = doc.body, - win = getWindow(doc), - clientTop = docElem.clientTop || body.clientTop || 0, - clientLeft = docElem.clientLeft || body.clientLeft || 0, - scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop, - scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft, - top = box.top + scrollTop - clientTop, - left = box.left + scrollLeft - clientLeft; - - return { top: top, left: left }; - }; - -} else { - jQuery.fn.offset = function( options ) { - var elem = this[0]; - - if ( options ) { - return this.each(function( i ) { - jQuery.offset.setOffset( this, options, i ); - }); - } - - if ( !elem || !elem.ownerDocument ) { - return null; - } - - if ( elem === elem.ownerDocument.body ) { - return jQuery.offset.bodyOffset( elem ); - } - - var computedStyle, - offsetParent = elem.offsetParent, - prevOffsetParent = elem, - doc = elem.ownerDocument, - docElem = doc.documentElement, - body = doc.body, - defaultView = doc.defaultView, - prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle, - top = elem.offsetTop, - left = elem.offsetLeft; - - while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) { - if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) { - break; - } - - computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle; - top -= elem.scrollTop; - left -= elem.scrollLeft; - - if ( elem === offsetParent ) { - top += elem.offsetTop; - left += elem.offsetLeft; - - if ( jQuery.support.doesNotAddBorder && !(jQuery.support.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) { - top += parseFloat( computedStyle.borderTopWidth ) || 0; - left += parseFloat( computedStyle.borderLeftWidth ) || 0; - } - - prevOffsetParent = offsetParent; - offsetParent = elem.offsetParent; - } + } - if ( jQuery.support.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) { - top += parseFloat( computedStyle.borderTopWidth ) || 0; - left += parseFloat( computedStyle.borderLeftWidth ) || 0; - } + var docElem, win, + box = { top: 0, left: 0 }, + elem = this[ 0 ], + doc = elem && elem.ownerDocument; - prevComputedStyle = computedStyle; - } + if ( !doc ) { + return; + } - if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) { - top += body.offsetTop; - left += body.offsetLeft; - } + docElem = doc.documentElement; - if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) { - top += Math.max( docElem.scrollTop, body.scrollTop ); - left += Math.max( docElem.scrollLeft, body.scrollLeft ); - } + // Make sure it's not a disconnected DOM node + if ( !jQuery.contains( docElem, elem ) ) { + return box; + } - return { top: top, left: left }; + // If we don't have gBCR, just use 0,0 rather than error + // BlackBerry 5, iOS 3 (original iPhone) + if ( typeof elem.getBoundingClientRect !== core_strundefined ) { + box = elem.getBoundingClientRect(); + } + win = getWindow( doc ); + return { + top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ), + left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 ) }; -} +}; jQuery.offset = { - bodyOffset: function( body ) { - var top = body.offsetTop, - left = body.offsetLeft; - - if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) { - top += parseFloat( jQuery.css(body, "marginTop") ) || 0; - left += parseFloat( jQuery.css(body, "marginLeft") ) || 0; - } - - return { top: top, left: left }; - }, - setOffset: function( elem, options, i ) { var position = jQuery.css( elem, "position" ); @@ -9075,85 +9448,78 @@ jQuery.offset = { jQuery.fn.extend({ position: function() { - if ( !this[0] ) { - return null; + if ( !this[ 0 ] ) { + return; } - var elem = this[0], + var offsetParent, offset, + parentOffset = { top: 0, left: 0 }, + elem = this[ 0 ]; - // Get *real* offsetParent - offsetParent = this.offsetParent(), + // fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is it's only offset parent + if ( jQuery.css( elem, "position" ) === "fixed" ) { + // we assume that getBoundingClientRect is available when computed position is fixed + offset = elem.getBoundingClientRect(); + } else { + // Get *real* offsetParent + offsetParent = this.offsetParent(); - // Get correct offsets - offset = this.offset(), - parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset(); + // Get correct offsets + offset = this.offset(); + if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) { + parentOffset = offsetParent.offset(); + } + + // Add offsetParent borders + parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ); + parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true ); + } - // Subtract element margins + // Subtract parent offsets and element margins // note: when an element has margin: auto the offsetLeft and marginLeft // are the same in Safari causing offset.left to incorrectly be 0 - offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0; - offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0; - - // Add offsetParent borders - parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0; - parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0; - - // Subtract the two offsets return { - top: offset.top - parentOffset.top, - left: offset.left - parentOffset.left + top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ), + left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true) }; }, offsetParent: function() { return this.map(function() { - var offsetParent = this.offsetParent || document.body; - while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) { + var offsetParent = this.offsetParent || document.documentElement; + while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position") === "static" ) ) { offsetParent = offsetParent.offsetParent; } - return offsetParent; + return offsetParent || document.documentElement; }); } }); // Create scrollLeft and scrollTop methods -jQuery.each( ["Left", "Top"], function( i, name ) { - var method = "scroll" + name; +jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) { + var top = /Y/.test( prop ); jQuery.fn[ method ] = function( val ) { - var elem, win; + return jQuery.access( this, function( elem, method, val ) { + var win = getWindow( elem ); - if ( val === undefined ) { - elem = this[ 0 ]; - - if ( !elem ) { - return null; + if ( val === undefined ) { + return win ? (prop in win) ? win[ prop ] : + win.document.documentElement[ method ] : + elem[ method ]; } - win = getWindow( elem ); - - // Return the scroll offset - return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] : - jQuery.support.boxModel && win.document.documentElement[ method ] || - win.document.body[ method ] : - elem[ method ]; - } - - // Set the scroll offset - return this.each(function() { - win = getWindow( this ); - if ( win ) { win.scrollTo( - !i ? val : jQuery( win ).scrollLeft(), - i ? val : jQuery( win ).scrollTop() + !top ? val : jQuery( win ).scrollLeft(), + top ? val : jQuery( win ).scrollTop() ); } else { - this[ method ] = val; + elem[ method ] = val; } - }); + }, method, val, arguments.length, null ); }; }); @@ -9164,84 +9530,51 @@ function getWindow( elem ) { elem.defaultView || elem.parentWindow : false; } +// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods +jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { + jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) { + // margin is only for outerHeight, outerWidth + jQuery.fn[ funcName ] = function( margin, value ) { + var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), + extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" ); + + return jQuery.access( this, function( elem, type, value ) { + var doc; + + if ( jQuery.isWindow( elem ) ) { + // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there + // isn't a whole lot we can do. See pull request at this URL for discussion: + // https://github.com/jquery/jquery/pull/764 + return elem.document.documentElement[ "client" + name ]; + } + + // Get document width or height + if ( elem.nodeType === 9 ) { + doc = elem.documentElement; + + // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest + // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it. + return Math.max( + elem.body[ "scroll" + name ], doc[ "scroll" + name ], + elem.body[ "offset" + name ], doc[ "offset" + name ], + doc[ "client" + name ] + ); + } + return value === undefined ? + // Get width or height on the element, requesting but not forcing parseFloat + jQuery.css( elem, type, extra ) : - - -// Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods -jQuery.each([ "Height", "Width" ], function( i, name ) { - - var type = name.toLowerCase(); - - // innerHeight and innerWidth - jQuery.fn[ "inner" + name ] = function() { - var elem = this[0]; - return elem ? - elem.style ? - parseFloat( jQuery.css( elem, type, "padding" ) ) : - this[ type ]() : - null; - }; - - // outerHeight and outerWidth - jQuery.fn[ "outer" + name ] = function( margin ) { - var elem = this[0]; - return elem ? - elem.style ? - parseFloat( jQuery.css( elem, type, margin ? "margin" : "border" ) ) : - this[ type ]() : - null; - }; - - jQuery.fn[ type ] = function( size ) { - // Get window width or height - var elem = this[0]; - if ( !elem ) { - return size == null ? null : this; - } - - if ( jQuery.isFunction( size ) ) { - return this.each(function( i ) { - var self = jQuery( this ); - self[ type ]( size.call( this, i, self[ type ]() ) ); - }); - } - - if ( jQuery.isWindow( elem ) ) { - // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode - // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat - var docElemProp = elem.document.documentElement[ "client" + name ], - body = elem.document.body; - return elem.document.compatMode === "CSS1Compat" && docElemProp || - body && body[ "client" + name ] || docElemProp; - - // Get document width or height - } else if ( elem.nodeType === 9 ) { - // Either scroll[Width/Height] or offset[Width/Height], whichever is greater - return Math.max( - elem.documentElement["client" + name], - elem.body["scroll" + name], elem.documentElement["scroll" + name], - elem.body["offset" + name], elem.documentElement["offset" + name] - ); - - // Get or set width or height on the element - } else if ( size === undefined ) { - var orig = jQuery.css( elem, type ), - ret = parseFloat( orig ); - - return jQuery.isNumeric( ret ) ? ret : orig; - - // Set the width or height on the element (default to pixels if value is unitless) - } else { - return this.css( type, typeof size === "string" ? size : size + "px" ); - } - }; - + // Set width or height on the element + jQuery.style( elem, type, value, extra ); + }, type, chainable ? margin : undefined, chainable, null ); + }; + }); }); +// Limit scope pollution from any deprecated API +// (function() { - - - +// })(); // Expose jQuery to the global object window.jQuery = window.$ = jQuery; @@ -9261,6 +9594,4 @@ if ( typeof define === "function" && define.amd && define.amd.jQuery ) { define( "jquery", [], function () { return jQuery; } ); } - - })( window ); diff --git a/src/static/js/jquery_browser.js b/src/static/js/jquery_browser.js new file mode 100644 index 00000000..0d61e0dd --- /dev/null +++ b/src/static/js/jquery_browser.js @@ -0,0 +1,50 @@ +/* + Copied from jQuery 1.8, the last jquery version with browser recognition support +*/ + +(function(){ + // Use of jQuery.browser is frowned upon. + // More details: http://api.jquery.com/jQuery.browser + // jQuery.uaMatch maintained for back-compat + var uaMatch = function( ua ) { + ua = ua.toLowerCase(); + + var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) || + /(webkit)[ \/]([\w.]+)/.exec( ua ) || + /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) || + /(msie) ([\w.]+)/.exec( ua ) || + ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) || + []; + + return { + browser: match[ 1 ] || "", + version: match[ 2 ] || "0" + }; + }; + + var userAgent = navigator.userAgent; + var matched = uaMatch(userAgent); + var browser = {}; + + if ( matched.browser ) { + browser[ matched.browser ] = true; + browser.version = matched.version; + } + + // Chrome is Webkit, but Webkit is also Safari. + if ( browser.chrome ) { + browser.webkit = true; + } else if ( browser.webkit ) { + browser.safari = true; + } + + //custom extensions, the original jquery didn't have these + browser.windows = /windows/i.test(userAgent); + browser.mobile = /mobile/i.test(userAgent) || /android/i.test(userAgent); + + if(typeof exports !== 'undefined'){ + exports.browser = browser; + } else{ + $.browser = browser; + } +})();
\ No newline at end of file diff --git a/src/static/js/l10n.js b/src/static/js/l10n.js index a67a7c1a..c79ea706 100644 --- a/src/static/js/l10n.js +++ b/src/static/js/l10n.js @@ -1,8 +1,8 @@ (function(document) { // Set language for l10n - var language = document.cookie.match(/language=((\w{2,3})(-w+)?)/); + var language = document.cookie.match(/language=((\w{2,3})(-\w+)?)/); if(language) language = language[1]; - + html10n.bind('indexed', function() { html10n.localize([language, navigator.language, navigator.userLanguage, 'en']) }) diff --git a/src/static/js/pad.js b/src/static/js/pad.js index 27dd3b73..6e8b2ae0 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -35,7 +35,6 @@ var chat = require('./chat').chat; var getCollabClient = require('./collab_client').getCollabClient; var padconnectionstatus = require('./pad_connectionstatus').padconnectionstatus; var padcookie = require('./pad_cookie').padcookie; -var paddocbar = require('./pad_docbar').paddocbar; var padeditbar = require('./pad_editbar').padeditbar; var padeditor = require('./pad_editor').padeditor; var padimpexp = require('./pad_impexp').padimpexp; @@ -391,10 +390,6 @@ var pad = { { return clientVars.clientIp; }, - getIsProPad: function() - { - return clientVars.isProPad; - }, getColorPalette: function() { return clientVars.colorPalette; @@ -467,11 +462,6 @@ var pad = { } // order of inits is important here: - padcookie.init(clientVars.cookiePrefsToSet, this); - - $("#widthprefcheck").click(pad.toggleWidthPref); - // $("#sidebarcheck").click(pad.togglewSidebar); - pad.myUserInfo = { userId: clientVars.userId, name: clientVars.userName, @@ -488,20 +478,12 @@ var pad = { $("#specialkeyarea").html("mode: " + String(clientVars.specialKeyTranslation).toUpperCase()); } } - paddocbar.init( - { - isTitleEditable: pad.getIsProPad(), - initialTitle: clientVars.initialTitle, - initialPassword: clientVars.initialPassword, - guestPolicy: pad.padOptions.guestPolicy - }, this); padimpexp.init(this); padsavedrevs.init(this); padeditor.init(postAceInit, pad.padOptions.view || {}, this); paduserlist.init(pad.myUserInfo, this); - // padchat.init(clientVars.chatHistory, pad.myUserInfo); padconnectionstatus.init(); padmodals.init(this); @@ -540,7 +522,7 @@ var pad = { $('#options-stickychat').prop("checked", true); // set the checkbox to on } if(padcookie.getPref("showAuthorshipColors") == false){ - pad.changeViewOption('showAuthorColors', false); + pad.changeViewOption('showAuthorColors', false); } hooks.aCallAll("postAceInit", {ace: padeditor.ace}); } @@ -553,31 +535,11 @@ var pad = { { pad.myUserInfo.name = newName; pad.collabClient.updateUserInfo(pad.myUserInfo); - //padchat.handleUserJoinOrUpdate(pad.myUserInfo); }, notifyChangeColor: function(newColorId) { pad.myUserInfo.colorId = newColorId; pad.collabClient.updateUserInfo(pad.myUserInfo); - //padchat.handleUserJoinOrUpdate(pad.myUserInfo); - }, - notifyChangeTitle: function(newTitle) - { - pad.collabClient.sendClientMessage( - { - type: 'padtitle', - title: newTitle, - changedBy: pad.myUserInfo.name || "unnamed" - }); - }, - notifyChangePassword: function(newPass) - { - pad.collabClient.sendClientMessage( - { - type: 'padpassword', - password: newPass, - changedBy: pad.myUserInfo.name || "unnamed" - }); }, changePadOption: function(key, value) { @@ -619,7 +581,6 @@ var pad = { { // order important here pad.padOptions.guestPolicy = opts.guestPolicy; - paddocbar.setGuestPolicy(opts.guestPolicy); } }, getPadOptions: function() @@ -629,7 +590,7 @@ var pad = { }, isPadPublic: function() { - return (!pad.getIsProPad()) || (pad.getPadOptions().guestPolicy == 'allow'); + return pad.getPadOptions().guestPolicy == 'allow'; }, suggestUserName: function(userId, name) { @@ -643,17 +604,14 @@ var pad = { handleUserJoin: function(userInfo) { paduserlist.userJoinOrUpdate(userInfo); - //padchat.handleUserJoinOrUpdate(userInfo); }, handleUserUpdate: function(userInfo) { paduserlist.userJoinOrUpdate(userInfo); - //padchat.handleUserJoinOrUpdate(userInfo); }, handleUserLeave: function(userInfo) { paduserlist.userLeave(userInfo); - //padchat.handleUserLeave(userInfo); }, handleClientMessage: function(msg) { @@ -665,18 +623,6 @@ var pad = { paduserlist.setMyUserInfo(pad.myUserInfo); } } - else if (msg.type == 'chat') - { - //padchat.receiveChat(msg); - } - else if (msg.type == 'padtitle') - { - paddocbar.changeTitle(msg.title); - } - else if (msg.type == 'padpassword') - { - paddocbar.changePassword(msg.password); - } else if (msg.type == 'newRevisionList') { padsavedrevs.newRevisionList(msg.revisionList); @@ -769,7 +715,6 @@ var pad = { } padeditor.disable(); padeditbar.disable(); - paddocbar.disable(); padimpexp.disable(); padconnectionstatus.disconnected(message); @@ -796,28 +741,10 @@ var pad = { }, 1000); } - // pad.determineSidebarVisibility(isConnected && !isInitialConnect); pad.determineChatVisibility(isConnected && !isInitialConnect); pad.determineAuthorshipColorsVisibility(); }, -/* determineSidebarVisibility: function(asNowConnectedFeedback) - { - if (pad.isFullyConnected()) - { - var setSidebarVisibility = padutils.getCancellableAction("set-sidebar-visibility", function() - { - // $("body").toggleClass('hidesidebar', !! padcookie.getPref('hideSidebar')); - }); - window.setTimeout(setSidebarVisibility, asNowConnectedFeedback ? 3000 : 0); - } - else - { - padutils.cancelActions("set-sidebar-visibility"); - $("body").removeClass('hidesidebar'); - } - }, -*/ determineChatVisibility: function(asNowConnectedFeedback){ var chatVisCookie = padcookie.getPref('chatAlwaysVisible'); if(chatVisCookie){ // if the cookie is set for chat always visible @@ -879,37 +806,6 @@ var pad = { $('form#reconnectform input.missedChanges').val(JSON.stringify(pad.collabClient.getMissedChanges())); $('form#reconnectform').submit(); }, - toggleWidthPref: function() - { - var newValue = !padcookie.getPref('fullWidth'); - padcookie.setPref('fullWidth', newValue); - $("#widthprefcheck").toggleClass('widthprefchecked', !! newValue).toggleClass('widthprefunchecked', !newValue); - pad.handleWidthChange(); - }, -/* - toggleSidebar: function() - { - var newValue = !padcookie.getPref('hideSidebar'); - padcookie.setPref('hideSidebar', newValue); - $("#sidebarcheck").toggleClass('sidebarchecked', !newValue).toggleClass('sidebarunchecked', !! newValue); - pad.determineSidebarVisibility(); - }, -*/ - handleWidthChange: function() - { - var isFullWidth = padcookie.getPref('fullWidth'); - if (isFullWidth) - { - $("body").addClass('fullwidth').removeClass('limwidth').removeClass('squish1width').removeClass('squish2width'); - } - else - { - $("body").addClass('limwidth').removeClass('fullwidth'); - - var pageWidth = $(window).width(); - $("body").toggleClass('squish1width', (pageWidth < 912 && pageWidth > 812)).toggleClass('squish2width', (pageWidth <= 812)); - } - }, // this is called from code put into a frame from the server: handleImportExportFrameCall: function(callName, varargs) { diff --git a/src/static/js/pad_connectionstatus.js b/src/static/js/pad_connectionstatus.js index c592afbd..2d9354ab 100644 --- a/src/static/js/pad_connectionstatus.js +++ b/src/static/js/pad_connectionstatus.js @@ -43,9 +43,8 @@ var padconnectionstatus = (function() status = { what: 'connected' }; - padmodals.showModal('connected'); - padmodals.hideOverlay(500); + padmodals.hideOverlay(); }, reconnecting: function() { @@ -54,7 +53,7 @@ var padconnectionstatus = (function() }; padmodals.showModal('reconnecting'); - padmodals.showOverlay(500); + padmodals.showOverlay(); }, disconnected: function(msg) { @@ -73,10 +72,11 @@ var padconnectionstatus = (function() } padmodals.showModal(k); - padmodals.showOverlay(500); + padmodals.showOverlay(); }, isFullyConnected: function() { + padmodals.hideOverlay(); return status.what == 'connected'; }, getStatus: function() diff --git a/src/static/js/pad_cookie.js b/src/static/js/pad_cookie.js index 1bb5700a..9866dbfd 100644 --- a/src/static/js/pad_cookie.js +++ b/src/static/js/pad_cookie.js @@ -73,7 +73,7 @@ var padcookie = (function() } setRawCookie(stringifyCookie(cookieData)); - if (pad.getIsProPad() && (!getRawCookie()) && (!alreadyWarnedAboutNoCookies)) + if ((!getRawCookie()) && (!alreadyWarnedAboutNoCookies)) { alert("Warning: it appears that your browser does not have cookies enabled." + " EtherPad uses cookies to keep track of unique users for the purpose" + " of putting a quota on the number of active users. Using EtherPad without " + " cookies may fill up your server's user quota faster than expected."); alreadyWarnedAboutNoCookies = true; diff --git a/src/static/js/pad_docbar.js b/src/static/js/pad_docbar.js deleted file mode 100644 index c5858126..00000000 --- a/src/static/js/pad_docbar.js +++ /dev/null @@ -1,466 +0,0 @@ -/** - * This code is mostly from the old Etherpad. Please help us to comment this code. - * This helps other people to understand this code better and helps them to improve it. - * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED - */ - -/** - * Copyright 2009 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS-IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var padutils = require('./pad_utils').padutils; - -var paddocbar = (function() -{ - var isTitleEditable = false; - var isEditingTitle = false; - var isEditingPassword = false; - var enabled = false; - - function getPanelOpenCloseAnimator(panelName, panelHeight) - { - var wrapper = $("#" + panelName + "-wrapper"); - var openingClass = "docbar" + panelName + "-opening"; - var openClass = "docbar" + panelName + "-open"; - var closingClass = "docbar" + panelName + "-closing"; - - function setPanelState(action) - { - $("#docbar").removeClass(openingClass).removeClass(openClass). - removeClass(closingClass); - if (action != "closed") - { - $("#docbar").addClass("docbar" + panelName + "-" + action); - } - } - - function openCloseAnimate(state) - { - function pow(x) - { - x = 1 - x; - x *= x * x; - return 1 - x; - } - - if (state == -1) - { - // startng to open - setPanelState("opening"); - wrapper.css('height', '0'); - } - else if (state < 0) - { - // opening - var height = Math.round(pow(state + 1) * (panelHeight - 1)) + 'px'; - wrapper.css('height', height); - } - else if (state == 0) - { - // open - setPanelState("open"); - wrapper.css('height', panelHeight - 1); - } - else if (state < 1) - { - // closing - setPanelState("closing"); - var height = Math.round((1 - pow(state)) * (panelHeight - 1)) + 'px'; - wrapper.css('height', height); - } - else if (state == 1) - { - // closed - setPanelState("closed"); - wrapper.css('height', '0'); - } - } - - return padutils.makeShowHideAnimator(openCloseAnimate, false, 25, 500); - } - - - var currentPanel = null; - - function setCurrentPanel(newCurrentPanel) - { - if (currentPanel != newCurrentPanel) - { - currentPanel = newCurrentPanel; - padutils.cancelActions("hide-docbar-panel"); - } - } - var panels; - - function changePassword(newPass) - { - if ((newPass || null) != (self.password || null)) - { - self.password = (newPass || null); - pad.notifyChangePassword(newPass); - } - self.renderPassword(); - } - - var pad = undefined; - var self = { - title: null, - password: null, - init: function(opts, _pad) - { - pad = _pad; - - panels = { - impexp: { - animator: getPanelOpenCloseAnimator("impexp", 160) - }, - savedrevs: { - animator: getPanelOpenCloseAnimator("savedrevs", 79) - }, - options: { - animator: getPanelOpenCloseAnimator("options", 114) - }, - security: { - animator: getPanelOpenCloseAnimator("security", 130) - } - }; - - isTitleEditable = opts.isTitleEditable; - self.title = opts.initialTitle; - self.password = opts.initialPassword; - - $("#docbarimpexp").click(function() - { - self.togglePanel("impexp"); - }); - $("#docbarsavedrevs").click(function() - { - self.togglePanel("savedrevs"); - }); - $("#docbaroptions").click(function() - { - self.togglePanel("options"); - }); - $("#docbarsecurity").click(function() - { - self.togglePanel("security"); - }); - - $("#docbarrenamelink").click(self.editTitle); - $("#padtitlesave").click(function() - { - self.closeTitleEdit(true); - }); - $("#padtitlecancel").click(function() - { - self.closeTitleEdit(false); - }); - padutils.bindEnterAndEscape($("#padtitleedit"), function() - { - $("#padtitlesave").trigger('click'); - }, function() - { - $("#padtitlecancel").trigger('click'); - }); - - $("#options-close").click(function() - { - self.setShownPanel(null); - }); - $("#security-close").click(function() - { - self.setShownPanel(null); - }); - - if (pad.getIsProPad()) - { - self.initPassword(); - } - - enabled = true; - self.render(); - - // public/private - $("#security-access input").bind("change click", function(evt) - { - pad.changePadOption('guestPolicy', $("#security-access input[name='padaccess']:checked").val()); - }); - self.setGuestPolicy(opts.guestPolicy); - }, - setGuestPolicy: function(newPolicy) - { - $("#security-access input[value='" + newPolicy + "']").attr("checked", "checked"); - self.render(); - }, - initPassword: function() - { - self.renderPassword(); - $("#password-clearlink").click(function() - { - changePassword(null); - }); - $("#password-setlink, #password-display").click(function() - { - self.enterPassword(); - }); - $("#password-cancellink").click(function() - { - self.exitPassword(false); - }); - $("#password-savelink").click(function() - { - self.exitPassword(true); - }); - padutils.bindEnterAndEscape($("#security-passwordedit"), function() - { - self.exitPassword(true); - }, function() - { - self.exitPassword(false); - }); - }, - enterPassword: function() - { - isEditingPassword = true; - $("#security-passwordedit").val(self.password || ''); - self.renderPassword(); - $("#security-passwordedit").focus().select(); - }, - exitPassword: function(accept) - { - isEditingPassword = false; - if (accept) - { - changePassword($("#security-passwordedit").val()); - } - else - { - self.renderPassword(); - } - }, - renderPassword: function() - { - if (isEditingPassword) - { - $("#password-nonedit").hide(); - $("#password-inedit").show(); - } - else - { - $("#password-nonedit").toggleClass('nopassword', !self.password); - $("#password-setlink").html(self.password ? "Change..." : "Set..."); - if (self.password) - { - $("#password-display").html(self.password.replace(/./g, '•')); - } - else - { - $("#password-display").html("None"); - } - $("#password-inedit").hide(); - $("#password-nonedit").show(); - } - }, - togglePanel: function(panelName) - { - if (panelName in panels) - { - if (currentPanel == panelName) - { - self.setShownPanel(null); - } - else - { - self.setShownPanel(panelName); - } - } - }, - setShownPanel: function(panelName) - { - function animateHidePanel(panelName, next) - { - var delay = 0; - if (panelName == 'options' && isEditingPassword) - { - // give user feedback that the password they've - // typed in won't actually take effect - self.exitPassword(false); - delay = 500; - } - - window.setTimeout(function() - { - panels[panelName].animator.hide(); - if (next) - { - next(); - } - }, delay); - } - - if (!panelName) - { - if (currentPanel) - { - animateHidePanel(currentPanel); - setCurrentPanel(null); - } - } - else if (panelName in panels) - { - if (currentPanel != panelName) - { - if (currentPanel) - { - animateHidePanel(currentPanel, function() - { - panels[panelName].animator.show(); - setCurrentPanel(panelName); - }); - } - else - { - panels[panelName].animator.show(); - setCurrentPanel(panelName); - } - } - } - }, - isPanelShown: function(panelName) - { - if (!panelName) - { - return !currentPanel; - } - else - { - return (panelName == currentPanel); - } - }, - changeTitle: function(newTitle) - { - self.title = newTitle; - self.render(); - }, - editTitle: function() - { - if (!enabled) - { - return; - } - $("#padtitleedit").val(self.title); - isEditingTitle = true; - self.render(); - $("#padtitleedit").focus().select(); - }, - closeTitleEdit: function(accept) - { - if (!enabled) - { - return; - } - if (accept) - { - var newTitle = $("#padtitleedit").val(); - if (newTitle) - { - newTitle = newTitle.substring(0, 80); - self.title = newTitle; - - pad.notifyChangeTitle(newTitle); - } - } - - isEditingTitle = false; - self.render(); - }, - changePassword: function(newPass) - { - if (newPass) - { - self.password = newPass; - } - else - { - self.password = null; - } - self.renderPassword(); - }, - render: function() - { - if (isEditingTitle) - { - $("#docbarpadtitle").hide(); - $("#docbarrenamelink").hide(); - $("#padtitleedit").show(); - $("#padtitlebuttons").show(); - if (!enabled) - { - $("#padtitleedit").attr('disabled', 'disabled'); - } - else - { - $("#padtitleedit").removeAttr('disabled'); - } - } - else - { - $("#padtitleedit").hide(); - $("#padtitlebuttons").hide(); - - var titleSpan = $("#docbarpadtitle span"); - titleSpan.html(padutils.escapeHtml(self.title)); - $("#docbarpadtitle").attr('title', (pad.isPadPublic() ? "Public Pad: " : "") + self.title); - $("#docbarpadtitle").show(); - - if (isTitleEditable) - { - var titleRight = $("#docbarpadtitle").position().left + $("#docbarpadtitle span").position().left + Math.min($("#docbarpadtitle").width(), $("#docbarpadtitle span").width()); - $("#docbarrenamelink").css('left', titleRight + 10).show(); - } - - if (pad.isPadPublic()) - { - $("#docbar").addClass("docbar-public"); - } - else - { - $("#docbar").removeClass("docbar-public"); - } - } - }, - disable: function() - { - enabled = false; - self.render(); - }, - handleResizePage: function() - { - // Side-step circular reference. This should be injected. - var padsavedrevs = require('./pad_savedrevs'); - padsavedrevs.handleResizePage(); - }, - hideLaterIfNoOtherInteraction: function() - { - return padutils.getCancellableAction('hide-docbar-panel', function() - { - self.setShownPanel(null); - }); - } - }; - return self; -}()); - -exports.paddocbar = paddocbar; diff --git a/src/static/js/pad_editbar.js b/src/static/js/pad_editbar.js index 91a07bf9..cc9f8758 100644 --- a/src/static/js/pad_editbar.js +++ b/src/static/js/pad_editbar.js @@ -156,10 +156,7 @@ var padeditbar = (function() else if (cmd == 'insertorderedlist') ace.ace_doInsertOrderedList(); else if (cmd == 'indent') { - if (!ace.ace_doIndentOutdent(false)) - { - ace.ace_doInsertUnorderedList(); - } + ace.ace_doIndentOutdent(false); } else if (cmd == 'outdent') { diff --git a/src/static/js/pad_impexp.js b/src/static/js/pad_impexp.js index 74564256..ae951ca7 100644 --- a/src/static/js/pad_impexp.js +++ b/src/static/js/pad_impexp.js @@ -20,14 +20,11 @@ * limitations under the License. */ -var paddocbar = require('./pad_docbar').paddocbar; - var padimpexp = (function() { ///// import var currentImportTimer = null; - var hidePanelCall = null; function addImportFrames() { @@ -72,7 +69,6 @@ var padimpexp = (function() var ret = window.confirm(html10n.get("pad.impexp.confirmimport")); if (ret) { - hidePanelCall = paddocbar.hideLaterIfNoOtherInteraction(); currentImportTimer = window.setTimeout(function() { if (!currentImportTimer) @@ -255,11 +251,6 @@ var padimpexp = (function() $("#exportopena").attr("href", pad_root_path + "/export/odt"); } - $("#impexp-close").click(function() - { - paddocbar.setShownPanel(null); - }); - addImportFrames(); $("#importfileinput").change(fileInputUpdated); $('#importform').submit(fileInputSubmit); diff --git a/src/static/js/pad_userlist.js b/src/static/js/pad_userlist.js index d051182b..962595d2 100644 --- a/src/static/js/pad_userlist.js +++ b/src/static/js/pad_userlist.js @@ -107,14 +107,9 @@ var paduserlist = (function() function getUserRowHtml(height, data) { var nameHtml; - var isGuest = (data.id.charAt(0) != 'p'); if (data.name) { nameHtml = padutils.escapeHtml(data.name); - if (isGuest && pad.getIsProPad()) - { - nameHtml += ' ('+_(pad.userlist.guest)+')'; - } } else { diff --git a/src/static/js/pad_utils.js b/src/static/js/pad_utils.js index 82f7fcad..deee2dfd 100644 --- a/src/static/js/pad_utils.js +++ b/src/static/js/pad_utils.js @@ -520,11 +520,11 @@ function setupGlobalExceptionHandler() { $("#editorloadingbox").css("padding", "10px"); $("#editorloadingbox").css("padding-top", "45px"); $("#editorloadingbox").html("<div style='text-align:left;color:red;font-size:16px;'><b>An error occured</b><br>The error was reported with the following id: '" + errorId + "'<br><br><span style='color:black;font-weight:bold;font-size:16px'>Please send this error message to us: </span><div style='color:black;font-size:14px'>'" - + "ErrorId: " + errorId + "<br>UserAgent: " + navigator.userAgent + "<br>" + msg + " in " + url + " at line " + linenumber + "'</div></div>"); + + "ErrorId: " + errorId + "<br>URL: " + window.location.href + "<br>UserAgent: " + navigator.userAgent + "<br>" + msg + " in " + url + " at line " + linenumber + "'</div></div>"); } //send javascript errors to the server - var errObj = {errorInfo: JSON.stringify({errorId: errorId, msg: msg, url: url, linenumber: linenumber, userAgent: navigator.userAgent})}; + var errObj = {errorInfo: JSON.stringify({errorId: errorId, msg: msg, url: window.location.href, linenumber: linenumber, userAgent: navigator.userAgent})}; var loc = document.location; var url = loc.protocol + "//" + loc.hostname + ":" + loc.port + "/" + loc.pathname.substr(1, loc.pathname.indexOf("/p/")) + "jserror"; diff --git a/src/static/js/pluginfw/hooks.js b/src/static/js/pluginfw/hooks.js index d9a14d85..4d505794 100644 --- a/src/static/js/pluginfw/hooks.js +++ b/src/static/js/pluginfw/hooks.js @@ -70,10 +70,12 @@ exports.flatten = function (lst) { exports.callAll = function (hook_name, args) { if (!args) args = {}; - if (exports.plugins.hooks[hook_name] === undefined) return []; - return _.flatten(_.map(exports.plugins.hooks[hook_name], function (hook) { - return hookCallWrapper(hook, hook_name, args); - }), true); + if (exports.plugins){ + if (exports.plugins.hooks[hook_name] === undefined) return []; + return _.flatten(_.map(exports.plugins.hooks[hook_name], function (hook) { + return hookCallWrapper(hook, hook_name, args); + }), true); + } } exports.aCallAll = function (hook_name, args, cb) { diff --git a/src/static/js/pluginfw/installer.js b/src/static/js/pluginfw/installer.js index eb10f8af..15d87940 100644 --- a/src/static/js/pluginfw/installer.js +++ b/src/static/js/pluginfw/installer.js @@ -94,11 +94,12 @@ exports.search = function(query, cache, cb) { if (er) return cb(er); var res = {}; var i = 0; + var pattern = query.pattern.toLowerCase(); for (key in data) { // for every plugin in the data from npm if ( key.indexOf(plugins.prefix) == 0 - && key.indexOf(query.pattern) != -1 + && key.indexOf(pattern) != -1 || key.indexOf(plugins.prefix) == 0 - && data[key].description.indexOf(query.pattern) != -1 + && data[key].description.indexOf(pattern) != -1 ) { // If the name contains ep_ and the search string is in the name or description i++; if (i > query.offset diff --git a/src/static/js/rjquery.js b/src/static/js/rjquery.js index 21af074b..d9d1ed16 100644 --- a/src/static/js/rjquery.js +++ b/src/static/js/rjquery.js @@ -2,4 +2,9 @@ // Proviedes a require'able version of jQuery without leaking $ and jQuery; require('./jquery'); -exports.jQuery = exports.$ = $.noConflict(true);
\ No newline at end of file +var jq = window.$.noConflict(true); + +//added the old browser recognition +jq.browser = require('./jquery_browser').browser; + +exports.jQuery = exports.$ = jq;
\ No newline at end of file diff --git a/src/static/js/timeslider.js b/src/static/js/timeslider.js index 5203e57b..eb3703d9 100644 --- a/src/static/js/timeslider.js +++ b/src/static/js/timeslider.js @@ -29,8 +29,9 @@ var createCookie = require('./pad_utils').createCookie; var readCookie = require('./pad_utils').readCookie; var randomString = require('./pad_utils').randomString; var _ = require('./underscore'); +var hooks = require('./pluginfw/hooks'); -var socket, token, padId, export_links; +var token, padId, export_links; function init() { $(document).ready(function () @@ -106,6 +107,9 @@ function init() { window.location.reload(); }); + exports.socket = socket; // make the socket available + + hooks.aCallAll("postTimesliderInit"); }); } diff --git a/src/templates/admin/index.html b/src/templates/admin/index.html index 16ea8427..48776515 100644 --- a/src/templates/admin/index.html +++ b/src/templates/admin/index.html @@ -1,7 +1,8 @@ +<!doctype html>
<html>
<head>
- <title>Admin Dashboard - Etherpad lite</title>
- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
+ <title>Admin Dashboard - Etherpad</title>
+ <meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="../static/css/admin.css">
<script src="../static/js/jquery.js"></script>
<script src="../socket.io/socket.io.js"></script>
@@ -9,13 +10,15 @@ <body>
<div id="wrapper">
<div class="menu">
- <h1>Etherpad lite</h1>
- <li><a href="admin/plugins">Plugin manager</a> </li>
- <li><a href="admin/settings">Settings</a> </li>
- <li><a href="admin/plugins/info">Troubleshooting information</a> </li>
+ <h1>Etherpad</h1>
+ <ul>
+ <% e.begin_block("adminMenu"); %>
+ <li><a href="plugins">Plugin manager</a> </li>
+ <li><a href="settings">Settings</a> </li>
+ <li><a href="plugins/info">Troubleshooting information</a> </li>
+ <% e.end_block(); %>
+ </ul>
</div>
-
</div>
- <div id="topborder"></div>
</body>
</html>
diff --git a/src/templates/admin/plugins-info.html b/src/templates/admin/plugins-info.html index 605b23d3..d1ca9a11 100644 --- a/src/templates/admin/plugins-info.html +++ b/src/templates/admin/plugins-info.html @@ -1,20 +1,24 @@ <% var plugins = require("ep_etherpad-lite/static/js/pluginfw/plugins"); %> - +<!doctype html> <html> <head> - <title>Plugin information - Etherpad lite</title> - <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"> + <title>Plugin information - Etherpad</title> + <meta name="viewport" content="width=device-width"> <link rel="stylesheet" href="../../static/css/admin.css"> </head> <body> <div id="wrapper"> <div class="menu"> - <h1>Etherpad lite</h1> - <li><a href="../plugins">Plugin manager</a> </li> - <li><a href="../settings">Settings</a> </li> - <li><a href="../plugins/info">Troubleshooting information</a> </li> + <h1>Etherpad</h1> + <ul> + <% e.begin_block("adminMenu"); %> + <li><a href="../plugins">Plugin manager</a> </li> + <li><a href="../settings">Settings</a> </li> + <li><a href="../plugins/info">Troubleshooting information</a> </li> + <% e.end_block(); %> + </ul> </div> <div class="innerwrapper"> @@ -34,6 +38,5 @@ </div> </div> - <div id="topborder"></div> </body> </html> diff --git a/src/templates/admin/plugins.html b/src/templates/admin/plugins.html index a85db557..7c2a7abf 100644 --- a/src/templates/admin/plugins.html +++ b/src/templates/admin/plugins.html @@ -1,7 +1,8 @@ +<!doctype html>
<html>
<head>
- <title>Plugin manager - Etherpad lite</title>
- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
+ <title>Plugin manager - Etherpad</title>
+ <meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="../static/css/admin.css">
<script src="../static/js/jquery.js"></script>
<script src="../socket.io/socket.io.js"></script>
@@ -19,12 +20,15 @@ <% } %>
<div class="menu">
- <h1>Etherpad lite</h1>
- <li><a href="plugins">Plugin manager</a> </li>
- <li><a href="settings">Settings</a> </li>
- <li><a href="plugins/info">Troubleshooting information</a> </li>
-
- <div id="progress"><img src="../static/img/loading.gif" alt=""/> <span class="message"></span></div>
+ <h1>Etherpad</h1>
+ <ul>
+ <% e.begin_block("adminMenu"); %>
+ <li><a href="plugins">Plugin manager</a> </li>
+ <li><a href="settings">Settings</a> </li>
+ <li><a href="plugins/info">Troubleshooting information</a> </li>
+ <% e.end_block(); %>
+ </ul>
+ <div id="progress"><img src="../static/img/loading.gif"> <span class="message"></span></div>
</div>
<div class="innerwrapper">
@@ -40,9 +44,9 @@ </thead>
<tbody class="template">
<tr id="installed-plugin-template">
- <td class="name"></td>
- <td class="description"></td>
- <td class="version"></td>
+ <td class="name" data-label="Name"></td>
+ <td class="description" data-label="Description"></td>
+ <td class="version" data-label="Version"></td>
<td class="actions">
<input type="button" value="Uninstall" class="do-uninstall">
</td>
@@ -71,9 +75,9 @@ </thead>
<tbody class="template">
<tr>
- <td class="name"></td>
- <td class="description"></td>
- <td class="version"></td>
+ <td class="name" data-label="Name"></td>
+ <td class="description" data-label="Description"></td>
+ <td class="version" data-label="Version"></td>
<td class="actions">
<input type="button" value="Install" class="do-install">
</td>
@@ -89,6 +93,5 @@ </div>
</div>
- <div id="topborder"></div>
</body>
</html>
diff --git a/src/templates/admin/settings.html b/src/templates/admin/settings.html index be262f24..4476b733 100644 --- a/src/templates/admin/settings.html +++ b/src/templates/admin/settings.html @@ -1,7 +1,8 @@ +<!doctype html>
<html>
<head>
- <title>Settings - Etherpad lite</title>
- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
+ <title>Settings - Etherpad</title>
+ <meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="../static/css/admin.css">
<script src="../static/js/jquery.js"></script>
<script src="../socket.io/socket.io.js"></script>
@@ -23,22 +24,26 @@ <div class="menu">
- <h1>Etherpad lite</h1>
- <li><a href="plugins">Plugin manager</a> </li>
- <li><a href="settings">Settings</a> </li>
- <li><a href="plugins/info">Troubleshooting information</a> </li>
+ <h1>Etherpad</h1>
+ <ul>
+ <% e.begin_block("adminMenu"); %>
+ <li><a href="plugins">Plugin manager</a> </li>
+ <li><a href="settings">Settings</a> </li>
+ <li><a href="plugins/info">Troubleshooting information</a> </li>
+ <% e.end_block(); %>
+ </ul>
</div>
<div class="innerwrapper">
- <a href='https://github.com/ether/etherpad-lite/wiki/Example-Production-Settings.JSON'>Example production settings template</a>
- <a href='https://github.com/ether/etherpad-lite/wiki/Example-Development-Settings.JSON'>Example development settings template</a>
+ <h2>Current configuration</h2>
<textarea class="settings"></textarea>
<input type="button" class="settingsButton" id="saveSettings" value="Save Settings">
<input type="button" class="settingsButton" id="restartEtherpad" value="Restart Etherpad">
<div id="response"></div>
+ <div class="separator"></div>
+ <a href='https://github.com/ether/etherpad-lite/wiki/Example-Production-Settings.JSON'>Example production settings template</a>
+ <a href='https://github.com/ether/etherpad-lite/wiki/Example-Development-Settings.JSON'>Example development settings template</a>
</div>
</div>
-
- <div id="topborder"></div>
</body>
</html>
diff --git a/src/templates/index.html b/src/templates/index.html index c3c13db3..4f6d500b 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -64,7 +64,8 @@ box-shadow: 0px 1px 8px rgba(0,0,0,0.3); } #inner { - width: 300px; + position:relative; + max-width: 300px; margin: 0 auto; } #button { @@ -100,6 +101,10 @@ text-shadow: 0 1px 1px #fff; margin: 16px auto 0; } + #padname{ + height:38px; + max-width:280px; + } form { height: 38px; background: #fff; @@ -115,7 +120,8 @@ border-radius: 3px; box-sizing: border-box; -moz-box-sizing: border-box; - padding: 0 45px 0 10px; + line-height:36px; /* IE8 hack */ + padding: 0px 45px 0 10px; *padding: 0; /* IE7 hack */ width: 100%; height: 100%; @@ -125,7 +131,7 @@ } button[type="submit"] { position: absolute; - right: 0; + left:253px; width: 45px; height: 38px; } diff --git a/src/templates/timeslider.html b/src/templates/timeslider.html index 4a8543c5..d3062449 100644 --- a/src/templates/timeslider.html +++ b/src/templates/timeslider.html @@ -40,8 +40,10 @@ <% e.end_block(); %> <link rel="localizations" type="application/l10n+json" href="../../locales.json" /> + <% e.begin_block("timesliderScripts"); %> <script type="text/javascript" src="../../static/js/html10n.js"></script> <script type="text/javascript" src="../../static/js/l10n.js"></script> + <% e.end_block(); %> </head> <% e.begin_block("timesliderBody"); %> @@ -211,6 +213,8 @@ } var plugins = require('ep_etherpad-lite/static/js/pluginfw/client_plugins'); + var socket = require('ep_etherpad-lite/static/js/timeslider').socket; + plugins.baseURL = baseURL; plugins.update(function () { |