Fossil

Check-in [2e17a063]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the "data-copylength" attribute to control the length of the copied text. (Rationale: Allow copying just the shortened hash prefixes from elements displaying the full-length hashes, because the short forms are preferred when building command-lines or URLs, and because the full-length hashes are already much easier to copy.)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tooltip-copyhash
Files: files | file ages | folders
SHA3-256: 2e17a063a25575ff8c5062b99ac1811d9ff702da8568d818c7d629c986236746
User & Date: florian 2019-05-30 11:33:00
Wiki:tooltip-copyhash
Context
2019-05-31
14:44
Check that the value of the "data-copylength" attribute is a positive number prior to chopping the text. check-in: b9823751 user: florian tags: tooltip-copyhash
2019-05-30
11:33
Add the "data-copylength" attribute to control the length of the copied text. (Rationale: Allow copying just the shortened hash prefixes from elements displaying the full-length hashes, because the short forms are preferred when building command-lines or URLs, and because the full-length hashes are already much easier to copy.) check-in: 2e17a063 user: florian tags: tooltip-copyhash
11:04
Revert the manual edits to the makefiles from [f6fcbf292b], and only keep the changes made by the src/makemake.tcl script. check-in: 2002a508 user: florian tags: tooltip-copyhash
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/copybtn.js.

1
2
3
4

5

6
7
8


9
10
11
12
13
14
15
16
17
18
19

20
21
22
23
24
25
26
..
29
30
31
32
33
34
35


36
37
38
39
40
41
42
/* Create (if necessary) and initialize a "Copy Text" button <idButton> linked
** to the target element <idTarget>.
**
** HTML snippet for statically created buttons:

**    <span class="copy-button" id="idButton" data-copytarget="idTarget"></span>

**
** Note: <idTarget> can be set statically or dynamically, this function does not
** overwrite "data-copytarget" attributes with empty values.


*/
function makeCopyButton(idButton,idTarget){
  var elButton = document.getElementById(idButton);
  if( !elButton ){
    elButton = document.createElement("span");
    elButton.className = "copy-button";
    elButton.id = idButton;
  }
  elButton.style.transition = "";
  elButton.style.opacity = 1;
  if( idTarget ) elButton.setAttribute("data-copytarget",idTarget);

  elButton.onclick = clickCopyButton;
  return elButton;
}
/* The onclick handler for the "Copy Text" button. */
var lockCopyText = false;
function clickCopyButton(e){
  e.preventDefault();   /* Mandatory for <a> and <button>. */
................................................................................
  lockCopyText = true;
  this.style.transition = "opacity 400ms ease-in-out";
  this.style.opacity = 0;
  var idTarget = this.getAttribute("data-copytarget");
  var elTarget = document.getElementById(idTarget);
  if( elTarget ){
    var text = elTarget.innerText;


    copyTextToClipboard(text);
  }
  setTimeout(function(id){
    var elButton = document.getElementById(id);
    if( elButton ){
      elButton.style.transition = "";
      elButton.style.opacity = 1;




>
|
>

|
<
>
>

|









>







 







>
>







1
2
3
4
5
6
7
8
9

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
..
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* Create (if necessary) and initialize a "Copy Text" button <idButton> linked
** to the target element <idTarget>.
**
** HTML snippet for statically created buttons:
**
**    <span class="copy-button" id="idButton"
**      data-copytarget="idTarget" data-copylength="cchLength"></span>
**
** Note: Both <idTarget> and <cchLength> can be set statically or dynamically,

** i.e. the makeCopyButton() function does not overwrite the "data-copytarget"
** and "data-copylength" attributes with empty/zero values.
*/
function makeCopyButton(idButton,idTarget,cchLength){
  var elButton = document.getElementById(idButton);
  if( !elButton ){
    elButton = document.createElement("span");
    elButton.className = "copy-button";
    elButton.id = idButton;
  }
  elButton.style.transition = "";
  elButton.style.opacity = 1;
  if( idTarget ) elButton.setAttribute("data-copytarget",idTarget);
  if( cchLength ) elButton.setAttribute("data-copylength",cchLength);
  elButton.onclick = clickCopyButton;
  return elButton;
}
/* The onclick handler for the "Copy Text" button. */
var lockCopyText = false;
function clickCopyButton(e){
  e.preventDefault();   /* Mandatory for <a> and <button>. */
................................................................................
  lockCopyText = true;
  this.style.transition = "opacity 400ms ease-in-out";
  this.style.opacity = 0;
  var idTarget = this.getAttribute("data-copytarget");
  var elTarget = document.getElementById(idTarget);
  if( elTarget ){
    var text = elTarget.innerText;
    var cchLength = this.getAttribute("data-copylength");
    if( cchLength ) text = text.slice(0,cchLength); // Assume single-byte chars.
    copyTextToClipboard(text);
  }
  setTimeout(function(id){
    var elButton = document.getElementById(id);
    if( elButton ){
      elButton.style.transition = "";
      elButton.style.opacity = 1;

Changes to src/graph.js.

627
628
629
630
631
632
633

634
635
636
637
638
639
640
641
        tooltipObj.style.backgroundColor = s.getPropertyValue('background-color')
      }
      tooltipObj.style.borderColor =
         tooltipObj.style.color = s.getPropertyValue('color')
      tooltipObj.style.visibility = "hidden"
      tooltipObj.innerHTML = html
      tooltipObj.appendChild(document.createTextNode(' '));

      tooltipObj.appendChild(makeCopyButton("tooltip-copybtn","tooltip-link"));
      tooltipObj.style.display = "inline"
      tooltipObj.style.position = "absolute"
      var x = tooltipInfo.posX + 4 + window.pageXOffset
                   - absoluteX(tooltipObj.offsetParent)
      tooltipObj.style.left = x+"px"
      var y = tooltipInfo.posY + window.pageYOffset
                   - tooltipObj.clientHeight - 4







>
|







627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
        tooltipObj.style.backgroundColor = s.getPropertyValue('background-color')
      }
      tooltipObj.style.borderColor =
         tooltipObj.style.color = s.getPropertyValue('color')
      tooltipObj.style.visibility = "hidden"
      tooltipObj.innerHTML = html
      tooltipObj.appendChild(document.createTextNode(' '));
      tooltipObj.appendChild(
        makeCopyButton("tooltip-copybtn","tooltip-link",0));
      tooltipObj.style.display = "inline"
      tooltipObj.style.position = "absolute"
      var x = tooltipInfo.posX + 4 + window.pageXOffset
                   - absoluteX(tooltipObj.offsetParent)
      tooltipObj.style.left = x+"px"
      var y = tooltipInfo.posY + window.pageYOffset
                   - tooltipObj.clientHeight - 4