Fossil SCM

Made copy-to-clipboard toast message less verbose. Tapping anywhere on the clipboard buttons popup widget now activates the clipboard copy.

stephan 2020-08-16 02:43 line-number-selection
Commit 739e4ee339209b0f63e59fbaf5cc02c2dec736b4a13f43f3917490384e738bd6
1 file changed +10 -8
--- src/fossil.numbered-lines.js
+++ src/fossil.numbered-lines.js
@@ -23,10 +23,13 @@
2323
urlArgs: (window.location.search||'?').replace(/&?\bln=[^&]*/,''),
2424
start: 0, end: 0
2525
};
2626
2727
const lineTip = new fossil.PopupWidget({
28
+ style: {
29
+ cursor: 'pointer'
30
+ },
2831
refresh: function(){
2932
const link = this.state.link;
3033
D.clearElement(link);
3134
if(lineState.start){
3235
const ls = [lineState.start];
@@ -51,21 +54,20 @@
5154
this.state = {link};
5255
F.copyButton(btnCopy,{
5356
copyFromElement: link,
5457
extractText: ()=>link.dataset.url,
5558
oncopy: (ev)=>{
56
- F.toast("Copied: ",D.append(D.code(),ev.detail.text));
5759
D.flashOnce(ev.target, undefined, ()=>lineTip.hide());
60
+ F.toast("Copied link to clipboard.");
5861
}
59
- });//.addEventListener('text-copied', (ev)=>D.flashOnce(ev.target));
62
+ });
63
+ this.e.addEventListener('click', ()=>btnCopy.click(), false);
6064
D.append(this.e, btnCopy, link)
6165
}
6266
});
6367
64
- tbl.addEventListener('click', function f(ev){
65
- lineTip.show(false);
66
- }, false);
68
+ tbl.addEventListener('click', ()=>lineTip.hide(), true);
6769
6870
tdLn.addEventListener('click', function f(ev){
6971
if('SPAN'!==ev.target.tagName) return;
7072
else if('number' !== typeof f.mode){
7173
f.mode = 0 /*0=none selected, 1=1 selected, 2=2 selected*/;
@@ -98,11 +100,13 @@
98100
}
99101
if(f.selected){/*Unmark previously-selected lines.*/
100102
f.selected.forEach(f.unselect);
101103
f.selected = undefined;
102104
}
103
- if(f.mode>0){/*Mark selected lines*/
105
+ if(0===f.mode){
106
+ lineTip.hide();
107
+ }else{/*Mark selected lines*/
104108
const rect = ev.target.getBoundingClientRect();
105109
f.selected = [];
106110
if(f.spans.length>=lineState.start){
107111
let i = lineState.start, end = lineState.end || lineState.start, span = f.spans[i-1];
108112
for( ; i<=end && span; span = f.spans[i++] ){
@@ -111,11 +115,9 @@
111115
if(i===lineState.start) span.classList.add('start');
112116
if(i===end) span.classList.add('end');
113117
}
114118
}
115119
lineTip.refresh().show(rect.right+3, rect.top-4);
116
- }else{
117
- lineTip.show(false);
118120
}
119121
}, false);
120122
121123
})();
122124
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button