@osimatic/helpers-js 1.0.2
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/array.js +84 -0
- package/bank.js +7 -0
- package/button_loader.js +50 -0
- package/contact_details.js +172 -0
- package/count_down.js +103 -0
- package/data_table.js +419 -0
- package/date_time.js +551 -0
- package/details_sub_array.js +126 -0
- package/duration.js +177 -0
- package/file.js +128 -0
- package/flash_message.js +38 -0
- package/form_date.js +262 -0
- package/form_helper.js +237 -0
- package/google_charts.js +344 -0
- package/google_charts_mytime.js +295 -0
- package/google_maps.js +169 -0
- package/google_recaptcha.js +15 -0
- package/graphiques.js +281 -0
- package/import_from_csv.js +274 -0
- package/index.js +69 -0
- package/jquery.js +5 -0
- package/jwt.js +97 -0
- package/list_box.js +113 -0
- package/location.js +391 -0
- package/media.js +82 -0
- package/multiple_action_in_table.js +229 -0
- package/network.js +554 -0
- package/number.js +90 -0
- package/package.json +12 -0
- package/paging.js +237 -0
- package/php.min.js +4 -0
- package/select_all.js +132 -0
- package/social_network.js +110 -0
- package/string.js +118 -0
- package/tree.js +71 -0
- package/util.js +23 -0
package/paging.js
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
// Fonction commune de pagination
|
|
2
|
+
//Bootstrap class pagination https://getbootstrap.com/docs/3.3/components/#pagination
|
|
3
|
+
|
|
4
|
+
class Pagination {
|
|
5
|
+
static paginateCards(div, nbItemsPerPage) {
|
|
6
|
+
Pagination.paginate(div, div.find('.pagination_item'), nbItemsPerPage);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
static paginateTable(table, select) {
|
|
10
|
+
Pagination.paginate(table, table.find('tbody tr:not(.hide)'), parseInt(table.data('max_rows')), select);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static paginate(div, items, nbItemsPerPage, select) {
|
|
14
|
+
let maxItems = nbItemsPerPage;
|
|
15
|
+
|
|
16
|
+
if (typeof div == 'undefined' || !div.length) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (typeof select != 'undefined' && select.length) {
|
|
21
|
+
if (!select.children().length) {
|
|
22
|
+
select.append('<option value="0">'+labelDisplayAll+'</option>');
|
|
23
|
+
let nbRowsList = select.data('nb_rows_list') ? select.data('nb_rows_list').split(',') : [5, 10, 25, 50];
|
|
24
|
+
$.each(nbRowsList, function(idx, nbRows) {
|
|
25
|
+
select.append('<option value="'+nbRows+'">'+nbRows+'</option>');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
if (select.data('default_nb_rows')) {
|
|
29
|
+
select.val(select.data('default_nb_rows'))
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
maxItems = parseInt(select.val());
|
|
34
|
+
|
|
35
|
+
select.change(update);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let paginationUl = $('ul.pagination');
|
|
39
|
+
if (!paginationUl.length) {
|
|
40
|
+
paginationUl = $('<ul class="pagination"></ul>');
|
|
41
|
+
if (div.find('.pagination_links').length) {
|
|
42
|
+
div.find('.pagination_links').append(paginationUl);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
div.after(paginationUl);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function update() {
|
|
50
|
+
let totalItems = items.length;
|
|
51
|
+
|
|
52
|
+
let lineNum = 0;
|
|
53
|
+
items.each(function () {
|
|
54
|
+
lineNum++;
|
|
55
|
+
if (0 === maxItems || lineNum <= maxItems) {
|
|
56
|
+
$(this).show();
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
$(this).hide();
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
paginationUl.find('li').remove();
|
|
63
|
+
|
|
64
|
+
if (0 === maxItems || totalItems < maxItems) {
|
|
65
|
+
paginationUl.addClass('hide');
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let nbPages = Math.ceil(totalItems/maxItems);
|
|
70
|
+
for (let i=1; i <= nbPages; i++) {
|
|
71
|
+
paginationUl.append('<li class="page-item" data-page="'+i+'"><a href="#" class="page-link">'+i+'<span class="sr-only">(current)</span></a></li>').show();
|
|
72
|
+
}
|
|
73
|
+
paginationUl.removeClass('hide');
|
|
74
|
+
|
|
75
|
+
paginationUl.find('li:first-child').addClass('active');
|
|
76
|
+
paginationUl.find('li').click(function () {
|
|
77
|
+
paginationUl.find('li').removeClass('active');
|
|
78
|
+
|
|
79
|
+
let pageNum = $(this).data('page');
|
|
80
|
+
let trIndex = 0;
|
|
81
|
+
$(this).addClass('active');
|
|
82
|
+
items.each(function () {
|
|
83
|
+
trIndex++;
|
|
84
|
+
if (trIndex > (maxItems*pageNum) || trIndex <= ((maxItems*pageNum)-maxItems)) {
|
|
85
|
+
$(this).hide();
|
|
86
|
+
}
|
|
87
|
+
else{
|
|
88
|
+
$(this).show();
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
return false;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
update();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function activateTab(a) {
|
|
102
|
+
//console.log(a);
|
|
103
|
+
//a.click();
|
|
104
|
+
let ulNav = a.closest('.nav');
|
|
105
|
+
let tabContent = ulNav.parent().find('.tab-content');
|
|
106
|
+
|
|
107
|
+
// déselection éventuel des onglets
|
|
108
|
+
ulNav.find('a.nav-link').each(function(idx, navLink) {
|
|
109
|
+
$(navLink).removeClass('active');
|
|
110
|
+
let id = $(navLink).attr('href');
|
|
111
|
+
if (id.substr(0, 1) === '#') {
|
|
112
|
+
tabContent.find(id).removeClass('active').removeClass('show');
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// sélection de l'onglet correspondant au navLink passé en paramètre
|
|
117
|
+
a.addClass('active');
|
|
118
|
+
tabContent.find(a.attr('href')).addClass('active').addClass('show');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// deprecated
|
|
122
|
+
function paginationAsList(nbResultatsTotal, nbResultatsParPage, urlPage, nomParamPage) {
|
|
123
|
+
var currentUrl = urlPage || window.location.href;
|
|
124
|
+
var afficherLienFirstLastPage = true;
|
|
125
|
+
var afficherLienPagePrecedenteSuivante = true;
|
|
126
|
+
var emptyStringIfOnlyOnePage = true;
|
|
127
|
+
var nbLiensPageDebutFin = 3;
|
|
128
|
+
var nbLiensPageAvantApresPageCourante = 2;
|
|
129
|
+
var strEntreLiensPageDebutFinEtAvantApresPageCourante = '…';
|
|
130
|
+
nomParamPage = nomParamPage || 'page';
|
|
131
|
+
|
|
132
|
+
// Si le nombre de résultat total est inférieur au nombre d'affichage par page, il n'y a qu'une seule page.
|
|
133
|
+
if (nbResultatsTotal < nbResultatsParPage && emptyStringIfOnlyOnePage) {
|
|
134
|
+
return '';
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Initialisation du nombre de pages
|
|
138
|
+
var nbPages = Math.ceil(nbResultatsTotal/nbResultatsParPage);
|
|
139
|
+
|
|
140
|
+
// Initialisation du numéro de la page courante
|
|
141
|
+
//var query = window.location.search.substring(1).query.split("&");
|
|
142
|
+
|
|
143
|
+
var url = new URL(currentUrl);
|
|
144
|
+
var params = url.searchParams;
|
|
145
|
+
|
|
146
|
+
var numPageCourante = 1;
|
|
147
|
+
if (typeof params.get(nomParamPage) != 'undefined' && params.get(nomParamPage) != null) {
|
|
148
|
+
numPageCourante = parseInt(params.get(nomParamPage));
|
|
149
|
+
}
|
|
150
|
+
if (numPageCourante < 0) {
|
|
151
|
+
numPageCourante = 1;
|
|
152
|
+
}
|
|
153
|
+
if (numPageCourante > nbPages) {
|
|
154
|
+
numPageCourante = nbPages;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
var strPagination = '<ul class="pagination">';
|
|
158
|
+
|
|
159
|
+
// Lien pour la première page
|
|
160
|
+
if (afficherLienFirstLastPage) {
|
|
161
|
+
var strLienFirstPage = '<<';
|
|
162
|
+
if (numPageCourante > 1) {
|
|
163
|
+
strPagination += '<li class="page-item"><a class="page-link" href="'+UrlAndQueryString.setParamOfUrl(nomParamPage, 1, currentUrl)+'">'+strLienFirstPage+'</a></li>';
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
strPagination += '<li class="page-item disabled"><a class="page-link" href="#">'+strLienFirstPage+'</a></li>';
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Lien pour la page précédente
|
|
171
|
+
if (afficherLienPagePrecedenteSuivante) {
|
|
172
|
+
var strLienPagePrecedente = '<';
|
|
173
|
+
if (numPageCourante > 1) {
|
|
174
|
+
strPagination += '<li class="page-item"><a class="page-link" href="'+UrlAndQueryString.setParamOfUrl(nomParamPage, (numPageCourante - 1), currentUrl)+'">'+strLienPagePrecedente+'</a></li>';
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
strPagination += '<li class="page-item disabled"><a class="page-link" href="#">'+strLienPagePrecedente+'</a></li>';
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
var strEntreLiensPageDebutEtAvantPageCouranteDejaAffiche = false;
|
|
182
|
+
var strEntreLiensPageFinEtApresPageCouranteDejaAffiche = false;
|
|
183
|
+
|
|
184
|
+
for (var numPage=1; numPage<=nbPages; numPage++) {
|
|
185
|
+
if (numPage < numPageCourante) {
|
|
186
|
+
if (numPage <= nbLiensPageDebutFin || numPage >= (numPageCourante-nbLiensPageAvantApresPageCourante)) {
|
|
187
|
+
strPagination += '<li class="page-item"><a class="page-link" href="'+UrlAndQueryString.setParamOfUrl(nomParamPage, numPage, currentUrl)+'">'+numPage+'</a></li>';
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
if (!strEntreLiensPageDebutEtAvantPageCouranteDejaAffiche) {
|
|
191
|
+
strPagination += '<li class="page-item disabled"><a class="page-link" href="#">'+strEntreLiensPageDebutFinEtAvantApresPageCourante+'</a></li>';
|
|
192
|
+
strEntreLiensPageDebutEtAvantPageCouranteDejaAffiche = true;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
else if (numPage > numPageCourante) {
|
|
197
|
+
if (numPage >= (nbPages-(nbLiensPageDebutFin-1)) || numPage <= (numPageCourante+nbLiensPageAvantApresPageCourante)) {
|
|
198
|
+
strPagination += '<li class="page-item"><a class="page-link" href="'+UrlAndQueryString.setParamOfUrl(nomParamPage, numPage, currentUrl)+'">'+numPage+'</a></li>';
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
if (!strEntreLiensPageFinEtApresPageCouranteDejaAffiche) {
|
|
202
|
+
strPagination += '<li class="page-item disabled"><a class="page-link" href="#">'+strEntreLiensPageDebutFinEtAvantApresPageCourante+'</a></li>';
|
|
203
|
+
strEntreLiensPageFinEtApresPageCouranteDejaAffiche = true;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
strPagination += '<li class="page-item active"><a class="page-link" href="#">'+numPage+'</a></li>';
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Lien pour la page suivante
|
|
213
|
+
if (afficherLienPagePrecedenteSuivante) {
|
|
214
|
+
var strLienPageSuivante = '>';
|
|
215
|
+
if (numPageCourante < nbPages) {
|
|
216
|
+
strPagination += '<li class="page-item"><a class="page-link" href="'+UrlAndQueryString.setParamOfUrl(nomParamPage, (numPageCourante + 1), currentUrl)+'">'+strLienPageSuivante+'</a></li>';
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
strPagination += '<li class="page-item disabled"><a class="page-link" href="#">'+strLienPageSuivante+'</a></li>';
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Lien pour la dernière page
|
|
224
|
+
if (afficherLienFirstLastPage) {
|
|
225
|
+
var strLienLastPage = '>>';
|
|
226
|
+
if (numPageCourante < nbPages) {
|
|
227
|
+
strPagination += '<li class="page-item"><a class="page-link" href="'+UrlAndQueryString.setParamOfUrl(nomParamPage, nbPages, currentUrl)+'">'+strLienLastPage+'</a></li>';
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
strPagination += '<li class="page-item disabled"><a class="page-link" href="#">'+strLienLastPage+'</a></li>';
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
strPagination += '</ul>';
|
|
235
|
+
|
|
236
|
+
return strPagination;
|
|
237
|
+
}
|
package/php.min.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
function chr(codePt){if(codePt>65535){codePt-=65536;return String.fromCharCode(55296+(codePt>>10),56320+(codePt&1023))}return String.fromCharCode(codePt)}
|
|
2
|
+
function ord(string){var str=string+"",code=str.charCodeAt(0);if(55296<=code&&code<=56319){var hi=code;if(str.length===1){return code}var low=str.charCodeAt(1);return((hi-55296)*1024)+(low-56320)+65536}if(56320<=code&&code<=57343){return code}return code}
|
|
3
|
+
function trim(str){return str.replace(/^\s+/g,"").replace(/\s+$/g,"")}
|
|
4
|
+
function empty(mixed_var){var key;if(mixed_var===""||mixed_var===0||mixed_var==="0"||mixed_var===null||mixed_var===false||typeof mixed_var==="undefined"){return true}if(typeof mixed_var=="object"){for(key in mixed_var){return false}return true}return false}
|
package/select_all.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
class SelectAll {
|
|
2
|
+
|
|
3
|
+
// Dans un form-group
|
|
4
|
+
|
|
5
|
+
static initLinkInFormGroup(link) {
|
|
6
|
+
link.off('click').click(function() {
|
|
7
|
+
let formGroup = $(this).closest('.form-group');
|
|
8
|
+
let allCheckbox = formGroup.find('input[type="checkbox"]:not(.check_all)');
|
|
9
|
+
let allCheckboxWithCheckAll = formGroup.find('input[type="checkbox"]');
|
|
10
|
+
let allCheckboxChecked = formGroup.find('input[type="checkbox"]:not(.check_all):checked');
|
|
11
|
+
if (allCheckbox.length === allCheckboxChecked.length) {
|
|
12
|
+
allCheckboxWithCheckAll.prop('checked', false);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
allCheckboxWithCheckAll.prop('checked', true);
|
|
16
|
+
}
|
|
17
|
+
SelectAll.updateFormGroup(formGroup);
|
|
18
|
+
return false;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
link.closest('.form-group').find('input[type="checkbox"]').change(function() {
|
|
22
|
+
SelectAll.updateFormGroup($(this).closest('.form-group'));
|
|
23
|
+
});
|
|
24
|
+
SelectAll.updateFormGroup(link.closest('.form-group'));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static updateFormGroup(formGroup) {
|
|
28
|
+
let allCheckbox = formGroup.find('input[type="checkbox"]:not(.check_all)');
|
|
29
|
+
let allCheckboxChecked = formGroup.find('input[type="checkbox"]:not(.check_all):checked');
|
|
30
|
+
let lienSelectAll = formGroup.find('a.check_all');
|
|
31
|
+
// console.log(formGroup);
|
|
32
|
+
// console.log('SelectAll.updateFormGroup', allCheckbox.length, allCheckboxChecked.length);
|
|
33
|
+
if (allCheckboxChecked.length > 0 && allCheckbox.length === allCheckboxChecked.length) {
|
|
34
|
+
lienSelectAll.text('Tout désélectionner');
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
lienSelectAll.text('Tout sélectionner');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Dans tableau
|
|
42
|
+
|
|
43
|
+
static initInTable(table) {
|
|
44
|
+
let inputCheckAll = table.find('tr input.check_all');
|
|
45
|
+
if (inputCheckAll.length === 0) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
inputCheckAll.off('click').click(function() {
|
|
49
|
+
let allCheckbox = table.find('tbody input[type="checkbox"]');
|
|
50
|
+
let allCheckboxChecked = table.find('tbody input[type="checkbox"]:checked');
|
|
51
|
+
if (allCheckbox.length === allCheckboxChecked.length) {
|
|
52
|
+
allCheckbox.prop('checked', false);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
allCheckbox.prop('checked', true);
|
|
56
|
+
}
|
|
57
|
+
SelectAll.updateTable(table);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
table.find('tbody input[type="checkbox"]').off('change').change(function() {
|
|
61
|
+
SelectAll.updateTable(table);
|
|
62
|
+
});
|
|
63
|
+
SelectAll.updateTable(table);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
static updateTable(table) {
|
|
67
|
+
let allCheckbox = table.find('tbody input[type="checkbox"]');
|
|
68
|
+
let allCheckboxChecked = table.find('tbody input[type="checkbox"]:checked');
|
|
69
|
+
let checkboxSelectAll = table.find('thead input.check_all');
|
|
70
|
+
if (allCheckboxChecked.length > 0 && allCheckbox.length === allCheckboxChecked.length) {
|
|
71
|
+
checkboxSelectAll.prop('checked', true);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
checkboxSelectAll.prop('checked', false);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Dans un div
|
|
79
|
+
|
|
80
|
+
static initDiv(div) {
|
|
81
|
+
div.find('input.check_all').off('click').click(function() {
|
|
82
|
+
let rootDiv = $(this).closest('div.checkbox_with_check_all');
|
|
83
|
+
let allCheckbox = rootDiv.find('input[type="checkbox"]:not(.check_all)');
|
|
84
|
+
let allCheckboxChecked = rootDiv.find('input[type="checkbox"]:not(.check_all):checked');
|
|
85
|
+
if (allCheckbox.length === allCheckboxChecked.length) {
|
|
86
|
+
allCheckbox.prop('checked', false);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
allCheckbox.prop('checked', true);
|
|
90
|
+
}
|
|
91
|
+
SelectAll.updateDiv(rootDiv);
|
|
92
|
+
//SelectAll.updateFormGroup(rootDiv.closest('.form-group'));
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
div.find('div.checkbox, div.form-check').find('input[type="checkbox"]').change(function() {
|
|
96
|
+
SelectAll.updateDiv($(this).closest('div.checkbox_with_check_all'));
|
|
97
|
+
});
|
|
98
|
+
SelectAll.updateDiv(div);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
static updateDiv(div) {
|
|
102
|
+
// console.log('SelectAll.updateDiv');
|
|
103
|
+
// console.log(checkbox);
|
|
104
|
+
// 22/11/2021 : rajout :not(.check_all) sinon si toutes les cases sont coché, la case select all n'est pas coché à l'initialisation
|
|
105
|
+
let allCheckbox = div.find('div.checkbox, div.form-check').find('input[type="checkbox"]:not(.check_all)');
|
|
106
|
+
let allCheckboxChecked = div.find('div.checkbox, div.form-check').find('input[type="checkbox"]:not(.check_all):checked');
|
|
107
|
+
let checkboxSelectAll = div.find('input.check_all');
|
|
108
|
+
if (allCheckboxChecked.length > 0 && allCheckbox.length === allCheckboxChecked.length) {
|
|
109
|
+
checkboxSelectAll.prop('checked', true);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
checkboxSelectAll.prop('checked', false);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
$(function() {
|
|
118
|
+
// Dans un form-group
|
|
119
|
+
$('a.check_all').each(function(idx, link) {
|
|
120
|
+
SelectAll.initLinkInFormGroup($(link));
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// Dans tableau
|
|
124
|
+
$('table tr input.check_all').each(function(idx, inputCheckAll) {
|
|
125
|
+
SelectAll.initInTable($(inputCheckAll).closest('table'));
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// Dans un div
|
|
129
|
+
$('div.checkbox_with_check_all').each(function(idx, div) {
|
|
130
|
+
SelectAll.initDiv($(div));
|
|
131
|
+
});
|
|
132
|
+
});
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
class SocialNetwork {
|
|
2
|
+
|
|
3
|
+
// ---------- Facebook ----------
|
|
4
|
+
|
|
5
|
+
static getButtonFacebookShare(appId, urlPage) {
|
|
6
|
+
/*
|
|
7
|
+
<a target="_blank" title="Facebook" href="https://www.facebook.com/sharer.php?u=<?php the_permalink(); ?>&t=<?php the_title(); ?>" rel="nofollow" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=500,width=700');return false;"><img src="http://korben.info/wp-content/themes/korben2013/hab/facebook_icon.png" alt="Facebook" /></a>
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
return ''
|
|
11
|
+
+'<div id="fb-root"></div>'
|
|
12
|
+
+'<script>(function(d, s, id) {'
|
|
13
|
+
+'var js, fjs = d.getElementsByTagName(s)[0];'
|
|
14
|
+
+'if (d.getElementById(id)) return;'
|
|
15
|
+
+'js = d.createElement(s); js.id = id;'
|
|
16
|
+
+'js.src = "//connect.facebook.net/en_GB/sdk.js#xfbml=1&appId='+appId+'version=v2.0";'
|
|
17
|
+
+'fjs.parentNode.insertBefore(js, fjs);'
|
|
18
|
+
+'}(document, \'script\', \'facebook-jssdk\'));</script>'
|
|
19
|
+
+'<div class="fb-share-button" data-href="'+urlPage+'"></div>'
|
|
20
|
+
;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static getButtonFacebookLike(appId, urlPage) {
|
|
24
|
+
return ''
|
|
25
|
+
+'<div id="fb-root"></div>'
|
|
26
|
+
+'<script type="text/javascript">(function(d, s, id) {'
|
|
27
|
+
+'var js, fjs = d.getElementsByTagName(s)[0];'
|
|
28
|
+
+'if (d.getElementById(id)) return;'
|
|
29
|
+
+'js = d.createElement(s); js.id = id;'
|
|
30
|
+
+'js.src = "//connect.facebook.net/fr_FR/all.js#xfbml=1&appId='+appId+'";'
|
|
31
|
+
+'fjs.parentNode.insertBefore(js, fjs);'
|
|
32
|
+
+'}(document, \'script\', \'facebook-jssdk\'));</script>'
|
|
33
|
+
+'<div class="fb-like" data-href="'+urlPage+'" data-layout="button_count" data-show-faces="true"></div>'
|
|
34
|
+
;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// ---------- Twitter ----------
|
|
38
|
+
|
|
39
|
+
static getButtonTwitterShare(url, text, hashtags='', lang='fr') {
|
|
40
|
+
/*
|
|
41
|
+
<a target="_blank" title="Twitter" href="https://twitter.com/share?url=<?php the_permalink(); ?>&text=<?php the_title(); ?>&via=korben" rel="nofollow" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=400,width=700');return false;"><img src="http://korben.info/wp-content/themes/korben2013/hab/twitter_icon.png" alt="Twitter" /></a>
|
|
42
|
+
*/
|
|
43
|
+
return ''
|
|
44
|
+
+'<a href="https://twitter.com/share" class="twitter-share-button" data-url="'+url+'" data-text="'+text+'" data-lang="'+lang+'" data-hashtags="'+hashtags+'">Tweeter</a>'
|
|
45
|
+
+'<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>'
|
|
46
|
+
;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ---------- Google Plus ----------
|
|
50
|
+
|
|
51
|
+
static getButtonGooglePlusShare(lang='fr') {
|
|
52
|
+
/*
|
|
53
|
+
<a target="_blank" title="Google +" href="https://plus.google.com/share?url=<?php the_permalink(); ?>&hl=fr" rel="nofollow" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=450,width=650');return false;"><img src="http://korben.info/wp-content/themes/korben2013/hab/gplus_icon.png" alt="Google Plus" /></a>
|
|
54
|
+
*/
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static getButtonGooglePlusPlusOne(lang='fr') {
|
|
58
|
+
/*
|
|
59
|
+
$str = '
|
|
60
|
+
<!-- Place this tag where you want the +1 button to render -->
|
|
61
|
+
<div class="g-plusone"></div>
|
|
62
|
+
|
|
63
|
+
<!-- Place this render call where appropriate -->
|
|
64
|
+
<script type="text/javascript">
|
|
65
|
+
window.___gcfg = {lang: \'fr\'};
|
|
66
|
+
|
|
67
|
+
(function() {
|
|
68
|
+
var po = document.createElement(\'script\'); po.type = \'text/javascript\'; po.async = true;
|
|
69
|
+
po.src = \'https://apis.google.com/js/plusone.js\';
|
|
70
|
+
var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(po, s);
|
|
71
|
+
})();
|
|
72
|
+
</script>
|
|
73
|
+
';
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
return ''
|
|
77
|
+
+'<!-- Placez cette balise dans l\'en-tête ou juste avant la balise de fermeture du corps de texte. -->'
|
|
78
|
+
+'<script src="https://apis.google.com/js/platform.js" async defer>{lang: \''+lang+'\'}</script>'
|
|
79
|
+
+'<!-- Placez cette balise où vous souhaitez faire apparaître le gadget Bouton +1. -->'
|
|
80
|
+
+'<div class="g-plusone"></div>'
|
|
81
|
+
;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
// ---------- Linkedin ----------
|
|
86
|
+
|
|
87
|
+
static getButtonLinkedinShare() {
|
|
88
|
+
/*
|
|
89
|
+
<a target="_blank" title="Linkedin" href="https://www.linkedin.com/shareArticle?mini=true&url=<?php the_permalink(); ?>&title=<?php the_title(); ?>" rel="nofollow" onclick="javascript:window.open(this.href, '','menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=450,width=650');return false;"><img src="http://korben.info/wp-content/themes/korben2013/hab/linkedin_icon.png" alt="Linkedin" /></a>
|
|
90
|
+
*/
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
static getButtonLinkedinFollow(id, lang='fr_FR') {
|
|
94
|
+
return ''
|
|
95
|
+
+'<script src="//platform.linkedin.com/in.js" type="text/javascript">lang: '+lang+'</script>'
|
|
96
|
+
+'<script type="IN/FollowCompany" data-id="'+id+'" data-counter="right"></script>'
|
|
97
|
+
;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// ---------- Flattr ----------
|
|
101
|
+
|
|
102
|
+
static getButtonFlattrShare() {
|
|
103
|
+
/*
|
|
104
|
+
<a target="_blank" title="Flattr !" href="https://flattr.com/submit/auto?user_id=Korben&url=<?php the_permalink(); ?>&title=<?php the_title(); ?>&description=<?php bloginfo('description'); ?>&language=fr_FR&tags=blog&category=text" rel="nofollow"><img src="http://korben.info/wp-content/themes/korben2013/hab/flattr_icon.png" alt="Flattr !" /></a>
|
|
105
|
+
*/
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
exports.SocialNetwork = SocialNetwork;
|
package/string.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
|
|
2
|
+
function selectionnerContenuNode(node) {
|
|
3
|
+
if (window.getSelection) {
|
|
4
|
+
var selection = window.getSelection();
|
|
5
|
+
var intervalle = document.createRange();
|
|
6
|
+
intervalle.selectNodeContents(node);
|
|
7
|
+
selection.removeAllRanges();
|
|
8
|
+
selection.addRange(intervalle);
|
|
9
|
+
}
|
|
10
|
+
else if (document.body.createTextRange) {
|
|
11
|
+
var intervalle = document.body.createTextRange();
|
|
12
|
+
intervalle.moveToElementText(node);
|
|
13
|
+
intervalle.select();
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function copierTexte(texte) {
|
|
19
|
+
if (window.clipboardData && clipboardData.setData) {
|
|
20
|
+
window.clipboardData.setData('Text', texte);
|
|
21
|
+
}
|
|
22
|
+
else if (document.body.createTextRange) {
|
|
23
|
+
var textRange = document.body.createTextRange();
|
|
24
|
+
textRange.moveToElementText(texte);
|
|
25
|
+
textRange.execCommand("Copy");
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
try {
|
|
29
|
+
// On test si la configuration permet l'accès au presse-papier.
|
|
30
|
+
netscape.security.PrivilegeManager
|
|
31
|
+
.enablePrivilege("UniversalXPConnect");
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
alert("Impossible d'accéder au presse-papier.");
|
|
35
|
+
}
|
|
36
|
+
// Initialisation du composant fournit par Mozilla.
|
|
37
|
+
var gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper);
|
|
38
|
+
// Copie du texte dans le presse papier.
|
|
39
|
+
gClipboardHelper.copyString(texte);
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function escapeHtml(string) {
|
|
45
|
+
var entityMap = {
|
|
46
|
+
"&": "&",
|
|
47
|
+
"<": "<",
|
|
48
|
+
">": ">",
|
|
49
|
+
'"': '"',
|
|
50
|
+
"'": ''',
|
|
51
|
+
"/": '/'
|
|
52
|
+
};
|
|
53
|
+
return String(string).replace(/[&<>"'\/]/g, (s) => entityMap[s]);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function truncateString(str, length, from, ellipsis, split) {
|
|
57
|
+
var str1, str2, len1, len2;
|
|
58
|
+
if (str.length <= length) {
|
|
59
|
+
return str.toString();
|
|
60
|
+
}
|
|
61
|
+
ellipsis = typeof ellipsis === 'undefined' ? '…' : ellipsis;
|
|
62
|
+
switch(from) {
|
|
63
|
+
case 'left':
|
|
64
|
+
str2 = split ? truncateOnWord(str, length, true) : str.slice(str.length - length);
|
|
65
|
+
return ellipsis + str2;
|
|
66
|
+
case 'middle':
|
|
67
|
+
len1 = ceil(length / 2);
|
|
68
|
+
len2 = floor(length / 2);
|
|
69
|
+
str1 = split ? truncateOnWord(str, len1) : str.slice(0, len1);
|
|
70
|
+
str2 = split ? truncateOnWord(str, len2, true) : str.slice(str.length - len2);
|
|
71
|
+
return str1 + ellipsis + str2;
|
|
72
|
+
default:
|
|
73
|
+
str1 = split ? truncateOnWord(str, length) : str.slice(0, length);
|
|
74
|
+
return str1 + ellipsis;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function truncateOnWord(str, length, from, ellipsis) {
|
|
78
|
+
return truncateString(str, length, from, ellipsis, true);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
String.prototype.htmlentities = String.prototype.htmlentities || function() {
|
|
82
|
+
return this.replace(/[\u00A0-\u9999<>\&]/gim, (i) => '&#'+i.charCodeAt(0)+';');
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
String.prototype.escapeHtml = String.prototype.escapeHtml || function() {
|
|
86
|
+
return escapeHtml(this);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
String.prototype.normalizeBreaks = String.prototype.normalizeBreaks || function(breaktype) {
|
|
90
|
+
return this.replace('/(\r\n|\r|\n)/ms', breaktype);
|
|
91
|
+
//return this.replace('/(?:\r\n|\r|\n)/g', breaktype);
|
|
92
|
+
//console.log(breaktype);
|
|
93
|
+
//return this.replace(new RegExp('\r?\n','g'), breaktype);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
String.prototype.format = String.prototype.format || function() {
|
|
97
|
+
var args = arguments;
|
|
98
|
+
return this.replace(/{(\d+)}/g, (match, number) => (typeof args[number] != 'undefined' ? args[number] : match));
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
String.prototype.ucwords = function() {
|
|
102
|
+
return this.toLowerCase().replace(/(^([a-zA-Z\p{M}]))|([ -][a-zA-Z\p{M}])/g, ($1) => $1.toUpperCase());
|
|
103
|
+
};
|
|
104
|
+
String.prototype.capitalize = function() {
|
|
105
|
+
return this.charAt(0).toUpperCase() + this.slice(1);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
String.prototype.encodeForHtmlDataAttribute = function() {
|
|
109
|
+
return this.replace(/\"/g, "'");
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// s'utilise : "ma chaine {0} de caracteres"
|
|
113
|
+
if (!String.format) {
|
|
114
|
+
String.format = function(format) {
|
|
115
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
|
116
|
+
return format.replace(/{(\d+)}/g, (match, number) => (typeof args[number] != 'undefined' ? args[number] : match));
|
|
117
|
+
};
|
|
118
|
+
}
|
package/tree.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
|
|
2
|
+
/*
|
|
3
|
+
* SIDEBAR MENU
|
|
4
|
+
* ------------
|
|
5
|
+
* This is a custom plugin for the sidebar menu. It provides a tree view.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* $(".sidebar).tree();
|
|
9
|
+
*
|
|
10
|
+
* Note: This plugin does not accept any options. Instead, it only requires a class added to the element that contains a sub-menu.
|
|
11
|
+
*
|
|
12
|
+
* When used with the sidebar, for example, it would look something like this:
|
|
13
|
+
* <ul class='sidebar-menu'>
|
|
14
|
+
* <li class="treeview active">
|
|
15
|
+
* <a href="#>Menu</a>
|
|
16
|
+
* <ul class='treeview-menu'>
|
|
17
|
+
* <li class='active'><a href=#>Level 1</a></li>
|
|
18
|
+
* </ul>
|
|
19
|
+
* </li>
|
|
20
|
+
* </ul>
|
|
21
|
+
*
|
|
22
|
+
* Add .active class to <li> elements if you want the menu to be open automatically
|
|
23
|
+
* on page load. See above for an example.
|
|
24
|
+
*/
|
|
25
|
+
(function($) {
|
|
26
|
+
"use strict";
|
|
27
|
+
|
|
28
|
+
$.fn.tree = function() {
|
|
29
|
+
return this.each(function() {
|
|
30
|
+
var btn = $(this).children("a").first();
|
|
31
|
+
// var btn = $('a.sidebar-toggle');
|
|
32
|
+
var menu = $(this).children(".treeview-menu").first();
|
|
33
|
+
var isActive = $(this).hasClass('active');
|
|
34
|
+
// isActive = true;
|
|
35
|
+
|
|
36
|
+
//initialize already active menus
|
|
37
|
+
// if (isActive) {
|
|
38
|
+
menu.show();
|
|
39
|
+
btn.children(".fa-angle-left").first().removeClass("fa-angle-left").addClass("fa-angle-down");
|
|
40
|
+
// }
|
|
41
|
+
// else {
|
|
42
|
+
// menu.show();
|
|
43
|
+
// }
|
|
44
|
+
//Slide open or close the menu on link click
|
|
45
|
+
btn.click(function(e) {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
if (isActive) {
|
|
48
|
+
// Slide up to close menu
|
|
49
|
+
menu.slideUp();
|
|
50
|
+
isActive = false;
|
|
51
|
+
btn.children(".fa-angle-down").first().removeClass("fa-angle-down").addClass("fa-angle-left");
|
|
52
|
+
btn.parent("li").removeClass("active");
|
|
53
|
+
} else {
|
|
54
|
+
// Slide down to open menu
|
|
55
|
+
menu.slideDown();
|
|
56
|
+
isActive = true;
|
|
57
|
+
btn.children(".fa-angle-left").first().removeClass("fa-angle-left").addClass("fa-angle-down");
|
|
58
|
+
btn.parent("li").addClass("active");
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
/* Add margins to submenu elements to give it a tree look */
|
|
63
|
+
menu.find("li > a").each(function() {
|
|
64
|
+
var pad = parseInt($(this).css("margin-left")) + 10;
|
|
65
|
+
|
|
66
|
+
$(this).css({"margin-left": pad + "px"});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
}(jQuery));
|