<commit_before>(function($) {
  $.plugin('story_item', (function(){
    function renderByPlugin($this) {
      var item = $this.story_item('data');
      var plugin = wikimate.plugins[item.type];
      // add another div inside for removing conflict highlighting with text area
      // after changed to edit mode
      // it's also easier to keep item div element clean
      var content = $('<div />').addClass('item-content');
      plugin.emit.apply($this, [content, item]);
      plugin.bind.apply($this, [content, item]);
      initActionBar(content);
      return $this.html(content);
    }

    function editByPlugin($this) {
      var item = $this.story_item('data');
      var plugin = wikimate.plugins[item.type];
      return plugin.edit.apply($this, [item]);
    }

    function initItem(data) {
      var item = $.extend({id: wikimate.utils.generateId(), type: 'paragraph', text: ''}, data || {});
      var plugin = wikimate.plugins[item.type];
      return plugin.defaultData === undefined ? item : $.extend(item, plugin.defaultData());
    }

    var initActionBar = (function() {
      function createEditLink($this) {
        return $('<a href="javascript:void(0)" title="Click me or double click the content to edit">Edit</a>').on('click', function(e) {
          return $this.parent().story_item('edit');
        });
      }
      function createDeleteLink($this) {
        return $('<a href="javascript:void(0)" title="Click me to remove the content">Del</a>').on('click', function(e) {
          return $this.parent().story_item('remove');
        });
      }

      var cursor = {
        grab: function() {
          return this.css('cursor', 'grab').css('cursor', '-moz-grab').css('cursor', '-webkit-grab');
        },
        grabing: function() {
          return this.css('cursor', 'grabbing').css('cursor', '-moz-grabbing').css('cursor', '-webkit-grabbing');
        }
      };
      function createHandle() {
        var handle = $('<div />').addClass('item-handle').extend(cursor).grab();
        return handle.mousedown(function(e) {
          handle.grabing();
        }).mouseup(function() {
          handle.grab();
        });
      }

      return function($this) {
        var bar = $('<div />').addClass('item-action-bar')
          .append(createDeleteLink($this))
          .append(createEditLink($this))
          .append(createHandle());
        return $this.append(bar).hover(function(e) {
          bar.show();
        }, function(e) {
          bar.hide();
        });
      };<commit_msg>add item action bar and remove it when mouse out, instead of show&hide. more clean html elements in item-content<commit_after>(function($) {
  $.plugin('story_item', (function(){
    function renderByPlugin($this) {
      var item = $this.story_item('data');
      var plugin = wikimate.plugins[item.type];
      // add another div inside for removing conflict highlighting with text area
      // after changed to edit mode
      // it's also easier to keep item div element clean
      var content = $('<div />').addClass('item-content');
      plugin.emit.apply($this, [content, item]);
      plugin.bind.apply($this, [content, item]);
      initActionBar(content);
      return $this.html(content);
    }

    function editByPlugin($this) {
      var item = $this.story_item('data');
      var plugin = wikimate.plugins[item.type];
      return plugin.edit.apply($this, [item]);
    }

    function initItem(data) {
      var item = $.extend({id: wikimate.utils.generateId(), type: 'paragraph', text: ''}, data || {});
      var plugin = wikimate.plugins[item.type];
      return plugin.defaultData === undefined ? item : $.extend(item, plugin.defaultData());
    }

    var initActionBar = (function() {
      function createEditLink($this) {
        return $('<a href="javascript:void(0)" title="Click me or double click the content to edit">Edit</a>').on('click', function(e) {
          return $this.parent().story_item('edit');
        });
      }
      function createDeleteLink($this) {
        return $('<a href="javascript:void(0)" title="Click me to remove the content">Del</a>').on('click', function(e) {
          return $this.parent().story_item('remove');
        });
      }

      var cursor = {
        grab: function() {
          return this.css('cursor', 'grab').css('cursor', '-moz-grab').css('cursor', '-webkit-grab');
        },
        grabing: function() {
          return this.css('cursor', 'grabbing').css('cursor', '-moz-grabbing').css('cursor', '-webkit-grabbing');
        }
      };
      function createHandle() {
        var handle = $('<div />').addClass('item-handle').extend(cursor).grab();
        return handle.mousedown(function(e) {
          handle.grabing();
        }).mouseup(function() {
          handle.grab();
        });
      }

      return function($this) {
        return $this.hover(function(e) {
          var bar = $('<div />').addClass('item-action-bar')
            .append(createDeleteLink($this))
            .append(createEditLink($this))
            .append(createHandle());
          $this.append(bar);
        }, function(e) {
          $this.find('.item-action-bar').remove();
        });
      };
{'fraction_non_alphanumeric': 0.17470689986546223, 'fraction_numerical': 0.000768787238131847, 'mean_word_length': 2.5939226519337018, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '7279882', 'n_tokens_mistral': 1497, 'n_tokens_neox': 1474, 'n_words': 326}