summaryrefslogtreecommitdiffstats
path: root/pyload/web/app/scripts/views/linkgrabber
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/web/app/scripts/views/linkgrabber')
-rw-r--r--pyload/web/app/scripts/views/linkgrabber/collectorView.js10
-rw-r--r--pyload/web/app/scripts/views/linkgrabber/modalView.js10
-rw-r--r--pyload/web/app/scripts/views/linkgrabber/packageView.js8
3 files changed, 25 insertions, 3 deletions
diff --git a/pyload/web/app/scripts/views/linkgrabber/collectorView.js b/pyload/web/app/scripts/views/linkgrabber/collectorView.js
index d2b43f699..a02023a30 100644
--- a/pyload/web/app/scripts/views/linkgrabber/collectorView.js
+++ b/pyload/web/app/scripts/views/linkgrabber/collectorView.js
@@ -3,6 +3,15 @@ define(['jquery', 'underscore', 'backbone', 'app', './packageView'],
'use strict';
return Backbone.Marionette.CollectionView.extend({
itemView: packageView,
+
+ initialize: function() {
+ this.listenTo(App.vent, 'linkcheck:updated', _.bind(this.onData, this));
+ },
+
+ onData: function(rid, result) {
+ this.updateData({data: result});
+ },
+
updateData: function(result) {
var self = this;
_.each(result.data, function(links, name) {
@@ -16,6 +25,5 @@ define(['jquery', 'underscore', 'backbone', 'app', './packageView'],
pack.updateLinks(links);
});
}
-
});
}); \ No newline at end of file
diff --git a/pyload/web/app/scripts/views/linkgrabber/modalView.js b/pyload/web/app/scripts/views/linkgrabber/modalView.js
index 6e4781ac2..32730658c 100644
--- a/pyload/web/app/scripts/views/linkgrabber/modalView.js
+++ b/pyload/web/app/scripts/views/linkgrabber/modalView.js
@@ -4,6 +4,7 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/CollectorPackage', 'v
// Modal dialog for package adding - triggers package:added when package was added
return modalView.extend({
+ className: 'modal linkgrabber',
events: {
'keypress #inputLinks': 'addOnEnter'
},
@@ -16,6 +17,7 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/CollectorPackage', 'v
initialize: function() {
// Inherit parent events
this.events = _.extend({}, modalView.prototype.events, this.events);
+ this.listenTo(App.vent, 'package:added', _.bind(this.onAdded, this));
},
addOnEnter: function(e) {
@@ -44,6 +46,14 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/CollectorPackage', 'v
this.$('#inputLinks').val('');
},
+ // Hide when there are no more packages
+ onAdded: function() {
+ if (this.collectorView !== null) {
+ if (this.collectorView.collection.length === 0)
+ this.hide();
+ }
+ },
+
onRender: function() {
// anonymous collection
this.collectorView = new CollectorView({collection: new (Backbone.Collection.extend({
diff --git a/pyload/web/app/scripts/views/linkgrabber/packageView.js b/pyload/web/app/scripts/views/linkgrabber/packageView.js
index 89a307d2f..95c46e3cc 100644
--- a/pyload/web/app/scripts/views/linkgrabber/packageView.js
+++ b/pyload/web/app/scripts/views/linkgrabber/packageView.js
@@ -33,8 +33,10 @@ define(['jquery', 'underscore', 'backbone', 'app', 'hbs!tpl/linkgrabber/package'
return data;
},
- addPackage: function() {
+ addPackage: function(e) {
+ e.stopPropagation();
this.model.add();
+ return false;
},
renamePackage: function() {
@@ -63,9 +65,11 @@ define(['jquery', 'underscore', 'backbone', 'app', 'hbs!tpl/linkgrabber/package'
this.render();
},
- expand: function() {
+ expand: function(e) {
+ e.stopPropagation();
this.expanded ^= true;
this.ui.table.toggle();
+ return false;
}
});