@@ -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
113113var 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