[BUGFIX] Adjust modal window processing and RequireJS loading 07/59107/5
authorOliver Hader <oliver@typo3.org>
Tue, 11 Dec 2018 11:46:40 +0000 (12:46 +0100)
committerOliver Hader <oliver.hader@typo3.org>
Tue, 11 Dec 2018 12:31:50 +0000 (13:31 +0100)
Resolves: #87123
Releases: master, 8.7, 7.6
Change-Id: Idceecb174682261b967ea284e12e1836bb7e7bea
Reviewed-on: https://review.typo3.org/59107
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
typo3/sysext/backend/Resources/Private/TypeScript/ImageManipulation.ts
typo3/sysext/backend/Resources/Private/TypeScript/Modal.ts
typo3/sysext/backend/Resources/Public/JavaScript/ImageManipulation.js
typo3/sysext/backend/Resources/Public/JavaScript/Modal.js
typo3/sysext/install/Resources/Public/JavaScript/Modules/Router.js
typo3/sysext/install/Resources/Public/JavaScript/RequireJSConfig.js

index 0835d94..c311943 100644 (file)
@@ -269,7 +269,7 @@ class ImageManipulation {
             currentModal.find('.t3js-modal-body').append(response).addClass('cropper');
           });
         },
-        content: '<div class="modal-loading">' + icon + '</div>',
+        content: $('<div class="modal-loading">').append(icon),
         size: Modal.sizes.full,
         style: Modal.styles.dark,
         title: modalTitle,
index 76d53ab..991b2dc 100644 (file)
@@ -254,15 +254,9 @@ class Modal {
     configuration.title = typeof configuration.title === 'string'
       ? configuration.title
       : this.defaultConfiguration.title;
-    if (typeof configuration.content === 'string') {
-      // A string means, no markup allowed, let's ensure this
-      configuration.content = this.securityUtility.encodeHtml(configuration.content);
-    } else if (typeof configuration.content === 'object') {
-      // An object means, a valid jQuery object with markup, let's get the markup
-      configuration.content = configuration.content.html();
-    } else {
-      configuration.content = this.defaultConfiguration.content;
-    }
+    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;
@@ -385,7 +379,9 @@ class Modal {
       });
     } else {
       if (typeof configuration.content === 'string') {
-        configuration.content = $('<p />').html(configuration.content);
+        configuration.content = $('<p />').html(
+          this.securityUtility.encodeHtml(configuration.content)
+        );
       }
       currentModal.find(Identifiers.body).append(configuration.content);
     }
index 48fc8e1..621d426 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","jquery","./Icons","./Modal","TYPO3/CMS/Core/Contrib/imagesloaded.pkgd.min","jquery-ui/draggable","jquery-ui/resizable"],function(t,r,e,a,i,o){"use strict";return new(function(){function t(){var r=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 a=r.cropper.cropper("getImageData"),i=r.currentModal.find(r.cropImageSelector);r.imageOriginalSizeFactor=i.data("originalWidth")/a.naturalWidth,r.cropVariantTriggers.each(function(t,i){var o=e(i).attr("data-crop-variant-id"),n=r.convertRelativeToAbsoluteCropArea(r.data[o].cropArea,a),s=e.extend(!0,{},r.data[o],{cropArea:n});r.updatePreviewThumbnail(s,e(i))}),r.currentCropVariant.cropArea=r.convertRelativeToAbsoluteCropArea(r.currentCropVariant.cropArea,a),r.cropBox=r.currentModal.find(".cropper-crop-box"),r.setCropArea(r.currentCropVariant.cropArea),r.currentCropVariant.coverAreas&&r.initCoverAreas(r.cropBox,r.currentCropVariant.coverAreas),r.currentCropVariant.focusArea&&(t.isEmptyArea(r.currentCropVariant.focusArea)&&(r.currentCropVariant.focusArea=e.extend(!0,{},r.defaultFocusArea)),r.initFocusArea(r.cropBox),r.scaleAndMoveFocusArea(r.currentCropVariant.focusArea)),r.currentCropVariant.selectedRatio&&(r.setAspectRatio(r.currentCropVariant.allowedAspectRatios[r.currentCropVariant.selectedRatio]),r.setCropArea(r.currentCropVariant.cropArea),r.currentModal.find("[data-option='"+r.currentCropVariant.selectedRatio+"']").addClass("active")),r.cropperCanvas.addClass("is-visible")},this.cropMoveHandler=function(t){r.currentCropVariant.cropArea=e.extend(!0,r.currentCropVariant.cropArea,{height:Math.floor(t.height),width:Math.floor(t.width),x:Math.floor(t.x),y:Math.floor(t.y)}),r.updatePreviewThumbnail(r.currentCropVariant,r.activeCropVariantTrigger),r.updateCropVariantData(r.currentCropVariant);var a=Math.round(r.currentCropVariant.cropArea.width*r.imageOriginalSizeFactor),i=Math.round(r.currentCropVariant.cropArea.height*r.imageOriginalSizeFactor);r.cropInfo.text(a+"×"+i+" px")},this.cropStartHandler=function(){r.currentCropVariant.focusArea&&(r.focusArea.draggable("option","disabled",!0),r.focusArea.resizable("option","disabled",!0))},this.cropEndHandler=function(){r.currentCropVariant.focusArea&&(r.focusArea.draggable("option","disabled",!1),r.focusArea.resizable("option","disabled",!1))},e(window).resize(function(){r.cropper&&r.cropper.cropper("destroy")}),this.resizeEnd(function(){r.cropper&&r.init()})}return t.isEmptyArea=function(t){return e.isEmptyObject(t)},t.wait=function(t,r){window.setTimeout(t,r)},t.toCssPercent=function(t){return 100*t+"%"},t.serializeCropVariants=function(t){return JSON.stringify(t,function(t,r){return"id"===t||"title"===t||"allowedAspectRatios"===t||"coverAreas"===t?void 0:r})},t.prototype.initializeTrigger=function(){var t=this;e(".t3js-image-manipulation-trigger").off("click").click(function(r){r.preventDefault(),t.trigger=e(r.currentTarget),t.show()})},t.prototype.initializeCropperModal=function(){var t=this,r=this.currentModal.find(this.cropImageSelector);o(r,function(){setTimeout(function(){t.init()},100)})},t.prototype.show=function(){var t=this,r=this.trigger.data("modalTitle"),o=this.trigger.data("buttonPreviewText"),n=this.trigger.data("buttonDismissText"),s=this.trigger.data("buttonSaveText"),c=this.trigger.data("url"),p=this.trigger.data("payload"),u=this.initializeCropperModal.bind(this);a.getIcon("spinner-circle",a.sizes.default,null,null,a.markupIdentifiers.inline).done(function(a){t.currentModal=i.advanced({additionalCssClasses:["modal-image-manipulation"],buttons:[{btnClass:"btn-default pull-left",dataAttributes:{method:"preview"},icon:"actions-view",text:o},{btnClass:"btn-default",dataAttributes:{method:"dismiss"},icon:"actions-close",text:n},{btnClass:"btn-primary",dataAttributes:{method:"save"},icon:"actions-document-save",text:s}],callback:function(t){e.post({url:c,data:p}).done(function(r){u(),t.find(".t3js-modal-body").append(r).addClass("cropper")})},content:'<div class="modal-loading">'+a+"</div>",size:i.sizes.full,style:i.styles.dark,title:r}),t.currentModal.on("hide.bs.modal",function(r){t.destroy()}),t.currentModal.data("bs.modal").options.backdrop="static"})},t.prototype.init=function(){var r=this,a=this.currentModal.find(this.cropImageSelector),i=e(a).height(),o=e(a).width(),n=this.trigger.attr("data-crop-variants");if(!n)throw new TypeError("ImageManipulation: No cropVariants data found for image");this.data=e.isEmptyObject(this.data)?JSON.parse(n):this.data,this.currentModal.find(this.cropImageContainerSelector).css({height:i,width:o}),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(t){if(e(t.currentTarget).hasClass("is-active"))return t.stopPropagation(),void t.preventDefault();r.activeCropVariantTrigger.removeClass("is-active"),e(t.currentTarget).addClass("is-active"),r.activeCropVariantTrigger=e(t.currentTarget);var a=r.data[r.activeCropVariantTrigger.attr("data-crop-variant-id")],i=r.cropper.cropper("getImageData");a.cropArea=r.convertRelativeToAbsoluteCropArea(a.cropArea,i),r.currentCropVariant=e.extend(!0,{},a),r.update(a)}),this.aspectRatioTrigger.off("click").on("click",function(t){var a=e(t.currentTarget).attr("data-option"),i=e.extend(!0,{},r.currentCropVariant),o=i.allowedAspectRatios[a];r.setAspectRatio(o),r.setCropArea(i.cropArea),r.currentCropVariant=e.extend(!0,{},i,{selectedRatio:a}),r.update(r.currentCropVariant)}),this.saveButton.off("click").on("click",function(){r.save(r.data)}),this.trigger.attr("data-preview-url")?this.previewButton.off("click").on("click",function(){r.openPreview(r.data)}):this.previewButton.hide(),this.dismissButton.off("click").on("click",function(){r.currentModal.modal("hide")}),this.resetButton.off("click").on("click",function(t){var a=r.cropper.cropper("getImageData"),i=e(t.currentTarget).attr("data-crop-variant");if(t.preventDefault(),t.stopPropagation(),!i)throw new TypeError("TYPO3 Cropper: No cropVariant data attribute found on reset element.");var o=JSON.parse(i),n=r.convertRelativeToAbsoluteCropArea(o.cropArea,a);r.currentCropVariant=e.extend(!0,{},o,{cropArea:n}),r.update(r.currentCropVariant)}),t.isEmptyArea(this.currentCropVariant.cropArea)&&(this.defaultOpts=e.extend({autoCropArea:1},this.defaultOpts)),this.cropper=top.$(a).cropper(e.extend(this.defaultOpts,{built:this.cropBuiltHandler,crop:this.cropMoveHandler,cropend:this.cropEndHandler,cropstart:this.cropStartHandler,data:this.currentCropVariant.cropArea}))},t.prototype.update=function(r){var a=e.extend(!0,{},r),i=r.allowedAspectRatios[r.selectedRatio];this.currentModal.find("[data-option]").removeClass("active"),this.currentModal.find('[data-option="'+r.selectedRatio+'"]').addClass("active"),this.setAspectRatio(i),this.setCropArea(a.cropArea),this.currentCropVariant=e.extend(!0,{},a,r),this.cropBox.find(this.coverAreaSelector).remove(),this.cropBox.has(this.focusAreaSelector).length&&(this.focusArea.resizable("destroy").draggable("destroy"),this.focusArea.remove()),r.focusArea&&(t.isEmptyArea(r.focusArea)&&(this.currentCropVariant.focusArea=e.extend(!0,{},this.defaultFocusArea)),this.initFocusArea(this.cropBox),this.scaleAndMoveFocusArea(this.currentCropVariant.focusArea)),r.coverAreas&&this.initCoverAreas(this.cropBox,this.currentCropVariant.coverAreas),this.updatePreviewThumbnail(this.currentCropVariant,this.activeCropVariantTrigger)},t.prototype.initFocusArea=function(r){var a=this;this.focusArea=e('<div id="t3js-cropper-focus-area" class="cropper-focus-area"></div>'),r.append(this.focusArea),this.focusArea.draggable({containment:r,create:function(){a.scaleAndMoveFocusArea(a.currentCropVariant.focusArea)},drag:function(){var t=r.offset(),e=t.left,i=t.top,o=a.focusArea.offset(),n=o.left,s=o.top,c=a.currentCropVariant,p=c.focusArea,u=c.coverAreas;p.x=(n-e)/r.width(),p.y=(s-i)/r.height(),a.updatePreviewThumbnail(a.currentCropVariant,a.activeCropVariantTrigger),a.checkFocusAndCoverAreasCollision(p,u)?a.focusArea.addClass("has-nodrop"):a.focusArea.removeClass("has-nodrop")},revert:function(){var e=r.offset(),i=e.left,o=e.top,n=a.focusArea.offset(),s=n.left,c=n.top,p=a.currentCropVariant,u=p.focusArea,d=p.coverAreas;return!!a.checkFocusAndCoverAreasCollision(u,d)&&(a.focusArea.removeClass("has-nodrop"),t.wait(function(){u.x=(s-i)/r.width(),u.y=(c-o)/r.height(),a.updateCropVariantData(a.currentCropVariant)},250),!0)},revertDuration:200,stop:function(){var t=r.offset(),e=t.left,i=t.top,o=a.focusArea.offset(),n=o.left,s=o.top,c=a.currentCropVariant.focusArea;c.x=(n-e)/r.width(),c.y=(s-i)/r.height(),a.scaleAndMoveFocusArea(c)}}).resizable({containment:r,handles:"all",resize:function(){var t=r.offset(),e=t.left,i=t.top,o=a.focusArea.offset(),n=o.left,s=o.top,c=a.currentCropVariant,p=c.focusArea,u=c.coverAreas;p.height=a.focusArea.height()/r.height(),p.width=a.focusArea.width()/r.width(),p.x=(n-e)/r.width(),p.y=(s-i)/r.height(),a.updatePreviewThumbnail(a.currentCropVariant,a.activeCropVariantTrigger),a.checkFocusAndCoverAreasCollision(p,u)?a.focusArea.addClass("has-nodrop"):a.focusArea.removeClass("has-nodrop")},stop:function(t,i){var o=r.offset(),n=o.left,s=o.top,c=a.focusArea.offset(),p=c.left,u=c.top,d=a.currentCropVariant,h=d.focusArea,l=d.coverAreas;a.checkFocusAndCoverAreasCollision(h,l)?i.element.animate(e.extend(i.originalPosition,i.originalSize),250,function(){h.height=a.focusArea.height()/r.height(),h.height=a.focusArea.height()/r.height(),h.width=a.focusArea.width()/r.width(),h.x=(p-n)/r.width(),h.y=(u-s)/r.height(),a.scaleAndMoveFocusArea(h),a.focusArea.removeClass("has-nodrop")}):a.scaleAndMoveFocusArea(h)}})},t.prototype.initCoverAreas=function(r,a){a.forEach(function(a){var i=e('<div class="cropper-cover-area t3js-cropper-cover-area"></div>');r.append(i),i.css({height:t.toCssPercent(a.height),left:t.toCssPercent(a.x),top:t.toCssPercent(a.y),width:t.toCssPercent(a.width)})})},t.prototype.updatePreviewThumbnail=function(r,e){var a,i=e.find(".t3js-cropper-preview-thumbnail-crop-area"),o=e.find(".t3js-cropper-preview-thumbnail-crop-image"),n=e.find(".t3js-cropper-preview-thumbnail-focus-area"),s=this.cropper.cropper("getImageData");i.css({height:t.toCssPercent(r.cropArea.height/s.naturalHeight),left:t.toCssPercent(r.cropArea.x/s.naturalWidth),top:t.toCssPercent(r.cropArea.y/s.naturalHeight),width:t.toCssPercent(r.cropArea.width/s.naturalWidth)}),r.focusArea&&n.css({height:t.toCssPercent(r.focusArea.height),left:t.toCssPercent(r.focusArea.x),top:t.toCssPercent(r.focusArea.y),width:t.toCssPercent(r.focusArea.width)}),a=i.css(["width","height","left","top"]),o.css({height:parseFloat(a.height)*(1/(r.cropArea.height/s.naturalHeight))+"px",margin:-1*parseFloat(a.left)+"px",marginTop:-1*parseFloat(a.top)+"px",width:parseFloat(a.width)*(1/(r.cropArea.width/s.naturalWidth))+"px"})},t.prototype.scaleAndMoveFocusArea=function(r){this.focusArea.css({height:t.toCssPercent(r.height),left:t.toCssPercent(r.x),top:t.toCssPercent(r.y),width:t.toCssPercent(r.width)}),this.currentCropVariant.focusArea=r,this.updatePreviewThumbnail(this.currentCropVariant,this.activeCropVariantTrigger),this.updateCropVariantData(this.currentCropVariant)},t.prototype.updateCropVariantData=function(t){var r=this.cropper.cropper("getImageData"),a=this.convertAbsoluteToRelativeCropArea(t.cropArea,r);this.data[t.id]=e.extend(!0,{},t,{cropArea:a})},t.prototype.setAspectRatio=function(t){this.cropper.cropper("setAspectRatio",t.value)},t.prototype.setCropArea=function(t){0===this.currentCropVariant.allowedAspectRatios[this.currentCropVariant.selectedRatio].value?this.cropper.cropper("setData",{height:t.height,width:t.width,x:t.x,y:t.y}):this.cropper.cropper("setData",{height:t.height,x:t.x,y:t.y})},t.prototype.checkFocusAndCoverAreasCollision=function(t,r){return!!r&&r.some(function(r){return t.x<r.x+r.width&&t.x+t.width>r.x&&t.y<r.y+r.height&&t.height+t.y>r.y})},t.prototype.convertAbsoluteToRelativeCropArea=function(t,r){var e=t.height,a=t.width,i=t.x,o=t.y;return{height:e/r.naturalHeight,width:a/r.naturalWidth,x:i/r.naturalWidth,y:o/r.naturalHeight}},t.prototype.convertRelativeToAbsoluteCropArea=function(t,r){var e=t.height,a=t.width,i=t.x,o=t.y;return{height:e*r.naturalHeight,width:a*r.naturalWidth,x:i*r.naturalWidth,y:o*r.naturalHeight}},t.prototype.setPreviewImages=function(t){var r=this,a=this.cropper,i=a.cropper("getImageData");Object.keys(t).forEach(function(o){var n=t[o],s=r.convertRelativeToAbsoluteCropArea(n.cropArea,i),c=r.trigger.closest(".form-group").find('.t3js-image-manipulation-preview[data-crop-variant-id="'+o+'"]'),p=r.trigger.closest(".form-group").find('.t3js-image-manipulation-selected-ratio[data-crop-variant-id="'+o+'"]');if(0!==c.length){var u=c.width(),d=c.data("preview-height"),h=s.width/s.height,l=u/h;l>d?u=d*h:d=l,u>s.width&&(u=s.width,d=s.height);var f=u/s.width,g=e("<div />").html('<img src="'+a.attr("src")+'">'),v=r.currentModal.find('.t3-js-ratio-title[data-ratio-id="'+n.id+n.selectedRatio+'"]');p.text(v.text()),g.addClass("cropper-preview-container"),c.empty().append(g),g.wrap('<span class="thumbnail thumbnail-status"></span>'),g.width(u).height(d).find("img").css({height:i.naturalHeight*f,left:-s.x*f,top:-s.y*f,width:i.naturalWidth*f})}})},t.prototype.openPreview=function(r){var e=t.serializeCropVariants(r),a=this.trigger.attr("data-preview-url");a=a+"&cropVariants="+encodeURIComponent(e),window.open(a,"TYPO3ImageManipulationPreview")},t.prototype.save=function(r){var a=t.serializeCropVariants(r),i=e("#"+this.trigger.attr("data-field"));this.trigger.attr("data-crop-variants",JSON.stringify(r)),this.setPreviewImages(r),i.val(a),this.currentModal.modal("hide")},t.prototype.destroy=function(){this.currentModal&&(void 0!==this.cropper&&null!==this.cropper&&this.cropper.cropper("destroy"),this.cropper=null,this.currentModal=null,this.data=null)},t.prototype.resizeEnd=function(t){var r,a=this;e(window).on("resize",function(){clearTimeout(r),r=setTimeout(function(){t()},a.resizeTimeout)})},t}())});
\ No newline at end of file
+define(["require","exports","jquery","./Icons","./Modal","TYPO3/CMS/Core/Contrib/imagesloaded.pkgd.min","jquery-ui/draggable","jquery-ui/resizable"],function(t,r,e,a,i,o){"use strict";return new(function(){function t(){var r=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 a=r.cropper.cropper("getImageData"),i=r.currentModal.find(r.cropImageSelector);r.imageOriginalSizeFactor=i.data("originalWidth")/a.naturalWidth,r.cropVariantTriggers.each(function(t,i){var o=e(i).attr("data-crop-variant-id"),n=r.convertRelativeToAbsoluteCropArea(r.data[o].cropArea,a),s=e.extend(!0,{},r.data[o],{cropArea:n});r.updatePreviewThumbnail(s,e(i))}),r.currentCropVariant.cropArea=r.convertRelativeToAbsoluteCropArea(r.currentCropVariant.cropArea,a),r.cropBox=r.currentModal.find(".cropper-crop-box"),r.setCropArea(r.currentCropVariant.cropArea),r.currentCropVariant.coverAreas&&r.initCoverAreas(r.cropBox,r.currentCropVariant.coverAreas),r.currentCropVariant.focusArea&&(t.isEmptyArea(r.currentCropVariant.focusArea)&&(r.currentCropVariant.focusArea=e.extend(!0,{},r.defaultFocusArea)),r.initFocusArea(r.cropBox),r.scaleAndMoveFocusArea(r.currentCropVariant.focusArea)),r.currentCropVariant.selectedRatio&&(r.setAspectRatio(r.currentCropVariant.allowedAspectRatios[r.currentCropVariant.selectedRatio]),r.setCropArea(r.currentCropVariant.cropArea),r.currentModal.find("[data-option='"+r.currentCropVariant.selectedRatio+"']").addClass("active")),r.cropperCanvas.addClass("is-visible")},this.cropMoveHandler=function(t){r.currentCropVariant.cropArea=e.extend(!0,r.currentCropVariant.cropArea,{height:Math.floor(t.height),width:Math.floor(t.width),x:Math.floor(t.x),y:Math.floor(t.y)}),r.updatePreviewThumbnail(r.currentCropVariant,r.activeCropVariantTrigger),r.updateCropVariantData(r.currentCropVariant);var a=Math.round(r.currentCropVariant.cropArea.width*r.imageOriginalSizeFactor),i=Math.round(r.currentCropVariant.cropArea.height*r.imageOriginalSizeFactor);r.cropInfo.text(a+"×"+i+" px")},this.cropStartHandler=function(){r.currentCropVariant.focusArea&&(r.focusArea.draggable("option","disabled",!0),r.focusArea.resizable("option","disabled",!0))},this.cropEndHandler=function(){r.currentCropVariant.focusArea&&(r.focusArea.draggable("option","disabled",!1),r.focusArea.resizable("option","disabled",!1))},e(window).resize(function(){r.cropper&&r.cropper.cropper("destroy")}),this.resizeEnd(function(){r.cropper&&r.init()})}return t.isEmptyArea=function(t){return e.isEmptyObject(t)},t.wait=function(t,r){window.setTimeout(t,r)},t.toCssPercent=function(t){return 100*t+"%"},t.serializeCropVariants=function(t){return JSON.stringify(t,function(t,r){return"id"===t||"title"===t||"allowedAspectRatios"===t||"coverAreas"===t?void 0:r})},t.prototype.initializeTrigger=function(){var t=this;e(".t3js-image-manipulation-trigger").off("click").click(function(r){r.preventDefault(),t.trigger=e(r.currentTarget),t.show()})},t.prototype.initializeCropperModal=function(){var t=this,r=this.currentModal.find(this.cropImageSelector);o(r,function(){setTimeout(function(){t.init()},100)})},t.prototype.show=function(){var t=this,r=this.trigger.data("modalTitle"),o=this.trigger.data("buttonPreviewText"),n=this.trigger.data("buttonDismissText"),s=this.trigger.data("buttonSaveText"),c=this.trigger.data("url"),p=this.trigger.data("payload"),u=this.initializeCropperModal.bind(this);a.getIcon("spinner-circle",a.sizes.default,null,null,a.markupIdentifiers.inline).done(function(a){t.currentModal=i.advanced({additionalCssClasses:["modal-image-manipulation"],buttons:[{btnClass:"btn-default pull-left",dataAttributes:{method:"preview"},icon:"actions-view",text:o},{btnClass:"btn-default",dataAttributes:{method:"dismiss"},icon:"actions-close",text:n},{btnClass:"btn-primary",dataAttributes:{method:"save"},icon:"actions-document-save",text:s}],callback:function(t){e.post({url:c,data:p}).done(function(r){u(),t.find(".t3js-modal-body").append(r).addClass("cropper")})},content:e('<div class="modal-loading">').append(a),size:i.sizes.full,style:i.styles.dark,title:r}),t.currentModal.on("hide.bs.modal",function(r){t.destroy()}),t.currentModal.data("bs.modal").options.backdrop="static"})},t.prototype.init=function(){var r=this,a=this.currentModal.find(this.cropImageSelector),i=e(a).height(),o=e(a).width(),n=this.trigger.attr("data-crop-variants");if(!n)throw new TypeError("ImageManipulation: No cropVariants data found for image");this.data=e.isEmptyObject(this.data)?JSON.parse(n):this.data,this.currentModal.find(this.cropImageContainerSelector).css({height:i,width:o}),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(t){if(e(t.currentTarget).hasClass("is-active"))return t.stopPropagation(),void t.preventDefault();r.activeCropVariantTrigger.removeClass("is-active"),e(t.currentTarget).addClass("is-active"),r.activeCropVariantTrigger=e(t.currentTarget);var a=r.data[r.activeCropVariantTrigger.attr("data-crop-variant-id")],i=r.cropper.cropper("getImageData");a.cropArea=r.convertRelativeToAbsoluteCropArea(a.cropArea,i),r.currentCropVariant=e.extend(!0,{},a),r.update(a)}),this.aspectRatioTrigger.off("click").on("click",function(t){var a=e(t.currentTarget).attr("data-option"),i=e.extend(!0,{},r.currentCropVariant),o=i.allowedAspectRatios[a];r.setAspectRatio(o),r.setCropArea(i.cropArea),r.currentCropVariant=e.extend(!0,{},i,{selectedRatio:a}),r.update(r.currentCropVariant)}),this.saveButton.off("click").on("click",function(){r.save(r.data)}),this.trigger.attr("data-preview-url")?this.previewButton.off("click").on("click",function(){r.openPreview(r.data)}):this.previewButton.hide(),this.dismissButton.off("click").on("click",function(){r.currentModal.modal("hide")}),this.resetButton.off("click").on("click",function(t){var a=r.cropper.cropper("getImageData"),i=e(t.currentTarget).attr("data-crop-variant");if(t.preventDefault(),t.stopPropagation(),!i)throw new TypeError("TYPO3 Cropper: No cropVariant data attribute found on reset element.");var o=JSON.parse(i),n=r.convertRelativeToAbsoluteCropArea(o.cropArea,a);r.currentCropVariant=e.extend(!0,{},o,{cropArea:n}),r.update(r.currentCropVariant)}),t.isEmptyArea(this.currentCropVariant.cropArea)&&(this.defaultOpts=e.extend({autoCropArea:1},this.defaultOpts)),this.cropper=top.$(a).cropper(e.extend(this.defaultOpts,{built:this.cropBuiltHandler,crop:this.cropMoveHandler,cropend:this.cropEndHandler,cropstart:this.cropStartHandler,data:this.currentCropVariant.cropArea}))},t.prototype.update=function(r){var a=e.extend(!0,{},r),i=r.allowedAspectRatios[r.selectedRatio];this.currentModal.find("[data-option]").removeClass("active"),this.currentModal.find('[data-option="'+r.selectedRatio+'"]').addClass("active"),this.setAspectRatio(i),this.setCropArea(a.cropArea),this.currentCropVariant=e.extend(!0,{},a,r),this.cropBox.find(this.coverAreaSelector).remove(),this.cropBox.has(this.focusAreaSelector).length&&(this.focusArea.resizable("destroy").draggable("destroy"),this.focusArea.remove()),r.focusArea&&(t.isEmptyArea(r.focusArea)&&(this.currentCropVariant.focusArea=e.extend(!0,{},this.defaultFocusArea)),this.initFocusArea(this.cropBox),this.scaleAndMoveFocusArea(this.currentCropVariant.focusArea)),r.coverAreas&&this.initCoverAreas(this.cropBox,this.currentCropVariant.coverAreas),this.updatePreviewThumbnail(this.currentCropVariant,this.activeCropVariantTrigger)},t.prototype.initFocusArea=function(r){var a=this;this.focusArea=e('<div id="t3js-cropper-focus-area" class="cropper-focus-area"></div>'),r.append(this.focusArea),this.focusArea.draggable({containment:r,create:function(){a.scaleAndMoveFocusArea(a.currentCropVariant.focusArea)},drag:function(){var t=r.offset(),e=t.left,i=t.top,o=a.focusArea.offset(),n=o.left,s=o.top,c=a.currentCropVariant,p=c.focusArea,u=c.coverAreas;p.x=(n-e)/r.width(),p.y=(s-i)/r.height(),a.updatePreviewThumbnail(a.currentCropVariant,a.activeCropVariantTrigger),a.checkFocusAndCoverAreasCollision(p,u)?a.focusArea.addClass("has-nodrop"):a.focusArea.removeClass("has-nodrop")},revert:function(){var e=r.offset(),i=e.left,o=e.top,n=a.focusArea.offset(),s=n.left,c=n.top,p=a.currentCropVariant,u=p.focusArea,d=p.coverAreas;return!!a.checkFocusAndCoverAreasCollision(u,d)&&(a.focusArea.removeClass("has-nodrop"),t.wait(function(){u.x=(s-i)/r.width(),u.y=(c-o)/r.height(),a.updateCropVariantData(a.currentCropVariant)},250),!0)},revertDuration:200,stop:function(){var t=r.offset(),e=t.left,i=t.top,o=a.focusArea.offset(),n=o.left,s=o.top,c=a.currentCropVariant.focusArea;c.x=(n-e)/r.width(),c.y=(s-i)/r.height(),a.scaleAndMoveFocusArea(c)}}).resizable({containment:r,handles:"all",resize:function(){var t=r.offset(),e=t.left,i=t.top,o=a.focusArea.offset(),n=o.left,s=o.top,c=a.currentCropVariant,p=c.focusArea,u=c.coverAreas;p.height=a.focusArea.height()/r.height(),p.width=a.focusArea.width()/r.width(),p.x=(n-e)/r.width(),p.y=(s-i)/r.height(),a.updatePreviewThumbnail(a.currentCropVariant,a.activeCropVariantTrigger),a.checkFocusAndCoverAreasCollision(p,u)?a.focusArea.addClass("has-nodrop"):a.focusArea.removeClass("has-nodrop")},stop:function(t,i){var o=r.offset(),n=o.left,s=o.top,c=a.focusArea.offset(),p=c.left,u=c.top,d=a.currentCropVariant,h=d.focusArea,l=d.coverAreas;a.checkFocusAndCoverAreasCollision(h,l)?i.element.animate(e.extend(i.originalPosition,i.originalSize),250,function(){h.height=a.focusArea.height()/r.height(),h.height=a.focusArea.height()/r.height(),h.width=a.focusArea.width()/r.width(),h.x=(p-n)/r.width(),h.y=(u-s)/r.height(),a.scaleAndMoveFocusArea(h),a.focusArea.removeClass("has-nodrop")}):a.scaleAndMoveFocusArea(h)}})},t.prototype.initCoverAreas=function(r,a){a.forEach(function(a){var i=e('<div class="cropper-cover-area t3js-cropper-cover-area"></div>');r.append(i),i.css({height:t.toCssPercent(a.height),left:t.toCssPercent(a.x),top:t.toCssPercent(a.y),width:t.toCssPercent(a.width)})})},t.prototype.updatePreviewThumbnail=function(r,e){var a,i=e.find(".t3js-cropper-preview-thumbnail-crop-area"),o=e.find(".t3js-cropper-preview-thumbnail-crop-image"),n=e.find(".t3js-cropper-preview-thumbnail-focus-area"),s=this.cropper.cropper("getImageData");i.css({height:t.toCssPercent(r.cropArea.height/s.naturalHeight),left:t.toCssPercent(r.cropArea.x/s.naturalWidth),top:t.toCssPercent(r.cropArea.y/s.naturalHeight),width:t.toCssPercent(r.cropArea.width/s.naturalWidth)}),r.focusArea&&n.css({height:t.toCssPercent(r.focusArea.height),left:t.toCssPercent(r.focusArea.x),top:t.toCssPercent(r.focusArea.y),width:t.toCssPercent(r.focusArea.width)}),a=i.css(["width","height","left","top"]),o.css({height:parseFloat(a.height)*(1/(r.cropArea.height/s.naturalHeight))+"px",margin:-1*parseFloat(a.left)+"px",marginTop:-1*parseFloat(a.top)+"px",width:parseFloat(a.width)*(1/(r.cropArea.width/s.naturalWidth))+"px"})},t.prototype.scaleAndMoveFocusArea=function(r){this.focusArea.css({height:t.toCssPercent(r.height),left:t.toCssPercent(r.x),top:t.toCssPercent(r.y),width:t.toCssPercent(r.width)}),this.currentCropVariant.focusArea=r,this.updatePreviewThumbnail(this.currentCropVariant,this.activeCropVariantTrigger),this.updateCropVariantData(this.currentCropVariant)},t.prototype.updateCropVariantData=function(t){var r=this.cropper.cropper("getImageData"),a=this.convertAbsoluteToRelativeCropArea(t.cropArea,r);this.data[t.id]=e.extend(!0,{},t,{cropArea:a})},t.prototype.setAspectRatio=function(t){this.cropper.cropper("setAspectRatio",t.value)},t.prototype.setCropArea=function(t){0===this.currentCropVariant.allowedAspectRatios[this.currentCropVariant.selectedRatio].value?this.cropper.cropper("setData",{height:t.height,width:t.width,x:t.x,y:t.y}):this.cropper.cropper("setData",{height:t.height,x:t.x,y:t.y})},t.prototype.checkFocusAndCoverAreasCollision=function(t,r){return!!r&&r.some(function(r){return t.x<r.x+r.width&&t.x+t.width>r.x&&t.y<r.y+r.height&&t.height+t.y>r.y})},t.prototype.convertAbsoluteToRelativeCropArea=function(t,r){var e=t.height,a=t.width,i=t.x,o=t.y;return{height:e/r.naturalHeight,width:a/r.naturalWidth,x:i/r.naturalWidth,y:o/r.naturalHeight}},t.prototype.convertRelativeToAbsoluteCropArea=function(t,r){var e=t.height,a=t.width,i=t.x,o=t.y;return{height:e*r.naturalHeight,width:a*r.naturalWidth,x:i*r.naturalWidth,y:o*r.naturalHeight}},t.prototype.setPreviewImages=function(t){var r=this,a=this.cropper,i=a.cropper("getImageData");Object.keys(t).forEach(function(o){var n=t[o],s=r.convertRelativeToAbsoluteCropArea(n.cropArea,i),c=r.trigger.closest(".form-group").find('.t3js-image-manipulation-preview[data-crop-variant-id="'+o+'"]'),p=r.trigger.closest(".form-group").find('.t3js-image-manipulation-selected-ratio[data-crop-variant-id="'+o+'"]');if(0!==c.length){var u=c.width(),d=c.data("preview-height"),h=s.width/s.height,l=u/h;l>d?u=d*h:d=l,u>s.width&&(u=s.width,d=s.height);var f=u/s.width,g=e("<div />").html('<img src="'+a.attr("src")+'">'),v=r.currentModal.find('.t3-js-ratio-title[data-ratio-id="'+n.id+n.selectedRatio+'"]');p.text(v.text()),g.addClass("cropper-preview-container"),c.empty().append(g),g.wrap('<span class="thumbnail thumbnail-status"></span>'),g.width(u).height(d).find("img").css({height:i.naturalHeight*f,left:-s.x*f,top:-s.y*f,width:i.naturalWidth*f})}})},t.prototype.openPreview=function(r){var e=t.serializeCropVariants(r),a=this.trigger.attr("data-preview-url");a=a+"&cropVariants="+encodeURIComponent(e),window.open(a,"TYPO3ImageManipulationPreview")},t.prototype.save=function(r){var a=t.serializeCropVariants(r),i=e("#"+this.trigger.attr("data-field"));this.trigger.attr("data-crop-variants",JSON.stringify(r)),this.setPreviewImages(r),i.val(a),this.currentModal.modal("hide")},t.prototype.destroy=function(){this.currentModal&&(void 0!==this.cropper&&null!==this.cropper&&this.cropper.cropper("destroy"),this.cropper=null,this.currentModal=null,this.data=null)},t.prototype.resizeEnd=function(t){var r,a=this;e(window).on("resize",function(){clearTimeout(r),r=setTimeout(function(){t()},a.resizeTimeout)})},t}())});
\ No newline at end of file
index b1ac6bf..ff18f8a 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-var __values=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],a=0;return e?e.call(t):{next:function(){return t&&a>=t.length&&(t=void 0),{value:t&&t[a++],done:!t}}}};define(["require","exports","./Enum/Severity","jquery","./Icons","./Severity","TYPO3/CMS/Core/SecurityUtility","bootstrap"],function(t,e,a,n,i,o,l){"use strict";var s,r,d,c,u,f,m,g;(r=s||(s={})).modal=".t3js-modal",r.content=".t3js-modal-content",r.title=".t3js-modal-title",r.close=".t3js-modal-close",r.body=".t3js-modal-body",r.footer=".t3js-modal-footer",r.iframe=".t3js-modal-iframe",r.iconPlaceholder=".t3js-modal-icon-placeholder",(c=d||(d={})).small="small",c.default="default",c.medium="medium",c.large="large",c.full="full",(f=u||(u={})).default="default",f.light="light",f.dark="dark",(g=m||(m={})).default="default",g.ajax="ajax",g.iframe="iframe";var p=function(){function t(t){this.sizes=d,this.styles=u,this.types=m,this.currentModal=null,this.instances=[],this.$template=n('<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:m.default,title:"Information",content:"No content provided, please check your <code>Modal</code> configuration.",severity:a.SeverityEnum.notice,buttons:[],style:u.default,size:d.default,additionalCssClasses:[],callback:n.noop(),ajaxCallback:n.noop(),ajaxTarget:null},this.securityUtility=t,n(document).on("modal-dismiss",this.dismiss),this.initializeMarkupTrigger(document)}return t.prototype.dismiss=function(){this.currentModal&&this.currentModal.modal("hide")},t.prototype.confirm=function(t,e,i,l,s){return void 0===i&&(i=a.SeverityEnum.warning),void 0===l&&(l=[]),0===l.length&&l.push({text:n(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:n(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-"+o.getCssClass(i),name:"ok"}),this.advanced({title:t,content:e,severity:i,buttons:l,additionalCssClasses:s,callback:function(t){t.on("button.clicked",function(t){"cancel"===t.target.getAttribute("name")?n(t.currentTarget).trigger("confirm.button.cancel"):"ok"===t.target.getAttribute("name")&&n(t.currentTarget).trigger("confirm.button.ok")})}})},t.prototype.loadUrl=function(t,e,n,i,o,l){return void 0===e&&(e=a.SeverityEnum.info),this.advanced({type:m.ajax,title:t,severity:e,buttons:n,ajaxCallback:o,ajaxTarget:l})},t.prototype.show=function(t,e,n,i,o){return void 0===n&&(n=a.SeverityEnum.info),this.advanced({type:m.default,title:t,content:e,severity:n,buttons:i,additionalCssClasses:o})},t.prototype.advanced=function(t){return t.type="string"==typeof t.type&&t.type in m?t.type:this.defaultConfiguration.type,t.title="string"==typeof t.title?t.title:this.defaultConfiguration.title,"string"==typeof t.content?t.content=this.securityUtility.encodeHtml(t.content):"object"==typeof t.content?t.content=t.content.html():t.content=this.defaultConfiguration.content,t.severity=void 0!==t.severity?t.severity:this.defaultConfiguration.severity,t.buttons=t.buttons||this.defaultConfiguration.buttons,t.size="string"==typeof t.size&&t.size in d?t.size:this.defaultConfiguration.size,t.style="string"==typeof t.style&&t.style in u?t.style:this.defaultConfiguration.style,t.additionalCssClasses=t.additionalCssClasses||this.defaultConfiguration.additionalCssClasses,t.callback="function"==typeof t.callback?t.callback:this.defaultConfiguration.callback,t.ajaxCallback="function"==typeof t.ajaxCallback?t.ajaxCallback:this.defaultConfiguration.ajaxCallback,t.ajaxTarget="string"==typeof t.ajaxTarget?t.ajaxTarget:this.defaultConfiguration.ajaxTarget,this.generate(t)},t.prototype.initializeMarkupTrigger=function(t){var e=this;n(t).on("click",".t3js-modal-trigger",function(t){t.preventDefault();var i=n(t.currentTarget),l=i.data("content")||"Are you sure?",s=void 0!==a.SeverityEnum[i.data("severity")]?a.SeverityEnum[i.data("severity")]:a.SeverityEnum.info,r=i.data("url")||null;null!==r&&(r=r+(r.indexOf("?")>-1?"&":"?")+n.param({data:i.data()}));e.advanced({type:null!==r?m.ajax:m.default,title:i.data("title")||"Alert",content:null!==r?r:l,severity:s,buttons:[{text:i.data("button-close-text")||TYPO3.lang["button.close"]||"Close",active:!0,btnClass:"btn-default",trigger:function(){e.currentModal.trigger("modal-dismiss")}},{text:i.data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-"+o.getCssClass(s),trigger:function(){e.currentModal.trigger("modal-dismiss"),t.target.ownerDocument.location.href=i.data("href")||i.attr("href")}}]})})},t.prototype.generate=function(t){var e,a,l=this,r=this.$template.clone();if(t.additionalCssClasses.length>0)try{for(var d=__values(t.additionalCssClasses),c=d.next();!c.done;c=d.next()){var u=c.value;r.addClass(u)}}catch(t){e={error:t}}finally{try{c&&!c.done&&(a=d.return)&&a.call(d)}finally{if(e)throw e.error}}if(r.addClass("modal-type-"+t.type),r.addClass("modal-severity-"+o.getCssClass(t.severity)),r.addClass("modal-style-"+t.style),r.addClass("modal-size-"+t.size),r.attr("tabindex","-1"),r.find(s.title).text(t.title),r.find(s.close).on("click",function(){r.modal("hide")}),"ajax"===t.type){var f=t.ajaxTarget?t.ajaxTarget:s.body,m=r.find(f);i.getIcon("spinner-circle",i.sizes.default,null,null,i.markupIdentifiers.inline).done(function(e){m.html('<div class="modal-loading">'+e+"</div>"),n.get(t.content,function(e){l.currentModal.find(f).empty().append(e),t.ajaxCallback&&t.ajaxCallback(),l.currentModal.trigger("modal-loaded")},"html")})}else"iframe"===t.type?(r.find(s.body).append(n("<iframe />",{src:t.content,name:"modal_frame",class:"modal-iframe t3js-modal-iframe"})),r.find(s.iframe).on("load",function(){r.find(s.title).text(r.find(s.iframe).get(0).contentDocument.title)})):("string"==typeof t.content&&(t.content=n("<p />").html(t.content)),r.find(s.body).append(t.content));if(t.buttons.length>0){for(var g=function(e){var a=t.buttons[e],i=n("<button />",{class:"btn"});i.html("<span>"+a.text+"</span>"),a.active&&i.addClass("t3js-active"),""!==a.btnClass&&i.addClass(a.btnClass),""!==a.name&&i.attr("name",a.name),a.trigger&&i.on("click",a.trigger),a.dataAttributes&&Object.keys(a.dataAttributes).length>0&&Object.keys(a.dataAttributes).map(function(t){i.attr("data-"+t,a.dataAttributes[t])}),a.icon&&i.prepend('<span class="t3js-modal-icon-placeholder" data-icon="'+a.icon+'"></span>'),r.find(s.footer).append(i)},p=0;p<t.buttons.length;p++)g(p);r.find(s.footer).find("button").on("click",function(t){n(t.currentTarget).trigger("button.clicked")})}else r.find(s.footer).remove();return r.on("shown.bs.modal",function(t){var e=n(t.currentTarget);e.find(s.footer).find(".t3js-active").first().focus(),e.find(s.iconPlaceholder).each(function(t,e){i.getIcon(n(e).data("icon"),i.sizes.small,null,null,i.markupIdentifiers.inline).done(function(t){l.currentModal.find(s.iconPlaceholder+"[data-icon="+n(t).data("identifier")+"]").replaceWith(t)})})}),r.on("hidden.bs.modal",function(t){if(l.instances.length>0){var e=l.instances.length-1;l.instances.splice(e,1),l.currentModal=l.instances[e-1]}r.trigger("modal-destroyed"),n(t.currentTarget).remove(),l.instances.length>0&&n("body").addClass("modal-open")}),r.on("show.bs.modal",function(t){l.currentModal=n(t.currentTarget),l.instances.push(l.currentModal)}),r.on("modal-dismiss",function(t){n(t.currentTarget).modal("hide")}),t.callback&&t.callback(r),r.modal()},t}(),y=null;try{parent&&parent.window.TYPO3&&parent.window.TYPO3.Modal?(parent.window.TYPO3.Modal.initializeMarkupTrigger(document),y=parent.window.TYPO3.Modal):top&&top.TYPO3.Modal&&(top.TYPO3.Modal.initializeMarkupTrigger(document),y=top.TYPO3.Modal)}catch(t){}return y||(y=new p(new l),TYPO3.Modal=y),y});
\ No newline at end of file
+var __values=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],a=0;return e?e.call(t):{next:function(){return t&&a>=t.length&&(t=void 0),{value:t&&t[a++],done:!t}}}};define(["require","exports","./Enum/Severity","jquery","./Icons","./Severity","TYPO3/CMS/Core/SecurityUtility","bootstrap"],function(t,e,a,n,i,o,l){"use strict";var s,r,d,c,u,f,m,g;(r=s||(s={})).modal=".t3js-modal",r.content=".t3js-modal-content",r.title=".t3js-modal-title",r.close=".t3js-modal-close",r.body=".t3js-modal-body",r.footer=".t3js-modal-footer",r.iframe=".t3js-modal-iframe",r.iconPlaceholder=".t3js-modal-icon-placeholder",(c=d||(d={})).small="small",c.default="default",c.medium="medium",c.large="large",c.full="full",(f=u||(u={})).default="default",f.light="light",f.dark="dark",(g=m||(m={})).default="default",g.ajax="ajax",g.iframe="iframe";var p=function(){function t(t){this.sizes=d,this.styles=u,this.types=m,this.currentModal=null,this.instances=[],this.$template=n('<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:m.default,title:"Information",content:"No content provided, please check your <code>Modal</code> configuration.",severity:a.SeverityEnum.notice,buttons:[],style:u.default,size:d.default,additionalCssClasses:[],callback:n.noop(),ajaxCallback:n.noop(),ajaxTarget:null},this.securityUtility=t,n(document).on("modal-dismiss",this.dismiss),this.initializeMarkupTrigger(document)}return t.prototype.dismiss=function(){this.currentModal&&this.currentModal.modal("hide")},t.prototype.confirm=function(t,e,i,l,s){return void 0===i&&(i=a.SeverityEnum.warning),void 0===l&&(l=[]),0===l.length&&l.push({text:n(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:n(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-"+o.getCssClass(i),name:"ok"}),this.advanced({title:t,content:e,severity:i,buttons:l,additionalCssClasses:s,callback:function(t){t.on("button.clicked",function(t){"cancel"===t.target.getAttribute("name")?n(t.currentTarget).trigger("confirm.button.cancel"):"ok"===t.target.getAttribute("name")&&n(t.currentTarget).trigger("confirm.button.ok")})}})},t.prototype.loadUrl=function(t,e,n,i,o,l){return void 0===e&&(e=a.SeverityEnum.info),this.advanced({type:m.ajax,title:t,severity:e,buttons:n,ajaxCallback:o,ajaxTarget:l})},t.prototype.show=function(t,e,n,i,o){return void 0===n&&(n=a.SeverityEnum.info),this.advanced({type:m.default,title:t,content:e,severity:n,buttons:i,additionalCssClasses:o})},t.prototype.advanced=function(t){return t.type="string"==typeof t.type&&t.type in m?t.type:this.defaultConfiguration.type,t.title="string"==typeof t.title?t.title:this.defaultConfiguration.title,t.content="string"==typeof t.content||"object"==typeof t.content?t.content:this.defaultConfiguration.content,t.severity=void 0!==t.severity?t.severity:this.defaultConfiguration.severity,t.buttons=t.buttons||this.defaultConfiguration.buttons,t.size="string"==typeof t.size&&t.size in d?t.size:this.defaultConfiguration.size,t.style="string"==typeof t.style&&t.style in u?t.style:this.defaultConfiguration.style,t.additionalCssClasses=t.additionalCssClasses||this.defaultConfiguration.additionalCssClasses,t.callback="function"==typeof t.callback?t.callback:this.defaultConfiguration.callback,t.ajaxCallback="function"==typeof t.ajaxCallback?t.ajaxCallback:this.defaultConfiguration.ajaxCallback,t.ajaxTarget="string"==typeof t.ajaxTarget?t.ajaxTarget:this.defaultConfiguration.ajaxTarget,this.generate(t)},t.prototype.initializeMarkupTrigger=function(t){var e=this;n(t).on("click",".t3js-modal-trigger",function(t){t.preventDefault();var i=n(t.currentTarget),l=i.data("content")||"Are you sure?",s=void 0!==a.SeverityEnum[i.data("severity")]?a.SeverityEnum[i.data("severity")]:a.SeverityEnum.info,r=i.data("url")||null;null!==r&&(r=r+(r.indexOf("?")>-1?"&":"?")+n.param({data:i.data()}));e.advanced({type:null!==r?m.ajax:m.default,title:i.data("title")||"Alert",content:null!==r?r:l,severity:s,buttons:[{text:i.data("button-close-text")||TYPO3.lang["button.close"]||"Close",active:!0,btnClass:"btn-default",trigger:function(){e.currentModal.trigger("modal-dismiss")}},{text:i.data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-"+o.getCssClass(s),trigger:function(){e.currentModal.trigger("modal-dismiss"),t.target.ownerDocument.location.href=i.data("href")||i.attr("href")}}]})})},t.prototype.generate=function(t){var e,a,l=this,r=this.$template.clone();if(t.additionalCssClasses.length>0)try{for(var d=__values(t.additionalCssClasses),c=d.next();!c.done;c=d.next()){var u=c.value;r.addClass(u)}}catch(t){e={error:t}}finally{try{c&&!c.done&&(a=d.return)&&a.call(d)}finally{if(e)throw e.error}}if(r.addClass("modal-type-"+t.type),r.addClass("modal-severity-"+o.getCssClass(t.severity)),r.addClass("modal-style-"+t.style),r.addClass("modal-size-"+t.size),r.attr("tabindex","-1"),r.find(s.title).text(t.title),r.find(s.close).on("click",function(){r.modal("hide")}),"ajax"===t.type){var f=t.ajaxTarget?t.ajaxTarget:s.body,m=r.find(f);i.getIcon("spinner-circle",i.sizes.default,null,null,i.markupIdentifiers.inline).done(function(e){m.html('<div class="modal-loading">'+e+"</div>"),n.get(t.content,function(e){l.currentModal.find(f).empty().append(e),t.ajaxCallback&&t.ajaxCallback(),l.currentModal.trigger("modal-loaded")},"html")})}else"iframe"===t.type?(r.find(s.body).append(n("<iframe />",{src:t.content,name:"modal_frame",class:"modal-iframe t3js-modal-iframe"})),r.find(s.iframe).on("load",function(){r.find(s.title).text(r.find(s.iframe).get(0).contentDocument.title)})):("string"==typeof t.content&&(t.content=n("<p />").html(this.securityUtility.encodeHtml(t.content))),r.find(s.body).append(t.content));if(t.buttons.length>0){for(var g=function(e){var a=t.buttons[e],i=n("<button />",{class:"btn"});i.html("<span>"+a.text+"</span>"),a.active&&i.addClass("t3js-active"),""!==a.btnClass&&i.addClass(a.btnClass),""!==a.name&&i.attr("name",a.name),a.trigger&&i.on("click",a.trigger),a.dataAttributes&&Object.keys(a.dataAttributes).length>0&&Object.keys(a.dataAttributes).map(function(t){i.attr("data-"+t,a.dataAttributes[t])}),a.icon&&i.prepend('<span class="t3js-modal-icon-placeholder" data-icon="'+a.icon+'"></span>'),r.find(s.footer).append(i)},p=0;p<t.buttons.length;p++)g(p);r.find(s.footer).find("button").on("click",function(t){n(t.currentTarget).trigger("button.clicked")})}else r.find(s.footer).remove();return r.on("shown.bs.modal",function(t){var e=n(t.currentTarget);e.find(s.footer).find(".t3js-active").first().focus(),e.find(s.iconPlaceholder).each(function(t,e){i.getIcon(n(e).data("icon"),i.sizes.small,null,null,i.markupIdentifiers.inline).done(function(t){l.currentModal.find(s.iconPlaceholder+"[data-icon="+n(t).data("identifier")+"]").replaceWith(t)})})}),r.on("hidden.bs.modal",function(t){if(l.instances.length>0){var e=l.instances.length-1;l.instances.splice(e,1),l.currentModal=l.instances[e-1]}r.trigger("modal-destroyed"),n(t.currentTarget).remove(),l.instances.length>0&&n("body").addClass("modal-open")}),r.on("show.bs.modal",function(t){l.currentModal=n(t.currentTarget),l.instances.push(l.currentModal)}),r.on("modal-dismiss",function(t){n(t.currentTarget).modal("hide")}),t.callback&&t.callback(r),r.modal()},t}(),y=null;try{parent&&parent.window.TYPO3&&parent.window.TYPO3.Modal?(parent.window.TYPO3.Modal.initializeMarkupTrigger(document),y=parent.window.TYPO3.Modal):top&&top.TYPO3.Modal&&(top.TYPO3.Modal.initializeMarkupTrigger(document),y=top.TYPO3.Modal)}catch(t){}return y||(y=new p(new l),TYPO3.Modal=y),y});
\ No newline at end of file
index 84d4166..35e71a1 100644 (file)
@@ -70,7 +70,7 @@ define([
               type: Modal.types.default,
               title: modalTitle,
               size: modalSize,
-              content: '<div class="modal-loading">' + icon + '</div>',
+              content: $('<div class="modal-loading">').append(icon),
               additionalCssClasses: ['install-tool-modal'],
               callback: function (currentModal) {
                 require([requireModule], function (aModule) {
index 7f178c7..c00599e 100644 (file)
@@ -2,6 +2,7 @@ var require = {
   baseUrl: '',
   urlArgs: 'bust=' + (new Date()).getTime(),
   paths: {
+    'TYPO3/CMS/Core': 'sysext/core/Resources/Public/JavaScript',
     'TYPO3/CMS/Backend': 'sysext/backend/Resources/Public/JavaScript',
     'TYPO3/CMS/Install': 'sysext/install/Resources/Public/JavaScript/Modules',
     'jquery': 'sysext/core/Resources/Public/JavaScript/Contrib/jquery/jquery.min',