@@ -768,7 +882,12 @@ public function getAllMeetings($root_server)
public function getCroutonJsConfig($atts)
{
- $params = shortcode_atts($this->shortCodeOptions, $atts);
+ // Pulling simple values from options
+ $defaults = $this->shortCodeOptions;
+ foreach ($defaults as $key => $value) {
+ $defaults[$key] = (isset($this->options[$key]) ? $this->options[$key] : $value);
+ }
+ $params = shortcode_atts($defaults, $atts);
// Pulling from querystring
foreach ($params as $key => $value) {
@@ -839,7 +958,6 @@ public function getCroutonJsConfig($atts)
$params['service_body'] = $service_body;
$params['exclude_zip_codes'] = (!is_null($params['exclude_zip_codes']) ? explode(",", $params['exclude_zip_codes']) : array());
- $params['root_server'] = $params['root_server'] != '' ? $params['root_server'] : $this->options['root_server'];
if ($legacy_force_recurse) {
$params['recurse_service_bodies'] = true;
@@ -879,6 +997,9 @@ public function getCroutonJsConfig($atts)
}
$params['extra_meetings'] = $extra_meetings_array;
+
+ $params['force_rootserver_in_querystring'] = ($params['root_server'] !== $this->options['root_server']);
+ // TODO add default language and root_server
return json_encode($params);
}
}
@@ -889,4 +1010,4 @@ public function getCroutonJsConfig($atts)
if (class_exists("Crouton")) {
$BMLTTabs_instance = new Crouton();
}
-?>
+?>
\ No newline at end of file
diff --git a/croutonjs/src/js/crouton-core.js b/croutonjs/src/js/crouton-core.js
index 1f922c1..0383c67 100644
--- a/croutonjs/src/js/crouton-core.js
+++ b/croutonjs/src/js/crouton-core.js
@@ -55,6 +55,9 @@ function Crouton(config) {
service_body: [], // Array of service bodies to return data for.
formats: '', // Return only meetings with these formats (format shared-id, not key-string)
venue_types: '', // Return only meetings with this venue type (1, 2 or 3)
+ strict_datafields: true, // Only get the datafields that are mentioned in the templates
+ meeting_details_href: '', // Link to the meeting details page
+ virtual_meeting_details_href: '', // Link to the virtual meeting details page
exclude_zip_codes: [], // List of zip codes to exclude
extra_meetings: [], // List of id_bigint of meetings to include
native_lang: '', // The implied language of meetings with no explicit language specied. May be there as second language, but it still doesn't make sense to search for it.
@@ -66,11 +69,15 @@ function Crouton(config) {
int_start_day_id: 1, // Controls the first day of the week sequence. Sunday is 1.
view_by: "weekday", // TODO: replace with using the first choice in button_filters as the default view_by.
show_qrcode: false, // Determines whether or not to show the QR code for virtual / phone meetings if they exist.
+ force_rootserver_in_querystring: true, // Set to false to shorten generated meeting detail query strings
+ force_timeformat_in_querystring: true, // Set to false to shorten generated meeting detail query strings
+ force_language_in_querystring: true, // Set to false to shorten generated meeting detail query strings
theme: "jack", // Allows for setting pre-packaged themes. Choices are listed here: https://github.com/bmlt-enabled/crouton/blob/master/croutonjs/dist/templates/themes
meeting_data_template: croutonDefaultTemplates.meeting_data_template,
metadata_template: croutonDefaultTemplates.metadata_template,
observer_template: croutonDefaultTemplates.observer_template,
- meeting_count_template: croutonDefaultTemplates.meeting_count_template
+ meeting_count_template: croutonDefaultTemplates.meeting_count_template,
+ meeting_link_template: croutonDefaultTemplates.meeting_link_template,
};
self.setConfig(config);
@@ -205,9 +212,12 @@ function Crouton(config) {
self.mutex = false;
});
};
- self.mutex = true;
-
- self.meetingSearch = function() {
+ self.addDatafieldsToQuery = function() {
+ if (!self.config.strict_datafields) {
+ self.all_data_keys = [];
+ self.queryable_data_keys = [];
+ return '';
+ }
var base_data_field_keys = [
'location_postal_code_1',
'duration_time',
@@ -278,8 +288,13 @@ function Crouton(config) {
self.collectDataKeys(self.config['observer_template']);
var unique_data_field_keys = arrayUnique(self.queryable_data_keys);
+ return '&data_field_key=' + unique_data_field_keys.join(',');
+ }
+ self.mutex = true;
+
+ self.meetingSearch = function() {
var url = '/client_interface/jsonp/?switcher=GetSearchResults&get_used_formats&lang_enum=' + self.config['short_language'] +
- '&data_field_key=' + unique_data_field_keys.join(',');
+ self.addDatafieldsToQuery();
if (self.config['formats']) {
url += self.config['formats'].reduce(function(prev,id) {
@@ -546,7 +561,11 @@ function Crouton(config) {
}
}
};
-
+ self.toFarsinNumber = function( n ) {
+ const farsiDigits = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
+
+ return n.replace(/\d/g, x => farsiDigits[x]);
+ }
self.enrichMeetings = function (meetingData, filter) {
var meetings = [];
@@ -554,6 +573,7 @@ function Crouton(config) {
crouton_Handlebars.registerPartial("metaDataTemplate", self.config['metadata_template']);
crouton_Handlebars.registerPartial("observerTemplate", self.config['observer_template']);
crouton_Handlebars.registerPartial("meetingCountTemplate", self.config['meeting_count_template']);
+ crouton_Handlebars.registerPartial("meetingLink", self.config['meeting_link_template']);
for (var m = 0; m < meetingData.length; m++) {
meetingData[m]['formatted_comments'] = meetingData[m]['comments'];
@@ -570,6 +590,10 @@ function Crouton(config) {
.add(duration[0], 'hours')
.add(duration[1], 'minutes')
.format(self.config['time_format']);
+ if (self.config.language === 'fa-IR') {
+ meetingData[m]['start_time_formatted'] = self.toFarsinNumber(meetingData[m]['start_time_formatted']);
+ meetingData[m]['end_time_formatted'] = self.toFarsinNumber(meetingData[m]['end_time_formatted']);
+ }
// back to bmlt day
meetingData[m]['day_of_the_week'] = meetingData[m]['start_time_raw'].isoWeekday() === 7 ? 1 : meetingData[m]['start_time_raw'].isoWeekday() + 1;
@@ -625,6 +649,7 @@ function Crouton(config) {
meetingData[m]['serviceBodyPhone'] = serviceBodyInfo["helpline"];
meetingData[m]['serviceBodyName'] = serviceBodyInfo["name"];
meetingData[m]['serviceBodyDescription'] = serviceBodyInfo["description"];
+ meetingData[m]['serviceBodyContactEmail'] = serviceBodyInfo["contact_email"];
meetingData[m]['serviceBodyType'] = self.localization.getServiceBodyType(serviceBodyInfo["type"]);
var parentBodyInfo = self.getServiceBodyDetails(serviceBodyInfo["parent_id"]);
@@ -636,6 +661,19 @@ function Crouton(config) {
meetingData[m]['parentServiceBodyType'] = self.localization.getServiceBodyType(parentBodyInfo["type"]);
}
+ meetingData[m]['meeting_details_url'] = '';
+ if (self.config.meeting_details_href) {
+ meetingData[m]['meeting_details_url'] = self.config.meeting_details_href;
+ if (meetingData[m]['venue_type'] === 2 && self.config.virtual_meeting_details_href ) {
+ meetingData[m]['meeting_details_url'] = self.config.virtual_meeting_details_href;
+ }
+ meetingData[m]['meeting_details_url'] += ('?meeting-id=' + meetingData[m]['id_bigint']
+ + '&language=' + self.config.language
+ + '&time_format=' + encodeURIComponent(self.config.time_format)
+ + (self.config.force_rootserver_in_querystring ? '&root_server=' + encodeURIComponent(self.config.root_server) : '')
+ );
+ }
+
meetings.push(meetingData[m])
}
@@ -769,6 +807,81 @@ Crouton.prototype.getServiceBodyDetails = function(serviceBodyId) {
}
}
+Crouton.prototype.doHandlebars = function() {
+ var elements = document.getElementsByTagName('bmlt-handlebar');
+ if (elements.length === 0) {
+ self.showMessage('No
tags found');
+ return;
+ };
+ var self = this;
+ self.lock(function() {
+ if (self.isEmpty(self.meetingData)) {
+ self.showMessage("No meetings found for parameters specified.");
+ return;
+ }
+ var promises = [self.getServiceBodies(self.meetingData[0]['service_body_bigint'])];
+ Promise.all(promises)
+ .then(function(data) {
+ hbs_Crouton['localization'] = self.localization;
+ self.active_service_bodies = [];
+ self.all_service_bodies = [];
+ var service_body = data[0][0];
+ self.all_service_bodies.push(service_body);
+ var enrichedMeetingData = self.enrichMeetings(self.meetingData);
+ var customStartupTemplate = crouton_Handlebars.compile('{{startup}}');
+ customStartupTemplate(enrichedMeetingData);
+ var customEnrichTemplate = crouton_Handlebars.compile('{{enrich this}}');
+ customEnrichTemplate(enrichedMeetingData[0]);
+ var parser = new DOMParser();
+
+ while (elements.length > 0) {
+ var element = elements.item(0);
+ if (!element.firstChild) {
+ console.log(' tag must have at least one child');
+ element.remove();
+ continue;
+ }
+ var templateString = '';
+ if (element.firstChild.nodeType === 1) {
+ if (!element.firstChild.firstChild || element.firstChild.firstChild.nodeType !== 3) {
+ console.log(' tag: cannot find textnode');
+ element.remove();
+ continue;
+ }
+ templateString = element.firstChild.firstChild.textContent;
+ } else if (element.firstChild.nodeType === 3) {
+ if (!element.firstChild.nodeType !== 3) {
+ console.log(' tag: cannot find textnode');
+ element.remove();
+ continue;
+ }
+ templateString = element.firstChild.textContent;
+ }
+
+ var template = crouton_Handlebars.compile(templateString);
+ var handlebarResult = template(enrichedMeetingData[0]);
+ var htmlDecode = parser.parseFromString(''+handlebarResult+'', "text/html");
+ if (!htmlDecode.body || !htmlDecode.body.firstChild) {
+ console.log(' tag: could not parse the Handlebars result');
+ element.remove();
+ continue;
+ }
+ var firstPart = htmlDecode.body.firstChild;
+ var brothers = [];
+ var thisPart = firstPart;
+ var nextPart = null;
+ while (nextPart = thisPart.nextSibling) {
+ thisPart = nextPart;
+ brothers.push(thisPart);
+ }
+ element.replaceWith(firstPart);
+ if (brothers) firstPart.after(...brothers);
+ }
+ });
+ });
+
+};
+
Crouton.prototype.render = function() {
var self = this;
self.lock(function() {
diff --git a/croutonjs/src/js/crouton-default-templates.js b/croutonjs/src/js/crouton-default-templates.js
index 61284ce..a4aa21d 100644
--- a/croutonjs/src/js/crouton-default-templates.js
+++ b/croutonjs/src/js/crouton-default-templates.js
@@ -4,7 +4,7 @@ var croutonDefaultTemplates = {
"{{#isTemporarilyClosed this}}",
" {{temporarilyClosed this}}
",
"{{/isTemporarilyClosed}}",
- "{{this.meeting_name}}
",
+ "{{> meetingLink this}}
",
"{{this.location_text}}
",
"{{this.formatted_address}}
",
"{{this.formatted_location_info}}
",
@@ -55,6 +55,13 @@ var croutonDefaultTemplates = {
"{{#if this.config.has_meeting_count}}",
"{{getWord 'meeting_count'}} {{this.meetings.meetingCount}}",
"{{/if}}"
- ].join('\n')
+ ].join('\n'),
+ meeting_link_template: [
+ "{{#if this.meeting_details_url}}",
+ "{{this.meeting_name}}",
+ "{{else}}",
+ "{{this.meeting_name}}",
+ "{{/if}}"
+ ].join('\n')
}
diff --git a/croutonjs/src/js/crouton-localization.js b/croutonjs/src/js/crouton-localization.js
index edb3cb2..7396a9e 100644
--- a/croutonjs/src/js/crouton-localization.js
+++ b/croutonjs/src/js/crouton-localization.js
@@ -40,6 +40,8 @@ function CroutonLocalization(language) {
},
"share": "share",
"no_meetings_for_this_day": "No meetings for this day.",
+ 'css-textalign': '',
+ 'css-floatdirection': ''
},
"de-DE":{
"days_of_the_week": ["", "Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"],
@@ -78,6 +80,8 @@ function CroutonLocalization(language) {
},
"share": "Teilen",
"no_meetings_for_this_day": "Keine Meetings an diesem Tag.",
+ 'css-textalign': '',
+ 'css-floatdirection': ''
},
"en-AU": {
"days_of_the_week" : ["", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
@@ -116,6 +120,8 @@ function CroutonLocalization(language) {
},
"share": "share",
"no_meetings_for_this_day": "No meetings for this day.",
+ 'css-textalign': '',
+ 'css-floatdirection': ''
},
"en-CA": {
"days_of_the_week" : ["", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
@@ -154,6 +160,8 @@ function CroutonLocalization(language) {
},
"share": "share",
"no_meetings_for_this_day": "No meetings for this day.",
+ 'css-textalign': '',
+ 'css-floatdirection': ''
},
"en-NZ": {
"days_of_the_week" : ["", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
@@ -192,6 +200,8 @@ function CroutonLocalization(language) {
},
"share": "share",
"no_meetings_for_this_day": "No meetings for this day.",
+ 'css-textalign': '',
+ 'css-floatdirection': ''
},
"en-UK": {
"days_of_the_week" : ["", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
@@ -230,6 +240,8 @@ function CroutonLocalization(language) {
},
"share": "share",
"no_meetings_for_this_day": "No meetings for this day.",
+ 'css-textalign': '',
+ 'css-floatdirection': ''
},
"en-US": {
"days_of_the_week" : ["", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
@@ -268,6 +280,8 @@ function CroutonLocalization(language) {
},
"share": "share",
"no_meetings_for_this_day": "No meetings for this day.",
+ 'css-textalign': '',
+ 'css-floatdirection': ''
},
"es-US": {
"days_of_the_week" : ["", "Domingo", " Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"],
@@ -306,6 +320,8 @@ function CroutonLocalization(language) {
},
"share": "share",
"no_meetings_for_this_day": "No meetings for this day.",
+ 'css-textalign': '',
+ 'css-floatdirection': ''
},
"fa-IR": {
"days_of_the_week" : ["", 'یَکشَنب', 'دوشَنبه', 'سهشنبه', 'چهار شنبه', 'پَنج شَنبه', 'جُمعه', 'شَنبه'],
@@ -344,6 +360,8 @@ function CroutonLocalization(language) {
},
"share": "share",
"no_meetings_for_this_day": "No meetings for this day.",
+ 'css-textalign': 'style="text-align:right;"',
+ 'css-floatdirection': 'style="float:right;"'
},
"fr-CA": {
"days_of_the_week" : ["", "Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"],
@@ -382,6 +400,8 @@ function CroutonLocalization(language) {
},
"share": "share",
"no_meetings_for_this_day": "No meetings for this day.",
+ 'css-textalign': '',
+ 'css-floatdirection': ''
},
"it-IT": {
"days_of_the_week" : ["", "Domenica", " Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato"],
@@ -420,6 +440,8 @@ function CroutonLocalization(language) {
},
"share": "Condividi",
"no_meetings_for_this_day": "No meetings for this day.",
+ 'css-textalign': '',
+ 'css-floatdirection': ''
},
"nl-NL": {
"days_of_the_week" : ["", "Zondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag"],
@@ -458,6 +480,8 @@ function CroutonLocalization(language) {
},
"share": "share",
"no_meetings_for_this_day": "No meetings for this day.",
+ 'css-textalign': '',
+ 'css-floatdirection': ''
},
"pl-PL": {
"days_of_the_week" : ["", "Niedziela", "Poniedziałek", "Wtorek", "Środa", "Czwartek", "Piątek", "Sobota"],
@@ -496,6 +520,8 @@ function CroutonLocalization(language) {
},
"share": "share",
"no_meetings_for_this_day": "No meetings for this day.",
+ 'css-textalign': '',
+ 'css-floatdirection': ''
},
"pt-BR": {
"days_of_the_week" : ["", "Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"],
@@ -534,6 +560,8 @@ function CroutonLocalization(language) {
},
"share": "Compartilhar",
"no_meetings_for_this_day": "No meetings for this day.",
+ 'css-textalign': '',
+ 'css-floatdirection': ''
},
"ru-RU": {
"days_of_the_week" : ["", "Воскресенье", "Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота"],
@@ -572,6 +600,8 @@ function CroutonLocalization(language) {
},
"share": "share",
"no_meetings_for_this_day": "No meetings for this day.",
+ 'css-textalign': '',
+ 'css-floatdirection': ''
},
"sv-SE": {
"days_of_the_week" : ["", "Söndag", "Måndag", "Tisdag", "Onsdag", "Torsdag", "Fredag", "Lördag"],
@@ -610,6 +640,8 @@ function CroutonLocalization(language) {
},
"share": "share",
"no_meetings_for_this_day": "No meetings for this day.",
+ 'css-textalign': '',
+ 'css-floatdirection': ''
}
};
}
diff --git a/croutonjs/src/templates/byday.hbs b/croutonjs/src/templates/byday.hbs
index 675f770..5dc3ea6 100644
--- a/croutonjs/src/templates/byday.hbs
+++ b/croutonjs/src/templates/byday.hbs
@@ -5,7 +5,7 @@
{{#unless this.hide}}
{{#greaterThan this.meetings.length 0}}
{{/greaterThan}}
{{/unless}}
diff --git a/croutonjs/src/templates/byfield.hbs b/croutonjs/src/templates/byfield.hbs
index 3020ddc..c1e3dd0 100644
--- a/croutonjs/src/templates/byfield.hbs
+++ b/croutonjs/src/templates/byfield.hbs
@@ -2,7 +2,7 @@
{{#each this}}
-
{{> meetings }}
diff --git a/croutonjs/src/templates/header.hbs b/croutonjs/src/templates/header.hbs
index 57c5cfa..a41979c 100644
--- a/croutonjs/src/templates/header.hbs
+++ b/croutonjs/src/templates/header.hbs
@@ -168,9 +168,9 @@
{{#if this.config.has_tabs}}
{{#ifEquals this.config.view_by "weekdays"}}
-
+
{{else}}
-
+
{{/ifEquals}}
{{#each this.config.day_sequence}}
diff --git a/croutonjs/src/templates/main.hbs b/croutonjs/src/templates/main.hbs
index 54c749f..79693ec 100644
--- a/croutonjs/src/templates/main.hbs
+++ b/croutonjs/src/templates/main.hbs
@@ -1,9 +1,9 @@
-