diff options
Diffstat (limited to 'www')
-rw-r--r-- | www/js/jingles.js | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/www/js/jingles.js b/www/js/jingles.js index 3af1e63..b737a1b 100644 --- a/www/js/jingles.js +++ b/www/js/jingles.js @@ -46,7 +46,7 @@ var JingleGroupList = function() { this.groups = []; var self = this; - $(this).on('add remove update', function () { + $(this).on('add update', function () { self.render(); }); }; @@ -80,10 +80,6 @@ JingleGroupList.prototype.fetch = function() { self.fetch(); }); - $(jingleGroup).on('remove', function() { - self.fetch(); - }); - self.groups.push(jingleGroup); }); }); @@ -161,10 +157,6 @@ JingleGroup.prototype.createCartFromXml = function(cartXml, active) { active ); - $(cut).on('remove', function() { - $(self).trigger('remove'); - }); - $(cut).on('add', function() { $(self).trigger('add'); }); @@ -234,6 +226,15 @@ JingleCart.prototype.addCut = function(cut) { this.cuts.push(cut); }; +JingleCart.prototype.removeCut = function(cut) { + var self = this; + $.each(this.cuts, function(index, currentCut){ + if(currentCut === cut) { + self.cuts.splice(index, 1); + } + }); +}; + var JingleCut = function(cart, cartNumber, name, description, active) { this.cart = cart; this.cartNumber = cartNumber; @@ -284,15 +285,15 @@ JingleCut.prototype.toggleActive = function() { }); }; -JingleCut.prototype.delete = function() { +JingleCut.prototype.removeSelf = function() { var self = this; rivendell.removeCut(this.cartNumber, this.number, function() { - $(self).trigger('remove'); + self.cart.removeCut(this); + self.$el.remove(); }); }; JingleCut.prototype.render = function() { - var moveButton = $('<button class="btn btn-info btn-mini"><i class="icon-arrow-right icon-white"></i> Verschieben</button>'); var activateButton; if (this.active) { @@ -310,7 +311,7 @@ JingleCut.prototype.render = function() { self.toggleActive(); }); deleteButton.on('click', function() { - self.delete(); + self.removeSelf(); }); this.$el = $('<tr>').append($('<td>').text(this.name)) |