diff --git a/bootstrap2.facetview.theme.js b/bootstrap2.facetview.theme.js
index 574013e..0372b28 100644
--- a/bootstrap2.facetview.theme.js
+++ b/bootstrap2.facetview.theme.js
@@ -937,6 +937,201 @@ function renderResultRecord(options, record) {
}
function renderActiveTermsFilter(options, facet, field, filter_list) {
+ /*****************************************
+ * overrides must provide the following classes and ids
+ *
+ * class: facetview_filterselected - anchor tag for any clickable filter selection
+ * class: facetview_clear - anchor tag for any link which will remove the filter (should also provide data-value and data-field)
+ * class: facetview_inactive_link - any link combined with facetview_filterselected which should not execute when clicked
+ *
+ * should (not must) respect the config
+ *
+ * options.show_filter_field - whether to include the name of the field the filter is active on
+ * options.show_filter_logic - whether to include AND/OR along with filters
+ * facet.value_function - the value function to be applied to all displayed values
+ */
+ var clean = safeId(field);
+ var display = facet.display ? facet.display : facet.field;
+ var logic = facet.logic ? facet.logic : options.default_facet_operator;
+
+ var frag = "
";
+
+ if (options.show_filter_field) {
+ frag += '
' + display + ': ';
+ }
+
+ for (var i = 0; i < filter_list.length; i++) {
+ var value = filter_list[i];
+ if (facet.value_function) {
+ value = facet.value_function(value)
+ }
+
+ frag += '
' + value + ' ';
+ frag += '
';
+ frag += '';
+ frag += "";
+
+ if (i !== filter_list.length - 1 && options.show_filter_logic) {
+ frag += '
' + logic + ' ';
+ }
+ }
+ frag += "
";
+
+ return frag
+}
+
+function renderActiveRangeFilter(options, facet, field, value) {
+ /*****************************************
+ * overrides must provide the following classes and ids
+ *
+ * class: facetview_filterselected - anchor tag for any clickable filter selection
+ * class: facetview_clear - anchor tag for any link which will remove the filter (should also provide data-value and data-field)
+ * class: facetview_inactive_link - any link combined with facetview_filterselected which should not execute when clicked
+ *
+ * should (not must) respect the config
+ *
+ * options.show_filter_field - whether to include the name of the field the filter is active on
+ */
+
+ function getRangeForValue(value, facet) {
+ for (var i=0; i < facet.range.length; i=i+1) {
+ var range = facet.range[i];
+
+ // the "to"s match if they both value and range have a "to" and they are the same, or if neither have a "to"
+ var match_to = (value.to && range.to && value.to === range.to.toString()) || (!value.to && !range.to);
+
+ // the "from"s match if they both value and range have a "from" and they are the same, or if neither have a "from"
+ var match_from = (value.from && range.from && value.from === range.from.toString()) || (!value.from && !range.from);
+
+ if (match_to && match_from) {
+ return range
+ }
+ }
+ }
+
+ var clean = safeId(field);
+ var display = facet.display ? facet.display : facet.field;
+
+ var frag = "";
+
+ if (options.show_filter_field) {
+ frag += '
' + display + ': ';
+ }
+
+ var range = getRangeForValue(value, facet);
+
+ var data_to = value.to ? " data-to='" + value.to + "' " : "";
+ var data_from = value.from ? " data-from='" + value.from + "' " : "";
+
+ frag += '
' + range.display + ' ';
+ frag += '
';
+ frag += '';
+ frag += "";
+
+ frag += "
";
+
+ return frag
+}
+
+function renderActiveGeoFilter(options, facet, field, value) {
+ /*****************************************
+ * overrides must provide the following classes and ids
+ *
+ * class: facetview_filterselected - anchor tag for any clickable filter selection
+ * class: facetview_clear - anchor tag for any link which will remove the filter (should also provide data-value and data-field)
+ * class: facetview_inactive_link - any link combined with facetview_filterselected which should not execute when clicked
+ *
+ * should (not must) respect the config
+ *
+ * options.show_filter_field - whether to include the name of the field the filter is active on
+ */
+
+ function getRangeForValue(value, facet) {
+ for (var i=0; i < facet.distance.length; i=i+1) {
+ var range = facet.distance[i];
+
+ // the "to"s match if they both value and range have a "to" and they are the same, or if neither have a "to"
+ var match_to = (value.to && range.to && value.to === range.to.toString()) || (!value.to && !range.to);
+
+ // the "from"s match if they both value and range have a "from" and they are the same, or if neither have a "from"
+ var match_from = (value.from && range.from && value.from === range.from.toString()) || (!value.from && !range.from);
+
+ if (match_to && match_from) {
+ return range
+ }
+ }
+ }
+
+ var clean = safeId(field);
+ var display = facet.display ? facet.display : facet.field;
+
+ var frag = "";
+
+ if (options.show_filter_field) {
+ frag += '
' + display + ': ';
+ }
+
+ var range = getRangeForValue(value, facet);
+
+ var data_to = value.to ? " data-to='" + value.to + "' " : "";
+ var data_from = value.from ? " data-from='" + value.from + "' " : "";
+
+ frag += '
' + range.display + ' ';
+ frag += '
';
+ frag += '';
+ frag += "";
+
+ frag += "
";
+
+ return frag
+}
+
+function renderActiveDateHistogramFilter(options, facet, field, value) {
+ /*****************************************
+ * overrides must provide the following classes and ids
+ *
+ * class: facetview_filterselected - anchor tag for any clickable filter selection
+ * class: facetview_clear - anchor tag for any link which will remove the filter (should also provide data-value and data-field)
+ * class: facetview_inactive_link - any link combined with facetview_filterselected which should not execute when clicked
+ *
+ * should (not must) respect the config
+ *
+ * options.show_filter_field - whether to include the name of the field the filter is active on
+ */
+
+ var clean = safeId(field);
+ var display = facet.display ? facet.display : facet.field;
+
+ var frag = "";
+
+ if (options.show_filter_field) {
+ frag += '
' + display + ': ';
+ }
+
+ var data_from = value.from ? " data-from='" + value.from + "' " : "";
+
+ var valdisp = value.from;
+ if (facet.value_function) {
+ valdisp = facet.value_function(valdisp);
+ }
+
+ frag += '
' + valdisp + ' ';
+ frag += '
';
+ frag += '';
+ frag += "";
+
+ frag += "
";
+
+ return frag
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+// Alternative active filter renderers which use buttons - deprecated due to usability/ux concerns
+
+function renderActiveTermsFilterButton(options, facet, field, filter_list) {
/*****************************************
* overrides must provide the following classes and ids
*
@@ -983,7 +1178,7 @@ function renderActiveTermsFilter(options, facet, field, filter_list) {
return frag
}
-function renderActiveRangeFilter(options, facet, field, value) {
+function renderActiveRangeFilterButton(options, facet, field, value) {
/*****************************************
* overrides must provide the following classes and ids
*
@@ -1038,7 +1233,7 @@ function renderActiveRangeFilter(options, facet, field, value) {
return frag
}
-function renderActiveGeoFilter(options, facet, field, value) {
+function renderActiveGeoFilterButton(options, facet, field, value) {
/*****************************************
* overrides must provide the following classes and ids
*
@@ -1093,7 +1288,7 @@ function renderActiveGeoFilter(options, facet, field, value) {
return frag
}
-function renderActiveDateHistogramFilter(options, facet, field, value) {
+function renderActiveDateHistogramFilterButton(options, facet, field, value) {
/*****************************************
* overrides must provide the following classes and ids
*
@@ -1134,6 +1329,8 @@ function renderActiveDateHistogramFilter(options, facet, field, value) {
return frag
}
+/////////////////////////////////////////////////////////////////////////////////////////////
+
///// behaviour functions //////////////////////////
// called when searching begins. Use it to show the loading bar, or something
diff --git a/bootstrap3.facetview.theme.js b/bootstrap3.facetview.theme.js
index 8ea92c7..7da3937 100644
--- a/bootstrap3.facetview.theme.js
+++ b/bootstrap3.facetview.theme.js
@@ -948,6 +948,201 @@ function renderResultRecord(options, record) {
}
function renderActiveTermsFilter(options, facet, field, filter_list) {
+ /*****************************************
+ * overrides must provide the following classes and ids
+ *
+ * class: facetview_filterselected - anchor tag for any clickable filter selection
+ * class: facetview_clear - anchor tag for any link which will remove the filter (should also provide data-value and data-field)
+ * class: facetview_inactive_link - any link combined with facetview_filterselected which should not execute when clicked
+ *
+ * should (not must) respect the config
+ *
+ * options.show_filter_field - whether to include the name of the field the filter is active on
+ * options.show_filter_logic - whether to include AND/OR along with filters
+ * facet.value_function - the value function to be applied to all displayed values
+ */
+ var clean = safeId(field);
+ var display = facet.display ? facet.display : facet.field;
+ var logic = facet.logic ? facet.logic : options.default_facet_operator;
+
+ var frag = "";
+
+ if (options.show_filter_field) {
+ frag += '
' + display + ': ';
+ }
+
+ for (var i = 0; i < filter_list.length; i++) {
+ var value = filter_list[i];
+ if (facet.value_function) {
+ value = facet.value_function(value)
+ }
+
+ frag += '
' + value + ' ';
+ frag += '
';
+ frag += '';
+ frag += "";
+
+ if (i !== filter_list.length - 1 && options.show_filter_logic) {
+ frag += '
' + logic + ' ';
+ }
+ }
+ frag += "
";
+
+ return frag
+}
+
+function renderActiveRangeFilter(options, facet, field, value) {
+ /*****************************************
+ * overrides must provide the following classes and ids
+ *
+ * class: facetview_filterselected - anchor tag for any clickable filter selection
+ * class: facetview_clear - anchor tag for any link which will remove the filter (should also provide data-value and data-field)
+ * class: facetview_inactive_link - any link combined with facetview_filterselected which should not execute when clicked
+ *
+ * should (not must) respect the config
+ *
+ * options.show_filter_field - whether to include the name of the field the filter is active on
+ */
+
+ function getRangeForValue(value, facet) {
+ for (var i=0; i < facet.range.length; i=i+1) {
+ var range = facet.range[i];
+
+ // the "to"s match if they both value and range have a "to" and they are the same, or if neither have a "to"
+ var match_to = (value.to && range.to && value.to === range.to.toString()) || (!value.to && !range.to);
+
+ // the "from"s match if they both value and range have a "from" and they are the same, or if neither have a "from"
+ var match_from = (value.from && range.from && value.from === range.from.toString()) || (!value.from && !range.from);
+
+ if (match_to && match_from) {
+ return range
+ }
+ }
+ }
+
+ var clean = safeId(field);
+ var display = facet.display ? facet.display : facet.field;
+
+ var frag = "";
+
+ if (options.show_filter_field) {
+ frag += '
' + display + ': ';
+ }
+
+ var range = getRangeForValue(value, facet);
+
+ var data_to = value.to ? " data-to='" + value.to + "' " : "";
+ var data_from = value.from ? " data-from='" + value.from + "' " : "";
+
+ frag += '
' + range.display + ' ';
+ frag += '
';
+ frag += '';
+ frag += "";
+
+ frag += "
";
+
+ return frag
+}
+
+function renderActiveGeoFilter(options, facet, field, value) {
+ /*****************************************
+ * overrides must provide the following classes and ids
+ *
+ * class: facetview_filterselected - anchor tag for any clickable filter selection
+ * class: facetview_clear - anchor tag for any link which will remove the filter (should also provide data-value and data-field)
+ * class: facetview_inactive_link - any link combined with facetview_filterselected which should not execute when clicked
+ *
+ * should (not must) respect the config
+ *
+ * options.show_filter_field - whether to include the name of the field the filter is active on
+ */
+
+ function getRangeForValue(value, facet) {
+ for (var i=0; i < facet.distance.length; i=i+1) {
+ var range = facet.distance[i];
+
+ // the "to"s match if they both value and range have a "to" and they are the same, or if neither have a "to"
+ var match_to = (value.to && range.to && value.to === range.to.toString()) || (!value.to && !range.to);
+
+ // the "from"s match if they both value and range have a "from" and they are the same, or if neither have a "from"
+ var match_from = (value.from && range.from && value.from === range.from.toString()) || (!value.from && !range.from);
+
+ if (match_to && match_from) {
+ return range
+ }
+ }
+ }
+
+ var clean = safeId(field);
+ var display = facet.display ? facet.display : facet.field;
+
+ var frag = "";
+
+ if (options.show_filter_field) {
+ frag += '
' + display + ': ';
+ }
+
+ var range = getRangeForValue(value, facet);
+
+ var data_to = value.to ? " data-to='" + value.to + "' " : "";
+ var data_from = value.from ? " data-from='" + value.from + "' " : "";
+
+ frag += '
' + range.display + ' ';
+ frag += '
';
+ frag += '';
+ frag += "";
+
+ frag += "
";
+
+ return frag
+}
+
+function renderActiveDateHistogramFilter(options, facet, field, value) {
+ /*****************************************
+ * overrides must provide the following classes and ids
+ *
+ * class: facetview_filterselected - anchor tag for any clickable filter selection
+ * class: facetview_clear - anchor tag for any link which will remove the filter (should also provide data-value and data-field)
+ * class: facetview_inactive_link - any link combined with facetview_filterselected which should not execute when clicked
+ *
+ * should (not must) respect the config
+ *
+ * options.show_filter_field - whether to include the name of the field the filter is active on
+ */
+
+ var clean = safeId(field);
+ var display = facet.display ? facet.display : facet.field;
+
+ var frag = "";
+
+ if (options.show_filter_field) {
+ frag += '
' + display + ': ';
+ }
+
+ var data_from = value.from ? " data-from='" + value.from + "' " : "";
+
+ var valdisp = value.from;
+ if (facet.value_function) {
+ valdisp = facet.value_function(valdisp);
+ }
+
+ frag += '
' + valdisp + ' ';
+ frag += '
';
+ frag += '';
+ frag += "";
+
+ frag += "
";
+
+ return frag
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+// Alternative active filter renderers which use buttons - deprecated due to usability/ux concerns
+
+function renderActiveTermsFilterButton(options, facet, field, filter_list) {
/*****************************************
* overrides must provide the following classes and ids
*
@@ -994,7 +1189,7 @@ function renderActiveTermsFilter(options, facet, field, filter_list) {
return frag
}
-function renderActiveRangeFilter(options, facet, field, value) {
+function renderActiveRangeFilterButton(options, facet, field, value) {
/*****************************************
* overrides must provide the following classes and ids
*
@@ -1049,7 +1244,7 @@ function renderActiveRangeFilter(options, facet, field, value) {
return frag
}
-function renderActiveGeoFilter(options, facet, field, value) {
+function renderActiveGeoFilterButton(options, facet, field, value) {
/*****************************************
* overrides must provide the following classes and ids
*
@@ -1104,7 +1299,7 @@ function renderActiveGeoFilter(options, facet, field, value) {
return frag
}
-function renderActiveDateHistogramFilter(options, facet, field, value) {
+function renderActiveDateHistogramFilterButton(options, facet, field, value) {
/*****************************************
* overrides must provide the following classes and ids
*
@@ -1145,6 +1340,8 @@ function renderActiveDateHistogramFilter(options, facet, field, value) {
return frag
}
+/////////////////////////////////////////////////////////////////////////////////////////////
+
///// behaviour functions //////////////////////////
// called when searching begins. Use it to show the loading bar, or something