From b723428225cb83fa7404af4018d3b57aede61118 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Sun, 27 Dec 2015 17:54:59 +0100 Subject: [PATCH] reset tags behaviour moved to corresponding view --- js/app.js | 6 +++++- js/bookmarks.js | 7 ------- js/tagFilterView.js | 11 +++++++++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/js/app.js b/js/app.js index 4258c687..6804dbda 100644 --- a/js/app.js +++ b/js/app.js @@ -85,7 +85,8 @@ this.tagFilterView = new OCA.Bookmarks.TagFilterView({ collection: this.allTagsCollection, - id: 'tagitManager' + id: 'tagitManager', + el: '#tag_filter input' }); this.settingsView = new OCA.Bookmarks.SettingsView({ @@ -100,6 +101,9 @@ this.allTagsCollection.fetch(); console.warn('INiT DONE'); + + //FIXME: do be done by bookmarks collection + getBookmarks(); } }; })(); diff --git a/js/bookmarks.js b/js/bookmarks.js index d7089a72..a81bd6df 100644 --- a/js/bookmarks.js +++ b/js/bookmarks.js @@ -6,9 +6,6 @@ var ajaxCallCount = 0; $(document).ready(function () { $('.bookmarks_list').scroll(updateOnBottom).empty(); - $('.navigationAllBookmarks').click(resetTagFilter); - - getBookmarks(); }); var formatString = (function () { @@ -59,10 +56,6 @@ function addFilterTag(event) { $('#tag_filter input').tagit('createTag', $(this).text()); } -function resetTagFilter() { - $('#tag_filter input').tagit('removeAll'); -} - function updateTagsList(tag) { var selectedTags = $('#tag_filter input').tagit('assignedTags'); diff --git a/js/tagFilterView.js b/js/tagFilterView.js index 6a1f6767..cf802c20 100644 --- a/js/tagFilterView.js +++ b/js/tagFilterView.js @@ -13,23 +13,30 @@ var TagFilterView = OC.Backbone.View.extend({ initialize: function(options) { + _.bindAll(this, 'reset'); var view = this; this.collection.on('add remove', function() { view.render() }); - $('#tag_filter input').tagit({ + this.$el.tagit({ allowSpaces: true }); + + $('.navigationAllBookmarks').on('click', this.reset); }, render: function() { console.warn('RUNNING'); - $('#tag_filter input').tagit({ + this.$el.tagit({ allowSpaces: true, availableTags: this.collection.getLabels(), onTagFinishRemoved: filterTagsChanged, placeholderText: t('bookmarks', 'Filter by tag') }).tagit('option', 'onTagAdded', filterTagsChanged); + }, + + reset: function() { + this.$el.tagit('removeAll'); } });