Add take all button

This commit is contained in:
Travis Weston
2015-02-12 12:43:57 -05:00
committed by Blake Grotewold
parent 66054c2825
commit 8c368d363a
2 changed files with 124 additions and 85 deletions
+4
View File
@@ -508,6 +508,10 @@ body.noMask #description {
padding-bottom: 20px;
}
.take-all-button {
float: none;
}
#buttons > .button {
margin: 0 5px 5px;
margin-right: 15px;
+35
View File
@@ -503,9 +503,44 @@ var Events = {
$('<div>').addClass('clear').appendTo(lootButtons);
if(lootButtons.children().length > 1) {
lootButtons.appendTo(desc);
var takeAll = new Button.Button({
id: 'loot_take_all',
text: _('take all'),
click: Events.takeAllLoot
}).addClass('take-all-button').appendTo(lootButtons);
}
},
takeAllLoot: function(){
var stoppedEarly = false;
$('#lootButtons')
.children('.button')
.each(function(){
if( $(this).hasClass('take-all-button') ) {
return;
}
var weight = $(this).data('numLeft') * Path.getWeight($(this).attr('id').substring(5).replace('-', ' '));
while( $(this).data('numLeft') > 0 && weight < Path.getFreeSpace() ){
$(this).click();
}
if(weight > Path.getFreeSpace()){
stoppedEarly = true;
return;
}
});
if( !stoppedEarly ){
$('#leave').click();
$('#leaveBtn').click();
}
},
dropStuff: function(e) {
e.stopPropagation();
var btn = $(this);