From 877216ce1b8e87599dcbd1b0c0976802fe2f7022 Mon Sep 17 00:00:00 2001 From: Alistair Coleman Date: Fri, 11 Sep 2015 16:29:26 +0100 Subject: [PATCH 1/2] IE9 bug fix to ensure site furniture shows correctly. --- public/widgets/paper-badger-widget.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/public/widgets/paper-badger-widget.js b/public/widgets/paper-badger-widget.js index 1a7d682..b4f198f 100644 --- a/public/widgets/paper-badger-widget.js +++ b/public/widgets/paper-badger-widget.js @@ -98,11 +98,21 @@ function showBadgeFurniture(confIn) if(badgesCount && dataItem/dataItem) { visitArray(document.querySelectorAll("."+furnitureClass), function(elem){ - - if(elem.classList.contains(furnitureClass)) + var list=elem.classList; + + if(list!==undefined && list.contains(furnitureClass)) { - elem.classList.remove(furnitureClass); + list.remove(furnitureClass); } + else + { + var className=elem.className; + var indStart=className.indexOf(furnitureClass); + var indEnd=className.indexOf(" ", indStart); + + indEnd=(indEnd>=0) ? indEnd : className.length; + elem.className=className.substring(0, indStart)+" "+className.substring(indEnd); + } }); } }); From cfc78e92a7f8b001a32176d1ca960b8ac126d674 Mon Sep 17 00:00:00 2001 From: Alistair Coleman Date: Thu, 24 Sep 2015 16:55:07 +0100 Subject: [PATCH 2/2] Paper Badger widget with added support for different endpoints. --- public/widgets/paper-badger-widget.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/public/widgets/paper-badger-widget.js b/public/widgets/paper-badger-widget.js index b4f198f..aeb6cb6 100644 --- a/public/widgets/paper-badger-widget.js +++ b/public/widgets/paper-badger-widget.js @@ -87,12 +87,24 @@ function splitArray(arr, lookGroup, taxonomyClass) return ttt; } +function getEndpoint(confIn, count) +{ + var orcid=confIn["orcid"]; + var doi=confIn["article-doi"]; + var countPoint=(count) ? "/count" : ""; + + var endPoint=[]; + if(doi) {endPoint.push("papers/"+doi);} + if(orcid) {endPoint.push("users/"+orcid);} + return "https://badges.mozillascience.org/"+endPoint.join("/")+"/badges"+countPoint; +} + function showBadgeFurniture(confIn) { var furnitureClass=(confIn["furniture-class"]) ? confIn["furniture-class"] : "paper-badges-hidden"; - var doi=confIn["article-doi"]; + var endPoint=getEndpoint(confIn, 1); - callAjax("https://badges.mozillascience.org/papers/"+doi+"/badges/count", function(dataItem){ + callAjax(endPoint, function(dataItem){ var badgesCount=(dataItem) ? dataItem : 0; if(badgesCount && dataItem/dataItem) @@ -123,14 +135,14 @@ function showBadges(confIn, callback){ var k=""; var containerClass=(confIn["container-class"]) ? confIn["container-class"] : "badge-container"; - var doi=confIn["article-doi"]; - + var endPoint=getEndpoint(confIn); + if(callback) { clickEvent.assignCallback(callback); } - callAjax("https://badges.mozillascience.org/papers/"+doi+"/badges", function( entryData ) { + callAjax(endPoint, function( entryData ) { var outCount=0; var pos=0, end=0;