├── src └── main │ ├── webapp │ ├── static │ │ └── plupload │ │ │ └── js │ │ │ ├── Moxie.swf │ │ │ ├── Moxie.xap │ │ │ ├── jquery.plupload.queue │ │ │ ├── img │ │ │ │ ├── done.gif │ │ │ │ ├── delete.gif │ │ │ │ ├── error.gif │ │ │ │ ├── buttons.png │ │ │ │ ├── throbber.gif │ │ │ │ ├── transp50.png │ │ │ │ ├── backgrounds.gif │ │ │ │ └── buttons-disabled.png │ │ │ ├── css │ │ │ │ └── jquery.plupload.queue.css │ │ │ ├── jquery.plupload.queue.min.js │ │ │ └── jquery.plupload.queue.js │ │ │ ├── jquery.ui.plupload │ │ │ ├── img │ │ │ │ ├── loading.gif │ │ │ │ └── plupload.png │ │ │ ├── css │ │ │ │ └── jquery.ui.plupload.css │ │ │ ├── jquery.ui.plupload.min.js │ │ │ └── jquery.ui.plupload.js │ │ │ ├── i18n │ │ │ └── zh_CN.js │ │ │ └── moxie.min.js │ └── WEB-INF │ │ ├── web.xml │ │ └── jsp │ │ └── index.jsp │ ├── resources │ ├── log4j.properties │ ├── mvc-servlet.xml │ ├── spring-servlet.xml │ └── web-servlet.xml │ └── java │ └── com │ └── plupload │ └── controller │ ├── PluploadController.java │ └── PluploadServlet.java ├── README.MD ├── pom.xml └── LICENSE /src/main/webapp/static/plupload/js/Moxie.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellokaton/springmvc-plupload/HEAD/src/main/webapp/static/plupload/js/Moxie.swf -------------------------------------------------------------------------------- /src/main/webapp/static/plupload/js/Moxie.xap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellokaton/springmvc-plupload/HEAD/src/main/webapp/static/plupload/js/Moxie.xap -------------------------------------------------------------------------------- /src/main/webapp/static/plupload/js/jquery.plupload.queue/img/done.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellokaton/springmvc-plupload/HEAD/src/main/webapp/static/plupload/js/jquery.plupload.queue/img/done.gif -------------------------------------------------------------------------------- /src/main/webapp/static/plupload/js/jquery.ui.plupload/img/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellokaton/springmvc-plupload/HEAD/src/main/webapp/static/plupload/js/jquery.ui.plupload/img/loading.gif -------------------------------------------------------------------------------- /src/main/webapp/static/plupload/js/jquery.plupload.queue/img/delete.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellokaton/springmvc-plupload/HEAD/src/main/webapp/static/plupload/js/jquery.plupload.queue/img/delete.gif -------------------------------------------------------------------------------- /src/main/webapp/static/plupload/js/jquery.plupload.queue/img/error.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellokaton/springmvc-plupload/HEAD/src/main/webapp/static/plupload/js/jquery.plupload.queue/img/error.gif -------------------------------------------------------------------------------- /src/main/webapp/static/plupload/js/jquery.ui.plupload/img/plupload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellokaton/springmvc-plupload/HEAD/src/main/webapp/static/plupload/js/jquery.ui.plupload/img/plupload.png -------------------------------------------------------------------------------- /src/main/webapp/static/plupload/js/jquery.plupload.queue/img/buttons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellokaton/springmvc-plupload/HEAD/src/main/webapp/static/plupload/js/jquery.plupload.queue/img/buttons.png -------------------------------------------------------------------------------- /src/main/webapp/static/plupload/js/jquery.plupload.queue/img/throbber.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellokaton/springmvc-plupload/HEAD/src/main/webapp/static/plupload/js/jquery.plupload.queue/img/throbber.gif -------------------------------------------------------------------------------- /src/main/webapp/static/plupload/js/jquery.plupload.queue/img/transp50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellokaton/springmvc-plupload/HEAD/src/main/webapp/static/plupload/js/jquery.plupload.queue/img/transp50.png -------------------------------------------------------------------------------- /src/main/webapp/static/plupload/js/jquery.plupload.queue/img/backgrounds.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellokaton/springmvc-plupload/HEAD/src/main/webapp/static/plupload/js/jquery.plupload.queue/img/backgrounds.gif -------------------------------------------------------------------------------- /src/main/webapp/static/plupload/js/jquery.plupload.queue/img/buttons-disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellokaton/springmvc-plupload/HEAD/src/main/webapp/static/plupload/js/jquery.plupload.queue/img/buttons-disabled.png -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | Plupload 是一个Web浏览器上的界面友好的文件上传模块,可显示上传进度、图像自动缩略和上传分块。可同时上传多个文件。由于可以实现把文件分块上传,所以可以满足在某些限制了上传大小的环境上传大文件的需求。 这个例子演示了在java平台下用springmvc进行分片上传,还有一个servlet版本的,上传组件用的是commons-fileupload。 2 | 3 | 4 | ![上传文件](http://i2.tietuku.com/f820ccb5049bfc3a.jpg) -------------------------------------------------------------------------------- /src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=info,Console,File 2 | 3 | log4j.appender.Console=org.apache.log4j.ConsoleAppender 4 | log4j.appender.Console.Target=System.out 5 | log4j.appender.Console.layout=org.apache.log4j.PatternLayout 6 | log4j.appender.Console.layout.ConversionPattern=[%c]%m%n 7 | 8 | log4j.appender.File=org.apache.log4j.RollingFileAppender 9 | log4j.appender.File.MaxFileSize=10MB 10 | log4j.appender.File.Threshold=ALL 11 | log4j.appender.File.layout=org.apache.log4j.PatternLayout 12 | log4j.appender.File.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH\:mm\:ss,SSS}][%c]%m%n -------------------------------------------------------------------------------- /src/main/resources/mvc-servlet.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/main/resources/spring-servlet.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/webapp/static/plupload/js/i18n/zh_CN.js: -------------------------------------------------------------------------------- 1 | // Chinese (China) (zh_CN) 2 | plupload.addI18n({"Stop Upload":"停止上传","Upload URL might be wrong or doesn't exist.":"上传的URL可能是错误的或不存在。","tb":"tb","Size":"大小","Close":"关闭","Init error.":"初始化错误。","Add files to the upload queue and click the start button.":"将文件添加到上传队列,然后点击”开始上传“按钮。","Filename":"文件名","Image format either wrong or not supported.":"图片格式错误或者不支持。","Status":"状态","HTTP Error.":"HTTP 错误。","Start Upload":"开始上传","mb":"mb","kb":"kb","Duplicate file error.":"重复文件错误。","File size error.":"文件大小错误。","N/A":"N/A","gb":"gb","Error: Invalid file extension:":"错误:无效的文件扩展名:","Select files":"选择文件","%s already present in the queue.":"%s 已经在当前队列里。","File: %s":"文件: %s","b":"b","Uploaded %d/%d files":"已上传 %d/%d 个文件","Upload element accepts only %d file(s) at a time. Extra files were stripped.":"每次只接受同时上传 %d 个文件,多余的文件将会被删除。","%d files queued":"%d 个文件加入到队列","File: %s, size: %d, max file size: %d":"文件: %s, 大小: %d, 最大文件大小: %d","Drag files here.":"把文件拖到这里。","Runtime ran out of available memory.":"运行时已消耗所有可用内存。","File count error.":"文件数量错误。","File extension error.":"文件扩展名错误。","Error: File too large:":"错误: 文件太大:","Add Files":"增加文件"}); -------------------------------------------------------------------------------- /src/main/resources/web-servlet.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 35 | 36 | 37 | 104857600 38 | 39 | 40 | 1024000 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | springmvc-plupload 8 | 9 | 10 | org.springframework.web.context.ContextLoaderListener 11 | 12 | 13 | contextConfigLocation 14 | 15 | classpath:spring-servlet.xml 16 | 17 | 18 | 19 | org.springframework.web.context.request.RequestContextListener 20 | 21 | 22 | characterEncodingFilter 23 | org.springframework.web.filter.CharacterEncodingFilter 24 | 25 | encoding 26 | UTF-8 27 | 28 | 29 | forceEncoding 30 | true 31 | 32 | 33 | 34 | characterEncodingFilter 35 | /* 36 | 37 | 38 | 39 | dispatcher 40 | org.springframework.web.servlet.DispatcherServlet 41 | 42 | contextConfigLocation 43 | 44 | classpath:mvc-servlet.xml 45 | 46 | 47 | 1 48 | 49 | 50 | 51 | dispatcher 52 | / 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/jsp/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 | <% 3 | String path = request.getContextPath(); 4 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; 5 | %> 6 | 7 | 8 | 9 | 10 | My JSP 'plupload.jsp' starting page 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |

Your browser doesn't have Flash, Silverlight or HTML5 support.

19 |
20 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | springmvc-plupload 5 | springmvc-plupload 6 | war 7 | 0.0.1-SNAPSHOT 8 | springmvc Maven Webapp 9 | http://maven.apache.org 10 | 11 | 12 | 13 | org.springframework 14 | spring-core 15 | 3.2.3.RELEASE 16 | 17 | 18 | 19 | org.springframework 20 | spring-context 21 | 3.2.3.RELEASE 22 | 23 | 24 | 25 | org.springframework 26 | spring-web 27 | 3.2.3.RELEASE 28 | 29 | 30 | org.springframework 31 | spring-webmvc 32 | 3.2.3.RELEASE 33 | 34 | 35 | 36 | org.aspectj 37 | aspectjweaver 38 | 1.5.4 39 | 40 | 41 | 42 | javax.servlet 43 | javax.servlet-api 44 | 3.0.1 45 | provided 46 | 47 | 48 | 49 | javax.servlet 50 | jsp-api 51 | 2.0 52 | provided 53 | 54 | 55 | 56 | log4j 57 | log4j 58 | 1.2.17 59 | 60 | 61 | 62 | commons-io 63 | commons-io 64 | 2.4 65 | 66 | 67 | 68 | commons-fileupload 69 | commons-fileupload 70 | 1.3.1 71 | 72 | 73 | 74 | 75 | springmvc-plupload 76 | 77 | 78 | maven-compiler-plugin 79 | 80 | 1.6 81 | 1.6 82 | 83 | 84 | 85 | org.mortbay.jetty 86 | maven-jetty-plugin 87 | 6.1.7 88 | 89 | src/main/webapp 90 | 1 91 | / 92 | 93 | 94 | 9000 95 | 30000 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /src/main/java/com/plupload/controller/PluploadController.java: -------------------------------------------------------------------------------- 1 | package com.plupload.controller; 2 | 3 | import java.io.BufferedInputStream; 4 | import java.io.BufferedOutputStream; 5 | import java.io.File; 6 | import java.io.FileOutputStream; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | import java.io.OutputStream; 10 | 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpSession; 13 | 14 | import org.apache.log4j.Logger; 15 | import org.springframework.stereotype.Controller; 16 | import org.springframework.web.bind.annotation.RequestMapping; 17 | import org.springframework.web.bind.annotation.RequestMethod; 18 | import org.springframework.web.bind.annotation.RequestParam; 19 | import org.springframework.web.bind.annotation.ResponseBody; 20 | import org.springframework.web.multipart.MultipartFile; 21 | 22 | @Controller 23 | @RequestMapping(value = "/") 24 | public class PluploadController { 25 | 26 | private static final int BUFFER_SIZE = 100 * 1024; 27 | private static final Logger logger = Logger.getLogger(PluploadController.class); 28 | 29 | @RequestMapping(value = "/") 30 | public String index(HttpServletRequest request) { 31 | return "index"; 32 | } 33 | 34 | /** 35 | * 使用plupload上传文件 36 | * @param file 文件对象 37 | * @param name 文件名称 38 | * @param chunk 数据块序号 39 | * @param chunks 数据块总数 40 | * @return 41 | */ 42 | @ResponseBody 43 | @RequestMapping(value="plupload",method=RequestMethod.POST) 44 | public String plupload(@RequestParam MultipartFile file, HttpServletRequest request, HttpSession session) { 45 | try { 46 | String name = request.getParameter("name"); 47 | Integer chunk = 0, chunks = 0; 48 | if(null != request.getParameter("chunk") && !request.getParameter("chunk").equals("")){ 49 | chunk = Integer.valueOf(request.getParameter("chunk")); 50 | } 51 | if(null != request.getParameter("chunks") && !request.getParameter("chunks").equals("")){ 52 | chunks = Integer.valueOf(request.getParameter("chunks")); 53 | } 54 | logger.info("chunk:[" + chunk + "] chunks:[" + chunks + "]"); 55 | //检查文件目录,不存在则创建 56 | String relativePath = "/plupload/files/"; 57 | String realPath = session.getServletContext().getRealPath(""); 58 | File folder = new File(realPath + relativePath); 59 | if (!folder.exists()) { 60 | folder.mkdirs(); 61 | } 62 | 63 | //目标文件 64 | File destFile = new File(folder, name); 65 | //文件已存在删除旧文件(上传了同名的文件) 66 | if (chunk == 0 && destFile.exists()) { 67 | destFile.delete(); 68 | destFile = new File(folder, name); 69 | } 70 | //合成文件 71 | appendFile(file.getInputStream(), destFile); 72 | if (chunk == chunks - 1) { 73 | logger.info("上传完成"); 74 | }else { 75 | logger.info("还剩["+(chunks-1-chunk)+"]个块文件"); 76 | } 77 | 78 | } catch (IOException e) { 79 | logger.error(e.getMessage()); 80 | } 81 | 82 | return ""; 83 | } 84 | 85 | private void appendFile(InputStream in, File destFile) { 86 | OutputStream out = null; 87 | try { 88 | // plupload 配置了chunk的时候新上传的文件append到文件末尾 89 | if (destFile.exists()) { 90 | out = new BufferedOutputStream(new FileOutputStream(destFile, true), BUFFER_SIZE); 91 | } else { 92 | out = new BufferedOutputStream(new FileOutputStream(destFile),BUFFER_SIZE); 93 | } 94 | in = new BufferedInputStream(in, BUFFER_SIZE); 95 | 96 | int len = 0; 97 | byte[] buffer = new byte[BUFFER_SIZE]; 98 | while ((len = in.read(buffer)) > 0) { 99 | out.write(buffer, 0, len); 100 | } 101 | } catch (Exception e) { 102 | logger.error(e.getMessage()); 103 | } finally { 104 | try { 105 | if (null != in) { 106 | in.close(); 107 | } 108 | if(null != out){ 109 | out.close(); 110 | } 111 | } catch (IOException e) { 112 | logger.error(e.getMessage()); 113 | } 114 | } 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /src/main/webapp/static/plupload/js/jquery.plupload.queue/css/jquery.plupload.queue.css: -------------------------------------------------------------------------------- 1 | /* 2 | Plupload 3 | ------------------------------------------------------------------- */ 4 | 5 | .plupload_wrapper * { 6 | box-sizing: content-box; 7 | } 8 | 9 | .plupload_button { 10 | display: -moz-inline-box; /* FF < 3*/ 11 | display: inline-block; 12 | font: normal 12px sans-serif; 13 | text-decoration: none; 14 | color: #42454a; 15 | border: 1px solid #bababa; 16 | padding: 2px 8px 3px 20px; 17 | margin-right: 4px; 18 | background: #f3f3f3 url('../img/buttons.png') no-repeat 0 center; 19 | outline: 0; 20 | 21 | /* Optional rounded corners for browsers that support it */ 22 | -moz-border-radius: 3px; 23 | -khtml-border-radius: 3px; 24 | -webkit-border-radius: 3px; 25 | border-radius: 3px; 26 | } 27 | 28 | .plupload_button:hover { 29 | color: #000; 30 | text-decoration: none; 31 | } 32 | 33 | .plupload_disabled, a.plupload_disabled:hover { 34 | color: #737373; 35 | border-color: #c5c5c5; 36 | background: #ededed url('../img/buttons-disabled.png') no-repeat 0 center; 37 | cursor: default; 38 | } 39 | 40 | .plupload_add { 41 | background-position: -181px center; 42 | } 43 | 44 | .plupload_wrapper { 45 | font: normal 11px Verdana,sans-serif; 46 | width: 100%; 47 | } 48 | 49 | .plupload_container { 50 | padding: 8px; 51 | background: url('../img/transp50.png'); 52 | /*-moz-border-radius: 5px;*/ 53 | } 54 | 55 | .plupload_container input { 56 | border: 1px solid #DDD; 57 | font: normal 11px Verdana,sans-serif; 58 | width: 98%; 59 | } 60 | 61 | .plupload_header {background: #2A2C2E url('../img/backgrounds.gif') repeat-x;} 62 | .plupload_header_content { 63 | background: url('../img/backgrounds.gif') no-repeat 0 -317px; 64 | min-height: 56px; 65 | padding-left: 60px; 66 | color: #FFF; 67 | } 68 | .plupload_header_title { 69 | font: normal 18px sans-serif; 70 | padding: 6px 0 3px; 71 | } 72 | .plupload_header_text { 73 | font: normal 12px sans-serif; 74 | } 75 | 76 | .plupload_filelist { 77 | margin: 0; 78 | padding: 0; 79 | list-style: none; 80 | } 81 | 82 | .plupload_scroll .plupload_filelist { 83 | height: 185px; 84 | background: #F5F5F5; 85 | overflow-y: scroll; 86 | } 87 | 88 | .plupload_filelist li { 89 | padding: 10px 8px; 90 | background: #F5F5F5 url('../img/backgrounds.gif') repeat-x 0 -156px; 91 | border-bottom: 1px solid #DDD; 92 | } 93 | 94 | .plupload_filelist_header, .plupload_filelist_footer { 95 | background: #DFDFDF; 96 | padding: 8px 8px; 97 | color: #42454A; 98 | } 99 | .plupload_filelist_header { 100 | border-top: 1px solid #EEE; 101 | border-bottom: 1px solid #CDCDCD; 102 | } 103 | 104 | .plupload_filelist_footer {border-top: 1px solid #FFF; height: 22px; line-height: 20px; vertical-align: middle;} 105 | .plupload_file_name {float: left; overflow: hidden} 106 | .plupload_file_status {color: #777;} 107 | .plupload_file_status span {color: #42454A;} 108 | .plupload_file_size, .plupload_file_status, .plupload_progress { 109 | float: right; 110 | width: 80px; 111 | } 112 | .plupload_file_size, .plupload_file_status, .plupload_file_action {text-align: right;} 113 | 114 | .plupload_filelist .plupload_file_name { 115 | width: 205px; 116 | white-space: nowrap; 117 | text-overflow: ellipsis; 118 | } 119 | 120 | .plupload_file_action { 121 | float: right; 122 | width: 16px; 123 | height: 16px; 124 | margin-left: 15px; 125 | } 126 | 127 | .plupload_file_action * { 128 | display: none; 129 | width: 16px; 130 | height: 16px; 131 | } 132 | 133 | li.plupload_uploading {background: #ECF3DC url('../img/backgrounds.gif') repeat-x 0 -238px;} 134 | li.plupload_done {color:#AAA} 135 | 136 | li.plupload_delete a { 137 | background: url('../img/delete.gif'); 138 | } 139 | 140 | li.plupload_failed a { 141 | background: url('../img/error.gif'); 142 | cursor: default; 143 | } 144 | 145 | li.plupload_done a { 146 | background: url('../img/done.gif'); 147 | cursor: default; 148 | } 149 | 150 | .plupload_progress, .plupload_upload_status { 151 | display: none; 152 | } 153 | 154 | .plupload_progress_container { 155 | margin-top: 3px; 156 | border: 1px solid #CCC; 157 | background: #FFF; 158 | padding: 1px; 159 | } 160 | .plupload_progress_bar { 161 | width: 0px; 162 | height: 7px; 163 | background: #CDEB8B; 164 | } 165 | 166 | .plupload_scroll .plupload_filelist_header .plupload_file_action, .plupload_scroll .plupload_filelist_footer .plupload_file_action { 167 | margin-right: 17px; 168 | } 169 | 170 | /* Floats */ 171 | 172 | .plupload_clear,.plupload_clearer {clear: both;} 173 | .plupload_clearer, .plupload_progress_bar { 174 | display: block; 175 | font-size: 0; 176 | line-height: 0; 177 | } 178 | 179 | li.plupload_droptext { 180 | background: transparent; 181 | text-align: center; 182 | vertical-align: middle; 183 | border: 0; 184 | line-height: 165px; 185 | } 186 | -------------------------------------------------------------------------------- /src/main/java/com/plupload/controller/PluploadServlet.java: -------------------------------------------------------------------------------- 1 | package com.plupload.controller; 2 | 3 | import java.io.BufferedInputStream; 4 | import java.io.BufferedOutputStream; 5 | import java.io.File; 6 | import java.io.FileOutputStream; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | import java.io.OutputStream; 10 | import java.util.Iterator; 11 | import java.util.List; 12 | 13 | import javax.servlet.ServletException; 14 | import javax.servlet.annotation.WebServlet; 15 | import javax.servlet.http.HttpServlet; 16 | import javax.servlet.http.HttpServletRequest; 17 | import javax.servlet.http.HttpServletResponse; 18 | 19 | import org.apache.commons.fileupload.FileItem; 20 | import org.apache.commons.fileupload.FileUploadException; 21 | import org.apache.commons.fileupload.disk.DiskFileItemFactory; 22 | import org.apache.commons.fileupload.servlet.ServletFileUpload; 23 | import org.apache.commons.fileupload.util.Streams; 24 | import org.apache.log4j.Logger; 25 | 26 | /** 27 | * Servlet implementation class PluploadServlet 28 | */ 29 | @WebServlet("/pluploadservlet") 30 | public class PluploadServlet extends HttpServlet { 31 | 32 | private static final long serialVersionUID = 1L; 33 | 34 | private static final int BUFFER_SIZE = 100 * 1024; 35 | 36 | private Logger logger = Logger.getLogger(PluploadServlet.class); 37 | 38 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 39 | doPost(request, response); 40 | } 41 | 42 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 43 | try { 44 | boolean isMultipart = ServletFileUpload.isMultipartContent(request); 45 | if(isMultipart){ 46 | String fileName = ""; 47 | Integer chunk = 0, chunks = 0; 48 | 49 | //检查文件目录,不存在则创建 50 | String relativePath = "/plupload/files/"; 51 | String realPath = request.getServletContext().getRealPath(""); 52 | File folder = new File(realPath + relativePath); 53 | if (!folder.exists()) { 54 | folder.mkdirs(); 55 | } 56 | 57 | DiskFileItemFactory diskFactory = new DiskFileItemFactory(); 58 | // threshold 极限、临界值,即硬盘缓存 1M 59 | diskFactory.setSizeThreshold(4 * 1024); 60 | 61 | ServletFileUpload upload = new ServletFileUpload(diskFactory); 62 | // 设置允许上传的最大文件大小(单位MB) 63 | upload.setSizeMax(1024 * 1048576); 64 | upload.setHeaderEncoding("UTF-8"); 65 | 66 | try { 67 | List fileList = upload.parseRequest(request); 68 | Iterator it = fileList.iterator(); 69 | while (it.hasNext()) { 70 | FileItem item = it.next(); 71 | String name = item.getFieldName(); 72 | InputStream input = item.getInputStream(); 73 | if("name".equals(name)){ 74 | fileName = Streams.asString(input); 75 | continue; 76 | } 77 | if("chunk".equals(name)){ 78 | chunk = Integer.valueOf(Streams.asString(input)); 79 | continue; 80 | } 81 | if("chunks".equals(name)){ 82 | chunks = Integer.valueOf(Streams.asString(input)); 83 | continue; 84 | } 85 | // 处理上传文件内容 86 | if (!item.isFormField()) { 87 | //目标文件 88 | File destFile = new File(folder, fileName); 89 | //文件已存在删除旧文件(上传了同名的文件) 90 | if (chunk == 0 && destFile.exists()) { 91 | destFile.delete(); 92 | destFile = new File(folder, fileName); 93 | } 94 | //合成文件 95 | appendFile(input, destFile); 96 | if (chunk == chunks - 1) { 97 | logger.info("上传完成"); 98 | }else { 99 | logger.info("还剩["+(chunks-1-chunk)+"]个块文件"); 100 | } 101 | } 102 | } 103 | } catch (FileUploadException ex) { 104 | logger.warn("上传文件失败:" + ex.getMessage()); 105 | return; 106 | } 107 | } 108 | } catch (IOException e) { 109 | logger.error(e.getMessage()); 110 | } 111 | } 112 | 113 | private void appendFile(InputStream in, File destFile) { 114 | OutputStream out = null; 115 | try { 116 | // plupload 配置了chunk的时候新上传的文件append到文件末尾 117 | if (destFile.exists()) { 118 | out = new BufferedOutputStream(new FileOutputStream(destFile, true), BUFFER_SIZE); 119 | } else { 120 | out = new BufferedOutputStream(new FileOutputStream(destFile),BUFFER_SIZE); 121 | } 122 | in = new BufferedInputStream(in, BUFFER_SIZE); 123 | 124 | int len = 0; 125 | byte[] buffer = new byte[BUFFER_SIZE]; 126 | while ((len = in.read(buffer)) > 0) { 127 | out.write(buffer, 0, len); 128 | } 129 | } catch (Exception e) { 130 | logger.error(e.getMessage()); 131 | } finally { 132 | try { 133 | if (null != in) { 134 | in.close(); 135 | } 136 | if(null != out){ 137 | out.close(); 138 | } 139 | } catch (IOException e) { 140 | logger.error(e.getMessage()); 141 | } 142 | } 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/main/webapp/static/plupload/js/jquery.plupload.queue/jquery.plupload.queue.min.js: -------------------------------------------------------------------------------- 1 | ;(function(e,t){function r(e){return plupload.translate(e)||e}function i(t,n){n.contents().each(function(t,n){n=e(n),n.is(".plupload")||n.remove()}),n.prepend('
'+'
'+'
'+'
'+'
'+r("Select files")+"
"+'
'+r("Add files to the upload queue and click the start button.")+"
"+"
"+"
"+'
'+'
'+'
'+r("Filename")+"
"+'
 
'+'
'+r("Status")+"
"+'
'+r("Size")+"
"+'
 
'+"
"+'
    '+'"+"
    "+"
    "+"
    "+''+"
    ")}var n={};e.fn.pluploadQueue=function(s){return s?(this.each(function(){function c(t){var n;t.status==plupload.DONE&&(n="plupload_done"),t.status==plupload.FAILED&&(n="plupload_failed"),t.status==plupload.QUEUED&&(n="plupload_delete"),t.status==plupload.UPLOADING&&(n="plupload_uploading");var r=e("#"+t.id).attr("class",n).find("a").css("display","block");t.hint&&r.attr("title",t.hint)}function h(){e("span.plupload_total_status",a).html(u.total.percent+"%"),e("div.plupload_progress_bar",a).css("width",u.total.percent+"%"),e("span.plupload_upload_status",a).html(t.sprintf(r("Uploaded %d/%d files"),u.total.uploaded,u.files.length))}function p(){var n=e("ul.plupload_filelist",a).html(""),i=0,s;e.each(u.files,function(t,r){s="",r.status==plupload.DONE&&(r.target_name&&(s+=''),s+='',s+='',i++,e("#"+f+"_count").val(i)),n.append('
  • '+'
    '+r.name+"
    "+'
    '+'
    '+r.percent+"%
    "+'
    '+plupload.formatSize(r.size)+"
    "+'
     
    '+s+"
  • "),c(r),e("#"+r.id+".plupload_delete a").click(function(t){e("#"+r.id).remove(),u.removeFile(r),t.preventDefault()})}),e("span.plupload_total_file_size",a).html(plupload.formatSize(u.total.size)),u.total.queued===0?e("span.plupload_add_text",a).html(r("Add Files")):e("span.plupload_add_text",a).html(t.sprintf(r("%d files queued"),u.total.queued)),e("a.plupload_start",a).toggleClass("plupload_disabled",u.files.length==u.total.uploaded+u.total.failed),n[0].scrollTop=n[0].scrollHeight,h(),!u.files.length&&u.features.dragdrop&&u.settings.dragdrop&&e("#"+f+"_filelist").append('
  • '+r("Drag files here.")+"
  • ")}function d(){delete n[f],u.destroy(),a.html(l),u=a=l=null}var u,a,f,l;a=e(this),f=a.attr("id"),f||(f=plupload.guid(),a.attr("id",f)),l=a.html(),i(f,a),s=e.extend({dragdrop:!0,browse_button:f+"_browse",container:f},s),s.dragdrop&&(s.drop_element=f+"_filelist"),u=new plupload.Uploader(s),n[f]=u,u.bind("UploadFile",function(t,n){e("#"+n.id).addClass("plupload_current_file")}),u.bind("Init",function(t,n){!s.unique_names&&s.rename&&a.on("click","#"+f+"_filelist div.plupload_file_name span",function(n){var r=e(n.target),i,s,o,u="";i=t.getFile(r.parents("li")[0].id),o=i.name,s=/^(.+)(\.[^.]+)$/.exec(o),s&&(o=s[1],u=s[2]),r.hide().after(''),r.next().val(o).focus().blur(function(){r.show().next().remove()}).keydown(function(t){var n=e(this);t.keyCode==13&&(t.preventDefault(),i.name=n.val()+u,r.html(i.name),n.blur())})}),e("#"+f+"_container").attr("title","Using runtime: "+n.runtime),e("a.plupload_start",a).click(function(t){e(this).hasClass("plupload_disabled")||u.start(),t.preventDefault()}),e("a.plupload_stop",a).click(function(e){e.preventDefault(),u.stop()}),e("a.plupload_start",a).addClass("plupload_disabled")}),u.bind("Error",function(t,n){var i=n.file,s;i&&(s=n.message,n.details&&(s+=" ("+n.details+")"),n.code==plupload.FILE_SIZE_ERROR&&alert(r("Error: File too large:")+" "+i.name),n.code==plupload.FILE_EXTENSION_ERROR&&alert(r("Error: Invalid file extension:")+" "+i.name),i.hint=s,e("#"+i.id).attr("class","plupload_failed").find("a").css("display","block").attr("title",s)),n.code===plupload.INIT_ERROR&&setTimeout(function(){d()},1)}),u.bind("PostInit",function(t){t.settings.dragdrop&&t.features.dragdrop&&e("#"+f+"_filelist").append('
  • '+r("Drag files here.")+"
  • ")}),u.init(),u.bind("StateChanged",function(){u.state===plupload.STARTED?(e("li.plupload_delete a,div.plupload_buttons",a).hide(),u.disableBrowse(!0),e("span.plupload_upload_status,div.plupload_progress,a.plupload_stop",a).css("display","block"),e("span.plupload_upload_status",a).html("Uploaded "+u.total.uploaded+"/"+u.files.length+" files"),s.multiple_queues&&e("span.plupload_total_status,span.plupload_total_file_size",a).show()):(p(),e("a.plupload_stop,div.plupload_progress",a).hide(),e("a.plupload_delete",a).css("display","block"),s.multiple_queues&&u.total.uploaded+u.total.failed==u.files.length&&(e(".plupload_buttons,.plupload_upload_status",a).css("display","inline"),u.disableBrowse(!1),e(".plupload_start",a).addClass("plupload_disabled"),e("span.plupload_total_status,span.plupload_total_file_size",a).hide()))}),u.bind("FilesAdded",p),u.bind("FilesRemoved",function(){var t=e("#"+f+"_filelist").scrollTop();p(),e("#"+f+"_filelist").scrollTop(t)}),u.bind("FileUploaded",function(e,t){c(t)}),u.bind("UploadProgress",function(t,n){e("#"+n.id+" div.plupload_file_status",a).html(n.percent+"%"),c(n),h()}),s.setup&&s.setup(u)}),this):n[e(this[0]).attr("id")]}})(jQuery,mOxie); -------------------------------------------------------------------------------- /src/main/webapp/static/plupload/js/jquery.ui.plupload/css/jquery.ui.plupload.css: -------------------------------------------------------------------------------- 1 | /* 2 | Plupload 3 | ------------------------------------------------------------------- */ 4 | 5 | .plupload_wrapper * { 6 | box-sizing: content-box; 7 | } 8 | 9 | .plupload_button { 10 | cursor: pointer; 11 | outline: none; 12 | } 13 | 14 | .plupload_wrapper { 15 | font: normal 11px Verdana,sans-serif; 16 | width: 100%; 17 | min-width: 520px; 18 | line-height: 12px; 19 | } 20 | 21 | .plupload_container { 22 | _height: 300px; 23 | min-height: 300px; 24 | position: relative; 25 | } 26 | 27 | .plupload_filelist_footer {border-width: 1px 0 0 0} 28 | .plupload_file {border-width: 0 0 1px 0} 29 | .plupload_container .plupload_header {border-width: 0 0 1px 0; position: relative;} 30 | 31 | .plupload_delete .ui-icon, 32 | .plupload_done .ui-icon, 33 | .plupload_failed .ui-icon { 34 | cursor:pointer; 35 | } 36 | 37 | .plupload_header_content { 38 | height: 56px; 39 | padding: 0 160px 0 60px; 40 | position: relative; 41 | } 42 | 43 | .plupload_logo { 44 | width: 40px; 45 | height: 40px; 46 | background: url('../img/plupload.png') no-repeat 0 0; 47 | position: absolute; 48 | top: 8px; 49 | left: 8px; 50 | } 51 | 52 | .plupload_header_content_bw .plupload_logo { 53 | background-position: -40px 0; 54 | } 55 | 56 | .plupload_header_title { 57 | font: normal 18px sans-serif; 58 | line-height: 19px; 59 | padding: 6px 0 3px; 60 | } 61 | 62 | .plupload_header_text { 63 | font: normal 12px sans-serif; 64 | } 65 | 66 | .plupload_view_switch { 67 | position: absolute; 68 | right: 16px; 69 | bottom: 8px; 70 | margin: 0; 71 | display: none; 72 | } 73 | 74 | .plupload_view_switch .ui-button { 75 | margin-right: -0.31em; 76 | } 77 | 78 | .plupload_content { 79 | position: absolute; 80 | top: 86px; 81 | bottom: 44px; 82 | left: 0; 83 | right: 0; 84 | overflow-y: auto; 85 | width: 100%; 86 | } 87 | 88 | .plupload_filelist { 89 | border-collapse: collapse; 90 | border-left: none; 91 | border-right: none; 92 | margin: 0; 93 | padding: 0; 94 | width: 100%; 95 | -moz-user-select: none; 96 | -webkit-user-select: none; 97 | user-select: none; 98 | } 99 | 100 | .plupload_filelist_content { 101 | padding: 0; 102 | margin: 0; 103 | } 104 | 105 | .plupload_cell {padding: 8px 6px;} 106 | 107 | .plupload_file { 108 | list-style: none; 109 | display: block; 110 | position: relative; 111 | overflow: hidden; 112 | line-height: 12px; 113 | } 114 | 115 | .plupload_file_thumb { 116 | position: relative; 117 | background-image: none; 118 | background-color: #eee; 119 | } 120 | 121 | .plupload_file_loading .plupload_file_thumb { 122 | background: #eee url(../img/loading.gif) center no-repeat; 123 | } 124 | 125 | .plupload_file_name { 126 | overflow: hidden; 127 | text-overflow: ellipsis; 128 | white-space: nowrap; 129 | } 130 | 131 | .plupload_filelist_header { 132 | border-top: none; 133 | } 134 | 135 | .plupload_filelist_footer { 136 | position: absolute; 137 | bottom: 0; 138 | left: 0; 139 | right: 0; 140 | } 141 | 142 | .plupload_buttons { 143 | position: relative; 144 | } 145 | 146 | /* list view */ 147 | .plupload_view_list .plupload_file { 148 | border-left: none; 149 | border-right: none; 150 | border-top: none; 151 | height: 29px; 152 | width: 100% !important; 153 | /* fix IE6 vertical white-space bug */ 154 | _float: left; 155 | _clear: left; 156 | } 157 | 158 | .plupload_view_list div.plupload_file_size, 159 | .plupload_view_list div.plupload_file_status, 160 | .plupload_view_list div.plupload_file_action { 161 | padding: 8px 6px; 162 | position: absolute; 163 | top: 0; 164 | right: 0; 165 | } 166 | 167 | .plupload_view_list div.plupload_file_name { 168 | margin-right: 156px; 169 | padding: 8px 6px; 170 | _width: 75%; 171 | } 172 | 173 | .plupload_view_list div.plupload_file_size { 174 | right: 28px; 175 | } 176 | 177 | .plupload_view_list div.plupload_file_status { 178 | right: 82px; 179 | } 180 | 181 | .plupload_view_list .plupload_file_rename { 182 | margin-left: -2px; 183 | } 184 | 185 | .plupload_view_list .plupload_file_size, 186 | .plupload_view_list .plupload_file_status, 187 | .plupload_filelist_footer .plupload_file_size, 188 | .plupload_filelist_footer .plupload_file_status { 189 | text-align: right; 190 | width: 52px; 191 | } 192 | 193 | .plupload_view_list .plupload_file_thumb { 194 | position: absolute; 195 | top: -999px; 196 | } 197 | 198 | .plupload_view_list .plupload_file_progress { 199 | display: none; 200 | } 201 | 202 | 203 | /* thumbs view */ 204 | .plupload_view_thumbs .plupload_content { 205 | top: 57px; 206 | } 207 | 208 | .plupload_view_thumbs .plupload_filelist_header { 209 | display: none; 210 | } 211 | 212 | .plupload_view_thumbs .plupload_file { 213 | padding: 6px; 214 | margin: 10px; 215 | border: 1px solid #fff; 216 | float: left; 217 | } 218 | 219 | .plupload_view_thumbs .plupload_file_thumb, 220 | .plupload_view_thumbs .plupload_file_dummy { 221 | text-align: center; 222 | overflow: hidden; 223 | } 224 | 225 | .plupload_view_thumbs .plupload_file_dummy { 226 | font-size: 21px; 227 | font-weight: bold; 228 | text-transform: lowercase; 229 | overflow: hidden; 230 | border: none; 231 | position: absolute; 232 | top: 0; 233 | left: 0; 234 | width: 100%; 235 | height: 100%; 236 | } 237 | 238 | .plupload_view_thumbs div.plupload_file_action { 239 | position: absolute; 240 | top: 0; 241 | right: 0; 242 | } 243 | 244 | .plupload_view_thumbs div.plupload_file_name { 245 | padding: 0; 246 | font-weight: bold; 247 | } 248 | 249 | .plupload_view_thumbs .plupload_file_rename { 250 | padding: 1px 0; 251 | width: 100% !important; 252 | } 253 | 254 | .plupload_view_thumbs div.plupload_file_size { 255 | font-size: 0.8em; 256 | font-weight: normal; 257 | } 258 | 259 | .plupload_view_thumbs div.plupload_file_status { 260 | position: relative; 261 | height: 3px; 262 | overflow: hidden; 263 | text-indent: -999px; 264 | margin-bottom: 3px; 265 | } 266 | 267 | .plupload_view_thumbs div.plupload_file_progress { 268 | border: none; 269 | height: 100%; 270 | } 271 | 272 | .plupload .ui-sortable-helper, 273 | .plupload .ui-sortable .plupload_file { 274 | cursor:move; 275 | } 276 | 277 | .plupload_file_action {width: 16px;} 278 | .plupload_file_name { 279 | overflow: hidden; 280 | padding-left: 10px; 281 | } 282 | 283 | .plupload_file_rename { 284 | border: none; 285 | font: normal 11px Verdana, sans-serif; 286 | padding: 1px 2px; 287 | line-height: 11px; 288 | height: 11px; 289 | } 290 | 291 | .plupload_progress {width: 60px;} 292 | .plupload_progress_container {padding: 1px;} 293 | 294 | 295 | /* Floats */ 296 | 297 | .plupload_right {float: right;} 298 | .plupload_left {float: left;} 299 | .plupload_clear,.plupload_clearer {clear: both;} 300 | .plupload_clearer, .plupload_progress_bar { 301 | display: block; 302 | font-size: 0; 303 | line-height: 0; 304 | } 305 | .plupload_clearer {height: 0;} 306 | 307 | /* Misc */ 308 | .plupload_hidden {display: none !important;} 309 | 310 | .plupload_droptext { 311 | position: absolute; 312 | top: 0; 313 | left: 0; 314 | right: 0; 315 | bottom: 0; 316 | background: transparent; 317 | text-align: center; 318 | vertical-align: middle; 319 | border: 0; 320 | line-height: 160px; 321 | display: none; 322 | } 323 | 324 | .plupload_dropbox .plupload_droptext { 325 | display: block; 326 | } 327 | 328 | .plupload_buttons, .plupload_upload_status {float: left} 329 | 330 | .plupload_message { 331 | position: absolute; 332 | top: -1px; 333 | left: -1px; 334 | height: 100%; 335 | width: 100%; 336 | } 337 | 338 | .plupload_message p { 339 | padding:0.7em; 340 | margin:0; 341 | } 342 | 343 | .plupload_message strong { 344 | font-weight: bold; 345 | } 346 | 347 | plupload_message i { 348 | font-style: italic; 349 | } 350 | 351 | .plupload_message p span.ui-icon { 352 | float: left; 353 | margin-right: 0.3em; 354 | } 355 | 356 | .plupload_header_content .ui-state-error, 357 | .plupload_header_content .ui-state-highlight { 358 | border:none; 359 | } 360 | 361 | .plupload_message_close { 362 | position:absolute; 363 | top:5px; 364 | right:5px; 365 | cursor:pointer; 366 | } 367 | 368 | .plupload .ui-sortable-placeholder { 369 | height:35px; 370 | } 371 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /src/main/webapp/static/plupload/js/jquery.ui.plupload/jquery.ui.plupload.min.js: -------------------------------------------------------------------------------- 1 | ;(function(e,t,n,r,i){function o(e){return n.translate(e)||e}function u(e){e.id=e.attr("id"),e.html('
    '+o("Select files")+"
    "+'
    '+o("Add files to the upload queue and click the start button.")+"
    "+'
    '+'"+'"+"
    "+"
    "+"
    "+''+""+'"+'"+'"+''+""+"
    '+o("Filename")+"'+o("Status")+"'+o("Size")+" 
    "+'
    '+'
    '+o("Drag files here.")+"
    "+'
    '+'
     
    '+"
    "+''+""+'"+''+''+''+""+""+"
    "+''+"
    ")}var s={};i.widget("ui.plupload",{widgetEventPrefix:"",contents_bak:"",options:{browse_button_hover:"ui-state-hover",browse_button_active:"ui-state-active",filters:{},buttons:{browse:!0,start:!0,stop:!0},views:{list:!0,thumbs:!1,active:"list",remember:!0},thumb_width:100,thumb_height:60,multiple_queues:!0,dragdrop:!0,autostart:!1,sortable:!1,rename:!1},FILE_COUNT_ERROR:-9001,_create:function(){var e=this.element.attr("id");e||(e=n.guid(),this.element.attr("id",e)),this.id=e,this.contents_bak=this.element.html(),u(this.element),this.container=i(".plupload_container",this.element).attr("id",e+"_container"),this.content=i(".plupload_content",this.element),i.fn.resizable&&this.container.resizable({handles:"s",minHeight:300}),this.filelist=i(".plupload_filelist_content",this.container).attr({id:e+"_filelist",unselectable:"on"}),this.browse_button=i(".plupload_add",this.container).attr("id",e+"_browse"),this.start_button=i(".plupload_start",this.container).attr("id",e+"_start"),this.stop_button=i(".plupload_stop",this.container).attr("id",e+"_stop"),this.thumbs_switcher=i("#"+e+"_view_thumbs"),this.list_switcher=i("#"+e+"_view_list"),i.ui.button&&(this.browse_button.button({icons:{primary:"ui-icon-circle-plus"},disabled:!0}),this.start_button.button({icons:{primary:"ui-icon-circle-arrow-e"},disabled:!0}),this.stop_button.button({icons:{primary:"ui-icon-circle-close"}}),this.list_switcher.button({text:!1,icons:{secondary:"ui-icon-grip-dotted-horizontal"}}),this.thumbs_switcher.button({text:!1,icons:{secondary:"ui-icon-image"}})),this.progressbar=i(".plupload_progress_container",this.container),i.ui.progressbar&&this.progressbar.progressbar(),this.counter=i(".plupload_count",this.element).attr({id:e+"_count",name:e+"_count"}),this._initUploader()},_initUploader:function(){var e=this,t=this.id,u,a={container:t+"_buttons",browse_button:t+"_browse"};i(".plupload_buttons",this.element).attr("id",t+"_buttons"),e.options.dragdrop&&(this.filelist.parent().attr("id",this.id+"_dropbox"),a.drop_element=this.id+"_dropbox"),this.filelist.on("click",function(t){i(t.target).hasClass("plupload_action_icon")&&(e.removeFile(i(t.target).closest(".plupload_file").attr("id")),t.preventDefault())}),u=this.uploader=s[t]=new n.Uploader(i.extend(this.options,a)),e.options.views.thumbs&&(u.settings.required_features.display_media=!0),e.options.max_file_count&&n.extend(u.getOption("filters"),{max_file_count:e.options.max_file_count}),n.addFileFilter("max_file_count",function(t,n,r){t<=this.files.length-(this.total.uploaded+this.total.failed)?(e.browse_button.button("disable"),this.disableBrowse(),this.trigger("Error",{code:e.FILE_COUNT_ERROR,message:o("File count error."),file:n}),r(!1)):r(!0)}),u.bind("Error",function(t,i){var s,u="";s=""+i.message+"";switch(i.code){case n.FILE_EXTENSION_ERROR:u=r.sprintf(o("File: %s"),i.file.name);break;case n.FILE_SIZE_ERROR:u=r.sprintf(o("File: %s, size: %d, max file size: %d"),i.file.name,n.formatSize(i.file.size),n.formatSize(n.parseSize(t.getOption("filters").max_file_size)));break;case n.FILE_DUPLICATE_ERROR:u=r.sprintf(o("%s already present in the queue."),i.file.name);break;case e.FILE_COUNT_ERROR:u=r.sprintf(o("Upload element accepts only %d file(s) at a time. Extra files were stripped."),t.getOption("filters").max_file_count||0);break;case n.IMAGE_FORMAT_ERROR:u=o("Image format either wrong or not supported.");break;case n.IMAGE_MEMORY_ERROR:u=o("Runtime ran out of available memory.");break;case n.HTTP_ERROR:u=o("Upload URL might be wrong or doesn't exist.")}s+="
    "+u+"",e._trigger("error",null,{up:t,error:i}),i.code===n.INIT_ERROR?setTimeout(function(){e.destroy()},1):e.notify("error",s)}),u.bind("PostInit",function(t){e.options.buttons.browse?e.browse_button.button("enable"):(e.browse_button.button("disable").hide(),t.disableBrowse(!0)),e.options.buttons.start||e.start_button.button("disable").hide(),e.options.buttons.stop||e.stop_button.button("disable").hide(),!e.options.unique_names&&e.options.rename&&e._enableRenaming(),e.options.dragdrop&&t.features.dragdrop&&e.filelist.parent().addClass("plupload_dropbox"),e._enableViewSwitcher(),e.start_button.click(function(t){i(this).button("option","disabled")||e.start(),t.preventDefault()}),e.stop_button.click(function(t){e.stop(),t.preventDefault()}),e._trigger("ready",null,{up:t})}),u.init(),u.bind("FileFiltered",function(t,n){e._addFiles(n)}),u.bind("FilesAdded",function(t,n){e._trigger("selected",null,{up:t,files:n}),e.options.sortable&&i.ui.sortable&&e._enableSortingList(),e._trigger("updatelist",null,{filelist:e.filelist}),e.options.autostart&&setTimeout(function(){e.start()},10)}),u.bind("FilesRemoved",function(t,n){i.ui.sortable&&e.options.sortable&&i("tbody",e.filelist).sortable("destroy"),i.each(n,function(e,t){i("#"+t.id).toggle("highlight",function(){i(this).remove()})}),t.files.length&&e.options.sortable&&i.ui.sortable&&e._enableSortingList(),e._trigger("updatelist",null,{filelist:e.filelist}),e._trigger("removed",null,{up:t,files:n})}),u.bind("QueueChanged StateChanged",function(){e._handleState()}),u.bind("UploadFile",function(t,n){e._handleFileStatus(n)}),u.bind("FileUploaded",function(t,n){e._handleFileStatus(n),e._trigger("uploaded",null,{up:t,file:n})}),u.bind("UploadProgress",function(t,n){e._handleFileStatus(n),e._updateTotalProgress(),e._trigger("progress",null,{up:t,file:n})}),u.bind("UploadComplete",function(t,n){e._addFormFields(),e._trigger("complete",null,{up:t,files:n})})},_setOption:function(e,t){var n=this;e=="buttons"&&typeof t=="object"&&(t=i.extend(n.options.buttons,t),t.browse?(n.browse_button.button("enable").show(),n.uploader.disableBrowse(!1)):(n.browse_button.button("disable").hide(),n.uploader.disableBrowse(!0)),t.start?n.start_button.button("enable").show():n.start_button.button("disable").hide(),t.stop?n.start_button.button("enable").show():n.stop_button.button("disable").hide()),n.uploader.settings[e]=t},start:function(){this.uploader.start(),this._trigger("start",null,{up:this.uploader})},stop:function(){this.uploader.stop(),this._trigger("stop",null,{up:this.uploader})},enable:function(){this.browse_button.button("enable"),this.uploader.disableBrowse(!1)},disable:function(){this.browse_button.button("disable"),this.uploader.disableBrowse(!0)},getFile:function(e){var t;return typeof e=="number"?t=this.uploader.files[e]:t=this.uploader.getFile(e),t},getFiles:function(){return this.uploader.files},removeFile:function(e){n.typeOf(e)==="string"&&(e=this.getFile(e)),this.uploader.removeFile(e)},clearQueue:function(){this.uploader.splice()},getUploader:function(){return this.uploader},refresh:function(){this.uploader.refresh()},notify:function(e,t){var n=i('
    '+'

    '+t+"

    "+"
    ");n.addClass("ui-state-"+(e==="error"?"error":"highlight")).find("p .ui-icon").addClass("ui-icon-"+(e==="error"?"alert":"info")).end().find(".plupload_message_close").click(function(){n.remove()}).end(),i(".plupload_header",this.container).append(n)},destroy:function(){this.uploader.destroy(),i(".plupload_button",this.element).unbind(),i.ui.button&&i(".plupload_add, .plupload_start, .plupload_stop",this.container).button("destroy"),i.ui.progressbar&&this.progressbar.progressbar("destroy"),i.ui.sortable&&this.options.sortable&&i("tbody",this.filelist).sortable("destroy"),this.element.empty().html(this.contents_bak),this.contents_bak="",i.Widget.prototype.destroy.apply(this)},_handleState:function(){var e=this.uploader,t=e.files.length-(e.total.uploaded+e.total.failed),s=e.getOption("filters").max_file_count||0;n.STARTED===e.state?(i([]).add(this.stop_button).add(".plupload_started").removeClass("plupload_hidden"),this.start_button.button("disable"),this.options.multiple_queues||(this.browse_button.button("disable"),e.disableBrowse()),i(".plupload_upload_status",this.element).html(r.sprintf(o("Uploaded %d/%d files"),e.total.uploaded,e.files.length)),i(".plupload_header_content",this.element).addClass("plupload_header_content_bw")):n.STOPPED===e.state&&(i([]).add(this.stop_button).add(".plupload_started").addClass("plupload_hidden"),t?this.start_button.button("enable"):this.start_button.button("disable"),this.options.multiple_queues&&i(".plupload_header_content",this.element).removeClass("plupload_header_content_bw"),this.options.multiple_queues&&s&&s>t&&(this.browse_button.button("enable"),e.disableBrowse(!1)),this._updateTotalProgress()),e.total.queued===0?i(".ui-button-text",this.browse_button).html(o("Add Files")):i(".ui-button-text",this.browse_button).html(r.sprintf(o("%d files queued"),e.total.queued)),e.refresh()},_handleFileStatus:function(e){var t=i("#"+e.id),r,s;if(!t.length)return;switch(e.status){case n.DONE:r="plupload_done",s="plupload_action_icon ui-icon ui-icon-circle-check";break;case n.FAILED:r="ui-state-error plupload_failed",s="plupload_action_icon ui-icon ui-icon-alert";break;case n.QUEUED:r="plupload_delete",s="plupload_action_icon ui-icon ui-icon-circle-minus";break;case n.UPLOADING:r="ui-state-highlight plupload_uploading",s="plupload_action_icon ui-icon ui-icon-circle-arrow-w";var o=i(".plupload_scroll",this.container),u=o.scrollTop(),a=o.height(),f=t.position().top+t.height();a
    %ext%
    %percent%
    %name%
    %size%
    ',n.typeOf(e)!=="array"&&(e=[e]),i.each(e,function(e,i){var u=r.Mime.getFileExtension(i.name)||"none";o+=s.replace(/%(\w+)%/g,function(e,r){switch(r){case"thumb_width":case"thumb_height":return t.options[r];case"size":return n.formatSize(i.size);case"ext":return u;default:return i[r]||""}})}),t.filelist.append(o)},_addFormFields:function(){var e=this;i(".plupload_file_fields",this.filelist).html(""),n.each(this.uploader.files,function(t,r){var s="",o=e.id+"_"+r;t.target_name&&(s+=''),s+='',s+='',i("#"+t.id).find(".plupload_file_fields").html(s)}),this.counter.val(this.uploader.files.length)},_viewChanged:function(e){this.options.views.remember&&i.cookie&&i.cookie("plupload_ui_view",e,{expires:7,path:"/"}),r.Env.browser==="IE"&&r.Env.version<7&&this.content.attr("style",'height:expression(document.getElementById("'+this.id+"_container"+'").clientHeight - '+(e==="list"?132:102)+")"),this.container.removeClass("plupload_view_list plupload_view_thumbs").addClass("plupload_view_"+e),this.view_mode=e,this._trigger("viewchanged",null,{view:e})},_enableViewSwitcher:function(){var e=this,t,r=i(".plupload_view_switch",this.container),s,o;n.each(["list","thumbs"],function(t){e.options.views[t]||r.find('[for="'+e.id+"_view_"+t+'"], #'+e.id+"_view_"+t).remove()}),s=r.find(".plupload_button"),s.length===1?(r.hide(),t=s.eq(0).data("view"),this._viewChanged(t)):i.ui.button&&s.length>1?(this.options.views.remember&&i.cookie&&(t=i.cookie("plupload_ui_view")),~n.inArray(t,["list","thumbs"])||(t=this.options.views.active),r.show().buttonset().find(".ui-button").click(function(n){t=i(this).data("view"),e._viewChanged(t),n.preventDefault()}),o=r.find('[for="'+e.id+"_view_"+t+'"]'),o.length&&o.trigger("click")):(r.show(),this._viewChanged(this.options.views.active)),this.options.views.thumbs&&this._displayThumbs()},_enableRenaming:function(){var e=this;this.filelist.dblclick(function(t){var n=i(t.target),r,s,o,u,a="";if(!n.hasClass("plupload_file_name_wrapper"))return;s=e.uploader.getFile(n.closest(".plupload_file")[0].id),u=s.name,o=/^(.+)(\.[^.]+)$/.exec(u),o&&(u=o[1],a=o[2]),r=i('').width(n.width()).insertAfter(n.hide()),r.val(u).blur(function(){n.show().parent().scrollLeft(0).end().next().remove()}).keydown(function(e){var t=i(this);i.inArray(e.keyCode,[13,27])!==-1&&(e.preventDefault(),e.keyCode===13&&(s.name=t.val()+a,n.html(s.name)),t.blur())})[0].focus()})},_enableSortingList:function(){var e=this;if(i(".plupload_file",this.filelist).length<2)return;i("tbody",this.filelist).sortable("destroy"),this.filelist.sortable({items:".plupload_delete",cancel:"object, .plupload_clearer",stop:function(){var t=[];i.each(i(this).sortable("toArray"),function(n,r){t[t.length]=e.uploader.getFile(r)}),t.unshift(t.length),t.unshift(0),Array.prototype.splice.apply(e.uploader.files,t)}})}})})(window,document,plupload,mOxie,jQuery); -------------------------------------------------------------------------------- /src/main/webapp/static/plupload/js/jquery.plupload.queue/jquery.plupload.queue.js: -------------------------------------------------------------------------------- 1 | /** 2 | * jquery.plupload.queue.js 3 | * 4 | * Copyright 2009, Moxiecode Systems AB 5 | * Released under GPL License. 6 | * 7 | * License: http://www.plupload.com/license 8 | * Contributing: http://www.plupload.com/contributing 9 | */ 10 | 11 | /* global jQuery:true, alert:true */ 12 | 13 | /** 14 | jQuery based implementation of the Plupload API - multi-runtime file uploading API. 15 | 16 | To use the widget you must include _jQuery_. It is not meant to be extended in any way and is provided to be 17 | used as it is. 18 | 19 | @example 20 | 21 |
    22 |

    Your browser doesn't have Flash, Silverlight or HTML5 support.

    23 |
    24 | 25 | 36 | 37 | @example 38 | // Retrieving a reference to plupload.Uploader object 39 | var uploader = $('#uploader').pluploadQueue(); 40 | 41 | uploader.bind('FilesAdded', function() { 42 | 43 | // Autostart 44 | setTimeout(uploader.start, 1); // "detach" from the main thread 45 | }); 46 | 47 | @class pluploadQueue 48 | @constructor 49 | @param {Object} settings For detailed information about each option check documentation. 50 | @param {String} settings.url URL of the server-side upload handler. 51 | @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. 52 | @param {String} [settings.file_data_name="file"] Name for the file field in Multipart formated message. 53 | @param {Array} [settings.filters=[]] Set of file type filters, each one defined by hash of title and extensions. `e.g. {title : "Image files", extensions : "jpg,jpeg,gif,png"}`. Dispatches `plupload.FILE_EXTENSION_ERROR` 54 | @param {String} [settings.flash_swf_url] URL of the Flash swf. 55 | @param {Object} [settings.headers] Custom headers to send with the upload. Hash of name/value pairs. 56 | @param {Number|String} [settings.max_file_size] 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`. 57 | @param {Number} [settings.max_retries=0] How many times to retry the chunk or file, before triggering Error event. 58 | @param {Boolean} [settings.multipart=true] Whether to send file and additional parameters as Multipart formated message. 59 | @param {Object} [settings.multipart_params] Hash of key/value pairs to send with every file upload. 60 | @param {Boolean} [settings.multi_selection=true] Enable ability to select multiple files at once in file dialog. 61 | @param {Boolean} [settings.prevent_duplicates=false] Do not let duplicates into the queue. Dispatches `plupload.FILE_DUPLICATE_ERROR`. 62 | @param {String|Object} [settings.required_features] Either comma-separated list or hash of required features that chosen runtime should absolutely possess. 63 | @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}` 64 | @param {Number} [settings.resize.width] If image is bigger, it will be resized. 65 | @param {Number} [settings.resize.height] If image is bigger, it will be resized. 66 | @param {Number} [settings.resize.quality=90] Compression quality for jpegs (1-100). 67 | @param {Boolean} [settings.resize.crop=false] Whether to crop images to exact dimensions. By default they will be resized proportionally. 68 | @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. 69 | @param {String} [settings.silverlight_xap_url] URL of the Silverlight xap. 70 | @param {Boolean} [settings.unique_names=false] If true will generate unique filenames for uploaded files. 71 | 72 | @param {Boolean} [settings.dragdrop=true] Enable ability to add file to the queue by drag'n'dropping them from the desktop. 73 | @param {Boolean} [settings.rename=false] Enable ability to rename files in the queue. 74 | @param {Boolean} [settings.multiple_queues=true] Re-activate the widget after each upload procedure. 75 | */ 76 | ;(function($, o) { 77 | var uploaders = {}; 78 | 79 | function _(str) { 80 | return plupload.translate(str) || str; 81 | } 82 | 83 | function renderUI(id, target) { 84 | // Remove all existing non plupload items 85 | target.contents().each(function(i, node) { 86 | node = $(node); 87 | 88 | if (!node.is('.plupload')) { 89 | node.remove(); 90 | } 91 | }); 92 | 93 | target.prepend( 94 | '
    ' + 95 | '
    ' + 96 | '
    ' + 97 | '
    ' + 98 | '
    ' + 99 | '
    ' + _('Select files') + '
    ' + 100 | '
    ' + _('Add files to the upload queue and click the start button.') + '
    ' + 101 | '
    ' + 102 | '
    ' + 103 | 104 | '
    ' + 105 | '
    ' + 106 | '
    ' + _('Filename') + '
    ' + 107 | '
     
    ' + 108 | '
    ' + _('Status') + '
    ' + 109 | '
    ' + _('Size') + '
    ' + 110 | '
     
    ' + 111 | '
    ' + 112 | 113 | '
      ' + 114 | 115 | '' + 133 | '
      ' + 134 | '
      ' + 135 | '
      ' + 136 | '' + 137 | '
      ' 138 | ); 139 | } 140 | 141 | $.fn.pluploadQueue = function(settings) { 142 | if (settings) { 143 | this.each(function() { 144 | var uploader, target, id, contents_bak; 145 | 146 | target = $(this); 147 | id = target.attr('id'); 148 | 149 | if (!id) { 150 | id = plupload.guid(); 151 | target.attr('id', id); 152 | } 153 | 154 | contents_bak = target.html(); 155 | renderUI(id, target); 156 | 157 | settings = $.extend({ 158 | dragdrop : true, 159 | browse_button : id + '_browse', 160 | container : id 161 | }, settings); 162 | 163 | // Enable drag/drop (see PostInit handler as well) 164 | if (settings.dragdrop) { 165 | settings.drop_element = id + '_filelist'; 166 | } 167 | 168 | uploader = new plupload.Uploader(settings); 169 | 170 | uploaders[id] = uploader; 171 | 172 | function handleStatus(file) { 173 | var actionClass; 174 | 175 | if (file.status == plupload.DONE) { 176 | actionClass = 'plupload_done'; 177 | } 178 | 179 | if (file.status == plupload.FAILED) { 180 | actionClass = 'plupload_failed'; 181 | } 182 | 183 | if (file.status == plupload.QUEUED) { 184 | actionClass = 'plupload_delete'; 185 | } 186 | 187 | if (file.status == plupload.UPLOADING) { 188 | actionClass = 'plupload_uploading'; 189 | } 190 | 191 | var icon = $('#' + file.id).attr('class', actionClass).find('a').css('display', 'block'); 192 | if (file.hint) { 193 | icon.attr('title', file.hint); 194 | } 195 | } 196 | 197 | function updateTotalProgress() { 198 | $('span.plupload_total_status', target).html(uploader.total.percent + '%'); 199 | $('div.plupload_progress_bar', target).css('width', uploader.total.percent + '%'); 200 | $('span.plupload_upload_status', target).html( 201 | o.sprintf(_('Uploaded %d/%d files'), uploader.total.uploaded, uploader.files.length) 202 | ); 203 | } 204 | 205 | function updateList() { 206 | var fileList = $('ul.plupload_filelist', target).html(''), inputCount = 0, inputHTML; 207 | 208 | $.each(uploader.files, function(i, file) { 209 | inputHTML = ''; 210 | 211 | if (file.status == plupload.DONE) { 212 | if (file.target_name) { 213 | inputHTML += ''; 214 | } 215 | 216 | inputHTML += ''; 217 | inputHTML += ''; 218 | 219 | inputCount++; 220 | 221 | $('#' + id + '_count').val(inputCount); 222 | } 223 | 224 | fileList.append( 225 | '
    • ' + 226 | '
      ' + file.name + '
      ' + 227 | '
      ' + 228 | '
      ' + file.percent + '%
      ' + 229 | '
      ' + plupload.formatSize(file.size) + '
      ' + 230 | '
       
      ' + 231 | inputHTML + 232 | '
    • ' 233 | ); 234 | 235 | handleStatus(file); 236 | 237 | $('#' + file.id + '.plupload_delete a').click(function(e) { 238 | $('#' + file.id).remove(); 239 | uploader.removeFile(file); 240 | 241 | e.preventDefault(); 242 | }); 243 | }); 244 | 245 | $('span.plupload_total_file_size', target).html(plupload.formatSize(uploader.total.size)); 246 | 247 | if (uploader.total.queued === 0) { 248 | $('span.plupload_add_text', target).html(_('Add Files')); 249 | } else { 250 | $('span.plupload_add_text', target).html(o.sprintf(_('%d files queued'), uploader.total.queued)); 251 | } 252 | 253 | $('a.plupload_start', target).toggleClass('plupload_disabled', uploader.files.length == (uploader.total.uploaded + uploader.total.failed)); 254 | 255 | // Scroll to end of file list 256 | fileList[0].scrollTop = fileList[0].scrollHeight; 257 | 258 | updateTotalProgress(); 259 | 260 | // Re-add drag message if there is no files 261 | if (!uploader.files.length && uploader.features.dragdrop && uploader.settings.dragdrop) { 262 | $('#' + id + '_filelist').append('
    • ' + _("Drag files here.") + '
    • '); 263 | } 264 | } 265 | 266 | function destroy() { 267 | delete uploaders[id]; 268 | uploader.destroy(); 269 | target.html(contents_bak); 270 | uploader = target = contents_bak = null; 271 | } 272 | 273 | uploader.bind("UploadFile", function(up, file) { 274 | $('#' + file.id).addClass('plupload_current_file'); 275 | }); 276 | 277 | uploader.bind('Init', function(up, res) { 278 | // Enable rename support 279 | if (!settings.unique_names && settings.rename) { 280 | target.on('click', '#' + id + '_filelist div.plupload_file_name span', function(e) { 281 | var targetSpan = $(e.target), file, parts, name, ext = ""; 282 | 283 | // Get file name and split out name and extension 284 | file = up.getFile(targetSpan.parents('li')[0].id); 285 | name = file.name; 286 | parts = /^(.+)(\.[^.]+)$/.exec(name); 287 | if (parts) { 288 | name = parts[1]; 289 | ext = parts[2]; 290 | } 291 | 292 | // Display input element 293 | targetSpan.hide().after(''); 294 | targetSpan.next().val(name).focus().blur(function() { 295 | targetSpan.show().next().remove(); 296 | }).keydown(function(e) { 297 | var targetInput = $(this); 298 | 299 | if (e.keyCode == 13) { 300 | e.preventDefault(); 301 | 302 | // Rename file and glue extension back on 303 | file.name = targetInput.val() + ext; 304 | targetSpan.html(file.name); 305 | targetInput.blur(); 306 | } 307 | }); 308 | }); 309 | } 310 | 311 | $('#' + id + '_container').attr('title', 'Using runtime: ' + res.runtime); 312 | 313 | $('a.plupload_start', target).click(function(e) { 314 | if (!$(this).hasClass('plupload_disabled')) { 315 | uploader.start(); 316 | } 317 | 318 | e.preventDefault(); 319 | }); 320 | 321 | $('a.plupload_stop', target).click(function(e) { 322 | e.preventDefault(); 323 | uploader.stop(); 324 | }); 325 | 326 | $('a.plupload_start', target).addClass('plupload_disabled'); 327 | }); 328 | 329 | uploader.bind("Error", function(up, err) { 330 | var file = err.file, message; 331 | 332 | if (file) { 333 | message = err.message; 334 | 335 | if (err.details) { 336 | message += " (" + err.details + ")"; 337 | } 338 | 339 | if (err.code == plupload.FILE_SIZE_ERROR) { 340 | alert(_("Error: File too large:") + " " + file.name); 341 | } 342 | 343 | if (err.code == plupload.FILE_EXTENSION_ERROR) { 344 | alert(_("Error: Invalid file extension:") + " " + file.name); 345 | } 346 | 347 | file.hint = message; 348 | $('#' + file.id).attr('class', 'plupload_failed').find('a').css('display', 'block').attr('title', message); 349 | } 350 | 351 | if (err.code === plupload.INIT_ERROR) { 352 | setTimeout(function() { 353 | destroy(); 354 | }, 1); 355 | } 356 | }); 357 | 358 | uploader.bind("PostInit", function(up) { 359 | // features are populated only after input components are fully instantiated 360 | if (up.settings.dragdrop && up.features.dragdrop) { 361 | $('#' + id + '_filelist').append('
    • ' + _("Drag files here.") + '
    • '); 362 | } 363 | }); 364 | 365 | uploader.init(); 366 | 367 | uploader.bind('StateChanged', function() { 368 | if (uploader.state === plupload.STARTED) { 369 | $('li.plupload_delete a,div.plupload_buttons', target).hide(); 370 | uploader.disableBrowse(true); 371 | 372 | $('span.plupload_upload_status,div.plupload_progress,a.plupload_stop', target).css('display', 'block'); 373 | $('span.plupload_upload_status', target).html('Uploaded ' + uploader.total.uploaded + '/' + uploader.files.length + ' files'); 374 | 375 | if (settings.multiple_queues) { 376 | $('span.plupload_total_status,span.plupload_total_file_size', target).show(); 377 | } 378 | } else { 379 | updateList(); 380 | $('a.plupload_stop,div.plupload_progress', target).hide(); 381 | $('a.plupload_delete', target).css('display', 'block'); 382 | 383 | if (settings.multiple_queues && uploader.total.uploaded + uploader.total.failed == uploader.files.length) { 384 | $(".plupload_buttons,.plupload_upload_status", target).css("display", "inline"); 385 | uploader.disableBrowse(false); 386 | 387 | $(".plupload_start", target).addClass("plupload_disabled"); 388 | $('span.plupload_total_status,span.plupload_total_file_size', target).hide(); 389 | } 390 | } 391 | }); 392 | 393 | uploader.bind('FilesAdded', updateList); 394 | 395 | uploader.bind('FilesRemoved', function() { 396 | // since the whole file list is redrawn for every change in the queue 397 | // we need to scroll back to the file removal point to avoid annoying 398 | // scrolling to the bottom bug (see #926) 399 | var scrollTop = $('#' + id + '_filelist').scrollTop(); 400 | updateList(); 401 | $('#' + id + '_filelist').scrollTop(scrollTop); 402 | }); 403 | 404 | uploader.bind('FileUploaded', function(up, file) { 405 | handleStatus(file); 406 | }); 407 | 408 | uploader.bind("UploadProgress", function(up, file) { 409 | // Set file specific progress 410 | $('#' + file.id + ' div.plupload_file_status', target).html(file.percent + '%'); 411 | 412 | handleStatus(file); 413 | updateTotalProgress(); 414 | }); 415 | 416 | // Call setup function 417 | if (settings.setup) { 418 | settings.setup(uploader); 419 | } 420 | }); 421 | 422 | return this; 423 | } else { 424 | // Get uploader instance for specified element 425 | return uploaders[$(this[0]).attr('id')]; 426 | } 427 | }; 428 | })(jQuery, mOxie); 429 | -------------------------------------------------------------------------------- /src/main/webapp/static/plupload/js/jquery.ui.plupload/jquery.ui.plupload.js: -------------------------------------------------------------------------------- 1 | /** 2 | * jquery.ui.plupload.js 3 | * 4 | * Copyright 2013, Moxiecode Systems AB 5 | * Released under GPL License. 6 | * 7 | * License: http://www.plupload.com/license 8 | * Contributing: http://www.plupload.com/contributing 9 | * 10 | * Depends: 11 | * jquery.ui.core.js 12 | * jquery.ui.widget.js 13 | * jquery.ui.button.js 14 | * jquery.ui.progressbar.js 15 | * 16 | * Optionally: 17 | * jquery.ui.sortable.js 18 | */ 19 | 20 | /* global jQuery:true */ 21 | 22 | /** 23 | jQuery UI based implementation of the Plupload API - multi-runtime file uploading API. 24 | 25 | To use the widget you must include _jQuery_ and _jQuery UI_ bundle (including `ui.core`, `ui.widget`, `ui.button`, 26 | `ui.progressbar` and `ui.sortable`). 27 | 28 | In general the widget is designed the way that you do not usually need to do anything to it after you instantiate it. 29 | But! You still can intervenue, to some extent, in case you need to. Although, due to the fact that widget is based on 30 | _jQuery UI_ widget factory, there are some specifics. See examples below for more details. 31 | 32 | @example 33 | 34 |
      35 |

      Your browser doesn't have Flash, Silverlight or HTML5 support.

      36 |
      37 | 38 | 50 | 51 | @example 52 | // Invoking methods: 53 | $('#uploader').plupload(options); 54 | 55 | // Display welcome message in the notification area 56 | $('#uploader').plupload('notify', 'info', "This might be obvious, but you need to click 'Add Files' to add some files."); 57 | 58 | @example 59 | // Subscribing to the events... 60 | // ... on initialization: 61 | $('#uploader').plupload({ 62 | ... 63 | viewchanged: function(event, args) { 64 | // stuff ... 65 | } 66 | }); 67 | // ... or after initialization 68 | $('#uploader').on("viewchanged", function(event, args) { 69 | // stuff ... 70 | }); 71 | 72 | @class UI.Plupload 73 | @constructor 74 | @param {Object} settings For detailed information about each option check documentation. 75 | @param {String} settings.url URL of the server-side upload handler. 76 | @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. 77 | @param {String} [settings.file_data_name="file"] Name for the file field in Multipart formated message. 78 | @param {Object} [settings.filters={}] Set of file type filters. 79 | @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` 80 | @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`. 81 | @param {Boolean} [settings.filters.prevent_duplicates=false] Do not let duplicates into the queue. Dispatches `plupload.FILE_DUPLICATE_ERROR`. 82 | @param {Number} [settings.filters.max_file_count=0] Limit the number of files that can reside in the queue at the same time (default is 0 - no limit). 83 | @param {String} [settings.flash_swf_url] URL of the Flash swf. 84 | @param {Object} [settings.headers] Custom headers to send with the upload. Hash of name/value pairs. 85 | @param {Number|String} [settings.max_file_size] 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`. 86 | @param {Number} [settings.max_retries=0] How many times to retry the chunk or file, before triggering Error event. 87 | @param {Boolean} [settings.multipart=true] Whether to send file and additional parameters as Multipart formated message. 88 | @param {Object} [settings.multipart_params] Hash of key/value pairs to send with every file upload. 89 | @param {Boolean} [settings.multi_selection=true] Enable ability to select multiple files at once in file dialog. 90 | @param {Boolean} [settings.prevent_duplicates=false] Do not let duplicates into the queue. Dispatches `plupload.FILE_DUPLICATE_ERROR`. 91 | @param {String|Object} [settings.required_features] Either comma-separated list or hash of required features that chosen runtime should absolutely possess. 92 | @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}` 93 | @param {Number} [settings.resize.width] If image is bigger, it will be resized. 94 | @param {Number} [settings.resize.height] If image is bigger, it will be resized. 95 | @param {Number} [settings.resize.quality=90] Compression quality for jpegs (1-100). 96 | @param {Boolean} [settings.resize.crop=false] Whether to crop images to exact dimensions. By default they will be resized proportionally. 97 | @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. 98 | @param {String} [settings.silverlight_xap_url] URL of the Silverlight xap. 99 | @param {Boolean} [settings.unique_names=false] If true will generate unique filenames for uploaded files. 100 | 101 | @param {Boolean} [settings.autostart=false] Whether to auto start uploading right after file selection. 102 | @param {Boolean} [settings.dragdrop=true] Enable ability to add file to the queue by drag'n'dropping them from the desktop. 103 | @param {Boolean} [settings.rename=false] Enable ability to rename files in the queue. 104 | @param {Boolean} [settings.sortable=false] Enable ability to sort files in the queue, changing their uploading priority. 105 | @param {Object} [settings.buttons] Control the visibility of functional buttons. 106 | @param {Boolean} [settings.buttons.browse=true] Display browse button. 107 | @param {Boolean} [settings.buttons.start=true] Display start button. 108 | @param {Boolean} [settings.buttons.stop=true] Display stop button. 109 | @param {Object} [settings.views] Control various views of the file queue. 110 | @param {Boolean} [settings.views.list=true] Enable list view. 111 | @param {Boolean} [settings.views.thumbs=false] Enable thumbs view. 112 | @param {String} [settings.views.default='list'] Default view. 113 | @param {Boolean} [settings.views.remember=true] Whether to remember the current view (requires jQuery Cookie plugin). 114 | @param {Boolean} [settings.multiple_queues=true] Re-activate the widget after each upload procedure. 115 | */ 116 | ;(function(window, document, plupload, o, $) { 117 | 118 | /** 119 | Dispatched when the widget is initialized and ready. 120 | 121 | @event ready 122 | @param {plupload.Uploader} uploader Uploader instance sending the event. 123 | */ 124 | 125 | /** 126 | Dispatched when file dialog is closed. 127 | 128 | @event selected 129 | @param {plupload.Uploader} uploader Uploader instance sending the event. 130 | @param {Array} files Array of selected files represented by plupload.File objects 131 | */ 132 | 133 | /** 134 | Dispatched when file dialog is closed. 135 | 136 | @event removed 137 | @param {plupload.Uploader} uploader Uploader instance sending the event. 138 | @param {Array} files Array of removed files represented by plupload.File objects 139 | */ 140 | 141 | /** 142 | Dispatched when upload is started. 143 | 144 | @event start 145 | @param {plupload.Uploader} uploader Uploader instance sending the event. 146 | */ 147 | 148 | /** 149 | Dispatched when upload is stopped. 150 | 151 | @event stop 152 | @param {plupload.Uploader} uploader Uploader instance sending the event. 153 | */ 154 | 155 | /** 156 | Dispatched during the upload process. 157 | 158 | @event progress 159 | @param {plupload.Uploader} uploader Uploader instance sending the event. 160 | @param {plupload.File} file File that is being uploaded (includes loaded and percent properties among others). 161 | @param {Number} size Total file size in bytes. 162 | @param {Number} loaded Number of bytes uploaded of the files total size. 163 | @param {Number} percent Number of percentage uploaded of the file. 164 | */ 165 | 166 | /** 167 | Dispatched when file is uploaded. 168 | 169 | @event uploaded 170 | @param {plupload.Uploader} uploader Uploader instance sending the event. 171 | @param {plupload.File} file File that was uploaded. 172 | @param {Enum} status Status constant matching the plupload states QUEUED, UPLOADING, FAILED, DONE. 173 | */ 174 | 175 | /** 176 | Dispatched when upload of the whole queue is complete. 177 | 178 | @event complete 179 | @param {plupload.Uploader} uploader Uploader instance sending the event. 180 | @param {Array} files Array of uploaded files represented by plupload.File objects 181 | */ 182 | 183 | /** 184 | Dispatched when the view is changed, e.g. from `list` to `thumbs` or vice versa. 185 | 186 | @event viewchanged 187 | @param {plupload.Uploader} uploader Uploader instance sending the event. 188 | @param {String} type Current view type. 189 | */ 190 | 191 | /** 192 | Dispatched when error of some kind is detected. 193 | 194 | @event error 195 | @param {plupload.Uploader} uploader Uploader instance sending the event. 196 | @param {String} error Error message. 197 | @param {plupload.File} file File that was uploaded. 198 | @param {Enum} status Status constant matching the plupload states QUEUED, UPLOADING, FAILED, DONE. 199 | */ 200 | 201 | var uploaders = {}; 202 | 203 | function _(str) { 204 | return plupload.translate(str) || str; 205 | } 206 | 207 | function renderUI(obj) { 208 | obj.id = obj.attr('id'); 209 | 210 | obj.html( 211 | '
      ' + 212 | '
      ' + 213 | '
      ' + 214 | '
      ' + 215 | '' + 216 | '
      ' + _("Select files") + '
      ' + 217 | '
      ' + _("Add files to the upload queue and click the start button.") + '
      ' + 218 | '
      ' + 219 | '' + 220 | '' + 221 | '
      ' + 222 | '
      ' + 223 | '
      ' + 224 | 225 | '' + 226 | '' + 227 | '' + 228 | '' + 229 | '' + 230 | '' + 231 | '' + 232 | '
      ' + _('Filename') + '' + _('Status') + '' + _('Size') + ' 
      ' + 233 | 234 | '
      ' + 235 | '
      ' + _("Drag files here.") + '
      ' + 236 | '
      ' + 237 | '
       
      ' + 238 | '
      ' + 239 | 240 | '' + 241 | '' + 242 | '' + 259 | '' + 260 | '' + 261 | '' + 262 | '' + 263 | '' + 264 | 265 | '
      ' + 266 | '' + 267 | '
      ' 268 | ); 269 | } 270 | 271 | 272 | $.widget("ui.plupload", { 273 | 274 | widgetEventPrefix: '', 275 | 276 | contents_bak: '', 277 | 278 | options: { 279 | browse_button_hover: 'ui-state-hover', 280 | browse_button_active: 'ui-state-active', 281 | 282 | filters: {}, 283 | 284 | // widget specific 285 | buttons: { 286 | browse: true, 287 | start: true, 288 | stop: true 289 | }, 290 | 291 | views: { 292 | list: true, 293 | thumbs: false, 294 | active: 'list', 295 | remember: true // requires: https://github.com/carhartl/jquery-cookie, otherwise disabled even if set to true 296 | }, 297 | 298 | thumb_width: 100, 299 | thumb_height: 60, 300 | 301 | multiple_queues: true, // re-use widget by default 302 | dragdrop : true, 303 | autostart: false, 304 | sortable: false, 305 | rename: false 306 | }, 307 | 308 | FILE_COUNT_ERROR: -9001, 309 | 310 | _create: function() { 311 | var id = this.element.attr('id'); 312 | if (!id) { 313 | id = plupload.guid(); 314 | this.element.attr('id', id); 315 | } 316 | this.id = id; 317 | 318 | // backup the elements initial state 319 | this.contents_bak = this.element.html(); 320 | renderUI(this.element); 321 | 322 | // container, just in case 323 | this.container = $('.plupload_container', this.element).attr('id', id + '_container'); 324 | 325 | this.content = $('.plupload_content', this.element); 326 | 327 | if ($.fn.resizable) { 328 | this.container.resizable({ 329 | handles: 's', 330 | minHeight: 300 331 | }); 332 | } 333 | 334 | // list of files, may become sortable 335 | this.filelist = $('.plupload_filelist_content', this.container) 336 | .attr({ 337 | id: id + '_filelist', 338 | unselectable: 'on' 339 | }); 340 | 341 | 342 | // buttons 343 | this.browse_button = $('.plupload_add', this.container).attr('id', id + '_browse'); 344 | this.start_button = $('.plupload_start', this.container).attr('id', id + '_start'); 345 | this.stop_button = $('.plupload_stop', this.container).attr('id', id + '_stop'); 346 | this.thumbs_switcher = $('#' + id + '_view_thumbs'); 347 | this.list_switcher = $('#' + id + '_view_list'); 348 | 349 | if ($.ui.button) { 350 | this.browse_button.button({ 351 | icons: { primary: 'ui-icon-circle-plus' }, 352 | disabled: true 353 | }); 354 | 355 | this.start_button.button({ 356 | icons: { primary: 'ui-icon-circle-arrow-e' }, 357 | disabled: true 358 | }); 359 | 360 | this.stop_button.button({ 361 | icons: { primary: 'ui-icon-circle-close' } 362 | }); 363 | 364 | this.list_switcher.button({ 365 | text: false, 366 | icons: { secondary: "ui-icon-grip-dotted-horizontal" } 367 | }); 368 | 369 | this.thumbs_switcher.button({ 370 | text: false, 371 | icons: { secondary: "ui-icon-image" } 372 | }); 373 | } 374 | 375 | // progressbar 376 | this.progressbar = $('.plupload_progress_container', this.container); 377 | 378 | if ($.ui.progressbar) { 379 | this.progressbar.progressbar(); 380 | } 381 | 382 | // counter 383 | this.counter = $('.plupload_count', this.element) 384 | .attr({ 385 | id: id + '_count', 386 | name: id + '_count' 387 | }); 388 | 389 | // initialize uploader instance 390 | this._initUploader(); 391 | }, 392 | 393 | _initUploader: function() { 394 | var self = this 395 | , id = this.id 396 | , uploader 397 | , options = { 398 | container: id + '_buttons', 399 | browse_button: id + '_browse' 400 | } 401 | ; 402 | 403 | $('.plupload_buttons', this.element).attr('id', id + '_buttons'); 404 | 405 | if (self.options.dragdrop) { 406 | this.filelist.parent().attr('id', this.id + '_dropbox'); 407 | options.drop_element = this.id + '_dropbox'; 408 | } 409 | 410 | this.filelist.on('click', function(e) { 411 | if ($(e.target).hasClass('plupload_action_icon')) { 412 | self.removeFile($(e.target).closest('.plupload_file').attr('id')); 413 | e.preventDefault(); 414 | } 415 | }); 416 | 417 | uploader = this.uploader = uploaders[id] = new plupload.Uploader($.extend(this.options, options)); 418 | 419 | if (self.options.views.thumbs) { 420 | uploader.settings.required_features.display_media = true; 421 | } 422 | 423 | // for backward compatibility 424 | if (self.options.max_file_count) { 425 | plupload.extend(uploader.getOption('filters'), { 426 | max_file_count: self.options.max_file_count 427 | }); 428 | } 429 | 430 | plupload.addFileFilter('max_file_count', function(maxCount, file, cb) { 431 | if (maxCount <= this.files.length - (this.total.uploaded + this.total.failed)) { 432 | self.browse_button.button('disable'); 433 | this.disableBrowse(); 434 | 435 | this.trigger('Error', { 436 | code : self.FILE_COUNT_ERROR, 437 | message : _("File count error."), 438 | file : file 439 | }); 440 | cb(false); 441 | } else { 442 | cb(true); 443 | } 444 | }); 445 | 446 | 447 | uploader.bind('Error', function(up, err) { 448 | var message, details = ""; 449 | 450 | message = '' + err.message + ''; 451 | 452 | switch (err.code) { 453 | case plupload.FILE_EXTENSION_ERROR: 454 | details = o.sprintf(_("File: %s"), err.file.name); 455 | break; 456 | 457 | case plupload.FILE_SIZE_ERROR: 458 | details = o.sprintf(_("File: %s, size: %d, max file size: %d"), err.file.name, plupload.formatSize(err.file.size), plupload.formatSize(plupload.parseSize(up.getOption('filters').max_file_size))); 459 | break; 460 | 461 | case plupload.FILE_DUPLICATE_ERROR: 462 | details = o.sprintf(_("%s already present in the queue."), err.file.name); 463 | break; 464 | 465 | case self.FILE_COUNT_ERROR: 466 | details = o.sprintf(_("Upload element accepts only %d file(s) at a time. Extra files were stripped."), up.getOption('filters').max_file_count || 0); 467 | break; 468 | 469 | case plupload.IMAGE_FORMAT_ERROR : 470 | details = _("Image format either wrong or not supported."); 471 | break; 472 | 473 | case plupload.IMAGE_MEMORY_ERROR : 474 | details = _("Runtime ran out of available memory."); 475 | break; 476 | 477 | /* // This needs a review 478 | case plupload.IMAGE_DIMENSIONS_ERROR : 479 | details = o.sprintf(_('Resoultion out of boundaries! %s runtime supports images only up to %wx%hpx.'), up.runtime, up.features.maxWidth, up.features.maxHeight); 480 | break; */ 481 | 482 | case plupload.HTTP_ERROR: 483 | details = _("Upload URL might be wrong or doesn't exist."); 484 | break; 485 | } 486 | 487 | message += "
      " + details + ""; 488 | 489 | self._trigger('error', null, { up: up, error: err } ); 490 | 491 | // do not show UI if no runtime can be initialized 492 | if (err.code === plupload.INIT_ERROR) { 493 | setTimeout(function() { 494 | self.destroy(); 495 | }, 1); 496 | } else { 497 | self.notify('error', message); 498 | } 499 | }); 500 | 501 | 502 | uploader.bind('PostInit', function(up) { 503 | // all buttons are optional, so they can be disabled and hidden 504 | if (!self.options.buttons.browse) { 505 | self.browse_button.button('disable').hide(); 506 | up.disableBrowse(true); 507 | } else { 508 | self.browse_button.button('enable'); 509 | } 510 | 511 | if (!self.options.buttons.start) { 512 | self.start_button.button('disable').hide(); 513 | } 514 | 515 | if (!self.options.buttons.stop) { 516 | self.stop_button.button('disable').hide(); 517 | } 518 | 519 | if (!self.options.unique_names && self.options.rename) { 520 | self._enableRenaming(); 521 | } 522 | 523 | if (self.options.dragdrop && up.features.dragdrop) { 524 | self.filelist.parent().addClass('plupload_dropbox'); 525 | } 526 | 527 | self._enableViewSwitcher(); 528 | 529 | self.start_button.click(function(e) { 530 | if (!$(this).button('option', 'disabled')) { 531 | self.start(); 532 | } 533 | e.preventDefault(); 534 | }); 535 | 536 | self.stop_button.click(function(e) { 537 | self.stop(); 538 | e.preventDefault(); 539 | }); 540 | 541 | self._trigger('ready', null, { up: up }); 542 | }); 543 | 544 | // uploader internal events must run first 545 | uploader.init(); 546 | 547 | uploader.bind('FileFiltered', function(up, file) { 548 | self._addFiles(file); 549 | }); 550 | 551 | uploader.bind('FilesAdded', function(up, files) { 552 | self._trigger('selected', null, { up: up, files: files } ); 553 | 554 | // re-enable sortable 555 | if (self.options.sortable && $.ui.sortable) { 556 | self._enableSortingList(); 557 | } 558 | 559 | self._trigger('updatelist', null, { filelist: self.filelist }); 560 | 561 | if (self.options.autostart) { 562 | // set a little delay to make sure that QueueChanged triggered by the core has time to complete 563 | setTimeout(function() { 564 | self.start(); 565 | }, 10); 566 | } 567 | }); 568 | 569 | uploader.bind('FilesRemoved', function(up, files) { 570 | // destroy sortable if enabled 571 | if ($.ui.sortable && self.options.sortable) { 572 | $('tbody', self.filelist).sortable('destroy'); 573 | } 574 | 575 | $.each(files, function(i, file) { 576 | $('#' + file.id).toggle("highlight", function() { 577 | $(this).remove(); 578 | }); 579 | }); 580 | 581 | if (up.files.length) { 582 | // re-initialize sortable 583 | if (self.options.sortable && $.ui.sortable) { 584 | self._enableSortingList(); 585 | } 586 | } 587 | 588 | self._trigger('updatelist', null, { filelist: self.filelist }); 589 | self._trigger('removed', null, { up: up, files: files } ); 590 | }); 591 | 592 | uploader.bind('QueueChanged StateChanged', function() { 593 | self._handleState(); 594 | }); 595 | 596 | uploader.bind('UploadFile', function(up, file) { 597 | self._handleFileStatus(file); 598 | }); 599 | 600 | uploader.bind('FileUploaded', function(up, file) { 601 | self._handleFileStatus(file); 602 | self._trigger('uploaded', null, { up: up, file: file } ); 603 | }); 604 | 605 | uploader.bind('UploadProgress', function(up, file) { 606 | self._handleFileStatus(file); 607 | self._updateTotalProgress(); 608 | self._trigger('progress', null, { up: up, file: file } ); 609 | }); 610 | 611 | uploader.bind('UploadComplete', function(up, files) { 612 | self._addFormFields(); 613 | self._trigger('complete', null, { up: up, files: files } ); 614 | }); 615 | }, 616 | 617 | 618 | _setOption: function(key, value) { 619 | var self = this; 620 | 621 | if (key == 'buttons' && typeof(value) == 'object') { 622 | value = $.extend(self.options.buttons, value); 623 | 624 | if (!value.browse) { 625 | self.browse_button.button('disable').hide(); 626 | self.uploader.disableBrowse(true); 627 | } else { 628 | self.browse_button.button('enable').show(); 629 | self.uploader.disableBrowse(false); 630 | } 631 | 632 | if (!value.start) { 633 | self.start_button.button('disable').hide(); 634 | } else { 635 | self.start_button.button('enable').show(); 636 | } 637 | 638 | if (!value.stop) { 639 | self.stop_button.button('disable').hide(); 640 | } else { 641 | self.start_button.button('enable').show(); 642 | } 643 | } 644 | 645 | self.uploader.settings[key] = value; 646 | }, 647 | 648 | 649 | /** 650 | Start upload. Triggers `start` event. 651 | 652 | @method start 653 | */ 654 | start: function() { 655 | this.uploader.start(); 656 | this._trigger('start', null, { up: this.uploader }); 657 | }, 658 | 659 | 660 | /** 661 | Stop upload. Triggers `stop` event. 662 | 663 | @method stop 664 | */ 665 | stop: function() { 666 | this.uploader.stop(); 667 | this._trigger('stop', null, { up: this.uploader }); 668 | }, 669 | 670 | 671 | /** 672 | Enable browse button. 673 | 674 | @method enable 675 | */ 676 | enable: function() { 677 | this.browse_button.button('enable'); 678 | this.uploader.disableBrowse(false); 679 | }, 680 | 681 | 682 | /** 683 | Disable browse button. 684 | 685 | @method disable 686 | */ 687 | disable: function() { 688 | this.browse_button.button('disable'); 689 | this.uploader.disableBrowse(true); 690 | }, 691 | 692 | 693 | /** 694 | Retrieve file by it's unique id. 695 | 696 | @method getFile 697 | @param {String} id Unique id of the file 698 | @return {plupload.File} 699 | */ 700 | getFile: function(id) { 701 | var file; 702 | 703 | if (typeof id === 'number') { 704 | file = this.uploader.files[id]; 705 | } else { 706 | file = this.uploader.getFile(id); 707 | } 708 | return file; 709 | }, 710 | 711 | /** 712 | Return array of files currently in the queue. 713 | 714 | @method getFiles 715 | @return {Array} Array of files in the queue represented by plupload.File objects 716 | */ 717 | getFiles: function() { 718 | return this.uploader.files; 719 | }, 720 | 721 | 722 | /** 723 | Remove the file from the queue. 724 | 725 | @method removeFile 726 | @param {plupload.File|String} file File to remove, might be specified directly or by it's unique id 727 | */ 728 | removeFile: function(file) { 729 | if (plupload.typeOf(file) === 'string') { 730 | file = this.getFile(file); 731 | } 732 | this.uploader.removeFile(file); 733 | }, 734 | 735 | 736 | /** 737 | Clear the file queue. 738 | 739 | @method clearQueue 740 | */ 741 | clearQueue: function() { 742 | this.uploader.splice(); 743 | }, 744 | 745 | 746 | /** 747 | Retrieve internal plupload.Uploader object (usually not required). 748 | 749 | @method getUploader 750 | @return {plupload.Uploader} 751 | */ 752 | getUploader: function() { 753 | return this.uploader; 754 | }, 755 | 756 | 757 | /** 758 | Trigger refresh procedure, specifically browse_button re-measure and re-position operations. 759 | Might get handy, when UI Widget is placed within the popup, that is constantly hidden and shown 760 | again - without calling this method after each show operation, dialog trigger might get displaced 761 | and disfunctional. 762 | 763 | @method refresh 764 | */ 765 | refresh: function() { 766 | this.uploader.refresh(); 767 | }, 768 | 769 | 770 | /** 771 | Display a message in notification area. 772 | 773 | @method notify 774 | @param {Enum} type Type of the message, either `error` or `info` 775 | @param {String} message The text message to display. 776 | */ 777 | notify: function(type, message) { 778 | var popup = $( 779 | '
      ' + 780 | '' + 781 | '

      ' + message + '

      ' + 782 | '
      ' 783 | ); 784 | 785 | popup 786 | .addClass('ui-state-' + (type === 'error' ? 'error' : 'highlight')) 787 | .find('p .ui-icon') 788 | .addClass('ui-icon-' + (type === 'error' ? 'alert' : 'info')) 789 | .end() 790 | .find('.plupload_message_close') 791 | .click(function() { 792 | popup.remove(); 793 | }) 794 | .end(); 795 | 796 | $('.plupload_header', this.container).append(popup); 797 | }, 798 | 799 | 800 | /** 801 | Destroy the widget, the uploader, free associated resources and bring back original html. 802 | 803 | @method destroy 804 | */ 805 | destroy: function() { 806 | // destroy uploader instance 807 | this.uploader.destroy(); 808 | 809 | // unbind all button events 810 | $('.plupload_button', this.element).unbind(); 811 | 812 | // destroy buttons 813 | if ($.ui.button) { 814 | $('.plupload_add, .plupload_start, .plupload_stop', this.container) 815 | .button('destroy'); 816 | } 817 | 818 | // destroy progressbar 819 | if ($.ui.progressbar) { 820 | this.progressbar.progressbar('destroy'); 821 | } 822 | 823 | // destroy sortable behavior 824 | if ($.ui.sortable && this.options.sortable) { 825 | $('tbody', this.filelist).sortable('destroy'); 826 | } 827 | 828 | // restore the elements initial state 829 | this.element 830 | .empty() 831 | .html(this.contents_bak); 832 | this.contents_bak = ''; 833 | 834 | $.Widget.prototype.destroy.apply(this); 835 | }, 836 | 837 | 838 | _handleState: function() { 839 | var up = this.uploader 840 | , filesPending = up.files.length - (up.total.uploaded + up.total.failed) 841 | , maxCount = up.getOption('filters').max_file_count || 0 842 | ; 843 | 844 | if (plupload.STARTED === up.state) { 845 | $([]) 846 | .add(this.stop_button) 847 | .add('.plupload_started') 848 | .removeClass('plupload_hidden'); 849 | 850 | this.start_button.button('disable'); 851 | 852 | if (!this.options.multiple_queues) { 853 | this.browse_button.button('disable'); 854 | up.disableBrowse(); 855 | } 856 | 857 | $('.plupload_upload_status', this.element).html(o.sprintf(_('Uploaded %d/%d files'), up.total.uploaded, up.files.length)); 858 | $('.plupload_header_content', this.element).addClass('plupload_header_content_bw'); 859 | } 860 | else if (plupload.STOPPED === up.state) { 861 | $([]) 862 | .add(this.stop_button) 863 | .add('.plupload_started') 864 | .addClass('plupload_hidden'); 865 | 866 | if (filesPending) { 867 | this.start_button.button('enable'); 868 | } else { 869 | this.start_button.button('disable'); 870 | } 871 | 872 | if (this.options.multiple_queues) { 873 | $('.plupload_header_content', this.element).removeClass('plupload_header_content_bw'); 874 | } 875 | 876 | // if max_file_count defined, only that many files can be queued at once 877 | if (this.options.multiple_queues && maxCount && maxCount > filesPending) { 878 | this.browse_button.button('enable'); 879 | up.disableBrowse(false); 880 | } 881 | 882 | this._updateTotalProgress(); 883 | } 884 | 885 | if (up.total.queued === 0) { 886 | $('.ui-button-text', this.browse_button).html(_('Add Files')); 887 | } else { 888 | $('.ui-button-text', this.browse_button).html(o.sprintf(_('%d files queued'), up.total.queued)); 889 | } 890 | 891 | up.refresh(); 892 | }, 893 | 894 | 895 | _handleFileStatus: function(file) { 896 | var $file = $('#' + file.id), actionClass, iconClass; 897 | 898 | // since this method might be called asynchronously, file row might not yet be rendered 899 | if (!$file.length) { 900 | return; 901 | } 902 | 903 | switch (file.status) { 904 | case plupload.DONE: 905 | actionClass = 'plupload_done'; 906 | iconClass = 'plupload_action_icon ui-icon ui-icon-circle-check'; 907 | break; 908 | 909 | case plupload.FAILED: 910 | actionClass = 'ui-state-error plupload_failed'; 911 | iconClass = 'plupload_action_icon ui-icon ui-icon-alert'; 912 | break; 913 | 914 | case plupload.QUEUED: 915 | actionClass = 'plupload_delete'; 916 | iconClass = 'plupload_action_icon ui-icon ui-icon-circle-minus'; 917 | break; 918 | 919 | case plupload.UPLOADING: 920 | actionClass = 'ui-state-highlight plupload_uploading'; 921 | iconClass = 'plupload_action_icon ui-icon ui-icon-circle-arrow-w'; 922 | 923 | // scroll uploading file into the view if its bottom boundary is out of it 924 | var scroller = $('.plupload_scroll', this.container) 925 | , scrollTop = scroller.scrollTop() 926 | , scrollerHeight = scroller.height() 927 | , rowOffset = $file.position().top + $file.height() 928 | ; 929 | 930 | if (scrollerHeight < rowOffset) { 931 | scroller.scrollTop(scrollTop + rowOffset - scrollerHeight); 932 | } 933 | 934 | // Set file specific progress 935 | $file 936 | .find('.plupload_file_percent') 937 | .html(file.percent + '%') 938 | .end() 939 | .find('.plupload_file_progress') 940 | .css('width', file.percent + '%') 941 | .end() 942 | .find('.plupload_file_size') 943 | .html(plupload.formatSize(file.size)); 944 | break; 945 | } 946 | actionClass += ' ui-state-default plupload_file'; 947 | 948 | $file 949 | .attr('class', actionClass) 950 | .find('.plupload_action_icon') 951 | .attr('class', iconClass); 952 | }, 953 | 954 | 955 | _updateTotalProgress: function() { 956 | var up = this.uploader; 957 | 958 | // Scroll to end of file list 959 | this.filelist[0].scrollTop = this.filelist[0].scrollHeight; 960 | 961 | this.progressbar.progressbar('value', up.total.percent); 962 | 963 | this.element 964 | .find('.plupload_total_status') 965 | .html(up.total.percent + '%') 966 | .end() 967 | .find('.plupload_total_file_size') 968 | .html(plupload.formatSize(up.total.size)) 969 | .end() 970 | .find('.plupload_upload_status') 971 | .html(o.sprintf(_('Uploaded %d/%d files'), up.total.uploaded, up.files.length)); 972 | }, 973 | 974 | 975 | _displayThumbs: function() { 976 | var self = this 977 | , tw, th // thumb width/height 978 | , cols 979 | , num = 0 // number of simultaneously visible thumbs 980 | , thumbs = [] // array of thumbs to preload at any given moment 981 | , loading = false 982 | ; 983 | 984 | if (!this.options.views.thumbs) { 985 | return; 986 | } 987 | 988 | 989 | function onLast(el, eventName, cb) { 990 | var timer; 991 | 992 | el.on(eventName, function() { 993 | clearTimeout(timer); 994 | timer = setTimeout(function() { 995 | clearTimeout(timer); 996 | cb(); 997 | }, 300); 998 | }); 999 | } 1000 | 1001 | 1002 | // calculate number of simultaneously visible thumbs 1003 | function measure() { 1004 | if (!tw || !th) { 1005 | var wrapper = $('.plupload_file:eq(0)', self.filelist); 1006 | tw = wrapper.outerWidth(true); 1007 | th = wrapper.outerHeight(true); 1008 | } 1009 | 1010 | var aw = self.content.width(), ah = self.content.height(); 1011 | cols = Math.floor(aw / tw); 1012 | num = cols * (Math.ceil(ah / th) + 1); 1013 | } 1014 | 1015 | 1016 | function pickThumbsToLoad() { 1017 | // calculate index of virst visible thumb 1018 | var startIdx = Math.floor(self.content.scrollTop() / th) * cols; 1019 | // get potentially visible thumbs that are not yet visible 1020 | thumbs = $('.plupload_file', self.filelist) 1021 | .slice(startIdx, startIdx + num) 1022 | .filter('.plupload_file_loading') 1023 | .get(); 1024 | } 1025 | 1026 | 1027 | function init() { 1028 | function mpl() { // measure, pick, load 1029 | if (self.view_mode !== 'thumbs') { 1030 | return; 1031 | } 1032 | measure(); 1033 | pickThumbsToLoad(); 1034 | lazyLoad(); 1035 | } 1036 | 1037 | if ($.fn.resizable) { 1038 | onLast(self.container, 'resize', mpl); 1039 | } 1040 | 1041 | onLast(self.window, 'resize', mpl); 1042 | onLast(self.content, 'scroll', mpl); 1043 | 1044 | self.element.on('viewchanged selected', mpl); 1045 | 1046 | mpl(); 1047 | } 1048 | 1049 | 1050 | function preloadThumb(file, cb) { 1051 | var img = new o.Image(); 1052 | 1053 | img.onload = function() { 1054 | var thumb = $('#' + file.id + ' .plupload_file_thumb', self.filelist).html(''); 1055 | this.embed(thumb[0], { 1056 | width:  self.options.thumb_width, 1057 | height: self.options.thumb_height, 1058 | crop: true, 1059 | swf_url: o.resolveUrl(self.options.flash_swf_url), 1060 | xap_url: o.resolveUrl(self.options.silverlight_xap_url) 1061 | }); 1062 | }; 1063 | 1064 | img.bind("embedded error", function() { 1065 | $('#' + file.id, self.filelist).removeClass('plupload_file_loading'); 1066 | this.destroy(); 1067 | setTimeout(cb, 1); // detach, otherwise ui might hang (in SilverLight for example) 1068 | }); 1069 | 1070 | img.load(file.getSource()); 1071 | } 1072 | 1073 | 1074 | function lazyLoad() { 1075 | if (self.view_mode !== 'thumbs' || loading) { 1076 | return; 1077 | } 1078 | 1079 | pickThumbsToLoad(); 1080 | if (!thumbs.length) { 1081 | return; 1082 | } 1083 | 1084 | loading = true; 1085 | 1086 | preloadThumb(self.getFile($(thumbs.shift()).attr('id')), function() { 1087 | loading = false; 1088 | lazyLoad(); 1089 | }); 1090 | } 1091 | 1092 | // this has to run only once to measure structures and bind listeners 1093 | this.element.on('selected', function onselected() { 1094 | self.element.off('selected', onselected); 1095 | init(); 1096 | }); 1097 | }, 1098 | 1099 | 1100 | _addFiles: function(files) { 1101 | var self = this, file_html, html = ''; 1102 | 1103 | file_html = '
    • ' + 1104 | '
      ' + 1105 | '
      %ext%
      ' + 1106 | '
      ' + 1107 | '
      ' + 1108 | '
      ' + 1109 | '%percent% ' + 1110 | '
      ' + 1111 | '
      ' + 1112 | '%name% ' + 1113 | '
      ' + 1114 | '
      ' + 1115 | '
      ' + 1116 | '
      ' + 1117 | '
      %size%
      ' + 1118 | '
      ' + 1119 | '
    • '; 1120 | 1121 | if (plupload.typeOf(files) !== 'array') { 1122 | files = [files]; 1123 | } 1124 | 1125 | $.each(files, function(i, file) { 1126 | var ext = o.Mime.getFileExtension(file.name) || 'none'; 1127 | 1128 | html += file_html.replace(/%(\w+)%/g, function($0, $1) { 1129 | switch ($1) { 1130 | case 'thumb_width': 1131 | case 'thumb_height': 1132 | return self.options[$1]; 1133 | 1134 | case 'size': 1135 | return plupload.formatSize(file.size); 1136 | 1137 | case 'ext': 1138 | return ext; 1139 | 1140 | default: 1141 | return file[$1] || ''; 1142 | } 1143 | }); 1144 | }); 1145 | 1146 | self.filelist.append(html); 1147 | }, 1148 | 1149 | 1150 | _addFormFields: function() { 1151 | var self = this; 1152 | 1153 | // re-add from fresh 1154 | $('.plupload_file_fields', this.filelist).html(''); 1155 | 1156 | plupload.each(this.uploader.files, function(file, count) { 1157 | var fields = '' 1158 | , id = self.id + '_' + count 1159 | ; 1160 | 1161 | if (file.target_name) { 1162 | fields += ''; 1163 | } 1164 | fields += ''; 1165 | fields += ''; 1166 | 1167 | $('#' + file.id).find('.plupload_file_fields').html(fields); 1168 | }); 1169 | 1170 | this.counter.val(this.uploader.files.length); 1171 | }, 1172 | 1173 | 1174 | _viewChanged: function(view) { 1175 | // update or write a new cookie 1176 | if (this.options.views.remember && $.cookie) { 1177 | $.cookie('plupload_ui_view', view, { expires: 7, path: '/' }); 1178 | } 1179 | 1180 | // ugly fix for IE6 - make content area stretchable 1181 | if (o.Env.browser === 'IE' && o.Env.version < 7) { 1182 | this.content.attr('style', 'height:expression(document.getElementById("' + this.id + '_container' + '").clientHeight - ' + (view === 'list' ? 132 : 102) + ')'); 1183 | } 1184 | 1185 | this.container.removeClass('plupload_view_list plupload_view_thumbs').addClass('plupload_view_' + view); 1186 | this.view_mode = view; 1187 | this._trigger('viewchanged', null, { view: view }); 1188 | }, 1189 | 1190 | 1191 | _enableViewSwitcher: function() { 1192 | var self = this 1193 | , view 1194 | , switcher = $('.plupload_view_switch', this.container) 1195 | , buttons 1196 | , button 1197 | ; 1198 | 1199 | plupload.each(['list', 'thumbs'], function(view) { 1200 | if (!self.options.views[view]) { 1201 | switcher.find('[for="' + self.id + '_view_' + view + '"], #'+ self.id +'_view_' + view).remove(); 1202 | } 1203 | }); 1204 | 1205 | // check if any visible left 1206 | buttons = switcher.find('.plupload_button'); 1207 | 1208 | if (buttons.length === 1) { 1209 | switcher.hide(); 1210 | view = buttons.eq(0).data('view'); 1211 | this._viewChanged(view); 1212 | } else if ($.ui.button && buttons.length > 1) { 1213 | if (this.options.views.remember && $.cookie) { 1214 | view = $.cookie('plupload_ui_view'); 1215 | } 1216 | 1217 | // if wierd case, bail out to default 1218 | if (!~plupload.inArray(view, ['list', 'thumbs'])) { 1219 | view = this.options.views.active; 1220 | } 1221 | 1222 | switcher 1223 | .show() 1224 | .buttonset() 1225 | .find('.ui-button') 1226 | .click(function(e) { 1227 | view = $(this).data('view'); 1228 | self._viewChanged(view); 1229 | e.preventDefault(); // avoid auto scrolling to widget in IE and FF (see #850) 1230 | }); 1231 | 1232 | // if view not active - happens when switcher wasn't clicked manually 1233 | button = switcher.find('[for="' + self.id + '_view_'+view+'"]'); 1234 | if (button.length) { 1235 | button.trigger('click'); 1236 | } 1237 | } else { 1238 | switcher.show(); 1239 | this._viewChanged(this.options.views.active); 1240 | } 1241 | 1242 | // initialize thumb viewer if requested 1243 | if (this.options.views.thumbs) { 1244 | this._displayThumbs(); 1245 | } 1246 | }, 1247 | 1248 | 1249 | _enableRenaming: function() { 1250 | var self = this; 1251 | 1252 | this.filelist.dblclick(function(e) { 1253 | var nameSpan = $(e.target), nameInput, file, parts, name, ext = ""; 1254 | 1255 | if (!nameSpan.hasClass('plupload_file_name_wrapper')) { 1256 | return; 1257 | } 1258 | 1259 | // Get file name and split out name and extension 1260 | file = self.uploader.getFile(nameSpan.closest('.plupload_file')[0].id); 1261 | name = file.name; 1262 | parts = /^(.+)(\.[^.]+)$/.exec(name); 1263 | if (parts) { 1264 | name = parts[1]; 1265 | ext = parts[2]; 1266 | } 1267 | 1268 | // Display input element 1269 | nameInput = $('').width(nameSpan.width()).insertAfter(nameSpan.hide()); 1270 | nameInput.val(name).blur(function() { 1271 | nameSpan.show().parent().scrollLeft(0).end().next().remove(); 1272 | }).keydown(function(e) { 1273 | var nameInput = $(this); 1274 | 1275 | if ($.inArray(e.keyCode, [13, 27]) !== -1) { 1276 | e.preventDefault(); 1277 | 1278 | // Rename file and glue extension back on 1279 | if (e.keyCode === 13) { 1280 | file.name = nameInput.val() + ext; 1281 | nameSpan.html(file.name); 1282 | } 1283 | nameInput.blur(); 1284 | } 1285 | })[0].focus(); 1286 | }); 1287 | }, 1288 | 1289 | 1290 | _enableSortingList: function() { 1291 | var self = this; 1292 | 1293 | if ($('.plupload_file', this.filelist).length < 2) { 1294 | return; 1295 | } 1296 | 1297 | // destroy sortable if enabled 1298 | $('tbody', this.filelist).sortable('destroy'); 1299 | 1300 | // enable 1301 | this.filelist.sortable({ 1302 | items: '.plupload_delete', 1303 | 1304 | cancel: 'object, .plupload_clearer', 1305 | 1306 | stop: function() { 1307 | var files = []; 1308 | 1309 | $.each($(this).sortable('toArray'), function(i, id) { 1310 | files[files.length] = self.uploader.getFile(id); 1311 | }); 1312 | 1313 | files.unshift(files.length); 1314 | files.unshift(0); 1315 | 1316 | // re-populate files array 1317 | Array.prototype.splice.apply(self.uploader.files, files); 1318 | } 1319 | }); 1320 | } 1321 | }); 1322 | 1323 | } (window, document, plupload, mOxie, jQuery)); 1324 | -------------------------------------------------------------------------------- /src/main/webapp/static/plupload/js/moxie.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * mOxie - multi-runtime File API & XMLHttpRequest L2 Polyfill 3 | * v1.2.1 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: 2014-05-14 12 | */ 13 | !function(e,t){"use strict";function n(e,t){for(var n,i=[],r=0;r0&&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){++rn;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;ti;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;ni;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(!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;n0?2==c.length?t[c[0]]=typeof c[1]==i?c[1].call(this,d):c[1]:3==c.length?t[c[0]]=typeof c[1]!==i||c[1].exec&&c[1].test?d?d.replace(c[1],c[2]):e: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=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>16&255,o=d>>8&255,a=255&d,m[h++]=64==c?String.fromCharCode(r):64==l?String.fromCharCode(r,o):String.fromCharCode(r,o,a);while(f>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(fa;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='',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='",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=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&&(h.responseType="json"!==n.responseType||u.can("return_response_type","json")?n.responseType:"text"),m?h.sendAsBinary?h.sendAsBinary(r):!function(){for(var e=new Uint8Array(r.length),t=0;ta;a++)i|=o.charCodeAt(e+a)<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,g[s]=l.hasOwnProperty(s)&&"object"!=typeof p?l[s][p]: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",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 15 | },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=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;ng;){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='',"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=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='',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(et,[Q,u,V],function(e,t,n){return e.Blob=t.extend({},n)}),i(tt,[Q],function(e){var t={init:function(e){function t(e){for(var t="",n=0;no;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(ut,[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(ct,[ut,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(lt,[ut,F],function(e,t){return e.FileReader=t}),i(dt,[ut,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='',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*]*>/,"").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(ft,[ut,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); --------------------------------------------------------------------------------