User:MateyY/Module.js

/* A module constructor plugin * Relies on jQuery * Version 1.0 * By MateyY * Please import */ (function($) {    $.fn.railModule = function(settings) {          var $rail = $("#WikiaRail");          if (!settings) settings = {}; //Evade errors          if (!settings.position) settings.position = 0;          else if (settings.position < 0) settings.position = $rail.find(".module").length + 1 + settings.position; //Negative values          var $module = $rail.find(".module:eq(" + settings.position + ")"),              $new = this.addClass("module");          $rail.find(".module").length <= settings.position ? $new.insertAfter($rail.find(".module:last")) : $new.insertBefore($module);          return this;     }; })(jQuery);