update clipboardcopypaste with jquery
This commit is contained in:
parent
76ce77f7ba
commit
5a95cc16aa
@ -210,3 +210,25 @@ print '
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});'."\n";
|
});'."\n";
|
||||||
|
|
||||||
|
print "\n/* JS CODE TO ENABLE ClipBoard copy paste*/\n";
|
||||||
|
print 'jQuery(\'.clipboardCopyPaste\').click(function() {
|
||||||
|
console.log(this.firstChild.innerText);
|
||||||
|
if ( window.getSelection ) {
|
||||||
|
|
||||||
|
selection = window.getSelection();
|
||||||
|
|
||||||
|
range = document.createRange();
|
||||||
|
range.selectNodeContents( this.firstChild );
|
||||||
|
|
||||||
|
selection.removeAllRanges();
|
||||||
|
selection.addRange( range );
|
||||||
|
|
||||||
|
}
|
||||||
|
document.execCommand( \'copy\' );
|
||||||
|
window.getSelection().removeAllRanges();
|
||||||
|
var lastchild = this.lastChild
|
||||||
|
var tmp =lastchild.innerHTML
|
||||||
|
lastchild.innerHTML = \''.dol_escape_js($langs->trans('CopiedToClipboard')).'\';
|
||||||
|
setTimeout(() => { lastchild.innerHTML = tmp; }, 1000);
|
||||||
|
})'."\n";
|
||||||
@ -9239,34 +9239,9 @@ function readfileLowMemory($fullpath_original_file_osencoded, $method = -1)
|
|||||||
* @param Translate $langs the $langs variable
|
* @param Translate $langs the $langs variable
|
||||||
* @return string the string to print for the button
|
* @return string the string to print for the button
|
||||||
*/
|
*/
|
||||||
function showValueWithCopyAndPasteButton($valuetoprint, $spanid, $langs)
|
function showValueWithCopyAndPasteButton($valuetoprint)
|
||||||
{
|
{
|
||||||
$stringtoprint= '<span id="'.$spanid.'">';
|
return '<span class="clipboardCopyPaste"><span>'.dol_escape_js($valuetoprint).'
|
||||||
$stringtoprint.= $valuetoprint .'</span> ';
|
</span> <span class ="opacitymedium"><i " class="far fa-clipboard"></i></span></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;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2426,7 +2426,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
|||||||
print $langs->trans('CustomerCode');
|
print $langs->trans('CustomerCode');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print showValueWithCopyAndPasteButton($object->code_client, 'code_client', $langs);
|
print showValueWithCopyAndPasteButton($object->code_client);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
$tmpcheck = $object->check_codeclient();
|
$tmpcheck = $object->check_codeclient();
|
||||||
if ($tmpcheck != 0 && $tmpcheck != -5) {
|
if ($tmpcheck != 0 && $tmpcheck != -5) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user