mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-03-16 22:10:25 +00:00
- Internally, each plugin self-initializes by binding to the pagecreate event. - Unit tests have been added and adjusted to support some internal changes involved in this commit. - In the process, the portions of the page plugin that were used to enhance the header,content,and footer sections of a native-app style page layout are now located in jquery.mobile.page.sections.js. - No public API options have changed, except that the page plugin no longer has options for keepNative, and degradeInputs, as plugins now handle these internally (keepNative was never documented, and degradeInputs only affected slider, so it lives there now. Page options related to the page sections are now located in the page.sections script, but they are still configurable via the page plugin's options api. - Make, Ant, and index files are updated with a new load order for all JS files.
91 lines
No EOL
2 KiB
JavaScript
91 lines
No EOL
2 KiB
JavaScript
/*
|
|
* jQuery Mobile Framework : "button" plugin - links that proxy to native input/buttons
|
|
* Copyright (c) jQuery Project
|
|
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
* http://jquery.org/license
|
|
*/
|
|
|
|
(function( $, undefined ) {
|
|
|
|
//auto self-init widgets
|
|
$( document ).bind( "pagecreate", function( e ){
|
|
$( "button, [type='button'], [type='submit'], [type='reset'], [type='image']", e.target )
|
|
.not( ":jqmData(role='none'), :jqmData(role='nojs')" )
|
|
.button();
|
|
});
|
|
|
|
$.widget( "mobile.button", $.mobile.widget, {
|
|
options: {
|
|
theme: null,
|
|
icon: null,
|
|
iconpos: null,
|
|
inline: null,
|
|
corners: true,
|
|
shadow: true,
|
|
iconshadow: true
|
|
},
|
|
_create: function() {
|
|
var $el = this.element,
|
|
o = this.options,
|
|
type;
|
|
|
|
// Add ARIA role
|
|
this.button = $( "<div></div>" )
|
|
.text( $el.text() || $el.val() )
|
|
.buttonMarkup({
|
|
theme: o.theme,
|
|
icon: o.icon,
|
|
iconpos: o.iconpos,
|
|
inline: o.inline,
|
|
corners: o.corners,
|
|
shadow: o.shadow,
|
|
iconshadow: o.iconshadow
|
|
})
|
|
.insertBefore( $el )
|
|
.append( $el.addClass( "ui-btn-hidden" ) );
|
|
|
|
// Add hidden input during submit
|
|
type = $el.attr( "type" );
|
|
|
|
if ( type !== "button" && type !== "reset" ) {
|
|
|
|
$el.bind( "vclick", function() {
|
|
|
|
var $buttonPlaceholder = $( "<input>", {
|
|
type: "hidden",
|
|
name: $el.attr( "name" ),
|
|
value: $el.attr( "value" )
|
|
})
|
|
.insertBefore( $el );
|
|
|
|
// Bind to doc to remove after submit handling
|
|
$( document ).submit(function(){
|
|
$buttonPlaceholder.remove();
|
|
});
|
|
});
|
|
}
|
|
|
|
this.refresh();
|
|
},
|
|
|
|
enable: function() {
|
|
this.element.attr( "disabled", false );
|
|
this.button.removeClass( "ui-disabled" ).attr( "aria-disabled", false );
|
|
return this._setOption( "disabled", false );
|
|
},
|
|
|
|
disable: function() {
|
|
this.element.attr( "disabled", true );
|
|
this.button.addClass( "ui-disabled" ).attr( "aria-disabled", true );
|
|
return this._setOption( "disabled", true );
|
|
},
|
|
|
|
refresh: function() {
|
|
if ( this.element.attr( "disabled" ) ) {
|
|
this.disable();
|
|
} else {
|
|
this.enable();
|
|
}
|
|
}
|
|
});
|
|
})( jQuery ); |