@@ -135,7 +135,9 @@ module.exports = {
135135 type : "input" ,
136136 inputType : "range" ,
137137 label : "Range" ,
138- model : "age" ,
138+ model : "rank" ,
139+ min : 0 ,
140+ max : 10 ,
139141 styleClasses : "half-width"
140142} ,
141143{
@@ -272,11 +274,63 @@ module.exports = {
272274 rows : 4 ,
273275 validator : validators . string
274276} ,
277+ {
278+ type : "text" ,
279+ label : "Field with buttons" ,
280+ model : "address.geo" ,
281+ disabled : false ,
282+ get ( model ) {
283+ if ( model && model . address && model . address . geo )
284+ return model . address . geo . latitude + ", " + model . address . geo . longitude ;
285+ } ,
286+ set ( model , val ) {
287+ let values = val . split ( "," ) ;
288+ if ( ! model . address )
289+ model . address = { } ;
290+ if ( ! model . address . geo )
291+ model . address . geo = { } ;
292+ if ( values . length > 0 && values [ 0 ] . trim ( ) != "" )
293+ model . address . geo . latitude = parseFloat ( values [ 0 ] . trim ( ) ) ;
294+ else
295+ model . address . geo . latitude = 0
296+ if ( values . length > 1 && values [ 1 ] . trim ( ) != "" )
297+ model . address . geo . longitude = parseFloat ( values [ 1 ] . trim ( ) ) ;
298+ else
299+ model . address . geo . longitude = 0
300+ } ,
301+ buttons : [ {
302+ classes : "btn-location" ,
303+ label : "Current location" ,
304+ onclick : function ( model ) {
305+ if ( navigator . geolocation ) {
306+ navigator . geolocation . getCurrentPosition ( ( pos ) => {
307+ if ( ! model . address )
308+ model . address = { } ;
309+ if ( ! model . address . geo )
310+ model . address . geo = { } ;
311+ model . address . geo . latitude = pos . coords . latitude . toFixed ( 5 ) ;
312+ model . address . geo . longitude = pos . coords . longitude . toFixed ( 5 ) ;
313+ } ) ;
314+ } else {
315+ alert ( "Geolocation is not supported by this browser." ) ;
316+ }
317+ }
318+ } , {
319+ classes : "btn-clear" ,
320+ label : "Clear" ,
321+ onclick : function ( model ) {
322+ model . address . geo = {
323+ latitude : 0 ,
324+ longitude : 0
325+ } ;
326+ }
327+ } ]
328+ } ,
275329{
276330 type : "staticMap" ,
277331 label : "Map" ,
278332 model : "address.geo" ,
279- visible : true ,
333+ visible : false ,
280334 staticMapOptions : {
281335 lat : "latitude" ,
282336 lng : "longitude" ,
@@ -503,7 +557,7 @@ module.exports = {
503557 format : "YYYY-MM-DD"
504558 } ,
505559 onChanged ( model , newVal , oldVal , field ) {
506- model . age = moment ( ) . year ( ) - moment ( newVal ) . year ( ) ;
560+ // model.age = moment().year() - moment(newVal).year();
507561 }
508562} ,
509563{
0 commit comments