Permalink
Browse files

Added //>>css comments to express CSS dependencies

  • Loading branch information...
1 parent 27934fe commit e88fd481db010948b8d1189088abf01a8f395333 @gseguin gseguin committed Mar 14, 2012
@@ -1,244 +1,74 @@
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
-//>>description: For making button-like links.
-//>>label: Buttons
+//>>description: Widget factory extentions for mobile.
+//>>label: Widget Factory Extensions
+//>>css: ../css/themes/default/jquery.mobile.theme.css
-define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.vmouse" ], function( $ ) {
+define( [ "jquery", "../external/requirejs/depend!./jquery.ui.widget[jquery]" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
-( function( $, undefined ) {
-
-$.fn.buttonMarkup = function( options ) {
- var $workingSet = this;
-
- // Enforce options to be of type string
- options = ( options && ( $.type( options ) == "object" ) )? options : {};
- for ( var i = 0; i < $workingSet.length; i++ ) {
- var el = $workingSet.eq( i ),
- e = el[ 0 ],
- o = $.extend( {}, $.fn.buttonMarkup.defaults, {
- icon: options.icon !== undefined ? options.icon : el.jqmData( "icon" ),
- iconpos: options.iconpos !== undefined ? options.iconpos : el.jqmData( "iconpos" ),
- theme: options.theme !== undefined ? options.theme : el.jqmData( "theme" ) || $.mobile.getInheritedTheme( el, "c" ),
- inline: options.inline !== undefined ? options.inline : el.jqmData( "inline" ),
- shadow: options.shadow !== undefined ? options.shadow : el.jqmData( "shadow" ),
- corners: options.corners !== undefined ? options.corners : el.jqmData( "corners" ),
- iconshadow: options.iconshadow !== undefined ? options.iconshadow : el.jqmData( "iconshadow" ),
- mini: options.mini !== undefined ? options.mini : el.jqmData( "mini" )
- }, options ),
-
- // Classes Defined
- innerClass = "ui-btn-inner",
- textClass = "ui-btn-text",
- buttonClass, iconClass,
- // Button inner markup
- buttonInner,
- buttonText,
- buttonIcon,
- buttonElements;
-
- $.each(o, function(key, value) {
- e.setAttribute( "data-" + $.mobile.ns + key, value );
- el.jqmData(key, value);
- });
+(function( $, undefined ) {
- // Check if this element is already enhanced
- buttonElements = $.data(((e.tagName === "INPUT" || e.tagName === "BUTTON") ? e.parentNode : e), "buttonElements");
-
- if (buttonElements) {
- e = buttonElements.outer;
- el = $(e);
- buttonInner = buttonElements.inner;
- buttonText = buttonElements.text;
- // We will recreate this icon below
- $(buttonElements.icon).remove();
- buttonElements.icon = null;
- }
- else {
- buttonInner = document.createElement( o.wrapperEls );
- buttonText = document.createElement( o.wrapperEls );
- }
- buttonIcon = o.icon ? document.createElement( "span" ) : null;
+$.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' );
+ },
- if ( attachEvents && !buttonElements) {
- attachEvents();
- }
-
- // if not, try to find closest theme container
- if ( !o.theme ) {
- o.theme = $.mobile.getInheritedTheme( el, "c" );
- }
-
- buttonClass = "ui-btn ui-btn-up-" + o.theme;
- buttonClass += o.inline ? " ui-btn-inline" : "";
- buttonClass += o.shadow ? " ui-shadow" : "";
- buttonClass += o.corners ? " ui-btn-corner-all" : "";
-
- if ( o.mini !== undefined ) {
- // Used to control styling in headers/footers, where buttons default to `mini` style.
- buttonClass += o.mini ? " ui-mini" : " ui-fullsize";
- }
-
- if ( o.icon ) {
- o.icon = "ui-icon-" + o.icon;
- o.iconpos = o.iconpos || "left";
+ _getCreateOptions: function() {
- iconClass = "ui-icon " + o.icon;
+ var elem = this.element,
+ options = {};
- if ( o.iconshadow ) {
- iconClass += " ui-icon-shadow";
- }
- }
+ $.each( this.options, function( option ) {
- if ( o.iconpos ) {
- buttonClass += " ui-btn-icon-" + o.iconpos;
+ var value = elem.jqmData( option.replace( /[A-Z]/g, function( c ) {
+ return "-" + c.toLowerCase();
+ })
+ );
- if ( o.iconpos == "notext" && !el.attr( "title" ) ) {
- el.attr( "title", el.getEncodedText() );
+ if ( value !== undefined ) {
+ options[ option ] = value;
}
- }
-
- innerClass += o.corners ? " ui-btn-corner-all" : "";
-
- if ( o.iconpos && o.iconpos === "notext" && !el.attr( "title" ) ) {
- el.attr( "title", el.getEncodedText() );
- }
-
- if ( buttonElements ) {
- el.removeClass( buttonElements.bcls || "" );
- }
- el.removeClass( "ui-link" ).addClass( buttonClass );
+ });
- buttonInner.className = innerClass;
+ return options;
+ },
- buttonText.className = textClass;
- if ( !buttonElements ) {
- buttonInner.appendChild( buttonText );
- }
- if ( buttonIcon ) {
- buttonIcon.className = iconClass;
- if ( !(buttonElements && buttonElements.icon) ) {
- buttonInner.appendChild( buttonIcon );
- }
- }
+ enhanceWithin: function( target, useKeepNative ) {
+ this.enhance( $( this.options.initSelector, $( target )), useKeepNative );
+ },
- while ( e.firstChild && !buttonElements) {
- buttonText.appendChild( e.firstChild );
- }
+ enhance: function( targets, useKeepNative ) {
+ var page, keepNative, $widgetElements = $( targets ), self = this;
- if ( !buttonElements ) {
- e.appendChild( buttonInner );
- }
+ // if ignoreContentEnabled is set to true the framework should
+ // only enhance the selected elements when they do NOT have a
+ // parent with the data-namespace-ignore attribute
+ $widgetElements = $.mobile.enhanceable( $widgetElements );
- // Assign a structure containing the elements of this button to the elements of this button. This
- // will allow us to recognize this as an already-enhanced button in future calls to buttonMarkup().
- buttonElements = {
- bcls : buttonClass,
- outer : e,
- inner : buttonInner,
- text : buttonText,
- icon : buttonIcon
- };
-
- $.data(e, 'buttonElements', buttonElements);
- $.data(buttonInner, 'buttonElements', buttonElements);
- $.data(buttonText, 'buttonElements', buttonElements);
- if (buttonIcon) {
- $.data(buttonIcon, 'buttonElements', buttonElements);
- }
- }
+ if ( useKeepNative && $widgetElements.length ) {
+ // 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
+ page = $.mobile.closestPageData( $widgetElements );
+ keepNative = (page && page.keepNativeSelector()) || "";
- return this;
-};
-
-$.fn.buttonMarkup.defaults = {
- corners: true,
- shadow: true,
- iconshadow: true,
- inline: false,
- wrapperEls: "span"
-};
-
-function closestEnabledButton( element ) {
- var cname;
-
- while ( element ) {
- // Note that we check for typeof className below because the element we
- // handed could be in an SVG DOM where className on SVG elements is defined to
- // be of a different type (SVGAnimatedString). We only operate on HTML DOM
- // elements, so we look for plain "string".
- cname = ( typeof element.className === 'string' ) && (element.className + ' ');
- if ( cname && cname.indexOf("ui-btn ") > -1 && cname.indexOf("ui-disabled ") < 0 ) {
- break;
- }
-
- element = element.parentNode;
- }
-
- return element;
-}
-
-var attachEvents = function() {
- var hoverDelay = 200,
- hov, foc;
- $( document ).bind( {
- "vmousedown vmousecancel vmouseup vmouseover vmouseout focus blur scrollstart": function( event ) {
- var theme,
- $btn = $( closestEnabledButton( event.target ) ),
- evt = event.type;
-
- if ( $btn.length ) {
- theme = $btn.attr( "data-" + $.mobile.ns + "theme" );
-
- if ( evt === "vmousedown" ) {
- if ( $.support.touch ) {
- hov = setTimeout(function() {
- $btn.removeClass( "ui-btn-up-" + theme ).addClass( "ui-btn-down-" + theme );
- }, hoverDelay );
- } else {
- $btn.removeClass( "ui-btn-up-" + theme ).addClass( "ui-btn-down-" + theme );
- }
- } else if ( evt === "vmousecancel" || evt === "vmouseup" ) {
- $btn.removeClass( "ui-btn-down-" + theme ).addClass( "ui-btn-up-" + theme );
- } else if ( evt === "vmouseover" || evt === "focus" ) {
- if ( $.support.touch ) {
- foc = setTimeout(function() {
- $btn.removeClass( "ui-btn-up-" + theme ).addClass( "ui-btn-hover-" + theme );
- }, hoverDelay );
- } else {
- $btn.removeClass( "ui-btn-up-" + theme ).addClass( "ui-btn-hover-" + theme );
- }
- } else if ( evt === "vmouseout" || evt === "blur" || evt === "scrollstart" ) {
- $btn.removeClass( "ui-btn-hover-" + theme + " ui-btn-down-" + theme ).addClass( "ui-btn-up-" + theme );
- if ( hov ) {
- clearTimeout( hov );
- }
- if ( foc ) {
- clearTimeout( foc );
- }
- }
- }
- },
- "focusin focus": function( event ){
- $( closestEnabledButton( event.target ) ).addClass( $.mobile.focusClass );
- },
- "focusout blur": function( event ){
- $( closestEnabledButton( event.target ) ).removeClass( $.mobile.focusClass );
+ $widgetElements = $widgetElements.not( keepNative );
}
- });
- attachEvents = null;
-};
+ $widgetElements[ this.widgetName ]();
+ },
-//links in bars, or those with data-role become buttons
-//auto self-init widgets
-$( document ).bind( "pagecreate create", function( e ){
-
- $( ":jqmData(role='button'), .ui-bar > a, .ui-header > a, .ui-footer > a, .ui-bar > :jqmData(role='controlgroup') > a", e.target )
- .not( ".ui-btn, :jqmData(role='none'), :jqmData(role='nojs')" )
- .buttonMarkup();
+ raise: function( msg ) {
+ throw "Widget [" + this.widgetName + "]: " + msg;
+ }
});
})( jQuery );
-
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
});
//>>excludeEnd("jqmBuildExclude");
@@ -1,6 +1,8 @@
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
//>>description: Creates collapsible content areas.
//>>label: Collapsibles
+//>>css: ../css/themes/default/jquery.mobile.theme.css,../css/structure/jquery.mobile.collapsible.css
+
define( [ "jquery", "./jquery.mobile.widget", "./jquery.mobile.buttonMarkup" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) {
@@ -1,6 +1,7 @@
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
//>>description: For creating grouped collapsible content areas.
//>>label: Collapsible Sets
+//>>css: ../css/themes/default/jquery.mobile.theme.css,../css/structure/jquery.mobile.collapsible.css
define( [ "jquery", "./jquery.mobile.widget", "./jquery.mobile.collapsible" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
@@ -1,6 +1,7 @@
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
//>>description: Corner-rounding for groups of buttons, checks, radios, etc
//>>label: Controlgroups
+//>>css: ../css/themes/default/jquery.mobile.theme.css,../css/structure/jquery.mobile.controlgroup.css
define( [ "jquery", "./jquery.mobile.buttonMarkup" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
@@ -1,6 +1,7 @@
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
//>>description: Degrades inputs to another type after custom enhancements are made.
//>>label: Dialog-style Pages
+//>>css: ../css/themes/default/jquery.mobile.theme.css,../css/structure/jquery.mobile.dialog.css
define( [ "jquery", "./jquery.mobile.widget" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
@@ -1,6 +1,7 @@
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
//>>description: Simple class additions to make form row separators
//>>label: Fieldcontains
+//>>css: ../css/themes/default/jquery.mobile.theme.css,../css/structure/jquery.mobile.forms.fieldcontain.css
define( [ "jquery" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
@@ -1,6 +1,7 @@
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
//>>description: Behavior for "fixed" headers and footers
//>>label: Fixedtoolbar
+//>>css: ../css/themes/default/jquery.mobile.theme.css,../css/structure/jquery.mobile.fixedToolbar.css
define( [ "jquery", "./jquery.mobile.widget", "./jquery.mobile.core", "./jquery.mobile.navigation", "./jquery.mobile.page", "./jquery.mobile.page.sections", "./jquery.mobile.zoom" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
@@ -2,6 +2,7 @@
//>>description: Form Buttons
//>>label: links that proxy to native input/buttons
//>>group: forms
+//>>css: ../css/themes/default/jquery.mobile.theme.css,../css/structure/jquery.mobile.button.css
define( [ "jquery", "./jquery.mobile.widget", "./jquery.mobile.buttonMarkup" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
@@ -6,6 +6,7 @@
//>>description: Consistent styling for checkboxes/radio buttons.
//>>label: Checkboxes/Radio Buttons
//>>group: forms
+//>>css: ../css/themes/default/jquery.mobile.theme.css,../css/structure/jquery.mobile.forms.checkboxradio.css
define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.widget", "./jquery.mobile.buttonMarkup" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
@@ -6,6 +6,7 @@
//>>description: Fully-custom select menus.
//>>label: Custom Selects
//>>group: forms
+//>>css: ../css/themes/default/jquery.mobile.theme.css, ../css/structure/jquery.mobile.forms.select.css
define( [
"jquery",
@@ -2,6 +2,7 @@
//>>description: Consistent styling for native select menus.
//>>label: Enhanced Native Selects
//>>group: forms
+//>>css: ../css/themes/default/jquery.mobile.theme.css, ../css/structure/jquery.mobile.forms.select.css
define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.widget", "./jquery.mobile.buttonMarkup", "./jquery.mobile.zoom" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
@@ -2,6 +2,7 @@
//>>description: Slider form widget
//>>label: Slider
//>>group: forms
+//>>css: ../css/themes/default/jquery.mobile.theme.css, ../css/structure/jquery.mobile.forms.slider.css
define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.widget", "./jquery.mobile.forms.textinput", "./jquery.mobile.buttonMarkup" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
@@ -2,6 +2,7 @@
//>>description: Enhances and consistently styles text inputs.
//>>label: Text Inputs
//>>group: forms
+//>>css: ../css/themes/default/jquery.mobile.theme.css, ../css/structure/jquery.mobile.forms.textinput.css
define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.widget", "./jquery.mobile.degradeInputs", "./jquery.mobile.buttonMarkup", "./jquery.mobile.zoom" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
View
@@ -1,6 +1,7 @@
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
//>>description: Applies classes for grid styling.
//>>label: CSS Grid Tool
+//>>css: ../css/themes/default/jquery.mobile.theme.css, ../css/structure/jquery.mobile.grid.css
define( [ "jquery" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
Oops, something went wrong.

0 comments on commit e88fd48

Please sign in to comment.