Inisital Asset Commit
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* jQuery postMessage Transport Plugin
|
||||
* https://github.com/blueimp/jQuery-File-Upload
|
||||
*
|
||||
* Copyright 2011, Sebastian Tschan
|
||||
* https://blueimp.net
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
/* global define, require, window, document */
|
||||
|
||||
;(function (factory) {
|
||||
'use strict';
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// Register as an anonymous AMD module:
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node/CommonJS:
|
||||
factory(require('jquery'));
|
||||
} else {
|
||||
// Browser globals:
|
||||
factory(window.jQuery);
|
||||
}
|
||||
}(function ($) {
|
||||
'use strict';
|
||||
|
||||
var counter = 0,
|
||||
names = [
|
||||
'accepts',
|
||||
'cache',
|
||||
'contents',
|
||||
'contentType',
|
||||
'crossDomain',
|
||||
'data',
|
||||
'dataType',
|
||||
'headers',
|
||||
'ifModified',
|
||||
'mimeType',
|
||||
'password',
|
||||
'processData',
|
||||
'timeout',
|
||||
'traditional',
|
||||
'type',
|
||||
'url',
|
||||
'username'
|
||||
],
|
||||
convert = function (p) {
|
||||
return p;
|
||||
};
|
||||
|
||||
$.ajaxSetup({
|
||||
converters: {
|
||||
'postmessage text': convert,
|
||||
'postmessage json': convert,
|
||||
'postmessage html': convert
|
||||
}
|
||||
});
|
||||
|
||||
$.ajaxTransport('postmessage', function (options) {
|
||||
if (options.postMessage && window.postMessage) {
|
||||
var iframe,
|
||||
loc = $('<a>').prop('href', options.postMessage)[0],
|
||||
target = loc.protocol + '//' + loc.host,
|
||||
xhrUpload = options.xhr().upload;
|
||||
// IE always includes the port for the host property of a link
|
||||
// element, but not in the location.host or origin property for the
|
||||
// default http port 80 and https port 443, so we strip it:
|
||||
if (/^(http:\/\/.+:80)|(https:\/\/.+:443)$/.test(target)) {
|
||||
target = target.replace(/:(80|443)$/, '');
|
||||
}
|
||||
return {
|
||||
send: function (_, completeCallback) {
|
||||
counter += 1;
|
||||
var message = {
|
||||
id: 'postmessage-transport-' + counter
|
||||
},
|
||||
eventName = 'message.' + message.id;
|
||||
iframe = $(
|
||||
'<iframe style="display:none;" src="' +
|
||||
options.postMessage + '" name="' +
|
||||
message.id + '"></iframe>'
|
||||
).bind('load', function () {
|
||||
$.each(names, function (i, name) {
|
||||
message[name] = options[name];
|
||||
});
|
||||
message.dataType = message.dataType.replace('postmessage ', '');
|
||||
$(window).bind(eventName, function (e) {
|
||||
e = e.originalEvent;
|
||||
var data = e.data,
|
||||
ev;
|
||||
if (e.origin === target && data.id === message.id) {
|
||||
if (data.type === 'progress') {
|
||||
ev = document.createEvent('Event');
|
||||
ev.initEvent(data.type, false, true);
|
||||
$.extend(ev, data);
|
||||
xhrUpload.dispatchEvent(ev);
|
||||
} else {
|
||||
completeCallback(
|
||||
data.status,
|
||||
data.statusText,
|
||||
{postmessage: data.result},
|
||||
data.headers
|
||||
);
|
||||
iframe.remove();
|
||||
$(window).unbind(eventName);
|
||||
}
|
||||
}
|
||||
});
|
||||
iframe[0].contentWindow.postMessage(
|
||||
message,
|
||||
target
|
||||
);
|
||||
}).appendTo(document.body);
|
||||
},
|
||||
abort: function () {
|
||||
if (iframe) {
|
||||
iframe.remove();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
}));
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* jQuery XDomainRequest Transport Plugin
|
||||
* https://github.com/blueimp/jQuery-File-Upload
|
||||
*
|
||||
* Copyright 2011, Sebastian Tschan
|
||||
* https://blueimp.net
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* https://opensource.org/licenses/MIT
|
||||
*
|
||||
* Based on Julian Aubourg's ajaxHooks xdr.js:
|
||||
* https://github.com/jaubourg/ajaxHooks/
|
||||
*/
|
||||
|
||||
/* global define, require, window, XDomainRequest */
|
||||
|
||||
;(function (factory) {
|
||||
'use strict';
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// Register as an anonymous AMD module:
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node/CommonJS:
|
||||
factory(require('jquery'));
|
||||
} else {
|
||||
// Browser globals:
|
||||
factory(window.jQuery);
|
||||
}
|
||||
}(function ($) {
|
||||
'use strict';
|
||||
if (window.XDomainRequest && !$.support.cors) {
|
||||
$.ajaxTransport(function (s) {
|
||||
if (s.crossDomain && s.async) {
|
||||
if (s.timeout) {
|
||||
s.xdrTimeout = s.timeout;
|
||||
delete s.timeout;
|
||||
}
|
||||
var xdr;
|
||||
return {
|
||||
send: function (headers, completeCallback) {
|
||||
var addParamChar = /\?/.test(s.url) ? '&' : '?';
|
||||
function callback(status, statusText, responses, responseHeaders) {
|
||||
xdr.onload = xdr.onerror = xdr.ontimeout = $.noop;
|
||||
xdr = null;
|
||||
completeCallback(status, statusText, responses, responseHeaders);
|
||||
}
|
||||
xdr = new XDomainRequest();
|
||||
// XDomainRequest only supports GET and POST:
|
||||
if (s.type === 'DELETE') {
|
||||
s.url = s.url + addParamChar + '_method=DELETE';
|
||||
s.type = 'POST';
|
||||
} else if (s.type === 'PUT') {
|
||||
s.url = s.url + addParamChar + '_method=PUT';
|
||||
s.type = 'POST';
|
||||
} else if (s.type === 'PATCH') {
|
||||
s.url = s.url + addParamChar + '_method=PATCH';
|
||||
s.type = 'POST';
|
||||
}
|
||||
xdr.open(s.type, s.url);
|
||||
xdr.onload = function () {
|
||||
callback(
|
||||
200,
|
||||
'OK',
|
||||
{text: xdr.responseText},
|
||||
'Content-Type: ' + xdr.contentType
|
||||
);
|
||||
};
|
||||
xdr.onerror = function () {
|
||||
callback(404, 'Not Found');
|
||||
};
|
||||
if (s.xdrTimeout) {
|
||||
xdr.ontimeout = function () {
|
||||
callback(0, 'timeout');
|
||||
};
|
||||
xdr.timeout = s.xdrTimeout;
|
||||
}
|
||||
xdr.send((s.hasContent && s.data) || null);
|
||||
},
|
||||
abort: function () {
|
||||
if (xdr) {
|
||||
xdr.onerror = $.noop();
|
||||
xdr.abort();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
}));
|
||||
433
assets/plugins/fancy-file-uploader/fancy_fileupload.css
Normal file
433
assets/plugins/fancy-file-uploader/fancy_fileupload.css
Normal file
@@ -0,0 +1,433 @@
|
||||
.ff_fileupload_hidden {
|
||||
display: none;
|
||||
}
|
||||
.ff_fileupload_wrap .ff_fileupload_dropzone_wrap {
|
||||
position: relative;
|
||||
}
|
||||
.ff_fileupload_wrap .ff_fileupload_dropzone {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 200px;
|
||||
box-sizing: border-box;
|
||||
border: 2px dashed #008cff;
|
||||
border-radius: 3px;
|
||||
padding: 0;
|
||||
background-color: rgb(255 255 255 / 0.12);
|
||||
background-image: url('fancy_upload.png');
|
||||
background-repeat: no-repeat;
|
||||
background-position: center center;
|
||||
opacity: 0.85;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
}
|
||||
.ff_fileupload_wrap .ff_fileupload_dropzone::-moz-focus-inner {
|
||||
border: 0;
|
||||
}
|
||||
.ff_fileupload_wrap .ff_fileupload_dropzone:hover, .ff_fileupload_wrap .ff_fileupload_dropzone:focus, .ff_fileupload_wrap .ff_fileupload_dropzone:active {
|
||||
opacity: 1;
|
||||
background-color: rgb(255 255 255 / 0.18);
|
||||
border-color: #157EFB;
|
||||
}
|
||||
.ff_fileupload_wrap .ff_fileupload_dropzone_tools {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 0;
|
||||
}
|
||||
.ff_fileupload_wrap .ff_fileupload_dropzone_tool {
|
||||
display: block;
|
||||
margin-top: 10px;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #A2B4CA;
|
||||
border-radius: 3px;
|
||||
padding: 0;
|
||||
background-color: #FDFDFD;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center center;
|
||||
opacity: 0.85;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
}
|
||||
.ff_fileupload_wrap .ff_fileupload_dropzone_tool::-moz-focus-inner {
|
||||
border: 0;
|
||||
}
|
||||
.ff_fileupload_wrap .ff_fileupload_dropzone_tool:hover, .ff_fileupload_wrap .ff_fileupload_dropzone_tool:focus, .ff_fileupload_wrap .ff_fileupload_dropzone_tool:active {
|
||||
opacity: 1;
|
||||
background-color: #FFFFFF;
|
||||
border-color: #157EFB;
|
||||
}
|
||||
.ff_fileupload_wrap .ff_fileupload_recordaudio {
|
||||
background-image: url('fancy_microphone.png');
|
||||
}
|
||||
.ff_fileupload_wrap .ff_fileupload_recordvideo {
|
||||
background-image: url('fancy_webcam.png');
|
||||
}
|
||||
.ff_fileupload_wrap .ff_fileupload_recordvideo_preview {
|
||||
position: absolute;
|
||||
display: block;
|
||||
right: 60px;
|
||||
top: 10px;
|
||||
width: 320px;
|
||||
max-width: calc(100% - 70px);
|
||||
height: calc(100% - 20px);
|
||||
background-color: #222222;
|
||||
}
|
||||
.ff_fileupload_wrap .ff_fileupload_recordvideo_preview.ff_fileupload_hidden {
|
||||
display: none;
|
||||
}
|
||||
@keyframes ff_fileupload_recording_animate {
|
||||
from {
|
||||
border-color: #EF1F1F;
|
||||
}
|
||||
to {
|
||||
border-color: #C9A1A1;
|
||||
}
|
||||
}
|
||||
.ff_fileupload_wrap .ff_fileupload_recording {
|
||||
animation: ff_fileupload_recording_animate 1.2s infinite alternate;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads {
|
||||
width: 100%;
|
||||
border-collapse: collapse !important;
|
||||
border: 0 none;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads tr, .ff_fileupload_wrap table.ff_fileupload_uploads td {
|
||||
margin: 0;
|
||||
border: 0 none;
|
||||
padding: 0;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td {
|
||||
vertical-align: top;
|
||||
padding: 1em 0;
|
||||
white-space: nowrap;
|
||||
line-height: normal;
|
||||
}
|
||||
@keyframes ff_fileupload_bounce_animate {
|
||||
10%, 90% {
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
20%, 80% {
|
||||
transform: translateY(2px);
|
||||
}
|
||||
30%, 50%, 70% {
|
||||
transform: translateY(-3px);
|
||||
}
|
||||
40%, 60% {
|
||||
transform: translateY(3px);
|
||||
}
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads tr.ff_fileupload_bounce {
|
||||
animation: ff_fileupload_bounce_animate 0.82s cubic-bezier(.36, .07, .19, .97) both;
|
||||
transform: translateY(0);
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview {
|
||||
width: 1px;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_image {
|
||||
display: block;
|
||||
box-sizing: border-box;
|
||||
border: 0 none;
|
||||
padding: 0;
|
||||
background-color: #DDDDDD;
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center center;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
border-radius: 5px;
|
||||
opacity: 0.75;
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
color: #222222;
|
||||
overflow: hidden;
|
||||
outline: none;
|
||||
cursor: default;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_image::-moz-focus-inner {
|
||||
border: 0;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_image_has_preview {
|
||||
cursor: pointer;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_image:hover, .ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_image:focus, .ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_image:active {
|
||||
opacity: 1;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
width: 70%;
|
||||
overflow: hidden;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_actions button {
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #A2B4CA;
|
||||
border-radius: 3px;
|
||||
padding: 0;
|
||||
background-color: #FCFCFC;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center center;
|
||||
opacity: 0.85;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_actions button::-moz-focus-inner {
|
||||
border: 0;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_actions button:hover, .ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_actions button:focus, .ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_actions button:active {
|
||||
opacity: 1;
|
||||
background-color: #FDFDFD;
|
||||
border-color: #157EFB;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_actions button.ff_fileupload_start_upload {
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_actions_mobile {
|
||||
display: none;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_actions_mobile button {
|
||||
display: block;
|
||||
margin-top: 0.3em;
|
||||
width: 100%;
|
||||
height: 28px;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #A2B4CA;
|
||||
border-radius: 3px;
|
||||
padding: 0;
|
||||
background-color: #FCFCFC;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center center;
|
||||
opacity: 0.85;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_actions_mobile button::-moz-focus-inner {
|
||||
border: 0;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_actions_mobile button:hover, .ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_actions_mobile button:focus, .ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_actions_mobile button:active {
|
||||
opacity: 1;
|
||||
background-color: #FDFDFD;
|
||||
border-color: #157EFB;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads button.ff_fileupload_start_upload {
|
||||
background-image: url('fancy_okay.png');
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads button.ff_fileupload_remove_file {
|
||||
background-image: url('fancy_remove.png');
|
||||
}
|
||||
/* Colored buttons based on file extension for non-images. */
|
||||
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_with_color {
|
||||
color: #FFFFFF;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_a {
|
||||
background-color: #F03C3C;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_b {
|
||||
background-color: #F05A3C;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_c {
|
||||
background-color: #F0783C;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_d {
|
||||
background-color: #F0963C;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_e {
|
||||
background-color: #E0862B;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_f {
|
||||
background-color: #DCA12B;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_g {
|
||||
background-color: #C7AB1E;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_h {
|
||||
background-color: #C7C71E;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_i {
|
||||
background-color: #ABC71E;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_j {
|
||||
background-color: #8FC71E;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_k {
|
||||
background-color: #72C71E;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_l {
|
||||
background-color: #56C71E;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_m {
|
||||
background-color: #3AC71E;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_n {
|
||||
background-color: #1EC71E;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_o {
|
||||
background-color: #1EC73A;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_p {
|
||||
background-color: #1EC756;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_q {
|
||||
background-color: #1EC78F;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_r {
|
||||
background-color: #1EC7AB;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_s {
|
||||
background-color: #1EC7C7;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_t {
|
||||
background-color: #1EABC7;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_u {
|
||||
background-color: #1E8FC7;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_v {
|
||||
background-color: #1E72C7;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_w {
|
||||
background-color: #3C78F0;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_x {
|
||||
background-color: #3C5AF0;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_y {
|
||||
background-color: #3C3CF0;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_z {
|
||||
background-color: #5A3CF0;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_0 {
|
||||
background-color: #783CF0;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_1 {
|
||||
background-color: #963CF0;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_2 {
|
||||
background-color: #B43CF0;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_3 {
|
||||
background-color: #D23CF0;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_4 {
|
||||
background-color: #F03CF0;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_5 {
|
||||
background-color: #F03CD2;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_6 {
|
||||
background-color: #F03CB4;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_7 {
|
||||
background-color: #F03C96;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_8 {
|
||||
background-color: #F03C78;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_text_9 {
|
||||
background-color: #F03C5A;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_summary {
|
||||
padding: 1em;
|
||||
font-size: 0.9em;
|
||||
white-space: normal;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_summary .ff_fileupload_filename {
|
||||
width: 100%;
|
||||
font-weight: bold;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_summary .ff_fileupload_filename input {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
padding: 0.3em;
|
||||
margin-bottom: 0.1em;
|
||||
font-size: 1.0em;
|
||||
font-weight: normal;
|
||||
line-height: normal;
|
||||
border: 1px solid #BBBBBB;
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_summary .ff_fileupload_filename input:focus, .ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_summary .ff_fileupload_filename input:hover {
|
||||
border: 1px solid #888888;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_summary .ff_fileupload_errors {
|
||||
color: #A94442;
|
||||
font-weight: bold;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_summary .ff_fileupload_progress_background {
|
||||
margin-top: 0.5em;
|
||||
background-color: #CCCCCC;
|
||||
height: 2px;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_summary .ff_fileupload_progress_bar {
|
||||
background-color: #157EFB;
|
||||
width: 0;
|
||||
height: 2px;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_actions {
|
||||
width: 1px;
|
||||
text-align: right;
|
||||
}
|
||||
@media (max-width: 420px) {
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_preview_image {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
font-size: 11px;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_summary {
|
||||
padding-right: 0;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_actions {
|
||||
display: none;
|
||||
}
|
||||
.ff_fileupload_wrap table.ff_fileupload_uploads td.ff_fileupload_preview .ff_fileupload_actions_mobile {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
.ff_fileupload_dialog_background {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.85);
|
||||
z-index: 10000;
|
||||
}
|
||||
.ff_fileupload_dialog_main {
|
||||
position: absolute;
|
||||
top: 10%;
|
||||
left: 10%;
|
||||
width: 80%;
|
||||
height: 80%;
|
||||
text-align: center;
|
||||
}
|
||||
.ff_fileupload_dialog_main img {
|
||||
position: relative;
|
||||
top: 50%;
|
||||
transform: perspective(1px) translateY(-50%);
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
}
|
||||
.ff_fileupload_dialog_main audio {
|
||||
position: relative;
|
||||
top: 50%;
|
||||
transform: perspective(1px) translateY(-50%);
|
||||
width: 100%;
|
||||
}
|
||||
.ff_fileupload_dialog_main video {
|
||||
position: relative;
|
||||
top: 50%;
|
||||
transform: perspective(1px) translateY(-50%);
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
}
|
||||
BIN
assets/plugins/fancy-file-uploader/fancy_microphone.png
Normal file
BIN
assets/plugins/fancy-file-uploader/fancy_microphone.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 868 B |
BIN
assets/plugins/fancy-file-uploader/fancy_okay.png
Normal file
BIN
assets/plugins/fancy-file-uploader/fancy_okay.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 264 B |
BIN
assets/plugins/fancy-file-uploader/fancy_remove.png
Normal file
BIN
assets/plugins/fancy-file-uploader/fancy_remove.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 256 B |
BIN
assets/plugins/fancy-file-uploader/fancy_upload.png
Normal file
BIN
assets/plugins/fancy-file-uploader/fancy_upload.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
BIN
assets/plugins/fancy-file-uploader/fancy_webcam.png
Normal file
BIN
assets/plugins/fancy-file-uploader/fancy_webcam.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
785
assets/plugins/fancy-file-uploader/jquery.fancy-fileupload.js
Normal file
785
assets/plugins/fancy-file-uploader/jquery.fancy-fileupload.js
Normal file
@@ -0,0 +1,785 @@
|
||||
// jQuery plugin to display a custom jQuery File Uploader interface.
|
||||
// (C) 2019 CubicleSoft. All Rights Reserved.
|
||||
|
||||
(function($) {
|
||||
var EscapeHTML = function(text) {
|
||||
var map = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": '''
|
||||
};
|
||||
|
||||
return text.replace(/[&<>"']/g, function(m) { return map[m]; });
|
||||
}
|
||||
|
||||
var FormatStr = function(format) {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
|
||||
return format.replace(/{(\d+)}/g, function(match, number) {
|
||||
return (typeof args[number] != 'undefined' ? args[number] : match);
|
||||
});
|
||||
};
|
||||
|
||||
var GetDisplayFilesize = function(numbytes, adjustprecision, units) {
|
||||
if (numbytes == 0) return '0 Bytes';
|
||||
if (numbytes == 1) return '1 Byte';
|
||||
|
||||
numbytes = Math.abs(numbytes);
|
||||
var magnitude, abbreviations;
|
||||
if (units && units.toLowerCase() === 'iec_formal')
|
||||
{
|
||||
magnitude = Math.pow(2, 10);
|
||||
abbreviations = ['Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
|
||||
}
|
||||
else if (units && units.toLowerCase() === 'si')
|
||||
{
|
||||
magnitude = Math.pow(10, 3);
|
||||
abbreviations = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
}
|
||||
else
|
||||
{
|
||||
magnitude = Math.pow(2, 10);
|
||||
abbreviations = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
}
|
||||
|
||||
var pos = Math.floor(Math.log(numbytes) / Math.log(magnitude));
|
||||
var result = (numbytes / Math.pow(magnitude, pos));
|
||||
|
||||
return (pos == 0 || (adjustprecision && result >= 99.995) ? result.toFixed(0) : result.toFixed(2)) + ' ' + abbreviations[pos];
|
||||
};
|
||||
|
||||
var DisplayPreviewDialog = function(preview, endelem, inforow, data, settings) {
|
||||
var previewbackground = $('<div>').addClass('ff_fileupload_dialog_background');
|
||||
var previewclone = preview.clone(true, true).click(function(e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
var previewdialog = $('<div>').addClass('ff_fileupload_dialog_main').append(previewclone);
|
||||
|
||||
var HidePreviewDialog = function() {
|
||||
$(document).off('keyup.fancy_fileupload');
|
||||
|
||||
previewbackground.remove();
|
||||
endelem.focus();
|
||||
|
||||
if (settings.hidepreview) settings.hidepreview.call(inforow, data, preview, previewclone);
|
||||
};
|
||||
|
||||
$(document).on('keyup.fancy_fileupload', function(e) {
|
||||
if (e.keyCode == 27) {
|
||||
HidePreviewDialog();
|
||||
}
|
||||
});
|
||||
|
||||
previewbackground.append(previewdialog).click(function() {
|
||||
HidePreviewDialog();
|
||||
});
|
||||
|
||||
$('body').append(previewbackground);
|
||||
previewclone.focus();
|
||||
|
||||
if (settings.showpreview) settings.showpreview.call(inforow, data, preview, previewclone);
|
||||
};
|
||||
|
||||
var InitShowAriaLabelInfo = function(inforow) {
|
||||
inforow.find('button').hover(function() {
|
||||
var val = $(this).attr('aria-label');
|
||||
|
||||
if (val)
|
||||
{
|
||||
inforow.find('.ff_fileupload_buttoninfo').text(val).removeClass('ff_fileupload_hidden');
|
||||
inforow.find('.ff_fileupload_fileinfo').addClass('ff_fileupload_hidden');
|
||||
}
|
||||
}, function() {
|
||||
inforow.find('.ff_fileupload_fileinfo').removeClass('ff_fileupload_hidden');
|
||||
inforow.find('.ff_fileupload_buttoninfo').addClass('ff_fileupload_hidden');
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.FancyFileUpload = function(options) {
|
||||
this.each(function() {
|
||||
var $this = $(this);
|
||||
|
||||
// Remove the previous file uploader.
|
||||
if ($this.data('fancy-fileupload') && typeof($this.data('fancy-fileupload')) === 'object')
|
||||
{
|
||||
$this.removeClass('ff_fileupload_hidden');
|
||||
|
||||
var data = $this.data('fancy-fileupload');
|
||||
|
||||
data.form.find('input[type=file]').fileupload('destroy');
|
||||
data.form.remove();
|
||||
data.fileuploadwrap.remove();
|
||||
|
||||
$this.removeData('fancy-fileupload');
|
||||
}
|
||||
});
|
||||
|
||||
if (!$('.ff_fileupload_hidden').length)
|
||||
{
|
||||
$(document).off('drop.fancy_fileupload dragover.fancy_fileupload');
|
||||
$(window).off('beforeunload.fancy_fileupload');
|
||||
}
|
||||
|
||||
if (typeof(options) === 'string' && options === 'destroy') return this;
|
||||
|
||||
var settings = $.extend({}, $.fn.FancyFileUpload.defaults, options);
|
||||
|
||||
// Let custom callbacks make last second changes to the finalized settings.
|
||||
if (settings.preinit) settings.preinit(settings);
|
||||
|
||||
// Prevent default file drag-and-drop operations.
|
||||
$(document).off('drop.fancy_fileupload dragover.fancy_fileupload');
|
||||
$(document).on('drop.fancy_fileupload dragover.fancy_fileupload', function (e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
// Some useful functions.
|
||||
var Translate = function(str) {
|
||||
return (settings.langmap[str] ? settings.langmap[str] : str);
|
||||
};
|
||||
|
||||
// Prevent the user from leaving the page if there is an active upload.
|
||||
// Most browsers won't show the custom message. So make the relevant UI elements bounce using CSS.
|
||||
$(window).on('beforeunload.fancy_fileupload', function(e) {
|
||||
var active = $('.ff_fileupload_uploading, .ff_fileupload_starting');
|
||||
var queued = $('.ff_fileupload_queued');
|
||||
|
||||
if (active.length || queued.length)
|
||||
{
|
||||
active.removeClass('ff_fileupload_bounce');
|
||||
setTimeout(function() { active.addClass('ff_fileupload_bounce') }, 250);
|
||||
|
||||
queued.removeClass('ff_fileupload_bounce');
|
||||
setTimeout(function() { queued.addClass('ff_fileupload_bounce') }, 250);
|
||||
|
||||
if (active.length) return Translate('There is a file upload still in progress. Leaving the page will cancel the upload.\n\nAre you sure you want to leave this page?');
|
||||
if (queued.length) return Translate('There is a file that was added to the queue but the upload has not been started. Leaving the page will clear the queue and not upload the file.\n\nAre you sure you want to leave this page?');
|
||||
}
|
||||
});
|
||||
|
||||
// Create some extra DOM nodes for preview checking.
|
||||
var audioelem = document.createElement('audio');
|
||||
var videoelem = document.createElement('video');
|
||||
|
||||
var AddFile = function(uploads, e, data) {
|
||||
var inforow = $('<tr><td class="ff_fileupload_preview"><button class="ff_fileupload_preview_image" type="button"><span class="ff_fileupload_preview_text"></span></button><div class="ff_fileupload_actions_mobile"></div></td><td class="ff_fileupload_summary"><div class="ff_fileupload_filename"></div><div class="ff_fileupload_fileinfo"></div><div class="ff_fileupload_buttoninfo ff_fileupload_hidden"></div><div class="ff_fileupload_errors ff_fileupload_hidden"></div><div class="ff_fileupload_progress_background ff_fileupload_hidden"><div class="ff_fileupload_progress_bar"></div></div></td><td class="ff_fileupload_actions"></td></tr>');
|
||||
var pos = data.files[0].name.lastIndexOf('.');
|
||||
var filename = (pos > -1 ? data.files[0].name.substring(0, pos) : data.files[0].name);
|
||||
var fileext = (pos > -1 ? data.files[0].name.substring(pos + 1).toLowerCase() : '');
|
||||
var alphanum = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
||||
pos = (fileext == '' ? -1 : alphanum.indexOf(fileext.charAt(0)));
|
||||
var fileextclass = alphanum.charAt((pos > -1 ? pos : Math.floor(Math.random() * alphanum.length)));
|
||||
|
||||
// Initialize necessary callback options.
|
||||
data.ff_info = {};
|
||||
data.ff_info.errors = [];
|
||||
data.ff_info.retries = 0;
|
||||
data.ff_info.retrydelay = settings.retrydelay;
|
||||
data.ff_info.removewidget = false;
|
||||
data.ff_info.inforow = inforow;
|
||||
data.ff_info.displayfilesize = GetDisplayFilesize(data.files[0].size, settings.adjustprecision, settings.displayunits);
|
||||
data.context = inforow;
|
||||
|
||||
// A couple of functions for handling actions.
|
||||
var StartUpload = function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
// Set filename.
|
||||
if (settings.edit && !data.ff_info.errors.length)
|
||||
{
|
||||
var fileinput = inforow.find('.ff_fileupload_filename input');
|
||||
if (fileinput.length)
|
||||
{
|
||||
var newfilename = fileinput.val();
|
||||
if (fileext != '') newfilename += '.' + fileext;
|
||||
|
||||
inforow.find('.ff_fileupload_filename').text(newfilename);
|
||||
data.files[0].uploadName = newfilename;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove start upload buttons.
|
||||
inforow.find('button.ff_fileupload_start_upload').remove();
|
||||
|
||||
// Reset hover status.
|
||||
inforow.find('.ff_fileupload_fileinfo').removeClass('ff_fileupload_hidden');
|
||||
inforow.find('.ff_fileupload_buttoninfo').addClass('ff_fileupload_hidden');
|
||||
|
||||
// Set the status.
|
||||
inforow.find('.ff_fileupload_fileinfo').text(data.ff_info.displayfilesize + ' | ' + Translate('Starting upload...'));
|
||||
|
||||
// Display progress bar.
|
||||
inforow.find('.ff_fileupload_progress_background').removeClass('ff_fileupload_hidden');
|
||||
|
||||
// Alter remove buttons.
|
||||
inforow.find('button.ff_fileupload_remove_file').attr('aria-label', Translate('Cancel upload and remove from list'));
|
||||
|
||||
// Begin the actual upload.
|
||||
inforow.removeClass('ff_fileupload_queued');
|
||||
inforow.addClass('ff_fileupload_starting');
|
||||
|
||||
var SubmitUpload = function() {
|
||||
inforow.removeClass('ff_fileupload_starting');
|
||||
inforow.addClass('ff_fileupload_uploading');
|
||||
data.submit();
|
||||
};
|
||||
|
||||
if (settings.startupload) settings.startupload.call(inforow, SubmitUpload, e, data);
|
||||
else SubmitUpload();
|
||||
};
|
||||
|
||||
var RemoveFile = function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (inforow.hasClass('ff_fileupload_uploading'))
|
||||
{
|
||||
if (!confirm(Translate('This file is currently being uploaded.\n\nStop the upload and remove the file from the list?'))) return;
|
||||
|
||||
data.ff_info.removewidget = true;
|
||||
data.abort();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inforow.hasClass('ff_fileupload_starting'))
|
||||
{
|
||||
if (!confirm(Translate('This file is waiting to start.\n\nCancel the operation and remove the file from the list?'))) return;
|
||||
|
||||
if (settings.uploadcancelled) settings.uploadcancelled.call(data.ff_info.inforow, e, data);
|
||||
}
|
||||
|
||||
inforow.remove();
|
||||
|
||||
delete data.ff_info;
|
||||
}
|
||||
};
|
||||
|
||||
data.ff_info.RemoveFile = function() {
|
||||
if (inforow.hasClass('ff_fileupload_uploading'))
|
||||
{
|
||||
data.ff_info.removewidget = true;
|
||||
data.abort();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inforow.hasClass('ff_fileupload_starting'))
|
||||
{
|
||||
if (settings.uploadcancelled) settings.uploadcancelled.call(data.ff_info.inforow, e, data);
|
||||
}
|
||||
|
||||
inforow.remove();
|
||||
|
||||
delete data.ff_info;
|
||||
}
|
||||
};
|
||||
|
||||
// Thumbnail preview.
|
||||
var haspreview = false;
|
||||
var preview;
|
||||
var hasimage = false;
|
||||
if (URL && URL.createObjectURL)
|
||||
{
|
||||
var url = URL.createObjectURL(data.files[0]);
|
||||
if (url)
|
||||
{
|
||||
if (data.files[0].type === 'image/gif' || data.files[0].type === 'image/jpeg' || data.files[0].type === 'image/png')
|
||||
{
|
||||
inforow.find('.ff_fileupload_preview_image').css('background-image', 'url("' + url + '")');
|
||||
|
||||
haspreview = true;
|
||||
preview = $('<img>').attr('src', url);
|
||||
hasimage = true;
|
||||
}
|
||||
else if (data.files[0].type.lastIndexOf('audio/', 0) > -1 && audioelem.canPlayType && audioelem.canPlayType(data.files[0].type))
|
||||
{
|
||||
haspreview = true;
|
||||
preview = $('<audio>').attr('src', url).prop('controls', true);
|
||||
}
|
||||
else if (data.files[0].type.lastIndexOf('video/', 0) > -1 && videoelem.canPlayType && videoelem.canPlayType(data.files[0].type))
|
||||
{
|
||||
haspreview = true;
|
||||
preview = $('<video>').attr('src', url).prop('controls', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (haspreview)
|
||||
{
|
||||
inforow.find('.ff_fileupload_preview_image').addClass('ff_fileupload_preview_image_has_preview').attr('aria-label', Translate('Preview')).click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
this.blur();
|
||||
DisplayPreviewDialog(preview, this, inforow, data, settings);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
inforow.find('.ff_fileupload_preview_image').prop('disabled', true).attr('aria-label', Translate('No preview available')).click(function(e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
if (!hasimage) inforow.find('.ff_fileupload_preview_image').addClass('ff_fileupload_preview_text_with_color').addClass('ff_fileupload_preview_text_' + fileextclass).text(fileext);
|
||||
|
||||
// Validate inputs.
|
||||
if (settings.accept)
|
||||
{
|
||||
var found = false;
|
||||
for (var x = 0; x < settings.accept.length && !found; x++)
|
||||
{
|
||||
if (settings.accept[x] === fileext || settings.accept[x] === data.files[0].type) found = true;
|
||||
}
|
||||
|
||||
if (!found) data.ff_info.errors.push(Translate('Invalid file extension.'));
|
||||
}
|
||||
|
||||
if (settings.maxfilesize > -1 && data.files[0].size > settings.maxfilesize) data.ff_info.errors.push(FormatStr(Translate('File is too large. Maximum file size is {0}.'), GetDisplayFilesize(settings.maxfilesize, settings.adjustprecision, settings.displayunits)));
|
||||
|
||||
// Filename text field/display.
|
||||
if (settings.edit && !data.ff_info.errors.length)
|
||||
{
|
||||
inforow.find('.ff_fileupload_filename').append($('<input>').attr('type', 'text').val(filename).keydown(function(e) {
|
||||
// Start uploading if someone presses enter.
|
||||
if (e.keyCode == 13) StartUpload(e);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
inforow.find('.ff_fileupload_filename').text(data.files[0].name);
|
||||
}
|
||||
|
||||
// File/Upload information.
|
||||
inforow.find('.ff_fileupload_fileinfo').text(data.ff_info.displayfilesize + (hasimage && settings.edit && !data.ff_info.errors.length ? ' | .' + fileext : ''));
|
||||
|
||||
// Errors.
|
||||
if (data.ff_info.errors.length) inforow.find('.ff_fileupload_errors').html(data.ff_info.errors.join('<br>')).removeClass('ff_fileupload_hidden');
|
||||
|
||||
// Action buttons.
|
||||
if (!data.ff_info.errors.length)
|
||||
{
|
||||
inforow.find('.ff_fileupload_actions').append($('<button>').addClass('ff_fileupload_start_upload').attr('type', 'button').attr('aria-label', Translate('Start uploading')).click(StartUpload));
|
||||
inforow.find('.ff_fileupload_actions_mobile').append($('<button>').addClass('ff_fileupload_start_upload').attr('type', 'button').attr('aria-label', Translate('Start uploading')).click(StartUpload));
|
||||
|
||||
inforow.addClass('ff_fileupload_queued');
|
||||
}
|
||||
|
||||
inforow.find('.ff_fileupload_actions').append($('<button>').addClass('ff_fileupload_remove_file').attr('type', 'button').attr('aria-label', Translate('Remove from list')).click(RemoveFile));
|
||||
inforow.find('.ff_fileupload_actions_mobile').append($('<button>').addClass('ff_fileupload_remove_file').attr('type', 'button').attr('aria-label', Translate('Remove from list')).click(RemoveFile));
|
||||
|
||||
// Handle button hover.
|
||||
InitShowAriaLabelInfo(inforow);
|
||||
|
||||
// Improve progress bar performance during upload.
|
||||
data.ff_info.fileinfo = inforow.find('.ff_fileupload_fileinfo');
|
||||
data.ff_info.progressbar = inforow.find('.ff_fileupload_progress_bar');
|
||||
|
||||
uploads.append(inforow);
|
||||
|
||||
if (settings.added) settings.added.call(inforow, e, data);
|
||||
};
|
||||
|
||||
var UploadProgress = function(e, data) {
|
||||
var progress = (data.total < 1 ? 0 : data.loaded / data.total * 100);
|
||||
|
||||
data.ff_info.fileinfo.text(FormatStr(Translate('{0} of {1} | {2}%'), GetDisplayFilesize(data.loaded, settings.adjustprecision, settings.displayunits), data.ff_info.displayfilesize, progress.toFixed(0)));
|
||||
data.ff_info.progressbar.css('width', progress + '%');
|
||||
|
||||
if (settings.continueupload && settings.continueupload.call(data.ff_info.inforow, e, data) === false) data.abort();
|
||||
};
|
||||
|
||||
var UploadFailed = function(e, data) {
|
||||
// For handling chunked upload termination.
|
||||
if (data.ff_info.lastresult && !data.ff_info.lastresult.success)
|
||||
{
|
||||
data.result = data.ff_info.lastresult;
|
||||
data.errorThrown = 'failed_with_msg';
|
||||
}
|
||||
|
||||
if (data.errorThrown !== 'abort' && data.errorThrown !== 'failed_with_msg' && data.uploadedBytes < data.files[0].size && data.ff_info.retries < settings.retries)
|
||||
{
|
||||
data.ff_info.fileinfo.text(FormatStr(Translate('{0} | Network error, retrying in a moment... ({1})'), data.ff_info.displayfilesize, data.errorThrown));
|
||||
|
||||
data.ff_info.inforow.removeClass('ff_fileupload_uploading');
|
||||
data.ff_info.inforow.addClass('ff_fileupload_starting');
|
||||
|
||||
setTimeout(function() {
|
||||
data.ff_info.inforow.removeClass('ff_fileupload_starting');
|
||||
data.ff_info.inforow.addClass('ff_fileupload_uploading');
|
||||
data.data = null;
|
||||
data.submit();
|
||||
}, data.ff_info.retrydelay);
|
||||
|
||||
data.ff_info.retries++;
|
||||
data.ff_info.retrydelay *= 2;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
data.ff_info.inforow.removeClass('ff_fileupload_uploading');
|
||||
|
||||
if (settings.uploadcancelled) settings.uploadcancelled.call(data.ff_info.inforow, e, data);
|
||||
|
||||
if (data.ff_info.removewidget)
|
||||
{
|
||||
data.ff_info.inforow.remove();
|
||||
|
||||
delete data.ff_info;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set the error info.
|
||||
if (data.errorThrown === 'abort') data.ff_info.errors.push(Translate('The upload was cancelled.'));
|
||||
else if (data.errorThrown === 'failed_with_msg') data.ff_info.errors.push(FormatStr(Translate('The upload failed. {0} ({1})'), EscapeHTML(data.result.error), EscapeHTML(data.result.errorcode)));
|
||||
else data.ff_info.errors.push(Translate('The upload failed.'));
|
||||
data.ff_info.inforow.find('.ff_fileupload_errors').html(data.ff_info.errors.join('<br>')).removeClass('ff_fileupload_hidden');
|
||||
|
||||
// Hide the progress bar.
|
||||
data.ff_info.inforow.find('.ff_fileupload_progress_background').addClass('ff_fileupload_hidden');
|
||||
|
||||
// Alter remove buttons.
|
||||
data.ff_info.inforow.find('button.ff_fileupload_remove_file').attr('aria-label', Translate('Remove from list'));
|
||||
}
|
||||
};
|
||||
|
||||
var UploadDone = function(e, data) {
|
||||
if (!data.result.success)
|
||||
{
|
||||
if (typeof(data.result.error) !== 'string') data.result.error = Translate('The server indicated that the upload was not successful. No additional information available.');
|
||||
if (typeof(data.result.errorcode) !== 'string') data.result.errorcode = 'server_response';
|
||||
|
||||
data.errorThrown = 'failed_with_msg';
|
||||
data.ff_info.removewidget = false;
|
||||
|
||||
UploadFailed(e, data);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
data.ff_info.inforow.removeClass('ff_fileupload_uploading');
|
||||
|
||||
if (settings.uploadcompleted) settings.uploadcompleted.call(data.ff_info.inforow, e, data);
|
||||
|
||||
if (data.ff_info.removewidget)
|
||||
{
|
||||
data.ff_info.inforow.remove();
|
||||
|
||||
delete data.ff_info;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set the status.
|
||||
data.ff_info.inforow.find('.ff_fileupload_fileinfo').text(data.ff_info.displayfilesize + ' | ' + Translate('Upload completed'));
|
||||
|
||||
// Hide the progress bar.
|
||||
data.ff_info.inforow.find('.ff_fileupload_progress_background').addClass('ff_fileupload_hidden');
|
||||
|
||||
// Alter remove buttons.
|
||||
data.ff_info.inforow.find('button.ff_fileupload_remove_file').attr('aria-label', Translate('Remove from list'));
|
||||
}
|
||||
};
|
||||
|
||||
var UploadChunkSend = function(e, data) {
|
||||
if (data.ff_info)
|
||||
{
|
||||
if (settings.continueupload && settings.continueupload.call(data.ff_info.inforow, e, data) === false)
|
||||
{
|
||||
if (!data.ff_info.lastresult || data.ff_info.lastresult.success)
|
||||
{
|
||||
data.ff_info.lastresult = {
|
||||
'success' : false
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (data.ff_info.lastresult && !data.ff_info.lastresult.success)
|
||||
{
|
||||
data.result = data.ff_info.lastresult;
|
||||
|
||||
if (typeof(data.ff_info.lastresult.error) !== 'string') data.ff_info.lastresult.error = Translate('The server indicated that the upload was not successful. No additional information available.');
|
||||
if (typeof(data.ff_info.lastresult.errorcode) !== 'string') data.ff_info.lastresult.errorcode = 'server_response';
|
||||
|
||||
data.ff_info.removewidget = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var UploadChunkDone = function(e, data) {
|
||||
// Reset retries for successful chunked uploads.
|
||||
data.ff_info.retries = 0;
|
||||
data.ff_info.retrydelay = settings.retrydelay;
|
||||
|
||||
// Save for the next UploadChunkSend() call.
|
||||
data.ff_info.lastresult = data.result;
|
||||
};
|
||||
|
||||
|
||||
return this.each(function() {
|
||||
var $this = $(this);
|
||||
|
||||
// Calculate the action URL.
|
||||
if (settings.url === '')
|
||||
{
|
||||
var url = $this.closest('form').attr('action');
|
||||
if (url) settings.url = url;
|
||||
}
|
||||
|
||||
// Create a separate, hidden form on the page for handling file uploads.
|
||||
var form = $('<form>').addClass('ff_fileupload_hidden').attr({
|
||||
'action' : settings.url,
|
||||
'method' : 'post',
|
||||
'enctype' : 'multipart/form-data'
|
||||
});
|
||||
$('body').append(form);
|
||||
|
||||
// Append hidden input elements.
|
||||
for (var x in settings.params)
|
||||
{
|
||||
if (settings.params.hasOwnProperty(x))
|
||||
{
|
||||
var input = $('<input>').attr({
|
||||
'type' : 'hidden',
|
||||
'name' : x,
|
||||
'value' : settings.params[x]
|
||||
});
|
||||
|
||||
form.append(input);
|
||||
}
|
||||
}
|
||||
|
||||
// Append a file input element.
|
||||
var fileinputname = $this.attr('name');
|
||||
var fileinput = $('<input>').attr({
|
||||
'type' : 'file',
|
||||
'name' : (fileinputname ? fileinputname : 'file')
|
||||
});
|
||||
if ($this.prop('multiple')) fileinput.prop('multiple', true);
|
||||
|
||||
// Process the accepted file extensions.
|
||||
if ($this.attr('accept'))
|
||||
{
|
||||
fileinput.attr('accept', $this.attr('accept'));
|
||||
|
||||
if (!settings.accept)
|
||||
{
|
||||
var accept = $this.attr('accept').split(',');
|
||||
|
||||
settings.accept = [];
|
||||
for (var x = 0; x < accept.length; x++)
|
||||
{
|
||||
var opt = $.trim(accept[x]).toLowerCase();
|
||||
settings.accept.push(opt.indexOf('/') < 0 && opt.lastIndexOf('.') > -1 ? opt.substring(opt.lastIndexOf('.') + 1) : opt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
form.append(fileinput);
|
||||
|
||||
// Insert the widget wrapper.
|
||||
var fileuploadwrap = $('<div>').addClass('ff_fileupload_wrap');
|
||||
$this.after(fileuploadwrap);
|
||||
|
||||
// Insert a new dropzone. Using a button allows for standard keyboard and mouse navigation to the element. The wrapper is for paste support.
|
||||
var dropzonewrap = $('<div>').addClass('ff_fileupload_dropzone_wrap');
|
||||
var dropzone = $('<button>').addClass('ff_fileupload_dropzone').attr('type', 'button').attr('aria-label', Translate('Browse, drag-and-drop, or paste files to upload'));
|
||||
dropzonewrap.append(dropzone);
|
||||
fileuploadwrap.append(dropzonewrap);
|
||||
dropzone.on('click.fancy_fileupload', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
form.find('input[type=file]').click();
|
||||
});
|
||||
|
||||
// Add special recording buttons (if enabled).
|
||||
var dropzonetools = $('<div>').addClass('ff_fileupload_dropzone_tools');
|
||||
dropzonewrap.append(dropzonetools);
|
||||
|
||||
// Record audio.
|
||||
if (settings.recordaudio && navigator.mediaDevices && window.MediaRecorder)
|
||||
{
|
||||
var audiobutton = $('<button>').addClass('ff_fileupload_dropzone_tool').addClass('ff_fileupload_recordaudio').attr('type', 'button').attr('aria-label', Translate('Record audio using a microphone'));
|
||||
dropzonetools.append(audiobutton);
|
||||
|
||||
var audiorec = null;
|
||||
var audiochunks = [];
|
||||
audiobutton.click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (!audiorec)
|
||||
{
|
||||
navigator.mediaDevices.getUserMedia({ audio: true }).then(function(stream) {
|
||||
audiorec = new MediaRecorder(stream, settings.audiosettings);
|
||||
|
||||
audiorec.addEventListener('dataavailable', function(e) {
|
||||
if (e.data.size > 0) audiochunks.push(e.data);
|
||||
|
||||
if (audiorec.state === 'inactive')
|
||||
{
|
||||
var blob = new Blob(audiochunks, { type: 'audio/mp3' });
|
||||
blob.lastModifiedDate = new Date();
|
||||
blob.lastModified = Math.floor(blob.lastModifiedDate.getTime() / 1000);
|
||||
blob.name = FormatStr(Translate('Audio recording - {0}.mp3'), blob.lastModifiedDate.toLocaleString());
|
||||
|
||||
fileinput.fileupload('add', { files: [blob] });
|
||||
|
||||
stream.getTracks().forEach(function(track) {
|
||||
track.stop();
|
||||
});
|
||||
|
||||
audiobutton.removeClass('ff_fileupload_recording');
|
||||
audiochunks = [];
|
||||
audiorec = null;
|
||||
}
|
||||
});
|
||||
|
||||
audiorec.start();
|
||||
audiobutton.addClass('ff_fileupload_recording');
|
||||
}).catch(function(e) {
|
||||
alert(Translate('Unable to record audio. Either a microphone was not found or access was denied.'));
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
audiorec.stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Record video.
|
||||
if (settings.recordvideo && navigator.mediaDevices && window.MediaRecorder)
|
||||
{
|
||||
var videobutton = $('<button>').addClass('ff_fileupload_dropzone_tool').addClass('ff_fileupload_recordvideo').attr('type', 'button').attr('aria-label', Translate('Record video using a camera'));
|
||||
dropzonetools.append(videobutton);
|
||||
|
||||
var videorecpreview = $('<video>').prop('muted', true).prop('autoplay', true).addClass('ff_fileupload_recordvideo_preview').addClass('ff_fileupload_hidden');
|
||||
dropzonewrap.append(videorecpreview);
|
||||
|
||||
var videorec = null;
|
||||
var videochunks = [];
|
||||
videobutton.click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (!videorec)
|
||||
{
|
||||
var streamhandler = function(stream) {
|
||||
videorec = new MediaRecorder(stream, settings.videosettings);
|
||||
|
||||
videorec.addEventListener('dataavailable', function(e) {
|
||||
if (e.data.size > 0) videochunks.push(e.data);
|
||||
|
||||
if (videorec.state === 'inactive')
|
||||
{
|
||||
var blob = new Blob(videochunks, { type: 'video/mp4' });
|
||||
blob.lastModifiedDate = new Date();
|
||||
blob.lastModified = Math.floor(blob.lastModifiedDate.getTime() / 1000);
|
||||
blob.name = FormatStr(Translate('Video recording - {0}.mp4'), blob.lastModifiedDate.toLocaleString());
|
||||
|
||||
fileinput.fileupload('add', { files: [blob] });
|
||||
|
||||
stream.getTracks().forEach(function(track) {
|
||||
track.stop();
|
||||
});
|
||||
|
||||
videobutton.removeClass('ff_fileupload_recording');
|
||||
videorecpreview.addClass('ff_fileupload_hidden');
|
||||
if (videorecpreview[0].src !== '') videorecpreview[0].src = '';
|
||||
videorecpreview[0].srcObject = null;
|
||||
videochunks = [];
|
||||
videorec = null;
|
||||
}
|
||||
});
|
||||
|
||||
videorec.start();
|
||||
videobutton.addClass('ff_fileupload_recording');
|
||||
|
||||
// Display a preview box with just the video stream.
|
||||
try { videorecpreview[0].src = URL.createObjectURL(stream); } catch(e) { videorecpreview[0].srcObject = stream; }
|
||||
|
||||
videorecpreview.removeClass('ff_fileupload_hidden');
|
||||
};
|
||||
|
||||
// Video with audio (e.g. webcam) with fallback to video only (e.g. some screen recording codecs).
|
||||
navigator.mediaDevices.getUserMedia({ video: true, audio: true }).then(streamhandler).catch(function(e) {
|
||||
navigator.mediaDevices.getUserMedia({ video: true }).then(streamhandler).catch(function(e) {
|
||||
alert(Translate('Unable to record video. Either a camera was not found or access was denied.'));
|
||||
});
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
videorec.stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Add a table to track unprocessed and in-progress uploads.
|
||||
var uploads = $('<table>').addClass('ff_fileupload_uploads');
|
||||
fileuploadwrap.append(uploads);
|
||||
|
||||
// Hide the starting element.
|
||||
$this.addClass('ff_fileupload_hidden');
|
||||
|
||||
// Initialize jQuery File Upload using the hidden form and visible dropzone.
|
||||
var baseoptions = {
|
||||
url: settings.url,
|
||||
dataType: 'json',
|
||||
pasteZone: dropzonewrap,
|
||||
limitConcurrentUploads: 2
|
||||
};
|
||||
|
||||
// Immutable options.
|
||||
var immutableoptions = {
|
||||
singleFileUploads: true,
|
||||
dropZone: dropzone,
|
||||
add: function(e, data) { AddFile(uploads, e, data) },
|
||||
progress: UploadProgress,
|
||||
fail: UploadFailed,
|
||||
done: UploadDone,
|
||||
chunksend: UploadChunkSend,
|
||||
chunkdone: UploadChunkDone
|
||||
};
|
||||
|
||||
// The user interface requires certain options to be set correctly.
|
||||
fileinput.fileupload($.extend(baseoptions, settings.fileupload, immutableoptions));
|
||||
|
||||
// Save necessary information in case the uploader is destroyed later.
|
||||
$this.data('fancy-fileupload', {
|
||||
'fileuploadwrap' : fileuploadwrap,
|
||||
'form' : form,
|
||||
'settings': settings
|
||||
});
|
||||
|
||||
// Post-initialization callback.
|
||||
if (settings.postinit) settings.postinit.call($this);
|
||||
});
|
||||
}
|
||||
|
||||
$.fn.FancyFileUpload.defaults = {
|
||||
'url' : '',
|
||||
'params' : {},
|
||||
'edit' : true,
|
||||
'maxfilesize' : -1,
|
||||
'accept' : null,
|
||||
'displayunits' : 'iec_windows',
|
||||
'adjustprecision' : true,
|
||||
'retries' : 5,
|
||||
'retrydelay' : 500,
|
||||
'recordaudio' : false,
|
||||
'audiosettings' : {},
|
||||
'recordvideo' : false,
|
||||
'videosettings' : {},
|
||||
'preinit' : null,
|
||||
'postinit' : null,
|
||||
'added' : null,
|
||||
'showpreview' : null,
|
||||
'hidepreview' : null,
|
||||
'startupload' : null,
|
||||
'continueupload' : null,
|
||||
'uploadcancelled' : null,
|
||||
'uploadcompleted' : null,
|
||||
'fileupload' : {},
|
||||
'langmap' : {}
|
||||
};
|
||||
}(jQuery));
|
||||
1597
assets/plugins/fancy-file-uploader/jquery.fileupload.js
vendored
Normal file
1597
assets/plugins/fancy-file-uploader/jquery.fileupload.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
221
assets/plugins/fancy-file-uploader/jquery.iframe-transport.js
Normal file
221
assets/plugins/fancy-file-uploader/jquery.iframe-transport.js
Normal file
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* jQuery Iframe Transport Plugin
|
||||
* https://github.com/blueimp/jQuery-File-Upload
|
||||
*
|
||||
* Copyright 2011, Sebastian Tschan
|
||||
* https://blueimp.net
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
/* global define, require */
|
||||
|
||||
(function (factory) {
|
||||
'use strict';
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// Register as an anonymous AMD module:
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node/CommonJS:
|
||||
factory(require('jquery'));
|
||||
} else {
|
||||
// Browser globals:
|
||||
factory(window.jQuery);
|
||||
}
|
||||
})(function ($) {
|
||||
'use strict';
|
||||
|
||||
// Helper variable to create unique names for the transport iframes:
|
||||
var counter = 0,
|
||||
jsonAPI = $,
|
||||
jsonParse = 'parseJSON';
|
||||
|
||||
if ('JSON' in window && 'parse' in JSON) {
|
||||
jsonAPI = JSON;
|
||||
jsonParse = 'parse';
|
||||
}
|
||||
|
||||
// The iframe transport accepts four 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}]
|
||||
// options.initialIframeSrc: the URL of the initial iframe src,
|
||||
// by default set to "javascript:false;"
|
||||
$.ajaxTransport('iframe', function (options) {
|
||||
if (options.async) {
|
||||
// javascript:false as initial iframe src
|
||||
// prevents warning popups on HTTPS in IE6:
|
||||
// eslint-disable-next-line no-script-url
|
||||
var initialIframeSrc = options.initialIframeSrc || 'javascript:false;',
|
||||
form,
|
||||
iframe,
|
||||
addParamChar;
|
||||
return {
|
||||
send: function (_, completeCallback) {
|
||||
form = $('<form style="display:none;"></form>');
|
||||
form.attr('accept-charset', options.formAcceptCharset);
|
||||
addParamChar = /\?/.test(options.url) ? '&' : '?';
|
||||
// XDomainRequest only supports GET and POST:
|
||||
if (options.type === 'DELETE') {
|
||||
options.url = options.url + addParamChar + '_method=DELETE';
|
||||
options.type = 'POST';
|
||||
} else if (options.type === 'PUT') {
|
||||
options.url = options.url + addParamChar + '_method=PUT';
|
||||
options.type = 'POST';
|
||||
} else if (options.type === 'PATCH') {
|
||||
options.url = options.url + addParamChar + '_method=PATCH';
|
||||
options.type = 'POST';
|
||||
}
|
||||
// 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:
|
||||
counter += 1;
|
||||
iframe = $(
|
||||
'<iframe src="' +
|
||||
initialIframeSrc +
|
||||
'" name="iframe-transport-' +
|
||||
counter +
|
||||
'"></iframe>'
|
||||
).on('load', function () {
|
||||
var fileInputClones,
|
||||
paramNames = $.isArray(options.paramName)
|
||||
? options.paramName
|
||||
: [options.paramName];
|
||||
iframe.off('load').on('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="' + initialIframeSrc + '"></iframe>').appendTo(
|
||||
form
|
||||
);
|
||||
window.setTimeout(function () {
|
||||
// Removing the form in a setTimeout call
|
||||
// allows Chrome's developer tools to display
|
||||
// the response result
|
||||
form.remove();
|
||||
}, 0);
|
||||
});
|
||||
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');
|
||||
// Remove the HTML5 form attribute from the input(s):
|
||||
options.fileInput.removeAttr('form');
|
||||
}
|
||||
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]);
|
||||
// Restore the original name and form properties:
|
||||
$(input)
|
||||
.prop('name', clone.prop('name'))
|
||||
.attr('form', clone.attr('form'));
|
||||
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.
|
||||
iframe.off('load').prop('src', initialIframeSrc);
|
||||
}
|
||||
if (form) {
|
||||
form.remove();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// The iframe transport returns the iframe content document as response.
|
||||
// The following adds converters from iframe to text, json, html, xml
|
||||
// and script.
|
||||
// Please note that the Content-Type for JSON responses has to be text/plain
|
||||
// or text/html, if the browser doesn't include application/json in the
|
||||
// Accept header, else IE will show a download dialog.
|
||||
// The Content-Type for XML responses on the other hand has to be always
|
||||
// application/xml or text/xml, so IE properly parses the XML response.
|
||||
// See also
|
||||
// https://github.com/blueimp/jQuery-File-Upload/wiki/Setup#content-type-negotiation
|
||||
$.ajaxSetup({
|
||||
converters: {
|
||||
'iframe text': function (iframe) {
|
||||
return iframe && $(iframe[0].body).text();
|
||||
},
|
||||
'iframe json': function (iframe) {
|
||||
return iframe && jsonAPI[jsonParse]($(iframe[0].body).text());
|
||||
},
|
||||
'iframe html': function (iframe) {
|
||||
return iframe && $(iframe[0].body).html();
|
||||
},
|
||||
'iframe xml': function (iframe) {
|
||||
var xmlDoc = iframe && iframe[0];
|
||||
return xmlDoc && $.isXMLDoc(xmlDoc)
|
||||
? xmlDoc
|
||||
: $.parseXML(
|
||||
(xmlDoc.XMLDocument && xmlDoc.XMLDocument.xml) ||
|
||||
$(xmlDoc.body).html()
|
||||
);
|
||||
},
|
||||
'iframe script': function (iframe) {
|
||||
return iframe && $.globalEval($(iframe[0].body).text());
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
808
assets/plugins/fancy-file-uploader/jquery.ui.widget.js
vendored
Normal file
808
assets/plugins/fancy-file-uploader/jquery.ui.widget.js
vendored
Normal file
@@ -0,0 +1,808 @@
|
||||
/*! jQuery UI - v1.12.1+0b7246b6eeadfa9e2696e22f3230f6452f8129dc - 2020-02-20
|
||||
* http://jqueryui.com
|
||||
* Includes: widget.js
|
||||
* Copyright jQuery Foundation and other contributors; Licensed MIT */
|
||||
|
||||
/* global define, require */
|
||||
/* eslint-disable no-param-reassign, new-cap, jsdoc/require-jsdoc */
|
||||
|
||||
(function (factory) {
|
||||
'use strict';
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node/CommonJS
|
||||
factory(require('jquery'));
|
||||
} else {
|
||||
// Browser globals
|
||||
factory(window.jQuery);
|
||||
}
|
||||
})(function ($) {
|
||||
('use strict');
|
||||
|
||||
$.ui = $.ui || {};
|
||||
|
||||
$.ui.version = '1.12.1';
|
||||
|
||||
/*!
|
||||
* jQuery UI Widget 1.12.1
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Widget
|
||||
//>>group: Core
|
||||
//>>description: Provides a factory for creating stateful widgets with a common API.
|
||||
//>>docs: http://api.jqueryui.com/jQuery.widget/
|
||||
//>>demos: http://jqueryui.com/widget/
|
||||
|
||||
// Support: jQuery 1.9.x or older
|
||||
// $.expr[ ":" ] is deprecated.
|
||||
if (!$.expr.pseudos) {
|
||||
$.expr.pseudos = $.expr[':'];
|
||||
}
|
||||
|
||||
// Support: jQuery 1.11.x or older
|
||||
// $.unique has been renamed to $.uniqueSort
|
||||
if (!$.uniqueSort) {
|
||||
$.uniqueSort = $.unique;
|
||||
}
|
||||
|
||||
var widgetUuid = 0;
|
||||
var widgetHasOwnProperty = Array.prototype.hasOwnProperty;
|
||||
var widgetSlice = Array.prototype.slice;
|
||||
|
||||
$.cleanData = (function (orig) {
|
||||
return function (elems) {
|
||||
var events, elem, i;
|
||||
// eslint-disable-next-line eqeqeq
|
||||
for (i = 0; (elem = elems[i]) != null; i++) {
|
||||
// Only trigger remove when necessary to save time
|
||||
events = $._data(elem, 'events');
|
||||
if (events && events.remove) {
|
||||
$(elem).triggerHandler('remove');
|
||||
}
|
||||
}
|
||||
orig(elems);
|
||||
};
|
||||
})($.cleanData);
|
||||
|
||||
$.widget = function (name, base, prototype) {
|
||||
var existingConstructor, constructor, basePrototype;
|
||||
|
||||
// ProxiedPrototype allows the provided prototype to remain unmodified
|
||||
// so that it can be used as a mixin for multiple widgets (#8876)
|
||||
var proxiedPrototype = {};
|
||||
|
||||
var namespace = name.split('.')[0];
|
||||
name = name.split('.')[1];
|
||||
var fullName = namespace + '-' + name;
|
||||
|
||||
if (!prototype) {
|
||||
prototype = base;
|
||||
base = $.Widget;
|
||||
}
|
||||
|
||||
if ($.isArray(prototype)) {
|
||||
prototype = $.extend.apply(null, [{}].concat(prototype));
|
||||
}
|
||||
|
||||
// Create selector for plugin
|
||||
$.expr.pseudos[fullName.toLowerCase()] = function (elem) {
|
||||
return !!$.data(elem, fullName);
|
||||
};
|
||||
|
||||
$[namespace] = $[namespace] || {};
|
||||
existingConstructor = $[namespace][name];
|
||||
constructor = $[namespace][name] = function (options, element) {
|
||||
// Allow instantiation without "new" keyword
|
||||
if (!this._createWidget) {
|
||||
return new constructor(options, element);
|
||||
}
|
||||
|
||||
// Allow instantiation without initializing for simple inheritance
|
||||
// must use "new" keyword (the code above always passes args)
|
||||
if (arguments.length) {
|
||||
this._createWidget(options, element);
|
||||
}
|
||||
};
|
||||
|
||||
// Extend with the existing constructor to carry over any static properties
|
||||
$.extend(constructor, existingConstructor, {
|
||||
version: prototype.version,
|
||||
|
||||
// Copy the object used to create the prototype in case we need to
|
||||
// redefine the widget later
|
||||
_proto: $.extend({}, prototype),
|
||||
|
||||
// Track widgets that inherit from this widget in case this widget is
|
||||
// redefined after a widget inherits from it
|
||||
_childConstructors: []
|
||||
});
|
||||
|
||||
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
|
||||
basePrototype.options = $.widget.extend({}, basePrototype.options);
|
||||
$.each(prototype, function (prop, value) {
|
||||
if (!$.isFunction(value)) {
|
||||
proxiedPrototype[prop] = value;
|
||||
return;
|
||||
}
|
||||
proxiedPrototype[prop] = (function () {
|
||||
function _super() {
|
||||
return base.prototype[prop].apply(this, arguments);
|
||||
}
|
||||
|
||||
function _superApply(args) {
|
||||
return base.prototype[prop].apply(this, args);
|
||||
}
|
||||
|
||||
return function () {
|
||||
var __super = this._super;
|
||||
var __superApply = this._superApply;
|
||||
var returnValue;
|
||||
|
||||
this._super = _super;
|
||||
this._superApply = _superApply;
|
||||
|
||||
returnValue = value.apply(this, arguments);
|
||||
|
||||
this._super = __super;
|
||||
this._superApply = __superApply;
|
||||
|
||||
return returnValue;
|
||||
};
|
||||
})();
|
||||
});
|
||||
constructor.prototype = $.widget.extend(
|
||||
basePrototype,
|
||||
{
|
||||
// TODO: remove support for widgetEventPrefix
|
||||
// always use the name + a colon as the prefix, e.g., draggable:start
|
||||
// don't prefix for widgets that aren't DOM-based
|
||||
widgetEventPrefix: existingConstructor
|
||||
? basePrototype.widgetEventPrefix || name
|
||||
: name
|
||||
},
|
||||
proxiedPrototype,
|
||||
{
|
||||
constructor: constructor,
|
||||
namespace: namespace,
|
||||
widgetName: name,
|
||||
widgetFullName: fullName
|
||||
}
|
||||
);
|
||||
|
||||
// If this widget is being redefined then we need to find all widgets that
|
||||
// are inheriting from it and redefine all of them so that they inherit from
|
||||
// the new version of this widget. We're essentially trying to replace one
|
||||
// level in the prototype chain.
|
||||
if (existingConstructor) {
|
||||
$.each(existingConstructor._childConstructors, function (i, child) {
|
||||
var childPrototype = child.prototype;
|
||||
|
||||
// Redefine the child widget using the same prototype that was
|
||||
// originally used, but inherit from the new version of the base
|
||||
$.widget(
|
||||
childPrototype.namespace + '.' + childPrototype.widgetName,
|
||||
constructor,
|
||||
child._proto
|
||||
);
|
||||
});
|
||||
|
||||
// Remove the list of existing child constructors from the old constructor
|
||||
// so the old child constructors can be garbage collected
|
||||
delete existingConstructor._childConstructors;
|
||||
} else {
|
||||
base._childConstructors.push(constructor);
|
||||
}
|
||||
|
||||
$.widget.bridge(name, constructor);
|
||||
|
||||
return constructor;
|
||||
};
|
||||
|
||||
$.widget.extend = function (target) {
|
||||
var input = widgetSlice.call(arguments, 1);
|
||||
var inputIndex = 0;
|
||||
var inputLength = input.length;
|
||||
var key;
|
||||
var value;
|
||||
|
||||
for (; inputIndex < inputLength; inputIndex++) {
|
||||
for (key in input[inputIndex]) {
|
||||
value = input[inputIndex][key];
|
||||
if (
|
||||
widgetHasOwnProperty.call(input[inputIndex], key) &&
|
||||
value !== undefined
|
||||
) {
|
||||
// Clone objects
|
||||
if ($.isPlainObject(value)) {
|
||||
target[key] = $.isPlainObject(target[key])
|
||||
? $.widget.extend({}, target[key], value)
|
||||
: // Don't extend strings, arrays, etc. with objects
|
||||
$.widget.extend({}, value);
|
||||
|
||||
// Copy everything else by reference
|
||||
} else {
|
||||
target[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return target;
|
||||
};
|
||||
|
||||
$.widget.bridge = function (name, object) {
|
||||
var fullName = object.prototype.widgetFullName || name;
|
||||
$.fn[name] = function (options) {
|
||||
var isMethodCall = typeof options === 'string';
|
||||
var args = widgetSlice.call(arguments, 1);
|
||||
var returnValue = this;
|
||||
|
||||
if (isMethodCall) {
|
||||
// If this is an empty collection, we need to have the instance method
|
||||
// return undefined instead of the jQuery instance
|
||||
if (!this.length && options === 'instance') {
|
||||
returnValue = undefined;
|
||||
} else {
|
||||
this.each(function () {
|
||||
var methodValue;
|
||||
var instance = $.data(this, fullName);
|
||||
|
||||
if (options === 'instance') {
|
||||
returnValue = instance;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!instance) {
|
||||
return $.error(
|
||||
'cannot call methods on ' +
|
||||
name +
|
||||
' prior to initialization; ' +
|
||||
"attempted to call method '" +
|
||||
options +
|
||||
"'"
|
||||
);
|
||||
}
|
||||
|
||||
if (!$.isFunction(instance[options]) || options.charAt(0) === '_') {
|
||||
return $.error(
|
||||
"no such method '" +
|
||||
options +
|
||||
"' for " +
|
||||
name +
|
||||
' widget instance'
|
||||
);
|
||||
}
|
||||
|
||||
methodValue = instance[options].apply(instance, args);
|
||||
|
||||
if (methodValue !== instance && methodValue !== undefined) {
|
||||
returnValue =
|
||||
methodValue && methodValue.jquery
|
||||
? returnValue.pushStack(methodValue.get())
|
||||
: methodValue;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Allow multiple hashes to be passed on init
|
||||
if (args.length) {
|
||||
options = $.widget.extend.apply(null, [options].concat(args));
|
||||
}
|
||||
|
||||
this.each(function () {
|
||||
var instance = $.data(this, fullName);
|
||||
if (instance) {
|
||||
instance.option(options || {});
|
||||
if (instance._init) {
|
||||
instance._init();
|
||||
}
|
||||
} else {
|
||||
$.data(this, fullName, new object(options, this));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
};
|
||||
};
|
||||
|
||||
$.Widget = function (/* options, element */) {};
|
||||
$.Widget._childConstructors = [];
|
||||
|
||||
$.Widget.prototype = {
|
||||
widgetName: 'widget',
|
||||
widgetEventPrefix: '',
|
||||
defaultElement: '<div>',
|
||||
|
||||
options: {
|
||||
classes: {},
|
||||
disabled: false,
|
||||
|
||||
// Callbacks
|
||||
create: null
|
||||
},
|
||||
|
||||
_createWidget: function (options, element) {
|
||||
element = $(element || this.defaultElement || this)[0];
|
||||
this.element = $(element);
|
||||
this.uuid = widgetUuid++;
|
||||
this.eventNamespace = '.' + this.widgetName + this.uuid;
|
||||
|
||||
this.bindings = $();
|
||||
this.hoverable = $();
|
||||
this.focusable = $();
|
||||
this.classesElementLookup = {};
|
||||
|
||||
if (element !== this) {
|
||||
$.data(element, this.widgetFullName, this);
|
||||
this._on(true, this.element, {
|
||||
remove: function (event) {
|
||||
if (event.target === element) {
|
||||
this.destroy();
|
||||
}
|
||||
}
|
||||
});
|
||||
this.document = $(
|
||||
element.style
|
||||
? // Element within the document
|
||||
element.ownerDocument
|
||||
: // Element is window or document
|
||||
element.document || element
|
||||
);
|
||||
this.window = $(
|
||||
this.document[0].defaultView || this.document[0].parentWindow
|
||||
);
|
||||
}
|
||||
|
||||
this.options = $.widget.extend(
|
||||
{},
|
||||
this.options,
|
||||
this._getCreateOptions(),
|
||||
options
|
||||
);
|
||||
|
||||
this._create();
|
||||
|
||||
if (this.options.disabled) {
|
||||
this._setOptionDisabled(this.options.disabled);
|
||||
}
|
||||
|
||||
this._trigger('create', null, this._getCreateEventData());
|
||||
this._init();
|
||||
},
|
||||
|
||||
_getCreateOptions: function () {
|
||||
return {};
|
||||
},
|
||||
|
||||
_getCreateEventData: $.noop,
|
||||
|
||||
_create: $.noop,
|
||||
|
||||
_init: $.noop,
|
||||
|
||||
destroy: function () {
|
||||
var that = this;
|
||||
|
||||
this._destroy();
|
||||
$.each(this.classesElementLookup, function (key, value) {
|
||||
that._removeClass(value, key);
|
||||
});
|
||||
|
||||
// We can probably remove the unbind calls in 2.0
|
||||
// all event bindings should go through this._on()
|
||||
this.element.off(this.eventNamespace).removeData(this.widgetFullName);
|
||||
this.widget().off(this.eventNamespace).removeAttr('aria-disabled');
|
||||
|
||||
// Clean up events and states
|
||||
this.bindings.off(this.eventNamespace);
|
||||
},
|
||||
|
||||
_destroy: $.noop,
|
||||
|
||||
widget: function () {
|
||||
return this.element;
|
||||
},
|
||||
|
||||
option: function (key, value) {
|
||||
var options = key;
|
||||
var parts;
|
||||
var curOption;
|
||||
var i;
|
||||
|
||||
if (arguments.length === 0) {
|
||||
// Don't return a reference to the internal hash
|
||||
return $.widget.extend({}, this.options);
|
||||
}
|
||||
|
||||
if (typeof key === 'string') {
|
||||
// Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
|
||||
options = {};
|
||||
parts = key.split('.');
|
||||
key = parts.shift();
|
||||
if (parts.length) {
|
||||
curOption = options[key] = $.widget.extend({}, this.options[key]);
|
||||
for (i = 0; i < parts.length - 1; i++) {
|
||||
curOption[parts[i]] = curOption[parts[i]] || {};
|
||||
curOption = curOption[parts[i]];
|
||||
}
|
||||
key = parts.pop();
|
||||
if (arguments.length === 1) {
|
||||
return curOption[key] === undefined ? null : curOption[key];
|
||||
}
|
||||
curOption[key] = value;
|
||||
} else {
|
||||
if (arguments.length === 1) {
|
||||
return this.options[key] === undefined ? null : this.options[key];
|
||||
}
|
||||
options[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
this._setOptions(options);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
_setOptions: function (options) {
|
||||
var key;
|
||||
|
||||
for (key in options) {
|
||||
this._setOption(key, options[key]);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
_setOption: function (key, value) {
|
||||
if (key === 'classes') {
|
||||
this._setOptionClasses(value);
|
||||
}
|
||||
|
||||
this.options[key] = value;
|
||||
|
||||
if (key === 'disabled') {
|
||||
this._setOptionDisabled(value);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
_setOptionClasses: function (value) {
|
||||
var classKey, elements, currentElements;
|
||||
|
||||
for (classKey in value) {
|
||||
currentElements = this.classesElementLookup[classKey];
|
||||
if (
|
||||
value[classKey] === this.options.classes[classKey] ||
|
||||
!currentElements ||
|
||||
!currentElements.length
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// We are doing this to create a new jQuery object because the _removeClass() call
|
||||
// on the next line is going to destroy the reference to the current elements being
|
||||
// tracked. We need to save a copy of this collection so that we can add the new classes
|
||||
// below.
|
||||
elements = $(currentElements.get());
|
||||
this._removeClass(currentElements, classKey);
|
||||
|
||||
// We don't use _addClass() here, because that uses this.options.classes
|
||||
// for generating the string of classes. We want to use the value passed in from
|
||||
// _setOption(), this is the new value of the classes option which was passed to
|
||||
// _setOption(). We pass this value directly to _classes().
|
||||
elements.addClass(
|
||||
this._classes({
|
||||
element: elements,
|
||||
keys: classKey,
|
||||
classes: value,
|
||||
add: true
|
||||
})
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
_setOptionDisabled: function (value) {
|
||||
this._toggleClass(
|
||||
this.widget(),
|
||||
this.widgetFullName + '-disabled',
|
||||
null,
|
||||
!!value
|
||||
);
|
||||
|
||||
// If the widget is becoming disabled, then nothing is interactive
|
||||
if (value) {
|
||||
this._removeClass(this.hoverable, null, 'ui-state-hover');
|
||||
this._removeClass(this.focusable, null, 'ui-state-focus');
|
||||
}
|
||||
},
|
||||
|
||||
enable: function () {
|
||||
return this._setOptions({ disabled: false });
|
||||
},
|
||||
|
||||
disable: function () {
|
||||
return this._setOptions({ disabled: true });
|
||||
},
|
||||
|
||||
_classes: function (options) {
|
||||
var full = [];
|
||||
var that = this;
|
||||
|
||||
options = $.extend(
|
||||
{
|
||||
element: this.element,
|
||||
classes: this.options.classes || {}
|
||||
},
|
||||
options
|
||||
);
|
||||
|
||||
function bindRemoveEvent() {
|
||||
options.element.each(function (_, element) {
|
||||
var isTracked = $.map(that.classesElementLookup, function (elements) {
|
||||
return elements;
|
||||
}).some(function (elements) {
|
||||
return elements.is(element);
|
||||
});
|
||||
|
||||
if (!isTracked) {
|
||||
that._on($(element), {
|
||||
remove: '_untrackClassesElement'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function processClassString(classes, checkOption) {
|
||||
var current, i;
|
||||
for (i = 0; i < classes.length; i++) {
|
||||
current = that.classesElementLookup[classes[i]] || $();
|
||||
if (options.add) {
|
||||
bindRemoveEvent();
|
||||
current = $(
|
||||
$.uniqueSort(current.get().concat(options.element.get()))
|
||||
);
|
||||
} else {
|
||||
current = $(current.not(options.element).get());
|
||||
}
|
||||
that.classesElementLookup[classes[i]] = current;
|
||||
full.push(classes[i]);
|
||||
if (checkOption && options.classes[classes[i]]) {
|
||||
full.push(options.classes[classes[i]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (options.keys) {
|
||||
processClassString(options.keys.match(/\S+/g) || [], true);
|
||||
}
|
||||
if (options.extra) {
|
||||
processClassString(options.extra.match(/\S+/g) || []);
|
||||
}
|
||||
|
||||
return full.join(' ');
|
||||
},
|
||||
|
||||
_untrackClassesElement: function (event) {
|
||||
var that = this;
|
||||
$.each(that.classesElementLookup, function (key, value) {
|
||||
if ($.inArray(event.target, value) !== -1) {
|
||||
that.classesElementLookup[key] = $(value.not(event.target).get());
|
||||
}
|
||||
});
|
||||
|
||||
this._off($(event.target));
|
||||
},
|
||||
|
||||
_removeClass: function (element, keys, extra) {
|
||||
return this._toggleClass(element, keys, extra, false);
|
||||
},
|
||||
|
||||
_addClass: function (element, keys, extra) {
|
||||
return this._toggleClass(element, keys, extra, true);
|
||||
},
|
||||
|
||||
_toggleClass: function (element, keys, extra, add) {
|
||||
add = typeof add === 'boolean' ? add : extra;
|
||||
var shift = typeof element === 'string' || element === null,
|
||||
options = {
|
||||
extra: shift ? keys : extra,
|
||||
keys: shift ? element : keys,
|
||||
element: shift ? this.element : element,
|
||||
add: add
|
||||
};
|
||||
options.element.toggleClass(this._classes(options), add);
|
||||
return this;
|
||||
},
|
||||
|
||||
_on: function (suppressDisabledCheck, element, handlers) {
|
||||
var delegateElement;
|
||||
var instance = this;
|
||||
|
||||
// No suppressDisabledCheck flag, shuffle arguments
|
||||
if (typeof suppressDisabledCheck !== 'boolean') {
|
||||
handlers = element;
|
||||
element = suppressDisabledCheck;
|
||||
suppressDisabledCheck = false;
|
||||
}
|
||||
|
||||
// No element argument, shuffle and use this.element
|
||||
if (!handlers) {
|
||||
handlers = element;
|
||||
element = this.element;
|
||||
delegateElement = this.widget();
|
||||
} else {
|
||||
element = delegateElement = $(element);
|
||||
this.bindings = this.bindings.add(element);
|
||||
}
|
||||
|
||||
$.each(handlers, function (event, handler) {
|
||||
function handlerProxy() {
|
||||
// Allow widgets to customize the disabled handling
|
||||
// - disabled as an array instead of boolean
|
||||
// - disabled class as method for disabling individual parts
|
||||
if (
|
||||
!suppressDisabledCheck &&
|
||||
(instance.options.disabled === true ||
|
||||
$(this).hasClass('ui-state-disabled'))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
return (typeof handler === 'string'
|
||||
? instance[handler]
|
||||
: handler
|
||||
).apply(instance, arguments);
|
||||
}
|
||||
|
||||
// Copy the guid so direct unbinding works
|
||||
if (typeof handler !== 'string') {
|
||||
handlerProxy.guid = handler.guid =
|
||||
handler.guid || handlerProxy.guid || $.guid++;
|
||||
}
|
||||
|
||||
var match = event.match(/^([\w:-]*)\s*(.*)$/);
|
||||
var eventName = match[1] + instance.eventNamespace;
|
||||
var selector = match[2];
|
||||
|
||||
if (selector) {
|
||||
delegateElement.on(eventName, selector, handlerProxy);
|
||||
} else {
|
||||
element.on(eventName, handlerProxy);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_off: function (element, eventName) {
|
||||
eventName =
|
||||
(eventName || '').split(' ').join(this.eventNamespace + ' ') +
|
||||
this.eventNamespace;
|
||||
element.off(eventName);
|
||||
|
||||
// Clear the stack to avoid memory leaks (#10056)
|
||||
this.bindings = $(this.bindings.not(element).get());
|
||||
this.focusable = $(this.focusable.not(element).get());
|
||||
this.hoverable = $(this.hoverable.not(element).get());
|
||||
},
|
||||
|
||||
_delay: function (handler, delay) {
|
||||
var instance = this;
|
||||
function handlerProxy() {
|
||||
return (typeof handler === 'string'
|
||||
? instance[handler]
|
||||
: handler
|
||||
).apply(instance, arguments);
|
||||
}
|
||||
return setTimeout(handlerProxy, delay || 0);
|
||||
},
|
||||
|
||||
_hoverable: function (element) {
|
||||
this.hoverable = this.hoverable.add(element);
|
||||
this._on(element, {
|
||||
mouseenter: function (event) {
|
||||
this._addClass($(event.currentTarget), null, 'ui-state-hover');
|
||||
},
|
||||
mouseleave: function (event) {
|
||||
this._removeClass($(event.currentTarget), null, 'ui-state-hover');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_focusable: function (element) {
|
||||
this.focusable = this.focusable.add(element);
|
||||
this._on(element, {
|
||||
focusin: function (event) {
|
||||
this._addClass($(event.currentTarget), null, 'ui-state-focus');
|
||||
},
|
||||
focusout: function (event) {
|
||||
this._removeClass($(event.currentTarget), null, 'ui-state-focus');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_trigger: function (type, event, data) {
|
||||
var prop, orig;
|
||||
var 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.apply(this.element[0], [event].concat(data)) === false) ||
|
||||
event.isDefaultPrevented()
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
$.each({ show: 'fadeIn', hide: 'fadeOut' }, function (method, defaultEffect) {
|
||||
$.Widget.prototype['_' + method] = function (element, options, callback) {
|
||||
if (typeof options === 'string') {
|
||||
options = { effect: options };
|
||||
}
|
||||
|
||||
var hasOptions;
|
||||
var effectName = !options
|
||||
? method
|
||||
: options === true || typeof options === 'number'
|
||||
? defaultEffect
|
||||
: options.effect || defaultEffect;
|
||||
|
||||
options = options || {};
|
||||
if (typeof options === 'number') {
|
||||
options = { duration: options };
|
||||
}
|
||||
|
||||
hasOptions = !$.isEmptyObject(options);
|
||||
options.complete = callback;
|
||||
|
||||
if (options.delay) {
|
||||
element.delay(options.delay);
|
||||
}
|
||||
|
||||
if (hasOptions && $.effects && $.effects.effect[effectName]) {
|
||||
element[method](options);
|
||||
} else if (effectName !== method && element[effectName]) {
|
||||
element[effectName](options.duration, options.easing, callback);
|
||||
} else {
|
||||
element.queue(function (next) {
|
||||
$(this)[method]();
|
||||
if (callback) {
|
||||
callback.call(element[0]);
|
||||
}
|
||||
next();
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user