@osimatic/helpers-js 1.0.21 → 1.0.22

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.
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$" />
5
+ <orderEntry type="inheritedJdk" />
6
+ <orderEntry type="sourceFolder" forTests="false" />
7
+ </component>
8
+ </module>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/helpers-js.iml" filepath="$PROJECT_DIR$/.idea/helpers-js.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
package/form_helper.js CHANGED
@@ -72,7 +72,7 @@ class FormHelper {
72
72
 
73
73
  var input = form.find('[name="'+key+'"]');
74
74
 
75
- if (input.prop('type') == 'radio' || input.prop('type') == 'checkbox') {
75
+ if (input.prop('type') === 'radio' || input.prop('type') === 'checkbox') {
76
76
  input.prop('checked', false);
77
77
  input.filter('[value="'+value+'"]').prop('checked', true);
78
78
  return;
@@ -187,8 +187,8 @@ class FormHelper {
187
187
  }
188
188
 
189
189
  static getFormErrorText(errors) {
190
- var errorLabels = '';
191
- for (var property in errors) {
190
+ let errorLabels = '';
191
+ for (let property in errors) {
192
192
  if (typeof errors[property] != 'function') {
193
193
  errorLabels += '<span>' + errors[property] + '</span><br>';
194
194
  }
@@ -197,8 +197,8 @@ class FormHelper {
197
197
  }
198
198
 
199
199
  static getFormErrorTextBis(errors) {
200
- var errorLabels = '';
201
- for (var property in errors) {
200
+ let errorLabels = '';
201
+ for (let property in errors) {
202
202
  // console.log(property);
203
203
  if (typeof errors[property] != 'function') {
204
204
  if (typeof errors[property]['error_description'] === 'undefined') {
@@ -211,8 +211,8 @@ class FormHelper {
211
211
  return errorLabels;
212
212
  }
213
213
 
214
- static displayFormErrors(form, btnSubmit, errors) {
215
- this.displayFormErrorsFromText(form, this.getFormErrorTextBis(errors));
214
+ static displayFormErrors(form, btnSubmit, errors, errorWrapperDiv) {
215
+ this.displayFormErrorsFromText(form, this.getFormErrorTextBis(errors), errorWrapperDiv);
216
216
  if (btnSubmit != null) {
217
217
  if (btnSubmit.buttonLoader != null) {
218
218
  btnSubmit.buttonLoader('reset');
@@ -226,20 +226,25 @@ class FormHelper {
226
226
  this.displayFormErrors(form, btnSubmit, xhr.responseJSON);
227
227
  }
228
228
 
229
- static displayFormErrorsFromText(form, errorLabels) {
230
- var errorDiv = '<div class="alert alert-danger form_errors">'+errorLabels+'</div>';
231
- var errorsParentDiv = form;
229
+ static displayFormErrorsFromText(form, errorLabels, errorWrapperDiv) {
230
+ let errorDiv = '<div class="alert alert-danger form_errors">'+errorLabels+'</div>';
231
+
232
+ if (typeof errorWrapperDiv != 'undefined' && errorWrapperDiv != null) {
233
+ errorWrapperDiv.append(errorDiv);
234
+ return;
235
+ }
232
236
 
233
237
  if (form.find('.form_errors_content').length) {
234
238
  form.find('.form_errors_content').append(errorDiv);
235
239
  return;
236
240
  }
237
241
 
242
+ let errorsParentDiv = form;
238
243
  if (form.find('.modal-body').length) {
239
244
  errorsParentDiv = form.find('.modal-body');
240
245
  }
241
246
 
242
- var firstFormGroup = errorsParentDiv.find('.form-group:first');
247
+ let firstFormGroup = errorsParentDiv.find('.form-group:first');
243
248
  if (firstFormGroup.length) {
244
249
  if (firstFormGroup.parent().parent().hasClass('row')) {
245
250
  firstFormGroup.parent().parent().before(errorDiv);
package/media.js CHANGED
@@ -88,10 +88,8 @@ class UserMedia {
88
88
  const browserName = browser.getBrowserName();
89
89
 
90
90
  navigator.mediaDevices.getUserMedia(constraints !== 'undefined' ? constraints : { audio: true, video: true })
91
- .then((stream) => {
92
- //stream.getTracks().forEach((track) => track.stop());
93
- resolve(stream);
94
- }).catch((error) => {
91
+ .then((stream) => resolve(stream))
92
+ .catch((error) => {
95
93
  const errName = error.name;
96
94
  const errMessage = error.message;
97
95
  let errorType = "Generic";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"