Array.from() to spread syntax

This commit is contained in:
djmaze 2020-09-22 10:13:32 +02:00
parent 07b002a66a
commit df1d0fc8d6
6 changed files with 27 additions and 7 deletions

View file

@ -58,7 +58,7 @@ const doc = document,
tpl.querySelectorAll(':not('+allowedElements+',signature)').forEach(el => el.replaceWith(getFragmentOfChildren(el)));
tpl.querySelectorAll('*').forEach(el => {
if (el.hasAttributes()) {
Array.from(el.attributes).forEach(attr => {
[...el.attributes].forEach(attr => {
let name = attr.name.toLowerCase();
if (!allowedAttributes.includes(name)) {
el.removeAttribute(name);

View file

@ -397,8 +397,28 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
* @param {Object} oAttachment
* @returns {boolean}
*/
attachmentPreview() {
// TODO: add lightgallery alternative?
attachmentPreview(/*attachment*/) {
/*
if (attachment && attachment.isImage() && !attachment.isLinked && this.message() && this.message().attachments()) {
const items = this.message().attachments().map(item => {
if (item && !item.isLinked && item.isImage()) {
if (item === attachment) {
index = listIndex;
}
++listIndex;
return {
src: item.linkPreview(),
msrc: item.linkThumbnail(),
title: item.fileName
};
}
return null;
}).filter(value => !!value);
if (items.length) {
}
}
*/
return true;
}

View file

@ -67,7 +67,7 @@ window.BSN = (() => {
self.show = () => {
menu = parent.querySelector('.dropdown-menu');
menuItems = [];
Array.from(menu.children).forEach(child => {
[...menu.children].forEach(child => {
child.children.length && (child.children[0].tagName === 'A' && menuItems.push(child.children[0]));
child.tagName === 'A' && menuItems.push(child);
});

View file

@ -4,4 +4,4 @@
* Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE)
*/
window.BSN=(()=>{"use strict";const e=document,t=e=>e.focus?e.focus():e.setActive();return{Dropdown:function(s){let o,n=[];const r=this,a=s.parentNode,i=e=>{const t=e.target,s=t.href||t.parentNode&&t.parentNode.href;s&&"#"===s.slice(-1)&&e.preventDefault()},c=()=>{let t=s.open?"addEventListener":"removeEventListener";e[t]("click",d,!1),e[t]("keydown",h,!1),e[t]("keyup",p,!1),e[t]("focus",d,!1)},d=e=>{let t=e.target,n=o.contains(t),a=t&&(t.getAttribute("data-toggle")||t.parentNode&&t.parentNode.getAttribute("data-toggle"));"focus"===e.type&&(t===s||n)||a&&n||(r.hide(),i(e))},l=e=>{r.show(),i(e)},h=e=>("ArrowUp"===e.code||"ArrowDown"===e.code)&&e.preventDefault(),p=a=>{let i=e.activeElement,c=i===s,d=o.contains(i),l=i.parentNode===o||i.parentNode.parentNode===o,h=n.indexOf(i);l&&(h=c?0:"ArrowUp"===a.code?h>1?h-1:0:"ArrowDown"===a.code&&h<n.length-1?h+1:h,n[h]&&t(n[h])),(n.length&&l||!n.length&&(d||c)||!d)&&s.open&&"Escape"===a.code&&r.toggle()};r.show=(()=>{o=a.querySelector(".dropdown-menu"),n=[],Array.from(o.children).forEach(e=>{e.children.length&&"A"===e.children[0].tagName&&n.push(e.children[0]),"A"===e.tagName&&n.push(e)}),!("tabindex"in o)&&o.setAttribute("tabindex","0"),o.classList.add("show"),a.classList.add("show"),s.setAttribute("aria-expanded",!0),s.open=!0,s.removeEventListener("click",l,!1),setTimeout(()=>{t(o.getElementsByTagName("INPUT")[0]||s),c()},1)}),r.hide=(()=>{o.classList.remove("show"),a.classList.remove("show"),s.setAttribute("aria-expanded",!1),s.open=!1,c(),t(s),setTimeout(()=>s.Dropdown&&s.addEventListener("click",l,!1),1)}),r.toggle=(()=>a.classList.contains("show")&&s.open?r.hide():r.show()),s.addEventListener("click",l,!1),s.open=!1,s.Dropdown=r},Tab:class{constructor(e){this.element=e,e.Tab=this,e.addEventListener("click",e=>{e.preventDefault(),this.show()})}show(){const t=this.element,s=t.closest("li");if(!s.classList.contains("active")){const o=t.closest("ul").querySelector(".active a");o.closest("li").classList.remove("active"),e.querySelector(o.getAttribute("href")).classList.remove("active"),s.classList.add("active"),e.querySelector(t.getAttribute("href")).classList.add("active")}}}}})();
window.BSN=(()=>{"use strict";const e=document,t=e=>e.focus?e.focus():e.setActive();return{Dropdown:function(s){let o,n=[];const r=this,i=s.parentNode,a=e=>{const t=e.target,s=t.href||t.parentNode&&t.parentNode.href;s&&"#"===s.slice(-1)&&e.preventDefault()},c=()=>{let t=s.open?"addEventListener":"removeEventListener";e[t]("click",d,!1),e[t]("keydown",h,!1),e[t]("keyup",p,!1),e[t]("focus",d,!1)},d=e=>{let t=e.target,n=o.contains(t),i=t&&(t.getAttribute("data-toggle")||t.parentNode&&t.parentNode.getAttribute("data-toggle"));"focus"===e.type&&(t===s||n)||i&&n||(r.hide(),a(e))},l=e=>{r.show(),a(e)},h=e=>("ArrowUp"===e.code||"ArrowDown"===e.code)&&e.preventDefault(),p=i=>{let a=e.activeElement,c=a===s,d=o.contains(a),l=a.parentNode===o||a.parentNode.parentNode===o,h=n.indexOf(a);l&&(h=c?0:"ArrowUp"===i.code?h>1?h-1:0:"ArrowDown"===i.code&&h<n.length-1?h+1:h,n[h]&&t(n[h])),(n.length&&l||!n.length&&(d||c)||!d)&&s.open&&"Escape"===i.code&&r.toggle()};r.show=(()=>{o=i.querySelector(".dropdown-menu"),n=[],[...o.children].forEach(e=>{e.children.length&&"A"===e.children[0].tagName&&n.push(e.children[0]),"A"===e.tagName&&n.push(e)}),!("tabindex"in o)&&o.setAttribute("tabindex","0"),o.classList.add("show"),i.classList.add("show"),s.setAttribute("aria-expanded",!0),s.open=!0,s.removeEventListener("click",l,!1),setTimeout(()=>{t(o.getElementsByTagName("INPUT")[0]||s),c()},1)}),r.hide=(()=>{o.classList.remove("show"),i.classList.remove("show"),s.setAttribute("aria-expanded",!1),s.open=!1,c(),t(s),setTimeout(()=>s.Dropdown&&s.addEventListener("click",l,!1),1)}),r.toggle=(()=>i.classList.contains("show")&&s.open?r.hide():r.show()),s.addEventListener("click",l,!1),s.open=!1,s.Dropdown=r},Tab:class{constructor(e){this.element=e,e.Tab=this,e.addEventListener("click",e=>{e.preventDefault(),this.show()})}show(){const t=this.element,s=t.closest("li");if(!s.classList.contains("active")){const o=t.closest("ul").querySelector(".active a");o.closest("li").classList.remove("active"),e.querySelector(o.getAttribute("href")).classList.remove("active"),s.classList.add("active"),e.querySelector(t.getAttribute("href")).classList.add("active")}}}}})();

2
vendors/jua/jua.js vendored
View file

@ -24,7 +24,7 @@
bCallLimit = false
;
Array.from(aItems).forEach(oItem => {
[...aItems].forEach(oItem => {
if (oItem)
{
if (!bUseLimit || 0 <= --iLimit)

File diff suppressed because one or more lines are too long