<commit_before>/**
 * @module Core
 */
define([
    'core/modules/GelatoView'
], function(GelatoView) {

    /**
     * @class GelatoSidebar
     * @extends GelatoView
     */
    var GelatoSidebar = GelatoView.extend({
        /**
         * @method initialize
         * @constructor
         */
        initialize: function(options) {
            options = options === undefined ? {} : options;
            this.element = options.name === undefined ? $(this.$('.gelato-sidebar').get(0)) : this.$('#sidebar-' + options.name);
            this.page = options.page;
        },
        /**
         * @property events
         * @type Object
         */
        events: {},
        /**
         * @method getName
         * @returns {String}
         */
        getName: function() {
            return this.element.get(0).id.replace('sidebar-', '');
        }
    });

    return GelatoSidebar;

});<commit_msg>Added flexible logic for handling dialogs embedded in page views.<commit_after>/**
 * @module Core
 */
define([
    'core/modules/GelatoView'
], function(GelatoView) {

    /**
     * @class GelatoDialog
     * @extends GelatoView
     */
    var GelatoDialog = GelatoView.extend({
        /**
         * @method initialize
         * @constructor
         */
        initialize: function(options) {
            options = options || {};
            this.element = null;
            this.page = options.page;
            this.state = 'hidden';
        },
        /**
         * @property events
         * @type Object
         */
        events: {
            'vclick [data-dialog]': 'handleClickDialogToggle'
        },
        /**
         * @method handleClickDialogToggle
         * @param {Event} event
         */
        handleClickDialogToggle: function(event) {
            event.preventDefault();
            var options = {};
            var target = $(event.currentTarget);
            var name = target.data('dialog');
            //TODO: parse keyboard, show and remote as boolean
            options.backdrop = target.data('backdrop');
            options.keyboard = target.data('keyboard');
            options.show = target.data('show');
            options.remote = target.data('remote');
            this.show(name, options);
        },
        /**
         * @method handleModalHide
         * @param {Event} event
         */
        handleModalHide: function(event) {
            this.state = 'hide';
            this.trigger('hide', event);
        },
        /**
         * @method handleModalHidden
         * @param {Event} event
         */
        handleModalHidden: function(event) {
            this.state = 'hidden';
            this.element = null;
            $(event.target).find('*').off();
            this.trigger('hidden', event);
        },
        /**
         * @method handleModalShow
         * @param {Event} event
         */
        handleModalShow: function(event) {
            this.state = 'show';
            this.trigger('show', event);
        },
        /**
         * @method handleModalShown
         * @param {Event} event
         */
        handleModalShown: function(event) {
            this.state = 'shown';
            this.trigger('shown', event);
        },
        /**
         * @method hide
         * @returns {GelatoDialog}
         */
        hide: function() {
            this.element.modal('hide');
            return this;
        },
        /**
         * @method show
         * @param {String} name
         * @param {Object} [options]
         * @returns {GelatoDialog}
         */
        show: function(name, options) {
            options = options || {};
            options.backdrop = options.backdrop || 'static';
            options.keyboard = options.keyboard || false;
            options.show = options.show || true;
            options.remote = options.remote || false;
            if (this.state === 'hidden') {
                this.element = this.$('#' + name + ' .modal');
                this.element.one('show.bs.modal', $.proxy(this.handleModalShow, this));
                this.element.one('shown.bs.modal', $.proxy(this.handleModalShown, this));
                this.element.one('hide.bs.modal', $.proxy(this.handleModalHide, this));
                this.element.one('hidden.bs.modal', $.proxy(this.handleModalHidden, this));
                this.element.modal(options);
            }
            return this;
        }
    });

    return GelatoDialog;

});
{'fraction_non_alphanumeric': 0.14173757277205554, 'fraction_numerical': 0.0004478280340349306, 'mean_word_length': 1.532312925170068, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3297126', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1170, 'n_words': 229}