Fossil SCM
Made copy-to-clipboard toast message less verbose. Tapping anywhere on the clipboard buttons popup widget now activates the clipboard copy.
Commit
739e4ee339209b0f63e59fbaf5cc02c2dec736b4a13f43f3917490384e738bd6
Parent
af47d1531d30c59…
1 file changed
+10
-8
+10
-8
| --- src/fossil.numbered-lines.js | ||
| +++ src/fossil.numbered-lines.js | ||
| @@ -23,10 +23,13 @@ | ||
| 23 | 23 | urlArgs: (window.location.search||'?').replace(/&?\bln=[^&]*/,''), |
| 24 | 24 | start: 0, end: 0 |
| 25 | 25 | }; |
| 26 | 26 | |
| 27 | 27 | const lineTip = new fossil.PopupWidget({ |
| 28 | + style: { | |
| 29 | + cursor: 'pointer' | |
| 30 | + }, | |
| 28 | 31 | refresh: function(){ |
| 29 | 32 | const link = this.state.link; |
| 30 | 33 | D.clearElement(link); |
| 31 | 34 | if(lineState.start){ |
| 32 | 35 | const ls = [lineState.start]; |
| @@ -51,21 +54,20 @@ | ||
| 51 | 54 | this.state = {link}; |
| 52 | 55 | F.copyButton(btnCopy,{ |
| 53 | 56 | copyFromElement: link, |
| 54 | 57 | extractText: ()=>link.dataset.url, |
| 55 | 58 | oncopy: (ev)=>{ |
| 56 | - F.toast("Copied: ",D.append(D.code(),ev.detail.text)); | |
| 57 | 59 | D.flashOnce(ev.target, undefined, ()=>lineTip.hide()); |
| 60 | + F.toast("Copied link to clipboard."); | |
| 58 | 61 | } |
| 59 | - });//.addEventListener('text-copied', (ev)=>D.flashOnce(ev.target)); | |
| 62 | + }); | |
| 63 | + this.e.addEventListener('click', ()=>btnCopy.click(), false); | |
| 60 | 64 | D.append(this.e, btnCopy, link) |
| 61 | 65 | } |
| 62 | 66 | }); |
| 63 | 67 | |
| 64 | - tbl.addEventListener('click', function f(ev){ | |
| 65 | - lineTip.show(false); | |
| 66 | - }, false); | |
| 68 | + tbl.addEventListener('click', ()=>lineTip.hide(), true); | |
| 67 | 69 | |
| 68 | 70 | tdLn.addEventListener('click', function f(ev){ |
| 69 | 71 | if('SPAN'!==ev.target.tagName) return; |
| 70 | 72 | else if('number' !== typeof f.mode){ |
| 71 | 73 | f.mode = 0 /*0=none selected, 1=1 selected, 2=2 selected*/; |
| @@ -98,11 +100,13 @@ | ||
| 98 | 100 | } |
| 99 | 101 | if(f.selected){/*Unmark previously-selected lines.*/ |
| 100 | 102 | f.selected.forEach(f.unselect); |
| 101 | 103 | f.selected = undefined; |
| 102 | 104 | } |
| 103 | - if(f.mode>0){/*Mark selected lines*/ | |
| 105 | + if(0===f.mode){ | |
| 106 | + lineTip.hide(); | |
| 107 | + }else{/*Mark selected lines*/ | |
| 104 | 108 | const rect = ev.target.getBoundingClientRect(); |
| 105 | 109 | f.selected = []; |
| 106 | 110 | if(f.spans.length>=lineState.start){ |
| 107 | 111 | let i = lineState.start, end = lineState.end || lineState.start, span = f.spans[i-1]; |
| 108 | 112 | for( ; i<=end && span; span = f.spans[i++] ){ |
| @@ -111,11 +115,9 @@ | ||
| 111 | 115 | if(i===lineState.start) span.classList.add('start'); |
| 112 | 116 | if(i===end) span.classList.add('end'); |
| 113 | 117 | } |
| 114 | 118 | } |
| 115 | 119 | lineTip.refresh().show(rect.right+3, rect.top-4); |
| 116 | - }else{ | |
| 117 | - lineTip.show(false); | |
| 118 | 120 | } |
| 119 | 121 | }, false); |
| 120 | 122 | |
| 121 | 123 | })(); |
| 122 | 124 |
| --- src/fossil.numbered-lines.js | |
| +++ src/fossil.numbered-lines.js | |
| @@ -23,10 +23,13 @@ | |
| 23 | urlArgs: (window.location.search||'?').replace(/&?\bln=[^&]*/,''), |
| 24 | start: 0, end: 0 |
| 25 | }; |
| 26 | |
| 27 | const lineTip = new fossil.PopupWidget({ |
| 28 | refresh: function(){ |
| 29 | const link = this.state.link; |
| 30 | D.clearElement(link); |
| 31 | if(lineState.start){ |
| 32 | const ls = [lineState.start]; |
| @@ -51,21 +54,20 @@ | |
| 51 | this.state = {link}; |
| 52 | F.copyButton(btnCopy,{ |
| 53 | copyFromElement: link, |
| 54 | extractText: ()=>link.dataset.url, |
| 55 | oncopy: (ev)=>{ |
| 56 | F.toast("Copied: ",D.append(D.code(),ev.detail.text)); |
| 57 | D.flashOnce(ev.target, undefined, ()=>lineTip.hide()); |
| 58 | } |
| 59 | });//.addEventListener('text-copied', (ev)=>D.flashOnce(ev.target)); |
| 60 | D.append(this.e, btnCopy, link) |
| 61 | } |
| 62 | }); |
| 63 | |
| 64 | tbl.addEventListener('click', function f(ev){ |
| 65 | lineTip.show(false); |
| 66 | }, false); |
| 67 | |
| 68 | tdLn.addEventListener('click', function f(ev){ |
| 69 | if('SPAN'!==ev.target.tagName) return; |
| 70 | else if('number' !== typeof f.mode){ |
| 71 | f.mode = 0 /*0=none selected, 1=1 selected, 2=2 selected*/; |
| @@ -98,11 +100,13 @@ | |
| 98 | } |
| 99 | if(f.selected){/*Unmark previously-selected lines.*/ |
| 100 | f.selected.forEach(f.unselect); |
| 101 | f.selected = undefined; |
| 102 | } |
| 103 | if(f.mode>0){/*Mark selected lines*/ |
| 104 | const rect = ev.target.getBoundingClientRect(); |
| 105 | f.selected = []; |
| 106 | if(f.spans.length>=lineState.start){ |
| 107 | let i = lineState.start, end = lineState.end || lineState.start, span = f.spans[i-1]; |
| 108 | for( ; i<=end && span; span = f.spans[i++] ){ |
| @@ -111,11 +115,9 @@ | |
| 111 | if(i===lineState.start) span.classList.add('start'); |
| 112 | if(i===end) span.classList.add('end'); |
| 113 | } |
| 114 | } |
| 115 | lineTip.refresh().show(rect.right+3, rect.top-4); |
| 116 | }else{ |
| 117 | lineTip.show(false); |
| 118 | } |
| 119 | }, false); |
| 120 | |
| 121 | })(); |
| 122 |
| --- src/fossil.numbered-lines.js | |
| +++ src/fossil.numbered-lines.js | |
| @@ -23,10 +23,13 @@ | |
| 23 | urlArgs: (window.location.search||'?').replace(/&?\bln=[^&]*/,''), |
| 24 | start: 0, end: 0 |
| 25 | }; |
| 26 | |
| 27 | const lineTip = new fossil.PopupWidget({ |
| 28 | style: { |
| 29 | cursor: 'pointer' |
| 30 | }, |
| 31 | refresh: function(){ |
| 32 | const link = this.state.link; |
| 33 | D.clearElement(link); |
| 34 | if(lineState.start){ |
| 35 | const ls = [lineState.start]; |
| @@ -51,21 +54,20 @@ | |
| 54 | this.state = {link}; |
| 55 | F.copyButton(btnCopy,{ |
| 56 | copyFromElement: link, |
| 57 | extractText: ()=>link.dataset.url, |
| 58 | oncopy: (ev)=>{ |
| 59 | D.flashOnce(ev.target, undefined, ()=>lineTip.hide()); |
| 60 | F.toast("Copied link to clipboard."); |
| 61 | } |
| 62 | }); |
| 63 | this.e.addEventListener('click', ()=>btnCopy.click(), false); |
| 64 | D.append(this.e, btnCopy, link) |
| 65 | } |
| 66 | }); |
| 67 | |
| 68 | tbl.addEventListener('click', ()=>lineTip.hide(), true); |
| 69 | |
| 70 | tdLn.addEventListener('click', function f(ev){ |
| 71 | if('SPAN'!==ev.target.tagName) return; |
| 72 | else if('number' !== typeof f.mode){ |
| 73 | f.mode = 0 /*0=none selected, 1=1 selected, 2=2 selected*/; |
| @@ -98,11 +100,13 @@ | |
| 100 | } |
| 101 | if(f.selected){/*Unmark previously-selected lines.*/ |
| 102 | f.selected.forEach(f.unselect); |
| 103 | f.selected = undefined; |
| 104 | } |
| 105 | if(0===f.mode){ |
| 106 | lineTip.hide(); |
| 107 | }else{/*Mark selected lines*/ |
| 108 | const rect = ev.target.getBoundingClientRect(); |
| 109 | f.selected = []; |
| 110 | if(f.spans.length>=lineState.start){ |
| 111 | let i = lineState.start, end = lineState.end || lineState.start, span = f.spans[i-1]; |
| 112 | for( ; i<=end && span; span = f.spans[i++] ){ |
| @@ -111,11 +115,9 @@ | |
| 115 | if(i===lineState.start) span.classList.add('start'); |
| 116 | if(i===end) span.classList.add('end'); |
| 117 | } |
| 118 | } |
| 119 | lineTip.refresh().show(rect.right+3, rect.top-4); |
| 120 | } |
| 121 | }, false); |
| 122 | |
| 123 | })(); |
| 124 |