@@ -127,42 +127,95 @@ define( [ "jquery", "./jquery.mobile.ns", "./jquery.ui.core", "json!../package.j
127127 }
128128 } ) ;
129129
130- $ . fn . removeWithDependents = function ( ) {
131- $ . removeWithDependents ( this ) ;
132- } ;
133-
134- $ . removeWithDependents = function ( elem ) {
135- var $elem = $ ( elem ) ;
136-
137- ( $elem . jqmData ( "dependents" ) || $ ( ) ) . remove ( ) ;
138- $elem . remove ( ) ;
139- } ;
140-
141- $ . fn . addDependents = function ( newDependents ) {
142- $ . addDependents ( this , newDependents ) ;
143- } ;
130+
144131
145132 $ . addDependents = function ( elem , newDependents ) {
146133 var $elem = $ ( elem ) ,
147134 dependents = $elem . jqmData ( "dependents" ) || $ ( ) ;
148135
149136 $elem . jqmData ( "dependents" , $ ( dependents ) . add ( newDependents ) ) ;
150137 } ;
138+ // plugins
139+ $ . fn . extend ( {
140+ removeWithDependents : function ( ) {
141+ $ . removeWithDependents ( this ) ;
142+ } ,
151143
152- // note that this helper doesn't attempt to handle the callback
153- // or setting of an html element's text, its only purpose is
154- // to return the html encoded version of the text in all cases. (thus the name)
155- $ . fn . getEncodedText = function ( ) {
156- return $ ( "<a>" ) . text ( $ ( this ) . text ( ) ) . html ( ) ;
157- } ;
144+ //enhance child elements
145+ enhanceWithin : function ( ) {
146+ var widgetElements ,
147+ that = this ;
148+
149+ //Add no js class to elements
150+ if ( $ . mobile . nojs ) {
151+ $ . mobile . nojs ( this ) ;
152+ }
153+ //bind links for ajax nav
154+ if ( $ . mobile . links ) {
155+ $ . mobile . links ( this ) ;
156+ }
157+ //degrade inputs for styleing
158+ if ( $ . mobile . degradeInputsWithin ) {
159+ $ . mobile . degradeInputsWithin ( this ) ;
160+ }
161+ //run buttonmarkup
162+ if ( $ . mobile . enhanceWithButtonMarkup ) {
163+ $ ( "a:jqmData(role='button'), .ui-bar > a, .ui-bar > :jqmData(role='controlgroup') > a, button" , this ) . each ( $ . mobile . enhanceWithButtonMarkup ) ;
164+ }
165+ //add classes for fieldContain
166+ if ( $ . fn . fieldcontain ) {
167+
168+ $ ( ":jqmData(role='fieldcontain')" , this ) . jqmEnhanceable ( ) . fieldcontain ( ) ;
169+ }
170+ //enhance widgets
171+ $ . each ( $ . mobile . widgets , function ( name , constructor ) {
172+ //filter elements that should not be enhanced based on parents
173+ widgetElements = $ . mobile . enhanceable ( that . find ( constructor . initSelector ) ) ;
174+ //if any matching elements remain filter ones with keepNativeSelector
175+ if ( widgetElements . length ) {
176+ //$.mobile.page.prototype.keepNativeSelector is deprecated this is just for backcompt
177+ //switch to $.mobile.keepNativeSelector in 1.5 which is just a value not a function
178+ widgetElements = widgetElements . not ( $ . mobile . page . prototype . keepNativeSelector ( ) ) ;
179+ }
180+ //enhance whatever is left
181+ widgetElements [ constructor . prototype . widgetName ] ( ) ;
182+ } ) ;
183+
184+ return this ;
185+ } ,
186+
187+ addDependents : function ( newDependents ) {
188+ $ . addDependents ( this , newDependents ) ;
189+ } ,
190+
191+ // note that this helper doesn't attempt to handle the callback
192+ // or setting of an html element's text, its only purpose is
193+ // to return the html encoded version of the text in all cases. (thus the name)
194+ getEncodedText : function ( ) {
195+ return $ ( "<a>" ) . text ( $ ( this ) . text ( ) ) . html ( ) ;
196+ } ,
197+
198+ // fluent helper function for the mobile namespaced equivalent
199+ jqmEnhanceable : function ( ) {
200+ return $ . mobile . enhanceable ( this ) ;
201+ } ,
202+
203+ jqmHijackable : function ( ) {
204+ return $ . mobile . hijackable ( this ) ;
205+ }
206+ } ) ;
207+
208+ $ . removeWithDependents = function ( nativeElement ) {
209+ var element = $ ( nativeElement ) ;
158210
159- // fluent helper function for the mobile namespaced equivalent
160- $ . fn . jqmEnhanceable = function ( ) {
161- return $ . mobile . enhanceable ( this ) ;
211+ ( element . jqmData ( "dependents" ) || $ ( ) ) . remove ( ) ;
212+ element . remove ( ) ;
162213 } ;
214+ $ . addDependents = function ( nativeElement , newDependents ) {
215+ var element = $ ( nativeElement ) ,
216+ dependents = element . jqmData ( "dependents" ) || $ ( ) ;
163217
164- $ . fn . jqmHijackable = function ( ) {
165- return $ . mobile . hijackable ( this ) ;
218+ element . jqmData ( "dependents" , $ ( dependents ) . add ( newDependents ) ) ;
166219 } ;
167220
168221 $ . find . matches = function ( expr , set ) {
0 commit comments