MediaWiki:TabViewEditLinks/code.js

// __NOWYSIWYG__ /** * TabViewEditLinks * * @version 2.0 * * @author ©TriMoon™  * * Version 1 authors: * - Comunity discussion  * - Pera Pisar  * - ©TriMoon™  * * documentation and examples at: (not yet) *  */

/*jshint jquery:true, browser:true, devel:true, camelcase:true, curly:false, undef:true, bitwise:true, eqeqeq:true, forin:true, immed:true, latedef:true, newcap:true, noarg:true, unused:true, regexp:true, strict:true, trailing:false */ /*global mediaWiki:true*/

'use strict';
 * (function (module, mw, $, undefined) {

function click(e) { e.preventDefault; window.location.href = $(this).data('url'); }

function doEach { let $that = $(this) ,$link = $that.find('> a').first ,$url = new mw.Uri(							$link.attr('href')						) .extend({							action: 'edit'						}) .toString;

$link.append(			$(' ', { 'class': 'editsection' ,'click': click ,'data-url': $url })			.append( $('', {					'href': $url					,'css': {						'border': 'none'						,'cursor': 'pointer'						,'padding': '0'						,'font-size': 'x-small'					}					,'title': 'Edit Tab-page'				}) .append(					$(' ', { 'class': "sprite edit-pencil" ,'src': "data:image/gif;base64,R0lGODlhAQABAIABAAAAAP///yH5BAEAAAEALAAAAAABAAEAQAICTAEAOw%3D%3D" })				)				.append('Edit') )		);	}

function init($content=mw.util.$content) { let $tabs = $content.find('[id^="flytabs_"] > ul.tabs > li[data-tab]:not(.tvel_handled)');

if (!$tabs.length) { return false; }		$tabs.each(doEach); $tabs.addClass('tvel_handled'); return true; }

module.init = init; mw.hook('wikipage.content').add(init); init; }(window.TabViewEditLinks = window.TabViewEditLinks || {}, mediaWiki, jQuery));