From 2a066ba2f1c214dbfadfbbb59398aaeb4a7d7b30 Mon Sep 17 00:00:00 2001 From: Thomas Kranitsas Date: Fri, 3 Mar 2017 21:13:40 +0200 Subject: [PATCH 1/2] Fix feedback widget to be visible only on the /listings page --- app/listings/listings.controller.js | 6 +++--- app/listings/listings.jade | 2 +- app/listings/listings.routes.js | 7 +++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/listings/listings.controller.js b/app/listings/listings.controller.js index d6428e864..f709102f5 100755 --- a/app/listings/listings.controller.js +++ b/app/listings/listings.controller.js @@ -11,7 +11,7 @@ import { loadUser } from '../services/userv3.service.js' 'TcAuthService', 'UserService', 'UserStatsService', 'ProfileService', 'ChallengeService', 'ExternalAccountService', 'ngDialog', '$anchorScroll' ] - + function ListingsCtrl($location, $scope, CONSTANTS, logger, $q, TcAuthService, UserService, UserStatsService,ProfileService, ChallengeService, ExternalAccountService, ngDialog, $anchorScroll) { var vm = this @@ -32,8 +32,8 @@ import { loadUser } from '../services/userv3.service.js' s.async = true s.src = '//api.usersnap.com/load/'+ '3e7c8f0c-6cf6-41b6-9f2c-e8e4e60dfc59.js' - var x = document.getElementsByTagName('script')[0] - x.parentNode.insertBefore(s, x) + var x = document.getElementById('react-component') + x.appendChild(s, x) })() $scope.myChallenges = [] diff --git a/app/listings/listings.jade b/app/listings/listings.jade index 6401773e0..23a54d428 100755 --- a/app/listings/listings.jade +++ b/app/listings/listings.jade @@ -1 +1 @@ -react-component.listings(name="ChallengeFiltersExample" props="reactProps" watch-depth="reference") +react-component.listings(name="ChallengeFiltersExample" props="reactProps" watch-depth="reference" id="react-component") diff --git a/app/listings/listings.routes.js b/app/listings/listings.routes.js index c6a89efd3..03993bd86 100755 --- a/app/listings/listings.routes.js +++ b/app/listings/listings.routes.js @@ -14,6 +14,13 @@ import angular from 'angular' // $state.go('404') // } }) + $rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams, error) { + if (toState.name !== 'listings') { + // remove usersnap widget if not in listings page + var usersnapWidget = document.getElementById("us_report_button") + if (usersnapWidget) usersnapWidget.remove() + } + }) }]) function routes($stateProvider) { From aa5f1506b8a139e8273b515e79c931ebcf5fb992 Mon Sep 17 00:00:00 2001 From: Thomas Kranitsas Date: Fri, 3 Mar 2017 22:20:07 +0200 Subject: [PATCH 2/2] Fix feedback widget to be visible only on the /listings page --- app/listings/listings.routes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/listings/listings.routes.js b/app/listings/listings.routes.js index 03993bd86..9e3f117a2 100755 --- a/app/listings/listings.routes.js +++ b/app/listings/listings.routes.js @@ -17,8 +17,8 @@ import angular from 'angular' $rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams, error) { if (toState.name !== 'listings') { // remove usersnap widget if not in listings page - var usersnapWidget = document.getElementById("us_report_button") - if (usersnapWidget) usersnapWidget.remove() + var usersnapWidget = document.querySelectorAll('div[id*="_report_button"]') + if (usersnapWidget && usersnapWidget[0]) usersnapWidget[0].remove() } }) }])