diff --git a/js/jquery.mobile.forms.checkboxradio.js b/js/jquery.mobile.forms.checkboxradio.js index 329116e7f68..594506dcb92 100644 --- a/js/jquery.mobile.forms.checkboxradio.js +++ b/js/jquery.mobile.forms.checkboxradio.js @@ -51,8 +51,11 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, { }); // Wrap the input + label in a div - input.add( label ) - .wrapAll( "
" ); + var wrapper = document.createElement('div'); + wrapper.className = 'ui-' + inputtype; + input[0].parentNode.insertBefore(wrapper,input[0]); + wrapper.appendChild(input[0]); + wrapper.appendChild(label[0]); label.bind({ vmouseover: function( event ) { diff --git a/js/jquery.mobile.forms.select.custom.js b/js/jquery.mobile.forms.select.custom.js index 385e44182fa..f294759069b 100644 --- a/js/jquery.mobile.forms.select.custom.js +++ b/js/jquery.mobile.forms.select.custom.js @@ -19,7 +19,7 @@ "
" + label.getEncodedText() + "
"+ ""+ "
"+ - "" ).appendTo( $.mobile.pageContainer ).page(), + "" ), listbox = $("
", { "class": "ui-selectmenu ui-selectmenu-hidden ui-overlay-shadow ui-corner-all ui-body-" + widget.options.overlayTheme + " " + $.mobile.defaultDialogTransition } ).insertAfter(screen), @@ -44,9 +44,9 @@ "class": "ui-btn-left" }).attr( "data-" + $.mobile.ns + "iconpos", "notext" ).attr( "data-" + $.mobile.ns + "icon", "delete" ).appendTo( header ).buttonMarkup(), - menuPageContent = menuPage.find( ".ui-content" ), - - menuPageClose = menuPage.find( ".ui-header a" ); + menuPageContent, + + menuPageClose; $.extend( widget, { @@ -316,6 +316,11 @@ } if ( menuHeight > screenHeight - 80 || !$.support.scrollTop ) { + + self.menuPage.appendTo( $.mobile.pageContainer ).page(); + self.menuPageContent = menuPage.find( ".ui-content" ); + self.menuPageClose = menuPage.find( ".ui-header a" ); + // prevent the parent page from being removed from the DOM, // otherwise the results of selecting a list item in the dialog // fall into a black hole @@ -408,49 +413,63 @@ self.list.empty().filter( ".ui-listview" ).listview( "destroy" ); - // Populate menu with options from select element - self.select.find( "option" ).each( function( i ) { - var $this = $( this ), - $parent = $this.parent(), - text = $this.getEncodedText(), - anchor = ""+ text +"", - classes = [], - extraAttrs = []; - - // Are we inside an optgroup? - if ( $parent.is( "optgroup" ) ) { - var optLabel = $parent.attr( "label" ); - - // has this optgroup already been built yet? - if ( $.inArray( optLabel, optgroups ) === -1 ) { - lis.push( "
  • "+ optLabel +"
  • " ); - optgroups.push( optLabel ); + var $options = self.select.find("option"), + numOptions = $options.length, + select = this.select[ 0 ], + dataPrefix = 'data-' + $.mobile.ns, + dataIndexAttr = dataPrefix + 'option-index', + dataIconAttr = dataPrefix + 'icon', + dataRoleAttr = dataPrefix + 'role', + fragment = document.createDocumentFragment(), + optGroup; + + for (var i = 0; i < numOptions;i++){ + var option = $options[i], + $option = $(option), + parent = option.parentNode, + text = $option.text(), + anchor = document.createElement('a'); + classes = []; + + anchor.setAttribute('href','#'); + anchor.appendChild(document.createTextNode(text)); + + // Are we inside an optgroup? + if (parent !== select && parent.nodeName.toLowerCase() === "optgroup"){ + var optLabel = parent.getAttribute('label'); + if ( optLabel != optGroup) { + var divider = document.createElement('li'); + divider.setAttribute(dataRoleAttr,'list-divider'); + divider.setAttribute('role','option'); + divider.setAttribute('tabindex','-1'); + divider.appendChild(document.createTextNode(optLabel)); + fragment.appendChild(divider); + optGroup = optLabel; } - } - - // Find placeholder text - // TODO: Are you sure you want to use getAttribute? ^RW - if ( !this.getAttribute( "value" ) || text.length == 0 || $this.jqmData( "placeholder" ) ) { + } + + if (!placeholder && (!option.getAttribute( "value" ) || text.length == 0 || $option.jqmData( "placeholder" )) ) { if ( o.hidePlaceholderMenuItems ) { classes.push( "ui-selectmenu-placeholder" ); - } - placeholder = self.placeholder = text; + } + placeholder = self.placeholder = text; } - - // support disabled option tags - if ( this.disabled ) { + + var item = document.createElement('li'); + if ( option.disabled ) { classes.push( "ui-disabled" ); - extraAttrs.push( "aria-disabled='true'" ); + item.setAttribute('aria-disabled',true); } - - lis.push( "
  • "+ anchor +"
  • " ); - }); - - self.list.html( lis.join(" ") ); - - self.list.find( "li" ) - .attr({ "role": "option", "tabindex": "-1" }) - .first().attr( "tabindex", "0" ); + item.setAttribute(dataIndexAttr,i); + item.setAttribute(dataIconAttr,dataIcon); + item.className = classes.join(" "); + item.setAttribute('role','option'); + item.setAttribute('tabindex','-1'); + item.appendChild(anchor); + fragment.appendChild(item); + } + fragment.firstChild.setAttribute('tabindex',0); + self.list[0].appendChild(fragment); // Hide header close link for single selects if ( !this.isMultiple ) { diff --git a/js/jquery.mobile.forms.slider.js b/js/jquery.mobile.forms.slider.js index 33c624d9251..3c469c37798 100644 --- a/js/jquery.mobile.forms.slider.js +++ b/js/jquery.mobile.forms.slider.js @@ -45,21 +45,27 @@ $.widget( "mobile.slider", $.mobile.widget, { step = window.parseFloat( control.attr( "step" ) || 1 ), - slider = $( "
    " ), - - handle = $( "" ) - .appendTo( slider ) - .buttonMarkup({ corners: true, theme: theme, shadow: true }) - .attr({ - "role": "slider", - "aria-valuemin": min, - "aria-valuemax": max, - "aria-valuenow": val(), - "aria-valuetext": val(), - "title": val(), - "aria-labelledby": labelID - }), + domSlider = document.createElement('div'), + + handle = document.createElement('a'); + + domSlider.setAttribute('role','application'); + domSlider.className = ['ui-slider ',selectClass," ui-btn-down-",trackTheme,' ui-btn-corner-all'].join(""); + handle.className = 'ui-slider-handle'; + domSlider.appendChild(handle); + + var slider = $(domSlider), + handle = $(handle) + .buttonMarkup({ corners: true, theme: theme, shadow: true }) + .attr({ + "role": "slider", + "aria-valuemin": min, + "aria-valuemax": max, + "aria-valuenow": val(), + "aria-valuetext": val(), + "title": val(), + "aria-labelledby": labelID + }), options; $.extend( this, { @@ -72,27 +78,31 @@ $.widget( "mobile.slider", $.mobile.widget, { }); if ( cType == "select" ) { - - slider.wrapInner( "
    " ); - + var wrapper = document.createElement('div'); + wrapper.className = 'ui-slider-inneroffset'; + for(var j = 0,length = domSlider.childNodes.length;j < length;j++){ + wrapper.appendChild(domSlider.childNodes[j]); + } + domSlider.appendChild(wrapper); + // make the handle move with a smooth transition handle.addClass( "ui-slider-handle-snapping" ); options = control.find( "option" ); - control.find( "option" ).each(function( i ) { - + for(var i = 0, length = options.length; i < length; i++){ var side = !i ? "b":"a", corners = !i ? "right" :"left", - theme = !i ? " ui-btn-down-" + trackTheme :( " " + $.mobile.activeBtnClass ); - - $( "
    " ) - .prependTo( slider ); - - $( "" + $( this ).getEncodedText() + "" ) - .prependTo( handle ); - }); - + theme = !i ? " ui-btn-down-" + trackTheme :( " " + $.mobile.activeBtnClass ), + sliderLabel = document.createElement('div'), + sliderImg = document.createElement('span'); + sliderLabel.className = ['ui-slider-labelbg ui-slider-labelbg-',side,theme," ui-btn-corner-",corners].join(""); + $(sliderLabel).prependTo( slider ); + sliderImg.className = ['ui-slider-label ui-slider-label-',side,theme," ui-btn-corner-",corners].join(""); + sliderImg.setAttribute('role','img'); + sliderImg.appendChild(document.createTextNode(options[i].innerHTML)); + $(sliderImg).prependTo( handle ); + } } label.addClass( "ui-slider" ); diff --git a/tests/speed/checkbox.html b/tests/speed/checkbox.html new file mode 100644 index 00000000000..8337cb0a352 --- /dev/null +++ b/tests/speed/checkbox.html @@ -0,0 +1,55 @@ + + + + + + jQuery Mobile Docs - Checkboxradio + + + + + + +
    + +
    +

    Checkboxradio

    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + diff --git a/tests/speed/checkbox.php b/tests/speed/checkbox.php new file mode 100644 index 00000000000..fe87ba0f2ec --- /dev/null +++ b/tests/speed/checkbox.php @@ -0,0 +1,57 @@ + + + + + + jQuery Mobile Docs - Checkboxradio + + + + + + + + +
    + +
    +

    Checkboxradio

    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + diff --git a/tests/speed/lists-ul-record.php b/tests/speed/lists-ul-record.php index a7760956251..c659825f584 100644 --- a/tests/speed/lists-ul-record.php +++ b/tests/speed/lists-ul-record.php @@ -12,7 +12,7 @@ -
    +

    400 item list

    diff --git a/tests/speed/select.custom.html b/tests/speed/select.custom.html new file mode 100644 index 00000000000..5a6154eafc9 --- /dev/null +++ b/tests/speed/select.custom.html @@ -0,0 +1,132 @@ + + + + + + jQuery Mobile Docs - Custom selectmenu + + + + + + +
    + +
    +

    Custom selectmenu

    +
    + +
    + +
    +
    + + + diff --git a/tests/speed/select.custom.php b/tests/speed/select.custom.php new file mode 100644 index 00000000000..7960045c76c --- /dev/null +++ b/tests/speed/select.custom.php @@ -0,0 +1,134 @@ + + + + + + jQuery Mobile Docs - Custom selectmenu + + + + + + + + +
    + +
    +

    Custom selectmenu

    +
    + +
    + +
    +
    + + + diff --git a/tests/speed/slider.html b/tests/speed/slider.html new file mode 100644 index 00000000000..ca20dfbe399 --- /dev/null +++ b/tests/speed/slider.html @@ -0,0 +1,75 @@ + + + + + + jQuery Mobile Docs - Slider + + + + + + +
    + +
    +

    Slider

    +
    + +
    + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + diff --git a/tests/speed/slider.php b/tests/speed/slider.php new file mode 100644 index 00000000000..c03ad505faf --- /dev/null +++ b/tests/speed/slider.php @@ -0,0 +1,77 @@ + + + + + + jQuery Mobile Docs - Slider + + + + + + + + +
    + +
    +

    Slider

    +
    + +
    + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + diff --git a/tests/speed/stats/startup.js b/tests/speed/stats/startup.js index 438df106a70..adf8b7fcaba 100644 --- a/tests/speed/stats/startup.js +++ b/tests/speed/stats/startup.js @@ -1,5 +1,5 @@ (function(Perf) { - var $listPage = $( "#list-page" ), firstCounter = 0; + var $listPage = $( "#perf-test-page" ), firstCounter = 0; Perf.setCurrentRev(); Perf.pageLoadStart = Date.now(); @@ -16,7 +16,7 @@ }); $listPage.live( "pagecreate", function( event ) { - if( event.target !== $("#list-page")[0] ){ + if( event.target !== $("#perf-test-page")[0] ){ return; } @@ -26,7 +26,7 @@ $listPage.live( "pageinit", function( event ) { // if a child page init is fired ignore it, we only // want the top level page init event - if( event.target !== $("#list-page")[0] ){ + if( event.target !== $("#perf-test-page")[0] ){ return; } diff --git a/tests/unit/select/select_cached.js b/tests/unit/select/select_cached.js index 2849cca86b0..9445c7feeaa 100644 --- a/tests/unit/select/select_cached.js +++ b/tests/unit/select/select_cached.js @@ -101,23 +101,35 @@ asyncTest( "menupage is removed when the parent page is removed", function(){ var dialogCount = $(":jqmData(role='dialog')").length; - $.testHelper.pageSequence([ resetHash, function(){ - $.mobile.changePage( "uncached-dom-cached-false.html" ); }, function(){ - same( $(":jqmData(role='dialog')").length, dialogCount + 1 ); + // for performance reason we don't initially create the menu dialog now + same( $(":jqmData(role='dialog')").length, dialogCount); + + // manually trigger dialog opening + $( "#domcache-uncached-page-select" ).data( 'selectmenu' ).open(); + }, + + function(){ + // check if dialog was successfully created + same( $(":jqmData(role='dialog')").length, dialogCount + 1 ); + $( "#domcache-uncached-page-select" ).data( 'selectmenu' ).close(); + }, + + function(){ + // navigate to parent(initial) page window.history.back(); }, - + function() { same( $(":jqmData(role='dialog')").length, dialogCount ); - start(); + start(); } ]); }); diff --git a/tests/unit/select/select_core.js b/tests/unit/select/select_core.js index 3271000f11a..0230f7f5e85 100644 --- a/tests/unit/select/select_core.js +++ b/tests/unit/select/select_core.js @@ -325,15 +325,16 @@ }); // issue #2547 - test( "custom select list item links have unencoded option text values when using vanilla $.fn.text", function() { + // getEncodedText() is no longer used in _buildList() so we don't need this extra check + /*test( "custom select list item links have unencoded option text values when using vanilla $.fn.text", function() { // undo our changes, undone in teardown $.fn.getEncodedText = $.fn.text; $( "#encoded-option" ).data( 'selectmenu' )._buildList(); same(window.encodedValueIsDefined, true); - }); - + });*/ + $.mobile.page.prototype.options.keepNative = "select.should-be-native"; // not testing the positive case here since's it's obviously tested elsewhere