File tree Expand file tree Collapse file tree 4 files changed +17
-17
lines changed
Expand file tree Collapse file tree 4 files changed +17
-17
lines changed Original file line number Diff line number Diff line change 157157 // specified default.
158158
159159 return ltr || defaultTheme || "a" ;
160+ } ,
161+
162+ // TODO the following $ and $.fn extensions can/probably should be moved into jquery.mobile.core.helpers
163+ //
164+ // Find the closest javascript page element to gather settings data jsperf test
165+ // http://jsperf.com/single-complex-selector-vs-many-complex-selectors/edit
166+ // possibly naive, but it shows that the parsing overhead for *just* the page selector vs
167+ // the page and dialog selector is negligable. This could probably be speed up by
168+ // doing a similar parent node traversal to the one found in the inherited theme code above
169+ closestPageData : function ( $target ) {
170+ return $target
171+ . closest ( ':jqmData(role="page"), :jqmData(role="dialog")' )
172+ . data ( "page" ) ;
160173 }
161174 } ) ;
162175
163- // TODO the following $ and $.fn extensions can/probably should be moved into jquery.mobile.core.helpers
164- //
165- // Find the closest javascript page element to gather settings data jsperf test
166- // http://jsperf.com/single-complex-selector-vs-many-complex-selectors/edit
167- // possibly naive, but it shows that the parsing overhead for *just* the page selector vs
168- // the page and dialog selector is negligable. This could probably be speed up by
169- // doing a similar parent node traversal to the one found in the inherited theme code above
170- $ . fn . closestPageData = function ( ) {
171- return $ ( this )
172- . closest ( ':jqmData(role="page"), :jqmData(role="dialog")' )
173- . data ( "page" ) ;
174- } ;
175-
176176 // Mobile version of data and removeData and hasData methods
177177 // ensures all data is set and retrieved using jQuery Mobile's data namespace
178178 $ . fn . jqmData = function ( prop , value ) {
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ $.mobile.page.prototype.options.degradeInputs = {
2424//auto self-init widgets
2525$ ( document ) . bind ( "pagecreate create" , function ( e ) {
2626
27- var page = $ ( e . target ) . closestPageData ( ) ;
27+ var page = $ . mobile . closestPageData ( $ ( e . target ) ) ;
2828
2929 if ( ! page ) {
3030 return ;
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ $.widget( "mobile.widget", {
3939 // TODO remove dependency on the page widget for the keepNative.
4040 // Currently the keepNative value is defined on the page prototype so
4141 // the method is as well
42- var page = $ ( target ) . closestPageData ( ) ,
42+ var page = $ . mobile . closestPageData ( $ ( target ) ) ,
4343 keepNative = ( page && page . keepNativeSelector ( ) ) || "" ;
4444
4545 $ ( this . options . initSelector , target ) . not ( keepNative ) [ this . widgetName ] ( ) ;
Original file line number Diff line number Diff line change 150150 var pageChild = $ ( "#page-child" ) ;
151151
152152 $ ( "#parent-page" ) . data ( "page" , { foo : "bar" } ) ;
153- same ( pageChild . closestPageData ( ) . foo , "bar" ) ;
153+ same ( $ . mobile . closestPageData ( pageChild ) . foo , "bar" ) ;
154154 } ) ;
155155
156156 test ( "closestPageData returns the parent dialog's page data" , function ( ) {
157157 var dialogChild = $ ( "#dialog-child" ) ;
158158
159159 $ ( "#parent-dialog" ) . data ( "page" , { foo : "bar" } ) ;
160- same ( dialogChild . closestPageData ( ) . foo , "bar" ) ;
160+ same ( $ . mobile . closestPageData ( dialogChild ) . foo , "bar" ) ;
161161 } ) ;
162162} ) ( jQuery ) ;
You can’t perform that action at this time.
0 commit comments