MediaWiki:Gadget-oswf-core.js

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.
 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);