2014-05-14 01:42:31 +02:00
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
|
2014-05-14 11:14:45 +02:00
|
|
|
// Variables
|
|
|
|
var liMenu = document.querySelectorAll('#apps a')
|
|
|
|
, colors = ['bluebg','purplebg','redbg','orangebg','greenbg','darkbluebg','lightbluebg','yellowbg','lightpinkbg']
|
|
|
|
, 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
|
|
|
liMenu && [].forEach.call(liMenu, function(el, i) {
|
2014-05-14 11:14:45 +02:00
|
|
|
// Add color class.
|
2014-05-20 13:23:51 +02:00
|
|
|
el.classList.add(colors[i%colors.length]);
|
2014-05-14 11:14:45 +02:00
|
|
|
// Set first-letter data attribute.
|
|
|
|
el.querySelector('.first-letter').setAttribute('data-first-letter',el.textContent.substring(0, 2));
|
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
|
|
|
|
2014-05-14 01:42:31 +02:00
|
|
|
});
|