<commit_before>/*global define*/
/*jslint white: true*/
define(['jquery', 
        'narrativeConfig',
        'kbwidget', 
        'bootstrap'], 
function($, Config) {
    'use strict';
    $.KBWidget({
        name: 'kbaseNarrativeCellMenu',
        parent: 'kbaseWidget',
        options: {cell: null, kbWidget: null, kbWidgetType: null},
        genId: function () {
            if (!this.lastId) {
                this.lastId = 1;
            } else {
                this.lastId += 1;
            }
            return 'kbaseNarrativeCellMenu_' + this.lastId;
        },
        init: function (options) {
            var self = this;
            this._super(options);

            // console.log(['cell menu', this.options.cell]);
//            var outputPane = this.$elem.closest('.cell').find('.inner_cell > div:nth-child(2)').get(0);
//            if (!outputPane.id) {
//                outputPane.id = this.genId();
//            }
//            this.$elem.data('ouputPaneId', outputPane.id);

            var $deleteBtn = $('<button type="button" class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="left" Title="Delete Cell">')
                .append($('<span class="fa fa-trash-o" style="font-size:14pt; padding-left: 5px;">'))
                .click($.proxy(function () {
                    this.trigger('deleteCell.Narrative', Jupyter.notebook.get_selected_index());
                }, this)),
                $menuBtn = $('<button type="button" data-toggle="dropdown" aria-haspopup="true" class="btn btn-default btn-xs">')
                .append($('<span class="fa fa-cog" style="font-size:14pt">')),
                // $collapseBtn = $('<button class="btn btn-default" role="button" data-toggle="collapse" href="#' + outputPane.id + '" aria-controls="' + $outputPane.id + '">Open</button>'),
                $collapseBtn = $('<button type="button" class="btn btn-default btn-xs" role="button" data-button="toggle"><span class="fa fa-chevron-down"></button>')
                .on('click', function () {
                    self.$elem.trigger('toggle.toolbar');                    
                });

            var cell = this.options.cell;

            /* 
             * Each cell type unfortunately has a different top level layout.
             * Not that it matters, but I don't see why there isn't a uniform layout 
             * for the primary layout areas - prompt, toolbar, body, as they exist
             * now, and another nice one would be a message/notification are
             */
            this.$elem.on('toggle.toolbar', function () {                
                var $cellNode = self.$elem.closest('.cell');
                $cellNode
                    .trigger('toggle.cell');
            });
            
//            this.$elem.on('toggle-output-all', function () {
//                self.$elem
//                    .closest('.notebook')
//                    .find('.cell .inner_cell > div:nth-child(3)')
//                    .toggle();
//            });

            this.$menu = $('<ul>')
                .addClass('dropdown-menu dropdown-menu-right');
            
            if (Config.debug) {
                this.addMenuItem({
                    icon: 'fa fa-code',
                    text: 'View Job Submission',
                    action: function () {
                        var metadata = Jupyter.notebook.get_selected_cell().metadata,
                            stackTrace = [],
                            cell = Jupyter.notebook.insert_cell_below('code');
                        if (metadata['kb-cell'] && metadata['kb-cell'].stackTrace) {
                            stackTrace = metadata['kb-cell'].stackTrace;
                        }
                        console.log(stackTrace);<commit_msg>Fixed wrong cell being deleted.<commit_after>/*global define*/
/*jslint white: true*/
define(['jquery', 
        'narrativeConfig',
        'kbwidget', 
        'bootstrap'], 
function($, Config) {
    'use strict';
    $.KBWidget({
        name: 'kbaseNarrativeCellMenu',
        parent: 'kbaseWidget',
        options: {cell: null, kbWidget: null, kbWidgetType: null},
        genId: function () {
            if (!this.lastId) {
                this.lastId = 1;
            } else {
                this.lastId += 1;
            }
            return 'kbaseNarrativeCellMenu_' + this.lastId;
        },
        init: function (options) {
            var self = this;
            this._super(options);


            var $deleteBtn = $('<button type="button" class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="left" Title="Delete Cell">')
                .append($('<span class="fa fa-trash-o" style="font-size:14pt; padding-left: 5px;">'))
                .click($.proxy(function () {
                    this.trigger('deleteCell.Narrative', Jupyter.notebook.find_cell_index(this.options.cell));
                }, this));

            var $menuBtn = $('<button type="button" data-toggle="dropdown" aria-haspopup="true" class="btn btn-default btn-xs">')
                .append($('<span class="fa fa-cog" style="font-size:14pt">'));

            var $collapseBtn = $('<button type="button" class="btn btn-default btn-xs" role="button" data-button="toggle"><span class="fa fa-chevron-down"></button>')
                .on('click', function () {
                    self.$elem.trigger('toggle.toolbar');                    
                });

            var cell = this.options.cell;

            /* 
             * Each cell type unfortunately has a different top level layout.
             * Not that it matters, but I don't see why there isn't a uniform layout 
             * for the primary layout areas - prompt, toolbar, body, as they exist
             * now, and another nice one would be a message/notification area.
             */
            this.$elem.on('toggle.toolbar', function () {
                var $cellNode = self.$elem.closest('.cell');
                $cellNode
                    .trigger('toggle.cell');
            });
            
//            this.$elem.on('toggle-output-all', function () {
//                self.$elem
//                    .closest('.notebook')
//                    .find('.cell .inner_cell > div:nth-child(3)')
//                    .toggle();
//            });

            this.$menu = $('<ul>')
                .addClass('dropdown-menu dropdown-menu-right');
            
            if (Config.debug) {
                this.addMenuItem({
                    icon: 'fa fa-code',
                    text: 'View Job Submission',
                    action: function () {
                        var metadata = Jupyter.notebook.get_selected_cell().metadata,
                            stackTrace = [],
                            cell = Jupyter.notebook.insert_cell_below('code');
                        if (metadata['kb-cell'] && metadata['kb-cell'].stackTrace) {
                            stackTrace = metadata['kb-cell'].stackTrace;
                        }
                        console.log(stackTrace);
{'fraction_non_alphanumeric': 0.14687191074706962, 'fraction_numerical': 0.002542013839853128, 'mean_word_length': 1.522079772079772, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 24, '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': '6892565', 'n_tokens_mistral': 1917, 'n_tokens_neox': 1811, 'n_words': 391}