/* You need to add 2 ULs with list items and all the rest will be handled by plugin code */
(function () {
$.fn.Movify = function (options) {
return this.each(function () {
var settings = $.extend({
mainClass: "movify",
box1Class: "box1",
box2Class: "box2"
}, options);
var el = $(this);
var box1 = el.find("div:nth-child(1)");
var box2 = el.find("div:nth-child(2)");
var mover = $('<div class="movebutton alignleft"><input class="button mover" value=">>" type="button" /></div>');
var upDown = $('<div class="alignleft"><input class="button" id="move-up" type="button" value="Up" /><input class="button" id="move-down"type="button" value="Down" /></div>');
var nonDelButton = $('<span class="unmoved alignright">DELETE</span>');
var delButton = '<span class="delete alignright">DELETE</span>';
var delClass = el.find('.delete');
var moveUpDown = box2.addClass('moveUpDown');
commonFunctions();
function commonFunctions() {
// main object class
el.addClass(settings.mainClass);
// box1, box2 class addition
box1.addClass(settings.box1Class);
box2.addClass(settings.box2Class);
// events, buttons appending to object
mover.insertAfter(box1);
upDown.insertAfter(box2);
// active item onclick
el.find('li').click(function () {
$(this).addClass('active').siblings().removeClass('active');
});
commonEvents();
}
function commonEvents() {
var iBox2 = el.find('.box2 li');
iBox2.prepend(nonDelButton);
moveTrigger();
reverseMoved();
removeBox2Item();
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.