Skip to content
Snippets Groups Projects
Commit 99b5c69d authored by Rafael Ostertag's avatar Rafael Ostertag
Browse files

Renamed Text.js to Textual.js. Textual now accepts any textual type for <input>

parent b9ecf9e8
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,7 @@ QfqNS.Element = QfqNS.Element || {};
}
if (!$element[0].hasAttribute('type')) {
return new n.Text($element);
return new n.Textual($element);
}
var type = $element[0].getAttribute('type').toLowerCase();
......@@ -41,7 +41,7 @@ QfqNS.Element = QfqNS.Element || {};
case "month":
case "time":
case "week":
return new n.Text($element);
return new n.Textual($element);
default:
throw new Error("Don't know how to handle <input> of type '" + type + "'");
}
......
......@@ -14,25 +14,52 @@ QfqNS.Element = QfqNS.Element || {};
* @param $element
* @constructor
*/
function Text($element) {
function Textual($element) {
n.FormGroup.call(this, $element);
if (!this.isType("text")) {
var textualTypes = [
'text',
'datetime',
'datetime-local',
'date',
'month',
'time',
'week',
'number',
'range',
'email',
'url',
'search',
'tel',
'password',
'hidden'
];
var textualTypesLength = textualTypes.length;
var isTextual = false;
for (var i = 0; i < textualTypesLength; i++) {
if (this.isType(textualTypes[i])) {
isTextual = true;
break;
}
}
if (!isTextual) {
throw new Error("$element is not of type 'text'");
}
}
Text.prototype = Object.create(n.FormGroup.prototype);
Text.prototype.constructor = Text;
Textual.prototype = Object.create(n.FormGroup.prototype);
Textual.prototype.constructor = Textual;
Text.prototype.setValue = function (val) {
Textual.prototype.setValue = function (val) {
this.$element.val(val);
};
Text.prototype.getValue = function () {
Textual.prototype.getValue = function () {
return this.$element.val();
};
n.Text = Text;
n.Textual = Textual;
})(QfqNS.Element);
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment