Merge "Revert "Do not double load gallery styles now cache has expired""
[lhc/web/wiklou.git] / resources / ResourcesOOUI.php
1 <?php
2 /**
3 * Definition of OOjs UI ResourceLoader modules.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 */
22
23 if ( !defined( 'MEDIAWIKI' ) ) {
24 die( 'Not an entry point.' );
25 }
26
27 // WARNING: OOjs-UI is NOT TESTED with older browsers and is likely to break
28 // if loaded in browsers that don't support ES5
29 return call_user_func( function () {
30 $themes = ExtensionRegistry::getInstance()->getAttribute( 'SkinOOUIThemes' );
31 // We only use the theme names for file names, and they are lowercase
32 $themes = array_map( 'strtolower', $themes );
33 $themes['default'] = 'mediawiki';
34
35 $modules = array();
36 $modules['oojs-ui'] = array(
37 'scripts' => array(
38 'resources/lib/oojs-ui/oojs-ui.js',
39 ),
40 'skinScripts' => array_combine(
41 array_keys( $themes ),
42 array_map( function ( $theme ) {
43 // TODO Allow extensions to specify this path somehow
44 return "resources/lib/oojs-ui/oojs-ui-$theme.js";
45 }, array_values( $themes ) )
46 ),
47 'dependencies' => array(
48 'es5-shim',
49 'oojs',
50 'oojs-ui.styles',
51 'oojs-ui.styles.icons',
52 'oojs-ui.styles.indicators',
53 'oojs-ui.styles.textures',
54 ),
55 'messages' => array(
56 'ooui-dialog-message-accept',
57 'ooui-dialog-message-reject',
58 'ooui-dialog-process-continue',
59 'ooui-dialog-process-dismiss',
60 'ooui-dialog-process-error',
61 'ooui-dialog-process-retry',
62 'ooui-outline-control-move-down',
63 'ooui-outline-control-move-up',
64 'ooui-outline-control-remove',
65 'ooui-selectfile-button-select',
66 'ooui-selectfile-dragdrop-placeholder',
67 'ooui-selectfile-not-supported',
68 'ooui-selectfile-placeholder',
69 'ooui-toolbar-more',
70 'ooui-toolgroup-collapse',
71 'ooui-toolgroup-expand',
72 ),
73 'targets' => array( 'desktop', 'mobile' ),
74 );
75 $modules['oojs-ui.styles'] = array(
76 'position' => 'top',
77 'styles' => 'resources/src/oojs-ui-local.css', // HACK, see inside the file
78 'skinStyles' => array_combine(
79 array_keys( $themes ),
80 array_map( function ( $theme ) {
81 // TODO Allow extensions to specify this path somehow
82 return "resources/lib/oojs-ui/oojs-ui-$theme-noimages.css";
83 }, array_values( $themes ) )
84 ),
85 'targets' => array( 'desktop', 'mobile' ),
86 );
87
88 $imageSets = array(
89 // Comments for greppability
90 'icons', // oojs-ui.styles.icons
91 'indicators', // oojs-ui.styles.indicators
92 'textures', // oojs-ui.styles.textures
93 'icons-accessibility', // oojs-ui.styles.icons-accessibility
94 'icons-alerts', // oojs-ui.styles.icons-alerts
95 'icons-content', // oojs-ui.styles.icons-content
96 'icons-editing-advanced', // oojs-ui.styles.icons-editing-advanced
97 'icons-editing-core', // oojs-ui.styles.icons-editing-core
98 'icons-editing-list', // oojs-ui.styles.icons-editing-list
99 'icons-editing-styling', // oojs-ui.styles.icons-editing-styling
100 'icons-interactions', // oojs-ui.styles.icons-interactions
101 'icons-layout', // oojs-ui.styles.icons-layout
102 'icons-location', // oojs-ui.styles.icons-location
103 'icons-media', // oojs-ui.styles.icons-media
104 'icons-moderation', // oojs-ui.styles.icons-moderation
105 'icons-movement', // oojs-ui.styles.icons-movement
106 'icons-user', // oojs-ui.styles.icons-user
107 'icons-wikimedia', // oojs-ui.styles.icons-wikimedia
108 );
109 $rootPath = 'resources/lib/oojs-ui/themes';
110
111 foreach ( $imageSets as $name ) {
112 $module = array(
113 'position' => 'top',
114 'class' => 'ResourceLoaderOOUIImageModule',
115 'name' => $name,
116 'rootPath' => $rootPath,
117 );
118
119 if ( substr( $name, 0, 5 ) === 'icons' ) {
120 $module['selectorWithoutVariant'] = '.oo-ui-icon-{name}, .mw-ui-icon-{name}:before';
121 $module['selectorWithVariant'] = '
122 .oo-ui-image-{variant}.oo-ui-icon-{name}, .mw-ui-icon-{name}-{variant}:before,
123 /* Hack for Flow, see T110051 */
124 .mw-ui-hovericon:hover .mw-ui-icon-{name}-{variant}-hover:before,
125 .mw-ui-hovericon.mw-ui-icon-{name}-{variant}-hover:hover:before';
126 }
127
128 $modules["oojs-ui.styles.$name"] = $module;
129 }
130
131 return $modules;
132 } );