pail 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ module Pail
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module Pail
2
+ VERSION = "0.1.0"
3
+ end
data/pail.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pail/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pail"
8
+ spec.version = Pail::VERSION
9
+ spec.authors = ["Eddie Johnston"]
10
+ spec.email = ["eddie@beanstalk.ie"]
11
+
12
+
13
+ spec.summary = %q{Upload assets firectly to S3 using the Plupload JS Library}
14
+ spec.description = %q{When using a read-only file-system, it makes sense to upload assests directly to cloud storage. This gem makes it easy to upload directly to an S3 bucket using the Plupload JS Library. Callback functions can be triggered to run once files have finished uploading so that they can be processed by your application.}
15
+ spec.homepage = "https://github.com/eddiej/pail"
16
+ spec.license = "MIT"
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.8"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "rails" ## for testing ::Rails::Engine
27
+ spec.add_development_dependency "rspec-rails"
28
+ spec.add_development_dependency "guard"
29
+ spec.add_development_dependency "guard-rspec"
30
+ spec.add_development_dependency "coveralls"
31
+ end
@@ -0,0 +1 @@
1
+ //= require plupload/plupload.full.min.js
@@ -0,0 +1,2341 @@
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);
16
+ /**
17
+ * Plupload - multi-runtime File Uploader
18
+ * v2.1.3
19
+ *
20
+ * Copyright 2013, Moxiecode Systems AB
21
+ * Released under GPL License.
22
+ *
23
+ * License: http://www.plupload.com/license
24
+ * Contributing: http://www.plupload.com/contributing
25
+ *
26
+ * Date: 2015-05-11
27
+ *//**
28
+ * Plupload - multi-runtime File Uploader
29
+ * v2.1.3
30
+ *
31
+ * Copyright 2013, Moxiecode Systems AB
32
+ * Released under GPL License.
33
+ *
34
+ * License: http://www.plupload.com/license
35
+ * Contributing: http://www.plupload.com/contributing
36
+ *
37
+ * Date: 2015-05-11
38
+ */
39
+ /**
40
+ * Plupload.js
41
+ *
42
+ * Copyright 2013, Moxiecode Systems AB
43
+ * Released under GPL License.
44
+ *
45
+ * License: http://www.plupload.com/license
46
+ * Contributing: http://www.plupload.com/contributing
47
+ */
48
+
49
+ /*global mOxie:true */
50
+
51
+ ;(function(window, o, undef) {
52
+
53
+ var delay = window.setTimeout
54
+ , fileFilters = {}
55
+ ;
56
+
57
+ // convert plupload features to caps acceptable by mOxie
58
+ function normalizeCaps(settings) {
59
+ var features = settings.required_features, caps = {};
60
+
61
+ function resolve(feature, value, strict) {
62
+ // Feature notation is deprecated, use caps (this thing here is required for backward compatibility)
63
+ var map = {
64
+ chunks: 'slice_blob',
65
+ jpgresize: 'send_binary_string',
66
+ pngresize: 'send_binary_string',
67
+ progress: 'report_upload_progress',
68
+ multi_selection: 'select_multiple',
69
+ dragdrop: 'drag_and_drop',
70
+ drop_element: 'drag_and_drop',
71
+ headers: 'send_custom_headers',
72
+ urlstream_upload: 'send_binary_string',
73
+ canSendBinary: 'send_binary',
74
+ triggerDialog: 'summon_file_dialog'
75
+ };
76
+
77
+ if (map[feature]) {
78
+ caps[map[feature]] = value;
79
+ } else if (!strict) {
80
+ caps[feature] = value;
81
+ }
82
+ }
83
+
84
+ if (typeof(features) === 'string') {
85
+ plupload.each(features.split(/\s*,\s*/), function(feature) {
86
+ resolve(feature, true);
87
+ });
88
+ } else if (typeof(features) === 'object') {
89
+ plupload.each(features, function(value, feature) {
90
+ resolve(feature, value);
91
+ });
92
+ } else if (features === true) {
93
+ // check settings for required features
94
+ if (settings.chunk_size > 0) {
95
+ caps.slice_blob = true;
96
+ }
97
+
98
+ if (settings.resize.enabled || !settings.multipart) {
99
+ caps.send_binary_string = true;
100
+ }
101
+
102
+ plupload.each(settings, function(value, feature) {
103
+ resolve(feature, !!value, true); // strict check
104
+ });
105
+ }
106
+
107
+ return caps;
108
+ }
109
+
110
+ /**
111
+ * @module plupload
112
+ * @static
113
+ */
114
+ var plupload = {
115
+ /**
116
+ * Plupload version will be replaced on build.
117
+ *
118
+ * @property VERSION
119
+ * @for Plupload
120
+ * @static
121
+ * @final
122
+ */
123
+ VERSION : '2.1.3',
124
+
125
+ /**
126
+ * Inital state of the queue and also the state ones it's finished all it's uploads.
127
+ *
128
+ * @property STOPPED
129
+ * @static
130
+ * @final
131
+ */
132
+ STOPPED : 1,
133
+
134
+ /**
135
+ * Upload process is running
136
+ *
137
+ * @property STARTED
138
+ * @static
139
+ * @final
140
+ */
141
+ STARTED : 2,
142
+
143
+ /**
144
+ * File is queued for upload
145
+ *
146
+ * @property QUEUED
147
+ * @static
148
+ * @final
149
+ */
150
+ QUEUED : 1,
151
+
152
+ /**
153
+ * File is being uploaded
154
+ *
155
+ * @property UPLOADING
156
+ * @static
157
+ * @final
158
+ */
159
+ UPLOADING : 2,
160
+
161
+ /**
162
+ * File has failed to be uploaded
163
+ *
164
+ * @property FAILED
165
+ * @static
166
+ * @final
167
+ */
168
+ FAILED : 4,
169
+
170
+ /**
171
+ * File has been uploaded successfully
172
+ *
173
+ * @property DONE
174
+ * @static
175
+ * @final
176
+ */
177
+ DONE : 5,
178
+
179
+ // Error constants used by the Error event
180
+
181
+ /**
182
+ * Generic error for example if an exception is thrown inside Silverlight.
183
+ *
184
+ * @property GENERIC_ERROR
185
+ * @static
186
+ * @final
187
+ */
188
+ GENERIC_ERROR : -100,
189
+
190
+ /**
191
+ * HTTP transport error. For example if the server produces a HTTP status other than 200.
192
+ *
193
+ * @property HTTP_ERROR
194
+ * @static
195
+ * @final
196
+ */
197
+ HTTP_ERROR : -200,
198
+
199
+ /**
200
+ * Generic I/O error. For example if it wasn't possible to open the file stream on local machine.
201
+ *
202
+ * @property IO_ERROR
203
+ * @static
204
+ * @final
205
+ */
206
+ IO_ERROR : -300,
207
+
208
+ /**
209
+ * @property SECURITY_ERROR
210
+ * @static
211
+ * @final
212
+ */
213
+ SECURITY_ERROR : -400,
214
+
215
+ /**
216
+ * Initialization error. Will be triggered if no runtime was initialized.
217
+ *
218
+ * @property INIT_ERROR
219
+ * @static
220
+ * @final
221
+ */
222
+ INIT_ERROR : -500,
223
+
224
+ /**
225
+ * 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.
226
+ *
227
+ * @property FILE_SIZE_ERROR
228
+ * @static
229
+ * @final
230
+ */
231
+ FILE_SIZE_ERROR : -600,
232
+
233
+ /**
234
+ * File extension error. If the user selects a file that isn't valid according to the filters setting.
235
+ *
236
+ * @property FILE_EXTENSION_ERROR
237
+ * @static
238
+ * @final
239
+ */
240
+ FILE_EXTENSION_ERROR : -601,
241
+
242
+ /**
243
+ * Duplicate file error. If prevent_duplicates is set to true and user selects the same file again.
244
+ *
245
+ * @property FILE_DUPLICATE_ERROR
246
+ * @static
247
+ * @final
248
+ */
249
+ FILE_DUPLICATE_ERROR : -602,
250
+
251
+ /**
252
+ * Runtime will try to detect if image is proper one. Otherwise will throw this error.
253
+ *
254
+ * @property IMAGE_FORMAT_ERROR
255
+ * @static
256
+ * @final
257
+ */
258
+ IMAGE_FORMAT_ERROR : -700,
259
+
260
+ /**
261
+ * While working on files runtime may run out of memory and will throw this error.
262
+ *
263
+ * @since 2.1.2
264
+ * @property MEMORY_ERROR
265
+ * @static
266
+ * @final
267
+ */
268
+ MEMORY_ERROR : -701,
269
+
270
+ /**
271
+ * Each runtime has an upper limit on a dimension of the image it can handle. If bigger, will throw this error.
272
+ *
273
+ * @property IMAGE_DIMENSIONS_ERROR
274
+ * @static
275
+ * @final
276
+ */
277
+ IMAGE_DIMENSIONS_ERROR : -702,
278
+
279
+ /**
280
+ * Mime type lookup table.
281
+ *
282
+ * @property mimeTypes
283
+ * @type Object
284
+ * @final
285
+ */
286
+ mimeTypes : o.mimes,
287
+
288
+ /**
289
+ * In some cases sniffing is the only way around :(
290
+ */
291
+ ua: o.ua,
292
+
293
+ /**
294
+ * Gets the true type of the built-in object (better version of typeof).
295
+ * @credits Angus Croll (http://javascriptweblog.wordpress.com/)
296
+ *
297
+ * @method typeOf
298
+ * @static
299
+ * @param {Object} o Object to check.
300
+ * @return {String} Object [[Class]]
301
+ */
302
+ typeOf: o.typeOf,
303
+
304
+ /**
305
+ * Extends the specified object with another object.
306
+ *
307
+ * @method extend
308
+ * @static
309
+ * @param {Object} target Object to extend.
310
+ * @param {Object..} obj Multiple objects to extend with.
311
+ * @return {Object} Same as target, the extended object.
312
+ */
313
+ extend : o.extend,
314
+
315
+ /**
316
+ * Generates an unique ID. This is 99.99% unique since it takes the current time and 5 random numbers.
317
+ * The only way a user would be able to get the same ID is if the two persons at the same exact milisecond manages
318
+ * 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.
319
+ * 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
320
+ * to an user unique key.
321
+ *
322
+ * @method guid
323
+ * @static
324
+ * @return {String} Virtually unique id.
325
+ */
326
+ guid : o.guid,
327
+
328
+ /**
329
+ * Get array of DOM Elements by their ids.
330
+ *
331
+ * @method get
332
+ * @for Utils
333
+ * @param {String} id Identifier of the DOM Element
334
+ * @return {Array}
335
+ */
336
+ get : function get(ids) {
337
+ var els = [], el;
338
+
339
+ if (o.typeOf(ids) !== 'array') {
340
+ ids = [ids];
341
+ }
342
+
343
+ var i = ids.length;
344
+ while (i--) {
345
+ el = o.get(ids[i]);
346
+ if (el) {
347
+ els.push(el);
348
+ }
349
+ }
350
+
351
+ return els.length ? els : null;
352
+ },
353
+
354
+ /**
355
+ * Executes the callback function for each item in array/object. If you return false in the
356
+ * callback it will break the loop.
357
+ *
358
+ * @method each
359
+ * @static
360
+ * @param {Object} obj Object to iterate.
361
+ * @param {function} callback Callback function to execute for each item.
362
+ */
363
+ each : o.each,
364
+
365
+ /**
366
+ * Returns the absolute x, y position of an Element. The position will be returned in a object with x, y fields.
367
+ *
368
+ * @method getPos
369
+ * @static
370
+ * @param {Element} node HTML element or element id to get x, y position from.
371
+ * @param {Element} root Optional root element to stop calculations at.
372
+ * @return {object} Absolute position of the specified element object with x, y fields.
373
+ */
374
+ getPos : o.getPos,
375
+
376
+ /**
377
+ * Returns the size of the specified node in pixels.
378
+ *
379
+ * @method getSize
380
+ * @static
381
+ * @param {Node} node Node to get the size of.
382
+ * @return {Object} Object with a w and h property.
383
+ */
384
+ getSize : o.getSize,
385
+
386
+ /**
387
+ * Encodes the specified string.
388
+ *
389
+ * @method xmlEncode
390
+ * @static
391
+ * @param {String} s String to encode.
392
+ * @return {String} Encoded string.
393
+ */
394
+ xmlEncode : function(str) {
395
+ var xmlEncodeChars = {'<' : 'lt', '>' : 'gt', '&' : 'amp', '"' : 'quot', '\'' : '#39'}, xmlEncodeRegExp = /[<>&\"\']/g;
396
+
397
+ return str ? ('' + str).replace(xmlEncodeRegExp, function(chr) {
398
+ return xmlEncodeChars[chr] ? '&' + xmlEncodeChars[chr] + ';' : chr;
399
+ }) : str;
400
+ },
401
+
402
+ /**
403
+ * Forces anything into an array.
404
+ *
405
+ * @method toArray
406
+ * @static
407
+ * @param {Object} obj Object with length field.
408
+ * @return {Array} Array object containing all items.
409
+ */
410
+ toArray : o.toArray,
411
+
412
+ /**
413
+ * Find an element in array and return it's index if present, otherwise return -1.
414
+ *
415
+ * @method inArray
416
+ * @static
417
+ * @param {mixed} needle Element to find
418
+ * @param {Array} array
419
+ * @return {Int} Index of the element, or -1 if not found
420
+ */
421
+ inArray : o.inArray,
422
+
423
+ /**
424
+ * Extends the language pack object with new items.
425
+ *
426
+ * @method addI18n
427
+ * @static
428
+ * @param {Object} pack Language pack items to add.
429
+ * @return {Object} Extended language pack object.
430
+ */
431
+ addI18n : o.addI18n,
432
+
433
+ /**
434
+ * Translates the specified string by checking for the english string in the language pack lookup.
435
+ *
436
+ * @method translate
437
+ * @static
438
+ * @param {String} str String to look for.
439
+ * @return {String} Translated string or the input string if it wasn't found.
440
+ */
441
+ translate : o.translate,
442
+
443
+ /**
444
+ * Checks if object is empty.
445
+ *
446
+ * @method isEmptyObj
447
+ * @static
448
+ * @param {Object} obj Object to check.
449
+ * @return {Boolean}
450
+ */
451
+ isEmptyObj : o.isEmptyObj,
452
+
453
+ /**
454
+ * Checks if specified DOM element has specified class.
455
+ *
456
+ * @method hasClass
457
+ * @static
458
+ * @param {Object} obj DOM element like object to add handler to.
459
+ * @param {String} name Class name
460
+ */
461
+ hasClass : o.hasClass,
462
+
463
+ /**
464
+ * Adds specified className to specified DOM element.
465
+ *
466
+ * @method addClass
467
+ * @static
468
+ * @param {Object} obj DOM element like object to add handler to.
469
+ * @param {String} name Class name
470
+ */
471
+ addClass : o.addClass,
472
+
473
+ /**
474
+ * Removes specified className from specified DOM element.
475
+ *
476
+ * @method removeClass
477
+ * @static
478
+ * @param {Object} obj DOM element like object to add handler to.
479
+ * @param {String} name Class name
480
+ */
481
+ removeClass : o.removeClass,
482
+
483
+ /**
484
+ * Returns a given computed style of a DOM element.
485
+ *
486
+ * @method getStyle
487
+ * @static
488
+ * @param {Object} obj DOM element like object.
489
+ * @param {String} name Style you want to get from the DOM element
490
+ */
491
+ getStyle : o.getStyle,
492
+
493
+ /**
494
+ * Adds an event handler to the specified object and store reference to the handler
495
+ * in objects internal Plupload registry (@see removeEvent).
496
+ *
497
+ * @method addEvent
498
+ * @static
499
+ * @param {Object} obj DOM element like object to add handler to.
500
+ * @param {String} name Name to add event listener to.
501
+ * @param {Function} callback Function to call when event occurs.
502
+ * @param {String} (optional) key that might be used to add specifity to the event record.
503
+ */
504
+ addEvent : o.addEvent,
505
+
506
+ /**
507
+ * Remove event handler from the specified object. If third argument (callback)
508
+ * is not specified remove all events with the specified name.
509
+ *
510
+ * @method removeEvent
511
+ * @static
512
+ * @param {Object} obj DOM element to remove event listener(s) from.
513
+ * @param {String} name Name of event listener to remove.
514
+ * @param {Function|String} (optional) might be a callback or unique key to match.
515
+ */
516
+ removeEvent: o.removeEvent,
517
+
518
+ /**
519
+ * Remove all kind of events from the specified object
520
+ *
521
+ * @method removeAllEvents
522
+ * @static
523
+ * @param {Object} obj DOM element to remove event listeners from.
524
+ * @param {String} (optional) unique key to match, when removing events.
525
+ */
526
+ removeAllEvents: o.removeAllEvents,
527
+
528
+ /**
529
+ * Cleans the specified name from national characters (diacritics). The result will be a name with only a-z, 0-9 and _.
530
+ *
531
+ * @method cleanName
532
+ * @static
533
+ * @param {String} s String to clean up.
534
+ * @return {String} Cleaned string.
535
+ */
536
+ cleanName : function(name) {
537
+ var i, lookup;
538
+
539
+ // Replace diacritics
540
+ lookup = [
541
+ /[\300-\306]/g, 'A', /[\340-\346]/g, 'a',
542
+ /\307/g, 'C', /\347/g, 'c',
543
+ /[\310-\313]/g, 'E', /[\350-\353]/g, 'e',
544
+ /[\314-\317]/g, 'I', /[\354-\357]/g, 'i',
545
+ /\321/g, 'N', /\361/g, 'n',
546
+ /[\322-\330]/g, 'O', /[\362-\370]/g, 'o',
547
+ /[\331-\334]/g, 'U', /[\371-\374]/g, 'u'
548
+ ];
549
+
550
+ for (i = 0; i < lookup.length; i += 2) {
551
+ name = name.replace(lookup[i], lookup[i + 1]);
552
+ }
553
+
554
+ // Replace whitespace
555
+ name = name.replace(/\s+/g, '_');
556
+
557
+ // Remove anything else
558
+ name = name.replace(/[^a-z0-9_\-\.]+/gi, '');
559
+
560
+ return name;
561
+ },
562
+
563
+ /**
564
+ * Builds a full url out of a base URL and an object with items to append as query string items.
565
+ *
566
+ * @method buildUrl
567
+ * @static
568
+ * @param {String} url Base URL to append query string items to.
569
+ * @param {Object} items Name/value object to serialize as a querystring.
570
+ * @return {String} String with url + serialized query string items.
571
+ */
572
+ buildUrl : function(url, items) {
573
+ var query = '';
574
+
575
+ plupload.each(items, function(value, name) {
576
+ query += (query ? '&' : '') + encodeURIComponent(name) + '=' + encodeURIComponent(value);
577
+ });
578
+
579
+ if (query) {
580
+ url += (url.indexOf('?') > 0 ? '&' : '?') + query;
581
+ }
582
+
583
+ return url;
584
+ },
585
+
586
+ /**
587
+ * Formats the specified number as a size string for example 1024 becomes 1 KB.
588
+ *
589
+ * @method formatSize
590
+ * @static
591
+ * @param {Number} size Size to format as string.
592
+ * @return {String} Formatted size string.
593
+ */
594
+ formatSize : function(size) {
595
+
596
+ if (size === undef || /\D/.test(size)) {
597
+ return plupload.translate('N/A');
598
+ }
599
+
600
+ function round(num, precision) {
601
+ return Math.round(num * Math.pow(10, precision)) / Math.pow(10, precision);
602
+ }
603
+
604
+ var boundary = Math.pow(1024, 4);
605
+
606
+ // TB
607
+ if (size > boundary) {
608
+ return round(size / boundary, 1) + " " + plupload.translate('tb');
609
+ }
610
+
611
+ // GB
612
+ if (size > (boundary/=1024)) {
613
+ return round(size / boundary, 1) + " " + plupload.translate('gb');
614
+ }
615
+
616
+ // MB
617
+ if (size > (boundary/=1024)) {
618
+ return round(size / boundary, 1) + " " + plupload.translate('mb');
619
+ }
620
+
621
+ // KB
622
+ if (size > 1024) {
623
+ return Math.round(size / 1024) + " " + plupload.translate('kb');
624
+ }
625
+
626
+ return size + " " + plupload.translate('b');
627
+ },
628
+
629
+
630
+ /**
631
+ * Parses the specified size string into a byte value. For example 10kb becomes 10240.
632
+ *
633
+ * @method parseSize
634
+ * @static
635
+ * @param {String|Number} size String to parse or number to just pass through.
636
+ * @return {Number} Size in bytes.
637
+ */
638
+ parseSize : o.parseSizeStr,
639
+
640
+
641
+ /**
642
+ * A way to predict what runtime will be choosen in the current environment with the
643
+ * specified settings.
644
+ *
645
+ * @method predictRuntime
646
+ * @static
647
+ * @param {Object|String} config Plupload settings to check
648
+ * @param {String} [runtimes] Comma-separated list of runtimes to check against
649
+ * @return {String} Type of compatible runtime
650
+ */
651
+ predictRuntime : function(config, runtimes) {
652
+ var up, runtime;
653
+
654
+ up = new plupload.Uploader(config);
655
+ runtime = o.Runtime.thatCan(up.getOption().required_features, runtimes || config.runtimes);
656
+ up.destroy();
657
+ return runtime;
658
+ },
659
+
660
+ /**
661
+ * Registers a filter that will be executed for each file added to the queue.
662
+ * If callback returns false, file will not be added.
663
+ *
664
+ * Callback receives two arguments: a value for the filter as it was specified in settings.filters
665
+ * and a file to be filtered. Callback is executed in the context of uploader instance.
666
+ *
667
+ * @method addFileFilter
668
+ * @static
669
+ * @param {String} name Name of the filter by which it can be referenced in settings.filters
670
+ * @param {String} cb Callback - the actual routine that every added file must pass
671
+ */
672
+ addFileFilter: function(name, cb) {
673
+ fileFilters[name] = cb;
674
+ }
675
+ };
676
+
677
+
678
+ plupload.addFileFilter('mime_types', function(filters, file, cb) {
679
+ if (filters.length && !filters.regexp.test(file.name)) {
680
+ this.trigger('Error', {
681
+ code : plupload.FILE_EXTENSION_ERROR,
682
+ message : plupload.translate('File extension error.'),
683
+ file : file
684
+ });
685
+ cb(false);
686
+ } else {
687
+ cb(true);
688
+ }
689
+ });
690
+
691
+
692
+ plupload.addFileFilter('max_file_size', function(maxSize, file, cb) {
693
+ var undef;
694
+
695
+ maxSize = plupload.parseSize(maxSize);
696
+
697
+ // Invalid file size
698
+ if (file.size !== undef && maxSize && file.size > maxSize) {
699
+ this.trigger('Error', {
700
+ code : plupload.FILE_SIZE_ERROR,
701
+ message : plupload.translate('File size error.'),
702
+ file : file
703
+ });
704
+ cb(false);
705
+ } else {
706
+ cb(true);
707
+ }
708
+ });
709
+
710
+
711
+ plupload.addFileFilter('prevent_duplicates', function(value, file, cb) {
712
+ if (value) {
713
+ var ii = this.files.length;
714
+ while (ii--) {
715
+ // Compare by name and size (size might be 0 or undefined, but still equivalent for both)
716
+ if (file.name === this.files[ii].name && file.size === this.files[ii].size) {
717
+ this.trigger('Error', {
718
+ code : plupload.FILE_DUPLICATE_ERROR,
719
+ message : plupload.translate('Duplicate file error.'),
720
+ file : file
721
+ });
722
+ cb(false);
723
+ return;
724
+ }
725
+ }
726
+ }
727
+ cb(true);
728
+ });
729
+
730
+
731
+ /**
732
+ @class Uploader
733
+ @constructor
734
+
735
+ @param {Object} settings For detailed information about each option check documentation.
736
+ @param {String|DOMElement} settings.browse_button id of the DOM element or DOM element itself to use as file dialog trigger.
737
+ @param {String} settings.url URL of the server-side upload handler.
738
+ @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.
739
+ @param {Boolean} [settings.send_chunk_number=true] Whether to send chunks and chunk numbers, or total and offset bytes.
740
+ @param {String} [settings.container] id of the DOM element to use as a container for uploader structures. Defaults to document.body.
741
+ @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.
742
+ @param {String} [settings.file_data_name="file"] Name for the file field in Multipart formated message.
743
+ @param {Object} [settings.filters={}] Set of file type filters.
744
+ @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`
745
+ @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`.
746
+ @param {Boolean} [settings.filters.prevent_duplicates=false] Do not let duplicates into the queue. Dispatches `plupload.FILE_DUPLICATE_ERROR`.
747
+ @param {String} [settings.flash_swf_url] URL of the Flash swf.
748
+ @param {Object} [settings.headers] Custom headers to send with the upload. Hash of name/value pairs.
749
+ @param {Number} [settings.max_retries=0] How many times to retry the chunk or file, before triggering Error event.
750
+ @param {Boolean} [settings.multipart=true] Whether to send file and additional parameters as Multipart formated message.
751
+ @param {Object} [settings.multipart_params] Hash of key/value pairs to send with every file upload.
752
+ @param {Boolean} [settings.multi_selection=true] Enable ability to select multiple files at once in file dialog.
753
+ @param {String|Object} [settings.required_features] Either comma-separated list or hash of required features that chosen runtime should absolutely possess.
754
+ @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}`
755
+ @param {Number} [settings.resize.width] If image is bigger, it will be resized.
756
+ @param {Number} [settings.resize.height] If image is bigger, it will be resized.
757
+ @param {Number} [settings.resize.quality=90] Compression quality for jpegs (1-100).
758
+ @param {Boolean} [settings.resize.crop=false] Whether to crop images to exact dimensions. By default they will be resized proportionally.
759
+ @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.
760
+ @param {String} [settings.silverlight_xap_url] URL of the Silverlight xap.
761
+ @param {Boolean} [settings.unique_names=false] If true will generate unique filenames for uploaded files.
762
+ @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).
763
+ */
764
+ plupload.Uploader = function(options) {
765
+ /**
766
+ * Fires when the current RunTime has been initialized.
767
+ *
768
+ * @event Init
769
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
770
+ */
771
+
772
+ /**
773
+ * Fires after the init event incase you need to perform actions there.
774
+ *
775
+ * @event PostInit
776
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
777
+ */
778
+
779
+ /**
780
+ * Fires when the option is changed in via uploader.setOption().
781
+ *
782
+ * @event OptionChanged
783
+ * @since 2.1
784
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
785
+ * @param {String} name Name of the option that was changed
786
+ * @param {Mixed} value New value for the specified option
787
+ * @param {Mixed} oldValue Previous value of the option
788
+ */
789
+
790
+ /**
791
+ * Fires when the silverlight/flash or other shim needs to move.
792
+ *
793
+ * @event Refresh
794
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
795
+ */
796
+
797
+ /**
798
+ * Fires when the overall state is being changed for the upload queue.
799
+ *
800
+ * @event StateChanged
801
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
802
+ */
803
+
804
+ /**
805
+ * Fires when browse_button is clicked and browse dialog shows.
806
+ *
807
+ * @event Browse
808
+ * @since 2.1.2
809
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
810
+ */
811
+
812
+ /**
813
+ * Fires for every filtered file before it is added to the queue.
814
+ *
815
+ * @event FileFiltered
816
+ * @since 2.1
817
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
818
+ * @param {plupload.File} file Another file that has to be added to the queue.
819
+ */
820
+
821
+ /**
822
+ * Fires when the file queue is changed. In other words when files are added/removed to the files array of the uploader instance.
823
+ *
824
+ * @event QueueChanged
825
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
826
+ */
827
+
828
+ /**
829
+ * Fires after files were filtered and added to the queue.
830
+ *
831
+ * @event FilesAdded
832
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
833
+ * @param {Array} files Array of file objects that were added to queue by the user.
834
+ */
835
+
836
+ /**
837
+ * Fires when file is removed from the queue.
838
+ *
839
+ * @event FilesRemoved
840
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
841
+ * @param {Array} files Array of files that got removed.
842
+ */
843
+
844
+ /**
845
+ * Fires when just before a file is uploaded. This event enables you to override settings
846
+ * on the uploader instance before the file is uploaded.
847
+ *
848
+ * @event BeforeUpload
849
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
850
+ * @param {plupload.File} file File to be uploaded.
851
+ */
852
+
853
+ /**
854
+ * Fires when a file is to be uploaded by the runtime.
855
+ *
856
+ * @event UploadFile
857
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
858
+ * @param {plupload.File} file File to be uploaded.
859
+ */
860
+
861
+ /**
862
+ * Fires while a file is being uploaded. Use this event to update the current file upload progress.
863
+ *
864
+ * @event UploadProgress
865
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
866
+ * @param {plupload.File} file File that is currently being uploaded.
867
+ */
868
+
869
+ /**
870
+ * Fires when file chunk is uploaded.
871
+ *
872
+ * @event ChunkUploaded
873
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
874
+ * @param {plupload.File} file File that the chunk was uploaded for.
875
+ * @param {Object} response Object with response properties.
876
+ */
877
+
878
+ /**
879
+ * Fires when a file is successfully uploaded.
880
+ *
881
+ * @event FileUploaded
882
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
883
+ * @param {plupload.File} file File that was uploaded.
884
+ * @param {Object} response Object with response properties.
885
+ */
886
+
887
+ /**
888
+ * Fires when all files in a queue are uploaded.
889
+ *
890
+ * @event UploadComplete
891
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
892
+ * @param {Array} files Array of file objects that was added to queue/selected by the user.
893
+ */
894
+
895
+ /**
896
+ * Fires when a error occurs.
897
+ *
898
+ * @event Error
899
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
900
+ * @param {Object} error Contains code, message and sometimes file and other details.
901
+ */
902
+
903
+ /**
904
+ * Fires when destroy method is called.
905
+ *
906
+ * @event Destroy
907
+ * @param {plupload.Uploader} uploader Uploader instance sending the event.
908
+ */
909
+ var uid = plupload.guid()
910
+ , settings
911
+ , files = []
912
+ , preferred_caps = {}
913
+ , fileInputs = []
914
+ , fileDrops = []
915
+ , startTime
916
+ , total
917
+ , disabled = false
918
+ , xhr
919
+ ;
920
+
921
+
922
+ // Private methods
923
+ function uploadNext() {
924
+ var file, count = 0, i;
925
+
926
+ if (this.state == plupload.STARTED) {
927
+ // Find first QUEUED file
928
+ for (i = 0; i < files.length; i++) {
929
+ if (!file && files[i].status == plupload.QUEUED) {
930
+ file = files[i];
931
+ if (this.trigger("BeforeUpload", file)) {
932
+ file.status = plupload.UPLOADING;
933
+ this.trigger("UploadFile", file);
934
+ }
935
+ } else {
936
+ count++;
937
+ }
938
+ }
939
+
940
+ // All files are DONE or FAILED
941
+ if (count == files.length) {
942
+ if (this.state !== plupload.STOPPED) {
943
+ this.state = plupload.STOPPED;
944
+ this.trigger("StateChanged");
945
+ }
946
+ this.trigger("UploadComplete", files);
947
+ }
948
+ }
949
+ }
950
+
951
+
952
+ function calcFile(file) {
953
+ file.percent = file.size > 0 ? Math.ceil(file.loaded / file.size * 100) : 100;
954
+ calc();
955
+ }
956
+
957
+
958
+ function calc() {
959
+ var i, file;
960
+
961
+ // Reset stats
962
+ total.reset();
963
+
964
+ // Check status, size, loaded etc on all files
965
+ for (i = 0; i < files.length; i++) {
966
+ file = files[i];
967
+
968
+ if (file.size !== undef) {
969
+ // We calculate totals based on original file size
970
+ total.size += file.origSize;
971
+
972
+ // Since we cannot predict file size after resize, we do opposite and
973
+ // interpolate loaded amount to match magnitude of total
974
+ total.loaded += file.loaded * file.origSize / file.size;
975
+ } else {
976
+ total.size = undef;
977
+ }
978
+
979
+ if (file.status == plupload.DONE) {
980
+ total.uploaded++;
981
+ } else if (file.status == plupload.FAILED) {
982
+ total.failed++;
983
+ } else {
984
+ total.queued++;
985
+ }
986
+ }
987
+
988
+ // If we couldn't calculate a total file size then use the number of files to calc percent
989
+ if (total.size === undef) {
990
+ total.percent = files.length > 0 ? Math.ceil(total.uploaded / files.length * 100) : 0;
991
+ } else {
992
+ total.bytesPerSec = Math.ceil(total.loaded / ((+new Date() - startTime || 1) / 1000.0));
993
+ total.percent = total.size > 0 ? Math.ceil(total.loaded / total.size * 100) : 0;
994
+ }
995
+ }
996
+
997
+
998
+ function getRUID() {
999
+ var ctrl = fileInputs[0] || fileDrops[0];
1000
+ if (ctrl) {
1001
+ return ctrl.getRuntime().uid;
1002
+ }
1003
+ return false;
1004
+ }
1005
+
1006
+
1007
+ function runtimeCan(file, cap) {
1008
+ if (file.ruid) {
1009
+ var info = o.Runtime.getInfo(file.ruid);
1010
+ if (info) {
1011
+ return info.can(cap);
1012
+ }
1013
+ }
1014
+ return false;
1015
+ }
1016
+
1017
+
1018
+ function bindEventListeners() {
1019
+ this.bind('FilesAdded FilesRemoved', function(up) {
1020
+ up.trigger('QueueChanged');
1021
+ up.refresh();
1022
+ });
1023
+
1024
+ this.bind('CancelUpload', onCancelUpload);
1025
+
1026
+ this.bind('BeforeUpload', onBeforeUpload);
1027
+
1028
+ this.bind('UploadFile', onUploadFile);
1029
+
1030
+ this.bind('UploadProgress', onUploadProgress);
1031
+
1032
+ this.bind('StateChanged', onStateChanged);
1033
+
1034
+ this.bind('QueueChanged', calc);
1035
+
1036
+ this.bind('Error', onError);
1037
+
1038
+ this.bind('FileUploaded', onFileUploaded);
1039
+
1040
+ this.bind('Destroy', onDestroy);
1041
+ }
1042
+
1043
+
1044
+ function initControls(settings, cb) {
1045
+ var self = this, inited = 0, queue = [];
1046
+
1047
+ // common settings
1048
+ var options = {
1049
+ runtime_order: settings.runtimes,
1050
+ required_caps: settings.required_features,
1051
+ preferred_caps: preferred_caps,
1052
+ swf_url: settings.flash_swf_url,
1053
+ xap_url: settings.silverlight_xap_url
1054
+ };
1055
+
1056
+ // add runtime specific options if any
1057
+ plupload.each(settings.runtimes.split(/\s*,\s*/), function(runtime) {
1058
+ if (settings[runtime]) {
1059
+ options[runtime] = settings[runtime];
1060
+ }
1061
+ });
1062
+
1063
+ // initialize file pickers - there can be many
1064
+ if (settings.browse_button) {
1065
+ plupload.each(settings.browse_button, function(el) {
1066
+ queue.push(function(cb) {
1067
+ var fileInput = new o.FileInput(plupload.extend({}, options, {
1068
+ accept: settings.filters.mime_types,
1069
+ name: settings.file_data_name,
1070
+ multiple: settings.multi_selection,
1071
+ container: settings.container,
1072
+ browse_button: el
1073
+ }));
1074
+
1075
+ fileInput.onready = function() {
1076
+ var info = o.Runtime.getInfo(this.ruid);
1077
+
1078
+ // for backward compatibility
1079
+ o.extend(self.features, {
1080
+ chunks: info.can('slice_blob'),
1081
+ multipart: info.can('send_multipart'),
1082
+ multi_selection: info.can('select_multiple')
1083
+ });
1084
+
1085
+ inited++;
1086
+ fileInputs.push(this);
1087
+ cb();
1088
+ };
1089
+
1090
+ fileInput.onchange = function() {
1091
+ self.addFile(this.files);
1092
+ };
1093
+
1094
+ fileInput.bind('mouseenter mouseleave mousedown mouseup', function(e) {
1095
+ if (!disabled) {
1096
+ if (settings.browse_button_hover) {
1097
+ if ('mouseenter' === e.type) {
1098
+ o.addClass(el, settings.browse_button_hover);
1099
+ } else if ('mouseleave' === e.type) {
1100
+ o.removeClass(el, settings.browse_button_hover);
1101
+ }
1102
+ }
1103
+
1104
+ if (settings.browse_button_active) {
1105
+ if ('mousedown' === e.type) {
1106
+ o.addClass(el, settings.browse_button_active);
1107
+ } else if ('mouseup' === e.type) {
1108
+ o.removeClass(el, settings.browse_button_active);
1109
+ }
1110
+ }
1111
+ }
1112
+ });
1113
+
1114
+ fileInput.bind('mousedown', function() {
1115
+ self.trigger('Browse');
1116
+ });
1117
+
1118
+ fileInput.bind('error runtimeerror', function() {
1119
+ fileInput = null;
1120
+ cb();
1121
+ });
1122
+
1123
+ fileInput.init();
1124
+ });
1125
+ });
1126
+ }
1127
+
1128
+ // initialize drop zones
1129
+ if (settings.drop_element) {
1130
+ plupload.each(settings.drop_element, function(el) {
1131
+ queue.push(function(cb) {
1132
+ var fileDrop = new o.FileDrop(plupload.extend({}, options, {
1133
+ drop_zone: el
1134
+ }));
1135
+
1136
+ fileDrop.onready = function() {
1137
+ var info = o.Runtime.getInfo(this.ruid);
1138
+
1139
+ self.features.dragdrop = info.can('drag_and_drop'); // for backward compatibility
1140
+
1141
+ inited++;
1142
+ fileDrops.push(this);
1143
+ cb();
1144
+ };
1145
+
1146
+ fileDrop.ondrop = function() {
1147
+ self.addFile(this.files);
1148
+ };
1149
+
1150
+ fileDrop.bind('error runtimeerror', function() {
1151
+ fileDrop = null;
1152
+ cb();
1153
+ });
1154
+
1155
+ fileDrop.init();
1156
+ });
1157
+ });
1158
+ }
1159
+
1160
+
1161
+ o.inSeries(queue, function() {
1162
+ if (typeof(cb) === 'function') {
1163
+ cb(inited);
1164
+ }
1165
+ });
1166
+ }
1167
+
1168
+
1169
+ function resizeImage(blob, params, cb) {
1170
+ var img = new o.Image();
1171
+
1172
+ try {
1173
+ img.onload = function() {
1174
+ // no manipulation required if...
1175
+ if (params.width > this.width &&
1176
+ params.height > this.height &&
1177
+ params.quality === undef &&
1178
+ params.preserve_headers &&
1179
+ !params.crop
1180
+ ) {
1181
+ this.destroy();
1182
+ return cb(blob);
1183
+ }
1184
+ // otherwise downsize
1185
+ img.downsize(params.width, params.height, params.crop, params.preserve_headers);
1186
+ };
1187
+
1188
+ img.onresize = function() {
1189
+ cb(this.getAsBlob(blob.type, params.quality));
1190
+ this.destroy();
1191
+ };
1192
+
1193
+ img.onerror = function() {
1194
+ cb(blob);
1195
+ };
1196
+
1197
+ img.load(blob);
1198
+ } catch(ex) {
1199
+ cb(blob);
1200
+ }
1201
+ }
1202
+
1203
+
1204
+ function setOption(option, value, init) {
1205
+ var self = this, reinitRequired = false;
1206
+
1207
+ function _setOption(option, value, init) {
1208
+ var oldValue = settings[option];
1209
+
1210
+ switch (option) {
1211
+ case 'max_file_size':
1212
+ if (option === 'max_file_size') {
1213
+ settings.max_file_size = settings.filters.max_file_size = value;
1214
+ }
1215
+ break;
1216
+
1217
+ case 'chunk_size':
1218
+ if (value = plupload.parseSize(value)) {
1219
+ settings[option] = value;
1220
+ settings.send_file_name = true;
1221
+ }
1222
+ break;
1223
+
1224
+ case 'multipart':
1225
+ settings[option] = value;
1226
+ if (!value) {
1227
+ settings.send_file_name = true;
1228
+ }
1229
+ break;
1230
+
1231
+ case 'unique_names':
1232
+ settings[option] = value;
1233
+ if (value) {
1234
+ settings.send_file_name = true;
1235
+ }
1236
+ break;
1237
+
1238
+ case 'filters':
1239
+ // for sake of backward compatibility
1240
+ if (plupload.typeOf(value) === 'array') {
1241
+ value = {
1242
+ mime_types: value
1243
+ };
1244
+ }
1245
+
1246
+ if (init) {
1247
+ plupload.extend(settings.filters, value);
1248
+ } else {
1249
+ settings.filters = value;
1250
+ }
1251
+
1252
+ // if file format filters are being updated, regenerate the matching expressions
1253
+ if (value.mime_types) {
1254
+ settings.filters.mime_types.regexp = (function(filters) {
1255
+ var extensionsRegExp = [];
1256
+
1257
+ plupload.each(filters, function(filter) {
1258
+ plupload.each(filter.extensions.split(/,/), function(ext) {
1259
+ if (/^\s*\*\s*$/.test(ext)) {
1260
+ extensionsRegExp.push('\\.*');
1261
+ } else {
1262
+ extensionsRegExp.push('\\.' + ext.replace(new RegExp('[' + ('/^$.*+?|()[]{}\\'.replace(/./g, '\\$&')) + ']', 'g'), '\\$&'));
1263
+ }
1264
+ });
1265
+ });
1266
+
1267
+ return new RegExp('(' + extensionsRegExp.join('|') + ')$', 'i');
1268
+ }(settings.filters.mime_types));
1269
+ }
1270
+ break;
1271
+
1272
+ case 'resize':
1273
+ if (init) {
1274
+ plupload.extend(settings.resize, value, {
1275
+ enabled: true
1276
+ });
1277
+ } else {
1278
+ settings.resize = value;
1279
+ }
1280
+ break;
1281
+
1282
+ case 'prevent_duplicates':
1283
+ settings.prevent_duplicates = settings.filters.prevent_duplicates = !!value;
1284
+ break;
1285
+
1286
+ case 'browse_button':
1287
+ case 'drop_element':
1288
+ value = plupload.get(value);
1289
+
1290
+ case 'container':
1291
+ case 'runtimes':
1292
+ case 'multi_selection':
1293
+ case 'flash_swf_url':
1294
+ case 'silverlight_xap_url':
1295
+ settings[option] = value;
1296
+ if (!init) {
1297
+ reinitRequired = true;
1298
+ }
1299
+ break;
1300
+
1301
+ default:
1302
+ settings[option] = value;
1303
+ }
1304
+
1305
+ if (!init) {
1306
+ self.trigger('OptionChanged', option, value, oldValue);
1307
+ }
1308
+ }
1309
+
1310
+ if (typeof(option) === 'object') {
1311
+ plupload.each(option, function(value, option) {
1312
+ _setOption(option, value, init);
1313
+ });
1314
+ } else {
1315
+ _setOption(option, value, init);
1316
+ }
1317
+
1318
+ if (init) {
1319
+ // Normalize the list of required capabilities
1320
+ settings.required_features = normalizeCaps(plupload.extend({}, settings));
1321
+
1322
+ // Come up with the list of capabilities that can affect default mode in a multi-mode runtimes
1323
+ preferred_caps = normalizeCaps(plupload.extend({}, settings, {
1324
+ required_features: true
1325
+ }));
1326
+ } else if (reinitRequired) {
1327
+ self.trigger('Destroy');
1328
+
1329
+ initControls.call(self, settings, function(inited) {
1330
+ if (inited) {
1331
+ self.runtime = o.Runtime.getInfo(getRUID()).type;
1332
+ self.trigger('Init', { runtime: self.runtime });
1333
+ self.trigger('PostInit');
1334
+ } else {
1335
+ self.trigger('Error', {
1336
+ code : plupload.INIT_ERROR,
1337
+ message : plupload.translate('Init error.')
1338
+ });
1339
+ }
1340
+ });
1341
+ }
1342
+ }
1343
+
1344
+
1345
+ // Internal event handlers
1346
+ function onBeforeUpload(up, file) {
1347
+ // Generate unique target filenames
1348
+ if (up.settings.unique_names) {
1349
+ var matches = file.name.match(/\.([^.]+)$/), ext = "part";
1350
+ if (matches) {
1351
+ ext = matches[1];
1352
+ }
1353
+ file.target_name = file.id + '.' + ext;
1354
+ }
1355
+ }
1356
+
1357
+
1358
+ function onUploadFile(up, file) {
1359
+ var url = up.settings.url
1360
+ , chunkSize = up.settings.chunk_size
1361
+ , retries = up.settings.max_retries
1362
+ , features = up.features
1363
+ , offset = 0
1364
+ , blob
1365
+ ;
1366
+
1367
+ // make sure we start at a predictable offset
1368
+ if (file.loaded) {
1369
+ offset = file.loaded = chunkSize ? chunkSize * Math.floor(file.loaded / chunkSize) : 0;
1370
+ }
1371
+
1372
+ function handleError() {
1373
+ if (retries-- > 0) {
1374
+ delay(uploadNextChunk, 1000);
1375
+ } else {
1376
+ file.loaded = offset; // reset all progress
1377
+
1378
+ up.trigger('Error', {
1379
+ code : plupload.HTTP_ERROR,
1380
+ message : plupload.translate('HTTP Error.'),
1381
+ file : file,
1382
+ response : xhr.responseText,
1383
+ status : xhr.status,
1384
+ responseHeaders: xhr.getAllResponseHeaders()
1385
+ });
1386
+ }
1387
+ }
1388
+
1389
+ function uploadNextChunk() {
1390
+ var chunkBlob, formData, args = {}, curChunkSize;
1391
+
1392
+ // make sure that file wasn't cancelled and upload is not stopped in general
1393
+ if (file.status !== plupload.UPLOADING || up.state === plupload.STOPPED) {
1394
+ return;
1395
+ }
1396
+
1397
+ // send additional 'name' parameter only if required
1398
+ if (up.settings.send_file_name) {
1399
+ args.name = file.target_name || file.name;
1400
+ }
1401
+
1402
+ if (chunkSize && features.chunks && blob.size > chunkSize) { // blob will be of type string if it was loaded in memory
1403
+ curChunkSize = Math.min(chunkSize, blob.size - offset);
1404
+ chunkBlob = blob.slice(offset, offset + curChunkSize);
1405
+ } else {
1406
+ curChunkSize = blob.size;
1407
+ chunkBlob = blob;
1408
+ }
1409
+
1410
+ // If chunking is enabled add corresponding args, no matter if file is bigger than chunk or smaller
1411
+ if (chunkSize && features.chunks) {
1412
+ // Setup query string arguments
1413
+ if (up.settings.send_chunk_number) {
1414
+ args.chunk = Math.ceil(offset / chunkSize);
1415
+ args.chunks = Math.ceil(blob.size / chunkSize);
1416
+ } else { // keep support for experimental chunk format, just in case
1417
+ args.offset = offset;
1418
+ args.total = blob.size;
1419
+ }
1420
+ }
1421
+
1422
+ xhr = new o.XMLHttpRequest();
1423
+
1424
+ // Do we have upload progress support
1425
+ if (xhr.upload) {
1426
+ xhr.upload.onprogress = function(e) {
1427
+ file.loaded = Math.min(file.size, offset + e.loaded);
1428
+ up.trigger('UploadProgress', file);
1429
+ };
1430
+ }
1431
+
1432
+ xhr.onload = function() {
1433
+ // check if upload made itself through
1434
+ if (xhr.status >= 400) {
1435
+ handleError();
1436
+ return;
1437
+ }
1438
+
1439
+ retries = up.settings.max_retries; // reset the counter
1440
+
1441
+ // Handle chunk response
1442
+ if (curChunkSize < blob.size) {
1443
+ chunkBlob.destroy();
1444
+
1445
+ offset += curChunkSize;
1446
+ file.loaded = Math.min(offset, blob.size);
1447
+
1448
+ up.trigger('ChunkUploaded', file, {
1449
+ offset : file.loaded,
1450
+ total : blob.size,
1451
+ response : xhr.responseText,
1452
+ status : xhr.status,
1453
+ responseHeaders: xhr.getAllResponseHeaders()
1454
+ });
1455
+
1456
+ // stock Android browser doesn't fire upload progress events, but in chunking mode we can fake them
1457
+ if (o.Env.browser === 'Android Browser') {
1458
+ // doesn't harm in general, but is not required anywhere else
1459
+ up.trigger('UploadProgress', file);
1460
+ }
1461
+ } else {
1462
+ file.loaded = file.size;
1463
+ }
1464
+
1465
+ chunkBlob = formData = null; // Free memory
1466
+
1467
+ // Check if file is uploaded
1468
+ if (!offset || offset >= blob.size) {
1469
+ // If file was modified, destory the copy
1470
+ if (file.size != file.origSize) {
1471
+ blob.destroy();
1472
+ blob = null;
1473
+ }
1474
+
1475
+ up.trigger('UploadProgress', file);
1476
+
1477
+ file.status = plupload.DONE;
1478
+
1479
+ up.trigger('FileUploaded', file, {
1480
+ response : xhr.responseText,
1481
+ status : xhr.status,
1482
+ responseHeaders: xhr.getAllResponseHeaders()
1483
+ });
1484
+ } else {
1485
+ // Still chunks left
1486
+ delay(uploadNextChunk, 1); // run detached, otherwise event handlers interfere
1487
+ }
1488
+ };
1489
+
1490
+ xhr.onerror = function() {
1491
+ handleError();
1492
+ };
1493
+
1494
+ xhr.onloadend = function() {
1495
+ this.destroy();
1496
+ xhr = null;
1497
+ };
1498
+
1499
+ // Build multipart request
1500
+ if (up.settings.multipart && features.multipart) {
1501
+ xhr.open("post", url, true);
1502
+
1503
+ // Set custom headers
1504
+ plupload.each(up.settings.headers, function(value, name) {
1505
+ xhr.setRequestHeader(name, value);
1506
+ });
1507
+
1508
+ formData = new o.FormData();
1509
+
1510
+ // Add multipart params
1511
+ plupload.each(plupload.extend(args, up.settings.multipart_params), function(value, name) {
1512
+ formData.append(name, value);
1513
+ });
1514
+
1515
+ // Add file and send it
1516
+ formData.append(up.settings.file_data_name, chunkBlob);
1517
+ xhr.send(formData, {
1518
+ runtime_order: up.settings.runtimes,
1519
+ required_caps: up.settings.required_features,
1520
+ preferred_caps: preferred_caps,
1521
+ swf_url: up.settings.flash_swf_url,
1522
+ xap_url: up.settings.silverlight_xap_url
1523
+ });
1524
+ } else {
1525
+ // if no multipart, send as binary stream
1526
+ url = plupload.buildUrl(up.settings.url, plupload.extend(args, up.settings.multipart_params));
1527
+
1528
+ xhr.open("post", url, true);
1529
+
1530
+ xhr.setRequestHeader('Content-Type', 'application/octet-stream'); // Binary stream header
1531
+
1532
+ // Set custom headers
1533
+ plupload.each(up.settings.headers, function(value, name) {
1534
+ xhr.setRequestHeader(name, value);
1535
+ });
1536
+
1537
+ xhr.send(chunkBlob, {
1538
+ runtime_order: up.settings.runtimes,
1539
+ required_caps: up.settings.required_features,
1540
+ preferred_caps: preferred_caps,
1541
+ swf_url: up.settings.flash_swf_url,
1542
+ xap_url: up.settings.silverlight_xap_url
1543
+ });
1544
+ }
1545
+ }
1546
+
1547
+ blob = file.getSource();
1548
+
1549
+ // Start uploading chunks
1550
+ if (up.settings.resize.enabled && runtimeCan(blob, 'send_binary_string') && !!~o.inArray(blob.type, ['image/jpeg', 'image/png'])) {
1551
+ // Resize if required
1552
+ resizeImage.call(this, blob, up.settings.resize, function(resizedBlob) {
1553
+ blob = resizedBlob;
1554
+ file.size = resizedBlob.size;
1555
+ uploadNextChunk();
1556
+ });
1557
+ } else {
1558
+ uploadNextChunk();
1559
+ }
1560
+ }
1561
+
1562
+
1563
+ function onUploadProgress(up, file) {
1564
+ calcFile(file);
1565
+ }
1566
+
1567
+
1568
+ function onStateChanged(up) {
1569
+ if (up.state == plupload.STARTED) {
1570
+ // Get start time to calculate bps
1571
+ startTime = (+new Date());
1572
+ } else if (up.state == plupload.STOPPED) {
1573
+ // Reset currently uploading files
1574
+ for (var i = up.files.length - 1; i >= 0; i--) {
1575
+ if (up.files[i].status == plupload.UPLOADING) {
1576
+ up.files[i].status = plupload.QUEUED;
1577
+ calc();
1578
+ }
1579
+ }
1580
+ }
1581
+ }
1582
+
1583
+
1584
+ function onCancelUpload() {
1585
+ if (xhr) {
1586
+ xhr.abort();
1587
+ }
1588
+ }
1589
+
1590
+
1591
+ function onFileUploaded(up) {
1592
+ calc();
1593
+
1594
+ // Upload next file but detach it from the error event
1595
+ // since other custom listeners might want to stop the queue
1596
+ delay(function() {
1597
+ uploadNext.call(up);
1598
+ }, 1);
1599
+ }
1600
+
1601
+
1602
+ function onError(up, err) {
1603
+ if (err.code === plupload.INIT_ERROR) {
1604
+ up.destroy();
1605
+ }
1606
+ // Set failed status if an error occured on a file
1607
+ else if (err.file) {
1608
+ err.file.status = plupload.FAILED;
1609
+ calcFile(err.file);
1610
+
1611
+ // Upload next file but detach it from the error event
1612
+ // since other custom listeners might want to stop the queue
1613
+ if (up.state == plupload.STARTED) { // upload in progress
1614
+ up.trigger('CancelUpload');
1615
+ delay(function() {
1616
+ uploadNext.call(up);
1617
+ }, 1);
1618
+ }
1619
+ }
1620
+ }
1621
+
1622
+
1623
+ function onDestroy(up) {
1624
+ up.stop();
1625
+
1626
+ // Purge the queue
1627
+ plupload.each(files, function(file) {
1628
+ file.destroy();
1629
+ });
1630
+ files = [];
1631
+
1632
+ if (fileInputs.length) {
1633
+ plupload.each(fileInputs, function(fileInput) {
1634
+ fileInput.destroy();
1635
+ });
1636
+ fileInputs = [];
1637
+ }
1638
+
1639
+ if (fileDrops.length) {
1640
+ plupload.each(fileDrops, function(fileDrop) {
1641
+ fileDrop.destroy();
1642
+ });
1643
+ fileDrops = [];
1644
+ }
1645
+
1646
+ preferred_caps = {};
1647
+ disabled = false;
1648
+ startTime = xhr = null;
1649
+ total.reset();
1650
+ }
1651
+
1652
+
1653
+ // Default settings
1654
+ settings = {
1655
+ runtimes: o.Runtime.order,
1656
+ max_retries: 0,
1657
+ chunk_size: 0,
1658
+ multipart: true,
1659
+ multi_selection: true,
1660
+ file_data_name: 'file',
1661
+ flash_swf_url: 'js/Moxie.swf',
1662
+ silverlight_xap_url: 'js/Moxie.xap',
1663
+ filters: {
1664
+ mime_types: [],
1665
+ prevent_duplicates: false,
1666
+ max_file_size: 0
1667
+ },
1668
+ resize: {
1669
+ enabled: false,
1670
+ preserve_headers: true,
1671
+ crop: false
1672
+ },
1673
+ send_file_name: true,
1674
+ send_chunk_number: true
1675
+ };
1676
+
1677
+
1678
+ setOption.call(this, options, null, true);
1679
+
1680
+ // Inital total state
1681
+ total = new plupload.QueueProgress();
1682
+
1683
+ // Add public methods
1684
+ plupload.extend(this, {
1685
+
1686
+ /**
1687
+ * Unique id for the Uploader instance.
1688
+ *
1689
+ * @property id
1690
+ * @type String
1691
+ */
1692
+ id : uid,
1693
+ uid : uid, // mOxie uses this to differentiate between event targets
1694
+
1695
+ /**
1696
+ * Current state of the total uploading progress. This one can either be plupload.STARTED or plupload.STOPPED.
1697
+ * These states are controlled by the stop/start methods. The default value is STOPPED.
1698
+ *
1699
+ * @property state
1700
+ * @type Number
1701
+ */
1702
+ state : plupload.STOPPED,
1703
+
1704
+ /**
1705
+ * Map of features that are available for the uploader runtime. Features will be filled
1706
+ * before the init event is called, these features can then be used to alter the UI for the end user.
1707
+ * Some of the current features that might be in this map is: dragdrop, chunks, jpgresize, pngresize.
1708
+ *
1709
+ * @property features
1710
+ * @type Object
1711
+ */
1712
+ features : {},
1713
+
1714
+ /**
1715
+ * Current runtime name.
1716
+ *
1717
+ * @property runtime
1718
+ * @type String
1719
+ */
1720
+ runtime : null,
1721
+
1722
+ /**
1723
+ * Current upload queue, an array of File instances.
1724
+ *
1725
+ * @property files
1726
+ * @type Array
1727
+ * @see plupload.File
1728
+ */
1729
+ files : files,
1730
+
1731
+ /**
1732
+ * Object with name/value settings.
1733
+ *
1734
+ * @property settings
1735
+ * @type Object
1736
+ */
1737
+ settings : settings,
1738
+
1739
+ /**
1740
+ * Total progess information. How many files has been uploaded, total percent etc.
1741
+ *
1742
+ * @property total
1743
+ * @type plupload.QueueProgress
1744
+ */
1745
+ total : total,
1746
+
1747
+
1748
+ /**
1749
+ * Initializes the Uploader instance and adds internal event listeners.
1750
+ *
1751
+ * @method init
1752
+ */
1753
+ init : function() {
1754
+ var self = this;
1755
+
1756
+ if (typeof(settings.preinit) == "function") {
1757
+ settings.preinit(self);
1758
+ } else {
1759
+ plupload.each(settings.preinit, function(func, name) {
1760
+ self.bind(name, func);
1761
+ });
1762
+ }
1763
+
1764
+ bindEventListeners.call(this);
1765
+
1766
+ // Check for required options
1767
+ if (!settings.browse_button || !settings.url) {
1768
+ this.trigger('Error', {
1769
+ code : plupload.INIT_ERROR,
1770
+ message : plupload.translate('Init error.')
1771
+ });
1772
+ return;
1773
+ }
1774
+
1775
+ initControls.call(this, settings, function(inited) {
1776
+ if (typeof(settings.init) == "function") {
1777
+ settings.init(self);
1778
+ } else {
1779
+ plupload.each(settings.init, function(func, name) {
1780
+ self.bind(name, func);
1781
+ });
1782
+ }
1783
+
1784
+ if (inited) {
1785
+ self.runtime = o.Runtime.getInfo(getRUID()).type;
1786
+ self.trigger('Init', { runtime: self.runtime });
1787
+ self.trigger('PostInit');
1788
+ } else {
1789
+ self.trigger('Error', {
1790
+ code : plupload.INIT_ERROR,
1791
+ message : plupload.translate('Init error.')
1792
+ });
1793
+ }
1794
+ });
1795
+ },
1796
+
1797
+ /**
1798
+ * Set the value for the specified option(s).
1799
+ *
1800
+ * @method setOption
1801
+ * @since 2.1
1802
+ * @param {String|Object} option Name of the option to change or the set of key/value pairs
1803
+ * @param {Mixed} [value] Value for the option (is ignored, if first argument is object)
1804
+ */
1805
+ setOption: function(option, value) {
1806
+ setOption.call(this, option, value, !this.runtime); // until runtime not set we do not need to reinitialize
1807
+ },
1808
+
1809
+ /**
1810
+ * Get the value for the specified option or the whole configuration, if not specified.
1811
+ *
1812
+ * @method getOption
1813
+ * @since 2.1
1814
+ * @param {String} [option] Name of the option to get
1815
+ * @return {Mixed} Value for the option or the whole set
1816
+ */
1817
+ getOption: function(option) {
1818
+ if (!option) {
1819
+ return settings;
1820
+ }
1821
+ return settings[option];
1822
+ },
1823
+
1824
+ /**
1825
+ * Refreshes the upload instance by dispatching out a refresh event to all runtimes.
1826
+ * This would for example reposition flash/silverlight shims on the page.
1827
+ *
1828
+ * @method refresh
1829
+ */
1830
+ refresh : function() {
1831
+ if (fileInputs.length) {
1832
+ plupload.each(fileInputs, function(fileInput) {
1833
+ fileInput.trigger('Refresh');
1834
+ });
1835
+ }
1836
+ this.trigger('Refresh');
1837
+ },
1838
+
1839
+ /**
1840
+ * Starts uploading the queued files.
1841
+ *
1842
+ * @method start
1843
+ */
1844
+ start : function() {
1845
+ if (this.state != plupload.STARTED) {
1846
+ this.state = plupload.STARTED;
1847
+ this.trigger('StateChanged');
1848
+
1849
+ uploadNext.call(this);
1850
+ }
1851
+ },
1852
+
1853
+ /**
1854
+ * Stops the upload of the queued files.
1855
+ *
1856
+ * @method stop
1857
+ */
1858
+ stop : function() {
1859
+ if (this.state != plupload.STOPPED) {
1860
+ this.state = plupload.STOPPED;
1861
+ this.trigger('StateChanged');
1862
+ this.trigger('CancelUpload');
1863
+ }
1864
+ },
1865
+
1866
+
1867
+ /**
1868
+ * Disables/enables browse button on request.
1869
+ *
1870
+ * @method disableBrowse
1871
+ * @param {Boolean} disable Whether to disable or enable (default: true)
1872
+ */
1873
+ disableBrowse : function() {
1874
+ disabled = arguments[0] !== undef ? arguments[0] : true;
1875
+
1876
+ if (fileInputs.length) {
1877
+ plupload.each(fileInputs, function(fileInput) {
1878
+ fileInput.disable(disabled);
1879
+ });
1880
+ }
1881
+
1882
+ this.trigger('DisableBrowse', disabled);
1883
+ },
1884
+
1885
+ /**
1886
+ * Returns the specified file object by id.
1887
+ *
1888
+ * @method getFile
1889
+ * @param {String} id File id to look for.
1890
+ * @return {plupload.File} File object or undefined if it wasn't found;
1891
+ */
1892
+ getFile : function(id) {
1893
+ var i;
1894
+ for (i = files.length - 1; i >= 0; i--) {
1895
+ if (files[i].id === id) {
1896
+ return files[i];
1897
+ }
1898
+ }
1899
+ },
1900
+
1901
+ /**
1902
+ * Adds file to the queue programmatically. Can be native file, instance of Plupload.File,
1903
+ * instance of mOxie.File, input[type="file"] element, or array of these. Fires FilesAdded,
1904
+ * if any files were added to the queue. Otherwise nothing happens.
1905
+ *
1906
+ * @method addFile
1907
+ * @since 2.0
1908
+ * @param {plupload.File|mOxie.File|File|Node|Array} file File or files to add to the queue.
1909
+ * @param {String} [fileName] If specified, will be used as a name for the file
1910
+ */
1911
+ addFile : function(file, fileName) {
1912
+ var self = this
1913
+ , queue = []
1914
+ , filesAdded = []
1915
+ , ruid
1916
+ ;
1917
+
1918
+ function filterFile(file, cb) {
1919
+ var queue = [];
1920
+ o.each(self.settings.filters, function(rule, name) {
1921
+ if (fileFilters[name]) {
1922
+ queue.push(function(cb) {
1923
+ fileFilters[name].call(self, rule, file, function(res) {
1924
+ cb(!res);
1925
+ });
1926
+ });
1927
+ }
1928
+ });
1929
+ o.inSeries(queue, cb);
1930
+ }
1931
+
1932
+ /**
1933
+ * @method resolveFile
1934
+ * @private
1935
+ * @param {o.File|o.Blob|plupload.File|File|Blob|input[type="file"]} file
1936
+ */
1937
+ function resolveFile(file) {
1938
+ var type = o.typeOf(file);
1939
+
1940
+ // o.File
1941
+ if (file instanceof o.File) {
1942
+ if (!file.ruid && !file.isDetached()) {
1943
+ if (!ruid) { // weird case
1944
+ return false;
1945
+ }
1946
+ file.ruid = ruid;
1947
+ file.connectRuntime(ruid);
1948
+ }
1949
+ resolveFile(new plupload.File(file));
1950
+ }
1951
+ // o.Blob
1952
+ else if (file instanceof o.Blob) {
1953
+ resolveFile(file.getSource());
1954
+ file.destroy();
1955
+ }
1956
+ // plupload.File - final step for other branches
1957
+ else if (file instanceof plupload.File) {
1958
+ if (fileName) {
1959
+ file.name = fileName;
1960
+ }
1961
+
1962
+ queue.push(function(cb) {
1963
+ // run through the internal and user-defined filters, if any
1964
+ filterFile(file, function(err) {
1965
+ if (!err) {
1966
+ // make files available for the filters by updating the main queue directly
1967
+ files.push(file);
1968
+ // collect the files that will be passed to FilesAdded event
1969
+ filesAdded.push(file);
1970
+
1971
+ self.trigger("FileFiltered", file);
1972
+ }
1973
+ delay(cb, 1); // do not build up recursions or eventually we might hit the limits
1974
+ });
1975
+ });
1976
+ }
1977
+ // native File or blob
1978
+ else if (o.inArray(type, ['file', 'blob']) !== -1) {
1979
+ resolveFile(new o.File(null, file));
1980
+ }
1981
+ // input[type="file"]
1982
+ else if (type === 'node' && o.typeOf(file.files) === 'filelist') {
1983
+ // if we are dealing with input[type="file"]
1984
+ o.each(file.files, resolveFile);
1985
+ }
1986
+ // mixed array of any supported types (see above)
1987
+ else if (type === 'array') {
1988
+ fileName = null; // should never happen, but unset anyway to avoid funny situations
1989
+ o.each(file, resolveFile);
1990
+ }
1991
+ }
1992
+
1993
+ ruid = getRUID();
1994
+
1995
+ resolveFile(file);
1996
+
1997
+ if (queue.length) {
1998
+ o.inSeries(queue, function() {
1999
+ // if any files left after filtration, trigger FilesAdded
2000
+ if (filesAdded.length) {
2001
+ self.trigger("FilesAdded", filesAdded);
2002
+ }
2003
+ });
2004
+ }
2005
+ },
2006
+
2007
+ /**
2008
+ * Removes a specific file.
2009
+ *
2010
+ * @method removeFile
2011
+ * @param {plupload.File|String} file File to remove from queue.
2012
+ */
2013
+ removeFile : function(file) {
2014
+ var id = typeof(file) === 'string' ? file : file.id;
2015
+
2016
+ for (var i = files.length - 1; i >= 0; i--) {
2017
+ if (files[i].id === id) {
2018
+ return this.splice(i, 1)[0];
2019
+ }
2020
+ }
2021
+ },
2022
+
2023
+ /**
2024
+ * Removes part of the queue and returns the files removed. This will also trigger the FilesRemoved and QueueChanged events.
2025
+ *
2026
+ * @method splice
2027
+ * @param {Number} start (Optional) Start index to remove from.
2028
+ * @param {Number} length (Optional) Lengh of items to remove.
2029
+ * @return {Array} Array of files that was removed.
2030
+ */
2031
+ splice : function(start, length) {
2032
+ // Splice and trigger events
2033
+ var removed = files.splice(start === undef ? 0 : start, length === undef ? files.length : length);
2034
+
2035
+ // if upload is in progress we need to stop it and restart after files are removed
2036
+ var restartRequired = false;
2037
+ if (this.state == plupload.STARTED) { // upload in progress
2038
+ plupload.each(removed, function(file) {
2039
+ if (file.status === plupload.UPLOADING) {
2040
+ restartRequired = true; // do not restart, unless file that is being removed is uploading
2041
+ return false;
2042
+ }
2043
+ });
2044
+
2045
+ if (restartRequired) {
2046
+ this.stop();
2047
+ }
2048
+ }
2049
+
2050
+ this.trigger("FilesRemoved", removed);
2051
+
2052
+ // Dispose any resources allocated by those files
2053
+ plupload.each(removed, function(file) {
2054
+ file.destroy();
2055
+ });
2056
+
2057
+ if (restartRequired) {
2058
+ this.start();
2059
+ }
2060
+
2061
+ return removed;
2062
+ },
2063
+
2064
+ /**
2065
+ * Dispatches the specified event name and it's arguments to all listeners.
2066
+ *
2067
+ *
2068
+ * @method trigger
2069
+ * @param {String} name Event name to fire.
2070
+ * @param {Object..} Multiple arguments to pass along to the listener functions.
2071
+ */
2072
+
2073
+ /**
2074
+ * Check whether uploader has any listeners to the specified event.
2075
+ *
2076
+ * @method hasEventListener
2077
+ * @param {String} name Event name to check for.
2078
+ */
2079
+
2080
+
2081
+ /**
2082
+ * Adds an event listener by name.
2083
+ *
2084
+ * @method bind
2085
+ * @param {String} name Event name to listen for.
2086
+ * @param {function} func Function to call ones the event gets fired.
2087
+ * @param {Object} scope Optional scope to execute the specified function in.
2088
+ */
2089
+ bind : function(name, func, scope) {
2090
+ var self = this;
2091
+ // adapt moxie EventTarget style to Plupload-like
2092
+ plupload.Uploader.prototype.bind.call(this, name, function() {
2093
+ var args = [].slice.call(arguments);
2094
+ args.splice(0, 1, self); // replace event object with uploader instance
2095
+ return func.apply(this, args);
2096
+ }, 0, scope);
2097
+ },
2098
+
2099
+ /**
2100
+ * Removes the specified event listener.
2101
+ *
2102
+ * @method unbind
2103
+ * @param {String} name Name of event to remove.
2104
+ * @param {function} func Function to remove from listener.
2105
+ */
2106
+
2107
+ /**
2108
+ * Removes all event listeners.
2109
+ *
2110
+ * @method unbindAll
2111
+ */
2112
+
2113
+
2114
+ /**
2115
+ * Destroys Plupload instance and cleans after itself.
2116
+ *
2117
+ * @method destroy
2118
+ */
2119
+ destroy : function() {
2120
+ this.trigger('Destroy');
2121
+ settings = total = null; // purge these exclusively
2122
+ this.unbindAll();
2123
+ }
2124
+ });
2125
+ };
2126
+
2127
+ plupload.Uploader.prototype = o.EventTarget.instance;
2128
+
2129
+ /**
2130
+ * Constructs a new file instance.
2131
+ *
2132
+ * @class File
2133
+ * @constructor
2134
+ *
2135
+ * @param {Object} file Object containing file properties
2136
+ * @param {String} file.name Name of the file.
2137
+ * @param {Number} file.size File size.
2138
+ */
2139
+ plupload.File = (function() {
2140
+ var filepool = {};
2141
+
2142
+ function PluploadFile(file) {
2143
+
2144
+ plupload.extend(this, {
2145
+
2146
+ /**
2147
+ * File id this is a globally unique id for the specific file.
2148
+ *
2149
+ * @property id
2150
+ * @type String
2151
+ */
2152
+ id: plupload.guid(),
2153
+
2154
+ /**
2155
+ * File name for example "myfile.gif".
2156
+ *
2157
+ * @property name
2158
+ * @type String
2159
+ */
2160
+ name: file.name || file.fileName,
2161
+
2162
+ /**
2163
+ * File type, `e.g image/jpeg`
2164
+ *
2165
+ * @property type
2166
+ * @type String
2167
+ */
2168
+ type: file.type || '',
2169
+
2170
+ /**
2171
+ * File size in bytes (may change after client-side manupilation).
2172
+ *
2173
+ * @property size
2174
+ * @type Number
2175
+ */
2176
+ size: file.size || file.fileSize,
2177
+
2178
+ /**
2179
+ * Original file size in bytes.
2180
+ *
2181
+ * @property origSize
2182
+ * @type Number
2183
+ */
2184
+ origSize: file.size || file.fileSize,
2185
+
2186
+ /**
2187
+ * Number of bytes uploaded of the files total size.
2188
+ *
2189
+ * @property loaded
2190
+ * @type Number
2191
+ */
2192
+ loaded: 0,
2193
+
2194
+ /**
2195
+ * Number of percentage uploaded of the file.
2196
+ *
2197
+ * @property percent
2198
+ * @type Number
2199
+ */
2200
+ percent: 0,
2201
+
2202
+ /**
2203
+ * Status constant matching the plupload states QUEUED, UPLOADING, FAILED, DONE.
2204
+ *
2205
+ * @property status
2206
+ * @type Number
2207
+ * @see plupload
2208
+ */
2209
+ status: plupload.QUEUED,
2210
+
2211
+ /**
2212
+ * Date of last modification.
2213
+ *
2214
+ * @property lastModifiedDate
2215
+ * @type {String}
2216
+ */
2217
+ lastModifiedDate: file.lastModifiedDate || (new Date()).toLocaleString(), // Thu Aug 23 2012 19:40:00 GMT+0400 (GET)
2218
+
2219
+ /**
2220
+ * Returns native window.File object, when it's available.
2221
+ *
2222
+ * @method getNative
2223
+ * @return {window.File} or null, if plupload.File is of different origin
2224
+ */
2225
+ getNative: function() {
2226
+ var file = this.getSource().getSource();
2227
+ return o.inArray(o.typeOf(file), ['blob', 'file']) !== -1 ? file : null;
2228
+ },
2229
+
2230
+ /**
2231
+ * Returns mOxie.File - unified wrapper object that can be used across runtimes.
2232
+ *
2233
+ * @method getSource
2234
+ * @return {mOxie.File} or null
2235
+ */
2236
+ getSource: function() {
2237
+ if (!filepool[this.id]) {
2238
+ return null;
2239
+ }
2240
+ return filepool[this.id];
2241
+ },
2242
+
2243
+ /**
2244
+ * Destroys plupload.File object.
2245
+ *
2246
+ * @method destroy
2247
+ */
2248
+ destroy: function() {
2249
+ var src = this.getSource();
2250
+ if (src) {
2251
+ src.destroy();
2252
+ delete filepool[this.id];
2253
+ }
2254
+ }
2255
+ });
2256
+
2257
+ filepool[this.id] = file;
2258
+ }
2259
+
2260
+ return PluploadFile;
2261
+ }());
2262
+
2263
+
2264
+ /**
2265
+ * Constructs a queue progress.
2266
+ *
2267
+ * @class QueueProgress
2268
+ * @constructor
2269
+ */
2270
+ plupload.QueueProgress = function() {
2271
+ var self = this; // Setup alias for self to reduce code size when it's compressed
2272
+
2273
+ /**
2274
+ * Total queue file size.
2275
+ *
2276
+ * @property size
2277
+ * @type Number
2278
+ */
2279
+ self.size = 0;
2280
+
2281
+ /**
2282
+ * Total bytes uploaded.
2283
+ *
2284
+ * @property loaded
2285
+ * @type Number
2286
+ */
2287
+ self.loaded = 0;
2288
+
2289
+ /**
2290
+ * Number of files uploaded.
2291
+ *
2292
+ * @property uploaded
2293
+ * @type Number
2294
+ */
2295
+ self.uploaded = 0;
2296
+
2297
+ /**
2298
+ * Number of files failed to upload.
2299
+ *
2300
+ * @property failed
2301
+ * @type Number
2302
+ */
2303
+ self.failed = 0;
2304
+
2305
+ /**
2306
+ * Number of files yet to be uploaded.
2307
+ *
2308
+ * @property queued
2309
+ * @type Number
2310
+ */
2311
+ self.queued = 0;
2312
+
2313
+ /**
2314
+ * Total percent of the uploaded bytes.
2315
+ *
2316
+ * @property percent
2317
+ * @type Number
2318
+ */
2319
+ self.percent = 0;
2320
+
2321
+ /**
2322
+ * Bytes uploaded per second.
2323
+ *
2324
+ * @property bytesPerSec
2325
+ * @type Number
2326
+ */
2327
+ self.bytesPerSec = 0;
2328
+
2329
+ /**
2330
+ * Resets the progress to it's initial values.
2331
+ *
2332
+ * @method reset
2333
+ */
2334
+ self.reset = function() {
2335
+ self.size = self.loaded = self.uploaded = self.failed = self.queued = self.percent = self.bytesPerSec = 0;
2336
+ };
2337
+ };
2338
+
2339
+ window.plupload = plupload;
2340
+
2341
+ }(window, mOxie));