summaryrefslogtreecommitdiff
path: root/extensions/Vector/modules/ext.vector.footerCleanup.js
blob: b3f5594d185d4fa9da247bfbf6149c92305a652d (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 * Footer cleanup for Vector
 */
jQuery( function ( $ ) {
	$( '#editpage-copywarn' )
		.add( '.editOptions' )
		.wrapAll( '<div id="editpage-bottom"></div>' );
	$( '#wpSummary' )
		.data( 'hint',
			$( '#wpSummaryLabel span small' )
				.remove()
				.text()
				// FIXME - Not a long-term solution. This change should be done in the message itself
				.replace( /\)|\(/g, '' )
		)
		.change( function () {
			if ( $( this ).val().length === 0 ) {
				$( this )
					.addClass( 'inline-hint' )
					.val( $( this ).data( 'hint' ) );
			} else {
				$( this ).removeClass( 'inline-hint' );
			}
		} )
		.focus( function () {
			if ( $( this ).val() == $( this ).data( 'hint' ) ) {
				$( this )
					.removeClass( 'inline-hint' )
					.val( "" );
			}
		})
		.blur( function () { $( this ).trigger( 'change' ); } )
		.trigger( 'change' );
	$( '#wpSummary' )
		.add( '.editCheckboxes' )
		.wrapAll( '<div id="editpage-summary-fields"></div>' );
		
	$( '#editpage-specialchars' ).remove();
	
	// transclusions
	// FIXME - bad CSS styling here with double class selectors. Should address here. 
	var transclusionCount = $( '.templatesUsed ul li' ).size();
	$( '.templatesUsed ul' )
		.wrap( '<div id="transclusions-list" class="collapsible-list collapsed"></div>' )
		.parent()
		.prepend( $( '<label>' )
			.text( mw.msg( 'vector-footercleanup-transclusion', transclusionCount ) ) 
		);
	$( '.mw-templatesUsedExplanation' ).remove();
	
	$( '.collapsible-list label' )
		.click( function () {
			$( this )
				.parent()
				.toggleClass( 'expanded' )
				.toggleClass( 'collapsed' )
				.find( 'ul' )
				.slideToggle( 'fast' );
			return false;
		})
		.trigger( 'click' );

	$( '#wpPreview, #wpDiff, .editHelp, #editpage-specialchars' )
		.remove();

	$( '#mw-editform-cancel' )
		.remove()
		.appendTo( '.editButtons' );
} );