<commit_before>toolview = require("./toolview")
ToolView = toolview.ToolView
ButtonEventGenerator = require("./eventgenerators").ButtonEventGenerator
LinearMapper = require("../mappers/1d/linear_mapper").LinearMapper
base = require("../base")
safebind = base.safebind
HasParent = base.HasParent

class PreviewSaveToolView extends ToolView
  initialize: (options) ->
    super(options)

  eventGeneratorClass: ButtonEventGenerator
  evgen_options: { buttonText:"Preview/Save" }
  tool_events: {
     activated: "_activated"
  }

  _activated: (e) ->
    data_uri = @plot_view.canvas[0].toDataURL()
    modal = """
      '<div id="previewModal" class="modal" role="dialog" aria-labelledby="previewLabel" aria-hidden="true">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
          <h3 id="dataConfirmLabel">Image Preview (right click to save)</h3></div><div class="modal-body">
        <div class="modal-body">
          <img src="#{data_uri}">
        </div>
        </div><div class="modal-footer">
          <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
        </div>
      </div>')
    """
    $('body').append(modal)
    $('#previewModal').modal({show:true});

class PreviewSaveTool extends HasParent
  type: "PreviewSaveTool"
  default_view: PreviewSaveToolView

PreviewSaveTool::defaults = _.clone(PreviewSaveTool::defaults)
_.extend(PreviewSaveTool::defaults)


class PreviewSaveTools extends Backbone.Collection
  model: PreviewSaveTool

exports.PreviewSaveToolView = PreviewSaveToolView
exports.previewsavetools = new PreviewSaveTools<commit_msg>dialog should clean up after itself<commit_after>toolview = require("./toolview")
ToolView = toolview.ToolView
ButtonEventGenerator = require("./eventgenerators").ButtonEventGenerator
LinearMapper = require("../mappers/1d/linear_mapper").LinearMapper
base = require("../base")
safebind = base.safebind
HasParent = base.HasParent

class PreviewSaveToolView extends ToolView
  initialize: (options) ->
    super(options)

  eventGeneratorClass: ButtonEventGenerator
  evgen_options: { buttonText:"Preview/Save" }
  tool_events: {
     activated: "_activated"
  }

  _activated: (e) ->
    data_uri = @plot_view.canvas[0].toDataURL()
    modal = """
      '<div id="previewModal" class="modal" role="dialog" aria-labelledby="previewLabel" aria-hidden="true">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
          <h3 id="dataConfirmLabel">Image Preview (right click to save)</h3></div><div class="modal-body">
        <div class="modal-body">
          <img src="#{data_uri}">
        </div>
        </div><div class="modal-footer">
          <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
        </div>
      </div>')
    """
    $('body').append(modal)
    $('#previewModal').on('hidden', () =>
      $('#previewModal').remove()
    )
    $('#previewModal').modal({show:true});

class PreviewSaveTool extends HasParent
  type: "PreviewSaveTool"
  default_view: PreviewSaveToolView

PreviewSaveTool::defaults = _.clone(PreviewSaveTool::defaults)
_.extend(PreviewSaveTool::defaults)


class PreviewSaveTools extends Backbone.Collection
  model: PreviewSaveTool

exports.PreviewSaveToolView = PreviewSaveToolView
exports.previewsavetools = new PreviewSaveTools
{'fraction_non_alphanumeric': 0.1484601975595584, 'fraction_numerical': 0.002324230098779779, 'mean_word_length': 4.422047244094488, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 42, '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': '2264106', 'n_tokens_mistral': 1033, 'n_tokens_neox': 1014, 'n_words': 188}