move of function showValueWithCopyPasteButton in function.lib.php
This commit is contained in:
parent
5e94cf09ef
commit
64d08544b2
@ -9231,3 +9231,42 @@ function readfileLowMemory($fullpath_original_file_osencoded, $method = -1)
|
||||
fclose($handle2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a button to copy $valuetoprint in the clipboard
|
||||
* @param string $valuetoprint the value to print
|
||||
* @param string $spanid unique id for a span
|
||||
* @param Translate $langs the $langs variable
|
||||
* @return string the string to print for the button
|
||||
*/
|
||||
function showValueWithCopyAndPasteButton($valuetoprint, $spanid, $langs)
|
||||
{
|
||||
$stringtoprint= '<span id="'.$spanid.'">';
|
||||
$stringtoprint.= $valuetoprint .'</span> ';
|
||||
$stringtoprint.= '</span>';
|
||||
$stringtoprint.='<span class="opacitymedium" id="'.dol_escape_json($spanid).'clipboardChar" onclick="'.dol_escape_json($spanid).'clipBoardCopy()"><i " class="far fa-clipboard"></i></span>';
|
||||
$stringtoprint.="<script>
|
||||
function ".dol_escape_json($spanid)."clipBoardCopy() {
|
||||
var copied_text = document.getElementById( \"".dol_escape_json($spanid)."\" );
|
||||
if ( window.getSelection ) {
|
||||
|
||||
selection = window.getSelection();
|
||||
|
||||
range = document.createRange();
|
||||
range.selectNodeContents( copied_text );
|
||||
|
||||
selection.removeAllRanges();
|
||||
selection.addRange( range );
|
||||
|
||||
}
|
||||
|
||||
document.execCommand( 'copy' );
|
||||
window.getSelection().removeAllRanges();
|
||||
var span = document.getElementById( \"".dol_escape_json($spanid)."clipboardChar\" );
|
||||
var tmp = span.innerHTML
|
||||
span.innerHTML = '".dol_escape_js($langs->trans('CopiedToClipboard'))."';
|
||||
setTimeout(() => { span.innerHTML = tmp; }, 1000);
|
||||
}
|
||||
</script>";
|
||||
return $stringtoprint;
|
||||
}
|
||||
@ -2939,43 +2939,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param string $valuetoprint the value to print
|
||||
* @param string $spanid unique id for a span
|
||||
* @param Translate $langs the $langs variable
|
||||
* @return string the string to print for the button
|
||||
*/
|
||||
function showValueWithCopyAndPasteButton($valuetoprint, $spanid, $langs)
|
||||
{
|
||||
$stringtoprint= '<span id="'.$spanid.'">';
|
||||
$stringtoprint.= $valuetoprint .'</span> ';
|
||||
$stringtoprint.= '</span>';
|
||||
$stringtoprint.='<span class="opacitymedium" id="'.dol_escape_json($spanid).'clipboardChar" onclick="'.dol_escape_json($spanid).'clipBoardCopy()"><i " class="far fa-clipboard"></i></span>';
|
||||
$stringtoprint.="<script>
|
||||
function ".dol_escape_json($spanid)."clipBoardCopy() {
|
||||
var copied_text = document.getElementById( \"".dol_escape_json($spanid)."\" );
|
||||
if ( window.getSelection ) {
|
||||
|
||||
selection = window.getSelection();
|
||||
|
||||
range = document.createRange();
|
||||
range.selectNodeContents( copied_text );
|
||||
|
||||
selection.removeAllRanges();
|
||||
selection.addRange( range );
|
||||
|
||||
}
|
||||
|
||||
document.execCommand( 'copy' );
|
||||
window.getSelection().removeAllRanges();
|
||||
var span = document.getElementById( \"".dol_escape_json($spanid)."clipboardChar\" );
|
||||
var tmp = span.innerHTML
|
||||
span.innerHTML = '".$langs->trans('CopiedToClipboard')."';
|
||||
setTimeout(() => { span.innerHTML = tmp; }, 1000);
|
||||
}
|
||||
</script>";
|
||||
return $stringtoprint;
|
||||
}
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user