Skip to content

Commit af2d0e6

Browse files
committed
fixed: code clean-up and small improvements
1 parent 6e21074 commit af2d0e6

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

themes/base/jquery.ui.selectmenu.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,15 @@
66
.ui-selectmenu-menu ul { padding:0; margin:0; list-style:none; position: relative; overflow: auto; overflow-y: auto ; overflow-x: hidden; }
77
.ui-selectmenu-open { display: block; }
88
.ui-selectmenu-menu-popup { margin-top: -1px; }
9-
.ui-selectmenu-menu-dropdown { }
109
.ui-selectmenu-menu li { padding:0; margin:0; display: block; border-top: 1px dotted transparent; border-bottom: 1px dotted transparent; border-right-width: 0 !important; border-left-width: 0 !important; font-weight: normal !important; }
1110
.ui-selectmenu-menu li a,.ui-selectmenu-status { line-height: 1.4em; display: block; padding: .405em 2.1em .405em 1em; outline:none; text-decoration:none; }
1211
.ui-selectmenu-menu li.ui-state-disabled a, .ui-state-disabled { cursor: default; }
1312
.ui-selectmenu-menu li.ui-selectmenu-hasIcon a,
1413
.ui-selectmenu-hasIcon .ui-selectmenu-status { padding-left: 20px; position: relative; margin-left: 5px; }
1514
.ui-selectmenu-menu li .ui-icon, .ui-selectmenu-status .ui-icon { position: absolute; top: 1em; margin-top: -8px; left: 0; }
1615
.ui-selectmenu-status { line-height: 1.4em; }
17-
.ui-selectmenu-open li.ui-selectmenu-item-focus a { }
18-
.ui-selectmenu-open li.ui-selectmenu-item-selected { }
1916
.ui-selectmenu-menu li span,.ui-selectmenu-status span { display:block; margin-bottom: .2em; }
2017
.ui-selectmenu-menu li .ui-selectmenu-item-header { font-weight: bold; }
21-
.ui-selectmenu-menu li .ui-selectmenu-item-content { }
2218
.ui-selectmenu-menu li .ui-selectmenu-item-footer { opacity: .8; }
2319
/* for optgroups */
2420
.ui-selectmenu-menu .ui-selectmenu-group { font-size: 1em; }

ui/jquery.ui.selectmenu.js

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -280,21 +280,19 @@ $.widget("ui.selectmenu", {
280280

281281
// serialize selectmenu element options
282282
var selectOptionData = [];
283-
this.element
284-
.find('option')
285-
.each(function() {
286-
var opt = $(this);
287-
selectOptionData.push({
288-
value: opt.attr('value'),
289-
text: self._formatText(opt.text()),
290-
selected: opt.attr('selected'),
291-
disabled: opt.attr('disabled'),
292-
classes: opt.attr('class'),
293-
typeahead: opt.attr('typeahead'),
294-
parentOptGroup: opt.parent('optgroup'),
295-
bgImage: o.bgImage.call(opt)
296-
});
283+
this.element.find('option').each(function() {
284+
var opt = $(this);
285+
selectOptionData.push({
286+
value: opt.attr('value'),
287+
text: self._formatText(opt.text()),
288+
selected: opt.attr('selected'),
289+
disabled: opt.attr('disabled'),
290+
classes: opt.attr('class'),
291+
typeahead: opt.attr('typeahead'),
292+
parentOptGroup: opt.parent('optgroup'),
293+
bgImage: o.bgImage.call(opt)
297294
});
295+
});
298296

299297
// active state class is only used in popup style
300298
var activeClass = (self.options.style == "popup") ? " ui-state-active" : "";
@@ -478,7 +476,6 @@ $.widget("ui.selectmenu", {
478476
_typeAhead: function( code, eventType ) {
479477
var self = this,
480478
c = String.fromCharCode(code).toLowerCase(),
481-
items = this.list.find( 'li a' ),
482479
matchee = null,
483480
nextIndex = null;
484481

@@ -516,11 +513,10 @@ $.widget("ui.selectmenu", {
516513
this._selectedOptionLi().data('index') :
517514
this._focusedOptionLi().data('index')) || 0;
518515

519-
for (var i = 0; i < items.length; i++) {
520-
var thisText = items.eq(i).text().substr(0, matchee.length).toLowerCase();
516+
for (var i = 0; i < this._optionLis.length; i++) {
517+
var thisText = this._optionLis.eq(i).text().substr(0, matchee.length).toLowerCase();
521518

522519
if ( thisText === matchee ) {
523-
524520
if ( self._typeAhead_cycling ) {
525521
if ( nextIndex === null )
526522
nextIndex = i;
@@ -540,7 +536,7 @@ $.widget("ui.selectmenu", {
540536
// index? Because we don't what is the exact action to do, it
541537
// depends if the user is typing on the element or on the popped
542538
// up menu
543-
items.eq(nextIndex).trigger( eventType );
539+
this._optionLis.eq(nextIndex).find("a").trigger( eventType );
544540
}
545541

546542
self._typeAhead_timer = window.setTimeout(function() {
@@ -714,7 +710,7 @@ $.widget("ui.selectmenu", {
714710
},
715711

716712
_scrollPage: function(direction) {
717-
var numPerPage = Math.floor(this.list.outerHeight() / this.list.find('li:first').outerHeight());
713+
var numPerPage = Math.floor(this.list.outerHeight() / this._optionLis.first().outerHeight());
718714
numPerPage = (direction == 'up' ? -numPerPage : numPerPage);
719715
this._moveFocus(numPerPage);
720716
},

0 commit comments

Comments
 (0)