Merge "Warn if stateful ParserOutput transforms are used"
[lhc/web/wiklou.git] / resources / lib / oojs-ui / oojs-ui-wikimediaui.js
1 /*!
2 * OOUI v0.25.1
3 * https://www.mediawiki.org/wiki/OOUI
4 *
5 * Copyright 2011–2018 OOUI Team and other contributors.
6 * Released under the MIT license
7 * http://oojs.mit-license.org
8 *
9 * Date: 2018-01-17T01:47:15Z
10 */
11 ( function ( OO ) {
12
13 'use strict';
14
15 /**
16 * @class
17 * @extends OO.ui.Theme
18 *
19 * @constructor
20 */
21 OO.ui.WikimediaUITheme = function OoUiWikimediaUITheme() {
22 // Parent constructor
23 OO.ui.WikimediaUITheme.parent.call( this );
24 };
25
26 /* Setup */
27
28 OO.inheritClass( OO.ui.WikimediaUITheme, OO.ui.Theme );
29
30 /* Methods */
31
32 /**
33 * @inheritdoc
34 */
35 OO.ui.WikimediaUITheme.prototype.getElementClasses = function ( element ) {
36 // Parent method
37 var variant, isFramed, isActive,
38 variants = {
39 warning: false,
40 invert: false,
41 progressive: false,
42 destructive: false
43 },
44 // Parent method
45 classes = OO.ui.WikimediaUITheme.parent.prototype.getElementClasses.call( this, element );
46
47 if ( element.supports( [ 'hasFlag' ] ) ) {
48 isFramed = element.supports( [ 'isFramed' ] ) && element.isFramed();
49 isActive = element.supports( [ 'isActive' ] ) && element.isActive();
50 if (
51 // Button with a dark background
52 isFramed && ( isActive || element.isDisabled() || element.hasFlag( 'primary' ) ) ||
53 // Toolbar with a dark background
54 OO.ui.ToolGroup && element instanceof OO.ui.ToolGroup && ( isActive || element.hasFlag( 'primary' ) )
55 ) {
56 // … use white icon / indicator, regardless of other flags
57 variants.invert = true;
58 } else if ( !isFramed && element.isDisabled() ) {
59 // Frameless disabled button, always use black icon / indicator regardless of other flags
60 variants.invert = false;
61 } else if ( !element.isDisabled() ) {
62 // Any other kind of button, use the right colored icon / indicator if available
63 variants.progressive = element.hasFlag( 'progressive' );
64 variants.destructive = element.hasFlag( 'destructive' );
65 variants.warning = element.hasFlag( 'warning' );
66 }
67 }
68
69 for ( variant in variants ) {
70 classes[ variants[ variant ] ? 'on' : 'off' ].push( 'oo-ui-image-' + variant );
71 }
72
73 return classes;
74 };
75
76 /**
77 * @inheritdoc
78 */
79 OO.ui.WikimediaUITheme.prototype.getDialogTransitionDuration = function () {
80 return 250;
81 };
82
83 /* Instantiation */
84
85 OO.ui.theme = new OO.ui.WikimediaUITheme();
86
87 }( OO ) );
88
89 //# sourceMappingURL=oojs-ui-wikimediaui.js.map