diff options
author | Mario <mario@mariovavti.com> | 2020-05-07 21:48:26 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2020-05-07 21:48:26 +0000 |
commit | f132436af3c90cff8dcef852bd836546311036f3 (patch) | |
tree | 89531366ba5fc62095981a81a91a2fc52adcad9c /vendor/blueimp/jquery-file-upload/js | |
parent | fae70bf0a7f1b566d25e30064f60d58ab150951a (diff) | |
download | volse-hubzilla-f132436af3c90cff8dcef852bd836546311036f3.tar.gz volse-hubzilla-f132436af3c90cff8dcef852bd836546311036f3.tar.bz2 volse-hubzilla-f132436af3c90cff8dcef852bd836546311036f3.zip |
composer updates 2
Diffstat (limited to 'vendor/blueimp/jquery-file-upload/js')
12 files changed, 778 insertions, 724 deletions
diff --git a/vendor/blueimp/jquery-file-upload/js/cors/jquery.postmessage-transport.js b/vendor/blueimp/jquery-file-upload/js/cors/jquery.postmessage-transport.js index 0a3d9fe45..5d5cc2f8d 100644 --- a/vendor/blueimp/jquery-file-upload/js/cors/jquery.postmessage-transport.js +++ b/vendor/blueimp/jquery-file-upload/js/cors/jquery.postmessage-transport.js @@ -11,7 +11,7 @@ /* global define, require */ -(function(factory) { +(function (factory) { 'use strict'; if (typeof define === 'function' && define.amd) { // Register as an anonymous AMD module: @@ -23,7 +23,7 @@ // Browser globals: factory(window.jQuery); } -})(function($) { +})(function ($) { 'use strict'; var counter = 0, @@ -46,7 +46,7 @@ 'url', 'username' ], - convert = function(p) { + convert = function (p) { return p; }; @@ -58,10 +58,10 @@ } }); - $.ajaxTransport('postmessage', function(options) { + $.ajaxTransport('postmessage', function (options) { if (options.postMessage && window.postMessage) { var iframe, - loc = $('<a>').prop('href', options.postMessage)[0], + loc = $('<a></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 @@ -71,7 +71,7 @@ target = target.replace(/:(80|443)$/, ''); } return { - send: function(_, completeCallback) { + send: function (_, completeCallback) { counter += 1; var message = { id: 'postmessage-transport-' + counter @@ -84,12 +84,12 @@ message.id + '"></iframe>' ) - .bind('load', function() { - $.each(names, function(i, name) { + .on('load', function () { + $.each(names, function (i, name) { message[name] = options[name]; }); message.dataType = message.dataType.replace('postmessage ', ''); - $(window).bind(eventName, function(event) { + $(window).on(eventName, function (event) { var e = event.originalEvent; var data = e.data; var ev; @@ -107,7 +107,7 @@ data.headers ); iframe.remove(); - $(window).unbind(eventName); + $(window).off(eventName); } } }); @@ -115,7 +115,7 @@ }) .appendTo(document.body); }, - abort: function() { + abort: function () { if (iframe) { iframe.remove(); } diff --git a/vendor/blueimp/jquery-file-upload/js/cors/jquery.xdr-transport.js b/vendor/blueimp/jquery-file-upload/js/cors/jquery.xdr-transport.js index 68e36be58..9e81860b9 100644 --- a/vendor/blueimp/jquery-file-upload/js/cors/jquery.xdr-transport.js +++ b/vendor/blueimp/jquery-file-upload/js/cors/jquery.xdr-transport.js @@ -14,7 +14,7 @@ /* global define, require, XDomainRequest */ -(function(factory) { +(function (factory) { 'use strict'; if (typeof define === 'function' && define.amd) { // Register as an anonymous AMD module: @@ -26,10 +26,10 @@ // Browser globals: factory(window.jQuery); } -})(function($) { +})(function ($) { 'use strict'; if (window.XDomainRequest && !$.support.cors) { - $.ajaxTransport(function(s) { + $.ajaxTransport(function (s) { if (s.crossDomain && s.async) { if (s.timeout) { s.xdrTimeout = s.timeout; @@ -37,7 +37,7 @@ } var xdr; return { - send: function(headers, completeCallback) { + send: function (headers, completeCallback) { var addParamChar = /\?/.test(s.url) ? '&' : '?'; /** * Callback wrapper function @@ -65,7 +65,7 @@ s.type = 'POST'; } xdr.open(s.type, s.url); - xdr.onload = function() { + xdr.onload = function () { callback( 200, 'OK', @@ -73,18 +73,18 @@ 'Content-Type: ' + xdr.contentType ); }; - xdr.onerror = function() { + xdr.onerror = function () { callback(404, 'Not Found'); }; if (s.xdrTimeout) { - xdr.ontimeout = function() { + xdr.ontimeout = function () { callback(0, 'timeout'); }; xdr.timeout = s.xdrTimeout; } xdr.send((s.hasContent && s.data) || null); }, - abort: function() { + abort: function () { if (xdr) { xdr.onerror = $.noop(); xdr.abort(); diff --git a/vendor/blueimp/jquery-file-upload/js/demo.js b/vendor/blueimp/jquery-file-upload/js/demo.js index bb4eccd6e..0735031b8 100644 --- a/vendor/blueimp/jquery-file-upload/js/demo.js +++ b/vendor/blueimp/jquery-file-upload/js/demo.js @@ -11,7 +11,7 @@ /* global $ */ -$(function() { +$(function () { 'use strict'; // Initialize the jQuery File Upload widget: @@ -46,8 +46,8 @@ $(function() { $.ajax({ url: '//jquery-file-upload.appspot.com/', type: 'HEAD' - }).fail(function() { - $('<div class="alert alert-danger"/>') + }).fail(function () { + $('<div class="alert alert-danger"></div>') .text('Upload server currently unavailable - ' + new Date()) .appendTo('#fileupload'); }); @@ -62,10 +62,10 @@ $(function() { dataType: 'json', context: $('#fileupload')[0] }) - .always(function() { + .always(function () { $(this).removeClass('fileupload-processing'); }) - .done(function(result) { + .done(function (result) { $(this) .fileupload('option', 'done') // eslint-disable-next-line new-cap diff --git a/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-audio.js b/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-audio.js index 2992213b9..e5c9202f9 100644 --- a/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-audio.js +++ b/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-audio.js @@ -11,7 +11,7 @@ /* global define, require */ -(function(factory) { +(function (factory) { 'use strict'; if (typeof define === 'function' && define.amd) { // Register as an anonymous AMD module: @@ -27,7 +27,7 @@ // Browser globals: factory(window.jQuery, window.loadImage); } -})(function($, loadImage) { +})(function ($, loadImage) { 'use strict'; // Prepend to the default processQueue: @@ -63,7 +63,7 @@ // as audio element if the browser supports playing it. // Accepts the options fileTypes (regular expression) // and maxFileSize (integer) to limit the files to load: - loadAudio: function(data, options) { + loadAudio: function (data, options) { if (options.disabled) { return data; } @@ -90,7 +90,7 @@ }, // Sets the audio element as a property of the file object: - setAudio: function(data, options) { + setAudio: function (data, options) { if (data.audio && !options.disabled) { data.files[data.index][options.name || 'preview'] = data.audio; } diff --git a/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-image.js b/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-image.js index 8e9b46215..859846103 100644 --- a/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-image.js +++ b/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-image.js @@ -11,7 +11,7 @@ /* global define, require */ -(function(factory) { +(function (factory) { 'use strict'; if (typeof define === 'function' && define.amd) { // Register as an anonymous AMD module: @@ -21,6 +21,7 @@ 'load-image-meta', 'load-image-scale', 'load-image-exif', + 'load-image-orientation', 'canvas-to-blob', './jquery.fileupload-process' ], factory); @@ -32,6 +33,7 @@ require('blueimp-load-image/js/load-image-meta'), require('blueimp-load-image/js/load-image-scale'), require('blueimp-load-image/js/load-image-exif'), + require('blueimp-load-image/js/load-image-orientation'), require('blueimp-canvas-to-blob'), require('./jquery.fileupload-process') ); @@ -39,18 +41,25 @@ // Browser globals: factory(window.jQuery, window.loadImage); } -})(function($, loadImage) { +})(function ($, loadImage) { 'use strict'; // Prepend to the default processQueue: $.blueimp.fileupload.prototype.options.processQueue.unshift( { action: 'loadImageMetaData', + maxMetaDataSize: '@', disableImageHead: '@', + disableMetaDataParsers: '@', disableExif: '@', disableExifThumbnail: '@', - disableExifSub: '@', - disableExifGps: '@', + disableExifOffsets: '@', + includeExifTags: '@', + excludeExifTags: '@', + disableIptc: '@', + disableIptcOffsets: '@', + includeIptcTags: '@', + excludeIptcTags: '@', disabled: '@disableImageMetaDataLoad' }, { @@ -125,7 +134,7 @@ imageMaxHeight: 1080, // Defines the image orientation (1-8) or takes the orientation // value from Exif data if set to true: - imageOrientation: false, + imageOrientation: true, // Define if resized images should be cropped or only scaled: imageCrop: false, // Disable the resize image functionality by default: @@ -150,7 +159,7 @@ // as img element, if the browser supports the File API. // Accepts the options fileTypes (regular expression) // and maxFileSize (integer) to limit the files to load: - loadImage: function(data, options) { + loadImage: function (data, options) { if (options.disabled) { return data; } @@ -164,7 +173,7 @@ (options.fileTypes && !options.fileTypes.test(file.type)) || !loadImage( file, - function(img) { + function (img) { if (img.src) { data.img = img; } @@ -183,7 +192,7 @@ // Also stores the resized image as preview property. // Accepts the options maxWidth, maxHeight, minWidth, // minHeight, canvas and crop: - resizeImage: function(data, options) { + resizeImage: function (data, options) { if (options.disabled || !(data.canvas || data.img)) { return data; } @@ -193,7 +202,7 @@ // eslint-disable-next-line new-cap dfd = $.Deferred(), img = (options.canvas && data.canvas) || data.img, - resolve = function(newImg) { + resolve = function (newImg) { if ( newImg && (newImg.width !== img.width || @@ -205,18 +214,24 @@ data.preview = newImg; dfd.resolveWith(that, [data]); }, - thumbnail; + thumbnail, + thumbnailBlob; if (data.exif) { if (options.orientation === true) { options.orientation = data.exif.get('Orientation'); } if (options.thumbnail) { thumbnail = data.exif.get('Thumbnail'); - if (thumbnail) { - loadImage(thumbnail, resolve, options); + thumbnailBlob = thumbnail && thumbnail.get('Blob'); + if (thumbnailBlob) { + loadImage(thumbnailBlob, resolve, options); return dfd.promise(); } } + // Prevent orienting browser oriented images: + if (loadImage.orientation) { + data.orientation = data.orientation || options.orientation; + } // Prevent orienting the same image twice: if (data.orientation) { delete options.orientation; @@ -233,7 +248,7 @@ // Saves the processed image given as data.canvas // inplace at data.index of data.files: - saveImage: function(data, options) { + saveImage: function (data, options) { if (!data.canvas || options.disabled) { return data; } @@ -243,7 +258,7 @@ dfd = $.Deferred(); if (data.canvas.toBlob) { data.canvas.toBlob( - function(blob) { + function (blob) { if (!blob.name) { if (file.type === blob.type) { blob.name = file.name; @@ -272,7 +287,7 @@ return dfd.promise(); }, - loadImageMetaData: function(data, options) { + loadImageMetaData: function (data, options) { if (options.disabled) { return data; } @@ -281,7 +296,7 @@ dfd = $.Deferred(); loadImage.parseMetaData( data.files[data.index], - function(result) { + function (result) { $.extend(data, result); dfd.resolveWith(that, [data]); }, @@ -290,7 +305,7 @@ return dfd.promise(); }, - saveImageMetaData: function(data, options) { + saveImageMetaData: function (data, options) { if ( !( data.imageHead && @@ -301,31 +316,32 @@ ) { return data; } - var file = data.files[data.index], - blob = new Blob( - [ - data.imageHead, - // Resized images always have a head size of 20 bytes, - // including the JPEG marker and a minimal JFIF header: - this._blobSlice.call(file, 20) - ], - { type: file.type } - ); - blob.name = file.name; - data.files[data.index] = blob; - return data; + var that = this, + file = data.files[data.index], + // eslint-disable-next-line new-cap + dfd = $.Deferred(); + if (data.orientation && data.exifOffsets) { + // Reset Exif Orientation data: + loadImage.writeExifData(data.imageHead, data, 'Orientation', 1); + } + loadImage.replaceHead(file, data.imageHead, function (blob) { + blob.name = file.name; + data.files[data.index] = blob; + dfd.resolveWith(that, [data]); + }); + return dfd.promise(); }, // Sets the resized version of the image as a property of the // file object, must be called after "saveImage": - setImage: function(data, options) { + setImage: function (data, options) { if (data.preview && !options.disabled) { data.files[data.index][options.name || 'preview'] = data.preview; } return data; }, - deleteImageReferences: function(data, options) { + deleteImageReferences: function (data, options) { if (!options.disabled) { delete data.img; delete data.canvas; diff --git a/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-process.js b/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-process.js index 54d216913..29de8309a 100644 --- a/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-process.js +++ b/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-process.js @@ -11,7 +11,7 @@ /* global define, require */ -(function(factory) { +(function (factory) { 'use strict'; if (typeof define === 'function' && define.amd) { // Register as an anonymous AMD module: @@ -23,7 +23,7 @@ // Browser globals: factory(window.jQuery); } -})(function($) { +})(function ($) { 'use strict'; var originalAdd = $.blueimp.fileupload.prototype.options.add; @@ -41,9 +41,9 @@ } */ ], - add: function(e, data) { + add: function (e, data) { var $this = $(this); - data.process(function() { + data.process(function () { return $this.fileupload('process', data); }); originalAdd.call(this, e, data); @@ -60,19 +60,17 @@ */ }, - _processFile: function(data, originalData) { + _processFile: function (data, originalData) { var that = this, // eslint-disable-next-line new-cap dfd = $.Deferred().resolveWith(that, [data]), chain = dfd.promise(); this._trigger('process', null, data); - $.each(data.processQueue, function(i, settings) { - var func = function(data) { + $.each(data.processQueue, function (i, settings) { + var func = function (data) { if (originalData.errorThrown) { // eslint-disable-next-line new-cap - return $.Deferred() - .rejectWith(that, [originalData]) - .promise(); + return $.Deferred().rejectWith(that, [originalData]).promise(); } return that.processActions[settings.action].call( that, @@ -83,11 +81,11 @@ chain = chain.then(func, settings.always && func); }); chain - .done(function() { + .done(function () { that._trigger('processdone', null, data); that._trigger('processalways', null, data); }) - .fail(function() { + .fail(function () { that._trigger('processfail', null, data); that._trigger('processalways', null, data); }); @@ -98,13 +96,13 @@ // are strings starting with an "@", using the remaining // substring as key for the option map, // e.g. "@autoUpload" is replaced with options.autoUpload: - _transformProcessQueue: function(options) { + _transformProcessQueue: function (options) { var processQueue = []; - $.each(options.processQueue, function() { + $.each(options.processQueue, function () { var settings = {}, action = this.action, prefix = this.prefix === true ? action : this.prefix; - $.each(this, function(key, value) { + $.each(this, function (key, value) { if ($.type(value) === 'string' && value.charAt(0) === '@') { settings[key] = options[ @@ -123,13 +121,13 @@ }, // Returns the number of files currently in the processsing queue: - processing: function() { + processing: function () { return this._processing; }, // Processes the files given as files property of the data parameter, // returns a Promise object that allows to bind callbacks: - process: function(data) { + process: function (data) { var that = this, options = $.extend({}, this.options, data); if (options.processQueue && options.processQueue.length) { @@ -137,14 +135,12 @@ if (this._processing === 0) { this._trigger('processstart'); } - $.each(data.files, function(index) { + $.each(data.files, function (index) { var opts = index ? $.extend({}, options) : options, - func = function() { + func = function () { if (data.errorThrown) { // eslint-disable-next-line new-cap - return $.Deferred() - .rejectWith(that, [data]) - .promise(); + return $.Deferred().rejectWith(that, [data]).promise(); } return that._processFile(opts, data); }; @@ -152,7 +148,7 @@ that._processing += 1; that._processingQueue = that._processingQueue .then(func, func) - .always(function() { + .always(function () { that._processing -= 1; if (that._processing === 0) { that._trigger('processstop'); @@ -163,13 +159,11 @@ return this._processingQueue; }, - _create: function() { + _create: function () { this._super(); this._processing = 0; // eslint-disable-next-line new-cap - this._processingQueue = $.Deferred() - .resolveWith(this) - .promise(); + this._processingQueue = $.Deferred().resolveWith(this).promise(); } }); }); diff --git a/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-ui.js b/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-ui.js index ff725cf14..c42b18cc2 100644 --- a/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-ui.js +++ b/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-ui.js @@ -11,7 +11,7 @@ /* global define, require */ -(function(factory) { +(function (factory) { 'use strict'; if (typeof define === 'function' && define.amd) { // Register as an anonymous AMD module: @@ -37,7 +37,7 @@ // Browser globals: factory(window.jQuery, window.tmpl); } -})(function($, tmpl) { +})(function ($, tmpl) { 'use strict'; $.blueimp.fileupload.prototype._specialOptions.push( @@ -77,12 +77,12 @@ // Function returning the current number of files, // used by the maxNumberOfFiles validation: - getNumberOfFiles: function() { + getNumberOfFiles: function () { return this.filesContainer.children().not('.processing').length; }, // Callback to retrieve the list of files from the server response: - getFilesFromResponse: function(data) { + getFilesFromResponse: function (data) { if (data.result && $.isArray(data.result.files)) { return data.result.files; } @@ -92,7 +92,7 @@ // The add callback is invoked as soon as files are added to the fileupload // widget (via file input selection, drag & drop or add API call). // See the basic file upload widget for more information: - add: function(e, data) { + add: function (e, data) { if (e.isDefaultPrevented()) { return false; } @@ -109,12 +109,12 @@ that._forceReflow(data.context); that._transition(data.context); data - .process(function() { + .process(function () { return $this.fileupload('process', data); }) - .always(function() { + .always(function () { data.context - .each(function(index) { + .each(function (index) { $(this) .find('.size') .text(that._formatFileSize(data.files[index].size)); @@ -122,7 +122,7 @@ .removeClass('processing'); that._renderPreviews(data); }) - .done(function() { + .done(function () { data.context.find('.edit,.start').prop('disabled', false); if ( that._trigger('added', e, data) !== false && @@ -132,21 +132,19 @@ data.submit(); } }) - .fail(function() { + .fail(function () { if (data.files.error) { - data.context.each(function(index) { + data.context.each(function (index) { var error = data.files[index].error; if (error) { - $(this) - .find('.error') - .text(error); + $(this).find('.error').text(error); } }); } }); }, // Callback for the start of each file upload request: - send: function(e, data) { + send: function (e, data) { if (e.isDefaultPrevented()) { return false; } @@ -171,7 +169,7 @@ return that._trigger('sent', e, data); }, // Callback for successful uploads: - done: function(e, data) { + done: function (e, data) { if (e.isDefaultPrevented()) { return false; } @@ -183,14 +181,14 @@ template, deferred; if (data.context) { - data.context.each(function(index) { + data.context.each(function (index) { var file = files[index] || { error: 'Empty file upload result' }; deferred = that._addFinishedDeferreds(); - that._transition($(this)).done(function() { + that._transition($(this)).done(function () { var node = $(this); template = that._renderDownload([file]).replaceAll(node); that._forceReflow(template); - that._transition(template).done(function() { + that._transition(template).done(function () { data.context = $(this); that._trigger('completed', e, data); that._trigger('finished', e, data); @@ -206,7 +204,7 @@ ); that._forceReflow(template); deferred = that._addFinishedDeferreds(); - that._transition(template).done(function() { + that._transition(template).done(function () { data.context = $(this); that._trigger('completed', e, data); that._trigger('finished', e, data); @@ -215,7 +213,7 @@ } }, // Callback for failed (abort or error) uploads: - fail: function(e, data) { + fail: function (e, data) { if (e.isDefaultPrevented()) { return false; } @@ -224,17 +222,17 @@ template, deferred; if (data.context) { - data.context.each(function(index) { + data.context.each(function (index) { if (data.errorThrown !== 'abort') { var file = data.files[index]; file.error = file.error || data.errorThrown || data.i18n('unknownError'); deferred = that._addFinishedDeferreds(); - that._transition($(this)).done(function() { + that._transition($(this)).done(function () { var node = $(this); template = that._renderDownload([file]).replaceAll(node); that._forceReflow(template); - that._transition(template).done(function() { + that._transition(template).done(function () { data.context = $(this); that._trigger('failed', e, data); that._trigger('finished', e, data); @@ -243,7 +241,7 @@ }); } else { deferred = that._addFinishedDeferreds(); - that._transition($(this)).done(function() { + that._transition($(this)).done(function () { $(this).remove(); that._trigger('failed', e, data); that._trigger('finished', e, data); @@ -260,7 +258,7 @@ .data('data', data); that._forceReflow(data.context); deferred = that._addFinishedDeferreds(); - that._transition(data.context).done(function() { + that._transition(data.context).done(function () { data.context = $(this); that._trigger('failed', e, data); that._trigger('finished', e, data); @@ -273,13 +271,13 @@ } }, // Callback for upload progress events: - progress: function(e, data) { + progress: function (e, data) { if (e.isDefaultPrevented()) { return false; } var progress = Math.floor((data.loaded / data.total) * 100); if (data.context) { - data.context.each(function() { + data.context.each(function () { $(this) .find('.progress') .attr('aria-valuenow', progress) @@ -290,7 +288,7 @@ } }, // Callback for global upload progress events: - progressall: function(e, data) { + progressall: function (e, data) { if (e.isDefaultPrevented()) { return false; } @@ -313,62 +311,64 @@ .css('width', progress + '%'); }, // Callback for uploads start, equivalent to the global ajaxStart event: - start: function(e) { + start: function (e) { if (e.isDefaultPrevented()) { return false; } var that = $(this).data('blueimp-fileupload') || $(this).data('fileupload'); that._resetFinishedDeferreds(); - that._transition($(this).find('.fileupload-progress')).done(function() { - that._trigger('started', e); - }); + that + ._transition($(this).find('.fileupload-progress')) + .done(function () { + that._trigger('started', e); + }); }, // Callback for uploads stop, equivalent to the global ajaxStop event: - stop: function(e) { + stop: function (e) { if (e.isDefaultPrevented()) { return false; } var that = $(this).data('blueimp-fileupload') || $(this).data('fileupload'), deferred = that._addFinishedDeferreds(); - $.when.apply($, that._getFinishedDeferreds()).done(function() { + $.when.apply($, that._getFinishedDeferreds()).done(function () { that._trigger('stopped', e); }); - that._transition($(this).find('.fileupload-progress')).done(function() { - $(this) - .find('.progress') - .attr('aria-valuenow', '0') - .children() - .first() - .css('width', '0%'); - $(this) - .find('.progress-extended') - .html(' '); - deferred.resolve(); - }); + that + ._transition($(this).find('.fileupload-progress')) + .done(function () { + $(this) + .find('.progress') + .attr('aria-valuenow', '0') + .children() + .first() + .css('width', '0%'); + $(this).find('.progress-extended').html(' '); + deferred.resolve(); + }); }, - processstart: function(e) { + processstart: function (e) { if (e.isDefaultPrevented()) { return false; } $(this).addClass('fileupload-processing'); }, - processstop: function(e) { + processstop: function (e) { if (e.isDefaultPrevented()) { return false; } $(this).removeClass('fileupload-processing'); }, // Callback for file deletion: - destroy: function(e, data) { + destroy: function (e, data) { if (e.isDefaultPrevented()) { return false; } var that = $(this).data('blueimp-fileupload') || $(this).data('fileupload'), - removeNode = function() { - that._transition(data.context).done(function() { + removeNode = function () { + that._transition(data.context).done(function () { $(this).remove(); that._trigger('destroyed', e, data); }); @@ -377,7 +377,7 @@ data.dataType = data.dataType || that.options.dataType; $.ajax(data) .done(removeNode) - .fail(function() { + .fail(function () { that._trigger('destroyfailed', e, data); }); } else { @@ -386,29 +386,29 @@ } }, - _resetFinishedDeferreds: function() { + _resetFinishedDeferreds: function () { this._finishedUploads = []; }, - _addFinishedDeferreds: function(deferred) { + _addFinishedDeferreds: function (deferred) { // eslint-disable-next-line new-cap var promise = deferred || $.Deferred(); this._finishedUploads.push(promise); return promise; }, - _getFinishedDeferreds: function() { + _getFinishedDeferreds: function () { return this._finishedUploads; }, // Link handler, that allows to download files // by drag & drop of the links to the desktop: - _enableDragToDesktop: function() { + _enableDragToDesktop: function () { var link = $(this), url = link.prop('href'), name = link.prop('download'), type = 'application/octet-stream'; - link.bind('dragstart', function(e) { + link.on('dragstart', function (e) { try { e.originalEvent.dataTransfer.setData( 'DownloadURL', @@ -420,7 +420,7 @@ }); }, - _formatFileSize: function(bytes) { + _formatFileSize: function (bytes) { if (typeof bytes !== 'number') { return ''; } @@ -433,7 +433,7 @@ return (bytes / 1000).toFixed(2) + ' KB'; }, - _formatBitrate: function(bits) { + _formatBitrate: function (bits) { if (typeof bits !== 'number') { return ''; } @@ -449,7 +449,7 @@ return bits.toFixed(2) + ' bit/s'; }, - _formatTime: function(seconds) { + _formatTime: function (seconds) { var date = new Date(seconds * 1000), days = Math.floor(seconds / 86400); days = days ? days + 'd ' : ''; @@ -463,11 +463,11 @@ ); }, - _formatPercentage: function(floatValue) { + _formatPercentage: function (floatValue) { return (floatValue * 100).toFixed(2) + ' %'; }, - _renderExtendedProgress: function(data) { + _renderExtendedProgress: function (data) { return ( this._formatBitrate(data.bitrate) + ' | ' + @@ -481,7 +481,7 @@ ); }, - _renderTemplate: function(func, files) { + _renderTemplate: function (func, files) { if (!func) { return $(); } @@ -493,31 +493,27 @@ if (result instanceof $) { return result; } - return $(this.options.templatesContainer) - .html(result) - .children(); + return $(this.options.templatesContainer).html(result).children(); }, - _renderPreviews: function(data) { - data.context.find('.preview').each(function(index, elm) { - $(elm) - .empty() - .append(data.files[index].preview); + _renderPreviews: function (data) { + data.context.find('.preview').each(function (index, elm) { + $(elm).empty().append(data.files[index].preview); }); }, - _renderUpload: function(files) { + _renderUpload: function (files) { return this._renderTemplate(this.options.uploadTemplate, files); }, - _renderDownload: function(files) { + _renderDownload: function (files) { return this._renderTemplate(this.options.downloadTemplate, files) .find('a[download]') .each(this._enableDragToDesktop) .end(); }, - _editHandler: function(e) { + _editHandler: function (e) { e.preventDefault(); if (!this.options.edit) return; var that = this, @@ -525,24 +521,24 @@ template = button.closest('.template-upload'), data = template.data('data'), index = button.data().index; - this.options.edit(data.files[index]).then(function(file) { + this.options.edit(data.files[index]).then(function (file) { if (!file) return; data.files[index] = file; data.context.addClass('processing'); template.find('.edit,.start').prop('disabled', true); $(that.element) .fileupload('process', data) - .always(function() { + .always(function () { template .find('.size') .text(that._formatFileSize(data.files[index].size)); data.context.removeClass('processing'); that._renderPreviews(data); }) - .done(function() { + .done(function () { template.find('.edit,.start').prop('disabled', false); }) - .fail(function() { + .fail(function () { template.find('.edit').prop('disabled', false); var error = data.files[index].error; if (error) { @@ -552,7 +548,7 @@ }); }, - _startHandler: function(e) { + _startHandler: function (e) { e.preventDefault(); var button = $(e.currentTarget), template = button.closest('.template-upload'), @@ -563,7 +559,7 @@ } }, - _cancelHandler: function(e) { + _cancelHandler: function (e) { e.preventDefault(); var template = $(e.currentTarget).closest( '.template-upload,.template-download' @@ -578,7 +574,7 @@ } }, - _deleteHandler: function(e) { + _deleteHandler: function (e) { e.preventDefault(); var button = $(e.currentTarget); this._trigger( @@ -594,11 +590,11 @@ ); }, - _forceReflow: function(node) { + _forceReflow: function (node) { return $.support.transition && node.length && node[0].offsetWidth; }, - _transition: function(node) { + _transition: function (node) { // eslint-disable-next-line new-cap var dfd = $.Deferred(); if ( @@ -606,16 +602,16 @@ node.hasClass('fade') && node.is(':visible') ) { - var transitionEndHandler = function(e) { + var transitionEndHandler = function (e) { // Make sure we don't respond to other transition events // in the container element, e.g. from button elements: if (e.target === node[0]) { - node.unbind($.support.transition.end, transitionEndHandler); + node.off($.support.transition.end, transitionEndHandler); dfd.resolveWith(node); } }; node - .bind($.support.transition.end, transitionEndHandler) + .on($.support.transition.end, transitionEndHandler) .toggleClass(this.options.showElementClass); } else { node.toggleClass(this.options.showElementClass); @@ -624,23 +620,23 @@ return dfd; }, - _initButtonBarEventHandlers: function() { + _initButtonBarEventHandlers: function () { var fileUploadButtonBar = this.element.find('.fileupload-buttonbar'), filesList = this.options.filesContainer; this._on(fileUploadButtonBar.find('.start'), { - click: function(e) { + click: function (e) { e.preventDefault(); filesList.find('.start').click(); } }); this._on(fileUploadButtonBar.find('.cancel'), { - click: function(e) { + click: function (e) { e.preventDefault(); filesList.find('.cancel').click(); } }); this._on(fileUploadButtonBar.find('.delete'), { - click: function(e) { + click: function (e) { e.preventDefault(); filesList .find('.toggle:checked') @@ -651,7 +647,7 @@ } }); this._on(fileUploadButtonBar.find('.toggle'), { - change: function(e) { + change: function (e) { filesList .find('.toggle') .prop('checked', $(e.currentTarget).is(':checked')); @@ -659,7 +655,7 @@ }); }, - _destroyButtonBarEventHandlers: function() { + _destroyButtonBarEventHandlers: function () { this._off( this.element .find('.fileupload-buttonbar') @@ -669,7 +665,7 @@ this._off(this.element.find('.fileupload-buttonbar .toggle'), 'change.'); }, - _initEventHandlers: function() { + _initEventHandlers: function () { this._super(); this._on(this.options.filesContainer, { 'click .edit': this._editHandler, @@ -680,13 +676,13 @@ this._initButtonBarEventHandlers(); }, - _destroyEventHandlers: function() { + _destroyEventHandlers: function () { this._destroyButtonBarEventHandlers(); this._off(this.options.filesContainer, 'click'); this._super(); }, - _enableFileInputButton: function() { + _enableFileInputButton: function () { this.element .find('.fileinput-button input') .prop('disabled', false) @@ -694,7 +690,7 @@ .removeClass('disabled'); }, - _disableFileInputButton: function() { + _disableFileInputButton: function () { this.element .find('.fileinput-button input') .prop('disabled', true) @@ -702,7 +698,7 @@ .addClass('disabled'); }, - _initTemplates: function() { + _initTemplates: function () { var options = this.options; options.templatesContainer = this.document[0].createElement( options.filesContainer.prop('nodeName') @@ -717,7 +713,7 @@ } }, - _initFilesContainer: function() { + _initFilesContainer: function () { var options = this.options; if (options.filesContainer === undefined) { options.filesContainer = this.element.find('.files'); @@ -726,13 +722,13 @@ } }, - _initSpecialOptions: function() { + _initSpecialOptions: function () { this._super(); this._initFilesContainer(); this._initTemplates(); }, - _create: function() { + _create: function () { this._super(); this._resetFinishedDeferreds(); if (!$.support.fileInput) { @@ -740,7 +736,7 @@ } }, - enable: function() { + enable: function () { var wasDisabled = false; if (this.options.disabled) { wasDisabled = true; @@ -752,7 +748,7 @@ } }, - disable: function() { + disable: function () { if (!this.options.disabled) { this.element.find('input, button').prop('disabled', true); this._disableFileInputButton(); diff --git a/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-validate.js b/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-validate.js index 37b380a00..a277efc46 100644 --- a/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-validate.js +++ b/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-validate.js @@ -11,7 +11,7 @@ /* global define, require */ -(function(factory) { +(function (factory) { 'use strict'; if (typeof define === 'function' && define.amd) { // Register as an anonymous AMD module: @@ -23,7 +23,7 @@ // Browser globals: factory(window.jQuery); } -})(function($) { +})(function ($) { 'use strict'; // Append to the default processQueue: @@ -70,7 +70,7 @@ }, processActions: { - validate: function(data, options) { + validate: function (data, options) { if (options.disabled) { return data; } diff --git a/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-video.js b/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-video.js index 06d5f66cf..5dc78f36b 100644 --- a/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-video.js +++ b/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-video.js @@ -11,7 +11,7 @@ /* global define, require */ -(function(factory) { +(function (factory) { 'use strict'; if (typeof define === 'function' && define.amd) { // Register as an anonymous AMD module: @@ -27,7 +27,7 @@ // Browser globals: factory(window.jQuery, window.loadImage); } -})(function($, loadImage) { +})(function ($, loadImage) { 'use strict'; // Prepend to the default processQueue: @@ -63,7 +63,7 @@ // as video element if the browser supports playing it. // Accepts the options fileTypes (regular expression) // and maxFileSize (integer) to limit the files to load: - loadVideo: function(data, options) { + loadVideo: function (data, options) { if (options.disabled) { return data; } @@ -90,7 +90,7 @@ }, // Sets the video element as a property of the file object: - setVideo: function(data, options) { + setVideo: function (data, options) { if (data.video && !options.disabled) { data.files[data.index][options.name || 'preview'] = data.video; } diff --git a/vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js b/vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js index d4d32570c..f75cf2b10 100644 --- a/vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js +++ b/vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js @@ -12,7 +12,7 @@ /* global define, require */ /* eslint-disable new-cap */ -(function(factory) { +(function (factory) { 'use strict'; if (typeof define === 'function' && define.amd) { // Register as an anonymous AMD module: @@ -24,7 +24,7 @@ // Browser globals: factory(window.jQuery); } -})(function($) { +})(function ($) { 'use strict'; // Detect file input support, based on @@ -64,7 +64,7 @@ */ function getDragHandler(type) { var isDragOver = type === 'dragover'; - return function(e) { + return function (e) { e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer; var dataTransfer = e.dataTransfer; if ( @@ -185,11 +185,11 @@ // Translation function, gets the message key to be translated // and an object with context specific data as arguments: - i18n: function(message, context) { + i18n: function (message, context) { // eslint-disable-next-line no-param-reassign message = this.messages[message] || message.toString(); if (context) { - $.each(context, function(key, value) { + $.each(context, function (key, value) { // eslint-disable-next-line no-param-reassign message = message.replace('{' + key + '}', value); }); @@ -202,7 +202,7 @@ // value properties, a function returning such an array, a FormData // object (for XHR file uploads), or a simple object. // The form of the first fileInput is given as parameter to the function: - formData: function(form) { + formData: function (form) { return form.serializeArray(); }, @@ -217,12 +217,12 @@ // and allows you to override plugin options as well as define ajax settings. // // Listeners for this callback can also be bound the following way: - // .bind('fileuploadadd', func); + // .on('fileuploadadd', func); // // data.submit() returns a Promise object and allows to attach additional // handlers using jQuery's Deferred callbacks: // data.submit().done(func).fail(func).always(func); - add: function(e, data) { + add: function (e, data) { if (e.isDefaultPrevented()) { return false; } @@ -231,7 +231,7 @@ (data.autoUpload !== false && $(this).fileupload('option', 'autoUpload')) ) { - data.process().done(function() { + data.process().done(function () { data.submit(); }); } @@ -240,58 +240,58 @@ // Other callbacks: // Callback for the submit event of each file upload: - // submit: function (e, data) {}, // .bind('fileuploadsubmit', func); + // submit: function (e, data) {}, // .on('fileuploadsubmit', func); // Callback for the start of each file upload request: - // send: function (e, data) {}, // .bind('fileuploadsend', func); + // send: function (e, data) {}, // .on('fileuploadsend', func); // Callback for successful uploads: - // done: function (e, data) {}, // .bind('fileuploaddone', func); + // done: function (e, data) {}, // .on('fileuploaddone', func); // Callback for failed (abort or error) uploads: - // fail: function (e, data) {}, // .bind('fileuploadfail', func); + // fail: function (e, data) {}, // .on('fileuploadfail', func); // Callback for completed (success, abort or error) requests: - // always: function (e, data) {}, // .bind('fileuploadalways', func); + // always: function (e, data) {}, // .on('fileuploadalways', func); // Callback for upload progress events: - // progress: function (e, data) {}, // .bind('fileuploadprogress', func); + // progress: function (e, data) {}, // .on('fileuploadprogress', func); // Callback for global upload progress events: - // progressall: function (e, data) {}, // .bind('fileuploadprogressall', func); + // progressall: function (e, data) {}, // .on('fileuploadprogressall', func); // Callback for uploads start, equivalent to the global ajaxStart event: - // start: function (e) {}, // .bind('fileuploadstart', func); + // start: function (e) {}, // .on('fileuploadstart', func); // Callback for uploads stop, equivalent to the global ajaxStop event: - // stop: function (e) {}, // .bind('fileuploadstop', func); + // stop: function (e) {}, // .on('fileuploadstop', func); // Callback for change events of the fileInput(s): - // change: function (e, data) {}, // .bind('fileuploadchange', func); + // change: function (e, data) {}, // .on('fileuploadchange', func); // Callback for paste events to the pasteZone(s): - // paste: function (e, data) {}, // .bind('fileuploadpaste', func); + // paste: function (e, data) {}, // .on('fileuploadpaste', func); // Callback for drop events of the dropZone(s): - // drop: function (e, data) {}, // .bind('fileuploaddrop', func); + // drop: function (e, data) {}, // .on('fileuploaddrop', func); // Callback for dragover events of the dropZone(s): - // dragover: function (e) {}, // .bind('fileuploaddragover', func); + // dragover: function (e) {}, // .on('fileuploaddragover', func); // Callback before the start of each chunk upload request (before form data initialization): - // chunkbeforesend: function (e, data) {}, // .bind('fileuploadchunkbeforesend', func); + // chunkbeforesend: function (e, data) {}, // .on('fileuploadchunkbeforesend', func); // Callback for the start of each chunk upload request: - // chunksend: function (e, data) {}, // .bind('fileuploadchunksend', func); + // chunksend: function (e, data) {}, // .on('fileuploadchunksend', func); // Callback for successful chunk uploads: - // chunkdone: function (e, data) {}, // .bind('fileuploadchunkdone', func); + // chunkdone: function (e, data) {}, // .on('fileuploadchunkdone', func); // Callback for failed (abort or error) chunk uploads: - // chunkfail: function (e, data) {}, // .bind('fileuploadchunkfail', func); + // chunkfail: function (e, data) {}, // .on('fileuploadchunkfail', func); // Callback for completed (success, abort or error) chunk upload requests: - // chunkalways: function (e, data) {}, // .bind('fileuploadchunkalways', func); + // chunkalways: function (e, data) {}, // .on('fileuploadchunkalways', func); // The plugin options are used as settings object for the ajax calls. // The following are jQuery ajax settings required for the file uploads: @@ -313,16 +313,16 @@ _blobSlice: $.support.blobSlice && - function() { + function () { var slice = this.slice || this.webkitSlice || this.mozSlice; return slice.apply(this, arguments); }, - _BitrateTimer: function() { + _BitrateTimer: function () { this.timestamp = Date.now ? Date.now() : new Date().getTime(); this.loaded = 0; this.bitrate = 0; - this.getBitrate = function(now, loaded, interval) { + this.getBitrate = function (now, loaded, interval) { var timeDiff = now - this.timestamp; if (!this.bitrate || !interval || timeDiff > interval) { this.bitrate = (loaded - this.loaded) * (1000 / timeDiff) * 8; @@ -333,7 +333,7 @@ }; }, - _isXHRUpload: function(options) { + _isXHRUpload: function (options) { return ( !options.forceIframeTransport && ((!options.multipart && $.support.xhrFileUpload) || @@ -341,7 +341,7 @@ ); }, - _getFormData: function(options) { + _getFormData: function (options) { var formData; if ($.type(options.formData) === 'function') { return options.formData(options.form); @@ -351,7 +351,7 @@ } if ($.type(options.formData) === 'object') { formData = []; - $.each(options.formData, function(name, value) { + $.each(options.formData, function (name, value) { formData.push({ name: name, value: value }); }); return formData; @@ -359,15 +359,15 @@ return []; }, - _getTotal: function(files) { + _getTotal: function (files) { var total = 0; - $.each(files, function(index, file) { + $.each(files, function (index, file) { total += file.size || 1; }); return total; }, - _initProgressObject: function(obj) { + _initProgressObject: function (obj) { var progress = { loaded: 0, total: 0, @@ -380,7 +380,7 @@ } }, - _initResponseObject: function(obj) { + _initResponseObject: function (obj) { var prop; if (obj._response) { for (prop in obj._response) { @@ -393,7 +393,7 @@ } }, - _onProgress: function(e, data) { + _onProgress: function (e, data) { if (e.lengthComputable) { var now = Date.now ? Date.now() : new Date().getTime(), loaded; @@ -442,13 +442,13 @@ } }, - _initProgressListener: function(options) { + _initProgressListener: function (options) { var that = this, xhr = options.xhr ? options.xhr() : $.ajaxSettings.xhr(); // Accesss to the native XHR object is required to add event listeners // for the upload progress event: if (xhr.upload) { - $(xhr.upload).bind('progress', function(e) { + $(xhr.upload).on('progress', function (e) { var oe = e.originalEvent; // Make sure the progress event properties get copied over: e.lengthComputable = oe.lengthComputable; @@ -456,30 +456,30 @@ e.total = oe.total; that._onProgress(e, options); }); - options.xhr = function() { + options.xhr = function () { return xhr; }; } }, - _deinitProgressListener: function(options) { + _deinitProgressListener: function (options) { var xhr = options.xhr ? options.xhr() : $.ajaxSettings.xhr(); if (xhr.upload) { - $(xhr.upload).unbind('progress'); + $(xhr.upload).off('progress'); } }, - _isInstanceOf: function(type, obj) { + _isInstanceOf: function (type, obj) { // Cross-frame instanceof check return Object.prototype.toString.call(obj) === '[object ' + type + ']'; }, - _getUniqueFilename: function(name, map) { + _getUniqueFilename: function (name, map) { // eslint-disable-next-line no-param-reassign name = String(name); if (map[name]) { // eslint-disable-next-line no-param-reassign - name = name.replace(/(?: \(([\d]+)\))?(\.[^.]+)?$/, function( + name = name.replace(/(?: \(([\d]+)\))?(\.[^.]+)?$/, function ( _, p1, p2 @@ -494,7 +494,7 @@ return name; }, - _initXHRData: function(options) { + _initXHRData: function (options) { var that = this, formData, file = options.files[0], @@ -530,7 +530,7 @@ value: options.blob }); } else { - $.each(options.files, function(index, file) { + $.each(options.files, function (index, file) { formData.push({ name: ($.type(options.paramName) === 'array' && @@ -545,7 +545,7 @@ formData = options.formData; } else { formData = new FormData(); - $.each(this._getFormData(options), function(index, field) { + $.each(this._getFormData(options), function (index, field) { formData.append(field.name, field.value); }); } @@ -556,7 +556,7 @@ file.uploadName || file.name ); } else { - $.each(options.files, function(index, file) { + $.each(options.files, function (index, file) { // This check allows the tests to run with // dummy objects: if ( @@ -587,10 +587,8 @@ options.blob = null; }, - _initIframeSettings: function(options) { - var targetHost = $('<a></a>') - .prop('href', options.url) - .prop('host'); + _initIframeSettings: function (options) { + var targetHost = $('<a></a>').prop('href', options.url).prop('host'); // Setting the dataType to iframe enables the iframe transport: options.dataType = 'iframe ' + (options.dataType || ''); // The iframe transport accepts a serialized array as form data: @@ -604,7 +602,7 @@ } }, - _initDataSettings: function(options) { + _initDataSettings: function (options) { if (this._isXHRUpload(options)) { if (!this._chunkedUpload(options, true)) { if (!options.data) { @@ -622,12 +620,12 @@ } }, - _getParamName: function(options) { + _getParamName: function (options) { var fileInput = $(options.fileInput), paramName = options.paramName; if (!paramName) { paramName = []; - fileInput.each(function() { + fileInput.each(function () { var input = $(this), name = input.prop('name') || 'files[]', i = (input.prop('files') || [1]).length; @@ -645,7 +643,7 @@ return paramName; }, - _initFormSettings: function(options) { + _initFormSettings: function (options) { // Retrieve missing options from the input field and the // associated form, if available: if (!options.form || !options.form.length) { @@ -679,7 +677,7 @@ } }, - _getAJAXSettings: function(data) { + _getAJAXSettings: function (data) { var options = $.extend({}, this.options, data); this._initFormSettings(options); this._initDataSettings(options); @@ -688,7 +686,7 @@ // jQuery 1.6 doesn't provide .state(), // while jQuery 1.8+ removed .isRejected() and .isResolved(): - _getDeferredState: function(deferred) { + _getDeferredState: function (deferred) { if (deferred.state) { return deferred.state(); } @@ -703,7 +701,7 @@ // Maps jqXHR callbacks to the equivalent // methods of the given Promise object: - _enhancePromise: function(promise) { + _enhancePromise: function (promise) { promise.success = promise.done; promise.error = promise.fail; promise.complete = promise.always; @@ -712,7 +710,7 @@ // Creates and returns a Promise object enhanced with // the jqXHR methods abort, success, error and complete: - _getXHRPromise: function(resolveOrReject, context, args) { + _getXHRPromise: function (resolveOrReject, context, args) { var dfd = $.Deferred(), promise = dfd.promise(); // eslint-disable-next-line no-param-reassign @@ -727,23 +725,19 @@ }, // Adds convenience methods to the data callback argument: - _addConvenienceMethods: function(e, data) { + _addConvenienceMethods: function (e, data) { var that = this, - getPromise = function(args) { - return $.Deferred() - .resolveWith(that, args) - .promise(); + getPromise = function (args) { + return $.Deferred().resolveWith(that, args).promise(); }; - data.process = function(resolveFunc, rejectFunc) { + data.process = function (resolveFunc, rejectFunc) { if (resolveFunc || rejectFunc) { data._processQueue = this._processQueue = ( this._processQueue || getPromise([this]) ) - .then(function() { + .then(function () { if (data.errorThrown) { - return $.Deferred() - .rejectWith(that, [data]) - .promise(); + return $.Deferred().rejectWith(that, [data]).promise(); } return getPromise(arguments); }) @@ -751,7 +745,7 @@ } return this._processQueue || getPromise([this]); }; - data.submit = function() { + data.submit = function () { if (this.state() !== 'pending') { data.jqXHR = this.jqXHR = that._trigger( @@ -762,7 +756,7 @@ } return this.jqXHR || that._getXHRPromise(); }; - data.abort = function() { + data.abort = function () { if (this.jqXHR) { return this.jqXHR.abort(); } @@ -770,7 +764,7 @@ that._trigger('fail', null, this); return that._getXHRPromise(false); }; - data.state = function() { + data.state = function () { if (this.jqXHR) { return that._getDeferredState(this.jqXHR); } @@ -778,24 +772,24 @@ return that._getDeferredState(this._processQueue); } }; - data.processing = function() { + data.processing = function () { return ( !this.jqXHR && this._processQueue && that._getDeferredState(this._processQueue) === 'pending' ); }; - data.progress = function() { + data.progress = function () { return this._progress; }; - data.response = function() { + data.response = function () { return this._response; }; }, // Parses the Range header from the server response // and returns the uploaded bytes: - _getUploadedBytes: function(jqXHR) { + _getUploadedBytes: function (jqXHR) { var range = jqXHR.getResponseHeader('Range'), parts = range && range.split('-'), upperBytesPos = parts && parts.length > 1 && parseInt(parts[1], 10); @@ -807,7 +801,7 @@ // If the second parameter is true, only tests if the file // should be uploaded in chunks, but does not invoke any // upload requests: - _chunkedUpload: function(options, testOnly) { + _chunkedUpload: function (options, testOnly) { options.uploadedBytes = options.uploadedBytes || 0; var that = this, file = options.files[0], @@ -841,7 +835,7 @@ ]); } // The chunk upload method: - upload = function() { + upload = function () { // Clone the options object for each chunk upload: var o = $.extend({}, options), currentLoaded = o._progress.loaded; @@ -867,7 +861,7 @@ (that._trigger('chunksend', null, o) !== false && $.ajax(o)) || that._getXHRPromise(false, o.context) ) - .done(function(result, textStatus, jqXHR) { + .done(function (result, textStatus, jqXHR) { ub = that._getUploadedBytes(jqXHR) || ub + o.chunkSize; // Create a progress event if no final progress event // with loaded equaling total has been triggered @@ -896,7 +890,7 @@ dfd.resolveWith(o.context, [result, textStatus, jqXHR]); } }) - .fail(function(jqXHR, textStatus, errorThrown) { + .fail(function (jqXHR, textStatus, errorThrown) { o.jqXHR = jqXHR; o.textStatus = textStatus; o.errorThrown = errorThrown; @@ -904,19 +898,19 @@ that._trigger('chunkalways', null, o); dfd.rejectWith(o.context, [jqXHR, textStatus, errorThrown]); }) - .always(function() { + .always(function () { that._deinitProgressListener(o); }); }; this._enhancePromise(promise); - promise.abort = function() { + promise.abort = function () { return jqXHR.abort(); }; upload(); return promise; }, - _beforeSend: function(e, data) { + _beforeSend: function (e, data) { if (this._active === 0) { // the start callback is triggered when an upload starts // and no other uploads are currently running, @@ -942,7 +936,7 @@ this._progress.total += data.total; }, - _onDone: function(result, textStatus, jqXHR, options) { + _onDone: function (result, textStatus, jqXHR, options) { var total = options._progress.total, response = options._response; if (options._progress.loaded < total) { @@ -963,7 +957,7 @@ this._trigger('done', null, options); }, - _onFail: function(jqXHR, textStatus, errorThrown, options) { + _onFail: function (jqXHR, textStatus, errorThrown, options) { var response = options._response; if (options.recalculateProgress) { // Remove the failed (error or abort) file upload from @@ -977,13 +971,13 @@ this._trigger('fail', null, options); }, - _onAlways: function(jqXHRorResult, textStatus, jqXHRorError, options) { + _onAlways: function (jqXHRorResult, textStatus, jqXHRorError, options) { // jqXHRorResult, textStatus and jqXHRorError are added to the // options object via done and fail callbacks this._trigger('always', null, options); }, - _onSend: function(e, data) { + _onSend: function (e, data) { if (!data.submit) { this._addConvenienceMethods(e, data); } @@ -993,7 +987,7 @@ slot, pipe, options = that._getAJAXSettings(data), - send = function() { + send = function () { that._sending += 1; // Set timer for bitrate progress calculation: options._bitrateTimer = new that._BitrateTimer(); @@ -1010,13 +1004,13 @@ that._chunkedUpload(options) || $.ajax(options) ) - .done(function(result, textStatus, jqXHR) { + .done(function (result, textStatus, jqXHR) { that._onDone(result, textStatus, jqXHR, options); }) - .fail(function(jqXHR, textStatus, errorThrown) { + .fail(function (jqXHR, textStatus, errorThrown) { that._onFail(jqXHR, textStatus, errorThrown, options); }) - .always(function(jqXHRorResult, textStatus, jqXHRorError) { + .always(function (jqXHRorResult, textStatus, jqXHRorError) { that._deinitProgressListener(options); that._onAlways( jqXHRorResult, @@ -1066,7 +1060,7 @@ // Return the piped Promise object, enhanced with an abort method, // which is delegated to the jqXHR object of the current upload, // and jqXHR callbacks mapped to the equivalent Promise methods: - pipe.abort = function() { + pipe.abort = function () { aborted = [undefined, 'abort', 'abort']; if (!jqXHR) { if (slot) { @@ -1081,7 +1075,7 @@ return send(); }, - _onAdd: function(e, data) { + _onAdd: function (e, data) { var that = this, result = true, options = $.extend({}, this.options, data), @@ -1144,7 +1138,7 @@ paramNameSet = paramName; } data.originalFiles = files; - $.each(fileSet || files, function(index, element) { + $.each(fileSet || files, function (index, element) { var newData = $.extend({}, data); newData.files = fileSet ? element : [element]; newData.paramName = paramNameSet[index]; @@ -1161,15 +1155,13 @@ return result; }, - _replaceFileInput: function(data) { + _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(); + $('<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(); @@ -1179,11 +1171,11 @@ inputClone.focus(); } // Avoid memory leaks with the detached file input: - $.cleanData(input.unbind('remove')); + $.cleanData(input.off('remove')); // Replace the original file input element in the fileInput // elements set with the clone, which has been copied including // event handlers: - this.options.fileInput = this.options.fileInput.map(function(i, el) { + this.options.fileInput = this.options.fileInput.map(function (i, el) { if (el === input[0]) { return inputClone[0]; } @@ -1196,12 +1188,12 @@ } }, - _handleFileTreeEntry: function(entry, path) { + _handleFileTreeEntry: function (entry, path) { var that = this, dfd = $.Deferred(), entries = [], dirReader, - errorHandler = function(e) { + errorHandler = function (e) { if (e && !e.entry) { e.entry = entry; } @@ -1211,16 +1203,16 @@ // to be returned together in one set: dfd.resolve([e]); }, - successHandler = function(entries) { + successHandler = function (entries) { that ._handleFileTreeEntries(entries, path + entry.name + '/') - .done(function(files) { + .done(function (files) { dfd.resolve(files); }) .fail(errorHandler); }, - readEntries = function() { - dirReader.readEntries(function(results) { + readEntries = function () { + dirReader.readEntries(function (results) { if (!results.length) { successHandler(entries); } else { @@ -1237,7 +1229,7 @@ entry._file.relativePath = path; dfd.resolve(entry._file); } else { - entry.file(function(file) { + entry.file(function (file) { file.relativePath = path; dfd.resolve(file); }, errorHandler); @@ -1253,21 +1245,21 @@ return dfd.promise(); }, - _handleFileTreeEntries: function(entries, path) { + _handleFileTreeEntries: function (entries, path) { var that = this; return $.when .apply( $, - $.map(entries, function(entry) { + $.map(entries, function (entry) { return that._handleFileTreeEntry(entry, path); }) ) - .then(function() { + .then(function () { return Array.prototype.concat.apply([], arguments); }); }, - _getDroppedFiles: function(dataTransfer) { + _getDroppedFiles: function (dataTransfer) { // eslint-disable-next-line no-param-reassign dataTransfer = dataTransfer || {}; var items = dataTransfer.items; @@ -1277,7 +1269,7 @@ (items[0].webkitGetAsEntry || items[0].getAsEntry) ) { return this._handleFileTreeEntries( - $.map(items, function(item) { + $.map(items, function (item) { var entry; if (item.webkitGetAsEntry) { entry = item.webkitGetAsEntry(); @@ -1291,12 +1283,10 @@ }) ); } - return $.Deferred() - .resolve($.makeArray(dataTransfer.files)) - .promise(); + return $.Deferred().resolve($.makeArray(dataTransfer.files)).promise(); }, - _getSingleFileInputFiles: function(fileInput) { + _getSingleFileInputFiles: function (fileInput) { // eslint-disable-next-line no-param-reassign fileInput = $(fileInput); var entries = @@ -1310,9 +1300,7 @@ if (!files.length) { value = fileInput.prop('value'); if (!value) { - return $.Deferred() - .resolve([]) - .promise(); + return $.Deferred().resolve([]).promise(); } // If the files property is not available, the browser does not // support the File API and we add a pseudo File object with @@ -1320,34 +1308,32 @@ files = [{ name: value.replace(/^.*\\/, '') }]; } else if (files[0].name === undefined && files[0].fileName) { // File normalization for Safari 4 and Firefox 3: - $.each(files, function(index, file) { + $.each(files, function (index, file) { file.name = file.fileName; file.size = file.fileSize; }); } - return $.Deferred() - .resolve(files) - .promise(); + return $.Deferred().resolve(files).promise(); }, - _getFileInputFiles: function(fileInput) { + _getFileInputFiles: function (fileInput) { if (!(fileInput instanceof $) || fileInput.length === 1) { return this._getSingleFileInputFiles(fileInput); } return $.when .apply($, $.map(fileInput, this._getSingleFileInputFiles)) - .then(function() { + .then(function () { return Array.prototype.concat.apply([], arguments); }); }, - _onChange: function(e) { + _onChange: function (e) { var that = this, data = { fileInput: $(e.target), form: $(e.target.form) }; - this._getFileInputFiles(data.fileInput).always(function(files) { + this._getFileInputFiles(data.fileInput).always(function (files) { data.files = files; if (that.options.replaceFileInput) { that._replaceFileInput(data); @@ -1364,14 +1350,14 @@ }); }, - _onPaste: function(e) { + _onPaste: function (e) { var items = e.originalEvent && e.originalEvent.clipboardData && e.originalEvent.clipboardData.items, data = { files: [] }; if (items && items.length) { - $.each(items, function(index, item) { + $.each(items, function (index, item) { var file = item.getAsFile && item.getAsFile(); if (file) { data.files.push(file); @@ -1389,14 +1375,14 @@ } }, - _onDrop: function(e) { + _onDrop: function (e) { e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer; var that = this, dataTransfer = e.dataTransfer, data = {}; if (dataTransfer && dataTransfer.files && dataTransfer.files.length) { e.preventDefault(); - this._getDroppedFiles(dataTransfer).always(function(files) { + this._getDroppedFiles(dataTransfer).always(function (files) { data.files = files; if ( that._trigger( @@ -1417,7 +1403,7 @@ _onDragLeave: getDragHandler('dragleave'), - _initEventHandlers: function() { + _initEventHandlers: function () { if (this._isXHRUpload(this.options)) { this._on(this.options.dropZone, { dragover: this._onDragOver, @@ -1438,17 +1424,17 @@ } }, - _destroyEventHandlers: function() { + _destroyEventHandlers: function () { this._off(this.options.dropZone, 'dragenter dragleave dragover drop'); this._off(this.options.pasteZone, 'paste'); this._off(this.options.fileInput, 'change'); }, - _destroy: function() { + _destroy: function () { this._destroyEventHandlers(); }, - _setOption: function(key, value) { + _setOption: function (key, value) { var reinit = $.inArray(key, this._specialOptions) !== -1; if (reinit) { this._destroyEventHandlers(); @@ -1460,7 +1446,7 @@ } }, - _initSpecialOptions: function() { + _initSpecialOptions: function () { var options = this.options; if (options.fileInput === undefined) { options.fileInput = this.element.is('input[type="file"]') @@ -1477,14 +1463,14 @@ } }, - _getRegExp: function(str) { + _getRegExp: function (str) { var parts = str.split('/'), modifiers = parts.pop(); parts.shift(); return new RegExp(parts.join('/'), modifiers); }, - _isRegExpOption: function(key, value) { + _isRegExpOption: function (key, value) { return ( key !== 'url' && $.type(value) === 'string' && @@ -1492,17 +1478,17 @@ ); }, - _initDataAttributes: function() { + _initDataAttributes: function () { var that = this, options = this.options, data = this.element.data(); // Initialize options set via HTML5 data-attributes: - $.each(this.element[0].attributes, function(index, attr) { + $.each(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) { + key = key.slice(5).replace(/-[a-z]/g, function (str) { return str.charAt(1).toUpperCase(); }); value = data[key]; @@ -1514,7 +1500,7 @@ }); }, - _create: function() { + _create: function () { this._initDataAttributes(); this._initSpecialOptions(); this._slots = []; @@ -1526,7 +1512,7 @@ // This method is exposed to the widget API and allows to query // the number of active uploads: - active: function() { + active: function () { return this._active; }, @@ -1534,7 +1520,7 @@ // the widget upload progress. // It returns an object with loaded, total and bitrate properties // for the running uploads: - progress: function() { + progress: function () { return this._progress; }, @@ -1542,13 +1528,13 @@ // using the fileupload API. The data parameter accepts an object which // must have a files property and can contain additional options: // .fileupload('add', {files: filesList}); - add: function(data) { + add: function (data) { var that = this; if (!data || this.options.disabled) { return; } if (data.fileInput && !data.files) { - this._getFileInputFiles(data.fileInput).always(function(files) { + this._getFileInputFiles(data.fileInput).always(function (files) { data.files = files; that._onAdd(null, data); }); @@ -1563,7 +1549,7 @@ // must have a files or fileInput property and can contain additional options: // .fileupload('send', {files: filesList}); // The method returns a Promise object for the file upload call. - send: function(data) { + send: function (data) { if (data && !this.options.disabled) { if (data.fileInput && !data.files) { var that = this, @@ -1571,7 +1557,7 @@ promise = dfd.promise(), jqXHR, aborted; - promise.abort = function() { + promise.abort = function () { aborted = true; if (jqXHR) { return jqXHR.abort(); @@ -1579,7 +1565,7 @@ dfd.reject(null, 'abort', 'abort'); return promise; }; - this._getFileInputFiles(data.fileInput).always(function(files) { + this._getFileInputFiles(data.fileInput).always(function (files) { if (aborted) { return; } @@ -1590,10 +1576,10 @@ data.files = files; jqXHR = that._onSend(null, data); jqXHR.then( - function(result, textStatus, jqXHR) { + function (result, textStatus, jqXHR) { dfd.resolve(result, textStatus, jqXHR); }, - function(jqXHR, textStatus, errorThrown) { + function (jqXHR, textStatus, errorThrown) { dfd.reject(jqXHR, textStatus, errorThrown); } ); diff --git a/vendor/blueimp/jquery-file-upload/js/jquery.iframe-transport.js b/vendor/blueimp/jquery-file-upload/js/jquery.iframe-transport.js index b56690bea..3e3b9a93b 100644 --- a/vendor/blueimp/jquery-file-upload/js/jquery.iframe-transport.js +++ b/vendor/blueimp/jquery-file-upload/js/jquery.iframe-transport.js @@ -11,7 +11,7 @@ /* global define, require */ -(function(factory) { +(function (factory) { 'use strict'; if (typeof define === 'function' && define.amd) { // Register as an anonymous AMD module: @@ -23,7 +23,7 @@ // Browser globals: factory(window.jQuery); } -})(function($) { +})(function ($) { 'use strict'; // Helper variable to create unique names for the transport iframes: @@ -46,7 +46,7 @@ // [{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) { + $.ajaxTransport('iframe', function (options) { if (options.async) { // javascript:false as initial iframe src // prevents warning popups on HTTPS in IE6: @@ -56,7 +56,7 @@ iframe, addParamChar; return { - send: function(_, completeCallback) { + send: function (_, completeCallback) { form = $('<form style="display:none;"></form>'); form.attr('accept-charset', options.formAcceptCharset); addParamChar = /\?/.test(options.url) ? '&' : '?'; @@ -81,12 +81,12 @@ '" name="iframe-transport-' + counter + '"></iframe>' - ).bind('load', function() { + ).on('load', function () { var fileInputClones, paramNames = $.isArray(options.paramName) ? options.paramName : [options.paramName]; - iframe.unbind('load').bind('load', function() { + 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: @@ -109,7 +109,7 @@ $('<iframe src="' + initialIframeSrc + '"></iframe>').appendTo( form ); - window.setTimeout(function() { + window.setTimeout(function () { // Removing the form in a setTimeout call // allows Chrome's developer tools to display // the response result @@ -121,7 +121,7 @@ .prop('action', options.url) .prop('method', options.type); if (options.formData) { - $.each(options.formData, function(index, field) { + $.each(options.formData, function (index, field) { $('<input type="hidden"/>') .prop('name', field.name) .val(field.value) @@ -135,11 +135,11 @@ ) { fileInputClones = options.fileInput.clone(); // Insert a clone for each file input field: - options.fileInput.after(function(index) { + options.fileInput.after(function (index) { return fileInputClones[index]; }); if (options.paramName) { - options.fileInput.each(function(index) { + options.fileInput.each(function (index) { $(this).prop('name', paramNames[index] || options.paramName); }); } @@ -153,27 +153,33 @@ // 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); - }); - } + window.setTimeout(function () { + // Submitting the form in a setTimeout call fixes an issue with + // Safari 13 not triggering the iframe load event after resetting + // the load event handler, see also: + // https://github.com/blueimp/jQuery-File-Upload/issues/3633 + 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); + }); + } + }, 0); }); form.append(iframe).appendTo(document.body); }, - abort: function() { + abort: function () { if (iframe) { // javascript:false as iframe src aborts the request // and prevents warning popups on HTTPS in IE6. - iframe.unbind('load').prop('src', initialIframeSrc); + iframe.off('load').prop('src', initialIframeSrc); } if (form) { form.remove(); @@ -195,16 +201,16 @@ // https://github.com/blueimp/jQuery-File-Upload/wiki/Setup#content-type-negotiation $.ajaxSetup({ converters: { - 'iframe text': function(iframe) { + 'iframe text': function (iframe) { return iframe && $(iframe[0].body).text(); }, - 'iframe json': function(iframe) { + 'iframe json': function (iframe) { return iframe && jsonAPI[jsonParse]($(iframe[0].body).text()); }, - 'iframe html': function(iframe) { + 'iframe html': function (iframe) { return iframe && $(iframe[0].body).html(); }, - 'iframe xml': function(iframe) { + 'iframe xml': function (iframe) { var xmlDoc = iframe && iframe[0]; return xmlDoc && $.isXMLDoc(xmlDoc) ? xmlDoc @@ -213,7 +219,7 @@ $(xmlDoc.body).html() ); }, - 'iframe script': function(iframe) { + 'iframe script': function (iframe) { return iframe && $.globalEval($(iframe[0].body).text()); } } diff --git a/vendor/blueimp/jquery-file-upload/js/vendor/jquery.ui.widget.js b/vendor/blueimp/jquery-file-upload/js/vendor/jquery.ui.widget.js index 914b8ffb8..69096aaa3 100644 --- a/vendor/blueimp/jquery-file-upload/js/vendor/jquery.ui.widget.js +++ b/vendor/blueimp/jquery-file-upload/js/vendor/jquery.ui.widget.js @@ -1,28 +1,29 @@ -/*! jQuery UI - v1.12.1+CommonJS - 2018-02-10 +/*! jQuery UI - v1.12.1+0b7246b6eeadfa9e2696e22f3230f6452f8129dc - 2020-02-20 * http://jqueryui.com * Includes: widget.js * Copyright jQuery Foundation and other contributors; Licensed MIT */ -(function( factory ) { - if ( typeof define === "function" && define.amd ) { +/* 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" ) { - + define(['jquery'], factory); + } else if (typeof exports === 'object') { // Node/CommonJS - factory( require( "jquery" ) ); + factory(require('jquery')); } else { - // Browser globals - factory( jQuery ); + factory(window.jQuery); } -}(function( $ ) { +})(function ($) { + ('use strict'); $.ui = $.ui || {}; - var version = $.ui.version = "1.12.1"; - + $.ui.version = '1.12.1'; /*! * jQuery UI Widget 1.12.1 @@ -39,105 +40,111 @@ //>>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 ) { + $.cleanData = (function (orig) { + return function (elems) { var events, elem, i; - for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) { - try { - - // Only trigger remove when necessary to save time - events = $._data( elem, "events" ); - if ( events && events.remove ) { - $( elem ).triggerHandler( "remove" ); - } - - // Http://bugs.jquery.com/ticket/8235 - } catch ( e ) {} + // 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 ); + orig(elems); }; - } )( $.cleanData ); + })($.cleanData); - $.widget = function( name, base, prototype ) { + $.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; + var namespace = name.split('.')[0]; + name = name.split('.')[1]; + var fullName = namespace + '-' + name; - if ( !prototype ) { + if (!prototype) { prototype = base; base = $.Widget; } - if ( $.isArray( prototype ) ) { - prototype = $.extend.apply( null, [ {} ].concat( prototype ) ); + if ($.isArray(prototype)) { + prototype = $.extend.apply(null, [{}].concat(prototype)); } // Create selector for plugin - $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) { - return !!$.data( elem, fullName ); + $.expr.pseudos[fullName.toLowerCase()] = function (elem) { + return !!$.data(elem, fullName); }; - $[ namespace ] = $[ namespace ] || {}; - existingConstructor = $[ namespace ][ name ]; - constructor = $[ namespace ][ name ] = function( options, element ) { - + $[namespace] = $[namespace] || {}; + existingConstructor = $[namespace][name]; + constructor = $[namespace][name] = function (options, element) { // Allow instantiation without "new" keyword - if ( !this._createWidget ) { - return new constructor( options, element ); + 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 ); + if (arguments.length) { + this._createWidget(options, element); } }; // Extend with the existing constructor to carry over any static properties - $.extend( constructor, existingConstructor, { + $.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 ), + _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; + basePrototype.options = $.widget.extend({}, basePrototype.options); + $.each(prototype, function (prop, value) { + if (!$.isFunction(value)) { + proxiedPrototype[prop] = value; return; } - proxiedPrototype[ prop ] = ( function() { + proxiedPrototype[prop] = (function () { function _super() { - return base.prototype[ prop ].apply( this, arguments ); + return base.prototype[prop].apply(this, arguments); } - function _superApply( args ) { - return base.prototype[ prop ].apply( this, args ); + function _superApply(args) { + return base.prototype[prop].apply(this, args); } - return function() { + return function () { var __super = this._super; var __superApply = this._superApply; var returnValue; @@ -145,77 +152,87 @@ this._super = _super; this._superApply = _superApply; - returnValue = value.apply( this, arguments ); + 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 - } ); + })(); + }); + 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 ) { + 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 ); - } ); + $.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 ); + base._childConstructors.push(constructor); } - $.widget.bridge( name, constructor ); + $.widget.bridge(name, constructor); return constructor; }; - $.widget.extend = function( target ) { - var input = widgetSlice.call( arguments, 1 ); + $.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 ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) { - + 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 ); + 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; + target[key] = value; } } } @@ -223,81 +240,90 @@ return target; }; - $.widget.bridge = function( name, object ) { + $.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 ); + $.fn[name] = function (options) { + var isMethodCall = typeof options === 'string'; + var args = widgetSlice.call(arguments, 1); var returnValue = this; - if ( isMethodCall ) { - + 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" ) { + if (!this.length && options === 'instance') { returnValue = undefined; } else { - this.each( function() { + this.each(function () { var methodValue; - var instance = $.data( this, fullName ); + var instance = $.data(this, fullName); - if ( options === "instance" ) { + 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 (!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" ); + if (!$.isFunction(instance[options]) || options.charAt(0) === '_') { + return $.error( + "no such method '" + + options + + "' for " + + name + + ' widget instance' + ); } - methodValue = instance[ options ].apply( instance, args ); + methodValue = instance[options].apply(instance, args); - if ( methodValue !== instance && methodValue !== undefined ) { - returnValue = methodValue && methodValue.jquery ? - returnValue.pushStack( methodValue.get() ) : - methodValue; + 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 ) ); + 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 ) { + 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 ) ); + $.data(this, fullName, new object(options, this)); } - } ); + }); } return returnValue; }; }; - $.Widget = function( /* options, element */ ) {}; + $.Widget = function (/* options, element */) {}; $.Widget._childConstructors = []; $.Widget.prototype = { - widgetName: "widget", - widgetEventPrefix: "", - defaultElement: "<div>", + widgetName: 'widget', + widgetEventPrefix: '', + defaultElement: '<div>', options: { classes: {}, @@ -307,52 +333,56 @@ create: null }, - _createWidget: function( options, element ) { - element = $( element || this.defaultElement || this )[ 0 ]; - this.element = $( element ); + _createWidget: function (options, element) { + element = $(element || this.defaultElement || this)[0]; + this.element = $(element); this.uuid = widgetUuid++; - this.eventNamespace = "." + this.widgetName + this.uuid; + 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 ) { + 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.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 = $.widget.extend( + {}, this.options, this._getCreateOptions(), - options ); + options + ); this._create(); - if ( this.options.disabled ) { - this._setOptionDisabled( this.options.disabled ); + if (this.options.disabled) { + this._setOptionDisabled(this.options.disabled); } - this._trigger( "create", null, this._getCreateEventData() ); + this._trigger('create', null, this._getCreateEventData()); this._init(); }, - _getCreateOptions: function() { + _getCreateOptions: function () { return {}; }, @@ -362,107 +392,103 @@ _init: $.noop, - destroy: function() { + destroy: function () { var that = this; this._destroy(); - $.each( this.classesElementLookup, function( key, value ) { - that._removeClass( value, key ); - } ); + $.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" ); + 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 ); + this.bindings.off(this.eventNamespace); }, _destroy: $.noop, - widget: function() { + widget: function () { return this.element; }, - option: function( key, value ) { + option: function (key, value) { var options = key; var parts; var curOption; var i; - if ( arguments.length === 0 ) { - + if (arguments.length === 0) { // Don't return a reference to the internal hash - return $.widget.extend( {}, this.options ); + return $.widget.extend({}, this.options); } - if ( typeof key === "string" ) { - + if (typeof key === 'string') { // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } options = {}; - parts = key.split( "." ); + 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 ] ]; + 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 ]; + if (arguments.length === 1) { + return curOption[key] === undefined ? null : curOption[key]; } - curOption[ key ] = value; + curOption[key] = value; } else { - if ( arguments.length === 1 ) { - return this.options[ key ] === undefined ? null : this.options[ key ]; + if (arguments.length === 1) { + return this.options[key] === undefined ? null : this.options[key]; } - options[ key ] = value; + options[key] = value; } } - this._setOptions( options ); + this._setOptions(options); return this; }, - _setOptions: function( options ) { + _setOptions: function (options) { var key; - for ( key in options ) { - this._setOption( key, options[ key ] ); + for (key in options) { + this._setOption(key, options[key]); } return this; }, - _setOption: function( key, value ) { - if ( key === "classes" ) { - this._setOptionClasses( value ); + _setOption: function (key, value) { + if (key === 'classes') { + this._setOptionClasses(value); } - this.options[ key ] = value; + this.options[key] = value; - if ( key === "disabled" ) { - this._setOptionDisabled( value ); + if (key === 'disabled') { + this._setOptionDisabled(value); } return this; }, - _setOptionClasses: function( value ) { + _setOptionClasses: function (value) { var classKey, elements, currentElements; - for ( classKey in value ) { - currentElements = this.classesElementLookup[ classKey ]; - if ( value[ classKey ] === this.options.classes[ classKey ] || + for (classKey in value) { + currentElements = this.classesElementLookup[classKey]; + if ( + value[classKey] === this.options.classes[classKey] || !currentElements || - !currentElements.length ) { + !currentElements.length + ) { continue; } @@ -470,283 +496,313 @@ // 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 ); + 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 - } ) ); + elements.addClass( + this._classes({ + element: elements, + keys: classKey, + classes: value, + add: true + }) + ); } }, - _setOptionDisabled: function( value ) { - this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value ); + _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" ); + 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 } ); + enable: function () { + return this._setOptions({ disabled: false }); }, - disable: function() { - return this._setOptions( { disabled: true } ); + disable: function () { + return this._setOptions({ disabled: true }); }, - _classes: function( options ) { + _classes: function (options) { var full = []; var that = this; - options = $.extend( { - element: this.element, - classes: this.options.classes || {} - }, options ); + 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 ) { + function processClassString(classes, checkOption) { var current, i; - for ( i = 0; i < classes.length; i++ ) { - current = that.classesElementLookup[ classes[ i ] ] || $(); - if ( options.add ) { - current = $( $.unique( current.get().concat( options.element.get() ) ) ); + 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() ); + 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 ] ] ); + that.classesElementLookup[classes[i]] = current; + full.push(classes[i]); + if (checkOption && options.classes[classes[i]]) { + full.push(options.classes[classes[i]]); } } } - this._on( options.element, { - "remove": "_untrackClassesElement" - } ); - - if ( options.keys ) { - processClassString( options.keys.match( /\S+/g ) || [], true ); + if (options.keys) { + processClassString(options.keys.match(/\S+/g) || [], true); } - if ( options.extra ) { - processClassString( options.extra.match( /\S+/g ) || [] ); + if (options.extra) { + processClassString(options.extra.match(/\S+/g) || []); } - return full.join( " " ); + return full.join(' '); }, - _untrackClassesElement: function( event ) { + _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() ); + $.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 ); + _removeClass: function (element, keys, extra) { + return this._toggleClass(element, keys, extra, false); }, - _addClass: function( element, keys, extra ) { - return this._toggleClass( element, keys, extra, true ); + _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 ), + _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 ); + options.element.toggleClass(this._classes(options), add); return this; }, - _on: function( suppressDisabledCheck, element, handlers ) { + _on: function (suppressDisabledCheck, element, handlers) { var delegateElement; var instance = this; // No suppressDisabledCheck flag, shuffle arguments - if ( typeof suppressDisabledCheck !== "boolean" ) { + if (typeof suppressDisabledCheck !== 'boolean') { handlers = element; element = suppressDisabledCheck; suppressDisabledCheck = false; } // No element argument, shuffle and use this.element - if ( !handlers ) { + if (!handlers) { handlers = element; element = this.element; delegateElement = this.widget(); } else { - element = delegateElement = $( element ); - this.bindings = this.bindings.add( element ); + element = delegateElement = $(element); + this.bindings = this.bindings.add(element); } - $.each( handlers, function( event, handler ) { + $.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" ) ) ) { + if ( + !suppressDisabledCheck && + (instance.options.disabled === true || + $(this).hasClass('ui-state-disabled')) + ) { return; } - return ( typeof handler === "string" ? instance[ handler ] : handler ) - .apply( instance, arguments ); + return (typeof handler === 'string' + ? instance[handler] + : handler + ).apply(instance, arguments); } // Copy the guid so direct unbinding works - if ( typeof handler !== "string" ) { + 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 ]; + var match = event.match(/^([\w:-]*)\s*(.*)$/); + var eventName = match[1] + instance.eventNamespace; + var selector = match[2]; - if ( selector ) { - delegateElement.on( eventName, selector, handlerProxy ); + if (selector) { + delegateElement.on(eventName, selector, handlerProxy); } else { - element.on( eventName, handlerProxy ); + element.on(eventName, handlerProxy); } - } ); + }); }, - _off: function( element, eventName ) { - eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) + + _off: function (element, eventName) { + eventName = + (eventName || '').split(' ').join(this.eventNamespace + ' ') + this.eventNamespace; - element.off( eventName ).off( eventName ); + 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() ); + 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 ) { + _delay: function (handler, delay) { + var instance = this; function handlerProxy() { - return ( typeof handler === "string" ? instance[ handler ] : handler ) - .apply( instance, arguments ); + return (typeof handler === 'string' + ? instance[handler] + : handler + ).apply(instance, arguments); } - var instance = this; - return setTimeout( handlerProxy, delay || 0 ); + 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" ); + _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" ); + 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" ); + _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" ); + focusout: function (event) { + this._removeClass($(event.currentTarget), null, 'ui-state-focus'); } - } ); + }); }, - _trigger: function( type, event, data ) { + _trigger: function (type, event, data) { var prop, orig; - var callback = this.options[ type ]; + var callback = this.options[type]; data = data || {}; - event = $.Event( event ); - event.type = ( type === this.widgetEventPrefix ? - type : - this.widgetEventPrefix + type ).toLowerCase(); + 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 ]; + 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 ]; + 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() ); + 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" ) { + $.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; + var effectName = !options + ? method + : options === true || typeof options === 'number' + ? defaultEffect + : options.effect || defaultEffect; options = options || {}; - if ( typeof options === "number" ) { + if (typeof options === 'number') { options = { duration: options }; } - hasOptions = !$.isEmptyObject( options ); + hasOptions = !$.isEmptyObject(options); options.complete = callback; - if ( options.delay ) { - element.delay( options.delay ); + 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 ); + 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 ] ); + element.queue(function (next) { + $(this)[method](); + if (callback) { + callback.call(element[0]); } next(); - } ); + }); } }; - } ); - - var widget = $.widget; - - - - -})); + }); +}); |