Merge "Revert "Use display name in category page subheadings if provided""
[lhc/web/wiklou.git] / resources / lib / oojs-ui / oojs-ui-mediawiki.js
1 /*!
2 * OOjs UI v0.17.10
3 * https://www.mediawiki.org/wiki/OOjs_UI
4 *
5 * Copyright 2011–2016 OOjs UI Team and other contributors.
6 * Released under the MIT license
7 * http://oojs.mit-license.org
8 *
9 * Date: 2016-10-03T18:59:01Z
10 */
11 ( function ( OO ) {
12
13 'use strict';
14
15 /**
16 * @class
17 * @extends OO.ui.Theme
18 *
19 * @constructor
20 */
21 OO.ui.MediaWikiTheme = function OoUiMediaWikiTheme() {
22 // Parent constructor
23 OO.ui.MediaWikiTheme.parent.call( this );
24 };
25
26 /* Setup */
27
28 OO.inheritClass( OO.ui.MediaWikiTheme, OO.ui.Theme );
29
30 /* Methods */
31
32 /**
33 * @inheritdoc
34 */
35 OO.ui.MediaWikiTheme.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.MediaWikiTheme.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 ( isFramed && ( isActive || element.isDisabled() || element.hasFlag( 'primary' ) ) ) {
52 // Button with a dark background, use white icon
53 variants.invert = true;
54 } else if ( !isFramed && element.isDisabled() ) {
55 // Frameless disabled button, always use black icon regardless of flags
56 variants.invert = false;
57 } else if ( !element.isDisabled() ) {
58 // Any other kind of button, use the right colored icon if available
59 variants.progressive = element.hasFlag( 'progressive' );
60 variants.constructive = element.hasFlag( 'constructive' );
61 variants.destructive = element.hasFlag( 'destructive' );
62 variants.warning = element.hasFlag( 'warning' );
63 }
64 }
65
66 for ( variant in variants ) {
67 classes[ variants[ variant ] ? 'on' : 'off' ].push( 'oo-ui-image-' + variant );
68 }
69
70 return classes;
71 };
72
73 /**
74 * @inheritdoc
75 */
76 OO.ui.MediaWikiTheme.prototype.getDialogTransitionDuration = function () {
77 return 250;
78 };
79
80 /* Instantiation */
81
82 OO.ui.theme = new OO.ui.MediaWikiTheme();
83
84 }( OO ) );