summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/res/smw/util/smw.property.page.js
blob: 766711f14faaa2d6f40a69435c1e4b823680ebe0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
 * @license GNU GPL v2+
 * @since 3.0
 *
 * @author mwjames
 */

/*global jQuery, mediaWiki, mw */
( function ( $, mw ) {

	'use strict';

	$( document ).ready( function() {

		$( '.smw-property-page-info' ).removeClass( 'is-disabled' );

		$( '.smw-property-page-info' ).each( function() {

			var context = $( this );

			var params = {
				'search': $( this ).data( 'label' ),
				'limit' : 1,
				'strict': true,
				'usageCount': true
			};

			var postArgs = {
				'action': 'smwbrowse',
				'browse': 'property',
				'params': JSON.stringify( params )
			};

			new mw.Api().post( postArgs ).then( function ( data ) {
				var text = '<table class="smw-personal-table"><tbody>' + data.query[context.data( 'key' )].usageCount + '</tbody></table>';

				smw.Factory.newTooltip().show ( {
					context: context,
					title: mw.msg( 'smw-personal-jobqueue-watchlist' ),
					type: 'persitent',
					content: text
				} );
			}, function () {
				// Do nothing
			} );
		} );

	} );

}( jQuery, mediaWiki ) );