User:Amit6/sandbox14.js
Appearance
(Redirected from User:Myrecovery/sandbox14.js)
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
This user script seems to have a documentation page at User:Amit6/sandbox14. |
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js" ></script>
<script type="text/javascript">
$(document).ready(function(){
//Store Image paths
var toggleMinus = 'path/to/minus/image';
var togglePlus = 'path/to/plus/image';
var $subHead = $('.children').parent();
//Add the Plus image to every child by default
$subHead.prepend('<img src="' + togglePlus + '" alt="collapse this section" /> ');
//By Default put the Menu in collapsed state
$('.children').parent().children('ul').slideUp('fast');
//Expand All Code
$('.expand').click(function() {
$subHead.children('ul').slideDown('fast');
$('img', $subHead).attr('src', toggleMinus);
});
//Contract All Code
$('.contract').click(function() {
$subHead.attr('src', toggleMinus).children('ul').slideUp('fast');
$('img', $subHead).attr('src', togglePlus);
});
//Expand or Contract one particular Nested ul
$('img', $subHead).addClass('clickable').click(function() {
var toggleSrc = $(this).attr('src');
if ( toggleSrc == toggleMinus ) {
$(this).attr('src', togglePlus).parent().children('ul').slideUp('fast');
} else{
$(this).attr('src', toggleMinus).parent().children('ul').slideDown('fast');
};
});
});
</script>