MediaWiki:Gadget-GrAnnotations.js: Difference between revisions
No edit summary |
No edit summary |
||
| Line 469: | Line 469: | ||
+ commentText.slice(0,500) | + commentText.slice(0,500) | ||
+ ( commentText.length > 500 ? '\n...' : '' ) | + ( commentText.length > 500 ? '\n...' : '' ) | ||
+ '\n\n[[User:Chandrashekars|Chandrashekars]] ([[User talk:Chandrashekars|talk]]) 18: | + '\n\n[[User:Chandrashekars|Chandrashekars]] ([[User talk:Chandrashekars|talk]]) 18:58, 25 April 2026 (UTC)'; | ||
new mw.Api().postWithEditToken({ | new mw.Api().postWithEditToken({ | ||
action:'edit', title:'User_talk:' + ADMIN_USER, section:'new', | action:'edit', title:'User_talk:' + ADMIN_USER, section:'new', | ||
| Line 677: | Line 677: | ||
// ── Selection → show FAB ────────────────────────────────────── | // ── Selection → show FAB ────────────────────────────────────── | ||
// | // Listen on the content area only, not the whole document, | ||
// | // so we never accidentally capture selections in the panel/composer. | ||
$( document ).on('mouseup', function( | var $content = $( CONTENT_SEL ); | ||
// | if ( !$content.length ) $content = $( document ); | ||
$content.on('mouseup', function(){ | |||
// Brief delay so browser finalises the selection object | |||
setTimeout( function(){ | |||
if ( $cmpComposer.hasClass('gra-composer-visible') || | |||
$bmComposer.hasClass('gra-composer-visible') ) return; | |||
if ( captureSelection() ) { | if ( captureSelection() ) { | ||
showFab( _selRect ); | showFab( _selRect ); | ||
| Line 691: | Line 692: | ||
hideFab(); | hideFab(); | ||
} | } | ||
}, | }, 50 ); | ||
}); | }); | ||
// ── FAB mousedown | // ── FAB buttons ────────────────────────────────────────────── | ||
// | // preventDefault on mousedown keeps the browser text-selection alive. | ||
// | // We also stopPropagation so the document mousedown handler below | ||
$fab.on('mousedown', function(e){ | // does NOT fire and hide the FAB before the click registers. | ||
$( '#gra-fab-comment' ).on('mousedown', function(e){ | |||
e.preventDefault(); | e.preventDefault(); | ||
e.stopPropagation(); | e.stopPropagation(); | ||
}).on('click', function(){ | |||
openCommentComposer(); | openCommentComposer(); | ||
}); | }); | ||
$( '#gra-fab-bookmark' ).on('mousedown', function(e){ | |||
$( '#gra-fab-bookmark' ).on(' | e.preventDefault(); | ||
e.stopPropagation(); | e.stopPropagation(); | ||
}).on('click', function(){ | |||
openBookmarkComposer(); | openBookmarkComposer(); | ||
}); | |||
// ── Hide FAB when clicking elsewhere ───────────────────────── | |||
$( document ).on('mousedown', function(e){ | |||
var $t = $( e.target ); | |||
var inside = $t.closest( | |||
'#gra-fab, .gra-composer, .gra-bm-composer, #gra-toggle, #gra-panel' | |||
).length; | |||
if ( !inside ) hideFab(); | |||
}); | }); | ||