From 6300c4188c020ba10f54b9905357032503bff514 Mon Sep 17 00:00:00 2001 From: Veovis Date: Tue, 3 Sep 2013 19:15:39 +0200 Subject: [PATCH 1/3] FIX issue when using selectmenu on an XHTML5 page with & in text/value's options. --- ui/jquery.ui.selectmenu.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js index 49f4d2ba3f8..0fb5d75d283 100644 --- a/ui/jquery.ui.selectmenu.js +++ b/ui/jquery.ui.selectmenu.js @@ -276,7 +276,7 @@ $.widget("ui.selectmenu", { var opt = $( this ); selectOptionData.push({ value: opt.attr( 'value' ), - text: self._formatText( opt.text(), opt ), + text: self._formatText( opt.html(), opt ), selected: opt.attr( 'selected' ), disabled: opt.attr( 'disabled' ), classes: opt.attr( 'class' ), @@ -300,7 +300,7 @@ $.widget("ui.selectmenu", { thisLiAttr[ 'class' ] = 'ui-state-disabled'; } var thisAAttr = { - html: selectOptionData[ i ].text || ' ', + html: selectOptionData[ i ].text || '&#a0;', href: '#nogo', tabindex : -1, role: 'option', From 525655482671dda9f02ad2dd95e86c74d61727bd Mon Sep 17 00:00:00 2001 From: Veovis Date: Sat, 7 Sep 2013 11:25:47 +0200 Subject: [PATCH 2/3] Add a missing 'x' to specify an html entity with heca code. --- ui/jquery.ui.selectmenu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js index 0fb5d75d283..6fdb21a321c 100644 --- a/ui/jquery.ui.selectmenu.js +++ b/ui/jquery.ui.selectmenu.js @@ -300,7 +300,7 @@ $.widget("ui.selectmenu", { thisLiAttr[ 'class' ] = 'ui-state-disabled'; } var thisAAttr = { - html: selectOptionData[ i ].text || '&#a0;', + html: selectOptionData[ i ].text || ' ', href: '#nogo', tabindex : -1, role: 'option', From 5ffc9d257eae9ebab75f4327d76528fed02b0244 Mon Sep 17 00:00:00 2001 From: Veovis Date: Tue, 18 Feb 2014 12:11:31 +0100 Subject: [PATCH 3/3] selectmenu should use prop instead of attr to retrieve the actual value of the nodes. --- ui/jquery.ui.selectmenu.js | 1664 ++++++++++++++++++------------------ 1 file changed, 829 insertions(+), 835 deletions(-) diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js index 1b7592483eb..5eea5841dd7 100644 --- a/ui/jquery.ui.selectmenu.js +++ b/ui/jquery.ui.selectmenu.js @@ -1,835 +1,829 @@ - /* - * jQuery UI Selectmenu version 1.5.0pre - * - * Copyright (c) 2009-2010 filament group, http://filamentgroup.com - * Copyright (c) 2010-2013 Felix Nagel, http://www.felixnagel.com - * Licensed under the MIT (MIT-LICENSE.txt) - * - * https://github.com/fnagel/jquery-ui/wiki/Selectmenu - */ - -(function( $ ) { - -$.widget("ui.selectmenu", { - options: { - appendTo: "body", - typeAhead: 1000, - style: 'dropdown', - positionOptions: null, - width: null, - menuWidth: null, - handleWidth: 26, - maxHeight: null, - icons: null, - format: null, - escapeHtml: false, - bgImage: function() {} - }, - - _create: function() { - var self = this, o = this.options; - - // make / set unique id - var selectmenuId = this.element.uniqueId().attr( "id" ); - - // quick array of button and menu id's - this.ids = [ selectmenuId, selectmenuId + '-button', selectmenuId + '-menu' ]; - - // define safe mouseup for future toggling - this._safemouseup = true; - this.isOpen = false; - - // create menu button wrapper - this.newelement = $( '', { - 'class': 'ui-selectmenu ui-widget ui-state-default ui-corner-all', - 'id' : this.ids[ 1 ], - 'role': 'button', - 'href': '#nogo', - 'tabindex': this.element.attr( 'disabled' ) ? 1 : 0, - 'aria-haspopup': true, - 'aria-owns': this.ids[ 2 ] - }); - this.newelementWrap = $( "" ) - .append( this.newelement ) - .insertAfter( this.element ); - - // transfer tabindex - var tabindex = this.element.attr( 'tabindex' ); - if ( tabindex ) { - this.newelement.attr( 'tabindex', tabindex ); - } - - // save reference to select in data for ease in calling methods - this.newelement.data( 'selectelement', this.element ); - - // menu icon - this.selectmenuIcon = $( '' ) - .prependTo( this.newelement ); - - // append status span to button - this.newelement.prepend( '' ); - - // make associated form label trigger focus - this.element.bind({ - 'click.selectmenu': function( event ) { - self.newelement.focus(); - event.preventDefault(); - } - }); - - // click toggle for menu visibility - this.newelement - .bind( 'mousedown.selectmenu', function( event ) { - self._toggle( event, true ); - // make sure a click won't open/close instantly - if ( o.style == "popup" ) { - self._safemouseup = false; - setTimeout( function() { self._safemouseup = true; }, 300 ); - } - - event.preventDefault(); - }) - .bind( 'click.selectmenu', function( event ) { - event.preventDefault(); - }) - .bind( "keydown.selectmenu", function( event ) { - var ret = false; - switch ( event.keyCode ) { - case $.ui.keyCode.ENTER: - ret = true; - break; - case $.ui.keyCode.SPACE: - self._toggle( event ); - break; - case $.ui.keyCode.UP: - if ( event.altKey ) { - self.open( event ); - } else { - self._moveSelection( -1 ); - } - break; - case $.ui.keyCode.DOWN: - if ( event.altKey ) { - self.open( event ); - } else { - self._moveSelection( 1 ); - } - break; - case $.ui.keyCode.LEFT: - self._moveSelection( -1 ); - break; - case $.ui.keyCode.RIGHT: - self._moveSelection( 1 ); - break; - case $.ui.keyCode.TAB: - ret = true; - break; - case $.ui.keyCode.PAGE_UP: - case $.ui.keyCode.HOME: - self.index( 0 ); - break; - case $.ui.keyCode.PAGE_DOWN: - case $.ui.keyCode.END: - self.index( self._optionLis.length ); - break; - default: - ret = true; - } - return ret; - }) - .bind( 'keypress.selectmenu', function( event ) { - if ( event.which > 0 ) { - self._typeAhead( event.which, 'mouseup' ); - } - return true; - }) - .bind( 'mouseover.selectmenu', function() { - if ( !o.disabled ) $( this ).addClass( 'ui-state-hover' ); - }) - .bind( 'mouseout.selectmenu', function() { - if ( !o.disabled ) $( this ).removeClass( 'ui-state-hover' ); - }) - .bind( 'focus.selectmenu', function() { - if ( !o.disabled ) $( this ).addClass( 'ui-state-focus' ); - }) - .bind( 'blur.selectmenu', function() { - if (!o.disabled) $( this ).removeClass( 'ui-state-focus' ); - }); - - // document click closes menu - $( document ).bind( "mousedown.selectmenu-" + this.ids[ 0 ], function( event ) { - //check if open and if the clicket targes parent is the same - if ( self.isOpen && !$( event.target ).closest( "#" + self.ids[ 1 ] ).length ) { - self.close( event ); - } - }); - - // change event on original selectmenu - this.element - .bind( "click.selectmenu", function() { - self._refreshValue(); - }) - // FIXME: newelement can be null under unclear circumstances in IE8 - // TODO not sure if this is still a problem (fnagel 20.03.11) - .bind( "focus.selectmenu", function() { - if ( self.newelement ) { - self.newelement[ 0 ].focus(); - } - }); - - // set width when not set via options - if ( !o.width ) { - o.width = this.element.outerWidth(); - } - // set menu button width - this.newelement.width( o.width ); - - // hide original selectmenu element - this.element.hide(); - - // create menu portion, append to body - this.list = $( '