summaryrefslogtreecommitdiffstats
path: root/module/web/static/js/views/packageTreeView.js
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-09-23 21:04:47 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-09-23 21:04:47 +0200
commitf370ef06ad9db2e47edba02b99271137324997cf (patch)
treed432ea10ee77fc9a4165c685eefe9afd1714fcbf /module/web/static/js/views/packageTreeView.js
parentfixed the dashboard (diff)
downloadpyload-f370ef06ad9db2e47edba02b99271137324997cf.tar.xz
added some animations, code for show/hiding items
Diffstat (limited to 'module/web/static/js/views/packageTreeView.js')
-rw-r--r--module/web/static/js/views/packageTreeView.js39
1 files changed, 28 insertions, 11 deletions
diff --git a/module/web/static/js/views/packageTreeView.js b/module/web/static/js/views/packageTreeView.js
index 3cef27601..3329c9582 100644
--- a/module/web/static/js/views/packageTreeView.js
+++ b/module/web/static/js/views/packageTreeView.js
@@ -4,11 +4,12 @@ define(['jquery', 'backbone', 'underscore', 'models/TreeCollection', 'views/pack
// Renders whole PackageView
return Backbone.View.extend({
- el: '#dashboard',
+ el: '#content',
events: {
'click #add': 'addPackage',
- 'keypress #name': 'addOnEnter'
+ 'keypress #name': 'addOnEnter',
+ 'click #show_active': 'filter'
},
initialize: function() {
@@ -25,27 +26,29 @@ define(['jquery', 'backbone', 'underscore', 'models/TreeCollection', 'views/pack
render: function() {
var packs = this.tree.get('packages'),
- files = this.tree.get('files');
+ files = this.tree.get('files'),
+ el = this.$('#dashboard');
- this.$el.empty()
- this.$el.append($('<span>Root: ' + this.tree.get('root').get('name') + ' </span>'));
- this.$el.append($('<input id="name" type="text" size="20">'));
- this.$el.append($('<a id="add" href="#"> Add</a><br>'));
+ el.empty();
+ el.append($('<span>Root: ' + this.tree.get('root').get('name') + ' </span>'));
+ el.append($('<input id="name" type="text" size="20">'));
+ el.append($('<a id="add" href="#"> Add</a><br>'));
var ul = $('<ul></ul>');
packs.each(function(pack) {
ul.append(new packageView({model: pack}).render().el);
});
- this.$el.append(ul);
- this.$el.append($('<br> Files: ' + files.size() + '<br>'));
+ el.append(ul);
+ el.append($('<br> Files: ' + files.size() + '<br>'));
ul = $('<ul></ul>');
files.each(function(file) {
ul.append(new fileView({model: file}).render().el);
});
- this.$el.append(ul);
+ el.append(ul);
+ $('#name').focus();
return this;
},
@@ -55,7 +58,7 @@ define(['jquery', 'backbone', 'underscore', 'models/TreeCollection', 'views/pack
this.addPackage(e);
},
- addPackage: function() {
+ addPackage: function(e) {
var self = this;
var settings = {
type: 'POST',
@@ -72,6 +75,20 @@ define(['jquery', 'backbone', 'underscore', 'models/TreeCollection', 'views/pack
$.ajax('api/addPackage', settings);
$('#name').val('');
+ },
+
+ toggle: false,
+
+ filter: function(e) {
+ var self = this;
+ this.tree.get('packages').each(function(item){
+ if(!self.toggle)
+ item.trigger('filter:added');
+ else
+ item.trigger('filter:removed');
+
+ });
+ self.toggle ^= true;
}
});
}); \ No newline at end of file