mediawiki-skins-MinervaNeue/resources/skins.minerva.scripts/utils.js

45 lines
900 B
JavaScript
Raw Normal View History

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