Difference between revisions of "MediaWiki:Common.js"

From The Grove - Academia de Idiomas
Jump to: navigation, search
 
(23 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
/* Any JavaScript here will be loaded for all users on every page load. */
 
/* Any JavaScript here will be loaded for all users on every page load. */
  
function ModifySidebar( action, section, name, link ) {
+
(function() {
try {
+
 
switch ( section ) {
+
$('.acc div').addClass('hide');
case 'languages':
+
 
var target = 'p-lang';
+
$('div.acc').on('click', 'h2', function() {
break;
+
$(this)
case 'toolbox':
+
.next()
var target = 'p-tb';
+
.slideToggle(200)
break;
+
});
case 'navigation':
+
})();
var target = 'p-navigation';
+
 
break;
+
 
default:
+
$(function () {
var target = 'p-' + section;
+
        $("[rel='tooltip']").tooltip();
break;
+
});
}
+
 
+
(function() {
if ( action == 'add' ) {
+
 
var node = document.getElementById( target )
+
        $( "div.tier2 > ol" ).attr( "start", "11" );
  .getElementsByTagName( 'div' )[0]
+
        $( "div.tier3 > ol" ).attr( "start", "21" );
  .getElementsByTagName( 'ul' )[0];
+
        $( "div.tier4 > ol" ).attr( "start", "31" );
+
        $( "div.tier5 > ol" ).attr( "start", "41" );
var aNode = document.createElement( 'a' );
+
        $( "div.tier6 > ol" ).attr( "start", "51" );
var liNode = document.createElement( 'li' );
+
        $( "div.tier7 > ol" ).attr( "start", "61" );
+
        $( "div.tier8 > ol" ).attr( "start", "71" );
aNode.appendChild( document.createTextNode( name ) );
+
        $( "div.tier9 > ol" ).attr( "start", "81" );
aNode.setAttribute( 'href', link );
+
        $( "div.tier10 > ol" ).attr( "start", "91" );
liNode.appendChild( aNode );
+
 
liNode.className = 'plainlinks';
+
})();
node.appendChild( liNode );
+
 
}
+
$(document).ready(function() {
+
  $(".exercise-link").on(function() {
if ( action == 'remove' ) {
+
    var exerciseLink = $(this).find("a");
var list = document.getElementById( target )
+
 
  .getElementsByTagName( 'div' )[0]
+
    exerciseLink.attr("target", "_blank");
  .getElementsByTagName( 'ul' )[0];
+
    window.open(exerciseLink.attr("href"));
+
 
var listelements = list.getElementsByTagName( 'li' );
+
    return false;
+
  });
for ( var i = 0; i < listelements.length; i++ ) {
+
});
if (
 
listelements[i].getElementsByTagName( 'a' )[0].innerHTML == name ||
 
listelements[i].getElementsByTagName( 'a' )[0].href == link
 
)
 
{
 
list.removeChild( listelements[i] );
 
}
 
}
 
}
 
 
} catch( e ) {
 
// let's just ignore what's happened
 
return;
 
}
 
}
 
 
function CustomizeModificationsOfSidebar() {
 
// adds [[Special:CategoryTree]] to toolbox
 
ModifySidebar( 'add', 'courses', 'Essentials', 'http://thegrove.com.br/metodo/index.php?title=Lesson:Essentials' );
 
// removes [[Special:Upload]] from toolbox
 
ModifySidebar( 'remove', 'toolbox', 'Upload file', 'http://thegrove.com.br/metodo/index.php?title=Special:Upload' );
 
}
 
 
addOnloadHook( CustomizeModificationsOfSidebar );
 

Latest revision as of 11:37, 27 September 2014

/* Any JavaScript here will be loaded for all users on every page load. */

(function() {

	$('.acc div').addClass('hide');

	$('div.acc').on('click', 'h2', function() {
		$(this)
			.next()
				.slideToggle(200)
	});
})();


$(function () {
        $("[rel='tooltip']").tooltip();
});

(function() {

        $( "div.tier2 > ol" ).attr( "start", "11" );
        $( "div.tier3 > ol" ).attr( "start", "21" );
        $( "div.tier4 > ol" ).attr( "start", "31" );
        $( "div.tier5 > ol" ).attr( "start", "41" );
        $( "div.tier6 > ol" ).attr( "start", "51" );
        $( "div.tier7 > ol" ).attr( "start", "61" );
        $( "div.tier8 > ol" ).attr( "start", "71" );
        $( "div.tier9 > ol" ).attr( "start", "81" );
        $( "div.tier10 > ol" ).attr( "start", "91" );

})();

$(document).ready(function() {
  $(".exercise-link").on(function() {
    var exerciseLink = $(this).find("a");

    exerciseLink.attr("target", "_blank");
    window.open(exerciseLink.attr("href"));

    return false;
  });
});