@@ -125,103 +125,95 @@ <h2>Submit Tests</h2>
125125
126126< script type ='text/javascript '>
127127
128- $ ( "#fileversion" ) . text ( $ . fn . jquery ) ;
128+ $ ( "#fileversion" ) . text ( $ . fn . jquery ) ;
129129
130130// Try an auto-submit, it should only fire once
131- $ ( function ( ) {
131+ $ ( function ( ) {
132132 var triggered = false ;
133- $ ( "#autosub input" ) . trigger ( "keypress" ) ;
134- $ ( "body" ) . on ( "submit" , "#autosub" , function ( e ) {
133+ $ ( "#autosub input" ) . trigger ( "keypress" ) ;
134+ $ ( "body" ) . on ( "submit" , "#autosub" , function ( e ) {
135135 e . preventDefault ( ) ;
136136 e . stopPropagation ( ) ;
137137 if ( triggered ) {
138- alert ( "autosubmit FAIL" ) ;
138+ alert ( "autosubmit FAIL" ) ;
139139 }
140140 triggered = true ;
141- } ) ;
142- $ ( "#autosub" ) . submit ( ) . remove ( ) ;
143- } ) ;
141+ } ) ;
142+ $ ( "#autosub" ) . submit ( ) . remove ( ) ;
143+ } ) ;
144144
145145// Events we want to track in row-order
146- var events = "bind-change live-change onX-change bind-propertychange live-beforeactivate live-focusin bind-focus live-beforedeactivate live-focusout bind-blur live-click live-keydown" . split ( " " ) ,
146+ var events = "bind-change live-change onX-change bind-propertychange live-beforeactivate live-focusin bind-focus live-beforedeactivate live-focusout bind-blur live-click live-keydown" . split ( " " ) ,
147147 counter = 0 ;
148- blinker = function ( event ) {
149- if ( ! counter ) {
150- $ ( "#changes tbody td" ) . text ( "" ) ;
151- }
152- var $el = event . data ,
153- prev = $el . text ( ) ;
154- prev = prev ? prev + " | " : "" ;
155- return $el
156- . text ( prev + ++ counter + " " + ( this . value . replace ( / ^ o n $ / , "" ) || this . id || this . checked || "" ) )
157- . css ( "backgroundColor" , "#0f0" )
158- . delay ( 800 )
159- . queue ( function ( next ) {
160- $el . css ( "backgroundColor" , "#afa" ) ;
161- -- counter ;
162- next ( ) ;
163- } ) ;
164- } ;
148+ blinker = function ( event ) {
149+ if ( ! counter ) {
150+ $ ( "#changes tbody td" ) . text ( "" ) ;
151+ }
152+ var $el = event . data ,
153+ prev = $el . text ( ) ;
154+ prev = prev ? prev + " | " : "" ;
155+ return $el
156+ . text ( prev + ++ counter + " " + ( this . value . replace ( / ^ o n $ / , "" ) || this . id || this . checked || "" ) )
157+ . css ( "backgroundColor" , "#0f0" )
158+ . delay ( 800 )
159+ . queue ( function ( next ) {
160+ $el . css ( "backgroundColor" , "#afa" ) ;
161+ -- counter ;
162+ next ( ) ;
163+ } ) ;
164+ } ;
165165
166- for ( var i = 0 ; i < events . length ; i ++ ) {
167- var m = events [ i ] . split ( "-" ) ,
168- api = m [ 0 ] ,
169- type = m [ 1 ] ,
170- $row = $ ( "<tr><th>" + type + " " + api + "</th></tr>" ) ;
166+ for ( var i = 0 ; i < events . length ; i ++ ) {
167+ var m = events [ i ] . split ( "-" ) ,
168+ api = m [ 0 ] ,
169+ type = m [ 1 ] ,
170+ $row = $ ( "<tr><th>" + type + " " + api + "</th></tr>" ) ;
171171
172- $ ( "#changes thead td" ) . each ( function ( ) {
173- var id = "#" + this . id ,
174- $cell = $ ( "<td></td>" ) ;
172+ $ ( "#changes thead td" ) . each ( function ( ) {
173+ var id = "#" + this . id ,
174+ $cell = $ ( "<td></td>" ) ;
175175 if ( api == "onX" ) {
176- $ ( this ) . find ( "input, button, select, textarea" ) . each ( function ( ) {
177- this [ "on" + type ] = function ( e ) { e = $ . event . fix ( e || event ) ; e . data = $cell ; blinker . call ( this , e ) ; } ;
178- } ) ;
176+ $ ( this ) . find ( "input, button, select, textarea" ) . each ( function ( ) {
177+ this [ "on" + type ] = function ( e ) {
178+ e = $ . event . fix ( e || event ) ; e . data = $cell ; blinker . call ( this , e ) ;
179+ } ;
180+ } ) ;
179181 } else if ( api == "bind" ) {
180- $ ( this ) . find ( "input, button, select, textarea" ) . bind ( type , $cell , blinker ) ;
182+ $ ( this ) . find ( "input, button, select, textarea" ) . bind ( type , $cell , blinker ) ;
181183 } else {
182- $ ( id + " input," + id + " button," + id + " select," + id + " textarea" ) . live ( type , $cell , blinker ) ;
184+ $ ( id + " input," + id + " button," + id + " select," + id + " textarea" ) . live ( type , $cell , blinker ) ;
183185 }
184- $row . append ( $cell ) ;
185- } ) ;
186- $ ( "#changes tbody" ) . append ( $row ) ;
187- }
188-
189- // Ensure that cloned elements get the delegated event magic; this is
190- // implementation-specific knowledge but otherwise impossible to test.
191- // The beforeactivate event attaches a direct-bound change event.
192- // (Only care about the live change for this third select element.)
193- var sel1 = $ ( "#select-one select:first-child" ) ;
194- if ( typeof ( sel1 [ 0 ] . fireEvent ) !== "undefined" ) {
195- sel1 . trigger ( "beforeactivate" ) . clone ( ) . appendTo ( "#select-one" ) ;
196- //alert($("#select-one select").map(function(){ return this._change_attached || "undef"; }).get().join("|"));
186+ $row . append ( $cell ) ;
187+ } ) ;
188+ $ ( "#changes tbody" ) . append ( $row ) ;
197189}
198190
199- jQuery . fn . blink = function ( ) {
191+ jQuery . fn . blink = function ( ) {
200192 return this
201- . css ( "backgroundColor" , "green" )
202- . text ( ( parseInt ( this . text ( ) , 10 ) || 0 ) + 1 )
203- . delay ( 700 ) . queue ( function ( next ) {
204- jQuery ( this ) . css ( "backgroundColor" , "#afa" ) ;
193+ . css ( "backgroundColor" , "green" )
194+ . text ( ( parseInt ( this . text ( ) , 10 ) || 0 ) + 1 )
195+ . delay ( 700 ) . queue ( function ( next ) {
196+ jQuery ( this ) . css ( "backgroundColor" , "#afa" ) ;
205197 next ( ) ;
206- } ) ;
198+ } ) ;
207199} ;
208200
209201jQuery . fn . addSubmitTest = function ( id , prevent ) {
210- return this . live ( "submit" , function ( e ) {
202+ return this . live ( "submit" , function ( e ) {
211203 if ( prevent ) {
212- e . preventDefault ( ) ;
204+ e . preventDefault ( ) ;
213205 }
214- jQuery ( id ) . blink ( ) ;
215- } ) ;
206+ jQuery ( id ) . blink ( ) ;
207+ } ) ;
216208} ;
217209
218- $ ( "#text_submit" ) . addSubmitTest ( "#textSubmit" , true ) ;
219- $ ( "#password_submit" ) . addSubmitTest ( "#passwordSubmit" , true ) ;
220- $ ( "#submit_submit" ) . addSubmitTest ( "#submitSubmit" , true ) ;
221- $ ( "#prog_submit" ) . addSubmitTest ( "#submitSubmit" , true ) ;
222- $ ( document ) . bind ( "submit" , function ( ) {
223- jQuery ( "#boundSubmit" ) . blink ( ) ;
224- } ) ;
210+ $ ( "#text_submit" ) . addSubmitTest ( "#textSubmit" , true ) ;
211+ $ ( "#password_submit" ) . addSubmitTest ( "#passwordSubmit" , true ) ;
212+ $ ( "#submit_submit" ) . addSubmitTest ( "#submitSubmit" , true ) ;
213+ $ ( "#prog_submit" ) . addSubmitTest ( "#submitSubmit" , true ) ;
214+ $ ( document ) . bind ( "submit" , function ( ) {
215+ jQuery ( "#boundSubmit" ) . blink ( ) ;
216+ } ) ;
225217
226218</ script >
227219</ body >
0 commit comments