@@ -13,7 +13,7 @@ app.navigation = (function () {
13
13
this . bindEvents ( errors , scenarios , filteringButtons , displayChartButton ) ;
14
14
this . bindFilterButtonsEvent ( filteringButtons , scenarios , steps ) ;
15
15
} ,
16
-
16
+ /** Showing error log for step that failed */
17
17
showErrorDetails : function ( e ) {
18
18
e . stopPropagation ( ) ;
19
19
var display = this . querySelector ( '.error-details' ) . style . display ;
@@ -24,7 +24,7 @@ app.navigation = (function () {
24
24
this . querySelector ( '.error-details' ) . style . display = 'block' ;
25
25
}
26
26
} ,
27
-
27
+ /** Hiding and displaying steps after clicking on scenario header*/
28
28
toggleStep : function ( ) {
29
29
var steps = this . querySelectorAll ( '.step' ) ;
30
30
for ( var k = 0 ; k < steps . length ; k ++ ) {
@@ -48,14 +48,15 @@ app.navigation = (function () {
48
48
scenarios [ i ] . addEventListener ( 'click' , this . toggleStep , false ) ;
49
49
}
50
50
} ,
51
-
52
-
53
- /** Filtering scenarios */
51
+ /**
52
+ * Filtering passed and failed scenarios by clicking the passed or failed button respectively
53
+ *
54
+ * @param buttonState indicates the clicked button
55
+ */
54
56
filterScenarios : function ( buttonState ) {
55
57
var scenarios = document . querySelectorAll ( '.scenario' ) ,
56
58
hasClass ;
57
59
for ( var i = 0 ; i < scenarios . length ; i ++ ) {
58
-
59
60
hasClass = scenarios [ i ] . classList . contains ( buttonState ) ;
60
61
if ( hasClass === true ) {
61
62
if ( scenarios [ i ] . parentNode . style . display === 'none' ) {
@@ -66,16 +67,20 @@ app.navigation = (function () {
66
67
}
67
68
}
68
69
} ,
69
-
70
- /** Displaying all scenarios */
70
+ /**
71
+ * Displaying all scenarios within the report
72
+ *
73
+ * @param scenarios indicate the all scenarios in report
74
+ *
75
+ */
71
76
displayAllScenarios : function ( scenarios ) {
72
77
for ( var i = 0 ; i < scenarios . length ; i ++ ) {
73
78
if ( scenarios [ i ] . style . display != 'block' ) {
74
79
scenarios [ i ] . style . display = 'block' ;
75
80
}
76
81
}
77
82
} ,
78
- /*
83
+ /**
79
84
* @param string buttonsList indicate the group of buttons that have the "active" class name
80
85
*
81
86
* Removing "active" class from all buttons except for the active one
@@ -85,7 +90,15 @@ app.navigation = (function () {
85
90
buttonsList [ j ] . classList . remove ( 'active' ) ;
86
91
}
87
92
} ,
88
-
93
+ /**
94
+ * Run appropriate action depending on button state
95
+ *
96
+ * @param filteringButtons indicate the navigation buttons
97
+ *
98
+ * @param scenarios indicate all scenarios in report
99
+ *
100
+ * @param steps indicate all steps in report
101
+ */
89
102
bindFilterButtonsEvent : function ( filteringButtons , scenarios , steps ) {
90
103
var self = this ,
91
104
btnState ;
@@ -94,7 +107,7 @@ app.navigation = (function () {
94
107
95
108
btnState = this . dataset . state ;
96
109
97
- if ( btnState !== 'chart ' ) {
110
+ if ( btnState !== 'steps ' ) {
98
111
self . removeActiveClass ( filteringButtons ) ;
99
112
this . classList . add ( 'active' ) ;
100
113
self . hideSteps ( steps ) ;
@@ -110,7 +123,7 @@ app.navigation = (function () {
110
123
break ;
111
124
case 'steps' :
112
125
self . displayAllScenarios ( scenarios ) ;
113
- self . showSteps ( steps ) ;
126
+ self . toggleSteps ( steps ) ;
114
127
break ;
115
128
default :
116
129
self . filterScenarios ( btnState ) ;
@@ -120,13 +133,28 @@ app.navigation = (function () {
120
133
} , false ) ;
121
134
}
122
135
} ,
123
-
124
- showSteps : function ( steps ) {
136
+ /**
137
+ * Displaying and hiding steps by clicking "chart report" button
138
+ *
139
+ * @param steps indicate all steps in report
140
+ */
141
+ toggleSteps : function ( steps ) {
125
142
for ( var i = 0 ; i < steps . length ; i ++ ) {
126
- steps [ i ] . style . display = 'block' ;
143
+ var display = steps [ i ] . style . display ;
144
+ if ( display === 'none' || display === '' ) {
145
+ steps [ i ] . style . display = 'block' ;
146
+ all_btn . classList . add ( 'active' ) ;
147
+ } else {
148
+ all_btn . classList . add ( 'active' ) ;
149
+ steps [ i ] . style . display = 'none' ;
150
+ }
127
151
}
128
152
} ,
129
-
153
+ /**
154
+ * Hiding currently displayed steps
155
+ *
156
+ * @param steps indicate all steps in report
157
+ */
130
158
hideSteps : function ( steps ) {
131
159
for ( var i = 0 ; i < steps . length ; i ++ ) {
132
160
steps [ i ] . style . display = 'none' ;
0 commit comments