diff options
Diffstat (limited to 'apps/files/js/navigation.js')
-rw-r--r-- | apps/files/js/navigation.js | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index c4a02ee7549..c58a284e83f 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -73,25 +73,40 @@ * @param array options "silent" to not trigger event */ setActiveItem: function(itemId, options) { + var oldItemId = this._activeItem; if (itemId === this._activeItem) { + if (!options || !options.silent) { + this.$el.trigger( + new $.Event('itemChanged', {itemId: itemId, previousItemId: oldItemId}) + ); + } return; } - this._activeItem = itemId; this.$el.find('li').removeClass('selected'); if (this.$currentContent) { this.$currentContent.addClass('hidden'); this.$currentContent.trigger(jQuery.Event('hide')); } + this._activeItem = itemId; + this.$el.find('li[data-id=' + itemId + ']').addClass('selected'); this.$currentContent = $('#app-content-' + itemId); this.$currentContent.removeClass('hidden'); - this.$el.find('li[data-id=' + itemId + ']').addClass('selected'); if (!options || !options.silent) { this.$currentContent.trigger(jQuery.Event('show')); - this.$el.trigger(new $.Event('itemChanged', {itemId: itemId})); + this.$el.trigger( + new $.Event('itemChanged', {itemId: itemId, previousItemId: oldItemId}) + ); } }, /** + * Returns whether a given item exists + */ + itemExists: function(itemId) { + return this.$el.find('li[data-id=' + itemId + ']').length; + }, + + /** * Event handler for when clicking on an item. */ _onClickItem: function(ev) { |