Skip to content

Commit f45db87

Browse files
Adding a "tutorial.change" event listener to the input box that is triggered when the tutorial changes the input.
This replaces $input.change(), which no longer triggers the input recalculation now that there is an explicit submit button.
1 parent e33da07 commit f45db87

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

js/main.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ define(function(require, exports, module) {
139139
$startTutorial = $('.js-tutorial-start'),
140140
lastTutorialStepNum = null;
141141

142-
$submit.on('click keypress', function() {
142+
function processInput() {
143143
var input = $input.val(),
144144
expression, columnClasses;
145145

@@ -174,6 +174,14 @@ define(function(require, exports, module) {
174174
}
175175

176176
}
177+
}
178+
179+
$submit.on('click keypress', function() {
180+
processInput();
181+
});
182+
183+
$input.on('tutorial.change', function() {
184+
processInput();
177185
});
178186

179187
$startTutorial.click(function() {
@@ -186,7 +194,7 @@ define(function(require, exports, module) {
186194
// so detect the start using onShow
187195
if(lastTutorialStepNum === null) {
188196
userInput = $input.val();
189-
$input.val('').change();
197+
$input.val('').trigger('tutorial.change');
190198
}
191199
},
192200
onShown: function(tour) {
@@ -205,7 +213,7 @@ define(function(require, exports, module) {
205213
},
206214
onEnd: function(tour) {
207215
lastTutorialStepNum = null;
208-
$input.val(userInput).change();
216+
$input.val(userInput).trigger('tutorial.change');
209217
trackEventTutorialEnd(thisStepNum(tour));
210218
}
211219
});

js/tutorial.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ define(function(require, exports, module) {
77

88
function Tutorial(_options) {
99
var resetInput = function() {
10-
return $input.val('').change();
10+
return $input.val('').trigger('tutorial.change');
1111
};
1212

1313
var example1 = 'if( A || B ) {',
@@ -41,7 +41,7 @@ define(function(require, exports, module) {
4141
},{
4242
onShow: function(tour) {
4343
if(_options.onShow) { _options.onShow(tour); }
44-
resetInput().val(example1).change();
44+
resetInput().val(example1).trigger('tutorial.change');
4545
},
4646
element: '.js-truth-table',
4747
placement: 'bottom',
@@ -59,7 +59,7 @@ define(function(require, exports, module) {
5959
},{
6060
onShow: function(tour) {
6161
if(_options.onShow) { _options.onShow(tour); }
62-
resetInput().val(example2).change();
62+
resetInput().val(example2).trigger('tutorial.change');
6363
},
6464
element: '.js-truth-table',
6565
placement: 'bottom',
@@ -77,7 +77,7 @@ define(function(require, exports, module) {
7777
},{
7878
onShow: function(tour) {
7979
if(_options.onShow) { _options.onShow(tour); }
80-
resetInput().val(example3).change();
80+
resetInput().val(example3).trigger('tutorial.change');
8181
},
8282
element: '.js-truth-table',
8383
placement: 'bottom',

0 commit comments

Comments
 (0)