MediaWiki:Gadget-KeyShortcuts.js

/* * * KeyShortcuts.js * provides some useful keyboard shortcuts on the Gratisdata GUI $( function {	'use strict';	if ( !mw.config.exists( 'wbEntityId' ) ) {		return;	}	var addStatement = function  {		$( '.wikibase-toolbar-button-add' ).last.find( 'a' ).first.click;	},	editTerms = function  {		$( '.wikibase-entitytermsview .wikibase-toolbar-button-edit a' ).first.click;	},	editDescription = function  {		$( '.wikibase-entitytermsforlanguagelistview' ).one( 'entitytermsforlanguagelistviewafterstartediting', function  { $( '.wikibase-labelview-text textarea' ).one( 'focus', function {				$( this ).closest( '.wikibase-entitytermsforlanguageview' )				.find( '.wikibase-descriptionview-text textarea' ).first.focus;			} ); } );		editTerms;	},	scrollHelper = function ( $el ) {		if ( $el.length > 0 ) {			$( 'html, body' ).animate( { scrollTop: $el.first.offset.top }, 400 );		}	},	scrollToStatements = function {		scrollHelper( $( '#claims' ) );	},	scrollToIdentifiers = function  {		scrollHelper( $( '#identifiers' ) );	},	scrollToSitelinks = function  {		scrollHelper( $( '.wikibase-sitelinkgrouplistview' ) );	};	$( this )	.keydown( function ( event ) { if (			!event.ctrlKey &&			!event.altKey &&			!event.shiftKey &&			!event.metaKey &&			$( ':focus' ).length === 0		) { switch ( event.keyCode ) { case 65: addStatement; return false; // A				case 68: editDescription; return false; // D				case 73: scrollToSitelinks; return false; // I				case 74: scrollToIdentifiers; return false; // J				case 76: editTerms; return false; // L				case 83: scrollToStatements; return false; // S			} }	} ); } );