Skip to content

Commit

Permalink
#2; going to drop support of jq lt 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
jslayer committed May 7, 2013
1 parent 1b7fa56 commit df0f806
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Yet another combobox plugin. Were developed for my own purposes and successfully

##Features

* works with jQuery 1.3.2+
* works with jQuery 1.9+

##Usage

Expand Down
38 changes: 20 additions & 18 deletions combobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@
switch(e.which) {
case 38:
if (index > 0) {
$options.eq(index - 1).attr('selected', 'selected');
$options.eq(index - 1).prop('selected', 'selected');
self.$element.change();
}
break;
case 40:
if (index < $options.length) {
$options.eq(index + 1).attr('selected', 'selected');
$options.eq(index + 1).prop('selected', 'selected');
self.$element.change();
}
break;
Expand All @@ -136,19 +136,19 @@
index = index == -1 ? 1 : index;
index = (index > $options.length - 1) ? $options.length - 1 : index;
if (!ctrl) {
$options.attr('selected', null);
$options.prop('selected', null);
}
$options.eq(index - 1).attr('selected', 'selected');
$options.eq(index - 1).prop('selected', 'selected');
self.$element.change();
break;
case 40:
index = $options.index($options.filter(':selected').last());
index = index == -1 ? -1 : index;
index = (index >= $options.length - 1) ? -1 : index;
if (!ctrl) {
$options.attr('selected', null);
$options.prop('selected', null);
}
$options.eq(index + 1).attr('selected', 'selected');
$options.eq(index + 1).prop('selected', 'selected');
self.$element.change();
break;
}
Expand Down Expand Up @@ -187,7 +187,7 @@
display: 'inline-block',
width: self.width,
height: self.height
}).attr('tabindex', 0);
}).prop('tabindex', 0);
self.button.css({
width: self.btnWidth,
height: self.height,
Expand All @@ -206,7 +206,7 @@
else {
self._list.style.display = 'inline-block';
self._list.style.width = self.width + 'px';
self.list.attr('tabindex', 0);
self.list.prop('tabindex', 0);
}

if (!self.multiple) {
Expand Down Expand Up @@ -294,7 +294,7 @@

//if group have options
if ($options.length > 0) {
var label = $optgroup.attr('label');
var label = $optgroup.prop('label');
if (label != undefined) {
_html += '<li class="'+ self.options.classes.groupLabel +'">' + label + '</li>';
}
Expand Down Expand Up @@ -339,9 +339,9 @@
}
this.mouseenter_inited = true;

$children.hover(function() {
$children.mouseover(function() {
$(this).addClass(self.options.classes.itemHover);
}, function(){
}).mouseout(function(){
$(this).removeClass(self.options.classes.itemHover);
});
});
Expand Down Expand Up @@ -377,14 +377,14 @@
index = firstIndex;
firstIndex = e.target.combobox_index;
}
children.attr('selected', false).slice(firstIndex, index + 1).attr('selected', 'selected');
children.prop('selected', null).slice(firstIndex, index + 1).prop('selected', 'selected');
}
else if (self.multiple){
children.filter(':selected').attr('selected', null);
children.eq(e.target.combobox_index).attr('selected', 'selected');
children.filter(':selected').prop('selected', null);
children.eq(e.target.combobox_index).prop('selected', 'selected');
}
else {
children.eq(e.target.combobox_index).attr('selected', 'selected');
children.eq(e.target.combobox_index).prop('selected', 'selected');
}

self.$element.change();
Expand All @@ -402,7 +402,9 @@
$children = !self.groups ? self.list.find('li') : self.list.find('li').not('.' + self.options.classes.groupLabel).not('.' + self.options.classes.group),
$selected = self.$element.find('option').filter(':selected'),
selectedText;


//debugger;

if (!self.multiple) {
selectedText = $selected.text();
self.selected.text(typeof self.options.filter == 'function' ? self.options.filter('selected', selectedText) : selectedText);
Expand All @@ -422,7 +424,7 @@
});
}
else {
self.value = $selected.attr('value');
self.value = $selected.prop('value');
$children.eq($selected.get(0).index).addClass(self.options.classes.itemActive);
}
}
Expand Down Expand Up @@ -564,7 +566,7 @@
return self;
},
isDisabled: function() {
var dValue = this.$element.attr('disabled');
var dValue = this.$element.prop('disabled');
return (dValue === 'disabled' || dValue == true) ? true : false;
},
updateDisabled: function() {
Expand Down
4 changes: 2 additions & 2 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="UTF-8">
<title>jQuery Combobox Plugin: Demo page</title>
<link href="css/combobox.css" rel="stylesheet" type="text/css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<script src="combobox.js"></script>
<script>
$(function() {
Expand All @@ -27,7 +27,7 @@
});
$('#select3').combobox({});
$('#select4').combobox({});

$('#select5').combobox({}).bind('update_position', function(e, offset) {
offset.left += 5;
});
Expand Down

0 comments on commit df0f806

Please sign in to comment.