Diferencia entre revisiones de «MediaWiki:Gadget-Descriptions.js»
(Página creada con «// required modules: wikibase.store.EntityStore, jquery.wikibase.wbtooltip ( function ( mw, $, wb ) { // only works for items if ( !mw.config.exists( 'wbEntityId' ) ) {...») |
(Sin diferencias)
|
Revisión actual del 08:56 9 abr 2014
// required modules: wikibase.store.EntityStore, jquery.wikibase.wbtooltip ( function ( mw, $, wb ) { // only works for items if ( !mw.config.exists( 'wbEntityId' ) ) { return; } function init() { var entityStore = new wb.store.EntityStore(); wb.compileEntityStoreFromMwConfig( entityStore ); $( '.wb-claimlistview a[href^="/wiki/"]' ) .each( function() { var $anchor = $( this ), id = $anchor.attr( 'href' ).replace( /.*(Q\d+)/, '$1' ).replace( /.*Property:(P\d+)/, '$1' ); if ( id.indexOf( 'Q' ) !== 0 && id.indexOf( 'P' ) !== 0 ) { return; } entityStore.get( id ) .done( function ( entity ) { var description = entity.getContent().getDescription(); if ( !description ) { return; } var $tooltip = $( '<span>' ) .appendTo( 'body' ) .wbtooltip( { content: $( '<span>' ).text( description ), permanent: true, gravity: 'nw', $anchor: $anchor } ); $anchor.hover( function() { $tooltip.data( 'wbtooltip' ).show(); }, function() { $tooltip.data( 'wbtooltip' ).hide(); } ); } ); } ); } mw.loader.using( ['wikibase.store.EntityStore', 'jquery.wikibase.wbtooltip'], function () { mw.hook( 'wikibase.domready' ).add( init ); } ); } ( mediaWiki, jQuery, wikibase ) );