2017-08-04 16:28:16 +02:00
|
|
|
$(document).ready(function () {
|
2017-09-12 16:17:11 +02:00
|
|
|
// Modal di default
|
2017-08-04 16:28:16 +02:00
|
|
|
$('[data-href]').not('.ask, .bound').click(function () {
|
|
|
|
launch_modal($(this).data('title'), $(this).data('href'), 1, $(this).data('target'));
|
|
|
|
});
|
2017-09-12 16:17:11 +02:00
|
|
|
$('[data-href]').not('.ask, .bound').addClass('bound');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2017-09-12 16:17:11 +02:00
|
|
|
// Tooltip
|
2017-08-04 16:28:16 +02:00
|
|
|
$('.tip').not('.tooltipstered').tooltipster({
|
|
|
|
animation: 'grow',
|
|
|
|
contentAsHTML: true,
|
|
|
|
hideOnClick: true,
|
|
|
|
onlyOne: true,
|
|
|
|
maxWidth: 350,
|
|
|
|
touchDevices: true,
|
|
|
|
trigger: 'hover',
|
|
|
|
position: 'top'
|
|
|
|
});
|
|
|
|
|
2017-09-12 16:17:11 +02:00
|
|
|
// Autosize per le textarea
|
2017-08-04 16:28:16 +02:00
|
|
|
autosize($('.autosize'));
|
|
|
|
|
|
|
|
if ($('form').length) {
|
|
|
|
$('form').not('.no-check').parsley();
|
|
|
|
}
|
|
|
|
|
|
|
|
window.Parsley.on('field:success', function () {
|
|
|
|
this.$element.removeClass('parsley-success');
|
|
|
|
});
|
|
|
|
|
|
|
|
var icons = {
|
|
|
|
time: 'fa fa-clock-o',
|
|
|
|
date: 'fa fa-calendar',
|
|
|
|
up: 'fa fa-chevron-up',
|
|
|
|
down: 'fa fa-chevron-down',
|
|
|
|
previous: 'fa fa-chevron-left',
|
|
|
|
next: 'fa fa-chevron-right',
|
|
|
|
today: 'fa fa-street-view',
|
2017-08-28 09:50:25 +02:00
|
|
|
clear: 'fa fa-trash',
|
2017-08-04 16:28:16 +02:00
|
|
|
close: 'fa fa-times'
|
|
|
|
}
|
|
|
|
|
|
|
|
$('.timestamp-picker').each(function () {
|
|
|
|
$this = $(this);
|
|
|
|
$this.datetimepicker({
|
|
|
|
locale: globals.locale,
|
|
|
|
icons: icons,
|
2017-09-01 18:13:25 +02:00
|
|
|
collapse: false,
|
|
|
|
sideBySide: true,
|
2017-08-04 16:28:16 +02:00
|
|
|
useCurrent: false,
|
2017-09-01 18:13:25 +02:00
|
|
|
stepping: 5,
|
2017-09-06 15:29:51 +02:00
|
|
|
minDate: moment($this.attr('min-date')).isValid() ? $this.attr('min-date') : false,
|
|
|
|
maxDate: moment($this.attr('max-date')).isValid() ? $this.attr('max-date') : false,
|
2017-08-04 16:28:16 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.datepicker').each(function () {
|
|
|
|
$this = $(this);
|
|
|
|
$this.datetimepicker({
|
|
|
|
locale: globals.locale,
|
|
|
|
icons: icons,
|
|
|
|
useCurrent: false,
|
|
|
|
format: 'L',
|
2017-09-06 15:29:51 +02:00
|
|
|
minDate: moment($this.attr('min-date')).isValid() ? $this.attr('min-date') : false,
|
|
|
|
maxDate: moment($this.attr('max-date')).isValid() ? $this.attr('max-date') : false,
|
2017-08-04 16:28:16 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.timepicker').each(function () {
|
|
|
|
$this = $(this);
|
|
|
|
$this.datetimepicker({
|
|
|
|
locale: globals.locale,
|
|
|
|
icons: icons,
|
|
|
|
useCurrent: false,
|
|
|
|
format: 'LT',
|
|
|
|
stepping: 5,
|
2017-09-06 15:29:51 +02:00
|
|
|
minDate: moment($this.attr('min-date')).isValid() ? $this.attr('min-date') : false,
|
|
|
|
maxDate: moment($this.attr('max-date')).isValid() ? $this.attr('max-date') : false,
|
2017-08-04 16:28:16 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-08-30 14:43:38 +02:00
|
|
|
// Aggiunta nell'URL del nome tab su cui tornare dopo il submit
|
|
|
|
// Blocco del pulsante di submit dopo il primo submit
|
2017-08-04 16:28:16 +02:00
|
|
|
$("form").submit(function() {
|
|
|
|
if ($(this).parsley().validate()) {
|
|
|
|
$(this).submit(function() {
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$(this).find('[type=submit]').prop("disabled", true).addClass("disabled");
|
|
|
|
|
2017-08-30 14:43:38 +02:00
|
|
|
$(this).find('input:disabled, select:disabled').prop('disabled', false);
|
|
|
|
|
|
|
|
var hash = window.location.hash;
|
|
|
|
if (hash) {
|
|
|
|
var input = $('<input/>', {
|
|
|
|
type: 'hidden',
|
|
|
|
name: 'hash',
|
|
|
|
value: hash,
|
|
|
|
});
|
|
|
|
|
|
|
|
$(this).append(input);
|
|
|
|
}
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
start_superselect();
|
|
|
|
start_inputmask();
|
|
|
|
});
|