MediaWiki:Gadget-oswf-core.js: Difference between revisions

From Old School Near-Reality Wiki
Jump to navigation Jump to search
(Created page with "var showText = 'Get started with this task', hideText = 'Hide additional info', showTitle = 'Show the guidance for this task', hideTitle = 'Hide the guidance for this task'; function init() { $('.oswf-guidance').each(function(i,e){ var $this = $(e), $content, toggleButton, showing = false; $content = $('<div>').append($this.contents()); $content.hide(); toggleButton = new OO.ui.ButtonWidget({ icon: 'expand', title: showTitle, label: showTex...")
 
(No difference)

Latest revision as of 19:25, 3 October 2022

 1 var showText = 'Get started with this task',
 2 hideText = 'Hide additional info',
 3 showTitle = 'Show the guidance for this task',
 4 hideTitle = 'Hide the guidance for this task';
 5 
 6 function init() {
 7 	$('.oswf-guidance').each(function(i,e){
 8 		var $this = $(e),
 9 		$content,
10 		toggleButton,
11 		showing = false;
12 		
13 		$content = $('<div>').append($this.contents());
14 		$content.hide();
15 		
16 		toggleButton = new OO.ui.ButtonWidget({
17 			icon: 'expand',
18 			title: showTitle,
19 			label: showText,
20 			flags: ['primary', 'progressive']
21 		});
22 		
23 		toggleButton.on('click', function(){
24 			showing = !showing;
25 			if (showing) {
26 				toggleButton.setIcon('collapse').setTitle(hideTitle).setLabel(hideText);
27 				
28 			} else {
29 				toggleButton.setIcon('expand').setTitle(showTitle).setLabel(showText);
30 			}
31 			$content.toggle();
32 		});
33 		
34 		$this.append(toggleButton.$element).append($content);
35 	});
36 	
37 }
38 $(init);