mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-20 15:52:24 +02:00
jQuery modernization : updated libraries to a version compatible with jquery 1.12.4
SVN:trunk[5357]
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* jQuery Autocomplete plugin 1.1
|
||||
* jQuery Autocomplete plugin 1.2.3
|
||||
*
|
||||
* Copyright (c) 2009 Jörn Zaefferer
|
||||
*
|
||||
@@ -7,19 +7,25 @@
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Revision: $Id: jquery.autocomplete.js 15 2009-08-22 10:30:27Z joern.zaefferer $
|
||||
* With small modifications by Alfonso Gómez-Arzola.
|
||||
* See changelog for details.
|
||||
*
|
||||
* patched by sabello to : replace .size() to length
|
||||
* set the row response split to "\t"
|
||||
*
|
||||
*/
|
||||
|
||||
;(function($) {
|
||||
|
||||
$.fn.extend({
|
||||
$.fn.extend({
|
||||
autocomplete: function(urlOrData, options) {
|
||||
var isUrl = typeof urlOrData == "string";
|
||||
options = $.extend({}, $.Autocompleter.defaults, {
|
||||
url: isUrl ? urlOrData : null,
|
||||
data: isUrl ? null : urlOrData,
|
||||
delay: isUrl ? $.Autocompleter.defaults.delay : 10,
|
||||
max: options && !options.scroll ? 10 : 150
|
||||
max: options && !options.scroll ? 10 : 150,
|
||||
noRecord: "No Records."
|
||||
}, options);
|
||||
|
||||
// if highlight is set to false, replace it with a do-nothing function
|
||||
@@ -47,9 +53,9 @@ $.fn.extend({
|
||||
unautocomplete: function() {
|
||||
return this.trigger("unautocomplete");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$.Autocompleter = function(input, options) {
|
||||
$.Autocompleter = function(input, options) {
|
||||
|
||||
var KEY = {
|
||||
UP: 38,
|
||||
@@ -64,6 +70,11 @@ $.Autocompleter = function(input, options) {
|
||||
BACKSPACE: 8
|
||||
};
|
||||
|
||||
var globalFailure = null;
|
||||
if(options.failure != null && typeof options.failure == "function") {
|
||||
globalFailure = options.failure;
|
||||
}
|
||||
|
||||
// Create $ object for input element
|
||||
var $input = $(input).attr("autocomplete", "off").addClass(options.inputClass);
|
||||
|
||||
@@ -80,15 +91,15 @@ $.Autocompleter = function(input, options) {
|
||||
var blockSubmit;
|
||||
|
||||
// prevent form submit in opera when selecting with return key
|
||||
$.browser.opera && $(input.form).bind("submit.autocomplete", function() {
|
||||
navigator.userAgent.indexOf("Opera") != -1 && $(input.form).bind("submit.autocomplete", function() {
|
||||
if (blockSubmit) {
|
||||
blockSubmit = false;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// only opera doesn't trigger keydown multiple times while pressed, others don't work with keypress at all
|
||||
$input.bind(($.browser.opera ? "keypress" : "keydown") + ".autocomplete", function(event) {
|
||||
// older versions of opera don't trigger keydown multiple times while pressed, others don't work with keypress at all
|
||||
$input.bind((navigator.userAgent.indexOf("Opera") != -1 && !'KeyboardEvent' in window ? "keypress" : "keydown") + ".autocomplete", function(event) {
|
||||
// a keypress means the input has focus
|
||||
// avoids issue where input had focus before the autocomplete was applied
|
||||
hasFocus = 1;
|
||||
@@ -97,8 +108,8 @@ $.Autocompleter = function(input, options) {
|
||||
switch(event.keyCode) {
|
||||
|
||||
case KEY.UP:
|
||||
event.preventDefault();
|
||||
if ( select.visible() ) {
|
||||
event.preventDefault();
|
||||
select.prev();
|
||||
} else {
|
||||
onChange(0, true);
|
||||
@@ -106,8 +117,8 @@ $.Autocompleter = function(input, options) {
|
||||
break;
|
||||
|
||||
case KEY.DOWN:
|
||||
event.preventDefault();
|
||||
if ( select.visible() ) {
|
||||
event.preventDefault();
|
||||
select.next();
|
||||
} else {
|
||||
onChange(0, true);
|
||||
@@ -115,8 +126,8 @@ $.Autocompleter = function(input, options) {
|
||||
break;
|
||||
|
||||
case KEY.PAGEUP:
|
||||
event.preventDefault();
|
||||
if ( select.visible() ) {
|
||||
event.preventDefault();
|
||||
select.pageUp();
|
||||
} else {
|
||||
onChange(0, true);
|
||||
@@ -124,8 +135,8 @@ $.Autocompleter = function(input, options) {
|
||||
break;
|
||||
|
||||
case KEY.PAGEDOWN:
|
||||
event.preventDefault();
|
||||
if ( select.visible() ) {
|
||||
event.preventDefault();
|
||||
select.pageDown();
|
||||
} else {
|
||||
onChange(0, true);
|
||||
@@ -164,9 +175,17 @@ $.Autocompleter = function(input, options) {
|
||||
}
|
||||
}).click(function() {
|
||||
// show select when clicking in a focused field
|
||||
// but if clickFire is true, don't require field
|
||||
// to be focused to begin with; just show select
|
||||
if( options.clickFire ) {
|
||||
if ( !select.visible() ) {
|
||||
onChange(0, true);
|
||||
}
|
||||
} else {
|
||||
if ( hasFocus++ > 1 && !select.visible() ) {
|
||||
onChange(0, true);
|
||||
}
|
||||
}
|
||||
}).bind("search", function() {
|
||||
// TODO why not just specifying both arguments?
|
||||
var fn = (arguments.length > 1) ? arguments[1] : null;
|
||||
@@ -189,7 +208,7 @@ $.Autocompleter = function(input, options) {
|
||||
}).bind("flushCache", function() {
|
||||
cache.flush();
|
||||
}).bind("setOptions", function() {
|
||||
$.extend(options, arguments[1]);
|
||||
$.extend(true, options, arguments[1]);
|
||||
// if we've updated the data, repopulate
|
||||
if ( "data" in arguments[1] )
|
||||
cache.populate();
|
||||
@@ -321,7 +340,7 @@ $.Autocompleter = function(input, options) {
|
||||
$input.val( words.join(options.multipleSeparator) + (words.length ? options.multipleSeparator : "") );
|
||||
}
|
||||
else {
|
||||
//$input.val( "" );
|
||||
$input.val( "" );
|
||||
$input.trigger("result", null);
|
||||
}
|
||||
}
|
||||
@@ -346,8 +365,14 @@ $.Autocompleter = function(input, options) {
|
||||
term = term.toLowerCase();
|
||||
var data = cache.load(term);
|
||||
// recieve the cached data
|
||||
if (data && data.length) {
|
||||
if (data) {
|
||||
if(data.length) {
|
||||
success(term, data);
|
||||
}
|
||||
else{
|
||||
var parsed = options.parse && options.parse(options.noRecord) || parse(options.noRecord);
|
||||
success(term,parsed);
|
||||
}
|
||||
// if an AJAX url has been supplied, try loading the data now
|
||||
} else if( (typeof options.url == "string") && (options.url.length > 0) ){
|
||||
|
||||
@@ -361,7 +386,6 @@ $.Autocompleter = function(input, options) {
|
||||
$.ajax({
|
||||
// try to leverage ajaxQueue plugin to abort previous requests
|
||||
mode: "abort",
|
||||
type: "POST",
|
||||
// limit abortion to this input
|
||||
port: "autocomplete" + input.name,
|
||||
dataType: options.dataType,
|
||||
@@ -379,8 +403,13 @@ $.Autocompleter = function(input, options) {
|
||||
} else {
|
||||
// if we have a failure, we need to empty the list -- this prevents the the [TAB] key from selecting the last successful match
|
||||
select.emptyList();
|
||||
if(globalFailure != null) {
|
||||
globalFailure();
|
||||
}
|
||||
else {
|
||||
failure(term);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function parse(data) {
|
||||
@@ -404,9 +433,9 @@ $.Autocompleter = function(input, options) {
|
||||
$input.removeClass(options.loadingClass);
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
$.Autocompleter.defaults = {
|
||||
$.Autocompleter.defaults = {
|
||||
inputClass: "ac_input",
|
||||
resultsClass: "ac_results",
|
||||
loadingClass: "ac_loading",
|
||||
@@ -415,8 +444,8 @@ $.Autocompleter.defaults = {
|
||||
matchCase: false,
|
||||
matchSubset: true,
|
||||
matchContains: false,
|
||||
cacheLength: 10,
|
||||
max: 100,
|
||||
cacheLength: 100,
|
||||
max: 1000,
|
||||
mustMatch: false,
|
||||
extraParams: {},
|
||||
selectFirst: true,
|
||||
@@ -425,15 +454,18 @@ $.Autocompleter.defaults = {
|
||||
autoFill: false,
|
||||
width: 0,
|
||||
multiple: false,
|
||||
multipleSeparator: ", ",
|
||||
multipleSeparator: " ",
|
||||
inputFocus: true,
|
||||
clickFire: false,
|
||||
highlight: function(value, term) {
|
||||
return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
|
||||
},
|
||||
scroll: true,
|
||||
scrollHeight: 180
|
||||
};
|
||||
scrollHeight: 180,
|
||||
scrollJumpPosition: true
|
||||
};
|
||||
|
||||
$.Autocompleter.Cache = function(options) {
|
||||
$.Autocompleter.Cache = function(options) {
|
||||
|
||||
var data = {};
|
||||
var length = 0;
|
||||
@@ -478,7 +510,7 @@ $.Autocompleter.Cache = function(options) {
|
||||
rawValue = (typeof rawValue == "string") ? [rawValue] : rawValue;
|
||||
|
||||
var value = options.formatMatch(rawValue, i+1, options.data.length);
|
||||
if ( value === false )
|
||||
if ( typeof(value) === 'undefined' || value === false )
|
||||
continue;
|
||||
|
||||
var firstChar = value.charAt(0).toLowerCase();
|
||||
@@ -570,9 +602,9 @@ $.Autocompleter.Cache = function(options) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
$.Autocompleter.Select = function (options, input, select, config) {
|
||||
$.Autocompleter.Select = function (options, input, select, config) {
|
||||
var CLASSES = {
|
||||
ACTIVE: "ac_over"
|
||||
};
|
||||
@@ -593,7 +625,14 @@ $.Autocompleter.Select = function (options, input, select, config) {
|
||||
.hide()
|
||||
.addClass(options.resultsClass)
|
||||
.css("position", "absolute")
|
||||
.appendTo(document.body);
|
||||
.appendTo(document.body)
|
||||
.hover(function(event) {
|
||||
// Browsers except FF do not fire mouseup event on scrollbars, resulting in mouseDownOnSelect remaining true, and results list not always hiding.
|
||||
if($(this).is(":visible")) {
|
||||
input.focus();
|
||||
}
|
||||
config.mouseDownOnSelect = false;
|
||||
});
|
||||
|
||||
list = $("<ul/>").appendTo(element).mouseover( function(event) {
|
||||
if(target(event).nodeName && target(event).nodeName.toUpperCase() == 'LI') {
|
||||
@@ -603,7 +642,7 @@ $.Autocompleter.Select = function (options, input, select, config) {
|
||||
}).click(function(event) {
|
||||
$(target(event)).addClass(CLASSES.ACTIVE);
|
||||
select();
|
||||
// TODO provide option to avoid setting focus again after selection? useful for cleanup-on-focus
|
||||
if( options.inputFocus )
|
||||
input.focus();
|
||||
return false;
|
||||
}).mousedown(function() {
|
||||
@@ -646,13 +685,16 @@ $.Autocompleter.Select = function (options, input, select, config) {
|
||||
};
|
||||
|
||||
function movePosition(step) {
|
||||
if (options.scrollJumpPosition || (!options.scrollJumpPosition && !((step < 0 && active == 0) || (step > 0 && active == listItems.length - 1)) )) {
|
||||
active += step;
|
||||
if (active < 0) {
|
||||
active = listItems.size() - 1;
|
||||
} else if (active >= listItems.size()) {
|
||||
active = listItems.length - 1;
|
||||
} else if (active >= listItems.length) {
|
||||
active = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function limitNumberOfItems(available) {
|
||||
return options.max && options.max < available
|
||||
@@ -669,9 +711,7 @@ $.Autocompleter.Select = function (options, input, select, config) {
|
||||
var formatted = options.formatItem(data[i].data, i+1, max, data[i].value, term);
|
||||
if ( formatted === false )
|
||||
continue;
|
||||
// Escape dangerous characters to prevent XSS vulnerabilities
|
||||
formatted = formatted.replace('&', '&').replace('"', '"').replace('>', '>').replace('<', '<');
|
||||
var li = $("<li/>").html( options.highlight(formatted, term) ).addClass('ac_item').addClass(i%2 == 0 ? "ac_even" : "ac_odd").appendTo(list)[0];
|
||||
var li = $("<li/>").html( options.highlight(formatted, term) ).addClass(i%2 == 0 ? "ac_even" : "ac_odd").appendTo(list)[0];
|
||||
$.data(li, "ac_data", data[i]);
|
||||
}
|
||||
listItems = list.find("li");
|
||||
@@ -705,8 +745,8 @@ $.Autocompleter.Select = function (options, input, select, config) {
|
||||
}
|
||||
},
|
||||
pageDown: function() {
|
||||
if (active != listItems.size() - 1 && active + 8 > listItems.size()) {
|
||||
moveSelect( listItems.size() - 1 - active );
|
||||
if (active != listItems.length - 1 && active + 8 > listItems.length) {
|
||||
moveSelect( listItems.length - 1 - active );
|
||||
} else {
|
||||
moveSelect(8);
|
||||
}
|
||||
@@ -725,7 +765,7 @@ $.Autocompleter.Select = function (options, input, select, config) {
|
||||
show: function() {
|
||||
var offset = $(input).offset();
|
||||
element.css({
|
||||
'min-width': typeof options.width == "string" || options.width > 0 ? options.width : $(input).width(),
|
||||
width: typeof options.width == "string" || options.width > 0 ? options.width : $(input).width(),
|
||||
top: offset.top + input.offsetHeight,
|
||||
left: offset.left
|
||||
}).show();
|
||||
@@ -736,7 +776,7 @@ $.Autocompleter.Select = function (options, input, select, config) {
|
||||
overflow: 'auto'
|
||||
});
|
||||
|
||||
if($.browser.msie && typeof document.body.style.maxHeight === "undefined") {
|
||||
if(navigator.userAgent.indexOf("MSIE") != -1 && typeof document.body.style.maxHeight === "undefined") {
|
||||
var listHeight = 0;
|
||||
listItems.each(function() {
|
||||
listHeight += this.offsetHeight;
|
||||
@@ -762,9 +802,9 @@ $.Autocompleter.Select = function (options, input, select, config) {
|
||||
element && element.remove();
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
$.fn.selection = function(start, end) {
|
||||
$.fn.selection = function(start, end) {
|
||||
if (start !== undefined) {
|
||||
return this.each(function() {
|
||||
if( this.createTextRange ){
|
||||
@@ -806,6 +846,6 @@ $.fn.selection = function(start, end) {
|
||||
end: field.selectionEnd
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
170
js/jquery.fileupload.js
vendored
170
js/jquery.fileupload.js
vendored
@@ -1,25 +1,31 @@
|
||||
/*
|
||||
* jQuery File Upload Plugin 5.40.1
|
||||
* jQuery File Upload Plugin
|
||||
* 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
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
/* jshint nomen:false */
|
||||
/* global define, window, document, location, Blob, FormData */
|
||||
/* global define, require, window, document, location, Blob, FormData */
|
||||
|
||||
(function (factory) {
|
||||
;(function (factory) {
|
||||
'use strict';
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// Register as an anonymous AMD module:
|
||||
define([
|
||||
'jquery',
|
||||
'jquery.ui.widget'
|
||||
'jquery-ui/ui/widget'
|
||||
], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node/CommonJS:
|
||||
factory(
|
||||
require('jquery'),
|
||||
require('./vendor/jquery.ui.widget')
|
||||
);
|
||||
} else {
|
||||
// Browser globals:
|
||||
factory(window.jQuery);
|
||||
@@ -37,7 +43,7 @@
|
||||
'|(Kindle/(1\\.0|2\\.[05]|3\\.0))'
|
||||
).test(window.navigator.userAgent) ||
|
||||
// Feature detection for all other devices:
|
||||
$('<input type="file">').prop('disabled'));
|
||||
$('<input type="file"/>').prop('disabled'));
|
||||
|
||||
// The FileReader API is not actually used, but works as feature detection,
|
||||
// as some Safari versions (5?) support XHR file uploads via the FormData API,
|
||||
@@ -51,6 +57,25 @@
|
||||
$.support.blobSlice = window.Blob && (Blob.prototype.slice ||
|
||||
Blob.prototype.webkitSlice || Blob.prototype.mozSlice);
|
||||
|
||||
// Helper function to create drag handlers for dragover/dragenter/dragleave:
|
||||
function getDragHandler(type) {
|
||||
var isDragOver = type === 'dragover';
|
||||
return function (e) {
|
||||
e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer;
|
||||
var dataTransfer = e.dataTransfer;
|
||||
if (dataTransfer && $.inArray('Files', dataTransfer.types) !== -1 &&
|
||||
this._trigger(
|
||||
type,
|
||||
$.Event(type, {delegatedEvent: e})
|
||||
) !== false) {
|
||||
e.preventDefault();
|
||||
if (isDragOver) {
|
||||
dataTransfer.dropEffect = 'copy';
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 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
|
||||
@@ -65,9 +90,9 @@
|
||||
// The drop target element(s), by the default the complete document.
|
||||
// Set to null to disable drag & drop support:
|
||||
dropZone: $(document),
|
||||
// The paste target element(s), by the default the complete document.
|
||||
// Set to null to disable paste support:
|
||||
pasteZone: $(document),
|
||||
// The paste target element(s), by the default undefined.
|
||||
// Set to a DOM node or jQuery object to enable file pasting:
|
||||
pasteZone: undefined,
|
||||
// The file input field(s), that are listened to for change events.
|
||||
// If undefined, it is set to the file input fields inside
|
||||
// of the widget element on plugin initialization.
|
||||
@@ -252,7 +277,8 @@
|
||||
// The following are jQuery ajax settings required for the file uploads:
|
||||
processData: false,
|
||||
contentType: false,
|
||||
cache: false
|
||||
cache: false,
|
||||
timeout: 0
|
||||
},
|
||||
|
||||
// A list of options that require reinitializing event listeners and/or
|
||||
@@ -427,7 +453,7 @@
|
||||
}
|
||||
if (!multipart || options.blob || !this._isInstanceOf('File', file)) {
|
||||
options.headers['Content-Disposition'] = 'attachment; filename="' +
|
||||
encodeURI(file.name) + '"';
|
||||
encodeURI(file.uploadName || file.name) + '"';
|
||||
}
|
||||
if (!multipart) {
|
||||
options.contentType = file.type || 'application/octet-stream';
|
||||
@@ -463,7 +489,11 @@
|
||||
});
|
||||
}
|
||||
if (options.blob) {
|
||||
formData.append(paramName, options.blob, file.name);
|
||||
formData.append(
|
||||
paramName,
|
||||
options.blob,
|
||||
file.uploadName || file.name
|
||||
);
|
||||
} else {
|
||||
$.each(options.files, function (index, file) {
|
||||
// This check allows the tests to run with
|
||||
@@ -626,7 +656,7 @@
|
||||
data.process = function (resolveFunc, rejectFunc) {
|
||||
if (resolveFunc || rejectFunc) {
|
||||
data._processQueue = this._processQueue =
|
||||
(this._processQueue || getPromise([this])).pipe(
|
||||
(this._processQueue || getPromise([this])).then(
|
||||
function () {
|
||||
if (data.errorThrown) {
|
||||
return $.Deferred()
|
||||
@@ -634,7 +664,7 @@
|
||||
}
|
||||
return getPromise(arguments);
|
||||
}
|
||||
).pipe(resolveFunc, rejectFunc);
|
||||
).then(resolveFunc, rejectFunc);
|
||||
}
|
||||
return this._processQueue || getPromise([this]);
|
||||
};
|
||||
@@ -704,7 +734,7 @@
|
||||
promise = dfd.promise(),
|
||||
jqXHR,
|
||||
upload;
|
||||
if (!(this._isXHRUpload(options) && slice && (ub || mcs < fs)) ||
|
||||
if (!(this._isXHRUpload(options) && slice && (ub || ($.type(mcs) === 'function' ? mcs(options) : mcs) < fs)) ||
|
||||
options.data) {
|
||||
return false;
|
||||
}
|
||||
@@ -727,7 +757,7 @@
|
||||
o.blob = slice.call(
|
||||
file,
|
||||
ub,
|
||||
ub + mcs,
|
||||
ub + ($.type(mcs) === 'function' ? mcs(o) : mcs),
|
||||
file.type
|
||||
);
|
||||
// Store the current chunk size, as the blob itself
|
||||
@@ -919,9 +949,9 @@
|
||||
if (this.options.limitConcurrentUploads > 1) {
|
||||
slot = $.Deferred();
|
||||
this._slots.push(slot);
|
||||
pipe = slot.pipe(send);
|
||||
pipe = slot.then(send);
|
||||
} else {
|
||||
this._sequence = this._sequence.pipe(send, send);
|
||||
this._sequence = this._sequence.then(send, send);
|
||||
pipe = this._sequence;
|
||||
}
|
||||
// Return the piped Promise object, enhanced with an abort method,
|
||||
@@ -958,7 +988,10 @@
|
||||
fileSet,
|
||||
i,
|
||||
j = 0;
|
||||
if (limitSize && (!filesLength || files[0].size === undefined)) {
|
||||
if (!filesLength) {
|
||||
return false;
|
||||
}
|
||||
if (limitSize && files[0].size === undefined) {
|
||||
limitSize = undefined;
|
||||
}
|
||||
if (!(options.singleFileUploads || limit || limitSize) ||
|
||||
@@ -1015,12 +1048,21 @@
|
||||
return result;
|
||||
},
|
||||
|
||||
_replaceFileInput: function (input) {
|
||||
var inputClone = input.clone(true);
|
||||
_replaceFileInput: function (data) {
|
||||
var input = data.fileInput,
|
||||
inputClone = input.clone(true),
|
||||
restoreFocus = input.is(document.activeElement);
|
||||
// Add a reference for the new cloned file input to the data argument:
|
||||
data.fileInputClone = inputClone;
|
||||
$('<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();
|
||||
// If the fileInput had focus before it was detached,
|
||||
// restore focus to the inputClone.
|
||||
if (restoreFocus) {
|
||||
inputClone.focus();
|
||||
}
|
||||
// Avoid memory leaks with the detached file input:
|
||||
$.cleanData(input.unbind('remove'));
|
||||
// Replace the original file input element in the fileInput
|
||||
@@ -1042,6 +1084,8 @@
|
||||
_handleFileTreeEntry: function (entry, path) {
|
||||
var that = this,
|
||||
dfd = $.Deferred(),
|
||||
entries = [],
|
||||
dirReader,
|
||||
errorHandler = function (e) {
|
||||
if (e && !e.entry) {
|
||||
e.entry = entry;
|
||||
@@ -1052,7 +1096,24 @@
|
||||
// to be returned together in one set:
|
||||
dfd.resolve([e]);
|
||||
},
|
||||
dirReader;
|
||||
successHandler = function (entries) {
|
||||
that._handleFileTreeEntries(
|
||||
entries,
|
||||
path + entry.name + '/'
|
||||
).done(function (files) {
|
||||
dfd.resolve(files);
|
||||
}).fail(errorHandler);
|
||||
},
|
||||
readEntries = function () {
|
||||
dirReader.readEntries(function (results) {
|
||||
if (!results.length) {
|
||||
successHandler(entries);
|
||||
} else {
|
||||
entries = entries.concat(results);
|
||||
readEntries();
|
||||
}
|
||||
}, errorHandler);
|
||||
};
|
||||
path = path || '';
|
||||
if (entry.isFile) {
|
||||
if (entry._file) {
|
||||
@@ -1067,14 +1128,7 @@
|
||||
}
|
||||
} else if (entry.isDirectory) {
|
||||
dirReader = entry.createReader();
|
||||
dirReader.readEntries(function (entries) {
|
||||
that._handleFileTreeEntries(
|
||||
entries,
|
||||
path + entry.name + '/'
|
||||
).done(function (files) {
|
||||
dfd.resolve(files);
|
||||
}).fail(errorHandler);
|
||||
}, errorHandler);
|
||||
readEntries();
|
||||
} else {
|
||||
// Return an empy list for file system items
|
||||
// other than files or directories:
|
||||
@@ -1090,7 +1144,7 @@
|
||||
$.map(entries, function (entry) {
|
||||
return that._handleFileTreeEntry(entry, path);
|
||||
})
|
||||
).pipe(function () {
|
||||
).then(function () {
|
||||
return Array.prototype.concat.apply(
|
||||
[],
|
||||
arguments
|
||||
@@ -1159,7 +1213,7 @@
|
||||
return $.when.apply(
|
||||
$,
|
||||
$.map(fileInput, this._getSingleFileInputFiles)
|
||||
).pipe(function () {
|
||||
).then(function () {
|
||||
return Array.prototype.concat.apply(
|
||||
[],
|
||||
arguments
|
||||
@@ -1176,7 +1230,7 @@
|
||||
this._getFileInputFiles(data.fileInput).always(function (files) {
|
||||
data.files = files;
|
||||
if (that.options.replaceFileInput) {
|
||||
that._replaceFileInput(data.fileInput);
|
||||
that._replaceFileInput(data);
|
||||
}
|
||||
if (that._trigger(
|
||||
'change',
|
||||
@@ -1229,24 +1283,21 @@
|
||||
}
|
||||
},
|
||||
|
||||
_onDragOver: function (e) {
|
||||
e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer;
|
||||
var dataTransfer = e.dataTransfer;
|
||||
if (dataTransfer && $.inArray('Files', dataTransfer.types) !== -1 &&
|
||||
this._trigger(
|
||||
'dragover',
|
||||
$.Event('dragover', {delegatedEvent: e})
|
||||
) !== false) {
|
||||
e.preventDefault();
|
||||
dataTransfer.dropEffect = 'copy';
|
||||
}
|
||||
},
|
||||
_onDragOver: getDragHandler('dragover'),
|
||||
|
||||
_onDragEnter: getDragHandler('dragenter'),
|
||||
|
||||
_onDragLeave: getDragHandler('dragleave'),
|
||||
|
||||
_initEventHandlers: function () {
|
||||
if (this._isXHRUpload(this.options)) {
|
||||
this._on(this.options.dropZone, {
|
||||
dragover: this._onDragOver,
|
||||
drop: this._onDrop
|
||||
drop: this._onDrop,
|
||||
// event.preventDefault() on dragenter is required for IE10+:
|
||||
dragenter: this._onDragEnter,
|
||||
// dragleave is not required, but added for completeness:
|
||||
dragleave: this._onDragLeave
|
||||
});
|
||||
this._on(this.options.pasteZone, {
|
||||
paste: this._onPaste
|
||||
@@ -1260,11 +1311,15 @@
|
||||
},
|
||||
|
||||
_destroyEventHandlers: function () {
|
||||
this._off(this.options.dropZone, 'dragover drop');
|
||||
this._off(this.options.dropZone, 'dragenter dragleave dragover drop');
|
||||
this._off(this.options.pasteZone, 'paste');
|
||||
this._off(this.options.fileInput, 'change');
|
||||
},
|
||||
|
||||
_destroy: function () {
|
||||
this._destroyEventHandlers();
|
||||
},
|
||||
|
||||
_setOption: function (key, value) {
|
||||
var reinit = $.inArray(key, this._specialOptions) !== -1;
|
||||
if (reinit) {
|
||||
@@ -1308,15 +1363,19 @@
|
||||
_initDataAttributes: function () {
|
||||
var that = this,
|
||||
options = this.options,
|
||||
clone = $(this.element[0].cloneNode(false));
|
||||
data = this.element.data();
|
||||
// Initialize options set via HTML5 data-attributes:
|
||||
$.each(
|
||||
clone.data(),
|
||||
function (key, value) {
|
||||
var dataAttributeName = 'data-' +
|
||||
// Convert camelCase to hyphen-ated key:
|
||||
key.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
||||
if (clone.attr(dataAttributeName)) {
|
||||
this.element[0].attributes,
|
||||
function (index, attr) {
|
||||
var key = attr.name.toLowerCase(),
|
||||
value;
|
||||
if (/^data-/.test(key)) {
|
||||
// Convert hyphen-ated key to camelCase:
|
||||
key = key.slice(5).replace(/-[a-z]/g, function (str) {
|
||||
return str.charAt(1).toUpperCase();
|
||||
});
|
||||
value = data[key];
|
||||
if (that._isRegExpOption(key, value)) {
|
||||
value = that._getRegExp(value);
|
||||
}
|
||||
@@ -1401,7 +1460,8 @@
|
||||
return;
|
||||
}
|
||||
data.files = files;
|
||||
jqXHR = that._onSend(null, data).then(
|
||||
jqXHR = that._onSend(null, data);
|
||||
jqXHR.then(
|
||||
function (result, textStatus, jqXHR) {
|
||||
dfd.resolve(result, textStatus, jqXHR);
|
||||
},
|
||||
|
||||
11
js/jquery.qtip-1.0.min.js
vendored
11
js/jquery.qtip-1.0.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user