@osimatic/helpers-js 1.1.77 → 1.1.78
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 +76 -76
- package/array.js +93 -90
- package/bank.js +20 -20
- package/contact_details.js +194 -194
- package/count_down.js +102 -102
- package/data_table.js +416 -416
- package/date_time.js +592 -592
- package/details_sub_array.js +123 -123
- package/draw.js +52 -52
- package/duration.js +198 -198
- package/event_bus.js +38 -38
- package/file.js +146 -146
- package/flash_message.js +35 -35
- package/form_date.js +610 -610
- package/form_helper.js +410 -410
- package/google_charts.js +347 -347
- package/google_maps.js +169 -169
- package/google_recaptcha.js +87 -87
- package/http_client.js +469 -469
- package/import_from_csv.js +273 -273
- package/index.js +55 -55
- package/jwt.js +288 -288
- package/list_box.js +112 -112
- package/location.js +431 -431
- package/media.js +218 -218
- package/multiple_action_in_table.js +336 -336
- package/network.js +756 -756
- package/number.js +99 -99
- package/open_street_map.js +142 -142
- package/package.json +15 -15
- package/paging.js +278 -278
- package/php.min.js +5 -5
- package/revolut.js +22 -22
- package/select_all.js +121 -121
- package/shopping_cart.js +31 -31
- package/social_network.js +109 -109
- package/sortable_list.js +37 -37
- package/string.js +162 -162
- package/util.js +16 -16
- package/visitor.js +77 -77
- package/web_rtc.js +114 -114
- package/web_socket.js +97 -97
package/details_sub_array.js
CHANGED
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
class DetailsSubArray {
|
|
2
|
-
|
|
3
|
-
static initDetailsLink(table, callbackOnDetailsActionRequestSuccess, callbackOnDetailsActionRequestError, callbackOnDetailsActionRequestBeforeSend) {
|
|
4
|
-
function getNbColumns(tr) {
|
|
5
|
-
return tr.closest('table').find('thead tr').children().length;
|
|
6
|
-
}
|
|
7
|
-
function displayErrorRow(tr) {
|
|
8
|
-
tr.after($('<tr class="text-error"><td colspan="'+getNbColumns(tr)+'">'+(typeof labelErrorOccured != 'undefined' ? labelErrorOccured : 'Une erreur s’est produite.')+'</td></tr>'));
|
|
9
|
-
}
|
|
10
|
-
function displayDetailsRow(tr, content) {
|
|
11
|
-
var trContent = $(''
|
|
12
|
-
+ '<tr class="participants">'
|
|
13
|
-
+ '<td colspan="'+getNbColumns(tr)+'">'
|
|
14
|
-
+ '</td>'
|
|
15
|
-
+ '</tr>'
|
|
16
|
-
);
|
|
17
|
-
trContent.find('td').append(content);
|
|
18
|
-
tr.after(trContent);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function hideDetailsRow(link) {
|
|
22
|
-
var tr = link.closest('tr').addClass('folded');
|
|
23
|
-
if (tr.next().hasClass('participants') ) {
|
|
24
|
-
tr.next().remove();
|
|
25
|
-
}
|
|
26
|
-
showPlusButton(link);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function showPlusButton(link) {
|
|
30
|
-
link.prop('title', showDetailsLabel).attr('disabled', false).html($('<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>'));
|
|
31
|
-
}
|
|
32
|
-
function showMinusButton(link) {
|
|
33
|
-
link.prop('title', hideDetailsLabel).attr('disabled', false).html($('<span class="glyphicon glyphicon-minus" aria-hidden="true"></span>'));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function displayLoading(link) {
|
|
37
|
-
link.attr('disabled', true).html($('<i class="fa fa-circle-notch fa-spin"></i>'));
|
|
38
|
-
var tr = link.closest('tr');
|
|
39
|
-
tr.after($('<tr class="waiting_icon"><td colspan="'+getNbColumns(tr)+'" class="center"><i class="fa fa-circle-notch fa-spin"></i></td></tr>'));
|
|
40
|
-
}
|
|
41
|
-
function hideLoading(link) {
|
|
42
|
-
// todo : cacher que le loader du lien au lieu de tous les loaders (cas ou l'user clique sur tous les boutons rapidement)
|
|
43
|
-
if ($('tr.waiting_icon').length > 0) {
|
|
44
|
-
$(('tr.waiting_icon')).remove();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function setHideDetailsLink(link) {
|
|
49
|
-
showMinusButton(link);
|
|
50
|
-
link.click(function() {
|
|
51
|
-
$(this).stop();
|
|
52
|
-
hideDetailsRow(link);
|
|
53
|
-
setDisplayDetailsLink(link);
|
|
54
|
-
return false;
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function setDisplayDetailsLink(link) {
|
|
59
|
-
link.click(function() {
|
|
60
|
-
$(this).stop().off('click');
|
|
61
|
-
hideDetailsRow(link);
|
|
62
|
-
doDetailsActionRequest(link);
|
|
63
|
-
return false;
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function doDetailsActionRequest(link) {
|
|
68
|
-
displayLoading(link);
|
|
69
|
-
|
|
70
|
-
if (typeof callbackOnDetailsActionRequestBeforeSend != 'undefined' && callbackOnDetailsActionRequestBeforeSend != null) {
|
|
71
|
-
displayDetailsRow(link.closest('tr'), callbackOnDetailsActionRequestBeforeSend(link));
|
|
72
|
-
hideLoading(link);
|
|
73
|
-
setHideDetailsLink(link);
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function onComplete() {
|
|
78
|
-
hideLoading(link);
|
|
79
|
-
setHideDetailsLink(link);
|
|
80
|
-
//link.attr('disabled', false).button('reset');
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
//link.attr('disabled', true).button('loading');
|
|
84
|
-
HTTPClient.request('GET', link.data('url_details'), null,
|
|
85
|
-
(jsonObj) => {
|
|
86
|
-
if (jsonObj == null) {
|
|
87
|
-
if (typeof callbackOnDetailsActionRequestError != 'undefined' && callbackOnDetailsActionRequestError != null) {
|
|
88
|
-
callbackOnDetailsActionRequestError(link);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
displayErrorRow(link.closest('tr'));
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (typeof callbackOnDetailsActionRequestSuccess != 'undefined' && callbackOnDetailsActionRequestSuccess != null) {
|
|
96
|
-
displayDetailsRow(link.closest('tr'), callbackOnDetailsActionRequestSuccess(jsonObj, link));
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
onComplete();
|
|
100
|
-
},
|
|
101
|
-
() => {
|
|
102
|
-
if (typeof callbackOnDetailsActionRequestError != 'undefined' && callbackOnDetailsActionRequestError != null) {
|
|
103
|
-
callbackOnDetailsActionRequestError(link);
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
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();
|
|
110
|
-
//window.location.replace(decodeURIComponent(urlRetour));
|
|
111
|
-
}
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
table.find('a.details_link').each(function(idx, link) {
|
|
116
|
-
$(link).removeClass('hide');
|
|
117
|
-
setDisplayDetailsLink($(link));
|
|
118
|
-
showPlusButton($(link));
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
1
|
+
class DetailsSubArray {
|
|
2
|
+
|
|
3
|
+
static initDetailsLink(table, callbackOnDetailsActionRequestSuccess, callbackOnDetailsActionRequestError, callbackOnDetailsActionRequestBeforeSend) {
|
|
4
|
+
function getNbColumns(tr) {
|
|
5
|
+
return tr.closest('table').find('thead tr').children().length;
|
|
6
|
+
}
|
|
7
|
+
function displayErrorRow(tr) {
|
|
8
|
+
tr.after($('<tr class="text-error"><td colspan="'+getNbColumns(tr)+'">'+(typeof labelErrorOccured != 'undefined' ? labelErrorOccured : 'Une erreur s’est produite.')+'</td></tr>'));
|
|
9
|
+
}
|
|
10
|
+
function displayDetailsRow(tr, content) {
|
|
11
|
+
var trContent = $(''
|
|
12
|
+
+ '<tr class="participants">'
|
|
13
|
+
+ '<td colspan="'+getNbColumns(tr)+'">'
|
|
14
|
+
+ '</td>'
|
|
15
|
+
+ '</tr>'
|
|
16
|
+
);
|
|
17
|
+
trContent.find('td').append(content);
|
|
18
|
+
tr.after(trContent);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function hideDetailsRow(link) {
|
|
22
|
+
var tr = link.closest('tr').addClass('folded');
|
|
23
|
+
if (tr.next().hasClass('participants') ) {
|
|
24
|
+
tr.next().remove();
|
|
25
|
+
}
|
|
26
|
+
showPlusButton(link);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function showPlusButton(link) {
|
|
30
|
+
link.prop('title', showDetailsLabel).attr('disabled', false).html($('<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>'));
|
|
31
|
+
}
|
|
32
|
+
function showMinusButton(link) {
|
|
33
|
+
link.prop('title', hideDetailsLabel).attr('disabled', false).html($('<span class="glyphicon glyphicon-minus" aria-hidden="true"></span>'));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function displayLoading(link) {
|
|
37
|
+
link.attr('disabled', true).html($('<i class="fa fa-circle-notch fa-spin"></i>'));
|
|
38
|
+
var tr = link.closest('tr');
|
|
39
|
+
tr.after($('<tr class="waiting_icon"><td colspan="'+getNbColumns(tr)+'" class="center"><i class="fa fa-circle-notch fa-spin"></i></td></tr>'));
|
|
40
|
+
}
|
|
41
|
+
function hideLoading(link) {
|
|
42
|
+
// todo : cacher que le loader du lien au lieu de tous les loaders (cas ou l'user clique sur tous les boutons rapidement)
|
|
43
|
+
if ($('tr.waiting_icon').length > 0) {
|
|
44
|
+
$(('tr.waiting_icon')).remove();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function setHideDetailsLink(link) {
|
|
49
|
+
showMinusButton(link);
|
|
50
|
+
link.click(function() {
|
|
51
|
+
$(this).stop();
|
|
52
|
+
hideDetailsRow(link);
|
|
53
|
+
setDisplayDetailsLink(link);
|
|
54
|
+
return false;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function setDisplayDetailsLink(link) {
|
|
59
|
+
link.click(function() {
|
|
60
|
+
$(this).stop().off('click');
|
|
61
|
+
hideDetailsRow(link);
|
|
62
|
+
doDetailsActionRequest(link);
|
|
63
|
+
return false;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function doDetailsActionRequest(link) {
|
|
68
|
+
displayLoading(link);
|
|
69
|
+
|
|
70
|
+
if (typeof callbackOnDetailsActionRequestBeforeSend != 'undefined' && callbackOnDetailsActionRequestBeforeSend != null) {
|
|
71
|
+
displayDetailsRow(link.closest('tr'), callbackOnDetailsActionRequestBeforeSend(link));
|
|
72
|
+
hideLoading(link);
|
|
73
|
+
setHideDetailsLink(link);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function onComplete() {
|
|
78
|
+
hideLoading(link);
|
|
79
|
+
setHideDetailsLink(link);
|
|
80
|
+
//link.attr('disabled', false).button('reset');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
//link.attr('disabled', true).button('loading');
|
|
84
|
+
HTTPClient.request('GET', link.data('url_details'), null,
|
|
85
|
+
(jsonObj) => {
|
|
86
|
+
if (jsonObj == null) {
|
|
87
|
+
if (typeof callbackOnDetailsActionRequestError != 'undefined' && callbackOnDetailsActionRequestError != null) {
|
|
88
|
+
callbackOnDetailsActionRequestError(link);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
displayErrorRow(link.closest('tr'));
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (typeof callbackOnDetailsActionRequestSuccess != 'undefined' && callbackOnDetailsActionRequestSuccess != null) {
|
|
96
|
+
displayDetailsRow(link.closest('tr'), callbackOnDetailsActionRequestSuccess(jsonObj, link));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
onComplete();
|
|
100
|
+
},
|
|
101
|
+
() => {
|
|
102
|
+
if (typeof callbackOnDetailsActionRequestError != 'undefined' && callbackOnDetailsActionRequestError != null) {
|
|
103
|
+
callbackOnDetailsActionRequestError(link);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
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();
|
|
110
|
+
//window.location.replace(decodeURIComponent(urlRetour));
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
table.find('a.details_link').each(function(idx, link) {
|
|
116
|
+
$(link).removeClass('hide');
|
|
117
|
+
setDisplayDetailsLink($(link));
|
|
118
|
+
showPlusButton($(link));
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
|
|
124
124
|
module.exports = { DetailsSubArray };
|
package/draw.js
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
class HexColor {
|
|
2
|
-
static check(hexColor) {
|
|
3
|
-
return hexColor.match(/^[0-9a-fA-F]{6}$/).length;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
static convertToRgb(hexColor) {
|
|
7
|
-
if (hexColor.substring(0, 1) === '#') {
|
|
8
|
-
hexColor = hexColor.substring(1);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (hexColor.length === 3) {
|
|
12
|
-
hexColor = hexColor+hexColor;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (!HexColor.check(hexColor)) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
let hexRed = hexColor.substring(0,2);
|
|
20
|
-
let hexGreen = hexColor.substring(2,4);
|
|
21
|
-
let hexBlue = hexColor.substring(4,6);
|
|
22
|
-
|
|
23
|
-
let red = parseInt(hexRed, 16);
|
|
24
|
-
let green = parseInt(hexGreen, 16);
|
|
25
|
-
let blue = parseInt(hexBlue, 16);
|
|
26
|
-
|
|
27
|
-
return [red, green, blue];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static isLight(hexColor) {
|
|
31
|
-
let rgb = HexColor.convertToRgb(hexColor);
|
|
32
|
-
if (rgb === null) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
return RgbColor.isLight(rgb[0], rgb[1], rgb[2]);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
class RgbColor {
|
|
40
|
-
static isLight(red, green, blue) {
|
|
41
|
-
const PERCENT_RED = 0.2125;
|
|
42
|
-
const PERCENT_GREEN = 0.7154;
|
|
43
|
-
const PERCENT_BLUE = 0.0721;
|
|
44
|
-
// $percentageRed = 0.3;
|
|
45
|
-
// $percentageGreen = 0.59;
|
|
46
|
-
// $percentageBlue = 0.11;
|
|
47
|
-
|
|
48
|
-
let coeff = (PERCENT_RED*red) + (PERCENT_GREEN*green) + (PERCENT_BLUE*blue);
|
|
49
|
-
return coeff > 128;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
1
|
+
class HexColor {
|
|
2
|
+
static check(hexColor) {
|
|
3
|
+
return hexColor.match(/^[0-9a-fA-F]{6}$/).length;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
static convertToRgb(hexColor) {
|
|
7
|
+
if (hexColor.substring(0, 1) === '#') {
|
|
8
|
+
hexColor = hexColor.substring(1);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (hexColor.length === 3) {
|
|
12
|
+
hexColor = hexColor+hexColor;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (!HexColor.check(hexColor)) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let hexRed = hexColor.substring(0,2);
|
|
20
|
+
let hexGreen = hexColor.substring(2,4);
|
|
21
|
+
let hexBlue = hexColor.substring(4,6);
|
|
22
|
+
|
|
23
|
+
let red = parseInt(hexRed, 16);
|
|
24
|
+
let green = parseInt(hexGreen, 16);
|
|
25
|
+
let blue = parseInt(hexBlue, 16);
|
|
26
|
+
|
|
27
|
+
return [red, green, blue];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static isLight(hexColor) {
|
|
31
|
+
let rgb = HexColor.convertToRgb(hexColor);
|
|
32
|
+
if (rgb === null) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
return RgbColor.isLight(rgb[0], rgb[1], rgb[2]);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
class RgbColor {
|
|
40
|
+
static isLight(red, green, blue) {
|
|
41
|
+
const PERCENT_RED = 0.2125;
|
|
42
|
+
const PERCENT_GREEN = 0.7154;
|
|
43
|
+
const PERCENT_BLUE = 0.0721;
|
|
44
|
+
// $percentageRed = 0.3;
|
|
45
|
+
// $percentageGreen = 0.59;
|
|
46
|
+
// $percentageBlue = 0.11;
|
|
47
|
+
|
|
48
|
+
let coeff = (PERCENT_RED*red) + (PERCENT_GREEN*green) + (PERCENT_BLUE*blue);
|
|
49
|
+
return coeff > 128;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
53
|
module.exports = { HexColor, RgbColor };
|