{"size": 2020, "ext": "js", "max_stars_repo_path": "js/views/help/shortcuts.js", "max_stars_repo_name": "bmeurant/tournament-front", "max_stars_repo_stars_event_min_datetime": "2015-05-02T18:47:01.000Z", "max_stars_repo_stars_event_max_datetime": "2015-05-02T18:47:01.000Z", "max_issues_repo_path": "js/views/help/shortcuts.js", "max_issues_repo_name": "bmeurant/tournament-front", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "js/views/help/shortcuts.js", "max_forks_repo_name": "bmeurant/tournament-front", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 32.5806451613, "max_line_length": 111, "alphanum_fraction": 0.5702970297}
define([
    'underscore',
    'backbone',
    'hbs!templates/help/shortcuts.html',
    'hbs!templates/help/shortcuts/global.html',
    'pubsub',
    'bootstrap'
], function(_, Backbone, shortcutsTemplate, globalTemplate, Pubsub) {

    var ShortcutsTemplate = Backbone.View.extend({

        template: shortcutsTemplate,

        events: {
            'keydown': 'modalKeydown'
        },

        initialize: function() {
            // in this specific case we can add container as el because we will never close or review this view
            Pubsub.on(App.Events.KEYBOARD_CALLED, this.render, this);
            Pubsub.on(App.Events.VIEW_CHANGED, this.viewChanged, this);
            Pubsub.on(App.Events.ECHAP_CALLED, this.hide, this);
        },

        render: function() {

            var elemTypeStr = _.str.capitalize(this.elemType);
            var viewTypeStr = _.str.capitalize(this.viewType);

            ShortcutsTemplate.__super__.render.apply(this, [{elemType: elemTypeStr, viewType: viewTypeStr}]);

            this.$('.global-shortcuts > .shortcuts').html(globalTemplate());

            require(['hbs!templates/help/shortcuts/' + this.elemType + '/' + this.viewType + '.html'],
                function(specificTemplate) {
                    specificTemplate = specificTemplate({elemType: elemTypeStr, viewType: viewTypeStr});
                    if (specificTemplate.indexOf('404') == -1) {
                        this.$('.specific-shortcuts > .shortcuts').html(specificTemplate);
                    }
                }.bind(this));

            this.$root.modal('show');
            return this;
        },

        modalKeydown: function(event) {
            event.stopPropagation();
            event.preventDefault();
        },

        viewChanged: function(elemType, viewType) {
            this.elemType = elemType;
            this.viewType = viewType;
        },

        hide: function () {
            this.$el.modal('hide');
        }
    });

    return ShortcutsTemplate;
});