Sha256: e3bee89afa993a275e4a3f68793e261793abdd8862006208fd815096c0295a6d
Contents?: true
Size: 1.47 KB
Versions: 12
Compression:
Stored size: 1.47 KB
Contents
pageflow.HelpView = Backbone.Marionette.ItemView.extend({ template: 'templates/help', className: 'help', defaultSection: 'outline', routeSectionMapping: { 'pages': 'page', 'files': 'files', 'publish': 'publish' }, ui: { breakButton: '.break', message: '.error .message', sections: 'section', menuItems: 'li' }, events: { 'click .close': function() { this.toggle(); }, 'click li': function(event) { this.showSection($(event.currentTarget).data('section')); }, 'click .box': function() { return false; }, 'click': function() { this.toggle(); } }, initialize: function() { this.listenTo(pageflow.app, 'toggle-help', function() { this.chooseSectionFromFragment(); this.toggle(); }); }, toggle: function() { this.$el.toggle(); }, chooseSectionFromFragment: function() { var route = _.chain(this.routeSectionMapping).keys().find(function(route) { if (Backbone.history.fragment.indexOf(route) >= 0) { return true; } }, this).value(); this.showSection(this.routeSectionMapping[route] || this.defaultSection); }, showSection: function(name) { this.ui.menuItems.each(function() { var menuItem = $(this); menuItem.toggleClass('active', menuItem.data('section') === name); }); this.ui.sections.each(function() { var section = $(this); section.toggle(section.data('name') === name); }); } });
Version data entries
12 entries across 12 versions & 1 rubygems