From f370ef06ad9db2e47edba02b99271137324997cf Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 23 Sep 2012 21:04:47 +0200 Subject: added some animations, code for show/hiding items --- module/web/static/js/views/packageTreeView.js | 39 +++++++++++++++++++-------- 1 file changed, 28 insertions(+), 11 deletions(-) (limited to 'module/web/static/js/views/packageTreeView.js') 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($('Root: ' + this.tree.get('root').get('name') + ' ')); - this.$el.append($('')); - this.$el.append($(' Add
')); + el.empty(); + el.append($('Root: ' + this.tree.get('root').get('name') + ' ')); + el.append($('')); + el.append($(' Add
')); var ul = $(''); packs.each(function(pack) { ul.append(new packageView({model: pack}).render().el); }); - this.$el.append(ul); - this.$el.append($('
Files: ' + files.size() + '
')); + el.append(ul); + el.append($('
Files: ' + files.size() + '
')); 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 -- cgit v1.2.3