Merge "Fix and make some types in PHPDoc and JSDoc tags more specific"
[lhc/web/wiklou.git] / resources / lib / oojs-ui / oojs-ui-wikimediaui.js
1 /*!
2 * OOjs UI v0.22.4
3 * https://www.mediawiki.org/wiki/OOjs_UI
4 *
5 * Copyright 2011–2017 OOjs UI Team and other contributors.
6 * Released under the MIT license
7 * http://oojs.mit-license.org
8 *
9 * Date: 2017-08-03T19:36:51Z
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 constructive: false,
43 destructive: false
44 },
45 // Parent method
46 classes = OO.ui.WikimediaUITheme.parent.prototype.getElementClasses.call( this, element );
47
48 if ( element.supports( [ 'hasFlag' ] ) ) {
49 isFramed = element.supports( [ 'isFramed' ] ) && element.isFramed();
50 isActive = element.supports( [ 'isActive' ] ) && element.isActive();
51 if (
52 // Button with a dark background
53 isFramed && ( isActive || element.isDisabled() || element.hasFlag( 'primary' ) ) ||
54 // Toolbar with a dark background
55 OO.ui.ToolGroup && element instanceof OO.ui.ToolGroup && ( isActive || element.hasFlag( 'primary' ) )
56 ) {
57 // … use white icon / indicator, regardless of other flags
58 variants.invert = true;
59 } else if ( !isFramed && element.isDisabled() ) {
60 // Frameless disabled button, always use black icon / indicator regardless of other flags
61 variants.invert = false;
62 } else if ( !element.isDisabled() ) {
63 // Any other kind of button, use the right colored icon / indicator if available
64 variants.progressive = element.hasFlag( 'progressive' );
65 variants.constructive = element.hasFlag( 'constructive' );
66 variants.destructive = element.hasFlag( 'destructive' );
67 variants.warning = element.hasFlag( 'warning' );
68 }
69 }
70
71 for ( variant in variants ) {
72 classes[ variants[ variant ] ? 'on' : 'off' ].push( 'oo-ui-image-' + variant );
73 }
74
75 return classes;
76 };
77
78 /**
79 * @inheritdoc
80 */
81 OO.ui.WikimediaUITheme.prototype.getDialogTransitionDuration = function () {
82 return 250;
83 };
84
85 /* Instantiation */
86
87 OO.ui.theme = new OO.ui.WikimediaUITheme();
88
89 }( OO ) );
90
91 //# sourceMappingURL=oojs-ui-wikimediaui.js.map