<commit_before>ne.util.defineNamespace('ne.component');

ne.component.Layout = ne.util.defineClass({
	init: function(opitons, $element) {
		this.$element = $element;
		this._makeGroup(opitons.grouplist);
		this._makeDragAndDrop(opitons.guideHTML);
		this._setEvents();
	},

	/**
	 * make group
	 * @param {array} grouplist list of group options
	 **/
	_makeGroup: function(grouplist) {
		var group;
		this.groups = {};

		ne.util.forEach(grouplist, function(item) {
			group = this.groups[item.id] = new ne.component.Layout.Group(item);
			this.$element.append(group.$element);
		}, this);
	},

	/**
	 * @param {(string|object)} object group item id or information to find group
	 **/
	_getGroup: function(group) {
		if (ne.util.isObject(group)) {
			if (group.attr('data-group')) {
				group = group.attr('data-group');
			} else {
				group = group.parent().attr('data-group');
			}
		}
		return this.groups[group];
	},

	/**
	 * make drag and drop event
	 * @param {string} [guideHTML] guide element html
	 **/
	_makeDragAndDrop: function(guideHTML) {
		this._drag = new ne.component.Layout.Drag({
			guideHTML: guideHTML
		});
	},

	/**
	 * set Events
	 **/
	_setEvents: function() {
		this.onMouseDown = $.proxy(this._onMouseDown, this);
		this.onMouseMove = $.proxy(this._onMouseMove, this);
		this.onMouseUp = $.proxy(this._onMouseUp, this);
		$('.drag-item-move').on('mousedown', this.onMouseDown);
	},

	/**
	 * mouse down event handler
	 * @param {JqueryEvent} e event object
	 **/
	_onMouseDown: function(e) {
		var initPos = {
			x: e.clientX + this.getX() + 10,
			y: e.clientY + this.getY() + 10
		},
		itemId = $(e.target).attr('data-item'),
		$moveEl = $('#' + itemId);
		this._drag.ready(initPos);
		this._drag.setMoveElement($moveEl);
		this.$temp = $moveEl;
		this.$temp.addClass('drag-clone');
		$(document).on('mousemove', this.onMouseMove);
		$(document).on('mouseup', this.onMouseUp);
	},

	/**
	 * mouse move handler
	 * @param {JqueryEvent} e event object
	 **/
	_onMouseMove: function(e) {		
		var parent = $(e.target).parent(),
			x = this.getX(),
			y = this.getY(),
			pointX = e.clientX + this.getX(),
			pointY = e.clientY + this.getY(),
			drag = this._drag,
			group = parent.attr('data-group'),
			groupInst,
			$before;

		this._moveGuide(pointX, pointY);

		if (!group) {
			return;
		}

		groupInst = this._getGroup(group);

		if (ne.util.isEmpty(groupInst.list)) {
			parent.append(this.$temp);
			this.$temp.way = 'after';
			this.$temp.index = 0;<commit_msg>layout<commit_after>ne.util.defineNamespace('ne.component');

ne.component.Layout = ne.util.defineClass({
	init: function(opitons, $element) {
		this.$element = $element;
		this._makeGroup(opitons.grouplist);
		this._makeDragAndDrop(opitons.guideHTML);
		this._setEvents();
	},

	/**
	 * make group
	 * @param {array} grouplist list of group options
	 **/
	_makeGroup: function(grouplist) {
		var group;
		this.groups = {};

		ne.util.forEach(grouplist, function(item) {
			group = this.groups[item.id] = new ne.component.Layout.Group(item);
			this.$element.append(group.$element);
		}, this);
	},

	/**
	 * @param {(string|object)} object group item id or information to find group
	 **/
	_getGroup: function(group) {
		if (ne.util.isObject(group)) {
			if (group.attr('data-group')) {
				group = group.attr('data-group');
			} else {
				group = group.parent().attr('data-group');
			}
		}
		return this.groups[group];
	},

	/**
	 * make drag and drop event
	 * @param {string} [guideHTML] guide element html
	 **/
	_makeDragAndDrop: function(guideHTML) {
		this._drag = new ne.component.Layout.Drag({
			guideHTML: guideHTML
		});
	},

	/**
	 * set Events
	 **/
	_setEvents: function() {
		this.onMouseDown = $.proxy(this._onMouseDown, this);
		this.onMouseMove = $.proxy(this._onMouseMove, this);
		this.onMouseUp = $.proxy(this._onMouseUp, this);
		$('.drag-item-move').on('mousedown', this.onMouseDown);
	},

	/**
	 * mouse down event handler
	 * @param {JqueryEvent} e event object
	 **/
	_onMouseDown: function(e) {
		var initPos = {
			x: e.clientX + this.getX() + 10,
			y: e.clientY + this.getY() + 10
		},
		itemId = $(e.target).attr('data-item'),
		$moveEl = $('#' + itemId);
		this._drag.ready(initPos);
		this._drag.setMoveElement($moveEl);
		this.$temp = $moveEl;
		this.$temp.addClass('drag-clone');
		$(document).on('mousemove', this.onMouseMove);
		$(document).on('mouseup', this.onMouseUp);
	},

	/**
	 * mouse move handler
	 * @param {JqueryEvent} e event object
	 **/
	_onMouseMove: function(e) {		
		var parent = $(e.target).parent(),
			pointX = e.clientX + this.getX(),
			pointY = e.clientY + this.getY(),
			group = parent.attr('data-group'),
			groupInst,
			$before;

		this._moveGuide(pointX, pointY);

		if (!group) {
			return;
		}

		groupInst = this._getGroup(group);

		if (ne.util.isEmpty(groupInst.list)) {
			parent.append(this.$temp);
			this.$temp.way = 'after';
			this.$temp.index = 0;
{'fraction_non_alphanumeric': 0.18246397402070225, 'fraction_numerical': 0.0020296326364927946, 'mean_word_length': 3.5377532228360957, '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': '6560260', 'n_tokens_mistral': 1993, 'n_tokens_neox': 1745, 'n_words': 327}