diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-11-24 22:01:21 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-11-24 22:01:21 +0100 |
commit | 606d2839aff19da1593c5cab4297342398b626aa (patch) | |
tree | 8a0714581ad31fe23b9acad9dc50fb1310905fb2 /pyload/web/app/scripts/views/dashboard | |
parent | downgraded handlebars (diff) | |
download | pyload-606d2839aff19da1593c5cab4297342398b626aa.tar.xz |
render addon menu for packages
Diffstat (limited to 'pyload/web/app/scripts/views/dashboard')
-rw-r--r-- | pyload/web/app/scripts/views/dashboard/packageView.js | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/pyload/web/app/scripts/views/dashboard/packageView.js b/pyload/web/app/scripts/views/dashboard/packageView.js index 2738fcbea..30121c344 100644 --- a/pyload/web/app/scripts/views/dashboard/packageView.js +++ b/pyload/web/app/scripts/views/dashboard/packageView.js @@ -1,5 +1,5 @@ -define(['jquery', 'app', 'views/abstract/itemView', 'underscore', 'hbs!tpl/dashboard/package'], - function($, App, itemView, _, template) { +define(['jquery', 'app', 'views/abstract/itemView', 'underscore', 'hbs!tpl/dashboard/package', 'hbs!tpl/dashboard/submenu'], + function($, App, itemView, _, template, templateSubmenu) { 'use strict'; // Renders a single package item @@ -12,7 +12,9 @@ define(['jquery', 'app', 'views/abstract/itemView', 'underscore', 'hbs!tpl/dashb 'click .package-name, .btn-open': 'open', 'click .icon-refresh': 'restart', 'click .select': 'select', - 'click .btn-delete': 'deleteItem' + 'click .icon-chevron-down': 'loadMenu', + 'click .btn-delete': 'deleteItem', + 'click .dropdown-submenu a': 'invokeAddon' }, // Ul for child packages (unused) @@ -44,6 +46,10 @@ define(['jquery', 'app', 'views/abstract/itemView', 'underscore', 'hbs!tpl/dashb return this; }, + renderSubmenu: function(addons) { + this.$('.dropdown-submenu ul').html(templateSubmenu(addons)); + }, + unrender: function() { itemView.prototype.unrender.apply(this); @@ -51,7 +57,6 @@ define(['jquery', 'app', 'views/abstract/itemView', 'underscore', 'hbs!tpl/dashb App.vent.trigger('dashboard:loading', null); }, - // TODO // Toggle expanding of packages expand: function(e) { @@ -70,6 +75,20 @@ define(['jquery', 'app', 'views/abstract/itemView', 'underscore', 'hbs!tpl/dashb this.model.set('selected', !checked, {silent: true}); this.$('.select').toggleClass('icon-check').toggleClass('icon-check-empty'); App.vent.trigger('package:selection'); + }, + + loadMenu: function() { + App.addons.getForType(true, null, _.bind(this.renderSubmenu, this)); + }, + + invokeAddon: function(e) { + var el = $(e.target); + // clicked on icon + if (el.context.tagName === 'IMG') + el = el.parent(); + + App.addons.invoke(el.data('plugin'), el.data('func'), this.model.get('pid')); } + }); });
\ No newline at end of file |