diff --git a/Build/types/TYPO3/index.d.ts b/Build/types/TYPO3/index.d.ts index d114aad49161..07966314d492 100644 --- a/Build/types/TYPO3/index.d.ts +++ b/Build/types/TYPO3/index.d.ts @@ -46,14 +46,6 @@ declare namespace TYPO3 { public error(title: string, message: string, duration: Number): string; public showMessage(title: string, message: string, severity: Number, duration?: Number): string; } - export class Severity { - public readonly notice: number; - public readonly info: number; - public readonly ok: number; - public readonly warning: number; - public readonly: number; - public getCssClass(severity: number): string; - } } } } @@ -78,10 +70,6 @@ declare module 'TYPO3/CMS/Backend/Notification' { export = new TYPO3.CMS.Backend.Notification(); } -declare module 'TYPO3/CMS/Backend/Severity' { - export = new TYPO3.CMS.Backend.Severity(); -} - // type definition for global namespace object interface Window { TYPO3: any; diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/DragUploader.ts b/typo3/sysext/backend/Resources/Private/TypeScript/DragUploader.ts index b1e7a326477f..fe66787e76ce 100644 --- a/typo3/sysext/backend/Resources/Private/TypeScript/DragUploader.ts +++ b/typo3/sysext/backend/Resources/Private/TypeScript/DragUploader.ts @@ -20,7 +20,7 @@ import moment = require('moment'); import NProgress = require('nprogress'); import Modal = require('TYPO3/CMS/Backend/Modal'); import Notification = require('TYPO3/CMS/Backend/Notification'); -import Severity = require('TYPO3/CMS/Backend/Severity'); +import Severity = require('./Severity'); /** * Possible actions for conflicts w/ existing files diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/GridEditor.ts b/typo3/sysext/backend/Resources/Private/TypeScript/GridEditor.ts index c022e0ae0cfb..e9bda7ce5521 100644 --- a/typo3/sysext/backend/Resources/Private/TypeScript/GridEditor.ts +++ b/typo3/sysext/backend/Resources/Private/TypeScript/GridEditor.ts @@ -14,7 +14,7 @@ import 'bootstrap'; import * as $ from 'jquery'; import Modal = require('TYPO3/CMS/Backend/Modal'); -import Severity = require('TYPO3/CMS/Backend/Severity'); +import Severity = require('./Severity'); /** * GridEditorConfigurationInterface diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/InfoWindow.ts b/typo3/sysext/backend/Resources/Private/TypeScript/InfoWindow.ts index a7aa9e66801b..9c1fd8f591ad 100644 --- a/typo3/sysext/backend/Resources/Private/TypeScript/InfoWindow.ts +++ b/typo3/sysext/backend/Resources/Private/TypeScript/InfoWindow.ts @@ -12,7 +12,7 @@ */ import Modal = require('TYPO3/CMS/Backend/Modal'); -import Severity = require('TYPO3/CMS/Backend/Severity'); +import Severity = require('./Severity'); /** * Module: TYPO3/CMS/Backend/InfoWindow diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/RenameFile.ts b/typo3/sysext/backend/Resources/Private/TypeScript/RenameFile.ts index 2bba56b2c9bd..db6cf04886bc 100644 --- a/typo3/sysext/backend/Resources/Private/TypeScript/RenameFile.ts +++ b/typo3/sysext/backend/Resources/Private/TypeScript/RenameFile.ts @@ -13,7 +13,7 @@ import * as $ from 'jquery'; import Modal = require('TYPO3/CMS/Backend/Modal'); -import Severity = require('TYPO3/CMS/Backend/Severity'); +import Severity = require('./Severity'); /** * Module: TYPO3/CMS/Backend/RenameFile diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/Severity.ts b/typo3/sysext/backend/Resources/Private/TypeScript/Severity.ts new file mode 100644 index 000000000000..afcf64743eec --- /dev/null +++ b/typo3/sysext/backend/Resources/Private/TypeScript/Severity.ts @@ -0,0 +1,92 @@ +/* + * 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! + */ + +enum SeverityEnum { + notice = -2, + info = -1, + ok = 0, + warning = 1, + error = 2 +} + +/** + * Module: TYPO3/CMS/Backend/Severity + * Severity for the TYPO3 backend + */ +class Severity { + public static notice: number = SeverityEnum.notice; + public static info: number = SeverityEnum.info; + public static ok: number = SeverityEnum.ok; + public static warning: number = SeverityEnum.warning; + public static error: number = SeverityEnum.error; + + /** + * Gets the CSS class for the severity + * + * @param {SeverityEnum} severity + * @returns {string} + */ + public static getCssClass(severity: SeverityEnum): string { + let severityClass: string; + + switch (severity) { + case SeverityEnum.notice: + severityClass = 'notice'; + break; + case SeverityEnum.ok: + severityClass = 'success'; + break; + case SeverityEnum.warning: + severityClass = 'warning'; + break; + case SeverityEnum.error: + severityClass = 'danger'; + break; + case SeverityEnum.info: + default: + severityClass = 'info'; + } + + return severityClass; + } +} + +let severityObject; +try { + // fetch from opening window + if (window.opener && window.opener.TYPO3 && window.opener.TYPO3.Severity) { + severityObject = window.opener.TYPO3.Severity; + } + + // fetch from parent + if (parent && parent.window.TYPO3 && parent.window.TYPO3.Severity) { + severityObject = parent.window.TYPO3.Severity; + } + + // fetch object from outer frame + if (top && top.TYPO3 && top.TYPO3.Severity) { + severityObject = top.TYPO3.Severity; + } +} 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 (!severityObject) { + severityObject = Severity; +} + +TYPO3.Storage = severityObject; +export = severityObject; diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/Wizard/NewContentElement.ts b/typo3/sysext/backend/Resources/Private/TypeScript/Wizard/NewContentElement.ts index f207e549c6d1..9af8785a0166 100644 --- a/typo3/sysext/backend/Resources/Private/TypeScript/Wizard/NewContentElement.ts +++ b/typo3/sysext/backend/Resources/Private/TypeScript/Wizard/NewContentElement.ts @@ -12,7 +12,7 @@ */ import Modal = require('TYPO3/CMS/Backend/Modal'); -import Severity = require('TYPO3/CMS/Backend/Severity'); +import Severity = require('../Severity'); /** * Module: TYPO3/CMS/Backend/Wizard/NewContentElement diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/DragUploader.js b/typo3/sysext/backend/Resources/Public/JavaScript/DragUploader.js index ac35b7727b52..4a647a79116c 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/DragUploader.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/DragUploader.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -define(["require","exports","jquery","moment","nprogress","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Backend/Notification","TYPO3/CMS/Backend/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("
").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("").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('"+a+"
").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