<commit_before>var $document = $(document),
    $source = $('#source');

var editorModes = {
  html: 'htmlmixed',
  javascript: 'javascript',
  css: 'css'
};

var Panel = function (name, settings) {
  var panel = this;
  panel.settings = settings = settings || {};
  panel.id = panel.name = name;
  var $panel = $('.panel.' + name);
  $panel.data('name', name);
  panel.$el = $panel.detach();
  panel.$el.appendTo($source);
  panel.$el.wrapAll('<div class="stretch panelwrapper">');
  // var wrapper = panel.$el.parent().hide();
  panel.$el = panel.$el.parent().hide();
  panel.el = document.getElementById(name);
  panel.order = ++Panel.order;

  panel.$el.data('panel', panel);

  // keyboard shortcut (set in keyboardcontrol.js)
  panelShortcuts[panelShortcuts.start + panel.order] = panel.id;

  if (panel.order === 1) {
    settings.nosplitter = true;
  }

  var splitterSettings = {};

  if (settings.editor) {
    var cmSettings = {
      parserfile: [],
      tabMode: 'shift',
      dragDrop: false, // we handle it ourselves
      mode: editorModes[name],
      onChange: function (event) { 
        $document.trigger('codeChange', [{ panelId: panel.id, revert: true }]); 
        return true; 
      },
      lineWrapping: true,
      theme: 'jsbin'
    };

    $.extend(cmSettings, jsbin.settings.codemirror || {});

    panel.editor = CodeMirror.fromTextArea(panel.el, cmSettings);

    panel.processor = settings.processor || function (str) { return str; };

    panel._setupEditor(panel.editor, name);
  } 

  if (!settings.nosplitter) {
    // console.log(panel.id, wrapper);
    panel.splitter = panel.$el.splitter(splitterSettings).data('splitter');
    panel.splitter.hide();
  } else {
    // create a fake splitter to let the rest of the code work
    panel.splitter = $();
  }

  if (settings.beforeRender) {
    $document.bind('render', $.proxy(settings.beforeRender, panel));
  }

  if (!settings.editor) {
    panel.ready = true;
  }

  // append panel to controls

  this.controlButton = $('<a class="button group" href="#' + name + '">' + (settings.label || name) + '</a>');
  this.controlButton.click(function () {
    panel.toggle();
    return false;
  });
  this.controlButton.appendTo('#panels');

  $panel.focus(function () {
    panel.focus();
  });
  $panel.add(this.$el.find('.label')).click(function () {
    panel.focus();
    return false;
  });
}

Panel.order = 0;

Panel.prototype = {
  virgin: true,
  visible: false,
  show: function (x) {
    // check to see if there's a panel to the left.
    // if there is, take it's size/2 and make this our
    // width
    var panel = this,
        panelCount = panel.$el.find('.panel').length;

    analytics.showPanel(panel.id);

    // panel.$el.show();
    if (panel.splitter.length) {
      if (panelCount == 0 || panelCount > 1) {
        var $panel = $('.panel.' + panel.id).show();
        // $panel.next().show(); // should be the splitter...
        $panel.closest('.panelwrapper').show();
      } else {<commit_msg>Fixed cancelling of click<commit_after>var $document = $(document),
    $source = $('#source');

var editorModes = {
  html: 'htmlmixed',
  javascript: 'javascript',
  css: 'css'
};

var Panel = function (name, settings) {
  var panel = this;
  panel.settings = settings = settings || {};
  panel.id = panel.name = name;
  var $panel = $('.panel.' + name);
  $panel.data('name', name);
  panel.$el = $panel.detach();
  panel.$el.appendTo($source);
  panel.$el.wrapAll('<div class="stretch panelwrapper">');
  // var wrapper = panel.$el.parent().hide();
  panel.$el = panel.$el.parent().hide();
  panel.el = document.getElementById(name);
  panel.order = ++Panel.order;

  panel.$el.data('panel', panel);

  // keyboard shortcut (set in keyboardcontrol.js)
  panelShortcuts[panelShortcuts.start + panel.order] = panel.id;

  if (panel.order === 1) {
    settings.nosplitter = true;
  }

  var splitterSettings = {};

  if (settings.editor) {
    var cmSettings = {
      parserfile: [],
      tabMode: 'shift',
      dragDrop: false, // we handle it ourselves
      mode: editorModes[name],
      onChange: function (event) { 
        $document.trigger('codeChange', [{ panelId: panel.id, revert: true }]); 
        return true; 
      },
      lineWrapping: true,
      theme: 'jsbin'
    };

    $.extend(cmSettings, jsbin.settings.codemirror || {});

    panel.editor = CodeMirror.fromTextArea(panel.el, cmSettings);

    panel.processor = settings.processor || function (str) { return str; };

    panel._setupEditor(panel.editor, name);
  } 

  if (!settings.nosplitter) {
    // console.log(panel.id, wrapper);
    panel.splitter = panel.$el.splitter(splitterSettings).data('splitter');
    panel.splitter.hide();
  } else {
    // create a fake splitter to let the rest of the code work
    panel.splitter = $();
  }

  if (settings.beforeRender) {
    $document.bind('render', $.proxy(settings.beforeRender, panel));
  }

  if (!settings.editor) {
    panel.ready = true;
  }

  // append panel to controls

  this.controlButton = $('<a class="button group" href="#' + name + '">' + (settings.label || name) + '</a>');
  this.controlButton.click(function () {
    panel.toggle();
    return false;
  });
  this.controlButton.appendTo('#panels');

  $panel.focus(function () {
    panel.focus();
  });
  $panel.add(this.$el.find('.label')).click(function () {
    panel.focus();
  });
}

Panel.order = 0;

Panel.prototype = {
  virgin: true,
  visible: false,
  show: function (x) {
    // check to see if there's a panel to the left.
    // if there is, take it's size/2 and make this our
    // width
    var panel = this,
        panelCount = panel.$el.find('.panel').length;

    analytics.showPanel(panel.id);

    // panel.$el.show();
    if (panel.splitter.length) {
      if (panelCount == 0 || panelCount > 1) {
        var $panel = $('.panel.' + panel.id).show();
        // $panel.next().show(); // should be the splitter...
        $panel.closest('.panelwrapper').show();
      } else {
{'fraction_non_alphanumeric': 0.178084469571001, 'fraction_numerical': 0.0016627868307283007, 'mean_word_length': 2.916015625, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '2805276', 'n_tokens_mistral': 1973, 'n_tokens_neox': 1904, 'n_words': 435}