caboose-cms 0.5.221 → 0.5.222

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +8 -8
  2. data/app/assets/javascripts/caboose/admin_media_index.js +401 -0
  3. data/app/assets/javascripts/caboose/jquery-ui.drag-multiple.min.js +4 -0
  4. data/app/assets/javascripts/plupload/Moxie.swf +0 -0
  5. data/app/assets/javascripts/plupload/Moxie.xap +0 -0
  6. data/app/assets/javascripts/plupload/i18n/ar.js +2 -0
  7. data/app/assets/javascripts/plupload/i18n/az.js +2 -0
  8. data/app/assets/javascripts/plupload/i18n/bg.js +2 -0
  9. data/app/assets/javascripts/plupload/i18n/bs.js +2 -0
  10. data/app/assets/javascripts/plupload/i18n/ca.js +2 -0
  11. data/app/assets/javascripts/plupload/i18n/cs.js +2 -0
  12. data/app/assets/javascripts/plupload/i18n/cy.js +2 -0
  13. data/app/assets/javascripts/plupload/i18n/da.js +2 -0
  14. data/app/assets/javascripts/plupload/i18n/de.js +2 -0
  15. data/app/assets/javascripts/plupload/i18n/el.js +2 -0
  16. data/app/assets/javascripts/plupload/i18n/en.js +2 -0
  17. data/app/assets/javascripts/plupload/i18n/es.js +2 -0
  18. data/app/assets/javascripts/plupload/i18n/et.js +2 -0
  19. data/app/assets/javascripts/plupload/i18n/fa.js +2 -0
  20. data/app/assets/javascripts/plupload/i18n/fi.js +2 -0
  21. data/app/assets/javascripts/plupload/i18n/fr.js +2 -0
  22. data/app/assets/javascripts/plupload/i18n/he.js +2 -0
  23. data/app/assets/javascripts/plupload/i18n/hr.js +2 -0
  24. data/app/assets/javascripts/plupload/i18n/hu.js +2 -0
  25. data/app/assets/javascripts/plupload/i18n/hy.js +2 -0
  26. data/app/assets/javascripts/plupload/i18n/id.js +2 -0
  27. data/app/assets/javascripts/plupload/i18n/it.js +2 -0
  28. data/app/assets/javascripts/plupload/i18n/ja.js +2 -0
  29. data/app/assets/javascripts/plupload/i18n/ka.js +2 -0
  30. data/app/assets/javascripts/plupload/i18n/kk.js +2 -0
  31. data/app/assets/javascripts/plupload/i18n/km.js +2 -0
  32. data/app/assets/javascripts/plupload/i18n/ko.js +2 -0
  33. data/app/assets/javascripts/plupload/i18n/ku_IQ.js +2 -0
  34. data/app/assets/javascripts/plupload/i18n/lt.js +2 -0
  35. data/app/assets/javascripts/plupload/i18n/lv.js +2 -0
  36. data/app/assets/javascripts/plupload/i18n/mn.js +2 -0
  37. data/app/assets/javascripts/plupload/i18n/ms.js +2 -0
  38. data/app/assets/javascripts/plupload/i18n/nl.js +2 -0
  39. data/app/assets/javascripts/plupload/i18n/pl.js +2 -0
  40. data/app/assets/javascripts/plupload/i18n/pt_BR.js +2 -0
  41. data/app/assets/javascripts/plupload/i18n/ro.js +2 -0
  42. data/app/assets/javascripts/plupload/i18n/ru.js +2 -0
  43. data/app/assets/javascripts/plupload/i18n/sk.js +2 -0
  44. data/app/assets/javascripts/plupload/i18n/sq.js +2 -0
  45. data/app/assets/javascripts/plupload/i18n/sr.js +2 -0
  46. data/app/assets/javascripts/plupload/i18n/sr_RS.js +2 -0
  47. data/app/assets/javascripts/plupload/i18n/sv.js +2 -0
  48. data/app/assets/javascripts/plupload/i18n/th_TH.js +2 -0
  49. data/app/assets/javascripts/plupload/i18n/tr.js +2 -0
  50. data/app/assets/javascripts/plupload/i18n/uk_UA.js +2 -0
  51. data/app/assets/javascripts/plupload/i18n/vi.js +2 -0
  52. data/app/assets/javascripts/plupload/i18n/zh_CN.js +2 -0
  53. data/app/assets/javascripts/plupload/i18n/zh_TW.js +2 -0
  54. data/app/assets/javascripts/plupload/jquery.plupload.queue/css/jquery.plupload.queue.css +185 -0
  55. data/app/assets/javascripts/plupload/jquery.plupload.queue/img/backgrounds.gif +0 -0
  56. data/app/assets/javascripts/plupload/jquery.plupload.queue/img/buttons-disabled.png +0 -0
  57. data/app/assets/javascripts/plupload/jquery.plupload.queue/img/buttons.png +0 -0
  58. data/app/assets/javascripts/plupload/jquery.plupload.queue/img/delete.gif +0 -0
  59. data/app/assets/javascripts/plupload/jquery.plupload.queue/img/done.gif +0 -0
  60. data/app/assets/javascripts/plupload/jquery.plupload.queue/img/error.gif +0 -0
  61. data/app/assets/javascripts/plupload/jquery.plupload.queue/img/throbber.gif +0 -0
  62. data/app/assets/javascripts/plupload/jquery.plupload.queue/img/transp50.png +0 -0
  63. data/app/assets/javascripts/plupload/jquery.plupload.queue/jquery.plupload.queue.js +428 -0
  64. data/app/assets/javascripts/plupload/jquery.plupload.queue/jquery.plupload.queue.min.js +1 -0
  65. data/app/assets/javascripts/plupload/jquery.ui.plupload/css/jquery.ui.plupload.css +370 -0
  66. data/app/assets/javascripts/plupload/jquery.ui.plupload/img/loading.gif +0 -0
  67. data/app/assets/javascripts/plupload/jquery.ui.plupload/img/plupload.png +0 -0
  68. data/app/assets/javascripts/plupload/jquery.ui.plupload/jquery.ui.plupload.js +1323 -0
  69. data/app/assets/javascripts/plupload/jquery.ui.plupload/jquery.ui.plupload.min.js +1 -0
  70. data/app/assets/javascripts/plupload/moxie.js +10726 -0
  71. data/app/assets/javascripts/plupload/moxie.min.js +15 -0
  72. data/app/assets/javascripts/plupload/plupload.dev.js +2315 -0
  73. data/app/assets/javascripts/plupload/plupload.full.min.js +28 -0
  74. data/app/assets/javascripts/plupload/plupload.min.js +13 -0
  75. data/app/assets/stylesheets/caboose/admin_media_index.css.scss +115 -0
  76. data/app/controllers/caboose/application_controller.rb +1 -1
  77. data/app/controllers/caboose/cart_controller.rb +1 -1
  78. data/app/controllers/caboose/media_categories_controller.rb +44 -8
  79. data/app/controllers/caboose/media_controller.rb +116 -0
  80. data/app/controllers/caboose/posts_controller.rb +1 -1
  81. data/app/controllers/caboose/sns_controller.rb +60 -0
  82. data/app/models/caboose/block.rb +4 -2
  83. data/app/models/caboose/media.rb +94 -0
  84. data/app/models/caboose/media_category.rb +55 -15
  85. data/app/models/caboose/schema.rb +6 -9
  86. data/app/models/caboose/tax_calculator.rb +1 -1
  87. data/app/views/caboose/{images → media}/admin_edit.html.erb +0 -0
  88. data/app/views/caboose/media/admin_index.html.erb +49 -0
  89. data/app/views/caboose/posts/admin_edit_general.html.erb +3 -1
  90. data/config/routes.rb +30 -17
  91. data/lib/caboose.rb +6 -0
  92. data/lib/caboose/version.rb +1 -1
  93. metadata +81 -11
  94. data/app/assets/javascripts/caboose/admin_images_index.js +0 -171
  95. data/app/assets/stylesheets/caboose/admin_images_index.css.scss +0 -53
  96. data/app/controllers/caboose/images_controller.rb +0 -149
  97. data/app/models/caboose/media_file.rb +0 -18
  98. data/app/models/caboose/media_image.rb +0 -43
  99. data/app/views/caboose/images/admin_index.html.erb +0 -59
  100. data/app/views/caboose/images/admin_new.html.erb +0 -80
  101. data/app/views/caboose/images/admin_s3_result.html.erb +0 -3
@@ -0,0 +1,15 @@
1
+ /**
2
+ * mOxie - multi-runtime File API & XMLHttpRequest L2 Polyfill
3
+ * v1.2.2
4
+ *
5
+ * Copyright 2013, Moxiecode Systems AB
6
+ * Released under GPL License.
7
+ *
8
+ * License: http://www.plupload.com/license
9
+ * Contributing: http://www.plupload.com/contributing
10
+ *
11
+ * Date: 2015-05-11
12
+ */
13
+ !function(e,t){"use strict";function n(e,t){for(var n,i=[],r=0;r<e.length;++r){if(n=s[e[r]]||o(e[r]),!n)throw"module definition dependecy not found: "+e[r];i.push(n)}t.apply(null,i)}function i(e,i,r){if("string"!=typeof e)throw"invalid module definition, module id must be defined and be a string";if(i===t)throw"invalid module definition, dependencies must be specified";if(r===t)throw"invalid module definition, definition function must be specified";n(i,function(){s[e]=r.apply(null,arguments)})}function r(e){return!!s[e]}function o(t){for(var n=e,i=t.split(/[.\/]/),r=0;r<i.length;++r){if(!n[i[r]])return;n=n[i[r]]}return n}function a(n){for(var i=0;i<n.length;i++){for(var r=e,o=n[i],a=o.split(/[.\/]/),u=0;u<a.length-1;++u)r[a[u]]===t&&(r[a[u]]={}),r=r[a[u]];r[a[a.length-1]]=s[o]}}var s={},u="moxie/core/utils/Basic",c="moxie/core/I18n",l="moxie/core/utils/Mime",d="moxie/core/utils/Env",f="moxie/core/utils/Dom",h="moxie/core/Exceptions",p="moxie/core/EventTarget",m="moxie/core/utils/Encode",g="moxie/runtime/Runtime",v="moxie/runtime/RuntimeClient",y="moxie/file/Blob",w="moxie/file/File",E="moxie/file/FileInput",_="moxie/file/FileDrop",x="moxie/runtime/RuntimeTarget",b="moxie/file/FileReader",R="moxie/core/utils/Url",T="moxie/file/FileReaderSync",A="moxie/xhr/FormData",S="moxie/xhr/XMLHttpRequest",O="moxie/runtime/Transporter",I="moxie/image/Image",D="moxie/runtime/html5/Runtime",N="moxie/runtime/html5/file/Blob",L="moxie/core/utils/Events",M="moxie/runtime/html5/file/FileInput",C="moxie/runtime/html5/file/FileDrop",F="moxie/runtime/html5/file/FileReader",H="moxie/runtime/html5/xhr/XMLHttpRequest",P="moxie/runtime/html5/utils/BinaryReader",k="moxie/runtime/html5/image/JPEGHeaders",U="moxie/runtime/html5/image/ExifParser",B="moxie/runtime/html5/image/JPEG",z="moxie/runtime/html5/image/PNG",G="moxie/runtime/html5/image/ImageInfo",q="moxie/runtime/html5/image/MegaPixel",X="moxie/runtime/html5/image/Image",j="moxie/runtime/flash/Runtime",V="moxie/runtime/flash/file/Blob",W="moxie/runtime/flash/file/FileInput",Y="moxie/runtime/flash/file/FileReader",$="moxie/runtime/flash/file/FileReaderSync",J="moxie/runtime/flash/xhr/XMLHttpRequest",Z="moxie/runtime/flash/runtime/Transporter",K="moxie/runtime/flash/image/Image",Q="moxie/runtime/silverlight/Runtime",ee="moxie/runtime/silverlight/file/Blob",te="moxie/runtime/silverlight/file/FileInput",ne="moxie/runtime/silverlight/file/FileDrop",ie="moxie/runtime/silverlight/file/FileReader",re="moxie/runtime/silverlight/file/FileReaderSync",oe="moxie/runtime/silverlight/xhr/XMLHttpRequest",ae="moxie/runtime/silverlight/runtime/Transporter",se="moxie/runtime/silverlight/image/Image",ue="moxie/runtime/html4/Runtime",ce="moxie/runtime/html4/file/FileInput",le="moxie/runtime/html4/file/FileReader",de="moxie/runtime/html4/xhr/XMLHttpRequest",fe="moxie/runtime/html4/image/Image";i(u,[],function(){var e=function(e){var t;return e===t?"undefined":null===e?"null":e.nodeType?"node":{}.toString.call(e).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()},t=function(i){var r;return n(arguments,function(o,s){s>0&&n(o,function(n,o){n!==r&&(e(i[o])===e(n)&&~a(e(n),["array","object"])?t(i[o],n):i[o]=n)})}),i},n=function(e,t){var n,i,r,o;if(e){try{n=e.length}catch(a){n=o}if(n===o){for(i in e)if(e.hasOwnProperty(i)&&t(e[i],i)===!1)return}else for(r=0;n>r;r++)if(t(e[r],r)===!1)return}},i=function(t){var n;if(!t||"object"!==e(t))return!0;for(n in t)return!1;return!0},r=function(t,n){function i(r){"function"===e(t[r])&&t[r](function(e){++r<o&&!e?i(r):n(e)})}var r=0,o=t.length;"function"!==e(n)&&(n=function(){}),t&&t.length||n(),i(r)},o=function(e,t){var i=0,r=e.length,o=new Array(r);n(e,function(e,n){e(function(e){if(e)return t(e);var a=[].slice.call(arguments);a.shift(),o[n]=a,i++,i===r&&(o.unshift(null),t.apply(this,o))})})},a=function(e,t){if(t){if(Array.prototype.indexOf)return Array.prototype.indexOf.call(t,e);for(var n=0,i=t.length;i>n;n++)if(t[n]===e)return n}return-1},s=function(t,n){var i=[];"array"!==e(t)&&(t=[t]),"array"!==e(n)&&(n=[n]);for(var r in t)-1===a(t[r],n)&&i.push(t[r]);return i.length?i:!1},u=function(e,t){var i=[];return n(e,function(e){-1!==a(e,t)&&i.push(e)}),i.length?i:null},c=function(e){var t,n=[];for(t=0;t<e.length;t++)n[t]=e[t];return n},l=function(){var e=0;return function(t){var n=(new Date).getTime().toString(32),i;for(i=0;5>i;i++)n+=Math.floor(65535*Math.random()).toString(32);return(t||"o_")+n+(e++).toString(32)}}(),d=function(e){return e?String.prototype.trim?String.prototype.trim.call(e):e.toString().replace(/^\s*/,"").replace(/\s*$/,""):e},f=function(e){if("string"!=typeof e)return e;var t={t:1099511627776,g:1073741824,m:1048576,k:1024},n;return e=/^([0-9]+)([mgk]?)$/.exec(e.toLowerCase().replace(/[^0-9mkg]/g,"")),n=e[2],e=+e[1],t.hasOwnProperty(n)&&(e*=t[n]),e};return{guid:l,typeOf:e,extend:t,each:n,isEmptyObj:i,inSeries:r,inParallel:o,inArray:a,arrayDiff:s,arrayIntersect:u,toArray:c,trim:d,parseSizeStr:f}}),i(c,[u],function(e){var t={};return{addI18n:function(n){return e.extend(t,n)},translate:function(e){return t[e]||e},_:function(e){return this.translate(e)},sprintf:function(t){var n=[].slice.call(arguments,1);return t.replace(/%[a-z]/g,function(){var t=n.shift();return"undefined"!==e.typeOf(t)?t:""})}}}),i(l,[u,c],function(e,t){var n="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,application/vnd.ms-powerpoint,ppt pps pot,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",i={mimes:{},extensions:{},addMimeType:function(e){var t=e.split(/,/),n,i,r;for(n=0;n<t.length;n+=2){for(r=t[n+1].split(/ /),i=0;i<r.length;i++)this.mimes[r[i]]=t[n];this.extensions[t[n]]=r}},extList2mimes:function(t,n){var i=this,r,o,a,s,u=[];for(o=0;o<t.length;o++)for(r=t[o].extensions.split(/\s*,\s*/),a=0;a<r.length;a++){if("*"===r[a])return[];if(s=i.mimes[r[a]])-1===e.inArray(s,u)&&u.push(s);else{if(!n||!/^\w+$/.test(r[a]))return[];u.push("."+r[a])}}return u},mimes2exts:function(t){var n=this,i=[];return e.each(t,function(t){if("*"===t)return i=[],!1;var r=t.match(/^(\w+)\/(\*|\w+)$/);r&&("*"===r[2]?e.each(n.extensions,function(e,t){new RegExp("^"+r[1]+"/").test(t)&&[].push.apply(i,n.extensions[t])}):n.extensions[t]&&[].push.apply(i,n.extensions[t]))}),i},mimes2extList:function(n){var i=[],r=[];return"string"===e.typeOf(n)&&(n=e.trim(n).split(/\s*,\s*/)),r=this.mimes2exts(n),i.push({title:t.translate("Files"),extensions:r.length?r.join(","):"*"}),i.mimes=n,i},getFileExtension:function(e){var t=e&&e.match(/\.([^.]+)$/);return t?t[1].toLowerCase():""},getFileMime:function(e){return this.mimes[this.getFileExtension(e)]||""}};return i.addMimeType(n),i}),i(d,[u],function(e){function t(e,t,n){var i=0,r=0,o=0,a={dev:-6,alpha:-5,a:-5,beta:-4,b:-4,RC:-3,rc:-3,"#":-2,p:1,pl:1},s=function(e){return e=(""+e).replace(/[_\-+]/g,"."),e=e.replace(/([^.\d]+)/g,".$1.").replace(/\.{2,}/g,"."),e.length?e.split("."):[-8]},u=function(e){return e?isNaN(e)?a[e]||-7:parseInt(e,10):0};for(e=s(e),t=s(t),r=Math.max(e.length,t.length),i=0;r>i;i++)if(e[i]!=t[i]){if(e[i]=u(e[i]),t[i]=u(t[i]),e[i]<t[i]){o=-1;break}if(e[i]>t[i]){o=1;break}}if(!n)return o;switch(n){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="",n="?",i="function",r="undefined",o="object",a="major",s="model",u="name",c="type",l="vendor",d="version",f="architecture",h="console",p="mobile",m="tablet",g={has:function(e,t){return-1!==t.toLowerCase().indexOf(e.toLowerCase())},lowerize:function(e){return e.toLowerCase()}},v={rgx:function(){for(var t,n=0,a,s,u,c,l,d,f=arguments;n<f.length;n+=2){var h=f[n],p=f[n+1];if(typeof t===r){t={};for(u in p)c=p[u],typeof c===o?t[c[0]]=e:t[c]=e}for(a=s=0;a<h.length;a++)if(l=h[a].exec(this.getUA())){for(u=0;u<p.length;u++)d=l[++s],c=p[u],typeof c===o&&c.length>0?2==c.length?typeof c[1]==i?t[c[0]]=c[1].call(this,d):t[c[0]]=c[1]:3==c.length?typeof c[1]!==i||c[1].exec&&c[1].test?t[c[0]]=d?d.replace(c[1],c[2]):e:t[c[0]]=d?c[1].call(this,d,c[2]):e:4==c.length&&(t[c[0]]=d?c[3].call(this,d.replace(c[1],c[2])):e):t[c]=d?d:e;break}if(l)break}return t},str:function(t,i){for(var r in i)if(typeof i[r]===o&&i[r].length>0){for(var a=0;a<i[r].length;a++)if(g.has(i[r][a],t))return r===n?e:r}else if(g.has(i[r],t))return r===n?e:r;return t}},y={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"}}}},w={browser:[[/(opera\smini)\/((\d+)?[\w\.-]+)/i,/(opera\s[mobiletab]+).+version\/((\d+)?[\w\.-]+)/i,/(opera).+version\/((\d+)?[\w\.]+)/i,/(opera)[\/\s]+((\d+)?[\w\.]+)/i],[u,d,a],[/\s(opr)\/((\d+)?[\w\.]+)/i],[[u,"Opera"],d,a],[/(kindle)\/((\d+)?[\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?((\d+)?[\w\.]+)*/i,/(avant\s|iemobile|slim|baidu)(?:browser)?[\/\s]?((\d+)?[\w\.]*)/i,/(?:ms|\()(ie)\s((\d+)?[\w\.]+)/i,/(rekonq)((?:\/)[\w\.]+)*/i,/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron)\/((\d+)?[\w\.-]+)/i],[u,d,a],[/(trident).+rv[:\s]((\d+)?[\w\.]+).+like\sgecko/i],[[u,"IE"],d,a],[/(yabrowser)\/((\d+)?[\w\.]+)/i],[[u,"Yandex"],d,a],[/(comodo_dragon)\/((\d+)?[\w\.]+)/i],[[u,/_/g," "],d,a],[/(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?((\d+)?[\w\.]+)/i],[u,d,a],[/(dolfin)\/((\d+)?[\w\.]+)/i],[[u,"Dolphin"],d,a],[/((?:android.+)crmo|crios)\/((\d+)?[\w\.]+)/i],[[u,"Chrome"],d,a],[/((?:android.+))version\/((\d+)?[\w\.]+)\smobile\ssafari/i],[[u,"Android Browser"],d,a],[/version\/((\d+)?[\w\.]+).+?mobile\/\w+\s(safari)/i],[d,a,[u,"Mobile Safari"]],[/version\/((\d+)?[\w\.]+).+?(mobile\s?safari|safari)/i],[d,a,u],[/webkit.+?(mobile\s?safari|safari)((\/[\w\.]+))/i],[u,[a,v.str,y.browser.oldsafari.major],[d,v.str,y.browser.oldsafari.version]],[/(konqueror)\/((\d+)?[\w\.]+)/i,/(webkit|khtml)\/((\d+)?[\w\.]+)/i],[u,d,a],[/(navigator|netscape)\/((\d+)?[\w\.-]+)/i],[[u,"Netscape"],d,a],[/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?((\d+)?[\w\.\+]+)/i,/(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix)\/((\d+)?[\w\.-]+)/i,/(mozilla)\/((\d+)?[\w\.]+).+rv\:.+gecko\/\d+/i,/(uc\s?browser|polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|qqbrowser)[\/\s]?((\d+)?[\w\.]+)/i,/(links)\s\(((\d+)?[\w\.]+)/i,/(gobrowser)\/?((\d+)?[\w\.]+)*/i,/(ice\s?browser)\/v?((\d+)?[\w\._]+)/i,/(mosaic)[\/\s]((\d+)?[\w\.]+)/i],[u,d,a]],engine:[[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i,/(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i,/(icab)[\/\s]([23]\.[\d\.]+)/i],[u,d],[/rv\:([\w\.]+).*(gecko)/i],[d,u]],os:[[/(windows)\snt\s6\.2;\s(arm)/i,/(windows\sphone(?:\sos)*|windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i],[u,[d,v.str,y.os.windows.version]],[/(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i],[[u,"Windows"],[d,v.str,y.os.windows.version]],[/\((bb)(10);/i],[[u,"BlackBerry"],d],[/(blackberry)\w*\/?([\w\.]+)*/i,/(tizen)\/([\w\.]+)/i,/(android|webos|palm\os|qnx|bada|rim\stablet\sos|meego)[\/\s-]?([\w\.]+)*/i],[u,d],[/(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]+)*/i],[[u,"Symbian"],d],[/mozilla.+\(mobile;.+gecko.+firefox/i],[[u,"Firefox OS"],d],[/(nintendo|playstation)\s([wids3portablevu]+)/i,/(mint)[\/\s\(]?(\w+)*/i,/(joli|[kxln]?ubuntu|debian|[open]*suse|gentoo|arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk)[\/\s-]?([\w\.-]+)*/i,/(hurd|linux)\s?([\w\.]+)*/i,/(gnu)\s?([\w\.]+)*/i],[u,d],[/(cros)\s[\w]+\s([\w\.]+\w)/i],[[u,"Chromium OS"],d],[/(sunos)\s?([\w\.]+\d)*/i],[[u,"Solaris"],d],[/\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]+)*/i],[u,d],[/(ip[honead]+)(?:.*os\s*([\w]+)*\slike\smac|;\sopera)/i],[[u,"iOS"],[d,/_/g,"."]],[/(mac\sos\sx)\s?([\w\s\.]+\w)*/i],[u,[d,/_/g,"."]],[/(haiku)\s(\w+)/i,/(aix)\s((\d)(?=\.|\)|\s)[\w\.]*)*/i,/(macintosh|mac(?=_powerpc)|plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos)/i,/(unix)\s?([\w\.]+)*/i],[u,d]]},E=function(e){var n=e||(window&&window.navigator&&window.navigator.userAgent?window.navigator.userAgent:t);this.getBrowser=function(){return v.rgx.apply(this,w.browser)},this.getEngine=function(){return v.rgx.apply(this,w.engine)},this.getOS=function(){return v.rgx.apply(this,w.os)},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS()}},this.getUA=function(){return n},this.setUA=function(e){return n=e,this},this.setUA(n)};return(new E).getResult()}(),i=function(){var t={define_property:function(){return!1}(),create_canvas:function(){var e=document.createElement("canvas");return!(!e.getContext||!e.getContext("2d"))}(),return_response_type:function(t){try{if(-1!==e.inArray(t,["","text","document"]))return!0;if(window.XMLHttpRequest){var n=new XMLHttpRequest;if(n.open("get","/"),"responseType"in n)return n.responseType=t,n.responseType!==t?!1:!0}}catch(i){}return!1},use_data_uri:function(){var e=new Image;return e.onload=function(){t.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 t.use_data_uri&&("IE"!==r.browser||r.version>=9)},use_data_uri_of:function(e){return t.use_data_uri&&33e3>e||t.use_data_uri_over32kb()},use_fileinput:function(){var e=document.createElement("input");return e.setAttribute("type","file"),!e.disabled}};return function(n){var i=[].slice.call(arguments);return i.shift(),"function"===e.typeOf(t[n])?t[n].apply(this,i):!!t[n]}}(),r={can:i,browser:n.browser.name,version:parseFloat(n.browser.major),os:n.os.name,osVersion:n.os.version,verComp:t,swf_url:"../flash/Moxie.swf",xap_url:"../silverlight/Moxie.xap",global_event_dispatcher:"moxie.core.EventTarget.instance.dispatchEvent"};return r.OS=r.os,r}),i(f,[d],function(e){var t=function(e){return"string"!=typeof e?e:document.getElementById(e)},n=function(e,t){if(!e.className)return!1;var n=new RegExp("(^|\\s+)"+t+"(\\s+|$)");return n.test(e.className)},i=function(e,t){n(e,t)||(e.className=e.className?e.className.replace(/\s+$/,"")+" "+t:t)},r=function(e,t){if(e.className){var n=new RegExp("(^|\\s+)"+t+"(\\s+|$)");e.className=e.className.replace(n,function(e,t,n){return" "===t&&" "===n?" ":""})}},o=function(e,t){return e.currentStyle?e.currentStyle[t]:window.getComputedStyle?window.getComputedStyle(e,null)[t]:void 0},a=function(t,n){function i(e){var t,n,i=0,r=0;return e&&(n=e.getBoundingClientRect(),t="CSS1Compat"===s.compatMode?s.documentElement:s.body,i=n.left+t.scrollLeft,r=n.top+t.scrollTop),{x:i,y:r}}var r=0,o=0,a,s=document,u,c;if(t=t,n=n||s.body,t&&t.getBoundingClientRect&&"IE"===e.browser&&(!s.documentMode||s.documentMode<8))return u=i(t),c=i(n),{x:u.x-c.x,y:u.y-c.y};for(a=t;a&&a!=n&&a.nodeType;)r+=a.offsetLeft||0,o+=a.offsetTop||0,a=a.offsetParent;for(a=t.parentNode;a&&a!=n&&a.nodeType;)r-=a.scrollLeft||0,o-=a.scrollTop||0,a=a.parentNode;return{x:r,y:o}},s=function(e){return{w:e.offsetWidth||e.clientWidth,h:e.offsetHeight||e.clientHeight}};return{get:t,hasClass:n,addClass:i,removeClass:r,getStyle:o,getPos:a,getSize:s}}),i(h,[u],function(e){function t(e,t){var n;for(n in e)if(e[n]===t)return n;return null}return{RuntimeError:function(){function n(e){this.code=e,this.name=t(i,e),this.message=this.name+": RuntimeError "+this.code}var i={NOT_INIT_ERR:1,NOT_SUPPORTED_ERR:9,JS_ERR:4};return e.extend(n,i),n.prototype=Error.prototype,n}(),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 n(e){this.code=e,this.name=t(i,e),this.message=this.name+": ImageError "+this.code}var i={WRONG_FORMAT:1,MAX_RESOLUTION_ERR:2};return e.extend(n,i),n.prototype=Error.prototype,n}(),FileException:function(){function n(e){this.code=e,this.name=t(i,e),this.message=this.name+": FileException "+this.code}var i={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(n,i),n.prototype=Error.prototype,n}(),DOMException:function(){function n(e){this.code=e,this.name=t(i,e),this.message=this.name+": DOMException "+this.code}var i={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(n,i),n.prototype=Error.prototype,n}(),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}()}}),i(p,[h,u],function(e,t){function n(){var n={};t.extend(this,{uid:null,init:function(){this.uid||(this.uid=t.guid("uid_"))},addEventListener:function(e,i,r,o){var a=this,s;return e=t.trim(e),/\s/.test(e)?void t.each(e.split(/\s+/),function(e){a.addEventListener(e,i,r,o)}):(e=e.toLowerCase(),r=parseInt(r,10)||0,s=n[this.uid]&&n[this.uid][e]||[],s.push({fn:i,priority:r,scope:o||this}),n[this.uid]||(n[this.uid]={}),void(n[this.uid][e]=s))},hasEventListener:function(e){return e?!(!n[this.uid]||!n[this.uid][e]):!!n[this.uid]},removeEventListener:function(e,i){e=e.toLowerCase();var r=n[this.uid]&&n[this.uid][e],o;if(r){if(i){for(o=r.length-1;o>=0;o--)if(r[o].fn===i){r.splice(o,1);break}}else r=[];r.length||(delete n[this.uid][e],t.isEmptyObj(n[this.uid])&&delete n[this.uid])}},removeAllEventListeners:function(){n[this.uid]&&delete n[this.uid]},dispatchEvent:function(i){var r,o,a,s,u={},c=!0,l;if("string"!==t.typeOf(i)){if(s=i,"string"!==t.typeOf(s.type))throw new e.EventException(e.EventException.UNSPECIFIED_EVENT_TYPE_ERR);i=s.type,s.total!==l&&s.loaded!==l&&(u.total=s.total,u.loaded=s.loaded),u.async=s.async||!1}if(-1!==i.indexOf("::")?!function(e){r=e[0],i=e[1]}(i.split("::")):r=this.uid,i=i.toLowerCase(),o=n[r]&&n[r][i]){o.sort(function(e,t){return t.priority-e.priority}),a=[].slice.call(arguments),a.shift(),u.type=i,a.unshift(u);var d=[];t.each(o,function(e){a[0].target=e.scope,d.push(u.async?function(t){setTimeout(function(){t(e.fn.apply(e.scope,a)===!1)},1)}:function(t){t(e.fn.apply(e.scope,a)===!1)})}),d.length&&t.inSeries(d,function(e){c=!e})}return c},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)},convertEventPropsToHandlers:function(e){var n;"array"!==t.typeOf(e)&&(e=[e]);for(var i=0;i<e.length;i++)n="on"+e[i],"function"===t.typeOf(this[n])?this.addEventListener(e[i],this[n]):"undefined"===t.typeOf(this[n])&&(this[n]=null)}})}return n.instance=new n,n}),i(m,[],function(){var e=function(e){return unescape(encodeURIComponent(e))},t=function(e){return decodeURIComponent(escape(e))},n=function(e,n){if("function"==typeof window.atob)return n?t(window.atob(e)):window.atob(e);var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r,o,a,s,u,c,l,d,f=0,h=0,p="",m=[];if(!e)return e;e+="";do s=i.indexOf(e.charAt(f++)),u=i.indexOf(e.charAt(f++)),c=i.indexOf(e.charAt(f++)),l=i.indexOf(e.charAt(f++)),d=s<<18|u<<12|c<<6|l,r=d>>16&255,o=d>>8&255,a=255&d,64==c?m[h++]=String.fromCharCode(r):64==l?m[h++]=String.fromCharCode(r,o):m[h++]=String.fromCharCode(r,o,a);while(f<e.length);return p=m.join(""),n?t(p):p},i=function(t,n){if(n&&e(t),"function"==typeof window.btoa)return window.btoa(t);var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r,o,a,s,u,c,l,d,f=0,h=0,p="",m=[];if(!t)return t;do r=t.charCodeAt(f++),o=t.charCodeAt(f++),a=t.charCodeAt(f++),d=r<<16|o<<8|a,s=d>>18&63,u=d>>12&63,c=d>>6&63,l=63&d,m[h++]=i.charAt(s)+i.charAt(u)+i.charAt(c)+i.charAt(l);while(f<t.length);p=m.join("");var g=t.length%3;return(g?p.slice(0,g-3):p)+"===".slice(g||3)};return{utf8_encode:e,utf8_decode:t,atob:n,btoa:i}}),i(g,[u,f,p],function(e,t,n){function i(n,r,a,s,u){var c=this,l,d=e.guid(r+"_"),f=u||"browser";n=n||{},o[d]=this,a=e.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},a),n.preferred_caps&&(f=i.getMode(s,n.preferred_caps,f)),l=function(){var t={};return{exec:function(e,n,i,r){return l[n]&&(t[e]||(t[e]={context:this,instance:new l[n]}),t[e].instance[i])?t[e].instance[i].apply(this,r):void 0},removeInstance:function(e){delete t[e]},removeAllInstances:function(){var n=this;e.each(t,function(t,i){"function"===e.typeOf(t.instance.destroy)&&t.instance.destroy.call(t.context),n.removeInstance(i)})}}}(),e.extend(this,{initialized:!1,uid:d,type:r,mode:i.getMode(s,n.required_caps,f),shimid:d+"_container",clients:0,options:n,can:function(t,n){var r=arguments[2]||a;if("string"===e.typeOf(t)&&"undefined"===e.typeOf(n)&&(t=i.parseCaps(t)),"object"===e.typeOf(t)){for(var o in t)if(!this.can(o,t[o],r))return!1;return!0}return"function"===e.typeOf(r[t])?r[t].call(this,n):n===r[t]},getShimContainer:function(){var n,i=t.get(this.shimid);return i||(n=this.options.container?t.get(this.options.container):document.body,i=document.createElement("div"),i.id=this.shimid,i.className="moxie-shim moxie-shim-"+this.type,e.extend(i.style,{position:"absolute",top:"0px",left:"0px",width:"1px",height:"1px",overflow:"hidden"}),n.appendChild(i),n=null),i},getShim:function(){return l},shimExec:function(e,t){var n=[].slice.call(arguments,2);return c.getShim().exec.call(this,this.uid,e,t,n)},exec:function(e,t){var n=[].slice.call(arguments,2);return c[e]&&c[e][t]?c[e][t].apply(this,n):c.shimExec.apply(this,arguments)},destroy:function(){if(c){var e=t.get(this.shimid);e&&e.parentNode.removeChild(e),l&&l.removeAllInstances(),this.unbindAll(),delete o[this.uid],this.uid=null,d=c=l=e=null}}}),this.mode&&n.required_caps&&!this.can(n.required_caps)&&(this.mode=!1)}var r={},o={};return i.order="html5,flash,silverlight,html4",i.getRuntime=function(e){return o[e]?o[e]:!1},i.addConstructor=function(e,t){t.prototype=n.instance,r[e]=t},i.getConstructor=function(e){return r[e]||null},i.getInfo=function(e){var t=i.getRuntime(e);return t?{uid:t.uid,type:t.type,mode:t.mode,can:function(){return t.can.apply(t,arguments)}}:null},i.parseCaps=function(t){var n={};return"string"!==e.typeOf(t)?t||{}:(e.each(t.split(","),function(e){n[e]=!0}),n)},i.can=function(e,t){var n,r=i.getConstructor(e),o;return r?(n=new r({required_caps:t}),o=n.mode,n.destroy(),!!o):!1},i.thatCan=function(e,t){var n=(t||i.order).split(/\s*,\s*/);for(var r in n)if(i.can(n[r],e))return n[r];return null},i.getMode=function(t,n,i){var r=null;if("undefined"===e.typeOf(i)&&(i="browser"),n&&!e.isEmptyObj(t)){if(e.each(n,function(n,i){if(t.hasOwnProperty(i)){var o=t[i](n);if("string"==typeof o&&(o=[o]),r){if(!(r=e.arrayIntersect(r,o)))return r=!1}else r=o}}),r)return-1!==e.inArray(i,r)?i:r[0];if(r===!1)return!1}return i},i.capTrue=function(){return!0},i.capFalse=function(){return!1},i.capTest=function(e){return function(){return!!e}},i}),i(v,[h,u,g],function(e,t,n){return function i(){var i;t.extend(this,{connectRuntime:function(r){function o(t){var s,u;return t.length?(s=t.shift(),(u=n.getConstructor(s))?(i=new u(r),i.bind("Init",function(){i.initialized=!0,setTimeout(function(){i.clients++,a.trigger("RuntimeInit",i)},1)}),i.bind("Error",function(){i.destroy(),o(t)}),i.mode?void i.init():void i.trigger("Error")):void o(t)):(a.trigger("RuntimeError",new e.RuntimeError(e.RuntimeError.NOT_INIT_ERR)),void(i=null))}var a=this,s;if("string"===t.typeOf(r)?s=r:"string"===t.typeOf(r.ruid)&&(s=r.ruid),s){if(i=n.getRuntime(s))return i.clients++,i;throw new e.RuntimeError(e.RuntimeError.NOT_INIT_ERR)}o((r.runtime_order||n.order).split(/\s*,\s*/))},getRuntime:function(){return i&&i.uid?i:(i=null,null)},disconnectRuntime:function(){i&&--i.clients<=0&&(i.destroy(),i=null)}})}}),i(y,[u,m,v],function(e,t,n){function i(o,a){function s(t,n,o){var a,s=r[this.uid];return"string"===e.typeOf(s)&&s.length?(a=new i(null,{type:o,size:n-t}),a.detach(s.substr(t,a.size)),a):null}n.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,n){return this.isDetached()?s.apply(this,arguments):this.getRuntime().exec.call(this,"Blob","slice",this.getSource(),e,t,n)},getSource:function(){return r[this.uid]?r[this.uid]:null},detach:function(e){this.ruid&&(this.getRuntime().exec.call(this,"Blob","destroy"),this.disconnectRuntime(),this.ruid=null),e=e||"";var n=e.match(/^data:([^;]*);base64,/);n&&(this.type=n[1],e=t.atob(e.substring(e.indexOf("base64,")+7))),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 i}),i(w,[u,l,y],function(e,t,n){function i(i,r){var o,a;if(r||(r={}),a=r.type&&""!==r.type?r.type:t.getFileMime(r.name),r.name)o=r.name.replace(/\\/g,"/"),o=o.substr(o.lastIndexOf("/")+1);else{var s=a.split("/")[0];o=e.guid((""!==s?s:"file")+"_"),t.extensions[a]&&(o+="."+t.extensions[a][0])}n.apply(this,arguments),e.extend(this,{type:a||"",name:o||e.guid("file_"),lastModifiedDate:r.lastModifiedDate||(new Date).toLocaleString()})}return i.prototype=n.prototype,i}),i(E,[u,l,f,h,p,c,w,g,v],function(e,t,n,i,r,o,a,s,u){function c(r){var c=this,d,f,h;if(-1!==e.inArray(e.typeOf(r),["string","node"])&&(r={browse_button:r}),f=n.get(r.browse_button),!f)throw new i.DOMException(i.DOMException.NOT_FOUND_ERR);h={accept:[{title:o.translate("All Files"),extensions:"*"}],name:"file",multiple:!1,required_caps:!1,container:f.parentNode||document.body},r=e.extend({},h,r),"string"==typeof r.required_caps&&(r.required_caps=s.parseCaps(r.required_caps)),"string"==typeof r.accept&&(r.accept=t.mimes2extList(r.accept)),d=n.get(r.container),d||(d=document.body),"static"===n.getStyle(d,"position")&&(d.style.position="relative"),d=f=null,u.call(c),e.extend(c,{uid:e.guid("uid_"),ruid:null,shimid:null,files:null,init:function(){c.convertEventPropsToHandlers(l),c.bind("RuntimeInit",function(t,i){c.ruid=i.uid,c.shimid=i.shimid,c.bind("Ready",function(){c.trigger("Refresh")},999),c.bind("Change",function(){var t=i.exec.call(c,"FileInput","getFiles");c.files=[],e.each(t,function(e){return 0===e.size?!0:void c.files.push(new a(c.ruid,e))})},999),c.bind("Refresh",function(){var t,o,a,s;a=n.get(r.browse_button),s=n.get(i.shimid),a&&(t=n.getPos(a,n.get(r.container)),o=n.getSize(a),s&&e.extend(s.style,{top:t.y+"px",left:t.x+"px",width:o.w+"px",height:o.h+"px"})),s=a=null}),i.exec.call(c,"FileInput","init",r)}),c.connectRuntime(e.extend({},r,{required_caps:{select_file:!0}}))},disable:function(t){var n=this.getRuntime();n&&n.exec.call(this,"FileInput","disable","undefined"===e.typeOf(t)?!0:t)},refresh:function(){c.trigger("Refresh")},destroy:function(){var t=this.getRuntime();t&&(t.exec.call(this,"FileInput","destroy"),this.disconnectRuntime()),"array"===e.typeOf(this.files)&&e.each(this.files,function(e){e.destroy()}),this.files=null}})}var l=["ready","change","cancel","mouseenter","mouseleave","mousedown","mouseup"];return c.prototype=r.instance,c}),i(_,[c,f,h,u,w,v,p,l],function(e,t,n,i,r,o,a,s){function u(n){var a=this,u;"string"==typeof n&&(n={drop_zone:n}),u={accept:[{title:e.translate("All Files"),extensions:"*"}],required_caps:{drag_and_drop:!0}},n="object"==typeof n?i.extend({},u,n):u,n.container=t.get(n.drop_zone)||document.body,"static"===t.getStyle(n.container,"position")&&(n.container.style.position="relative"),"string"==typeof n.accept&&(n.accept=s.mimes2extList(n.accept)),o.call(a),i.extend(a,{uid:i.guid("uid_"),ruid:null,files:null,init:function(){a.convertEventPropsToHandlers(c),a.bind("RuntimeInit",function(e,t){a.ruid=t.uid,a.bind("Drop",function(){var e=t.exec.call(a,"FileDrop","getFiles");a.files=[],i.each(e,function(e){a.files.push(new r(a.ruid,e))})},999),t.exec.call(a,"FileDrop","init",n),a.dispatchEvent("ready")}),a.connectRuntime(n)},destroy:function(){var e=this.getRuntime();e&&(e.exec.call(this,"FileDrop","destroy"),this.disconnectRuntime()),this.files=null}})}var c=["ready","dragenter","dragleave","drop","error"];return u.prototype=a.instance,u}),i(x,[u,v,p],function(e,t,n){function i(){this.uid=e.guid("uid_"),t.call(this),this.destroy=function(){this.disconnectRuntime(),this.unbindAll()}}return i.prototype=n.instance,i}),i(b,[u,m,h,p,y,w,x],function(e,t,n,i,r,o,a){function s(){function i(e,i){function l(e){o.readyState=s.DONE,o.error=e,o.trigger("error"),d()}function d(){c.destroy(),c=null,o.trigger("loadend")}function f(t){c.bind("Error",function(e,t){l(t)}),c.bind("Progress",function(e){o.result=t.exec.call(c,"FileReader","getResult"),o.trigger(e)}),c.bind("Load",function(e){o.readyState=s.DONE,o.result=t.exec.call(c,"FileReader","getResult"),o.trigger(e),d()}),t.exec.call(c,"FileReader","read",e,i)}if(c=new a,this.convertEventPropsToHandlers(u),this.readyState===s.LOADING)return l(new n.DOMException(n.DOMException.INVALID_STATE_ERR));if(this.readyState=s.LOADING,this.trigger("loadstart"),i instanceof r)if(i.isDetached()){var h=i.getSource();switch(e){case"readAsText":case"readAsBinaryString":this.result=h;break;case"readAsDataURL":this.result="data:"+i.type+";base64,"+t.btoa(h)}this.readyState=s.DONE,this.trigger("load"),d()}else f(c.connectRuntime(i.ruid));else l(new n.DOMException(n.DOMException.NOT_FOUND_ERR))}var o=this,c;e.extend(this,{uid:e.guid("uid_"),readyState:s.EMPTY,result:null,error:null,readAsBinaryString:function(e){i.call(this,"readAsBinaryString",e)},readAsDataURL:function(e){i.call(this,"readAsDataURL",e)},readAsText:function(e){i.call(this,"readAsText",e)},abort:function(){
14
+ this.result=null,-1===e.inArray(this.readyState,[s.EMPTY,s.DONE])&&(this.readyState===s.LOADING&&(this.readyState=s.DONE),c&&c.getRuntime().exec.call(this,"FileReader","abort"),this.trigger("abort"),this.trigger("loadend"))},destroy:function(){this.abort(),c&&(c.getRuntime().exec.call(this,"FileReader","destroy"),c.disconnectRuntime()),o=c=null}})}var u=["loadstart","progress","load","abort","error","loadend"];return s.EMPTY=0,s.LOADING=1,s.DONE=2,s.prototype=i.instance,s}),i(R,[],function(){var e=function(t,n){for(var i=["source","scheme","authority","userInfo","user","pass","host","port","relative","path","directory","file","query","fragment"],r=i.length,o={http:80,https:443},a={},s=/^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/,u=s.exec(t||"");r--;)u[r]&&(a[i[r]]=u[r]);if(!a.scheme){n&&"string"!=typeof n||(n=e(n||document.location.href)),a.scheme=n.scheme,a.host=n.host,a.port=n.port;var c="";/^[^\/]/.test(a.path)&&(c=n.path,/(\/|\/[^\.]+)$/.test(c)?c+="/":c=c.replace(/\/[^\/]+$/,"/")),a.path=c+(a.path||"")}return a.port||(a.port=o[a.scheme]||80),a.port=parseInt(a.port,10),a.path||(a.path="/"),delete a.source,a},t=function(t){var n={http:80,https:443},i=e(t);return i.scheme+"://"+i.host+(i.port!==n[i.scheme]?":"+i.port:"")+i.path+(i.query?i.query:"")},n=function(t){function n(e){return[e.scheme,e.host,e.port].join("/")}return"string"==typeof t&&(t=e(t)),n(e())===n(t)};return{parseUrl:e,resolveUrl:t,hasSameOrigin:n}}),i(T,[u,v,m],function(e,t,n){return function(){function i(e,t){if(!t.isDetached()){var i=this.connectRuntime(t.ruid).exec.call(this,"FileReaderSync","read",e,t);return this.disconnectRuntime(),i}var r=t.getSource();switch(e){case"readAsBinaryString":return r;case"readAsDataURL":return"data:"+t.type+";base64,"+n.btoa(r);case"readAsText":for(var o="",a=0,s=r.length;s>a;a++)o+=String.fromCharCode(r[a]);return o}}t.call(this),e.extend(this,{uid:e.guid("uid_"),readAsBinaryString:function(e){return i.call(this,"readAsBinaryString",e)},readAsDataURL:function(e){return i.call(this,"readAsDataURL",e)},readAsText:function(e){return i.call(this,"readAsText",e)}})}}),i(A,[h,u,y],function(e,t,n){function i(){var e,i=[];t.extend(this,{append:function(r,o){var a=this,s=t.typeOf(o);o instanceof n?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"):i.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(n){t.each(i,function(e){n(e.value,e.name)}),e&&n(e.value,e.name)},destroy:function(){e=null,i=[]}})}return i}),i(S,[u,h,p,m,R,g,x,y,T,A,d,l],function(e,t,n,i,r,o,a,s,u,c,l,d){function f(){this.uid=e.guid("uid_")}function h(){function n(e,t){return y.hasOwnProperty(e)?1===arguments.length?l.can("define_property")?y[e]:v[e]:void(l.can("define_property")?y[e]=t:v[e]=t):void 0}function u(t){function i(){k&&(k.destroy(),k=null),s.dispatchEvent("loadend"),s=null}function r(r){k.bind("LoadStart",function(e){n("readyState",h.LOADING),s.dispatchEvent("readystatechange"),s.dispatchEvent(e),I&&s.upload.dispatchEvent(e)}),k.bind("Progress",function(e){n("readyState")!==h.LOADING&&(n("readyState",h.LOADING),s.dispatchEvent("readystatechange")),s.dispatchEvent(e)}),k.bind("UploadProgress",function(e){I&&s.upload.dispatchEvent({type:"progress",lengthComputable:!1,total:e.total,loaded:e.loaded})}),k.bind("Load",function(t){n("readyState",h.DONE),n("status",Number(r.exec.call(k,"XMLHttpRequest","getStatus")||0)),n("statusText",p[n("status")]||""),n("response",r.exec.call(k,"XMLHttpRequest","getResponse",n("responseType"))),~e.inArray(n("responseType"),["text",""])?n("responseText",n("response")):"document"===n("responseType")&&n("responseXML",n("response")),U=r.exec.call(k,"XMLHttpRequest","getAllResponseHeaders"),s.dispatchEvent("readystatechange"),n("status")>0?(I&&s.upload.dispatchEvent(t),s.dispatchEvent(t)):(N=!0,s.dispatchEvent("error")),i()}),k.bind("Abort",function(e){s.dispatchEvent(e),i()}),k.bind("Error",function(e){N=!0,n("readyState",h.DONE),s.dispatchEvent("readystatechange"),D=!0,s.dispatchEvent(e),i()}),r.exec.call(k,"XMLHttpRequest","send",{url:E,method:_,async:w,user:b,password:R,headers:x,mimeType:A,encoding:T,responseType:s.responseType,withCredentials:s.withCredentials,options:P},t)}var s=this;M=(new Date).getTime(),k=new a,"string"==typeof P.required_caps&&(P.required_caps=o.parseCaps(P.required_caps)),P.required_caps=e.extend({},P.required_caps,{return_response_type:s.responseType}),t instanceof c&&(P.required_caps.send_multipart=!0),L||(P.required_caps.do_cors=!0),P.ruid?r(k.connectRuntime(P)):(k.bind("RuntimeInit",function(e,t){r(t)}),k.bind("RuntimeError",function(e,t){s.dispatchEvent("RuntimeError",t)}),k.connectRuntime(P))}function g(){n("responseText",""),n("responseXML",null),n("response",null),n("status",0),n("statusText",""),M=C=null}var v=this,y={timeout:0,readyState:h.UNSENT,withCredentials:!1,status:0,statusText:"",responseType:"",responseXML:null,responseText:null,response:null},w=!0,E,_,x={},b,R,T=null,A=null,S=!1,O=!1,I=!1,D=!1,N=!1,L=!1,M,C,F=null,H=null,P={},k,U="",B;e.extend(this,y,{uid:e.guid("uid_"),upload:new f,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)||i.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"])&&(_=o.toUpperCase()),~e.inArray(_,["CONNECT","TRACE","TRACK"]))throw new t.DOMException(t.DOMException.SECURITY_ERR);if(a=i.utf8_encode(a),l=r.parseUrl(a),L=r.hasSameOrigin(l),E=r.resolveUrl(a),(u||c)&&!L)throw new t.DOMException(t.DOMException.INVALID_ACCESS_ERR);if(b=u||l.user,R=c||l.pass,w=s||!0,w===!1&&(n("timeout")||n("withCredentials")||""!==n("responseType")))throw new t.DOMException(t.DOMException.INVALID_ACCESS_ERR);S=!w,O=!1,x={},g.call(this),n("readyState",h.OPENED),this.convertEventPropsToHandlers(["readystatechange"]),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(n("readyState")!==h.OPENED||O)throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);if(/[\u0100-\uffff]/.test(r)||i.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:(x[r]?x[r]+=", "+o:x[r]=o,!0)},getAllResponseHeaders:function(){return U||""},getResponseHeader:function(t){return t=t.toLowerCase(),N||~e.inArray(t,["set-cookie","set-cookie2"])?null:U&&""!==U&&(B||(B={},e.each(U.split(/\r\n/),function(t){var n=t.split(/:\s+/);2===n.length&&(n[0]=e.trim(n[0]),B[n[0].toLowerCase()]={header:n[0],value:e.trim(n[1])})})),B.hasOwnProperty(t))?B[t].header+": "+B[t].value:null},overrideMimeType:function(i){var r,o;if(~e.inArray(n("readyState"),[h.LOADING,h.DONE]))throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);if(i=e.trim(i.toLowerCase()),/;/.test(i)&&(r=i.match(/^([^;]+)(?:;\scharset\=)?(.*)$/))&&(i=r[1],r[2]&&(o=r[2])),!d.mimes[i])throw new t.DOMException(t.DOMException.SYNTAX_ERR);F=i,H=o},send:function(n,r){if(P="string"===e.typeOf(r)?{ruid:r}:r?r:{},this.convertEventPropsToHandlers(m),this.upload.convertEventPropsToHandlers(m),this.readyState!==h.OPENED||O)throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);if(n instanceof s)P.ruid=n.ruid,A=n.type||"application/octet-stream";else if(n instanceof c){if(n.hasBlob()){var o=n.getBlob();P.ruid=o.ruid,A=o.type||"application/octet-stream"}}else"string"==typeof n&&(T="UTF-8",A="text/plain;charset=UTF-8",n=i.utf8_encode(n));this.withCredentials||(this.withCredentials=P.required_caps&&P.required_caps.send_browser_cookies&&!L),I=!S&&this.upload.hasEventListener(),N=!1,D=!n,S||(O=!0),u.call(this,n)},abort:function(){if(N=!0,S=!1,~e.inArray(n("readyState"),[h.UNSENT,h.OPENED,h.DONE]))n("readyState",h.UNSENT);else{if(n("readyState",h.DONE),O=!1,!k)throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);k.getRuntime().exec.call(k,"XMLHttpRequest","abort",D),D=!0}},destroy:function(){k&&("function"===e.typeOf(k.destroy)&&k.destroy(),k=null),this.unbindAll(),this.upload&&(this.upload.unbindAll(),this.upload=null)}})}var p={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"};f.prototype=n.instance;var m=["loadstart","progress","abort","error","load","timeout","loadend"],g=1,v=2;return h.UNSENT=0,h.OPENED=1,h.HEADERS_RECEIVED=2,h.LOADING=3,h.DONE=4,h.prototype=n.instance,h}),i(O,[u,m,v,p],function(e,t,n,i){function r(){function i(){l=d=0,c=this.result=null}function o(t,n){var i=this;u=n,i.bind("TransportingProgress",function(t){d=t.loaded,l>d&&-1===e.inArray(i.state,[r.IDLE,r.DONE])&&a.call(i)},999),i.bind("TransportingComplete",function(){d=l,i.state=r.DONE,c=null,i.result=u.exec.call(i,"Transporter","getAsBlob",t||"")},999),i.state=r.BUSY,i.trigger("TransportingStarted"),a.call(i)}function a(){var e=this,n,i=l-d;f>i&&(f=i),n=t.btoa(c.substr(d,f)),u.exec.call(e,"Transporter","receive",n,l)}var s,u,c,l,d,f;n.call(this),e.extend(this,{uid:e.guid("uid_"),state:r.IDLE,result:null,transport:function(t,n,r){var a=this;if(r=e.extend({chunk_size:204798},r),(s=r.chunk_size%3)&&(r.chunk_size+=3-s),f=r.chunk_size,i.call(this),c=t,l=t.length,"string"===e.typeOf(r)||r.ruid)o.call(a,n,this.connectRuntime(r));else{var u=function(e,t){a.unbind("RuntimeInit",u),o.call(a,n,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")),i.call(e)},destroy:function(){this.unbindAll(),u=null,this.disconnectRuntime(),i.call(this)}})}return r.IDLE=0,r.BUSY=1,r.DONE=2,r.prototype=i.instance,r}),i(I,[u,f,h,T,S,g,v,O,d,p,y,w,m],function(e,t,n,i,r,o,a,s,u,c,l,d,f){function h(){function i(e){e||(e=this.getRuntime().exec.call(this,"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)}function c(t){var i=e.typeOf(t);try{if(t instanceof h){if(!t.size)throw new n.DOMException(n.DOMException.INVALID_STATE_ERR);m.apply(this,arguments)}else if(t instanceof l){if(!~e.inArray(t.type,["image/jpeg","image/png"]))throw new n.ImageError(n.ImageError.WRONG_FORMAT);g.apply(this,arguments)}else if(-1!==e.inArray(i,["blob","file"]))c.call(this,new d(null,t),arguments[1]);else if("string"===i)/^data:[^;]*;base64,/.test(t)?c.call(this,new l(null,{data:t}),arguments[1]):v.apply(this,arguments);else{if("node"!==i||"img"!==t.nodeName.toLowerCase())throw new n.DOMException(n.DOMException.TYPE_MISMATCH_ERR);c.call(this,t.src,arguments[1])}}catch(r){this.trigger("error",r.code)}}function m(t,n){var i=this.connectRuntime(t.ruid);this.ruid=i.uid,i.exec.call(this,"Image","loadFromImage",t,"undefined"===e.typeOf(n)?!0:n)}function g(t,n){function i(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){i(t)}),n&&"string"==typeof n.required_caps&&(n.required_caps=o.parseCaps(n.required_caps)),this.connectRuntime(e.extend({required_caps:{access_image_binary:!0,resize_image:!0}},n))):i(this.connectRuntime(t.ruid))}function v(e,t){var n=this,i;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(){this.bind("Load Resize",function(){i.call(this)},999),this.convertEventPropsToHandlers(p),c.apply(this,arguments)},downsize:function(t){var i={width:this.width,height:this.height,crop:!1,preserveHeaders:!0};t="object"==typeof t?e.extend(i,t):e.extend(i,{width:arguments[0],height:arguments[1],crop:arguments[2],preserveHeaders:arguments[3]});try{if(!this.size)throw new n.DOMException(n.DOMException.INVALID_STATE_ERR);if(this.width>h.MAX_RESIZE_WIDTH||this.height>h.MAX_RESIZE_HEIGHT)throw new n.ImageError(n.ImageError.MAX_RESOLUTION_ERR);this.getRuntime().exec.call(this,"Image","downsize",t.width,t.height,t.crop,t.preserveHeaders)}catch(r){this.trigger("error",r.code)}},crop:function(e,t,n){this.downsize(e,t,!0,n)},getAsCanvas:function(){if(!u.can("create_canvas"))throw new n.RuntimeError(n.RuntimeError.NOT_SUPPORTED_ERR);var e=this.connectRuntime(this.ruid);return e.exec.call(this,"Image","getAsCanvas")},getAsBlob:function(e,t){if(!this.size)throw new n.DOMException(n.DOMException.INVALID_STATE_ERR);return e||(e="image/jpeg"),"image/jpeg"!==e||t||(t=90),this.getRuntime().exec.call(this,"Image","getAsBlob",e,t)},getAsDataURL:function(e,t){if(!this.size)throw new n.DOMException(n.DOMException.INVALID_STATE_ERR);return this.getRuntime().exec.call(this,"Image","getAsDataURL",e,t)},getAsBinaryString:function(e,t){var n=this.getAsDataURL(e,t);return f.atob(n.substring(n.indexOf("base64,")+7))},embed:function(i){function r(){if(u.can("create_canvas")){var t=a.getAsCanvas();if(t)return i.appendChild(t),t=null,a.destroy(),void o.trigger("embedded")}var r=a.getAsDataURL(c,l);if(!r)throw new n.ImageError(n.ImageError.WRONG_FORMAT);if(u.can("use_data_uri_of",r.length))i.innerHTML='<img src="'+r+'" width="'+a.width+'" height="'+a.height+'" />',a.destroy(),o.trigger("embedded");else{var d=new s;d.bind("TransportingComplete",function(){v=o.connectRuntime(this.result.ruid),o.bind("Embedded",function(){e.extend(v.getShimContainer().style,{top:"0px",left:"0px",width:a.width+"px",height:a.height+"px"}),v=null},999),v.exec.call(o,"ImageView","display",this.result.uid,m,g),a.destroy()}),d.transport(f.atob(r.substring(r.indexOf("base64,")+7)),c,e.extend({},p,{required_caps:{display_media:!0},runtime_order:"flash,silverlight",container:i}))}}var o=this,a,c,l,d,p=arguments[1]||{},m=this.width,g=this.height,v;try{if(!(i=t.get(i)))throw new n.DOMException(n.DOMException.INVALID_NODE_TYPE_ERR);if(!this.size)throw new n.DOMException(n.DOMException.INVALID_STATE_ERR);if(this.width>h.MAX_RESIZE_WIDTH||this.height>h.MAX_RESIZE_HEIGHT)throw new n.ImageError(n.ImageError.MAX_RESOLUTION_ERR);if(c=p.type||this.type||"image/jpeg",l=p.quality||90,d="undefined"!==e.typeOf(p.crop)?p.crop:!1,p.width)m=p.width,g=p.height||m;else{var y=t.getSize(i);y.w&&y.h&&(m=y.w,g=y.h)}return a=new h,a.bind("Resize",function(){r.call(o)}),a.bind("Load",function(){a.downsize(m,g,d,!1)}),a.clone(this,!1),a}catch(w){this.trigger("error",w.code)}},destroy:function(){this.ruid&&(this.getRuntime().exec.call(this,"Image","destroy"),this.disconnectRuntime()),this.unbindAll()}})}var p=["progress","load","error","resize","embedded"];return h.MAX_RESIZE_WIDTH=6500,h.MAX_RESIZE_HEIGHT=6500,h.prototype=c.instance,h}),i(D,[u,h,g,d],function(e,t,n,i){function r(t){var r=this,s=n.capTest,u=n.capTrue,c=e.extend({access_binary:s(window.FileReader||window.File&&window.File.getAsDataURL),access_image_binary:function(){return r.can("access_binary")&&!!a.Image},display_media:s(i.can("create_canvas")||i.can("use_data_uri_over32kb")),do_cors:s(window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest),drag_and_drop:s(function(){var e=document.createElement("div");return("draggable"in e||"ondragstart"in e&&"ondrop"in e)&&("IE"!==i.browser||i.version>9)}()),filter_by_extension:s(function(){return"Chrome"===i.browser&&i.version>=28||"IE"===i.browser&&i.version>=10}()),return_response_headers:u,return_response_type:function(e){return"json"===e&&window.JSON?!0:i.can("return_response_type",e)},return_status_code:u,report_upload_progress:s(window.XMLHttpRequest&&(new XMLHttpRequest).upload),resize_image:function(){return r.can("access_binary")&&i.can("create_canvas")},select_file:function(){return i.can("use_fileinput")&&window.File},select_folder:function(){return r.can("select_file")&&"Chrome"===i.browser&&i.version>=21},select_multiple:function(){return!(!r.can("select_file")||"Safari"===i.browser&&"Windows"===i.os||"iOS"===i.os&&i.verComp(i.osVersion,"7.0.4","<"))},send_binary_string:s(window.XMLHttpRequest&&((new XMLHttpRequest).sendAsBinary||window.Uint8Array&&window.ArrayBuffer)),send_custom_headers:s(window.XMLHttpRequest),send_multipart:function(){return!!(window.XMLHttpRequest&&(new XMLHttpRequest).upload&&window.FormData)||r.can("send_binary_string")},slice_blob:s(window.File&&(File.prototype.mozSlice||File.prototype.webkitSlice||File.prototype.slice)),stream_upload:function(){return r.can("slice_blob")&&r.can("send_multipart")},summon_file_dialog:s(function(){return"Firefox"===i.browser&&i.version>=4||"Opera"===i.browser&&i.version>=12||"IE"===i.browser&&i.version>=10||!!~e.inArray(i.browser,["Chrome","Safari"])}()),upload_filesize:u},arguments[2]);n.call(this,t,arguments[1]||o,c),e.extend(this,{init:function(){this.trigger("Init")},destroy:function(e){return function(){e.call(r),e=r=null}}(this.destroy)}),e.extend(this.getShim(),a)}var o="html5",a={};return n.addConstructor(o,r),a}),i(N,[D,y],function(e,t){function n(){function e(e,t,n){var i;if(!window.File.prototype.slice)return(i=window.File.prototype.webkitSlice||window.File.prototype.mozSlice)?i.call(e,t,n):null;try{return e.slice(),e.slice(t,n)}catch(r){return e.slice(t,n-t)}}this.slice=function(){return new t(this.getRuntime().uid,e.apply(this,arguments))}}return e.Blob=n}),i(L,[u],function(e){function t(){this.returnValue=!1}function n(){this.cancelBubble=!0}var i={},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=n,s(e)},o.attachEvent("on"+a,c)),o[r]||(o[r]=e.guid()),i.hasOwnProperty(o[r])||(i[o[r]]={}),l=i[o[r]],l.hasOwnProperty(a)||(l[a]=[]),l[a].push({func:c,orig:s,key:u})},a=function(t,n,o){var a,s;if(n=n.toLowerCase(),t[r]&&i[t[r]]&&i[t[r]][n]){a=i[t[r]][n];for(var u=a.length-1;u>=0&&(a[u].orig!==o&&a[u].key!==o||(t.removeEventListener?t.removeEventListener(n,a[u].func,!1):t.detachEvent&&t.detachEvent("on"+n,a[u].func),a[u].orig=null,a[u].func=null,a.splice(u,1),o===s));u--);if(a.length||delete i[t[r]][n],e.isEmptyObj(i[t[r]])){delete i[t[r]];try{delete t[r]}catch(c){t[r]=s}}}},s=function(t,n){t&&t[r]&&e.each(i[t[r]],function(e,i){a(t,i,n)})};return{addEvent:o,removeEvent:a,removeAllEvents:s}}),i(M,[D,u,f,L,l,d],function(e,t,n,i,r,o){function a(){var e=[],a;t.extend(this,{init:function(s){var u=this,c=u.getRuntime(),l,d,f,h,p,m;a=s,e=[],f=a.accept.mimes||r.extList2mimes(a.accept,c.can("filter_by_extension")),d=c.getShimContainer(),d.innerHTML='<input id="'+c.uid+'" type="file" style="font-size:999px;opacity:0;"'+(a.multiple&&c.can("select_multiple")?"multiple":"")+(a.directory&&c.can("select_folder")?"webkitdirectory directory":"")+(f?' accept="'+f.join(",")+'"':"")+" />",l=n.get(c.uid),t.extend(l.style,{position:"absolute",top:0,left:0,width:"100%",height:"100%"}),h=n.get(a.browse_button),c.can("summon_file_dialog")&&("static"===n.getStyle(h,"position")&&(h.style.position="relative"),p=parseInt(n.getStyle(h,"z-index"),10)||1,h.style.zIndex=p,d.style.zIndex=p-1,i.addEvent(h,"click",function(e){var t=n.get(c.uid);t&&!t.disabled&&t.click(),e.preventDefault()},u.uid)),m=c.can("summon_file_dialog")?h:d,i.addEvent(m,"mouseover",function(){u.trigger("mouseenter")},u.uid),i.addEvent(m,"mouseout",function(){u.trigger("mouseleave")},u.uid),i.addEvent(m,"mousedown",function(){u.trigger("mousedown")},u.uid),i.addEvent(n.get(a.container),"mouseup",function(){u.trigger("mouseup")},u.uid),l.onchange=function g(){if(e=[],a.directory?t.each(this.files,function(t){"."!==t.name&&e.push(t)}):e=[].slice.call(this.files),"IE"!==o.browser&&"IEMobile"!==o.browser)this.value="";else{var n=this.cloneNode(!0);this.parentNode.replaceChild(n,this),n.onchange=g}u.trigger("change")},u.trigger({type:"ready",async:!0}),d=null},getFiles:function(){return e},disable:function(e){var t=this.getRuntime(),i;(i=n.get(t.uid))&&(i.disabled=!!e)},destroy:function(){var t=this.getRuntime(),r=t.getShim(),o=t.getShimContainer();i.removeAllEvents(o,this.uid),i.removeAllEvents(a&&n.get(a.container),this.uid),i.removeAllEvents(a&&n.get(a.browse_button),this.uid),o&&(o.innerHTML=""),r.removeInstance(this.uid),e=a=o=r=null}})}return e.FileInput=a}),i(C,[D,u,f,L,l],function(e,t,n,i,r){function o(){function e(e){if(!e.dataTransfer||!e.dataTransfer.types)return!1;var n=t.toArray(e.dataTransfer.types||[]);return-1!==t.inArray("Files",n)||-1!==t.inArray("public.file-url",n)||-1!==t.inArray("application/x-moz-file",n)}function o(e){for(var n=[],i=0;i<e.length;i++)[].push.apply(n,e[i].extensions.split(/\s*,\s*/));return-1===t.inArray("*",n)?n:[]}function a(e){if(!f.length)return!0;var n=r.getFileExtension(e.name);return!n||-1!==t.inArray(n,f)}function s(e,n){var i=[];t.each(e,function(e){var t=e.webkitGetAsEntry();if(t)if(t.isFile){var n=e.getAsFile();a(n)&&d.push(n)}else i.push(t)}),i.length?u(i,n):n()}function u(e,n){var i=[];t.each(e,function(e){i.push(function(t){c(e,t)})}),t.inSeries(i,function(){n()})}function c(e,t){e.isFile?e.file(function(e){a(e)&&d.push(e),t()},function(){t()}):e.isDirectory?l(e,t):t()}function l(e,t){function n(e){r.readEntries(function(t){t.length?([].push.apply(i,t),n(e)):e()},e)}var i=[],r=e.createReader();n(function(){u(i,t)})}var d=[],f=[],h;t.extend(this,{init:function(n){var r=this,u;h=n,f=o(h.accept),u=h.container,i.addEvent(u,"dragover",function(t){e(t)&&(t.preventDefault(),t.dataTransfer.dropEffect="copy")},r.uid),i.addEvent(u,"drop",function(n){e(n)&&(n.preventDefault(),d=[],n.dataTransfer.items&&n.dataTransfer.items[0].webkitGetAsEntry?s(n.dataTransfer.items,function(){r.trigger("drop")}):(t.each(n.dataTransfer.files,function(e){a(e)&&d.push(e)}),r.trigger("drop")))},r.uid),i.addEvent(u,"dragenter",function(e){r.trigger("dragenter")},r.uid),i.addEvent(u,"dragleave",function(e){r.trigger("dragleave")},r.uid)},getFiles:function(){return d},destroy:function(){i.removeAllEvents(h&&n.get(h.container),this.uid),d=f=h=null}})}return e.FileDrop=o}),i(F,[D,m,u],function(e,t,n){function i(){function e(e){return t.atob(e.substring(e.indexOf("base64,")+7))}var i,r=!1;n.extend(this,{read:function(e,t){var o=this;i=new window.FileReader,i.addEventListener("progress",function(e){o.trigger(e)}),i.addEventListener("load",function(e){o.trigger(e)}),i.addEventListener("error",function(e){o.trigger(e,i.error)}),i.addEventListener("loadend",function(){i=null}),"function"===n.typeOf(i[e])?(r=!1,i[e](t.getSource())):"readAsBinaryString"===e&&(r=!0,i.readAsDataURL(t.getSource()))},getResult:function(){return i&&i.result?r?e(i.result):i.result:null},abort:function(){i&&i.abort()},destroy:function(){i=null}})}return e.FileReader=i}),i(H,[D,u,l,R,w,y,A,h,d],function(e,t,n,i,r,o,a,s,u){function c(){function e(e,t){var n=this,i,r;i=t.getBlob().getSource(),r=new window.FileReader,r.onload=function(){t.append(t.getBlobName(),new o(null,{type:i.type,data:r.result})),f.send.call(n,e,t)},r.readAsBinaryString(i)}function c(){return!window.XMLHttpRequest||"IE"===u.browser&&u.version<8?function(){for(var e=["Msxml2.XMLHTTP.6.0","Microsoft.XMLHTTP"],t=0;t<e.length;t++)try{return new ActiveXObject(e[t])}catch(n){}}():new window.XMLHttpRequest}function l(e){var t=e.responseXML,n=e.responseText;return"IE"===u.browser&&n&&t&&!t.documentElement&&/[^\/]+\/[^\+]+\+xml/.test(e.getResponseHeader("Content-Type"))&&(t=new window.ActiveXObject("Microsoft.XMLDOM"),t.async=!1,t.validateOnParse=!1,t.loadXML(n)),t&&("IE"===u.browser&&0!==t.parseError||!t.documentElement||"parsererror"===t.documentElement.tagName)?null:t}function d(e){var t="----moxieboundary"+(new Date).getTime(),n="--",i="\r\n",r="",a=this.getRuntime();if(!a.can("send_binary_string"))throw new s.RuntimeError(s.RuntimeError.NOT_SUPPORTED_ERR);return h.setRequestHeader("Content-Type","multipart/form-data; boundary="+t),e.each(function(e,a){r+=e instanceof o?n+t+i+'Content-Disposition: form-data; name="'+a+'"; filename="'+unescape(encodeURIComponent(e.name||"blob"))+'"'+i+"Content-Type: "+(e.type||"application/octet-stream")+i+i+e.getSource()+i:n+t+i+'Content-Disposition: form-data; name="'+a+'"'+i+i+unescape(encodeURIComponent(e))+i}),r+=n+t+n+i}var f=this,h,p;t.extend(this,{send:function(n,r){var s=this,l="Mozilla"===u.browser&&u.version>=4&&u.version<7,f="Android Browser"===u.browser,m=!1;if(p=n.url.replace(/^.+?\/([\w\-\.]+)$/,"$1").toLowerCase(),h=c(),h.open(n.method,n.url,n.async,n.user,n.password),r instanceof o)r.isDetached()&&(m=!0),r=r.getSource();else if(r instanceof a){if(r.hasBlob())if(r.getBlob().isDetached())r=d.call(s,r),m=!0;else if((l||f)&&"blob"===t.typeOf(r.getBlob().getSource())&&window.FileReader)return void e.call(s,n,r);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}}h.upload?(n.withCredentials&&(h.withCredentials=!0),h.addEventListener("load",function(e){s.trigger(e)}),h.addEventListener("error",function(e){s.trigger(e)}),h.addEventListener("progress",function(e){s.trigger(e)}),h.upload.addEventListener("progress",function(e){s.trigger({type:"UploadProgress",loaded:e.loaded,total:e.total})})):h.onreadystatechange=function v(){switch(h.readyState){case 1:break;case 2:break;case 3:var e,t;try{i.hasSameOrigin(n.url)&&(e=h.getResponseHeader("Content-Length")||0),h.responseText&&(t=h.responseText.length)}catch(r){e=t=0}s.trigger({type:"progress",lengthComputable:!!e,total:parseInt(e,10),loaded:t});break;case 4:h.onreadystatechange=function(){},s.trigger(0===h.status?"error":"load")}},t.isEmptyObj(n.headers)||t.each(n.headers,function(e,t){h.setRequestHeader(t,e)}),""!==n.responseType&&"responseType"in h&&("json"!==n.responseType||u.can("return_response_type","json")?h.responseType=n.responseType:h.responseType="text"),m?h.sendAsBinary?h.sendAsBinary(r):!function(){for(var e=new Uint8Array(r.length),t=0;t<r.length;t++)e[t]=255&r.charCodeAt(t);h.send(e.buffer)}():h.send(r),s.trigger("loadstart")},getStatus:function(){try{if(h)return h.status}catch(e){}return 0},getResponse:function(e){var t=this.getRuntime();try{switch(e){case"blob":var i=new r(t.uid,h.response),o=h.getResponseHeader("Content-Disposition");if(o){var a=o.match(/filename=([\'\"'])([^\1]+)\1/);a&&(p=a[2])}return i.name=p,i.type||(i.type=n.getFileMime(p)),i;case"json":return u.can("return_response_type","json")?h.response:200===h.status&&window.JSON?JSON.parse(h.responseText):null;case"document":return l(h);default:return""!==h.responseText?h.responseText:null}}catch(s){return null}},getAllResponseHeaders:function(){try{return h.getAllResponseHeaders()}catch(e){}return""},abort:function(){h&&h.abort()},destroy:function(){f=p=null}})}return e.XMLHttpRequest=c}),i(P,[],function(){return function(){function e(e,t){var n=r?0:-8*(t-1),i=0,a;for(a=0;t>a;a++)i|=o.charCodeAt(e+a)<<Math.abs(n+8*a);return i}function n(e,t,n){n=3===arguments.length?n:o.length-t-1,o=o.substr(0,t)+e+o.substr(n+t)}function i(e,t,i){var o="",a=r?0:-8*(i-1),s;for(s=0;i>s;s++)o+=String.fromCharCode(t>>Math.abs(a+8*s)&255);n(o,e,i)}var r=!1,o;return{II:function(e){return e===t?r:void(r=e)},init:function(e){r=!1,o=e},SEGMENT:function(e,t,i){switch(arguments.length){case 1:return o.substr(e,o.length-e-1);case 2:return o.substr(e,t);case 3:n(i,e,t);break;default:return o}},BYTE:function(t){return e(t,1)},SHORT:function(t){return e(t,2)},LONG:function(n,r){return r===t?e(n,4):void i(n,r,4)},SLONG:function(t){var n=e(t,4);return n>2147483647?n-4294967296:n},STRING:function(t,n){var i="";for(n+=t;n>t;t++)i+=String.fromCharCode(e(t,1));return i}}}}),i(k,[P],function(e){return function t(n){var i=[],r,o,a,s=0;if(r=new e,r.init(n),65496===r.SHORT(0)){for(o=2;o<=n.length;)if(a=r.SHORT(o),a>=65488&&65495>=a)o+=2;else{if(65498===a||65497===a)break;s=r.SHORT(o+2)+2,a>=65505&&65519>=a&&i.push({hex:a,name:"APP"+(15&a),start:o,length:s,segment:r.SEGMENT(o,s)}),o+=s}return r.init(null),{headers:i,restore:function(e){var t,n;for(r.init(e),o=65504==r.SHORT(2)?4+r.SHORT(4):2,n=0,t=i.length;t>n;n++)r.SEGMENT(o,0,i[n].segment),o+=i[n].length;return e=r.SEGMENT(),r.init(null),e},strip:function(e){var n,i,o;for(i=new t(e),n=i.headers,i.purge(),r.init(e),o=n.length;o--;)r.SEGMENT(n[o].start,n[o].length,"");return e=r.SEGMENT(),r.init(null),e},get:function(e){for(var t=[],n=0,r=i.length;r>n;n++)i[n].name===e.toUpperCase()&&t.push(i[n].segment);return t},set:function(e,t){var n=[],r,o,a;for("string"==typeof t?n.push(t):n=t,r=o=0,a=i.length;a>r&&(i[r].name===e.toUpperCase()&&(i[r].segment=n[o],i[r].length=n[o].length,o++),!(o>=n.length));r++);},purge:function(){i=[],r.init(null),r=null}}}}}),i(U,[u,P],function(e,n){return function i(){function i(e,n){var i=a.SHORT(e),r,o,s,u,d,f,h,p,m=[],g={};for(r=0;i>r;r++)if(h=f=e+12*r+2,s=n[a.SHORT(h)],s!==t){switch(u=a.SHORT(h+=2),d=a.LONG(h+=2),h+=4,m=[],u){case 1:case 7:for(d>4&&(h=a.LONG(h)+c.tiffHeader),o=0;d>o;o++)m[o]=a.BYTE(h+o);break;case 2:d>4&&(h=a.LONG(h)+c.tiffHeader),g[s]=a.STRING(h,d-1);continue;case 3:for(d>2&&(h=a.LONG(h)+c.tiffHeader),o=0;d>o;o++)m[o]=a.SHORT(h+2*o);break;case 4:for(d>1&&(h=a.LONG(h)+c.tiffHeader),o=0;d>o;o++)m[o]=a.LONG(h+4*o);break;case 5:for(h=a.LONG(h)+c.tiffHeader,o=0;d>o;o++)m[o]=a.LONG(h+4*o)/a.LONG(h+4*o+4);break;case 9:for(h=a.LONG(h)+c.tiffHeader,o=0;d>o;o++)m[o]=a.SLONG(h+4*o);break;case 10:for(h=a.LONG(h)+c.tiffHeader,o=0;d>o;o++)m[o]=a.SLONG(h+4*o)/a.SLONG(h+4*o+4);break;default:continue}p=1==d?m[0]:m,l.hasOwnProperty(s)&&"object"!=typeof p?g[s]=l[s][p]:g[s]=p}return g}function r(){var e=c.tiffHeader;return a.II(18761==a.SHORT(e)),42!==a.SHORT(e+=2)?!1:(c.IFD0=c.tiffHeader+a.LONG(e+=2),u=i(c.IFD0,s.tiff),"ExifIFDPointer"in u&&(c.exifIFD=c.tiffHeader+u.ExifIFDPointer,delete u.ExifIFDPointer),"GPSInfoIFDPointer"in u&&(c.gpsIFD=c.tiffHeader+u.GPSInfoIFDPointer,delete u.GPSInfoIFDPointer),!0)}function o(e,t,n){var i,r,o,u=0;if("string"==typeof t){var l=s[e.toLowerCase()];for(var d in l)if(l[d]===t){t=d;break}}i=c[e.toLowerCase()+"IFD"],r=a.SHORT(i);for(var f=0;r>f;f++)if(o=i+12*f+2,a.SHORT(o)==t){u=o+8;break}return u?(a.LONG(u,n),!0):!1}var a,s,u,c={},l;return a=new n,s={tiff:{274:"Orientation",270:"ImageDescription",271:"Make",272:"Model",305:"Software",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer"},exif:{36864:"ExifVersion",
15
+ 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"}},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"}},{init:function(e){return c={tiffHeader:10},e!==t&&e.length?(a.init(e),65505===a.SHORT(0)&&"EXIF\x00"===a.STRING(4,5).toUpperCase()?r():!1):!1},TIFF:function(){return u},EXIF:function(){var t;if(t=i(c.exifIFD,s.exif),t.ExifVersion&&"array"===e.typeOf(t.ExifVersion)){for(var n=0,r="";n<t.ExifVersion.length;n++)r+=String.fromCharCode(t.ExifVersion[n]);t.ExifVersion=r}return t},GPS:function(){var t;return t=i(c.gpsIFD,s.gps),t.GPSVersionID&&"array"===e.typeOf(t.GPSVersionID)&&(t.GPSVersionID=t.GPSVersionID.join(".")),t},setExif:function(e,t){return"PixelXDimension"!==e&&"PixelYDimension"!==e?!1:o("exif",e,t)},getBinary:function(){return a.SEGMENT()},purge:function(){a.init(null),a=u=null,c={}}}}}),i(B,[u,h,k,P,U],function(e,t,n,i,r){function o(o){function a(){for(var e=0,t,n;e<=u.length;){if(t=c.SHORT(e+=2),t>=65472&&65475>=t)return e+=5,{height:c.SHORT(e),width:c.SHORT(e+=2)};n=c.SHORT(e+=2),e+=n-2}return null}function s(){d&&l&&c&&(d.purge(),l.purge(),c.init(null),u=f=l=d=c=null)}var u,c,l,d,f,h;if(u=o,c=new i,c.init(u),65496!==c.SHORT(0))throw new t.ImageError(t.ImageError.WRONG_FORMAT);l=new n(o),d=new r,h=!!d.init(l.get("app1")[0]),f=a.call(this),e.extend(this,{type:"image/jpeg",size:u.length,width:f&&f.width||0,height:f&&f.height||0,setExif:function(t,n){return h?("object"===e.typeOf(t)?e.each(t,function(e,t){d.setExif(t,e)}):d.setExif(t,n),void l.set("app1",d.getBinary())):!1},writeHeaders:function(){return arguments.length?l.restore(arguments[0]):u=l.restore(u)},stripHeaders:function(e){return l.strip(e)},purge:function(){s.call(this)}}),h&&(this.meta={tiff:d.TIFF(),exif:d.EXIF(),gps:d.GPS()})}return o}),i(z,[h,u,P],function(e,t,n){function i(i){function r(){var e,t;return e=a.call(this,8),"IHDR"==e.type?(t=e.start,{width:u.LONG(t),height:u.LONG(t+=4)}):null}function o(){u&&(u.init(null),s=d=c=l=u=null)}function a(e){var t,n,i,r;return t=u.LONG(e),n=u.STRING(e+=4,4),i=e+=4,r=u.LONG(e+t),{length:t,type:n,start:i,CRC:r}}var s,u,c,l,d;s=i,u=new n,u.init(s),function(){var t=0,n=0,i=[35152,20039,3338,6666];for(n=0;n<i.length;n++,t+=2)if(i[n]!=u.SHORT(t))throw new e.ImageError(e.ImageError.WRONG_FORMAT)}(),d=r.call(this),t.extend(this,{type:"image/png",size:s.length,width:d.width,height:d.height,purge:function(){o.call(this)}}),o.call(this)}return i}),i(G,[u,h,B,z],function(e,t,n,i){return function(r){var o=[n,i],a;a=function(){for(var e=0;e<o.length;e++)try{return new o[e](r)}catch(n){}throw new t.ImageError(t.ImageError.WRONG_FORMAT)}(),e.extend(this,{type:"",size:0,width:0,height:0,setExif:function(){},writeHeaders:function(e){return e},stripHeaders:function(e){return e},purge:function(){}}),e.extend(this,a),this.purge=function(){a.purge(),a=null}}}),i(q,[],function(){function e(e,i,r){var o=e.naturalWidth,a=e.naturalHeight,s=r.width,u=r.height,c=r.x||0,l=r.y||0,d=i.getContext("2d");t(e)&&(o/=2,a/=2);var f=1024,h=document.createElement("canvas");h.width=h.height=f;for(var p=h.getContext("2d"),m=n(e,o,a),g=0;a>g;){for(var v=g+f>a?a-g:f,y=0;o>y;){var w=y+f>o?o-y:f;p.clearRect(0,0,f,f),p.drawImage(e,-y,-g);var E=y*s/o+c<<0,_=Math.ceil(w*s/o),x=g*u/a/m+l<<0,b=Math.ceil(v*u/a/m);d.drawImage(h,0,0,w,v,E,x,_,b),y+=f}g+=f}h=p=null}function t(e){var t=e.naturalWidth,n=e.naturalHeight;if(t*n>1048576){var i=document.createElement("canvas");i.width=i.height=1;var r=i.getContext("2d");return r.drawImage(e,-t+1,0),0===r.getImageData(0,0,1,1).data[3]}return!1}function n(e,t,n){var i=document.createElement("canvas");i.width=1,i.height=n;var r=i.getContext("2d");r.drawImage(e,0,0);for(var o=r.getImageData(0,0,1,n).data,a=0,s=n,u=n;u>a;){var c=o[4*(u-1)+3];0===c?s=u:a=u,u=s+a>>1}i=null;var l=u/n;return 0===l?1:l}return{isSubsampled:t,renderTo:e}}),i(X,[D,u,h,m,w,G,q,l,d],function(e,t,n,i,r,o,a,s,u){function c(){function e(){if(!E&&!y)throw new n.ImageError(n.DOMException.INVALID_STATE_ERR);return E||y}function c(e){return i.atob(e.substring(e.indexOf("base64,")+7))}function l(e,t){return"data:"+(t||"")+";base64,"+i.btoa(e)}function d(e){var t=this;y=new Image,y.onerror=function(){g.call(this),t.trigger("error",n.ImageError.WRONG_FORMAT)},y.onload=function(){t.trigger("load")},y.src=/^data:[^;]*;base64,/.test(e)?e:l(e,x.type)}function f(e,t){var i=this,r;return window.FileReader?(r=new FileReader,r.onload=function(){t(this.result)},r.onerror=function(){i.trigger("error",n.ImageError.WRONG_FORMAT)},r.readAsDataURL(e),void 0):t(e.getAsDataURL())}function h(n,i,r,o){var a=this,s,u,c=0,l=0,d,f,h,g;if(R=o,g=this.meta&&this.meta.tiff&&this.meta.tiff.Orientation||1,-1!==t.inArray(g,[5,6,7,8])){var v=n;n=i,i=v}return d=e(),r?(n=Math.min(n,d.width),i=Math.min(i,d.height),s=Math.max(n/d.width,i/d.height)):s=Math.min(n/d.width,i/d.height),s>1&&!r&&o?void this.trigger("Resize"):(E||(E=document.createElement("canvas")),f=Math.round(d.width*s),h=Math.round(d.height*s),r?(E.width=n,E.height=i,f>n&&(c=Math.round((f-n)/2)),h>i&&(l=Math.round((h-i)/2))):(E.width=f,E.height=h),R||m(E.width,E.height,g),p.call(this,d,E,-c,-l,f,h),this.width=E.width,this.height=E.height,b=!0,void a.trigger("Resize"))}function p(e,t,n,i,r,o){if("iOS"===u.OS)a.renderTo(e,t,{width:r,height:o,x:n,y:i});else{var s=t.getContext("2d");s.drawImage(e,n,i,r,o)}}function m(e,t,n){switch(n){case 5:case 6:case 7:case 8:E.width=t,E.height=e;break;default:E.width=e,E.height=t}var i=E.getContext("2d");switch(n){case 2:i.translate(e,0),i.scale(-1,1);break;case 3:i.translate(e,t),i.rotate(Math.PI);break;case 4:i.translate(0,t),i.scale(1,-1);break;case 5:i.rotate(.5*Math.PI),i.scale(1,-1);break;case 6:i.rotate(.5*Math.PI),i.translate(0,-t);break;case 7:i.rotate(.5*Math.PI),i.translate(e,-t),i.scale(-1,1);break;case 8:i.rotate(-.5*Math.PI),i.translate(-e,0)}}function g(){w&&(w.purge(),w=null),_=y=E=x=null,b=!1}var v=this,y,w,E,_,x,b=!1,R=!0;t.extend(this,{loadFromBlob:function(e){var t=this,i=t.getRuntime(),r=arguments.length>1?arguments[1]:!0;if(!i.can("access_binary"))throw new n.RuntimeError(n.RuntimeError.NOT_SUPPORTED_ERR);return x=e,e.isDetached()?(_=e.getSource(),void d.call(this,_)):void f.call(this,e.getSource(),function(e){r&&(_=c(e)),d.call(t,e)})},loadFromImage:function(e,t){this.meta=e.meta,x=new r(null,{name:e.name,size:e.size,type:e.type}),d.call(this,t?_=e.getAsBinaryString():e.getAsDataURL())},getInfo:function(){var t=this.getRuntime(),n;return!w&&_&&t.can("access_image_binary")&&(w=new o(_)),n={width:e().width||0,height:e().height||0,type:x.type||s.getFileMime(x.name),size:_&&_.length||x.size||0,name:x.name||"",meta:w&&w.meta||this.meta||{}}},downsize:function(){h.apply(this,arguments)},getAsCanvas:function(){return E&&(E.id=this.uid+"_canvas"),E},getAsBlob:function(e,t){return e!==this.type&&h.call(this,this.width,this.height,!1),new r(null,{name:x.name||"",type:e,data:v.getAsBinaryString.call(this,e,t)})},getAsDataURL:function(e){var t=arguments[1]||90;if(!b)return y.src;if("image/jpeg"!==e)return E.toDataURL("image/png");try{return E.toDataURL("image/jpeg",t/100)}catch(n){return E.toDataURL("image/jpeg")}},getAsBinaryString:function(e,t){if(!b)return _||(_=c(v.getAsDataURL(e,t))),_;if("image/jpeg"!==e)_=c(v.getAsDataURL(e,t));else{var n;t||(t=90);try{n=E.toDataURL("image/jpeg",t/100)}catch(i){n=E.toDataURL("image/jpeg")}_=c(n),w&&(_=w.stripHeaders(_),R&&(w.meta&&w.meta.exif&&w.setExif({PixelXDimension:this.width,PixelYDimension:this.height}),_=w.writeHeaders(_)),w.purge(),w=null)}return b=!1,_},destroy:function(){v=null,g.call(this),this.getRuntime().getShim().removeInstance(this.uid)}})}return e.Image=c}),i(j,[u,d,f,h,g],function(e,t,n,i,r){function o(){var e;try{e=navigator.plugins["Shockwave Flash"],e=e.description}catch(t){try{e=new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version")}catch(n){e="0.0"}}return e=e.match(/\d+/g),parseFloat(e[0]+"."+e[1])}function a(a){var c=this,l;a=e.extend({swf_url:t.swf_url},a),r.call(this,a,s,{access_binary:function(e){return e&&"browser"===c.mode},access_image_binary:function(e){return e&&"browser"===c.mode},display_media:r.capTrue,do_cors:r.capTrue,drag_and_drop:!1,report_upload_progress:function(){return"client"===c.mode},resize_image:r.capTrue,return_response_headers:!1,return_response_type:function(t){return"json"===t&&window.JSON?!0:!e.arrayDiff(t,["","text","document"])||"browser"===c.mode},return_status_code:function(t){return"browser"===c.mode||!e.arrayDiff(t,[200,404])},select_file:r.capTrue,select_multiple:r.capTrue,send_binary_string:function(e){return e&&"browser"===c.mode},send_browser_cookies:function(e){return e&&"browser"===c.mode},send_custom_headers:function(e){return e&&"browser"===c.mode},send_multipart:r.capTrue,slice_blob:function(e){return e&&"browser"===c.mode},stream_upload:function(e){return e&&"browser"===c.mode},summon_file_dialog:!1,upload_filesize:function(t){return e.parseSizeStr(t)<=2097152||"client"===c.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"},stream_upload:function(e){return e?"client":"browser"},upload_filesize:function(t){return e.parseSizeStr(t)>=2097152?"client":"browser"}},"client"),o()<10&&(this.mode=!1),e.extend(this,{getShim:function(){return n.get(this.uid)},shimExec:function(e,t){var n=[].slice.call(arguments,2);return c.getShim().exec(this.uid,e,t,n)},init:function(){var n,r,o;o=this.getShimContainer(),e.extend(o.style,{position:"absolute",top:"-8px",left:"-8px",width:"9px",height:"9px",overflow:"hidden"}),n='<object id="'+this.uid+'" type="application/x-shockwave-flash" data="'+a.swf_url+'" ',"IE"===t.browser&&(n+='classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '),n+='width="100%" height="100%" style="outline:0"><param name="movie" value="'+a.swf_url+'" /><param name="flashvars" value="uid='+escape(this.uid)+"&target="+t.global_event_dispatcher+'" /><param name="wmode" value="transparent" /><param name="allowscriptaccess" value="always" /></object>',"IE"===t.browser?(r=document.createElement("div"),o.appendChild(r),r.outerHTML=n,r=o=null):o.innerHTML=n,l=setTimeout(function(){c&&!c.initialized&&c.trigger("Error",new i.RuntimeError(i.RuntimeError.NOT_INIT_ERR))},5e3)},destroy:function(e){return function(){e.call(c),clearTimeout(l),a=l=e=c=null}}(this.destroy)},u)}var s="flash",u={};return r.addConstructor(s,a),u}),i(V,[j,y],function(e,t){var n={slice:function(e,n,i,r){var o=this.getRuntime();return 0>n?n=Math.max(e.size+n,0):n>0&&(n=Math.min(n,e.size)),0>i?i=Math.max(e.size+i,0):i>0&&(i=Math.min(i,e.size)),e=o.shimExec.call(this,"Blob","slice",n,i,r||""),e&&(e=new t(o.uid,e)),e}};return e.Blob=n}),i(W,[j],function(e){var t={init:function(e){this.getRuntime().shimExec.call(this,"FileInput","init",{name:e.name,accept:e.accept,multiple:e.multiple}),this.trigger("ready")}};return e.FileInput=t}),i(Y,[j,m],function(e,t){function n(e,n){switch(n){case"readAsText":return t.atob(e,"utf8");case"readAsBinaryString":return t.atob(e);case"readAsDataURL":return e}return null}var i="",r={read:function(e,t){var r=this,o=r.getRuntime();return"readAsDataURL"===e&&(i="data:"+(t.type||"")+";base64,"),r.bind("Progress",function(t,r){r&&(i+=n(r,e))}),o.shimExec.call(this,"FileReader","readAsBase64",t.uid)},getResult:function(){return i},destroy:function(){i=null}};return e.FileReader=r}),i($,[j,m],function(e,t){function n(e,n){switch(n){case"readAsText":return t.atob(e,"utf8");case"readAsBinaryString":return t.atob(e);case"readAsDataURL":return e}return null}var i={read:function(e,t){var i,r=this.getRuntime();return(i=r.shimExec.call(this,"FileReaderSync","readAsBase64",t.uid))?("readAsDataURL"===e&&(i="data:"+(t.type||"")+";base64,"+i),n(i,e,t.type)):null}};return e.FileReaderSync=i}),i(J,[j,u,y,w,T,A,O],function(e,t,n,i,r,o,a){var s={send:function(e,i){function r(){e.transport=l.mode,l.shimExec.call(c,"XMLHttpRequest","send",e,i)}function s(e,t){l.shimExec.call(c,"XMLHttpRequest","appendBlob",e,t.uid),i=null,r()}function u(e,t){var n=new a;n.bind("TransportingComplete",function(){t(this.result)}),n.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())}),i instanceof o){var d;if(i.each(function(e,t){e instanceof n?d=t:l.shimExec.call(c,"XMLHttpRequest","append",t,e)}),i.hasBlob()){var f=i.getBlob();f.isDetached()?u(f,function(e){f.destroy(),s(d,e)}):s(d,f)}else i=null,r()}else i instanceof n?i.isDetached()?u(i,function(e){i.destroy(),i=e.uid,r()}):(i=i.uid,r()):r()},getResponse:function(e){var n,o,a=this.getRuntime();if(o=a.shimExec.call(this,"XMLHttpRequest","getResponseAsBlob")){if(o=new i(a.uid,o),"blob"===e)return o;try{if(n=new r,~t.inArray(e,["","text"]))return n.readAsText(o);if("json"===e&&window.JSON)return JSON.parse(n.readAsText(o))}finally{o.destroy()}}return null},abort:function(e){var t=this.getRuntime();t.shimExec.call(this,"XMLHttpRequest","abort"),this.dispatchEvent("readystatechange"),this.dispatchEvent("abort")}};return e.XMLHttpRequest=s}),i(Z,[j,y],function(e,t){var n={getAsBlob:function(e){var n=this.getRuntime(),i=n.shimExec.call(this,"Transporter","getAsBlob",e);return i?new t(n.uid,i):null}};return e.Transporter=n}),i(K,[j,u,O,y,T],function(e,t,n,i,r){var o={loadFromBlob:function(e){function t(e){r.shimExec.call(i,"Image","loadFromBlob",e.uid),i=r=null}var i=this,r=i.getRuntime();if(e.isDetached()){var o=new n;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)},getAsBlob:function(e,t){var n=this.getRuntime(),r=n.shimExec.call(this,"Image","getAsBlob",e,t);return r?new i(n.uid,r):null},getAsDataURL:function(){var e=this.getRuntime(),t=e.Image.getAsBlob.apply(this,arguments),n;return t?(n=new r,n.readAsDataURL(t)):null}};return e.Image=o}),i(Q,[u,d,f,h,g],function(e,t,n,i,r){function o(e){var t=!1,n=null,i,r,o,a,s,u=0;try{try{n=new ActiveXObject("AgControl.AgControl"),n.IsVersionSupported(e)&&(t=!0),n=null}catch(c){var l=navigator.plugins["Silverlight Plug-In"];if(l){for(i=l.description,"1.0.30226.2"===i&&(i="2.0.30226.2"),r=i.split(".");r.length>3;)r.pop();for(;r.length<4;)r.push(0);for(o=e.split(".");o.length>4;)o.pop();do a=parseInt(o[u],10),s=parseInt(r[u],10),u++;while(u<o.length&&a===s);s>=a&&!isNaN(a)&&(t=!0)}}}catch(d){t=!1}return t}function a(a){var c=this,l;a=e.extend({xap_url:t.xap_url},a),r.call(this,a,s,{access_binary:r.capTrue,access_image_binary:r.capTrue,display_media:r.capTrue,do_cors:r.capTrue,drag_and_drop:!1,report_upload_progress:r.capTrue,resize_image:r.capTrue,return_response_headers:function(e){return e&&"client"===c.mode},return_response_type:function(e){return"json"!==e?!0:!!window.JSON},return_status_code:function(t){return"client"===c.mode||!e.arrayDiff(t,[200,404])},select_file:r.capTrue,select_multiple:r.capTrue,send_binary_string:r.capTrue,send_browser_cookies:function(e){return e&&"browser"===c.mode},send_custom_headers:function(e){return e&&"client"===c.mode},send_multipart:r.capTrue,slice_blob:r.capTrue,stream_upload:!0,summon_file_dialog:!1,upload_filesize:r.capTrue,use_http_method:function(t){return"client"===c.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"]}}),o("2.0.31005.0")&&"Opera"!==t.browser||(this.mode=!1),e.extend(this,{getShim:function(){return n.get(this.uid).content.Moxie},shimExec:function(e,t){var n=[].slice.call(arguments,2);return c.getShim().exec(this.uid,e,t,n)},init:function(){var e;e=this.getShimContainer(),e.innerHTML='<object id="'+this.uid+'" data="data:application/x-silverlight," type="application/x-silverlight-2" width="100%" height="100%" style="outline:none;"><param name="source" value="'+a.xap_url+'"/><param name="background" value="Transparent"/><param name="windowless" value="true"/><param name="enablehtmlaccess" value="true"/><param name="initParams" value="uid='+this.uid+",target="+t.global_event_dispatcher+'"/></object>',l=setTimeout(function(){c&&!c.initialized&&c.trigger("Error",new i.RuntimeError(i.RuntimeError.NOT_INIT_ERR))},"Windows"!==t.OS?1e4:5e3)},destroy:function(e){return function(){e.call(c),clearTimeout(l),a=l=e=c=null}}(this.destroy)},u)}var s="silverlight",u={};return r.addConstructor(s,a),u}),i(ee,[Q,u,V],function(e,t,n){return e.Blob=t.extend({},n)}),i(te,[Q],function(e){var t={init:function(e){function t(e){for(var t="",n=0;n<e.length;n++)t+=(""!==t?"|":"")+e[n].title+" | *."+e[n].extensions.replace(/,/g,";*.");return t}this.getRuntime().shimExec.call(this,"FileInput","init",t(e.accept),e.name,e.multiple),this.trigger("ready")}};return e.FileInput=t}),i(ne,[Q,f,L],function(e,t,n){var i={init:function(){var e=this,i=e.getRuntime(),r;return r=i.getShimContainer(),n.addEvent(r,"dragover",function(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="copy"},e.uid),n.addEvent(r,"dragenter",function(e){e.preventDefault();var n=t.get(i.uid).dragEnter(e);n&&e.stopPropagation()},e.uid),n.addEvent(r,"drop",function(e){e.preventDefault();var n=t.get(i.uid).dragDrop(e);n&&e.stopPropagation()},e.uid),i.shimExec.call(this,"FileDrop","init")}};return e.FileDrop=i}),i(ie,[Q,u,Y],function(e,t,n){return e.FileReader=t.extend({},n)}),i(re,[Q,u,$],function(e,t,n){return e.FileReaderSync=t.extend({},n)}),i(oe,[Q,u,J],function(e,t,n){return e.XMLHttpRequest=t.extend({},n)}),i(ae,[Q,u,Z],function(e,t,n){return e.Transporter=t.extend({},n)}),i(se,[Q,u,K],function(e,t,n){return e.Image=t.extend({},n,{getInfo:function(){var e=this.getRuntime(),n=["tiff","exif","gps"],i={meta:{}},r=e.shimExec.call(this,"Image","getInfo");return r.meta&&t.each(n,function(e){var t=r.meta[e],n,o,a,s;if(t&&t.keys)for(i.meta[e]={},o=0,a=t.keys.length;a>o;o++)n=t.keys[o],s=t[n],s&&(/^(\d|[1-9]\d+)$/.test(s)?s=parseInt(s,10):/^\d*\.\d+$/.test(s)&&(s=parseFloat(s)),i.meta[e][n]=s)}),i.width=parseInt(r.width,10),i.height=parseInt(r.height,10),i.size=parseInt(r.size,10),i.type=r.type,i.name=r.name,i}})}),i(ue,[u,h,g,d],function(e,t,n,i){function r(t){var r=this,s=n.capTest,u=n.capTrue;n.call(this,t,o,{access_binary:s(window.FileReader||window.File&&File.getAsDataURL),access_image_binary:!1,display_media:s(a.Image&&(i.can("create_canvas")||i.can("use_data_uri_over32kb"))),do_cors:!1,drag_and_drop:!1,filter_by_extension:s(function(){return"Chrome"===i.browser&&i.version>=28||"IE"===i.browser&&i.version>=10}()),resize_image:function(){return a.Image&&r.can("access_binary")&&i.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 i.can("use_fileinput")},select_multiple:!1,send_binary_string:!1,send_custom_headers:!1,send_multipart:!0,slice_blob:!1,stream_upload:function(){return r.can("select_file")},summon_file_dialog:s(function(){return"Firefox"===i.browser&&i.version>=4||"Opera"===i.browser&&i.version>=12||!!~e.inArray(i.browser,["Chrome","Safari"])}()),upload_filesize:u,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(r),e=r=null}}(this.destroy)}),e.extend(this.getShim(),a)}var o="html4",a={};return n.addConstructor(o,r),a}),i(ce,[ue,u,f,L,l,d],function(e,t,n,i,r,o){function a(){function e(){var r=this,l=r.getRuntime(),d,f,h,p,m,g;g=t.guid("uid_"),d=l.getShimContainer(),a&&(h=n.get(a+"_form"),h&&t.extend(h.style,{top:"100%"})),p=document.createElement("form"),p.setAttribute("id",g+"_form"),p.setAttribute("method","post"),p.setAttribute("enctype","multipart/form-data"),p.setAttribute("encoding","multipart/form-data"),t.extend(p.style,{overflow:"hidden",position:"absolute",top:0,left:0,width:"100%",height:"100%"}),m=document.createElement("input"),m.setAttribute("id",g),m.setAttribute("type","file"),m.setAttribute("name",c.name||"Filedata"),m.setAttribute("accept",u.join(",")),t.extend(m.style,{fontSize:"999px",opacity:0}),p.appendChild(m),d.appendChild(p),t.extend(m.style,{position:"absolute",top:0,left:0,width:"100%",height:"100%"}),"IE"===o.browser&&o.version<10&&t.extend(m.style,{filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=0)"}),m.onchange=function(){var t;this.value&&(t=this.files?this.files[0]:{name:this.value},s=[t],this.onchange=function(){},e.call(r),r.bind("change",function i(){var e=n.get(g),t=n.get(g+"_form"),o;r.unbind("change",i),r.files.length&&e&&t&&(o=r.files[0],e.setAttribute("id",o.uid),t.setAttribute("id",o.uid+"_form"),t.setAttribute("target",o.uid+"_iframe")),e=t=null},998),m=p=null,r.trigger("change"))},l.can("summon_file_dialog")&&(f=n.get(c.browse_button),i.removeEvent(f,"click",r.uid),i.addEvent(f,"click",function(e){m&&!m.disabled&&m.click(),e.preventDefault()},r.uid)),a=g,d=h=f=null}var a,s=[],u=[],c;t.extend(this,{init:function(t){var o=this,a=o.getRuntime(),s;c=t,u=t.accept.mimes||r.extList2mimes(t.accept,a.can("filter_by_extension")),s=a.getShimContainer(),function(){var e,r,u;e=n.get(t.browse_button),a.can("summon_file_dialog")&&("static"===n.getStyle(e,"position")&&(e.style.position="relative"),r=parseInt(n.getStyle(e,"z-index"),10)||1,e.style.zIndex=r,s.style.zIndex=r-1),u=a.can("summon_file_dialog")?e:s,i.addEvent(u,"mouseover",function(){o.trigger("mouseenter")},o.uid),i.addEvent(u,"mouseout",function(){o.trigger("mouseleave")},o.uid),i.addEvent(u,"mousedown",function(){o.trigger("mousedown")},o.uid),i.addEvent(n.get(t.container),"mouseup",function(){o.trigger("mouseup")},o.uid),e=null}(),e.call(this),s=null,o.trigger({type:"ready",async:!0})},getFiles:function(){return s},disable:function(e){var t;(t=n.get(a))&&(t.disabled=!!e)},destroy:function(){var e=this.getRuntime(),t=e.getShim(),r=e.getShimContainer();i.removeAllEvents(r,this.uid),i.removeAllEvents(c&&n.get(c.container),this.uid),i.removeAllEvents(c&&n.get(c.browse_button),this.uid),r&&(r.innerHTML=""),t.removeInstance(this.uid),a=s=u=c=r=t=null}})}return e.FileInput=a}),i(le,[ue,F],function(e,t){return e.FileReader=t}),i(de,[ue,u,f,R,h,L,y,A],function(e,t,n,i,r,o,a,s){function u(){function e(e){var t=this,i,r,a,s,u=!1;if(l){if(i=l.id.replace(/_iframe$/,""),r=n.get(i+"_form")){for(a=r.getElementsByTagName("input"),s=a.length;s--;)switch(a[s].getAttribute("type")){case"hidden":a[s].parentNode.removeChild(a[s]);break;case"file":u=!0}a=[],u||r.parentNode.removeChild(r),r=null}setTimeout(function(){o.removeEvent(l,"load",t.uid),l.parentNode&&l.parentNode.removeChild(l);var n=t.getRuntime().getShimContainer();n.children.length||n.parentNode.removeChild(n),n=l=null,e()},1)}}var u,c,l;t.extend(this,{send:function(d,f){function h(){var n=m.getShimContainer()||document.body,r=document.createElement("div");r.innerHTML='<iframe id="'+g+'_iframe" name="'+g+'_iframe" src="javascript:&quot;&quot;" style="display:none"></iframe>',l=r.firstChild,n.appendChild(l),o.addEvent(l,"load",function(){var n;try{n=l.contentWindow.document||l.contentDocument||window.frames[l.id].document,/^4(0[0-9]|1[0-7]|2[2346])\s/.test(n.title)?u=n.title.replace(/^(\d+).*$/,"$1"):(u=200,c=t.trim(n.body.innerHTML),p.trigger({type:"progress",loaded:c.length,total:c.length}),w&&p.trigger({type:"uploadprogress",loaded:w.size||1025,total:w.size||1025}))}catch(r){if(!i.hasSameOrigin(d.url))return void e.call(p,function(){p.trigger("error")});u=404}e.call(p,function(){p.trigger("load")})},p.uid)}var p=this,m=p.getRuntime(),g,v,y,w;if(u=c=null,f instanceof s&&f.hasBlob()){if(w=f.getBlob(),g=w.uid,y=n.get(g),v=n.get(g+"_form"),!v)throw new r.DOMException(r.DOMException.NOT_FOUND_ERR)}else g=t.guid("uid_"),v=document.createElement("form"),v.setAttribute("id",g+"_form"),v.setAttribute("method",d.method),v.setAttribute("enctype","multipart/form-data"),v.setAttribute("encoding","multipart/form-data"),v.setAttribute("target",g+"_iframe"),m.getShimContainer().appendChild(v);f instanceof s&&f.each(function(e,n){if(e instanceof a)y&&y.setAttribute("name",n);else{var i=document.createElement("input");t.extend(i,{type:"hidden",name:n,value:e}),y?v.insertBefore(i,y):v.appendChild(i)}}),v.setAttribute("action",d.url),h(),v.submit(),p.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*<pre[^>]*>/,"").replace(/<\/pre>\s*$/,""))}catch(n){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")})}})}return e.XMLHttpRequest=u}),i(fe,[ue,X],function(e,t){return e.Image=t}),a([u,c,l,d,f,h,p,m,g,v,y,w,E,_,x,b,R,T,A,S,O,I,L])}(this);;(function(e){"use strict";var t={},n=e.moxie.core.utils.Basic.inArray;return function r(e){var i,s;for(i in e)s=typeof e[i],s==="object"&&!~n(i,["Exceptions","Env","Mime"])?r(e[i]):s==="function"&&(t[i]=e[i])}(e.moxie),t.Env=e.moxie.core.utils.Env,t.Mime=e.moxie.core.utils.Mime,t.Exceptions=e.moxie.core.Exceptions,e.mOxie=t,e.o||(e.o=t),t})(this);
@@ -0,0 +1,2315 @@
1
+ /**
2
+ * Plupload - multi-runtime File Uploader
3
+ * v2.1.3
4
+ *
5
+ * Copyright 2013, Moxiecode Systems AB
6
+ * Released under GPL License.
7
+ *
8
+ * License: http://www.plupload.com/license
9
+ * Contributing: http://www.plupload.com/contributing
10
+ *
11
+ * Date: 2015-05-11
12
+ */
13
+ /**
14
+ * Plupload.js
15
+ *
16
+ * Copyright 2013, Moxiecode Systems AB
17
+ * Released under GPL License.
18
+ *
19
+ * License: http://www.plupload.com/license
20
+ * Contributing: http://www.plupload.com/contributing
21
+ */
22
+
23
+ /*global mOxie:true */
24
+
25
+ ;(function(window, o, undef) {
26
+
27
+ var delay = window.setTimeout
28
+ , fileFilters = {}
29
+ ;
30
+
31
+ // convert plupload features to caps acceptable by mOxie
32
+ function normalizeCaps(settings) {
33
+ var features = settings.required_features, caps = {};
34
+
35
+ function resolve(feature, value, strict) {
36
+ // Feature notation is deprecated, use caps (this thing here is required for backward compatibility)
37
+ var map = {
38
+ chunks: 'slice_blob',
39
+ jpgresize: 'send_binary_string',
40
+ pngresize: 'send_binary_string',
41
+ progress: 'report_upload_progress',
42
+ multi_selection: 'select_multiple',
43
+ dragdrop: 'drag_and_drop',
44
+ drop_element: 'drag_and_drop',
45
+ headers: 'send_custom_headers',
46
+ urlstream_upload: 'send_binary_string',
47
+ canSendBinary: 'send_binary',
48
+ triggerDialog: 'summon_file_dialog'
49
+ };
50
+
51
+ if (map[feature]) {
52
+ caps[map[feature]] = value;
53
+ } else if (!strict) {
54
+ caps[feature] = value;
55
+ }
56
+ }
57
+
58
+ if (typeof(features) === 'string') {
59
+ plupload.each(features.split(/\s*,\s*/), function(feature) {
60
+ resolve(feature, true);
61
+ });
62
+ } else if (typeof(features) === 'object') {
63
+ plupload.each(features, function(value, feature) {
64
+ resolve(feature, value);
65
+ });
66
+ } else if (features === true) {
67
+ // check settings for required features
68
+ if (settings.chunk_size > 0) {
69
+ caps.slice_blob = true;
70
+ }
71
+
72
+ if (settings.resize.enabled || !settings.multipart) {
73
+ caps.send_binary_string = true;
74
+ }
75
+
76
+ plupload.each(settings, function(value, feature) {
77
+ resolve(feature, !!value, true); // strict check
78
+ });
79
+ }
80
+
81
+ return caps;
82
+ }
83
+
84
+ /**
85
+ * @module plupload
86
+ * @static
87
+ */
88
+ var plupload = {
89
+ /**
90
+ * Plupload version will be replaced on build.
91
+ *
92
+ * @property VERSION
93
+ * @for Plupload
94
+ * @static
95
+ * @final
96
+ */
97
+ VERSION : '2.1.3',
98
+
99
+ /**
100
+ * Inital state of the queue and also the state ones it's finished all it's uploads.
101
+ *
102
+ * @property STOPPED
103
+ * @static
104
+ * @final
105
+ */
106
+ STOPPED : 1,
107
+
108
+ /**
109
+ * Upload process is running
110
+ *
111
+ * @property STARTED
112
+ * @static
113
+ * @final
114
+ */
115
+ STARTED : 2,
116
+
117
+ /**
118
+ * File is queued for upload
119
+ *
120
+ * @property QUEUED
121
+ * @static
122
+ * @final
123
+ */
124
+ QUEUED : 1,
125
+
126
+ /**
127
+ * File is being uploaded
128
+ *
129
+ * @property UPLOADING
130
+ * @static
131
+ * @final
132
+ */
133
+ UPLOADING : 2,
134
+
135
+ /**
136
+ * File has failed to be uploaded
137
+ *
138
+ * @property FAILED
139
+ * @static
140
+ * @final
141
+ */
142
+ FAILED : 4,
143
+
144
+ /**
145
+ * File has been uploaded successfully
146
+ *
147
+ * @property DONE
148
+ * @static
149
+ * @final
150
+ */
151
+ DONE : 5,
152
+
153
+ // Error constants used by the Error event
154
+
155
+ /**
156
+ * Generic error for example if an exception is thrown inside Silverlight.
157
+ *
158
+ * @property GENERIC_ERROR
159
+ * @static
160
+ * @final
161
+ */
162
+ GENERIC_ERROR : -100,
163
+
164
+ /**
165
+ * HTTP transport error. For example if the server produces a HTTP status other than 200.
166
+ *
167
+ * @property HTTP_ERROR
168
+ * @static
169
+ * @final
170
+ */
171
+ HTTP_ERROR : -200,
172
+
173
+ /**
174
+ * Generic I/O error. For example if it wasn't possible to open the file stream on local machine.
175
+ *
176
+ * @property IO_ERROR
177
+ * @static
178
+ * @final
179
+ */
180
+ IO_ERROR : -300,
181
+
182
+ /**
183
+ * @property SECURITY_ERROR
184
+ * @static
185
+ * @final
186
+ */
187
+ SECURITY_ERROR : -400,
188
+
189
+ /**
190
+ * Initialization error. Will be triggered if no runtime was initialized.
191
+ *
192
+ * @property INIT_ERROR
193
+ * @static
194
+ * @final
195
+ */
196
+ INIT_ERROR : -500,
197
+
198
+ /**
199
+ * 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.
200
+ *
201
+ * @property FILE_SIZE_ERROR
202
+ * @static
203
+ * @final
204
+ */
205
+ FILE_SIZE_ERROR : -600,
206
+
207
+ /**
208
+ * File extension error. If the user selects a file that isn't valid according to the filters setting.
209
+ *
210
+ * @property FILE_EXTENSION_ERROR
211
+ * @static
212
+ * @final
213
+ */
214
+ FILE_EXTENSION_ERROR : -601,
215
+
216
+ /**
217
+ * Duplicate file error. If prevent_duplicates is set to true and user selects the same file again.
218
+ *
219
+ * @property FILE_DUPLICATE_ERROR
220
+ * @static
221
+ * @final
222
+ */
223
+ FILE_DUPLICATE_ERROR : -602,
224
+
225
+ /**
226
+ * Runtime will try to detect if image is proper one. Otherwise will throw this error.
227
+ *
228
+ * @property IMAGE_FORMAT_ERROR
229
+ * @static
230
+ * @final
231
+ */
232
+ IMAGE_FORMAT_ERROR : -700,
233
+
234
+ /**
235
+ * While working on files runtime may run out of memory and will throw this error.
236
+ *
237
+ * @since 2.1.2
238
+ * @property MEMORY_ERROR
239
+ * @static
240
+ * @final
241
+ */
242
+ MEMORY_ERROR : -701,
243
+
244
+ /**
245
+ * Each runtime has an upper limit on a dimension of the image it can handle. If bigger, will throw this error.
246
+ *
247
+ * @property IMAGE_DIMENSIONS_ERROR
248
+ * @static
249
+ * @final
250
+ */
251
+ IMAGE_DIMENSIONS_ERROR : -702,
252
+
253
+ /**
254
+ * Mime type lookup table.
255
+ *
256
+ * @property mimeTypes
257
+ * @type Object
258
+ * @final
259
+ */
260
+ mimeTypes : o.mimes,
261
+
262
+ /**
263
+ * In some cases sniffing is the only way around :(
264
+ */
265
+ ua: o.ua,
266
+
267
+ /**
268
+ * Gets the true type of the built-in object (better version of typeof).
269
+ * @credits Angus Croll (http://javascriptweblog.wordpress.com/)
270
+ *
271
+ * @method typeOf
272
+ * @static
273
+ * @param {Object} o Object to check.
274
+ * @return {String} Object [[Class]]
275
+ */
276
+ typeOf: o.typeOf,
277
+
278
+ /**
279
+ * Extends the specified object with another object.
280
+ *
281
+ * @method extend
282
+ * @static
283
+ * @param {Object} target Object to extend.
284
+ * @param {Object..} obj Multiple objects to extend with.
285
+ * @return {Object} Same as target, the extended object.
286
+ */
287
+ extend : o.extend,
288
+
289
+ /**
290
+ * Generates an unique ID. This is 99.99% unique since it takes the current time and 5 random numbers.
291
+ * The only way a user would be able to get the same ID is if the two persons at the same exact milisecond manages
292
+ * 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.
293
+ * It's more probable for the earth to be hit with an ansteriod. You can also if you want to be 100% sure set the plupload.guidPrefix property
294
+ * to an user unique key.
295
+ *
296
+ * @method guid
297
+ * @static
298
+ * @return {String} Virtually unique id.
299
+ */
300
+ guid : o.guid,
301
+
302
+ /**
303
+ * Get array of DOM Elements by their ids.
304
+ *
305
+ * @method get
306
+ * @for Utils
307
+ * @param {String} id Identifier of the DOM Element
308
+ * @return {Array}
309
+ */
310
+ get : function get(ids) {
311
+ var els = [], el;
312
+
313
+ if (o.typeOf(ids) !== 'array') {
314
+ ids = [ids];
315
+ }
316
+
317
+ var i = ids.length;
318
+ while (i--) {
319
+ el = o.get(ids[i]);
320
+ if (el) {
321
+ els.push(el);
322
+ }
323
+ }
324
+
325
+ return els.length ? els : null;
326
+ },
327
+
328
+ /**
329
+ * Executes the callback function for each item in array/object. If you return false in the
330
+ * callback it will break the loop.
331
+ *
332
+ * @method each
333
+ * @static
334
+ * @param {Object} obj Object to iterate.
335
+ * @param {function} callback Callback function to execute for each item.
336
+ */
337
+ each : o.each,
338
+
339
+ /**
340
+ * Returns the absolute x, y position of an Element. The position will be returned in a object with x, y fields.
341
+ *
342
+ * @method getPos
343
+ * @static
344
+ * @param {Element} node HTML element or element id to get x, y position from.
345
+ * @param {Element} root Optional root element to stop calculations at.
346
+ * @return {object} Absolute position of the specified element object with x, y fields.
347
+ */
348
+ getPos : o.getPos,
349
+
350
+ /**
351
+ * Returns the size of the specified node in pixels.
352
+ *
353
+ * @method getSize
354
+ * @static
355
+ * @param {Node} node Node to get the size of.
356
+ * @return {Object} Object with a w and h property.
357
+ */
358
+ getSize : o.getSize,
359
+
360
+ /**
361
+ * Encodes the specified string.
362
+ *
363
+ * @method xmlEncode
364
+ * @static
365
+ * @param {String} s String to encode.
366
+ * @return {String} Encoded string.
367
+ */
368
+ xmlEncode : function(str) {
369
+ var xmlEncodeChars = {'<' : 'lt', '>' : 'gt', '&' : 'amp', '"' : 'quot', '\'' : '#39'}, xmlEncodeRegExp = /[<>&\"\']/g;
370
+
371
+ return str ? ('' + str).replace(xmlEncodeRegExp, function(chr) {
372
+ return xmlEncodeChars[chr] ? '&' + xmlEncodeChars[chr] + ';' : chr;
373
+ }) : str;
374
+ },
375
+
376
+ /**
377
+ * Forces anything into an array.
378
+ *
379
+ * @method toArray
380
+ * @static
381
+ * @param {Object} obj Object with length field.
382
+ * @return {Array} Array object containing all items.
383
+ */
384
+ toArray : o.toArray,
385
+
386
+ /**
387
+ * Find an element in array and return it's index if present, otherwise return -1.
388
+ *
389
+ * @method inArray
390
+ * @static
391
+ * @param {mixed} needle Element to find
392
+ * @param {Array} array
393
+ * @return {Int} Index of the element, or -1 if not found
394
+ */
395
+ inArray : o.inArray,
396
+
397
+ /**
398
+ * Extends the language pack object with new items.
399
+ *
400
+ * @method addI18n
401
+ * @static
402
+ * @param {Object} pack Language pack items to add.
403
+ * @return {Object} Extended language pack object.
404
+ */
405
+ addI18n : o.addI18n,
406
+
407
+ /**
408
+ * Translates the specified string by checking for the english string in the language pack lookup.
409
+ *
410
+ * @method translate
411
+ * @static
412
+ * @param {String} str String to look for.
413
+ * @return {String} Translated string or the input string if it wasn't found.
414
+ */
415
+ translate : o.translate,
416
+
417
+ /**
418
+ * Checks if object is empty.
419
+ *
420
+ * @method isEmptyObj
421
+ * @static
422
+ * @param {Object} obj Object to check.
423
+ * @return {Boolean}
424
+ */
425
+ isEmptyObj : o.isEmptyObj,
426
+
427
+ /**
428
+ * Checks if specified DOM element has specified class.
429
+ *
430
+ * @method hasClass
431
+ * @static
432
+ * @param {Object} obj DOM element like object to add handler to.
433
+ * @param {String} name Class name
434
+ */
435
+ hasClass : o.hasClass,
436
+
437
+ /**
438
+ * Adds specified className to specified DOM element.
439
+ *
440
+ * @method addClass
441
+ * @static
442
+ * @param {Object} obj DOM element like object to add handler to.
443
+ * @param {String} name Class name
444
+ */
445
+ addClass : o.addClass,
446
+
447
+ /**
448
+ * Removes specified className from specified DOM element.
449
+ *
450
+ * @method removeClass
451
+ * @static
452
+ * @param {Object} obj DOM element like object to add handler to.
453
+ * @param {String} name Class name
454
+ */
455
+ removeClass : o.removeClass,
456
+
457
+ /**
458
+ * Returns a given computed style of a DOM element.
459
+ *
460
+ * @method getStyle
461
+ * @static
462
+ * @param {Object} obj DOM element like object.
463
+ * @param {String} name Style you want to get from the DOM element
464
+ */
465
+ getStyle : o.getStyle,
466
+
467
+ /**
468
+ * Adds an event handler to the specified object and store reference to the handler
469
+ * in objects internal Plupload registry (@see removeEvent).
470
+ *
471
+ * @method addEvent
472
+ * @static
473
+ * @param {Object} obj DOM element like object to add handler to.
474
+ * @param {String} name Name to add event listener to.
475
+ * @param {Function} callback Function to call when event occurs.
476
+ * @param {String} (optional) key that might be used to add specifity to the event record.
477
+ */
478
+ addEvent : o.addEvent,
479
+
480
+ /**
481
+ * Remove event handler from the specified object. If third argument (callback)
482
+ * is not specified remove all events with the specified name.
483
+ *
484
+ * @method removeEvent
485
+ * @static
486
+ * @param {Object} obj DOM element to remove event listener(s) from.
487
+ * @param {String} name Name of event listener to remove.
488
+ * @param {Function|String} (optional) might be a callback or unique key to match.
489
+ */
490
+ removeEvent: o.removeEvent,
491
+
492
+ /**
493
+ * Remove all kind of events from the specified object
494
+ *
495
+ * @method removeAllEvents
496
+ * @static
497
+ * @param {Object} obj DOM element to remove event listeners from.
498
+ * @param {String} (optional) unique key to match, when removing events.
499
+ */
500
+ removeAllEvents: o.removeAllEvents,
501
+
502
+ /**
503
+ * Cleans the specified name from national characters (diacritics). The result will be a name with only a-z, 0-9 and _.
504
+ *
505
+ * @method cleanName
506
+ * @static
507
+ * @param {String} s String to clean up.
508
+ * @return {String} Cleaned string.
509
+ */
510
+ cleanName : function(name) {
511
+ var i, lookup;
512
+
513
+ // Replace diacritics
514
+ lookup = [
515
+ /[\300-\306]/g, 'A', /[\340-\346]/g, 'a',
516
+ /\307/g, 'C', /\347/g, 'c',
517
+ /[\310-\313]/g, 'E', /[\350-\353]/g, 'e',
518
+ /[\314-\317]/g, 'I', /[\354-\357]/g, 'i',
519
+ /\321/g, 'N', /\361/g, 'n',
520
+ /[\322-\330]/g, 'O', /[\362-\370]/g, 'o',
521
+ /[\331-\334]/g, 'U', /[\371-\374]/g, 'u'
522
+ ];
523
+
524
+ for (i = 0; i < lookup.length; i += 2) {
525
+ name = name.replace(lookup[i], lookup[i + 1]);
526
+ }
527
+
528
+ // Replace whitespace
529
+ name = name.replace(/\s+/g, '_');
530
+
531
+ // Remove anything else
532
+ name = name.replace(/[^a-z0-9_\-\.]+/gi, '');
533
+
534
+ return name;
535
+ },
536
+
537
+ /**
538
+ * Builds a full url out of a base URL and an object with items to append as query string items.
539
+ *
540
+ * @method buildUrl
541
+ * @static
542
+ * @param {String} url Base URL to append query string items to.
543
+ * @param {Object} items Name/value object to serialize as a querystring.
544
+ * @return {String} String with url + serialized query string items.
545
+ */
546
+ buildUrl : function(url, items) {
547
+ var query = '';
548
+
549
+ plupload.each(items, function(value, name) {
550
+ query += (query ? '&' : '') + encodeURIComponent(name) + '=' + encodeURIComponent(value);
551
+ });
552
+
553
+ if (query) {
554
+ url += (url.indexOf('?') > 0 ? '&' : '?') + query;
555
+ }
556
+
557
+ return url;
558
+ },
559
+
560
+ /**
561
+ * Formats the specified number as a size string for example 1024 becomes 1 KB.
562
+ *
563
+ * @method formatSize
564
+ * @static
565
+ * @param {Number} size Size to format as string.
566
+ * @return {String} Formatted size string.
567
+ */
568
+ formatSize : function(size) {
569
+
570
+ if (size === undef || /\D/.test(size)) {
571
+ return plupload.translate('N/A');
572
+ }
573
+
574
+ function round(num, precision) {
575
+ return Math.round(num * Math.pow(10, precision)) / Math.pow(10, precision);
576
+ }
577
+
578
+ var boundary = Math.pow(1024, 4);
579
+
580
+ // TB
581
+ if (size > boundary) {
582
+ return round(size / boundary, 1) + " " + plupload.translate('tb');
583
+ }
584
+
585
+ // GB
586
+ if (size > (boundary/=1024)) {
587
+ return round(size / boundary, 1) + " " + plupload.translate('gb');
588
+ }
589
+
590
+ // MB
591
+ if (size > (boundary/=1024)) {
592
+ return round(size / boundary, 1) + " " + plupload.translate('mb');
593
+ }
594
+
595
+ // KB
596
+ if (size > 1024) {
597
+ return Math.round(size / 1024) + " " + plupload.translate('kb');
598
+ }
599
+
600
+ return size + " " + plupload.translate('b');
601
+ },
602
+
603
+
604
+ /**
605
+ * Parses the specified size string into a byte value. For example 10kb becomes 10240.
606
+ *
607
+ * @method parseSize
608
+ * @static
609
+ * @param {String|Number} size String to parse or number to just pass through.
610
+ * @return {Number} Size in bytes.
611
+ */
612
+ parseSize : o.parseSizeStr,
613
+
614
+
615
+ /**
616
+ * A way to predict what runtime will be choosen in the current environment with the
617
+ * specified settings.
618
+ *
619
+ * @method predictRuntime
620
+ * @static
621
+ * @param {Object|String} config Plupload settings to check
622
+ * @param {String} [runtimes] Comma-separated list of runtimes to check against
623
+ * @return {String} Type of compatible runtime
624
+ */
625
+ predictRuntime : function(config, runtimes) {
626
+ var up, runtime;
627
+
628
+ up = new plupload.Uploader(config);
629
+ runtime = o.Runtime.thatCan(up.getOption().required_features, runtimes || config.runtimes);
630
+ up.destroy();
631
+ return runtime;
632
+ },
633
+
634
+ /**
635
+ * Registers a filter that will be executed for each file added to the queue.
636
+ * If callback returns false, file will not be added.
637
+ *
638
+ * Callback receives two arguments: a value for the filter as it was specified in settings.filters
639
+ * and a file to be filtered. Callback is executed in the context of uploader instance.
640
+ *
641
+ * @method addFileFilter
642
+ * @static
643
+ * @param {String} name Name of the filter by which it can be referenced in settings.filters
644
+ * @param {String} cb Callback - the actual routine that every added file must pass
645
+ */
646
+ addFileFilter: function(name, cb) {
647
+ fileFilters[name] = cb;
648
+ }
649
+ };
650
+
651
+
652
+ plupload.addFileFilter('mime_types', function(filters, file, cb) {
653
+ if (filters.length && !filters.regexp.test(file.name)) {
654
+ this.trigger('Error', {
655
+ code : plupload.FILE_EXTENSION_ERROR,
656
+ message : plupload.translate('File extension error.'),
657
+ file : file
658
+ });
659
+ cb(false);
660
+ } else {
661
+ cb(true);
662
+ }
663
+ });
664
+
665
+
666
+ plupload.addFileFilter('max_file_size', function(maxSize, file, cb) {
667
+ var undef;
668
+
669
+ maxSize = plupload.parseSize(maxSize);
670
+
671
+ // Invalid file size
672
+ if (file.size !== undef && maxSize && file.size > maxSize) {
673
+ this.trigger('Error', {
674
+ code : plupload.FILE_SIZE_ERROR,
675
+ message : plupload.translate('File size error.'),
676
+ file : file
677
+ });
678
+ cb(false);
679
+ } else {
680
+ cb(true);
681
+ }
682
+ });
683
+
684
+
685
+ plupload.addFileFilter('prevent_duplicates', function(value, file, cb) {
686
+ if (value) {
687
+ var ii = this.files.length;
688
+ while (ii--) {
689
+ // Compare by name and size (size might be 0 or undefined, but still equivalent for both)
690
+ if (file.name === this.files[ii].name && file.size === this.files[ii].size) {
691
+ this.trigger('Error', {
692
+ code : plupload.FILE_DUPLICATE_ERROR,
693
+ message : plupload.translate('Duplicate file error.'),
694
+ file : file
695
+ });
696
+ cb(false);
697
+ return;
698
+ }
699
+ }
700
+ }
701
+ cb(true);
702
+ });
703
+
704
+
705
+ /**
706
+ @class Uploader
707
+ @constructor
708
+
709
+ @param {Object} settings For detailed information about each option check documentation.
710
+ @param {String|DOMElement} settings.browse_button id of the DOM element or DOM element itself to use as file dialog trigger.
711
+ @param {String} settings.url URL of the server-side upload handler.
712
+ @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.
713
+ @param {Boolean} [settings.send_chunk_number=true] Whether to send chunks and chunk numbers, or total and offset bytes.
714
+ @param {String} [settings.container] id of the DOM element to use as a container for uploader structures. Defaults to document.body.
715
+ @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.
716
+ @param {String} [settings.file_data_name="file"] Name for the file field in Multipart formated message.
717
+ @param {Object} [settings.filters={}] Set of file type filters.
718
+ @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`
719
+ @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`.
720
+ @param {Boolean} [settings.filters.prevent_duplicates=false] Do not let duplicates into the queue. Dispatches `plupload.FILE_DUPLICATE_ERROR`.
721
+ @param {String} [settings.flash_swf_url] URL of the Flash swf.
722
+ @param {Object} [settings.headers] Custom headers to send with the upload. Hash of name/value pairs.
723
+ @param {Number} [settings.max_retries=0] How many times to retry the chunk or file, before triggering Error event.
724
+ @param {Boolean} [settings.multipart=true] Whether to send file and additional parameters as Multipart formated message.
725
+ @param {Object} [settings.multipart_params] Hash of key/value pairs to send with every file upload.
726
+ @param {Boolean} [settings.multi_selection=true] Enable ability to select multiple files at once in file dialog.
727
+ @param {String|Object} [settings.required_features] Either comma-separated list or hash of required features that chosen runtime should absolutely possess.
728
+ @param {Object} [settings.resize] Enable resizng of images on client-side. Applies to `image/jpeg` and `image/png` only. `e.g. {width : 200, height : 200, quality : 90, crop: true}`
729
+ @param {Number} [settings.resize.width] If image is bigger, it will be resized.
730
+ @param {Number} [settings.resize.height] If image is bigger, it will be resized.
731
+ @param {Number} [settings.resize.quality=90] Compression quality for jpegs (1-100).
732
+ @param {Boolean} [settings.resize.crop=false] Whether to crop images to exact dimensions. By default they will be resized proportionally.
733
+ @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.
734
+ @param {String} [settings.silverlight_xap_url] URL of the Silverlight xap.
735
+ @param {Boolean} [settings.unique_names=false] If true will generate unique filenames for uploaded files.
736
+ @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).
737
+ */
738
+ plupload.Uploader = function(options) {
739
+ /**
740
+ * Fires when the current RunTime has been initialized.
741
+ *
742
+ * @event Init
743
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
744
+ */
745
+
746
+ /**
747
+ * Fires after the init event incase you need to perform actions there.
748
+ *
749
+ * @event PostInit
750
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
751
+ */
752
+
753
+ /**
754
+ * Fires when the option is changed in via uploader.setOption().
755
+ *
756
+ * @event OptionChanged
757
+ * @since 2.1
758
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
759
+ * @param {String} name Name of the option that was changed
760
+ * @param {Mixed} value New value for the specified option
761
+ * @param {Mixed} oldValue Previous value of the option
762
+ */
763
+
764
+ /**
765
+ * Fires when the silverlight/flash or other shim needs to move.
766
+ *
767
+ * @event Refresh
768
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
769
+ */
770
+
771
+ /**
772
+ * Fires when the overall state is being changed for the upload queue.
773
+ *
774
+ * @event StateChanged
775
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
776
+ */
777
+
778
+ /**
779
+ * Fires when browse_button is clicked and browse dialog shows.
780
+ *
781
+ * @event Browse
782
+ * @since 2.1.2
783
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
784
+ */
785
+
786
+ /**
787
+ * Fires for every filtered file before it is added to the queue.
788
+ *
789
+ * @event FileFiltered
790
+ * @since 2.1
791
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
792
+ * @param {plupload.File} file Another file that has to be added to the queue.
793
+ */
794
+
795
+ /**
796
+ * Fires when the file queue is changed. In other words when files are added/removed to the files array of the uploader instance.
797
+ *
798
+ * @event QueueChanged
799
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
800
+ */
801
+
802
+ /**
803
+ * Fires after files were filtered and added to the queue.
804
+ *
805
+ * @event FilesAdded
806
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
807
+ * @param {Array} files Array of file objects that were added to queue by the user.
808
+ */
809
+
810
+ /**
811
+ * Fires when file is removed from the queue.
812
+ *
813
+ * @event FilesRemoved
814
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
815
+ * @param {Array} files Array of files that got removed.
816
+ */
817
+
818
+ /**
819
+ * Fires when just before a file is uploaded. This event enables you to override settings
820
+ * on the uploader instance before the file is uploaded.
821
+ *
822
+ * @event BeforeUpload
823
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
824
+ * @param {plupload.File} file File to be uploaded.
825
+ */
826
+
827
+ /**
828
+ * Fires when a file is to be uploaded by the runtime.
829
+ *
830
+ * @event UploadFile
831
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
832
+ * @param {plupload.File} file File to be uploaded.
833
+ */
834
+
835
+ /**
836
+ * Fires while a file is being uploaded. Use this event to update the current file upload progress.
837
+ *
838
+ * @event UploadProgress
839
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
840
+ * @param {plupload.File} file File that is currently being uploaded.
841
+ */
842
+
843
+ /**
844
+ * Fires when file chunk is uploaded.
845
+ *
846
+ * @event ChunkUploaded
847
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
848
+ * @param {plupload.File} file File that the chunk was uploaded for.
849
+ * @param {Object} response Object with response properties.
850
+ */
851
+
852
+ /**
853
+ * Fires when a file is successfully uploaded.
854
+ *
855
+ * @event FileUploaded
856
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
857
+ * @param {plupload.File} file File that was uploaded.
858
+ * @param {Object} response Object with response properties.
859
+ */
860
+
861
+ /**
862
+ * Fires when all files in a queue are uploaded.
863
+ *
864
+ * @event UploadComplete
865
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
866
+ * @param {Array} files Array of file objects that was added to queue/selected by the user.
867
+ */
868
+
869
+ /**
870
+ * Fires when a error occurs.
871
+ *
872
+ * @event Error
873
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
874
+ * @param {Object} error Contains code, message and sometimes file and other details.
875
+ */
876
+
877
+ /**
878
+ * Fires when destroy method is called.
879
+ *
880
+ * @event Destroy
881
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
882
+ */
883
+ var uid = plupload.guid()
884
+ , settings
885
+ , files = []
886
+ , preferred_caps = {}
887
+ , fileInputs = []
888
+ , fileDrops = []
889
+ , startTime
890
+ , total
891
+ , disabled = false
892
+ , xhr
893
+ ;
894
+
895
+
896
+ // Private methods
897
+ function uploadNext() {
898
+ var file, count = 0, i;
899
+
900
+ if (this.state == plupload.STARTED) {
901
+ // Find first QUEUED file
902
+ for (i = 0; i < files.length; i++) {
903
+ if (!file && files[i].status == plupload.QUEUED) {
904
+ file = files[i];
905
+ if (this.trigger("BeforeUpload", file)) {
906
+ file.status = plupload.UPLOADING;
907
+ this.trigger("UploadFile", file);
908
+ }
909
+ } else {
910
+ count++;
911
+ }
912
+ }
913
+
914
+ // All files are DONE or FAILED
915
+ if (count == files.length) {
916
+ if (this.state !== plupload.STOPPED) {
917
+ this.state = plupload.STOPPED;
918
+ this.trigger("StateChanged");
919
+ }
920
+ this.trigger("UploadComplete", files);
921
+ }
922
+ }
923
+ }
924
+
925
+
926
+ function calcFile(file) {
927
+ file.percent = file.size > 0 ? Math.ceil(file.loaded / file.size * 100) : 100;
928
+ calc();
929
+ }
930
+
931
+
932
+ function calc() {
933
+ var i, file;
934
+
935
+ // Reset stats
936
+ total.reset();
937
+
938
+ // Check status, size, loaded etc on all files
939
+ for (i = 0; i < files.length; i++) {
940
+ file = files[i];
941
+
942
+ if (file.size !== undef) {
943
+ // We calculate totals based on original file size
944
+ total.size += file.origSize;
945
+
946
+ // Since we cannot predict file size after resize, we do opposite and
947
+ // interpolate loaded amount to match magnitude of total
948
+ total.loaded += file.loaded * file.origSize / file.size;
949
+ } else {
950
+ total.size = undef;
951
+ }
952
+
953
+ if (file.status == plupload.DONE) {
954
+ total.uploaded++;
955
+ } else if (file.status == plupload.FAILED) {
956
+ total.failed++;
957
+ } else {
958
+ total.queued++;
959
+ }
960
+ }
961
+
962
+ // If we couldn't calculate a total file size then use the number of files to calc percent
963
+ if (total.size === undef) {
964
+ total.percent = files.length > 0 ? Math.ceil(total.uploaded / files.length * 100) : 0;
965
+ } else {
966
+ total.bytesPerSec = Math.ceil(total.loaded / ((+new Date() - startTime || 1) / 1000.0));
967
+ total.percent = total.size > 0 ? Math.ceil(total.loaded / total.size * 100) : 0;
968
+ }
969
+ }
970
+
971
+
972
+ function getRUID() {
973
+ var ctrl = fileInputs[0] || fileDrops[0];
974
+ if (ctrl) {
975
+ return ctrl.getRuntime().uid;
976
+ }
977
+ return false;
978
+ }
979
+
980
+
981
+ function runtimeCan(file, cap) {
982
+ if (file.ruid) {
983
+ var info = o.Runtime.getInfo(file.ruid);
984
+ if (info) {
985
+ return info.can(cap);
986
+ }
987
+ }
988
+ return false;
989
+ }
990
+
991
+
992
+ function bindEventListeners() {
993
+ this.bind('FilesAdded FilesRemoved', function(up) {
994
+ up.trigger('QueueChanged');
995
+ up.refresh();
996
+ });
997
+
998
+ this.bind('CancelUpload', onCancelUpload);
999
+
1000
+ this.bind('BeforeUpload', onBeforeUpload);
1001
+
1002
+ this.bind('UploadFile', onUploadFile);
1003
+
1004
+ this.bind('UploadProgress', onUploadProgress);
1005
+
1006
+ this.bind('StateChanged', onStateChanged);
1007
+
1008
+ this.bind('QueueChanged', calc);
1009
+
1010
+ this.bind('Error', onError);
1011
+
1012
+ this.bind('FileUploaded', onFileUploaded);
1013
+
1014
+ this.bind('Destroy', onDestroy);
1015
+ }
1016
+
1017
+
1018
+ function initControls(settings, cb) {
1019
+ var self = this, inited = 0, queue = [];
1020
+
1021
+ // common settings
1022
+ var options = {
1023
+ runtime_order: settings.runtimes,
1024
+ required_caps: settings.required_features,
1025
+ preferred_caps: preferred_caps,
1026
+ swf_url: settings.flash_swf_url,
1027
+ xap_url: settings.silverlight_xap_url
1028
+ };
1029
+
1030
+ // add runtime specific options if any
1031
+ plupload.each(settings.runtimes.split(/\s*,\s*/), function(runtime) {
1032
+ if (settings[runtime]) {
1033
+ options[runtime] = settings[runtime];
1034
+ }
1035
+ });
1036
+
1037
+ // initialize file pickers - there can be many
1038
+ if (settings.browse_button) {
1039
+ plupload.each(settings.browse_button, function(el) {
1040
+ queue.push(function(cb) {
1041
+ var fileInput = new o.FileInput(plupload.extend({}, options, {
1042
+ accept: settings.filters.mime_types,
1043
+ name: settings.file_data_name,
1044
+ multiple: settings.multi_selection,
1045
+ container: settings.container,
1046
+ browse_button: el
1047
+ }));
1048
+
1049
+ fileInput.onready = function() {
1050
+ var info = o.Runtime.getInfo(this.ruid);
1051
+
1052
+ // for backward compatibility
1053
+ o.extend(self.features, {
1054
+ chunks: info.can('slice_blob'),
1055
+ multipart: info.can('send_multipart'),
1056
+ multi_selection: info.can('select_multiple')
1057
+ });
1058
+
1059
+ inited++;
1060
+ fileInputs.push(this);
1061
+ cb();
1062
+ };
1063
+
1064
+ fileInput.onchange = function() {
1065
+ self.addFile(this.files);
1066
+ };
1067
+
1068
+ fileInput.bind('mouseenter mouseleave mousedown mouseup', function(e) {
1069
+ if (!disabled) {
1070
+ if (settings.browse_button_hover) {
1071
+ if ('mouseenter' === e.type) {
1072
+ o.addClass(el, settings.browse_button_hover);
1073
+ } else if ('mouseleave' === e.type) {
1074
+ o.removeClass(el, settings.browse_button_hover);
1075
+ }
1076
+ }
1077
+
1078
+ if (settings.browse_button_active) {
1079
+ if ('mousedown' === e.type) {
1080
+ o.addClass(el, settings.browse_button_active);
1081
+ } else if ('mouseup' === e.type) {
1082
+ o.removeClass(el, settings.browse_button_active);
1083
+ }
1084
+ }
1085
+ }
1086
+ });
1087
+
1088
+ fileInput.bind('mousedown', function() {
1089
+ self.trigger('Browse');
1090
+ });
1091
+
1092
+ fileInput.bind('error runtimeerror', function() {
1093
+ fileInput = null;
1094
+ cb();
1095
+ });
1096
+
1097
+ fileInput.init();
1098
+ });
1099
+ });
1100
+ }
1101
+
1102
+ // initialize drop zones
1103
+ if (settings.drop_element) {
1104
+ plupload.each(settings.drop_element, function(el) {
1105
+ queue.push(function(cb) {
1106
+ var fileDrop = new o.FileDrop(plupload.extend({}, options, {
1107
+ drop_zone: el
1108
+ }));
1109
+
1110
+ fileDrop.onready = function() {
1111
+ var info = o.Runtime.getInfo(this.ruid);
1112
+
1113
+ self.features.dragdrop = info.can('drag_and_drop'); // for backward compatibility
1114
+
1115
+ inited++;
1116
+ fileDrops.push(this);
1117
+ cb();
1118
+ };
1119
+
1120
+ fileDrop.ondrop = function() {
1121
+ self.addFile(this.files);
1122
+ };
1123
+
1124
+ fileDrop.bind('error runtimeerror', function() {
1125
+ fileDrop = null;
1126
+ cb();
1127
+ });
1128
+
1129
+ fileDrop.init();
1130
+ });
1131
+ });
1132
+ }
1133
+
1134
+
1135
+ o.inSeries(queue, function() {
1136
+ if (typeof(cb) === 'function') {
1137
+ cb(inited);
1138
+ }
1139
+ });
1140
+ }
1141
+
1142
+
1143
+ function resizeImage(blob, params, cb) {
1144
+ var img = new o.Image();
1145
+
1146
+ try {
1147
+ img.onload = function() {
1148
+ // no manipulation required if...
1149
+ if (params.width > this.width &&
1150
+ params.height > this.height &&
1151
+ params.quality === undef &&
1152
+ params.preserve_headers &&
1153
+ !params.crop
1154
+ ) {
1155
+ this.destroy();
1156
+ return cb(blob);
1157
+ }
1158
+ // otherwise downsize
1159
+ img.downsize(params.width, params.height, params.crop, params.preserve_headers);
1160
+ };
1161
+
1162
+ img.onresize = function() {
1163
+ cb(this.getAsBlob(blob.type, params.quality));
1164
+ this.destroy();
1165
+ };
1166
+
1167
+ img.onerror = function() {
1168
+ cb(blob);
1169
+ };
1170
+
1171
+ img.load(blob);
1172
+ } catch(ex) {
1173
+ cb(blob);
1174
+ }
1175
+ }
1176
+
1177
+
1178
+ function setOption(option, value, init) {
1179
+ var self = this, reinitRequired = false;
1180
+
1181
+ function _setOption(option, value, init) {
1182
+ var oldValue = settings[option];
1183
+
1184
+ switch (option) {
1185
+ case 'max_file_size':
1186
+ if (option === 'max_file_size') {
1187
+ settings.max_file_size = settings.filters.max_file_size = value;
1188
+ }
1189
+ break;
1190
+
1191
+ case 'chunk_size':
1192
+ if (value = plupload.parseSize(value)) {
1193
+ settings[option] = value;
1194
+ settings.send_file_name = true;
1195
+ }
1196
+ break;
1197
+
1198
+ case 'multipart':
1199
+ settings[option] = value;
1200
+ if (!value) {
1201
+ settings.send_file_name = true;
1202
+ }
1203
+ break;
1204
+
1205
+ case 'unique_names':
1206
+ settings[option] = value;
1207
+ if (value) {
1208
+ settings.send_file_name = true;
1209
+ }
1210
+ break;
1211
+
1212
+ case 'filters':
1213
+ // for sake of backward compatibility
1214
+ if (plupload.typeOf(value) === 'array') {
1215
+ value = {
1216
+ mime_types: value
1217
+ };
1218
+ }
1219
+
1220
+ if (init) {
1221
+ plupload.extend(settings.filters, value);
1222
+ } else {
1223
+ settings.filters = value;
1224
+ }
1225
+
1226
+ // if file format filters are being updated, regenerate the matching expressions
1227
+ if (value.mime_types) {
1228
+ settings.filters.mime_types.regexp = (function(filters) {
1229
+ var extensionsRegExp = [];
1230
+
1231
+ plupload.each(filters, function(filter) {
1232
+ plupload.each(filter.extensions.split(/,/), function(ext) {
1233
+ if (/^\s*\*\s*$/.test(ext)) {
1234
+ extensionsRegExp.push('\\.*');
1235
+ } else {
1236
+ extensionsRegExp.push('\\.' + ext.replace(new RegExp('[' + ('/^$.*+?|()[]{}\\'.replace(/./g, '\\$&')) + ']', 'g'), '\\$&'));
1237
+ }
1238
+ });
1239
+ });
1240
+
1241
+ return new RegExp('(' + extensionsRegExp.join('|') + ')$', 'i');
1242
+ }(settings.filters.mime_types));
1243
+ }
1244
+ break;
1245
+
1246
+ case 'resize':
1247
+ if (init) {
1248
+ plupload.extend(settings.resize, value, {
1249
+ enabled: true
1250
+ });
1251
+ } else {
1252
+ settings.resize = value;
1253
+ }
1254
+ break;
1255
+
1256
+ case 'prevent_duplicates':
1257
+ settings.prevent_duplicates = settings.filters.prevent_duplicates = !!value;
1258
+ break;
1259
+
1260
+ case 'browse_button':
1261
+ case 'drop_element':
1262
+ value = plupload.get(value);
1263
+
1264
+ case 'container':
1265
+ case 'runtimes':
1266
+ case 'multi_selection':
1267
+ case 'flash_swf_url':
1268
+ case 'silverlight_xap_url':
1269
+ settings[option] = value;
1270
+ if (!init) {
1271
+ reinitRequired = true;
1272
+ }
1273
+ break;
1274
+
1275
+ default:
1276
+ settings[option] = value;
1277
+ }
1278
+
1279
+ if (!init) {
1280
+ self.trigger('OptionChanged', option, value, oldValue);
1281
+ }
1282
+ }
1283
+
1284
+ if (typeof(option) === 'object') {
1285
+ plupload.each(option, function(value, option) {
1286
+ _setOption(option, value, init);
1287
+ });
1288
+ } else {
1289
+ _setOption(option, value, init);
1290
+ }
1291
+
1292
+ if (init) {
1293
+ // Normalize the list of required capabilities
1294
+ settings.required_features = normalizeCaps(plupload.extend({}, settings));
1295
+
1296
+ // Come up with the list of capabilities that can affect default mode in a multi-mode runtimes
1297
+ preferred_caps = normalizeCaps(plupload.extend({}, settings, {
1298
+ required_features: true
1299
+ }));
1300
+ } else if (reinitRequired) {
1301
+ self.trigger('Destroy');
1302
+
1303
+ initControls.call(self, settings, function(inited) {
1304
+ if (inited) {
1305
+ self.runtime = o.Runtime.getInfo(getRUID()).type;
1306
+ self.trigger('Init', { runtime: self.runtime });
1307
+ self.trigger('PostInit');
1308
+ } else {
1309
+ self.trigger('Error', {
1310
+ code : plupload.INIT_ERROR,
1311
+ message : plupload.translate('Init error.')
1312
+ });
1313
+ }
1314
+ });
1315
+ }
1316
+ }
1317
+
1318
+
1319
+ // Internal event handlers
1320
+ function onBeforeUpload(up, file) {
1321
+ // Generate unique target filenames
1322
+ if (up.settings.unique_names) {
1323
+ var matches = file.name.match(/\.([^.]+)$/), ext = "part";
1324
+ if (matches) {
1325
+ ext = matches[1];
1326
+ }
1327
+ file.target_name = file.id + '.' + ext;
1328
+ }
1329
+ }
1330
+
1331
+
1332
+ function onUploadFile(up, file) {
1333
+ var url = up.settings.url
1334
+ , chunkSize = up.settings.chunk_size
1335
+ , retries = up.settings.max_retries
1336
+ , features = up.features
1337
+ , offset = 0
1338
+ , blob
1339
+ ;
1340
+
1341
+ // make sure we start at a predictable offset
1342
+ if (file.loaded) {
1343
+ offset = file.loaded = chunkSize ? chunkSize * Math.floor(file.loaded / chunkSize) : 0;
1344
+ }
1345
+
1346
+ function handleError() {
1347
+ if (retries-- > 0) {
1348
+ delay(uploadNextChunk, 1000);
1349
+ } else {
1350
+ file.loaded = offset; // reset all progress
1351
+
1352
+ up.trigger('Error', {
1353
+ code : plupload.HTTP_ERROR,
1354
+ message : plupload.translate('HTTP Error.'),
1355
+ file : file,
1356
+ response : xhr.responseText,
1357
+ status : xhr.status,
1358
+ responseHeaders: xhr.getAllResponseHeaders()
1359
+ });
1360
+ }
1361
+ }
1362
+
1363
+ function uploadNextChunk() {
1364
+ var chunkBlob, formData, args = {}, curChunkSize;
1365
+
1366
+ // make sure that file wasn't cancelled and upload is not stopped in general
1367
+ if (file.status !== plupload.UPLOADING || up.state === plupload.STOPPED) {
1368
+ return;
1369
+ }
1370
+
1371
+ // send additional 'name' parameter only if required
1372
+ if (up.settings.send_file_name) {
1373
+ args.name = file.target_name || file.name;
1374
+ }
1375
+
1376
+ if (chunkSize && features.chunks && blob.size > chunkSize) { // blob will be of type string if it was loaded in memory
1377
+ curChunkSize = Math.min(chunkSize, blob.size - offset);
1378
+ chunkBlob = blob.slice(offset, offset + curChunkSize);
1379
+ } else {
1380
+ curChunkSize = blob.size;
1381
+ chunkBlob = blob;
1382
+ }
1383
+
1384
+ // If chunking is enabled add corresponding args, no matter if file is bigger than chunk or smaller
1385
+ if (chunkSize && features.chunks) {
1386
+ // Setup query string arguments
1387
+ if (up.settings.send_chunk_number) {
1388
+ args.chunk = Math.ceil(offset / chunkSize);
1389
+ args.chunks = Math.ceil(blob.size / chunkSize);
1390
+ } else { // keep support for experimental chunk format, just in case
1391
+ args.offset = offset;
1392
+ args.total = blob.size;
1393
+ }
1394
+ }
1395
+
1396
+ xhr = new o.XMLHttpRequest();
1397
+
1398
+ // Do we have upload progress support
1399
+ if (xhr.upload) {
1400
+ xhr.upload.onprogress = function(e) {
1401
+ file.loaded = Math.min(file.size, offset + e.loaded);
1402
+ up.trigger('UploadProgress', file);
1403
+ };
1404
+ }
1405
+
1406
+ xhr.onload = function() {
1407
+ // check if upload made itself through
1408
+ if (xhr.status >= 400) {
1409
+ handleError();
1410
+ return;
1411
+ }
1412
+
1413
+ retries = up.settings.max_retries; // reset the counter
1414
+
1415
+ // Handle chunk response
1416
+ if (curChunkSize < blob.size) {
1417
+ chunkBlob.destroy();
1418
+
1419
+ offset += curChunkSize;
1420
+ file.loaded = Math.min(offset, blob.size);
1421
+
1422
+ up.trigger('ChunkUploaded', file, {
1423
+ offset : file.loaded,
1424
+ total : blob.size,
1425
+ response : xhr.responseText,
1426
+ status : xhr.status,
1427
+ responseHeaders: xhr.getAllResponseHeaders()
1428
+ });
1429
+
1430
+ // stock Android browser doesn't fire upload progress events, but in chunking mode we can fake them
1431
+ if (o.Env.browser === 'Android Browser') {
1432
+ // doesn't harm in general, but is not required anywhere else
1433
+ up.trigger('UploadProgress', file);
1434
+ }
1435
+ } else {
1436
+ file.loaded = file.size;
1437
+ }
1438
+
1439
+ chunkBlob = formData = null; // Free memory
1440
+
1441
+ // Check if file is uploaded
1442
+ if (!offset || offset >= blob.size) {
1443
+ // If file was modified, destory the copy
1444
+ if (file.size != file.origSize) {
1445
+ blob.destroy();
1446
+ blob = null;
1447
+ }
1448
+
1449
+ up.trigger('UploadProgress', file);
1450
+
1451
+ file.status = plupload.DONE;
1452
+
1453
+ up.trigger('FileUploaded', file, {
1454
+ response : xhr.responseText,
1455
+ status : xhr.status,
1456
+ responseHeaders: xhr.getAllResponseHeaders()
1457
+ });
1458
+ } else {
1459
+ // Still chunks left
1460
+ delay(uploadNextChunk, 1); // run detached, otherwise event handlers interfere
1461
+ }
1462
+ };
1463
+
1464
+ xhr.onerror = function() {
1465
+ handleError();
1466
+ };
1467
+
1468
+ xhr.onloadend = function() {
1469
+ this.destroy();
1470
+ xhr = null;
1471
+ };
1472
+
1473
+ // Build multipart request
1474
+ if (up.settings.multipart && features.multipart) {
1475
+ xhr.open("post", url, true);
1476
+
1477
+ // Set custom headers
1478
+ plupload.each(up.settings.headers, function(value, name) {
1479
+ xhr.setRequestHeader(name, value);
1480
+ });
1481
+
1482
+ formData = new o.FormData();
1483
+
1484
+ // Add multipart params
1485
+ plupload.each(plupload.extend(args, up.settings.multipart_params), function(value, name) {
1486
+ formData.append(name, value);
1487
+ });
1488
+
1489
+ // Add file and send it
1490
+ formData.append(up.settings.file_data_name, chunkBlob);
1491
+ xhr.send(formData, {
1492
+ runtime_order: up.settings.runtimes,
1493
+ required_caps: up.settings.required_features,
1494
+ preferred_caps: preferred_caps,
1495
+ swf_url: up.settings.flash_swf_url,
1496
+ xap_url: up.settings.silverlight_xap_url
1497
+ });
1498
+ } else {
1499
+ // if no multipart, send as binary stream
1500
+ url = plupload.buildUrl(up.settings.url, plupload.extend(args, up.settings.multipart_params));
1501
+
1502
+ xhr.open("post", url, true);
1503
+
1504
+ xhr.setRequestHeader('Content-Type', 'application/octet-stream'); // Binary stream header
1505
+
1506
+ // Set custom headers
1507
+ plupload.each(up.settings.headers, function(value, name) {
1508
+ xhr.setRequestHeader(name, value);
1509
+ });
1510
+
1511
+ xhr.send(chunkBlob, {
1512
+ runtime_order: up.settings.runtimes,
1513
+ required_caps: up.settings.required_features,
1514
+ preferred_caps: preferred_caps,
1515
+ swf_url: up.settings.flash_swf_url,
1516
+ xap_url: up.settings.silverlight_xap_url
1517
+ });
1518
+ }
1519
+ }
1520
+
1521
+ blob = file.getSource();
1522
+
1523
+ // Start uploading chunks
1524
+ if (up.settings.resize.enabled && runtimeCan(blob, 'send_binary_string') && !!~o.inArray(blob.type, ['image/jpeg', 'image/png'])) {
1525
+ // Resize if required
1526
+ resizeImage.call(this, blob, up.settings.resize, function(resizedBlob) {
1527
+ blob = resizedBlob;
1528
+ file.size = resizedBlob.size;
1529
+ uploadNextChunk();
1530
+ });
1531
+ } else {
1532
+ uploadNextChunk();
1533
+ }
1534
+ }
1535
+
1536
+
1537
+ function onUploadProgress(up, file) {
1538
+ calcFile(file);
1539
+ }
1540
+
1541
+
1542
+ function onStateChanged(up) {
1543
+ if (up.state == plupload.STARTED) {
1544
+ // Get start time to calculate bps
1545
+ startTime = (+new Date());
1546
+ } else if (up.state == plupload.STOPPED) {
1547
+ // Reset currently uploading files
1548
+ for (var i = up.files.length - 1; i >= 0; i--) {
1549
+ if (up.files[i].status == plupload.UPLOADING) {
1550
+ up.files[i].status = plupload.QUEUED;
1551
+ calc();
1552
+ }
1553
+ }
1554
+ }
1555
+ }
1556
+
1557
+
1558
+ function onCancelUpload() {
1559
+ if (xhr) {
1560
+ xhr.abort();
1561
+ }
1562
+ }
1563
+
1564
+
1565
+ function onFileUploaded(up) {
1566
+ calc();
1567
+
1568
+ // Upload next file but detach it from the error event
1569
+ // since other custom listeners might want to stop the queue
1570
+ delay(function() {
1571
+ uploadNext.call(up);
1572
+ }, 1);
1573
+ }
1574
+
1575
+
1576
+ function onError(up, err) {
1577
+ if (err.code === plupload.INIT_ERROR) {
1578
+ up.destroy();
1579
+ }
1580
+ // Set failed status if an error occured on a file
1581
+ else if (err.file) {
1582
+ err.file.status = plupload.FAILED;
1583
+ calcFile(err.file);
1584
+
1585
+ // Upload next file but detach it from the error event
1586
+ // since other custom listeners might want to stop the queue
1587
+ if (up.state == plupload.STARTED) { // upload in progress
1588
+ up.trigger('CancelUpload');
1589
+ delay(function() {
1590
+ uploadNext.call(up);
1591
+ }, 1);
1592
+ }
1593
+ }
1594
+ }
1595
+
1596
+
1597
+ function onDestroy(up) {
1598
+ up.stop();
1599
+
1600
+ // Purge the queue
1601
+ plupload.each(files, function(file) {
1602
+ file.destroy();
1603
+ });
1604
+ files = [];
1605
+
1606
+ if (fileInputs.length) {
1607
+ plupload.each(fileInputs, function(fileInput) {
1608
+ fileInput.destroy();
1609
+ });
1610
+ fileInputs = [];
1611
+ }
1612
+
1613
+ if (fileDrops.length) {
1614
+ plupload.each(fileDrops, function(fileDrop) {
1615
+ fileDrop.destroy();
1616
+ });
1617
+ fileDrops = [];
1618
+ }
1619
+
1620
+ preferred_caps = {};
1621
+ disabled = false;
1622
+ startTime = xhr = null;
1623
+ total.reset();
1624
+ }
1625
+
1626
+
1627
+ // Default settings
1628
+ settings = {
1629
+ runtimes: o.Runtime.order,
1630
+ max_retries: 0,
1631
+ chunk_size: 0,
1632
+ multipart: true,
1633
+ multi_selection: true,
1634
+ file_data_name: 'file',
1635
+ flash_swf_url: 'js/Moxie.swf',
1636
+ silverlight_xap_url: 'js/Moxie.xap',
1637
+ filters: {
1638
+ mime_types: [],
1639
+ prevent_duplicates: false,
1640
+ max_file_size: 0
1641
+ },
1642
+ resize: {
1643
+ enabled: false,
1644
+ preserve_headers: true,
1645
+ crop: false
1646
+ },
1647
+ send_file_name: true,
1648
+ send_chunk_number: true
1649
+ };
1650
+
1651
+
1652
+ setOption.call(this, options, null, true);
1653
+
1654
+ // Inital total state
1655
+ total = new plupload.QueueProgress();
1656
+
1657
+ // Add public methods
1658
+ plupload.extend(this, {
1659
+
1660
+ /**
1661
+ * Unique id for the Uploader instance.
1662
+ *
1663
+ * @property id
1664
+ * @type String
1665
+ */
1666
+ id : uid,
1667
+ uid : uid, // mOxie uses this to differentiate between event targets
1668
+
1669
+ /**
1670
+ * Current state of the total uploading progress. This one can either be plupload.STARTED or plupload.STOPPED.
1671
+ * These states are controlled by the stop/start methods. The default value is STOPPED.
1672
+ *
1673
+ * @property state
1674
+ * @type Number
1675
+ */
1676
+ state : plupload.STOPPED,
1677
+
1678
+ /**
1679
+ * Map of features that are available for the uploader runtime. Features will be filled
1680
+ * before the init event is called, these features can then be used to alter the UI for the end user.
1681
+ * Some of the current features that might be in this map is: dragdrop, chunks, jpgresize, pngresize.
1682
+ *
1683
+ * @property features
1684
+ * @type Object
1685
+ */
1686
+ features : {},
1687
+
1688
+ /**
1689
+ * Current runtime name.
1690
+ *
1691
+ * @property runtime
1692
+ * @type String
1693
+ */
1694
+ runtime : null,
1695
+
1696
+ /**
1697
+ * Current upload queue, an array of File instances.
1698
+ *
1699
+ * @property files
1700
+ * @type Array
1701
+ * @see plupload.File
1702
+ */
1703
+ files : files,
1704
+
1705
+ /**
1706
+ * Object with name/value settings.
1707
+ *
1708
+ * @property settings
1709
+ * @type Object
1710
+ */
1711
+ settings : settings,
1712
+
1713
+ /**
1714
+ * Total progess information. How many files has been uploaded, total percent etc.
1715
+ *
1716
+ * @property total
1717
+ * @type plupload.QueueProgress
1718
+ */
1719
+ total : total,
1720
+
1721
+
1722
+ /**
1723
+ * Initializes the Uploader instance and adds internal event listeners.
1724
+ *
1725
+ * @method init
1726
+ */
1727
+ init : function() {
1728
+ var self = this;
1729
+
1730
+ if (typeof(settings.preinit) == "function") {
1731
+ settings.preinit(self);
1732
+ } else {
1733
+ plupload.each(settings.preinit, function(func, name) {
1734
+ self.bind(name, func);
1735
+ });
1736
+ }
1737
+
1738
+ bindEventListeners.call(this);
1739
+
1740
+ // Check for required options
1741
+ if (!settings.browse_button || !settings.url) {
1742
+ this.trigger('Error', {
1743
+ code : plupload.INIT_ERROR,
1744
+ message : plupload.translate('Init error.')
1745
+ });
1746
+ return;
1747
+ }
1748
+
1749
+ initControls.call(this, settings, function(inited) {
1750
+ if (typeof(settings.init) == "function") {
1751
+ settings.init(self);
1752
+ } else {
1753
+ plupload.each(settings.init, function(func, name) {
1754
+ self.bind(name, func);
1755
+ });
1756
+ }
1757
+
1758
+ if (inited) {
1759
+ self.runtime = o.Runtime.getInfo(getRUID()).type;
1760
+ self.trigger('Init', { runtime: self.runtime });
1761
+ self.trigger('PostInit');
1762
+ } else {
1763
+ self.trigger('Error', {
1764
+ code : plupload.INIT_ERROR,
1765
+ message : plupload.translate('Init error.')
1766
+ });
1767
+ }
1768
+ });
1769
+ },
1770
+
1771
+ /**
1772
+ * Set the value for the specified option(s).
1773
+ *
1774
+ * @method setOption
1775
+ * @since 2.1
1776
+ * @param {String|Object} option Name of the option to change or the set of key/value pairs
1777
+ * @param {Mixed} [value] Value for the option (is ignored, if first argument is object)
1778
+ */
1779
+ setOption: function(option, value) {
1780
+ setOption.call(this, option, value, !this.runtime); // until runtime not set we do not need to reinitialize
1781
+ },
1782
+
1783
+ /**
1784
+ * Get the value for the specified option or the whole configuration, if not specified.
1785
+ *
1786
+ * @method getOption
1787
+ * @since 2.1
1788
+ * @param {String} [option] Name of the option to get
1789
+ * @return {Mixed} Value for the option or the whole set
1790
+ */
1791
+ getOption: function(option) {
1792
+ if (!option) {
1793
+ return settings;
1794
+ }
1795
+ return settings[option];
1796
+ },
1797
+
1798
+ /**
1799
+ * Refreshes the upload instance by dispatching out a refresh event to all runtimes.
1800
+ * This would for example reposition flash/silverlight shims on the page.
1801
+ *
1802
+ * @method refresh
1803
+ */
1804
+ refresh : function() {
1805
+ if (fileInputs.length) {
1806
+ plupload.each(fileInputs, function(fileInput) {
1807
+ fileInput.trigger('Refresh');
1808
+ });
1809
+ }
1810
+ this.trigger('Refresh');
1811
+ },
1812
+
1813
+ /**
1814
+ * Starts uploading the queued files.
1815
+ *
1816
+ * @method start
1817
+ */
1818
+ start : function() {
1819
+ if (this.state != plupload.STARTED) {
1820
+ this.state = plupload.STARTED;
1821
+ this.trigger('StateChanged');
1822
+
1823
+ uploadNext.call(this);
1824
+ }
1825
+ },
1826
+
1827
+ /**
1828
+ * Stops the upload of the queued files.
1829
+ *
1830
+ * @method stop
1831
+ */
1832
+ stop : function() {
1833
+ if (this.state != plupload.STOPPED) {
1834
+ this.state = plupload.STOPPED;
1835
+ this.trigger('StateChanged');
1836
+ this.trigger('CancelUpload');
1837
+ }
1838
+ },
1839
+
1840
+
1841
+ /**
1842
+ * Disables/enables browse button on request.
1843
+ *
1844
+ * @method disableBrowse
1845
+ * @param {Boolean} disable Whether to disable or enable (default: true)
1846
+ */
1847
+ disableBrowse : function() {
1848
+ disabled = arguments[0] !== undef ? arguments[0] : true;
1849
+
1850
+ if (fileInputs.length) {
1851
+ plupload.each(fileInputs, function(fileInput) {
1852
+ fileInput.disable(disabled);
1853
+ });
1854
+ }
1855
+
1856
+ this.trigger('DisableBrowse', disabled);
1857
+ },
1858
+
1859
+ /**
1860
+ * Returns the specified file object by id.
1861
+ *
1862
+ * @method getFile
1863
+ * @param {String} id File id to look for.
1864
+ * @return {plupload.File} File object or undefined if it wasn't found;
1865
+ */
1866
+ getFile : function(id) {
1867
+ var i;
1868
+ for (i = files.length - 1; i >= 0; i--) {
1869
+ if (files[i].id === id) {
1870
+ return files[i];
1871
+ }
1872
+ }
1873
+ },
1874
+
1875
+ /**
1876
+ * Adds file to the queue programmatically. Can be native file, instance of Plupload.File,
1877
+ * instance of mOxie.File, input[type="file"] element, or array of these. Fires FilesAdded,
1878
+ * if any files were added to the queue. Otherwise nothing happens.
1879
+ *
1880
+ * @method addFile
1881
+ * @since 2.0
1882
+ * @param {plupload.File|mOxie.File|File|Node|Array} file File or files to add to the queue.
1883
+ * @param {String} [fileName] If specified, will be used as a name for the file
1884
+ */
1885
+ addFile : function(file, fileName) {
1886
+ var self = this
1887
+ , queue = []
1888
+ , filesAdded = []
1889
+ , ruid
1890
+ ;
1891
+
1892
+ function filterFile(file, cb) {
1893
+ var queue = [];
1894
+ o.each(self.settings.filters, function(rule, name) {
1895
+ if (fileFilters[name]) {
1896
+ queue.push(function(cb) {
1897
+ fileFilters[name].call(self, rule, file, function(res) {
1898
+ cb(!res);
1899
+ });
1900
+ });
1901
+ }
1902
+ });
1903
+ o.inSeries(queue, cb);
1904
+ }
1905
+
1906
+ /**
1907
+ * @method resolveFile
1908
+ * @private
1909
+ * @param {o.File|o.Blob|plupload.File|File|Blob|input[type="file"]} file
1910
+ */
1911
+ function resolveFile(file) {
1912
+ var type = o.typeOf(file);
1913
+
1914
+ // o.File
1915
+ if (file instanceof o.File) {
1916
+ if (!file.ruid && !file.isDetached()) {
1917
+ if (!ruid) { // weird case
1918
+ return false;
1919
+ }
1920
+ file.ruid = ruid;
1921
+ file.connectRuntime(ruid);
1922
+ }
1923
+ resolveFile(new plupload.File(file));
1924
+ }
1925
+ // o.Blob
1926
+ else if (file instanceof o.Blob) {
1927
+ resolveFile(file.getSource());
1928
+ file.destroy();
1929
+ }
1930
+ // plupload.File - final step for other branches
1931
+ else if (file instanceof plupload.File) {
1932
+ if (fileName) {
1933
+ file.name = fileName;
1934
+ }
1935
+
1936
+ queue.push(function(cb) {
1937
+ // run through the internal and user-defined filters, if any
1938
+ filterFile(file, function(err) {
1939
+ if (!err) {
1940
+ // make files available for the filters by updating the main queue directly
1941
+ files.push(file);
1942
+ // collect the files that will be passed to FilesAdded event
1943
+ filesAdded.push(file);
1944
+
1945
+ self.trigger("FileFiltered", file);
1946
+ }
1947
+ delay(cb, 1); // do not build up recursions or eventually we might hit the limits
1948
+ });
1949
+ });
1950
+ }
1951
+ // native File or blob
1952
+ else if (o.inArray(type, ['file', 'blob']) !== -1) {
1953
+ resolveFile(new o.File(null, file));
1954
+ }
1955
+ // input[type="file"]
1956
+ else if (type === 'node' && o.typeOf(file.files) === 'filelist') {
1957
+ // if we are dealing with input[type="file"]
1958
+ o.each(file.files, resolveFile);
1959
+ }
1960
+ // mixed array of any supported types (see above)
1961
+ else if (type === 'array') {
1962
+ fileName = null; // should never happen, but unset anyway to avoid funny situations
1963
+ o.each(file, resolveFile);
1964
+ }
1965
+ }
1966
+
1967
+ ruid = getRUID();
1968
+
1969
+ resolveFile(file);
1970
+
1971
+ if (queue.length) {
1972
+ o.inSeries(queue, function() {
1973
+ // if any files left after filtration, trigger FilesAdded
1974
+ if (filesAdded.length) {
1975
+ self.trigger("FilesAdded", filesAdded);
1976
+ }
1977
+ });
1978
+ }
1979
+ },
1980
+
1981
+ /**
1982
+ * Removes a specific file.
1983
+ *
1984
+ * @method removeFile
1985
+ * @param {plupload.File|String} file File to remove from queue.
1986
+ */
1987
+ removeFile : function(file) {
1988
+ var id = typeof(file) === 'string' ? file : file.id;
1989
+
1990
+ for (var i = files.length - 1; i >= 0; i--) {
1991
+ if (files[i].id === id) {
1992
+ return this.splice(i, 1)[0];
1993
+ }
1994
+ }
1995
+ },
1996
+
1997
+ /**
1998
+ * Removes part of the queue and returns the files removed. This will also trigger the FilesRemoved and QueueChanged events.
1999
+ *
2000
+ * @method splice
2001
+ * @param {Number} start (Optional) Start index to remove from.
2002
+ * @param {Number} length (Optional) Lengh of items to remove.
2003
+ * @return {Array} Array of files that was removed.
2004
+ */
2005
+ splice : function(start, length) {
2006
+ // Splice and trigger events
2007
+ var removed = files.splice(start === undef ? 0 : start, length === undef ? files.length : length);
2008
+
2009
+ // if upload is in progress we need to stop it and restart after files are removed
2010
+ var restartRequired = false;
2011
+ if (this.state == plupload.STARTED) { // upload in progress
2012
+ plupload.each(removed, function(file) {
2013
+ if (file.status === plupload.UPLOADING) {
2014
+ restartRequired = true; // do not restart, unless file that is being removed is uploading
2015
+ return false;
2016
+ }
2017
+ });
2018
+
2019
+ if (restartRequired) {
2020
+ this.stop();
2021
+ }
2022
+ }
2023
+
2024
+ this.trigger("FilesRemoved", removed);
2025
+
2026
+ // Dispose any resources allocated by those files
2027
+ plupload.each(removed, function(file) {
2028
+ file.destroy();
2029
+ });
2030
+
2031
+ if (restartRequired) {
2032
+ this.start();
2033
+ }
2034
+
2035
+ return removed;
2036
+ },
2037
+
2038
+ /**
2039
+ * Dispatches the specified event name and it's arguments to all listeners.
2040
+ *
2041
+ *
2042
+ * @method trigger
2043
+ * @param {String} name Event name to fire.
2044
+ * @param {Object..} Multiple arguments to pass along to the listener functions.
2045
+ */
2046
+
2047
+ /**
2048
+ * Check whether uploader has any listeners to the specified event.
2049
+ *
2050
+ * @method hasEventListener
2051
+ * @param {String} name Event name to check for.
2052
+ */
2053
+
2054
+
2055
+ /**
2056
+ * Adds an event listener by name.
2057
+ *
2058
+ * @method bind
2059
+ * @param {String} name Event name to listen for.
2060
+ * @param {function} func Function to call ones the event gets fired.
2061
+ * @param {Object} scope Optional scope to execute the specified function in.
2062
+ */
2063
+ bind : function(name, func, scope) {
2064
+ var self = this;
2065
+ // adapt moxie EventTarget style to Plupload-like
2066
+ plupload.Uploader.prototype.bind.call(this, name, function() {
2067
+ var args = [].slice.call(arguments);
2068
+ args.splice(0, 1, self); // replace event object with uploader instance
2069
+ return func.apply(this, args);
2070
+ }, 0, scope);
2071
+ },
2072
+
2073
+ /**
2074
+ * Removes the specified event listener.
2075
+ *
2076
+ * @method unbind
2077
+ * @param {String} name Name of event to remove.
2078
+ * @param {function} func Function to remove from listener.
2079
+ */
2080
+
2081
+ /**
2082
+ * Removes all event listeners.
2083
+ *
2084
+ * @method unbindAll
2085
+ */
2086
+
2087
+
2088
+ /**
2089
+ * Destroys Plupload instance and cleans after itself.
2090
+ *
2091
+ * @method destroy
2092
+ */
2093
+ destroy : function() {
2094
+ this.trigger('Destroy');
2095
+ settings = total = null; // purge these exclusively
2096
+ this.unbindAll();
2097
+ }
2098
+ });
2099
+ };
2100
+
2101
+ plupload.Uploader.prototype = o.EventTarget.instance;
2102
+
2103
+ /**
2104
+ * Constructs a new file instance.
2105
+ *
2106
+ * @class File
2107
+ * @constructor
2108
+ *
2109
+ * @param {Object} file Object containing file properties
2110
+ * @param {String} file.name Name of the file.
2111
+ * @param {Number} file.size File size.
2112
+ */
2113
+ plupload.File = (function() {
2114
+ var filepool = {};
2115
+
2116
+ function PluploadFile(file) {
2117
+
2118
+ plupload.extend(this, {
2119
+
2120
+ /**
2121
+ * File id this is a globally unique id for the specific file.
2122
+ *
2123
+ * @property id
2124
+ * @type String
2125
+ */
2126
+ id: plupload.guid(),
2127
+
2128
+ /**
2129
+ * File name for example "myfile.gif".
2130
+ *
2131
+ * @property name
2132
+ * @type String
2133
+ */
2134
+ name: file.name || file.fileName,
2135
+
2136
+ /**
2137
+ * File type, `e.g image/jpeg`
2138
+ *
2139
+ * @property type
2140
+ * @type String
2141
+ */
2142
+ type: file.type || '',
2143
+
2144
+ /**
2145
+ * File size in bytes (may change after client-side manupilation).
2146
+ *
2147
+ * @property size
2148
+ * @type Number
2149
+ */
2150
+ size: file.size || file.fileSize,
2151
+
2152
+ /**
2153
+ * Original file size in bytes.
2154
+ *
2155
+ * @property origSize
2156
+ * @type Number
2157
+ */
2158
+ origSize: file.size || file.fileSize,
2159
+
2160
+ /**
2161
+ * Number of bytes uploaded of the files total size.
2162
+ *
2163
+ * @property loaded
2164
+ * @type Number
2165
+ */
2166
+ loaded: 0,
2167
+
2168
+ /**
2169
+ * Number of percentage uploaded of the file.
2170
+ *
2171
+ * @property percent
2172
+ * @type Number
2173
+ */
2174
+ percent: 0,
2175
+
2176
+ /**
2177
+ * Status constant matching the plupload states QUEUED, UPLOADING, FAILED, DONE.
2178
+ *
2179
+ * @property status
2180
+ * @type Number
2181
+ * @see plupload
2182
+ */
2183
+ status: plupload.QUEUED,
2184
+
2185
+ /**
2186
+ * Date of last modification.
2187
+ *
2188
+ * @property lastModifiedDate
2189
+ * @type {String}
2190
+ */
2191
+ lastModifiedDate: file.lastModifiedDate || (new Date()).toLocaleString(), // Thu Aug 23 2012 19:40:00 GMT+0400 (GET)
2192
+
2193
+ /**
2194
+ * Returns native window.File object, when it's available.
2195
+ *
2196
+ * @method getNative
2197
+ * @return {window.File} or null, if plupload.File is of different origin
2198
+ */
2199
+ getNative: function() {
2200
+ var file = this.getSource().getSource();
2201
+ return o.inArray(o.typeOf(file), ['blob', 'file']) !== -1 ? file : null;
2202
+ },
2203
+
2204
+ /**
2205
+ * Returns mOxie.File - unified wrapper object that can be used across runtimes.
2206
+ *
2207
+ * @method getSource
2208
+ * @return {mOxie.File} or null
2209
+ */
2210
+ getSource: function() {
2211
+ if (!filepool[this.id]) {
2212
+ return null;
2213
+ }
2214
+ return filepool[this.id];
2215
+ },
2216
+
2217
+ /**
2218
+ * Destroys plupload.File object.
2219
+ *
2220
+ * @method destroy
2221
+ */
2222
+ destroy: function() {
2223
+ var src = this.getSource();
2224
+ if (src) {
2225
+ src.destroy();
2226
+ delete filepool[this.id];
2227
+ }
2228
+ }
2229
+ });
2230
+
2231
+ filepool[this.id] = file;
2232
+ }
2233
+
2234
+ return PluploadFile;
2235
+ }());
2236
+
2237
+
2238
+ /**
2239
+ * Constructs a queue progress.
2240
+ *
2241
+ * @class QueueProgress
2242
+ * @constructor
2243
+ */
2244
+ plupload.QueueProgress = function() {
2245
+ var self = this; // Setup alias for self to reduce code size when it's compressed
2246
+
2247
+ /**
2248
+ * Total queue file size.
2249
+ *
2250
+ * @property size
2251
+ * @type Number
2252
+ */
2253
+ self.size = 0;
2254
+
2255
+ /**
2256
+ * Total bytes uploaded.
2257
+ *
2258
+ * @property loaded
2259
+ * @type Number
2260
+ */
2261
+ self.loaded = 0;
2262
+
2263
+ /**
2264
+ * Number of files uploaded.
2265
+ *
2266
+ * @property uploaded
2267
+ * @type Number
2268
+ */
2269
+ self.uploaded = 0;
2270
+
2271
+ /**
2272
+ * Number of files failed to upload.
2273
+ *
2274
+ * @property failed
2275
+ * @type Number
2276
+ */
2277
+ self.failed = 0;
2278
+
2279
+ /**
2280
+ * Number of files yet to be uploaded.
2281
+ *
2282
+ * @property queued
2283
+ * @type Number
2284
+ */
2285
+ self.queued = 0;
2286
+
2287
+ /**
2288
+ * Total percent of the uploaded bytes.
2289
+ *
2290
+ * @property percent
2291
+ * @type Number
2292
+ */
2293
+ self.percent = 0;
2294
+
2295
+ /**
2296
+ * Bytes uploaded per second.
2297
+ *
2298
+ * @property bytesPerSec
2299
+ * @type Number
2300
+ */
2301
+ self.bytesPerSec = 0;
2302
+
2303
+ /**
2304
+ * Resets the progress to it's initial values.
2305
+ *
2306
+ * @method reset
2307
+ */
2308
+ self.reset = function() {
2309
+ self.size = self.loaded = self.uploaded = self.failed = self.queued = self.percent = self.bytesPerSec = 0;
2310
+ };
2311
+ };
2312
+
2313
+ window.plupload = plupload;
2314
+
2315
+ }(window, mOxie));