Aggiunto supporto agli input in Swal

@lucasalva87 Gli input per le azioni bulk devono essere definiti nel campo "msg".
This commit is contained in:
Thomas Zilio 2018-07-23 11:09:50 +02:00
parent 9f390c3702
commit 433c80dedc
2 changed files with 56 additions and 48 deletions

View File

@ -155,11 +155,11 @@ if (!empty($module_options) && $module_options != 'menu' && $module_options != '
$data = is_array($value) ? $value['data'] : [];
$extra = [];
foreach ($data as $k => $v) {
$extra[] = 'data-'.$k.'="'.$v.'"';
$extra[] = 'data-'.$k.'="'.prepareToField($v).'"';
}
echo '
<li role="presentation"><a class="bulk-action clickable" data-op="'.$key.'" data-backto="record-list" '.implode(' ', $extra).'>'.$text.'</a></li>';
<li role="presentation"><a class="bulk-action clickable" data-op="'.prepareToField($key).'" data-backto="record-list" '.implode(' ', $extra).'>'.$text.'</a></li>';
}
echo '

View File

@ -429,8 +429,8 @@ function start_widgets($widgets) {
// Modal
function launch_modal(title, href, init_modal, id) {
//Fix - Select2 does not function properly when I use it inside a Bootstrap modal.
$.fn.modal.Constructor.prototype.enforceFocus = function() {};
//Fix - Select2 does not function properly when I use it inside a Bootstrap modal.
$.fn.modal.Constructor.prototype.enforceFocus = function () {};
if (id == null) {
id = '#bs-popup';
@ -445,7 +445,7 @@ function launch_modal(title, href, init_modal, id) {
$(id).on('hidden.bs.modal', function () {
if ($('.modal-backdrop').length < 1 ) {
if ($('.modal-backdrop').length < 1) {
$('html').removeClass('modal-open');
$(this).html('');
$(this).data('modal', null);
@ -547,7 +547,7 @@ function start_datatables() {
var sum;
var tempo;
var tempo_attesa_ricerche = (globals.tempo_attesa_ricerche*1000);
var tempo_attesa_ricerche = (globals.tempo_attesa_ricerche * 1000);
var table = $this.DataTable({
language: {
@ -582,8 +582,7 @@ function start_datatables() {
style: 'multi',
selector: 'td:first-child'
},
buttons: [
{
buttons: [{
extend: 'csv',
fieldSeparator: ";",
exportOptions: {
@ -602,21 +601,21 @@ function start_datatables() {
},
{
extend: 'print',
autoPrint: true,
customize: function ( win ) {
$(win.document.body)
.css( 'font-size', '10pt' )
.append(
'<table class="main-records table table-condensed table-bordered dataTable" ><tfoot><tr><td></td><td class="pull-right" >'+$('#summable').text()+'</td><td></td></tr></tfoot></table>',
);
$(win.document.body).find( 'table' )
.addClass( 'compact' )
.css( 'font-size', 'inherit' );
$(win.document.body).find( 'td:first-child' )
.addClass( 'hide' );
$(win.document.body).find( 'th:first-child' )
.addClass( 'hide' );
},
autoPrint: true,
customize: function (win) {
$(win.document.body)
.css('font-size', '10pt')
.append(
'<table class="main-records table table-condensed table-bordered dataTable" ><tfoot><tr><td></td><td class="pull-right" >' + $('#summable').text() + '</td><td></td></tr></tfoot></table>',
);
$(win.document.body).find('table')
.addClass('compact')
.css('font-size', 'inherit');
$(win.document.body).find('td:first-child')
.addClass('hide');
$(win.document.body).find('th:first-child')
.addClass('hide');
},
exportOptions: {
modifier: {
selected: true
@ -678,15 +677,15 @@ function start_datatables() {
idx1 = 'module_' + $this.data('idmodule'); //+ "-" + $this.data('idplugin');
idx2 = 'search_' + $(this).parent().attr('id').replace('th_', '');
function start_search(search_value){
function start_search(search_value) {
session_set(idx1 + ',' + idx2, search_value, 0);
column.search(search_value).draw();
}
// Imposto delle sessioni per le ricerche del modulo e del campo specificatsi
if(e.keyCode == 13 || $(this).val()==''){
if (e.keyCode == 13 || $(this).val() == '') {
start_search($(this).val());
}else{
} else {
tempo = window.setTimeout(start_search, tempo_attesa_ricerche, $(this).val());
}
});
@ -776,7 +775,7 @@ function start_datatables() {
this.api().columns().every(function () {
if (sum.summable[i] != undefined) {
$(this.footer()).addClass("text-right");
$(this.footer()).attr("id", "summable");
$(this.footer()).attr("id", "summable");
$(this.footer()).html(sum.summable[i]);
} else $(this.footer()).html("&nbsp;");
i++;
@ -1035,7 +1034,7 @@ jQuery.fn.selectData = function () {
// Inputmask
function start_inputmask(element) {
if( element == undefined ){
if (element == undefined) {
element = '';
} else {
element = element + ' ';
@ -1043,24 +1042,24 @@ function start_inputmask(element) {
var date = moment.localeData().longDateFormat('L').toLowerCase();
$(element+".date-mask").inputmask(date, {
$(element + ".date-mask").inputmask(date, {
"placeholder": date
});
$(element+'.email-mask').inputmask('Regex', {
$(element + '.email-mask').inputmask('Regex', {
regex: "^[a-zA-Z0-9_!#$%&'*+/=?`{|}~^-]+(?:\\.[a-zA-Z0-9_!#$%&'*+/=?`{|}~^-]+)*@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$",
});
$(element+'.alphanumeric-mask').inputmask('Regex', {
$(element + '.alphanumeric-mask').inputmask('Regex', {
regex: "[A-Za-z0-9#_|\/\\-.]*",
});
if (isMobile.any()) {
$(element+'.inputmask-decimal, '+element+'.date-mask, '+element+'.timestamp-mask').each(function () {
$(element + '.inputmask-decimal, ' + element + '.date-mask, ' + element + '.timestamp-mask').each(function () {
$(this).attr('type', 'tel');
});
} else {
$(element+'.inputmask-decimal').each(function () {
$(element + '.inputmask-decimal').each(function () {
var $this = $(this);
var min = $this.attr('min-value');
@ -1068,7 +1067,7 @@ function start_inputmask(element) {
min = false;
}
var max = $this.attr('max-value');
var max = $this.attr('max-value');
if (max == 'undefined') {
max = false;
}
@ -1076,8 +1075,8 @@ function start_inputmask(element) {
$this.inputmask("decimal", {
min: min ? min : undefined,
allowMinus: !min || min < 0 ? true : false,
max: max ? max : undefined,
allowPlus: !max || max < 0 ? true : false,
max: max ? max : undefined,
allowPlus: !max || max < 0 ? true : false,
digits: $this.attr('decimals') ? $this.attr('decimals') : globals.cifre_decimali,
digitsOptional: true, // Necessario per un problema di inputmask con i numeri negativi durante l'init
enforceDigitsOnBlur: true,
@ -1162,9 +1161,9 @@ function session_set(session_array, value, clear, reload) {
reload = 0;
}
return $.get(globals.rootdir + "/ajax.php?op=session_set&session=" + session_array + "&value=" + value + "&clear=" + clear, function(data, status){
return $.get(globals.rootdir + "/ajax.php?op=session_set&session=" + session_array + "&value=" + value + "&clear=" + clear, function (data, status) {
if (reload==1)
if (reload == 1)
location.reload();
});
@ -1261,7 +1260,7 @@ function message(element) {
if (data["title"] != undefined) title = data["title"];
var msg = globals.translations.deleteMessage;
if (data["msg"] != undefined) msg = data["msg"];
if (data["msg"] != undefined) msg = '<div id="swal-form">' + data["msg"] + '</div>';
var button = globals.translations.delete;
if (data["button"] != undefined) button = data["button"];
@ -1271,11 +1270,21 @@ function message(element) {
swal({
title: title,
text: msg,
html: msg,
type: "warning",
showCancelButton: true,
confirmButtonText: button,
confirmButtonClass: btn_class,
preConfirm: function () {
$('#swal-form').find(':input').each(function () {
data[$(this).attr('name')] = $(this).val();
console.log($(this).attr('name'));
});
return new Promise(function (resolve) {
resolve([]);
});
}
}).then(
function (result) {
if (data["op"] == undefined) data["op"] = "delete";
@ -1344,8 +1353,8 @@ function redirect(href, data, method, blank) {
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+ d.toUTCString();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
@ -1353,7 +1362,7 @@ function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
@ -1366,13 +1375,12 @@ function getCookie(cname) {
}
/**
* Funzione per controllare se un file esiste
*/
* Funzione per controllare se un file esiste
*/
function UrlExists(url)
{
function UrlExists(url) {
var http = new XMLHttpRequest();
http.open('HEAD', url, false);
http.send();
return http.status!=404;
return http.status != 404;
}