@osimatic/helpers-js 1.0.82 → 1.0.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/form_helper.js CHANGED
@@ -13,9 +13,10 @@ class FormHelper {
13
13
  return form;
14
14
  }
15
15
 
16
- static reset(form) {
17
- form.find('[name]').each((idx, el) => $(el).val(''));
18
- FormHelper.buttonLoader(form.find('button'), 'reset');
16
+ static reset(form, submitButton) {
17
+ submitButton = typeof submitButton != 'undefined' && null != submitButton ? submitButton : form.find('button[name="validate"]');
18
+ form.find('input[name]:not([type="checkbox"], [type="radio"]), select, textarea').each((idx, el) => $(el).val('')).off('change');
19
+ FormHelper.buttonLoader(submitButton, 'reset');
19
20
  FormHelper.hideFormErrors(form);
20
21
  return form;
21
22
  }
@@ -300,7 +301,7 @@ class FormHelper {
300
301
  return self;
301
302
  }
302
303
  button.attr('disabled', true);
303
- button.attr('data-btn-text', button.html());
304
+ button.data('btn-text', button.html());
304
305
  //let text = '<span class="spinner"><i class=\'fa fa-circle-notch fa-spin\'></i></span>Traitement en cours…';
305
306
  let text = '<i class=\'fa fa-circle-notch fa-spin\'></i> Traitement en cours…';
306
307
  if (button.data('load-text') != undefined && button.data('load-text') != null && button.data('load-text') != '') {
@@ -313,7 +314,7 @@ class FormHelper {
313
314
  button.addClass('disabled');
314
315
  }
315
316
  if (action === 'stop' || action === 'reset') {
316
- button.html(button.attr('data-btn-text'));
317
+ button.html(button.data('btn-text'));
317
318
  button.removeClass('disabled');
318
319
  button.attr('disabled', false);
319
320
  //button.removeAttr("disabled");
package/location.js CHANGED
@@ -288,6 +288,23 @@ class Country {
288
288
  }
289
289
 
290
290
  class PostalAddress {
291
+ static setAutocomplete(input, onPlaceChanged) {
292
+ let autocomplete = new google.maps.places.Autocomplete(
293
+ input[0],
294
+ {types: ['geocode']}
295
+ );
296
+ //console.log(autocomplete);
297
+
298
+ // When the user selects an address from the dropdown, populate the address fields in the form.
299
+ autocomplete.addListener('place_changed', function() {
300
+ let place = autocomplete.getPlace();
301
+ input.val('');
302
+ if (typeof onPlaceChanged == 'function') {
303
+ onPlaceChanged(place['formatted_address']);
304
+ }
305
+ });
306
+ }
307
+
291
308
  static format(addressData, separator) {
292
309
  if (typeof separator == 'undefined') {
293
310
  separator = '<br/>';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.0.82",
3
+ "version": "1.0.84",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"