2019-02-21 19:26:11 +01:00
|
|
|
// FIXME : this stuff is really weird given that global.js
|
|
|
|
// is ran on all pages, even if you are not logged in ...
|
|
|
|
// Maybe add a check. I noticed that if the user is logged in,
|
|
|
|
// there's a "logged" class added to the body.
|
2014-05-14 01:42:31 +02:00
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
|
2014-05-14 11:14:45 +02:00
|
|
|
// Variables
|
2019-02-22 20:11:23 +01:00
|
|
|
var colors = ['redbg','purpledarkbg','darkbluebg','orangebg','greenbg','darkbluebg','purpledarkbg','yellowbg','lightpinkbg','pinkbg','turquoisebg','yellowbg','lightbluebg','purpledarkbg', 'bluebg']
|
2014-05-14 11:14:45 +02:00
|
|
|
, addMailAlias = document.getElementById('add-mailalias')
|
|
|
|
, addMaildrop = document.getElementById('add-maildrop')
|
|
|
|
;
|
2014-05-14 01:42:31 +02:00
|
|
|
|
2014-06-01 13:57:48 +02:00
|
|
|
addMailAlias && addMailAlias.addEventListener('click', function(){
|
2014-05-14 11:14:45 +02:00
|
|
|
// Clone last input.
|
|
|
|
var inputAliasClone = document.querySelector('.mailalias-input').cloneNode(true);
|
|
|
|
// Empty value.
|
|
|
|
inputAliasClone.value = '';
|
|
|
|
// Append to form-group.
|
|
|
|
addMailAlias.parentNode.insertBefore(inputAliasClone, addMailAlias);
|
2014-05-14 01:42:31 +02:00
|
|
|
});
|
|
|
|
|
2014-06-01 13:57:48 +02:00
|
|
|
addMaildrop && addMaildrop.addEventListener('click', function(){
|
2014-05-14 11:14:45 +02:00
|
|
|
// Clone last input.
|
|
|
|
var inputDropClone = document.querySelector('.maildrop-input').cloneNode(true);
|
|
|
|
// Empty value.
|
|
|
|
inputDropClone.value = '';
|
|
|
|
// Append to form-group.
|
|
|
|
addMaildrop.parentNode.insertBefore(inputDropClone, addMaildrop);
|
2014-05-14 01:42:31 +02:00
|
|
|
});
|
2014-05-14 11:14:45 +02:00
|
|
|
|
2019-02-22 17:35:03 +01:00
|
|
|
var app_tiles = document.getElementsByClassName("app-tile");
|
|
|
|
if (app_tiles) {
|
|
|
|
for (var i = 0; i < app_tiles.length; i++) {
|
2019-02-22 20:11:23 +01:00
|
|
|
|
|
|
|
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) {
|
2019-02-22 17:35:03 +01:00
|
|
|
// if asked to open in new tab
|
|
|
|
if (event.ctrlKey || event.shiftKey || event.metaKey
|
|
|
|
|| (event.button && event.button == 1)) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// if asked in current tab
|
|
|
|
else {
|
|
|
|
event.preventDefault();
|
|
|
|
parent.location.href=this.href;
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
}, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-21 19:20:55 +01:00
|
|
|
// FIXME - I don't understand what this do ...
|
|
|
|
// This looks kinda hackish :|
|
|
|
|
if(window.location != window.parent.location) {
|
|
|
|
// Set class to body to show we're in overlay
|
|
|
|
document.body.classList.add('overlay');
|
|
|
|
let userContainer = document.querySelector('a.user-container');
|
|
|
|
userContainer.classList.replace('user-container-info', 'user-container-edit');
|
|
|
|
userContainer.setAttribute('href', userContainer
|
|
|
|
.getAttribute('href')
|
|
|
|
.replace('edit.html', ''));
|
|
|
|
userContainer.addEventListener('click', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
window.parent.location.href = userContainer.getAttribute('href');
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2015-06-14 12:53:16 +02:00
|
|
|
});
|