Update OOjs UI to v0.16.4
[lhc/web/wiklou.git] / resources / lib / oojs-ui / oojs-ui-mediawiki.js
1 /*!
2 * OOjs UI v0.16.4
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-03-22T22:48:21Z
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 (
52 ( isFramed && ( isActive || element.isDisabled() || element.hasFlag( 'primary' ) ) )
53 ) {
54 // Button with a dark background, use white icon
55 variants.invert = true;
56 } else if ( !isFramed && element.isDisabled() ) {
57 // Frameless disabled button, always use black icon regardless of flags
58 variants.invert = false;
59 } else {
60 // Any other kind of button, use the right colored icon if available
61 variants.progressive = element.hasFlag( 'progressive' );
62 variants.constructive = element.hasFlag( 'constructive' );
63 variants.destructive = element.hasFlag( 'destructive' );
64 variants.warning = element.hasFlag( 'warning' );
65 }
66 }
67
68 for ( variant in variants ) {
69 classes[ variants[ variant ] ? 'on' : 'off' ].push( 'oo-ui-image-' + variant );
70 }
71
72 return classes;
73 };
74
75 /* Instantiation */
76
77 OO.ui.theme = new OO.ui.MediaWikiTheme();
78
79 }( OO ) );