@bebranded/bb-contents 1.0.121 → 1.0.123
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/bb-contents.js +322 -19
- package/package.json +1 -1
package/bb-contents.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* BeBranded Contents
|
|
3
3
|
* Contenus additionnels français pour Webflow
|
|
4
|
-
* @version 1.0.
|
|
4
|
+
* @version 1.0.123
|
|
5
5
|
* @author BeBranded
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @website https://www.bebranded.xyz
|
|
@@ -32,16 +32,19 @@
|
|
|
32
32
|
window._bbContentsInitialized = true;
|
|
33
33
|
|
|
34
34
|
// Log de démarrage simple (une seule fois)
|
|
35
|
-
console.log('bb-contents | v1.0.
|
|
35
|
+
console.log('bb-contents | v1.0.123');
|
|
36
36
|
|
|
37
37
|
// Configuration
|
|
38
38
|
const config = {
|
|
39
|
-
version: '1.0.
|
|
39
|
+
version: '1.0.123',
|
|
40
40
|
debug: false, // Debug désactivé pour rendu propre
|
|
41
41
|
prefix: 'bb-', // utilisé pour générer les sélecteurs (data-bb-*)
|
|
42
42
|
youtubeEndpoint: null, // URL du worker YouTube (à définir par l'utilisateur)
|
|
43
43
|
i18n: {
|
|
44
|
-
copied: 'Lien copié !'
|
|
44
|
+
copied: 'Lien copié !',
|
|
45
|
+
selectCountry: { fr: 'Sélectionner un pays', en: 'Select country' },
|
|
46
|
+
searchCountry: { fr: 'Rechercher un pays...', en: 'Search country...' },
|
|
47
|
+
noCountryFound: { fr: 'Aucun pays trouvé', en: 'No country found' }
|
|
45
48
|
}
|
|
46
49
|
};
|
|
47
50
|
|
|
@@ -310,6 +313,42 @@
|
|
|
310
313
|
|
|
311
314
|
const mainBlock = document.createElement('div');
|
|
312
315
|
mainBlock.innerHTML = originalHTML;
|
|
316
|
+
|
|
317
|
+
// Permettre le retour à la ligne pour le texte dans les items du marquee
|
|
318
|
+
// Le white-space: nowrap sur le conteneur flex empêche les items de se retourner,
|
|
319
|
+
// mais ne doit pas empêcher le texte à l'intérieur des items de faire plusieurs lignes
|
|
320
|
+
if (!isVertical) {
|
|
321
|
+
setTimeout(() => {
|
|
322
|
+
const marqueeItems = mainBlock.querySelectorAll('.bb-marquee_item, [role="listitem"]');
|
|
323
|
+
marqueeItems.forEach(item => {
|
|
324
|
+
// Préserver la largeur de l'item définie dans Webflow
|
|
325
|
+
const computedStyle = getComputedStyle(item);
|
|
326
|
+
const itemWidth = computedStyle.width;
|
|
327
|
+
if (itemWidth && itemWidth !== 'auto' && itemWidth !== '0px') {
|
|
328
|
+
item.style.minWidth = itemWidth;
|
|
329
|
+
item.style.width = itemWidth;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Permettre le retour à la ligne pour les conteneurs de texte
|
|
333
|
+
const textContainers = item.querySelectorAll('.use-case_client, .testimonial_client-info, [class*="text"], p, span');
|
|
334
|
+
textContainers.forEach(container => {
|
|
335
|
+
const containerComputed = getComputedStyle(container);
|
|
336
|
+
// Si l'élément a une largeur définie, la préserver
|
|
337
|
+
if (containerComputed.width && containerComputed.width !== 'auto' && containerComputed.width !== '0px') {
|
|
338
|
+
container.style.width = containerComputed.width;
|
|
339
|
+
} else {
|
|
340
|
+
// Sinon, prendre 100% de la largeur du parent
|
|
341
|
+
container.style.width = '100%';
|
|
342
|
+
}
|
|
343
|
+
// Forcer le retour à la ligne
|
|
344
|
+
container.style.whiteSpace = 'normal';
|
|
345
|
+
container.style.wordWrap = 'break-word';
|
|
346
|
+
container.style.overflowWrap = 'break-word';
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
}, 0);
|
|
350
|
+
}
|
|
351
|
+
|
|
313
352
|
mainBlock.style.cssText = `
|
|
314
353
|
display: flex;
|
|
315
354
|
${isVertical ? 'flex-direction: column;' : ''}
|
|
@@ -554,10 +593,10 @@
|
|
|
554
593
|
// Toutes les images sont chargées ET ont leurs dimensions
|
|
555
594
|
// Attendre plus longtemps sur mobile Safari pour le rendu visuel
|
|
556
595
|
const renderDelay = isSafari && isMobile ? 1500 : (isMobile ? 1000 : 200);
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
596
|
+
setTimeout(() => {
|
|
597
|
+
startSafariAnimation();
|
|
598
|
+
}, renderDelay);
|
|
599
|
+
} else {
|
|
561
600
|
// Continuer à attendre que les dimensions soient disponibles
|
|
562
601
|
setTimeout(waitForImages, 100);
|
|
563
602
|
}
|
|
@@ -633,7 +672,7 @@
|
|
|
633
672
|
let currentPosition;
|
|
634
673
|
if (direction === (isVertical ? 'bottom' : 'right')) {
|
|
635
674
|
currentPosition = -(finalContentSize + gapSize);
|
|
636
|
-
|
|
675
|
+
} else {
|
|
637
676
|
currentPosition = 0;
|
|
638
677
|
}
|
|
639
678
|
|
|
@@ -642,7 +681,7 @@
|
|
|
642
681
|
? `translate3d(0, ${currentPosition}px, 0)`
|
|
643
682
|
: `translate3d(${currentPosition}px, 0, 0)`;
|
|
644
683
|
scrollContainer.style.transform = initialTransform;
|
|
645
|
-
|
|
684
|
+
|
|
646
685
|
// OPTIMISATION SAFARI MOBILE : Forcer un reflow avant de démarrer l'animation
|
|
647
686
|
if (isSafari && isMobile) {
|
|
648
687
|
void scrollContainer.offsetHeight;
|
|
@@ -661,7 +700,7 @@
|
|
|
661
700
|
if (currentPosition >= 0) {
|
|
662
701
|
currentPosition = -(finalContentSize + gapSize);
|
|
663
702
|
}
|
|
664
|
-
|
|
703
|
+
} else {
|
|
665
704
|
currentPosition -= step * deltaTime;
|
|
666
705
|
if (currentPosition <= -(2 * (finalContentSize + gapSize))) {
|
|
667
706
|
currentPosition = -(finalContentSize + gapSize);
|
|
@@ -690,10 +729,10 @@
|
|
|
690
729
|
});
|
|
691
730
|
});
|
|
692
731
|
} else {
|
|
693
|
-
|
|
732
|
+
setTimeout(() => {
|
|
694
733
|
lastTime = performance.now();
|
|
695
734
|
animate(lastTime);
|
|
696
|
-
|
|
735
|
+
}, 50);
|
|
697
736
|
}
|
|
698
737
|
|
|
699
738
|
// Pause au survol pour Safari
|
|
@@ -1083,7 +1122,7 @@
|
|
|
1083
1122
|
if (element.bbProcessed) return;
|
|
1084
1123
|
element.bbProcessed = true;
|
|
1085
1124
|
|
|
1086
|
-
|
|
1125
|
+
const targetSelector = bbContents._getAttr(element, 'bb-reading-time-target');
|
|
1087
1126
|
const speedAttr = bbContents._getAttr(element, 'bb-reading-time-speed');
|
|
1088
1127
|
const imageSpeedAttr = bbContents._getAttr(element, 'bb-reading-time-image-speed');
|
|
1089
1128
|
const format = bbContents._getAttr(element, 'bb-reading-time-format') || '{minutes} min';
|
|
@@ -1091,12 +1130,12 @@
|
|
|
1091
1130
|
|
|
1092
1131
|
// Validation et correction des valeurs
|
|
1093
1132
|
let wordsPerMinute = Number(speedAttr);
|
|
1094
|
-
|
|
1133
|
+
if (isNaN(wordsPerMinute) || wordsPerMinute <= 0) {
|
|
1095
1134
|
wordsPerMinute = 230;
|
|
1096
|
-
|
|
1135
|
+
}
|
|
1097
1136
|
|
|
1098
1137
|
let secondsPerImage = Number(imageSpeedAttr);
|
|
1099
|
-
|
|
1138
|
+
if (isNaN(secondsPerImage) || secondsPerImage < 0) {
|
|
1100
1139
|
secondsPerImage = 12;
|
|
1101
1140
|
}
|
|
1102
1141
|
|
|
@@ -1148,7 +1187,7 @@
|
|
|
1148
1187
|
sourceNodes = [element];
|
|
1149
1188
|
} else {
|
|
1150
1189
|
sourceNodes = Array.from(foundNodes);
|
|
1151
|
-
|
|
1190
|
+
}
|
|
1152
1191
|
} else {
|
|
1153
1192
|
sourceNodes = [element];
|
|
1154
1193
|
}
|
|
@@ -1179,6 +1218,270 @@
|
|
|
1179
1218
|
}
|
|
1180
1219
|
},
|
|
1181
1220
|
|
|
1221
|
+
// Module Country Select
|
|
1222
|
+
countrySelect: {
|
|
1223
|
+
// Liste complète des pays ISO 3166
|
|
1224
|
+
countries: [
|
|
1225
|
+
{alpha2:'AD',alpha3:'AND',name:{fr:'Andorre',en:'Andorra'}},{alpha2:'AE',alpha3:'ARE',name:{fr:'Émirats arabes unis',en:'United Arab Emirates'}},{alpha2:'AF',alpha3:'AFG',name:{fr:'Afghanistan',en:'Afghanistan'}},{alpha2:'AG',alpha3:'ATG',name:{fr:'Antigua-et-Barbuda',en:'Antigua and Barbuda'}},{alpha2:'AI',alpha3:'AIA',name:{fr:'Anguilla',en:'Anguilla'}},{alpha2:'AL',alpha3:'ALB',name:{fr:'Albanie',en:'Albania'}},{alpha2:'AM',alpha3:'ARM',name:{fr:'Arménie',en:'Armenia'}},{alpha2:'AO',alpha3:'AGO',name:{fr:'Angola',en:'Angola'}},{alpha2:'AQ',alpha3:'ATA',name:{fr:'Antarctique',en:'Antarctica'}},{alpha2:'AR',alpha3:'ARG',name:{fr:'Argentine',en:'Argentina'}},{alpha2:'AS',alpha3:'ASM',name:{fr:'Samoa américaines',en:'American Samoa'}},{alpha2:'AT',alpha3:'AUT',name:{fr:'Autriche',en:'Austria'}},{alpha2:'AU',alpha3:'AUS',name:{fr:'Australie',en:'Australia'}},{alpha2:'AW',alpha3:'ABW',name:{fr:'Aruba',en:'Aruba'}},{alpha2:'AX',alpha3:'ALA',name:{fr:'Åland',en:'Åland Islands'}},{alpha2:'AZ',alpha3:'AZE',name:{fr:'Azerbaïdjan',en:'Azerbaijan'}},{alpha2:'BA',alpha3:'BIH',name:{fr:'Bosnie-Herzégovine',en:'Bosnia and Herzegovina'}},{alpha2:'BB',alpha3:'BRB',name:{fr:'Barbade',en:'Barbados'}},{alpha2:'BD',alpha3:'BGD',name:{fr:'Bangladesh',en:'Bangladesh'}},{alpha2:'BE',alpha3:'BEL',name:{fr:'Belgique',en:'Belgium'}},{alpha2:'BF',alpha3:'BFA',name:{fr:'Burkina Faso',en:'Burkina Faso'}},{alpha2:'BG',alpha3:'BGR',name:{fr:'Bulgarie',en:'Bulgaria'}},{alpha2:'BH',alpha3:'BHR',name:{fr:'Bahreïn',en:'Bahrain'}},{alpha2:'BI',alpha3:'BDI',name:{fr:'Burundi',en:'Burundi'}},{alpha2:'BJ',alpha3:'BEN',name:{fr:'Bénin',en:'Benin'}},{alpha2:'BL',alpha3:'BLM',name:{fr:'Saint-Barthélemy',en:'Saint Barthélemy'}},{alpha2:'BM',alpha3:'BMU',name:{fr:'Bermudes',en:'Bermuda'}},{alpha2:'BN',alpha3:'BRN',name:{fr:'Brunei',en:'Brunei'}},{alpha2:'BO',alpha3:'BOL',name:{fr:'Bolivie',en:'Bolivia'}},{alpha2:'BQ',alpha3:'BES',name:{fr:'Pays-Bas caribéens',en:'Caribbean Netherlands'}},{alpha2:'BR',alpha3:'BRA',name:{fr:'Brésil',en:'Brazil'}},{alpha2:'BS',alpha3:'BHS',name:{fr:'Bahamas',en:'Bahamas'}},{alpha2:'BT',alpha3:'BTN',name:{fr:'Bhoutan',en:'Bhutan'}},{alpha2:'BV',alpha3:'BVT',name:{fr:'Île Bouvet',en:'Bouvet Island'}},{alpha2:'BW',alpha3:'BWA',name:{fr:'Botswana',en:'Botswana'}},{alpha2:'BY',alpha3:'BLR',name:{fr:'Biélorussie',en:'Belarus'}},{alpha2:'BZ',alpha3:'BLZ',name:{fr:'Belize',en:'Belize'}},{alpha2:'CA',alpha3:'CAN',name:{fr:'Canada',en:'Canada'}},{alpha2:'CC',alpha3:'CCK',name:{fr:'Îles Cocos',en:'Cocos Islands'}},{alpha2:'CD',alpha3:'COD',name:{fr:'République démocratique du Congo',en:'Democratic Republic of the Congo'}},{alpha2:'CF',alpha3:'CAF',name:{fr:'République centrafricaine',en:'Central African Republic'}},{alpha2:'CG',alpha3:'COG',name:{fr:'Congo',en:'Republic of the Congo'}},{alpha2:'CH',alpha3:'CHE',name:{fr:'Suisse',en:'Switzerland'}},{alpha2:'CI',alpha3:'CIV',name:{fr:"Côte d'Ivoire",en:'Ivory Coast'}},{alpha2:'CK',alpha3:'COK',name:{fr:'Îles Cook',en:'Cook Islands'}},{alpha2:'CL',alpha3:'CHL',name:{fr:'Chili',en:'Chile'}},{alpha2:'CM',alpha3:'CMR',name:{fr:'Cameroun',en:'Cameroon'}},{alpha2:'CN',alpha3:'CHN',name:{fr:'Chine',en:'China'}},{alpha2:'CO',alpha3:'COL',name:{fr:'Colombie',en:'Colombia'}},{alpha2:'CR',alpha3:'CRI',name:{fr:'Costa Rica',en:'Costa Rica'}},{alpha2:'CU',alpha3:'CUB',name:{fr:'Cuba',en:'Cuba'}},{alpha2:'CV',alpha3:'CPV',name:{fr:'Cap-Vert',en:'Cape Verde'}},{alpha2:'CW',alpha3:'CUW',name:{fr:'Curaçao',en:'Curaçao'}},{alpha2:'CX',alpha3:'CXR',name:{fr:'Île Christmas',en:'Christmas Island'}},{alpha2:'CY',alpha3:'CYP',name:{fr:'Chypre',en:'Cyprus'}},{alpha2:'CZ',alpha3:'CZE',name:{fr:'Tchéquie',en:'Czechia'}},{alpha2:'DE',alpha3:'DEU',name:{fr:'Allemagne',en:'Germany'}},{alpha2:'DJ',alpha3:'DJI',name:{fr:'Djibouti',en:'Djibouti'}},{alpha2:'DK',alpha3:'DNK',name:{fr:'Danemark',en:'Denmark'}},{alpha2:'DM',alpha3:'DMA',name:{fr:'Dominique',en:'Dominica'}},{alpha2:'DO',alpha3:'DOM',name:{fr:'République dominicaine',en:'Dominican Republic'}},{alpha2:'DZ',alpha3:'DZA',name:{fr:'Algérie',en:'Algeria'}},{alpha2:'EC',alpha3:'ECU',name:{fr:'Équateur',en:'Ecuador'}},{alpha2:'EE',alpha3:'EST',name:{fr:'Estonie',en:'Estonia'}},{alpha2:'EG',alpha3:'EGY',name:{fr:'Égypte',en:'Egypt'}},{alpha2:'EH',alpha3:'ESH',name:{fr:'Sahara occidental',en:'Western Sahara'}},{alpha2:'ER',alpha3:'ERI',name:{fr:'Érythrée',en:'Eritrea'}},{alpha2:'ES',alpha3:'ESP',name:{fr:'Espagne',en:'Spain'}},{alpha2:'ET',alpha3:'ETH',name:{fr:'Éthiopie',en:'Ethiopia'}},{alpha2:'FI',alpha3:'FIN',name:{fr:'Finlande',en:'Finland'}},{alpha2:'FJ',alpha3:'FJI',name:{fr:'Fidji',en:'Fiji'}},{alpha2:'FK',alpha3:'FLK',name:{fr:'Îles Malouines',en:'Falkland Islands'}},{alpha2:'FM',alpha3:'FSM',name:{fr:'Micronésie',en:'Micronesia'}},{alpha2:'FO',alpha3:'FRO',name:{fr:'Îles Féroé',en:'Faroe Islands'}},{alpha2:'FR',alpha3:'FRA',name:{fr:'France',en:'France'}},{alpha2:'GA',alpha3:'GAB',name:{fr:'Gabon',en:'Gabon'}},{alpha2:'GB',alpha3:'GBR',name:{fr:'Royaume-Uni',en:'United Kingdom'}},{alpha2:'GD',alpha3:'GRD',name:{fr:'Grenade',en:'Grenada'}},{alpha2:'GE',alpha3:'GEO',name:{fr:'Géorgie',en:'Georgia'}},{alpha2:'GF',alpha3:'GUF',name:{fr:'Guyane française',en:'French Guiana'}},{alpha2:'GG',alpha3:'GGY',name:{fr:'Guernesey',en:'Guernsey'}},{alpha2:'GH',alpha3:'GHA',name:{fr:'Ghana',en:'Ghana'}},{alpha2:'GI',alpha3:'GIB',name:{fr:'Gibraltar',en:'Gibraltar'}},{alpha2:'GL',alpha3:'GRL',name:{fr:'Groenland',en:'Greenland'}},{alpha2:'GM',alpha3:'GMB',name:{fr:'Gambie',en:'Gambia'}},{alpha2:'GN',alpha3:'GIN',name:{fr:'Guinée',en:'Guinea'}},{alpha2:'GP',alpha3:'GLP',name:{fr:'Guadeloupe',en:'Guadeloupe'}},{alpha2:'GQ',alpha3:'GNQ',name:{fr:'Guinée équatoriale',en:'Equatorial Guinea'}},{alpha2:'GR',alpha3:'GRC',name:{fr:'Grèce',en:'Greece'}},{alpha2:'GS',alpha3:'SGS',name:{fr:'Géorgie du Sud-et-les Îles Sandwich du Sud',en:'South Georgia and the South Sandwich Islands'}},{alpha2:'GT',alpha3:'GTM',name:{fr:'Guatemala',en:'Guatemala'}},{alpha2:'GU',alpha3:'GUM',name:{fr:'Guam',en:'Guam'}},{alpha2:'GW',alpha3:'GNB',name:{fr:'Guinée-Bissau',en:'Guinea-Bissau'}},{alpha2:'GY',alpha3:'GUY',name:{fr:'Guyane',en:'Guyana'}},{alpha2:'HK',alpha3:'HKG',name:{fr:'Hong Kong',en:'Hong Kong'}},{alpha2:'HM',alpha3:'HMD',name:{fr:'Îles Heard-et-MacDonald',en:'Heard Island and McDonald Islands'}},{alpha2:'HN',alpha3:'HND',name:{fr:'Honduras',en:'Honduras'}},{alpha2:'HR',alpha3:'HRV',name:{fr:'Croatie',en:'Croatia'}},{alpha2:'HT',alpha3:'HTI',name:{fr:'Haïti',en:'Haiti'}},{alpha2:'HU',alpha3:'HUN',name:{fr:'Hongrie',en:'Hungary'}},{alpha2:'ID',alpha3:'IDN',name:{fr:'Indonésie',en:'Indonesia'}},{alpha2:'IE',alpha3:'IRL',name:{fr:'Irlande',en:'Ireland'}},{alpha2:'IL',alpha3:'ISR',name:{fr:'Israël',en:'Israel'}},{alpha2:'IM',alpha3:'IMN',name:{fr:'Île de Man',en:'Isle of Man'}},{alpha2:'IN',alpha3:'IND',name:{fr:'Inde',en:'India'}},{alpha2:'IO',alpha3:'IOT',name:{fr:'Territoire britannique de l\'océan Indien',en:'British Indian Ocean Territory'}},{alpha2:'IQ',alpha3:'IRQ',name:{fr:'Irak',en:'Iraq'}},{alpha2:'IR',alpha3:'IRN',name:{fr:'Iran',en:'Iran'}},{alpha2:'IS',alpha3:'ISL',name:{fr:'Islande',en:'Iceland'}},{alpha2:'IT',alpha3:'ITA',name:{fr:'Italie',en:'Italy'}},{alpha2:'JE',alpha3:'JEY',name:{fr:'Jersey',en:'Jersey'}},{alpha2:'JM',alpha3:'JAM',name:{fr:'Jamaïque',en:'Jamaica'}},{alpha2:'JO',alpha3:'JOR',name:{fr:'Jordanie',en:'Jordan'}},{alpha2:'JP',alpha3:'JPN',name:{fr:'Japon',en:'Japan'}},{alpha2:'KE',alpha3:'KEN',name:{fr:'Kenya',en:'Kenya'}},{alpha2:'KG',alpha3:'KGZ',name:{fr:'Kirghizistan',en:'Kyrgyzstan'}},{alpha2:'KH',alpha3:'KHM',name:{fr:'Cambodge',en:'Cambodia'}},{alpha2:'KI',alpha3:'KIR',name:{fr:'Kiribati',en:'Kiribati'}},{alpha2:'KM',alpha3:'COM',name:{fr:'Comores',en:'Comoros'}},{alpha2:'KN',alpha3:'KNA',name:{fr:'Saint-Kitts-et-Nevis',en:'Saint Kitts and Nevis'}},{alpha2:'KP',alpha3:'PRK',name:{fr:'Corée du Nord',en:'North Korea'}},{alpha2:'KR',alpha3:'KOR',name:{fr:'Corée du Sud',en:'South Korea'}},{alpha2:'KW',alpha3:'KWT',name:{fr:'Koweït',en:'Kuwait'}},{alpha2:'KY',alpha3:'CYM',name:{fr:'Îles Caïmans',en:'Cayman Islands'}},{alpha2:'KZ',alpha3:'KAZ',name:{fr:'Kazakhstan',en:'Kazakhstan'}},{alpha2:'LA',alpha3:'LAO',name:{fr:'Laos',en:'Laos'}},{alpha2:'LB',alpha3:'LBN',name:{fr:'Liban',en:'Lebanon'}},{alpha2:'LC',alpha3:'LCA',name:{fr:'Sainte-Lucie',en:'Saint Lucia'}},{alpha2:'LI',alpha3:'LIE',name:{fr:'Liechtenstein',en:'Liechtenstein'}},{alpha2:'LK',alpha3:'LKA',name:{fr:'Sri Lanka',en:'Sri Lanka'}},{alpha2:'LR',alpha3:'LBR',name:{fr:'Liberia',en:'Liberia'}},{alpha2:'LS',alpha3:'LSO',name:{fr:'Lesotho',en:'Lesotho'}},{alpha2:'LT',alpha3:'LTU',name:{fr:'Lituanie',en:'Lithuania'}},{alpha2:'LU',alpha3:'LUX',name:{fr:'Luxembourg',en:'Luxembourg'}},{alpha2:'LV',alpha3:'LVA',name:{fr:'Lettonie',en:'Latvia'}},{alpha2:'LY',alpha3:'LBY',name:{fr:'Libye',en:'Libya'}},{alpha2:'MA',alpha3:'MAR',name:{fr:'Maroc',en:'Morocco'}},{alpha2:'MC',alpha3:'MCO',name:{fr:'Monaco',en:'Monaco'}},{alpha2:'MD',alpha3:'MDA',name:{fr:'Moldavie',en:'Moldova'}},{alpha2:'ME',alpha3:'MNE',name:{fr:'Monténégro',en:'Montenegro'}},{alpha2:'MF',alpha3:'MAF',name:{fr:'Saint-Martin',en:'Saint Martin'}},{alpha2:'MG',alpha3:'MDG',name:{fr:'Madagascar',en:'Madagascar'}},{alpha2:'MH',alpha3:'MHL',name:{fr:'Îles Marshall',en:'Marshall Islands'}},{alpha2:'MK',alpha3:'MKD',name:{fr:'Macédoine du Nord',en:'North Macedonia'}},{alpha2:'ML',alpha3:'MLI',name:{fr:'Mali',en:'Mali'}},{alpha2:'MM',alpha3:'MMR',name:{fr:'Myanmar',en:'Myanmar'}},{alpha2:'MN',alpha3:'MNG',name:{fr:'Mongolie',en:'Mongolia'}},{alpha2:'MO',alpha3:'MAC',name:{fr:'Macao',en:'Macao'}},{alpha2:'MP',alpha3:'MNP',name:{fr:'Îles Mariannes du Nord',en:'Northern Mariana Islands'}},{alpha2:'MQ',alpha3:'MTQ',name:{fr:'Martinique',en:'Martinique'}},{alpha2:'MR',alpha3:'MRT',name:{fr:'Mauritanie',en:'Mauritania'}},{alpha2:'MS',alpha3:'MSR',name:{fr:'Montserrat',en:'Montserrat'}},{alpha2:'MT',alpha3:'MLT',name:{fr:'Malte',en:'Malta'}},{alpha2:'MU',alpha3:'MUS',name:{fr:'Maurice',en:'Mauritius'}},{alpha2:'MV',alpha3:'MDV',name:{fr:'Maldives',en:'Maldives'}},{alpha2:'MW',alpha3:'MWI',name:{fr:'Malawi',en:'Malawi'}},{alpha2:'MX',alpha3:'MEX',name:{fr:'Mexique',en:'Mexico'}},{alpha2:'MY',alpha3:'MYS',name:{fr:'Malaisie',en:'Malaysia'}},{alpha2:'MZ',alpha3:'MOZ',name:{fr:'Mozambique',en:'Mozambique'}},{alpha2:'NA',alpha3:'NAM',name:{fr:'Namibie',en:'Namibia'}},{alpha2:'NC',alpha3:'NCL',name:{fr:'Nouvelle-Calédonie',en:'New Caledonia'}},{alpha2:'NE',alpha3:'NER',name:{fr:'Niger',en:'Niger'}},{alpha2:'NF',alpha3:'NFK',name:{fr:'Île Norfolk',en:'Norfolk Island'}},{alpha2:'NG',alpha3:'NGA',name:{fr:'Nigeria',en:'Nigeria'}},{alpha2:'NI',alpha3:'NIC',name:{fr:'Nicaragua',en:'Nicaragua'}},{alpha2:'NL',alpha3:'NLD',name:{fr:'Pays-Bas',en:'Netherlands'}},{alpha2:'NO',alpha3:'NOR',name:{fr:'Norvège',en:'Norway'}},{alpha2:'NP',alpha3:'NPL',name:{fr:'Népal',en:'Nepal'}},{alpha2:'NR',alpha3:'NRU',name:{fr:'Nauru',en:'Nauru'}},{alpha2:'NU',alpha3:'NIU',name:{fr:'Niue',en:'Niue'}},{alpha2:'NZ',alpha3:'NZL',name:{fr:'Nouvelle-Zélande',en:'New Zealand'}},{alpha2:'OM',alpha3:'OMN',name:{fr:'Oman',en:'Oman'}},{alpha2:'PA',alpha3:'PAN',name:{fr:'Panama',en:'Panama'}},{alpha2:'PE',alpha3:'PER',name:{fr:'Pérou',en:'Peru'}},{alpha2:'PF',alpha3:'PYF',name:{fr:'Polynésie française',en:'French Polynesia'}},{alpha2:'PG',alpha3:'PNG',name:{fr:'Papouasie-Nouvelle-Guinée',en:'Papua New Guinea'}},{alpha2:'PH',alpha3:'PHL',name:{fr:'Philippines',en:'Philippines'}},{alpha2:'PK',alpha3:'PAK',name:{fr:'Pakistan',en:'Pakistan'}},{alpha2:'PL',alpha3:'POL',name:{fr:'Pologne',en:'Poland'}},{alpha2:'PM',alpha3:'SPM',name:{fr:'Saint-Pierre-et-Miquelon',en:'Saint Pierre and Miquelon'}},{alpha2:'PN',alpha3:'PCN',name:{fr:'Pitcairn',en:'Pitcairn'}},{alpha2:'PR',alpha3:'PRI',name:{fr:'Porto Rico',en:'Puerto Rico'}},{alpha2:'PS',alpha3:'PSE',name:{fr:'Palestine',en:'Palestine'}},{alpha2:'PT',alpha3:'PRT',name:{fr:'Portugal',en:'Portugal'}},{alpha2:'PW',alpha3:'PLW',name:{fr:'Palaos',en:'Palau'}},{alpha2:'PY',alpha3:'PRY',name:{fr:'Paraguay',en:'Paraguay'}},{alpha2:'QA',alpha3:'QAT',name:{fr:'Qatar',en:'Qatar'}},{alpha2:'RE',alpha3:'REU',name:{fr:'La Réunion',en:'Réunion'}},{alpha2:'RO',alpha3:'ROU',name:{fr:'Roumanie',en:'Romania'}},{alpha2:'RS',alpha3:'SRB',name:{fr:'Serbie',en:'Serbia'}},{alpha2:'RU',alpha3:'RUS',name:{fr:'Russie',en:'Russia'}},{alpha2:'RW',alpha3:'RWA',name:{fr:'Rwanda',en:'Rwanda'}},{alpha2:'SA',alpha3:'SAU',name:{fr:'Arabie saoudite',en:'Saudi Arabia'}},{alpha2:'SB',alpha3:'SLB',name:{fr:'Îles Salomon',en:'Solomon Islands'}},{alpha2:'SC',alpha3:'SYC',name:{fr:'Seychelles',en:'Seychelles'}},{alpha2:'SD',alpha3:'SDN',name:{fr:'Soudan',en:'Sudan'}},{alpha2:'SE',alpha3:'SWE',name:{fr:'Suède',en:'Sweden'}},{alpha2:'SG',alpha3:'SGP',name:{fr:'Singapour',en:'Singapore'}},{alpha2:'SH',alpha3:'SHN',name:{fr:'Sainte-Hélène',en:'Saint Helena'}},{alpha2:'SI',alpha3:'SVN',name:{fr:'Slovénie',en:'Slovenia'}},{alpha2:'SJ',alpha3:'SJM',name:{fr:'Svalbard et Jan Mayen',en:'Svalbard and Jan Mayen'}},{alpha2:'SK',alpha3:'SVK',name:{fr:'Slovaquie',en:'Slovakia'}},{alpha2:'SL',alpha3:'SLE',name:{fr:'Sierra Leone',en:'Sierra Leone'}},{alpha2:'SM',alpha3:'SMR',name:{fr:'Saint-Marin',en:'San Marino'}},{alpha2:'SN',alpha3:'SEN',name:{fr:'Sénégal',en:'Senegal'}},{alpha2:'SO',alpha3:'SOM',name:{fr:'Somalie',en:'Somalia'}},{alpha2:'SR',alpha3:'SUR',name:{fr:'Suriname',en:'Suriname'}},{alpha2:'SS',alpha3:'SSD',name:{fr:'Soudan du Sud',en:'South Sudan'}},{alpha2:'ST',alpha3:'STP',name:{fr:'São Tomé-et-Príncipe',en:'São Tomé and Príncipe'}},{alpha2:'SV',alpha3:'SLV',name:{fr:'Salvador',en:'El Salvador'}},{alpha2:'SX',alpha3:'SXM',name:{fr:'Saint-Martin',en:'Sint Maarten'}},{alpha2:'SY',alpha3:'SYR',name:{fr:'Syrie',en:'Syria'}},{alpha2:'SZ',alpha3:'SWZ',name:{fr:'Eswatini',en:'Eswatini'}},{alpha2:'TC',alpha3:'TCA',name:{fr:'Îles Turques-et-Caïques',en:'Turks and Caicos Islands'}},{alpha2:'TD',alpha3:'TCD',name:{fr:'Tchad',en:'Chad'}},{alpha2:'TF',alpha3:'ATF',name:{fr:'Terres australes françaises',en:'French Southern Territories'}},{alpha2:'TG',alpha3:'TGO',name:{fr:'Togo',en:'Togo'}},{alpha2:'TH',alpha3:'THA',name:{fr:'Thaïlande',en:'Thailand'}},{alpha2:'TJ',alpha3:'TJK',name:{fr:'Tadjikistan',en:'Tajikistan'}},{alpha2:'TK',alpha3:'TKL',name:{fr:'Tokelau',en:'Tokelau'}},{alpha2:'TL',alpha3:'TLS',name:{fr:'Timor oriental',en:'Timor-Leste'}},{alpha2:'TM',alpha3:'TKM',name:{fr:'Turkménistan',en:'Turkmenistan'}},{alpha2:'TN',alpha3:'TUN',name:{fr:'Tunisie',en:'Tunisia'}},{alpha2:'TO',alpha3:'TON',name:{fr:'Tonga',en:'Tonga'}},{alpha2:'TR',alpha3:'TUR',name:{fr:'Turquie',en:'Turkey'}},{alpha2:'TT',alpha3:'TTO',name:{fr:'Trinité-et-Tobago',en:'Trinidad and Tobago'}},{alpha2:'TV',alpha3:'TUV',name:{fr:'Tuvalu',en:'Tuvalu'}},{alpha2:'TW',alpha3:'TWN',name:{fr:'Taïwan',en:'Taiwan'}},{alpha2:'TZ',alpha3:'TZA',name:{fr:'Tanzanie',en:'Tanzania'}},{alpha2:'UA',alpha3:'UKR',name:{fr:'Ukraine',en:'Ukraine'}},{alpha2:'UG',alpha3:'UGA',name:{fr:'Ouganda',en:'Uganda'}},{alpha2:'UM',alpha3:'UMI',name:{fr:'Îles mineures éloignées des États-Unis',en:'United States Minor Outlying Islands'}},{alpha2:'US',alpha3:'USA',name:{fr:'États-Unis',en:'United States'}},{alpha2:'UY',alpha3:'URY',name:{fr:'Uruguay',en:'Uruguay'}},{alpha2:'UZ',alpha3:'UZB',name:{fr:'Ouzbékistan',en:'Uzbekistan'}},{alpha2:'VA',alpha3:'VAT',name:{fr:'Vatican',en:'Vatican City'}},{alpha2:'VC',alpha3:'VCT',name:{fr:'Saint-Vincent-et-les-Grenadines',en:'Saint Vincent and the Grenadines'}},{alpha2:'VE',alpha3:'VEN',name:{fr:'Venezuela',en:'Venezuela'}},{alpha2:'VG',alpha3:'VGB',name:{fr:'Îles Vierges britanniques',en:'British Virgin Islands'}},{alpha2:'VI',alpha3:'VIR',name:{fr:'Îles Vierges américaines',en:'United States Virgin Islands'}},{alpha2:'VN',alpha3:'VNM',name:{fr:'Vietnam',en:'Vietnam'}},{alpha2:'VU',alpha3:'VUT',name:{fr:'Vanuatu',en:'Vanuatu'}},{alpha2:'WF',alpha3:'WLF',name:{fr:'Wallis-et-Futuna',en:'Wallis and Futuna'}},{alpha2:'WS',alpha3:'WSM',name:{fr:'Samoa',en:'Samoa'}},{alpha2:'YE',alpha3:'YEM',name:{fr:'Yémen',en:'Yemen'}},{alpha2:'YT',alpha3:'MYT',name:{fr:'Mayotte',en:'Mayotte'}},{alpha2:'ZA',alpha3:'ZAF',name:{fr:'Afrique du Sud',en:'South Africa'}},{alpha2:'ZM',alpha3:'ZMB',name:{fr:'Zambie',en:'Zambia'}},{alpha2:'ZW',alpha3:'ZWE',name:{fr:'Zimbabwe',en:'Zimbabwe'}}
|
|
1226
|
+
],
|
|
1227
|
+
|
|
1228
|
+
// Détecter la langue
|
|
1229
|
+
getLanguage: function(element) {
|
|
1230
|
+
const lang = element.getAttribute('lang') ||
|
|
1231
|
+
(element.closest && element.closest('[lang]') ? element.closest('[lang]').getAttribute('lang') : null) ||
|
|
1232
|
+
document.documentElement.getAttribute('lang') ||
|
|
1233
|
+
'fr';
|
|
1234
|
+
return lang.startsWith('en') ? 'en' : 'fr';
|
|
1235
|
+
},
|
|
1236
|
+
|
|
1237
|
+
// Trouver un pays par code ou nom
|
|
1238
|
+
findCountry: function(query) {
|
|
1239
|
+
if (!query) return null;
|
|
1240
|
+
const upperQuery = query.toUpperCase().trim();
|
|
1241
|
+
const lowerQuery = query.toLowerCase().trim();
|
|
1242
|
+
return this.countries.find(function(c) {
|
|
1243
|
+
return c.alpha2 === upperQuery ||
|
|
1244
|
+
c.alpha3 === upperQuery ||
|
|
1245
|
+
c.name.fr.toLowerCase() === lowerQuery ||
|
|
1246
|
+
c.name.en.toLowerCase() === lowerQuery;
|
|
1247
|
+
});
|
|
1248
|
+
},
|
|
1249
|
+
|
|
1250
|
+
detect: function(scope) {
|
|
1251
|
+
const s = scope || document;
|
|
1252
|
+
return s.querySelector(bbContents._attrSelector('country-select')) !== null;
|
|
1253
|
+
},
|
|
1254
|
+
|
|
1255
|
+
init: function(root) {
|
|
1256
|
+
const scope = root || document;
|
|
1257
|
+
if (scope.closest && scope.closest('[data-bb-disable]')) return;
|
|
1258
|
+
const elements = scope.querySelectorAll(bbContents._attrSelector('country-select'));
|
|
1259
|
+
const self = this;
|
|
1260
|
+
|
|
1261
|
+
elements.forEach(function(element) {
|
|
1262
|
+
if (element.bbProcessed || element.hasAttribute('data-bb-country-select-processed')) return;
|
|
1263
|
+
if (element.tagName !== 'SELECT') {
|
|
1264
|
+
bbContents.utils.log('bb-country-select doit être utilisé sur un élément <select>');
|
|
1265
|
+
return;
|
|
1266
|
+
}
|
|
1267
|
+
element.bbProcessed = true;
|
|
1268
|
+
|
|
1269
|
+
const language = self.getLanguage(element);
|
|
1270
|
+
const preferredAttr = bbContents._getAttr(element, 'bb-country-select-preferred');
|
|
1271
|
+
const defaultAttr = bbContents._getAttr(element, 'bb-country-select-default');
|
|
1272
|
+
const placeholder = bbContents.config.i18n.selectCountry[language] ||
|
|
1273
|
+
(language === 'en' ? 'Select country' : 'Sélectionner un pays');
|
|
1274
|
+
const searchPlaceholder = bbContents.config.i18n.searchCountry[language] ||
|
|
1275
|
+
(language === 'en' ? 'Search country...' : 'Rechercher un pays...');
|
|
1276
|
+
|
|
1277
|
+
// Parser les pays préférés
|
|
1278
|
+
let preferredCountries = [];
|
|
1279
|
+
if (preferredAttr) {
|
|
1280
|
+
preferredAttr.split(',').forEach(function(code) {
|
|
1281
|
+
const country = self.findCountry(code.trim());
|
|
1282
|
+
if (country) preferredCountries.push(country.alpha2);
|
|
1283
|
+
});
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
// Pays par défaut
|
|
1287
|
+
let defaultCountry = null;
|
|
1288
|
+
if (defaultAttr) {
|
|
1289
|
+
defaultCountry = self.findCountry(defaultAttr.trim());
|
|
1290
|
+
} else if (element.value) {
|
|
1291
|
+
defaultCountry = self.findCountry(element.value);
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
// Trier les pays : préférés en haut
|
|
1295
|
+
let sortedCountries = self.countries.slice();
|
|
1296
|
+
if (preferredCountries.length > 0) {
|
|
1297
|
+
sortedCountries = sortedCountries.filter(function(c) {
|
|
1298
|
+
return preferredCountries.indexOf(c.alpha2) !== -1;
|
|
1299
|
+
}).concat(sortedCountries.filter(function(c) {
|
|
1300
|
+
return preferredCountries.indexOf(c.alpha2) === -1;
|
|
1301
|
+
}));
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
// Créer le wrapper
|
|
1305
|
+
const wrapper = document.createElement('div');
|
|
1306
|
+
wrapper.className = 'bb-country-select-wrapper';
|
|
1307
|
+
wrapper.style.cssText = 'position: relative; width: 100%;';
|
|
1308
|
+
|
|
1309
|
+
// Masquer le select natif mais le garder fonctionnel
|
|
1310
|
+
const selectStyle = element.style.cssText || '';
|
|
1311
|
+
element.style.cssText = selectStyle + '; position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; overflow: hidden;';
|
|
1312
|
+
element.setAttribute('aria-hidden', 'true');
|
|
1313
|
+
|
|
1314
|
+
// Créer le bouton custom
|
|
1315
|
+
const trigger = document.createElement('button');
|
|
1316
|
+
trigger.type = 'button';
|
|
1317
|
+
trigger.className = 'bb-country-select-trigger';
|
|
1318
|
+
trigger.setAttribute('aria-haspopup', 'listbox');
|
|
1319
|
+
trigger.setAttribute('aria-expanded', 'false');
|
|
1320
|
+
|
|
1321
|
+
const selectedCountry = defaultCountry;
|
|
1322
|
+
const selectedName = selectedCountry ? selectedCountry.name[language] : placeholder;
|
|
1323
|
+
const selectedFlag = selectedCountry ?
|
|
1324
|
+
'<img src="https://hatscripts.github.io/circle-flags/flags/' + selectedCountry.alpha2.toLowerCase() + '.svg" alt="' + bbContents.utils.sanitize(selectedCountry.name[language]) + '" style="width: 20px; height: 20px; border-radius: 50%; object-fit: cover; flex-shrink: 0;">' :
|
|
1325
|
+
'';
|
|
1326
|
+
|
|
1327
|
+
trigger.innerHTML = '<div style="display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0;"><span class="bb-country-flag" style="flex-shrink: 0;">' + selectedFlag + '</span><span class="bb-country-name" style="flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">' + bbContents.utils.sanitize(selectedName) + '</span></div><svg width="16" height="16" viewBox="0 0 16 16" fill="none" style="flex-shrink: 0; transition: transform 0.2s;"><path d="M4 6L8 10L12 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
|
1328
|
+
trigger.style.cssText = 'display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 8px 12px; border: 1px solid #e5e7eb; border-radius: 6px; background: white; cursor: pointer; font-size: inherit; font-family: inherit; color: inherit; transition: border-color 0.2s; box-sizing: border-box;';
|
|
1329
|
+
|
|
1330
|
+
// Créer le popover
|
|
1331
|
+
const popover = document.createElement('div');
|
|
1332
|
+
popover.className = 'bb-country-select-popover';
|
|
1333
|
+
popover.setAttribute('role', 'listbox');
|
|
1334
|
+
popover.style.cssText = 'position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px; background: white; border: 1px solid #e5e7eb; border-radius: 6px; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05); max-height: 300px; overflow: hidden; display: none; z-index: 50;';
|
|
1335
|
+
|
|
1336
|
+
// Barre de recherche
|
|
1337
|
+
const searchWrapper = document.createElement('div');
|
|
1338
|
+
searchWrapper.className = 'bb-country-search';
|
|
1339
|
+
searchWrapper.style.cssText = 'position: sticky; top: 0; padding: 8px; background: white; border-bottom: 1px solid #e5e7eb; z-index: 1;';
|
|
1340
|
+
|
|
1341
|
+
const searchInput = document.createElement('input');
|
|
1342
|
+
searchInput.type = 'text';
|
|
1343
|
+
searchInput.className = 'bb-country-search-input';
|
|
1344
|
+
searchInput.placeholder = searchPlaceholder;
|
|
1345
|
+
searchInput.setAttribute('aria-label', searchPlaceholder);
|
|
1346
|
+
searchInput.style.cssText = 'width: 100%; padding: 8px 12px; border: 1px solid #e5e7eb; border-radius: 4px; font-size: inherit; font-family: inherit; box-sizing: border-box;';
|
|
1347
|
+
|
|
1348
|
+
searchWrapper.appendChild(searchInput);
|
|
1349
|
+
popover.appendChild(searchWrapper);
|
|
1350
|
+
|
|
1351
|
+
// Liste des pays
|
|
1352
|
+
const list = document.createElement('div');
|
|
1353
|
+
list.className = 'bb-country-list';
|
|
1354
|
+
list.style.cssText = 'overflow-y: auto; max-height: 250px;';
|
|
1355
|
+
popover.appendChild(list);
|
|
1356
|
+
|
|
1357
|
+
// Fonction pour rendre la liste
|
|
1358
|
+
function renderCountries(countries) {
|
|
1359
|
+
if (countries.length === 0) {
|
|
1360
|
+
const noResult = bbContents.config.i18n.noCountryFound[language] ||
|
|
1361
|
+
(language === 'en' ? 'No country found' : 'Aucun pays trouvé');
|
|
1362
|
+
list.innerHTML = '<div style="padding: 16px; text-align: center; color: #9ca3af; font-size: inherit; font-family: inherit;">' + bbContents.utils.sanitize(noResult) + '</div>';
|
|
1363
|
+
return;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
list.innerHTML = countries.map(function(country) {
|
|
1367
|
+
const isSelected = selectedCountry && selectedCountry.alpha2 === country.alpha2;
|
|
1368
|
+
return '<div class="bb-country-item" data-country="' + country.alpha2 + '" role="option" aria-selected="' + (isSelected ? 'true' : 'false') + '" style="display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; font-size: inherit; font-family: inherit; transition: background-color 0.15s;' + (isSelected ? ' background-color: #f3f4f6;' : '') + '"><img src="https://hatscripts.github.io/circle-flags/flags/' + country.alpha2.toLowerCase() + '.svg" alt="' + bbContents.utils.sanitize(country.name[language]) + '" style="width: 20px; height: 20px; border-radius: 50%; object-fit: cover; flex-shrink: 0;"><span>' + bbContents.utils.sanitize(country.name[language]) + '</span></div>';
|
|
1369
|
+
}).join('');
|
|
1370
|
+
|
|
1371
|
+
// Ajouter hover effect
|
|
1372
|
+
list.querySelectorAll('.bb-country-item').forEach(function(item) {
|
|
1373
|
+
item.addEventListener('mouseenter', function() {
|
|
1374
|
+
if (this.getAttribute('aria-selected') !== 'true') {
|
|
1375
|
+
this.style.backgroundColor = '#f3f4f6';
|
|
1376
|
+
}
|
|
1377
|
+
});
|
|
1378
|
+
item.addEventListener('mouseleave', function() {
|
|
1379
|
+
if (this.getAttribute('aria-selected') !== 'true') {
|
|
1380
|
+
this.style.backgroundColor = '';
|
|
1381
|
+
}
|
|
1382
|
+
});
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
// Initialiser la liste
|
|
1387
|
+
renderCountries(sortedCountries);
|
|
1388
|
+
|
|
1389
|
+
// Assembler le wrapper
|
|
1390
|
+
const parent = element.parentNode;
|
|
1391
|
+
parent.insertBefore(wrapper, element);
|
|
1392
|
+
wrapper.appendChild(element);
|
|
1393
|
+
wrapper.appendChild(trigger);
|
|
1394
|
+
wrapper.appendChild(popover);
|
|
1395
|
+
|
|
1396
|
+
// Références
|
|
1397
|
+
const flagSpan = trigger.querySelector('.bb-country-flag');
|
|
1398
|
+
const nameSpan = trigger.querySelector('.bb-country-name');
|
|
1399
|
+
const chevron = trigger.querySelector('svg');
|
|
1400
|
+
|
|
1401
|
+
// Toggle dropdown
|
|
1402
|
+
trigger.addEventListener('click', function(e) {
|
|
1403
|
+
e.stopPropagation();
|
|
1404
|
+
const isOpen = popover.style.display === 'block';
|
|
1405
|
+
popover.style.display = isOpen ? 'none' : 'block';
|
|
1406
|
+
trigger.setAttribute('aria-expanded', isOpen ? 'false' : 'true');
|
|
1407
|
+
if (chevron) chevron.style.transform = isOpen ? 'rotate(0deg)' : 'rotate(180deg)';
|
|
1408
|
+
if (!isOpen) {
|
|
1409
|
+
searchInput.focus();
|
|
1410
|
+
searchInput.value = '';
|
|
1411
|
+
renderCountries(sortedCountries);
|
|
1412
|
+
}
|
|
1413
|
+
});
|
|
1414
|
+
|
|
1415
|
+
// Fermer en cliquant à l'extérieur
|
|
1416
|
+
document.addEventListener('click', function(e) {
|
|
1417
|
+
if (!wrapper.contains(e.target)) {
|
|
1418
|
+
popover.style.display = 'none';
|
|
1419
|
+
trigger.setAttribute('aria-expanded', 'false');
|
|
1420
|
+
if (chevron) chevron.style.transform = 'rotate(0deg)';
|
|
1421
|
+
}
|
|
1422
|
+
});
|
|
1423
|
+
|
|
1424
|
+
// Recherche
|
|
1425
|
+
searchInput.addEventListener('input', function(e) {
|
|
1426
|
+
const query = e.target.value.toLowerCase();
|
|
1427
|
+
const filtered = sortedCountries.filter(function(c) {
|
|
1428
|
+
return c.name[language].toLowerCase().indexOf(query) !== -1 ||
|
|
1429
|
+
c.alpha2.toLowerCase().indexOf(query) !== -1 ||
|
|
1430
|
+
c.alpha3.toLowerCase().indexOf(query) !== -1;
|
|
1431
|
+
});
|
|
1432
|
+
renderCountries(filtered);
|
|
1433
|
+
});
|
|
1434
|
+
|
|
1435
|
+
// Navigation clavier
|
|
1436
|
+
searchInput.addEventListener('keydown', function(e) {
|
|
1437
|
+
if (e.key === 'Escape') {
|
|
1438
|
+
popover.style.display = 'none';
|
|
1439
|
+
trigger.setAttribute('aria-expanded', 'false');
|
|
1440
|
+
if (chevron) chevron.style.transform = 'rotate(0deg)';
|
|
1441
|
+
trigger.focus();
|
|
1442
|
+
}
|
|
1443
|
+
});
|
|
1444
|
+
|
|
1445
|
+
// Sélectionner un pays
|
|
1446
|
+
list.addEventListener('click', function(e) {
|
|
1447
|
+
const item = e.target.closest('.bb-country-item');
|
|
1448
|
+
if (!item) return;
|
|
1449
|
+
|
|
1450
|
+
const countryCode = item.dataset.country;
|
|
1451
|
+
const country = self.countries.find(function(c) {
|
|
1452
|
+
return c.alpha2 === countryCode;
|
|
1453
|
+
});
|
|
1454
|
+
if (!country) return;
|
|
1455
|
+
|
|
1456
|
+
// Mettre à jour l'affichage
|
|
1457
|
+
flagSpan.innerHTML = '<img src="https://hatscripts.github.io/circle-flags/flags/' + country.alpha2.toLowerCase() + '.svg" alt="' + bbContents.utils.sanitize(country.name[language]) + '" style="width: 20px; height: 20px; border-radius: 50%; object-fit: cover; flex-shrink: 0;">';
|
|
1458
|
+
nameSpan.textContent = country.name[language];
|
|
1459
|
+
|
|
1460
|
+
// Mettre à jour le select natif
|
|
1461
|
+
element.value = country.alpha2;
|
|
1462
|
+
const changeEvent = new Event('change', { bubbles: true });
|
|
1463
|
+
element.dispatchEvent(changeEvent);
|
|
1464
|
+
|
|
1465
|
+
// Fermer le dropdown
|
|
1466
|
+
popover.style.display = 'none';
|
|
1467
|
+
trigger.setAttribute('aria-expanded', 'false');
|
|
1468
|
+
if (chevron) chevron.style.transform = 'rotate(0deg)';
|
|
1469
|
+
searchInput.value = '';
|
|
1470
|
+
renderCountries(sortedCountries);
|
|
1471
|
+
|
|
1472
|
+
// Re-render pour mettre à jour l'état sélectionné
|
|
1473
|
+
setTimeout(function() {
|
|
1474
|
+
renderCountries(sortedCountries);
|
|
1475
|
+
}, 0);
|
|
1476
|
+
});
|
|
1477
|
+
|
|
1478
|
+
wrapper.setAttribute('data-bb-country-select-processed', 'true');
|
|
1479
|
+
});
|
|
1480
|
+
|
|
1481
|
+
bbContents.utils.log('Module CountrySelect initialisé:', elements.length, 'éléments');
|
|
1482
|
+
}
|
|
1483
|
+
},
|
|
1484
|
+
|
|
1182
1485
|
// Module Favicon (Favicon Dynamique)
|
|
1183
1486
|
favicon: {
|
|
1184
1487
|
originalFavicon: null,
|
|
@@ -1468,7 +1771,7 @@
|
|
|
1468
1771
|
const newCachedData = this.cache.get(cacheKey);
|
|
1469
1772
|
if (newCachedData && newCachedData.value) {
|
|
1470
1773
|
this.generateYouTubeFeed(container, template, newCachedData.value, allowShorts, language);
|
|
1471
|
-
|
|
1774
|
+
} else {
|
|
1472
1775
|
container.innerHTML = '<div style="padding: 20px; text-align: center; color: #6b7280;">Erreur de chargement</div>';
|
|
1473
1776
|
}
|
|
1474
1777
|
} else {
|