MediaWiki:Gadget-copyTable.js: Difference between revisions
Content deleted Content added
No edit summary |
No edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
Line 1:
/**
* Gadget: CopyTable
* Discreet copy icon at the
* Copies content as TSV for pasting into Excel / Sheets.
*/
Line 35:
mw.hook( 'wikipage.content' ).add( function ( $content ) {
// .chunkinfo: the narrow right-floated Chunk Info boxes (summary
$content.find( 'table.wikitable' ).not( '.copy-table-added' ).each( function () {▼
// Phase 3) — the wrapper divs would break their float (text must
// wrap around them), and TSV copy is pointless for annotation rows.
▲ $content.find( 'table.wikitable' ).not( '.copy-table-added' ).not( '.chunkinfo' ).each( function () {
var $table = $( this ).addClass( 'copy-table-added' );
Line 52 ⟶ 55:
} );
//
// button is a SIBLING of the scroller (inside the wrapper), so it stays at
$table.parent().append( $btn );▼
// the visible top-right while the table scrolls underneath. If the table is
// already inside a scroll box, reuse that box as the scroller.
var $parent = $table.parent();
var $scroller;
if ( /auto|scroll/.test( $parent.css( 'overflow-x' ) ) ) {
$scroller = $parent;
} else {
$table.wrap( '<div class="copy-table-scroll">' );
$scroller = $table.parent();
}
$scroller.wrap( '<div class="copy-table-wrapper">' );
} );
} );
| |||