/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

  1. //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
  2. //>>description: Widget factory extentions for mobile.
  3. //>>label: Widget Factory Extensions
  4. define( [ "jquery.ui.widget" ], function() {
  5. //>>excludeEnd("jqmBuildExclude");
  6. (function( $, undefined ) {
  7. $.widget( "mobile.widget", {
  8. // decorate the parent _createWidget to trigger `widgetinit` for users
  9. // who wish to do post post `widgetcreate` alterations/additions
  10. //
  11. // TODO create a pull request for jquery ui to trigger this event
  12. // in the original _createWidget
  13. _createWidget: function() {
  14. $.Widget.prototype._createWidget.apply( this, arguments );
  15. this._trigger( 'init' );
  16. },
  17. _getCreateOptions: function() {
  18. var elem = this.element,
  19. options = {};
  20. $.each( this.options, function( option ) {
  21. var value = elem.jqmData( option.replace( /[A-Z]/g, function( c ) {
  22. return "-" + c.toLowerCase();
  23. })
  24. );
  25. if ( value !== undefined ) {
  26. options[ option ] = value;
  27. }
  28. });
  29. return options;
  30. },
  31. enhanceWithin: function( target ) {
  32. // TODO remove dependency on the page widget for the keepNative.
  33. // Currently the keepNative value is defined on the page prototype so
  34. // the method is as well
  35. var page = $.mobile.closestPageData( $(target) ),
  36. keepNative = (page && page.keepNativeSelector()) || "";
  37. $( this.options.initSelector, target ).not( keepNative )[ this.widgetName ]();
  38. }
  39. });
  40. })( jQuery );
  41. //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
  42. });
  43. //>>excludeEnd("jqmBuildExclude");