Update OOjs UI to v0.6.0
[lhc/web/wiklou.git] / resources / lib / oojs-ui / oojs-ui-mediawiki.js
1 /*!
2 * OOjs UI v0.6.0
3 * https://www.mediawiki.org/wiki/OOjs_UI
4 *
5 * Copyright 2011–2014 OOjs Team and other contributors.
6 * Released under the MIT license
7 * http://oojs.mit-license.org
8 *
9 * Date: 2014-12-16T21:00:55Z
10 */
11 /**
12 * @class
13 * @extends OO.ui.Theme
14 *
15 * @constructor
16 */
17 OO.ui.MediaWikiTheme = function OoUiMediaWikiTheme() {
18 // Parent constructor
19 OO.ui.MediaWikiTheme.super.call( this );
20 };
21
22 /* Setup */
23
24 OO.inheritClass( OO.ui.MediaWikiTheme, OO.ui.Theme );
25
26 /* Methods */
27
28 /**
29 * @inheritdoc
30 */
31 OO.ui.MediaWikiTheme.prototype.getElementClasses = function ( element ) {
32 // Parent method
33 var variant,
34 variants = {
35 invert: false,
36 progressive: false,
37 constructive: false,
38 destructive: false
39 },
40 // Parent method
41 classes = OO.ui.MediaWikiTheme.super.prototype.getElementClasses.call( this, element );
42
43 if ( element.supports( [ 'isFramed', 'isDisabled', 'hasFlag' ] ) ) {
44 if ( !element.isDisabled() && element.isFramed() && element.hasFlag( 'primary' ) ) {
45 variants.invert = true;
46 } else {
47 variants.progressive = element.hasFlag( 'progressive' );
48 variants.constructive = element.hasFlag( 'constructive' );
49 variants.destructive = element.hasFlag( 'destructive' );
50 }
51 }
52
53 for ( variant in variants ) {
54 classes[variants[variant] ? 'on' : 'off'].push( 'oo-ui-image-' + variant );
55 }
56
57 return classes;
58 };
59
60 /* Instantiation */
61
62 OO.ui.theme = new OO.ui.MediaWikiTheme();