fix #261 #264 html TextInput widget enhancement #265

Closed
wants to merge 2 commits into from
View
2 src/aria/html/TextInput.js
@@ -90,7 +90,7 @@
cfg.tagName = "input";
cfg.attributes = cfg.attributes || {};
- cfg.attributes.type = "text";
+ cfg.attributes.type = (cfg.password) ? "password" : "text";
cfg.on = cfg.on || {};
/**
View
11 src/aria/html/beans/TextInputCfg.js
@@ -17,6 +17,7 @@ Aria.beanDefinitions({
$package : "aria.html.beans.TextInputCfg",
$description : "Configuration for Text Input widget.",
$namespaces : {
+ "json" : "aria.core.JsonTypes",
"base" : "aria.html.beans.ElementCfg",
"common" : "aria.widgetLibs.CommonBeans"
},
@@ -25,6 +26,11 @@ Aria.beanDefinitions({
$type : "base:Properties",
$description : "Properties of a Text Input widget.",
$properties : {
+ "tagName" : {
+ $type : "base:Properties.$properties.tagName",
+ $description : "Automatically set to input by the framework. It cannot be overridden in the configuration.",
+ $mandatory : true
+ },
"bind" : {
$type : "base:Properties.$properties.bind",
$properties : {
@@ -42,6 +48,11 @@ Aria.beanDefinitions({
$description : "Callback called when the user types inside the input. It corresponds to a keydown."
}
}
+ },
+ "password" : {
+ $type : "json:Boolean",
+ $description : "Whether the input field should be of type password.",
+ $default : false
}
}
}
View
1 test/aria/html/HTMLTestSuite.js
@@ -25,6 +25,7 @@ Aria.classDefinition({
this.addTests("test.aria.html.ElementEventsTest");
this.addTests("test.aria.html.TextInputBindTest");
this.addTests("test.aria.html.TextInputOnTypeTest");
+ this.addTests("test.aria.html.TextInputPasswordTest");
this.addTests("test.aria.html.controllers.suggestions.ResourcesHandlerTest");
}
View
77 test/aria/html/TextInputPasswordTest.js
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2012 Amadeus s.a.s.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+Aria.classDefinition({
+ $classpath : "test.aria.html.TextInputPasswordTest",
+ $extends : "aria.jsunit.TestCase",
+ $dependencies : ["aria.html.TextInput"],
+ $prototype : {
+
+ createMockMarkupWriter : function () {
+ var buffer = [];
+ return {
+ write : function (markup) {
+ buffer.push(markup);
+ },
+
+ getMarkup : function () {
+ return buffer.join("");
+ }
+ };
+ },
+
+ /**
+ * Verify that a correctly defined widget with password set to true works fine
+ */
+ testPasswordMarkup : function () {
+ // tag name should be ignored
+ var cfg = {
+ password : true,
+ attributes : {
+ name : "division",
+ classList : ["a", "b"],
+ type : "text"
+ }
+ };
+
+ var widget = new aria.html.TextInput(cfg, {
+ tplClasspath : "TextInput"
+ });
+ widget._id = "x";
+ widget.__originalDelegateId = widget.__delegateId;
+ widget.__delegateId = "y";
+
+ // This one when we use it a closing tag
+ this.checkMarkup(widget);
+
+ widget.__delegateId = widget.__originalDelegateId;
+
+ widget.$dispose();
+ },
+
+ /**
+ * Markup
+ */
+ checkMarkup : function (widget) {
+ var out = this.createMockMarkupWriter();
+
+ widget.writeMarkup(out);
+
+ var markup = out.getMarkup();
+ this.assertEquals("<input id='x' name=\"division\" class=\"a b\" type=\"password\" atdelegate='y' />", markup, "Markup: <xmp>"
+ + markup + "</xmp>");
+ }
+ }
+});