diff options
Diffstat (limited to 'apps/files/js/navigation.js')
-rw-r--r-- | apps/files/js/navigation.js | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index f53abddd4db..c4a02ee7549 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -22,7 +22,7 @@ /** * Currently selected item in the list */ - _selectedItem: null, + _activeItem: null, /** * Currently selected container @@ -35,7 +35,7 @@ */ initialize: function($el) { this.$el = $el; - this._selectedItem = null; + this._activeItem = null; this.$currentContent = null; this._setupEvents(); }, @@ -48,22 +48,47 @@ }, /** + * Returns the container of the currently active app. + * + * @return app container + */ + getActiveContainer: function() { + return this.$currentContent; + }, + + /** + * Returns the currently active item + * + * @return item ID + */ + getActiveItem: function() { + return this._activeItem; + }, + + /** * Switch the currently selected item, mark it as selected and * make the content container visible, if any. + * * @param string itemId id of the navigation item to select + * @param array options "silent" to not trigger event */ - setSelectedItem: function(itemId) { - if (itemId === this._selectedItem) { + setActiveItem: function(itemId, options) { + if (itemId === this._activeItem) { return; } - this._selectedItem = itemId; + this._activeItem = itemId; this.$el.find('li').removeClass('selected'); if (this.$currentContent) { this.$currentContent.addClass('hidden'); + this.$currentContent.trigger(jQuery.Event('hide')); } 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})); + } }, /** @@ -72,7 +97,8 @@ _onClickItem: function(ev) { var $target = $(ev.target); var itemId = $target.closest('li').attr('data-id'); - this.setSelectedItem(itemId); + this.setActiveItem(itemId); + return false; } }; |