@osimatic/helpers-js 1.0.19 → 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.
- package/.idea/helpers-js.iml +8 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/form_helper.js +16 -11
- package/media.js +9 -10
- package/package.json +1 -1
|
@@ -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
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')
|
|
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
|
-
|
|
191
|
-
for (
|
|
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
|
-
|
|
201
|
-
for (
|
|
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
|
-
|
|
231
|
-
|
|
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
|
-
|
|
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
|
@@ -84,18 +84,17 @@ class UserMedia {
|
|
|
84
84
|
static requestMediaPermissions(constraints) {
|
|
85
85
|
return new Promise((resolve, reject) => {
|
|
86
86
|
const bowser = require('bowser');
|
|
87
|
-
const browser = bowser.getParser(window.navigator.userAgent)
|
|
87
|
+
const browser = bowser.getParser(window.navigator.userAgent);
|
|
88
|
+
const browserName = browser.getBrowserName();
|
|
88
89
|
|
|
89
90
|
navigator.mediaDevices.getUserMedia(constraints !== 'undefined' ? constraints : { audio: true, video: true })
|
|
90
|
-
.then((stream) =>
|
|
91
|
-
|
|
92
|
-
resolve(stream);
|
|
93
|
-
}).catch((error) => {
|
|
91
|
+
.then((stream) => resolve(stream))
|
|
92
|
+
.catch((error) => {
|
|
94
93
|
const errName = error.name;
|
|
95
94
|
const errMessage = error.message;
|
|
96
95
|
let errorType = "Generic";
|
|
97
96
|
|
|
98
|
-
if (
|
|
97
|
+
if (browserName === 'Chrome') {
|
|
99
98
|
if (errName === 'NotAllowedError') {
|
|
100
99
|
if (errMessage === 'Permission denied by system') {
|
|
101
100
|
errorType = "SystemPermissionDenied";
|
|
@@ -105,17 +104,17 @@ class UserMedia {
|
|
|
105
104
|
} else if (errName === 'NotReadableError') {
|
|
106
105
|
errorType = "CouldNotStartVideoSource";
|
|
107
106
|
}
|
|
108
|
-
} else if (
|
|
107
|
+
} else if (browserName === 'Safari') {
|
|
109
108
|
if (errName === 'NotAllowedError') {
|
|
110
109
|
errorType = "UserPermissionDenied";
|
|
111
110
|
}
|
|
112
|
-
} else if (
|
|
111
|
+
} else if (browserName === 'Microsoft Edge') {
|
|
113
112
|
if (errName === 'NotAllowedError') {
|
|
114
113
|
errorType = "UserPermissionDenied";
|
|
115
114
|
} else if (errName === 'NotReadableError') {
|
|
116
115
|
errorType = "CouldNotStartVideoSource";
|
|
117
116
|
}
|
|
118
|
-
} else if (
|
|
117
|
+
} else if (browserName === 'Firefox') {
|
|
119
118
|
// https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#exceptions
|
|
120
119
|
if (errName === 'NotFoundError') {
|
|
121
120
|
errorType = "SystemPermissionDenied";
|
|
@@ -128,7 +127,7 @@ class UserMedia {
|
|
|
128
127
|
}
|
|
129
128
|
}
|
|
130
129
|
|
|
131
|
-
reject({
|
|
130
|
+
reject({ type: errorType, name: error.name, message: error.message });
|
|
132
131
|
});
|
|
133
132
|
});
|
|
134
133
|
}
|