Skip to content

Commit

Permalink
Add Select all buttons, updated tests.
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Gaddy <Kevin.Gaddy@gmail.com>
  • Loading branch information
kgaddy committed Sep 14, 2011
1 parent b4f8e9f commit 8e8a5c7
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 5 deletions.
41 changes: 40 additions & 1 deletion js/jquery.MoverBoxes.js
Expand Up @@ -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");
Expand Down Expand Up @@ -146,9 +164,14 @@

$('#moveRight').live('click', function () {
moveRightToleft();

});

$('#moveRightAll').live('click', function () {
movAllRightToleft();
});
$('#moveLeftAll').live('click', function () {
moveAllLeftToRight();
});
}

// public methods
Expand Down Expand Up @@ -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) {
Expand Down
30 changes: 26 additions & 4 deletions test/funcunit_test.js
Expand Up @@ -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();
Expand Down

0 comments on commit 8e8a5c7

Please sign in to comment.