Merge app tile stuff together

This commit is contained in:
Alexandre Aubin 2019-02-22 20:11:23 +01:00
parent c62471703b
commit 7fa5b91297

View file

@ -5,22 +5,11 @@
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
// Variables // Variables
var liMenu = document.querySelectorAll('#apps a') var colors = ['redbg','purpledarkbg','darkbluebg','orangebg','greenbg','darkbluebg','purpledarkbg','yellowbg','lightpinkbg','pinkbg','turquoisebg','yellowbg','lightbluebg','purpledarkbg', 'bluebg']
, colors = ['redbg','purpledarkbg','darkbluebg','orangebg','greenbg','darkbluebg','purpledarkbg','yellowbg','lightpinkbg','pinkbg','turquoisebg','yellowbg','lightbluebg','purpledarkbg', 'bluebg']
, addMailAlias = document.getElementById('add-mailalias') , addMailAlias = document.getElementById('add-mailalias')
, addMaildrop = document.getElementById('add-maildrop') , addMaildrop = document.getElementById('add-maildrop')
; ;
liMenu && [].forEach.call(liMenu, function(el, i) {
// Select a color value from the App label
randomColorNumber = parseInt(el.textContent, 36) % colors.length;
//randomColorNumber = i%colors.length; // Old value
// Add color class.
el.classList.add(colors[randomColorNumber]);
// Set first-letter data attribute.
el.querySelector('.first-letter').setAttribute('data-first-letter',el.textContent.substring(0, 2));
});
addMailAlias && addMailAlias.addEventListener('click', function(){ addMailAlias && addMailAlias.addEventListener('click', function(){
// Clone last input. // Clone last input.
var inputAliasClone = document.querySelector('.mailalias-input').cloneNode(true); var inputAliasClone = document.querySelector('.mailalias-input').cloneNode(true);
@ -39,11 +28,22 @@ document.addEventListener('DOMContentLoaded', function() {
addMaildrop.parentNode.insertBefore(inputDropClone, addMaildrop); addMaildrop.parentNode.insertBefore(inputDropClone, addMaildrop);
}); });
// handle app links so they work both in plain info page and in the info iframe called from ynhpanel.js
var app_tiles = document.getElementsByClassName("app-tile"); var app_tiles = document.getElementsByClassName("app-tile");
if (app_tiles) { if (app_tiles) {
for (var i = 0; i < app_tiles.length; i++) { for (var i = 0; i < app_tiles.length; i++) {
app_tiles[i].addEventListener('click', function(event) {
var el = app_tiles[i];
// Select a color value from the App label
randomColorNumber = parseInt(el.textContent, 36) % colors.length;
//randomColorNumber = i%colors.length; // Old value
// Add color class.
el.classList.add(colors[randomColorNumber]);
// Set first-letter data attribute.
el.querySelector('.first-letter').setAttribute('data-first-letter', el.textContent.substring(0, 2));
// handle app links so they work both in plain info page and in the info iframe called from ynhpanel.js
el.addEventListener('click', function(event) {
// if asked to open in new tab // if asked to open in new tab
if (event.ctrlKey || event.shiftKey || event.metaKey if (event.ctrlKey || event.shiftKey || event.metaKey
|| (event.button && event.button == 1)) { || (event.button && event.button == 1)) {