From a871ebd766d18dca5180063464026ee80fa8f564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Fri, 28 Feb 2020 09:25:42 +0100 Subject: [PATCH] #1080 DataTables & PlUpload libraries removed --- README.md | 6 +- after_init.rb | 5 +- app/controllers/dmsf_controller.rb | 205 +- app/controllers/dmsf_files_controller.rb | 11 +- app/controllers/dmsf_upload_controller.rb | 4 - app/views/dmsf/_custom_fields.html.erb | 2 +- app/views/dmsf/_dir.html.erb | 87 - app/views/dmsf/_dir_trash.html.erb | 71 - app/views/dmsf/_dmsf_rows.erb | 117 - app/views/dmsf/_file.html.erb | 91 - app/views/dmsf/_file_trash.html.erb | 71 - app/views/dmsf/_list_view.erb | 149 - app/views/dmsf/_tree_view.erb | 72 - app/views/dmsf/_url.html.erb | 73 - app/views/dmsf/_url_trash.html.erb | 70 - app/views/dmsf/dmsf_rows.js.erb | 79 - app/views/dmsf/show.html.erb | 157 +- app/views/dmsf/trash.html.erb | 219 +- .../dmsf_files/_revision_access.html.erb | 59 +- app/views/dmsf_upload/_form.html.erb | 6 +- app/views/dmsf_upload/_multi_upload.html.erb | 100 - .../_approval_workflow_button.html.erb | 6 +- app/views/dmsf_workflows/assignment.js.erb | 3 +- app/views/settings/_dmsf_settings.html.erb | 16 - assets/javascripts/attachments_dmsf.js | 4 +- .../jquery.dataTables/datatables.min.js | 231 - .../jquery.dataTables/locales/af.json | 23 - .../jquery.dataTables/locales/am.json | 23 - .../jquery.dataTables/locales/ar.json | 23 - .../jquery.dataTables/locales/az.json | 23 - .../jquery.dataTables/locales/be.json | 21 - .../jquery.dataTables/locales/bg.json | 17 - .../jquery.dataTables/locales/bn.json | 17 - .../jquery.dataTables/locales/ca.json | 17 - .../jquery.dataTables/locales/co.json | 23 - .../jquery.dataTables/locales/cr.json | 23 - .../jquery.dataTables/locales/cs.json | 23 - .../jquery.dataTables/locales/cy.json | 23 - .../jquery.dataTables/locales/da.json | 17 - .../jquery.dataTables/locales/de.json | 45 - .../jquery.dataTables/locales/du.json | 30 - .../jquery.dataTables/locales/el.json | 27 - .../jquery.dataTables/locales/en.json | 23 - .../jquery.dataTables/locales/eo.json | 23 - .../jquery.dataTables/locales/es.json | 28 - .../jquery.dataTables/locales/et.json | 16 - .../jquery.dataTables/locales/eu.json | 24 - .../jquery.dataTables/locales/fa.json | 23 - .../jquery.dataTables/locales/fi.json | 39 - .../jquery.dataTables/locales/fr.json | 30 - .../jquery.dataTables/locales/ga.json | 17 - .../jquery.dataTables/locales/gl.json | 24 - .../jquery.dataTables/locales/gu.json | 23 - .../jquery.dataTables/locales/he.json | 18 - .../jquery.dataTables/locales/hi.json | 17 - .../jquery.dataTables/locales/hu.json | 40 - .../jquery.dataTables/locales/hy.json | 23 - .../jquery.dataTables/locales/id.json | 18 - .../jquery.dataTables/locales/is.json | 23 - .../jquery.dataTables/locales/it.json | 23 - .../jquery.dataTables/locales/ja.json | 23 - .../jquery.dataTables/locales/ka.json | 23 - .../jquery.dataTables/locales/kk.json | 22 - .../jquery.dataTables/locales/km.json | 23 - .../jquery.dataTables/locales/ko.json | 23 - .../jquery.dataTables/locales/ky.json | 23 - .../jquery.dataTables/locales/lo.json | 23 - .../jquery.dataTables/locales/lt.json | 22 - .../jquery.dataTables/locales/lv.json | 22 - .../jquery.dataTables/locales/mk.json | 19 - .../jquery.dataTables/locales/mn.json | 23 - .../jquery.dataTables/locales/ms.json | 23 - .../jquery.dataTables/locales/nb.json | 25 - .../jquery.dataTables/locales/ne.json | 24 - .../jquery.dataTables/locales/nj.json | 23 - .../jquery.dataTables/locales/nn.json | 25 - .../jquery.dataTables/locales/no.json | 24 - .../jquery.dataTables/locales/pl.json | 22 - .../jquery.dataTables/locales/ps.json | 23 - .../jquery.dataTables/locales/pt-BR.json | 30 - .../jquery.dataTables/locales/pt.json | 22 - .../jquery.dataTables/locales/ro.json | 17 - .../jquery.dataTables/locales/ru.json | 29 - .../jquery.dataTables/locales/si.json | 23 - .../jquery.dataTables/locales/sk.json | 23 - .../jquery.dataTables/locales/sl.json | 23 - .../jquery.dataTables/locales/sq.json | 23 - .../jquery.dataTables/locales/sr.json | 23 - .../jquery.dataTables/locales/sv.json | 23 - .../jquery.dataTables/locales/sw.json | 23 - .../jquery.dataTables/locales/ta.json | 23 - .../jquery.dataTables/locales/te.json | 23 - .../jquery.dataTables/locales/th.json | 23 - .../jquery.dataTables/locales/to.json | 17 - .../jquery.dataTables/locales/tr.json | 31 - .../jquery.dataTables/locales/uk.json | 21 - .../jquery.dataTables/locales/ur.json | 17 - .../jquery.dataTables/locales/uz.json | 22 - .../jquery.dataTables/locales/vi.json | 17 - .../jquery.dataTables/locales/zh-TW.json | 24 - .../jquery.dataTables/locales/zh.json | 24 - assets/javascripts/plupload/bower.json | 25 - assets/javascripts/plupload/js/Moxie.swf | Bin 27640 -> 0 bytes assets/javascripts/plupload/js/Moxie.xap | Bin 65757 -> 0 bytes assets/javascripts/plupload/js/i18n/ar.js | 2 - assets/javascripts/plupload/js/i18n/az.js | 2 - assets/javascripts/plupload/js/i18n/bg.js | 2 - assets/javascripts/plupload/js/i18n/bs.js | 2 - assets/javascripts/plupload/js/i18n/ca.js | 2 - assets/javascripts/plupload/js/i18n/cs.js | 2 - assets/javascripts/plupload/js/i18n/cy.js | 2 - assets/javascripts/plupload/js/i18n/da.js | 2 - assets/javascripts/plupload/js/i18n/de.js | 2 - assets/javascripts/plupload/js/i18n/el.js | 2 - assets/javascripts/plupload/js/i18n/en.js | 2 - assets/javascripts/plupload/js/i18n/es.js | 2 - assets/javascripts/plupload/js/i18n/et.js | 2 - assets/javascripts/plupload/js/i18n/fa.js | 2 - assets/javascripts/plupload/js/i18n/fi.js | 2 - assets/javascripts/plupload/js/i18n/fr.js | 2 - assets/javascripts/plupload/js/i18n/he.js | 2 - assets/javascripts/plupload/js/i18n/hr.js | 2 - assets/javascripts/plupload/js/i18n/hu.js | 2 - assets/javascripts/plupload/js/i18n/hy.js | 2 - assets/javascripts/plupload/js/i18n/id.js | 2 - assets/javascripts/plupload/js/i18n/it.js | 2 - assets/javascripts/plupload/js/i18n/ja.js | 2 - assets/javascripts/plupload/js/i18n/ka.js | 2 - assets/javascripts/plupload/js/i18n/kk.js | 2 - assets/javascripts/plupload/js/i18n/km.js | 2 - assets/javascripts/plupload/js/i18n/ko.js | 2 - assets/javascripts/plupload/js/i18n/ku_IQ.js | 2 - assets/javascripts/plupload/js/i18n/lt.js | 2 - assets/javascripts/plupload/js/i18n/lv.js | 2 - assets/javascripts/plupload/js/i18n/ms.js | 2 - assets/javascripts/plupload/js/i18n/nl.js | 2 - assets/javascripts/plupload/js/i18n/pl.js | 2 - assets/javascripts/plupload/js/i18n/pt.js | 2 - assets/javascripts/plupload/js/i18n/pt_BR.js | 2 - assets/javascripts/plupload/js/i18n/ro.js | 2 - assets/javascripts/plupload/js/i18n/ru.js | 2 - assets/javascripts/plupload/js/i18n/sk.js | 2 - assets/javascripts/plupload/js/i18n/sl.js | 2 - assets/javascripts/plupload/js/i18n/sq.js | 2 - assets/javascripts/plupload/js/i18n/sr.js | 2 - assets/javascripts/plupload/js/i18n/sv.js | 2 - assets/javascripts/plupload/js/i18n/th_TH.js | 2 - assets/javascripts/plupload/js/i18n/tr.js | 2 - assets/javascripts/plupload/js/i18n/uk_UA.js | 2 - assets/javascripts/plupload/js/i18n/vi.js | 2 - assets/javascripts/plupload/js/i18n/zh_CN.js | 2 - assets/javascripts/plupload/js/i18n/zh_TW.js | 2 - .../jquery.ui.plupload/jquery.ui.plupload.js | 1350 -- .../jquery.ui.plupload.min.js | 1 - assets/javascripts/plupload/js/moxie.js | 11718 ---------------- assets/javascripts/plupload/js/moxie.min.js | 16 - .../javascripts/plupload/js/plupload.dev.js | 4388 ------ .../plupload/js/plupload.full.min.js | 29 - .../javascripts/plupload/js/plupload.min.js | 13 - assets/javascripts/plupload/license.txt | 661 - assets/javascripts/plupload/readme.md | 147 - assets/javascripts/redmine_dmsf.js | 113 - .../jquery.dataTables/datatables.min.css | 18 - .../jquery.dataTables/images/sort_asc.png | Bin 160 -> 0 bytes .../images/sort_asc_disabled.png | Bin 148 -> 0 bytes .../jquery.dataTables/images/sort_both.png | Bin 201 -> 0 bytes .../jquery.dataTables/images/sort_desc.png | Bin 158 -> 0 bytes .../images/sort_desc_disabled.png | Bin 146 -> 0 bytes .../plupload/jquery.ui.plupload.css | 379 - assets/stylesheets/redmine_dmsf.css | 220 +- config/locales/cs.yml | 12 - config/locales/de.yml | 11 - config/locales/en.yml | 12 - config/locales/es.yml | 12 - config/locales/fr.yml | 12 - config/locales/hu.yml | 13 - config/locales/it.yml | 12 - config/locales/ja.yml | 12 - config/locales/ko.yml | 11 - config/locales/nl.yml | 12 - config/locales/pl.yml | 12 - config/locales/pt-BR.yml | 12 - config/locales/ru.yml | 12 - config/locales/sl.yml | 12 - config/locales/zh-TW.yml | 12 - config/locales/zh.yml | 12 - config/routes.rb | 1 - init.rb | 2 - 188 files changed, 141 insertions(+), 22884 deletions(-) delete mode 100644 app/views/dmsf/_dir.html.erb delete mode 100644 app/views/dmsf/_dir_trash.html.erb delete mode 100644 app/views/dmsf/_dmsf_rows.erb delete mode 100644 app/views/dmsf/_file.html.erb delete mode 100644 app/views/dmsf/_file_trash.html.erb delete mode 100644 app/views/dmsf/_list_view.erb delete mode 100644 app/views/dmsf/_tree_view.erb delete mode 100644 app/views/dmsf/_url.html.erb delete mode 100644 app/views/dmsf/_url_trash.html.erb delete mode 100644 app/views/dmsf/dmsf_rows.js.erb delete mode 100644 app/views/dmsf_upload/_multi_upload.html.erb delete mode 100644 assets/javascripts/jquery.dataTables/datatables.min.js delete mode 100644 assets/javascripts/jquery.dataTables/locales/af.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/am.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/ar.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/az.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/be.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/bg.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/bn.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/ca.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/co.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/cr.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/cs.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/cy.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/da.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/de.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/du.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/el.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/en.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/eo.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/es.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/et.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/eu.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/fa.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/fi.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/fr.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/ga.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/gl.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/gu.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/he.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/hi.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/hu.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/hy.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/id.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/is.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/it.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/ja.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/ka.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/kk.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/km.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/ko.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/ky.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/lo.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/lt.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/lv.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/mk.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/mn.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/ms.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/nb.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/ne.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/nj.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/nn.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/no.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/pl.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/ps.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/pt-BR.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/pt.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/ro.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/ru.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/si.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/sk.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/sl.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/sq.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/sr.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/sv.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/sw.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/ta.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/te.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/th.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/to.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/tr.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/uk.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/ur.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/uz.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/vi.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/zh-TW.json delete mode 100644 assets/javascripts/jquery.dataTables/locales/zh.json delete mode 100644 assets/javascripts/plupload/bower.json delete mode 100644 assets/javascripts/plupload/js/Moxie.swf delete mode 100644 assets/javascripts/plupload/js/Moxie.xap delete mode 100644 assets/javascripts/plupload/js/i18n/ar.js delete mode 100644 assets/javascripts/plupload/js/i18n/az.js delete mode 100644 assets/javascripts/plupload/js/i18n/bg.js delete mode 100644 assets/javascripts/plupload/js/i18n/bs.js delete mode 100644 assets/javascripts/plupload/js/i18n/ca.js delete mode 100644 assets/javascripts/plupload/js/i18n/cs.js delete mode 100644 assets/javascripts/plupload/js/i18n/cy.js delete mode 100644 assets/javascripts/plupload/js/i18n/da.js delete mode 100644 assets/javascripts/plupload/js/i18n/de.js delete mode 100644 assets/javascripts/plupload/js/i18n/el.js delete mode 100644 assets/javascripts/plupload/js/i18n/en.js delete mode 100644 assets/javascripts/plupload/js/i18n/es.js delete mode 100644 assets/javascripts/plupload/js/i18n/et.js delete mode 100644 assets/javascripts/plupload/js/i18n/fa.js delete mode 100644 assets/javascripts/plupload/js/i18n/fi.js delete mode 100644 assets/javascripts/plupload/js/i18n/fr.js delete mode 100644 assets/javascripts/plupload/js/i18n/he.js delete mode 100644 assets/javascripts/plupload/js/i18n/hr.js delete mode 100644 assets/javascripts/plupload/js/i18n/hu.js delete mode 100644 assets/javascripts/plupload/js/i18n/hy.js delete mode 100644 assets/javascripts/plupload/js/i18n/id.js delete mode 100644 assets/javascripts/plupload/js/i18n/it.js delete mode 100644 assets/javascripts/plupload/js/i18n/ja.js delete mode 100644 assets/javascripts/plupload/js/i18n/ka.js delete mode 100644 assets/javascripts/plupload/js/i18n/kk.js delete mode 100644 assets/javascripts/plupload/js/i18n/km.js delete mode 100644 assets/javascripts/plupload/js/i18n/ko.js delete mode 100644 assets/javascripts/plupload/js/i18n/ku_IQ.js delete mode 100644 assets/javascripts/plupload/js/i18n/lt.js delete mode 100644 assets/javascripts/plupload/js/i18n/lv.js delete mode 100644 assets/javascripts/plupload/js/i18n/ms.js delete mode 100644 assets/javascripts/plupload/js/i18n/nl.js delete mode 100644 assets/javascripts/plupload/js/i18n/pl.js delete mode 100644 assets/javascripts/plupload/js/i18n/pt.js delete mode 100644 assets/javascripts/plupload/js/i18n/pt_BR.js delete mode 100644 assets/javascripts/plupload/js/i18n/ro.js delete mode 100644 assets/javascripts/plupload/js/i18n/ru.js delete mode 100644 assets/javascripts/plupload/js/i18n/sk.js delete mode 100644 assets/javascripts/plupload/js/i18n/sl.js delete mode 100644 assets/javascripts/plupload/js/i18n/sq.js delete mode 100644 assets/javascripts/plupload/js/i18n/sr.js delete mode 100644 assets/javascripts/plupload/js/i18n/sv.js delete mode 100644 assets/javascripts/plupload/js/i18n/th_TH.js delete mode 100644 assets/javascripts/plupload/js/i18n/tr.js delete mode 100644 assets/javascripts/plupload/js/i18n/uk_UA.js delete mode 100644 assets/javascripts/plupload/js/i18n/vi.js delete mode 100644 assets/javascripts/plupload/js/i18n/zh_CN.js delete mode 100644 assets/javascripts/plupload/js/i18n/zh_TW.js delete mode 100644 assets/javascripts/plupload/js/jquery.ui.plupload/jquery.ui.plupload.js delete mode 100644 assets/javascripts/plupload/js/jquery.ui.plupload/jquery.ui.plupload.min.js delete mode 100644 assets/javascripts/plupload/js/moxie.js delete mode 100644 assets/javascripts/plupload/js/moxie.min.js delete mode 100644 assets/javascripts/plupload/js/plupload.dev.js delete mode 100644 assets/javascripts/plupload/js/plupload.full.min.js delete mode 100644 assets/javascripts/plupload/js/plupload.min.js delete mode 100644 assets/javascripts/plupload/license.txt delete mode 100644 assets/javascripts/plupload/readme.md delete mode 100644 assets/stylesheets/jquery.dataTables/datatables.min.css delete mode 100644 assets/stylesheets/jquery.dataTables/images/sort_asc.png delete mode 100644 assets/stylesheets/jquery.dataTables/images/sort_asc_disabled.png delete mode 100644 assets/stylesheets/jquery.dataTables/images/sort_both.png delete mode 100644 assets/stylesheets/jquery.dataTables/images/sort_desc.png delete mode 100644 assets/stylesheets/jquery.dataTables/images/sort_desc_disabled.png delete mode 100644 assets/stylesheets/plupload/jquery.ui.plupload.css diff --git a/README.md b/README.md index aee9dd38..5406fcf5 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,7 @@ Features * Document versioning / revision history * Email notifications for directories and/or documents * Document locking - * Multi (drag/drop depending on browser) upload/download - * Multi download via zip + * Multi (drag/drop depending on browser) upload/download * Direct document or document link sending via email * Configurable document approval workflow * Document access auditing @@ -34,8 +33,7 @@ Features * Wiki macros for quick content linking * Full read/write webdav functionality * Optional document content full-text search - * Documents and folders symbolic links - * Document tagging + * Documents and folders symbolic links * Trash bin * Documents attachable to issues * Compatible with Redmine 4.1.x diff --git a/after_init.rb b/after_init.rb index fb1e85a5..7b963d7e 100644 --- a/after_init.rb +++ b/after_init.rb @@ -49,10 +49,7 @@ def dmsf_init {:dmsf => [:show]}, :read => true pmap.permission :user_preferences, - { - dmsf_state: [:user_pref_save], - dmsf: [:switch_rlf] - } + { dmsf_state: [:user_pref_save] } pmap.permission :view_dmsf_files, {:dmsf => [:entries_operation, :entries_email, :download_email_entries, :tag_changed, :add_email, :append_email, :autocomplete_for_user], diff --git a/app/controllers/dmsf_controller.rb b/app/controllers/dmsf_controller.rb index 09c1b8ee..11b43b6f 100644 --- a/app/controllers/dmsf_controller.rb +++ b/app/controllers/dmsf_controller.rb @@ -67,65 +67,25 @@ class DmsfController < ApplicationController end end - def switch_rlf - rlf = params[:rlf] == 'true' - cookie_options = { - value: !rlf, - expires: 1.year.from_now, - path: (RedmineApp::Application.config.relative_url_root || '/'), - secure: request.ssl?, - httponly: true - } - cookies[:dmsf_switch_rlf] = cookie_options - redirect_to dmsf_folder_path(id: @project, folder_id: @folder) - end - def show - @rlf = cookies[:dmsf_switch_rlf] == 'true' - if @rlf - @system_folder = @folder && @folder.system - @locked_for_user = @folder && @folder.locked_for_user? - @folder_manipulation_allowed = User.current.allowed_to?(:folder_manipulation, @project) - @file_manipulation_allowed = User.current.allowed_to?(:file_manipulation, @project) - #@file_delete_allowed = User.current.allowed_to?(:file_delete, @project) - #@file_view_allowed = User.current.allowed_to?(:view_dmsf_files, @project) - #@force_file_unlock_allowed = User.current.allowed_to?(:force_file_unlock, @project) - #@workflows_available = DmsfWorkflow.where(['project_id = ? OR project_id IS NULL', @project.id]).exists? - #@file_approval_allowed = User.current.allowed_to?(:file_approval, @project) - @trash_enabled = @folder_manipulation_allowed && @file_manipulation_allowed - use_session = !request.format.csv? - @query = retrieve_query(DmsfQuery, use_session) - @query.dmsf_folder_id = @folder ? @folder.id : nil - @query.deleted = false - if (@folder && @folder.deleted?) || (params[:folder_title].present? && !@folder) - render_404 - return - end - respond_to do |format| - format.html { - @dmsf_count = @query.dmsf_count - @dmsf_pages = Paginator.new @dmsf_count, per_page_option, params['page'] - render layout: !request.xhr? - } - format.api - format.csv { - filename = @project.name - filename << "_#{@folder.title}" if @folder - filename << DateTime.current.strftime('_%Y%m%d%H%M%S.csv') - send_data(DmsfHelper.dmsf_to_csv(@folder ? @folder : @project, params[:settings][:dmsf_columns]), - :type => 'text/csv; header=present', :filename => filename) - } - end - return - end - get_display_params + @system_folder = @folder && @folder.system + @locked_for_user = @folder && @folder.locked_for_user? + @folder_manipulation_allowed = User.current.allowed_to?(:folder_manipulation, @project) + @file_manipulation_allowed = User.current.allowed_to?(:file_manipulation, @project) + @trash_enabled = @folder_manipulation_allowed && @file_manipulation_allowed + use_session = !request.format.csv? + @query = retrieve_query(DmsfQuery, use_session) + @query.dmsf_folder_id = @folder ? @folder.id : nil + @query.deleted = false if (@folder && @folder.deleted?) || (params[:folder_title].present? && !@folder) render_404 return end respond_to do |format| format.html { - render :layout => !request.xhr? + @dmsf_count = @query.dmsf_count + @dmsf_pages = Paginator.new @dmsf_count, per_page_option, params['page'] + render layout: !request.xhr? } format.api format.csv { @@ -133,36 +93,24 @@ class DmsfController < ApplicationController filename << "_#{@folder.title}" if @folder filename << DateTime.current.strftime('_%Y%m%d%H%M%S.csv') send_data(DmsfHelper.dmsf_to_csv(@folder ? @folder : @project, params[:settings][:dmsf_columns]), - :type => 'text/csv; header=present', :filename => filename) + type: 'text/csv; header=present', filename: filename) } end end def trash - @rlf = cookies[:dmsf_switch_rlf] == 'true' - if @rlf - @folder_manipulation_allowed = User.current.allowed_to? :folder_manipulation, @project - @file_manipulation_allowed = User.current.allowed_to? :file_manipulation, @project - @file_delete_allowed = User.current.allowed_to? :file_delete, @project - @query = retrieve_query(DmsfQuery, true) - @query.deleted = true - respond_to do |format| - format.html { - @dmsf_count = @query.dmsf_count - @dmsf_pages = Paginator.new @dmsf_count, per_page_option, params['page'] - render layout: !request.xhr? - } - end - return - end @folder_manipulation_allowed = User.current.allowed_to? :folder_manipulation, @project @file_manipulation_allowed = User.current.allowed_to? :file_manipulation, @project @file_delete_allowed = User.current.allowed_to? :file_delete, @project - @subfolders = DmsfFolder.deleted.where(project_id: @project.id) - @files = DmsfFile.deleted.where(project_id: @project.id) - @dir_links = DmsfLink.deleted.where(project_id: @project.id, target_type: DmsfFolder.model_name.to_s) - @file_links = DmsfLink.deleted.where(project_id: @project.id, target_type: DmsfFile.model_name.to_s) - @url_links = DmsfLink.deleted.where(project_id: @project.id, target_type: 'DmsfUrl') + @query = retrieve_query(DmsfQuery, true) + @query.deleted = true + respond_to do |format| + format.html { + @dmsf_count = @query.dmsf_count + @dmsf_pages = Paginator.new @dmsf_count, per_page_option, params['page'] + render layout: !request.xhr? + } + end end def download_email_entries @@ -699,113 +647,4 @@ class DmsfController < ApplicationController copy end - def get_display_params - @rlf = cookies[:dmsf_switch_rlf] == 'true' - @system_folder = @folder && @folder.system - @folder_manipulation_allowed = User.current.allowed_to?(:folder_manipulation, @project) - @file_manipulation_allowed = User.current.allowed_to?(:file_manipulation, @project) - @file_delete_allowed = User.current.allowed_to?(:file_delete, @project) - @file_view_allowed = User.current.allowed_to?(:view_dmsf_files, @project) - @force_file_unlock_allowed = User.current.allowed_to?(:force_file_unlock, @project) - @workflows_available = DmsfWorkflow.where(project_id: @project.id).or(DmsfWorkflow.where(project_id: nil)).exists? - @file_approval_allowed = User.current.allowed_to?(:file_approval, @project) - tag = params[:custom_field_id].present? && params[:custom_value].present? - @extra_columns = [l(:label_last_approver), l(:field_project), l(:label_document_url), l(:label_last_revision_id)] - if @tree_view - @locked_for_user = false - else - if tag - @subfolders = [] - @folder = nil - DmsfFolder.where(project_id: @project.id, system: false).visible.find_each do |f| - f.custom_field_values.each do |v| - if v.custom_field_id == params[:custom_field_id].to_i - if v.custom_field.compare_values?(v.value, params[:custom_value]) - @subfolders << f - break - end - end - end - end - @files = [] - DmsfFile.where(project_id: @project.id).visible.find_each do |f| - r = f.last_revision - if r - r.custom_field_values.each do |v| - if v.custom_field_id == params[:custom_field_id].to_i - if v.custom_field.compare_values?(v.value, params[:custom_value]) - @files << f - break - end - end - end - end - end - @dir_links = [] - DmsfLink.where(project_id: @project.id, target_type: DmsfFolder.model_name.to_s).where.not( - target_id: nil).visible.find_each do |l| - l.target_folder.custom_field_values.each do |v| - if v.custom_field_id == params[:custom_field_id].to_i - if v.custom_field.compare_values?(v.value, params[:custom_value]) - @dir_links << l - break - end - end - end - end - @file_links = [] - DmsfLink.where(project_id: @project.id, target_type: DmsfFile.model_name.to_s).visible.find_each do |l| - r = l.target_file.last_revision if l.target_file - if r - r.custom_field_values.each do |v| - if v.custom_field_id == params[:custom_field_id].to_i - if v.custom_field.compare_values?(v.value, params[:custom_value]) - @file_links << l - break - end - end - end - end - end - @url_links = [] - else - scope = @folder ? @folder : @project - @locked_for_user = @folder && @folder.locked_for_user? - @subfolders = scope.dmsf_folders.visible - @files = scope.dmsf_files.visible - @dir_links = scope.folder_links.visible - @file_links = scope.file_links.visible - @url_links = scope.url_links.visible - # Limit and offset for REST API calls - if params[:limit].present? - @subfolders = @subfolders.limit(params[:limit]) - @files = @files.limit(params[:limit]) - @dir_links = @dir_links.limit(params[:limit]) - @file_links = @file_links.limit(params[:limit]) - @url_links = @url_links.limit(params[:limit]) - end - if params[:offset].present? - @subfolders = @subfolders.offset(params[:offset]) - @files = @files.offset(params[:offset]) - @dir_links = @dir_links.offset(params[:offset]) - @file_links = @file_links.offset(params[:offset]) - @url_links = @url_links.offset(params[:offset]) - end - end - # Remove system folders you are not allowed to see because you are not allowed to see the issue or you are not - # permitted to see system folders - @subfolders = DmsfFolder.visible_folders(@subfolders, @project) - end - - @ajax_upload_size = Setting.plugin_redmine_dmsf['dmsf_max_ajax_upload_filesize'].presence || 100 - - # Trash - visible = @folder_manipulation_allowed && @file_manipulation_allowed && - @file_delete_allowed && !@locked_for_user && !@folder - enabled = DmsfFolder.deleted.where(project_id: @project.id).exists? || - DmsfFile.deleted.where(project_id: @project.id).exists? || - DmsfLink.deleted.where(project_id: @project.id).exists? - @trash_enabled = visible && enabled - end - end diff --git a/app/controllers/dmsf_files_controller.rb b/app/controllers/dmsf_files_controller.rb index b0103bd4..ac62f908 100644 --- a/app/controllers/dmsf_files_controller.rb +++ b/app/controllers/dmsf_files_controller.rb @@ -87,13 +87,10 @@ class DmsfFilesController < ApplicationController @file_delete_allowed = User.current.allowed_to?(:file_delete, @project) @file_manipulation_allowed = User.current.allowed_to?(:file_manipulation, @project) @revision_pages = Paginator.new @file.dmsf_file_revisions.visible.count, params['per_page'] ? params['per_page'].to_i : 25, params['page'] - @rlf = cookies[:dmsf_switch_rlf] == 'true' - if @rlf - @revision_access_query = retrieve_query(DmsfFileRevisionAccessQuery, true) - @revision_access_query.revision_id = @revision.id - @revision_access_count = @revision_access_query.access_count - @revision_access_pages = Paginator.new @revision_access_count, per_page_option, params['page'] - end + @revision_access_query = retrieve_query(DmsfFileRevisionAccessQuery, true) + @revision_access_query.revision_id = @revision.id + @revision_access_count = @revision_access_query.access_count + @revision_access_pages = Paginator.new @revision_access_count, per_page_option, params['page'] respond_to do |format| format.html { diff --git a/app/controllers/dmsf_upload_controller.rb b/app/controllers/dmsf_upload_controller.rb index 92783b46..335ac516 100644 --- a/app/controllers/dmsf_upload_controller.rb +++ b/app/controllers/dmsf_upload_controller.rb @@ -40,10 +40,6 @@ class DmsfUploadController < ApplicationController true end - def multi_upload - @rlf = cookies[:dmsf_switch_rlf] == 'true' - end - def upload_files uploaded_files = params[:dmsf_attachments] @uploads = [] diff --git a/app/views/dmsf/_custom_fields.html.erb b/app/views/dmsf/_custom_fields.html.erb index 0acdb532..2fdfa990 100644 --- a/app/views/dmsf/_custom_fields.html.erb +++ b/app/views/dmsf/_custom_fields.html.erb @@ -27,7 +27,7 @@ <% object.custom_field_values.each do |custom_value| %> <% unless custom_value.value.blank? %>
- <%= content_tag :div, h(custom_value.custom_field.name), :class => 'label' %> + <%= content_tag :div, h(custom_value.custom_field.name), class: 'label' %>
<%= show_value custom_value %>
diff --git a/app/views/dmsf/_dir.html.erb b/app/views/dmsf/_dir.html.erb deleted file mode 100644 index 37a71720..00000000 --- a/app/views/dmsf/_dir.html.erb +++ /dev/null @@ -1,87 +0,0 @@ -<% -# encoding: utf-8 -# -# Redmine plugin for Document Management System "Features" -# -# Copyright © 2011-20 Karel Pičman -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -%> - - - <% unless subfolder && subfolder.system %> - <%= check_box_tag('ids[]', "#{name}-#{id}", false, :id => "subfolder_#{id}") %> - <% end %> - -<% if DmsfFolder.is_column_on?('id') %> - - <% if subfolder %> - <% if subfolder.system %> - <%= subfolder.id %> - <% else %> - <%= link_to(subfolder.id, edit_dmsf_path(:id => project, :folder_id => subfolder)) %> - <% end %> - <% else %> - <%= link_to(link.target_project_id, project_path(link.target_project)) %> - <% end %> - -<% end %> -<% if DmsfFolder.is_column_on?('title') %> - - <% if @tree_view %> - > - <% end %> - <%= link_to(h(title), - dmsf_folder_path(:id => project, :folder_id => subfolder), - :class => 'icon icon-folder', - :title => subfolder ? h(subfolder.description) : nil) %> - <% if link %> -
<%= link.path %>
- <% else %> -
[<%= subfolder.items %>]
- <% end %> - -<% end %> -<% if DmsfFolder.is_column_on?('extension') %> - -<% end %> -<% if DmsfFolder.is_column_on?('size') %> - -<% end %> -<% if DmsfFolder.is_column_on?('modified') %> - <%= format_time(subfolder.modified) if subfolder %> -<% end %> -<% if DmsfFolder.is_column_on?('version') %> - -<% end %> -<% if DmsfFolder.is_column_on?('workflow') %> - -<% end %> -<% if DmsfFolder.is_column_on?('author') %> - <%= h(subfolder.user) if subfolder %> -<% end %> -<% DmsfFileRevisionCustomField.visible.order(:position).each do |c| %> - <% if DmsfFolder.is_column_on?(c.name) %> - - <%= show_value(subfolder.custom_value(c)) if subfolder %> - - <% end %> -<% end %> -<%= link_to_context_menu %> -<%= position %> -0 -<%= subfolder.modified.to_i if subfolder %> -0 -<%= clear_title(title) %> diff --git a/app/views/dmsf/_dir_trash.html.erb b/app/views/dmsf/_dir_trash.html.erb deleted file mode 100644 index 8f835a57..00000000 --- a/app/views/dmsf/_dir_trash.html.erb +++ /dev/null @@ -1,71 +0,0 @@ -<% -# encoding: utf-8 -# -# Redmine plugin for Document Management System "Features" -# -# Copyright © 2011-20 Karel Pičman -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -%> - -<%= check_box_tag('ids[]', "#{name}-#{id}", false, :id => "subfolder_#{id}") %> -<% if DmsfFolder.is_column_on?('id') %> - <%= link_to(subfolder.id, edit_dmsf_path(:id => project, :folder_id => subfolder)) %> -<% end %> -<% if DmsfFolder.is_column_on?('title') %> - - <%= content_tag(:span, h(title), - :title => subfolder ? h(subfolder.description) : nil, - :class => 'icon icon-folder') %> - <% if link %> -
<%= link.path %>
- <% else %> -
[<%= subfolder.items %>]
- <% end %> - -<% end %> -<% if DmsfFolder.is_column_on?('extension') %> - -<% end %> -<% if DmsfFolder.is_column_on?('size') %> - -<% end %> -<% if DmsfFolder.is_column_on?('modified') %> - - <%= format_time(subfolder.modified) if subfolder %> - -<% end %> -<% if DmsfFolder.is_column_on?('version') %> - -<% end %> -<% if DmsfFolder.is_column_on?('workflow') %> - -<% end %> -<% if DmsfFolder.is_column_on?('author') %> - <%= h(subfolder.user) if subfolder %> -<% end %> -<% DmsfFileRevisionCustomField.visible.order(:position).each do |c| %> - <% if DmsfFolder.is_column_on?(c.name) %> - - <%= show_value(subfolder.custom_value(c)) if subfolder %> - - <% end %> -<% end %> -<%= link_to_context_menu %> -0 -0 -<%= subfolder.modified.to_i if subfolder %> -0 -<%= clear_title(title) %> diff --git a/app/views/dmsf/_dmsf_rows.erb b/app/views/dmsf/_dmsf_rows.erb deleted file mode 100644 index e903915b..00000000 --- a/app/views/dmsf/_dmsf_rows.erb +++ /dev/null @@ -1,117 +0,0 @@ -<% - # encoding: utf-8 - # - # Redmine plugin for Document Management System "Features" - # - # Copyright © 2011-20 Karel Pičman - # - # This program is free software; you can redistribute it and/or - # modify it under the terms of the GNU General Public License - # as published by the Free Software Foundation; either version 2 - # of the License, or (at your option) any later version. - # - # This program is distributed in the hope that it will be useful, - # but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - # GNU General Public License for more details. - # - # You should have received a copy of the GNU General Public License - # along with this program; if not, write to the Free Software - # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -%> - -<% parent = @folder ? @folder : @project %> -<% all_children_sorted(parent, @pos, @idnt).each do |obj, position| %> - <% classes = "dmsf_tree idnt-#{@idnt} hascontextmenu" %> - <% if obj.is_a?(DmsfFolder) && ((obj.dmsf_folders.visible.any?) || (obj.dmsf_files.visible.any?) || (obj.dmsf_links.visible.any?)) %> - <% classes += ' idnt dmsf_collapsed dmsf-not-loaded' %> - <% id = "id='#{obj.id}span'".html_safe %> - <% onclick = "onclick=\"dmsfToggle('#{obj.id}','#{obj.id}span','#{escape_javascript(expand_folder_dmsf_path)}')\"" %> - <% else %> - <% classes += ' dmsf_child' %> - <% onclick = '' %> - <% end %> - <% parent = obj.dmsf_folder %> - <% while parent %> - <% classes += " #{parent.id}" %> - <% parent = parent.dmsf_folder %> - <% end %> - - <% if obj.is_a? DmsfFolder %> - <% classes << ' dmsf_system' if obj.system %> - <% classes << ' dmsf_system_closed' if obj.issue && obj.issue.closed? %> - class="dir <%= classes %>"> - <%= render(:partial => 'dir', - :locals => { - :project => @project, - :subfolder => obj, - :link => nil, - :id => obj.id, - :name => 'folder', - :title => obj.title, - :onclick => onclick, - :position => position}) %> - - <% elsif obj.is_a?(DmsfLink) && (obj.target_type == 'DmsfFolder') %> - <% unless obj.target_project %> - <% Rails.logger.error "Error: dmsf_link id #{obj.id} has no target!" %> - <% next %> - <% end %> - class="dmsf_gray <%= classes %>"> - <%= render(:partial => 'dir', - :locals => { - :project => obj.target_project, - :subfolder => obj.target_folder, - :link => obj, - :id => obj.id, - :name => 'folder-link', - :title => obj.name, - :onclick => onclick, - :position => position}) %> - - <% elsif obj.is_a?(DmsfFile) %> - <% unless obj.last_revision %> - <% Rails.logger.error "Error: dmsf_file id #{obj.id} has no revision!" %> - <% next %> - <% end %> - class="file <%= classes %>"> - <%= render(:partial => 'file', :locals => { - :project => @project, - :file => obj, - :link => nil, - :id => obj.id, - :name => 'file', - :title => obj.title, - :onclick => onclick, - :position => position}) %> - - <% elsif obj.is_a?(DmsfLink) && (obj.target_type == 'DmsfFile') %> - <% unless obj.target_file && obj.target_file.last_revision %> - <% Rails.logger.error "Error: dmsf_file id #{obj.target_id} has no revision!" %> - <% next %> - <% end %> - class="dmsf_gray <%= classes %>"> - <%= render(:partial => 'file', :locals => { - :project => obj.target_project, - :file => obj.target_file, - :link => obj, - :id => obj.id, - :name => 'file-link', - :title => obj.name, - :onclick => onclick, - :position => position}) %> - - <% elsif obj.is_a?(DmsfLink) && (obj.target_type == 'DmsfUrl') %> - class="dmsf_gray <%= classes %>"> - <%= render(:partial => 'url', :locals => { - :project => obj.target_project, - :file => obj.target_file, - :link => obj, - :id => obj.id, - :name => 'url-link', - :title => obj.name, - :onclick => onclick, - :position => position}) %> - - <% end %> -<% end %> diff --git a/app/views/dmsf/_file.html.erb b/app/views/dmsf/_file.html.erb deleted file mode 100644 index 53d76511..00000000 --- a/app/views/dmsf/_file.html.erb +++ /dev/null @@ -1,91 +0,0 @@ -<% -# encode: utf-8 -# -# Redmine plugin for Document Management System "Features" -# -# Copyright © 2011-20 Karel Pičman -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -%> - -<% wf = DmsfWorkflow.find_by(id: file.last_revision.dmsf_workflow_id) if file.last_revision.dmsf_workflow_id %> - -<%= check_box_tag('ids[]', "#{name}-#{id}", false, :id => "file_#{id}") %> -<% if DmsfFolder.is_column_on?('id') %> - <%= link_to(file.id, dmsf_file_path(:id => file)) %> -<% end %> -<% if DmsfFolder.is_column_on?('title') %> - - <% if @tree_view %> - - <% end %> - <% file_view_url = url_for({:controller => :dmsf_files, :action => 'view', :id => file}) %> - <%= link_to(h(title), - file_view_url, - :target => '_blank', - :class => "icon icon-file #{DmsfHelper.filetype_css(file.name)}", - :title => h(file.last_revision.try(:tooltip)), - 'data-downloadurl' => "#{file.last_revision.detect_content_type}:#{h(file.name)}:#{file_view_url}") %> -
<%= h(link ? link.path : file.display_name) %>
- -<% end %> -<% if DmsfFolder.is_column_on?('extension') %> - - <%= file.extension %> - -<% end %> -<% if DmsfFolder.is_column_on?('size') %> - <%= number_to_human_size(file.last_revision.size) %> -<% end %> -<% if DmsfFolder.is_column_on?('modified') %> - - <%= format_time(file.last_revision.updated_at) %> - -<% end %> -<% if DmsfFolder.is_column_on?('version') %> - <%= file.last_revision.version %> -<% end %> -<% if DmsfFolder.is_column_on?('workflow') %> - - <% if wf && @file_approval_allowed %> - <%= link_to( - file.last_revision.workflow_str(false), - log_dmsf_workflow_path( - :project_id => project.id, - :id => wf.id, - :dmsf_file_revision_id => file.last_revision.id), - :title => file.last_revision.workflow_tooltip, - :remote => true) %> - <% else %> - <%= file.last_revision.workflow_str(false) %> - <% end %> - -<% end %> -<% if DmsfFolder.is_column_on?('author') %> - <%= h(file.last_revision.user) %> -<% end %> -<% DmsfFileRevisionCustomField.visible.order(:position).each do |c| %> - <% if DmsfFolder.is_column_on?(c.name) %> - - <%= show_value file.custom_value(c) %> - - <% end %> -<% end %> -<%= link_to_context_menu %> -<%= position %> -<%= file.last_revision.size %> -<%= file.last_revision.updated_at.to_i %> -<%= file.last_revision.iversion %> -<%= clear_title(title) %> diff --git a/app/views/dmsf/_file_trash.html.erb b/app/views/dmsf/_file_trash.html.erb deleted file mode 100644 index 355171b8..00000000 --- a/app/views/dmsf/_file_trash.html.erb +++ /dev/null @@ -1,71 +0,0 @@ -<% -# encoding: utf-8 -# -# Redmine plugin for Document Management System "Features" -# -# Copyright © 2011-20 Karel Pičman -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -%> - -<%= check_box_tag('ids[]', "#{name}-#{id}", false, :id => "file_#{id}") %> -<% if DmsfFolder.is_column_on?('id') %> - <%= file.id %> -<% end %> -<% if DmsfFolder.is_column_on?('title') %> - - <%= content_tag(:span, h(title), - :title => h(file.last_revision.try(:tooltip)), - :class => "icon icon-file #{DmsfHelper.filetype_css(file.name)}") %> -
<%= h(link ? link.path : file.display_name) %>
- -<% end %> -<% if DmsfFolder.is_column_on?('extension') %> - - <%= $1 if file.last_revision.disk_filename =~ /\.(.+)$/ %> - -<% end %> -<% if DmsfFolder.is_column_on?('size') %> - <%= number_to_human_size(file.last_revision.size) %> -<% end %> -<% if DmsfFolder.is_column_on?('modified') %> - - <%= format_time(file.last_revision.updated_at) %> - -<% end %> -<% if DmsfFolder.is_column_on?('version') %> - <%= file.last_revision.version %> -<% end %> -<% if DmsfFolder.is_column_on?('workflow') %> - - <%= file.last_revision.workflow_str(false) %> - -<% end %> -<% if DmsfFolder.is_column_on?('author') %> - <%= h(file.last_revision.user) %> -<% end %> -<% DmsfFileRevisionCustomField.visible.order(:position).each do |c| %> - <% if DmsfFolder.is_column_on?(c.name) %> - - <%= show_value file.custom_value(c) %> - - <% end %> -<% end %> -<%= link_to_context_menu %> -1 -<%= file.last_revision.size %> -<%= file.last_revision.updated_at.to_i %> -<%= file.last_revision.iversion %> -<%= clear_title(title) %> diff --git a/app/views/dmsf/_list_view.erb b/app/views/dmsf/_list_view.erb deleted file mode 100644 index b31b41be..00000000 --- a/app/views/dmsf/_list_view.erb +++ /dev/null @@ -1,149 +0,0 @@ -<% -# encoding: utf-8 -# -# Redmine plugin for Document Management System "Features" -# -# Copyright © 2011-20 Karel Pičman -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -%> - - - - - - <% if DmsfFolder.is_column_on?('id') %> - - <% end %> - <% if DmsfFolder.is_column_on?('title') %> - - <% end %> - <% if DmsfFolder.is_column_on?('extension') %> - - <% end %> - <% if DmsfFolder.is_column_on?('size') %> - - <% end %> - <% if DmsfFolder.is_column_on?('modified') %> - - <% end %> - <% if DmsfFolder.is_column_on?('version') %> - - <% end %> - <% if DmsfFolder.is_column_on?('workflow') %> - - <% end %> - <% if DmsfFolder.is_column_on?('author') %> - - <% end %> - <% DmsfFileRevisionCustomField.visible.order(:position).each do |c| %> - <% if DmsfFolder.is_column_on?(c.name) %> - - <% end %> - <% end %> - - - - - - - - - - <% classes = 'dir hascontextmenu' %> - <% @subfolders.each do |subfolder| %> - - <%= render(:partial => 'dir', - :locals => { - :project => @project, - :subfolder => subfolder, - :link => nil, - :id => subfolder.id, - :name => 'folder', - :title => subfolder.title, - :position => 0 }) %> - - <% end %> - <% classes = 'dmsf_gray hascontextmenu' %> - <% @dir_links.each do |link| %> - <% unless link.target_project %> - <% Rails.logger.error "Error: dmsf_link id #{link.id} has no target!" %> - <% next %> - <% end %> - - <%= render(:partial => 'dir', - :locals => { - :project => link.target_project, - :subfolder => link.target_folder, - :link => link, - :id => link.id, - :name => 'folder-link', - :title => link.name, - :position => 0}) %> - - <% end %> - <% classes = 'file hascontextmenu' %> - <% @files.each do |file| %> - <% unless file.last_revision %> - <% Rails.logger.error "Error: dmsf_file id #{file.id} has no revision!" %> - <% next %> - <% end %> - - <%= render(:partial => 'file', :locals => { - :project => @project, - :file => file, - :link => nil, - :id => file.id, - :name => 'file', - :title => file.title, - :position => 1 }) %> - - <% end %> - <% classes = 'dmsf_gray hascontextmenu' %> - <% @file_links.each do |link| %> - <% unless link.target_file && link.target_file.last_revision %> - <% Rails.logger.error "Error: dmsf_file id #{link.target_id} has no revision!" %> - <% next %> - <% end %> - - <%= render(:partial => 'file', :locals => { - :project => link.target_project, - :file => link.target_file, - :link => link, - :id => link.id, - :name => 'file-link', - :title => link.name, - :position => 1}) %> - - <% end %> - <% @url_links.each do |link| %> - - <%= render(:partial => 'url', :locals => { - :project => link.target_project, - :file => link.target_file, - :link => link, - :id => link.id, - :name => 'url-link', - :title => link.name, - :position => 1}) %> - - <% end %> - -
- <% unless @system_folder %> - <%= check_box_tag 'check_all', '', false, :class => 'toggle-selection', - :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %> - <% end %> - #<%= l(:link_title) %><%= l(:link_extension) %><%= l(:link_size) %><%= l(:link_modified) %><%= l(:link_ver) %><%= l(:link_workflow) %><%= l(:link_author) %><%= h(c.name) %><%# controls %><%# position %><%# size calculated %><%# modified calculated %><%# version calculated %><%# clear title %>
diff --git a/app/views/dmsf/_tree_view.erb b/app/views/dmsf/_tree_view.erb deleted file mode 100644 index f26b371e..00000000 --- a/app/views/dmsf/_tree_view.erb +++ /dev/null @@ -1,72 +0,0 @@ -<% -# encoding: utf-8 -# -# Redmine plugin for Document Management System "Features" -# -# Copyright © 2011-20 Karel Pičman -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -%> - - - - - - <% if DmsfFolder.is_column_on?('id') %> - - <% end %> - <% if DmsfFolder.is_column_on?('title') %> - - <% end %> - <% if DmsfFolder.is_column_on?('extension') %> - - <% end %> - <% if DmsfFolder.is_column_on?('size') %> - - <% end %> - <% if DmsfFolder.is_column_on?('modified') %> - - <% end %> - <% if DmsfFolder.is_column_on?('version') %> - - <% end %> - <% if DmsfFolder.is_column_on?('workflow') %> - - <% end %> - <% if DmsfFolder.is_column_on?('author') %> - - <% end %> - <% DmsfFileRevisionCustomField.visible.order(:position).each do |c| %> - <% if DmsfFolder.is_column_on?(c.name) %> - - <% end %> - <% end %> - - - - - - - - - - <%= render partial: 'dmsf/dmsf_rows' %> - -
- <% unless @system_folder %> - <%= check_box_tag 'check_all', '', false, :class => 'toggle-selection', - :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %> - <% end %> - #<%= l(:link_title) %><%= l(:link_extension) %><%= l(:link_size) %><%= l(:link_modified) %><%= l(:link_ver) %><%= l(:link_workflow) %><%= l(:link_author) %><%= c.name %><%# controls %><%# position %><%# size calculated %><%# modified calculated %><%# version calculated %><%# clear title %>
diff --git a/app/views/dmsf/_url.html.erb b/app/views/dmsf/_url.html.erb deleted file mode 100644 index 9f40e175..00000000 --- a/app/views/dmsf/_url.html.erb +++ /dev/null @@ -1,73 +0,0 @@ -<% -# encoding: utf-8 -# -# Redmine plugin for Document Management System "Features" -# -# Copyright © 2011-20 Karel Pičman -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -%> - -<%= check_box_tag('ids[]', "#{name}-#{id}", false) %> -<% if DmsfFolder.is_column_on?('id') %> - -<% end %> -<% if DmsfFolder.is_column_on?('title') %> - - <% if @tree_view %> - > - <% end %> - <%= link_to(h(title), - link.external_url, - :target => '_blank', - :class => 'icon icon-link') %> -
- <% if link.external_url && link.external_url.length > 50 %> - <%= "#{link.external_url[0, 25]}...#{link.external_url[-25, 25]}" %> - <% else %> - <%= link.external_url %> - <% end %> -
- -<% end %> -<% if DmsfFolder.is_column_on?('extension') %> - -<% end %> -<% if DmsfFolder.is_column_on?('size') %> - -<% end %> -<% if DmsfFolder.is_column_on?('modified') %> - <%= format_time(link.updated_at) %> -<% end %> -<% if DmsfFolder.is_column_on?('version') %> - -<% end %> -<% if DmsfFolder.is_column_on?('workflow') %> - -<% end %> -<% if DmsfFolder.is_column_on?('author') %> - <%= h(link.user) %> -<% end %> -<% DmsfFileRevisionCustomField.visible.order(:position).each do |c| %> - <% if DmsfFolder.is_column_on?(c.name) %> - - <% end %> -<% end %> -<%= link_to_context_menu %> -<%= position %> - -link.updated_at.to_i - -<%= clear_title(title) %> diff --git a/app/views/dmsf/_url_trash.html.erb b/app/views/dmsf/_url_trash.html.erb deleted file mode 100644 index 94554a64..00000000 --- a/app/views/dmsf/_url_trash.html.erb +++ /dev/null @@ -1,70 +0,0 @@ -<% -# encoding: utf-8 -# -# Redmine plugin for Document Management System "Features" -# -# Copyright © 2011-20 Karel Pičman -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -%> - -<%= check_box_tag('ids[]', "#{name}-#{id}", false) %> -<% if DmsfFolder.is_column_on?('id') %> - -<% end %> -<% if DmsfFolder.is_column_on?('title') %> - - <%= link_to(h(title), - link.external_url, - :target => '_blank', - :class => 'icon icon-link') %> -
- <% if link.external_url && link.external_url.length > 50 %> - <%= "#{link.external_url[0, 25]}...#{link.external_url[-25, 25]}" %> - <% else %> - <%= link.external_url %> - <% end %> -
- -<% end %> -<% if DmsfFolder.is_column_on?('extension') %> - -<% end %> -<% if DmsfFolder.is_column_on?('size') %> - -<% end %> -<% if DmsfFolder.is_column_on?('modified') %> - <%= format_time(link.updated_at) %> -<% end %> -<% if DmsfFolder.is_column_on?('version') %> - -<% end %> -<% if DmsfFolder.is_column_on?('workflow') %> - -<% end %> -<% if DmsfFolder.is_column_on?('author') %> - <%= h(link.user) %> -<% end %> -<% DmsfFileRevisionCustomField.visible.order(:position).each do |c| %> - <% if DmsfFolder.is_column_on?(c.name) %> - - <% end %> -<% end %> -<%= link_to_context_menu %> -1 - -<%= link.updated_at.to_i %> - -<%= clear_title(title) %> diff --git a/app/views/dmsf/dmsf_rows.js.erb b/app/views/dmsf/dmsf_rows.js.erb deleted file mode 100644 index e047737f..00000000 --- a/app/views/dmsf/dmsf_rows.js.erb +++ /dev/null @@ -1,79 +0,0 @@ -// Store DMSF controls -var dmsfButtons = $('#dmsf_buttons')[0].outerHTML; -var browserInfo = $('#browser_info').text(); -var tag = $('#dmsf_tag'); -var dmsfTag; -var browser = $("#browser"); - -if((tag != null) && tag[0] != null) { - - dmsfTag = tag[0].outerHTML -} - -// Destroy the original dataTable -browser.dataTable().fnDestroy(); - -// Add rows -$('#<%= params[:row_id] %>').after('<%= escape_javascript(render(:partial => 'dmsf/dmsf_rows')) %>'); -hideOnLoad(); -$('#dmsf_uploader').hide(); -$('#dmsf_uploader_header').hide(); -$("#dmsf_ajax_loading").show(); - -// Reinitialize the dataTable -<% title = DmsfFolder.get_column_position('title') %> -<% position = DmsfFolder.get_column_position('position') %> -<% commands = DmsfFolder.get_column_position('commands') %> -<% position = DmsfFolder.get_column_position('position') %> -<% version = DmsfFolder.get_column_position('version') %> -<% size_calculated = DmsfFolder.get_column_position('size_calculated') %> -<% modified_calculated = DmsfFolder.get_column_position('modified_calculated') %> -<% version_calculated = DmsfFolder.get_column_position('version_calculated') %> -<% size = DmsfFolder.get_column_position('size') %> -<% modified = DmsfFolder.get_column_position('modified') %> - -browser.dataTable({ - orderClasses: false, - responsive: { - details: false - }, - language: { - url: "<%= plugin_asset_path(:redmine_dmsf, 'javascripts', json_url) %>" - }, - autoWidth: false, - paginate: false, - <% if title %> - order: [[<%= title %>, "asc"]], - <% end %> - sortingFixed: [[ <%= position %>, "asc"]], - columnDefs: [ - { searchable: false, targets: [0, <%= commands %>, <%= position %>, <%= size_calculated %>, <%= modified_calculated %>, <%= version_calculated %>] }, - { sortable: false, targets: [0, <%= commands %>] } - <% if size %> - ,{ iDataSort: <%= size_calculated %>, targets: [ <%= size %> ] } - <% end %> - <% if modified %> - ,{ iDataSort: <%= modified_calculated %>, targets: [ <%= modified %> ] } - <% end %> - <% if version %> - ,{ iDataSort: <%= version_calculated %>, targets: [ <%= version %> ] } - <% end %> - ], - "fnInitComplete": function() { - var wrapper = $("#browser_wrapper div.fg-toolbar")[0]; - $(dmsfButtons).prependTo(wrapper); - if($(dmsfTag) != null) { - $(dmsfTag).prependTo(wrapper); - } - $("#browser").show(); - $('#dmsf_uploader').show(); - $('#dmsf_uploader_header').show(); - $("#dmsf_ajax_loading").hide(); - }, - "fnInfoCallback": function( oSettings, iStart, iEnd, iMax, iTotal, sPre ) { - return browserInfo; - } -}); - -// Hot fix -browser.attr('style', 'width: 100%'); diff --git a/app/views/dmsf/show.html.erb b/app/views/dmsf/show.html.erb index 36c117b1..af630e81 100644 --- a/app/views/dmsf/show.html.erb +++ b/app/views/dmsf/show.html.erb @@ -24,10 +24,7 @@ <% html_title l(:dmsf) %>
- <%= link_to(l(:button_switch), switch_rlf_dmsf_path(id: @project, rlf: @rlf), - title: l(:label_switch_rlf), - class: 'icon icon-plugins') %> - <% if @rlf && @file_manipulation_allowed && !@locked_for_user && !@system_folder %> + <% if @file_manipulation_allowed && !@locked_for_user && !@system_folder %> <%= link_to l(:label_attachment_new), multi_dmsf_upload_path(id: @project, dmsf_folder_id: @folder), class: 'icon icon-add' %> <% end %> @@ -94,156 +91,14 @@
-<% if @query %> - <%= form_tag(dmsf_folder_path(d: @project, folder_id: @folder), method: :get, id: 'query_form') do %> - <%= render partial: 'queries/query_form' %> - <% end %> - <%= render partial: 'query_list', locals: { query: @query } %> - <%= pagination_links_full @dmsf_pages, @dmsf_count %> -<% else %> -
- <%= form_tag(entries_operations_dmsf_path(id: @project, folder_id: @folder), method: :post, - class: 'dmsf_entries', id: 'entries_form', data: { cm_url: dmsf_context_menu_path }) do %> - <%= hidden_field_tag('action') %> - <% unless @system_folder %> -
- <%= submit_tag(l(:button_download), title: l(:title_download_checked), name: 'download_entries', - class: 'toggle-selection', data: { disable_with: false }) if @file_view_allowed %> - <%= submit_tag(l(:field_mail), title: l(:title_send_checked_by_email), name: 'email_entries', class: 'toggle-selection', - data: { disable_with: false }) if (@file_view_allowed && User.current.allowed_to?(:email_documents, @project)) %> - <% if @file_delete_allowed %> - <%= submit_tag(l(:button_delete), title: l(:title_delete_checked), name: 'delete_entries', class: 'toggle-selection', - data: { confirm: l(:text_are_you_sure), disable_with: false }) if @file_delete_allowed %> - <% end %> -
- <% end %> - <% unless @system_folder %> - <% values = @folder ? @folder.custom_field_values : DmsfFolder.new.custom_field_values %> - <% unless values.empty? %> - <% values.sort! { |a, b| a.custom_field.position <=> b.custom_field.position } %> - <% custom_value = values.first %> - <% if custom_value.custom_field.format.is_a?(Redmine::FieldFormat::ListFormat) %> -
- <% custom_value.custom_field.is_required = false %> - <% custom_value.value = params[:custom_value].present? ? params[:custom_value] : '' %> - <%= h(custom_value.custom_field.name) %>: - <%= custom_value.custom_field.format.edit_tag(self, - custom_field_tag_id(:dmsf_folder, custom_value.custom_field), - custom_field_tag_name(:dmsf_folder, custom_value.custom_field), - custom_value, - :class => "#{custom_value.custom_field.field_format}_cf", - :style => 'width: auto') %> -
- <% end %> - <% end %> - <% end %> - <% if @tree_view %> - <%= render(:partial => 'tree_view') %> - <% else %> - <%= render(:partial => 'list_view') %> - <% end %> - <% end %> - - <% content_for :header_tags do %> - <%= stylesheet_link_tag 'jquery.dataTables/datatables.min.css', :plugin => :redmine_dmsf %> - <%= javascript_include_tag 'jquery.dataTables/datatables.min.js', :plugin => :redmine_dmsf, defer: true %> - - <% title = DmsfFolder.get_column_position('title') %> - <% position = DmsfFolder.get_column_position('position') %> - <% commands = DmsfFolder.get_column_position('commands') %> - <% position = DmsfFolder.get_column_position('position') %> - <% version = DmsfFolder.get_column_position('version') %> - <% size_calculated = DmsfFolder.get_column_position('size_calculated') %> - <% modified_calculated = DmsfFolder.get_column_position('modified_calculated') %> - <% version_calculated = DmsfFolder.get_column_position('version_calculated') %> - <% size = DmsfFolder.get_column_position('size') %> - <% modified = DmsfFolder.get_column_position('modified') %> - <% clear_title = DmsfFolder.get_column_position('clear_title') %> - - <%= late_javascript_tag do %> - $("#browser").dataTable({ - orderClasses: false, - responsive: { - details: false - }, - language: { - url: "<%= plugin_asset_path(:redmine_dmsf, 'javascripts', json_url) %>" - }, - oLanguage: { - sSearch: "<%= l(:description_filter) %>:" - }, - autoWidth: false, - paginate: false, - <% if title %> - order: [[<%= title %>, "asc"]], - <% end %> - sortingFixed: [[ <%= position %>, "asc"]], - columnDefs: [ - { responsivePriority: 1, targets: <%= title %> }, - { responsivePriority: 2, targets: <%= commands %> }, - { searchable: false, targets: [0, <%= commands %>, <%= position %>, <%= size_calculated %>, <%= modified_calculated %>, <%= version_calculated %>, <%= clear_title %>] }, - { sortable: false, targets: [0, <%= commands %>] } - <% if title %> - ,{ iDataSort: <%= clear_title %>, targets: [ <%= title %> ] } - <% end %> - <% if size %> - ,{ iDataSort: <%= size_calculated %>, targets: [ <%= size %> ] } - <% end %> - <% if modified %> - ,{ iDataSort: <%= modified_calculated %>, targets: [ <%= modified %> ] } - <% end %> - <% if version %> - ,{ iDataSort: <%= version_calculated %>, targets: [ <%= version %> ] } - <% end %> - ], - "fnInitComplete": function() { - var browserFilter = $("#browser_filter"); - $("#dmsf_buttons").insertBefore(browserFilter); - $("#dmsf_tag").insertBefore(browserFilter); - $("#dmsf_ajax_loading").hide(); - $("#browser").show(); - $("#dmsf_buttons").show(); - $("#dmsf_tag").show(); - $("#dmsf_uploader").show(); - $("#dmsf_uploader_header").show(); - }, - "fnInfoCallback": function( oSettings, iStart, iEnd, iMax, iTotal, sPre ) { - <% folder_id = @folder ? @folder.id : nil %> - return "<%= "#{l(:label_number_of_folders)}: #{DmsfFolder.visible.where(project_id: @project.id, dmsf_folder_id: folder_id).all.size + DmsfLink.visible.where(project_id: @project.id, dmsf_folder_id: folder_id, target_type: 'DmsfFolder').all.size}, #{l(:label_number_of_documents)}: #{DmsfFile.visible.where(project_id: @project.id, dmsf_folder_id: folder_id).all.size + DmsfLink.visible.where(project_id: @project.id, dmsf_folder_id: folder_id, target_type: %w(DmsfFile DmsfUrl)).all.size}" %>"; - } - }); - - $("[data-downloadurl]").each(function() { - var url = this.getAttribute("data-downloadurl"); - if (this.addEventListener) { - this.addEventListener("dragstart", function(e) { - if (e.dataTransfer) { - e.dataTransfer.setData("DownloadURL", url); - } - },false); - } - }); - - var entriesForm = $('#entries_form'); - - entriesForm.submit(function () { - $(this).removeAttr("data-submitted"); - }); - - $('.list_cf').change(function() { - entriesForm.attr('action', "<%= tag_changed_path(:id => @project, :folder_id => @folder) %>"); - entriesForm.submit(); - }); - <% end %> - <% end %> +<%= form_tag(dmsf_folder_path(d: @project, folder_id: @folder), method: :get, id: 'query_form') do %> + <%= render partial: 'queries/query_form' %> <% end %> +<%= render partial: 'query_list', locals: { query: @query } %> +<%= pagination_links_full @dmsf_pages, @dmsf_count %> <%= context_menu %> -<% if !@rlf && @file_manipulation_allowed && !@locked_for_user && !@system_folder %> - <%= render(:partial => 'dmsf_upload/multi_upload', locals: { rlf: @rlf }) %> -<% end %> - <% unless (@folder && @folder.system) %> <% other_formats_links do |f| %> <%= f.link_to 'CSV', onclick: "showModal('dmsf_csv_export_options', '350px'); return false;" %> @@ -264,4 +119,4 @@ <%= submit_tag l(:button_cancel), name: nil, onclick: "hideModal(this);", type: 'button' %>

<% end %> - \ No newline at end of file + diff --git a/app/views/dmsf/trash.html.erb b/app/views/dmsf/trash.html.erb index 97174ea8..84d68443 100644 --- a/app/views/dmsf/trash.html.erb +++ b/app/views/dmsf/trash.html.erb @@ -20,227 +20,20 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. %> -<% html_title(l(:dmsf)) %> +<% html_title l(:dmsf) %>

<%= l(:link_trash_bin) %>

- <%= textilizable(@project.dmsf_description) %> + <%= textilizable @project.dmsf_description %>
-<% if @query %> - <%= form_tag(trash_dmsf_path(id: @project), method: :get, id: 'query_form') do %> - <%= render partial: 'queries/query_form' %> - <% end %> - <%= render partial: 'query_list', locals: { query: @query } %> - <%= pagination_links_full @dmsf_pages, @dmsf_count %> -<% else %> -
- <%= form_tag(entries_operations_dmsf_path(:id => @project, :folder_id => @folder), :method => :post, - :class => 'dmsf_entries', :id => 'entries_form', :data => {:cm_url => dmsf_trash_context_menu_path}) do %> - <%= hidden_field_tag('action') %> -
- <% if @file_manipulation_allowed && @folder_manipulation_allowed %> - <%= submit_tag l(:title_restore), :title => l(:title_restore_checked), :name => 'restore_entries', - :class => 'toggle-selection' %> - <% if @file_delete_allowed%> - <%= submit_tag l(:button_delete), :title => l(:title_delete_checked), :name => 'destroy_entries', - :class => 'toggle-selection', :data => { :confirm => l(:text_are_you_sure) } %> - <% end %> - <% end %> -
- - - - - <% if DmsfFolder.is_column_on?('id') %> - - <% end %> - <% if DmsfFolder.is_column_on?('title') %> - - <% end %> - <% if DmsfFolder.is_column_on?('extension') %> - - <% end %> - <% if DmsfFolder.is_column_on?('size') %> - - <% end %> - <% if DmsfFolder.is_column_on?('modified') %> - - <% end %> - <% if DmsfFolder.is_column_on?('version') %> - - <% end %> - <% if DmsfFolder.is_column_on?('workflow') %> - - <% end %> - <% if DmsfFolder.is_column_on?('author') %> - - <% end %> - <% DmsfFileRevisionCustomField.visible.order(:position).each do |c| %> - <% if DmsfFolder.is_column_on?(c.name) %> - - <% end %> - <% end %> - - - - - - - - - - <% classes = 'dir hascontextmenu' %> - <% @subfolders.each do |subfolder| %> - - <%= render(:partial => 'dir_trash', - :locals => { - :project => @project, - :subfolder => subfolder, - :link => nil, - :id => subfolder.id, - :name => 'folder', - :title => subfolder.title }) %> - - <% end %> - <% classes = 'dmsf_gray hascontextmenu' %> - <% @dir_links.each do |link| %> - - <%= render(:partial => 'dir_trash', - :locals => { - :project => link.target_project, - :subfolder => link.target_folder, - :link => link, - :id => link.id, - :name => 'folder-link', - :title => link.name }) %> - - <% end %> - <% classes = 'file hascontextmenu' %> - <% @files.each do |file| %> - <% unless file.last_revision %> - <% Rails.logger.error "Error: dmsf_file id #{file.id} has no revision!" %> - <% next %> - <% end %> - - <%= render(:partial => 'file_trash', :locals => { - :project => @project, - :file => file, - :link => nil, - :id => file.id, - :name => 'file', - :title => file.title }) %> - - <% end %> - <% classes = 'dmsf_gray hascontextmenu' %> - <% @file_links.each do |link| %> - <% unless link.target_file %> - <% Rails.logger.error "Error: dmsf_link id #{link.id} has no target file!" %> - <% next %> - <% end %> - <% unless link.target_file.last_revision %> - <% Rails.logger.error "Error: dmsf_file id #{link.target_id} has no revision!" %> - <% next %> - <% end %> - - <%= render(:partial => 'file_trash', :locals => { - :project => link.target_project, - :file => link.target_file, - :link => link, - :id => link.id, - :name => 'file-link', - :title => link.name }) %> - - <% end %> - <% @url_links.each do |link| %> - - <%= render(:partial => 'url_trash', :locals => { - :project => link.target_project, - :file => link.target_file, - :link => link, - :id => link.id, - :name => 'url-link', - :title => link.name }) %> - - <% end %> - -
- <%= check_box_tag 'check_all', '', false, :class => 'toggle-selection', - :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %> - #<%= l(:link_title) %><%= l(:link_extension) %><%= l(:link_size) %><%= l(:link_modified) %><%= l(:link_ver) %><%= l(:link_workflow) %><%= l(:link_author) %><%= h(c.name) %><%# controls %><%# position %><%# size calculated %><%# modified calculated %><%# version calculated %><%# clear title %>
- <% end %> - - <% content_for :header_tags do %> - <%= stylesheet_link_tag 'jquery.dataTables/datatables.min.css', :plugin => :redmine_dmsf %> - <%= javascript_include_tag 'jquery.dataTables/datatables.min.js', :plugin => :redmine_dmsf, defer: true %> - - <% title = DmsfFolder.get_column_position('title') %> - <% position = DmsfFolder.get_column_position('position') %> - <% commands = DmsfFolder.get_column_position('commands') %> - <% position = DmsfFolder.get_column_position('position') %> - <% version = DmsfFolder.get_column_position('version') %> - <% size_calculated = DmsfFolder.get_column_position('size_calculated') %> - <% modified_calculated = DmsfFolder.get_column_position('modified_calculated') %> - <% version_calculated = DmsfFolder.get_column_position('version_calculated') %> - <% size = DmsfFolder.get_column_position('size') %> - <% modified = DmsfFolder.get_column_position('modified') %> - <% clear_title = DmsfFolder.get_column_position('clear_title') %> - - <%= late_javascript_tag do %> - $('#browser').dataTable({ - orderClasses: false, - responsive: { - details: false - }, - language: { - url: "<%= plugin_asset_path(:redmine_dmsf, 'javascripts', json_url) %>" - }, - oLanguage: { - sSearch: "<%= l(:description_filter) %>:" - }, - autoWidth: false, - paginate: false, - <% if title %> - order: [[<%= title %>, "asc"]], - <% end %> - sortingFixed: [[ <%= position %>, "asc"]], - columnDefs: [ - { responsivePriority: 1, targets: <%= title %> }, - { responsivePriority: 2, targets: <%= commands %> }, - { searchable: false, targets: [0, <%= commands %>, <%= position %>, <%= size_calculated %>, <%= modified_calculated %>, <%= version_calculated %>, <%= clear_title %>] }, - { sortable: false, targets: [0, <%= commands %>] } - <% if title %> - ,{ iDataSort: <%= clear_title %>, targets: [ <%= title %> ] } - <% end %> - <% if size %> - ,{ iDataSort: <%= size_calculated %>, targets: [ <%= size %> ] } - <% end %> - <% if modified %> - ,{ iDataSort: <%= modified_calculated %>, targets: [ <%= modified %> ] } - <% end %> - <% if version %> - ,{ iDataSort: <%= version_calculated %>, targets: [ <%= version %> ] } - <% end %> - ], - "fnInitComplete": function() { - $("#dmsf_buttons").insertBefore($("#browser_filter")); - $("#dmsf_ajax_loading").hide(); - $("#browser").show(); - $("#dmsf_buttons").show(); - }, - "fnInfoCallback": function( oSettings, iStart, iEnd, iMax, iTotal, sPre ) { - return "<%= l(:label_number_of_folders)%>: <%= @subfolders.count + @dir_links.count %>, <%= l(:label_number_of_documents)%>: <%= @files.count + @file_links.count + @url_links.count %>"; - } - }); - - $("#entries_form").submit(function () { - $(this).removeAttr("data-submitted"); - }); - <% end %> - <% end %> +<%= form_tag(trash_dmsf_path(id: @project), method: :get, id: 'query_form') do %> + <%= render partial: 'queries/query_form' %> <% end %> +<%= render partial: 'query_list', locals: { query: @query } %> +<%= pagination_links_full @dmsf_pages, @dmsf_count %> <%= context_menu %> diff --git a/app/views/dmsf_files/_revision_access.html.erb b/app/views/dmsf_files/_revision_access.html.erb index e225fb01..ceb78861 100644 --- a/app/views/dmsf_files/_revision_access.html.erb +++ b/app/views/dmsf_files/_revision_access.html.erb @@ -22,49 +22,26 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. %> -<% if query %> - <% query_options = nil unless defined?(query_options) %> - <% query_options ||= {} %> -
- - - - <% query.inline_columns.each do |column| %> - <%= column_header(query, column, query_options) %> - <% end %> - - - - <% query.accesses.each do |access| %> - - <% query.inline_columns.each do |column| %> - <%= content_tag('td', column_content(column, access), class: column.css_classes) %> - <% end %> - - <% end %> - -
-
- <%= pagination_links_full revision_access_pages, revision_access_count %> -<% else %> - +<% query_options = nil unless defined?(query_options) %> +<% query_options ||= {} %> +
+
- - - - - - + + <% query.inline_columns.each do |column| %> + <%= column_header(query, column, query_options) %> + <% end %> + - <% DmsfFileRevisionAccess.access_grouped.where(dmsf_file_revision_id: revision.id).each do |access| %> - - - - - - - <% end %> + <% query.accesses.each do |access| %> + + <% query.inline_columns.each do |column| %> + <%= content_tag('td', column_content(column, access), class: column.css_classes) %> + <% end %> + + <% end %>
<%= l(:field_user) %><%= l(:heading_access_downloads_emails) %><%= l(:heading_access_first) %><%= l(:heading_access_last) %>
<%= link_to_user(access.user) %><%= access.count %><%= format_time(access.first_at) %><%= format_time(access.last_at) %>
-<% end %> + +<%= pagination_links_full revision_access_pages, revision_access_count %> diff --git a/app/views/dmsf_upload/_form.html.erb b/app/views/dmsf_upload/_form.html.erb index b6dc194d..3b3a6c85 100644 --- a/app/views/dmsf_upload/_form.html.erb +++ b/app/views/dmsf_upload/_form.html.erb @@ -32,12 +32,12 @@ :method => 'delete', :remote => true, :class => 'remove-upload icon-only icon-del') %> <% wf = container.saved_dmsf_attachments_wfs[attachment.id] %> <% if wf %> - + <%= hidden_field_tag("dmsf_attachments_wfs[p#{i}]", wf.id) if wf %> <% else %> <%= link_to('', assign_dmsf_workflow_path(:id => container.project.id, :project_id => container.project.id, :attachment_id => i + 1), :title => l(:label_dmsf_wokflow_action_assign), - :remote => true, :class => 'modify-upload icon-only icon-wf-none') %> + :remote => true, :class => 'modify-upload icon-only icon-ok') %> <% end %> <% end %> @@ -54,7 +54,7 @@ :method => 'delete', :remote => true, :class => 'remove-upload icon-only icon-del') %> <% wf = container.saved_dmsf_links_wfs[dmsf_link.id] %> <% if wf %> - + <%= hidden_field_tag("dmsf_links_wfs[#{dmsf_link.id}]", wf.id) if wf %> <% else %> <%= render(:partial => 'dmsf_workflows/approval_workflow_button', diff --git a/app/views/dmsf_upload/_multi_upload.html.erb b/app/views/dmsf_upload/_multi_upload.html.erb deleted file mode 100644 index 8822180f..00000000 --- a/app/views/dmsf_upload/_multi_upload.html.erb +++ /dev/null @@ -1,100 +0,0 @@ -<% -# encoding: utf-8 -# -# Redmine plugin for Document Management System "Features" -# -# Copyright © 2011 Vít Jonáš -# Copyright © 2012 Daniel Munn -# Copyright © 2011-20 Karel Pičman -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -%> - -
- <% unless @rlf %> -
- -
- <% end %> - -

<%= l(:button_add) %>

- -
-<%= form_tag({ controller: 'dmsf_upload', action: 'upload_files', id: @project, folder_id: @folder }, - id: 'uploadform', method: :post, multipart: true) do %> -
- - <%= render partial: 'dmsf_upload/form', - locals: { multiple: true, container: nil, description: true, awf: false } %> - - <%= submit_tag l(:label_upload) %> -
-<% end %> - -<% if rlf %> - <%= late_javascript_tag do %> - $("#dmsf_uploader").show(); - $("#dmsf_uploader_header").show(); - <% end %> -<% else %> - <% - form_url = url_for({:controller => 'dmsf_upload', :action => 'upload_file', :id => @project}) - max_file_size = "#{@ajax_upload_size}mb" - max_file_count = Setting.plugin_redmine_dmsf['dmsf_max_file_upload'].to_i if Setting.plugin_redmine_dmsf['dmsf_max_file_upload'].to_i > 0 - flash_url = plugin_asset_path(:redmine_dmsf, 'javascripts', 'plupload/js/Moxie.swf') - %> - - <%= late_javascript_tag do %> - var originalUploaderContent; - var uploader = $('#dmsf_uploader'); - originalUploaderContent = uploader.html(); - $('#uploader_select').change(function() { - if($(this).val() === '2') { - uploader.html(originalUploaderContent); - dmsfSetupFileDrop(); - } else { - initPlUploader( - uploader, - '<%= form_url %>', - '<%= max_file_size %>', - '<%= max_file_count %>', - '<%= flash_url %>' - ); - } - }); - initPlUploader( - uploader, - '<%= form_url %>', - '<%= max_file_size %>', - '<%= max_file_count %>', - '<%= flash_url %>' - ); - window.dmsfFileFieldCount = 1; - <% end %> - - <% content_for :header_tags do %> - <%= stylesheet_link_tag 'plupload/jquery.ui.plupload.css', :plugin => :redmine_dmsf %> - <%= javascript_include_tag 'plupload/js/plupload.full.min.js', :plugin => :redmine_dmsf, defer: true %> - <%= javascript_include_tag 'plupload/js/jquery.ui.plupload/jquery.ui.plupload.js', :plugin => :redmine_dmsf, defer: true %> - <%= javascript_include_tag(js_url, :plugin => :redmine_dmsf, defer: true) %> - <% end %> -<% end %> diff --git a/app/views/dmsf_workflows/_approval_workflow_button.html.erb b/app/views/dmsf_workflows/_approval_workflow_button.html.erb index 57193040..a4a890f5 100644 --- a/app/views/dmsf_workflows/_approval_workflow_button.html.erb +++ b/app/views/dmsf_workflows/_approval_workflow_button.html.erb @@ -35,7 +35,7 @@ :dmsf_file_revision_id => file.last_revision.id), :title => l(:title_waiting_for_approval), :remote => true, - :class => 'icon-only icon-wf-waiting') %> + :class => 'icon-only icon-ok') %> <% else %> <% end %> @@ -49,7 +49,7 @@ :id => file.last_revision.dmsf_workflow_id, :dmsf_file_revision_id => file.last_revision.id), :title => l(:label_dmsf_wokflow_action_start), - :class => 'icon-only icon-wf-assigned') %> + :class => 'icon-only icon-ok') %> <% else %> <% end %> @@ -69,7 +69,7 @@ :dmsf_file_revision_id => file.last_revision.id), :title => l(:label_dmsf_wokflow_action_assign), :remote => true, - :class => 'icon-only icon-wf-none') %> + :class => 'icon-only icon-ok') %> <% else %> <% end %> diff --git a/app/views/dmsf_workflows/assignment.js.erb b/app/views/dmsf_workflows/assignment.js.erb index aca94d5f..1d16e3ec 100644 --- a/app/views/dmsf_workflows/assignment.js.erb +++ b/app/views/dmsf_workflows/assignment.js.erb @@ -38,8 +38,7 @@ var span = input.parent(); ""); <% end %> -var a = span.children("a.icon-wf-none"); +var a = span.children("a.icon-ok"); -a.attr("class", "icon icon-wf-assigned"); a.attr("href", "javascript:void(0);"); a.attr("title", "<%= l(:title_assigned) %>"); diff --git a/app/views/settings/_dmsf_settings.html.erb b/app/views/settings/_dmsf_settings.html.erb index b061d238..f33a285c 100644 --- a/app/views/settings/_dmsf_settings.html.erb +++ b/app/views/settings/_dmsf_settings.html.erb @@ -26,14 +26,6 @@ <%= l(:label_general) %> -

- <%= content_tag(:label, l(:label_maximum_files_upload)) %> - <%= text_field_tag 'settings[dmsf_max_file_upload]', @settings['dmsf_max_file_upload'], :size => 10 %> - - <%= l(:note_maximum_number_of_files_uploaded) %> <%= l(:label_default) %>: 0 - -

-

<%= content_tag(:label, l(:label_maximum_files_download)) %> <%= text_field_tag 'settings[dmsf_max_file_download]', @settings['dmsf_max_file_download'], :size => 10 %> @@ -50,14 +42,6 @@

-

- <%= content_tag(:label, l(:label_maximum_ajax_upload_filesize)) %> - <%= text_field_tag 'settings[dmsf_max_ajax_upload_filesize]', @settings['dmsf_max_ajax_upload_filesize'], :size => 10 %> - - <%= l(:note_maximum_ajax_upload_filesize) %> <%= l(:label_default) %>: 100 - -

-

<%= content_tag(:label, l(:label_file_storage_directory)) %> <% diff --git a/assets/javascripts/attachments_dmsf.js b/assets/javascripts/attachments_dmsf.js index 810e4efc..6bd8a050 100644 --- a/assets/javascripts/attachments_dmsf.js +++ b/assets/javascripts/attachments_dmsf.js @@ -36,7 +36,7 @@ function dmsfAddLink(linksSpan, linkId, linkName, title, project, awf) { if(awf) { var iconWf = $('').attr({href: "/dmsf_workflows/" + project + "/assign?dmsf_link_id=" + linkId, - 'class': 'modify-upload icon-only icon-wf-none', 'data-remote': 'true', 'title': title}); + 'class': 'modify-upload icon-only icon-ok', 'data-remote': 'true', 'title': title}); linkSpan.append(iconWf); } @@ -78,7 +78,7 @@ function dmsfAddFile(inputEl, file, eagerUpload) { if($(inputEl).data('awf')) { var iconWf = $('').attr({href: '/dmsf_workflows/' + $(inputEl).attr( - 'data-project') + "/assign?attachment_id=" + attachmentId, 'class': 'modify-upload icon-only icon-wf-none', + 'data-project') + "/assign?attachment_id=" + attachmentId, 'class': 'modify-upload icon-only icon-ok', 'data-remote': 'true'}); fileSpan.append(iconWf); diff --git a/assets/javascripts/jquery.dataTables/datatables.min.js b/assets/javascripts/jquery.dataTables/datatables.min.js deleted file mode 100644 index b6bccbe4..00000000 --- a/assets/javascripts/jquery.dataTables/datatables.min.js +++ /dev/null @@ -1,231 +0,0 @@ -/* - * This combined file was created by the DataTables downloader builder: - * https://datatables.net/download - * - * To rebuild or modify this file with the latest versions of the included - * software please visit: - * https://datatables.net/download/#ju/dt-1.10.18/r-2.2.2 - * - * Included libraries: - * DataTables 1.10.18, Responsive 2.2.2 - */ - -/*! - DataTables 1.10.18 - ©2008-2018 SpryMedia Ltd - datatables.net/license -*/ -(function(h){"function"===typeof define&&define.amd?define(["jquery"],function(E){return h(E,window,document)}):"object"===typeof exports?module.exports=function(E,H){E||(E=window);H||(H="undefined"!==typeof window?require("jquery"):require("jquery")(E));return h(H,E,E.document)}:h(jQuery,window,document)})(function(h,E,H,k){function Z(a){var b,c,d={};h.each(a,function(e){if((b=e.match(/^([^A-Z]+?)([A-Z])/))&&-1!=="a aa ai ao as b fn i m o s ".indexOf(b[1]+" "))c=e.replace(b[0],b[2].toLowerCase()), -d[c]=e,"o"===b[1]&&Z(a[e])});a._hungarianMap=d}function J(a,b,c){a._hungarianMap||Z(a);var d;h.each(b,function(e){d=a._hungarianMap[e];if(d!==k&&(c||b[d]===k))"o"===d.charAt(0)?(b[d]||(b[d]={}),h.extend(!0,b[d],b[e]),J(a[d],b[d],c)):b[d]=b[e]})}function Ca(a){var b=n.defaults.oLanguage,c=b.sDecimal;c&&Da(c);if(a){var d=a.sZeroRecords;!a.sEmptyTable&&(d&&"No data available in table"===b.sEmptyTable)&&F(a,a,"sZeroRecords","sEmptyTable");!a.sLoadingRecords&&(d&&"Loading..."===b.sLoadingRecords)&&F(a, -a,"sZeroRecords","sLoadingRecords");a.sInfoThousands&&(a.sThousands=a.sInfoThousands);(a=a.sDecimal)&&c!==a&&Da(a)}}function eb(a){A(a,"ordering","bSort");A(a,"orderMulti","bSortMulti");A(a,"orderClasses","bSortClasses");A(a,"orderCellsTop","bSortCellsTop");A(a,"order","aaSorting");A(a,"orderFixed","aaSortingFixed");A(a,"paging","bPaginate");A(a,"pagingType","sPaginationType");A(a,"pageLength","iDisplayLength");A(a,"searching","bFilter");"boolean"===typeof a.sScrollX&&(a.sScrollX=a.sScrollX?"100%": -"");"boolean"===typeof a.scrollX&&(a.scrollX=a.scrollX?"100%":"");if(a=a.aoSearchCols)for(var b=0,c=a.length;b").css({position:"fixed",top:0,left:-1*h(E).scrollLeft(),height:1,width:1, -overflow:"hidden"}).append(h("

").css({position:"absolute",top:1,left:1,width:100,overflow:"scroll"}).append(h("
").css({width:"100%",height:10}))).appendTo("body"),d=c.children(),e=d.children();b.barWidth=d[0].offsetWidth-d[0].clientWidth;b.bScrollOversize=100===e[0].offsetWidth&&100!==d[0].clientWidth;b.bScrollbarLeft=1!==Math.round(e.offset().left);b.bBounding=c[0].getBoundingClientRect().width?!0:!1;c.remove()}h.extend(a.oBrowser,n.__browser);a.oScroll.iBarWidth=n.__browser.barWidth} -function hb(a,b,c,d,e,f){var g,j=!1;c!==k&&(g=c,j=!0);for(;d!==e;)a.hasOwnProperty(d)&&(g=j?b(g,a[d],d,a):a[d],j=!0,d+=f);return g}function Ea(a,b){var c=n.defaults.column,d=a.aoColumns.length,c=h.extend({},n.models.oColumn,c,{nTh:b?b:H.createElement("th"),sTitle:c.sTitle?c.sTitle:b?b.innerHTML:"",aDataSort:c.aDataSort?c.aDataSort:[d],mData:c.mData?c.mData:d,idx:d});a.aoColumns.push(c);c=a.aoPreSearchCols;c[d]=h.extend({},n.models.oSearch,c[d]);ka(a,d,h(b).data())}function ka(a,b,c){var b=a.aoColumns[b], -d=a.oClasses,e=h(b.nTh);if(!b.sWidthOrig){b.sWidthOrig=e.attr("width")||null;var f=(e.attr("style")||"").match(/width:\s*(\d+[pxem%]+)/);f&&(b.sWidthOrig=f[1])}c!==k&&null!==c&&(fb(c),J(n.defaults.column,c),c.mDataProp!==k&&!c.mData&&(c.mData=c.mDataProp),c.sType&&(b._sManualType=c.sType),c.className&&!c.sClass&&(c.sClass=c.className),c.sClass&&e.addClass(c.sClass),h.extend(b,c),F(b,c,"sWidth","sWidthOrig"),c.iDataSort!==k&&(b.aDataSort=[c.iDataSort]),F(b,c,"aDataSort"));var g=b.mData,j=S(g),i=b.mRender? -S(b.mRender):null,c=function(a){return"string"===typeof a&&-1!==a.indexOf("@")};b._bAttrSrc=h.isPlainObject(g)&&(c(g.sort)||c(g.type)||c(g.filter));b._setter=null;b.fnGetData=function(a,b,c){var d=j(a,b,k,c);return i&&b?i(d,b,a,c):d};b.fnSetData=function(a,b,c){return N(g)(a,b,c)};"number"!==typeof g&&(a._rowReadObject=!0);a.oFeatures.bSort||(b.bSortable=!1,e.addClass(d.sSortableNone));a=-1!==h.inArray("asc",b.asSorting);c=-1!==h.inArray("desc",b.asSorting);!b.bSortable||!a&&!c?(b.sSortingClass=d.sSortableNone, -b.sSortingClassJUI=""):a&&!c?(b.sSortingClass=d.sSortableAsc,b.sSortingClassJUI=d.sSortJUIAscAllowed):!a&&c?(b.sSortingClass=d.sSortableDesc,b.sSortingClassJUI=d.sSortJUIDescAllowed):(b.sSortingClass=d.sSortable,b.sSortingClassJUI=d.sSortJUI)}function $(a){if(!1!==a.oFeatures.bAutoWidth){var b=a.aoColumns;Fa(a);for(var c=0,d=b.length;cq[f])d(l.length+q[f],m);else if("string"=== -typeof q[f]){j=0;for(i=l.length;jb&&a[e]--; -1!=d&&c===k&&a.splice(d, -1)}function da(a,b,c,d){var e=a.aoData[b],f,g=function(c,d){for(;c.childNodes.length;)c.removeChild(c.firstChild);c.innerHTML=B(a,b,d,"display")};if("dom"===c||(!c||"auto"===c)&&"dom"===e.src)e._aData=Ia(a,e,d,d===k?k:e._aData).data;else{var j=e.anCells;if(j)if(d!==k)g(j[d],d);else{c=0;for(f=j.length;c").appendTo(g));b=0;for(c=l.length;btr").attr("role","row");h(g).find(">tr>th, >tr>td").addClass(m.sHeaderTH);h(j).find(">tr>th, >tr>td").addClass(m.sFooterTH);if(null!==j){a=a.aoFooter[0];b=0;for(c=a.length;b=a.fnRecordsDisplay()?0:g,a.iInitDisplayStart=-1);var g=a._iDisplayStart,m=a.fnDisplayEnd();if(a.bDeferLoading)a.bDeferLoading=!1,a.iDraw++,C(a,!1);else if(j){if(!a.bDestroying&&!lb(a))return}else a.iDraw++;if(0!==i.length){f=j?a.aoData.length:m;for(j=j?0:g;j",{"class":e?d[0]:""}).append(h("",{valign:"top",colSpan:V(a),"class":a.oClasses.sRowEmpty}).html(c))[0];r(a,"aoHeaderCallback","header",[h(a.nTHead).children("tr")[0],Ka(a),g,m,i]);r(a,"aoFooterCallback","footer",[h(a.nTFoot).children("tr")[0],Ka(a),g,m,i]);d=h(a.nTBody);d.children().detach(); -d.append(h(b));r(a,"aoDrawCallback","draw",[a]);a.bSorted=!1;a.bFiltered=!1;a.bDrawing=!1}}function T(a,b){var c=a.oFeatures,d=c.bFilter;c.bSort&&mb(a);d?ga(a,a.oPreviousSearch):a.aiDisplay=a.aiDisplayMaster.slice();!0!==b&&(a._iDisplayStart=0);a._drawHold=b;P(a);a._drawHold=!1}function nb(a){var b=a.oClasses,c=h(a.nTable),c=h("
").insertBefore(c),d=a.oFeatures,e=h("
",{id:a.sTableId+"_wrapper","class":b.sWrapper+(a.nTFoot?"":" "+b.sNoFooter)});a.nHolding=c[0];a.nTableWrapper=e[0];a.nTableReinsertBefore= -a.nTable.nextSibling;for(var f=a.sDom.split(""),g,j,i,m,l,q,k=0;k")[0];m=f[k+1];if("'"==m||'"'==m){l="";for(q=2;f[k+q]!=m;)l+=f[k+q],q++;"H"==l?l=b.sJUIHeader:"F"==l&&(l=b.sJUIFooter);-1!=l.indexOf(".")?(m=l.split("."),i.id=m[0].substr(1,m[0].length-1),i.className=m[1]):"#"==l.charAt(0)?i.id=l.substr(1,l.length-1):i.className=l;k+=q}e.append(i);e=h(i)}else if(">"==j)e=e.parent();else if("l"==j&&d.bPaginate&&d.bLengthChange)g=ob(a);else if("f"==j&& -d.bFilter)g=pb(a);else if("r"==j&&d.bProcessing)g=qb(a);else if("t"==j)g=rb(a);else if("i"==j&&d.bInfo)g=sb(a);else if("p"==j&&d.bPaginate)g=tb(a);else if(0!==n.ext.feature.length){i=n.ext.feature;q=0;for(m=i.length;q',j=d.sSearch,j=j.match(/_INPUT_/)?j.replace("_INPUT_", -g):j+g,b=h("
",{id:!f.f?c+"_filter":null,"class":b.sFilter}).append(h("
").addClass(b.sLength);a.aanFeatures.l||(i[0].id=c+"_length");i.children().append(a.oLanguage.sLengthMenu.replace("_MENU_",e[0].outerHTML));h("select",i).val(a._iDisplayLength).on("change.DT",function(){Ra(a,h(this).val());P(a)});h(a.nTable).on("length.dt.DT",function(b,c,d){a=== -c&&h("select",i).val(d)});return i[0]}function tb(a){var b=a.sPaginationType,c=n.ext.pager[b],d="function"===typeof c,e=function(a){P(a)},b=h("
").addClass(a.oClasses.sPaging+b)[0],f=a.aanFeatures;d||c.fnInit(a,b,e);f.p||(b.id=a.sTableId+"_paginate",a.aoDrawCallback.push({fn:function(a){if(d){var b=a._iDisplayStart,i=a._iDisplayLength,h=a.fnRecordsDisplay(),l=-1===i,b=l?0:Math.ceil(b/i),i=l?1:Math.ceil(h/i),h=c(b,i),k,l=0;for(k=f.p.length;lf&&(d=0)):"first"==b?d=0:"previous"==b?(d=0<=e?d-e:0,0>d&&(d=0)):"next"==b?d+e",{id:!a.aanFeatures.r?a.sTableId+"_processing":null,"class":a.oClasses.sProcessing}).html(a.oLanguage.sProcessing).insertBefore(a.nTable)[0]} -function C(a,b){a.oFeatures.bProcessing&&h(a.aanFeatures.r).css("display",b?"block":"none");r(a,null,"processing",[a,b])}function rb(a){var b=h(a.nTable);b.attr("role","grid");var c=a.oScroll;if(""===c.sX&&""===c.sY)return a.nTable;var d=c.sX,e=c.sY,f=a.oClasses,g=b.children("caption"),j=g.length?g[0]._captionSide:null,i=h(b[0].cloneNode(!1)),m=h(b[0].cloneNode(!1)),l=b.children("tfoot");l.length||(l=null);i=h("
",{"class":f.sScrollWrapper}).append(h("
",{"class":f.sScrollHead}).css({overflow:"hidden", -position:"relative",border:0,width:d?!d?null:v(d):"100%"}).append(h("
",{"class":f.sScrollHeadInner}).css({"box-sizing":"content-box",width:c.sXInner||"100%"}).append(i.removeAttr("id").css("margin-left",0).append("top"===j?g:null).append(b.children("thead"))))).append(h("
",{"class":f.sScrollBody}).css({position:"relative",overflow:"auto",width:!d?null:v(d)}).append(b));l&&i.append(h("
",{"class":f.sScrollFoot}).css({overflow:"hidden",border:0,width:d?!d?null:v(d):"100%"}).append(h("
", -{"class":f.sScrollFootInner}).append(m.removeAttr("id").css("margin-left",0).append("bottom"===j?g:null).append(b.children("tfoot")))));var b=i.children(),k=b[0],f=b[1],t=l?b[2]:null;if(d)h(f).on("scroll.DT",function(){var a=this.scrollLeft;k.scrollLeft=a;l&&(t.scrollLeft=a)});h(f).css(e&&c.bCollapse?"max-height":"height",e);a.nScrollHead=k;a.nScrollBody=f;a.nScrollFoot=t;a.aoDrawCallback.push({fn:la,sName:"scrolling"});return i[0]}function la(a){var b=a.oScroll,c=b.sX,d=b.sXInner,e=b.sY,b=b.iBarWidth, -f=h(a.nScrollHead),g=f[0].style,j=f.children("div"),i=j[0].style,m=j.children("table"),j=a.nScrollBody,l=h(j),q=j.style,t=h(a.nScrollFoot).children("div"),n=t.children("table"),o=h(a.nTHead),p=h(a.nTable),s=p[0],r=s.style,u=a.nTFoot?h(a.nTFoot):null,x=a.oBrowser,U=x.bScrollOversize,Xb=D(a.aoColumns,"nTh"),Q,L,R,w,Ua=[],y=[],z=[],A=[],B,C=function(a){a=a.style;a.paddingTop="0";a.paddingBottom="0";a.borderTopWidth="0";a.borderBottomWidth="0";a.height=0};L=j.scrollHeight>j.clientHeight;if(a.scrollBarVis!== -L&&a.scrollBarVis!==k)a.scrollBarVis=L,$(a);else{a.scrollBarVis=L;p.children("thead, tfoot").remove();u&&(R=u.clone().prependTo(p),Q=u.find("tr"),R=R.find("tr"));w=o.clone().prependTo(p);o=o.find("tr");L=w.find("tr");w.find("th, td").removeAttr("tabindex");c||(q.width="100%",f[0].style.width="100%");h.each(ra(a,w),function(b,c){B=aa(a,b);c.style.width=a.aoColumns[B].sWidth});u&&I(function(a){a.style.width=""},R);f=p.outerWidth();if(""===c){r.width="100%";if(U&&(p.find("tbody").height()>j.offsetHeight|| -"scroll"==l.css("overflow-y")))r.width=v(p.outerWidth()-b);f=p.outerWidth()}else""!==d&&(r.width=v(d),f=p.outerWidth());I(C,L);I(function(a){z.push(a.innerHTML);Ua.push(v(h(a).css("width")))},L);I(function(a,b){if(h.inArray(a,Xb)!==-1)a.style.width=Ua[b]},o);h(L).height(0);u&&(I(C,R),I(function(a){A.push(a.innerHTML);y.push(v(h(a).css("width")))},R),I(function(a,b){a.style.width=y[b]},Q),h(R).height(0));I(function(a,b){a.innerHTML='
'+z[b]+"
";a.childNodes[0].style.height= -"0";a.childNodes[0].style.overflow="hidden";a.style.width=Ua[b]},L);u&&I(function(a,b){a.innerHTML='
'+A[b]+"
";a.childNodes[0].style.height="0";a.childNodes[0].style.overflow="hidden";a.style.width=y[b]},R);if(p.outerWidth()j.offsetHeight||"scroll"==l.css("overflow-y")?f+b:f;if(U&&(j.scrollHeight>j.offsetHeight||"scroll"==l.css("overflow-y")))r.width=v(Q-b);(""===c||""!==d)&&K(a,1,"Possible column misalignment",6)}else Q="100%";q.width=v(Q); -g.width=v(Q);u&&(a.nScrollFoot.style.width=v(Q));!e&&U&&(q.height=v(s.offsetHeight+b));c=p.outerWidth();m[0].style.width=v(c);i.width=v(c);d=p.height()>j.clientHeight||"scroll"==l.css("overflow-y");e="padding"+(x.bScrollbarLeft?"Left":"Right");i[e]=d?b+"px":"0px";u&&(n[0].style.width=v(c),t[0].style.width=v(c),t[0].style[e]=d?b+"px":"0px");p.children("colgroup").insertBefore(p.children("thead"));l.scroll();if((a.bSorted||a.bFiltered)&&!a._drawHold)j.scrollTop=0}}function I(a,b,c){for(var d=0,e=0, -f=b.length,g,j;e").appendTo(j.find("tbody"));j.find("thead, tfoot").remove();j.append(h(a.nTHead).clone()).append(h(a.nTFoot).clone());j.find("tfoot th, tfoot td").css("width","");m=ra(a,j.find("thead")[0]);for(n=0;n").css({width:o.sWidthOrig,margin:0,padding:0,border:0,height:1}));if(a.aoData.length)for(n=0;n").css(f||e?{position:"absolute",top:0,left:0,height:1,right:0,overflow:"hidden"}:{}).append(j).appendTo(k);f&&g?j.width(g):f?(j.css("width","auto"),j.removeAttr("width"),j.width()").css("width",v(a)).appendTo(b||H.body),d=c[0].offsetWidth;c.remove();return d}function Fb(a, -b){var c=Gb(a,b);if(0>c)return null;var d=a.aoData[c];return!d.nTr?h("").html(B(a,c,b,"display"))[0]:d.anCells[b]}function Gb(a,b){for(var c,d=-1,e=-1,f=0,g=a.aoData.length;fd&&(d=c.length,e=f);return e}function v(a){return null===a?"0px":"number"==typeof a?0>a?"0px":a+"px":a.match(/\d$/)?a+"px":a}function X(a){var b,c,d=[],e=a.aoColumns,f,g,j,i;b=a.aaSortingFixed;c=h.isPlainObject(b);var m=[];f=function(a){a.length&& -!h.isArray(a[0])?m.push(a):h.merge(m,a)};h.isArray(b)&&f(b);c&&b.pre&&f(b.pre);f(a.aaSorting);c&&b.post&&f(b.post);for(a=0;ae?1:0,0!==c)return"asc"===j.dir?c:-c;c=d[a];e=d[b];return ce?1:0}):i.sort(function(a,b){var c,g,j,i,k=h.length,n=f[a]._aSortData,o=f[b]._aSortData;for(j=0;jg?1:0})}a.bSorted=!0}function Ib(a){for(var b,c,d=a.aoColumns,e=X(a),a=a.oLanguage.oAria,f=0,g=d.length;f/g,"");var i=c.nTh;i.removeAttribute("aria-sort");c.bSortable&&(0e?e+1:3));e=0;for(f=d.length;ee?e+1:3))}a.aLastSort=d}function Hb(a,b){var c=a.aoColumns[b],d=n.ext.order[c.sSortDataType],e;d&&(e=d.call(a.oInstance,a,b,ba(a,b)));for(var f,g=n.ext.type.order[c.sType+"-pre"],j=0,i=a.aoData.length;j=f.length?[0,c[1]]:c)}));b.search!==k&&h.extend(a.oPreviousSearch,Bb(b.search));if(b.columns){d=0;for(e=b.columns.length;d=c&&(b=c-d);b-=b%d;if(-1===d||0>b)b=0;a._iDisplayStart=b}function Na(a,b){var c=a.renderer,d=n.ext.renderer[b];return h.isPlainObject(c)&&c[b]?d[c[b]]||d._:"string"=== -typeof c?d[c]||d._:d._}function y(a){return a.oFeatures.bServerSide?"ssp":a.ajax||a.sAjaxSource?"ajax":"dom"}function ia(a,b){var c=[],c=Kb.numbers_length,d=Math.floor(c/2);b<=c?c=Y(0,b):a<=d?(c=Y(0,c-2),c.push("ellipsis"),c.push(b-1)):(a>=b-1-d?c=Y(b-(c-2),b):(c=Y(a-d+2,a+d-1),c.push("ellipsis"),c.push(b-1)),c.splice(0,0,"ellipsis"),c.splice(0,0,0));c.DT_el="span";return c}function Da(a){h.each({num:function(b){return za(b,a)},"num-fmt":function(b){return za(b,a,Ya)},"html-num":function(b){return za(b, -a,Aa)},"html-num-fmt":function(b){return za(b,a,Aa,Ya)}},function(b,c){x.type.order[b+a+"-pre"]=c;b.match(/^html\-/)&&(x.type.search[b+a]=x.type.search.html)})}function Lb(a){return function(){var b=[ya(this[n.ext.iApiIndex])].concat(Array.prototype.slice.call(arguments));return n.ext.internal[a].apply(this,b)}}var n=function(a){this.$=function(a,b){return this.api(!0).$(a,b)};this._=function(a,b){return this.api(!0).rows(a,b).data()};this.api=function(a){return a?new s(ya(this[x.iApiIndex])):new s(this)}; -this.fnAddData=function(a,b){var c=this.api(!0),d=h.isArray(a)&&(h.isArray(a[0])||h.isPlainObject(a[0]))?c.rows.add(a):c.row.add(a);(b===k||b)&&c.draw();return d.flatten().toArray()};this.fnAdjustColumnSizing=function(a){var b=this.api(!0).columns.adjust(),c=b.settings()[0],d=c.oScroll;a===k||a?b.draw(!1):(""!==d.sX||""!==d.sY)&&la(c)};this.fnClearTable=function(a){var b=this.api(!0).clear();(a===k||a)&&b.draw()};this.fnClose=function(a){this.api(!0).row(a).child.hide()};this.fnDeleteRow=function(a, -b,c){var d=this.api(!0),a=d.rows(a),e=a.settings()[0],h=e.aoData[a[0][0]];a.remove();b&&b.call(this,e,h);(c===k||c)&&d.draw();return h};this.fnDestroy=function(a){this.api(!0).destroy(a)};this.fnDraw=function(a){this.api(!0).draw(a)};this.fnFilter=function(a,b,c,d,e,h){e=this.api(!0);null===b||b===k?e.search(a,c,d,h):e.column(b).search(a,c,d,h);e.draw()};this.fnGetData=function(a,b){var c=this.api(!0);if(a!==k){var d=a.nodeName?a.nodeName.toLowerCase():"";return b!==k||"td"==d||"th"==d?c.cell(a,b).data(): -c.row(a).data()||null}return c.data().toArray()};this.fnGetNodes=function(a){var b=this.api(!0);return a!==k?b.row(a).node():b.rows().nodes().flatten().toArray()};this.fnGetPosition=function(a){var b=this.api(!0),c=a.nodeName.toUpperCase();return"TR"==c?b.row(a).index():"TD"==c||"TH"==c?(a=b.cell(a).index(),[a.row,a.columnVisible,a.column]):null};this.fnIsOpen=function(a){return this.api(!0).row(a).child.isShown()};this.fnOpen=function(a,b,c){return this.api(!0).row(a).child(b,c).show().child()[0]}; -this.fnPageChange=function(a,b){var c=this.api(!0).page(a);(b===k||b)&&c.draw(!1)};this.fnSetColumnVis=function(a,b,c){a=this.api(!0).column(a).visible(b);(c===k||c)&&a.columns.adjust().draw()};this.fnSettings=function(){return ya(this[x.iApiIndex])};this.fnSort=function(a){this.api(!0).order(a).draw()};this.fnSortListener=function(a,b,c){this.api(!0).order.listener(a,b,c)};this.fnUpdate=function(a,b,c,d,e){var h=this.api(!0);c===k||null===c?h.row(b).data(a):h.cell(b,c).data(a);(e===k||e)&&h.columns.adjust(); -(d===k||d)&&h.draw();return 0};this.fnVersionCheck=x.fnVersionCheck;var b=this,c=a===k,d=this.length;c&&(a={});this.oApi=this.internal=x.internal;for(var e in n.ext.internal)e&&(this[e]=Lb(e));this.each(function(){var e={},g=1").appendTo(q)); -p.nTHead=b[0];b=q.children("tbody");b.length===0&&(b=h("").appendTo(q));p.nTBody=b[0];b=q.children("tfoot");if(b.length===0&&a.length>0&&(p.oScroll.sX!==""||p.oScroll.sY!==""))b=h("").appendTo(q);if(b.length===0||b.children().length===0)q.addClass(u.sNoFooter);else if(b.length>0){p.nTFoot=b[0];ea(p.aoFooter,p.nTFoot)}if(g.aaData)for(j=0;j/g,Zb=/^\d{2,4}[\.\/\-]\d{1,2}[\.\/\-]\d{1,2}([T ]{1}\d{1,2}[:\.]\d{2}([\.:]\d{2})?)?$/,$b=RegExp("(\\/|\\.|\\*|\\+|\\?|\\||\\(|\\)|\\[|\\]|\\{|\\}|\\\\|\\$|\\^|\\-)","g"),Ya=/[',$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfkɃΞ]/gi,M=function(a){return!a||!0===a||"-"===a?!0:!1},Nb=function(a){var b=parseInt(a,10);return!isNaN(b)&& -isFinite(a)?b:null},Ob=function(a,b){Za[b]||(Za[b]=RegExp(Qa(b),"g"));return"string"===typeof a&&"."!==b?a.replace(/\./g,"").replace(Za[b],"."):a},$a=function(a,b,c){var d="string"===typeof a;if(M(a))return!0;b&&d&&(a=Ob(a,b));c&&d&&(a=a.replace(Ya,""));return!isNaN(parseFloat(a))&&isFinite(a)},Pb=function(a,b,c){return M(a)?!0:!(M(a)||"string"===typeof a)?null:$a(a.replace(Aa,""),b,c)?!0:null},D=function(a,b,c){var d=[],e=0,f=a.length;if(c!==k)for(;ea.length)){b=a.slice().sort();for(var c=b[0],d=1,e=b.length;d")[0],Wb=va.textContent!==k,Yb= -/<.*?>/g,Oa=n.util.throttle,Rb=[],w=Array.prototype,ac=function(a){var b,c,d=n.settings,e=h.map(d,function(a){return a.nTable});if(a){if(a.nTable&&a.oApi)return[a];if(a.nodeName&&"table"===a.nodeName.toLowerCase())return b=h.inArray(a,e),-1!==b?[d[b]]:null;if(a&&"function"===typeof a.settings)return a.settings().toArray();"string"===typeof a?c=h(a):a instanceof h&&(c=a)}else return[];if(c)return c.map(function(){b=h.inArray(this,e);return-1!==b?d[b]:null}).toArray()};s=function(a,b){if(!(this instanceof -s))return new s(a,b);var c=[],d=function(a){(a=ac(a))&&(c=c.concat(a))};if(h.isArray(a))for(var e=0,f=a.length;ea?new s(b[a],this[a]):null},filter:function(a){var b=[];if(w.filter)b=w.filter.call(this,a,this);else for(var c=0,d=this.length;c").addClass(b),h("td",c).addClass(b).html(a)[0].colSpan=V(d),e.push(c[0]))};f(a,b);c._details&&c._details.detach();c._details=h(e); -c._detailsShow&&c._details.insertAfter(c.nTr)}return this});o(["row().child.show()","row().child().show()"],function(){Tb(this,!0);return this});o(["row().child.hide()","row().child().hide()"],function(){Tb(this,!1);return this});o(["row().child.remove()","row().child().remove()"],function(){db(this);return this});o("row().child.isShown()",function(){var a=this.context;return a.length&&this.length?a[0].aoData[this[0]]._detailsShow||!1:!1});var bc=/^([^:]+):(name|visIdx|visible)$/,Ub=function(a,b, -c,d,e){for(var c=[],d=0,f=e.length;d=0?b:g.length+b];if(typeof a==="function"){var e=Ba(c,f);return h.map(g,function(b,f){return a(f,Ub(c,f,0,0,e),i[f])?f:null})}var k=typeof a==="string"?a.match(bc): -"";if(k)switch(k[2]){case "visIdx":case "visible":b=parseInt(k[1],10);if(b<0){var n=h.map(g,function(a,b){return a.bVisible?b:null});return[n[n.length+b]]}return[aa(c,b)];case "name":return h.map(j,function(a,b){return a===k[1]?b:null});default:return[]}if(a.nodeName&&a._DT_CellIndex)return[a._DT_CellIndex.column];b=h(i).filter(a).map(function(){return h.inArray(this,i)}).toArray();if(b.length||!a.nodeName)return b;b=h(a).closest("*[data-dt-column]");return b.length?[b.data("dt-column")]:[]},c,f)}, -1);c.selector.cols=a;c.selector.opts=b;return c});u("columns().header()","column().header()",function(){return this.iterator("column",function(a,b){return a.aoColumns[b].nTh},1)});u("columns().footer()","column().footer()",function(){return this.iterator("column",function(a,b){return a.aoColumns[b].nTf},1)});u("columns().data()","column().data()",function(){return this.iterator("column-rows",Ub,1)});u("columns().dataSrc()","column().dataSrc()",function(){return this.iterator("column",function(a,b){return a.aoColumns[b].mData}, -1)});u("columns().cache()","column().cache()",function(a){return this.iterator("column-rows",function(b,c,d,e,f){return ja(b.aoData,f,"search"===a?"_aFilterData":"_aSortData",c)},1)});u("columns().nodes()","column().nodes()",function(){return this.iterator("column-rows",function(a,b,c,d,e){return ja(a.aoData,e,"anCells",b)},1)});u("columns().visible()","column().visible()",function(a,b){var c=this.iterator("column",function(b,c){if(a===k)return b.aoColumns[c].bVisible;var f=b.aoColumns,g=f[c],j=b.aoData, -i,m,l;if(a!==k&&g.bVisible!==a){if(a){var n=h.inArray(!0,D(f,"bVisible"),c+1);i=0;for(m=j.length;id;return!0};n.isDataTable= -n.fnIsDataTable=function(a){var b=h(a).get(0),c=!1;if(a instanceof n.Api)return!0;h.each(n.settings,function(a,e){var f=e.nScrollHead?h("table",e.nScrollHead)[0]:null,g=e.nScrollFoot?h("table",e.nScrollFoot)[0]:null;if(e.nTable===b||f===b||g===b)c=!0});return c};n.tables=n.fnTables=function(a){var b=!1;h.isPlainObject(a)&&(b=a.api,a=a.visible);var c=h.map(n.settings,function(b){if(!a||a&&h(b.nTable).is(":visible"))return b.nTable});return b?new s(c):c};n.camelToHungarian=J;o("$()",function(a,b){var c= -this.rows(b).nodes(),c=h(c);return h([].concat(c.filter(a).toArray(),c.find(a).toArray()))});h.each(["on","one","off"],function(a,b){o(b+"()",function(){var a=Array.prototype.slice.call(arguments);a[0]=h.map(a[0].split(/\s/),function(a){return!a.match(/\.dt\b/)?a+".dt":a}).join(" ");var d=h(this.tables().nodes());d[b].apply(d,a);return this})});o("clear()",function(){return this.iterator("table",function(a){oa(a)})});o("settings()",function(){return new s(this.context,this.context)});o("init()",function(){var a= -this.context;return a.length?a[0].oInit:null});o("data()",function(){return this.iterator("table",function(a){return D(a.aoData,"_aData")}).flatten()});o("destroy()",function(a){a=a||!1;return this.iterator("table",function(b){var c=b.nTableWrapper.parentNode,d=b.oClasses,e=b.nTable,f=b.nTBody,g=b.nTHead,j=b.nTFoot,i=h(e),f=h(f),k=h(b.nTableWrapper),l=h.map(b.aoData,function(a){return a.nTr}),o;b.bDestroying=!0;r(b,"aoDestroyCallback","destroy",[b]);a||(new s(b)).columns().visible(!0);k.off(".DT").find(":not(tbody *)").off(".DT"); -h(E).off(".DT-"+b.sInstance);e!=g.parentNode&&(i.children("thead").detach(),i.append(g));j&&e!=j.parentNode&&(i.children("tfoot").detach(),i.append(j));b.aaSorting=[];b.aaSortingFixed=[];wa(b);h(l).removeClass(b.asStripeClasses.join(" "));h("th, td",g).removeClass(d.sSortable+" "+d.sSortableAsc+" "+d.sSortableDesc+" "+d.sSortableNone);f.children().detach();f.append(l);g=a?"remove":"detach";i[g]();k[g]();!a&&c&&(c.insertBefore(e,b.nTableReinsertBefore),i.css("width",b.sDestroyWidth).removeClass(d.sTable), -(o=b.asDestroyStripes.length)&&f.children().each(function(a){h(this).addClass(b.asDestroyStripes[a%o])}));c=h.inArray(b,n.settings);-1!==c&&n.settings.splice(c,1)})});h.each(["column","row","cell"],function(a,b){o(b+"s().every()",function(a){var d=this.selector.opts,e=this;return this.iterator(b,function(f,g,h,i,m){a.call(e[b](g,"cell"===b?h:d,"cell"===b?d:k),g,h,i,m)})})});o("i18n()",function(a,b,c){var d=this.context[0],a=S(a)(d.oLanguage);a===k&&(a=b);c!==k&&h.isPlainObject(a)&&(a=a[c]!==k?a[c]: -a._);return a.replace("%d",c)});n.version="1.10.18";n.settings=[];n.models={};n.models.oSearch={bCaseInsensitive:!0,sSearch:"",bRegex:!1,bSmart:!0};n.models.oRow={nTr:null,anCells:null,_aData:[],_aSortData:null,_aFilterData:null,_sFilterRow:null,_sRowStripe:"",src:null,idx:-1};n.models.oColumn={idx:null,aDataSort:null,asSorting:null,bSearchable:null,bSortable:null,bVisible:null,_sManualType:null,_bAttrSrc:!1,fnCreatedCell:null,fnGetData:null,fnSetData:null,mData:null,mRender:null,nTh:null,nTf:null, -sClass:null,sContentPadding:null,sDefaultContent:null,sName:null,sSortDataType:"std",sSortingClass:null,sSortingClassJUI:null,sTitle:null,sType:null,sWidth:null,sWidthOrig:null};n.defaults={aaData:null,aaSorting:[[0,"asc"]],aaSortingFixed:[],ajax:null,aLengthMenu:[10,25,50,100],aoColumns:null,aoColumnDefs:null,aoSearchCols:[],asStripeClasses:null,bAutoWidth:!0,bDeferRender:!1,bDestroy:!1,bFilter:!0,bInfo:!0,bLengthChange:!0,bPaginate:!0,bProcessing:!1,bRetrieve:!1,bScrollCollapse:!1,bServerSide:!1, -bSort:!0,bSortMulti:!0,bSortCellsTop:!1,bSortClasses:!0,bStateSave:!1,fnCreatedRow:null,fnDrawCallback:null,fnFooterCallback:null,fnFormatNumber:function(a){return a.toString().replace(/\B(?=(\d{3})+(?!\d))/g,this.oLanguage.sThousands)},fnHeaderCallback:null,fnInfoCallback:null,fnInitComplete:null,fnPreDrawCallback:null,fnRowCallback:null,fnServerData:null,fnServerParams:null,fnStateLoadCallback:function(a){try{return JSON.parse((-1===a.iStateDuration?sessionStorage:localStorage).getItem("DataTables_"+ -a.sInstance+"_"+location.pathname))}catch(b){}},fnStateLoadParams:null,fnStateLoaded:null,fnStateSaveCallback:function(a,b){try{(-1===a.iStateDuration?sessionStorage:localStorage).setItem("DataTables_"+a.sInstance+"_"+location.pathname,JSON.stringify(b))}catch(c){}},fnStateSaveParams:null,iStateDuration:7200,iDeferLoading:null,iDisplayLength:10,iDisplayStart:0,iTabIndex:0,oClasses:{},oLanguage:{oAria:{sSortAscending:": activate to sort column ascending",sSortDescending:": activate to sort column descending"}, -oPaginate:{sFirst:"First",sLast:"Last",sNext:"Next",sPrevious:"Previous"},sEmptyTable:"No data available in table",sInfo:"Showing _START_ to _END_ of _TOTAL_ entries",sInfoEmpty:"Showing 0 to 0 of 0 entries",sInfoFiltered:"(filtered from _MAX_ total entries)",sInfoPostFix:"",sDecimal:"",sThousands:",",sLengthMenu:"Show _MENU_ entries",sLoadingRecords:"Loading...",sProcessing:"Processing...",sSearch:"Search:",sSearchPlaceholder:"",sUrl:"",sZeroRecords:"No matching records found"},oSearch:h.extend({}, -n.models.oSearch),sAjaxDataProp:"data",sAjaxSource:null,sDom:"lfrtip",searchDelay:null,sPaginationType:"simple_numbers",sScrollX:"",sScrollXInner:"",sScrollY:"",sServerMethod:"GET",renderer:null,rowId:"DT_RowId"};Z(n.defaults);n.defaults.column={aDataSort:null,iDataSort:-1,asSorting:["asc","desc"],bSearchable:!0,bSortable:!0,bVisible:!0,fnCreatedCell:null,mData:null,mRender:null,sCellType:"td",sClass:"",sContentPadding:"",sDefaultContent:null,sName:"",sSortDataType:"std",sTitle:null,sType:null,sWidth:null}; -Z(n.defaults.column);n.models.oSettings={oFeatures:{bAutoWidth:null,bDeferRender:null,bFilter:null,bInfo:null,bLengthChange:null,bPaginate:null,bProcessing:null,bServerSide:null,bSort:null,bSortMulti:null,bSortClasses:null,bStateSave:null},oScroll:{bCollapse:null,iBarWidth:0,sX:null,sXInner:null,sY:null},oLanguage:{fnInfoCallback:null},oBrowser:{bScrollOversize:!1,bScrollbarLeft:!1,bBounding:!1,barWidth:0},ajax:null,aanFeatures:[],aoData:[],aiDisplay:[],aiDisplayMaster:[],aIds:{},aoColumns:[],aoHeader:[], -aoFooter:[],oPreviousSearch:{},aoPreSearchCols:[],aaSorting:null,aaSortingFixed:[],asStripeClasses:null,asDestroyStripes:[],sDestroyWidth:0,aoRowCallback:[],aoHeaderCallback:[],aoFooterCallback:[],aoDrawCallback:[],aoRowCreatedCallback:[],aoPreDrawCallback:[],aoInitComplete:[],aoStateSaveParams:[],aoStateLoadParams:[],aoStateLoaded:[],sTableId:"",nTable:null,nTHead:null,nTFoot:null,nTBody:null,nTableWrapper:null,bDeferLoading:!1,bInitialised:!1,aoOpenRows:[],sDom:null,searchDelay:null,sPaginationType:"two_button", -iStateDuration:0,aoStateSave:[],aoStateLoad:[],oSavedState:null,oLoadedState:null,sAjaxSource:null,sAjaxDataProp:null,bAjaxDataGet:!0,jqXHR:null,json:k,oAjaxData:k,fnServerData:null,aoServerParams:[],sServerMethod:null,fnFormatNumber:null,aLengthMenu:null,iDraw:0,bDrawing:!1,iDrawError:-1,_iDisplayLength:10,_iDisplayStart:0,_iRecordsTotal:0,_iRecordsDisplay:0,oClasses:{},bFiltered:!1,bSorted:!1,bSortCellsTop:null,oInit:null,aoDestroyCallback:[],fnRecordsTotal:function(){return"ssp"==y(this)?1*this._iRecordsTotal: -this.aiDisplayMaster.length},fnRecordsDisplay:function(){return"ssp"==y(this)?1*this._iRecordsDisplay:this.aiDisplay.length},fnDisplayEnd:function(){var a=this._iDisplayLength,b=this._iDisplayStart,c=b+a,d=this.aiDisplay.length,e=this.oFeatures,f=e.bPaginate;return e.bServerSide?!1===f||-1===a?b+d:Math.min(b+a,this._iRecordsDisplay):!f||c>d||-1===a?d:c},oInstance:null,sInstance:null,iTabIndex:0,nScrollHead:null,nScrollFoot:null,aLastSort:[],oPlugins:{},rowIdFn:null,rowId:null};n.ext=x={buttons:{}, -classes:{},build:"ju/dt-1.10.18/r-2.2.2",errMode:"alert",feature:[],search:[],selector:{cell:[],column:[],row:[]},internal:{},legacy:{ajax:null},pager:{},renderer:{pageButton:{},header:{}},order:{},type:{detect:[],search:{},order:{}},_unique:0,fnVersionCheck:n.fnVersionCheck,iApiIndex:0,oJUIClasses:{},sVersion:n.version};h.extend(x,{afnFiltering:x.search,aTypes:x.type.detect,ofnSearch:x.type.search,oSort:x.type.order,afnSortData:x.order,aoFeatures:x.feature,oApi:x.internal,oStdClasses:x.classes,oPagination:x.pager}); -h.extend(n.ext.classes,{sTable:"dataTable",sNoFooter:"no-footer",sPageButton:"paginate_button",sPageButtonActive:"current",sPageButtonDisabled:"disabled",sStripeOdd:"odd",sStripeEven:"even",sRowEmpty:"dataTables_empty",sWrapper:"dataTables_wrapper",sFilter:"dataTables_filter",sInfo:"dataTables_info",sPaging:"dataTables_paginate paging_",sLength:"dataTables_length",sProcessing:"dataTables_processing",sSortAsc:"sorting_asc",sSortDesc:"sorting_desc",sSortable:"sorting",sSortableAsc:"sorting_asc_disabled", -sSortableDesc:"sorting_desc_disabled",sSortableNone:"sorting_disabled",sSortColumn:"sorting_",sFilterInput:"",sLengthSelect:"",sScrollWrapper:"dataTables_scroll",sScrollHead:"dataTables_scrollHead",sScrollHeadInner:"dataTables_scrollHeadInner",sScrollBody:"dataTables_scrollBody",sScrollFoot:"dataTables_scrollFoot",sScrollFootInner:"dataTables_scrollFootInner",sHeaderTH:"",sFooterTH:"",sSortJUIAsc:"",sSortJUIDesc:"",sSortJUI:"",sSortJUIAscAllowed:"",sSortJUIDescAllowed:"",sSortJUIWrapper:"",sSortIcon:"", -sJUIHeader:"",sJUIFooter:""});var Kb=n.ext.pager;h.extend(Kb,{simple:function(){return["previous","next"]},full:function(){return["first","previous","next","last"]},numbers:function(a,b){return[ia(a,b)]},simple_numbers:function(a,b){return["previous",ia(a,b),"next"]},full_numbers:function(a,b){return["first","previous",ia(a,b),"next","last"]},first_last_numbers:function(a,b){return["first",ia(a,b),"last"]},_numbers:ia,numbers_length:7});h.extend(!0,n.ext.renderer,{pageButton:{_:function(a,b,c,d,e, -f){var g=a.oClasses,j=a.oLanguage.oPaginate,i=a.oLanguage.oAria.paginate||{},m,l,n=0,o=function(b,d){var k,s,u,r,v=function(b){Ta(a,b.data.action,true)};k=0;for(s=d.length;k").appendTo(b);o(u,r)}else{m=null;l="";switch(r){case "ellipsis":b.append('');break;case "first":m=j.sFirst;l=r+(e>0?"":" "+g.sPageButtonDisabled);break;case "previous":m=j.sPrevious;l=r+(e>0?"":" "+g.sPageButtonDisabled);break;case "next":m= -j.sNext;l=r+(e",{"class":g.sPageButton+" "+l,"aria-controls":a.sTableId,"aria-label":i[r],"data-dt-idx":n,tabindex:a.iTabIndex,id:c===0&&typeof r==="string"?a.sTableId+"_"+r:null}).html(m).appendTo(b);Wa(u,{action:r},v);n++}}}},s;try{s=h(b).find(H.activeElement).data("dt-idx")}catch(u){}o(h(b).empty(),d);s!==k&&h(b).find("[data-dt-idx="+ -s+"]").focus()}}});h.extend(n.ext.type.detect,[function(a,b){var c=b.oLanguage.sDecimal;return $a(a,c)?"num"+c:null},function(a){if(a&&!(a instanceof Date)&&!Zb.test(a))return null;var b=Date.parse(a);return null!==b&&!isNaN(b)||M(a)?"date":null},function(a,b){var c=b.oLanguage.sDecimal;return $a(a,c,!0)?"num-fmt"+c:null},function(a,b){var c=b.oLanguage.sDecimal;return Pb(a,c)?"html-num"+c:null},function(a,b){var c=b.oLanguage.sDecimal;return Pb(a,c,!0)?"html-num-fmt"+c:null},function(a){return M(a)|| -"string"===typeof a&&-1!==a.indexOf("<")?"html":null}]);h.extend(n.ext.type.search,{html:function(a){return M(a)?a:"string"===typeof a?a.replace(Mb," ").replace(Aa,""):""},string:function(a){return M(a)?a:"string"===typeof a?a.replace(Mb," "):a}});var za=function(a,b,c,d){if(0!==a&&(!a||"-"===a))return-Infinity;b&&(a=Ob(a,b));a.replace&&(c&&(a=a.replace(c,"")),d&&(a=a.replace(d,"")));return 1*a};h.extend(x.type.order,{"date-pre":function(a){a=Date.parse(a);return isNaN(a)?-Infinity:a},"html-pre":function(a){return M(a)? -"":a.replace?a.replace(/<.*?>/g,"").toLowerCase():a+""},"string-pre":function(a){return M(a)?"":"string"===typeof a?a.toLowerCase():!a.toString?"":a.toString()},"string-asc":function(a,b){return ab?1:0},"string-desc":function(a,b){return ab?-1:0}});Da("");h.extend(!0,n.ext.renderer,{header:{_:function(a,b,c,d){h(a.nTable).on("order.dt.DT",function(e,f,g,h){if(a===f){e=c.idx;b.removeClass(c.sSortingClass+" "+d.sSortAsc+" "+d.sSortDesc).addClass(h[e]=="asc"?d.sSortAsc:h[e]=="desc"?d.sSortDesc: -c.sSortingClass)}})},jqueryui:function(a,b,c,d){h("
").addClass(d.sSortJUIWrapper).append(b.contents()).append(h("").addClass(d.sSortIcon+" "+c.sSortingClassJUI)).appendTo(b);h(a.nTable).on("order.dt.DT",function(e,f,g,h){if(a===f){e=c.idx;b.removeClass(d.sSortAsc+" "+d.sSortDesc).addClass(h[e]=="asc"?d.sSortAsc:h[e]=="desc"?d.sSortDesc:c.sSortingClass);b.find("span."+d.sSortIcon).removeClass(d.sSortJUIAsc+" "+d.sSortJUIDesc+" "+d.sSortJUI+" "+d.sSortJUIAscAllowed+" "+d.sSortJUIDescAllowed).addClass(h[e]== -"asc"?d.sSortJUIAsc:h[e]=="desc"?d.sSortJUIDesc:c.sSortingClassJUI)}})}}});var Vb=function(a){return"string"===typeof a?a.replace(//g,">").replace(/"/g,"""):a};n.render={number:function(a,b,c,d,e){return{display:function(f){if("number"!==typeof f&&"string"!==typeof f)return f;var g=0>f?"-":"",h=parseFloat(f);if(isNaN(h))return Vb(f);h=h.toFixed(c);f=Math.abs(h);h=parseInt(f,10);f=c?b+(f-h).toFixed(c).substring(2):"";return g+(d||"")+h.toString().replace(/\B(?=(\d{3})+(?!\d))/g, -a)+f+(e||"")}}},text:function(){return{display:Vb}}};h.extend(n.ext.internal,{_fnExternApiFunc:Lb,_fnBuildAjax:sa,_fnAjaxUpdate:lb,_fnAjaxParameters:ub,_fnAjaxUpdateDraw:vb,_fnAjaxDataSrc:ta,_fnAddColumn:Ea,_fnColumnOptions:ka,_fnAdjustColumnSizing:$,_fnVisibleToColumnIndex:aa,_fnColumnIndexToVisible:ba,_fnVisbleColumns:V,_fnGetColumns:ma,_fnColumnTypes:Ga,_fnApplyColumnDefs:ib,_fnHungarianMap:Z,_fnCamelToHungarian:J,_fnLanguageCompat:Ca,_fnBrowserDetect:gb,_fnAddData:O,_fnAddTr:na,_fnNodeToDataIndex:function(a, -b){return b._DT_RowIndex!==k?b._DT_RowIndex:null},_fnNodeToColumnIndex:function(a,b,c){return h.inArray(c,a.aoData[b].anCells)},_fnGetCellData:B,_fnSetCellData:jb,_fnSplitObjNotation:Ja,_fnGetObjectDataFn:S,_fnSetObjectDataFn:N,_fnGetDataMaster:Ka,_fnClearTable:oa,_fnDeleteIndex:pa,_fnInvalidate:da,_fnGetRowElements:Ia,_fnCreateTr:Ha,_fnBuildHead:kb,_fnDrawHead:fa,_fnDraw:P,_fnReDraw:T,_fnAddOptionsHtml:nb,_fnDetectHeader:ea,_fnGetUniqueThs:ra,_fnFeatureHtmlFilter:pb,_fnFilterComplete:ga,_fnFilterCustom:yb, -_fnFilterColumn:xb,_fnFilter:wb,_fnFilterCreateSearch:Pa,_fnEscapeRegex:Qa,_fnFilterData:zb,_fnFeatureHtmlInfo:sb,_fnUpdateInfo:Cb,_fnInfoMacros:Db,_fnInitialise:ha,_fnInitComplete:ua,_fnLengthChange:Ra,_fnFeatureHtmlLength:ob,_fnFeatureHtmlPaginate:tb,_fnPageChange:Ta,_fnFeatureHtmlProcessing:qb,_fnProcessingDisplay:C,_fnFeatureHtmlTable:rb,_fnScrollDraw:la,_fnApplyToChildren:I,_fnCalculateColumnWidths:Fa,_fnThrottle:Oa,_fnConvertToWidth:Eb,_fnGetWidestNode:Fb,_fnGetMaxLenString:Gb,_fnStringToCss:v, -_fnSortFlatten:X,_fnSort:mb,_fnSortAria:Ib,_fnSortListener:Va,_fnSortAttachListener:Ma,_fnSortingClasses:wa,_fnSortData:Hb,_fnSaveState:xa,_fnLoadState:Jb,_fnSettingsFromNode:ya,_fnLog:K,_fnMap:F,_fnBindAction:Wa,_fnCallbackReg:z,_fnCallbackFire:r,_fnLengthOverflow:Sa,_fnRenderer:Na,_fnDataSource:y,_fnRowAttributes:La,_fnExtend:Xa,_fnCalculateEnd:function(){}});h.fn.dataTable=n;n.$=h;h.fn.dataTableSettings=n.settings;h.fn.dataTableExt=n.ext;h.fn.DataTable=function(a){return h(this).dataTable(a).api()}; -h.each(n,function(a,b){h.fn.DataTable[a]=b});return h.fn.dataTable}); - - -/*! - DataTables jQuery UI integration - ©2011-2014 SpryMedia Ltd - datatables.net/license -*/ -(function(a){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(b){return a(b,window,document)}):"object"===typeof exports?module.exports=function(b,d){b||(b=window);if(!d||!d.fn.dataTable)d=require("datatables.net")(b,d).$;return a(d,b,b.document)}:a(jQuery,window,document)})(function(a){var b=a.fn.dataTable;a.extend(!0,b.defaults,{dom:'<"fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix ui-corner-tl ui-corner-tr"lfr>t<"fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix ui-corner-bl ui-corner-br"ip>', -renderer:"jqueryui"});a.extend(b.ext.classes,{sWrapper:"dataTables_wrapper dt-jqueryui",sPageButton:"fg-button ui-button ui-state-default",sPageButtonActive:"ui-state-disabled",sPageButtonDisabled:"ui-state-disabled",sPaging:"dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi ui-buttonset-multi paging_",sSortAsc:"ui-state-default sorting_asc",sSortDesc:"ui-state-default sorting_desc",sSortable:"ui-state-default sorting",sSortableAsc:"ui-state-default sorting_asc_disabled",sSortableDesc:"ui-state-default sorting_desc_disabled", -sSortableNone:"ui-state-default sorting_disabled",sSortIcon:"DataTables_sort_icon",sScrollHead:"dataTables_scrollHead ui-state-default",sScrollFoot:"dataTables_scrollFoot ui-state-default",sHeaderTH:"ui-state-default",sFooterTH:"ui-state-default"});b.ext.renderer.header.jqueryui=function(b,h,e,c){var f="css_right ui-icon ui-icon-caret-2-n-s",g=-1!==a.inArray("asc",e.asSorting),i=-1!==a.inArray("desc",e.asSorting);!e.bSortable||!g&&!i?f="":g&&!i?f="css_right ui-icon ui-icon-caret-1-n":!g&&i&&(f="css_right ui-icon ui-icon-caret-1-s"); -a("
").addClass("DataTables_sort_wrapper").append(h.contents()).append(a("").addClass(c.sSortIcon+" "+f)).appendTo(h);a(b.nTable).on("order.dt",function(a,g,i,j){b===g&&(a=e.idx,h.removeClass(c.sSortAsc+" "+c.sSortDesc).addClass("asc"==j[a]?c.sSortAsc:"desc"==j[a]?c.sSortDesc:e.sSortingClass),h.find("span."+c.sSortIcon).removeClass("css_right ui-icon ui-icon-triangle-1-n css_right ui-icon ui-icon-triangle-1-s css_right ui-icon ui-icon-caret-2-n-s css_right ui-icon ui-icon-caret-1-n css_right ui-icon ui-icon-caret-1-s").addClass("asc"== -j[a]?"css_right ui-icon ui-icon-triangle-1-n":"desc"==j[a]?"css_right ui-icon ui-icon-triangle-1-s":f))})};b.TableTools&&a.extend(!0,b.TableTools.classes,{container:"DTTT_container ui-buttonset ui-buttonset-multi",buttons:{normal:"DTTT_button ui-button ui-state-default"},collection:{container:"DTTT_collection ui-buttonset ui-buttonset-multi"}});return b}); - - -/*! - Responsive 2.2.2 - 2014-2018 SpryMedia Ltd - datatables.net/license -*/ -(function(d){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(l){return d(l,window,document)}):"object"===typeof exports?module.exports=function(l,j){l||(l=window);if(!j||!j.fn.dataTable)j=require("datatables.net")(l,j).$;return d(j,l,l.document)}:d(jQuery,window,document)})(function(d,l,j,q){function t(a,b,c){var e=b+"-"+c;if(n[e])return n[e];for(var d=[],a=a.cell(b,c).node().childNodes,b=0,c=a.length;btd, >th", -e).each(function(e){e=b.column.index("toData",e);!1===a.s.current[e]&&d(this).css("display","none")})});b.on("destroy.dtr",function(){b.off(".dtr");d(b.table().body()).off(".dtr");d(l).off("resize.dtr orientationchange.dtr");d.each(a.s.current,function(b,e){!1===e&&a._setColumnVis(b,!0)})});this.c.breakpoints.sort(function(a,b){return a.widthb.width?-1:0});this._classLogic();this._resizeAuto();c=this.c.details;!1!==c.type&&(a._detailsInit(),b.on("column-visibility.dtr",function(){a._timer&& -clearTimeout(a._timer);a._timer=setTimeout(function(){a._timer=null;a._classLogic();a._resizeAuto();a._resize();a._redrawChildren()},100)}),b.on("draw.dtr",function(){a._redrawChildren()}),d(b.table().node()).addClass("dtr-"+c.type));b.on("column-reorder.dtr",function(){a._classLogic();a._resizeAuto();a._resize()});b.on("column-sizing.dtr",function(){a._resizeAuto();a._resize()});b.on("preXhr.dtr",function(){var e=[];b.rows().every(function(){this.child.isShown()&&e.push(this.id(true))});b.one("draw.dtr", -function(){a._resizeAuto();a._resize();b.rows(e).every(function(){a._detailsDisplay(this,false)})})});b.on("init.dtr",function(){a._resizeAuto();a._resize();d.inArray(false,a.s.current)&&b.columns.adjust()});this._resize()},_columnsVisiblity:function(a){var b=this.s.dt,c=this.s.columns,e,f,g=c.map(function(a,b){return{columnIdx:b,priority:a.priority}}).sort(function(a,b){return a.priority!==b.priority?a.priority-b.priority:a.columnIdx-b.columnIdx}),h=d.map(c,function(e,c){return!1===b.column(c).visible()? -"not-visible":e.auto&&null===e.minWidth?!1:!0===e.auto?"-":-1!==d.inArray(a,e.includeIn)}),m=0;e=0;for(f=h.length;em-c[k].minWidth?(s=!0,h[k]=!1):h[k]=!0,m-=c[k].minWidth)}g=!1;e=0;for(f=c.length;e=k&&f(d,b[c].name)}else{if("not-"===g){c=0;for(g=b.length;c").append(h).appendTo(f)}d("").append(g).appendTo(e);"inline"===this.c.details.type&&d(c).addClass("dtr-inline collapsed");d(c).find("[name]").removeAttr("name");d(c).css("position","relative"); -c=d("
").css({width:1,height:1,overflow:"hidden",clear:"both"}).append(c);c.insertBefore(a.table().node());g.each(function(c){c=a.column.index("fromVisible",c);b[c].minWidth=this.offsetWidth||0});c.remove()}},_setColumnVis:function(a,b){var c=this.s.dt,e=b?"":"none";d(c.column(a).header()).css("display",e);d(c.column(a).footer()).css("display",e);c.column(a).nodes().to$().css("display",e);d.isEmptyObject(n)||c.cells(null,a).indexes().each(function(a){r(c,a.row,a.column)})},_tabIndexes:function(){var a= -this.s.dt,b=a.cells({page:"current"}).nodes().to$(),c=a.settings()[0],e=this.c.details.target;b.filter("[data-dtr-keyboard]").removeData("[data-dtr-keyboard]");"number"===typeof e?a.cells(null,e,{page:"current"}).nodes().to$().attr("tabIndex",c.iTabIndex).data("dtr-keyboard",1):("td:first-child, th:first-child"===e&&(e=">td:first-child, >th:first-child"),d(e,a.rows({page:"current"}).nodes()).attr("tabIndex",c.iTabIndex).data("dtr-keyboard",1))}});i.breakpoints=[{name:"desktop",width:Infinity},{name:"tablet-l", -width:1024},{name:"tablet-p",width:768},{name:"mobile-l",width:480},{name:"mobile-p",width:320}];i.display={childRow:function(a,b,c){if(b){if(d(a.node()).hasClass("parent"))return a.child(c(),"child").show(),!0}else{if(a.child.isShown())return a.child(!1),d(a.node()).removeClass("parent"),!1;a.child(c(),"child").show();d(a.node()).addClass("parent");return!0}},childRowImmediate:function(a,b,c){if(!b&&a.child.isShown()||!a.responsive.hasHidden())return a.child(!1),d(a.node()).removeClass("parent"), -!1;a.child(c(),"child").show();d(a.node()).addClass("parent");return!0},modal:function(a){return function(b,c,e){if(c)d("div.dtr-modal-content").empty().append(e());else{var f=function(){g.remove();d(j).off("keypress.dtr")},g=d('
').append(d('
').append(d('
').append(e())).append(d('
×
').click(function(){f()}))).append(d('
').click(function(){f()})).appendTo("body"); -d(j).on("keyup.dtr",function(a){27===a.keyCode&&(a.stopPropagation(),f())})}a&&a.header&&d("div.dtr-modal-content").prepend("

"+a.header(b)+"

")}}};var n={};i.renderer={listHiddenNodes:function(){return function(a,b,c){var e=d('
' + - '' + - '
' - ); -} - - -$.widget("ui.plupload", { - - widgetEventPrefix: '', - - contents_bak: '', - - options: { - browse_button_hover: 'ui-state-hover', - browse_button_active: 'ui-state-active', - - filters: {}, - - // widget specific - buttons: { - browse: true, - start: true, - stop: true - }, - - views: { - list: true, - thumbs: false, - active: 'list', - remember: true // requires: https://github.com/carhartl/jquery-cookie, otherwise disabled even if set to true - }, - - thumb_width: 100, - thumb_height: 60, - - multiple_queues: true, // re-use widget by default - dragdrop : true, - autostart: false, - sortable: false, - rename: false - }, - - FILE_COUNT_ERROR: -9001, - - _create: function() { - var id = this.element.attr('id'); - if (!id) { - id = plupload.guid(); - this.element.attr('id', id); - } - this.id = id; - - // backup the elements initial state - this.contents_bak = this.element.html(); - renderUI(this.element); - - // container, just in case - this.container = $('.plupload_container', this.element).attr('id', id + '_container'); - - this.content = $('.plupload_content', this.element); - - if ($.fn.resizable) { - this.container.resizable({ - handles: 's', - minHeight: 300 - }); - } - - // list of files, may become sortable - this.filelist = $('.plupload_filelist_content', this.container) - .attr({ - id: id + '_filelist', - unselectable: 'on' - }); - - - // buttons - this.browse_button = $('.plupload_add', this.container).attr('id', id + '_browse'); - this.start_button = $('.plupload_start', this.container).attr('id', id + '_start'); - this.stop_button = $('.plupload_stop', this.container).attr('id', id + '_stop'); - this.thumbs_switcher = $('#' + id + '_view_thumbs'); - this.list_switcher = $('#' + id + '_view_list'); - - if ($.ui.button) { - this.browse_button.button({ - icons: { primary: 'ui-icon-circle-plus' }, - disabled: true - }); - - this.start_button.button({ - icons: { primary: 'ui-icon-circle-arrow-e' }, - disabled: true - }); - - this.stop_button.button({ - icons: { primary: 'ui-icon-circle-close' } - }); - - this.list_switcher.button({ - text: false, - icons: { secondary: "ui-icon-grip-dotted-horizontal" } - }); - - this.thumbs_switcher.button({ - text: false, - icons: { secondary: "ui-icon-image" } - }); - } - - // progressbar - this.progressbar = $('.plupload_progress_container', this.container); - - if ($.ui.progressbar) { - this.progressbar.progressbar(); - } - - // counter - this.counter = $('.plupload_count', this.element) - .attr({ - id: id + '_count', - name: id + '_count' - }); - - // initialize uploader instance - this._initUploader(); - }, - - _initUploader: function() { - var self = this - , id = this.id - , uploader - , options = { - container: id + '_buttons', - browse_button: id + '_browse', - required_features: {}, - filters: {} - } - ; - - $('.plupload_buttons', this.element).attr('id', id + '_buttons'); - - if (self.options.dragdrop) { - this.filelist.parent().attr('id', this.id + '_dropbox'); - options.drop_element = this.id + '_dropbox'; - } - - this.filelist.on('click', function(e) { - if ($(e.target).hasClass('plupload_action_icon')) { - self.removeFile($(e.target).closest('.plupload_file').attr('id')); - e.preventDefault(); - } - }); - - - if (self.options.views.thumbs) { - options.required_features.display_media = true; - } - - // for backward compatibility - if (self.options.max_file_count) { - options.filters.max_file_count = self.options.max_file_count - } - - uploader = this.uploader = uploaders[id] = new plupload.Uploader($.extend(this.options, options)); - - // retrieve full normalized set of options - this.options = uploader.getOption(); - - - plupload.addFileFilter('max_file_count', function(maxCount, file, cb) { - if (maxCount <= this.files.length - (this.total.uploaded + this.total.failed)) { - self.browse_button.button('disable'); - this.disableBrowse(); - - this.trigger('Error', { - code : self.FILE_COUNT_ERROR, - message : _("File count error."), - file : file - }); - cb(false); - } else { - cb(true); - } - }); - - - uploader.bind('Error', function(up, err) { - var message, details = ""; - - message = '' + err.message + ''; - - switch (err.code) { - case plupload.FILE_EXTENSION_ERROR: - details = plupload.sprintf(_("File: %s"), err.file.name); - break; - - case plupload.FILE_SIZE_ERROR: - details = plupload.sprintf(_("File: %s, size: %d, max file size: %d"), err.file.name, plupload.formatSize(err.file.size), plupload.formatSize(plupload.parseSize(up.getOption('filters').max_file_size))); - break; - - case plupload.FILE_DUPLICATE_ERROR: - details = plupload.sprintf(_("%s already present in the queue."), err.file.name); - break; - - case self.FILE_COUNT_ERROR: - details = plupload.sprintf(_("Upload element accepts only %d file(s) at a time. Extra files were stripped."), up.getOption('filters').max_file_count || 0); - break; - - case plupload.IMAGE_FORMAT_ERROR : - details = _("Image format either wrong or not supported."); - break; - - case plupload.IMAGE_MEMORY_ERROR : - details = _("Runtime ran out of available memory."); - break; - - /* // This needs a review - case plupload.IMAGE_DIMENSIONS_ERROR : - details = plupload.sprintf(_('Resoultion out of boundaries! %s runtime supports images only up to %wx%hpx.'), up.runtime, up.features.maxWidth, up.features.maxHeight); - break; */ - - case plupload.HTTP_ERROR: - details = _("Upload URL might be wrong or doesn't exist."); - break; - } - - message += "
" + details + ""; - - self._trigger('error', null, { up: up, error: err } ); - - // do not show UI if no runtime can be initialized - if (err.code === plupload.INIT_ERROR) { - setTimeout(function() { - self.destroy(); - }, 1); - } else { - self.notify('error', message); - } - }); - - - uploader.bind('PostInit', function(up) { - // all buttons are optional, so they can be disabled and hidden - if (!self.options.buttons.browse) { - self.browse_button.button('disable').hide(); - up.disableBrowse(true); - } else { - self.browse_button.button('enable'); - } - - if (!self.options.buttons.start) { - self.start_button.button('disable').hide(); - } - - if (!self.options.buttons.stop) { - self.stop_button.button('disable').hide(); - } - - if (!self.options.unique_names && self.options.rename) { - self._enableRenaming(); - } - - if (self.options.dragdrop && up.features.dragdrop) { - self.filelist.parent().addClass('plupload_dropbox'); - } - - self._enableViewSwitcher(); - - self.start_button.click(function(e) { - if (!$(this).button('option', 'disabled')) { - self.start(); - } - e.preventDefault(); - }); - - self.stop_button.click(function(e) { - self.stop(); - e.preventDefault(); - }); - - self._trigger('ready', null, { up: up }); - }); - - // uploader internal events must run first - uploader.init(); - - uploader.bind('FileFiltered', function(up, file) { - self._addFiles(file); - }); - - uploader.bind('FilesAdded', function(up, files) { - self._trigger('selected', null, { up: up, files: files } ); - - // re-enable sortable - if (self.options.sortable && $.ui.sortable) { - self._enableSortingList(); - } - - self._trigger('updatelist', null, { filelist: self.filelist }); - - if (self.options.autostart) { - // set a little delay to make sure that QueueChanged triggered by the core has time to complete - setTimeout(function() { - self.start(); - }, 10); - } - }); - - uploader.bind('FilesRemoved', function(up, files) { - // destroy sortable if enabled - if ($.ui.sortable && self.options.sortable) { - $('tbody', self.filelist).sortable('destroy'); - } - - $.each(files, function(i, file) { - $('#' + file.id).toggle("highlight", function() { - $(this).remove(); - }); - }); - - if (up.files.length) { - // re-initialize sortable - if (self.options.sortable && $.ui.sortable) { - self._enableSortingList(); - } - } - - self._trigger('updatelist', null, { filelist: self.filelist }); - self._trigger('removed', null, { up: up, files: files } ); - }); - - uploader.bind('QueueChanged', function() { - self._handleState(); - }); - - uploader.bind('StateChanged', function(up) { - self._handleState(); - if (plupload.STARTED === up.state) { - self._trigger('started', null, { up: this.uploader }); - } else if (plupload.STOPPED === up.state) { - self._trigger('stopped', null, { up: this.uploader }); - } - }); - - uploader.bind('UploadFile', function(up, file) { - self._handleFileStatus(file); - }); - - uploader.bind('FileUploaded', function(up, file, result) { - self._handleFileStatus(file); - self._trigger('uploaded', null, { up: up, file: file, result: result } ); - }); - - uploader.bind('UploadProgress', function(up, file) { - self._handleFileStatus(file); - self._updateTotalProgress(); - self._trigger('progress', null, { up: up, file: file } ); - }); - - uploader.bind('UploadComplete', function(up, files) { - self._addFormFields(); - self._trigger('complete', null, { up: up, files: files } ); - }); - }, - - - _setOption: function(key, value) { - var self = this; - - if (key == 'buttons' && typeof(value) == 'object') { - value = $.extend(self.options.buttons, value); - - if (!value.browse) { - self.browse_button.button('disable').hide(); - self.uploader.disableBrowse(true); - } else { - self.browse_button.button('enable').show(); - self.uploader.disableBrowse(false); - } - - if (!value.start) { - self.start_button.button('disable').hide(); - } else { - self.start_button.button('enable').show(); - } - - if (!value.stop) { - self.stop_button.button('disable').hide(); - } else { - self.start_button.button('enable').show(); - } - } - - self.uploader.setOption(key, value); - }, - - - /** - Start upload. Triggers `start` event. - - @method start - */ - start: function() { - this.uploader.start(); - }, - - - /** - Stop upload. Triggers `stop` event. - - @method stop - */ - stop: function() { - this.uploader.stop(); - }, - - - /** - Enable browse button. - - @method enable - */ - enable: function() { - this.browse_button.button('enable'); - this.uploader.disableBrowse(false); - }, - - - /** - Disable browse button. - - @method disable - */ - disable: function() { - this.browse_button.button('disable'); - this.uploader.disableBrowse(true); - }, - - - /** - Retrieve file by its unique id. - - @method getFile - @param {String} id Unique id of the file - @return {plupload.File} - */ - getFile: function(id) { - var file; - - if (typeof id === 'number') { - file = this.uploader.files[id]; - } else { - file = this.uploader.getFile(id); - } - return file; - }, - - /** - Return array of files currently in the queue. - - @method getFiles - @return {Array} Array of files in the queue represented by plupload.File objects - */ - getFiles: function() { - return this.uploader.files; - }, - - - /** - Remove the file from the queue. - - @method removeFile - @param {plupload.File|String} file File to remove, might be specified directly or by its unique id - */ - removeFile: function(file) { - if (plupload.typeOf(file) === 'string') { - file = this.getFile(file); - } - this.uploader.removeFile(file); - }, - - - /** - Clear the file queue. - - @method clearQueue - */ - clearQueue: function() { - this.uploader.splice(); - }, - - - /** - Retrieve internal plupload.Uploader object (usually not required). - - @method getUploader - @return {plupload.Uploader} - */ - getUploader: function() { - return this.uploader; - }, - - - /** - Trigger refresh procedure, specifically browse_button re-measure and re-position operations. - Might get handy, when UI Widget is placed within the popup, that is constantly hidden and shown - again - without calling this method after each show operation, dialog trigger might get displaced - and disfunctional. - - @method refresh - */ - refresh: function() { - this.uploader.refresh(); - }, - - - /** - Display a message in notification area. - - @method notify - @param {Enum} type Type of the message, either `error` or `info` - @param {String} message The text message to display. - */ - notify: function(type, message) { - var popup = $( - '
' + - '' + - '

' + message + '

' + - '
' - ); - - popup - .addClass('ui-state-' + (type === 'error' ? 'error' : 'highlight')) - .find('p .ui-icon') - .addClass('ui-icon-' + (type === 'error' ? 'alert' : 'info')) - .end() - .find('.plupload_message_close') - .click(function() { - popup.remove(); - }) - .end(); - - $('.plupload_header', this.container).append(popup); - }, - - - /** - Destroy the widget, the uploader, free associated resources and bring back original html. - - @method destroy - */ - destroy: function() { - // destroy uploader instance - this.uploader.destroy(); - - // unbind all button events - $('.plupload_button', this.element).unbind(); - - // destroy buttons - if ($.ui.button) { - $('.plupload_add, .plupload_start, .plupload_stop', this.container) - .button('destroy'); - } - - // destroy progressbar - if ($.ui.progressbar) { - this.progressbar.progressbar('destroy'); - } - - // destroy sortable behavior - if ($.ui.sortable && this.options.sortable) { - $('tbody', this.filelist).sortable('destroy'); - } - - // restore the elements initial state - this.element - .empty() - .html(this.contents_bak); - this.contents_bak = ''; - - $.Widget.prototype.destroy.apply(this); - }, - - - _handleState: function() { - var up = this.uploader - , filesPending = up.files.length - (up.total.uploaded + up.total.failed) - , maxCount = up.getOption('filters').max_file_count || 0 - ; - - if (plupload.STARTED === up.state) { - $([]) - .add(this.stop_button) - .add('.plupload_started') - .removeClass('plupload_hidden'); - - this.start_button.button('disable'); - - if (!this.options.multiple_queues) { - this.browse_button.button('disable'); - up.disableBrowse(); - } - - $('.plupload_upload_status', this.element).html(plupload.sprintf(_('Uploaded %d/%d files'), up.total.uploaded, up.files.length)); - $('.plupload_header_content', this.element).addClass('plupload_header_content_bw'); - } - else if (plupload.STOPPED === up.state) { - $([]) - .add(this.stop_button) - .add('.plupload_started') - .addClass('plupload_hidden'); - - if (filesPending) { - this.start_button.button('enable'); - } else { - this.start_button.button('disable'); - } - - if (this.options.multiple_queues) { - $('.plupload_header_content', this.element).removeClass('plupload_header_content_bw'); - } - - // if max_file_count defined, only that many files can be queued at once - if (this.options.multiple_queues && maxCount && maxCount > filesPending) { - this.browse_button.button('enable'); - up.disableBrowse(false); - } - - // have a helper class on a container expressing whether it has files queued or not - this.container.toggleClass('plupload_files_queued', up.files.length); - - this._updateTotalProgress(); - } - - if (up.total.queued === 0) { - $('.ui-button-text', this.browse_button).html(_('Add Files')); - } else { - $('.ui-button-text', this.browse_button).html(plupload.sprintf(_('%d files queued'), up.total.queued)); - } - - up.refresh(); - }, - - - _handleFileStatus: function(file) { - var $file = $('#' + file.id), actionClass, iconClass; - - // since this method might be called asynchronously, file row might not yet be rendered - if (!$file.length) { - return; - } - - switch (file.status) { - case plupload.DONE: - actionClass = 'plupload_done'; - iconClass = 'plupload_action_icon ui-icon ui-icon-circle-check'; - break; - - case plupload.FAILED: - actionClass = 'ui-state-error plupload_failed'; - iconClass = 'plupload_action_icon ui-icon ui-icon-alert'; - break; - - case plupload.QUEUED: - actionClass = 'plupload_delete'; - iconClass = 'plupload_action_icon ui-icon ui-icon-circle-minus'; - break; - - case plupload.UPLOADING: - actionClass = 'ui-state-highlight plupload_uploading'; - iconClass = 'plupload_action_icon ui-icon ui-icon-circle-arrow-w'; - - // scroll uploading file into the view if its bottom boundary is out of it - var scroller = $('.plupload_scroll', this.container) - , scrollTop = scroller.scrollTop() - , scrollerHeight = scroller.height() - , rowOffset = $file.position().top + $file.height() - ; - - if (scrollerHeight < rowOffset) { - scroller.scrollTop(scrollTop + rowOffset - scrollerHeight); - } - - // Set file specific progress - $file - .find('.plupload_file_percent') - .html(file.percent + '%') - .end() - .find('.plupload_file_progress') - .css('width', file.percent + '%') - .end() - .find('.plupload_file_size') - .html(plupload.formatSize(file.size)); - break; - } - actionClass += ' ui-state-default plupload_file'; - - $file - .attr('class', actionClass) - .find('.plupload_action_icon') - .attr('class', iconClass); - }, - - - _updateTotalProgress: function() { - var up = this.uploader; - - // Scroll to end of file list - this.filelist[0].scrollTop = this.filelist[0].scrollHeight; - - this.progressbar.progressbar('value', up.total.percent); - - this.element - .find('.plupload_total_status') - .html(up.total.percent + '%') - .end() - .find('.plupload_total_file_size') - .html(plupload.formatSize(up.total.size)) - .end() - .find('.plupload_upload_status') - .html(plupload.sprintf(_('Uploaded %d/%d files'), up.total.uploaded, up.files.length)); - }, - - - _displayThumbs: function() { - var self = this - , tw, th // thumb width/height - , cols - , num = 0 // number of simultaneously visible thumbs - , thumbs = [] // array of thumbs to preload at any given moment - , loading = false - ; - - if (!this.options.views.thumbs) { - return; - } - - - function onLast(el, eventName, cb) { - var timer; - - el.on(eventName, function() { - clearTimeout(timer); - timer = setTimeout(function() { - clearTimeout(timer); - cb(); - }, 300); - }); - } - - - // calculate number of simultaneously visible thumbs - function measure() { - if (!tw || !th) { - var wrapper = $('.plupload_file:eq(0)', self.filelist); - tw = wrapper.outerWidth(true); - th = wrapper.outerHeight(true); - } - - var aw = self.content.width(), ah = self.content.height(); - cols = Math.floor(aw / tw); - num = cols * (Math.ceil(ah / th) + 1); - } - - - function pickThumbsToLoad() { - // calculate index of virst visible thumb - var startIdx = Math.floor(self.content.scrollTop() / th) * cols; - // get potentially visible thumbs that are not yet visible - thumbs = $('.plupload_file .plupload_file_thumb', self.filelist) - .slice(startIdx, startIdx + num) - .filter('.plupload_thumb_toload') - .get(); - } - - - function init() { - function mpl() { // measure, pick, load - if (self.view_mode !== 'thumbs') { - return; - } - measure(); - pickThumbsToLoad(); - lazyLoad(); - } - - if ($.fn.resizable) { - onLast(self.container, 'resize', mpl); - } - - onLast(self.window, 'resize', mpl); - onLast(self.content, 'scroll', mpl); - - self.element.on('viewchanged selected', mpl); - - mpl(); - } - - - function preloadThumb(file, cb) { - var img = new plupload.Image(); - - img.onload = function() { - var thumb = $('#' + file.id + ' .plupload_file_thumb', self.filelist); - this.embed(thumb[0], { - width: self.options.thumb_width, - height: self.options.thumb_height, - crop: true, - fit: true, - preserveHeaders: false, - swf_url: plupload.resolveUrl(self.options.flash_swf_url), - xap_url: plupload.resolveUrl(self.options.silverlight_xap_url) - }); - }; - - img.bind("embedded error", function(e) { - $('#' + file.id, self.filelist) - .find('.plupload_file_thumb') - .removeClass('plupload_thumb_loading') - .addClass('plupload_thumb_' + e.type) - ; - this.destroy(); - setTimeout(cb, 1); // detach, otherwise ui might hang (in SilverLight for example) - }); - - $('#' + file.id, self.filelist) - .find('.plupload_file_thumb') - .removeClass('plupload_thumb_toload') - .addClass('plupload_thumb_loading') - ; - img.load(file.getSource()); - } - - - function lazyLoad() { - if (self.view_mode !== 'thumbs' || loading) { - return; - } - - pickThumbsToLoad(); - if (!thumbs.length) { - return; - } - - loading = true; - - preloadThumb(self.getFile($(thumbs.shift()).closest('.plupload_file').attr('id')), function() { - loading = false; - lazyLoad(); - }); - } - - // this has to run only once to measure structures and bind listeners - this.element.on('selected', function onselected() { - self.element.off('selected', onselected); - init(); - }); - }, - - - _addFiles: function(files) { - var self = this, file_html, html = ''; - - file_html = '
  • ' + - '
    ' + - '
    {ext}
    ' + - '
    ' + - '
    ' + - '
    ' + - '{percent} ' + - '
    ' + - '
    ' + - '{name} ' + - '
    ' + - '
    ' + - '
    ' + - '
    ' + - '
    {size}
    ' + - '
    ' + - '
  • '; - - if (plupload.typeOf(files) !== 'array') { - files = [files]; - } - - $.each(files, function(i, file) { - var m = file.name.match(/\.([^.]+)$/); - var ext = m && m[1].toLowerCase() || 'none'; - - html += file_html.replace(/\{(\w+)\}/g, function($0, $1) { - switch ($1) { - case 'thumb_width': - case 'thumb_height': - return self.options[$1]; - - case 'size': - return plupload.formatSize(file.size); - - case 'ext': - return ext; - - default: - return file[$1] || ''; - } - }); - }); - - self.filelist.append(html); - }, - - - _addFormFields: function() { - var self = this; - - // re-add from fresh - $('.plupload_file_fields', this.filelist).html(''); - - plupload.each(this.uploader.files, function(file, count) { - var fields = '' - , id = self.id + '_' + count - ; - - if (file.target_name) { - fields += ''; - } - fields += ''; - fields += ''; - - $('#' + file.id).find('.plupload_file_fields').html(fields); - }); - - this.counter.val(this.uploader.files.length); - }, - - - _viewChanged: function(view) { - // update or write a new cookie - if (this.options.views.remember && $.cookie) { - $.cookie('plupload_ui_view', view, { expires: 7, path: '/' }); - } - - // ugly fix for IE6 - make content area stretchable - if (plupload.ua.browser === 'IE' && plupload.ua.version < 7) { - this.content.attr('style', 'height:expression(document.getElementById("' + this.id + '_container' + '").clientHeight - ' + (view === 'list' ? 132 : 102) + ')'); - } - - this.container.removeClass('plupload_view_list plupload_view_thumbs').addClass('plupload_view_' + view); - this.view_mode = view; - this._trigger('viewchanged', null, { view: view }); - }, - - - _enableViewSwitcher: function() { - var self = this - , view - , switcher = $('.plupload_view_switch', this.container) - , buttons - , button - ; - - plupload.each(['list', 'thumbs'], function(view) { - if (!self.options.views[view]) { - switcher.find('[for="' + self.id + '_view_' + view + '"], #'+ self.id +'_view_' + view).remove(); - } - }); - - // check if any visible left - buttons = switcher.find('.plupload_button'); - - if (buttons.length === 1) { - switcher.hide(); - view = buttons.eq(0).data('view'); - this._viewChanged(view); - } else if ($.ui.button && buttons.length > 1) { - if (this.options.views.remember && $.cookie) { - view = $.cookie('plupload_ui_view'); - } - - // if wierd case, bail out to default - if (!~plupload.inArray(view, ['list', 'thumbs'])) { - view = this.options.views.active; - } - - switcher - .show() - .buttonset() - .find('.ui-button') - .click(function(e) { - view = $(this).data('view'); - self._viewChanged(view); - e.preventDefault(); // avoid auto scrolling to widget in IE and FF (see #850) - }); - - // if view not active - happens when switcher wasn't clicked manually - button = switcher.find('[for="' + self.id + '_view_'+view+'"]'); - if (button.length) { - button.trigger('click'); - } - } else { - switcher.show(); - this._viewChanged(this.options.views.active); - } - - // initialize thumb viewer if requested - if (this.options.views.thumbs) { - this._displayThumbs(); - } - }, - - - _enableRenaming: function() { - var self = this; - - this.filelist.dblclick(function(e) { - var nameSpan = $(e.target), nameInput, file, parts, name, ext = ""; - - if (!nameSpan.hasClass('plupload_file_name_wrapper')) { - return; - } - - // Get file name and split out name and extension - file = self.uploader.getFile(nameSpan.closest('.plupload_file')[0].id); - name = file.name; - parts = /^(.+)(\.[^.]+)$/.exec(name); - if (parts) { - name = parts[1]; - ext = parts[2]; - } - - // Display input element - nameInput = $('').width(nameSpan.width()).insertAfter(nameSpan.hide()); - nameInput.val(name).blur(function() { - nameSpan.show().parent().scrollLeft(0).end().next().remove(); - }).keydown(function(e) { - var nameInput = $(this); - - if ($.inArray(e.keyCode, [13, 27]) !== -1) { - e.preventDefault(); - - // Rename file and glue extension back on - if (e.keyCode === 13) { - file.name = nameInput.val() + ext; - nameSpan.html(file.name); - } - nameInput.blur(); - } - })[0].focus(); - }); - }, - - - _enableSortingList: function() { - var self = this; - - if ($('.plupload_file', this.filelist).length < 2) { - return; - } - - // destroy sortable if enabled - $('tbody', this.filelist).sortable('destroy'); - - // enable - this.filelist.sortable({ - items: '.plupload_delete', - - cancel: 'object, .plupload_clearer', - - stop: function() { - var files = []; - - $.each($(this).sortable('toArray'), function(i, id) { - files[files.length] = self.uploader.getFile(id); - }); - - files.unshift(files.length); - files.unshift(0); - - // re-populate files array - Array.prototype.splice.apply(self.uploader.files, files); - } - }); - } -}); - -} (window, document, plupload, jQuery)); diff --git a/assets/javascripts/plupload/js/jquery.ui.plupload/jquery.ui.plupload.min.js b/assets/javascripts/plupload/js/jquery.ui.plupload/jquery.ui.plupload.min.js deleted file mode 100644 index 8bd9a2f3..00000000 --- a/assets/javascripts/plupload/js/jquery.ui.plupload/jquery.ui.plupload.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(t,e,i,s){function n(t){return i.translate(t)||t}function o(t){t.id=t.attr("id"),t.html('
    '+n("Select files")+"
    "+'
    '+n("Add files to the upload queue and click the start button.")+"
    "+'
    '+'"+'"+"
    "+"
    "+"
    "+''+""+'"+'"+'"+''+""+"
    '+n("Filename")+"'+n("Status")+"'+n("Size")+" 
    "+'
    '+'
    '+n("Drag files here.")+"
    "+'
    '+'
     
    '+"
    "+''+""+'"+''+''+''+""+""+"
    "+''+"
    ")}var a={};s.widget("ui.plupload",{widgetEventPrefix:"",contents_bak:"",options:{browse_button_hover:"ui-state-hover",browse_button_active:"ui-state-active",filters:{},buttons:{browse:!0,start:!0,stop:!0},views:{list:!0,thumbs:!1,active:"list",remember:!0},thumb_width:100,thumb_height:60,multiple_queues:!0,dragdrop:!0,autostart:!1,sortable:!1,rename:!1},FILE_COUNT_ERROR:-9001,_create:function(){var t=this.element.attr("id");t||(t=i.guid(),this.element.attr("id",t)),this.id=t,this.contents_bak=this.element.html(),o(this.element),this.container=s(".plupload_container",this.element).attr("id",t+"_container"),this.content=s(".plupload_content",this.element),s.fn.resizable&&this.container.resizable({handles:"s",minHeight:300}),this.filelist=s(".plupload_filelist_content",this.container).attr({id:t+"_filelist",unselectable:"on"}),this.browse_button=s(".plupload_add",this.container).attr("id",t+"_browse"),this.start_button=s(".plupload_start",this.container).attr("id",t+"_start"),this.stop_button=s(".plupload_stop",this.container).attr("id",t+"_stop"),this.thumbs_switcher=s("#"+t+"_view_thumbs"),this.list_switcher=s("#"+t+"_view_list"),s.ui.button&&(this.browse_button.button({icons:{primary:"ui-icon-circle-plus"},disabled:!0}),this.start_button.button({icons:{primary:"ui-icon-circle-arrow-e"},disabled:!0}),this.stop_button.button({icons:{primary:"ui-icon-circle-close"}}),this.list_switcher.button({text:!1,icons:{secondary:"ui-icon-grip-dotted-horizontal"}}),this.thumbs_switcher.button({text:!1,icons:{secondary:"ui-icon-image"}})),this.progressbar=s(".plupload_progress_container",this.container),s.ui.progressbar&&this.progressbar.progressbar(),this.counter=s(".plupload_count",this.element).attr({id:t+"_count",name:t+"_count"}),this._initUploader()},_initUploader:function(){var t,e=this,o=this.id,r={container:o+"_buttons",browse_button:o+"_browse",required_features:{},filters:{}};s(".plupload_buttons",this.element).attr("id",o+"_buttons"),e.options.dragdrop&&(this.filelist.parent().attr("id",this.id+"_dropbox"),r.drop_element=this.id+"_dropbox"),this.filelist.on("click",function(t){s(t.target).hasClass("plupload_action_icon")&&(e.removeFile(s(t.target).closest(".plupload_file").attr("id")),t.preventDefault())}),e.options.views.thumbs&&(r.required_features.display_media=!0),e.options.max_file_count&&(r.filters.max_file_count=e.options.max_file_count),t=this.uploader=a[o]=new i.Uploader(s.extend(this.options,r)),this.options=t.getOption(),i.addFileFilter("max_file_count",function(t,i,s){t<=this.files.length-(this.total.uploaded+this.total.failed)?(e.browse_button.button("disable"),this.disableBrowse(),this.trigger("Error",{code:e.FILE_COUNT_ERROR,message:n("File count error."),file:i}),s(!1)):s(!0)}),t.bind("Error",function(t,s){var o,a="";switch(o=""+s.message+"",s.code){case i.FILE_EXTENSION_ERROR:a=i.sprintf(n("File: %s"),s.file.name);break;case i.FILE_SIZE_ERROR:a=i.sprintf(n("File: %s, size: %d, max file size: %d"),s.file.name,i.formatSize(s.file.size),i.formatSize(i.parseSize(t.getOption("filters").max_file_size)));break;case i.FILE_DUPLICATE_ERROR:a=i.sprintf(n("%s already present in the queue."),s.file.name);break;case e.FILE_COUNT_ERROR:a=i.sprintf(n("Upload element accepts only %d file(s) at a time. Extra files were stripped."),t.getOption("filters").max_file_count||0);break;case i.IMAGE_FORMAT_ERROR:a=n("Image format either wrong or not supported.");break;case i.IMAGE_MEMORY_ERROR:a=n("Runtime ran out of available memory.");break;case i.HTTP_ERROR:a=n("Upload URL might be wrong or doesn't exist.")}o+="
    "+a+"",e._trigger("error",null,{up:t,error:s}),s.code===i.INIT_ERROR?setTimeout(function(){e.destroy()},1):e.notify("error",o)}),t.bind("PostInit",function(t){e.options.buttons.browse?e.browse_button.button("enable"):(e.browse_button.button("disable").hide(),t.disableBrowse(!0)),e.options.buttons.start||e.start_button.button("disable").hide(),e.options.buttons.stop||e.stop_button.button("disable").hide(),!e.options.unique_names&&e.options.rename&&e._enableRenaming(),e.options.dragdrop&&t.features.dragdrop&&e.filelist.parent().addClass("plupload_dropbox"),e._enableViewSwitcher(),e.start_button.click(function(t){s(this).button("option","disabled")||e.start(),t.preventDefault()}),e.stop_button.click(function(t){e.stop(),t.preventDefault()}),e._trigger("ready",null,{up:t})}),t.init(),t.bind("FileFiltered",function(t,i){e._addFiles(i)}),t.bind("FilesAdded",function(t,i){e._trigger("selected",null,{up:t,files:i}),e.options.sortable&&s.ui.sortable&&e._enableSortingList(),e._trigger("updatelist",null,{filelist:e.filelist}),e.options.autostart&&setTimeout(function(){e.start()},10)}),t.bind("FilesRemoved",function(t,i){s.ui.sortable&&e.options.sortable&&s("tbody",e.filelist).sortable("destroy"),s.each(i,function(t,e){s("#"+e.id).toggle("highlight",function(){s(this).remove()})}),t.files.length&&e.options.sortable&&s.ui.sortable&&e._enableSortingList(),e._trigger("updatelist",null,{filelist:e.filelist}),e._trigger("removed",null,{up:t,files:i})}),t.bind("QueueChanged",function(){e._handleState()}),t.bind("StateChanged",function(t){e._handleState(),i.STARTED===t.state?e._trigger("started",null,{up:this.uploader}):i.STOPPED===t.state&&e._trigger("stopped",null,{up:this.uploader})}),t.bind("UploadFile",function(t,i){e._handleFileStatus(i)}),t.bind("FileUploaded",function(t,i,s){e._handleFileStatus(i),e._trigger("uploaded",null,{up:t,file:i,result:s})}),t.bind("UploadProgress",function(t,i){e._handleFileStatus(i),e._updateTotalProgress(),e._trigger("progress",null,{up:t,file:i})}),t.bind("UploadComplete",function(t,i){e._addFormFields(),e._trigger("complete",null,{up:t,files:i})})},_setOption:function(t,e){var i=this;"buttons"==t&&"object"==typeof e&&(e=s.extend(i.options.buttons,e),e.browse?(i.browse_button.button("enable").show(),i.uploader.disableBrowse(!1)):(i.browse_button.button("disable").hide(),i.uploader.disableBrowse(!0)),e.start?i.start_button.button("enable").show():i.start_button.button("disable").hide(),e.stop?i.start_button.button("enable").show():i.stop_button.button("disable").hide()),i.uploader.setOption(t,e)},start:function(){this.uploader.start()},stop:function(){this.uploader.stop()},enable:function(){this.browse_button.button("enable"),this.uploader.disableBrowse(!1)},disable:function(){this.browse_button.button("disable"),this.uploader.disableBrowse(!0)},getFile:function(t){var e;return e="number"==typeof t?this.uploader.files[t]:this.uploader.getFile(t)},getFiles:function(){return this.uploader.files},removeFile:function(t){"string"===i.typeOf(t)&&(t=this.getFile(t)),this.uploader.removeFile(t)},clearQueue:function(){this.uploader.splice()},getUploader:function(){return this.uploader},refresh:function(){this.uploader.refresh()},notify:function(t,e){var i=s('
    '+'

    '+e+"

    "+"
    ");i.addClass("ui-state-"+("error"===t?"error":"highlight")).find("p .ui-icon").addClass("ui-icon-"+("error"===t?"alert":"info")).end().find(".plupload_message_close").click(function(){i.remove()}).end(),s(".plupload_header",this.container).append(i)},destroy:function(){this.uploader.destroy(),s(".plupload_button",this.element).unbind(),s.ui.button&&s(".plupload_add, .plupload_start, .plupload_stop",this.container).button("destroy"),s.ui.progressbar&&this.progressbar.progressbar("destroy"),s.ui.sortable&&this.options.sortable&&s("tbody",this.filelist).sortable("destroy"),this.element.empty().html(this.contents_bak),this.contents_bak="",s.Widget.prototype.destroy.apply(this)},_handleState:function(){var t=this.uploader,e=t.files.length-(t.total.uploaded+t.total.failed),o=t.getOption("filters").max_file_count||0;i.STARTED===t.state?(s([]).add(this.stop_button).add(".plupload_started").removeClass("plupload_hidden"),this.start_button.button("disable"),this.options.multiple_queues||(this.browse_button.button("disable"),t.disableBrowse()),s(".plupload_upload_status",this.element).html(i.sprintf(n("Uploaded %d/%d files"),t.total.uploaded,t.files.length)),s(".plupload_header_content",this.element).addClass("plupload_header_content_bw")):i.STOPPED===t.state&&(s([]).add(this.stop_button).add(".plupload_started").addClass("plupload_hidden"),e?this.start_button.button("enable"):this.start_button.button("disable"),this.options.multiple_queues&&s(".plupload_header_content",this.element).removeClass("plupload_header_content_bw"),this.options.multiple_queues&&o&&o>e&&(this.browse_button.button("enable"),t.disableBrowse(!1)),this.container.toggleClass("plupload_files_queued",t.files.length),this._updateTotalProgress()),0===t.total.queued?s(".ui-button-text",this.browse_button).html(n("Add Files")):s(".ui-button-text",this.browse_button).html(i.sprintf(n("%d files queued"),t.total.queued)),t.refresh()},_handleFileStatus:function(t){var e,n,o=s("#"+t.id);if(o.length){switch(t.status){case i.DONE:e="plupload_done",n="plupload_action_icon ui-icon ui-icon-circle-check";break;case i.FAILED:e="ui-state-error plupload_failed",n="plupload_action_icon ui-icon ui-icon-alert";break;case i.QUEUED:e="plupload_delete",n="plupload_action_icon ui-icon ui-icon-circle-minus";break;case i.UPLOADING:e="ui-state-highlight plupload_uploading",n="plupload_action_icon ui-icon ui-icon-circle-arrow-w";var a=s(".plupload_scroll",this.container),r=a.scrollTop(),l=a.height(),u=o.position().top+o.height();u>l&&a.scrollTop(r+u-l),o.find(".plupload_file_percent").html(t.percent+"%").end().find(".plupload_file_progress").css("width",t.percent+"%").end().find(".plupload_file_size").html(i.formatSize(t.size))}e+=" ui-state-default plupload_file",o.attr("class",e).find(".plupload_action_icon").attr("class",n)}},_updateTotalProgress:function(){var t=this.uploader;this.filelist[0].scrollTop=this.filelist[0].scrollHeight,this.progressbar.progressbar("value",t.total.percent),this.element.find(".plupload_total_status").html(t.total.percent+"%").end().find(".plupload_total_file_size").html(i.formatSize(t.total.size)).end().find(".plupload_upload_status").html(i.sprintf(n("Uploaded %d/%d files"),t.total.uploaded,t.files.length))},_displayThumbs:function(){function t(t,e,i){var s;t.on(e,function(){clearTimeout(s),s=setTimeout(function(){clearTimeout(s),i()},300)})}function e(){if(!l||!u){var t=s(".plupload_file:eq(0)",p.filelist);l=t.outerWidth(!0),u=t.outerHeight(!0)}var e=p.content.width(),i=p.content.height();d=Math.floor(e/l),c=d*(Math.ceil(i/u)+1)}function n(){var t=Math.floor(p.content.scrollTop()/u)*d;h=s(".plupload_file .plupload_file_thumb",p.filelist).slice(t,t+c).filter(".plupload_thumb_toload").get()}function o(){function i(){"thumbs"===p.view_mode&&(e(),n(),r())}s.fn.resizable&&t(p.container,"resize",i),t(p.window,"resize",i),t(p.content,"scroll",i),p.element.on("viewchanged selected",i),i()}function a(t,e){var n=new i.Image;n.onload=function(){var e=s("#"+t.id+" .plupload_file_thumb",p.filelist);this.embed(e[0],{width:p.options.thumb_width,height:p.options.thumb_height,crop:!0,fit:!0,preserveHeaders:!1,swf_url:i.resolveUrl(p.options.flash_swf_url),xap_url:i.resolveUrl(p.options.silverlight_xap_url)})},n.bind("embedded error",function(i){s("#"+t.id,p.filelist).find(".plupload_file_thumb").removeClass("plupload_thumb_loading").addClass("plupload_thumb_"+i.type),this.destroy(),setTimeout(e,1)}),s("#"+t.id,p.filelist).find(".plupload_file_thumb").removeClass("plupload_thumb_toload").addClass("plupload_thumb_loading"),n.load(t.getSource())}function r(){"thumbs"!==p.view_mode||f||(n(),h.length&&(f=!0,a(p.getFile(s(h.shift()).closest(".plupload_file").attr("id")),function(){f=!1,r()})))}var l,u,d,p=this,c=0,h=[],f=!1;this.options.views.thumbs&&this.element.on("selected",function _(){p.element.off("selected",_),o()})},_addFiles:function(t){var e,n=this,o="";e='
  • {ext}
    {percent}
    {name}
    {size}
  • ',"array"!==i.typeOf(t)&&(t=[t]),s.each(t,function(t,s){var a=s.name.match(/\.([^.]+)$/),r=a&&a[1].toLowerCase()||"none";o+=e.replace(/\{(\w+)\}/g,function(t,e){switch(e){case"thumb_width":case"thumb_height":return n.options[e];case"size":return i.formatSize(s.size);case"ext":return r;default:return s[e]||""}})}),n.filelist.append(o)},_addFormFields:function(){var t=this;s(".plupload_file_fields",this.filelist).html(""),i.each(this.uploader.files,function(e,n){var o="",a=t.id+"_"+n;e.target_name&&(o+=''),o+='',o+='',s("#"+e.id).find(".plupload_file_fields").html(o)}),this.counter.val(this.uploader.files.length)},_viewChanged:function(t){this.options.views.remember&&s.cookie&&s.cookie("plupload_ui_view",t,{expires:7,path:"/"}),"IE"===i.ua.browser&&i.ua.version<7&&this.content.attr("style",'height:expression(document.getElementById("'+this.id+"_container"+'").clientHeight - '+("list"===t?132:102)+")"),this.container.removeClass("plupload_view_list plupload_view_thumbs").addClass("plupload_view_"+t),this.view_mode=t,this._trigger("viewchanged",null,{view:t})},_enableViewSwitcher:function(){var t,e,n,o=this,a=s(".plupload_view_switch",this.container);i.each(["list","thumbs"],function(t){o.options.views[t]||a.find('[for="'+o.id+"_view_"+t+'"], #'+o.id+"_view_"+t).remove()}),e=a.find(".plupload_button"),1===e.length?(a.hide(),t=e.eq(0).data("view"),this._viewChanged(t)):s.ui.button&&e.length>1?(this.options.views.remember&&s.cookie&&(t=s.cookie("plupload_ui_view")),~i.inArray(t,["list","thumbs"])||(t=this.options.views.active),a.show().buttonset().find(".ui-button").click(function(e){t=s(this).data("view"),o._viewChanged(t),e.preventDefault()}),n=a.find('[for="'+o.id+"_view_"+t+'"]'),n.length&&n.trigger("click")):(a.show(),this._viewChanged(this.options.views.active)),this.options.views.thumbs&&this._displayThumbs()},_enableRenaming:function(){var t=this;this.filelist.dblclick(function(e){var i,n,o,a,r=s(e.target),l="";r.hasClass("plupload_file_name_wrapper")&&(n=t.uploader.getFile(r.closest(".plupload_file")[0].id),a=n.name,o=/^(.+)(\.[^.]+)$/.exec(a),o&&(a=o[1],l=o[2]),i=s('').width(r.width()).insertAfter(r.hide()),i.val(a).blur(function(){r.show().parent().scrollLeft(0).end().next().remove()}).keydown(function(t){var e=s(this);-1!==s.inArray(t.keyCode,[13,27])&&(t.preventDefault(),13===t.keyCode&&(n.name=e.val()+l,r.html(n.name)),e.blur())})[0].focus())})},_enableSortingList:function(){var t=this;s(".plupload_file",this.filelist).length<2||(s("tbody",this.filelist).sortable("destroy"),this.filelist.sortable({items:".plupload_delete",cancel:"object, .plupload_clearer",stop:function(){var e=[];s.each(s(this).sortable("toArray"),function(i,s){e[e.length]=t.uploader.getFile(s)}),e.unshift(e.length),e.unshift(0),Array.prototype.splice.apply(t.uploader.files,e)}}))}})}(window,document,plupload,jQuery); \ No newline at end of file diff --git a/assets/javascripts/plupload/js/moxie.js b/assets/javascripts/plupload/js/moxie.js deleted file mode 100644 index 87625fdf..00000000 --- a/assets/javascripts/plupload/js/moxie.js +++ /dev/null @@ -1,11718 +0,0 @@ -;var MXI_DEBUG = true; -/** - * mOxie - multi-runtime File API & XMLHttpRequest L2 Polyfill - * v1.5.8 - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - * - * Date: 2018-02-19 - */ -;(function (global, factory) { - var extract = function() { - var ctx = {}; - factory.apply(ctx, arguments); - return ctx.moxie; - }; - - if (typeof define === "function" && define.amd) { - define("moxie", [], extract); - } else if (typeof module === "object" && module.exports) { - module.exports = extract(); - } else { - global.moxie = extract(); - } -}(this || window, function() { -/** - * Compiled inline version. (Library mode) - */ - -/*jshint smarttabs:true, undef:true, latedef:true, curly:true, bitwise:true, camelcase:true */ -/*globals $code */ - -(function(exports, undefined) { - "use strict"; - - var modules = {}; - - function require(ids, callback) { - var module, defs = []; - - for (var i = 0; i < ids.length; ++i) { - module = modules[ids[i]] || resolve(ids[i]); - if (!module) { - throw 'module definition dependecy not found: ' + ids[i]; - } - - defs.push(module); - } - - callback.apply(null, defs); - } - - function define(id, dependencies, definition) { - if (typeof id !== 'string') { - throw 'invalid module definition, module id must be defined and be a string'; - } - - if (dependencies === undefined) { - throw 'invalid module definition, dependencies must be specified'; - } - - if (definition === undefined) { - throw 'invalid module definition, definition function must be specified'; - } - - require(dependencies, function() { - modules[id] = definition.apply(null, arguments); - }); - } - - function defined(id) { - return !!modules[id]; - } - - function resolve(id) { - var target = exports; - var fragments = id.split(/[.\/]/); - - for (var fi = 0; fi < fragments.length; ++fi) { - if (!target[fragments[fi]]) { - return; - } - - target = target[fragments[fi]]; - } - - return target; - } - - function expose(ids) { - for (var i = 0; i < ids.length; i++) { - var target = exports; - var id = ids[i]; - var fragments = id.split(/[.\/]/); - - for (var fi = 0; fi < fragments.length - 1; ++fi) { - if (target[fragments[fi]] === undefined) { - target[fragments[fi]] = {}; - } - - target = target[fragments[fi]]; - } - - target[fragments[fragments.length - 1]] = modules[id]; - } - } - -// Included from: src/javascript/core/utils/Basic.js - -/** - * Basic.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/core/utils/Basic -@public -@static -*/ - -define('moxie/core/utils/Basic', [], function() { - /** - Gets the true type of the built-in object (better version of typeof). - @author Angus Croll (http://javascriptweblog.wordpress.com/) - - @method typeOf - @static - @param {Object} o Object to check. - @return {String} Object [[Class]] - */ - function typeOf(o) { - var undef; - - if (o === undef) { - return 'undefined'; - } else if (o === null) { - return 'null'; - } else if (o.nodeType) { - return 'node'; - } - - // the snippet below is awesome, however it fails to detect null, undefined and arguments types in IE lte 8 - return ({}).toString.call(o).match(/\s([a-z|A-Z]+)/)[1].toLowerCase(); - } - - /** - Extends the specified object with another object(s). - - @method extend - @static - @param {Object} target Object to extend. - @param {Object} [obj]* Multiple objects to extend with. - @return {Object} Same as target, the extended object. - */ - function extend() { - return merge(false, false, arguments); - } - - - /** - Extends the specified object with another object(s), but only if the property exists in the target. - - @method extendIf - @static - @param {Object} target Object to extend. - @param {Object} [obj]* Multiple objects to extend with. - @return {Object} Same as target, the extended object. - */ - function extendIf() { - return merge(true, false, arguments); - } - - - function extendImmutable() { - return merge(false, true, arguments); - } - - - function extendImmutableIf() { - return merge(true, true, arguments); - } - - - function clone(value) { - switch (typeOf(value)) { - case 'array': - return merge(false, true, [[], value]); - - case 'object': - return merge(false, true, [{}, value]); - - default: - return value; - } - } - - - function shallowCopy(obj) { - switch (typeOf(obj)) { - case 'array': - return Array.prototype.slice.call(obj); - - case 'object': - return extend({}, obj); - } - return obj; - } - - - function merge(strict, immutable, args) { - var undef; - var target = args[0]; - - each(args, function(arg, i) { - if (i > 0) { - each(arg, function(value, key) { - var isComplex = inArray(typeOf(value), ['array', 'object']) !== -1; - - if (value === undef || strict && target[key] === undef) { - return true; - } - - if (isComplex && immutable) { - value = shallowCopy(value); - } - - if (typeOf(target[key]) === typeOf(value) && isComplex) { - merge(strict, immutable, [target[key], value]); - } else { - target[key] = value; - } - }); - } - }); - - return target; - } - - - /** - A way to inherit one `class` from another in a consisstent way (more or less) - - @method inherit - @static - @since >1.4.1 - @param {Function} child - @param {Function} parent - @return {Function} Prepared constructor - */ - function inherit(child, parent) { - // copy over all parent properties - for (var key in parent) { - if ({}.hasOwnProperty.call(parent, key)) { - child[key] = parent[key]; - } - } - - // give child `class` a place to define its own methods - function ctor() { - this.constructor = child; - - if (MXI_DEBUG) { - var getCtorName = function(fn) { - var m = fn.toString().match(/^function\s([^\(\s]+)/); - return m ? m[1] : false; - }; - - this.ctorName = getCtorName(child); - } - } - ctor.prototype = parent.prototype; - child.prototype = new ctor(); - - // keep a way to reference parent methods - child.parent = parent.prototype; - return child; - } - - - /** - Executes the callback function for each item in array/object. If you return false in the - callback it will break the loop. - - @method each - @static - @param {Object} obj Object to iterate. - @param {function} callback Callback function to execute for each item. - */ - function each(obj, callback) { - var length, key, i, undef; - - if (obj) { - try { - length = obj.length; - } catch(ex) { - length = undef; - } - - if (length === undef || typeof(length) !== 'number') { - // Loop object items - for (key in obj) { - if (obj.hasOwnProperty(key)) { - if (callback(obj[key], key) === false) { - return; - } - } - } - } else { - // Loop array items - for (i = 0; i < length; i++) { - if (callback(obj[i], i) === false) { - return; - } - } - } - } - } - - /** - Checks if object is empty. - - @method isEmptyObj - @static - @param {Object} o Object to check. - @return {Boolean} - */ - function isEmptyObj(obj) { - var prop; - - if (!obj || typeOf(obj) !== 'object') { - return true; - } - - for (prop in obj) { - return false; - } - - return true; - } - - /** - Recieve an array of functions (usually async) to call in sequence, each function - receives a callback as first argument that it should call, when it completes. Finally, - after everything is complete, main callback is called. Passing truthy value to the - callback as a first argument will interrupt the sequence and invoke main callback - immediately. - - @method inSeries - @static - @param {Array} queue Array of functions to call in sequence - @param {Function} cb Main callback that is called in the end, or in case of error - */ - function inSeries(queue, cb) { - var i = 0, length = queue.length; - - if (typeOf(cb) !== 'function') { - cb = function() {}; - } - - if (!queue || !queue.length) { - cb(); - } - - function callNext(i) { - if (typeOf(queue[i]) === 'function') { - queue[i](function(error) { - /*jshint expr:true */ - ++i < length && !error ? callNext(i) : cb(error); - }); - } - } - callNext(i); - } - - - /** - Recieve an array of functions (usually async) to call in parallel, each function - receives a callback as first argument that it should call, when it completes. After - everything is complete, main callback is called. Passing truthy value to the - callback as a first argument will interrupt the process and invoke main callback - immediately. - - @method inParallel - @static - @param {Array} queue Array of functions to call in sequence - @param {Function} cb Main callback that is called in the end, or in case of erro - */ - function inParallel(queue, cb) { - var count = 0, num = queue.length, cbArgs = new Array(num); - - each(queue, function(fn, i) { - fn(function(error) { - if (error) { - return cb(error); - } - - var args = [].slice.call(arguments); - args.shift(); // strip error - undefined or not - - cbArgs[i] = args; - count++; - - if (count === num) { - cbArgs.unshift(null); - cb.apply(this, cbArgs); - } - }); - }); - } - - - /** - Find an element in array and return it's index if present, otherwise return -1. - - @method inArray - @static - @param {Mixed} needle Element to find - @param {Array} array - @return {Int} Index of the element, or -1 if not found - */ - function inArray(needle, array) { - if (array) { - if (Array.prototype.indexOf) { - return Array.prototype.indexOf.call(array, needle); - } - - for (var i = 0, length = array.length; i < length; i++) { - if (array[i] === needle) { - return i; - } - } - } - return -1; - } - - - /** - Returns elements of first array if they are not present in second. And false - otherwise. - - @private - @method arrayDiff - @param {Array} needles - @param {Array} array - @return {Array|Boolean} - */ - function arrayDiff(needles, array) { - var diff = []; - - if (typeOf(needles) !== 'array') { - needles = [needles]; - } - - if (typeOf(array) !== 'array') { - array = [array]; - } - - for (var i in needles) { - if (inArray(needles[i], array) === -1) { - diff.push(needles[i]); - } - } - return diff.length ? diff : false; - } - - - /** - Find intersection of two arrays. - - @private - @method arrayIntersect - @param {Array} array1 - @param {Array} array2 - @return {Array} Intersection of two arrays or null if there is none - */ - function arrayIntersect(array1, array2) { - var result = []; - each(array1, function(item) { - if (inArray(item, array2) !== -1) { - result.push(item); - } - }); - return result.length ? result : null; - } - - - /** - Forces anything into an array. - - @method toArray - @static - @param {Object} obj Object with length field. - @return {Array} Array object containing all items. - */ - function toArray(obj) { - var i, arr = []; - - for (i = 0; i < obj.length; i++) { - arr[i] = obj[i]; - } - - return arr; - } - - - /** - Generates an unique ID. The only way a user would be able to get the same ID is if the two persons - at the same exact millisecond manage to get the same 5 random numbers between 0-65535; it also uses - a counter so each ID is guaranteed to be unique for the given page. It is more probable for the earth - to be hit with an asteroid. - - @method guid - @static - @param {String} prefix to prepend (by default 'o' will be prepended). - @method guid - @return {String} Virtually unique id. - */ - var guid = (function() { - var counter = 0; - - return function(prefix) { - var guid = new Date().getTime().toString(32), i; - - for (i = 0; i < 5; i++) { - guid += Math.floor(Math.random() * 65535).toString(32); - } - - return (prefix || 'o_') + guid + (counter++).toString(32); - }; - }()); - - - /** - Trims white spaces around the string - - @method trim - @static - @param {String} str - @return {String} - */ - function trim(str) { - if (!str) { - return str; - } - return String.prototype.trim ? String.prototype.trim.call(str) : str.toString().replace(/^\s*/, '').replace(/\s*$/, ''); - } - - - /** - Parses the specified size string into a byte value. For example 10kb becomes 10240. - - @method parseSizeStr - @static - @param {String/Number} size String to parse or number to just pass through. - @return {Number} Size in bytes. - */ - function parseSizeStr(size) { - if (typeof(size) !== 'string') { - return size; - } - - var muls = { - t: 1099511627776, - g: 1073741824, - m: 1048576, - k: 1024 - }, - mul; - - size = /^([0-9\.]+)([tmgk]?)$/.exec(size.toLowerCase().replace(/[^0-9\.tmkg]/g, '')); - mul = size[2]; - size = +size[1]; - - if (muls.hasOwnProperty(mul)) { - size *= muls[mul]; - } - return Math.floor(size); - } - - - /** - * Pseudo sprintf implementation - simple way to replace tokens with specified values. - * - * @param {String} str String with tokens - * @return {String} String with replaced tokens - */ - function sprintf(str) { - var args = [].slice.call(arguments, 1); - - return str.replace(/%([a-z])/g, function($0, $1) { - var value = args.shift(); - - switch ($1) { - case 's': - return value + ''; - - case 'd': - return parseInt(value, 10); - - case 'f': - return parseFloat(value); - - case 'c': - return ''; - - default: - return value; - } - }); - } - - - - function delay(cb, timeout) { - var self = this; - setTimeout(function() { - cb.call(self); - }, timeout || 1); - } - - - return { - guid: guid, - typeOf: typeOf, - extend: extend, - extendIf: extendIf, - extendImmutable: extendImmutable, - extendImmutableIf: extendImmutableIf, - clone: clone, - inherit: inherit, - each: each, - isEmptyObj: isEmptyObj, - inSeries: inSeries, - inParallel: inParallel, - inArray: inArray, - arrayDiff: arrayDiff, - arrayIntersect: arrayIntersect, - toArray: toArray, - trim: trim, - sprintf: sprintf, - parseSizeStr: parseSizeStr, - delay: delay - }; -}); - -// Included from: src/javascript/core/utils/Encode.js - -/** - * Encode.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/core/utils/Encode -@public -@static -*/ - -define('moxie/core/utils/Encode', [], function() { - - /** - Encode string with UTF-8 - - @method utf8_encode - @static - @param {String} str String to encode - @return {String} UTF-8 encoded string - */ - var utf8_encode = function(str) { - return unescape(encodeURIComponent(str)); - }; - - /** - Decode UTF-8 encoded string - - @method utf8_decode - @static - @param {String} str String to decode - @return {String} Decoded string - */ - var utf8_decode = function(str_data) { - return decodeURIComponent(escape(str_data)); - }; - - /** - Decode Base64 encoded string (uses browser's default method if available), - from: https://raw.github.com/kvz/phpjs/master/functions/url/base64_decode.js - - @method atob - @static - @param {String} data String to decode - @return {String} Decoded string - */ - var atob = function(data, utf8) { - if (typeof(window.atob) === 'function') { - return utf8 ? utf8_decode(window.atob(data)) : window.atob(data); - } - - // http://kevin.vanzonneveld.net - // + original by: Tyler Akins (http://rumkin.com) - // + improved by: Thunder.m - // + input by: Aman Gupta - // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) - // + bugfixed by: Onno Marsman - // + bugfixed by: Pellentesque Malesuada - // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) - // + input by: Brett Zamir (http://brett-zamir.me) - // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) - // * example 1: base64_decode('S2V2aW4gdmFuIFpvbm5ldmVsZA=='); - // * returns 1: 'Kevin van Zonneveld' - // mozilla has this native - // - but breaks in 2.0.0.12! - //if (typeof this.window.atob == 'function') { - // return atob(data); - //} - var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, - ac = 0, - dec = "", - tmp_arr = []; - - if (!data) { - return data; - } - - data += ''; - - do { // unpack four hexets into three octets using index points in b64 - h1 = b64.indexOf(data.charAt(i++)); - h2 = b64.indexOf(data.charAt(i++)); - h3 = b64.indexOf(data.charAt(i++)); - h4 = b64.indexOf(data.charAt(i++)); - - bits = h1 << 18 | h2 << 12 | h3 << 6 | h4; - - o1 = bits >> 16 & 0xff; - o2 = bits >> 8 & 0xff; - o3 = bits & 0xff; - - if (h3 == 64) { - tmp_arr[ac++] = String.fromCharCode(o1); - } else if (h4 == 64) { - tmp_arr[ac++] = String.fromCharCode(o1, o2); - } else { - tmp_arr[ac++] = String.fromCharCode(o1, o2, o3); - } - } while (i < data.length); - - dec = tmp_arr.join(''); - - return utf8 ? utf8_decode(dec) : dec; - }; - - /** - Base64 encode string (uses browser's default method if available), - from: https://raw.github.com/kvz/phpjs/master/functions/url/base64_encode.js - - @method btoa - @static - @param {String} data String to encode - @return {String} Base64 encoded string - */ - var btoa = function(data, utf8) { - if (utf8) { - data = utf8_encode(data); - } - - if (typeof(window.btoa) === 'function') { - return window.btoa(data); - } - - // http://kevin.vanzonneveld.net - // + original by: Tyler Akins (http://rumkin.com) - // + improved by: Bayron Guevara - // + improved by: Thunder.m - // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) - // + bugfixed by: Pellentesque Malesuada - // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) - // + improved by: Rafał Kukawski (http://kukawski.pl) - // * example 1: base64_encode('Kevin van Zonneveld'); - // * returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA==' - // mozilla has this native - // - but breaks in 2.0.0.12! - var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, - ac = 0, - enc = "", - tmp_arr = []; - - if (!data) { - return data; - } - - do { // pack three octets into four hexets - o1 = data.charCodeAt(i++); - o2 = data.charCodeAt(i++); - o3 = data.charCodeAt(i++); - - bits = o1 << 16 | o2 << 8 | o3; - - h1 = bits >> 18 & 0x3f; - h2 = bits >> 12 & 0x3f; - h3 = bits >> 6 & 0x3f; - h4 = bits & 0x3f; - - // use hexets to index into b64, and append result to encoded string - tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4); - } while (i < data.length); - - enc = tmp_arr.join(''); - - var r = data.length % 3; - - return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3); - }; - - - return { - utf8_encode: utf8_encode, - utf8_decode: utf8_decode, - atob: atob, - btoa: btoa - }; -}); - -// Included from: src/javascript/core/utils/Env.js - -/** - * Env.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/core/utils/Env -@public -@static -*/ - -define("moxie/core/utils/Env", [ - "moxie/core/utils/Basic" -], function(Basic) { - - /** - * UAParser.js v0.7.7 - * Lightweight JavaScript-based User-Agent string parser - * https://github.com/faisalman/ua-parser-js - * - * Copyright © 2012-2015 Faisal Salman - * Dual licensed under GPLv2 & MIT - */ - var UAParser = (function (undefined) { - - ////////////// - // Constants - ///////////// - - - var EMPTY = '', - UNKNOWN = '?', - FUNC_TYPE = 'function', - UNDEF_TYPE = 'undefined', - OBJ_TYPE = 'object', - MAJOR = 'major', - MODEL = 'model', - NAME = 'name', - TYPE = 'type', - VENDOR = 'vendor', - VERSION = 'version', - ARCHITECTURE= 'architecture', - CONSOLE = 'console', - MOBILE = 'mobile', - TABLET = 'tablet'; - - - /////////// - // Helper - ////////// - - - var util = { - has : function (str1, str2) { - return str2.toLowerCase().indexOf(str1.toLowerCase()) !== -1; - }, - lowerize : function (str) { - return str.toLowerCase(); - } - }; - - - /////////////// - // Map helper - ////////////// - - - var mapper = { - - rgx : function () { - - // loop through all regexes maps - for (var result, i = 0, j, k, p, q, matches, match, args = arguments; i < args.length; i += 2) { - - var regex = args[i], // even sequence (0,2,4,..) - props = args[i + 1]; // odd sequence (1,3,5,..) - - // construct object barebones - if (typeof(result) === UNDEF_TYPE) { - result = {}; - for (p in props) { - q = props[p]; - if (typeof(q) === OBJ_TYPE) { - result[q[0]] = undefined; - } else { - result[q] = undefined; - } - } - } - - // try matching uastring with regexes - for (j = k = 0; j < regex.length; j++) { - matches = regex[j].exec(this.getUA()); - if (!!matches) { - for (p = 0; p < props.length; p++) { - match = matches[++k]; - q = props[p]; - // check if given property is actually array - if (typeof(q) === OBJ_TYPE && q.length > 0) { - if (q.length == 2) { - if (typeof(q[1]) == FUNC_TYPE) { - // assign modified match - result[q[0]] = q[1].call(this, match); - } else { - // assign given value, ignore regex match - result[q[0]] = q[1]; - } - } else if (q.length == 3) { - // check whether function or regex - if (typeof(q[1]) === FUNC_TYPE && !(q[1].exec && q[1].test)) { - // call function (usually string mapper) - result[q[0]] = match ? q[1].call(this, match, q[2]) : undefined; - } else { - // sanitize match using given regex - result[q[0]] = match ? match.replace(q[1], q[2]) : undefined; - } - } else if (q.length == 4) { - result[q[0]] = match ? q[3].call(this, match.replace(q[1], q[2])) : undefined; - } - } else { - result[q] = match ? match : undefined; - } - } - break; - } - } - - if(!!matches) break; // break the loop immediately if match found - } - return result; - }, - - str : function (str, map) { - - for (var i in map) { - // check if array - if (typeof(map[i]) === OBJ_TYPE && map[i].length > 0) { - for (var j = 0; j < map[i].length; j++) { - if (util.has(map[i][j], str)) { - return (i === UNKNOWN) ? undefined : i; - } - } - } else if (util.has(map[i], str)) { - return (i === UNKNOWN) ? undefined : i; - } - } - return str; - } - }; - - - /////////////// - // String map - ////////////// - - - var maps = { - - browser : { - oldsafari : { - major : { - '1' : ['/8', '/1', '/3'], - '2' : '/4', - '?' : '/' - }, - version : { - '1.0' : '/8', - '1.2' : '/1', - '1.3' : '/3', - '2.0' : '/412', - '2.0.2' : '/416', - '2.0.3' : '/417', - '2.0.4' : '/419', - '?' : '/' - } - } - }, - - device : { - sprint : { - model : { - 'Evo Shift 4G' : '7373KT' - }, - vendor : { - 'HTC' : 'APA', - 'Sprint' : 'Sprint' - } - } - }, - - os : { - windows : { - version : { - 'ME' : '4.90', - 'NT 3.11' : 'NT3.51', - 'NT 4.0' : 'NT4.0', - '2000' : 'NT 5.0', - 'XP' : ['NT 5.1', 'NT 5.2'], - 'Vista' : 'NT 6.0', - '7' : 'NT 6.1', - '8' : 'NT 6.2', - '8.1' : 'NT 6.3', - 'RT' : 'ARM' - } - } - } - }; - - - ////////////// - // Regex map - ///////////// - - - var regexes = { - - browser : [[ - - // Presto based - /(opera\smini)\/([\w\.-]+)/i, // Opera Mini - /(opera\s[mobiletab]+).+version\/([\w\.-]+)/i, // Opera Mobi/Tablet - /(opera).+version\/([\w\.]+)/i, // Opera > 9.80 - /(opera)[\/\s]+([\w\.]+)/i // Opera < 9.80 - - ], [NAME, VERSION], [ - - /\s(opr)\/([\w\.]+)/i // Opera Webkit - ], [[NAME, 'Opera'], VERSION], [ - - // Mixed - /(kindle)\/([\w\.]+)/i, // Kindle - /(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?([\w\.]+)*/i, - // Lunascape/Maxthon/Netfront/Jasmine/Blazer - - // Trident based - /(avant\s|iemobile|slim|baidu)(?:browser)?[\/\s]?([\w\.]*)/i, - // Avant/IEMobile/SlimBrowser/Baidu - /(?:ms|\()(ie)\s([\w\.]+)/i, // Internet Explorer - - // Webkit/KHTML based - /(rekonq)\/([\w\.]+)*/i, // Rekonq - /(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi)\/([\w\.-]+)/i - // Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron - ], [NAME, VERSION], [ - - /(trident).+rv[:\s]([\w\.]+).+like\sgecko/i // IE11 - ], [[NAME, 'IE'], VERSION], [ - - /(edge)\/((\d+)?[\w\.]+)/i // Microsoft Edge - ], [NAME, VERSION], [ - - /(yabrowser)\/([\w\.]+)/i // Yandex - ], [[NAME, 'Yandex'], VERSION], [ - - /(comodo_dragon)\/([\w\.]+)/i // Comodo Dragon - ], [[NAME, /_/g, ' '], VERSION], [ - - /(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?([\w\.]+)/i, - // Chrome/OmniWeb/Arora/Tizen/Nokia - /(uc\s?browser|qqbrowser)[\/\s]?([\w\.]+)/i - // UCBrowser/QQBrowser - ], [NAME, VERSION], [ - - /(dolfin)\/([\w\.]+)/i // Dolphin - ], [[NAME, 'Dolphin'], VERSION], [ - - /((?:android.+)crmo|crios)\/([\w\.]+)/i // Chrome for Android/iOS - ], [[NAME, 'Chrome'], VERSION], [ - - /XiaoMi\/MiuiBrowser\/([\w\.]+)/i // MIUI Browser - ], [VERSION, [NAME, 'MIUI Browser']], [ - - /android.+version\/([\w\.]+)\s+(?:mobile\s?safari|safari)/i // Android Browser - ], [VERSION, [NAME, 'Android Browser']], [ - - /FBAV\/([\w\.]+);/i // Facebook App for iOS - ], [VERSION, [NAME, 'Facebook']], [ - - /version\/([\w\.]+).+?mobile\/\w+\s(safari)/i // Mobile Safari - ], [VERSION, [NAME, 'Mobile Safari']], [ - - /version\/([\w\.]+).+?(mobile\s?safari|safari)/i // Safari & Safari Mobile - ], [VERSION, NAME], [ - - /webkit.+?(mobile\s?safari|safari)(\/[\w\.]+)/i // Safari < 3.0 - ], [NAME, [VERSION, mapper.str, maps.browser.oldsafari.version]], [ - - /(konqueror)\/([\w\.]+)/i, // Konqueror - /(webkit|khtml)\/([\w\.]+)/i - ], [NAME, VERSION], [ - - // Gecko based - /(navigator|netscape)\/([\w\.-]+)/i // Netscape - ], [[NAME, 'Netscape'], VERSION], [ - /(swiftfox)/i, // Swiftfox - /(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?([\w\.\+]+)/i, - // IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror - /(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix)\/([\w\.-]+)/i, - // Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix - /(mozilla)\/([\w\.]+).+rv\:.+gecko\/\d+/i, // Mozilla - - // Other - /(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf)[\/\s]?([\w\.]+)/i, - // Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf - /(links)\s\(([\w\.]+)/i, // Links - /(gobrowser)\/?([\w\.]+)*/i, // GoBrowser - /(ice\s?browser)\/v?([\w\._]+)/i, // ICE Browser - /(mosaic)[\/\s]([\w\.]+)/i // Mosaic - ], [NAME, VERSION] - ], - - engine : [[ - - /windows.+\sedge\/([\w\.]+)/i // EdgeHTML - ], [VERSION, [NAME, 'EdgeHTML']], [ - - /(presto)\/([\w\.]+)/i, // Presto - /(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i, // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m - /(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i, // KHTML/Tasman/Links - /(icab)[\/\s]([23]\.[\d\.]+)/i // iCab - ], [NAME, VERSION], [ - - /rv\:([\w\.]+).*(gecko)/i // Gecko - ], [VERSION, NAME] - ], - - os : [[ - - // Windows based - /microsoft\s(windows)\s(vista|xp)/i // Windows (iTunes) - ], [NAME, VERSION], [ - /(windows)\snt\s6\.2;\s(arm)/i, // Windows RT - /(windows\sphone(?:\sos)*|windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i - ], [NAME, [VERSION, mapper.str, maps.os.windows.version]], [ - /(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i - ], [[NAME, 'Windows'], [VERSION, mapper.str, maps.os.windows.version]], [ - - // Mobile/Embedded OS - /\((bb)(10);/i // BlackBerry 10 - ], [[NAME, 'BlackBerry'], VERSION], [ - /(blackberry)\w*\/?([\w\.]+)*/i, // Blackberry - /(tizen)[\/\s]([\w\.]+)/i, // Tizen - /(android|webos|palm\os|qnx|bada|rim\stablet\sos|meego|contiki)[\/\s-]?([\w\.]+)*/i, - // Android/WebOS/Palm/QNX/Bada/RIM/MeeGo/Contiki - /linux;.+(sailfish);/i // Sailfish OS - ], [NAME, VERSION], [ - /(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]+)*/i // Symbian - ], [[NAME, 'Symbian'], VERSION], [ - /\((series40);/i // Series 40 - ], [NAME], [ - /mozilla.+\(mobile;.+gecko.+firefox/i // Firefox OS - ], [[NAME, 'Firefox OS'], VERSION], [ - - // Console - /(nintendo|playstation)\s([wids3portablevu]+)/i, // Nintendo/Playstation - - // GNU/Linux based - /(mint)[\/\s\(]?(\w+)*/i, // Mint - /(mageia|vectorlinux)[;\s]/i, // Mageia/VectorLinux - /(joli|[kxln]?ubuntu|debian|[open]*suse|gentoo|arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk|linpus)[\/\s-]?([\w\.-]+)*/i, - // Joli/Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware - // Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk/Linpus - /(hurd|linux)\s?([\w\.]+)*/i, // Hurd/Linux - /(gnu)\s?([\w\.]+)*/i // GNU - ], [NAME, VERSION], [ - - /(cros)\s[\w]+\s([\w\.]+\w)/i // Chromium OS - ], [[NAME, 'Chromium OS'], VERSION],[ - - // Solaris - /(sunos)\s?([\w\.]+\d)*/i // Solaris - ], [[NAME, 'Solaris'], VERSION], [ - - // BSD based - /\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]+)*/i // FreeBSD/NetBSD/OpenBSD/PC-BSD/DragonFly - ], [NAME, VERSION],[ - - /(ip[honead]+)(?:.*os\s*([\w]+)*\slike\smac|;\sopera)/i // iOS - ], [[NAME, 'iOS'], [VERSION, /_/g, '.']], [ - - /(mac\sos\sx)\s?([\w\s\.]+\w)*/i, - /(macintosh|mac(?=_powerpc)\s)/i // Mac OS - ], [[NAME, 'Mac OS'], [VERSION, /_/g, '.']], [ - - // Other - /((?:open)?solaris)[\/\s-]?([\w\.]+)*/i, // Solaris - /(haiku)\s(\w+)/i, // Haiku - /(aix)\s((\d)(?=\.|\)|\s)[\w\.]*)*/i, // AIX - /(plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos|openvms)/i, - // Plan9/Minix/BeOS/OS2/AmigaOS/MorphOS/RISCOS/OpenVMS - /(unix)\s?([\w\.]+)*/i // UNIX - ], [NAME, VERSION] - ] - }; - - - ///////////////// - // Constructor - //////////////// - - - var UAParser = function (uastring) { - - var ua = uastring || ((window && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY); - - this.getBrowser = function () { - return mapper.rgx.apply(this, regexes.browser); - }; - this.getEngine = function () { - return mapper.rgx.apply(this, regexes.engine); - }; - this.getOS = function () { - return mapper.rgx.apply(this, regexes.os); - }; - this.getResult = function() { - return { - ua : this.getUA(), - browser : this.getBrowser(), - engine : this.getEngine(), - os : this.getOS() - }; - }; - this.getUA = function () { - return ua; - }; - this.setUA = function (uastring) { - ua = uastring; - return this; - }; - this.setUA(ua); - }; - - return UAParser; - })(); - - - function version_compare(v1, v2, operator) { - // From: http://phpjs.org/functions - // + original by: Philippe Jausions (http://pear.php.net/user/jausions) - // + original by: Aidan Lister (http://aidanlister.com/) - // + reimplemented by: Kankrelune (http://www.webfaktory.info/) - // + improved by: Brett Zamir (http://brett-zamir.me) - // + improved by: Scott Baker - // + improved by: Theriault - // * example 1: version_compare('8.2.5rc', '8.2.5a'); - // * returns 1: 1 - // * example 2: version_compare('8.2.50', '8.2.52', '<'); - // * returns 2: true - // * example 3: version_compare('5.3.0-dev', '5.3.0'); - // * returns 3: -1 - // * example 4: version_compare('4.1.0.52','4.01.0.51'); - // * returns 4: 1 - - // Important: compare must be initialized at 0. - var i = 0, - x = 0, - compare = 0, - // vm maps textual PHP versions to negatives so they're less than 0. - // PHP currently defines these as CASE-SENSITIVE. It is important to - // leave these as negatives so that they can come before numerical versions - // and as if no letters were there to begin with. - // (1alpha is < 1 and < 1.1 but > 1dev1) - // If a non-numerical value can't be mapped to this table, it receives - // -7 as its value. - vm = { - 'dev': -6, - 'alpha': -5, - 'a': -5, - 'beta': -4, - 'b': -4, - 'RC': -3, - 'rc': -3, - '#': -2, - 'p': 1, - 'pl': 1 - }, - // This function will be called to prepare each version argument. - // It replaces every _, -, and + with a dot. - // It surrounds any nonsequence of numbers/dots with dots. - // It replaces sequences of dots with a single dot. - // version_compare('4..0', '4.0') == 0 - // Important: A string of 0 length needs to be converted into a value - // even less than an unexisting value in vm (-7), hence [-8]. - // It's also important to not strip spaces because of this. - // version_compare('', ' ') == 1 - prepVersion = function (v) { - v = ('' + v).replace(/[_\-+]/g, '.'); - v = v.replace(/([^.\d]+)/g, '.$1.').replace(/\.{2,}/g, '.'); - return (!v.length ? [-8] : v.split('.')); - }, - // This converts a version component to a number. - // Empty component becomes 0. - // Non-numerical component becomes a negative number. - // Numerical component becomes itself as an integer. - numVersion = function (v) { - return !v ? 0 : (isNaN(v) ? vm[v] || -7 : parseInt(v, 10)); - }; - - v1 = prepVersion(v1); - v2 = prepVersion(v2); - x = Math.max(v1.length, v2.length); - for (i = 0; i < x; i++) { - if (v1[i] == v2[i]) { - continue; - } - v1[i] = numVersion(v1[i]); - v2[i] = numVersion(v2[i]); - if (v1[i] < v2[i]) { - compare = -1; - break; - } else if (v1[i] > v2[i]) { - compare = 1; - break; - } - } - if (!operator) { - return compare; - } - - // Important: operator is CASE-SENSITIVE. - // "No operator" seems to be treated as "<." - // Any other values seem to make the function return null. - switch (operator) { - case '>': - case 'gt': - return (compare > 0); - case '>=': - case 'ge': - return (compare >= 0); - case '<=': - case 'le': - return (compare <= 0); - case '==': - case '=': - case 'eq': - return (compare === 0); - case '<>': - case '!=': - case 'ne': - return (compare !== 0); - case '': - case '<': - case 'lt': - return (compare < 0); - default: - return null; - } - } - - - var can = (function() { - var caps = { - access_global_ns: function () { - return !!window.moxie; - }, - - define_property: (function() { - /* // currently too much extra code required, not exactly worth it - try { // as of IE8, getters/setters are supported only on DOM elements - var obj = {}; - if (Object.defineProperty) { - Object.defineProperty(obj, 'prop', { - enumerable: true, - configurable: true - }); - return true; - } - } catch(ex) {} - - if (Object.prototype.__defineGetter__ && Object.prototype.__defineSetter__) { - return true; - }*/ - return false; - }()), - - create_canvas: function() { - // On the S60 and BB Storm, getContext exists, but always returns undefined - // so we actually have to call getContext() to verify - // github.com/Modernizr/Modernizr/issues/issue/97/ - var el = document.createElement('canvas'); - var isSupported = !!(el.getContext && el.getContext('2d')); - caps.create_canvas = isSupported; - return isSupported; - }, - - return_response_type: function(responseType) { - try { - if (Basic.inArray(responseType, ['', 'text', 'document']) !== -1) { - return true; - } else if (window.XMLHttpRequest) { - var xhr = new XMLHttpRequest(); - xhr.open('get', '/'); // otherwise Gecko throws an exception - if ('responseType' in xhr) { - xhr.responseType = responseType; - // as of 23.0.1271.64, Chrome switched from throwing exception to merely logging it to the console (why? o why?) - if (xhr.responseType !== responseType) { - return false; - } - return true; - } - } - } catch (ex) {} - return false; - }, - - use_blob_uri: function() { - var URL = window.URL; - caps.use_blob_uri = (URL && - 'createObjectURL' in URL && - 'revokeObjectURL' in URL && - (Env.browser !== 'IE' || Env.verComp(Env.version, '11.0.46', '>=')) // IE supports createObjectURL, but not fully, for example it fails to use it as a src for the image - ); - return caps.use_blob_uri; - }, - - // ideas for this heavily come from Modernizr (http://modernizr.com/) - use_data_uri: (function() { - var du = new Image(); - - du.onload = function() { - caps.use_data_uri = (du.width === 1 && du.height === 1); - }; - - setTimeout(function() { - du.src = "data:image/gif;base64,R0lGODlhAQABAIAAAP8AAAAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=="; - }, 1); - return false; - }()), - - use_data_uri_over32kb: function() { // IE8 - return caps.use_data_uri && (Env.browser !== 'IE' || Env.version >= 9); - }, - - use_data_uri_of: function(bytes) { - return (caps.use_data_uri && bytes < 33000 || caps.use_data_uri_over32kb()); - }, - - use_fileinput: function() { - if (navigator.userAgent.match(/(Android (1.0|1.1|1.5|1.6|2.0|2.1))|(Windows Phone (OS 7|8.0))|(XBLWP)|(ZuneWP)|(w(eb)?OSBrowser)|(webOS)|(Kindle\/(1.0|2.0|2.5|3.0))/)) { - return false; - } - - var el = document.createElement('input'); - el.setAttribute('type', 'file'); - return caps.use_fileinput = !el.disabled; - }, - - use_webgl: function() { - var canvas = document.createElement('canvas'); - var gl = null, isSupported; - try { - gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl"); - } - catch(e) {} - - if (!gl) { // it seems that sometimes it doesn't throw exception, but still fails to get context - gl = null; - } - - isSupported = !!gl; - caps.use_webgl = isSupported; // save result of our check - canvas = undefined; - return isSupported; - } - }; - - return function(cap) { - var args = [].slice.call(arguments); - args.shift(); // shift of cap - return Basic.typeOf(caps[cap]) === 'function' ? caps[cap].apply(this, args) : !!caps[cap]; - }; - }()); - - - var uaResult = new UAParser().getResult(); - - - var Env = { - can: can, - - uaParser: UAParser, - - browser: uaResult.browser.name, - version: uaResult.browser.version, - os: uaResult.os.name, // everybody intuitively types it in a lowercase for some reason - osVersion: uaResult.os.version, - - verComp: version_compare, - - swf_url: "../flash/Moxie.swf", - xap_url: "../silverlight/Moxie.xap", - global_event_dispatcher: "moxie.core.EventTarget.instance.dispatchEvent" - }; - - // for backward compatibility - // @deprecated Use `Env.os` instead - Env.OS = Env.os; - - if (MXI_DEBUG) { - Env.debug = { - runtime: true, - events: false - }; - - Env.log = function() { - - function logObj(data) { - // TODO: this should recursively print out the object in a pretty way - console.appendChild(document.createTextNode(data + "\n")); - } - - // if debugger present, IE8 might have window.console.log method, but not be able to apply on it (why...) - if (window && window.console && window.console.log && window.console.log.apply) { - window.console.log.apply(window.console, arguments); - } else if (document) { - var console = document.getElementById('moxie-console'); - if (!console) { - console = document.createElement('pre'); - console.id = 'moxie-console'; - //console.style.display = 'none'; - document.body.appendChild(console); - } - - var data = arguments[0]; - if (Basic.typeOf(data) === 'string') { - data = Basic.sprintf.apply(this, arguments); - } else if (Basic.inArray(Basic.typeOf(data), ['object', 'array']) !== -1) { - logObj(data); - return; - } - - console.appendChild(document.createTextNode(data + "\n")); - } - }; - } - - return Env; -}); - -// Included from: src/javascript/core/Exceptions.js - -/** - * Exceptions.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -define('moxie/core/Exceptions', [ - 'moxie/core/utils/Basic' -], function(Basic) { - - function _findKey(obj, value) { - var key; - for (key in obj) { - if (obj[key] === value) { - return key; - } - } - return null; - } - - /** - @class moxie/core/Exception - */ - return { - RuntimeError: (function() { - var namecodes = { - NOT_INIT_ERR: 1, - EXCEPTION_ERR: 3, - NOT_SUPPORTED_ERR: 9, - JS_ERR: 4 - }; - - function RuntimeError(code, message) { - this.code = code; - this.name = _findKey(namecodes, code); - this.message = this.name + (message || ": RuntimeError " + this.code); - } - - Basic.extend(RuntimeError, namecodes); - RuntimeError.prototype = Error.prototype; - return RuntimeError; - }()), - - OperationNotAllowedException: (function() { - - function OperationNotAllowedException(code) { - this.code = code; - this.name = 'OperationNotAllowedException'; - } - - Basic.extend(OperationNotAllowedException, { - NOT_ALLOWED_ERR: 1 - }); - - OperationNotAllowedException.prototype = Error.prototype; - - return OperationNotAllowedException; - }()), - - ImageError: (function() { - var namecodes = { - WRONG_FORMAT: 1, - MAX_RESOLUTION_ERR: 2, - INVALID_META_ERR: 3 - }; - - function ImageError(code) { - this.code = code; - this.name = _findKey(namecodes, code); - this.message = this.name + ": ImageError " + this.code; - } - - Basic.extend(ImageError, namecodes); - ImageError.prototype = Error.prototype; - - return ImageError; - }()), - - FileException: (function() { - var namecodes = { - NOT_FOUND_ERR: 1, - SECURITY_ERR: 2, - ABORT_ERR: 3, - NOT_READABLE_ERR: 4, - ENCODING_ERR: 5, - NO_MODIFICATION_ALLOWED_ERR: 6, - INVALID_STATE_ERR: 7, - SYNTAX_ERR: 8 - }; - - function FileException(code) { - this.code = code; - this.name = _findKey(namecodes, code); - this.message = this.name + ": FileException " + this.code; - } - - Basic.extend(FileException, namecodes); - FileException.prototype = Error.prototype; - return FileException; - }()), - - DOMException: (function() { - var namecodes = { - INDEX_SIZE_ERR: 1, - DOMSTRING_SIZE_ERR: 2, - HIERARCHY_REQUEST_ERR: 3, - WRONG_DOCUMENT_ERR: 4, - INVALID_CHARACTER_ERR: 5, - NO_DATA_ALLOWED_ERR: 6, - NO_MODIFICATION_ALLOWED_ERR: 7, - NOT_FOUND_ERR: 8, - NOT_SUPPORTED_ERR: 9, - INUSE_ATTRIBUTE_ERR: 10, - INVALID_STATE_ERR: 11, - SYNTAX_ERR: 12, - INVALID_MODIFICATION_ERR: 13, - NAMESPACE_ERR: 14, - INVALID_ACCESS_ERR: 15, - VALIDATION_ERR: 16, - TYPE_MISMATCH_ERR: 17, - SECURITY_ERR: 18, - NETWORK_ERR: 19, - ABORT_ERR: 20, - URL_MISMATCH_ERR: 21, - QUOTA_EXCEEDED_ERR: 22, - TIMEOUT_ERR: 23, - INVALID_NODE_TYPE_ERR: 24, - DATA_CLONE_ERR: 25 - }; - - function DOMException(code) { - this.code = code; - this.name = _findKey(namecodes, code); - this.message = this.name + ": DOMException " + this.code; - } - - Basic.extend(DOMException, namecodes); - DOMException.prototype = Error.prototype; - return DOMException; - }()), - - EventException: (function() { - function EventException(code) { - this.code = code; - this.name = 'EventException'; - } - - Basic.extend(EventException, { - UNSPECIFIED_EVENT_TYPE_ERR: 0 - }); - - EventException.prototype = Error.prototype; - - return EventException; - }()) - }; -}); - -// Included from: src/javascript/core/utils/Dom.js - -/** - * Dom.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/core/utils/Dom -@public -@static -*/ - -define('moxie/core/utils/Dom', ['moxie/core/utils/Env'], function(Env) { - - /** - Get DOM Element by it's id. - - @method get - @param {String} id Identifier of the DOM Element - @return {DOMElement} - */ - var get = function(id) { - if (typeof id !== 'string') { - return id; - } - return document.getElementById(id); - }; - - /** - Checks if specified DOM element has specified class. - - @method hasClass - @static - @param {Object} obj DOM element like object to add handler to. - @param {String} name Class name - */ - var hasClass = function(obj, name) { - if (!obj.className) { - return false; - } - - var regExp = new RegExp("(^|\\s+)"+name+"(\\s+|$)"); - return regExp.test(obj.className); - }; - - /** - Adds specified className to specified DOM element. - - @method addClass - @static - @param {Object} obj DOM element like object to add handler to. - @param {String} name Class name - */ - var addClass = function(obj, name) { - if (!hasClass(obj, name)) { - obj.className = !obj.className ? name : obj.className.replace(/\s+$/, '') + ' ' + name; - } - }; - - /** - Removes specified className from specified DOM element. - - @method removeClass - @static - @param {Object} obj DOM element like object to add handler to. - @param {String} name Class name - */ - var removeClass = function(obj, name) { - if (obj.className) { - var regExp = new RegExp("(^|\\s+)"+name+"(\\s+|$)"); - obj.className = obj.className.replace(regExp, function($0, $1, $2) { - return $1 === ' ' && $2 === ' ' ? ' ' : ''; - }); - } - }; - - /** - Returns a given computed style of a DOM element. - - @method getStyle - @static - @param {Object} obj DOM element like object. - @param {String} name Style you want to get from the DOM element - */ - var getStyle = function(obj, name) { - if (obj.currentStyle) { - return obj.currentStyle[name]; - } else if (window.getComputedStyle) { - return window.getComputedStyle(obj, null)[name]; - } - }; - - - /** - Returns the absolute x, y position of an Element. The position will be returned in a object with x, y fields. - - @method getPos - @static - @param {Element} node HTML element or element id to get x, y position from. - @param {Element} root Optional root element to stop calculations at. - @return {object} Absolute position of the specified element object with x, y fields. - */ - var getPos = function(node, root) { - var x = 0, y = 0, parent, doc = document, nodeRect, rootRect; - - node = node; - root = root || doc.body; - - // Returns the x, y cordinate for an element on IE 6 and IE 7 - function getIEPos(node) { - var bodyElm, rect, x = 0, y = 0; - - if (node) { - rect = node.getBoundingClientRect(); - bodyElm = doc.compatMode === "CSS1Compat" ? doc.documentElement : doc.body; - x = rect.left + bodyElm.scrollLeft; - y = rect.top + bodyElm.scrollTop; - } - - return { - x : x, - y : y - }; - } - - // Use getBoundingClientRect on IE 6 and IE 7 but not on IE 8 in standards mode - if (node && node.getBoundingClientRect && Env.browser === 'IE' && (!doc.documentMode || doc.documentMode < 8)) { - nodeRect = getIEPos(node); - rootRect = getIEPos(root); - - return { - x : nodeRect.x - rootRect.x, - y : nodeRect.y - rootRect.y - }; - } - - parent = node; - while (parent && parent != root && parent.nodeType) { - x += parent.offsetLeft || 0; - y += parent.offsetTop || 0; - parent = parent.offsetParent; - } - - parent = node.parentNode; - while (parent && parent != root && parent.nodeType) { - x -= parent.scrollLeft || 0; - y -= parent.scrollTop || 0; - parent = parent.parentNode; - } - - return { - x : x, - y : y - }; - }; - - /** - Returns the size of the specified node in pixels. - - @method getSize - @static - @param {Node} node Node to get the size of. - @return {Object} Object with a w and h property. - */ - var getSize = function(node) { - return { - w : node.offsetWidth || node.clientWidth, - h : node.offsetHeight || node.clientHeight - }; - }; - - return { - get: get, - hasClass: hasClass, - addClass: addClass, - removeClass: removeClass, - getStyle: getStyle, - getPos: getPos, - getSize: getSize - }; -}); - -// Included from: src/javascript/core/EventTarget.js - -/** - * EventTarget.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -define('moxie/core/EventTarget', [ - 'moxie/core/utils/Env', - 'moxie/core/Exceptions', - 'moxie/core/utils/Basic' -], function(Env, x, Basic) { - - // hash of event listeners by object uid - var eventpool = {}; - - /** - Parent object for all event dispatching components and objects - - @class moxie/core/EventTarget - @constructor EventTarget - */ - function EventTarget() { - /** - Unique id of the event dispatcher, usually overriden by children - - @property uid - @type String - */ - this.uid = Basic.guid(); - } - - - Basic.extend(EventTarget.prototype, { - - /** - Can be called from within a child in order to acquire uniqie id in automated manner - - @method init - */ - init: function() { - if (!this.uid) { - this.uid = Basic.guid('uid_'); - } - }, - - /** - Register a handler to a specific event dispatched by the object - - @method addEventListener - @param {String} type Type or basically a name of the event to subscribe to - @param {Function} fn Callback function that will be called when event happens - @param {Number} [priority=0] Priority of the event handler - handlers with higher priorities will be called first - @param {Object} [scope=this] A scope to invoke event handler in - */ - addEventListener: function(type, fn, priority, scope) { - var self = this, list; - - // without uid no event handlers can be added, so make sure we got one - if (!this.hasOwnProperty('uid')) { - this.uid = Basic.guid('uid_'); - } - - type = Basic.trim(type); - - if (/\s/.test(type)) { - // multiple event types were passed for one handler - Basic.each(type.split(/\s+/), function(type) { - self.addEventListener(type, fn, priority, scope); - }); - return; - } - - type = type.toLowerCase(); - priority = parseInt(priority, 10) || 0; - - list = eventpool[this.uid] && eventpool[this.uid][type] || []; - list.push({fn : fn, priority : priority, scope : scope || this}); - - if (!eventpool[this.uid]) { - eventpool[this.uid] = {}; - } - eventpool[this.uid][type] = list; - }, - - /** - Check if any handlers were registered to the specified event - - @method hasEventListener - @param {String} [type] Type or basically a name of the event to check - @return {Mixed} Returns a handler if it was found and false, if - not - */ - hasEventListener: function(type) { - var list; - if (type) { - type = type.toLowerCase(); - list = eventpool[this.uid] && eventpool[this.uid][type]; - } else { - list = eventpool[this.uid]; - } - return list ? list : false; - }, - - /** - Unregister the handler from the event, or if former was not specified - unregister all handlers - - @method removeEventListener - @param {String} type Type or basically a name of the event - @param {Function} [fn] Handler to unregister - */ - removeEventListener: function(type, fn) { - var self = this, list, i; - - type = type.toLowerCase(); - - if (/\s/.test(type)) { - // multiple event types were passed for one handler - Basic.each(type.split(/\s+/), function(type) { - self.removeEventListener(type, fn); - }); - return; - } - - list = eventpool[this.uid] && eventpool[this.uid][type]; - - if (list) { - if (fn) { - for (i = list.length - 1; i >= 0; i--) { - if (list[i].fn === fn) { - list.splice(i, 1); - break; - } - } - } else { - list = []; - } - - // delete event list if it has become empty - if (!list.length) { - delete eventpool[this.uid][type]; - - // and object specific entry in a hash if it has no more listeners attached - if (Basic.isEmptyObj(eventpool[this.uid])) { - delete eventpool[this.uid]; - } - } - } - }, - - /** - Remove all event handlers from the object - - @method removeAllEventListeners - */ - removeAllEventListeners: function() { - if (eventpool[this.uid]) { - delete eventpool[this.uid]; - } - }, - - /** - Dispatch the event - - @method dispatchEvent - @param {String/Object} Type of event or event object to dispatch - @param {Mixed} [...] Variable number of arguments to be passed to a handlers - @return {Boolean} true by default and false if any handler returned false - */ - dispatchEvent: function(type) { - var uid, list, args, tmpEvt, evt = {}, result = true, undef; - - if (Basic.typeOf(type) !== 'string') { - // we can't use original object directly (because of Silverlight) - tmpEvt = type; - - if (Basic.typeOf(tmpEvt.type) === 'string') { - type = tmpEvt.type; - - if (tmpEvt.total !== undef && tmpEvt.loaded !== undef) { // progress event - evt.total = tmpEvt.total; - evt.loaded = tmpEvt.loaded; - } - evt.async = tmpEvt.async || false; - } else { - throw new x.EventException(x.EventException.UNSPECIFIED_EVENT_TYPE_ERR); - } - } - - // check if event is meant to be dispatched on an object having specific uid - if (type.indexOf('::') !== -1) { - (function(arr) { - uid = arr[0]; - type = arr[1]; - }(type.split('::'))); - } else { - uid = this.uid; - } - - type = type.toLowerCase(); - - list = eventpool[uid] && eventpool[uid][type]; - - if (list) { - // sort event list by prority - list.sort(function(a, b) { return b.priority - a.priority; }); - - args = [].slice.call(arguments); - - // first argument will be pseudo-event object - args.shift(); - evt.type = type; - args.unshift(evt); - - if (MXI_DEBUG && Env.debug.events) { - Env.log("%cEvent '%s' fired on %s", 'color: #999;', evt.type, (this.ctorName ? this.ctorName + '::' : '') + uid); - } - - // Dispatch event to all listeners - var queue = []; - Basic.each(list, function(handler) { - // explicitly set the target, otherwise events fired from shims do not get it - args[0].target = handler.scope; - // if event is marked as async, detach the handler - if (evt.async) { - queue.push(function(cb) { - setTimeout(function() { - cb(handler.fn.apply(handler.scope, args) === false); - }, 1); - }); - } else { - queue.push(function(cb) { - cb(handler.fn.apply(handler.scope, args) === false); // if handler returns false stop propagation - }); - } - }); - if (queue.length) { - Basic.inSeries(queue, function(err) { - result = !err; - }); - } - } - return result; - }, - - /** - Register a handler to the event type that will run only once - - @method bindOnce - @since >1.4.1 - @param {String} type Type or basically a name of the event to subscribe to - @param {Function} fn Callback function that will be called when event happens - @param {Number} [priority=0] Priority of the event handler - handlers with higher priorities will be called first - @param {Object} [scope=this] A scope to invoke event handler in - */ - bindOnce: function(type, fn, priority, scope) { - var self = this; - self.bind.call(this, type, function cb() { - self.unbind(type, cb); - return fn.apply(this, arguments); - }, priority, scope); - }, - - /** - Alias for addEventListener - - @method bind - @protected - */ - bind: function() { - this.addEventListener.apply(this, arguments); - }, - - /** - Alias for removeEventListener - - @method unbind - @protected - */ - unbind: function() { - this.removeEventListener.apply(this, arguments); - }, - - /** - Alias for removeAllEventListeners - - @method unbindAll - @protected - */ - unbindAll: function() { - this.removeAllEventListeners.apply(this, arguments); - }, - - /** - Alias for dispatchEvent - - @method trigger - @protected - */ - trigger: function() { - return this.dispatchEvent.apply(this, arguments); - }, - - - /** - Handle properties of on[event] type. - - @method handleEventProps - @private - */ - handleEventProps: function(dispatches) { - var self = this; - - this.bind(dispatches.join(' '), function(e) { - var prop = 'on' + e.type.toLowerCase(); - if (Basic.typeOf(this[prop]) === 'function') { - this[prop].apply(this, arguments); - } - }); - - // object must have defined event properties, even if it doesn't make use of them - Basic.each(dispatches, function(prop) { - prop = 'on' + prop.toLowerCase(prop); - if (Basic.typeOf(self[prop]) === 'undefined') { - self[prop] = null; - } - }); - } - - }); - - - EventTarget.instance = new EventTarget(); - - return EventTarget; -}); - -// Included from: src/javascript/runtime/Runtime.js - -/** - * Runtime.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -define('moxie/runtime/Runtime', [ - "moxie/core/utils/Env", - "moxie/core/utils/Basic", - "moxie/core/utils/Dom", - "moxie/core/EventTarget" -], function(Env, Basic, Dom, EventTarget) { - var runtimeConstructors = {}, runtimes = {}; - - /** - Common set of methods and properties for every runtime instance - - @class moxie/runtime/Runtime - - @param {Object} options - @param {String} type Sanitized name of the runtime - @param {Object} [caps] Set of capabilities that differentiate specified runtime - @param {Object} [modeCaps] Set of capabilities that do require specific operational mode - @param {String} [preferredMode='browser'] Preferred operational mode to choose if no required capabilities were requested - */ - function Runtime(options, type, caps, modeCaps, preferredMode) { - /** - Dispatched when runtime is initialized and ready. - Results in RuntimeInit on a connected component. - - @event Init - */ - - /** - Dispatched when runtime fails to initialize. - Results in RuntimeError on a connected component. - - @event Error - */ - - var self = this - , _shim - , _uid = Basic.guid(type + '_') - , defaultMode = preferredMode || 'browser' - ; - - options = options || {}; - - // register runtime in private hash - runtimes[_uid] = this; - - /** - Default set of capabilities, which can be redifined later by specific runtime - - @private - @property caps - @type Object - */ - caps = Basic.extend({ - // Runtime can: - // provide access to raw binary data of the file - access_binary: false, - // provide access to raw binary data of the image (image extension is optional) - access_image_binary: false, - // display binary data as thumbs for example - display_media: false, - // make cross-domain requests - do_cors: false, - // accept files dragged and dropped from the desktop - drag_and_drop: false, - // filter files in selection dialog by their extensions - filter_by_extension: true, - // resize image (and manipulate it raw data of any file in general) - resize_image: false, - // periodically report how many bytes of total in the file were uploaded (loaded) - report_upload_progress: false, - // provide access to the headers of http response - return_response_headers: false, - // support response of specific type, which should be passed as an argument - // e.g. runtime.can('return_response_type', 'blob') - return_response_type: false, - // return http status code of the response - return_status_code: true, - // send custom http header with the request - send_custom_headers: false, - // pick up the files from a dialog - select_file: false, - // select whole folder in file browse dialog - select_folder: false, - // select multiple files at once in file browse dialog - select_multiple: true, - // send raw binary data, that is generated after image resizing or manipulation of other kind - send_binary_string: false, - // send cookies with http request and therefore retain session - send_browser_cookies: true, - // send data formatted as multipart/form-data - send_multipart: true, - // slice the file or blob to smaller parts - slice_blob: false, - // upload file without preloading it to memory, stream it out directly from disk - stream_upload: false, - // programmatically trigger file browse dialog - summon_file_dialog: false, - // upload file of specific size, size should be passed as argument - // e.g. runtime.can('upload_filesize', '500mb') - upload_filesize: true, - // initiate http request with specific http method, method should be passed as argument - // e.g. runtime.can('use_http_method', 'put') - use_http_method: true - }, caps); - - - // default to the mode that is compatible with preferred caps - if (options.preferred_caps) { - defaultMode = Runtime.getMode(modeCaps, options.preferred_caps, defaultMode); - } - - if (MXI_DEBUG && Env.debug.runtime) { - Env.log("\tdefault mode: %s", defaultMode); - } - - // small extension factory here (is meant to be extended with actual extensions constructors) - _shim = (function() { - var objpool = {}; - return { - exec: function(uid, comp, fn, args) { - if (_shim[comp]) { - if (!objpool[uid]) { - objpool[uid] = { - context: this, - instance: new _shim[comp]() - }; - } - if (objpool[uid].instance[fn]) { - return objpool[uid].instance[fn].apply(this, args); - } - } - }, - - removeInstance: function(uid) { - delete objpool[uid]; - }, - - removeAllInstances: function() { - var self = this; - Basic.each(objpool, function(obj, uid) { - if (Basic.typeOf(obj.instance.destroy) === 'function') { - obj.instance.destroy.call(obj.context); - } - self.removeInstance(uid); - }); - } - }; - }()); - - - // public methods - Basic.extend(this, { - /** - Specifies whether runtime instance was initialized or not - - @property initialized - @type {Boolean} - @default false - */ - initialized: false, // shims require this flag to stop initialization retries - - /** - Unique ID of the runtime - - @property uid - @type {String} - */ - uid: _uid, - - /** - Runtime type (e.g. flash, html5, etc) - - @property type - @type {String} - */ - type: type, - - /** - Runtime (not native one) may operate in browser or client mode. - - @property mode - @private - @type {String|Boolean} current mode or false, if none possible - */ - mode: Runtime.getMode(modeCaps, (options.required_caps), defaultMode), - - /** - id of the DOM container for the runtime (if available) - - @property shimid - @type {String} - */ - shimid: _uid + '_container', - - /** - Number of connected clients. If equal to zero, runtime can be destroyed - - @property clients - @type {Number} - */ - clients: 0, - - /** - Runtime initialization options - - @property options - @type {Object} - */ - options: options, - - /** - Checks if the runtime has specific capability - - @method can - @param {String} cap Name of capability to check - @param {Mixed} [value] If passed, capability should somehow correlate to the value - @param {Object} [refCaps] Set of capabilities to check the specified cap against (defaults to internal set) - @return {Boolean} true if runtime has such capability and false, if - not - */ - can: function(cap, value) { - var refCaps = arguments[2] || caps; - - // if cap var is a comma-separated list of caps, convert it to object (key/value) - if (Basic.typeOf(cap) === 'string' && Basic.typeOf(value) === 'undefined') { - cap = Runtime.parseCaps(cap); - } - - if (Basic.typeOf(cap) === 'object') { - for (var key in cap) { - if (!this.can(key, cap[key], refCaps)) { - return false; - } - } - return true; - } - - // check the individual cap - if (Basic.typeOf(refCaps[cap]) === 'function') { - return refCaps[cap].call(this, value); - } else { - return (value === refCaps[cap]); - } - }, - - /** - Returns container for the runtime as DOM element - - @method getShimContainer - @return {DOMElement} - */ - getShimContainer: function() { - var container, shimContainer = Dom.get(this.shimid); - - // if no container for shim, create one - if (!shimContainer) { - container = Dom.get(this.options.container) || document.body; - - // create shim container and insert it at an absolute position into the outer container - shimContainer = document.createElement('div'); - shimContainer.id = this.shimid; - shimContainer.className = 'moxie-shim moxie-shim-' + this.type; - - Basic.extend(shimContainer.style, { - position: 'absolute', - top: '0px', - left: '0px', - width: '1px', - height: '1px', - overflow: 'hidden' - }); - - container.appendChild(shimContainer); - container = null; - } - - return shimContainer; - }, - - /** - Returns runtime as DOM element (if appropriate) - - @method getShim - @return {DOMElement} - */ - getShim: function() { - return _shim; - }, - - /** - Invokes a method within the runtime itself (might differ across the runtimes) - - @method shimExec - @param {Mixed} [] - @protected - @return {Mixed} Depends on the action and component - */ - shimExec: function(component, action) { - var args = [].slice.call(arguments, 2); - return self.getShim().exec.call(this, this.uid, component, action, args); - }, - - /** - Operaional interface that is used by components to invoke specific actions on the runtime - (is invoked in the scope of component) - - @method exec - @param {Mixed} []* - @protected - @return {Mixed} Depends on the action and component - */ - exec: function(component, action) { // this is called in the context of component, not runtime - var args = [].slice.call(arguments, 2); - - if (self[component] && self[component][action]) { - return self[component][action].apply(this, args); - } - return self.shimExec.apply(this, arguments); - }, - - /** - Destroys the runtime (removes all events and deletes DOM structures) - - @method destroy - */ - destroy: function() { - if (!self) { - return; // obviously already destroyed - } - - var shimContainer = Dom.get(this.shimid); - if (shimContainer) { - shimContainer.parentNode.removeChild(shimContainer); - } - - if (_shim) { - _shim.removeAllInstances(); - } - - this.unbindAll(); - delete runtimes[this.uid]; - this.uid = null; // mark this runtime as destroyed - _uid = self = _shim = shimContainer = null; - } - }); - - // once we got the mode, test against all caps - if (this.mode && options.required_caps && !this.can(options.required_caps)) { - this.mode = false; - } - } - - - /** - Default order to try different runtime types - - @property order - @type String - @static - */ - Runtime.order = 'html5,flash,silverlight,html4'; - - - /** - Retrieves runtime from private hash by it's uid - - @method getRuntime - @private - @static - @param {String} uid Unique identifier of the runtime - @return {Runtime|Boolean} Returns runtime, if it exists and false, if - not - */ - Runtime.getRuntime = function(uid) { - return runtimes[uid] ? runtimes[uid] : false; - }; - - - /** - Register constructor for the Runtime of new (or perhaps modified) type - - @method addConstructor - @static - @param {String} type Runtime type (e.g. flash, html5, etc) - @param {Function} construct Constructor for the Runtime type - */ - Runtime.addConstructor = function(type, constructor) { - constructor.prototype = EventTarget.instance; - runtimeConstructors[type] = constructor; - }; - - - /** - Get the constructor for the specified type. - - method getConstructor - @static - @param {String} type Runtime type (e.g. flash, html5, etc) - @return {Function} Constructor for the Runtime type - */ - Runtime.getConstructor = function(type) { - return runtimeConstructors[type] || null; - }; - - - /** - Get info about the runtime (uid, type, capabilities) - - @method getInfo - @static - @param {String} uid Unique identifier of the runtime - @return {Mixed} Info object or null if runtime doesn't exist - */ - Runtime.getInfo = function(uid) { - var runtime = Runtime.getRuntime(uid); - - if (runtime) { - return { - uid: runtime.uid, - type: runtime.type, - mode: runtime.mode, - can: function() { - return runtime.can.apply(runtime, arguments); - } - }; - } - return null; - }; - - - /** - Convert caps represented by a comma-separated string to the object representation. - - @method parseCaps - @static - @param {String} capStr Comma-separated list of capabilities - @return {Object} - */ - Runtime.parseCaps = function(capStr) { - var capObj = {}; - - if (Basic.typeOf(capStr) !== 'string') { - return capStr || {}; - } - - Basic.each(capStr.split(','), function(key) { - capObj[key] = true; // we assume it to be - true - }); - - return capObj; - }; - - /** - Test the specified runtime for specific capabilities. - - @method can - @static - @param {String} type Runtime type (e.g. flash, html5, etc) - @param {String|Object} caps Set of capabilities to check - @return {Boolean} Result of the test - */ - Runtime.can = function(type, caps) { - var runtime - , constructor = Runtime.getConstructor(type) - , mode - ; - if (constructor) { - runtime = new constructor({ - required_caps: caps - }); - mode = runtime.mode; - runtime.destroy(); - return !!mode; - } - return false; - }; - - - /** - Figure out a runtime that supports specified capabilities. - - @method thatCan - @static - @param {String|Object} caps Set of capabilities to check - @param {String} [runtimeOrder] Comma-separated list of runtimes to check against - @return {String} Usable runtime identifier or null - */ - Runtime.thatCan = function(caps, runtimeOrder) { - var types = (runtimeOrder || Runtime.order).split(/\s*,\s*/); - for (var i in types) { - if (Runtime.can(types[i], caps)) { - return types[i]; - } - } - return null; - }; - - - /** - Figure out an operational mode for the specified set of capabilities. - - @method getMode - @static - @param {Object} modeCaps Set of capabilities that depend on particular runtime mode - @param {Object} [requiredCaps] Supplied set of capabilities to find operational mode for - @param {String|Boolean} [defaultMode='browser'] Default mode to use - @return {String|Boolean} Compatible operational mode - */ - Runtime.getMode = function(modeCaps, requiredCaps, defaultMode) { - var mode = null; - - if (Basic.typeOf(defaultMode) === 'undefined') { // only if not specified - defaultMode = 'browser'; - } - - if (requiredCaps && !Basic.isEmptyObj(modeCaps)) { - // loop over required caps and check if they do require the same mode - Basic.each(requiredCaps, function(value, cap) { - if (modeCaps.hasOwnProperty(cap)) { - var capMode = modeCaps[cap](value); - - // make sure we always have an array - if (typeof(capMode) === 'string') { - capMode = [capMode]; - } - - if (!mode) { - mode = capMode; - } else if (!(mode = Basic.arrayIntersect(mode, capMode))) { - // if cap requires conflicting mode - runtime cannot fulfill required caps - - if (MXI_DEBUG && Env.debug.runtime) { - Env.log("\t\t%s: %s (conflicting mode requested: %s)", cap, value, capMode); - } - - return (mode = false); - } - } - - if (MXI_DEBUG && Env.debug.runtime) { - Env.log("\t\t%s: %s (compatible modes: %s)", cap, value, mode); - } - }); - - if (mode) { - return Basic.inArray(defaultMode, mode) !== -1 ? defaultMode : mode[0]; - } else if (mode === false) { - return false; - } - } - return defaultMode; - }; - - - /** - * Third party shims (Flash and Silverlight) require global event target against which they - * will fire their events. However when moxie is not loaded to global namespace, default - * event target is not accessible and we have to create artificial ones. - * - * @method getGlobalEventTarget - * @static - * @return {String} Name of the global event target - */ - Runtime.getGlobalEventTarget = function() { - if (/^moxie\./.test(Env.global_event_dispatcher) && !Env.can('access_global_ns')) { - var uniqueCallbackName = Basic.guid('moxie_event_target_'); - - window[uniqueCallbackName] = function(e, data) { - EventTarget.instance.dispatchEvent(e, data); - }; - - Env.global_event_dispatcher = uniqueCallbackName; - } - - return Env.global_event_dispatcher; - }; - - - /** - Capability check that always returns true - - @private - @static - @return {True} - */ - Runtime.capTrue = function() { - return true; - }; - - /** - Capability check that always returns false - - @private - @static - @return {False} - */ - Runtime.capFalse = function() { - return false; - }; - - /** - Evaluate the expression to boolean value and create a function that always returns it. - - @private - @static - @param {Mixed} expr Expression to evaluate - @return {Function} Function returning the result of evaluation - */ - Runtime.capTest = function(expr) { - return function() { - return !!expr; - }; - }; - - return Runtime; -}); - -// Included from: src/javascript/runtime/RuntimeClient.js - -/** - * RuntimeClient.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -define('moxie/runtime/RuntimeClient', [ - 'moxie/core/utils/Env', - 'moxie/core/Exceptions', - 'moxie/core/utils/Basic', - 'moxie/runtime/Runtime' -], function(Env, x, Basic, Runtime) { - /** - Set of methods and properties, required by a component to acquire ability to connect to a runtime - - @class moxie/runtime/RuntimeClient - */ - return function RuntimeClient() { - var runtime; - - Basic.extend(this, { - /** - Connects to the runtime specified by the options. Will either connect to existing runtime or create a new one. - Increments number of clients connected to the specified runtime. - - @private - @method connectRuntime - @param {Mixed} options Can be a runtme uid or a set of key-value pairs defining requirements and pre-requisites - */ - connectRuntime: function(options) { - var comp = this, ruid; - - function initialize(items) { - var type, constructor; - - // if we ran out of runtimes - if (!items.length) { - comp.trigger('RuntimeError', new x.RuntimeError(x.RuntimeError.NOT_INIT_ERR)); - runtime = null; - return; - } - - type = items.shift().toLowerCase(); - constructor = Runtime.getConstructor(type); - if (!constructor) { - if (MXI_DEBUG && Env.debug.runtime) { - Env.log("Constructor for '%s' runtime is not available.", type); - } - initialize(items); - return; - } - - if (MXI_DEBUG && Env.debug.runtime) { - Env.log("Trying runtime: %s", type); - Env.log(options); - } - - // try initializing the runtime - runtime = new constructor(options); - - runtime.bind('Init', function() { - // mark runtime as initialized - runtime.initialized = true; - - if (MXI_DEBUG && Env.debug.runtime) { - Env.log("Runtime '%s' initialized", runtime.type); - } - - // jailbreak ... - setTimeout(function() { - runtime.clients++; - comp.ruid = runtime.uid; - // this will be triggered on component - comp.trigger('RuntimeInit', runtime); - }, 1); - }); - - runtime.bind('Error', function() { - if (MXI_DEBUG && Env.debug.runtime) { - Env.log("Runtime '%s' failed to initialize", runtime.type); - } - - runtime.destroy(); // runtime cannot destroy itself from inside at a right moment, thus we do it here - initialize(items); - }); - - runtime.bind('Exception', function(e, err) { - var message = err.name + "(#" + err.code + ")" + (err.message ? ", from: " + err.message : ''); - - if (MXI_DEBUG && Env.debug.runtime) { - Env.log("Runtime '%s' has thrown an exception: %s", this.type, message); - } - comp.trigger('RuntimeError', new x.RuntimeError(x.RuntimeError.EXCEPTION_ERR, message)); - }); - - if (MXI_DEBUG && Env.debug.runtime) { - Env.log("\tselected mode: %s", runtime.mode); - } - - // check if runtime managed to pick-up operational mode - if (!runtime.mode) { - runtime.trigger('Error'); - return; - } - - runtime.init(); - } - - // check if a particular runtime was requested - if (Basic.typeOf(options) === 'string') { - ruid = options; - } else if (Basic.typeOf(options.ruid) === 'string') { - ruid = options.ruid; - } - - if (ruid) { - runtime = Runtime.getRuntime(ruid); - if (runtime) { - comp.ruid = ruid; - runtime.clients++; - return runtime; - } else { - // there should be a runtime and there's none - weird case - throw new x.RuntimeError(x.RuntimeError.NOT_INIT_ERR); - } - } - - // initialize a fresh one, that fits runtime list and required features best - initialize((options.runtime_order || Runtime.order).split(/\s*,\s*/)); - }, - - - /** - Disconnects from the runtime. Decrements number of clients connected to the specified runtime. - - @private - @method disconnectRuntime - */ - disconnectRuntime: function() { - if (runtime && --runtime.clients <= 0) { - runtime.destroy(); - } - - // once the component is disconnected, it shouldn't have access to the runtime - runtime = null; - }, - - - /** - Returns the runtime to which the client is currently connected. - - @method getRuntime - @return {Runtime} Runtime or null if client is not connected - */ - getRuntime: function() { - if (runtime && runtime.uid) { - return runtime; - } - return runtime = null; // make sure we do not leave zombies rambling around - }, - - - /** - Handy shortcut to safely invoke runtime extension methods. - - @private - @method exec - @return {Mixed} Whatever runtime extension method returns - */ - exec: function() { - return runtime ? runtime.exec.apply(this, arguments) : null; - }, - - - /** - Test runtime client for specific capability - - @method can - @param {String} cap - @return {Bool} - */ - can: function(cap) { - return runtime ? runtime.can(cap) : false; - } - - }); - }; - - -}); - -// Included from: src/javascript/file/Blob.js - -/** - * Blob.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -define('moxie/file/Blob', [ - 'moxie/core/utils/Basic', - 'moxie/core/utils/Encode', - 'moxie/runtime/RuntimeClient' -], function(Basic, Encode, RuntimeClient) { - - var blobpool = {}; - - /** - @class moxie/file/Blob - @constructor - @param {String} ruid Unique id of the runtime, to which this blob belongs to - @param {Object} blob Object "Native" blob object, as it is represented in the runtime - */ - function Blob(ruid, blob) { - - function _sliceDetached(start, end, type) { - var blob, data = blobpool[this.uid]; - - if (Basic.typeOf(data) !== 'string' || !data.length) { - return null; // or throw exception - } - - blob = new Blob(null, { - type: type, - size: end - start - }); - blob.detach(data.substr(start, blob.size)); - - return blob; - } - - RuntimeClient.call(this); - - if (ruid) { - this.connectRuntime(ruid); - } - - if (!blob) { - blob = {}; - } else if (Basic.typeOf(blob) === 'string') { // dataUrl or binary string - blob = { data: blob }; - } - - Basic.extend(this, { - - /** - Unique id of the component - - @property uid - @type {String} - */ - uid: blob.uid || Basic.guid('uid_'), - - /** - Unique id of the connected runtime, if falsy, then runtime will have to be initialized - before this Blob can be used, modified or sent - - @property ruid - @type {String} - */ - ruid: ruid, - - /** - Size of blob - - @property size - @type {Number} - @default 0 - */ - size: blob.size || 0, - - /** - Mime type of blob - - @property type - @type {String} - @default '' - */ - type: blob.type || '', - - /** - @method slice - @param {Number} [start=0] - */ - slice: function(start, end, type) { - if (this.isDetached()) { - return _sliceDetached.apply(this, arguments); - } - return this.getRuntime().exec.call(this, 'Blob', 'slice', this.getSource(), start, end, type); - }, - - /** - Returns "native" blob object (as it is represented in connected runtime) or null if not found - - @method getSource - @return {Blob} Returns "native" blob object or null if not found - */ - getSource: function() { - if (!blobpool[this.uid]) { - return null; - } - return blobpool[this.uid]; - }, - - /** - Detaches blob from any runtime that it depends on and initialize with standalone value - - @method detach - @protected - @param {DOMString} [data=''] Standalone value - */ - detach: function(data) { - if (this.ruid) { - this.getRuntime().exec.call(this, 'Blob', 'destroy'); - this.disconnectRuntime(); - this.ruid = null; - } - - data = data || ''; - - // if dataUrl, convert to binary string - if (data.substr(0, 5) == 'data:') { - var base64Offset = data.indexOf(';base64,'); - this.type = data.substring(5, base64Offset); - data = Encode.atob(data.substring(base64Offset + 8)); - } - - this.size = data.length; - - blobpool[this.uid] = data; - }, - - /** - Checks if blob is standalone (detached of any runtime) - - @method isDetached - @protected - @return {Boolean} - */ - isDetached: function() { - return !this.ruid && Basic.typeOf(blobpool[this.uid]) === 'string'; - }, - - /** - Destroy Blob and free any resources it was using - - @method destroy - */ - destroy: function() { - this.detach(); - delete blobpool[this.uid]; - } - }); - - - if (blob.data) { - this.detach(blob.data); // auto-detach if payload has been passed - } else { - blobpool[this.uid] = blob; - } - } - - return Blob; -}); - -// Included from: src/javascript/core/I18n.js - -/** - * I18n.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -define("moxie/core/I18n", [ - "moxie/core/utils/Basic" -], function(Basic) { - var i18n = {}; - - /** - @class moxie/core/I18n - */ - return { - /** - * Extends the language pack object with new items. - * - * @param {Object} pack Language pack items to add. - * @return {Object} Extended language pack object. - */ - addI18n: function(pack) { - return Basic.extend(i18n, pack); - }, - - /** - * Translates the specified string by checking for the english string in the language pack lookup. - * - * @param {String} str String to look for. - * @return {String} Translated string or the input string if it wasn't found. - */ - translate: function(str) { - return i18n[str] || str; - }, - - /** - * Shortcut for translate function - * - * @param {String} str String to look for. - * @return {String} Translated string or the input string if it wasn't found. - */ - _: function(str) { - return this.translate(str); - }, - - /** - * Pseudo sprintf implementation - simple way to replace tokens with specified values. - * - * @param {String} str String with tokens - * @return {String} String with replaced tokens - */ - sprintf: function(str) { - var args = [].slice.call(arguments, 1); - - return str.replace(/%[a-z]/g, function() { - var value = args.shift(); - return Basic.typeOf(value) !== 'undefined' ? value : ''; - }); - } - }; -}); - -// Included from: src/javascript/core/utils/Mime.js - -/** - * Mime.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/core/utils/Mime -@public -@static -*/ - -define("moxie/core/utils/Mime", [ - "moxie/core/utils/Basic", - "moxie/core/I18n" -], function(Basic, I18n) { - - var mimeData = "" + - "application/msword,doc dot," + - "application/pdf,pdf," + - "application/pgp-signature,pgp," + - "application/postscript,ps ai eps," + - "application/rtf,rtf," + - "application/vnd.ms-excel,xls xlb xlt xla," + - "application/vnd.ms-powerpoint,ppt pps pot ppa," + - "application/zip,zip," + - "application/x-shockwave-flash,swf swfl," + - "application/vnd.openxmlformats-officedocument.wordprocessingml.document,docx," + - "application/vnd.openxmlformats-officedocument.wordprocessingml.template,dotx," + - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,xlsx," + - "application/vnd.openxmlformats-officedocument.presentationml.presentation,pptx," + - "application/vnd.openxmlformats-officedocument.presentationml.template,potx," + - "application/vnd.openxmlformats-officedocument.presentationml.slideshow,ppsx," + - "application/x-javascript,js," + - "application/json,json," + - "audio/mpeg,mp3 mpga mpega mp2," + - "audio/x-wav,wav," + - "audio/x-m4a,m4a," + - "audio/ogg,oga ogg," + - "audio/aiff,aiff aif," + - "audio/flac,flac," + - "audio/aac,aac," + - "audio/ac3,ac3," + - "audio/x-ms-wma,wma," + - "image/bmp,bmp," + - "image/gif,gif," + - "image/jpeg,jpg jpeg jpe," + - "image/photoshop,psd," + - "image/png,png," + - "image/svg+xml,svg svgz," + - "image/tiff,tiff tif," + - "text/plain,asc txt text diff log," + - "text/html,htm html xhtml," + - "text/css,css," + - "text/csv,csv," + - "text/rtf,rtf," + - "video/mpeg,mpeg mpg mpe m2v," + - "video/quicktime,qt mov," + - "video/mp4,mp4," + - "video/x-m4v,m4v," + - "video/x-flv,flv," + - "video/x-ms-wmv,wmv," + - "video/avi,avi," + - "video/webm,webm," + - "video/3gpp,3gpp 3gp," + - "video/3gpp2,3g2," + - "video/vnd.rn-realvideo,rv," + - "video/ogg,ogv," + - "video/x-matroska,mkv," + - "application/vnd.oasis.opendocument.formula-template,otf," + - "application/octet-stream,exe"; - - - /** - * Map of mimes to extensions - * - * @property mimes - * @type {Object} - */ - var mimes = {}; - - /** - * Map of extensions to mimes - * - * @property extensions - * @type {Object} - */ - var extensions = {}; - - - /** - * Parses mimeData string into a mimes and extensions lookup maps. String should have the - * following format: - * - * application/msword,doc dot,application/pdf,pdf, ... - * - * so mime-type followed by comma and followed by space-separated list of associated extensions, - * then comma again and then another mime-type, etc. - * - * If invoked externally will replace override internal lookup maps with user-provided data. - * - * @method addMimeType - * @param {String} mimeData - */ - var addMimeType = function (mimeData) { - var items = mimeData.split(/,/), i, ii, ext; - - for (i = 0; i < items.length; i += 2) { - ext = items[i + 1].split(/ /); - - // extension to mime lookup - for (ii = 0; ii < ext.length; ii++) { - mimes[ext[ii]] = items[i]; - } - // mime to extension lookup - extensions[items[i]] = ext; - } - }; - - - var extList2mimes = function (filters, addMissingExtensions) { - var ext, i, ii, type, mimes = []; - - // convert extensions to mime types list - for (i = 0; i < filters.length; i++) { - ext = filters[i].extensions.toLowerCase().split(/\s*,\s*/); - - for (ii = 0; ii < ext.length; ii++) { - - // if there's an asterisk in the list, then accept attribute is not required - if (ext[ii] === '*') { - return []; - } - - type = mimes[ext[ii]]; - - // future browsers should filter by extension, finally - if (addMissingExtensions && /^\w+$/.test(ext[ii])) { - mimes.push('.' + ext[ii]); - } else if (type && Basic.inArray(type, mimes) === -1) { - mimes.push(type); - } else if (!type) { - // if we have no type in our map, then accept all - return []; - } - } - } - return mimes; - }; - - - var mimes2exts = function(mimes) { - var exts = []; - - Basic.each(mimes, function(mime) { - mime = mime.toLowerCase(); - - if (mime === '*') { - exts = []; - return false; - } - - // check if this thing looks like mime type - var m = mime.match(/^(\w+)\/(\*|\w+)$/); - if (m) { - if (m[2] === '*') { - // wildcard mime type detected - Basic.each(extensions, function(arr, mime) { - if ((new RegExp('^' + m[1] + '/')).test(mime)) { - [].push.apply(exts, extensions[mime]); - } - }); - } else if (extensions[mime]) { - [].push.apply(exts, extensions[mime]); - } - } - }); - return exts; - }; - - - var mimes2extList = function(mimes) { - var accept = [], exts = []; - - if (Basic.typeOf(mimes) === 'string') { - mimes = Basic.trim(mimes).split(/\s*,\s*/); - } - - exts = mimes2exts(mimes); - - accept.push({ - title: I18n.translate('Files'), - extensions: exts.length ? exts.join(',') : '*' - }); - - return accept; - }; - - /** - * Extract extension from the given filename - * - * @method getFileExtension - * @param {String} fileName - * @return {String} File extension - */ - var getFileExtension = function(fileName) { - var matches = fileName && fileName.match(/\.([^.]+)$/); - if (matches) { - return matches[1].toLowerCase(); - } - return ''; - }; - - - /** - * Get file mime-type from it's filename - will try to match the extension - * against internal mime-type lookup map - * - * @method getFileMime - * @param {String} fileName - * @return File mime-type if found or an empty string if not - */ - var getFileMime = function(fileName) { - return mimes[getFileExtension(fileName)] || ''; - }; - - - addMimeType(mimeData); - - return { - mimes: mimes, - extensions: extensions, - addMimeType: addMimeType, - extList2mimes: extList2mimes, - mimes2exts: mimes2exts, - mimes2extList: mimes2extList, - getFileExtension: getFileExtension, - getFileMime: getFileMime - } -}); - -// Included from: src/javascript/file/FileInput.js - -/** - * FileInput.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -define('moxie/file/FileInput', [ - 'moxie/core/utils/Basic', - 'moxie/core/utils/Env', - 'moxie/core/utils/Mime', - 'moxie/core/utils/Dom', - 'moxie/core/Exceptions', - 'moxie/core/EventTarget', - 'moxie/core/I18n', - 'moxie/runtime/Runtime', - 'moxie/runtime/RuntimeClient' -], function(Basic, Env, Mime, Dom, x, EventTarget, I18n, Runtime, RuntimeClient) { - /** - Provides a convenient way to create cross-browser file-picker. Generates file selection dialog on click, - converts selected files to _File_ objects, to be used in conjunction with _Image_, preloaded in memory - with _FileReader_ or uploaded to a server through _XMLHttpRequest_. - - @class moxie/file/FileInput - @constructor - @extends EventTarget - @uses RuntimeClient - @param {Object|String|DOMElement} options If options is string or node, argument is considered as _browse\_button_. - @param {String|DOMElement} options.browse_button DOM Element to turn into file picker. - @param {Array} [options.accept] Array of mime types to accept. By default accepts all. - @param {Boolean} [options.multiple=false] Enable selection of multiple files. - @param {Boolean} [options.directory=false] Turn file input into the folder input (cannot be both at the same time). - @param {String|DOMElement} [options.container] DOM Element to use as a container for file-picker. Defaults to parentNode - for _browse\_button_. - @param {Object|String} [options.required_caps] Set of required capabilities, that chosen runtime must support. - - @example -
    - - - */ - var dispatches = [ - /** - Dispatched when runtime is connected and file-picker is ready to be used. - - @event ready - @param {Object} event - */ - 'ready', - - /** - Dispatched right after [ready](#event_ready) event, and whenever [refresh()](#method_refresh) is invoked. - Check [corresponding documentation entry](#method_refresh) for more info. - - @event refresh - @param {Object} event - */ - - /** - Dispatched when selection of files in the dialog is complete. - - @event change - @param {Object} event - */ - 'change', - - 'cancel', // TODO: might be useful - - /** - Dispatched when mouse cursor enters file-picker area. Can be used to style element - accordingly. - - @event mouseenter - @param {Object} event - */ - 'mouseenter', - - /** - Dispatched when mouse cursor leaves file-picker area. Can be used to style element - accordingly. - - @event mouseleave - @param {Object} event - */ - 'mouseleave', - - /** - Dispatched when functional mouse button is pressed on top of file-picker area. - - @event mousedown - @param {Object} event - */ - 'mousedown', - - /** - Dispatched when functional mouse button is released on top of file-picker area. - - @event mouseup - @param {Object} event - */ - 'mouseup' - ]; - - function FileInput(options) { - if (MXI_DEBUG) { - Env.log("Instantiating FileInput..."); - } - - var container, browseButton, defaults; - - // if flat argument passed it should be browse_button id - if (Basic.inArray(Basic.typeOf(options), ['string', 'node']) !== -1) { - options = { browse_button : options }; - } - - // this will help us to find proper default container - browseButton = Dom.get(options.browse_button); - if (!browseButton) { - // browse button is required - throw new x.DOMException(x.DOMException.NOT_FOUND_ERR); - } - - // figure out the options - defaults = { - accept: [{ - title: I18n.translate('All Files'), - extensions: '*' - }], - multiple: false, - required_caps: false, - container: browseButton.parentNode || document.body - }; - - options = Basic.extend({}, defaults, options); - - // convert to object representation - if (typeof(options.required_caps) === 'string') { - options.required_caps = Runtime.parseCaps(options.required_caps); - } - - // normalize accept option (could be list of mime types or array of title/extensions pairs) - if (typeof(options.accept) === 'string') { - options.accept = Mime.mimes2extList(options.accept); - } - - container = Dom.get(options.container); - // make sure we have container - if (!container) { - container = document.body; - } - - // make container relative, if it's not - if (Dom.getStyle(container, 'position') === 'static') { - container.style.position = 'relative'; - } - - container = browseButton = null; // IE - - RuntimeClient.call(this); - - Basic.extend(this, { - /** - Unique id of the component - - @property uid - @protected - @readOnly - @type {String} - @default UID - */ - uid: Basic.guid('uid_'), - - /** - Unique id of the connected runtime, if any. - - @property ruid - @protected - @type {String} - */ - ruid: null, - - /** - Unique id of the runtime container. Useful to get hold of it for various manipulations. - - @property shimid - @protected - @type {String} - */ - shimid: null, - - /** - Array of selected moxie.file.File objects - - @property files - @type {Array} - @default null - */ - files: null, - - /** - Initializes the file-picker, connects it to runtime and dispatches event ready when done. - - @method init - */ - init: function() { - var self = this; - - self.bind('RuntimeInit', function(e, runtime) { - self.ruid = runtime.uid; - self.shimid = runtime.shimid; - - self.bind("Ready", function() { - self.trigger("Refresh"); - }, 999); - - // re-position and resize shim container - self.bind('Refresh', function() { - var pos, size, browseButton, shimContainer, zIndex; - - browseButton = Dom.get(options.browse_button); - shimContainer = Dom.get(runtime.shimid); // do not use runtime.getShimContainer(), since it will create container if it doesn't exist - - if (browseButton) { - pos = Dom.getPos(browseButton, Dom.get(options.container)); - size = Dom.getSize(browseButton); - zIndex = parseInt(Dom.getStyle(browseButton, 'z-index'), 10) || 0; - - if (shimContainer) { - Basic.extend(shimContainer.style, { - top: pos.y + 'px', - left: pos.x + 'px', - width: size.w + 'px', - height: size.h + 'px', - zIndex: zIndex + 1 - }); - } - } - shimContainer = browseButton = null; - }); - - runtime.exec.call(self, 'FileInput', 'init', options); - }); - - // runtime needs: options.required_features, options.runtime_order and options.container - self.connectRuntime(Basic.extend({}, options, { - required_caps: { - select_file: true - } - })); - }, - - - /** - * Get current option value by its name - * - * @method getOption - * @param name - * @return {Mixed} - */ - getOption: function(name) { - return options[name]; - }, - - - /** - * Sets a new value for the option specified by name - * - * @method setOption - * @param name - * @param value - */ - setOption: function(name, value) { - if (!options.hasOwnProperty(name)) { - return; - } - - var oldValue = options[name]; - - switch (name) { - case 'accept': - if (typeof(value) === 'string') { - value = Mime.mimes2extList(value); - } - break; - - case 'container': - case 'required_caps': - throw new x.FileException(x.FileException.NO_MODIFICATION_ALLOWED_ERR); - } - - options[name] = value; - this.exec('FileInput', 'setOption', name, value); - - this.trigger('OptionChanged', name, value, oldValue); - }, - - /** - Disables file-picker element, so that it doesn't react to mouse clicks. - - @method disable - @param {Boolean} [state=true] Disable component if - true, enable if - false - */ - disable: function(state) { - var runtime = this.getRuntime(); - if (runtime) { - this.exec('FileInput', 'disable', Basic.typeOf(state) === 'undefined' ? true : state); - } - }, - - - /** - Reposition and resize dialog trigger to match the position and size of browse_button element. - - @method refresh - */ - refresh: function() { - this.trigger("Refresh"); - }, - - - /** - Destroy component. - - @method destroy - */ - destroy: function() { - var runtime = this.getRuntime(); - if (runtime) { - runtime.exec.call(this, 'FileInput', 'destroy'); - this.disconnectRuntime(); - } - - if (Basic.typeOf(this.files) === 'array') { - // no sense in leaving associated files behind - Basic.each(this.files, function(file) { - file.destroy(); - }); - } - this.files = null; - - this.unbindAll(); - } - }); - - this.handleEventProps(dispatches); - } - - FileInput.prototype = EventTarget.instance; - - return FileInput; -}); - -// Included from: src/javascript/file/File.js - -/** - * File.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -define('moxie/file/File', [ - 'moxie/core/utils/Basic', - 'moxie/core/utils/Mime', - 'moxie/file/Blob' -], function(Basic, Mime, Blob) { - /** - @class moxie/file/File - @extends Blob - @constructor - @param {String} ruid Unique id of the runtime, to which this blob belongs to - @param {Object} file Object "Native" file object, as it is represented in the runtime - */ - function File(ruid, file) { - if (!file) { // avoid extra errors in case we overlooked something - file = {}; - } - - Blob.apply(this, arguments); - - if (!this.type) { - this.type = Mime.getFileMime(file.name); - } - - // sanitize file name or generate new one - var name; - if (file.name) { - name = file.name.replace(/\\/g, '/'); - name = name.substr(name.lastIndexOf('/') + 1); - } else if (this.type) { - var prefix = this.type.split('/')[0]; - name = Basic.guid((prefix !== '' ? prefix : 'file') + '_'); - - if (Mime.extensions[this.type]) { - name += '.' + Mime.extensions[this.type][0]; // append proper extension if possible - } - } - - - Basic.extend(this, { - /** - File name - - @property name - @type {String} - @default UID - */ - name: name || Basic.guid('file_'), - - /** - Relative path to the file inside a directory - - @property relativePath - @type {String} - @default '' - */ - relativePath: '', - - /** - Date of last modification - - @property lastModifiedDate - @type {String} - @default now - */ - lastModifiedDate: file.lastModified ? new Date(file.lastModified) : file.lastModifiedDate || (new Date()).toLocaleString() // Thu Aug 23 2012 19:40:00 GMT+0400 (GET) - }); - } - - File.prototype = Blob.prototype; - - return File; -}); - -// Included from: src/javascript/file/FileDrop.js - -/** - * FileDrop.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -define('moxie/file/FileDrop', [ - 'moxie/core/I18n', - 'moxie/core/utils/Dom', - 'moxie/core/Exceptions', - 'moxie/core/utils/Basic', - 'moxie/core/utils/Env', - 'moxie/file/File', - 'moxie/runtime/RuntimeClient', - 'moxie/core/EventTarget', - 'moxie/core/utils/Mime' -], function(I18n, Dom, x, Basic, Env, File, RuntimeClient, EventTarget, Mime) { - /** - Turn arbitrary DOM element to a drop zone accepting files. Converts selected files to _File_ objects, to be used - in conjunction with _Image_, preloaded in memory with _FileReader_ or uploaded to a server through - _XMLHttpRequest_. - - @example -
    - Drop files here -
    -
    -
    - - - - @class moxie/file/FileDrop - @constructor - @extends EventTarget - @uses RuntimeClient - @param {Object|String} options If options has typeof string, argument is considered as options.drop_zone - @param {String|DOMElement} options.drop_zone DOM Element to turn into a drop zone - @param {Array} [options.accept] Array of mime types to accept. By default accepts all - @param {Object|String} [options.required_caps] Set of required capabilities, that chosen runtime must support - */ - var dispatches = [ - /** - Dispatched when runtime is connected and drop zone is ready to accept files. - - @event ready - @param {Object} event - */ - 'ready', - - /** - Dispatched when dragging cursor enters the drop zone. - - @event dragenter - @param {Object} event - */ - 'dragenter', - - /** - Dispatched when dragging cursor leaves the drop zone. - - @event dragleave - @param {Object} event - */ - 'dragleave', - - /** - Dispatched when file is dropped onto the drop zone. - - @event drop - @param {Object} event - */ - 'drop', - - /** - Dispatched if error occurs. - - @event error - @param {Object} event - */ - 'error' - ]; - - function FileDrop(options) { - if (MXI_DEBUG) { - Env.log("Instantiating FileDrop..."); - } - - var self = this, defaults; - - // if flat argument passed it should be drop_zone id - if (typeof(options) === 'string') { - options = { drop_zone : options }; - } - - // figure out the options - defaults = { - accept: [{ - title: I18n.translate('All Files'), - extensions: '*' - }], - required_caps: { - drag_and_drop: true - } - }; - - options = typeof(options) === 'object' ? Basic.extend({}, defaults, options) : defaults; - - // this will help us to find proper default container - options.container = Dom.get(options.drop_zone) || document.body; - - // make container relative, if it is not - if (Dom.getStyle(options.container, 'position') === 'static') { - options.container.style.position = 'relative'; - } - - // normalize accept option (could be list of mime types or array of title/extensions pairs) - if (typeof(options.accept) === 'string') { - options.accept = Mime.mimes2extList(options.accept); - } - - RuntimeClient.call(self); - - Basic.extend(self, { - uid: Basic.guid('uid_'), - - ruid: null, - - files: null, - - init: function() { - self.bind('RuntimeInit', function(e, runtime) { - self.ruid = runtime.uid; - runtime.exec.call(self, 'FileDrop', 'init', options); - self.dispatchEvent('ready'); - }); - - // runtime needs: options.required_features, options.runtime_order and options.container - self.connectRuntime(options); // throws RuntimeError - }, - - destroy: function() { - var runtime = this.getRuntime(); - if (runtime) { - runtime.exec.call(this, 'FileDrop', 'destroy'); - this.disconnectRuntime(); - } - this.files = null; - - this.unbindAll(); - } - }); - - this.handleEventProps(dispatches); - } - - FileDrop.prototype = EventTarget.instance; - - return FileDrop; -}); - -// Included from: src/javascript/file/FileReader.js - -/** - * FileReader.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -define('moxie/file/FileReader', [ - 'moxie/core/utils/Basic', - 'moxie/core/utils/Encode', - 'moxie/core/Exceptions', - 'moxie/core/EventTarget', - 'moxie/file/Blob', - 'moxie/runtime/RuntimeClient' -], function(Basic, Encode, x, EventTarget, Blob, RuntimeClient) { - /** - Utility for preloading o.Blob/o.File objects in memory. By design closely follows [W3C FileReader](http://www.w3.org/TR/FileAPI/#dfn-filereader) - interface. Where possible uses native FileReader, where - not falls back to shims. - - @class moxie/file/FileReader - @constructor FileReader - @extends EventTarget - @uses RuntimeClient - */ - var dispatches = [ - - /** - Dispatched when the read starts. - - @event loadstart - @param {Object} event - */ - 'loadstart', - - /** - Dispatched while reading (and decoding) blob, and reporting partial Blob data (progess.loaded/progress.total). - - @event progress - @param {Object} event - */ - 'progress', - - /** - Dispatched when the read has successfully completed. - - @event load - @param {Object} event - */ - 'load', - - /** - Dispatched when the read has been aborted. For instance, by invoking the abort() method. - - @event abort - @param {Object} event - */ - 'abort', - - /** - Dispatched when the read has failed. - - @event error - @param {Object} event - */ - 'error', - - /** - Dispatched when the request has completed (either in success or failure). - - @event loadend - @param {Object} event - */ - 'loadend' - ]; - - function FileReader() { - - RuntimeClient.call(this); - - Basic.extend(this, { - /** - UID of the component instance. - - @property uid - @type {String} - */ - uid: Basic.guid('uid_'), - - /** - Contains current state of FileReader object. Can take values of FileReader.EMPTY, FileReader.LOADING - and FileReader.DONE. - - @property readyState - @type {Number} - @default FileReader.EMPTY - */ - readyState: FileReader.EMPTY, - - /** - Result of the successful read operation. - - @property result - @type {String} - */ - result: null, - - /** - Stores the error of failed asynchronous read operation. - - @property error - @type {DOMError} - */ - error: null, - - /** - Initiates reading of File/Blob object contents to binary string. - - @method readAsBinaryString - @param {Blob|File} blob Object to preload - */ - readAsBinaryString: function(blob) { - _read.call(this, 'readAsBinaryString', blob); - }, - - /** - Initiates reading of File/Blob object contents to dataURL string. - - @method readAsDataURL - @param {Blob|File} blob Object to preload - */ - readAsDataURL: function(blob) { - _read.call(this, 'readAsDataURL', blob); - }, - - /** - Initiates reading of File/Blob object contents to string. - - @method readAsText - @param {Blob|File} blob Object to preload - */ - readAsText: function(blob) { - _read.call(this, 'readAsText', blob); - }, - - /** - Aborts preloading process. - - @method abort - */ - abort: function() { - this.result = null; - - if (Basic.inArray(this.readyState, [FileReader.EMPTY, FileReader.DONE]) !== -1) { - return; - } else if (this.readyState === FileReader.LOADING) { - this.readyState = FileReader.DONE; - } - - this.exec('FileReader', 'abort'); - - this.trigger('abort'); - this.trigger('loadend'); - }, - - /** - Destroy component and release resources. - - @method destroy - */ - destroy: function() { - this.abort(); - this.exec('FileReader', 'destroy'); - this.disconnectRuntime(); - this.unbindAll(); - } - }); - - // uid must already be assigned - this.handleEventProps(dispatches); - - this.bind('Error', function(e, err) { - this.readyState = FileReader.DONE; - this.error = err; - }, 999); - - this.bind('Load', function(e) { - this.readyState = FileReader.DONE; - }, 999); - - - function _read(op, blob) { - var self = this; - - this.trigger('loadstart'); - - if (this.readyState === FileReader.LOADING) { - this.trigger('error', new x.DOMException(x.DOMException.INVALID_STATE_ERR)); - this.trigger('loadend'); - return; - } - - // if source is not o.Blob/o.File - if (!(blob instanceof Blob)) { - this.trigger('error', new x.DOMException(x.DOMException.NOT_FOUND_ERR)); - this.trigger('loadend'); - return; - } - - this.result = null; - this.readyState = FileReader.LOADING; - - if (blob.isDetached()) { - var src = blob.getSource(); - switch (op) { - case 'readAsText': - case 'readAsBinaryString': - this.result = src; - break; - case 'readAsDataURL': - this.result = 'data:' + blob.type + ';base64,' + Encode.btoa(src); - break; - } - this.readyState = FileReader.DONE; - this.trigger('load'); - this.trigger('loadend'); - } else { - this.connectRuntime(blob.ruid); - this.exec('FileReader', 'read', op, blob); - } - } - } - - /** - Initial FileReader state - - @property EMPTY - @type {Number} - @final - @static - @default 0 - */ - FileReader.EMPTY = 0; - - /** - FileReader switches to this state when it is preloading the source - - @property LOADING - @type {Number} - @final - @static - @default 1 - */ - FileReader.LOADING = 1; - - /** - Preloading is complete, this is a final state - - @property DONE - @type {Number} - @final - @static - @default 2 - */ - FileReader.DONE = 2; - - FileReader.prototype = EventTarget.instance; - - return FileReader; -}); - -// Included from: src/javascript/core/utils/Url.js - -/** - * Url.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/core/utils/Url -@public -@static -*/ - -define('moxie/core/utils/Url', [ - 'moxie/core/utils/Basic' -], function(Basic) { - /** - Parse url into separate components and fill in absent parts with parts from current url, - based on https://raw.github.com/kvz/phpjs/master/functions/url/parse_url.js - - @method parseUrl - @static - @param {String} url Url to parse (defaults to empty string if undefined) - @return {Object} Hash containing extracted uri components - */ - var parseUrl = function(url, currentUrl) { - var key = ['source', 'scheme', 'authority', 'userInfo', 'user', 'pass', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'fragment'] - , i = key.length - , ports = { - http: 80, - https: 443 - } - , uri = {} - , regex = /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@\/]*):?([^:@\/]*))?@)?(\[[\da-fA-F:]+\]|[^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/ - , m = regex.exec(url || '') - , isRelative - , isSchemeLess = /^\/\/\w/.test(url) - ; - - switch (Basic.typeOf(currentUrl)) { - case 'undefined': - currentUrl = parseUrl(document.location.href, false); - break; - - case 'string': - currentUrl = parseUrl(currentUrl, false); - break; - } - - while (i--) { - if (m[i]) { - uri[key[i]] = m[i]; - } - } - - isRelative = !isSchemeLess && !uri.scheme; - - if (isSchemeLess || isRelative) { - uri.scheme = currentUrl.scheme; - } - - // when url is relative, we set the origin and the path ourselves - if (isRelative) { - uri.host = currentUrl.host; - uri.port = currentUrl.port; - - var path = ''; - // for urls without trailing slash we need to figure out the path - if (/^[^\/]/.test(uri.path)) { - path = currentUrl.path; - // if path ends with a filename, strip it - if (/\/[^\/]*\.[^\/]*$/.test(path)) { - path = path.replace(/\/[^\/]+$/, '/'); - } else { - // avoid double slash at the end (see #127) - path = path.replace(/\/?$/, '/'); - } - } - uri.path = path + (uri.path || ''); // site may reside at domain.com or domain.com/subdir - } - - if (!uri.port) { - uri.port = ports[uri.scheme] || 80; - } - - uri.port = parseInt(uri.port, 10); - - if (!uri.path) { - uri.path = "/"; - } - - delete uri.source; - - return uri; - }; - - /** - Resolve url - among other things will turn relative url to absolute - - @method resolveUrl - @static - @param {String|Object} url Either absolute or relative, or a result of parseUrl call - @return {String} Resolved, absolute url - */ - var resolveUrl = function(url) { - var ports = { // we ignore default ports - http: 80, - https: 443 - } - , urlp = typeof(url) === 'object' ? url : parseUrl(url); - ; - - return urlp.scheme + '://' + urlp.host + (urlp.port !== ports[urlp.scheme] ? ':' + urlp.port : '') + urlp.path + (urlp.query ? urlp.query : ''); - }; - - /** - Check if specified url has the same origin as the current document - - @method hasSameOrigin - @static - @param {String|Object} url - @return {Boolean} - */ - var hasSameOrigin = function(url) { - function origin(url) { - return [url.scheme, url.host, url.port].join('/'); - } - - if (typeof url === 'string') { - url = parseUrl(url); - } - - return origin(parseUrl()) === origin(url); - }; - - return { - parseUrl: parseUrl, - resolveUrl: resolveUrl, - hasSameOrigin: hasSameOrigin - }; -}); - -// Included from: src/javascript/runtime/RuntimeTarget.js - -/** - * RuntimeTarget.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -define('moxie/runtime/RuntimeTarget', [ - 'moxie/core/utils/Basic', - 'moxie/runtime/RuntimeClient', - "moxie/core/EventTarget" -], function(Basic, RuntimeClient, EventTarget) { - /** - Instance of this class can be used as a target for the events dispatched by shims, - when allowing them onto components is for either reason inappropriate - - @class moxie/runtime/RuntimeTarget - @constructor - @protected - @extends EventTarget - */ - function RuntimeTarget() { - this.uid = Basic.guid('uid_'); - - RuntimeClient.call(this); - - this.destroy = function() { - this.disconnectRuntime(); - this.unbindAll(); - }; - } - - RuntimeTarget.prototype = EventTarget.instance; - - return RuntimeTarget; -}); - -// Included from: src/javascript/file/FileReaderSync.js - -/** - * FileReaderSync.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -define('moxie/file/FileReaderSync', [ - 'moxie/core/utils/Basic', - 'moxie/runtime/RuntimeClient', - 'moxie/core/utils/Encode' -], function(Basic, RuntimeClient, Encode) { - /** - Synchronous FileReader implementation. Something like this is available in WebWorkers environment, here - it can be used to read only preloaded blobs/files and only below certain size (not yet sure what that'd be, - but probably < 1mb). Not meant to be used directly by user. - - @class moxie/file/FileReaderSync - @private - @constructor - */ - return function() { - RuntimeClient.call(this); - - Basic.extend(this, { - uid: Basic.guid('uid_'), - - readAsBinaryString: function(blob) { - return _read.call(this, 'readAsBinaryString', blob); - }, - - readAsDataURL: function(blob) { - return _read.call(this, 'readAsDataURL', blob); - }, - - /*readAsArrayBuffer: function(blob) { - return _read.call(this, 'readAsArrayBuffer', blob); - },*/ - - readAsText: function(blob) { - return _read.call(this, 'readAsText', blob); - } - }); - - function _read(op, blob) { - if (blob.isDetached()) { - var src = blob.getSource(); - switch (op) { - case 'readAsBinaryString': - return src; - case 'readAsDataURL': - return 'data:' + blob.type + ';base64,' + Encode.btoa(src); - case 'readAsText': - var txt = ''; - for (var i = 0, length = src.length; i < length; i++) { - txt += String.fromCharCode(src[i]); - } - return txt; - } - } else { - var result = this.connectRuntime(blob.ruid).exec.call(this, 'FileReaderSync', 'read', op, blob); - this.disconnectRuntime(); - return result; - } - } - }; -}); - -// Included from: src/javascript/xhr/FormData.js - -/** - * FormData.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -define("moxie/xhr/FormData", [ - "moxie/core/Exceptions", - "moxie/core/utils/Basic", - "moxie/file/Blob" -], function(x, Basic, Blob) { - /** - FormData - - @class moxie/xhr/FormData - @constructor - */ - function FormData() { - var _blob, _fields = []; - - Basic.extend(this, { - /** - Append another key-value pair to the FormData object - - @method append - @param {String} name Name for the new field - @param {String|Blob|Array|Object} value Value for the field - */ - append: function(name, value) { - var self = this, valueType = Basic.typeOf(value); - - // according to specs value might be either Blob or String - if (value instanceof Blob) { - _blob = { - name: name, - value: value // unfortunately we can only send single Blob in one FormData - }; - } else if ('array' === valueType) { - name += '[]'; - - Basic.each(value, function(value) { - self.append(name, value); - }); - } else if ('object' === valueType) { - Basic.each(value, function(value, key) { - self.append(name + '[' + key + ']', value); - }); - } else if ('null' === valueType || 'undefined' === valueType || 'number' === valueType && isNaN(value)) { - self.append(name, "false"); - } else { - _fields.push({ - name: name, - value: value.toString() - }); - } - }, - - /** - Checks if FormData contains Blob. - - @method hasBlob - @return {Boolean} - */ - hasBlob: function() { - return !!this.getBlob(); - }, - - /** - Retrieves blob. - - @method getBlob - @return {Object} Either Blob if found or null - */ - getBlob: function() { - return _blob && _blob.value || null; - }, - - /** - Retrieves blob field name. - - @method getBlobName - @return {String} Either Blob field name or null - */ - getBlobName: function() { - return _blob && _blob.name || null; - }, - - /** - Loop over the fields in FormData and invoke the callback for each of them. - - @method each - @param {Function} cb Callback to call for each field - */ - each: function(cb) { - Basic.each(_fields, function(field) { - cb(field.value, field.name); - }); - - if (_blob) { - cb(_blob.value, _blob.name); - } - }, - - destroy: function() { - _blob = null; - _fields = []; - } - }); - } - - return FormData; -}); - -// Included from: src/javascript/xhr/XMLHttpRequest.js - -/** - * XMLHttpRequest.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -define("moxie/xhr/XMLHttpRequest", [ - "moxie/core/utils/Basic", - "moxie/core/Exceptions", - "moxie/core/EventTarget", - "moxie/core/utils/Encode", - "moxie/core/utils/Url", - "moxie/runtime/Runtime", - "moxie/runtime/RuntimeTarget", - "moxie/file/Blob", - "moxie/file/FileReaderSync", - "moxie/xhr/FormData", - "moxie/core/utils/Env", - "moxie/core/utils/Mime" -], function(Basic, x, EventTarget, Encode, Url, Runtime, RuntimeTarget, Blob, FileReaderSync, FormData, Env, Mime) { - - var httpCode = { - 100: 'Continue', - 101: 'Switching Protocols', - 102: 'Processing', - - 200: 'OK', - 201: 'Created', - 202: 'Accepted', - 203: 'Non-Authoritative Information', - 204: 'No Content', - 205: 'Reset Content', - 206: 'Partial Content', - 207: 'Multi-Status', - 226: 'IM Used', - - 300: 'Multiple Choices', - 301: 'Moved Permanently', - 302: 'Found', - 303: 'See Other', - 304: 'Not Modified', - 305: 'Use Proxy', - 306: 'Reserved', - 307: 'Temporary Redirect', - - 400: 'Bad Request', - 401: 'Unauthorized', - 402: 'Payment Required', - 403: 'Forbidden', - 404: 'Not Found', - 405: 'Method Not Allowed', - 406: 'Not Acceptable', - 407: 'Proxy Authentication Required', - 408: 'Request Timeout', - 409: 'Conflict', - 410: 'Gone', - 411: 'Length Required', - 412: 'Precondition Failed', - 413: 'Request Entity Too Large', - 414: 'Request-URI Too Long', - 415: 'Unsupported Media Type', - 416: 'Requested Range Not Satisfiable', - 417: 'Expectation Failed', - 422: 'Unprocessable Entity', - 423: 'Locked', - 424: 'Failed Dependency', - 426: 'Upgrade Required', - - 500: 'Internal Server Error', - 501: 'Not Implemented', - 502: 'Bad Gateway', - 503: 'Service Unavailable', - 504: 'Gateway Timeout', - 505: 'HTTP Version Not Supported', - 506: 'Variant Also Negotiates', - 507: 'Insufficient Storage', - 510: 'Not Extended' - }; - - function XMLHttpRequestUpload() { - this.uid = Basic.guid('uid_'); - } - - XMLHttpRequestUpload.prototype = EventTarget.instance; - - /** - Implementation of XMLHttpRequest - - @class moxie/xhr/XMLHttpRequest - @constructor - @uses RuntimeClient - @extends EventTarget - */ - var dispatches = [ - 'loadstart', - - 'progress', - - 'abort', - - 'error', - - 'load', - - 'timeout', - - 'loadend' - - // readystatechange (for historical reasons) - ]; - - var NATIVE = 1, RUNTIME = 2; - - function XMLHttpRequest() { - var self = this, - // this (together with _p() @see below) is here to gracefully upgrade to setter/getter syntax where possible - props = { - /** - The amount of milliseconds a request can take before being terminated. Initially zero. Zero means there is no timeout. - - @property timeout - @type Number - @default 0 - */ - timeout: 0, - - /** - Current state, can take following values: - UNSENT (numeric value 0) - The object has been constructed. - - OPENED (numeric value 1) - The open() method has been successfully invoked. During this state request headers can be set using setRequestHeader() and the request can be made using the send() method. - - HEADERS_RECEIVED (numeric value 2) - All redirects (if any) have been followed and all HTTP headers of the final response have been received. Several response members of the object are now available. - - LOADING (numeric value 3) - The response entity body is being received. - - DONE (numeric value 4) - - @property readyState - @type Number - @default 0 (UNSENT) - */ - readyState: XMLHttpRequest.UNSENT, - - /** - True when user credentials are to be included in a cross-origin request. False when they are to be excluded - in a cross-origin request and when cookies are to be ignored in its response. Initially false. - - @property withCredentials - @type Boolean - @default false - */ - withCredentials: false, - - /** - Returns the HTTP status code. - - @property status - @type Number - @default 0 - */ - status: 0, - - /** - Returns the HTTP status text. - - @property statusText - @type String - */ - statusText: "", - - /** - Returns the response type. Can be set to change the response type. Values are: - the empty string (default), "arraybuffer", "blob", "document", "json", and "text". - - @property responseType - @type String - */ - responseType: "", - - /** - Returns the document response entity body. - - Throws an "InvalidStateError" exception if responseType is not the empty string or "document". - - @property responseXML - @type Document - */ - responseXML: null, - - /** - Returns the text response entity body. - - Throws an "InvalidStateError" exception if responseType is not the empty string or "text". - - @property responseText - @type String - */ - responseText: null, - - /** - Returns the response entity body (http://www.w3.org/TR/XMLHttpRequest/#response-entity-body). - Can become: ArrayBuffer, Blob, Document, JSON, Text - - @property response - @type Mixed - */ - response: null - }, - - _async = true, - _url, - _method, - _headers = {}, - _user, - _password, - _encoding = null, - _mimeType = null, - - // flags - _sync_flag = false, - _send_flag = false, - _upload_events_flag = false, - _upload_complete_flag = false, - _error_flag = false, - _same_origin_flag = false, - - // times - _start_time, - _timeoutset_time, - - _finalMime = null, - _finalCharset = null, - - _options = {}, - _xhr, - _responseHeaders = '', - _responseHeadersBag - ; - - - Basic.extend(this, props, { - /** - Unique id of the component - - @property uid - @type String - */ - uid: Basic.guid('uid_'), - - /** - Target for Upload events - - @property upload - @type XMLHttpRequestUpload - */ - upload: new XMLHttpRequestUpload(), - - - /** - Sets the request method, request URL, synchronous flag, request username, and request password. - - Throws a "SyntaxError" exception if one of the following is true: - - method is not a valid HTTP method. - url cannot be resolved. - url contains the "user:password" format in the userinfo production. - Throws a "SecurityError" exception if method is a case-insensitive match for CONNECT, TRACE or TRACK. - - Throws an "InvalidAccessError" exception if one of the following is true: - - Either user or password is passed as argument and the origin of url does not match the XMLHttpRequest origin. - There is an associated XMLHttpRequest document and either the timeout attribute is not zero, - the withCredentials attribute is true, or the responseType attribute is not the empty string. - - - @method open - @param {String} method HTTP method to use on request - @param {String} url URL to request - @param {Boolean} [async=true] If false request will be done in synchronous manner. Asynchronous by default. - @param {String} [user] Username to use in HTTP authentication process on server-side - @param {String} [password] Password to use in HTTP authentication process on server-side - */ - open: function(method, url, async, user, password) { - var urlp; - - // first two arguments are required - if (!method || !url) { - throw new x.DOMException(x.DOMException.SYNTAX_ERR); - } - - // 2 - check if any code point in method is higher than U+00FF or after deflating method it does not match the method - if (/[\u0100-\uffff]/.test(method) || Encode.utf8_encode(method) !== method) { - throw new x.DOMException(x.DOMException.SYNTAX_ERR); - } - - // 3 - if (!!~Basic.inArray(method.toUpperCase(), ['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT', 'TRACE', 'TRACK'])) { - _method = method.toUpperCase(); - } - - - // 4 - allowing these methods poses a security risk - if (!!~Basic.inArray(_method, ['CONNECT', 'TRACE', 'TRACK'])) { - throw new x.DOMException(x.DOMException.SECURITY_ERR); - } - - // 5 - url = Encode.utf8_encode(url); - - // 6 - Resolve url relative to the XMLHttpRequest base URL. If the algorithm returns an error, throw a "SyntaxError". - urlp = Url.parseUrl(url); - - _same_origin_flag = Url.hasSameOrigin(urlp); - - // 7 - manually build up absolute url - _url = Url.resolveUrl(url); - - // 9-10, 12-13 - if ((user || password) && !_same_origin_flag) { - throw new x.DOMException(x.DOMException.INVALID_ACCESS_ERR); - } - - _user = user || urlp.user; - _password = password || urlp.pass; - - // 11 - _async = async || true; - - if (_async === false && (_p('timeout') || _p('withCredentials') || _p('responseType') !== "")) { - throw new x.DOMException(x.DOMException.INVALID_ACCESS_ERR); - } - - // 14 - terminate abort() - - // 15 - terminate send() - - // 18 - _sync_flag = !_async; - _send_flag = false; - _headers = {}; - _reset.call(this); - - // 19 - _p('readyState', XMLHttpRequest.OPENED); - - // 20 - this.dispatchEvent('readystatechange'); - }, - - /** - Appends an header to the list of author request headers, or if header is already - in the list of author request headers, combines its value with value. - - Throws an "InvalidStateError" exception if the state is not OPENED or if the send() flag is set. - Throws a "SyntaxError" exception if header is not a valid HTTP header field name or if value - is not a valid HTTP header field value. - - @method setRequestHeader - @param {String} header - @param {String|Number} value - */ - setRequestHeader: function(header, value) { - var uaHeaders = [ // these headers are controlled by the user agent - "accept-charset", - "accept-encoding", - "access-control-request-headers", - "access-control-request-method", - "connection", - "content-length", - "cookie", - "cookie2", - "content-transfer-encoding", - "date", - "expect", - "host", - "keep-alive", - "origin", - "referer", - "te", - "trailer", - "transfer-encoding", - "upgrade", - "user-agent", - "via" - ]; - - // 1-2 - if (_p('readyState') !== XMLHttpRequest.OPENED || _send_flag) { - throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); - } - - // 3 - if (/[\u0100-\uffff]/.test(header) || Encode.utf8_encode(header) !== header) { - throw new x.DOMException(x.DOMException.SYNTAX_ERR); - } - - // 4 - /* this step is seemingly bypassed in browsers, probably to allow various unicode characters in header values - if (/[\u0100-\uffff]/.test(value) || Encode.utf8_encode(value) !== value) { - throw new x.DOMException(x.DOMException.SYNTAX_ERR); - }*/ - - header = Basic.trim(header).toLowerCase(); - - // setting of proxy-* and sec-* headers is prohibited by spec - if (!!~Basic.inArray(header, uaHeaders) || /^(proxy\-|sec\-)/.test(header)) { - return false; - } - - // camelize - // browsers lowercase header names (at least for custom ones) - // header = header.replace(/\b\w/g, function($1) { return $1.toUpperCase(); }); - - if (!_headers[header]) { - _headers[header] = value; - } else { - // http://tools.ietf.org/html/rfc2616#section-4.2 (last paragraph) - _headers[header] += ', ' + value; - } - return true; - }, - - /** - * Test if the specified header is already set on this request. - * Returns a header value or boolean false if it's not yet set. - * - * @method hasRequestHeader - * @param {String} header Name of the header to test - * @return {Boolean|String} - */ - hasRequestHeader: function(header) { - return header && _headers[header.toLowerCase()] || false; - }, - - /** - Returns all headers from the response, with the exception of those whose field name is Set-Cookie or Set-Cookie2. - - @method getAllResponseHeaders - @return {String} reponse headers or empty string - */ - getAllResponseHeaders: function() { - return _responseHeaders || ''; - }, - - /** - Returns the header field value from the response of which the field name matches header, - unless the field name is Set-Cookie or Set-Cookie2. - - @method getResponseHeader - @param {String} header - @return {String} value(s) for the specified header or null - */ - getResponseHeader: function(header) { - header = header.toLowerCase(); - - if (_error_flag || !!~Basic.inArray(header, ['set-cookie', 'set-cookie2'])) { - return null; - } - - if (_responseHeaders && _responseHeaders !== '') { - // if we didn't parse response headers until now, do it and keep for later - if (!_responseHeadersBag) { - _responseHeadersBag = {}; - Basic.each(_responseHeaders.split(/\r\n/), function(line) { - var pair = line.split(/:\s+/); - if (pair.length === 2) { // last line might be empty, omit - pair[0] = Basic.trim(pair[0]); // just in case - _responseHeadersBag[pair[0].toLowerCase()] = { // simply to retain header name in original form - header: pair[0], - value: Basic.trim(pair[1]) - }; - } - }); - } - if (_responseHeadersBag.hasOwnProperty(header)) { - return _responseHeadersBag[header].header + ': ' + _responseHeadersBag[header].value; - } - } - return null; - }, - - /** - Sets the Content-Type header for the response to mime. - Throws an "InvalidStateError" exception if the state is LOADING or DONE. - Throws a "SyntaxError" exception if mime is not a valid media type. - - @method overrideMimeType - @param String mime Mime type to set - */ - overrideMimeType: function(mime) { - var matches, charset; - - // 1 - if (!!~Basic.inArray(_p('readyState'), [XMLHttpRequest.LOADING, XMLHttpRequest.DONE])) { - throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); - } - - // 2 - mime = Basic.trim(mime.toLowerCase()); - - if (/;/.test(mime) && (matches = mime.match(/^([^;]+)(?:;\scharset\=)?(.*)$/))) { - mime = matches[1]; - if (matches[2]) { - charset = matches[2]; - } - } - - if (!Mime.mimes[mime]) { - throw new x.DOMException(x.DOMException.SYNTAX_ERR); - } - - // 3-4 - _finalMime = mime; - _finalCharset = charset; - }, - - /** - Initiates the request. The optional argument provides the request entity body. - The argument is ignored if request method is GET or HEAD. - - Throws an "InvalidStateError" exception if the state is not OPENED or if the send() flag is set. - - @method send - @param {Blob|Document|String|FormData} [data] Request entity body - @param {Object} [options] Set of requirements and pre-requisities for runtime initialization - */ - send: function(data, options) { - if (Basic.typeOf(options) === 'string') { - _options = { ruid: options }; - } else if (!options) { - _options = {}; - } else { - _options = options; - } - - // 1-2 - if (this.readyState !== XMLHttpRequest.OPENED || _send_flag) { - throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); - } - - // 3 - // sending Blob - if (data instanceof Blob) { - _options.ruid = data.ruid; - _mimeType = data.type || 'application/octet-stream'; - } - - // FormData - else if (data instanceof FormData) { - if (data.hasBlob()) { - var blob = data.getBlob(); - _options.ruid = blob.ruid; - _mimeType = blob.type || 'application/octet-stream'; - } - } - - // DOMString - else if (typeof data === 'string') { - _encoding = 'UTF-8'; - _mimeType = 'text/plain;charset=UTF-8'; - - // data should be converted to Unicode and encoded as UTF-8 - data = Encode.utf8_encode(data); - } - - // if withCredentials not set, but requested, set it automatically - if (!this.withCredentials) { - this.withCredentials = (_options.required_caps && _options.required_caps.send_browser_cookies) && !_same_origin_flag; - } - - // 4 - storage mutex - // 5 - _upload_events_flag = (!_sync_flag && this.upload.hasEventListener()); // DSAP - // 6 - _error_flag = false; - // 7 - _upload_complete_flag = !data; - // 8 - Asynchronous steps - if (!_sync_flag) { - // 8.1 - _send_flag = true; - // 8.2 - // this.dispatchEvent('loadstart'); // will be dispatched either by native or runtime xhr - // 8.3 - //if (!_upload_complete_flag) { - // this.upload.dispatchEvent('loadstart'); // will be dispatched either by native or runtime xhr - //} - } - // 8.5 - Return the send() method call, but continue running the steps in this algorithm. - _doXHR.call(this, data); - }, - - /** - Cancels any network activity. - - @method abort - */ - abort: function() { - _error_flag = true; - _sync_flag = false; - - if (!~Basic.inArray(_p('readyState'), [XMLHttpRequest.UNSENT, XMLHttpRequest.OPENED, XMLHttpRequest.DONE])) { - _p('readyState', XMLHttpRequest.DONE); - _send_flag = false; - - if (_xhr) { - _xhr.getRuntime().exec.call(_xhr, 'XMLHttpRequest', 'abort', _upload_complete_flag); - } else { - throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); - } - - _upload_complete_flag = true; - } else { - _p('readyState', XMLHttpRequest.UNSENT); - } - }, - - destroy: function() { - if (_xhr) { - if (Basic.typeOf(_xhr.destroy) === 'function') { - _xhr.destroy(); - } - _xhr = null; - } - - this.unbindAll(); - - if (this.upload) { - this.upload.unbindAll(); - this.upload = null; - } - } - }); - - this.handleEventProps(dispatches.concat(['readystatechange'])); // for historical reasons - this.upload.handleEventProps(dispatches); - - /* this is nice, but maybe too lengthy - - // if supported by JS version, set getters/setters for specific properties - o.defineProperty(this, 'readyState', { - configurable: false, - - get: function() { - return _p('readyState'); - } - }); - - o.defineProperty(this, 'timeout', { - configurable: false, - - get: function() { - return _p('timeout'); - }, - - set: function(value) { - - if (_sync_flag) { - throw new x.DOMException(x.DOMException.INVALID_ACCESS_ERR); - } - - // timeout still should be measured relative to the start time of request - _timeoutset_time = (new Date).getTime(); - - _p('timeout', value); - } - }); - - // the withCredentials attribute has no effect when fetching same-origin resources - o.defineProperty(this, 'withCredentials', { - configurable: false, - - get: function() { - return _p('withCredentials'); - }, - - set: function(value) { - // 1-2 - if (!~o.inArray(_p('readyState'), [XMLHttpRequest.UNSENT, XMLHttpRequest.OPENED]) || _send_flag) { - throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); - } - - // 3-4 - if (_anonymous_flag || _sync_flag) { - throw new x.DOMException(x.DOMException.INVALID_ACCESS_ERR); - } - - // 5 - _p('withCredentials', value); - } - }); - - o.defineProperty(this, 'status', { - configurable: false, - - get: function() { - return _p('status'); - } - }); - - o.defineProperty(this, 'statusText', { - configurable: false, - - get: function() { - return _p('statusText'); - } - }); - - o.defineProperty(this, 'responseType', { - configurable: false, - - get: function() { - return _p('responseType'); - }, - - set: function(value) { - // 1 - if (!!~o.inArray(_p('readyState'), [XMLHttpRequest.LOADING, XMLHttpRequest.DONE])) { - throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); - } - - // 2 - if (_sync_flag) { - throw new x.DOMException(x.DOMException.INVALID_ACCESS_ERR); - } - - // 3 - _p('responseType', value.toLowerCase()); - } - }); - - o.defineProperty(this, 'responseText', { - configurable: false, - - get: function() { - // 1 - if (!~o.inArray(_p('responseType'), ['', 'text'])) { - throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); - } - - // 2-3 - if (_p('readyState') !== XMLHttpRequest.DONE && _p('readyState') !== XMLHttpRequest.LOADING || _error_flag) { - throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); - } - - return _p('responseText'); - } - }); - - o.defineProperty(this, 'responseXML', { - configurable: false, - - get: function() { - // 1 - if (!~o.inArray(_p('responseType'), ['', 'document'])) { - throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); - } - - // 2-3 - if (_p('readyState') !== XMLHttpRequest.DONE || _error_flag) { - throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); - } - - return _p('responseXML'); - } - }); - - o.defineProperty(this, 'response', { - configurable: false, - - get: function() { - if (!!~o.inArray(_p('responseType'), ['', 'text'])) { - if (_p('readyState') !== XMLHttpRequest.DONE && _p('readyState') !== XMLHttpRequest.LOADING || _error_flag) { - return ''; - } - } - - if (_p('readyState') !== XMLHttpRequest.DONE || _error_flag) { - return null; - } - - return _p('response'); - } - }); - - */ - - function _p(prop, value) { - if (!props.hasOwnProperty(prop)) { - return; - } - if (arguments.length === 1) { // get - return Env.can('define_property') ? props[prop] : self[prop]; - } else { // set - if (Env.can('define_property')) { - props[prop] = value; - } else { - self[prop] = value; - } - } - } - - /* - function _toASCII(str, AllowUnassigned, UseSTD3ASCIIRules) { - // TODO: http://tools.ietf.org/html/rfc3490#section-4.1 - return str.toLowerCase(); - } - */ - - - function _doXHR(data) { - var self = this; - - _start_time = new Date().getTime(); - - _xhr = new RuntimeTarget(); - - function loadEnd() { - if (_xhr) { // it could have been destroyed by now - _xhr.destroy(); - _xhr = null; - } - self.dispatchEvent('loadend'); - self = null; - } - - function exec(runtime) { - _xhr.bind('LoadStart', function(e) { - _p('readyState', XMLHttpRequest.LOADING); - self.dispatchEvent('readystatechange'); - - self.dispatchEvent(e); - - if (_upload_events_flag) { - self.upload.dispatchEvent(e); - } - }); - - _xhr.bind('Progress', function(e) { - if (_p('readyState') !== XMLHttpRequest.LOADING) { - _p('readyState', XMLHttpRequest.LOADING); // LoadStart unreliable (in Flash for example) - self.dispatchEvent('readystatechange'); - } - self.dispatchEvent(e); - }); - - _xhr.bind('UploadProgress', function(e) { - if (_upload_events_flag) { - self.upload.dispatchEvent({ - type: 'progress', - lengthComputable: false, - total: e.total, - loaded: e.loaded - }); - } - }); - - _xhr.bind('Load', function(e) { - _p('readyState', XMLHttpRequest.DONE); - _p('status', Number(runtime.exec.call(_xhr, 'XMLHttpRequest', 'getStatus') || 0)); - _p('statusText', httpCode[_p('status')] || ""); - - _p('response', runtime.exec.call(_xhr, 'XMLHttpRequest', 'getResponse', _p('responseType'))); - - if (!!~Basic.inArray(_p('responseType'), ['text', ''])) { - _p('responseText', _p('response')); - } else if (_p('responseType') === 'document') { - _p('responseXML', _p('response')); - } - - _responseHeaders = runtime.exec.call(_xhr, 'XMLHttpRequest', 'getAllResponseHeaders'); - - self.dispatchEvent('readystatechange'); - - if (_p('status') > 0) { // status 0 usually means that server is unreachable - if (_upload_events_flag) { - self.upload.dispatchEvent(e); - } - self.dispatchEvent(e); - } else { - _error_flag = true; - self.dispatchEvent('error'); - } - loadEnd(); - }); - - _xhr.bind('Abort', function(e) { - self.dispatchEvent(e); - loadEnd(); - }); - - _xhr.bind('Error', function(e) { - _error_flag = true; - _p('readyState', XMLHttpRequest.DONE); - self.dispatchEvent('readystatechange'); - _upload_complete_flag = true; - self.dispatchEvent(e); - loadEnd(); - }); - - runtime.exec.call(_xhr, 'XMLHttpRequest', 'send', { - url: _url, - method: _method, - async: _async, - user: _user, - password: _password, - headers: _headers, - mimeType: _mimeType, - encoding: _encoding, - responseType: self.responseType, - withCredentials: self.withCredentials, - options: _options - }, data); - } - - // clarify our requirements - if (typeof(_options.required_caps) === 'string') { - _options.required_caps = Runtime.parseCaps(_options.required_caps); - } - - _options.required_caps = Basic.extend({}, _options.required_caps, { - return_response_type: self.responseType - }); - - if (data instanceof FormData) { - _options.required_caps.send_multipart = true; - } - - if (!Basic.isEmptyObj(_headers)) { - _options.required_caps.send_custom_headers = true; - } - - if (!_same_origin_flag) { - _options.required_caps.do_cors = true; - } - - - if (_options.ruid) { // we do not need to wait if we can connect directly - exec(_xhr.connectRuntime(_options)); - } else { - _xhr.bind('RuntimeInit', function(e, runtime) { - exec(runtime); - }); - _xhr.bind('RuntimeError', function(e, err) { - self.dispatchEvent('RuntimeError', err); - }); - _xhr.connectRuntime(_options); - } - } - - - function _reset() { - _p('responseText', ""); - _p('responseXML', null); - _p('response', null); - _p('status', 0); - _p('statusText', ""); - _start_time = _timeoutset_time = null; - } - } - - XMLHttpRequest.UNSENT = 0; - XMLHttpRequest.OPENED = 1; - XMLHttpRequest.HEADERS_RECEIVED = 2; - XMLHttpRequest.LOADING = 3; - XMLHttpRequest.DONE = 4; - - XMLHttpRequest.prototype = EventTarget.instance; - - return XMLHttpRequest; -}); - -// Included from: src/javascript/runtime/Transporter.js - -/** - * Transporter.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -define("moxie/runtime/Transporter", [ - "moxie/core/utils/Basic", - "moxie/core/utils/Encode", - "moxie/runtime/RuntimeClient", - "moxie/core/EventTarget" -], function(Basic, Encode, RuntimeClient, EventTarget) { - - /** - @class moxie/runtime/Transporter - @private - @constructor - */ - function Transporter() { - var mod, _runtime, _data, _size, _pos, _chunk_size; - - RuntimeClient.call(this); - - Basic.extend(this, { - uid: Basic.guid('uid_'), - - state: Transporter.IDLE, - - result: null, - - transport: function(data, type, options) { - var self = this; - - options = Basic.extend({ - chunk_size: 204798 - }, options); - - // should divide by three, base64 requires this - if ((mod = options.chunk_size % 3)) { - options.chunk_size += 3 - mod; - } - - _chunk_size = options.chunk_size; - - _reset.call(this); - _data = data; - _size = data.length; - - if (Basic.typeOf(options) === 'string' || options.ruid) { - _run.call(self, type, this.connectRuntime(options)); - } else { - // we require this to run only once - var cb = function(e, runtime) { - self.unbind("RuntimeInit", cb); - _run.call(self, type, runtime); - }; - this.bind("RuntimeInit", cb); - this.connectRuntime(options); - } - }, - - abort: function() { - var self = this; - - self.state = Transporter.IDLE; - if (_runtime) { - _runtime.exec.call(self, 'Transporter', 'clear'); - self.trigger("TransportingAborted"); - } - - _reset.call(self); - }, - - - destroy: function() { - this.unbindAll(); - _runtime = null; - this.disconnectRuntime(); - _reset.call(this); - } - }); - - function _reset() { - _size = _pos = 0; - _data = this.result = null; - } - - function _run(type, runtime) { - var self = this; - - _runtime = runtime; - - //self.unbind("RuntimeInit"); - - self.bind("TransportingProgress", function(e) { - _pos = e.loaded; - - if (_pos < _size && Basic.inArray(self.state, [Transporter.IDLE, Transporter.DONE]) === -1) { - _transport.call(self); - } - }, 999); - - self.bind("TransportingComplete", function() { - _pos = _size; - self.state = Transporter.DONE; - _data = null; // clean a bit - self.result = _runtime.exec.call(self, 'Transporter', 'getAsBlob', type || ''); - }, 999); - - self.state = Transporter.BUSY; - self.trigger("TransportingStarted"); - _transport.call(self); - } - - function _transport() { - var self = this, - chunk, - bytesLeft = _size - _pos; - - if (_chunk_size > bytesLeft) { - _chunk_size = bytesLeft; - } - - chunk = Encode.btoa(_data.substr(_pos, _chunk_size)); - _runtime.exec.call(self, 'Transporter', 'receive', chunk, _size); - } - } - - Transporter.IDLE = 0; - Transporter.BUSY = 1; - Transporter.DONE = 2; - - Transporter.prototype = EventTarget.instance; - - return Transporter; -}); - -// Included from: src/javascript/image/Image.js - -/** - * Image.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -define("moxie/image/Image", [ - "moxie/core/utils/Basic", - "moxie/core/utils/Dom", - "moxie/core/Exceptions", - "moxie/file/FileReaderSync", - "moxie/xhr/XMLHttpRequest", - "moxie/runtime/Runtime", - "moxie/runtime/RuntimeClient", - "moxie/runtime/Transporter", - "moxie/core/utils/Env", - "moxie/core/EventTarget", - "moxie/file/Blob", - "moxie/file/File", - "moxie/core/utils/Encode" -], function(Basic, Dom, x, FileReaderSync, XMLHttpRequest, Runtime, RuntimeClient, Transporter, Env, EventTarget, Blob, File, Encode) { - /** - Image preloading and manipulation utility. Additionally it provides access to image meta info (Exif, GPS) and raw binary data. - - @class moxie/image/Image - @constructor - @extends EventTarget - */ - var dispatches = [ - 'progress', - - /** - Dispatched when loading is complete. - - @event load - @param {Object} event - */ - 'load', - - 'error', - - /** - Dispatched when resize operation is complete. - - @event resize - @param {Object} event - */ - 'resize', - - /** - Dispatched when visual representation of the image is successfully embedded - into the corresponsing container. - - @event embedded - @param {Object} event - */ - 'embedded' - ]; - - function Image() { - - RuntimeClient.call(this); - - Basic.extend(this, { - /** - Unique id of the component - - @property uid - @type {String} - */ - uid: Basic.guid('uid_'), - - /** - Unique id of the connected runtime, if any. - - @property ruid - @type {String} - */ - ruid: null, - - /** - Name of the file, that was used to create an image, if available. If not equals to empty string. - - @property name - @type {String} - @default "" - */ - name: "", - - /** - Size of the image in bytes. Actual value is set only after image is preloaded. - - @property size - @type {Number} - @default 0 - */ - size: 0, - - /** - Width of the image. Actual value is set only after image is preloaded. - - @property width - @type {Number} - @default 0 - */ - width: 0, - - /** - Height of the image. Actual value is set only after image is preloaded. - - @property height - @type {Number} - @default 0 - */ - height: 0, - - /** - Mime type of the image. Currently only image/jpeg and image/png are supported. Actual value is set only after image is preloaded. - - @property type - @type {String} - @default "" - */ - type: "", - - /** - Holds meta info (Exif, GPS). Is populated only for image/jpeg. Actual value is set only after image is preloaded. - - @property meta - @type {Object} - @default {} - */ - meta: {}, - - /** - Alias for load method, that takes another moxie.image.Image object as a source (see load). - - @method clone - @param {Image} src Source for the image - @param {Boolean} [exact=false] Whether to activate in-depth clone mode - */ - clone: function() { - this.load.apply(this, arguments); - }, - - /** - Loads image from various sources. Currently the source for new image can be: moxie.image.Image, - moxie.file.Blob/moxie.file.File, native Blob/File, dataUrl or URL. Depending on the type of the - source, arguments - differ. When source is URL, Image will be downloaded from remote destination - and loaded in memory. - - @example - var img = new moxie.image.Image(); - img.onload = function() { - var blob = img.getAsBlob(); - - var formData = new moxie.xhr.FormData(); - formData.append('file', blob); - - var xhr = new moxie.xhr.XMLHttpRequest(); - xhr.onload = function() { - // upload complete - }; - xhr.open('post', 'upload.php'); - xhr.send(formData); - }; - img.load("http://www.moxiecode.com/images/mox-logo.jpg"); // notice file extension (.jpg) - - - @method load - @param {Image|Blob|File|String} src Source for the image - @param {Boolean|Object} [mixed] - */ - load: function() { - _load.apply(this, arguments); - }, - - - /** - Resizes the image to fit the specified width/height. If crop is specified, image will also be - cropped to the exact dimensions. - - @method resize - @since 3.0 - @param {Object} options - @param {Number} options.width Resulting width - @param {Number} [options.height=width] Resulting height (optional, if not supplied will default to width) - @param {String} [options.type='image/jpeg'] MIME type of the resulting image - @param {Number} [options.quality=90] In the case of JPEG, controls the quality of resulting image - @param {Boolean} [options.crop='cc'] If not falsy, image will be cropped, by default from center - @param {Boolean} [options.fit=true] Whether to upscale the image to fit the exact dimensions - @param {Boolean} [options.preserveHeaders=true] Whether to preserve meta headers (on JPEGs after resize) - @param {String} [options.resample='default'] Resampling algorithm to use during resize - @param {Boolean} [options.multipass=true] Whether to scale the image in steps (results in better quality) - */ - resize: function(options) { - var self = this; - var orientation; - var scale; - - var srcRect = { - x: 0, - y: 0, - width: self.width, - height: self.height - }; - - var opts = Basic.extendIf({ - width: self.width, - height: self.height, - type: self.type || 'image/jpeg', - quality: 90, - crop: false, - fit: true, - preserveHeaders: true, - resample: 'default', - multipass: true - }, options); - - try { - if (!self.size) { // only preloaded image objects can be used as source - throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); - } - - // no way to reliably intercept the crash due to high resolution, so we simply avoid it - if (self.width > Image.MAX_RESIZE_WIDTH || self.height > Image.MAX_RESIZE_HEIGHT) { - throw new x.ImageError(x.ImageError.MAX_RESOLUTION_ERR); - } - - // take into account orientation tag - orientation = (self.meta && self.meta.tiff && self.meta.tiff.Orientation) || 1; - - if (Basic.inArray(orientation, [5,6,7,8]) !== -1) { // values that require 90 degree rotation - var tmp = opts.width; - opts.width = opts.height; - opts.height = tmp; - } - - if (opts.crop) { - scale = Math.max(opts.width/self.width, opts.height/self.height); - - if (options.fit) { - // first scale it up or down to fit the original image - srcRect.width = Math.min(Math.ceil(opts.width/scale), self.width); - srcRect.height = Math.min(Math.ceil(opts.height/scale), self.height); - - // recalculate the scale for adapted dimensions - scale = opts.width/srcRect.width; - } else { - srcRect.width = Math.min(opts.width, self.width); - srcRect.height = Math.min(opts.height, self.height); - - // now we do not need to scale it any further - scale = 1; - } - - if (typeof(opts.crop) === 'boolean') { - opts.crop = 'cc'; - } - - switch (opts.crop.toLowerCase().replace(/_/, '-')) { - case 'rb': - case 'right-bottom': - srcRect.x = self.width - srcRect.width; - srcRect.y = self.height - srcRect.height; - break; - - case 'cb': - case 'center-bottom': - srcRect.x = Math.floor((self.width - srcRect.width) / 2); - srcRect.y = self.height - srcRect.height; - break; - - case 'lb': - case 'left-bottom': - srcRect.x = 0; - srcRect.y = self.height - srcRect.height; - break; - - case 'lt': - case 'left-top': - srcRect.x = 0; - srcRect.y = 0; - break; - - case 'ct': - case 'center-top': - srcRect.x = Math.floor((self.width - srcRect.width) / 2); - srcRect.y = 0; - break; - - case 'rt': - case 'right-top': - srcRect.x = self.width - srcRect.width; - srcRect.y = 0; - break; - - case 'rc': - case 'right-center': - case 'right-middle': - srcRect.x = self.width - srcRect.width; - srcRect.y = Math.floor((self.height - srcRect.height) / 2); - break; - - - case 'lc': - case 'left-center': - case 'left-middle': - srcRect.x = 0; - srcRect.y = Math.floor((self.height - srcRect.height) / 2); - break; - - case 'cc': - case 'center-center': - case 'center-middle': - default: - srcRect.x = Math.floor((self.width - srcRect.width) / 2); - srcRect.y = Math.floor((self.height - srcRect.height) / 2); - } - - // original image might be smaller than requested crop, so - avoid negative values - srcRect.x = Math.max(srcRect.x, 0); - srcRect.y = Math.max(srcRect.y, 0); - } else { - scale = Math.min(opts.width/self.width, opts.height/self.height); - - // do not upscale if we were asked to not fit it - if (scale > 1 && !opts.fit) { - scale = 1; - } - } - - this.exec('Image', 'resize', srcRect, scale, opts); - } catch(ex) { - // for now simply trigger error event - self.trigger('error', ex.code); - } - }, - - /** - Downsizes the image to fit the specified width/height. If crop is supplied, image will be cropped to exact dimensions. - - @method downsize - @deprecated use resize() - */ - downsize: function(options) { - var defaults = { - width: this.width, - height: this.height, - type: this.type || 'image/jpeg', - quality: 90, - crop: false, - fit: false, - preserveHeaders: true, - resample: 'default' - }, opts; - - if (typeof(options) === 'object') { - opts = Basic.extend(defaults, options); - } else { - // for backward compatibility - opts = Basic.extend(defaults, { - width: arguments[0], - height: arguments[1], - crop: arguments[2], - preserveHeaders: arguments[3] - }); - } - - this.resize(opts); - }, - - /** - Alias for downsize(width, height, true). (see downsize) - - @method crop - @param {Number} width Resulting width - @param {Number} [height=width] Resulting height (optional, if not supplied will default to width) - @param {Boolean} [preserveHeaders=true] Whether to preserve meta headers (on JPEGs after resize) - */ - crop: function(width, height, preserveHeaders) { - this.downsize(width, height, true, preserveHeaders); - }, - - getAsCanvas: function() { - if (!Env.can('create_canvas')) { - throw new x.RuntimeError(x.RuntimeError.NOT_SUPPORTED_ERR); - } - return this.exec('Image', 'getAsCanvas'); - }, - - /** - Retrieves image in it's current state as moxie.file.Blob object. Cannot be run on empty or image in progress (throws - DOMException.INVALID_STATE_ERR). - - @method getAsBlob - @param {String} [type="image/jpeg"] Mime type of resulting blob. Can either be image/jpeg or image/png - @param {Number} [quality=90] Applicable only together with mime type image/jpeg - @return {Blob} Image as Blob - */ - getAsBlob: function(type, quality) { - if (!this.size) { - throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); - } - return this.exec('Image', 'getAsBlob', type || 'image/jpeg', quality || 90); - }, - - /** - Retrieves image in it's current state as dataURL string. Cannot be run on empty or image in progress (throws - DOMException.INVALID_STATE_ERR). - - @method getAsDataURL - @param {String} [type="image/jpeg"] Mime type of resulting blob. Can either be image/jpeg or image/png - @param {Number} [quality=90] Applicable only together with mime type image/jpeg - @return {String} Image as dataURL string - */ - getAsDataURL: function(type, quality) { - if (!this.size) { - throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); - } - return this.exec('Image', 'getAsDataURL', type || 'image/jpeg', quality || 90); - }, - - /** - Retrieves image in it's current state as binary string. Cannot be run on empty or image in progress (throws - DOMException.INVALID_STATE_ERR). - - @method getAsBinaryString - @param {String} [type="image/jpeg"] Mime type of resulting blob. Can either be image/jpeg or image/png - @param {Number} [quality=90] Applicable only together with mime type image/jpeg - @return {String} Image as binary string - */ - getAsBinaryString: function(type, quality) { - var dataUrl = this.getAsDataURL(type, quality); - return Encode.atob(dataUrl.substring(dataUrl.indexOf('base64,') + 7)); - }, - - /** - Embeds a visual representation of the image into the specified node. Depending on the runtime, - it might be a canvas, an img node or a thrid party shim object (Flash or SilverLight - very rare, - can be used in legacy browsers that do not have canvas or proper dataURI support). - - @method embed - @param {DOMElement} el DOM element to insert the image object into - @param {Object} [options] - @param {Number} [options.width] The width of an embed (defaults to the image width) - @param {Number} [options.height] The height of an embed (defaults to the image height) - @param {String} [options.type="image/jpeg"] Mime type - @param {Number} [options.quality=90] Quality of an embed, if mime type is image/jpeg - @param {Boolean} [options.crop=false] Whether to crop an embed to the specified dimensions - @param {Boolean} [options.fit=true] By default thumbs will be up- or downscaled as necessary to fit the dimensions - */ - embed: function(el, options) { - var self = this - , runtime // this has to be outside of all the closures to contain proper runtime - ; - - var opts = Basic.extend({ - width: this.width, - height: this.height, - type: this.type || 'image/jpeg', - quality: 90, - fit: true, - resample: 'nearest' - }, options); - - - function render(type, quality) { - var img = this; - - // if possible, embed a canvas element directly - if (Env.can('create_canvas')) { - var canvas = img.getAsCanvas(); - if (canvas) { - el.appendChild(canvas); - canvas = null; - img.destroy(); - self.trigger('embedded'); - return; - } - } - - var dataUrl = img.getAsDataURL(type, quality); - if (!dataUrl) { - throw new x.ImageError(x.ImageError.WRONG_FORMAT); - } - - if (Env.can('use_data_uri_of', dataUrl.length)) { - el.innerHTML = ''; - img.destroy(); - self.trigger('embedded'); - } else { - var tr = new Transporter(); - - tr.bind("TransportingComplete", function() { - runtime = self.connectRuntime(this.result.ruid); - - self.bind("Embedded", function() { - // position and size properly - Basic.extend(runtime.getShimContainer().style, { - //position: 'relative', - top: '0px', - left: '0px', - width: img.width + 'px', - height: img.height + 'px' - }); - - // some shims (Flash/SilverLight) reinitialize, if parent element is hidden, reordered or it's - // position type changes (in Gecko), but since we basically need this only in IEs 6/7 and - // sometimes 8 and they do not have this problem, we can comment this for now - /*tr.bind("RuntimeInit", function(e, runtime) { - tr.destroy(); - runtime.destroy(); - onResize.call(self); // re-feed our image data - });*/ - - runtime = null; // release - }, 999); - - runtime.exec.call(self, "ImageView", "display", this.result.uid, width, height); - img.destroy(); - }); - - tr.transport(Encode.atob(dataUrl.substring(dataUrl.indexOf('base64,') + 7)), type, { - required_caps: { - display_media: true - }, - runtime_order: 'flash,silverlight', - container: el - }); - } - } - - try { - if (!(el = Dom.get(el))) { - throw new x.DOMException(x.DOMException.INVALID_NODE_TYPE_ERR); - } - - if (!this.size) { // only preloaded image objects can be used as source - throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); - } - - // high-resolution images cannot be consistently handled across the runtimes - if (this.width > Image.MAX_RESIZE_WIDTH || this.height > Image.MAX_RESIZE_HEIGHT) { - //throw new x.ImageError(x.ImageError.MAX_RESOLUTION_ERR); - } - - var imgCopy = new Image(); - - imgCopy.bind("Resize", function() { - render.call(this, opts.type, opts.quality); - }); - - imgCopy.bind("Load", function() { - this.downsize(opts); - }); - - // if embedded thumb data is available and dimensions are big enough, use it - if (this.meta.thumb && this.meta.thumb.width >= opts.width && this.meta.thumb.height >= opts.height) { - imgCopy.load(this.meta.thumb.data); - } else { - imgCopy.clone(this, false); - } - - return imgCopy; - } catch(ex) { - // for now simply trigger error event - this.trigger('error', ex.code); - } - }, - - /** - Properly destroys the image and frees resources in use. If any. Recommended way to dispose - moxie.image.Image object. - - @method destroy - */ - destroy: function() { - if (this.ruid) { - this.getRuntime().exec.call(this, 'Image', 'destroy'); - this.disconnectRuntime(); - } - if (this.meta && this.meta.thumb) { - // thumb is blob, make sure we destroy it first - this.meta.thumb.data.destroy(); - } - this.unbindAll(); - } - }); - - - // this is here, because in order to bind properly, we need uid, which is created above - this.handleEventProps(dispatches); - - this.bind('Load Resize', function() { - return _updateInfo.call(this); // if operation fails (e.g. image is neither PNG nor JPEG) cancel all pending events - }, 999); - - - function _updateInfo(info) { - try { - if (!info) { - info = this.exec('Image', 'getInfo'); - } - - this.size = info.size; - this.width = info.width; - this.height = info.height; - this.type = info.type; - this.meta = info.meta; - - // update file name, only if empty - if (this.name === '') { - this.name = info.name; - } - - return true; - } catch(ex) { - this.trigger('error', ex.code); - return false; - } - } - - - function _load(src) { - var srcType = Basic.typeOf(src); - - try { - // if source is Image - if (src instanceof Image) { - if (!src.size) { // only preloaded image objects can be used as source - throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); - } - _loadFromImage.apply(this, arguments); - } - // if source is o.Blob/o.File - else if (src instanceof Blob) { - if (!~Basic.inArray(src.type, ['image/jpeg', 'image/png'])) { - throw new x.ImageError(x.ImageError.WRONG_FORMAT); - } - _loadFromBlob.apply(this, arguments); - } - // if native blob/file - else if (Basic.inArray(srcType, ['blob', 'file']) !== -1) { - _load.call(this, new File(null, src), arguments[1]); - } - // if String - else if (srcType === 'string') { - // if dataUrl String - if (src.substr(0, 5) === 'data:') { - _load.call(this, new Blob(null, { data: src }), arguments[1]); - } - // else assume Url, either relative or absolute - else { - _loadFromUrl.apply(this, arguments); - } - } - // if source seems to be an img node - else if (srcType === 'node' && src.nodeName.toLowerCase() === 'img') { - _load.call(this, src.src, arguments[1]); - } - else { - throw new x.DOMException(x.DOMException.TYPE_MISMATCH_ERR); - } - } catch(ex) { - // for now simply trigger error event - this.trigger('error', ex.code); - } - } - - - function _loadFromImage(img, exact) { - var runtime = this.connectRuntime(img.ruid); - this.ruid = runtime.uid; - runtime.exec.call(this, 'Image', 'loadFromImage', img, (Basic.typeOf(exact) === 'undefined' ? true : exact)); - } - - - function _loadFromBlob(blob, options) { - var self = this; - - self.name = blob.name || ''; - - function exec(runtime) { - self.ruid = runtime.uid; - runtime.exec.call(self, 'Image', 'loadFromBlob', blob); - } - - if (blob.isDetached()) { - this.bind('RuntimeInit', function(e, runtime) { - exec(runtime); - }); - - // convert to object representation - if (options && typeof(options.required_caps) === 'string') { - options.required_caps = Runtime.parseCaps(options.required_caps); - } - - this.connectRuntime(Basic.extend({ - required_caps: { - access_image_binary: true, - resize_image: true - } - }, options)); - } else { - exec(this.connectRuntime(blob.ruid)); - } - } - - - function _loadFromUrl(url, options) { - var self = this, xhr; - - xhr = new XMLHttpRequest(); - - xhr.open('get', url); - xhr.responseType = 'blob'; - - xhr.onprogress = function(e) { - self.trigger(e); - }; - - xhr.onload = function() { - _loadFromBlob.call(self, xhr.response, true); - }; - - xhr.onerror = function(e) { - self.trigger(e); - }; - - xhr.onloadend = function() { - xhr.destroy(); - }; - - xhr.bind('RuntimeError', function(e, err) { - self.trigger('RuntimeError', err); - }); - - xhr.send(null, options); - } - } - - // virtual world will crash on you if image has a resolution higher than this: - Image.MAX_RESIZE_WIDTH = 8192; - Image.MAX_RESIZE_HEIGHT = 8192; - - Image.prototype = EventTarget.instance; - - return Image; -}); - -// Included from: src/javascript/runtime/html5/Runtime.js - -/** - * Runtime.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/*global File:true */ - -/** -Defines constructor for HTML5 runtime. - -@class moxie/runtime/html5/Runtime -@private -*/ -define("moxie/runtime/html5/Runtime", [ - "moxie/core/utils/Basic", - "moxie/core/Exceptions", - "moxie/runtime/Runtime", - "moxie/core/utils/Env" -], function(Basic, x, Runtime, Env) { - - var type = "html5", extensions = {}; - - function Html5Runtime(options) { - var I = this - , Test = Runtime.capTest - , True = Runtime.capTrue - ; - - var caps = Basic.extend({ - access_binary: Test(window.FileReader || window.File && window.File.getAsDataURL), - access_image_binary: function() { - return I.can('access_binary') && !!extensions.Image; - }, - display_media: Test( - (Env.can('create_canvas') || Env.can('use_data_uri_over32kb')) && - defined('moxie/image/Image') - ), - do_cors: Test(window.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest()), - drag_and_drop: Test(function() { - // this comes directly from Modernizr: http://www.modernizr.com/ - var div = document.createElement('div'); - // IE has support for drag and drop since version 5, but doesn't support dropping files from desktop - return (('draggable' in div) || ('ondragstart' in div && 'ondrop' in div)) && - (Env.browser !== 'IE' || Env.verComp(Env.version, 9, '>')); - }()), - filter_by_extension: Test(function() { // if you know how to feature-detect this, please suggest - return !( - (Env.browser === 'Chrome' && Env.verComp(Env.version, 28, '<')) || - (Env.browser === 'IE' && Env.verComp(Env.version, 10, '<')) || - (Env.browser === 'Safari' && Env.verComp(Env.version, 11, '<=')) || - (Env.browser === 'Firefox' && Env.verComp(Env.version, 37, '<')) || - Env.os === 'iOS' || // as of iOS11, no extensions are supported in accept attribute - Env.os === 'Android' - ); - }()), - return_response_headers: True, - return_response_type: function(responseType) { - if (responseType === 'json' && !!window.JSON) { // we can fake this one even if it's not supported - return true; - } - return Env.can('return_response_type', responseType); - }, - return_status_code: True, - report_upload_progress: Test(window.XMLHttpRequest && new XMLHttpRequest().upload), - resize_image: function() { - return I.can('access_binary') && Env.can('create_canvas'); - }, - select_file: function() { - return Env.can('use_fileinput') && window.File; - }, - select_folder: function() { - return I.can('select_file') && ( - Env.browser === 'Chrome' && Env.verComp(Env.version, 21, '>=') || - Env.browser === 'Firefox' && Env.verComp(Env.version, 42, '>=') // https://developer.mozilla.org/en-US/Firefox/Releases/42 - ); - }, - select_multiple: function() { - // it is buggy on Safari Windows and iOS - return I.can('select_file') && - !(Env.browser === 'Safari' && Env.os === 'Windows') && - !(Env.os === 'iOS' && Env.verComp(Env.osVersion, "7.0.0", '>') && Env.verComp(Env.osVersion, "8.0.0", '<')); - }, - send_binary_string: Test(window.XMLHttpRequest && (new XMLHttpRequest().sendAsBinary || (window.Uint8Array && window.ArrayBuffer))), - send_custom_headers: Test(window.XMLHttpRequest), - send_multipart: function() { - return !!(window.XMLHttpRequest && new XMLHttpRequest().upload && window.FormData) || I.can('send_binary_string'); - }, - slice_blob: Test(window.File && (File.prototype.mozSlice || File.prototype.webkitSlice || File.prototype.slice)), - stream_upload: function(){ - return I.can('slice_blob') && I.can('send_multipart'); - }, - summon_file_dialog: function() { // yeah... some dirty sniffing here... - return I.can('select_file') && !( - (Env.browser === 'Firefox' && Env.verComp(Env.version, 4, '<')) || - (Env.browser === 'Opera' && Env.verComp(Env.version, 12, '<')) || - (Env.browser === 'IE' && Env.verComp(Env.version, 10, '<')) - ); - }, - upload_filesize: True, - use_http_method: True - }, - arguments[2] - ); - - Runtime.call(this, options, (arguments[1] || type), caps); - - - Basic.extend(this, { - - init : function() { - this.trigger("Init"); - }, - - destroy: (function(destroy) { // extend default destroy method - return function() { - destroy.call(I); - destroy = I = null; - }; - }(this.destroy)) - }); - - Basic.extend(this.getShim(), extensions); - } - - Runtime.addConstructor(type, Html5Runtime); - - return extensions; -}); - -// Included from: src/javascript/runtime/html5/file/Blob.js - -/** - * Blob.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/html5/file/Blob -@private -*/ -define("moxie/runtime/html5/file/Blob", [ - "moxie/runtime/html5/Runtime", - "moxie/file/Blob" -], function(extensions, Blob) { - - function HTML5Blob() { - function w3cBlobSlice(blob, start, end) { - var blobSlice; - - if (window.File.prototype.slice) { - try { - blob.slice(); // depricated version will throw WRONG_ARGUMENTS_ERR exception - return blob.slice(start, end); - } catch (e) { - // depricated slice method - return blob.slice(start, end - start); - } - // slice method got prefixed: https://bugzilla.mozilla.org/show_bug.cgi?id=649672 - } else if ((blobSlice = window.File.prototype.webkitSlice || window.File.prototype.mozSlice)) { - return blobSlice.call(blob, start, end); - } else { - return null; // or throw some exception - } - } - - this.slice = function() { - return new Blob(this.getRuntime().uid, w3cBlobSlice.apply(this, arguments)); - }; - - this.destroy = function() { - this.getRuntime().getShim().removeInstance(this.uid); - }; - } - - return (extensions.Blob = HTML5Blob); -}); - -// Included from: src/javascript/core/utils/Events.js - -/** - * Events.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/core/utils/Events -@public -@static -*/ - -define('moxie/core/utils/Events', [ - 'moxie/core/utils/Basic' -], function(Basic) { - var eventhash = {}, uid = 'moxie_' + Basic.guid(); - - // IE W3C like event funcs - function preventDefault() { - this.returnValue = false; - } - - function stopPropagation() { - this.cancelBubble = true; - } - - /** - Adds an event handler to the specified object and store reference to the handler - in objects internal Plupload registry (@see removeEvent). - - @method addEvent - @static - @param {Object} obj DOM element like object to add handler to. - @param {String} name Name to add event listener to. - @param {Function} callback Function to call when event occurs. - @param {String} [key] that might be used to add specifity to the event record. - */ - var addEvent = function(obj, name, callback, key) { - var func, events; - - name = name.toLowerCase(); - - // Add event listener - if (obj.addEventListener) { - func = callback; - - obj.addEventListener(name, func, false); - } else if (obj.attachEvent) { - func = function() { - var evt = window.event; - - if (!evt.target) { - evt.target = evt.srcElement; - } - - evt.preventDefault = preventDefault; - evt.stopPropagation = stopPropagation; - - callback(evt); - }; - - obj.attachEvent('on' + name, func); - } - - // Log event handler to objects internal mOxie registry - if (!obj[uid]) { - obj[uid] = Basic.guid(); - } - - if (!eventhash.hasOwnProperty(obj[uid])) { - eventhash[obj[uid]] = {}; - } - - events = eventhash[obj[uid]]; - - if (!events.hasOwnProperty(name)) { - events[name] = []; - } - - events[name].push({ - func: func, - orig: callback, // store original callback for IE - key: key - }); - }; - - - /** - Remove event handler from the specified object. If third argument (callback) - is not specified remove all events with the specified name. - - @method removeEvent - @static - @param {Object} obj DOM element to remove event listener(s) from. - @param {String} name Name of event listener to remove. - @param {Function|String} [callback] might be a callback or unique key to match. - */ - var removeEvent = function(obj, name, callback) { - var type, undef; - - name = name.toLowerCase(); - - if (obj[uid] && eventhash[obj[uid]] && eventhash[obj[uid]][name]) { - type = eventhash[obj[uid]][name]; - } else { - return; - } - - for (var i = type.length - 1; i >= 0; i--) { - // undefined or not, key should match - if (type[i].orig === callback || type[i].key === callback) { - if (obj.removeEventListener) { - obj.removeEventListener(name, type[i].func, false); - } else if (obj.detachEvent) { - obj.detachEvent('on'+name, type[i].func); - } - - type[i].orig = null; - type[i].func = null; - type.splice(i, 1); - - // If callback was passed we are done here, otherwise proceed - if (callback !== undef) { - break; - } - } - } - - // If event array got empty, remove it - if (!type.length) { - delete eventhash[obj[uid]][name]; - } - - // If mOxie registry has become empty, remove it - if (Basic.isEmptyObj(eventhash[obj[uid]])) { - delete eventhash[obj[uid]]; - - // IE doesn't let you remove DOM object property with - delete - try { - delete obj[uid]; - } catch(e) { - obj[uid] = undef; - } - } - }; - - - /** - Remove all kind of events from the specified object - - @method removeAllEvents - @static - @param {Object} obj DOM element to remove event listeners from. - @param {String} [key] unique key to match, when removing events. - */ - var removeAllEvents = function(obj, key) { - if (!obj || !obj[uid]) { - return; - } - - Basic.each(eventhash[obj[uid]], function(events, name) { - removeEvent(obj, name, key); - }); - }; - - return { - addEvent: addEvent, - removeEvent: removeEvent, - removeAllEvents: removeAllEvents - }; -}); - -// Included from: src/javascript/runtime/html5/file/FileInput.js - -/** - * FileInput.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/html5/file/FileInput -@private -*/ -define("moxie/runtime/html5/file/FileInput", [ - "moxie/runtime/html5/Runtime", - "moxie/file/File", - "moxie/core/utils/Basic", - "moxie/core/utils/Dom", - "moxie/core/utils/Events", - "moxie/core/utils/Mime", - "moxie/core/utils/Env" -], function(extensions, File, Basic, Dom, Events, Mime, Env) { - - function FileInput() { - var _options, _browseBtnZIndex; // save original z-index - - Basic.extend(this, { - init: function(options) { - var comp = this, I = comp.getRuntime(), input, shimContainer, mimes, browseButton, zIndex, top; - - _options = options; - - // figure out accept string - mimes = Mime.extList2mimes(_options.accept, I.can('filter_by_extension')); - - shimContainer = I.getShimContainer(); - - shimContainer.innerHTML = ''; - - input = Dom.get(I.uid); - - // prepare file input to be placed underneath the browse_button element - Basic.extend(input.style, { - position: 'absolute', - top: 0, - left: 0, - width: '100%', - height: '100%' - }); - - - browseButton = Dom.get(_options.browse_button); - _browseBtnZIndex = Dom.getStyle(browseButton, 'z-index') || 'auto'; - - // Route click event to the input[type=file] element for browsers that support such behavior - if (I.can('summon_file_dialog')) { - if (Dom.getStyle(browseButton, 'position') === 'static') { - browseButton.style.position = 'relative'; - } - - Events.addEvent(browseButton, 'click', function(e) { - var input = Dom.get(I.uid); - if (input && !input.disabled) { // for some reason FF (up to 8.0.1 so far) lets to click disabled input[type=file] - input.click(); - } - e.preventDefault(); - }, comp.uid); - - comp.bind('Refresh', function() { - zIndex = parseInt(_browseBtnZIndex, 10) || 1; - - Dom.get(_options.browse_button).style.zIndex = zIndex; - this.getRuntime().getShimContainer().style.zIndex = zIndex - 1; - }); - } - - /* Since we have to place input[type=file] on top of the browse_button for some browsers, - browse_button loses interactivity, so we restore it here */ - top = I.can('summon_file_dialog') ? browseButton : shimContainer; - - Events.addEvent(top, 'mouseover', function() { - comp.trigger('mouseenter'); - }, comp.uid); - - Events.addEvent(top, 'mouseout', function() { - comp.trigger('mouseleave'); - }, comp.uid); - - Events.addEvent(top, 'mousedown', function() { - comp.trigger('mousedown'); - }, comp.uid); - - Events.addEvent(Dom.get(_options.container), 'mouseup', function() { - comp.trigger('mouseup'); - }, comp.uid); - - // it shouldn't be possible to tab into the hidden element - (I.can('summon_file_dialog') ? input : browseButton).setAttribute('tabindex', -1); - - input.onchange = function onChange() { // there should be only one handler for this - comp.files = []; - - Basic.each(this.files, function(file) { - var relativePath = ''; - - if (_options.directory) { - // folders are represented by dots, filter them out (Chrome 11+) - if (file.name == ".") { - // if it looks like a folder... - return true; - } - } - - if (file.webkitRelativePath) { - relativePath = '/' + file.webkitRelativePath.replace(/^\//, ''); - } - - file = new File(I.uid, file); - file.relativePath = relativePath; - - comp.files.push(file); - }); - - // clearing the value enables the user to select the same file again if they want to - if (Env.browser !== 'IE' && Env.browser !== 'IEMobile') { - this.value = ''; - } else { - // in IE input[type="file"] is read-only so the only way to reset it is to re-insert it - var clone = this.cloneNode(true); - this.parentNode.replaceChild(clone, this); - clone.onchange = onChange; - } - - if (comp.files.length) { - comp.trigger('change'); - } - }; - - // ready event is perfectly asynchronous - comp.trigger({ - type: 'ready', - async: true - }); - - shimContainer = null; - }, - - - setOption: function(name, value) { - var I = this.getRuntime(); - var input = Dom.get(I.uid); - - switch (name) { - case 'accept': - if (value) { - var mimes = value.mimes || Mime.extList2mimes(value, I.can('filter_by_extension')); - input.setAttribute('accept', mimes.join(',')); - } else { - input.removeAttribute('accept'); - } - break; - - case 'directory': - if (value && I.can('select_folder')) { - input.setAttribute('directory', ''); - input.setAttribute('webkitdirectory', ''); - } else { - input.removeAttribute('directory'); - input.removeAttribute('webkitdirectory'); - } - break; - - case 'multiple': - if (value && I.can('select_multiple')) { - input.setAttribute('multiple', ''); - } else { - input.removeAttribute('multiple'); - } - - } - }, - - - disable: function(state) { - var I = this.getRuntime(), input; - - if ((input = Dom.get(I.uid))) { - input.disabled = !!state; - } - }, - - destroy: function() { - var I = this.getRuntime() - , shim = I.getShim() - , shimContainer = I.getShimContainer() - , container = _options && Dom.get(_options.container) - , browseButton = _options && Dom.get(_options.browse_button) - ; - - if (container) { - Events.removeAllEvents(container, this.uid); - } - - if (browseButton) { - Events.removeAllEvents(browseButton, this.uid); - browseButton.style.zIndex = _browseBtnZIndex; // reset to original value - } - - if (shimContainer) { - Events.removeAllEvents(shimContainer, this.uid); - shimContainer.innerHTML = ''; - } - - shim.removeInstance(this.uid); - - _options = shimContainer = container = browseButton = shim = null; - } - }); - } - - return (extensions.FileInput = FileInput); -}); - -// Included from: src/javascript/runtime/html5/file/FileDrop.js - -/** - * FileDrop.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/html5/file/FileDrop -@private -*/ -define("moxie/runtime/html5/file/FileDrop", [ - "moxie/runtime/html5/Runtime", - 'moxie/file/File', - "moxie/core/utils/Basic", - "moxie/core/utils/Dom", - "moxie/core/utils/Events", - "moxie/core/utils/Mime" -], function(extensions, File, Basic, Dom, Events, Mime) { - - function FileDrop() { - var _files = [], _allowedExts = [], _options, _ruid; - - Basic.extend(this, { - init: function(options) { - var comp = this, dropZone; - - _options = options; - _ruid = comp.ruid; // every dropped-in file should have a reference to the runtime - _allowedExts = _extractExts(_options.accept); - dropZone = _options.container; - - Events.addEvent(dropZone, 'dragover', function(e) { - if (!_hasFiles(e)) { - return; - } - e.preventDefault(); - e.dataTransfer.dropEffect = 'copy'; - }, comp.uid); - - Events.addEvent(dropZone, 'drop', function(e) { - if (!_hasFiles(e)) { - return; - } - e.preventDefault(); - - _files = []; - - // Chrome 21+ accepts folders via Drag'n'Drop - if (e.dataTransfer.items && e.dataTransfer.items[0].webkitGetAsEntry) { - _readItems(e.dataTransfer.items, function() { - comp.files = _files; - comp.trigger("drop"); - }); - } else { - Basic.each(e.dataTransfer.files, function(file) { - _addFile(file); - }); - comp.files = _files; - comp.trigger("drop"); - } - }, comp.uid); - - Events.addEvent(dropZone, 'dragenter', function(e) { - comp.trigger("dragenter"); - }, comp.uid); - - Events.addEvent(dropZone, 'dragleave', function(e) { - comp.trigger("dragleave"); - }, comp.uid); - }, - - destroy: function() { - Events.removeAllEvents(_options && Dom.get(_options.container), this.uid); - _ruid = _files = _allowedExts = _options = null; - this.getRuntime().getShim().removeInstance(this.uid); - } - }); - - - function _hasFiles(e) { - if (!e.dataTransfer || !e.dataTransfer.types) { // e.dataTransfer.files is not available in Gecko during dragover - return false; - } - - var types = Basic.toArray(e.dataTransfer.types || []); - - return Basic.inArray("Files", types) !== -1 || - Basic.inArray("public.file-url", types) !== -1 || // Safari < 5 - Basic.inArray("application/x-moz-file", types) !== -1 // Gecko < 1.9.2 (< Firefox 3.6) - ; - } - - - function _addFile(file, relativePath) { - if (_isAcceptable(file)) { - var fileObj = new File(_ruid, file); - fileObj.relativePath = relativePath || ''; - _files.push(fileObj); - } - } - - - function _extractExts(accept) { - var exts = []; - for (var i = 0; i < accept.length; i++) { - [].push.apply(exts, accept[i].extensions.split(/\s*,\s*/)); - } - return Basic.inArray('*', exts) === -1 ? exts : []; - } - - - function _isAcceptable(file) { - if (!_allowedExts.length) { - return true; - } - var ext = Mime.getFileExtension(file.name); - return !ext || Basic.inArray(ext, _allowedExts) !== -1; - } - - - function _readItems(items, cb) { - var entries = []; - Basic.each(items, function(item) { - var entry = item.webkitGetAsEntry(); - // Address #998 (https://code.google.com/p/chromium/issues/detail?id=332579) - if (entry) { - // file() fails on OSX when the filename contains a special character (e.g. umlaut): see #61 - if (entry.isFile) { - _addFile(item.getAsFile(), entry.fullPath); - } else { - entries.push(entry); - } - } - }); - - if (entries.length) { - _readEntries(entries, cb); - } else { - cb(); - } - } - - - function _readEntries(entries, cb) { - var queue = []; - Basic.each(entries, function(entry) { - queue.push(function(cbcb) { - _readEntry(entry, cbcb); - }); - }); - Basic.inSeries(queue, function() { - cb(); - }); - } - - - function _readEntry(entry, cb) { - if (entry.isFile) { - entry.file(function(file) { - _addFile(file, entry.fullPath); - cb(); - }, function() { - // fire an error event maybe - cb(); - }); - } else if (entry.isDirectory) { - _readDirEntry(entry, cb); - } else { - cb(); // not file, not directory? what then?.. - } - } - - - function _readDirEntry(dirEntry, cb) { - var entries = [], dirReader = dirEntry.createReader(); - - // keep quering recursively till no more entries - function getEntries(cbcb) { - dirReader.readEntries(function(moreEntries) { - if (moreEntries.length) { - [].push.apply(entries, moreEntries); - getEntries(cbcb); - } else { - cbcb(); - } - }, cbcb); - } - - // ...and you thought FileReader was crazy... - getEntries(function() { - _readEntries(entries, cb); - }); - } - } - - return (extensions.FileDrop = FileDrop); -}); - -// Included from: src/javascript/runtime/html5/file/FileReader.js - -/** - * FileReader.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/html5/file/FileReader -@private -*/ -define("moxie/runtime/html5/file/FileReader", [ - "moxie/runtime/html5/Runtime", - "moxie/core/utils/Encode", - "moxie/core/utils/Basic" -], function(extensions, Encode, Basic) { - - function FileReader() { - var _fr, _convertToBinary = false; - - Basic.extend(this, { - - read: function(op, blob) { - var comp = this; - - comp.result = ''; - - _fr = new window.FileReader(); - - _fr.addEventListener('progress', function(e) { - comp.trigger(e); - }); - - _fr.addEventListener('load', function(e) { - comp.result = _convertToBinary ? _toBinary(_fr.result) : _fr.result; - comp.trigger(e); - }); - - _fr.addEventListener('error', function(e) { - comp.trigger(e, _fr.error); - }); - - _fr.addEventListener('loadend', function(e) { - _fr = null; - comp.trigger(e); - }); - - if (Basic.typeOf(_fr[op]) === 'function') { - _convertToBinary = false; - _fr[op](blob.getSource()); - } else if (op === 'readAsBinaryString') { // readAsBinaryString is depricated in general and never existed in IE10+ - _convertToBinary = true; - _fr.readAsDataURL(blob.getSource()); - } - }, - - abort: function() { - if (_fr) { - _fr.abort(); - } - }, - - destroy: function() { - _fr = null; - this.getRuntime().getShim().removeInstance(this.uid); - } - }); - - function _toBinary(str) { - return Encode.atob(str.substring(str.indexOf('base64,') + 7)); - } - } - - return (extensions.FileReader = FileReader); -}); - -// Included from: src/javascript/runtime/html5/xhr/XMLHttpRequest.js - -/** - * XMLHttpRequest.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/*global ActiveXObject:true */ - -/** -@class moxie/runtime/html5/xhr/XMLHttpRequest -@private -*/ -define("moxie/runtime/html5/xhr/XMLHttpRequest", [ - "moxie/runtime/html5/Runtime", - "moxie/core/utils/Basic", - "moxie/core/utils/Mime", - "moxie/core/utils/Url", - "moxie/file/File", - "moxie/file/Blob", - "moxie/xhr/FormData", - "moxie/core/Exceptions", - "moxie/core/utils/Env" -], function(extensions, Basic, Mime, Url, File, Blob, FormData, x, Env) { - - function XMLHttpRequest() { - var self = this - , _xhr - , _filename - ; - - Basic.extend(this, { - send: function(meta, data) { - var target = this - , isGecko2_5_6 = (Env.browser === 'Mozilla' && Env.verComp(Env.version, 4, '>=') && Env.verComp(Env.version, 7, '<')) - , isAndroidBrowser = Env.browser === 'Android Browser' - , mustSendAsBinary = false - ; - - // extract file name - _filename = meta.url.replace(/^.+?\/([\w\-\.]+)$/, '$1').toLowerCase(); - - _xhr = _getNativeXHR(); - _xhr.open(meta.method, meta.url, meta.async, meta.user, meta.password); - - - // prepare data to be sent - if (data instanceof Blob) { - if (data.isDetached()) { - mustSendAsBinary = true; - } - data = data.getSource(); - } else if (data instanceof FormData) { - - if (data.hasBlob()) { - if (data.getBlob().isDetached()) { - data = _prepareMultipart.call(target, data); // _xhr must be instantiated and be in OPENED state - mustSendAsBinary = true; - } else if ((isGecko2_5_6 || isAndroidBrowser) && Basic.typeOf(data.getBlob().getSource()) === 'blob' && window.FileReader) { - // Gecko 2/5/6 can't send blob in FormData: https://bugzilla.mozilla.org/show_bug.cgi?id=649150 - // Android browsers (default one and Dolphin) seem to have the same issue, see: #613 - _preloadAndSend.call(target, meta, data); - return; // _preloadAndSend will reinvoke send() with transmutated FormData =%D - } - } - - // transfer fields to real FormData - if (data instanceof FormData) { // if still a FormData, e.g. not mangled by _prepareMultipart() - var fd = new window.FormData(); - data.each(function(value, name) { - if (value instanceof Blob) { - fd.append(name, value.getSource()); - } else { - fd.append(name, value); - } - }); - data = fd; - } - } - - - // if XHR L2 - if (_xhr.upload) { - if (meta.withCredentials) { - _xhr.withCredentials = true; - } - - _xhr.addEventListener('load', function(e) { - target.trigger(e); - }); - - _xhr.addEventListener('error', function(e) { - target.trigger(e); - }); - - // additionally listen to progress events - _xhr.addEventListener('progress', function(e) { - target.trigger(e); - }); - - _xhr.upload.addEventListener('progress', function(e) { - target.trigger({ - type: 'UploadProgress', - loaded: e.loaded, - total: e.total - }); - }); - // ... otherwise simulate XHR L2 - } else { - _xhr.onreadystatechange = function onReadyStateChange() { - - // fake Level 2 events - switch (_xhr.readyState) { - - case 1: // XMLHttpRequest.OPENED - // readystatechanged is fired twice for OPENED state (in IE and Mozilla) - neu - break; - - // looks like HEADERS_RECEIVED (state 2) is not reported in Opera (or it's old versions) - neu - case 2: // XMLHttpRequest.HEADERS_RECEIVED - break; - - case 3: // XMLHttpRequest.LOADING - // try to fire progress event for not XHR L2 - var total, loaded; - - try { - if (Url.hasSameOrigin(meta.url)) { // Content-Length not accessible for cross-domain on some browsers - total = _xhr.getResponseHeader('Content-Length') || 0; // old Safari throws an exception here - } - - if (_xhr.responseText) { // responseText was introduced in IE7 - loaded = _xhr.responseText.length; - } - } catch(ex) { - total = loaded = 0; - } - - target.trigger({ - type: 'progress', - lengthComputable: !!total, - total: parseInt(total, 10), - loaded: loaded - }); - break; - - case 4: // XMLHttpRequest.DONE - // release readystatechange handler (mostly for IE) - _xhr.onreadystatechange = function() {}; - - // usually status 0 is returned when server is unreachable, but FF also fails to status 0 for 408 timeout - try { - if (_xhr.status >= 200 && _xhr.status < 400) { - target.trigger('load'); - break; - } - } catch(ex) {} - - target.trigger('error'); - break; - } - }; - } - - - // set request headers - if (!Basic.isEmptyObj(meta.headers)) { - Basic.each(meta.headers, function(value, header) { - _xhr.setRequestHeader(header, value); - }); - } - - // request response type - if ("" !== meta.responseType && 'responseType' in _xhr) { - if ('json' === meta.responseType && !Env.can('return_response_type', 'json')) { // we can fake this one - _xhr.responseType = 'text'; - } else { - _xhr.responseType = meta.responseType; - } - } - - // send ... - if (!mustSendAsBinary) { - _xhr.send(data); - } else { - if (_xhr.sendAsBinary) { // Gecko - _xhr.sendAsBinary(data); - } else { // other browsers having support for typed arrays - (function() { - // mimic Gecko's sendAsBinary - var ui8a = new Uint8Array(data.length); - for (var i = 0; i < data.length; i++) { - ui8a[i] = (data.charCodeAt(i) & 0xff); - } - _xhr.send(ui8a.buffer); - }()); - } - } - - target.trigger('loadstart'); - }, - - getStatus: function() { - // according to W3C spec it should return 0 for readyState < 3, but instead it throws an exception - try { - if (_xhr) { - return _xhr.status; - } - } catch(ex) {} - return 0; - }, - - getResponse: function(responseType) { - var I = this.getRuntime(); - - try { - switch (responseType) { - case 'blob': - var file = new File(I.uid, _xhr.response); - - // try to extract file name from content-disposition if possible (might be - not, if CORS for example) - var disposition = _xhr.getResponseHeader('Content-Disposition'); - if (disposition) { - // extract filename from response header if available - var match = disposition.match(/filename=([\'\"'])([^\1]+)\1/); - if (match) { - _filename = match[2]; - } - } - file.name = _filename; - - // pre-webkit Opera doesn't set type property on the blob response - if (!file.type) { - file.type = Mime.getFileMime(_filename); - } - return file; - - case 'json': - if (!Env.can('return_response_type', 'json')) { - return _xhr.status === 200 && !!window.JSON ? JSON.parse(_xhr.responseText) : null; - } - return _xhr.response; - - case 'document': - return _getDocument(_xhr); - - default: - return _xhr.responseText !== '' ? _xhr.responseText : null; // against the specs, but for consistency across the runtimes - } - } catch(ex) { - return null; - } - }, - - getAllResponseHeaders: function() { - try { - return _xhr.getAllResponseHeaders(); - } catch(ex) {} - return ''; - }, - - abort: function() { - if (_xhr) { - _xhr.abort(); - } - }, - - destroy: function() { - self = _filename = null; - this.getRuntime().getShim().removeInstance(this.uid); - } - }); - - - // here we go... ugly fix for ugly bug - function _preloadAndSend(meta, data) { - var target = this, blob, fr; - - // get original blob - blob = data.getBlob().getSource(); - - // preload blob in memory to be sent as binary string - fr = new window.FileReader(); - fr.onload = function() { - // overwrite original blob - data.append(data.getBlobName(), new Blob(null, { - type: blob.type, - data: fr.result - })); - // invoke send operation again - self.send.call(target, meta, data); - }; - fr.readAsBinaryString(blob); - } - - - function _getNativeXHR() { - if (window.XMLHttpRequest && !(Env.browser === 'IE' && Env.verComp(Env.version, 8, '<'))) { // IE7 has native XHR but it's buggy - return new window.XMLHttpRequest(); - } else { - return (function() { - var progIDs = ['Msxml2.XMLHTTP.6.0', 'Microsoft.XMLHTTP']; // if 6.0 available, use it, otherwise failback to default 3.0 - for (var i = 0; i < progIDs.length; i++) { - try { - return new ActiveXObject(progIDs[i]); - } catch (ex) {} - } - })(); - } - } - - // @credits Sergey Ilinsky (http://www.ilinsky.com/) - function _getDocument(xhr) { - var rXML = xhr.responseXML; - var rText = xhr.responseText; - - // Try parsing responseText (@see: http://www.ilinsky.com/articles/XMLHttpRequest/#bugs-ie-responseXML-content-type) - if (Env.browser === 'IE' && rText && rXML && !rXML.documentElement && /[^\/]+\/[^\+]+\+xml/.test(xhr.getResponseHeader("Content-Type"))) { - rXML = new window.ActiveXObject("Microsoft.XMLDOM"); - rXML.async = false; - rXML.validateOnParse = false; - rXML.loadXML(rText); - } - - // Check if there is no error in document - if (rXML) { - if ((Env.browser === 'IE' && rXML.parseError !== 0) || !rXML.documentElement || rXML.documentElement.tagName === "parsererror") { - return null; - } - } - return rXML; - } - - - function _prepareMultipart(fd) { - var boundary = '----moxieboundary' + new Date().getTime() - , dashdash = '--' - , crlf = '\r\n' - , multipart = '' - , I = this.getRuntime() - ; - - if (!I.can('send_binary_string')) { - throw new x.RuntimeError(x.RuntimeError.NOT_SUPPORTED_ERR); - } - - _xhr.setRequestHeader('Content-Type', 'multipart/form-data; boundary=' + boundary); - - // append multipart parameters - fd.each(function(value, name) { - // Firefox 3.6 failed to convert multibyte characters to UTF-8 in sendAsBinary(), - // so we try it here ourselves with: unescape(encodeURIComponent(value)) - if (value instanceof Blob) { - // Build RFC2388 blob - multipart += dashdash + boundary + crlf + - 'Content-Disposition: form-data; name="' + name + '"; filename="' + unescape(encodeURIComponent(value.name || 'blob')) + '"' + crlf + - 'Content-Type: ' + (value.type || 'application/octet-stream') + crlf + crlf + - value.getSource() + crlf; - } else { - multipart += dashdash + boundary + crlf + - 'Content-Disposition: form-data; name="' + name + '"' + crlf + crlf + - unescape(encodeURIComponent(value)) + crlf; - } - }); - - multipart += dashdash + boundary + dashdash + crlf; - - return multipart; - } - } - - return (extensions.XMLHttpRequest = XMLHttpRequest); -}); - -// Included from: src/javascript/runtime/html5/utils/BinaryReader.js - -/** - * BinaryReader.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/html5/utils/BinaryReader -@private -*/ -define("moxie/runtime/html5/utils/BinaryReader", [ - "moxie/core/utils/Basic" -], function(Basic) { - - - function BinaryReader(data) { - if (data instanceof ArrayBuffer) { - ArrayBufferReader.apply(this, arguments); - } else { - UTF16StringReader.apply(this, arguments); - } - } - - Basic.extend(BinaryReader.prototype, { - - littleEndian: false, - - - read: function(idx, size) { - var sum, mv, i; - - if (idx + size > this.length()) { - throw new Error("You are trying to read outside the source boundaries."); - } - - mv = this.littleEndian - ? 0 - : -8 * (size - 1) - ; - - for (i = 0, sum = 0; i < size; i++) { - sum |= (this.readByteAt(idx + i) << Math.abs(mv + i*8)); - } - return sum; - }, - - - write: function(idx, num, size) { - var mv, i, str = ''; - - if (idx > this.length()) { - throw new Error("You are trying to write outside the source boundaries."); - } - - mv = this.littleEndian - ? 0 - : -8 * (size - 1) - ; - - for (i = 0; i < size; i++) { - this.writeByteAt(idx + i, (num >> Math.abs(mv + i*8)) & 255); - } - }, - - - BYTE: function(idx) { - return this.read(idx, 1); - }, - - - SHORT: function(idx) { - return this.read(idx, 2); - }, - - - LONG: function(idx) { - return this.read(idx, 4); - }, - - - SLONG: function(idx) { // 2's complement notation - var num = this.read(idx, 4); - return (num > 2147483647 ? num - 4294967296 : num); - }, - - - CHAR: function(idx) { - return String.fromCharCode(this.read(idx, 1)); - }, - - - STRING: function(idx, count) { - return this.asArray('CHAR', idx, count).join(''); - }, - - - asArray: function(type, idx, count) { - var values = []; - - for (var i = 0; i < count; i++) { - values[i] = this[type](idx + i); - } - return values; - } - }); - - - function ArrayBufferReader(data) { - var _dv = new DataView(data); - - Basic.extend(this, { - - readByteAt: function(idx) { - return _dv.getUint8(idx); - }, - - - writeByteAt: function(idx, value) { - _dv.setUint8(idx, value); - }, - - - SEGMENT: function(idx, size, value) { - switch (arguments.length) { - case 2: - return data.slice(idx, idx + size); - - case 1: - return data.slice(idx); - - case 3: - if (value === null) { - value = new ArrayBuffer(); - } - - if (value instanceof ArrayBuffer) { - var arr = new Uint8Array(this.length() - size + value.byteLength); - if (idx > 0) { - arr.set(new Uint8Array(data.slice(0, idx)), 0); - } - arr.set(new Uint8Array(value), idx); - arr.set(new Uint8Array(data.slice(idx + size)), idx + value.byteLength); - - this.clear(); - data = arr.buffer; - _dv = new DataView(data); - break; - } - - default: return data; - } - }, - - - length: function() { - return data ? data.byteLength : 0; - }, - - - clear: function() { - _dv = data = null; - } - }); - } - - - function UTF16StringReader(data) { - Basic.extend(this, { - - readByteAt: function(idx) { - return data.charCodeAt(idx); - }, - - - writeByteAt: function(idx, value) { - putstr(String.fromCharCode(value), idx, 1); - }, - - - SEGMENT: function(idx, length, segment) { - switch (arguments.length) { - case 1: - return data.substr(idx); - case 2: - return data.substr(idx, length); - case 3: - putstr(segment !== null ? segment : '', idx, length); - break; - default: return data; - } - }, - - - length: function() { - return data ? data.length : 0; - }, - - clear: function() { - data = null; - } - }); - - - function putstr(segment, idx, length) { - length = arguments.length === 3 ? length : data.length - idx - 1; - data = data.substr(0, idx) + segment + data.substr(length + idx); - } - } - - - return BinaryReader; -}); - -// Included from: src/javascript/runtime/html5/image/JPEGHeaders.js - -/** - * JPEGHeaders.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/html5/image/JPEGHeaders -@private -*/ -define("moxie/runtime/html5/image/JPEGHeaders", [ - "moxie/runtime/html5/utils/BinaryReader", - "moxie/core/Exceptions" -], function(BinaryReader, x) { - - return function JPEGHeaders(data) { - var headers = [], _br, idx, marker, length = 0; - - _br = new BinaryReader(data); - - // Check if data is jpeg - if (_br.SHORT(0) !== 0xFFD8) { - _br.clear(); - throw new x.ImageError(x.ImageError.WRONG_FORMAT); - } - - idx = 2; - - while (idx <= _br.length()) { - marker = _br.SHORT(idx); - - // omit RST (restart) markers - if (marker >= 0xFFD0 && marker <= 0xFFD7) { - idx += 2; - continue; - } - - // no headers allowed after SOS marker - if (marker === 0xFFDA || marker === 0xFFD9) { - break; - } - - length = _br.SHORT(idx + 2) + 2; - - // APPn marker detected - if (marker >= 0xFFE1 && marker <= 0xFFEF) { - headers.push({ - hex: marker, - name: 'APP' + (marker & 0x000F), - start: idx, - length: length, - segment: _br.SEGMENT(idx, length) - }); - } - - idx += length; - } - - _br.clear(); - - return { - headers: headers, - - restore: function(data) { - var max, i, br; - - br = new BinaryReader(data); - - idx = br.SHORT(2) == 0xFFE0 ? 4 + br.SHORT(4) : 2; - - for (i = 0, max = headers.length; i < max; i++) { - br.SEGMENT(idx, 0, headers[i].segment); - idx += headers[i].length; - } - - data = br.SEGMENT(); - br.clear(); - return data; - }, - - strip: function(data) { - var br, headers, jpegHeaders, i; - - jpegHeaders = new JPEGHeaders(data); - headers = jpegHeaders.headers; - jpegHeaders.purge(); - - br = new BinaryReader(data); - - i = headers.length; - while (i--) { - br.SEGMENT(headers[i].start, headers[i].length, ''); - } - - data = br.SEGMENT(); - br.clear(); - return data; - }, - - get: function(name) { - var array = []; - - for (var i = 0, max = headers.length; i < max; i++) { - if (headers[i].name === name.toUpperCase()) { - array.push(headers[i].segment); - } - } - return array; - }, - - set: function(name, segment) { - var array = [], i, ii, max; - - if (typeof(segment) === 'string') { - array.push(segment); - } else { - array = segment; - } - - for (i = ii = 0, max = headers.length; i < max; i++) { - if (headers[i].name === name.toUpperCase()) { - headers[i].segment = array[ii]; - headers[i].length = array[ii].length; - ii++; - } - if (ii >= array.length) { - break; - } - } - }, - - purge: function() { - this.headers = headers = []; - } - }; - }; -}); - -// Included from: src/javascript/runtime/html5/image/ExifParser.js - -/** - * ExifParser.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/html5/image/ExifParser -@private -*/ -define("moxie/runtime/html5/image/ExifParser", [ - "moxie/core/utils/Basic", - "moxie/runtime/html5/utils/BinaryReader", - "moxie/core/Exceptions" -], function(Basic, BinaryReader, x) { - - function ExifParser(data) { - var __super__, tags, tagDescs, offsets, idx, Tiff; - - BinaryReader.call(this, data); - - tags = { - tiff: { - /* - The image orientation viewed in terms of rows and columns. - - 1 = The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side. - 2 = The 0th row is at the visual top of the image, and the 0th column is the visual right-hand side. - 3 = The 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side. - 4 = The 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side. - 5 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual top. - 6 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual top. - 7 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom. - 8 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom. - */ - 0x0112: 'Orientation', - 0x010E: 'ImageDescription', - 0x010F: 'Make', - 0x0110: 'Model', - 0x0131: 'Software', - 0x8769: 'ExifIFDPointer', - 0x8825: 'GPSInfoIFDPointer' - }, - exif: { - 0x9000: 'ExifVersion', - 0xA001: 'ColorSpace', - 0xA002: 'PixelXDimension', - 0xA003: 'PixelYDimension', - 0x9003: 'DateTimeOriginal', - 0x829A: 'ExposureTime', - 0x829D: 'FNumber', - 0x8827: 'ISOSpeedRatings', - 0x9201: 'ShutterSpeedValue', - 0x9202: 'ApertureValue' , - 0x9207: 'MeteringMode', - 0x9208: 'LightSource', - 0x9209: 'Flash', - 0x920A: 'FocalLength', - 0xA402: 'ExposureMode', - 0xA403: 'WhiteBalance', - 0xA406: 'SceneCaptureType', - 0xA404: 'DigitalZoomRatio', - 0xA408: 'Contrast', - 0xA409: 'Saturation', - 0xA40A: 'Sharpness' - }, - gps: { - 0x0000: 'GPSVersionID', - 0x0001: 'GPSLatitudeRef', - 0x0002: 'GPSLatitude', - 0x0003: 'GPSLongitudeRef', - 0x0004: 'GPSLongitude' - }, - - thumb: { - 0x0201: 'JPEGInterchangeFormat', - 0x0202: 'JPEGInterchangeFormatLength' - } - }; - - tagDescs = { - 'ColorSpace': { - 1: 'sRGB', - 0: 'Uncalibrated' - }, - - 'MeteringMode': { - 0: 'Unknown', - 1: 'Average', - 2: 'CenterWeightedAverage', - 3: 'Spot', - 4: 'MultiSpot', - 5: 'Pattern', - 6: 'Partial', - 255: 'Other' - }, - - 'LightSource': { - 1: 'Daylight', - 2: 'Fliorescent', - 3: 'Tungsten', - 4: 'Flash', - 9: 'Fine weather', - 10: 'Cloudy weather', - 11: 'Shade', - 12: 'Daylight fluorescent (D 5700 - 7100K)', - 13: 'Day white fluorescent (N 4600 -5400K)', - 14: 'Cool white fluorescent (W 3900 - 4500K)', - 15: 'White fluorescent (WW 3200 - 3700K)', - 17: 'Standard light A', - 18: 'Standard light B', - 19: 'Standard light C', - 20: 'D55', - 21: 'D65', - 22: 'D75', - 23: 'D50', - 24: 'ISO studio tungsten', - 255: 'Other' - }, - - 'Flash': { - 0x0000: 'Flash did not fire', - 0x0001: 'Flash fired', - 0x0005: 'Strobe return light not detected', - 0x0007: 'Strobe return light detected', - 0x0009: 'Flash fired, compulsory flash mode', - 0x000D: 'Flash fired, compulsory flash mode, return light not detected', - 0x000F: 'Flash fired, compulsory flash mode, return light detected', - 0x0010: 'Flash did not fire, compulsory flash mode', - 0x0018: 'Flash did not fire, auto mode', - 0x0019: 'Flash fired, auto mode', - 0x001D: 'Flash fired, auto mode, return light not detected', - 0x001F: 'Flash fired, auto mode, return light detected', - 0x0020: 'No flash function', - 0x0041: 'Flash fired, red-eye reduction mode', - 0x0045: 'Flash fired, red-eye reduction mode, return light not detected', - 0x0047: 'Flash fired, red-eye reduction mode, return light detected', - 0x0049: 'Flash fired, compulsory flash mode, red-eye reduction mode', - 0x004D: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected', - 0x004F: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light detected', - 0x0059: 'Flash fired, auto mode, red-eye reduction mode', - 0x005D: 'Flash fired, auto mode, return light not detected, red-eye reduction mode', - 0x005F: 'Flash fired, auto mode, return light detected, red-eye reduction mode' - }, - - 'ExposureMode': { - 0: 'Auto exposure', - 1: 'Manual exposure', - 2: 'Auto bracket' - }, - - 'WhiteBalance': { - 0: 'Auto white balance', - 1: 'Manual white balance' - }, - - 'SceneCaptureType': { - 0: 'Standard', - 1: 'Landscape', - 2: 'Portrait', - 3: 'Night scene' - }, - - 'Contrast': { - 0: 'Normal', - 1: 'Soft', - 2: 'Hard' - }, - - 'Saturation': { - 0: 'Normal', - 1: 'Low saturation', - 2: 'High saturation' - }, - - 'Sharpness': { - 0: 'Normal', - 1: 'Soft', - 2: 'Hard' - }, - - // GPS related - 'GPSLatitudeRef': { - N: 'North latitude', - S: 'South latitude' - }, - - 'GPSLongitudeRef': { - E: 'East longitude', - W: 'West longitude' - } - }; - - offsets = { - tiffHeader: 10 - }; - - idx = offsets.tiffHeader; - - __super__ = { - clear: this.clear - }; - - // Public functions - Basic.extend(this, { - - read: function() { - try { - return ExifParser.prototype.read.apply(this, arguments); - } catch (ex) { - throw new x.ImageError(x.ImageError.INVALID_META_ERR); - } - }, - - - write: function() { - try { - return ExifParser.prototype.write.apply(this, arguments); - } catch (ex) { - throw new x.ImageError(x.ImageError.INVALID_META_ERR); - } - }, - - - UNDEFINED: function() { - return this.BYTE.apply(this, arguments); - }, - - - RATIONAL: function(idx) { - return this.LONG(idx) / this.LONG(idx + 4) - }, - - - SRATIONAL: function(idx) { - return this.SLONG(idx) / this.SLONG(idx + 4) - }, - - ASCII: function(idx) { - return this.CHAR(idx); - }, - - TIFF: function() { - return Tiff || null; - }, - - - EXIF: function() { - var Exif = null; - - if (offsets.exifIFD) { - try { - Exif = extractTags.call(this, offsets.exifIFD, tags.exif); - } catch(ex) { - return null; - } - - // Fix formatting of some tags - if (Exif.ExifVersion && Basic.typeOf(Exif.ExifVersion) === 'array') { - for (var i = 0, exifVersion = ''; i < Exif.ExifVersion.length; i++) { - exifVersion += String.fromCharCode(Exif.ExifVersion[i]); - } - Exif.ExifVersion = exifVersion; - } - } - - return Exif; - }, - - - GPS: function() { - var GPS = null; - - if (offsets.gpsIFD) { - try { - GPS = extractTags.call(this, offsets.gpsIFD, tags.gps); - } catch (ex) { - return null; - } - - // iOS devices (and probably some others) do not put in GPSVersionID tag (why?..) - if (GPS.GPSVersionID && Basic.typeOf(GPS.GPSVersionID) === 'array') { - GPS.GPSVersionID = GPS.GPSVersionID.join('.'); - } - } - - return GPS; - }, - - - thumb: function() { - if (offsets.IFD1) { - try { - var IFD1Tags = extractTags.call(this, offsets.IFD1, tags.thumb); - - if ('JPEGInterchangeFormat' in IFD1Tags) { - return this.SEGMENT(offsets.tiffHeader + IFD1Tags.JPEGInterchangeFormat, IFD1Tags.JPEGInterchangeFormatLength); - } - } catch (ex) {} - } - return null; - }, - - - setExif: function(tag, value) { - // Right now only setting of width/height is possible - if (tag !== 'PixelXDimension' && tag !== 'PixelYDimension') { return false; } - - return setTag.call(this, 'exif', tag, value); - }, - - - clear: function() { - __super__.clear(); - data = tags = tagDescs = Tiff = offsets = __super__ = null; - } - }); - - - // Check if that's APP1 and that it has EXIF - if (this.SHORT(0) !== 0xFFE1 || this.STRING(4, 5).toUpperCase() !== "EXIF\0") { - throw new x.ImageError(x.ImageError.INVALID_META_ERR); - } - - // Set read order of multi-byte data - this.littleEndian = (this.SHORT(idx) == 0x4949); - - // Check if always present bytes are indeed present - if (this.SHORT(idx+=2) !== 0x002A) { - throw new x.ImageError(x.ImageError.INVALID_META_ERR); - } - - offsets.IFD0 = offsets.tiffHeader + this.LONG(idx += 2); - Tiff = extractTags.call(this, offsets.IFD0, tags.tiff); - - if ('ExifIFDPointer' in Tiff) { - offsets.exifIFD = offsets.tiffHeader + Tiff.ExifIFDPointer; - delete Tiff.ExifIFDPointer; - } - - if ('GPSInfoIFDPointer' in Tiff) { - offsets.gpsIFD = offsets.tiffHeader + Tiff.GPSInfoIFDPointer; - delete Tiff.GPSInfoIFDPointer; - } - - if (Basic.isEmptyObj(Tiff)) { - Tiff = null; - } - - // check if we have a thumb as well - var IFD1Offset = this.LONG(offsets.IFD0 + this.SHORT(offsets.IFD0) * 12 + 2); - if (IFD1Offset) { - offsets.IFD1 = offsets.tiffHeader + IFD1Offset; - } - - - function extractTags(IFD_offset, tags2extract) { - var data = this; - var length, i, tag, type, count, size, offset, value, values = [], hash = {}; - - var types = { - 1 : 'BYTE', - 7 : 'UNDEFINED', - 2 : 'ASCII', - 3 : 'SHORT', - 4 : 'LONG', - 5 : 'RATIONAL', - 9 : 'SLONG', - 10: 'SRATIONAL' - }; - - var sizes = { - 'BYTE' : 1, - 'UNDEFINED' : 1, - 'ASCII' : 1, - 'SHORT' : 2, - 'LONG' : 4, - 'RATIONAL' : 8, - 'SLONG' : 4, - 'SRATIONAL' : 8 - }; - - length = data.SHORT(IFD_offset); - - // The size of APP1 including all these elements shall not exceed the 64 Kbytes specified in the JPEG standard. - - for (i = 0; i < length; i++) { - values = []; - - // Set binary reader pointer to beginning of the next tag - offset = IFD_offset + 2 + i*12; - - tag = tags2extract[data.SHORT(offset)]; - - if (tag === undefined) { - continue; // Not the tag we requested - } - - type = types[data.SHORT(offset+=2)]; - count = data.LONG(offset+=2); - size = sizes[type]; - - if (!size) { - throw new x.ImageError(x.ImageError.INVALID_META_ERR); - } - - offset += 4; - - // tag can only fit 4 bytes of data, if data is larger we should look outside - if (size * count > 4) { - // instead of data tag contains an offset of the data - offset = data.LONG(offset) + offsets.tiffHeader; - } - - // in case we left the boundaries of data throw an early exception - if (offset + size * count >= this.length()) { - throw new x.ImageError(x.ImageError.INVALID_META_ERR); - } - - // special care for the string - if (type === 'ASCII') { - hash[tag] = Basic.trim(data.STRING(offset, count).replace(/\0$/, '')); // strip trailing NULL - continue; - } else { - values = data.asArray(type, offset, count); - value = (count == 1 ? values[0] : values); - - if (tagDescs.hasOwnProperty(tag) && typeof value != 'object') { - hash[tag] = tagDescs[tag][value]; - } else { - hash[tag] = value; - } - } - } - - return hash; - } - - // At the moment only setting of simple (LONG) values, that do not require offset recalculation, is supported - function setTag(ifd, tag, value) { - var offset, length, tagOffset, valueOffset = 0; - - // If tag name passed translate into hex key - if (typeof(tag) === 'string') { - var tmpTags = tags[ifd.toLowerCase()]; - for (var hex in tmpTags) { - if (tmpTags[hex] === tag) { - tag = hex; - break; - } - } - } - offset = offsets[ifd.toLowerCase() + 'IFD']; - length = this.SHORT(offset); - - for (var i = 0; i < length; i++) { - tagOffset = offset + 12 * i + 2; - - if (this.SHORT(tagOffset) == tag) { - valueOffset = tagOffset + 8; - break; - } - } - - if (!valueOffset) { - return false; - } - - try { - this.write(valueOffset, value, 4); - } catch(ex) { - return false; - } - - return true; - } - } - - ExifParser.prototype = BinaryReader.prototype; - - return ExifParser; -}); - -// Included from: src/javascript/runtime/html5/image/JPEG.js - -/** - * JPEG.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/html5/image/JPEG -@private -*/ -define("moxie/runtime/html5/image/JPEG", [ - "moxie/core/utils/Basic", - "moxie/core/Exceptions", - "moxie/runtime/html5/image/JPEGHeaders", - "moxie/runtime/html5/utils/BinaryReader", - "moxie/runtime/html5/image/ExifParser" -], function(Basic, x, JPEGHeaders, BinaryReader, ExifParser) { - - function JPEG(data) { - var _br, _hm, _ep, _info; - - _br = new BinaryReader(data); - - // check if it is jpeg - if (_br.SHORT(0) !== 0xFFD8) { - throw new x.ImageError(x.ImageError.WRONG_FORMAT); - } - - // backup headers - _hm = new JPEGHeaders(data); - - // extract exif info - try { - _ep = new ExifParser(_hm.get('app1')[0]); - } catch(ex) {} - - // get dimensions - _info = _getDimensions.call(this); - - Basic.extend(this, { - type: 'image/jpeg', - - size: _br.length(), - - width: _info && _info.width || 0, - - height: _info && _info.height || 0, - - setExif: function(tag, value) { - if (!_ep) { - return false; // or throw an exception - } - - if (Basic.typeOf(tag) === 'object') { - Basic.each(tag, function(value, tag) { - _ep.setExif(tag, value); - }); - } else { - _ep.setExif(tag, value); - } - - // update internal headers - _hm.set('app1', _ep.SEGMENT()); - }, - - writeHeaders: function() { - if (!arguments.length) { - // if no arguments passed, update headers internally - return _hm.restore(data); - } - return _hm.restore(arguments[0]); - }, - - stripHeaders: function(data) { - return _hm.strip(data); - }, - - purge: function() { - _purge.call(this); - } - }); - - if (_ep) { - this.meta = { - tiff: _ep.TIFF(), - exif: _ep.EXIF(), - gps: _ep.GPS(), - thumb: _getThumb() - }; - } - - - function _getDimensions(br) { - var idx = 0 - , marker - , length - ; - - if (!br) { - br = _br; - } - - // examine all through the end, since some images might have very large APP segments - while (idx <= br.length()) { - marker = br.SHORT(idx += 2); - - if (marker >= 0xFFC0 && marker <= 0xFFC3) { // SOFn - idx += 5; // marker (2 bytes) + length (2 bytes) + Sample precision (1 byte) - return { - height: br.SHORT(idx), - width: br.SHORT(idx += 2) - }; - } - length = br.SHORT(idx += 2); - idx += length - 2; - } - return null; - } - - - function _getThumb() { - var data = _ep.thumb() - , br - , info - ; - - if (data) { - br = new BinaryReader(data); - info = _getDimensions(br); - br.clear(); - - if (info) { - info.data = data; - return info; - } - } - return null; - } - - - function _purge() { - if (!_ep || !_hm || !_br) { - return; // ignore any repeating purge requests - } - _ep.clear(); - _hm.purge(); - _br.clear(); - _info = _hm = _ep = _br = null; - } - } - - return JPEG; -}); - -// Included from: src/javascript/runtime/html5/image/PNG.js - -/** - * PNG.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/html5/image/PNG -@private -*/ -define("moxie/runtime/html5/image/PNG", [ - "moxie/core/Exceptions", - "moxie/core/utils/Basic", - "moxie/runtime/html5/utils/BinaryReader" -], function(x, Basic, BinaryReader) { - - function PNG(data) { - var _br, _hm, _ep, _info; - - _br = new BinaryReader(data); - - // check if it's png - (function() { - var idx = 0, i = 0 - , signature = [0x8950, 0x4E47, 0x0D0A, 0x1A0A] - ; - - for (i = 0; i < signature.length; i++, idx += 2) { - if (signature[i] != _br.SHORT(idx)) { - throw new x.ImageError(x.ImageError.WRONG_FORMAT); - } - } - }()); - - function _getDimensions() { - var chunk, idx; - - chunk = _getChunkAt.call(this, 8); - - if (chunk.type == 'IHDR') { - idx = chunk.start; - return { - width: _br.LONG(idx), - height: _br.LONG(idx += 4) - }; - } - return null; - } - - function _purge() { - if (!_br) { - return; // ignore any repeating purge requests - } - _br.clear(); - data = _info = _hm = _ep = _br = null; - } - - _info = _getDimensions.call(this); - - Basic.extend(this, { - type: 'image/png', - - size: _br.length(), - - width: _info.width, - - height: _info.height, - - purge: function() { - _purge.call(this); - } - }); - - // for PNG we can safely trigger purge automatically, as we do not keep any data for later - _purge.call(this); - - function _getChunkAt(idx) { - var length, type, start, CRC; - - length = _br.LONG(idx); - type = _br.STRING(idx += 4, 4); - start = idx += 4; - CRC = _br.LONG(idx + length); - - return { - length: length, - type: type, - start: start, - CRC: CRC - }; - } - } - - return PNG; -}); - -// Included from: src/javascript/runtime/html5/image/ImageInfo.js - -/** - * ImageInfo.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -Optional image investigation tool for HTML5 runtime. Provides the following features: -- ability to distinguish image type (JPEG or PNG) by signature -- ability to extract image width/height directly from it's internals, without preloading in memory (fast) -- ability to extract APP headers from JPEGs (Exif, GPS, etc) -- ability to replace width/height tags in extracted JPEG headers -- ability to restore APP headers, that were for example stripped during image manipulation - -@class moxie/runtime/html5/image/ImageInfo -@private -@param {String} data Image source as binary string -*/ -define("moxie/runtime/html5/image/ImageInfo", [ - "moxie/core/utils/Basic", - "moxie/core/Exceptions", - "moxie/runtime/html5/image/JPEG", - "moxie/runtime/html5/image/PNG" -], function(Basic, x, JPEG, PNG) { - - return function(data) { - var _cs = [JPEG, PNG], _img; - - // figure out the format, throw: ImageError.WRONG_FORMAT if not supported - _img = (function() { - for (var i = 0; i < _cs.length; i++) { - try { - return new _cs[i](data); - } catch (ex) { - // console.info(ex); - } - } - throw new x.ImageError(x.ImageError.WRONG_FORMAT); - }()); - - Basic.extend(this, { - /** - Image Mime Type extracted from it's depths - - @property type - @type {String} - @default '' - */ - type: '', - - /** - Image size in bytes - - @property size - @type {Number} - @default 0 - */ - size: 0, - - /** - Image width extracted from image source - - @property width - @type {Number} - @default 0 - */ - width: 0, - - /** - Image height extracted from image source - - @property height - @type {Number} - @default 0 - */ - height: 0, - - /** - Sets Exif tag. Currently applicable only for width and height tags. Obviously works only with JPEGs. - - @method setExif - @param {String} tag Tag to set - @param {Mixed} value Value to assign to the tag - */ - setExif: function() {}, - - /** - Restores headers to the source. - - @method writeHeaders - @param {String} data Image source as binary string - @return {String} Updated binary string - */ - writeHeaders: function(data) { - return data; - }, - - /** - Strip all headers from the source. - - @method stripHeaders - @param {String} data Image source as binary string - @return {String} Updated binary string - */ - stripHeaders: function(data) { - return data; - }, - - /** - Dispose resources. - - @method purge - */ - purge: function() { - data = null; - } - }); - - Basic.extend(this, _img); - - this.purge = function() { - _img.purge(); - _img = null; - }; - }; -}); - -// Included from: src/javascript/runtime/html5/image/ResizerCanvas.js - -/** - * ResizerCanvas.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** - * Resizes image/canvas using canvas - */ -define("moxie/runtime/html5/image/ResizerCanvas", [], function() { - - function scale(image, ratio, resample) { - var sD = image.width > image.height ? 'width' : 'height'; // take the largest side - var dD = Math.round(image[sD] * ratio); - var scaleCapped = false; - - if (resample !== 'nearest' && (ratio < 0.5 || ratio > 2)) { - ratio = ratio < 0.5 ? 0.5 : 2; - scaleCapped = true; - } - - var tCanvas = _scale(image, ratio); - - if (scaleCapped) { - return scale(tCanvas, dD / tCanvas[sD], resample); - } else { - return tCanvas; - } - } - - - function _scale(image, ratio) { - var sW = image.width; - var sH = image.height; - var dW = Math.round(sW * ratio); - var dH = Math.round(sH * ratio); - - var canvas = document.createElement('canvas'); - canvas.width = dW; - canvas.height = dH; - canvas.getContext("2d").drawImage(image, 0, 0, sW, sH, 0, 0, dW, dH); - - image = null; // just in case - return canvas; - } - - return { - scale: scale - }; - -}); - -// Included from: src/javascript/runtime/html5/image/Image.js - -/** - * Image.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/html5/image/Image -@private -*/ -define("moxie/runtime/html5/image/Image", [ - "moxie/runtime/html5/Runtime", - "moxie/core/utils/Basic", - "moxie/core/Exceptions", - "moxie/core/utils/Encode", - "moxie/file/Blob", - "moxie/file/File", - "moxie/runtime/html5/image/ImageInfo", - "moxie/runtime/html5/image/ResizerCanvas", - "moxie/core/utils/Mime", - "moxie/core/utils/Env" -], function(extensions, Basic, x, Encode, Blob, File, ImageInfo, ResizerCanvas, Mime, Env) { - - function HTML5Image() { - var me = this - , _img, _imgInfo, _canvas, _binStr, _blob - , _modified = false // is set true whenever image is modified - , _preserveHeaders = true - ; - - Basic.extend(this, { - loadFromBlob: function(blob) { - var I = this.getRuntime() - , asBinary = arguments.length > 1 ? arguments[1] : true - ; - - if (!I.can('access_binary')) { - throw new x.RuntimeError(x.RuntimeError.NOT_SUPPORTED_ERR); - } - - _blob = blob; - - if (blob.isDetached()) { - _binStr = blob.getSource(); - _preload.call(this, _binStr); - return; - } else { - _readAsDataUrl.call(this, blob.getSource(), function(dataUrl) { - if (asBinary) { - _binStr = _toBinary(dataUrl); - } - _preload.call(this, dataUrl); - }); - } - }, - - loadFromImage: function(img, exact) { - this.meta = img.meta; - - _blob = new File(null, { - name: img.name, - size: img.size, - type: img.type - }); - - _preload.call(this, exact ? (_binStr = img.getAsBinaryString()) : img.getAsDataURL()); - }, - - getInfo: function() { - var I = this.getRuntime(), info; - - if (!_imgInfo && _binStr && I.can('access_image_binary')) { - _imgInfo = new ImageInfo(_binStr); - } - - // this stuff below is definitely having fun with itself - info = { - width: _getImg().width || 0, - height: _getImg().height || 0, - type: _blob.type || Mime.getFileMime(_blob.name), - size: _binStr && _binStr.length || _blob.size || 0, - name: _blob.name || '', - meta: null - }; - - if (_preserveHeaders) { - info.meta = _imgInfo && _imgInfo.meta || this.meta || {}; - - // if data was taken from ImageInfo it will be a binary string, so we convert it to blob - if (info.meta && info.meta.thumb && !(info.meta.thumb.data instanceof Blob)) { - info.meta.thumb.data = new Blob(null, { - type: 'image/jpeg', - data: info.meta.thumb.data - }); - } - } - - return info; - }, - - - resize: function(rect, ratio, options) { - var canvas = document.createElement('canvas'); - canvas.width = rect.width; - canvas.height = rect.height; - - canvas.getContext("2d").drawImage(_getImg(), rect.x, rect.y, rect.width, rect.height, 0, 0, canvas.width, canvas.height); - - _canvas = ResizerCanvas.scale(canvas, ratio); - - _preserveHeaders = options.preserveHeaders; - - // rotate if required, according to orientation tag - if (!_preserveHeaders) { - var orientation = (this.meta && this.meta.tiff && this.meta.tiff.Orientation) || 1; - _canvas = _rotateToOrientaion(_canvas, orientation); - } - - this.width = _canvas.width; - this.height = _canvas.height; - - _modified = true; - - this.trigger('Resize'); - }, - - getAsCanvas: function() { - if (!_canvas) { - _canvas = _getCanvas(); - } - _canvas.id = this.uid + '_canvas'; - return _canvas; - }, - - getAsBlob: function(type, quality) { - if (type !== this.type) { - _modified = true; // reconsider the state - return new File(null, { - name: _blob.name || '', - type: type, - data: me.getAsDataURL(type, quality) - }); - } - return new File(null, { - name: _blob.name || '', - type: type, - data: me.getAsBinaryString(type, quality) - }); - }, - - getAsDataURL: function(type) { - var quality = arguments[1] || 90; - - // if image has not been modified, return the source right away - if (!_modified) { - return _img.src; - } - - // make sure we have a canvas to work with - _getCanvas(); - - if ('image/jpeg' !== type) { - return _canvas.toDataURL('image/png'); - } else { - try { - // older Geckos used to result in an exception on quality argument - return _canvas.toDataURL('image/jpeg', quality/100); - } catch (ex) { - return _canvas.toDataURL('image/jpeg'); - } - } - }, - - getAsBinaryString: function(type, quality) { - // if image has not been modified, return the source right away - if (!_modified) { - // if image was not loaded from binary string - if (!_binStr) { - _binStr = _toBinary(me.getAsDataURL(type, quality)); - } - return _binStr; - } - - if ('image/jpeg' !== type) { - _binStr = _toBinary(me.getAsDataURL(type, quality)); - } else { - var dataUrl; - - // if jpeg - if (!quality) { - quality = 90; - } - - // make sure we have a canvas to work with - _getCanvas(); - - try { - // older Geckos used to result in an exception on quality argument - dataUrl = _canvas.toDataURL('image/jpeg', quality/100); - } catch (ex) { - dataUrl = _canvas.toDataURL('image/jpeg'); - } - - _binStr = _toBinary(dataUrl); - - if (_imgInfo) { - _binStr = _imgInfo.stripHeaders(_binStr); - - if (_preserveHeaders) { - // update dimensions info in exif - if (_imgInfo.meta && _imgInfo.meta.exif) { - _imgInfo.setExif({ - PixelXDimension: this.width, - PixelYDimension: this.height - }); - } - - // re-inject the headers - _binStr = _imgInfo.writeHeaders(_binStr); - } - - // will be re-created from fresh on next getInfo call - _imgInfo.purge(); - _imgInfo = null; - } - } - - _modified = false; - - return _binStr; - }, - - destroy: function() { - me = null; - _purge.call(this); - this.getRuntime().getShim().removeInstance(this.uid); - } - }); - - - function _getImg() { - if (!_canvas && !_img) { - throw new x.ImageError(x.DOMException.INVALID_STATE_ERR); - } - return _canvas || _img; - } - - - function _getCanvas() { - var canvas = _getImg(); - if (canvas.nodeName.toLowerCase() == 'canvas') { - return canvas; - } - _canvas = document.createElement('canvas'); - _canvas.width = canvas.width; - _canvas.height = canvas.height; - _canvas.getContext("2d").drawImage(canvas, 0, 0); - return _canvas; - } - - - function _toBinary(str) { - return Encode.atob(str.substring(str.indexOf('base64,') + 7)); - } - - - function _toDataUrl(str, type) { - return 'data:' + (type || '') + ';base64,' + Encode.btoa(str); - } - - - function _preload(str) { - var comp = this; - - _img = new Image(); - _img.onerror = function() { - _purge.call(this); - comp.trigger('error', x.ImageError.WRONG_FORMAT); - }; - _img.onload = function() { - comp.trigger('load'); - }; - - _img.src = str.substr(0, 5) == 'data:' ? str : _toDataUrl(str, _blob.type); - } - - - function _readAsDataUrl(file, callback) { - var comp = this, fr; - - // use FileReader if it's available - if (window.FileReader) { - fr = new FileReader(); - fr.onload = function() { - callback.call(comp, this.result); - }; - fr.onerror = function() { - comp.trigger('error', x.ImageError.WRONG_FORMAT); - }; - fr.readAsDataURL(file); - } else { - return callback.call(this, file.getAsDataURL()); - } - } - - /** - * Transform canvas coordination according to specified frame size and orientation - * Orientation value is from EXIF tag - * @author Shinichi Tomita - */ - function _rotateToOrientaion(img, orientation) { - var RADIANS = Math.PI/180; - var canvas = document.createElement('canvas'); - var ctx = canvas.getContext('2d'); - var width = img.width; - var height = img.height; - - if (Basic.inArray(orientation, [5,6,7,8]) > -1) { - canvas.width = height; - canvas.height = width; - } else { - canvas.width = width; - canvas.height = height; - } - - /** - 1 = The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side. - 2 = The 0th row is at the visual top of the image, and the 0th column is the visual right-hand side. - 3 = The 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side. - 4 = The 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side. - 5 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual top. - 6 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual top. - 7 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom. - 8 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom. - */ - switch (orientation) { - case 2: - // horizontal flip - ctx.translate(width, 0); - ctx.scale(-1, 1); - break; - case 3: - // 180 rotate left - ctx.translate(width, height); - ctx.rotate(180 * RADIANS); - break; - case 4: - // vertical flip - ctx.translate(0, height); - ctx.scale(1, -1); - break; - case 5: - // vertical flip + 90 rotate right - ctx.rotate(90 * RADIANS); - ctx.scale(1, -1); - break; - case 6: - // 90 rotate right - ctx.rotate(90 * RADIANS); - ctx.translate(0, -height); - break; - case 7: - // horizontal flip + 90 rotate right - ctx.rotate(90 * RADIANS); - ctx.translate(width, -height); - ctx.scale(-1, 1); - break; - case 8: - // 90 rotate left - ctx.rotate(-90 * RADIANS); - ctx.translate(-width, 0); - break; - } - - ctx.drawImage(img, 0, 0, width, height); - return canvas; - } - - - function _purge() { - if (_imgInfo) { - _imgInfo.purge(); - _imgInfo = null; - } - - _binStr = _img = _canvas = _blob = null; - _modified = false; - } - } - - return (extensions.Image = HTML5Image); -}); - -// Included from: src/javascript/runtime/flash/Runtime.js - -/** - * Runtime.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/*global ActiveXObject:true */ - -/** -Defines constructor for Flash runtime. - -@class moxie/runtime/flash/Runtime -@private -*/ -define("moxie/runtime/flash/Runtime", [ - "moxie/core/utils/Basic", - "moxie/core/utils/Env", - "moxie/core/utils/Dom", - "moxie/core/Exceptions", - "moxie/runtime/Runtime" -], function(Basic, Env, Dom, x, Runtime) { - - var type = 'flash', extensions = {}; - - /** - Get the version of the Flash Player - - @method getShimVersion - @private - @return {Number} Flash Player version - */ - function getShimVersion() { - var version; - - try { - version = navigator.plugins['Shockwave Flash']; - version = version.description; - } catch (e1) { - try { - version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version'); - } catch (e2) { - version = '0.0'; - } - } - version = version.match(/\d+/g); - return parseFloat(version[0] + '.' + version[1]); - } - - - /** - Cross-browser SWF removal - - Especially needed to safely and completely remove a SWF in Internet Explorer - - Originated from SWFObject v2.2 - */ - function removeSWF(id) { - var obj = Dom.get(id); - if (obj && obj.nodeName == "OBJECT") { - if (Env.browser === 'IE') { - obj.style.display = "none"; - (function onInit(){ - // http://msdn.microsoft.com/en-us/library/ie/ms534360(v=vs.85).aspx - if (obj.readyState == 4) { - removeObjectInIE(id); - } - else { - setTimeout(onInit, 10); - } - })(); - } - else { - obj.parentNode.removeChild(obj); - } - } - } - - - function removeObjectInIE(id) { - var obj = Dom.get(id); - if (obj) { - for (var i in obj) { - if (typeof obj[i] == "function") { - obj[i] = null; - } - } - obj.parentNode.removeChild(obj); - } - } - - /** - Constructor for the Flash Runtime - */ - function FlashRuntime(options) { - var I = this, initTimer; - - options = Basic.extend({ swf_url: Env.swf_url }, options); - - Runtime.call(this, options, type, { - access_binary: function(value) { - return value && I.mode === 'browser'; - }, - access_image_binary: function(value) { - return value && I.mode === 'browser'; - }, - display_media: Runtime.capTest(defined('moxie/image/Image')), - do_cors: Runtime.capTrue, - drag_and_drop: false, - report_upload_progress: function() { - return I.mode === 'client'; - }, - resize_image: Runtime.capTrue, - return_response_headers: false, - return_response_type: function(responseType) { - if (responseType === 'json' && !!window.JSON) { - return true; - } - return !Basic.arrayDiff(responseType, ['', 'text', 'document']) || I.mode === 'browser'; - }, - return_status_code: function(code) { - return I.mode === 'browser' || !Basic.arrayDiff(code, [200, 404]); - }, - select_file: Runtime.capTrue, - select_multiple: Runtime.capTrue, - send_binary_string: function(value) { - return value && I.mode === 'browser'; - }, - send_browser_cookies: function(value) { - return value && I.mode === 'browser'; - }, - send_custom_headers: function(value) { - return value && I.mode === 'browser'; - }, - send_multipart: Runtime.capTrue, - slice_blob: function(value) { - return value && I.mode === 'browser'; - }, - stream_upload: function(value) { - return value && I.mode === 'browser'; - }, - summon_file_dialog: false, - upload_filesize: function(size) { - return Basic.parseSizeStr(size) <= 2097152 || I.mode === 'client'; - }, - use_http_method: function(methods) { - return !Basic.arrayDiff(methods, ['GET', 'POST']); - } - }, { - // capabilities that require specific mode - access_binary: function(value) { - return value ? 'browser' : 'client'; - }, - access_image_binary: function(value) { - return value ? 'browser' : 'client'; - }, - report_upload_progress: function(value) { - return value ? 'browser' : 'client'; - }, - return_response_type: function(responseType) { - return Basic.arrayDiff(responseType, ['', 'text', 'json', 'document']) ? 'browser' : ['client', 'browser']; - }, - return_status_code: function(code) { - return Basic.arrayDiff(code, [200, 404]) ? 'browser' : ['client', 'browser']; - }, - send_binary_string: function(value) { - return value ? 'browser' : 'client'; - }, - send_browser_cookies: function(value) { - return value ? 'browser' : 'client'; - }, - send_custom_headers: function(value) { - return value ? 'browser' : 'client'; - }, - slice_blob: function(value) { - return value ? 'browser' : 'client'; - }, - stream_upload: function(value) { - return value ? 'client' : 'browser'; - }, - upload_filesize: function(size) { - return Basic.parseSizeStr(size) >= 2097152 ? 'client' : 'browser'; - } - }, 'client'); - - - // minimal requirement for Flash Player version - if (getShimVersion() < 11.3) { - if (MXI_DEBUG && Env.debug.runtime) { - Env.log("\tFlash didn't meet minimal version requirement (11.3)."); - } - - this.mode = false; // with falsy mode, runtime won't operable, no matter what the mode was before - } - - - Basic.extend(this, { - - getShim: function() { - return Dom.get(this.uid); - }, - - shimExec: function(component, action) { - var args = [].slice.call(arguments, 2); - return I.getShim().exec(this.uid, component, action, args); - }, - - init: function() { - var html, el, container; - - container = this.getShimContainer(); - - // if not the minimal height, shims are not initialized in older browsers (e.g FF3.6, IE6,7,8, Safari 4.0,5.0, etc) - Basic.extend(container.style, { - position: 'absolute', - top: '-8px', - left: '-8px', - width: '9px', - height: '9px', - overflow: 'hidden' - }); - - // insert flash object - html = '' + - '' + - '' + - '' + - ''; - - if (Env.browser === 'IE') { - el = document.createElement('div'); - container.appendChild(el); - el.outerHTML = html; - el = container = null; // just in case - } else { - container.innerHTML = html; - } - - // Init is dispatched by the shim - initTimer = setTimeout(function() { - if (I && !I.initialized) { // runtime might be already destroyed by this moment - I.trigger("Error", new x.RuntimeError(x.RuntimeError.NOT_INIT_ERR)); - - if (MXI_DEBUG && Env.debug.runtime) { - Env.log("\tFlash failed to initialize within a specified period of time (typically 5s)."); - } - } - }, 5000); - }, - - destroy: (function(destroy) { // extend default destroy method - return function() { - removeSWF(I.uid); // SWF removal requires special care in IE - - destroy.call(I); - clearTimeout(initTimer); // initialization check might be still onwait - options = initTimer = destroy = I = null; - }; - }(this.destroy)) - - }, extensions); - } - - Runtime.addConstructor(type, FlashRuntime); - - return extensions; -}); - -// Included from: src/javascript/runtime/flash/file/Blob.js - -/** - * Blob.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/flash/file/Blob -@private -*/ -define("moxie/runtime/flash/file/Blob", [ - "moxie/runtime/flash/Runtime", - "moxie/file/Blob" -], function(extensions, Blob) { - - var FlashBlob = { - slice: function(blob, start, end, type) { - var self = this.getRuntime(); - - if (start < 0) { - start = Math.max(blob.size + start, 0); - } else if (start > 0) { - start = Math.min(start, blob.size); - } - - if (end < 0) { - end = Math.max(blob.size + end, 0); - } else if (end > 0) { - end = Math.min(end, blob.size); - } - - blob = self.shimExec.call(this, 'Blob', 'slice', start, end, type || ''); - - if (blob) { - blob = new Blob(self.uid, blob); - } - return blob; - } - }; - - return (extensions.Blob = FlashBlob); -}); - -// Included from: src/javascript/runtime/flash/file/FileInput.js - -/** - * FileInput.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/flash/file/FileInput -@private -*/ -define("moxie/runtime/flash/file/FileInput", [ - "moxie/runtime/flash/Runtime", - "moxie/file/File", - "moxie/core/utils/Dom", - "moxie/core/utils/Basic" -], function(extensions, File, Dom, Basic) { - - var FileInput = { - init: function(options) { - var comp = this, I = this.getRuntime(); - var browseButton = Dom.get(options.browse_button); - - if (browseButton) { - browseButton.setAttribute('tabindex', -1); - browseButton = null; - } - - this.bind("Change", function() { - var files = I.shimExec.call(comp, 'FileInput', 'getFiles'); - comp.files = []; - Basic.each(files, function(file) { - comp.files.push(new File(I.uid, file)); - }); - }, 999); - - this.getRuntime().shimExec.call(this, 'FileInput', 'init', { - accept: options.accept, - multiple: options.multiple - }); - - this.trigger('ready'); - } - }; - - return (extensions.FileInput = FileInput); -}); - -// Included from: src/javascript/runtime/flash/file/FileReader.js - -/** - * FileReader.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/flash/file/FileReader -@private -*/ -define("moxie/runtime/flash/file/FileReader", [ - "moxie/runtime/flash/Runtime", - "moxie/core/utils/Encode" -], function(extensions, Encode) { - - function _formatData(data, op) { - switch (op) { - case 'readAsText': - return Encode.atob(data, 'utf8'); - case 'readAsBinaryString': - return Encode.atob(data); - case 'readAsDataURL': - return data; - } - return null; - } - - var FileReader = { - read: function(op, blob) { - var comp = this; - - comp.result = ''; - - // special prefix for DataURL read mode - if (op === 'readAsDataURL') { - comp.result = 'data:' + (blob.type || '') + ';base64,'; - } - - comp.bind('Progress', function(e, data) { - if (data) { - comp.result += _formatData(data, op); - } - }, 999); - - return comp.getRuntime().shimExec.call(this, 'FileReader', 'readAsBase64', blob.uid); - } - }; - - return (extensions.FileReader = FileReader); -}); - -// Included from: src/javascript/runtime/flash/file/FileReaderSync.js - -/** - * FileReaderSync.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/flash/file/FileReaderSync -@private -*/ -define("moxie/runtime/flash/file/FileReaderSync", [ - "moxie/runtime/flash/Runtime", - "moxie/core/utils/Encode" -], function(extensions, Encode) { - - function _formatData(data, op) { - switch (op) { - case 'readAsText': - return Encode.atob(data, 'utf8'); - case 'readAsBinaryString': - return Encode.atob(data); - case 'readAsDataURL': - return data; - } - return null; - } - - var FileReaderSync = { - read: function(op, blob) { - var result, self = this.getRuntime(); - - result = self.shimExec.call(this, 'FileReaderSync', 'readAsBase64', blob.uid); - if (!result) { - return null; // or throw ex - } - - // special prefix for DataURL read mode - if (op === 'readAsDataURL') { - result = 'data:' + (blob.type || '') + ';base64,' + result; - } - - return _formatData(result, op, blob.type); - } - }; - - return (extensions.FileReaderSync = FileReaderSync); -}); - -// Included from: src/javascript/runtime/flash/runtime/Transporter.js - -/** - * Transporter.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/flash/runtime/Transporter -@private -*/ -define("moxie/runtime/flash/runtime/Transporter", [ - "moxie/runtime/flash/Runtime", - "moxie/file/Blob" -], function(extensions, Blob) { - - var Transporter = { - getAsBlob: function(type) { - var self = this.getRuntime() - , blob = self.shimExec.call(this, 'Transporter', 'getAsBlob', type) - ; - if (blob) { - return new Blob(self.uid, blob); - } - return null; - } - }; - - return (extensions.Transporter = Transporter); -}); - -// Included from: src/javascript/runtime/flash/xhr/XMLHttpRequest.js - -/** - * XMLHttpRequest.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/flash/xhr/XMLHttpRequest -@private -*/ -define("moxie/runtime/flash/xhr/XMLHttpRequest", [ - "moxie/runtime/flash/Runtime", - "moxie/core/utils/Basic", - "moxie/file/Blob", - "moxie/file/File", - "moxie/file/FileReaderSync", - "moxie/runtime/flash/file/FileReaderSync", - "moxie/xhr/FormData", - "moxie/runtime/Transporter", - "moxie/runtime/flash/runtime/Transporter" -], function(extensions, Basic, Blob, File, FileReaderSync, FileReaderSyncFlash, FormData, Transporter, TransporterFlash) { - - var XMLHttpRequest = { - - send: function(meta, data) { - var target = this, self = target.getRuntime(); - - function send() { - meta.transport = self.mode; - self.shimExec.call(target, 'XMLHttpRequest', 'send', meta, data); - } - - - function appendBlob(name, blob) { - self.shimExec.call(target, 'XMLHttpRequest', 'appendBlob', name, blob.uid); - data = null; - send(); - } - - - function attachBlob(blob, cb) { - var tr = new Transporter(); - - tr.bind("TransportingComplete", function() { - cb(this.result); - }); - - tr.transport(blob.getSource(), blob.type, { - ruid: self.uid - }); - } - - // copy over the headers if any - if (!Basic.isEmptyObj(meta.headers)) { - Basic.each(meta.headers, function(value, header) { - self.shimExec.call(target, 'XMLHttpRequest', 'setRequestHeader', header, value.toString()); // Silverlight doesn't accept integers into the arguments of type object - }); - } - - // transfer over multipart params and blob itself - if (data instanceof FormData) { - var blobField; - data.each(function(value, name) { - if (value instanceof Blob) { - blobField = name; - } else { - self.shimExec.call(target, 'XMLHttpRequest', 'append', name, value); - } - }); - - if (!data.hasBlob()) { - data = null; - send(); - } else { - var blob = data.getBlob(); - if (blob.isDetached()) { - attachBlob(blob, function(attachedBlob) { - blob.destroy(); - appendBlob(blobField, attachedBlob); - }); - } else { - appendBlob(blobField, blob); - } - } - } else if (data instanceof Blob) { - if (data.isDetached()) { - attachBlob(data, function(attachedBlob) { - data.destroy(); - data = attachedBlob.uid; - send(); - }); - } else { - data = data.uid; - send(); - } - } else { - send(); - } - }, - - getResponse: function(responseType) { - var frs, blob, self = this.getRuntime(); - - blob = self.shimExec.call(this, 'XMLHttpRequest', 'getResponseAsBlob'); - - if (blob) { - blob = new File(self.uid, blob); - - if ('blob' === responseType) { - return blob; - } - - try { - frs = new FileReaderSync(); - - if (!!~Basic.inArray(responseType, ["", "text"])) { - return frs.readAsText(blob); - } else if ('json' === responseType && !!window.JSON) { - return JSON.parse(frs.readAsText(blob)); - } - } finally { - blob.destroy(); - } - } - return null; - }, - - abort: function(upload_complete_flag) { - var self = this.getRuntime(); - - self.shimExec.call(this, 'XMLHttpRequest', 'abort'); - - this.dispatchEvent('readystatechange'); - // this.dispatchEvent('progress'); - this.dispatchEvent('abort'); - - //if (!upload_complete_flag) { - // this.dispatchEvent('uploadprogress'); - //} - } - }; - - return (extensions.XMLHttpRequest = XMLHttpRequest); -}); - -// Included from: src/javascript/runtime/flash/image/Image.js - -/** - * Image.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/flash/image/Image -@private -*/ -define("moxie/runtime/flash/image/Image", [ - "moxie/runtime/flash/Runtime", - "moxie/core/utils/Basic", - "moxie/runtime/Transporter", - "moxie/file/Blob", - "moxie/file/FileReaderSync" -], function(extensions, Basic, Transporter, Blob, FileReaderSync) { - - var Image = { - loadFromBlob: function(blob) { - var comp = this, self = comp.getRuntime(); - - function exec(srcBlob) { - self.shimExec.call(comp, 'Image', 'loadFromBlob', srcBlob.uid); - comp = self = null; - } - - if (blob.isDetached()) { // binary string - var tr = new Transporter(); - tr.bind("TransportingComplete", function() { - exec(tr.result.getSource()); - }); - tr.transport(blob.getSource(), blob.type, { ruid: self.uid }); - } else { - exec(blob.getSource()); - } - }, - - loadFromImage: function(img) { - var self = this.getRuntime(); - return self.shimExec.call(this, 'Image', 'loadFromImage', img.uid); - }, - - getInfo: function() { - var self = this.getRuntime() - , info = self.shimExec.call(this, 'Image', 'getInfo') - ; - - if (info.meta && info.meta.thumb && info.meta.thumb.data && !(self.meta.thumb.data instanceof Blob)) { - info.meta.thumb.data = new Blob(self.uid, info.meta.thumb.data); - } - return info; - }, - - getAsBlob: function(type, quality) { - var self = this.getRuntime() - , blob = self.shimExec.call(this, 'Image', 'getAsBlob', type, quality) - ; - if (blob) { - return new Blob(self.uid, blob); - } - return null; - }, - - getAsDataURL: function() { - var self = this.getRuntime() - , blob = self.Image.getAsBlob.apply(this, arguments) - , frs - ; - if (!blob) { - return null; - } - frs = new FileReaderSync(); - return frs.readAsDataURL(blob); - } - }; - - return (extensions.Image = Image); -}); - -// Included from: src/javascript/runtime/silverlight/Runtime.js - -/** - * RunTime.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/*global ActiveXObject:true */ - -/** -Defines constructor for Silverlight runtime. - -@class moxie/runtime/silverlight/Runtime -@private -*/ -define("moxie/runtime/silverlight/Runtime", [ - "moxie/core/utils/Basic", - "moxie/core/utils/Env", - "moxie/core/utils/Dom", - "moxie/core/Exceptions", - "moxie/runtime/Runtime" -], function(Basic, Env, Dom, x, Runtime) { - - var type = "silverlight", extensions = {}; - - function isInstalled(version) { - var isVersionSupported = false, control = null, actualVer, - actualVerArray, reqVerArray, requiredVersionPart, actualVersionPart, index = 0; - - try { - try { - control = new ActiveXObject('AgControl.AgControl'); - - if (control.IsVersionSupported(version)) { - isVersionSupported = true; - } - - control = null; - } catch (e) { - var plugin = navigator.plugins["Silverlight Plug-In"]; - - if (plugin) { - actualVer = plugin.description; - - if (actualVer === "1.0.30226.2") { - actualVer = "2.0.30226.2"; - } - - actualVerArray = actualVer.split("."); - - while (actualVerArray.length > 3) { - actualVerArray.pop(); - } - - while ( actualVerArray.length < 4) { - actualVerArray.push(0); - } - - reqVerArray = version.split("."); - - while (reqVerArray.length > 4) { - reqVerArray.pop(); - } - - do { - requiredVersionPart = parseInt(reqVerArray[index], 10); - actualVersionPart = parseInt(actualVerArray[index], 10); - index++; - } while (index < reqVerArray.length && requiredVersionPart === actualVersionPart); - - if (requiredVersionPart <= actualVersionPart && !isNaN(requiredVersionPart)) { - isVersionSupported = true; - } - } - } - } catch (e2) { - isVersionSupported = false; - } - - return isVersionSupported; - } - - /** - Constructor for the Silverlight Runtime - */ - function SilverlightRuntime(options) { - var I = this, initTimer; - - options = Basic.extend({ xap_url: Env.xap_url }, options); - - Runtime.call(this, options, type, { - access_binary: Runtime.capTrue, - access_image_binary: Runtime.capTrue, - display_media: Runtime.capTest(defined('moxie/image/Image')), - do_cors: Runtime.capTrue, - drag_and_drop: false, - report_upload_progress: Runtime.capTrue, - resize_image: Runtime.capTrue, - return_response_headers: function(value) { - return value && I.mode === 'client'; - }, - return_response_type: function(responseType) { - if (responseType !== 'json') { - return true; - } else { - return !!window.JSON; - } - }, - return_status_code: function(code) { - return I.mode === 'client' || !Basic.arrayDiff(code, [200, 404]); - }, - select_file: Runtime.capTrue, - select_multiple: Runtime.capTrue, - send_binary_string: Runtime.capTrue, - send_browser_cookies: function(value) { - return value && I.mode === 'browser'; - }, - send_custom_headers: function(value) { - return value && I.mode === 'client'; - }, - send_multipart: Runtime.capTrue, - slice_blob: Runtime.capTrue, - stream_upload: true, - summon_file_dialog: false, - upload_filesize: Runtime.capTrue, - use_http_method: function(methods) { - return I.mode === 'client' || !Basic.arrayDiff(methods, ['GET', 'POST']); - } - }, { - // capabilities that require specific mode - return_response_headers: function(value) { - return value ? 'client' : 'browser'; - }, - return_status_code: function(code) { - return Basic.arrayDiff(code, [200, 404]) ? 'client' : ['client', 'browser']; - }, - send_browser_cookies: function(value) { - return value ? 'browser' : 'client'; - }, - send_custom_headers: function(value) { - return value ? 'client' : 'browser'; - }, - use_http_method: function(methods) { - return Basic.arrayDiff(methods, ['GET', 'POST']) ? 'client' : ['client', 'browser']; - } - }); - - - // minimal requirement - if (!isInstalled('2.0.31005.0') || Env.browser === 'Opera') { - if (MXI_DEBUG && Env.debug.runtime) { - Env.log("\tSilverlight is not installed or minimal version (2.0.31005.0) requirement not met (not likely)."); - } - - this.mode = false; - } - - - Basic.extend(this, { - getShim: function() { - return Dom.get(this.uid).content.Moxie; - }, - - shimExec: function(component, action) { - var args = [].slice.call(arguments, 2); - return I.getShim().exec(this.uid, component, action, args); - }, - - init : function() { - var container; - - container = this.getShimContainer(); - - container.innerHTML = '' + - '' + - '' + - '' + - '' + - '' + - ''; - - // Init is dispatched by the shim - initTimer = setTimeout(function() { - if (I && !I.initialized) { // runtime might be already destroyed by this moment - I.trigger("Error", new x.RuntimeError(x.RuntimeError.NOT_INIT_ERR)); - - if (MXI_DEBUG && Env.debug.runtime) { - Env.log("\Silverlight failed to initialize within a specified period of time (5-10s)."); - } - } - }, Env.OS !== 'Windows'? 10000 : 5000); // give it more time to initialize in non Windows OS (like Mac) - }, - - destroy: (function(destroy) { // extend default destroy method - return function() { - destroy.call(I); - clearTimeout(initTimer); // initialization check might be still onwait - options = initTimer = destroy = I = null; - }; - }(this.destroy)) - - }, extensions); - } - - Runtime.addConstructor(type, SilverlightRuntime); - - return extensions; -}); - -// Included from: src/javascript/runtime/silverlight/file/Blob.js - -/** - * Blob.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/silverlight/file/Blob -@private -*/ -define("moxie/runtime/silverlight/file/Blob", [ - "moxie/runtime/silverlight/Runtime", - "moxie/core/utils/Basic", - "moxie/runtime/flash/file/Blob" -], function(extensions, Basic, Blob) { - return (extensions.Blob = Basic.extend({}, Blob)); -}); - -// Included from: src/javascript/runtime/silverlight/file/FileInput.js - -/** - * FileInput.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/silverlight/file/FileInput -@private -*/ -define("moxie/runtime/silverlight/file/FileInput", [ - "moxie/runtime/silverlight/Runtime", - "moxie/file/File", - "moxie/core/utils/Dom", - "moxie/core/utils/Basic" -], function(extensions, File, Dom, Basic) { - - function toFilters(accept) { - var filter = ''; - for (var i = 0; i < accept.length; i++) { - filter += (filter !== '' ? '|' : '') + accept[i].title + " | *." + accept[i].extensions.replace(/,/g, ';*.'); - } - return filter; - } - - - var FileInput = { - init: function(options) { - var comp = this, I = this.getRuntime(); - var browseButton = Dom.get(options.browse_button); - - if (browseButton) { - browseButton.setAttribute('tabindex', -1); - browseButton = null; - } - - this.bind("Change", function() { - var files = I.shimExec.call(comp, 'FileInput', 'getFiles'); - comp.files = []; - Basic.each(files, function(file) { - comp.files.push(new File(I.uid, file)); - }); - }, 999); - - I.shimExec.call(this, 'FileInput', 'init', toFilters(options.accept), options.multiple); - this.trigger('ready'); - }, - - setOption: function(name, value) { - if (name == 'accept') { - value = toFilters(value); - } - this.getRuntime().shimExec.call(this, 'FileInput', 'setOption', name, value); - } - }; - - return (extensions.FileInput = FileInput); -}); - -// Included from: src/javascript/runtime/silverlight/file/FileDrop.js - -/** - * FileDrop.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/silverlight/file/FileDrop -@private -*/ -define("moxie/runtime/silverlight/file/FileDrop", [ - "moxie/runtime/silverlight/Runtime", - "moxie/core/utils/Dom", - "moxie/core/utils/Events" -], function(extensions, Dom, Events) { - - // not exactly useful, since works only in safari (...crickets...) - var FileDrop = { - init: function() { - var comp = this, self = comp.getRuntime(), dropZone; - - dropZone = self.getShimContainer(); - - Events.addEvent(dropZone, 'dragover', function(e) { - e.preventDefault(); - e.stopPropagation(); - e.dataTransfer.dropEffect = 'copy'; - }, comp.uid); - - Events.addEvent(dropZone, 'dragenter', function(e) { - e.preventDefault(); - var flag = Dom.get(self.uid).dragEnter(e); - // If handled, then stop propagation of event in DOM - if (flag) { - e.stopPropagation(); - } - }, comp.uid); - - Events.addEvent(dropZone, 'drop', function(e) { - e.preventDefault(); - var flag = Dom.get(self.uid).dragDrop(e); - // If handled, then stop propagation of event in DOM - if (flag) { - e.stopPropagation(); - } - }, comp.uid); - - return self.shimExec.call(this, 'FileDrop', 'init'); - } - }; - - return (extensions.FileDrop = FileDrop); -}); - -// Included from: src/javascript/runtime/silverlight/file/FileReader.js - -/** - * FileReader.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/silverlight/file/FileReader -@private -*/ -define("moxie/runtime/silverlight/file/FileReader", [ - "moxie/runtime/silverlight/Runtime", - "moxie/core/utils/Basic", - "moxie/runtime/flash/file/FileReader" -], function(extensions, Basic, FileReader) { - return (extensions.FileReader = Basic.extend({}, FileReader)); -}); - -// Included from: src/javascript/runtime/silverlight/file/FileReaderSync.js - -/** - * FileReaderSync.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/silverlight/file/FileReaderSync -@private -*/ -define("moxie/runtime/silverlight/file/FileReaderSync", [ - "moxie/runtime/silverlight/Runtime", - "moxie/core/utils/Basic", - "moxie/runtime/flash/file/FileReaderSync" -], function(extensions, Basic, FileReaderSync) { - return (extensions.FileReaderSync = Basic.extend({}, FileReaderSync)); -}); - -// Included from: src/javascript/runtime/silverlight/runtime/Transporter.js - -/** - * Transporter.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/silverlight/runtime/Transporter -@private -*/ -define("moxie/runtime/silverlight/runtime/Transporter", [ - "moxie/runtime/silverlight/Runtime", - "moxie/core/utils/Basic", - "moxie/runtime/flash/runtime/Transporter" -], function(extensions, Basic, Transporter) { - return (extensions.Transporter = Basic.extend({}, Transporter)); -}); - -// Included from: src/javascript/runtime/silverlight/xhr/XMLHttpRequest.js - -/** - * XMLHttpRequest.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/silverlight/xhr/XMLHttpRequest -@private -*/ -define("moxie/runtime/silverlight/xhr/XMLHttpRequest", [ - "moxie/runtime/silverlight/Runtime", - "moxie/core/utils/Basic", - "moxie/runtime/flash/xhr/XMLHttpRequest", - "moxie/runtime/silverlight/file/FileReaderSync", - "moxie/runtime/silverlight/runtime/Transporter" -], function(extensions, Basic, XMLHttpRequest, FileReaderSyncSilverlight, TransporterSilverlight) { - return (extensions.XMLHttpRequest = Basic.extend({}, XMLHttpRequest)); -}); - -// Included from: src/javascript/runtime/silverlight/image/Image.js - -/** - * Image.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/silverlight/image/Image -@private -*/ -define("moxie/runtime/silverlight/image/Image", [ - "moxie/runtime/silverlight/Runtime", - "moxie/core/utils/Basic", - "moxie/file/Blob", - "moxie/runtime/flash/image/Image" -], function(extensions, Basic, Blob, Image) { - return (extensions.Image = Basic.extend({}, Image, { - - getInfo: function() { - var self = this.getRuntime() - , grps = ['tiff', 'exif', 'gps', 'thumb'] - , info = { meta: {} } - , rawInfo = self.shimExec.call(this, 'Image', 'getInfo') - ; - - if (rawInfo.meta) { - Basic.each(grps, function(grp) { - var meta = rawInfo.meta[grp] - , tag - , i - , length - , value - ; - if (meta && meta.keys) { - info.meta[grp] = {}; - for (i = 0, length = meta.keys.length; i < length; i++) { - tag = meta.keys[i]; - value = meta[tag]; - if (value) { - // convert numbers - if (/^(\d|[1-9]\d+)$/.test(value)) { // integer (make sure doesn't start with zero) - value = parseInt(value, 10); - } else if (/^\d*\.\d+$/.test(value)) { // double - value = parseFloat(value); - } - info.meta[grp][tag] = value; - } - } - } - }); - - // save thumb data as blob - if (info.meta && info.meta.thumb && info.meta.thumb.data && !(self.meta.thumb.data instanceof Blob)) { - info.meta.thumb.data = new Blob(self.uid, info.meta.thumb.data); - } - } - - info.width = parseInt(rawInfo.width, 10); - info.height = parseInt(rawInfo.height, 10); - info.size = parseInt(rawInfo.size, 10); - info.type = rawInfo.type; - info.name = rawInfo.name; - - return info; - }, - - resize: function(rect, ratio, opts) { - this.getRuntime().shimExec.call(this, 'Image', 'resize', rect.x, rect.y, rect.width, rect.height, ratio, opts.preserveHeaders, opts.resample); - } - })); -}); - -// Included from: src/javascript/runtime/html4/Runtime.js - -/** - * Runtime.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/*global File:true */ - -/** -Defines constructor for HTML4 runtime. - -@class moxie/runtime/html4/Runtime -@private -*/ -define("moxie/runtime/html4/Runtime", [ - "moxie/core/utils/Basic", - "moxie/core/Exceptions", - "moxie/runtime/Runtime", - "moxie/core/utils/Env" -], function(Basic, x, Runtime, Env) { - - var type = 'html4', extensions = {}; - - function Html4Runtime(options) { - var I = this - , Test = Runtime.capTest - , True = Runtime.capTrue - ; - - Runtime.call(this, options, type, { - access_binary: Test(window.FileReader || window.File && File.getAsDataURL), - access_image_binary: false, - display_media: Test( - (Env.can('create_canvas') || Env.can('use_data_uri_over32kb')) && - defined('moxie/image/Image') - ), - do_cors: false, - drag_and_drop: false, - filter_by_extension: Test(function() { // if you know how to feature-detect this, please suggest - return !( - (Env.browser === 'Chrome' && Env.verComp(Env.version, 28, '<')) || - (Env.browser === 'IE' && Env.verComp(Env.version, 10, '<')) || - (Env.browser === 'Safari' && Env.verComp(Env.version, 11, '<=')) || - (Env.browser === 'Firefox' && Env.verComp(Env.version, 37, '<')) || - Env.os === 'iOS' || // as of iOS11, no extensions are supported in accept attribute - Env.os === 'Android' - ); - }()), - resize_image: function() { - return extensions.Image && I.can('access_binary') && Env.can('create_canvas'); - }, - report_upload_progress: false, - return_response_headers: false, - return_response_type: function(responseType) { - if (responseType === 'json' && !!window.JSON) { - return true; - } - return !!~Basic.inArray(responseType, ['text', 'document', '']); - }, - return_status_code: function(code) { - return !Basic.arrayDiff(code, [200, 404]); - }, - select_file: function() { - return Env.can('use_fileinput'); - }, - select_multiple: false, - send_binary_string: false, - send_custom_headers: false, - send_multipart: true, - slice_blob: false, - stream_upload: function() { - return I.can('select_file'); - }, - summon_file_dialog: function() { // yeah... some dirty sniffing here... - return I.can('select_file') && !( - (Env.browser === 'Firefox' && Env.verComp(Env.version, 4, '<')) || - (Env.browser === 'Opera' && Env.verComp(Env.version, 12, '<')) || - (Env.browser === 'IE' && Env.verComp(Env.version, 10, '<')) - ); - }, - upload_filesize: True, - use_http_method: function(methods) { - return !Basic.arrayDiff(methods, ['GET', 'POST']); - } - }); - - - Basic.extend(this, { - init : function() { - this.trigger("Init"); - }, - - destroy: (function(destroy) { // extend default destroy method - return function() { - destroy.call(I); - destroy = I = null; - }; - }(this.destroy)) - }); - - Basic.extend(this.getShim(), extensions); - } - - Runtime.addConstructor(type, Html4Runtime); - - return extensions; -}); - -// Included from: src/javascript/runtime/html4/file/FileInput.js - -/** - * FileInput.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/html4/file/FileInput -@private -*/ -define("moxie/runtime/html4/file/FileInput", [ - "moxie/runtime/html4/Runtime", - "moxie/file/File", - "moxie/core/utils/Basic", - "moxie/core/utils/Dom", - "moxie/core/utils/Events", - "moxie/core/utils/Mime", - "moxie/core/utils/Env" -], function(extensions, File, Basic, Dom, Events, Mime, Env) { - - function FileInput() { - var _uid, _mimes = [], _options, _browseBtnZIndex; // save original z-index; - - function addInput() { - var comp = this, I = comp.getRuntime(), shimContainer, browseButton, currForm, form, input, uid; - - uid = Basic.guid('uid_'); - - shimContainer = I.getShimContainer(); // we get new ref every time to avoid memory leaks in IE - - if (_uid) { // move previous form out of the view - currForm = Dom.get(_uid + '_form'); - if (currForm) { - Basic.extend(currForm.style, { top: '100%' }); - // it shouldn't be possible to tab into the hidden element - currForm.firstChild.setAttribute('tabindex', -1); - } - } - - // build form in DOM, since innerHTML version not able to submit file for some reason - form = document.createElement('form'); - form.setAttribute('id', uid + '_form'); - form.setAttribute('method', 'post'); - form.setAttribute('enctype', 'multipart/form-data'); - form.setAttribute('encoding', 'multipart/form-data'); - - Basic.extend(form.style, { - overflow: 'hidden', - position: 'absolute', - top: 0, - left: 0, - width: '100%', - height: '100%' - }); - - input = document.createElement('input'); - input.setAttribute('id', uid); - input.setAttribute('type', 'file'); - input.setAttribute('accept', _mimes.join(',')); - - if (I.can('summon_file_dialog')) { - input.setAttribute('tabindex', -1); - } - - Basic.extend(input.style, { - fontSize: '999px', - opacity: 0 - }); - - form.appendChild(input); - shimContainer.appendChild(form); - - // prepare file input to be placed underneath the browse_button element - Basic.extend(input.style, { - position: 'absolute', - top: 0, - left: 0, - width: '100%', - height: '100%' - }); - - if (Env.browser === 'IE' && Env.verComp(Env.version, 10, '<')) { - Basic.extend(input.style, { - filter : "progid:DXImageTransform.Microsoft.Alpha(opacity=0)" - }); - } - - input.onchange = function() { // there should be only one handler for this - var file; - - if (!this.value) { - return; - } - - if (this.files) { // check if browser is fresh enough - file = this.files[0]; - } else { - file = { - name: this.value - }; - } - - file = new File(I.uid, file); - - // clear event handler - this.onchange = function() {}; - addInput.call(comp); - - comp.files = [file]; - - // substitute all ids with file uids (consider file.uid read-only - we cannot do it the other way around) - input.setAttribute('id', file.uid); - form.setAttribute('id', file.uid + '_form'); - - comp.trigger('change'); - - input = form = null; - }; - - - // route click event to the input - if (I.can('summon_file_dialog')) { - browseButton = Dom.get(_options.browse_button); - Events.removeEvent(browseButton, 'click', comp.uid); - Events.addEvent(browseButton, 'click', function(e) { - if (input && !input.disabled) { // for some reason FF (up to 8.0.1 so far) lets to click disabled input[type=file] - input.click(); - } - e.preventDefault(); - }, comp.uid); - } - - _uid = uid; - - shimContainer = currForm = browseButton = null; - } - - Basic.extend(this, { - init: function(options) { - var comp = this, I = comp.getRuntime(), shimContainer; - - // figure out accept string - _options = options; - _mimes = Mime.extList2mimes(options.accept, I.can('filter_by_extension')); - - shimContainer = I.getShimContainer(); - - (function() { - var browseButton, zIndex, top; - - browseButton = Dom.get(options.browse_button); - _browseBtnZIndex = Dom.getStyle(browseButton, 'z-index') || 'auto'; - - // Route click event to the input[type=file] element for browsers that support such behavior - if (I.can('summon_file_dialog')) { - if (Dom.getStyle(browseButton, 'position') === 'static') { - browseButton.style.position = 'relative'; - } - - comp.bind('Refresh', function() { - zIndex = parseInt(_browseBtnZIndex, 10) || 1; - - Dom.get(_options.browse_button).style.zIndex = zIndex; - this.getRuntime().getShimContainer().style.zIndex = zIndex - 1; - }); - } else { - // it shouldn't be possible to tab into the hidden element - browseButton.setAttribute('tabindex', -1); - } - - /* Since we have to place input[type=file] on top of the browse_button for some browsers, - browse_button loses interactivity, so we restore it here */ - top = I.can('summon_file_dialog') ? browseButton : shimContainer; - - Events.addEvent(top, 'mouseover', function() { - comp.trigger('mouseenter'); - }, comp.uid); - - Events.addEvent(top, 'mouseout', function() { - comp.trigger('mouseleave'); - }, comp.uid); - - Events.addEvent(top, 'mousedown', function() { - comp.trigger('mousedown'); - }, comp.uid); - - Events.addEvent(Dom.get(options.container), 'mouseup', function() { - comp.trigger('mouseup'); - }, comp.uid); - - browseButton = null; - }()); - - addInput.call(this); - - shimContainer = null; - - // trigger ready event asynchronously - comp.trigger({ - type: 'ready', - async: true - }); - }, - - setOption: function(name, value) { - var I = this.getRuntime(); - var input; - - if (name == 'accept') { - _mimes = value.mimes || Mime.extList2mimes(value, I.can('filter_by_extension')); - } - - // update current input - input = Dom.get(_uid) - if (input) { - input.setAttribute('accept', _mimes.join(',')); - } - }, - - - disable: function(state) { - var input; - - if ((input = Dom.get(_uid))) { - input.disabled = !!state; - } - }, - - destroy: function() { - var I = this.getRuntime() - , shim = I.getShim() - , shimContainer = I.getShimContainer() - , container = _options && Dom.get(_options.container) - , browseButton = _options && Dom.get(_options.browse_button) - ; - - if (container) { - Events.removeAllEvents(container, this.uid); - } - - if (browseButton) { - Events.removeAllEvents(browseButton, this.uid); - browseButton.style.zIndex = _browseBtnZIndex; // reset to original value - } - - if (shimContainer) { - Events.removeAllEvents(shimContainer, this.uid); - shimContainer.innerHTML = ''; - } - - shim.removeInstance(this.uid); - - _uid = _mimes = _options = shimContainer = container = browseButton = shim = null; - } - }); - } - - return (extensions.FileInput = FileInput); -}); - -// Included from: src/javascript/runtime/html4/file/FileReader.js - -/** - * FileReader.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/html4/file/FileReader -@private -*/ -define("moxie/runtime/html4/file/FileReader", [ - "moxie/runtime/html4/Runtime", - "moxie/runtime/html5/file/FileReader" -], function(extensions, FileReader) { - return (extensions.FileReader = FileReader); -}); - -// Included from: src/javascript/runtime/html4/xhr/XMLHttpRequest.js - -/** - * XMLHttpRequest.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/html4/xhr/XMLHttpRequest -@private -*/ -define("moxie/runtime/html4/xhr/XMLHttpRequest", [ - "moxie/runtime/html4/Runtime", - "moxie/core/utils/Basic", - "moxie/core/utils/Dom", - "moxie/core/utils/Url", - "moxie/core/Exceptions", - "moxie/core/utils/Events", - "moxie/file/Blob", - "moxie/xhr/FormData" -], function(extensions, Basic, Dom, Url, x, Events, Blob, FormData) { - - function XMLHttpRequest() { - var _status, _response, _iframe; - - function cleanup(cb) { - var target = this, uid, form, inputs, i, hasFile = false; - - if (!_iframe) { - return; - } - - uid = _iframe.id.replace(/_iframe$/, ''); - - form = Dom.get(uid + '_form'); - if (form) { - inputs = form.getElementsByTagName('input'); - i = inputs.length; - - while (i--) { - switch (inputs[i].getAttribute('type')) { - case 'hidden': - inputs[i].parentNode.removeChild(inputs[i]); - break; - case 'file': - hasFile = true; // flag the case for later - break; - } - } - inputs = []; - - if (!hasFile) { // we need to keep the form for sake of possible retries - form.parentNode.removeChild(form); - } - form = null; - } - - // without timeout, request is marked as canceled (in console) - setTimeout(function() { - Events.removeEvent(_iframe, 'load', target.uid); - if (_iframe.parentNode) { // #382 - _iframe.parentNode.removeChild(_iframe); - } - - // check if shim container has any other children, if - not, remove it as well - var shimContainer = target.getRuntime().getShimContainer(); - if (!shimContainer.children.length) { - shimContainer.parentNode.removeChild(shimContainer); - } - - shimContainer = _iframe = null; - cb(); - }, 1); - } - - Basic.extend(this, { - send: function(meta, data) { - var target = this, I = target.getRuntime(), uid, form, input, blob; - - _status = _response = null; - - function createIframe() { - var container = I.getShimContainer() || document.body - , temp = document.createElement('div') - ; - - // IE 6 won't be able to set the name using setAttribute or iframe.name - temp.innerHTML = ''; - _iframe = temp.firstChild; - container.appendChild(_iframe); - - /* _iframe.onreadystatechange = function() { - console.info(_iframe.readyState); - };*/ - - Events.addEvent(_iframe, 'load', function() { // _iframe.onload doesn't work in IE lte 8 - var el; - - try { - el = _iframe.contentWindow.document || _iframe.contentDocument || window.frames[_iframe.id].document; - - // try to detect some standard error pages - if (/^4(0[0-9]|1[0-7]|2[2346])\s/.test(el.title)) { // test if title starts with 4xx HTTP error - _status = el.title.replace(/^(\d+).*$/, '$1'); - } else { - _status = 200; - // get result - _response = Basic.trim(el.body.innerHTML); - - // we need to fire these at least once - target.trigger({ - type: 'progress', - loaded: _response.length, - total: _response.length - }); - - if (blob) { // if we were uploading a file - target.trigger({ - type: 'uploadprogress', - loaded: blob.size || 1025, - total: blob.size || 1025 - }); - } - } - } catch (ex) { - if (Url.hasSameOrigin(meta.url)) { - // if response is sent with error code, iframe in IE gets redirected to res://ieframe.dll/http_x.htm - // which obviously results to cross domain error (wtf?) - _status = 404; - } else { - cleanup.call(target, function() { - target.trigger('error'); - }); - return; - } - } - - cleanup.call(target, function() { - target.trigger('load'); - }); - }, target.uid); - } // end createIframe - - // prepare data to be sent and convert if required - if (data instanceof FormData && data.hasBlob()) { - blob = data.getBlob(); - uid = blob.uid; - input = Dom.get(uid); - form = Dom.get(uid + '_form'); - if (!form) { - throw new x.DOMException(x.DOMException.NOT_FOUND_ERR); - } - } else { - uid = Basic.guid('uid_'); - - form = document.createElement('form'); - form.setAttribute('id', uid + '_form'); - form.setAttribute('method', meta.method); - form.setAttribute('enctype', 'multipart/form-data'); - form.setAttribute('encoding', 'multipart/form-data'); - - I.getShimContainer().appendChild(form); - } - - // set upload target - form.setAttribute('target', uid + '_iframe'); - - if (data instanceof FormData) { - data.each(function(value, name) { - if (value instanceof Blob) { - if (input) { - input.setAttribute('name', name); - } - } else { - var hidden = document.createElement('input'); - - Basic.extend(hidden, { - type : 'hidden', - name : name, - value : value - }); - - // make sure that input[type="file"], if it's there, comes last - if (input) { - form.insertBefore(hidden, input); - } else { - form.appendChild(hidden); - } - } - }); - } - - // set destination url - form.setAttribute("action", meta.url); - - createIframe(); - form.submit(); - target.trigger('loadstart'); - }, - - getStatus: function() { - return _status; - }, - - getResponse: function(responseType) { - if ('json' === responseType) { - // strip off
    ..
    tags that might be enclosing the response - if (Basic.typeOf(_response) === 'string' && !!window.JSON) { - try { - return JSON.parse(_response.replace(/^\s*]*>/, '').replace(/<\/pre>\s*$/, '')); - } catch (ex) { - return null; - } - } - } else if ('document' === responseType) { - - } - return _response; - }, - - abort: function() { - var target = this; - - if (_iframe && _iframe.contentWindow) { - if (_iframe.contentWindow.stop) { // FireFox/Safari/Chrome - _iframe.contentWindow.stop(); - } else if (_iframe.contentWindow.document.execCommand) { // IE - _iframe.contentWindow.document.execCommand('Stop'); - } else { - _iframe.src = "about:blank"; - } - } - - cleanup.call(this, function() { - // target.dispatchEvent('readystatechange'); - target.dispatchEvent('abort'); - }); - }, - - destroy: function() { - this.getRuntime().getShim().removeInstance(this.uid); - } - }); - } - - return (extensions.XMLHttpRequest = XMLHttpRequest); -}); - -// Included from: src/javascript/runtime/html4/image/Image.js - -/** - * Image.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/html4/image/Image -@private -*/ -define("moxie/runtime/html4/image/Image", [ - "moxie/runtime/html4/Runtime", - "moxie/runtime/html5/image/Image" -], function(extensions, Image) { - return (extensions.Image = Image); -}); - -expose(["moxie/core/utils/Basic","moxie/core/utils/Encode","moxie/core/utils/Env","moxie/core/Exceptions","moxie/core/utils/Dom","moxie/core/EventTarget","moxie/runtime/Runtime","moxie/runtime/RuntimeClient","moxie/file/Blob","moxie/core/I18n","moxie/core/utils/Mime","moxie/file/FileInput","moxie/file/File","moxie/file/FileDrop","moxie/file/FileReader","moxie/core/utils/Url","moxie/runtime/RuntimeTarget","moxie/xhr/FormData","moxie/xhr/XMLHttpRequest","moxie/image/Image","moxie/core/utils/Events","moxie/runtime/html5/image/ResizerCanvas"]); -})(this); -})); \ No newline at end of file diff --git a/assets/javascripts/plupload/js/moxie.min.js b/assets/javascripts/plupload/js/moxie.min.js deleted file mode 100644 index a854364c..00000000 --- a/assets/javascripts/plupload/js/moxie.min.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * mOxie - multi-runtime File API & XMLHttpRequest L2 Polyfill - * v1.5.8 - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - * - * Date: 2018-02-19 - */ -!function(e,t){var i=function(){var e={};return t.apply(e,arguments),e.moxie};"function"==typeof define&&define.amd?define("moxie",[],i):"object"==typeof module&&module.exports?module.exports=i():e.moxie=i()}(this||window,function(){!function(e,t){"use strict";function i(e,t){for(var i,n=[],r=0;r0&&c(n,function(n,u){var c=-1!==h(e(n),["array","object"]);return n===r||t&&o[u]===r?!0:(c&&i&&(n=a(n)),e(o[u])===e(n)&&c?s(t,i,[o[u],n]):o[u]=n,void 0)})}),o}function u(e,t){function i(){this.constructor=e}for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n]);return i.prototype=t.prototype,e.prototype=new i,e.parent=t.prototype,e}function c(e,t){var i,n,r,o;if(e){try{i=e.length}catch(a){i=o}if(i===o||"number"!=typeof i){for(n in e)if(e.hasOwnProperty(n)&&t(e[n],n)===!1)return}else for(r=0;i>r;r++)if(t(e[r],r)===!1)return}}function l(t){var i;if(!t||"object"!==e(t))return!0;for(i in t)return!1;return!0}function d(t,i){function n(r){"function"===e(t[r])&&t[r](function(e){++ri;i++)if(t[i]===e)return i}return-1}function f(t,i){var n=[];"array"!==e(t)&&(t=[t]),"array"!==e(i)&&(i=[i]);for(var r in t)-1===h(t[r],i)&&n.push(t[r]);return n.length?n:!1}function p(e,t){var i=[];return c(e,function(e){-1!==h(e,t)&&i.push(e)}),i.length?i:null}function g(e){var t,i=[];for(t=0;ti;i++)n+=Math.floor(65535*Math.random()).toString(32);return(t||"o_")+n+(e++).toString(32)}}();return{guid:E,typeOf:e,extend:t,extendIf:i,extendImmutable:n,extendImmutableIf:r,clone:o,inherit:u,each:c,isEmptyObj:l,inSeries:d,inParallel:m,inArray:h,arrayDiff:f,arrayIntersect:p,toArray:g,trim:x,sprintf:w,parseSizeStr:v,delay:y}}),n("moxie/core/utils/Encode",[],function(){var e=function(e){return unescape(encodeURIComponent(e))},t=function(e){return decodeURIComponent(escape(e))},i=function(e,i){if("function"==typeof window.atob)return i?t(window.atob(e)):window.atob(e);var n,r,o,a,s,u,c,l,d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",m=0,h=0,f="",p=[];if(!e)return e;e+="";do a=d.indexOf(e.charAt(m++)),s=d.indexOf(e.charAt(m++)),u=d.indexOf(e.charAt(m++)),c=d.indexOf(e.charAt(m++)),l=a<<18|s<<12|u<<6|c,n=255&l>>16,r=255&l>>8,o=255&l,p[h++]=64==u?String.fromCharCode(n):64==c?String.fromCharCode(n,r):String.fromCharCode(n,r,o);while(m>18,s=63&l>>12,u=63&l>>6,c=63&l,p[h++]=d.charAt(a)+d.charAt(s)+d.charAt(u)+d.charAt(c);while(mn;n++)if(e[n]!=t[n]){if(e[n]=u(e[n]),t[n]=u(t[n]),e[n]t[n]){o=1;break}}if(!i)return o;switch(i){case">":case"gt":return o>0;case">=":case"ge":return o>=0;case"<=":case"le":return 0>=o;case"==":case"=":case"eq":return 0===o;case"<>":case"!=":case"ne":return 0!==o;case"":case"<":case"lt":return 0>o;default:return null}}var n=function(e){var t="",i="?",n="function",r="undefined",o="object",a="name",s="version",u={has:function(e,t){return-1!==t.toLowerCase().indexOf(e.toLowerCase())},lowerize:function(e){return e.toLowerCase()}},c={rgx:function(){for(var t,i,a,s,u,c,l,d=0,m=arguments;d0?2==u.length?t[u[0]]=typeof u[1]==n?u[1].call(this,l):u[1]:3==u.length?t[u[0]]=typeof u[1]!==n||u[1].exec&&u[1].test?l?l.replace(u[1],u[2]):e:l?u[1].call(this,l,u[2]):e:4==u.length&&(t[u[0]]=l?u[3].call(this,l.replace(u[1],u[2])):e):t[u]=l?l:e;break}if(c)break}return t},str:function(t,n){for(var r in n)if(typeof n[r]===o&&n[r].length>0){for(var a=0;a=")),i.use_blob_uri},use_data_uri:function(){var e=new Image;return e.onload=function(){i.use_data_uri=1===e.width&&1===e.height},setTimeout(function(){e.src="data:image/gif;base64,R0lGODlhAQABAIAAAP8AAAAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=="},1),!1}(),use_data_uri_over32kb:function(){return i.use_data_uri&&("IE"!==a.browser||a.version>=9)},use_data_uri_of:function(e){return i.use_data_uri&&33e3>e||i.use_data_uri_over32kb()},use_fileinput:function(){if(navigator.userAgent.match(/(Android (1.0|1.1|1.5|1.6|2.0|2.1))|(Windows Phone (OS 7|8.0))|(XBLWP)|(ZuneWP)|(w(eb)?OSBrowser)|(webOS)|(Kindle\/(1.0|2.0|2.5|3.0))/))return!1;var e=document.createElement("input");return e.setAttribute("type","file"),i.use_fileinput=!e.disabled},use_webgl:function(){var e,n=document.createElement("canvas"),r=null;try{r=n.getContext("webgl")||n.getContext("experimental-webgl")}catch(o){}return r||(r=null),e=!!r,i.use_webgl=e,n=t,e}};return function(t){var n=[].slice.call(arguments);return n.shift(),"function"===e.typeOf(i[t])?i[t].apply(this,n):!!i[t]}}(),o=(new n).getResult(),a={can:r,uaParser:n,browser:o.browser.name,version:o.browser.version,os:o.os.name,osVersion:o.os.version,verComp:i,swf_url:"../flash/Moxie.swf",xap_url:"../silverlight/Moxie.xap",global_event_dispatcher:"moxie.core.EventTarget.instance.dispatchEvent"};return a.OS=a.os,a}),n("moxie/core/Exceptions",["moxie/core/utils/Basic"],function(e){function t(e,t){var i;for(i in e)if(e[i]===t)return i;return null}return{RuntimeError:function(){function i(e,i){this.code=e,this.name=t(n,e),this.message=this.name+(i||": RuntimeError "+this.code)}var n={NOT_INIT_ERR:1,EXCEPTION_ERR:3,NOT_SUPPORTED_ERR:9,JS_ERR:4};return e.extend(i,n),i.prototype=Error.prototype,i}(),OperationNotAllowedException:function(){function t(e){this.code=e,this.name="OperationNotAllowedException"}return e.extend(t,{NOT_ALLOWED_ERR:1}),t.prototype=Error.prototype,t}(),ImageError:function(){function i(e){this.code=e,this.name=t(n,e),this.message=this.name+": ImageError "+this.code}var n={WRONG_FORMAT:1,MAX_RESOLUTION_ERR:2,INVALID_META_ERR:3};return e.extend(i,n),i.prototype=Error.prototype,i}(),FileException:function(){function i(e){this.code=e,this.name=t(n,e),this.message=this.name+": FileException "+this.code}var n={NOT_FOUND_ERR:1,SECURITY_ERR:2,ABORT_ERR:3,NOT_READABLE_ERR:4,ENCODING_ERR:5,NO_MODIFICATION_ALLOWED_ERR:6,INVALID_STATE_ERR:7,SYNTAX_ERR:8};return e.extend(i,n),i.prototype=Error.prototype,i}(),DOMException:function(){function i(e){this.code=e,this.name=t(n,e),this.message=this.name+": DOMException "+this.code}var n={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25};return e.extend(i,n),i.prototype=Error.prototype,i}(),EventException:function(){function t(e){this.code=e,this.name="EventException"}return e.extend(t,{UNSPECIFIED_EVENT_TYPE_ERR:0}),t.prototype=Error.prototype,t}()}}),n("moxie/core/utils/Dom",["moxie/core/utils/Env"],function(e){var t=function(e){return"string"!=typeof e?e:document.getElementById(e)},i=function(e,t){if(!e.className)return!1;var i=new RegExp("(^|\\s+)"+t+"(\\s+|$)");return i.test(e.className)},n=function(e,t){i(e,t)||(e.className=e.className?e.className.replace(/\s+$/,"")+" "+t:t)},r=function(e,t){if(e.className){var i=new RegExp("(^|\\s+)"+t+"(\\s+|$)");e.className=e.className.replace(i,function(e,t,i){return" "===t&&" "===i?" ":""})}},o=function(e,t){return e.currentStyle?e.currentStyle[t]:window.getComputedStyle?window.getComputedStyle(e,null)[t]:void 0},a=function(t,i){function n(e){var t,i,n=0,r=0;return e&&(i=e.getBoundingClientRect(),t="CSS1Compat"===c.compatMode?c.documentElement:c.body,n=i.left+t.scrollLeft,r=i.top+t.scrollTop),{x:n,y:r}}var r,o,a,s=0,u=0,c=document;if(t=t,i=i||c.body,t&&t.getBoundingClientRect&&"IE"===e.browser&&(!c.documentMode||c.documentMode<8))return o=n(t),a=n(i),{x:o.x-a.x,y:o.y-a.y};for(r=t;r&&r!=i&&r.nodeType;)s+=r.offsetLeft||0,u+=r.offsetTop||0,r=r.offsetParent;for(r=t.parentNode;r&&r!=i&&r.nodeType;)s-=r.scrollLeft||0,u-=r.scrollTop||0,r=r.parentNode;return{x:s,y:u}},s=function(e){return{w:e.offsetWidth||e.clientWidth,h:e.offsetHeight||e.clientHeight}};return{get:t,hasClass:i,addClass:n,removeClass:r,getStyle:o,getPos:a,getSize:s}}),n("moxie/core/EventTarget",["moxie/core/utils/Env","moxie/core/Exceptions","moxie/core/utils/Basic"],function(e,t,i){function n(){this.uid=i.guid()}var r={};return i.extend(n.prototype,{init:function(){this.uid||(this.uid=i.guid("uid_"))},addEventListener:function(e,t,n,o){var a,s=this;return this.hasOwnProperty("uid")||(this.uid=i.guid("uid_")),e=i.trim(e),/\s/.test(e)?(i.each(e.split(/\s+/),function(e){s.addEventListener(e,t,n,o)}),void 0):(e=e.toLowerCase(),n=parseInt(n,10)||0,a=r[this.uid]&&r[this.uid][e]||[],a.push({fn:t,priority:n,scope:o||this}),r[this.uid]||(r[this.uid]={}),r[this.uid][e]=a,void 0)},hasEventListener:function(e){var t;return e?(e=e.toLowerCase(),t=r[this.uid]&&r[this.uid][e]):t=r[this.uid],t?t:!1},removeEventListener:function(e,t){var n,o,a=this;if(e=e.toLowerCase(),/\s/.test(e))return i.each(e.split(/\s+/),function(e){a.removeEventListener(e,t)}),void 0;if(n=r[this.uid]&&r[this.uid][e]){if(t){for(o=n.length-1;o>=0;o--)if(n[o].fn===t){n.splice(o,1);break}}else n=[];n.length||(delete r[this.uid][e],i.isEmptyObj(r[this.uid])&&delete r[this.uid])}},removeAllEventListeners:function(){r[this.uid]&&delete r[this.uid]},dispatchEvent:function(e){var n,o,a,s,u,c={},l=!0;if("string"!==i.typeOf(e)){if(s=e,"string"!==i.typeOf(s.type))throw new t.EventException(t.EventException.UNSPECIFIED_EVENT_TYPE_ERR);e=s.type,s.total!==u&&s.loaded!==u&&(c.total=s.total,c.loaded=s.loaded),c.async=s.async||!1}if(-1!==e.indexOf("::")?function(t){n=t[0],e=t[1]}(e.split("::")):n=this.uid,e=e.toLowerCase(),o=r[n]&&r[n][e]){o.sort(function(e,t){return t.priority-e.priority}),a=[].slice.call(arguments),a.shift(),c.type=e,a.unshift(c);var d=[];i.each(o,function(e){a[0].target=e.scope,c.async?d.push(function(t){setTimeout(function(){t(e.fn.apply(e.scope,a)===!1)},1)}):d.push(function(t){t(e.fn.apply(e.scope,a)===!1)})}),d.length&&i.inSeries(d,function(e){l=!e})}return l},bindOnce:function(e,t,i,n){var r=this;r.bind.call(this,e,function o(){return r.unbind(e,o),t.apply(this,arguments)},i,n)},bind:function(){this.addEventListener.apply(this,arguments)},unbind:function(){this.removeEventListener.apply(this,arguments)},unbindAll:function(){this.removeAllEventListeners.apply(this,arguments)},trigger:function(){return this.dispatchEvent.apply(this,arguments)},handleEventProps:function(e){var t=this;this.bind(e.join(" "),function(e){var t="on"+e.type.toLowerCase();"function"===i.typeOf(this[t])&&this[t].apply(this,arguments)}),i.each(e,function(e){e="on"+e.toLowerCase(e),"undefined"===i.typeOf(t[e])&&(t[e]=null)})}}),n.instance=new n,n}),n("moxie/runtime/Runtime",["moxie/core/utils/Env","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/EventTarget"],function(e,t,i,n){function r(e,n,o,s,u){var c,l=this,d=t.guid(n+"_"),m=u||"browser";e=e||{},a[d]=this,o=t.extend({access_binary:!1,access_image_binary:!1,display_media:!1,do_cors:!1,drag_and_drop:!1,filter_by_extension:!0,resize_image:!1,report_upload_progress:!1,return_response_headers:!1,return_response_type:!1,return_status_code:!0,send_custom_headers:!1,select_file:!1,select_folder:!1,select_multiple:!0,send_binary_string:!1,send_browser_cookies:!0,send_multipart:!0,slice_blob:!1,stream_upload:!1,summon_file_dialog:!1,upload_filesize:!0,use_http_method:!0},o),e.preferred_caps&&(m=r.getMode(s,e.preferred_caps,m)),c=function(){var e={};return{exec:function(t,i,n,r){return c[i]&&(e[t]||(e[t]={context:this,instance:new c[i]}),e[t].instance[n])?e[t].instance[n].apply(this,r):void 0},removeInstance:function(t){delete e[t]},removeAllInstances:function(){var i=this;t.each(e,function(e,n){"function"===t.typeOf(e.instance.destroy)&&e.instance.destroy.call(e.context),i.removeInstance(n)})}}}(),t.extend(this,{initialized:!1,uid:d,type:n,mode:r.getMode(s,e.required_caps,m),shimid:d+"_container",clients:0,options:e,can:function(e,i){var n=arguments[2]||o;if("string"===t.typeOf(e)&&"undefined"===t.typeOf(i)&&(e=r.parseCaps(e)),"object"===t.typeOf(e)){for(var a in e)if(!this.can(a,e[a],n))return!1;return!0}return"function"===t.typeOf(n[e])?n[e].call(this,i):i===n[e]},getShimContainer:function(){var e,n=i.get(this.shimid);return n||(e=i.get(this.options.container)||document.body,n=document.createElement("div"),n.id=this.shimid,n.className="moxie-shim moxie-shim-"+this.type,t.extend(n.style,{position:"absolute",top:"0px",left:"0px",width:"1px",height:"1px",overflow:"hidden"}),e.appendChild(n),e=null),n},getShim:function(){return c},shimExec:function(e,t){var i=[].slice.call(arguments,2);return l.getShim().exec.call(this,this.uid,e,t,i)},exec:function(e,t){var i=[].slice.call(arguments,2);return l[e]&&l[e][t]?l[e][t].apply(this,i):l.shimExec.apply(this,arguments)},destroy:function(){if(l){var e=i.get(this.shimid);e&&e.parentNode.removeChild(e),c&&c.removeAllInstances(),this.unbindAll(),delete a[this.uid],this.uid=null,d=l=c=e=null}}}),this.mode&&e.required_caps&&!this.can(e.required_caps)&&(this.mode=!1)}var o={},a={};return r.order="html5,flash,silverlight,html4",r.getRuntime=function(e){return a[e]?a[e]:!1},r.addConstructor=function(e,t){t.prototype=n.instance,o[e]=t},r.getConstructor=function(e){return o[e]||null},r.getInfo=function(e){var t=r.getRuntime(e);return t?{uid:t.uid,type:t.type,mode:t.mode,can:function(){return t.can.apply(t,arguments)}}:null},r.parseCaps=function(e){var i={};return"string"!==t.typeOf(e)?e||{}:(t.each(e.split(","),function(e){i[e]=!0}),i)},r.can=function(e,t){var i,n,o=r.getConstructor(e);return o?(i=new o({required_caps:t}),n=i.mode,i.destroy(),!!n):!1},r.thatCan=function(e,t){var i=(t||r.order).split(/\s*,\s*/);for(var n in i)if(r.can(i[n],e))return i[n];return null},r.getMode=function(e,i,n){var r=null;if("undefined"===t.typeOf(n)&&(n="browser"),i&&!t.isEmptyObj(e)){if(t.each(i,function(i,n){if(e.hasOwnProperty(n)){var o=e[n](i);if("string"==typeof o&&(o=[o]),r){if(!(r=t.arrayIntersect(r,o)))return r=!1}else r=o}}),r)return-1!==t.inArray(n,r)?n:r[0];if(r===!1)return!1}return n},r.getGlobalEventTarget=function(){if(/^moxie\./.test(e.global_event_dispatcher)&&!e.can("access_global_ns")){var i=t.guid("moxie_event_target_");window[i]=function(e,t){n.instance.dispatchEvent(e,t)},e.global_event_dispatcher=i}return e.global_event_dispatcher},r.capTrue=function(){return!0},r.capFalse=function(){return!1},r.capTest=function(e){return function(){return!!e}},r}),n("moxie/runtime/RuntimeClient",["moxie/core/utils/Env","moxie/core/Exceptions","moxie/core/utils/Basic","moxie/runtime/Runtime"],function(e,t,i,n){return function(){var e;i.extend(this,{connectRuntime:function(r){function o(i){var a,u;return i.length?(a=i.shift().toLowerCase(),(u=n.getConstructor(a))?(e=new u(r),e.bind("Init",function(){e.initialized=!0,setTimeout(function(){e.clients++,s.ruid=e.uid,s.trigger("RuntimeInit",e)},1)}),e.bind("Error",function(){e.destroy(),o(i)}),e.bind("Exception",function(e,i){var n=i.name+"(#"+i.code+")"+(i.message?", from: "+i.message:"");s.trigger("RuntimeError",new t.RuntimeError(t.RuntimeError.EXCEPTION_ERR,n))}),e.mode?(e.init(),void 0):(e.trigger("Error"),void 0)):(o(i),void 0)):(s.trigger("RuntimeError",new t.RuntimeError(t.RuntimeError.NOT_INIT_ERR)),e=null,void 0)}var a,s=this;if("string"===i.typeOf(r)?a=r:"string"===i.typeOf(r.ruid)&&(a=r.ruid),a){if(e=n.getRuntime(a))return s.ruid=a,e.clients++,e;throw new t.RuntimeError(t.RuntimeError.NOT_INIT_ERR)}o((r.runtime_order||n.order).split(/\s*,\s*/))},disconnectRuntime:function(){e&&--e.clients<=0&&e.destroy(),e=null},getRuntime:function(){return e&&e.uid?e:e=null},exec:function(){return e?e.exec.apply(this,arguments):null},can:function(t){return e?e.can(t):!1}})}}),n("moxie/file/Blob",["moxie/core/utils/Basic","moxie/core/utils/Encode","moxie/runtime/RuntimeClient"],function(e,t,i){function n(o,a){function s(t,i,o){var a,s=r[this.uid];return"string"===e.typeOf(s)&&s.length?(a=new n(null,{type:o,size:i-t}),a.detach(s.substr(t,a.size)),a):null}i.call(this),o&&this.connectRuntime(o),a?"string"===e.typeOf(a)&&(a={data:a}):a={},e.extend(this,{uid:a.uid||e.guid("uid_"),ruid:o,size:a.size||0,type:a.type||"",slice:function(e,t,i){return this.isDetached()?s.apply(this,arguments):this.getRuntime().exec.call(this,"Blob","slice",this.getSource(),e,t,i)},getSource:function(){return r[this.uid]?r[this.uid]:null},detach:function(e){if(this.ruid&&(this.getRuntime().exec.call(this,"Blob","destroy"),this.disconnectRuntime(),this.ruid=null),e=e||"","data:"==e.substr(0,5)){var i=e.indexOf(";base64,");this.type=e.substring(5,i),e=t.atob(e.substring(i+8))}this.size=e.length,r[this.uid]=e},isDetached:function(){return!this.ruid&&"string"===e.typeOf(r[this.uid])},destroy:function(){this.detach(),delete r[this.uid]}}),a.data?this.detach(a.data):r[this.uid]=a}var r={};return n}),n("moxie/core/I18n",["moxie/core/utils/Basic"],function(e){var t={};return{addI18n:function(i){return e.extend(t,i)},translate:function(e){return t[e]||e},_:function(e){return this.translate(e)},sprintf:function(t){var i=[].slice.call(arguments,1);return t.replace(/%[a-z]/g,function(){var t=i.shift();return"undefined"!==e.typeOf(t)?t:""})}}}),n("moxie/core/utils/Mime",["moxie/core/utils/Basic","moxie/core/I18n"],function(e,t){var i="application/msword,doc dot,application/pdf,pdf,application/pgp-signature,pgp,application/postscript,ps ai eps,application/rtf,rtf,application/vnd.ms-excel,xls xlb xlt xla,application/vnd.ms-powerpoint,ppt pps pot ppa,application/zip,zip,application/x-shockwave-flash,swf swfl,application/vnd.openxmlformats-officedocument.wordprocessingml.document,docx,application/vnd.openxmlformats-officedocument.wordprocessingml.template,dotx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,xlsx,application/vnd.openxmlformats-officedocument.presentationml.presentation,pptx,application/vnd.openxmlformats-officedocument.presentationml.template,potx,application/vnd.openxmlformats-officedocument.presentationml.slideshow,ppsx,application/x-javascript,js,application/json,json,audio/mpeg,mp3 mpga mpega mp2,audio/x-wav,wav,audio/x-m4a,m4a,audio/ogg,oga ogg,audio/aiff,aiff aif,audio/flac,flac,audio/aac,aac,audio/ac3,ac3,audio/x-ms-wma,wma,image/bmp,bmp,image/gif,gif,image/jpeg,jpg jpeg jpe,image/photoshop,psd,image/png,png,image/svg+xml,svg svgz,image/tiff,tiff tif,text/plain,asc txt text diff log,text/html,htm html xhtml,text/css,css,text/csv,csv,text/rtf,rtf,video/mpeg,mpeg mpg mpe m2v,video/quicktime,qt mov,video/mp4,mp4,video/x-m4v,m4v,video/x-flv,flv,video/x-ms-wmv,wmv,video/avi,avi,video/webm,webm,video/3gpp,3gpp 3gp,video/3gpp2,3g2,video/vnd.rn-realvideo,rv,video/ogg,ogv,video/x-matroska,mkv,application/vnd.oasis.opendocument.formula-template,otf,application/octet-stream,exe",n={},r={},o=function(e){var t,i,o,a=e.split(/,/);for(t=0;ta;a++)o+=String.fromCharCode(r[a]);return o}}t.call(this),e.extend(this,{uid:e.guid("uid_"),readAsBinaryString:function(e){return n.call(this,"readAsBinaryString",e)},readAsDataURL:function(e){return n.call(this,"readAsDataURL",e)},readAsText:function(e){return n.call(this,"readAsText",e)}})}}),n("moxie/xhr/FormData",["moxie/core/Exceptions","moxie/core/utils/Basic","moxie/file/Blob"],function(e,t,i){function n(){var e,n=[];t.extend(this,{append:function(r,o){var a=this,s=t.typeOf(o);o instanceof i?e={name:r,value:o}:"array"===s?(r+="[]",t.each(o,function(e){a.append(r,e)})):"object"===s?t.each(o,function(e,t){a.append(r+"["+t+"]",e)}):"null"===s||"undefined"===s||"number"===s&&isNaN(o)?a.append(r,"false"):n.push({name:r,value:o.toString()})},hasBlob:function(){return!!this.getBlob()},getBlob:function(){return e&&e.value||null},getBlobName:function(){return e&&e.name||null},each:function(i){t.each(n,function(e){i(e.value,e.name)}),e&&i(e.value,e.name)},destroy:function(){e=null,n=[]}})}return n}),n("moxie/xhr/XMLHttpRequest",["moxie/core/utils/Basic","moxie/core/Exceptions","moxie/core/EventTarget","moxie/core/utils/Encode","moxie/core/utils/Url","moxie/runtime/Runtime","moxie/runtime/RuntimeTarget","moxie/file/Blob","moxie/file/FileReaderSync","moxie/xhr/FormData","moxie/core/utils/Env","moxie/core/utils/Mime"],function(e,t,i,n,r,o,a,s,u,c,l,d){function m(){this.uid=e.guid("uid_")}function h(){function i(e,t){return I.hasOwnProperty(e)?1===arguments.length?l.can("define_property")?I[e]:A[e]:(l.can("define_property")?I[e]=t:A[e]=t,void 0):void 0}function u(t){function n(){_&&(_.destroy(),_=null),s.dispatchEvent("loadend"),s=null}function r(r){_.bind("LoadStart",function(e){i("readyState",h.LOADING),s.dispatchEvent("readystatechange"),s.dispatchEvent(e),L&&s.upload.dispatchEvent(e)}),_.bind("Progress",function(e){i("readyState")!==h.LOADING&&(i("readyState",h.LOADING),s.dispatchEvent("readystatechange")),s.dispatchEvent(e)}),_.bind("UploadProgress",function(e){L&&s.upload.dispatchEvent({type:"progress",lengthComputable:!1,total:e.total,loaded:e.loaded})}),_.bind("Load",function(t){i("readyState",h.DONE),i("status",Number(r.exec.call(_,"XMLHttpRequest","getStatus")||0)),i("statusText",f[i("status")]||""),i("response",r.exec.call(_,"XMLHttpRequest","getResponse",i("responseType"))),~e.inArray(i("responseType"),["text",""])?i("responseText",i("response")):"document"===i("responseType")&&i("responseXML",i("response")),U=r.exec.call(_,"XMLHttpRequest","getAllResponseHeaders"),s.dispatchEvent("readystatechange"),i("status")>0?(L&&s.upload.dispatchEvent(t),s.dispatchEvent(t)):(F=!0,s.dispatchEvent("error")),n()}),_.bind("Abort",function(e){s.dispatchEvent(e),n()}),_.bind("Error",function(e){F=!0,i("readyState",h.DONE),s.dispatchEvent("readystatechange"),M=!0,s.dispatchEvent(e),n()}),r.exec.call(_,"XMLHttpRequest","send",{url:x,method:v,async:T,user:w,password:y,headers:S,mimeType:D,encoding:O,responseType:s.responseType,withCredentials:s.withCredentials,options:k},t)}var s=this;E=(new Date).getTime(),_=new a,"string"==typeof k.required_caps&&(k.required_caps=o.parseCaps(k.required_caps)),k.required_caps=e.extend({},k.required_caps,{return_response_type:s.responseType}),t instanceof c&&(k.required_caps.send_multipart=!0),e.isEmptyObj(S)||(k.required_caps.send_custom_headers=!0),B||(k.required_caps.do_cors=!0),k.ruid?r(_.connectRuntime(k)):(_.bind("RuntimeInit",function(e,t){r(t)}),_.bind("RuntimeError",function(e,t){s.dispatchEvent("RuntimeError",t)}),_.connectRuntime(k))}function g(){i("responseText",""),i("responseXML",null),i("response",null),i("status",0),i("statusText",""),E=b=null}var x,v,w,y,E,b,_,R,A=this,I={timeout:0,readyState:h.UNSENT,withCredentials:!1,status:0,statusText:"",responseType:"",responseXML:null,responseText:null,response:null},T=!0,S={},O=null,D=null,N=!1,C=!1,L=!1,M=!1,F=!1,B=!1,P=null,H=null,k={},U="";e.extend(this,I,{uid:e.guid("uid_"),upload:new m,open:function(o,a,s,u,c){var l;if(!o||!a)throw new t.DOMException(t.DOMException.SYNTAX_ERR);if(/[\u0100-\uffff]/.test(o)||n.utf8_encode(o)!==o)throw new t.DOMException(t.DOMException.SYNTAX_ERR);if(~e.inArray(o.toUpperCase(),["CONNECT","DELETE","GET","HEAD","OPTIONS","POST","PUT","TRACE","TRACK"])&&(v=o.toUpperCase()),~e.inArray(v,["CONNECT","TRACE","TRACK"]))throw new t.DOMException(t.DOMException.SECURITY_ERR);if(a=n.utf8_encode(a),l=r.parseUrl(a),B=r.hasSameOrigin(l),x=r.resolveUrl(a),(u||c)&&!B)throw new t.DOMException(t.DOMException.INVALID_ACCESS_ERR);if(w=u||l.user,y=c||l.pass,T=s||!0,T===!1&&(i("timeout")||i("withCredentials")||""!==i("responseType")))throw new t.DOMException(t.DOMException.INVALID_ACCESS_ERR);N=!T,C=!1,S={},g.call(this),i("readyState",h.OPENED),this.dispatchEvent("readystatechange")},setRequestHeader:function(r,o){var a=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","content-transfer-encoding","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"];if(i("readyState")!==h.OPENED||C)throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);if(/[\u0100-\uffff]/.test(r)||n.utf8_encode(r)!==r)throw new t.DOMException(t.DOMException.SYNTAX_ERR);return r=e.trim(r).toLowerCase(),~e.inArray(r,a)||/^(proxy\-|sec\-)/.test(r)?!1:(S[r]?S[r]+=", "+o:S[r]=o,!0)},hasRequestHeader:function(e){return e&&S[e.toLowerCase()]||!1},getAllResponseHeaders:function(){return U||""},getResponseHeader:function(t){return t=t.toLowerCase(),F||~e.inArray(t,["set-cookie","set-cookie2"])?null:U&&""!==U&&(R||(R={},e.each(U.split(/\r\n/),function(t){var i=t.split(/:\s+/);2===i.length&&(i[0]=e.trim(i[0]),R[i[0].toLowerCase()]={header:i[0],value:e.trim(i[1])})})),R.hasOwnProperty(t))?R[t].header+": "+R[t].value:null},overrideMimeType:function(n){var r,o;if(~e.inArray(i("readyState"),[h.LOADING,h.DONE]))throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);if(n=e.trim(n.toLowerCase()),/;/.test(n)&&(r=n.match(/^([^;]+)(?:;\scharset\=)?(.*)$/))&&(n=r[1],r[2]&&(o=r[2])),!d.mimes[n])throw new t.DOMException(t.DOMException.SYNTAX_ERR);P=n,H=o},send:function(i,r){if(k="string"===e.typeOf(r)?{ruid:r}:r?r:{},this.readyState!==h.OPENED||C)throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);if(i instanceof s)k.ruid=i.ruid,D=i.type||"application/octet-stream";else if(i instanceof c){if(i.hasBlob()){var o=i.getBlob();k.ruid=o.ruid,D=o.type||"application/octet-stream"}}else"string"==typeof i&&(O="UTF-8",D="text/plain;charset=UTF-8",i=n.utf8_encode(i));this.withCredentials||(this.withCredentials=k.required_caps&&k.required_caps.send_browser_cookies&&!B),L=!N&&this.upload.hasEventListener(),F=!1,M=!i,N||(C=!0),u.call(this,i)},abort:function(){if(F=!0,N=!1,~e.inArray(i("readyState"),[h.UNSENT,h.OPENED,h.DONE]))i("readyState",h.UNSENT);else{if(i("readyState",h.DONE),C=!1,!_)throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);_.getRuntime().exec.call(_,"XMLHttpRequest","abort",M),M=!0}},destroy:function(){_&&("function"===e.typeOf(_.destroy)&&_.destroy(),_=null),this.unbindAll(),this.upload&&(this.upload.unbindAll(),this.upload=null)}}),this.handleEventProps(p.concat(["readystatechange"])),this.upload.handleEventProps(p)}var f={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",306:"Reserved",307:"Temporary Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Large",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",426:"Upgrade Required",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",510:"Not Extended"};m.prototype=i.instance;var p=["loadstart","progress","abort","error","load","timeout","loadend"];return h.UNSENT=0,h.OPENED=1,h.HEADERS_RECEIVED=2,h.LOADING=3,h.DONE=4,h.prototype=i.instance,h}),n("moxie/runtime/Transporter",["moxie/core/utils/Basic","moxie/core/utils/Encode","moxie/runtime/RuntimeClient","moxie/core/EventTarget"],function(e,t,i,n){function r(){function n(){l=d=0,c=this.result=null}function o(t,i){var n=this;u=i,n.bind("TransportingProgress",function(t){d=t.loaded,l>d&&-1===e.inArray(n.state,[r.IDLE,r.DONE])&&a.call(n)},999),n.bind("TransportingComplete",function(){d=l,n.state=r.DONE,c=null,n.result=u.exec.call(n,"Transporter","getAsBlob",t||"")},999),n.state=r.BUSY,n.trigger("TransportingStarted"),a.call(n)}function a(){var e,i=this,n=l-d;m>n&&(m=n),e=t.btoa(c.substr(d,m)),u.exec.call(i,"Transporter","receive",e,l)}var s,u,c,l,d,m;i.call(this),e.extend(this,{uid:e.guid("uid_"),state:r.IDLE,result:null,transport:function(t,i,r){var a=this;if(r=e.extend({chunk_size:204798},r),(s=r.chunk_size%3)&&(r.chunk_size+=3-s),m=r.chunk_size,n.call(this),c=t,l=t.length,"string"===e.typeOf(r)||r.ruid)o.call(a,i,this.connectRuntime(r));else{var u=function(e,t){a.unbind("RuntimeInit",u),o.call(a,i,t)};this.bind("RuntimeInit",u),this.connectRuntime(r)}},abort:function(){var e=this;e.state=r.IDLE,u&&(u.exec.call(e,"Transporter","clear"),e.trigger("TransportingAborted")),n.call(e)},destroy:function(){this.unbindAll(),u=null,this.disconnectRuntime(),n.call(this)}})}return r.IDLE=0,r.BUSY=1,r.DONE=2,r.prototype=n.instance,r}),n("moxie/image/Image",["moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/file/FileReaderSync","moxie/xhr/XMLHttpRequest","moxie/runtime/Runtime","moxie/runtime/RuntimeClient","moxie/runtime/Transporter","moxie/core/utils/Env","moxie/core/EventTarget","moxie/file/Blob","moxie/file/File","moxie/core/utils/Encode"],function(e,t,i,n,r,o,a,s,u,c,l,d,m){function h(){function n(e){try{return e||(e=this.exec("Image","getInfo")),this.size=e.size,this.width=e.width,this.height=e.height,this.type=e.type,this.meta=e.meta,""===this.name&&(this.name=e.name),!0}catch(t){return this.trigger("error",t.code),!1}}function c(t){var n=e.typeOf(t);try{if(t instanceof h){if(!t.size)throw new i.DOMException(i.DOMException.INVALID_STATE_ERR);p.apply(this,arguments)}else if(t instanceof l){if(!~e.inArray(t.type,["image/jpeg","image/png"]))throw new i.ImageError(i.ImageError.WRONG_FORMAT);g.apply(this,arguments)}else if(-1!==e.inArray(n,["blob","file"]))c.call(this,new d(null,t),arguments[1]);else if("string"===n)"data:"===t.substr(0,5)?c.call(this,new l(null,{data:t}),arguments[1]):x.apply(this,arguments);else{if("node"!==n||"img"!==t.nodeName.toLowerCase())throw new i.DOMException(i.DOMException.TYPE_MISMATCH_ERR);c.call(this,t.src,arguments[1])}}catch(r){this.trigger("error",r.code)}}function p(t,i){var n=this.connectRuntime(t.ruid);this.ruid=n.uid,n.exec.call(this,"Image","loadFromImage",t,"undefined"===e.typeOf(i)?!0:i)}function g(t,i){function n(e){r.ruid=e.uid,e.exec.call(r,"Image","loadFromBlob",t)}var r=this;r.name=t.name||"",t.isDetached()?(this.bind("RuntimeInit",function(e,t){n(t)}),i&&"string"==typeof i.required_caps&&(i.required_caps=o.parseCaps(i.required_caps)),this.connectRuntime(e.extend({required_caps:{access_image_binary:!0,resize_image:!0}},i))):n(this.connectRuntime(t.ruid))}function x(e,t){var i,n=this;i=new r,i.open("get",e),i.responseType="blob",i.onprogress=function(e){n.trigger(e)},i.onload=function(){g.call(n,i.response,!0)},i.onerror=function(e){n.trigger(e)},i.onloadend=function(){i.destroy()},i.bind("RuntimeError",function(e,t){n.trigger("RuntimeError",t)}),i.send(null,t)}a.call(this),e.extend(this,{uid:e.guid("uid_"),ruid:null,name:"",size:0,width:0,height:0,type:"",meta:{},clone:function(){this.load.apply(this,arguments)},load:function(){c.apply(this,arguments)},resize:function(t){var n,r,o=this,a={x:0,y:0,width:o.width,height:o.height},s=e.extendIf({width:o.width,height:o.height,type:o.type||"image/jpeg",quality:90,crop:!1,fit:!0,preserveHeaders:!0,resample:"default",multipass:!0},t);try{if(!o.size)throw new i.DOMException(i.DOMException.INVALID_STATE_ERR);if(o.width>h.MAX_RESIZE_WIDTH||o.height>h.MAX_RESIZE_HEIGHT)throw new i.ImageError(i.ImageError.MAX_RESOLUTION_ERR);if(n=o.meta&&o.meta.tiff&&o.meta.tiff.Orientation||1,-1!==e.inArray(n,[5,6,7,8])){var u=s.width;s.width=s.height,s.height=u}if(s.crop){switch(r=Math.max(s.width/o.width,s.height/o.height),t.fit?(a.width=Math.min(Math.ceil(s.width/r),o.width),a.height=Math.min(Math.ceil(s.height/r),o.height),r=s.width/a.width):(a.width=Math.min(s.width,o.width),a.height=Math.min(s.height,o.height),r=1),"boolean"==typeof s.crop&&(s.crop="cc"),s.crop.toLowerCase().replace(/_/,"-")){case"rb":case"right-bottom":a.x=o.width-a.width,a.y=o.height-a.height;break;case"cb":case"center-bottom":a.x=Math.floor((o.width-a.width)/2),a.y=o.height-a.height;break;case"lb":case"left-bottom":a.x=0,a.y=o.height-a.height;break;case"lt":case"left-top":a.x=0,a.y=0;break;case"ct":case"center-top":a.x=Math.floor((o.width-a.width)/2),a.y=0;break;case"rt":case"right-top":a.x=o.width-a.width,a.y=0;break;case"rc":case"right-center":case"right-middle":a.x=o.width-a.width,a.y=Math.floor((o.height-a.height)/2);break;case"lc":case"left-center":case"left-middle":a.x=0,a.y=Math.floor((o.height-a.height)/2);break;case"cc":case"center-center":case"center-middle":default:a.x=Math.floor((o.width-a.width)/2),a.y=Math.floor((o.height-a.height)/2)}a.x=Math.max(a.x,0),a.y=Math.max(a.y,0)}else r=Math.min(s.width/o.width,s.height/o.height),r>1&&!s.fit&&(r=1);this.exec("Image","resize",a,r,s)}catch(c){o.trigger("error",c.code)}},downsize:function(t){var i,n={width:this.width,height:this.height,type:this.type||"image/jpeg",quality:90,crop:!1,fit:!1,preserveHeaders:!0,resample:"default"};i="object"==typeof t?e.extend(n,t):e.extend(n,{width:arguments[0],height:arguments[1],crop:arguments[2],preserveHeaders:arguments[3]}),this.resize(i)},crop:function(e,t,i){this.downsize(e,t,!0,i)},getAsCanvas:function(){if(!u.can("create_canvas"))throw new i.RuntimeError(i.RuntimeError.NOT_SUPPORTED_ERR);return this.exec("Image","getAsCanvas")},getAsBlob:function(e,t){if(!this.size)throw new i.DOMException(i.DOMException.INVALID_STATE_ERR);return this.exec("Image","getAsBlob",e||"image/jpeg",t||90)},getAsDataURL:function(e,t){if(!this.size)throw new i.DOMException(i.DOMException.INVALID_STATE_ERR);return this.exec("Image","getAsDataURL",e||"image/jpeg",t||90)},getAsBinaryString:function(e,t){var i=this.getAsDataURL(e,t);return m.atob(i.substring(i.indexOf("base64,")+7))},embed:function(n,r){function o(t,r){var o=this;if(u.can("create_canvas")){var l=o.getAsCanvas();if(l)return n.appendChild(l),l=null,o.destroy(),c.trigger("embedded"),void 0}var d=o.getAsDataURL(t,r);if(!d)throw new i.ImageError(i.ImageError.WRONG_FORMAT);if(u.can("use_data_uri_of",d.length))n.innerHTML='',o.destroy(),c.trigger("embedded");else{var h=new s;h.bind("TransportingComplete",function(){a=c.connectRuntime(this.result.ruid),c.bind("Embedded",function(){e.extend(a.getShimContainer().style,{top:"0px",left:"0px",width:o.width+"px",height:o.height+"px"}),a=null},999),a.exec.call(c,"ImageView","display",this.result.uid,width,height),o.destroy()}),h.transport(m.atob(d.substring(d.indexOf("base64,")+7)),t,{required_caps:{display_media:!0},runtime_order:"flash,silverlight",container:n})}}var a,c=this,l=e.extend({width:this.width,height:this.height,type:this.type||"image/jpeg",quality:90,fit:!0,resample:"nearest"},r);try{if(!(n=t.get(n)))throw new i.DOMException(i.DOMException.INVALID_NODE_TYPE_ERR);if(!this.size)throw new i.DOMException(i.DOMException.INVALID_STATE_ERR);this.width>h.MAX_RESIZE_WIDTH||this.height>h.MAX_RESIZE_HEIGHT;var d=new h;return d.bind("Resize",function(){o.call(this,l.type,l.quality)}),d.bind("Load",function(){this.downsize(l)}),this.meta.thumb&&this.meta.thumb.width>=l.width&&this.meta.thumb.height>=l.height?d.load(this.meta.thumb.data):d.clone(this,!1),d}catch(f){this.trigger("error",f.code)}},destroy:function(){this.ruid&&(this.getRuntime().exec.call(this,"Image","destroy"),this.disconnectRuntime()),this.meta&&this.meta.thumb&&this.meta.thumb.data.destroy(),this.unbindAll()}}),this.handleEventProps(f),this.bind("Load Resize",function(){return n.call(this)},999)}var f=["progress","load","error","resize","embedded"];return h.MAX_RESIZE_WIDTH=8192,h.MAX_RESIZE_HEIGHT=8192,h.prototype=c.instance,h}),n("moxie/runtime/html5/Runtime",["moxie/core/utils/Basic","moxie/core/Exceptions","moxie/runtime/Runtime","moxie/core/utils/Env"],function(e,t,i,n){function o(t){var o=this,u=i.capTest,c=i.capTrue,l=e.extend({access_binary:u(window.FileReader||window.File&&window.File.getAsDataURL),access_image_binary:function(){return o.can("access_binary")&&!!s.Image},display_media:u((n.can("create_canvas")||n.can("use_data_uri_over32kb"))&&r("moxie/image/Image")),do_cors:u(window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest),drag_and_drop:u(function(){var e=document.createElement("div");return("draggable"in e||"ondragstart"in e&&"ondrop"in e)&&("IE"!==n.browser||n.verComp(n.version,9,">"))}()),filter_by_extension:u(function(){return!("Chrome"===n.browser&&n.verComp(n.version,28,"<")||"IE"===n.browser&&n.verComp(n.version,10,"<")||"Safari"===n.browser&&n.verComp(n.version,11,"<=")||"Firefox"===n.browser&&n.verComp(n.version,37,"<")||"iOS"===n.os||"Android"===n.os)}()),return_response_headers:c,return_response_type:function(e){return"json"===e&&window.JSON?!0:n.can("return_response_type",e)},return_status_code:c,report_upload_progress:u(window.XMLHttpRequest&&(new XMLHttpRequest).upload),resize_image:function(){return o.can("access_binary")&&n.can("create_canvas")},select_file:function(){return n.can("use_fileinput")&&window.File},select_folder:function(){return o.can("select_file")&&("Chrome"===n.browser&&n.verComp(n.version,21,">=")||"Firefox"===n.browser&&n.verComp(n.version,42,">="))},select_multiple:function(){return!(!o.can("select_file")||"Safari"===n.browser&&"Windows"===n.os||"iOS"===n.os&&n.verComp(n.osVersion,"7.0.0",">")&&n.verComp(n.osVersion,"8.0.0","<"))},send_binary_string:u(window.XMLHttpRequest&&((new XMLHttpRequest).sendAsBinary||window.Uint8Array&&window.ArrayBuffer)),send_custom_headers:u(window.XMLHttpRequest),send_multipart:function(){return!!(window.XMLHttpRequest&&(new XMLHttpRequest).upload&&window.FormData)||o.can("send_binary_string")},slice_blob:u(window.File&&(File.prototype.mozSlice||File.prototype.webkitSlice||File.prototype.slice)),stream_upload:function(){return o.can("slice_blob")&&o.can("send_multipart")},summon_file_dialog:function(){return o.can("select_file")&&!("Firefox"===n.browser&&n.verComp(n.version,4,"<")||"Opera"===n.browser&&n.verComp(n.version,12,"<")||"IE"===n.browser&&n.verComp(n.version,10,"<"))},upload_filesize:c,use_http_method:c},arguments[2]);i.call(this,t,arguments[1]||a,l),e.extend(this,{init:function(){this.trigger("Init")},destroy:function(e){return function(){e.call(o),e=o=null}}(this.destroy)}),e.extend(this.getShim(),s)}var a="html5",s={};return i.addConstructor(a,o),s}),n("moxie/runtime/html5/file/Blob",["moxie/runtime/html5/Runtime","moxie/file/Blob"],function(e,t){function i(){function e(e,t,i){var n;if(!window.File.prototype.slice)return(n=window.File.prototype.webkitSlice||window.File.prototype.mozSlice)?n.call(e,t,i):null;try{return e.slice(),e.slice(t,i)}catch(r){return e.slice(t,i-t)}}this.slice=function(){return new t(this.getRuntime().uid,e.apply(this,arguments))},this.destroy=function(){this.getRuntime().getShim().removeInstance(this.uid)}}return e.Blob=i}),n("moxie/core/utils/Events",["moxie/core/utils/Basic"],function(e){function t(){this.returnValue=!1}function i(){this.cancelBubble=!0}var n={},r="moxie_"+e.guid(),o=function(o,a,s,u){var c,l;a=a.toLowerCase(),o.addEventListener?(c=s,o.addEventListener(a,c,!1)):o.attachEvent&&(c=function(){var e=window.event;e.target||(e.target=e.srcElement),e.preventDefault=t,e.stopPropagation=i,s(e)},o.attachEvent("on"+a,c)),o[r]||(o[r]=e.guid()),n.hasOwnProperty(o[r])||(n[o[r]]={}),l=n[o[r]],l.hasOwnProperty(a)||(l[a]=[]),l[a].push({func:c,orig:s,key:u})},a=function(t,i,o){var a,s;if(i=i.toLowerCase(),t[r]&&n[t[r]]&&n[t[r]][i]){a=n[t[r]][i];for(var u=a.length-1;u>=0&&(a[u].orig!==o&&a[u].key!==o||(t.removeEventListener?t.removeEventListener(i,a[u].func,!1):t.detachEvent&&t.detachEvent("on"+i,a[u].func),a[u].orig=null,a[u].func=null,a.splice(u,1),o===s));u--);if(a.length||delete n[t[r]][i],e.isEmptyObj(n[t[r]])){delete n[t[r]];try{delete t[r]}catch(c){t[r]=s}}}},s=function(t,i){t&&t[r]&&e.each(n[t[r]],function(e,n){a(t,n,i)})};return{addEvent:o,removeEvent:a,removeAllEvents:s}}),n("moxie/runtime/html5/file/FileInput",["moxie/runtime/html5/Runtime","moxie/file/File","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/utils/Events","moxie/core/utils/Mime","moxie/core/utils/Env"],function(e,t,i,n,r,o,a){function s(){var e,s;i.extend(this,{init:function(u){var c,l,d,m,h,f,p=this,g=p.getRuntime();e=u,d=o.extList2mimes(e.accept,g.can("filter_by_extension")),l=g.getShimContainer(),l.innerHTML='",c=n.get(g.uid),i.extend(c.style,{position:"absolute",top:0,left:0,width:"100%",height:"100%"}),m=n.get(e.browse_button),s=n.getStyle(m,"z-index")||"auto",g.can("summon_file_dialog")&&("static"===n.getStyle(m,"position")&&(m.style.position="relative"),r.addEvent(m,"click",function(e){var t=n.get(g.uid);t&&!t.disabled&&t.click(),e.preventDefault()},p.uid),p.bind("Refresh",function(){h=parseInt(s,10)||1,n.get(e.browse_button).style.zIndex=h,this.getRuntime().getShimContainer().style.zIndex=h-1})),f=g.can("summon_file_dialog")?m:l,r.addEvent(f,"mouseover",function(){p.trigger("mouseenter")},p.uid),r.addEvent(f,"mouseout",function(){p.trigger("mouseleave")},p.uid),r.addEvent(f,"mousedown",function(){p.trigger("mousedown")},p.uid),r.addEvent(n.get(e.container),"mouseup",function(){p.trigger("mouseup")},p.uid),(g.can("summon_file_dialog")?c:m).setAttribute("tabindex",-1),c.onchange=function x(){if(p.files=[],i.each(this.files,function(i){var n="";return e.directory&&"."==i.name?!0:(i.webkitRelativePath&&(n="/"+i.webkitRelativePath.replace(/^\//,"")),i=new t(g.uid,i),i.relativePath=n,p.files.push(i),void 0)}),"IE"!==a.browser&&"IEMobile"!==a.browser)this.value="";else{var n=this.cloneNode(!0);this.parentNode.replaceChild(n,this),n.onchange=x}p.files.length&&p.trigger("change")},p.trigger({type:"ready",async:!0}),l=null},setOption:function(e,t){var i=this.getRuntime(),r=n.get(i.uid);switch(e){case"accept":if(t){var a=t.mimes||o.extList2mimes(t,i.can("filter_by_extension"));r.setAttribute("accept",a.join(","))}else r.removeAttribute("accept");break;case"directory":t&&i.can("select_folder")?(r.setAttribute("directory",""),r.setAttribute("webkitdirectory","")):(r.removeAttribute("directory"),r.removeAttribute("webkitdirectory"));break;case"multiple":t&&i.can("select_multiple")?r.setAttribute("multiple",""):r.removeAttribute("multiple")}},disable:function(e){var t,i=this.getRuntime();(t=n.get(i.uid))&&(t.disabled=!!e)},destroy:function(){var t=this.getRuntime(),i=t.getShim(),o=t.getShimContainer(),a=e&&n.get(e.container),u=e&&n.get(e.browse_button);a&&r.removeAllEvents(a,this.uid),u&&(r.removeAllEvents(u,this.uid),u.style.zIndex=s),o&&(r.removeAllEvents(o,this.uid),o.innerHTML=""),i.removeInstance(this.uid),e=o=a=u=i=null}})}return e.FileInput=s}),n("moxie/runtime/html5/file/FileDrop",["moxie/runtime/html5/Runtime","moxie/file/File","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/utils/Events","moxie/core/utils/Mime"],function(e,t,i,n,r,o){function a(){function e(e){if(!e.dataTransfer||!e.dataTransfer.types)return!1;var t=i.toArray(e.dataTransfer.types||[]);return-1!==i.inArray("Files",t)||-1!==i.inArray("public.file-url",t)||-1!==i.inArray("application/x-moz-file",t)}function a(e,i){if(u(e)){var n=new t(f,e);n.relativePath=i||"",p.push(n)}}function s(e){for(var t=[],n=0;n=")&&u.verComp(u.version,7,"<"),f="Android Browser"===u.browser,p=!1;if(h=i.url.replace(/^.+?\/([\w\-\.]+)$/,"$1").toLowerCase(),m=c(),m.open(i.method,i.url,i.async,i.user,i.password),r instanceof o)r.isDetached()&&(p=!0),r=r.getSource();else if(r instanceof a){if(r.hasBlob())if(r.getBlob().isDetached())r=d.call(s,r),p=!0;else if((l||f)&&"blob"===t.typeOf(r.getBlob().getSource())&&window.FileReader)return e.call(s,i,r),void 0;if(r instanceof a){var g=new window.FormData;r.each(function(e,t){e instanceof o?g.append(t,e.getSource()):g.append(t,e)}),r=g}}m.upload?(i.withCredentials&&(m.withCredentials=!0),m.addEventListener("load",function(e){s.trigger(e)}),m.addEventListener("error",function(e){s.trigger(e)}),m.addEventListener("progress",function(e){s.trigger(e)}),m.upload.addEventListener("progress",function(e){s.trigger({type:"UploadProgress",loaded:e.loaded,total:e.total})})):m.onreadystatechange=function(){switch(m.readyState){case 1:break;case 2:break;case 3:var e,t;try{n.hasSameOrigin(i.url)&&(e=m.getResponseHeader("Content-Length")||0),m.responseText&&(t=m.responseText.length)}catch(r){e=t=0}s.trigger({type:"progress",lengthComputable:!!e,total:parseInt(e,10),loaded:t});break;case 4:m.onreadystatechange=function(){};try{if(m.status>=200&&m.status<400){s.trigger("load");break}}catch(r){}s.trigger("error")}},t.isEmptyObj(i.headers)||t.each(i.headers,function(e,t){m.setRequestHeader(t,e)}),""!==i.responseType&&"responseType"in m&&(m.responseType="json"!==i.responseType||u.can("return_response_type","json")?i.responseType:"text"),p?m.sendAsBinary?m.sendAsBinary(r):function(){for(var e=new Uint8Array(r.length),t=0;t0&&o.set(new Uint8Array(t.slice(0,e)),0),o.set(new Uint8Array(r),e),o.set(new Uint8Array(t.slice(e+n)),e+r.byteLength),this.clear(),t=o.buffer,i=new DataView(t);break}default:return t}},length:function(){return t?t.byteLength:0},clear:function(){i=t=null}})}function n(t){function i(e,i,n){n=3===arguments.length?n:t.length-i-1,t=t.substr(0,i)+e+t.substr(n+i)}e.extend(this,{readByteAt:function(e){return t.charCodeAt(e)},writeByteAt:function(e,t){i(String.fromCharCode(t),e,1)},SEGMENT:function(e,n,r){switch(arguments.length){case 1:return t.substr(e);case 2:return t.substr(e,n);case 3:i(null!==r?r:"",e,n);break;default:return t}},length:function(){return t?t.length:0},clear:function(){t=null}})}return e.extend(t.prototype,{littleEndian:!1,read:function(e,t){var i,n,r;if(e+t>this.length())throw new Error("You are trying to read outside the source boundaries.");for(n=this.littleEndian?0:-8*(t-1),r=0,i=0;t>r;r++)i|=this.readByteAt(e+r)<this.length())throw new Error("You are trying to write outside the source boundaries.");for(n=this.littleEndian?0:-8*(i-1),r=0;i>r;r++)this.writeByteAt(e+r,255&t>>Math.abs(n+8*r))},BYTE:function(e){return this.read(e,1)},SHORT:function(e){return this.read(e,2)},LONG:function(e){return this.read(e,4)},SLONG:function(e){var t=this.read(e,4);return t>2147483647?t-4294967296:t},CHAR:function(e){return String.fromCharCode(this.read(e,1))},STRING:function(e,t){return this.asArray("CHAR",e,t).join("")},asArray:function(e,t,i){for(var n=[],r=0;i>r;r++)n[r]=this[e](t+r);return n}}),t}),n("moxie/runtime/html5/image/JPEGHeaders",["moxie/runtime/html5/utils/BinaryReader","moxie/core/Exceptions"],function(e,t){return function i(n){var r,o,a,s=[],u=0;if(r=new e(n),65496!==r.SHORT(0))throw r.clear(),new t.ImageError(t.ImageError.WRONG_FORMAT);for(o=2;o<=r.length();)if(a=r.SHORT(o),a>=65488&&65495>=a)o+=2;else{if(65498===a||65497===a)break;u=r.SHORT(o+2)+2,a>=65505&&65519>=a&&s.push({hex:a,name:"APP"+(15&a),start:o,length:u,segment:r.SEGMENT(o,u)}),o+=u}return r.clear(),{headers:s,restore:function(t){var i,n,r;for(r=new e(t),o=65504==r.SHORT(2)?4+r.SHORT(4):2,n=0,i=s.length;i>n;n++)r.SEGMENT(o,0,s[n].segment),o+=s[n].length;return t=r.SEGMENT(),r.clear(),t},strip:function(t){var n,r,o,a;for(o=new i(t),r=o.headers,o.purge(),n=new e(t),a=r.length;a--;)n.SEGMENT(r[a].start,r[a].length,"");return t=n.SEGMENT(),n.clear(),t},get:function(e){for(var t=[],i=0,n=s.length;n>i;i++)s[i].name===e.toUpperCase()&&t.push(s[i].segment);return t},set:function(e,t){var i,n,r,o=[];for("string"==typeof t?o.push(t):o=t,i=n=0,r=s.length;r>i&&(s[i].name===e.toUpperCase()&&(s[i].segment=o[n],s[i].length=o[n].length,n++),!(n>=o.length));i++);},purge:function(){this.headers=s=[]}}}}),n("moxie/runtime/html5/image/ExifParser",["moxie/core/utils/Basic","moxie/runtime/html5/utils/BinaryReader","moxie/core/Exceptions"],function(e,i,n){function r(o){function a(i,r){var o,a,s,u,c,m,h,f,p=this,g=[],x={},v={1:"BYTE",7:"UNDEFINED",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",9:"SLONG",10:"SRATIONAL"},w={BYTE:1,UNDEFINED:1,ASCII:1,SHORT:2,LONG:4,RATIONAL:8,SLONG:4,SRATIONAL:8};for(o=p.SHORT(i),a=0;o>a;a++)if(g=[],h=i+2+12*a,s=r[p.SHORT(h)],s!==t){if(u=v[p.SHORT(h+=2)],c=p.LONG(h+=2),m=w[u],!m)throw new n.ImageError(n.ImageError.INVALID_META_ERR);if(h+=4,m*c>4&&(h=p.LONG(h)+d.tiffHeader),h+m*c>=this.length())throw new n.ImageError(n.ImageError.INVALID_META_ERR);"ASCII"!==u?(g=p.asArray(u,h,c),f=1==c?g[0]:g,x[s]=l.hasOwnProperty(s)&&"object"!=typeof f?l[s][f]:f):x[s]=e.trim(p.STRING(h,c).replace(/\0$/,""))}return x}function s(e,t,i){var n,r,o,a=0;if("string"==typeof t){var s=c[e.toLowerCase()];for(var u in s)if(s[u]===t){t=u;break}}n=d[e.toLowerCase()+"IFD"],r=this.SHORT(n);for(var l=0;r>l;l++)if(o=n+12*l+2,this.SHORT(o)==t){a=o+8;break}if(!a)return!1;try{this.write(a,i,4)}catch(m){return!1}return!0}var u,c,l,d,m,h;if(i.call(this,o),c={tiff:{274:"Orientation",270:"ImageDescription",271:"Make",272:"Model",305:"Software",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer"},exif:{36864:"ExifVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",36867:"DateTimeOriginal",33434:"ExposureTime",33437:"FNumber",34855:"ISOSpeedRatings",37377:"ShutterSpeedValue",37378:"ApertureValue",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37386:"FocalLength",41986:"ExposureMode",41987:"WhiteBalance",41990:"SceneCaptureType",41988:"DigitalZoomRatio",41992:"Contrast",41993:"Saturation",41994:"Sharpness"},gps:{0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude"},thumb:{513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength"}},l={ColorSpace:{1:"sRGB",0:"Uncalibrated"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{1:"Daylight",2:"Fliorescent",3:"Tungsten",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 -5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},ExposureMode:{0:"Auto exposure",1:"Manual exposure",2:"Auto bracket"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},GPSLatitudeRef:{N:"North latitude",S:"South latitude"},GPSLongitudeRef:{E:"East longitude",W:"West longitude"}},d={tiffHeader:10},m=d.tiffHeader,u={clear:this.clear},e.extend(this,{read:function(){try{return r.prototype.read.apply(this,arguments)}catch(e){throw new n.ImageError(n.ImageError.INVALID_META_ERR)}},write:function(){try{return r.prototype.write.apply(this,arguments)}catch(e){throw new n.ImageError(n.ImageError.INVALID_META_ERR)}},UNDEFINED:function(){return this.BYTE.apply(this,arguments)},RATIONAL:function(e){return this.LONG(e)/this.LONG(e+4)},SRATIONAL:function(e){return this.SLONG(e)/this.SLONG(e+4)},ASCII:function(e){return this.CHAR(e)},TIFF:function(){return h||null},EXIF:function(){var t=null;if(d.exifIFD){try{t=a.call(this,d.exifIFD,c.exif)}catch(i){return null}if(t.ExifVersion&&"array"===e.typeOf(t.ExifVersion)){for(var n=0,r="";n=65472&&65475>=t)return n+=5,{height:e.SHORT(n),width:e.SHORT(n+=2)};i=e.SHORT(n+=2),n+=i-2}return null}function s(){var e,t,i=d.thumb();return i&&(e=new n(i),t=a(e),e.clear(),t)?(t.data=i,t):null}function u(){d&&l&&c&&(d.clear(),l.purge(),c.clear(),m=l=d=c=null)}var c,l,d,m;if(c=new n(o),65496!==c.SHORT(0))throw new t.ImageError(t.ImageError.WRONG_FORMAT);l=new i(o);try{d=new r(l.get("app1")[0])}catch(h){}m=a.call(this),e.extend(this,{type:"image/jpeg",size:c.length(),width:m&&m.width||0,height:m&&m.height||0,setExif:function(t,i){return d?("object"===e.typeOf(t)?e.each(t,function(e,t){d.setExif(t,e)}):d.setExif(t,i),l.set("app1",d.SEGMENT()),void 0):!1},writeHeaders:function(){return arguments.length?l.restore(arguments[0]):l.restore(o)},stripHeaders:function(e){return l.strip(e)},purge:function(){u.call(this)}}),d&&(this.meta={tiff:d.TIFF(),exif:d.EXIF(),gps:d.GPS(),thumb:s()})}return o}),n("moxie/runtime/html5/image/PNG",["moxie/core/Exceptions","moxie/core/utils/Basic","moxie/runtime/html5/utils/BinaryReader"],function(e,t,i){function n(n){function r(){var e,t;return e=a.call(this,8),"IHDR"==e.type?(t=e.start,{width:s.LONG(t),height:s.LONG(t+=4)}):null}function o(){s&&(s.clear(),n=l=u=c=s=null)}function a(e){var t,i,n,r;return t=s.LONG(e),i=s.STRING(e+=4,4),n=e+=4,r=s.LONG(e+t),{length:t,type:i,start:n,CRC:r}}var s,u,c,l;s=new i(n),function(){var t=0,i=0,n=[35152,20039,3338,6666];for(i=0;ii.height?"width":"height",a=Math.round(i[o]*n),s=!1;"nearest"!==r&&(.5>n||n>2)&&(n=.5>n?.5:2,s=!0);var u=t(i,n);return s?e(u,a/u[o],r):u}function t(e,t){var i=e.width,n=e.height,r=Math.round(i*t),o=Math.round(n*t),a=document.createElement("canvas");return a.width=r,a.height=o,a.getContext("2d").drawImage(e,0,0,i,n,0,0,r,o),e=null,a}return{scale:e}}),n("moxie/runtime/html5/image/Image",["moxie/runtime/html5/Runtime","moxie/core/utils/Basic","moxie/core/Exceptions","moxie/core/utils/Encode","moxie/file/Blob","moxie/file/File","moxie/runtime/html5/image/ImageInfo","moxie/runtime/html5/image/ResizerCanvas","moxie/core/utils/Mime","moxie/core/utils/Env"],function(e,t,i,n,r,o,a,s,u){function c(){function e(){if(!v&&!g)throw new i.ImageError(i.DOMException.INVALID_STATE_ERR);return v||g}function c(){var t=e();return"canvas"==t.nodeName.toLowerCase()?t:(v=document.createElement("canvas"),v.width=t.width,v.height=t.height,v.getContext("2d").drawImage(t,0,0),v)}function l(e){return n.atob(e.substring(e.indexOf("base64,")+7))}function d(e,t){return"data:"+(t||"")+";base64,"+n.btoa(e)}function m(e){var t=this;g=new Image,g.onerror=function(){p.call(this),t.trigger("error",i.ImageError.WRONG_FORMAT)},g.onload=function(){t.trigger("load")},g.src="data:"==e.substr(0,5)?e:d(e,y.type)}function h(e,t){var n,r=this;return window.FileReader?(n=new FileReader,n.onload=function(){t.call(r,this.result)},n.onerror=function(){r.trigger("error",i.ImageError.WRONG_FORMAT)},n.readAsDataURL(e),void 0):t.call(this,e.getAsDataURL())}function f(e,i){var n=Math.PI/180,r=document.createElement("canvas"),o=r.getContext("2d"),a=e.width,s=e.height;switch(t.inArray(i,[5,6,7,8])>-1?(r.width=s,r.height=a):(r.width=a,r.height=s),i){case 2:o.translate(a,0),o.scale(-1,1);break;case 3:o.translate(a,s),o.rotate(180*n);break;case 4:o.translate(0,s),o.scale(1,-1);break;case 5:o.rotate(90*n),o.scale(1,-1);break;case 6:o.rotate(90*n),o.translate(0,-s);break;case 7:o.rotate(90*n),o.translate(a,-s),o.scale(-1,1);break;case 8:o.rotate(-90*n),o.translate(-a,0)}return o.drawImage(e,0,0,a,s),r}function p(){x&&(x.purge(),x=null),w=g=v=y=null,b=!1}var g,x,v,w,y,E=this,b=!1,_=!0;t.extend(this,{loadFromBlob:function(e){var t=this.getRuntime(),n=arguments.length>1?arguments[1]:!0;if(!t.can("access_binary"))throw new i.RuntimeError(i.RuntimeError.NOT_SUPPORTED_ERR);return y=e,e.isDetached()?(w=e.getSource(),m.call(this,w),void 0):(h.call(this,e.getSource(),function(e){n&&(w=l(e)),m.call(this,e)}),void 0)},loadFromImage:function(e,t){this.meta=e.meta,y=new o(null,{name:e.name,size:e.size,type:e.type}),m.call(this,t?w=e.getAsBinaryString():e.getAsDataURL())},getInfo:function(){var t,i=this.getRuntime();return!x&&w&&i.can("access_image_binary")&&(x=new a(w)),t={width:e().width||0,height:e().height||0,type:y.type||u.getFileMime(y.name),size:w&&w.length||y.size||0,name:y.name||"",meta:null},_&&(t.meta=x&&x.meta||this.meta||{},!t.meta||!t.meta.thumb||t.meta.thumb.data instanceof r||(t.meta.thumb.data=new r(null,{type:"image/jpeg",data:t.meta.thumb.data}))),t},resize:function(t,i,n){var r=document.createElement("canvas");if(r.width=t.width,r.height=t.height,r.getContext("2d").drawImage(e(),t.x,t.y,t.width,t.height,0,0,r.width,r.height),v=s.scale(r,i),_=n.preserveHeaders,!_){var o=this.meta&&this.meta.tiff&&this.meta.tiff.Orientation||1;v=f(v,o)}this.width=v.width,this.height=v.height,b=!0,this.trigger("Resize")},getAsCanvas:function(){return v||(v=c()),v.id=this.uid+"_canvas",v},getAsBlob:function(e,t){return e!==this.type?(b=!0,new o(null,{name:y.name||"",type:e,data:E.getAsDataURL(e,t)})):new o(null,{name:y.name||"",type:e,data:E.getAsBinaryString(e,t)})},getAsDataURL:function(e){var t=arguments[1]||90;if(!b)return g.src;if(c(),"image/jpeg"!==e)return v.toDataURL("image/png");try{return v.toDataURL("image/jpeg",t/100)}catch(i){return v.toDataURL("image/jpeg")}},getAsBinaryString:function(e,t){if(!b)return w||(w=l(E.getAsDataURL(e,t))),w;if("image/jpeg"!==e)w=l(E.getAsDataURL(e,t));else{var i;t||(t=90),c();try{i=v.toDataURL("image/jpeg",t/100)}catch(n){i=v.toDataURL("image/jpeg")}w=l(i),x&&(w=x.stripHeaders(w),_&&(x.meta&&x.meta.exif&&x.setExif({PixelXDimension:this.width,PixelYDimension:this.height}),w=x.writeHeaders(w)),x.purge(),x=null)}return b=!1,w},destroy:function(){E=null,p.call(this),this.getRuntime().getShim().removeInstance(this.uid)}})}return e.Image=c}),n("moxie/runtime/flash/Runtime",["moxie/core/utils/Basic","moxie/core/utils/Env","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/runtime/Runtime"],function(e,t,i,n,o){function a(){var e;try{e=navigator.plugins["Shockwave Flash"],e=e.description}catch(t){try{e=new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version")}catch(i){e="0.0"}}return e=e.match(/\d+/g),parseFloat(e[0]+"."+e[1])}function s(e){var n=i.get(e);n&&"OBJECT"==n.nodeName&&("IE"===t.browser?(n.style.display="none",function r(){4==n.readyState?u(e):setTimeout(r,10)}()):n.parentNode.removeChild(n))}function u(e){var t=i.get(e);if(t){for(var n in t)"function"==typeof t[n]&&(t[n]=null);t.parentNode.removeChild(t)}}function c(u){var c,m=this;u=e.extend({swf_url:t.swf_url},u),o.call(this,u,l,{access_binary:function(e){return e&&"browser"===m.mode},access_image_binary:function(e){return e&&"browser"===m.mode},display_media:o.capTest(r("moxie/image/Image")),do_cors:o.capTrue,drag_and_drop:!1,report_upload_progress:function(){return"client"===m.mode},resize_image:o.capTrue,return_response_headers:!1,return_response_type:function(t){return"json"===t&&window.JSON?!0:!e.arrayDiff(t,["","text","document"])||"browser"===m.mode},return_status_code:function(t){return"browser"===m.mode||!e.arrayDiff(t,[200,404])},select_file:o.capTrue,select_multiple:o.capTrue,send_binary_string:function(e){return e&&"browser"===m.mode},send_browser_cookies:function(e){return e&&"browser"===m.mode},send_custom_headers:function(e){return e&&"browser"===m.mode},send_multipart:o.capTrue,slice_blob:function(e){return e&&"browser"===m.mode},stream_upload:function(e){return e&&"browser"===m.mode},summon_file_dialog:!1,upload_filesize:function(t){return e.parseSizeStr(t)<=2097152||"client"===m.mode},use_http_method:function(t){return!e.arrayDiff(t,["GET","POST"])}},{access_binary:function(e){return e?"browser":"client"},access_image_binary:function(e){return e?"browser":"client"},report_upload_progress:function(e){return e?"browser":"client"},return_response_type:function(t){return e.arrayDiff(t,["","text","json","document"])?"browser":["client","browser"]},return_status_code:function(t){return e.arrayDiff(t,[200,404])?"browser":["client","browser"]},send_binary_string:function(e){return e?"browser":"client"},send_browser_cookies:function(e){return e?"browser":"client"},send_custom_headers:function(e){return e?"browser":"client"},slice_blob:function(e){return e?"browser":"client"},stream_upload:function(e){return e?"client":"browser"},upload_filesize:function(t){return e.parseSizeStr(t)>=2097152?"client":"browser"}},"client"),a()<11.3&&(this.mode=!1),e.extend(this,{getShim:function(){return i.get(this.uid)},shimExec:function(e,t){var i=[].slice.call(arguments,2);return m.getShim().exec(this.uid,e,t,i)},init:function(){var i,r,a;a=this.getShimContainer(),e.extend(a.style,{position:"absolute",top:"-8px",left:"-8px",width:"9px",height:"9px",overflow:"hidden"}),i=''+''+''+''+"","IE"===t.browser?(r=document.createElement("div"),a.appendChild(r),r.outerHTML=i,r=a=null):a.innerHTML=i,c=setTimeout(function(){m&&!m.initialized&&m.trigger("Error",new n.RuntimeError(n.RuntimeError.NOT_INIT_ERR))},5e3)},destroy:function(e){return function(){s(m.uid),e.call(m),clearTimeout(c),u=c=e=m=null}}(this.destroy)},d)}var l="flash",d={};return o.addConstructor(l,c),d}),n("moxie/runtime/flash/file/Blob",["moxie/runtime/flash/Runtime","moxie/file/Blob"],function(e,t){var i={slice:function(e,i,n,r){var o=this.getRuntime();return 0>i?i=Math.max(e.size+i,0):i>0&&(i=Math.min(i,e.size)),0>n?n=Math.max(e.size+n,0):n>0&&(n=Math.min(n,e.size)),e=o.shimExec.call(this,"Blob","slice",i,n,r||""),e&&(e=new t(o.uid,e)),e}};return e.Blob=i}),n("moxie/runtime/flash/file/FileInput",["moxie/runtime/flash/Runtime","moxie/file/File","moxie/core/utils/Dom","moxie/core/utils/Basic"],function(e,t,i,n){var r={init:function(e){var r=this,o=this.getRuntime(),a=i.get(e.browse_button);a&&(a.setAttribute("tabindex",-1),a=null),this.bind("Change",function(){var e=o.shimExec.call(r,"FileInput","getFiles");r.files=[],n.each(e,function(e){r.files.push(new t(o.uid,e))})},999),this.getRuntime().shimExec.call(this,"FileInput","init",{accept:e.accept,multiple:e.multiple}),this.trigger("ready")}};return e.FileInput=r}),n("moxie/runtime/flash/file/FileReader",["moxie/runtime/flash/Runtime","moxie/core/utils/Encode"],function(e,t){function i(e,i){switch(i){case"readAsText":return t.atob(e,"utf8");case"readAsBinaryString":return t.atob(e);case"readAsDataURL":return e}return null}var n={read:function(e,t){var n=this;return n.result="","readAsDataURL"===e&&(n.result="data:"+(t.type||"")+";base64,"),n.bind("Progress",function(t,r){r&&(n.result+=i(r,e))},999),n.getRuntime().shimExec.call(this,"FileReader","readAsBase64",t.uid)}};return e.FileReader=n}),n("moxie/runtime/flash/file/FileReaderSync",["moxie/runtime/flash/Runtime","moxie/core/utils/Encode"],function(e,t){function i(e,i){switch(i){case"readAsText":return t.atob(e,"utf8");case"readAsBinaryString":return t.atob(e);case"readAsDataURL":return e}return null}var n={read:function(e,t){var n,r=this.getRuntime();return(n=r.shimExec.call(this,"FileReaderSync","readAsBase64",t.uid))?("readAsDataURL"===e&&(n="data:"+(t.type||"")+";base64,"+n),i(n,e,t.type)):null}};return e.FileReaderSync=n}),n("moxie/runtime/flash/runtime/Transporter",["moxie/runtime/flash/Runtime","moxie/file/Blob"],function(e,t){var i={getAsBlob:function(e){var i=this.getRuntime(),n=i.shimExec.call(this,"Transporter","getAsBlob",e);return n?new t(i.uid,n):null}};return e.Transporter=i}),n("moxie/runtime/flash/xhr/XMLHttpRequest",["moxie/runtime/flash/Runtime","moxie/core/utils/Basic","moxie/file/Blob","moxie/file/File","moxie/file/FileReaderSync","moxie/runtime/flash/file/FileReaderSync","moxie/xhr/FormData","moxie/runtime/Transporter","moxie/runtime/flash/runtime/Transporter"],function(e,t,i,n,r,o,a,s){var u={send:function(e,n){function r(){e.transport=l.mode,l.shimExec.call(c,"XMLHttpRequest","send",e,n)}function o(e,t){l.shimExec.call(c,"XMLHttpRequest","appendBlob",e,t.uid),n=null,r()}function u(e,t){var i=new s;i.bind("TransportingComplete",function(){t(this.result)}),i.transport(e.getSource(),e.type,{ruid:l.uid})}var c=this,l=c.getRuntime();if(t.isEmptyObj(e.headers)||t.each(e.headers,function(e,t){l.shimExec.call(c,"XMLHttpRequest","setRequestHeader",t,e.toString())}),n instanceof a){var d;if(n.each(function(e,t){e instanceof i?d=t:l.shimExec.call(c,"XMLHttpRequest","append",t,e)}),n.hasBlob()){var m=n.getBlob();m.isDetached()?u(m,function(e){m.destroy(),o(d,e)}):o(d,m)}else n=null,r()}else n instanceof i?n.isDetached()?u(n,function(e){n.destroy(),n=e.uid,r()}):(n=n.uid,r()):r()},getResponse:function(e){var i,o,a=this.getRuntime();if(o=a.shimExec.call(this,"XMLHttpRequest","getResponseAsBlob")){if(o=new n(a.uid,o),"blob"===e)return o;try{if(i=new r,~t.inArray(e,["","text"]))return i.readAsText(o);if("json"===e&&window.JSON)return JSON.parse(i.readAsText(o))}finally{o.destroy()}}return null},abort:function(){var e=this.getRuntime();e.shimExec.call(this,"XMLHttpRequest","abort"),this.dispatchEvent("readystatechange"),this.dispatchEvent("abort")}};return e.XMLHttpRequest=u}),n("moxie/runtime/flash/image/Image",["moxie/runtime/flash/Runtime","moxie/core/utils/Basic","moxie/runtime/Transporter","moxie/file/Blob","moxie/file/FileReaderSync"],function(e,t,i,n,r){var o={loadFromBlob:function(e){function t(e){r.shimExec.call(n,"Image","loadFromBlob",e.uid),n=r=null}var n=this,r=n.getRuntime();if(e.isDetached()){var o=new i;o.bind("TransportingComplete",function(){t(o.result.getSource())}),o.transport(e.getSource(),e.type,{ruid:r.uid})}else t(e.getSource())},loadFromImage:function(e){var t=this.getRuntime();return t.shimExec.call(this,"Image","loadFromImage",e.uid)},getInfo:function(){var e=this.getRuntime(),t=e.shimExec.call(this,"Image","getInfo");return t.meta&&t.meta.thumb&&t.meta.thumb.data&&!(e.meta.thumb.data instanceof n)&&(t.meta.thumb.data=new n(e.uid,t.meta.thumb.data)),t},getAsBlob:function(e,t){var i=this.getRuntime(),r=i.shimExec.call(this,"Image","getAsBlob",e,t);return r?new n(i.uid,r):null},getAsDataURL:function(){var e,t=this.getRuntime(),i=t.Image.getAsBlob.apply(this,arguments);return i?(e=new r,e.readAsDataURL(i)):null}};return e.Image=o}),n("moxie/runtime/silverlight/Runtime",["moxie/core/utils/Basic","moxie/core/utils/Env","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/runtime/Runtime"],function(e,t,i,n,o){function a(e){var t,i,n,r,o,a=!1,s=null,u=0;try{try{s=new ActiveXObject("AgControl.AgControl"),s.IsVersionSupported(e)&&(a=!0),s=null}catch(c){var l=navigator.plugins["Silverlight Plug-In"];if(l){for(t=l.description,"1.0.30226.2"===t&&(t="2.0.30226.2"),i=t.split(".");i.length>3;)i.pop();for(;i.length<4;)i.push(0);for(n=e.split(".");n.length>4;)n.pop();do r=parseInt(n[u],10),o=parseInt(i[u],10),u++;while(u=r&&!isNaN(r)&&(a=!0)}}}catch(d){a=!1}return a}function s(s){var l,d=this;s=e.extend({xap_url:t.xap_url},s),o.call(this,s,u,{access_binary:o.capTrue,access_image_binary:o.capTrue,display_media:o.capTest(r("moxie/image/Image")),do_cors:o.capTrue,drag_and_drop:!1,report_upload_progress:o.capTrue,resize_image:o.capTrue,return_response_headers:function(e){return e&&"client"===d.mode},return_response_type:function(e){return"json"!==e?!0:!!window.JSON},return_status_code:function(t){return"client"===d.mode||!e.arrayDiff(t,[200,404])},select_file:o.capTrue,select_multiple:o.capTrue,send_binary_string:o.capTrue,send_browser_cookies:function(e){return e&&"browser"===d.mode},send_custom_headers:function(e){return e&&"client"===d.mode},send_multipart:o.capTrue,slice_blob:o.capTrue,stream_upload:!0,summon_file_dialog:!1,upload_filesize:o.capTrue,use_http_method:function(t){return"client"===d.mode||!e.arrayDiff(t,["GET","POST"])}},{return_response_headers:function(e){return e?"client":"browser"},return_status_code:function(t){return e.arrayDiff(t,[200,404])?"client":["client","browser"]},send_browser_cookies:function(e){return e?"browser":"client"},send_custom_headers:function(e){return e?"client":"browser"},use_http_method:function(t){return e.arrayDiff(t,["GET","POST"])?"client":["client","browser"]}}),a("2.0.31005.0")&&"Opera"!==t.browser||(this.mode=!1),e.extend(this,{getShim:function(){return i.get(this.uid).content.Moxie},shimExec:function(e,t){var i=[].slice.call(arguments,2);return d.getShim().exec(this.uid,e,t,i)},init:function(){var e;e=this.getShimContainer(),e.innerHTML=''+''+''+''+''+''+"",l=setTimeout(function(){d&&!d.initialized&&d.trigger("Error",new n.RuntimeError(n.RuntimeError.NOT_INIT_ERR))},"Windows"!==t.OS?1e4:5e3)},destroy:function(e){return function(){e.call(d),clearTimeout(l),s=l=e=d=null}}(this.destroy)},c)}var u="silverlight",c={};return o.addConstructor(u,s),c}),n("moxie/runtime/silverlight/file/Blob",["moxie/runtime/silverlight/Runtime","moxie/core/utils/Basic","moxie/runtime/flash/file/Blob"],function(e,t,i){return e.Blob=t.extend({},i)}),n("moxie/runtime/silverlight/file/FileInput",["moxie/runtime/silverlight/Runtime","moxie/file/File","moxie/core/utils/Dom","moxie/core/utils/Basic"],function(e,t,i,n){function r(e){for(var t="",i=0;ii;i++)t=s.keys[i],a=s[t],a&&(/^(\d|[1-9]\d+)$/.test(a)?a=parseInt(a,10):/^\d*\.\d+$/.test(a)&&(a=parseFloat(a)),r.meta[e][t]=a)}),r.meta&&r.meta.thumb&&r.meta.thumb.data&&!(e.meta.thumb.data instanceof i)&&(r.meta.thumb.data=new i(e.uid,r.meta.thumb.data))),r.width=parseInt(o.width,10),r.height=parseInt(o.height,10),r.size=parseInt(o.size,10),r.type=o.type,r.name=o.name,r},resize:function(e,t,i){this.getRuntime().shimExec.call(this,"Image","resize",e.x,e.y,e.width,e.height,t,i.preserveHeaders,i.resample)}})}),n("moxie/runtime/html4/Runtime",["moxie/core/utils/Basic","moxie/core/Exceptions","moxie/runtime/Runtime","moxie/core/utils/Env"],function(e,t,i,n){function o(t){var o=this,u=i.capTest,c=i.capTrue;i.call(this,t,a,{access_binary:u(window.FileReader||window.File&&File.getAsDataURL),access_image_binary:!1,display_media:u((n.can("create_canvas")||n.can("use_data_uri_over32kb"))&&r("moxie/image/Image")),do_cors:!1,drag_and_drop:!1,filter_by_extension:u(function(){return!("Chrome"===n.browser&&n.verComp(n.version,28,"<")||"IE"===n.browser&&n.verComp(n.version,10,"<")||"Safari"===n.browser&&n.verComp(n.version,11,"<=")||"Firefox"===n.browser&&n.verComp(n.version,37,"<")||"iOS"===n.os||"Android"===n.os)}()),resize_image:function(){return s.Image&&o.can("access_binary")&&n.can("create_canvas")},report_upload_progress:!1,return_response_headers:!1,return_response_type:function(t){return"json"===t&&window.JSON?!0:!!~e.inArray(t,["text","document",""])},return_status_code:function(t){return!e.arrayDiff(t,[200,404])},select_file:function(){return n.can("use_fileinput")},select_multiple:!1,send_binary_string:!1,send_custom_headers:!1,send_multipart:!0,slice_blob:!1,stream_upload:function(){return o.can("select_file")},summon_file_dialog:function(){return o.can("select_file")&&!("Firefox"===n.browser&&n.verComp(n.version,4,"<")||"Opera"===n.browser&&n.verComp(n.version,12,"<")||"IE"===n.browser&&n.verComp(n.version,10,"<"))},upload_filesize:c,use_http_method:function(t){return!e.arrayDiff(t,["GET","POST"])}}),e.extend(this,{init:function(){this.trigger("Init")},destroy:function(e){return function(){e.call(o),e=o=null}}(this.destroy)}),e.extend(this.getShim(),s)}var a="html4",s={};return i.addConstructor(a,o),s}),n("moxie/runtime/html4/file/FileInput",["moxie/runtime/html4/Runtime","moxie/file/File","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/utils/Events","moxie/core/utils/Mime","moxie/core/utils/Env"],function(e,t,i,n,r,o,a){function s(){function e(){var o,c,d,m,h,f,p=this,g=p.getRuntime();f=i.guid("uid_"),o=g.getShimContainer(),s&&(d=n.get(s+"_form"),d&&(i.extend(d.style,{top:"100%"}),d.firstChild.setAttribute("tabindex",-1))),m=document.createElement("form"),m.setAttribute("id",f+"_form"),m.setAttribute("method","post"),m.setAttribute("enctype","multipart/form-data"),m.setAttribute("encoding","multipart/form-data"),i.extend(m.style,{overflow:"hidden",position:"absolute",top:0,left:0,width:"100%",height:"100%"}),h=document.createElement("input"),h.setAttribute("id",f),h.setAttribute("type","file"),h.setAttribute("accept",l.join(",")),g.can("summon_file_dialog")&&h.setAttribute("tabindex",-1),i.extend(h.style,{fontSize:"999px",opacity:0}),m.appendChild(h),o.appendChild(m),i.extend(h.style,{position:"absolute",top:0,left:0,width:"100%",height:"100%"}),"IE"===a.browser&&a.verComp(a.version,10,"<")&&i.extend(h.style,{filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=0)"}),h.onchange=function(){var i;this.value&&(i=this.files?this.files[0]:{name:this.value},i=new t(g.uid,i),this.onchange=function(){},e.call(p),p.files=[i],h.setAttribute("id",i.uid),m.setAttribute("id",i.uid+"_form"),p.trigger("change"),h=m=null)},g.can("summon_file_dialog")&&(c=n.get(u.browse_button),r.removeEvent(c,"click",p.uid),r.addEvent(c,"click",function(e){h&&!h.disabled&&h.click(),e.preventDefault()},p.uid)),s=f,o=d=c=null}var s,u,c,l=[];i.extend(this,{init:function(t){var i,a=this,s=a.getRuntime();u=t,l=o.extList2mimes(t.accept,s.can("filter_by_extension")),i=s.getShimContainer(),function(){var e,o,l;e=n.get(t.browse_button),c=n.getStyle(e,"z-index")||"auto",s.can("summon_file_dialog")?("static"===n.getStyle(e,"position")&&(e.style.position="relative"),a.bind("Refresh",function(){o=parseInt(c,10)||1,n.get(u.browse_button).style.zIndex=o,this.getRuntime().getShimContainer().style.zIndex=o-1})):e.setAttribute("tabindex",-1),l=s.can("summon_file_dialog")?e:i,r.addEvent(l,"mouseover",function(){a.trigger("mouseenter")},a.uid),r.addEvent(l,"mouseout",function(){a.trigger("mouseleave")},a.uid),r.addEvent(l,"mousedown",function(){a.trigger("mousedown")},a.uid),r.addEvent(n.get(t.container),"mouseup",function(){a.trigger("mouseup")},a.uid),e=null}(),e.call(this),i=null,a.trigger({type:"ready",async:!0})},setOption:function(e,t){var i,r=this.getRuntime();"accept"==e&&(l=t.mimes||o.extList2mimes(t,r.can("filter_by_extension"))),i=n.get(s),i&&i.setAttribute("accept",l.join(","))},disable:function(e){var t;(t=n.get(s))&&(t.disabled=!!e)},destroy:function(){var e=this.getRuntime(),t=e.getShim(),i=e.getShimContainer(),o=u&&n.get(u.container),a=u&&n.get(u.browse_button);o&&r.removeAllEvents(o,this.uid),a&&(r.removeAllEvents(a,this.uid),a.style.zIndex=c),i&&(r.removeAllEvents(i,this.uid),i.innerHTML=""),t.removeInstance(this.uid),s=l=u=i=o=a=t=null}})}return e.FileInput=s}),n("moxie/runtime/html4/file/FileReader",["moxie/runtime/html4/Runtime","moxie/runtime/html5/file/FileReader"],function(e,t){return e.FileReader=t}),n("moxie/runtime/html4/xhr/XMLHttpRequest",["moxie/runtime/html4/Runtime","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/utils/Url","moxie/core/Exceptions","moxie/core/utils/Events","moxie/file/Blob","moxie/xhr/FormData"],function(e,t,i,n,r,o,a,s){function u(){function e(e){var t,n,r,a,s=this,u=!1;if(l){if(t=l.id.replace(/_iframe$/,""),n=i.get(t+"_form")){for(r=n.getElementsByTagName("input"),a=r.length;a--;)switch(r[a].getAttribute("type")){case"hidden":r[a].parentNode.removeChild(r[a]);break;case"file":u=!0}r=[],u||n.parentNode.removeChild(n),n=null}setTimeout(function(){o.removeEvent(l,"load",s.uid),l.parentNode&&l.parentNode.removeChild(l);var t=s.getRuntime().getShimContainer();t.children.length||t.parentNode.removeChild(t),t=l=null,e()},1)}}var u,c,l;t.extend(this,{send:function(d,m){function h(){var i=w.getShimContainer()||document.body,r=document.createElement("div");r.innerHTML='',l=r.firstChild,i.appendChild(l),o.addEvent(l,"load",function(){var i;try{i=l.contentWindow.document||l.contentDocument||window.frames[l.id].document,/^4(0[0-9]|1[0-7]|2[2346])\s/.test(i.title)?u=i.title.replace(/^(\d+).*$/,"$1"):(u=200,c=t.trim(i.body.innerHTML),v.trigger({type:"progress",loaded:c.length,total:c.length}),x&&v.trigger({type:"uploadprogress",loaded:x.size||1025,total:x.size||1025}))}catch(r){if(!n.hasSameOrigin(d.url))return e.call(v,function(){v.trigger("error")}),void 0;u=404}e.call(v,function(){v.trigger("load")})},v.uid)}var f,p,g,x,v=this,w=v.getRuntime();if(u=c=null,m instanceof s&&m.hasBlob()){if(x=m.getBlob(),f=x.uid,g=i.get(f),p=i.get(f+"_form"),!p)throw new r.DOMException(r.DOMException.NOT_FOUND_ERR)}else f=t.guid("uid_"),p=document.createElement("form"),p.setAttribute("id",f+"_form"),p.setAttribute("method",d.method),p.setAttribute("enctype","multipart/form-data"),p.setAttribute("encoding","multipart/form-data"),w.getShimContainer().appendChild(p);p.setAttribute("target",f+"_iframe"),m instanceof s&&m.each(function(e,i){if(e instanceof a)g&&g.setAttribute("name",i);else{var n=document.createElement("input");t.extend(n,{type:"hidden",name:i,value:e}),g?p.insertBefore(n,g):p.appendChild(n)}}),p.setAttribute("action",d.url),h(),p.submit(),v.trigger("loadstart")},getStatus:function(){return u},getResponse:function(e){if("json"===e&&"string"===t.typeOf(c)&&window.JSON)try{return JSON.parse(c.replace(/^\s*]*>/,"").replace(/<\/pre>\s*$/,""))}catch(i){return null}return c},abort:function(){var t=this;l&&l.contentWindow&&(l.contentWindow.stop?l.contentWindow.stop():l.contentWindow.document.execCommand?l.contentWindow.document.execCommand("Stop"):l.src="about:blank"),e.call(this,function(){t.dispatchEvent("abort")})},destroy:function(){this.getRuntime().getShim().removeInstance(this.uid)}})}return e.XMLHttpRequest=u}),n("moxie/runtime/html4/image/Image",["moxie/runtime/html4/Runtime","moxie/runtime/html5/image/Image"],function(e,t){return e.Image=t}),a(["moxie/core/utils/Basic","moxie/core/utils/Encode","moxie/core/utils/Env","moxie/core/Exceptions","moxie/core/utils/Dom","moxie/core/EventTarget","moxie/runtime/Runtime","moxie/runtime/RuntimeClient","moxie/file/Blob","moxie/core/I18n","moxie/core/utils/Mime","moxie/file/FileInput","moxie/file/File","moxie/file/FileDrop","moxie/file/FileReader","moxie/core/utils/Url","moxie/runtime/RuntimeTarget","moxie/xhr/FormData","moxie/xhr/XMLHttpRequest","moxie/image/Image","moxie/core/utils/Events","moxie/runtime/html5/image/ResizerCanvas"])}(this)}); \ No newline at end of file diff --git a/assets/javascripts/plupload/js/plupload.dev.js b/assets/javascripts/plupload/js/plupload.dev.js deleted file mode 100644 index 6e799956..00000000 --- a/assets/javascripts/plupload/js/plupload.dev.js +++ /dev/null @@ -1,4388 +0,0 @@ -/** - * Plupload - multi-runtime File Uploader - * v3.1.2 - * - * Copyright 2018, Ephox - * Released under AGPLv3 License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - * - * Date: 2018-02-20 - */ -;(function (global, factory) { - var extract = function() { - var ctx = {}; - factory.apply(ctx, arguments); - return ctx.plupload; - }; - - if (typeof define === "function" && define.amd) { - define("plupload", ['./moxie'], extract); - } else if (typeof module === "object" && module.exports) { - module.exports = extract(require('./moxie')); - } else { - global.plupload = extract(global.moxie); - } -}(this || window, function(moxie) { -/** - * Compiled inline version. (Library mode) - */ - -/*jshint smarttabs:true, undef:true, latedef:true, curly:true, bitwise:true, camelcase:true */ -/*globals $code */ - -(function(exports, undefined) { - "use strict"; - - var modules = {}; - - function require(ids, callback) { - var module, defs = []; - - for (var i = 0; i < ids.length; ++i) { - module = modules[ids[i]] || resolve(ids[i]); - if (!module) { - throw 'module definition dependecy not found: ' + ids[i]; - } - - defs.push(module); - } - - callback.apply(null, defs); - } - - function define(id, dependencies, definition) { - if (typeof id !== 'string') { - throw 'invalid module definition, module id must be defined and be a string'; - } - - if (dependencies === undefined) { - throw 'invalid module definition, dependencies must be specified'; - } - - if (definition === undefined) { - throw 'invalid module definition, definition function must be specified'; - } - - require(dependencies, function() { - modules[id] = definition.apply(null, arguments); - }); - } - - function defined(id) { - return !!modules[id]; - } - - function resolve(id) { - var target = exports; - var fragments = id.split(/[.\/]/); - - for (var fi = 0; fi < fragments.length; ++fi) { - if (!target[fragments[fi]]) { - return; - } - - target = target[fragments[fi]]; - } - - return target; - } - - function expose(ids) { - for (var i = 0; i < ids.length; i++) { - var target = exports; - var id = ids[i]; - var fragments = id.split(/[.\/]/); - - for (var fi = 0; fi < fragments.length - 1; ++fi) { - if (target[fragments[fi]] === undefined) { - target[fragments[fi]] = {}; - } - - target = target[fragments[fi]]; - } - - target[fragments[fragments.length - 1]] = modules[id]; - } - } - -// Included from: src/plupload.js - -/** - * plupload.js - * - * Copyright 2017, Ephox - * Released under AGPLv3 License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -Namespace for all Plupload related classes, methods and properties. - -@class plupload -@public -@static -*/ -define('plupload', [], function() { - - var o = moxie; - var u = o.core.utils; - - // redifine event dispatcher for Flash/Silverlight runtimes - u.Env.global_event_dispatcher = 'plupload.EventTarget.instance.dispatchEvent'; - - - return { - /** - * Plupload version will be replaced on build. - * - * @property VERSION - * @static - * @final - */ - VERSION: '3.1.2', - - /** - * The state of the queue before it has started and after it has finished - * - * @property STOPPED - * @static - * @final - */ - STOPPED: 1, - - /** - * Upload process is running - * - * @property STARTED - * @static - * @final - */ - STARTED: 2, - - /** - File is queued for upload - - @property QUEUED - @static - @final - */ - QUEUED: 1, - - /** - File is being uploaded - - @property UPLOADING - @static - @final - */ - UPLOADING: 2, - - /** - File has failed to be uploaded - - @property FAILED - @static - @final - */ - FAILED: 4, - - /** - File has been uploaded successfully - - @property DONE - @static - @final - */ - DONE: 5, - - // Error constants used by the Error event - - /** - * Generic error for example if an exception is thrown inside Silverlight. - * - * @property GENERIC_ERROR - * @static - * @final - */ - GENERIC_ERROR: -100, - - /** - * HTTP transport error. For example if the server produces a HTTP status other than 200. - * - * @property HTTP_ERROR - * @static - * @final - */ - HTTP_ERROR: -200, - - /** - * Generic I/O error. For example if it wasn't possible to open the file stream on local machine. - * - * @property IO_ERROR - * @static - * @final - */ - IO_ERROR: -300, - - /** - * @property SECURITY_ERROR - * @static - * @final - */ - SECURITY_ERROR: -400, - - /** - * Initialization error. Will be triggered if no runtime was initialized. - * - * @property INIT_ERROR - * @static - * @final - */ - INIT_ERROR: -500, - - /** - * File size error. If the user selects a file that is too large it will be blocked and an error of this type will be triggered. - * - * @property FILE_SIZE_ERROR - * @static - * @final - */ - FILE_SIZE_ERROR: -600, - - /** - * File extension error. If the user selects a file that isn't valid according to the filters setting. - * - * @property FILE_EXTENSION_ERROR - * @static - * @final - */ - FILE_EXTENSION_ERROR: -601, - - /** - * Duplicate file error. If prevent_duplicates is set to true and user selects the same file again. - * - * @property FILE_DUPLICATE_ERROR - * @static - * @final - */ - FILE_DUPLICATE_ERROR: -602, - - /** - * Runtime will try to detect if image is proper one. Otherwise will throw this error. - * - * @property IMAGE_FORMAT_ERROR - * @static - * @final - */ - IMAGE_FORMAT_ERROR: -700, - - /** - * While working on files runtime may run out of memory and will throw this error. - * - * @since 2.1.2 - * @property MEMORY_ERROR - * @static - * @final - */ - MEMORY_ERROR: -701, - - /** - * Each runtime has an upper limit on a dimension of the image it can handle. If bigger, will throw this error. - * - * @property IMAGE_DIMENSIONS_ERROR - * @static - * @final - */ - IMAGE_DIMENSIONS_ERROR: -702, - - - /** - Invalid option error. Will be thrown if user tries to alter the option that cannot be changed without - uploader reinitialisation. - - @property OPTION_ERROR - @static - @final - */ - OPTION_ERROR: -800, - - /** - * Expose whole moxie (#1469). - * - * @property moxie - * @type Object - * @final - */ - moxie: o, - - /** - * In some cases sniffing is the only way around :( - */ - ua: u.Env, - - /** - * Gets the true type of the built-in object (better version of typeof). - * @credits Angus Croll (http://javascriptweblog.wordpress.com/) - * - * @method typeOf - * @static - * @param {Object} o Object to check. - * @return {String} Object [[Class]] - */ - typeOf: u.Basic.typeOf, - - clone: u.Basic.clone, - - inherit: u.Basic.inherit, - - - /** - * Extends the specified object with another object. - * - * @method extend - * @static - * @param {Object} target Object to extend. - * @param {Object..} obj Multiple objects to extend with. - * @return {Object} Same as target, the extended object. - */ - extend: u.Basic.extend, - - - extendImmutable: u.Basic.extendImmutable, - - /** - Extends the specified object with another object(s), but only if the property exists in the target. - - @method extendIf - @static - @param {Object} target Object to extend. - @param {Object} [obj]* Multiple objects to extend with. - @return {Object} Same as target, the extended object. - */ - extendIf: u.Basic.extendIf, - - /** - Recieve an array of functions (usually async) to call in sequence, each function - receives a callback as first argument that it should call, when it completes. Finally, - after everything is complete, main callback is called. Passing truthy value to the - callback as a first argument will interrupt the sequence and invoke main callback - immediately. - - @method inSeries - @static - @param {Array} queue Array of functions to call in sequence - @param {Function} cb Main callback that is called in the end, or in case of error - */ - inSeries: u.Basic.inSeries, - - /** - Recieve an array of functions (usually async) to call in parallel, each function - receives a callback as first argument that it should call, when it completes. After - everything is complete, main callback is called. Passing truthy value to the - callback as a first argument will interrupt the process and invoke main callback - immediately. - - @method inParallel - @static - @param {Array} queue Array of functions to call in sequence - @param {Function} cb Main callback that is called in the end, or in case of erro - */ - inParallel: u.Basic.inParallel, - - /** - * Generates an unique ID. This is 99.99% unique since it takes the current time and 5 random numbers. - * The only way a user would be able to get the same ID is if the two persons at the same exact millisecond manages - * to get 5 the same random numbers between 0-65535 it also uses a counter so each call will be guaranteed to be page unique. - * It's more probable for the earth to be hit with an asteriod. You can also if you want to be 100% sure set the plupload.guidPrefix property - * to an user unique key. - * - * @method guid - * @static - * @return {String} Virtually unique id. - */ - guid: u.Basic.guid, - - /** - * Get array of DOM Elements by their ids. - * - * @method get - * @param {String} id Identifier of the DOM Element - * @return {Array} - */ - getAll: function get(ids) { - var els = [], - el; - - if (u.Basic.typeOf(ids) !== 'array') { - ids = [ids]; - } - - var i = ids.length; - while (i--) { - el = u.Dom.get(ids[i]); - if (el) { - els.push(el); - } - } - - return els.length ? els : null; - }, - - /** - Get DOM element by id - - @method get - @param {String} id Identifier of the DOM Element - @return {Node} - */ - get: u.Dom.get, - - /** - * Executes the callback function for each item in array/object. If you return false in the - * callback it will break the loop. - * - * @method each - * @static - * @param {Object} obj Object to iterate. - * @param {function} callback Callback function to execute for each item. - */ - each: u.Basic.each, - - /** - * Returns the absolute x, y position of an Element. The position will be returned in a object with x, y fields. - * - * @method getPos - * @static - * @param {Element} node HTML element or element id to get x, y position from. - * @param {Element} root Optional root element to stop calculations at. - * @return {object} Absolute position of the specified element object with x, y fields. - */ - getPos: u.Dom.getPos, - - /** - * Returns the size of the specified node in pixels. - * - * @method getSize - * @static - * @param {Node} node Node to get the size of. - * @return {Object} Object with a w and h property. - */ - getSize: u.Dom.getSize, - - /** - * Encodes the specified string. - * - * @method xmlEncode - * @static - * @param {String} s String to encode. - * @return {String} Encoded string. - */ - xmlEncode: function(str) { - var xmlEncodeChars = { - '<': 'lt', - '>': 'gt', - '&': 'amp', - '"': 'quot', - '\'': '#39' - }, - xmlEncodeRegExp = /[<>&\"\']/g; - - return str ? ('' + str).replace(xmlEncodeRegExp, function(chr) { - return xmlEncodeChars[chr] ? '&' + xmlEncodeChars[chr] + ';' : chr; - }) : str; - }, - - /** - * Forces anything into an array. - * - * @method toArray - * @static - * @param {Object} obj Object with length field. - * @return {Array} Array object containing all items. - */ - toArray: u.Basic.toArray, - - /** - * Find an element in array and return its index if present, otherwise return -1. - * - * @method inArray - * @static - * @param {mixed} needle Element to find - * @param {Array} array - * @return {Int} Index of the element, or -1 if not found - */ - inArray: u.Basic.inArray, - - /** - * Extends the language pack object with new items. - * - * @method addI18n - * @static - * @param {Object} pack Language pack items to add. - * @return {Object} Extended language pack object. - */ - addI18n: o.core.I18n.addI18n, - - /** - * Translates the specified string by checking for the english string in the language pack lookup. - * - * @method translate - * @static - * @param {String} str String to look for. - * @return {String} Translated string or the input string if it wasn't found. - */ - translate: o.core.I18n.translate, - - /** - * Pseudo sprintf implementation - simple way to replace tokens with specified values. - * - * @param {String} str String with tokens - * @return {String} String with replaced tokens - */ - sprintf: u.Basic.sprintf, - - /** - * Checks if object is empty. - * - * @method isEmptyObj - * @static - * @param {Object} obj Object to check. - * @return {Boolean} - */ - isEmptyObj: u.Basic.isEmptyObj, - - /** - * Checks if specified DOM element has specified class. - * - * @method hasClass - * @static - * @param {Object} obj DOM element like object to add handler to. - * @param {String} name Class name - */ - hasClass: u.Dom.hasClass, - - /** - * Adds specified className to specified DOM element. - * - * @method addClass - * @static - * @param {Object} obj DOM element like object to add handler to. - * @param {String} name Class name - */ - addClass: u.Dom.addClass, - - /** - * Removes specified className from specified DOM element. - * - * @method removeClass - * @static - * @param {Object} obj DOM element like object to add handler to. - * @param {String} name Class name - */ - removeClass: u.Dom.removeClass, - - /** - * Returns a given computed style of a DOM element. - * - * @method getStyle - * @static - * @param {Object} obj DOM element like object. - * @param {String} name Style you want to get from the DOM element - */ - getStyle: u.Dom.getStyle, - - /** - * Adds an event handler to the specified object and store reference to the handler - * in objects internal Plupload registry (@see removeEvent). - * - * @method addEvent - * @static - * @param {Object} obj DOM element like object to add handler to. - * @param {String} name Name to add event listener to. - * @param {Function} callback Function to call when event occurs. - * @param {String} (optional) key that might be used to add specifity to the event record. - */ - addEvent: u.Events.addEvent, - - /** - * Remove event handler from the specified object. If third argument (callback) - * is not specified remove all events with the specified name. - * - * @method removeEvent - * @static - * @param {Object} obj DOM element to remove event listener(s) from. - * @param {String} name Name of event listener to remove. - * @param {Function|String} (optional) might be a callback or unique key to match. - */ - removeEvent: u.Events.removeEvent, - - /** - * Remove all kind of events from the specified object - * - * @method removeAllEvents - * @static - * @param {Object} obj DOM element to remove event listeners from. - * @param {String} (optional) unique key to match, when removing events. - */ - removeAllEvents: u.Events.removeAllEvents, - - /** - * Cleans the specified name from national characters (diacritics). The result will be a name with only a-z, 0-9 and _. - * - * @method cleanName - * @static - * @param {String} s String to clean up. - * @return {String} Cleaned string. - */ - cleanName: function(name) { - var i, lookup; - - // Replace diacritics - lookup = [ - /[\300-\306]/g, 'A', /[\340-\346]/g, 'a', - /\307/g, 'C', /\347/g, 'c', - /[\310-\313]/g, 'E', /[\350-\353]/g, 'e', - /[\314-\317]/g, 'I', /[\354-\357]/g, 'i', - /\321/g, 'N', /\361/g, 'n', - /[\322-\330]/g, 'O', /[\362-\370]/g, 'o', - /[\331-\334]/g, 'U', /[\371-\374]/g, 'u' - ]; - - for (i = 0; i < lookup.length; i += 2) { - name = name.replace(lookup[i], lookup[i + 1]); - } - - // Replace whitespace - name = name.replace(/\s+/g, '_'); - - // Remove anything else - name = name.replace(/[^a-z0-9_\-\.]+/gi, ''); - - return name; - }, - - /** - * Builds a full url out of a base URL and an object with items to append as query string items. - * - * @method buildUrl - * @static - * @param {String} url Base URL to append query string items to. - * @param {Object} items Name/value object to serialize as a querystring. - * @return {String} String with url + serialized query string items. - */ - buildUrl: function(url, items) { - var query = ''; - - u.Basic.each(items, function(value, name) { - query += (query ? '&' : '') + encodeURIComponent(name) + '=' + encodeURIComponent(value); - }); - - if (query) { - url += (url.indexOf('?') > 0 ? '&' : '?') + query; - } - - return url; - }, - - /** - * Formats the specified number as a size string for example 1024 becomes 1 KB. - * - * @method formatSize - * @static - * @param {Number} size Size to format as string. - * @return {String} Formatted size string. - */ - formatSize: function(size) { - var self = this; - - function round(num, precision) { - return Math.round(num * Math.pow(10, precision)) / Math.pow(10, precision); - } - - size = parseInt(size, 10); - if (isNaN(size)) { - return self.translate('N/A'); - } - - var boundary = Math.pow(1024, 4); - - // TB - if (size > boundary) { - return round(size / boundary, 1) + " " + self.translate('tb'); - } - - // GB - if (size > (boundary /= 1024)) { - return round(size / boundary, 1) + " " + self.translate('gb'); - } - - // MB - if (size > (boundary /= 1024)) { - return round(size / boundary, 1) + " " + self.translate('mb'); - } - - // KB - if (size > 1024) { - return Math.round(size / 1024) + " " + self.translate('kb'); - } - - return size + " " + self.translate('b'); - }, - - /** - * @private - */ - mimes2extList: moxie.core.utils.Mime.mimes2extList, - - /** - Resolve url - among other things will turn relative url to absolute - - @method resolveUrl - @static - @param {String|Object} url Either absolute or relative, or a result of parseUrl call - @return {String} Resolved, absolute url - */ - resolveUrl: u.Url.resolveUrl, - - /** - * Parses the specified size string into a byte value. For example 10kb becomes 10240. - * - * @method parseSize - * @static - * @param {String|Number} size String to parse or number to just pass through. - * @return {Number} Size in bytes. - */ - parseSize: u.Basic.parseSizeStr, - - delay: u.Basic.delay, - - - /** - Parent object for all event dispatching components and objects - - @class plupload.EventTarget - @private - @constructor - */ - EventTarget: moxie.core.EventTarget, - - /** - Common set of methods and properties for every runtime instance - - @class plupload.Runtime - @private - - @param {Object} options - @param {String} type Sanitized name of the runtime - @param {Object} [caps] Set of capabilities that differentiate specified runtime - @param {Object} [modeCaps] Set of capabilities that do require specific operational mode - @param {String} [preferredMode='browser'] Preferred operational mode to choose if no required capabilities were requested - */ - Runtime: moxie.runtime.Runtime, - - /** - Provides a convenient way to create cross-browser file-picker. Generates file selection dialog on click, - converts selected files to _File_ objects, to be used in conjunction with _Image_, preloaded in memory - with _FileReader_ or uploaded to a server through _XMLHttpRequest_. - - @class plupload.FileInput - @private - @constructor - @extends EventTarget - @uses RuntimeClient - @param {Object|String|DOMElement} options If options is string or node, argument is considered as _browse\_button_. - @param {String|DOMElement} options.browse_button DOM Element to turn into file picker. - @param {Array} [options.accept] Array of mime types to accept. By default accepts all. - @param {String} [options.file='file'] Name of the file field (not the filename). - @param {Boolean} [options.multiple=false] Enable selection of multiple files. - @param {Boolean} [options.directory=false] Turn file input into the folder input (cannot be both at the same time). - @param {String|DOMElement} [options.container] DOM Element to use as a container for file-picker. Defaults to parentNode - for _browse\_button_. - @param {Object|String} [options.required_caps] Set of required capabilities, that chosen runtime must support. - */ - FileInput: moxie.file.FileInput, - - /** - Utility for preloading o.Blob/o.File objects in memory. By design closely follows [W3C FileReader](http://www.w3.org/TR/FileAPI/#dfn-filereader) - interface. Where possible uses native FileReader, where - not falls back to shims. - - @class plupload.FileReader - @private - @constructor - @extends EventTarget - @uses RuntimeClient - */ - FileReader: moxie.file.FileReader - }; - -}); - -// Included from: src/core/Collection.js - -/** - * Collection.js - * - * Copyright 2017, Ephox - * Released under AGPLv3 License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - - -/** -Helper collection class - in a way a mix of object and array - -@contsructor -@class plupload.core.Collection -@private -*/ -define('plupload/core/Collection', [ - 'plupload' -], function(Basic) { - - var Collection = function() { - var _registry = {}; - var _length = 0; - var _last; - - - plupload.extend(this, { - - count: function() { - return _length; - }, - - hasKey: function(key) { - return _registry.hasOwnProperty(key) - }, - - - get: function(key) { - return _registry[key]; - }, - - - first: function() { - for (var key in _registry) { - return _registry[key]; - } - }, - - - last: function() { - return _last; - }, - - - toObject: function() { - return _registry; - }, - - - add: function(key, obj) { - var self = this; - - if (typeof(key) === 'object' && !obj) { - return plupload.each(key, function(obj, key) { - self.add(key, obj); - }); - } - - if (_registry.hasOwnProperty(key)) { - return self.update.apply(self, arguments); - } - - _registry[key] = _last = obj; - _length++; - }, - - - remove: function(key) { - if (this.hasKey(key)) { - var last = _registry[key]; - - delete _registry[key]; - _length--; - - // renew ref to the last added item if necessary - if (_last === last) { - _last = findLast(); - } - } - }, - - - extract: function(key) { - var item = this.get(key); - this.remove(key); - return item; - }, - - - shift: function() { - var self = this, - first, key; - - for (key in _registry) { - first = _registry[key]; - self.remove(key); - return first; - } - }, - - - update: function(key, obj) { - _registry[key] = obj; - }, - - - each: function(cb) { - plupload.each(_registry, cb); - }, - - - combineWith: function() { - var newCol = new Collection(); - - newCol.add(_registry); - - plupload.each(arguments, function(col) { - if (col instanceof Collection) { - newCol.add(col.toObject()); - } - }); - return newCol; - }, - - - clear: function() { - _registry = {}; - _last = null; - _length = 0; - } - }); - - - function findLast() { - var key; - for (key in _registry) {} - return _registry[key]; - } - - }; - - return Collection; -}); - -// Included from: src/core/ArrCollection.js - -/** - * ArrCollection.js - * - * Copyright 2017, Ephox - * Released under AGPLv3 License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - - -/** -@contsructor -@class plupload.core.ArrCollection -@private -*/ -define('plupload/core/ArrCollection', [ - 'plupload' -], function(plupload) { - - var ArrCollection = function() { - var _registry = []; - - plupload.extend(this, { - - count: function() { - return _registry.length; - }, - - hasKey: function(key) { - return this.getIdx(key) > -1; - }, - - - get: function(key) { - var idx = this.getIdx(key); - return idx > -1 ? _registry[idx] : null; - }, - - getIdx: function(key) { - for (var i = 0, length = _registry.length; i < length; i++) { - if (_registry[i].uid === key) { - return i; - } - } - return -1; - }, - - getByIdx: function(idx) { - return _registry[idx] - }, - - first: function() { - return _registry[0]; - }, - - last: function() { - return _registry[_registry.length - 1]; - }, - - add: function(obj) { - obj = arguments[1] || obj; // make it compatible with Collection.add() - - var idx = this.getIdx(obj.uid); - if (idx > -1) { - _registry[idx] = obj; - return idx; - } - - _registry.push(obj); - return _registry.length - 1; - }, - - remove: function(key) { - return !!this.extract(key); - }, - - splice: function(start, length) { - start = plupload.typeOf(start) === 'undefinded' ? 0 : Math.max(start, 0); - length = plupload.typeOf(length) !== 'undefinded' && start + length < _registry.length ? length : _registry.length - start; - - return _registry.splice(start, length); - }, - - extract: function(key) { - var idx = this.getIdx(key); - if (idx > -1) { - return _registry.splice(idx, 1); - } - return null; - }, - - shift: function() { - return _registry.shift(); - }, - - update: function(key, obj) { - var idx = this.getIdx(key); - if (idx > -1) { - _registry[idx] = obj; - return true; - } - return false; - }, - - each: function(cb) { - plupload.each(_registry, cb); - }, - - combineWith: function() { - return Array.prototype.concat.apply(this.toArray(), arguments); - }, - - sort: function(cb) { - _registry.sort(cb || function(a, b) { - return a.priority - b.priority; - }); - }, - - clear: function() { - _registry = []; - }, - - toObject: function() { - var obj = {}; - for (var i = 0, length = _registry.length; i < length; i++) { - obj[_registry[i].uid] = _registry[i]; - } - return obj; - }, - - toArray: function() { - return Array.prototype.slice.call(_registry); - } - }); - }; - - return ArrCollection; -}); - -// Included from: src/core/Optionable.js - -/** - * Optionable.js - * - * Copyright 2017, Ephox - * Released under AGPLv3 License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - - -/** -@contsructor -@class plupload.core.Optionable -@private -@since 3.0 -*/ -define('plupload/core/Optionable', [ - 'plupload' -], function(plupload) { - var EventTarget = moxie.core.EventTarget; - - var dispatches = [ - /** - * Dispatched when option is being changed. - * - * @event OptionChanged - * @param {Object} event - * @param {String} name Name of the option being changed - * @param {Mixed} value - * @param {Mixed} oldValue - */ - 'OptionChanged' - ]; - - return (function(Parent) { - - /** - * @class Optionable - * @constructor - * @extends EventTarget - */ - function Optionable() { - Parent.apply(this, arguments); - - this._options = {}; - } - - plupload.inherit(Optionable, Parent); - - plupload.extend(Optionable.prototype, { - /** - * Set the value for the specified option(s). - * - * @method setOption - * @since 2.1 - * @param {String|Object} option Name of the option to change or the set of key/value pairs - * @param {Mixed} [value] Value for the option (is ignored, if first argument is object) - * @param {Boolean} [mustBeDefined] if truthy, any option that is not in defaults will be ignored - */ - setOption: function(option, value, mustBeDefined) { - var self = this; - var oldValue; - - if (typeof(option) === 'object') { - mustBeDefined = value; - plupload.each(option, function(value, option) { - self.setOption(option, value, mustBeDefined); - }); - return; - } - - if (mustBeDefined && !self._options.hasOwnProperty(option)) { - return; - } - - oldValue = plupload.clone(self._options[option]); - - //! basically if an option is of type object extend it rather than replace - if (plupload.typeOf(value) === 'object' && plupload.typeOf(self._options[option]) === 'object') { - // having some options as objects was a bad idea, prefixes is the way - plupload.extend(self._options[option], value); - } else { - self._options[option] = value; - } - - self.trigger('OptionChanged', option, value, oldValue); - }, - - /** - * Get the value for the specified option or the whole configuration, if not specified. - * - * @method getOption - * @since 2.1 - * @param {String} [option] Name of the option to get - * @return {Mixed} Value for the option or the whole set - */ - getOption: function(option) { - if (!option) { - return this._options; - } - - var value = this._options[option]; - if (plupload.inArray(plupload.typeOf(value), ['array', 'object']) > -1) { - return plupload.extendImmutable({}, value); - } else { - return value; - } - }, - - - /** - * Set many options as once. - * - * @method setOptions - * @param {Object} options - * @param {Boolean} [mustBeDefined] if truthy, any option that is not in defaults will be ignored - */ - setOptions: function(options, mustBeDefined) { - if (typeof(options) !== 'object') { - return; - } - this.setOption(options, mustBeDefined); - }, - - - /** - Gets all options. - - @method getOptions - @return {Object} - */ - getOptions: function() { - return this.getOption(); - } - }); - - return Optionable; - - }(EventTarget)); - -}); - -// Included from: src/core/Queueable.js - -/** - * Queueable.js - * - * Copyright 2017, Ephox - * Released under AGPLv3 License.se. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - - -/** -Every queue item must have properties, implement methods and fire events defined in this class - -@contsructor -@class plupload.core.Queueable -@private -@decorator -@extends EventTarget -*/ -define('plupload/core/Queueable', [ - 'plupload', - 'plupload/core/Optionable' -], function(plupload, Optionable) { - - var dispatches = [ - /** - * Dispatched every time the state of queue changes - * - * @event statechanged - * @param {Object} event - * @param {Number} state New state - * @param {Number} prevState Previous state - */ - 'statechanged', - - - /** - * Dispatched when the item is put on pending list - * - * @event queued - * @param {Object} event - */ - 'queued', - - - /** - * Dispatched as soon as activity starts - * - * @event started - * @param {Object} event - */ - 'started', - - - 'paused', - - - 'resumed', - - - 'stopped', - - - /** - * Dispatched as the activity progresses - * - * @event - * @param {Object} event - * @param {Number} event.percent - * @param {Number} [event.processed] - * @param {Number} [event.total] - */ - 'progress', - - - 'failed', - - - 'done', - - - 'processed', - - 'destroy' - ]; - - - return (function(Parent) { - - function Queueable() { - Parent.apply(this, arguments); - - /** - Unique identifier - @property uid - @type {String} - */ - this.uid = plupload.guid(); - - this.state = Queueable.IDLE; - - this.processed = 0; - - this.total = 0; - - this.percent = 0; - - this.retries = 0; - - /** - * Can be 0-Infinity - item with higher priority will have well... higher priority - * @property [priority=0] - * @type {Number} - */ - this.priority = 0; - - this.startedTimestamp = 0; - - /** - * Set when item becomes Queueable.DONE or Queueable.FAILED. - * Used to calculate proper processedPerSec for the queue stats. - * @property processedTimestamp - * @type {Number} - */ - this.processedTimestamp = 0; - - if (MXI_DEBUG) { - this.bind('StateChanged', function(e, state, oldState) { - var self = this; - - var stateToString = function(code) { - switch (code) { - case Queueable.IDLE: - return 'IDLE'; - - case Queueable.PROCESSING: - return 'PROCESSING'; - - case Queueable.PAUSED: - return 'PAUSED'; - - case Queueable.RESUMED: - return 'RESUMED'; - - case Queueable.DONE: - return 'DONE'; - - case Queueable.FAILED: - return 'FAILED'; - - case Queueable.DESTROYED: - return 'DESTROYED'; - } - }; - - var indent = function() { - switch (self.ctorName) { - case 'File': - return "\t".repeat(2); - - case 'QueueUpload': - case 'QueueResize': - return "\t"; - - case 'FileUploader': - return "\t".repeat(3); - - case 'ChunkUploader': - return "\t".repeat(4); - - default: - return "\t"; - } - }; - - plupload.ua.log("StateChanged:" + indent() + self.ctorName + '::' + self.uid + ' (' + stateToString(oldState) + ' to ' + stateToString(state) + ')'); - }, 999); - } - } - - Queueable.IDLE = 1; - Queueable.PROCESSING = 2; - Queueable.PAUSED = 6; - Queueable.RESUMED = 7; - Queueable.DONE = 5; - Queueable.FAILED = 4; - Queueable.DESTROYED = 8; - - plupload.inherit(Queueable, Parent); - - plupload.extend(Queueable.prototype, { - - start: function() { - var prevState = this.state; - - if (this.state === Queueable.PROCESSING) { - return false; - } - - if (!this.startedTimestamp) { - this.startedTimestamp = +new Date(); - } - - this.state = Queueable.PROCESSING; - this.trigger('statechanged', this.state, prevState); - this.trigger('started'); - - return true; - }, - - - pause: function() { - var prevState = this.state; - - if (plupload.inArray(this.state, [Queueable.IDLE, Queueable.RESUMED, Queueable.PROCESSING]) === -1) { - return false; - } - - this.processed = this.percent = 0; // by default reset all progress - this.loaded = this.processed; // for backward compatibility - - this.state = Queueable.PAUSED; - this.trigger('statechanged', this.state, prevState); - this.trigger('paused'); - return true; - }, - - - resume: function() { - var prevState = this.state; - - if (this.state !== Queueable.PAUSED && this.state !== Queueable.RESUMED) { - return false; - } - - this.state = Queueable.RESUMED; - this.trigger('statechanged', this.state, prevState); - this.trigger('resumed'); - return true; - }, - - - stop: function() { - var prevState = this.state; - - if (this.state === Queueable.IDLE) { - return false; - } - - this.processed = this.percent = 0; - this.loaded = this.processed; // for backward compatibility - - this.startedTimestamp = 0; - - this.state = Queueable.IDLE; - this.trigger('statechanged', this.state, prevState); - this.trigger('stopped'); - return true; - }, - - - done: function(result) { - var prevState = this.state; - - if (this.state === Queueable.DONE) { - return false; - } - - this.processed = this.total; - this.loaded = this.processed; // for backward compatibility - this.percent = 100; - - this.processedTimestamp = +new Date(); - - this.state = Queueable.DONE; - this.trigger('statechanged', this.state, prevState); - this.trigger('done', result); - this.trigger('processed'); - return true; - }, - - - failed: function(result) { - var prevState = this.state; - - if (this.state === Queueable.FAILED) { - return false; - } - - this.processed = this.percent = 0; // reset the progress - this.loaded = this.processed; // for backward compatibility - - this.processedTimestamp = +new Date(); - - this.state = Queueable.FAILED; - this.trigger('statechanged', this.state, prevState); - this.trigger('failed', result); - this.trigger('processed'); - return true; - }, - - - progress: function(processed, total) { - if (total) { - this.total = total; // is this even required? - } - - this.processed = Math.min(processed, this.total); - this.loaded = this.processed; // for backward compatibility - this.percent = Math.ceil(this.processed / this.total * 100); - - this.trigger({ - type: 'progress', - loaded: this.processed, - total: this.total - }); - }, - - - destroy: function() { - var prevState = this.state; - - if (this.state === Queueable.DESTROYED) { - return false; // already destroyed - } - - this.state = Queueable.DESTROYED; - this.trigger('statechanged', this.state, prevState); - this.trigger('destroy'); - this.unbindAll(); - return true; - } - - }); - - return Queueable; - - }(Optionable)); -}); - -// Included from: src/core/Stats.js - -/** -@class plupload.core.Stats -@constructor -@private -*/ -define('plupload/core/Stats', [], function() { - - return function() { - var self = this; - - /** - * Total queue file size. - * - * @property size - * @deprecated use total - * @type Number - */ - self.size = 0; - - /** - * Total size of the queue in units. - * - * @property total - * @since 3.0 - * @type Number - */ - self.total = 0; - - /** - * Total bytes uploaded. - * - * @property loaded - * @type Number - */ - self.loaded = 0; - - - /** - * Number of files uploaded successfully. - * - * @property uploaded - * @deprecated use done - * @type Number - */ - self.uploaded = 0; - - /** - * Number of items processed successfully. - * - * @property done - * @since 3.0 - * @type Number - */ - self.done = 0; - - /** - * Number of failed items. - * - * @property failed - * @type Number - */ - self.failed = 0; - - /** - * Number of items yet to be processed. - * - * @property queued - * @type Number - */ - self.queued = 0; - - /** - * Number of items currently paused. - * - * @property paused - * @type Number - */ - self.paused = 0; - - /** - * Number of items being processed. - * - * @property processing - * @type Number - */ - self.processing = 0; - - - /** - * Number of items being paused. - * - * @property paused - * @type Number - */ - self.paused = 0; - - /** - * Percent of processed units. - * - * @property percent - * @type Number - */ - self.percent = 0; - - /** - * Bytes processed per second. - * - * @property bytesPerSec - * @deprecated use processedPerSec - * @type Number - */ - self.bytesPerSec = 0; - - /** - * Units processed per second. - * - * @property processedPerSec - * @since 3.0 - * @type Number - */ - self.processedPerSec = 0; - - /** - * Resets the progress to its initial values. - * - * @method reset - */ - self.reset = function() { - self.size = // deprecated - self.total = - self.loaded = // deprecated - self.processed = - self.uploaded = // deprecated - self.done = - self.failed = - self.queued = - self.processing = - self.paused = - self.percent = - self.bytesPerSec = // deprecated - self.processedPerSec = 0; - }; - }; -}); - -// Included from: src/core/Queue.js - -/** - * Queue.js - * - * Copyright 2017, Ephox - * Released under AGPLv3 License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - - -/** -@contsructor -@class plupload.core.Queue -@private -*/ -define('plupload/core/Queue', [ - 'plupload', - 'plupload/core/ArrCollection', - 'plupload/core/Queueable', - 'plupload/core/Stats' -], function(plupload, ArrCollection, Queueable, Stats) { - - var dispatches = [ - /** - * Dispatched as soon as activity starts - * - * @event started - * @param {Object} event - */ - 'Started', - - - /** - * Dispatched as activity progresses - * - * @event progress - * @param {Object} event - * @param {Number} processed - * @param {Number} total - * @param {plupload.core.Stats} stats - */ - 'Progress', - - /** - * Dispatched when activity is paused - * - * @event paused - * @param {Object} event - */ - 'Paused', - - /** - * Dispatched when there's no more items in processing - * - * @event done - * @param {Object} event - */ - 'Done', - - /** - * Dispatched as soon as activity ends - * - * @event stopped - * @param {Object} event - */ - 'Stopped', - - /** - * Dispatched when queue is destroyed - * - * @event destroy - * @param {Object} event - */ - 'Destroy' - ]; - - /** - * @class Queue - * @constructor - * @extends EventTarget - */ - return (function(Parent) { - plupload.inherit(Queue, Parent); - - - function Queue(options) { - Parent.apply(this, arguments); - - /** - @property _queue - @type {Collection} - @private - */ - this._queue = new ArrCollection(); - - - /** - @property stats - @type {Stats} - @readOnly - */ - this.stats = new Stats(); - - - this._options = plupload.extend({}, this._options, { - max_slots: 1, - max_retries: 0, - auto_start: false, - finish_active: false - }, options); - } - - plupload.extend(Queue.prototype, { - - /** - * Returns number of items in the queue - * - * @method count - * @returns {Number} - */ - count: function() { - return this._queue.count(); - }, - - /** - * Start the queue - * - * @method start - */ - start: function() { - if (!Queue.parent.start.call(this)) { - return false; - } - return processNext.call(this); - }, - - - pause: function() { - if (!Queue.parent.pause.call(this)) { - return false; - } - - this.forEachItem(function(item) { - item.pause(); - }); - }, - - /** - * Stop the queue. If `finish_active=true` the queue will wait until active items are done, before - * stopping. - * - * @method stop - */ - stop: function() { - if (!Queue.parent.stop.call(this) || this.getOption('finish_active')) { - return false; - } - - if (this.isActive()) { - this.forEachItem(function(item) { - item.stop(); - }); - } - }, - - - forEachItem: function(cb) { - this._queue.each(cb); - }, - - - getItem: function(uid) { - return this._queue.get(uid); - }, - - - /** - * Add instance of Queueable to the queue. If `auto_start=true` queue will start as well. - * - * @method addItem - * @param {Queueable} item - */ - addItem: function(item) { - var self = this; - - item.bind('Started', function() { - if (self.calcStats()) { - plupload.delay.call(self, processNext); - } - }); - - item.bind('Resumed',function() { - self.start(); - }); - - item.bind('Paused', function() { - if (self.calcStats()) { - plupload.delay.call(self, function() { - if (!processNext.call(self) && !self.stats.processing) { - self.pause(); - } - }); - } - }); - - item.bind('Processed Stopped', function() { - if (self.calcStats()) { - plupload.delay.call(self, function() { - if (!processNext.call(self) && !this.isStopped() && !this.isActive()) { - self.stop(); - } - }); - } - }); - - item.bind('Progress', function() { - if (self.calcStats()) { - self.trigger('Progress', self.stats.processed, self.stats.total, self.stats); - } - }); - - item.bind('Failed', function() { - if (self.getOption('max_retries') && this.retries < self.getOption('max_retries')) { - this.stop(); - this.retries++; - } - }); - - this._queue.add(item.uid, item); - this.calcStats(); - item.trigger('Queued'); - - if (self.getOption('auto_start') || self.state === Queueable.PAUSED) { - plupload.delay.call(this, this.start); - } - }, - - - /** - * Extracts item from the queue by its uid and returns it. - * - * @method extractItem - * @param {String} uid - * @return {Queueable} Item that was removed - */ - extractItem: function(uid) { - var item = this._queue.get(uid); - if (item) { - this.stopItem(item.uid); - this._queue.remove(uid); - this.calcStats(); - } - return item; - }, - - /** - * Removes item from the queue and destroys it - * - * @method removeItem - * @param {String} uid - * @returns {Boolean} Result of the operation - */ - removeItem: function(uid) { - var item = this.extractItem(uid); - if (item) { - item.destroy(); - return true; - } - return false; - }, - - - stopItem: function(uid) { - var item = this._queue.get(uid); - if (item) { - return item.stop(); - } else { - return false; - } - }, - - - pauseItem: function(uid) { - var item = this._queue.get(uid); - if (item) { - return item.pause(); - } else { - return false; - } - }, - - - resumeItem: function(uid) { - var item = this._queue.get(uid); - if (item) { - plupload.delay.call(this, function() { - this.start(); // start() will know if it needs to restart the queue - }); - return item.resume(); - } else { - return false; - } - }, - - - splice: function(start, length) { - return this._queue.splice(start, length); - }, - - - isActive: function() { - return this.stats && (this.stats.processing || this.stats.paused); - }, - - isStopped: function() { - return this.state === Queueable.IDLE || this.state === Queueable.DESTROYED; - }, - - - countSpareSlots: function() { - return Math.max(this.getOption('max_slots') - this.stats.processing, 0); - }, - - - toArray: function() { - return this._queue.toArray(); - }, - - - clear: function() { - var self = this; - - if (self.state !== Queueable.IDLE) { - // stop the active queue first - self.bindOnce('Stopped', function() { - self.clear(); - }); - return self.stop(); - } else { - self._queue.clear(); - self.stats.reset(); - } - }, - - - calcStats: function() { - var self = this; - var stats = self.stats; - var processed = 0; - var processedDuringThisSession = 0; - - if (!stats) { - return false; // maybe queue is destroyed - } - - stats.reset(); - - self.forEachItem(function(item) { - switch (item.state) { - case Queueable.DONE: - stats.done++; - stats.uploaded = stats.done; // for backward compatibility - break; - - case Queueable.FAILED: - stats.failed++; - break; - - case Queueable.PROCESSING: - stats.processing++; - break; - - case Queueable.PAUSED: - stats.paused++; - break; - - default: - stats.queued++; - } - - processed += item.processed; - - if (!item.processedTimestamp || item.processedTimestamp > self.startedTimestamp) { - processedDuringThisSession += processed; - } - - stats.processedPerSec = Math.ceil(processedDuringThisSession / ((+new Date() - self.startedTimestamp || 1) / 1000.0)); - - stats.processed = processed; - stats.total += item.total; - if (stats.total) { - stats.percent = Math.ceil(stats.processed / stats.total * 100); - } - }); - - // enable properties inherited from Queueable - - /* TODO: this is good but it currently conflicts with deprecated total property in Uploader - self.processed = stats.processed; - self.total = stats.total; - */ - self.percent = stats.percent; - - // for backward compatibility - stats.loaded = stats.processed; - stats.size = stats.total; - stats.bytesPerSec = stats.processedPerSec; - - return true; - }, - - - destroy: function() { - var self = this; - - if (self.state === Queueable.DESTROYED) { - return false; // already destroyed - } - - if (self.state !== Queueable.IDLE) { - // stop the active queue first - self.bindOnce('Stopped', function() { - plupload.delay.call(self, self.destroy); - }); - return self.stop(); - } else { - self.clear(); - Queue.parent.destroy.call(this); - self._queue = self.stats = null; - } - return true; - } - }); - - - /** - * Returns another Queueable.IDLE or Queueable.RESUMED item, or null. - */ - function getNextIdleItem() { - var nextItem; - this.forEachItem(function(item) { - if (item.state === Queueable.IDLE || item.state === Queueable.RESUMED) { - nextItem = item; - return false; - } - }); - return nextItem ? nextItem : null; - } - - - function processNext() { - var item; - - if (this.state !== Queueable.PROCESSING && this.state !== Queueable.PAUSED) { - return false; - } - - if (this.stats.processing < this.getOption('max_slots')) { - item = getNextIdleItem.call(this); - if (item) { - if (item.trigger('beforestart')) { - item.setOptions(this.getOptions()); - return item.start(); - } else { - item.pause(); - // we need to call it sync, otherwise another thread may pick up the same file, while it is processed in beforestart handler - processNext.call(this); - } - } - } - return false; - } - - return Queue; - - }(Queueable)); -}); - -// Included from: src/QueueUpload.js - -/** - * QueueUpload.js - * - * Copyright 2017, Ephox - * Released under AGPLv3 License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - - -/** - @class plupload.QueueUpload - @extends plupload.core.Queue - @constructor - @private - @final - @since 3.0 - @param {Object} options - */ -define('plupload/QueueUpload', [ - 'plupload', - 'plupload/core/Queue' -], function(plupload, Queue) { - - return (function(Parent) { - plupload.inherit(QueueUpload, Parent); - - function QueueUpload(options) { - - Queue.call(this, { - max_slots: 1, - max_retries: 0, - auto_start: false, - finish_active: false, - url: false, - chunk_size: 0, - multipart: true, - http_method: 'POST', - params: {}, - headers: false, - file_data_name: 'file', - send_file_name: true, - stop_on_fail: true - }); - - this.setOption = function(option, value) { - if (typeof(option) !== 'object') { - if (option == 'max_upload_slots') { - option = 'max_slots'; - } - } - QueueUpload.prototype.setOption.call(this, option, value, true); - }; - - this.setOptions(options); - } - - return QueueUpload; - }(Queue)); -}); - -// Included from: src/QueueResize.js - -/** - * QueueResize.js - * - * Copyright 2017, Ephox - * Released under AGPLv3 License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - - -/** - @class plupload.QueueResize - @extends plupload.core.Queue - @constructor - @private - @final - @since 3.0 - @param {Object} options -*/ -define('plupload/QueueResize', [ - 'plupload', - 'plupload/core/Queue' -], function(plupload, Queue) { - - return (function(Parent) { - plupload.inherit(QueueResize, Parent); - - function QueueResize(options) { - - Queue.call(this, { - max_slots: 1, - max_retries: 0, - auto_start: false, - finish_active: false, - resize: {} - }); - - this.setOption = function(option, value) { - if (typeof(option) !== 'object') { - if (option == 'max_resize_slots') { - option = 'max_slots'; - } - } - QueueResize.prototype.setOption.call(this, option, value, true); - }; - - - this.setOptions(options); - } - - - return QueueResize; - }(Queue)); -}); - -// Included from: src/ChunkUploader.js - -/** - * ChunkUploader.js - * - * Copyright 2017, Ephox - * Released under AGPLv3 License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** - * @class plupload.ChunkUploader - * @extends plupload.core.Queueable - * @constructor - * @private - * @final - * @constructor - */ -define('plupload/ChunkUploader', [ - 'plupload', - 'plupload/core/Collection', - 'plupload/core/Queueable' -], function(plupload, Collection, Queueable) { - var XMLHttpRequest = moxie.xhr.XMLHttpRequest; - var FormData = moxie.xhr.FormData; - - function ChunkUploader(blob) { - var _xhr; - - Queueable.call(this); - - this._options = { - file_data_name: 'file', - headers: false, - http_method: 'POST', - multipart: true, - params: {}, - send_file_name: true, - url: false - }; - - plupload.extend(this, { - - start: function() { - var self = this; - var url; - var formData; - var prevState = this.state; - var options = self._options; - - if (this.state === Queueable.PROCESSING) { - return false; - } - - if (!this.startedTimestamp) { - this.startedTimestamp = +new Date(); - } - - this.state = Queueable.PROCESSING; - this.trigger('statechanged', this.state, prevState); - - _xhr = new XMLHttpRequest(); - - if (_xhr.upload) { - _xhr.upload.onprogress = function(e) { - self.progress(e.loaded, e.total); - }; - } - - _xhr.onload = function() { - var result = { - response: this.responseText, - status: this.status, - responseHeaders: this.getAllResponseHeaders() - }; - - if (this.status < 200 || this.status >= 400) { // assume error - return self.failed(result); - } - - self.done(result); - }; - - _xhr.onerror = function() { - self.failed(); // TODO: reason here - }; - - _xhr.onloadend = function() { - // we do not need _xhr anymore, so destroy it - setTimeout(function() { // we detach to sustain reference until all handlers are done - if (_xhr) { - _xhr.destroy(); - _xhr = null; - } - }, 1); - }; - - try { - url = options.multipart ? options.url : buildUrl(options.url, options.params); - _xhr.open(options.http_method, url, true); - - - // headers must be set after request is already opened, otherwise INVALID_STATE_ERR exception will raise - if (!plupload.isEmptyObj(options.headers)) { - plupload.each(options.headers, function(val, key) { - _xhr.setRequestHeader(key, val); - }); - } - - - if (options.multipart) { - formData = new FormData(); - - if (!plupload.isEmptyObj(options.params)) { - plupload.each(options.params, function(val, key) { - formData.append(key, val); - }); - } - - formData.append(options.file_data_name, blob); - - _xhr.send(formData); - } else { // if no multipart, send as binary stream - if (plupload.isEmptyObj(options.headers) || !_xhr.hasRequestHeader('content-type')) { - _xhr.setRequestHeader('content-type', 'application/octet-stream'); // binary stream header - } - - _xhr.send(blob); - } - - this.trigger('started'); - } catch(ex) { - self.failed(); - } - }, - - - stop: function() { - if (_xhr) { - _xhr.abort(); - _xhr.destroy(); - _xhr = null; - } - ChunkUploader.prototype.stop.call(this); - }, - - setOption: function(option, value) { - ChunkUploader.prototype.setOption.call(this, option, value, true); - }, - - setOptions: function(options) { - ChunkUploader.prototype.setOption.call(this, options, true); - }, - - destroy: function() { - this.stop(); - ChunkUploader.prototype.destroy.call(this); - } - }); - - - /** - * Builds a full url out of a base URL and an object with items to append as query string items. - * - * @method buildUrl - * @private - * @param {String} url Base URL to append query string items to. - * @param {Object} items Name/value object to serialize as a querystring. - * @return {String} String with url + serialized query string items. - */ - function buildUrl(url, items) { - var query = ''; - - plupload.each(items, function(value, name) { - query += (query ? '&' : '') + encodeURIComponent(name) + '=' + encodeURIComponent(value); - }); - - if (query) { - url += (url.indexOf('?') > 0 ? '&' : '?') + query; - } - - return url; - } - - } - - plupload.inherit(ChunkUploader, Queueable); - - return ChunkUploader; -}); - -// Included from: src/FileUploader.js - -/** - * FileUploader.js - * - * Copyright 2017, Ephox - * Released under AGPLv3 License.se. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** - * @class plupload.FileUploader - * @extends plupload.core.Queueable - * @constructor - * @since 3.0 - * @final - */ -define('plupload/FileUploader', [ - 'plupload', - 'plupload/core/Collection', - 'plupload/core/Queueable', - 'plupload/ChunkUploader' -], function(plupload, Collection, Queueable, ChunkUploader) { - - - function FileUploader(file, queue) { - var _chunks = new Collection(); - var _totalChunks = 1; - - Queueable.call(this); - - this._options = { - chunk_size: 0, - params: {}, - send_file_name: true, - stop_on_fail: true - }; - - plupload.extend(this, { - /** - When send_file_name is set to true, will be sent with the request as `name` param. - Can be used on server-side to override original file name. - - @property name - @type {String} - */ - name: file.name, - - - start: function() { - var self = this; - var prevState = this.state; - var up; - - if (this.state === Queueable.PROCESSING) { - return false; - } - - if (!this.startedTimestamp) { - this.startedTimestamp = +new Date(); - } - - this.state = Queueable.PROCESSING; - this.trigger('statechanged', this.state, prevState); - - // send additional 'name' parameter only if required or explicitly requested - if (self._options.send_file_name) { - self._options.params.name = self.target_name || self.name; - } - - if (self._options.chunk_size) { - _totalChunks = Math.ceil(file.size / self._options.chunk_size); - self.uploadChunk(false, true); - } else { - up = new ChunkUploader(file); - - up.bind('progress', function(e) { - self.progress(e.loaded, e.total); - }); - - up.bind('done', function(e, result) { - self.done(result); - }); - - up.bind('failed', function(e, result) { - self.failed(result); - }); - - up.setOptions(self._options); - - queue.addItem(up); - } - - this.trigger('started'); - }, - - - uploadChunk: function(seq, dontStop) { - var self = this; - var chunkSize = this.getOption('chunk_size'); - var up; - var chunk = {}; - var _options; - - chunk.seq = parseInt(seq, 10) || getNextChunk(); - chunk.start = chunk.seq * chunkSize; - chunk.end = Math.min(chunk.start + chunkSize, file.size); - chunk.total = file.size; - - // do not proceed for weird chunks - if (chunk.start < 0 || chunk.start >= file.size) { - return false; - } - - _options = plupload.extendImmutable({}, this.getOptions(), { - params: { - chunk: chunk.seq, - chunks: _totalChunks - } - }); - - up = new ChunkUploader(file.slice(chunk.start, chunk.end, file.type)); - - up.bind('progress', function(e) { - self.progress(calcProcessed() + e.loaded, file.size); - }); - - up.bind('failed', function(e, result) { - _chunks.add(chunk.seq, plupload.extend({ - state: Queueable.FAILED - }, chunk)); - - self.trigger('chunkuploadfailed', plupload.extendImmutable({}, chunk, result)); - - if (_options.stop_on_fail) { - self.failed(result); - } - }); - - up.bind('done', function(e, result) { - _chunks.add(chunk.seq, plupload.extend({ - state: Queueable.DONE - }, chunk)); - - self.trigger('chunkuploaded', plupload.extendImmutable({}, chunk, result)); - - if (calcProcessed() >= file.size) { - self.progress(file.size, file.size); - self.done(result); // obviously we are done - } else if (dontStop) { - plupload.delay(function() { - self.uploadChunk(getNextChunk(), dontStop); - }); - } - }); - - up.bind('processed', function() { - this.destroy(); - }); - - up.setOptions(_options); - - _chunks.add(chunk.seq, plupload.extend({ - state: Queueable.PROCESSING - }, chunk)); - - queue.addItem(up); - - // enqueue even more chunks if slots available - if (dontStop && queue.countSpareSlots()) { - self.uploadChunk(getNextChunk(), dontStop); - } - - return true; - }, - - destroy: function() { - FileUploader.prototype.destroy.call(this); - _chunks.clear(); - } - }); - - - function calcProcessed() { - var processed = 0; - - _chunks.each(function(item) { - if (item.state === Queueable.DONE) { - processed += (item.end - item.start); - } - }); - - return processed; - } - - - function getNextChunk() { - var i = 0; - while (i < _totalChunks && _chunks.hasKey(i)) { - i++; - } - return i; - } - - } - - - plupload.inherit(FileUploader, Queueable); - - return FileUploader; -}); - -// Included from: src/ImageResizer.js - -/** - * ImageResizer.js - * - * Copyright 2017, Ephox - * Released under AGPLv3 License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** - @class plupload.ImageResizer - @extends plupload.core.Queueable - @constructor - @private - @final - @since 3.0 - @param {plupload.File} fileRef -*/ -define("plupload/ImageResizer", [ - 'plupload', - 'plupload/core/Queueable' -], function(plupload, Queueable) { - var mxiImage = moxie.image.Image; - - function ImageResizer(fileRef) { - - Queueable.call(this); - - this._options = { - type: 'image/jpeg', - quality: 90, - crop: false, - fit: true, - preserveHeaders: true, - resample: 'default', - multipass: true - }; - - this.setOption = function(option, value) { - if (typeof(option) !== 'object' && !this._options.hasOwnProperty(option)) { - return; - } - ImageResizer.prototype.setOption.apply(this, arguments); - }; - - - this.start = function(options) { - var self = this; - var img; - - if (options) { - this.setOptions(options.resize); - } - - img = new mxiImage(); - - img.bind('load', function() { - this.resize(self.getOptions()); - }); - - img.bind('resize', function() { - self.done(this.getAsBlob(self.getOption('type'), self.getOption('quality'))); - this.destroy(); - }); - - img.bind('error', function() { - self.failed(); - this.destroy(); - }); - - img.load(fileRef, self.getOption('runtimeOptions')); - }; - } - - plupload.inherit(ImageResizer, Queueable); - - // ImageResizer is only included for builds with Image manipulation support, so we add plupload.Image here manually - plupload.Image = mxiImage; - - return ImageResizer; -}); - -// Included from: src/File.js - -/** - * File.js - * - * Copyright 2017, Ephox - * Released under AGPLv3 License.se. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** - * @class plupload.File - * @extends plupload.core.Queueable - * @constructor - * @since 3.0 - * @final - */ -define('plupload/File', [ - 'plupload', - 'plupload/core/Queueable', - 'plupload/FileUploader', - 'plupload/ImageResizer' -], function(plupload, Queueable, FileUploader, ImageResizer) { - - function File(file, queueUpload, queueResize) { - Queueable.call(this); - - - plupload.extend(this, { - /** - * For backward compatibility - * - * @property id - * @type {String} - * @deprecated - */ - id: this.uid, - - - /** - When send_file_name is set to true, will be sent with the request as `name` param. - Can be used on server-side to override original file name. - - @property name - @type {String} - */ - name: file.name, - - /** - @property target_name - @type {String} - @deprecated use name - */ - target_name: null, - - /** - * File type, `e.g image/jpeg` - * - * @property type - * @type String - */ - type: file.type, - - /** - * File size in bytes (may change after client-side manupilation). - * - * @property size - * @type Number - */ - size: file.size, - - /** - * Original file size in bytes. - * - * @property origSize - * @type Number - */ - origSize: file.size, - - start: function() { - var prevState = this.state; - - if (this.state === Queueable.PROCESSING) { - return false; - } - - this.state = Queueable.PROCESSING; - this.trigger('statechanged', this.state, prevState); - this.trigger('started'); - - if (!plupload.isEmptyObj(this._options.resize) && isImage(this.type) && runtimeCan(file, 'send_binary_string')) { - this.resizeAndUpload(); - } else { - this.upload(); - } - return true; - }, - - /** - * Get the file for which this File is responsible - * - * @method getSource - * @returns {moxie.file.File} - */ - getSource: function() { - return file; - }, - - /** - * Returns file representation of the current runtime. For HTML5 runtime - * this is going to be native browser File object - * (for backward compatibility) - * - * @method getNative - * @deprecated - * @returns {File|Blob|Object} - */ - getNative: function() { - return this.getFile().getSource(); - }, - - - resizeAndUpload: function() { - var self = this; - var opts = self.getOptions(); - var rszr = new ImageResizer(file); - - rszr.bind('progress', function(e) { - self.progress(e.loaded, e.total); - }); - - rszr.bind('done', function(e, file) { - file = file; - self.upload(); - }); - - rszr.bind('failed', function() { - self.upload(); - }); - - rszr.setOption('runtimeOptions', { - runtime_order: opts.runtimes, - required_caps: opts.required_features, - preferred_caps: opts.preferred_caps, - swf_url: opts.flash_swf_url, - xap_url: opts.silverlight_xap_url - }); - - queueResize.addItem(rszr); - }, - - - upload: function() { - var self = this; - var up = new FileUploader(file, queueUpload); - - up.bind('paused', function() { - self.pause(); - }); - - up.bind('resumed', function() { - this.start(); - }); - - up.bind('started', function() { - self.trigger('startupload'); - }); - - up.bind('progress', function(e) { - self.progress(e.loaded, e.total); - }); - - up.bind('done', function(e, result) { - self.done(result); - }); - - up.bind('failed', function(e, result) { - self.failed(result); - }); - - up.setOptions(self.getOptions()); - - up.start(); - }, - - - - destroy: function() { - File.prototype.destroy.call(this); - file = null; - } - }); - } - - - function isImage(type) { - return plupload.inArray(type, ['image/jpeg', 'image/png']) > -1; - } - - - function runtimeCan(blob, cap) { - if (blob.ruid) { - var info = plupload.Runtime.getInfo(blob.ruid); - if (info) { - return info.can(cap); - } - } - return false; - } - - - plupload.inherit(File, Queueable); - - return File; -}); - -// Included from: src/Uploader.js - -/** - * Uploader.js - * - * Copyright 2017, Ephox - * Released under AGPLv3 License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - - -/** -@class plupload.Uploader -@extends plupload.core.Queue -@constructor -@public -@final - -@param {Object} settings For detailed information about each option check documentation. - @param {String|DOMElement} settings.browse_button id of the DOM element or DOM element itself to use as file dialog trigger. - @param {Number|String} [settings.chunk_size=0] Chunk size in bytes to slice the file into. Shorcuts with b, kb, mb, gb, tb suffixes also supported. `e.g. 204800 or "204800b" or "200kb"`. By default - disabled. - @param {Boolean} [settings.send_chunk_number=true] Whether to send chunks and chunk numbers, or total and offset bytes. - @param {String|DOMElement} [settings.container] id of the DOM element or DOM element itself that will be used to wrap uploader structures. Defaults to immediate parent of the `browse_button` element. - @param {String|DOMElement} [settings.drop_element] id of the DOM element or DOM element itself to use as a drop zone for Drag-n-Drop. - @param {String} [settings.file_data_name="file"] Name for the file field in Multipart formated message. - @param {Object} [settings.filters={}] Set of file type filters. - @param {Array} [settings.filters.mime_types=[]] List of file types to accept, each one defined by title and list of extensions. `e.g. {title : "Image files", extensions : "jpg,jpeg,gif,png"}`. Dispatches `plupload.FILE_EXTENSION_ERROR` - @param {String|Number} [settings.filters.max_file_size=0] Maximum file size that the user can pick, in bytes. Optionally supports b, kb, mb, gb, tb suffixes. `e.g. "10mb" or "1gb"`. By default - not set. Dispatches `plupload.FILE_SIZE_ERROR`. - @param {Boolean} [settings.filters.prevent_duplicates=false] Do not let duplicates into the queue. Dispatches `plupload.FILE_DUPLICATE_ERROR`. - @param {String} [settings.flash_swf_url] URL of the Flash swf. - @param {Object} [settings.headers] Custom headers to send with the upload. Hash of name/value pairs. - @param {String} [settings.http_method="POST"] HTTP method to use during upload (only PUT or POST allowed). - @param {Number} [settings.max_retries=0] How many times to retry the chunk or file, before triggering Error event. - @param {Boolean} [settings.multipart=true] Whether to send file and additional parameters as Multipart formated message. - @param {Boolean} [settings.multi_selection=true] Enable ability to select multiple files at once in file dialog. - @param {Object} [settings.params] Hash of key/value pairs to send with every file upload. - @param {String|Object} [settings.required_features] Either comma-separated list or hash of required features that chosen runtime should absolutely possess. - @param {Object} [settings.resize] Enable resizing of images on client-side. Applies to `image/jpeg` and `image/png` only. `e.g. {width : 200, height : 200, quality : 90, crop: true}` - @param {Number} settings.resize.width Resulting width - @param {Number} [settings.resize.height=width] Resulting height (optional, if not supplied will default to width) - @param {String} [settings.resize.type='image/jpeg'] MIME type of the resulting image - @param {Number} [settings.resize.quality=90] In the case of JPEG, controls the quality of resulting image - @param {Boolean} [settings.resize.crop='cc'] If not falsy, image will be cropped, by default from center - @param {Boolean} [settings.resize.fit=true] In case of crop whether to upscale the image to fit the exact dimensions - @param {Boolean} [settings.resize.preserveHeaders=true] Whether to preserve meta headers (on JPEGs after resize) - @param {String} [settings.resize.resample='default'] Resampling algorithm to use during resize - @param {Boolean} [settings.resize.multipass=true] Whether to scale the image in steps (results in better quality) - @param {String} [settings.runtimes="html5,flash,silverlight,html4"] Comma separated list of runtimes, that Plupload will try in turn, moving to the next if previous fails. - @param {Boolean} [settings.send_file_name=true] Whether to send file name as additional argument - 'name' (required for chunked uploads and some other cases where file name cannot be sent via normal ways). - @param {String} [settings.silverlight_xap_url] URL of the Silverlight xap. - @param {Boolean} [settings.unique_names=false] If true will generate unique filenames for uploaded files. - @param {String} settings.url URL of the server-side upload handler. -*/ - -/** -Fires when the current RunTime has been initialized. - -@event Init -@param {plupload.Uploader} uploader Uploader instance sending the event. - */ - -/** -Fires after the init event incase you need to perform actions there. - -@event PostInit -@param {plupload.Uploader} uploader Uploader instance sending the event. - */ - -/** -Fires when the option is changed in via uploader.setOption(). - -@event OptionChanged -@since 2.1 -@param {plupload.Uploader} uploader Uploader instance sending the event. -@param {String} name Name of the option that was changed -@param {Mixed} value New value for the specified option -@param {Mixed} oldValue Previous value of the option - */ - -/** -Fires when the silverlight/flash or other shim needs to move. - -@event Refresh -@param {plupload.Uploader} uploader Uploader instance sending the event. - */ - -/** -Fires when the overall state is being changed for the upload queue. - -@event StateChanged -@param {plupload.Uploader} uploader Uploader instance sending the event. - */ - -/** -Fires when browse_button is clicked and browse dialog shows. - -@event Browse -@since 2.1.2 -@param {plupload.Uploader} uploader Uploader instance sending the event. - */ - -/** -Fires for every filtered file before it is added to the queue. - -@event FileFiltered -@since 2.1 -@param {plupload.Uploader} uploader Uploader instance sending the event. -@param {plupload.File} file Another file that has to be added to the queue. - */ - -/** -Fires when the file queue is changed. In other words when files are added/removed to the files array of the uploader instance. - -@event QueueChanged -@param {plupload.Uploader} uploader Uploader instance sending the event. - */ - -/** -Fires after files were filtered and added to the queue. - -@event FilesAdded -@param {plupload.Uploader} uploader Uploader instance sending the event. -@param {Array} files Array of FileUploader objects that were added to the queue by user. - */ - -/** -Fires when file is removed from the queue. - -@event FilesRemoved -@param {plupload.Uploader} uploader Uploader instance sending the event. -@param {Array} files Array of files that got removed. - */ - -/** -Fires just before a file is uploaded. Can be used to cancel upload of the current file -by returning false from the handler. - -@event BeforeUpload -@param {plupload.Uploader} uploader Uploader instance sending the event. -@param {plupload.File} file File to be uploaded. - */ - -/** -Fires when a file is to be uploaded by the runtime. - -@event UploadFile -@param {plupload.Uploader} uploader Uploader instance sending the event. -@param {plupload.File} file File to be uploaded. - */ - -/** -Fires while a file is being uploaded. Use this event to update the current file upload progress. - -@event UploadProgress -@param {plupload.Uploader} uploader Uploader instance sending the event. -@param {plupload.File} file File that is currently being uploaded. - */ - -/** -Fires when file chunk is uploaded. - -@event ChunkUploaded -@param {plupload.Uploader} uploader Uploader instance sending the event. -@param {plupload.File} file File that the chunk was uploaded for. -@param {Object} result Object with response properties. - @param {Number} result.offset The amount of bytes the server has received so far, including this chunk. - @param {Number} result.total The size of the file. - @param {String} result.response The response body sent by the server. - @param {Number} result.status The HTTP status code sent by the server. - @param {String} result.responseHeaders All the response headers as a single string. - */ - -/** -Fires when a file is successfully uploaded. - -@event FileUploaded -@param {plupload.Uploader} uploader Uploader instance sending the event. -@param {plupload.File} file File that was uploaded. -@param {Object} result Object with response properties. - @param {String} result.response The response body sent by the server. - @param {Number} result.status The HTTP status code sent by the server. - @param {String} result.responseHeaders All the response headers as a single string. - */ - -/** -Fires when all files in a queue are uploaded - -@event UploadComplete -@param {plupload.Uploader} uploader Uploader instance sending the event. - */ - - -/** -Fires whenever upload is aborted for some reason - -@event CancelUpload -@param {plupload.Uploader} uploader Uploader instance sending the event. - */ - -/** -Fires when a error occurs. - -@event Error -@param {plupload.Uploader} uploader Uploader instance sending the event. -@param {Object} error Contains code, message and sometimes file and other details. - @param {Number} error.code The plupload error code. - @param {String} error.message Description of the error (uses i18n). - */ - -/** -Fires when destroy method is called. - -@event Destroy -@param {plupload.Uploader} uploader Uploader instance sending the event. - */ -define('plupload/Uploader', [ - 'plupload', - 'plupload/core/Collection', - 'plupload/core/Queue', - 'plupload/QueueUpload', - 'plupload/QueueResize', - 'plupload/File' -], function(plupload, Collection, Queue, QueueUpload, QueueResize, PluploadFile) { - - var fileFilters = {}; - var undef; - - - function Uploader(options) { - var _fileInputs = []; - var _fileDrops = []; - var _queueUpload, _queueResize; - var _initialized = false; - var _disabled = false; - - var _options = normalizeOptions(plupload.extend({ - backward_compatibility: true, - chunk_size: 0, - file_data_name: 'file', - filters: { - mime_types: '*', - prevent_duplicates: false, - max_file_size: 0 - }, - flash_swf_url: 'js/Moxie.swf', - // @since 2.3 - http_method: 'POST', - // headers: false, // Plupload had a required feature with the same name, comment it to avoid confusion - max_resize_slots: 1, - max_retries: 0, - max_upload_slots: 1, - multipart: true, - multipart_params: {}, // deprecated, use - params, - multi_selection: true, - // @since 3 - params: {}, - resize: false, - runtimes: plupload.Runtime.order, - send_chunk_number: true, // whether to send chunks and chunk numbers, instead of total and offset bytes - send_file_name: true, - silverlight_xap_url: 'js/Moxie.xap', - - // during normalization, these should be processed last - required_features: false, - preferred_caps: false - }, options)); - - Queue.call(this); - - - // Add public methods - plupload.extend(this, { - - _options: _options, - - /** - * Unique id for the Uploader instance. - * - * @property id - * @type String - */ - id: this.uid, - - /** - * Current state of the total uploading progress. This one can either be plupload.STARTED or plupload.STOPPED. - * These states are controlled by the stop/start methods. The default value is STOPPED. - * - * @property state - * @type Number - */ - state: plupload.STOPPED, - - /** - * Map of features that are available for the uploader runtime. Features will be filled - * before the init event is called, these features can then be used to alter the UI for the end user. - * Some of the current features that might be in this map is: dragdrop, chunks, jpgresize, pngresize. - * - * @property features - * @type Object - * @deprecated - */ - features: {}, - - /** - * Object with name/value settings. - * - * @property settings - * @type Object - * @deprecated Use `getOption()/setOption()` - */ - settings : _options, - - /** - * Current runtime name - * - * @property runtime - * @type String - * @deprecated There might be multiple runtimes per uploader - */ - runtime: null, - - /** - * Current upload queue, an array of File instances - * - * @property files - * @deprecated use forEachItem(callback) to cycle over the items in the queue - * @type Array - */ - files: [], - - /** - * Total progess information. How many files has been uploaded, total percent etc. - * - * @property total - * @deprecated use stats - */ - total: this.stats, - - /** - * Initializes the Uploader instance and adds internal event listeners. - * - * @method init - */ - init: function() { - var self = this, preinitOpt, err; - - preinitOpt = self.getOption('preinit'); - if (typeof(preinitOpt) == "function") { - preinitOpt(self); - } else { - plupload.each(preinitOpt, function(func, name) { - self.bind(name, func); - }); - } - - bindEventListeners.call(self); - - // Check for required options - plupload.each(['container', 'browse_button', 'drop_element'], function(el) { - if (self.getOption(el) === null) { - err = { - code: plupload.INIT_ERROR, - message: plupload.sprintf(plupload.translate("%s specified, but cannot be found."), el) - } - return false; - } - }); - - if (err) { - return self.trigger('Error', err); - } - - - if (!self.getOption('browse_button') && !self.getOption('drop_element')) { - return self.trigger('Error', { - code: plupload.INIT_ERROR, - message: plupload.translate("You must specify either browse_button or drop_element.") - }); - } - - - initControls.call(self, function(initialized) { - var runtime; - var initOpt = self.getOption('init'); - var queueOpts = plupload.extendImmutable({}, self.getOption(), { auto_start: true }); - - if (typeof(initOpt) == "function") { - initOpt(self); - } else { - plupload.each(initOpt, function(func, name) { - self.bind(name, func); - }); - } - - if (initialized) { - _initialized = true; - runtime = plupload.Runtime.getInfo(getRUID()); - - _queueUpload = new QueueUpload(queueOpts); - _queueResize = new QueueResize(queueOpts); - - self.trigger('Init', { - ruid: runtime.uid, - runtime: self.runtime = runtime.type - }); - - self.trigger('PostInit'); - } else { - self.trigger('Error', { - code: plupload.INIT_ERROR, - message: plupload.translate('Init error.') - }); - } - }); - }, - - /** - * Set the value for the specified option(s). - * - * @method setOption - * @since 2.1 - * @param {String|Object} option Name of the option to change or the set of key/value pairs - * @param {Mixed} [value] Value for the option (is ignored, if first argument is object) - */ - setOption: function(option, value) { - if (_initialized) { - // following options cannot be changed after initialization - if (plupload.inArray(option, [ - 'container', - 'browse_button', - 'drop_element', - 'runtimes', - 'multi_selection', - 'flash_swf_url', - 'silverlight_xap_url' - ]) > -1) { - return this.trigger('Error', { - code: plupload.OPTION_ERROR, - message: plupload.sprintf(plupload.translate("%s option cannot be changed.")), - option: option - }); - } - } - - if (typeof(option) !== 'object') { - value = normalizeOption(option, value, this._options); - - // queues will take in only appropriate options - if (_queueUpload) { - _queueUpload.setOption(option, value); - } - if (_queueResize) { - _queueResize.setOption(option, value); - } - } - - Uploader.prototype.setOption.call(this, option, value); - }, - - /** - * Refreshes the upload instance by dispatching out a refresh event to all runtimes. - * This would for example reposition flash/silverlight shims on the page. - * - * @method refresh - */ - refresh: function() { - if (_fileInputs.length) { - plupload.each(_fileInputs, function(fileInput) { - fileInput.trigger('Refresh'); - }); - } - - if (_fileDrops.length) { - plupload.each(_fileDrops, function(fileDrops) { - fileDrops.trigger('Refresh'); - }); - } - - this.trigger('Refresh'); - }, - - /** - * Stops the upload of the queued files. - * - * @method stop - */ - stop: function() { - if (Uploader.prototype.stop.call(this) && this.state != plupload.STOPPED) { - this.trigger('CancelUpload'); - } - }, - - - /** - * Disables/enables browse button on request. - * - * @method disableBrowse - * @param {Boolean} disable Whether to disable or enable (default: true) - */ - disableBrowse: function() { - _disabled = arguments[0] !== undef ? arguments[0] : true; - - if (_fileInputs.length) { - plupload.each(_fileInputs, function(fileInput) { - fileInput.disable(_disabled); - }); - } - - this.trigger('DisableBrowse', _disabled); - }, - - /** - * Returns the specified FileUploader object by id - * - * @method getFile - * @deprecated use getItem() - * @param {String} id FileUploader id to look for - * @return {plupload.FileUploader} - */ - getFile: function(id) { - return this.getItem(id); - }, - - /** - * Adds file to the queue programmatically. Can be native file, instance of Plupload.File, - * instance of mOxie.File, input[type="file"] element, or array of these. Fires FilesAdded, - * if any files were added to the queue. Otherwise nothing happens. - * - * @method addFile - * @since 2.0 - * @param {plupload.File|mOxie.File|File|Node|Array} file File or files to add to the queue. - * @param {String} [fileName] If specified, will be used as a name for the file - */ - addFile: function(file, fileName) { - var self = this; - var queue = []; - var ruid; // spare runtime uid, for those files that do not have their own - var filesAdded = []; // here we track the files that got filtered and are added to the queue - - - function bindListeners(fileUp) { - fileUp.bind('beforestart', function(e) { - return self.trigger('BeforeUpload', e.target); - }); - - fileUp.bind('startupload', function() { - self.trigger('UploadFile', this); - }); - - fileUp.bind('progress', function() { - self.trigger('UploadProgress', this); - }); - - fileUp.bind('done', function(e, args) { - self.trigger('FileUploaded', this, args); - }); - - fileUp.bind('failed', function(e, err) { - self.trigger('Error', plupload.extend({ - code: plupload.HTTP_ERROR, - message: plupload.translate('HTTP Error.'), - file: this - }, err)); - }); - } - - - function filterFile(file, cb) { - var queue = []; - plupload.each(self.getOption('filters'), function(rule, name) { - if (fileFilters[name]) { - queue.push(function(cb) { - fileFilters[name].call(self, rule, file, function(res) { - cb(!res); - }); - }); - } - }); - plupload.inParallel(queue, cb); - } - - /** - * @method resolveFile - * @private - * @param {mxiFile|mxiBlob|FileUploader|File|Blob|input[type="file"]} file - */ - function resolveFile(file) { - var type = plupload.typeOf(file); - - // mxiFile (final step for other conditional branches) - if (file instanceof moxie.file.File) { - if (!file.ruid && !file.isDetached()) { - if (!ruid) { // weird case - return false; - } - file.ruid = ruid; - file.connectRuntime(ruid); - } - - queue.push(function(cb) { - // run through the internal and user-defined filters, if any - filterFile(file, function(err) { - var fileUp; - - if (!err) { - fileUp = new PluploadFile(file, _queueUpload, _queueResize); - - if (fileName) { - fileUp.name = fileName; - } - - bindListeners(fileUp); - - self.addItem(fileUp); // make files available for the filters by updating the main queue directly - filesAdded.push(fileUp); - self.trigger("FileFiltered", fileUp); - } - - plupload.delay(cb); // do not build up recursions or eventually we might hit the limits - }); - }); - } - // mxiBlob - else if (file instanceof moxie.file.Blob) { - resolveFile(file.getSource()); - file.destroy(); - } - // native File or blob - else if (plupload.inArray(type, ['file', 'blob']) !== -1) { - resolveFile(new moxie.file.File(null, file)); - } - // input[type="file"] - else if (type === 'node' && plupload.typeOf(file.files) === 'filelist') { - // if we are dealing with input[type="file"] - plupload.each(file.files, resolveFile); - } - // mixed array of any supported types (see above) - else if (type === 'array') { - fileName = null; // should never happen, but unset anyway to avoid funny situations - plupload.each(file, resolveFile); - } - } - - ruid = getRUID(); - - resolveFile(file); - - if (queue.length) { - plupload.inParallel(queue, function() { - // if any files left after filtration, trigger FilesAdded - if (filesAdded.length) { - self.trigger("FilesAdded", filesAdded); - } - }); - } - }, - - /** - * Removes a specific item from the queue - * - * @method removeFile - * @param {plupload.FileUploader|String} file - */ - removeFile: function(file) { - var item = this.extractItem(typeof(file) === 'string' ? file : file.uid); - if (item) { - this.trigger("FilesRemoved", [item]); - item.destroy(); - } - }, - - /** - * Removes part of the queue and returns removed files. - * Triggers FilesRemoved and consequently QueueChanged events. - * - * @method splice - * @param {Number} [start=0] Start index to remove from - * @param {Number} [length] Length of items to remove - */ - splice: function() { - var i = 0; - var shouldRestart = plupload.STARTED == this.state; - - var removed = Queue.prototype.splice.apply(this, arguments); - if (removed.length) { - this.trigger("FilesRemoved", removed); - - if (shouldRestart) { - this.stop(); - } - - for (i = 0; i < removed.length; i++) { - removed[i].destroy(); - } - - if (shouldRestart) { - this.start(); - } - } - }, - - /** - Dispatches the specified event name and its arguments to all listeners. - - @method trigger - @param {String} name Event name to fire. - @param {Object..} Multiple arguments to pass along to the listener functions. - */ - - // override the parent method to match Plupload-like event logic - dispatchEvent: function(type) { - var list, args, result; - - type = type.toLowerCase(); - - list = this.hasEventListener(type); - - if (list) { - // sort event list by priority - list.sort(function(a, b) { - return b.priority - a.priority; - }); - - // first argument should be current plupload.Uploader instance - args = [].slice.call(arguments); - args.shift(); - args.unshift(this); - - for (var i = 0; i < list.length; i++) { - // Fire event, break chain if false is returned - if (list[i].fn.apply(list[i].scope, args) === false) { - return false; - } - } - } - return true; - }, - - /** - Check whether uploader has any listeners to the specified event. - - @method hasEventListener - @param {String} name Event name to check for. - */ - - - /** - Adds an event listener by name. - - @method bind - @param {String} name Event name to listen for. - @param {function} fn Function to call ones the event gets fired. - @param {Object} [scope] Optional scope to execute the specified function in. - @param {Number} [priority=0] Priority of the event handler - handlers with higher priorities will be called first - */ - bind: function(name, fn, scope, priority) { - // adapt moxie EventTarget style to Plupload-like - plupload.Uploader.prototype.bind.call(this, name, fn, priority, scope); - } - - /** - Removes the specified event listener. - - @method unbind - @param {String} name Name of event to remove. - @param {function} fn Function to remove from listener. - */ - - /** - Removes all event listeners. - - @method unbindAll - */ - }); - - - // keep alive deprecated properties - if (_options.backward_compatibility) { - this.bind('FilesAdded FilesRemoved', function (up) { - up.files = up.toArray(); - }, this, 999); - - this.bind('OptionChanged', function (up, name, value) { - up.settings[name] = typeof(value) == 'object' ? plupload.extend({}, value) : value; - }, this, 999); - } - - - function getRUID() { - var ctrl = _fileInputs[0] || _fileDrops[0]; - if (ctrl) { - return ctrl.getRuntime().uid; - } - return false; - } - - - function bindEventListeners() { - this.bind('FilesAdded FilesRemoved', function(up) { - up.trigger('QueueChanged'); - up.refresh(); - }, this, 999); - - this.bind('BeforeUpload', onBeforeUpload); - - this.bind('Stopped', function(up) { - up.trigger('UploadComplete'); - }); - - this.bind('Error', onError); - - this.bind('Destroy', onDestroy); - } - - - function initControls(cb) { - var self = this; - var initialized = 0; - var queue = []; - - // common settings - var options = { - runtime_order: self.getOption('runtimes'), - required_caps: self.getOption('required_features'), - preferred_caps: self.getOption('preferred_caps'), - swf_url: self.getOption('flash_swf_url'), - xap_url: self.getOption('silverlight_xap_url') - }; - - // add runtime specific options if any - plupload.each(self.getOption('runtimes').split(/\s*,\s*/), function(runtime) { - if (self.getOption(runtime)) { - options[runtime] = self.getOption(runtime); - } - }); - - // initialize file pickers - there can be many - if (self.getOption('browse_button')) { - plupload.each(self.getOption('browse_button'), function(el) { - queue.push(function(cb) { - var fileInput = new moxie.file.FileInput(plupload.extend({}, options, { - accept: self.getOption('filters').mime_types, - name: self.getOption('file_data_name'), - multiple: self.getOption('multi_selection'), - container: self.getOption('container'), - browse_button: el - })); - - fileInput.onready = function() { - var info = plupload.Runtime.getInfo(this.ruid); - - // for backward compatibility - plupload.extend(self.features, { - chunks: info.can('slice_blob'), - multipart: info.can('send_multipart'), - multi_selection: info.can('select_multiple') - }); - - initialized++; - _fileInputs.push(this); - cb(); - }; - - fileInput.onchange = function() { - self.addFile(this.files); - }; - - fileInput.bind('mouseenter mouseleave mousedown mouseup', function(e) { - if (!_disabled) { - if (self.getOption('browse_button_hover')) { - if ('mouseenter' === e.type) { - plupload.addClass(el, self.getOption('browse_button_hover')); - } else if ('mouseleave' === e.type) { - plupload.removeClass(el, self.getOption('browse_button_hover')); - } - } - - if (self.getOption('browse_button_active')) { - if ('mousedown' === e.type) { - plupload.addClass(el, self.getOption('browse_button_active')); - } else if ('mouseup' === e.type) { - plupload.removeClass(el, self.getOption('browse_button_active')); - } - } - } - }); - - fileInput.bind('mousedown', function() { - self.trigger('Browse'); - }); - - fileInput.bind('error runtimeerror', function() { - fileInput = null; - cb(); - }); - - fileInput.init(); - }); - }); - } - - // initialize drop zones - if (self.getOption('drop_element')) { - plupload.each(self.getOption('drop_element'), function(el) { - queue.push(function(cb) { - var fileDrop = new moxie.file.FileDrop(plupload.extend({}, options, { - drop_zone: el - })); - - fileDrop.onready = function() { - var info = plupload.Runtime.getInfo(this.ruid); - - // for backward compatibility - plupload.extend(self.features, { - chunks: info.can('slice_blob'), - multipart: info.can('send_multipart'), - dragdrop: info.can('drag_and_drop') - }); - - initialized++; - _fileDrops.push(this); - cb(); - }; - - fileDrop.ondrop = function() { - self.addFile(this.files); - }; - - fileDrop.bind('error runtimeerror', function() { - fileDrop = null; - cb(); - }); - - fileDrop.init(); - }); - }); - } - - - plupload.inParallel(queue, function() { - if (typeof(cb) === 'function') { - cb(initialized); - } - }); - } - - - // Internal event handlers - function onBeforeUpload(up, file) { - // Generate unique target filenames - if (up.getOption('unique_names')) { - var matches = file.name.match(/\.([^.]+)$/), - ext = "part"; - if (matches) { - ext = matches[1]; - } - file.target_name = file.id + '.' + ext; - } - } - - - function onError(up, err) { - if (err.code === plupload.INIT_ERROR) { - up.destroy(); - } - else if (err.code === plupload.HTTP_ERROR && up.state == plupload.STARTED) { - up.trigger('CancelUpload'); - } - } - - - function onDestroy(up) { - up.forEachItem(function(file) { - file.destroy(); - }); - - if (_fileInputs.length) { - plupload.each(_fileInputs, function(fileInput) { - fileInput.destroy(); - }); - _fileInputs = []; - } - - if (_fileDrops.length) { - plupload.each(_fileDrops, function(fileDrop) { - fileDrop.destroy(); - }); - _fileDrops = []; - } - - _initialized = false; - - if (_queueUpload) { - _queueUpload.destroy(); - } - - if (_queueResize) { - _queueResize.destroy(); - } - - _options = _queueUpload = _queueResize = null; // purge these exclusively - - } - - } - - - // convert plupload features to caps acceptable by mOxie - function normalizeCaps(settings) { - var features = settings.required_features, - caps = {}; - - function resolve(feature, value, strict) { - // Feature notation is deprecated, use caps (this thing here is required for backward compatibility) - var map = { - chunks: 'slice_blob', - jpgresize: 'send_binary_string', - pngresize: 'send_binary_string', - progress: 'report_upload_progress', - multi_selection: 'select_multiple', - dragdrop: 'drag_and_drop', - drop_element: 'drag_and_drop', - headers: 'send_custom_headers', - urlstream_upload: 'send_binary_string', - canSendBinary: 'send_binary', - triggerDialog: 'summon_file_dialog' - }; - - if (map[feature]) { - caps[map[feature]] = value; - } else if (!strict) { - caps[feature] = value; - } - } - - if (typeof(features) === 'string') { - plupload.each(features.split(/\s*,\s*/), function(feature) { - resolve(feature, true); - }); - } else if (typeof(features) === 'object') { - plupload.each(features, function(value, feature) { - resolve(feature, value); - }); - } else if (features === true) { - // check settings for required features - if (settings.chunk_size && settings.chunk_size > 0) { - caps.slice_blob = true; - } - - if (!plupload.isEmptyObj(settings.resize) || settings.multipart === false) { - caps.send_binary_string = true; - } - - if (settings.http_method) { - caps.use_http_method = settings.http_method; - } - - plupload.each(settings, function(value, feature) { - resolve(feature, !!value, true); // strict check - }); - } - - return caps; - } - - function normalizeOptions(options) { - plupload.each(options, function(value, option) { - options[option] = normalizeOption(option, value, options); - }); - return options; - } - - /** - Normalize an option. - - @method normalizeOption - @private - - @param {String} option Name of the option to normalize - @param {Mixed} value - @param {Object} options The whole set of options, that might be modified during normalization (see max_file_size or unique_names)! - */ - function normalizeOption(option, value, options) { - switch (option) { - - case 'chunk_size': - if (value = plupload.parseSize(value)) { - options.send_file_name = true; - } - break; - - case 'headers': - var headers = {}; - if (typeof(value) === 'object') { - plupload.each(value, function(value, key) { - headers[key.toLowerCase()] = value; - }); - } - return headers; - - case 'http_method': - return value.toUpperCase() === 'PUT' ? 'PUT' : 'POST'; - - - case 'filters': - if (plupload.typeOf(value) === 'array') { // for backward compatibility - value = { - mime_types: value - }; - } - - // if file format filters are being updated, regenerate the matching expressions - if (value.mime_types) { - if (plupload.typeOf(value.mime_types) === 'string') { - value.mime_types = plupload.mimes2extList(value.mime_types); - } - - // generate and cache regular expression for filtering file extensions - options.re_ext_filter = (function(filters) { - var extensionsRegExp = []; - - plupload.each(filters, function(filter) { - plupload.each(filter.extensions.split(/,/), function(ext) { - if (/^\s*\*\s*$/.test(ext)) { - extensionsRegExp.push('\\.*'); - } else { - extensionsRegExp.push('\\.' + ext.replace(new RegExp('[' + ('/^$.*+?|()[]{}\\'.replace(/./g, '\\$&')) + ']', 'g'), '\\$&')); - } - }); - }); - - return new RegExp('(' + extensionsRegExp.join('|') + ')$', 'i'); - }(value.mime_types)); - } - - return value; - - case 'max_file_size': - if (options && !options.filters) { - options.filters = {}; - } - options.filters.max_file_size = value; - break; - - case 'multipart': - if (!value) { - options.send_file_name = true; - } - break; - - case 'multipart_params': - options.params = options.multipart_params = value; - break; - - case 'resize': - if (value) { - return plupload.extend({ - preserve_headers: true, - crop: false - }, value); - } - return false; - - case 'prevent_duplicates': - if (options && !options.filters) { - options.filters = {}; - } - options.filters.prevent_duplicates = !!value; - break; - - case 'unique_names': - if (value) { - options.send_file_name = true; - } - break; - - case 'required_features': - // Normalize the list of required capabilities - return normalizeCaps(plupload.extend({}, options)); - - case 'preferred_caps': - // Come up with the list of capabilities that can affect default mode in a multi-mode runtimes - return normalizeCaps(plupload.extend({}, options, { - required_features: true - })); - - // options that require reinitialisation - case 'container': - case 'browse_button': - case 'drop_element': - return 'container' === option ? plupload.get(value) : plupload.getAll(value); - } - - return value; - } - - - /** - * Registers a filter that will be executed for each file added to the queue. - * If callback returns false, file will not be added. - * - * Callback receives two arguments: a value for the filter as it was specified in settings.filters - * and a file to be filtered. Callback is executed in the context of uploader instance. - * - * @method addFileFilter - * @static - * @param {String} name Name of the filter by which it can be referenced in settings.filters - * @param {String} cb Callback - the actual routine that every added file must pass - */ - function addFileFilter(name, cb) { - fileFilters[name] = cb; - } - - - /** - * A way to predict what runtime will be choosen in the current environment with the - * specified settings. - * - * @method predictRuntime - * @static - * @param {Object|String} config Plupload settings to check - * @param {String} [runtimes] Comma-separated list of runtimes to check against - * @return {String} Type of compatible runtime - */ - function predictRuntime(config, runtimes) { - var up, runtime; - - up = new Uploader(config); - runtime = plupload.Runtime.thatCan(up.getOption('required_features'), runtimes || config.runtimes); - up.destroy(); - return runtime; - } - - - addFileFilter('mime_types', function(filters, file, cb) { - if (filters.length && !this.getOption('re_ext_filter').test(file.name)) { - this.trigger('Error', { - code: plupload.FILE_EXTENSION_ERROR, - message: plupload.translate('File extension error.'), - file: file - }); - cb(false); - } else { - cb(true); - } - }); - - - addFileFilter('max_file_size', function(maxSize, file, cb) { - var undef; - - maxSize = plupload.parseSize(maxSize); - - // Invalid file size - if (file.size !== undef && maxSize && file.size > maxSize) { - this.trigger('Error', { - code: plupload.FILE_SIZE_ERROR, - message: plupload.translate('File size error.'), - file: file - }); - cb(false); - } else { - cb(true); - } - }); - - - addFileFilter('prevent_duplicates', function(value, file, cb) { - var self = this; - if (value) { - this.forEachItem(function(item) { - // Compare by name and size (size might be 0 or undefined, but still equivalent for both) - if (file.name === item.name && file.size === item.size) { - self.trigger('Error', { - code: plupload.FILE_DUPLICATE_ERROR, - message: plupload.translate('Duplicate file error.'), - file: file - }); - cb(false); - return; - } - }); - } - cb(true); - }); - - - addFileFilter('prevent_empty', function(value, file, cb) { - if (value && !file.size && file.size !== undef) { - this.trigger('Error', { - code : plupload.FILE_SIZE_ERROR, - message : plupload.translate('File size error.'), - file : file - }); - cb(false); - } else { - cb(true); - } - }); - - - Uploader.addFileFilter = addFileFilter; - - plupload.inherit(Uploader, Queue); - - // for backward compatibility - plupload.addFileFilter = addFileFilter; - plupload.predictRuntime = predictRuntime; - - return Uploader; -}); - -expose(["plupload","plupload/core/Collection","plupload/core/ArrCollection","plupload/core/Optionable","plupload/core/Queueable","plupload/core/Stats","plupload/core/Queue","plupload/QueueUpload","plupload/QueueResize","plupload/ChunkUploader","plupload/FileUploader","plupload/ImageResizer","plupload/File","plupload/Uploader"]); -})(this); -})); \ No newline at end of file diff --git a/assets/javascripts/plupload/js/plupload.full.min.js b/assets/javascripts/plupload/js/plupload.full.min.js deleted file mode 100644 index 63bcd5b7..00000000 --- a/assets/javascripts/plupload/js/plupload.full.min.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * mOxie - multi-runtime File API & XMLHttpRequest L2 Polyfill - * v1.5.8 - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - * - * Date: 2018-02-19 - */ -!function(e,t){var i=function(){var e={};return t.apply(e,arguments),e.moxie};"function"==typeof define&&define.amd?define("moxie",[],i):"object"==typeof module&&module.exports?module.exports=i():e.moxie=i()}(this||window,function(){!function(e,t){"use strict";function i(e,t){for(var i,n=[],r=0;r0&&c(n,function(n,u){var c=-1!==h(e(n),["array","object"]);return n===r||t&&o[u]===r?!0:(c&&i&&(n=a(n)),e(o[u])===e(n)&&c?s(t,i,[o[u],n]):o[u]=n,void 0)})}),o}function u(e,t){function i(){this.constructor=e}for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n]);return i.prototype=t.prototype,e.prototype=new i,e.parent=t.prototype,e}function c(e,t){var i,n,r,o;if(e){try{i=e.length}catch(a){i=o}if(i===o||"number"!=typeof i){for(n in e)if(e.hasOwnProperty(n)&&t(e[n],n)===!1)return}else for(r=0;i>r;r++)if(t(e[r],r)===!1)return}}function l(t){var i;if(!t||"object"!==e(t))return!0;for(i in t)return!1;return!0}function d(t,i){function n(r){"function"===e(t[r])&&t[r](function(e){++ri;i++)if(t[i]===e)return i}return-1}function f(t,i){var n=[];"array"!==e(t)&&(t=[t]),"array"!==e(i)&&(i=[i]);for(var r in t)-1===h(t[r],i)&&n.push(t[r]);return n.length?n:!1}function p(e,t){var i=[];return c(e,function(e){-1!==h(e,t)&&i.push(e)}),i.length?i:null}function g(e){var t,i=[];for(t=0;ti;i++)n+=Math.floor(65535*Math.random()).toString(32);return(t||"o_")+n+(e++).toString(32)}}();return{guid:E,typeOf:e,extend:t,extendIf:i,extendImmutable:n,extendImmutableIf:r,clone:o,inherit:u,each:c,isEmptyObj:l,inSeries:d,inParallel:m,inArray:h,arrayDiff:f,arrayIntersect:p,toArray:g,trim:x,sprintf:w,parseSizeStr:v,delay:y}}),n("moxie/core/utils/Encode",[],function(){var e=function(e){return unescape(encodeURIComponent(e))},t=function(e){return decodeURIComponent(escape(e))},i=function(e,i){if("function"==typeof window.atob)return i?t(window.atob(e)):window.atob(e);var n,r,o,a,s,u,c,l,d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",m=0,h=0,f="",p=[];if(!e)return e;e+="";do a=d.indexOf(e.charAt(m++)),s=d.indexOf(e.charAt(m++)),u=d.indexOf(e.charAt(m++)),c=d.indexOf(e.charAt(m++)),l=a<<18|s<<12|u<<6|c,n=255&l>>16,r=255&l>>8,o=255&l,p[h++]=64==u?String.fromCharCode(n):64==c?String.fromCharCode(n,r):String.fromCharCode(n,r,o);while(m>18,s=63&l>>12,u=63&l>>6,c=63&l,p[h++]=d.charAt(a)+d.charAt(s)+d.charAt(u)+d.charAt(c);while(mn;n++)if(e[n]!=t[n]){if(e[n]=u(e[n]),t[n]=u(t[n]),e[n]t[n]){o=1;break}}if(!i)return o;switch(i){case">":case"gt":return o>0;case">=":case"ge":return o>=0;case"<=":case"le":return 0>=o;case"==":case"=":case"eq":return 0===o;case"<>":case"!=":case"ne":return 0!==o;case"":case"<":case"lt":return 0>o;default:return null}}var n=function(e){var t="",i="?",n="function",r="undefined",o="object",a="name",s="version",u={has:function(e,t){return-1!==t.toLowerCase().indexOf(e.toLowerCase())},lowerize:function(e){return e.toLowerCase()}},c={rgx:function(){for(var t,i,a,s,u,c,l,d=0,m=arguments;d0?2==u.length?t[u[0]]=typeof u[1]==n?u[1].call(this,l):u[1]:3==u.length?t[u[0]]=typeof u[1]!==n||u[1].exec&&u[1].test?l?l.replace(u[1],u[2]):e:l?u[1].call(this,l,u[2]):e:4==u.length&&(t[u[0]]=l?u[3].call(this,l.replace(u[1],u[2])):e):t[u]=l?l:e;break}if(c)break}return t},str:function(t,n){for(var r in n)if(typeof n[r]===o&&n[r].length>0){for(var a=0;a=")),i.use_blob_uri},use_data_uri:function(){var e=new Image;return e.onload=function(){i.use_data_uri=1===e.width&&1===e.height},setTimeout(function(){e.src="data:image/gif;base64,R0lGODlhAQABAIAAAP8AAAAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=="},1),!1}(),use_data_uri_over32kb:function(){return i.use_data_uri&&("IE"!==a.browser||a.version>=9)},use_data_uri_of:function(e){return i.use_data_uri&&33e3>e||i.use_data_uri_over32kb()},use_fileinput:function(){if(navigator.userAgent.match(/(Android (1.0|1.1|1.5|1.6|2.0|2.1))|(Windows Phone (OS 7|8.0))|(XBLWP)|(ZuneWP)|(w(eb)?OSBrowser)|(webOS)|(Kindle\/(1.0|2.0|2.5|3.0))/))return!1;var e=document.createElement("input");return e.setAttribute("type","file"),i.use_fileinput=!e.disabled},use_webgl:function(){var e,n=document.createElement("canvas"),r=null;try{r=n.getContext("webgl")||n.getContext("experimental-webgl")}catch(o){}return r||(r=null),e=!!r,i.use_webgl=e,n=t,e}};return function(t){var n=[].slice.call(arguments);return n.shift(),"function"===e.typeOf(i[t])?i[t].apply(this,n):!!i[t]}}(),o=(new n).getResult(),a={can:r,uaParser:n,browser:o.browser.name,version:o.browser.version,os:o.os.name,osVersion:o.os.version,verComp:i,swf_url:"../flash/Moxie.swf",xap_url:"../silverlight/Moxie.xap",global_event_dispatcher:"moxie.core.EventTarget.instance.dispatchEvent"};return a.OS=a.os,a}),n("moxie/core/Exceptions",["moxie/core/utils/Basic"],function(e){function t(e,t){var i;for(i in e)if(e[i]===t)return i;return null}return{RuntimeError:function(){function i(e,i){this.code=e,this.name=t(n,e),this.message=this.name+(i||": RuntimeError "+this.code)}var n={NOT_INIT_ERR:1,EXCEPTION_ERR:3,NOT_SUPPORTED_ERR:9,JS_ERR:4};return e.extend(i,n),i.prototype=Error.prototype,i}(),OperationNotAllowedException:function(){function t(e){this.code=e,this.name="OperationNotAllowedException"}return e.extend(t,{NOT_ALLOWED_ERR:1}),t.prototype=Error.prototype,t}(),ImageError:function(){function i(e){this.code=e,this.name=t(n,e),this.message=this.name+": ImageError "+this.code}var n={WRONG_FORMAT:1,MAX_RESOLUTION_ERR:2,INVALID_META_ERR:3};return e.extend(i,n),i.prototype=Error.prototype,i}(),FileException:function(){function i(e){this.code=e,this.name=t(n,e),this.message=this.name+": FileException "+this.code}var n={NOT_FOUND_ERR:1,SECURITY_ERR:2,ABORT_ERR:3,NOT_READABLE_ERR:4,ENCODING_ERR:5,NO_MODIFICATION_ALLOWED_ERR:6,INVALID_STATE_ERR:7,SYNTAX_ERR:8};return e.extend(i,n),i.prototype=Error.prototype,i}(),DOMException:function(){function i(e){this.code=e,this.name=t(n,e),this.message=this.name+": DOMException "+this.code}var n={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25};return e.extend(i,n),i.prototype=Error.prototype,i}(),EventException:function(){function t(e){this.code=e,this.name="EventException"}return e.extend(t,{UNSPECIFIED_EVENT_TYPE_ERR:0}),t.prototype=Error.prototype,t}()}}),n("moxie/core/utils/Dom",["moxie/core/utils/Env"],function(e){var t=function(e){return"string"!=typeof e?e:document.getElementById(e)},i=function(e,t){if(!e.className)return!1;var i=new RegExp("(^|\\s+)"+t+"(\\s+|$)");return i.test(e.className)},n=function(e,t){i(e,t)||(e.className=e.className?e.className.replace(/\s+$/,"")+" "+t:t)},r=function(e,t){if(e.className){var i=new RegExp("(^|\\s+)"+t+"(\\s+|$)");e.className=e.className.replace(i,function(e,t,i){return" "===t&&" "===i?" ":""})}},o=function(e,t){return e.currentStyle?e.currentStyle[t]:window.getComputedStyle?window.getComputedStyle(e,null)[t]:void 0},a=function(t,i){function n(e){var t,i,n=0,r=0;return e&&(i=e.getBoundingClientRect(),t="CSS1Compat"===c.compatMode?c.documentElement:c.body,n=i.left+t.scrollLeft,r=i.top+t.scrollTop),{x:n,y:r}}var r,o,a,s=0,u=0,c=document;if(t=t,i=i||c.body,t&&t.getBoundingClientRect&&"IE"===e.browser&&(!c.documentMode||c.documentMode<8))return o=n(t),a=n(i),{x:o.x-a.x,y:o.y-a.y};for(r=t;r&&r!=i&&r.nodeType;)s+=r.offsetLeft||0,u+=r.offsetTop||0,r=r.offsetParent;for(r=t.parentNode;r&&r!=i&&r.nodeType;)s-=r.scrollLeft||0,u-=r.scrollTop||0,r=r.parentNode;return{x:s,y:u}},s=function(e){return{w:e.offsetWidth||e.clientWidth,h:e.offsetHeight||e.clientHeight}};return{get:t,hasClass:i,addClass:n,removeClass:r,getStyle:o,getPos:a,getSize:s}}),n("moxie/core/EventTarget",["moxie/core/utils/Env","moxie/core/Exceptions","moxie/core/utils/Basic"],function(e,t,i){function n(){this.uid=i.guid()}var r={};return i.extend(n.prototype,{init:function(){this.uid||(this.uid=i.guid("uid_"))},addEventListener:function(e,t,n,o){var a,s=this;return this.hasOwnProperty("uid")||(this.uid=i.guid("uid_")),e=i.trim(e),/\s/.test(e)?(i.each(e.split(/\s+/),function(e){s.addEventListener(e,t,n,o)}),void 0):(e=e.toLowerCase(),n=parseInt(n,10)||0,a=r[this.uid]&&r[this.uid][e]||[],a.push({fn:t,priority:n,scope:o||this}),r[this.uid]||(r[this.uid]={}),r[this.uid][e]=a,void 0)},hasEventListener:function(e){var t;return e?(e=e.toLowerCase(),t=r[this.uid]&&r[this.uid][e]):t=r[this.uid],t?t:!1},removeEventListener:function(e,t){var n,o,a=this;if(e=e.toLowerCase(),/\s/.test(e))return i.each(e.split(/\s+/),function(e){a.removeEventListener(e,t)}),void 0;if(n=r[this.uid]&&r[this.uid][e]){if(t){for(o=n.length-1;o>=0;o--)if(n[o].fn===t){n.splice(o,1);break}}else n=[];n.length||(delete r[this.uid][e],i.isEmptyObj(r[this.uid])&&delete r[this.uid])}},removeAllEventListeners:function(){r[this.uid]&&delete r[this.uid]},dispatchEvent:function(e){var n,o,a,s,u,c={},l=!0;if("string"!==i.typeOf(e)){if(s=e,"string"!==i.typeOf(s.type))throw new t.EventException(t.EventException.UNSPECIFIED_EVENT_TYPE_ERR);e=s.type,s.total!==u&&s.loaded!==u&&(c.total=s.total,c.loaded=s.loaded),c.async=s.async||!1}if(-1!==e.indexOf("::")?function(t){n=t[0],e=t[1]}(e.split("::")):n=this.uid,e=e.toLowerCase(),o=r[n]&&r[n][e]){o.sort(function(e,t){return t.priority-e.priority}),a=[].slice.call(arguments),a.shift(),c.type=e,a.unshift(c);var d=[];i.each(o,function(e){a[0].target=e.scope,c.async?d.push(function(t){setTimeout(function(){t(e.fn.apply(e.scope,a)===!1)},1)}):d.push(function(t){t(e.fn.apply(e.scope,a)===!1)})}),d.length&&i.inSeries(d,function(e){l=!e})}return l},bindOnce:function(e,t,i,n){var r=this;r.bind.call(this,e,function o(){return r.unbind(e,o),t.apply(this,arguments)},i,n)},bind:function(){this.addEventListener.apply(this,arguments)},unbind:function(){this.removeEventListener.apply(this,arguments)},unbindAll:function(){this.removeAllEventListeners.apply(this,arguments)},trigger:function(){return this.dispatchEvent.apply(this,arguments)},handleEventProps:function(e){var t=this;this.bind(e.join(" "),function(e){var t="on"+e.type.toLowerCase();"function"===i.typeOf(this[t])&&this[t].apply(this,arguments)}),i.each(e,function(e){e="on"+e.toLowerCase(e),"undefined"===i.typeOf(t[e])&&(t[e]=null)})}}),n.instance=new n,n}),n("moxie/runtime/Runtime",["moxie/core/utils/Env","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/EventTarget"],function(e,t,i,n){function r(e,n,o,s,u){var c,l=this,d=t.guid(n+"_"),m=u||"browser";e=e||{},a[d]=this,o=t.extend({access_binary:!1,access_image_binary:!1,display_media:!1,do_cors:!1,drag_and_drop:!1,filter_by_extension:!0,resize_image:!1,report_upload_progress:!1,return_response_headers:!1,return_response_type:!1,return_status_code:!0,send_custom_headers:!1,select_file:!1,select_folder:!1,select_multiple:!0,send_binary_string:!1,send_browser_cookies:!0,send_multipart:!0,slice_blob:!1,stream_upload:!1,summon_file_dialog:!1,upload_filesize:!0,use_http_method:!0},o),e.preferred_caps&&(m=r.getMode(s,e.preferred_caps,m)),c=function(){var e={};return{exec:function(t,i,n,r){return c[i]&&(e[t]||(e[t]={context:this,instance:new c[i]}),e[t].instance[n])?e[t].instance[n].apply(this,r):void 0},removeInstance:function(t){delete e[t]},removeAllInstances:function(){var i=this;t.each(e,function(e,n){"function"===t.typeOf(e.instance.destroy)&&e.instance.destroy.call(e.context),i.removeInstance(n)})}}}(),t.extend(this,{initialized:!1,uid:d,type:n,mode:r.getMode(s,e.required_caps,m),shimid:d+"_container",clients:0,options:e,can:function(e,i){var n=arguments[2]||o;if("string"===t.typeOf(e)&&"undefined"===t.typeOf(i)&&(e=r.parseCaps(e)),"object"===t.typeOf(e)){for(var a in e)if(!this.can(a,e[a],n))return!1;return!0}return"function"===t.typeOf(n[e])?n[e].call(this,i):i===n[e]},getShimContainer:function(){var e,n=i.get(this.shimid);return n||(e=i.get(this.options.container)||document.body,n=document.createElement("div"),n.id=this.shimid,n.className="moxie-shim moxie-shim-"+this.type,t.extend(n.style,{position:"absolute",top:"0px",left:"0px",width:"1px",height:"1px",overflow:"hidden"}),e.appendChild(n),e=null),n},getShim:function(){return c},shimExec:function(e,t){var i=[].slice.call(arguments,2);return l.getShim().exec.call(this,this.uid,e,t,i)},exec:function(e,t){var i=[].slice.call(arguments,2);return l[e]&&l[e][t]?l[e][t].apply(this,i):l.shimExec.apply(this,arguments)},destroy:function(){if(l){var e=i.get(this.shimid);e&&e.parentNode.removeChild(e),c&&c.removeAllInstances(),this.unbindAll(),delete a[this.uid],this.uid=null,d=l=c=e=null}}}),this.mode&&e.required_caps&&!this.can(e.required_caps)&&(this.mode=!1)}var o={},a={};return r.order="html5,flash,silverlight,html4",r.getRuntime=function(e){return a[e]?a[e]:!1},r.addConstructor=function(e,t){t.prototype=n.instance,o[e]=t},r.getConstructor=function(e){return o[e]||null},r.getInfo=function(e){var t=r.getRuntime(e);return t?{uid:t.uid,type:t.type,mode:t.mode,can:function(){return t.can.apply(t,arguments)}}:null},r.parseCaps=function(e){var i={};return"string"!==t.typeOf(e)?e||{}:(t.each(e.split(","),function(e){i[e]=!0}),i)},r.can=function(e,t){var i,n,o=r.getConstructor(e);return o?(i=new o({required_caps:t}),n=i.mode,i.destroy(),!!n):!1},r.thatCan=function(e,t){var i=(t||r.order).split(/\s*,\s*/);for(var n in i)if(r.can(i[n],e))return i[n];return null},r.getMode=function(e,i,n){var r=null;if("undefined"===t.typeOf(n)&&(n="browser"),i&&!t.isEmptyObj(e)){if(t.each(i,function(i,n){if(e.hasOwnProperty(n)){var o=e[n](i);if("string"==typeof o&&(o=[o]),r){if(!(r=t.arrayIntersect(r,o)))return r=!1}else r=o}}),r)return-1!==t.inArray(n,r)?n:r[0];if(r===!1)return!1}return n},r.getGlobalEventTarget=function(){if(/^moxie\./.test(e.global_event_dispatcher)&&!e.can("access_global_ns")){var i=t.guid("moxie_event_target_");window[i]=function(e,t){n.instance.dispatchEvent(e,t)},e.global_event_dispatcher=i}return e.global_event_dispatcher},r.capTrue=function(){return!0},r.capFalse=function(){return!1},r.capTest=function(e){return function(){return!!e}},r}),n("moxie/runtime/RuntimeClient",["moxie/core/utils/Env","moxie/core/Exceptions","moxie/core/utils/Basic","moxie/runtime/Runtime"],function(e,t,i,n){return function(){var e;i.extend(this,{connectRuntime:function(r){function o(i){var a,u;return i.length?(a=i.shift().toLowerCase(),(u=n.getConstructor(a))?(e=new u(r),e.bind("Init",function(){e.initialized=!0,setTimeout(function(){e.clients++,s.ruid=e.uid,s.trigger("RuntimeInit",e)},1)}),e.bind("Error",function(){e.destroy(),o(i)}),e.bind("Exception",function(e,i){var n=i.name+"(#"+i.code+")"+(i.message?", from: "+i.message:"");s.trigger("RuntimeError",new t.RuntimeError(t.RuntimeError.EXCEPTION_ERR,n))}),e.mode?(e.init(),void 0):(e.trigger("Error"),void 0)):(o(i),void 0)):(s.trigger("RuntimeError",new t.RuntimeError(t.RuntimeError.NOT_INIT_ERR)),e=null,void 0)}var a,s=this;if("string"===i.typeOf(r)?a=r:"string"===i.typeOf(r.ruid)&&(a=r.ruid),a){if(e=n.getRuntime(a))return s.ruid=a,e.clients++,e;throw new t.RuntimeError(t.RuntimeError.NOT_INIT_ERR)}o((r.runtime_order||n.order).split(/\s*,\s*/))},disconnectRuntime:function(){e&&--e.clients<=0&&e.destroy(),e=null},getRuntime:function(){return e&&e.uid?e:e=null},exec:function(){return e?e.exec.apply(this,arguments):null},can:function(t){return e?e.can(t):!1}})}}),n("moxie/file/Blob",["moxie/core/utils/Basic","moxie/core/utils/Encode","moxie/runtime/RuntimeClient"],function(e,t,i){function n(o,a){function s(t,i,o){var a,s=r[this.uid];return"string"===e.typeOf(s)&&s.length?(a=new n(null,{type:o,size:i-t}),a.detach(s.substr(t,a.size)),a):null}i.call(this),o&&this.connectRuntime(o),a?"string"===e.typeOf(a)&&(a={data:a}):a={},e.extend(this,{uid:a.uid||e.guid("uid_"),ruid:o,size:a.size||0,type:a.type||"",slice:function(e,t,i){return this.isDetached()?s.apply(this,arguments):this.getRuntime().exec.call(this,"Blob","slice",this.getSource(),e,t,i)},getSource:function(){return r[this.uid]?r[this.uid]:null},detach:function(e){if(this.ruid&&(this.getRuntime().exec.call(this,"Blob","destroy"),this.disconnectRuntime(),this.ruid=null),e=e||"","data:"==e.substr(0,5)){var i=e.indexOf(";base64,");this.type=e.substring(5,i),e=t.atob(e.substring(i+8))}this.size=e.length,r[this.uid]=e},isDetached:function(){return!this.ruid&&"string"===e.typeOf(r[this.uid])},destroy:function(){this.detach(),delete r[this.uid]}}),a.data?this.detach(a.data):r[this.uid]=a}var r={};return n}),n("moxie/core/I18n",["moxie/core/utils/Basic"],function(e){var t={};return{addI18n:function(i){return e.extend(t,i)},translate:function(e){return t[e]||e},_:function(e){return this.translate(e)},sprintf:function(t){var i=[].slice.call(arguments,1);return t.replace(/%[a-z]/g,function(){var t=i.shift();return"undefined"!==e.typeOf(t)?t:""})}}}),n("moxie/core/utils/Mime",["moxie/core/utils/Basic","moxie/core/I18n"],function(e,t){var i="application/msword,doc dot,application/pdf,pdf,application/pgp-signature,pgp,application/postscript,ps ai eps,application/rtf,rtf,application/vnd.ms-excel,xls xlb xlt xla,application/vnd.ms-powerpoint,ppt pps pot ppa,application/zip,zip,application/x-shockwave-flash,swf swfl,application/vnd.openxmlformats-officedocument.wordprocessingml.document,docx,application/vnd.openxmlformats-officedocument.wordprocessingml.template,dotx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,xlsx,application/vnd.openxmlformats-officedocument.presentationml.presentation,pptx,application/vnd.openxmlformats-officedocument.presentationml.template,potx,application/vnd.openxmlformats-officedocument.presentationml.slideshow,ppsx,application/x-javascript,js,application/json,json,audio/mpeg,mp3 mpga mpega mp2,audio/x-wav,wav,audio/x-m4a,m4a,audio/ogg,oga ogg,audio/aiff,aiff aif,audio/flac,flac,audio/aac,aac,audio/ac3,ac3,audio/x-ms-wma,wma,image/bmp,bmp,image/gif,gif,image/jpeg,jpg jpeg jpe,image/photoshop,psd,image/png,png,image/svg+xml,svg svgz,image/tiff,tiff tif,text/plain,asc txt text diff log,text/html,htm html xhtml,text/css,css,text/csv,csv,text/rtf,rtf,video/mpeg,mpeg mpg mpe m2v,video/quicktime,qt mov,video/mp4,mp4,video/x-m4v,m4v,video/x-flv,flv,video/x-ms-wmv,wmv,video/avi,avi,video/webm,webm,video/3gpp,3gpp 3gp,video/3gpp2,3g2,video/vnd.rn-realvideo,rv,video/ogg,ogv,video/x-matroska,mkv,application/vnd.oasis.opendocument.formula-template,otf,application/octet-stream,exe",n={},r={},o=function(e){var t,i,o,a=e.split(/,/);for(t=0;ta;a++)o+=String.fromCharCode(r[a]);return o}}t.call(this),e.extend(this,{uid:e.guid("uid_"),readAsBinaryString:function(e){return n.call(this,"readAsBinaryString",e)},readAsDataURL:function(e){return n.call(this,"readAsDataURL",e)},readAsText:function(e){return n.call(this,"readAsText",e)}})}}),n("moxie/xhr/FormData",["moxie/core/Exceptions","moxie/core/utils/Basic","moxie/file/Blob"],function(e,t,i){function n(){var e,n=[];t.extend(this,{append:function(r,o){var a=this,s=t.typeOf(o);o instanceof i?e={name:r,value:o}:"array"===s?(r+="[]",t.each(o,function(e){a.append(r,e)})):"object"===s?t.each(o,function(e,t){a.append(r+"["+t+"]",e)}):"null"===s||"undefined"===s||"number"===s&&isNaN(o)?a.append(r,"false"):n.push({name:r,value:o.toString()})},hasBlob:function(){return!!this.getBlob()},getBlob:function(){return e&&e.value||null},getBlobName:function(){return e&&e.name||null},each:function(i){t.each(n,function(e){i(e.value,e.name)}),e&&i(e.value,e.name)},destroy:function(){e=null,n=[]}})}return n}),n("moxie/xhr/XMLHttpRequest",["moxie/core/utils/Basic","moxie/core/Exceptions","moxie/core/EventTarget","moxie/core/utils/Encode","moxie/core/utils/Url","moxie/runtime/Runtime","moxie/runtime/RuntimeTarget","moxie/file/Blob","moxie/file/FileReaderSync","moxie/xhr/FormData","moxie/core/utils/Env","moxie/core/utils/Mime"],function(e,t,i,n,r,o,a,s,u,c,l,d){function m(){this.uid=e.guid("uid_")}function h(){function i(e,t){return I.hasOwnProperty(e)?1===arguments.length?l.can("define_property")?I[e]:A[e]:(l.can("define_property")?I[e]=t:A[e]=t,void 0):void 0}function u(t){function n(){_&&(_.destroy(),_=null),s.dispatchEvent("loadend"),s=null}function r(r){_.bind("LoadStart",function(e){i("readyState",h.LOADING),s.dispatchEvent("readystatechange"),s.dispatchEvent(e),L&&s.upload.dispatchEvent(e)}),_.bind("Progress",function(e){i("readyState")!==h.LOADING&&(i("readyState",h.LOADING),s.dispatchEvent("readystatechange")),s.dispatchEvent(e)}),_.bind("UploadProgress",function(e){L&&s.upload.dispatchEvent({type:"progress",lengthComputable:!1,total:e.total,loaded:e.loaded})}),_.bind("Load",function(t){i("readyState",h.DONE),i("status",Number(r.exec.call(_,"XMLHttpRequest","getStatus")||0)),i("statusText",f[i("status")]||""),i("response",r.exec.call(_,"XMLHttpRequest","getResponse",i("responseType"))),~e.inArray(i("responseType"),["text",""])?i("responseText",i("response")):"document"===i("responseType")&&i("responseXML",i("response")),U=r.exec.call(_,"XMLHttpRequest","getAllResponseHeaders"),s.dispatchEvent("readystatechange"),i("status")>0?(L&&s.upload.dispatchEvent(t),s.dispatchEvent(t)):(F=!0,s.dispatchEvent("error")),n()}),_.bind("Abort",function(e){s.dispatchEvent(e),n()}),_.bind("Error",function(e){F=!0,i("readyState",h.DONE),s.dispatchEvent("readystatechange"),M=!0,s.dispatchEvent(e),n()}),r.exec.call(_,"XMLHttpRequest","send",{url:x,method:v,async:T,user:w,password:y,headers:S,mimeType:D,encoding:O,responseType:s.responseType,withCredentials:s.withCredentials,options:k},t)}var s=this;E=(new Date).getTime(),_=new a,"string"==typeof k.required_caps&&(k.required_caps=o.parseCaps(k.required_caps)),k.required_caps=e.extend({},k.required_caps,{return_response_type:s.responseType}),t instanceof c&&(k.required_caps.send_multipart=!0),e.isEmptyObj(S)||(k.required_caps.send_custom_headers=!0),B||(k.required_caps.do_cors=!0),k.ruid?r(_.connectRuntime(k)):(_.bind("RuntimeInit",function(e,t){r(t)}),_.bind("RuntimeError",function(e,t){s.dispatchEvent("RuntimeError",t)}),_.connectRuntime(k))}function g(){i("responseText",""),i("responseXML",null),i("response",null),i("status",0),i("statusText",""),E=b=null}var x,v,w,y,E,b,_,R,A=this,I={timeout:0,readyState:h.UNSENT,withCredentials:!1,status:0,statusText:"",responseType:"",responseXML:null,responseText:null,response:null},T=!0,S={},O=null,D=null,N=!1,C=!1,L=!1,M=!1,F=!1,B=!1,P=null,H=null,k={},U="";e.extend(this,I,{uid:e.guid("uid_"),upload:new m,open:function(o,a,s,u,c){var l;if(!o||!a)throw new t.DOMException(t.DOMException.SYNTAX_ERR);if(/[\u0100-\uffff]/.test(o)||n.utf8_encode(o)!==o)throw new t.DOMException(t.DOMException.SYNTAX_ERR);if(~e.inArray(o.toUpperCase(),["CONNECT","DELETE","GET","HEAD","OPTIONS","POST","PUT","TRACE","TRACK"])&&(v=o.toUpperCase()),~e.inArray(v,["CONNECT","TRACE","TRACK"]))throw new t.DOMException(t.DOMException.SECURITY_ERR);if(a=n.utf8_encode(a),l=r.parseUrl(a),B=r.hasSameOrigin(l),x=r.resolveUrl(a),(u||c)&&!B)throw new t.DOMException(t.DOMException.INVALID_ACCESS_ERR);if(w=u||l.user,y=c||l.pass,T=s||!0,T===!1&&(i("timeout")||i("withCredentials")||""!==i("responseType")))throw new t.DOMException(t.DOMException.INVALID_ACCESS_ERR);N=!T,C=!1,S={},g.call(this),i("readyState",h.OPENED),this.dispatchEvent("readystatechange")},setRequestHeader:function(r,o){var a=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","content-transfer-encoding","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"];if(i("readyState")!==h.OPENED||C)throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);if(/[\u0100-\uffff]/.test(r)||n.utf8_encode(r)!==r)throw new t.DOMException(t.DOMException.SYNTAX_ERR);return r=e.trim(r).toLowerCase(),~e.inArray(r,a)||/^(proxy\-|sec\-)/.test(r)?!1:(S[r]?S[r]+=", "+o:S[r]=o,!0)},hasRequestHeader:function(e){return e&&S[e.toLowerCase()]||!1},getAllResponseHeaders:function(){return U||""},getResponseHeader:function(t){return t=t.toLowerCase(),F||~e.inArray(t,["set-cookie","set-cookie2"])?null:U&&""!==U&&(R||(R={},e.each(U.split(/\r\n/),function(t){var i=t.split(/:\s+/);2===i.length&&(i[0]=e.trim(i[0]),R[i[0].toLowerCase()]={header:i[0],value:e.trim(i[1])})})),R.hasOwnProperty(t))?R[t].header+": "+R[t].value:null},overrideMimeType:function(n){var r,o;if(~e.inArray(i("readyState"),[h.LOADING,h.DONE]))throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);if(n=e.trim(n.toLowerCase()),/;/.test(n)&&(r=n.match(/^([^;]+)(?:;\scharset\=)?(.*)$/))&&(n=r[1],r[2]&&(o=r[2])),!d.mimes[n])throw new t.DOMException(t.DOMException.SYNTAX_ERR);P=n,H=o},send:function(i,r){if(k="string"===e.typeOf(r)?{ruid:r}:r?r:{},this.readyState!==h.OPENED||C)throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);if(i instanceof s)k.ruid=i.ruid,D=i.type||"application/octet-stream";else if(i instanceof c){if(i.hasBlob()){var o=i.getBlob();k.ruid=o.ruid,D=o.type||"application/octet-stream"}}else"string"==typeof i&&(O="UTF-8",D="text/plain;charset=UTF-8",i=n.utf8_encode(i));this.withCredentials||(this.withCredentials=k.required_caps&&k.required_caps.send_browser_cookies&&!B),L=!N&&this.upload.hasEventListener(),F=!1,M=!i,N||(C=!0),u.call(this,i)},abort:function(){if(F=!0,N=!1,~e.inArray(i("readyState"),[h.UNSENT,h.OPENED,h.DONE]))i("readyState",h.UNSENT);else{if(i("readyState",h.DONE),C=!1,!_)throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);_.getRuntime().exec.call(_,"XMLHttpRequest","abort",M),M=!0}},destroy:function(){_&&("function"===e.typeOf(_.destroy)&&_.destroy(),_=null),this.unbindAll(),this.upload&&(this.upload.unbindAll(),this.upload=null)}}),this.handleEventProps(p.concat(["readystatechange"])),this.upload.handleEventProps(p)}var f={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",306:"Reserved",307:"Temporary Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Large",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",426:"Upgrade Required",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",510:"Not Extended"};m.prototype=i.instance;var p=["loadstart","progress","abort","error","load","timeout","loadend"];return h.UNSENT=0,h.OPENED=1,h.HEADERS_RECEIVED=2,h.LOADING=3,h.DONE=4,h.prototype=i.instance,h}),n("moxie/runtime/Transporter",["moxie/core/utils/Basic","moxie/core/utils/Encode","moxie/runtime/RuntimeClient","moxie/core/EventTarget"],function(e,t,i,n){function r(){function n(){l=d=0,c=this.result=null}function o(t,i){var n=this;u=i,n.bind("TransportingProgress",function(t){d=t.loaded,l>d&&-1===e.inArray(n.state,[r.IDLE,r.DONE])&&a.call(n)},999),n.bind("TransportingComplete",function(){d=l,n.state=r.DONE,c=null,n.result=u.exec.call(n,"Transporter","getAsBlob",t||"")},999),n.state=r.BUSY,n.trigger("TransportingStarted"),a.call(n)}function a(){var e,i=this,n=l-d;m>n&&(m=n),e=t.btoa(c.substr(d,m)),u.exec.call(i,"Transporter","receive",e,l)}var s,u,c,l,d,m;i.call(this),e.extend(this,{uid:e.guid("uid_"),state:r.IDLE,result:null,transport:function(t,i,r){var a=this;if(r=e.extend({chunk_size:204798},r),(s=r.chunk_size%3)&&(r.chunk_size+=3-s),m=r.chunk_size,n.call(this),c=t,l=t.length,"string"===e.typeOf(r)||r.ruid)o.call(a,i,this.connectRuntime(r));else{var u=function(e,t){a.unbind("RuntimeInit",u),o.call(a,i,t)};this.bind("RuntimeInit",u),this.connectRuntime(r)}},abort:function(){var e=this;e.state=r.IDLE,u&&(u.exec.call(e,"Transporter","clear"),e.trigger("TransportingAborted")),n.call(e)},destroy:function(){this.unbindAll(),u=null,this.disconnectRuntime(),n.call(this)}})}return r.IDLE=0,r.BUSY=1,r.DONE=2,r.prototype=n.instance,r}),n("moxie/image/Image",["moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/file/FileReaderSync","moxie/xhr/XMLHttpRequest","moxie/runtime/Runtime","moxie/runtime/RuntimeClient","moxie/runtime/Transporter","moxie/core/utils/Env","moxie/core/EventTarget","moxie/file/Blob","moxie/file/File","moxie/core/utils/Encode"],function(e,t,i,n,r,o,a,s,u,c,l,d,m){function h(){function n(e){try{return e||(e=this.exec("Image","getInfo")),this.size=e.size,this.width=e.width,this.height=e.height,this.type=e.type,this.meta=e.meta,""===this.name&&(this.name=e.name),!0}catch(t){return this.trigger("error",t.code),!1}}function c(t){var n=e.typeOf(t);try{if(t instanceof h){if(!t.size)throw new i.DOMException(i.DOMException.INVALID_STATE_ERR);p.apply(this,arguments)}else if(t instanceof l){if(!~e.inArray(t.type,["image/jpeg","image/png"]))throw new i.ImageError(i.ImageError.WRONG_FORMAT);g.apply(this,arguments)}else if(-1!==e.inArray(n,["blob","file"]))c.call(this,new d(null,t),arguments[1]);else if("string"===n)"data:"===t.substr(0,5)?c.call(this,new l(null,{data:t}),arguments[1]):x.apply(this,arguments);else{if("node"!==n||"img"!==t.nodeName.toLowerCase())throw new i.DOMException(i.DOMException.TYPE_MISMATCH_ERR);c.call(this,t.src,arguments[1])}}catch(r){this.trigger("error",r.code)}}function p(t,i){var n=this.connectRuntime(t.ruid);this.ruid=n.uid,n.exec.call(this,"Image","loadFromImage",t,"undefined"===e.typeOf(i)?!0:i)}function g(t,i){function n(e){r.ruid=e.uid,e.exec.call(r,"Image","loadFromBlob",t)}var r=this;r.name=t.name||"",t.isDetached()?(this.bind("RuntimeInit",function(e,t){n(t)}),i&&"string"==typeof i.required_caps&&(i.required_caps=o.parseCaps(i.required_caps)),this.connectRuntime(e.extend({required_caps:{access_image_binary:!0,resize_image:!0}},i))):n(this.connectRuntime(t.ruid))}function x(e,t){var i,n=this;i=new r,i.open("get",e),i.responseType="blob",i.onprogress=function(e){n.trigger(e)},i.onload=function(){g.call(n,i.response,!0)},i.onerror=function(e){n.trigger(e)},i.onloadend=function(){i.destroy()},i.bind("RuntimeError",function(e,t){n.trigger("RuntimeError",t)}),i.send(null,t)}a.call(this),e.extend(this,{uid:e.guid("uid_"),ruid:null,name:"",size:0,width:0,height:0,type:"",meta:{},clone:function(){this.load.apply(this,arguments)},load:function(){c.apply(this,arguments)},resize:function(t){var n,r,o=this,a={x:0,y:0,width:o.width,height:o.height},s=e.extendIf({width:o.width,height:o.height,type:o.type||"image/jpeg",quality:90,crop:!1,fit:!0,preserveHeaders:!0,resample:"default",multipass:!0},t);try{if(!o.size)throw new i.DOMException(i.DOMException.INVALID_STATE_ERR);if(o.width>h.MAX_RESIZE_WIDTH||o.height>h.MAX_RESIZE_HEIGHT)throw new i.ImageError(i.ImageError.MAX_RESOLUTION_ERR);if(n=o.meta&&o.meta.tiff&&o.meta.tiff.Orientation||1,-1!==e.inArray(n,[5,6,7,8])){var u=s.width;s.width=s.height,s.height=u}if(s.crop){switch(r=Math.max(s.width/o.width,s.height/o.height),t.fit?(a.width=Math.min(Math.ceil(s.width/r),o.width),a.height=Math.min(Math.ceil(s.height/r),o.height),r=s.width/a.width):(a.width=Math.min(s.width,o.width),a.height=Math.min(s.height,o.height),r=1),"boolean"==typeof s.crop&&(s.crop="cc"),s.crop.toLowerCase().replace(/_/,"-")){case"rb":case"right-bottom":a.x=o.width-a.width,a.y=o.height-a.height;break;case"cb":case"center-bottom":a.x=Math.floor((o.width-a.width)/2),a.y=o.height-a.height;break;case"lb":case"left-bottom":a.x=0,a.y=o.height-a.height;break;case"lt":case"left-top":a.x=0,a.y=0;break;case"ct":case"center-top":a.x=Math.floor((o.width-a.width)/2),a.y=0;break;case"rt":case"right-top":a.x=o.width-a.width,a.y=0;break;case"rc":case"right-center":case"right-middle":a.x=o.width-a.width,a.y=Math.floor((o.height-a.height)/2);break;case"lc":case"left-center":case"left-middle":a.x=0,a.y=Math.floor((o.height-a.height)/2);break;case"cc":case"center-center":case"center-middle":default:a.x=Math.floor((o.width-a.width)/2),a.y=Math.floor((o.height-a.height)/2)}a.x=Math.max(a.x,0),a.y=Math.max(a.y,0)}else r=Math.min(s.width/o.width,s.height/o.height),r>1&&!s.fit&&(r=1);this.exec("Image","resize",a,r,s)}catch(c){o.trigger("error",c.code)}},downsize:function(t){var i,n={width:this.width,height:this.height,type:this.type||"image/jpeg",quality:90,crop:!1,fit:!1,preserveHeaders:!0,resample:"default"};i="object"==typeof t?e.extend(n,t):e.extend(n,{width:arguments[0],height:arguments[1],crop:arguments[2],preserveHeaders:arguments[3]}),this.resize(i)},crop:function(e,t,i){this.downsize(e,t,!0,i)},getAsCanvas:function(){if(!u.can("create_canvas"))throw new i.RuntimeError(i.RuntimeError.NOT_SUPPORTED_ERR);return this.exec("Image","getAsCanvas")},getAsBlob:function(e,t){if(!this.size)throw new i.DOMException(i.DOMException.INVALID_STATE_ERR);return this.exec("Image","getAsBlob",e||"image/jpeg",t||90)},getAsDataURL:function(e,t){if(!this.size)throw new i.DOMException(i.DOMException.INVALID_STATE_ERR);return this.exec("Image","getAsDataURL",e||"image/jpeg",t||90)},getAsBinaryString:function(e,t){var i=this.getAsDataURL(e,t);return m.atob(i.substring(i.indexOf("base64,")+7))},embed:function(n,r){function o(t,r){var o=this;if(u.can("create_canvas")){var l=o.getAsCanvas();if(l)return n.appendChild(l),l=null,o.destroy(),c.trigger("embedded"),void 0}var d=o.getAsDataURL(t,r);if(!d)throw new i.ImageError(i.ImageError.WRONG_FORMAT);if(u.can("use_data_uri_of",d.length))n.innerHTML='',o.destroy(),c.trigger("embedded");else{var h=new s;h.bind("TransportingComplete",function(){a=c.connectRuntime(this.result.ruid),c.bind("Embedded",function(){e.extend(a.getShimContainer().style,{top:"0px",left:"0px",width:o.width+"px",height:o.height+"px"}),a=null},999),a.exec.call(c,"ImageView","display",this.result.uid,width,height),o.destroy()}),h.transport(m.atob(d.substring(d.indexOf("base64,")+7)),t,{required_caps:{display_media:!0},runtime_order:"flash,silverlight",container:n})}}var a,c=this,l=e.extend({width:this.width,height:this.height,type:this.type||"image/jpeg",quality:90,fit:!0,resample:"nearest"},r);try{if(!(n=t.get(n)))throw new i.DOMException(i.DOMException.INVALID_NODE_TYPE_ERR);if(!this.size)throw new i.DOMException(i.DOMException.INVALID_STATE_ERR);this.width>h.MAX_RESIZE_WIDTH||this.height>h.MAX_RESIZE_HEIGHT;var d=new h;return d.bind("Resize",function(){o.call(this,l.type,l.quality)}),d.bind("Load",function(){this.downsize(l)}),this.meta.thumb&&this.meta.thumb.width>=l.width&&this.meta.thumb.height>=l.height?d.load(this.meta.thumb.data):d.clone(this,!1),d}catch(f){this.trigger("error",f.code)}},destroy:function(){this.ruid&&(this.getRuntime().exec.call(this,"Image","destroy"),this.disconnectRuntime()),this.meta&&this.meta.thumb&&this.meta.thumb.data.destroy(),this.unbindAll()}}),this.handleEventProps(f),this.bind("Load Resize",function(){return n.call(this)},999)}var f=["progress","load","error","resize","embedded"];return h.MAX_RESIZE_WIDTH=8192,h.MAX_RESIZE_HEIGHT=8192,h.prototype=c.instance,h}),n("moxie/runtime/html5/Runtime",["moxie/core/utils/Basic","moxie/core/Exceptions","moxie/runtime/Runtime","moxie/core/utils/Env"],function(e,t,i,n){function o(t){var o=this,u=i.capTest,c=i.capTrue,l=e.extend({access_binary:u(window.FileReader||window.File&&window.File.getAsDataURL),access_image_binary:function(){return o.can("access_binary")&&!!s.Image},display_media:u((n.can("create_canvas")||n.can("use_data_uri_over32kb"))&&r("moxie/image/Image")),do_cors:u(window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest),drag_and_drop:u(function(){var e=document.createElement("div");return("draggable"in e||"ondragstart"in e&&"ondrop"in e)&&("IE"!==n.browser||n.verComp(n.version,9,">"))}()),filter_by_extension:u(function(){return!("Chrome"===n.browser&&n.verComp(n.version,28,"<")||"IE"===n.browser&&n.verComp(n.version,10,"<")||"Safari"===n.browser&&n.verComp(n.version,11,"<=")||"Firefox"===n.browser&&n.verComp(n.version,37,"<")||"iOS"===n.os||"Android"===n.os)}()),return_response_headers:c,return_response_type:function(e){return"json"===e&&window.JSON?!0:n.can("return_response_type",e)},return_status_code:c,report_upload_progress:u(window.XMLHttpRequest&&(new XMLHttpRequest).upload),resize_image:function(){return o.can("access_binary")&&n.can("create_canvas")},select_file:function(){return n.can("use_fileinput")&&window.File},select_folder:function(){return o.can("select_file")&&("Chrome"===n.browser&&n.verComp(n.version,21,">=")||"Firefox"===n.browser&&n.verComp(n.version,42,">="))},select_multiple:function(){return!(!o.can("select_file")||"Safari"===n.browser&&"Windows"===n.os||"iOS"===n.os&&n.verComp(n.osVersion,"7.0.0",">")&&n.verComp(n.osVersion,"8.0.0","<"))},send_binary_string:u(window.XMLHttpRequest&&((new XMLHttpRequest).sendAsBinary||window.Uint8Array&&window.ArrayBuffer)),send_custom_headers:u(window.XMLHttpRequest),send_multipart:function(){return!!(window.XMLHttpRequest&&(new XMLHttpRequest).upload&&window.FormData)||o.can("send_binary_string")},slice_blob:u(window.File&&(File.prototype.mozSlice||File.prototype.webkitSlice||File.prototype.slice)),stream_upload:function(){return o.can("slice_blob")&&o.can("send_multipart")},summon_file_dialog:function(){return o.can("select_file")&&!("Firefox"===n.browser&&n.verComp(n.version,4,"<")||"Opera"===n.browser&&n.verComp(n.version,12,"<")||"IE"===n.browser&&n.verComp(n.version,10,"<"))},upload_filesize:c,use_http_method:c},arguments[2]);i.call(this,t,arguments[1]||a,l),e.extend(this,{init:function(){this.trigger("Init")},destroy:function(e){return function(){e.call(o),e=o=null}}(this.destroy)}),e.extend(this.getShim(),s)}var a="html5",s={};return i.addConstructor(a,o),s}),n("moxie/runtime/html5/file/Blob",["moxie/runtime/html5/Runtime","moxie/file/Blob"],function(e,t){function i(){function e(e,t,i){var n;if(!window.File.prototype.slice)return(n=window.File.prototype.webkitSlice||window.File.prototype.mozSlice)?n.call(e,t,i):null;try{return e.slice(),e.slice(t,i)}catch(r){return e.slice(t,i-t)}}this.slice=function(){return new t(this.getRuntime().uid,e.apply(this,arguments))},this.destroy=function(){this.getRuntime().getShim().removeInstance(this.uid)}}return e.Blob=i}),n("moxie/core/utils/Events",["moxie/core/utils/Basic"],function(e){function t(){this.returnValue=!1}function i(){this.cancelBubble=!0}var n={},r="moxie_"+e.guid(),o=function(o,a,s,u){var c,l;a=a.toLowerCase(),o.addEventListener?(c=s,o.addEventListener(a,c,!1)):o.attachEvent&&(c=function(){var e=window.event;e.target||(e.target=e.srcElement),e.preventDefault=t,e.stopPropagation=i,s(e)},o.attachEvent("on"+a,c)),o[r]||(o[r]=e.guid()),n.hasOwnProperty(o[r])||(n[o[r]]={}),l=n[o[r]],l.hasOwnProperty(a)||(l[a]=[]),l[a].push({func:c,orig:s,key:u})},a=function(t,i,o){var a,s;if(i=i.toLowerCase(),t[r]&&n[t[r]]&&n[t[r]][i]){a=n[t[r]][i];for(var u=a.length-1;u>=0&&(a[u].orig!==o&&a[u].key!==o||(t.removeEventListener?t.removeEventListener(i,a[u].func,!1):t.detachEvent&&t.detachEvent("on"+i,a[u].func),a[u].orig=null,a[u].func=null,a.splice(u,1),o===s));u--);if(a.length||delete n[t[r]][i],e.isEmptyObj(n[t[r]])){delete n[t[r]];try{delete t[r]}catch(c){t[r]=s}}}},s=function(t,i){t&&t[r]&&e.each(n[t[r]],function(e,n){a(t,n,i)})};return{addEvent:o,removeEvent:a,removeAllEvents:s}}),n("moxie/runtime/html5/file/FileInput",["moxie/runtime/html5/Runtime","moxie/file/File","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/utils/Events","moxie/core/utils/Mime","moxie/core/utils/Env"],function(e,t,i,n,r,o,a){function s(){var e,s;i.extend(this,{init:function(u){var c,l,d,m,h,f,p=this,g=p.getRuntime();e=u,d=o.extList2mimes(e.accept,g.can("filter_by_extension")),l=g.getShimContainer(),l.innerHTML='",c=n.get(g.uid),i.extend(c.style,{position:"absolute",top:0,left:0,width:"100%",height:"100%"}),m=n.get(e.browse_button),s=n.getStyle(m,"z-index")||"auto",g.can("summon_file_dialog")&&("static"===n.getStyle(m,"position")&&(m.style.position="relative"),r.addEvent(m,"click",function(e){var t=n.get(g.uid);t&&!t.disabled&&t.click(),e.preventDefault()},p.uid),p.bind("Refresh",function(){h=parseInt(s,10)||1,n.get(e.browse_button).style.zIndex=h,this.getRuntime().getShimContainer().style.zIndex=h-1})),f=g.can("summon_file_dialog")?m:l,r.addEvent(f,"mouseover",function(){p.trigger("mouseenter")},p.uid),r.addEvent(f,"mouseout",function(){p.trigger("mouseleave")},p.uid),r.addEvent(f,"mousedown",function(){p.trigger("mousedown")},p.uid),r.addEvent(n.get(e.container),"mouseup",function(){p.trigger("mouseup")},p.uid),(g.can("summon_file_dialog")?c:m).setAttribute("tabindex",-1),c.onchange=function x(){if(p.files=[],i.each(this.files,function(i){var n="";return e.directory&&"."==i.name?!0:(i.webkitRelativePath&&(n="/"+i.webkitRelativePath.replace(/^\//,"")),i=new t(g.uid,i),i.relativePath=n,p.files.push(i),void 0)}),"IE"!==a.browser&&"IEMobile"!==a.browser)this.value="";else{var n=this.cloneNode(!0);this.parentNode.replaceChild(n,this),n.onchange=x}p.files.length&&p.trigger("change")},p.trigger({type:"ready",async:!0}),l=null},setOption:function(e,t){var i=this.getRuntime(),r=n.get(i.uid);switch(e){case"accept":if(t){var a=t.mimes||o.extList2mimes(t,i.can("filter_by_extension"));r.setAttribute("accept",a.join(","))}else r.removeAttribute("accept");break;case"directory":t&&i.can("select_folder")?(r.setAttribute("directory",""),r.setAttribute("webkitdirectory","")):(r.removeAttribute("directory"),r.removeAttribute("webkitdirectory"));break;case"multiple":t&&i.can("select_multiple")?r.setAttribute("multiple",""):r.removeAttribute("multiple")}},disable:function(e){var t,i=this.getRuntime();(t=n.get(i.uid))&&(t.disabled=!!e)},destroy:function(){var t=this.getRuntime(),i=t.getShim(),o=t.getShimContainer(),a=e&&n.get(e.container),u=e&&n.get(e.browse_button);a&&r.removeAllEvents(a,this.uid),u&&(r.removeAllEvents(u,this.uid),u.style.zIndex=s),o&&(r.removeAllEvents(o,this.uid),o.innerHTML=""),i.removeInstance(this.uid),e=o=a=u=i=null}})}return e.FileInput=s}),n("moxie/runtime/html5/file/FileDrop",["moxie/runtime/html5/Runtime","moxie/file/File","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/utils/Events","moxie/core/utils/Mime"],function(e,t,i,n,r,o){function a(){function e(e){if(!e.dataTransfer||!e.dataTransfer.types)return!1;var t=i.toArray(e.dataTransfer.types||[]);return-1!==i.inArray("Files",t)||-1!==i.inArray("public.file-url",t)||-1!==i.inArray("application/x-moz-file",t)}function a(e,i){if(u(e)){var n=new t(f,e);n.relativePath=i||"",p.push(n)}}function s(e){for(var t=[],n=0;n=")&&u.verComp(u.version,7,"<"),f="Android Browser"===u.browser,p=!1;if(h=i.url.replace(/^.+?\/([\w\-\.]+)$/,"$1").toLowerCase(),m=c(),m.open(i.method,i.url,i.async,i.user,i.password),r instanceof o)r.isDetached()&&(p=!0),r=r.getSource();else if(r instanceof a){if(r.hasBlob())if(r.getBlob().isDetached())r=d.call(s,r),p=!0;else if((l||f)&&"blob"===t.typeOf(r.getBlob().getSource())&&window.FileReader)return e.call(s,i,r),void 0;if(r instanceof a){var g=new window.FormData;r.each(function(e,t){e instanceof o?g.append(t,e.getSource()):g.append(t,e)}),r=g}}m.upload?(i.withCredentials&&(m.withCredentials=!0),m.addEventListener("load",function(e){s.trigger(e)}),m.addEventListener("error",function(e){s.trigger(e)}),m.addEventListener("progress",function(e){s.trigger(e)}),m.upload.addEventListener("progress",function(e){s.trigger({type:"UploadProgress",loaded:e.loaded,total:e.total})})):m.onreadystatechange=function(){switch(m.readyState){case 1:break;case 2:break;case 3:var e,t;try{n.hasSameOrigin(i.url)&&(e=m.getResponseHeader("Content-Length")||0),m.responseText&&(t=m.responseText.length)}catch(r){e=t=0}s.trigger({type:"progress",lengthComputable:!!e,total:parseInt(e,10),loaded:t});break;case 4:m.onreadystatechange=function(){};try{if(m.status>=200&&m.status<400){s.trigger("load");break}}catch(r){}s.trigger("error")}},t.isEmptyObj(i.headers)||t.each(i.headers,function(e,t){m.setRequestHeader(t,e)}),""!==i.responseType&&"responseType"in m&&(m.responseType="json"!==i.responseType||u.can("return_response_type","json")?i.responseType:"text"),p?m.sendAsBinary?m.sendAsBinary(r):function(){for(var e=new Uint8Array(r.length),t=0;t0&&o.set(new Uint8Array(t.slice(0,e)),0),o.set(new Uint8Array(r),e),o.set(new Uint8Array(t.slice(e+n)),e+r.byteLength),this.clear(),t=o.buffer,i=new DataView(t);break}default:return t}},length:function(){return t?t.byteLength:0},clear:function(){i=t=null}})}function n(t){function i(e,i,n){n=3===arguments.length?n:t.length-i-1,t=t.substr(0,i)+e+t.substr(n+i)}e.extend(this,{readByteAt:function(e){return t.charCodeAt(e)},writeByteAt:function(e,t){i(String.fromCharCode(t),e,1)},SEGMENT:function(e,n,r){switch(arguments.length){case 1:return t.substr(e);case 2:return t.substr(e,n);case 3:i(null!==r?r:"",e,n);break;default:return t}},length:function(){return t?t.length:0},clear:function(){t=null}})}return e.extend(t.prototype,{littleEndian:!1,read:function(e,t){var i,n,r;if(e+t>this.length())throw new Error("You are trying to read outside the source boundaries.");for(n=this.littleEndian?0:-8*(t-1),r=0,i=0;t>r;r++)i|=this.readByteAt(e+r)<this.length())throw new Error("You are trying to write outside the source boundaries.");for(n=this.littleEndian?0:-8*(i-1),r=0;i>r;r++)this.writeByteAt(e+r,255&t>>Math.abs(n+8*r))},BYTE:function(e){return this.read(e,1)},SHORT:function(e){return this.read(e,2)},LONG:function(e){return this.read(e,4)},SLONG:function(e){var t=this.read(e,4);return t>2147483647?t-4294967296:t},CHAR:function(e){return String.fromCharCode(this.read(e,1))},STRING:function(e,t){return this.asArray("CHAR",e,t).join("")},asArray:function(e,t,i){for(var n=[],r=0;i>r;r++)n[r]=this[e](t+r);return n}}),t}),n("moxie/runtime/html5/image/JPEGHeaders",["moxie/runtime/html5/utils/BinaryReader","moxie/core/Exceptions"],function(e,t){return function i(n){var r,o,a,s=[],u=0;if(r=new e(n),65496!==r.SHORT(0))throw r.clear(),new t.ImageError(t.ImageError.WRONG_FORMAT);for(o=2;o<=r.length();)if(a=r.SHORT(o),a>=65488&&65495>=a)o+=2;else{if(65498===a||65497===a)break;u=r.SHORT(o+2)+2,a>=65505&&65519>=a&&s.push({hex:a,name:"APP"+(15&a),start:o,length:u,segment:r.SEGMENT(o,u)}),o+=u}return r.clear(),{headers:s,restore:function(t){var i,n,r;for(r=new e(t),o=65504==r.SHORT(2)?4+r.SHORT(4):2,n=0,i=s.length;i>n;n++)r.SEGMENT(o,0,s[n].segment),o+=s[n].length;return t=r.SEGMENT(),r.clear(),t},strip:function(t){var n,r,o,a;for(o=new i(t),r=o.headers,o.purge(),n=new e(t),a=r.length;a--;)n.SEGMENT(r[a].start,r[a].length,"");return t=n.SEGMENT(),n.clear(),t},get:function(e){for(var t=[],i=0,n=s.length;n>i;i++)s[i].name===e.toUpperCase()&&t.push(s[i].segment);return t},set:function(e,t){var i,n,r,o=[];for("string"==typeof t?o.push(t):o=t,i=n=0,r=s.length;r>i&&(s[i].name===e.toUpperCase()&&(s[i].segment=o[n],s[i].length=o[n].length,n++),!(n>=o.length));i++);},purge:function(){this.headers=s=[]}}}}),n("moxie/runtime/html5/image/ExifParser",["moxie/core/utils/Basic","moxie/runtime/html5/utils/BinaryReader","moxie/core/Exceptions"],function(e,i,n){function r(o){function a(i,r){var o,a,s,u,c,m,h,f,p=this,g=[],x={},v={1:"BYTE",7:"UNDEFINED",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",9:"SLONG",10:"SRATIONAL"},w={BYTE:1,UNDEFINED:1,ASCII:1,SHORT:2,LONG:4,RATIONAL:8,SLONG:4,SRATIONAL:8};for(o=p.SHORT(i),a=0;o>a;a++)if(g=[],h=i+2+12*a,s=r[p.SHORT(h)],s!==t){if(u=v[p.SHORT(h+=2)],c=p.LONG(h+=2),m=w[u],!m)throw new n.ImageError(n.ImageError.INVALID_META_ERR);if(h+=4,m*c>4&&(h=p.LONG(h)+d.tiffHeader),h+m*c>=this.length())throw new n.ImageError(n.ImageError.INVALID_META_ERR);"ASCII"!==u?(g=p.asArray(u,h,c),f=1==c?g[0]:g,x[s]=l.hasOwnProperty(s)&&"object"!=typeof f?l[s][f]:f):x[s]=e.trim(p.STRING(h,c).replace(/\0$/,""))}return x}function s(e,t,i){var n,r,o,a=0;if("string"==typeof t){var s=c[e.toLowerCase()];for(var u in s)if(s[u]===t){t=u;break}}n=d[e.toLowerCase()+"IFD"],r=this.SHORT(n);for(var l=0;r>l;l++)if(o=n+12*l+2,this.SHORT(o)==t){a=o+8;break}if(!a)return!1;try{this.write(a,i,4)}catch(m){return!1}return!0}var u,c,l,d,m,h;if(i.call(this,o),c={tiff:{274:"Orientation",270:"ImageDescription",271:"Make",272:"Model",305:"Software",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer"},exif:{36864:"ExifVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",36867:"DateTimeOriginal",33434:"ExposureTime",33437:"FNumber",34855:"ISOSpeedRatings",37377:"ShutterSpeedValue",37378:"ApertureValue",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37386:"FocalLength",41986:"ExposureMode",41987:"WhiteBalance",41990:"SceneCaptureType",41988:"DigitalZoomRatio",41992:"Contrast",41993:"Saturation",41994:"Sharpness"},gps:{0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude"},thumb:{513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength"}},l={ColorSpace:{1:"sRGB",0:"Uncalibrated"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{1:"Daylight",2:"Fliorescent",3:"Tungsten",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 -5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},ExposureMode:{0:"Auto exposure",1:"Manual exposure",2:"Auto bracket"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},GPSLatitudeRef:{N:"North latitude",S:"South latitude"},GPSLongitudeRef:{E:"East longitude",W:"West longitude"}},d={tiffHeader:10},m=d.tiffHeader,u={clear:this.clear},e.extend(this,{read:function(){try{return r.prototype.read.apply(this,arguments)}catch(e){throw new n.ImageError(n.ImageError.INVALID_META_ERR)}},write:function(){try{return r.prototype.write.apply(this,arguments)}catch(e){throw new n.ImageError(n.ImageError.INVALID_META_ERR)}},UNDEFINED:function(){return this.BYTE.apply(this,arguments)},RATIONAL:function(e){return this.LONG(e)/this.LONG(e+4)},SRATIONAL:function(e){return this.SLONG(e)/this.SLONG(e+4)},ASCII:function(e){return this.CHAR(e)},TIFF:function(){return h||null},EXIF:function(){var t=null;if(d.exifIFD){try{t=a.call(this,d.exifIFD,c.exif)}catch(i){return null}if(t.ExifVersion&&"array"===e.typeOf(t.ExifVersion)){for(var n=0,r="";n=65472&&65475>=t)return n+=5,{height:e.SHORT(n),width:e.SHORT(n+=2)};i=e.SHORT(n+=2),n+=i-2}return null}function s(){var e,t,i=d.thumb();return i&&(e=new n(i),t=a(e),e.clear(),t)?(t.data=i,t):null}function u(){d&&l&&c&&(d.clear(),l.purge(),c.clear(),m=l=d=c=null)}var c,l,d,m;if(c=new n(o),65496!==c.SHORT(0))throw new t.ImageError(t.ImageError.WRONG_FORMAT);l=new i(o);try{d=new r(l.get("app1")[0])}catch(h){}m=a.call(this),e.extend(this,{type:"image/jpeg",size:c.length(),width:m&&m.width||0,height:m&&m.height||0,setExif:function(t,i){return d?("object"===e.typeOf(t)?e.each(t,function(e,t){d.setExif(t,e)}):d.setExif(t,i),l.set("app1",d.SEGMENT()),void 0):!1},writeHeaders:function(){return arguments.length?l.restore(arguments[0]):l.restore(o)},stripHeaders:function(e){return l.strip(e)},purge:function(){u.call(this)}}),d&&(this.meta={tiff:d.TIFF(),exif:d.EXIF(),gps:d.GPS(),thumb:s()})}return o}),n("moxie/runtime/html5/image/PNG",["moxie/core/Exceptions","moxie/core/utils/Basic","moxie/runtime/html5/utils/BinaryReader"],function(e,t,i){function n(n){function r(){var e,t;return e=a.call(this,8),"IHDR"==e.type?(t=e.start,{width:s.LONG(t),height:s.LONG(t+=4)}):null}function o(){s&&(s.clear(),n=l=u=c=s=null)}function a(e){var t,i,n,r;return t=s.LONG(e),i=s.STRING(e+=4,4),n=e+=4,r=s.LONG(e+t),{length:t,type:i,start:n,CRC:r}}var s,u,c,l;s=new i(n),function(){var t=0,i=0,n=[35152,20039,3338,6666];for(i=0;ii.height?"width":"height",a=Math.round(i[o]*n),s=!1;"nearest"!==r&&(.5>n||n>2)&&(n=.5>n?.5:2,s=!0);var u=t(i,n);return s?e(u,a/u[o],r):u}function t(e,t){var i=e.width,n=e.height,r=Math.round(i*t),o=Math.round(n*t),a=document.createElement("canvas");return a.width=r,a.height=o,a.getContext("2d").drawImage(e,0,0,i,n,0,0,r,o),e=null,a}return{scale:e}}),n("moxie/runtime/html5/image/Image",["moxie/runtime/html5/Runtime","moxie/core/utils/Basic","moxie/core/Exceptions","moxie/core/utils/Encode","moxie/file/Blob","moxie/file/File","moxie/runtime/html5/image/ImageInfo","moxie/runtime/html5/image/ResizerCanvas","moxie/core/utils/Mime","moxie/core/utils/Env"],function(e,t,i,n,r,o,a,s,u){function c(){function e(){if(!v&&!g)throw new i.ImageError(i.DOMException.INVALID_STATE_ERR);return v||g}function c(){var t=e();return"canvas"==t.nodeName.toLowerCase()?t:(v=document.createElement("canvas"),v.width=t.width,v.height=t.height,v.getContext("2d").drawImage(t,0,0),v)}function l(e){return n.atob(e.substring(e.indexOf("base64,")+7))}function d(e,t){return"data:"+(t||"")+";base64,"+n.btoa(e)}function m(e){var t=this;g=new Image,g.onerror=function(){p.call(this),t.trigger("error",i.ImageError.WRONG_FORMAT)},g.onload=function(){t.trigger("load")},g.src="data:"==e.substr(0,5)?e:d(e,y.type)}function h(e,t){var n,r=this;return window.FileReader?(n=new FileReader,n.onload=function(){t.call(r,this.result)},n.onerror=function(){r.trigger("error",i.ImageError.WRONG_FORMAT)},n.readAsDataURL(e),void 0):t.call(this,e.getAsDataURL())}function f(e,i){var n=Math.PI/180,r=document.createElement("canvas"),o=r.getContext("2d"),a=e.width,s=e.height;switch(t.inArray(i,[5,6,7,8])>-1?(r.width=s,r.height=a):(r.width=a,r.height=s),i){case 2:o.translate(a,0),o.scale(-1,1);break;case 3:o.translate(a,s),o.rotate(180*n);break;case 4:o.translate(0,s),o.scale(1,-1);break;case 5:o.rotate(90*n),o.scale(1,-1);break;case 6:o.rotate(90*n),o.translate(0,-s);break;case 7:o.rotate(90*n),o.translate(a,-s),o.scale(-1,1);break;case 8:o.rotate(-90*n),o.translate(-a,0)}return o.drawImage(e,0,0,a,s),r}function p(){x&&(x.purge(),x=null),w=g=v=y=null,b=!1}var g,x,v,w,y,E=this,b=!1,_=!0;t.extend(this,{loadFromBlob:function(e){var t=this.getRuntime(),n=arguments.length>1?arguments[1]:!0;if(!t.can("access_binary"))throw new i.RuntimeError(i.RuntimeError.NOT_SUPPORTED_ERR);return y=e,e.isDetached()?(w=e.getSource(),m.call(this,w),void 0):(h.call(this,e.getSource(),function(e){n&&(w=l(e)),m.call(this,e)}),void 0)},loadFromImage:function(e,t){this.meta=e.meta,y=new o(null,{name:e.name,size:e.size,type:e.type}),m.call(this,t?w=e.getAsBinaryString():e.getAsDataURL())},getInfo:function(){var t,i=this.getRuntime();return!x&&w&&i.can("access_image_binary")&&(x=new a(w)),t={width:e().width||0,height:e().height||0,type:y.type||u.getFileMime(y.name),size:w&&w.length||y.size||0,name:y.name||"",meta:null},_&&(t.meta=x&&x.meta||this.meta||{},!t.meta||!t.meta.thumb||t.meta.thumb.data instanceof r||(t.meta.thumb.data=new r(null,{type:"image/jpeg",data:t.meta.thumb.data}))),t},resize:function(t,i,n){var r=document.createElement("canvas");if(r.width=t.width,r.height=t.height,r.getContext("2d").drawImage(e(),t.x,t.y,t.width,t.height,0,0,r.width,r.height),v=s.scale(r,i),_=n.preserveHeaders,!_){var o=this.meta&&this.meta.tiff&&this.meta.tiff.Orientation||1;v=f(v,o)}this.width=v.width,this.height=v.height,b=!0,this.trigger("Resize")},getAsCanvas:function(){return v||(v=c()),v.id=this.uid+"_canvas",v},getAsBlob:function(e,t){return e!==this.type?(b=!0,new o(null,{name:y.name||"",type:e,data:E.getAsDataURL(e,t)})):new o(null,{name:y.name||"",type:e,data:E.getAsBinaryString(e,t)})},getAsDataURL:function(e){var t=arguments[1]||90;if(!b)return g.src;if(c(),"image/jpeg"!==e)return v.toDataURL("image/png");try{return v.toDataURL("image/jpeg",t/100)}catch(i){return v.toDataURL("image/jpeg")}},getAsBinaryString:function(e,t){if(!b)return w||(w=l(E.getAsDataURL(e,t))),w;if("image/jpeg"!==e)w=l(E.getAsDataURL(e,t));else{var i;t||(t=90),c();try{i=v.toDataURL("image/jpeg",t/100)}catch(n){i=v.toDataURL("image/jpeg")}w=l(i),x&&(w=x.stripHeaders(w),_&&(x.meta&&x.meta.exif&&x.setExif({PixelXDimension:this.width,PixelYDimension:this.height}),w=x.writeHeaders(w)),x.purge(),x=null)}return b=!1,w},destroy:function(){E=null,p.call(this),this.getRuntime().getShim().removeInstance(this.uid)}})}return e.Image=c}),n("moxie/runtime/flash/Runtime",["moxie/core/utils/Basic","moxie/core/utils/Env","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/runtime/Runtime"],function(e,t,i,n,o){function a(){var e;try{e=navigator.plugins["Shockwave Flash"],e=e.description}catch(t){try{e=new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version")}catch(i){e="0.0"}}return e=e.match(/\d+/g),parseFloat(e[0]+"."+e[1])}function s(e){var n=i.get(e);n&&"OBJECT"==n.nodeName&&("IE"===t.browser?(n.style.display="none",function r(){4==n.readyState?u(e):setTimeout(r,10)}()):n.parentNode.removeChild(n))}function u(e){var t=i.get(e);if(t){for(var n in t)"function"==typeof t[n]&&(t[n]=null);t.parentNode.removeChild(t)}}function c(u){var c,m=this;u=e.extend({swf_url:t.swf_url},u),o.call(this,u,l,{access_binary:function(e){return e&&"browser"===m.mode},access_image_binary:function(e){return e&&"browser"===m.mode},display_media:o.capTest(r("moxie/image/Image")),do_cors:o.capTrue,drag_and_drop:!1,report_upload_progress:function(){return"client"===m.mode},resize_image:o.capTrue,return_response_headers:!1,return_response_type:function(t){return"json"===t&&window.JSON?!0:!e.arrayDiff(t,["","text","document"])||"browser"===m.mode},return_status_code:function(t){return"browser"===m.mode||!e.arrayDiff(t,[200,404])},select_file:o.capTrue,select_multiple:o.capTrue,send_binary_string:function(e){return e&&"browser"===m.mode},send_browser_cookies:function(e){return e&&"browser"===m.mode},send_custom_headers:function(e){return e&&"browser"===m.mode},send_multipart:o.capTrue,slice_blob:function(e){return e&&"browser"===m.mode},stream_upload:function(e){return e&&"browser"===m.mode},summon_file_dialog:!1,upload_filesize:function(t){return e.parseSizeStr(t)<=2097152||"client"===m.mode},use_http_method:function(t){return!e.arrayDiff(t,["GET","POST"])}},{access_binary:function(e){return e?"browser":"client"},access_image_binary:function(e){return e?"browser":"client"},report_upload_progress:function(e){return e?"browser":"client"},return_response_type:function(t){return e.arrayDiff(t,["","text","json","document"])?"browser":["client","browser"]},return_status_code:function(t){return e.arrayDiff(t,[200,404])?"browser":["client","browser"]},send_binary_string:function(e){return e?"browser":"client"},send_browser_cookies:function(e){return e?"browser":"client"},send_custom_headers:function(e){return e?"browser":"client"},slice_blob:function(e){return e?"browser":"client"},stream_upload:function(e){return e?"client":"browser"},upload_filesize:function(t){return e.parseSizeStr(t)>=2097152?"client":"browser"}},"client"),a()<11.3&&(this.mode=!1),e.extend(this,{getShim:function(){return i.get(this.uid)},shimExec:function(e,t){var i=[].slice.call(arguments,2);return m.getShim().exec(this.uid,e,t,i)},init:function(){var i,r,a;a=this.getShimContainer(),e.extend(a.style,{position:"absolute",top:"-8px",left:"-8px",width:"9px",height:"9px",overflow:"hidden"}),i=''+''+''+''+"","IE"===t.browser?(r=document.createElement("div"),a.appendChild(r),r.outerHTML=i,r=a=null):a.innerHTML=i,c=setTimeout(function(){m&&!m.initialized&&m.trigger("Error",new n.RuntimeError(n.RuntimeError.NOT_INIT_ERR))},5e3)},destroy:function(e){return function(){s(m.uid),e.call(m),clearTimeout(c),u=c=e=m=null}}(this.destroy)},d)}var l="flash",d={};return o.addConstructor(l,c),d}),n("moxie/runtime/flash/file/Blob",["moxie/runtime/flash/Runtime","moxie/file/Blob"],function(e,t){var i={slice:function(e,i,n,r){var o=this.getRuntime();return 0>i?i=Math.max(e.size+i,0):i>0&&(i=Math.min(i,e.size)),0>n?n=Math.max(e.size+n,0):n>0&&(n=Math.min(n,e.size)),e=o.shimExec.call(this,"Blob","slice",i,n,r||""),e&&(e=new t(o.uid,e)),e}};return e.Blob=i}),n("moxie/runtime/flash/file/FileInput",["moxie/runtime/flash/Runtime","moxie/file/File","moxie/core/utils/Dom","moxie/core/utils/Basic"],function(e,t,i,n){var r={init:function(e){var r=this,o=this.getRuntime(),a=i.get(e.browse_button);a&&(a.setAttribute("tabindex",-1),a=null),this.bind("Change",function(){var e=o.shimExec.call(r,"FileInput","getFiles");r.files=[],n.each(e,function(e){r.files.push(new t(o.uid,e))})},999),this.getRuntime().shimExec.call(this,"FileInput","init",{accept:e.accept,multiple:e.multiple}),this.trigger("ready")}};return e.FileInput=r}),n("moxie/runtime/flash/file/FileReader",["moxie/runtime/flash/Runtime","moxie/core/utils/Encode"],function(e,t){function i(e,i){switch(i){case"readAsText":return t.atob(e,"utf8");case"readAsBinaryString":return t.atob(e);case"readAsDataURL":return e}return null}var n={read:function(e,t){var n=this;return n.result="","readAsDataURL"===e&&(n.result="data:"+(t.type||"")+";base64,"),n.bind("Progress",function(t,r){r&&(n.result+=i(r,e))},999),n.getRuntime().shimExec.call(this,"FileReader","readAsBase64",t.uid)}};return e.FileReader=n}),n("moxie/runtime/flash/file/FileReaderSync",["moxie/runtime/flash/Runtime","moxie/core/utils/Encode"],function(e,t){function i(e,i){switch(i){case"readAsText":return t.atob(e,"utf8");case"readAsBinaryString":return t.atob(e);case"readAsDataURL":return e}return null}var n={read:function(e,t){var n,r=this.getRuntime();return(n=r.shimExec.call(this,"FileReaderSync","readAsBase64",t.uid))?("readAsDataURL"===e&&(n="data:"+(t.type||"")+";base64,"+n),i(n,e,t.type)):null}};return e.FileReaderSync=n}),n("moxie/runtime/flash/runtime/Transporter",["moxie/runtime/flash/Runtime","moxie/file/Blob"],function(e,t){var i={getAsBlob:function(e){var i=this.getRuntime(),n=i.shimExec.call(this,"Transporter","getAsBlob",e);return n?new t(i.uid,n):null}};return e.Transporter=i}),n("moxie/runtime/flash/xhr/XMLHttpRequest",["moxie/runtime/flash/Runtime","moxie/core/utils/Basic","moxie/file/Blob","moxie/file/File","moxie/file/FileReaderSync","moxie/runtime/flash/file/FileReaderSync","moxie/xhr/FormData","moxie/runtime/Transporter","moxie/runtime/flash/runtime/Transporter"],function(e,t,i,n,r,o,a,s){var u={send:function(e,n){function r(){e.transport=l.mode,l.shimExec.call(c,"XMLHttpRequest","send",e,n)}function o(e,t){l.shimExec.call(c,"XMLHttpRequest","appendBlob",e,t.uid),n=null,r()}function u(e,t){var i=new s;i.bind("TransportingComplete",function(){t(this.result)}),i.transport(e.getSource(),e.type,{ruid:l.uid})}var c=this,l=c.getRuntime();if(t.isEmptyObj(e.headers)||t.each(e.headers,function(e,t){l.shimExec.call(c,"XMLHttpRequest","setRequestHeader",t,e.toString())}),n instanceof a){var d;if(n.each(function(e,t){e instanceof i?d=t:l.shimExec.call(c,"XMLHttpRequest","append",t,e)}),n.hasBlob()){var m=n.getBlob();m.isDetached()?u(m,function(e){m.destroy(),o(d,e)}):o(d,m)}else n=null,r()}else n instanceof i?n.isDetached()?u(n,function(e){n.destroy(),n=e.uid,r()}):(n=n.uid,r()):r()},getResponse:function(e){var i,o,a=this.getRuntime();if(o=a.shimExec.call(this,"XMLHttpRequest","getResponseAsBlob")){if(o=new n(a.uid,o),"blob"===e)return o;try{if(i=new r,~t.inArray(e,["","text"]))return i.readAsText(o);if("json"===e&&window.JSON)return JSON.parse(i.readAsText(o))}finally{o.destroy()}}return null},abort:function(){var e=this.getRuntime();e.shimExec.call(this,"XMLHttpRequest","abort"),this.dispatchEvent("readystatechange"),this.dispatchEvent("abort")}};return e.XMLHttpRequest=u}),n("moxie/runtime/flash/image/Image",["moxie/runtime/flash/Runtime","moxie/core/utils/Basic","moxie/runtime/Transporter","moxie/file/Blob","moxie/file/FileReaderSync"],function(e,t,i,n,r){var o={loadFromBlob:function(e){function t(e){r.shimExec.call(n,"Image","loadFromBlob",e.uid),n=r=null}var n=this,r=n.getRuntime();if(e.isDetached()){var o=new i;o.bind("TransportingComplete",function(){t(o.result.getSource())}),o.transport(e.getSource(),e.type,{ruid:r.uid})}else t(e.getSource())},loadFromImage:function(e){var t=this.getRuntime();return t.shimExec.call(this,"Image","loadFromImage",e.uid)},getInfo:function(){var e=this.getRuntime(),t=e.shimExec.call(this,"Image","getInfo");return t.meta&&t.meta.thumb&&t.meta.thumb.data&&!(e.meta.thumb.data instanceof n)&&(t.meta.thumb.data=new n(e.uid,t.meta.thumb.data)),t},getAsBlob:function(e,t){var i=this.getRuntime(),r=i.shimExec.call(this,"Image","getAsBlob",e,t);return r?new n(i.uid,r):null},getAsDataURL:function(){var e,t=this.getRuntime(),i=t.Image.getAsBlob.apply(this,arguments);return i?(e=new r,e.readAsDataURL(i)):null}};return e.Image=o}),n("moxie/runtime/silverlight/Runtime",["moxie/core/utils/Basic","moxie/core/utils/Env","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/runtime/Runtime"],function(e,t,i,n,o){function a(e){var t,i,n,r,o,a=!1,s=null,u=0;try{try{s=new ActiveXObject("AgControl.AgControl"),s.IsVersionSupported(e)&&(a=!0),s=null}catch(c){var l=navigator.plugins["Silverlight Plug-In"];if(l){for(t=l.description,"1.0.30226.2"===t&&(t="2.0.30226.2"),i=t.split(".");i.length>3;)i.pop();for(;i.length<4;)i.push(0);for(n=e.split(".");n.length>4;)n.pop();do r=parseInt(n[u],10),o=parseInt(i[u],10),u++;while(u=r&&!isNaN(r)&&(a=!0)}}}catch(d){a=!1}return a}function s(s){var l,d=this;s=e.extend({xap_url:t.xap_url},s),o.call(this,s,u,{access_binary:o.capTrue,access_image_binary:o.capTrue,display_media:o.capTest(r("moxie/image/Image")),do_cors:o.capTrue,drag_and_drop:!1,report_upload_progress:o.capTrue,resize_image:o.capTrue,return_response_headers:function(e){return e&&"client"===d.mode},return_response_type:function(e){return"json"!==e?!0:!!window.JSON},return_status_code:function(t){return"client"===d.mode||!e.arrayDiff(t,[200,404])},select_file:o.capTrue,select_multiple:o.capTrue,send_binary_string:o.capTrue,send_browser_cookies:function(e){return e&&"browser"===d.mode},send_custom_headers:function(e){return e&&"client"===d.mode},send_multipart:o.capTrue,slice_blob:o.capTrue,stream_upload:!0,summon_file_dialog:!1,upload_filesize:o.capTrue,use_http_method:function(t){return"client"===d.mode||!e.arrayDiff(t,["GET","POST"])}},{return_response_headers:function(e){return e?"client":"browser"},return_status_code:function(t){return e.arrayDiff(t,[200,404])?"client":["client","browser"]},send_browser_cookies:function(e){return e?"browser":"client"},send_custom_headers:function(e){return e?"client":"browser"},use_http_method:function(t){return e.arrayDiff(t,["GET","POST"])?"client":["client","browser"]}}),a("2.0.31005.0")&&"Opera"!==t.browser||(this.mode=!1),e.extend(this,{getShim:function(){return i.get(this.uid).content.Moxie},shimExec:function(e,t){var i=[].slice.call(arguments,2);return d.getShim().exec(this.uid,e,t,i)},init:function(){var e;e=this.getShimContainer(),e.innerHTML=''+''+''+''+''+''+"",l=setTimeout(function(){d&&!d.initialized&&d.trigger("Error",new n.RuntimeError(n.RuntimeError.NOT_INIT_ERR))},"Windows"!==t.OS?1e4:5e3)},destroy:function(e){return function(){e.call(d),clearTimeout(l),s=l=e=d=null}}(this.destroy)},c)}var u="silverlight",c={};return o.addConstructor(u,s),c}),n("moxie/runtime/silverlight/file/Blob",["moxie/runtime/silverlight/Runtime","moxie/core/utils/Basic","moxie/runtime/flash/file/Blob"],function(e,t,i){return e.Blob=t.extend({},i)}),n("moxie/runtime/silverlight/file/FileInput",["moxie/runtime/silverlight/Runtime","moxie/file/File","moxie/core/utils/Dom","moxie/core/utils/Basic"],function(e,t,i,n){function r(e){for(var t="",i=0;ii;i++)t=s.keys[i],a=s[t],a&&(/^(\d|[1-9]\d+)$/.test(a)?a=parseInt(a,10):/^\d*\.\d+$/.test(a)&&(a=parseFloat(a)),r.meta[e][t]=a)}),r.meta&&r.meta.thumb&&r.meta.thumb.data&&!(e.meta.thumb.data instanceof i)&&(r.meta.thumb.data=new i(e.uid,r.meta.thumb.data))),r.width=parseInt(o.width,10),r.height=parseInt(o.height,10),r.size=parseInt(o.size,10),r.type=o.type,r.name=o.name,r},resize:function(e,t,i){this.getRuntime().shimExec.call(this,"Image","resize",e.x,e.y,e.width,e.height,t,i.preserveHeaders,i.resample)}})}),n("moxie/runtime/html4/Runtime",["moxie/core/utils/Basic","moxie/core/Exceptions","moxie/runtime/Runtime","moxie/core/utils/Env"],function(e,t,i,n){function o(t){var o=this,u=i.capTest,c=i.capTrue;i.call(this,t,a,{access_binary:u(window.FileReader||window.File&&File.getAsDataURL),access_image_binary:!1,display_media:u((n.can("create_canvas")||n.can("use_data_uri_over32kb"))&&r("moxie/image/Image")),do_cors:!1,drag_and_drop:!1,filter_by_extension:u(function(){return!("Chrome"===n.browser&&n.verComp(n.version,28,"<")||"IE"===n.browser&&n.verComp(n.version,10,"<")||"Safari"===n.browser&&n.verComp(n.version,11,"<=")||"Firefox"===n.browser&&n.verComp(n.version,37,"<")||"iOS"===n.os||"Android"===n.os)}()),resize_image:function(){return s.Image&&o.can("access_binary")&&n.can("create_canvas")},report_upload_progress:!1,return_response_headers:!1,return_response_type:function(t){return"json"===t&&window.JSON?!0:!!~e.inArray(t,["text","document",""])},return_status_code:function(t){return!e.arrayDiff(t,[200,404])},select_file:function(){return n.can("use_fileinput")},select_multiple:!1,send_binary_string:!1,send_custom_headers:!1,send_multipart:!0,slice_blob:!1,stream_upload:function(){return o.can("select_file")},summon_file_dialog:function(){return o.can("select_file")&&!("Firefox"===n.browser&&n.verComp(n.version,4,"<")||"Opera"===n.browser&&n.verComp(n.version,12,"<")||"IE"===n.browser&&n.verComp(n.version,10,"<"))},upload_filesize:c,use_http_method:function(t){return!e.arrayDiff(t,["GET","POST"])}}),e.extend(this,{init:function(){this.trigger("Init")},destroy:function(e){return function(){e.call(o),e=o=null}}(this.destroy)}),e.extend(this.getShim(),s)}var a="html4",s={};return i.addConstructor(a,o),s}),n("moxie/runtime/html4/file/FileInput",["moxie/runtime/html4/Runtime","moxie/file/File","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/utils/Events","moxie/core/utils/Mime","moxie/core/utils/Env"],function(e,t,i,n,r,o,a){function s(){function e(){var o,c,d,m,h,f,p=this,g=p.getRuntime();f=i.guid("uid_"),o=g.getShimContainer(),s&&(d=n.get(s+"_form"),d&&(i.extend(d.style,{top:"100%"}),d.firstChild.setAttribute("tabindex",-1))),m=document.createElement("form"),m.setAttribute("id",f+"_form"),m.setAttribute("method","post"),m.setAttribute("enctype","multipart/form-data"),m.setAttribute("encoding","multipart/form-data"),i.extend(m.style,{overflow:"hidden",position:"absolute",top:0,left:0,width:"100%",height:"100%"}),h=document.createElement("input"),h.setAttribute("id",f),h.setAttribute("type","file"),h.setAttribute("accept",l.join(",")),g.can("summon_file_dialog")&&h.setAttribute("tabindex",-1),i.extend(h.style,{fontSize:"999px",opacity:0}),m.appendChild(h),o.appendChild(m),i.extend(h.style,{position:"absolute",top:0,left:0,width:"100%",height:"100%"}),"IE"===a.browser&&a.verComp(a.version,10,"<")&&i.extend(h.style,{filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=0)"}),h.onchange=function(){var i;this.value&&(i=this.files?this.files[0]:{name:this.value},i=new t(g.uid,i),this.onchange=function(){},e.call(p),p.files=[i],h.setAttribute("id",i.uid),m.setAttribute("id",i.uid+"_form"),p.trigger("change"),h=m=null)},g.can("summon_file_dialog")&&(c=n.get(u.browse_button),r.removeEvent(c,"click",p.uid),r.addEvent(c,"click",function(e){h&&!h.disabled&&h.click(),e.preventDefault()},p.uid)),s=f,o=d=c=null}var s,u,c,l=[];i.extend(this,{init:function(t){var i,a=this,s=a.getRuntime();u=t,l=o.extList2mimes(t.accept,s.can("filter_by_extension")),i=s.getShimContainer(),function(){var e,o,l;e=n.get(t.browse_button),c=n.getStyle(e,"z-index")||"auto",s.can("summon_file_dialog")?("static"===n.getStyle(e,"position")&&(e.style.position="relative"),a.bind("Refresh",function(){o=parseInt(c,10)||1,n.get(u.browse_button).style.zIndex=o,this.getRuntime().getShimContainer().style.zIndex=o-1})):e.setAttribute("tabindex",-1),l=s.can("summon_file_dialog")?e:i,r.addEvent(l,"mouseover",function(){a.trigger("mouseenter")},a.uid),r.addEvent(l,"mouseout",function(){a.trigger("mouseleave")},a.uid),r.addEvent(l,"mousedown",function(){a.trigger("mousedown")},a.uid),r.addEvent(n.get(t.container),"mouseup",function(){a.trigger("mouseup")},a.uid),e=null}(),e.call(this),i=null,a.trigger({type:"ready",async:!0})},setOption:function(e,t){var i,r=this.getRuntime();"accept"==e&&(l=t.mimes||o.extList2mimes(t,r.can("filter_by_extension"))),i=n.get(s),i&&i.setAttribute("accept",l.join(","))},disable:function(e){var t;(t=n.get(s))&&(t.disabled=!!e)},destroy:function(){var e=this.getRuntime(),t=e.getShim(),i=e.getShimContainer(),o=u&&n.get(u.container),a=u&&n.get(u.browse_button);o&&r.removeAllEvents(o,this.uid),a&&(r.removeAllEvents(a,this.uid),a.style.zIndex=c),i&&(r.removeAllEvents(i,this.uid),i.innerHTML=""),t.removeInstance(this.uid),s=l=u=i=o=a=t=null}})}return e.FileInput=s}),n("moxie/runtime/html4/file/FileReader",["moxie/runtime/html4/Runtime","moxie/runtime/html5/file/FileReader"],function(e,t){return e.FileReader=t}),n("moxie/runtime/html4/xhr/XMLHttpRequest",["moxie/runtime/html4/Runtime","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/utils/Url","moxie/core/Exceptions","moxie/core/utils/Events","moxie/file/Blob","moxie/xhr/FormData"],function(e,t,i,n,r,o,a,s){function u(){function e(e){var t,n,r,a,s=this,u=!1;if(l){if(t=l.id.replace(/_iframe$/,""),n=i.get(t+"_form")){for(r=n.getElementsByTagName("input"),a=r.length;a--;)switch(r[a].getAttribute("type")){case"hidden":r[a].parentNode.removeChild(r[a]);break;case"file":u=!0}r=[],u||n.parentNode.removeChild(n),n=null}setTimeout(function(){o.removeEvent(l,"load",s.uid),l.parentNode&&l.parentNode.removeChild(l);var t=s.getRuntime().getShimContainer();t.children.length||t.parentNode.removeChild(t),t=l=null,e()},1)}}var u,c,l;t.extend(this,{send:function(d,m){function h(){var i=w.getShimContainer()||document.body,r=document.createElement("div");r.innerHTML='',l=r.firstChild,i.appendChild(l),o.addEvent(l,"load",function(){var i;try{i=l.contentWindow.document||l.contentDocument||window.frames[l.id].document,/^4(0[0-9]|1[0-7]|2[2346])\s/.test(i.title)?u=i.title.replace(/^(\d+).*$/,"$1"):(u=200,c=t.trim(i.body.innerHTML),v.trigger({type:"progress",loaded:c.length,total:c.length}),x&&v.trigger({type:"uploadprogress",loaded:x.size||1025,total:x.size||1025}))}catch(r){if(!n.hasSameOrigin(d.url))return e.call(v,function(){v.trigger("error")}),void 0;u=404}e.call(v,function(){v.trigger("load")})},v.uid)}var f,p,g,x,v=this,w=v.getRuntime();if(u=c=null,m instanceof s&&m.hasBlob()){if(x=m.getBlob(),f=x.uid,g=i.get(f),p=i.get(f+"_form"),!p)throw new r.DOMException(r.DOMException.NOT_FOUND_ERR)}else f=t.guid("uid_"),p=document.createElement("form"),p.setAttribute("id",f+"_form"),p.setAttribute("method",d.method),p.setAttribute("enctype","multipart/form-data"),p.setAttribute("encoding","multipart/form-data"),w.getShimContainer().appendChild(p);p.setAttribute("target",f+"_iframe"),m instanceof s&&m.each(function(e,i){if(e instanceof a)g&&g.setAttribute("name",i);else{var n=document.createElement("input");t.extend(n,{type:"hidden",name:i,value:e}),g?p.insertBefore(n,g):p.appendChild(n)}}),p.setAttribute("action",d.url),h(),p.submit(),v.trigger("loadstart")},getStatus:function(){return u},getResponse:function(e){if("json"===e&&"string"===t.typeOf(c)&&window.JSON)try{return JSON.parse(c.replace(/^\s*]*>/,"").replace(/<\/pre>\s*$/,""))}catch(i){return null}return c},abort:function(){var t=this;l&&l.contentWindow&&(l.contentWindow.stop?l.contentWindow.stop():l.contentWindow.document.execCommand?l.contentWindow.document.execCommand("Stop"):l.src="about:blank"),e.call(this,function(){t.dispatchEvent("abort")})},destroy:function(){this.getRuntime().getShim().removeInstance(this.uid)}})}return e.XMLHttpRequest=u}),n("moxie/runtime/html4/image/Image",["moxie/runtime/html4/Runtime","moxie/runtime/html5/image/Image"],function(e,t){return e.Image=t}),a(["moxie/core/utils/Basic","moxie/core/utils/Encode","moxie/core/utils/Env","moxie/core/Exceptions","moxie/core/utils/Dom","moxie/core/EventTarget","moxie/runtime/Runtime","moxie/runtime/RuntimeClient","moxie/file/Blob","moxie/core/I18n","moxie/core/utils/Mime","moxie/file/FileInput","moxie/file/File","moxie/file/FileDrop","moxie/file/FileReader","moxie/core/utils/Url","moxie/runtime/RuntimeTarget","moxie/xhr/FormData","moxie/xhr/XMLHttpRequest","moxie/image/Image","moxie/core/utils/Events","moxie/runtime/html5/image/ResizerCanvas"])}(this)}); -/** - * Plupload - multi-runtime File Uploader - * v3.1.2 - * - * Copyright 2018, Ephox - * Released under AGPLv3 License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - * - * Date: 2018-02-20 - */ -!function(t,e){var i=function(){var t={};return e.apply(t,arguments),t.plupload};"function"==typeof define&&define.amd?define("plupload",["./moxie"],i):"object"==typeof module&&module.exports?module.exports=i(require("./moxie")):t.plupload=i(t.moxie)}(this||window,function(t){!function(e,i){"use strict";function n(t,e){for(var i,n=[],r=0;r":"gt","&":"amp",'"':"quot","'":"#39"},i=/[<>&\"\']/g;return t?(""+t).replace(i,function(t){return e[t]?"&"+e[t]+";":t}):t},toArray:i.Basic.toArray,inArray:i.Basic.inArray,addI18n:e.core.I18n.addI18n,translate:e.core.I18n.translate,sprintf:i.Basic.sprintf,isEmptyObj:i.Basic.isEmptyObj,hasClass:i.Dom.hasClass,addClass:i.Dom.addClass,removeClass:i.Dom.removeClass,getStyle:i.Dom.getStyle,addEvent:i.Events.addEvent,removeEvent:i.Events.removeEvent,removeAllEvents:i.Events.removeAllEvents,cleanName:function(t){var e,i;for(i=[/[\300-\306]/g,"A",/[\340-\346]/g,"a",/\307/g,"C",/\347/g,"c",/[\310-\313]/g,"E",/[\350-\353]/g,"e",/[\314-\317]/g,"I",/[\354-\357]/g,"i",/\321/g,"N",/\361/g,"n",/[\322-\330]/g,"O",/[\362-\370]/g,"o",/[\331-\334]/g,"U",/[\371-\374]/g,"u"],e=0;e0?"&":"?")+n),t},formatSize:function(t){function e(t,e){return Math.round(t*Math.pow(10,e))/Math.pow(10,e)}var i=this;if(t=parseInt(t,10),isNaN(t))return i.translate("N/A");var n=Math.pow(1024,4);return t>n?e(t/n,1)+" "+i.translate("tb"):t>(n/=1024)?e(t/n,1)+" "+i.translate("gb"):t>(n/=1024)?e(t/n,1)+" "+i.translate("mb"):t>1024?Math.round(t/1024)+" "+i.translate("kb"):t+" "+i.translate("b")},mimes2extList:t.core.utils.Mime.mimes2extList,resolveUrl:i.Url.resolveUrl,parseSize:i.Basic.parseSizeStr,delay:i.Basic.delay,EventTarget:t.core.EventTarget,Runtime:t.runtime.Runtime,FileInput:t.file.FileInput,FileReader:t.file.FileReader}}),r("plupload/core/Collection",["plupload"],function(){var t=function(){function e(){var t;for(t in n);return n[t]}var i,n={},r=0;plupload.extend(this,{count:function(){return r},hasKey:function(t){return n.hasOwnProperty(t)},get:function(t){return n[t]},first:function(){for(var t in n)return n[t]},last:function(){return i},toObject:function(){return n},add:function(t,e){var s=this;return"object"!=typeof t||e?n.hasOwnProperty(t)?s.update.apply(s,arguments):(n[t]=i=e,r++,void 0):plupload.each(t,function(t,e){s.add(e,t)})},remove:function(t){if(this.hasKey(t)){var s=n[t];delete n[t],r--,i===s&&(i=e())}},extract:function(t){var e=this.get(t);return this.remove(t),e},shift:function(){var t,e,i=this;for(e in n)return t=n[e],i.remove(e),t},update:function(t,e){n[t]=e},each:function(t){plupload.each(n,t)},combineWith:function(){var e=new t;return e.add(n),plupload.each(arguments,function(i){i instanceof t&&e.add(i.toObject())}),e},clear:function(){n={},i=null,r=0}})};return t}),r("plupload/core/ArrCollection",["plupload"],function(t){var e=function(){var e=[];t.extend(this,{count:function(){return e.length},hasKey:function(t){return this.getIdx(t)>-1},get:function(t){var i=this.getIdx(t);return i>-1?e[i]:null},getIdx:function(t){for(var i=0,n=e.length;n>i;i++)if(e[i].uid===t)return i;return-1},getByIdx:function(t){return e[t]},first:function(){return e[0]},last:function(){return e[e.length-1]},add:function(t){t=arguments[1]||t;var i=this.getIdx(t.uid);return i>-1?(e[i]=t,i):(e.push(t),e.length-1)},remove:function(t){return!!this.extract(t)},splice:function(i,n){return i="undefinded"===t.typeOf(i)?0:Math.max(i,0),n="undefinded"!==t.typeOf(n)&&i+n-1?e.splice(i,1):null},shift:function(){return e.shift()},update:function(t,i){var n=this.getIdx(t);return n>-1?(e[n]=i,!0):!1},each:function(i){t.each(e,i)},combineWith:function(){return Array.prototype.concat.apply(this.toArray(),arguments)},sort:function(t){e.sort(t||function(t,e){return t.priority-e.priority})},clear:function(){e=[]},toObject:function(){for(var t={},i=0,n=e.length;n>i;i++)t[e[i].uid]=e[i];return t},toArray:function(){return Array.prototype.slice.call(e)}})};return e}),r("plupload/core/Optionable",["plupload"],function(e){var i=t.core.EventTarget;return function(t){function i(){t.apply(this,arguments),this._options={}}return e.inherit(i,t),e.extend(i.prototype,{setOption:function(t,i,n){var r,s=this;return"object"==typeof t?(n=i,e.each(t,function(t,e){s.setOption(e,t,n)}),void 0):((!n||s._options.hasOwnProperty(t))&&(r=e.clone(s._options[t]),"object"===e.typeOf(i)&&"object"===e.typeOf(s._options[t])?e.extend(s._options[t],i):s._options[t]=i,s.trigger("OptionChanged",t,i,r)),void 0)},getOption:function(t){if(!t)return this._options;var i=this._options[t];return e.inArray(e.typeOf(i),["array","object"])>-1?e.extendImmutable({},i):i},setOptions:function(t,e){"object"==typeof t&&this.setOption(t,e)},getOptions:function(){return this.getOption()}}),i}(i)}),r("plupload/core/Queueable",["plupload","plupload/core/Optionable"],function(t,e){return function(e){function i(){e.apply(this,arguments),this.uid=t.guid(),this.state=i.IDLE,this.processed=0,this.total=0,this.percent=0,this.retries=0,this.priority=0,this.startedTimestamp=0,this.processedTimestamp=0}return i.IDLE=1,i.PROCESSING=2,i.PAUSED=6,i.RESUMED=7,i.DONE=5,i.FAILED=4,i.DESTROYED=8,t.inherit(i,e),t.extend(i.prototype,{start:function(){var t=this.state;return this.state===i.PROCESSING?!1:(this.startedTimestamp||(this.startedTimestamp=+new Date),this.state=i.PROCESSING,this.trigger("statechanged",this.state,t),this.trigger("started"),!0)},pause:function(){var e=this.state;return-1===t.inArray(this.state,[i.IDLE,i.RESUMED,i.PROCESSING])?!1:(this.processed=this.percent=0,this.loaded=this.processed,this.state=i.PAUSED,this.trigger("statechanged",this.state,e),this.trigger("paused"),!0)},resume:function(){var t=this.state;return this.state!==i.PAUSED&&this.state!==i.RESUMED?!1:(this.state=i.RESUMED,this.trigger("statechanged",this.state,t),this.trigger("resumed"),!0)},stop:function(){var t=this.state;return this.state===i.IDLE?!1:(this.processed=this.percent=0,this.loaded=this.processed,this.startedTimestamp=0,this.state=i.IDLE,this.trigger("statechanged",this.state,t),this.trigger("stopped"),!0)},done:function(t){var e=this.state;return this.state===i.DONE?!1:(this.processed=this.total,this.loaded=this.processed,this.percent=100,this.processedTimestamp=+new Date,this.state=i.DONE,this.trigger("statechanged",this.state,e),this.trigger("done",t),this.trigger("processed"),!0)},failed:function(t){var e=this.state;return this.state===i.FAILED?!1:(this.processed=this.percent=0,this.loaded=this.processed,this.processedTimestamp=+new Date,this.state=i.FAILED,this.trigger("statechanged",this.state,e),this.trigger("failed",t),this.trigger("processed"),!0)},progress:function(t,e){e&&(this.total=e),this.processed=Math.min(t,this.total),this.loaded=this.processed,this.percent=Math.ceil(100*(this.processed/this.total)),this.trigger({type:"progress",loaded:this.processed,total:this.total})},destroy:function(){var t=this.state;return this.state===i.DESTROYED?!1:(this.state=i.DESTROYED,this.trigger("statechanged",this.state,t),this.trigger("destroy"),this.unbindAll(),!0)}}),i}(e)}),r("plupload/core/Stats",[],function(){return function(){var t=this;t.size=0,t.total=0,t.loaded=0,t.uploaded=0,t.done=0,t.failed=0,t.queued=0,t.paused=0,t.processing=0,t.paused=0,t.percent=0,t.bytesPerSec=0,t.processedPerSec=0,t.reset=function(){t.size=t.total=t.loaded=t.processed=t.uploaded=t.done=t.failed=t.queued=t.processing=t.paused=t.percent=t.bytesPerSec=t.processedPerSec=0}}}),r("plupload/core/Queue",["plupload","plupload/core/ArrCollection","plupload/core/Queueable","plupload/core/Stats"],function(t,e,i,n){return function(r){function s(i){r.apply(this,arguments),this._queue=new e,this.stats=new n,this._options=t.extend({},this._options,{max_slots:1,max_retries:0,auto_start:!1,finish_active:!1},i)}function o(){var t;return this.forEachItem(function(e){return e.state===i.IDLE||e.state===i.RESUMED?(t=e,!1):void 0}),t?t:null}function a(){var t;if(this.state!==i.PROCESSING&&this.state!==i.PAUSED)return!1;if(this.stats.processingt.startedTimestamp)&&(r+=n),e.processedPerSec=Math.ceil(r/((+new Date-t.startedTimestamp||1)/1e3)),e.processed=n,e.total+=s.total,e.total&&(e.percent=Math.ceil(100*(e.processed/e.total)))}),t.percent=e.percent,e.loaded=e.processed,e.size=e.total,e.bytesPerSec=e.processedPerSec,!0):!1},destroy:function(){var e=this;return e.state===i.DESTROYED?!1:e.state!==i.IDLE?(e.bindOnce("Stopped",function(){t.delay.call(e,e.destroy)}),e.stop()):(e.clear(),s.parent.destroy.call(this),e._queue=e.stats=null,!0)}}),s}(i)}),r("plupload/QueueUpload",["plupload","plupload/core/Queue"],function(t,e){return function(i){function n(t){e.call(this,{max_slots:1,max_retries:0,auto_start:!1,finish_active:!1,url:!1,chunk_size:0,multipart:!0,http_method:"POST",params:{},headers:!1,file_data_name:"file",send_file_name:!0,stop_on_fail:!0}),this.setOption=function(t,e){"object"!=typeof t&&"max_upload_slots"==t&&(t="max_slots"),n.prototype.setOption.call(this,t,e,!0)},this.setOptions(t)}return t.inherit(n,i),n}(e)}),r("plupload/QueueResize",["plupload","plupload/core/Queue"],function(t,e){return function(i){function n(t){e.call(this,{max_slots:1,max_retries:0,auto_start:!1,finish_active:!1,resize:{}}),this.setOption=function(t,e){"object"!=typeof t&&"max_resize_slots"==t&&(t="max_slots"),n.prototype.setOption.call(this,t,e,!0)},this.setOptions(t)}return t.inherit(n,i),n}(e)}),r("plupload/ChunkUploader",["plupload","plupload/core/Collection","plupload/core/Queueable"],function(e,i,n){function r(t){function i(t,i){var n="";return e.each(i,function(t,e){n+=(n?"&":"")+encodeURIComponent(e)+"="+encodeURIComponent(t)}),n&&(t+=(t.indexOf("?")>0?"&":"?")+n),t}var a;n.call(this),this._options={file_data_name:"file",headers:!1,http_method:"POST",multipart:!0,params:{},send_file_name:!0,url:!1},e.extend(this,{start:function(){var r,u,l=this,p=this.state,c=l._options;if(this.state===n.PROCESSING)return!1;this.startedTimestamp||(this.startedTimestamp=+new Date),this.state=n.PROCESSING,this.trigger("statechanged",this.state,p),a=new s,a.upload&&(a.upload.onprogress=function(t){l.progress(t.loaded,t.total)}),a.onload=function(){var t={response:this.responseText,status:this.status,responseHeaders:this.getAllResponseHeaders()};return this.status<200||this.status>=400?l.failed(t):(l.done(t),void 0)},a.onerror=function(){l.failed()},a.onloadend=function(){setTimeout(function(){a&&(a.destroy(),a=null)},1)};try{r=c.multipart?c.url:i(c.url,c.params),a.open(c.http_method,r,!0),e.isEmptyObj(c.headers)||e.each(c.headers,function(t,e){a.setRequestHeader(e,t)}),c.multipart?(u=new o,e.isEmptyObj(c.params)||e.each(c.params,function(t,e){u.append(e,t)}),u.append(c.file_data_name,t),a.send(u)):((e.isEmptyObj(c.headers)||!a.hasRequestHeader("content-type"))&&a.setRequestHeader("content-type","application/octet-stream"),a.send(t)),this.trigger("started")}catch(d){l.failed()}},stop:function(){a&&(a.abort(),a.destroy(),a=null),r.prototype.stop.call(this)},setOption:function(t,e){r.prototype.setOption.call(this,t,e,!0)},setOptions:function(t){r.prototype.setOption.call(this,t,!0)},destroy:function(){this.stop(),r.prototype.destroy.call(this)}})}var s=t.xhr.XMLHttpRequest,o=t.xhr.FormData;return e.inherit(r,n),r}),r("plupload/FileUploader",["plupload","plupload/core/Collection","plupload/core/Queueable","plupload/ChunkUploader"],function(t,e,i,n){function r(s,o){function a(){var t=0;return l.each(function(e){e.state===i.DONE&&(t+=e.end-e.start)}),t}function u(){for(var t=0;p>t&&l.hasKey(t);)t++;return t}var l=new e,p=1;i.call(this),this._options={chunk_size:0,params:{},send_file_name:!0,stop_on_fail:!0},t.extend(this,{name:s.name,start:function(){var t,e=this,r=this.state;return this.state===i.PROCESSING?!1:(this.startedTimestamp||(this.startedTimestamp=+new Date),this.state=i.PROCESSING,this.trigger("statechanged",this.state,r),e._options.send_file_name&&(e._options.params.name=e.target_name||e.name),e._options.chunk_size?(p=Math.ceil(s.size/e._options.chunk_size),e.uploadChunk(!1,!0)):(t=new n(s),t.bind("progress",function(t){e.progress(t.loaded,t.total)}),t.bind("done",function(t,i){e.done(i)}),t.bind("failed",function(t,i){e.failed(i)}),t.setOptions(e._options),o.addItem(t)),this.trigger("started"),void 0)},uploadChunk:function(e,r){var c,d,h=this,f=this.getOption("chunk_size"),g={};return g.seq=parseInt(e,10)||u(),g.start=g.seq*f,g.end=Math.min(g.start+f,s.size),g.total=s.size,g.start<0||g.start>=s.size?!1:(d=t.extendImmutable({},this.getOptions(),{params:{chunk:g.seq,chunks:p}}),c=new n(s.slice(g.start,g.end,s.type)),c.bind("progress",function(t){h.progress(a()+t.loaded,s.size)}),c.bind("failed",function(e,n){l.add(g.seq,t.extend({state:i.FAILED},g)),h.trigger("chunkuploadfailed",t.extendImmutable({},g,n)),d.stop_on_fail&&h.failed(n)}),c.bind("done",function(e,n){l.add(g.seq,t.extend({state:i.DONE},g)),h.trigger("chunkuploaded",t.extendImmutable({},g,n)),a()>=s.size?(h.progress(s.size,s.size),h.done(n)):r&&t.delay(function(){h.uploadChunk(u(),r)})}),c.bind("processed",function(){this.destroy()}),c.setOptions(d),l.add(g.seq,t.extend({state:i.PROCESSING},g)),o.addItem(c),r&&o.countSpareSlots()&&h.uploadChunk(u(),r),!0)},destroy:function(){r.prototype.destroy.call(this),l.clear()}})}return t.inherit(r,i),r}),r("plupload/ImageResizer",["plupload","plupload/core/Queueable"],function(e,i){function n(t){i.call(this),this._options={type:"image/jpeg",quality:90,crop:!1,fit:!0,preserveHeaders:!0,resample:"default",multipass:!0},this.setOption=function(t){("object"==typeof t||this._options.hasOwnProperty(t))&&n.prototype.setOption.apply(this,arguments)},this.start=function(e){var i,n=this;e&&this.setOptions(e.resize),i=new r,i.bind("load",function(){this.resize(n.getOptions())}),i.bind("resize",function(){n.done(this.getAsBlob(n.getOption("type"),n.getOption("quality"))),this.destroy()}),i.bind("error",function(){n.failed(),this.destroy()}),i.load(t,n.getOption("runtimeOptions"))}}var r=t.image.Image;return e.inherit(n,i),e.Image=r,n}),r("plupload/File",["plupload","plupload/core/Queueable","plupload/FileUploader","plupload/ImageResizer"],function(t,e,i,n){function r(a,u,l){e.call(this),t.extend(this,{id:this.uid,name:a.name,target_name:null,type:a.type,size:a.size,origSize:a.size,start:function(){var i=this.state;return this.state===e.PROCESSING?!1:(this.state=e.PROCESSING,this.trigger("statechanged",this.state,i),this.trigger("started"),!t.isEmptyObj(this._options.resize)&&s(this.type)&&o(a,"send_binary_string")?this.resizeAndUpload():this.upload(),!0)},getSource:function(){return a},getNative:function(){return this.getFile().getSource()},resizeAndUpload:function(){var t=this,e=t.getOptions(),i=new n(a);i.bind("progress",function(e){t.progress(e.loaded,e.total)}),i.bind("done",function(e,i){i=i,t.upload()}),i.bind("failed",function(){t.upload()}),i.setOption("runtimeOptions",{runtime_order:e.runtimes,required_caps:e.required_features,preferred_caps:e.preferred_caps,swf_url:e.flash_swf_url,xap_url:e.silverlight_xap_url}),l.addItem(i)},upload:function(){var t=this,e=new i(a,u);e.bind("paused",function(){t.pause()}),e.bind("resumed",function(){this.start()}),e.bind("started",function(){t.trigger("startupload")}),e.bind("progress",function(e){t.progress(e.loaded,e.total)}),e.bind("done",function(e,i){t.done(i)}),e.bind("failed",function(e,i){t.failed(i)}),e.setOptions(t.getOptions()),e.start()},destroy:function(){r.prototype.destroy.call(this),a=null}})}function s(e){return t.inArray(e,["image/jpeg","image/png"])>-1}function o(e,i){if(e.ruid){var n=t.Runtime.getInfo(e.ruid);if(n)return n.can(i)}return!1}return t.inherit(r,e),r}),r("plupload/Uploader",["plupload","plupload/core/Collection","plupload/core/Queue","plupload/QueueUpload","plupload/QueueResize","plupload/File"],function(e,i,n,r,s,o){function a(i){function u(){var t=O[0]||b[0];return t?t.getRuntime().uid:!1}function c(){this.bind("FilesAdded FilesRemoved",function(t){t.trigger("QueueChanged"),t.refresh()},this,999),this.bind("BeforeUpload",g),this.bind("Stopped",function(t){t.trigger("UploadComplete")}),this.bind("Error",m),this.bind("Destroy",_)}function d(i){var n=this,r=0,s=[],o={runtime_order:n.getOption("runtimes"),required_caps:n.getOption("required_features"),preferred_caps:n.getOption("preferred_caps"),swf_url:n.getOption("flash_swf_url"),xap_url:n.getOption("silverlight_xap_url")};e.each(n.getOption("runtimes").split(/\s*,\s*/),function(t){n.getOption(t)&&(o[t]=n.getOption(t))}),n.getOption("browse_button")&&e.each(n.getOption("browse_button"),function(i){s.push(function(s){var a=new t.file.FileInput(e.extend({},o,{accept:n.getOption("filters").mime_types,name:n.getOption("file_data_name"),multiple:n.getOption("multi_selection"),container:n.getOption("container"),browse_button:i}));a.onready=function(){var t=e.Runtime.getInfo(this.ruid);e.extend(n.features,{chunks:t.can("slice_blob"),multipart:t.can("send_multipart"),multi_selection:t.can("select_multiple")}),r++,O.push(this),s()},a.onchange=function(){n.addFile(this.files)},a.bind("mouseenter mouseleave mousedown mouseup",function(t){R||(n.getOption("browse_button_hover")&&("mouseenter"===t.type?e.addClass(i,n.getOption("browse_button_hover")):"mouseleave"===t.type&&e.removeClass(i,n.getOption("browse_button_hover"))),n.getOption("browse_button_active")&&("mousedown"===t.type?e.addClass(i,n.getOption("browse_button_active")):"mouseup"===t.type&&e.removeClass(i,n.getOption("browse_button_active"))))}),a.bind("mousedown",function(){n.trigger("Browse")}),a.bind("error runtimeerror",function(){a=null,s()}),a.init()})}),n.getOption("drop_element")&&e.each(n.getOption("drop_element"),function(i){s.push(function(s){var a=new t.file.FileDrop(e.extend({},o,{drop_zone:i}));a.onready=function(){var t=e.Runtime.getInfo(this.ruid);e.extend(n.features,{chunks:t.can("slice_blob"),multipart:t.can("send_multipart"),dragdrop:t.can("drag_and_drop")}),r++,b.push(this),s()},a.ondrop=function(){n.addFile(this.files)},a.bind("error runtimeerror",function(){a=null,s()}),a.init()})}),e.inParallel(s,function(){"function"==typeof i&&i(r)})}function g(t,e){if(t.getOption("unique_names")){var i=e.name.match(/\.([^.]+)$/),n="part";i&&(n=i[1]),e.target_name=e.id+"."+n}}function m(t,i){i.code===e.INIT_ERROR?t.destroy():i.code===e.HTTP_ERROR&&t.state==e.STARTED&&t.trigger("CancelUpload")}function _(t){t.forEachItem(function(t){t.destroy()}),O.length&&(e.each(O,function(t){t.destroy()}),O=[]),b.length&&(e.each(b,function(t){t.destroy()}),b=[]),E=!1,y&&y.destroy(),v&&v.destroy(),I=y=v=null}var y,v,O=[],b=[],E=!1,R=!1,I=l(e.extend({backward_compatibility:!0,chunk_size:0,file_data_name:"file",filters:{mime_types:"*",prevent_duplicates:!1,max_file_size:0},flash_swf_url:"js/Moxie.swf",http_method:"POST",max_resize_slots:1,max_retries:0,max_upload_slots:1,multipart:!0,multipart_params:{},multi_selection:!0,params:{},resize:!1,runtimes:e.Runtime.order,send_chunk_number:!0,send_file_name:!0,silverlight_xap_url:"js/Moxie.xap",required_features:!1,preferred_caps:!1},i));n.call(this),e.extend(this,{_options:I,id:this.uid,state:e.STOPPED,features:{},settings:I,runtime:null,files:[],total:this.stats,init:function(){var t,i,n=this;return t=n.getOption("preinit"),"function"==typeof t?t(n):e.each(t,function(t,e){n.bind(e,t)}),c.call(n),e.each(["container","browse_button","drop_element"],function(t){return null===n.getOption(t)?(i={code:e.INIT_ERROR,message:e.sprintf(e.translate("%s specified, but cannot be found."),t)},!1):void 0}),i?n.trigger("Error",i):n.getOption("browse_button")||n.getOption("drop_element")?(d.call(n,function(t){var i,o=n.getOption("init"),a=e.extendImmutable({},n.getOption(),{auto_start:!0});"function"==typeof o?o(n):e.each(o,function(t,e){n.bind(e,t)}),t?(E=!0,i=e.Runtime.getInfo(u()),y=new r(a),v=new s(a),n.trigger("Init",{ruid:i.uid,runtime:n.runtime=i.type}),n.trigger("PostInit")):n.trigger("Error",{code:e.INIT_ERROR,message:e.translate("Init error.")})}),void 0):n.trigger("Error",{code:e.INIT_ERROR,message:e.translate("You must specify either browse_button or drop_element.")})},setOption:function(t,i){return E&&e.inArray(t,["container","browse_button","drop_element","runtimes","multi_selection","flash_swf_url","silverlight_xap_url"])>-1?this.trigger("Error",{code:e.OPTION_ERROR,message:e.sprintf(e.translate("%s option cannot be changed.")),option:t}):("object"!=typeof t&&(i=p(t,i,this._options),y&&y.setOption(t,i),v&&v.setOption(t,i)),a.prototype.setOption.call(this,t,i),void 0)},refresh:function(){O.length&&e.each(O,function(t){t.trigger("Refresh")}),b.length&&e.each(b,function(t){t.trigger("Refresh")}),this.trigger("Refresh")},stop:function(){a.prototype.stop.call(this)&&this.state!=e.STOPPED&&this.trigger("CancelUpload")},disableBrowse:function(){R=arguments[0]!==h?arguments[0]:!0,O.length&&e.each(O,function(t){t.disable(R)}),this.trigger("DisableBrowse",R)},getFile:function(t){return this.getItem(t)},addFile:function(i,n){function r(t){t.bind("beforestart",function(t){return p.trigger("BeforeUpload",t.target)}),t.bind("startupload",function(){p.trigger("UploadFile",this)}),t.bind("progress",function(){p.trigger("UploadProgress",this)}),t.bind("done",function(t,e){p.trigger("FileUploaded",this,e)}),t.bind("failed",function(t,i){p.trigger("Error",e.extend({code:e.HTTP_ERROR,message:e.translate("HTTP Error."),file:this},i))})}function s(t,i){var n=[];e.each(p.getOption("filters"),function(e,i){f[i]&&n.push(function(n){f[i].call(p,e,t,function(t){n(!t)})})}),e.inParallel(n,i)}function a(i){var u=e.typeOf(i);if(i instanceof t.file.File){if(!i.ruid&&!i.isDetached()){if(!l)return!1;i.ruid=l,i.connectRuntime(l)}c.push(function(t){s(i,function(s){var a;s||(a=new o(i,y,v),n&&(a.name=n),r(a),p.addItem(a),d.push(a),p.trigger("FileFiltered",a)),e.delay(t)})})}else i instanceof t.file.Blob?(a(i.getSource()),i.destroy()):-1!==e.inArray(u,["file","blob"])?a(new t.file.File(null,i)):"node"===u&&"filelist"===e.typeOf(i.files)?e.each(i.files,a):"array"===u&&(n=null,e.each(i,a))}var l,p=this,c=[],d=[];l=u(),a(i),c.length&&e.inParallel(c,function(){d.length&&p.trigger("FilesAdded",d)})},removeFile:function(t){var e=this.extractItem("string"==typeof t?t:t.uid);e&&(this.trigger("FilesRemoved",[e]),e.destroy())},splice:function(){var t=0,i=e.STARTED==this.state,r=n.prototype.splice.apply(this,arguments);if(r.length){for(this.trigger("FilesRemoved",r),i&&this.stop(),t=0;t0&&(r.slice_blob=!0),e.isEmptyObj(t.resize)&&t.multipart!==!1||(r.send_binary_string=!0),t.http_method&&(r.use_http_method=t.http_method),e.each(t,function(t,e){i(e,!!t,!0)})),r}function l(t){return e.each(t,function(e,i){t[i]=p(i,e,t)}),t}function p(t,i,n){switch(t){case"chunk_size":(i=e.parseSize(i))&&(n.send_file_name=!0);break;case"headers":var r={};return"object"==typeof i&&e.each(i,function(t,e){r[e.toLowerCase()]=t}),r;case"http_method":return"PUT"===i.toUpperCase()?"PUT":"POST";case"filters":return"array"===e.typeOf(i)&&(i={mime_types:i}),i.mime_types&&("string"===e.typeOf(i.mime_types)&&(i.mime_types=e.mimes2extList(i.mime_types)),n.re_ext_filter=function(t){var i=[];return e.each(t,function(t){e.each(t.extensions.split(/,/),function(t){/^\s*\*\s*$/.test(t)?i.push("\\.*"):i.push("\\."+t.replace(new RegExp("["+"/^$.*+?|()[]{}\\".replace(/./g,"\\$&")+"]","g"),"\\$&"))})}),new RegExp("("+i.join("|")+")$","i")}(i.mime_types)),i;case"max_file_size":n&&!n.filters&&(n.filters={}),n.filters.max_file_size=i;break;case"multipart":i||(n.send_file_name=!0);break;case"multipart_params":n.params=n.multipart_params=i;break;case"resize":return i?e.extend({preserve_headers:!0,crop:!1},i):!1;case"prevent_duplicates":n&&!n.filters&&(n.filters={}),n.filters.prevent_duplicates=!!i;break;case"unique_names":i&&(n.send_file_name=!0);break;case"required_features":return u(e.extend({},n));case"preferred_caps":return u(e.extend({},n,{required_features:!0}));case"container":case"browse_button":case"drop_element":return"container"===t?e.get(i):e.getAll(i)}return i}function c(t,e){f[t]=e}function d(t,i){var n,r;return n=new a(t),r=e.Runtime.thatCan(n.getOption("required_features"),i||t.runtimes),n.destroy(),r}var h,f={};return c("mime_types",function(t,i,n){t.length&&!this.getOption("re_ext_filter").test(i.name)?(this.trigger("Error",{code:e.FILE_EXTENSION_ERROR,message:e.translate("File extension error."),file:i}),n(!1)):n(!0)}),c("max_file_size",function(t,i,n){var r;t=e.parseSize(t),i.size!==r&&t&&i.size>t?(this.trigger("Error",{code:e.FILE_SIZE_ERROR,message:e.translate("File size error."),file:i}),n(!1)):n(!0)}),c("prevent_duplicates",function(t,i,n){var r=this;t&&this.forEachItem(function(t){return i.name===t.name&&i.size===t.size?(r.trigger("Error",{code:e.FILE_DUPLICATE_ERROR,message:e.translate("Duplicate file error."),file:i}),n(!1),void 0):void 0}),n(!0)}),c("prevent_empty",function(t,i,n){t&&!i.size&&i.size!==h?(this.trigger("Error",{code:e.FILE_SIZE_ERROR,message:e.translate("File size error."),file:i}),n(!1)):n(!0)}),a.addFileFilter=c,e.inherit(a,n),e.addFileFilter=c,e.predictRuntime=d,a}),o(["plupload","plupload/core/Collection","plupload/core/ArrCollection","plupload/core/Optionable","plupload/core/Queueable","plupload/core/Stats","plupload/core/Queue","plupload/QueueUpload","plupload/QueueResize","plupload/ChunkUploader","plupload/FileUploader","plupload/ImageResizer","plupload/File","plupload/Uploader"])}(this)}); \ No newline at end of file diff --git a/assets/javascripts/plupload/js/plupload.min.js b/assets/javascripts/plupload/js/plupload.min.js deleted file mode 100644 index 9f9d4475..00000000 --- a/assets/javascripts/plupload/js/plupload.min.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Plupload - multi-runtime File Uploader - * v3.1.2 - * - * Copyright 2018, Ephox - * Released under AGPLv3 License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - * - * Date: 2018-02-20 - */ -!function(t,e){var i=function(){var t={};return e.apply(t,arguments),t.plupload};"function"==typeof define&&define.amd?define("plupload",["./moxie"],i):"object"==typeof module&&module.exports?module.exports=i(require("./moxie")):t.plupload=i(t.moxie)}(this||window,function(t){!function(e,i){"use strict";function n(t,e){for(var i,n=[],r=0;r":"gt","&":"amp",'"':"quot","'":"#39"},i=/[<>&\"\']/g;return t?(""+t).replace(i,function(t){return e[t]?"&"+e[t]+";":t}):t},toArray:i.Basic.toArray,inArray:i.Basic.inArray,addI18n:e.core.I18n.addI18n,translate:e.core.I18n.translate,sprintf:i.Basic.sprintf,isEmptyObj:i.Basic.isEmptyObj,hasClass:i.Dom.hasClass,addClass:i.Dom.addClass,removeClass:i.Dom.removeClass,getStyle:i.Dom.getStyle,addEvent:i.Events.addEvent,removeEvent:i.Events.removeEvent,removeAllEvents:i.Events.removeAllEvents,cleanName:function(t){var e,i;for(i=[/[\300-\306]/g,"A",/[\340-\346]/g,"a",/\307/g,"C",/\347/g,"c",/[\310-\313]/g,"E",/[\350-\353]/g,"e",/[\314-\317]/g,"I",/[\354-\357]/g,"i",/\321/g,"N",/\361/g,"n",/[\322-\330]/g,"O",/[\362-\370]/g,"o",/[\331-\334]/g,"U",/[\371-\374]/g,"u"],e=0;e0?"&":"?")+n),t},formatSize:function(t){function e(t,e){return Math.round(t*Math.pow(10,e))/Math.pow(10,e)}var i=this;if(t=parseInt(t,10),isNaN(t))return i.translate("N/A");var n=Math.pow(1024,4);return t>n?e(t/n,1)+" "+i.translate("tb"):t>(n/=1024)?e(t/n,1)+" "+i.translate("gb"):t>(n/=1024)?e(t/n,1)+" "+i.translate("mb"):t>1024?Math.round(t/1024)+" "+i.translate("kb"):t+" "+i.translate("b")},mimes2extList:t.core.utils.Mime.mimes2extList,resolveUrl:i.Url.resolveUrl,parseSize:i.Basic.parseSizeStr,delay:i.Basic.delay,EventTarget:t.core.EventTarget,Runtime:t.runtime.Runtime,FileInput:t.file.FileInput,FileReader:t.file.FileReader}}),r("plupload/core/Collection",["plupload"],function(){var t=function(){function e(){var t;for(t in n);return n[t]}var i,n={},r=0;plupload.extend(this,{count:function(){return r},hasKey:function(t){return n.hasOwnProperty(t)},get:function(t){return n[t]},first:function(){for(var t in n)return n[t]},last:function(){return i},toObject:function(){return n},add:function(t,e){var s=this;return"object"!=typeof t||e?n.hasOwnProperty(t)?s.update.apply(s,arguments):(n[t]=i=e,r++,void 0):plupload.each(t,function(t,e){s.add(e,t)})},remove:function(t){if(this.hasKey(t)){var s=n[t];delete n[t],r--,i===s&&(i=e())}},extract:function(t){var e=this.get(t);return this.remove(t),e},shift:function(){var t,e,i=this;for(e in n)return t=n[e],i.remove(e),t},update:function(t,e){n[t]=e},each:function(t){plupload.each(n,t)},combineWith:function(){var e=new t;return e.add(n),plupload.each(arguments,function(i){i instanceof t&&e.add(i.toObject())}),e},clear:function(){n={},i=null,r=0}})};return t}),r("plupload/core/ArrCollection",["plupload"],function(t){var e=function(){var e=[];t.extend(this,{count:function(){return e.length},hasKey:function(t){return this.getIdx(t)>-1},get:function(t){var i=this.getIdx(t);return i>-1?e[i]:null},getIdx:function(t){for(var i=0,n=e.length;n>i;i++)if(e[i].uid===t)return i;return-1},getByIdx:function(t){return e[t]},first:function(){return e[0]},last:function(){return e[e.length-1]},add:function(t){t=arguments[1]||t;var i=this.getIdx(t.uid);return i>-1?(e[i]=t,i):(e.push(t),e.length-1)},remove:function(t){return!!this.extract(t)},splice:function(i,n){return i="undefinded"===t.typeOf(i)?0:Math.max(i,0),n="undefinded"!==t.typeOf(n)&&i+n-1?e.splice(i,1):null},shift:function(){return e.shift()},update:function(t,i){var n=this.getIdx(t);return n>-1?(e[n]=i,!0):!1},each:function(i){t.each(e,i)},combineWith:function(){return Array.prototype.concat.apply(this.toArray(),arguments)},sort:function(t){e.sort(t||function(t,e){return t.priority-e.priority})},clear:function(){e=[]},toObject:function(){for(var t={},i=0,n=e.length;n>i;i++)t[e[i].uid]=e[i];return t},toArray:function(){return Array.prototype.slice.call(e)}})};return e}),r("plupload/core/Optionable",["plupload"],function(e){var i=t.core.EventTarget;return function(t){function i(){t.apply(this,arguments),this._options={}}return e.inherit(i,t),e.extend(i.prototype,{setOption:function(t,i,n){var r,s=this;return"object"==typeof t?(n=i,e.each(t,function(t,e){s.setOption(e,t,n)}),void 0):((!n||s._options.hasOwnProperty(t))&&(r=e.clone(s._options[t]),"object"===e.typeOf(i)&&"object"===e.typeOf(s._options[t])?e.extend(s._options[t],i):s._options[t]=i,s.trigger("OptionChanged",t,i,r)),void 0)},getOption:function(t){if(!t)return this._options;var i=this._options[t];return e.inArray(e.typeOf(i),["array","object"])>-1?e.extendImmutable({},i):i},setOptions:function(t,e){"object"==typeof t&&this.setOption(t,e)},getOptions:function(){return this.getOption()}}),i}(i)}),r("plupload/core/Queueable",["plupload","plupload/core/Optionable"],function(t,e){return function(e){function i(){e.apply(this,arguments),this.uid=t.guid(),this.state=i.IDLE,this.processed=0,this.total=0,this.percent=0,this.retries=0,this.priority=0,this.startedTimestamp=0,this.processedTimestamp=0}return i.IDLE=1,i.PROCESSING=2,i.PAUSED=6,i.RESUMED=7,i.DONE=5,i.FAILED=4,i.DESTROYED=8,t.inherit(i,e),t.extend(i.prototype,{start:function(){var t=this.state;return this.state===i.PROCESSING?!1:(this.startedTimestamp||(this.startedTimestamp=+new Date),this.state=i.PROCESSING,this.trigger("statechanged",this.state,t),this.trigger("started"),!0)},pause:function(){var e=this.state;return-1===t.inArray(this.state,[i.IDLE,i.RESUMED,i.PROCESSING])?!1:(this.processed=this.percent=0,this.loaded=this.processed,this.state=i.PAUSED,this.trigger("statechanged",this.state,e),this.trigger("paused"),!0)},resume:function(){var t=this.state;return this.state!==i.PAUSED&&this.state!==i.RESUMED?!1:(this.state=i.RESUMED,this.trigger("statechanged",this.state,t),this.trigger("resumed"),!0)},stop:function(){var t=this.state;return this.state===i.IDLE?!1:(this.processed=this.percent=0,this.loaded=this.processed,this.startedTimestamp=0,this.state=i.IDLE,this.trigger("statechanged",this.state,t),this.trigger("stopped"),!0)},done:function(t){var e=this.state;return this.state===i.DONE?!1:(this.processed=this.total,this.loaded=this.processed,this.percent=100,this.processedTimestamp=+new Date,this.state=i.DONE,this.trigger("statechanged",this.state,e),this.trigger("done",t),this.trigger("processed"),!0)},failed:function(t){var e=this.state;return this.state===i.FAILED?!1:(this.processed=this.percent=0,this.loaded=this.processed,this.processedTimestamp=+new Date,this.state=i.FAILED,this.trigger("statechanged",this.state,e),this.trigger("failed",t),this.trigger("processed"),!0)},progress:function(t,e){e&&(this.total=e),this.processed=Math.min(t,this.total),this.loaded=this.processed,this.percent=Math.ceil(100*(this.processed/this.total)),this.trigger({type:"progress",loaded:this.processed,total:this.total})},destroy:function(){var t=this.state;return this.state===i.DESTROYED?!1:(this.state=i.DESTROYED,this.trigger("statechanged",this.state,t),this.trigger("destroy"),this.unbindAll(),!0)}}),i}(e)}),r("plupload/core/Stats",[],function(){return function(){var t=this;t.size=0,t.total=0,t.loaded=0,t.uploaded=0,t.done=0,t.failed=0,t.queued=0,t.paused=0,t.processing=0,t.paused=0,t.percent=0,t.bytesPerSec=0,t.processedPerSec=0,t.reset=function(){t.size=t.total=t.loaded=t.processed=t.uploaded=t.done=t.failed=t.queued=t.processing=t.paused=t.percent=t.bytesPerSec=t.processedPerSec=0}}}),r("plupload/core/Queue",["plupload","plupload/core/ArrCollection","plupload/core/Queueable","plupload/core/Stats"],function(t,e,i,n){return function(r){function s(i){r.apply(this,arguments),this._queue=new e,this.stats=new n,this._options=t.extend({},this._options,{max_slots:1,max_retries:0,auto_start:!1,finish_active:!1},i)}function o(){var t;return this.forEachItem(function(e){return e.state===i.IDLE||e.state===i.RESUMED?(t=e,!1):void 0}),t?t:null}function a(){var t;if(this.state!==i.PROCESSING&&this.state!==i.PAUSED)return!1;if(this.stats.processingt.startedTimestamp)&&(r+=n),e.processedPerSec=Math.ceil(r/((+new Date-t.startedTimestamp||1)/1e3)),e.processed=n,e.total+=s.total,e.total&&(e.percent=Math.ceil(100*(e.processed/e.total)))}),t.percent=e.percent,e.loaded=e.processed,e.size=e.total,e.bytesPerSec=e.processedPerSec,!0):!1},destroy:function(){var e=this;return e.state===i.DESTROYED?!1:e.state!==i.IDLE?(e.bindOnce("Stopped",function(){t.delay.call(e,e.destroy)}),e.stop()):(e.clear(),s.parent.destroy.call(this),e._queue=e.stats=null,!0)}}),s}(i)}),r("plupload/QueueUpload",["plupload","plupload/core/Queue"],function(t,e){return function(i){function n(t){e.call(this,{max_slots:1,max_retries:0,auto_start:!1,finish_active:!1,url:!1,chunk_size:0,multipart:!0,http_method:"POST",params:{},headers:!1,file_data_name:"file",send_file_name:!0,stop_on_fail:!0}),this.setOption=function(t,e){"object"!=typeof t&&"max_upload_slots"==t&&(t="max_slots"),n.prototype.setOption.call(this,t,e,!0)},this.setOptions(t)}return t.inherit(n,i),n}(e)}),r("plupload/QueueResize",["plupload","plupload/core/Queue"],function(t,e){return function(i){function n(t){e.call(this,{max_slots:1,max_retries:0,auto_start:!1,finish_active:!1,resize:{}}),this.setOption=function(t,e){"object"!=typeof t&&"max_resize_slots"==t&&(t="max_slots"),n.prototype.setOption.call(this,t,e,!0)},this.setOptions(t)}return t.inherit(n,i),n}(e)}),r("plupload/ChunkUploader",["plupload","plupload/core/Collection","plupload/core/Queueable"],function(e,i,n){function r(t){function i(t,i){var n="";return e.each(i,function(t,e){n+=(n?"&":"")+encodeURIComponent(e)+"="+encodeURIComponent(t)}),n&&(t+=(t.indexOf("?")>0?"&":"?")+n),t}var a;n.call(this),this._options={file_data_name:"file",headers:!1,http_method:"POST",multipart:!0,params:{},send_file_name:!0,url:!1},e.extend(this,{start:function(){var r,u,l=this,p=this.state,c=l._options;if(this.state===n.PROCESSING)return!1;this.startedTimestamp||(this.startedTimestamp=+new Date),this.state=n.PROCESSING,this.trigger("statechanged",this.state,p),a=new s,a.upload&&(a.upload.onprogress=function(t){l.progress(t.loaded,t.total)}),a.onload=function(){var t={response:this.responseText,status:this.status,responseHeaders:this.getAllResponseHeaders()};return this.status<200||this.status>=400?l.failed(t):(l.done(t),void 0)},a.onerror=function(){l.failed()},a.onloadend=function(){setTimeout(function(){a&&(a.destroy(),a=null)},1)};try{r=c.multipart?c.url:i(c.url,c.params),a.open(c.http_method,r,!0),e.isEmptyObj(c.headers)||e.each(c.headers,function(t,e){a.setRequestHeader(e,t)}),c.multipart?(u=new o,e.isEmptyObj(c.params)||e.each(c.params,function(t,e){u.append(e,t)}),u.append(c.file_data_name,t),a.send(u)):((e.isEmptyObj(c.headers)||!a.hasRequestHeader("content-type"))&&a.setRequestHeader("content-type","application/octet-stream"),a.send(t)),this.trigger("started")}catch(d){l.failed()}},stop:function(){a&&(a.abort(),a.destroy(),a=null),r.prototype.stop.call(this)},setOption:function(t,e){r.prototype.setOption.call(this,t,e,!0)},setOptions:function(t){r.prototype.setOption.call(this,t,!0)},destroy:function(){this.stop(),r.prototype.destroy.call(this)}})}var s=t.xhr.XMLHttpRequest,o=t.xhr.FormData;return e.inherit(r,n),r}),r("plupload/FileUploader",["plupload","plupload/core/Collection","plupload/core/Queueable","plupload/ChunkUploader"],function(t,e,i,n){function r(s,o){function a(){var t=0;return l.each(function(e){e.state===i.DONE&&(t+=e.end-e.start)}),t}function u(){for(var t=0;p>t&&l.hasKey(t);)t++;return t}var l=new e,p=1;i.call(this),this._options={chunk_size:0,params:{},send_file_name:!0,stop_on_fail:!0},t.extend(this,{name:s.name,start:function(){var t,e=this,r=this.state;return this.state===i.PROCESSING?!1:(this.startedTimestamp||(this.startedTimestamp=+new Date),this.state=i.PROCESSING,this.trigger("statechanged",this.state,r),e._options.send_file_name&&(e._options.params.name=e.target_name||e.name),e._options.chunk_size?(p=Math.ceil(s.size/e._options.chunk_size),e.uploadChunk(!1,!0)):(t=new n(s),t.bind("progress",function(t){e.progress(t.loaded,t.total)}),t.bind("done",function(t,i){e.done(i)}),t.bind("failed",function(t,i){e.failed(i)}),t.setOptions(e._options),o.addItem(t)),this.trigger("started"),void 0)},uploadChunk:function(e,r){var c,d,h=this,f=this.getOption("chunk_size"),g={};return g.seq=parseInt(e,10)||u(),g.start=g.seq*f,g.end=Math.min(g.start+f,s.size),g.total=s.size,g.start<0||g.start>=s.size?!1:(d=t.extendImmutable({},this.getOptions(),{params:{chunk:g.seq,chunks:p}}),c=new n(s.slice(g.start,g.end,s.type)),c.bind("progress",function(t){h.progress(a()+t.loaded,s.size)}),c.bind("failed",function(e,n){l.add(g.seq,t.extend({state:i.FAILED},g)),h.trigger("chunkuploadfailed",t.extendImmutable({},g,n)),d.stop_on_fail&&h.failed(n)}),c.bind("done",function(e,n){l.add(g.seq,t.extend({state:i.DONE},g)),h.trigger("chunkuploaded",t.extendImmutable({},g,n)),a()>=s.size?(h.progress(s.size,s.size),h.done(n)):r&&t.delay(function(){h.uploadChunk(u(),r)})}),c.bind("processed",function(){this.destroy()}),c.setOptions(d),l.add(g.seq,t.extend({state:i.PROCESSING},g)),o.addItem(c),r&&o.countSpareSlots()&&h.uploadChunk(u(),r),!0)},destroy:function(){r.prototype.destroy.call(this),l.clear()}})}return t.inherit(r,i),r}),r("plupload/ImageResizer",["plupload","plupload/core/Queueable"],function(e,i){function n(t){i.call(this),this._options={type:"image/jpeg",quality:90,crop:!1,fit:!0,preserveHeaders:!0,resample:"default",multipass:!0},this.setOption=function(t){("object"==typeof t||this._options.hasOwnProperty(t))&&n.prototype.setOption.apply(this,arguments)},this.start=function(e){var i,n=this;e&&this.setOptions(e.resize),i=new r,i.bind("load",function(){this.resize(n.getOptions())}),i.bind("resize",function(){n.done(this.getAsBlob(n.getOption("type"),n.getOption("quality"))),this.destroy()}),i.bind("error",function(){n.failed(),this.destroy()}),i.load(t,n.getOption("runtimeOptions"))}}var r=t.image.Image;return e.inherit(n,i),e.Image=r,n}),r("plupload/File",["plupload","plupload/core/Queueable","plupload/FileUploader","plupload/ImageResizer"],function(t,e,i,n){function r(a,u,l){e.call(this),t.extend(this,{id:this.uid,name:a.name,target_name:null,type:a.type,size:a.size,origSize:a.size,start:function(){var i=this.state;return this.state===e.PROCESSING?!1:(this.state=e.PROCESSING,this.trigger("statechanged",this.state,i),this.trigger("started"),!t.isEmptyObj(this._options.resize)&&s(this.type)&&o(a,"send_binary_string")?this.resizeAndUpload():this.upload(),!0)},getSource:function(){return a},getNative:function(){return this.getFile().getSource()},resizeAndUpload:function(){var t=this,e=t.getOptions(),i=new n(a);i.bind("progress",function(e){t.progress(e.loaded,e.total)}),i.bind("done",function(e,i){i=i,t.upload()}),i.bind("failed",function(){t.upload()}),i.setOption("runtimeOptions",{runtime_order:e.runtimes,required_caps:e.required_features,preferred_caps:e.preferred_caps,swf_url:e.flash_swf_url,xap_url:e.silverlight_xap_url}),l.addItem(i)},upload:function(){var t=this,e=new i(a,u);e.bind("paused",function(){t.pause()}),e.bind("resumed",function(){this.start()}),e.bind("started",function(){t.trigger("startupload")}),e.bind("progress",function(e){t.progress(e.loaded,e.total)}),e.bind("done",function(e,i){t.done(i)}),e.bind("failed",function(e,i){t.failed(i)}),e.setOptions(t.getOptions()),e.start()},destroy:function(){r.prototype.destroy.call(this),a=null}})}function s(e){return t.inArray(e,["image/jpeg","image/png"])>-1}function o(e,i){if(e.ruid){var n=t.Runtime.getInfo(e.ruid);if(n)return n.can(i)}return!1}return t.inherit(r,e),r}),r("plupload/Uploader",["plupload","plupload/core/Collection","plupload/core/Queue","plupload/QueueUpload","plupload/QueueResize","plupload/File"],function(e,i,n,r,s,o){function a(i){function u(){var t=O[0]||b[0];return t?t.getRuntime().uid:!1}function c(){this.bind("FilesAdded FilesRemoved",function(t){t.trigger("QueueChanged"),t.refresh()},this,999),this.bind("BeforeUpload",g),this.bind("Stopped",function(t){t.trigger("UploadComplete")}),this.bind("Error",m),this.bind("Destroy",_)}function d(i){var n=this,r=0,s=[],o={runtime_order:n.getOption("runtimes"),required_caps:n.getOption("required_features"),preferred_caps:n.getOption("preferred_caps"),swf_url:n.getOption("flash_swf_url"),xap_url:n.getOption("silverlight_xap_url")};e.each(n.getOption("runtimes").split(/\s*,\s*/),function(t){n.getOption(t)&&(o[t]=n.getOption(t))}),n.getOption("browse_button")&&e.each(n.getOption("browse_button"),function(i){s.push(function(s){var a=new t.file.FileInput(e.extend({},o,{accept:n.getOption("filters").mime_types,name:n.getOption("file_data_name"),multiple:n.getOption("multi_selection"),container:n.getOption("container"),browse_button:i}));a.onready=function(){var t=e.Runtime.getInfo(this.ruid);e.extend(n.features,{chunks:t.can("slice_blob"),multipart:t.can("send_multipart"),multi_selection:t.can("select_multiple")}),r++,O.push(this),s()},a.onchange=function(){n.addFile(this.files)},a.bind("mouseenter mouseleave mousedown mouseup",function(t){R||(n.getOption("browse_button_hover")&&("mouseenter"===t.type?e.addClass(i,n.getOption("browse_button_hover")):"mouseleave"===t.type&&e.removeClass(i,n.getOption("browse_button_hover"))),n.getOption("browse_button_active")&&("mousedown"===t.type?e.addClass(i,n.getOption("browse_button_active")):"mouseup"===t.type&&e.removeClass(i,n.getOption("browse_button_active"))))}),a.bind("mousedown",function(){n.trigger("Browse")}),a.bind("error runtimeerror",function(){a=null,s()}),a.init()})}),n.getOption("drop_element")&&e.each(n.getOption("drop_element"),function(i){s.push(function(s){var a=new t.file.FileDrop(e.extend({},o,{drop_zone:i}));a.onready=function(){var t=e.Runtime.getInfo(this.ruid);e.extend(n.features,{chunks:t.can("slice_blob"),multipart:t.can("send_multipart"),dragdrop:t.can("drag_and_drop")}),r++,b.push(this),s()},a.ondrop=function(){n.addFile(this.files)},a.bind("error runtimeerror",function(){a=null,s()}),a.init()})}),e.inParallel(s,function(){"function"==typeof i&&i(r)})}function g(t,e){if(t.getOption("unique_names")){var i=e.name.match(/\.([^.]+)$/),n="part";i&&(n=i[1]),e.target_name=e.id+"."+n}}function m(t,i){i.code===e.INIT_ERROR?t.destroy():i.code===e.HTTP_ERROR&&t.state==e.STARTED&&t.trigger("CancelUpload")}function _(t){t.forEachItem(function(t){t.destroy()}),O.length&&(e.each(O,function(t){t.destroy()}),O=[]),b.length&&(e.each(b,function(t){t.destroy()}),b=[]),E=!1,y&&y.destroy(),v&&v.destroy(),I=y=v=null}var y,v,O=[],b=[],E=!1,R=!1,I=l(e.extend({backward_compatibility:!0,chunk_size:0,file_data_name:"file",filters:{mime_types:"*",prevent_duplicates:!1,max_file_size:0},flash_swf_url:"js/Moxie.swf",http_method:"POST",max_resize_slots:1,max_retries:0,max_upload_slots:1,multipart:!0,multipart_params:{},multi_selection:!0,params:{},resize:!1,runtimes:e.Runtime.order,send_chunk_number:!0,send_file_name:!0,silverlight_xap_url:"js/Moxie.xap",required_features:!1,preferred_caps:!1},i));n.call(this),e.extend(this,{_options:I,id:this.uid,state:e.STOPPED,features:{},settings:I,runtime:null,files:[],total:this.stats,init:function(){var t,i,n=this;return t=n.getOption("preinit"),"function"==typeof t?t(n):e.each(t,function(t,e){n.bind(e,t)}),c.call(n),e.each(["container","browse_button","drop_element"],function(t){return null===n.getOption(t)?(i={code:e.INIT_ERROR,message:e.sprintf(e.translate("%s specified, but cannot be found."),t)},!1):void 0}),i?n.trigger("Error",i):n.getOption("browse_button")||n.getOption("drop_element")?(d.call(n,function(t){var i,o=n.getOption("init"),a=e.extendImmutable({},n.getOption(),{auto_start:!0});"function"==typeof o?o(n):e.each(o,function(t,e){n.bind(e,t)}),t?(E=!0,i=e.Runtime.getInfo(u()),y=new r(a),v=new s(a),n.trigger("Init",{ruid:i.uid,runtime:n.runtime=i.type}),n.trigger("PostInit")):n.trigger("Error",{code:e.INIT_ERROR,message:e.translate("Init error.")})}),void 0):n.trigger("Error",{code:e.INIT_ERROR,message:e.translate("You must specify either browse_button or drop_element.")})},setOption:function(t,i){return E&&e.inArray(t,["container","browse_button","drop_element","runtimes","multi_selection","flash_swf_url","silverlight_xap_url"])>-1?this.trigger("Error",{code:e.OPTION_ERROR,message:e.sprintf(e.translate("%s option cannot be changed.")),option:t}):("object"!=typeof t&&(i=p(t,i,this._options),y&&y.setOption(t,i),v&&v.setOption(t,i)),a.prototype.setOption.call(this,t,i),void 0)},refresh:function(){O.length&&e.each(O,function(t){t.trigger("Refresh")}),b.length&&e.each(b,function(t){t.trigger("Refresh")}),this.trigger("Refresh")},stop:function(){a.prototype.stop.call(this)&&this.state!=e.STOPPED&&this.trigger("CancelUpload")},disableBrowse:function(){R=arguments[0]!==h?arguments[0]:!0,O.length&&e.each(O,function(t){t.disable(R)}),this.trigger("DisableBrowse",R)},getFile:function(t){return this.getItem(t)},addFile:function(i,n){function r(t){t.bind("beforestart",function(t){return p.trigger("BeforeUpload",t.target)}),t.bind("startupload",function(){p.trigger("UploadFile",this)}),t.bind("progress",function(){p.trigger("UploadProgress",this)}),t.bind("done",function(t,e){p.trigger("FileUploaded",this,e)}),t.bind("failed",function(t,i){p.trigger("Error",e.extend({code:e.HTTP_ERROR,message:e.translate("HTTP Error."),file:this},i))})}function s(t,i){var n=[];e.each(p.getOption("filters"),function(e,i){f[i]&&n.push(function(n){f[i].call(p,e,t,function(t){n(!t)})})}),e.inParallel(n,i)}function a(i){var u=e.typeOf(i);if(i instanceof t.file.File){if(!i.ruid&&!i.isDetached()){if(!l)return!1;i.ruid=l,i.connectRuntime(l)}c.push(function(t){s(i,function(s){var a;s||(a=new o(i,y,v),n&&(a.name=n),r(a),p.addItem(a),d.push(a),p.trigger("FileFiltered",a)),e.delay(t)})})}else i instanceof t.file.Blob?(a(i.getSource()),i.destroy()):-1!==e.inArray(u,["file","blob"])?a(new t.file.File(null,i)):"node"===u&&"filelist"===e.typeOf(i.files)?e.each(i.files,a):"array"===u&&(n=null,e.each(i,a))}var l,p=this,c=[],d=[];l=u(),a(i),c.length&&e.inParallel(c,function(){d.length&&p.trigger("FilesAdded",d)})},removeFile:function(t){var e=this.extractItem("string"==typeof t?t:t.uid);e&&(this.trigger("FilesRemoved",[e]),e.destroy())},splice:function(){var t=0,i=e.STARTED==this.state,r=n.prototype.splice.apply(this,arguments);if(r.length){for(this.trigger("FilesRemoved",r),i&&this.stop(),t=0;t0&&(r.slice_blob=!0),e.isEmptyObj(t.resize)&&t.multipart!==!1||(r.send_binary_string=!0),t.http_method&&(r.use_http_method=t.http_method),e.each(t,function(t,e){i(e,!!t,!0)})),r}function l(t){return e.each(t,function(e,i){t[i]=p(i,e,t)}),t}function p(t,i,n){switch(t){case"chunk_size":(i=e.parseSize(i))&&(n.send_file_name=!0);break;case"headers":var r={};return"object"==typeof i&&e.each(i,function(t,e){r[e.toLowerCase()]=t}),r;case"http_method":return"PUT"===i.toUpperCase()?"PUT":"POST";case"filters":return"array"===e.typeOf(i)&&(i={mime_types:i}),i.mime_types&&("string"===e.typeOf(i.mime_types)&&(i.mime_types=e.mimes2extList(i.mime_types)),n.re_ext_filter=function(t){var i=[];return e.each(t,function(t){e.each(t.extensions.split(/,/),function(t){/^\s*\*\s*$/.test(t)?i.push("\\.*"):i.push("\\."+t.replace(new RegExp("["+"/^$.*+?|()[]{}\\".replace(/./g,"\\$&")+"]","g"),"\\$&"))})}),new RegExp("("+i.join("|")+")$","i")}(i.mime_types)),i;case"max_file_size":n&&!n.filters&&(n.filters={}),n.filters.max_file_size=i;break;case"multipart":i||(n.send_file_name=!0);break;case"multipart_params":n.params=n.multipart_params=i;break;case"resize":return i?e.extend({preserve_headers:!0,crop:!1},i):!1;case"prevent_duplicates":n&&!n.filters&&(n.filters={}),n.filters.prevent_duplicates=!!i;break;case"unique_names":i&&(n.send_file_name=!0);break;case"required_features":return u(e.extend({},n));case"preferred_caps":return u(e.extend({},n,{required_features:!0}));case"container":case"browse_button":case"drop_element":return"container"===t?e.get(i):e.getAll(i)}return i}function c(t,e){f[t]=e}function d(t,i){var n,r;return n=new a(t),r=e.Runtime.thatCan(n.getOption("required_features"),i||t.runtimes),n.destroy(),r}var h,f={};return c("mime_types",function(t,i,n){t.length&&!this.getOption("re_ext_filter").test(i.name)?(this.trigger("Error",{code:e.FILE_EXTENSION_ERROR,message:e.translate("File extension error."),file:i}),n(!1)):n(!0)}),c("max_file_size",function(t,i,n){var r;t=e.parseSize(t),i.size!==r&&t&&i.size>t?(this.trigger("Error",{code:e.FILE_SIZE_ERROR,message:e.translate("File size error."),file:i}),n(!1)):n(!0)}),c("prevent_duplicates",function(t,i,n){var r=this;t&&this.forEachItem(function(t){return i.name===t.name&&i.size===t.size?(r.trigger("Error",{code:e.FILE_DUPLICATE_ERROR,message:e.translate("Duplicate file error."),file:i}),n(!1),void 0):void 0}),n(!0)}),c("prevent_empty",function(t,i,n){t&&!i.size&&i.size!==h?(this.trigger("Error",{code:e.FILE_SIZE_ERROR,message:e.translate("File size error."),file:i}),n(!1)):n(!0)}),a.addFileFilter=c,e.inherit(a,n),e.addFileFilter=c,e.predictRuntime=d,a}),o(["plupload","plupload/core/Collection","plupload/core/ArrCollection","plupload/core/Optionable","plupload/core/Queueable","plupload/core/Stats","plupload/core/Queue","plupload/QueueUpload","plupload/QueueResize","plupload/ChunkUploader","plupload/FileUploader","plupload/ImageResizer","plupload/File","plupload/Uploader"])}(this)}); \ No newline at end of file diff --git a/assets/javascripts/plupload/license.txt b/assets/javascripts/plupload/license.txt deleted file mode 100644 index 2def0e88..00000000 --- a/assets/javascripts/plupload/license.txt +++ /dev/null @@ -1,661 +0,0 @@ - GNU AFFERO GENERAL PUBLIC LICENSE - Version 3, 19 November 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU Affero General Public License is a free, copyleft license for -software and other kinds of works, specifically designed to ensure -cooperation with the community in the case of network server software. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -our General Public Licenses are intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - Developers that use our General Public Licenses protect your rights -with two steps: (1) assert copyright on the software, and (2) offer -you this License which gives you legal permission to copy, distribute -and/or modify the software. - - A secondary benefit of defending all users' freedom is that -improvements made in alternate versions of the program, if they -receive widespread use, become available for other developers to -incorporate. Many developers of free software are heartened and -encouraged by the resulting cooperation. However, in the case of -software used on network servers, this result may fail to come about. -The GNU General Public License permits making a modified version and -letting the public access it on a server without ever releasing its -source code to the public. - - The GNU Affero General Public License is designed specifically to -ensure that, in such cases, the modified source code becomes available -to the community. It requires the operator of a network server to -provide the source code of the modified version running there to the -users of that server. Therefore, public use of a modified version, on -a publicly accessible server, gives the public access to the source -code of the modified version. - - An older license, called the Affero General Public License and -published by Affero, was designed to accomplish similar goals. This is -a different license, not a version of the Affero GPL, but Affero has -released a new version of the Affero GPL which permits relicensing under -this license. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU Affero General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Remote Network Interaction; Use with the GNU General Public License. - - Notwithstanding any other provision of this License, if you modify the -Program, your modified version must prominently offer all users -interacting with it remotely through a computer network (if your version -supports such interaction) an opportunity to receive the Corresponding -Source of your version by providing access to the Corresponding Source -from a network server at no charge, through some standard or customary -means of facilitating copying of software. This Corresponding Source -shall include the Corresponding Source for any work covered by version 3 -of the GNU General Public License that is incorporated pursuant to the -following paragraph. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the work with which it is combined will remain governed by version -3 of the GNU General Public License. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU Affero General Public License from time to time. Such new versions -will be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU Affero General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU Affero General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU Affero General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If your software can interact with users remotely through a computer -network, you should also make sure that it provides a way for users to -get its source. For example, if your program is a web application, its -interface could display a "Source" link that leads users to an archive -of the code. There are many ways you could offer source, and different -solutions will be better for different programs; see section 13 for the -specific requirements. - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU AGPL, see -. \ No newline at end of file diff --git a/assets/javascripts/plupload/readme.md b/assets/javascripts/plupload/readme.md deleted file mode 100644 index 5e329d55..00000000 --- a/assets/javascripts/plupload/readme.md +++ /dev/null @@ -1,147 +0,0 @@ -# Plupload - -Plupload is a cross-browser multi-runtime file uploading API. Basically, a set of tools that will help you to -build a reliable and visually appealing file uploader in minutes. - -Historically, Plupload comes from a dark and hostile age of no HTML5, hence all the alternative fallbacks, -like Flash, Silverlight and Java (still in development). It is meant to provide an API, that -will work anywhere and in any case, in one way or another. While having very solid fallbacks, Plupload -is built with the future of HTML5 in mind. - -### Table of Contents -* [Backstory](#backstory) -* [Structure](#structure) - * [File API and XHR L2 pollyfills](https://github.com/moxiecode/moxie/blob/master/README.md) - * [Plupload API](https://github.com/moxiecode/plupload/wiki/API) - * [UI Widget](https://github.com/moxiecode/plupload/wiki/UI.Plupload) - * [Queue Widget](https://github.com/moxiecode/plupload/wiki/pluploadQueue) -* [Demos](https://github.com/jayarjo/plupload-demos/blob/master/README.md) -* [Building Instructions](#build) -* [Getting Started](https://github.com/moxiecode/plupload/wiki/Getting-Started) - * [Options](https://github.com/moxiecode/plupload/wiki/Options) - * [Events](https://github.com/moxiecode/plupload/wiki/Uploader#wiki-events) - * [Methods](https://github.com/moxiecode/plupload/wiki/Uploader#wiki-methods) - * [Plupload in Your Language](https://github.com/moxiecode/plupload/wiki/Plupload-in-Your-Language) - * [File Filters](https://github.com/moxiecode/plupload/wiki/File-Filters) - * [Image Resizing on Client-Side](https://github.com/moxiecode/plupload/wiki/Image-Resizing-on-Client-Side) - * [Chunking](https://github.com/moxiecode/plupload/wiki/Chunking) - * [Upload to Amazon S3](https://github.com/moxiecode/plupload/wiki/Upload-to-Amazon-S3) -* [FAQ](https://github.com/moxiecode/plupload/wiki/Frequently-Asked-Questions) -* [Support](#support) - * [Create a Fiddle](https://github.com/moxiecode/plupload/wiki/Create-a-Fiddle) -* [Contributing](#contribute) -* [License](#license) -* [Contact Us](http://www.moxiecode.com/contact.php) - - -### Backstory - -Plupload started in a time when uploading a file in a responsive and customizable manner was a real pain. -Internally, browsers only had the `input[type="file"]` element. It was ugly and clunky at the same time. -One couldn't even change it's visuals, without hiding it and coding another one on top of it from scratch. -And then there was no progress indication for the upload process... Sounds pretty crazy today. - -It was very logical for developers to look for alternatives and writing their own implementations, using -Flash and Java, in order to somehow extend limited browser capabilities. And so did we, in our search for -a reliable and flexible file uploader for -our [TinyMCE](http://www.tinymce.com/index.php)'s -[MCImageManager](http://www.tinymce.com/enterprise/mcimagemanager.php). - -Quickly enough though, Plupload grew big. It easily split into a standalone project. -With major *version 2.0* it underwent another huge reconstruction, basically -[from the ground up](http://blog.moxiecode.com/2012/11/28/first-public-beta-plupload-2/), -as all the low-level runtime logic has been extracted into separate [File API](http://www.w3.org/TR/FileAPI/) -and [XHR L2](http://www.w3.org/TR/XMLHttpRequest/) pollyfills (currently known under combined name of [mOxie](https://github.com/moxiecode/moxie)), -giving Plupload a chance to evolve further. - - -### Structure - -Currently, Plupload may be considered as consisting of three parts: low-level pollyfills, -Plupload API and Widgets (UI and Queue). Initially, Widgets were meant only to serve as examples -of the API, but quickly formed into fully-functional API implementations that now come bundled with -the Plupload API. This has been a source for multiple misconceptions about the API as Widgets were -easily mistaken for the Plupload itself. They are only implementations, such as any of you can -build by yourself out of the API. - -* [Low-level pollyfills (mOxie)](https://github.com/moxiecode/moxie) - have their own [code base](https://github.com/moxiecode/moxie) and [documentation](https://github.com/moxiecode/moxie/wiki) on GitHub. -* [Plupload API](https://github.com/moxiecode/plupload/wiki/API) -* [UI Widget](https://github.com/moxiecode/plupload/wiki/UI.Plupload) -* [Queue Widget](https://github.com/moxiecode/plupload/wiki/pluploadQueue) - - -### Building instructions - -Plupload depends on File API and XHR2 L2 pollyfills that currently have their -[own repository](https://github.com/moxiecode/moxie) on GitHub. However, in most cases you shouldn't -care as we bundle the latest build of mOxie, including full and minified JavaScript source and -pre-compiled `SWF` and `XAP` components, with [every release](https://github.com/moxiecode/plupload/releases). You can find everything you may need under `js/` folder. - -There are cases where you might need a custom build, for example free of unnecessary runtimes, half the -original size, etc. The difficult part of this task comes from mOxie and its set of additional runtimes -that require special tools on your workstation in order to compile. -Consider [build instructions for mOxie](https://github.com/moxiecode/moxie#build-instructions) - -everything applies to Plupload as well. - -First of all, if you want to build custom Plupload packages you will require [Node.js](http://nodejs.org/), -as this is our build environment of choice. Node.js binaries (as well as Source) -[are available](http://nodejs.org/download/) for all major operating systems. - -Plupload includes _mOxie_ as a submodule, it also depends on some other repositories for building up it's dev -environment - to avoid necessity of downloading them one by one, we recommended you to simply clone Plupload -with [git](http://git-scm.com/) recursively (you will require git installed on your system for this operation -to succeed): - -``` -git clone --recursive https://github.com/moxiecode/plupload.git -``` - -And finalize the preparation stage with: `npm install` - this will install all additional modules, including those -required by dev and test environments. In case you would rather keep it minimal, add a `--production` flag. - -*Note:* Currently, for an unknown reason, locally installed Node.js modules on Windows, may not be automatically -added to the system PATH. So, if `jake` commands below are not recognized you will need to add them manually: - -``` -set PATH=%PATH%;%CD%\node_modules\.bin\ -``` - - -### Support - -We are actively standing behind the Plupload and now that we are done with major rewrites and refactoring, -the only real goal that we have ahead is making it as reliable and bulletproof as possible. We are open to -all the suggestions and feature requests. We ask you to file bug reports if you encounter any. We may not -react to them instantly, but we constantly bear them in my mind as we extend the code base. - -In addition to dedicated support for those who dare to buy our OEM licenses, we got -[discussion boards](http://www.plupload.com/punbb/index.php), which is like an enormous FAQ, -covering every possible application case. Of course, you are welcome to file a bug report or feature request, -here on [GitHub](https://github.com/moxiecode/plupload/issues). - -Sometimes it is easier to notice the problem when bug report is accompained by the actual code. Consider providing -[a Plupload fiddle](https://github.com/moxiecode/plupload/wiki/Create-a-Fiddle) for the troublesome code. - - -### Contributing - -We are open to suggestions and code revisions, however there are some rules and limitations that you might -want to consider first. - -* Code that you contribute will automatically be licensed under the LGPL, but will not be limited to LGPL. -* Although all contributors will get the credit for their work, copyright notices will be changed to [Moxiecode Systems AB](http://www.moxiecode.com/). -* Third party code will be reviewed, tested and possibly modified before being released. - -These basic rules help us earn a living and ensure that code remains Open Source and compatible with LGPL license. All contributions will be added to the changelog and appear in every release and on the site. - -An easy place to start is to [translate Plupload to your language](https://github.com/moxiecode/plupload/wiki/Plupload-in-Your-Language#contribute). - -You can read more about how to contribute at: [http://www.plupload.com/contributing](http://www.plupload.com/contributing) - - -### License - -Copyright 2013, [Moxiecode Systems AB](http://www.moxiecode.com/) -Released under [GPLv2 License](https://github.com/moxiecode/plupload/blob/master/license.txt). - -We also provide [commercial license](http://www.plupload.com/commercial.php). diff --git a/assets/javascripts/redmine_dmsf.js b/assets/javascripts/redmine_dmsf.js index 133c19d2..e145bd53 100644 --- a/assets/javascripts/redmine_dmsf.js +++ b/assets/javascripts/redmine_dmsf.js @@ -171,116 +171,3 @@ function dmsfExpandRows(EL, parentRow, url) { alert('An error in rows expanding'); }); } - -/* Plupload */ -function dmsf_plupload_toggle(button, second_button) { - if(button.hasClass('ui-state-default')) { - button.removeClass('ui-state-default'); - button.addClass('ui-state-active'); - button.attr('aria-pressed', 'true'); - second_button.removeClass('ui-state-active'); - second_button.addClass('ui-state-default'); - second_button.attr('aria-pressed', 'false'); - } -} - -function initPlUploader(uploader, formUrl, maxFileSize, maxFileCount, flashUrl) { - uploader.html('
    '); - uploader = $('div', uploader); - uploader.plupload({ - runtimes : 'html5,flash,html4', - url : formUrl, - max_file_size : maxFileSize, - max_file_count: maxFileCount, - multipart: true, - // Enable ability to drag'n'drop files onto the widget (currently only HTML5 supports that) - dragdrop: true, - multipart_params : { authenticity_token : $('input[name=authenticity_token]').val() }, - // Rename files by clicking on their titles - rename: true, - // Views to activate - views: { - list: true, - thumbs: true, // Show thumbs - active: 'thumbs' - }, - // Flash settings - flash_swf_url : flashUrl - }); - $('.plupload_scroll', uploader).resizable({ - handles: 's' - }); - - var pluploader = uploader.plupload('getUploader'); - - pluploader.bind('FileUploaded', function(up, file, response) { - var responseObject = $.parseJSON(response.response); - if (responseObject == null) { //Bug: on Firefox folders entries act unexpectedly. - file.status = plupload.FAILED; - pluploader.trigger('UploadProgress', file); - pluploader.trigger('QueueChanged'); - } else { - if (responseObject.error == null) { - var disk_filename_input = $('').attr('type', 'hidden') - .attr('name', 'uploaded[' + window.dmsfFileFieldCount + '][disk_filename]') - .val(responseObject.disk_filename); - uploader.append(disk_filename_input); - var content_type_input = $('').attr('type', 'hidden') - .attr('name', 'uploaded[' + window.dmsfFileFieldCount + '][content_type]') - .val(responseObject.content_type); - uploader.append(content_type_input); - var original_filename_input = $('').attr('type', 'hidden') - .attr('name', 'uploaded[' + window.dmsfFileFieldCount + '][original_filename]') - .val(responseObject.original_filename); - uploader.append(original_filename_input); - var tempfile_path = $('').attr('type', 'hidden') - .attr('name', 'uploaded[' + window.dmsfFileFieldCount + '][tempfile_path]') - .val(responseObject.tempfile_path); - uploader.append(tempfile_path); - } else { - file.status = plupload.FAILED; - pluploader.trigger('UploadProgress', file); - pluploader.trigger('QueueChanged'); - } - } - window.dmsfFileFieldCount++; - return true; - }); - - pluploader.bind('UploadComplete', function(up, files) { - $('#uploadform').submit(); - }); - - pluploader.bind('PostInit', function() { - /* This is a workaround for EasyRedmine. - There are radio buttons with texts instead of buttons with icons. */ - var list = $("label.plupload_button[data-view='list']"); - if(list.attr('role') != 'button') { - var thumbs = $("label.plupload_button[data-view='thumbs']"); - if (list) { - list.text(''); - list.attr('title', 'List'); - list.attr('role', 'button'); - list.attr('aria-pressed', 'false'); - list.removeClass('ui-checkboxradio-radio-label ui-checkboxradio-checked ui-state-active ui-controlgroup-item ui-checkboxradio-label'); - list.addClass('ui-button-icon-only ui-state-default ui-corner-left'); - list.html("List"); - list.click(function () { - dmsf_plupload_toggle(list, thumbs); - }); - } - if (thumbs) { - thumbs.text(''); - thumbs.attr('title', 'Thumbnails'); - thumbs.attr('role', 'button'); - thumbs.attr('aria-pressed', 'true'); - thumbs.removeClass('ui-checkboxradio-radio-label ui-checkboxradio-checked ui-controlgroup-item ui-checkboxradio-label'); - thumbs.addClass('ui-button-icon-only ui-corner-right'); - thumbs.html("Thumbnails"); - thumbs.click(function () { - dmsf_plupload_toggle(thumbs, list); - }); - } - } - }); -} \ No newline at end of file diff --git a/assets/stylesheets/jquery.dataTables/datatables.min.css b/assets/stylesheets/jquery.dataTables/datatables.min.css deleted file mode 100644 index 7ad9f7d8..00000000 --- a/assets/stylesheets/jquery.dataTables/datatables.min.css +++ /dev/null @@ -1,18 +0,0 @@ -/* - * This combined file was created by the DataTables downloader builder: - * https://datatables.net/download - * - * To rebuild or modify this file with the latest versions of the included - * software please visit: - * https://datatables.net/download/#ju/dt-1.10.18/r-2.2.2 - * - * Included libraries: - * DataTables 1.10.18, Responsive 2.2.2 - */ - -table.dataTable{width:100%;margin:0 auto;clear:both;border-collapse:separate;border-spacing:0}table.dataTable thead th,table.dataTable tfoot th{font-weight:bold}table.dataTable thead th,table.dataTable thead td{padding:10px 18px}table.dataTable thead th:active,table.dataTable thead td:active{outline:none}table.dataTable tfoot th,table.dataTable tfoot td{padding:10px 18px 6px 18px}table.dataTable tbody tr{background-color:#ffffff}table.dataTable tbody tr.selected{background-color:#B0BED9}table.dataTable tbody th,table.dataTable tbody td{padding:8px 10px}table.dataTable.row-border tbody th,table.dataTable.row-border tbody td,table.dataTable.display tbody th,table.dataTable.display tbody td{border-top:1px solid #ddd}table.dataTable.row-border tbody tr:first-child th,table.dataTable.row-border tbody tr:first-child td,table.dataTable.display tbody tr:first-child th,table.dataTable.display tbody tr:first-child td{border-top:none}table.dataTable.cell-border tbody th,table.dataTable.cell-border tbody td{border-top:1px solid #ddd;border-right:1px solid #ddd}table.dataTable.cell-border tbody tr th:first-child,table.dataTable.cell-border tbody tr td:first-child{border-left:1px solid #ddd}table.dataTable.cell-border tbody tr:first-child th,table.dataTable.cell-border tbody tr:first-child td{border-top:none}table.dataTable.stripe tbody tr.odd,table.dataTable.display tbody tr.odd{background-color:#f9f9f9}table.dataTable.stripe tbody tr.odd.selected,table.dataTable.display tbody tr.odd.selected{background-color:#acbad4}table.dataTable.hover tbody tr:hover,table.dataTable.display tbody tr:hover{background-color:#f6f6f6}table.dataTable.hover tbody tr:hover.selected,table.dataTable.display tbody tr:hover.selected{background-color:#aab7d1}table.dataTable.order-column tbody tr>.sorting_1,table.dataTable.order-column tbody tr>.sorting_2,table.dataTable.order-column tbody tr>.sorting_3,table.dataTable.display tbody tr>.sorting_1,table.dataTable.display tbody tr>.sorting_2,table.dataTable.display tbody tr>.sorting_3{background-color:#fafafa}table.dataTable.order-column tbody tr.selected>.sorting_1,table.dataTable.order-column tbody tr.selected>.sorting_2,table.dataTable.order-column tbody tr.selected>.sorting_3,table.dataTable.display tbody tr.selected>.sorting_1,table.dataTable.display tbody tr.selected>.sorting_2,table.dataTable.display tbody tr.selected>.sorting_3{background-color:#acbad5}table.dataTable.display tbody tr.odd>.sorting_1,table.dataTable.order-column.stripe tbody tr.odd>.sorting_1{background-color:#f1f1f1}table.dataTable.display tbody tr.odd>.sorting_2,table.dataTable.order-column.stripe tbody tr.odd>.sorting_2{background-color:#f3f3f3}table.dataTable.display tbody tr.odd>.sorting_3,table.dataTable.order-column.stripe tbody tr.odd>.sorting_3{background-color:whitesmoke}table.dataTable.display tbody tr.odd.selected>.sorting_1,table.dataTable.order-column.stripe tbody tr.odd.selected>.sorting_1{background-color:#a6b4cd}table.dataTable.display tbody tr.odd.selected>.sorting_2,table.dataTable.order-column.stripe tbody tr.odd.selected>.sorting_2{background-color:#a8b5cf}table.dataTable.display tbody tr.odd.selected>.sorting_3,table.dataTable.order-column.stripe tbody tr.odd.selected>.sorting_3{background-color:#a9b7d1}table.dataTable.display tbody tr.even>.sorting_1,table.dataTable.order-column.stripe tbody tr.even>.sorting_1{background-color:#fafafa}table.dataTable.display tbody tr.even>.sorting_2,table.dataTable.order-column.stripe tbody tr.even>.sorting_2{background-color:#fcfcfc}table.dataTable.display tbody tr.even>.sorting_3,table.dataTable.order-column.stripe tbody tr.even>.sorting_3{background-color:#fefefe}table.dataTable.display tbody tr.even.selected>.sorting_1,table.dataTable.order-column.stripe tbody tr.even.selected>.sorting_1{background-color:#acbad5}table.dataTable.display tbody tr.even.selected>.sorting_2,table.dataTable.order-column.stripe tbody tr.even.selected>.sorting_2{background-color:#aebcd6}table.dataTable.display tbody tr.even.selected>.sorting_3,table.dataTable.order-column.stripe tbody tr.even.selected>.sorting_3{background-color:#afbdd8}table.dataTable.display tbody tr:hover>.sorting_1,table.dataTable.order-column.hover tbody tr:hover>.sorting_1{background-color:#eaeaea}table.dataTable.display tbody tr:hover>.sorting_2,table.dataTable.order-column.hover tbody tr:hover>.sorting_2{background-color:#ececec}table.dataTable.display tbody tr:hover>.sorting_3,table.dataTable.order-column.hover tbody tr:hover>.sorting_3{background-color:#efefef}table.dataTable.display tbody tr:hover.selected>.sorting_1,table.dataTable.order-column.hover tbody tr:hover.selected>.sorting_1{background-color:#a2aec7}table.dataTable.display tbody tr:hover.selected>.sorting_2,table.dataTable.order-column.hover tbody tr:hover.selected>.sorting_2{background-color:#a3b0c9}table.dataTable.display tbody tr:hover.selected>.sorting_3,table.dataTable.order-column.hover tbody tr:hover.selected>.sorting_3{background-color:#a5b2cb}table.dataTable.no-footer{border-bottom:1px solid #111}table.dataTable.nowrap th,table.dataTable.nowrap td{white-space:nowrap}table.dataTable.compact thead th,table.dataTable.compact thead td{padding:4px 17px 4px 4px}table.dataTable.compact tfoot th,table.dataTable.compact tfoot td{padding:4px}table.dataTable.compact tbody th,table.dataTable.compact tbody td{padding:4px}table.dataTable th.dt-left,table.dataTable td.dt-left{text-align:left}table.dataTable th.dt-center,table.dataTable td.dt-center,table.dataTable td.dataTables_empty{text-align:center}table.dataTable th.dt-right,table.dataTable td.dt-right{text-align:right}table.dataTable th.dt-justify,table.dataTable td.dt-justify{text-align:justify}table.dataTable th.dt-nowrap,table.dataTable td.dt-nowrap{white-space:nowrap}table.dataTable thead th.dt-head-left,table.dataTable thead td.dt-head-left,table.dataTable tfoot th.dt-head-left,table.dataTable tfoot td.dt-head-left{text-align:left}table.dataTable thead th.dt-head-center,table.dataTable thead td.dt-head-center,table.dataTable tfoot th.dt-head-center,table.dataTable tfoot td.dt-head-center{text-align:center}table.dataTable thead th.dt-head-right,table.dataTable thead td.dt-head-right,table.dataTable tfoot th.dt-head-right,table.dataTable tfoot td.dt-head-right{text-align:right}table.dataTable thead th.dt-head-justify,table.dataTable thead td.dt-head-justify,table.dataTable tfoot th.dt-head-justify,table.dataTable tfoot td.dt-head-justify{text-align:justify}table.dataTable thead th.dt-head-nowrap,table.dataTable thead td.dt-head-nowrap,table.dataTable tfoot th.dt-head-nowrap,table.dataTable tfoot td.dt-head-nowrap{white-space:nowrap}table.dataTable tbody th.dt-body-left,table.dataTable tbody td.dt-body-left{text-align:left}table.dataTable tbody th.dt-body-center,table.dataTable tbody td.dt-body-center{text-align:center}table.dataTable tbody th.dt-body-right,table.dataTable tbody td.dt-body-right{text-align:right}table.dataTable tbody th.dt-body-justify,table.dataTable tbody td.dt-body-justify{text-align:justify}table.dataTable tbody th.dt-body-nowrap,table.dataTable tbody td.dt-body-nowrap{white-space:nowrap}table.dataTable,table.dataTable th,table.dataTable td{box-sizing:content-box}.dataTables_wrapper{position:relative;clear:both;*zoom:1;zoom:1}.dataTables_wrapper .dataTables_length{float:left}.dataTables_wrapper .dataTables_filter{float:right;text-align:right}.dataTables_wrapper .dataTables_filter input{margin-left:0.5em}.dataTables_wrapper .dataTables_info{clear:both;float:left;padding-top:0.755em}.dataTables_wrapper .dataTables_paginate{float:right;text-align:right;padding-top:0.25em}.dataTables_wrapper .dataTables_paginate .paginate_button{box-sizing:border-box;display:inline-block;min-width:1.5em;padding:0.5em 1em;margin-left:2px;text-align:center;text-decoration:none !important;cursor:pointer;*cursor:hand;color:#333 !important;border:1px solid transparent;border-radius:2px}.dataTables_wrapper .dataTables_paginate .paginate_button.current,.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover{color:#333 !important;border:1px solid #979797;background-color:white;background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #fff), color-stop(100%, #dcdcdc));background:-webkit-linear-gradient(top, #fff 0%, #dcdcdc 100%);background:-moz-linear-gradient(top, #fff 0%, #dcdcdc 100%);background:-ms-linear-gradient(top, #fff 0%, #dcdcdc 100%);background:-o-linear-gradient(top, #fff 0%, #dcdcdc 100%);background:linear-gradient(to bottom, #fff 0%, #dcdcdc 100%)}.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover,.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:active{cursor:default;color:#666 !important;border:1px solid transparent;background:transparent;box-shadow:none}.dataTables_wrapper .dataTables_paginate .paginate_button:hover{color:white !important;border:1px solid #111;background-color:#585858;background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #585858), color-stop(100%, #111));background:-webkit-linear-gradient(top, #585858 0%, #111 100%);background:-moz-linear-gradient(top, #585858 0%, #111 100%);background:-ms-linear-gradient(top, #585858 0%, #111 100%);background:-o-linear-gradient(top, #585858 0%, #111 100%);background:linear-gradient(to bottom, #585858 0%, #111 100%)}.dataTables_wrapper .dataTables_paginate .paginate_button:active{outline:none;background-color:#2b2b2b;background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #2b2b2b), color-stop(100%, #0c0c0c));background:-webkit-linear-gradient(top, #2b2b2b 0%, #0c0c0c 100%);background:-moz-linear-gradient(top, #2b2b2b 0%, #0c0c0c 100%);background:-ms-linear-gradient(top, #2b2b2b 0%, #0c0c0c 100%);background:-o-linear-gradient(top, #2b2b2b 0%, #0c0c0c 100%);background:linear-gradient(to bottom, #2b2b2b 0%, #0c0c0c 100%);box-shadow:inset 0 0 3px #111}.dataTables_wrapper .dataTables_paginate .ellipsis{padding:0 1em}.dataTables_wrapper .dataTables_processing{position:absolute;top:50%;left:50%;width:100%;height:40px;margin-left:-50%;margin-top:-25px;padding-top:20px;text-align:center;font-size:1.2em;background-color:white;background:-webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255,255,255,0)), color-stop(25%, rgba(255,255,255,0.9)), color-stop(75%, rgba(255,255,255,0.9)), color-stop(100%, rgba(255,255,255,0)));background:-webkit-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%);background:-moz-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%);background:-ms-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%);background:-o-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%);background:linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%)}.dataTables_wrapper .dataTables_length,.dataTables_wrapper .dataTables_filter,.dataTables_wrapper .dataTables_info,.dataTables_wrapper .dataTables_processing,.dataTables_wrapper .dataTables_paginate{color:#333}.dataTables_wrapper .dataTables_scroll{clear:both}.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody{*margin-top:-1px;-webkit-overflow-scrolling:touch}.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>thead>tr>th,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>thead>tr>td,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>tbody>tr>th,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>tbody>tr>td{vertical-align:middle}.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>thead>tr>th>div.dataTables_sizing,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>thead>tr>td>div.dataTables_sizing,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>tbody>tr>th>div.dataTables_sizing,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>tbody>tr>td>div.dataTables_sizing{height:0;overflow:hidden;margin:0 !important;padding:0 !important}.dataTables_wrapper.no-footer .dataTables_scrollBody{border-bottom:1px solid #111}.dataTables_wrapper.no-footer div.dataTables_scrollHead table.dataTable,.dataTables_wrapper.no-footer div.dataTables_scrollBody>table{border-bottom:none}.dataTables_wrapper:after{visibility:hidden;display:block;content:"";clear:both;height:0}@media screen and (max-width: 767px){.dataTables_wrapper .dataTables_info,.dataTables_wrapper .dataTables_paginate{float:none;text-align:center}.dataTables_wrapper .dataTables_paginate{margin-top:0.5em}}@media screen and (max-width: 640px){.dataTables_wrapper .dataTables_length,.dataTables_wrapper .dataTables_filter{float:none;text-align:center}.dataTables_wrapper .dataTables_filter{margin-top:0.5em}}table.dataTable thead th div.DataTables_sort_wrapper{position:relative}table.dataTable thead th div.DataTables_sort_wrapper span{position:absolute;top:50%;margin-top:-8px;right:-18px}table.dataTable thead th.ui-state-default,table.dataTable tfoot th.ui-state-default{border-left-width:0}table.dataTable thead th.ui-state-default:first-child,table.dataTable tfoot th.ui-state-default:first-child{border-left-width:1px}.dataTables_wrapper .dataTables_paginate .fg-button{box-sizing:border-box;display:inline-block;min-width:1.5em;padding:0.5em;margin-left:2px;text-align:center;text-decoration:none !important;cursor:pointer;*cursor:hand;border:1px solid transparent}.dataTables_wrapper .dataTables_paginate .fg-button:active{outline:none}.dataTables_wrapper .dataTables_paginate .fg-button:first-child{border-top-left-radius:3px;border-bottom-left-radius:3px}.dataTables_wrapper .dataTables_paginate .fg-button:last-child{border-top-right-radius:3px;border-bottom-right-radius:3px}.dataTables_wrapper .ui-widget-header{font-weight:normal}.dataTables_wrapper .ui-toolbar{padding:8px}.dataTables_wrapper.no-footer .dataTables_scrollBody{border-bottom:none}.dataTables_wrapper .dataTables_length,.dataTables_wrapper .dataTables_filter,.dataTables_wrapper .dataTables_info,.dataTables_wrapper .dataTables_processing,.dataTables_wrapper .dataTables_paginate{color:inherit} - - -table.dataTable.dtr-inline.collapsed>tbody>tr>td.child,table.dataTable.dtr-inline.collapsed>tbody>tr>th.child,table.dataTable.dtr-inline.collapsed>tbody>tr>td.dataTables_empty{cursor:default !important}table.dataTable.dtr-inline.collapsed>tbody>tr>td.child:before,table.dataTable.dtr-inline.collapsed>tbody>tr>th.child:before,table.dataTable.dtr-inline.collapsed>tbody>tr>td.dataTables_empty:before{display:none !important}table.dataTable.dtr-inline.collapsed>tbody>tr[role="row"]>td:first-child,table.dataTable.dtr-inline.collapsed>tbody>tr[role="row"]>th:first-child{position:relative;padding-left:30px;cursor:pointer}table.dataTable.dtr-inline.collapsed>tbody>tr[role="row"]>td:first-child:before,table.dataTable.dtr-inline.collapsed>tbody>tr[role="row"]>th:first-child:before{top:9px;left:4px;height:14px;width:14px;display:block;position:absolute;color:white;border:2px solid white;border-radius:14px;box-shadow:0 0 3px #444;box-sizing:content-box;text-align:center;text-indent:0 !important;font-family:'Courier New', Courier, monospace;line-height:14px;content:'+';background-color:#31b131}table.dataTable.dtr-inline.collapsed>tbody>tr.parent>td:first-child:before,table.dataTable.dtr-inline.collapsed>tbody>tr.parent>th:first-child:before{content:'-';background-color:#d33333}table.dataTable.dtr-inline.collapsed.compact>tbody>tr>td:first-child,table.dataTable.dtr-inline.collapsed.compact>tbody>tr>th:first-child{padding-left:27px}table.dataTable.dtr-inline.collapsed.compact>tbody>tr>td:first-child:before,table.dataTable.dtr-inline.collapsed.compact>tbody>tr>th:first-child:before{top:5px;left:4px;height:14px;width:14px;border-radius:14px;line-height:14px;text-indent:3px}table.dataTable.dtr-column>tbody>tr>td.control,table.dataTable.dtr-column>tbody>tr>th.control{position:relative;cursor:pointer}table.dataTable.dtr-column>tbody>tr>td.control:before,table.dataTable.dtr-column>tbody>tr>th.control:before{top:50%;left:50%;height:16px;width:16px;margin-top:-10px;margin-left:-10px;display:block;position:absolute;color:white;border:2px solid white;border-radius:14px;box-shadow:0 0 3px #444;box-sizing:content-box;text-align:center;text-indent:0 !important;font-family:'Courier New', Courier, monospace;line-height:14px;content:'+';background-color:#31b131}table.dataTable.dtr-column>tbody>tr.parent td.control:before,table.dataTable.dtr-column>tbody>tr.parent th.control:before{content:'-';background-color:#d33333}table.dataTable>tbody>tr.child{padding:0.5em 1em}table.dataTable>tbody>tr.child:hover{background:transparent !important}table.dataTable>tbody>tr.child ul.dtr-details{display:inline-block;list-style-type:none;margin:0;padding:0}table.dataTable>tbody>tr.child ul.dtr-details>li{border-bottom:1px solid #efefef;padding:0.5em 0}table.dataTable>tbody>tr.child ul.dtr-details>li:first-child{padding-top:0}table.dataTable>tbody>tr.child ul.dtr-details>li:last-child{border-bottom:none}table.dataTable>tbody>tr.child span.dtr-title{display:inline-block;min-width:75px;font-weight:bold}div.dtr-modal{position:fixed;box-sizing:border-box;top:0;left:0;height:100%;width:100%;z-index:100;padding:10em 1em}div.dtr-modal div.dtr-modal-display{position:absolute;top:0;left:0;bottom:0;right:0;width:50%;height:50%;overflow:auto;margin:auto;z-index:102;overflow:auto;background-color:#f5f5f7;border:1px solid black;border-radius:0.5em;box-shadow:0 12px 30px rgba(0,0,0,0.6)}div.dtr-modal div.dtr-modal-content{position:relative;padding:1em}div.dtr-modal div.dtr-modal-close{position:absolute;top:6px;right:6px;width:22px;height:22px;border:1px solid #eaeaea;background-color:#f9f9f9;text-align:center;border-radius:3px;cursor:pointer;z-index:12}div.dtr-modal div.dtr-modal-close:hover{background-color:#eaeaea}div.dtr-modal div.dtr-modal-background{position:fixed;top:0;left:0;right:0;bottom:0;z-index:101;background:rgba(0,0,0,0.6)}@media screen and (max-width: 767px){div.dtr-modal div.dtr-modal-display{width:95%}} - - diff --git a/assets/stylesheets/jquery.dataTables/images/sort_asc.png b/assets/stylesheets/jquery.dataTables/images/sort_asc.png deleted file mode 100644 index e1ba61a8055fcb18273f2468d335572204667b1f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 160 zcmeAS@N?(olHy`uVBq!ia0vp^!XV7S1|*9D%+3I*bWaz@5R22v2@;zYta_*?F5u6Q zWR@in#&u+WgT?Hi<}D3B3}GOXuX|8Oj3tosHiJ3*4TN zC7>_x-r1O=t(?KoTC+`+>7&2GzdqLHBg&F)2Q?&EGZ+}|Rpsc~9`m>jw35No)z4*} HQ$iB}HK{Sd diff --git a/assets/stylesheets/jquery.dataTables/images/sort_asc_disabled.png b/assets/stylesheets/jquery.dataTables/images/sort_asc_disabled.png deleted file mode 100644 index fb11dfe24a6c564cb7ddf8bc96703ebb121df1e7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 148 zcmeAS@N?(olHy`uVBq!ia0vp^!XV7S0wixl{&NRX(Vi}jAsXkC6BcOhI9!^3NY?Do zDX;f`c1`y6n0RgO@$!H7chZT&|Jn0dmaqO^XNm-CGtk!Ur<_=Jws3;%W$<+Mb6Mw<&;$T1GdZXL diff --git a/assets/stylesheets/jquery.dataTables/images/sort_both.png b/assets/stylesheets/jquery.dataTables/images/sort_both.png deleted file mode 100644 index af5bc7c5a10b9d6d57cb641aeec752428a07f0ca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 201 zcmeAS@N?(olHy`uVBq!ia0vp^!XV7S0wixl{&NRX6FglULp08Bycxyy87-Q;~nRxO8@-UU*I^KVWyN+&SiMHu5xDOu|HNvwzODfTdXjhVyNu1 z#7^XbGKZ7LW3XeONb$RKLeE*WhqbYpIXPIqK@r4)v+qN8um%99%MPpS9d#7Ed7SL@Bp00i_>zopr0H-Zb Aj{pDw diff --git a/assets/stylesheets/jquery.dataTables/images/sort_desc.png b/assets/stylesheets/jquery.dataTables/images/sort_desc.png deleted file mode 100644 index 0e156deb5f61d18f9e2ec5da4f6a8c94a5b4fb41..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 158 zcmeAS@N?(olHy`uVBq!ia0vp^!XV7S1|*9D%+3I*R8JSj5R22v2@yo z(czD9$NuDl3Ljm9c#_#4$vXUz=f1~&WY3aa=h!;z7fOEN>ySP9QA=6C-^Dmb&tuM= z4Z&=WZU;2WF>e%GI&mWJk^K!jrbro{W;-I>FeCfLGJl3}+Z^2)3Kw?+EoAU?^>bP0 Hl+XkKC^j|Q{b@g3TV7E(Grjn^aLC2o)_ptHrtUEoT$S@q)~)7U@V;W{6)!%@ u>N?4t-1qslpJw9!O?PJ&w0Cby 'dmsf', :action => 'lock', :as => 'lock_dmsf' get '/projects/:id/dmsf/unlock', :controller => 'dmsf', :action => 'unlock', :as => 'unlock_dmsf' get '/projects/:id/dmsf/', :controller => 'dmsf', :action => 'show', :as => 'dmsf_folder' - get '/projects/:id/dmsf/rlf', controller: 'dmsf', action: 'switch_rlf', as: 'switch_rlf_dmsf' get '/projects/:id/dmsf/new', :controller => 'dmsf', :action => 'new', :as => 'new_dmsf' get '/projects/:id/dmsf/edit', :controller => 'dmsf', :action => 'edit', :as => 'edit_dmsf' get '/projects/:id/dmsf/edit/root', :controller => 'dmsf', :action => 'edit_root', :as => 'edit_root_dmsf' diff --git a/init.rb b/init.rb index 9efb48f6..076fcdb6 100644 --- a/init.rb +++ b/init.rb @@ -39,10 +39,8 @@ Redmine::Plugin.register :redmine_dmsf do settings partial: 'settings/dmsf_settings', default: { - 'dmsf_max_file_upload' => 0, 'dmsf_max_file_download' => 0, 'dmsf_max_email_filesize' => 0, - 'dmsf_max_ajax_upload_filesize' => 100, 'dmsf_storage_directory' => 'files/dmsf', 'dmsf_index_database' => File.expand_path('dmsf_index', Rails.root), 'dmsf_stemming_lang' => 'english',