@osimatic/helpers-js 1.0.31 → 1.0.34

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/changelog.txt CHANGED
@@ -37,4 +37,9 @@ let httpHeaders = {...} -> HTTPRequest.setHeader(key, value);
37
37
  remplacer l'utilisation des variables httpHeaders / _httpHeaders par HTTPRequest.getHeaders()
38
38
 
39
39
  FlashMessage.displayRequestFailure(status, exception, modal) -> FlashMessage.displayError(labelErrorOccured, modal)
40
- FormHelper.logRequestFailure(status, exception) -> HTTPRequest.logJqueryRequestFailure(jqxhr, status, exception) (le log de l'erreur est devenu inutile car fait de base dans la classe HTTPRequest)
40
+ FormHelper.logRequestFailure(status, exception) -> HTTPRequest.logJqueryRequestFailure(jqxhr, status, exception) (le log de l'erreur est devenu inutile car fait de base dans la classe HTTPRequest)
41
+
42
+ Location.checkCoordinates(...) -> GeographicCoordinates.check(...) (car Location est déjà défini en javascript natif)
43
+
44
+ FormHelper.getFormErrorTextBis(...) -> FormHelper.getFormErrorText(...)
45
+ FormHelper.displayFormErrorsFromXhr(form, btnSubmit, xhr) -> FormHelper.displayFormErrors(form, btnSubmit, xhr.responseJSON)
package/data_table.js CHANGED
@@ -284,7 +284,7 @@ class DataTable {
284
284
  }
285
285
 
286
286
  if (error == null) {
287
- return this.displayErrorMessage(div, (typeof defaultMessage != 'undefined' ? defaultMessage : labelErrorOccured));
287
+ return this.displayErrorMessage(div, (typeof defaultMessage != 'undefined' ? defaultMessage : (typeof labelErrorOccured != 'undefined' ? labelErrorOccured : 'Une erreur s’est produite.')));
288
288
  }
289
289
  return this.displayErrorMessage(div, 'Critères sélectionnés incorrect.');
290
290
  }
@@ -5,7 +5,7 @@ class DetailsSubArray {
5
5
  return tr.closest('table').find('thead tr').children().length;
6
6
  }
7
7
  function displayErrorRow(tr) {
8
- tr.after($('<tr class="text-error"><td colspan="'+getNbColumns(tr)+'">'+labelErrorOccured+'</td></tr>'));
8
+ tr.after($('<tr class="text-error"><td colspan="'+getNbColumns(tr)+'">'+(typeof labelErrorOccured != 'undefined' ? labelErrorOccured : 'Une erreur s’est produite.')+'</td></tr>'));
9
9
  }
10
10
  function displayDetailsRow(tr, content) {
11
11
  var trContent = $(''
@@ -74,14 +74,15 @@ class DetailsSubArray {
74
74
  return;
75
75
  }
76
76
 
77
+ function onComplete() {
78
+ hideLoading(link);
79
+ setHideDetailsLink(link);
80
+ //link.attr('disabled', false).button('reset');
81
+ }
82
+
77
83
  //link.attr('disabled', true).button('loading');
78
- $.ajax({
79
- url: link.data("url_details"),
80
- method: 'GET',
81
- headers: HTTPRequest.getHeaders(),
82
- cache: false,
83
- dataType: 'json',
84
- success: function (jsonObj) {
84
+ HTTPRequest.get(link.data('url_details'), {},
85
+ (jsonObj) => {
85
86
  if (jsonObj == null) {
86
87
  if (typeof callbackOnDetailsActionRequestError != 'undefined' && callbackOnDetailsActionRequestError != null) {
87
88
  callbackOnDetailsActionRequestError(link);
@@ -94,24 +95,21 @@ class DetailsSubArray {
94
95
  if (typeof callbackOnDetailsActionRequestSuccess != 'undefined' && callbackOnDetailsActionRequestSuccess != null) {
95
96
  displayDetailsRow(link.closest('tr'), callbackOnDetailsActionRequestSuccess(jsonObj, link));
96
97
  }
97
- },
98
- error: function (jqxhr, status, exception) {
99
- console.log('Detail request failure. Status: '+status+' ; Exception: '+exception);
100
98
 
99
+ onComplete();
100
+ },
101
+ () => {
101
102
  if (typeof callbackOnDetailsActionRequestError != 'undefined' && callbackOnDetailsActionRequestError != null) {
102
103
  callbackOnDetailsActionRequestError(link);
103
104
  return;
104
105
  }
105
106
 
106
- link.closest('tr').after($('<tr class="error"><td colspan="6" class="center">'+labelErrorOccured+'</td></tr>'));
107
+ link.closest('tr').after($('<tr class="error"><td colspan="6" class="center">'+(typeof labelErrorOccured != 'undefined' ? labelErrorOccured : 'Une erreur s’est produite.')+'</td></tr>'));
108
+
109
+ onComplete();
107
110
  //window.location.replace(decodeURIComponent(urlRetour));
108
111
  },
109
- complete: function() {
110
- hideLoading(link);
111
- setHideDetailsLink(link);
112
- //link.attr('disabled', false).button('reset');
113
- }
114
- });
112
+ );
115
113
  }
116
114
 
117
115
  table.find('a.details_link').each(function(idx, link) {
package/file.js CHANGED
@@ -103,7 +103,7 @@ class Img {
103
103
  $.ajax({
104
104
  type: 'GET',
105
105
  url: url,
106
- headers: HTTPRequest.getHeaders(),
106
+ headers: HTTPRequest.getHeaders(true),
107
107
  cache: false,
108
108
  xhrFields: {responseType: 'blob'},
109
109
  success: (data) => {
package/flash_message.js CHANGED
@@ -31,7 +31,7 @@ class FlashMessage {
31
31
  /** @deprecated **/
32
32
  static displayRequestFailure(status, exception, modal) {
33
33
  console.log('request failure. Status: ', status, ' Exception: ', exception);
34
- this.display('danger', typeof labelErrorOccured != 'undefined' ? labelErrorOccured : "Une erreur s'est produite.", false, modal);
34
+ this.display('danger', typeof labelErrorOccured != 'undefined' ? labelErrorOccured : 'Une erreur sest produite.', false, modal);
35
35
  }
36
36
  }
37
37
 
package/form_helper.js CHANGED
@@ -183,16 +183,6 @@ class FormHelper {
183
183
  }
184
184
 
185
185
  static getFormErrorText(errors) {
186
- let errorLabels = '';
187
- for (let property in errors) {
188
- if (typeof errors[property] != 'function') {
189
- errorLabels += '<span>' + errors[property] + '</span><br>';
190
- }
191
- }
192
- return errorLabels;
193
- }
194
-
195
- static getFormErrorTextBis(errors) {
196
186
  let errorLabels = '';
197
187
  for (let property in errors) {
198
188
  // console.log(property);
@@ -208,7 +198,7 @@ class FormHelper {
208
198
  }
209
199
 
210
200
  static displayFormErrors(form, btnSubmit, errors, errorWrapperDiv) {
211
- this.displayFormErrorsFromText(form, this.getFormErrorTextBis(errors), errorWrapperDiv);
201
+ this.displayFormErrorsFromText(form, this.getFormErrorText(errors), errorWrapperDiv);
212
202
  if (btnSubmit != null) {
213
203
  if (btnSubmit.buttonLoader != null) {
214
204
  btnSubmit.buttonLoader('reset');
@@ -218,10 +208,6 @@ class FormHelper {
218
208
  }
219
209
  }
220
210
 
221
- static displayFormErrorsFromXhr(form, btnSubmit, xhr) {
222
- this.displayFormErrors(form, btnSubmit, xhr.responseJSON);
223
- }
224
-
225
211
  static displayFormErrorsFromText(form, errorLabels, errorWrapperDiv) {
226
212
  let errorDiv = '<div class="alert alert-danger form_errors">'+errorLabels+'</div>';
227
213
 
@@ -255,12 +241,48 @@ class FormHelper {
255
241
  }
256
242
 
257
243
 
244
+ static buttonLoader(button, action) {
245
+ button = $(button);
246
+ if (action === 'start' || action === 'loading') {
247
+ if (button.attr('disabled')) {
248
+ return self;
249
+ }
250
+ button.attr('disabled', true);
251
+ button.attr('data-btn-text', button.html());
252
+ //let text = '<span class="spinner"><i class=\'fa fa-circle-notch fa-spin\'></i></span>Traitement en cours…';
253
+ let text = '<i class=\'fa fa-circle-notch fa-spin\'></i> Traitement en cours…';
254
+ if (button.data('load-text') != undefined && button.data('load-text') != null && button.data('load-text') != '') {
255
+ text = button.data('load-text');
256
+ }
257
+ if (button.data('loading-text') != undefined && button.data('loading-text') != null && button.data('loading-text') != '') {
258
+ text = button.data('loading-text');
259
+ }
260
+ button.html(text);
261
+ button.addClass('disabled');
262
+ }
263
+ if (action === 'stop' || action === 'reset') {
264
+ button.html(button.attr('data-btn-text'));
265
+ button.removeClass('disabled');
266
+ button.attr('disabled', false);
267
+ //button.removeAttr("disabled");
268
+ }
269
+ return button;
270
+ }
271
+
272
+
273
+
274
+
258
275
 
259
276
  /** @deprecated **/
260
277
  static logRequestFailure(status, exception) {
261
278
  console.log('request failure. Status: '+status+' ; Exception: '+exception);
262
279
  }
263
280
 
281
+ /** @deprecated **/
282
+ static displayFormErrorsFromXhr(form, btnSubmit, xhr) {
283
+ this.displayFormErrors(form, btnSubmit, xhr.responseJSON);
284
+ }
285
+
264
286
  }
265
287
 
266
288
  module.exports = { FormHelper };
package/index.js CHANGED
@@ -15,7 +15,7 @@ const { DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime } = require('./da
15
15
  const { Duration } = require('./duration');
16
16
  const { File, CSV, Img } = require('./file');
17
17
  const { FormHelper } = require('./form_helper');
18
- const { Country, PostalAddress, Location } = require('./location');
18
+ const { Country, PostalAddress, GeographicCoordinates } = require('./location');
19
19
  const { SocialNetwork } = require('./social_network');
20
20
  const { sleep, refresh } = require('./util');
21
21
  const { chr, ord, trim, empty } = require('./php.min');
@@ -40,11 +40,9 @@ const { GoogleRecaptcha } = require('./google_recaptcha');
40
40
  const { GoogleMap } = require('./google_maps');
41
41
  const { OpenStreetMap } = require('./open_street_map');
42
42
 
43
- // deprecated
44
-
45
43
  module.exports = {
46
44
  Array, Object, Number, String,
47
- HTTPRequest, Cookie, UrlAndQueryString, IBAN, BankCard, AudioMedia, UserMedia, PersonName, Email, TelephoneNumber, DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, Duration, File, CSV, Img, FormHelper, Country, PostalAddress, Location, SocialNetwork,
45
+ HTTPRequest, Cookie, UrlAndQueryString, IBAN, BankCard, AudioMedia, UserMedia, PersonName, Email, TelephoneNumber, DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, Duration, File, CSV, Img, FormHelper, Country, PostalAddress, GeographicCoordinates, SocialNetwork,
48
46
  DataTable, Pagination, Navigation, DetailsSubArray, SelectAll, MultipleActionInTable, FormDate, InputPeriod, ShoppingCart, FlashMessage, CountDown, ImportFromCsv, JwtToken, JwtSession, ListBox,
49
47
  sleep, refresh, chr, ord, trim, empty,
50
48
  GoogleCharts, GoogleRecaptcha, GoogleMap, OpenStreetMap
package/location.js CHANGED
@@ -394,10 +394,10 @@ class PostalAddress {
394
394
  }
395
395
  }
396
396
 
397
- class Location {
398
- static checkCoordinates(str) {
397
+ class GeographicCoordinates {
398
+ static check(str) {
399
399
  return /^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$/.test(str);
400
400
  }
401
401
  }
402
402
 
403
- module.exports = { Country, PostalAddress, Location };
403
+ module.exports = { Country, PostalAddress, GeographicCoordinates };
package/network.js CHANGED
@@ -14,7 +14,7 @@ class HTTPRequest {
14
14
  this.headers[key] = value;
15
15
  }
16
16
 
17
- static getHeaders() {
17
+ static getHeaders(asObject) {
18
18
  //if (typeof httpHeaders != 'undefined') {
19
19
  // return httpHeaders;
20
20
  //}
@@ -23,6 +23,10 @@ class HTTPRequest {
23
23
  this.headers = {};
24
24
  }
25
25
 
26
+ if (typeof asObject != 'undefined' && asObject) {
27
+ return this.headers;
28
+ }
29
+
26
30
  let httpHeaders = new Headers();
27
31
  Object.entries(this.headers).forEach(([key, value]) => {
28
32
  httpHeaders.append(key, value);
@@ -78,27 +82,27 @@ class HTTPRequest {
78
82
  //console.log(url, jsonData);
79
83
  //console.log(response.status, response.statusText, jsonData['error']);
80
84
 
81
- if (response.status == 401 && (response.statusText === "Expired JWT Token" || typeof jsonData['error'] != 'undefined' && jsonData['error'] === 'expired_token')) {
85
+ if (response.status == 401 && (response.statusText === 'Expired JWT Token' || typeof jsonData['error'] != 'undefined' && jsonData['error'] === 'expired_token')) {
82
86
  HTTPRequest.refreshToken(() => HTTPRequest.get(url, data, successCallback, errorCallback));
83
87
  return;
84
88
  }
85
89
 
86
90
  if (response.ok) {
87
- successCallback(jsonData);
91
+ successCallback(jsonData, response);
88
92
  return;
89
93
  }
90
94
  }
91
95
  catch (e) {
92
96
  console.error(e);
93
97
  if (typeof errorCallback != 'undefined' && errorCallback != null) {
94
- errorCallback(response, response.status, e);
98
+ errorCallback(response);
95
99
  }
96
100
  return;
97
101
  }
98
102
 
99
103
  HTTPRequest.logRequestFailure(response, jsonData);
100
104
  if (typeof errorCallback != 'undefined' && errorCallback != null) {
101
- errorCallback(response, response.status, null, jsonData);
105
+ errorCallback(response, jsonData);
102
106
  }
103
107
  return;
104
108
  }
@@ -108,19 +112,23 @@ class HTTPRequest {
108
112
  $.ajax({
109
113
  type: 'GET',
110
114
  url: url,
111
- headers: HTTPRequest.getHeaders(),
115
+ headers: HTTPRequest.getHeaders(true),
112
116
  dataType: 'json',
113
117
  cache: false,
114
- success: (data) => successCallback(data),
118
+ success: (data, status, jqxhr) => {
119
+ if (typeof successCallback != 'undefined' && successCallback != null) {
120
+ successCallback(data, jqxhr);
121
+ }
122
+ },
115
123
  error: (jqxhr, status, errorThrown) => {
116
- if (typeof jqxhr.responseJSON != 'undefined' && jqxhr.responseJSON.code == 401 && (jqxhr.responseJSON.message === "Expired JWT Token" || (typeof jqxhr.responseJSON['error'] != 'undefined' && jqxhr.responseJSON['error'] === 'expired_token' ))) {
124
+ if (jqxhr.status == 401 && (jqxhr.statusText === 'Expired JWT Token' || (typeof jqxhr.responseJSON['message'] != 'undefined' && jqxhr.responseJSON['message'] === 'Expired JWT Token') || (typeof jqxhr.responseJSON['error'] != 'undefined' && jqxhr.responseJSON['error'] === 'expired_token' ))) {
117
125
  HTTPRequest.refreshToken(() => HTTPRequest.get(url, data, successCallback, errorCallback));
118
126
  return;
119
127
  }
120
128
 
121
129
  HTTPRequest.logJqueryRequestFailure(jqxhr, status, errorThrown);
122
130
  if (typeof errorCallback != 'undefined' && errorCallback != null) {
123
- errorCallback(jqxhr, status, errorThrown);
131
+ errorCallback(jqxhr, jqxhr.responseJSON);
124
132
  }
125
133
  }
126
134
  });
@@ -153,7 +161,7 @@ class HTTPRequest {
153
161
  /*console.log(url);
154
162
  console.log(blobData);*/
155
163
 
156
- if (response.status == 401 && response.statusText === "Expired JWT Token") {
164
+ if (response.status == 401 && response.statusText === 'Expired JWT Token') {
157
165
  HTTPRequest.refreshToken(() => HTTPRequest.download(url, data, errorCallback, completeCallback, method));
158
166
  return;
159
167
  }
@@ -164,18 +172,18 @@ class HTTPRequest {
164
172
  else {
165
173
  HTTPRequest.logRequestFailure(response, null);
166
174
  if (typeof errorCallback != 'undefined' && errorCallback != null) {
167
- errorCallback(response, response.status, null);
175
+ errorCallback(response);
168
176
  }
169
177
  }
170
178
  }
171
179
  catch (e) {
172
180
  console.error(e);
173
181
  if (typeof errorCallback != 'undefined' && errorCallback != null) {
174
- errorCallback(response, response.status, e);
182
+ errorCallback(response);
175
183
  }
176
184
  }
177
185
  if (typeof completeCallback != 'undefined' && completeCallback != null) {
178
- completeCallback(response, response.status);
186
+ completeCallback(response);
179
187
  }
180
188
  return;
181
189
  }
@@ -183,11 +191,10 @@ class HTTPRequest {
183
191
  //l'api fetch n'est pas dispo pour ce navigateur => normalement ce cas ne devrait pas arriver car le polyfill est chargé
184
192
  console.error('fetch\'s polyfill used');
185
193
 
186
-
187
194
  let ajaxOptions = {
188
195
  type: 'GET',
189
196
  url: url,
190
- headers: HTTPRequest.getHeaders(),
197
+ headers: HTTPRequest.getHeaders(true),
191
198
  cache: false,
192
199
  xhrFields: {
193
200
  responseType: 'blob'
@@ -203,19 +210,19 @@ class HTTPRequest {
203
210
  $.ajax(Object.assign({...ajaxOptions}, {
204
211
  success: (data, status, jqxhr) => File.download(data, jqxhr.getResponseHeader('Content-Type'), jqxhr.getResponseHeader('Content-Disposition')),
205
212
  error: (jqxhr, status, errorThrown) => {
206
- if (typeof jqxhr.responseJSON != 'undefined' && jqxhr.responseJSON.code == 401 && (jqxhr.responseJSON.message === "Expired JWT Token" || (typeof jqxhr.responseJSON['error'] != 'undefined' && jqxhr.responseJSON['error'] === 'expired_token' ))) {
213
+ if (jqxhr.status == 401 && (jqxhr.statusText === 'Expired JWT Token' || (typeof jqxhr.responseJSON['message'] != 'undefined' && jqxhr.responseJSON['message'] === 'Expired JWT Token') || (typeof jqxhr.responseJSON['error'] != 'undefined' && jqxhr.responseJSON['error'] === 'expired_token' ))) {
207
214
  HTTPRequest.refreshToken(() => HTTPRequest.download(url, data, errorCallback, completeCallback, method));
208
215
  return;
209
216
  }
210
217
 
211
218
  HTTPRequest.logJqueryRequestFailure(jqxhr, status, errorThrown);
212
219
  if (typeof errorCallback != 'undefined' && errorCallback != null) {
213
- errorCallback(jqxhr, status, errorThrown);
220
+ errorCallback(jqxhr);
214
221
  }
215
222
  },
216
- complete: (jqxhr, status) => {
223
+ complete: (jqxhr) => {
217
224
  if (typeof completeCallback != 'undefined' && completeCallback != null) {
218
- completeCallback(jqxhr, status);
225
+ completeCallback(jqxhr);
219
226
  }
220
227
  }
221
228
  }));
@@ -224,7 +231,7 @@ class HTTPRequest {
224
231
  static async post(url, formData, successCallback, errorCallback, formErrorCallback) {
225
232
  formData = this.formatFormData(formData);
226
233
 
227
- if (window.fetch && false) {
234
+ if (window.fetch) {
228
235
  const response = await fetch(url, {
229
236
  method: 'POST',
230
237
  body: formData,
@@ -235,37 +242,39 @@ class HTTPRequest {
235
242
 
236
243
  let jsonData = {};
237
244
  try {
238
- jsonData = await response.json();
245
+ if (response.statusText !== 'No Content') {
246
+ jsonData = await response.json();
247
+ }
239
248
  //console.log(url, jsonData);
240
249
 
241
- if (response.status == 401 && url !== HTTPRequest.refreshTokenUrl && (response.statusText === "Expired JWT Token" || (typeof jsonData['error'] != 'undefined' && jsonData['error'] === 'expired_token'))) {
250
+ if (response.status == 401 && url !== HTTPRequest.refreshTokenUrl && (response.statusText === 'Expired JWT Token' || (typeof jsonData['error'] != 'undefined' && jsonData['error'] === 'expired_token'))) {
242
251
  HTTPRequest.refreshToken(() => HTTPRequest.post(url, formData, successCallback, errorCallback, formErrorCallback));
243
252
  return;
244
253
  }
245
254
 
246
255
  if (response.ok) {
247
256
  if (typeof successCallback != 'undefined' && successCallback != null) {
248
- successCallback(jsonData);
257
+ successCallback(jsonData, response);
249
258
  }
250
259
  return;
251
260
  }
252
261
 
253
262
  if (response.status == 400 && typeof formErrorCallback != 'undefined' && formErrorCallback != null) {
254
- formErrorCallback(response, response.status, jsonData);
263
+ formErrorCallback(jsonData, response);
255
264
  return;
256
265
  }
257
266
  }
258
267
  catch (e) {
259
268
  console.error(e);
260
269
  if (typeof errorCallback != 'undefined' && errorCallback != null) {
261
- errorCallback(response, response.status, e);
270
+ errorCallback(response);
262
271
  }
263
272
  return;
264
273
  }
265
274
 
266
275
  HTTPRequest.logRequestFailure(response, jsonData);
267
276
  if (typeof errorCallback != 'undefined' && errorCallback != null) {
268
- errorCallback(response, response.status, null, jsonData);
277
+ errorCallback(response, jsonData);
269
278
  }
270
279
  return;
271
280
  }
@@ -275,30 +284,30 @@ class HTTPRequest {
275
284
  $.ajax({
276
285
  type: 'POST',
277
286
  url: url,
278
- headers: HTTPRequest.getHeaders(),
287
+ headers: HTTPRequest.getHeaders(true),
279
288
  dataType: 'json', // 22/09/2020 : à voir si cette ligne pose pb (utilisé pour requete import et peut être d'autres
280
289
  data: formData,
281
290
  cache: false,
282
291
  contentType: false,
283
292
  processData: false,
284
- success: (data) => {
293
+ success: (data, status, jqxhr) => {
285
294
  if (typeof successCallback != 'undefined' && successCallback != null) {
286
- successCallback(data);
295
+ successCallback(data, jqxhr);
287
296
  }
288
297
  },
289
298
  error: (jqxhr, status, errorThrown) => {
290
- if (typeof jqxhr.responseJSON != 'undefined' && jqxhr.responseJSON.code == 401 && url !== HTTPRequest.refreshTokenUrl && (jqxhr.responseJSON.message === "Expired JWT Token" || (typeof jqxhr.responseJSON['error'] != 'undefined' && jqxhr.responseJSON['error'] === 'expired_token' ))) {
299
+ if (url !== HTTPRequest.refreshTokenUrl && jqxhr.status == 401 && (jqxhr.statusText === 'Expired JWT Token' || (typeof jqxhr.responseJSON['message'] != 'undefined' && jqxhr.responseJSON['message'] === 'Expired JWT Token') || (typeof jqxhr.responseJSON['error'] != 'undefined' && jqxhr.responseJSON['error'] === 'expired_token' ))) {
291
300
  HTTPRequest.refreshToken(() => HTTPRequest.post(url, formData, successCallback, errorCallback, formErrorCallback));
292
301
  return;
293
302
  }
294
303
  if (jqxhr.status == 400 && typeof formErrorCallback != 'undefined' && formErrorCallback != null) {
295
- formErrorCallback(jqxhr, status, errorThrown);
304
+ formErrorCallback(jqxhr.responseJSON, jqxhr);
296
305
  return;
297
306
  }
298
307
 
299
308
  HTTPRequest.logJqueryRequestFailure(jqxhr, status, errorThrown);
300
309
  if (typeof errorCallback != 'undefined' && errorCallback != null) {
301
- errorCallback(jqxhr, status, errorThrown);
310
+ errorCallback(jqxhr, jqxhr.responseJSON);
302
311
  }
303
312
  }
304
313
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.0.31",
3
+ "version": "1.0.34",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -1,50 +0,0 @@
1
-
2
- // Loading button plugin (removed from BS4)
3
- (function($) {
4
- "use strict";
5
-
6
- $.fn.extend({
7
- /*
8
- button: function (action) {
9
- console.log(action);
10
- if (action === 'loading' && this.data('loading-text')) {
11
- console.log('loading');
12
- this.data('original-text', this.html()).html(this.data('loading-text')).prop('disabled', true);
13
- }
14
- if (action === 'reset' && this.data('original-text')) {
15
- console.log('reset');
16
- this.html(this.data('original-text')).prop('disabled', false);
17
- }
18
- },
19
- */
20
-
21
- buttonLoader: function (action) {
22
- //console.log(action);
23
- var self = $(this);
24
- if (action === 'start' || action === 'loading') {
25
- if ($(self).attr('disabled')) {
26
- return self;
27
- }
28
- $(self).attr('disabled', true);
29
- $(self).attr('data-btn-text', $(self).html());
30
- //let text = '<span class="spinner"><i class=\'fa fa-circle-notch fa-spin\'></i></span>Traitement en cours…';
31
- let text = '<i class=\'fa fa-circle-notch fa-spin\'></i> Traitement en cours…';
32
- if ($(self).data('load-text') != undefined && $(self).data('load-text') != null && $(self).data('load-text') != '') {
33
- text = $(self).data('load-text');
34
- }
35
- if ($(self).data('loading-text') != undefined && $(self).data('loading-text') != null && $(self).data('loading-text') != '') {
36
- text = $(self).data('loading-text');
37
- }
38
- $(self).html(text);
39
- $(self).addClass('disabled');
40
- }
41
- if (action === 'stop' || action === 'reset') {
42
- $(self).html($(self).attr('data-btn-text'));
43
- $(self).removeClass('disabled');
44
- $(self).attr('disabled', false);
45
- //$(self).removeAttr("disabled");
46
- }
47
- return self;
48
- }
49
- });
50
- }(jQuery));