User:Erutuon/scripts/semhide.js

Hello, you have come here looking for the meaning of the word User:Erutuon/scripts/semhide.js. In DICTIOUS you will not only get to know all the dictionary meanings for the word User:Erutuon/scripts/semhide.js, but we will also tell you about its etymology, its characteristics and you will know how to say User:Erutuon/scripts/semhide.js in singular and plural. Everything you need to know about the word User:Erutuon/scripts/semhide.js you have here. The definition of the word User:Erutuon/scripts/semhide.js will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofUser:Erutuon/scripts/semhide.js, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
// based on ] and ]

/* globals $ */

(function () {
'use strict';

function setupNyms(index, dlTag) {
	// ]
	var relationClasses = [ 'synonym', 'antonym', 'hypernym', 'hyponym', 'meronym',
							'holonym', 'troponym', 'coordinate-term' ];
	
	var relations = $(dlTag).find('dd > .nyms').get().filter(
		function(element) {
			return Array.prototype.some.call(element.classList, function (className) {
				if (relationClasses.indexOf(className) !== -1) {
					$(element).data('relationClass', className);
					return true;
				}
			});
		});
	
	function setupToggle(elements, category, visibleByDefault) {
		if (elements.length === 0) return null;
		var toggler = $('<a>');
		var text = elements.map(function (e) {
			return $(e).data('relationClass').replace('-', ' ') +
				 (($(e).find('a').length > 1) ? 's' : '');
		}).join(', ');
		
		function show() {
			toggler.html(text + '&nbsp;▲');
			$(dlTag).show();
			$(elements).show();
		}
		function hide() {
			toggler.html(text + '&nbsp;▼');
			if ($(dlTag).children().length === elements.length) {
				$(dlTag).hide();
			} else {
				$(elements).hide();
			}
		}
	
		$(dlTag).before($('<span>')
		   .addClass('HQToggle')
		   .append(toggler)
		   .css('margin-left', '5px'));
		   
		toggler.click(window.VisibilityToggles.register(category, show, hide, visibleByDefault));
	}
	
	var synonyms = relations.filter(function (e) {
		return .indexOf($(e).data('relationClass')) !== -1;
	});
	var other = relations.filter(function (e) { return synonyms.indexOf(e) === -1; });
   
	setupToggle(synonyms, 'synonyms', true /* show by default */);
	setupToggle(other, 'semantic relations');
}

$(function() {
	// if (mw.config.get('wgNamespaceNumber') === 0) {
		$('dl:has(dd > .nyms)').each(setupNyms);
	// }
});

})();