Autoselect for HTML Text Input #272

Closed
wants to merge 1 commit into
from

Projects

None yet

2 participants

@fab-b
Contributor
fab-b commented Dec 11, 2012

No description provided.

@divdavem divdavem was assigned Dec 14, 2012
@divdavem divdavem commented on an outdated diff Dec 14, 2012
src/aria/html/TextInput.js
@@ -100,7 +118,15 @@
*/
this._reactOnType = this._registerType(cfg.on, context);
- this._registerBlur(cfg.on, context);
+ this._registerListeners(cfg, context);
+
+ /**
+ * Flag set to false after first focus, and set back to true after a blur. Used for the autoselect behaviour.
+ * This value is true when the field receives focus for the first time (user action) and false when the focus is
+ * giveng programmatically by the controller
@divdavem
divdavem Dec 14, 2012 Member

Should be 'given' instead of 'giveng'

@divdavem divdavem commented on an outdated diff Dec 14, 2012
src/aria/html/TextInput.js
+ if (this._firstFocus) {
+ // this allow to click again and put the cursor at a given
+ // position
+ this._firstFocus = false;
+ var field = this._domElt;
+ var start = 0;
+ var end = (field.value.length) ? field.value.length : 0;
+ if (end) {
+ aria.utils.Caret.setCaretPosition(field, start, end);
+ }
+ }
+ },
+
+ /**
+ * Add special listeners on top of the ones specified in configuration.
+ * @param {aria.html.beans.TextInputCfg.Properties} listeners On listeners taken from the widget configuration.
@divdavem
divdavem Dec 14, 2012 Member

JSDoc has to be updated: the first parameter is now the whole configuration and not only 'On' listeners.

@divdavem divdavem commented on an outdated diff Dec 14, 2012
src/aria/html/beans/TextInputCfg.js
@@ -53,6 +53,11 @@ Aria.beanDefinitions({
$type : "json:Boolean",
$description : "Whether the input field should be of type password.",
$default : false
+ },
+ "autoselect" : {
+ $type : "json:Boolean",
+ $description : "Autoselect for the input field.",
@divdavem
divdavem Dec 14, 2012 Member

I think the description should describe the feature more precisely. For example: "If true, the whole field is automatically selected when the user clicks on it."

@divdavem divdavem commented on an outdated diff Dec 14, 2012
src/aria/utils/Caret.js
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
@divdavem
divdavem Dec 14, 2012 Member

There seems to be a formatting issue with the license header.

@divdavem divdavem added a commit to divdavem/ariatemplates that referenced this pull request Dec 17, 2012
@fab-b @divdavem fab-b + divdavem feat #272 Autoselect feature for HTML text input bbed68b
@divdavem
Member

👍
Integrated in bbed68b.

@divdavem divdavem closed this Dec 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment