v0.165.1: native Megosztás… button in the share modal (Web Share API)
Feature-detected navigator.share opens the OS share sheet with title+text+URL only (no QR files: — narrow support drops the URL when given file+URL). Hidden unless supported; Link másolása stays the universal fallback and catches the non-cancel rejection; AbortError is silent. Template JS + tests only. 2 red-proofs verified red.
This commit is contained in:
@@ -59,6 +59,7 @@
|
||||
<div class="share-link-row">
|
||||
<input id="share-link-input" type="text" readonly value="{{.ShareURL}}">
|
||||
<button type="button" id="share-copy-btn" class="btn btn-outline" onclick="copyShareLink()">Link másolása</button>
|
||||
<button type="button" id="share-native-btn" class="btn btn-outline" style="display:none" onclick="nativeShare()">Megosztás…</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="share-qr">
|
||||
@@ -124,9 +125,19 @@ function copyShareLink(){
|
||||
if(navigator.clipboard&&navigator.clipboard.writeText){navigator.clipboard.writeText(inp.value).then(done,function(){inp.select();done();});}
|
||||
else{inp.select();try{document.execCommand('copy');}catch(e){}done();}
|
||||
}
|
||||
// Native OS share sheet (Web Share API, feature-detected). URL + title/text only — never the QR as a
|
||||
// file: file-share support is narrow and several targets drop the URL when handed file+URL. On a
|
||||
// non-cancel rejection, fall back to the universal clipboard copy so the user still keeps the link.
|
||||
function nativeShare(){
|
||||
var inp=document.getElementById('share-link-input');
|
||||
if(!inp||!navigator.share)return;
|
||||
navigator.share({title:'Indítópult — {{.Domain}}',text:'Az otthoni alkalmazások egy helyen.',url:inp.value})
|
||||
.catch(function(e){if(e&&e.name==='AbortError')return;copyShareLink();});
|
||||
}
|
||||
(function(){
|
||||
var m=document.getElementById('share-modal');
|
||||
if(m){m.addEventListener('click',function(e){if(e.target===m)closeShareModal();});}
|
||||
if(navigator.share){var nb=document.getElementById('share-native-btn');if(nb)nb.style.display='';}
|
||||
{{if .ShareFlash}}openShareModal();{{end}}
|
||||
})();
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user