[TASK] Migrate Modal to TypeScript 47/55847/10
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Tue, 20 Feb 2018 21:56:24 +0000 (22:56 +0100)
committerBenni Mack <benni@typo3.org>
Mon, 26 Feb 2018 16:49:09 +0000 (17:49 +0100)
Change-Id: Ic71a3dde434402ad828e2098eefae80f4039475b
Resolves: #82596
Releases: master
Reviewed-on: https://review.typo3.org/55847
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
15 files changed:
Build/types/TYPO3/index.d.ts
typo3/sysext/backend/Resources/Private/TypeScript/DragUploader.ts
typo3/sysext/backend/Resources/Private/TypeScript/GridEditor.ts
typo3/sysext/backend/Resources/Private/TypeScript/ImageManipulation.ts
typo3/sysext/backend/Resources/Private/TypeScript/InfoWindow.ts
typo3/sysext/backend/Resources/Private/TypeScript/Modal.ts [new file with mode: 0644]
typo3/sysext/backend/Resources/Private/TypeScript/RenameFile.ts
typo3/sysext/backend/Resources/Private/TypeScript/Wizard/NewContentElement.ts
typo3/sysext/backend/Resources/Public/JavaScript/DragUploader.js
typo3/sysext/backend/Resources/Public/JavaScript/GridEditor.js
typo3/sysext/backend/Resources/Public/JavaScript/ImageManipulation.js
typo3/sysext/backend/Resources/Public/JavaScript/InfoWindow.js
typo3/sysext/backend/Resources/Public/JavaScript/Modal.js
typo3/sysext/backend/Resources/Public/JavaScript/RenameFile.js
typo3/sysext/backend/Resources/Public/JavaScript/Wizard/NewContentElement.js

index 50e9f1c..1fff037 100644 (file)
@@ -10,6 +10,7 @@ declare namespace TYPO3 {
   export let InfoWindow: any;
   export let ModuleMenu: any;
   export let Notification: any;
+  export let Modal: any;
   export let Popover: any;
   export let Severity: any;
   export let ShortcutMenu: any;
@@ -25,16 +26,6 @@ declare namespace TYPO3 {
       export class FormEngine {
         public readonly Validation: FormEngineValidation;
       }
-      export class Modal {
-        public readonly sizes: {[key: string]: string};
-        public readonly styles: {[key: string]: string};
-        public readonly types: {[key: string]: string};
-        public currentModal: JQuery;
-        public advanced(configuration: object): any;
-        public confirm(title: string, content: any, severity: number, buttons: any[], additionalCssClasses?: string[]): JQuery; // tslint:disable-line:max-line-length
-        public show(title: string, content: any, severity: number, buttons: any[], additionalCssClasses?: string[]): JQuery; // tslint:disable-line:max-line-length
-        public dismiss(): void;
-      }
     }
   }
 }
@@ -51,10 +42,6 @@ declare module 'TYPO3/CMS/Backend/FormEngine' {
   export = new TYPO3.CMS.Backend.FormEngine();
 }
 
-declare module 'TYPO3/CMS/Backend/Modal' {
-  export = new TYPO3.CMS.Backend.Modal();
-}
-
 // type definition for global namespace object
 interface Window {
   TYPO3: any;
index 5896a0b..c518749 100644 (file)
 /**
  * Module: TYPO3/CMS/Backend/DragUploader
  */
-
+import {SeverityEnum} from './Enum/Severity';
 import * as $ from 'jquery';
 import moment = require('moment');
 import NProgress = require('nprogress');
-import Modal = require('TYPO3/CMS/Backend/Modal');
+import Modal = require('./Modal');
 import Notification = require('./Notification');
-import Severity = require('./Severity');
 
 /**
  * Possible actions for conflicts w/ existing files
@@ -363,7 +362,7 @@ class DragUploaderPlugin {
     }
 
     const $modal = Modal.confirm(
-      TYPO3.lang['file_upload.existingfiles.title'], $modalContent, Severity.warning,
+      TYPO3.lang['file_upload.existingfiles.title'], $modalContent, SeverityEnum.warning,
       [
         {
           text: $(this).data('button-close-text') || TYPO3.lang['file_upload.button.cancel'] || 'Cancel',
index e9bda7c..ca34582 100644 (file)
  * The TYPO3 project - inspiring people to share!
  */
 
+import {SeverityEnum} from './Enum/Severity';
 import 'bootstrap';
 import * as $ from 'jquery';
-import Modal = require('TYPO3/CMS/Backend/Modal');
-import Severity = require('./Severity');
+import Modal = require('./Modal');
 
 /**
  * GridEditorConfigurationInterface
@@ -679,7 +679,7 @@ export class GridEditor {
         ]),
     ]);
 
-    const $modal = Modal.show(TYPO3.lang.grid_windowTitle, $markup, Severity.notice, [
+    const $modal = Modal.show(TYPO3.lang.grid_windowTitle, $markup, SeverityEnum.notice, [
       {
         active: true,
         btnClass: 'btn-default',
index 84dd76a..c4b26a4 100644 (file)
@@ -14,7 +14,7 @@
 import * as $ from 'jquery';
 import 'jquery-ui/draggable';
 import 'jquery-ui/resizable';
-import Modal = require('TYPO3/CMS/Backend/Modal');
+import Modal = require('./Modal');
 import ImagesLoaded = require('TYPO3/CMS/Core/Contrib/imagesloaded.pkgd.min');
 
 interface Area {
index 9c1fd8f..afbe27f 100644 (file)
@@ -11,8 +11,8 @@
  * The TYPO3 project - inspiring people to share!
  */
 
-import Modal = require('TYPO3/CMS/Backend/Modal');
-import Severity = require('./Severity');
+import {SeverityEnum} from './Enum/Severity';
+import Modal = require('./Modal');
 
 /**
  * Module: TYPO3/CMS/Backend/InfoWindow
@@ -32,7 +32,7 @@ class InfoWindow {
       content: TYPO3.settings.ShowItem.moduleUrl
         + '&table=' + encodeURIComponent(table)
         + '&uid=' + (typeof uid === 'number' ? uid : encodeURIComponent(uid)),
-      severity: Severity.notice
+      severity: SeverityEnum.notice
     });
   }
 }
diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/Modal.ts b/typo3/sysext/backend/Resources/Private/TypeScript/Modal.ts
new file mode 100644 (file)
index 0000000..ffcf684
--- /dev/null
@@ -0,0 +1,492 @@
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+import {SeverityEnum} from './Enum/Severity';
+import 'bootstrap';
+import * as $ from 'jquery';
+import Icons = require('./Icons');
+import Severity = require('./Severity');
+
+enum Identifiers {
+  modal = '.t3js-modal',
+  content = '.t3js-modal-content',
+  title = '.t3js-modal-title',
+  close = '.t3js-modal-close',
+  body = '.t3js-modal-body',
+  footer = '.t3js-modal-footer',
+  iframe = '.t3js-modal-iframe',
+  iconPlaceholder = '.t3js-modal-icon-placeholder'
+}
+
+enum Sizes {
+  small = 'small',
+  default = 'default',
+  medium = 'medium',
+  large = 'large',
+  full = 'full'
+}
+
+enum Styles {
+  default = 'default',
+  light = 'light',
+  dark = 'dark'
+}
+
+enum Types {
+  default = 'default',
+  ajax = 'ajax',
+  iframe = 'iframe'
+}
+
+interface Button {
+  text: string;
+  active: boolean;
+  btnClass: string;
+  name: string;
+  trigger: (e: JQueryEventObject) => {};
+  dataAttributes: { [key: string]: string };
+  icon: string;
+}
+
+interface Configuration {
+  type: Types;
+  title: string;
+  content: string | JQuery;
+  severity: SeverityEnum;
+  buttons: Array<Button>;
+  style: string;
+  size: string;
+  additionalCssClasses: Array<string>;
+  callback: Function;
+  ajaxCallback: Function;
+  ajaxTarget: string;
+}
+
+/**
+ * Module: TYPO3/CMS/Backend/Modal
+ * API for modal windows powered by Twitter Bootstrap.
+ */
+class Modal {
+  public readonly sizes: any = Sizes;
+  public readonly styles: any = Styles;
+  public readonly types: any = Types;
+  public currentModal: JQuery = null;
+  private instances: Array<JQuery> = [];
+  private readonly $template: JQuery = $(
+    '<div class="t3js-modal modal fade">' +
+    '<div class="modal-dialog">' +
+    '<div class="t3js-modal-content modal-content">' +
+    '<div class="modal-header">' +
+    '<button class="t3js-modal-close close">' +
+    '<span aria-hidden="true">' +
+    '<span class="t3js-modal-icon-placeholder" data-icon="actions-close"></span>' +
+    '</span>' +
+    '<span class="sr-only"></span>' +
+    '</button>' +
+    '<h4 class="t3js-modal-title modal-title"></h4>' +
+    '</div>' +
+    '<div class="t3js-modal-body modal-body"></div>' +
+    '<div class="t3js-modal-footer modal-footer"></div>' +
+    '</div>' +
+    '</div>' +
+    '</div>'
+  );
+
+  private defaultConfiguration: Configuration = {
+    type: Types.default,
+    title: 'Information',
+    content: 'No content provided, please check your <code>Modal</code> configuration.',
+    severity: SeverityEnum.notice,
+    buttons: [],
+    style: Styles.default,
+    size: Sizes.default,
+    additionalCssClasses: [],
+    callback: $.noop(),
+    ajaxCallback: $.noop(),
+    ajaxTarget: null
+  };
+
+  constructor() {
+    $(document).on('modal-dismiss', this.dismiss);
+    this.initializeMarkupTrigger(document);
+  }
+
+  /**
+   * Close the current open modal
+   */
+  public dismiss(): void {
+    if (this.currentModal) {
+      this.currentModal.modal('hide');
+    }
+  }
+
+  /**
+   * Shows a confirmation dialog
+   * Events:
+   * - button.clicked
+   * - confirm.button.cancel
+   * - confirm.button.ok
+   *
+   * @param {string} title The title for the confirm modal
+   * @param {string | JQuery} content The content for the conform modal, e.g. the main question
+   * @param {SeverityEnum} severity Default SeverityEnum.warning
+   * @param {Array<Button>} buttons An array with buttons, default no buttons
+   * @param {Array<string>} additionalCssClasses Additional css classes to add to the modal
+   * @returns {JQuery}
+   */
+  public confirm(title: string,
+                 content: string | JQuery,
+                 severity: SeverityEnum = SeverityEnum.warning,
+                 buttons: Array<Object> = [],
+                 additionalCssClasses?: Array<string>): JQuery {
+    if (buttons.length === 0) {
+      buttons.push(
+        {
+          text: $(this).data('button-close-text') || TYPO3.lang['button.cancel'] || 'Cancel',
+          active: true,
+          btnClass: 'btn-default',
+          name: 'cancel'
+        },
+        {
+          text: $(this).data('button-ok-text') || TYPO3.lang['button.ok'] || 'OK',
+          btnClass: 'btn-' + Severity.getCssClass(severity),
+          name: 'ok'
+        }
+      );
+    }
+
+    return this.advanced({
+      title,
+      content,
+      severity,
+      buttons,
+      additionalCssClasses,
+      callback: (currentModal: JQuery): void => {
+        currentModal.on('button.clicked', (e: JQueryEventObject): void => {
+          if (e.target.getAttribute('name') === 'cancel') {
+            $(e.currentTarget).trigger('confirm.button.cancel');
+          } else if (e.target.getAttribute('name') === 'ok') {
+            $(e.currentTarget).trigger('confirm.button.ok');
+          }
+        });
+      }
+    });
+  }
+
+  /**
+   * Load URL with AJAX, append the content to the modal-body
+   * and trigger the callback
+   *
+   * @param {string} title
+   * @param {SeverityEnum} severity
+   * @param {Array<Button>} buttons
+   * @param {string} url
+   * @param {Function} callback
+   * @param {string} target
+   * @returns {JQuery}
+   */
+  public loadUrl(title: string,
+                 severity: SeverityEnum = SeverityEnum.info,
+                 buttons: Array<Object>,
+                 url: string,
+                 callback: Function,
+                 target: string
+  ): JQuery {
+    return this.advanced({
+      type: Types.ajax,
+      title,
+      severity,
+      buttons,
+      ajaxCallback: callback,
+      ajaxTarget: target
+    });
+  }
+
+  /**
+   * Shows a dialog
+   *
+   * @param {string} title
+   * @param {string | JQuery} content
+   * @param {number} severity
+   * @param {Array<Object>} buttons
+   * @param {Array<string>} additionalCssClasses
+   * @returns {JQuery}
+   */
+  public show(title: string,
+              content: string | JQuery,
+              severity: SeverityEnum = SeverityEnum.info,
+              buttons?: Array<Object>,
+              additionalCssClasses?: Array<string>): JQuery {
+    return this.advanced({
+      type: Types.default,
+      title,
+      content,
+      buttons,
+      additionalCssClasses
+    });
+  }
+
+  /**
+   * Loads modal by configuration
+   *
+   * @param {object} configuration configuration for the modal
+   */
+  public advanced(configuration: { [key: string]: any }): JQuery {
+    // Validation of configuration
+    configuration.type = typeof configuration.type === 'string' && configuration.type in Types
+      ? configuration.type
+      : this.defaultConfiguration.type;
+    configuration.title = typeof configuration.title === 'string'
+      ? configuration.title
+      : this.defaultConfiguration.title;
+    configuration.content = typeof configuration.content === 'string' || typeof configuration.content === 'object'
+      ? configuration.content
+      : this.defaultConfiguration.content;
+    configuration.severity = typeof configuration.severity !== 'undefined'
+      ? configuration.severity
+      : this.defaultConfiguration.severity;
+    configuration.buttons = <Array<Button>>configuration.buttons || this.defaultConfiguration.buttons;
+    configuration.size = typeof configuration.size === 'string' && configuration.size in Sizes
+      ? configuration.size
+      : this.defaultConfiguration.size;
+    configuration.style = typeof configuration.style === 'string' && configuration.style in Styles
+      ? configuration.style
+      : this.defaultConfiguration.style;
+    configuration.additionalCssClasses = configuration.additionalCssClasses || this.defaultConfiguration.additionalCssClasses;
+    configuration.callback = typeof configuration.callback === 'function' ? configuration.callback : this.defaultConfiguration.callback;
+    configuration.ajaxCallback = typeof configuration.ajaxCallback === 'function'
+      ? configuration.ajaxCallback
+      : this.defaultConfiguration.ajaxCallback;
+    configuration.ajaxTarget = typeof configuration.ajaxTarget === 'string'
+      ? configuration.ajaxTarget
+      : this.defaultConfiguration.ajaxTarget;
+
+    return this.generate(<Configuration>configuration);
+  }
+
+  /**
+   * Initialize markup with data attributes
+   *
+   * @param {HTMLDocument} theDocument
+   */
+  private initializeMarkupTrigger(theDocument: HTMLDocument): void {
+    $(theDocument).on('click', '.t3js-modal-trigger', (evt: JQueryEventObject): void => {
+      evt.preventDefault();
+      const $element = $(evt.currentTarget);
+      const content = $element.data('content') || 'Are you sure?';
+      const severity = typeof SeverityEnum[$element.data('severity')] !== 'undefined'
+        ? SeverityEnum[$element.data('severity')]
+        : SeverityEnum.info;
+      let url = $element.data('url') || null;
+      if (url !== null) {
+        const separator = (url.indexOf('?') > -1) ? '&' : '?';
+        const params = $.param({data: $element.data()});
+        url = url + separator + params;
+      }
+      this.advanced({
+        type: url !== null ? Types.ajax : Types.default,
+        title: $element.data('title') || 'Alert',
+        content: url !== null ? url : content,
+        severity,
+        buttons: [
+          {
+            text: $element.data('button-close-text') || 'Close',
+            active: true,
+            btnClass: 'btn-default',
+            trigger: (): void => {
+              this.currentModal.trigger('modal-dismiss');
+            }
+          },
+          {
+            text: $element.data('button-ok-text') || 'OK',
+            btnClass: 'btn-' + Severity.getCssClass(severity),
+            trigger: (): void => {
+              this.currentModal.trigger('modal-dismiss');
+              evt.target.ownerDocument.location.href = $element.data('href') || $element.attr('href');
+            }
+          }
+        ],
+      });
+    });
+  }
+
+  /**
+   * @param {Configuration} configuration
+   */
+  private generate(configuration: Configuration): JQuery {
+    const currentModal = this.$template.clone();
+    if (configuration.additionalCssClasses.length > 0) {
+      for (let additionalClass of configuration.additionalCssClasses) {
+        currentModal.addClass(additionalClass);
+      }
+    }
+    currentModal.addClass('modal-type-' + configuration.type);
+    currentModal.addClass('modal-severity-' + Severity.getCssClass(configuration.severity));
+    currentModal.addClass('modal-style-' + configuration.style);
+    currentModal.addClass('modal-size-' + configuration.size);
+    currentModal.attr('tabindex', '-1');
+    currentModal.find(Identifiers.title).text(configuration.title);
+    currentModal.find(Identifiers.close).on('click', (): void => {
+      currentModal.modal('hide');
+    });
+
+    if (configuration.type === 'ajax') {
+      $.get(
+        <string>configuration.content,
+        (response: string): void => {
+          this.currentModal.find(configuration.ajaxTarget ? configuration.ajaxTarget : Identifiers.body).empty().append(response);
+          if (configuration.ajaxCallback) {
+            configuration.ajaxCallback();
+          }
+          this.currentModal.trigger('modal-loaded');
+        },
+        'html'
+      );
+      Icons.getIcon('spinner-circle', Icons.sizes.default, null, null, Icons.markupIdentifiers.inline).done((icon: string): void => {
+        currentModal.find(Identifiers.body).html('<div class="modal-loading">' + icon + '</div>');
+      });
+    } else if (configuration.type === 'iframe') {
+      currentModal.find(Identifiers.body).append(
+        $('<iframe />', {
+          src: configuration.content,
+          'name': 'modal_frame',
+          'class': 'modal-iframe t3js-modal-iframe'
+        })
+      );
+      currentModal.find(Identifiers.iframe).on('load', (): void => {
+        currentModal.find(Identifiers.title).text(
+          (<HTMLIFrameElement>currentModal.find(Identifiers.iframe).get(0)).contentDocument.title
+        );
+      });
+    } else {
+      if (typeof configuration.content === 'string') {
+        // we need html, check if we have to wrap content in <p>
+        if (!/^<[a-z][\s\S]*>/i.test(configuration.content)) {
+          configuration.content = $('<p />').html(configuration.content);
+        }
+      }
+      currentModal.find(Identifiers.body).append(configuration.content);
+    }
+
+    // Add buttons
+    if (configuration.buttons.length > 0) {
+      for (let i = 0; i < configuration.buttons.length; i++) {
+        const button = configuration.buttons[i];
+        const $button = $('<button />', {'class': 'btn'});
+        $button.html('<span>' + button.text + '</span>');
+        if (button.active) {
+          $button.addClass('t3js-active');
+        }
+        if (button.btnClass !== '') {
+          $button.addClass(button.btnClass);
+        }
+        if (button.name !== '') {
+          $button.attr('name', button.name);
+        }
+        if (button.trigger) {
+          $button.on('click', button.trigger);
+        }
+        if (button.dataAttributes) {
+          if (Object.keys(button.dataAttributes).length > 0) {
+            Object.keys(button.dataAttributes).map((value: string): any => {
+              $button.attr('data-' + value, button.dataAttributes[value]);
+            });
+          }
+        }
+        if (button.icon) {
+          $button.prepend('<span class="t3js-modal-icon-placeholder" data-icon="' + button.icon + '"></span>');
+        }
+        currentModal.find(Identifiers.footer).append($button);
+      }
+      currentModal
+        .find(Identifiers.footer).find('button')
+        .on('click', (e: JQueryEventObject): void => {
+          $(e.currentTarget).trigger('button.clicked');
+        });
+    } else {
+      currentModal.find(Identifiers.footer).remove();
+    }
+
+    currentModal.on('shown.bs.modal', (e: JQueryEventObject): void => {
+      const $me = $(e.currentTarget);
+      // focus the button which was configured as active button
+      $me.find(Identifiers.footer).find('.t3js-active').first().focus();
+      // Get Icons
+      $me.find(Identifiers.iconPlaceholder).each((index: number, elem: Element): void => {
+        Icons.getIcon($(elem).data('icon'), Icons.sizes.small, null, null, Icons.markupIdentifiers.inline).done((icon: string): void => {
+          this.currentModal.find(Identifiers.iconPlaceholder + '[data-icon=' + $(icon).data('identifier') + ']').replaceWith(icon);
+        });
+      });
+    });
+
+    // Remove modal from Modal.instances when hidden
+    currentModal.on('hidden.bs.modal', (): void => {
+      if (this.instances.length > 0) {
+        const lastIndex = this.instances.length - 1;
+        this.instances.splice(lastIndex, 1);
+        this.currentModal = this.instances[lastIndex - 1];
+      }
+      currentModal.trigger('modal-destroyed');
+      $(this).remove();
+      // Keep class modal-open on body tag as long as open modals exist
+      if (this.instances.length > 0) {
+        $('body').addClass('modal-open');
+      }
+    });
+
+    // When modal is opened/shown add it to Modal.instances and make it Modal.currentModal
+    currentModal.on('show.bs.modal', (e: JQueryEventObject): void => {
+      this.currentModal = $(e.currentTarget);
+      this.instances.push(this.currentModal);
+    });
+    currentModal.on('modal-dismiss', (e: JQueryEventObject): void => {
+      // Hide modal, the bs.modal events will clean up Modal.instances
+      $(e.currentTarget).modal('hide');
+    });
+
+    if (configuration.callback) {
+      configuration.callback(currentModal);
+    }
+
+    return currentModal.modal();
+  }
+}
+
+let modalObject: Modal = null;
+try {
+  if (parent && parent.window.TYPO3 && parent.window.TYPO3.Modal) {
+    // fetch from parent
+    // we need to trigger the event capturing again, in order to make sure this works inside iframes
+    parent.window.TYPO3.Modal.initializeMarkupTrigger(document);
+    modalObject = parent.window.TYPO3.Modal;
+  } else if (top && top.TYPO3.Modal) {
+    // fetch object from outer frame
+    // we need to trigger the event capturing again, in order to make sure this works inside iframes
+    top.TYPO3.Modal.initializeMarkupTrigger(document);
+    modalObject = top.TYPO3.Modal;
+  }
+} catch (e) {
+  // This only happens if the opener, parent or top is some other url (eg a local file)
+  // which loaded the current window. Then the browser's cross domain policy jumps in
+  // and raises an exception.
+  // For this case we are safe and we can create our global object below.
+}
+
+if (!modalObject) {
+  modalObject = new Modal();
+
+  // expose as global object
+  TYPO3.Modal = modalObject;
+}
+
+export = modalObject;
index db6cf04..a122c98 100644 (file)
@@ -11,9 +11,9 @@
  * The TYPO3 project - inspiring people to share!
  */
 
+import {SeverityEnum} from './Enum/Severity';
 import * as $ from 'jquery';
-import Modal = require('TYPO3/CMS/Backend/Modal');
-import Severity = require('./Severity');
+import Modal = require('./Modal');
 
 /**
  * Module: TYPO3/CMS/Backend/RenameFile
@@ -56,7 +56,7 @@ class RenameFile {
           const modal: JQuery = Modal.confirm(
             TYPO3.lang['file_rename.exists.title'],
             description,
-            Severity.warning,
+            SeverityEnum.warning,
             [
               {
                 active: true,
index 9af8785..48ab854 100644 (file)
@@ -11,8 +11,8 @@
  * The TYPO3 project - inspiring people to share!
  */
 
-import Modal = require('TYPO3/CMS/Backend/Modal');
-import Severity = require('../Severity');
+import {SeverityEnum} from '../Enum/Severity';
+import Modal = require('../Modal');
 
 /**
  * Module: TYPO3/CMS/Backend/Wizard/NewContentElement
@@ -26,7 +26,7 @@ class NewContentElement {
         currentModal.find('.t3js-modal-body').addClass('t3-new-content-element-wizard-window');
       },
       content: url,
-      severity: Severity.notice,
+      severity: SeverityEnum.notice,
       size: Modal.sizes.medium,
       title,
       type: Modal.types.ajax,
index 6293f60..349247f 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","jquery","moment","nprogress","TYPO3/CMS/Backend/Modal","./Notification","./Severity"],function(a,b,c,d,e,f,g,h){"use strict";Object.defineProperty(b,"__esModule",{value:!0});var i;!function(a){a.OVERRIDE="replace",a.RENAME="rename",a.SKIP="cancel",a.USE_EXISTING="useExisting"}(i||(i={}));var j=function(){function a(a){var b=this;this.askForOverride=[],this.percentagePerFile=1,this.dragFileIntoDocument=function(a){return a.stopPropagation(),a.preventDefault(),c(a.currentTarget).addClass("drop-in-progress"),b.showDropzone(),!1},this.dragAborted=function(a){return a.stopPropagation(),a.preventDefault(),c(a.currentTarget).removeClass("drop-in-progress"),!1},this.ignoreDrop=function(a){return a.stopPropagation(),a.preventDefault(),b.dragAborted(a),!1},this.handleDrop=function(a){b.ignoreDrop(a),b.processFiles(a.originalEvent.dataTransfer.files),b.$dropzone.removeClass("drop-status-ok")},this.fileInDropzone=function(){b.$dropzone.addClass("drop-status-ok")},this.fileOutOfDropzone=function(){b.$dropzone.removeClass("drop-status-ok")},this.$body=c("body"),this.$element=c(a);var d=void 0!==this.$element.data("dropzoneTrigger");this.$trigger=c(this.$element.data("dropzoneTrigger")),this.$dropzone=c("<div />").addClass("dropzone").hide(),this.irreObjectUid=this.$element.data("fileIrreObject");var e=this.$element.data("dropzoneTarget");return this.irreObjectUid&&0!==this.$element.nextAll(e).length?(this.dropZoneInsertBefore=!0,this.$dropzone.insertBefore(e)):(this.dropZoneInsertBefore=!1,this.$dropzone.insertAfter(e)),this.$dropzoneMask=c("<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=c(this.$element.data("progress-container")),this.fileListColumnCount=c("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(a){return b.handleDrop(a)}),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(){b.fileInput.click()}),c("<span />").addClass("dropzone-close").click(this.hideDropzone).appendTo(this.$dropzone),0===this.$fileList.length&&(this.$fileList=c("<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(){b.processFiles(Array.apply(null,b.fileInput.files))}),void this.bindUploadButton(d===!0?this.$trigger:this.$element)):void console.warn("Browser has no Drag and drop capabilities; cannot initialize DragUploader")}return a.prototype.showDropzone=function(){this.$dropzone.show()},a.prototype.hideDropzone=function(a){a.stopPropagation(),a.preventDefault(),this.$dropzone.hide()},a.prototype.processFiles=function(a){var b=this;this.queueLength=a.length,this.$fileList.is(":visible")||this.$fileList.show(),e.start(),this.percentagePerFile=1/a.length;var d=[];c.each(a,function(a,f){d[parseInt(a,10)]=c.ajax({url:TYPO3.settings.ajaxUrls.file_exists,data:{fileName:f.name,fileTarget:b.target},cache:!1,success:function(a){var c="undefined"!=typeof a.uid;if(c)b.askForOverride.push({original:a,uploaded:f,action:b.irreObjectUid?i.USE_EXISTING:i.SKIP}),e.inc(b.percentagePerFile);else{new k(b,f,i.SKIP)}}})}),c.when.apply(c,d).done(function(){b.drawOverrideModal(),e.done()}),this.fileInput.value=""},a.prototype.bindUploadButton=function(a){var b=this;a.click(function(a){a.preventDefault(),b.fileInput.click(),b.showDropzone()})},a.prototype.decrementQueueLength=function(){this.queueLength>0&&(this.queueLength--,0===this.queueLength&&c.ajax({url:TYPO3.settings.ajaxUrls.flashmessages_render,cache:!1,success:function(a){c.each(a,function(a,b){g.showMessage(b.title,b.message,b.severity)})}}))},a.prototype.drawOverrideModal=function(){var a=this,b=Object.keys(this.askForOverride).length;if(0!==b){for(var e=c("<div/>").append(c("<p/>").text(TYPO3.lang["file_upload.existingfiles.description"]),c("<table/>",{class:"table"}).append(c("<thead/>").append(c("<tr />").append(c("<th/>"),c("<th/>").text(TYPO3.lang["file_upload.header.originalFile"]),c("<th/>").text(TYPO3.lang["file_upload.header.uploadedFile"]),c("<th/>").text(TYPO3.lang["file_upload.header.action"]))))),g=0;g<b;++g){var j=c("<tr />").append(c("<td />").append(""!==this.askForOverride[g].original.thumbUrl?c("<img />",{src:this.askForOverride[g].original.thumbUrl,height:40}):c(this.askForOverride[g].original.icon)),c("<td />").html(this.askForOverride[g].uploaded.name+" ("+l.fileSizeAsString(this.askForOverride[g].uploaded.size)+")<br>"+d(this.askForOverride[g].uploaded.lastModifiedDate,"x").format("YYYY-MM-DD HH:mm")),c("<td />").html(this.askForOverride[g].uploaded.name+" ("+l.fileSizeAsString(this.askForOverride[g].original.size)+")<br>"+d(this.askForOverride[g].original.mtime,"X").format("YYYY-MM-DD HH:mm")),c("<td />").append(c("<select />",{class:"form-control t3js-actions","data-override":g}).append(this.irreObjectUid?c("<option/>").val(i.USE_EXISTING).text(TYPO3.lang["file_upload.actions.use_existing"]):"",c("<option />").val(i.SKIP).text(TYPO3.lang["file_upload.actions.skip"]),c("<option />").val(i.RENAME).text(TYPO3.lang["file_upload.actions.rename"]),c("<option />").val(i.OVERRIDE).text(TYPO3.lang["file_upload.actions.override"]))));e.find("table").append("<tbody />").append(j)}var m=f.confirm(TYPO3.lang["file_upload.existingfiles.title"],e,h.warning,[{text:c(this).data("button-close-text")||TYPO3.lang["file_upload.button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:c(this).data("button-ok-text")||TYPO3.lang["file_upload.button.continue"]||"Continue with selected actions",btnClass:"btn-warning",name:"continue"}],["modal-inner-scroll"]);m.find(".modal-dialog").addClass("modal-lg"),m.find(".modal-footer").prepend(c("<span/>").addClass("form-inline").append(c("<label/>").text(TYPO3.lang["file_upload.actions.all.label"]),c("<select/>",{class:"form-control t3js-actions-all"}).append(c("<option/>").val("").text(TYPO3.lang["file_upload.actions.all.empty"]),this.irreObjectUid?c("<option/>").val(i.USE_EXISTING).text(TYPO3.lang["file_upload.actions.all.use_existing"]):"",c("<option/>").val(i.SKIP).text(TYPO3.lang["file_upload.actions.all.skip"]),c("<option/>").val(i.RENAME).text(TYPO3.lang["file_upload.actions.all.rename"]),c("<option/>").val(i.OVERRIDE).text(TYPO3.lang["file_upload.actions.all.override"]))));var n=this;m.on("change",".t3js-actions-all",function(){var a=c(this),b=a.val();""!==b?m.find(".t3js-actions").each(function(a,d){var e=c(d),f=parseInt(e.data("override"),10);e.val(b).prop("disabled","disabled"),n.askForOverride[f].action=e.val()}):m.find(".t3js-actions").removeProp("disabled")}).on("change",".t3js-actions",function(){var a=c(this),b=parseInt(a.data("override"),10);n.askForOverride[b].action=a.val()}).on("button.clicked",function(a){"cancel"===a.target.name?(n.askForOverride=[],f.dismiss()):"continue"===a.target.name&&(c.each(n.askForOverride,function(a,b){if(b.action===i.USE_EXISTING)l.addFileToIrre(n.irreObjectUid,b.original);else if(b.action!==i.SKIP){new k(n,b.uploaded,b.action)}}),n.askForOverride=[],f.dismiss())}).on("hidden.bs.modal",function(){a.askForOverride=[]})}},a}(),k=function(){function a(a,b,d){var e=this;if(this.dragUploader=a,this.file=b,this.override=d,this.$row=c("<tr />").addClass("upload-queue-item uploading"),this.$iconCol=c("<td />").addClass("col-icon").appendTo(this.$row),this.$fileName=c("<td />").text(b.name).appendTo(this.$row),this.$progress=c("<td />").attr("colspan",this.dragUploader.fileListColumnCount-2).appendTo(this.$row),this.$progressContainer=c("<div />").addClass("upload-queue-progress").appendTo(this.$progress),this.$progressBar=c("<div />").addClass("upload-queue-progress-bar").appendTo(this.$progressContainer),this.$progressPercentage=c("<span />").addClass("upload-queue-progress-percentage").appendTo(this.$progressContainer),this.$progressMessage=c("<span />").addClass("upload-queue-progress-message").appendTo(this.$progressContainer),0===c("tbody tr.upload-queue-item",this.dragUploader.$fileList).length?(this.$row.prependTo(c("tbody",this.dragUploader.$fileList)),this.$row.addClass("last")):this.$row.insertBefore(c("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,l.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("- "+l.fileSizeAsString(this.file.size));var f=new FormData;f.append("data[upload][1][target]",this.dragUploader.target),f.append("data[upload][1][data]","1"),f.append("overwriteExistingFiles",this.override),f.append("redirect",""),f.append("upload_1",this.file);var g=c.extend(!0,{},c.ajaxSettings,{url:TYPO3.settings.ajaxUrls.file_process,contentType:!1,processData:!1,data:f,cache:!1,type:"POST",success:function(a){return e.uploadSuccess(a)},error:function(a){return e.uploadError(a)}});g.xhr=function(){var a=c.ajaxSettings.xhr();return a.upload.addEventListener("progress",function(a){return e.updateProgress(a)}),a},this.upload=c.ajax(g)}else this.updateMessage(TYPO3.lang["file_upload.fileExtensionExpected"].replace(/\{0\}/g,this.dragUploader.filesExtensionsAllowed)),this.$row.addClass("error")}return a.prototype.updateMessage=function(a){this.$progressMessage.text(a)},a.prototype.removeProgress=function(){this.$progress&&this.$progress.remove()},a.prototype.uploadStart=function(){this.$progressPercentage.text("(0%)"),this.$progressBar.width("1%"),this.dragUploader.$trigger.trigger("uploadStart",[this])},a.prototype.uploadError=function(a){this.updateMessage(TYPO3.lang["file_upload.uploadFailed"].replace(/\{0\}/g,this.file.name));var b=c(a.responseText);b.is("t3err")?this.$progressPercentage.text(b.text()):this.$progressPercentage.text("("+a.statusText+")"),this.$row.addClass("error"),this.dragUploader.decrementQueueLength(),this.dragUploader.$trigger.trigger("uploadError",[this,a])},a.prototype.updateProgress=function(a){var b=Math.round(a.loaded/a.total*100)+"%";this.$progressBar.outerWidth(b),this.$progressPercentage.text(b),this.dragUploader.$trigger.trigger("updateProgress",[this,b,a])},a.prototype.uploadSuccess=function(a){var b=this;a.upload&&(this.dragUploader.decrementQueueLength(),this.$row.removeClass("uploading"),this.$fileName.text(a.upload[0].name),this.$progressPercentage.text(""),this.$progressMessage.text("100%"),this.$progressBar.outerWidth("100%"),a.upload[0].icon&&this.$iconCol.html('<a href="#" class="t3js-contextmenutrigger" data-uid="'+a.upload[0].id+'" data-table="sys_file">'+a.upload[0].icon+"&nbsp;</span></a>"),this.dragUploader.irreObjectUid?(l.addFileToIrre(this.dragUploader.irreObjectUid,a.upload[0]),setTimeout(function(){b.$row.remove(),0===c("tr",b.dragUploader.$fileList).length&&(b.dragUploader.$fileList.hide(),b.dragUploader.$trigger.trigger("uploadSuccess",[b,a]))},3e3)):setTimeout(function(){b.showFileInfo(a.upload[0]),b.dragUploader.$trigger.trigger("uploadSuccess",[b,a])},3e3))},a.prototype.showFileInfo=function(a){this.removeProgress();for(var b=7;b<this.dragUploader.fileListColumnCount;b++)c("<td />").text("").appendTo(this.$row);c("<td />").text(a.extension.toUpperCase()).appendTo(this.$row),c("<td />").text(a.date).appendTo(this.$row),c("<td />").text(l.fileSizeAsString(a.size)).appendTo(this.$row);var d="";a.permissions.read&&(d+='<strong class="text-danger">'+TYPO3.lang["permissions.read"]+"</strong>"),a.permissions.write&&(d+='<strong class="text-danger">'+TYPO3.lang["permissions.write"]+"</strong>"),c("<td />").html(d).appendTo(this.$row),c("<td />").text("-").appendTo(this.$row)},a.prototype.checkAllowedExtensions=function(){if(!this.dragUploader.filesExtensionsAllowed)return!0;var a=this.file.name.split(".").pop(),b=this.dragUploader.filesExtensionsAllowed.split(",");return c.inArray(a.toLowerCase(),b)!==-1},a}(),l=function(){function a(){}return a.fileSizeAsString=function(a){var b=a/1024,c="";return c=b>1024?(b/1024).toFixed(1)+" MB":b.toFixed(1)+" KB"},a.addFileToIrre=function(a,b){window.inline.delayedImportElement(a,"sys_file",b.uid,"file")},a.init=function(){var a=this,b=a.options;c.fn.extend({dragUploader:function(a){return this.each(function(b,d){var e=c(d),f=e.data("DragUploaderPlugin");f||e.data("DragUploaderPlugin",f=new j(d)),"string"==typeof a&&f[a]()})}}),c(function(){c(".t3js-drag-uploader").dragUploader(b)})},a}();b.initialize=function(){l.init(),"undefined"!=typeof TYPO3.settings&&"undefined"!=typeof TYPO3.settings.RequireJS&&"undefined"!=typeof TYPO3.settings.RequireJS.PostInitializationModules&&"undefined"!=typeof TYPO3.settings.RequireJS.PostInitializationModules["TYPO3/CMS/Backend/DragUploader"]&&c.each(TYPO3.settings.RequireJS.PostInitializationModules["TYPO3/CMS/Backend/DragUploader"],function(b,c){a([c])})},b.initialize()});
\ No newline at end of file
+define(["require","exports","./Enum/Severity","jquery","moment","nprogress","./Modal","./Notification"],function(a,b,c,d,e,f,g,h){"use strict";Object.defineProperty(b,"__esModule",{value:!0});var i;!function(a){a.OVERRIDE="replace",a.RENAME="rename",a.SKIP="cancel",a.USE_EXISTING="useExisting"}(i||(i={}));var j=function(){function a(a){var b=this;this.askForOverride=[],this.percentagePerFile=1,this.dragFileIntoDocument=function(a){return a.stopPropagation(),a.preventDefault(),d(a.currentTarget).addClass("drop-in-progress"),b.showDropzone(),!1},this.dragAborted=function(a){return a.stopPropagation(),a.preventDefault(),d(a.currentTarget).removeClass("drop-in-progress"),!1},this.ignoreDrop=function(a){return a.stopPropagation(),a.preventDefault(),b.dragAborted(a),!1},this.handleDrop=function(a){b.ignoreDrop(a),b.processFiles(a.originalEvent.dataTransfer.files),b.$dropzone.removeClass("drop-status-ok")},this.fileInDropzone=function(){b.$dropzone.addClass("drop-status-ok")},this.fileOutOfDropzone=function(){b.$dropzone.removeClass("drop-status-ok")},this.$body=d("body"),this.$element=d(a);var c=void 0!==this.$element.data("dropzoneTrigger");this.$trigger=d(this.$element.data("dropzoneTrigger")),this.$dropzone=d("<div />").addClass("dropzone").hide(),this.irreObjectUid=this.$element.data("fileIrreObject");var e=this.$element.data("dropzoneTarget");return this.irreObjectUid&&0!==this.$element.nextAll(e).length?(this.dropZoneInsertBefore=!0,this.$dropzone.insertBefore(e)):(this.dropZoneInsertBefore=!1,this.$dropzone.insertAfter(e)),this.$dropzoneMask=d("<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=d(this.$element.data("progress-container")),this.fileListColumnCount=d("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(a){return b.handleDrop(a)}),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(){b.fileInput.click()}),d("<span />").addClass("dropzone-close").click(this.hideDropzone).appendTo(this.$dropzone),0===this.$fileList.length&&(this.$fileList=d("<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(){b.processFiles(Array.apply(null,b.fileInput.files))}),void this.bindUploadButton(c===!0?this.$trigger:this.$element)):void console.warn("Browser has no Drag and drop capabilities; cannot initialize DragUploader")}return a.prototype.showDropzone=function(){this.$dropzone.show()},a.prototype.hideDropzone=function(a){a.stopPropagation(),a.preventDefault(),this.$dropzone.hide()},a.prototype.processFiles=function(a){var b=this;this.queueLength=a.length,this.$fileList.is(":visible")||this.$fileList.show(),f.start(),this.percentagePerFile=1/a.length;var c=[];d.each(a,function(a,e){c[parseInt(a,10)]=d.ajax({url:TYPO3.settings.ajaxUrls.file_exists,data:{fileName:e.name,fileTarget:b.target},cache:!1,success:function(a){var c="undefined"!=typeof a.uid;if(c)b.askForOverride.push({original:a,uploaded:e,action:b.irreObjectUid?i.USE_EXISTING:i.SKIP}),f.inc(b.percentagePerFile);else{new k(b,e,i.SKIP)}}})}),d.when.apply(d,c).done(function(){b.drawOverrideModal(),f.done()}),this.fileInput.value=""},a.prototype.bindUploadButton=function(a){var b=this;a.click(function(a){a.preventDefault(),b.fileInput.click(),b.showDropzone()})},a.prototype.decrementQueueLength=function(){this.queueLength>0&&(this.queueLength--,0===this.queueLength&&d.ajax({url:TYPO3.settings.ajaxUrls.flashmessages_render,cache:!1,success:function(a){d.each(a,function(a,b){h.showMessage(b.title,b.message,b.severity)})}}))},a.prototype.drawOverrideModal=function(){var a=this,b=Object.keys(this.askForOverride).length;if(0!==b){for(var f=d("<div/>").append(d("<p/>").text(TYPO3.lang["file_upload.existingfiles.description"]),d("<table/>",{class:"table"}).append(d("<thead/>").append(d("<tr />").append(d("<th/>"),d("<th/>").text(TYPO3.lang["file_upload.header.originalFile"]),d("<th/>").text(TYPO3.lang["file_upload.header.uploadedFile"]),d("<th/>").text(TYPO3.lang["file_upload.header.action"]))))),h=0;h<b;++h){var j=d("<tr />").append(d("<td />").append(""!==this.askForOverride[h].original.thumbUrl?d("<img />",{src:this.askForOverride[h].original.thumbUrl,height:40}):d(this.askForOverride[h].original.icon)),d("<td />").html(this.askForOverride[h].uploaded.name+" ("+l.fileSizeAsString(this.askForOverride[h].uploaded.size)+")<br>"+e(this.askForOverride[h].uploaded.lastModifiedDate,"x").format("YYYY-MM-DD HH:mm")),d("<td />").html(this.askForOverride[h].uploaded.name+" ("+l.fileSizeAsString(this.askForOverride[h].original.size)+")<br>"+e(this.askForOverride[h].original.mtime,"X").format("YYYY-MM-DD HH:mm")),d("<td />").append(d("<select />",{class:"form-control t3js-actions","data-override":h}).append(this.irreObjectUid?d("<option/>").val(i.USE_EXISTING).text(TYPO3.lang["file_upload.actions.use_existing"]):"",d("<option />").val(i.SKIP).text(TYPO3.lang["file_upload.actions.skip"]),d("<option />").val(i.RENAME).text(TYPO3.lang["file_upload.actions.rename"]),d("<option />").val(i.OVERRIDE).text(TYPO3.lang["file_upload.actions.override"]))));f.find("table").append("<tbody />").append(j)}var m=g.confirm(TYPO3.lang["file_upload.existingfiles.title"],f,c.SeverityEnum.warning,[{text:d(this).data("button-close-text")||TYPO3.lang["file_upload.button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:d(this).data("button-ok-text")||TYPO3.lang["file_upload.button.continue"]||"Continue with selected actions",btnClass:"btn-warning",name:"continue"}],["modal-inner-scroll"]);m.find(".modal-dialog").addClass("modal-lg"),m.find(".modal-footer").prepend(d("<span/>").addClass("form-inline").append(d("<label/>").text(TYPO3.lang["file_upload.actions.all.label"]),d("<select/>",{class:"form-control t3js-actions-all"}).append(d("<option/>").val("").text(TYPO3.lang["file_upload.actions.all.empty"]),this.irreObjectUid?d("<option/>").val(i.USE_EXISTING).text(TYPO3.lang["file_upload.actions.all.use_existing"]):"",d("<option/>").val(i.SKIP).text(TYPO3.lang["file_upload.actions.all.skip"]),d("<option/>").val(i.RENAME).text(TYPO3.lang["file_upload.actions.all.rename"]),d("<option/>").val(i.OVERRIDE).text(TYPO3.lang["file_upload.actions.all.override"]))));var n=this;m.on("change",".t3js-actions-all",function(){var a=d(this),b=a.val();""!==b?m.find(".t3js-actions").each(function(a,c){var e=d(c),f=parseInt(e.data("override"),10);e.val(b).prop("disabled","disabled"),n.askForOverride[f].action=e.val()}):m.find(".t3js-actions").removeProp("disabled")}).on("change",".t3js-actions",function(){var a=d(this),b=parseInt(a.data("override"),10);n.askForOverride[b].action=a.val()}).on("button.clicked",function(a){"cancel"===a.target.name?(n.askForOverride=[],g.dismiss()):"continue"===a.target.name&&(d.each(n.askForOverride,function(a,b){if(b.action===i.USE_EXISTING)l.addFileToIrre(n.irreObjectUid,b.original);else if(b.action!==i.SKIP){new k(n,b.uploaded,b.action)}}),n.askForOverride=[],g.dismiss())}).on("hidden.bs.modal",function(){a.askForOverride=[]})}},a}(),k=function(){function a(a,b,c){var e=this;if(this.dragUploader=a,this.file=b,this.override=c,this.$row=d("<tr />").addClass("upload-queue-item uploading"),this.$iconCol=d("<td />").addClass("col-icon").appendTo(this.$row),this.$fileName=d("<td />").text(b.name).appendTo(this.$row),this.$progress=d("<td />").attr("colspan",this.dragUploader.fileListColumnCount-2).appendTo(this.$row),this.$progressContainer=d("<div />").addClass("upload-queue-progress").appendTo(this.$progress),this.$progressBar=d("<div />").addClass("upload-queue-progress-bar").appendTo(this.$progressContainer),this.$progressPercentage=d("<span />").addClass("upload-queue-progress-percentage").appendTo(this.$progressContainer),this.$progressMessage=d("<span />").addClass("upload-queue-progress-message").appendTo(this.$progressContainer),0===d("tbody tr.upload-queue-item",this.dragUploader.$fileList).length?(this.$row.prependTo(d("tbody",this.dragUploader.$fileList)),this.$row.addClass("last")):this.$row.insertBefore(d("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,l.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("- "+l.fileSizeAsString(this.file.size));var f=new FormData;f.append("data[upload][1][target]",this.dragUploader.target),f.append("data[upload][1][data]","1"),f.append("overwriteExistingFiles",this.override),f.append("redirect",""),f.append("upload_1",this.file);var g=d.extend(!0,{},d.ajaxSettings,{url:TYPO3.settings.ajaxUrls.file_process,contentType:!1,processData:!1,data:f,cache:!1,type:"POST",success:function(a){return e.uploadSuccess(a)},error:function(a){return e.uploadError(a)}});g.xhr=function(){var a=d.ajaxSettings.xhr();return a.upload.addEventListener("progress",function(a){return e.updateProgress(a)}),a},this.upload=d.ajax(g)}else this.updateMessage(TYPO3.lang["file_upload.fileExtensionExpected"].replace(/\{0\}/g,this.dragUploader.filesExtensionsAllowed)),this.$row.addClass("error")}return a.prototype.updateMessage=function(a){this.$progressMessage.text(a)},a.prototype.removeProgress=function(){this.$progress&&this.$progress.remove()},a.prototype.uploadStart=function(){this.$progressPercentage.text("(0%)"),this.$progressBar.width("1%"),this.dragUploader.$trigger.trigger("uploadStart",[this])},a.prototype.uploadError=function(a){this.updateMessage(TYPO3.lang["file_upload.uploadFailed"].replace(/\{0\}/g,this.file.name));var b=d(a.responseText);b.is("t3err")?this.$progressPercentage.text(b.text()):this.$progressPercentage.text("("+a.statusText+")"),this.$row.addClass("error"),this.dragUploader.decrementQueueLength(),this.dragUploader.$trigger.trigger("uploadError",[this,a])},a.prototype.updateProgress=function(a){var b=Math.round(a.loaded/a.total*100)+"%";this.$progressBar.outerWidth(b),this.$progressPercentage.text(b),this.dragUploader.$trigger.trigger("updateProgress",[this,b,a])},a.prototype.uploadSuccess=function(a){var b=this;a.upload&&(this.dragUploader.decrementQueueLength(),this.$row.removeClass("uploading"),this.$fileName.text(a.upload[0].name),this.$progressPercentage.text(""),this.$progressMessage.text("100%"),this.$progressBar.outerWidth("100%"),a.upload[0].icon&&this.$iconCol.html('<a href="#" class="t3js-contextmenutrigger" data-uid="'+a.upload[0].id+'" data-table="sys_file">'+a.upload[0].icon+"&nbsp;</span></a>"),this.dragUploader.irreObjectUid?(l.addFileToIrre(this.dragUploader.irreObjectUid,a.upload[0]),setTimeout(function(){b.$row.remove(),0===d("tr",b.dragUploader.$fileList).length&&(b.dragUploader.$fileList.hide(),b.dragUploader.$trigger.trigger("uploadSuccess",[b,a]))},3e3)):setTimeout(function(){b.showFileInfo(a.upload[0]),b.dragUploader.$trigger.trigger("uploadSuccess",[b,a])},3e3))},a.prototype.showFileInfo=function(a){this.removeProgress();for(var b=7;b<this.dragUploader.fileListColumnCount;b++)d("<td />").text("").appendTo(this.$row);d("<td />").text(a.extension.toUpperCase()).appendTo(this.$row),d("<td />").text(a.date).appendTo(this.$row),d("<td />").text(l.fileSizeAsString(a.size)).appendTo(this.$row);var c="";a.permissions.read&&(c+='<strong class="text-danger">'+TYPO3.lang["permissions.read"]+"</strong>"),a.permissions.write&&(c+='<strong class="text-danger">'+TYPO3.lang["permissions.write"]+"</strong>"),d("<td />").html(c).appendTo(this.$row),d("<td />").text("-").appendTo(this.$row)},a.prototype.checkAllowedExtensions=function(){if(!this.dragUploader.filesExtensionsAllowed)return!0;var a=this.file.name.split(".").pop(),b=this.dragUploader.filesExtensionsAllowed.split(",");return d.inArray(a.toLowerCase(),b)!==-1},a}(),l=function(){function a(){}return a.fileSizeAsString=function(a){var b=a/1024,c="";return c=b>1024?(b/1024).toFixed(1)+" MB":b.toFixed(1)+" KB"},a.addFileToIrre=function(a,b){window.inline.delayedImportElement(a,"sys_file",b.uid,"file")},a.init=function(){var a=this,b=a.options;d.fn.extend({dragUploader:function(a){return this.each(function(b,c){var e=d(c),f=e.data("DragUploaderPlugin");f||e.data("DragUploaderPlugin",f=new j(c)),"string"==typeof a&&f[a]()})}}),d(function(){d(".t3js-drag-uploader").dragUploader(b)})},a}();b.initialize=function(){l.init(),"undefined"!=typeof TYPO3.settings&&"undefined"!=typeof TYPO3.settings.RequireJS&&"undefined"!=typeof TYPO3.settings.RequireJS.PostInitializationModules&&"undefined"!=typeof TYPO3.settings.RequireJS.PostInitializationModules["TYPO3/CMS/Backend/DragUploader"]&&d.each(TYPO3.settings.RequireJS.PostInitializationModules["TYPO3/CMS/Backend/DragUploader"],function(b,c){a([c])})},b.initialize()});
\ No newline at end of file
index 5cb1bac..727c20a 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-var __values=this&&this.__values||function(a){var b="function"==typeof Symbol&&a[Symbol.iterator],c=0;return b?b.call(a):{next:function(){return a&&c>=a.length&&(a=void 0),{value:a&&a[c++],done:!a}}}};define(["require","exports","jquery","TYPO3/CMS/Backend/Modal","./Severity","bootstrap"],function(a,b,c,d,e){"use strict";Object.defineProperty(b,"__esModule",{value:!0});var f=function(){function a(a){void 0===a&&(a=null);var b=this;this.colCount=1,this.rowCount=1,this.nameLabel="name",this.columnLabel="columen label",this.defaultCell={spanned:0,rowspan:1,colspan:1,name:"",colpos:"",column:void 0},this.selectorEditor=".t3js-grideditor",this.selectorAddColumn=".t3js-grideditor-addcolumn",this.selectorRemoveColumn=".t3js-grideditor-removecolumn",this.selectorAddRowTop=".t3js-grideditor-addrow-top",this.selectorRemoveRowTop=".t3js-grideditor-removerow-top",this.selectorAddRowBottom=".t3js-grideditor-addrow-bottom",this.selectorRemoveRowBottom=".t3js-grideditor-removerow-bottom",this.selectorLinkEditor=".t3js-grideditor-link-editor",this.selectorLinkExpandRight=".t3js-grideditor-link-expand-right",this.selectorLinkShrinkLeft=".t3js-grideditor-link-shrink-left",this.selectorLinkExpandDown=".t3js-grideditor-link-expand-down",this.selectorLinkShrinkUp=".t3js-grideditor-link-shrink-up",this.selectorDocHeaderSave=".t3js-grideditor-savedok",this.selectorDocHeaderSaveClose=".t3js-grideditor-savedokclose",this.selectorConfigPreview=".t3js-grideditor-preview-config",this.selectorConfigPreviewButton=".t3js-grideditor-preview-button",this.modalButtonClickHandler=function(a){var c=a.target;"cancel"===c.name?d.currentModal.trigger("modal-dismiss"):"ok"===c.name&&(b.setName(d.currentModal.find(".t3js-grideditor-field-name").val(),d.currentModal.data("col"),d.currentModal.data("row")),b.setColumn(d.currentModal.find(".t3js-grideditor-field-colpos").val(),d.currentModal.data("col"),d.currentModal.data("row")),b.drawTable(),b.writeConfig(b.export2LayoutRecord()),d.currentModal.trigger("modal-dismiss"))},this.addColumnHandler=function(a){a.preventDefault(),b.addColumn(),b.drawTable(),b.writeConfig(b.export2LayoutRecord())},this.removeColumnHandler=function(a){a.preventDefault(),b.removeColumn(),b.drawTable(),b.writeConfig(b.export2LayoutRecord())},this.addRowTopHandler=function(a){a.preventDefault(),b.addRowTop(),b.drawTable(),b.writeConfig(b.export2LayoutRecord())},this.addRowBottomHandler=function(a){a.preventDefault(),b.addRowBottom(),b.drawTable(),b.writeConfig(b.export2LayoutRecord())},this.removeRowTopHandler=function(a){a.preventDefault(),b.removeRowTop(),b.drawTable(),b.writeConfig(b.export2LayoutRecord())},this.removeRowBottomHandler=function(a){a.preventDefault(),b.removeRowBottom(),b.drawTable(),b.writeConfig(b.export2LayoutRecord())},this.linkEditorHandler=function(a){a.preventDefault();var d=c(a.target);b.showOptions(d.data("col"),d.data("row"))},this.linkExpandRightHandler=function(a){a.preventDefault();var d=c(a.target);b.addColspan(d.data("col"),d.data("row")),b.drawTable(),b.writeConfig(b.export2LayoutRecord())},this.linkShrinkLeftHandler=function(a){a.preventDefault();var d=c(a.target);b.removeColspan(d.data("col"),d.data("row")),b.drawTable(),b.writeConfig(b.export2LayoutRecord())},this.linkExpandDownHandler=function(a){a.preventDefault();var d=c(a.target);b.addRowspan(d.data("col"),d.data("row")),b.drawTable(),b.writeConfig(b.export2LayoutRecord())},this.linkShrinkUpHandler=function(a){a.preventDefault();var d=c(a.target);b.removeRowspan(d.data("col"),d.data("row")),b.drawTable(),b.writeConfig(b.export2LayoutRecord())},this.configPreviewButtonHandler=function(a){a.preventDefault();var d=c(b.selectorConfigPreview),e=c(b.selectorConfigPreviewButton);d.is(":visible")?(e.empty().append(TYPO3.lang["button.showPageTsConfig"]),c(b.selectorConfigPreview).slideUp()):(e.empty().append(TYPO3.lang["button.hidePageTsConfig"]),c(b.selectorConfigPreview).slideDown())};var e=c(this.selectorEditor);this.colCount=e.data("colcount"),this.rowCount=e.data("rowcount"),this.field=c('input[name="'+e.data("field")+'"]'),this.data=e.data("data"),this.nameLabel=null!==a?a.nameLabel:"Name",this.columnLabel=null!==a?a.columnLabel:"Column",this.targetElement=c(this.selectorEditor),c(this.selectorConfigPreview).hide(),c(this.selectorConfigPreviewButton).empty().append(TYPO3.lang["button.showPageTsConfig"]),this.initializeEvents(),this.drawTable(),this.writeConfig(this.export2LayoutRecord())}return a.stripMarkup=function(a){return a=a.replace(/<(.*)>/gi,""),c("<p>"+a+"</p>").text()},a.prototype.initializeEvents=function(){c(document).on("click",this.selectorAddColumn,this.addColumnHandler),c(document).on("click",this.selectorRemoveColumn,this.removeColumnHandler),c(document).on("click",this.selectorAddRowTop,this.addRowTopHandler),c(document).on("click",this.selectorAddRowBottom,this.addRowBottomHandler),c(document).on("click",this.selectorRemoveRowTop,this.removeRowTopHandler),c(document).on("click",this.selectorRemoveRowBottom,this.removeRowBottomHandler),c(document).on("click",this.selectorLinkEditor,this.linkEditorHandler),c(document).on("click",this.selectorLinkExpandRight,this.linkExpandRightHandler),c(document).on("click",this.selectorLinkShrinkLeft,this.linkShrinkLeftHandler),c(document).on("click",this.selectorLinkExpandDown,this.linkExpandDownHandler),c(document).on("click",this.selectorLinkShrinkUp,this.linkShrinkUpHandler),c(document).on("click",this.selectorConfigPreviewButton,this.configPreviewButtonHandler)},a.prototype.getNewCell=function(){return c.extend({},this.defaultCell)},a.prototype.writeConfig=function(a){this.field.val(a);var b=a.split("\n"),d="";try{for(var e=__values(b),f=e.next();!f.done;f=e.next()){var g=f.value;g&&(d+="\t\t\t"+g+"\n")}}catch(a){h={error:a}}finally{try{f&&!f.done&&(i=e.return)&&i.call(e)}finally{if(h)throw h.error}}c(this.selectorConfigPreview).find("code").empty().append("mod.web_layout.BackendLayouts {\n  exampleKey {\n    title = Example\n    icon = EXT:example_extension/Resources/Public/Images/BackendLayouts/default.gif\n    config {\n"+d.replace(new RegExp("\t","g"),"  ")+"    }\n  }\n}\n");var h,i},a.prototype.addRowTop=function(){for(var a=[],b=0;b<this.colCount;b++){var c=this.getNewCell();c.name=b+"x"+this.data.length,a[b]=c}this.data.unshift(a),this.rowCount++},a.prototype.addRowBottom=function(){for(var a=[],b=0;b<this.colCount;b++){var c=this.getNewCell();c.name=b+"x"+this.data.length,a[b]=c}this.data.push(a),this.rowCount++},a.prototype.removeRowTop=function(){if(this.rowCount<=1)return!1;for(var a=[],b=1;b<this.rowCount;b++)a.push(this.data[b]);for(var c=0;c<this.colCount;c++)1===this.data[0][c].spanned&&this.findUpperCellWidthRowspanAndDecreaseByOne(c,0);return this.data=a,this.rowCount--,!0},a.prototype.removeRowBottom=function(){if(this.rowCount<=1)return!1;for(var a=[],b=0;b<this.rowCount-1;b++)a.push(this.data[b]);for(var c=0;c<this.colCount;c++)1===this.data[this.rowCount-1][c].spanned&&this.findUpperCellWidthRowspanAndDecreaseByOne(c,this.rowCount-1);return this.data=a,this.rowCount--,!0},a.prototype.findUpperCellWidthRowspanAndDecreaseByOne=function(a,b){var c=this.getCell(a,b-1);return!!c&&(1===c.spanned?this.findUpperCellWidthRowspanAndDecreaseByOne(a,b-1):c.rowspan>1&&this.removeRowspan(a,b-1),!0)},a.prototype.removeColumn=function(){if(this.colCount<=1)return!1;for(var a=[],b=0;b<this.rowCount;b++){for(var c=[],d=0;d<this.colCount-1;d++)c.push(this.data[b][d]);1===this.data[b][this.colCount-1].spanned&&this.findLeftCellWidthColspanAndDecreaseByOne(this.colCount-1,b),a.push(c)}return this.data=a,this.colCount--,!0},a.prototype.findLeftCellWidthColspanAndDecreaseByOne=function(a,b){var c=this.getCell(a-1,b);return!!c&&(1===c.spanned?this.findLeftCellWidthColspanAndDecreaseByOne(a-1,b):c.colspan>1&&this.removeColspan(a-1,b),!0)},a.prototype.addColumn=function(){for(var a=0;a<this.rowCount;a++){var b=this.getNewCell();b.name=this.colCount+"x"+a,this.data[a].push(b)}this.colCount++},a.prototype.drawTable=function(){for(var b=c("<colgroup>"),d=0;d<this.colCount;d++){var e=100/this.colCount;b.append(c("<col>").css({width:parseInt(e.toString(),10)+"%"}))}var f=c('<table id="base" class="table editor">');f.append(b);for(var g=0;g<this.rowCount;g++){var h=this.data[g];if(0!==h.length){for(var i=c("<tr>"),d=0;d<this.colCount;d++){var j=this.data[g][d];if(1!==j.spanned){var k=100/this.rowCount,l=100/this.colCount,m=c("<td>").css({height:parseInt(k.toString(),10)*j.rowspan+"%",width:parseInt(l.toString(),10)*j.colspan+"%"}),n=c('<div class="cell_container">');m.append(n);var o=c('<a href="#" data-col="'+d+'" data-row="'+g+'">');n.append(o.clone().attr("class","t3js-grideditor-link-editor link link_editor").attr("title",TYPO3.lang.grid_editCell)),this.cellCanSpanRight(d,g)&&n.append(o.clone().attr("class","t3js-grideditor-link-expand-right link link_expand_right").attr("title",TYPO3.lang.grid_mergeCell)),this.cellCanShrinkLeft(d,g)&&n.append(o.clone().attr("class","t3js-grideditor-link-shrink-left link link_shrink_left").attr("title",TYPO3.lang.grid_splitCell)),this.cellCanSpanDown(d,g)&&n.append(o.clone().attr("class","t3js-grideditor-link-expand-down link link_expand_down").attr("title",TYPO3.lang.grid_mergeCell)),this.cellCanShrinkUp(d,g)&&n.append(o.clone().attr("class","t3js-grideditor-link-shrink-up link link_shrink_up").attr("title",TYPO3.lang.grid_splitCell)),m.append(c('<div class="cell_data">').html(TYPO3.lang.grid_name+": "+(j.name?a.stripMarkup(j.name):TYPO3.lang.grid_notSet)+"<br />"+TYPO3.lang.grid_column+": "+("undefined"==typeof j.column||isNaN(j.column)?TYPO3.lang.grid_notSet:parseInt(j.column,10)))),j.colspan>1&&m.attr("colspan",j.colspan),j.rowspan>1&&m.attr("rowspan",j.rowspan),i.append(m)}}f.append(i)}}c(this.targetElement).empty().append(f)},a.prototype.setName=function(b,c,d){var e=this.getCell(c,d);return!!e&&(e.name=a.stripMarkup(b),!0)},a.prototype.setColumn=function(a,b,c){var d=this.getCell(b,c);return!!d&&(d.column=parseInt(a.toString(),10),!0)},a.prototype.showOptions=function(b,f){var g=this.getCell(b,f);if(!g)return!1;var h;h=0===g.column?0:g.column?parseInt(g.column.toString(),10):"";var i=c("<div>"),j=c('<div class="form-group">'),k=c("<label>"),l=c("<input>");i.append([j.clone().append([k.clone().text(TYPO3.lang.grid_nameHelp),l.clone().attr("type","text").attr("class","t3js-grideditor-field-name form-control").attr("name","name").val(a.stripMarkup(g.name)||"")]),j.clone().append([k.clone().text(TYPO3.lang.grid_columnHelp),l.clone().attr("type","text").attr("class","t3js-grideditor-field-colpos form-control").attr("name","column").val(h)])]);var m=d.show(TYPO3.lang.grid_windowTitle,i,e.notice,[{active:!0,btnClass:"btn-default",name:"cancel",text:c(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel"},{btnClass:"btn-primary",name:"ok",text:c(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK"}]);return m.data("col",b),m.data("row",f),m.on("button.clicked",this.modalButtonClickHandler),!0},a.prototype.getCell=function(a,b){return!(a>this.colCount-1)&&(!(b>this.rowCount-1)&&(this.data.length>b-1&&this.data[b].length>a-1?this.data[b][a]:null))},a.prototype.cellCanSpanRight=function(a,b){if(a===this.colCount-1)return!1;var c,d=this.getCell(a,b);if(d.rowspan>1){for(var e=b;e<b+d.rowspan;e++)if(c=this.getCell(a+d.colspan,e),!c||1===c.spanned||c.colspan>1||c.rowspan>1)return!1}else if(c=this.getCell(a+d.colspan,b),!c||1===d.spanned||1===c.spanned||c.colspan>1||c.rowspan>1)return!1;return!0},a.prototype.cellCanSpanDown=function(a,b){if(b===this.rowCount-1)return!1;var c,d=this.getCell(a,b);if(d.colspan>1){for(var e=a;e<a+d.colspan;e++)if(c=this.getCell(e,b+d.rowspan),!c||1===c.spanned||c.colspan>1||c.rowspan>1)return!1}else if(c=this.getCell(a,b+d.rowspan),!c||1===d.spanned||1===c.spanned||c.colspan>1||c.rowspan>1)return!1;return!0},a.prototype.cellCanShrinkLeft=function(a,b){return this.data[b][a].colspan>1},a.prototype.cellCanShrinkUp=function(a,b){return this.data[b][a].rowspan>1},a.prototype.addColspan=function(a,b){var c=this.getCell(a,b);if(!c||!this.cellCanSpanRight(a,b))return!1;for(var d=b;d<b+c.rowspan;d++)this.data[d][a+c.colspan].spanned=1;return c.colspan+=1,!0},a.prototype.addRowspan=function(a,b){var c=this.getCell(a,b);if(!c||!this.cellCanSpanDown(a,b))return!1;for(var d=a;d<a+c.colspan;d++)this.data[b+c.rowspan][d].spanned=1;return c.rowspan+=1,!0},a.prototype.removeColspan=function(a,b){var c=this.getCell(a,b);if(!c||!this.cellCanShrinkLeft(a,b))return!1;c.colspan-=1;for(var d=b;d<b+c.rowspan;d++)this.data[d][a+c.colspan].spanned=0;return!0},a.prototype.removeRowspan=function(a,b){var c=this.getCell(a,b);if(!c||!this.cellCanShrinkUp(a,b))return!1;c.rowspan-=1;for(var d=a;d<a+c.colspan;d++)this.data[b+c.rowspan][d].spanned=0;return!0},a.prototype.export2LayoutRecord=function(){for(var a="backend_layout {\n\tcolCount = "+this.colCount+"\n\trowCount = "+this.rowCount+"\n\trows {\n",b=0;b<this.rowCount;b++){a+="\t\t"+(b+1)+" {\n",a+="\t\t\tcolumns {\n";for(var c=0,d=0;d<this.colCount;d++){var e=this.getCell(d,b);e&&(e.spanned||(c++,a+="\t\t\t\t"+c+" {\n",a+="\t\t\t\t\tname = "+(e.name?e.name:d+"x"+b)+"\n",e.colspan>1&&(a+="\t\t\t\t\tcolspan = "+e.colspan+"\n"),e.rowspan>1&&(a+="\t\t\t\t\trowspan = "+e.rowspan+"\n"),"number"==typeof e.column&&(a+="\t\t\t\t\tcolPos = "+e.column+"\n"),a+="\t\t\t\t}\n"))}a+="\t\t\t}\n",a+="\t\t}\n"}return a+="\t}\n}\n"},a}();b.GridEditor=f});
\ No newline at end of file
+var __values=this&&this.__values||function(a){var b="function"==typeof Symbol&&a[Symbol.iterator],c=0;return b?b.call(a):{next:function(){return a&&c>=a.length&&(a=void 0),{value:a&&a[c++],done:!a}}}};define(["require","exports","./Enum/Severity","jquery","./Modal","bootstrap"],function(a,b,c,d,e){"use strict";Object.defineProperty(b,"__esModule",{value:!0});var f=function(){function a(a){void 0===a&&(a=null);var b=this;this.colCount=1,this.rowCount=1,this.nameLabel="name",this.columnLabel="columen label",this.defaultCell={spanned:0,rowspan:1,colspan:1,name:"",colpos:"",column:void 0},this.selectorEditor=".t3js-grideditor",this.selectorAddColumn=".t3js-grideditor-addcolumn",this.selectorRemoveColumn=".t3js-grideditor-removecolumn",this.selectorAddRowTop=".t3js-grideditor-addrow-top",this.selectorRemoveRowTop=".t3js-grideditor-removerow-top",this.selectorAddRowBottom=".t3js-grideditor-addrow-bottom",this.selectorRemoveRowBottom=".t3js-grideditor-removerow-bottom",this.selectorLinkEditor=".t3js-grideditor-link-editor",this.selectorLinkExpandRight=".t3js-grideditor-link-expand-right",this.selectorLinkShrinkLeft=".t3js-grideditor-link-shrink-left",this.selectorLinkExpandDown=".t3js-grideditor-link-expand-down",this.selectorLinkShrinkUp=".t3js-grideditor-link-shrink-up",this.selectorDocHeaderSave=".t3js-grideditor-savedok",this.selectorDocHeaderSaveClose=".t3js-grideditor-savedokclose",this.selectorConfigPreview=".t3js-grideditor-preview-config",this.selectorConfigPreviewButton=".t3js-grideditor-preview-button",this.modalButtonClickHandler=function(a){var c=a.target;"cancel"===c.name?e.currentModal.trigger("modal-dismiss"):"ok"===c.name&&(b.setName(e.currentModal.find(".t3js-grideditor-field-name").val(),e.currentModal.data("col"),e.currentModal.data("row")),b.setColumn(e.currentModal.find(".t3js-grideditor-field-colpos").val(),e.currentModal.data("col"),e.currentModal.data("row")),b.drawTable(),b.writeConfig(b.export2LayoutRecord()),e.currentModal.trigger("modal-dismiss"))},this.addColumnHandler=function(a){a.preventDefault(),b.addColumn(),b.drawTable(),b.writeConfig(b.export2LayoutRecord())},this.removeColumnHandler=function(a){a.preventDefault(),b.removeColumn(),b.drawTable(),b.writeConfig(b.export2LayoutRecord())},this.addRowTopHandler=function(a){a.preventDefault(),b.addRowTop(),b.drawTable(),b.writeConfig(b.export2LayoutRecord())},this.addRowBottomHandler=function(a){a.preventDefault(),b.addRowBottom(),b.drawTable(),b.writeConfig(b.export2LayoutRecord())},this.removeRowTopHandler=function(a){a.preventDefault(),b.removeRowTop(),b.drawTable(),b.writeConfig(b.export2LayoutRecord())},this.removeRowBottomHandler=function(a){a.preventDefault(),b.removeRowBottom(),b.drawTable(),b.writeConfig(b.export2LayoutRecord())},this.linkEditorHandler=function(a){a.preventDefault();var c=d(a.target);b.showOptions(c.data("col"),c.data("row"))},this.linkExpandRightHandler=function(a){a.preventDefault();var c=d(a.target);b.addColspan(c.data("col"),c.data("row")),b.drawTable(),b.writeConfig(b.export2LayoutRecord())},this.linkShrinkLeftHandler=function(a){a.preventDefault();var c=d(a.target);b.removeColspan(c.data("col"),c.data("row")),b.drawTable(),b.writeConfig(b.export2LayoutRecord())},this.linkExpandDownHandler=function(a){a.preventDefault();var c=d(a.target);b.addRowspan(c.data("col"),c.data("row")),b.drawTable(),b.writeConfig(b.export2LayoutRecord())},this.linkShrinkUpHandler=function(a){a.preventDefault();var c=d(a.target);b.removeRowspan(c.data("col"),c.data("row")),b.drawTable(),b.writeConfig(b.export2LayoutRecord())},this.configPreviewButtonHandler=function(a){a.preventDefault();var c=d(b.selectorConfigPreview),e=d(b.selectorConfigPreviewButton);c.is(":visible")?(e.empty().append(TYPO3.lang["button.showPageTsConfig"]),d(b.selectorConfigPreview).slideUp()):(e.empty().append(TYPO3.lang["button.hidePageTsConfig"]),d(b.selectorConfigPreview).slideDown())};var c=d(this.selectorEditor);this.colCount=c.data("colcount"),this.rowCount=c.data("rowcount"),this.field=d('input[name="'+c.data("field")+'"]'),this.data=c.data("data"),this.nameLabel=null!==a?a.nameLabel:"Name",this.columnLabel=null!==a?a.columnLabel:"Column",this.targetElement=d(this.selectorEditor),d(this.selectorConfigPreview).hide(),d(this.selectorConfigPreviewButton).empty().append(TYPO3.lang["button.showPageTsConfig"]),this.initializeEvents(),this.drawTable(),this.writeConfig(this.export2LayoutRecord())}return a.stripMarkup=function(a){return a=a.replace(/<(.*)>/gi,""),d("<p>"+a+"</p>").text()},a.prototype.initializeEvents=function(){d(document).on("click",this.selectorAddColumn,this.addColumnHandler),d(document).on("click",this.selectorRemoveColumn,this.removeColumnHandler),d(document).on("click",this.selectorAddRowTop,this.addRowTopHandler),d(document).on("click",this.selectorAddRowBottom,this.addRowBottomHandler),d(document).on("click",this.selectorRemoveRowTop,this.removeRowTopHandler),d(document).on("click",this.selectorRemoveRowBottom,this.removeRowBottomHandler),d(document).on("click",this.selectorLinkEditor,this.linkEditorHandler),d(document).on("click",this.selectorLinkExpandRight,this.linkExpandRightHandler),d(document).on("click",this.selectorLinkShrinkLeft,this.linkShrinkLeftHandler),d(document).on("click",this.selectorLinkExpandDown,this.linkExpandDownHandler),d(document).on("click",this.selectorLinkShrinkUp,this.linkShrinkUpHandler),d(document).on("click",this.selectorConfigPreviewButton,this.configPreviewButtonHandler)},a.prototype.getNewCell=function(){return d.extend({},this.defaultCell)},a.prototype.writeConfig=function(a){this.field.val(a);var b=a.split("\n"),c="";try{for(var e=__values(b),f=e.next();!f.done;f=e.next()){var g=f.value;g&&(c+="\t\t\t"+g+"\n")}}catch(a){h={error:a}}finally{try{f&&!f.done&&(i=e.return)&&i.call(e)}finally{if(h)throw h.error}}d(this.selectorConfigPreview).find("code").empty().append("mod.web_layout.BackendLayouts {\n  exampleKey {\n    title = Example\n    icon = EXT:example_extension/Resources/Public/Images/BackendLayouts/default.gif\n    config {\n"+c.replace(new RegExp("\t","g"),"  ")+"    }\n  }\n}\n");var h,i},a.prototype.addRowTop=function(){for(var a=[],b=0;b<this.colCount;b++){var c=this.getNewCell();c.name=b+"x"+this.data.length,a[b]=c}this.data.unshift(a),this.rowCount++},a.prototype.addRowBottom=function(){for(var a=[],b=0;b<this.colCount;b++){var c=this.getNewCell();c.name=b+"x"+this.data.length,a[b]=c}this.data.push(a),this.rowCount++},a.prototype.removeRowTop=function(){if(this.rowCount<=1)return!1;for(var a=[],b=1;b<this.rowCount;b++)a.push(this.data[b]);for(var c=0;c<this.colCount;c++)1===this.data[0][c].spanned&&this.findUpperCellWidthRowspanAndDecreaseByOne(c,0);return this.data=a,this.rowCount--,!0},a.prototype.removeRowBottom=function(){if(this.rowCount<=1)return!1;for(var a=[],b=0;b<this.rowCount-1;b++)a.push(this.data[b]);for(var c=0;c<this.colCount;c++)1===this.data[this.rowCount-1][c].spanned&&this.findUpperCellWidthRowspanAndDecreaseByOne(c,this.rowCount-1);return this.data=a,this.rowCount--,!0},a.prototype.findUpperCellWidthRowspanAndDecreaseByOne=function(a,b){var c=this.getCell(a,b-1);return!!c&&(1===c.spanned?this.findUpperCellWidthRowspanAndDecreaseByOne(a,b-1):c.rowspan>1&&this.removeRowspan(a,b-1),!0)},a.prototype.removeColumn=function(){if(this.colCount<=1)return!1;for(var a=[],b=0;b<this.rowCount;b++){for(var c=[],d=0;d<this.colCount-1;d++)c.push(this.data[b][d]);1===this.data[b][this.colCount-1].spanned&&this.findLeftCellWidthColspanAndDecreaseByOne(this.colCount-1,b),a.push(c)}return this.data=a,this.colCount--,!0},a.prototype.findLeftCellWidthColspanAndDecreaseByOne=function(a,b){var c=this.getCell(a-1,b);return!!c&&(1===c.spanned?this.findLeftCellWidthColspanAndDecreaseByOne(a-1,b):c.colspan>1&&this.removeColspan(a-1,b),!0)},a.prototype.addColumn=function(){for(var a=0;a<this.rowCount;a++){var b=this.getNewCell();b.name=this.colCount+"x"+a,this.data[a].push(b)}this.colCount++},a.prototype.drawTable=function(){for(var b=d("<colgroup>"),c=0;c<this.colCount;c++){var e=100/this.colCount;b.append(d("<col>").css({width:parseInt(e.toString(),10)+"%"}))}var f=d('<table id="base" class="table editor">');f.append(b);for(var g=0;g<this.rowCount;g++){var h=this.data[g];if(0!==h.length){for(var i=d("<tr>"),c=0;c<this.colCount;c++){var j=this.data[g][c];if(1!==j.spanned){var k=100/this.rowCount,l=100/this.colCount,m=d("<td>").css({height:parseInt(k.toString(),10)*j.rowspan+"%",width:parseInt(l.toString(),10)*j.colspan+"%"}),n=d('<div class="cell_container">');m.append(n);var o=d('<a href="#" data-col="'+c+'" data-row="'+g+'">');n.append(o.clone().attr("class","t3js-grideditor-link-editor link link_editor").attr("title",TYPO3.lang.grid_editCell)),this.cellCanSpanRight(c,g)&&n.append(o.clone().attr("class","t3js-grideditor-link-expand-right link link_expand_right").attr("title",TYPO3.lang.grid_mergeCell)),this.cellCanShrinkLeft(c,g)&&n.append(o.clone().attr("class","t3js-grideditor-link-shrink-left link link_shrink_left").attr("title",TYPO3.lang.grid_splitCell)),this.cellCanSpanDown(c,g)&&n.append(o.clone().attr("class","t3js-grideditor-link-expand-down link link_expand_down").attr("title",TYPO3.lang.grid_mergeCell)),this.cellCanShrinkUp(c,g)&&n.append(o.clone().attr("class","t3js-grideditor-link-shrink-up link link_shrink_up").attr("title",TYPO3.lang.grid_splitCell)),m.append(d('<div class="cell_data">').html(TYPO3.lang.grid_name+": "+(j.name?a.stripMarkup(j.name):TYPO3.lang.grid_notSet)+"<br />"+TYPO3.lang.grid_column+": "+("undefined"==typeof j.column||isNaN(j.column)?TYPO3.lang.grid_notSet:parseInt(j.column,10)))),j.colspan>1&&m.attr("colspan",j.colspan),j.rowspan>1&&m.attr("rowspan",j.rowspan),i.append(m)}}f.append(i)}}d(this.targetElement).empty().append(f)},a.prototype.setName=function(b,c,d){var e=this.getCell(c,d);return!!e&&(e.name=a.stripMarkup(b),!0)},a.prototype.setColumn=function(a,b,c){var d=this.getCell(b,c);return!!d&&(d.column=parseInt(a.toString(),10),!0)},a.prototype.showOptions=function(b,f){var g=this.getCell(b,f);if(!g)return!1;var h;h=0===g.column?0:g.column?parseInt(g.column.toString(),10):"";var i=d("<div>"),j=d('<div class="form-group">'),k=d("<label>"),l=d("<input>");i.append([j.clone().append([k.clone().text(TYPO3.lang.grid_nameHelp),l.clone().attr("type","text").attr("class","t3js-grideditor-field-name form-control").attr("name","name").val(a.stripMarkup(g.name)||"")]),j.clone().append([k.clone().text(TYPO3.lang.grid_columnHelp),l.clone().attr("type","text").attr("class","t3js-grideditor-field-colpos form-control").attr("name","column").val(h)])]);var m=e.show(TYPO3.lang.grid_windowTitle,i,c.SeverityEnum.notice,[{active:!0,btnClass:"btn-default",name:"cancel",text:d(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel"},{btnClass:"btn-primary",name:"ok",text:d(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK"}]);return m.data("col",b),m.data("row",f),m.on("button.clicked",this.modalButtonClickHandler),!0},a.prototype.getCell=function(a,b){return!(a>this.colCount-1)&&(!(b>this.rowCount-1)&&(this.data.length>b-1&&this.data[b].length>a-1?this.data[b][a]:null))},a.prototype.cellCanSpanRight=function(a,b){if(a===this.colCount-1)return!1;var c,d=this.getCell(a,b);if(d.rowspan>1){for(var e=b;e<b+d.rowspan;e++)if(c=this.getCell(a+d.colspan,e),!c||1===c.spanned||c.colspan>1||c.rowspan>1)return!1}else if(c=this.getCell(a+d.colspan,b),!c||1===d.spanned||1===c.spanned||c.colspan>1||c.rowspan>1)return!1;return!0},a.prototype.cellCanSpanDown=function(a,b){if(b===this.rowCount-1)return!1;var c,d=this.getCell(a,b);if(d.colspan>1){for(var e=a;e<a+d.colspan;e++)if(c=this.getCell(e,b+d.rowspan),!c||1===c.spanned||c.colspan>1||c.rowspan>1)return!1}else if(c=this.getCell(a,b+d.rowspan),!c||1===d.spanned||1===c.spanned||c.colspan>1||c.rowspan>1)return!1;return!0},a.prototype.cellCanShrinkLeft=function(a,b){return this.data[b][a].colspan>1},a.prototype.cellCanShrinkUp=function(a,b){return this.data[b][a].rowspan>1},a.prototype.addColspan=function(a,b){var c=this.getCell(a,b);if(!c||!this.cellCanSpanRight(a,b))return!1;for(var d=b;d<b+c.rowspan;d++)this.data[d][a+c.colspan].spanned=1;return c.colspan+=1,!0},a.prototype.addRowspan=function(a,b){var c=this.getCell(a,b);if(!c||!this.cellCanSpanDown(a,b))return!1;for(var d=a;d<a+c.colspan;d++)this.data[b+c.rowspan][d].spanned=1;return c.rowspan+=1,!0},a.prototype.removeColspan=function(a,b){var c=this.getCell(a,b);if(!c||!this.cellCanShrinkLeft(a,b))return!1;c.colspan-=1;for(var d=b;d<b+c.rowspan;d++)this.data[d][a+c.colspan].spanned=0;return!0},a.prototype.removeRowspan=function(a,b){var c=this.getCell(a,b);if(!c||!this.cellCanShrinkUp(a,b))return!1;c.rowspan-=1;for(var d=a;d<a+c.colspan;d++)this.data[b+c.rowspan][d].spanned=0;return!0},a.prototype.export2LayoutRecord=function(){for(var a="backend_layout {\n\tcolCount = "+this.colCount+"\n\trowCount = "+this.rowCount+"\n\trows {\n",b=0;b<this.rowCount;b++){a+="\t\t"+(b+1)+" {\n",a+="\t\t\tcolumns {\n";for(var c=0,d=0;d<this.colCount;d++){var e=this.getCell(d,b);e&&(e.spanned||(c++,a+="\t\t\t\t"+c+" {\n",a+="\t\t\t\t\tname = "+(e.name?e.name:d+"x"+b)+"\n",e.colspan>1&&(a+="\t\t\t\t\tcolspan = "+e.colspan+"\n"),e.rowspan>1&&(a+="\t\t\t\t\trowspan = "+e.rowspan+"\n"),"number"==typeof e.column&&(a+="\t\t\t\t\tcolPos = "+e.column+"\n"),a+="\t\t\t\t}\n"))}a+="\t\t\t}\n",a+="\t\t}\n"}return a+="\t}\n}\n"},a}();b.GridEditor=f});
\ No newline at end of file
index 58ad95a..efb6c05 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","jquery","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Core/Contrib/imagesloaded.pkgd.min","jquery-ui/draggable","jquery-ui/resizable"],function(a,b,c,d,e){"use strict";var f=function(){function a(){var b=this;this.cropImageContainerSelector="#t3js-crop-image-container",this.cropImageSelector="#t3js-crop-image",this.coverAreaSelector=".t3js-cropper-cover-area",this.cropInfoSelector=".t3js-cropper-info-crop",this.focusAreaSelector="#t3js-cropper-focus-area",this.defaultFocusArea={height:1/3,width:1/3,x:0,y:0},this.defaultOpts={autoCrop:!0,autoCropArea:"0.7",dragMode:"crop",guides:!0,responsive:!0,viewMode:1,zoomable:!1},this.resizeTimeout=450,this.cropBuiltHandler=function(){var d=b.cropper.cropper("getImageData"),e=b.currentModal.find(b.cropImageSelector);b.imageOriginalSizeFactor=e.data("originalWidth")/d.naturalWidth,b.cropVariantTriggers.each(function(a,e){var f=c(e).attr("data-crop-variant-id"),g=b.convertRelativeToAbsoluteCropArea(b.data[f].cropArea,d),h=c.extend(!0,{},b.data[f],{cropArea:g});b.updatePreviewThumbnail(h,c(e))}),b.currentCropVariant.cropArea=b.convertRelativeToAbsoluteCropArea(b.currentCropVariant.cropArea,d),b.cropBox=b.currentModal.find(".cropper-crop-box"),b.setCropArea(b.currentCropVariant.cropArea),b.currentCropVariant.coverAreas&&b.initCoverAreas(b.cropBox,b.currentCropVariant.coverAreas),b.currentCropVariant.focusArea&&(a.isEmptyArea(b.currentCropVariant.focusArea)&&(b.currentCropVariant.focusArea=c.extend(!0,{},b.defaultFocusArea)),b.initFocusArea(b.cropBox),b.scaleAndMoveFocusArea(b.currentCropVariant.focusArea)),b.currentCropVariant.selectedRatio&&(b.setAspectRatio(b.currentCropVariant.allowedAspectRatios[b.currentCropVariant.selectedRatio]),b.setCropArea(b.currentCropVariant.cropArea),b.currentModal.find("[data-option='"+b.currentCropVariant.selectedRatio+"']").addClass("active")),b.cropperCanvas.addClass("is-visible")},this.cropMoveHandler=function(a){b.currentCropVariant.cropArea=c.extend(!0,b.currentCropVariant.cropArea,{height:Math.floor(a.height),width:Math.floor(a.width),x:Math.floor(a.x),y:Math.floor(a.y)}),b.updatePreviewThumbnail(b.currentCropVariant,b.activeCropVariantTrigger),b.updateCropVariantData(b.currentCropVariant);var d=Math.round(b.currentCropVariant.cropArea.width*b.imageOriginalSizeFactor),e=Math.round(b.currentCropVariant.cropArea.height*b.imageOriginalSizeFactor);b.cropInfo.text(d+"×"+e+" px")},this.cropStartHandler=function(){b.currentCropVariant.focusArea&&(b.focusArea.draggable("option","disabled",!0),b.focusArea.resizable("option","disabled",!0))},this.cropEndHandler=function(){b.currentCropVariant.focusArea&&(b.focusArea.draggable("option","disabled",!1),b.focusArea.resizable("option","disabled",!1))},c(window).resize(function(){b.cropper&&b.cropper.cropper("destroy")}),this.resizeEnd(function(){b.cropper&&b.init()})}return a.isEmptyArea=function(a){return c.isEmptyObject(a)},a.wait=function(a,b){window.setTimeout(a,b)},a.toCssPercent=function(a){return 100*a+"%"},a.serializeCropVariants=function(a){var b=function(a,b){return"id"===a||"title"===a||"allowedAspectRatios"===a||"coverAreas"===a?void 0:b};return JSON.stringify(a,b)},a.prototype.initializeTrigger=function(){var a=this,b=function(b){b.preventDefault(),a.trigger=c(b.currentTarget),a.show()};c(".t3js-image-manipulation-trigger").off("click").click(b)},a.prototype.initializeCropperModal=function(){var a=this,b=this.currentModal.find(this.cropImageSelector);e(b,function(){setTimeout(function(){a.init()},100)})},a.prototype.show=function(){var a=this,b=this.trigger.data("modalTitle"),c=this.trigger.data("buttonPreviewText"),e=this.trigger.data("buttonDismissText"),f=this.trigger.data("buttonSaveText"),g=this.trigger.data("url"),h=this.initializeCropperModal.bind(this);this.currentModal=d.advanced({additionalCssClasses:["modal-image-manipulation"],ajaxCallback:h,buttons:[{btnClass:"btn-default pull-left",dataAttributes:{method:"preview"},icon:"actions-view",text:c},{btnClass:"btn-default",dataAttributes:{method:"dismiss"},icon:"actions-close",text:e},{btnClass:"btn-primary",dataAttributes:{method:"save"},icon:"actions-document-save",text:f}],callback:function(a){a.find(".t3js-modal-body").addClass("cropper")},content:g,size:d.sizes.full,style:d.styles.dark,title:b,type:"ajax"}),this.currentModal.on("hide.bs.modal",function(b){a.destroy()}),this.currentModal.data("bs.modal").options.backdrop="static"},a.prototype.init=function(){var b=this,d=this.currentModal.find(this.cropImageSelector),e=c(d).height(),f=c(d).width(),g=this.trigger.attr("data-crop-variants");if(!g)throw new TypeError("ImageManipulation: No cropVariants data found for image");this.data=c.isEmptyObject(this.data)?JSON.parse(g):this.data,this.currentModal.find(this.cropImageContainerSelector).css({height:e,width:f}),this.cropVariantTriggers=this.currentModal.find(".t3js-crop-variant-trigger"),this.activeCropVariantTrigger=this.currentModal.find(".t3js-crop-variant-trigger.is-active"),this.cropInfo=this.currentModal.find(this.cropInfoSelector),this.saveButton=this.currentModal.find("[data-method=save]"),this.previewButton=this.currentModal.find("[data-method=preview]"),this.dismissButton=this.currentModal.find("[data-method=dismiss]"),this.resetButton=this.currentModal.find("[data-method=reset]"),this.cropperCanvas=this.currentModal.find("#js-crop-canvas"),this.aspectRatioTrigger=this.currentModal.find("[data-method=setAspectRatio]"),this.currentCropVariant=this.data[this.activeCropVariantTrigger.attr("data-crop-variant-id")],this.cropVariantTriggers.off("click").on("click",function(a){if(c(a.currentTarget).hasClass("is-active"))return a.stopPropagation(),void a.preventDefault();b.activeCropVariantTrigger.removeClass("is-active"),c(a.currentTarget).addClass("is-active"),b.activeCropVariantTrigger=c(a.currentTarget);var d=b.data[b.activeCropVariantTrigger.attr("data-crop-variant-id")],e=b.cropper.cropper("getImageData");d.cropArea=b.convertRelativeToAbsoluteCropArea(d.cropArea,e),b.currentCropVariant=c.extend(!0,{},d),b.update(d)}),this.aspectRatioTrigger.off("click").on("click",function(a){var d=c(a.currentTarget).attr("data-option"),e=c.extend(!0,{},b.currentCropVariant),f=e.allowedAspectRatios[d];b.setAspectRatio(f),b.setCropArea(e.cropArea),b.currentCropVariant=c.extend(!0,{},e,{selectedRatio:d}),b.update(b.currentCropVariant)}),this.saveButton.off("click").on("click",function(){b.save(b.data)}),this.trigger.attr("data-preview-url")?this.previewButton.off("click").on("click",function(){b.openPreview(b.data)}):this.previewButton.hide(),this.dismissButton.off("click").on("click",function(){b.currentModal.modal("hide")}),this.resetButton.off("click").on("click",function(a){var d=b.cropper.cropper("getImageData"),e=c(a.currentTarget).attr("data-crop-variant");if(a.preventDefault(),a.stopPropagation(),!e)throw new TypeError("TYPO3 Cropper: No cropVariant data attribute found on reset element.");var f=JSON.parse(e),g=b.convertRelativeToAbsoluteCropArea(f.cropArea,d);b.currentCropVariant=c.extend(!0,{},f,{cropArea:g}),b.update(b.currentCropVariant)}),a.isEmptyArea(this.currentCropVariant.cropArea)&&(this.defaultOpts=c.extend({autoCropArea:1},this.defaultOpts)),this.cropper=top.$(d).cropper(c.extend(this.defaultOpts,{built:this.cropBuiltHandler,crop:this.cropMoveHandler,cropend:this.cropEndHandler,cropstart:this.cropStartHandler,data:this.currentCropVariant.cropArea}))},a.prototype.update=function(b){var d=c.extend(!0,{},b),e=b.allowedAspectRatios[b.selectedRatio];this.currentModal.find("[data-option]").removeClass("active"),this.currentModal.find('[data-option="'+b.selectedRatio+'"]').addClass("active"),this.setAspectRatio(e),this.setCropArea(d.cropArea),this.currentCropVariant=c.extend(!0,{},d,b),this.cropBox.find(this.coverAreaSelector).remove(),this.cropBox.has(this.focusAreaSelector).length&&(this.focusArea.resizable("destroy").draggable("destroy"),this.focusArea.remove()),b.focusArea&&(a.isEmptyArea(b.focusArea)&&(this.currentCropVariant.focusArea=c.extend(!0,{},this.defaultFocusArea)),this.initFocusArea(this.cropBox),this.scaleAndMoveFocusArea(this.currentCropVariant.focusArea)),b.coverAreas&&this.initCoverAreas(this.cropBox,this.currentCropVariant.coverAreas),this.updatePreviewThumbnail(this.currentCropVariant,this.activeCropVariantTrigger)},a.prototype.initFocusArea=function(b){var d=this;this.focusArea=c('<div id="t3js-cropper-focus-area" class="cropper-focus-area"></div>'),b.append(this.focusArea),this.focusArea.draggable({containment:b,create:function(){d.scaleAndMoveFocusArea(d.currentCropVariant.focusArea)},drag:function(){var a=b.offset(),c=a.left,e=a.top,f=d.focusArea.offset(),g=f.left,h=f.top,i=d.currentCropVariant,j=i.focusArea,k=i.coverAreas;j.x=(g-c)/b.width(),j.y=(h-e)/b.height(),d.updatePreviewThumbnail(d.currentCropVariant,d.activeCropVariantTrigger),d.checkFocusAndCoverAreasCollision(j,k)?d.focusArea.addClass("has-nodrop"):d.focusArea.removeClass("has-nodrop")},revert:function(){var c=250,e=b.offset(),f=e.left,g=e.top,h=d.focusArea.offset(),i=h.left,j=h.top,k=d.currentCropVariant,l=k.focusArea,m=k.coverAreas;return!!d.checkFocusAndCoverAreasCollision(l,m)&&(d.focusArea.removeClass("has-nodrop"),a.wait(function(){l.x=(i-f)/b.width(),l.y=(j-g)/b.height(),d.updateCropVariantData(d.currentCropVariant)},c),!0)},revertDuration:200,stop:function(){var a=b.offset(),c=a.left,e=a.top,f=d.focusArea.offset(),g=f.left,h=f.top,i=d.currentCropVariant.focusArea;i.x=(g-c)/b.width(),i.y=(h-e)/b.height(),d.scaleAndMoveFocusArea(i)}}).resizable({containment:b,handles:"all",resize:function(){var a=b.offset(),c=a.left,e=a.top,f=d.focusArea.offset(),g=f.left,h=f.top,i=d.currentCropVariant,j=i.focusArea,k=i.coverAreas;j.height=d.focusArea.height()/b.height(),j.width=d.focusArea.width()/b.width(),j.x=(g-c)/b.width(),j.y=(h-e)/b.height(),d.updatePreviewThumbnail(d.currentCropVariant,d.activeCropVariantTrigger),d.checkFocusAndCoverAreasCollision(j,k)?d.focusArea.addClass("has-nodrop"):d.focusArea.removeClass("has-nodrop")},stop:function(a,e){var f=250,g=b.offset(),h=g.left,i=g.top,j=d.focusArea.offset(),k=j.left,l=j.top,m=d.currentCropVariant,n=m.focusArea,o=m.coverAreas;d.checkFocusAndCoverAreasCollision(n,o)?e.element.animate(c.extend(e.originalPosition,e.originalSize),f,function(){n.height=d.focusArea.height()/b.height(),n.height=d.focusArea.height()/b.height(),n.width=d.focusArea.width()/b.width(),n.x=(k-h)/b.width(),n.y=(l-i)/b.height(),d.scaleAndMoveFocusArea(n),d.focusArea.removeClass("has-nodrop")}):d.scaleAndMoveFocusArea(n)}})},a.prototype.initCoverAreas=function(b,d){d.forEach(function(d){var e=c('<div class="cropper-cover-area t3js-cropper-cover-area"></div>');b.append(e),e.css({height:a.toCssPercent(d.height),left:a.toCssPercent(d.x),top:a.toCssPercent(d.y),width:a.toCssPercent(d.width)})})},a.prototype.updatePreviewThumbnail=function(b,c){var d,e=c.find(".t3js-cropper-preview-thumbnail-crop-area"),f=c.find(".t3js-cropper-preview-thumbnail-crop-image"),g=c.find(".t3js-cropper-preview-thumbnail-focus-area"),h=this.cropper.cropper("getImageData");e.css({height:a.toCssPercent(b.cropArea.height/h.naturalHeight),left:a.toCssPercent(b.cropArea.x/h.naturalWidth),top:a.toCssPercent(b.cropArea.y/h.naturalHeight),width:a.toCssPercent(b.cropArea.width/h.naturalWidth)}),b.focusArea&&g.css({height:a.toCssPercent(b.focusArea.height),left:a.toCssPercent(b.focusArea.x),top:a.toCssPercent(b.focusArea.y),width:a.toCssPercent(b.focusArea.width)}),d=e.css(["width","height","left","top"]),f.css({height:parseFloat(d.height)*(1/(b.cropArea.height/h.naturalHeight))+"px",margin:-1*parseFloat(d.left)+"px",marginTop:-1*parseFloat(d.top)+"px",width:parseFloat(d.width)*(1/(b.cropArea.width/h.naturalWidth))+"px"})},a.prototype.scaleAndMoveFocusArea=function(b){this.focusArea.css({height:a.toCssPercent(b.height),left:a.toCssPercent(b.x),top:a.toCssPercent(b.y),width:a.toCssPercent(b.width)}),this.currentCropVariant.focusArea=b,this.updatePreviewThumbnail(this.currentCropVariant,this.activeCropVariantTrigger),this.updateCropVariantData(this.currentCropVariant)},a.prototype.updateCropVariantData=function(a){var b=this.cropper.cropper("getImageData"),d=this.convertAbsoluteToRelativeCropArea(a.cropArea,b);this.data[a.id]=c.extend(!0,{},a,{cropArea:d})},a.prototype.setAspectRatio=function(a){this.cropper.cropper("setAspectRatio",a.value)},a.prototype.setCropArea=function(a){var b=this.currentCropVariant.allowedAspectRatios[this.currentCropVariant.selectedRatio];0===b.value?this.cropper.cropper("setData",{height:a.height,width:a.width,x:a.x,y:a.y}):this.cropper.cropper("setData",{height:a.height,x:a.x,y:a.y})},a.prototype.checkFocusAndCoverAreasCollision=function(a,b){return!!b&&b.some(function(b){return a.x<b.x+b.width&&a.x+a.width>b.x&&a.y<b.y+b.height&&a.height+a.y>b.y})},a.prototype.convertAbsoluteToRelativeCropArea=function(a,b){var c=a.height,d=a.width,e=a.x,f=a.y;return{height:c/b.naturalHeight,width:d/b.naturalWidth,x:e/b.naturalWidth,y:f/b.naturalHeight}},a.prototype.convertRelativeToAbsoluteCropArea=function(a,b){var c=a.height,d=a.width,e=a.x,f=a.y;return{height:c*b.naturalHeight,width:d*b.naturalWidth,x:e*b.naturalWidth,y:f*b.naturalHeight}},a.prototype.setPreviewImages=function(a){var b=this,d=this.cropper,e=d.cropper("getImageData");Object.keys(a).forEach(function(f){var g=a[f],h=b.convertRelativeToAbsoluteCropArea(g.cropArea,e),i=b.trigger.closest(".form-group").find('.t3js-image-manipulation-preview[data-crop-variant-id="'+f+'"]'),j=b.trigger.closest(".form-group").find('.t3js-image-manipulation-selected-ratio[data-crop-variant-id="'+f+'"]');if(0!==i.length){var k=i.width(),l=i.data("preview-height"),m=h.width/h.height,n=k/m;n>l?k=l*m:l=n,k>h.width&&(k=h.width,l=h.height);var o=k/h.width,p=c("<div />").html('<img src="'+d.attr("src")+'">'),q=b.currentModal.find('.t3-js-ratio-title[data-ratio-id="'+g.id+g.selectedRatio+'"]');j.text(q.text()),p.addClass("cropper-preview-container"),i.empty().append(p),p.wrap('<span class="thumbnail thumbnail-status"></span>'),p.width(k).height(l).find("img").css({height:e.naturalHeight*o,left:-h.x*o,top:-h.y*o,width:e.naturalWidth*o})}})},a.prototype.openPreview=function(b){var c=a.serializeCropVariants(b),d=this.trigger.attr("data-preview-url");d=d+"&cropVariants="+encodeURIComponent(c),window.open(d,"TYPO3ImageManipulationPreview")},a.prototype.save=function(b){var d=a.serializeCropVariants(b),e=c("#"+this.trigger.attr("data-field"));this.trigger.attr("data-crop-variants",JSON.stringify(b)),this.setPreviewImages(b),e.val(d),this.currentModal.modal("hide")},a.prototype.destroy=function(){this.currentModal&&(this.cropper.cropper("destroy"),this.cropper=null,this.currentModal=null,this.data=null)},a.prototype.resizeEnd=function(a){var b,d=this;c(window).on("resize",function(){clearTimeout(b),b=setTimeout(function(){a()},d.resizeTimeout)})},a}();return new f});
\ No newline at end of file
+define(["require","exports","jquery","./Modal","TYPO3/CMS/Core/Contrib/imagesloaded.pkgd.min","jquery-ui/draggable","jquery-ui/resizable"],function(a,b,c,d,e){"use strict";var f=function(){function a(){var b=this;this.cropImageContainerSelector="#t3js-crop-image-container",this.cropImageSelector="#t3js-crop-image",this.coverAreaSelector=".t3js-cropper-cover-area",this.cropInfoSelector=".t3js-cropper-info-crop",this.focusAreaSelector="#t3js-cropper-focus-area",this.defaultFocusArea={height:1/3,width:1/3,x:0,y:0},this.defaultOpts={autoCrop:!0,autoCropArea:"0.7",dragMode:"crop",guides:!0,responsive:!0,viewMode:1,zoomable:!1},this.resizeTimeout=450,this.cropBuiltHandler=function(){var d=b.cropper.cropper("getImageData"),e=b.currentModal.find(b.cropImageSelector);b.imageOriginalSizeFactor=e.data("originalWidth")/d.naturalWidth,b.cropVariantTriggers.each(function(a,e){var f=c(e).attr("data-crop-variant-id"),g=b.convertRelativeToAbsoluteCropArea(b.data[f].cropArea,d),h=c.extend(!0,{},b.data[f],{cropArea:g});b.updatePreviewThumbnail(h,c(e))}),b.currentCropVariant.cropArea=b.convertRelativeToAbsoluteCropArea(b.currentCropVariant.cropArea,d),b.cropBox=b.currentModal.find(".cropper-crop-box"),b.setCropArea(b.currentCropVariant.cropArea),b.currentCropVariant.coverAreas&&b.initCoverAreas(b.cropBox,b.currentCropVariant.coverAreas),b.currentCropVariant.focusArea&&(a.isEmptyArea(b.currentCropVariant.focusArea)&&(b.currentCropVariant.focusArea=c.extend(!0,{},b.defaultFocusArea)),b.initFocusArea(b.cropBox),b.scaleAndMoveFocusArea(b.currentCropVariant.focusArea)),b.currentCropVariant.selectedRatio&&(b.setAspectRatio(b.currentCropVariant.allowedAspectRatios[b.currentCropVariant.selectedRatio]),b.setCropArea(b.currentCropVariant.cropArea),b.currentModal.find("[data-option='"+b.currentCropVariant.selectedRatio+"']").addClass("active")),b.cropperCanvas.addClass("is-visible")},this.cropMoveHandler=function(a){b.currentCropVariant.cropArea=c.extend(!0,b.currentCropVariant.cropArea,{height:Math.floor(a.height),width:Math.floor(a.width),x:Math.floor(a.x),y:Math.floor(a.y)}),b.updatePreviewThumbnail(b.currentCropVariant,b.activeCropVariantTrigger),b.updateCropVariantData(b.currentCropVariant);var d=Math.round(b.currentCropVariant.cropArea.width*b.imageOriginalSizeFactor),e=Math.round(b.currentCropVariant.cropArea.height*b.imageOriginalSizeFactor);b.cropInfo.text(d+"×"+e+" px")},this.cropStartHandler=function(){b.currentCropVariant.focusArea&&(b.focusArea.draggable("option","disabled",!0),b.focusArea.resizable("option","disabled",!0))},this.cropEndHandler=function(){b.currentCropVariant.focusArea&&(b.focusArea.draggable("option","disabled",!1),b.focusArea.resizable("option","disabled",!1))},c(window).resize(function(){b.cropper&&b.cropper.cropper("destroy")}),this.resizeEnd(function(){b.cropper&&b.init()})}return a.isEmptyArea=function(a){return c.isEmptyObject(a)},a.wait=function(a,b){window.setTimeout(a,b)},a.toCssPercent=function(a){return 100*a+"%"},a.serializeCropVariants=function(a){var b=function(a,b){return"id"===a||"title"===a||"allowedAspectRatios"===a||"coverAreas"===a?void 0:b};return JSON.stringify(a,b)},a.prototype.initializeTrigger=function(){var a=this,b=function(b){b.preventDefault(),a.trigger=c(b.currentTarget),a.show()};c(".t3js-image-manipulation-trigger").off("click").click(b)},a.prototype.initializeCropperModal=function(){var a=this,b=this.currentModal.find(this.cropImageSelector);e(b,function(){setTimeout(function(){a.init()},100)})},a.prototype.show=function(){var a=this,b=this.trigger.data("modalTitle"),c=this.trigger.data("buttonPreviewText"),e=this.trigger.data("buttonDismissText"),f=this.trigger.data("buttonSaveText"),g=this.trigger.data("url"),h=this.initializeCropperModal.bind(this);this.currentModal=d.advanced({additionalCssClasses:["modal-image-manipulation"],ajaxCallback:h,buttons:[{btnClass:"btn-default pull-left",dataAttributes:{method:"preview"},icon:"actions-view",text:c},{btnClass:"btn-default",dataAttributes:{method:"dismiss"},icon:"actions-close",text:e},{btnClass:"btn-primary",dataAttributes:{method:"save"},icon:"actions-document-save",text:f}],callback:function(a){a.find(".t3js-modal-body").addClass("cropper")},content:g,size:d.sizes.full,style:d.styles.dark,title:b,type:"ajax"}),this.currentModal.on("hide.bs.modal",function(b){a.destroy()}),this.currentModal.data("bs.modal").options.backdrop="static"},a.prototype.init=function(){var b=this,d=this.currentModal.find(this.cropImageSelector),e=c(d).height(),f=c(d).width(),g=this.trigger.attr("data-crop-variants");if(!g)throw new TypeError("ImageManipulation: No cropVariants data found for image");this.data=c.isEmptyObject(this.data)?JSON.parse(g):this.data,this.currentModal.find(this.cropImageContainerSelector).css({height:e,width:f}),this.cropVariantTriggers=this.currentModal.find(".t3js-crop-variant-trigger"),this.activeCropVariantTrigger=this.currentModal.find(".t3js-crop-variant-trigger.is-active"),this.cropInfo=this.currentModal.find(this.cropInfoSelector),this.saveButton=this.currentModal.find("[data-method=save]"),this.previewButton=this.currentModal.find("[data-method=preview]"),this.dismissButton=this.currentModal.find("[data-method=dismiss]"),this.resetButton=this.currentModal.find("[data-method=reset]"),this.cropperCanvas=this.currentModal.find("#js-crop-canvas"),this.aspectRatioTrigger=this.currentModal.find("[data-method=setAspectRatio]"),this.currentCropVariant=this.data[this.activeCropVariantTrigger.attr("data-crop-variant-id")],this.cropVariantTriggers.off("click").on("click",function(a){if(c(a.currentTarget).hasClass("is-active"))return a.stopPropagation(),void a.preventDefault();b.activeCropVariantTrigger.removeClass("is-active"),c(a.currentTarget).addClass("is-active"),b.activeCropVariantTrigger=c(a.currentTarget);var d=b.data[b.activeCropVariantTrigger.attr("data-crop-variant-id")],e=b.cropper.cropper("getImageData");d.cropArea=b.convertRelativeToAbsoluteCropArea(d.cropArea,e),b.currentCropVariant=c.extend(!0,{},d),b.update(d)}),this.aspectRatioTrigger.off("click").on("click",function(a){var d=c(a.currentTarget).attr("data-option"),e=c.extend(!0,{},b.currentCropVariant),f=e.allowedAspectRatios[d];b.setAspectRatio(f),b.setCropArea(e.cropArea),b.currentCropVariant=c.extend(!0,{},e,{selectedRatio:d}),b.update(b.currentCropVariant)}),this.saveButton.off("click").on("click",function(){b.save(b.data)}),this.trigger.attr("data-preview-url")?this.previewButton.off("click").on("click",function(){b.openPreview(b.data)}):this.previewButton.hide(),this.dismissButton.off("click").on("click",function(){b.currentModal.modal("hide")}),this.resetButton.off("click").on("click",function(a){var d=b.cropper.cropper("getImageData"),e=c(a.currentTarget).attr("data-crop-variant");if(a.preventDefault(),a.stopPropagation(),!e)throw new TypeError("TYPO3 Cropper: No cropVariant data attribute found on reset element.");var f=JSON.parse(e),g=b.convertRelativeToAbsoluteCropArea(f.cropArea,d);b.currentCropVariant=c.extend(!0,{},f,{cropArea:g}),b.update(b.currentCropVariant)}),a.isEmptyArea(this.currentCropVariant.cropArea)&&(this.defaultOpts=c.extend({autoCropArea:1},this.defaultOpts)),this.cropper=top.$(d).cropper(c.extend(this.defaultOpts,{built:this.cropBuiltHandler,crop:this.cropMoveHandler,cropend:this.cropEndHandler,cropstart:this.cropStartHandler,data:this.currentCropVariant.cropArea}))},a.prototype.update=function(b){var d=c.extend(!0,{},b),e=b.allowedAspectRatios[b.selectedRatio];this.currentModal.find("[data-option]").removeClass("active"),this.currentModal.find('[data-option="'+b.selectedRatio+'"]').addClass("active"),this.setAspectRatio(e),this.setCropArea(d.cropArea),this.currentCropVariant=c.extend(!0,{},d,b),this.cropBox.find(this.coverAreaSelector).remove(),this.cropBox.has(this.focusAreaSelector).length&&(this.focusArea.resizable("destroy").draggable("destroy"),this.focusArea.remove()),b.focusArea&&(a.isEmptyArea(b.focusArea)&&(this.currentCropVariant.focusArea=c.extend(!0,{},this.defaultFocusArea)),this.initFocusArea(this.cropBox),this.scaleAndMoveFocusArea(this.currentCropVariant.focusArea)),b.coverAreas&&this.initCoverAreas(this.cropBox,this.currentCropVariant.coverAreas),this.updatePreviewThumbnail(this.currentCropVariant,this.activeCropVariantTrigger)},a.prototype.initFocusArea=function(b){var d=this;this.focusArea=c('<div id="t3js-cropper-focus-area" class="cropper-focus-area"></div>'),b.append(this.focusArea),this.focusArea.draggable({containment:b,create:function(){d.scaleAndMoveFocusArea(d.currentCropVariant.focusArea)},drag:function(){var a=b.offset(),c=a.left,e=a.top,f=d.focusArea.offset(),g=f.left,h=f.top,i=d.currentCropVariant,j=i.focusArea,k=i.coverAreas;j.x=(g-c)/b.width(),j.y=(h-e)/b.height(),d.updatePreviewThumbnail(d.currentCropVariant,d.activeCropVariantTrigger),d.checkFocusAndCoverAreasCollision(j,k)?d.focusArea.addClass("has-nodrop"):d.focusArea.removeClass("has-nodrop")},revert:function(){var c=250,e=b.offset(),f=e.left,g=e.top,h=d.focusArea.offset(),i=h.left,j=h.top,k=d.currentCropVariant,l=k.focusArea,m=k.coverAreas;return!!d.checkFocusAndCoverAreasCollision(l,m)&&(d.focusArea.removeClass("has-nodrop"),a.wait(function(){l.x=(i-f)/b.width(),l.y=(j-g)/b.height(),d.updateCropVariantData(d.currentCropVariant)},c),!0)},revertDuration:200,stop:function(){var a=b.offset(),c=a.left,e=a.top,f=d.focusArea.offset(),g=f.left,h=f.top,i=d.currentCropVariant.focusArea;i.x=(g-c)/b.width(),i.y=(h-e)/b.height(),d.scaleAndMoveFocusArea(i)}}).resizable({containment:b,handles:"all",resize:function(){var a=b.offset(),c=a.left,e=a.top,f=d.focusArea.offset(),g=f.left,h=f.top,i=d.currentCropVariant,j=i.focusArea,k=i.coverAreas;j.height=d.focusArea.height()/b.height(),j.width=d.focusArea.width()/b.width(),j.x=(g-c)/b.width(),j.y=(h-e)/b.height(),d.updatePreviewThumbnail(d.currentCropVariant,d.activeCropVariantTrigger),d.checkFocusAndCoverAreasCollision(j,k)?d.focusArea.addClass("has-nodrop"):d.focusArea.removeClass("has-nodrop")},stop:function(a,e){var f=250,g=b.offset(),h=g.left,i=g.top,j=d.focusArea.offset(),k=j.left,l=j.top,m=d.currentCropVariant,n=m.focusArea,o=m.coverAreas;d.checkFocusAndCoverAreasCollision(n,o)?e.element.animate(c.extend(e.originalPosition,e.originalSize),f,function(){n.height=d.focusArea.height()/b.height(),n.height=d.focusArea.height()/b.height(),n.width=d.focusArea.width()/b.width(),n.x=(k-h)/b.width(),n.y=(l-i)/b.height(),d.scaleAndMoveFocusArea(n),d.focusArea.removeClass("has-nodrop")}):d.scaleAndMoveFocusArea(n)}})},a.prototype.initCoverAreas=function(b,d){d.forEach(function(d){var e=c('<div class="cropper-cover-area t3js-cropper-cover-area"></div>');b.append(e),e.css({height:a.toCssPercent(d.height),left:a.toCssPercent(d.x),top:a.toCssPercent(d.y),width:a.toCssPercent(d.width)})})},a.prototype.updatePreviewThumbnail=function(b,c){var d,e=c.find(".t3js-cropper-preview-thumbnail-crop-area"),f=c.find(".t3js-cropper-preview-thumbnail-crop-image"),g=c.find(".t3js-cropper-preview-thumbnail-focus-area"),h=this.cropper.cropper("getImageData");e.css({height:a.toCssPercent(b.cropArea.height/h.naturalHeight),left:a.toCssPercent(b.cropArea.x/h.naturalWidth),top:a.toCssPercent(b.cropArea.y/h.naturalHeight),width:a.toCssPercent(b.cropArea.width/h.naturalWidth)}),b.focusArea&&g.css({height:a.toCssPercent(b.focusArea.height),left:a.toCssPercent(b.focusArea.x),top:a.toCssPercent(b.focusArea.y),width:a.toCssPercent(b.focusArea.width)}),d=e.css(["width","height","left","top"]),f.css({height:parseFloat(d.height)*(1/(b.cropArea.height/h.naturalHeight))+"px",margin:-1*parseFloat(d.left)+"px",marginTop:-1*parseFloat(d.top)+"px",width:parseFloat(d.width)*(1/(b.cropArea.width/h.naturalWidth))+"px"})},a.prototype.scaleAndMoveFocusArea=function(b){this.focusArea.css({height:a.toCssPercent(b.height),left:a.toCssPercent(b.x),top:a.toCssPercent(b.y),width:a.toCssPercent(b.width)}),this.currentCropVariant.focusArea=b,this.updatePreviewThumbnail(this.currentCropVariant,this.activeCropVariantTrigger),this.updateCropVariantData(this.currentCropVariant)},a.prototype.updateCropVariantData=function(a){var b=this.cropper.cropper("getImageData"),d=this.convertAbsoluteToRelativeCropArea(a.cropArea,b);this.data[a.id]=c.extend(!0,{},a,{cropArea:d})},a.prototype.setAspectRatio=function(a){this.cropper.cropper("setAspectRatio",a.value)},a.prototype.setCropArea=function(a){var b=this.currentCropVariant.allowedAspectRatios[this.currentCropVariant.selectedRatio];0===b.value?this.cropper.cropper("setData",{height:a.height,width:a.width,x:a.x,y:a.y}):this.cropper.cropper("setData",{height:a.height,x:a.x,y:a.y})},a.prototype.checkFocusAndCoverAreasCollision=function(a,b){return!!b&&b.some(function(b){return a.x<b.x+b.width&&a.x+a.width>b.x&&a.y<b.y+b.height&&a.height+a.y>b.y})},a.prototype.convertAbsoluteToRelativeCropArea=function(a,b){var c=a.height,d=a.width,e=a.x,f=a.y;return{height:c/b.naturalHeight,width:d/b.naturalWidth,x:e/b.naturalWidth,y:f/b.naturalHeight}},a.prototype.convertRelativeToAbsoluteCropArea=function(a,b){var c=a.height,d=a.width,e=a.x,f=a.y;return{height:c*b.naturalHeight,width:d*b.naturalWidth,x:e*b.naturalWidth,y:f*b.naturalHeight}},a.prototype.setPreviewImages=function(a){var b=this,d=this.cropper,e=d.cropper("getImageData");Object.keys(a).forEach(function(f){var g=a[f],h=b.convertRelativeToAbsoluteCropArea(g.cropArea,e),i=b.trigger.closest(".form-group").find('.t3js-image-manipulation-preview[data-crop-variant-id="'+f+'"]'),j=b.trigger.closest(".form-group").find('.t3js-image-manipulation-selected-ratio[data-crop-variant-id="'+f+'"]');if(0!==i.length){var k=i.width(),l=i.data("preview-height"),m=h.width/h.height,n=k/m;n>l?k=l*m:l=n,k>h.width&&(k=h.width,l=h.height);var o=k/h.width,p=c("<div />").html('<img src="'+d.attr("src")+'">'),q=b.currentModal.find('.t3-js-ratio-title[data-ratio-id="'+g.id+g.selectedRatio+'"]');j.text(q.text()),p.addClass("cropper-preview-container"),i.empty().append(p),p.wrap('<span class="thumbnail thumbnail-status"></span>'),p.width(k).height(l).find("img").css({height:e.naturalHeight*o,left:-h.x*o,top:-h.y*o,width:e.naturalWidth*o})}})},a.prototype.openPreview=function(b){var c=a.serializeCropVariants(b),d=this.trigger.attr("data-preview-url");d=d+"&cropVariants="+encodeURIComponent(c),window.open(d,"TYPO3ImageManipulationPreview")},a.prototype.save=function(b){var d=a.serializeCropVariants(b),e=c("#"+this.trigger.attr("data-field"));this.trigger.attr("data-crop-variants",JSON.stringify(b)),this.setPreviewImages(b),e.val(d),this.currentModal.modal("hide")},a.prototype.destroy=function(){this.currentModal&&(this.cropper.cropper("destroy"),this.cropper=null,this.currentModal=null,this.data=null)},a.prototype.resizeEnd=function(a){var b,d=this;c(window).on("resize",function(){clearTimeout(b),b=setTimeout(function(){a()},d.resizeTimeout)})},a}();return new f});
\ No newline at end of file
index e54611c..cb83fad 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","TYPO3/CMS/Backend/Modal","./Severity"],function(a,b,c,d){"use strict";var e=function(){function a(){}return a.showItem=function(a,b){c.advanced({type:c.types.iframe,size:c.sizes.large,content:TYPO3.settings.ShowItem.moduleUrl+"&table="+encodeURIComponent(a)+"&uid="+("number"==typeof b?b:encodeURIComponent(b)),severity:d.notice})},a}();return TYPO3.InfoWindow=e,e});
\ No newline at end of file
+define(["require","exports","./Enum/Severity","./Modal"],function(a,b,c,d){"use strict";var e=function(){function a(){}return a.showItem=function(a,b){d.advanced({type:d.types.iframe,size:d.sizes.large,content:TYPO3.settings.ShowItem.moduleUrl+"&table="+encodeURIComponent(a)+"&uid="+("number"==typeof b?b:encodeURIComponent(b)),severity:c.SeverityEnum.notice})},a}();return TYPO3.InfoWindow=e,e});
\ No newline at end of file
index ba37686..8b19bb9 100644 (file)
  *
  * The TYPO3 project - inspiring people to share!
  */
-
-/**
- * Module: TYPO3/CMS/Backend/Modal
- * API for modal windows powered by Twitter Bootstrap.
- */
-define(['jquery',
-  'TYPO3/CMS/Backend/Severity',
-  'TYPO3/CMS/Backend/Icons',
-  'bootstrap'
-], function($, Severity, Icons) {
-  'use strict';
-
-  try {
-    // fetch from parent
-    if (parent && parent.window.TYPO3 && parent.window.TYPO3.Modal) {
-      // we need to trigger the event capturing again, in order to make sure this works inside iframes
-      parent.window.TYPO3.Modal.initializeMarkupTrigger(document);
-      return parent.window.TYPO3.Modal;
-    }
-
-    // fetch object from outer frame
-    if (top && top.TYPO3.Modal) {
-      // we need to trigger the event capturing again, in order to make sure this works inside iframes
-      top.TYPO3.Modal.initializeMarkupTrigger(document);
-      return top.TYPO3.Modal;
-    }
-  } catch (e) {
-    // This only happens if the opener, parent or top is some other url (eg a local file)
-    // which loaded the current window. Then the browser's cross domain policy jumps in
-    // and raises an exception.
-    // For this case we are safe and we can create our global object below.
-  }
-
-  /**
-   * The main object of the modal API
-   *
-   * @type {{instances: Array, currentModal: null, template: (*), identifiers: {modal: string, content: string, title: string, close: string, body: string, footer: string, iframe: string, iconPlaceholder: string}, sizes: {small: string, default: string, large: string, full: string}, styles: {default: string, light: string, dark: string}, types: {default: string, ajax: string, iframe: string}, defaultConfiguration: {type: string, title: string, content: string, severity: number, buttons: Array, style: string, size: string, additionalCssClasses: Array, callback: Modal.defaultConfiguration.callback, ajaxCallback: Modal.defaultConfiguration.ajaxCallback, ajaxTarget: null}}}
-   * @exports TYPO3/CMS/Backend/Modal
-   */
-  var Modal = {
-    instances: [],
-    currentModal: null,
-    template: $(
-      '<div class="t3js-modal modal fade">' +
-      '<div class="modal-dialog">' +
-      '<div class="t3js-modal-content modal-content">' +
-      '<div class="modal-header">' +
-      '<button class="t3js-modal-close close">' +
-      '<span aria-hidden="true">' +
-      '<span class="t3js-modal-icon-placeholder" data-icon="actions-close"></span>' +
-      '</span>' +
-      '<span class="sr-only"></span>' +
-      '</button>' +
-      '<h4 class="t3js-modal-title modal-title"></h4>' +
-      '</div>' +
-      '<div class="t3js-modal-body modal-body"></div>' +
-      '<div class="t3js-modal-footer modal-footer"></div>' +
-      '</div>' +
-      '</div>' +
-      '</div>'
-    ),
-    identifiers: {
-      modal: '.t3js-modal',
-      content: '.t3js-modal-content',
-      title: '.t3js-modal-title',
-      close: '.t3js-modal-close',
-      body: '.t3js-modal-body',
-      footer: '.t3js-modal-footer',
-      iframe: '.t3js-modal-iframe',
-      iconPlaceholder: '.t3js-modal-icon-placeholder'
-    },
-    sizes: {
-      small: 'small',
-      default: 'default',
-      medium: 'medium',
-      large: 'large',
-      full: 'full'
-    },
-    styles: {
-      default: 'light',
-      light: 'light',
-      dark: 'dark'
-    },
-    types: {
-      default: 'default',
-      ajax: 'ajax',
-      iframe: 'iframe'
-    },
-    defaultConfiguration: {
-      type: 'default',
-      title: 'Information',
-      content: 'No content provided, please check your <code>Modal</code> configuration.',
-      severity: Severity.notice,
-      buttons: [],
-      style: 'default',
-      size: 'default',
-      additionalCssClasses: [],
-      callback: function() {
-      },
-      ajaxCallback: function() {
-      },
-      ajaxTarget: null
-    }
-  };
-
-  /**
-   * Shows a confirmation dialog
-   * Events:
-   * - button.clicked
-   * - confirm.button.cancel
-   * - confirm.button.ok
-   *
-   * @param {String} title the title for the confirm modal
-   * @param {*} content the content for the conform modal, e.g. the main question
-   * @param {int} [severity=Severity.warning] severity default Severity.warning
-   * @param {array} [buttons] an array with buttons, default no buttons
-   * @param {array} [additionalCssClasses=''] additional css classes to add to the modal
-   */
-  Modal.confirm = function(title, content, severity, buttons, additionalCssClasses) {
-    severity = typeof severity !== 'undefined' ? severity : Severity.warning;
-
-    return Modal.advanced(
-      {
-        title: title,
-        content: content,
-        severity: severity,
-        buttons: buttons || [
-          {
-            text: $(this).data('button-close-text') || TYPO3.lang['button.cancel'] || 'Cancel',
-            active: true,
-            btnClass: 'btn-default',
-            name: 'cancel'
-          },
-          {
-            text: $(this).data('button-ok-text') || TYPO3.lang['button.ok'] || 'OK',
-            btnClass: 'btn-' + Severity.getCssClass(severity),
-            name: 'ok'
-          }
-        ],
-        additionalCssClasses: additionalCssClasses || [],
-        callback: function(currentModal) {
-          currentModal.on('button.clicked', function(e) {
-            if (e.target.name === 'cancel') {
-              $(this).trigger('confirm.button.cancel');
-            } else if (e.target.name === 'ok') {
-              $(this).trigger('confirm.button.ok');
-            }
-          });
-        }
-      }
-    );
-  };
-
-  /**
-   * load URL with AJAX, append the content to the modal-body
-   * and trigger the callback
-   *
-   * @param {String} title
-   * @param {int} severity
-   * @param {array} buttons
-   * @param {String} url
-   * @param {function} callback
-   * @param {String} target
-   */
-  Modal.loadUrl = function(title, severity, buttons, url, callback, target) {
-    return Modal.advanced({
-      type: Modal.types.ajax,
-      title: title,
-      content: url,
-      severity: typeof severity !== 'undefined' ? severity : Severity.info,
-      buttons: buttons,
-      ajaxCallback: callback,
-      ajaxTarget: target
-    });
-  };
-
-  /**
-   * Shows a dialog
-   *
-   * @param {String} title the title for the modal
-   * @param {*} content the content for the modal, e.g. the main question
-   * @param {int} severity default Severity.info
-   * @param {array} buttons an array with buttons, default no buttons
-   * @param {array} additionalCssClasses additional css classes to add to the modal
-   */
-  Modal.show = function(title, content, severity, buttons, additionalCssClasses) {
-    return Modal.advanced({
-      type: Modal.types.default,
-      title: title,
-      content: content,
-      severity: typeof severity !== 'undefined' ? severity : Severity.info,
-      buttons: buttons,
-      additionalCssClasses: additionalCssClasses
-    });
-  };
-
-  /**
-   * Loads modal by configuration
-   *
-   * @param {object} configuration configuration for the modal
-   */
-  Modal.advanced = function(configuration) {
-    if (typeof configuration !== 'object') {
-      configuration = {};
-    }
-
-    // Validation of configuration
-    configuration.type = typeof configuration.type === 'string' && configuration.type in Modal.types ? configuration.type : Modal.defaultConfiguration.type;
-    configuration.title = typeof configuration.title === 'string' ? configuration.title : Modal.defaultConfiguration.title;
-    configuration.content = typeof configuration.content === 'string' || typeof configuration.content === 'object' ? configuration.content : Modal.defaultConfiguration.content;
-    configuration.severity = typeof configuration.severity !== 'undefined' ? configuration.severity : Modal.defaultConfiguration.severity;
-    configuration.buttons = configuration.buttons || Modal.defaultConfiguration.buttons;
-    configuration.size = typeof configuration.size === 'string' && configuration.size in Modal.sizes ? configuration.size : Modal.defaultConfiguration.size;
-    configuration.style = typeof configuration.style === 'string' && configuration.style in Modal.styles ? configuration.style : Modal.defaultConfiguration.style;
-    configuration.additionalCssClasses = configuration.additionalCssClasses || Modal.defaultConfiguration.additionalCssClasses;
-    configuration.callback = typeof configuration.callback === 'function' ? configuration.callback : Modal.defaultConfiguration.callback;
-    configuration.ajaxCallback = typeof configuration.ajaxCallback === 'function' ? configuration.ajaxCallback : Modal.defaultConfiguration.ajaxCallback;
-    configuration.ajaxTarget = typeof configuration.ajaxTarget === 'string' ? configuration.ajaxTarget : Modal.defaultConfiguration.ajaxTarget;
-
-    return Modal._generate(
-      configuration.type,
-      configuration.title,
-      configuration.content,
-      configuration.severity,
-      configuration.buttons,
-      configuration.style,
-      configuration.size,
-      configuration.additionalCssClasses,
-      configuration.callback,
-      configuration.ajaxCallback,
-      configuration.ajaxTarget
-    );
-  };
-
-  /**
-   * Generate the modal window
-   * Events:
-   * - button.clicked
-   *
-   * @param {String} type the type of the modal
-   * @param {String} title the title for the modal
-   * @param {*} content the content for the modal, e.g. the main question
-   * @param {int} severity default Severity.info
-   * @param {array} buttons an array with buttons, default no buttons
-   * @param {String} style the style of the modal window
-   * @param {String} size the size of the modal window
-   * @param {array} additionalCssClasses additional css classes to add to the modal
-   * @param {function} callback
-   * @param {function} ajaxCallback
-   * @param {String} ajaxTarget
-   * @private
-   */
-  Modal._generate = function(type, title, content, severity, buttons, style, size, additionalCssClasses, callback, ajaxCallback, ajaxTarget) {
-    var currentModal = Modal.template.clone();
-    if (additionalCssClasses.length) {
-      for (var i = 0; i < additionalCssClasses.length; i++) {
-        currentModal.addClass(additionalCssClasses[i]);
-      }
-    }
-    currentModal.addClass('modal-type-' + Modal.types[type]);
-    currentModal.addClass('modal-severity-' + Severity.getCssClass(severity));
-    currentModal.addClass('modal-style-' + Modal.styles[style]);
-    currentModal.addClass('modal-size-' + Modal.sizes[size]);
-    currentModal.attr('tabindex', '-1');
-    currentModal.find(Modal.identifiers.title).text(title);
-    currentModal.find(Modal.identifiers.close).on('click', function() {
-      currentModal.modal('hide');
-    });
-
-    // Add content
-    if (type === 'ajax') {
-      $.get(content, function(response) {
-        Modal.currentModal.find(ajaxTarget ? ajaxTarget : Modal.identifiers.body).empty().append(response);
-        if (ajaxCallback) {
-          ajaxCallback();
-        }
-        Modal.currentModal.trigger('modal-loaded');
-      }, 'html');
-      Icons.getIcon('spinner-circle', Icons.sizes.default, null, null, Icons.markupIdentifiers.inline).done(function(icon) {
-        currentModal.find(Modal.identifiers.body).html('<div class="modal-loading">' + icon + '</div>');
-      });
-    } else if (type === 'iframe') {
-      currentModal.find(Modal.identifiers.body).append(
-        $('<iframe />', {
-          src: content,
-          'name': 'modal_frame',
-          'class': 'modal-iframe t3js-modal-iframe'
-        })
-      );
-      currentModal.find(Modal.identifiers.iframe).on('load', function() {
-        currentModal.find(Modal.identifiers.title).text(
-          currentModal.find(Modal.identifiers.iframe).get(0).contentDocument.title
-        );
-      });
-    } else {
-      if (typeof content === 'object') {
-        currentModal.find(Modal.identifiers.body).append(content);
-      } else {
-        // we need html, check if we have to wrap content in <p>
-        if (!/^<[a-z][\s\S]*>/i.test(content)) {
-          content = $('<p />').html(content);
-        }
-        currentModal.find(Modal.identifiers.body).html(content);
-      }
-    }
-
-    // Add buttons
-    if (buttons.length > 0) {
-      for (i = 0; i < buttons.length; i++) {
-        var button = buttons[i];
-        var $button = $('<button />', {class: 'btn'});
-        $button.html('<span>' + button.text + '</span>');
-        if (button.active) {
-          $button.addClass('t3js-active');
-        }
-        if (button.btnClass) {
-          $button.addClass(button.btnClass);
-        }
-        if (button.name) {
-          $button.attr('name', button.name);
-        }
-        if (button.trigger) {
-          $button.on('click', button.trigger);
-        }
-        if (button.dataAttributes) {
-          if (Object.keys(button.dataAttributes).length > 0) {
-            Object.keys(button.dataAttributes).map(function(key, index) {
-              $button.attr('data-' + key, button.dataAttributes[key]);
-            });
-          }
-        }
-        if (button.icon) {
-          $button.prepend('<span class="t3js-modal-icon-placeholder" data-icon="' + button.icon + '"></span>');
-        }
-        currentModal.find(Modal.identifiers.footer).append($button);
-      }
-      currentModal
-        .find(Modal.identifiers.footer).find('button')
-        .on('click', function() {
-          $(this).trigger('button.clicked');
-        });
-
-    } else {
-      currentModal.find(Modal.identifiers.footer).remove();
-    }
-
-    currentModal.on('shown.bs.modal', function() {
-      // focus the button which was configured as active button
-      $(this).find(Modal.identifiers.footer).find('.t3js-active').first().focus();
-      // Get Icons
-      $(this).find(Modal.identifiers.iconPlaceholder).each(function() {
-        Icons.getIcon($(this).data('icon'), Icons.sizes.small, null, null, Icons.markupIdentifiers.inline).done(function(icon) {
-          Modal.currentModal.find(Modal.identifiers.iconPlaceholder + '[data-icon=' + $(icon).data('identifier') + ']').replaceWith(icon);
-        });
-      });
-    });
-
-    // Remove modal from Modal.instances when hidden
-    currentModal.on('hidden.bs.modal', function() {
-      if (Modal.instances.length > 0) {
-        var lastIndex = Modal.instances.length - 1;
-        Modal.instances.splice(lastIndex, 1);
-        Modal.currentModal = Modal.instances[lastIndex - 1];
-      }
-      currentModal.trigger('modal-destroyed');
-      $(this).remove();
-      // Keep class modal-open on body tag as long as open modals exist
-      if (Modal.instances.length > 0) {
-        $('body').addClass('modal-open');
-      }
-    });
-
-    // When modal is opened/shown add it to Modal.instances and make it Modal.currentModal
-    currentModal.on('show.bs.modal', function() {
-      Modal.currentModal = $(this);
-      Modal.instances.push(Modal.currentModal);
-    });
-    currentModal.on('modal-dismiss', function() {
-      // Hide modal, the bs.modal events will clean up Modal.instances
-      $(this).modal('hide');
-    });
-
-    if (callback) {
-      callback(currentModal);
-    }
-
-    return currentModal.modal();
-  };
-
-  /**
-   * Close the current open modal
-   */
-  Modal.dismiss = function() {
-    if (Modal.currentModal) {
-      Modal.currentModal.modal('hide');
-    }
-  };
-
-  /**
-   * Initialize markup with data attributes
-   *
-   * @param {object} theDocument
-   */
-  Modal.initializeMarkupTrigger = function(theDocument) {
-    $(theDocument).on('click', '.t3js-modal-trigger', function(evt) {
-      evt.preventDefault();
-      var $element = $(this);
-      var url = $element.data('url') || null;
-      var content = $element.data('content') || 'Are you sure?';
-      var severity = typeof Severity[$element.data('severity')] !== 'undefined' ? Severity[$element.data('severity')] : Severity.info;
-      if (url !== null) {
-        var separator = (url.indexOf('?') > -1) ? '&' : '?';
-        var params = $.param({data: $element.data()});
-        url = url + separator + params;
-      }
-      Modal.advanced({
-        type: url !== null ? Modal.types.ajax : Modal.types.default,
-        title: $element.data('title') || 'Alert',
-        content: url !== null ? url : content,
-        severity: severity,
-        buttons: [
-          {
-            text: $element.data('button-close-text') || 'Close',
-            active: true,
-            btnClass: 'btn-default',
-            trigger: function() {
-              Modal.currentModal.trigger('modal-dismiss');
-            }
-          },
-          {
-            text: $element.data('button-ok-text') || 'OK',
-            btnClass: 'btn-' + Severity.getCssClass(severity),
-            trigger: function() {
-              Modal.currentModal.trigger('modal-dismiss');
-              evt.target.ownerDocument.location.href = $element.data('href') || $element.attr('href');
-            }
-          }
-        ]
-      });
-    });
-  };
-
-  /**
-   * Custom event, fired if modal gets closed
-   */
-  $(document).on('modal-dismiss', Modal.dismiss);
-
-  Modal.initializeMarkupTrigger(document);
-
-  // expose as global object
-  TYPO3.Modal = Modal;
-
-  return Modal;
-});
+var __values=this&&this.__values||function(a){var b="function"==typeof Symbol&&a[Symbol.iterator],c=0;return b?b.call(a):{next:function(){return a&&c>=a.length&&(a=void 0),{value:a&&a[c++],done:!a}}}};define(["require","exports","./Enum/Severity","jquery","./Icons","./Severity","bootstrap"],function(a,b,c,d,e,f){"use strict";var g;!function(a){a.modal=".t3js-modal",a.content=".t3js-modal-content",a.title=".t3js-modal-title",a.close=".t3js-modal-close",a.body=".t3js-modal-body",a.footer=".t3js-modal-footer",a.iframe=".t3js-modal-iframe",a.iconPlaceholder=".t3js-modal-icon-placeholder"}(g||(g={}));var h;!function(a){a.small="small",a.default="default",a.medium="medium",a.large="large",a.full="full"}(h||(h={}));var i;!function(a){a.default="default",a.light="light",a.dark="dark"}(i||(i={}));var j;!function(a){a.default="default",a.ajax="ajax",a.iframe="iframe"}(j||(j={}));var k=function(){function a(){this.sizes=h,this.styles=i,this.types=j,this.currentModal=null,this.instances=[],this.$template=d('<div class="t3js-modal modal fade"><div class="modal-dialog"><div class="t3js-modal-content modal-content"><div class="modal-header"><button class="t3js-modal-close close"><span aria-hidden="true"><span class="t3js-modal-icon-placeholder" data-icon="actions-close"></span></span><span class="sr-only"></span></button><h4 class="t3js-modal-title modal-title"></h4></div><div class="t3js-modal-body modal-body"></div><div class="t3js-modal-footer modal-footer"></div></div></div></div>'),this.defaultConfiguration={type:j.default,title:"Information",content:"No content provided, please check your <code>Modal</code> configuration.",severity:c.SeverityEnum.notice,buttons:[],style:i.default,size:h.default,additionalCssClasses:[],callback:d.noop(),ajaxCallback:d.noop(),ajaxTarget:null},d(document).on("modal-dismiss",this.dismiss),this.initializeMarkupTrigger(document)}return a.prototype.dismiss=function(){this.currentModal&&this.currentModal.modal("hide")},a.prototype.confirm=function(a,b,e,g,h){return void 0===e&&(e=c.SeverityEnum.warning),void 0===g&&(g=[]),0===g.length&&g.push({text:d(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:d(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-"+f.getCssClass(e),name:"ok"}),this.advanced({title:a,content:b,severity:e,buttons:g,additionalCssClasses:h,callback:function(a){a.on("button.clicked",function(a){"cancel"===a.target.getAttribute("name")?d(a.currentTarget).trigger("confirm.button.cancel"):"ok"===a.target.getAttribute("name")&&d(a.currentTarget).trigger("confirm.button.ok")})}})},a.prototype.loadUrl=function(a,b,d,e,f,g){return void 0===b&&(b=c.SeverityEnum.info),this.advanced({type:j.ajax,title:a,severity:b,buttons:d,ajaxCallback:f,ajaxTarget:g})},a.prototype.show=function(a,b,d,e,f){return void 0===d&&(d=c.SeverityEnum.info),this.advanced({type:j.default,title:a,content:b,buttons:e,additionalCssClasses:f})},a.prototype.advanced=function(a){return a.type="string"==typeof a.type&&a.type in j?a.type:this.defaultConfiguration.type,a.title="string"==typeof a.title?a.title:this.defaultConfiguration.title,a.content="string"==typeof a.content||"object"==typeof a.content?a.content:this.defaultConfiguration.content,a.severity="undefined"!=typeof a.severity?a.severity:this.defaultConfiguration.severity,a.buttons=a.buttons||this.defaultConfiguration.buttons,a.size="string"==typeof a.size&&a.size in h?a.size:this.defaultConfiguration.size,a.style="string"==typeof a.style&&a.style in i?a.style:this.defaultConfiguration.style,a.additionalCssClasses=a.additionalCssClasses||this.defaultConfiguration.additionalCssClasses,a.callback="function"==typeof a.callback?a.callback:this.defaultConfiguration.callback,a.ajaxCallback="function"==typeof a.ajaxCallback?a.ajaxCallback:this.defaultConfiguration.ajaxCallback,a.ajaxTarget="string"==typeof a.ajaxTarget?a.ajaxTarget:this.defaultConfiguration.ajaxTarget,this.generate(a)},a.prototype.initializeMarkupTrigger=function(a){var b=this;d(a).on("click",".t3js-modal-trigger",function(a){a.preventDefault();var e=d(a.currentTarget),g=e.data("content")||"Are you sure?",h="undefined"!=typeof c.SeverityEnum[e.data("severity")]?c.SeverityEnum[e.data("severity")]:c.SeverityEnum.info,i=e.data("url")||null;if(null!==i){var k=i.indexOf("?")>-1?"&":"?",l=d.param({data:e.data()});i=i+k+l}b.advanced({type:null!==i?j.ajax:j.default,title:e.data("title")||"Alert",content:null!==i?i:g,severity:h,buttons:[{text:e.data("button-close-text")||"Close",active:!0,btnClass:"btn-default",trigger:function(){b.currentModal.trigger("modal-dismiss")}},{text:e.data("button-ok-text")||"OK",btnClass:"btn-"+f.getCssClass(h),trigger:function(){b.currentModal.trigger("modal-dismiss"),a.target.ownerDocument.location.href=e.data("href")||e.attr("href")}}]})})},a.prototype.generate=function(a){var b=this,c=this.$template.clone();if(a.additionalCssClasses.length>0)try{for(var h=__values(a.additionalCssClasses),i=h.next();!i.done;i=h.next()){var j=i.value;c.addClass(j)}}catch(a){m={error:a}}finally{try{i&&!i.done&&(n=h.return)&&n.call(h)}finally{if(m)throw m.error}}if(c.addClass("modal-type-"+a.type),c.addClass("modal-severity-"+f.getCssClass(a.severity)),c.addClass("modal-style-"+a.style),c.addClass("modal-size-"+a.size),c.attr("tabindex","-1"),c.find(g.title).text(a.title),c.find(g.close).on("click",function(){c.modal("hide")}),"ajax"===a.type?(d.get(a.content,function(c){b.currentModal.find(a.ajaxTarget?a.ajaxTarget:g.body).empty().append(c),a.ajaxCallback&&a.ajaxCallback(),b.currentModal.trigger("modal-loaded")},"html"),e.getIcon("spinner-circle",e.sizes.default,null,null,e.markupIdentifiers.inline).done(function(a){c.find(g.body).html('<div class="modal-loading">'+a+"</div>")})):"iframe"===a.type?(c.find(g.body).append(d("<iframe />",{src:a.content,name:"modal_frame",class:"modal-iframe t3js-modal-iframe"})),c.find(g.iframe).on("load",function(){c.find(g.title).text(c.find(g.iframe).get(0).contentDocument.title)})):("string"==typeof a.content&&(/^<[a-z][\s\S]*>/i.test(a.content)||(a.content=d("<p />").html(a.content))),c.find(g.body).append(a.content)),a.buttons.length>0){for(var k=function(b){var e=a.buttons[b],f=d("<button />",{class:"btn"});f.html("<span>"+e.text+"</span>"),e.active&&f.addClass("t3js-active"),""!==e.btnClass&&f.addClass(e.btnClass),""!==e.name&&f.attr("name",e.name),e.trigger&&f.on("click",e.trigger),e.dataAttributes&&Object.keys(e.dataAttributes).length>0&&Object.keys(e.dataAttributes).map(function(a){f.attr("data-"+a,e.dataAttributes[a])}),e.icon&&f.prepend('<span class="t3js-modal-icon-placeholder" data-icon="'+e.icon+'"></span>'),c.find(g.footer).append(f)},l=0;l<a.buttons.length;l++)k(l);c.find(g.footer).find("button").on("click",function(a){d(a.currentTarget).trigger("button.clicked")})}else c.find(g.footer).remove();return c.on("shown.bs.modal",function(a){var c=d(a.currentTarget);c.find(g.footer).find(".t3js-active").first().focus(),c.find(g.iconPlaceholder).each(function(a,c){e.getIcon(d(c).data("icon"),e.sizes.small,null,null,e.markupIdentifiers.inline).done(function(a){b.currentModal.find(g.iconPlaceholder+"[data-icon="+d(a).data("identifier")+"]").replaceWith(a)})})}),c.on("hidden.bs.modal",function(){if(b.instances.length>0){var a=b.instances.length-1;b.instances.splice(a,1),b.currentModal=b.instances[a-1]}c.trigger("modal-destroyed"),d(b).remove(),b.instances.length>0&&d("body").addClass("modal-open")}),c.on("show.bs.modal",function(a){b.currentModal=d(a.currentTarget),b.instances.push(b.currentModal)}),c.on("modal-dismiss",function(a){d(a.currentTarget).modal("hide")}),a.callback&&a.callback(c),c.modal();var m,n},a}(),l=null;try{parent&&parent.window.TYPO3&&parent.window.TYPO3.Modal?(parent.window.TYPO3.Modal.initializeMarkupTrigger(document),l=parent.window.TYPO3.Modal):top&&top.TYPO3.Modal&&(top.TYPO3.Modal.initializeMarkupTrigger(document),l=top.TYPO3.Modal)}catch(a){}return l||(l=new k,TYPO3.Modal=l),l});
\ No newline at end of file
index 856443c..53da347 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","jquery","TYPO3/CMS/Backend/Modal","./Severity"],function(a,b,c,d,e){"use strict";var f=function(){function a(){this.initialize()}return a.prototype.initialize=function(){c(".t3js-submit-file-rename").on("click",this.checkForDuplicate)},a.prototype.checkForDuplicate=function(a){a.preventDefault();var b=c("#"+c(a.currentTarget).attr("form")),f=b.find('input[name="data[rename][0][target]"]'),g=b.find('input[name="data[rename][0][conflictMode]"]'),h=TYPO3.settings.ajaxUrls.file_exists;c.ajax({cache:!1,data:{fileName:f.val(),fileTarget:b.find('input[name="data[rename][0][destination]"]').val()},success:function(a){var c="undefined"!=typeof a.uid,h=f.data("original"),i=f.val();if(c&&h!==i){var j=TYPO3.lang["file_rename.exists.description"].replace("{0}",h).replace("{1}",i),k=d.confirm(TYPO3.lang["file_rename.exists.title"],j,e.warning,[{active:!0,btnClass:"btn-default",name:"cancel",text:TYPO3.lang["file_rename.actions.cancel"]},{btnClass:"btn-primary",name:"rename",text:TYPO3.lang["file_rename.actions.rename"]},{btnClass:"btn-default",name:"replace",text:TYPO3.lang["file_rename.actions.override"]}]);k.on("button.clicked",function(a){"cancel"!==a.target.name&&(g.val(a.target.name),b.submit()),d.dismiss()})}else b.submit()},url:h})},a}();return new f});
\ No newline at end of file
+define(["require","exports","./Enum/Severity","jquery","./Modal"],function(a,b,c,d,e){"use strict";var f=function(){function a(){this.initialize()}return a.prototype.initialize=function(){d(".t3js-submit-file-rename").on("click",this.checkForDuplicate)},a.prototype.checkForDuplicate=function(a){a.preventDefault();var b=d("#"+d(a.currentTarget).attr("form")),f=b.find('input[name="data[rename][0][target]"]'),g=b.find('input[name="data[rename][0][conflictMode]"]'),h=TYPO3.settings.ajaxUrls.file_exists;d.ajax({cache:!1,data:{fileName:f.val(),fileTarget:b.find('input[name="data[rename][0][destination]"]').val()},success:function(a){var d="undefined"!=typeof a.uid,h=f.data("original"),i=f.val();if(d&&h!==i){var j=TYPO3.lang["file_rename.exists.description"].replace("{0}",h).replace("{1}",i),k=e.confirm(TYPO3.lang["file_rename.exists.title"],j,c.SeverityEnum.warning,[{active:!0,btnClass:"btn-default",name:"cancel",text:TYPO3.lang["file_rename.actions.cancel"]},{btnClass:"btn-primary",name:"rename",text:TYPO3.lang["file_rename.actions.rename"]},{btnClass:"btn-default",name:"replace",text:TYPO3.lang["file_rename.actions.override"]}]);k.on("button.clicked",function(a){"cancel"!==a.target.name&&(g.val(a.target.name),b.submit()),e.dismiss()})}else b.submit()},url:h})},a}();return new f});
\ No newline at end of file
index e3bad1a..3ddab3c 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","TYPO3/CMS/Backend/Modal","../Severity"],function(a,b,c,d){"use strict";var e=function(){function a(){}return a.wizard=function(a,b){c.advanced({callback:function(a){a.find(".t3js-modal-body").addClass("t3-new-content-element-wizard-window")},content:a,severity:d.notice,size:c.sizes.medium,title:b,type:c.types.ajax})},a}();return e});
\ No newline at end of file
+define(["require","exports","../Enum/Severity","../Modal"],function(a,b,c,d){"use strict";var e=function(){function a(){}return a.wizard=function(a,b){d.advanced({callback:function(a){a.find(".t3js-modal-body").addClass("t3-new-content-element-wizard-window")},content:a,severity:c.SeverityEnum.notice,size:d.sizes.medium,title:b,type:d.types.ajax})},a}();return e});
\ No newline at end of file