Debug v16
This commit is contained in:
parent
8fb7d129c9
commit
7505e2a1ab
@ -231,33 +231,41 @@ print '
|
||||
);
|
||||
|
||||
jQuery(\'.clipboardCPValue, .clipboardCPButton, .clipboardCPValueToPrint\').click(function() {
|
||||
/* console.log(this.parentNode); */
|
||||
console.log("We click on a clipboardCPButton or clipboardCPValueToPrint class and we want to copy content of clipboardCPValue class");
|
||||
|
||||
if (window.getSelection) {
|
||||
range = document.createRange();
|
||||
|
||||
/* We select value to print using the parent. */
|
||||
/* We should use the class clipboardCPValue but it may have several element with copy/paste so class to select is not enough */
|
||||
range.selectNodeContents(this.parentNode.firstChild);
|
||||
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();
|
||||
}
|
||||
|
||||
/* copy selection into clipboard */
|
||||
var succeed;
|
||||
try {
|
||||
succeed = document.execCommand(\'copy\');
|
||||
} 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) {
|
||||
|
||||
@ -11030,12 +11030,12 @@ function readfileLowMemory($fullpath_original_file_osencoded, $method = -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a button to copy $valuetocopy in the clipboard.
|
||||
* Code that handle the click is inside lib_foot.jsp.php.
|
||||
* Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
|
||||
* Code that handle the click is inside core/js/lib_foot.js.php.
|
||||
*
|
||||
* @param string $valuetocopy The value to print
|
||||
* @param int $showonlyonhover Show the copy-paste button only on hover
|
||||
* @param string $texttoshow Replace the value to show with this text
|
||||
* @param string $texttoshow Replace the value to show with this text. Use 'none' to show no text (only the copy-paste picto)
|
||||
* @return string The string to print for the button
|
||||
*/
|
||||
function showValueWithClipboardCPButton($valuetocopy, $showonlyonhover = 1, $texttoshow = '')
|
||||
@ -11047,8 +11047,10 @@ function showValueWithClipboardCPButton($valuetocopy, $showonlyonhover = 1, $tex
|
||||
$showonlyonhover = 0;
|
||||
}*/
|
||||
|
||||
$tag = 'span'; // Using div does not work when using the js copy code.
|
||||
if ($texttoshow) {
|
||||
$tag = 'span'; // Using div (like any style of type 'block') does not work when using the js copy code.
|
||||
if ($texttoshow === 'none') {
|
||||
$result = '<span class="clipboardCP'.($showonlyonhover ? ' clipboardCPShowOnHover' : '').'"><'.$tag.' class="clipboardCPValue hidewithsize">'.dol_escape_htmltag($valuetocopy, 1, 1).'</'.$tag.'><span class="clipboardCPValueToPrint"></span><span class="clipboardCPButton far fa-clipboard opacitymedium paddingleft paddingright"></span><span class="clipboardCPText"></span></span>';
|
||||
} elseif ($texttoshow) {
|
||||
$result = '<span class="clipboardCP'.($showonlyonhover ? ' clipboardCPShowOnHover' : '').'"><'.$tag.' class="clipboardCPValue hidewithsize">'.dol_escape_htmltag($valuetocopy, 1, 1).'</'.$tag.'><span class="clipboardCPValueToPrint">'.dol_escape_htmltag($texttoshow, 1, 1).'</span><span class="clipboardCPButton far fa-clipboard opacitymedium paddingleft paddingright"></span><span class="clipboardCPText"></span></span>';
|
||||
} else {
|
||||
$result = '<span class="clipboardCP'.($showonlyonhover ? ' clipboardCPShowOnHover' : '').'"><'.$tag.' class="clipboardCPValue">'.dol_escape_htmltag($valuetocopy, 1, 1).'</'.$tag.'><span class="clipboardCPButton far fa-clipboard opacitymedium paddingleft paddingright"></span><span class="clipboardCPText"></span></span>';
|
||||
|
||||
@ -7260,7 +7260,7 @@ span.clipboardCPValueToPrint, div.clipboardCPValueToPrint {
|
||||
}
|
||||
span.clipboardCPValue.hidewithsize {
|
||||
width: 0 !important;
|
||||
display: inline-block;
|
||||
display: inline-block; /* this will be modifiy on the fly by the copy-paste js code in lib_foot.js.php to have copy feature working */
|
||||
color: transparent;
|
||||
white-space: nowrap;
|
||||
overflow-x: hidden;
|
||||
|
||||
@ -7026,7 +7026,7 @@ span.clipboardCPValueToPrint, div.clipboardCPValueToPrint {
|
||||
}
|
||||
span.clipboardCPValue.hidewithsize {
|
||||
width: 0 !important;
|
||||
display: inline-block;
|
||||
display: inline-block; /* this will be modifiy on the fly by the copy-paste js code in lib_foot.js.php to have copy feature working */
|
||||
color: transparent;
|
||||
white-space: nowrap;
|
||||
overflow-x: hidden;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user