Skip to content

Commit

Permalink
onBlur support added to TextInput and all the inheriting widgets.
Browse files Browse the repository at this point in the history
onClick support added to MultiAutoComplete
  • Loading branch information
lsimone committed Feb 24, 2014
1 parent 3c38899 commit fc468f5
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/aria/widgets/CfgBeans.js
Expand Up @@ -401,6 +401,10 @@ Aria.beanDefinitions({
$type : "common:Callback",
$description : "Function to be called when the autocomplete receives focus."
},
"onblur" : {
$type : "common:Callback",
$description : "Function to be called when the autocomplete loses focus."
},
"spellCheck" : {
$type : "json:Boolean",
$description : "Specifies whether native spell check from the browser is enabled or not on this field. If null, uses the default behaviour from the browser. If true or false, tries to enable or disable native spell check from the browser."
Expand Down
1 change: 1 addition & 0 deletions src/aria/widgets/form/MultiAutoComplete.js
Expand Up @@ -94,6 +94,7 @@ Aria.classDefinition({
* @protected
*/
_dom_onclick : function (event) {
this.$AutoComplete._dom_onclick.call(this, event);
var element = event.target;
if (element.className === "closeBtn") {
this._removeMultiselectValues(element, event);
Expand Down
4 changes: 3 additions & 1 deletion src/aria/widgets/form/TextInput.js
Expand Up @@ -971,7 +971,9 @@ Aria.classDefinition({
// this._hasFocus = false must be after the call of this.getCaretPosition()
this._hasFocus = false;
}

if (this._cfg.onblur) {
this.evalCallback(this._cfg.onblur);
}
},

/**
Expand Down
1 change: 1 addition & 0 deletions test/aria/widgets/form/textinput/TextInputTestSuite.js
Expand Up @@ -20,6 +20,7 @@ Aria.classDefinition({
this.$TestSuite.constructor.call(this);

this._tests = ["test.aria.widgets.form.textinput.onchange.OnChangeTestCase",
"test.aria.widgets.form.textinput.onblur.OnBlurTest",
"test.aria.widgets.form.textinput.blurvalidation.BlurValidationTestCase",
"test.aria.widgets.form.textinput.quotes.QuotesTestCase",
"test.aria.widgets.form.textinput.onclick.OnClickTest",
Expand Down
86 changes: 86 additions & 0 deletions test/aria/widgets/form/textinput/onblur/OnBlurTemplate.tpl
@@ -0,0 +1,86 @@
/*
* Copyright 2013 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.
*/

{Template {
$classpath : "test.aria.widgets.form.textinput.onblur.OnBlurTemplate",
$extends : "test.aria.widgets.form.textinput.onclick.OnClickTemplate"
}}
{macro main()}

{@aria:TextField {
id: "tf",
onblur:{fn:onaction},
value : "aaa"
}/}

{@aria:NumberField {
id: "nf",
onblur:{fn:onaction},
value : 5
}/}

{@aria:PasswordField {
id: "pf",
onblur:{fn:onaction},
value : "aaa"
}/}

{@aria:DateField {
id: "df",
onblur:{fn:onaction},
value : new Date()
}/}

{@aria:TimeField {
id: "time",
onblur:{fn:onaction}
}/}

{@aria:DatePicker {
id: "dp",
onblur:{fn:onaction},
value : new Date()
}/}

{@aria:AutoComplete {
id: "ac",
resourcesHandler: this.airlinesHandler,
onblur:{fn:onaction}
}/}

{@aria:MultiSelect {
id: "ms",
items: [{value : "a", code : "a"},{value : "b", code : "b"}],
onblur:{fn:onaction}
}/}

{@aria:SelectBox {
id: "sb",
options: [{label : "a", value : "a"},{label : "b", value : "b"}],
onblur:{fn:onaction}
}/}

{@aria:MultiAutoComplete {
id: "mac",
resourcesHandler: this.airlinesHandler,
onblur:{fn:onaction}
}/}





{/macro}
{/Template}
42 changes: 42 additions & 0 deletions test/aria/widgets/form/textinput/onblur/OnBlurTest.js
@@ -0,0 +1,42 @@
/*
* Copyright 2013 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.widgets.form.textinput.onblur.OnBlurTest",
$extends : "test.aria.widgets.form.textinput.onclick.OnClickTest",
$constructor : function () {
this.$OnClickTest.constructor.call(this);
this.setTestEnv({
template : "test.aria.widgets.form.textinput.onblur.OnBlurTemplate",
data : {
action : 0
}
});
this._delay = 10;
},
$prototype : {
runTemplateTest : function () {
this.templateCtxt.$focus(this._widgetIds[0]);
this._currentIndex = 0;
this._testWidget();
},

simulateUserAction : function (index) {
var ix = (index + 1) % this._widgetIds.length;
this.templateCtxt.$focus(this._widgetIds[ix]);
this.onAfterUserAction();
}
}
});
6 changes: 6 additions & 0 deletions test/aria/widgets/form/textinput/onclick/OnClickTemplate.tpl
Expand Up @@ -72,6 +72,12 @@
onclick:{fn:onaction}
}/}

{@aria:MultiAutoComplete {
id: "mac",
resourcesHandler: this.airlinesHandler,
onclick:{fn:onaction}
}/}




Expand Down
2 changes: 1 addition & 1 deletion test/aria/widgets/form/textinput/onclick/OnClickTest.js
Expand Up @@ -26,7 +26,7 @@ Aria.classDefinition({
});
this.defaultTestTimeout = 10000;
this._delay = 200;
this._widgetIds = ["df", "tf", "nf", "pf", "dp", "ac", "ms", "time", "sb"];
this._widgetIds = ["df", "tf", "nf", "pf", "dp", "ac", "ms", "time", "sb", "mac"];
this._currentIndex = null;
},
$prototype : {
Expand Down
7 changes: 7 additions & 0 deletions test/aria/widgets/form/textinput/onfocus/OnFocusTemplate.tpl
Expand Up @@ -72,6 +72,13 @@
onfocus:{fn:onaction}
}/}

{@aria:MultiAutoComplete {
id: "mac",
resourcesHandler: this.airlinesHandler,
onfocus:{fn:onaction}
}/}





Expand Down

0 comments on commit fc468f5

Please sign in to comment.