Skip to content

Commit ba74c04

Browse files
committed
bammy
1 parent 9f08378 commit ba74c04

2 files changed

Lines changed: 25 additions & 11 deletions

File tree

‎v3/js/opt-office-mix.js‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,9 @@ function officeMixEnterViewMode() {
260260

261261
if (savedAppState.testCasesLst) {
262262
$("#createTestsLink").hide();
263-
initTestcasesPane('#testCasesPane');
263+
initTestcasesPane('#testCasesPane', saveCurrentConfiguration);
264264
savedAppState.testCasesLst.forEach(function(e) {
265-
addTestcase(e);
265+
addTestcase(e, saveCurrentConfiguration);
266266
});
267267
}
268268

@@ -305,9 +305,9 @@ function officeMixEnterEditMode() {
305305

306306
if (savedAppState.testCasesLst) {
307307
$("#createTestsLink").hide();
308-
initTestcasesPane('#testCasesPane');
308+
initTestcasesPane('#testCasesPane', saveCurrentConfiguration);
309309
savedAppState.testCasesLst.forEach(function(e) {
310-
addTestcase(e);
310+
addTestcase(e, saveCurrentConfiguration);
311311
});
312312
}
313313

@@ -411,7 +411,7 @@ $(document).ready(function() {
411411
});
412412

413413
$("#createTestsLink").click(function() {
414-
initTestcasesPane('#testCasesPane');
414+
initTestcasesPane('#testCasesPane', saveCurrentConfiguration);
415415
$(this).hide();
416416
return false;
417417
});

‎v3/js/opt-testcases.js‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ var testcasesPaneHtml = '\
5252
<a href="#" id="addNewTestCase">Add new test</a>\
5353
'
5454

55-
function initTestcasesPane(parentDivId) {
55+
function initTestcasesPane(parentDivId, onChangeCallback /* optional */) {
5656
$(parentDivId).empty(); // just to be paranoid, empty this out
5757
// (and its event handlers, too, supposedly)
5858
$(parentDivId).html(testcasesPaneHtml);
5959

6060
$("#addNewTestCase").click(function() {
61-
addTestcase();
61+
addTestcase(null, onChangeCallback);
6262
return false; // to prevent link from being followed
6363
});
6464

@@ -112,7 +112,8 @@ function vizTestFinishSuccessfulExecution() {
112112

113113
var curTestcaseId = 1;
114114

115-
function addTestcase(initialCod /* optional code to pre-seed this test */) {
115+
function addTestcase(initialCod /* optional code to pre-seed this test */,
116+
onChangeCallback /* to be called if this elt changes */) {
116117
var id = curTestcaseId;
117118
curTestcaseId++; // nasty global
118119
var newTr = $('<tr/>').attr('id', 'testCaseRow_' + id);
@@ -175,6 +176,13 @@ function addTestcase(initialCod /* optional code to pre-seed this test */) {
175176
}
176177
s.setMode("ace/mode/" + mod);
177178

179+
// detect when the buffer has changed
180+
s.on("change", function() {
181+
if (onChangeCallback) {
182+
onChangeCallback();
183+
}
184+
});
185+
178186
te.setValue(initialCod ? initialCod.rtrim() : defaultVal,
179187
-1 /* do NOT select after setting text */);
180188

@@ -256,13 +264,19 @@ function addTestcase(initialCod /* optional code to pre-seed this test */) {
256264
$('#vizTestCase_' + id).click(runOrVizTestCase.bind(null, true));
257265

258266
$('#delTestCase_' + id).click(function() {
259-
var res = confirm("Press OK to delete this test.");
260-
if (res) {
261-
$('#testCaseRow_' + id).remove();
267+
// confirm() not supported within Office Mix labs :/
268+
//var res = confirm("Press OK to delete this test.");
269+
270+
$('#testCaseRow_' + id).remove();
271+
if (onChangeCallback) {
272+
onChangeCallback();
262273
}
263274
return false; // to prevent link from being followed
264275
});
265276

277+
if (onChangeCallback) {
278+
onChangeCallback();
279+
}
266280
}
267281

268282
// returns a list of strings, each of which is a test case

0 commit comments

Comments
 (0)