<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://en.battlestarwiki.org/MediaWiki:Gadget-Edittools.js/history?feed=atom</id>
	<title>MediaWiki:Gadget-Edittools.js - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://en.battlestarwiki.org/MediaWiki:Gadget-Edittools.js/history?feed=atom"/>
	<link rel="alternate" type="text/html" href="https://en.battlestarwiki.org/MediaWiki:Gadget-Edittools.js/history"/>
	<updated>2026-04-06T10:32:38Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://en.battlestarwiki.org/w/index.php?title=MediaWiki:Gadget-Edittools.js&amp;diff=217347&amp;oldid=prev</id>
		<title>Joe Beaudoin Jr.: Created page with &quot;/**  * EditTools support: add a selector, change &lt;a&gt; into buttons.  * The special characters to insert are defined at MediaWiki:Edittools.  *  * @author Arnomane, 2006 (on...&quot;</title>
		<link rel="alternate" type="text/html" href="https://en.battlestarwiki.org/w/index.php?title=MediaWiki:Gadget-Edittools.js&amp;diff=217347&amp;oldid=prev"/>
		<updated>2019-08-18T06:15:31Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;/**  * EditTools support: add a selector, change &amp;lt;a&amp;gt; into buttons.  * The special characters to insert are defined at &lt;a href=&quot;/MediaWiki:Edittools&quot; title=&quot;MediaWiki:Edittools&quot;&gt;MediaWiki:Edittools&lt;/a&gt;.  *  * @author Arnomane, 2006 (on...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;/**&lt;br /&gt;
 * EditTools support: add a selector, change &amp;lt;a&amp;gt; into buttons.&lt;br /&gt;
 * The special characters to insert are defined at [[MediaWiki:Edittools]].&lt;br /&gt;
 *&lt;br /&gt;
 * @author Arnomane, 2006 (on the commons.wikimedia.org/wiki/MediaWiki:Edittools.js)&lt;br /&gt;
 * @author Kaganer, 2007 (adapting to www.mediawiki.org)&lt;br /&gt;
 * @author Krinkle, 2012&lt;br /&gt;
 * @source www.mediawiki.org/wiki/MediaWiki:Gadget-Edittools.js&lt;br /&gt;
 * @revision 2012-02-29&lt;br /&gt;
 */&lt;br /&gt;
/*jslint browser: true*/&lt;br /&gt;
/*global jQuery, mediaWiki*/&lt;br /&gt;
(function ($, mw) {&lt;br /&gt;
	&amp;quot;use strict&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
	var conf, editTools, $sections;&lt;br /&gt;
&lt;br /&gt;
	conf = {&lt;br /&gt;
		initialSubset: window.EditTools_initial_subset === undefined ? window.EditTools_initial_subset : 0&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	editTools = {&lt;br /&gt;
&lt;br /&gt;
		/**&lt;br /&gt;
		 * Creates the selector&lt;br /&gt;
		 */&lt;br /&gt;
		setup: function () {&lt;br /&gt;
			var $container, $select, initial;&lt;br /&gt;
&lt;br /&gt;
			$container = $(&amp;#039;#mw-edittools-charinsert&amp;#039;);&lt;br /&gt;
			if (!$container.length) {&lt;br /&gt;
				return;&lt;br /&gt;
			}&lt;br /&gt;
			$sections = $container.find(&amp;#039;.mw-edittools-section&amp;#039;);&lt;br /&gt;
			if ($sections.length &amp;lt;= 1) {&lt;br /&gt;
				// Only care if there is more than one&lt;br /&gt;
				return;&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			$select = $(&amp;#039;&amp;lt;select&amp;gt;&amp;#039;).css(&amp;#039;display&amp;#039;, &amp;#039;inline&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
			initial = conf.initialSubset;&lt;br /&gt;
			if (isNaN(initial) || initial &amp;lt; 0 || initial &amp;gt;= $select.length) {&lt;br /&gt;
				initial = 0;&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			$sections.each(function (i, el) {&lt;br /&gt;
				var $section, sectionTitle, $option;&lt;br /&gt;
&lt;br /&gt;
				$section = $(el);&lt;br /&gt;
				sectionTitle = $section.data(&amp;#039;sectionTitle&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
				$option = $(&amp;#039;&amp;lt;option&amp;gt;&amp;#039;)&lt;br /&gt;
					.text(sectionTitle)&lt;br /&gt;
					.prop(&amp;#039;value&amp;#039;, i)&lt;br /&gt;
					.prop(&amp;#039;selected&amp;#039;, i === initial);&lt;br /&gt;
&lt;br /&gt;
				$select.append($option);&lt;br /&gt;
			});&lt;br /&gt;
&lt;br /&gt;
			$select.change(editTools.handleOnchange);&lt;br /&gt;
			$container.prepend($select);&lt;br /&gt;
&lt;br /&gt;
			editTools.chooseSection(initial);&lt;br /&gt;
		},&lt;br /&gt;
&lt;br /&gt;
		/**&lt;br /&gt;
		 * Handle onchange event of the &amp;lt;select&amp;gt;&lt;br /&gt;
		 *&lt;br /&gt;
		 * @context {Element}&lt;br /&gt;
		 * @param e {jQuery.Event}&lt;br /&gt;
		 */&lt;br /&gt;
		handleOnchange: function () {&lt;br /&gt;
			editTools.chooseSection(Number($(this).val()));&lt;br /&gt;
&lt;br /&gt;
			return true;&lt;br /&gt;
		},&lt;br /&gt;
&lt;br /&gt;
		/**&lt;br /&gt;
		 * Toggle the currently visible section&lt;br /&gt;
		 *&lt;br /&gt;
		 * @param sectionNr {Number}&lt;br /&gt;
		 * @param setFocus {Boolean}&lt;br /&gt;
		 */&lt;br /&gt;
		chooseSection: function (sectionNr) {&lt;br /&gt;
			var $choise = $sections.eq(sectionNr);&lt;br /&gt;
			if ($choise.length !== 1) {&lt;br /&gt;
				return;&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			// Making these buttons is a little slow,&lt;br /&gt;
			// If we made them all at once the browser would hang&lt;br /&gt;
			// for over 2 seconds, so instead we&amp;#039;re doing it on-demand&lt;br /&gt;
			// for each section. No need to do it twice thoguh, so remember&lt;br /&gt;
			// in data whether it was done already&lt;br /&gt;
			if (!$choise.data(&amp;#039;charInsert.buttonsMade&amp;#039;)) {&lt;br /&gt;
				$choise.data(&amp;#039;charInsert.buttonsMade&amp;#039;, true);&lt;br /&gt;
				editTools.makeButtons($choise);&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			$choise.show();&lt;br /&gt;
			$sections.not($choise).hide();&lt;br /&gt;
		},&lt;br /&gt;
&lt;br /&gt;
		/**&lt;br /&gt;
		 * Convert the &amp;lt;a onclick&amp;gt; links to buttons in a given section.&lt;br /&gt;
		 *&lt;br /&gt;
		 * @param $section {jQuery}&lt;br /&gt;
		 */&lt;br /&gt;
		makeButtons: function ($section) {&lt;br /&gt;
			var $links;&lt;br /&gt;
&lt;br /&gt;
			if (!$section.length) {&lt;br /&gt;
				return;&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			$links = $section.find(&amp;#039;a&amp;#039;);&lt;br /&gt;
			$links.each(function (i, a) {&lt;br /&gt;
				var $a, $button, start, end;&lt;br /&gt;
				$a = $(a);&lt;br /&gt;
				$button = $( &amp;#039;&amp;lt;input&amp;gt;&amp;#039; ).attr( &amp;#039;type&amp;#039;, &amp;#039;button&amp;#039; );&lt;br /&gt;
				start = $a.data( &amp;#039;mw-charinsert-start&amp;#039; );&lt;br /&gt;
				end = $a.data( &amp;#039;mw-charinsert-end&amp;#039; );&lt;br /&gt;
				if ( start !== undefined &amp;amp;&amp;amp; end !== undefined ) {&lt;br /&gt;
					$button.click( function( e ) {&lt;br /&gt;
						e.preventDefault();&lt;br /&gt;
						$(&amp;#039;#wpTextbox1&amp;#039;).textSelection(&amp;#039;encapsulateSelection&amp;#039;, {pre: start, post: end});&lt;br /&gt;
					} );&lt;br /&gt;
				} else {&lt;br /&gt;
					$button[0].onclick = a.onclick;&lt;br /&gt;
                                }&lt;br /&gt;
				$button[0].value = $a.text();&lt;br /&gt;
				$a.replaceWith($button);&lt;br /&gt;
			});&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	$(document).ready(editTools.setup);&lt;br /&gt;
&lt;br /&gt;
}(jQuery, mediaWiki));&lt;/div&gt;</summary>
		<author><name>Joe Beaudoin Jr.</name></author>
	</entry>
</feed>