File: ve.ui.MWSaveTool.js

package info (click to toggle)
mediawiki 1%3A1.39.13-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 320,416 kB
  • sloc: php: 815,516; javascript: 601,264; sql: 11,218; python: 4,863; xml: 3,080; sh: 990; ruby: 82; makefile: 78
file content (66 lines) | stat: -rw-r--r-- 2,108 bytes parent folder | download
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
/**
 * MediaWiki save tool
 *
 * @class
 * @abstract
 * @extends ve.ui.Tool
 * @constructor
 * @param {OO.ui.ToolGroup} toolGroup
 * @param {Object} [config] Configuration options
 */
ve.ui.MWSaveTool = function VeUiMWSaveTool() {
	// Parent constructor
	ve.ui.MWSaveTool.super.apply( this, arguments );

	// NOTE (phuedx, 2014-08-20): This class is used by the firsteditve guided
	// tour to attach a guider to the "Save page" button.
	this.$link.addClass( 've-ui-toolbar-saveButton' );

	if ( this.toolbar instanceof ve.ui.TargetToolbar ) {
		if ( ve.msg( 'accesskey-save' ) !== '-' && ve.msg( 'accesskey-save' ) !== '' ) {
			// FlaggedRevs tries to use this - it's useless on VE pages because all that stuff gets hidden, but it will still conflict so get rid of it
			this.toolbar.target.$saveAccessKeyElements = $( '[accesskey="' + ve.msg( 'accesskey-save' ) + '"]' ).removeAttr( 'accesskey' );
			this.$link.attr( 'accesskey', ve.msg( 'accesskey-save' ) );
		}

		this.setTitle( this.toolbar.target.getSaveButtonLabel( true ) );
	}
};

/* Inheritance */

OO.inheritClass( ve.ui.MWSaveTool, ve.ui.Tool );

/* Static properties */

ve.ui.MWSaveTool.static.name = 'showSave';
ve.ui.MWSaveTool.static.flags = [ 'primary', 'progressive' ];
ve.ui.MWSaveTool.static.displayBothIconAndLabel = true;
ve.ui.MWSaveTool.static.group = 'save';
ve.ui.MWSaveTool.static.commandName = 'showSave';
ve.ui.MWSaveTool.static.autoAddToCatchall = false;
ve.ui.MWSaveTool.static.autoAddToGroup = false;

/* Methods */

/**
 * @inheritdoc
 */
ve.ui.MWSaveTool.prototype.onUpdateState = function () {
	var wasSaveable = !this.isDisabled(),
		isSaveable = this.toolbar instanceof ve.ui.TargetToolbar &&
			this.toolbar.target.isSaveable();

	// This could be a ve.ui.WindowTool that becomes active
	// when the save dialog is open, but onUpdateState is
	// called without arguments in ArticleTarget for speed.

	if ( wasSaveable !== isSaveable ) {
		this.setDisabled( !isSaveable );
		mw.hook( 've.toolbarSaveButton.stateChanged' ).fire( !isSaveable );
	}
};

/* Registration */

ve.ui.toolFactory.register( ve.ui.MWSaveTool );