@@ -19,11 +19,11 @@ import Tooltip from 'appirio-tech-react-components/components/Tooltip/Tooltip.js
19
19
rating : '=' ,
20
20
graphState : '='
21
21
} ,
22
- controller : [ '$scope' , '$state' , 'CONSTANTS' , HistoryGraphController ]
22
+ controller : [ '$scope' , '$state' , '$filter' , ' CONSTANTS', HistoryGraphController ]
23
23
}
24
24
}
25
25
26
- function HistoryGraphController ( $scope , $state , CONSTANTS ) {
26
+ function HistoryGraphController ( $scope , $state , $filter , CONSTANTS ) {
27
27
$scope . colors = [
28
28
// grey
29
29
{
@@ -275,13 +275,11 @@ import Tooltip from 'appirio-tech-react-components/components/Tooltip/Tooltip.js
275
275
$scope . historyRating = d . newRating
276
276
$scope . historyDate = moment ( d . ratingDate ) . format ( 'YYYY-MM-DD' )
277
277
$scope . historyChallenge = d . challengeName
278
- $ ( '#chart-tooltip .tooltip-container' ) . on ( 'click' , function ( ) {
279
- if ( $state . params && $state . params . track === 'DEVELOP' )
280
- location . href = ( CONSTANTS . CHALLENGE_DETAIL_URL + d . challengeId + '/?type=develop' )
281
- else if ( $state . params && $state . params . subTrack === 'SRM' )
282
- location . href = ( CONSTANTS . SRM_DETAIL_URL + d . challengeId )
283
- else if ( $state . params && $state . params . subTrack === 'MARATHON_MATCH' )
284
- location . href = ( CONSTANTS . MARATHON_DETAIL_URL + d . challengeId )
278
+ $ ( '#chart-tooltip .tooltip-container' ) . on ( 'click' , function ( ) {
279
+ if ( $state . params && ( $state . params . subTrack === 'SRM' || $state . params . subTrack === 'MARATHON_MATCH' ) )
280
+ location . href = $filter ( 'challengeLinks' ) ( { 'rounds' : [ { id : d . challengeId , forumId : null } ] , 'track' : $state . params . track , 'subTrack' : $state . params . subTrack } , 'detail' )
281
+ else
282
+ location . href = $filter ( 'challengeLinks' ) ( { id : d . challengeId , 'track' : $state . params . track , 'subTrack' : $state . params . subTrack } , 'detail' )
285
283
} )
286
284
d3 . select ( '#chart-tooltip' )
287
285
. style ( 'left' , ( d3 . event . pageX - 5 ) + 'px' )
@@ -297,21 +295,20 @@ import Tooltip from 'appirio-tech-react-components/components/Tooltip/Tooltip.js
297
295
d3 . select ( '#chart-tooltip .challenge-date' ) . text ( moment ( d . ratingDate ) . format ( 'MMM DD, YYYY' ) )
298
296
d3 . select ( '#chart-tooltip .tooltip-rating' ) . text ( $scope . historyRating )
299
297
d3 . select ( '#chart-tooltip .tooltip-rating' ) . style ( 'background' , ratingToColor ( $scope . colors , $scope . historyRating ) )
298
+ $ ( '#chart-tooltip' ) . removeClass ( 'distribution' )
300
299
$scope . $digest ( )
301
300
} )
302
301
. on ( 'mouseout' , function ( d ) {
303
302
$scope . historyRating = undefined
304
- $ ( '#chart-tooltip' ) . off ( 'click' )
305
303
$scope . $digest ( )
306
304
} )
307
305
308
306
d3 . select ( 'body' ) . on ( 'click' , function ( ) {
309
307
if ( ( d3 . event . target . classList [ 0 ] != 'tooltip-target' ) && ! $ ( '#chart-tooltip .tooltip-container' ) . hasClass ( 'tooltip-hide' ) &&
310
- ( d3 . event . target . classList [ 0 ] != 'tooltip-content-container' ) && ( d3 . event . target . classList [ 0 ] != 'tooltip-container' ) &&
311
- ( d3 . event . target . classList [ 0 ] != 'tooltip-body' ) && ( d3 . event . target . classList [ 0 ] != 'Tooltip' ) &&
312
308
( d3 . event . target . tagName . toLowerCase ( ) != 'circle' ) && ! ( d3 . event . target . tagName . toLowerCase ( ) == 'rect' && d3 . event . target . classList [ 0 ] == 'hover' ) ) {
313
309
$ ( '#chart-tooltip .tooltip-target' ) . trigger ( 'click' )
314
- }
310
+ $ ( '#chart-tooltip .tooltip-container' ) . off ( 'click' )
311
+ }
315
312
} )
316
313
317
314
}
@@ -322,5 +319,9 @@ import Tooltip from 'appirio-tech-react-components/components/Tooltip/Tooltip.js
322
319
} )
323
320
return colors [ 0 ] && colors [ 0 ] . color || 'black'
324
321
}
322
+
323
+ function isInArray ( value , array ) {
324
+ return array . indexOf ( value ) > - 1 ;
325
+ }
325
326
}
326
327
} ) ( )
0 commit comments