Merge branch 'master' into fastclick

Conflicts resolved:
	js/jquery.mobile.forms.select.js
This commit is contained in:
Kin Blas 2011-03-18 09:15:01 -07:00
commit 7f8438e966
17 changed files with 251 additions and 84 deletions

View file

@ -20,10 +20,16 @@
<div data-role="content">
<h2>Form submission</h2>
<h2>Ajax form submission</h2>
<p>In jQuery Mobile, form submissions are automatically handled using Ajax whenever possible, creating a smooth transition between the form and the result page. To ensure your form submits as intended, be sure to specify <code>action</code> and <code>method</code> properties on your form element.</p>
<p>This page demonstrates automated ajax handling of form submissions. The form below is configured to send regular a <code>get</code> request to <code>forms-sample-response.php</code>. On submit, jQuery Mobile will make sure that the Url specified is able to be retrieved via Ajax, and handle it appropriately. Keep in mind that just like ordinary HTTP form submissions, jQuery Mobile allows <code>get</code> result pages to be bookmarked by updating the Url hash when the response returns successfully. Also like ordinary form submissions, <code>post</code> requests do not contain query parameters in the hash, so they are not bookmarkable.</p>
<h2>Non-Ajax handling</h2>
<p>To prevent form submissions from being automatically handled with Ajax, add the <code>data-ajax="false"</code> attribute to the form element. You can also turn of Ajax form handling completely via the <code>ajaxFormsEnabled</code> <a href="../api/globalconfig.html">global config option</a>.</p>
<h2>Simple Ajax form example</h2>
<p>This page demonstrates automated ajax handling of form submissions. The form below is configured to send regular a <code>get</code> request to <code>forms-sample-response.php</code>. On submit, jQuery Mobile will make sure that the Url specified is able to be retrieved via Ajax, and handle it appropriately. Keep in mind that just like ordinary HTTP form submissions, jQuery Mobile allows <code>get</code> result pages to be bookmarked by updating the Url hash when the response returns successfully. Also like ordinary form submissions, <code>post</code> requests do not contain query parameters in the hash, so they are not bookmarkable.</p>
<form action="forms-sample-response.php" method="get">
<fieldset>
<div data-role="fieldcontain">

View file

@ -35,6 +35,7 @@
<li><a href="lists-icons.html">Icons</a></li>
<li><a href="lists-formatting.html">Content formatting</a></li>
<li><a href="lists-search.html">Search filter bar</a></li>
<li><a href="lists-search-inset.html">Inset search filter bar</a></li>
<li><a href="lists-search-with-dividers.html">Search filter bar with dividers</a></li>
<li><a href="lists-inset.html">Inset styled lists</a></li>
<li><a href="lists-performance.html">List performance test</a></li>

View file

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1">
<title>jQuery Mobile Docs - Lists</title>
<link rel="stylesheet" href="../../themes/default/" />
<link rel="stylesheet" href="../_assets/css/jqm-docs.css"/>
<script type="text/javascript" src="../../js/jquery.js"></script>
<script type="text/javascript" src="../../js/"></script>
<script type="text/javascript" src="docs/docs.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header" data-theme="b">
<h1>Inset Search filter bar</h1>
<a href="../../" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
</div><!-- /header -->
<div data-role="content">
<ul data-role="listview" data-filter="true" data-inset="true">
<li><a href="index.html">Acura</a></li>
<li><a href="index.html">Audi</a></li>
<li><a href="index.html">BMW</a></li>
<li><a href="index.html">Cadillac</a></li>
<li><a href="index.html">Chrysler</a></li>
<li><a href="index.html">Dodge</a></li>
<li><a href="index.html">Ferrari</a></li>
<li><a href="index.html">Ford</a></li>
<li><a href="index.html">GMC</a></li>
<li><a href="index.html">Honda</a></li>
<li><a href="index.html">Hyundai</a></li>
<li><a href="index.html">Infiniti</a></li>
<li><a href="index.html">Jeep</a></li>
<li><a href="index.html">Kia</a></li>
<li><a href="index.html">Lexus</a></li>
<li><a href="index.html">Mini</a></li>
<li><a href="index.html">Nissan</a></li>
<li><a href="index.html">Porsche</a></li>
<li><a href="index.html">Subaru</a></li>
<li><a href="index.html">Toyota</a></li>
<li><a href="index.html">Volkswagon</a></li>
<li><a href="index.html">Volvo</a></li>
</ul>
</div><!-- /content -->
</div><!-- /page -->
</body>
</html>

View file

@ -106,6 +106,16 @@
</div><!-- /navbar -->
</div><!-- /footer -->
<p>As a fallback, navbars with 1 item will simply render as 100%.</p>
<div data-role="footer">
<div data-role="navbar">
<ul>
<li><a href="#" class="ui-btn-active">One</a></li>
</ul>
</div><!-- /navbar -->
</div><!-- /footer -->
<h2>Navbars in headers</h2>
<p>If you want to add a navbar to the top of the page, you can still have a page title and buttons. Just add the navbar container inside the header block, right after the title and buttons in the source order.</p>

View file

@ -264,22 +264,10 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
});
//events on "screen" overlay + close button
screen
.add( headerClose )
.add( menuPageClose )
.bind("vclick", function(event){
self.close();
event.preventDefault();
// if the dialog's close icon was clicked, prevent the dialog's close
// handler from firing. selectmenu's should take precedence
if( $.contains(menuPageClose[0], event.target) ){
event.stopImmediatePropagation();
}
});
screen.bind("vclick", function( event ){
self.close();
});
}
},
_buildList: function(){
@ -359,7 +347,7 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
return options.index( this );
}).get();
if( !self.options.nativeMenu && ( forceRebuild || select[0].options.length > self.list.find('li').length )){
if( !self.options.nativeMenu && ( forceRebuild || select[0].options.length != self.list.find('li').length )){
self._buildList();
}
@ -415,6 +403,11 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
//add active class to button
self.button.addClass( $.mobile.activeBtnClass );
//remove after delay
setTimeout(function(){
self.button.removeClass( $.mobile.activeBtnClass );
}, 300);
function focusMenuItem(){
self.list.find( ".ui-btn-active" ).focus();
@ -504,9 +497,6 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
function focusButton(){
setTimeout(function(){
self.button.focus();
//remove active class from button
self.button.removeClass( $.mobile.activeBtnClass );
}, 40);
self.listbox.removeAttr('style').append( self.list );

View file

@ -13,7 +13,7 @@ $.fn.grid = function(options){
var $kids = $(this).children(),
gridCols = {a: 2, b:3, c:4, d:5},
gridCols = {solo:1, a:2, b:3, c:4, d:5},
grid = o.grid,
iterator;
@ -32,12 +32,13 @@ $.fn.grid = function(options){
$(this).addClass('ui-grid-' + grid);
$kids.filter(':nth-child(' + iterator + 'n+1)').addClass('ui-block-a');
$kids.filter(':nth-child(' + iterator + 'n+2)').addClass('ui-block-b');
if(iterator > 1){
$kids.filter(':nth-child(' + iterator + 'n+2)').addClass('ui-block-b');
}
if(iterator > 2){
$kids.filter(':nth-child(3n+3)').addClass('ui-block-c');
}
if(iterator> 3){
if(iterator > 3){
$kids.filter(':nth-child(4n+4)').addClass('ui-block-d');
}
if(iterator > 4){
@ -46,5 +47,4 @@ $.fn.grid = function(options){
});
};
})(jQuery);
})(jQuery);

View file

@ -51,6 +51,10 @@ $( "[data-role='listview']" ).live( "listviewcreate", function() {
.appendTo( wrapper )
.textinput();
if ($( this ).data( "inset" ) ) {
wrapper.addClass( "ui-listview-filter-inset" );
}
wrapper.insertBefore( list );
});

View file

@ -384,9 +384,9 @@
//set as data for returning to that spot
from.data( "lastScroll", currScroll);
//trigger before show/hide events
from.data( "page" )._trigger( "beforehide", { nextPage: to } );
from.data( "page" )._trigger( "beforehide", null, { nextPage: to } );
}
to.data( "page" )._trigger( "beforeshow", { prevPage: from || $("") } );
to.data( "page" )._trigger( "beforeshow", null, { prevPage: from || $("") } );
function loadComplete(){
@ -612,10 +612,11 @@
/* Event Bindings - hashchange, submit, and click */
//bind to form submit events, handle with Ajax
$( "form[data-ajax!='false']" ).live('submit', function(event){
$( "form" ).live('submit', function(event){
if( !$.mobile.ajaxEnabled ||
//TODO: deprecated - remove at 1.0
!$.mobile.ajaxFormsEnabled ){ return; }
!$.mobile.ajaxFormsEnabled ||
$(this).is( "[data-ajax='false']" ) ){ return; }
var type = $(this).attr("method"),
url = path.clean( $(this).attr( "action" ) );
@ -632,7 +633,7 @@
$.mobile.changePage({
url: url,
type: type,
type: type || "get",
data: $(this).serialize()
},
undefined,
@ -697,7 +698,7 @@
// TODO: deprecated - remove at 1.0
!$.mobile.ajaxLinksEnabled ){
//remove active link class if external (then it won't be there if you come back)
removeActiveLinkClass(true);
window.setTimeout(function() {removeActiveLinkClass(true);}, 200);
//deliberately redirect, in case click was triggered
if( hasTarget ){

View file

@ -139,8 +139,10 @@ $.widget( "mobile.page", $.mobile.widget, {
$elem.fixHeaderFooter();
},
_typeAttributeRegex: /\s+type=["']?\w+['"]?/,
_enhanceControls: function() {
var o = this.options;
var o = this.options, self = this;
// degrade inputs to avoid poorly implemented native functionality
this.element.find( "input" ).not(this.keepNative).each(function() {
@ -150,7 +152,7 @@ $.widget( "mobile.page", $.mobile.widget, {
if ( o.degradeInputs[ type ] ) {
$( this ).replaceWith(
$( "<div>" ).html( $(this).clone() ).html()
.replace( / type="?([a-zA-Z]+)"?/, " type=\""+ optType +"\" data-type=\""+type+"\" " ) );
.replace( self._typeAttributeRegex, " type=\""+ optType +"\" data-type=\""+type+"\" " ) );
}
});

View file

@ -0,0 +1,65 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>jQuery Mobile: Grid Layout</title>
<link rel="stylesheet" href="../../themes/default/" />
<link rel="stylesheet" href="../../docs/_assets/css/jqm-docs.css" />
<script type="text/javascript" src="../../js/jquery.js"></script>
<script type="text/javascript" src="../../js/"></script>
<script>
$(function(){
$(".ui-grid-d a").bind("tap", function(e){
$(this).hide();
$("#log")
.prepend("<li>"+ e.type +" event; target: "+ e.target.nodeName +"; message: grid '"+$(this).text()+"' hidden</li>")
.listview("refresh");
return false;
}).bind("click", false);
$("#showbtn").bind("tap", function(e){
$(".ui-grid-d a").show();
$("#log")
.prepend("<li>"+ e.type +" event; target: "+ e.target.nodeName +"; message: show all buttons</li>")
.listview("refresh");
}).bind("click", false);
});
</script>
</head>
<body>
<div data-role="page" data-theme="b" id="jqm-home">
<div data-role="header">
<h1>Grid Layout</h1>
</div>
<div data-role="content">
<p>Touch events on this page will log out below, prepending to the top as they arrive.</p>
<div class="ui-grid-d">
<div class="ui-block-a">
<a data-role="button" id="btn1" data-theme="b">Button 1</a>
</div>
<div class="ui-block-b">
<a data-role="button" id="btn2" data-theme="b">Button 2</a>
</div>
<div class="ui-block-c">
<a data-role="button" id="btn3" data-theme="b">Button 3</a>
</div>
<div class="ui-block-d">
<a data-role="button" id="btn4" data-theme="b">Button 4</a>
</div>
<div class="ui-block-e">
<a data-role="button" id="btn5" data-theme="b">Button 5</a>
</div>
</div>
<a data-role="button" id="showbtn">Show all button</a>
<ul data-role="listview" id="log">
</ul>
</div>
</div>
</body>
</html>

View file

@ -1,32 +1,48 @@
/*
* mobile page unit tests
*/
module('jquery.mobile.page.js');
(function($){
var libName = 'jquery.mobile.page.js',
typeAttributeRegex = $.mobile.page.prototype._typeAttributeRegex;
test( "nested header anchors aren't altered", function(){
ok(!$('.ui-header > div > a').hasClass('ui-btn'));
});
module(libName);
test( "nested footer anchors aren't altered", function(){
ok(!$('.ui-footer > div > a').hasClass('ui-btn'));
});
test( "nested header anchors aren't altered", function(){
ok(!$('.ui-header > div > a').hasClass('ui-btn'));
});
test( "nested bar anchors aren't styled", function(){
ok(!$('.ui-bar > div > a').hasClass('ui-btn'));
});
test( "nested footer anchors aren't altered", function(){
ok(!$('.ui-footer > div > a').hasClass('ui-btn'));
});
test( "unnested footer anchors are styled", function(){
ok($('.ui-footer > a').hasClass('ui-btn'));
});
test( "nested bar anchors aren't styled", function(){
ok(!$('.ui-bar > div > a').hasClass('ui-btn'));
});
test( "unnested footer anchors are styled", function(){
ok($('.ui-footer > a').hasClass('ui-btn'));
});
test( "unnested footer anchors are styled", function(){
ok($('.ui-footer > a').hasClass('ui-btn'));
});
test( "unnested bar anchors are styled", function(){
ok($('.ui-bar > a').hasClass('ui-btn'));
});
test( "unnested footer anchors are styled", function(){
ok($('.ui-footer > a').hasClass('ui-btn'));
});
test( "no auto-generated back button exists on first page", function(){
ok( !$('.ui-header > [data-rel="back"]').length );
});
test( "unnested bar anchors are styled", function(){
ok($('.ui-bar > a').hasClass('ui-btn'));
});
test( "no auto-generated back button exists on first page", function(){
ok( !$('.ui-header > [data-rel="back"]').length );
});
test( "input type replacement regex works properly", function(){
ok(typeAttributeRegex.test( "<input type=range" ), "test no quotes" );
ok(typeAttributeRegex.test( "<input type='range'" ), "test single quotes" );
ok(typeAttributeRegex.test( "<input type=\"range\"" ), "test double quotes" );
ok(typeAttributeRegex.test( "<input type=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_"), "test \w" );
ok(typeAttributeRegex.test( "<input type=\"range\"" ), "test many preceding spaces" );
ok(typeAttributeRegex.test( "<input type='range'>" ), "test final attribute (FF)" );
ok(!typeAttributeRegex.test( "<inputtype=\"range\"" ), "requires preceding space" );
});
})(jQuery);

View file

@ -6,7 +6,7 @@
.ui-select { display: block; position: relative; }
.ui-select select { position: absolute; left: -9999px; top: -9999px; }
.ui-select .ui-btn { overflow: hidden; }
.ui-select .ui-btn select { cursor: pointer; -webkit-appearance: button; left: 0; top:0; width: 100%; height: 100%; opacity: 0.001; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter: alpha(opacity=0); }
.ui-select .ui-btn select { cursor: pointer; -webkit-appearance: button; left: 0; top:0; width: 100%; height: 100%; opacity: 0; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter: alpha(opacity=0); }
.ui-select .ui-btn select.ui-select-nativeonly { opacity: 1; }
.ui-select .ui-btn-icon-right .ui-btn-inner { padding-right: 45px; }
@ -27,9 +27,10 @@ label.ui-select { font-size: 16px; line-height: 1.4; font-weight: normal; margi
.ui-screen-hidden, .ui-selectmenu-list .ui-li .ui-icon { display: none; }
.ui-selectmenu-list .ui-li .ui-icon { display: block; }
.ui-li.ui-selectmenu-placeholder { display: none; }
.ui-selectmenu .ui-header .ui-title { margin: 0.6em 46px 0.8em; }
.min-width-480px label.ui-select { display: inline-block; width: 20%; margin: 0 2% 0 0; }
.min-width-480px .ui-select { width: 60%; display: inline-block; }
/* when no placeholder is defined in a multiple select, the header height doesn't even extend past the close button. this shim's content in there */
.ui-selectmenu .ui-header h1:after { content: '.'; visibility: hidden; }
.ui-selectmenu .ui-header h1:after { content: '.'; visibility: hidden; }

View file

@ -18,4 +18,5 @@ textarea.ui-input-text { height: 50px; -webkit-transition: height 200ms linear;
.min-width-480px input.ui-input-text,
.min-width-480px textarea.ui-input-text,
.min-width-480px .ui-input-search { width: 60%; display: inline-block; }
.min-width-480px .ui-input-search { width: 50%; }
.min-width-480px .ui-input-search { width: 50%; }
.min-width-480px .ui-input-search input.ui-input-text { width: 98%; /*echos rule from above*/ }

View file

@ -6,7 +6,10 @@
/* content configurations. */
.ui-grid-a, .ui-grid-b, .ui-grid-c, .ui-grid-d { overflow: hidden; }
.ui-block-a, .ui-block-b, .ui-block-c, .ui-block-d, .ui-block-e { margin: 0; padding: 0; border: 0; float: left; }
.ui-block-a, .ui-block-b, .ui-block-c, .ui-block-d, .ui-block-e { margin: 0; padding: 0; border: 0; float: left; min-height:1px;}
/* grid solo: 100 - single item fallback */
.ui-grid-solo .ui-block-a { width: 100%; float: none; }
/* grid a: 50/50 */
.ui-grid-a .ui-block-a, .ui-grid-a .ui-block-b { width: 50%; }
@ -22,4 +25,4 @@
/* grid d: 20/20/20/20/20 */
.ui-grid-d .ui-block-a, .ui-grid-d .ui-block-b, .ui-grid-d .ui-block-c, .ui-grid-d .ui-block-d, .ui-grid-d .ui-block-e { width: 20%; }
.ui-grid-d .ui-block-a { clear: left; }
.ui-grid-d .ui-block-a { clear: left; }

View file

@ -37,6 +37,8 @@ ol.ui-listview .ui-li-jsnumbering:before { content: "" !important; } /* to avoid
.ui-listview-filter { border-width: 0; overflow: hidden; margin: -15px -15px 15px -15px }
.ui-listview-filter .ui-input-search { margin: 5px; width: auto; display: block; }
.ui-listview-filter-inset { margin: -15px -5px -15px -5px; background: transparent; }
/* Odd iPad positioning issue. */
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
.ui-li .ui-btn-text { overflow: visible; }

View file

@ -76,7 +76,6 @@
background: #333333;
font-weight: bold;
color: #fff;
cursor: pointer;
text-shadow: 0 -1px 1px #000;
text-decoration: none;
background-image: -moz-linear-gradient(top,
@ -197,7 +196,6 @@
background: #2567ab;
font-weight: bold;
color: #fff;
cursor: pointer;
text-shadow: 0 -1px 1px #145072;
text-decoration: none;
background-image: -moz-linear-gradient(top,
@ -310,7 +308,6 @@
background: #eee;
font-weight: bold;
color: #444;
cursor: pointer;
text-shadow: 0 1px 1px #f6f6f6;
text-decoration: none;
background-image: -moz-linear-gradient(top,
@ -544,7 +541,6 @@
background: #fadb4e;
font-weight: bold;
color: #333;
cursor: pointer;
text-shadow: 0 1px 1px #fe3;
text-decoration: none;
text-shadow: 0 1px 0 #fff;
@ -734,7 +730,7 @@ a.ui-link-inherit {
/* Alt icon color
-----------------------------------------------------------------------------------------------------------*/
.ui-icon-black {
.ui-icon-alt {
background: #fff;
background: rgba(255,255,255,.3);
background-image: url(images/icons-18-black.png);
@ -744,14 +740,23 @@ a.ui-link-inherit {
/* HD/"retina" sprite
-----------------------------------------------------------------------------------------------------------*/
@media screen and (-webkit-min-device-pixel-ratio: 2), screen and (max--moz-device-pixel-ratio: 2) {
.ui-icon {
background-image: url(images/icons-36-white.png);
background-size: 630px 18px;
}
.ui-icon-black {
background-image: url(images/icons-36-black.png);
}
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (min--moz-device-pixel-ratio: 1.5),
only screen and (min-resolution: 240dpi) {
.ui-icon-plus, .ui-icon-minus, .ui-icon-delete, .ui-icon-arrow-r,
.ui-icon-arrow-l, .ui-icon-arrow-u, .ui-icon-arrow-d, .ui-icon-check,
.ui-icon-gear, .ui-icon-refresh, .ui-icon-forward, .ui-icon-back,
.ui-icon-grid, .ui-icon-star, .ui-icon-alert, .ui-icon-info, .ui-icon-home, .ui-icon-search {
background-image: url(images/icons-36-white.png);
-moz-background-size: 630px 18px;
-o-background-size: 630px 18px;
-webkit-background-size: 630px 18px;
background-size: 630px 18px;
}
.ui-icon-alt {
background-image: url(images/icons-36-black.png);
}
}
/* plus minus */

View file

@ -724,7 +724,7 @@ a.ui-link-inherit {
/* Alt icon color
-----------------------------------------------------------------------------------------------------------*/
.ui-icon-black {
.ui-icon-alt {
background: #fff;
background: rgba(255,255,255,.3);
background-image: url(images/icons-18-black.png);
@ -734,14 +734,23 @@ a.ui-link-inherit {
/* HD/"retina" sprite
-----------------------------------------------------------------------------------------------------------*/
@media screen and (-webkit-min-device-pixel-ratio: 2), screen and (max--moz-device-pixel-ratio: 2) {
.ui-icon {
background-image: url(images/icons-36-white.png);
background-size: 630px 18px;
}
.ui-icon-black {
background-image: url(images/icons-36-black.png);
}
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (min--moz-device-pixel-ratio: 1.5),
only screen and (min-resolution: 240dpi) {
.ui-icon-plus, .ui-icon-minus, .ui-icon-delete, .ui-icon-arrow-r,
.ui-icon-arrow-l, .ui-icon-arrow-u, .ui-icon-arrow-d, .ui-icon-check,
.ui-icon-gear, .ui-icon-refresh, .ui-icon-forward, .ui-icon-back,
.ui-icon-grid, .ui-icon-star, .ui-icon-alert, .ui-icon-info, .ui-icon-home, .ui-icon-search {
background-image: url(images/icons-36-white.png);
-moz-background-size: 630px 18px;
-o-background-size: 630px 18px;
-webkit-background-size: 630px 18px;
background-size: 630px 18px;
}
.ui-icon-alt {
background-image: url(images/icons-36-black.png);
}
}
/* plus minus */