},
initialize: function () {
- this.listenTo(this.options.state, 'change:query', this.toggleHidden);
+ this.listenTo(this.options.state, 'change', this.toggleHidden);
},
onRender: function () {
toggleHidden: function () {
var test = this.model.get('path') + '/' + this.model.get('key');
- this.$el.toggleClass('hidden', !this.options.state.match(test));
+ this.$el.toggleClass('hidden', !this.options.state.match(test, this.model.get('internal')));
}
});
// State
this.state = new Backbone.Model({ internal: false });
- this.state.match = function (test) {
+ this.state.match = function (test, internal) {
var pattern = new RegExp(this.get('query'), 'i');
- return test.search(pattern) !== -1;
+ var internalCheck = !this.get('internal') && internal;
+ return test.search(pattern) !== -1 && !internalCheck;
};
// Layout
this.options.app.layout.headerRegion.show(new HeaderView({ model: item }));
if (opts.action != null) {
- actionsView.scrollToAction(opts.action);
+ var model = actions.findWhere({ key: opts.action });
+ if (model) {
+ if (model.get('internal')) {
+ this.options.state.set({ internal: true });
+ }
+ actionsView.scrollToAction(opts.action);
+ }
} else {
actionsView.scrollToTop();
}
var match = this.options.state.match(this.model.get('path')) ||
_.some(this.model.get('actions'), function (action) {
var test = action.path + '/' + action.key;
- return that.options.state.match(test);
+ return that.options.state.match(test, action.internal);
});
var showInternal = this.options.state.get('internal'),