Sha256: a10a93d3972fa2bd4d8ad04f9f19197aeebdd348484969e1f1765dc10cf223d6
Contents?: true
Size: 1.9 KB
Versions: 15
Compression:
Stored size: 1.9 KB
Contents
pageflow.HelpView = Backbone.Marionette.ItemView.extend({ template: 'templates/help', className: 'help', ui: { placeholder: '.placeholder', sections: 'section', menuItems: 'li' }, events: { 'click .close': function() { this.toggle(); }, 'click .expandable > a': function(event) { $(event.currentTarget).parents('.expandable').toggleClass('expanded'); }, 'click a': function(event) { var link = $(event.currentTarget); if (link.attr('href').indexOf('#') === 0) { this.showSection(link.attr('href').substring(1), {scrollIntoView: !link.parents('nav').length}); } return false; }, 'click .box': function() { return false; }, 'click': function() { this.toggle(); } }, initialize: function() { this.listenTo(pageflow.app, 'toggle-help', function(name) { this.toggle(); this.showSection(name || pageflow.editor.defaultHelpEntry || this.defaultHelpEntry(), {scrollIntoView: true}); }); }, onRender: function() { this.ui.placeholder.replaceWith($('#help_entries_seed').html()); this.bindUIElements(); }, toggle: function() { this.$el.toggle(); }, defaultHelpEntry: function() { return this.ui.sections.first().data('name'); }, showSection: function(name, options) { this.ui.menuItems.each(function() { var menuItem = $(this); var active = (menuItem.find('a').attr('href') === '#' + name); menuItem.toggleClass('active', active); if (active) { menuItem.parents('.expandable').addClass('expanded'); if (options.scrollIntoView) { menuItem[0].scrollIntoView(); } } }); this.ui.sections.each(function() { var section = $(this); section.toggle(section.data('name') === name); }); } });
Version data entries
15 entries across 15 versions & 1 rubygems