Skip to content

Commit

Permalink
Altmetric badge support
Browse files Browse the repository at this point in the history
  • Loading branch information
gneissone committed May 6, 2016
1 parent 5ff9fd9 commit 43d1133
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 4 additions & 4 deletions bootstrap3.facetview.theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,12 @@ function renderRangeFacet(facet, options) {
*/

// full template for the facet - we'll then go on and do some find and replace
var filterTmpl = '<table id="facetview_filter_{{FILTER_NAME}}" class="facetview_filters table table-bordered table-condensed table-striped" data-href="{{FILTER_EXACT}}"> \
var filterTmpl = '<div class="panel panel-default facet-panel"><table id="facetview_filter_{{FILTER_NAME}}" class="facetview_filters table table-bordered table-condensed table-striped" data-href="{{FILTER_EXACT}}"> \
<tr><td class="facetview_filtershow" data-href="{{FILTER_EXACT}}" title="filter by {{FILTER_DISPLAY}}"> \
<i class="glyphicon glyphicon-triangle-right"></i> {{FILTER_DISPLAY}} \
</a> \
</td></tr> \
</table>';
</table></div>';

// put the name of the field into FILTER_NAME and FILTER_EXACT
filterTmpl = filterTmpl.replace(/{{FILTER_NAME}}/g, safeId(facet['field'])).replace(/{{FILTER_EXACT}}/g, facet['field']);
Expand Down Expand Up @@ -397,12 +397,12 @@ function renderDateHistogramFacet(facet, options) {
*/

// full template for the facet - we'll then go on and do some find and replace
var filterTmpl = '<table id="facetview_filter_{{FILTER_NAME}}" class="facetview_filters table table-bordered table-condensed table-striped" data-href="{{FILTER_EXACT}}"> \
var filterTmpl = '<div class="panel panel-default facet-panel"><table id="facetview_filter_{{FILTER_NAME}}" class="facetview_filters table table-bordered table-condensed table-striped" data-href="{{FILTER_EXACT}}"> \
<tbody><tr><td class="facetview_filtershow" data-href="{{FILTER_EXACT}}" title="filter by {{FILTER_DISPLAY}}"> \
<i class="glyphicon glyphicon-triangle-right"></i> {{FILTER_DISPLAY}} \
</a> \
</td></tr></tbody> \
</table>';
</table></div>';

// put the name of the field into FILTER_NAME and FILTER_EXACT
filterTmpl = filterTmpl.replace(/{{FILTER_NAME}}/g, safeId(facet['field'])).replace(/{{FILTER_EXACT}}/g, facet['field']);
Expand Down
9 changes: 8 additions & 1 deletion jquery.facetview2.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ function getUrlVars() {

(function($){
$.fn.facetview = function(options) {

// Load the Altmetric badge script
$.getScript("https://d1bxh8uas1mnw7.cloudfront.net/assets/embed.js", function(){
});

/**************************************************************
* handle the incoming options, default options and url parameters
Expand Down Expand Up @@ -822,7 +826,7 @@ function getUrlVars() {
event.preventDefault();
sortchoice = ($(this).attr('id'))
options.behaviour_set_order_by(options, obj, {orderby: sortchoice})
$('.dropdown-toggle').html($(this).html() + '<span class="caret"></span>');
// $('.dropdown-toggle').html($(this).html() + '<span class="caret"></span>');
// synchronise the new sort with the options
saveSortOption(sortchoice);

Expand Down Expand Up @@ -1372,6 +1376,7 @@ function getUrlVars() {
$('#facetview_results', obj).children().hide().fadeIn(options.fadein);
// FIXME: is possibly a debug feature?
// $('.facetview_viewrecord', obj).bind('click', viewrecord);

}

/**************************************************************
Expand Down Expand Up @@ -1464,6 +1469,8 @@ function getUrlVars() {
function queryComplete(jqXHR, textStatus) {
options.behaviour_finished_searching(options, obj);
options.searching = false;
// For altmetric badge. The JS file must be included in the html file.
_altmetric_embed_init();
}

function pruneActiveFilters() {
Expand Down

0 comments on commit 43d1133

Please sign in to comment.