Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
merge conflict resolved for checkbox radio and select tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbender committed Feb 14, 2012
2 parents 934b24a + f86eb66 commit 480cdea
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 74 deletions.
7 changes: 5 additions & 2 deletions js/jquery.mobile.forms.checkboxradio.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
});

// Wrap the input + label in a div
input.add( label )
.wrapAll( "<div class='ui-" + inputtype + "'></div>" );
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 ) {
Expand Down
101 changes: 60 additions & 41 deletions js/jquery.mobile.forms.select.custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ define( [
"<div class='ui-title'>" + label.getEncodedText() + "</div>"+
"</div>"+
"<div data-" + $.mobile.ns + "role='content'></div>"+
"</div>" ).appendTo( $.mobile.pageContainer ).page(),
"</div>" ),

listbox = $("<div>", { "class": "ui-selectmenu ui-selectmenu-hidden ui-overlay-shadow ui-corner-all ui-body-" + widget.options.overlayTheme + " " + $.mobile.defaultDialogTransition } ).insertAfter(screen),

Expand All @@ -60,9 +60,9 @@ define( [
"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, {
Expand Down Expand Up @@ -333,6 +333,11 @@ define( [
}

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
Expand Down Expand Up @@ -425,49 +430,63 @@ define( [

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 = "<a href='#'>"+ text +"</a>",
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( "<li data-" + $.mobile.ns + "role='list-divider'>"+ optLabel +"</li>" );
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( "<li data-" + $.mobile.ns + "option-index='" + i + "' data-" + $.mobile.ns + "icon='"+ dataIcon +"' class='"+ classes.join(" ") + "' " + extraAttrs.join(" ") +">"+ anchor +"</li>" );
});

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 ) {
Expand Down
58 changes: 42 additions & 16 deletions js/jquery.mobile.forms.slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,12 @@ $.widget( "mobile.slider", $.mobile.widget, {
step = window.parseFloat( control.attr( "step" ) || 1 ),

inlineClass = ( this.options.inline || control.jqmData("inline") == true ) ? " ui-slider-inline" : "",

miniClass = ( this.options.mini || control.jqmData("mini") ) ? " ui-slider-mini" : "",

slider = $( "<div class='ui-slider " + selectClass + " ui-btn-down-" + trackTheme +
" ui-btn-corner-all" + inlineClass + miniClass + "' role='application'></div>" ),

valuebg = control.jqmData("highlight") && cType != "select" ? $( "<div class='ui-slider-bg ui-btn-active ui-btn-corner-all'></div>" ).prependTo( slider ) : false,

handle = $( "<a href='#' class='ui-slider-handle'></a>" )
handle = $( document.createElement('a') ) //"<a href='#' class='ui-slider-handle'></a>" )
.appendTo( slider )
.buttonMarkup({ corners: true, theme: theme, shadow: true })
.attr({
Expand All @@ -70,8 +67,28 @@ $.widget( "mobile.slider", $.mobile.widget, {
"title": val(),
"aria-labelledby": labelID
}),

domSlider = document.createElement('div'),
slider = $(domSlider),
options;

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);

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
}),

$.extend( this, {
slider: slider,
handle: handle,
Expand All @@ -83,25 +100,34 @@ $.widget( "mobile.slider", $.mobile.widget, {
});

if ( cType == "select" ) {

slider.wrapInner( "<div class='ui-slider-inneroffset'></div>" );
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",
theme = !i ? " ui-btn-down-" + trackTheme :( " " + $.mobile.activeBtnClass );

$( "<span class='ui-slider-label ui-slider-label-" + side + theme + " ui-btn-corner-all' role='img'>" + $( this ).getEncodedText() + "</span>" )
.prependTo( slider );
});

self._labels = $( ".ui-slider-label", slider );
corners = !i ? "right" :"left",
sliderTheme = !i ? " ui-btn-down-" + trackTheme :( " " + $.mobile.activeBtnClass ),
sliderLabel = document.createElement('div'),
sliderImg = document.createElement('span');

sliderLabel.className = ['ui-slider-labelbg ui-slider-labelbg-',side,sliderTheme," ui-btn-corner-",corners].join("");
$(sliderLabel).prependTo( slider );
sliderImg.className = ['ui-slider-label ui-slider-label-',side,sliderTheme," ui-btn-corner-",corners].join("");
sliderImg.setAttribute('role','img');
sliderImg.appendChild(document.createTextNode(options[i].innerHTML));
$(sliderImg).prependTo( handle );
}

self._labels = $( ".ui-slider-label", slider );
}

label.addClass( "ui-slider" );
Expand Down
22 changes: 17 additions & 5 deletions tests/unit/select/select_cached.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,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();
}
]);
});
Expand Down
10 changes: 0 additions & 10 deletions tests/unit/select/select_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,16 +324,6 @@
same(window.encodedValueIsDefined, undefined);
});

// issue #2547
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);
});

// not testing the positive case here since's it's obviously tested elsewhere
test( "select elements in the keepNative set shouldn't be enhanced", function() {
ok( !$("#keep-native").parent().is("div.ui-btn") );
Expand Down

0 comments on commit 480cdea

Please sign in to comment.