/js/jquery.mobile.widget.js
https://github.com/asgeo1/jquery-mobile · JavaScript · 54 lines · 29 code · 11 blank · 14 comment · 3 complexity · f0246f884818286d3945fce8dbb18326 MD5 · raw file
- //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
- //>>description: Widget factory extentions for mobile.
- //>>label: Widget Factory Extensions
- define( [ "jquery.ui.widget" ], function() {
- //>>excludeEnd("jqmBuildExclude");
- (function( $, undefined ) {
- $.widget( "mobile.widget", {
- // decorate the parent _createWidget to trigger `widgetinit` for users
- // who wish to do post post `widgetcreate` alterations/additions
- //
- // TODO create a pull request for jquery ui to trigger this event
- // in the original _createWidget
- _createWidget: function() {
- $.Widget.prototype._createWidget.apply( this, arguments );
- this._trigger( 'init' );
- },
- _getCreateOptions: function() {
- var elem = this.element,
- options = {};
- $.each( this.options, function( option ) {
- var value = elem.jqmData( option.replace( /[A-Z]/g, function( c ) {
- return "-" + c.toLowerCase();
- })
- );
- if ( value !== undefined ) {
- options[ option ] = value;
- }
- });
- return options;
- },
- enhanceWithin: function( target ) {
- // TODO remove dependency on the page widget for the keepNative.
- // Currently the keepNative value is defined on the page prototype so
- // the method is as well
- var page = $.mobile.closestPageData( $(target) ),
- keepNative = (page && page.keepNativeSelector()) || "";
- $( this.options.initSelector, target ).not( keepNative )[ this.widgetName ]();
- }
- });
- })( jQuery );
- //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
- });
- //>>excludeEnd("jqmBuildExclude");