diff --git a/src/aria/widgets/CfgBeans.js b/src/aria/widgets/CfgBeans.js index 1ab7a68a7..544aae951 100644 --- a/src/aria/widgets/CfgBeans.js +++ b/src/aria/widgets/CfgBeans.js @@ -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." diff --git a/src/aria/widgets/form/MultiAutoComplete.js b/src/aria/widgets/form/MultiAutoComplete.js index 2eb948668..ae285a1f1 100644 --- a/src/aria/widgets/form/MultiAutoComplete.js +++ b/src/aria/widgets/form/MultiAutoComplete.js @@ -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); diff --git a/src/aria/widgets/form/TextInput.js b/src/aria/widgets/form/TextInput.js index c7787942a..f8958bee0 100644 --- a/src/aria/widgets/form/TextInput.js +++ b/src/aria/widgets/form/TextInput.js @@ -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); + } }, /** diff --git a/test/aria/widgets/form/textinput/TextInputTestSuite.js b/test/aria/widgets/form/textinput/TextInputTestSuite.js index a3d93f4d2..55923c869 100644 --- a/test/aria/widgets/form/textinput/TextInputTestSuite.js +++ b/test/aria/widgets/form/textinput/TextInputTestSuite.js @@ -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", diff --git a/test/aria/widgets/form/textinput/onblur/OnBlurTemplate.tpl b/test/aria/widgets/form/textinput/onblur/OnBlurTemplate.tpl new file mode 100644 index 000000000..2f398be9a --- /dev/null +++ b/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} diff --git a/test/aria/widgets/form/textinput/onblur/OnBlurTest.js b/test/aria/widgets/form/textinput/onblur/OnBlurTest.js new file mode 100644 index 000000000..833afc3c7 --- /dev/null +++ b/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(); + } + } +}); diff --git a/test/aria/widgets/form/textinput/onclick/OnClickTemplate.tpl b/test/aria/widgets/form/textinput/onclick/OnClickTemplate.tpl index 4edf78618..c26dda459 100644 --- a/test/aria/widgets/form/textinput/onclick/OnClickTemplate.tpl +++ b/test/aria/widgets/form/textinput/onclick/OnClickTemplate.tpl @@ -72,6 +72,12 @@ onclick:{fn:onaction} }/} + {@aria:MultiAutoComplete { + id: "mac", + resourcesHandler: this.airlinesHandler, + onclick:{fn:onaction} + }/} + diff --git a/test/aria/widgets/form/textinput/onclick/OnClickTest.js b/test/aria/widgets/form/textinput/onclick/OnClickTest.js index f82118922..5db5ab2a2 100644 --- a/test/aria/widgets/form/textinput/onclick/OnClickTest.js +++ b/test/aria/widgets/form/textinput/onclick/OnClickTest.js @@ -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 : { diff --git a/test/aria/widgets/form/textinput/onfocus/OnFocusTemplate.tpl b/test/aria/widgets/form/textinput/onfocus/OnFocusTemplate.tpl index 78c8bf609..539181136 100644 --- a/test/aria/widgets/form/textinput/onfocus/OnFocusTemplate.tpl +++ b/test/aria/widgets/form/textinput/onfocus/OnFocusTemplate.tpl @@ -72,6 +72,13 @@ onfocus:{fn:onaction} }/} + {@aria:MultiAutoComplete { + id: "mac", + resourcesHandler: this.airlinesHandler, + onfocus:{fn:onaction} + }/} + +