@@ -68,7 +68,7 @@ qx.Class.define("osparc.ui.form.IntlTelInput", {
6868 members : {
6969 __htmlId : null ,
7070 __inputElement : null ,
71- __itiInput : null ,
71+ __intlTelInput : null ,
7272
7373 _createChildControlImpl : function ( id ) {
7474 let control ;
@@ -88,13 +88,13 @@ qx.Class.define("osparc.ui.form.IntlTelInput", {
8888
8989 // IStringForm interface implementation
9090 getValue : function ( ) {
91- return this . __itiInput ? this . __itiInput . getNumber ( ) : null ;
91+ return this . __intlTelInput ? this . __intlTelInput . getNumber ( ) : null ;
9292 } ,
9393
9494 setValue : function ( value ) {
95- if ( this . __itiInput && value ) {
95+ if ( this . __intlTelInput && value ) {
9696 // intlTelInput doesn't have a full setter for raw numbers
97- this . __itiInput . setNumber ( value ) ;
97+ this . __intlTelInput . setNumber ( value ) ;
9898 }
9999 this . _applyValue ( value ) ;
100100 } ,
@@ -130,7 +130,7 @@ qx.Class.define("osparc.ui.form.IntlTelInput", {
130130 } ,
131131
132132 isValidNumber : function ( ) {
133- return this . __itiInput ? this . __itiInput . isValidNumber ( ) : false ;
133+ return this . __intlTelInput ? this . __intlTelInput . isValidNumber ( ) : false ;
134134 } ,
135135
136136 verifyPhoneNumber : function ( ) {
@@ -144,7 +144,7 @@ qx.Class.define("osparc.ui.form.IntlTelInput", {
144144 alignY : "middle" ,
145145 } ) ;
146146 if ( ! isValid ) {
147- const validationError = this . __itiInput . getValidationError ( ) ;
147+ const validationError = this . __intlTelInput . getValidationError ( ) ;
148148 const errorMap = {
149149 0 : this . tr ( "Invalid number" ) ,
150150 1 : this . tr ( "Invalid country code" ) ,
@@ -160,28 +160,26 @@ qx.Class.define("osparc.ui.form.IntlTelInput", {
160160 } ,
161161
162162 __updateStyle : function ( ) {
163- const phoneNumber = this . getChildControl ( "phone-input-field" ) ;
164- const itiInput = this . __itiInput ;
165- const feedbackIcon = this . getChildControl ( "feedback-icon" ) ;
166163 const isCompact = this . isCompactField ( ) ;
167-
168164 const textColor = qx . theme . manager . Color . getInstance ( ) . resolve ( "text" ) ;
169165 const bgColor = qx . theme . manager . Color . getInstance ( ) . resolve ( "input_background" ) ;
170166 const productColor = qx . theme . manager . Color . getInstance ( ) . resolve ( "product-color" ) ;
171167 const height = isCompact ? 26 : 30 ;
172168
173- phoneNumber . set ( {
169+ this . getChildControl ( "phone-input-field" ) . set ( {
174170 minWidth : 185 ,
175171 maxHeight : height ,
176172 margin : 0 ,
177173 } ) ;
178174
179- if ( itiInput ) {
180- itiInput . a . style [ "width" ] = feedbackIcon . isVisible ( ) ? "185px" : "215px" ;
181- itiInput . a . style [ "height" ] = height + "px" ;
182- itiInput . a . style [ "borderWidth" ] = "0px" ;
183- itiInput . a . style [ "backgroundColor" ] = isCompact ? "transparent" : bgColor ;
184- itiInput . a . style [ "color" ] = textColor ;
175+ const intlTelInput = this . __intlTelInput ;
176+ const feedbackIcon = this . getChildControl ( "feedback-icon" ) ;
177+ if ( intlTelInput ) {
178+ intlTelInput . a . style [ "width" ] = feedbackIcon . isVisible ( ) ? "185px" : "215px" ;
179+ intlTelInput . a . style [ "height" ] = height + "px" ;
180+ intlTelInput . a . style [ "borderWidth" ] = "0px" ;
181+ intlTelInput . a . style [ "backgroundColor" ] = isCompact ? "transparent" : bgColor ;
182+ intlTelInput . a . style [ "color" ] = textColor ;
185183 }
186184
187185 document . documentElement . style . setProperty ( '--country-list-dropdown-bg' , bgColor ) ;
@@ -192,8 +190,8 @@ qx.Class.define("osparc.ui.form.IntlTelInput", {
192190 __convertInputToPhoneInput : function ( ) {
193191 const convertInputToPhoneInput = ( ) => {
194192 const domElement = document . querySelector ( `#${ this . __htmlId } ` ) ;
193+ this . __convertInputToIntlTelInput ( domElement ) ;
195194 const phoneNumber = this . getChildControl ( "phone-input-field" ) ;
196- this . __itiInput = this . __inputToPhoneInput ( domElement ) ;
197195 phoneNumber . getContentElement ( ) . setStyles ( {
198196 "overflow" : "visible" // needed for countries dropdown menu
199197 } ) ;
@@ -212,9 +210,9 @@ qx.Class.define("osparc.ui.form.IntlTelInput", {
212210 }
213211 } ,
214212
215- __inputToPhoneInput : function ( input ) {
213+ __convertInputToIntlTelInput : function ( input ) {
216214 this . __inputElement = input ; // keep reference to raw <input>
217- const iti = intlTelInput ( input , {
215+ this . __intlTelInput = intlTelInput ( input , {
218216 initialCountry : "auto" ,
219217 geoIpLookup : callback => {
220218 fetch ( "https://ipapi.co/json" )
@@ -226,7 +224,6 @@ qx.Class.define("osparc.ui.form.IntlTelInput", {
226224 dropdownContainer : document . body ,
227225 } ) ;
228226 this . __updateStyle ( ) ;
229- return iti ;
230227 }
231228 }
232229} ) ;
0 commit comments