Merge "Make IndexPager query direction code more readable"
[lhc/web/wiklou.git] / resources / lib / ooui / oojs-ui-wikimediaui.js
1 /*!
2 * OOUI v0.30.4
3 * https://www.mediawiki.org/wiki/OOUI
4 *
5 * Copyright 2011–2019 OOUI Team and other contributors.
6 * Released under the MIT license
7 * http://oojs.mit-license.org
8 *
9 * Date: 2019-03-07T09:14:18Z
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, isToolOrGroup,
38 variants = {
39 invert: false,
40 progressive: false,
41 destructive: false,
42 error: false,
43 warning: false
44 },
45 // Parent method
46 classes = OO.ui.WikimediaUITheme.parent.prototype.getElementClasses.call( this, element );
47
48 if (
49 element instanceof OO.ui.IconWidget &&
50 element.$element.hasClass( 'oo-ui-checkboxInputWidget-checkIcon' )
51 ) {
52 // Icon on CheckboxInputWidget
53 variants.invert = true;
54 } else if ( element.supports( [ 'hasFlag' ] ) ) {
55 isFramed = element.supports( [ 'isFramed' ] ) && element.isFramed();
56 isActive = element.supports( [ 'isActive' ] ) && element.isActive();
57 isToolOrGroup =
58 // Check if the class exists, as classes that are not in the 'core' module may
59 // not be loaded.
60 ( OO.ui.Tool && element instanceof OO.ui.Tool ) ||
61 ( OO.ui.ToolGroup && element instanceof OO.ui.ToolGroup );
62 if (
63 // Button with a dark background.
64 isFramed && ( isActive || element.isDisabled() || element.hasFlag( 'primary' ) ) ||
65 // Toolbar with a dark background.
66 isToolOrGroup && element.hasFlag( 'primary' )
67 ) {
68 // … use white icon / indicator, regardless of other flags
69 variants.invert = true;
70 } else if ( !isFramed && element.isDisabled() ) {
71 // Frameless disabled button, always use black icon / indicator regardless of
72 // other flags.
73 variants.invert = false;
74 } else if ( !element.isDisabled() ) {
75 // Any other kind of button, use the right colored icon / indicator if available.
76 variants.progressive = element.hasFlag( 'progressive' ) ||
77 // Active tools/toolgroups
78 ( isToolOrGroup && isActive ) ||
79 // Pressed or selected outline/menu option widgets
80 (
81 (
82 element instanceof OO.ui.MenuOptionWidget ||
83 // Check if the class exists, as classes that are not in the 'core' module
84 // may not be loaded.
85 (
86 OO.ui.OutlineOptionWidget &&
87 element instanceof OO.ui.OutlineOptionWidget
88 )
89 ) &&
90 ( element.isPressed() || element.isSelected() )
91 );
92
93 variants.destructive = element.hasFlag( 'destructive' );
94 variants.error = element.hasFlag( 'error' );
95 variants.warning = element.hasFlag( 'warning' );
96 }
97 }
98
99 for ( variant in variants ) {
100 classes[ variants[ variant ] ? 'on' : 'off' ].push( 'oo-ui-image-' + variant );
101 }
102
103 return classes;
104 };
105
106 /**
107 * @inheritdoc
108 */
109 OO.ui.WikimediaUITheme.prototype.getDialogTransitionDuration = function () {
110 return 250;
111 };
112
113 /* Instantiation */
114
115 OO.ui.theme = new OO.ui.WikimediaUITheme();
116
117 }( OO ) );
118
119 //# sourceMappingURL=oojs-ui-wikimediaui.js.map.json