File tree 4 files changed +17
-17
lines changed
4 files changed +17
-17
lines changed Original file line number Diff line number Diff line change 157
157
// specified default.
158
158
159
159
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" ) ;
160
173
}
161
174
} ) ;
162
175
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
-
176
176
// Mobile version of data and removeData and hasData methods
177
177
// ensures all data is set and retrieved using jQuery Mobile's data namespace
178
178
$ . fn . jqmData = function ( prop , value ) {
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ $.mobile.page.prototype.options.degradeInputs = {
24
24
//auto self-init widgets
25
25
$ ( document ) . bind ( "pagecreate create" , function ( e ) {
26
26
27
- var page = $ ( e . target ) . closestPageData ( ) ;
27
+ var page = $ . mobile . closestPageData ( $ ( e . target ) ) ;
28
28
29
29
if ( ! page ) {
30
30
return ;
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ $.widget( "mobile.widget", {
39
39
// TODO remove dependency on the page widget for the keepNative.
40
40
// Currently the keepNative value is defined on the page prototype so
41
41
// the method is as well
42
- var page = $ ( target ) . closestPageData ( ) ,
42
+ var page = $ . mobile . closestPageData ( $ ( target ) ) ,
43
43
keepNative = ( page && page . keepNativeSelector ( ) ) || "" ;
44
44
45
45
$ ( this . options . initSelector , target ) . not ( keepNative ) [ this . widgetName ] ( ) ;
Original file line number Diff line number Diff line change 150
150
var pageChild = $ ( "#page-child" ) ;
151
151
152
152
$ ( "#parent-page" ) . data ( "page" , { foo : "bar" } ) ;
153
- same ( pageChild . closestPageData ( ) . foo , "bar" ) ;
153
+ same ( $ . mobile . closestPageData ( pageChild ) . foo , "bar" ) ;
154
154
} ) ;
155
155
156
156
test ( "closestPageData returns the parent dialog's page data" , function ( ) {
157
157
var dialogChild = $ ( "#dialog-child" ) ;
158
158
159
159
$ ( "#parent-dialog" ) . data ( "page" , { foo : "bar" } ) ;
160
- same ( dialogChild . closestPageData ( ) . foo , "bar" ) ;
160
+ same ( $ . mobile . closestPageData ( dialogChild ) . foo , "bar" ) ;
161
161
} ) ;
162
162
} ) ( jQuery ) ;
You can’t perform that action at this time.
0 commit comments