Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Possibility to call $focus on HTML Text Input #267

Closed
wants to merge 1 commit into from

2 participants

@fab-b
Collaborator

It is possible to provide an id to text input widget of the HTML library and to use it with the $focus method.

@flongo flongo closed this
@flongo flongo referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@flongo flongo referenced this pull request from a commit in flongo/ariatemplates
@flongo flongo feat #268 - Possibility to call $focus on HTML Text Input - fixes and…
… tests

Related to PR #267.
a20033c
@piuccio piuccio referenced this pull request from a commit
@flongo flongo feat #268 - Possibility to call $focus on HTML Text Input - fixes and…
… tests

Related to PR #267.
697c744
@piuccio piuccio referenced this pull request from a commit
@fab-b fab-b feat #267 Possibility to call $focus on HTML Text Input
Conflicts:
	test/aria/html/ElementTest.js
(cherry-picked from 244047c)
7928f88
@piuccio piuccio referenced this pull request from a commit
@flongo flongo feat #268 - Possibility to call $focus on HTML Text Input - fixes and…
… tests

Related to PR #267.
(cherry picked from commit 697c744)

Conflicts:
	test/aria/html/HTMLTestSuite.js
	test/aria/html/textinput/TextInputBindTest.js
	test/aria/html/textinput/TextInputOnTypeTest.js
	test/aria/html/textinput/TextInputPasswordTest.js
	test/aria/html/textinput/TextInputTest.js
cad007d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 10, 2012
  1. @fab-b
This page is out of date. Refresh to see the latest.
View
4 src/aria/html/Element.js
@@ -68,6 +68,10 @@
*/
this._id = this._createDynamicId();
+ if (cfg.id) {
+ this._id = this._id + "_" + cfg.id;
+ }
+
/**
* Reference of the DOM element with id this._id.
* @type HTMLElement
View
27 src/aria/html/TextInput.js
@@ -96,19 +96,26 @@
/**
* Wheter or not this widget has a 'on type' callback
* @protected
- * @param {Boolean}
+ * @type Boolean
*/
this._reactOnType = this._registerType(cfg.on, context);
this._registerBlur(cfg.on, context);
+ /**
+ * Element containing input field
+ * @protected
+ * @type HTMLElement
+ */
+ this._inputText = null;
+
this.$Element.constructor.call(this, cfg, context, line);
},
$destructor : function () {
if (this._typeCallback) {
aria.core.Timer.cancelCallback(this._typeCallback);
}
-
+ this._inputText = null;
this.$Element.$destructor.call(this);
},
$prototype : {
@@ -140,6 +147,7 @@
this._domElt.value = newValue;
}
}
+ this._inputText = aria.utils.Dom.getElementById(this._id);
},
/**
@@ -155,6 +163,21 @@
},
/**
+ * Function to return the id
+ * @return {String} Element id.
+ */
+ getId : function () {
+ return this._cfg.id;
+ },
+
+ /**
+ * Function to assign the focus to input field.
+ */
+ focus : function () {
+ this._inputText.focus();
+ },
+
+ /**
* Convert the special event type into a keydown event listener.
* @param {Object} listeners On listeners taken from the widget configuration.
* @param {aria.templates.TemplateCtxt} context Reference of the template context.
View
4 src/aria/html/beans/ElementCfg.js
@@ -25,6 +25,10 @@ Aria.beanDefinitions({
$type : "json:Object",
$description : "All properties that can be used in Element widget.",
$properties : {
+ "id" : {
+ $type : "json:String",
+ $description : "Element id"
+ },
"tagName" : {
$type : "json:String",
$description : "Qualified name of the Element node",
View
19 test/aria/html/ElementTest.js
@@ -68,6 +68,25 @@ Aria.classDefinition({
var widget = new aria.html.Element(cfg, {
tplClasspath : "Element"
});
+
+ this.assertEquals(widget._id, "w0", "The id is not the id expected");
+ widget.$dispose();
+
+ cfg.id = 'x';
+
+ widget = new aria.html.Element(cfg, {
+ tplClasspath : "Element"
+ });
+
+ this.assertEquals(widget._id, "w0_x", "The id is not the id expected");
+ widget.$dispose();
+
+ delete cfg.id;
+
+ widget = new aria.html.Element(cfg, {
+ tplClasspath : "Element"
+ });
+
widget._id = "x";
// These two functions are called if the widget is used as a container
Something went wrong with that request. Please try again.