@@ -216,22 +216,12 @@ $( document ).on( "pagebeforecreate", "[data-role='page']", function() {
216
216
SyntaxHighlighter . defaults [ 'auto-links' ] = false ;
217
217
} ) ;
218
218
219
- $ ( document ) . on ( "pagecreate" , function ( e ) {
220
- // prevent page scroll while scrolling source code
221
- $ ( document ) . on ( "mousewheel" , ".jqm-view-source .ui-collapsible-content" , function ( event , delta ) {
222
- if ( delta > 0 && $ ( this ) . scrollTop ( ) === 0 ) {
223
- event . preventDefault ( ) ;
224
- } else if ( delta < 0 && $ ( this ) . scrollTop ( ) === $ ( this ) . get ( 0 ) . scrollHeight - $ ( this ) . innerHeight ( ) ) {
225
- event . preventDefault ( ) ;
226
- }
227
- } ) ;
228
-
219
+ $ ( document )
229
220
// reposition when switching between html / js / css
230
- $ ( e . target ) . delegate ( ".jqm-view-source .ui-collapsible" , "expand ", function ( ) {
221
+ . on ( "collapsibleexpand" , " .jqm-view-source .ui-collapsible", function ( ) {
231
222
$ ( this ) . parents ( ":mobile-popup" ) . popup ( "reposition" , { positionTo : "window" } ) ;
232
- } ) ;
233
-
234
- $ ( e . target ) . delegate ( ".jqm-view-source" , "popupbeforeposition" , function ( ) {
223
+ } )
224
+ . on ( "popupbeforeposition" , ".jqm-view-source" , function ( ) {
235
225
// max height: screen height - tolerance (2*30px) - 42px for each collapsible heading
236
226
var x = $ ( this ) . find ( ".ui-collapsible" ) . length ,
237
227
maxHeight = $ . mobile . getScreenHeight ( ) - 60 - ( x * 42 ) ;
@@ -251,8 +241,17 @@ $( document ).on( "pagecreate", function( e ) {
251
241
$ ( line ) . height ( height ) ;
252
242
}
253
243
} ) ;
244
+ } )
245
+ . on ( "pagecreate" , function ( e ) {
246
+ // prevent page scroll while scrolling source code
247
+ $ ( document ) . on ( "mousewheel" , ".jqm-view-source .ui-collapsible-content" , function ( event , delta ) {
248
+ if ( delta > 0 && $ ( this ) . scrollTop ( ) === 0 ) {
249
+ event . preventDefault ( ) ;
250
+ } else if ( delta < 0 && $ ( this ) . scrollTop ( ) === $ ( this ) . get ( 0 ) . scrollHeight - $ ( this ) . innerHeight ( ) ) {
251
+ event . preventDefault ( ) ;
252
+ }
253
+ } ) ;
254
254
} ) ;
255
- } ) ;
256
255
257
256
/**
258
257
* SyntaxHighlighter
0 commit comments