From d6bc45cd39d82f4d5412055a018371b56351e2f5 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Mon, 22 Jul 2013 18:44:54 +0200 Subject: implemented media type filter --- pyload/web/app/scripts/views/dashboard/filterView.js | 20 ++++++++++++++++++++ pyload/web/app/scripts/views/headerView.js | 1 - .../app/templates/default/dashboard/actionbar.html | 5 +++-- .../web/app/templates/default/dashboard/package.html | 4 ++-- 4 files changed, 25 insertions(+), 5 deletions(-) (limited to 'pyload/web') diff --git a/pyload/web/app/scripts/views/dashboard/filterView.js b/pyload/web/app/scripts/views/dashboard/filterView.js index ad72cf926..736b740e1 100644 --- a/pyload/web/app/scripts/views/dashboard/filterView.js +++ b/pyload/web/app/scripts/views/dashboard/filterView.js @@ -31,7 +31,10 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'models/Pac }, template: template, + // Visible dl state state: null, + // bit mask of filtered, thus not visible media types + types: 0, initialize: function() { this.state = Api.DownloadState.All; @@ -120,6 +123,10 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'models/Pac // determine if a file should be visible // TODO: non download files is_visible: function(file) { + // bit is set -> not visible + if (file.get('media') & this.types) + return false; + if (this.state === Api.DownloadState.Finished) return file.isFinished(); else if (this.state === Api.DownloadState.Unfinished) @@ -140,7 +147,20 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'models/Pac }, filter_type: function(e) { + var el = $(e.target); + var type = parseInt(el.data('type')); + + // Bit is already set, so type is not visible, will become visible now + if (type & this.types) { + el.find('i').removeClass('icon-remove').addClass('icon-ok'); + } else { // type will be hidden + el.find('i').removeClass('icon-ok').addClass('icon-remove'); + } + this.types ^= type; + + this.apply_filter(); + return false; } }); diff --git a/pyload/web/app/scripts/views/headerView.js b/pyload/web/app/scripts/views/headerView.js index 2c83fb381..b4ffbc35d 100644 --- a/pyload/web/app/scripts/views/headerView.js +++ b/pyload/web/app/scripts/views/headerView.js @@ -144,7 +144,6 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'colle // Render progressbar only when needed if (!_.isEqual([data.tasks, data.downloads], this.lastStatus)) { - console.log('render bar'); this.lastStatus = [data.tasks, data.downloads]; this.$('#progress-info').html(templateProgress(data)); } else { diff --git a/pyload/web/app/templates/default/dashboard/actionbar.html b/pyload/web/app/templates/default/dashboard/actionbar.html index a8b2ebecd..ad9a1278d 100644 --- a/pyload/web/app/templates/default/dashboard/actionbar.html +++ b/pyload/web/app/templates/default/dashboard/actionbar.html @@ -31,8 +31,9 @@
  •  Image
  •  Video
  •  Document
  • -
  •  Archive
  • -
  •  Other
  • +
  •  Archive
  • +
  •  Executable
  • +
  •  Other