Demo/Liquid Rail and Rotate Rail/code.js

(function(d,h,e,a,b){var i={},c=d('');d(function(){var k="#WikiaRail{position:relative!important}#Railgun-toolbar-wrapper{bottom:27px;margin:0;padding:0;position:fixed}#Railgun-toolbar{left:342px;margin:0;padding:0;position:relative;width:25px}#Railgun-toolbar .Railgun-toolbar-button{cursor:pointer;display:inline-block;float:none;height:25px;margin:0;padding:0;width:25px}";var j='<style id="Railgun-stylesheet">'+k+"</style>";d(document.head).append(j)});function f(q,p,o,k,m,l){var j='<img id="'+q+'" class="Railgun-toolbar-button" src="'+p+'" title="'+o+'" width="25" height="25" />',n=d(j);if(l){n.attr("style",l)}if(m!==b&&m!==null){n.on("click",m,k)}else{n.on("click",k)}c.append(n);return n}(function(k){function l(p){var m,r,o,q,n;p.stopPropagation();m=k("#WikiaRail .module");if(m.length<2){return}j(false);r=m.first();o=m.last();q=200;if(p.data===-1){n=r.attr("style");r.hide("drop",{direction:"up"},q,function(){if(n){r.attr("style",n)}else{r.removeAttr("style")}o.after(r);j(true)})}else{n=o.attr("style");r.before(o);o.show("drop",{direction:"up"},q,function(){if(n){o.attr("style",n)}else{o.removeAttr("style")}j(true)})}}function j(m){if(m){k("#Railgun-toolbar-rotate-up").on("click",-1,l);k("#Railgun-toolbar-rotate-down").on("click",l)}else{k("#Railgun-toolbar-rotate-up, #Railgun-toolbar-rotate-down").off("click")}}f("Railgun-toolbar-rotate-up","http://images3.wikia.nocookie.net/mathmagician/images/0/06/RotateUp.png","Rotate Up: shifts all modules on the siderail up by one, the top module goes around to the bottom",l,-1);f("Railgun-toolbar-rotate-down","http://images1.wikia.nocookie.net/mathmagician/images/f/fa/RotateDown.png","Rotate Down: pushes all siderail modules down by one, the bottom module goes around to the top",l)}(d));(function(k){function j(r){var s=e.scrollY,n=k("#WikiaRail"),m=k("#WikiaMainContent").position().top,q=m+53,p=n.height(),o=k("#WikiaFooter").position().top;if(s<=q){n.css("top",0)}else{if(s>=o-p){n.css("top",((o-p-m)+"px"))}else{n.css("top",((s-q)+"px"))}}}function l(n){n.stopPropagation();var o,m;if(n.data===-1){k(e).on("scroll",j);k("#Railgun-toolbar-liquid-on").css("display","none");k("#Railgun-toolbar-liquid-off").removeAttr("style");o=e.scrollY;if(o>0){m=o-1}else{m=1}e.scrollTo(0,m);e.scrollTo(0,o)}else{k(e).off("scroll",j);k("#Railgun-toolbar-liquid-on").removeAttr("style");k("#Railgun-toolbar-liquid-off").css("display","none")}}f("Railgun-toolbar-liquid-on","http://images1.wikia.nocookie.net/mathmagician/images/b/b3/LiquidOn.png","Liquid Rail On: makes the siderail scroll with the window",l,-1,"display: none");f("Railgun-toolbar-liquid-off","http://images2.wikia.nocookie.net/mathmagician/images/7/76/LiquidOff.png","Liquid Rail Off: reverts the siderail to its default static state",l);k(e).off("scroll",j)}(d));function g(){d("#WikiaRail").append(d('').append(c))}i.Module=function(){};d(g);e.Railgun=i}(jQuery,mediaWiki,window,window.Railgun));