Your IP : 216.73.217.95


Current Path : /var/www/surf/TYPO3/vendor/typo3/cms-backend/Resources/Public/JavaScript/
Upload File :
Current File : //var/www/surf/TYPO3/vendor/typo3/cms-backend/Resources/Public/JavaScript/switch-user.js

/*
 * 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!
 */
var Modes,__decorate=function(t,e,r,s){var i,o=arguments.length,n=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,r,s);else for(var c=t.length-1;c>=0;c--)(i=t[c])&&(n=(o<3?i(n):o>3?i(e,r,n):i(e,r))||n);return o>3&&n&&Object.defineProperty(e,r,n),n};import{html,css,LitElement}from"lit";import{customElement,property}from"lit/decorators.js";import AjaxRequest from"@typo3/core/ajax/ajax-request.js";import Notification from"@typo3/backend/notification.js";!function(t){t.switch="switch",t.exit="exit"}(Modes||(Modes={}));let SwitchUser=class extends LitElement{constructor(){super(),this.mode=Modes.switch,this.addEventListener("click",(t=>{t.preventDefault(),this.mode===Modes.switch?this.handleSwitchUser():this.mode===Modes.exit&&this.handleExitSwitchUser()})),this.addEventListener("keydown",(t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.mode===Modes.switch?this.handleSwitchUser():this.mode===Modes.exit&&this.handleExitSwitchUser())}))}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0")}render(){return html`<slot></slot>`}handleSwitchUser(){this.targetUser?new AjaxRequest(TYPO3.settings.ajaxUrls.switch_user).post({targetUser:this.targetUser}).then((async t=>{const e=await t.resolve();!0===e.success&&e.url?top.window.location.href=e.url:Notification.error("Switching to user went wrong.")})):Notification.error("Switching to user went wrong.")}handleExitSwitchUser(){new AjaxRequest(TYPO3.settings.ajaxUrls.switch_user_exit).post({}).then((async t=>{const e=await t.resolve();!0===e.success&&e.url?top.window.location.href=e.url:Notification.error("Exiting current user went wrong.")}))}};SwitchUser.styles=[css`:host { cursor: pointer; appearance: button; }`],__decorate([property({type:String})],SwitchUser.prototype,"targetUser",void 0),__decorate([property({type:Modes})],SwitchUser.prototype,"mode",void 0),SwitchUser=__decorate([customElement("typo3-backend-switch-user")],SwitchUser);export{SwitchUser};