User:Ricordisamoa/emoticons/SMirC.js

From Meta, a Wikimedia project coordination wiki

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* <nowiki>
 * Set of smilies from the SMirC set
 * [[commons:Category:SMirC smilies]]
*/
/* global mw, $ */
$( function () {
	'use strict';

	var emotigroup, prefix,
		$text = $( '#wpTextbox1' );

	if ( $text.length === 0 ) {
		return;
	}
	$text.wikiEditor( 'addToToolbar', {
		section: 'emoticons',
		groups: {
			'smilies-SMirC': {
				label: 'SMirC'
			}
		}
	} );
	emotigroup = {
		section: 'emoticons',
		group: 'smilies-SMirC',
		tools: {}
	};
	prefix = 'SMirC-';
	$.each( [ 'alien', 'angel', 'beam', 'beware', 'coffeebreak', 'congrats', 'cool', 'cry', 'dead', 'devil', 'doh', 'dunno', 'facepalm',
	'freezing', 'goggle', 'grin', 'hi', 'hot', 'laugh', 'love', 'martial', 'medium', 'puke', 'puppyeyes', 'rolleyes', 'sad', 'shy',
	'silent', 'smile', 'spent', 'stoned', 'thumbsdown', 'thumbsup', 'tongue', 'vamp', 'what', 'wink', 'wtf', 'xmas', 'zzz' ], function ( i, emoticon ) {
		var ucFirst = emoticon.charAt( 0 ).toUpperCase() + emoticon.slice( 1 );
		emotigroup.tools[ ucFirst ] = {
			label: ucFirst,
			type: 'button',
			icon: '//commons.wikimedia.org/wiki/Special:Filepath/' + prefix + mw.util.wikiUrlencode( emoticon ) + '.svg?width=20',
			action: {
				type: 'encapsulate',
				options: {
					pre: '[[File:' + prefix + emoticon + '.svg|20px]]',
					post: ''
				}
			}
		};
	} );
	$text.wikiEditor( 'addToToolbar', emotigroup );
} );