Commit 63e41f2c authored by Andreas Fernandez's avatar Andreas Fernandez Committed by Benni Mack
Browse files

[TASK] Replace jQuery shortcuts with AJAX API

Resolves: #90941
Releases: master
Change-Id: If205ab5308c0f1bb7e935a53bebee41e7b9e2fd2
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64061

Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Frank Nägler's avatarFrank Nägler <frank.naegler@typo3.org>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Frank Nägler's avatarFrank Nägler <frank.naegler@typo3.org>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent 7b919798
......@@ -13,6 +13,8 @@
import 'bootstrap';
import * as $ from 'jquery';
import {AjaxResponse} from 'TYPO3/CMS/Core/Ajax/AjaxResponse';
import AjaxRequest = require('TYPO3/CMS/Core/Ajax/AjaxRequest');
import Popover = require('./Popover');
interface HelpData {
......@@ -148,13 +150,14 @@ class ContextHelp {
// If a table is defined, use ajax call to get the tooltip's content
if (table) {
// Load content
$.getJSON(this.ajaxUrl, {
new AjaxRequest(this.ajaxUrl).withQueryArguments({
params: {
action: 'getContextHelp',
table: table,
field: field,
},
}).done((data: HelpData): void => {
}
}).get().then(async (response: AjaxResponse): Promise<any> => {
const data: HelpData = await response.resolve();
const title = data.title || '';
const content = data.content || '<p></p>';
Popover.setOptions($trigger, {
......
......@@ -14,10 +14,12 @@
import * as $ from 'jquery';
import 'jquery-ui/draggable';
import 'jquery-ui/resizable';
import {AjaxResponse} from 'TYPO3/CMS/Core/Ajax/AjaxResponse';
import FormEngineValidation = require('TYPO3/CMS/Backend/FormEngineValidation');
import AjaxRequest = require('TYPO3/CMS/Core/Ajax/AjaxRequest');
import ImagesLoaded = require('TYPO3/CMS/Core/Contrib/imagesloaded.pkgd.min');
import Icons = require('./Icons');
import Modal = require('./Modal');
import ImagesLoaded = require('TYPO3/CMS/Core/Contrib/imagesloaded.pkgd.min');
interface Area {
x: number;
......@@ -262,12 +264,9 @@ class ImageManipulation {
},
],
callback: (currentModal: JQuery): void => {
$.post({
url: imageUri,
data: payload,
}).done((response: string): void => {
new AjaxRequest(imageUri).post(payload).then(async (response: AjaxResponse): Promise<void> => {
initCropperModal();
currentModal.find('.t3js-modal-body').append(response).addClass('cropper');
currentModal.find('.t3js-modal-body').append(await response.resolve()).addClass('cropper');
});
},
content: $('<div class="modal-loading">').append(icon),
......
......@@ -13,11 +13,11 @@
import * as $ from 'jquery';
import {AjaxResponse} from 'TYPO3/CMS/Core/Ajax/AjaxResponse';
import Typo3Notification = require('TYPO3/CMS/Backend/Notification');
import Modal = require('TYPO3/CMS/Backend/Modal');
import Typo3Notification = require('TYPO3/CMS/Backend/Notification');
import Severity = require('TYPO3/CMS/Backend/Severity');
import AjaxRequest = require('TYPO3/CMS/Core/Ajax/AjaxRequest');
import Client = require('TYPO3/CMS/Backend/Storage/Client');
import AjaxRequest = require('TYPO3/CMS/Core/Ajax/AjaxRequest');
enum MarkupIdentifiers {
loginrefresh = 't3js-modal-loginrefresh',
......@@ -458,8 +458,9 @@ class LoginRefresh {
* and opens a dialog.
*/
protected checkActiveSession = (): void => {
$.getJSON(TYPO3.settings.ajaxUrls.login_timedout, [], (response: { [key: string ]: any }) => {
if (response.login.locked) {
new AjaxRequest(TYPO3.settings.ajaxUrls.login_timedout).get().then(async (response: AjaxResponse): Promise<void> => {
const data = await response.resolve();
if (data.login.locked) {
if (!this.backendIsLocked) {
this.backendIsLocked = true;
this.showBackendLockedModal();
......@@ -472,8 +473,8 @@ class LoginRefresh {
}
if (!this.backendIsLocked) {
if (response.login.timed_out || response.login.will_time_out) {
response.login.timed_out
if (data.login.timed_out || data.login.will_time_out) {
data.login.timed_out
? this.showLoginForm()
: this.showTimeoutModal();
}
......
......@@ -11,13 +11,15 @@
* The TYPO3 project - inspiring people to share!
*/
import {AbstractAction} from './ActionButton/AbstractAction';
import {SeverityEnum} from './Enum/Severity';
import 'bootstrap';
import * as $ from 'jquery';
import {AjaxResponse} from 'TYPO3/CMS/Core/Ajax/AjaxResponse';
import {AbstractAction} from './ActionButton/AbstractAction';
import {SeverityEnum} from './Enum/Severity';
import AjaxRequest = require('TYPO3/CMS/Core/Ajax/AjaxRequest');
import SecurityUtility = require('TYPO3/CMS/Core/SecurityUtility');
import Icons = require('./Icons');
import Severity = require('./Severity');
import SecurityUtility = require('TYPO3/CMS/Core/SecurityUtility');
enum Identifiers {
modal = '.t3js-modal',
......@@ -415,19 +417,15 @@ class Modal {
const $loaderTarget = currentModal.find(contentTarget);
Icons.getIcon('spinner-circle', Icons.sizes.default, null, null, Icons.markupIdentifiers.inline).then((icon: string): void => {
$loaderTarget.html('<div class="modal-loading">' + icon + '</div>');
$.get(
<string>configuration.content,
(response: string): void => {
this.currentModal.find(contentTarget)
.empty()
.append(response);
if (configuration.ajaxCallback) {
configuration.ajaxCallback();
}
this.currentModal.trigger('modal-loaded');
},
'html',
);
new AjaxRequest(configuration.content as string).get().then(async (response: AjaxResponse): Promise<void> => {
this.currentModal.find(contentTarget)
.empty()
.append(await response.raw().text());
if (configuration.ajaxCallback) {
configuration.ajaxCallback();
}
this.currentModal.trigger('modal-loaded');
});
});
} else if (configuration.type === 'iframe') {
currentModal.find(Identifiers.body).append(
......
......@@ -11,13 +11,15 @@
* The TYPO3 project - inspiring people to share!
*/
import {KeyTypesEnum} from './Enum/KeyTypes';
import * as $ from 'jquery';
import {MessageUtility} from 'TYPO3/CMS/Backend/Utility/MessageUtility';
import {AjaxResponse} from 'TYPO3/CMS/Core/Ajax/AjaxResponse';
import {KeyTypesEnum} from './Enum/KeyTypes';
import NProgress = require('nprogress');
import AjaxRequest = require('TYPO3/CMS/Core/Ajax/AjaxRequest');
import SecurityUtility = require('TYPO3/CMS/Core/SecurityUtility');
import Modal = require('./Modal');
import Severity = require('./Severity');
import SecurityUtility = require('TYPO3/CMS/Core/SecurityUtility');
import {MessageUtility} from 'TYPO3/CMS/Backend/Utility/MessageUtility';
interface Response {
file?: number;
......@@ -54,40 +56,37 @@ class OnlineMedia {
const irreObjectUid = $trigger.data('file-irre-object');
NProgress.start();
$.post(
TYPO3.settings.ajaxUrls.online_media_create,
{
url: url,
targetFolder: target,
allowed: allowed,
},
(data: Response): void => {
if (data.file) {
const message = {
actionName: 'typo3:foreignRelation:insert',
objectGroup: irreObjectUid,
table: 'sys_file',
uid: data.file,
};
MessageUtility.send(message);
} else {
const $confirm = Modal.confirm(
'ERROR',
data.error,
Severity.error,
[{
text: TYPO3.lang['button.ok'] || 'OK',
btnClass: 'btn-' + Severity.getCssClass(Severity.error),
name: 'ok',
active: true,
}],
).on('confirm.button.ok', (): void => {
$confirm.modal('hide');
});
}
NProgress.done();
},
);
new AjaxRequest(TYPO3.settings.ajaxUrls.online_media_create).post({
url: url,
targetFolder: target,
allowed: allowed,
}).then(async (response: AjaxResponse): Promise<void> => {
const data: Response = await response.resolve();
if (data.file) {
const message = {
actionName: 'typo3:foreignRelation:insert',
objectGroup: irreObjectUid,
table: 'sys_file',
uid: data.file,
};
MessageUtility.send(message);
} else {
const $confirm = Modal.confirm(
'ERROR',
data.error,
Severity.error,
[{
text: TYPO3.lang['button.ok'] || 'OK',
btnClass: 'btn-' + Severity.getCssClass(Severity.error),
name: 'ok',
active: true,
}],
).on('confirm.button.ok', (): void => {
$confirm.modal('hide');
});
}
NProgress.done();
});
}
/**
......
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","jquery","./Popover","bootstrap"],(function(t,e,o,a){"use strict";class s{constructor(){this.ajaxUrl=TYPO3.settings.ajaxUrls.context_help,this.trigger="click",this.placement="auto",this.selector=".help-link",this.initialize()}static resolveBackend(){return void 0!==window.opener&&null!==window.opener?window.opener.top:top}initialize(){const t=s.resolveBackend();void 0!==t.TYPO3.settings.ContextHelp&&(this.helpModuleUrl=t.TYPO3.settings.ContextHelp.moduleUrl),void 0===TYPO3.ShortcutMenu&&void 0===t.TYPO3.ShortcutMenu&&o(".icon-actions-system-shortcut-new").closest(".btn").hide();let e="&nbsp;";void 0!==t.TYPO3.lang&&(e=t.TYPO3.lang.csh_tooltip_loading);const i=o(this.selector);i.attr("data-loaded","false").attr("data-html","true").attr("data-original-title",e).attr("data-placement",this.placement).attr("data-trigger",this.trigger),a.popover(i),o(document).on("show.bs.popover",this.selector,t=>{const e=o(t.currentTarget),s=e.data("description");void 0!==s&&""!==s?a.setOptions(e,{title:e.data("title"),content:s}):"false"===e.attr("data-loaded")&&e.data("table")&&this.loadHelp(e),e.closest(".t3js-module-docheader").length&&a.setOption(e,"placement","bottom")}).on("shown.bs.popover",this.selector,t=>{const e=o(t.target).data("bs.popover").$tip;e.find(".popover-title").is(":visible")||e.addClass("no-title")}).on("click",".help-has-link",t=>{o(".popover").each((e,a)=>{const s=o(a);s.has(t.target).length&&this.showHelpPopup(s.data("bs.popover").$element)})}).on("click","body",t=>{o(this.selector).each((e,s)=>{const i=o(s);i.is(t.target)||0!==i.has(t.target).length||0!==o(".popover").has(t.target).length||a.hide(i)})})}showHelpPopup(t){try{const e=window.open(this.helpModuleUrl+"&table="+t.data("table")+"&field="+t.data("field"),"ContextHelpWindow","height=400,width=600,status=0,menubar=0,scrollbars=1");return e.focus(),a.hide(t),e}catch(t){}}loadHelp(t){const e=t.data("table"),s=t.data("field");e&&o.getJSON(this.ajaxUrl,{params:{action:"getContextHelp",table:e,field:s}}).done(e=>{const o=e.title||"",s=e.content||"<p></p>";a.setOptions(t,{title:o,content:s}),t.attr("data-loaded","true").one("hidden.bs.popover",()=>{a.show(t)}),a.hide(t)})}}return new s}));
\ No newline at end of file
define(["require","exports","jquery","TYPO3/CMS/Core/Ajax/AjaxRequest","./Popover","bootstrap"],(function(t,e,o,a,s){"use strict";class i{constructor(){this.ajaxUrl=TYPO3.settings.ajaxUrls.context_help,this.trigger="click",this.placement="auto",this.selector=".help-link",this.initialize()}static resolveBackend(){return void 0!==window.opener&&null!==window.opener?window.opener.top:top}initialize(){const t=i.resolveBackend();void 0!==t.TYPO3.settings.ContextHelp&&(this.helpModuleUrl=t.TYPO3.settings.ContextHelp.moduleUrl),void 0===TYPO3.ShortcutMenu&&void 0===t.TYPO3.ShortcutMenu&&o(".icon-actions-system-shortcut-new").closest(".btn").hide();let e="&nbsp;";void 0!==t.TYPO3.lang&&(e=t.TYPO3.lang.csh_tooltip_loading);const a=o(this.selector);a.attr("data-loaded","false").attr("data-html","true").attr("data-original-title",e).attr("data-placement",this.placement).attr("data-trigger",this.trigger),s.popover(a),o(document).on("show.bs.popover",this.selector,t=>{const e=o(t.currentTarget),a=e.data("description");void 0!==a&&""!==a?s.setOptions(e,{title:e.data("title"),content:a}):"false"===e.attr("data-loaded")&&e.data("table")&&this.loadHelp(e),e.closest(".t3js-module-docheader").length&&s.setOption(e,"placement","bottom")}).on("shown.bs.popover",this.selector,t=>{const e=o(t.target).data("bs.popover").$tip;e.find(".popover-title").is(":visible")||e.addClass("no-title")}).on("click",".help-has-link",t=>{o(".popover").each((e,a)=>{const s=o(a);s.has(t.target).length&&this.showHelpPopup(s.data("bs.popover").$element)})}).on("click","body",t=>{o(this.selector).each((e,a)=>{const i=o(a);i.is(t.target)||0!==i.has(t.target).length||0!==o(".popover").has(t.target).length||s.hide(i)})})}showHelpPopup(t){try{const e=window.open(this.helpModuleUrl+"&table="+t.data("table")+"&field="+t.data("field"),"ContextHelpWindow","height=400,width=600,status=0,menubar=0,scrollbars=1");return e.focus(),s.hide(t),e}catch(t){}}loadHelp(t){const e=t.data("table"),o=t.data("field");e&&new a(this.ajaxUrl).withQueryArguments({params:{action:"getContextHelp",table:e,field:o}}).get().then(async e=>{const o=await e.resolve(),a=o.title||"",i=o.content||"<p></p>";s.setOptions(t,{title:a,content:i}),t.attr("data-loaded","true").one("hidden.bs.popover",()=>{s.show(t)}),s.hide(t)})}}return new i}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","jquery","TYPO3/CMS/Backend/Notification","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Backend/Severity","TYPO3/CMS/Core/Ajax/AjaxRequest","TYPO3/CMS/Backend/Storage/Client"],(function(e,o,t,i,s,n,a,l){"use strict";var d;!function(e){e.loginrefresh="t3js-modal-loginrefresh",e.lockedModal="t3js-modal-backendlocked",e.loginFormModal="t3js-modal-backendloginform"}(d||(d={}));class r{constructor(){this.options={modalConfig:{backdrop:"static"}},this.webNotification=null,this.intervalTime=60,this.intervalId=null,this.backendIsLocked=!1,this.isTimingOut=!1,this.$timeoutModal=null,this.$backendLockedModal=null,this.$loginForm=null,this.loginFramesetUrl="",this.logoutUrl="",this.submitForm=e=>{e.preventDefault();const o=this.$loginForm.find("form"),s=o.find("input[name=p_field]"),n=o.find("input[name=userident]"),l=s.val();if(""===l&&""===n.val())return i.error(TYPO3.lang["mess.refresh_login_failed"],TYPO3.lang["mess.refresh_login_emptyPassword"]),void s.focus();l&&(n.val(l),s.val(""));const d={login_status:"login"};t.each(o.serializeArray(),(function(e,o){d[o.name]=o.value})),new a(o.attr("action")).post(d).then(async e=>{(await e.resolve()).login.success?this.hideLoginForm():(i.error(TYPO3.lang["mess.refresh_login_failed"],TYPO3.lang["mess.refresh_login_failed_message"]),s.focus())})},this.checkActiveSession=()=>{t.getJSON(TYPO3.settings.ajaxUrls.login_timedout,[],e=>{e.login.locked?this.backendIsLocked||(this.backendIsLocked=!0,this.showBackendLockedModal()):this.backendIsLocked&&(this.backendIsLocked=!1,this.hideBackendLockedModal()),this.backendIsLocked||(e.login.timed_out||e.login.will_time_out)&&(e.login.timed_out?this.showLoginForm():this.showTimeoutModal())})}}initialize(){this.initializeTimeoutModal(),this.initializeBackendLockedModal(),this.initializeLoginForm(),this.startTask();const e=!(l.isset("notifications.asked")&&"yes"===l.get("notifications.asked")),o="undefined"!=typeof Notification&&"default"===Notification.permission;e&&"https:"===document.location.protocol&&o&&s.confirm(TYPO3.lang["notification.request.title"],TYPO3.lang["notification.request.description"],n.info,[{text:TYPO3.lang["button.yes"]||"Yes",btnClass:"btn-"+n.getCssClass(n.info),name:"ok",active:!0},{text:TYPO3.lang["button.no"]||"No",btnClass:"btn-"+n.getCssClass(n.notice),name:"cancel"}]).on("confirm.button.ok",()=>{Notification.requestPermission(),s.dismiss()}).on("confirm.button.cancel",()=>{s.dismiss()}).on("hide.bs.modal",()=>{l.set("notifications.asked","yes")})}startTask(){if(null!==this.intervalId)return;let e=1e3*this.intervalTime;this.intervalId=setInterval(this.checkActiveSession,e)}stopTask(){clearInterval(this.intervalId),this.intervalId=null}setIntervalTime(e){this.intervalTime=Math.min(e,86400)}setLogoutUrl(e){this.logoutUrl=e}setLoginFramesetUrl(e){this.loginFramesetUrl=e}showTimeoutModal(){this.isTimingOut=!0,this.$timeoutModal.modal(this.options.modalConfig),this.fillProgressbar(this.$timeoutModal),"https:"===document.location.protocol&&"undefined"!=typeof Notification&&"granted"===Notification.permission&&document.hidden&&(this.webNotification=new Notification(TYPO3.lang["mess.login_about_to_expire_title"],{body:TYPO3.lang["mess.login_about_to_expire"],icon:"/typo3/sysext/backend/Resources/Public/Images/Logo.png"}),this.webNotification.onclick=()=>{window.focus()})}hideTimeoutModal(){this.isTimingOut=!1,this.$timeoutModal.modal("hide"),"undefined"!=typeof Notification&&null!==this.webNotification&&this.webNotification.close()}showBackendLockedModal(){this.$backendLockedModal.modal(this.options.modalConfig)}hideBackendLockedModal(){this.$backendLockedModal.modal("hide")}showLoginForm(){new a(TYPO3.settings.ajaxUrls.logout).get().then(()=>{TYPO3.configuration.showRefreshLoginPopup?this.showLoginPopup():this.$loginForm.modal(this.options.modalConfig)})}showLoginPopup(){const e=window.open(this.loginFramesetUrl,"relogin_"+Math.random().toString(16).slice(2),"height=450,width=700,status=0,menubar=0,location=1");e&&e.focus()}hideLoginForm(){this.$loginForm.modal("hide")}initializeBackendLockedModal(){this.$backendLockedModal=this.generateModal(d.lockedModal),this.$backendLockedModal.find(".modal-header h4").text(TYPO3.lang["mess.please_wait"]),this.$backendLockedModal.find(".modal-body").append(t("<p />").text(TYPO3.lang["mess.be_locked"])),this.$backendLockedModal.find(".modal-footer").remove(),t("body").append(this.$backendLockedModal)}initializeTimeoutModal(){this.$timeoutModal=this.generateModal(d.loginrefresh),this.$timeoutModal.addClass("modal-severity-notice"),this.$timeoutModal.find(".modal-header h4").text(TYPO3.lang["mess.login_about_to_expire_title"]),this.$timeoutModal.find(".modal-body").append(t("<p />").text(TYPO3.lang["mess.login_about_to_expire"]),t("<div />",{class:"progress"}).append(t("<div />",{class:"progress-bar progress-bar-warning progress-bar-striped active",role:"progressbar","aria-valuemin":"0","aria-valuemax":"100"}).append(t("<span />",{class:"sr-only"})))),this.$timeoutModal.find(".modal-footer").append(t("<button />",{class:"btn btn-default","data-action":"logout"}).text(TYPO3.lang["mess.refresh_login_logout_button"]).on("click",()=>{top.location.href=this.logoutUrl}),t("<button />",{class:"btn btn-primary t3js-active","data-action":"refreshSession"}).text(TYPO3.lang["mess.refresh_login_refresh_button"]).on("click",()=>{new a(TYPO3.settings.ajaxUrls.login_timedout).get().then(()=>{this.hideTimeoutModal()})})),this.registerDefaultModalEvents(this.$timeoutModal),t("body").append(this.$timeoutModal)}initializeLoginForm(){if(TYPO3.configuration.showRefreshLoginPopup)return;this.$loginForm=this.generateModal(d.loginFormModal),this.$loginForm.addClass("modal-notice");let o=String(TYPO3.lang["mess.refresh_login_title"]).replace("%s",TYPO3.configuration.username);this.$loginForm.find(".modal-header h4").text(o),this.$loginForm.find(".modal-body").append(t("<p />").text(TYPO3.lang["mess.login_expired"]),t("<form />",{id:"beLoginRefresh",method:"POST",action:TYPO3.settings.ajaxUrls.login}).append(t("<div />",{class:"form-group"}).append(t("<input />",{type:"password",name:"p_field",autofocus:"autofocus",class:"form-control",placeholder:TYPO3.lang["mess.refresh_login_password"],"data-rsa-encryption":"t3-loginrefres-userident"})),t("<input />",{type:"hidden",name:"username",value:TYPO3.configuration.username}),t("<input />",{type:"hidden",name:"userident",id:"t3-loginrefres-userident"}))),this.$loginForm.find(".modal-footer").append(t("<a />",{href:this.logoutUrl,class:"btn btn-default"}).text(TYPO3.lang["mess.refresh_exit_button"]),t("<button />",{type:"button",class:"btn btn-primary","data-action":"refreshSession"}).text(TYPO3.lang["mess.refresh_login_button"]).on("click",()=>{this.$loginForm.find("form").submit()})),this.registerDefaultModalEvents(this.$loginForm).on("submit",this.submitForm),t("body").append(this.$loginForm),e.specified("TYPO3/CMS/Rsaauth/RsaEncryptionModule")&&e(["TYPO3/CMS/Rsaauth/RsaEncryptionModule"],(function(e){e.registerForm(t("#beLoginRefresh").get(0))}))}generateModal(e){return t("<div />",{id:e,class:"t3js-modal "+e+" modal modal-type-default modal-severity-notice modal-style-light modal-size-small fade"}).append(t("<div />",{class:"modal-dialog"}).append(t("<div />",{class:"modal-content"}).append(t("<div />",{class:"modal-header"}).append(t("<h4 />",{class:"modal-title"})),t("<div />",{class:"modal-body"}),t("<div />",{class:"modal-footer"}))))}fillProgressbar(e){if(!this.isTimingOut)return;let o=0;const t=e.find(".progress-bar"),i=t.children(".sr-only"),s=setInterval(()=>{const e=o>=100;!this.isTimingOut||e?(clearInterval(s),e&&(this.hideTimeoutModal(),this.showLoginForm()),o=0):o+=1;const n=o+"%";t.css("width",n),i.text(n)},300)}registerDefaultModalEvents(e){return e.on("hidden.bs.modal",()=>{this.startTask()}).on("shown.bs.modal",()=>{this.stopTask(),this.$timeoutModal.find(".modal-footer .t3js-active").first().focus()}),e}}let c;try{window.opener&&window.opener.TYPO3&&window.opener.TYPO3.LoginRefresh&&(c=window.opener.TYPO3.LoginRefresh),parent&&parent.window.TYPO3&&parent.window.TYPO3.LoginRefresh&&(c=parent.window.TYPO3.LoginRefresh),top&&top.TYPO3&&top.TYPO3.LoginRefresh&&(c=top.TYPO3.LoginRefresh)}catch(e){}return c||(c=new r,"undefined"!=typeof TYPO3&&(TYPO3.LoginRefresh=c)),c}));
\ No newline at end of file
define(["require","exports","jquery","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Backend/Notification","TYPO3/CMS/Backend/Severity","TYPO3/CMS/Backend/Storage/Client","TYPO3/CMS/Core/Ajax/AjaxRequest"],(function(e,o,t,i,s,n,a,l){"use strict";var d;!function(e){e.loginrefresh="t3js-modal-loginrefresh",e.lockedModal="t3js-modal-backendlocked",e.loginFormModal="t3js-modal-backendloginform"}(d||(d={}));class r{constructor(){this.options={modalConfig:{backdrop:"static"}},this.webNotification=null,this.intervalTime=60,this.intervalId=null,this.backendIsLocked=!1,this.isTimingOut=!1,this.$timeoutModal=null,this.$backendLockedModal=null,this.$loginForm=null,this.loginFramesetUrl="",this.logoutUrl="",this.submitForm=e=>{e.preventDefault();const o=this.$loginForm.find("form"),i=o.find("input[name=p_field]"),n=o.find("input[name=userident]"),a=i.val();if(""===a&&""===n.val())return s.error(TYPO3.lang["mess.refresh_login_failed"],TYPO3.lang["mess.refresh_login_emptyPassword"]),void i.focus();a&&(n.val(a),i.val(""));const d={login_status:"login"};t.each(o.serializeArray(),(function(e,o){d[o.name]=o.value})),new l(o.attr("action")).post(d).then(async e=>{(await e.resolve()).login.success?this.hideLoginForm():(s.error(TYPO3.lang["mess.refresh_login_failed"],TYPO3.lang["mess.refresh_login_failed_message"]),i.focus())})},this.checkActiveSession=()=>{new l(TYPO3.settings.ajaxUrls.login_timedout).get().then(async e=>{const o=await e.resolve();o.login.locked?this.backendIsLocked||(this.backendIsLocked=!0,this.showBackendLockedModal()):this.backendIsLocked&&(this.backendIsLocked=!1,this.hideBackendLockedModal()),this.backendIsLocked||(o.login.timed_out||o.login.will_time_out)&&(o.login.timed_out?this.showLoginForm():this.showTimeoutModal())})}}initialize(){this.initializeTimeoutModal(),this.initializeBackendLockedModal(),this.initializeLoginForm(),this.startTask();const e=!(a.isset("notifications.asked")&&"yes"===a.get("notifications.asked")),o="undefined"!=typeof Notification&&"default"===Notification.permission;e&&"https:"===document.location.protocol&&o&&i.confirm(TYPO3.lang["notification.request.title"],TYPO3.lang["notification.request.description"],n.info,[{text:TYPO3.lang["button.yes"]||"Yes",btnClass:"btn-"+n.getCssClass(n.info),name:"ok",active:!0},{text:TYPO3.lang["button.no"]||"No",btnClass:"btn-"+n.getCssClass(n.notice),name:"cancel"}]).on("confirm.button.ok",()=>{Notification.requestPermission(),i.dismiss()}).on("confirm.button.cancel",()=>{i.dismiss()}).on("hide.bs.modal",()=>{a.set("notifications.asked","yes")})}startTask(){if(null!==this.intervalId)return;let e=1e3*this.intervalTime;this.intervalId=setInterval(this.checkActiveSession,e)}stopTask(){clearInterval(this.intervalId),this.intervalId=null}setIntervalTime(e){this.intervalTime=Math.min(e,86400)}setLogoutUrl(e){this.logoutUrl=e}setLoginFramesetUrl(e){this.loginFramesetUrl=e}showTimeoutModal(){this.isTimingOut=!0,this.$timeoutModal.modal(this.options.modalConfig),this.fillProgressbar(this.$timeoutModal),"https:"===document.location.protocol&&"undefined"!=typeof Notification&&"granted"===Notification.permission&&document.hidden&&(this.webNotification=new Notification(TYPO3.lang["mess.login_about_to_expire_title"],{body:TYPO3.lang["mess.login_about_to_expire"],icon:"/typo3/sysext/backend/Resources/Public/Images/Logo.png"}),this.webNotification.onclick=()=>{window.focus()})}hideTimeoutModal(){this.isTimingOut=!1,this.$timeoutModal.modal("hide"),"undefined"!=typeof Notification&&null!==this.webNotification&&this.webNotification.close()}showBackendLockedModal(){this.$backendLockedModal.modal(this.options.modalConfig)}hideBackendLockedModal(){this.$backendLockedModal.modal("hide")}showLoginForm(){new l(TYPO3.settings.ajaxUrls.logout).get().then(()=>{TYPO3.configuration.showRefreshLoginPopup?this.showLoginPopup():this.$loginForm.modal(this.options.modalConfig)})}showLoginPopup(){const e=window.open(this.loginFramesetUrl,"relogin_"+Math.random().toString(16).slice(2),"height=450,width=700,status=0,menubar=0,location=1");e&&e.focus()}hideLoginForm(){this.$loginForm.modal("hide")}initializeBackendLockedModal(){this.$backendLockedModal=this.generateModal(d.lockedModal),this.$backendLockedModal.find(".modal-header h4").text(TYPO3.lang["mess.please_wait"]),this.$backendLockedModal.find(".modal-body").append(t("<p />").text(TYPO3.lang["mess.be_locked"])),this.$backendLockedModal.find(".modal-footer").remove(),t("body").append(this.$backendLockedModal)}initializeTimeoutModal(){this.$timeoutModal=this.generateModal(d.loginrefresh),this.$timeoutModal.addClass("modal-severity-notice"),this.$timeoutModal.find(".modal-header h4").text(TYPO3.lang["mess.login_about_to_expire_title"]),this.$timeoutModal.find(".modal-body").append(t("<p />").text(TYPO3.lang["mess.login_about_to_expire"]),t("<div />",{class:"progress"}).append(t("<div />",{class:"progress-bar progress-bar-warning progress-bar-striped active",role:"progressbar","aria-valuemin":"0","aria-valuemax":"100"}).append(t("<span />",{class:"sr-only"})))),this.$timeoutModal.find(".modal-footer").append(t("<button />",{class:"btn btn-default","data-action":"logout"}).text(TYPO3.lang["mess.refresh_login_logout_button"]).on("click",()=>{top.location.href=this.logoutUrl}),t("<button />",{class:"btn btn-primary t3js-active","data-action":"refreshSession"}).text(TYPO3.lang["mess.refresh_login_refresh_button"]).on("click",()=>{new l(TYPO3.settings.ajaxUrls.login_timedout).get().then(()=>{this.hideTimeoutModal()})})),this.registerDefaultModalEvents(this.$timeoutModal),t("body").append(this.$timeoutModal)}initializeLoginForm(){if(TYPO3.configuration.showRefreshLoginPopup)return;this.$loginForm=this.generateModal(d.loginFormModal),this.$loginForm.addClass("modal-notice");let o=String(TYPO3.lang["mess.refresh_login_title"]).replace("%s",TYPO3.configuration.username);this.$loginForm.find(".modal-header h4").text(o),this.$loginForm.find(".modal-body").append(t("<p />").text(TYPO3.lang["mess.login_expired"]),t("<form />",{id:"beLoginRefresh",method:"POST",action:TYPO3.settings.ajaxUrls.login}).append(t("<div />",{class:"form-group"}).append(t("<input />",{type:"password",name:"p_field",autofocus:"autofocus",class:"form-control",placeholder:TYPO3.lang["mess.refresh_login_password"],"data-rsa-encryption":"t3-loginrefres-userident"})),t("<input />",{type:"hidden",name:"username",value:TYPO3.configuration.username}),t("<input />",{type:"hidden",name:"userident",id:"t3-loginrefres-userident"}))),this.$loginForm.find(".modal-footer").append(t("<a />",{href:this.logoutUrl,class:"btn btn-default"}).text(TYPO3.lang["mess.refresh_exit_button"]),t("<button />",{type:"button",class:"btn btn-primary","data-action":"refreshSession"}).text(TYPO3.lang["mess.refresh_login_button"]).on("click",()=>{this.$loginForm.find("form").submit()})),this.registerDefaultModalEvents(this.$loginForm).on("submit",this.submitForm),t("body").append(this.$loginForm),e.specified("TYPO3/CMS/Rsaauth/RsaEncryptionModule")&&e(["TYPO3/CMS/Rsaauth/RsaEncryptionModule"],(function(e){e.registerForm(t("#beLoginRefresh").get(0))}))}generateModal(e){return t("<div />",{id:e,class:"t3js-modal "+e+" modal modal-type-default modal-severity-notice modal-style-light modal-size-small fade"}).append(t("<div />",{class:"modal-dialog"}).append(t("<div />",{class:"modal-content"}).append(t("<div />",{class:"modal-header"}).append(t("<h4 />",{class:"modal-title"})),t("<div />",{class:"modal-body"}),t("<div />",{class:"modal-footer"}))))}fillProgressbar(e){if(!this.isTimingOut)return;let o=0;const t=e.find(".progress-bar"),i=t.children(".sr-only"),s=setInterval(()=>{const e=o>=100;!this.isTimingOut||e?(clearInterval(s),e&&(this.hideTimeoutModal(),this.showLoginForm()),o=0):o+=1;const n=o+"%";t.css("width",n),i.text(n)},300)}registerDefaultModalEvents(e){return e.on("hidden.bs.modal",()=>{this.startTask()}).on("shown.bs.modal",()=>{this.stopTask(),this.$timeoutModal.find(".modal-footer .t3js-active").first().focus()}),e}}let c;try{window.opener&&window.opener.TYPO3&&window.opener.TYPO3.LoginRefresh&&(c=window.opener.TYPO3.LoginRefresh),parent&&parent.window.TYPO3&&parent.window.TYPO3.LoginRefresh&&(c=parent.window.TYPO3.LoginRefresh),top&&top.TYPO3&&top.TYPO3.LoginRefresh&&(c=top.TYPO3.LoginRefresh)}catch(e){}return c||(c=new r,"undefined"!=typeof TYPO3&&(TYPO3.LoginRefresh=c)),c}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","./Enum/Severity","jquery","./Icons","./Severity","TYPO3/CMS/Core/SecurityUtility","bootstrap"],(function(t,e,a,n,i,s,l){"use strict";var o,d,r,c;!function(t){t.modal=".t3js-modal",t.content=".t3js-modal-content",t.title=".t3js-modal-title",t.close=".t3js-modal-close",t.body=".t3js-modal-body",t.footer=".t3js-modal-footer",t.iframe=".t3js-modal-iframe",t.iconPlaceholder=".t3js-modal-icon-placeholder"}(o||(o={})),function(t){t.small="small",t.default="default",t.medium="medium",t.large="large",t.full="full"}(d||(d={})),function(t){t.default="default",t.light="light",t.dark="dark"}(r||(r={})),function(t){t.default="default",t.ajax="ajax",t.iframe="iframe"}(c||(c={}));class u{constructor(t){this.sizes=d,this.styles=r,this.types=c,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:c.default,title:"Information",content:"No content provided, please check your <code>Modal</code> configuration.",severity:a.SeverityEnum.notice,buttons:[],style:r.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)}dismiss(){this.currentModal&&this.currentModal.modal("hide")}confirm(t,e,i=a.SeverityEnum.warning,l=[],o){return 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-"+s.getCssClass(i),name:"ok"}),this.advanced({title:t,content:e,severity:i,buttons:l,additionalCssClasses:o,callback:t=>{t.on("button.clicked",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")})}})}loadUrl(t,e=a.SeverityEnum.info,n,i,s,l){return this.advanced({type:c.ajax,title:t,severity:e,buttons:n,ajaxCallback:s,ajaxTarget:l,content:i})}show(t,e,n=a.SeverityEnum.info,i,s){return this.advanced({type:c.default,title:t,content:e,severity:n,buttons:i,additionalCssClasses:s})}advanced(t){return t.type="string"==typeof t.type&&t.type in c?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 r?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)}setButtons(t){const e=this.currentModal.find(o.footer);if(t.length>0){e.empty();for(let a=0;a<t.length;a++){const i=t[a],s=n("<button />",{class:"btn"});s.html("<span>"+this.securityUtility.encodeHtml(i.text,!1)+"</span>"),i.active&&s.addClass("t3js-active"),""!==i.btnClass&&s.addClass(i.btnClass),""!==i.name&&s.attr("name",i.name),i.action?s.on("click",()=>{e.find("button").not(s).addClass("disabled"),i.action.execute(s.get(0)).then(()=>{this.currentModal.modal("hide")})}):i.trigger&&s.on("click",i.trigger),i.dataAttributes&&Object.keys(i.dataAttributes).length>0&&Object.keys(i.dataAttributes).map(t=>{s.attr("data-"+t,i.dataAttributes[t])}),i.icon&&s.prepend('<span class="t3js-modal-icon-placeholder" data-icon="'+i.icon+'"></span>'),e.append(s)}e.show(),e.find("button").on("click",t=>{n(t.currentTarget).trigger("button.clicked")})}else e.hide();return this.currentModal}initializeMarkupTrigger(t){n(t).on("click",".t3js-modal-trigger",t=>{t.preventDefault();const e=n(t.currentTarget),i=e.data("content")||"Are you sure?",l=void 0!==a.SeverityEnum[e.data("severity")]?a.SeverityEnum[e.data("severity")]:a.SeverityEnum.info;let o=e.data("url")||null;if(null!==o){const t=o.includes("?")?"&":"?";o=o+t+n.param({data:e.data()})}this.advanced({type:null!==o?c.ajax:c.default,title:e.data("title")||"Alert",content:null!==o?o:i,severity:l,buttons:[{text:e.data("button-close-text")||TYPO3.lang["button.close"]||"Close",active:!0,btnClass:"btn-default",trigger:()=>{this.currentModal.trigger("modal-dismiss")}},{text:e.data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-"+s.getCssClass(l),trigger:()=>{this.currentModal.trigger("modal-dismiss"),t.target.ownerDocument.location.href=e.data("href")||e.attr("href")}}]})})}generate(t){const e=this.$template.clone();if(t.additionalCssClasses.length>0)for(let a of t.additionalCssClasses)e.addClass(a);if(e.addClass("modal-type-"+t.type),e.addClass("modal-severity-"+s.getCssClass(t.severity)),e.addClass("modal-style-"+t.style),e.addClass("modal-size-"+t.size),e.attr("tabindex","-1"),e.find(o.title).text(t.title),e.find(o.close).on("click",()=>{e.modal("hide")}),"ajax"===t.type){const a=t.ajaxTarget?t.ajaxTarget:o.body,s=e.find(a);i.getIcon("spinner-circle",i.sizes.default,null,null,i.markupIdentifiers.inline).then(e=>{s.html('<div class="modal-loading">'+e+"</div>"),n.get(t.content,e=>{this.currentModal.find(a).empty().append(e),t.ajaxCallback&&t.ajaxCallback(),this.currentModal.trigger("modal-loaded")},"html")})}else"iframe"===t.type?(e.find(o.body).append(n("<iframe />",{src:t.content,name:"modal_frame",class:"modal-iframe t3js-modal-iframe"})),e.find(o.iframe).on("load",()=>{e.find(o.title).text(e.find(o.iframe).get(0).contentDocument.title)})):("string"==typeof t.content&&(t.content=n("<p />").html(this.securityUtility.encodeHtml(t.content))),e.find(o.body).append(t.content));return e.on("shown.bs.modal",t=>{const e=n(t.currentTarget);e.find(o.footer).find(".t3js-active").first().focus(),e.find(o.iconPlaceholder).each((t,e)=>{i.getIcon(n(e).data("icon"),i.sizes.small,null,null,i.markupIdentifiers.inline).then(t=>{this.currentModal.find(o.iconPlaceholder+"[data-icon="+n(t).data("identifier")+"]").replaceWith(t)})})}),e.on("hidden.bs.modal",t=>{if(this.instances.length>0){const t=this.instances.length-1;this.instances.splice(t,1),this.currentModal=this.instances[t-1]}e.trigger("modal-destroyed"),n(t.currentTarget).remove(),this.instances.length>0&&n("body").addClass("modal-open")}),e.on("show.bs.modal",e=>{this.currentModal=n(e.currentTarget),this.setButtons(t.buttons),this.instances.push(this.currentModal)}),e.on("modal-dismiss",t=>{n(t.currentTarget).modal("hide")}),t.callback&&t.callback(e),e.modal()}}let f=null;try{parent&&parent.window.TYPO3&&parent.window.TYPO3.Modal?(parent.window.TYPO3.Modal.initializeMarkupTrigger(document),f=parent.window.TYPO3.Modal):top&&top.TYPO3.Modal&&(top.TYPO3.Modal.initializeMarkupTrigger(document),f=top.TYPO3.Modal)}catch(t){}return f||(f=new u(new l),TYPO3.Modal=f),f}));
\ No newline at end of file
define(["require","exports","jquery","./Enum/Severity","TYPO3/CMS/Core/Ajax/AjaxRequest","TYPO3/CMS/Core/SecurityUtility","./Icons","./Severity","bootstrap"],(function(t,e,a,n,i,s,l,o){"use strict";var d,r,c,u;!function(t){t.modal=".t3js-modal",t.content=".t3js-modal-content",t.title=".t3js-modal-title",t.close=".t3js-modal-close",t.body=".t3js-modal-body",t.footer=".t3js-modal-footer",t.iframe=".t3js-modal-iframe",t.iconPlaceholder=".t3js-modal-icon-placeholder"}(d||(d={})),function(t){t.small="small",t.default="default",t.medium="medium",t.large="large",t.full="full"}(r||(r={})),function(t){t.default="default",t.light="light",t.dark="dark"}(c||(c={})),function(t){t.default="default",t.ajax="ajax",t.iframe="iframe"}(u||(u={}));class f{constructor(t){this.sizes=r,this.styles=c,this.types=u,this.currentModal=null,this.instances=[],this.$template=a('<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:u.default,title:"Information",content:"No content provided, please check your <code>Modal</code> configuration.",severity:n.SeverityEnum.notice,buttons:[],style:c.default,size:r.default,additionalCssClasses:[],callback:a.noop(),ajaxCallback:a.noop(),ajaxTarget:null},this.securityUtility=t,a(document).on("modal-dismiss",this.dismiss),this.initializeMarkupTrigger(document)}dismiss(){this.currentModal&&this.currentModal.modal("hide")}confirm(t,e,i=n.SeverityEnum.warning,s=[],l){return 0===s.length&&s.push({text:a(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:a(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:s,additionalCssClasses:l,callback:t=>{t.on("button.clicked",t=>{"cancel"===t.target.getAttribute("name")?a(t.currentTarget).trigger("confirm.button.cancel"):"ok"===t.target.getAttribute("name")&&a(t.currentTarget).trigger("confirm.button.ok")})}})}loadUrl(t,e=n.SeverityEnum.info,a,i,s,l){return this.advanced({type:u.ajax,title:t,severity:e,buttons:a,ajaxCallback:s,ajaxTarget:l,content:i})}show(t,e,a=n.SeverityEnum.info,i,s){return this.advanced({type:u.default,title:t,content:e,severity:a,buttons:i,additionalCssClasses:s})}advanced(t){return t.type="string"==typeof t.type&&t.type in u?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 r?t.size:this.defaultConfiguration.size,t.style="string"==typeof t.style&&t.style in c?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)}setButtons(t){const e=this.currentModal.find(d.footer);if(t.length>0){e.empty();for(let n=0;n<t.length;n++){const i=t[n],s=a("<button />",{class:"btn"});s.html("<span>"+this.securityUtility.encodeHtml(i.text,!1)+"</span>"),i.active&&s.addClass("t3js-active"),""!==i.btnClass&&s.addClass(i.btnClass),""!==i.name&&s.attr("name",i.name),i.action?s.on("click",()=>{e.find("button").not(s).addClass("disabled"),i.action.execute(s.get(0)).then(()=>{this.currentModal.modal("hide")})}):i.trigger&&s.on("click",i.trigger),i.dataAttributes&&Object.keys(i.dataAttributes).length>0&&Object.keys(i.dataAttributes).map(t=>{s.attr("data-"+t,i.dataAttributes[t])}),i.icon&&s.prepend('<span class="t3js-modal-icon-placeholder" data-icon="'+i.icon+'"></span>'),e.append(s)}e.show(),e.find("button").on("click",t=>{a(t.currentTarget).trigger("button.clicked")})}else e.hide();return this.currentModal}initializeMarkupTrigger(t){a(t).on("click",".t3js-modal-trigger",t=>{t.preventDefault();const e=a(t.currentTarget),i=e.data("content")||"Are you sure?",s=void 0!==n.SeverityEnum[e.data("severity")]?n.SeverityEnum[e.data("severity")]:n.SeverityEnum.info;let l=e.data("url")||null;if(null!==l){const t=l.includes("?")?"&":"?";l=l+t+a.param({data:e.data()})}this.advanced({type:null!==l?u.ajax:u.default,title:e.data("title")||"Alert",content:null!==l?l:i,severity:s,buttons:[{text:e.data("button-close-text")||TYPO3.lang["button.close"]||"Close",active:!0,btnClass:"btn-default",trigger:()=>{this.currentModal.trigger("modal-dismiss")}},{text:e.data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-"+o.getCssClass(s),trigger:()=>{this.currentModal.trigger("modal-dismiss"),t.target.ownerDocument.location.href=e.data("href")||e.attr("href")}}]})})}generate(t){const e=this.$template.clone();if(t.additionalCssClasses.length>0)for(let a of t.additionalCssClasses)e.addClass(a);if(e.addClass("modal-type-"+t.type),e.addClass("modal-severity-"+o.getCssClass(t.severity)),e.addClass("modal-style-"+t.style),e.addClass("modal-size-"+t.size),e.attr("tabindex","-1"),e.find(d.title).text(t.title),e.find(d.close).on("click",()=>{e.modal("hide")}),"ajax"===t.type){const a=t.ajaxTarget?t.ajaxTarget:d.body,n=e.find(a);l.getIcon("spinner-circle",l.sizes.default,null,null,l.markupIdentifiers.inline).then(e=>{n.html('<div class="modal-loading">'+e+"</div>"),new i(t.content).get().then(async e=>{this.currentModal.find(a).empty().append(await e.raw().text()),t.ajaxCallback&&t.ajaxCallback(),this.currentModal.trigger("modal-loaded")})})}else"iframe"===t.type?(e.find(d.body).append(a("<iframe />",{src:t.content,name:"modal_frame",class:"modal-iframe t3js-modal-iframe"})),e.find(d.iframe).on("load",()=>{e.find(d.title).text(e.find(d.iframe).get(0).contentDocument.title)})):("string"==typeof t.content&&(t.content=a("<p />").html(this.securityUtility.encodeHtml(t.content))),e.find(d.body).append(t.content));return e.on("shown.bs.modal",t=>{const e=a(t.currentTarget);e.find(d.footer).find(".t3js-active").first().focus(),e.find(d.iconPlaceholder).each((t,e)=>{l.getIcon(a(e).data("icon"),l.sizes.small,null,null,l.markupIdentifiers.inline).then(t=>{this.currentModal.find(d.iconPlaceholder+"[data-icon="+a(t).data("identifier")+"]").replaceWith(t)})})}),e.on("hidden.bs.modal",t=>{if(this.instances.length>0){const t=this.instances.length-1;this.instances.splice(t,1),this.currentModal=this.instances[t-1]}e.trigger("modal-destroyed"),a(t.currentTarget).remove(),this.instances.length>0&&a("body").addClass("modal-open")}),e.on("show.bs.modal",e=>{this.currentModal=a(e.currentTarget),this.setButtons(t.buttons),this.instances.push(this.currentModal)}),e.on("modal-dismiss",t=>{a(t.currentTarget).modal("hide")}),t.callback&&t.callback(e),e.modal()}}let m=null;try{parent&&parent.window.TYPO3&&parent.window.TYPO3.Modal?(parent.window.TYPO3.Modal.initializeMarkupTrigger(document),m=parent.window.TYPO3.Modal):top&&top.TYPO3.Modal&&(top.TYPO3.Modal.initializeMarkupTrigger(document),m=top.TYPO3.Modal)}catch(t){}return m||(m=new f(new s),TYPO3.Modal=m),m}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","./Enum/KeyTypes","jquery","nprogress","./Modal","./Severity","TYPO3/CMS/Core/SecurityUtility","TYPO3/CMS/Backend/Utility/MessageUtility"],(function(e,t,i,n,a,r,o,l,s){"use strict";return new class{constructor(){this.securityUtility=new l,n(()=>{this.registerEvents()})}registerEvents(){const e=this;n(document).on("click",".t3js-online-media-add-btn",t=>{e.triggerModal(n(t.currentTarget))})}addOnlineMedia(e,t){const i=e.data("target-folder"),l=e.data("online-media-allowed"),d=e.data("file-irre-object");a.start(),n.post(TYPO3.settings.ajaxUrls.online_media_create,{url:t,targetFolder:i,allowed:l},e=>{if(e.file){const t={actionName:"typo3:foreignRelation:insert",objectGroup:d,table:"sys_file",uid:e.file};s.MessageUtility.send(t)}else{const t=r.confirm("ERROR",e.error,o.error,[{text:TYPO3.lang["button.ok"]||"OK",btnClass:"btn-"+o.getCssClass(o.error),name:"ok",active:!0}]).on("confirm.button.ok",()=>{t.modal("hide")})}a.done()})}triggerModal(e){const t=e.data("btn-submit")||"Add",a=e.data("placeholder")||"Paste media url here...",l=n.map(e.data("online-media-allowed").split(","),e=>'<span class="label label-success">'+this.securityUtility.encodeHtml(e.toUpperCase(),!1)+"</span>"),s=e.data("online-media-allowed-help-text")||"Allow to embed from sources:",d=n("<div>").attr("class","form-control-wrap").append([n("<input>").attr("type","text").attr("class","form-control online-media-url").attr("placeholder",a),n("<div>").attr("class","help-block").html(this.securityUtility.encodeHtml(s,!1)+"<br>"+l.join(" "))]),c=r.show(e.attr("title"),d,o.notice,[{text:t,btnClass:"btn btn-primary",name:"ok",trigger:()=>{const t=c.find("input.online-media-url").val();t&&(c.modal("hide"),this.addOnlineMedia(e,t))}}]);c.on("shown.bs.modal",e=>{n(e.currentTarget).find("input.online-media-url").first().focus().on("keydown",e=>{e.keyCode===i.KeyTypesEnum.ENTER&&c.find('button[name="ok"]').trigger("click")})})}}}));
\ No newline at end of file
define(["require","exports","jquery","TYPO3/CMS/Backend/Utility/MessageUtility","./Enum/KeyTypes","nprogress","TYPO3/CMS/Core/Ajax/AjaxRequest","TYPO3/CMS/Core/SecurityUtility","./Modal","./Severity"],(function(e,t,i,a,n,r,o,s,l,d){"use strict";return new class{constructor(){this.securityUtility=new s,i(()=>{this.registerEvents()})}registerEvents(){const e=this;i(document).on("click",".t3js-online-media-add-btn",t=>{e.triggerModal(i(t.currentTarget))})}addOnlineMedia(e,t){const i=e.data("target-folder"),n=e.data("online-media-allowed"),s=e.data("file-irre-object");r.start(),new o(TYPO3.settings.ajaxUrls.online_media_create).post({url:t,targetFolder:i,allowed:n}).then(async e=>{const t=await e.resolve();if(t.file){const e={actionName:"typo3:foreignRelation:insert",objectGroup:s,table:"sys_file",uid:t.file};a.MessageUtility.send(e)}else{const e=l.confirm("ERROR",t.error,d.error,[{text:TYPO3.lang["button.ok"]||"OK",btnClass:"btn-"+d.getCssClass(d.error),name:"ok",active:!0}]).on("confirm.button.ok",()=>{e.modal("hide")})}r.done()})}triggerModal(e){const t=e.data("btn-submit")||"Add",a=e.data("placeholder")||"Paste media url here...",r=i.map(e.data("online-media-allowed").split(","),e=>'<span class="label label-success">'+this.securityUtility.encodeHtml(e.toUpperCase(),!1)+"</span>"),o=e.data("online-media-allowed-help-text")||"Allow to embed from sources:",s=i("<div>").attr("class","form-control-wrap").append([i("<input>").attr("type","text").attr("class","form-control online-media-url").attr("placeholder",a),i("<div>").attr("class","help-block").html(this.securityUtility.encodeHtml(o,!1)+"<br>"+r.join(" "))]),c=l.show(e.attr("title"),s,d.notice,[{text:t,btnClass:"btn btn-primary",name:"ok",trigger:()=>{const t=c.find("input.online-media-url").val();t&&(c.modal("hide"),this.addOnlineMedia(e,t))}}]);c.on("shown.bs.modal",e=>{i(e.currentTarget).find("input.online-media-url").first().focus().on("keydown",e=>{e.keyCode===n.KeyTypesEnum.ENTER&&c.find('button[name="ok"]').trigger("click")})})}}}));
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment