@@ -6,18 +6,24 @@ import _ from 'lodash';
6
6
7
7
var options = { } ;
8
8
9
- function getHandleTemplate ( type , op , value ) {
9
+ function getHandleInnerHtml ( type , op , value ) {
10
10
if ( op === '>' ) { op = '>' ; }
11
11
if ( op === '<' ) { op = '<' ; }
12
12
13
- return `
13
+ return `
14
+ <div class="alert-handle-line">
15
+ </div>
16
+ <div class="alert-handle">
17
+ <i class="icon-gf icon-gf-${ type } alert-icon-${ type } "></i>
18
+ ${ op } ${ value }
19
+ </div>` ;
20
+ }
21
+
22
+ function getFullHandleHtml ( type , op , value ) {
23
+ var innerTemplate = getHandleInnerHtml ( type , op , value ) ;
24
+ return `
14
25
<div class="alert-handle-wrapper alert-handle-wrapper--${ type } ">
15
- <div class="alert-handle-line">
16
- </div>
17
- <div class="alert-handle">
18
- <i class="icon-gf icon-gf-${ type } alert-icon-${ type } "></i>
19
- ${ op } ${ value }
20
- </div>
26
+ ${ innerTemplate }
21
27
</div>
22
28
` ;
23
29
}
@@ -32,14 +38,12 @@ function dragEndHandler() {
32
38
console . log ( 'drag end' ) ;
33
39
}
34
40
35
- var past ;
36
-
37
41
function drawAlertHandles ( plot ) {
38
42
var options = plot . getOptions ( ) ;
39
43
var $placeholder = plot . getPlaceholder ( ) ;
40
44
41
45
if ( ! options . alerting . editing ) {
42
- $placeholder . find ( ".alert-handle" ) . remove ( ) ;
46
+ $placeholder . find ( ".alert-handle-wrapper " ) . remove ( ) ;
43
47
return ;
44
48
}
45
49
@@ -55,16 +59,15 @@ function drawAlertHandles(plot) {
55
59
}
56
60
57
61
if ( $handle . length === 0 ) {
58
- console . log ( 'not found ' ) ;
59
- $handle = $ ( getHandleTemplate ( type , model . op , model . level ) ) ;
62
+ console . log ( 'creating handle ' ) ;
63
+ $handle = $ ( getFullHandleHtml ( type , model . op , model . level ) ) ;
60
64
$handle . attr ( 'draggable' , true ) ;
61
65
$handle . bind ( 'dragend' , dragEndHandler ) ;
62
66
$handle . bind ( 'dragstart' , dragStartHandler ) ;
63
67
$placeholder . append ( $handle ) ;
64
- console . log ( 'registering drag events' ) ;
65
68
} else {
66
- console . log ( 'reusing!' ) ;
67
- $handle . html ( getHandleTemplate ( type , model . op , model . level ) ) ;
69
+ console . log ( 'reusing handle !' ) ;
70
+ $handle . html ( getHandleInnerHtml ( type , model . op , model . level ) ) ;
68
71
}
69
72
70
73
var levelCanvasPos = plot . p2c ( { x : 0 , y : model . level } ) ;
0 commit comments