Skip to content

Commit

Permalink
Added preventSubmitOnEnter option. Fixes #270
Browse files Browse the repository at this point in the history
  • Loading branch information
jenssogaard committed Nov 20, 2018
1 parent fdd9407 commit 741cbb3
Show file tree
Hide file tree
Showing 5 changed files with 457 additions and 52 deletions.
156 changes: 108 additions & 48 deletions dist/conversational-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,12 @@ var cf;
/// <reference path="../BasicElement.ts"/>
/// <reference path="../../form-tags/Tag.ts"/>
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
Expand Down Expand Up @@ -1799,6 +1802,13 @@ var cf;
enumerable: true,
configurable: true
});
Object.defineProperty(Tag.prototype, "rows", {
get: function () {
return this.domElement.hasAttribute("rows") ? parseInt(this.domElement.getAttribute("rows")) : 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Tag.prototype, "disabled", {
get: function () {
// a tag is disabled if its conditions are not meet, also if it contains the disabled attribute
Expand Down Expand Up @@ -2467,9 +2477,12 @@ var cf;

/// <reference path="Tag.ts"/>
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
Expand Down Expand Up @@ -2531,9 +2544,12 @@ var cf;

/// <reference path="Tag.ts"/>
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
Expand Down Expand Up @@ -2653,9 +2669,12 @@ var cf;

/// <reference path="Tag.ts"/>
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
Expand Down Expand Up @@ -2686,9 +2705,12 @@ var cf;
/// <reference path="Tag.ts"/>
/// <reference path="../parsing/TagsParser.ts"/>
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
Expand Down Expand Up @@ -2754,9 +2776,12 @@ var cf;

/// <reference path="Tag.ts"/>
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
Expand Down Expand Up @@ -2785,9 +2810,12 @@ var cf;

/// <reference path="ControlElement.ts"/>
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
Expand Down Expand Up @@ -2869,9 +2897,12 @@ var cf;

/// <reference path="Button.ts"/>
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
Expand Down Expand Up @@ -2931,9 +2962,12 @@ var cf;

/// <reference path="Button.ts"/>
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
Expand Down Expand Up @@ -2991,9 +3025,12 @@ var cf;

/// <reference path="Button.ts"/>
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
Expand Down Expand Up @@ -3155,9 +3192,12 @@ var cf;
/// <reference path="Button.ts"/>
/// <reference path="../../logic/Helpers.ts"/>
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
Expand Down Expand Up @@ -3814,9 +3854,12 @@ var cf;
/// <reference path="../../logic/FlowManager.ts"/>
/// <reference path="../../interfaces/IUserInput.ts"/>
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
Expand Down Expand Up @@ -3985,9 +4028,12 @@ var cf;
/// <reference path="UserInputElement.ts"/>
/// <reference path="UserInputSubmitButton.ts"/>
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
Expand Down Expand Up @@ -4280,6 +4326,10 @@ var cf;
else {
this.el.classList.remove("hide-input");
}
// Set rows attribute if present
if (this._currentTag.rows && this._currentTag.rows > 1) {
this.inputElement.setAttribute('rows', this._currentTag.rows.toString());
}
if (cf.UserInputElement.hideUserInputOnNoneTextInput) {
// toggle userinput hide
if (this.controlElements.active) {
Expand Down Expand Up @@ -4493,6 +4543,8 @@ var cf;
};
UserTextInput.prototype.resetValue = function () {
this.inputElement.value = "";
if (this.inputElement.hasAttribute('rows'))
this.inputElement.setAttribute('rows', '1');
this.onInputChange();
};
UserTextInput.prototype.dealloc = function () {
Expand Down Expand Up @@ -4527,9 +4579,12 @@ var cf;
/// <reference path="../../ConversationalForm.ts"/>
/// <reference path="../../interfaces/IUserInterfaceOptions.ts"/>
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
Expand Down Expand Up @@ -4866,9 +4921,12 @@ var cf;
/// <reference path="../BasicElement.ts"/>
/// <reference path="../../logic/FlowManager.ts"/>
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
Expand Down Expand Up @@ -4958,6 +5016,8 @@ var cf;
this.onInputElementChanged();
};
ChatList.prototype.onInputElementChanged = function () {
if (!this.cfReference || !this.cfReference.el)
return;
var cfHeight = this.cfReference.el.offsetHeight;
var inputHeight = this.input.height;
var listHeight = cfHeight - inputHeight;
Expand Down Expand Up @@ -5575,7 +5635,7 @@ var cf;
var tag = indexesToRemove[i];
this.tags.splice(this.tags.indexOf(tag), 1);
}
if (!this.tags || this.tags.length == 0) {
if (!ConversationalForm.suppressLog && (!this.tags || this.tags.length == 0)) {
console.warn("Conversational Form: No tags found or registered.");
}
//let's start the conversation
Expand Down Expand Up @@ -5675,7 +5735,7 @@ var cf;
// remove the tags as they are now apart of a group
for (var i = 0; i < groups[group].length; i++) {
var tagToBeRemoved = groups[group][i];
if (i == 0)
if (i == 0) // add the group at same index as the the first tag to be removed
tags.splice(tags.indexOf(tagToBeRemoved), 1, tagGroup);
else
tags.splice(tags.indexOf(tagToBeRemoved), 1);
Expand Down Expand Up @@ -5819,7 +5879,7 @@ var cf;
// doing classic .submit wont trigger onsubmit if that is present on form element
// as described here: http://wayback.archive.org/web/20090323062817/http://blogs.vertigosoftware.com/snyholm/archive/2006/09/27/3788.aspx
// so we mimic a click.
var button = this.formEl.ownerDocument.createElement('input');
var button = this.formEl.ownerDocument.createElement('button');
button.style.display = 'none';
button.type = 'submit';
this.formEl.appendChild(button);
Expand Down
8 changes: 4 additions & 4 deletions dist/conversational-form.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 741cbb3

Please sign in to comment.