From e5efbfa5c36ae3f77663bd80ca1255417c2ac8bc Mon Sep 17 00:00:00 2001 From: zhengxie Date: Tue, 28 Apr 2015 16:43:28 +0800 Subject: [PATCH] [dist] Add static files to media/assets --- .gitignore | 1 - media/assets/css/backbone.css | 41 + media/assets/css/backbone.df4963eacd12.css | 41 + .../css/magnific-popup.656241b2c8ed.css | 369 + media/assets/css/magnific-popup.css | 369 + .../assets/css/select2-3.5.2.b9d0598b4e1c.css | 704 ++ media/assets/css/select2-3.5.2.css | 704 ++ .../css/select2-spinner.7b9776076d5f.gif | Bin 0 -> 1849 bytes media/assets/css/select2-spinner.gif | Bin 0 -> 1849 bytes media/assets/css/select2.2ca61b76e220.png | Bin 0 -> 613 bytes media/assets/css/select2.png | Bin 0 -> 613 bytes media/assets/css/select2x2.49e3f0060186.png | Bin 0 -> 845 bytes media/assets/css/select2x2.png | Bin 0 -> 845 bytes .../app/collections/dirents.040a5eb353dd.js | 42 + .../assets/scripts/app/collections/dirents.js | 42 + .../collections/group-repos.f4dbbebabc0f.js | 28 + .../scripts/app/collections/group-repos.js | 28 + .../app/collections/pub-repos.5b75c0a2d366.js | 17 + .../scripts/app/collections/pub-repos.js | 17 + .../app/collections/repos.44cf9dd4e1eb.js | 40 + media/assets/scripts/app/collections/repos.js | 40 + media/assets/scripts/app/main.e72a78a72bbe.js | 6 + media/assets/scripts/app/main.js | 6 + .../scripts/app/models/dirent.553e08252016.js | 10 + media/assets/scripts/app/models/dirent.js | 10 + .../app/models/group-repo.133c1bd74fd2.js | 17 + media/assets/scripts/app/models/group-repo.js | 17 + .../app/models/pub-repo.3f52334f11d8.js | 17 + media/assets/scripts/app/models/pub-repo.js | 17 + .../scripts/app/models/repo.96554e3b47f2.js | 45 + media/assets/scripts/app/models/repo.js | 45 + .../assets/scripts/app/router.70dc7dd5dc67.js | 154 + media/assets/scripts/app/router.js | 154 + .../app/views/add-group-repo.1b73df633a61.js | 27 + .../scripts/app/views/add-group-repo.js | 27 + .../app/views/add-pub-repo.31eb194e78d8.js | 27 + .../assets/scripts/app/views/add-pub-repo.js | 27 + .../app/views/add-repo.14400988204f.js | 96 + media/assets/scripts/app/views/add-repo.js | 96 + .../scripts/app/views/dir.128cc156b122.js | 875 ++ media/assets/scripts/app/views/dir.js | 875 ++ .../scripts/app/views/dirent.b1f79799a510.js | 455 + media/assets/scripts/app/views/dirent.js | 455 + .../app/views/fileupload.a40f2a483bc0.js | 460 + media/assets/scripts/app/views/fileupload.js | 460 + .../views/folder-perm-item.781a1d6e78cb.js | 138 + .../scripts/app/views/folder-perm-item.js | 138 + .../app/views/folder-perm.02e63ba83d44.js | 227 + media/assets/scripts/app/views/folder-perm.js | 227 + .../app/views/group-repo.8efc7562548b.js | 68 + media/assets/scripts/app/views/group-repo.js | 68 + .../app/views/group-side-nav.0b05e7fb5a80.js | 96 + .../scripts/app/views/group-side-nav.js | 96 + .../scripts/app/views/group.8affe284ec5e.js | 145 + media/assets/scripts/app/views/group.js | 145 + .../app/views/myhome-repos.8119c47ffa88.js | 122 + .../assets/scripts/app/views/myhome-repos.js | 122 + .../views/myhome-shared-repos.aa3b73934daf.js | 113 + .../scripts/app/views/myhome-shared-repos.js | 113 + .../app/views/myhome-side-nav.09acd723fcd3.js | 87 + .../scripts/app/views/myhome-side-nav.js | 87 + .../views/myhome-sub-repos.6292413141b1.js | 154 + .../scripts/app/views/myhome-sub-repos.js | 154 + .../scripts/app/views/myhome.05696a550d46.js | 72 + media/assets/scripts/app/views/myhome.js | 72 + .../views/organization-repo.85337c75bb59.js | 61 + .../scripts/app/views/organization-repo.js | 61 + .../app/views/organization.dcf0e843b140.js | 125 + .../assets/scripts/app/views/organization.js | 125 + .../scripts/app/views/repo.ddaeff40f80b.js | 105 + media/assets/scripts/app/views/repo.js | 105 + .../scripts/app/views/share.3b5d600852d2.js | 555 + media/assets/scripts/app/views/share.js | 555 + .../app/views/shared-repo.3e3c3a02066a.js | 63 + media/assets/scripts/app/views/shared-repo.js | 63 + .../scripts/app/views/sub-lib.d2f2c2f463f1.js | 90 + media/assets/scripts/app/views/sub-lib.js | 90 + .../app/views/top-group-nav.0ccf1d180d14.js | 52 + .../assets/scripts/app/views/top-group-nav.js | 52 + media/assets/scripts/build.c3bc7fad923f.js | 15 + media/assets/scripts/build.js | 15 + media/assets/scripts/common.e99c3b8b18f1.js | 533 + media/assets/scripts/common.js | 533 + .../assets/scripts/dist/build.628bdefaa541.js | 1 + .../scripts/dist/build.74e2510f5c60.txt | 57 + media/assets/scripts/dist/build.js | 1 + media/assets/scripts/dist/build.txt | 57 + .../assets/scripts/dist/group.ac8990bfd581.js | 1 + media/assets/scripts/dist/group.js | 1 + .../dist/i18n/ca/djangojs.014bb51da78a.js | 1 + media/assets/scripts/dist/i18n/ca/djangojs.js | 1 + .../dist/i18n/de/djangojs.49b4a16591a9.js | 1 + media/assets/scripts/dist/i18n/de/djangojs.js | 1 + .../dist/i18n/en/djangojs.f713e4d2c6be.js | 1 + media/assets/scripts/dist/i18n/en/djangojs.js | 1 + .../dist/i18n/es-ar/djangojs.d1549fa766f4.js | 1 + .../scripts/dist/i18n/es-ar/djangojs.js | 1 + .../dist/i18n/es-mx/djangojs.3cee89d0ad1b.js | 1 + .../scripts/dist/i18n/es-mx/djangojs.js | 1 + .../dist/i18n/es/djangojs.24e34bdaadb2.js | 1 + media/assets/scripts/dist/i18n/es/djangojs.js | 1 + .../dist/i18n/fr/djangojs.d4b014013f86.js | 1 + media/assets/scripts/dist/i18n/fr/djangojs.js | 1 + .../dist/i18n/he/djangojs.47afa608ace9.js | 1 + media/assets/scripts/dist/i18n/he/djangojs.js | 1 + .../dist/i18n/hu/djangojs.553b16b1f8f8.js | 1 + media/assets/scripts/dist/i18n/hu/djangojs.js | 1 + .../dist/i18n/is/djangojs.a38badd0ed59.js | 1 + media/assets/scripts/dist/i18n/is/djangojs.js | 1 + .../dist/i18n/it/djangojs.82cbde8f71c4.js | 1 + media/assets/scripts/dist/i18n/it/djangojs.js | 1 + .../dist/i18n/ja/djangojs.ceb1b841818b.js | 1 + media/assets/scripts/dist/i18n/ja/djangojs.js | 1 + .../dist/i18n/ko/djangojs.c986cdad4434.js | 1 + media/assets/scripts/dist/i18n/ko/djangojs.js | 1 + .../dist/i18n/lv/djangojs.98c391424dee.js | 1 + media/assets/scripts/dist/i18n/lv/djangojs.js | 1 + .../dist/i18n/nl/djangojs.96c8824f83dc.js | 1 + media/assets/scripts/dist/i18n/nl/djangojs.js | 1 + .../dist/i18n/pl/djangojs.39ef27daa46c.js | 1 + media/assets/scripts/dist/i18n/pl/djangojs.js | 1 + .../dist/i18n/pt-br/djangojs.de66f591a925.js | 1 + .../scripts/dist/i18n/pt-br/djangojs.js | 1 + .../dist/i18n/ru/djangojs.b823fe11174f.js | 1 + media/assets/scripts/dist/i18n/ru/djangojs.js | 1 + .../dist/i18n/sk/djangojs.01f7cbc1bf26.js | 1 + media/assets/scripts/dist/i18n/sk/djangojs.js | 1 + .../dist/i18n/sl/djangojs.0033cae277db.js | 1 + media/assets/scripts/dist/i18n/sl/djangojs.js | 1 + .../dist/i18n/sv/djangojs.13b0c400897a.js | 1 + media/assets/scripts/dist/i18n/sv/djangojs.js | 1 + .../dist/i18n/th/djangojs.b4b37f06f38d.js | 1 + media/assets/scripts/dist/i18n/th/djangojs.js | 1 + .../dist/i18n/tr/djangojs.f1cf33f9e993.js | 1 + media/assets/scripts/dist/i18n/tr/djangojs.js | 1 + .../dist/i18n/uk/djangojs.93bbc2717ad8.js | 1 + media/assets/scripts/dist/i18n/uk/djangojs.js | 1 + .../dist/i18n/zh-cn/djangojs.a12224f1c9fe.js | 1 + .../scripts/dist/i18n/zh-cn/djangojs.js | 1 + .../dist/i18n/zh-tw/djangojs.d68336d24a36.js | 1 + .../scripts/dist/i18n/zh-tw/djangojs.js | 1 + .../jquery.ui.widget.1.11.3.ba4bd4e41caf.js | 17 + .../dist/lib/jquery.ui.widget.1.11.3.js | 17 + .../scripts/dist/lib/require.75e6d0132deb.js | 7 + media/assets/scripts/dist/lib/require.js | 7 + .../assets/scripts/dist/main.f4b66266164f.js | 205 + media/assets/scripts/dist/main.js | 205 + .../scripts/dist/myhome.2fe1e6ec7616.js | 1 + media/assets/scripts/dist/myhome.js | 1 + .../scripts/dist/organization.3a47f7c652c2.js | 1 + media/assets/scripts/dist/organization.js | 1 + .../assets/scripts/file-tree.e5b1b217960b.js | 324 + media/assets/scripts/file-tree.js | 324 + media/assets/scripts/group.1405e8a49cbd.js | 4 + media/assets/scripts/group.js | 4 + .../scripts/i18n/ca/djangojs.ec0b244d30aa.js | 85 + media/assets/scripts/i18n/ca/djangojs.js | 85 + .../scripts/i18n/de/djangojs.4f31cbd45e4d.js | 84 + media/assets/scripts/i18n/de/djangojs.js | 84 + .../scripts/i18n/en/djangojs.2cb862e7970d.js | 87 + media/assets/scripts/i18n/en/djangojs.js | 87 + .../i18n/es-ar/djangojs.2f11be76fd8b.js | 85 + media/assets/scripts/i18n/es-ar/djangojs.js | 85 + .../i18n/es-mx/djangojs.652b2d642a46.js | 86 + media/assets/scripts/i18n/es-mx/djangojs.js | 86 + .../scripts/i18n/es/djangojs.942e8afc0f00.js | 85 + media/assets/scripts/i18n/es/djangojs.js | 85 + .../scripts/i18n/fr/djangojs.f212d84a41ba.js | 89 + media/assets/scripts/i18n/fr/djangojs.js | 89 + .../scripts/i18n/he/djangojs.c0961455c8ff.js | 97 + media/assets/scripts/i18n/he/djangojs.js | 97 + .../scripts/i18n/hu/djangojs.7bb9c06fce30.js | 85 + media/assets/scripts/i18n/hu/djangojs.js | 85 + .../scripts/i18n/is/djangojs.2d7484b7c9d2.js | 97 + media/assets/scripts/i18n/is/djangojs.js | 97 + .../scripts/i18n/it/djangojs.4ccf41c832f5.js | 96 + media/assets/scripts/i18n/it/djangojs.js | 96 + .../scripts/i18n/ja/djangojs.990dbd705948.js | 97 + media/assets/scripts/i18n/ja/djangojs.js | 97 + .../scripts/i18n/ko/djangojs.cf13dc103e1f.js | 92 + media/assets/scripts/i18n/ko/djangojs.js | 92 + .../scripts/i18n/lv/djangojs.c2f0419b2bdc.js | 91 + media/assets/scripts/i18n/lv/djangojs.js | 91 + .../scripts/i18n/nl/djangojs.4b7555b7107f.js | 93 + media/assets/scripts/i18n/nl/djangojs.js | 93 + .../scripts/i18n/pl/djangojs.bc376581accd.js | 85 + media/assets/scripts/i18n/pl/djangojs.js | 85 + .../i18n/pt-br/djangojs.e64a1a2f59cb.js | 87 + media/assets/scripts/i18n/pt-br/djangojs.js | 87 + .../scripts/i18n/ru/djangojs.6a9c24e96bb6.js | 87 + media/assets/scripts/i18n/ru/djangojs.js | 87 + .../scripts/i18n/sk/djangojs.16dc3317e219.js | 85 + media/assets/scripts/i18n/sk/djangojs.js | 85 + .../scripts/i18n/sl/djangojs.b405ecb1969e.js | 99 + media/assets/scripts/i18n/sl/djangojs.js | 99 + .../scripts/i18n/sv/djangojs.f1a1e23fc322.js | 87 + media/assets/scripts/i18n/sv/djangojs.js | 87 + .../scripts/i18n/th/djangojs.518d01eaf70f.js | 97 + media/assets/scripts/i18n/th/djangojs.js | 97 + .../scripts/i18n/tr/djangojs.3557d7371d1b.js | 85 + media/assets/scripts/i18n/tr/djangojs.js | 85 + .../scripts/i18n/uk/djangojs.ef7a1a0e307d.js | 97 + media/assets/scripts/i18n/uk/djangojs.js | 97 + .../i18n/zh-cn/djangojs.1b1f9ddfae58.js | 138 + media/assets/scripts/i18n/zh-cn/djangojs.js | 138 + .../i18n/zh-tw/djangojs.d346a9ff2a0b.js | 97 + media/assets/scripts/i18n/zh-tw/djangojs.js | 97 + .../scripts/lib/backbone.c1a39c11a835.js | 1608 +++ media/assets/scripts/lib/backbone.js | 1608 +++ .../assets/scripts/lib/jquery.c0b3962f9f23.js | 10346 ++++++++++++++++ .../jquery.fileupload.5.42.1.bc1c71220915.js | 11 + .../scripts/lib/jquery.fileupload.5.42.1.js | 11 + ...load.file-processing.1.3.0.ee4d16d07ff3.js | 11 + ...jquery.fileupload.file-processing.1.3.0.js | 11 + ...jquery.fileupload.ui.9.6.0.d6ef1cd0ec86.js | 15 + .../scripts/lib/jquery.fileupload.ui.9.6.0.js | 15 + ...ileupload.validation.1.1.2.63b30087cf31.js | 13 + .../lib/jquery.fileupload.validation.1.1.2.js | 13 + ...query.iframe-transport.1.4.ccdffe1d1ff0.js | 11 + .../lib/jquery.iframe-transport.1.4.js | 11 + media/assets/scripts/lib/jquery.js | 10346 ++++++++++++++++ .../lib/jquery.magnific-popup.46e3906a2c4d.js | 2062 +++ .../scripts/lib/jquery.magnific-popup.js | 2062 +++ ...uery.simplemodal.1.4.4.min.fb6aca1466d2.js | 26 + .../lib/jquery.simplemodal.1.4.4.min.js | 26 + .../lib/jquery.ui.core.954b6603ec44.js | 310 + media/assets/scripts/lib/jquery.ui.core.js | 310 + .../lib/jquery.ui.progressbar.0695670bde95.js | 164 + .../scripts/lib/jquery.ui.progressbar.js | 164 + .../lib/jquery.ui.tabs.7406a3c5d2e3.js | 1727 +++ media/assets/scripts/lib/jquery.ui.tabs.js | 1727 +++ .../jquery.ui.widget.1.11.1.5bae5494c8e9.js | 16 + .../scripts/lib/jquery.ui.widget.1.11.1.js | 16 + .../jquery.ui.widget.1.11.3.e7ca91e0a8c2.js | 565 + .../scripts/lib/jquery.ui.widget.1.11.3.js | 565 + .../scripts/lib/jstree.1.0.2561f0294340.js | 2 + media/assets/scripts/lib/jstree.1.0.js | 2 + .../scripts/lib/require.640929dac3c2.js | 2076 ++++ media/assets/scripts/lib/require.js | 2076 ++++ .../scripts/lib/select2-3.5.2.d5f38f0c37db.js | 3541 ++++++ media/assets/scripts/lib/select2-3.5.2.js | 3541 ++++++ media/assets/scripts/lib/text.71e5a361c2c7.js | 391 + media/assets/scripts/lib/text.js | 391 + .../scripts/lib/tmpl.min.0e87d44edb61.js | 2 + media/assets/scripts/lib/tmpl.min.js | 2 + .../scripts/lib/underscore.1dccc53d7339.js | 1246 ++ media/assets/scripts/lib/underscore.js | 1246 ++ media/assets/scripts/main.ee715e56433e.js | 4 + media/assets/scripts/main.js | 4 + media/assets/scripts/myhome.f03d2e13d00a.js | 4 + media/assets/scripts/myhome.js | 4 + .../scripts/organization.1d9bad867934.js | 4 + media/assets/scripts/organization.js | 4 + 253 files changed, 66886 insertions(+), 1 deletion(-) create mode 100644 media/assets/css/backbone.css create mode 100644 media/assets/css/backbone.df4963eacd12.css create mode 100644 media/assets/css/magnific-popup.656241b2c8ed.css create mode 100644 media/assets/css/magnific-popup.css create mode 100644 media/assets/css/select2-3.5.2.b9d0598b4e1c.css create mode 100644 media/assets/css/select2-3.5.2.css create mode 100644 media/assets/css/select2-spinner.7b9776076d5f.gif create mode 100644 media/assets/css/select2-spinner.gif create mode 100644 media/assets/css/select2.2ca61b76e220.png create mode 100644 media/assets/css/select2.png create mode 100644 media/assets/css/select2x2.49e3f0060186.png create mode 100644 media/assets/css/select2x2.png create mode 100644 media/assets/scripts/app/collections/dirents.040a5eb353dd.js create mode 100644 media/assets/scripts/app/collections/dirents.js create mode 100644 media/assets/scripts/app/collections/group-repos.f4dbbebabc0f.js create mode 100644 media/assets/scripts/app/collections/group-repos.js create mode 100644 media/assets/scripts/app/collections/pub-repos.5b75c0a2d366.js create mode 100644 media/assets/scripts/app/collections/pub-repos.js create mode 100644 media/assets/scripts/app/collections/repos.44cf9dd4e1eb.js create mode 100644 media/assets/scripts/app/collections/repos.js create mode 100644 media/assets/scripts/app/main.e72a78a72bbe.js create mode 100644 media/assets/scripts/app/main.js create mode 100644 media/assets/scripts/app/models/dirent.553e08252016.js create mode 100644 media/assets/scripts/app/models/dirent.js create mode 100644 media/assets/scripts/app/models/group-repo.133c1bd74fd2.js create mode 100644 media/assets/scripts/app/models/group-repo.js create mode 100644 media/assets/scripts/app/models/pub-repo.3f52334f11d8.js create mode 100644 media/assets/scripts/app/models/pub-repo.js create mode 100644 media/assets/scripts/app/models/repo.96554e3b47f2.js create mode 100644 media/assets/scripts/app/models/repo.js create mode 100644 media/assets/scripts/app/router.70dc7dd5dc67.js create mode 100644 media/assets/scripts/app/router.js create mode 100644 media/assets/scripts/app/views/add-group-repo.1b73df633a61.js create mode 100644 media/assets/scripts/app/views/add-group-repo.js create mode 100644 media/assets/scripts/app/views/add-pub-repo.31eb194e78d8.js create mode 100644 media/assets/scripts/app/views/add-pub-repo.js create mode 100644 media/assets/scripts/app/views/add-repo.14400988204f.js create mode 100644 media/assets/scripts/app/views/add-repo.js create mode 100644 media/assets/scripts/app/views/dir.128cc156b122.js create mode 100644 media/assets/scripts/app/views/dir.js create mode 100644 media/assets/scripts/app/views/dirent.b1f79799a510.js create mode 100644 media/assets/scripts/app/views/dirent.js create mode 100644 media/assets/scripts/app/views/fileupload.a40f2a483bc0.js create mode 100644 media/assets/scripts/app/views/fileupload.js create mode 100644 media/assets/scripts/app/views/folder-perm-item.781a1d6e78cb.js create mode 100644 media/assets/scripts/app/views/folder-perm-item.js create mode 100644 media/assets/scripts/app/views/folder-perm.02e63ba83d44.js create mode 100644 media/assets/scripts/app/views/folder-perm.js create mode 100644 media/assets/scripts/app/views/group-repo.8efc7562548b.js create mode 100644 media/assets/scripts/app/views/group-repo.js create mode 100644 media/assets/scripts/app/views/group-side-nav.0b05e7fb5a80.js create mode 100644 media/assets/scripts/app/views/group-side-nav.js create mode 100644 media/assets/scripts/app/views/group.8affe284ec5e.js create mode 100644 media/assets/scripts/app/views/group.js create mode 100644 media/assets/scripts/app/views/myhome-repos.8119c47ffa88.js create mode 100644 media/assets/scripts/app/views/myhome-repos.js create mode 100644 media/assets/scripts/app/views/myhome-shared-repos.aa3b73934daf.js create mode 100644 media/assets/scripts/app/views/myhome-shared-repos.js create mode 100644 media/assets/scripts/app/views/myhome-side-nav.09acd723fcd3.js create mode 100644 media/assets/scripts/app/views/myhome-side-nav.js create mode 100644 media/assets/scripts/app/views/myhome-sub-repos.6292413141b1.js create mode 100644 media/assets/scripts/app/views/myhome-sub-repos.js create mode 100644 media/assets/scripts/app/views/myhome.05696a550d46.js create mode 100644 media/assets/scripts/app/views/myhome.js create mode 100644 media/assets/scripts/app/views/organization-repo.85337c75bb59.js create mode 100644 media/assets/scripts/app/views/organization-repo.js create mode 100644 media/assets/scripts/app/views/organization.dcf0e843b140.js create mode 100644 media/assets/scripts/app/views/organization.js create mode 100644 media/assets/scripts/app/views/repo.ddaeff40f80b.js create mode 100644 media/assets/scripts/app/views/repo.js create mode 100644 media/assets/scripts/app/views/share.3b5d600852d2.js create mode 100644 media/assets/scripts/app/views/share.js create mode 100644 media/assets/scripts/app/views/shared-repo.3e3c3a02066a.js create mode 100644 media/assets/scripts/app/views/shared-repo.js create mode 100644 media/assets/scripts/app/views/sub-lib.d2f2c2f463f1.js create mode 100644 media/assets/scripts/app/views/sub-lib.js create mode 100644 media/assets/scripts/app/views/top-group-nav.0ccf1d180d14.js create mode 100644 media/assets/scripts/app/views/top-group-nav.js create mode 100644 media/assets/scripts/build.c3bc7fad923f.js create mode 100644 media/assets/scripts/build.js create mode 100644 media/assets/scripts/common.e99c3b8b18f1.js create mode 100644 media/assets/scripts/common.js create mode 100644 media/assets/scripts/dist/build.628bdefaa541.js create mode 100644 media/assets/scripts/dist/build.74e2510f5c60.txt create mode 100644 media/assets/scripts/dist/build.js create mode 100644 media/assets/scripts/dist/build.txt create mode 100644 media/assets/scripts/dist/group.ac8990bfd581.js create mode 100644 media/assets/scripts/dist/group.js create mode 100644 media/assets/scripts/dist/i18n/ca/djangojs.014bb51da78a.js create mode 100644 media/assets/scripts/dist/i18n/ca/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/de/djangojs.49b4a16591a9.js create mode 100644 media/assets/scripts/dist/i18n/de/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/en/djangojs.f713e4d2c6be.js create mode 100644 media/assets/scripts/dist/i18n/en/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/es-ar/djangojs.d1549fa766f4.js create mode 100644 media/assets/scripts/dist/i18n/es-ar/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/es-mx/djangojs.3cee89d0ad1b.js create mode 100644 media/assets/scripts/dist/i18n/es-mx/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/es/djangojs.24e34bdaadb2.js create mode 100644 media/assets/scripts/dist/i18n/es/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/fr/djangojs.d4b014013f86.js create mode 100644 media/assets/scripts/dist/i18n/fr/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/he/djangojs.47afa608ace9.js create mode 100644 media/assets/scripts/dist/i18n/he/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/hu/djangojs.553b16b1f8f8.js create mode 100644 media/assets/scripts/dist/i18n/hu/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/is/djangojs.a38badd0ed59.js create mode 100644 media/assets/scripts/dist/i18n/is/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/it/djangojs.82cbde8f71c4.js create mode 100644 media/assets/scripts/dist/i18n/it/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/ja/djangojs.ceb1b841818b.js create mode 100644 media/assets/scripts/dist/i18n/ja/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/ko/djangojs.c986cdad4434.js create mode 100644 media/assets/scripts/dist/i18n/ko/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/lv/djangojs.98c391424dee.js create mode 100644 media/assets/scripts/dist/i18n/lv/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/nl/djangojs.96c8824f83dc.js create mode 100644 media/assets/scripts/dist/i18n/nl/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/pl/djangojs.39ef27daa46c.js create mode 100644 media/assets/scripts/dist/i18n/pl/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/pt-br/djangojs.de66f591a925.js create mode 100644 media/assets/scripts/dist/i18n/pt-br/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/ru/djangojs.b823fe11174f.js create mode 100644 media/assets/scripts/dist/i18n/ru/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/sk/djangojs.01f7cbc1bf26.js create mode 100644 media/assets/scripts/dist/i18n/sk/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/sl/djangojs.0033cae277db.js create mode 100644 media/assets/scripts/dist/i18n/sl/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/sv/djangojs.13b0c400897a.js create mode 100644 media/assets/scripts/dist/i18n/sv/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/th/djangojs.b4b37f06f38d.js create mode 100644 media/assets/scripts/dist/i18n/th/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/tr/djangojs.f1cf33f9e993.js create mode 100644 media/assets/scripts/dist/i18n/tr/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/uk/djangojs.93bbc2717ad8.js create mode 100644 media/assets/scripts/dist/i18n/uk/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/zh-cn/djangojs.a12224f1c9fe.js create mode 100644 media/assets/scripts/dist/i18n/zh-cn/djangojs.js create mode 100644 media/assets/scripts/dist/i18n/zh-tw/djangojs.d68336d24a36.js create mode 100644 media/assets/scripts/dist/i18n/zh-tw/djangojs.js create mode 100644 media/assets/scripts/dist/lib/jquery.ui.widget.1.11.3.ba4bd4e41caf.js create mode 100644 media/assets/scripts/dist/lib/jquery.ui.widget.1.11.3.js create mode 100644 media/assets/scripts/dist/lib/require.75e6d0132deb.js create mode 100644 media/assets/scripts/dist/lib/require.js create mode 100644 media/assets/scripts/dist/main.f4b66266164f.js create mode 100644 media/assets/scripts/dist/main.js create mode 100644 media/assets/scripts/dist/myhome.2fe1e6ec7616.js create mode 100644 media/assets/scripts/dist/myhome.js create mode 100644 media/assets/scripts/dist/organization.3a47f7c652c2.js create mode 100644 media/assets/scripts/dist/organization.js create mode 100644 media/assets/scripts/file-tree.e5b1b217960b.js create mode 100644 media/assets/scripts/file-tree.js create mode 100644 media/assets/scripts/group.1405e8a49cbd.js create mode 100644 media/assets/scripts/group.js create mode 100644 media/assets/scripts/i18n/ca/djangojs.ec0b244d30aa.js create mode 100644 media/assets/scripts/i18n/ca/djangojs.js create mode 100644 media/assets/scripts/i18n/de/djangojs.4f31cbd45e4d.js create mode 100644 media/assets/scripts/i18n/de/djangojs.js create mode 100644 media/assets/scripts/i18n/en/djangojs.2cb862e7970d.js create mode 100644 media/assets/scripts/i18n/en/djangojs.js create mode 100644 media/assets/scripts/i18n/es-ar/djangojs.2f11be76fd8b.js create mode 100644 media/assets/scripts/i18n/es-ar/djangojs.js create mode 100644 media/assets/scripts/i18n/es-mx/djangojs.652b2d642a46.js create mode 100644 media/assets/scripts/i18n/es-mx/djangojs.js create mode 100644 media/assets/scripts/i18n/es/djangojs.942e8afc0f00.js create mode 100644 media/assets/scripts/i18n/es/djangojs.js create mode 100644 media/assets/scripts/i18n/fr/djangojs.f212d84a41ba.js create mode 100644 media/assets/scripts/i18n/fr/djangojs.js create mode 100644 media/assets/scripts/i18n/he/djangojs.c0961455c8ff.js create mode 100644 media/assets/scripts/i18n/he/djangojs.js create mode 100644 media/assets/scripts/i18n/hu/djangojs.7bb9c06fce30.js create mode 100644 media/assets/scripts/i18n/hu/djangojs.js create mode 100644 media/assets/scripts/i18n/is/djangojs.2d7484b7c9d2.js create mode 100644 media/assets/scripts/i18n/is/djangojs.js create mode 100644 media/assets/scripts/i18n/it/djangojs.4ccf41c832f5.js create mode 100644 media/assets/scripts/i18n/it/djangojs.js create mode 100644 media/assets/scripts/i18n/ja/djangojs.990dbd705948.js create mode 100644 media/assets/scripts/i18n/ja/djangojs.js create mode 100644 media/assets/scripts/i18n/ko/djangojs.cf13dc103e1f.js create mode 100644 media/assets/scripts/i18n/ko/djangojs.js create mode 100644 media/assets/scripts/i18n/lv/djangojs.c2f0419b2bdc.js create mode 100644 media/assets/scripts/i18n/lv/djangojs.js create mode 100644 media/assets/scripts/i18n/nl/djangojs.4b7555b7107f.js create mode 100644 media/assets/scripts/i18n/nl/djangojs.js create mode 100644 media/assets/scripts/i18n/pl/djangojs.bc376581accd.js create mode 100644 media/assets/scripts/i18n/pl/djangojs.js create mode 100644 media/assets/scripts/i18n/pt-br/djangojs.e64a1a2f59cb.js create mode 100644 media/assets/scripts/i18n/pt-br/djangojs.js create mode 100644 media/assets/scripts/i18n/ru/djangojs.6a9c24e96bb6.js create mode 100644 media/assets/scripts/i18n/ru/djangojs.js create mode 100644 media/assets/scripts/i18n/sk/djangojs.16dc3317e219.js create mode 100644 media/assets/scripts/i18n/sk/djangojs.js create mode 100644 media/assets/scripts/i18n/sl/djangojs.b405ecb1969e.js create mode 100644 media/assets/scripts/i18n/sl/djangojs.js create mode 100644 media/assets/scripts/i18n/sv/djangojs.f1a1e23fc322.js create mode 100644 media/assets/scripts/i18n/sv/djangojs.js create mode 100644 media/assets/scripts/i18n/th/djangojs.518d01eaf70f.js create mode 100644 media/assets/scripts/i18n/th/djangojs.js create mode 100644 media/assets/scripts/i18n/tr/djangojs.3557d7371d1b.js create mode 100644 media/assets/scripts/i18n/tr/djangojs.js create mode 100644 media/assets/scripts/i18n/uk/djangojs.ef7a1a0e307d.js create mode 100644 media/assets/scripts/i18n/uk/djangojs.js create mode 100644 media/assets/scripts/i18n/zh-cn/djangojs.1b1f9ddfae58.js create mode 100644 media/assets/scripts/i18n/zh-cn/djangojs.js create mode 100644 media/assets/scripts/i18n/zh-tw/djangojs.d346a9ff2a0b.js create mode 100644 media/assets/scripts/i18n/zh-tw/djangojs.js create mode 100644 media/assets/scripts/lib/backbone.c1a39c11a835.js create mode 100644 media/assets/scripts/lib/backbone.js create mode 100644 media/assets/scripts/lib/jquery.c0b3962f9f23.js create mode 100644 media/assets/scripts/lib/jquery.fileupload.5.42.1.bc1c71220915.js create mode 100644 media/assets/scripts/lib/jquery.fileupload.5.42.1.js create mode 100644 media/assets/scripts/lib/jquery.fileupload.file-processing.1.3.0.ee4d16d07ff3.js create mode 100644 media/assets/scripts/lib/jquery.fileupload.file-processing.1.3.0.js create mode 100644 media/assets/scripts/lib/jquery.fileupload.ui.9.6.0.d6ef1cd0ec86.js create mode 100644 media/assets/scripts/lib/jquery.fileupload.ui.9.6.0.js create mode 100644 media/assets/scripts/lib/jquery.fileupload.validation.1.1.2.63b30087cf31.js create mode 100644 media/assets/scripts/lib/jquery.fileupload.validation.1.1.2.js create mode 100644 media/assets/scripts/lib/jquery.iframe-transport.1.4.ccdffe1d1ff0.js create mode 100644 media/assets/scripts/lib/jquery.iframe-transport.1.4.js create mode 100644 media/assets/scripts/lib/jquery.js create mode 100644 media/assets/scripts/lib/jquery.magnific-popup.46e3906a2c4d.js create mode 100644 media/assets/scripts/lib/jquery.magnific-popup.js create mode 100644 media/assets/scripts/lib/jquery.simplemodal.1.4.4.min.fb6aca1466d2.js create mode 100644 media/assets/scripts/lib/jquery.simplemodal.1.4.4.min.js create mode 100644 media/assets/scripts/lib/jquery.ui.core.954b6603ec44.js create mode 100644 media/assets/scripts/lib/jquery.ui.core.js create mode 100644 media/assets/scripts/lib/jquery.ui.progressbar.0695670bde95.js create mode 100644 media/assets/scripts/lib/jquery.ui.progressbar.js create mode 100644 media/assets/scripts/lib/jquery.ui.tabs.7406a3c5d2e3.js create mode 100644 media/assets/scripts/lib/jquery.ui.tabs.js create mode 100644 media/assets/scripts/lib/jquery.ui.widget.1.11.1.5bae5494c8e9.js create mode 100644 media/assets/scripts/lib/jquery.ui.widget.1.11.1.js create mode 100644 media/assets/scripts/lib/jquery.ui.widget.1.11.3.e7ca91e0a8c2.js create mode 100644 media/assets/scripts/lib/jquery.ui.widget.1.11.3.js create mode 100644 media/assets/scripts/lib/jstree.1.0.2561f0294340.js create mode 100644 media/assets/scripts/lib/jstree.1.0.js create mode 100644 media/assets/scripts/lib/require.640929dac3c2.js create mode 100644 media/assets/scripts/lib/require.js create mode 100644 media/assets/scripts/lib/select2-3.5.2.d5f38f0c37db.js create mode 100644 media/assets/scripts/lib/select2-3.5.2.js create mode 100644 media/assets/scripts/lib/text.71e5a361c2c7.js create mode 100644 media/assets/scripts/lib/text.js create mode 100644 media/assets/scripts/lib/tmpl.min.0e87d44edb61.js create mode 100644 media/assets/scripts/lib/tmpl.min.js create mode 100644 media/assets/scripts/lib/underscore.1dccc53d7339.js create mode 100644 media/assets/scripts/lib/underscore.js create mode 100644 media/assets/scripts/main.ee715e56433e.js create mode 100644 media/assets/scripts/main.js create mode 100644 media/assets/scripts/myhome.f03d2e13d00a.js create mode 100644 media/assets/scripts/myhome.js create mode 100644 media/assets/scripts/organization.1d9bad867934.js create mode 100644 media/assets/scripts/organization.js diff --git a/.gitignore b/.gitignore index 132df919ca..23d65d1e75 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,6 @@ setenv.sh pylintrc .DS_Store *.mo -media/assets media/CACHE media/avatars/* !media/avatars/default-non-register.jpg diff --git a/media/assets/css/backbone.css b/media/assets/css/backbone.css new file mode 100644 index 0000000000..65aaf1c9c4 --- /dev/null +++ b/media/assets/css/backbone.css @@ -0,0 +1,41 @@ +/* lib view */ +.repo-file-list .dirent-name { + width:220px; +} +.repo-file-list .dirent-size { + width:114px; +} +.repo-file-list .dirent-update { + width:123px; +} +.repo-file-list .dirent-op { + padding-left:30px; + width:120px; +} +.repo-file-list .hidden-op { + min-width: 100px; +} +.displayed-op .op { + margin-left:5px; +} +.hidden-op a { + color:#444; +} +.hidden-op a:hover { + color:#fff; + text-decoration:none; + background:#feaa7c; +} +/* custom select2 */ +.select2-container-multi .select2-choices { + border-color: #ddd; + background-image: none; /* rm the shadow */ +} +.select2-container-multi .select2-choices .select2-search-field input { + padding:2px; +} +.select2-container-multi .select2-choices .select2-search-choice { + border:none; + border-radius:0; + background:#eee; +} diff --git a/media/assets/css/backbone.df4963eacd12.css b/media/assets/css/backbone.df4963eacd12.css new file mode 100644 index 0000000000..65aaf1c9c4 --- /dev/null +++ b/media/assets/css/backbone.df4963eacd12.css @@ -0,0 +1,41 @@ +/* lib view */ +.repo-file-list .dirent-name { + width:220px; +} +.repo-file-list .dirent-size { + width:114px; +} +.repo-file-list .dirent-update { + width:123px; +} +.repo-file-list .dirent-op { + padding-left:30px; + width:120px; +} +.repo-file-list .hidden-op { + min-width: 100px; +} +.displayed-op .op { + margin-left:5px; +} +.hidden-op a { + color:#444; +} +.hidden-op a:hover { + color:#fff; + text-decoration:none; + background:#feaa7c; +} +/* custom select2 */ +.select2-container-multi .select2-choices { + border-color: #ddd; + background-image: none; /* rm the shadow */ +} +.select2-container-multi .select2-choices .select2-search-field input { + padding:2px; +} +.select2-container-multi .select2-choices .select2-search-choice { + border:none; + border-radius:0; + background:#eee; +} diff --git a/media/assets/css/magnific-popup.656241b2c8ed.css b/media/assets/css/magnific-popup.656241b2c8ed.css new file mode 100644 index 0000000000..76a1b4afb6 --- /dev/null +++ b/media/assets/css/magnific-popup.656241b2c8ed.css @@ -0,0 +1,369 @@ +/* Magnific Popup CSS */ +.mfp-bg { + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 1042; + overflow: hidden; + position: fixed; + background: #0b0b0b; + opacity: 0.8; + filter: alpha(opacity=80); } + +.mfp-wrap { + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 1043; + position: fixed; + outline: none !important; + -webkit-backface-visibility: hidden; } + +.mfp-container { + text-align: center; + position: absolute; + width: 100%; + height: 100%; + left: 0; + top: 0; + padding: 0 8px; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } + +.mfp-container:before { + content: ''; + display: inline-block; + height: 100%; + vertical-align: middle; } + +.mfp-align-top .mfp-container:before { + display: none; } + +.mfp-content { + position: relative; + display: inline-block; + vertical-align: middle; + margin: 0 auto; + text-align: left; + z-index: 1045; } + +.mfp-inline-holder .mfp-content, .mfp-ajax-holder .mfp-content { + width: 100%; + cursor: auto; } + +.mfp-ajax-cur { + cursor: progress; } + +.mfp-zoom-out-cur, .mfp-zoom-out-cur .mfp-image-holder .mfp-close { + cursor: -moz-zoom-out; + cursor: -webkit-zoom-out; + cursor: zoom-out; } + +.mfp-zoom { + cursor: pointer; + cursor: -webkit-zoom-in; + cursor: -moz-zoom-in; + cursor: zoom-in; } + +.mfp-auto-cursor .mfp-content { + cursor: auto; } + +.mfp-close, .mfp-arrow, .mfp-preloader, .mfp-counter { + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; } + +.mfp-loading.mfp-figure { + display: none; } + +.mfp-hide { + display: none !important; } + +.mfp-preloader { + color: #cccccc; + position: absolute; + top: 50%; + width: auto; + text-align: center; + margin-top: -0.8em; + left: 8px; + right: 8px; + z-index: 1044; } + .mfp-preloader a { + color: #cccccc; } + .mfp-preloader a:hover { + color: white; } + +.mfp-s-ready .mfp-preloader { + display: none; } + +.mfp-s-error .mfp-content { + display: none; } + +button.mfp-close, button.mfp-arrow { + overflow: visible; + cursor: pointer; + background: transparent; + border: 0; + -webkit-appearance: none; + display: block; + outline: none; + padding: 0; + z-index: 1046; + -webkit-box-shadow: none; + box-shadow: none; } +button::-moz-focus-inner { + padding: 0; + border: 0; } + +.mfp-close { + width: 44px; + height: 44px; + line-height: 44px; + position: absolute; + right: 0; + top: 0; + text-decoration: none; + text-align: center; + opacity: 0.65; + filter: alpha(opacity=65); + padding: 0 0 18px 10px; + color: white; + font-style: normal; + font-size: 28px; + font-family: Arial, Baskerville, monospace; } + .mfp-close:hover, .mfp-close:focus { + opacity: 1; + filter: alpha(opacity=100); } + .mfp-close:active { + top: 1px; } + +.mfp-close-btn-in .mfp-close { + color: #333333; } + +.mfp-image-holder .mfp-close, .mfp-iframe-holder .mfp-close { + color: white; + right: -6px; + text-align: right; + padding-right: 6px; + width: 100%; } + +.mfp-counter { + position: absolute; + top: 0; + right: 0; + color: #cccccc; + font-size: 12px; + line-height: 18px; + white-space: nowrap; } + +.mfp-arrow { + position: absolute; + opacity: 0.65; + filter: alpha(opacity=65); + margin: 0; + top: 50%; + margin-top: -55px; + padding: 0; + width: 90px; + height: 110px; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } + .mfp-arrow:active { + margin-top: -54px; } + .mfp-arrow:hover, .mfp-arrow:focus { + opacity: 1; + filter: alpha(opacity=100); } + .mfp-arrow:before, .mfp-arrow:after, .mfp-arrow .mfp-b, .mfp-arrow .mfp-a { + content: ''; + display: block; + width: 0; + height: 0; + position: absolute; + left: 0; + top: 0; + margin-top: 35px; + margin-left: 35px; + border: medium inset transparent; } + .mfp-arrow:after, .mfp-arrow .mfp-a { + border-top-width: 13px; + border-bottom-width: 13px; + top: 8px; } + .mfp-arrow:before, .mfp-arrow .mfp-b { + border-top-width: 21px; + border-bottom-width: 21px; + opacity: 0.7; } + +.mfp-arrow-left { + left: 0; } + .mfp-arrow-left:after, .mfp-arrow-left .mfp-a { + border-right: 17px solid white; + margin-left: 31px; } + .mfp-arrow-left:before, .mfp-arrow-left .mfp-b { + margin-left: 25px; + border-right: 27px solid #3f3f3f; } + +.mfp-arrow-right { + right: 0; } + .mfp-arrow-right:after, .mfp-arrow-right .mfp-a { + border-left: 17px solid white; + margin-left: 39px; } + .mfp-arrow-right:before, .mfp-arrow-right .mfp-b { + border-left: 27px solid #3f3f3f; } + +.mfp-iframe-holder { + padding-top: 40px; + padding-bottom: 40px; } + .mfp-iframe-holder .mfp-content { + line-height: 0; + width: 100%; + max-width: 900px; } + .mfp-iframe-holder .mfp-close { + top: -40px; } + +.mfp-iframe-scaler { + width: 100%; + height: 0; + overflow: hidden; + padding-top: 56.25%; } + .mfp-iframe-scaler iframe { + position: absolute; + display: block; + top: 0; + left: 0; + width: 100%; + height: 100%; + box-shadow: 0 0 8px rgba(0, 0, 0, 0.6); + background: black; } + +/* Main image in popup */ +img.mfp-img { + width: auto; + max-width: 100%; + height: auto; + display: block; + line-height: 0; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + padding: 40px 0 40px; + margin: 0 auto; } + +/* The shadow behind the image */ +.mfp-figure { + line-height: 0; } + .mfp-figure:after { + content: ''; + position: absolute; + left: 0; + top: 40px; + bottom: 40px; + display: block; + right: 0; + width: auto; + height: auto; + z-index: -1; + box-shadow: 0 0 8px rgba(0, 0, 0, 0.6); + background: #444444; } + .mfp-figure small { + color: #bdbdbd; + display: block; + font-size: 12px; + line-height: 14px; } + .mfp-figure figure { + margin: 0; } + +.mfp-bottom-bar { + margin-top: -36px; + position: absolute; + top: 100%; + left: 0; + width: 100%; + cursor: auto; } + +.mfp-title { + text-align: left; + line-height: 18px; + color: #f3f3f3; + word-wrap: break-word; + padding-right: 36px; } + +.mfp-image-holder .mfp-content { + max-width: 100%; } + +.mfp-gallery .mfp-image-holder .mfp-figure { + cursor: pointer; } + +@media screen and (max-width: 800px) and (orientation: landscape), screen and (max-height: 300px) { + /** + * Remove all paddings around the image on small screen + */ + .mfp-img-mobile .mfp-image-holder { + padding-left: 0; + padding-right: 0; } + .mfp-img-mobile img.mfp-img { + padding: 0; } + .mfp-img-mobile .mfp-figure:after { + top: 0; + bottom: 0; } + .mfp-img-mobile .mfp-figure small { + display: inline; + margin-left: 5px; } + .mfp-img-mobile .mfp-bottom-bar { + background: rgba(0, 0, 0, 0.6); + bottom: 0; + margin: 0; + top: auto; + padding: 3px 5px; + position: fixed; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } + .mfp-img-mobile .mfp-bottom-bar:empty { + padding: 0; } + .mfp-img-mobile .mfp-counter { + right: 5px; + top: 3px; } + .mfp-img-mobile .mfp-close { + top: 0; + right: 0; + width: 35px; + height: 35px; + line-height: 35px; + background: rgba(0, 0, 0, 0.6); + position: fixed; + text-align: center; + padding: 0; } } + +@media all and (max-width: 900px) { + .mfp-arrow { + -webkit-transform: scale(0.75); + transform: scale(0.75); } + .mfp-arrow-left { + -webkit-transform-origin: 0; + transform-origin: 0; } + .mfp-arrow-right { + -webkit-transform-origin: 100%; + transform-origin: 100%; } + .mfp-container { + padding-left: 6px; + padding-right: 6px; } } + +.mfp-ie7 .mfp-img { + padding: 0; } +.mfp-ie7 .mfp-bottom-bar { + width: 600px; + left: 50%; + margin-left: -300px; + margin-top: 5px; + padding-bottom: 5px; } +.mfp-ie7 .mfp-container { + padding: 0; } +.mfp-ie7 .mfp-content { + padding-top: 44px; } +.mfp-ie7 .mfp-close { + top: 0; + right: 0; + padding-top: 0; } diff --git a/media/assets/css/magnific-popup.css b/media/assets/css/magnific-popup.css new file mode 100644 index 0000000000..76a1b4afb6 --- /dev/null +++ b/media/assets/css/magnific-popup.css @@ -0,0 +1,369 @@ +/* Magnific Popup CSS */ +.mfp-bg { + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 1042; + overflow: hidden; + position: fixed; + background: #0b0b0b; + opacity: 0.8; + filter: alpha(opacity=80); } + +.mfp-wrap { + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 1043; + position: fixed; + outline: none !important; + -webkit-backface-visibility: hidden; } + +.mfp-container { + text-align: center; + position: absolute; + width: 100%; + height: 100%; + left: 0; + top: 0; + padding: 0 8px; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } + +.mfp-container:before { + content: ''; + display: inline-block; + height: 100%; + vertical-align: middle; } + +.mfp-align-top .mfp-container:before { + display: none; } + +.mfp-content { + position: relative; + display: inline-block; + vertical-align: middle; + margin: 0 auto; + text-align: left; + z-index: 1045; } + +.mfp-inline-holder .mfp-content, .mfp-ajax-holder .mfp-content { + width: 100%; + cursor: auto; } + +.mfp-ajax-cur { + cursor: progress; } + +.mfp-zoom-out-cur, .mfp-zoom-out-cur .mfp-image-holder .mfp-close { + cursor: -moz-zoom-out; + cursor: -webkit-zoom-out; + cursor: zoom-out; } + +.mfp-zoom { + cursor: pointer; + cursor: -webkit-zoom-in; + cursor: -moz-zoom-in; + cursor: zoom-in; } + +.mfp-auto-cursor .mfp-content { + cursor: auto; } + +.mfp-close, .mfp-arrow, .mfp-preloader, .mfp-counter { + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; } + +.mfp-loading.mfp-figure { + display: none; } + +.mfp-hide { + display: none !important; } + +.mfp-preloader { + color: #cccccc; + position: absolute; + top: 50%; + width: auto; + text-align: center; + margin-top: -0.8em; + left: 8px; + right: 8px; + z-index: 1044; } + .mfp-preloader a { + color: #cccccc; } + .mfp-preloader a:hover { + color: white; } + +.mfp-s-ready .mfp-preloader { + display: none; } + +.mfp-s-error .mfp-content { + display: none; } + +button.mfp-close, button.mfp-arrow { + overflow: visible; + cursor: pointer; + background: transparent; + border: 0; + -webkit-appearance: none; + display: block; + outline: none; + padding: 0; + z-index: 1046; + -webkit-box-shadow: none; + box-shadow: none; } +button::-moz-focus-inner { + padding: 0; + border: 0; } + +.mfp-close { + width: 44px; + height: 44px; + line-height: 44px; + position: absolute; + right: 0; + top: 0; + text-decoration: none; + text-align: center; + opacity: 0.65; + filter: alpha(opacity=65); + padding: 0 0 18px 10px; + color: white; + font-style: normal; + font-size: 28px; + font-family: Arial, Baskerville, monospace; } + .mfp-close:hover, .mfp-close:focus { + opacity: 1; + filter: alpha(opacity=100); } + .mfp-close:active { + top: 1px; } + +.mfp-close-btn-in .mfp-close { + color: #333333; } + +.mfp-image-holder .mfp-close, .mfp-iframe-holder .mfp-close { + color: white; + right: -6px; + text-align: right; + padding-right: 6px; + width: 100%; } + +.mfp-counter { + position: absolute; + top: 0; + right: 0; + color: #cccccc; + font-size: 12px; + line-height: 18px; + white-space: nowrap; } + +.mfp-arrow { + position: absolute; + opacity: 0.65; + filter: alpha(opacity=65); + margin: 0; + top: 50%; + margin-top: -55px; + padding: 0; + width: 90px; + height: 110px; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } + .mfp-arrow:active { + margin-top: -54px; } + .mfp-arrow:hover, .mfp-arrow:focus { + opacity: 1; + filter: alpha(opacity=100); } + .mfp-arrow:before, .mfp-arrow:after, .mfp-arrow .mfp-b, .mfp-arrow .mfp-a { + content: ''; + display: block; + width: 0; + height: 0; + position: absolute; + left: 0; + top: 0; + margin-top: 35px; + margin-left: 35px; + border: medium inset transparent; } + .mfp-arrow:after, .mfp-arrow .mfp-a { + border-top-width: 13px; + border-bottom-width: 13px; + top: 8px; } + .mfp-arrow:before, .mfp-arrow .mfp-b { + border-top-width: 21px; + border-bottom-width: 21px; + opacity: 0.7; } + +.mfp-arrow-left { + left: 0; } + .mfp-arrow-left:after, .mfp-arrow-left .mfp-a { + border-right: 17px solid white; + margin-left: 31px; } + .mfp-arrow-left:before, .mfp-arrow-left .mfp-b { + margin-left: 25px; + border-right: 27px solid #3f3f3f; } + +.mfp-arrow-right { + right: 0; } + .mfp-arrow-right:after, .mfp-arrow-right .mfp-a { + border-left: 17px solid white; + margin-left: 39px; } + .mfp-arrow-right:before, .mfp-arrow-right .mfp-b { + border-left: 27px solid #3f3f3f; } + +.mfp-iframe-holder { + padding-top: 40px; + padding-bottom: 40px; } + .mfp-iframe-holder .mfp-content { + line-height: 0; + width: 100%; + max-width: 900px; } + .mfp-iframe-holder .mfp-close { + top: -40px; } + +.mfp-iframe-scaler { + width: 100%; + height: 0; + overflow: hidden; + padding-top: 56.25%; } + .mfp-iframe-scaler iframe { + position: absolute; + display: block; + top: 0; + left: 0; + width: 100%; + height: 100%; + box-shadow: 0 0 8px rgba(0, 0, 0, 0.6); + background: black; } + +/* Main image in popup */ +img.mfp-img { + width: auto; + max-width: 100%; + height: auto; + display: block; + line-height: 0; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + padding: 40px 0 40px; + margin: 0 auto; } + +/* The shadow behind the image */ +.mfp-figure { + line-height: 0; } + .mfp-figure:after { + content: ''; + position: absolute; + left: 0; + top: 40px; + bottom: 40px; + display: block; + right: 0; + width: auto; + height: auto; + z-index: -1; + box-shadow: 0 0 8px rgba(0, 0, 0, 0.6); + background: #444444; } + .mfp-figure small { + color: #bdbdbd; + display: block; + font-size: 12px; + line-height: 14px; } + .mfp-figure figure { + margin: 0; } + +.mfp-bottom-bar { + margin-top: -36px; + position: absolute; + top: 100%; + left: 0; + width: 100%; + cursor: auto; } + +.mfp-title { + text-align: left; + line-height: 18px; + color: #f3f3f3; + word-wrap: break-word; + padding-right: 36px; } + +.mfp-image-holder .mfp-content { + max-width: 100%; } + +.mfp-gallery .mfp-image-holder .mfp-figure { + cursor: pointer; } + +@media screen and (max-width: 800px) and (orientation: landscape), screen and (max-height: 300px) { + /** + * Remove all paddings around the image on small screen + */ + .mfp-img-mobile .mfp-image-holder { + padding-left: 0; + padding-right: 0; } + .mfp-img-mobile img.mfp-img { + padding: 0; } + .mfp-img-mobile .mfp-figure:after { + top: 0; + bottom: 0; } + .mfp-img-mobile .mfp-figure small { + display: inline; + margin-left: 5px; } + .mfp-img-mobile .mfp-bottom-bar { + background: rgba(0, 0, 0, 0.6); + bottom: 0; + margin: 0; + top: auto; + padding: 3px 5px; + position: fixed; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } + .mfp-img-mobile .mfp-bottom-bar:empty { + padding: 0; } + .mfp-img-mobile .mfp-counter { + right: 5px; + top: 3px; } + .mfp-img-mobile .mfp-close { + top: 0; + right: 0; + width: 35px; + height: 35px; + line-height: 35px; + background: rgba(0, 0, 0, 0.6); + position: fixed; + text-align: center; + padding: 0; } } + +@media all and (max-width: 900px) { + .mfp-arrow { + -webkit-transform: scale(0.75); + transform: scale(0.75); } + .mfp-arrow-left { + -webkit-transform-origin: 0; + transform-origin: 0; } + .mfp-arrow-right { + -webkit-transform-origin: 100%; + transform-origin: 100%; } + .mfp-container { + padding-left: 6px; + padding-right: 6px; } } + +.mfp-ie7 .mfp-img { + padding: 0; } +.mfp-ie7 .mfp-bottom-bar { + width: 600px; + left: 50%; + margin-left: -300px; + margin-top: 5px; + padding-bottom: 5px; } +.mfp-ie7 .mfp-container { + padding: 0; } +.mfp-ie7 .mfp-content { + padding-top: 44px; } +.mfp-ie7 .mfp-close { + top: 0; + right: 0; + padding-top: 0; } diff --git a/media/assets/css/select2-3.5.2.b9d0598b4e1c.css b/media/assets/css/select2-3.5.2.b9d0598b4e1c.css new file mode 100644 index 0000000000..abb318e2c7 --- /dev/null +++ b/media/assets/css/select2-3.5.2.b9d0598b4e1c.css @@ -0,0 +1,704 @@ +/* +Version: 3.5.2 Timestamp: Sat Nov 1 14:43:36 EDT 2014 +*/ +.select2-container { + margin: 0; + position: relative; + display: inline-block; + /* inline-block for ie7 */ + zoom: 1; + *display: inline; + vertical-align: middle; +} + +.select2-container, +.select2-drop, +.select2-search, +.select2-search input { + /* + Force border-box so that % widths fit the parent + container without overlap because of margin/padding. + More Info : http://www.quirksmode.org/css/box.html + */ + -webkit-box-sizing: border-box; /* webkit */ + -moz-box-sizing: border-box; /* firefox */ + box-sizing: border-box; /* css3 */ +} + +.select2-container .select2-choice { + display: block; + height: 26px; + padding: 0 0 0 8px; + overflow: hidden; + position: relative; + + border: 1px solid #aaa; + white-space: nowrap; + line-height: 26px; + color: #444; + text-decoration: none; + + border-radius: 4px; + + background-clip: padding-box; + + -webkit-touch-callout: none; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + + background-color: #fff; + background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.5, #fff)); + background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 50%); + background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 50%); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#ffffff', endColorstr = '#eeeeee', GradientType = 0); + background-image: linear-gradient(to top, #eee 0%, #fff 50%); +} + +html[dir="rtl"] .select2-container .select2-choice { + padding: 0 8px 0 0; +} + +.select2-container.select2-drop-above .select2-choice { + border-bottom-color: #aaa; + + border-radius: 0 0 4px 4px; + + background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.9, #fff)); + background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 90%); + background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 90%); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0); + background-image: linear-gradient(to bottom, #eee 0%, #fff 90%); +} + +.select2-container.select2-allowclear .select2-choice .select2-chosen { + margin-right: 42px; +} + +.select2-container .select2-choice > .select2-chosen { + margin-right: 26px; + display: block; + overflow: hidden; + + white-space: nowrap; + + text-overflow: ellipsis; + float: none; + width: auto; +} + +html[dir="rtl"] .select2-container .select2-choice > .select2-chosen { + margin-left: 26px; + margin-right: 0; +} + +.select2-container .select2-choice abbr { + display: none; + width: 12px; + height: 12px; + position: absolute; + right: 24px; + top: 8px; + + font-size: 1px; + text-decoration: none; + + border: 0; + background: url("select2.2ca61b76e220.png") right top no-repeat; + cursor: pointer; + outline: 0; +} + +.select2-container.select2-allowclear .select2-choice abbr { + display: inline-block; +} + +.select2-container .select2-choice abbr:hover { + background-position: right -11px; + cursor: pointer; +} + +.select2-drop-mask { + border: 0; + margin: 0; + padding: 0; + position: fixed; + left: 0; + top: 0; + min-height: 100%; + min-width: 100%; + height: auto; + width: auto; + opacity: 0; + z-index: 9998; + /* styles required for IE to work */ + background-color: #fff; + filter: alpha(opacity=0); +} + +.select2-drop { + width: 100%; + margin-top: -1px; + position: absolute; + z-index: 9999; + top: 100%; + + background: #fff; + color: #000; + border: 1px solid #aaa; + border-top: 0; + + border-radius: 0 0 4px 4px; + + -webkit-box-shadow: 0 4px 5px rgba(0, 0, 0, .15); + box-shadow: 0 4px 5px rgba(0, 0, 0, .15); +} + +.select2-drop.select2-drop-above { + margin-top: 1px; + border-top: 1px solid #aaa; + border-bottom: 0; + + border-radius: 4px 4px 0 0; + + -webkit-box-shadow: 0 -4px 5px rgba(0, 0, 0, .15); + box-shadow: 0 -4px 5px rgba(0, 0, 0, .15); +} + +.select2-drop-active { + border: 1px solid #5897fb; + border-top: none; +} + +.select2-drop.select2-drop-above.select2-drop-active { + border-top: 1px solid #5897fb; +} + +.select2-drop-auto-width { + border-top: 1px solid #aaa; + width: auto; +} + +.select2-drop-auto-width .select2-search { + padding-top: 4px; +} + +.select2-container .select2-choice .select2-arrow { + display: inline-block; + width: 18px; + height: 100%; + position: absolute; + right: 0; + top: 0; + + border-left: 1px solid #aaa; + border-radius: 0 4px 4px 0; + + background-clip: padding-box; + + background: #ccc; + background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #ccc), color-stop(0.6, #eee)); + background-image: -webkit-linear-gradient(center bottom, #ccc 0%, #eee 60%); + background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#eeeeee', endColorstr = '#cccccc', GradientType = 0); + background-image: linear-gradient(to top, #ccc 0%, #eee 60%); +} + +html[dir="rtl"] .select2-container .select2-choice .select2-arrow { + left: 0; + right: auto; + + border-left: none; + border-right: 1px solid #aaa; + border-radius: 4px 0 0 4px; +} + +.select2-container .select2-choice .select2-arrow b { + display: block; + width: 100%; + height: 100%; + background: url("select2.2ca61b76e220.png") no-repeat 0 1px; +} + +html[dir="rtl"] .select2-container .select2-choice .select2-arrow b { + background-position: 2px 1px; +} + +.select2-search { + display: inline-block; + width: 100%; + min-height: 26px; + margin: 0; + padding-left: 4px; + padding-right: 4px; + + position: relative; + z-index: 10000; + + white-space: nowrap; +} + +.select2-search input { + width: 100%; + height: auto !important; + min-height: 26px; + padding: 4px 20px 4px 5px; + margin: 0; + + outline: 0; + font-family: sans-serif; + font-size: 1em; + + border: 1px solid #aaa; + border-radius: 0; + + -webkit-box-shadow: none; + box-shadow: none; + + background: #fff url("select2.2ca61b76e220.png") no-repeat 100% -22px; + background: url("select2.2ca61b76e220.png") no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee)); + background: url("select2.2ca61b76e220.png") no-repeat 100% -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%); + background: url("select2.2ca61b76e220.png") no-repeat 100% -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%); + background: url("select2.2ca61b76e220.png") no-repeat 100% -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0; +} + +html[dir="rtl"] .select2-search input { + padding: 4px 5px 4px 20px; + + background: #fff url("select2.2ca61b76e220.png") no-repeat -37px -22px; + background: url("select2.2ca61b76e220.png") no-repeat -37px -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee)); + background: url("select2.2ca61b76e220.png") no-repeat -37px -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%); + background: url("select2.2ca61b76e220.png") no-repeat -37px -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%); + background: url("select2.2ca61b76e220.png") no-repeat -37px -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0; +} + +.select2-drop.select2-drop-above .select2-search input { + margin-top: 4px; +} + +.select2-search input.select2-active { + background: #fff url("select2-spinner.7b9776076d5f.gif") no-repeat 100%; + background: url("select2-spinner.7b9776076d5f.gif") no-repeat 100%, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee)); + background: url("select2-spinner.7b9776076d5f.gif") no-repeat 100%, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%); + background: url("select2-spinner.7b9776076d5f.gif") no-repeat 100%, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%); + background: url("select2-spinner.7b9776076d5f.gif") no-repeat 100%, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0; +} + +.select2-container-active .select2-choice, +.select2-container-active .select2-choices { + border: 1px solid #5897fb; + outline: none; + + -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3); + box-shadow: 0 0 5px rgba(0, 0, 0, .3); +} + +.select2-dropdown-open .select2-choice { + border-bottom-color: transparent; + -webkit-box-shadow: 0 1px 0 #fff inset; + box-shadow: 0 1px 0 #fff inset; + + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; + + background-color: #eee; + background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #fff), color-stop(0.5, #eee)); + background-image: -webkit-linear-gradient(center bottom, #fff 0%, #eee 50%); + background-image: -moz-linear-gradient(center bottom, #fff 0%, #eee 50%); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0); + background-image: linear-gradient(to top, #fff 0%, #eee 50%); +} + +.select2-dropdown-open.select2-drop-above .select2-choice, +.select2-dropdown-open.select2-drop-above .select2-choices { + border: 1px solid #5897fb; + border-top-color: transparent; + + background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fff), color-stop(0.5, #eee)); + background-image: -webkit-linear-gradient(center top, #fff 0%, #eee 50%); + background-image: -moz-linear-gradient(center top, #fff 0%, #eee 50%); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0); + background-image: linear-gradient(to bottom, #fff 0%, #eee 50%); +} + +.select2-dropdown-open .select2-choice .select2-arrow { + background: transparent; + border-left: none; + filter: none; +} +html[dir="rtl"] .select2-dropdown-open .select2-choice .select2-arrow { + border-right: none; +} + +.select2-dropdown-open .select2-choice .select2-arrow b { + background-position: -18px 1px; +} + +html[dir="rtl"] .select2-dropdown-open .select2-choice .select2-arrow b { + background-position: -16px 1px; +} + +.select2-hidden-accessible { + border: 0; + clip: rect(0 0 0 0); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; +} + +/* results */ +.select2-results { + max-height: 200px; + padding: 0 0 0 4px; + margin: 4px 4px 4px 0; + position: relative; + overflow-x: hidden; + overflow-y: auto; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); +} + +html[dir="rtl"] .select2-results { + padding: 0 4px 0 0; + margin: 4px 0 4px 4px; +} + +.select2-results ul.select2-result-sub { + margin: 0; + padding-left: 0; +} + +.select2-results li { + list-style: none; + display: list-item; + background-image: none; +} + +.select2-results li.select2-result-with-children > .select2-result-label { + font-weight: bold; +} + +.select2-results .select2-result-label { + padding: 3px 7px 4px; + margin: 0; + cursor: pointer; + + min-height: 1em; + + -webkit-touch-callout: none; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.select2-results-dept-1 .select2-result-label { padding-left: 20px } +.select2-results-dept-2 .select2-result-label { padding-left: 40px } +.select2-results-dept-3 .select2-result-label { padding-left: 60px } +.select2-results-dept-4 .select2-result-label { padding-left: 80px } +.select2-results-dept-5 .select2-result-label { padding-left: 100px } +.select2-results-dept-6 .select2-result-label { padding-left: 110px } +.select2-results-dept-7 .select2-result-label { padding-left: 120px } + +.select2-results .select2-highlighted { + background: #3875d7; + color: #fff; +} + +.select2-results li em { + background: #feffde; + font-style: normal; +} + +.select2-results .select2-highlighted em { + background: transparent; +} + +.select2-results .select2-highlighted ul { + background: #fff; + color: #000; +} + +.select2-results .select2-no-results, +.select2-results .select2-searching, +.select2-results .select2-ajax-error, +.select2-results .select2-selection-limit { + background: #f4f4f4; + display: list-item; + padding-left: 5px; +} + +/* +disabled look for disabled choices in the results dropdown +*/ +.select2-results .select2-disabled.select2-highlighted { + color: #666; + background: #f4f4f4; + display: list-item; + cursor: default; +} +.select2-results .select2-disabled { + background: #f4f4f4; + display: list-item; + cursor: default; +} + +.select2-results .select2-selected { + display: none; +} + +.select2-more-results.select2-active { + background: #f4f4f4 url("select2-spinner.7b9776076d5f.gif") no-repeat 100%; +} + +.select2-results .select2-ajax-error { + background: rgba(255, 50, 50, .2); +} + +.select2-more-results { + background: #f4f4f4; + display: list-item; +} + +/* disabled styles */ + +.select2-container.select2-container-disabled .select2-choice { + background-color: #f4f4f4; + background-image: none; + border: 1px solid #ddd; + cursor: default; +} + +.select2-container.select2-container-disabled .select2-choice .select2-arrow { + background-color: #f4f4f4; + background-image: none; + border-left: 0; +} + +.select2-container.select2-container-disabled .select2-choice abbr { + display: none; +} + + +/* multiselect */ + +.select2-container-multi .select2-choices { + height: auto !important; + height: 1%; + margin: 0; + padding: 0 5px 0 0; + position: relative; + + border: 1px solid #aaa; + cursor: text; + overflow: hidden; + + background-color: #fff; + background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eee), color-stop(15%, #fff)); + background-image: -webkit-linear-gradient(top, #eee 1%, #fff 15%); + background-image: -moz-linear-gradient(top, #eee 1%, #fff 15%); + background-image: linear-gradient(to bottom, #eee 1%, #fff 15%); +} + +html[dir="rtl"] .select2-container-multi .select2-choices { + padding: 0 0 0 5px; +} + +.select2-locked { + padding: 3px 5px 3px 5px !important; +} + +.select2-container-multi .select2-choices { + min-height: 26px; +} + +.select2-container-multi.select2-container-active .select2-choices { + border: 1px solid #5897fb; + outline: none; + + -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3); + box-shadow: 0 0 5px rgba(0, 0, 0, .3); +} +.select2-container-multi .select2-choices li { + float: left; + list-style: none; +} +html[dir="rtl"] .select2-container-multi .select2-choices li +{ + float: right; +} +.select2-container-multi .select2-choices .select2-search-field { + margin: 0; + padding: 0; + white-space: nowrap; +} + +.select2-container-multi .select2-choices .select2-search-field input { + padding: 5px; + margin: 1px 0; + + font-family: sans-serif; + font-size: 100%; + color: #666; + outline: 0; + border: 0; + -webkit-box-shadow: none; + box-shadow: none; + background: transparent !important; +} + +.select2-container-multi .select2-choices .select2-search-field input.select2-active { + background: #fff url("select2-spinner.7b9776076d5f.gif") no-repeat 100% !important; +} + +.select2-default { + color: #999 !important; +} + +.select2-container-multi .select2-choices .select2-search-choice { + padding: 3px 5px 3px 18px; + margin: 3px 0 3px 5px; + position: relative; + + line-height: 13px; + color: #333; + cursor: default; + border: 1px solid #aaaaaa; + + border-radius: 3px; + + -webkit-box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05); + box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05); + + background-clip: padding-box; + + -webkit-touch-callout: none; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + + background-color: #e4e4e4; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#f4f4f4', GradientType=0); + background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eee)); + background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%); + background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%); + background-image: linear-gradient(to bottom, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%); +} +html[dir="rtl"] .select2-container-multi .select2-choices .select2-search-choice +{ + margin: 3px 5px 3px 0; + padding: 3px 18px 3px 5px; +} +.select2-container-multi .select2-choices .select2-search-choice .select2-chosen { + cursor: default; +} +.select2-container-multi .select2-choices .select2-search-choice-focus { + background: #d4d4d4; +} + +.select2-search-choice-close { + display: block; + width: 12px; + height: 13px; + position: absolute; + right: 3px; + top: 4px; + + font-size: 1px; + outline: none; + background: url("select2.2ca61b76e220.png") right top no-repeat; +} +html[dir="rtl"] .select2-search-choice-close { + right: auto; + left: 3px; +} + +.select2-container-multi .select2-search-choice-close { + left: 3px; +} + +html[dir="rtl"] .select2-container-multi .select2-search-choice-close { + left: auto; + right: 2px; +} + +.select2-container-multi .select2-choices .select2-search-choice .select2-search-choice-close:hover { + background-position: right -11px; +} +.select2-container-multi .select2-choices .select2-search-choice-focus .select2-search-choice-close { + background-position: right -11px; +} + +/* disabled styles */ +.select2-container-multi.select2-container-disabled .select2-choices { + background-color: #f4f4f4; + background-image: none; + border: 1px solid #ddd; + cursor: default; +} + +.select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice { + padding: 3px 5px 3px 5px; + border: 1px solid #ddd; + background-image: none; + background-color: #f4f4f4; +} + +.select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice .select2-search-choice-close { display: none; + background: none; +} +/* end multiselect */ + + +.select2-result-selectable .select2-match, +.select2-result-unselectable .select2-match { + text-decoration: underline; +} + +.select2-offscreen, .select2-offscreen:focus { + clip: rect(0 0 0 0) !important; + width: 1px !important; + height: 1px !important; + border: 0 !important; + margin: 0 !important; + padding: 0 !important; + overflow: hidden !important; + position: absolute !important; + outline: 0 !important; + left: 0px !important; + top: 0px !important; +} + +.select2-display-none { + display: none; +} + +.select2-measure-scrollbar { + position: absolute; + top: -10000px; + left: -10000px; + width: 100px; + height: 100px; + overflow: scroll; +} + +/* Retina-ize icons */ + +@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 2dppx) { + .select2-search input, + .select2-search-choice-close, + .select2-container .select2-choice abbr, + .select2-container .select2-choice .select2-arrow b { + background-image: url("select2x2.49e3f0060186.png") !important; + background-repeat: no-repeat !important; + background-size: 60px 40px !important; + } + + .select2-search input { + background-position: 100% -21px !important; + } +} diff --git a/media/assets/css/select2-3.5.2.css b/media/assets/css/select2-3.5.2.css new file mode 100644 index 0000000000..2d07a0343b --- /dev/null +++ b/media/assets/css/select2-3.5.2.css @@ -0,0 +1,704 @@ +/* +Version: 3.5.2 Timestamp: Sat Nov 1 14:43:36 EDT 2014 +*/ +.select2-container { + margin: 0; + position: relative; + display: inline-block; + /* inline-block for ie7 */ + zoom: 1; + *display: inline; + vertical-align: middle; +} + +.select2-container, +.select2-drop, +.select2-search, +.select2-search input { + /* + Force border-box so that % widths fit the parent + container without overlap because of margin/padding. + More Info : http://www.quirksmode.org/css/box.html + */ + -webkit-box-sizing: border-box; /* webkit */ + -moz-box-sizing: border-box; /* firefox */ + box-sizing: border-box; /* css3 */ +} + +.select2-container .select2-choice { + display: block; + height: 26px; + padding: 0 0 0 8px; + overflow: hidden; + position: relative; + + border: 1px solid #aaa; + white-space: nowrap; + line-height: 26px; + color: #444; + text-decoration: none; + + border-radius: 4px; + + background-clip: padding-box; + + -webkit-touch-callout: none; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + + background-color: #fff; + background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.5, #fff)); + background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 50%); + background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 50%); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#ffffff', endColorstr = '#eeeeee', GradientType = 0); + background-image: linear-gradient(to top, #eee 0%, #fff 50%); +} + +html[dir="rtl"] .select2-container .select2-choice { + padding: 0 8px 0 0; +} + +.select2-container.select2-drop-above .select2-choice { + border-bottom-color: #aaa; + + border-radius: 0 0 4px 4px; + + background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.9, #fff)); + background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 90%); + background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 90%); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0); + background-image: linear-gradient(to bottom, #eee 0%, #fff 90%); +} + +.select2-container.select2-allowclear .select2-choice .select2-chosen { + margin-right: 42px; +} + +.select2-container .select2-choice > .select2-chosen { + margin-right: 26px; + display: block; + overflow: hidden; + + white-space: nowrap; + + text-overflow: ellipsis; + float: none; + width: auto; +} + +html[dir="rtl"] .select2-container .select2-choice > .select2-chosen { + margin-left: 26px; + margin-right: 0; +} + +.select2-container .select2-choice abbr { + display: none; + width: 12px; + height: 12px; + position: absolute; + right: 24px; + top: 8px; + + font-size: 1px; + text-decoration: none; + + border: 0; + background: url('select2.png') right top no-repeat; + cursor: pointer; + outline: 0; +} + +.select2-container.select2-allowclear .select2-choice abbr { + display: inline-block; +} + +.select2-container .select2-choice abbr:hover { + background-position: right -11px; + cursor: pointer; +} + +.select2-drop-mask { + border: 0; + margin: 0; + padding: 0; + position: fixed; + left: 0; + top: 0; + min-height: 100%; + min-width: 100%; + height: auto; + width: auto; + opacity: 0; + z-index: 9998; + /* styles required for IE to work */ + background-color: #fff; + filter: alpha(opacity=0); +} + +.select2-drop { + width: 100%; + margin-top: -1px; + position: absolute; + z-index: 9999; + top: 100%; + + background: #fff; + color: #000; + border: 1px solid #aaa; + border-top: 0; + + border-radius: 0 0 4px 4px; + + -webkit-box-shadow: 0 4px 5px rgba(0, 0, 0, .15); + box-shadow: 0 4px 5px rgba(0, 0, 0, .15); +} + +.select2-drop.select2-drop-above { + margin-top: 1px; + border-top: 1px solid #aaa; + border-bottom: 0; + + border-radius: 4px 4px 0 0; + + -webkit-box-shadow: 0 -4px 5px rgba(0, 0, 0, .15); + box-shadow: 0 -4px 5px rgba(0, 0, 0, .15); +} + +.select2-drop-active { + border: 1px solid #5897fb; + border-top: none; +} + +.select2-drop.select2-drop-above.select2-drop-active { + border-top: 1px solid #5897fb; +} + +.select2-drop-auto-width { + border-top: 1px solid #aaa; + width: auto; +} + +.select2-drop-auto-width .select2-search { + padding-top: 4px; +} + +.select2-container .select2-choice .select2-arrow { + display: inline-block; + width: 18px; + height: 100%; + position: absolute; + right: 0; + top: 0; + + border-left: 1px solid #aaa; + border-radius: 0 4px 4px 0; + + background-clip: padding-box; + + background: #ccc; + background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #ccc), color-stop(0.6, #eee)); + background-image: -webkit-linear-gradient(center bottom, #ccc 0%, #eee 60%); + background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#eeeeee', endColorstr = '#cccccc', GradientType = 0); + background-image: linear-gradient(to top, #ccc 0%, #eee 60%); +} + +html[dir="rtl"] .select2-container .select2-choice .select2-arrow { + left: 0; + right: auto; + + border-left: none; + border-right: 1px solid #aaa; + border-radius: 4px 0 0 4px; +} + +.select2-container .select2-choice .select2-arrow b { + display: block; + width: 100%; + height: 100%; + background: url('select2.png') no-repeat 0 1px; +} + +html[dir="rtl"] .select2-container .select2-choice .select2-arrow b { + background-position: 2px 1px; +} + +.select2-search { + display: inline-block; + width: 100%; + min-height: 26px; + margin: 0; + padding-left: 4px; + padding-right: 4px; + + position: relative; + z-index: 10000; + + white-space: nowrap; +} + +.select2-search input { + width: 100%; + height: auto !important; + min-height: 26px; + padding: 4px 20px 4px 5px; + margin: 0; + + outline: 0; + font-family: sans-serif; + font-size: 1em; + + border: 1px solid #aaa; + border-radius: 0; + + -webkit-box-shadow: none; + box-shadow: none; + + background: #fff url('select2.png') no-repeat 100% -22px; + background: url('select2.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee)); + background: url('select2.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%); + background: url('select2.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%); + background: url('select2.png') no-repeat 100% -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0; +} + +html[dir="rtl"] .select2-search input { + padding: 4px 5px 4px 20px; + + background: #fff url('select2.png') no-repeat -37px -22px; + background: url('select2.png') no-repeat -37px -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee)); + background: url('select2.png') no-repeat -37px -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%); + background: url('select2.png') no-repeat -37px -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%); + background: url('select2.png') no-repeat -37px -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0; +} + +.select2-drop.select2-drop-above .select2-search input { + margin-top: 4px; +} + +.select2-search input.select2-active { + background: #fff url('select2-spinner.gif') no-repeat 100%; + background: url('select2-spinner.gif') no-repeat 100%, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee)); + background: url('select2-spinner.gif') no-repeat 100%, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%); + background: url('select2-spinner.gif') no-repeat 100%, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%); + background: url('select2-spinner.gif') no-repeat 100%, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0; +} + +.select2-container-active .select2-choice, +.select2-container-active .select2-choices { + border: 1px solid #5897fb; + outline: none; + + -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3); + box-shadow: 0 0 5px rgba(0, 0, 0, .3); +} + +.select2-dropdown-open .select2-choice { + border-bottom-color: transparent; + -webkit-box-shadow: 0 1px 0 #fff inset; + box-shadow: 0 1px 0 #fff inset; + + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; + + background-color: #eee; + background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #fff), color-stop(0.5, #eee)); + background-image: -webkit-linear-gradient(center bottom, #fff 0%, #eee 50%); + background-image: -moz-linear-gradient(center bottom, #fff 0%, #eee 50%); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0); + background-image: linear-gradient(to top, #fff 0%, #eee 50%); +} + +.select2-dropdown-open.select2-drop-above .select2-choice, +.select2-dropdown-open.select2-drop-above .select2-choices { + border: 1px solid #5897fb; + border-top-color: transparent; + + background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fff), color-stop(0.5, #eee)); + background-image: -webkit-linear-gradient(center top, #fff 0%, #eee 50%); + background-image: -moz-linear-gradient(center top, #fff 0%, #eee 50%); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0); + background-image: linear-gradient(to bottom, #fff 0%, #eee 50%); +} + +.select2-dropdown-open .select2-choice .select2-arrow { + background: transparent; + border-left: none; + filter: none; +} +html[dir="rtl"] .select2-dropdown-open .select2-choice .select2-arrow { + border-right: none; +} + +.select2-dropdown-open .select2-choice .select2-arrow b { + background-position: -18px 1px; +} + +html[dir="rtl"] .select2-dropdown-open .select2-choice .select2-arrow b { + background-position: -16px 1px; +} + +.select2-hidden-accessible { + border: 0; + clip: rect(0 0 0 0); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; +} + +/* results */ +.select2-results { + max-height: 200px; + padding: 0 0 0 4px; + margin: 4px 4px 4px 0; + position: relative; + overflow-x: hidden; + overflow-y: auto; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); +} + +html[dir="rtl"] .select2-results { + padding: 0 4px 0 0; + margin: 4px 0 4px 4px; +} + +.select2-results ul.select2-result-sub { + margin: 0; + padding-left: 0; +} + +.select2-results li { + list-style: none; + display: list-item; + background-image: none; +} + +.select2-results li.select2-result-with-children > .select2-result-label { + font-weight: bold; +} + +.select2-results .select2-result-label { + padding: 3px 7px 4px; + margin: 0; + cursor: pointer; + + min-height: 1em; + + -webkit-touch-callout: none; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.select2-results-dept-1 .select2-result-label { padding-left: 20px } +.select2-results-dept-2 .select2-result-label { padding-left: 40px } +.select2-results-dept-3 .select2-result-label { padding-left: 60px } +.select2-results-dept-4 .select2-result-label { padding-left: 80px } +.select2-results-dept-5 .select2-result-label { padding-left: 100px } +.select2-results-dept-6 .select2-result-label { padding-left: 110px } +.select2-results-dept-7 .select2-result-label { padding-left: 120px } + +.select2-results .select2-highlighted { + background: #3875d7; + color: #fff; +} + +.select2-results li em { + background: #feffde; + font-style: normal; +} + +.select2-results .select2-highlighted em { + background: transparent; +} + +.select2-results .select2-highlighted ul { + background: #fff; + color: #000; +} + +.select2-results .select2-no-results, +.select2-results .select2-searching, +.select2-results .select2-ajax-error, +.select2-results .select2-selection-limit { + background: #f4f4f4; + display: list-item; + padding-left: 5px; +} + +/* +disabled look for disabled choices in the results dropdown +*/ +.select2-results .select2-disabled.select2-highlighted { + color: #666; + background: #f4f4f4; + display: list-item; + cursor: default; +} +.select2-results .select2-disabled { + background: #f4f4f4; + display: list-item; + cursor: default; +} + +.select2-results .select2-selected { + display: none; +} + +.select2-more-results.select2-active { + background: #f4f4f4 url('select2-spinner.gif') no-repeat 100%; +} + +.select2-results .select2-ajax-error { + background: rgba(255, 50, 50, .2); +} + +.select2-more-results { + background: #f4f4f4; + display: list-item; +} + +/* disabled styles */ + +.select2-container.select2-container-disabled .select2-choice { + background-color: #f4f4f4; + background-image: none; + border: 1px solid #ddd; + cursor: default; +} + +.select2-container.select2-container-disabled .select2-choice .select2-arrow { + background-color: #f4f4f4; + background-image: none; + border-left: 0; +} + +.select2-container.select2-container-disabled .select2-choice abbr { + display: none; +} + + +/* multiselect */ + +.select2-container-multi .select2-choices { + height: auto !important; + height: 1%; + margin: 0; + padding: 0 5px 0 0; + position: relative; + + border: 1px solid #aaa; + cursor: text; + overflow: hidden; + + background-color: #fff; + background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eee), color-stop(15%, #fff)); + background-image: -webkit-linear-gradient(top, #eee 1%, #fff 15%); + background-image: -moz-linear-gradient(top, #eee 1%, #fff 15%); + background-image: linear-gradient(to bottom, #eee 1%, #fff 15%); +} + +html[dir="rtl"] .select2-container-multi .select2-choices { + padding: 0 0 0 5px; +} + +.select2-locked { + padding: 3px 5px 3px 5px !important; +} + +.select2-container-multi .select2-choices { + min-height: 26px; +} + +.select2-container-multi.select2-container-active .select2-choices { + border: 1px solid #5897fb; + outline: none; + + -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3); + box-shadow: 0 0 5px rgba(0, 0, 0, .3); +} +.select2-container-multi .select2-choices li { + float: left; + list-style: none; +} +html[dir="rtl"] .select2-container-multi .select2-choices li +{ + float: right; +} +.select2-container-multi .select2-choices .select2-search-field { + margin: 0; + padding: 0; + white-space: nowrap; +} + +.select2-container-multi .select2-choices .select2-search-field input { + padding: 5px; + margin: 1px 0; + + font-family: sans-serif; + font-size: 100%; + color: #666; + outline: 0; + border: 0; + -webkit-box-shadow: none; + box-shadow: none; + background: transparent !important; +} + +.select2-container-multi .select2-choices .select2-search-field input.select2-active { + background: #fff url('select2-spinner.gif') no-repeat 100% !important; +} + +.select2-default { + color: #999 !important; +} + +.select2-container-multi .select2-choices .select2-search-choice { + padding: 3px 5px 3px 18px; + margin: 3px 0 3px 5px; + position: relative; + + line-height: 13px; + color: #333; + cursor: default; + border: 1px solid #aaaaaa; + + border-radius: 3px; + + -webkit-box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05); + box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05); + + background-clip: padding-box; + + -webkit-touch-callout: none; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + + background-color: #e4e4e4; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#f4f4f4', GradientType=0); + background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eee)); + background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%); + background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%); + background-image: linear-gradient(to bottom, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%); +} +html[dir="rtl"] .select2-container-multi .select2-choices .select2-search-choice +{ + margin: 3px 5px 3px 0; + padding: 3px 18px 3px 5px; +} +.select2-container-multi .select2-choices .select2-search-choice .select2-chosen { + cursor: default; +} +.select2-container-multi .select2-choices .select2-search-choice-focus { + background: #d4d4d4; +} + +.select2-search-choice-close { + display: block; + width: 12px; + height: 13px; + position: absolute; + right: 3px; + top: 4px; + + font-size: 1px; + outline: none; + background: url('select2.png') right top no-repeat; +} +html[dir="rtl"] .select2-search-choice-close { + right: auto; + left: 3px; +} + +.select2-container-multi .select2-search-choice-close { + left: 3px; +} + +html[dir="rtl"] .select2-container-multi .select2-search-choice-close { + left: auto; + right: 2px; +} + +.select2-container-multi .select2-choices .select2-search-choice .select2-search-choice-close:hover { + background-position: right -11px; +} +.select2-container-multi .select2-choices .select2-search-choice-focus .select2-search-choice-close { + background-position: right -11px; +} + +/* disabled styles */ +.select2-container-multi.select2-container-disabled .select2-choices { + background-color: #f4f4f4; + background-image: none; + border: 1px solid #ddd; + cursor: default; +} + +.select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice { + padding: 3px 5px 3px 5px; + border: 1px solid #ddd; + background-image: none; + background-color: #f4f4f4; +} + +.select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice .select2-search-choice-close { display: none; + background: none; +} +/* end multiselect */ + + +.select2-result-selectable .select2-match, +.select2-result-unselectable .select2-match { + text-decoration: underline; +} + +.select2-offscreen, .select2-offscreen:focus { + clip: rect(0 0 0 0) !important; + width: 1px !important; + height: 1px !important; + border: 0 !important; + margin: 0 !important; + padding: 0 !important; + overflow: hidden !important; + position: absolute !important; + outline: 0 !important; + left: 0px !important; + top: 0px !important; +} + +.select2-display-none { + display: none; +} + +.select2-measure-scrollbar { + position: absolute; + top: -10000px; + left: -10000px; + width: 100px; + height: 100px; + overflow: scroll; +} + +/* Retina-ize icons */ + +@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 2dppx) { + .select2-search input, + .select2-search-choice-close, + .select2-container .select2-choice abbr, + .select2-container .select2-choice .select2-arrow b { + background-image: url('select2x2.png') !important; + background-repeat: no-repeat !important; + background-size: 60px 40px !important; + } + + .select2-search input { + background-position: 100% -21px !important; + } +} diff --git a/media/assets/css/select2-spinner.7b9776076d5f.gif b/media/assets/css/select2-spinner.7b9776076d5f.gif new file mode 100644 index 0000000000000000000000000000000000000000..5b33f7e54f4e55b6b8774d86d96895db9af044b4 GIT binary patch literal 1849 zcma*odr(tX9tZI2z31lM+(&YVk%mZ}5P~KlG2s=WSbGzm0!x7^P##Mnh7t-jP!X0Q zk_SQ}Po-L1tlDK;6l?(>v)e5ZBQx4|Y-Q?nr@Px3?9h(3ZWr3^tj=`TP57gKr87N$ zp2wWee1GRRCwo_xahnw)5cxNPJbCg2L6DV|6`#+yw6v6!mDS$f9-JvFD^n;GQ&UrZ zzh5jCkByB101O60U0q#p_1BM>Cv-vP?&s4@g_((4_1L=L$(a91)0=J91Gas#R{McE znYG^9*0A5YZ>#;~+Wkn(W5B0^yELIYLP!K}mB~<)AM@1&nqekynuaEGqPrzoH|KodRXJy)%+w_fu3nE5>@Bd_b zqC$EQ;{c`T&?EsNO|igL9gC7Ygxv?aQUEXMq?~>wg{EyW;VcJ37CUF#HjrT=KQO_* zS>M9yydXk18D(+QDJ1>r);Lav_uYKp$T?4vr{Q$lTo&pKv^?(>L-)G2*lwH!Ah7k? z7oH<8h-(KTKt5V6$8gF)C7Io&P5=SjTh)=zV=E2EUhQZP##L8S{d%UK>>+y82>+FV+#^BzW7u3F)Bb>=lYQ%%j`F>ASe zo*cw@V#u6T`A2He;70mR(V&iV&-7{qP~=SRf&jm9-T{*ZeZ}$rd0#6c&fLG^xJcf5 z+p<`wJYgW+_s*V{uI$nMB;%8`S_3>PfGOj3Rq}@Cx^+j?rk92fANSFDBYnOqQ>Vdj z)(|$AhP4t&Lb=Gvo2#3Gl%9<=Gv`Mz?Po@P4iLF!x}GUWJICDlFk-hS^Whyh7x~VH z@0vD1>HYD4&e+~yzS*-sFR{9`{QEEZO1zg7>R&7cHts-6j!xHVdA8eI+ZlVzd%`es zJT@$#GX(gvCJ1oJN%yLBK}{V=V;seo;!w|Yte!W1%5qLNFWqvZW>h&IiH+oPT=b@E zPhGzv5=(Un*X>v`>%8h_nj^NdYcE6NHS_ifkCV$*D)Tqrbu`s;<=t<4 zAHNqNV?6(g<1PY-w@#I-WYFViz?9TrkMr)u0g`O`u|>T;k|2sV*YF^punvT;$SuTy{j3Gv)yqD!R_CF>yR)MzmmYS5v+~R zXAdD%ng9?df;wd8GxR#%3O+gz};Vo;)sK%Bj-q>Oq%R7JU-KD?vYu>#2UjaDo z&8$>5xW~?KPD_#XFToU1hIb*VOMidUr6iYiO0N|i-7s`T8!cFT`rN!^1Pt78J93i6 z5HI1wIM$94m{3SLDvISDe6$ZG1;eq_D9RTaaC>=cO{@Bs>$IlPCPJJ$h$)-3vzNUQ6OsN#_zWxey!_9%hxwH2_dEJi=yY|1c7nDm2_Lm!Cof8-R_+9UkS zcBE(o47yE)oMR(Q=dp1a2wTX5KvvGyLqlWTa7V&!A*|w|)ax~1_~aJ0=_Lilg*0iQk7#ZD EAHN$8j{pDw literal 0 HcmV?d00001 diff --git a/media/assets/css/select2-spinner.gif b/media/assets/css/select2-spinner.gif new file mode 100644 index 0000000000000000000000000000000000000000..5b33f7e54f4e55b6b8774d86d96895db9af044b4 GIT binary patch literal 1849 zcma*odr(tX9tZI2z31lM+(&YVk%mZ}5P~KlG2s=WSbGzm0!x7^P##Mnh7t-jP!X0Q zk_SQ}Po-L1tlDK;6l?(>v)e5ZBQx4|Y-Q?nr@Px3?9h(3ZWr3^tj=`TP57gKr87N$ zp2wWee1GRRCwo_xahnw)5cxNPJbCg2L6DV|6`#+yw6v6!mDS$f9-JvFD^n;GQ&UrZ zzh5jCkByB101O60U0q#p_1BM>Cv-vP?&s4@g_((4_1L=L$(a91)0=J91Gas#R{McE znYG^9*0A5YZ>#;~+Wkn(W5B0^yELIYLP!K}mB~<)AM@1&nqekynuaEGqPrzoH|KodRXJy)%+w_fu3nE5>@Bd_b zqC$EQ;{c`T&?EsNO|igL9gC7Ygxv?aQUEXMq?~>wg{EyW;VcJ37CUF#HjrT=KQO_* zS>M9yydXk18D(+QDJ1>r);Lav_uYKp$T?4vr{Q$lTo&pKv^?(>L-)G2*lwH!Ah7k? z7oH<8h-(KTKt5V6$8gF)C7Io&P5=SjTh)=zV=E2EUhQZP##L8S{d%UK>>+y82>+FV+#^BzW7u3F)Bb>=lYQ%%j`F>ASe zo*cw@V#u6T`A2He;70mR(V&iV&-7{qP~=SRf&jm9-T{*ZeZ}$rd0#6c&fLG^xJcf5 z+p<`wJYgW+_s*V{uI$nMB;%8`S_3>PfGOj3Rq}@Cx^+j?rk92fANSFDBYnOqQ>Vdj z)(|$AhP4t&Lb=Gvo2#3Gl%9<=Gv`Mz?Po@P4iLF!x}GUWJICDlFk-hS^Whyh7x~VH z@0vD1>HYD4&e+~yzS*-sFR{9`{QEEZO1zg7>R&7cHts-6j!xHVdA8eI+ZlVzd%`es zJT@$#GX(gvCJ1oJN%yLBK}{V=V;seo;!w|Yte!W1%5qLNFWqvZW>h&IiH+oPT=b@E zPhGzv5=(Un*X>v`>%8h_nj^NdYcE6NHS_ifkCV$*D)Tqrbu`s;<=t<4 zAHNqNV?6(g<1PY-w@#I-WYFViz?9TrkMr)u0g`O`u|>T;k|2sV*YF^punvT;$SuTy{j3Gv)yqD!R_CF>yR)MzmmYS5v+~R zXAdD%ng9?df;wd8GxR#%3O+gz};Vo;)sK%Bj-q>Oq%R7JU-KD?vYu>#2UjaDo z&8$>5xW~?KPD_#XFToU1hIb*VOMidUr6iYiO0N|i-7s`T8!cFT`rN!^1Pt78J93i6 z5HI1wIM$94m{3SLDvISDe6$ZG1;eq_D9RTaaC>=cO{@Bs>$IlPCPJJ$h$)-3vzNUQ6OsN#_zWxey!_9%hxwH2_dEJi=yY|1c7nDm2_Lm!Cof8-R_+9UkS zcBE(o47yE)oMR(Q=dp1a2wTX5KvvGyLqlWTa7V&!A*|w|)ax~1_~aJ0=_Lilg*0iQk7#ZD EAHN$8j{pDw literal 0 HcmV?d00001 diff --git a/media/assets/css/select2.2ca61b76e220.png b/media/assets/css/select2.2ca61b76e220.png new file mode 100644 index 0000000000000000000000000000000000000000..1d804ffb99699b9e030f1010314de0970b5a000d GIT binary patch literal 613 zcmV-r0-F7aP)#WY!I$JQV$)A5aAS1BM||2XVJl=+L1^1S1H% zM-&lx?NZpUrHhn>fk<>POqf2sh40}xxGZfc+t+#Eb(qHy9_3*1(U%t9t)QDnI#YAL(|ACV(>)>6WD-t!8tutHkdb^#3`HzoJG3A2@T`% zA|K@o*b!`R#(7)PWrMFn2))Ca3MR4(zaT`Zr61*kZK5NPnZwQszxh$fyv3?&4c>$q z2m=+yc0dRXRAsPDxF6sD;@rK4JGdR_``1S~o6Xi@2&aR6hcSrEp9HVRzEqVDqBn<1%hR=D4e1f^ra^A|34Cjc=Gny{F(o#MrvPYgZuTJOz(n)-F<| zj()qR;C={)N<0RRvDZ^@6ND+W*}gh-Lip(MDt!(zMSO)!j2j+*hxgzC-e3$@(O2p* zu;+gddm(cZwXTCLx*Ky4THOa*^b^F`woveIeCK^0aR|TJ00000NkvXXu0mjfA#WC6 literal 0 HcmV?d00001 diff --git a/media/assets/css/select2.png b/media/assets/css/select2.png new file mode 100644 index 0000000000000000000000000000000000000000..1d804ffb99699b9e030f1010314de0970b5a000d GIT binary patch literal 613 zcmV-r0-F7aP)#WY!I$JQV$)A5aAS1BM||2XVJl=+L1^1S1H% zM-&lx?NZpUrHhn>fk<>POqf2sh40}xxGZfc+t+#Eb(qHy9_3*1(U%t9t)QDnI#YAL(|ACV(>)>6WD-t!8tutHkdb^#3`HzoJG3A2@T`% zA|K@o*b!`R#(7)PWrMFn2))Ca3MR4(zaT`Zr61*kZK5NPnZwQszxh$fyv3?&4c>$q z2m=+yc0dRXRAsPDxF6sD;@rK4JGdR_``1S~o6Xi@2&aR6hcSrEp9HVRzEqVDqBn<1%hR=D4e1f^ra^A|34Cjc=Gny{F(o#MrvPYgZuTJOz(n)-F<| zj()qR;C={)N<0RRvDZ^@6ND+W*}gh-Lip(MDt!(zMSO)!j2j+*hxgzC-e3$@(O2p* zu;+gddm(cZwXTCLx*Ky4THOa*^b^F`woveIeCK^0aR|TJ00000NkvXXu0mjfA#WC6 literal 0 HcmV?d00001 diff --git a/media/assets/css/select2x2.49e3f0060186.png b/media/assets/css/select2x2.49e3f0060186.png new file mode 100644 index 0000000000000000000000000000000000000000..4bdd5c961d452c49dfa0789c2c7ffb82c238fc24 GIT binary patch literal 845 zcmV-T1G4;yP)upQ6WKflyv?C|ADVW!U!t`EpA+x zB)5#EjWk-_X77YJZtQo`E0SF)^1bZr%)B7Cd`*OK*r z5WG-7e-R9G9^69ksDt29&oyHqxPSt|-S>xi3%PTd+GjY+BGF|nWC(7D-sd(kxqd9~ zS@2YF5vB+>dP8+$l^{oO3-lEWiGA*QIU)Wds#9M6RZ9N zcQ4y4)xqQOxD=vwu%7cz1nY#$lT&y8HCmkWgpwQP#3dhnYj9|2aS_R}IUF_^6s#$= zTm%~>A#oM?KIg$kh=<`gJkeoHa2LrulVy$Yx+N_0R3$4I!R*0677f(FKqm`2_o4~W z0h}fQZ`lC^1A+m;fM7uI(R1`S0KtG@KrkQ}5DW+&@cTnDVIow56KciMk7a899t0bC zC1KI{TsMe5NAR%GD_5`B-@ad4k~K3SO%H z_M31|`HV?E6)u$E3c&*<*n20+V@mRCop>R5;DWuZCmjSo7p@R&OYl^@GupQ6WKflyv?C|ADVW!U!t`EpA+x zB)5#EjWk-_X77YJZtQo`E0SF)^1bZr%)B7Cd`*OK*r z5WG-7e-R9G9^69ksDt29&oyHqxPSt|-S>xi3%PTd+GjY+BGF|nWC(7D-sd(kxqd9~ zS@2YF5vB+>dP8+$l^{oO3-lEWiGA*QIU)Wds#9M6RZ9N zcQ4y4)xqQOxD=vwu%7cz1nY#$lT&y8HCmkWgpwQP#3dhnYj9|2aS_R}IUF_^6s#$= zTm%~>A#oM?KIg$kh=<`gJkeoHa2LrulVy$Yx+N_0R3$4I!R*0677f(FKqm`2_o4~W z0h}fQZ`lC^1A+m;fM7uI(R1`S0KtG@KrkQ}5DW+&@cTnDVIow56KciMk7a899t0bC zC1KI{TsMe5NAR%GD_5`B-@ad4k~K3SO%H z_M31|`HV?E6)u$E3c&*<*n20+V@mRCop>R5;DWuZCmjSo7p@R&OYl^@G 0) { + this.topGroupNavView = new GroupNavView(); + } + }, + + switchCurrentView: function(newView) { + if (this.currentView != newView) { + this.currentView.hide(); + this.currentView = newView; + } + }, + + showMyRepos: function() { + this.switchCurrentView(this.myHomeView); + this.myHomeView.showMyRepos(); + }, + + showMySubRepos: function() { + this.switchCurrentView(this.myHomeView); + this.myHomeView.showMySubRepos(); + }, + + showSharedRepos: function() { + this.switchCurrentView(this.myHomeView); + this.myHomeView.showSharedRepos(); + }, + + showMyRepoDir: function(repo_id, path) { + if (path) { + path = '/' + path; + } else { + path = '/'; + } + this.switchCurrentView(this.myHomeView); + this.myHomeView.showDir('my-libs', repo_id, path); + }, + + showCommonDir: function(repo_id, path) { + if (path) { + path = '/' + path; + } else { + path = '/'; + } + this.switchCurrentView(this.myHomeView); + this.myHomeView.showDir('common', repo_id, path); + }, + + showMySubRepoDir: function(repo_id, path) { + if (path) { + path = '/' + path; + } else { + path = '/'; + } + this.switchCurrentView(this.myHomeView); + this.myHomeView.showDir('my-sub-libs', repo_id, path); + }, + + showSharedRepoDir: function(repo_id, path) { + if (path) { + path = '/' + path; + } else { + path = '/'; + } + this.switchCurrentView(this.myHomeView); + this.myHomeView.showDir('shared-libs', repo_id, path); + }, + + showGroupRepos: function(group_id) { + this.switchCurrentView(this.groupView); + this.groupView.showRepoList(group_id); + }, + + showGroupRepoDir: function(group_id, repo_id, path) { + if (path) { + path = '/' + path; + } else { + path = '/'; + } + this.switchCurrentView(this.groupView); + this.groupView.showDir(group_id, repo_id, path); + }, + + showOrgRepos: function() { + this.switchCurrentView(this.orgView); + this.orgView.showRepoList(); + }, + + showOrgRepoDir: function(repo_id, path) { + if (path) { + path = '/' + path; + } else { + path = '/'; + } + this.switchCurrentView(this.orgView); + this.orgView.showDir(repo_id, path); + }, + + defaultAction: function(actions) { + // We have no matching route, lets just log what the URL was + + this.switchCurrentView(this.myHomeView); + this.myHomeView.showMyRepos(); + } + }); + + return Router; +}); diff --git a/media/assets/scripts/app/router.js b/media/assets/scripts/app/router.js new file mode 100644 index 0000000000..55617bbba8 --- /dev/null +++ b/media/assets/scripts/app/router.js @@ -0,0 +1,154 @@ +/*global define*/ +define([ + 'jquery', + 'backbone', + 'common', + 'app/views/myhome', + 'app/views/group', + 'app/views/organization', + 'app/views/dir', + 'app/views/top-group-nav' +], function($, Backbone, Common, MyHomeView, GroupView, OrgView, + DirView, GroupNavView) { + "use strict"; + + var Router = Backbone.Router.extend({ + routes: { + '': 'showMyRepos', + 'my-libs/': 'showMyRepos', + 'my-libs/lib/:repo_id(/*path)': 'showMyRepoDir', + 'my-sub-libs/': 'showMySubRepos', + 'my-sub-libs/lib/:repo_id(/*path)': 'showMySubRepoDir', + 'shared-libs/': 'showSharedRepos', + 'shared-libs/lib/:repo_id(/*path)': 'showSharedRepoDir', + 'group/:group_id/': 'showGroupRepos', + 'group/:group_id/lib/:repo_id(/*path)': 'showGroupRepoDir', + 'org/': 'showOrgRepos', + 'org/lib/:repo_id(/*path)': 'showOrgRepoDir', + + 'common/lib/:repo_id(/*path)': 'showCommonDir', + // Default + '*actions': 'defaultAction' + }, + + initialize: function() { + Common.prepareApiCsrf(); + Common.initAccountPopup(); + Common.initNoticePopup(); + Common.getContacts(); + + this.dirView = new DirView(); + + this.myHomeView = new MyHomeView({dirView: this.dirView}); + this.groupView = new GroupView({dirView: this.dirView}); + this.orgView = new OrgView({dirView: this.dirView}); + + this.currentView = this.myHomeView; + + if (app.pageOptions.top_nav_groups.length > 0) { + this.topGroupNavView = new GroupNavView(); + } + }, + + switchCurrentView: function(newView) { + if (this.currentView != newView) { + this.currentView.hide(); + this.currentView = newView; + } + }, + + showMyRepos: function() { + this.switchCurrentView(this.myHomeView); + this.myHomeView.showMyRepos(); + }, + + showMySubRepos: function() { + this.switchCurrentView(this.myHomeView); + this.myHomeView.showMySubRepos(); + }, + + showSharedRepos: function() { + this.switchCurrentView(this.myHomeView); + this.myHomeView.showSharedRepos(); + }, + + showMyRepoDir: function(repo_id, path) { + if (path) { + path = '/' + path; + } else { + path = '/'; + } + this.switchCurrentView(this.myHomeView); + this.myHomeView.showDir('my-libs', repo_id, path); + }, + + showCommonDir: function(repo_id, path) { + if (path) { + path = '/' + path; + } else { + path = '/'; + } + this.switchCurrentView(this.myHomeView); + this.myHomeView.showDir('common', repo_id, path); + }, + + showMySubRepoDir: function(repo_id, path) { + if (path) { + path = '/' + path; + } else { + path = '/'; + } + this.switchCurrentView(this.myHomeView); + this.myHomeView.showDir('my-sub-libs', repo_id, path); + }, + + showSharedRepoDir: function(repo_id, path) { + if (path) { + path = '/' + path; + } else { + path = '/'; + } + this.switchCurrentView(this.myHomeView); + this.myHomeView.showDir('shared-libs', repo_id, path); + }, + + showGroupRepos: function(group_id) { + this.switchCurrentView(this.groupView); + this.groupView.showRepoList(group_id); + }, + + showGroupRepoDir: function(group_id, repo_id, path) { + if (path) { + path = '/' + path; + } else { + path = '/'; + } + this.switchCurrentView(this.groupView); + this.groupView.showDir(group_id, repo_id, path); + }, + + showOrgRepos: function() { + this.switchCurrentView(this.orgView); + this.orgView.showRepoList(); + }, + + showOrgRepoDir: function(repo_id, path) { + if (path) { + path = '/' + path; + } else { + path = '/'; + } + this.switchCurrentView(this.orgView); + this.orgView.showDir(repo_id, path); + }, + + defaultAction: function(actions) { + // We have no matching route, lets just log what the URL was + + this.switchCurrentView(this.myHomeView); + this.myHomeView.showMyRepos(); + } + }); + + return Router; +}); diff --git a/media/assets/scripts/app/views/add-group-repo.1b73df633a61.js b/media/assets/scripts/app/views/add-group-repo.1b73df633a61.js new file mode 100644 index 0000000000..2cb6664325 --- /dev/null +++ b/media/assets/scripts/app/views/add-group-repo.1b73df633a61.js @@ -0,0 +1,27 @@ +define([ + 'jquery', + 'simplemodal', + 'underscore', + 'backbone', + 'common', + 'app/views/add-repo' +], function($, simplemodal, _, Backbone, Common, AddRepoView) { + 'use strict'; + + var AddGroupRepoView = AddRepoView.extend({ + templateData: function() { + return { + showSharePerm: true + }; + }, + + newAttributes: function() { + var baseAttrs = AddRepoView.prototype.newAttributes.apply(this); + + return _.extend(baseAttrs, {'permission': $('select[name=permission]', this.$el).val()}); + }, + + }); + + return AddGroupRepoView; +}); diff --git a/media/assets/scripts/app/views/add-group-repo.js b/media/assets/scripts/app/views/add-group-repo.js new file mode 100644 index 0000000000..2cb6664325 --- /dev/null +++ b/media/assets/scripts/app/views/add-group-repo.js @@ -0,0 +1,27 @@ +define([ + 'jquery', + 'simplemodal', + 'underscore', + 'backbone', + 'common', + 'app/views/add-repo' +], function($, simplemodal, _, Backbone, Common, AddRepoView) { + 'use strict'; + + var AddGroupRepoView = AddRepoView.extend({ + templateData: function() { + return { + showSharePerm: true + }; + }, + + newAttributes: function() { + var baseAttrs = AddRepoView.prototype.newAttributes.apply(this); + + return _.extend(baseAttrs, {'permission': $('select[name=permission]', this.$el).val()}); + }, + + }); + + return AddGroupRepoView; +}); diff --git a/media/assets/scripts/app/views/add-pub-repo.31eb194e78d8.js b/media/assets/scripts/app/views/add-pub-repo.31eb194e78d8.js new file mode 100644 index 0000000000..8108af011c --- /dev/null +++ b/media/assets/scripts/app/views/add-pub-repo.31eb194e78d8.js @@ -0,0 +1,27 @@ +define([ + 'jquery', + 'simplemodal', + 'underscore', + 'backbone', + 'common', + 'app/views/add-repo' +], function($, simplemodal, _, Backbone, Common, AddRepoView) { + 'use strict'; + + var AddPubRepoView = AddRepoView.extend({ + templateData: function() { + return { + showSharePerm: true + }; + }, + + newAttributes: function() { + var baseAttrs = AddRepoView.prototype.newAttributes.apply(this); + + return _.extend(baseAttrs, {'permission': $('select[name=permission]', this.$el).val()}); + }, + + }); + + return AddPubRepoView; +}); diff --git a/media/assets/scripts/app/views/add-pub-repo.js b/media/assets/scripts/app/views/add-pub-repo.js new file mode 100644 index 0000000000..8108af011c --- /dev/null +++ b/media/assets/scripts/app/views/add-pub-repo.js @@ -0,0 +1,27 @@ +define([ + 'jquery', + 'simplemodal', + 'underscore', + 'backbone', + 'common', + 'app/views/add-repo' +], function($, simplemodal, _, Backbone, Common, AddRepoView) { + 'use strict'; + + var AddPubRepoView = AddRepoView.extend({ + templateData: function() { + return { + showSharePerm: true + }; + }, + + newAttributes: function() { + var baseAttrs = AddRepoView.prototype.newAttributes.apply(this); + + return _.extend(baseAttrs, {'permission': $('select[name=permission]', this.$el).val()}); + }, + + }); + + return AddPubRepoView; +}); diff --git a/media/assets/scripts/app/views/add-repo.14400988204f.js b/media/assets/scripts/app/views/add-repo.14400988204f.js new file mode 100644 index 0000000000..44993dbe3c --- /dev/null +++ b/media/assets/scripts/app/views/add-repo.14400988204f.js @@ -0,0 +1,96 @@ +define([ + 'jquery', + 'simplemodal', + 'underscore', + 'backbone', + 'common' +], function($, simplemodal, _, Backbone, Common) { + 'use strict'; + + var AddRepoView = Backbone.View.extend({ + + tagName: 'div', + + template: _.template($('#create-repo-tmpl').html()), + + initialize: function(repos) { + this.repos = repos; + + this.render(); + this.$el.modal(); + $("#simplemodal-container").css({'height':'auto'}); + + this.listenTo(repos, 'invalid', this.displayValidationErrors); + }, + + render: function() { + this.$el.html(this.template(this.templateData())); + return this; + }, + + templateData: function() { + return { + showSharePerm: false + }; + }, + + events: { + "submit": "addRepo", + "click #encrypt-switch": "togglePasswdInput" + }, + + // Generate the attributes for a new GroupRepo item. + newAttributes: function() { + return { + name: $('input[name=repo_name]', this.$el).val().trim(), + encrypted: $('#encrypt-switch', this.$el).parent().hasClass('checkbox-checked'), + passwd1: $('input[name=passwd]', this.$el).val(), + passwd2: $('input[name=passwd_again]', this.$el).val(), + passwd: $('input[name=passwd]', this.$el).val() + }; + }, + + // TODO: move to common + displayValidationErrors: function(model, error, options) { + this.$('.error').html(error).show(); + }, + + addRepo: function(e) { + e.preventDefault(); + + var repos = this.repos; + repos.create(this.newAttributes(), { + wait: true, + validate: true, + prepend: true, // show newly created repo at first line + success: function() { + if (repos.length == 1) { + repos.fetch({reset: true}); + } + }, + error: function(xhr, textStatus, errorThrown) { + // TODO: handle error gracefully + Common.feedback('Error', 'error', Common.ERROR_TIMEOUT); + }, + complete: function() { + Common.closeModal(); + } + }); + }, + + togglePasswdInput: function(e) { + var $parent = $(e.target).parent(); + $parent.toggleClass('checkbox-checked'); + + var pwd_input = $('input[type="password"]', $('.repo-create-encryption')); + if ($parent.hasClass('checkbox-checked')) { + pwd_input.attr('disabled', false).removeClass('input-disabled'); + } else { + pwd_input.attr('disabled', true).addClass('input-disabled'); + } + } + + }); + + return AddRepoView; +}); diff --git a/media/assets/scripts/app/views/add-repo.js b/media/assets/scripts/app/views/add-repo.js new file mode 100644 index 0000000000..44993dbe3c --- /dev/null +++ b/media/assets/scripts/app/views/add-repo.js @@ -0,0 +1,96 @@ +define([ + 'jquery', + 'simplemodal', + 'underscore', + 'backbone', + 'common' +], function($, simplemodal, _, Backbone, Common) { + 'use strict'; + + var AddRepoView = Backbone.View.extend({ + + tagName: 'div', + + template: _.template($('#create-repo-tmpl').html()), + + initialize: function(repos) { + this.repos = repos; + + this.render(); + this.$el.modal(); + $("#simplemodal-container").css({'height':'auto'}); + + this.listenTo(repos, 'invalid', this.displayValidationErrors); + }, + + render: function() { + this.$el.html(this.template(this.templateData())); + return this; + }, + + templateData: function() { + return { + showSharePerm: false + }; + }, + + events: { + "submit": "addRepo", + "click #encrypt-switch": "togglePasswdInput" + }, + + // Generate the attributes for a new GroupRepo item. + newAttributes: function() { + return { + name: $('input[name=repo_name]', this.$el).val().trim(), + encrypted: $('#encrypt-switch', this.$el).parent().hasClass('checkbox-checked'), + passwd1: $('input[name=passwd]', this.$el).val(), + passwd2: $('input[name=passwd_again]', this.$el).val(), + passwd: $('input[name=passwd]', this.$el).val() + }; + }, + + // TODO: move to common + displayValidationErrors: function(model, error, options) { + this.$('.error').html(error).show(); + }, + + addRepo: function(e) { + e.preventDefault(); + + var repos = this.repos; + repos.create(this.newAttributes(), { + wait: true, + validate: true, + prepend: true, // show newly created repo at first line + success: function() { + if (repos.length == 1) { + repos.fetch({reset: true}); + } + }, + error: function(xhr, textStatus, errorThrown) { + // TODO: handle error gracefully + Common.feedback('Error', 'error', Common.ERROR_TIMEOUT); + }, + complete: function() { + Common.closeModal(); + } + }); + }, + + togglePasswdInput: function(e) { + var $parent = $(e.target).parent(); + $parent.toggleClass('checkbox-checked'); + + var pwd_input = $('input[type="password"]', $('.repo-create-encryption')); + if ($parent.hasClass('checkbox-checked')) { + pwd_input.attr('disabled', false).removeClass('input-disabled'); + } else { + pwd_input.attr('disabled', true).addClass('input-disabled'); + } + } + + }); + + return AddRepoView; +}); diff --git a/media/assets/scripts/app/views/dir.128cc156b122.js b/media/assets/scripts/app/views/dir.128cc156b122.js new file mode 100644 index 0000000000..5b981ed092 --- /dev/null +++ b/media/assets/scripts/app/views/dir.128cc156b122.js @@ -0,0 +1,875 @@ +define([ + 'jquery', + 'jquery.ui.progressbar', + 'jquery.magnific-popup', + 'simplemodal', + 'underscore', + 'backbone', + 'common', + 'file-tree', + 'app/collections/dirents', + 'app/views/dirent', + 'app/views/fileupload', + 'app/views/share' + ], function($, progressbar, magnificPopup, simplemodal, _, Backbone, Common, + FileTree, DirentCollection, DirentView, FileUploadView, ShareView) { + 'use strict'; + + var DirView = Backbone.View.extend({ + el: $('#dir-view'), + + path_bar_template: _.template($('#path-bar-tmpl').html()), + dir_op_bar_template: _.template($('#dir-op-bar-tmpl').html()), + newDirTemplate: _.template($("#add-new-dir-form-template").html()), + newFileTemplate: _.template($("#add-new-file-form-template").html()), + mvcpTemplate: _.template($("#mvcp-form-template").html()), + mvProgressTemplate: _.template($("#mv-progress-popup-template").html()), + + initialize: function(options) { + this.$dirent_list = this.$('.repo-file-list tbody'); + this.$path_bar = this.$('.path'); + // For compatible with css, we use .repo-op instead of .dir-op + this.$dir_op_bar = this.$('.repo-op'); + + this.dir = new DirentCollection(); + this.listenTo(this.dir, 'add', this.addOne); + this.listenTo(this.dir, 'reset', this.reset); + + this.fileUploadView = new FileUploadView({dirView: this}); + + this.$el.magnificPopup({ + type: 'image', + delegate: '.img-name-link', + tClose: gettext("Close (Esc)"), // Alt text on close button + tLoading: gettext("Loading..."), // Text that is displayed during loading. Can contain %curr% and %total% keys + gallery: { + enabled: true, + tPrev: gettext("Previous (Left arrow key)"), // Alt text on left arrow + tNext: gettext("Next (Right arrow key)"), // Alt text on right arrow + tCounter: gettext("%curr% of %total%") // Markup for "1 of 7" counter + }, + image: { + titleSrc: function(item) { + var el = item.el; + var img_name = el[0].innerHTML; + var img_link = '' + gettext("Open in New Tab") + ''; + return img_name + '
' + img_link; + }, + tError: gettext('The image could not be loaded.') // Error message when image could not be loaded + } + }); + + // initialize common js behavior + this.$('th .checkbox-orig').unbind(); + + // get 'more' + var _this = this; + $(window).scroll(function() { + if ($(_this.el).is(':visible')) { + _this.onWindowScroll(); + } + }); + + // hide 'hidden-op' popup + app.globalState.noFileOpPopup = true; + $(document).click(function(e) { + var target = e.target || event.srcElement; + var popup = $('.hidden-op'); + if (!app.globalState.noFileOpPopup && + !$('.more-op-icon, .hidden-op').is(target) && + !popup.find('*').is(target)) { + popup.addClass('hide'); + app.globalState.noFileOpPopup = true; + if (!app.globalState.popup_tr.find('*').is(target)) { + app.globalState.popup_tr.removeClass('hl').find('.repo-file-op').addClass('vh'); // clicked place: the first tr, place out of the table + $('.repo-file-list tr:gt(0)').each(function() { // when other tr is clicked + if ($(this).find('*').is(target)) { + $(this).addClass('hl').find('.repo-file-op').removeClass('vh'); + } + }); + } + } + }); + }, + + showDir: function(category, repo_id, path) { + this.$el.show(); + this.$dirent_list.empty(); + var loading_tip = this.$('.loading-tip').show(); + var dir = this.dir; + dir.setPath(category, repo_id, path); + var _this = this; + dir.fetch({ + reset: true, + data: {'p': path}, + success: function (collection, response, opts) { + dir.last_start = 0; // for 'more' + if (response.dirent_list.length == 0 || // the dir is empty + !response.dirent_more ) { // no 'more' + loading_tip.hide(); + } + }, + error: function (collection, response, opts) { + loading_tip.hide(); + var $el_con = _this.$('.repo-file-list-topbar, .repo-file-list').hide(); + var $error = _this.$('.error'); + var err_msg; + var decrypt_lib = false; + if (response.responseText) { + if (response.responseJSON.lib_need_decrypt) { + decrypt_lib = true; + } else { + err_msg = response.responseJSON.error; + } + } else { + err_msg = gettext('Please check the network.'); + } + if (err_msg) { + $error.html(err_msg).show(); + } + + if (decrypt_lib) { + var form = $($('#repo-decrypt-form-template').html()); + form.modal({containerCss: {'padding': '1px'}}); + $('#simplemodal-container').css({'height':'auto'}); + form.submit(function() { + var passwd = $.trim($('[name="password"]', form).val()); + if (!passwd) { + $('.error', form).html(gettext("Password is required.")).removeClass('hide'); + return false; + } + Common.ajaxPost({ + form: form, + form_id: form.attr('id'), + post_url: Common.getUrl({'name':'repo_set_password'}), + post_data: { + repo_id: repo_id, + password: passwd, + username: app.pageOptions.username + }, + after_op_success: function() { + $.modal.close(); + $el_con.show(); + _this.showDir(category, repo_id, path); + } + }); + return false; + }); + } + } + }); + }, + + hide: function() { + this.$el.hide(); + }, + + addOne: function(dirent) { + var view = new DirentView({model: dirent, dirView: this}); + this.$dirent_list.append(view.render().el); + }, + + reset: function() { + this.dir.each(this.addOne, this); + this.renderPath(); + this.renderDirOpBar(); + this.fileUploadView.setFileInput(); + this.getImageThumbnail(); + }, + + getImageThumbnail: function() { + var images_with_no_thumbnail = this.dir.filter(function(dirent) { + // 'dirent' is a model + return dirent.get('is_img') && !dirent.get('thumbnail_src'); + }); + if (images_with_no_thumbnail.length == 0) { + return ; + } + + var images_len = images_with_no_thumbnail.length, + repo_id = this.dir.repo_id, + cur_path = this.dir.path, + _this = this; + var get_thumbnail = function(i) { + var cur_img = images_with_no_thumbnail[i]; + var cur_img_path = Common.pathJoin([cur_path, cur_img.get('obj_name')]); + $.ajax({ + url: Common.getUrl({name: 'thumbnail_create', repo_id: repo_id}), + data: {'path': cur_img_path}, + cache: false, + dataType: 'json', + success: function(data) { + cur_img.set({ + 'thumbnail_src': data.thumbnail_src + }); + }, + complete: function() { + // cur path may be changed. e.g., the user enter another directory + if (i < images_len - 1 && + _this.dir.repo_id == repo_id && + _this.dir.path == cur_path) { + get_thumbnail(++i); + } + } + }); + }; + get_thumbnail(0); + }, + + renderPath: function() { + var dir = this.dir; + var path = dir.path; + var context = 'my'; + + var category_start = dir.category.split('/')[0]; + if (category_start == 'org') { + context = 'org'; + } else if (category_start == 'group') { + context = 'group'; + } else if (category_start == 'common') { + context = 'common'; + } + var obj = { + path: path, + repo_name: dir.repo_name, + category: dir.category, + context: context + }; + + var path_list = path.substr(1).split('/'); + var path_list_encoded = path_list.map(function(e) { return encodeURIComponent(e); }); + if (path != '/') { + $.extend(obj, { + path_list: path_list, + path_list_encoded: path_list_encoded, + repo_id: dir.repo_id + }); + } + + this.$path_bar.html(this.path_bar_template(obj)); + }, + + renderDirOpBar: function() { + var dir = this.dir, + user_perm = dir.user_perm; + + this.$dir_op_bar.html($.trim(this.dir_op_bar_template({ + user_perm: user_perm, + encrypted: dir.encrypted, + path: dir.path, + repo_id: dir.repo_id, + site_root: app.pageOptions.site_root, + is_repo_owner: dir.is_repo_owner, + enable_upload_folder: app.pageOptions.enable_upload_folder + }))); + }, + + // Directory Operations + events: { + 'click .path-link': 'visitDir', + 'click #upload-file': 'uploadFile', + 'click #add-new-dir': 'newDir', + 'click #add-new-file': 'newFile', + 'click #share-cur-dir': 'share', + 'click th.select': 'select', + 'click #mv-dirents': 'mv', + 'click #cp-dirents': 'cp', + 'click #del-dirents': 'del', + 'click #by-name': 'sortByName', + 'click #by-time': 'sortByTime' + }, + + newDir: function() { + var form = $(this.newDirTemplate()), + form_id = form.attr('id'), + dir = this.dir, + dirView = this; + + form.modal({appendTo:'#main'}); + $('#simplemodal-container').css({'height':'auto'}); + + form.submit(function() { + var dirent_name = $.trim($('input[name="name"]', form).val()); + + if (!dirent_name) { + Common.showFormError(form_id, gettext("It is required.")); + return false; + }; + + var post_data = {'dirent_name': dirent_name}, + post_url = Common.getUrl({name: "new_dir", repo_id: dir.repo_id}) + + '?parent_dir=' + encodeURIComponent(dir.path); + var after_op_success = function(data) { + $.modal.close(); + + var new_dirent = dir.add({ + 'is_dir': true, + 'obj_name': data['name'], + 'last_modified': new Date().getTime() / 1000, + 'last_update': gettext("Just now"), + 'p_dpath': data['p_dpath'] + }, {silent:true}); + dirView.addNewDir(new_dirent); + }; + + Common.ajaxPost({ + 'form': form, + 'post_url': post_url, + 'post_data': post_data, + 'after_op_success': after_op_success, + 'form_id': form_id + }); + + return false; + }); + }, + + newFile: function() { + var form = $(this.newFileTemplate()), + form_id = form.attr('id'), + file_name = form.find('input[name="name"]'), + dir = this.dir, + dirView = this; + + form.modal({ + appendTo: '#main', + focus: false, + containerCss: {'padding':'20px 25px'} + }); + $('#simplemodal-container').css({'height':'auto'}); + + $('.set-file-type', form).click(function() { + file_name.val('.' + $(this).data('filetype')); + Common.setCaretPos(file_name[0], 0); + file_name.focus(); + }); + + form.submit(function() { + var dirent_name = $.trim(file_name.val()); + + if (!dirent_name) { + Common.showFormError(form_id, gettext("It is required.")); + return false; + }; + + // if it has an extension, make sure it has a name + if (dirent_name.lastIndexOf('.') != -1 && dirent_name.substr(0, dirent_name.lastIndexOf('.')).length == 0) { + Common.showFormError(form_id, gettext("Only an extension there, please input a name.")); + return false; + } + + var post_data = {'dirent_name': dirent_name}, + post_url = Common.getUrl({name: "new_file", repo_id: dir.repo_id}) + + '?parent_dir=' + encodeURIComponent(dir.path); + var after_op_success = function(data) { + $.modal.close(); + var new_dirent = dir.add({ + 'is_file': true, + 'is_img': Common.imageCheck(data['name']), + 'obj_name': data['name'], + 'file_size': Common.fileSizeFormat(0), + 'obj_id': '0000000000000000000000000000000000000000', + 'file_icon': 'file.png', + 'starred': false, + 'last_modified': new Date().getTime() / 1000, + 'last_update': gettext("Just now") + }, {silent: true}); + dirView.addNewFile(new_dirent); + }; + + Common.ajaxPost({ + 'form': form, + 'post_url': post_url, + 'post_data': post_data, + 'after_op_success': after_op_success, + 'form_id': form_id + }); + + return false; + }); + }, + + addNewFile: function(new_dirent) { + var dirView = this, + dir = this.dir; + var view = new DirentView({model: new_dirent, dirView: dirView}); + var new_file = view.render().el; + // put the new file as the first file + if ($('tr', dirView.$dirent_list).length == 0) { + dirView.$dirent_list.append(new_file); + } else { + var dirs = dir.where({'is_dir':true}); + if (dirs.length == 0) { + dirView.$dirent_list.prepend(new_file); + } else { + // put the new file after the last dir + $($('tr', dirView.$dirent_list)[dirs.length - 1]).after(new_file); + } + } + }, + + addNewDir: function(new_dirent) { + var dirView = this; + var view = new DirentView({model: new_dirent, dirView: dirView}); + dirView.$dirent_list.prepend(view.render().el); // put the new dir as the first one + }, + + share: function () { + var dir = this.dir; + var path = dir.path; + var options = { + 'is_repo_owner': dir.is_repo_owner, + 'is_virtual': dir.is_virtual, + 'user_perm': dir.user_perm, + 'repo_id': dir.repo_id, + 'is_dir': true, + 'dirent_path': path, + 'obj_name': path == '/' ? dir.repo_name : path.substr(path.lastIndexOf('/') + 1) + }; + new ShareView(options); + }, + + sortByName: function() { + var dirents = this.dir; + var el = $('#by-name'); + dirents.comparator = function(a, b) { + if (a.get('is_dir') && b.get('is_file')) { + return -1; + } + if (el.hasClass('icon-caret-up')) { + return a.get('obj_name').toLowerCase() < b.get('obj_name').toLowerCase() ? 1 : -1; + } else { + return a.get('obj_name').toLowerCase() < b.get('obj_name').toLowerCase() ? -1 : 1; + } + }; + dirents.sort(); + this.$dirent_list.empty(); + dirents.each(this.addOne, this); + el.toggleClass('icon-caret-up icon-caret-down'); + }, + + sortByTime: function () { + var dirents = this.dir; + var el = $('#by-time'); + dirents.comparator = function(a, b) { + if (a.get('is_dir') && b.get('is_file')) { + return -1; + } + if (el.hasClass('icon-caret-down')) { + return a.get('last_modified') < b.get('last_modified') ? 1 : -1; + } else { + return a.get('last_modified') < b.get('last_modified') ? -1 : 1; + } + }; + dirents.sort(); + this.$dirent_list.empty(); + dirents.each(this.addOne, this); + el.toggleClass('icon-caret-up icon-caret-down'); + }, + + select: function () { + var el = this.$('th .checkbox'); + el.toggleClass('checkbox-checked'); + + var dir = this.dir; + var all_dirent_checkbox = this.$('.checkbox'); + var $dirents_op = this.$('#multi-dirents-op'); + + if (el.hasClass('checkbox-checked')) { + all_dirent_checkbox.addClass('checkbox-checked'); + dir.each(function(model) { + model.set({'selected': true}, {silent: true}); + }); + $dirents_op.css({'display':'inline'}); + } else { + all_dirent_checkbox.removeClass('checkbox-checked'); + dir.each(function(model) { + model.set({'selected': false}, {silent: true}); + }); + $dirents_op.hide(); + } + }, + + del: function () { + var dirents = this.dir; + var _this = this; + + var del_dirents = function() { + $('#confirm-popup').append('

' + gettext("Processing...") + '

'); + var selected_dirents = dirents.where({'selected':true}), + selected_names = []; + $(selected_dirents).each(function() { + selected_names.push(this.get('obj_name')); + }); + $.ajax({ + url: Common.getUrl({ + name: 'del_dirents', + repo_id: dirents.repo_id + }) + '?parent_dir=' + encodeURIComponent(dirents.path), + type: 'POST', + dataType: 'json', + beforeSend: Common.prepareCSRFToken, + traditional: true, + data: { + 'dirents_names': selected_names + }, + success: function(data) { + var del_len = data['deleted'].length, + not_del_len = data['undeleted'].length, + msg_s, msg_f; + + if (del_len > 0) { + if (del_len == selected_names.length) { + dirents.remove(selected_dirents); + _this.$('th .checkbox').removeClass('checkbox-checked'); + _this.$('#multi-dirents-op').hide(); + } else { + $(selected_dirents).each(function() { + if (this.get('obj_name') in data['deleted']) { + dirents.remove(this); + } + }); + } + if (del_len == 1) { + msg_s = gettext("Successfully deleted %(name)s."); + } else if (del_len == 2) { + msg_s = gettext("Successfully deleted %(name)s and 1 other item."); + } else { + msg_s = gettext("Successfully deleted %(name)s and %(amount)s other items."); + } + msg_s = msg_s.replace('%(name)s', Common.HTMLescape(data['deleted'][0])).replace('%(amount)s', del_len - 1); + Common.feedback(msg_s, 'success'); + } + if (not_del_len > 0) { + if (not_del_len == 1) { + msg_f = gettext("Internal error. Failed to delete %(name)s."); + } else if (not_del_len == 2) { + msg_f = gettext("Internal error. Failed to delete %(name)s and 1 other item."); + } else { + msg_f = gettext("Internal error. Failed to delete %(name)s and %(amount)s other items."); + } + msg_f = msg_f.replace('%(name)s', Common.HTMLescape(data['undeleted'][0])).replace('%(amount)s', not_del_len - 1); + Common.feedback(msg_f, 'error'); + } + $.modal.close(); + }, + error: function(xhr, textStatus, errorThrown) { + $.modal.close(); + Common.ajaxErrorHandler(xhr, textStatus, errorThrown); + } + }); + }; + Common.showConfirm(gettext("Delete Items"), + gettext("Are you sure you want to delete these selected items?"), + del_dirents); + }, + + mv: function () { + this.mvcp({'op':'mv'}); + }, + cp: function () { + this.mvcp({'op':'cp'}); + }, + mvcp: function (params) { + var dir = this.dir; + var op = params.op; + + var title = op == 'mv' ? "Move selected item(s) to:" : "Copy selected item(s) to:"; + + var form = $(this.mvcpTemplate({ + form_title: title, + op_type: op, + obj_type: '', + obj_name: '', + show_other_repos: !dir.encrypted, + })); + form.modal({appendTo:'#main', autoResize:true, focus:false}); + $('#simplemodal-container').css({'width':'auto', 'height':'auto'}); + + FileTree.renderTreeForPath({ + repo_name: dir.repo_name, + repo_id: dir.repo_id, + path: dir.path + }); + if (!dir.encrypted) { + FileTree.prepareOtherReposTree({cur_repo_id: dir.repo_id}); + } + + var _this = this; + var dirents = this.dir; + // get models + var dirs = dirents.where({'is_dir':true, 'selected':true}), + files = dirents.where({'is_file':true, 'selected':true}); + var dir_names = [], file_names = []; + $(dirs).each(function() { + dir_names.push(this.get('obj_name')); + }); + $(files).each(function() { + file_names.push(this.get('obj_name')); + }); + form.submit(function() { + var dst_repo = $('[name="dst_repo"]', form).val(), + dst_path = $('[name="dst_path"]', form).val(), + url_main; + var cur_path = dirents.path; + var url_obj = {repo_id:dirents.repo_id}; + + if (!$.trim(dst_repo) || !$.trim(dst_path)) { + $('.error', form).removeClass('hide'); + return false; + } + if (dst_repo == dirents.repo_id && dst_path == cur_path) { + $('.error', form).html(gettext("Invalid destination path")).removeClass('hide'); + return false; + } + + Common.disableButton($('[type="submit"]', form)); + form.append('

' + gettext("Processing...") + '

'); + + if (dst_repo == dirents.repo_id) { + // when mv/cp in current lib, files/dirs can be handled in batch, and no need to show progress + url_obj.name = op == 'mv' ? 'mv_dirents' : 'cp_dirents'; + $.ajax({ + url: Common.getUrl(url_obj) + '?parent_dir=' + encodeURIComponent(cur_path), + type: 'POST', + dataType: 'json', + beforeSend: Common.prepareCSRFToken, + traditional: true, + data: { + 'file_names': file_names, + 'dir_names': dir_names, + 'dst_repo': dst_repo, + 'dst_path': dst_path + }, + success: function(data) { + var success_len = data['success'].length, + msg_s, msg_f, + view_url = data['url']; + + $.modal.close(); + if (success_len > 0) { + if (op == 'mv') { + if (success_len == files.length + dirs.length) { + dirents.remove(dirs); + dirents.remove(files); + _this.$('th .checkbox').removeClass('checkbox-checked'); + _this.$('#multi-dirents-op').hide(); + } else { + $(dirs).each(function() { + if (this.get('obj_name') in data['success']) { + dirents.remove(this); + } + }); + $(files).each(function() { + if (this.get('obj_name') in data['success']) { + dirents.remove(this); + } + }); + } + if (success_len == 1) { + msg_s = gettext("Successfully moved %(name)s."); + } else if (success_len == 2) { + msg_s = gettext("Successfully moved %(name)s and 1 other item."); + } else { + msg_s = gettext("Successfully moved %(name)s and %(amount)s other items."); + } + } else { // cp + if (success_len == 1) { + msg_s = gettext("Successfully copied %(name)s."); + } else if (success_len == 2) { + msg_s = gettext("Successfully copied %(name)s and 1 other item."); + } else { + msg_s = gettext("Successfully copied %(name)s and %(amount)s other items."); + } + } + + msg_s = msg_s.replace('%(name)s', Common.HTMLescape(data['success'][0])).replace('%(amount)s', success_len - 1); + //msg_s += ' ' + "View" + ''; + Common.feedback(msg_s, 'success'); + } + + if (data['failed'].length > 0) { + if (op == 'mv') { + if (data['failed'].length > 1) { + msg_f = gettext("Internal error. Failed to move %(name)s and %(amount)s other item(s)."); + } else { + msg_f = gettext("Internal error. Failed to move %(name)s."); + } + } else { + if (data['failed'].length > 1) { + msg_f = gettext("Internal error. Failed to copy %(name)s and %(amount)s other item(s)."); + } else { + msg_f = gettext("Internal error. Failed to copy %(name)s."); + } + } + msg_f = msg_f.replace('%(name)s', Common.HTMLescape(data['failed'][0])).replace('%(amount)s', data['failed'].length - 1); + Common.feedback(msg_f, 'error'); + } + }, + error: function(xhr, textStatus, errorThrown) { + $.modal.close(); + Common.ajaxErrorHandler(xhr, textStatus, errorThrown); + } + }); + } else { + // when mv/cp to another lib, files/dirs should be handled one by one, and need to show progress + var op_objs = dirents.where({'selected':true}), + i = 0; + // progress popup + var mv_progress_popup = $(_this.mvProgressTemplate()); + var details = $('#mv-details', mv_progress_popup), + cancel_btn = $('#cancel-mv', mv_progress_popup), + other_info = $('#mv-other-info', mv_progress_popup); + + var mvcpDirent = function () { + var op_obj = op_objs[i], + obj_type = op_obj.get('is_dir') ? 'dir':'file', + obj_name = op_obj.get('obj_name'), + post_url, + post_data; + + if (op == 'mv') { + url_obj.name = obj_type == 'dir' ? 'mv_dir' : 'mv_file'; + } else { + url_obj.name = obj_type == 'dir' ? 'cp_dir' : 'cp_file'; + } + post_url = Common.getUrl(url_obj) + '?path=' + encodeURIComponent(cur_path) + '&obj_name=' + encodeURIComponent(obj_name); + post_data = { + 'dst_repo': dst_repo, + 'dst_path': dst_path + }; + var after_op_success = function (data) { + var det_text = op == 'mv' ? gettext("Moving file %(index)s of %(total)s") : gettext("Copying file %(index)s of %(total)s"); + details.html(det_text.replace('%(index)s', i + 1).replace('%(total)s', op_objs.length)).removeClass('vh'); + cancel_btn.removeClass('hide'); + var req_progress = function () { + var task_id = data['task_id']; + cancel_btn.data('task_id', task_id); + $.ajax({ + url: Common.getUrl({name:'get_cp_progress'}) + '?task_id=' + encodeURIComponent(task_id), + dataType: 'json', + success: function(data) { + var bar = $('.ui-progressbar-value', $('#mv-progress')); + if (!data['failed'] && !data['canceled'] && !data['successful']) { + setTimeout(req_progress, 1000); + } else { + if (data['successful']) { + bar.css('width', parseInt((i + 1)/op_objs.length*100, 10) + '%').show(); + if (op == 'mv') { + dirents.remove(op_obj); + } + endOrContinue(); + } else { // failed or canceled + if (data['failed']) { + var error_msg = op == 'mv' ? gettext('Failed to move %(name)s') : gettext('Failed to copy %(name)s'); + cancel_btn.after('

' + error_msg.replace('%(name)s', Common.HTMLescape(obj_name)) + '

'); + end(); + } + } + } + }, + error: function(xhr, textStatus, errorThrown) { + var error; + if (xhr.responseText) { + error = $.parseJSON(xhr.responseText).error; + } else { + error = gettext("Failed. Please check the network."); + } + cancel_btn.after('

' + error + '

'); + end(); + } + }); + }; // 'req_progress' ends + if (i == 0) { + $.modal.close(); + setTimeout(function () { + mv_progress_popup.modal({containerCss: { + width: 300, + height: 150, + paddingTop: 50 + }, focus:false}); + $('#mv-progress').progressbar(); + req_progress(); + }, 100); + } else { + req_progress(); + } + }; // 'after_op_success' ends + Common.ajaxPost({ + 'form': form, + 'post_url': post_url, + 'post_data': post_data, + 'after_op_success': after_op_success, + 'form_id': form.attr('id') + }); + }; // 'mvcpDirent' ends + var endOrContinue = function () { + if (i == op_objs.length - 1) { + setTimeout(function () { $.modal.close(); }, 500); + } else { + mvcpDirent(++i); + } + }; + var end = function () { + setTimeout(function () { $.modal.close(); }, 500); + }; + mvcpDirent(); + cancel_btn.click(function() { + Common.disableButton(cancel_btn); + var task_id = $(this).data('task_id'); + $.ajax({ + url: Common.getUrl({name:'cancel_cp'}) + '?task_id=' + encodeURIComponent(task_id), + dataType: 'json', + success: function(data) { + other_info.html(gettext("Canceled.")).removeClass('hide'); + cancel_btn.addClass('hide'); + end(); + }, + error: function(xhr, textStatus, errorThrown) { + var error; + if (xhr.responseText) { + error = $.parseJSON(xhr.responseText).error; + } else { + error = gettext("Failed. Please check the network."); + } + other_info.html(error).removeClass('hide'); + Common.enableButton(cancel_btn); + } + }); + }); + } + return false; + }); + }, + + onWindowScroll: function () { + var dir = this.dir, + start = dir.more_start; + + if (dir.dirent_more && $(window).scrollTop() + $(window).height() > $(document).height() - $('#footer').outerHeight(true) && start != dir.last_start) { + var loading_tip = this.$('.loading-tip'), + _this = this; + dir.last_start = start; + dir.fetch({ + remove: false, + data: { + 'p': dir.path, + 'start': dir.more_start + }, + success: function (collection, response, opts) { + if (!response.dirent_more ) { // no 'more' + loading_tip.hide(); + } + _this.getImageThumbnail(); + }, + error: function(xhr, textStatus, errorThrown) { + loading_tip.hide(); + Common.ajaxErrorHandler(xhr, textStatus, errorThrown); + } + }); + } + } + }); + + return DirView; +}); diff --git a/media/assets/scripts/app/views/dir.js b/media/assets/scripts/app/views/dir.js new file mode 100644 index 0000000000..5b981ed092 --- /dev/null +++ b/media/assets/scripts/app/views/dir.js @@ -0,0 +1,875 @@ +define([ + 'jquery', + 'jquery.ui.progressbar', + 'jquery.magnific-popup', + 'simplemodal', + 'underscore', + 'backbone', + 'common', + 'file-tree', + 'app/collections/dirents', + 'app/views/dirent', + 'app/views/fileupload', + 'app/views/share' + ], function($, progressbar, magnificPopup, simplemodal, _, Backbone, Common, + FileTree, DirentCollection, DirentView, FileUploadView, ShareView) { + 'use strict'; + + var DirView = Backbone.View.extend({ + el: $('#dir-view'), + + path_bar_template: _.template($('#path-bar-tmpl').html()), + dir_op_bar_template: _.template($('#dir-op-bar-tmpl').html()), + newDirTemplate: _.template($("#add-new-dir-form-template").html()), + newFileTemplate: _.template($("#add-new-file-form-template").html()), + mvcpTemplate: _.template($("#mvcp-form-template").html()), + mvProgressTemplate: _.template($("#mv-progress-popup-template").html()), + + initialize: function(options) { + this.$dirent_list = this.$('.repo-file-list tbody'); + this.$path_bar = this.$('.path'); + // For compatible with css, we use .repo-op instead of .dir-op + this.$dir_op_bar = this.$('.repo-op'); + + this.dir = new DirentCollection(); + this.listenTo(this.dir, 'add', this.addOne); + this.listenTo(this.dir, 'reset', this.reset); + + this.fileUploadView = new FileUploadView({dirView: this}); + + this.$el.magnificPopup({ + type: 'image', + delegate: '.img-name-link', + tClose: gettext("Close (Esc)"), // Alt text on close button + tLoading: gettext("Loading..."), // Text that is displayed during loading. Can contain %curr% and %total% keys + gallery: { + enabled: true, + tPrev: gettext("Previous (Left arrow key)"), // Alt text on left arrow + tNext: gettext("Next (Right arrow key)"), // Alt text on right arrow + tCounter: gettext("%curr% of %total%") // Markup for "1 of 7" counter + }, + image: { + titleSrc: function(item) { + var el = item.el; + var img_name = el[0].innerHTML; + var img_link = '' + gettext("Open in New Tab") + ''; + return img_name + '
' + img_link; + }, + tError: gettext('The image could not be loaded.') // Error message when image could not be loaded + } + }); + + // initialize common js behavior + this.$('th .checkbox-orig').unbind(); + + // get 'more' + var _this = this; + $(window).scroll(function() { + if ($(_this.el).is(':visible')) { + _this.onWindowScroll(); + } + }); + + // hide 'hidden-op' popup + app.globalState.noFileOpPopup = true; + $(document).click(function(e) { + var target = e.target || event.srcElement; + var popup = $('.hidden-op'); + if (!app.globalState.noFileOpPopup && + !$('.more-op-icon, .hidden-op').is(target) && + !popup.find('*').is(target)) { + popup.addClass('hide'); + app.globalState.noFileOpPopup = true; + if (!app.globalState.popup_tr.find('*').is(target)) { + app.globalState.popup_tr.removeClass('hl').find('.repo-file-op').addClass('vh'); // clicked place: the first tr, place out of the table + $('.repo-file-list tr:gt(0)').each(function() { // when other tr is clicked + if ($(this).find('*').is(target)) { + $(this).addClass('hl').find('.repo-file-op').removeClass('vh'); + } + }); + } + } + }); + }, + + showDir: function(category, repo_id, path) { + this.$el.show(); + this.$dirent_list.empty(); + var loading_tip = this.$('.loading-tip').show(); + var dir = this.dir; + dir.setPath(category, repo_id, path); + var _this = this; + dir.fetch({ + reset: true, + data: {'p': path}, + success: function (collection, response, opts) { + dir.last_start = 0; // for 'more' + if (response.dirent_list.length == 0 || // the dir is empty + !response.dirent_more ) { // no 'more' + loading_tip.hide(); + } + }, + error: function (collection, response, opts) { + loading_tip.hide(); + var $el_con = _this.$('.repo-file-list-topbar, .repo-file-list').hide(); + var $error = _this.$('.error'); + var err_msg; + var decrypt_lib = false; + if (response.responseText) { + if (response.responseJSON.lib_need_decrypt) { + decrypt_lib = true; + } else { + err_msg = response.responseJSON.error; + } + } else { + err_msg = gettext('Please check the network.'); + } + if (err_msg) { + $error.html(err_msg).show(); + } + + if (decrypt_lib) { + var form = $($('#repo-decrypt-form-template').html()); + form.modal({containerCss: {'padding': '1px'}}); + $('#simplemodal-container').css({'height':'auto'}); + form.submit(function() { + var passwd = $.trim($('[name="password"]', form).val()); + if (!passwd) { + $('.error', form).html(gettext("Password is required.")).removeClass('hide'); + return false; + } + Common.ajaxPost({ + form: form, + form_id: form.attr('id'), + post_url: Common.getUrl({'name':'repo_set_password'}), + post_data: { + repo_id: repo_id, + password: passwd, + username: app.pageOptions.username + }, + after_op_success: function() { + $.modal.close(); + $el_con.show(); + _this.showDir(category, repo_id, path); + } + }); + return false; + }); + } + } + }); + }, + + hide: function() { + this.$el.hide(); + }, + + addOne: function(dirent) { + var view = new DirentView({model: dirent, dirView: this}); + this.$dirent_list.append(view.render().el); + }, + + reset: function() { + this.dir.each(this.addOne, this); + this.renderPath(); + this.renderDirOpBar(); + this.fileUploadView.setFileInput(); + this.getImageThumbnail(); + }, + + getImageThumbnail: function() { + var images_with_no_thumbnail = this.dir.filter(function(dirent) { + // 'dirent' is a model + return dirent.get('is_img') && !dirent.get('thumbnail_src'); + }); + if (images_with_no_thumbnail.length == 0) { + return ; + } + + var images_len = images_with_no_thumbnail.length, + repo_id = this.dir.repo_id, + cur_path = this.dir.path, + _this = this; + var get_thumbnail = function(i) { + var cur_img = images_with_no_thumbnail[i]; + var cur_img_path = Common.pathJoin([cur_path, cur_img.get('obj_name')]); + $.ajax({ + url: Common.getUrl({name: 'thumbnail_create', repo_id: repo_id}), + data: {'path': cur_img_path}, + cache: false, + dataType: 'json', + success: function(data) { + cur_img.set({ + 'thumbnail_src': data.thumbnail_src + }); + }, + complete: function() { + // cur path may be changed. e.g., the user enter another directory + if (i < images_len - 1 && + _this.dir.repo_id == repo_id && + _this.dir.path == cur_path) { + get_thumbnail(++i); + } + } + }); + }; + get_thumbnail(0); + }, + + renderPath: function() { + var dir = this.dir; + var path = dir.path; + var context = 'my'; + + var category_start = dir.category.split('/')[0]; + if (category_start == 'org') { + context = 'org'; + } else if (category_start == 'group') { + context = 'group'; + } else if (category_start == 'common') { + context = 'common'; + } + var obj = { + path: path, + repo_name: dir.repo_name, + category: dir.category, + context: context + }; + + var path_list = path.substr(1).split('/'); + var path_list_encoded = path_list.map(function(e) { return encodeURIComponent(e); }); + if (path != '/') { + $.extend(obj, { + path_list: path_list, + path_list_encoded: path_list_encoded, + repo_id: dir.repo_id + }); + } + + this.$path_bar.html(this.path_bar_template(obj)); + }, + + renderDirOpBar: function() { + var dir = this.dir, + user_perm = dir.user_perm; + + this.$dir_op_bar.html($.trim(this.dir_op_bar_template({ + user_perm: user_perm, + encrypted: dir.encrypted, + path: dir.path, + repo_id: dir.repo_id, + site_root: app.pageOptions.site_root, + is_repo_owner: dir.is_repo_owner, + enable_upload_folder: app.pageOptions.enable_upload_folder + }))); + }, + + // Directory Operations + events: { + 'click .path-link': 'visitDir', + 'click #upload-file': 'uploadFile', + 'click #add-new-dir': 'newDir', + 'click #add-new-file': 'newFile', + 'click #share-cur-dir': 'share', + 'click th.select': 'select', + 'click #mv-dirents': 'mv', + 'click #cp-dirents': 'cp', + 'click #del-dirents': 'del', + 'click #by-name': 'sortByName', + 'click #by-time': 'sortByTime' + }, + + newDir: function() { + var form = $(this.newDirTemplate()), + form_id = form.attr('id'), + dir = this.dir, + dirView = this; + + form.modal({appendTo:'#main'}); + $('#simplemodal-container').css({'height':'auto'}); + + form.submit(function() { + var dirent_name = $.trim($('input[name="name"]', form).val()); + + if (!dirent_name) { + Common.showFormError(form_id, gettext("It is required.")); + return false; + }; + + var post_data = {'dirent_name': dirent_name}, + post_url = Common.getUrl({name: "new_dir", repo_id: dir.repo_id}) + + '?parent_dir=' + encodeURIComponent(dir.path); + var after_op_success = function(data) { + $.modal.close(); + + var new_dirent = dir.add({ + 'is_dir': true, + 'obj_name': data['name'], + 'last_modified': new Date().getTime() / 1000, + 'last_update': gettext("Just now"), + 'p_dpath': data['p_dpath'] + }, {silent:true}); + dirView.addNewDir(new_dirent); + }; + + Common.ajaxPost({ + 'form': form, + 'post_url': post_url, + 'post_data': post_data, + 'after_op_success': after_op_success, + 'form_id': form_id + }); + + return false; + }); + }, + + newFile: function() { + var form = $(this.newFileTemplate()), + form_id = form.attr('id'), + file_name = form.find('input[name="name"]'), + dir = this.dir, + dirView = this; + + form.modal({ + appendTo: '#main', + focus: false, + containerCss: {'padding':'20px 25px'} + }); + $('#simplemodal-container').css({'height':'auto'}); + + $('.set-file-type', form).click(function() { + file_name.val('.' + $(this).data('filetype')); + Common.setCaretPos(file_name[0], 0); + file_name.focus(); + }); + + form.submit(function() { + var dirent_name = $.trim(file_name.val()); + + if (!dirent_name) { + Common.showFormError(form_id, gettext("It is required.")); + return false; + }; + + // if it has an extension, make sure it has a name + if (dirent_name.lastIndexOf('.') != -1 && dirent_name.substr(0, dirent_name.lastIndexOf('.')).length == 0) { + Common.showFormError(form_id, gettext("Only an extension there, please input a name.")); + return false; + } + + var post_data = {'dirent_name': dirent_name}, + post_url = Common.getUrl({name: "new_file", repo_id: dir.repo_id}) + + '?parent_dir=' + encodeURIComponent(dir.path); + var after_op_success = function(data) { + $.modal.close(); + var new_dirent = dir.add({ + 'is_file': true, + 'is_img': Common.imageCheck(data['name']), + 'obj_name': data['name'], + 'file_size': Common.fileSizeFormat(0), + 'obj_id': '0000000000000000000000000000000000000000', + 'file_icon': 'file.png', + 'starred': false, + 'last_modified': new Date().getTime() / 1000, + 'last_update': gettext("Just now") + }, {silent: true}); + dirView.addNewFile(new_dirent); + }; + + Common.ajaxPost({ + 'form': form, + 'post_url': post_url, + 'post_data': post_data, + 'after_op_success': after_op_success, + 'form_id': form_id + }); + + return false; + }); + }, + + addNewFile: function(new_dirent) { + var dirView = this, + dir = this.dir; + var view = new DirentView({model: new_dirent, dirView: dirView}); + var new_file = view.render().el; + // put the new file as the first file + if ($('tr', dirView.$dirent_list).length == 0) { + dirView.$dirent_list.append(new_file); + } else { + var dirs = dir.where({'is_dir':true}); + if (dirs.length == 0) { + dirView.$dirent_list.prepend(new_file); + } else { + // put the new file after the last dir + $($('tr', dirView.$dirent_list)[dirs.length - 1]).after(new_file); + } + } + }, + + addNewDir: function(new_dirent) { + var dirView = this; + var view = new DirentView({model: new_dirent, dirView: dirView}); + dirView.$dirent_list.prepend(view.render().el); // put the new dir as the first one + }, + + share: function () { + var dir = this.dir; + var path = dir.path; + var options = { + 'is_repo_owner': dir.is_repo_owner, + 'is_virtual': dir.is_virtual, + 'user_perm': dir.user_perm, + 'repo_id': dir.repo_id, + 'is_dir': true, + 'dirent_path': path, + 'obj_name': path == '/' ? dir.repo_name : path.substr(path.lastIndexOf('/') + 1) + }; + new ShareView(options); + }, + + sortByName: function() { + var dirents = this.dir; + var el = $('#by-name'); + dirents.comparator = function(a, b) { + if (a.get('is_dir') && b.get('is_file')) { + return -1; + } + if (el.hasClass('icon-caret-up')) { + return a.get('obj_name').toLowerCase() < b.get('obj_name').toLowerCase() ? 1 : -1; + } else { + return a.get('obj_name').toLowerCase() < b.get('obj_name').toLowerCase() ? -1 : 1; + } + }; + dirents.sort(); + this.$dirent_list.empty(); + dirents.each(this.addOne, this); + el.toggleClass('icon-caret-up icon-caret-down'); + }, + + sortByTime: function () { + var dirents = this.dir; + var el = $('#by-time'); + dirents.comparator = function(a, b) { + if (a.get('is_dir') && b.get('is_file')) { + return -1; + } + if (el.hasClass('icon-caret-down')) { + return a.get('last_modified') < b.get('last_modified') ? 1 : -1; + } else { + return a.get('last_modified') < b.get('last_modified') ? -1 : 1; + } + }; + dirents.sort(); + this.$dirent_list.empty(); + dirents.each(this.addOne, this); + el.toggleClass('icon-caret-up icon-caret-down'); + }, + + select: function () { + var el = this.$('th .checkbox'); + el.toggleClass('checkbox-checked'); + + var dir = this.dir; + var all_dirent_checkbox = this.$('.checkbox'); + var $dirents_op = this.$('#multi-dirents-op'); + + if (el.hasClass('checkbox-checked')) { + all_dirent_checkbox.addClass('checkbox-checked'); + dir.each(function(model) { + model.set({'selected': true}, {silent: true}); + }); + $dirents_op.css({'display':'inline'}); + } else { + all_dirent_checkbox.removeClass('checkbox-checked'); + dir.each(function(model) { + model.set({'selected': false}, {silent: true}); + }); + $dirents_op.hide(); + } + }, + + del: function () { + var dirents = this.dir; + var _this = this; + + var del_dirents = function() { + $('#confirm-popup').append('

' + gettext("Processing...") + '

'); + var selected_dirents = dirents.where({'selected':true}), + selected_names = []; + $(selected_dirents).each(function() { + selected_names.push(this.get('obj_name')); + }); + $.ajax({ + url: Common.getUrl({ + name: 'del_dirents', + repo_id: dirents.repo_id + }) + '?parent_dir=' + encodeURIComponent(dirents.path), + type: 'POST', + dataType: 'json', + beforeSend: Common.prepareCSRFToken, + traditional: true, + data: { + 'dirents_names': selected_names + }, + success: function(data) { + var del_len = data['deleted'].length, + not_del_len = data['undeleted'].length, + msg_s, msg_f; + + if (del_len > 0) { + if (del_len == selected_names.length) { + dirents.remove(selected_dirents); + _this.$('th .checkbox').removeClass('checkbox-checked'); + _this.$('#multi-dirents-op').hide(); + } else { + $(selected_dirents).each(function() { + if (this.get('obj_name') in data['deleted']) { + dirents.remove(this); + } + }); + } + if (del_len == 1) { + msg_s = gettext("Successfully deleted %(name)s."); + } else if (del_len == 2) { + msg_s = gettext("Successfully deleted %(name)s and 1 other item."); + } else { + msg_s = gettext("Successfully deleted %(name)s and %(amount)s other items."); + } + msg_s = msg_s.replace('%(name)s', Common.HTMLescape(data['deleted'][0])).replace('%(amount)s', del_len - 1); + Common.feedback(msg_s, 'success'); + } + if (not_del_len > 0) { + if (not_del_len == 1) { + msg_f = gettext("Internal error. Failed to delete %(name)s."); + } else if (not_del_len == 2) { + msg_f = gettext("Internal error. Failed to delete %(name)s and 1 other item."); + } else { + msg_f = gettext("Internal error. Failed to delete %(name)s and %(amount)s other items."); + } + msg_f = msg_f.replace('%(name)s', Common.HTMLescape(data['undeleted'][0])).replace('%(amount)s', not_del_len - 1); + Common.feedback(msg_f, 'error'); + } + $.modal.close(); + }, + error: function(xhr, textStatus, errorThrown) { + $.modal.close(); + Common.ajaxErrorHandler(xhr, textStatus, errorThrown); + } + }); + }; + Common.showConfirm(gettext("Delete Items"), + gettext("Are you sure you want to delete these selected items?"), + del_dirents); + }, + + mv: function () { + this.mvcp({'op':'mv'}); + }, + cp: function () { + this.mvcp({'op':'cp'}); + }, + mvcp: function (params) { + var dir = this.dir; + var op = params.op; + + var title = op == 'mv' ? "Move selected item(s) to:" : "Copy selected item(s) to:"; + + var form = $(this.mvcpTemplate({ + form_title: title, + op_type: op, + obj_type: '', + obj_name: '', + show_other_repos: !dir.encrypted, + })); + form.modal({appendTo:'#main', autoResize:true, focus:false}); + $('#simplemodal-container').css({'width':'auto', 'height':'auto'}); + + FileTree.renderTreeForPath({ + repo_name: dir.repo_name, + repo_id: dir.repo_id, + path: dir.path + }); + if (!dir.encrypted) { + FileTree.prepareOtherReposTree({cur_repo_id: dir.repo_id}); + } + + var _this = this; + var dirents = this.dir; + // get models + var dirs = dirents.where({'is_dir':true, 'selected':true}), + files = dirents.where({'is_file':true, 'selected':true}); + var dir_names = [], file_names = []; + $(dirs).each(function() { + dir_names.push(this.get('obj_name')); + }); + $(files).each(function() { + file_names.push(this.get('obj_name')); + }); + form.submit(function() { + var dst_repo = $('[name="dst_repo"]', form).val(), + dst_path = $('[name="dst_path"]', form).val(), + url_main; + var cur_path = dirents.path; + var url_obj = {repo_id:dirents.repo_id}; + + if (!$.trim(dst_repo) || !$.trim(dst_path)) { + $('.error', form).removeClass('hide'); + return false; + } + if (dst_repo == dirents.repo_id && dst_path == cur_path) { + $('.error', form).html(gettext("Invalid destination path")).removeClass('hide'); + return false; + } + + Common.disableButton($('[type="submit"]', form)); + form.append('

' + gettext("Processing...") + '

'); + + if (dst_repo == dirents.repo_id) { + // when mv/cp in current lib, files/dirs can be handled in batch, and no need to show progress + url_obj.name = op == 'mv' ? 'mv_dirents' : 'cp_dirents'; + $.ajax({ + url: Common.getUrl(url_obj) + '?parent_dir=' + encodeURIComponent(cur_path), + type: 'POST', + dataType: 'json', + beforeSend: Common.prepareCSRFToken, + traditional: true, + data: { + 'file_names': file_names, + 'dir_names': dir_names, + 'dst_repo': dst_repo, + 'dst_path': dst_path + }, + success: function(data) { + var success_len = data['success'].length, + msg_s, msg_f, + view_url = data['url']; + + $.modal.close(); + if (success_len > 0) { + if (op == 'mv') { + if (success_len == files.length + dirs.length) { + dirents.remove(dirs); + dirents.remove(files); + _this.$('th .checkbox').removeClass('checkbox-checked'); + _this.$('#multi-dirents-op').hide(); + } else { + $(dirs).each(function() { + if (this.get('obj_name') in data['success']) { + dirents.remove(this); + } + }); + $(files).each(function() { + if (this.get('obj_name') in data['success']) { + dirents.remove(this); + } + }); + } + if (success_len == 1) { + msg_s = gettext("Successfully moved %(name)s."); + } else if (success_len == 2) { + msg_s = gettext("Successfully moved %(name)s and 1 other item."); + } else { + msg_s = gettext("Successfully moved %(name)s and %(amount)s other items."); + } + } else { // cp + if (success_len == 1) { + msg_s = gettext("Successfully copied %(name)s."); + } else if (success_len == 2) { + msg_s = gettext("Successfully copied %(name)s and 1 other item."); + } else { + msg_s = gettext("Successfully copied %(name)s and %(amount)s other items."); + } + } + + msg_s = msg_s.replace('%(name)s', Common.HTMLescape(data['success'][0])).replace('%(amount)s', success_len - 1); + //msg_s += ' ' + "View" + ''; + Common.feedback(msg_s, 'success'); + } + + if (data['failed'].length > 0) { + if (op == 'mv') { + if (data['failed'].length > 1) { + msg_f = gettext("Internal error. Failed to move %(name)s and %(amount)s other item(s)."); + } else { + msg_f = gettext("Internal error. Failed to move %(name)s."); + } + } else { + if (data['failed'].length > 1) { + msg_f = gettext("Internal error. Failed to copy %(name)s and %(amount)s other item(s)."); + } else { + msg_f = gettext("Internal error. Failed to copy %(name)s."); + } + } + msg_f = msg_f.replace('%(name)s', Common.HTMLescape(data['failed'][0])).replace('%(amount)s', data['failed'].length - 1); + Common.feedback(msg_f, 'error'); + } + }, + error: function(xhr, textStatus, errorThrown) { + $.modal.close(); + Common.ajaxErrorHandler(xhr, textStatus, errorThrown); + } + }); + } else { + // when mv/cp to another lib, files/dirs should be handled one by one, and need to show progress + var op_objs = dirents.where({'selected':true}), + i = 0; + // progress popup + var mv_progress_popup = $(_this.mvProgressTemplate()); + var details = $('#mv-details', mv_progress_popup), + cancel_btn = $('#cancel-mv', mv_progress_popup), + other_info = $('#mv-other-info', mv_progress_popup); + + var mvcpDirent = function () { + var op_obj = op_objs[i], + obj_type = op_obj.get('is_dir') ? 'dir':'file', + obj_name = op_obj.get('obj_name'), + post_url, + post_data; + + if (op == 'mv') { + url_obj.name = obj_type == 'dir' ? 'mv_dir' : 'mv_file'; + } else { + url_obj.name = obj_type == 'dir' ? 'cp_dir' : 'cp_file'; + } + post_url = Common.getUrl(url_obj) + '?path=' + encodeURIComponent(cur_path) + '&obj_name=' + encodeURIComponent(obj_name); + post_data = { + 'dst_repo': dst_repo, + 'dst_path': dst_path + }; + var after_op_success = function (data) { + var det_text = op == 'mv' ? gettext("Moving file %(index)s of %(total)s") : gettext("Copying file %(index)s of %(total)s"); + details.html(det_text.replace('%(index)s', i + 1).replace('%(total)s', op_objs.length)).removeClass('vh'); + cancel_btn.removeClass('hide'); + var req_progress = function () { + var task_id = data['task_id']; + cancel_btn.data('task_id', task_id); + $.ajax({ + url: Common.getUrl({name:'get_cp_progress'}) + '?task_id=' + encodeURIComponent(task_id), + dataType: 'json', + success: function(data) { + var bar = $('.ui-progressbar-value', $('#mv-progress')); + if (!data['failed'] && !data['canceled'] && !data['successful']) { + setTimeout(req_progress, 1000); + } else { + if (data['successful']) { + bar.css('width', parseInt((i + 1)/op_objs.length*100, 10) + '%').show(); + if (op == 'mv') { + dirents.remove(op_obj); + } + endOrContinue(); + } else { // failed or canceled + if (data['failed']) { + var error_msg = op == 'mv' ? gettext('Failed to move %(name)s') : gettext('Failed to copy %(name)s'); + cancel_btn.after('

' + error_msg.replace('%(name)s', Common.HTMLescape(obj_name)) + '

'); + end(); + } + } + } + }, + error: function(xhr, textStatus, errorThrown) { + var error; + if (xhr.responseText) { + error = $.parseJSON(xhr.responseText).error; + } else { + error = gettext("Failed. Please check the network."); + } + cancel_btn.after('

' + error + '

'); + end(); + } + }); + }; // 'req_progress' ends + if (i == 0) { + $.modal.close(); + setTimeout(function () { + mv_progress_popup.modal({containerCss: { + width: 300, + height: 150, + paddingTop: 50 + }, focus:false}); + $('#mv-progress').progressbar(); + req_progress(); + }, 100); + } else { + req_progress(); + } + }; // 'after_op_success' ends + Common.ajaxPost({ + 'form': form, + 'post_url': post_url, + 'post_data': post_data, + 'after_op_success': after_op_success, + 'form_id': form.attr('id') + }); + }; // 'mvcpDirent' ends + var endOrContinue = function () { + if (i == op_objs.length - 1) { + setTimeout(function () { $.modal.close(); }, 500); + } else { + mvcpDirent(++i); + } + }; + var end = function () { + setTimeout(function () { $.modal.close(); }, 500); + }; + mvcpDirent(); + cancel_btn.click(function() { + Common.disableButton(cancel_btn); + var task_id = $(this).data('task_id'); + $.ajax({ + url: Common.getUrl({name:'cancel_cp'}) + '?task_id=' + encodeURIComponent(task_id), + dataType: 'json', + success: function(data) { + other_info.html(gettext("Canceled.")).removeClass('hide'); + cancel_btn.addClass('hide'); + end(); + }, + error: function(xhr, textStatus, errorThrown) { + var error; + if (xhr.responseText) { + error = $.parseJSON(xhr.responseText).error; + } else { + error = gettext("Failed. Please check the network."); + } + other_info.html(error).removeClass('hide'); + Common.enableButton(cancel_btn); + } + }); + }); + } + return false; + }); + }, + + onWindowScroll: function () { + var dir = this.dir, + start = dir.more_start; + + if (dir.dirent_more && $(window).scrollTop() + $(window).height() > $(document).height() - $('#footer').outerHeight(true) && start != dir.last_start) { + var loading_tip = this.$('.loading-tip'), + _this = this; + dir.last_start = start; + dir.fetch({ + remove: false, + data: { + 'p': dir.path, + 'start': dir.more_start + }, + success: function (collection, response, opts) { + if (!response.dirent_more ) { // no 'more' + loading_tip.hide(); + } + _this.getImageThumbnail(); + }, + error: function(xhr, textStatus, errorThrown) { + loading_tip.hide(); + Common.ajaxErrorHandler(xhr, textStatus, errorThrown); + } + }); + } + } + }); + + return DirView; +}); diff --git a/media/assets/scripts/app/views/dirent.b1f79799a510.js b/media/assets/scripts/app/views/dirent.b1f79799a510.js new file mode 100644 index 0000000000..098f1cdaa2 --- /dev/null +++ b/media/assets/scripts/app/views/dirent.b1f79799a510.js @@ -0,0 +1,455 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common', + 'file-tree', + 'app/views/share', + 'app/views/folder-perm' +], function($, _, Backbone, Common, FileTree, ShareView, FolderPermView) { + 'use strict'; + + app = app || {}; + app.globalState = app.globalState || {}; + + var DirentView = Backbone.View.extend({ + tagName: 'tr', + + template: _.template($('#dirent-tmpl').html()), + renameTemplate: _.template($("#rename-form-template").html()), + mvcpTemplate: _.template($("#mvcp-form-template").html()), + mvProgressTemplate: _.template($("#mv-progress-popup-template").html()), + + initialize: function(options) { + this.dirView = options.dirView; + this.dir = this.dirView.dir; + + this.listenTo(this.model, "change", this.render); + this.listenTo(this.model, 'remove', this.remove); // for multi dirents: delete, mv + }, + + render: function() { + var dir = this.dir; + var dirent_path = Common.pathJoin([dir.path, this.model.get('obj_name')]); + this.$el.html(this.template({ + dirent: this.model.attributes, + dirent_path: dirent_path, + encoded_path: Common.encodePath(dirent_path), + category: dir.category, + repo_id: dir.repo_id, + user_perm: dir.user_perm, + is_repo_owner: dir.is_repo_owner, + repo_encrypted: dir.encrypted + })); + return this; + }, + + events: { + 'mouseenter': 'highlight', + 'mouseleave': 'rmHighlight', + 'click .select': 'select', + 'click .file-star': 'starFile', + 'click .dir-link': 'visitDir', + 'click .more-op-icon': 'togglePopup', + 'click .share': 'share', + 'click .delete': 'delete', + 'click .rename': 'rename', + 'click .mv': 'mvcp', + 'click .cp': 'mvcp', + 'click .set-folder-permission': 'setFolderPerm' + }, + + highlight: function() { + if (app.globalState.noFileOpPopup) { + this.$el.addClass('hl').find('.repo-file-op').removeClass('vh'); + } + }, + + rmHighlight: function() { + if (app.globalState.noFileOpPopup) { + this.$el.removeClass('hl').find('.repo-file-op').addClass('vh'); + } + }, + + select: function () { + var checkbox = this.$('.checkbox'); + checkbox.toggleClass('checkbox-checked'); + if (checkbox.hasClass('checkbox-checked')) { + this.model.set({'selected':true}, {silent:true}); // do not trigger the 'change' event. + } else { + this.model.set({'selected':false}, {silent:true}); + } + + var dirView = this.dirView; + var $dirents_op = dirView.$('#multi-dirents-op'); + var toggle_all_checkbox = dirView.$('th .checkbox'); // TODO: any better variable name? + var checked_num = dirView.$('tr:gt(0) .checkbox-checked').length; + if (checked_num > 0) { + $dirents_op.css({'display':'inline'}); + } else { + $dirents_op.hide(); + } + if (checked_num == dirView.$('tr:gt(0)').length) { + toggle_all_checkbox.addClass('checkbox-checked'); + } else { + toggle_all_checkbox.removeClass('checkbox-checked'); + } + }, + + starFile: function() { + var _this = this; + var dir = this.dirView.dir; + //var path = dir.path; + //path += (path == '/' ? '' : '/'); + var starred = this.model.get('starred'); + var options = { repo_id: dir.repo_id }; + options.name = starred ? 'unstar_file' : 'star_file'; + var filePath = Common.pathJoin([dir.path, this.model.get('obj_name')]); + var url = Common.getUrl(options) + '?file=' + encodeURIComponent(filePath); + $.ajax({ + url: url, + dataType: 'json', + cache: false, + success: function () { + if (starred) { + _this.model.set({'starred':false}); + } else { + _this.model.set({'starred':true}); + } + }, + error: Common.ajaxErrorHandler + }); + }, + + visitDir: function () { // todo + // show 'loading' + this.$('.dirent-icon img').attr({ + 'src': app.config.mediaUrl + 'img/loading-icon.gif', + 'alt':'' + }); + // empty all models + this.dirView.dir.reset(); + // update url & dirents + var dir_url = this.$('.dir-link').attr("href"); + app.router.navigate(dir_url, {trigger: true}); // offer an url fragment + return false; + }, + + togglePopup: function () { + var icon = this.$('.more-op-icon'), + popup = this.$('.hidden-op'); + + if (popup.hasClass('hide')) { // the popup is not shown + + popup.css({'left': icon.position().left}); + if (icon.offset().top + popup.height() <= $('#main').offset().top + $('#main').height()) { + // below the icon + popup.css('top', icon.position().top + icon.height() + 3); + } else { + popup.css('bottom', icon.parent().outerHeight() - icon.position().top + 3); + } + + popup.removeClass('hide'); + app.globalState.noFileOpPopup = false; + app.globalState.popup_tr = icon.parents('tr'); + } else { + popup.addClass('hide'); + app.globalState.noFileOpPopup = true; + app.globalState.popup_tr = ''; + } + }, + + share: function() { + var dir = this.dir, + obj_name = this.model.get('obj_name'), + dirent_path = Common.pathJoin([dir.path, obj_name]); + + var options = { + 'is_repo_owner': dir.is_repo_owner, + 'is_virtual': dir.is_virtual, + 'user_perm': dir.user_perm, + 'repo_id': dir.repo_id, + 'is_dir': this.model.get('is_dir') ? true : false, + 'dirent_path': dirent_path, + 'obj_name': obj_name + }; + new ShareView(options); + return false; + }, + + delete: function() { + var dirent_name = this.model.get('obj_name'); + var options = { + repo_id: this.dirView.dir.repo_id, + name: this.model.get('is_dir') ? 'del_dir' : 'del_file' + }; + var el = this.$el; + $.ajax({ + url: Common.getUrl(options) + '?parent_dir=' + encodeURIComponent(this.dirView.dir.path) + + '&name=' + encodeURIComponent(dirent_name), + dataType: 'json', + success: function(data) { + el.remove(); + app.globalState.noFileOpPopup = true; // make other items can work normally when hover + var msg = gettext("Successfully deleted %(name)s"); + msg = msg.replace('%(name)s', Common.HTMLescape(dirent_name)); + Common.feedback(msg, 'success'); + }, + error: Common.ajaxErrorHandler + }); + return false; + }, + + rename: function() { + var is_dir = this.model.get('is_dir'); + var title = is_dir ? gettext("Rename Directory") : gettext("Rename File"); + var dirent_name = this.model.get('obj_name'); + + var form = $(this.renameTemplate({ + form_title: title, + dirent_name: dirent_name + })); + form.modal({focus:false}); // For 'newname' input: if use the default 'focus:true', text in it will be selected. + $('#simplemodal-container').css({'width':'auto', 'height':'auto'}); + + var op_detail = $('.detail', form); + op_detail.html(op_detail.html().replace('%(name)s', '' + Common.HTMLescape(dirent_name) + '')); + + var form_id = form.attr('id'); + var _this = this; + var dir = this.dirView.dir; + form.submit(function() { + var new_name = $.trim($('[name="newname"]', form).val()); + if (!new_name) { + Common.showFormError(form_id, gettext("It is required.")); + return false; + } + if (new_name == dirent_name) { + Common.showFormError(form_id, gettext("You have not renamed it.")); + return false; + } + var post_data = { + 'oldname': dirent_name, + 'newname': new_name + }; + var post_url = Common.getUrl({ + name: is_dir ? 'rename_dir' : 'rename_file', + repo_id: dir.repo_id + }) + '?parent_dir=' + encodeURIComponent(dir.path); + var after_op_success = function (data) { + var renamed_dirent_data = { + 'obj_name': data['newname'], + 'last_modified': new Date().getTime()/1000, + 'last_update': gettext("Just now"), + 'sharelink': '', + 'sharetoken': '' + }; + if (is_dir) { + /* + $.extend(renamed_dirent_data, { + 'p_dpath': data['p_dpath'] + }); + */ + } else { + $.extend(renamed_dirent_data, { + 'starred': false + }); + } + $.modal.close(); + _this.model.set(renamed_dirent_data); // it will trigger 'change' event + }; + Common.ajaxPost({ + 'form': form, + 'post_url': post_url, + 'post_data': post_data, + 'after_op_success': after_op_success, + 'form_id': form_id + }); + return false; + }); + return false; + }, + + mvcp: function() { + var dir = this.dir; + var el = event.target || event.srcElement, + op_type = $(el).hasClass('mv') ? 'mv' : 'cp', + obj_name = this.model.get('obj_name'), + obj_type = this.model.get('is_dir') ? 'dir' : 'file'; + + var title = op_type == 'mv' ? gettext("Move {placeholder} to:") : gettext("Copy {placeholder} to:"); + title = title.replace('{placeholder}', '' + Common.HTMLescape(obj_name) + ''); + + var form = $(this.mvcpTemplate({ + form_title: title, + op_type: op_type, + obj_type: obj_type, + obj_name: obj_name, + show_other_repos: !dir.encrypted, + })); + form.modal({appendTo:'#main', autoResize:true, focus:false}); + $('#simplemodal-container').css({'width':'auto', 'height':'auto'}); + + FileTree.renderTreeForPath({ + repo_name: dir.repo_name, + repo_id: dir.repo_id, + path: dir.path + }); + if (!dir.encrypted) { + FileTree.prepareOtherReposTree({cur_repo_id: dir.repo_id}); + } + + var dirent = this.$el; + var _this = this; + form.submit(function() { + var form = $(this), + form_id = form.attr('id'), + path = dir.path, + repo_id = dir.repo_id; + var dst_repo = $('[name="dst_repo"]', form).val(), + dst_path = $('[name="dst_path"]', form).val(), + op = $('[name="op"]', form).val(), + obj_name = $('[name="obj_name"]', form).val(), + obj_type = $('[name="obj_type"]', form).val(); + + if (!$.trim(dst_repo) || !$.trim(dst_path)) { + $('.error', form).removeClass('hide'); + return false; + } + if (dst_repo == repo_id && (dst_path == path || (obj_type == 'dir' && dst_path == path + obj_name + '/'))) { + $('.error', form).html(gettext("Invalid destination path")).removeClass('hide'); + return false; + } + var options = { repo_id: repo_id }; + if (obj_type == 'dir') { + options.name = op == 'mv' ? 'mv_dir' : 'cp_dir'; + } else { + options.name = op == 'mv' ? 'mv_file' : 'cp_file'; + } + var post_url = Common.getUrl(options) + '?path=' + encodeURIComponent(path) + '&obj_name=' + encodeURIComponent(obj_name); + var post_data = { + 'dst_repo': dst_repo, + 'dst_path': dst_path + }; + var after_op_success = function(data) { + $.modal.close(); + var msg = data['msg']; + if (!data['task_id']) { // no progress + if (op == 'mv') { + dirent.remove(); + } + Common.feedback(msg, 'success'); + } else { + var mv_progress_popup = $(_this.mvProgressTemplate()); + var details = $('#mv-details', mv_progress_popup), + cancel_btn = $('#cancel-mv', mv_progress_popup), + other_info = $('#mv-other-info', mv_progress_popup); + cancel_btn.removeClass('hide'); + setTimeout(function () { + mv_progress_popup.modal({containerCss: { + width: 300, + height: 150, + paddingTop: 50 + }, focus:false}); + var det_text = op == 'mv' ? gettext("Moving %(name)s") : gettext("Copying %(name)s"); + details.html(det_text.replace('%(name)s', Common.HTMLescape(obj_name))).removeClass('vh'); + $('#mv-progress').progressbar(); + req_progress(); + }, 100); + var req_progress = function () { + $.ajax({ + url: Common.getUrl({name: 'get_cp_progress'}) + '?task_id=' + encodeURIComponent(data['task_id']), + dataType: 'json', + success: function(data) { + var bar = $('.ui-progressbar-value', $('#mv-progress')); + if (!data['failed'] && !data['canceled'] && !data['successful']) { + if (data['done'] == data['total']) { + bar.css('width', '100%'); // 'done' and 'total' can be both 0 + details.addClass('vh'); + cancel_btn.addClass('hide'); + other_info.html(gettext("Saving...")).removeClass('hide'); + } else { + bar.css('width', parseInt(data['done']/data['total']*100, 10) + '%'); + } + bar.show(); + setTimeout(req_progress, 1000); + } else if (data['successful']) { + $.modal.close(); + if (op == 'mv') { + dirent.remove(); + } + Common.feedback(msg, 'success'); + } else { // failed or canceled + details.addClass('vh'); + var other_msg = data['failed'] ? gettext("Failed.") : gettext("Canceled."); + other_info.html(other_msg).removeClass('hide'); + cancel_btn.addClass('hide'); + setTimeout(function () { $.modal.close(); }, 1000); + } + }, + error: function(xhr, textStatus, errorThrown) { + var error; + if (xhr.responseText) { + error = $.parseJSON(xhr.responseText).error; + } else { + error = gettext("Failed. Please check the network."); + } + details.addClass('vh') + other_info.html(error).removeClass('hide'); + cancel_btn.addClass('hide'); + setTimeout(function () { $.modal.close(); }, 1000); + } + }); + }; + + cancel_btn.click(function() { + Common.disableButton(cancel_btn); + $.ajax({ + url: Common.getUrl({name: 'cancel_cp'}) + '?task_id=' + encodeURIComponent(data['task_id']), + dataType: 'json', + success: function(data) { + details.addClass('vh') + other_info.html(gettext("Canceled.")).removeClass('hide'); + cancel_btn.addClass('hide'); + setTimeout(function () {$.modal.close();}, 1000); + }, + error: function(xhr, textStatus, errorThrown) { + var error; + if (xhr.responseText) { + error = $.parseJSON(xhr.responseText).error; + } else { + error = gettext("Failed. Please check the network."); + } + other_info.html(error).removeClass('hide'); + Common.enableButton(cancel_btn); + } + }); + }); + } + } + Common.ajaxPost({ + 'form': form, + 'post_url': post_url, + 'post_data': post_data, + 'after_op_success': after_op_success, + 'form_id': form_id + }); + return false; + }); + return false; + }, + + setFolderPerm: function() { + var options = { + 'obj_name': this.model.get('obj_name'), + 'dir_path': this.dir.path, + 'repo_id': this.dir.repo_id + }; + new FolderPermView(options); + return false; + } + + }); + + return DirentView; +}); diff --git a/media/assets/scripts/app/views/dirent.js b/media/assets/scripts/app/views/dirent.js new file mode 100644 index 0000000000..098f1cdaa2 --- /dev/null +++ b/media/assets/scripts/app/views/dirent.js @@ -0,0 +1,455 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common', + 'file-tree', + 'app/views/share', + 'app/views/folder-perm' +], function($, _, Backbone, Common, FileTree, ShareView, FolderPermView) { + 'use strict'; + + app = app || {}; + app.globalState = app.globalState || {}; + + var DirentView = Backbone.View.extend({ + tagName: 'tr', + + template: _.template($('#dirent-tmpl').html()), + renameTemplate: _.template($("#rename-form-template").html()), + mvcpTemplate: _.template($("#mvcp-form-template").html()), + mvProgressTemplate: _.template($("#mv-progress-popup-template").html()), + + initialize: function(options) { + this.dirView = options.dirView; + this.dir = this.dirView.dir; + + this.listenTo(this.model, "change", this.render); + this.listenTo(this.model, 'remove', this.remove); // for multi dirents: delete, mv + }, + + render: function() { + var dir = this.dir; + var dirent_path = Common.pathJoin([dir.path, this.model.get('obj_name')]); + this.$el.html(this.template({ + dirent: this.model.attributes, + dirent_path: dirent_path, + encoded_path: Common.encodePath(dirent_path), + category: dir.category, + repo_id: dir.repo_id, + user_perm: dir.user_perm, + is_repo_owner: dir.is_repo_owner, + repo_encrypted: dir.encrypted + })); + return this; + }, + + events: { + 'mouseenter': 'highlight', + 'mouseleave': 'rmHighlight', + 'click .select': 'select', + 'click .file-star': 'starFile', + 'click .dir-link': 'visitDir', + 'click .more-op-icon': 'togglePopup', + 'click .share': 'share', + 'click .delete': 'delete', + 'click .rename': 'rename', + 'click .mv': 'mvcp', + 'click .cp': 'mvcp', + 'click .set-folder-permission': 'setFolderPerm' + }, + + highlight: function() { + if (app.globalState.noFileOpPopup) { + this.$el.addClass('hl').find('.repo-file-op').removeClass('vh'); + } + }, + + rmHighlight: function() { + if (app.globalState.noFileOpPopup) { + this.$el.removeClass('hl').find('.repo-file-op').addClass('vh'); + } + }, + + select: function () { + var checkbox = this.$('.checkbox'); + checkbox.toggleClass('checkbox-checked'); + if (checkbox.hasClass('checkbox-checked')) { + this.model.set({'selected':true}, {silent:true}); // do not trigger the 'change' event. + } else { + this.model.set({'selected':false}, {silent:true}); + } + + var dirView = this.dirView; + var $dirents_op = dirView.$('#multi-dirents-op'); + var toggle_all_checkbox = dirView.$('th .checkbox'); // TODO: any better variable name? + var checked_num = dirView.$('tr:gt(0) .checkbox-checked').length; + if (checked_num > 0) { + $dirents_op.css({'display':'inline'}); + } else { + $dirents_op.hide(); + } + if (checked_num == dirView.$('tr:gt(0)').length) { + toggle_all_checkbox.addClass('checkbox-checked'); + } else { + toggle_all_checkbox.removeClass('checkbox-checked'); + } + }, + + starFile: function() { + var _this = this; + var dir = this.dirView.dir; + //var path = dir.path; + //path += (path == '/' ? '' : '/'); + var starred = this.model.get('starred'); + var options = { repo_id: dir.repo_id }; + options.name = starred ? 'unstar_file' : 'star_file'; + var filePath = Common.pathJoin([dir.path, this.model.get('obj_name')]); + var url = Common.getUrl(options) + '?file=' + encodeURIComponent(filePath); + $.ajax({ + url: url, + dataType: 'json', + cache: false, + success: function () { + if (starred) { + _this.model.set({'starred':false}); + } else { + _this.model.set({'starred':true}); + } + }, + error: Common.ajaxErrorHandler + }); + }, + + visitDir: function () { // todo + // show 'loading' + this.$('.dirent-icon img').attr({ + 'src': app.config.mediaUrl + 'img/loading-icon.gif', + 'alt':'' + }); + // empty all models + this.dirView.dir.reset(); + // update url & dirents + var dir_url = this.$('.dir-link').attr("href"); + app.router.navigate(dir_url, {trigger: true}); // offer an url fragment + return false; + }, + + togglePopup: function () { + var icon = this.$('.more-op-icon'), + popup = this.$('.hidden-op'); + + if (popup.hasClass('hide')) { // the popup is not shown + + popup.css({'left': icon.position().left}); + if (icon.offset().top + popup.height() <= $('#main').offset().top + $('#main').height()) { + // below the icon + popup.css('top', icon.position().top + icon.height() + 3); + } else { + popup.css('bottom', icon.parent().outerHeight() - icon.position().top + 3); + } + + popup.removeClass('hide'); + app.globalState.noFileOpPopup = false; + app.globalState.popup_tr = icon.parents('tr'); + } else { + popup.addClass('hide'); + app.globalState.noFileOpPopup = true; + app.globalState.popup_tr = ''; + } + }, + + share: function() { + var dir = this.dir, + obj_name = this.model.get('obj_name'), + dirent_path = Common.pathJoin([dir.path, obj_name]); + + var options = { + 'is_repo_owner': dir.is_repo_owner, + 'is_virtual': dir.is_virtual, + 'user_perm': dir.user_perm, + 'repo_id': dir.repo_id, + 'is_dir': this.model.get('is_dir') ? true : false, + 'dirent_path': dirent_path, + 'obj_name': obj_name + }; + new ShareView(options); + return false; + }, + + delete: function() { + var dirent_name = this.model.get('obj_name'); + var options = { + repo_id: this.dirView.dir.repo_id, + name: this.model.get('is_dir') ? 'del_dir' : 'del_file' + }; + var el = this.$el; + $.ajax({ + url: Common.getUrl(options) + '?parent_dir=' + encodeURIComponent(this.dirView.dir.path) + + '&name=' + encodeURIComponent(dirent_name), + dataType: 'json', + success: function(data) { + el.remove(); + app.globalState.noFileOpPopup = true; // make other items can work normally when hover + var msg = gettext("Successfully deleted %(name)s"); + msg = msg.replace('%(name)s', Common.HTMLescape(dirent_name)); + Common.feedback(msg, 'success'); + }, + error: Common.ajaxErrorHandler + }); + return false; + }, + + rename: function() { + var is_dir = this.model.get('is_dir'); + var title = is_dir ? gettext("Rename Directory") : gettext("Rename File"); + var dirent_name = this.model.get('obj_name'); + + var form = $(this.renameTemplate({ + form_title: title, + dirent_name: dirent_name + })); + form.modal({focus:false}); // For 'newname' input: if use the default 'focus:true', text in it will be selected. + $('#simplemodal-container').css({'width':'auto', 'height':'auto'}); + + var op_detail = $('.detail', form); + op_detail.html(op_detail.html().replace('%(name)s', '' + Common.HTMLescape(dirent_name) + '')); + + var form_id = form.attr('id'); + var _this = this; + var dir = this.dirView.dir; + form.submit(function() { + var new_name = $.trim($('[name="newname"]', form).val()); + if (!new_name) { + Common.showFormError(form_id, gettext("It is required.")); + return false; + } + if (new_name == dirent_name) { + Common.showFormError(form_id, gettext("You have not renamed it.")); + return false; + } + var post_data = { + 'oldname': dirent_name, + 'newname': new_name + }; + var post_url = Common.getUrl({ + name: is_dir ? 'rename_dir' : 'rename_file', + repo_id: dir.repo_id + }) + '?parent_dir=' + encodeURIComponent(dir.path); + var after_op_success = function (data) { + var renamed_dirent_data = { + 'obj_name': data['newname'], + 'last_modified': new Date().getTime()/1000, + 'last_update': gettext("Just now"), + 'sharelink': '', + 'sharetoken': '' + }; + if (is_dir) { + /* + $.extend(renamed_dirent_data, { + 'p_dpath': data['p_dpath'] + }); + */ + } else { + $.extend(renamed_dirent_data, { + 'starred': false + }); + } + $.modal.close(); + _this.model.set(renamed_dirent_data); // it will trigger 'change' event + }; + Common.ajaxPost({ + 'form': form, + 'post_url': post_url, + 'post_data': post_data, + 'after_op_success': after_op_success, + 'form_id': form_id + }); + return false; + }); + return false; + }, + + mvcp: function() { + var dir = this.dir; + var el = event.target || event.srcElement, + op_type = $(el).hasClass('mv') ? 'mv' : 'cp', + obj_name = this.model.get('obj_name'), + obj_type = this.model.get('is_dir') ? 'dir' : 'file'; + + var title = op_type == 'mv' ? gettext("Move {placeholder} to:") : gettext("Copy {placeholder} to:"); + title = title.replace('{placeholder}', '' + Common.HTMLescape(obj_name) + ''); + + var form = $(this.mvcpTemplate({ + form_title: title, + op_type: op_type, + obj_type: obj_type, + obj_name: obj_name, + show_other_repos: !dir.encrypted, + })); + form.modal({appendTo:'#main', autoResize:true, focus:false}); + $('#simplemodal-container').css({'width':'auto', 'height':'auto'}); + + FileTree.renderTreeForPath({ + repo_name: dir.repo_name, + repo_id: dir.repo_id, + path: dir.path + }); + if (!dir.encrypted) { + FileTree.prepareOtherReposTree({cur_repo_id: dir.repo_id}); + } + + var dirent = this.$el; + var _this = this; + form.submit(function() { + var form = $(this), + form_id = form.attr('id'), + path = dir.path, + repo_id = dir.repo_id; + var dst_repo = $('[name="dst_repo"]', form).val(), + dst_path = $('[name="dst_path"]', form).val(), + op = $('[name="op"]', form).val(), + obj_name = $('[name="obj_name"]', form).val(), + obj_type = $('[name="obj_type"]', form).val(); + + if (!$.trim(dst_repo) || !$.trim(dst_path)) { + $('.error', form).removeClass('hide'); + return false; + } + if (dst_repo == repo_id && (dst_path == path || (obj_type == 'dir' && dst_path == path + obj_name + '/'))) { + $('.error', form).html(gettext("Invalid destination path")).removeClass('hide'); + return false; + } + var options = { repo_id: repo_id }; + if (obj_type == 'dir') { + options.name = op == 'mv' ? 'mv_dir' : 'cp_dir'; + } else { + options.name = op == 'mv' ? 'mv_file' : 'cp_file'; + } + var post_url = Common.getUrl(options) + '?path=' + encodeURIComponent(path) + '&obj_name=' + encodeURIComponent(obj_name); + var post_data = { + 'dst_repo': dst_repo, + 'dst_path': dst_path + }; + var after_op_success = function(data) { + $.modal.close(); + var msg = data['msg']; + if (!data['task_id']) { // no progress + if (op == 'mv') { + dirent.remove(); + } + Common.feedback(msg, 'success'); + } else { + var mv_progress_popup = $(_this.mvProgressTemplate()); + var details = $('#mv-details', mv_progress_popup), + cancel_btn = $('#cancel-mv', mv_progress_popup), + other_info = $('#mv-other-info', mv_progress_popup); + cancel_btn.removeClass('hide'); + setTimeout(function () { + mv_progress_popup.modal({containerCss: { + width: 300, + height: 150, + paddingTop: 50 + }, focus:false}); + var det_text = op == 'mv' ? gettext("Moving %(name)s") : gettext("Copying %(name)s"); + details.html(det_text.replace('%(name)s', Common.HTMLescape(obj_name))).removeClass('vh'); + $('#mv-progress').progressbar(); + req_progress(); + }, 100); + var req_progress = function () { + $.ajax({ + url: Common.getUrl({name: 'get_cp_progress'}) + '?task_id=' + encodeURIComponent(data['task_id']), + dataType: 'json', + success: function(data) { + var bar = $('.ui-progressbar-value', $('#mv-progress')); + if (!data['failed'] && !data['canceled'] && !data['successful']) { + if (data['done'] == data['total']) { + bar.css('width', '100%'); // 'done' and 'total' can be both 0 + details.addClass('vh'); + cancel_btn.addClass('hide'); + other_info.html(gettext("Saving...")).removeClass('hide'); + } else { + bar.css('width', parseInt(data['done']/data['total']*100, 10) + '%'); + } + bar.show(); + setTimeout(req_progress, 1000); + } else if (data['successful']) { + $.modal.close(); + if (op == 'mv') { + dirent.remove(); + } + Common.feedback(msg, 'success'); + } else { // failed or canceled + details.addClass('vh'); + var other_msg = data['failed'] ? gettext("Failed.") : gettext("Canceled."); + other_info.html(other_msg).removeClass('hide'); + cancel_btn.addClass('hide'); + setTimeout(function () { $.modal.close(); }, 1000); + } + }, + error: function(xhr, textStatus, errorThrown) { + var error; + if (xhr.responseText) { + error = $.parseJSON(xhr.responseText).error; + } else { + error = gettext("Failed. Please check the network."); + } + details.addClass('vh') + other_info.html(error).removeClass('hide'); + cancel_btn.addClass('hide'); + setTimeout(function () { $.modal.close(); }, 1000); + } + }); + }; + + cancel_btn.click(function() { + Common.disableButton(cancel_btn); + $.ajax({ + url: Common.getUrl({name: 'cancel_cp'}) + '?task_id=' + encodeURIComponent(data['task_id']), + dataType: 'json', + success: function(data) { + details.addClass('vh') + other_info.html(gettext("Canceled.")).removeClass('hide'); + cancel_btn.addClass('hide'); + setTimeout(function () {$.modal.close();}, 1000); + }, + error: function(xhr, textStatus, errorThrown) { + var error; + if (xhr.responseText) { + error = $.parseJSON(xhr.responseText).error; + } else { + error = gettext("Failed. Please check the network."); + } + other_info.html(error).removeClass('hide'); + Common.enableButton(cancel_btn); + } + }); + }); + } + } + Common.ajaxPost({ + 'form': form, + 'post_url': post_url, + 'post_data': post_data, + 'after_op_success': after_op_success, + 'form_id': form_id + }); + return false; + }); + return false; + }, + + setFolderPerm: function() { + var options = { + 'obj_name': this.model.get('obj_name'), + 'dir_path': this.dir.path, + 'repo_id': this.dir.repo_id + }; + new FolderPermView(options); + return false; + } + + }); + + return DirentView; +}); diff --git a/media/assets/scripts/app/views/fileupload.a40f2a483bc0.js b/media/assets/scripts/app/views/fileupload.a40f2a483bc0.js new file mode 100644 index 0000000000..618935ec45 --- /dev/null +++ b/media/assets/scripts/app/views/fileupload.a40f2a483bc0.js @@ -0,0 +1,460 @@ +define([ + 'common', + 'backbone', + 'jquery.fileupload-ui' +], function(Common, Backbone, FileUpload) { + + window.locale = { + "fileupload": { + "errors": { + "maxFileSize": gettext("File is too big"), + "minFileSize": gettext("File is too small"), + "acceptFileTypes": gettext("Filetype not allowed"), + "maxNumberOfFiles": gettext("Max number of files exceeded"), + "uploadedBytes": gettext("Uploaded bytes exceed file size"), + "emptyResult": gettext("Empty file upload result") + }, + "error": gettext("Error"), + "uploaded": gettext("uploaded"), + "canceled": gettext("canceled"), + "start": gettext("Start"), + "cancel": gettext("Cancel"), + "destroy": gettext("Delete") + } + }; + + var FileUploadView = Backbone.View.extend({ + el: $('#upload-file-dialog'), + + fileupdateConfirmTemplate: _.template($("#fileupdate-confirm-template").html()), + + initialize: function (options) { + var dirView = this.dirView = options.dirView; + var dirents = dirView.dir; + + var popup = this.$el.addClass('fixed-upload-file-dialog'); + + this.popup_height = '200px'; + + var $fu_status = $('.status', popup), + $total_progress = $('.total-progress', popup), + cancel_all_btn = $('.fileupload-buttonbar .cancel', popup), + close_icon = $('.close', popup), + saving_tip = $('.saving-tip', popup); + + var fu_status = { + 'uploading': gettext("File Uploading..."), + 'complete': gettext("File Upload complete"), + 'canceled': gettext("File Upload canceled"), + 'failed': gettext("File Upload failed") + }; + + var uploaded_files = []; + var updated_files = []; + + var enable_upload_folder = app.pageOptions.enable_upload_folder; + var new_dir_names = []; + var dirs_to_update = []; + + var _this = this; + popup.fileupload({ + paramName: 'file', + // customize it for 'done' + getFilesFromResponse: function (data) { + if (data.result) { + return data.result; + } + }, + autoUpload:true, + maxNumberOfFiles: 500, + sequentialUploads: true + }) + .bind('fileuploadadd', function(e, data) { + // for drag & drop + if (!dirView.$el.is(':visible')) { + return false; + } + if (dirents.user_perm && dirents.user_perm != 'rw') { + return false; + } + popup.removeClass('hide'); + cancel_all_btn.removeClass('hide'); + close_icon.addClass('hide'); + var path = dirents.path; + popup.fileupload('option', 'formData', { + 'parent_dir': path == '/' ? path : path + '/' + }); + + if (!enable_upload_folder) { + return; + } + // hide the upload menu + var menu = dirView.$('#upload-menu'); + if (!menu.hasClass('hide')) { + menu.find('.item').removeAttr('style') + .end().addClass('hide'); + } + + var file = data.files[0]; + + // add folder by clicking 'Upload Folder' + if (file.name == '.') { // a subdirectory will be shown as '.' + data.files.shift(); + return; + } + if (file.webkitRelativePath) { + file.relative_path = file.webkitRelativePath; + } + + // add folder by drag & drop + if (file.relativePath) { + file.relative_path = file.relativePath + file.name; + } + }) + .bind('fileuploadstart', function() { + $fu_status.html(fu_status.uploading); + }) + .bind('fileuploadsubmit', function(e, data) { + if (data.files.length == 0) { + return false; + } + var file = data.files[0]; + if (file.error) { + return false; + } + + var upload_file = function() { + $.ajax({ + url: Common.getUrl({ + name: 'get_file_op_url', + repo_id: dirents.repo_id + }), + data: { + 'op_type': 'upload', + 'path': dirents.path + }, + cache: false, + dataType: 'json', + success: function(ret) { + if (enable_upload_folder) { + var file_path = file.relative_path, + r_path; + if (file_path) { // 'add folder' + r_path = file_path.substring(0, file_path.lastIndexOf('/') + 1); + } + var formData = popup.fileupload('option', 'formData'); + formData.relative_path = r_path || ''; + popup.fileupload('option', 'formData', formData); + } + data.url = ret['url']; + data.jqXHR = popup.fileupload('send', data); + }, + error: function() { + file.error = gettext("Failed to get upload url"); + } + }); + }; + + if (file.relative_path || data.originalFiles.length > 1) { // 'add folder' or upload more than 1 file once + upload_file(); + return false; + } + + var update_file = function() { + $.ajax({ + url: Common.getUrl({ + name: 'get_file_op_url', + repo_id: dirents.repo_id + }), + data: { + 'op_type': 'update', + 'path': dirents.path + }, + cache: false, + dataType: 'json', + success: function(ret) { + var formData = popup.fileupload('option', 'formData'); + formData.target_file = formData.parent_dir + file.name; + popup.fileupload('option', 'formData', formData); + + file.to_update = true; + + data.url = ret['url']; + data.jqXHR = popup.fileupload('send', data); + }, + error: function() { + file.error = gettext("Failed to get update url"); + } + }); + }; + + var files = dirents.where({'is_file': true}), + file_names = []; + $(files).each(function() { + file_names.push(this.get('obj_name')); + }); + if (file_names.indexOf(file.name) != -1) { // file with the same name already exists in the dir + var confirm_title = gettext("Replace file {filename}?") + .replace('{filename}', '' + Common.HTMLescape(file.name) + ''); + var confirm_popup = $(_this.fileupdateConfirmTemplate({ + title: confirm_title + })); + confirm_popup.modal({ + onClose: function() { + $.modal.close(); + if (file.choose_to_update) { + update_file(); + } else if (file.choose_to_upload) { + upload_file(); + } else { + data.jqXHR = popup.fileupload('send', data); + data.jqXHR.abort(); + } + } + }); + $('.yes', confirm_popup).click(function() { + file.choose_to_update = true; + $.modal.close(); + }); + $('.no', confirm_popup).click(function() { + file.choose_to_upload = true; + $.modal.close(); + }); + } else { + upload_file(); + } + return false; + }) + .bind('fileuploadprogressall', function (e, data) { + $total_progress.html(parseInt(data.loaded / data.total * 100, 10) + '% ' + + '(' + + $(this).data('blueimp-fileupload')._formatBitrate(data.bitrate) + + ')').removeClass('hide'); + if (data.loaded > 0 && data.loaded == data.total) { + saving_tip.show(); + } + }) + .bind('fileuploaddone', function(e, data) { + if (data.textStatus != 'success') { + return; + } + var file = data.files[0]; + var file_path = file.relative_path; + var file_uploaded = data.result[0]; // 'id', 'name', 'size' + // for 'template_download' render + file_uploaded.uploaded = true; + if (file_path) { + file_uploaded.relative_path = file_path.substring(0, file_path.lastIndexOf('/') + 1) + file_uploaded.name; + } + var path = dirents.path; + path = path == '/' ? path : path + '/'; + if (data.formData.parent_dir != path) { + return; + } + if (!file_path) { + if (!file.to_update) { + uploaded_files.push(file_uploaded); + } else { + updated_files.push(file_uploaded); + } + return; + } + if (!enable_upload_folder) { + return; + } + // for 'add folder' + var dir_name = file_path.substring(0, file_path.indexOf('/')); + var dir = dirents.where({'is_dir': true, 'obj_name': dir_name}); + if (dir.length > 0) { // 0 or 1 + if (dirs_to_update.indexOf(dir_name) == -1) { + dirs_to_update.push(dir_name); + } + } else { + if (new_dir_names.indexOf(dir_name) == -1) { + new_dir_names.push(dir_name); + } + } + }) + .bind('fileuploadstop', function () { + cancel_all_btn.addClass('hide'); + close_icon.removeClass('hide'); + var path = dirents.path; + path = path == '/' ? path : path + '/'; + if (popup.fileupload('option','formData').parent_dir != path) { + return; + } + var now = parseInt(new Date().getTime()/1000); + if (uploaded_files.length > 0) { + $(uploaded_files).each(function(index, file) { + var new_dirent = dirents.add({ + 'is_file': true, + 'is_img': Common.imageCheck(file.name), + 'obj_name': file.name, + 'last_modified': now, + 'file_size': Common.fileSizeFormat(file.size, 1), + 'obj_id': file.id, + 'file_icon': 'file.png', + 'last_update': gettext("Just now"), + 'starred': false + }, {silent: true}); + dirView.addNewFile(new_dirent); + }); + uploaded_files = []; + } + if (new_dir_names.length > 0) { + $(new_dir_names).each(function(index, new_name) { + var new_dirent = dirents.add({ + 'is_dir': true, + 'obj_name': new_name, + 'last_modified': now, + 'last_update': gettext("Just now"), + 'p_dpath': path + new_name + }, {silent: true}); + dirView.addNewDir(new_dirent); + }); + new_dir_names = []; + } + if (dirs_to_update.length > 0) { + $(dirs_to_update).each(function(index, dir_name) { + var dir_to_update = dirents.where({'is_dir':true, 'obj_name':dir_name}); + dir_to_update[0].set({ + 'last_modified': now, + 'last_update': gettext("Just now") + }); + }); + dirs_to_update = []; + } + if (updated_files.length > 0) { + $(updated_files).each(function(index, item) { + var file_to_update = dirents.where({'is_file':true, 'obj_name':item.name}); + file_to_update[0].set({ + 'obj_id': item.id, + 'file_size': Common.fileSizeFormat(item.size, 1), + 'last_modified': now, + 'last_update': gettext("Just now") + }); + }); + updated_files = []; + } + }) + // after tpl has rendered + .bind('fileuploadcompleted', function() { // 'done' + if ($('.files .cancel', popup).length == 0) { + saving_tip.hide(); + $total_progress.addClass('hide'); + $fu_status.html(fu_status.complete); + } + }) + .bind('fileuploadfailed', function(e, data) { // 'fail' + if ($('.files .cancel', popup).length == 0) { + cancel_all_btn.addClass('hide'); + close_icon.removeClass('hide'); + $total_progress.addClass('hide'); + saving_tip.hide(); + if (data.errorThrown == 'abort') { // 'cancel' + $fu_status.html(fu_status.canceled); + } else { // 'error' + $fu_status.html(fu_status.failed); + } + } + }); + + var max_upload_file_size = app.pageOptions.max_upload_file_size; + if (max_upload_file_size) { + popup.fileupload( + 'option', + 'maxFileSize', + max_upload_file_size); + } + + // Enable iframe cross-domain access via redirect option: + popup.fileupload( + 'option', + 'redirect', + window.location.href.replace(/\/repo\/[-a-z0-9]{36}\/.*/, app.config.mediaUrl + 'cors/result.html?%s') + ); + + $(document).click(function(e) { + var target = e.target || event.srcElement; + var closePopup = function(popup, popup_switch) { + if (!popup.hasClass('hide') && !popup.is(target) && !popup.find('*').is(target) && !popup_switch.is(target) && !popup_switch.find('*').is(target) ) { + popup.addClass('hide'); + } + }; + closePopup(dirView.$('#upload-menu'), dirView.$('#upload-file')); + }); + }, + + events: { + 'click .fold-switch': 'foldAndUnfoldPopup', + 'click .close': 'closePopup' + }, + + foldAndUnfoldPopup : function () { + var popup = this.$el; + var full_ht = parseInt(this.popup_height); + var main_con = $('.fileupload-buttonbar, .table', popup); + if (popup.height() == full_ht) { + popup.height($('.hd', popup).outerHeight(true)); + main_con.addClass('hide'); + } else { + popup.height(full_ht); + main_con.removeClass('hide'); + } + }, + + closePopup: function () { + var popup = this.$el; + popup.addClass('hide'); + $('.files', popup).empty(); + }, + + setFileInput: function () { + var dirView = this.dirView, + dir = dirView.dir; + + var popup = this.$el; + if (dir.user_perm && dir.user_perm == 'rw') { + popup.fileupload( + 'option', + 'fileInput', + dirView.$('#upload-file input')); + } + if (!app.pageOptions.enable_upload_folder) { + return; + } + var upload_btn = dirView.$('#upload-file'), + upload_menu = dirView.$('#upload-menu'); + + if (dir.user_perm && dir.user_perm == 'rw' && + 'webkitdirectory' in $('input[type="file"]', upload_btn)[0]) { + upload_btn.find('input').remove().end().addClass('cspt'); + $('.item', upload_menu).click(function() { + popup.fileupload( + 'option', + 'fileInput', + $('input[type="file"]', $(this)) + ); + }) + .hover( + function() { + $(this).css({'background':'#f3f3f3'}); + }, + function() { + $(this).css({'background':'transparent'}); + } + ); + dirView.$('.repo-op').css({'position': 'relative'}); + upload_menu.css({ + 'left': upload_btn.position().left, + 'top': parseInt(dirView.$('.repo-op').css('padding-top')) + upload_btn.outerHeight(true) + }); + upload_btn.click(function () { + upload_menu.toggleClass('hide'); + }); + } + } + }); + + return FileUploadView; +}); diff --git a/media/assets/scripts/app/views/fileupload.js b/media/assets/scripts/app/views/fileupload.js new file mode 100644 index 0000000000..618935ec45 --- /dev/null +++ b/media/assets/scripts/app/views/fileupload.js @@ -0,0 +1,460 @@ +define([ + 'common', + 'backbone', + 'jquery.fileupload-ui' +], function(Common, Backbone, FileUpload) { + + window.locale = { + "fileupload": { + "errors": { + "maxFileSize": gettext("File is too big"), + "minFileSize": gettext("File is too small"), + "acceptFileTypes": gettext("Filetype not allowed"), + "maxNumberOfFiles": gettext("Max number of files exceeded"), + "uploadedBytes": gettext("Uploaded bytes exceed file size"), + "emptyResult": gettext("Empty file upload result") + }, + "error": gettext("Error"), + "uploaded": gettext("uploaded"), + "canceled": gettext("canceled"), + "start": gettext("Start"), + "cancel": gettext("Cancel"), + "destroy": gettext("Delete") + } + }; + + var FileUploadView = Backbone.View.extend({ + el: $('#upload-file-dialog'), + + fileupdateConfirmTemplate: _.template($("#fileupdate-confirm-template").html()), + + initialize: function (options) { + var dirView = this.dirView = options.dirView; + var dirents = dirView.dir; + + var popup = this.$el.addClass('fixed-upload-file-dialog'); + + this.popup_height = '200px'; + + var $fu_status = $('.status', popup), + $total_progress = $('.total-progress', popup), + cancel_all_btn = $('.fileupload-buttonbar .cancel', popup), + close_icon = $('.close', popup), + saving_tip = $('.saving-tip', popup); + + var fu_status = { + 'uploading': gettext("File Uploading..."), + 'complete': gettext("File Upload complete"), + 'canceled': gettext("File Upload canceled"), + 'failed': gettext("File Upload failed") + }; + + var uploaded_files = []; + var updated_files = []; + + var enable_upload_folder = app.pageOptions.enable_upload_folder; + var new_dir_names = []; + var dirs_to_update = []; + + var _this = this; + popup.fileupload({ + paramName: 'file', + // customize it for 'done' + getFilesFromResponse: function (data) { + if (data.result) { + return data.result; + } + }, + autoUpload:true, + maxNumberOfFiles: 500, + sequentialUploads: true + }) + .bind('fileuploadadd', function(e, data) { + // for drag & drop + if (!dirView.$el.is(':visible')) { + return false; + } + if (dirents.user_perm && dirents.user_perm != 'rw') { + return false; + } + popup.removeClass('hide'); + cancel_all_btn.removeClass('hide'); + close_icon.addClass('hide'); + var path = dirents.path; + popup.fileupload('option', 'formData', { + 'parent_dir': path == '/' ? path : path + '/' + }); + + if (!enable_upload_folder) { + return; + } + // hide the upload menu + var menu = dirView.$('#upload-menu'); + if (!menu.hasClass('hide')) { + menu.find('.item').removeAttr('style') + .end().addClass('hide'); + } + + var file = data.files[0]; + + // add folder by clicking 'Upload Folder' + if (file.name == '.') { // a subdirectory will be shown as '.' + data.files.shift(); + return; + } + if (file.webkitRelativePath) { + file.relative_path = file.webkitRelativePath; + } + + // add folder by drag & drop + if (file.relativePath) { + file.relative_path = file.relativePath + file.name; + } + }) + .bind('fileuploadstart', function() { + $fu_status.html(fu_status.uploading); + }) + .bind('fileuploadsubmit', function(e, data) { + if (data.files.length == 0) { + return false; + } + var file = data.files[0]; + if (file.error) { + return false; + } + + var upload_file = function() { + $.ajax({ + url: Common.getUrl({ + name: 'get_file_op_url', + repo_id: dirents.repo_id + }), + data: { + 'op_type': 'upload', + 'path': dirents.path + }, + cache: false, + dataType: 'json', + success: function(ret) { + if (enable_upload_folder) { + var file_path = file.relative_path, + r_path; + if (file_path) { // 'add folder' + r_path = file_path.substring(0, file_path.lastIndexOf('/') + 1); + } + var formData = popup.fileupload('option', 'formData'); + formData.relative_path = r_path || ''; + popup.fileupload('option', 'formData', formData); + } + data.url = ret['url']; + data.jqXHR = popup.fileupload('send', data); + }, + error: function() { + file.error = gettext("Failed to get upload url"); + } + }); + }; + + if (file.relative_path || data.originalFiles.length > 1) { // 'add folder' or upload more than 1 file once + upload_file(); + return false; + } + + var update_file = function() { + $.ajax({ + url: Common.getUrl({ + name: 'get_file_op_url', + repo_id: dirents.repo_id + }), + data: { + 'op_type': 'update', + 'path': dirents.path + }, + cache: false, + dataType: 'json', + success: function(ret) { + var formData = popup.fileupload('option', 'formData'); + formData.target_file = formData.parent_dir + file.name; + popup.fileupload('option', 'formData', formData); + + file.to_update = true; + + data.url = ret['url']; + data.jqXHR = popup.fileupload('send', data); + }, + error: function() { + file.error = gettext("Failed to get update url"); + } + }); + }; + + var files = dirents.where({'is_file': true}), + file_names = []; + $(files).each(function() { + file_names.push(this.get('obj_name')); + }); + if (file_names.indexOf(file.name) != -1) { // file with the same name already exists in the dir + var confirm_title = gettext("Replace file {filename}?") + .replace('{filename}', '' + Common.HTMLescape(file.name) + ''); + var confirm_popup = $(_this.fileupdateConfirmTemplate({ + title: confirm_title + })); + confirm_popup.modal({ + onClose: function() { + $.modal.close(); + if (file.choose_to_update) { + update_file(); + } else if (file.choose_to_upload) { + upload_file(); + } else { + data.jqXHR = popup.fileupload('send', data); + data.jqXHR.abort(); + } + } + }); + $('.yes', confirm_popup).click(function() { + file.choose_to_update = true; + $.modal.close(); + }); + $('.no', confirm_popup).click(function() { + file.choose_to_upload = true; + $.modal.close(); + }); + } else { + upload_file(); + } + return false; + }) + .bind('fileuploadprogressall', function (e, data) { + $total_progress.html(parseInt(data.loaded / data.total * 100, 10) + '% ' + + '(' + + $(this).data('blueimp-fileupload')._formatBitrate(data.bitrate) + + ')').removeClass('hide'); + if (data.loaded > 0 && data.loaded == data.total) { + saving_tip.show(); + } + }) + .bind('fileuploaddone', function(e, data) { + if (data.textStatus != 'success') { + return; + } + var file = data.files[0]; + var file_path = file.relative_path; + var file_uploaded = data.result[0]; // 'id', 'name', 'size' + // for 'template_download' render + file_uploaded.uploaded = true; + if (file_path) { + file_uploaded.relative_path = file_path.substring(0, file_path.lastIndexOf('/') + 1) + file_uploaded.name; + } + var path = dirents.path; + path = path == '/' ? path : path + '/'; + if (data.formData.parent_dir != path) { + return; + } + if (!file_path) { + if (!file.to_update) { + uploaded_files.push(file_uploaded); + } else { + updated_files.push(file_uploaded); + } + return; + } + if (!enable_upload_folder) { + return; + } + // for 'add folder' + var dir_name = file_path.substring(0, file_path.indexOf('/')); + var dir = dirents.where({'is_dir': true, 'obj_name': dir_name}); + if (dir.length > 0) { // 0 or 1 + if (dirs_to_update.indexOf(dir_name) == -1) { + dirs_to_update.push(dir_name); + } + } else { + if (new_dir_names.indexOf(dir_name) == -1) { + new_dir_names.push(dir_name); + } + } + }) + .bind('fileuploadstop', function () { + cancel_all_btn.addClass('hide'); + close_icon.removeClass('hide'); + var path = dirents.path; + path = path == '/' ? path : path + '/'; + if (popup.fileupload('option','formData').parent_dir != path) { + return; + } + var now = parseInt(new Date().getTime()/1000); + if (uploaded_files.length > 0) { + $(uploaded_files).each(function(index, file) { + var new_dirent = dirents.add({ + 'is_file': true, + 'is_img': Common.imageCheck(file.name), + 'obj_name': file.name, + 'last_modified': now, + 'file_size': Common.fileSizeFormat(file.size, 1), + 'obj_id': file.id, + 'file_icon': 'file.png', + 'last_update': gettext("Just now"), + 'starred': false + }, {silent: true}); + dirView.addNewFile(new_dirent); + }); + uploaded_files = []; + } + if (new_dir_names.length > 0) { + $(new_dir_names).each(function(index, new_name) { + var new_dirent = dirents.add({ + 'is_dir': true, + 'obj_name': new_name, + 'last_modified': now, + 'last_update': gettext("Just now"), + 'p_dpath': path + new_name + }, {silent: true}); + dirView.addNewDir(new_dirent); + }); + new_dir_names = []; + } + if (dirs_to_update.length > 0) { + $(dirs_to_update).each(function(index, dir_name) { + var dir_to_update = dirents.where({'is_dir':true, 'obj_name':dir_name}); + dir_to_update[0].set({ + 'last_modified': now, + 'last_update': gettext("Just now") + }); + }); + dirs_to_update = []; + } + if (updated_files.length > 0) { + $(updated_files).each(function(index, item) { + var file_to_update = dirents.where({'is_file':true, 'obj_name':item.name}); + file_to_update[0].set({ + 'obj_id': item.id, + 'file_size': Common.fileSizeFormat(item.size, 1), + 'last_modified': now, + 'last_update': gettext("Just now") + }); + }); + updated_files = []; + } + }) + // after tpl has rendered + .bind('fileuploadcompleted', function() { // 'done' + if ($('.files .cancel', popup).length == 0) { + saving_tip.hide(); + $total_progress.addClass('hide'); + $fu_status.html(fu_status.complete); + } + }) + .bind('fileuploadfailed', function(e, data) { // 'fail' + if ($('.files .cancel', popup).length == 0) { + cancel_all_btn.addClass('hide'); + close_icon.removeClass('hide'); + $total_progress.addClass('hide'); + saving_tip.hide(); + if (data.errorThrown == 'abort') { // 'cancel' + $fu_status.html(fu_status.canceled); + } else { // 'error' + $fu_status.html(fu_status.failed); + } + } + }); + + var max_upload_file_size = app.pageOptions.max_upload_file_size; + if (max_upload_file_size) { + popup.fileupload( + 'option', + 'maxFileSize', + max_upload_file_size); + } + + // Enable iframe cross-domain access via redirect option: + popup.fileupload( + 'option', + 'redirect', + window.location.href.replace(/\/repo\/[-a-z0-9]{36}\/.*/, app.config.mediaUrl + 'cors/result.html?%s') + ); + + $(document).click(function(e) { + var target = e.target || event.srcElement; + var closePopup = function(popup, popup_switch) { + if (!popup.hasClass('hide') && !popup.is(target) && !popup.find('*').is(target) && !popup_switch.is(target) && !popup_switch.find('*').is(target) ) { + popup.addClass('hide'); + } + }; + closePopup(dirView.$('#upload-menu'), dirView.$('#upload-file')); + }); + }, + + events: { + 'click .fold-switch': 'foldAndUnfoldPopup', + 'click .close': 'closePopup' + }, + + foldAndUnfoldPopup : function () { + var popup = this.$el; + var full_ht = parseInt(this.popup_height); + var main_con = $('.fileupload-buttonbar, .table', popup); + if (popup.height() == full_ht) { + popup.height($('.hd', popup).outerHeight(true)); + main_con.addClass('hide'); + } else { + popup.height(full_ht); + main_con.removeClass('hide'); + } + }, + + closePopup: function () { + var popup = this.$el; + popup.addClass('hide'); + $('.files', popup).empty(); + }, + + setFileInput: function () { + var dirView = this.dirView, + dir = dirView.dir; + + var popup = this.$el; + if (dir.user_perm && dir.user_perm == 'rw') { + popup.fileupload( + 'option', + 'fileInput', + dirView.$('#upload-file input')); + } + if (!app.pageOptions.enable_upload_folder) { + return; + } + var upload_btn = dirView.$('#upload-file'), + upload_menu = dirView.$('#upload-menu'); + + if (dir.user_perm && dir.user_perm == 'rw' && + 'webkitdirectory' in $('input[type="file"]', upload_btn)[0]) { + upload_btn.find('input').remove().end().addClass('cspt'); + $('.item', upload_menu).click(function() { + popup.fileupload( + 'option', + 'fileInput', + $('input[type="file"]', $(this)) + ); + }) + .hover( + function() { + $(this).css({'background':'#f3f3f3'}); + }, + function() { + $(this).css({'background':'transparent'}); + } + ); + dirView.$('.repo-op').css({'position': 'relative'}); + upload_menu.css({ + 'left': upload_btn.position().left, + 'top': parseInt(dirView.$('.repo-op').css('padding-top')) + upload_btn.outerHeight(true) + }); + upload_btn.click(function () { + upload_menu.toggleClass('hide'); + }); + } + } + }); + + return FileUploadView; +}); diff --git a/media/assets/scripts/app/views/folder-perm-item.781a1d6e78cb.js b/media/assets/scripts/app/views/folder-perm-item.781a1d6e78cb.js new file mode 100644 index 0000000000..c943582a6b --- /dev/null +++ b/media/assets/scripts/app/views/folder-perm-item.781a1d6e78cb.js @@ -0,0 +1,138 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common' +], function($, _, Backbone, Common) { + 'use strict'; + + var FolderPermItemView = Backbone.View.extend({ + tagName: 'tr', + + template: _.template($('#folder-perm-item-tmpl').html()), + + initialize: function(options) { + this.item_data = options.item_data; + this.repo_id = options.repo_id; + this.path = options.path; + + this.render(); + }, + + render: function () { + this.$el.html(this.template(this.item_data)); + return this; + }, + + events: { + 'mouseenter': 'showPermOpIcons', + 'mouseleave': 'hidePermOpIcons', + 'click .perm-edit-icon': 'editIconClick', + 'change .perm-toggle-select': 'editPerm', + 'click .perm-delete-icon': 'deletePerm' + }, + + showPermOpIcons: function () { + this.$el.find('.op-icon').removeClass('vh'); + }, + + hidePermOpIcons: function () { + this.$el.find('.op-icon').addClass('vh'); + }, + + editIconClick: function (e) { + $(e.currentTarget).closest('td') + .find('.perm').addClass('hide').end() + .find('.perm-toggle-select').removeClass('hide'); + }, + + editPerm: function (e) { + var _this = this; + var perm = $(e.currentTarget).val(); + var post_data = { + 'perm': perm, + 'path': this.path, + 'type': 'modify' + }; + var is_user_perm = this.item_data.is_user_perm; + if (is_user_perm) { + $.extend(post_data, {'user': this.item_data.user}); + } else { + $.extend(post_data, {'group_id': this.item_data.group_id}); + } + $.ajax({ + url: Common.getUrl({ + name: is_user_perm ? 'set_user_folder_perm' : 'set_group_folder_perm', + repo_id: this.repo_id + }), + type: 'POST', + dataType: 'json', + cache: false, + beforeSend: Common.prepareCSRFToken, + data: post_data, + success: function() { + _this.item_data.perm = perm; + _this.render(); + }, + error: function(xhr) { + var err; + if (xhr.responseText) { + err = $.parseJSON(xhr.responseText).error; + } else { + err = gettext("Failed. Please check the network."); + } + if (is_user_perm) { + $('#user-folder-perm .error').html(err).removeClass('hide'); + } else { + $('#group-folder-perm .error').html(err).removeClass('hide'); + } + } + }); + }, + + deletePerm: function () { + var _this = this; + var post_data = { + 'perm': this.item_data.perm, + 'path': this.path, + 'type': 'delete' + }; + var is_user_perm = this.item_data.is_user_perm; + if (is_user_perm) { + $.extend(post_data, {'user': this.item_data.user}); + } else { + $.extend(post_data, {'group_id': this.item_data.group_id}); + } + $.ajax({ + url: Common.getUrl({ + name: is_user_perm ? 'set_user_folder_perm' : 'set_group_folder_perm', + repo_id: this.repo_id + }), + type: 'POST', + dataType: 'json', + cache: false, + beforeSend: Common.prepareCSRFToken, + data: post_data, + success: function() { + _this.remove(); + }, + error: function(xhr) { + var err; + if (xhr.responseText) { + err = $.parseJSON(xhr.responseText).error; + } else { + err = gettext("Failed. Please check the network."); + } + if (is_user_perm) { + $('#user-folder-perm .error').html(err).removeClass('hide'); + } else { + $('#group-folder-perm .error').html(err).removeClass('hide'); + } + } + }); + } + + }); + + return FolderPermItemView; +}); diff --git a/media/assets/scripts/app/views/folder-perm-item.js b/media/assets/scripts/app/views/folder-perm-item.js new file mode 100644 index 0000000000..c943582a6b --- /dev/null +++ b/media/assets/scripts/app/views/folder-perm-item.js @@ -0,0 +1,138 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common' +], function($, _, Backbone, Common) { + 'use strict'; + + var FolderPermItemView = Backbone.View.extend({ + tagName: 'tr', + + template: _.template($('#folder-perm-item-tmpl').html()), + + initialize: function(options) { + this.item_data = options.item_data; + this.repo_id = options.repo_id; + this.path = options.path; + + this.render(); + }, + + render: function () { + this.$el.html(this.template(this.item_data)); + return this; + }, + + events: { + 'mouseenter': 'showPermOpIcons', + 'mouseleave': 'hidePermOpIcons', + 'click .perm-edit-icon': 'editIconClick', + 'change .perm-toggle-select': 'editPerm', + 'click .perm-delete-icon': 'deletePerm' + }, + + showPermOpIcons: function () { + this.$el.find('.op-icon').removeClass('vh'); + }, + + hidePermOpIcons: function () { + this.$el.find('.op-icon').addClass('vh'); + }, + + editIconClick: function (e) { + $(e.currentTarget).closest('td') + .find('.perm').addClass('hide').end() + .find('.perm-toggle-select').removeClass('hide'); + }, + + editPerm: function (e) { + var _this = this; + var perm = $(e.currentTarget).val(); + var post_data = { + 'perm': perm, + 'path': this.path, + 'type': 'modify' + }; + var is_user_perm = this.item_data.is_user_perm; + if (is_user_perm) { + $.extend(post_data, {'user': this.item_data.user}); + } else { + $.extend(post_data, {'group_id': this.item_data.group_id}); + } + $.ajax({ + url: Common.getUrl({ + name: is_user_perm ? 'set_user_folder_perm' : 'set_group_folder_perm', + repo_id: this.repo_id + }), + type: 'POST', + dataType: 'json', + cache: false, + beforeSend: Common.prepareCSRFToken, + data: post_data, + success: function() { + _this.item_data.perm = perm; + _this.render(); + }, + error: function(xhr) { + var err; + if (xhr.responseText) { + err = $.parseJSON(xhr.responseText).error; + } else { + err = gettext("Failed. Please check the network."); + } + if (is_user_perm) { + $('#user-folder-perm .error').html(err).removeClass('hide'); + } else { + $('#group-folder-perm .error').html(err).removeClass('hide'); + } + } + }); + }, + + deletePerm: function () { + var _this = this; + var post_data = { + 'perm': this.item_data.perm, + 'path': this.path, + 'type': 'delete' + }; + var is_user_perm = this.item_data.is_user_perm; + if (is_user_perm) { + $.extend(post_data, {'user': this.item_data.user}); + } else { + $.extend(post_data, {'group_id': this.item_data.group_id}); + } + $.ajax({ + url: Common.getUrl({ + name: is_user_perm ? 'set_user_folder_perm' : 'set_group_folder_perm', + repo_id: this.repo_id + }), + type: 'POST', + dataType: 'json', + cache: false, + beforeSend: Common.prepareCSRFToken, + data: post_data, + success: function() { + _this.remove(); + }, + error: function(xhr) { + var err; + if (xhr.responseText) { + err = $.parseJSON(xhr.responseText).error; + } else { + err = gettext("Failed. Please check the network."); + } + if (is_user_perm) { + $('#user-folder-perm .error').html(err).removeClass('hide'); + } else { + $('#group-folder-perm .error').html(err).removeClass('hide'); + } + } + }); + } + + }); + + return FolderPermItemView; +}); diff --git a/media/assets/scripts/app/views/folder-perm.02e63ba83d44.js b/media/assets/scripts/app/views/folder-perm.02e63ba83d44.js new file mode 100644 index 0000000000..03222162cc --- /dev/null +++ b/media/assets/scripts/app/views/folder-perm.02e63ba83d44.js @@ -0,0 +1,227 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common', + 'jquery.ui.tabs', + 'select2', + 'app/views/folder-perm-item' +], function($, _, Backbone, Common, Tabs, Select2, FolderPermItemView) { + 'use strict'; + + var FolderPermView = Backbone.View.extend({ + tagName: 'div', + id: 'folder-perm-popup', + + template: _.template($('#folder-perm-popup-tmpl').html()), + + initialize: function(options) { + this.repo_id = options.repo_id; + this.obj_name = options.obj_name; + this.dir_path = options.dir_path; + if (this.dir_path === '/') { + this.path = this.dir_path + this.obj_name; + } else { + this.path = this.dir_path + '/' + this.obj_name; + } + + this.render(); + + this.$el.modal({ + appendTo: "#main", + focus: false, + containerCss: {"padding": 0} + }); + $('#simplemodal-container').css({'width':'auto', 'height':'auto'}); + + this.$("#folder-perm-tabs").tabs(); + + this.panelsInit(); + + var _this = this; + $(document).on('click', function(e) { + var target = e.target || event.srcElement; + if (!_this.$('.perm-edit-icon, .perm-toggle-select').is(target)) { + _this.$('.perm').removeClass('hide'); + _this.$('.perm-toggle-select').addClass('hide'); + } + }); + }, + + render: function () { + this.$el.html(this.template({ + title: gettext("Set {placeholder}'s permission") + .replace('{placeholder}', '' + Common.HTMLescape(this.obj_name) + '') + })); + return this; + }, + + panelsInit: function() { + this.$add_user_perm = this.$('#add-user-folder-perm'); + this.$add_group_perm = this.$('#add-group-folder-perm'); + + var _this = this; + var $add_user_perm = this.$add_user_perm, + $add_group_perm = this.$add_group_perm; + + // show existing perm items + Common.ajaxGet({ + 'get_url': Common.getUrl({ + name: 'get_folder_perm_by_path', + repo_id: this.repo_id + }), + 'data': {'path': this.path}, + 'after_op_success': function (data) { + $(data['user_perms']).each(function(index, item) { + var perm_item = new FolderPermItemView({ + 'repo_id': _this.repo_id, + 'path': _this.path, + 'item_data':$.extend(item, {'is_user_perm': true}) + }); + $add_user_perm.after(perm_item.el); + }); + + $(data['group_perms']).each(function(index, item) { + var perm_item = new FolderPermItemView({ + 'repo_id': _this.repo_id, + 'path': _this.path, + 'item_data':$.extend(item, {'is_user_perm': false}) + }); + $add_group_perm.after(perm_item.el); + }); + } + }); + + // use select2 to 'user' input in 'add user perm' + $('[name="email"]', $add_user_perm).select2({ + maximumSelectionSize: 1, + tags: function () { + var contacts = app.pageOptions.contacts || []; + var contact_list = []; + for (var i = 0, len = contacts.length; i < len; i++) { + contact_list.push(contacts[i].email); + } + return contact_list; + }, + tokenSeparators: [',', ' '], + escapeMarkup: function(m) { return m; } + }); + + // use select2 to 'group' input in 'add group perm' + var groups = app.pageOptions.groups || [], + g_opts = ''; + for (var i = 0, len = groups.length; i < len; i++) { + g_opts += ''; + } + $('[name="group"]', $add_group_perm).html(g_opts).select2({ + maximumSelectionSize: 1, + escapeMarkup: function(m) { return m; } + }); + }, + + events: { + 'click #add-user-folder-perm .submit': 'addUserFolderPerm', + 'click #add-group-folder-perm .submit': 'addGroupFolderPerm' + }, + + addUserFolderPerm: function() { + var _this = this; + var form = this.$add_user_perm, // pseudo form + email = $('[name="email"]', form).val(); + if (!email) { + return false; + } + + var perm = $('[name="permission"]', form).val(); + Common.ajaxPost({ + 'form': form, + 'form_id': form.attr('id'), + 'post_url': Common.getUrl({ + name: 'set_user_folder_perm', + repo_id: this.repo_id + }), + 'post_data': { + 'path': this.path, + 'type': 'add', + 'user': email, + 'perm': perm + }, + 'after_op_success': function(data) { + var perm_item = new FolderPermItemView({ + 'repo_id': _this.repo_id, + 'path': _this.path, + 'item_data': { + 'user': email, + 'perm': perm, + 'is_user_perm': true + } + }); + form.after(perm_item.el); + + $('[name="email"]', form).select2("val", ""); + }, + 'after_op_error': function(xhr) { + var err; + if (xhr.responseText) { + err = $.parseJSON(xhr.responseText).error; + } else { + err = gettext("Failed. Please check the network."); + } + $('#user-folder-perm .error').html(err).removeClass('hide'); + } + }); + }, + + addGroupFolderPerm: function() { + var _this = this; + var form = this.$add_group_perm, // pseudo form + group_input = $('[name="group"]', form), + group_id = group_input.val()[0]; + if (!group_id) { + return false; + } + + var perm = $('[name="permission"]', form).val(); + Common.ajaxPost({ + 'form': form, + 'form_id': form.attr('id'), + 'post_url': Common.getUrl({ + name: 'set_group_folder_perm', + repo_id: this.repo_id + }), + 'post_data': { + 'path': this.path, + 'type': 'add', + 'group_id': group_id, + 'perm': perm + }, + 'after_op_success': function(data) { + var perm_item = new FolderPermItemView({ + 'repo_id': _this.repo_id, + 'path': _this.path, + 'item_data': { + 'is_user_perm': false, + 'perm': perm, + 'group_id': group_id, + 'group_name': $('[name="group"]', form).select2('data')[0].text + } + }); + form.after(perm_item.el); + + $('[name="group"]', form).select2("val", ""); + }, + 'after_op_error': function(xhr) { + var err; + if (xhr.responseText) { + err = $.parseJSON(xhr.responseText).error; + } else { + err = gettext("Failed. Please check the network."); + } + $('#group-folder-perm .error').html(err).removeClass('hide'); + } + }); + } + }); + + return FolderPermView; +}); diff --git a/media/assets/scripts/app/views/folder-perm.js b/media/assets/scripts/app/views/folder-perm.js new file mode 100644 index 0000000000..03222162cc --- /dev/null +++ b/media/assets/scripts/app/views/folder-perm.js @@ -0,0 +1,227 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common', + 'jquery.ui.tabs', + 'select2', + 'app/views/folder-perm-item' +], function($, _, Backbone, Common, Tabs, Select2, FolderPermItemView) { + 'use strict'; + + var FolderPermView = Backbone.View.extend({ + tagName: 'div', + id: 'folder-perm-popup', + + template: _.template($('#folder-perm-popup-tmpl').html()), + + initialize: function(options) { + this.repo_id = options.repo_id; + this.obj_name = options.obj_name; + this.dir_path = options.dir_path; + if (this.dir_path === '/') { + this.path = this.dir_path + this.obj_name; + } else { + this.path = this.dir_path + '/' + this.obj_name; + } + + this.render(); + + this.$el.modal({ + appendTo: "#main", + focus: false, + containerCss: {"padding": 0} + }); + $('#simplemodal-container').css({'width':'auto', 'height':'auto'}); + + this.$("#folder-perm-tabs").tabs(); + + this.panelsInit(); + + var _this = this; + $(document).on('click', function(e) { + var target = e.target || event.srcElement; + if (!_this.$('.perm-edit-icon, .perm-toggle-select').is(target)) { + _this.$('.perm').removeClass('hide'); + _this.$('.perm-toggle-select').addClass('hide'); + } + }); + }, + + render: function () { + this.$el.html(this.template({ + title: gettext("Set {placeholder}'s permission") + .replace('{placeholder}', '' + Common.HTMLescape(this.obj_name) + '') + })); + return this; + }, + + panelsInit: function() { + this.$add_user_perm = this.$('#add-user-folder-perm'); + this.$add_group_perm = this.$('#add-group-folder-perm'); + + var _this = this; + var $add_user_perm = this.$add_user_perm, + $add_group_perm = this.$add_group_perm; + + // show existing perm items + Common.ajaxGet({ + 'get_url': Common.getUrl({ + name: 'get_folder_perm_by_path', + repo_id: this.repo_id + }), + 'data': {'path': this.path}, + 'after_op_success': function (data) { + $(data['user_perms']).each(function(index, item) { + var perm_item = new FolderPermItemView({ + 'repo_id': _this.repo_id, + 'path': _this.path, + 'item_data':$.extend(item, {'is_user_perm': true}) + }); + $add_user_perm.after(perm_item.el); + }); + + $(data['group_perms']).each(function(index, item) { + var perm_item = new FolderPermItemView({ + 'repo_id': _this.repo_id, + 'path': _this.path, + 'item_data':$.extend(item, {'is_user_perm': false}) + }); + $add_group_perm.after(perm_item.el); + }); + } + }); + + // use select2 to 'user' input in 'add user perm' + $('[name="email"]', $add_user_perm).select2({ + maximumSelectionSize: 1, + tags: function () { + var contacts = app.pageOptions.contacts || []; + var contact_list = []; + for (var i = 0, len = contacts.length; i < len; i++) { + contact_list.push(contacts[i].email); + } + return contact_list; + }, + tokenSeparators: [',', ' '], + escapeMarkup: function(m) { return m; } + }); + + // use select2 to 'group' input in 'add group perm' + var groups = app.pageOptions.groups || [], + g_opts = ''; + for (var i = 0, len = groups.length; i < len; i++) { + g_opts += ''; + } + $('[name="group"]', $add_group_perm).html(g_opts).select2({ + maximumSelectionSize: 1, + escapeMarkup: function(m) { return m; } + }); + }, + + events: { + 'click #add-user-folder-perm .submit': 'addUserFolderPerm', + 'click #add-group-folder-perm .submit': 'addGroupFolderPerm' + }, + + addUserFolderPerm: function() { + var _this = this; + var form = this.$add_user_perm, // pseudo form + email = $('[name="email"]', form).val(); + if (!email) { + return false; + } + + var perm = $('[name="permission"]', form).val(); + Common.ajaxPost({ + 'form': form, + 'form_id': form.attr('id'), + 'post_url': Common.getUrl({ + name: 'set_user_folder_perm', + repo_id: this.repo_id + }), + 'post_data': { + 'path': this.path, + 'type': 'add', + 'user': email, + 'perm': perm + }, + 'after_op_success': function(data) { + var perm_item = new FolderPermItemView({ + 'repo_id': _this.repo_id, + 'path': _this.path, + 'item_data': { + 'user': email, + 'perm': perm, + 'is_user_perm': true + } + }); + form.after(perm_item.el); + + $('[name="email"]', form).select2("val", ""); + }, + 'after_op_error': function(xhr) { + var err; + if (xhr.responseText) { + err = $.parseJSON(xhr.responseText).error; + } else { + err = gettext("Failed. Please check the network."); + } + $('#user-folder-perm .error').html(err).removeClass('hide'); + } + }); + }, + + addGroupFolderPerm: function() { + var _this = this; + var form = this.$add_group_perm, // pseudo form + group_input = $('[name="group"]', form), + group_id = group_input.val()[0]; + if (!group_id) { + return false; + } + + var perm = $('[name="permission"]', form).val(); + Common.ajaxPost({ + 'form': form, + 'form_id': form.attr('id'), + 'post_url': Common.getUrl({ + name: 'set_group_folder_perm', + repo_id: this.repo_id + }), + 'post_data': { + 'path': this.path, + 'type': 'add', + 'group_id': group_id, + 'perm': perm + }, + 'after_op_success': function(data) { + var perm_item = new FolderPermItemView({ + 'repo_id': _this.repo_id, + 'path': _this.path, + 'item_data': { + 'is_user_perm': false, + 'perm': perm, + 'group_id': group_id, + 'group_name': $('[name="group"]', form).select2('data')[0].text + } + }); + form.after(perm_item.el); + + $('[name="group"]', form).select2("val", ""); + }, + 'after_op_error': function(xhr) { + var err; + if (xhr.responseText) { + err = $.parseJSON(xhr.responseText).error; + } else { + err = gettext("Failed. Please check the network."); + } + $('#group-folder-perm .error').html(err).removeClass('hide'); + } + }); + } + }); + + return FolderPermView; +}); diff --git a/media/assets/scripts/app/views/group-repo.8efc7562548b.js b/media/assets/scripts/app/views/group-repo.8efc7562548b.js new file mode 100644 index 0000000000..c383a7ec5d --- /dev/null +++ b/media/assets/scripts/app/views/group-repo.8efc7562548b.js @@ -0,0 +1,68 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common' +], function($, _, Backbone, Common) { + 'use strict'; + + var GroupRepoView = Backbone.View.extend({ + tagName: 'tr', + + template: _.template($('#group-repo-tmpl').html()), + + events: { + 'mouseenter': 'highlight', + 'mouseleave': 'rmHighlight', + 'click .cancel-share': 'unshare' + }, + + initialize: function(options) { + this.group_id = options.group_id; + this.is_staff = options.is_staff; + + this.listenTo(this.model, 'destroy', this.remove); + }, + + render: function() { + var obj = this.model.toJSON(); + $.extend(obj, { + group_id: this.group_id, + is_staff: this.is_staff + }); + this.$el.html(this.template(obj)); + return this; + }, + + highlight: function() { + this.$el.addClass('hl').find('.op-icon').removeClass('vh'); + }, + + rmHighlight: function() { + this.$el.removeClass('hl').find('.op-icon').addClass('vh'); + }, + + unshare: function() { + var lib_name = this.model.get('name'); + this.model.destroy({ + wait: true, + success: function() { + var msg = gettext('Successfully unshared {placeholder}').replace('{placeholder}', '' + Common.HTMLescape(lib_name) + ''); + Common.feedback(msg, 'success', Common.SUCCESS_TIMOUT); + }, + error: function(model, response) { + var err; + if (response.responseText) { + err = $.parseJSON(response.responseText).error_msg; + } else { + err = gettext("Failed. Please check the network."); + } + Common.feedback(err, 'error'); + } + }); + }, + + }); + + return GroupRepoView; +}); diff --git a/media/assets/scripts/app/views/group-repo.js b/media/assets/scripts/app/views/group-repo.js new file mode 100644 index 0000000000..c383a7ec5d --- /dev/null +++ b/media/assets/scripts/app/views/group-repo.js @@ -0,0 +1,68 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common' +], function($, _, Backbone, Common) { + 'use strict'; + + var GroupRepoView = Backbone.View.extend({ + tagName: 'tr', + + template: _.template($('#group-repo-tmpl').html()), + + events: { + 'mouseenter': 'highlight', + 'mouseleave': 'rmHighlight', + 'click .cancel-share': 'unshare' + }, + + initialize: function(options) { + this.group_id = options.group_id; + this.is_staff = options.is_staff; + + this.listenTo(this.model, 'destroy', this.remove); + }, + + render: function() { + var obj = this.model.toJSON(); + $.extend(obj, { + group_id: this.group_id, + is_staff: this.is_staff + }); + this.$el.html(this.template(obj)); + return this; + }, + + highlight: function() { + this.$el.addClass('hl').find('.op-icon').removeClass('vh'); + }, + + rmHighlight: function() { + this.$el.removeClass('hl').find('.op-icon').addClass('vh'); + }, + + unshare: function() { + var lib_name = this.model.get('name'); + this.model.destroy({ + wait: true, + success: function() { + var msg = gettext('Successfully unshared {placeholder}').replace('{placeholder}', '' + Common.HTMLescape(lib_name) + ''); + Common.feedback(msg, 'success', Common.SUCCESS_TIMOUT); + }, + error: function(model, response) { + var err; + if (response.responseText) { + err = $.parseJSON(response.responseText).error_msg; + } else { + err = gettext("Failed. Please check the network."); + } + Common.feedback(err, 'error'); + } + }); + }, + + }); + + return GroupRepoView; +}); diff --git a/media/assets/scripts/app/views/group-side-nav.0b05e7fb5a80.js b/media/assets/scripts/app/views/group-side-nav.0b05e7fb5a80.js new file mode 100644 index 0000000000..5a7e82773d --- /dev/null +++ b/media/assets/scripts/app/views/group-side-nav.0b05e7fb5a80.js @@ -0,0 +1,96 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common' +], function($, _, Backbone, Common) { + 'use strict'; + + var GroupSideNavView = Backbone.View.extend({ + el: '#group-side-nav', + + template: _.template($("#group-side-nav-tmpl").html()), + enableModTemplate: _.template($("#group-mods-enable-form-tmpl").html()), + + initialize: function() { + }, + + render: function (group_id) { + this.group_id = group_id; + var _this = this; + $.ajax({ + url: Common.getUrl({ + 'name': 'group_basic_info', + 'group_id': this.group_id + }), + cache: false, + dataType: 'json', + success: function (data) { + _this.$el.html(_this.template(data)); + // for 'enable mod' + _this.mods_available = data.mods_available; + _this.mods_enabled = data.mods_enabled; + }, + error: function(xhr) { + var err_msg; + if (xhr.responseText) { + err_msg = $.parseJSON(xhr.responseText).error; + } else { + err_msg = gettext("Please check the network."); + } + _this.$el.html('

' + err_msg + '

'); + } + }); + }, + + events: { + 'click #enable-mods': 'enableMods' + }, + + enableMods: function () { + var form = $(this.enableModTemplate({ + 'mods_available': this.mods_available, + 'mods_enabled': this.mods_enabled + })); + form.modal(); + $('#simplemodal-container').css('height', 'auto'); + $('.checkbox-orig', form).click(function() { + $(this).parent().toggleClass('checkbox-checked'); + }); + var checkbox = $('[name="group_wiki"]'); + var original_checked = checkbox.prop('checked'); + var _this = this; + form.submit(function() { + var cur_checked = checkbox.prop('checked'); + if (cur_checked == original_checked) { + return false; + } + Common.ajaxPost({ + form: form, + form_id: form.attr('id'), + post_url: Common.getUrl({ + 'name': 'toggle_group_modules', + 'group_id': _this.group_id + }), + post_data: {'group_wiki': cur_checked }, + after_op_success: function () { + $.modal.close(); + _this.render(_this.group_id); + } + }); + return false; + }); + }, + + show: function() { + this.$el.show(); + }, + + hide: function() { + this.$el.hide(); + } + + }); + + return GroupSideNavView; +}); diff --git a/media/assets/scripts/app/views/group-side-nav.js b/media/assets/scripts/app/views/group-side-nav.js new file mode 100644 index 0000000000..5a7e82773d --- /dev/null +++ b/media/assets/scripts/app/views/group-side-nav.js @@ -0,0 +1,96 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common' +], function($, _, Backbone, Common) { + 'use strict'; + + var GroupSideNavView = Backbone.View.extend({ + el: '#group-side-nav', + + template: _.template($("#group-side-nav-tmpl").html()), + enableModTemplate: _.template($("#group-mods-enable-form-tmpl").html()), + + initialize: function() { + }, + + render: function (group_id) { + this.group_id = group_id; + var _this = this; + $.ajax({ + url: Common.getUrl({ + 'name': 'group_basic_info', + 'group_id': this.group_id + }), + cache: false, + dataType: 'json', + success: function (data) { + _this.$el.html(_this.template(data)); + // for 'enable mod' + _this.mods_available = data.mods_available; + _this.mods_enabled = data.mods_enabled; + }, + error: function(xhr) { + var err_msg; + if (xhr.responseText) { + err_msg = $.parseJSON(xhr.responseText).error; + } else { + err_msg = gettext("Please check the network."); + } + _this.$el.html('

' + err_msg + '

'); + } + }); + }, + + events: { + 'click #enable-mods': 'enableMods' + }, + + enableMods: function () { + var form = $(this.enableModTemplate({ + 'mods_available': this.mods_available, + 'mods_enabled': this.mods_enabled + })); + form.modal(); + $('#simplemodal-container').css('height', 'auto'); + $('.checkbox-orig', form).click(function() { + $(this).parent().toggleClass('checkbox-checked'); + }); + var checkbox = $('[name="group_wiki"]'); + var original_checked = checkbox.prop('checked'); + var _this = this; + form.submit(function() { + var cur_checked = checkbox.prop('checked'); + if (cur_checked == original_checked) { + return false; + } + Common.ajaxPost({ + form: form, + form_id: form.attr('id'), + post_url: Common.getUrl({ + 'name': 'toggle_group_modules', + 'group_id': _this.group_id + }), + post_data: {'group_wiki': cur_checked }, + after_op_success: function () { + $.modal.close(); + _this.render(_this.group_id); + } + }); + return false; + }); + }, + + show: function() { + this.$el.show(); + }, + + hide: function() { + this.$el.hide(); + } + + }); + + return GroupSideNavView; +}); diff --git a/media/assets/scripts/app/views/group.8affe284ec5e.js b/media/assets/scripts/app/views/group.8affe284ec5e.js new file mode 100644 index 0000000000..f59a51e693 --- /dev/null +++ b/media/assets/scripts/app/views/group.8affe284ec5e.js @@ -0,0 +1,145 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common', + 'app/collections/group-repos', + 'app/views/group-repo', + 'app/views/add-group-repo', + 'app/views/group-side-nav' +], function($, _, Backbone, Common, GroupRepos, GroupRepoView, + AddGroupRepoView, GroupSideNavView) { + 'use strict'; + + var GroupView = Backbone.View.extend({ + el: '#main', + + events: { + 'click #group-repo-tabs .repo-create': 'createRepo', + 'click #grp-repos .by-name': 'sortByName', + 'click #grp-repos .by-time': 'sortByTime' + }, + + initialize: function(options) { + this.$tabs = this.$('#group-repo-tabs'); + this.$table = this.$('#grp-repos table', this.$tabs); + this.$tableHead = $('thead', this.$table); + this.$tableBody = $('tbody', this.$table); + this.$loadingTip = $('.loading-tip', this.$tabs); + this.$emptyTip = $('.empty-tips', this.$tabs); + + this.sideNavView = new GroupSideNavView(); + + this.repos = new GroupRepos(); + this.listenTo(this.repos, 'add', this.addOne); + this.listenTo(this.repos, 'reset', this.reset); + + this.dirView = options.dirView; + }, + + addOne: function(repo, collection, options) { + var view = new GroupRepoView({ + model: repo, + group_id: this.group_id, + is_staff: this.repos.is_staff + }); + if (options.prepend) { + this.$tableBody.prepend(view.render().el); + } else { + this.$tableBody.append(view.render().el); + } + }, + + reset: function() { + this.$tableBody.empty(); + this.repos.each(this.addOne, this); + this.$loadingTip.hide(); + if (this.repos.length) { + this.$emptyTip.hide(); + this.$table.show(); + } else { + this.$emptyTip.show(); + this.$table.hide(); + } + }, + + showSideNav: function () { + var sideNavView = this.sideNavView; + if (sideNavView.group_id && sideNavView.group_id == this.group_id) { + sideNavView.show(); + return; + } + sideNavView.render(this.group_id); + sideNavView.show(); + }, + + showRepoList: function(group_id) { + this.group_id = group_id; + this.showSideNav(); + this.dirView.hide(); + this.$emptyTip.hide(); + this.$tabs.show(); + this.$table.hide(); + this.repos.setGroupID(group_id); + this.repos.fetch({reset: true}); + this.$loadingTip.show(); + }, + + hideRepoList: function() { + this.$tabs.hide(); + }, + + showDir: function(group_id, repo_id, path) { + this.group_id = group_id; + this.showSideNav(); + this.hideRepoList(); + this.dirView.showDir('group/' + this.group_id, repo_id, path); + }, + + createRepo: function() { + new AddGroupRepoView(this.repos); + }, + + sortByName: function() { + var repos = this.repos; + var el = $('.by-name', this.$table); + repos.comparator = function(a, b) { // a, b: model + if (el.hasClass('icon-caret-up')) { + return a.get('name').toLowerCase() < b.get('name').toLowerCase() ? 1 : -1; + } else { + return a.get('name').toLowerCase() < b.get('name').toLowerCase() ? -1 : 1; + } + }; + repos.sort(); + this.$tableBody.empty(); + repos.each(this.addOne, this); + el.toggleClass('icon-caret-up icon-caret-down'); + }, + + sortByTime: function() { + var repos = this.repos; + var el = $('.by-time', this.$table); + repos.comparator = function(a, b) { // a, b: model + if (el.hasClass('icon-caret-down')) { + return a.get('mtime') < b.get('mtime') ? 1 : -1; + } else { + return a.get('mtime') < b.get('mtime') ? -1 : 1; + } + }; + repos.sort(); + this.$tableBody.empty(); + repos.each(this.addOne, this); + el.toggleClass('icon-caret-up icon-caret-down'); + }, + + hide: function() { + this.sideNavView.hide(); + this.hideRepoList(); + this.dirView.hide(); + this.$emptyTip.hide(); + } + + }); + + return GroupView; +}); diff --git a/media/assets/scripts/app/views/group.js b/media/assets/scripts/app/views/group.js new file mode 100644 index 0000000000..f59a51e693 --- /dev/null +++ b/media/assets/scripts/app/views/group.js @@ -0,0 +1,145 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common', + 'app/collections/group-repos', + 'app/views/group-repo', + 'app/views/add-group-repo', + 'app/views/group-side-nav' +], function($, _, Backbone, Common, GroupRepos, GroupRepoView, + AddGroupRepoView, GroupSideNavView) { + 'use strict'; + + var GroupView = Backbone.View.extend({ + el: '#main', + + events: { + 'click #group-repo-tabs .repo-create': 'createRepo', + 'click #grp-repos .by-name': 'sortByName', + 'click #grp-repos .by-time': 'sortByTime' + }, + + initialize: function(options) { + this.$tabs = this.$('#group-repo-tabs'); + this.$table = this.$('#grp-repos table', this.$tabs); + this.$tableHead = $('thead', this.$table); + this.$tableBody = $('tbody', this.$table); + this.$loadingTip = $('.loading-tip', this.$tabs); + this.$emptyTip = $('.empty-tips', this.$tabs); + + this.sideNavView = new GroupSideNavView(); + + this.repos = new GroupRepos(); + this.listenTo(this.repos, 'add', this.addOne); + this.listenTo(this.repos, 'reset', this.reset); + + this.dirView = options.dirView; + }, + + addOne: function(repo, collection, options) { + var view = new GroupRepoView({ + model: repo, + group_id: this.group_id, + is_staff: this.repos.is_staff + }); + if (options.prepend) { + this.$tableBody.prepend(view.render().el); + } else { + this.$tableBody.append(view.render().el); + } + }, + + reset: function() { + this.$tableBody.empty(); + this.repos.each(this.addOne, this); + this.$loadingTip.hide(); + if (this.repos.length) { + this.$emptyTip.hide(); + this.$table.show(); + } else { + this.$emptyTip.show(); + this.$table.hide(); + } + }, + + showSideNav: function () { + var sideNavView = this.sideNavView; + if (sideNavView.group_id && sideNavView.group_id == this.group_id) { + sideNavView.show(); + return; + } + sideNavView.render(this.group_id); + sideNavView.show(); + }, + + showRepoList: function(group_id) { + this.group_id = group_id; + this.showSideNav(); + this.dirView.hide(); + this.$emptyTip.hide(); + this.$tabs.show(); + this.$table.hide(); + this.repos.setGroupID(group_id); + this.repos.fetch({reset: true}); + this.$loadingTip.show(); + }, + + hideRepoList: function() { + this.$tabs.hide(); + }, + + showDir: function(group_id, repo_id, path) { + this.group_id = group_id; + this.showSideNav(); + this.hideRepoList(); + this.dirView.showDir('group/' + this.group_id, repo_id, path); + }, + + createRepo: function() { + new AddGroupRepoView(this.repos); + }, + + sortByName: function() { + var repos = this.repos; + var el = $('.by-name', this.$table); + repos.comparator = function(a, b) { // a, b: model + if (el.hasClass('icon-caret-up')) { + return a.get('name').toLowerCase() < b.get('name').toLowerCase() ? 1 : -1; + } else { + return a.get('name').toLowerCase() < b.get('name').toLowerCase() ? -1 : 1; + } + }; + repos.sort(); + this.$tableBody.empty(); + repos.each(this.addOne, this); + el.toggleClass('icon-caret-up icon-caret-down'); + }, + + sortByTime: function() { + var repos = this.repos; + var el = $('.by-time', this.$table); + repos.comparator = function(a, b) { // a, b: model + if (el.hasClass('icon-caret-down')) { + return a.get('mtime') < b.get('mtime') ? 1 : -1; + } else { + return a.get('mtime') < b.get('mtime') ? -1 : 1; + } + }; + repos.sort(); + this.$tableBody.empty(); + repos.each(this.addOne, this); + el.toggleClass('icon-caret-up icon-caret-down'); + }, + + hide: function() { + this.sideNavView.hide(); + this.hideRepoList(); + this.dirView.hide(); + this.$emptyTip.hide(); + } + + }); + + return GroupView; +}); diff --git a/media/assets/scripts/app/views/myhome-repos.8119c47ffa88.js b/media/assets/scripts/app/views/myhome-repos.8119c47ffa88.js new file mode 100644 index 0000000000..289053d292 --- /dev/null +++ b/media/assets/scripts/app/views/myhome-repos.8119c47ffa88.js @@ -0,0 +1,122 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common', + 'app/collections/repos', + 'app/views/repo', + 'app/views/add-repo', +], function($, _, Backbone, Common, RepoCollection, RepoView, AddRepoView) { + 'use strict'; + + var ReposView = Backbone.View.extend({ + el: $('#repo-tabs'), + + events: { + 'click .repo-create': 'createRepo', + 'click #my-own-repos .by-name': 'sortByName', + 'click #my-own-repos .by-time': 'sortByTime' + }, + + initialize: function(options) { + this.$tabs = $('#repo-tabs'); + this.$table = this.$('#my-own-repos table'); + this.$tableHead = $('thead', this.$table); + this.$tableBody = $('tbody', this.$table); + this.$loadingTip = $('.loading-tip', this.$tabs); + this.$emptyTip = $('#my-own-repos .empty-tips'); + this.$repoCreateBtn = this.$('.repo-create'); + + this.repos = new RepoCollection(); + this.listenTo(this.repos, 'add', this.addOne); + this.listenTo(this.repos, 'reset', this.reset); + }, + + addOne: function(repo, collection, options) { + var view = new RepoView({model: repo}); + if (options.prepend) { + this.$tableBody.prepend(view.render().el); + } else { + this.$tableBody.append(view.render().el); + } + }, + + reset: function() { + this.$tableBody.empty(); + this.repos.each(this.addOne, this); + if (this.repos.length) { + this.$emptyTip.hide(); + this.$table.show(); + } else { + this.$emptyTip.show(); + this.$table.hide(); + // Show guide popup when there is no owned repos and guide flag is true. + if (app.pageOptions.guide_enabled) { + $('#guide-for-new').modal({appendTo: '#main', focus:false}); + app.pageOptions.guide_enabled = false; + } + } + this.$loadingTip.hide(); + }, + + showMyRepos: function() { + this.repos.fetch({reset: true}); + this.$tabs.show(); + this.$table.hide(); + this.$loadingTip.show(); + $('#mylib-tab', this.$tabs).parent().addClass('ui-state-active'); + }, + + show: function() { + this.$repoCreateBtn.show(); + this.showMyRepos(); + }, + + hide: function() { + this.$repoCreateBtn.hide(); + this.$el.hide(); + this.$table.hide(); + this.$emptyTip.hide(); + $('#mylib-tab', this.$tabs).parent().removeClass('ui-state-active'); + }, + + createRepo: function() { + new AddRepoView(this.repos); + }, + + sortByName: function() { + var repos = this.repos; + var el = $('.by-name', this.$table); + repos.comparator = function(a, b) { // a, b: model + if (el.hasClass('icon-caret-up')) { + return a.get('name').toLowerCase() < b.get('name').toLowerCase() ? 1 : -1; + } else { + return a.get('name').toLowerCase() < b.get('name').toLowerCase() ? -1 : 1; + } + }; + repos.sort(); + this.$tableBody.empty(); + repos.each(this.addOne, this); + el.toggleClass('icon-caret-up icon-caret-down'); + }, + + sortByTime: function() { + var repos = this.repos; + var el = $('.by-time', this.$table); + repos.comparator = function(a, b) { // a, b: model + if (el.hasClass('icon-caret-down')) { + return a.get('mtime') < b.get('mtime') ? 1 : -1; + } else { + return a.get('mtime') < b.get('mtime') ? -1 : 1; + } + }; + repos.sort(); + this.$tableBody.empty(); + repos.each(this.addOne, this); + el.toggleClass('icon-caret-up icon-caret-down'); + } + + }); + + return ReposView; +}); diff --git a/media/assets/scripts/app/views/myhome-repos.js b/media/assets/scripts/app/views/myhome-repos.js new file mode 100644 index 0000000000..289053d292 --- /dev/null +++ b/media/assets/scripts/app/views/myhome-repos.js @@ -0,0 +1,122 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common', + 'app/collections/repos', + 'app/views/repo', + 'app/views/add-repo', +], function($, _, Backbone, Common, RepoCollection, RepoView, AddRepoView) { + 'use strict'; + + var ReposView = Backbone.View.extend({ + el: $('#repo-tabs'), + + events: { + 'click .repo-create': 'createRepo', + 'click #my-own-repos .by-name': 'sortByName', + 'click #my-own-repos .by-time': 'sortByTime' + }, + + initialize: function(options) { + this.$tabs = $('#repo-tabs'); + this.$table = this.$('#my-own-repos table'); + this.$tableHead = $('thead', this.$table); + this.$tableBody = $('tbody', this.$table); + this.$loadingTip = $('.loading-tip', this.$tabs); + this.$emptyTip = $('#my-own-repos .empty-tips'); + this.$repoCreateBtn = this.$('.repo-create'); + + this.repos = new RepoCollection(); + this.listenTo(this.repos, 'add', this.addOne); + this.listenTo(this.repos, 'reset', this.reset); + }, + + addOne: function(repo, collection, options) { + var view = new RepoView({model: repo}); + if (options.prepend) { + this.$tableBody.prepend(view.render().el); + } else { + this.$tableBody.append(view.render().el); + } + }, + + reset: function() { + this.$tableBody.empty(); + this.repos.each(this.addOne, this); + if (this.repos.length) { + this.$emptyTip.hide(); + this.$table.show(); + } else { + this.$emptyTip.show(); + this.$table.hide(); + // Show guide popup when there is no owned repos and guide flag is true. + if (app.pageOptions.guide_enabled) { + $('#guide-for-new').modal({appendTo: '#main', focus:false}); + app.pageOptions.guide_enabled = false; + } + } + this.$loadingTip.hide(); + }, + + showMyRepos: function() { + this.repos.fetch({reset: true}); + this.$tabs.show(); + this.$table.hide(); + this.$loadingTip.show(); + $('#mylib-tab', this.$tabs).parent().addClass('ui-state-active'); + }, + + show: function() { + this.$repoCreateBtn.show(); + this.showMyRepos(); + }, + + hide: function() { + this.$repoCreateBtn.hide(); + this.$el.hide(); + this.$table.hide(); + this.$emptyTip.hide(); + $('#mylib-tab', this.$tabs).parent().removeClass('ui-state-active'); + }, + + createRepo: function() { + new AddRepoView(this.repos); + }, + + sortByName: function() { + var repos = this.repos; + var el = $('.by-name', this.$table); + repos.comparator = function(a, b) { // a, b: model + if (el.hasClass('icon-caret-up')) { + return a.get('name').toLowerCase() < b.get('name').toLowerCase() ? 1 : -1; + } else { + return a.get('name').toLowerCase() < b.get('name').toLowerCase() ? -1 : 1; + } + }; + repos.sort(); + this.$tableBody.empty(); + repos.each(this.addOne, this); + el.toggleClass('icon-caret-up icon-caret-down'); + }, + + sortByTime: function() { + var repos = this.repos; + var el = $('.by-time', this.$table); + repos.comparator = function(a, b) { // a, b: model + if (el.hasClass('icon-caret-down')) { + return a.get('mtime') < b.get('mtime') ? 1 : -1; + } else { + return a.get('mtime') < b.get('mtime') ? -1 : 1; + } + }; + repos.sort(); + this.$tableBody.empty(); + repos.each(this.addOne, this); + el.toggleClass('icon-caret-up icon-caret-down'); + } + + }); + + return ReposView; +}); diff --git a/media/assets/scripts/app/views/myhome-shared-repos.aa3b73934daf.js b/media/assets/scripts/app/views/myhome-shared-repos.aa3b73934daf.js new file mode 100644 index 0000000000..4ab32d77ec --- /dev/null +++ b/media/assets/scripts/app/views/myhome-shared-repos.aa3b73934daf.js @@ -0,0 +1,113 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common', + 'app/collections/repos', + 'app/views/shared-repo', +], function($, _, Backbone, Common, RepoCollection, SharedRepoView) { + 'use strict'; + + var SharedReposView = Backbone.View.extend({ + el: $('#repo-tabs'), + + initialize: function(options) { + this.$tabs = $('#repo-tabs'); + this.$table = $('#repos-shared-to-me table'); + this.$tableHead = $('thead', this.$table); + this.$tableBody = $('tbody', this.$table); + this.$loadingTip = $('.loading-tip', this.$tabs); + this.$emptyTip = $('#repos-shared-to-me .empty-tips'); + + this.repos = new RepoCollection({type: 'shared'}); + this.listenTo(this.repos, 'add', this.addOne); + this.listenTo(this.repos, 'reset', this.reset); + }, + + addOne: function(repo, collection, options) { + var view = new SharedRepoView({model: repo, collection: this.repos}); + if (options.prepend) { + this.$tableBody.prepend(view.render().el); + } else { + this.$tableBody.append(view.render().el); + } + }, + + reset: function() { + this.$tableBody.empty(); + this.repos.each(this.addOne, this); + if (this.repos.length) { + this.$emptyTip.hide(); + this.$table.show(); + } else { + this.$emptyTip.show(); + this.$table.hide(); + } + this.$loadingTip.hide(); + }, + + renderPath: function() { + // + }, + + showSharedRepos: function() { + this.repos.fetch({reset: true}); + this.$tabs.show(); + //this.$table.parent().show(); + this.$table.hide(); + this.$loadingTip.show(); + $('#shared-lib-tab', this.$tabs).parent().addClass('ui-state-active'); + }, + + show: function() { + this.showSharedRepos(); + }, + + hide: function() { + this.$el.hide(); + this.$table.hide(); + this.$emptyTip.hide(); + $('#shared-lib-tab', this.$tabs).parent().removeClass('ui-state-active'); + }, + + events: { + 'click #repos-shared-to-me .by-name': 'sortByName', + 'click #repos-shared-to-me .by-time': 'sortByTime' + }, + + sortByName: function() { + var repos = this.repos; + var el = $('.by-name', this.$table); + repos.comparator = function(a, b) { // a, b: model + if (el.hasClass('icon-caret-up')) { + return a.get('name').toLowerCase() < b.get('name').toLowerCase() ? 1 : -1; + } else { + return a.get('name').toLowerCase() < b.get('name').toLowerCase() ? -1 : 1; + } + }; + repos.sort(); + this.$tableBody.empty(); + repos.each(this.addOne, this); + el.toggleClass('icon-caret-up icon-caret-down'); + }, + + sortByTime: function() { + var repos = this.repos; + var el = $('.by-time', this.$table); + repos.comparator = function(a, b) { // a, b: model + if (el.hasClass('icon-caret-down')) { + return a.get('mtime') < b.get('mtime') ? 1 : -1; + } else { + return a.get('mtime') < b.get('mtime') ? -1 : 1; + } + }; + repos.sort(); + this.$tableBody.empty(); + repos.each(this.addOne, this); + el.toggleClass('icon-caret-up icon-caret-down'); + } + + }); + + return SharedReposView; +}); diff --git a/media/assets/scripts/app/views/myhome-shared-repos.js b/media/assets/scripts/app/views/myhome-shared-repos.js new file mode 100644 index 0000000000..4ab32d77ec --- /dev/null +++ b/media/assets/scripts/app/views/myhome-shared-repos.js @@ -0,0 +1,113 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common', + 'app/collections/repos', + 'app/views/shared-repo', +], function($, _, Backbone, Common, RepoCollection, SharedRepoView) { + 'use strict'; + + var SharedReposView = Backbone.View.extend({ + el: $('#repo-tabs'), + + initialize: function(options) { + this.$tabs = $('#repo-tabs'); + this.$table = $('#repos-shared-to-me table'); + this.$tableHead = $('thead', this.$table); + this.$tableBody = $('tbody', this.$table); + this.$loadingTip = $('.loading-tip', this.$tabs); + this.$emptyTip = $('#repos-shared-to-me .empty-tips'); + + this.repos = new RepoCollection({type: 'shared'}); + this.listenTo(this.repos, 'add', this.addOne); + this.listenTo(this.repos, 'reset', this.reset); + }, + + addOne: function(repo, collection, options) { + var view = new SharedRepoView({model: repo, collection: this.repos}); + if (options.prepend) { + this.$tableBody.prepend(view.render().el); + } else { + this.$tableBody.append(view.render().el); + } + }, + + reset: function() { + this.$tableBody.empty(); + this.repos.each(this.addOne, this); + if (this.repos.length) { + this.$emptyTip.hide(); + this.$table.show(); + } else { + this.$emptyTip.show(); + this.$table.hide(); + } + this.$loadingTip.hide(); + }, + + renderPath: function() { + // + }, + + showSharedRepos: function() { + this.repos.fetch({reset: true}); + this.$tabs.show(); + //this.$table.parent().show(); + this.$table.hide(); + this.$loadingTip.show(); + $('#shared-lib-tab', this.$tabs).parent().addClass('ui-state-active'); + }, + + show: function() { + this.showSharedRepos(); + }, + + hide: function() { + this.$el.hide(); + this.$table.hide(); + this.$emptyTip.hide(); + $('#shared-lib-tab', this.$tabs).parent().removeClass('ui-state-active'); + }, + + events: { + 'click #repos-shared-to-me .by-name': 'sortByName', + 'click #repos-shared-to-me .by-time': 'sortByTime' + }, + + sortByName: function() { + var repos = this.repos; + var el = $('.by-name', this.$table); + repos.comparator = function(a, b) { // a, b: model + if (el.hasClass('icon-caret-up')) { + return a.get('name').toLowerCase() < b.get('name').toLowerCase() ? 1 : -1; + } else { + return a.get('name').toLowerCase() < b.get('name').toLowerCase() ? -1 : 1; + } + }; + repos.sort(); + this.$tableBody.empty(); + repos.each(this.addOne, this); + el.toggleClass('icon-caret-up icon-caret-down'); + }, + + sortByTime: function() { + var repos = this.repos; + var el = $('.by-time', this.$table); + repos.comparator = function(a, b) { // a, b: model + if (el.hasClass('icon-caret-down')) { + return a.get('mtime') < b.get('mtime') ? 1 : -1; + } else { + return a.get('mtime') < b.get('mtime') ? -1 : 1; + } + }; + repos.sort(); + this.$tableBody.empty(); + repos.each(this.addOne, this); + el.toggleClass('icon-caret-up icon-caret-down'); + } + + }); + + return SharedReposView; +}); diff --git a/media/assets/scripts/app/views/myhome-side-nav.09acd723fcd3.js b/media/assets/scripts/app/views/myhome-side-nav.09acd723fcd3.js new file mode 100644 index 0000000000..ba9f22c8ac --- /dev/null +++ b/media/assets/scripts/app/views/myhome-side-nav.09acd723fcd3.js @@ -0,0 +1,87 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common' +], function($, _, Backbone, Common) { + 'use strict'; + + var MyhomeSideNavView = Backbone.View.extend({ + el: '#myhome-side-nav', + + template: _.template($("#myhome-side-nav-tmpl").html()), + enableModTemplate: _.template($("#myhome-mods-enable-form-tmpl").html()), + + initialize: function() { + this.render(); + }, + + render: function() { + this.$el.html(this.template({ + 'mods_enabled': app.pageOptions.user_mods_enabled, + 'can_add_repo': app.pageOptions.can_add_repo, + 'events_enabled': app.pageOptions.events_enabled + })); + }, + + events: { + 'click #myhome-enable-mods': 'enableMods' + }, + + enableMods: function () { + var mods_enabled = app.pageOptions.user_mods_enabled; + var form = $(this.enableModTemplate({ + 'mods_available': app.pageOptions.user_mods_available, + 'mods_enabled': mods_enabled + })); + form.modal(); + $('#simplemodal-container').css('height', 'auto'); + + $('.checkbox-orig', form).click(function() { + $(this).parent().toggleClass('checkbox-checked'); + }); + + var checkbox = $('[name="personal_wiki"]'), + original_checked = checkbox.prop('checked'), + _this = this; + form.submit(function() { + var cur_checked = checkbox.prop('checked'); + if (cur_checked == original_checked) { + return false; + } + Common.ajaxPost({ + form: form, + form_id: form.attr('id'), + post_url: Common.getUrl({ + 'name': 'toggle_personal_modules' + }), + post_data: {'personal_wiki': cur_checked }, + after_op_success: function () { + if (cur_checked) { + mods_enabled.push('personal wiki'); + } else { + var index = mods_enabled.indexOf('personal wiki'); + if (index > -1) { + mods_enabled.splice(index, 1); // rm the item + } + } + $.modal.close(); + _this.render(); + } + }); + return false; + }); + }, + + show: function() { + this.$el.show(); + }, + + hide: function() { + this.$el.hide(); + } + + }); + + return MyhomeSideNavView; +}); diff --git a/media/assets/scripts/app/views/myhome-side-nav.js b/media/assets/scripts/app/views/myhome-side-nav.js new file mode 100644 index 0000000000..ba9f22c8ac --- /dev/null +++ b/media/assets/scripts/app/views/myhome-side-nav.js @@ -0,0 +1,87 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common' +], function($, _, Backbone, Common) { + 'use strict'; + + var MyhomeSideNavView = Backbone.View.extend({ + el: '#myhome-side-nav', + + template: _.template($("#myhome-side-nav-tmpl").html()), + enableModTemplate: _.template($("#myhome-mods-enable-form-tmpl").html()), + + initialize: function() { + this.render(); + }, + + render: function() { + this.$el.html(this.template({ + 'mods_enabled': app.pageOptions.user_mods_enabled, + 'can_add_repo': app.pageOptions.can_add_repo, + 'events_enabled': app.pageOptions.events_enabled + })); + }, + + events: { + 'click #myhome-enable-mods': 'enableMods' + }, + + enableMods: function () { + var mods_enabled = app.pageOptions.user_mods_enabled; + var form = $(this.enableModTemplate({ + 'mods_available': app.pageOptions.user_mods_available, + 'mods_enabled': mods_enabled + })); + form.modal(); + $('#simplemodal-container').css('height', 'auto'); + + $('.checkbox-orig', form).click(function() { + $(this).parent().toggleClass('checkbox-checked'); + }); + + var checkbox = $('[name="personal_wiki"]'), + original_checked = checkbox.prop('checked'), + _this = this; + form.submit(function() { + var cur_checked = checkbox.prop('checked'); + if (cur_checked == original_checked) { + return false; + } + Common.ajaxPost({ + form: form, + form_id: form.attr('id'), + post_url: Common.getUrl({ + 'name': 'toggle_personal_modules' + }), + post_data: {'personal_wiki': cur_checked }, + after_op_success: function () { + if (cur_checked) { + mods_enabled.push('personal wiki'); + } else { + var index = mods_enabled.indexOf('personal wiki'); + if (index > -1) { + mods_enabled.splice(index, 1); // rm the item + } + } + $.modal.close(); + _this.render(); + } + }); + return false; + }); + }, + + show: function() { + this.$el.show(); + }, + + hide: function() { + this.$el.hide(); + } + + }); + + return MyhomeSideNavView; +}); diff --git a/media/assets/scripts/app/views/myhome-sub-repos.6292413141b1.js b/media/assets/scripts/app/views/myhome-sub-repos.6292413141b1.js new file mode 100644 index 0000000000..240791111d --- /dev/null +++ b/media/assets/scripts/app/views/myhome-sub-repos.6292413141b1.js @@ -0,0 +1,154 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common', + 'file-tree', + 'app/collections/repos', + 'app/views/sub-lib', + 'app/views/add-repo', +], function($, _, Backbone, Common, FileTree, RepoCollection, RepoView, AddRepoView) { + 'use strict'; + + var ReposView = Backbone.View.extend({ + el: $('#repo-tabs'), + + events: { + 'click #sub-lib-create': 'createRepo', + }, + + initialize: function(options) { + this.$tabs = $('#repo-tabs'); + this.$table = this.$('#my-sub-repos table'); + this.$tableHead = $('thead', this.$table); + this.$tableBody = $('tbody', this.$table); + this.$loadingTip = $('.loading-tip', this.$tabs); + this.$emptyTip = $('#my-sub-repos .empty-tips'); + + this.repos = new RepoCollection({type: 'sub'}); + this.listenTo(this.repos, 'add', this.addOne); + this.listenTo(this.repos, 'reset', this.reset); + }, + + addOne: function(repo, collection, options) { + var view = new RepoView({model: repo}); + if (options.prepend) { + this.$tableBody.prepend(view.render().el); + } else { + this.$tableBody.append(view.render().el); + } + }, + + reset: function() { + this.$tableBody.empty(); + this.repos.each(this.addOne, this); + if (this.repos.length) { + this.$emptyTip.hide(); + this.$table.show(); + } else { + this.$emptyTip.show(); + this.$table.hide(); + } + this.$loadingTip.hide(); + }, + + showSubRepos: function() { + this.repos.fetch({reset: true}); + this.$tabs.show(); + this.$table.hide(); + this.$loadingTip.show(); + $('#sublib-tab', this.$tabs).parent().addClass('ui-state-active'); + }, + + show: function() { + $('#sub-lib-create').show(); + this.showSubRepos(); + }, + + hide: function() { + $('#sub-lib-create').hide(); + this.$el.hide(); + this.$table.hide(); + this.$emptyTip.hide(); + $('#sublib-tab', this.$tabs).parent().removeClass('ui-state-active'); + }, + + createRepo: function() { + var _this = this; + + var sublib_create_form = $('#sublib-create-form'); + + var dir_tree_cont = $('.dir-tree-cont', sublib_create_form); + sublib_create_form.modal(); + + $.ajax({ + url: Common.getUrl({'name': 'get_my_unenc_repos'}), + cache: false, + dataType: 'json', + success: function(data) { + var repos = FileTree.formatRepoData(data); + if (repos.length > 0) { + FileTree.renderDirTree(dir_tree_cont, sublib_create_form, repos); + } else { + dir_tree_cont.html('

' + gettext("You don't have any library at present.") + '

'); + } + }, + error: function(jqXHR, textStatus, errorThrown) { + var error; + if (jqXHR.responseText) { + error = $.parseJSON(jqXHR.responseText).error; + } else { + error = gettext("Failed. Please check the network."); + } + dir_tree_cont.html('

' + error + '

'); + } + }); + + $('.submit', sublib_create_form).click(function() { + var ori_repo_id = $('[name="dst_repo"]', sublib_create_form).val(); + var path = $('[name="dst_path"]', sublib_create_form).val(); + + if (!path || path == '/') { + $('.error', sublib_create_form).html(gettext("Please choose a directory")).removeClass('hide'); + return false; + } + + // path ends with '/', rm it here + path = path.substr(0, path.length - 1); + $.ajax({ + url: Common.getUrl({'name':'sub_repo', 'repo_id':ori_repo_id}) + '?p=' + encodeURIComponent(path), + dataType: 'json', + success: function(data) { + $.modal.close(); + if (_this.repos.length > 0) { + _this.repos.add({ + 'id': data["sub_repo_id"], + 'name': data["name"], + 'origin_repo_id': ori_repo_id, + 'origin_path': path, + 'abbrev_origin_path': data["abbrev_origin_path"], + 'mtime': new Date().getTime() / 1000, + 'mtime_relative': gettext("Just now") + }, {prepend: true}); + } else { + _this.showMyRepos(); + } + }, + error: function(xhr, textStatus, errorThrown) { + var err; + if (xhr.responseText) { + err = jQuery.parseJSON(xhr.responseText).error; + } else { + err = gettext("Failed. Please check the network."); + } + $('.error', sublib_create_form).html(err).removeClass('hide'); + } + }); + return false; + }); + } + + }); + + return ReposView; +}); diff --git a/media/assets/scripts/app/views/myhome-sub-repos.js b/media/assets/scripts/app/views/myhome-sub-repos.js new file mode 100644 index 0000000000..240791111d --- /dev/null +++ b/media/assets/scripts/app/views/myhome-sub-repos.js @@ -0,0 +1,154 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common', + 'file-tree', + 'app/collections/repos', + 'app/views/sub-lib', + 'app/views/add-repo', +], function($, _, Backbone, Common, FileTree, RepoCollection, RepoView, AddRepoView) { + 'use strict'; + + var ReposView = Backbone.View.extend({ + el: $('#repo-tabs'), + + events: { + 'click #sub-lib-create': 'createRepo', + }, + + initialize: function(options) { + this.$tabs = $('#repo-tabs'); + this.$table = this.$('#my-sub-repos table'); + this.$tableHead = $('thead', this.$table); + this.$tableBody = $('tbody', this.$table); + this.$loadingTip = $('.loading-tip', this.$tabs); + this.$emptyTip = $('#my-sub-repos .empty-tips'); + + this.repos = new RepoCollection({type: 'sub'}); + this.listenTo(this.repos, 'add', this.addOne); + this.listenTo(this.repos, 'reset', this.reset); + }, + + addOne: function(repo, collection, options) { + var view = new RepoView({model: repo}); + if (options.prepend) { + this.$tableBody.prepend(view.render().el); + } else { + this.$tableBody.append(view.render().el); + } + }, + + reset: function() { + this.$tableBody.empty(); + this.repos.each(this.addOne, this); + if (this.repos.length) { + this.$emptyTip.hide(); + this.$table.show(); + } else { + this.$emptyTip.show(); + this.$table.hide(); + } + this.$loadingTip.hide(); + }, + + showSubRepos: function() { + this.repos.fetch({reset: true}); + this.$tabs.show(); + this.$table.hide(); + this.$loadingTip.show(); + $('#sublib-tab', this.$tabs).parent().addClass('ui-state-active'); + }, + + show: function() { + $('#sub-lib-create').show(); + this.showSubRepos(); + }, + + hide: function() { + $('#sub-lib-create').hide(); + this.$el.hide(); + this.$table.hide(); + this.$emptyTip.hide(); + $('#sublib-tab', this.$tabs).parent().removeClass('ui-state-active'); + }, + + createRepo: function() { + var _this = this; + + var sublib_create_form = $('#sublib-create-form'); + + var dir_tree_cont = $('.dir-tree-cont', sublib_create_form); + sublib_create_form.modal(); + + $.ajax({ + url: Common.getUrl({'name': 'get_my_unenc_repos'}), + cache: false, + dataType: 'json', + success: function(data) { + var repos = FileTree.formatRepoData(data); + if (repos.length > 0) { + FileTree.renderDirTree(dir_tree_cont, sublib_create_form, repos); + } else { + dir_tree_cont.html('

' + gettext("You don't have any library at present.") + '

'); + } + }, + error: function(jqXHR, textStatus, errorThrown) { + var error; + if (jqXHR.responseText) { + error = $.parseJSON(jqXHR.responseText).error; + } else { + error = gettext("Failed. Please check the network."); + } + dir_tree_cont.html('

' + error + '

'); + } + }); + + $('.submit', sublib_create_form).click(function() { + var ori_repo_id = $('[name="dst_repo"]', sublib_create_form).val(); + var path = $('[name="dst_path"]', sublib_create_form).val(); + + if (!path || path == '/') { + $('.error', sublib_create_form).html(gettext("Please choose a directory")).removeClass('hide'); + return false; + } + + // path ends with '/', rm it here + path = path.substr(0, path.length - 1); + $.ajax({ + url: Common.getUrl({'name':'sub_repo', 'repo_id':ori_repo_id}) + '?p=' + encodeURIComponent(path), + dataType: 'json', + success: function(data) { + $.modal.close(); + if (_this.repos.length > 0) { + _this.repos.add({ + 'id': data["sub_repo_id"], + 'name': data["name"], + 'origin_repo_id': ori_repo_id, + 'origin_path': path, + 'abbrev_origin_path': data["abbrev_origin_path"], + 'mtime': new Date().getTime() / 1000, + 'mtime_relative': gettext("Just now") + }, {prepend: true}); + } else { + _this.showMyRepos(); + } + }, + error: function(xhr, textStatus, errorThrown) { + var err; + if (xhr.responseText) { + err = jQuery.parseJSON(xhr.responseText).error; + } else { + err = gettext("Failed. Please check the network."); + } + $('.error', sublib_create_form).html(err).removeClass('hide'); + } + }); + return false; + }); + } + + }); + + return ReposView; +}); diff --git a/media/assets/scripts/app/views/myhome.05696a550d46.js b/media/assets/scripts/app/views/myhome.05696a550d46.js new file mode 100644 index 0000000000..d27e43b17f --- /dev/null +++ b/media/assets/scripts/app/views/myhome.05696a550d46.js @@ -0,0 +1,72 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common', + 'app/views/myhome-repos', + 'app/views/myhome-sub-repos', + 'app/views/myhome-shared-repos', + 'app/views/myhome-side-nav' +], function($, _, Backbone, Common, ReposView, SubReposView, + SharedReposView, MyhomeSideNavView) { + 'use strict'; + + var MyHomeView = Backbone.View.extend({ + el: '#main', + + initialize: function(options) { + this.sideNavView = new MyhomeSideNavView(); + + this.reposView = new ReposView(); + this.subReposView = new SubReposView(); + this.sharedReposView = new SharedReposView(); + + this.dirView = options.dirView; + + this.currentView = this.reposView; + + $('#initial-loading-view').hide(); + }, + + showSideNav: function () { + this.sideNavView.show(); + }, + + showMyRepos: function() { + this.showSideNav(); + this.currentView.hide(); + this.reposView.show(); + this.currentView = this.reposView; + }, + + showMySubRepos: function() { + this.showSideNav(); + this.currentView.hide(); + this.subReposView.show(); + this.currentView = this.subReposView; + }, + + showSharedRepos: function() { + this.showSideNav(); + this.currentView.hide(); + this.sharedReposView.show(); + this.currentView = this.sharedReposView; + }, + + showDir: function(category, repo_id, path) { + this.showSideNav(); + var path = path || '/'; + this.currentView.hide(); + this.dirView.showDir(category, repo_id, path); + this.currentView = this.dirView; + }, + + hide: function() { + this.currentView.hide(); + this.sideNavView.hide(); + } + + }); + + return MyHomeView; +}); diff --git a/media/assets/scripts/app/views/myhome.js b/media/assets/scripts/app/views/myhome.js new file mode 100644 index 0000000000..d27e43b17f --- /dev/null +++ b/media/assets/scripts/app/views/myhome.js @@ -0,0 +1,72 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common', + 'app/views/myhome-repos', + 'app/views/myhome-sub-repos', + 'app/views/myhome-shared-repos', + 'app/views/myhome-side-nav' +], function($, _, Backbone, Common, ReposView, SubReposView, + SharedReposView, MyhomeSideNavView) { + 'use strict'; + + var MyHomeView = Backbone.View.extend({ + el: '#main', + + initialize: function(options) { + this.sideNavView = new MyhomeSideNavView(); + + this.reposView = new ReposView(); + this.subReposView = new SubReposView(); + this.sharedReposView = new SharedReposView(); + + this.dirView = options.dirView; + + this.currentView = this.reposView; + + $('#initial-loading-view').hide(); + }, + + showSideNav: function () { + this.sideNavView.show(); + }, + + showMyRepos: function() { + this.showSideNav(); + this.currentView.hide(); + this.reposView.show(); + this.currentView = this.reposView; + }, + + showMySubRepos: function() { + this.showSideNav(); + this.currentView.hide(); + this.subReposView.show(); + this.currentView = this.subReposView; + }, + + showSharedRepos: function() { + this.showSideNav(); + this.currentView.hide(); + this.sharedReposView.show(); + this.currentView = this.sharedReposView; + }, + + showDir: function(category, repo_id, path) { + this.showSideNav(); + var path = path || '/'; + this.currentView.hide(); + this.dirView.showDir(category, repo_id, path); + this.currentView = this.dirView; + }, + + hide: function() { + this.currentView.hide(); + this.sideNavView.hide(); + } + + }); + + return MyHomeView; +}); diff --git a/media/assets/scripts/app/views/organization-repo.85337c75bb59.js b/media/assets/scripts/app/views/organization-repo.85337c75bb59.js new file mode 100644 index 0000000000..d67649845f --- /dev/null +++ b/media/assets/scripts/app/views/organization-repo.85337c75bb59.js @@ -0,0 +1,61 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common' +], function($, _, Backbone, Common) { + 'use strict'; + + var OrganizationRepoView = Backbone.View.extend({ + tagName: 'tr', + + template: _.template($('#organization-repo-tmpl').html()), + + initialize: function() { + }, + + render: function() { + this.$el.html(this.template(this.model.toJSON())); + return this; + }, + + events: { + 'mouseenter': 'highlight', + 'mouseleave': 'rmHighlight', + 'click .cancel-share': 'removeShare' + }, + + highlight: function() { + this.$el.addClass('hl').find('.op-icon').removeClass('vh'); + }, + + rmHighlight: function() { + this.$el.removeClass('hl').find('.op-icon').addClass('vh'); + }, + + removeShare: function() { + var el = this.$el; + var lib_name = this.model.get('name'); + Common.ajaxGet({ + get_url: Common.getUrl({ + name: 'ajax_unset_inner_pub_repo', + repo_id: this.model.get('id') + }), + data: { + 'permission': this.model.get('permission') + }, + after_op_success: function () { + el.remove(); + var msg = gettext('Successfully unshared {placeholder}').replace('{placeholder}', '' + Common.HTMLescape(lib_name) + ''); + Common.feedback(msg, 'success', Common.SUCCESS_TIMOUT); + }, + after_op_error: function(xhr) { + Common.ajaxErrorHandler(xhr); + } + }); + } + + }); + + return OrganizationRepoView; +}); diff --git a/media/assets/scripts/app/views/organization-repo.js b/media/assets/scripts/app/views/organization-repo.js new file mode 100644 index 0000000000..d67649845f --- /dev/null +++ b/media/assets/scripts/app/views/organization-repo.js @@ -0,0 +1,61 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common' +], function($, _, Backbone, Common) { + 'use strict'; + + var OrganizationRepoView = Backbone.View.extend({ + tagName: 'tr', + + template: _.template($('#organization-repo-tmpl').html()), + + initialize: function() { + }, + + render: function() { + this.$el.html(this.template(this.model.toJSON())); + return this; + }, + + events: { + 'mouseenter': 'highlight', + 'mouseleave': 'rmHighlight', + 'click .cancel-share': 'removeShare' + }, + + highlight: function() { + this.$el.addClass('hl').find('.op-icon').removeClass('vh'); + }, + + rmHighlight: function() { + this.$el.removeClass('hl').find('.op-icon').addClass('vh'); + }, + + removeShare: function() { + var el = this.$el; + var lib_name = this.model.get('name'); + Common.ajaxGet({ + get_url: Common.getUrl({ + name: 'ajax_unset_inner_pub_repo', + repo_id: this.model.get('id') + }), + data: { + 'permission': this.model.get('permission') + }, + after_op_success: function () { + el.remove(); + var msg = gettext('Successfully unshared {placeholder}').replace('{placeholder}', '' + Common.HTMLescape(lib_name) + ''); + Common.feedback(msg, 'success', Common.SUCCESS_TIMOUT); + }, + after_op_error: function(xhr) { + Common.ajaxErrorHandler(xhr); + } + }); + } + + }); + + return OrganizationRepoView; +}); diff --git a/media/assets/scripts/app/views/organization.dcf0e843b140.js b/media/assets/scripts/app/views/organization.dcf0e843b140.js new file mode 100644 index 0000000000..2e8eb87059 --- /dev/null +++ b/media/assets/scripts/app/views/organization.dcf0e843b140.js @@ -0,0 +1,125 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common', + 'app/collections/pub-repos', + 'app/views/organization-repo', + 'app/views/add-pub-repo' +], function($, _, Backbone, Common, PubRepoCollection, OrganizationRepoView, + AddPubRepoView) { + 'use strict'; + + var OrganizationView = Backbone.View.extend({ + el: '#main', + + initialize: function(options) { + + this.$sideNav = $('#org-side-nav'); + this.$reposDiv = $('#organization-repos'); + this.$table = $('#organization-repos table'); + this.$tableBody = $('tbody', this.$table); + this.$loadingTip = $('#organization-repos .loading-tip'); + this.$emptyTip = $('#organization-repos .empty-tips'); + + this.repos = new PubRepoCollection(); + this.listenTo(this.repos, 'add', this.addOne); + this.listenTo(this.repos, 'reset', this.reset); + + this.dirView = options.dirView; + }, + + events: { + 'click #organization-repos .repo-create': 'createRepo', + 'click #organization-repos .by-name': 'sortByName', + 'click #organization-repos .by-time': 'sortByTime' + }, + + createRepo: function() { + new AddPubRepoView(this.repos); + }, + + addOne: function(repo, collection, options) { + var view = new OrganizationRepoView({model: repo, collection: this.repos}); + if (options.prepend) { + this.$tableBody.prepend(view.render().el); + } else { + this.$tableBody.append(view.render().el); + } + }, + + reset: function() { + this.$tableBody.empty(); + this.repos.each(this.addOne, this); + if (this.repos.length) { + this.$emptyTip.hide(); + this.$table.show(); + } else { + this.$emptyTip.show(); + this.$table.hide(); + } + this.$loadingTip.hide(); + }, + + showRepoList: function() { + this.$sideNav.show(); + this.dirView.hide(); + this.$reposDiv.show(); + this.repos.fetch({reset: true}); + this.$loadingTip.show(); + }, + + hideRepoList: function() { + this.$reposDiv.hide(); + }, + + showDir: function(repo_id, path) { + this.$sideNav.show(); + var path = path || '/'; + this.hideRepoList(); + this.dirView.showDir('org', repo_id, path); + }, + + sortByName: function() { + var repos = this.repos; + var el = $('.by-name', this.$table); + repos.comparator = function(a, b) { // a, b: model + if (el.hasClass('icon-caret-up')) { + return a.get('name').toLowerCase() < b.get('name').toLowerCase() ? 1 : -1; + } else { + return a.get('name').toLowerCase() < b.get('name').toLowerCase() ? -1 : 1; + } + }; + repos.sort(); + this.$tableBody.empty(); + repos.each(this.addOne, this); + el.toggleClass('icon-caret-up icon-caret-down'); + }, + + sortByTime: function() { + var repos = this.repos; + var el = $('.by-time', this.$table); + repos.comparator = function(a, b) { // a, b: model + if (el.hasClass('icon-caret-down')) { + return a.get('mtime') < b.get('mtime') ? 1 : -1; + } else { + return a.get('mtime') < b.get('mtime') ? -1 : 1; + } + }; + repos.sort(); + this.$tableBody.empty(); + repos.each(this.addOne, this); + el.toggleClass('icon-caret-up icon-caret-down'); + }, + + hide: function() { + this.$sideNav.hide(); + this.hideRepoList(); + this.$emptyTip.hide(); + this.dirView.hide(); + } + + }); + + return OrganizationView; +}); diff --git a/media/assets/scripts/app/views/organization.js b/media/assets/scripts/app/views/organization.js new file mode 100644 index 0000000000..2e8eb87059 --- /dev/null +++ b/media/assets/scripts/app/views/organization.js @@ -0,0 +1,125 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common', + 'app/collections/pub-repos', + 'app/views/organization-repo', + 'app/views/add-pub-repo' +], function($, _, Backbone, Common, PubRepoCollection, OrganizationRepoView, + AddPubRepoView) { + 'use strict'; + + var OrganizationView = Backbone.View.extend({ + el: '#main', + + initialize: function(options) { + + this.$sideNav = $('#org-side-nav'); + this.$reposDiv = $('#organization-repos'); + this.$table = $('#organization-repos table'); + this.$tableBody = $('tbody', this.$table); + this.$loadingTip = $('#organization-repos .loading-tip'); + this.$emptyTip = $('#organization-repos .empty-tips'); + + this.repos = new PubRepoCollection(); + this.listenTo(this.repos, 'add', this.addOne); + this.listenTo(this.repos, 'reset', this.reset); + + this.dirView = options.dirView; + }, + + events: { + 'click #organization-repos .repo-create': 'createRepo', + 'click #organization-repos .by-name': 'sortByName', + 'click #organization-repos .by-time': 'sortByTime' + }, + + createRepo: function() { + new AddPubRepoView(this.repos); + }, + + addOne: function(repo, collection, options) { + var view = new OrganizationRepoView({model: repo, collection: this.repos}); + if (options.prepend) { + this.$tableBody.prepend(view.render().el); + } else { + this.$tableBody.append(view.render().el); + } + }, + + reset: function() { + this.$tableBody.empty(); + this.repos.each(this.addOne, this); + if (this.repos.length) { + this.$emptyTip.hide(); + this.$table.show(); + } else { + this.$emptyTip.show(); + this.$table.hide(); + } + this.$loadingTip.hide(); + }, + + showRepoList: function() { + this.$sideNav.show(); + this.dirView.hide(); + this.$reposDiv.show(); + this.repos.fetch({reset: true}); + this.$loadingTip.show(); + }, + + hideRepoList: function() { + this.$reposDiv.hide(); + }, + + showDir: function(repo_id, path) { + this.$sideNav.show(); + var path = path || '/'; + this.hideRepoList(); + this.dirView.showDir('org', repo_id, path); + }, + + sortByName: function() { + var repos = this.repos; + var el = $('.by-name', this.$table); + repos.comparator = function(a, b) { // a, b: model + if (el.hasClass('icon-caret-up')) { + return a.get('name').toLowerCase() < b.get('name').toLowerCase() ? 1 : -1; + } else { + return a.get('name').toLowerCase() < b.get('name').toLowerCase() ? -1 : 1; + } + }; + repos.sort(); + this.$tableBody.empty(); + repos.each(this.addOne, this); + el.toggleClass('icon-caret-up icon-caret-down'); + }, + + sortByTime: function() { + var repos = this.repos; + var el = $('.by-time', this.$table); + repos.comparator = function(a, b) { // a, b: model + if (el.hasClass('icon-caret-down')) { + return a.get('mtime') < b.get('mtime') ? 1 : -1; + } else { + return a.get('mtime') < b.get('mtime') ? -1 : 1; + } + }; + repos.sort(); + this.$tableBody.empty(); + repos.each(this.addOne, this); + el.toggleClass('icon-caret-up icon-caret-down'); + }, + + hide: function() { + this.$sideNav.hide(); + this.hideRepoList(); + this.$emptyTip.hide(); + this.dirView.hide(); + } + + }); + + return OrganizationView; +}); diff --git a/media/assets/scripts/app/views/repo.ddaeff40f80b.js b/media/assets/scripts/app/views/repo.ddaeff40f80b.js new file mode 100644 index 0000000000..da1fc16934 --- /dev/null +++ b/media/assets/scripts/app/views/repo.ddaeff40f80b.js @@ -0,0 +1,105 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common', + 'app/views/share' +], function($, _, Backbone, Common, ShareView) { + 'use strict'; + + var RepoView = Backbone.View.extend({ + tagName: 'tr', + + template: _.template($('#repo-tmpl').html()), + repoDelConfirmTemplate: _.template($('#repo-del-confirm-template').html()), + + events: { + 'mouseenter': 'highlight', + 'mouseleave': 'rmHighlight', + 'click .repo-delete-btn': 'del', + 'click .repo-share-btn': 'share' + }, + + initialize: function() { + }, + + render: function() { + this.$el.html(this.template(this.model.toJSON())); + return this; + }, + + // disable 'hover' when 'repo-del-confirm' popup is shown + highlight: function() { + if ($('#my-own-repos .repo-del-confirm').length == 0) { + this.$el.addClass('hl').find('.op-icon').removeClass('vh'); + } + }, + + rmHighlight: function() { + if ($('#my-own-repos .repo-del-confirm').length == 0) { + this.$el.removeClass('hl').find('.op-icon').addClass('vh'); + } + }, + + del: function() { + var del_icon = this.$('.repo-delete-btn'); + var op_container = this.$('.op-container').css({'position': 'relative'}); + + var confirm_msg = gettext("Really want to delete {lib_name}?") + .replace('{lib_name}', '' + Common.HTMLescape(this.model.get('name')) + ''); + var confirm_popup = $(this.repoDelConfirmTemplate({ + content: confirm_msg + })) + .appendTo(op_container) + .css({ + 'left': del_icon.position().left, + 'top': del_icon.position().top + del_icon.height() + 2, + 'width': 180 + }); + + var _this = this; + $('.no', confirm_popup).click(function() { + confirm_popup.addClass('hide').remove(); // `addClass('hide')`: to rm cursor + _this.rmHighlight(); + }); + $('.yes', confirm_popup).click(function() { + $.ajax({ + url: Common.getUrl({'name':'repo_del', 'repo_id': _this.model.get('id')}), + dataType: 'json', + success: function(data) { + _this.remove(); + Common.feedback(gettext("Delete succeeded."), 'success'); + }, + error: function(xhr) { + confirm_popup.addClass('hide').remove(); + _this.rmHighlight(); + + var err; + if (xhr.responseText) { + err = $.parseJSON(xhr.responseText).error; + } else { + err = gettext("Failed. Please check the network."); + } + Common.feedback(err, 'error'); + } + }); + }); + }, + + share: function() { + var options = { + 'is_repo_owner': true, + 'is_virtual': this.model.get('virtual'), + 'user_perm': this.model.get('permission'), + 'repo_id': this.model.get('id'), + 'is_dir': true, + 'dirent_path': '/', + 'obj_name': this.model.get('name') + }; + new ShareView(options); + } + + }); + + return RepoView; +}); diff --git a/media/assets/scripts/app/views/repo.js b/media/assets/scripts/app/views/repo.js new file mode 100644 index 0000000000..da1fc16934 --- /dev/null +++ b/media/assets/scripts/app/views/repo.js @@ -0,0 +1,105 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common', + 'app/views/share' +], function($, _, Backbone, Common, ShareView) { + 'use strict'; + + var RepoView = Backbone.View.extend({ + tagName: 'tr', + + template: _.template($('#repo-tmpl').html()), + repoDelConfirmTemplate: _.template($('#repo-del-confirm-template').html()), + + events: { + 'mouseenter': 'highlight', + 'mouseleave': 'rmHighlight', + 'click .repo-delete-btn': 'del', + 'click .repo-share-btn': 'share' + }, + + initialize: function() { + }, + + render: function() { + this.$el.html(this.template(this.model.toJSON())); + return this; + }, + + // disable 'hover' when 'repo-del-confirm' popup is shown + highlight: function() { + if ($('#my-own-repos .repo-del-confirm').length == 0) { + this.$el.addClass('hl').find('.op-icon').removeClass('vh'); + } + }, + + rmHighlight: function() { + if ($('#my-own-repos .repo-del-confirm').length == 0) { + this.$el.removeClass('hl').find('.op-icon').addClass('vh'); + } + }, + + del: function() { + var del_icon = this.$('.repo-delete-btn'); + var op_container = this.$('.op-container').css({'position': 'relative'}); + + var confirm_msg = gettext("Really want to delete {lib_name}?") + .replace('{lib_name}', '' + Common.HTMLescape(this.model.get('name')) + ''); + var confirm_popup = $(this.repoDelConfirmTemplate({ + content: confirm_msg + })) + .appendTo(op_container) + .css({ + 'left': del_icon.position().left, + 'top': del_icon.position().top + del_icon.height() + 2, + 'width': 180 + }); + + var _this = this; + $('.no', confirm_popup).click(function() { + confirm_popup.addClass('hide').remove(); // `addClass('hide')`: to rm cursor + _this.rmHighlight(); + }); + $('.yes', confirm_popup).click(function() { + $.ajax({ + url: Common.getUrl({'name':'repo_del', 'repo_id': _this.model.get('id')}), + dataType: 'json', + success: function(data) { + _this.remove(); + Common.feedback(gettext("Delete succeeded."), 'success'); + }, + error: function(xhr) { + confirm_popup.addClass('hide').remove(); + _this.rmHighlight(); + + var err; + if (xhr.responseText) { + err = $.parseJSON(xhr.responseText).error; + } else { + err = gettext("Failed. Please check the network."); + } + Common.feedback(err, 'error'); + } + }); + }); + }, + + share: function() { + var options = { + 'is_repo_owner': true, + 'is_virtual': this.model.get('virtual'), + 'user_perm': this.model.get('permission'), + 'repo_id': this.model.get('id'), + 'is_dir': true, + 'dirent_path': '/', + 'obj_name': this.model.get('name') + }; + new ShareView(options); + } + + }); + + return RepoView; +}); diff --git a/media/assets/scripts/app/views/share.3b5d600852d2.js b/media/assets/scripts/app/views/share.3b5d600852d2.js new file mode 100644 index 0000000000..944f10e1a4 --- /dev/null +++ b/media/assets/scripts/app/views/share.3b5d600852d2.js @@ -0,0 +1,555 @@ +define([ + 'jquery', + 'underscore', + 'backbone', + 'common', + 'jquery.ui.tabs', + 'select2' +], function($, _, Backbone, Common, Tabs, Select2) { + 'use strict'; + + var SharePopupView = Backbone.View.extend({ + tagName: 'div', + id: 'share-popup', + template: _.template($('#share-popup-tmpl').html()), + + initialize: function(options) { + this.is_repo_owner = options.is_repo_owner; + this.is_virtual = options.is_virtual; + this.user_perm = options.user_perm; + this.repo_id = options.repo_id; + this.dirent_path = options.dirent_path; + this.obj_name = options.obj_name; + this.is_dir = options.is_dir; + + this.render(); + + this.$el.modal({ + appendTo: "#main", + focus: false, + containerCss: {"padding": 0} + }); + $('#simplemodal-container').css({'width':'auto', 'height':'auto'}); + + this.$("#share-tabs").tabs(); + + this.downloadLinkPanelInit(); + if (!this.is_dir && this.is_repo_owner) { + this.filePrivateSharePanelInit(); + } + if (this.is_dir) { + if (this.user_perm == 'rw') { + this.uploadLinkPanelInit(); + } + if (!this.is_virtual && this.is_repo_owner) { + this.dirPrivateSharePanelInit(); + } + } + }, + + render: function () { + this.$el.html(this.template({ + title: gettext("Share {placeholder}") + .replace('{placeholder}', '' + Common.HTMLescape(this.obj_name) + ''), + is_dir: this.is_dir, + is_repo_owner: this.is_repo_owner, + is_virtual: this.is_virtual, + user_perm: this.user_perm, + repo_id: this.repo_id + })); + + return this; + }, + + events: { + 'mouseenter .checkbox-label': 'highlightCheckbox', + 'mouseleave .checkbox-label': 'rmHighlightCheckbox', + 'click .checkbox-orig': 'clickCheckbox', + + // download link + 'submit #generate-download-link-form': 'generateDownloadLink', + 'click #send-download-link': 'showDownloadLinkSendForm', + 'submit #send-download-link-form': 'sendDownloadLink', + 'click #cancel-share-download-link': 'cancelShareDownloadLink', + 'click #delete-download-link': 'deleteDownloadLink', + + // upload link + 'submit #generate-upload-link-form': 'generateUploadLink', + 'click #send-upload-link': 'showUploadLinkSendForm', + 'submit #send-upload-link-form': 'sendUploadLink', + 'click #cancel-share-upload-link': 'cancelShareUploadLink', + 'click #delete-upload-link': 'deleteUploadLink', + + // file private share + 'submit #file-private-share-form': 'filePrivateShare', + + // dir private share + 'submit #dir-private-share-form': 'dirPrivateShare' + }, + + highlightCheckbox: function (e) { + $(e.currentTarget).addClass('hl'); + }, + + rmHighlightCheckbox: function (e) { + $(e.currentTarget).removeClass('hl'); + }, + + clickCheckbox: function(e) { + var el = e.currentTarget; + $(el).parent().toggleClass('checkbox-checked'); + // for link options such as 'password', 'expire' + $(el).closest('.checkbox-label').next().toggleClass('hide'); + }, + + downloadLinkPanelInit: function() { + var _this = this; + var after_op_success = function(data) { + _this.$('.loading-tip').hide(); + if (data['download_link']) { + _this.download_link = data["download_link"]; // for 'link send' + _this.download_link_token = data["token"]; // for 'link delete' + _this.$('#download-link').html(data['download_link']); // TODO: + _this.$('#download-link-operations').removeClass('hide'); + } else { + _this.$('#generate-download-link-form').removeClass('hide'); + } + }; + // check if downloadLink exists + Common.ajaxGet({ + 'get_url': Common.getUrl({name: 'get_shared_download_link'}), + 'data': { + 'repo_id': this.repo_id, + 'p': this.dirent_path, + 'type': this.is_dir ? 'd' : 'f' + }, + 'after_op_success': after_op_success + }); + }, + + generateLink: function(options) { + var link_type = options.link_type, // 'download' or 'upload' + form = options.form, + form_id = form.attr('id'), + use_passwd_checkbox = $('[name="use_passwd"]', form), + use_passwd = use_passwd_checkbox.prop('checked'); + if (link_type == 'download') { + var set_expiration_checkbox = $('[name="set_expiration"]', form), + set_expiration = set_expiration_checkbox.prop('checked'); + } + var post_data = {}; + + if (use_passwd) { + var passwd_input = $('[name="password"]', form), + passwd_again_input = $('[name="password_again"]', form), + passwd = $.trim(passwd_input.val()), + passwd_again = $.trim(passwd_again_input.val()); + if (!passwd) { + Common.showFormError(form_id, gettext("Please enter password")); + return false; + } + if (passwd.length < app.pageOptions.repo_password_min_length) { + Common.showFormError(form_id, gettext("Password is too short")); + return false; + } + if (!passwd_again) { + Common.showFormError(form_id, gettext("Please enter the password again")); + return false; + } + if (passwd != passwd_again) { + Common.showFormError(form_id, gettext("Passwords don't match")); + return false; + } + post_data["use_passwd"] = 1; + post_data["passwd"] = passwd; + } else { + post_data["use_passwd"] = 0; + } + + if (set_expiration) { // for upload link, 'set_expiration' is undefined + var expire_days_input = $('[name="expire_days"]', form), + expire_days = $.trim(expire_days_input.val()); + if (!expire_days) { + Common.showFormError(form_id, gettext("Please enter days.")); + return false; + } + if (Math.floor(expire_days) != expire_days || !$.isNumeric(expire_days)) { + Common.showFormError(form_id, gettext("Please enter valid days")); + return false; + }; + post_data["expire_days"] = expire_days; + } + + $('.error', form).addClass('hide').html(''); + var gen_btn = $('[type="submit"]', form); + Common.disableButton(gen_btn); + + $.extend(post_data, { + 'repo_id': this.repo_id, + 'p': this.dirent_path + }); + if (link_type == 'download') { + $.extend(post_data, { + 'type': this.is_dir? 'd' : 'f' + }); + } + + var _this = this; + var after_op_success = function(data) { + form.addClass('hide'); + // restore form state + Common.enableButton(gen_btn); + if (use_passwd) { + use_passwd_checkbox.prop('checked', false) + .parent().removeClass('checkbox-checked') + // hide password input + .end().closest('.checkbox-label').next().addClass('hide'); + passwd_input.val(''); + passwd_again_input.val(''); + } + if (set_expiration) { + set_expiration_checkbox.prop('checked', false) + .parent().removeClass('checkbox-checked') + // hide 'day' input + .end().closest('.checkbox-label').next().addClass('hide'); + expire_days_input.val(''); + } + + if (link_type == 'download') { + _this.$('#download-link').html(data["download_link"]); // TODO: add 'click & select' func + _this.download_link = data["download_link"]; // for 'link send' + _this.download_link_token = data["token"]; // for 'link delete' + _this.$('#download-link-operations').removeClass('hide'); + } else { + _this.$('#upload-link').html(data["upload_link"]); + _this.upload_link = data["upload_link"]; + _this.upload_link_token = data["token"]; + _this.$('#upload-link-operations').removeClass('hide'); + } + }; + + Common.ajaxPost({ + 'form': form, + 'post_url': options.post_url, + 'post_data': post_data, + 'after_op_success': after_op_success, + 'form_id': form_id + }); + }, + + generateDownloadLink: function() { + this.generateLink({ + link_type: 'download', + form: this.$('#generate-download-link-form'), + post_url: Common.getUrl({name: 'get_shared_download_link'}) + }); + return false; + }, + + showDownloadLinkSendForm: function() { + this.$('#send-download-link, #delete-download-link').addClass('hide'); + this.$('#send-download-link-form').removeClass('hide'); + // no addAutocomplete for email input + }, + + sendLink: function(options) { + // options: {form:$obj, other_post_data:{}, post_url:''} + var form = options.form, + form_id = form.attr('id'), + email = $.trim($('[name="email"]', form).val()), + extra_msg = $('textarea[name="extra_msg"]', form).val(); + + if (!email) { + Common.showFormError(form_id, gettext("Please input at least an email.")); + return false; + }; + + var submit_btn = $('[type="submit"]', form); + var sending_tip = $('.sending-tip', form); + Common.disableButton(submit_btn); + sending_tip.removeClass('hide'); + + var post_data = { + email: email, + extra_msg: extra_msg + }; + $.extend(post_data, options.other_post_data); + + var after_op_success = function(data) { + $.modal.close(); + var msg = gettext("Successfully sent to {placeholder}") + .replace('{placeholder}', Common.HTMLescape(data['send_success'].join(', '))); + Common.feedback(msg, 'success'); + if (data['send_failed'].length > 0) { + msg += '
' + gettext("Failed to send to {placeholder}") + .replace('{placeholder}', Common.HTMLescape(data['send_failed'].join(', '))); + Common.feedback(msg, 'info'); + } + }; + var after_op_error = function(xhr) { + sending_tip.addClass('hide'); + Common.enableButton(submit_btn); + var err; + if (xhr.responseText) { + err = $.parseJSON(xhr.responseText).error; + } else { + err = gettext("Failed. Please check the network."); + } + Common.showFormError(form_id, err); + Common.enableButton(submit_btn); + }; + + Common.ajaxPost({ + 'form': form, + 'post_url': options.post_url, + 'post_data': post_data, + 'after_op_success': after_op_success, + 'after_op_error': after_op_error, + 'form_id': form_id + }); + }, + + sendDownloadLink: function() { + this.sendLink({ + form: this.$('#send-download-link-form'), + other_post_data: { + file_shared_link: this.download_link, + file_shared_name: this.obj_name, + file_shared_type: this.is_dir ? 'd' : 'f' + }, + post_url: Common.getUrl({name: 'send_shared_download_link'}) + }); + return false; + }, + + cancelShareDownloadLink: function() { + this.$('#send-download-link, #delete-download-link').removeClass('hide'); + this.$('#send-download-link-form').addClass('hide'); + }, + + deleteDownloadLink: function() { + var _this = this; + var after_op_success = function(data) { + _this.$('#generate-download-link-form').removeClass('hide'), + _this.$('#download-link-operations').addClass('hide'); + }; + Common.ajaxGet({ + 'get_url': Common.getUrl({name: 'delete_shared_download_link'}), + 'data': { 't': _this.download_link_token }, + 'after_op_success': after_op_success + }); + }, + + uploadLinkPanelInit: function() { + var _this = this; + var after_op_success = function(data) { + if (data['upload_link']) { + _this.upload_link_token = data["token"]; + _this.upload_link = data["upload_link"]; + _this.$('#upload-link').html(data["upload_link"]); // TODO + _this.$('#upload-link-operations').removeClass('hide'); + } else { + _this.$('#generate-upload-link-form').removeClass('hide'); + } + }; + // check if upload link exists + Common.ajaxGet({ + 'get_url': Common.getUrl({name: 'get_share_upload_link'}), // TODO + 'data': {'repo_id': this.repo_id, 'p': this.dirent_path}, + 'after_op_success': after_op_success + }); + }, + + generateUploadLink: function(e) { + this.generateLink({ + link_type: 'upload', + form: this.$('#generate-upload-link-form'), + post_url: Common.getUrl({name: 'get_share_upload_link'}) + }); + return false; + }, + + showUploadLinkSendForm: function() { + this.$('#send-upload-link, #delete-upload-link').addClass('hide'); + this.$('#send-upload-link-form').removeClass('hide'); + // no addAutocomplete for email input + }, + + sendUploadLink: function() { + this.sendLink({ + form: this.$('#send-upload-link-form'), + other_post_data: { + shared_upload_link: this.upload_link + }, + post_url: Common.getUrl({name: 'send_shared_upload_link'}) + }); + return false; + }, + + cancelShareUploadLink: function() { + this.$('#send-upload-link, #delete-upload-link').removeClass('hide'); + this.$('#send-upload-link-form').addClass('hide'); + }, + + deleteUploadLink: function() { + var _this = this; + var after_op_success = function(data) { + _this.$('#generate-upload-link-form').removeClass('hide'), + _this.$('#upload-link-operations').addClass('hide'); + }; + Common.ajaxGet({ + 'get_url': Common.getUrl({name: 'delete_shared_upload_link'}), + 'data': { 't': _this.upload_link_token }, + 'after_op_success': after_op_success + }); + }, + + filePrivateSharePanelInit: function() { + var loading_tip = this.$('.loading-tip'); + var form = this.$('#file-private-share-form'); + loading_tip.show(); + + var contacts = app.pageOptions.contacts || []; + $('[name="emails"]', form).select2({ + placeholder: gettext("Select contacts or input"), + width: '400px', + // with 'tags', the user can directly enter, not just select + // tags need ``, not ``, not `"+"",e.querySelectorAll("[msallowcapture^='']").length&&m.push("[*^$]="+j+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||m.push("\\["+j+"*(?:value|"+B+")"),e.querySelectorAll("[id~="+w+"-]").length||m.push("~="),e.querySelectorAll(":checked").length||m.push(":checked"),e.querySelectorAll("a#"+w+"+*").length||m.push(".#.+[+~]")}),ft(function(e){var t=o.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&m.push("name"+j+"*[*^$|!~]?="),e.querySelectorAll(":enabled").length||m.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),m.push(",.*:")});return(n.matchesSelector=Y.test(y=d.matches||d.webkitMatchesSelector||d.mozMatchesSelector||d.oMatchesSelector||d.msMatchesSelector))&&ft(function(e){n.disconnectedMatch=y.call(e,"div"),y.call(e,"[s!='']:x"),g.push("!=",R)}),m=m.length&&new RegExp(m.join("|")),g=g.length&&new RegExp(g.join("|")),t=Y.test(d.compareDocumentPosition),b=t||Y.test(d.contains)?function(e,t){var n=e.nodeType===9?e.documentElement:e,r=t&&t.parentNode;return e===r||!!r&&r.nodeType===1&&!!(n.contains?n.contains(r):e.compareDocumentPosition&&e.compareDocumentPosition(r)&16)}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},k=t?function(e,t){if(e===t)return c=!0,0;var r=!e.compareDocumentPosition-!t.compareDocumentPosition;return r?r:(r=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1,r&1||!n.sortDetached&&t.compareDocumentPosition(e)===r?e===o||e.ownerDocument===E&&b(E,e)?-1:t===o||t.ownerDocument===E&&b(E,t)?1:l?H(l,e)-H(l,t):0:r&4?-1:1)}:function(e,t){if(e===t)return c=!0,0;var n,r=0,i=e.parentNode,s=t.parentNode,u=[e],a=[t];if(!i||!s)return e===o?-1:t===o?1:i?-1:s?1:l?H(l,e)-H(l,t):0;if(i===s)return ct(e,t);n=e;while(n=n.parentNode)u.unshift(n);n=t;while(n=n.parentNode)a.unshift(n);while(u[r]===a[r])r++;return r?ct(u[r],a[r]):u[r]===E?-1:a[r]===E?1:0},o},ot.matches=function(e,t){return ot(e,null,null,t)},ot.matchesSelector=function(e,t){(e.ownerDocument||e)!==p&&h(e),t=t.replace(V,"='$1']");if(n.matchesSelector&&v&&(!g||!g.test(t))&&(!m||!m.test(t)))try{var r=y.call(e,t);if(r||n.disconnectedMatch||e.document&&e.document.nodeType!==11)return r}catch(i){}return ot(t,p,null,[e]).length>0},ot.contains=function(e,t){return(e.ownerDocument||e)!==p&&h(e),b(e,t)},ot.attr=function(e,t){(e.ownerDocument||e)!==p&&h(e);var i=r.attrHandle[t.toLowerCase()],s=i&&A.call(r.attrHandle,t.toLowerCase())?i(e,t,!v):undefined;return s!==undefined?s:n.attributes||!v?e.getAttribute(t):(s=e.getAttributeNode(t))&&s.specified?s.value:null},ot.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},ot.uniqueSort=function(e){var t,r=[],i=0,s=0;c=!n.detectDuplicates,l=!n.sortStable&&e.slice(0),e.sort(k);if(c){while(t=e[s++])t===e[s]&&(i=r.push(s));while(i--)e.splice(r[i],1)}return l=null,e},i=ot.getText=function(e){var t,n="",r=0,s=e.nodeType;if(!s)while(t=e[r++])n+=i(t);else if(s===1||s===9||s===11){if(typeof e.textContent=="string")return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=i(e)}else if(s===3||s===4)return e.nodeValue;return n},r=ot.selectors={cacheLength:50,createPseudo:at,match:K,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(nt,rt),e[3]=(e[3]||e[4]||e[5]||"").replace(nt,rt),e[2]==="~="&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),e[1].slice(0,3)==="nth"?(e[3]||ot.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*(e[3]==="even"||e[3]==="odd")),e[5]=+(e[7]+e[8]||e[3]==="odd")):e[3]&&ot.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return K.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&$.test(n)&&(t=o(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(nt,rt).toLowerCase();return e==="*"?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=T[e+" "];return t||(t=new RegExp("(^|"+j+")"+e+"("+j+"|$)"))&&T(e,function(e){return t.test(typeof e.className=="string"&&e.className||typeof e.getAttribute!="undefined"&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=ot.attr(r,e);return i==null?t==="!=":t?(i+="",t==="="?i===n:t==="!="?i!==n:t==="^="?n&&i.indexOf(n)===0:t==="*="?n&&i.indexOf(n)>-1:t==="$="?n&&i.slice(-n.length)===n:t==="~="?(" "+i.replace(U," ")+" ").indexOf(n)>-1:t==="|="?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var s=e.slice(0,3)!=="nth",o=e.slice(-4)!=="last",u=t==="of-type";return r===1&&i===0?function(e){return!!e.parentNode}:function(t,n,a){var f,l,c,h,p,d,v=s!==o?"nextSibling":"previousSibling",m=t.parentNode,g=u&&t.nodeName.toLowerCase(),y=!a&&!u;if(m){if(s){while(v){c=t;while(c=c[v])if(u?c.nodeName.toLowerCase()===g:c.nodeType===1)return!1;d=v=e==="only"&&!d&&"nextSibling"}return!0}d=[o?m.firstChild:m.lastChild];if(o&&y){l=m[w]||(m[w]={}),f=l[e]||[],p=f[0]===S&&f[1],h=f[0]===S&&f[2],c=p&&m.childNodes[p];while(c=++p&&c&&c[v]||(h=p=0)||d.pop())if(c.nodeType===1&&++h&&c===t){l[e]=[S,p,h];break}}else if(y&&(f=(t[w]||(t[w]={}))[e])&&f[0]===S)h=f[1];else while(c=++p&&c&&c[v]||(h=p=0)||d.pop())if((u?c.nodeName.toLowerCase()===g:c.nodeType===1)&&++h){y&&((c[w]||(c[w]={}))[e]=[S,h]);if(c===t)break}return h-=i,h===r||h%r===0&&h/r>=0}}},PSEUDO:function(e,t){var n,i=r.pseudos[e]||r.setFilters[e.toLowerCase()]||ot.error("unsupported pseudo: "+e);return i[w]?i(t):i.length>1?(n=[e,e,"",t],r.setFilters.hasOwnProperty(e.toLowerCase())?at(function(e,n){var r,s=i(e,t),o=s.length;while(o--)r=H(e,s[o]),e[r]=!(n[r]=s[o])}):function(e){return i(e,0,n)}):i}},pseudos:{not:at(function(e){var t=[],n=[],r=u(e.replace(z,"$1"));return r[w]?at(function(e,t,n,i){var s,o=r(e,null,i,[]),u=e.length;while(u--)if(s=o[u])e[u]=!(t[u]=s)}):function(e,i,s){return t[0]=e,r(t,null,s,n),t[0]=null,!n.pop()}}),has:at(function(e){return function(t){return ot(e,t).length>0}}),contains:at(function(e){return e=e.replace(nt,rt),function(t){return(t.textContent||t.innerText||i(t)).indexOf(e)>-1}}),lang:at(function(e){return J.test(e||"")||ot.error("unsupported lang: "+e),e=e.replace(nt,rt).toLowerCase(),function(t){var n;do if(n=v?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return n=n.toLowerCase(),n===e||n.indexOf(e+"-")===0;while((t=t.parentNode)&&t.nodeType===1);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===d},focus:function(e){return e===p.activeElement&&(!p.hasFocus||p.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return t==="input"&&!!e.checked||t==="option"&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!r.pseudos.empty(e)},header:function(e){return G.test(e.nodeName)},input:function(e){return Q.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return t==="input"&&e.type==="button"||t==="button"},text:function(e){var t;return e.nodeName.toLowerCase()==="input"&&e.type==="text"&&((t=e.getAttribute("type"))==null||t.toLowerCase()==="text")},first:dt(function(){return[0]}),last:dt(function(e,t){return[t-1]}),eq:dt(function(e,t,n){return[n<0?n+t:n]}),even:dt(function(e,t){var n=0;for(;n=0;)e.push(r);return e}),gt:dt(function(e,t,n){var r=n<0?n+t:n;for(;++r2&&(l=f[0]).type==="ID"&&n.getById&&t.nodeType===9&&v&&r.relative[f[1].type]){t=(r.find.ID(l.matches[0].replace(nt,rt),t)||[])[0];if(!t)return i;p&&(t=t.parentNode),e=e.slice(f.shift().value.length)}a=K.needsContext.test(e)?0:f.length;while(a--){l=f[a];if(r.relative[c=l.type])break;if(h=r.find[c])if(s=h(l.matches[0].replace(nt,rt),et.test(f[0].type)&&vt(t.parentNode)||t)){f.splice(a,1),e=s.length&>(f);if(!e)return D.apply(i,s),i;break}}}return(p||u(e,d))(s,t,!v,i,et.test(e)&&vt(t.parentNode)||t),i},n.sortStable=w.split("").sort(k).join("")===w,n.detectDuplicates=!!c,h(),n.sortDetached=ft(function(e){return e.compareDocumentPosition(p.createElement("div"))&1}),ft(function(e){return e.innerHTML="",e.firstChild.getAttribute("href")==="#"})||lt("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,t.toLowerCase()==="type"?1:2)}),(!n.attributes||!ft(function(e){return e.innerHTML="",e.firstChild.setAttribute("value",""),e.firstChild.getAttribute("value")===""}))&<("value",function(e,t,n){if(!n&&e.nodeName.toLowerCase()==="input")return e.defaultValue}),ft(function(e){return e.getAttribute("disabled")==null})||lt(B,function(e,t,n){var r;if(!n)return e[t]===!0?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),ot}(e);h.find=y,h.expr=y.selectors,h.expr[":"]=h.expr.pseudos,h.unique=y.uniqueSort,h.text=y.getText,h.isXMLDoc=y.isXML,h.contains=y.contains;var b=h.expr.match.needsContext,w=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,E=/^.[^:#\[\.,]*$/;h.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),t.length===1&&r.nodeType===1?h.find.matchesSelector(r,e)?[r]:[]:h.find.matches(e,h.grep(t,function(e){return e.nodeType===1}))},h.fn.extend({find:function(e){var t,n=[],r=this,i=r.length;if(typeof e!="string")return this.pushStack(h(e).filter(function(){for(t=0;t1?h.unique(n):n),n.selector=this.selector?this.selector+" "+e:e,n},filter:function(e){return this.pushStack(S(this,e||[],!1))},not:function(e){return this.pushStack(S(this,e||[],!0))},is:function(e){return!!S(this,typeof e=="string"&&b.test(e)?h(e):e||[],!1).length}});var x,T=e.document,N=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,C=h.fn.init=function(e,t){var n,r;if(!e)return this;if(typeof e=="string"){e.charAt(0)==="<"&&e.charAt(e.length-1)===">"&&e.length>=3?n=[null,e,null]:n=N.exec(e);if(n&&(n[1]||!t)){if(n[1]){t=t instanceof h?t[0]:t,h.merge(this,h.parseHTML(n[1],t&&t.nodeType?t.ownerDocument||t:T,!0));if(w.test(n[1])&&h.isPlainObject(t))for(n in t)h.isFunction(this[n])?this[n](t[n]):this.attr(n,t[n]);return this}r=T.getElementById(n[2]);if(r&&r.parentNode){if(r.id!==n[2])return x.find(e);this.length=1,this[0]=r}return this.context=T,this.selector=e,this}return!t||t.jquery?(t||x).find(e):this.constructor(t).find(e)}return e.nodeType?(this.context=this[0]=e,this.length=1,this):h.isFunction(e)?typeof x.ready!="undefined"?x.ready(e):e(h):(e.selector!==undefined&&(this.selector=e.selector,this.context=e.context),h.makeArray(e,this))};C.prototype=h.fn,x=h(T);var k=/^(?:parents|prev(?:Until|All))/,L={children:!0,contents:!0,next:!0,prev:!0};h.extend({dir:function(e,t,n){var r=[],i=e[t];while(i&&i.nodeType!==9&&(n===undefined||i.nodeType!==1||!h(i).is(n)))i.nodeType===1&&r.push(i),i=i[t];return r},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)e.nodeType===1&&e!==t&&n.push(e);return n}}),h.fn.extend({has:function(e){var t,n=h(e,this),r=n.length;return this.filter(function(){for(t=0;t-1:n.nodeType===1&&h.find.matchesSelector(n,e))){s.push(n);break}return this.pushStack(s.length>1?h.unique(s):s)},index:function(e){return e?typeof e=="string"?h.inArray(this[0],h(e)):h.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(h.unique(h.merge(this.get(),h(e,t))))},addBack:function(e){return this.add(e==null?this.prevObject:this.prevObject.filter(e))}}),h.each({parent:function(e){var t=e.parentNode;return t&&t.nodeType!==11?t:null},parents:function(e){return h.dir(e,"parentNode")},parentsUntil:function(e,t,n){return h.dir(e,"parentNode",n)},next:function(e){return A(e,"nextSibling")},prev:function(e){return A(e,"previousSibling")},nextAll:function(e){return h.dir(e,"nextSibling")},prevAll:function(e){return h.dir(e,"previousSibling")},nextUntil:function(e,t,n){return h.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return h.dir(e,"previousSibling",n)},siblings:function(e){return h.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return h.sibling(e.firstChild)},contents:function(e){return h.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:h.merge([],e.childNodes)}},function(e,t){h.fn[e]=function(n,r){var i=h.map(this,t,n);return e.slice(-5)!=="Until"&&(r=n),r&&typeof r=="string"&&(i=h.filter(r,i)),this.length>1&&(L[e]||(i=h.unique(i)),k.test(e)&&(i=i.reverse())),this.pushStack(i)}});var O=/\S+/g,M={};h.Callbacks=function(e){e=typeof e=="string"?M[e]||_(e):h.extend({},e);var t,n,r,i,s,o,u=[],a=!e.once&&[],f=function(c){n=e.memory&&c,r=!0,s=o||0,o=0,i=u.length,t=!0;for(;u&&s-1)u.splice(r,1),t&&(r<=i&&i--,r<=s&&s--)}),this},has:function(e){return e?h.inArray(e,u)>-1:!!u&&!!u.length},empty:function(){return u=[],i=0,this},disable:function(){return u=a=n=undefined,this},disabled:function(){return!u},lock:function(){return a=undefined,n||l.disable(),this},locked:function(){return!a},fireWith:function(e,n){return u&&(!r||a)&&(n=n||[],n=[e,n.slice?n.slice():n],t?a.push(n):f(n)),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!r}};return l},h.extend({Deferred:function(e){var t=[["resolve","done",h.Callbacks("once memory"),"resolved"],["reject","fail",h.Callbacks("once memory"),"rejected"],["notify","progress",h.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return h.Deferred(function(n){h.each(t,function(t,s){var o=h.isFunction(e[t])&&e[t];i[s[1]](function(){var e=o&&o.apply(this,arguments);e&&h.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[s[0]+"With"](this===r?n.promise():this,o?[e]:arguments)})}),e=null}).promise()},promise:function(e){return e!=null?h.extend(e,r):r}},i={};return r.pipe=r.then,h.each(t,function(e,s){var o=s[2],u=s[3];r[s[1]]=o.add,u&&o.add(function(){n=u},t[e^1][2].disable,t[2][2].lock),i[s[0]]=function(){return i[s[0]+"With"](this===i?r:this,arguments),this},i[s[0]+"With"]=o.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=r.call(arguments),i=n.length,s=i!==1||e&&h.isFunction(e.promise)?i:0,o=s===1?e:h.Deferred(),u=function(e,t,n){return function(i){t[e]=this,n[e]=arguments.length>1?r.call(arguments):i,n===a?o.notifyWith(t,n):--s||o.resolveWith(t,n)}},a,f,l;if(i>1){a=new Array(i),f=new Array(i),l=new Array(i);for(;t0)return;D.resolveWith(T,[h]),h.fn.triggerHandler&&(h(T).triggerHandler("ready"),h(T).off("ready"))}}),h.ready.promise=function(t){if(!D){D=h.Deferred();if(T.readyState==="complete")setTimeout(h.ready);else if(T.addEventListener)T.addEventListener("DOMContentLoaded",H,!1),e.addEventListener("load",H,!1);else{T.attachEvent("onreadystatechange",H),e.attachEvent("onload",H);var n=!1;try{n=e.frameElement==null&&T.documentElement}catch(r){}n&&n.doScroll&&function i(){if(!h.isReady){try{n.doScroll("left")}catch(e){return setTimeout(i,50)}P(),h.ready()}}()}}return D.promise(t)};var B=typeof undefined,j;for(j in h(l))break;l.ownLast=j!=="0",l.inlineBlockNeedsLayout=!1,h(function(){var e,t,n,r;n=T.getElementsByTagName("body")[0];if(!n||!n.style)return;t=T.createElement("div"),r=T.createElement("div"),r.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",n.appendChild(r).appendChild(t),typeof t.style.zoom!==B&&(t.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",l.inlineBlockNeedsLayout=e=t.offsetWidth===3,e&&(n.style.zoom=1)),n.removeChild(r)}),function(){var e=T.createElement("div");if(l.deleteExpando==null){l.deleteExpando=!0;try{delete e.test}catch(t){l.deleteExpando=!1}}e=null}(),h.acceptData=function(e){var t=h.noData[(e.nodeName+" ").toLowerCase()],n=+e.nodeType||1;return n!==1&&n!==9?!1:!t||t!==!0&&e.getAttribute("classid")===t};var F=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,I=/([A-Z])/g;h.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(e){return e=e.nodeType?h.cache[e[h.expando]]:e[h.expando],!!e&&!R(e)},data:function(e,t,n){return U(e,t,n)},removeData:function(e,t){return z(e,t)},_data:function(e,t,n){return U(e,t,n,!0)},_removeData:function(e,t){return z(e,t,!0)}}),h.fn.extend({data:function(e,t){var n,r,i,s=this[0],o=s&&s.attributes;if(e===undefined){if(this.length){i=h.data(s);if(s.nodeType===1&&!h._data(s,"parsedAttrs")){n=o.length;while(n--)o[n]&&(r=o[n].name,r.indexOf("data-")===0&&(r=h.camelCase(r.slice(5)),q(s,r,i[r])));h._data(s,"parsedAttrs",!0)}}return i}return typeof e=="object"?this.each(function(){h.data(this,e)}):arguments.length>1?this.each(function(){h.data(this,e,t)}):s?q(s,e,h.data(s,e)):undefined},removeData:function(e){return this.each(function(){h.removeData(this,e)})}}),h.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=h._data(e,t),n&&(!r||h.isArray(n)?r=h._data(e,t,h.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=h.queue(e,t),r=n.length,i=n.shift(),s=h._queueHooks(e,t),o=function(){h.dequeue(e,t)};i==="inprogress"&&(i=n.shift(),r--),i&&(t==="fx"&&n.unshift("inprogress"),delete s.stop,i.call(e,o,s)),!r&&s&&s.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return h._data(e,n)||h._data(e,n,{empty:h.Callbacks("once memory").add(function(){h._removeData(e,t+"queue"),h._removeData(e,n)})})}}),h.fn.extend({queue:function(e,t){var n=2;return typeof e!="string"&&(t=e,e="fx",n--),arguments.length
a",l.leadingWhitespace=t.firstChild.nodeType===3,l.tbody=!t.getElementsByTagName("tbody").length,l.htmlSerialize=!!t.getElementsByTagName("link").length,l.html5Clone=T.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",e.type="checkbox",e.checked=!0,n.appendChild(e),l.appendChecked=e.checked,t.innerHTML="",l.noCloneChecked=!!t.cloneNode(!0).lastChild.defaultValue,n.appendChild(t),t.innerHTML="",l.checkClone=t.cloneNode(!0).cloneNode(!0).lastChild.checked,l.noCloneEvent=!0,t.attachEvent&&(t.attachEvent("onclick",function(){l.noCloneEvent=!1}),t.cloneNode(!0).click());if(l.deleteExpando==null){l.deleteExpando=!0;try{delete t.test}catch(r){l.deleteExpando=!1}}})(),function(){var t,n,r=T.createElement("div");for(t in{submit:!0,change:!0,focusin:!0})n="on"+t,(l[t+"Bubbles"]=n in e)||(r.setAttribute(n,"t"),l[t+"Bubbles"]=r.attributes[n].expando===!1);r=null}();var K=/^(?:input|select|textarea)$/i,Q=/^key/,G=/^(?:mouse|pointer|contextmenu)|click/,Y=/^(?:focusinfocus|focusoutblur)$/,Z=/^([^.]*)(?:\.(.+)|)$/;h.event={global:{},add:function(e,t,n,r,i){var s,o,u,a,f,l,c,p,d,v,m,g=h._data(e);if(!g)return;n.handler&&(a=n,n=a.handler,i=a.selector),n.guid||(n.guid=h.guid++),(o=g.events)||(o=g.events={}),(l=g.handle)||(l=g.handle=function(e){return typeof h===B||!!e&&h.event.triggered===e.type?undefined:h.event.dispatch.apply(l.elem,arguments)},l.elem=e),t=(t||"").match(O)||[""],u=t.length;while(u--){s=Z.exec(t[u])||[],d=m=s[1],v=(s[2]||"").split(".").sort();if(!d)continue;f=h.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=h.event.special[d]||{},c=h.extend({type:d,origType:m,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&h.expr.match.needsContext.test(i),namespace:v.join(".")},a);if(!(p=o[d])){p=o[d]=[],p.delegateCount=0;if(!f.setup||f.setup.call(e,r,v,l)===!1)e.addEventListener?e.addEventListener(d,l,!1):e.attachEvent&&e.attachEvent("on"+d,l)}f.add&&(f.add.call(e,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),h.event.global[d]=!0}e=null},remove:function(e,t,n,r,i){var s,o,u,a,f,l,c,p,d,v,m,g=h.hasData(e)&&h._data(e);if(!g||!(l=g.events))return;t=(t||"").match(O)||[""],f=t.length;while(f--){u=Z.exec(t[f])||[],d=m=u[1],v=(u[2]||"").split(".").sort();if(!d){for(d in l)h.event.remove(e,d+t[f],n,r,!0);continue}c=h.event.special[d]||{},d=(r?c.delegateType:c.bindType)||d,p=l[d]||[],u=u[2]&&new RegExp("(^|\\.)"+v.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=s=p.length;while(s--)o=p[s],(i||m===o.origType)&&(!n||n.guid===o.guid)&&(!u||u.test(o.namespace))&&(!r||r===o.selector||r==="**"&&o.selector)&&(p.splice(s,1),o.selector&&p.delegateCount--,c.remove&&c.remove.call(e,o));a&&!p.length&&((!c.teardown||c.teardown.call(e,v,g.handle)===!1)&&h.removeEvent(e,d,g.handle),delete l[d])}h.isEmptyObject(l)&&(delete g.handle,h._removeData(e,"events"))},trigger:function(t,n,r,i){var s,o,u,a,l,c,p,d=[r||T],v=f.call(t,"type")?t.type:t,m=f.call(t,"namespace")?t.namespace.split("."):[];u=c=r=r||T;if(r.nodeType===3||r.nodeType===8)return;if(Y.test(v+h.event.triggered))return;v.indexOf(".")>=0&&(m=v.split("."),v=m.shift(),m.sort()),o=v.indexOf(":")<0&&"on"+v,t=t[h.expando]?t:new h.Event(v,typeof t=="object"&&t),t.isTrigger=i?2:3,t.namespace=m.join("."),t.namespace_re=t.namespace?new RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=undefined,t.target||(t.target=r),n=n==null?[t]:h.makeArray(n,[t]),l=h.event.special[v]||{};if(!i&&l.trigger&&l.trigger.apply(r,n)===!1)return;if(!i&&!l.noBubble&&!h.isWindow(r)){a=l.delegateType||v,Y.test(a+v)||(u=u.parentNode);for(;u;u=u.parentNode)d.push(u),c=u;c===(r.ownerDocument||T)&&d.push(c.defaultView||c.parentWindow||e)}p=0;while((u=d[p++])&&!t.isPropagationStopped())t.type=p>1?a:l.bindType||v,s=(h._data(u,"events")||{})[t.type]&&h._data(u,"handle"),s&&s.apply(u,n),s=o&&u[o],s&&s.apply&&h.acceptData(u)&&(t.result=s.apply(u,n),t.result===!1&&t.preventDefault());t.type=v;if(!i&&!t.isDefaultPrevented()&&(!l._default||l._default.apply(d.pop(),n)===!1)&&h.acceptData(r)&&o&&r[v]&&!h.isWindow(r)){c=r[o],c&&(r[o]=null),h.event.triggered=v;try{r[v]()}catch(g){}h.event.triggered=undefined,c&&(r[o]=c)}return t.result},dispatch:function(e){e=h.event.fix(e);var t,n,i,s,o,u=[],a=r.call(arguments),f=(h._data(this,"events")||{})[e.type]||[],l=h.event.special[e.type]||{};a[0]=e,e.delegateTarget=this;if(l.preDispatch&&l.preDispatch.call(this,e)===!1)return;u=h.event.handlers.call(this,e,f),t=0;while((s=u[t++])&&!e.isPropagationStopped()){e.currentTarget=s.elem,o=0;while((i=s.handlers[o++])&&!e.isImmediatePropagationStopped())if(!e.namespace_re||e.namespace_re.test(i.namespace))e.handleObj=i,e.data=i.data,n=((h.event.special[i.origType]||{}).handle||i.handler).apply(s.elem,a),n!==undefined&&(e.result=n)===!1&&(e.preventDefault(),e.stopPropagation())}return l.postDispatch&&l.postDispatch.call(this,e),e.result},handlers:function(e,t){var n,r,i,s,o=[],u=t.delegateCount,a=e.target;if(u&&a.nodeType&&(!e.button||e.type!=="click"))for(;a!=this;a=a.parentNode||this)if(a.nodeType===1&&(a.disabled!==!0||e.type!=="click")){i=[];for(s=0;s=0:h.find(n,this,null,[a]).length),i[n]&&i.push(r);i.length&&o.push({elem:a,handlers:i})}return u]","i"),ut=/^\s+/,at=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,ft=/<([\w:]+)/,lt=/\s*$/g,gt={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],_default:l.htmlSerialize?[0,"",""]:[1,"X
","
"]},yt=rt(T),bt=yt.appendChild(T.createElement("div"));gt.optgroup=gt.option,gt.tbody=gt.tfoot=gt.colgroup=gt.caption=gt.thead,gt.th=gt.td,h.extend({clone:function(e,t,n){var r,i,s,o,u,a=h.contains(e.ownerDocument,e);l.html5Clone||h.isXMLDoc(e)||!ot.test("<"+e.nodeName+">")?s=e.cloneNode(!0):(bt.innerHTML=e.outerHTML,bt.removeChild(s=bt.firstChild));if((!l.noCloneEvent||!l.noCloneChecked)&&(e.nodeType===1||e.nodeType===11)&&!h.isXMLDoc(e)){r=wt(s),u=wt(e);for(o=0;(i=u[o])!=null;++o)r[o]&&kt(i,r[o])}if(t)if(n){u=u||wt(e),r=r||wt(s);for(o=0;(i=u[o])!=null;o++)Ct(i,r[o])}else Ct(e,s);return r=wt(s,"script"),r.length>0&&Nt(r,!a&&wt(e,"script")),r=u=i=null,s},buildFragment:function(e,t,n,r){var i,s,o,u,a,f,c,p=e.length,d=rt(t),v=[],m=0;for(;m")+c[2],i=c[0];while(i--)u=u.lastChild;!l.leadingWhitespace&&ut.test(s)&&v.push(t.createTextNode(ut.exec(s)[0]));if(!l.tbody){s=a==="table"&&!lt.test(s)?u.firstChild:c[1]===""&&!lt.test(s)?u:0,i=s&&s.childNodes.length;while(i--)h.nodeName(f=s.childNodes[i],"tbody")&&!f.childNodes.length&&s.removeChild(f)}h.merge(v,u.childNodes),u.textContent="";while(u.firstChild)u.removeChild(u.firstChild);u=d.lastChild}}u&&d.removeChild(u),l.appendChecked||h.grep(wt(v,"input"),Et),m=0;while(s=v[m++]){if(r&&h.inArray(s,r)!==-1)continue;o=h.contains(s.ownerDocument,s),u=wt(d.appendChild(s),"script"),o&&Nt(u);if(n){i=0;while(s=u[i++])dt.test(s.type||"")&&n.push(s)}}return u=null,d},cleanData:function(e,t){var r,i,s,o,u=0,a=h.expando,f=h.cache,c=l.deleteExpando,p=h.event.special;for(;(r=e[u])!=null;u++)if(t||h.acceptData(r)){s=r[a],o=s&&f[s];if(o){if(o.events)for(i in o.events)p[i]?h.event.remove(r,i):h.removeEvent(r,i,o.handle);f[s]&&(delete f[s],c?delete r[a]:typeof r.removeAttribute!==B?r.removeAttribute(a):r[a]=null,n.push(s))}}}}),h.fn.extend({text:function(e){return $(this,function(e){return e===undefined?h.text(this):this.empty().append((this[0]&&this[0].ownerDocument||T).createTextNode(e))},null,e,arguments.length)},append:function(){return this.domManip(arguments,function(e){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var t=St(this,e);t.appendChild(e)}})},prepend:function(){return this.domManip(arguments,function(e){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var t=St(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=e?h.filter(e,this):this,i=0;for(;(n=r[i])!=null;i++)!t&&n.nodeType===1&&h.cleanData(wt(n)),n.parentNode&&(t&&h.contains(n.ownerDocument,n)&&Nt(wt(n,"script")),n.parentNode.removeChild(n));return this},empty:function(){var e,t=0;for(;(e=this[t])!=null;t++){e.nodeType===1&&h.cleanData(wt(e,!1));while(e.firstChild)e.removeChild(e.firstChild);e.options&&h.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=e==null?!1:e,t=t==null?e:t,this.map(function(){return h.clone(this,e,t)})},html:function(e){return $(this,function(e){var t=this[0]||{},n=0,r=this.length;if(e===undefined)return t.nodeType===1?t.innerHTML.replace(st,""):undefined;if(typeof e=="string"&&!ht.test(e)&&(l.htmlSerialize||!ot.test(e))&&(l.leadingWhitespace||!ut.test(e))&&!gt[(ft.exec(e)||["",""])[1].toLowerCase()]){e=e.replace(at,"<$1>");try{for(;n1&&typeof v=="string"&&!l.checkClone&&pt.test(v))return this.each(function(n){var r=p.eq(n);m&&(e[0]=v.call(this,n,r.html())),r.domManip(e,t)});if(c){a=h.buildFragment(e,this[0].ownerDocument,!1,this),n=a.firstChild,a.childNodes.length===1&&(a=n);if(n){o=h.map(wt(a,"script"),xt),s=o.length;for(;f
t
",a=t.getElementsByTagName("td"),a[0].style.cssText="margin:0;border:0;padding:0;display:none",o=a[0].offsetHeight===0,o&&(a[0].style.display="",a[1].style.display="none",o=a[0].offsetHeight===0),n.removeChild(r)}var t,n,r,i,s,o,u;t=T.createElement("div"),t.innerHTML="
a",r=t.getElementsByTagName("a")[0],n=r&&r.style;if(!n)return;n.cssText="float:left;opacity:.5",l.opacity=n.opacity==="0.5",l.cssFloat=!!n.cssFloat,t.style.backgroundClip="content-box",t.cloneNode(!0).style.backgroundClip="",l.clearCloneStyle=t.style.backgroundClip==="content-box",l.boxSizing=n.boxSizing===""||n.MozBoxSizing===""||n.WebkitBoxSizing==="",h.extend(l,{reliableHiddenOffsets:function(){return o==null&&a(),o},boxSizingReliable:function(){return s==null&&a(),s},pixelPosition:function(){return i==null&&a(),i},reliableMarginRight:function(){return u==null&&a(),u}})}(),h.swap=function(e,t,n,r){var i,s,o={};for(s in t)o[s]=e.style[s],e.style[s]=t[s];i=n.apply(e,r||[]);for(s in t)e.style[s]=o[s];return i};var Ft=/alpha\([^)]*\)/i,It=/opacity\s*=\s*([^)]*)/,qt=/^(none|table(?!-c[ea]).+)/,Rt=new RegExp("^("+W+")(.*)$","i"),Ut=new RegExp("^([+-])=("+W+")","i"),zt={position:"absolute",visibility:"hidden",display:"block"},Wt={letterSpacing:"0",fontWeight:"400"},Xt=["Webkit","O","Moz","ms"];h.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Ht(e,"opacity");return n===""?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":l.cssFloat?"cssFloat":"styleFloat"},style:function(e,t,n,r){if(!e||e.nodeType===3||e.nodeType===8||!e.style)return;var i,s,o,u=h.camelCase(t),a=e.style;t=h.cssProps[u]||(h.cssProps[u]=Vt(a,u)),o=h.cssHooks[t]||h.cssHooks[u];if(n===undefined)return o&&"get"in o&&(i=o.get(e,!1,r))!==undefined?i:a[t];s=typeof n,s==="string"&&(i=Ut.exec(n))&&(n=(i[1]+1)*i[2]+parseFloat(h.css(e,t)),s="number");if(n==null||n!==n)return;s==="number"&&!h.cssNumber[u]&&(n+="px"),!l.clearCloneStyle&&n===""&&t.indexOf("background")===0&&(a[t]="inherit");if(!o||!("set"in o)||(n=o.set(e,n,r))!==undefined)try{a[t]=n}catch(f){}},css:function(e,t,n,r){var i,s,o,u=h.camelCase(t);return t=h.cssProps[u]||(h.cssProps[u]=Vt(e.style,u)),o=h.cssHooks[t]||h.cssHooks[u],o&&"get"in o&&(s=o.get(e,!0,n)),s===undefined&&(s=Ht(e,t,r)),s==="normal"&&t in Wt&&(s=Wt[t]),n===""||n?(i=parseFloat(s),n===!0||h.isNumeric(i)?i||0:s):s}}),h.each(["height","width"],function(e,t){h.cssHooks[t]={get:function(e,n,r){if(n)return qt.test(h.css(e,"display"))&&e.offsetWidth===0?h.swap(e,zt,function(){return Qt(e,t,r)}):Qt(e,t,r)},set:function(e,n,r){var i=r&&Pt(e);return Jt(e,n,r?Kt(e,t,r,l.boxSizing&&h.css(e,"boxSizing",!1,i)==="border-box",i):0)}}}),l.opacity||(h.cssHooks.opacity={get:function(e,t){return It.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":t?"1":""},set:function(e,t){var n=e.style,r=e.currentStyle,i=h.isNumeric(t)?"alpha(opacity="+t*100+")":"",s=r&&r.filter||n.filter||"";n.zoom=1;if((t>=1||t==="")&&h.trim(s.replace(Ft,""))===""&&n.removeAttribute){n.removeAttribute("filter");if(t===""||r&&!r.filter)return}n.filter=Ft.test(s)?s.replace(Ft,i):s+" "+i}}),h.cssHooks.marginRight=jt(l.reliableMarginRight,function(e,t){if(t)return h.swap(e,{display:"inline-block"},Ht,[e,"marginRight"])}),h.each({margin:"",padding:"",border:"Width"},function(e,t){h.cssHooks[e+t]={expand:function(n){var r=0,i={},s=typeof n=="string"?n.split(" "):[n];for(;r<4;r++)i[e+X[r]+t]=s[r]||s[r-2]||s[0];return i}},_t.test(e)||(h.cssHooks[e+t].set=Jt)}),h.fn.extend({css:function(e,t){return $(this,function(e,t,n){var r,i,s={},o=0;if(h.isArray(t)){r=Pt(e),i=t.length;for(;o1)},show:function(){return $t(this,!0)},hide:function(){return $t(this)},toggle:function(e){return typeof e=="boolean"?e?this.show():this.hide():this.each(function(){V(this)?h(this).show():h(this).hide()})}}),h.Tween=Gt,Gt.prototype={constructor:Gt,init:function(e,t,n,r,i,s){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=s||(h.cssNumber[n]?"":"px")},cur:function(){var e=Gt.propHooks[this.prop];return e&&e.get?e.get(this):Gt.propHooks._default.get(this)},run:function(e){var t,n=Gt.propHooks[this.prop];return this.options.duration?this.pos=t=h.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):Gt.propHooks._default.set(this),this}},Gt.prototype.init.prototype=Gt.prototype,Gt.propHooks={_default:{get:function(e){var t;return e.elem[e.prop]==null||!!e.elem.style&&e.elem.style[e.prop]!=null?(t=h.css(e.elem,e.prop,""),!t||t==="auto"?0:t):e.elem[e.prop]},set:function(e){h.fx.step[e.prop]?h.fx.step[e.prop](e):e.elem.style&&(e.elem.style[h.cssProps[e.prop]]!=null||h.cssHooks[e.prop])?h.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},Gt.propHooks.scrollTop=Gt.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},h.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},h.fx=Gt.prototype.init,h.fx.step={};var Yt,Zt,en=/^(?:toggle|show|hide)$/,tn=new RegExp("^(?:([+-])=|)("+W+")([a-z%]*)$","i"),nn=/queueHooks$/,rn=[fn],sn={"*":[function(e,t){var n=this.createTween(e,t),r=n.cur(),i=tn.exec(t),s=i&&i[3]||(h.cssNumber[e]?"":"px"),o=(h.cssNumber[e]||s!=="px"&&+r)&&tn.exec(h.css(n.elem,e)),u=1,a=20;if(o&&o[3]!==s){s=s||o[3],i=i||[],o=+r||1;do u=u||".5",o/=u,h.style(n.elem,e,o+s);while(u!==(u=n.cur()/r)&&u!==1&&--a)}return i&&(o=n.start=+o||+r||0,n.unit=s,n.end=i[1]?o+(i[1]+1)*i[2]:+i[2]),n}]};h.Animation=h.extend(cn,{tweener:function(e,t){h.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;r
a",r=t.getElementsByTagName("a")[0],n=T.createElement("select"),i=n.appendChild(T.createElement("option")),e=t.getElementsByTagName("input")[0],r.style.cssText="top:1px",l.getSetAttribute=t.className!=="t",l.style=/top/.test(r.getAttribute("style")),l.hrefNormalized=r.getAttribute("href")==="/a",l.checkOn=!!e.value,l.optSelected=i.selected,l.enctype=!!T.createElement("form").enctype,n.disabled=!0,l.optDisabled=!i.disabled,e=T.createElement("input"),e.setAttribute("value",""),l.input=e.getAttribute("value")==="",e.value="t",e.setAttribute("type","radio"),l.radioValue=e.value==="t"}();var hn=/\r/g;h.fn.extend({val:function(e){var t,n,r,i=this[0];if(!arguments.length){if(i)return t=h.valHooks[i.type]||h.valHooks[i.nodeName.toLowerCase()],t&&"get"in t&&(n=t.get(i,"value"))!==undefined?n:(n=i.value,typeof n=="string"?n.replace(hn,""):n==null?"":n);return}return r=h.isFunction(e),this.each(function(n){var i;if(this.nodeType!==1)return;r?i=e.call(this,n,h(this).val()):i=e,i==null?i="":typeof i=="number"?i+="":h.isArray(i)&&(i=h.map(i,function(e){return e==null?"":e+""})),t=h.valHooks[this.type]||h.valHooks[this.nodeName.toLowerCase()];if(!t||!("set"in t)||t.set(this,i,"value")===undefined)this.value=i})}}),h.extend({valHooks:{option:{get:function(e){var t=h.find.attr(e,"value");return t!=null?t:h.trim(h.text(e))}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,s=e.type==="select-one"||i<0,o=s?null:[],u=s?i+1:r.length,a=i<0?u:s?i:0;for(;a=0)try{r.selected=n=!0}catch(u){r.scrollHeight}else r.selected=!1}return n||(e.selectedIndex=-1),i}}}}),h.each(["radio","checkbox"],function(){h.valHooks[this]={set:function(e,t){if(h.isArray(t))return e.checked=h.inArray(h(e).val(),t)>=0}},l.checkOn||(h.valHooks[this].get=function(e){return e.getAttribute("value")===null?"on":e.value})});var pn,dn,vn=h.expr.attrHandle,mn=/^(?:checked|selected)$/i,gn=l.getSetAttribute,yn=l.input;h.fn.extend({attr:function(e,t){return $(this,h.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){h.removeAttr(this,e)})}}),h.extend({attr:function(e,t,n){var r,i,s=e.nodeType;if(!e||s===3||s===8||s===2)return;if(typeof e.getAttribute===B)return h.prop(e,t,n);if(s!==1||!h.isXMLDoc(e))t=t.toLowerCase(),r=h.attrHooks[t]||(h.expr.match.bool.test(t)?dn:pn);if(n===undefined)return r&&"get"in r&&(i=r.get(e,t))!==null?i:(i=h.find.attr(e,t),i==null?undefined:i);if(n!==null)return r&&"set"in r&&(i=r.set(e,n,t))!==undefined?i:(e.setAttribute(t,n+""),n);h.removeAttr(e,t)},removeAttr:function(e,t){var n,r,i=0,s=t&&t.match(O);if(s&&e.nodeType===1)while(n=s[i++])r=h.propFix[n]||n,h.expr.match.bool.test(n)?yn&&gn||!mn.test(n)?e[r]=!1:e[h.camelCase("default-"+n)]=e[r]=!1:h.attr(e,n,""),e.removeAttribute(gn?n:r)},attrHooks:{type:{set:function(e,t){if(!l.radioValue&&t==="radio"&&h.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}}}),dn={set:function(e,t,n){return t===!1?h.removeAttr(e,n):yn&&gn||!mn.test(n)?e.setAttribute(!gn&&h.propFix[n]||n,n):e[h.camelCase("default-"+n)]=e[n]=!0,n}},h.each(h.expr.match.bool.source.match(/\w+/g),function(e,t){var n=vn[t]||h.find.attr;vn[t]=yn&&gn||!mn.test(t)?function(e,t,r){var i,s;return r||(s=vn[t],vn[t]=i,i=n(e,t,r)!=null?t.toLowerCase():null,vn[t]=s),i}:function(e,t,n){if(!n)return e[h.camelCase("default-"+t)]?t.toLowerCase():null}});if(!yn||!gn)h.attrHooks.value={set:function(e,t,n){if(!h.nodeName(e,"input"))return pn&&pn.set(e,t,n);e.defaultValue=t}};gn||(pn={set:function(e,t,n){var r=e.getAttributeNode(n);r||e.setAttributeNode(r=e.ownerDocument.createAttribute(n)),r.value=t+="";if(n==="value"||t===e.getAttribute(n))return t}},vn.id=vn.name=vn.coords=function(e,t,n){var r;if(!n)return(r=e.getAttributeNode(t))&&r.value!==""?r.value:null},h.valHooks.button={get:function(e,t){var n=e.getAttributeNode(t);if(n&&n.specified)return n.value},set:pn.set},h.attrHooks.contenteditable={set:function(e,t,n){pn.set(e,t===""?!1:t,n)}},h.each(["width","height"],function(e,t){h.attrHooks[t]={set:function(e,n){if(n==="")return e.setAttribute(t,"auto"),n}}})),l.style||(h.attrHooks.style={get:function(e){return e.style.cssText||undefined},set:function(e,t){return e.style.cssText=t+""}});var bn=/^(?:input|select|textarea|button|object)$/i,wn=/^(?:a|area)$/i;h.fn.extend({prop:function(e,t){return $(this,h.prop,e,t,arguments.length>1)},removeProp:function(e){return e=h.propFix[e]||e,this.each(function(){try{this[e]=undefined,delete this[e]}catch(t){}})}}),h.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(e,t,n){var r,i,s,o=e.nodeType;if(!e||o===3||o===8||o===2)return;return s=o!==1||!h.isXMLDoc(e),s&&(t=h.propFix[t]||t,i=h.propHooks[t]),n!==undefined?i&&"set"in i&&(r=i.set(e,n,t))!==undefined?r:e[t]=n:i&&"get"in i&&(r=i.get(e,t))!==null?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=h.find.attr(e,"tabindex");return t?parseInt(t,10):bn.test(e.nodeName)||wn.test(e.nodeName)&&e.href?0:-1}}}}),l.hrefNormalized||h.each(["href","src"],function(e,t){h.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}}),l.optSelected||(h.propHooks.selected={get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}}),h.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){h.propFix[this.toLowerCase()]=this}),l.enctype||(h.propFix.enctype="encoding");var En=/[\t\r\n\f]/g;h.fn.extend({addClass:function(e){var t,n,r,i,s,o,u=0,a=this.length,f=typeof e=="string"&&e;if(h.isFunction(e))return this.each(function(t){h(this).addClass(e.call(this,t,this.className))});if(f){t=(e||"").match(O)||[];for(;u=0)r=r.replace(" "+i+" "," ");o=e?h.trim(r):"",n.className!==o&&(n.className=o)}}}return this},toggleClass:function(e,t){var n=typeof e;return typeof t=="boolean"&&n==="string"?t?this.addClass(e):this.removeClass(e):h.isFunction(e)?this.each(function(n){h(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if(n==="string"){var t,r=0,i=h(this),s=e.match(O)||[];while(t=s[r++])i.hasClass(t)?i.removeClass(t):i.addClass(t)}else if(n===B||n==="boolean")this.className&&h._data(this,"__className__",this.className),this.className=this.className||e===!1?"":h._data(this,"__className__")||""})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;n=0)return!0;return!1}}),h.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(e,t){h.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),h.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return arguments.length===1?this.off(e,"**"):this.off(t,e||"**",n)}});var Sn=h.now(),xn=/\?/,Tn=/(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;h.parseJSON=function(t){if(e.JSON&&e.JSON.parse)return e.JSON.parse(t+"");var n,r=null,i=h.trim(t+"");return i&&!h.trim(i.replace(Tn,function(e,t,i,s){return n&&t&&(r=0),r===0?e:(n=i||t,r+=!s-!i,"")}))?Function("return "+i)():h.error("Invalid JSON: "+t)},h.parseXML=function(t){var n,r;if(!t||typeof t!="string")return null;try{e.DOMParser?(r=new DOMParser,n=r.parseFromString(t,"text/xml")):(n=new ActiveXObject("Microsoft.XMLDOM"),n.async="false",n.loadXML(t))}catch(i){n=undefined}return(!n||!n.documentElement||n.getElementsByTagName("parsererror").length)&&h.error("Invalid XML: "+t),n};var Nn,Cn,kn=/#.*$/,Ln=/([?&])_=[^&]*/,An=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,On=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Mn=/^(?:GET|HEAD)$/,_n=/^\/\//,Dn=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,Pn={},Hn={},Bn="*/".concat("*");try{Cn=location.href}catch(jn){Cn=T.createElement("a"),Cn.href="",Cn=Cn.href}Nn=Dn.exec(Cn.toLowerCase())||[],h.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Cn,type:"GET",isLocal:On.test(Nn[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Bn,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":h.parseJSON,"text xml":h.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?qn(qn(e,h.ajaxSettings),t):qn(h.ajaxSettings,e)},ajaxPrefilter:Fn(Pn),ajaxTransport:Fn(Hn),ajax:function(e,t){function x(e,t,n,r){var f,g,y,w,S,x=t;if(b===2)return;b=2,o&&clearTimeout(o),a=undefined,s=r||"",E.readyState=e>0?4:0,f=e>=200&&e<300||e===304,n&&(w=Rn(l,E,n)),w=Un(l,w,E,f);if(f)l.ifModified&&(S=E.getResponseHeader("Last-Modified"),S&&(h.lastModified[i]=S),S=E.getResponseHeader("etag"),S&&(h.etag[i]=S)),e===204||l.type==="HEAD"?x="nocontent":e===304?x="notmodified":(x=w.state,g=w.data,y=w.error,f=!y);else{y=x;if(e||!x)x="error",e<0&&(e=0)}E.status=e,E.statusText=(t||x)+"",f?d.resolveWith(c,[g,x,E]):d.rejectWith(c,[E,x,y]),E.statusCode(m),m=undefined,u&&p.trigger(f?"ajaxSuccess":"ajaxError",[E,l,f?g:y]),v.fireWith(c,[E,x]),u&&(p.trigger("ajaxComplete",[E,l]),--h.active||h.event.trigger("ajaxStop"))}typeof e=="object"&&(t=e,e=undefined),t=t||{};var n,r,i,s,o,u,a,f,l=h.ajaxSetup({},t),c=l.context||l,p=l.context&&(c.nodeType||c.jquery)?h(c):h.event,d=h.Deferred(),v=h.Callbacks("once memory"),m=l.statusCode||{},g={},y={},b=0,w="canceled",E={readyState:0,getResponseHeader:function(e){var t;if(b===2){if(!f){f={};while(t=An.exec(s))f[t[1].toLowerCase()]=t[2]}t=f[e.toLowerCase()]}return t==null?null:t},getAllResponseHeaders:function(){return b===2?s:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return b||(e=y[n]=y[n]||e,g[e]=t),this},overrideMimeType:function(e){return b||(l.mimeType=e),this},statusCode:function(e){var t;if(e)if(b<2)for(t in e)m[t]=[m[t],e[t]];else E.always(e[E.status]);return this},abort:function(e){var t=e||w;return a&&a.abort(t),x(0,t),this}};d.promise(E).complete=v.add,E.success=E.done,E.error=E.fail,l.url=((e||l.url||Cn)+"").replace(kn,"").replace(_n,Nn[1]+"//"),l.type=t.method||t.type||l.method||l.type,l.dataTypes=h.trim(l.dataType||"*").toLowerCase().match(O)||[""],l.crossDomain==null&&(n=Dn.exec(l.url.toLowerCase()),l.crossDomain=!(!n||n[1]===Nn[1]&&n[2]===Nn[2]&&(n[3]||(n[1]==="http:"?"80":"443"))===(Nn[3]||(Nn[1]==="http:"?"80":"443")))),l.data&&l.processData&&typeof l.data!="string"&&(l.data=h.param(l.data,l.traditional)),In(Pn,l,t,E);if(b===2)return E;u=h.event&&l.global,u&&h.active++===0&&h.event.trigger("ajaxStart"),l.type=l.type.toUpperCase(),l.hasContent=!Mn.test(l.type),i=l.url,l.hasContent||(l.data&&(i=l.url+=(xn.test(i)?"&":"?")+l.data,delete l.data),l.cache===!1&&(l.url=Ln.test(i)?i.replace(Ln,"$1_="+Sn++):i+(xn.test(i)?"&":"?")+"_="+Sn++)),l.ifModified&&(h.lastModified[i]&&E.setRequestHeader("If-Modified-Since",h.lastModified[i]),h.etag[i]&&E.setRequestHeader("If-None-Match",h.etag[i])),(l.data&&l.hasContent&&l.contentType!==!1||t.contentType)&&E.setRequestHeader("Content-Type",l.contentType),E.setRequestHeader("Accept",l.dataTypes[0]&&l.accepts[l.dataTypes[0]]?l.accepts[l.dataTypes[0]]+(l.dataTypes[0]!=="*"?", "+Bn+"; q=0.01":""):l.accepts["*"]);for(r in l.headers)E.setRequestHeader(r,l.headers[r]);if(!l.beforeSend||l.beforeSend.call(c,E,l)!==!1&&b!==2){w="abort";for(r in{success:1,error:1,complete:1})E[r](l[r]);a=In(Hn,l,t,E);if(!a)x(-1,"No Transport");else{E.readyState=1,u&&p.trigger("ajaxSend",[E,l]),l.async&&l.timeout>0&&(o=setTimeout(function(){E.abort("timeout")},l.timeout));try{b=1,a.send(g,x)}catch(S){if(!(b<2))throw S;x(-1,S)}}return E}return E.abort()},getJSON:function(e,t,n){return h.get(e,t,n,"json")},getScript:function(e,t){return h.get(e,undefined,t,"script")}}),h.each(["get","post"],function(e,t){h[t]=function(e,n,r,i){return h.isFunction(n)&&(i=i||r,r=n,n=undefined),h.ajax({url:e,type:t,dataType:i,data:n,success:r})}}),h._evalUrl=function(e){return h.ajax({url:e,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},h.fn.extend({wrapAll:function(e){if(h.isFunction(e))return this.each(function(t){h(this).wrapAll(e.call(this,t))});if(this[0]){var t=h(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&e.firstChild.nodeType===1)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return h.isFunction(e)?this.each(function(t){h(this).wrapInner(e.call(this,t))}):this.each(function(){var t=h(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=h.isFunction(e);return this.each(function(n){h(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){h.nodeName(this,"body")||h(this).replaceWith(this.childNodes)}).end()}}),h.expr.filters.hidden=function(e){return e.offsetWidth<=0&&e.offsetHeight<=0||!l.reliableHiddenOffsets()&&(e.style&&e.style.display||h.css(e,"display"))==="none"},h.expr.filters.visible=function(e){return!h.expr.filters.hidden(e)};var zn=/%20/g,Wn=/\[\]$/,Xn=/\r?\n/g,Vn=/^(?:submit|button|image|reset|file)$/i,$n=/^(?:input|select|textarea|keygen)/i;h.param=function(e,t){var n,r=[],i=function(e,t){t=h.isFunction(t)?t():t==null?"":t,r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};t===undefined&&(t=h.ajaxSettings&&h.ajaxSettings.traditional);if(h.isArray(e)||e.jquery&&!h.isPlainObject(e))h.each(e,function(){i(this.name,this.value)});else for(n in e)Jn(n,e[n],t,i);return r.join("&").replace(zn,"+")},h.fn.extend({serialize:function(){return h.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=h.prop(this,"elements");return e?h.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!h(this).is(":disabled")&&$n.test(this.nodeName)&&!Vn.test(e)&&(this.checked||!J.test(e))}).map(function(e,t){var n=h(this).val();return n==null?null:h.isArray(n)?h.map(n,function(e){return{name:t.name,value:e.replace(Xn,"\r\n")}}):{name:t.name,value:n.replace(Xn,"\r\n")}}).get()}}),h.ajaxSettings.xhr=e.ActiveXObject!==undefined?function(){return!this.isLocal&&/^(get|post|head|put|delete|options)$/i.test(this.type)&&Yn()||Zn()}:Yn;var Kn=0,Qn={},Gn=h.ajaxSettings.xhr();e.attachEvent&&e.attachEvent("onunload",function(){for(var e in Qn)Qn[e](undefined,!0)}),l.cors=!!Gn&&"withCredentials"in Gn,Gn=l.ajax=!!Gn,Gn&&h.ajaxTransport(function(e){if(!e.crossDomain||l.cors){var t;return{send:function(n,r){var i,s=e.xhr(),o=++Kn;s.open(e.type,e.url,e.async,e.username,e.password);if(e.xhrFields)for(i in e.xhrFields)s[i]=e.xhrFields[i];e.mimeType&&s.overrideMimeType&&s.overrideMimeType(e.mimeType),!e.crossDomain&&!n["X-Requested-With"]&&(n["X-Requested-With"]="XMLHttpRequest");for(i in n)n[i]!==undefined&&s.setRequestHeader(i,n[i]+"");s.send(e.hasContent&&e.data||null),t=function(n,i){var u,a,f;if(t&&(i||s.readyState===4)){delete Qn[o],t=undefined,s.onreadystatechange=h.noop;if(i)s.readyState!==4&&s.abort();else{f={},u=s.status,typeof s.responseText=="string"&&(f.text=s.responseText);try{a=s.statusText}catch(l){a=""}!u&&e.isLocal&&!e.crossDomain?u=f.text?200:404:u===1223&&(u=204)}}f&&r(u,a,f,s.getAllResponseHeaders())},e.async?s.readyState===4?setTimeout(t):s.onreadystatechange=Qn[o]=t:t()},abort:function(){t&&t(undefined,!0)}}}}),h.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return h.globalEval(e),e}}}),h.ajaxPrefilter("script",function(e){e.cache===undefined&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),h.ajaxTransport("script",function(e){if(e.crossDomain){var t,n=T.head||h("head")[0]||T.documentElement;return{send:function(r,i){t=T.createElement("script"),t.async=!0,e.scriptCharset&&(t.charset=e.scriptCharset),t.src=e.url,t.onload=t.onreadystatechange=function(e,n){if(n||!t.readyState||/loaded|complete/.test(t.readyState))t.onload=t.onreadystatechange=null,t.parentNode&&t.parentNode.removeChild(t),t=null,n||i(200,"success")},n.insertBefore(t,n.firstChild)},abort:function(){t&&t.onload(undefined,!0)}}}});var er=[],tr=/(=)\?(?=&|$)|\?\?/;h.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=er.pop()||h.expando+"_"+Sn++;return this[e]=!0,e}}),h.ajaxPrefilter("json jsonp",function(t,n,r){var i,s,o,u=t.jsonp!==!1&&(tr.test(t.url)?"url":typeof t.data=="string"&&!(t.contentType||"").indexOf("application/x-www-form-urlencoded")&&tr.test(t.data)&&"data");if(u||t.dataTypes[0]==="jsonp")return i=t.jsonpCallback=h.isFunction(t.jsonpCallback)?t.jsonpCallback():t.jsonpCallback,u?t[u]=t[u].replace(tr,"$1"+i):t.jsonp!==!1&&(t.url+=(xn.test(t.url)?"&":"?")+t.jsonp+"="+i),t.converters["script json"]=function(){return o||h.error(i+" was not called"),o[0]},t.dataTypes[0]="json",s=e[i],e[i]=function(){o=arguments},r.always(function(){e[i]=s,t[i]&&(t.jsonpCallback=n.jsonpCallback,er.push(i)),o&&h.isFunction(s)&&s(o[0]),o=s=undefined}),"script"}),h.parseHTML=function(e,t,n){if(!e||typeof e!="string")return null;typeof t=="boolean"&&(n=t,t=!1),t=t||T;var r=w.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=h.buildFragment([e],t,i),i&&i.length&&h(i).remove(),h.merge([],r.childNodes))};var nr=h.fn.load;h.fn.load=function(e,t,n){if(typeof e!="string"&&nr)return nr.apply(this,arguments);var r,i,s,o=this,u=e.indexOf(" ");return u>=0&&(r=h.trim(e.slice(u,e.length)),e=e.slice(0,u)),h.isFunction(t)?(n=t,t=undefined):t&&typeof t=="object"&&(s="POST"),o.length>0&&h.ajax({url:e,type:s,dataType:"html",data:t}).done(function(e){i=arguments,o.html(r?h("
").append(h.parseHTML(e)).find(r):e)}).complete(n&&function(e,t){o.each(n,i||[e.responseText,t,e])}),this},h.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){h.fn[t]=function(e){return this.on(t,e)}}),h.expr.filters.animated=function(e){return h.grep(h.timers,function(t){return e===t.elem}).length};var rr=e.document.documentElement;h.offset={setOffset:function(e,t,n){var r,i,s,o,u,a,f,l=h.css(e,"position"),c=h(e),p={};l==="static"&&(e.style.position="relative"),u=c.offset(),s=h.css(e,"top"),a=h.css(e,"left"),f=(l==="absolute"||l==="fixed")&&h.inArray("auto",[s,a])>-1,f?(r=c.position(),o=r.top,i=r.left):(o=parseFloat(s)||0,i=parseFloat(a)||0),h.isFunction(t)&&(t=t.call(e,n,u)),t.top!=null&&(p.top=t.top-u.top+o),t.left!=null&&(p.left=t.left-u.left+i),"using"in t?t.using.call(e,p):c.css(p)}},h.fn.extend({offset:function(e){if(arguments.length)return e===undefined?this:this.each(function(t){h.offset.setOffset(this,e,t)});var t,n,r={top:0,left:0},i=this[0],s=i&&i.ownerDocument;if(!s)return;return t=s.documentElement,h.contains(t,i)?(typeof i.getBoundingClientRect!==B&&(r=i.getBoundingClientRect()),n=ir(s),{top:r.top+(n.pageYOffset||t.scrollTop)-(t.clientTop||0),left:r.left+(n.pageXOffset||t.scrollLeft)-(t.clientLeft||0)}):r},position:function(){if(!this[0])return;var e,t,n={top:0,left:0},r=this[0];return h.css(r,"position")==="fixed"?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),h.nodeName(e[0],"html")||(n=e.offset()),n.top+=h.css(e[0],"borderTopWidth",!0),n.left+=h.css(e[0],"borderLeftWidth",!0)),{top:t.top-n.top-h.css(r,"marginTop",!0),left:t.left-n.left-h.css(r,"marginLeft",!0)}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||rr;while(e&&!h.nodeName(e,"html")&&h.css(e,"position")==="static")e=e.offsetParent;return e||rr})}}),h.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,t){var n=/Y/.test(t);h.fn[e]=function(r){return $(this,function(e,r,i){var s=ir(e);if(i===undefined)return s?t in s?s[t]:s.document.documentElement[r]:e[r];s?s.scrollTo(n?h(s).scrollLeft():i,n?i:h(s).scrollTop()):e[r]=i},e,r,arguments.length,null)}}),h.each(["top","left"],function(e,t){h.cssHooks[t]=jt(l.pixelPosition,function(e,n){if(n)return n=Ht(e,t),Dt.test(n)?h(e).position()[t]+"px":n})}),h.each({Height:"height",Width:"width"},function(e,t){h.each({padding:"inner"+e,content:t,"":"outer"+e},function(n,r){h.fn[r]=function(r,i){var s=arguments.length&&(n||typeof r!="boolean"),o=n||(r===!0||i===!0?"margin":"border");return $(this,function(t,n,r){var i;return h.isWindow(t)?t.document.documentElement["client"+e]:t.nodeType===9?(i=t.documentElement,Math.max(t.body["scroll"+e],i["scroll"+e],t.body["offset"+e],i["offset"+e],i["client"+e])):r===undefined?h.css(t,n,o):h.style(t,n,r,o)},t,s?r:undefined,s,null)}})}),h.fn.size=function(){return this.length},h.fn.andSelf=h.fn.addBack,typeof define=="function"&&define.amd&&define("jquery",[],function(){return h});var sr=e.jQuery,or=e.$;return h.noConflict=function(t){return e.$===h&&(e.$=or),t&&e.jQuery===h&&(e.jQuery=sr),h},typeof t===B&&(e.jQuery=e.$=h),h}),function(){var e=this,t=e._,n={},r=Array.prototype,i=Object.prototype,s=Function.prototype,o=r.push,u=r.slice,a=r.concat,f=i.toString,l=i.hasOwnProperty,c=r.forEach,h=r.map,p=r.reduce,d=r.reduceRight,v=r.filter,m=r.every,g=r.some,y=r.indexOf,b=r.lastIndexOf,w=Array.isArray,E=Object.keys,S=s.bind,x=function(e){if(e instanceof x)return e;if(!(this instanceof x))return new x(e);this._wrapped=e};typeof exports!="undefined"?(typeof module!="undefined"&&module.exports&&(exports=module.exports=x),exports._=x):e._=x,x.VERSION="1.5.1";var T=x.each=x.forEach=function(e,t,r){if(e==null)return;if(c&&e.forEach===c)e.forEach(t,r);else if(e.length===+e.length){for(var i=0,s=e.length;i2;e==null&&(e=[]);if(p&&e.reduce===p)return r&&(t=x.bind(t,r)),i?e.reduce(t,n):e.reduce(t);T(e,function(e,s,o){i?n=t.call(r,n,e,s,o):(n=e,i=!0)});if(!i)throw new TypeError(N);return n},x.reduceRight=x.foldr=function(e,t,n,r){var i=arguments.length>2;e==null&&(e=[]);if(d&&e.reduceRight===d)return r&&(t=x.bind(t,r)),i?e.reduceRight(t,n):e.reduceRight(t);var s=e.length;if(s!==+s){var o=x.keys(e);s=o.length}T(e,function(u,a,f){a=o?o[--s]:--s,i?n=t.call(r,n,e[a],a,f):(n=e[a],i=!0)});if(!i)throw new TypeError(N);return n},x.find=x.detect=function(e,t,n){var r;return C(e,function(e,i,s){if(t.call(n,e,i,s))return r=e,!0}),r},x.filter=x.select=function(e,t,n){var r=[];return e==null?r:v&&e.filter===v?e.filter(t,n):(T(e,function(e,i,s){t.call(n,e,i,s)&&r.push(e)}),r)},x.reject=function(e,t,n){return x.filter(e,function(e,r,i){return!t.call(n,e,r,i)},n)},x.every=x.all=function(e,t,r){t||(t=x.identity);var i=!0;return e==null?i:m&&e.every===m?e.every(t,r):(T(e,function(e,s,o){if(!(i=i&&t.call(r,e,s,o)))return n}),!!i)};var C=x.some=x.any=function(e,t,r){t||(t=x.identity);var i=!1;return e==null?i:g&&e.some===g?e.some(t,r):(T(e,function(e,s,o){if(i||(i=t.call(r,e,s,o)))return n}),!!i)};x.contains=x.include=function(e,t){return e==null?!1:y&&e.indexOf===y?e.indexOf(t)!=-1:C(e,function(e){return e===t})},x.invoke=function(e,t){var n=u.call(arguments,2),r=x.isFunction(t);return x.map(e,function(e){return(r?t:e[t]).apply(e,n)})},x.pluck=function(e,t){return x.map(e,function(e){return e[t]})},x.where=function(e,t,n){return x.isEmpty(t)?n?void 0:[]:x[n?"find":"filter"](e,function(e){for(var n in t)if(t[n]!==e[n])return!1;return!0})},x.findWhere=function(e,t){return x.where(e,t,!0)},x.max=function(e,t,n){if(!t&&x.isArray(e)&&e[0]===+e[0]&&e.length<65535)return Math.max.apply(Math,e);if(!t&&x.isEmpty(e))return-Infinity;var r={computed:-Infinity,value:-Infinity};return T(e,function(e,i,s){var o=t?t.call(n,e,i,s):e;o>r.computed&&(r={value:e,computed:o})}),r.value},x.min=function(e,t,n){if(!t&&x.isArray(e)&&e[0]===+e[0]&&e.length<65535)return Math.min.apply(Math,e);if(!t&&x.isEmpty(e))return Infinity;var r={computed:Infinity,value:Infinity};return T(e,function(e,i,s){var o=t?t.call(n,e,i,s):e;or||n===void 0)return 1;if(n>>1;n.call(r,e[u])=0})})},x.difference=function(e){var t=a.apply(r,u.call(arguments,1));return x.filter(e,function(e){return!x.contains(t,e)})},x.zip=function(){var e=x.max(x.pluck(arguments,"length").concat(0)),t=new Array(e);for(var n=0;n=0;n--)t=[e[n].apply(this,t)];return t[0]}},x.after=function(e,t){return function(){if(--e<1)return t.apply(this,arguments)}},x.keys=E||function(e){if(e!==Object(e))throw new TypeError("Invalid object");var t=[];for(var n in e)x.has(e,n)&&t.push(n);return t},x.values=function(e){var t=[];for(var n in e)x.has(e,n)&&t.push(e[n]);return t},x.pairs=function(e){var t=[];for(var n in e)x.has(e,n)&&t.push([n,e[n]]);return t},x.invert=function(e){var t={};for(var n in e)x.has(e,n)&&(t[e[n]]=n);return t},x.functions=x.methods=function(e){var t=[];for(var n in e)x.isFunction(e[n])&&t.push(n);return t.sort()},x.extend=function(e){return T(u.call(arguments,1),function(t){if(t)for(var n in t)e[n]=t[n]}),e},x.pick=function(e){var t={},n=a.apply(r,u.call(arguments,1));return T(n,function(n){n in e&&(t[n]=e[n])}),t},x.omit=function(e){var t={},n=a.apply(r,u.call(arguments,1));for(var i in e)x.contains(n,i)||(t[i]=e[i]);return t},x.defaults=function(e){return T(u.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e},x.clone=function(e){return x.isObject(e)?x.isArray(e)?e.slice():x.extend({},e):e},x.tap=function(e,t){return t(e),e};var M=function(e,t,n,r){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return e===t;e instanceof x&&(e=e._wrapped),t instanceof x&&(t=t._wrapped);var i=f.call(e);if(i!=f.call(t))return!1;switch(i){case"[object String]":return e==String(t);case"[object Number]":return e!=+e?t!=+t:e==0?1/e==1/t:e==+t;case"[object Date]":case"[object Boolean]":return+e==+t;case"[object RegExp]":return e.source==t.source&&e.global==t.global&&e.multiline==t.multiline&&e.ignoreCase==t.ignoreCase}if(typeof e!="object"||typeof t!="object")return!1;var s=n.length;while(s--)if(n[s]==e)return r[s]==t;var o=e.constructor,u=t.constructor;if(o!==u&&!(x.isFunction(o)&&o instanceof o&&x.isFunction(u)&&u instanceof u))return!1;n.push(e),r.push(t);var a=0,l=!0;if(i=="[object Array]"){a=e.length,l=a==t.length;if(l)while(a--)if(!(l=M(e[a],t[a],n,r)))break}else{for(var c in e)if(x.has(e,c)){a++;if(!(l=x.has(t,c)&&M(e[c],t[c],n,r)))break}if(l){for(c in t)if(x.has(t,c)&&!(a--))break;l=!a}}return n.pop(),r.pop(),l};x.isEqual=function(e,t){return M(e,t,[],[])},x.isEmpty=function(e){if(e==null)return!0;if(x.isArray(e)||x.isString(e))return e.length===0;for(var t in e)if(x.has(e,t))return!1;return!0},x.isElement=function(e){return!!e&&e.nodeType===1},x.isArray=w||function(e){return f.call(e)=="[object Array]"},x.isObject=function(e){return e===Object(e)},T(["Arguments","Function","String","Number","Date","RegExp"],function(e){x["is"+e]=function(t){return f.call(t)=="[object "+e+"]"}}),x.isArguments(arguments)||(x.isArguments=function(e){return!!e&&!!x.has(e,"callee")}),typeof /./!="function"&&(x.isFunction=function(e){return typeof e=="function"}),x.isFinite=function(e){return isFinite(e)&&!isNaN(parseFloat(e))},x.isNaN=function(e){return x.isNumber(e)&&e!=+e},x.isBoolean=function(e){return e===!0||e===!1||f.call(e)=="[object Boolean]"},x.isNull=function(e){return e===null},x.isUndefined=function(e){return e===void 0},x.has=function(e,t){return l.call(e,t)},x.noConflict=function(){return e._=t,this},x.identity=function(e){return e},x.times=function(e,t,n){var r=Array(Math.max(0,e));for(var i=0;i":">",'"':""","'":"'","/":"/"}};_.unescape=x.invert(_.escape);var D={escape:new RegExp("["+x.keys(_.escape).join("")+"]","g"),unescape:new RegExp("("+x.keys(_.unescape).join("|")+")","g")};x.each(["escape","unescape"],function(e){x[e]=function(t){return t==null?"":(""+t).replace(D[e],function(t){return _[e][t]})}}),x.result=function(e,t){if(e==null)return void 0;var n=e[t];return x.isFunction(n)?n.call(e):n},x.mixin=function(e){T(x.functions(e),function(t){var n=x[t]=e[t];x.prototype[t]=function(){var e=[this._wrapped];return o.apply(e,arguments),F.call(this,n.apply(x,e))}})};var P=0;x.uniqueId=function(e){var t=++P+"";return e?e+t:t},x.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var H=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},j=/\\|'|\r|\n|\t|\u2028|\u2029/g;x.template=function(e,t,n){var r;n=x.defaults({},n,x.templateSettings);var i=new RegExp([(n.escape||H).source,(n.interpolate||H).source,(n.evaluate||H).source].join("|")+"|$","g"),s=0,o="__p+='";e.replace(i,function(t,n,r,i,u){return o+=e.slice(s,u).replace(j,function(e){return"\\"+B[e]}),n&&(o+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'"),r&&(o+="'+\n((__t=("+r+"))==null?'':__t)+\n'"),i&&(o+="';\n"+i+"\n__p+='"),s=u+t.length,t}),o+="';\n",n.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{r=new Function(n.variable||"obj","_",o)}catch(u){throw u.source=o,u}if(t)return r(t,x);var a=function(e){return r.call(this,e,x)};return a.source="function("+(n.variable||"obj")+"){\n"+o+"}",a},x.chain=function(e){return x(e).chain()};var F=function(e){return this._chain?x(e).chain():e};x.mixin(x),T(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=r[e];x.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),(e=="shift"||e=="splice")&&n.length===0&&delete n[0],F.call(this,n)}}),T(["concat","join","slice"],function(e){var t=r[e];x.prototype[e]=function(){return F.call(this,t.apply(this._wrapped,arguments))}}),x.extend(x.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}.call(this),define("underscore",function(e){return function(){var t,n;return t||e._}}(this)),define("text",["module"],function(e){var t,n,r,i,s,o=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],u=/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,a=/]*>\s*([\s\S]+)\s*<\/body>/im,f=typeof location!="undefined"&&location.href,l=f&&location.protocol&&location.protocol.replace(/\:/,""),c=f&&location.hostname,h=f&&(location.port||undefined),p={},d=e.config&&e.config()||{};t={version:"2.0.13+",strip:function(e){if(e){e=e.replace(u,"");var t=e.match(a);t&&(e=t[1])}else e="";return e},jsEscape:function(e){return e.replace(/(['\\])/g,"\\$1").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r").replace(/[\u2028]/g,"\\u2028").replace(/[\u2029]/g,"\\u2029")},createXhr:d.createXhr||function(){var e,t,n;if(typeof XMLHttpRequest!="undefined")return new XMLHttpRequest;if(typeof ActiveXObject!="undefined")for(t=0;t<3;t+=1){n=o[t];try{e=new ActiveXObject(n)}catch(r){}if(e){o=[n];break}}return e},parseName:function(e){var t,n,r,i=!1,s=e.lastIndexOf("."),o=e.indexOf("./")===0||e.indexOf("../")===0;return s!==-1&&(!o||s>1)?(t=e.substring(0,s),n=e.substring(s+1)):t=e,r=n||t,s=r.indexOf("!"),s!==-1&&(i=r.substring(s+1)==="strip",r=r.substring(0,s),n?n=r:t=r),{moduleName:t,ext:n,strip:i}},xdRegExp:/^((\w+)\:)?\/\/([^\/\\]+)/,useXhr:function(e,n,r,i){var s,o,u,a=t.xdRegExp.exec(e);return a?(s=a[2],o=a[3],o=o.split(":"),u=o[1],o=o[0],(!s||s===n)&&(!o||o.toLowerCase()===r.toLowerCase())&&(!u&&!o||u===i)):!0},finishLoad:function(e,n,r,i){r=n?t.strip(r):r,d.isBuild&&(p[e]=r),i(r)},load:function(e,n,r,i){if(i&&i.isBuild&&!i.inlineText){r();return}d.isBuild=i&&i.isBuild;var s=t.parseName(e),o=s.moduleName+(s.ext?"."+s.ext:""),u=n.toUrl(o),a=d.useXhr||t.useXhr;if(u.indexOf("empty:")===0){r();return}!f||a(u,l,c,h)?t.get(u,function(n){t.finishLoad(e,s.strip,n,r)},function(e){r.error&&r.error(e)}):n([o],function(e){t.finishLoad(s.moduleName+"."+s.ext,s.strip,e,r)})},write:function(e,n,r,i){if(p.hasOwnProperty(n)){var s=t.jsEscape(p[n]);r.asModule(e+"!"+n,"define(function () { return '"+s+"';});\n")}},writeFile:function(e,n,r,i,s){var o=t.parseName(n),u=o.ext?"."+o.ext:"",a=o.moduleName+u,f=r.toUrl(o.moduleName+u)+".js";t.load(a,r,function(n){var r=function(e){return i(f,e)};r.asModule=function(e,t){return i.asModule(e,f,t)},t.write(e,a,r,s)},s)}};if(d.env==="node"||!d.env&&typeof process!="undefined"&&process.versions&&!!process.versions.node&&!process.versions["node-webkit"]&&!process.versions["atom-shell"])n=require.nodeRequire("fs"),t.get=function(e,t,r){try{var i=n.readFileSync(e,"utf8");i[0]===""&&(i=i.substring(1)),t(i)}catch(s){r&&r(s)}};else if(d.env==="xhr"||!d.env&&t.createXhr())t.get=function(e,n,r,i){var s=t.createXhr(),o;s.open("GET",e,!0);if(i)for(o in i)i.hasOwnProperty(o)&&s.setRequestHeader(o.toLowerCase(),i[o]);d.onXhr&&d.onXhr(s,e),s.onreadystatechange=function(t){var i,o;s.readyState===4&&(i=s.status||0,i>399&&i<600?(o=new Error(e+" HTTP status: "+i),o.xhr=s,r&&r(o)):n(s.responseText),d.onXhrComplete&&d.onXhrComplete(s,e))},s.send(null)};else if(d.env==="rhino"||!d.env&&typeof Packages!="undefined"&&typeof java!="undefined")t.get=function(e,t){var n,r,i="utf-8",s=new java.io.File(e),o=java.lang.System.getProperty("line.separator"),u=new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(s),i)),a="";try{n=new java.lang.StringBuffer,r=u.readLine(),r&&r.length()&&r.charAt(0)===65279&&(r=r.substring(1)),r!==null&&n.append(r);while((r=u.readLine())!==null)n.append(o),n.append(r);a=String(n.toString())}finally{u.close()}t(a)};else if(d.env==="xpconnect"||!d.env&&typeof Components!="undefined"&&Components.classes&&Components.interfaces)r=Components.classes,i=Components.interfaces,Components.utils["import"]("resource://gre/modules/FileUtils.jsm"),s="@mozilla.org/windows-registry-key;1"in r,t.get=function(e,t){var n,o,u,a={};s&&(e=e.replace(/\//g,"\\")),u=new FileUtils.File(e);try{n=r["@mozilla.org/network/file-input-stream;1"].createInstance(i.nsIFileInputStream),n.init(u,1,0,!1),o=r["@mozilla.org/intl/converter-input-stream;1"].createInstance(i.nsIConverterInputStream),o.init(n,"utf-8",n.available(),i.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER),o.readString(n.available(),a),o.close(),n.close(),t(a.value)}catch(f){throw new Error((u&&u.path||"")+": "+f)}};return t}),require.config({shim:{underscore:{exports:"_"},backbone:{deps:["underscore","jquery"],exports:"Backbone"}},paths:{jquery:"lib/jquery","jquery.ui.core":"lib/jquery.ui.core","jquery.ui.widget":"lib/jquery.ui.widget.1.11.1","jquery.ui.progressbar":"lib/jquery.ui.progressbar","jquery.ui.tabs":"lib/jquery.ui.tabs",tmpl:"lib/tmpl.min","jquery.iframe-transport":"lib/jquery.iframe-transport.1.4","jquery.fileupload":"lib/jquery.fileupload.5.42.1","jquery.fileupload-process":"lib/jquery.fileupload.file-processing.1.3.0","jquery.fileupload-validate":"lib/jquery.fileupload.validation.1.1.2","jquery.fileupload-ui":"lib/jquery.fileupload.ui.9.6.0","jquery.magnific-popup":"lib/jquery.magnific-popup",simplemodal:"lib/jquery.simplemodal.1.4.4.min",jstree:"lib/jstree.1.0",select2:"lib/select2-3.5.2",underscore:"lib/underscore",backbone:"lib/backbone",text:"lib/text"}}),define("common",["jquery","underscore","text"],function(e,t,n){return{INFO_TIMEOUT:1e4,SUCCESS_TIMEOUT:3e3,ERROR_TIMEOUT:3e3,getUrl:function(e){var t=app.config.siteRoot;switch(e.name){case"list_lib_dir":return t+"ajax/lib/"+e.repo_id+"/dir/";case"star_file":return t+"ajax/repo/"+e.repo_id+"/file/star/";case"unstar_file":return t+"ajax/repo/"+e.repo_id+"/file/unstar/";case"del_dir":return t+"ajax/repo/"+e.repo_id+"/dir/delete/";case"del_file":return t+"ajax/repo/"+e.repo_id+"/file/delete/";case"rename_dir":return t+"ajax/repo/"+e.repo_id+"/dir/rename/";case"rename_file":return t+"ajax/repo/"+e.repo_id+"/file/rename/";case"mv_dir":return t+"ajax/repo/"+e.repo_id+"/dir/mv/";case"cp_dir":return t+"ajax/repo/"+e.repo_id+"/dir/cp/";case"mv_file":return t+"ajax/repo/"+e.repo_id+"/file/mv/";case"cp_file":return t+"ajax/repo/"+e.repo_id+"/file/cp/";case"new_dir":return t+"ajax/repo/"+e.repo_id+"/dir/new/";case"new_file":return t+"ajax/repo/"+e.repo_id+"/file/new/";case"del_dirents":return t+"ajax/repo/"+e.repo_id+"/dirents/delete/";case"mv_dirents":return t+"ajax/repo/"+e.repo_id+"/dirents/move/";case"cp_dirents":return t+"ajax/repo/"+e.repo_id+"/dirents/copy/";case"get_file_op_url":return t+"ajax/repo/"+e.repo_id+"/file_op_url/";case"get_dirents":return t+"ajax/repo/"+e.repo_id+"/dirents/";case"repo_del":return t+"ajax/repo/"+e.repo_id+"/remove/";case"sub_repo":return t+"ajax/repo/"+e.repo_id+"/dir/sub_repo/";case"thumbnail_create":return t+"thumbnail/"+e.repo_id+"/create/";case"get_my_unenc_repos":return t+"ajax/my-unenc-repos/";case"unenc_rw_repos":return t+"ajax/unenc-rw-repos/";case"get_cp_progress":return t+"ajax/cp_progress/";case"cancel_cp":return t+"ajax/cancel_cp/";case"ajax_repo_remove_share":return t+"share/ajax/repo_remove_share/";case"get_user_contacts":return t+"ajax/contacts/";case"get_shared_download_link":return t+"share/ajax/get-download-link/";case"delete_shared_download_link":return t+"share/ajax/link/remove/";case"send_shared_download_link":return t+"share/link/send/";case"send_shared_upload_link":return t+"share/upload_link/send/";case"delete_shared_upload_link":return t+"share/ajax/upload_link/remove/";case"get_share_upload_link":return t+"share/ajax/get-upload-link/";case"private_share_dir":return t+"share/ajax/private-share-dir/";case"private_share_file":return t+"share/ajax/private-share-file/";case"get_popup_notices":return t+"ajax/get_popup_notices/";case"set_notices_seen":return t+"ajax/set_notices_seen/";case"get_unseen_notices_num":return t+"ajax/unseen-notices-count/";case"set_notice_seen_by_id":return t+"ajax/set_notice_seen_by_id/";case"repo_set_password":return t+"repo/set_password/";case"group_repos":return t+"api2/groups/"+e.group_id+"/repos/";case"group_basic_info":return t+"ajax/group/"+e.group_id+"/basic-info/";case"toggle_group_modules":return t+"ajax/group/"+e.group_id+"/toggle-modules/";case"toggle_personal_modules":return t+"ajax/toggle-personal-modules/";case"ajax_unset_inner_pub_repo":return t+"ajax/unset-inner-pub-repo/"+e.repo_id+"/";case"get_folder_perm_by_path":return t+"ajax/repo/"+e.repo_id+"/get-folder-perm-by-path/";case"set_user_folder_perm":return t+"ajax/repo/"+e.repo_id+"/set-user-folder-perm/";case"set_group_folder_perm":return t+"ajax/repo/"+e.repo_id+"/set-group-folder-perm/"}},showConfirm:function(t,n,r){var i=e("#confirm-popup"),s=e("#confirm-con"),o=e("#simplemodal-container"),u=e("#confirm-yes");s.html("

"+t+"

"+n+"

"),i.modal({appendTo:"#main"}),o.css({height:"auto"}),u.click(r)},closeModal:function(){e.modal.close()},feedback:function(t,n,r){var r=r||5e3;if(e(".messages")[0])e(".messages").html('
  • '+t+"
  • ");else{var i='
    • '+t+"
    ";e("#main").append(i)}e(".messages").css({left:(e(window).width()-e(".messages").width())/2,top:10}).removeClass("hide"),setTimeout(function(){e(".messages").addClass("hide")},r)},showFormError:function(t,n){e("#"+t+" .error").html(n).removeClass("hide"),e("#simplemodal-container").css({height:"auto"})},ajaxErrorHandler:function(t,n,r){t.responseText?this.feedback(e.parseJSON(t.responseText).error,"error"):this.feedback(gettext("Failed. Please check the network."),"error")},enableButton:function(e){e.removeAttr("disabled").removeClass("btn-disabled")},disableButton:function(e){e.attr("disabled","disabled").addClass("btn-disabled")},setCaretPos:function(e,t){var n;return document.selection?(n=e.createTextRange(),n.move("character",t),n.select()):e.setSelectionRange(t,t)},prepareApiCsrf:function(){Backbone._sync=Backbone.sync,Backbone.sync=function(e,t,n){if(e=="create"||e=="update"||e=="delete"){var r=app.pageOptions.csrfToken;n.beforeSend=function(e){e.setRequestHeader("X-CSRFToken",r)}}return Backbone._sync(e,t,n)}},prepareCSRFToken:function(e,t){function n(e){var t=null;if(document.cookie&&document.cookie!=""){var n=document.cookie.split(";");for(var r=0;r'+o+"

    "):e(".error",t).removeClass("hide")}}})}}),_this=this,e(document).click(function(t){_this.closePopup(t,e("#user-info-popup"),e("#my-info"))})},initNoticePopup:function(){var t=e("#msg-count");if(t.length==0)return!1;var n=document.title;t.data("orig_doc_title",n);var r=function(){e.ajax({url:_this.getUrl({name:"get_unseen_notices_num"}),dataType:"json",cache:!1,success:function(r){var i=r.count,s=e(".num",t);s.html(i),i>0?(s.removeClass("hide"),document.title="("+i+")"+n):(s.addClass("hide"),document.title=n)}})};r(),setInterval(r,3e4),e("#notice-icon").click(function(){var t=e("#notice-popup");t.toggleClass("hide");if(!t.hasClass("hide")){e(".con",t).css({"max-height":e(window).height()-e("#header").outerHeight()-e(".hd",t).outerHeight()-3});var n=e(".loading-tip",t),r=e("#notice-list");r.addClass("hide"),n.show(),e(".error",t).addClass("hide"),e.ajax({url:_this.getUrl({name:"get_popup_notices"}),dataType:"json",success:function(t){n.hide(),r.html(t.notice_html).removeClass("hide"),e(".unread a",r).click(function(){var t=e(this).parents(".unread").data("id"),n=e(this).attr("href");return e.ajax({url:_this.getUrl({name:"set_notice_seen_by_id"})+"?notice_id="+encodeURIComponent(t),dataType:"json",success:function(e){location.href=n},error:function(){location.href=n}}),!1}),e(".detail",r).click(function(){location.href=e(".brief a",e(this).parent()).attr("href")})},error:function(r,i,s){if(r.responseText){var o=e.parseJSON(r.responseText).error;n.hide(),e(".error",t).length==0?n.after('

    '+o+"

    "):e(".error",t).removeClass("hide")}}})}}),e(window).resize(function(){var t=e("#notice-popup");t.hasClass("hide")||e(".con",t).css({"max-height":e(window).height()-e("#header").outerHeight()-e(".hd",t).outerHeight()-3})}),e("#notice-popup .close").click(function(){e("#notice-popup").addClass("hide"),e("#notice-list .unread").length>0&&e.ajax({url:_this.getUrl({name:"set_notices_seen"}),dataType:"json",success:function(){e(".num",t).html(0).addClass("hide"),document.title=n}})}),e(document).click(function(t){_this.closePopup(t,e("#notice-popup"),e("#notice-icon"))})},getContacts:function(){this.ajaxGet({get_url:this.getUrl({name:"get_user_contacts"}),after_op_success:function(e){app.pageOptions.contacts=e.contacts}})},imageCheck:function(e){if(e.lastIndexOf(".")==-1)return!1;var t=e.substr(e.lastIndexOf(".")+1).toLowerCase(),n=["gif","jpeg","jpg","png","ico","bmp"];return n.indexOf(t)!=-1?!0:!1},fileSizeFormat:function(e,t){var n=1024,r=n*1024,i=r*1024,s=i*1024,t=t||0;return e>=0&&e=n&&e=r&&e=i&&e=s?(e/s).toFixed(t)+" TB":e+" B"}}}),function(e,t){if(typeof define=="function"&&define.amd)define("backbone",["underscore","jquery","exports"],function(n,r,i){e.Backbone=t(e,i,n,r)});else if(typeof exports!="undefined"){var n=require("underscore");t(e,exports,n)}else e.Backbone=t(e,{},e._,e.jQuery||e.Zepto||e.ender||e.$)}(this,function(e,t,n,r){var i=e.Backbone,s=[],o=s.push,u=s.slice,a=s.splice;t.VERSION="1.1.2",t.$=r,t.noConflict=function(){return e.Backbone=i,this},t.emulateHTTP=!1,t.emulateJSON=!1;var f=t.Events={on:function(e,t,n){if(!c(this,"on",e,[t,n])||!t)return this;this._events||(this._events={});var r=this._events[e]||(this._events[e]=[]);return r.push({callback:t,context:n,ctx:n||this}),this},once:function(e,t,r){if(!c(this,"once",e,[t,r])||!t)return this;var i=this,s=n.once(function(){i.off(e,s),t.apply(this,arguments)});return s._callback=t,this.on(e,s,r)},off:function(e,t,r){var i,s,o,u,a,f,l,h;if(!this._events||!c(this,"off",e,[t,r]))return this;if(!e&&!t&&!r)return this._events=void 0,this;u=e?[e]:n.keys(this._events);for(a=0,f=u.length;a").attr(e);this.setElement(r,!1)}else this.setElement(n.result(this,"el"),!1)}}),t.sync=function(e,r,i){var s=N[e];n.defaults(i||(i={}),{emulateHTTP:t.emulateHTTP,emulateJSON:t.emulateJSON});var o={type:s,dataType:"json"};i.url||(o.url=n.result(r,"url")||F()),i.data==null&&r&&(e==="create"||e==="update"||e==="patch")&&(o.contentType="application/json",o.data=JSON.stringify(i.attrs||r.toJSON(i))),i.emulateJSON&&(o.contentType="application/x-www-form-urlencoded",o.data=o.data?{model:o.data}:{});if(i.emulateHTTP&&(s==="PUT"||s==="DELETE"||s==="PATCH")){o.type="POST",i.emulateJSON&&(o.data._method=s);var u=i.beforeSend;i.beforeSend=function(e){e.setRequestHeader("X-HTTP-Method-Override",s);if(u)return u.apply(this,arguments)}}o.type!=="GET"&&!i.emulateJSON&&(o.processData=!1),o.type==="PATCH"&&T&&(o.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")});var a=i.xhr=t.ajax(n.extend(o,i));return r.trigger("request",r,a,i),a};var T=typeof window!="undefined"&&!!window.ActiveXObject&&(!window.XMLHttpRequest||!(new XMLHttpRequest).dispatchEvent),N={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};t.ajax=function(){return t.$.ajax.apply(t.$,arguments)};var C=t.Router=function(e){e||(e={}),e.routes&&(this.routes=e.routes),this._bindRoutes(),this.initialize.apply(this,arguments)},k=/\((.*?)\)/g,L=/(\(\?)?:\w+/g,A=/\*\w+/g,O=/[\-{}\[\]+?.,\\\^$|#\s]/g;n.extend(C.prototype,f,{initialize:function(){},route:function(e,r,i){n.isRegExp(e)||(e=this._routeToRegExp(e)),n.isFunction(r)&&(i=r,r=""),i||(i=this[r]);var s=this;return t.history.route(e,function(n){var o=s._extractParameters(e,n);s.execute(i,o),s.trigger.apply(s,["route:"+r].concat(o)),s.trigger("route",r,o),t.history.trigger("route",s,r,o)}),this},execute:function(e,t){e&&e.apply(this,t)},navigate:function(e,n){return t.history.navigate(e,n),this},_bindRoutes:function(){if(!this.routes)return;this.routes=n.result(this,"routes");var e,t=n.keys(this.routes);while((e=t.pop())!=null)this.route(e,this.routes[e])},_routeToRegExp:function(e){return e=e.replace(O,"\\$&").replace(k,"(?:$1)?").replace(L,function(e,t){return t?e:"([^/?]+)"}).replace(A,"([^?]*?)"),new RegExp("^"+e+"(?:\\?([\\s\\S]*))?$")},_extractParameters:function(e,t){var r=e.exec(t).slice(1);return n.map(r,function(e,t){return t===r.length-1?e||null:e?decodeURIComponent(e):null})}});var M=t.History=function(){this.handlers=[],n.bindAll(this,"checkUrl"),typeof window!="undefined"&&(this.location=window.location,this.history=window.history)},_=/^[#\/]|\s+$/g,D=/^\/+|\/+$/g,P=/msie [\w.]+/,H=/\/$/,B=/#.*$/;M.started=!1,n.extend(M.prototype,f,{interval:50,atRoot:function(){return this.location.pathname.replace(/[^\/]$/,"$&/")===this.root},getHash:function(e){var t=(e||this).location.href.match(/#(.*)$/);return t?t[1]:""},getFragment:function(e,t){if(e==null)if(this._hasPushState||!this._wantsHashChange||t){e=decodeURI(this.location.pathname+this.location.search);var n=this.root.replace(H,"");e.indexOf(n)||(e=e.slice(n.length))}else e=this.getHash();return e.replace(_,"")},start:function(e){if(M.started)throw new Error("Backbone.history has already been started");M.started=!0,this.options=n.extend({root:"/"},this.options,e),this.root=this.options.root,this._wantsHashChange=this.options.hashChange!==!1,this._wantsPushState=!!this.options.pushState,this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var r=this.getFragment(),i=document.documentMode,s=P.exec(navigator.userAgent.toLowerCase())&&(!i||i<=7);this.root=("/"+this.root+"/").replace(D,"/");if(s&&this._wantsHashChange){var o=t.$('').css(e.extend(this.o.iframeCss,{display:"none",opacity:0,position:"fixed",height:s[0],width:s[1],zIndex:this.o.zIndex,top:0,left:0})).appendTo(this.o.appendTo)),this.d.overlay=e("
    ").attr("id",this.o.overlayId).addClass("simplemodal-overlay").css(e.extend(this.o.overlayCss,{display:"none",opacity:this.o.opacity/100,height:this.o.modal?t[0]:0,width:this.o.modal?t[1]:0,position:"fixed",left:0,top:0,zIndex:this.o.zIndex+1})).appendTo(this.o.appendTo),this.d.container=e("
    ").attr("id",this.o.containerId).addClass("simplemodal-container").css(e.extend({position:this.o.fixed?"fixed":"absolute"},this.o.containerCss,{display:"none",zIndex:this.o.zIndex+2})).append(this.o.close&&this.o.closeHTML?e(this.o.closeHTML).addClass(this.o.closeClass):"").appendTo(this.o.appendTo),this.d.wrap=e("
    ").attr("tabIndex",-1).addClass("simplemodal-wrap").css({height:"100%",outline:0,width:"100%"}).appendTo(this.d.container),this.d.data=n.attr("id",n.attr("id")||this.o.dataId).addClass("simplemodal-data").css(e.extend(this.o.dataCss,{display:"none"})).appendTo("body"),this.setContainerDimensions(),this.d.data.appendTo(this.d.wrap),(f||o)&&this.fixIE()},bindEvents:function(){var r=this;e("."+r.o.closeClass).bind("click.simplemodal",function(e){e.preventDefault(),r.close()}),r.o.modal&&r.o.close&&r.o.overlayClose&&r.d.overlay.bind("click.simplemodal",function(e){e.preventDefault(),r.close()}),n.bind("keydown.simplemodal",function(e){r.o.modal&&9===e.keyCode?r.watchTab(e):r.o.close&&r.o.escClose&&27===e.keyCode&&(e.preventDefault(),r.close())}),i.bind("resize.simplemodal orientationchange.simplemodal",function(){r.getDimensions(),r.o.autoResize?r.setContainerDimensions():r.o.autoPosition&&r.setPosition(),f||o?r.fixIE():r.o.modal&&(r.d.iframe&&r.d.iframe.css({height:s[0],width:s[1]}),r.d.overlay.css({height:t[0],width:t[1]}))})},unbindEvents:function(){e("."+this.o.closeClass).unbind("click.simplemodal"),n.unbind("keydown.simplemodal"),i.unbind(".simplemodal"),this.d.overlay.unbind("click.simplemodal")},fixIE:function(){var t=this.o.position;e.each([this.d.iframe||null,this.o.modal?this.d.overlay:null,"fixed"===this.d.container.css("position")?this.d.container:null],function(e,n){if(n){var r=n[0].style;r.position="absolute";if(2>e)r.removeExpression("height"),r.removeExpression("width"),r.setExpression("height",'document.body.scrollHeight > document.body.clientHeight ? document.body.scrollHeight : document.body.clientHeight + "px"'),r.setExpression("width",'document.body.scrollWidth > document.body.clientWidth ? document.body.scrollWidth : document.body.clientWidth + "px"');else{var i,s;t&&t.constructor===Array?(i=t[0]?"number"==typeof t[0]?t[0].toString():t[0].replace(/px/,""):n.css("top").replace(/px/,""),i=-1===i.indexOf("%")?i+' + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"':parseInt(i.replace(/%/,""))+' * ((document.documentElement.clientHeight || document.body.clientHeight) / 100) + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"',t[1]&&(s="number"==typeof t[1]?t[1].toString():t[1].replace(/px/,""),s=-1===s.indexOf("%")?s+' + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"':parseInt(s.replace(/%/,""))+' * ((document.documentElement.clientWidth || document.body.clientWidth) / 100) + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"')):(i='(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"',s='(document.documentElement.clientWidth || document.body.clientWidth) / 2 - (this.offsetWidth / 2) + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"'),r.removeExpression("top"),r.removeExpression("left"),r.setExpression("top",i),r.setExpression("left",s)}}})},focus:function(t){var n=this,t=t&&-1!==e.inArray(t,["first","last"])?t:"first",r=e(":input:enabled:visible:"+t,n.d.wrap);setTimeout(function(){0i?i:ti?i:this.o.minHeight&&"auto"!==u&&no?o:eo?o:this.o.minWidth&&"auto"!==i&&rt||r>e?"auto":"visible"}),this.o.autoPosition&&this.setPosition()},setPosition:function(){var e,t;e=s[0]/2-this.d.container.outerHeight(!0)/2,t=s[1]/2-this.d.container.outerWidth(!0)/2;var n="fixed"!==this.d.container.css("position")?i.scrollTop():0;this.o.position&&"[object Array]"===Object.prototype.toString.call(this.o.position)?(e=n+(this.o.position[0]||e),t=this.o.position[1]||t):e=n+e,this.d.container.css({left:t,top:e})},watchTab:function(t){if(0r.length+5)return!1;if(r[i].selectorText&&r[i].selectorText.toLowerCase()==e)return t===!0?(n.removeRule&&n.removeRule(i),n.deleteRule&&n.deleteRule(i),!0):r[i]}while(r[++i]);return!1},add_css:function(e,t){return r.jstree.css.get_css(e,!1,t)?!1:(t.insertRule?t.insertRule(e+" { }",0):t.addRule(e,null,0),r.vakata.css.get_css(e))},remove_css:function(e,t){return r.vakata.css.get_css(e,!0,t)},add_sheet:function(e){var t=!1,n=!0;if(e.str)return e.title&&(t=r("style[id='"+e.title+"-stylesheet']")[0]),t?n=!1:(t=document.createElement("style"),t.setAttribute("type","text/css"),e.title&&t.setAttribute("id",e.title+"-stylesheet")),t.styleSheet?n?(document.getElementsByTagName("head")[0].appendChild(t),t.styleSheet.cssText=e.str):t.styleSheet.cssText=t.styleSheet.cssText+" "+e.str:(t.appendChild(document.createTextNode(e.str)),document.getElementsByTagName("head")[0].appendChild(t)),t.sheet||t.styleSheet;if(e.url){if(!document.createStyleSheet)return t=document.createElement("link"),t.rel="stylesheet",t.type="text/css",t.media="all",t.href=e.url,document.getElementsByTagName("head")[0].appendChild(t),t.styleSheet;try{t=document.createStyleSheet(e.url)}catch(i){}}}};var i=[],s=-1,o={},u={};r.fn.jstree=function(e){var t=typeof e=="string",n=Array.prototype.slice.call(arguments,1),s=this;if(t){if(e.substring(0,1)=="_")return s;this.each(function(){var t=i[r.data(this,"jstree-instance-id")],o=t&&r.isFunction(t[e])?t[e].apply(t,n):t;if(typeof o!="undefined"&&(e.indexOf("is_")===0||o!==!0&&o!==!1))return s=o,!1})}else this.each(function(){var t=r.data(this,"jstree-instance-id"),s=[],u=e?r.extend({},!0,e):{},a=r(this),f=!1,l=[];s=s.concat(n),a.data("jstree")&&s.push(a.data("jstree")),u=s.length?r.extend.apply(null,[!0,u].concat(s)):u,typeof t!="undefined"&&i[t]&&i[t].destroy(),t=parseInt(i.push({}),10)-1,r.data(this,"jstree-instance-id",t),u.plugins=r.isArray(u.plugins)?u.plugins:r.jstree.defaults.plugins.slice(),u.plugins.unshift("core"),u.plugins=u.plugins.sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|$)/g,"$1$2$4").replace(/,,+/g,",").replace(/,$/,"").split(","),f=r.extend(!0,{},r.jstree.defaults,u),f.plugins=u.plugins,r.each(o,function(e,t){r.inArray(e,f.plugins)===-1?(f[e]=null,delete f[e]):l.push(e)}),f.plugins=l,i[t]=new r.jstree._instance(t,r(this).addClass("jstree jstree-"+t),f),r.each(i[t]._get_settings().plugins,function(e,n){i[t].data[n]={}}),r.each(i[t]._get_settings().plugins,function(e,n){o[n]&&o[n].__init.apply(i[t])}),setTimeout(function(){i[t].init()},0)});return s},r.jstree={defaults:{plugins:[]},_focused:function(){return i[s]||null},_reference:function(e){if(i[e])return i[e];var t=r(e);return!t.length&&typeof e=="string"&&(t=r("#"+e)),t.length?i[t.closest(".jstree").data("jstree-instance-id")]||null:null},_instance:function(e,t,n){this.data={core:{}},this.get_settings=function(){return r.extend(!0,{},n)},this._get_settings=function(){return n},this.get_index=function(){return e},this.get_container=function(){return t},this.get_container_ul=function(){return t.children("ul:eq(0)")},this._set_settings=function(e){n=r.extend(!0,{},n,e)}},_fn:{},plugin:function(e,t){t=r.extend({},{__init:r.noop,__destroy:r.noop,_fn:{},defaults:!1},t),o[e]=t,r.jstree.defaults[e]=t.defaults,r.each(t._fn,function(t,n){n.plugin=e,n.old=r.jstree._fn[t],r.jstree._fn[t]=function(){var e,i=n,s=Array.prototype.slice.call(arguments),o=new r.Event("before.jstree"),u=!1;if(this.data.core.locked===!0&&t!=="unlock"&&t!=="is_locked")return;do{if(i&&i.plugin&&r.inArray(i.plugin,this._get_settings().plugins)!==-1)break;i=i.old}while(i);if(!i)return;if(t.indexOf("_")===0)e=i.apply(this,s);else{e=this.get_container().triggerHandler(o,{func:t,inst:this,args:s,plugin:i.plugin});if(e===!1)return;typeof e!="undefined"&&(s=e),e=i.apply(r.extend({},this,{__callback:function(e){this.get_container().triggerHandler(t+".jstree",{inst:this,args:s,rslt:e,rlbk:u})},__rollback:function(){return u=this.get_rollback(),u},__call_old:function(e){return i.old.apply(this,e?Array.prototype.slice.call(arguments,1):s)}}),s)}return e},r.jstree._fn[t].old=n.old,r.jstree._fn[t].plugin=e})},rollback:function(e){e&&(r.isArray(e)||(e=[e]),r.each(e,function(e,t){i[t.i].set_rollback(t.h,t.d)}))}},r.jstree._fn=r.jstree._instance.prototype={},r(function(){var i=navigator.userAgent.toLowerCase(),s=(i.match(/.+?(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,"0"])[1],o=".jstree ul, .jstree li { display:block; margin:0 0 0 0; padding:0 0 0 0; list-style-type:none; } .jstree li { display:block; min-height:18px; line-height:18px; white-space:nowrap; margin-left:18px; min-width:18px; } .jstree-rtl li { margin-left:0; margin-right:18px; } .jstree > ul > li { margin-left:0px; } .jstree-rtl > ul > li { margin-right:0px; } .jstree ins { display:inline-block; text-decoration:none; width:18px; height:18px; margin:0 0 0 0; padding:0; } .jstree a { display:inline-block; line-height:16px; height:16px; color:black; white-space:nowrap; text-decoration:none; padding:1px 2px; margin:0; } .jstree a:focus { outline: none; } .jstree a > ins { height:16px; width:16px; } .jstree a > .jstree-icon { margin-right:3px; } .jstree-rtl a > .jstree-icon { margin-left:3px; margin-right:0; } li.jstree-open > ul { display:block; } li.jstree-closed > ul { display:none; } ";if(/msie/.test(i)&&parseInt(s,10)==6){e=!0;try{document.execCommand("BackgroundImageCache",!1,!0)}catch(u){}o+=".jstree li { height:18px; margin-left:0; margin-right:0; } .jstree li li { margin-left:18px; } .jstree-rtl li li { margin-left:0px; margin-right:18px; } li.jstree-open ul { display:block; } li.jstree-closed ul { display:none !important; } .jstree li a { display:inline; border-width:0 !important; padding:0px 2px !important; } .jstree li a ins { height:16px; width:16px; margin-right:3px; } .jstree-rtl li a ins { margin-right:0px; margin-left:3px; } "}/msie/.test(i)&&parseInt(s,10)==7&&(t=!0,o+=".jstree li a { border-width:0 !important; padding:0px 2px !important; } "),!/compatible/.test(i)&&/mozilla/.test(i)&&parseFloat(s,10)<1.9&&(n=!0,o+=".jstree ins { display:-moz-inline-box; } .jstree li { line-height:12px; } .jstree a { display:-moz-inline-box; } .jstree .jstree-no-icons .jstree-checkbox { display:-moz-inline-stack !important; } "),r.vakata.css.add_sheet({str:o,title:"jstree"})}),r.jstree.plugin("core",{__init:function(){this.data.core.locked=!1,this.data.core.to_open=this.get_settings().core.initially_open,this.data.core.to_load=this.get_settings().core.initially_load},defaults:{html_titles:!1,animation:500,initially_open:[],initially_load:[],open_parents:!0,notify_plugins:!0,rtl:!1,load_open:!1,strings:{loading:"Loading ...",new_node:"New node",multiple_selection:"Multiple selection"}},_fn:{init:function(){this.set_focus(),this._get_settings().core.rtl&&this.get_container().addClass("jstree-rtl").css("direction","rtl"),this.get_container().html(""),this.data.core.li_height=this.get_container_ul().find("li.jstree-closed, li.jstree-leaf").eq(0).height()||18,this.get_container().delegate("li > ins","click.jstree",r.proxy(function(e){var t=r(e.target);t.is("ins")&&e.pageY-t.offset().top ul > li:first-child"):e.length?t?e.nextAll("li").size()>0?e.nextAll("li:eq(0)"):!1:e.hasClass("jstree-open")?e.find("li:eq(0)"):e.nextAll("li").size()>0?e.nextAll("li:eq(0)"):e.parentsUntil(".jstree","li").next("li").eq(0):!1},_get_prev:function(e,t){e=this._get_node(e);if(e===-1)return this.get_container().find("> ul > li:last-child");if(!e.length)return!1;if(t)return e.prevAll("li").length>0?e.prevAll("li:eq(0)"):!1;if(e.prev("li").length){e=e.prev("li").eq(0);while(e.hasClass("jstree-open"))e=e.children("ul:eq(0)").children("li:last");return e}var n=e.parentsUntil(".jstree","li:eq(0)");return n.length?n:!1},_get_parent:function(e){e=this._get_node(e);if(e==-1||!e.length)return!1;var t=e.parentsUntil(".jstree","li:eq(0)");return t.length?t:-1},_get_children:function(e){return e=this._get_node(e),e===-1?this.get_container().children("ul:eq(0)").children("li"):e.length?e.children("ul:eq(0)").children("li"):!1},get_path:function(e,t){var n=[],r=this;return e=this._get_node(e),e===-1||!e||!e.length?!1:(e.parentsUntil(".jstree","li").each(function(){n.push(t?this.id:r.get_text(this))}),n.reverse(),n.push(t?e.attr("id"):this.get_text(e)),n)},_get_string:function(e){return this._get_settings().core.strings[e]||e},is_open:function(e){return e=this._get_node(e),e&&e!==-1&&e.hasClass("jstree-open")},is_closed:function(e){return e=this._get_node(e),e&&e!==-1&&e.hasClass("jstree-closed")},is_leaf:function(e){return e=this._get_node(e),e&&e!==-1&&e.hasClass("jstree-leaf")},correct_state:function(e){e=this._get_node(e);if(!e||e===-1)return!1;e.removeClass("jstree-closed jstree-open").addClass("jstree-leaf").children("ul").remove(),this.__callback({obj:e})},open_node:function(t,n,r){t=this._get_node(t);if(!t.length)return!1;if(!t.hasClass("jstree-closed"))return n&&n.call(),!1;var i=r||e?0:this._get_settings().core.animation,s=this;this._is_loaded(t)?(this._get_settings().core.open_parents&&t.parentsUntil(".jstree",".jstree-closed").each(function(){s.open_node(this,!1,!0)}),i&&t.children("ul").css("display","none"),t.removeClass("jstree-closed").addClass("jstree-open").children("a").removeClass("jstree-loading"),i?t.children("ul").stop(!0,!0).slideDown(i,function(){this.style.display="",s.after_open(t)}):s.after_open(t),this.__callback({obj:t}),n&&n.call()):(t.children("a").addClass("jstree-loading"),this.load_node(t,function(){s.open_node(t,n,r)},n))},after_open:function(e){this.__callback({obj:e})},close_node:function(t,n){t=this._get_node(t);var r=n||e?0:this._get_settings().core.animation,i=this;if(!t.length||!t.hasClass("jstree-open"))return!1;r&&t.children("ul").attr("style","display:block !important"),t.removeClass("jstree-open").addClass("jstree-closed"),r?t.children("ul").stop(!0,!0).slideUp(r,function(){this.style.display="",i.after_close(t)}):i.after_close(t),this.__callback({obj:t})},after_close:function(e){this.__callback({obj:e})},toggle_node:function(e){e=this._get_node(e);if(e.hasClass("jstree-closed"))return this.open_node(e);if(e.hasClass("jstree-open"))return this.close_node(e)},open_all:function(e,t,n){e=e?this._get_node(e):-1;if(!e||e===-1)e=this.get_container_ul();n?e=e.find("li.jstree-closed"):(n=e,e.is(".jstree-closed")?e=e.find("li.jstree-closed").andSelf():e=e.find("li.jstree-closed"));var r=this;e.each(function(){var e=this;r._is_loaded(this)?r.open_node(this,!1,!t):r.open_node(this,function(){r.open_all(e,t,n)},!t)}),n.find("li.jstree-closed").length===0&&this.__callback({obj:n})},close_all:function(e,t){var n=this;e=e?this._get_node(e):this.get_container();if(!e||e===-1)e=this.get_container_ul();e.find("li.jstree-open").andSelf().each(function(){n.close_node(this,!t)}),this.__callback({obj:e})},clean_node:function(e){e=e&&e!=-1?r(e):this.get_container_ul(),e=e.is("li")?e.find("li").andSelf():e.find("li"),e.removeClass("jstree-last").filter("li:last-child").addClass("jstree-last").end().filter(":has(li)").not(".jstree-open").removeClass("jstree-leaf").addClass("jstree-closed"),e.not(".jstree-open, .jstree-closed").addClass("jstree-leaf").children("ul").remove(),this.__callback({obj:e})},get_rollback:function(){return this.__callback(),{i:this.get_index(),h:this.get_container().children("ul").clone(!0),d:this.data}},set_rollback:function(e,t){this.get_container().empty().append(e),this.data=t,this.__callback()},load_node:function(e,t,n){this.__callback({obj:e})},_is_loaded:function(e){return!0},create_node:function(e,t,n,i,s){e=this._get_node(e),t=typeof t=="undefined"?"last":t;var o=r("
  • "),u=this._get_settings().core,a;if(e!==-1&&!e.length)return!1;if(!s&&!this._is_loaded(e))return this.load_node(e,function(){this.create_node(e,t,n,i,!0)}),!1;this.__rollback(),typeof n=="string"&&(n={data:n}),n||(n={}),n.attr&&o.attr(n.attr),n.metadata&&o.data(n.metadata),n.state&&o.addClass("jstree-"+n.state),n.data||(n.data=this._get_string("new_node")),r.isArray(n.data)||(a=n.data,n.data=[],n.data.push(a)),r.each(n.data,function(e,t){a=r(""),r.isFunction(t)&&(t=t.call(this,n)),typeof t=="string"?a.attr("href","#")[u.html_titles?"html":"text"](t):(t.attr||(t.attr={}),t.attr.href||(t.attr.href="#"),a.attr(t.attr)[u.html_titles?"html":"text"](t.title),t.language&&a.addClass(t.language)),a.prepend(" "),t.icon&&(t.icon.indexOf("/")===-1?a.children("ins").addClass(t.icon):a.children("ins").css("background","url('"+t.icon+"') center center no-repeat")),o.append(a)}),o.prepend(" "),e===-1&&(e=this.get_container(),t==="before"&&(t="first"),t==="after"&&(t="last"));switch(t){case"before":e.before(o),a=this._get_parent(e);break;case"after":e.after(o),a=this._get_parent(e);break;case"inside":case"first":e.children("ul").length||e.append("