diff --git a/js/jquery.MoverBoxes.js b/js/jquery.MoverBoxes.js index 0e31993..2c257a9 100644 --- a/js/jquery.MoverBoxes.js +++ b/js/jquery.MoverBoxes.js @@ -79,6 +79,24 @@ tableTDTwo.appendChild(inputTwo); tableTR.appendChild(tableTDTwo); + + brAllOne = document.createElement("br"); + tableTDTwo.appendChild(brAllOne); + var inputTwoAll = document.createElement("input"); + $(inputTwoAll).attr("type", "button"); + $(inputTwoAll).attr("value", "<<"); + $(inputTwoAll).attr('id', 'moveLeftAll'); + tableTDTwo.appendChild(inputTwoAll); + + + brAllTwp = document.createElement("br"); + tableTDTwo.appendChild(brAllTwp); + var inputThreeAll = document.createElement("input"); + $(inputThreeAll).attr("type", "button"); + $(inputThreeAll).attr("value", ">>"); + $(inputThreeAll).attr('id', 'moveRightAll'); + tableTDTwo.appendChild(inputThreeAll); + var tableTDThree = document.createElement("td"); if(rightLabel){ var rightSpan = document.createElement("span"); @@ -146,9 +164,14 @@ $('#moveRight').live('click', function () { moveRightToleft(); - }); + $('#moveRightAll').live('click', function () { + movAllRightToleft(); + }); + $('#moveLeftAll').live('click', function () { + moveAllLeftToRight(); + }); } // public methods @@ -177,6 +200,22 @@ } + var moveAllLeftToRight = function(){ + $('#selectorTwo option').each(function (index) { + $(this).remove(); + var that = $(this); + $(that).removeClass('selected'); + $('#selectorOne').append(that); + }); + } + var movAllRightToleft = function () { + $('#selectorOne option').each(function (index) { + $(this).remove(); + var that = $(this); + $(that).removeClass('selected'); + $('#selectorTwo').append(that); + }); + } var moveLeftToright = function () { $('#selectorTwo option').each(function (index) { diff --git a/test/funcunit_test.js b/test/funcunit_test.js index 7b580fb..eb9fef4 100755 --- a/test/funcunit_test.js +++ b/test/funcunit_test.js @@ -7,17 +7,39 @@ module("index.html",{ } }) test('Labels are correct', function(){ - S('#leftBox-label').exists(function(){ - ok(S('#leftBox-label')==='Unassigned'); + S('.leftBox-label').exists(function(){ + ok(S('.leftBox-label').html()==='Unassigned','Should be unassigned'); }); - S('#rightBox-label').exists(function(){ - ok(S('#rightBox-label')==='Assigned'); + S('.rightBox-label').exists(function(){ + ok(S('.rightBox-label').html()==='Assigned','Should be assigned'); }); }); +test('Move all buttons',function(){ + S('#moveRightAll').exists().click(); + S("#GetSelected").click(); + S('#SelectedItems').exists(function(){ + var count = S('#SelectedItems li').size(); + ok(count===5,'Five items are selected:' + count); + var one = S('#SelectedItems li:first-child').html(); + var two = S('#SelectedItems li:last-child').html(); + ok(one==='4', 'First value should be 4:' + one); + ok(two==='3', 'Second value should be 3:' + two); + }); + + S('#moveLeftAll').exists().click(); + S("#GetSelected").click(); + S('#SelectedItems').exists(function(){ + var count = S('#SelectedItems li').size(); + ok(0===0,'No items are selected:' + count); + + }); +}); + + test("Move stuff around and test", function(){ S("#optId_3").click(); S("#moveRight").click();