mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 15:38:15 +00:00
Rewrite file upload
This commit is contained in:
75
media/cors/postmessage.html
Normal file
75
media/cors/postmessage.html
Normal file
@@ -0,0 +1,75 @@
|
||||
<!DOCTYPE HTML>
|
||||
<!--
|
||||
/*
|
||||
* jQuery File Upload Plugin postMessage API 1.1.1
|
||||
* https://github.com/blueimp/jQuery-File-Upload
|
||||
*
|
||||
* Copyright 2011, Sebastian Tschan
|
||||
* https://blueimp.net
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* http://www.opensource.org/licenses/MIT
|
||||
*/
|
||||
-->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>jQuery File Upload Plugin postMessage API</title>
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
/*jslint unparam: true, regexp: true */
|
||||
/*global $, Blob, FormData, location */
|
||||
'use strict';
|
||||
var origin = /^http:\/\/example.org/,
|
||||
target = new RegExp('^(http(s)?:)?\\/\\/' + location.host + '\\/');
|
||||
$(window).on('message', function (e) {
|
||||
e = e.originalEvent;
|
||||
var s = e.data,
|
||||
xhr = $.ajaxSettings.xhr(),
|
||||
f;
|
||||
if (!origin.test(e.origin)) {
|
||||
throw new Error('Origin "' + e.origin + '" does not match ' + origin);
|
||||
}
|
||||
if (!target.test(e.data.url)) {
|
||||
throw new Error('Target "' + e.data.url + '" does not match ' + target);
|
||||
}
|
||||
$(xhr.upload).on('progress', function (ev) {
|
||||
ev = ev.originalEvent;
|
||||
e.source.postMessage({
|
||||
id: s.id,
|
||||
type: ev.type,
|
||||
timeStamp: ev.timeStamp,
|
||||
lengthComputable: ev.lengthComputable,
|
||||
loaded: ev.loaded,
|
||||
total: ev.total
|
||||
}, e.origin);
|
||||
});
|
||||
s.xhr = function () {
|
||||
return xhr;
|
||||
};
|
||||
if (!(s.data instanceof Blob)) {
|
||||
f = new FormData();
|
||||
$.each(s.data, function (i, v) {
|
||||
f.append(v.name, v.value);
|
||||
});
|
||||
s.data = f;
|
||||
}
|
||||
$.ajax(s).always(function (result, statusText, jqXHR) {
|
||||
if (!jqXHR.done) {
|
||||
jqXHR = result;
|
||||
result = null;
|
||||
}
|
||||
e.source.postMessage({
|
||||
id: s.id,
|
||||
status: jqXHR.status,
|
||||
statusText: statusText,
|
||||
result: result,
|
||||
headers: jqXHR.getAllResponseHeaders()
|
||||
}, e.origin);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
24
media/cors/result.html
Normal file
24
media/cors/result.html
Normal file
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE HTML>
|
||||
<!--
|
||||
/*
|
||||
* jQuery Iframe Transport Plugin Redirect Page 2.0.1
|
||||
* https://github.com/blueimp/jQuery-File-Upload
|
||||
*
|
||||
* Copyright 2010, Sebastian Tschan
|
||||
* https://blueimp.net
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* http://www.opensource.org/licenses/MIT
|
||||
*/
|
||||
-->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>jQuery Iframe Transport Plugin Redirect Page</title>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
document.body.innerText=document.body.textContent=decodeURIComponent(window.location.search.slice(1));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
677
media/css/bootstrap-button.css
vendored
Normal file
677
media/css/bootstrap-button.css
vendored
Normal file
@@ -0,0 +1,677 @@
|
||||
.btn {
|
||||
display: inline-block;
|
||||
*display: inline;
|
||||
padding: 4px 12px;
|
||||
margin-bottom: 0;
|
||||
*margin-left: .3em;
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
color: #333333;
|
||||
text-align: center;
|
||||
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
|
||||
vertical-align: middle;
|
||||
cursor: pointer;
|
||||
background-color: #f5f5f5;
|
||||
*background-color: #e6e6e6;
|
||||
background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
|
||||
background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
|
||||
background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
|
||||
background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);
|
||||
background-repeat: repeat-x;
|
||||
border: 1px solid #cccccc;
|
||||
*border: 0;
|
||||
border-color: #e6e6e6 #e6e6e6 #bfbfbf;
|
||||
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
|
||||
border-bottom-color: #b3b3b3;
|
||||
-webkit-border-radius: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
|
||||
*zoom: 1;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.btn:hover,
|
||||
.btn:focus,
|
||||
.btn:active,
|
||||
.btn.active,
|
||||
.btn.disabled,
|
||||
.btn[disabled] {
|
||||
color: #333333;
|
||||
background-color: #e6e6e6;
|
||||
*background-color: #d9d9d9;
|
||||
}
|
||||
|
||||
.btn:active,
|
||||
.btn.active {
|
||||
background-color: #cccccc \9;
|
||||
}
|
||||
|
||||
.btn:first-child {
|
||||
*margin-left: 0;
|
||||
}
|
||||
|
||||
.btn:hover,
|
||||
.btn:focus {
|
||||
color: #333333;
|
||||
text-decoration: none;
|
||||
background-position: 0 -15px;
|
||||
-webkit-transition: background-position 0.1s linear;
|
||||
-moz-transition: background-position 0.1s linear;
|
||||
-o-transition: background-position 0.1s linear;
|
||||
transition: background-position 0.1s linear;
|
||||
}
|
||||
|
||||
.btn:focus {
|
||||
outline: thin dotted #333;
|
||||
outline: 5px auto -webkit-focus-ring-color;
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
.btn.active,
|
||||
.btn:active {
|
||||
background-image: none;
|
||||
outline: 0;
|
||||
-webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
-moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.btn.disabled,
|
||||
.btn[disabled] {
|
||||
cursor: default;
|
||||
background-image: none;
|
||||
opacity: 0.65;
|
||||
filter: alpha(opacity=65);
|
||||
-webkit-box-shadow: none;
|
||||
-moz-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.btn-large {
|
||||
padding: 11px 19px;
|
||||
font-size: 17.5px;
|
||||
-webkit-border-radius: 6px;
|
||||
-moz-border-radius: 6px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.btn-large [class^="icon-"],
|
||||
.btn-large [class*=" icon-"] {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.btn-small {
|
||||
padding: 2px 10px;
|
||||
font-size: 11.9px;
|
||||
-webkit-border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.btn-small [class^="icon-"],
|
||||
.btn-small [class*=" icon-"] {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.btn-mini [class^="icon-"],
|
||||
.btn-mini [class*=" icon-"] {
|
||||
margin-top: -1px;
|
||||
}
|
||||
|
||||
.btn-mini {
|
||||
padding: 0 6px;
|
||||
font-size: 10.5px;
|
||||
-webkit-border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.btn-block {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding-right: 0;
|
||||
padding-left: 0;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.btn-block + .btn-block {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
input[type="submit"].btn-block,
|
||||
input[type="reset"].btn-block,
|
||||
input[type="button"].btn-block {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.btn-primary.active,
|
||||
.btn-warning.active,
|
||||
.btn-danger.active,
|
||||
.btn-success.active,
|
||||
.btn-info.active,
|
||||
.btn-inverse.active {
|
||||
color: rgba(255, 255, 255, 0.75);
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
color: #ffffff;
|
||||
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
|
||||
background-color: #006dcc;
|
||||
*background-color: #0044cc;
|
||||
background-image: -moz-linear-gradient(top, #0088cc, #0044cc);
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));
|
||||
background-image: -webkit-linear-gradient(top, #0088cc, #0044cc);
|
||||
background-image: -o-linear-gradient(top, #0088cc, #0044cc);
|
||||
background-image: linear-gradient(to bottom, #0088cc, #0044cc);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #0044cc #0044cc #002a80;
|
||||
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0044cc', GradientType=0);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
|
||||
}
|
||||
|
||||
.btn-primary:hover,
|
||||
.btn-primary:focus,
|
||||
.btn-primary:active,
|
||||
.btn-primary.active,
|
||||
.btn-primary.disabled,
|
||||
.btn-primary[disabled] {
|
||||
color: #ffffff;
|
||||
background-color: #0044cc;
|
||||
*background-color: #003bb3;
|
||||
}
|
||||
|
||||
.btn-primary:active,
|
||||
.btn-primary.active {
|
||||
background-color: #003399 \9;
|
||||
}
|
||||
|
||||
.btn-warning {
|
||||
color: #ffffff;
|
||||
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
|
||||
background-color: #faa732;
|
||||
*background-color: #f89406;
|
||||
background-image: -moz-linear-gradient(top, #fbb450, #f89406);
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406));
|
||||
background-image: -webkit-linear-gradient(top, #fbb450, #f89406);
|
||||
background-image: -o-linear-gradient(top, #fbb450, #f89406);
|
||||
background-image: linear-gradient(to bottom, #fbb450, #f89406);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #f89406 #f89406 #ad6704;
|
||||
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
|
||||
}
|
||||
|
||||
.btn-warning:hover,
|
||||
.btn-warning:focus,
|
||||
.btn-warning:active,
|
||||
.btn-warning.active,
|
||||
.btn-warning.disabled,
|
||||
.btn-warning[disabled] {
|
||||
color: #ffffff;
|
||||
background-color: #f89406;
|
||||
*background-color: #df8505;
|
||||
}
|
||||
|
||||
.btn-warning:active,
|
||||
.btn-warning.active {
|
||||
background-color: #c67605 \9;
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
color: #ffffff;
|
||||
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
|
||||
background-color: #da4f49;
|
||||
*background-color: #bd362f;
|
||||
background-image: -moz-linear-gradient(top, #ee5f5b, #bd362f);
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#bd362f));
|
||||
background-image: -webkit-linear-gradient(top, #ee5f5b, #bd362f);
|
||||
background-image: -o-linear-gradient(top, #ee5f5b, #bd362f);
|
||||
background-image: linear-gradient(to bottom, #ee5f5b, #bd362f);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #bd362f #bd362f #802420;
|
||||
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffee5f5b', endColorstr='#ffbd362f', GradientType=0);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
|
||||
}
|
||||
|
||||
.btn-danger:hover,
|
||||
.btn-danger:focus,
|
||||
.btn-danger:active,
|
||||
.btn-danger.active,
|
||||
.btn-danger.disabled,
|
||||
.btn-danger[disabled] {
|
||||
color: #ffffff;
|
||||
background-color: #bd362f;
|
||||
*background-color: #a9302a;
|
||||
}
|
||||
|
||||
.btn-danger:active,
|
||||
.btn-danger.active {
|
||||
background-color: #942a25 \9;
|
||||
}
|
||||
|
||||
.btn-success {
|
||||
color: #ffffff;
|
||||
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
|
||||
background-color: #5bb75b;
|
||||
*background-color: #51a351;
|
||||
background-image: -moz-linear-gradient(top, #62c462, #51a351);
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#51a351));
|
||||
background-image: -webkit-linear-gradient(top, #62c462, #51a351);
|
||||
background-image: -o-linear-gradient(top, #62c462, #51a351);
|
||||
background-image: linear-gradient(to bottom, #62c462, #51a351);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #51a351 #51a351 #387038;
|
||||
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff62c462', endColorstr='#ff51a351', GradientType=0);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
|
||||
}
|
||||
|
||||
.btn-success:hover,
|
||||
.btn-success:focus,
|
||||
.btn-success:active,
|
||||
.btn-success.active,
|
||||
.btn-success.disabled,
|
||||
.btn-success[disabled] {
|
||||
color: #ffffff;
|
||||
background-color: #51a351;
|
||||
*background-color: #499249;
|
||||
}
|
||||
|
||||
.btn-success:active,
|
||||
.btn-success.active {
|
||||
background-color: #408140 \9;
|
||||
}
|
||||
|
||||
.btn-info {
|
||||
color: #ffffff;
|
||||
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
|
||||
background-color: #49afcd;
|
||||
*background-color: #2f96b4;
|
||||
background-image: -moz-linear-gradient(top, #5bc0de, #2f96b4);
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#2f96b4));
|
||||
background-image: -webkit-linear-gradient(top, #5bc0de, #2f96b4);
|
||||
background-image: -o-linear-gradient(top, #5bc0de, #2f96b4);
|
||||
background-image: linear-gradient(to bottom, #5bc0de, #2f96b4);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #2f96b4 #2f96b4 #1f6377;
|
||||
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff2f96b4', GradientType=0);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
|
||||
}
|
||||
|
||||
.btn-info:hover,
|
||||
.btn-info:focus,
|
||||
.btn-info:active,
|
||||
.btn-info.active,
|
||||
.btn-info.disabled,
|
||||
.btn-info[disabled] {
|
||||
color: #ffffff;
|
||||
background-color: #2f96b4;
|
||||
*background-color: #2a85a0;
|
||||
}
|
||||
|
||||
.btn-info:active,
|
||||
.btn-info.active {
|
||||
background-color: #24748c \9;
|
||||
}
|
||||
|
||||
.btn-inverse {
|
||||
color: #ffffff;
|
||||
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
|
||||
background-color: #363636;
|
||||
*background-color: #222222;
|
||||
background-image: -moz-linear-gradient(top, #444444, #222222);
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#444444), to(#222222));
|
||||
background-image: -webkit-linear-gradient(top, #444444, #222222);
|
||||
background-image: -o-linear-gradient(top, #444444, #222222);
|
||||
background-image: linear-gradient(to bottom, #444444, #222222);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #222222 #222222 #000000;
|
||||
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff444444', endColorstr='#ff222222', GradientType=0);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
|
||||
}
|
||||
|
||||
.btn-inverse:hover,
|
||||
.btn-inverse:focus,
|
||||
.btn-inverse:active,
|
||||
.btn-inverse.active,
|
||||
.btn-inverse.disabled,
|
||||
.btn-inverse[disabled] {
|
||||
color: #ffffff;
|
||||
background-color: #222222;
|
||||
*background-color: #151515;
|
||||
}
|
||||
|
||||
.btn-inverse:active,
|
||||
.btn-inverse.active {
|
||||
background-color: #080808 \9;
|
||||
}
|
||||
|
||||
button.btn,
|
||||
input[type="submit"].btn {
|
||||
*padding-top: 3px;
|
||||
*padding-bottom: 3px;
|
||||
}
|
||||
|
||||
button.btn::-moz-focus-inner,
|
||||
input[type="submit"].btn::-moz-focus-inner {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
button.btn.btn-large,
|
||||
input[type="submit"].btn.btn-large {
|
||||
*padding-top: 7px;
|
||||
*padding-bottom: 7px;
|
||||
}
|
||||
|
||||
button.btn.btn-small,
|
||||
input[type="submit"].btn.btn-small {
|
||||
*padding-top: 3px;
|
||||
*padding-bottom: 3px;
|
||||
}
|
||||
|
||||
button.btn.btn-mini,
|
||||
input[type="submit"].btn.btn-mini {
|
||||
*padding-top: 1px;
|
||||
*padding-bottom: 1px;
|
||||
}
|
||||
|
||||
.btn-link,
|
||||
.btn-link:active,
|
||||
.btn-link[disabled] {
|
||||
background-color: transparent;
|
||||
background-image: none;
|
||||
-webkit-box-shadow: none;
|
||||
-moz-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.btn-link {
|
||||
color: #0088cc;
|
||||
cursor: pointer;
|
||||
border-color: transparent;
|
||||
-webkit-border-radius: 0;
|
||||
-moz-border-radius: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.btn-link:hover,
|
||||
.btn-link:focus {
|
||||
color: #005580;
|
||||
text-decoration: underline;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.btn-link[disabled]:hover,
|
||||
.btn-link[disabled]:focus {
|
||||
color: #333333;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.btn-group {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
*display: inline;
|
||||
*margin-left: .3em;
|
||||
font-size: 0;
|
||||
white-space: nowrap;
|
||||
vertical-align: middle;
|
||||
*zoom: 1;
|
||||
}
|
||||
|
||||
.btn-group:first-child {
|
||||
*margin-left: 0;
|
||||
}
|
||||
|
||||
.btn-group + .btn-group {
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.btn-toolbar {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
font-size: 0;
|
||||
}
|
||||
|
||||
.btn-toolbar > .btn + .btn,
|
||||
.btn-toolbar > .btn-group + .btn,
|
||||
.btn-toolbar > .btn + .btn-group {
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.btn-group > .btn {
|
||||
position: relative;
|
||||
-webkit-border-radius: 0;
|
||||
-moz-border-radius: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.btn-group > .btn + .btn {
|
||||
margin-left: -1px;
|
||||
}
|
||||
|
||||
.btn-group > .btn,
|
||||
.btn-group > .dropdown-menu,
|
||||
.btn-group > .popover {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.btn-group > .btn-mini {
|
||||
font-size: 10.5px;
|
||||
}
|
||||
|
||||
.btn-group > .btn-small {
|
||||
font-size: 11.9px;
|
||||
}
|
||||
|
||||
.btn-group > .btn-large {
|
||||
font-size: 17.5px;
|
||||
}
|
||||
|
||||
.btn-group > .btn:first-child {
|
||||
margin-left: 0;
|
||||
-webkit-border-bottom-left-radius: 4px;
|
||||
border-bottom-left-radius: 4px;
|
||||
-webkit-border-top-left-radius: 4px;
|
||||
border-top-left-radius: 4px;
|
||||
-moz-border-radius-bottomleft: 4px;
|
||||
-moz-border-radius-topleft: 4px;
|
||||
}
|
||||
|
||||
.btn-group > .btn:last-child,
|
||||
.btn-group > .dropdown-toggle {
|
||||
-webkit-border-top-right-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
-webkit-border-bottom-right-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
-moz-border-radius-topright: 4px;
|
||||
-moz-border-radius-bottomright: 4px;
|
||||
}
|
||||
|
||||
.btn-group > .btn.large:first-child {
|
||||
margin-left: 0;
|
||||
-webkit-border-bottom-left-radius: 6px;
|
||||
border-bottom-left-radius: 6px;
|
||||
-webkit-border-top-left-radius: 6px;
|
||||
border-top-left-radius: 6px;
|
||||
-moz-border-radius-bottomleft: 6px;
|
||||
-moz-border-radius-topleft: 6px;
|
||||
}
|
||||
|
||||
.btn-group > .btn.large:last-child,
|
||||
.btn-group > .large.dropdown-toggle {
|
||||
-webkit-border-top-right-radius: 6px;
|
||||
border-top-right-radius: 6px;
|
||||
-webkit-border-bottom-right-radius: 6px;
|
||||
border-bottom-right-radius: 6px;
|
||||
-moz-border-radius-topright: 6px;
|
||||
-moz-border-radius-bottomright: 6px;
|
||||
}
|
||||
|
||||
.btn-group > .btn:hover,
|
||||
.btn-group > .btn:focus,
|
||||
.btn-group > .btn:active,
|
||||
.btn-group > .btn.active {
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.btn-group .dropdown-toggle:active,
|
||||
.btn-group.open .dropdown-toggle {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
.btn-group > .btn + .dropdown-toggle {
|
||||
*padding-top: 5px;
|
||||
padding-right: 8px;
|
||||
*padding-bottom: 5px;
|
||||
padding-left: 8px;
|
||||
-webkit-box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
-moz-box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.btn-group > .btn-mini + .dropdown-toggle {
|
||||
*padding-top: 2px;
|
||||
padding-right: 5px;
|
||||
*padding-bottom: 2px;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.btn-group > .btn-small + .dropdown-toggle {
|
||||
*padding-top: 5px;
|
||||
*padding-bottom: 4px;
|
||||
}
|
||||
|
||||
.btn-group > .btn-large + .dropdown-toggle {
|
||||
*padding-top: 7px;
|
||||
padding-right: 12px;
|
||||
*padding-bottom: 7px;
|
||||
padding-left: 12px;
|
||||
}
|
||||
|
||||
.btn-group.open .dropdown-toggle {
|
||||
background-image: none;
|
||||
-webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
-moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.btn-group.open .btn.dropdown-toggle {
|
||||
background-color: #e6e6e6;
|
||||
}
|
||||
|
||||
.btn-group.open .btn-primary.dropdown-toggle {
|
||||
background-color: #0044cc;
|
||||
}
|
||||
|
||||
.btn-group.open .btn-warning.dropdown-toggle {
|
||||
background-color: #f89406;
|
||||
}
|
||||
|
||||
.btn-group.open .btn-danger.dropdown-toggle {
|
||||
background-color: #bd362f;
|
||||
}
|
||||
|
||||
.btn-group.open .btn-success.dropdown-toggle {
|
||||
background-color: #51a351;
|
||||
}
|
||||
|
||||
.btn-group.open .btn-info.dropdown-toggle {
|
||||
background-color: #2f96b4;
|
||||
}
|
||||
|
||||
.btn-group.open .btn-inverse.dropdown-toggle {
|
||||
background-color: #222222;
|
||||
}
|
||||
|
||||
.btn .caret {
|
||||
margin-top: 8px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.btn-large .caret {
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.btn-large .caret {
|
||||
border-top-width: 5px;
|
||||
border-right-width: 5px;
|
||||
border-left-width: 5px;
|
||||
}
|
||||
|
||||
.btn-mini .caret,
|
||||
.btn-small .caret {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.dropup .btn-large .caret {
|
||||
border-bottom-width: 5px;
|
||||
}
|
||||
|
||||
.btn-primary .caret,
|
||||
.btn-warning .caret,
|
||||
.btn-danger .caret,
|
||||
.btn-info .caret,
|
||||
.btn-success .caret,
|
||||
.btn-inverse .caret {
|
||||
border-top-color: #ffffff;
|
||||
border-bottom-color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-group-vertical {
|
||||
display: inline-block;
|
||||
*display: inline;
|
||||
/* IE7 inline-block hack */
|
||||
|
||||
*zoom: 1;
|
||||
}
|
||||
|
||||
.btn-group-vertical > .btn {
|
||||
display: block;
|
||||
float: none;
|
||||
max-width: 100%;
|
||||
-webkit-border-radius: 0;
|
||||
-moz-border-radius: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.btn-group-vertical > .btn + .btn {
|
||||
margin-top: -1px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.btn-group-vertical > .btn:first-child {
|
||||
-webkit-border-radius: 4px 4px 0 0;
|
||||
-moz-border-radius: 4px 4px 0 0;
|
||||
border-radius: 4px 4px 0 0;
|
||||
}
|
||||
|
||||
.btn-group-vertical > .btn:last-child {
|
||||
-webkit-border-radius: 0 0 4px 4px;
|
||||
-moz-border-radius: 0 0 4px 4px;
|
||||
border-radius: 0 0 4px 4px;
|
||||
}
|
||||
|
||||
.btn-group-vertical > .btn-large:first-child {
|
||||
-webkit-border-radius: 6px 6px 0 0;
|
||||
-moz-border-radius: 6px 6px 0 0;
|
||||
border-radius: 6px 6px 0 0;
|
||||
}
|
||||
|
||||
.btn-group-vertical > .btn-large:last-child {
|
||||
-webkit-border-radius: 0 0 6px 6px;
|
||||
-moz-border-radius: 0 0 6px 6px;
|
||||
border-radius: 0 0 6px 6px;
|
||||
}
|
221
media/css/bootstrap-progress-bar.css
vendored
Normal file
221
media/css/bootstrap-progress-bar.css
vendored
Normal file
@@ -0,0 +1,221 @@
|
||||
/* Bootstrap v2.3.2 */
|
||||
.fade {
|
||||
opacity: 0;
|
||||
-webkit-transition: opacity 0.15s linear;
|
||||
-moz-transition: opacity 0.15s linear;
|
||||
-o-transition: opacity 0.15s linear;
|
||||
transition: opacity 0.15s linear;
|
||||
}
|
||||
|
||||
.fade.in {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
@-webkit-keyframes progress-bar-stripes {
|
||||
from {
|
||||
background-position: 40px 0;
|
||||
}
|
||||
to {
|
||||
background-position: 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
@-moz-keyframes progress-bar-stripes {
|
||||
from {
|
||||
background-position: 40px 0;
|
||||
}
|
||||
to {
|
||||
background-position: 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
@-ms-keyframes progress-bar-stripes {
|
||||
from {
|
||||
background-position: 40px 0;
|
||||
}
|
||||
to {
|
||||
background-position: 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
@-o-keyframes progress-bar-stripes {
|
||||
from {
|
||||
background-position: 0 0;
|
||||
}
|
||||
to {
|
||||
background-position: 40px 0;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes progress-bar-stripes {
|
||||
from {
|
||||
background-position: 40px 0;
|
||||
}
|
||||
to {
|
||||
background-position: 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
.progress {
|
||||
height: 20px;
|
||||
margin-bottom: 20px;
|
||||
overflow: hidden;
|
||||
background-color: #f7f7f7;
|
||||
background-image: -moz-linear-gradient(top, #f5f5f5, #f9f9f9);
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f5f5f5), to(#f9f9f9));
|
||||
background-image: -webkit-linear-gradient(top, #f5f5f5, #f9f9f9);
|
||||
background-image: -o-linear-gradient(top, #f5f5f5, #f9f9f9);
|
||||
background-image: linear-gradient(to bottom, #f5f5f5, #f9f9f9);
|
||||
background-repeat: repeat-x;
|
||||
-webkit-border-radius: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#fff9f9f9', GradientType=0);
|
||||
-webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
|
||||
-moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
|
||||
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.progress .bar {
|
||||
float: left;
|
||||
width: 0;
|
||||
height: 100%;
|
||||
font-size: 12px;
|
||||
color: #ffffff;
|
||||
text-align: center;
|
||||
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
|
||||
background-color: #0e90d2;
|
||||
background-image: -moz-linear-gradient(top, #149bdf, #0480be);
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#149bdf), to(#0480be));
|
||||
background-image: -webkit-linear-gradient(top, #149bdf, #0480be);
|
||||
background-image: -o-linear-gradient(top, #149bdf, #0480be);
|
||||
background-image: linear-gradient(to bottom, #149bdf, #0480be);
|
||||
background-repeat: repeat-x;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff149bdf', endColorstr='#ff0480be', GradientType=0);
|
||||
-webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
|
||||
-moz-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
|
||||
box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
-webkit-transition: width 0.6s ease;
|
||||
-moz-transition: width 0.6s ease;
|
||||
-o-transition: width 0.6s ease;
|
||||
transition: width 0.6s ease;
|
||||
}
|
||||
|
||||
.progress .bar + .bar {
|
||||
-webkit-box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.15);
|
||||
-moz-box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.15);
|
||||
box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.progress-striped .bar {
|
||||
background-color: #149bdf;
|
||||
background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
|
||||
background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
||||
background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
||||
background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
||||
background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
||||
-webkit-background-size: 40px 40px;
|
||||
-moz-background-size: 40px 40px;
|
||||
-o-background-size: 40px 40px;
|
||||
background-size: 40px 40px;
|
||||
}
|
||||
|
||||
.progress.active .bar {
|
||||
-webkit-animation: progress-bar-stripes 2s linear infinite;
|
||||
-moz-animation: progress-bar-stripes 2s linear infinite;
|
||||
-ms-animation: progress-bar-stripes 2s linear infinite;
|
||||
-o-animation: progress-bar-stripes 2s linear infinite;
|
||||
animation: progress-bar-stripes 2s linear infinite;
|
||||
}
|
||||
|
||||
.progress-danger .bar,
|
||||
.progress .bar-danger {
|
||||
background-color: #dd514c;
|
||||
background-image: -moz-linear-gradient(top, #ee5f5b, #c43c35);
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#c43c35));
|
||||
background-image: -webkit-linear-gradient(top, #ee5f5b, #c43c35);
|
||||
background-image: -o-linear-gradient(top, #ee5f5b, #c43c35);
|
||||
background-image: linear-gradient(to bottom, #ee5f5b, #c43c35);
|
||||
background-repeat: repeat-x;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffee5f5b', endColorstr='#ffc43c35', GradientType=0);
|
||||
}
|
||||
|
||||
.progress-danger.progress-striped .bar,
|
||||
.progress-striped .bar-danger {
|
||||
background-color: #ee5f5b;
|
||||
background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
|
||||
background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
||||
background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
||||
background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
||||
background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
||||
}
|
||||
|
||||
.progress-success .bar,
|
||||
.progress .bar-success {
|
||||
background-color: #5eb95e;
|
||||
background-image: -moz-linear-gradient(top, #62c462, #57a957);
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#57a957));
|
||||
background-image: -webkit-linear-gradient(top, #62c462, #57a957);
|
||||
background-image: -o-linear-gradient(top, #62c462, #57a957);
|
||||
background-image: linear-gradient(to bottom, #62c462, #57a957);
|
||||
background-repeat: repeat-x;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff62c462', endColorstr='#ff57a957', GradientType=0);
|
||||
}
|
||||
|
||||
.progress-success.progress-striped .bar,
|
||||
.progress-striped .bar-success {
|
||||
background-color: #62c462;
|
||||
background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
|
||||
background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
||||
background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
||||
background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
||||
background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
||||
}
|
||||
|
||||
.progress-info .bar,
|
||||
.progress .bar-info {
|
||||
background-color: #4bb1cf;
|
||||
background-image: -moz-linear-gradient(top, #5bc0de, #339bb9);
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#339bb9));
|
||||
background-image: -webkit-linear-gradient(top, #5bc0de, #339bb9);
|
||||
background-image: -o-linear-gradient(top, #5bc0de, #339bb9);
|
||||
background-image: linear-gradient(to bottom, #5bc0de, #339bb9);
|
||||
background-repeat: repeat-x;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff339bb9', GradientType=0);
|
||||
}
|
||||
|
||||
.progress-info.progress-striped .bar,
|
||||
.progress-striped .bar-info {
|
||||
background-color: #5bc0de;
|
||||
background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
|
||||
background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
||||
background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
||||
background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
||||
background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
||||
}
|
||||
|
||||
.progress-warning .bar,
|
||||
.progress .bar-warning {
|
||||
background-color: #faa732;
|
||||
background-image: -moz-linear-gradient(top, #fbb450, #f89406);
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406));
|
||||
background-image: -webkit-linear-gradient(top, #fbb450, #f89406);
|
||||
background-image: -o-linear-gradient(top, #fbb450, #f89406);
|
||||
background-image: linear-gradient(to bottom, #fbb450, #f89406);
|
||||
background-repeat: repeat-x;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0);
|
||||
}
|
||||
|
||||
.progress-warning.progress-striped .bar,
|
||||
.progress-striped .bar-warning {
|
||||
background-color: #fbb450;
|
||||
background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
|
||||
background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
||||
background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
||||
background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
||||
background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
||||
}
|
||||
|
84
media/css/jquery.fileupload-ui.css
Normal file
84
media/css/jquery.fileupload-ui.css
Normal file
@@ -0,0 +1,84 @@
|
||||
@charset 'UTF-8';
|
||||
/*
|
||||
* jQuery File Upload UI Plugin CSS 6.3
|
||||
* https://github.com/blueimp/jQuery-File-Upload
|
||||
*
|
||||
* Copyright 2010, Sebastian Tschan
|
||||
* https://blueimp.net
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* http://www.opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
.fileinput-button {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
float: left;
|
||||
margin-right: 4px;
|
||||
}
|
||||
.fileinput-button input {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
margin: 0;
|
||||
border: solid transparent;
|
||||
border-width: 0 0 100px 200px;
|
||||
opacity: 0;
|
||||
filter: alpha(opacity=0);
|
||||
-moz-transform: translate(-300px, 0) scale(4);
|
||||
direction: ltr;
|
||||
cursor: pointer;
|
||||
}
|
||||
.fileupload-buttonbar .btn,
|
||||
.fileupload-buttonbar .toggle {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.files .progress {
|
||||
width: 200px;
|
||||
}
|
||||
.progress-animated .bar {
|
||||
background: url(../img/progressbar.gif) !important;
|
||||
filter: none;
|
||||
}
|
||||
.fileupload-loading {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
width: 128px;
|
||||
height: 128px;
|
||||
background: url(../img/loading.gif) center no-repeat;
|
||||
display: none;
|
||||
}
|
||||
.fileupload-processing .fileupload-loading {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Fix for IE 6: */
|
||||
*html .fileinput-button {
|
||||
line-height: 22px;
|
||||
margin: 1px -3px 0 0;
|
||||
}
|
||||
|
||||
/* Fix for IE 7: */
|
||||
*+html .fileinput-button {
|
||||
margin: 1px 0 0 0;
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.files .btn span {
|
||||
display: none;
|
||||
}
|
||||
.files .preview * {
|
||||
width: 40px;
|
||||
}
|
||||
.files .name * {
|
||||
width: 80px;
|
||||
display: inline-block;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
.files .progress {
|
||||
width: 20px;
|
||||
}
|
||||
.files .delete {
|
||||
width: 60px;
|
||||
}
|
||||
}
|
BIN
media/img/loading.gif
Normal file
BIN
media/img/loading.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
BIN
media/img/progressbar.gif
Normal file
BIN
media/img/progressbar.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
1
media/js/canvas-to-blob.min.js
vendored
Normal file
1
media/js/canvas-to-blob.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(function(a){"use strict";var b=a.HTMLCanvasElement&&a.HTMLCanvasElement.prototype,c=a.BlobBuilder||a.WebKitBlobBuilder||a.MozBlobBuilder,d=c&&a.atob&&a.ArrayBuffer&&a.Uint8Array&&function(a){var b,d,e,f,g,h;a.split(",")[0].indexOf("base64")>=0?b=atob(a.split(",")[1]):b=decodeURIComponent(a.split(",")[1]),d=new ArrayBuffer(b.length),e=new Uint8Array(d);for(f=0;f<b.length;f+=1)e[f]=b.charCodeAt(f);return g=new c,g.append(d),h=a.split(",")[0].split(":")[1].split(";")[0],g.getBlob(h)};a.HTMLCanvasElement&&!b.toBlob&&(b.mozGetAsFile?b.toBlob=function(a,b){a(this.mozGetAsFile("blob",b))}:b.toDataURL&&d&&(b.toBlob=function(a,b){a(d(this.toDataURL(b)))})),typeof define!="undefined"&&define.amd?define(function(){return d}):a.dataURLtoBlob=d})(this);
|
219
media/js/jquery.fileupload-fp.js
vendored
Normal file
219
media/js/jquery.fileupload-fp.js
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* jQuery File Upload File Processing Plugin 1.0
|
||||
* https://github.com/blueimp/jQuery-File-Upload
|
||||
*
|
||||
* Copyright 2012, Sebastian Tschan
|
||||
* https://blueimp.net
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* http://www.opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
/*jslint nomen: true, unparam: true, regexp: true */
|
||||
/*global define, window, document */
|
||||
|
||||
(function (factory) {
|
||||
'use strict';
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// Register as an anonymous AMD module:
|
||||
define([
|
||||
'jquery',
|
||||
'load-image',
|
||||
'canvas-to-blob',
|
||||
'./jquery.fileupload'
|
||||
], factory);
|
||||
} else {
|
||||
// Browser globals:
|
||||
factory(
|
||||
window.jQuery,
|
||||
window.loadImage
|
||||
);
|
||||
}
|
||||
}(function ($, loadImage) {
|
||||
'use strict';
|
||||
|
||||
// The File Upload IP version extends the basic fileupload widget
|
||||
// with file processing functionality:
|
||||
$.widget('blueimpFP.fileupload', $.blueimp.fileupload, {
|
||||
|
||||
options: {
|
||||
// The list of file processing actions:
|
||||
process: [
|
||||
/*
|
||||
{
|
||||
action: 'load',
|
||||
fileTypes: /^image\/(gif|jpeg|png)$/,
|
||||
maxFileSize: 20000000 // 20MB
|
||||
},
|
||||
{
|
||||
action: 'resize',
|
||||
maxWidth: 1920,
|
||||
maxHeight: 1200,
|
||||
minWidth: 800,
|
||||
minHeight: 600
|
||||
},
|
||||
{
|
||||
action: 'save'
|
||||
}
|
||||
*/
|
||||
],
|
||||
|
||||
// The add callback is invoked as soon as files are added to the
|
||||
// fileupload widget (via file input selection, drag & drop or add
|
||||
// API call). See the basic file upload widget for more information:
|
||||
add: function (e, data) {
|
||||
$(this).fileupload('process', data).done(function () {
|
||||
data.submit();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
processActions: {
|
||||
// Loads the image given via data.files and data.index
|
||||
// as canvas element.
|
||||
// Accepts the options fileTypes (regular expression)
|
||||
// and maxFileSize (integer) to limit the files to load:
|
||||
load: function (data, options) {
|
||||
var that = this,
|
||||
file = data.files[data.index],
|
||||
dfd = $.Deferred();
|
||||
if (window.HTMLCanvasElement &&
|
||||
window.HTMLCanvasElement.prototype.toBlob &&
|
||||
($.type(options.maxFileSize) !== 'number' ||
|
||||
file.size < options.maxFileSize) &&
|
||||
(!options.fileTypes ||
|
||||
options.fileTypes.test(file.type))) {
|
||||
loadImage(
|
||||
file,
|
||||
function (canvas) {
|
||||
data.canvas = canvas;
|
||||
dfd.resolveWith(that, [data]);
|
||||
},
|
||||
{canvas: true}
|
||||
);
|
||||
} else {
|
||||
dfd.rejectWith(that, [data]);
|
||||
}
|
||||
return dfd.promise();
|
||||
},
|
||||
// Resizes the image given as data.canvas and updates
|
||||
// data.canvas with the resized image.
|
||||
// Accepts the options maxWidth, maxHeight, minWidth and
|
||||
// minHeight to scale the given image:
|
||||
resize: function (data, options) {
|
||||
if (data.canvas) {
|
||||
var canvas = loadImage.scale(data.canvas, options);
|
||||
if (canvas.width !== data.canvas.width ||
|
||||
canvas.height !== data.canvas.height) {
|
||||
data.canvas = canvas;
|
||||
data.processed = true;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
},
|
||||
// Saves the processed image given as data.canvas
|
||||
// inplace at data.index of data.files:
|
||||
save: function (data, options) {
|
||||
// Do nothing if no processing has happened:
|
||||
if (!data.canvas || !data.processed) {
|
||||
return data;
|
||||
}
|
||||
var that = this,
|
||||
file = data.files[data.index],
|
||||
name = file.name,
|
||||
dfd = $.Deferred(),
|
||||
callback = function (blob) {
|
||||
if (!blob.name) {
|
||||
if (file.type === blob.type) {
|
||||
blob.name = file.name;
|
||||
} else if (file.name) {
|
||||
blob.name = file.name.replace(
|
||||
/\..+$/,
|
||||
'.' + blob.type.substr(6)
|
||||
);
|
||||
}
|
||||
}
|
||||
// Store the created blob at the position
|
||||
// of the original file in the files list:
|
||||
data.files[data.index] = blob;
|
||||
dfd.resolveWith(that, [data]);
|
||||
};
|
||||
// Use canvas.mozGetAsFile directly, to retain the filename, as
|
||||
// Gecko doesn't support the filename option for FormData.append:
|
||||
if (data.canvas.mozGetAsFile) {
|
||||
callback(data.canvas.mozGetAsFile(
|
||||
(/^image\/(jpeg|png)$/.test(file.type) && name) ||
|
||||
((name && name.replace(/\..+$/, '')) ||
|
||||
'blob') + '.png',
|
||||
file.type
|
||||
));
|
||||
} else {
|
||||
data.canvas.toBlob(callback, file.type);
|
||||
}
|
||||
return dfd.promise();
|
||||
}
|
||||
},
|
||||
|
||||
// Resizes the file at the given index and stores the created blob at
|
||||
// the original position of the files list, returns a Promise object:
|
||||
_processFile: function (files, index, options) {
|
||||
var that = this,
|
||||
dfd = $.Deferred().resolveWith(that, [{
|
||||
files: files,
|
||||
index: index
|
||||
}]),
|
||||
chain = dfd.promise();
|
||||
that._processing += 1;
|
||||
$.each(options.process, function (i, settings) {
|
||||
chain = chain.pipe(function (data) {
|
||||
return that.processActions[settings.action]
|
||||
.call(this, data, settings);
|
||||
});
|
||||
});
|
||||
chain.always(function () {
|
||||
that._processing -= 1;
|
||||
if (that._processing === 0) {
|
||||
that.element
|
||||
.removeClass('fileupload-processing');
|
||||
}
|
||||
});
|
||||
if (that._processing === 1) {
|
||||
that.element.addClass('fileupload-processing');
|
||||
}
|
||||
return chain;
|
||||
},
|
||||
|
||||
// Processes the files given as files property of the data parameter,
|
||||
// returns a Promise object that allows to bind a done handler, which
|
||||
// will be invoked after processing all files (inplace) is done:
|
||||
process: function (data) {
|
||||
var that = this,
|
||||
options = $.extend({}, this.options, data);
|
||||
if (options.process && options.process.length &&
|
||||
this._isXHRUpload(options)) {
|
||||
$.each(data.files, function (index, file) {
|
||||
that._processingQueue = that._processingQueue.pipe(
|
||||
function () {
|
||||
var dfd = $.Deferred();
|
||||
that._processFile(data.files, index, options)
|
||||
.always(function () {
|
||||
dfd.resolveWith(that);
|
||||
});
|
||||
return dfd.promise();
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
return this._processingQueue;
|
||||
},
|
||||
|
||||
_create: function () {
|
||||
$.blueimp.fileupload.prototype._create.call(this);
|
||||
this._processing = 0;
|
||||
this._processingQueue = $.Deferred().resolveWith(this)
|
||||
.promise();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}));
|
691
media/js/jquery.fileupload-ui.js
vendored
Normal file
691
media/js/jquery.fileupload-ui.js
vendored
Normal file
@@ -0,0 +1,691 @@
|
||||
/*
|
||||
* jQuery File Upload User Interface Plugin 6.8.1
|
||||
* https://github.com/blueimp/jQuery-File-Upload
|
||||
*
|
||||
* Copyright 2010, Sebastian Tschan
|
||||
* https://blueimp.net
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* http://www.opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
/*jslint nomen: true, unparam: true, regexp: true */
|
||||
/*global define, window, document, URL, webkitURL, FileReader */
|
||||
|
||||
(function (factory) {
|
||||
'use strict';
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// Register as an anonymous AMD module:
|
||||
define([
|
||||
'jquery',
|
||||
'tmpl',
|
||||
'load-image',
|
||||
'./jquery.fileupload-fp'
|
||||
], factory);
|
||||
} else {
|
||||
// Browser globals:
|
||||
factory(
|
||||
window.jQuery,
|
||||
window.tmpl,
|
||||
window.loadImage
|
||||
);
|
||||
}
|
||||
}(function ($, tmpl, loadImage) {
|
||||
'use strict';
|
||||
|
||||
// The UI version extends the FP (file processing) version or the basic
|
||||
// file upload widget and adds complete user interface interaction:
|
||||
var parentWidget = ($.blueimpFP || $.blueimp).fileupload;
|
||||
$.widget('blueimpUI.fileupload', parentWidget, {
|
||||
|
||||
options: {
|
||||
// By default, files added to the widget are uploaded as soon
|
||||
// as the user clicks on the start buttons. To enable automatic
|
||||
// uploads, set the following option to true:
|
||||
autoUpload: false,
|
||||
// The following option limits the number of files that are
|
||||
// allowed to be uploaded using this widget:
|
||||
maxNumberOfFiles: undefined,
|
||||
// The maximum allowed file size:
|
||||
maxFileSize: undefined,
|
||||
// The minimum allowed file size:
|
||||
minFileSize: undefined,
|
||||
// The regular expression for allowed file types, matches
|
||||
// against either file type or file name:
|
||||
acceptFileTypes: /.+$/i,
|
||||
// The regular expression to define for which files a preview
|
||||
// image is shown, matched against the file type:
|
||||
previewSourceFileTypes: /^image\/(gif|jpeg|png)$/,
|
||||
// The maximum file size of images that are to be displayed as preview:
|
||||
previewSourceMaxFileSize: 5000000, // 5MB
|
||||
// The maximum width of the preview images:
|
||||
previewMaxWidth: 80,
|
||||
// The maximum height of the preview images:
|
||||
previewMaxHeight: 80,
|
||||
// By default, preview images are displayed as canvas elements
|
||||
// if supported by the browser. Set the following option to false
|
||||
// to always display preview images as img elements:
|
||||
previewAsCanvas: true,
|
||||
// The ID of the upload template:
|
||||
uploadTemplateId: 'template-upload',
|
||||
// The ID of the download template:
|
||||
downloadTemplateId: 'template-download',
|
||||
// The container for the list of files. If undefined, it is set to
|
||||
// an element with class "files" inside of the widget element:
|
||||
filesContainer: undefined,
|
||||
// By default, files are appended to the files container.
|
||||
// Set the following option to true, to prepend files instead:
|
||||
prependFiles: false,
|
||||
// The expected data type of the upload response, sets the dataType
|
||||
// option of the $.ajax upload requests:
|
||||
dataType: 'json',
|
||||
|
||||
// The add callback is invoked as soon as files are added to the fileupload
|
||||
// widget (via file input selection, drag & drop or add API call).
|
||||
// See the basic file upload widget for more information:
|
||||
add: function (e, data) {
|
||||
var that = $(this).data('fileupload'),
|
||||
options = that.options,
|
||||
files = data.files;
|
||||
$(this).fileupload('process', data).done(function () {
|
||||
that._adjustMaxNumberOfFiles(-files.length);
|
||||
data.isAdjusted = true;
|
||||
data.files.valid = data.isValidated = that._validate(files);
|
||||
data.context = that._renderUpload(files).data('data', data);
|
||||
options.filesContainer[
|
||||
options.prependFiles ? 'prepend' : 'append'
|
||||
](data.context);
|
||||
that._renderPreviews(files, data.context);
|
||||
that._forceReflow(data.context);
|
||||
that._transition(data.context).done(
|
||||
function () {
|
||||
if ((that._trigger('added', e, data) !== false) &&
|
||||
(options.autoUpload || data.autoUpload) &&
|
||||
data.autoUpload !== false && data.isValidated) {
|
||||
data.submit();
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
},
|
||||
// Callback for the start of each file upload request:
|
||||
send: function (e, data) {
|
||||
var that = $(this).data('fileupload');
|
||||
if (!data.isValidated) {
|
||||
if (!data.isAdjusted) {
|
||||
that._adjustMaxNumberOfFiles(-data.files.length);
|
||||
}
|
||||
if (!that._validate(data.files)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (data.context && data.dataType &&
|
||||
data.dataType.substr(0, 6) === 'iframe') {
|
||||
// Iframe Transport does not support progress events.
|
||||
// In lack of an indeterminate progress bar, we set
|
||||
// the progress to 100%, showing the full animated bar:
|
||||
data.context
|
||||
.find('.progress').addClass(
|
||||
!$.support.transition && 'progress-animated'
|
||||
)
|
||||
.find('.bar').css(
|
||||
'width',
|
||||
parseInt(100, 10) + '%'
|
||||
);
|
||||
}
|
||||
return that._trigger('sent', e, data);
|
||||
},
|
||||
// Callback for successful uploads:
|
||||
done: function (e, data) {
|
||||
var that = $(this).data('fileupload'),
|
||||
template;
|
||||
if (data.context) {
|
||||
data.context.each(function (index) {
|
||||
var file = ($.isArray(data.result) &&
|
||||
data.result[index]) || {error: 'emptyResult'};
|
||||
if (file.error) {
|
||||
that._adjustMaxNumberOfFiles(1);
|
||||
}
|
||||
that._transition($(this)).done(
|
||||
function () {
|
||||
var node = $(this);
|
||||
template = that._renderDownload([file])
|
||||
.css('height', node.height())
|
||||
.replaceAll(node);
|
||||
that._forceReflow(template);
|
||||
that._transition(template).done(
|
||||
function () {
|
||||
data.context = $(this);
|
||||
that._trigger('completed', e, data);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
} else {
|
||||
template = that._renderDownload(data.result)
|
||||
.appendTo(that.options.filesContainer);
|
||||
that._forceReflow(template);
|
||||
that._transition(template).done(
|
||||
function () {
|
||||
data.context = $(this);
|
||||
that._trigger('completed', e, data);
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
// Callback for failed (abort or error) uploads:
|
||||
fail: function (e, data) {
|
||||
var that = $(this).data('fileupload'),
|
||||
template;
|
||||
that._adjustMaxNumberOfFiles(data.files.length);
|
||||
if (data.context) {
|
||||
data.context.each(function (index) {
|
||||
if (data.errorThrown !== 'abort') {
|
||||
var file = data.files[index];
|
||||
file.error = file.error || data.errorThrown ||
|
||||
true;
|
||||
that._transition($(this)).done(
|
||||
function () {
|
||||
var node = $(this);
|
||||
template = that._renderDownload([file])
|
||||
.replaceAll(node);
|
||||
that._forceReflow(template);
|
||||
that._transition(template).done(
|
||||
function () {
|
||||
data.context = $(this);
|
||||
that._trigger('failed', e, data);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
that._transition($(this)).done(
|
||||
function () {
|
||||
$(this).remove();
|
||||
that._trigger('failed', e, data);
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
} else if (data.errorThrown !== 'abort') {
|
||||
that._adjustMaxNumberOfFiles(-data.files.length);
|
||||
data.context = that._renderUpload(data.files)
|
||||
.appendTo(that.options.filesContainer)
|
||||
.data('data', data);
|
||||
that._forceReflow(data.context);
|
||||
that._transition(data.context).done(
|
||||
function () {
|
||||
data.context = $(this);
|
||||
that._trigger('failed', e, data);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
that._trigger('failed', e, data);
|
||||
}
|
||||
},
|
||||
// Callback for upload progress events:
|
||||
progress: function (e, data) {
|
||||
if (data.context) {
|
||||
data.context.find('.bar').css(
|
||||
'width',
|
||||
parseInt(data.loaded / data.total * 100, 10) + '%'
|
||||
);
|
||||
}
|
||||
},
|
||||
// Callback for global upload progress events:
|
||||
progressall: function (e, data) {
|
||||
var $this = $(this);
|
||||
$this.find('.fileupload-progress')
|
||||
.find('.bar').css(
|
||||
'width',
|
||||
parseInt(data.loaded / data.total * 100, 10) + '%'
|
||||
).end()
|
||||
.find('.progress-extended').each(function () {
|
||||
$(this).html(
|
||||
$this.data('fileupload')
|
||||
._renderExtendedProgress(data)
|
||||
);
|
||||
});
|
||||
},
|
||||
// Callback for uploads start, equivalent to the global ajaxStart event:
|
||||
start: function (e) {
|
||||
var that = $(this).data('fileupload');
|
||||
that._transition($(this).find('.fileupload-progress')).done(
|
||||
function () {
|
||||
that._trigger('started', e);
|
||||
}
|
||||
);
|
||||
},
|
||||
// Callback for uploads stop, equivalent to the global ajaxStop event:
|
||||
stop: function (e) {
|
||||
var that = $(this).data('fileupload');
|
||||
that._transition($(this).find('.fileupload-progress')).done(
|
||||
function () {
|
||||
$(this).find('.bar').css('width', '0%');
|
||||
$(this).find('.progress-extended').html(' ');
|
||||
that._trigger('stopped', e);
|
||||
}
|
||||
);
|
||||
},
|
||||
// Callback for file deletion:
|
||||
destroy: function (e, data) {
|
||||
var that = $(this).data('fileupload');
|
||||
if (data.url) {
|
||||
$.ajax(data);
|
||||
}
|
||||
that._adjustMaxNumberOfFiles(1);
|
||||
that._transition(data.context).done(
|
||||
function () {
|
||||
$(this).remove();
|
||||
that._trigger('destroyed', e, data);
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
// Link handler, that allows to download files
|
||||
// by drag & drop of the links to the desktop:
|
||||
_enableDragToDesktop: function () {
|
||||
var link = $(this),
|
||||
url = link.prop('href'),
|
||||
name = link.prop('download'),
|
||||
type = 'application/octet-stream';
|
||||
link.bind('dragstart', function (e) {
|
||||
try {
|
||||
e.originalEvent.dataTransfer.setData(
|
||||
'DownloadURL',
|
||||
[type, name, url].join(':')
|
||||
);
|
||||
} catch (err) {}
|
||||
});
|
||||
},
|
||||
|
||||
_adjustMaxNumberOfFiles: function (operand) {
|
||||
if (typeof this.options.maxNumberOfFiles === 'number') {
|
||||
this.options.maxNumberOfFiles += operand;
|
||||
if (this.options.maxNumberOfFiles < 1) {
|
||||
this._disableFileInputButton();
|
||||
} else {
|
||||
this._enableFileInputButton();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_formatFileSize: function (bytes) {
|
||||
if (typeof bytes !== 'number') {
|
||||
return '';
|
||||
}
|
||||
if (bytes >= 1000000000) {
|
||||
return (bytes / 1000000000).toFixed(2) + ' GB';
|
||||
}
|
||||
if (bytes >= 1000000) {
|
||||
return (bytes / 1000000).toFixed(2) + ' MB';
|
||||
}
|
||||
return (bytes / 1000).toFixed(2) + ' KB';
|
||||
},
|
||||
|
||||
_formatBitrate: function (bits) {
|
||||
if (typeof bits !== 'number') {
|
||||
return '';
|
||||
}
|
||||
if (bits >= 1000000000) {
|
||||
return (bits / 1000000000).toFixed(2) + ' Gbit/s';
|
||||
}
|
||||
if (bits >= 1000000) {
|
||||
return (bits / 1000000).toFixed(2) + ' Mbit/s';
|
||||
}
|
||||
if (bits >= 1000) {
|
||||
return (bits / 1000).toFixed(2) + ' kbit/s';
|
||||
}
|
||||
return bits + ' bit/s';
|
||||
},
|
||||
|
||||
_formatTime: function (seconds) {
|
||||
var date = new Date(seconds * 1000),
|
||||
days = parseInt(seconds / 86400, 10);
|
||||
days = days ? days + 'd ' : '';
|
||||
return days +
|
||||
('0' + date.getUTCHours()).slice(-2) + ':' +
|
||||
('0' + date.getUTCMinutes()).slice(-2) + ':' +
|
||||
('0' + date.getUTCSeconds()).slice(-2);
|
||||
},
|
||||
|
||||
_formatPercentage: function (floatValue) {
|
||||
return (floatValue * 100).toFixed(2) + ' %';
|
||||
},
|
||||
|
||||
_renderExtendedProgress: function (data) {
|
||||
return this._formatBitrate(data.bitrate) + ' | ' +
|
||||
this._formatTime(
|
||||
(data.total - data.loaded) * 8 / data.bitrate
|
||||
) + ' | ' +
|
||||
this._formatPercentage(
|
||||
data.loaded / data.total
|
||||
) + ' | ' +
|
||||
this._formatFileSize(data.loaded) + ' / ' +
|
||||
this._formatFileSize(data.total);
|
||||
},
|
||||
|
||||
_hasError: function (file) {
|
||||
if (file.error) {
|
||||
return file.error;
|
||||
}
|
||||
// The number of added files is subtracted from
|
||||
// maxNumberOfFiles before validation, so we check if
|
||||
// maxNumberOfFiles is below 0 (instead of below 1):
|
||||
if (this.options.maxNumberOfFiles < 0) {
|
||||
return 'maxNumberOfFiles';
|
||||
}
|
||||
// Files are accepted if either the file type or the file name
|
||||
// matches against the acceptFileTypes regular expression, as
|
||||
// only browsers with support for the File API report the type:
|
||||
if (!(this.options.acceptFileTypes.test(file.type) ||
|
||||
this.options.acceptFileTypes.test(file.name))) {
|
||||
return 'acceptFileTypes';
|
||||
}
|
||||
if (this.options.maxFileSize &&
|
||||
file.size > this.options.maxFileSize) {
|
||||
return 'maxFileSize';
|
||||
}
|
||||
if (typeof file.size === 'number' &&
|
||||
file.size < this.options.minFileSize) {
|
||||
return 'minFileSize';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
_validate: function (files) {
|
||||
var that = this,
|
||||
valid = !!files.length;
|
||||
$.each(files, function (index, file) {
|
||||
file.error = that._hasError(file);
|
||||
if (file.error) {
|
||||
valid = false;
|
||||
}
|
||||
});
|
||||
return valid;
|
||||
},
|
||||
|
||||
_renderTemplate: function (func, files) {
|
||||
if (!func) {
|
||||
return $();
|
||||
}
|
||||
var result = func({
|
||||
files: files,
|
||||
formatFileSize: this._formatFileSize,
|
||||
options: this.options
|
||||
});
|
||||
if (result instanceof $) {
|
||||
return result;
|
||||
}
|
||||
return $(this.options.templatesContainer).html(result).children();
|
||||
},
|
||||
|
||||
_renderPreview: function (file, node) {
|
||||
var that = this,
|
||||
options = this.options,
|
||||
dfd = $.Deferred();
|
||||
return ((loadImage && loadImage(
|
||||
file,
|
||||
function (img) {
|
||||
node.append(img);
|
||||
that._forceReflow(node);
|
||||
that._transition(node).done(function () {
|
||||
dfd.resolveWith(node);
|
||||
});
|
||||
if (!$.contains(document.body, node[0])) {
|
||||
// If the element is not part of the DOM,
|
||||
// transition events are not triggered,
|
||||
// so we have to resolve manually:
|
||||
dfd.resolveWith(node);
|
||||
}
|
||||
},
|
||||
{
|
||||
maxWidth: options.previewMaxWidth,
|
||||
maxHeight: options.previewMaxHeight,
|
||||
canvas: options.previewAsCanvas
|
||||
}
|
||||
)) || dfd.resolveWith(node)) && dfd;
|
||||
},
|
||||
|
||||
_renderPreviews: function (files, nodes) {
|
||||
var that = this,
|
||||
options = this.options;
|
||||
nodes.find('.preview span').each(function (index, element) {
|
||||
var file = files[index];
|
||||
if (options.previewSourceFileTypes.test(file.type) &&
|
||||
($.type(options.previewSourceMaxFileSize) !== 'number' ||
|
||||
file.size < options.previewSourceMaxFileSize)) {
|
||||
that._processingQueue = that._processingQueue.pipe(function () {
|
||||
var dfd = $.Deferred();
|
||||
that._renderPreview(file, $(element)).done(
|
||||
function () {
|
||||
dfd.resolveWith(that);
|
||||
}
|
||||
);
|
||||
return dfd.promise();
|
||||
});
|
||||
}
|
||||
});
|
||||
return this._processingQueue;
|
||||
},
|
||||
|
||||
_renderUpload: function (files) {
|
||||
return this._renderTemplate(
|
||||
this.options.uploadTemplate,
|
||||
files
|
||||
);
|
||||
},
|
||||
|
||||
_renderDownload: function (files) {
|
||||
return this._renderTemplate(
|
||||
this.options.downloadTemplate,
|
||||
files
|
||||
).find('a[download]').each(this._enableDragToDesktop).end();
|
||||
},
|
||||
|
||||
_startHandler: function (e) {
|
||||
e.preventDefault();
|
||||
var button = $(this),
|
||||
template = button.closest('.template-upload'),
|
||||
data = template.data('data');
|
||||
if (data && data.submit && !data.jqXHR && data.submit()) {
|
||||
button.prop('disabled', true);
|
||||
}
|
||||
},
|
||||
|
||||
_cancelHandler: function (e) {
|
||||
e.preventDefault();
|
||||
var template = $(this).closest('.template-upload'),
|
||||
data = template.data('data') || {};
|
||||
if (!data.jqXHR) {
|
||||
data.errorThrown = 'abort';
|
||||
e.data.fileupload._trigger('fail', e, data);
|
||||
} else {
|
||||
data.jqXHR.abort();
|
||||
}
|
||||
},
|
||||
|
||||
_deleteHandler: function (e) {
|
||||
e.preventDefault();
|
||||
var button = $(this);
|
||||
e.data.fileupload._trigger('destroy', e, {
|
||||
context: button.closest('.template-download'),
|
||||
url: button.attr('data-url'),
|
||||
type: button.attr('data-type') || 'DELETE',
|
||||
dataType: e.data.fileupload.options.dataType
|
||||
});
|
||||
},
|
||||
|
||||
_forceReflow: function (node) {
|
||||
this._reflow = $.support.transition &&
|
||||
node.length && node[0].offsetWidth;
|
||||
},
|
||||
|
||||
_transition: function (node) {
|
||||
var dfd = $.Deferred();
|
||||
if ($.support.transition && node.hasClass('fade')) {
|
||||
node.bind(
|
||||
$.support.transition.end,
|
||||
function (e) {
|
||||
// Make sure we don't respond to other transitions events
|
||||
// in the container element, e.g. from button elements:
|
||||
if (e.target === node[0]) {
|
||||
node.unbind($.support.transition.end);
|
||||
dfd.resolveWith(node);
|
||||
}
|
||||
}
|
||||
).toggleClass('in');
|
||||
} else {
|
||||
node.toggleClass('in');
|
||||
dfd.resolveWith(node);
|
||||
}
|
||||
return dfd;
|
||||
},
|
||||
|
||||
_initButtonBarEventHandlers: function () {
|
||||
var fileUploadButtonBar = this.element.find('.fileupload-buttonbar'),
|
||||
filesList = this.options.filesContainer,
|
||||
ns = this.options.namespace;
|
||||
fileUploadButtonBar.find('.start')
|
||||
.bind('click.' + ns, function (e) {
|
||||
e.preventDefault();
|
||||
filesList.find('.start button').click();
|
||||
});
|
||||
fileUploadButtonBar.find('.cancel')
|
||||
.bind('click.' + ns, function (e) {
|
||||
e.preventDefault();
|
||||
filesList.find('.cancel button').click();
|
||||
});
|
||||
fileUploadButtonBar.find('.delete')
|
||||
.bind('click.' + ns, function (e) {
|
||||
e.preventDefault();
|
||||
filesList.find('.delete input:checked')
|
||||
.siblings('button').click();
|
||||
fileUploadButtonBar.find('.toggle')
|
||||
.prop('checked', false);
|
||||
});
|
||||
fileUploadButtonBar.find('.toggle')
|
||||
.bind('change.' + ns, function (e) {
|
||||
filesList.find('.delete input').prop(
|
||||
'checked',
|
||||
$(this).is(':checked')
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
_destroyButtonBarEventHandlers: function () {
|
||||
this.element.find('.fileupload-buttonbar button')
|
||||
.unbind('click.' + this.options.namespace);
|
||||
this.element.find('.fileupload-buttonbar .toggle')
|
||||
.unbind('change.' + this.options.namespace);
|
||||
},
|
||||
|
||||
_initEventHandlers: function () {
|
||||
parentWidget.prototype._initEventHandlers.call(this);
|
||||
var eventData = {fileupload: this};
|
||||
this.options.filesContainer
|
||||
.delegate(
|
||||
'.start button',
|
||||
'click.' + this.options.namespace,
|
||||
eventData,
|
||||
this._startHandler
|
||||
)
|
||||
.delegate(
|
||||
'.cancel button',
|
||||
'click.' + this.options.namespace,
|
||||
eventData,
|
||||
this._cancelHandler
|
||||
)
|
||||
.delegate(
|
||||
'.delete button',
|
||||
'click.' + this.options.namespace,
|
||||
eventData,
|
||||
this._deleteHandler
|
||||
);
|
||||
this._initButtonBarEventHandlers();
|
||||
},
|
||||
|
||||
_destroyEventHandlers: function () {
|
||||
var options = this.options;
|
||||
this._destroyButtonBarEventHandlers();
|
||||
options.filesContainer
|
||||
.undelegate('.start button', 'click.' + options.namespace)
|
||||
.undelegate('.cancel button', 'click.' + options.namespace)
|
||||
.undelegate('.delete button', 'click.' + options.namespace);
|
||||
parentWidget.prototype._destroyEventHandlers.call(this);
|
||||
},
|
||||
|
||||
_enableFileInputButton: function () {
|
||||
this.element.find('.fileinput-button input')
|
||||
.prop('disabled', false)
|
||||
.parent().removeClass('disabled');
|
||||
},
|
||||
|
||||
_disableFileInputButton: function () {
|
||||
this.element.find('.fileinput-button input')
|
||||
.prop('disabled', true)
|
||||
.parent().addClass('disabled');
|
||||
},
|
||||
|
||||
_initTemplates: function () {
|
||||
var options = this.options;
|
||||
options.templatesContainer = document.createElement(
|
||||
options.filesContainer.prop('nodeName')
|
||||
);
|
||||
if (tmpl) {
|
||||
if (options.uploadTemplateId) {
|
||||
options.uploadTemplate = tmpl(options.uploadTemplateId);
|
||||
}
|
||||
if (options.downloadTemplateId) {
|
||||
options.downloadTemplate = tmpl(options.downloadTemplateId);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_initFilesContainer: function () {
|
||||
var options = this.options;
|
||||
if (options.filesContainer === undefined) {
|
||||
options.filesContainer = this.element.find('.files');
|
||||
} else if (!(options.filesContainer instanceof $)) {
|
||||
options.filesContainer = $(options.filesContainer);
|
||||
}
|
||||
},
|
||||
|
||||
_initSpecialOptions: function () {
|
||||
parentWidget.prototype._initSpecialOptions.call(this);
|
||||
this._initFilesContainer();
|
||||
this._initTemplates();
|
||||
},
|
||||
|
||||
_create: function () {
|
||||
parentWidget.prototype._create.call(this);
|
||||
this._refreshOptionsList.push(
|
||||
'filesContainer',
|
||||
'uploadTemplateId',
|
||||
'downloadTemplateId'
|
||||
);
|
||||
if (!$.blueimpFP) {
|
||||
this._processingQueue = $.Deferred().resolveWith(this).promise();
|
||||
this.process = function () {
|
||||
return this._processingQueue;
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
enable: function () {
|
||||
parentWidget.prototype.enable.call(this);
|
||||
this.element.find('input, button').prop('disabled', false);
|
||||
this._enableFileInputButton();
|
||||
},
|
||||
|
||||
disable: function () {
|
||||
this.element.find('input, button').prop('disabled', true);
|
||||
this._disableFileInputButton();
|
||||
parentWidget.prototype.disable.call(this);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}));
|
949
media/js/jquery.fileupload.js
vendored
Normal file
949
media/js/jquery.fileupload.js
vendored
Normal file
@@ -0,0 +1,949 @@
|
||||
/*
|
||||
* jQuery File Upload Plugin 5.11.2
|
||||
* https://github.com/blueimp/jQuery-File-Upload
|
||||
*
|
||||
* Copyright 2010, Sebastian Tschan
|
||||
* https://blueimp.net
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* http://www.opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
/*jslint nomen: true, unparam: true, regexp: true */
|
||||
/*global define, window, document, Blob, FormData, location */
|
||||
|
||||
(function (factory) {
|
||||
'use strict';
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// Register as an anonymous AMD module:
|
||||
define([
|
||||
'jquery',
|
||||
'jquery.ui.widget'
|
||||
], factory);
|
||||
} else {
|
||||
// Browser globals:
|
||||
factory(window.jQuery);
|
||||
}
|
||||
}(function ($) {
|
||||
'use strict';
|
||||
|
||||
// The FileReader API is not actually used, but works as feature detection,
|
||||
// as e.g. Safari supports XHR file uploads via the FormData API,
|
||||
// but not non-multipart XHR file uploads:
|
||||
$.support.xhrFileUpload = !!(window.XMLHttpRequestUpload && window.FileReader);
|
||||
$.support.xhrFormDataFileUpload = !!window.FormData;
|
||||
|
||||
// The fileupload widget listens for change events on file input fields defined
|
||||
// via fileInput setting and paste or drop events of the given dropZone.
|
||||
// In addition to the default jQuery Widget methods, the fileupload widget
|
||||
// exposes the "add" and "send" methods, to add or directly send files using
|
||||
// the fileupload API.
|
||||
// By default, files added via file input selection, paste, drag & drop or
|
||||
// "add" method are uploaded immediately, but it is possible to override
|
||||
// the "add" callback option to queue file uploads.
|
||||
$.widget('blueimp.fileupload', {
|
||||
|
||||
options: {
|
||||
// The namespace used for event handler binding on the dropZone and
|
||||
// fileInput collections.
|
||||
// If not set, the name of the widget ("fileupload") is used.
|
||||
namespace: undefined,
|
||||
// The drop target collection, by the default the complete document.
|
||||
// Set to null or an empty collection to disable drag & drop support:
|
||||
dropZone: $(document),
|
||||
// The file input field collection, that is listened for change events.
|
||||
// If undefined, it is set to the file input fields inside
|
||||
// of the widget element on plugin initialization.
|
||||
// Set to null or an empty collection to disable the change listener.
|
||||
fileInput: undefined,
|
||||
// By default, the file input field is replaced with a clone after
|
||||
// each input field change event. This is required for iframe transport
|
||||
// queues and allows change events to be fired for the same file
|
||||
// selection, but can be disabled by setting the following option to false:
|
||||
replaceFileInput: true,
|
||||
// The parameter name for the file form data (the request argument name).
|
||||
// If undefined or empty, the name property of the file input field is
|
||||
// used, or "files[]" if the file input name property is also empty,
|
||||
// can be a string or an array of strings:
|
||||
paramName: undefined,
|
||||
// By default, each file of a selection is uploaded using an individual
|
||||
// request for XHR type uploads. Set to false to upload file
|
||||
// selections in one request each:
|
||||
singleFileUploads: true,
|
||||
// To limit the number of files uploaded with one XHR request,
|
||||
// set the following option to an integer greater than 0:
|
||||
limitMultiFileUploads: undefined,
|
||||
// Set the following option to true to issue all file upload requests
|
||||
// in a sequential order:
|
||||
sequentialUploads: false,
|
||||
// To limit the number of concurrent uploads,
|
||||
// set the following option to an integer greater than 0:
|
||||
limitConcurrentUploads: undefined,
|
||||
// Set the following option to true to force iframe transport uploads:
|
||||
forceIframeTransport: false,
|
||||
// Set the following option to the location of a redirect url on the
|
||||
// origin server, for cross-domain iframe transport uploads:
|
||||
redirect: undefined,
|
||||
// The parameter name for the redirect url, sent as part of the form
|
||||
// data and set to 'redirect' if this option is empty:
|
||||
redirectParamName: undefined,
|
||||
// Set the following option to the location of a postMessage window,
|
||||
// to enable postMessage transport uploads:
|
||||
postMessage: undefined,
|
||||
// By default, XHR file uploads are sent as multipart/form-data.
|
||||
// The iframe transport is always using multipart/form-data.
|
||||
// Set to false to enable non-multipart XHR uploads:
|
||||
multipart: true,
|
||||
// To upload large files in smaller chunks, set the following option
|
||||
// to a preferred maximum chunk size. If set to 0, null or undefined,
|
||||
// or the browser does not support the required Blob API, files will
|
||||
// be uploaded as a whole.
|
||||
maxChunkSize: undefined,
|
||||
// When a non-multipart upload or a chunked multipart upload has been
|
||||
// aborted, this option can be used to resume the upload by setting
|
||||
// it to the size of the already uploaded bytes. This option is most
|
||||
// useful when modifying the options object inside of the "add" or
|
||||
// "send" callbacks, as the options are cloned for each file upload.
|
||||
uploadedBytes: undefined,
|
||||
// By default, failed (abort or error) file uploads are removed from the
|
||||
// global progress calculation. Set the following option to false to
|
||||
// prevent recalculating the global progress data:
|
||||
recalculateProgress: true,
|
||||
// Interval in milliseconds to calculate and trigger progress events:
|
||||
progressInterval: 100,
|
||||
// Interval in milliseconds to calculate progress bitrate:
|
||||
bitrateInterval: 500,
|
||||
|
||||
// Additional form data to be sent along with the file uploads can be set
|
||||
// using this option, which accepts an array of objects with name and
|
||||
// value properties, a function returning such an array, a FormData
|
||||
// object (for XHR file uploads), or a simple object.
|
||||
// The form of the first fileInput is given as parameter to the function:
|
||||
formData: function (form) {
|
||||
return form.serializeArray();
|
||||
},
|
||||
|
||||
// The add callback is invoked as soon as files are added to the fileupload
|
||||
// widget (via file input selection, drag & drop, paste or add API call).
|
||||
// If the singleFileUploads option is enabled, this callback will be
|
||||
// called once for each file in the selection for XHR file uplaods, else
|
||||
// once for each file selection.
|
||||
// The upload starts when the submit method is invoked on the data parameter.
|
||||
// The data object contains a files property holding the added files
|
||||
// and allows to override plugin options as well as define ajax settings.
|
||||
// Listeners for this callback can also be bound the following way:
|
||||
// .bind('fileuploadadd', func);
|
||||
// data.submit() returns a Promise object and allows to attach additional
|
||||
// handlers using jQuery's Deferred callbacks:
|
||||
// data.submit().done(func).fail(func).always(func);
|
||||
add: function (e, data) {
|
||||
data.submit();
|
||||
},
|
||||
|
||||
// Other callbacks:
|
||||
// Callback for the submit event of each file upload:
|
||||
// submit: function (e, data) {}, // .bind('fileuploadsubmit', func);
|
||||
// Callback for the start of each file upload request:
|
||||
// send: function (e, data) {}, // .bind('fileuploadsend', func);
|
||||
// Callback for successful uploads:
|
||||
// done: function (e, data) {}, // .bind('fileuploaddone', func);
|
||||
// Callback for failed (abort or error) uploads:
|
||||
// fail: function (e, data) {}, // .bind('fileuploadfail', func);
|
||||
// Callback for completed (success, abort or error) requests:
|
||||
// always: function (e, data) {}, // .bind('fileuploadalways', func);
|
||||
// Callback for upload progress events:
|
||||
// progress: function (e, data) {}, // .bind('fileuploadprogress', func);
|
||||
// Callback for global upload progress events:
|
||||
// progressall: function (e, data) {}, // .bind('fileuploadprogressall', func);
|
||||
// Callback for uploads start, equivalent to the global ajaxStart event:
|
||||
// start: function (e) {}, // .bind('fileuploadstart', func);
|
||||
// Callback for uploads stop, equivalent to the global ajaxStop event:
|
||||
// stop: function (e) {}, // .bind('fileuploadstop', func);
|
||||
// Callback for change events of the fileInput collection:
|
||||
// change: function (e, data) {}, // .bind('fileuploadchange', func);
|
||||
// Callback for paste events to the dropZone collection:
|
||||
// paste: function (e, data) {}, // .bind('fileuploadpaste', func);
|
||||
// Callback for drop events of the dropZone collection:
|
||||
// drop: function (e, data) {}, // .bind('fileuploaddrop', func);
|
||||
// Callback for dragover events of the dropZone collection:
|
||||
// dragover: function (e) {}, // .bind('fileuploaddragover', func);
|
||||
|
||||
// The plugin options are used as settings object for the ajax calls.
|
||||
// The following are jQuery ajax settings required for the file uploads:
|
||||
processData: false,
|
||||
contentType: false,
|
||||
cache: false
|
||||
},
|
||||
|
||||
// A list of options that require a refresh after assigning a new value:
|
||||
_refreshOptionsList: [
|
||||
'namespace',
|
||||
'dropZone',
|
||||
'fileInput',
|
||||
'multipart',
|
||||
'forceIframeTransport'
|
||||
],
|
||||
|
||||
_BitrateTimer: function () {
|
||||
this.timestamp = +(new Date());
|
||||
this.loaded = 0;
|
||||
this.bitrate = 0;
|
||||
this.getBitrate = function (now, loaded, interval) {
|
||||
var timeDiff = now - this.timestamp;
|
||||
if (!this.bitrate || !interval || timeDiff > interval) {
|
||||
this.bitrate = (loaded - this.loaded) * (1000 / timeDiff) * 8;
|
||||
this.loaded = loaded;
|
||||
this.timestamp = now;
|
||||
}
|
||||
return this.bitrate;
|
||||
};
|
||||
},
|
||||
|
||||
_isXHRUpload: function (options) {
|
||||
return !options.forceIframeTransport &&
|
||||
((!options.multipart && $.support.xhrFileUpload) ||
|
||||
$.support.xhrFormDataFileUpload);
|
||||
},
|
||||
|
||||
_getFormData: function (options) {
|
||||
var formData;
|
||||
if (typeof options.formData === 'function') {
|
||||
return options.formData(options.form);
|
||||
}
|
||||
if ($.isArray(options.formData)) {
|
||||
return options.formData;
|
||||
}
|
||||
if (options.formData) {
|
||||
formData = [];
|
||||
$.each(options.formData, function (name, value) {
|
||||
formData.push({name: name, value: value});
|
||||
});
|
||||
return formData;
|
||||
}
|
||||
return [];
|
||||
},
|
||||
|
||||
_getTotal: function (files) {
|
||||
var total = 0;
|
||||
$.each(files, function (index, file) {
|
||||
total += file.size || 1;
|
||||
});
|
||||
return total;
|
||||
},
|
||||
|
||||
_onProgress: function (e, data) {
|
||||
if (e.lengthComputable) {
|
||||
var now = +(new Date()),
|
||||
total,
|
||||
loaded;
|
||||
if (data._time && data.progressInterval &&
|
||||
(now - data._time < data.progressInterval) &&
|
||||
e.loaded !== e.total) {
|
||||
return;
|
||||
}
|
||||
data._time = now;
|
||||
total = data.total || this._getTotal(data.files);
|
||||
loaded = parseInt(
|
||||
e.loaded / e.total * (data.chunkSize || total),
|
||||
10
|
||||
) + (data.uploadedBytes || 0);
|
||||
this._loaded += loaded - (data.loaded || data.uploadedBytes || 0);
|
||||
data.lengthComputable = true;
|
||||
data.loaded = loaded;
|
||||
data.total = total;
|
||||
data.bitrate = data._bitrateTimer.getBitrate(
|
||||
now,
|
||||
loaded,
|
||||
data.bitrateInterval
|
||||
);
|
||||
// Trigger a custom progress event with a total data property set
|
||||
// to the file size(s) of the current upload and a loaded data
|
||||
// property calculated accordingly:
|
||||
this._trigger('progress', e, data);
|
||||
// Trigger a global progress event for all current file uploads,
|
||||
// including ajax calls queued for sequential file uploads:
|
||||
this._trigger('progressall', e, {
|
||||
lengthComputable: true,
|
||||
loaded: this._loaded,
|
||||
total: this._total,
|
||||
bitrate: this._bitrateTimer.getBitrate(
|
||||
now,
|
||||
this._loaded,
|
||||
data.bitrateInterval
|
||||
)
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
_initProgressListener: function (options) {
|
||||
var that = this,
|
||||
xhr = options.xhr ? options.xhr() : $.ajaxSettings.xhr();
|
||||
// Accesss to the native XHR object is required to add event listeners
|
||||
// for the upload progress event:
|
||||
if (xhr.upload) {
|
||||
$(xhr.upload).bind('progress', function (e) {
|
||||
var oe = e.originalEvent;
|
||||
// Make sure the progress event properties get copied over:
|
||||
e.lengthComputable = oe.lengthComputable;
|
||||
e.loaded = oe.loaded;
|
||||
e.total = oe.total;
|
||||
that._onProgress(e, options);
|
||||
});
|
||||
options.xhr = function () {
|
||||
return xhr;
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
_initXHRData: function (options) {
|
||||
var formData,
|
||||
file = options.files[0],
|
||||
// Ignore non-multipart setting if not supported:
|
||||
multipart = options.multipart || !$.support.xhrFileUpload,
|
||||
paramName = options.paramName[0];
|
||||
if (!multipart || options.blob) {
|
||||
// For non-multipart uploads and chunked uploads,
|
||||
// file meta data is not part of the request body,
|
||||
// so we transmit this data as part of the HTTP headers.
|
||||
// For cross domain requests, these headers must be allowed
|
||||
// via Access-Control-Allow-Headers or removed using
|
||||
// the beforeSend callback:
|
||||
options.headers = $.extend(options.headers, {
|
||||
'X-File-Name': file.name,
|
||||
'X-File-Type': file.type,
|
||||
'X-File-Size': file.size
|
||||
});
|
||||
if (!options.blob) {
|
||||
// Non-chunked non-multipart upload:
|
||||
options.contentType = file.type;
|
||||
options.data = file;
|
||||
} else if (!multipart) {
|
||||
// Chunked non-multipart upload:
|
||||
options.contentType = 'application/octet-stream';
|
||||
options.data = options.blob;
|
||||
}
|
||||
}
|
||||
if (multipart && $.support.xhrFormDataFileUpload) {
|
||||
if (options.postMessage) {
|
||||
// window.postMessage does not allow sending FormData
|
||||
// objects, so we just add the File/Blob objects to
|
||||
// the formData array and let the postMessage window
|
||||
// create the FormData object out of this array:
|
||||
formData = this._getFormData(options);
|
||||
if (options.blob) {
|
||||
formData.push({
|
||||
name: paramName,
|
||||
value: options.blob
|
||||
});
|
||||
} else {
|
||||
$.each(options.files, function (index, file) {
|
||||
formData.push({
|
||||
name: options.paramName[index] || paramName,
|
||||
value: file
|
||||
});
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (options.formData instanceof FormData) {
|
||||
formData = options.formData;
|
||||
} else {
|
||||
formData = new FormData();
|
||||
$.each(this._getFormData(options), function (index, field) {
|
||||
formData.append(field.name, field.value);
|
||||
});
|
||||
}
|
||||
if (options.blob) {
|
||||
formData.append(paramName, options.blob, file.name);
|
||||
} else {
|
||||
$.each(options.files, function (index, file) {
|
||||
// File objects are also Blob instances.
|
||||
// This check allows the tests to run with
|
||||
// dummy objects:
|
||||
if (file instanceof Blob) {
|
||||
formData.append(
|
||||
options.paramName[index] || paramName,
|
||||
file,
|
||||
file.name
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
options.data = formData;
|
||||
}
|
||||
// Blob reference is not needed anymore, free memory:
|
||||
options.blob = null;
|
||||
},
|
||||
|
||||
_initIframeSettings: function (options) {
|
||||
// Setting the dataType to iframe enables the iframe transport:
|
||||
options.dataType = 'iframe ' + (options.dataType || '');
|
||||
// The iframe transport accepts a serialized array as form data:
|
||||
options.formData = this._getFormData(options);
|
||||
// Add redirect url to form data on cross-domain uploads:
|
||||
if (options.redirect && $('<a></a>').prop('href', options.url)
|
||||
.prop('host') !== location.host) {
|
||||
options.formData.push({
|
||||
name: options.redirectParamName || 'redirect',
|
||||
value: options.redirect
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
_initDataSettings: function (options) {
|
||||
if (this._isXHRUpload(options)) {
|
||||
if (!this._chunkedUpload(options, true)) {
|
||||
if (!options.data) {
|
||||
this._initXHRData(options);
|
||||
}
|
||||
this._initProgressListener(options);
|
||||
}
|
||||
if (options.postMessage) {
|
||||
// Setting the dataType to postmessage enables the
|
||||
// postMessage transport:
|
||||
options.dataType = 'postmessage ' + (options.dataType || '');
|
||||
}
|
||||
} else {
|
||||
this._initIframeSettings(options, 'iframe');
|
||||
}
|
||||
},
|
||||
|
||||
_getParamName: function (options) {
|
||||
var fileInput = $(options.fileInput),
|
||||
paramName = options.paramName;
|
||||
if (!paramName) {
|
||||
paramName = [];
|
||||
fileInput.each(function () {
|
||||
var input = $(this),
|
||||
name = input.prop('name') || 'files[]',
|
||||
i = (input.prop('files') || [1]).length;
|
||||
while (i) {
|
||||
paramName.push(name);
|
||||
i -= 1;
|
||||
}
|
||||
});
|
||||
if (!paramName.length) {
|
||||
paramName = [fileInput.prop('name') || 'files[]'];
|
||||
}
|
||||
} else if (!$.isArray(paramName)) {
|
||||
paramName = [paramName];
|
||||
}
|
||||
return paramName;
|
||||
},
|
||||
|
||||
_initFormSettings: function (options) {
|
||||
// Retrieve missing options from the input field and the
|
||||
// associated form, if available:
|
||||
if (!options.form || !options.form.length) {
|
||||
options.form = $(options.fileInput.prop('form'));
|
||||
}
|
||||
options.paramName = this._getParamName(options);
|
||||
if (!options.url) {
|
||||
options.url = options.form.prop('action') || location.href;
|
||||
}
|
||||
// The HTTP request method must be "POST" or "PUT":
|
||||
options.type = (options.type || options.form.prop('method') || '')
|
||||
.toUpperCase();
|
||||
if (options.type !== 'POST' && options.type !== 'PUT') {
|
||||
options.type = 'POST';
|
||||
}
|
||||
},
|
||||
|
||||
_getAJAXSettings: function (data) {
|
||||
var options = $.extend({}, this.options, data);
|
||||
this._initFormSettings(options);
|
||||
this._initDataSettings(options);
|
||||
return options;
|
||||
},
|
||||
|
||||
// Maps jqXHR callbacks to the equivalent
|
||||
// methods of the given Promise object:
|
||||
_enhancePromise: function (promise) {
|
||||
promise.success = promise.done;
|
||||
promise.error = promise.fail;
|
||||
promise.complete = promise.always;
|
||||
return promise;
|
||||
},
|
||||
|
||||
// Creates and returns a Promise object enhanced with
|
||||
// the jqXHR methods abort, success, error and complete:
|
||||
_getXHRPromise: function (resolveOrReject, context, args) {
|
||||
var dfd = $.Deferred(),
|
||||
promise = dfd.promise();
|
||||
context = context || this.options.context || promise;
|
||||
if (resolveOrReject === true) {
|
||||
dfd.resolveWith(context, args);
|
||||
} else if (resolveOrReject === false) {
|
||||
dfd.rejectWith(context, args);
|
||||
}
|
||||
promise.abort = dfd.promise;
|
||||
return this._enhancePromise(promise);
|
||||
},
|
||||
|
||||
// Uploads a file in multiple, sequential requests
|
||||
// by splitting the file up in multiple blob chunks.
|
||||
// If the second parameter is true, only tests if the file
|
||||
// should be uploaded in chunks, but does not invoke any
|
||||
// upload requests:
|
||||
_chunkedUpload: function (options, testOnly) {
|
||||
var that = this,
|
||||
file = options.files[0],
|
||||
fs = file.size,
|
||||
ub = options.uploadedBytes = options.uploadedBytes || 0,
|
||||
mcs = options.maxChunkSize || fs,
|
||||
// Use the Blob methods with the slice implementation
|
||||
// according to the W3C Blob API specification:
|
||||
slice = file.webkitSlice || file.mozSlice || file.slice,
|
||||
upload,
|
||||
n,
|
||||
jqXHR,
|
||||
pipe;
|
||||
if (!(this._isXHRUpload(options) && slice && (ub || mcs < fs)) ||
|
||||
options.data) {
|
||||
return false;
|
||||
}
|
||||
if (testOnly) {
|
||||
return true;
|
||||
}
|
||||
if (ub >= fs) {
|
||||
file.error = 'uploadedBytes';
|
||||
return this._getXHRPromise(
|
||||
false,
|
||||
options.context,
|
||||
[null, 'error', file.error]
|
||||
);
|
||||
}
|
||||
// n is the number of blobs to upload,
|
||||
// calculated via filesize, uploaded bytes and max chunk size:
|
||||
n = Math.ceil((fs - ub) / mcs);
|
||||
// The chunk upload method accepting the chunk number as parameter:
|
||||
upload = function (i) {
|
||||
if (!i) {
|
||||
return that._getXHRPromise(true, options.context);
|
||||
}
|
||||
// Upload the blobs in sequential order:
|
||||
return upload(i -= 1).pipe(function () {
|
||||
// Clone the options object for each chunk upload:
|
||||
var o = $.extend({}, options);
|
||||
o.blob = slice.call(
|
||||
file,
|
||||
ub + i * mcs,
|
||||
ub + (i + 1) * mcs
|
||||
);
|
||||
// Store the current chunk size, as the blob itself
|
||||
// will be dereferenced after data processing:
|
||||
o.chunkSize = o.blob.size;
|
||||
// Process the upload data (the blob and potential form data):
|
||||
that._initXHRData(o);
|
||||
// Add progress listeners for this chunk upload:
|
||||
that._initProgressListener(o);
|
||||
jqXHR = ($.ajax(o) || that._getXHRPromise(false, o.context))
|
||||
.done(function () {
|
||||
// Create a progress event if upload is done and
|
||||
// no progress event has been invoked for this chunk:
|
||||
if (!o.loaded) {
|
||||
that._onProgress($.Event('progress', {
|
||||
lengthComputable: true,
|
||||
loaded: o.chunkSize,
|
||||
total: o.chunkSize
|
||||
}), o);
|
||||
}
|
||||
options.uploadedBytes = o.uploadedBytes +=
|
||||
o.chunkSize;
|
||||
});
|
||||
return jqXHR;
|
||||
});
|
||||
};
|
||||
// Return the piped Promise object, enhanced with an abort method,
|
||||
// which is delegated to the jqXHR object of the current upload,
|
||||
// and jqXHR callbacks mapped to the equivalent Promise methods:
|
||||
pipe = upload(n);
|
||||
pipe.abort = function () {
|
||||
return jqXHR.abort();
|
||||
};
|
||||
return this._enhancePromise(pipe);
|
||||
},
|
||||
|
||||
_beforeSend: function (e, data) {
|
||||
if (this._active === 0) {
|
||||
// the start callback is triggered when an upload starts
|
||||
// and no other uploads are currently running,
|
||||
// equivalent to the global ajaxStart event:
|
||||
this._trigger('start');
|
||||
// Set timer for global bitrate progress calculation:
|
||||
this._bitrateTimer = new this._BitrateTimer();
|
||||
}
|
||||
this._active += 1;
|
||||
// Initialize the global progress values:
|
||||
this._loaded += data.uploadedBytes || 0;
|
||||
this._total += this._getTotal(data.files);
|
||||
},
|
||||
|
||||
_onDone: function (result, textStatus, jqXHR, options) {
|
||||
if (!this._isXHRUpload(options)) {
|
||||
// Create a progress event for each iframe load:
|
||||
this._onProgress($.Event('progress', {
|
||||
lengthComputable: true,
|
||||
loaded: 1,
|
||||
total: 1
|
||||
}), options);
|
||||
}
|
||||
options.result = result;
|
||||
options.textStatus = textStatus;
|
||||
options.jqXHR = jqXHR;
|
||||
this._trigger('done', null, options);
|
||||
},
|
||||
|
||||
_onFail: function (jqXHR, textStatus, errorThrown, options) {
|
||||
options.jqXHR = jqXHR;
|
||||
options.textStatus = textStatus;
|
||||
options.errorThrown = errorThrown;
|
||||
this._trigger('fail', null, options);
|
||||
if (options.recalculateProgress) {
|
||||
// Remove the failed (error or abort) file upload from
|
||||
// the global progress calculation:
|
||||
this._loaded -= options.loaded || options.uploadedBytes || 0;
|
||||
this._total -= options.total || this._getTotal(options.files);
|
||||
}
|
||||
},
|
||||
|
||||
_onAlways: function (jqXHRorResult, textStatus, jqXHRorError, options) {
|
||||
this._active -= 1;
|
||||
options.textStatus = textStatus;
|
||||
if (jqXHRorError && jqXHRorError.always) {
|
||||
options.jqXHR = jqXHRorError;
|
||||
options.result = jqXHRorResult;
|
||||
} else {
|
||||
options.jqXHR = jqXHRorResult;
|
||||
options.errorThrown = jqXHRorError;
|
||||
}
|
||||
this._trigger('always', null, options);
|
||||
if (this._active === 0) {
|
||||
// The stop callback is triggered when all uploads have
|
||||
// been completed, equivalent to the global ajaxStop event:
|
||||
this._trigger('stop');
|
||||
// Reset the global progress values:
|
||||
this._loaded = this._total = 0;
|
||||
this._bitrateTimer = null;
|
||||
}
|
||||
},
|
||||
|
||||
_onSend: function (e, data) {
|
||||
var that = this,
|
||||
jqXHR,
|
||||
slot,
|
||||
pipe,
|
||||
options = that._getAJAXSettings(data),
|
||||
send = function (resolve, args) {
|
||||
that._sending += 1;
|
||||
// Set timer for bitrate progress calculation:
|
||||
options._bitrateTimer = new that._BitrateTimer();
|
||||
jqXHR = jqXHR || (
|
||||
(resolve !== false &&
|
||||
that._trigger('send', e, options) !== false &&
|
||||
(that._chunkedUpload(options) || $.ajax(options))) ||
|
||||
that._getXHRPromise(false, options.context, args)
|
||||
).done(function (result, textStatus, jqXHR) {
|
||||
that._onDone(result, textStatus, jqXHR, options);
|
||||
}).fail(function (jqXHR, textStatus, errorThrown) {
|
||||
that._onFail(jqXHR, textStatus, errorThrown, options);
|
||||
}).always(function (jqXHRorResult, textStatus, jqXHRorError) {
|
||||
that._sending -= 1;
|
||||
that._onAlways(
|
||||
jqXHRorResult,
|
||||
textStatus,
|
||||
jqXHRorError,
|
||||
options
|
||||
);
|
||||
if (options.limitConcurrentUploads &&
|
||||
options.limitConcurrentUploads > that._sending) {
|
||||
// Start the next queued upload,
|
||||
// that has not been aborted:
|
||||
var nextSlot = that._slots.shift();
|
||||
while (nextSlot) {
|
||||
if (!nextSlot.isRejected()) {
|
||||
nextSlot.resolve();
|
||||
break;
|
||||
}
|
||||
nextSlot = that._slots.shift();
|
||||
}
|
||||
}
|
||||
});
|
||||
return jqXHR;
|
||||
};
|
||||
this._beforeSend(e, options);
|
||||
if (this.options.sequentialUploads ||
|
||||
(this.options.limitConcurrentUploads &&
|
||||
this.options.limitConcurrentUploads <= this._sending)) {
|
||||
if (this.options.limitConcurrentUploads > 1) {
|
||||
slot = $.Deferred();
|
||||
this._slots.push(slot);
|
||||
pipe = slot.pipe(send);
|
||||
} else {
|
||||
pipe = (this._sequence = this._sequence.pipe(send, send));
|
||||
}
|
||||
// Return the piped Promise object, enhanced with an abort method,
|
||||
// which is delegated to the jqXHR object of the current upload,
|
||||
// and jqXHR callbacks mapped to the equivalent Promise methods:
|
||||
pipe.abort = function () {
|
||||
var args = [undefined, 'abort', 'abort'];
|
||||
if (!jqXHR) {
|
||||
if (slot) {
|
||||
slot.rejectWith(args);
|
||||
}
|
||||
return send(false, args);
|
||||
}
|
||||
return jqXHR.abort();
|
||||
};
|
||||
return this._enhancePromise(pipe);
|
||||
}
|
||||
return send();
|
||||
},
|
||||
|
||||
_onAdd: function (e, data) {
|
||||
var that = this,
|
||||
result = true,
|
||||
options = $.extend({}, this.options, data),
|
||||
limit = options.limitMultiFileUploads,
|
||||
paramName = this._getParamName(options),
|
||||
paramNameSet,
|
||||
paramNameSlice,
|
||||
fileSet,
|
||||
i;
|
||||
if (!(options.singleFileUploads || limit) ||
|
||||
!this._isXHRUpload(options)) {
|
||||
fileSet = [data.files];
|
||||
paramNameSet = [paramName];
|
||||
} else if (!options.singleFileUploads && limit) {
|
||||
fileSet = [];
|
||||
paramNameSet = [];
|
||||
for (i = 0; i < data.files.length; i += limit) {
|
||||
fileSet.push(data.files.slice(i, i + limit));
|
||||
paramNameSlice = paramName.slice(i, i + limit);
|
||||
if (!paramNameSlice.length) {
|
||||
paramNameSlice = paramName;
|
||||
}
|
||||
paramNameSet.push(paramNameSlice);
|
||||
}
|
||||
} else {
|
||||
paramNameSet = paramName;
|
||||
}
|
||||
data.originalFiles = data.files;
|
||||
$.each(fileSet || data.files, function (index, element) {
|
||||
var newData = $.extend({}, data);
|
||||
newData.files = fileSet ? element : [element];
|
||||
newData.paramName = paramNameSet[index];
|
||||
newData.submit = function () {
|
||||
newData.jqXHR = this.jqXHR =
|
||||
(that._trigger('submit', e, this) !== false) &&
|
||||
that._onSend(e, this);
|
||||
return this.jqXHR;
|
||||
};
|
||||
return (result = that._trigger('add', e, newData));
|
||||
});
|
||||
return result;
|
||||
},
|
||||
|
||||
// File Normalization for Gecko 1.9.1 (Firefox 3.5) support:
|
||||
_normalizeFile: function (index, file) {
|
||||
if (file.name === undefined && file.size === undefined) {
|
||||
file.name = file.fileName;
|
||||
file.size = file.fileSize;
|
||||
}
|
||||
},
|
||||
|
||||
_replaceFileInput: function (input) {
|
||||
var inputClone = input.clone(true);
|
||||
$('<form></form>').append(inputClone)[0].reset();
|
||||
// Detaching allows to insert the fileInput on another form
|
||||
// without loosing the file input value:
|
||||
input.after(inputClone).detach();
|
||||
// Avoid memory leaks with the detached file input:
|
||||
$.cleanData(input.unbind('remove'));
|
||||
// Replace the original file input element in the fileInput
|
||||
// collection with the clone, which has been copied including
|
||||
// event handlers:
|
||||
this.options.fileInput = this.options.fileInput.map(function (i, el) {
|
||||
if (el === input[0]) {
|
||||
return inputClone[0];
|
||||
}
|
||||
return el;
|
||||
});
|
||||
// If the widget has been initialized on the file input itself,
|
||||
// override this.element with the file input clone:
|
||||
if (input[0] === this.element[0]) {
|
||||
this.element = inputClone;
|
||||
}
|
||||
},
|
||||
|
||||
_onChange: function (e) {
|
||||
var that = e.data.fileupload,
|
||||
data = {
|
||||
files: $.each($.makeArray(e.target.files), that._normalizeFile),
|
||||
fileInput: $(e.target),
|
||||
form: $(e.target.form)
|
||||
};
|
||||
if (!data.files.length) {
|
||||
// If the files property is not available, the browser does not
|
||||
// support the File API and we add a pseudo File object with
|
||||
// the input value as name with path information removed:
|
||||
data.files = [{name: e.target.value.replace(/^.*\\/, '')}];
|
||||
}
|
||||
if (that.options.replaceFileInput) {
|
||||
that._replaceFileInput(data.fileInput);
|
||||
}
|
||||
if (that._trigger('change', e, data) === false ||
|
||||
that._onAdd(e, data) === false) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
_onPaste: function (e) {
|
||||
var that = e.data.fileupload,
|
||||
cbd = e.originalEvent.clipboardData,
|
||||
items = (cbd && cbd.items) || [],
|
||||
data = {files: []};
|
||||
$.each(items, function (index, item) {
|
||||
var file = item.getAsFile && item.getAsFile();
|
||||
if (file) {
|
||||
data.files.push(file);
|
||||
}
|
||||
});
|
||||
if (that._trigger('paste', e, data) === false ||
|
||||
that._onAdd(e, data) === false) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
_onDrop: function (e) {
|
||||
var that = e.data.fileupload,
|
||||
dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer,
|
||||
data = {
|
||||
files: $.each(
|
||||
$.makeArray(dataTransfer && dataTransfer.files),
|
||||
that._normalizeFile
|
||||
)
|
||||
};
|
||||
if (that._trigger('drop', e, data) === false ||
|
||||
that._onAdd(e, data) === false) {
|
||||
return false;
|
||||
}
|
||||
e.preventDefault();
|
||||
},
|
||||
|
||||
_onDragOver: function (e) {
|
||||
var that = e.data.fileupload,
|
||||
dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer;
|
||||
if (that._trigger('dragover', e) === false) {
|
||||
return false;
|
||||
}
|
||||
if (dataTransfer) {
|
||||
dataTransfer.dropEffect = dataTransfer.effectAllowed = 'copy';
|
||||
}
|
||||
e.preventDefault();
|
||||
},
|
||||
|
||||
_initEventHandlers: function () {
|
||||
var ns = this.options.namespace;
|
||||
if (this._isXHRUpload(this.options)) {
|
||||
this.options.dropZone
|
||||
.bind('dragover.' + ns, {fileupload: this}, this._onDragOver)
|
||||
.bind('drop.' + ns, {fileupload: this}, this._onDrop)
|
||||
.bind('paste.' + ns, {fileupload: this}, this._onPaste);
|
||||
}
|
||||
this.options.fileInput
|
||||
.bind('change.' + ns, {fileupload: this}, this._onChange);
|
||||
},
|
||||
|
||||
_destroyEventHandlers: function () {
|
||||
var ns = this.options.namespace;
|
||||
this.options.dropZone
|
||||
.unbind('dragover.' + ns, this._onDragOver)
|
||||
.unbind('drop.' + ns, this._onDrop)
|
||||
.unbind('paste.' + ns, this._onPaste);
|
||||
this.options.fileInput
|
||||
.unbind('change.' + ns, this._onChange);
|
||||
},
|
||||
|
||||
_setOption: function (key, value) {
|
||||
var refresh = $.inArray(key, this._refreshOptionsList) !== -1;
|
||||
if (refresh) {
|
||||
this._destroyEventHandlers();
|
||||
}
|
||||
$.Widget.prototype._setOption.call(this, key, value);
|
||||
if (refresh) {
|
||||
this._initSpecialOptions();
|
||||
this._initEventHandlers();
|
||||
}
|
||||
},
|
||||
|
||||
_initSpecialOptions: function () {
|
||||
var options = this.options;
|
||||
if (options.fileInput === undefined) {
|
||||
options.fileInput = this.element.is('input:file') ?
|
||||
this.element : this.element.find('input:file');
|
||||
} else if (!(options.fileInput instanceof $)) {
|
||||
options.fileInput = $(options.fileInput);
|
||||
}
|
||||
if (!(options.dropZone instanceof $)) {
|
||||
options.dropZone = $(options.dropZone);
|
||||
}
|
||||
},
|
||||
|
||||
_create: function () {
|
||||
var options = this.options;
|
||||
// Initialize options set via HTML5 data-attributes:
|
||||
$.extend(options, $(this.element[0].cloneNode(false)).data());
|
||||
options.namespace = options.namespace || this.widgetName;
|
||||
this._initSpecialOptions();
|
||||
this._slots = [];
|
||||
this._sequence = this._getXHRPromise(true);
|
||||
this._sending = this._active = this._loaded = this._total = 0;
|
||||
this._initEventHandlers();
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
this._destroyEventHandlers();
|
||||
$.Widget.prototype.destroy.call(this);
|
||||
},
|
||||
|
||||
enable: function () {
|
||||
$.Widget.prototype.enable.call(this);
|
||||
this._initEventHandlers();
|
||||
},
|
||||
|
||||
disable: function () {
|
||||
this._destroyEventHandlers();
|
||||
$.Widget.prototype.disable.call(this);
|
||||
},
|
||||
|
||||
// This method is exposed to the widget API and allows adding files
|
||||
// using the fileupload API. The data parameter accepts an object which
|
||||
// must have a files property and can contain additional options:
|
||||
// .fileupload('add', {files: filesList});
|
||||
add: function (data) {
|
||||
if (!data || this.options.disabled) {
|
||||
return;
|
||||
}
|
||||
data.files = $.each($.makeArray(data.files), this._normalizeFile);
|
||||
this._onAdd(null, data);
|
||||
},
|
||||
|
||||
// This method is exposed to the widget API and allows sending files
|
||||
// using the fileupload API. The data parameter accepts an object which
|
||||
// must have a files property and can contain additional options:
|
||||
// .fileupload('send', {files: filesList});
|
||||
// The method returns a Promise object for the file upload call.
|
||||
send: function (data) {
|
||||
if (data && !this.options.disabled) {
|
||||
data.files = $.each($.makeArray(data.files), this._normalizeFile);
|
||||
if (data.files.length) {
|
||||
return this._onSend(null, data);
|
||||
}
|
||||
}
|
||||
return this._getXHRPromise(false, data && data.context);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}));
|
171
media/js/jquery.iframe-transport.js
Normal file
171
media/js/jquery.iframe-transport.js
Normal file
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* jQuery Iframe Transport Plugin 1.4
|
||||
* https://github.com/blueimp/jQuery-File-Upload
|
||||
*
|
||||
* Copyright 2011, Sebastian Tschan
|
||||
* https://blueimp.net
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* http://www.opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
/*jslint unparam: true, nomen: true */
|
||||
/*global define, window, document */
|
||||
|
||||
(function (factory) {
|
||||
'use strict';
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// Register as an anonymous AMD module:
|
||||
define(['jquery'], factory);
|
||||
} else {
|
||||
// Browser globals:
|
||||
factory(window.jQuery);
|
||||
}
|
||||
}(function ($) {
|
||||
'use strict';
|
||||
|
||||
// Helper variable to create unique names for the transport iframes:
|
||||
var counter = 0;
|
||||
|
||||
// The iframe transport accepts three additional options:
|
||||
// options.fileInput: a jQuery collection of file input fields
|
||||
// options.paramName: the parameter name for the file form data,
|
||||
// overrides the name property of the file input field(s),
|
||||
// can be a string or an array of strings.
|
||||
// options.formData: an array of objects with name and value properties,
|
||||
// equivalent to the return data of .serializeArray(), e.g.:
|
||||
// [{name: 'a', value: 1}, {name: 'b', value: 2}]
|
||||
$.ajaxTransport('iframe', function (options) {
|
||||
if (options.async && (options.type === 'POST' || options.type === 'GET')) {
|
||||
var form,
|
||||
iframe;
|
||||
return {
|
||||
send: function (_, completeCallback) {
|
||||
form = $('<form style="display:none;"></form>');
|
||||
// javascript:false as initial iframe src
|
||||
// prevents warning popups on HTTPS in IE6.
|
||||
// IE versions below IE8 cannot set the name property of
|
||||
// elements that have already been added to the DOM,
|
||||
// so we set the name along with the iframe HTML markup:
|
||||
iframe = $(
|
||||
'<iframe src="javascript:false;" name="iframe-transport-' +
|
||||
(counter += 1) + '"></iframe>'
|
||||
).bind('load', function () {
|
||||
var fileInputClones,
|
||||
paramNames = $.isArray(options.paramName) ?
|
||||
options.paramName : [options.paramName];
|
||||
iframe
|
||||
.unbind('load')
|
||||
.bind('load', function () {
|
||||
var response;
|
||||
// Wrap in a try/catch block to catch exceptions thrown
|
||||
// when trying to access cross-domain iframe contents:
|
||||
try {
|
||||
response = iframe.contents();
|
||||
// Google Chrome and Firefox do not throw an
|
||||
// exception when calling iframe.contents() on
|
||||
// cross-domain requests, so we unify the response:
|
||||
if (!response.length || !response[0].firstChild) {
|
||||
throw new Error();
|
||||
}
|
||||
} catch (e) {
|
||||
response = undefined;
|
||||
}
|
||||
// The complete callback returns the
|
||||
// iframe content document as response object:
|
||||
completeCallback(
|
||||
200,
|
||||
'success',
|
||||
{'iframe': response}
|
||||
);
|
||||
// Fix for IE endless progress bar activity bug
|
||||
// (happens on form submits to iframe targets):
|
||||
$('<iframe src="javascript:false;"></iframe>')
|
||||
.appendTo(form);
|
||||
form.remove();
|
||||
});
|
||||
form
|
||||
.prop('target', iframe.prop('name'))
|
||||
.prop('action', options.url)
|
||||
.prop('method', options.type);
|
||||
if (options.formData) {
|
||||
$.each(options.formData, function (index, field) {
|
||||
$('<input type="hidden"/>')
|
||||
.prop('name', field.name)
|
||||
.val(field.value)
|
||||
.appendTo(form);
|
||||
});
|
||||
}
|
||||
if (options.fileInput && options.fileInput.length &&
|
||||
options.type === 'POST') {
|
||||
fileInputClones = options.fileInput.clone();
|
||||
// Insert a clone for each file input field:
|
||||
options.fileInput.after(function (index) {
|
||||
return fileInputClones[index];
|
||||
});
|
||||
if (options.paramName) {
|
||||
options.fileInput.each(function (index) {
|
||||
$(this).prop(
|
||||
'name',
|
||||
paramNames[index] || options.paramName
|
||||
);
|
||||
});
|
||||
}
|
||||
// Appending the file input fields to the hidden form
|
||||
// removes them from their original location:
|
||||
form
|
||||
.append(options.fileInput)
|
||||
.prop('enctype', 'multipart/form-data')
|
||||
// enctype must be set as encoding for IE:
|
||||
.prop('encoding', 'multipart/form-data');
|
||||
}
|
||||
form.submit();
|
||||
// Insert the file input fields at their original location
|
||||
// by replacing the clones with the originals:
|
||||
if (fileInputClones && fileInputClones.length) {
|
||||
options.fileInput.each(function (index, input) {
|
||||
var clone = $(fileInputClones[index]);
|
||||
$(input).prop('name', clone.prop('name'));
|
||||
clone.replaceWith(input);
|
||||
});
|
||||
}
|
||||
});
|
||||
form.append(iframe).appendTo(document.body);
|
||||
},
|
||||
abort: function () {
|
||||
if (iframe) {
|
||||
// javascript:false as iframe src aborts the request
|
||||
// and prevents warning popups on HTTPS in IE6.
|
||||
// concat is used to avoid the "Script URL" JSLint error:
|
||||
iframe
|
||||
.unbind('load')
|
||||
.prop('src', 'javascript'.concat(':false;'));
|
||||
}
|
||||
if (form) {
|
||||
form.remove();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// The iframe transport returns the iframe content document as response.
|
||||
// The following adds converters from iframe to text, json, html, and script:
|
||||
$.ajaxSetup({
|
||||
converters: {
|
||||
'iframe text': function (iframe) {
|
||||
return $(iframe[0].body).text();
|
||||
},
|
||||
'iframe json': function (iframe) {
|
||||
return $.parseJSON($(iframe[0].body).text());
|
||||
},
|
||||
'iframe html': function (iframe) {
|
||||
return $(iframe[0].body).html();
|
||||
},
|
||||
'iframe script': function (iframe) {
|
||||
return $.globalEval($(iframe[0].body).text());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}));
|
282
media/js/jquery.ui.widget.js
vendored
Normal file
282
media/js/jquery.ui.widget.js
vendored
Normal file
@@ -0,0 +1,282 @@
|
||||
/*
|
||||
* jQuery UI Widget 1.8.18+amd
|
||||
* https://github.com/blueimp/jQuery-File-Upload
|
||||
*
|
||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
* http://jquery.org/license
|
||||
*
|
||||
* http://docs.jquery.com/UI/Widget
|
||||
*/
|
||||
|
||||
(function (factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
// Register as an anonymous AMD module:
|
||||
define(["jquery"], factory);
|
||||
} else {
|
||||
// Browser globals:
|
||||
factory(jQuery);
|
||||
}
|
||||
}(function( $, undefined ) {
|
||||
|
||||
// jQuery 1.4+
|
||||
if ( $.cleanData ) {
|
||||
var _cleanData = $.cleanData;
|
||||
$.cleanData = function( elems ) {
|
||||
for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
|
||||
try {
|
||||
$( elem ).triggerHandler( "remove" );
|
||||
// http://bugs.jquery.com/ticket/8235
|
||||
} catch( e ) {}
|
||||
}
|
||||
_cleanData( elems );
|
||||
};
|
||||
} else {
|
||||
var _remove = $.fn.remove;
|
||||
$.fn.remove = function( selector, keepData ) {
|
||||
return this.each(function() {
|
||||
if ( !keepData ) {
|
||||
if ( !selector || $.filter( selector, [ this ] ).length ) {
|
||||
$( "*", this ).add( [ this ] ).each(function() {
|
||||
try {
|
||||
$( this ).triggerHandler( "remove" );
|
||||
// http://bugs.jquery.com/ticket/8235
|
||||
} catch( e ) {}
|
||||
});
|
||||
}
|
||||
}
|
||||
return _remove.call( $(this), selector, keepData );
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
$.widget = function( name, base, prototype ) {
|
||||
var namespace = name.split( "." )[ 0 ],
|
||||
fullName;
|
||||
name = name.split( "." )[ 1 ];
|
||||
fullName = namespace + "-" + name;
|
||||
|
||||
if ( !prototype ) {
|
||||
prototype = base;
|
||||
base = $.Widget;
|
||||
}
|
||||
|
||||
// create selector for plugin
|
||||
$.expr[ ":" ][ fullName ] = function( elem ) {
|
||||
return !!$.data( elem, name );
|
||||
};
|
||||
|
||||
$[ namespace ] = $[ namespace ] || {};
|
||||
$[ namespace ][ name ] = function( options, element ) {
|
||||
// allow instantiation without initializing for simple inheritance
|
||||
if ( arguments.length ) {
|
||||
this._createWidget( options, element );
|
||||
}
|
||||
};
|
||||
|
||||
var basePrototype = new base();
|
||||
// we need to make the options hash a property directly on the new instance
|
||||
// otherwise we'll modify the options hash on the prototype that we're
|
||||
// inheriting from
|
||||
// $.each( basePrototype, function( key, val ) {
|
||||
// if ( $.isPlainObject(val) ) {
|
||||
// basePrototype[ key ] = $.extend( {}, val );
|
||||
// }
|
||||
// });
|
||||
basePrototype.options = $.extend( true, {}, basePrototype.options );
|
||||
$[ namespace ][ name ].prototype = $.extend( true, basePrototype, {
|
||||
namespace: namespace,
|
||||
widgetName: name,
|
||||
widgetEventPrefix: $[ namespace ][ name ].prototype.widgetEventPrefix || name,
|
||||
widgetBaseClass: fullName
|
||||
}, prototype );
|
||||
|
||||
$.widget.bridge( name, $[ namespace ][ name ] );
|
||||
};
|
||||
|
||||
$.widget.bridge = function( name, object ) {
|
||||
$.fn[ name ] = function( options ) {
|
||||
var isMethodCall = typeof options === "string",
|
||||
args = Array.prototype.slice.call( arguments, 1 ),
|
||||
returnValue = this;
|
||||
|
||||
// allow multiple hashes to be passed on init
|
||||
options = !isMethodCall && args.length ?
|
||||
$.extend.apply( null, [ true, options ].concat(args) ) :
|
||||
options;
|
||||
|
||||
// prevent calls to internal methods
|
||||
if ( isMethodCall && options.charAt( 0 ) === "_" ) {
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
if ( isMethodCall ) {
|
||||
this.each(function() {
|
||||
var instance = $.data( this, name ),
|
||||
methodValue = instance && $.isFunction( instance[options] ) ?
|
||||
instance[ options ].apply( instance, args ) :
|
||||
instance;
|
||||
// TODO: add this back in 1.9 and use $.error() (see #5972)
|
||||
// if ( !instance ) {
|
||||
// throw "cannot call methods on " + name + " prior to initialization; " +
|
||||
// "attempted to call method '" + options + "'";
|
||||
// }
|
||||
// if ( !$.isFunction( instance[options] ) ) {
|
||||
// throw "no such method '" + options + "' for " + name + " widget instance";
|
||||
// }
|
||||
// var methodValue = instance[ options ].apply( instance, args );
|
||||
if ( methodValue !== instance && methodValue !== undefined ) {
|
||||
returnValue = methodValue;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.each(function() {
|
||||
var instance = $.data( this, name );
|
||||
if ( instance ) {
|
||||
instance.option( options || {} )._init();
|
||||
} else {
|
||||
$.data( this, name, new object( options, this ) );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
};
|
||||
};
|
||||
|
||||
$.Widget = function( options, element ) {
|
||||
// allow instantiation without initializing for simple inheritance
|
||||
if ( arguments.length ) {
|
||||
this._createWidget( options, element );
|
||||
}
|
||||
};
|
||||
|
||||
$.Widget.prototype = {
|
||||
widgetName: "widget",
|
||||
widgetEventPrefix: "",
|
||||
options: {
|
||||
disabled: false
|
||||
},
|
||||
_createWidget: function( options, element ) {
|
||||
// $.widget.bridge stores the plugin instance, but we do it anyway
|
||||
// so that it's stored even before the _create function runs
|
||||
$.data( element, this.widgetName, this );
|
||||
this.element = $( element );
|
||||
this.options = $.extend( true, {},
|
||||
this.options,
|
||||
this._getCreateOptions(),
|
||||
options );
|
||||
|
||||
var self = this;
|
||||
this.element.bind( "remove." + this.widgetName, function() {
|
||||
self.destroy();
|
||||
});
|
||||
|
||||
this._create();
|
||||
this._trigger( "create" );
|
||||
this._init();
|
||||
},
|
||||
_getCreateOptions: function() {
|
||||
return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];
|
||||
},
|
||||
_create: function() {},
|
||||
_init: function() {},
|
||||
|
||||
destroy: function() {
|
||||
this.element
|
||||
.unbind( "." + this.widgetName )
|
||||
.removeData( this.widgetName );
|
||||
this.widget()
|
||||
.unbind( "." + this.widgetName )
|
||||
.removeAttr( "aria-disabled" )
|
||||
.removeClass(
|
||||
this.widgetBaseClass + "-disabled " +
|
||||
"ui-state-disabled" );
|
||||
},
|
||||
|
||||
widget: function() {
|
||||
return this.element;
|
||||
},
|
||||
|
||||
option: function( key, value ) {
|
||||
var options = key;
|
||||
|
||||
if ( arguments.length === 0 ) {
|
||||
// don't return a reference to the internal hash
|
||||
return $.extend( {}, this.options );
|
||||
}
|
||||
|
||||
if (typeof key === "string" ) {
|
||||
if ( value === undefined ) {
|
||||
return this.options[ key ];
|
||||
}
|
||||
options = {};
|
||||
options[ key ] = value;
|
||||
}
|
||||
|
||||
this._setOptions( options );
|
||||
|
||||
return this;
|
||||
},
|
||||
_setOptions: function( options ) {
|
||||
var self = this;
|
||||
$.each( options, function( key, value ) {
|
||||
self._setOption( key, value );
|
||||
});
|
||||
|
||||
return this;
|
||||
},
|
||||
_setOption: function( key, value ) {
|
||||
this.options[ key ] = value;
|
||||
|
||||
if ( key === "disabled" ) {
|
||||
this.widget()
|
||||
[ value ? "addClass" : "removeClass"](
|
||||
this.widgetBaseClass + "-disabled" + " " +
|
||||
"ui-state-disabled" )
|
||||
.attr( "aria-disabled", value );
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
enable: function() {
|
||||
return this._setOption( "disabled", false );
|
||||
},
|
||||
disable: function() {
|
||||
return this._setOption( "disabled", true );
|
||||
},
|
||||
|
||||
_trigger: function( type, event, data ) {
|
||||
var prop, orig,
|
||||
callback = this.options[ type ];
|
||||
|
||||
data = data || {};
|
||||
event = $.Event( event );
|
||||
event.type = ( type === this.widgetEventPrefix ?
|
||||
type :
|
||||
this.widgetEventPrefix + type ).toLowerCase();
|
||||
// the original event may come from any element
|
||||
// so we need to reset the target on the new event
|
||||
event.target = this.element[ 0 ];
|
||||
|
||||
// copy original event properties over to the new event
|
||||
orig = event.originalEvent;
|
||||
if ( orig ) {
|
||||
for ( prop in orig ) {
|
||||
if ( !( prop in event ) ) {
|
||||
event[ prop ] = orig[ prop ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.element.trigger( event, data );
|
||||
|
||||
return !( $.isFunction(callback) &&
|
||||
callback.call( this.element[0], event, data ) === false ||
|
||||
event.isDefaultPrevented() );
|
||||
}
|
||||
};
|
||||
|
||||
}));
|
1
media/js/load-image.min.js
vendored
Normal file
1
media/js/load-image.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(function(a){"use strict";var b=function(a,c,d){var e=document.createElement("img"),f,g;return e.onerror=c,e.onload=function(){g&&b.revokeObjectURL(g),c(b.scale(e,d))},window.Blob&&a instanceof Blob||window.File&&a instanceof File?f=g=b.createObjectURL(a):f=a,f?(e.src=f,e):b.readFile(a,function(a){e.src=a})},c=window.createObjectURL&&window||window.URL&&URL||window.webkitURL&&webkitURL;b.scale=function(a,b){b=b||{};var c=document.createElement("canvas"),d=a.width,e=a.height,f=Math.max((b.minWidth||d)/d,(b.minHeight||e)/e);return f>1&&(d=parseInt(d*f,10),e=parseInt(e*f,10)),f=Math.min((b.maxWidth||d)/d,(b.maxHeight||e)/e),f<1&&(d=parseInt(d*f,10),e=parseInt(e*f,10)),a.getContext||b.canvas&&c.getContext?(c.width=d,c.height=e,c.getContext("2d").drawImage(a,0,0,d,e),c):(a.width=d,a.height=e,a)},b.createObjectURL=function(a){return c?c.createObjectURL(a):!1},b.revokeObjectURL=function(a){return c?c.revokeObjectURL(a):!1},b.readFile=function(a,b){if(window.FileReader&&FileReader.prototype.readAsDataURL){var c=new FileReader;return c.onload=function(a){b(a.target.result)},c.readAsDataURL(a),c}return!1},typeof define!="undefined"&&define.amd?define(function(){return b}):a.loadImage=b})(this);
|
29
media/js/locale.js
Normal file
29
media/js/locale.js
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* jQuery File Upload Plugin Localization Example 6.5.1
|
||||
* https://github.com/blueimp/jQuery-File-Upload
|
||||
*
|
||||
* Copyright 2012, Sebastian Tschan
|
||||
* https://blueimp.net
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* http://www.opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
/*global window */
|
||||
|
||||
window.locale = {
|
||||
"fileupload": {
|
||||
"errors": {
|
||||
"maxFileSize": "File is too big",
|
||||
"minFileSize": "File is too small",
|
||||
"acceptFileTypes": "Filetype not allowed",
|
||||
"maxNumberOfFiles": "Max number of files exceeded",
|
||||
"uploadedBytes": "Uploaded bytes exceed file size",
|
||||
"emptyResult": "Empty file upload result"
|
||||
},
|
||||
"error": "Error",
|
||||
"start": "Start",
|
||||
"cancel": "Cancel",
|
||||
"destroy": "Delete"
|
||||
}
|
||||
};
|
1
media/js/tmpl.min.js
vendored
Normal file
1
media/js/tmpl.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(function(a){"use strict";var b=function(a,c){var d=/[^\w\-\.:]/.test(a)?new Function(b.arg+",tmpl","var _e=tmpl.encode"+b.helper+",_s='"+a.replace(b.regexp,b.func)+"';return _s;"):b.cache[a]=b.cache[a]||b(b.load(a));return c?d(c,b):function(a){return d(a,b)}};b.cache={},b.load=function(a){return document.getElementById(a).innerHTML},b.regexp=/([\s'\\])(?![^%]*%\})|(?:\{%(=|#)([\s\S]+?)%\})|(\{%)|(%\})/g,b.func=function(a,b,c,d,e,f){if(b)return{"\n":"\\n","\r":"\\r","\t":"\\t"," ":" "}[a]||"\\"+a;if(c)return c==="="?"'+_e("+d+")+'":"'+("+d+"||'')+'";if(e)return"';";if(f)return"_s+='"},b.encReg=/[<>&"'\x00]/g,b.encMap={"<":"<",">":">","&":"&",'"':""","'":"'"},b.encode=function(a){return String(a||"").replace(b.encReg,function(a){return b.encMap[a]||""})},b.arg="o",b.helper=",print=function(s,e){_s+=e&&(s||'')||_e(s);},include=function(s,d){_s+=tmpl(s,d);}",typeof define=="function"&&define.amd?define(function(){return b}):a.tmpl=b})(this);
|
60
seahub/base/templatetags/upload_tags.py
Normal file
60
seahub/base/templatetags/upload_tags.py
Normal file
@@ -0,0 +1,60 @@
|
||||
from django import template
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@register.simple_tag
|
||||
def upload_js():
|
||||
return """
|
||||
<!-- The template to display files available for upload -->
|
||||
<script id="template-upload" type="text/x-tmpl">
|
||||
{% for (var i=0, file; file=o.files[i]; i++) { %}
|
||||
<tr class="template-upload fade">
|
||||
<td class="name"><span>{%=file.name%}</span></td>
|
||||
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
|
||||
{% if (file.error) { %}
|
||||
<td class="error" colspan="2"><span class="label label-important">{%=locale.fileupload.error%}</span> {%=locale.fileupload.errors[file.error] || file.error%}</td>
|
||||
{% } else if (o.files.valid && !i) { %}
|
||||
<td>
|
||||
<div class="progress progress-success progress-striped active"><div class="bar" style="width:0%;"></div></div>
|
||||
</td>
|
||||
<td class="start">{% if (!o.options.autoUpload) { %}
|
||||
<button class="btn btn-success">
|
||||
<i class="icon-upload icon-white"></i>
|
||||
<span>{%=locale.fileupload.start%}</span>
|
||||
</button>
|
||||
{% } %}</td>
|
||||
{% } else { %}
|
||||
<td colspan="2"></td>
|
||||
{% } %}
|
||||
<td class="cancel">{% if (!i) { %}
|
||||
<button class="btn btn-warning">
|
||||
<i class="icon-ban-circle icon-white"></i>
|
||||
<span>{%=locale.fileupload.cancel%}</span>
|
||||
</button>
|
||||
{% } %}</td>
|
||||
</tr>
|
||||
{% } %}
|
||||
</script>
|
||||
<!-- The template to display files available for download -->
|
||||
<script id="template-download" type="text/x-tmpl">
|
||||
{% for (var i=0, file; file=o.files[i]; i++) { %}
|
||||
<tr class="template-download fade">
|
||||
{% if (file.error) { %}
|
||||
<td></td>
|
||||
<td class="name"><span>{%=file.name%}</span></td>
|
||||
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
|
||||
<td class="error" colspan="2"><span class="label label-important">{%=locale.fileupload.error%}</span> {%=locale.fileupload.errors[file.error] || file.error%}</td>
|
||||
{% } else { %}
|
||||
<td class="preview">{% if (file.thumbnail_url) { %}
|
||||
<a href="{%=file.url%}" title="{%=file.name%}" rel="gallery" download="{%=file.name%}"><img src="{%=file.thumbnail_url%}"></a>
|
||||
{% } %}</td>
|
||||
<td class="name">
|
||||
<a href="{%=file.url%}" title="{%=file.name%}" rel="{%=file.thumbnail_url&&'gallery'%}" download="{%=file.name%}">{%=file.name%}</a>
|
||||
</td>
|
||||
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
|
||||
<td colspan="2"></td>
|
||||
{% } %}
|
||||
</tr>
|
||||
{% } %}
|
||||
</script>
|
||||
"""
|
@@ -1,15 +1,26 @@
|
||||
{% extends "myhome_base.html" %}
|
||||
|
||||
{% load seahub_tags avatar_tags i18n %}
|
||||
{% load seahub_tags avatar_tags i18n upload_tags %}
|
||||
|
||||
{% block sub_title %}{{repo.name}} - {% endblock %}
|
||||
{% block extra_style %}
|
||||
<!-- Bootstrap Progress CSS -->
|
||||
<link rel="stylesheet" href="{{ MEDIA_URL }}css/bootstrap-progress-bar.css">
|
||||
<!-- Bootstrap Button CSS -->
|
||||
<link rel="stylesheet" href="{{ MEDIA_URL }}css/bootstrap-button.css">
|
||||
|
||||
<link rel="stylesheet" href="{{ MEDIA_URL }}css/jquery.fileupload-ui.css">
|
||||
<!-- Shim to make HTML5 elements usable in older Internet Explorer versions -->
|
||||
<!--[if lt IE 9]><script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
|
||||
|
||||
<style type="text/css">
|
||||
#main { width:auto; }
|
||||
#footer { display:none; }
|
||||
</style>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block sub_title %}{{repo.name}} - {% endblock %}
|
||||
|
||||
{% block main_panel %}
|
||||
<div id="repo-top"><div class="block-inner">
|
||||
<div class="w100 ovhd">
|
||||
@@ -66,24 +77,42 @@
|
||||
{% if no_quota %}
|
||||
<p class="error">{% trans "The owner of this library has ran out of space." %}</p>
|
||||
{% else %}
|
||||
<form id="upload-file-form" enctype="multipart/form-data" method="post" action="{{ upload_url }}">{% csrf_token %}
|
||||
<input type="hidden" name="parent_dir" value="{{ path }}" />
|
||||
<div class="files-add">
|
||||
<span class="op add">{% trans "Add files" %}</span>
|
||||
<span id="upload-add-tip">({% trans "smaller than" %} {{ max_upload_file_size|filesizeformat }})</span>
|
||||
<input type="file" name="file" id="file-upload-input" />
|
||||
</div>
|
||||
<div id="upload-file-list"></div>
|
||||
<p class="error">{{ error_msg }}</p>
|
||||
<input type="submit" value="{% trans "Upload" %}" class="submit" />
|
||||
<form id="fileupload" enctype="multipart/form-data" method="post" action="{{ajax_upload_url}}">{% csrf_token %}
|
||||
<input type="hidden" name="parent_dir" id="parent_dir" value="{{ path }}" />
|
||||
|
||||
<div class="row fileupload-buttonbar">
|
||||
<div class="span7">
|
||||
<span class="btn btn-primary fileinput-button">
|
||||
<i class="icon-plus icon-white"></i>
|
||||
<span>Add files...</span>
|
||||
<input type="file" name="file" multiple>
|
||||
</span>
|
||||
<button type="submit" class="btn btn-success start">
|
||||
<i class="icon-upload icon-white"></i>
|
||||
<span>Start upload</span>
|
||||
</button>
|
||||
<button type="reset" class="btn btn-warning cancel">
|
||||
<i class="icon-ban-circle icon-white"></i>
|
||||
<span>Cancel upload</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="span5 fileupload-progress fade">
|
||||
<div class="progress progress-success progres-striped active">
|
||||
<div class="bar" style="width:0%"></div>
|
||||
</div>
|
||||
<div class="progress-extended"> </div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="fileupload-loading"></div>
|
||||
<table class="table table-striped"><tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody></table>
|
||||
</form>
|
||||
<div id="upload-progress-con" class="upload-progress-con hide">
|
||||
<p>{% trans "Uploaded:" %} <span class="upload-progress-text">{% trans "Fetching ..." %}</span></p>
|
||||
<div class="upload-progress-bar"></div>
|
||||
<button class="upload-cancel">{% trans "Cancel" %}</button>
|
||||
<iframe class="hide"><!--for chrome--></iframe>
|
||||
|
||||
<div class="fileupload-content">
|
||||
<table class="files"></table>
|
||||
<div class="fileupload-progressbar"></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div id="update-file-dialog" class="hide">
|
||||
@@ -192,11 +221,26 @@
|
||||
{% with attach_type='dir' %}
|
||||
{% include "snippets/group_recommend_form.html" %}
|
||||
{% endwith %}
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
<script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.MultiFile.pack.js"></script>
|
||||
{% upload_js %}
|
||||
<script type="text/javascript" src="{{ MEDIA_URL }}jstree_pre1.0_stable/jquery.jstree.js"></script>
|
||||
|
||||
<script src="{{ MEDIA_URL}}js/jquery.ui.widget.js"></script>
|
||||
<script src="{{ MEDIA_URL}}js/tmpl.min.js"></script>
|
||||
<script src="{{ MEDIA_URL}}js/load-image.min.js"></script>
|
||||
<script src="{{ MEDIA_URL}}js/canvas-to-blob.min.js"></script>
|
||||
<script src="{{ MEDIA_URL }}js/jquery.iframe-transport.js"></script>
|
||||
<script src="{{ MEDIA_URL }}js/jquery.fileupload.js"></script>
|
||||
<script src="{{ MEDIA_URL }}js/jquery.fileupload-fp.js"></script>
|
||||
<script src="{{ MEDIA_URL }}js/jquery.fileupload-ui.js"></script>
|
||||
<script src="{{ MEDIA_URL }}js/locale.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
//download, trash
|
||||
$('#repo-download-btn').click(function() {
|
||||
window.open('{{ SITE_ROOT }}seafile_access_check/?repo_id={{repo.props.id}}');
|
||||
@@ -281,20 +325,36 @@ $('.path .dir-link').click(dirlinkClick);
|
||||
$('#download-dir').click(function() {
|
||||
location.href = $(this).data('url');
|
||||
});
|
||||
|
||||
$('#upload-file').click(function () {
|
||||
$('#upload-file-dialog').modal({focus:false});
|
||||
$('#upload-file-form input[name="parent_dir"]').val(cur_path);
|
||||
$('#file-upload-input').MultiFile({
|
||||
list: '#upload-file-list',
|
||||
STRING: {
|
||||
file: '<span title="{% trans "Click to remove" %}" onclick="$(this).parent().prev().click()">$file</span>',
|
||||
duplicate: "{% trans "This file has already been selected:\n$file!" %}"
|
||||
$('#upload-file-dialog').modal({
|
||||
containerCss: {
|
||||
width: 650,
|
||||
},
|
||||
afterFileAppend:function() {
|
||||
$('#upload-file-form .files-add input').css({'right':$('#upload-add-tip').width()});
|
||||
maxHeight: 400,
|
||||
onShow: function (dlg) {
|
||||
// Initialize the jQuery File Upload widget:
|
||||
$('#fileupload').fileupload({
|
||||
sequentialUploads: true,
|
||||
});
|
||||
|
||||
// Enable iframe cross-domain access via redirect option:
|
||||
$('#fileupload').fileupload(
|
||||
'option',
|
||||
'redirect',
|
||||
window.location.href.replace(
|
||||
/\/repo\/[-a-z0-9]{36}\/.*/,
|
||||
'/media/cors/result.html?%s'
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
$(dlg.container).css('height', 'auto');
|
||||
$(dlg.wrap).css('overflow', 'auto'); // or try jQuery.modal.update();
|
||||
}
|
||||
});
|
||||
$('#simplemodal-container').css({'height':'auto', 'width':'auto'});
|
||||
|
||||
$('#upload-file-form .files-add').css({'width':$('#upload-file-form .files-add').width() + 1}); // '+ 1' for ie
|
||||
$('#file-upload-input').css({'right':$('#upload-add-tip').width()});
|
||||
});
|
||||
@@ -925,5 +985,5 @@ window.onload = function() {
|
||||
{% include "snippets/shared_link_js.html" %}
|
||||
{% include "snippets/bottom_bar.html" %}
|
||||
</script>
|
||||
{% include 'snippets/file_upload_progress_js.html' %}
|
||||
|
||||
{% endblock %}
|
||||
|
@@ -94,6 +94,23 @@ def get_upload_url(request, repo_id):
|
||||
else:
|
||||
return ''
|
||||
|
||||
def get_api_upload_url(request, repo_id):
|
||||
"""Get file upload url for web api.
|
||||
"""
|
||||
username = request.user.username
|
||||
if get_user_permission(request, repo_id) == 'rw':
|
||||
token = seafile_api.get_httpserver_access_token(repo_id, 'dummy',
|
||||
'upload', username)
|
||||
return gen_file_upload_url(token, 'upload-api')
|
||||
else:
|
||||
return ''
|
||||
|
||||
def get_ajax_upload_url(request, repo_id):
|
||||
"""Get file upload url for AJAX.
|
||||
"""
|
||||
api_upload_url = get_api_upload_url(request, repo_id)
|
||||
return api_upload_url.replace('api', 'aj')
|
||||
|
||||
def get_update_url(request, repo_id):
|
||||
username = request.user.username
|
||||
if get_user_permission(request, repo_id) == 'rw':
|
||||
@@ -174,6 +191,7 @@ def render_repo(request, repo):
|
||||
else:
|
||||
repo_group_str = ''
|
||||
upload_url = get_upload_url(request, repo.id)
|
||||
ajax_upload_url = get_ajax_upload_url(request, repo.id)
|
||||
update_url = get_update_url(request, repo.id)
|
||||
fileshare = get_fileshare(repo.id, username, path)
|
||||
dir_shared_link = get_dir_share_link(fileshare)
|
||||
@@ -196,6 +214,7 @@ def render_repo(request, repo):
|
||||
'no_quota': no_quota,
|
||||
'max_upload_file_size': max_upload_file_size,
|
||||
'upload_url': upload_url,
|
||||
'ajax_upload_url': ajax_upload_url,
|
||||
'update_url': update_url,
|
||||
'httpserver_root': httpserver_root,
|
||||
'protocol': protocol,
|
||||
|
Reference in New Issue
Block a user