@osimatic/helpers-js 1.5.7 → 1.5.9

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/file.js CHANGED
@@ -1,3 +1,4 @@
1
+ const { toEl } = require('./util');
1
2
  const { HTTPClient } = require('./http_client');
2
3
 
3
4
  class File {
@@ -103,6 +104,7 @@ class Img {
103
104
  }
104
105
 
105
106
  static initImg(div) {
107
+ div = toEl(div);
106
108
  div.querySelectorAll('.asynchronously_img').forEach(img => {
107
109
  Img.loadImgUrl(img.dataset.url, img);
108
110
  });
package/form_helper.js CHANGED
@@ -2,6 +2,7 @@ const { toEl } = require('./util');
2
2
 
3
3
  class FormHelper {
4
4
  static init(form, onSubmitCallback, submitButton=null) {
5
+ const wasJQuery = form && form.jquery;
5
6
  form = toEl(form); submitButton = toEl(submitButton);
6
7
  FormHelper.reset(form, submitButton);
7
8
  submitButton = null != submitButton ? submitButton : form.querySelector('button[name="validate"]');
@@ -13,10 +14,11 @@ class FormHelper {
13
14
  onSubmitCallback(form, submitButton);
14
15
  }
15
16
  };
16
- return form;
17
+ return wasJQuery && typeof $ !== 'undefined' ? $(form) : form;
17
18
  }
18
19
 
19
20
  static reset(form, submitButton=null) {
21
+ const wasJQuery = form && form.jquery;
20
22
  form = toEl(form); submitButton = toEl(submitButton);
21
23
  submitButton = null != submitButton ? submitButton : form.querySelector('button[name="validate"]');
22
24
  form.querySelectorAll('input[name]:not([type="checkbox"]):not([type="radio"]), select:not(.selectpicker), textarea').forEach(el => {
@@ -26,7 +28,7 @@ class FormHelper {
26
28
  form.querySelectorAll('select.selectpicker').forEach(el => el.value = '');
27
29
  FormHelper.buttonLoader(submitButton, 'reset');
28
30
  FormHelper.hideFormErrors(form);
29
- return form;
31
+ return wasJQuery && typeof $ !== 'undefined' ? $(form) : form;
30
32
  }
31
33
 
32
34
  static populateForm(form, data) {
package/media.js CHANGED
@@ -1,3 +1,4 @@
1
+ const { toEl } = require('./util');
1
2
  const { FormHelper } = require('./form_helper');
2
3
  const { HTTPClient } = require('./http_client');
3
4
 
@@ -8,6 +9,7 @@ class AudioMedia {
8
9
  }
9
10
 
10
11
  static initPlayLinks(div) {
12
+ div = toEl(div);
11
13
  // Affiche un lecteur audio
12
14
  div.querySelectorAll('.play_link').forEach(link => {
13
15
  link.addEventListener('click', function(e) {
@@ -125,6 +127,7 @@ class AudioMedia {
125
127
 
126
128
  class VideoMedia {
127
129
  static initPlayPauseClick(videoElement) {
130
+ videoElement = toEl(videoElement);
128
131
  videoElement.addEventListener('click', function(e) {
129
132
  // handle click if not Firefox (Firefox supports this feature natively)
130
133
  if (typeof InstallTrigger === 'undefined') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.5.7",
3
+ "version": "1.5.9",
4
4
  "main": "main.js",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -18,6 +18,9 @@
18
18
  "libphonenumber-js": "^1.12.39",
19
19
  "ua-parser-js": "^2.0.9"
20
20
  },
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
21
24
  "peerDependencies": {
22
25
  "intl-tel-input": ">=19.0",
23
26
  "leaflet": ">=1.9"
package/paging.js CHANGED
@@ -1,6 +1,3 @@
1
- // Fonction commune de pagination
2
- //Bootstrap class pagination https://getbootstrap.com/docs/3.3/components/#pagination
3
-
4
1
  const { UrlAndQueryString } = require('./network');
5
2
  const { toEl } = require('./util');
6
3