html tag, so we try to update input form field with name=page_y with value "+page_y);
jQuery("input[type=hidden][name=page_y]").val(page_y);
}
}
});
});'."\n";
// Code to manage Copy To Clipboard click
print "\n/* JS CODE TO ENABLE ClipBoard copy paste */\n";
print '
jQuery(document).ready(function() {
jQuery(\'.clipboardCPShowOnHover\').hover(
function() {
console.log("We hover a value with a copy paste feature");
$(this).children(".clipboardCPButton, .clipboardCPText").show();
},
function() {
console.log("We hover out the value with a copy paste feature");
$(this).children(".clipboardCPButton, .clipboardCPText").hide();
}
);
jQuery(\'.clipboardCPValue, .clipboardCPButton, .clipboardCPValueToPrint\').click(function() {
console.log("We click on a clipboardCPButton or clipboardCPValueToPrint class and we want to copy content of clipboardCPValue class");
if (window.getSelection) {
jqobj=$(this).parent().children(".clipboardCPValue");
console.log(jqobj.html());
selection = window.getSelection(); /* get the object used for selection */
selection.removeAllRanges(); /* clear current selection */
/* We select the value to print using the parentNode.firstChild */
/* We should use the class clipboardCPValue but it may have several element with copy/paste so class to select is not enough */
range = document.createRange();
range.selectNodeContents(this.parentNode.firstChild);
selection.addRange(range); /* make the new selection with the value to copy */
/* copy selection into clipboard */
var succeed;
try {
console.log("We set the style display to unset for the span so the copy will work");
jqobj.css("display", "unset"); /* Because copy does not work on "block" object */
succeed = document.execCommand(\'copy\');
console.log("We set the style display back to inline-block");
jqobj.css("display", "inline-block");
} catch(e) {
succeed = false;
}
/* Remove the selection to avoid to see the hidden field to copy selected */
window.getSelection().removeAllRanges();
}
/* Show message */
/* TODO Show message into a top left corner or center of screen */
var lastchild = this.parentNode.lastChild; /* .parentNode is clipboardCP and last child is clipboardCPText */
var tmp = lastchild.innerHTML
if (succeed) {
lastchild.innerHTML = \''.dol_escape_js($langs->trans('CopiedToClipboard')).'
\';
} else {
lastchild.innerHTML = \''.dol_escape_js($langs->trans('Error')).'
\';
}
setTimeout(() => { lastchild.innerHTML = tmp; }, 1000);
});
});'."\n";
// Code to manage clicktodial
print "\n/* JS CODE TO ENABLE clicktodial call of an URL */\n";
print '
jQuery(document).ready(function() {
jQuery(".cssforclicktodial").click(function() {
event.preventDefault();
var currenttoken = jQuery("meta[name=anti-csrf-currenttoken]").attr("content");
console.log("We click on a cssforclicktodial class with href="+this.href);
$.ajax({
url: this.href,
type: \'GET\',
data: { token: currenttoken }
}).done(function(xhr, textStatus, errorThrown) {
/* do nothing */
}).fail(function(xhr, textStatus, errorThrown) {
alert("Error: "+textStatus);
});
return false;
});
});'."\n";
// Code to manage the confirm dialog box
print "\n/* JS CODE TO ENABLE DIALOG CONFIRM POPUP ON ACTION BUTTON */\n";
print '
jQuery(document).ready(function() {
$(document).on("click", \'.butActionConfirm\', function(event) {
event.preventDefault();
// I don\'t use jquery $(this).data(\'confirm-url\'); to get $(this).attr(\'data-confirm-url\'); because .data() can doesn\'t work with ajax
var confirmUrl = $(this).attr(\'data-confirm-url\');
var confirmTitle = $(this).attr(\'data-confirm-title\');
var confirmContent = $(this).attr(\'data-confirm-content\');
var confirmActionBtnLabel = $(this).attr(\'data-confirm-action-btn-label\');
var confirmCancelBtnLabel = $(this).attr(\'data-confirm-cancel-btn-label\');
var confirmModal = $(this).attr(\'data-confirm-modal\');
if(confirmModal == undefined){ confirmModal = false; }
var confirmId = \'confirm-dialog-box\';
if($(this).attr(\'id\') != undefined){ var confirmId = confirmId + "-" + $(this).attr(\'id\'); }
if($("#" + confirmId) != undefined) { $(\'#\' + confirmId).remove(); }
// Create modal box
var $confirmBox = $(\'\', {
id: confirmId,
title: confirmTitle
}).appendTo(\'body\');
$confirmBox.dialog({
autoOpen: true,
modal: confirmModal,
//width: Math.min($( window ).width() - 50, 1700),
width: \'auto\',
dialogClass: \'confirm-dialog-box\',
buttons: [
{
text: confirmActionBtnLabel,
"class": \'ui-state-information\',
click: function () {
window.location.replace(confirmUrl);
}
},
{
text: confirmCancelBtnLabel,
"class": \'ui-state-information\',
click: function () {
$(this).dialog("close");
}
}
],
close: function( event, ui ) {
$(\'#\'+confirmBox).remove();
},
open: function( event, ui ) {
$confirmBox.html(confirmContent);
}
});
});
});
'."\n";