-
Notifications
You must be signed in to change notification settings - Fork 2
/
iconHelper.min.js
26 lines (26 loc) · 2.71 KB
/
iconHelper.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/***************************************************************
*
* Copyright notice
*
* (c) 2023 Regis TEDONE <syradev@proton.me>, Syradev
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
define("SYRADEV/RtPagesTreeIcons/iconHelper",["TYPO3/CMS/Backend/Notification"],t=>{"use strict";const n=document.querySelector("#icons-container"),o=document.querySelector("#new-icon-container"),c=document.querySelector("#iconName"),r=document.querySelector("#iconSize"),s=document.querySelector("#icon"),e=document.querySelector("#copyBtn"),a=document.querySelector("#copySuccessTitle"),l=document.querySelector("#copySuccessMessage"),i=document.querySelector("#semitransparent");n.addEventListener("click",e=>{const t=e.target.closest("li");t&&void 0!==t.dataset.icon&&(d(t).forEach(e=>{e.classList.remove("icon-current")}),t.classList.add("icon-current"),c.value=t.dataset.icon,u())},!0),r.addEventListener("change",()=>{u()}),i.addEventListener("click",()=>{u()});let u=()=>{require(["TYPO3/CMS/Core/Ajax/AjaxRequest"],e=>{var t={newIconName:c.value,newIconSize:r.value,semiTransparent:i.checked};const n=new e(TYPO3.settings.ajaxUrls.set_newIcon);n.post(t,{mode:"cors"}).then(async e=>{e=await e.resolve();s.value=e.newIconInfos.icon,o.innerHTML=e.newIconInfos.partialView},e=>{console.error("Request failed because of error: "+e.status+" "+e.statusText)})})},d=(e.addEventListener("click",()=>{var e=`<core:icon identifier="${s.value}" size="${r.value}"/>`;navigator.clipboard.writeText(e).then(()=>{t.success(a.value,l.value)})}),function(e){let t=[];if(!e.parentNode)return t;let n=e.parentNode.firstChild;for(;n;)1===n.nodeType&&n!==e&&t.push(n),n=n.nextSibling;return t});require(["TYPO3/CMS/Core/Ajax/AjaxRequest"],e=>{const t=new e(TYPO3.settings.ajaxUrls.get_allIcons);t.post({action:"iconsHelper"},{mode:"cors"}).then(async e=>{n.innerHTML=await e.resolve()},e=>{console.error("Request failed because of error: "+e.status+" "+e.statusText)})})});
//# sourceMappingURL=iconHelper.min.js.map