[TASK] Cleanup TypeScript type defintions and editorconfig 21/56921/2
authorFrank Naegler <frank.naegler@typo3.org>
Fri, 11 May 2018 09:28:35 +0000 (11:28 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Fri, 11 May 2018 10:17:19 +0000 (12:17 +0200)
Resolves: #84969
Releases: master
Change-Id: I871656c436a9ded5c82fbade4a28d5bd5e84de26
Reviewed-on: https://review.typo3.org/56921
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
.editorconfig
Build/types/TYPO3/index.d.ts
typo3/sysext/backend/Resources/Private/TypeScript/DragUploader.ts
typo3/sysext/backend/Resources/Public/JavaScript/DragUploader.js

index 05494ee..4f03775 100644 (file)
@@ -30,7 +30,10 @@ indent_size = 4
 indent_style = space
 indent_size = 4
 
-# JS-Files
+# TS/JS-Files
+[*.ts]
+indent_style = space
+indent_size = 2
 [*.js]
 indent_style = space
 indent_size = 2
@@ -68,9 +71,6 @@ indent_style = space
 indent_size = 2
 
 # TypoScript
-[*.ts]
-indent_style = space
-indent_size = 2
 [*.typoscript]
 indent_style = space
 indent_size = 2
index 8c237bb..186f208 100644 (file)
@@ -39,7 +39,6 @@ declare namespace TBE_EDITOR {
 /**
  * Current AMD/RequireJS modules are returning *instances* of ad-hoc *classes*, make that known to TypeScript
  */
-
 declare module 'TYPO3/CMS/Backend/FormEngineValidation' {
   export = new TYPO3.CMS.Backend.FormEngineValidation();
 }
@@ -75,22 +74,6 @@ declare module 'TYPO3/CMS/Core/Contrib/imagesloaded.pkgd.min' {
 
 declare module 'cm/lib/codemirror';
 declare module 'moment';
-declare module 'TYPO3/CMS/Backend/jsfunc.inline';
-
-/**
- * Options for the plugin.
- * TODO fix this
- */
-interface DragUploaderOptions {
-  /**
-   * CSS selector for the element where generated messages are inserted. (required)
-   */
-  outputSelector: string;
-  /**
-   * Color of the message text. (optional)
-   */
-  outputColor?: string;
-}
 
 interface JQueryTypedEvent<T extends Event> extends JQueryEventObject {
   originalEvent: T;
@@ -101,11 +84,14 @@ interface JQueryTypedEvent<T extends Event> extends JQueryEventObject {
  */
 interface JQuery {
   clearable(options?: any): JQuery;
+
   datetimepicker(options?: any): JQuery;
-  dragUploader(options?: DragUploaderOptions): JQuery;
+
+  dragUploader(options?: any): JQuery;
 
   // To be able to use twbs/bootstrap-slider we have to override the definition of jquerui
   slider(options: { [key: string]: any }): any;
+
   // To be able to use jquery/autocomplete-slider we have to override the definition of jquerui
   autocomplete(options?: { [key: string]: any }): any;
 }
index c518749..09c7e29 100644 (file)
@@ -20,6 +20,7 @@ import moment = require('moment');
 import NProgress = require('nprogress');
 import Modal = require('./Modal');
 import Notification = require('./Notification');
+import 'TYPO3/CMS/Backend/jsfunc.inline';
 
 /**
  * Possible actions for conflicts w/ existing files
@@ -41,7 +42,7 @@ interface UploadedFile {
   uid: number;
   icon: string;
   extension: string;
-  permissions: {read: boolean; write: boolean};
+  permissions: { read: boolean; write: boolean };
   size: number;
   // formatted as ddmmyy
   date: string;
@@ -51,6 +52,17 @@ interface UploadedFile {
   type: string;
 }
 
+interface DragUploaderOptions {
+  /**
+   * CSS selector for the element where generated messages are inserted. (required)
+   */
+  outputSelector: string;
+  /**
+   * Color of the message text. (optional)
+   */
+  outputColor?: string;
+}
+
 class DragUploaderPlugin {
   public irreObjectUid: number;
   public $fileList: JQuery;
@@ -64,7 +76,7 @@ class DragUploaderPlugin {
   /**
    * Array of files which are asked for being overridden
    */
-  private askForOverride: Array<{original: UploadedFile, uploaded: File, action: Action}> = [];
+  private askForOverride: Array<{ original: UploadedFile, uploaded: File, action: Action }> = [];
 
   private percentagePerFile: number = 1;
 
@@ -302,7 +314,7 @@ class DragUploaderPlugin {
           url: TYPO3.settings.ajaxUrls.flashmessages_render,
           cache: false,
           success: (data) => {
-            $.each(data, (index: number, flashMessage: {title: string, message: string, severity: number}) => {
+            $.each(data, (index: number, flashMessage: { title: string, message: string, severity: number }) => {
               Notification.showMessage(flashMessage.title, flashMessage.message, flashMessage.severity);
             });
           }
@@ -394,7 +406,7 @@ class DragUploaderPlugin {
     );
 
     const uploader = this;
-    $modal.on('change', '.t3js-actions-all', function(this: HTMLInputElement): void {
+    $modal.on('change', '.t3js-actions-all', function (this: HTMLInputElement): void {
       const $this = $(this),
         value = $this.val();
 
@@ -409,11 +421,11 @@ class DragUploaderPlugin {
       } else {
         $modal.find('.t3js-actions').removeProp('disabled');
       }
-    }).on('change', '.t3js-actions', function(this: HTMLInputElement): void {
+    }).on('change', '.t3js-actions', function (this: HTMLInputElement): void {
       const $this = $(this),
         index = parseInt($this.data('override'), 10);
       uploader.askForOverride[index].action = <Action>$this.val();
-    }).on('button.clicked', function(this: HTMLInputElement, e: Event): void {
+    }).on('button.clicked', function (this: HTMLInputElement, e: Event): void {
       if ((<HTMLInputElement>(e.target)).name === 'cancel') {
         uploader.askForOverride = [];
         Modal.dismiss();
@@ -512,7 +524,7 @@ class FileQueueItem {
         data: formData,
         cache: false,
         type: 'POST',
-        success: (data: {upload?: UploadedFile[]}) => this.uploadSuccess(data),
+        success: (data: { upload?: UploadedFile[] }) => this.uploadSuccess(data),
         error: (response: XMLHttpRequest) => this.uploadError(response)
       });
 
@@ -578,7 +590,7 @@ class FileQueueItem {
   /**
    * @param {{upload?: UploadedFile[]}} data
    */
-  public uploadSuccess(data: {upload?: UploadedFile[]}): void {
+  public uploadSuccess(data: { upload?: UploadedFile[] }): void {
     if (data.upload) {
       this.dragUploader.decrementQueueLength();
       this.$row.removeClass('uploading');
@@ -727,7 +739,7 @@ interface DragUploaderFunction {
   (options: DragUploaderOptions): JQuery;
 }
 
-export const initialize = function(): void {
+export const initialize = function (): void {
   DragUploader.init();
 
   // load required modules to hook in the post initialize function
index ee6f795..d144b2e 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","./Enum/Severity","jquery","moment","nprogress","./Modal","./Notification"],function(e,t,i,r,a,o,s,n){"use strict";var l,d;Object.defineProperty(t,"__esModule",{value:!0}),(d=l||(l={})).OVERRIDE="replace",d.RENAME="rename",d.SKIP="cancel",d.USE_EXISTING="useExisting";var p=function(){function e(e){var t=this;this.askForOverride=[],this.percentagePerFile=1,this.dragFileIntoDocument=function(e){return e.stopPropagation(),e.preventDefault(),r(e.currentTarget).addClass("drop-in-progress"),t.showDropzone(),!1},this.dragAborted=function(e){return e.stopPropagation(),e.preventDefault(),r(e.currentTarget).removeClass("drop-in-progress"),!1},this.ignoreDrop=function(e){return e.stopPropagation(),e.preventDefault(),t.dragAborted(e),!1},this.handleDrop=function(e){t.ignoreDrop(e),t.processFiles(e.originalEvent.dataTransfer.files),t.$dropzone.removeClass("drop-status-ok")},this.fileInDropzone=function(){t.$dropzone.addClass("drop-status-ok")},this.fileOutOfDropzone=function(){t.$dropzone.removeClass("drop-status-ok")},this.$body=r("body"),this.$element=r(e);var i=void 0!==this.$element.data("dropzoneTrigger");this.$trigger=r(this.$element.data("dropzoneTrigger")),this.$dropzone=r("<div />").addClass("dropzone").hide(),this.irreObjectUid=this.$element.data("fileIrreObject");var a=this.$element.data("dropzoneTarget");this.irreObjectUid&&0!==this.$element.nextAll(a).length?(this.dropZoneInsertBefore=!0,this.$dropzone.insertBefore(a)):(this.dropZoneInsertBefore=!1,this.$dropzone.insertAfter(a)),this.$dropzoneMask=r("<div />").addClass("dropzone-mask").appendTo(this.$dropzone),this.fileInput=document.createElement("input"),this.fileInput.setAttribute("type","file"),this.fileInput.setAttribute("multiple","multiple"),this.fileInput.setAttribute("name","files[]"),this.fileInput.classList.add("upload-file-picker"),this.$body.append(this.fileInput),this.$fileList=r(this.$element.data("progress-container")),this.fileListColumnCount=r("thead tr:first th",this.$fileList).length,this.filesExtensionsAllowed=this.$element.data("file-allowed"),this.fileDenyPattern=this.$element.data("file-deny-pattern")?new RegExp(this.$element.data("file-deny-pattern"),"i"):null,this.maxFileSize=parseInt(this.$element.data("max-file-size"),10),this.target=this.$element.data("target-folder"),this.browserCapabilities={fileReader:"undefined"!=typeof FileReader,DnD:"draggable"in document.createElement("span"),Progress:"upload"in new XMLHttpRequest},this.browserCapabilities.DnD?(this.$body.on("dragover",this.dragFileIntoDocument),this.$body.on("dragend",this.dragAborted),this.$body.on("drop",this.ignoreDrop),this.$dropzone.on("dragenter",this.fileInDropzone),this.$dropzoneMask.on("dragenter",this.fileInDropzone),this.$dropzoneMask.on("dragleave",this.fileOutOfDropzone),this.$dropzoneMask.on("drop",function(e){return t.handleDrop(e)}),this.$dropzone.prepend('<div class="dropzone-hint"><div class="dropzone-hint-media"><div class="dropzone-hint-icon"></div></div><div class="dropzone-hint-body"><h3 class="dropzone-hint-title">'+TYPO3.lang["file_upload.dropzonehint.title"]+'</h3><p class="dropzone-hint-message">'+TYPO3.lang["file_upload.dropzonehint.message"]+"</p></div></div>").click(function(){t.fileInput.click()}),r("<span />").addClass("dropzone-close").click(this.hideDropzone).appendTo(this.$dropzone),0===this.$fileList.length&&(this.$fileList=r("<table />").attr("id","typo3-filelist").addClass("table table-striped table-hover upload-queue").html("<tbody></tbody>").hide(),this.dropZoneInsertBefore?this.$fileList.insertAfter(this.$dropzone):this.$fileList.insertBefore(this.$dropzone),this.fileListColumnCount=7),this.fileInput.addEventListener("change",function(){t.processFiles(Array.apply(null,t.fileInput.files))}),this.bindUploadButton(!0===i?this.$trigger:this.$element)):console.warn("Browser has no Drag and drop capabilities; cannot initialize DragUploader")}return e.prototype.showDropzone=function(){this.$dropzone.show()},e.prototype.hideDropzone=function(e){e.stopPropagation(),e.preventDefault(),this.$dropzone.hide()},e.prototype.processFiles=function(e){var t=this;this.queueLength=e.length,this.$fileList.is(":visible")||this.$fileList.show(),o.start(),this.percentagePerFile=1/e.length;var i=[];r.each(e,function(e,a){i[parseInt(e,10)]=r.ajax({url:TYPO3.settings.ajaxUrls.file_exists,data:{fileName:a.name,fileTarget:t.target},cache:!1,success:function(e){if(void 0!==e.uid)t.askForOverride.push({original:e,uploaded:a,action:t.irreObjectUid?l.USE_EXISTING:l.SKIP}),o.inc(t.percentagePerFile);else new h(t,a,l.SKIP)}})}),r.when.apply(r,i).done(function(){t.drawOverrideModal(),o.done()}),this.fileInput.value=""},e.prototype.bindUploadButton=function(e){var t=this;e.click(function(e){e.preventDefault(),t.fileInput.click(),t.showDropzone()})},e.prototype.decrementQueueLength=function(){this.queueLength>0&&(this.queueLength--,0===this.queueLength&&r.ajax({url:TYPO3.settings.ajaxUrls.flashmessages_render,cache:!1,success:function(e){r.each(e,function(e,t){n.showMessage(t.title,t.message,t.severity)})}}))},e.prototype.drawOverrideModal=function(){var e=this,t=Object.keys(this.askForOverride).length;if(0!==t){for(var o=r("<div/>").append(r("<p/>").text(TYPO3.lang["file_upload.existingfiles.description"]),r("<table/>",{class:"table"}).append(r("<thead/>").append(r("<tr />").append(r("<th/>"),r("<th/>").text(TYPO3.lang["file_upload.header.originalFile"]),r("<th/>").text(TYPO3.lang["file_upload.header.uploadedFile"]),r("<th/>").text(TYPO3.lang["file_upload.header.action"]))))),n=0;n<t;++n){var d=r("<tr />").append(r("<td />").append(""!==this.askForOverride[n].original.thumbUrl?r("<img />",{src:this.askForOverride[n].original.thumbUrl,height:40}):r(this.askForOverride[n].original.icon)),r("<td />").html(this.askForOverride[n].uploaded.name+" ("+u.fileSizeAsString(this.askForOverride[n].uploaded.size)+")<br>"+a(this.askForOverride[n].uploaded.lastModifiedDate,"x").format("YYYY-MM-DD HH:mm")),r("<td />").html(this.askForOverride[n].uploaded.name+" ("+u.fileSizeAsString(this.askForOverride[n].original.size)+")<br>"+a(this.askForOverride[n].original.mtime,"X").format("YYYY-MM-DD HH:mm")),r("<td />").append(r("<select />",{class:"form-control t3js-actions","data-override":n}).append(this.irreObjectUid?r("<option/>").val(l.USE_EXISTING).text(TYPO3.lang["file_upload.actions.use_existing"]):"",r("<option />").val(l.SKIP).text(TYPO3.lang["file_upload.actions.skip"]),r("<option />").val(l.RENAME).text(TYPO3.lang["file_upload.actions.rename"]),r("<option />").val(l.OVERRIDE).text(TYPO3.lang["file_upload.actions.override"]))));o.find("table").append("<tbody />").append(d)}var p=s.confirm(TYPO3.lang["file_upload.existingfiles.title"],o,i.SeverityEnum.warning,[{text:r(this).data("button-close-text")||TYPO3.lang["file_upload.button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:r(this).data("button-ok-text")||TYPO3.lang["file_upload.button.continue"]||"Continue with selected actions",btnClass:"btn-warning",name:"continue"}],["modal-inner-scroll"]);p.find(".modal-dialog").addClass("modal-lg"),p.find(".modal-footer").prepend(r("<span/>").addClass("form-inline").append(r("<label/>").text(TYPO3.lang["file_upload.actions.all.label"]),r("<select/>",{class:"form-control t3js-actions-all"}).append(r("<option/>").val("").text(TYPO3.lang["file_upload.actions.all.empty"]),this.irreObjectUid?r("<option/>").val(l.USE_EXISTING).text(TYPO3.lang["file_upload.actions.all.use_existing"]):"",r("<option/>").val(l.SKIP).text(TYPO3.lang["file_upload.actions.all.skip"]),r("<option/>").val(l.RENAME).text(TYPO3.lang["file_upload.actions.all.rename"]),r("<option/>").val(l.OVERRIDE).text(TYPO3.lang["file_upload.actions.all.override"]))));var g=this;p.on("change",".t3js-actions-all",function(){var e=r(this).val();""!==e?p.find(".t3js-actions").each(function(t,i){var a=r(i),o=parseInt(a.data("override"),10);a.val(e).prop("disabled","disabled"),g.askForOverride[o].action=a.val()}):p.find(".t3js-actions").removeProp("disabled")}).on("change",".t3js-actions",function(){var e=r(this),t=parseInt(e.data("override"),10);g.askForOverride[t].action=e.val()}).on("button.clicked",function(e){"cancel"===e.target.name?(g.askForOverride=[],s.dismiss()):"continue"===e.target.name&&(r.each(g.askForOverride,function(e,t){if(t.action===l.USE_EXISTING)u.addFileToIrre(g.irreObjectUid,t.original);else if(t.action!==l.SKIP)new h(g,t.uploaded,t.action)}),g.askForOverride=[],s.dismiss())}).on("hidden.bs.modal",function(){e.askForOverride=[]})}},e}(),h=function(){function e(e,t,i){var a=this;if(this.dragUploader=e,this.file=t,this.override=i,this.$row=r("<tr />").addClass("upload-queue-item uploading"),this.$iconCol=r("<td />").addClass("col-icon").appendTo(this.$row),this.$fileName=r("<td />").text(t.name).appendTo(this.$row),this.$progress=r("<td />").attr("colspan",this.dragUploader.fileListColumnCount-2).appendTo(this.$row),this.$progressContainer=r("<div />").addClass("upload-queue-progress").appendTo(this.$progress),this.$progressBar=r("<div />").addClass("upload-queue-progress-bar").appendTo(this.$progressContainer),this.$progressPercentage=r("<span />").addClass("upload-queue-progress-percentage").appendTo(this.$progressContainer),this.$progressMessage=r("<span />").addClass("upload-queue-progress-message").appendTo(this.$progressContainer),0===r("tbody tr.upload-queue-item",this.dragUploader.$fileList).length?(this.$row.prependTo(r("tbody",this.dragUploader.$fileList)),this.$row.addClass("last")):this.$row.insertBefore(r("tbody tr.upload-queue-item:first",this.dragUploader.$fileList)),this.$iconCol.html('<span class="t3-icon t3-icon-mimetypes t3-icon-other-other">&nbsp;</span>'),this.dragUploader.maxFileSize>0&&this.file.size>this.dragUploader.maxFileSize)this.updateMessage(TYPO3.lang["file_upload.maxFileSizeExceeded"].replace(/\{0\}/g,this.file.name).replace(/\{1\}/g,u.fileSizeAsString(this.dragUploader.maxFileSize))),this.$row.addClass("error");else if(this.dragUploader.fileDenyPattern&&this.file.name.match(this.dragUploader.fileDenyPattern))this.updateMessage(TYPO3.lang["file_upload.fileNotAllowed"].replace(/\{0\}/g,this.file.name)),this.$row.addClass("error");else if(this.checkAllowedExtensions()){this.updateMessage("- "+u.fileSizeAsString(this.file.size));var o=new FormData;o.append("data[upload][1][target]",this.dragUploader.target),o.append("data[upload][1][data]","1"),o.append("overwriteExistingFiles",this.override),o.append("redirect",""),o.append("upload_1",this.file);var s=r.extend(!0,{},r.ajaxSettings,{url:TYPO3.settings.ajaxUrls.file_process,contentType:!1,processData:!1,data:o,cache:!1,type:"POST",success:function(e){return a.uploadSuccess(e)},error:function(e){return a.uploadError(e)}});s.xhr=function(){var e=r.ajaxSettings.xhr();return e.upload.addEventListener("progress",function(e){return a.updateProgress(e)}),e},this.upload=r.ajax(s)}else this.updateMessage(TYPO3.lang["file_upload.fileExtensionExpected"].replace(/\{0\}/g,this.dragUploader.filesExtensionsAllowed)),this.$row.addClass("error")}return e.prototype.updateMessage=function(e){this.$progressMessage.text(e)},e.prototype.removeProgress=function(){this.$progress&&this.$progress.remove()},e.prototype.uploadStart=function(){this.$progressPercentage.text("(0%)"),this.$progressBar.width("1%"),this.dragUploader.$trigger.trigger("uploadStart",[this])},e.prototype.uploadError=function(e){this.updateMessage(TYPO3.lang["file_upload.uploadFailed"].replace(/\{0\}/g,this.file.name));var t=r(e.responseText);t.is("t3err")?this.$progressPercentage.text(t.text()):this.$progressPercentage.text("("+e.statusText+")"),this.$row.addClass("error"),this.dragUploader.decrementQueueLength(),this.dragUploader.$trigger.trigger("uploadError",[this,e])},e.prototype.updateProgress=function(e){var t=Math.round(e.loaded/e.total*100)+"%";this.$progressBar.outerWidth(t),this.$progressPercentage.text(t),this.dragUploader.$trigger.trigger("updateProgress",[this,t,e])},e.prototype.uploadSuccess=function(e){var t=this;e.upload&&(this.dragUploader.decrementQueueLength(),this.$row.removeClass("uploading"),this.$fileName.text(e.upload[0].name),this.$progressPercentage.text(""),this.$progressMessage.text("100%"),this.$progressBar.outerWidth("100%"),e.upload[0].icon&&this.$iconCol.html('<a href="#" class="t3js-contextmenutrigger" data-uid="'+e.upload[0].id+'" data-table="sys_file">'+e.upload[0].icon+"&nbsp;</span></a>"),this.dragUploader.irreObjectUid?(u.addFileToIrre(this.dragUploader.irreObjectUid,e.upload[0]),setTimeout(function(){t.$row.remove(),0===r("tr",t.dragUploader.$fileList).length&&(t.dragUploader.$fileList.hide(),t.dragUploader.$trigger.trigger("uploadSuccess",[t,e]))},3e3)):setTimeout(function(){t.showFileInfo(e.upload[0]),t.dragUploader.$trigger.trigger("uploadSuccess",[t,e])},3e3))},e.prototype.showFileInfo=function(e){this.removeProgress();for(var t=7;t<this.dragUploader.fileListColumnCount;t++)r("<td />").text("").appendTo(this.$row);r("<td />").text(e.extension.toUpperCase()).appendTo(this.$row),r("<td />").text(e.date).appendTo(this.$row),r("<td />").text(u.fileSizeAsString(e.size)).appendTo(this.$row);var i="";e.permissions.read&&(i+='<strong class="text-danger">'+TYPO3.lang["permissions.read"]+"</strong>"),e.permissions.write&&(i+='<strong class="text-danger">'+TYPO3.lang["permissions.write"]+"</strong>"),r("<td />").html(i).appendTo(this.$row),r("<td />").text("-").appendTo(this.$row)},e.prototype.checkAllowedExtensions=function(){if(!this.dragUploader.filesExtensionsAllowed)return!0;var e=this.file.name.split(".").pop(),t=this.dragUploader.filesExtensionsAllowed.split(",");return-1!==r.inArray(e.toLowerCase(),t)},e}(),u=function(){function e(){}return e.fileSizeAsString=function(e){var t=e/1024;return t>1024?(t/1024).toFixed(1)+" MB":t.toFixed(1)+" KB"},e.addFileToIrre=function(e,t){window.inline.delayedImportElement(e,"sys_file",t.uid,"file")},e.init=function(){var e=this.options;r.fn.extend({dragUploader:function(e){return this.each(function(t,i){var a=r(i),o=a.data("DragUploaderPlugin");o||a.data("DragUploaderPlugin",o=new p(i)),"string"==typeof e&&o[e]()})}}),r(function(){r(".t3js-drag-uploader").dragUploader(e)})},e}();t.initialize=function(){u.init(),void 0!==TYPO3.settings&&void 0!==TYPO3.settings.RequireJS&&void 0!==TYPO3.settings.RequireJS.PostInitializationModules&&void 0!==TYPO3.settings.RequireJS.PostInitializationModules["TYPO3/CMS/Backend/DragUploader"]&&r.each(TYPO3.settings.RequireJS.PostInitializationModules["TYPO3/CMS/Backend/DragUploader"],function(t,i){e([i])})},t.initialize()});
\ No newline at end of file
+define(["require","exports","./Enum/Severity","jquery","moment","nprogress","./Modal","./Notification","TYPO3/CMS/Backend/jsfunc.inline"],function(e,t,i,r,a,o,s,n){"use strict";var l,d;Object.defineProperty(t,"__esModule",{value:!0}),(d=l||(l={})).OVERRIDE="replace",d.RENAME="rename",d.SKIP="cancel",d.USE_EXISTING="useExisting";var p=function(){function e(e){var t=this;this.askForOverride=[],this.percentagePerFile=1,this.dragFileIntoDocument=function(e){return e.stopPropagation(),e.preventDefault(),r(e.currentTarget).addClass("drop-in-progress"),t.showDropzone(),!1},this.dragAborted=function(e){return e.stopPropagation(),e.preventDefault(),r(e.currentTarget).removeClass("drop-in-progress"),!1},this.ignoreDrop=function(e){return e.stopPropagation(),e.preventDefault(),t.dragAborted(e),!1},this.handleDrop=function(e){t.ignoreDrop(e),t.processFiles(e.originalEvent.dataTransfer.files),t.$dropzone.removeClass("drop-status-ok")},this.fileInDropzone=function(){t.$dropzone.addClass("drop-status-ok")},this.fileOutOfDropzone=function(){t.$dropzone.removeClass("drop-status-ok")},this.$body=r("body"),this.$element=r(e);var i=void 0!==this.$element.data("dropzoneTrigger");this.$trigger=r(this.$element.data("dropzoneTrigger")),this.$dropzone=r("<div />").addClass("dropzone").hide(),this.irreObjectUid=this.$element.data("fileIrreObject");var a=this.$element.data("dropzoneTarget");this.irreObjectUid&&0!==this.$element.nextAll(a).length?(this.dropZoneInsertBefore=!0,this.$dropzone.insertBefore(a)):(this.dropZoneInsertBefore=!1,this.$dropzone.insertAfter(a)),this.$dropzoneMask=r("<div />").addClass("dropzone-mask").appendTo(this.$dropzone),this.fileInput=document.createElement("input"),this.fileInput.setAttribute("type","file"),this.fileInput.setAttribute("multiple","multiple"),this.fileInput.setAttribute("name","files[]"),this.fileInput.classList.add("upload-file-picker"),this.$body.append(this.fileInput),this.$fileList=r(this.$element.data("progress-container")),this.fileListColumnCount=r("thead tr:first th",this.$fileList).length,this.filesExtensionsAllowed=this.$element.data("file-allowed"),this.fileDenyPattern=this.$element.data("file-deny-pattern")?new RegExp(this.$element.data("file-deny-pattern"),"i"):null,this.maxFileSize=parseInt(this.$element.data("max-file-size"),10),this.target=this.$element.data("target-folder"),this.browserCapabilities={fileReader:"undefined"!=typeof FileReader,DnD:"draggable"in document.createElement("span"),Progress:"upload"in new XMLHttpRequest},this.browserCapabilities.DnD?(this.$body.on("dragover",this.dragFileIntoDocument),this.$body.on("dragend",this.dragAborted),this.$body.on("drop",this.ignoreDrop),this.$dropzone.on("dragenter",this.fileInDropzone),this.$dropzoneMask.on("dragenter",this.fileInDropzone),this.$dropzoneMask.on("dragleave",this.fileOutOfDropzone),this.$dropzoneMask.on("drop",function(e){return t.handleDrop(e)}),this.$dropzone.prepend('<div class="dropzone-hint"><div class="dropzone-hint-media"><div class="dropzone-hint-icon"></div></div><div class="dropzone-hint-body"><h3 class="dropzone-hint-title">'+TYPO3.lang["file_upload.dropzonehint.title"]+'</h3><p class="dropzone-hint-message">'+TYPO3.lang["file_upload.dropzonehint.message"]+"</p></div></div>").click(function(){t.fileInput.click()}),r("<span />").addClass("dropzone-close").click(this.hideDropzone).appendTo(this.$dropzone),0===this.$fileList.length&&(this.$fileList=r("<table />").attr("id","typo3-filelist").addClass("table table-striped table-hover upload-queue").html("<tbody></tbody>").hide(),this.dropZoneInsertBefore?this.$fileList.insertAfter(this.$dropzone):this.$fileList.insertBefore(this.$dropzone),this.fileListColumnCount=7),this.fileInput.addEventListener("change",function(){t.processFiles(Array.apply(null,t.fileInput.files))}),this.bindUploadButton(!0===i?this.$trigger:this.$element)):console.warn("Browser has no Drag and drop capabilities; cannot initialize DragUploader")}return e.prototype.showDropzone=function(){this.$dropzone.show()},e.prototype.hideDropzone=function(e){e.stopPropagation(),e.preventDefault(),this.$dropzone.hide()},e.prototype.processFiles=function(e){var t=this;this.queueLength=e.length,this.$fileList.is(":visible")||this.$fileList.show(),o.start(),this.percentagePerFile=1/e.length;var i=[];r.each(e,function(e,a){i[parseInt(e,10)]=r.ajax({url:TYPO3.settings.ajaxUrls.file_exists,data:{fileName:a.name,fileTarget:t.target},cache:!1,success:function(e){if(void 0!==e.uid)t.askForOverride.push({original:e,uploaded:a,action:t.irreObjectUid?l.USE_EXISTING:l.SKIP}),o.inc(t.percentagePerFile);else new h(t,a,l.SKIP)}})}),r.when.apply(r,i).done(function(){t.drawOverrideModal(),o.done()}),this.fileInput.value=""},e.prototype.bindUploadButton=function(e){var t=this;e.click(function(e){e.preventDefault(),t.fileInput.click(),t.showDropzone()})},e.prototype.decrementQueueLength=function(){this.queueLength>0&&(this.queueLength--,0===this.queueLength&&r.ajax({url:TYPO3.settings.ajaxUrls.flashmessages_render,cache:!1,success:function(e){r.each(e,function(e,t){n.showMessage(t.title,t.message,t.severity)})}}))},e.prototype.drawOverrideModal=function(){var e=this,t=Object.keys(this.askForOverride).length;if(0!==t){for(var o=r("<div/>").append(r("<p/>").text(TYPO3.lang["file_upload.existingfiles.description"]),r("<table/>",{class:"table"}).append(r("<thead/>").append(r("<tr />").append(r("<th/>"),r("<th/>").text(TYPO3.lang["file_upload.header.originalFile"]),r("<th/>").text(TYPO3.lang["file_upload.header.uploadedFile"]),r("<th/>").text(TYPO3.lang["file_upload.header.action"]))))),n=0;n<t;++n){var d=r("<tr />").append(r("<td />").append(""!==this.askForOverride[n].original.thumbUrl?r("<img />",{src:this.askForOverride[n].original.thumbUrl,height:40}):r(this.askForOverride[n].original.icon)),r("<td />").html(this.askForOverride[n].uploaded.name+" ("+u.fileSizeAsString(this.askForOverride[n].uploaded.size)+")<br>"+a(this.askForOverride[n].uploaded.lastModifiedDate,"x").format("YYYY-MM-DD HH:mm")),r("<td />").html(this.askForOverride[n].uploaded.name+" ("+u.fileSizeAsString(this.askForOverride[n].original.size)+")<br>"+a(this.askForOverride[n].original.mtime,"X").format("YYYY-MM-DD HH:mm")),r("<td />").append(r("<select />",{class:"form-control t3js-actions","data-override":n}).append(this.irreObjectUid?r("<option/>").val(l.USE_EXISTING).text(TYPO3.lang["file_upload.actions.use_existing"]):"",r("<option />").val(l.SKIP).text(TYPO3.lang["file_upload.actions.skip"]),r("<option />").val(l.RENAME).text(TYPO3.lang["file_upload.actions.rename"]),r("<option />").val(l.OVERRIDE).text(TYPO3.lang["file_upload.actions.override"]))));o.find("table").append("<tbody />").append(d)}var p=s.confirm(TYPO3.lang["file_upload.existingfiles.title"],o,i.SeverityEnum.warning,[{text:r(this).data("button-close-text")||TYPO3.lang["file_upload.button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:r(this).data("button-ok-text")||TYPO3.lang["file_upload.button.continue"]||"Continue with selected actions",btnClass:"btn-warning",name:"continue"}],["modal-inner-scroll"]);p.find(".modal-dialog").addClass("modal-lg"),p.find(".modal-footer").prepend(r("<span/>").addClass("form-inline").append(r("<label/>").text(TYPO3.lang["file_upload.actions.all.label"]),r("<select/>",{class:"form-control t3js-actions-all"}).append(r("<option/>").val("").text(TYPO3.lang["file_upload.actions.all.empty"]),this.irreObjectUid?r("<option/>").val(l.USE_EXISTING).text(TYPO3.lang["file_upload.actions.all.use_existing"]):"",r("<option/>").val(l.SKIP).text(TYPO3.lang["file_upload.actions.all.skip"]),r("<option/>").val(l.RENAME).text(TYPO3.lang["file_upload.actions.all.rename"]),r("<option/>").val(l.OVERRIDE).text(TYPO3.lang["file_upload.actions.all.override"]))));var g=this;p.on("change",".t3js-actions-all",function(){var e=r(this).val();""!==e?p.find(".t3js-actions").each(function(t,i){var a=r(i),o=parseInt(a.data("override"),10);a.val(e).prop("disabled","disabled"),g.askForOverride[o].action=a.val()}):p.find(".t3js-actions").removeProp("disabled")}).on("change",".t3js-actions",function(){var e=r(this),t=parseInt(e.data("override"),10);g.askForOverride[t].action=e.val()}).on("button.clicked",function(e){"cancel"===e.target.name?(g.askForOverride=[],s.dismiss()):"continue"===e.target.name&&(r.each(g.askForOverride,function(e,t){if(t.action===l.USE_EXISTING)u.addFileToIrre(g.irreObjectUid,t.original);else if(t.action!==l.SKIP)new h(g,t.uploaded,t.action)}),g.askForOverride=[],s.dismiss())}).on("hidden.bs.modal",function(){e.askForOverride=[]})}},e}(),h=function(){function e(e,t,i){var a=this;if(this.dragUploader=e,this.file=t,this.override=i,this.$row=r("<tr />").addClass("upload-queue-item uploading"),this.$iconCol=r("<td />").addClass("col-icon").appendTo(this.$row),this.$fileName=r("<td />").text(t.name).appendTo(this.$row),this.$progress=r("<td />").attr("colspan",this.dragUploader.fileListColumnCount-2).appendTo(this.$row),this.$progressContainer=r("<div />").addClass("upload-queue-progress").appendTo(this.$progress),this.$progressBar=r("<div />").addClass("upload-queue-progress-bar").appendTo(this.$progressContainer),this.$progressPercentage=r("<span />").addClass("upload-queue-progress-percentage").appendTo(this.$progressContainer),this.$progressMessage=r("<span />").addClass("upload-queue-progress-message").appendTo(this.$progressContainer),0===r("tbody tr.upload-queue-item",this.dragUploader.$fileList).length?(this.$row.prependTo(r("tbody",this.dragUploader.$fileList)),this.$row.addClass("last")):this.$row.insertBefore(r("tbody tr.upload-queue-item:first",this.dragUploader.$fileList)),this.$iconCol.html('<span class="t3-icon t3-icon-mimetypes t3-icon-other-other">&nbsp;</span>'),this.dragUploader.maxFileSize>0&&this.file.size>this.dragUploader.maxFileSize)this.updateMessage(TYPO3.lang["file_upload.maxFileSizeExceeded"].replace(/\{0\}/g,this.file.name).replace(/\{1\}/g,u.fileSizeAsString(this.dragUploader.maxFileSize))),this.$row.addClass("error");else if(this.dragUploader.fileDenyPattern&&this.file.name.match(this.dragUploader.fileDenyPattern))this.updateMessage(TYPO3.lang["file_upload.fileNotAllowed"].replace(/\{0\}/g,this.file.name)),this.$row.addClass("error");else if(this.checkAllowedExtensions()){this.updateMessage("- "+u.fileSizeAsString(this.file.size));var o=new FormData;o.append("data[upload][1][target]",this.dragUploader.target),o.append("data[upload][1][data]","1"),o.append("overwriteExistingFiles",this.override),o.append("redirect",""),o.append("upload_1",this.file);var s=r.extend(!0,{},r.ajaxSettings,{url:TYPO3.settings.ajaxUrls.file_process,contentType:!1,processData:!1,data:o,cache:!1,type:"POST",success:function(e){return a.uploadSuccess(e)},error:function(e){return a.uploadError(e)}});s.xhr=function(){var e=r.ajaxSettings.xhr();return e.upload.addEventListener("progress",function(e){return a.updateProgress(e)}),e},this.upload=r.ajax(s)}else this.updateMessage(TYPO3.lang["file_upload.fileExtensionExpected"].replace(/\{0\}/g,this.dragUploader.filesExtensionsAllowed)),this.$row.addClass("error")}return e.prototype.updateMessage=function(e){this.$progressMessage.text(e)},e.prototype.removeProgress=function(){this.$progress&&this.$progress.remove()},e.prototype.uploadStart=function(){this.$progressPercentage.text("(0%)"),this.$progressBar.width("1%"),this.dragUploader.$trigger.trigger("uploadStart",[this])},e.prototype.uploadError=function(e){this.updateMessage(TYPO3.lang["file_upload.uploadFailed"].replace(/\{0\}/g,this.file.name));var t=r(e.responseText);t.is("t3err")?this.$progressPercentage.text(t.text()):this.$progressPercentage.text("("+e.statusText+")"),this.$row.addClass("error"),this.dragUploader.decrementQueueLength(),this.dragUploader.$trigger.trigger("uploadError",[this,e])},e.prototype.updateProgress=function(e){var t=Math.round(e.loaded/e.total*100)+"%";this.$progressBar.outerWidth(t),this.$progressPercentage.text(t),this.dragUploader.$trigger.trigger("updateProgress",[this,t,e])},e.prototype.uploadSuccess=function(e){var t=this;e.upload&&(this.dragUploader.decrementQueueLength(),this.$row.removeClass("uploading"),this.$fileName.text(e.upload[0].name),this.$progressPercentage.text(""),this.$progressMessage.text("100%"),this.$progressBar.outerWidth("100%"),e.upload[0].icon&&this.$iconCol.html('<a href="#" class="t3js-contextmenutrigger" data-uid="'+e.upload[0].id+'" data-table="sys_file">'+e.upload[0].icon+"&nbsp;</span></a>"),this.dragUploader.irreObjectUid?(u.addFileToIrre(this.dragUploader.irreObjectUid,e.upload[0]),setTimeout(function(){t.$row.remove(),0===r("tr",t.dragUploader.$fileList).length&&(t.dragUploader.$fileList.hide(),t.dragUploader.$trigger.trigger("uploadSuccess",[t,e]))},3e3)):setTimeout(function(){t.showFileInfo(e.upload[0]),t.dragUploader.$trigger.trigger("uploadSuccess",[t,e])},3e3))},e.prototype.showFileInfo=function(e){this.removeProgress();for(var t=7;t<this.dragUploader.fileListColumnCount;t++)r("<td />").text("").appendTo(this.$row);r("<td />").text(e.extension.toUpperCase()).appendTo(this.$row),r("<td />").text(e.date).appendTo(this.$row),r("<td />").text(u.fileSizeAsString(e.size)).appendTo(this.$row);var i="";e.permissions.read&&(i+='<strong class="text-danger">'+TYPO3.lang["permissions.read"]+"</strong>"),e.permissions.write&&(i+='<strong class="text-danger">'+TYPO3.lang["permissions.write"]+"</strong>"),r("<td />").html(i).appendTo(this.$row),r("<td />").text("-").appendTo(this.$row)},e.prototype.checkAllowedExtensions=function(){if(!this.dragUploader.filesExtensionsAllowed)return!0;var e=this.file.name.split(".").pop(),t=this.dragUploader.filesExtensionsAllowed.split(",");return-1!==r.inArray(e.toLowerCase(),t)},e}(),u=function(){function e(){}return e.fileSizeAsString=function(e){var t=e/1024;return t>1024?(t/1024).toFixed(1)+" MB":t.toFixed(1)+" KB"},e.addFileToIrre=function(e,t){window.inline.delayedImportElement(e,"sys_file",t.uid,"file")},e.init=function(){var e=this.options;r.fn.extend({dragUploader:function(e){return this.each(function(t,i){var a=r(i),o=a.data("DragUploaderPlugin");o||a.data("DragUploaderPlugin",o=new p(i)),"string"==typeof e&&o[e]()})}}),r(function(){r(".t3js-drag-uploader").dragUploader(e)})},e}();t.initialize=function(){u.init(),void 0!==TYPO3.settings&&void 0!==TYPO3.settings.RequireJS&&void 0!==TYPO3.settings.RequireJS.PostInitializationModules&&void 0!==TYPO3.settings.RequireJS.PostInitializationModules["TYPO3/CMS/Backend/DragUploader"]&&r.each(TYPO3.settings.RequireJS.PostInitializationModules["TYPO3/CMS/Backend/DragUploader"],function(t,i){e([i])})},t.initialize()});
\ No newline at end of file