mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-16 10:50:52 +00:00
cfd5fbbde8
More hackery! This adds some tests and ensures that our own icons are mapped to the existing template icons. Bug: T187916 Change-Id: I49073f22995c6730369235d6039939915ba2079c
45 lines
900 B
JavaScript
45 lines
900 B
JavaScript
( function ( M ) {
|
|
|
|
var Icon = M.require( 'mobile.startup/Icon' );
|
|
|
|
function getIconFromAmbox( $box ) {
|
|
var glyph,
|
|
names = [
|
|
'speedy',
|
|
'delete',
|
|
'protection',
|
|
'pov',
|
|
'move',
|
|
'style',
|
|
'content'
|
|
];
|
|
|
|
// since objects have no concept of ordering we repeat ourselves here
|
|
names.forEach( function ( name ) {
|
|
if ( !glyph && $box.hasClass( 'ambox-' + name ) ) {
|
|
// with a match, exit
|
|
glyph = name;
|
|
}
|
|
} );
|
|
|
|
glyph = glyph || 'default';
|
|
return new Icon( {
|
|
glyphPrefix: 'minerva',
|
|
name: 'issue-' + glyph
|
|
} );
|
|
}
|
|
|
|
/**
|
|
* @module skins.minerva.scripts/utils
|
|
*/
|
|
M.define( 'skins.minerva.scripts/utils', {
|
|
/**
|
|
* Extract an icon for use with the issue.
|
|
* @param {jQuery.Object} $box element to extract the icon from
|
|
* @return {Icon} representing the icon
|
|
*/
|
|
getIconFromAmbox: getIconFromAmbox
|
|
} );
|
|
|
|
}( mw.mobileFrontend ) );
|