You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.4 KiB
JavaScript
80 lines
2.4 KiB
JavaScript
5 years ago
|
require('./app.css');
|
||
6 years ago
|
|
||
3 years ago
|
import logo from './mailu.png';
|
||
|
import modules from "./*.json";
|
||
|
|
||
|
// TODO: conditionally (or lazy) load select2 and dataTable
|
||
|
$('document').ready(function() {
|
||
|
|
||
|
// intercept anchors with data-clicked attribute and open alternate location instead
|
||
|
$('[data-clicked]').click(function(e) {
|
||
|
e.preventDefault();
|
||
|
window.location.href = $(this).data('clicked');
|
||
|
});
|
||
|
|
||
|
// use post for language selection
|
||
|
$('#mailu-languages > a').click(function(e) {
|
||
|
e.preventDefault();
|
||
|
$.post({
|
||
|
url: $(this).attr('href'),
|
||
|
success: function() {
|
||
3 years ago
|
window.location = window.location.href;
|
||
3 years ago
|
},
|
||
|
});
|
||
|
});
|
||
|
|
||
|
// allow en-/disabling of inputs in fieldset with checkbox in legend
|
||
|
$('fieldset legend input[type=checkbox]').change(function() {
|
||
|
var fieldset = $(this).parents('fieldset');
|
||
|
if (this.checked) {
|
||
|
fieldset.removeAttr('disabled');
|
||
3 years ago
|
fieldset.find('input,textarea').not(this).removeAttr('disabled');
|
||
3 years ago
|
} else {
|
||
|
fieldset.attr('disabled', '');
|
||
3 years ago
|
fieldset.find('input,textarea').not(this).attr('disabled', '');
|
||
3 years ago
|
}
|
||
|
});
|
||
|
|
||
|
// display of range input value
|
||
|
$('input[type=range]').each(function() {
|
||
|
var value_element = $('#'+this.id+'_value');
|
||
|
if (value_element.length) {
|
||
|
value_element = $(value_element[0]);
|
||
|
var infinity = $(this).data('infinity');
|
||
|
var step = $(this).attr('step');
|
||
|
$(this).on('input', function() {
|
||
3 years ago
|
var num = (infinity && this.value == 0) ? '∞' : (this.value/step).toFixed(2);
|
||
|
if (num.endsWith('.00')) num = num.substr(0, num.length - 3);
|
||
|
value_element.text(num);
|
||
3 years ago
|
}).trigger('input');
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// init select2
|
||
|
$('.mailselect').select2({
|
||
6 years ago
|
tags: true,
|
||
3 years ago
|
tokenSeparators: [',', ' '],
|
||
4 years ago
|
});
|
||
3 years ago
|
|
||
|
// init dataTable
|
||
|
var d = $(document.documentElement);
|
||
|
$('.dataTable').DataTable({
|
||
|
'responsive': true,
|
||
|
language: {
|
||
|
url: d.data('static') + d.attr('lang') + '.json',
|
||
|
},
|
||
4 years ago
|
});
|
||
3 years ago
|
|
||
|
// init clipboard.js
|
||
|
new ClipboardJS('.btn-clip');
|
||
|
|
||
3 years ago
|
// disable login if not possible
|
||
|
var l = $('#login_needs_https');
|
||
|
if (l.length && window.location.protocol != 'https:') {
|
||
|
l.removeClass("d-none");
|
||
|
$('form :input').prop('disabled', true);
|
||
|
}
|
||
|
|
||
6 years ago
|
});
|
||
3 years ago
|
|