jquery_mobile_rails 1.0rc1 → 1.0rc2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module JqueryMobileRails
2
- VERSION = "1.0rc1"
2
+ VERSION = "1.0rc2"
3
3
  end
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * jQuery Mobile v1.0rc1
2
+ * jQuery Mobile v1.0rc2
3
3
  * http://jquerymobile.com/
4
4
  *
5
5
  * Copyright 2010, jQuery Project
@@ -306,6 +306,16 @@ $.widget( "mobile.widget", {
306
306
  });
307
307
 
308
308
  return options;
309
+ },
310
+
311
+ enhanceWithin: function( target ) {
312
+ // TODO remove dependency on the page widget for the keepNative.
313
+ // Currently the keepNative value is defined on the page prototype so
314
+ // the method is as well
315
+ var page = $(target).data( "page" ),
316
+ keepNative = page && page.keepNativeSelector();
317
+
318
+ $( this.options.initSelector, target ).not( keepNative || "" )[ this.widgetName ]();
309
319
  }
310
320
  });
311
321
 
@@ -396,9 +406,9 @@ function baseTagTest() {
396
406
  href = base.attr( "href" );
397
407
  }
398
408
 
399
- link = $( "<a href='testurl'></a>" ).prependTo( fakeBody );
409
+ link = $( "<a href='testurl' />" ).prependTo( fakeBody );
400
410
  rebase = link[ 0 ].href;
401
- base[ 0 ].href = href ? href : location.pathname;
411
+ base[ 0 ].href = href || location.pathname;
402
412
 
403
413
  if ( fauxEle ) {
404
414
  fauxEle.remove();
@@ -422,7 +432,7 @@ $.mobile.browser.ie = (function() {
422
432
 
423
433
 
424
434
  $.extend( $.support, {
425
- orientation: "orientation" in window,
435
+ orientation: "orientation" in window && "onorientationchange" in window,
426
436
  touch: "ontouchend" in document,
427
437
  cssTransitions: "WebKitTransitionEvent" in window,
428
438
  pushState: "pushState" in history && "replaceState" in history,
@@ -465,7 +475,7 @@ $.mobile.ajaxBlacklist =
465
475
  // This simply reappends the CSS in place, which for some reason makes it apply
466
476
  if ( nokiaLTE7_3 ) {
467
477
  $(function() {
468
- $( "head link[rel=stylesheet]" ).attr( "rel", "alternate stylesheet" ).attr( "rel", "stylesheet" );
478
+ $( "head link[rel='stylesheet']" ).attr( "rel", "alternate stylesheet" ).attr( "rel", "stylesheet" );
469
479
  });
470
480
  }
471
481
 
@@ -474,7 +484,8 @@ if ( !$.support.boxShadow ) {
474
484
  $( "html" ).addClass( "ui-mobile-nosupport-boxshadow" );
475
485
  }
476
486
 
477
- })( jQuery );/*
487
+ })( jQuery );
488
+ /*
478
489
  * jQuery Mobile Framework : "mouse" plugin
479
490
  * Copyright (c) jQuery Project
480
491
  * Dual licensed under the MIT or GPL Version 2 licenses.
@@ -1092,11 +1103,11 @@ $.event.special.tap = {
1092
1103
  // also handles swipeleft, swiperight
1093
1104
  $.event.special.swipe = {
1094
1105
  scrollSupressionThreshold: 10, // More than this horizontal displacement, and we will suppress scrolling.
1095
-
1106
+
1096
1107
  durationThreshold: 1000, // More time than this, and it isn't a swipe.
1097
-
1108
+
1098
1109
  horizontalDistanceThreshold: 30, // Swipe horizontal displacement must be more than this.
1099
-
1110
+
1100
1111
  verticalDistanceThreshold: 75, // Swipe vertical displacement must be less than this.
1101
1112
 
1102
1113
  setup: function() {
@@ -1164,7 +1175,7 @@ $.event.special.swipe = {
1164
1175
  setup: function() {
1165
1176
  // If the event is supported natively, return false so that jQuery
1166
1177
  // will bind to the event using DOM methods.
1167
- if ( $.support.orientation ) {
1178
+ if ( $.support.orientation && $.mobile.orientationChangeEnabled ) {
1168
1179
  return false;
1169
1180
  }
1170
1181
 
@@ -1178,7 +1189,7 @@ $.event.special.swipe = {
1178
1189
  teardown: function(){
1179
1190
  // If the event is not supported natively, return false so that
1180
1191
  // jQuery will unbind the event using DOM methods.
1181
- if ( $.support.orientation ) {
1192
+ if ( $.support.orientation && $.mobile.orientationChangeEnabled ) {
1182
1193
  return false;
1183
1194
  }
1184
1195
 
@@ -1190,6 +1201,7 @@ $.event.special.swipe = {
1190
1201
  // Save a reference to the bound event handler.
1191
1202
  var old_handler = handleObj.handler;
1192
1203
 
1204
+
1193
1205
  handleObj.handler = function( event ) {
1194
1206
  // Modify event object, adding the .orientation property.
1195
1207
  event.orientation = get_orientation();
@@ -1216,8 +1228,22 @@ $.event.special.swipe = {
1216
1228
  // Get the current page orientation. This method is exposed publicly, should it
1217
1229
  // be needed, as jQuery.event.special.orientationchange.orientation()
1218
1230
  $.event.special.orientationchange.orientation = get_orientation = function() {
1219
- var elem = document.documentElement;
1220
- return elem && elem.clientWidth / elem.clientHeight < 1.1 ? "portrait" : "landscape";
1231
+ var isPortrait = true, elem = document.documentElement;
1232
+
1233
+ // prefer window orientation to the calculation based on screensize as
1234
+ // the actual screen resize takes place before or after the orientation change event
1235
+ // has been fired depending on implementation (eg android 2.3 is before, iphone after).
1236
+ // More testing is required to determine if a more reliable method of determining the new screensize
1237
+ // is possible when orientationchange is fired. (eg, use media queries + element + opacity)
1238
+ if ( $.support.orientation ) {
1239
+ // if the window orientation registers as 0 or 180 degrees report
1240
+ // portrait, otherwise landscape
1241
+ isPortrait = window.orientation % 180 == 0;
1242
+ } else {
1243
+ isPortrait = elem && elem.clientWidth / elem.clientHeight < 1.1;
1244
+ }
1245
+
1246
+ return isPortrait ? "portrait" : "landscape";
1221
1247
  };
1222
1248
 
1223
1249
  })( jQuery, window );
@@ -1679,7 +1705,8 @@ $.each({
1679
1705
  $.widget( "mobile.page", $.mobile.widget, {
1680
1706
  options: {
1681
1707
  theme: "c",
1682
- domCache: false
1708
+ domCache: false,
1709
+ keepNativeDefault: ":jqmData(role='none'), :jqmData(role='nojs')"
1683
1710
  },
1684
1711
 
1685
1712
  _create: function() {
@@ -1689,9 +1716,19 @@ $.widget( "mobile.page", $.mobile.widget, {
1689
1716
  this.element
1690
1717
  .attr( "tabindex", "0" )
1691
1718
  .addClass( "ui-page ui-body-" + this.options.theme );
1719
+ },
1720
+
1721
+ keepNativeSelector: function() {
1722
+ var options = this.options,
1723
+ keepNativeDefined = options.keepNative && $.trim(options.keepNative);
1724
+
1725
+ if( keepNativeDefined && options.keepNative !== options.keepNativeDefault ){
1726
+ return [options.keepNative, options.keepNativeDefault].join(", ");
1727
+ }
1728
+
1729
+ return options.keepNativeDefault;
1692
1730
  }
1693
1731
  });
1694
-
1695
1732
  })( jQuery );
1696
1733
  /*!
1697
1734
  * jQuery Mobile v@VERSION
@@ -1748,6 +1785,9 @@ $.widget( "mobile.page", $.mobile.widget, {
1748
1785
 
1749
1786
  pushStateEnabled: true,
1750
1787
 
1788
+ // turn of binding to the native orientationchange due to android orientation behavior
1789
+ orientationChangeEnabled: true,
1790
+
1751
1791
  // Support conditions that must be met in order to proceed
1752
1792
  // default enhanced qualifications are media query support OR IE 7+
1753
1793
  gradeA: function(){
@@ -1817,6 +1857,20 @@ $.widget( "mobile.page", $.mobile.widget, {
1817
1857
  }
1818
1858
 
1819
1859
  return $.camelCase( $.mobile.ns + prop );
1860
+ },
1861
+
1862
+ getInheritedTheme: function( el, defaultTheme ) {
1863
+ // Find the closest parent with a theme class on it.
1864
+ var themedParent = el.closest( "[class*='ui-bar-'],[class*='ui-body-']" ),
1865
+
1866
+ // If there's a themed parent, extract the theme letter
1867
+ // from the theme class .
1868
+ ltr = ( themedParent.length && /ui-(bar|body)-([a-z])\b/.exec( themedParent.attr( "class" ) )[ 2 ] || "" ) || "";
1869
+
1870
+ // Return the theme letter we found, if none, return the
1871
+ // specified default.
1872
+
1873
+ return ltr || defaultTheme || "a";
1820
1874
  }
1821
1875
  });
1822
1876
 
@@ -2030,7 +2084,7 @@ $.widget( "mobile.page", $.mobile.widget, {
2030
2084
  var relObj = path.parseUrl( relUrl ),
2031
2085
  absObj = path.parseUrl( absUrl ),
2032
2086
  protocol = relObj.protocol || absObj.protocol,
2033
- doubleSlash = relObj.protocol ? relObj.doubleSlash : ( relObj.doubleSlash || absObj.doubleSlash );
2087
+ doubleSlash = relObj.protocol ? relObj.doubleSlash : ( relObj.doubleSlash || absObj.doubleSlash ),
2034
2088
  authority = relObj.authority || absObj.authority,
2035
2089
  hasPath = relObj.pathname !== "",
2036
2090
  pathname = path.makePathAbsolute( relObj.pathname || absObj.filename, absObj.pathname ),
@@ -2633,14 +2687,14 @@ $.widget( "mobile.page", $.mobile.widget, {
2633
2687
  // reference to an embedded page. If so, it may have been dynamically
2634
2688
  // injected by a developer, in which case it would be lacking a data-url
2635
2689
  // attribute and in need of enhancement.
2636
- if ( page.length === 0 && !path.isPath( dataUrl ) ) {
2690
+ if ( page.length === 0 && dataUrl && !path.isPath( dataUrl ) ) {
2637
2691
  page = settings.pageContainer.children( "#" + dataUrl )
2638
2692
  .attr( "data-" + $.mobile.ns + "url", dataUrl )
2639
2693
  }
2640
2694
 
2641
2695
  // If we failed to find a page in the DOM, check the URL to see if it
2642
2696
  // refers to the first page in the application.
2643
- if ( page.length === 0 && $.mobile.firstPage && path.isFirstPageUrl( absUrl ) ) {
2697
+ if ( page.length === 0 && $.mobile.firstPage && path.isFirstPageUrl( fileUrl ) ) {
2644
2698
  page = $( $.mobile.firstPage );
2645
2699
  }
2646
2700
 
@@ -2913,6 +2967,14 @@ $.widget( "mobile.page", $.mobile.widget, {
2913
2967
  return;
2914
2968
  }
2915
2969
 
2970
+ // If we are going to the first-page of the application, we need to make
2971
+ // sure settings.dataUrl is set to the application document url. This allows
2972
+ // us to avoid generating a document url with an id hash in the case where the
2973
+ // first-page of the document has an id attribute specified.
2974
+ if ( toPage[ 0 ] === $.mobile.firstPage[ 0 ] && !settings.dataUrl ) {
2975
+ settings.dataUrl = documentUrl.hrefNoHash;
2976
+ }
2977
+
2916
2978
  // The caller passed us a real page DOM element. Update our
2917
2979
  // internal state and then trigger a transition to the page.
2918
2980
  var fromPage = settings.fromPage,
@@ -2986,11 +3048,16 @@ $.widget( "mobile.page", $.mobile.widget, {
2986
3048
  }
2987
3049
 
2988
3050
  //if title element wasn't found, try the page div data attr too
2989
- var newPageTitle = toPage.jqmData( "title" ) || toPage.children(":jqmData(role='header')").find(".ui-title" ).text();
3051
+ var newPageTitle = toPage.jqmData( "title" ) || toPage.children(":jqmData(role='header')").find(".ui-title" ).getEncodedText();
2990
3052
  if( !!newPageTitle && pageTitle == document.title ) {
2991
3053
  pageTitle = newPageTitle;
2992
3054
  }
2993
3055
 
3056
+ // Make sure we have a transition defined.
3057
+ settings.transition = settings.transition
3058
+ || ( ( historyDir && !activeIsInitialPage ) ? active.transition : undefined )
3059
+ || ( isDialog ? $.mobile.defaultDialogTransition : $.mobile.defaultPageTransition );
3060
+
2994
3061
  //add page to history stack if it's not back or forward
2995
3062
  if( !historyDir ) {
2996
3063
  urlHistory.addNew( url, settings.transition, pageTitle, pageUrl, settings.role );
@@ -3002,11 +3069,6 @@ $.widget( "mobile.page", $.mobile.widget, {
3002
3069
  //set "toPage" as activePage
3003
3070
  $.mobile.activePage = toPage;
3004
3071
 
3005
- // Make sure we have a transition defined.
3006
- settings.transition = settings.transition
3007
- || ( ( historyDir && !activeIsInitialPage ) ? active.transition : undefined )
3008
- || ( isDialog ? $.mobile.defaultDialogTransition : $.mobile.defaultPageTransition );
3009
-
3010
3072
  // If we're navigating back in the URL history, set reverse accordingly.
3011
3073
  settings.reverse = settings.reverse || historyDir < 0;
3012
3074
 
@@ -3238,16 +3300,19 @@ $.widget( "mobile.page", $.mobile.widget, {
3238
3300
  });
3239
3301
 
3240
3302
  //prefetch pages when anchors with data-prefetch are encountered
3241
- $( ".ui-page" ).live( "pageshow.prefetch", function(){
3303
+ $( ".ui-page" ).live( "pageshow.prefetch", function() {
3242
3304
  var urls = [];
3243
3305
  $( this ).find( "a:jqmData(prefetch)" ).each(function(){
3244
- var url = $( this ).attr( "href" );
3306
+ var $link = $(this),
3307
+ url = $link.attr( "href" );
3308
+
3245
3309
  if ( url && $.inArray( url, urls ) === -1 ) {
3246
3310
  urls.push( url );
3247
- $.mobile.loadPage( url );
3311
+
3312
+ $.mobile.loadPage( url, {role: $link.attr("data-" + $.mobile.ns + "rel")} );
3248
3313
  }
3249
3314
  });
3250
- } );
3315
+ });
3251
3316
 
3252
3317
  $.mobile._handleHashChange = function( hash ) {
3253
3318
  //find first page via hash
@@ -3404,14 +3469,15 @@ $.widget( "mobile.page", $.mobile.widget, {
3404
3469
 
3405
3470
  var href, state,
3406
3471
  hash = location.hash,
3407
- isPath = $.mobile.path.isPath( hash );
3472
+ isPath = $.mobile.path.isPath( hash ),
3473
+ resolutionUrl = isPath ? location.href : $.mobile.getDocumentUrl();
3408
3474
  hash = isPath ? hash.replace( "#", "" ) : hash;
3409
3475
 
3410
3476
  // propulate the hash when its not available
3411
3477
  state = self.state();
3412
3478
 
3413
3479
  // make the hash abolute with the current href
3414
- href = $.mobile.path.makeUrlAbsolute( hash, location.href );
3480
+ href = $.mobile.path.makeUrlAbsolute( hash, resolutionUrl );
3415
3481
 
3416
3482
  if ( isPath ) {
3417
3483
  href = self.resetUIKeys( href );
@@ -3546,22 +3612,25 @@ $.mobile.page.prototype.options.degradeInputs = {
3546
3612
  week: false
3547
3613
  };
3548
3614
 
3549
- $.mobile.page.prototype.options.keepNative = ":jqmData(role='none'), :jqmData(role='nojs')";
3550
-
3551
3615
 
3552
3616
  //auto self-init widgets
3553
- $( document ).bind( "pagecreate enhance", function( e ){
3554
-
3555
- var page = $( e.target ).data( "page" ),
3556
- o = page.options;
3557
-
3617
+ $( document ).bind( "pagecreate create", function( e ){
3618
+
3619
+ var page = $(e.target).closest(':jqmData(role="page")').data("page"), options;
3620
+
3621
+ if( !page ) {
3622
+ return;
3623
+ }
3624
+
3625
+ options = page.options;
3626
+
3558
3627
  // degrade inputs to avoid poorly implemented native functionality
3559
- $( e.target ).find( "input" ).not( o.keepNative ).each(function() {
3628
+ $( e.target ).find( "input" ).not( page.keepNativeSelector() ).each(function() {
3560
3629
  var $this = $( this ),
3561
3630
  type = this.getAttribute( "type" ),
3562
- optType = o.degradeInputs[ type ] || "text";
3631
+ optType = options.degradeInputs[ type ] || "text";
3563
3632
 
3564
- if ( o.degradeInputs[ type ] ) {
3633
+ if ( options.degradeInputs[ type ] ) {
3565
3634
  var html = $( "<div>" ).html( $this.clone() ).html(),
3566
3635
  // In IE browsers, the type sometimes doesn't exist in the cloned markup, so we replace the closing tag instead
3567
3636
  hasType = html.indexOf( " type=" ) > -1,
@@ -3571,7 +3640,7 @@ $( document ).bind( "pagecreate enhance", function( e ){
3571
3640
  $this.replaceWith( html.replace( findstr, repstr ) );
3572
3641
  }
3573
3642
  });
3574
-
3643
+
3575
3644
  });
3576
3645
 
3577
3646
  })( jQuery );/*
@@ -3662,23 +3731,23 @@ $( $.mobile.dialog.prototype.options.initSelector ).live( "pagecreate", function
3662
3731
 
3663
3732
  (function( $, undefined ) {
3664
3733
 
3665
- $.mobile.page.prototype.options.backBtnText = "Back";
3666
- $.mobile.page.prototype.options.addBackBtn = false;
3667
- $.mobile.page.prototype.options.backBtnTheme = null;
3668
- $.mobile.page.prototype.options.headerTheme = "a";
3669
- $.mobile.page.prototype.options.footerTheme = "a";
3670
- $.mobile.page.prototype.options.contentTheme = null;
3734
+ $.mobile.page.prototype.options.backBtnText = "Back";
3735
+ $.mobile.page.prototype.options.addBackBtn = false;
3736
+ $.mobile.page.prototype.options.backBtnTheme = null;
3737
+ $.mobile.page.prototype.options.headerTheme = "a";
3738
+ $.mobile.page.prototype.options.footerTheme = "a";
3739
+ $.mobile.page.prototype.options.contentTheme = null;
3671
3740
 
3672
3741
  $( ":jqmData(role='page'), :jqmData(role='dialog')" ).live( "pagecreate", function( e ) {
3673
3742
 
3674
- var $page = $( this ),
3675
- o = $page.data( "page" ).options,
3676
- pageTheme = o.theme;
3743
+ var $page = $( this ),
3744
+ o = $page.data( "page" ).options,
3745
+ pageTheme = o.theme;
3677
3746
 
3678
3747
  $( ":jqmData(role='header'), :jqmData(role='footer'), :jqmData(role='content')", this ).each(function() {
3679
- var $this = $( this ),
3680
- role = $this.jqmData( "role" ),
3681
- theme = $this.jqmData( "theme" ),
3748
+ var $this = $( this ),
3749
+ role = $this.jqmData( "role" ),
3750
+ theme = $this.jqmData( "theme" ),
3682
3751
  $headeranchors,
3683
3752
  leftbtn,
3684
3753
  rightbtn,
@@ -3691,35 +3760,32 @@ $( ":jqmData(role='page'), :jqmData(role='dialog')" ).live( "pagecreate", functi
3691
3760
 
3692
3761
  var thisTheme = theme || ( role === "header" ? o.headerTheme : o.footerTheme ) || pageTheme;
3693
3762
 
3694
- //add theme class
3695
- $this.addClass( "ui-bar-" + thisTheme );
3696
-
3697
- // Add ARIA role
3698
- $this.attr( "role", role === "header" ? "banner" : "contentinfo" );
3763
+ $this
3764
+ //add theme class
3765
+ .addClass( "ui-bar-" + thisTheme )
3766
+ // Add ARIA role
3767
+ .attr( "role", role === "header" ? "banner" : "contentinfo" );
3699
3768
 
3700
3769
  // Right,left buttons
3701
3770
  $headeranchors = $this.children( "a" );
3702
- leftbtn = $headeranchors.hasClass( "ui-btn-left" );
3703
- rightbtn = $headeranchors.hasClass( "ui-btn-right" );
3704
-
3705
- if ( !leftbtn ) {
3706
- leftbtn = $headeranchors.eq( 0 ).not( ".ui-btn-right" ).addClass( "ui-btn-left" ).length;
3707
- }
3708
-
3709
- if ( !rightbtn ) {
3710
- rightbtn = $headeranchors.eq( 1 ).addClass( "ui-btn-right" ).length;
3711
- }
3771
+ leftbtn = $headeranchors.hasClass( "ui-btn-left" );
3772
+ rightbtn = $headeranchors.hasClass( "ui-btn-right" );
3712
3773
 
3774
+ leftbtn = leftbtn || $headeranchors.eq( 0 ).not( ".ui-btn-right" ).addClass( "ui-btn-left" ).length;
3775
+
3776
+ rightbtn = rightbtn || $headeranchors.eq( 1 ).addClass( "ui-btn-right" ).length;
3777
+
3713
3778
  // Auto-add back btn on pages beyond first view
3714
- if ( o.addBackBtn && role === "header" &&
3715
- $( ".ui-page" ).length > 1 &&
3716
- $this.jqmData( "url" ) !== $.mobile.path.stripHash( location.hash ) &&
3717
- !leftbtn ) {
3718
-
3719
- backBtn = $( "<a href='#' class='ui-btn-left' data-"+ $.mobile.ns +"rel='back' data-"+ $.mobile.ns +"icon='arrow-l'>"+ o.backBtnText +"</a>" ).prependTo( $this );
3720
-
3721
- // If theme is provided, override default inheritance
3722
- backBtn.attr( "data-"+ $.mobile.ns +"theme", o.backBtnTheme || thisTheme );
3779
+ if ( o.addBackBtn &&
3780
+ role === "header" &&
3781
+ $( ".ui-page" ).length > 1 &&
3782
+ $this.jqmData( "url" ) !== $.mobile.path.stripHash( location.hash ) &&
3783
+ !leftbtn ) {
3784
+
3785
+ backBtn = $( "<a href='#' class='ui-btn-left' data-"+ $.mobile.ns +"rel='back' data-"+ $.mobile.ns +"icon='arrow-l'>"+ o.backBtnText +"</a>" )
3786
+ // If theme is provided, override default inheritance
3787
+ .attr( "data-"+ $.mobile.ns +"theme", o.backBtnTheme || thisTheme )
3788
+ .prependTo( $this );
3723
3789
  }
3724
3790
 
3725
3791
  // Page title
@@ -3733,14 +3799,12 @@ $( ":jqmData(role='page'), :jqmData(role='dialog')" ).live( "pagecreate", functi
3733
3799
  });
3734
3800
 
3735
3801
  } else if ( role === "content" ) {
3736
-
3737
3802
  if (theme || o.contentTheme) {
3738
3803
  $this.addClass( "ui-body-" + ( theme || o.contentTheme ) );
3739
3804
  }
3740
3805
 
3741
3806
  // Add ARIA role
3742
3807
  $this.attr( "role", "main" );
3743
-
3744
3808
  }
3745
3809
  });
3746
3810
  });
@@ -3867,7 +3931,7 @@ $.widget( "mobile.collapsible", $.mobile.widget, {
3867
3931
  collapsibleHeading
3868
3932
  .toggleClass( "ui-collapsible-heading-collapsed", isCollapse)
3869
3933
  .find( ".ui-collapsible-heading-status" )
3870
- .text( o.expandCueText )
3934
+ .text( isCollapse ? o.expandCueText : o.collapseCueText )
3871
3935
  .end()
3872
3936
  .find( ".ui-icon" )
3873
3937
  .toggleClass( "ui-icon-minus", !isCollapse )
@@ -3882,6 +3946,7 @@ $.widget( "mobile.collapsible", $.mobile.widget, {
3882
3946
  .toggleClass( "ui-corner-bottom", isCollapse );
3883
3947
  collapsibleContent.toggleClass( "ui-corner-bottom", !isCollapse );
3884
3948
  }
3949
+ collapsibleContent.trigger( "updatelayout" );
3885
3950
  }
3886
3951
  })
3887
3952
  .trigger( o.collapsed ? "collapse" : "expand" );
@@ -4119,6 +4184,7 @@ $.widget( "mobile.listview", $.mobile.widget, {
4119
4184
  .addClass( "ui-corner-tr" )
4120
4185
  .end()
4121
4186
  .find( ".ui-li-thumb" )
4187
+ .not(".ui-li-icon")
4122
4188
  .addClass( "ui-corner-tl" );
4123
4189
 
4124
4190
  // Select the last visible li element
@@ -4130,8 +4196,12 @@ $.widget( "mobile.listview", $.mobile.widget, {
4130
4196
  .addClass( "ui-corner-br" )
4131
4197
  .end()
4132
4198
  .find( ".ui-li-thumb" )
4199
+ .not(".ui-li-icon")
4133
4200
  .addClass( "ui-corner-bl" );
4134
4201
  }
4202
+ if ( !create ) {
4203
+ this.element.trigger( "updatelayout" );
4204
+ }
4135
4205
  },
4136
4206
 
4137
4207
  refresh: function( create ) {
@@ -4187,7 +4257,7 @@ $.widget( "mobile.listview", $.mobile.widget, {
4187
4257
  splittheme = listsplittheme || last.jqmData( "theme" ) || o.splitTheme;
4188
4258
 
4189
4259
  last.appendTo(item)
4190
- .attr( "title", last.text() )
4260
+ .attr( "title", last.getEncodedText() )
4191
4261
  .addClass( "ui-li-link-alt" )
4192
4262
  .empty()
4193
4263
  .buttonMarkup({
@@ -4268,7 +4338,7 @@ $.widget( "mobile.listview", $.mobile.widget, {
4268
4338
  parent = list.parent(),
4269
4339
  nodeEls = $( list.prevAll().toArray().reverse() ),
4270
4340
  nodeEls = nodeEls.length ? nodeEls : $( "<span>" + $.trim(parent.contents()[ 0 ].nodeValue) + "</span>" ),
4271
- title = nodeEls.first().text(),//url limits to first 30 chars of text
4341
+ title = nodeEls.first().getEncodedText(),//url limits to first 30 chars of text
4272
4342
  id = ( parentUrl || "" ) + "&" + $.mobile.subPageUrlKey + "=" + listId,
4273
4343
  theme = list.jqmData( "theme" ) || o.theme,
4274
4344
  countTheme = list.jqmData( "counttheme" ) || parentList.jqmData( "counttheme" ) || o.countTheme,
@@ -4527,9 +4597,9 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
4527
4597
  .wrapAll( "<div class='ui-" + inputtype + "'></div>" );
4528
4598
 
4529
4599
  label.bind({
4530
- vmouseover: function() {
4600
+ vmouseover: function( event ) {
4531
4601
  if ( $( this ).parent().is( ".ui-disabled" ) ) {
4532
- return false;
4602
+ event.stopPropagation();
4533
4603
  }
4534
4604
  },
4535
4605
 
@@ -4599,11 +4669,12 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
4599
4669
 
4600
4670
  //returns either a set of radios with the same name attribute, or a single checkbox
4601
4671
  _getInputSet: function(){
4602
- if(this.inputtype == "checkbox") {
4603
- return this.element;
4604
- }
4605
- return this.element.closest( "form,fieldset,:jqmData(role='page')" )
4606
- .find( "input[name='"+ this.element.attr( "name" ) +"'][type='"+ this.inputtype +"']" );
4672
+ if(this.inputtype == "checkbox") {
4673
+ return this.element;
4674
+ }
4675
+
4676
+ return this.element.closest( "form,fieldset,:jqmData(role='page')" )
4677
+ .find( "input[name='"+ this.element.attr( "name" ) +"'][type='"+ this.inputtype +"']" );
4607
4678
  },
4608
4679
 
4609
4680
  _updateAll: function() {
@@ -4655,9 +4726,7 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
4655
4726
 
4656
4727
  //auto self-init widgets
4657
4728
  $( document ).bind( "pagecreate create", function( e ){
4658
- $( $.mobile.checkboxradio.prototype.options.initSelector, e.target )
4659
- .not( ":jqmData(role='none'), :jqmData(role='nojs')" )
4660
- .checkboxradio();
4729
+ $.mobile.checkboxradio.prototype.enhanceWithin( e.target );
4661
4730
  });
4662
4731
 
4663
4732
  })( jQuery );
@@ -4691,6 +4760,7 @@ $.widget( "mobile.button", $.mobile.widget, {
4691
4760
  // Add ARIA role
4692
4761
  this.button = $( "<div></div>" )
4693
4762
  .text( $el.text() || $el.val() )
4763
+ .insertBefore( $el )
4694
4764
  .buttonMarkup({
4695
4765
  theme: o.theme,
4696
4766
  icon: o.icon,
@@ -4700,7 +4770,6 @@ $.widget( "mobile.button", $.mobile.widget, {
4700
4770
  shadow: o.shadow,
4701
4771
  iconshadow: o.iconshadow
4702
4772
  })
4703
- .insertBefore( $el )
4704
4773
  .append( $el.addClass( "ui-btn-hidden" ) );
4705
4774
 
4706
4775
  type = $el.attr( "type" );
@@ -4752,9 +4821,7 @@ $.widget( "mobile.button", $.mobile.widget, {
4752
4821
 
4753
4822
  //auto self-init widgets
4754
4823
  $( document ).bind( "pagecreate create", function( e ){
4755
- $( $.mobile.button.prototype.options.initSelector, e.target )
4756
- .not( ":jqmData(role='none'), :jqmData(role='nojs')" )
4757
- .button();
4824
+ $.mobile.button.prototype.enhanceWithin( e.target );
4758
4825
  });
4759
4826
 
4760
4827
  })( jQuery );/*
@@ -4781,13 +4848,11 @@ $.widget( "mobile.slider", $.mobile.widget, {
4781
4848
 
4782
4849
  control = this.element,
4783
4850
 
4784
- parentTheme = control.parents( "[class*='ui-bar-'],[class*='ui-body-']" ).eq( 0 ),
4851
+ parentTheme = $.mobile.getInheritedTheme( control, "c" ),
4785
4852
 
4786
- parentTheme = parentTheme.length ? parentTheme.attr( "class" ).match( /ui-(bar|body)-([a-z])/ )[ 2 ] : "c",
4853
+ theme = this.options.theme || parentTheme,
4787
4854
 
4788
- theme = this.options.theme ? this.options.theme : parentTheme,
4789
-
4790
- trackTheme = this.options.trackTheme ? this.options.trackTheme : parentTheme,
4855
+ trackTheme = this.options.trackTheme || parentTheme,
4791
4856
 
4792
4857
  cType = control[ 0 ].nodeName.toLowerCase(),
4793
4858
 
@@ -4849,7 +4914,7 @@ $.widget( "mobile.slider", $.mobile.widget, {
4849
4914
  $( "<div class='ui-slider-labelbg ui-slider-labelbg-" + side + theme + " ui-btn-corner-" + corners + "'></div>" )
4850
4915
  .prependTo( slider );
4851
4916
 
4852
- $( "<span class='ui-slider-label ui-slider-label-" + side + theme + " ui-btn-corner-" + corners + "' role='img'>" + $( this ).text() + "</span>" )
4917
+ $( "<span class='ui-slider-label ui-slider-label-" + side + theme + " ui-btn-corner-" + corners + "' role='img'>" + $( this ).getEncodedText() + "</span>" )
4853
4918
  .prependTo( handle );
4854
4919
  });
4855
4920
 
@@ -4974,7 +5039,11 @@ $.widget( "mobile.slider", $.mobile.widget, {
4974
5039
  },
4975
5040
 
4976
5041
  refresh: function( val, isfromControl, preventInputUpdate ) {
4977
- if ( this.options.disabled ) { return; }
5042
+
5043
+ if ( this.options.disabled || this.element.attr('disabled')) {
5044
+ this.slider.addClass('ui-disabled');
5045
+ return;
5046
+ }
4978
5047
 
4979
5048
  var control = this.element, percent,
4980
5049
  cType = control[0].nodeName.toLowerCase(),
@@ -5027,7 +5096,7 @@ $.widget( "mobile.slider", $.mobile.widget, {
5027
5096
  this.handle.css( "left", percent + "%" );
5028
5097
  this.handle.attr( {
5029
5098
  "aria-valuenow": cType === "input" ? newval : control.find( "option" ).eq( newval ).attr( "value" ),
5030
- "aria-valuetext": cType === "input" ? newval : control.find( "option" ).eq( newval ).text(),
5099
+ "aria-valuetext": cType === "input" ? newval : control.find( "option" ).eq( newval ).getEncodedText(),
5031
5100
  title: newval
5032
5101
  });
5033
5102
 
@@ -5075,11 +5144,7 @@ $.widget( "mobile.slider", $.mobile.widget, {
5075
5144
 
5076
5145
  //auto self-init widgets
5077
5146
  $( document ).bind( "pagecreate create", function( e ){
5078
-
5079
- $( $.mobile.slider.prototype.options.initSelector, e.target )
5080
- .not( ":jqmData(role='none'), :jqmData(role='nojs')" )
5081
- .slider();
5082
-
5147
+ $.mobile.slider.prototype.enhanceWithin( e.target );
5083
5148
  });
5084
5149
 
5085
5150
  })( jQuery );
@@ -5095,7 +5160,7 @@ $( document ).bind( "pagecreate create", function( e ){
5095
5160
  $.widget( "mobile.textinput", $.mobile.widget, {
5096
5161
  options: {
5097
5162
  theme: null,
5098
- initSelector: "input[type='text'], input[type='search'], :jqmData(type='search'), input[type='number'], :jqmData(type='number'), input[type='password'], input[type='email'], input[type='url'], input[type='tel'], textarea, input:not([type])"
5163
+ initSelector: "input[type='text'], input[type='search'], :jqmData(type='search'), input[type='number'], :jqmData(type='number'), input[type='password'], input[type='email'], input[type='url'], input[type='tel'], textarea, input[type='time'], input[type='date'], input[type='month'], input[type='week'], input[type='datetime'], input[type='datetime-local'], input[type='color'], input:not([type])"
5099
5164
  },
5100
5165
 
5101
5166
  _create: function() {
@@ -5103,19 +5168,17 @@ $.widget( "mobile.textinput", $.mobile.widget, {
5103
5168
  var input = this.element,
5104
5169
  o = this.options,
5105
5170
  theme = o.theme,
5106
- themedParent, themeclass, themeLetter, focusedEl, clearbtn;
5171
+ themeclass, focusedEl, clearbtn;
5107
5172
 
5108
5173
  if ( !theme ) {
5109
- themedParent = this.element.closest( "[class*='ui-bar-'],[class*='ui-body-']" );
5110
- themeLetter = themedParent.length && /ui-(bar|body)-([a-z])/.exec( themedParent.attr( "class" ) );
5111
- theme = themeLetter && themeLetter[2] || "c";
5174
+ theme = $.mobile.getInheritedTheme( this.element, "c" );
5112
5175
  }
5113
5176
 
5114
5177
  themeclass = " ui-body-" + theme;
5115
5178
 
5116
5179
  $( "label[for='" + input.attr( "id" ) + "']" ).addClass( "ui-input-text" );
5117
5180
 
5118
- input.addClass("ui-input-text ui-body-"+ o.theme );
5181
+ input.addClass("ui-input-text ui-body-"+ theme );
5119
5182
 
5120
5183
  focusedEl = input;
5121
5184
 
@@ -5197,6 +5260,12 @@ $.widget( "mobile.textinput", $.mobile.widget, {
5197
5260
  clearTimeout( keyupTimeout );
5198
5261
  keyupTimeout = setTimeout( keyup, keyupTimeoutBuffer );
5199
5262
  });
5263
+
5264
+ // Issue 509: the browser is not giving scrollHeight properly until after the document
5265
+ // is ready.
5266
+ if ($.trim(input.text())) {
5267
+ $(keyup);
5268
+ }
5200
5269
  }
5201
5270
  },
5202
5271
 
@@ -5213,11 +5282,7 @@ $.widget( "mobile.textinput", $.mobile.widget, {
5213
5282
 
5214
5283
  //auto self-init widgets
5215
5284
  $( document ).bind( "pagecreate create", function( e ){
5216
-
5217
- $( $.mobile.textinput.prototype.options.initSelector, e.target )
5218
- .not( ":jqmData(role='none'), :jqmData(role='nojs')" )
5219
- .textinput();
5220
-
5285
+ $.mobile.textinput.prototype.enhanceWithin( e.target );
5221
5286
  });
5222
5287
 
5223
5288
  })( jQuery );
@@ -5569,6 +5634,7 @@ $( document ).bind( "pagecreate create", function( e ){
5569
5634
 
5570
5635
  self.menuType = "page";
5571
5636
  self.menuPageContent.append( self.list );
5637
+ self.menuPage.find("div .ui-title").text(self.label.text());
5572
5638
  $.mobile.changePage( self.menuPage, {
5573
5639
  transition: $.mobile.defaultDialogTransition
5574
5640
  });
@@ -5747,22 +5813,6 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
5747
5813
  return $( "<div/>" );
5748
5814
  },
5749
5815
 
5750
- _theme: function(){
5751
- if ( this.options.theme ){
5752
- return this.options.theme;
5753
- }
5754
-
5755
- var themedParent, theme;
5756
- // if no theme is defined, try to find closest theme container
5757
- // TODO move to core as something like findCurrentTheme
5758
- themedParent = this.select.closest( "[class*='ui-bar-'], [class*='ui-body-']" );
5759
- theme = themedParent.length ?
5760
- /ui-(bar|body)-([a-z])/.exec( themedParent.attr( "class" ) )[2] :
5761
- "c";
5762
-
5763
- return theme;
5764
- },
5765
-
5766
5816
  _setDisabled: function( value ) {
5767
5817
  this.element.attr( "disabled", value );
5768
5818
  this.button.attr( "aria-disabled", value );
@@ -5787,7 +5837,9 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
5787
5837
  this.selectID = this.select.attr( "id" );
5788
5838
  this.label = $( "label[for='"+ this.selectID +"']" ).addClass( "ui-select" );
5789
5839
  this.isMultiple = this.select[ 0 ].multiple;
5790
- this.options.theme = this._theme();
5840
+ if ( !this.options.theme ) {
5841
+ this.options.theme = $.mobile.getInheritedTheme( this.select, "c" );
5842
+ }
5791
5843
  },
5792
5844
 
5793
5845
  _create: function() {
@@ -5840,7 +5892,7 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
5840
5892
  }
5841
5893
 
5842
5894
  // Disable if specified
5843
- if ( options.disabled ) {
5895
+ if ( options.disabled || this.element.attr('disabled')) {
5844
5896
  this.disable();
5845
5897
  }
5846
5898
 
@@ -5935,9 +5987,7 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
5935
5987
 
5936
5988
  //auto self-init widgets
5937
5989
  $( document ).bind( "pagecreate create", function( e ){
5938
- $( $.mobile.selectmenu.prototype.options.initSelector, e.target )
5939
- .not( ":jqmData(role='none'), :jqmData(role='nojs')" )
5940
- .selectmenu();
5990
+ $.mobile.selectmenu.prototype.enhanceWithin( e.target );
5941
5991
  });
5942
5992
  })( jQuery );
5943
5993
  /*
@@ -5955,13 +6005,16 @@ $.fn.buttonMarkup = function( options ) {
5955
6005
  icon: el.jqmData( "icon" ),
5956
6006
  iconpos: el.jqmData( "iconpos" ),
5957
6007
  theme: el.jqmData( "theme" ),
5958
- inline: el.jqmData( "inline" )
6008
+ inline: el.jqmData( "inline" ),
6009
+ shadow: el.jqmData( "shadow" ),
6010
+ corners: el.jqmData( "corners" ),
6011
+ iconshadow: el.jqmData( "iconshadow" )
5959
6012
  }, options ),
5960
6013
 
5961
6014
  // Classes Defined
5962
6015
  innerClass = "ui-btn-inner",
5963
6016
  buttonClass, iconClass,
5964
- themedParent, wrap;
6017
+ wrap;
5965
6018
 
5966
6019
  if ( attachEvents ) {
5967
6020
  attachEvents();
@@ -5969,10 +6022,7 @@ $.fn.buttonMarkup = function( options ) {
5969
6022
 
5970
6023
  // if not, try to find closest theme container
5971
6024
  if ( !o.theme ) {
5972
- themedParent = el.closest( "[class*='ui-bar-'],[class*='ui-body-']" );
5973
- o.theme = themedParent.length ?
5974
- /ui-(bar|body)-([a-z])/.exec( themedParent.attr( "class" ) )[2] :
5975
- "c";
6025
+ o.theme = $.mobile.getInheritedTheme( el, "c" );
5976
6026
  }
5977
6027
 
5978
6028
  buttonClass = "ui-btn ui-btn-up-" + o.theme;
@@ -5996,7 +6046,7 @@ $.fn.buttonMarkup = function( options ) {
5996
6046
  buttonClass += " ui-btn-icon-" + o.iconpos;
5997
6047
 
5998
6048
  if ( o.iconpos == "notext" && !el.attr( "title" ) ) {
5999
- el.attr( "title", el.text() );
6049
+ el.attr( "title", el.getEncodedText() );
6000
6050
  }
6001
6051
  }
6002
6052
 
@@ -6012,7 +6062,7 @@ $.fn.buttonMarkup = function( options ) {
6012
6062
  el.attr( "data-" + $.mobile.ns + "theme", o.theme )
6013
6063
  .addClass( buttonClass );
6014
6064
 
6015
- wrap = ( "<D class='" + innerClass + "'><D class='ui-btn-text'></D>" +
6065
+ wrap = ( "<D class='" + innerClass + "' aria-hidden='true'><D class='ui-btn-text'></D>" +
6016
6066
  ( o.icon ? "<span class='" + iconClass + "'></span>" : "" ) +
6017
6067
  "</D>" ).replace( /D/g, o.wrapperEls );
6018
6068
 
@@ -6319,7 +6369,7 @@ $.mobile.fixedToolbars = (function() {
6319
6369
  stateBefore = null;
6320
6370
  });
6321
6371
 
6322
- $window.bind( "resize", showEventCallback );
6372
+ $window.bind( "resize updatelayout", showEventCallback );
6323
6373
  });
6324
6374
 
6325
6375
  // 1. Before page is shown, check for duplicate footer