<commit_before>/**
 * ownCloud - Sketch
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author <NAME> <<EMAIL>>
 * @copyright <NAME> 2015
 */

define(function(require) {
	'use strict';

	var Marionette = require('marionette');

	return Marionette.ItemView.extend({
		tagName: 'li',
		className: 'with-menu',
		menuOpened: false,
		isEditing: false,
		template: '#sketch-list-item-template',
		templateHelpers: function() {
			var that = this;
			return {
				menuOpened: function() {
					return that.menuOpened;
				},
				isEditing: function() {
					return that.isEditing;
				}
			};
		},
		ui: {
			'menuButton': '.app-navigation-entry-utils-menu-button',
			'renameButton': '.rename-sketch',
			'nameInput': 'input[type=text]',
			'form': '.edit-form',
			'submitButton': 'input[type=submit]',
			'deleteButton': '.delete-sketch'
		},
		events: {
			'click': 'onClick',
			'click @ui.menuButton': 'onClickMenu',
			'click @ui.renameButton': 'onClickEdit',
			'click @ui.nameInput': 'onClickInput',
			'submit @ui.form': 'onEditSubmit',
			'click @ui.submitButton': 'onEditSubmit',
			'click @ui.deleteButton': 'onDelete'
		},
		initialize: function() {
			this.listenTo(require('app'), 'sketch:active', this.setActive);
			this.listenTo(require('app'), 'sketch:edit', this.onEdit);
		},
		onBeforeDestroy: function() {
			this.stopListening();
		},
		setActive: function(activeId) {
			if (activeId === this.model.get('id')) {
				this.$el.addClass('active');
			} else {
				this.$el.removeClass('active');
				this.menuOpened = false;
				this.isEditing = false;
				this.render();
			}
		},
		onClick: function(e) {
			e.stopPropagation();
			e.preventDefault();
			require('app').trigger('sketch:show', this.model.get('id'));
		},
		onClickMenu: function(e) {
			e.stopPropagation();
			this.menuOpened = !this.menuOpened;
			this.render();
		},
		onClickEdit: function(e) {
			e.stopPropagation();
			this.menuOpened = false;
			this.isEditing = true;
			this.render();
			this.ui.nameInput.select();
		},
		onClickInput: function(e) {
			e.stopPropagation();
		},
		onEditSubmit: function(e) {
			e.preventDefault();
<commit_msg>stop event propagation on form submit fixes #24<commit_after>/**
 * ownCloud - Sketch
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author <NAME> <<EMAIL>>
 * @copyright <NAME> 2015
 */

define(function(require) {
	'use strict';

	var Marionette = require('marionette');

	return Marionette.ItemView.extend({
		tagName: 'li',
		className: 'with-menu',
		menuOpened: false,
		isEditing: false,
		template: '#sketch-list-item-template',
		templateHelpers: function() {
			var that = this;
			return {
				menuOpened: function() {
					return that.menuOpened;
				},
				isEditing: function() {
					return that.isEditing;
				}
			};
		},
		ui: {
			'menuButton': '.app-navigation-entry-utils-menu-button',
			'renameButton': '.rename-sketch',
			'nameInput': 'input[type=text]',
			'form': '.edit-form',
			'submitButton': 'input[type=submit]',
			'deleteButton': '.delete-sketch'
		},
		events: {
			'click': 'onClick',
			'click @ui.menuButton': 'onClickMenu',
			'click @ui.renameButton': 'onClickEdit',
			'click @ui.nameInput': 'onClickInput',
			'submit @ui.form': 'onEditSubmit',
			'click @ui.submitButton': 'onEditSubmit',
			'click @ui.deleteButton': 'onDelete'
		},
		initialize: function() {
			this.listenTo(require('app'), 'sketch:active', this.setActive);
			this.listenTo(require('app'), 'sketch:edit', this.onEdit);
		},
		onBeforeDestroy: function() {
			this.stopListening();
		},
		setActive: function(activeId) {
			if (activeId === this.model.get('id')) {
				this.$el.addClass('active');
			} else {
				this.$el.removeClass('active');
				this.menuOpened = false;
				this.isEditing = false;
				this.render();
			}
		},
		onClick: function(e) {
			e.stopPropagation();
			e.preventDefault();
			require('app').trigger('sketch:show', this.model.get('id'));
		},
		onClickMenu: function(e) {
			e.stopPropagation();
			this.menuOpened = !this.menuOpened;
			this.render();
		},
		onClickEdit: function(e) {
			e.stopPropagation();
			this.menuOpened = false;
			this.isEditing = true;
			this.render();
			this.ui.nameInput.select();
		},
		onClickInput: function(e) {
			e.stopPropagation();
		},
		onEditSubmit: function(e) {
			e.preventDefault();
			e.stopPropagation();

{'fraction_non_alphanumeric': 0.17595896520963425, 'fraction_numerical': 0.0026761819803746653, 'mean_word_length': 3.6767466110531806, 'pattern_counts': {'":': 0, '<': 11, '<?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': '1429079', 'n_tokens_mistral': 1824, 'n_tokens_neox': 1565, 'n_words': 296}