summaryrefslogtreecommitdiff
path: root/www/js
diff options
context:
space:
mode:
authorPeter Grassberger <petertheone@gmail.com>2015-12-03 12:06:10 (GMT)
committerPeter Grassberger <petertheone@gmail.com>2015-12-03 12:06:10 (GMT)
commit9d04aa9f631b088113d933690266dacd0df38c97 (patch)
treef6dc7bade4b60232f3d606c54d0c550f0ac52a24 /www/js
parent4faf154105dd0678a59edfd947a3d1c589335503 (diff)
jingles: removecut without refetching all groups, carts and cuts.
Diffstat (limited to 'www/js')
-rw-r--r--www/js/jingles.js27
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))