mediawiki-skins-MinervaNeue/resources/skins.minerva.scripts/utils.js
jdlrobson cfd5fbbde8 Add icons for all the types of issues
More hackery!
This adds some tests and ensures that our own icons are mapped to the
existing template icons.

Bug: T187916
Change-Id: I49073f22995c6730369235d6039939915ba2079c
2018-03-15 15:02:05 -07:00

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 ) );