Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #7 from schourode/master

A few changes to yaselect, most related to IE7 issues
  • Loading branch information...
commit beb671dd4816238606e1cfe0ae5021afbaae0b2d 2 parents 6684674 + 3bfcbdf
@choonkeat authored
Showing with 10 additions and 10 deletions.
  1. +2 −2 demo/index.html
  2. +5 −5 jquery.yaselect.js
  3. +3 −3 jquery.yaselect.min.js
View
4 demo/index.html
@@ -16,8 +16,8 @@
.yaselect-wrap, .yaselect-current { cursor: pointer; display: block; }
.yaselect-wrap, .yaselect-current, .yaselect-select { width: 300px; font-size: 15px; }
.yaselect-select { margin-top: 0; padding-top: 0; }
- .yaselect-close { background: url('googlechrome-arrowdown.png') no-repeat 100% 50%; }
- .yaselect-open { background: url('googlechrome-arrowup.png') no-repeat 100% 50%; }
+ .yaselect-current { background: url('googlechrome-arrowdown.png') no-repeat 100% 50%; }
+ .yaselect-open .yaselect-current { background-image: url('googlechrome-arrowup.png'); }
</style>
</head>
<body>
View
10 jquery.yaselect.js
@@ -16,13 +16,13 @@ jQuery.fn.yaselect = function(options) {
options = options || {};
return this.each(function(index, select) {
var jselect = jQuery(select).css({position:'absolute',top:0,left:0,zIndex:1}).addClass('yaselect-select'),
- wrap = jQuery('<div class="yaselect-wrap yaselect-open" tabindex="0"><div class="yaselect-current"></div></div>'),
+ wrap = jQuery('<div class="yaselect-wrap" tabindex="0"><div class="yaselect-current"></div></div>'),
anchor = wrap.wrap('<div class="yaselect-anchor" style="position:relative;"></div>').parent(),
+ toggle = function() { anchor.toggleClass('yaselect-open', jselect.is(':visible')); },
gettext = function() { return jselect.find('option:nth(' + (select.selectedIndex || 0) + ')').text(); },
curr = wrap.find('.yaselect-current').text(gettext()),
confirm = function(to_focus_wrap) { jselect.blur(); curr.text(gettext()); jselect.css({top: wrap.outerHeight()}); if (to_focus_wrap) wrap.focus(); };
if (options.hoverOnly || window.navigator && navigator.userAgent.match(/iphone|ipod|ipad/i)) {
- wrap.toggleClass('yaselect-open yaselect-close');
return jselect /* becomes invisible and is placed above wrapper to receive screen tap -- triggering native <select> */
.before(anchor)
.css({opacity: 0.001})
@@ -33,11 +33,11 @@ jQuery.fn.yaselect = function(options) {
.before(anchor)
.keydown(function(e) { if (e.which==13||e.which==32) { e.preventDefault(); confirm(true); } })
.change(function(e) { curr.text(gettext()); })
- .blur(function(e) { jselect.hide(); wrap.toggleClass('yaselect-open yaselect-close'); })
+ .blur(function(e) { jselect.hide(); toggle(); })
.click(function(e) {
if (jselect.is(':hidden')) {
- wrap.toggleClass('yaselect-open yaselect-close');
jselect.show();
+ toggle();
setTimeout(function() { jselect.focus(); }); /* avoid trampling confusion with triggered blur */
} else {
confirm(true);
@@ -47,7 +47,7 @@ jQuery.fn.yaselect = function(options) {
wrap
.mousedown(function(e) { jselect.click(); })
.keydown(function(e) { if ([13,32,37,38,39,40].indexOf(e.which) != -1) { e.preventDefault(); jselect.click(); } }); /* preventDefault avoid pagescroll */
- select.size = options.size || 5;
+ select.size = Math.min(select.options.length, options.size || 10);
confirm();
});
}
View
6 jquery.yaselect.min.js
@@ -1,3 +1,3 @@
-jQuery.fn.yaselect=function(d){d=d||{};return this.each(function(j,g){var a=jQuery(g).css({position:"absolute",top:0,left:0,zIndex:1}).addClass("yaselect-select"),b=jQuery('<div class="yaselect-wrap yaselect-open" tabindex="0"><div class="yaselect-current"></div></div>'),e=b.wrap('<div class="yaselect-anchor" style="position:relative;"></div>').parent(),f=function(){return a.find("option:nth("+(g.selectedIndex||0)+")").text()},h=b.find(".yaselect-current").text(f()),i=function(c){a.blur();h.text(f());
-a.css({top:b.outerHeight()});c&&b.focus()};if(d.hoverOnly||window.navigator&&navigator.userAgent.match(/iphone|ipod|ipad/i)){b.toggleClass("yaselect-open yaselect-close");return a.before(e).css({opacity:0.0010}).change(function(){h.text(f())}).appendTo(e)}a.before(e).keydown(function(c){if(c.which==13||c.which==32){c.preventDefault();i(true)}}).change(function(){h.text(f())}).blur(function(){a.hide();b.toggleClass("yaselect-open yaselect-close")}).click(function(){if(a.is(":hidden")){b.toggleClass("yaselect-open yaselect-close");
-a.show();setTimeout(function(){a.focus()})}else i(true)}).appendTo(e);b.mousedown(function(){a.click()}).keydown(function(c){if([13,32,37,38,39,40].indexOf(c.which)!=-1){c.preventDefault();a.click()}});g.size=d.size||5;i()})};
+jQuery.fn.yaselect=function(d){d=d||{};return this.each(function(k,e){var a=jQuery(e).css({position:"absolute",top:0,left:0,zIndex:1}).addClass("yaselect-select"),b=jQuery('<div class="yaselect-wrap" tabindex="0"><div class="yaselect-current"></div></div>'),c=b.wrap('<div class="yaselect-anchor" style="position:relative;"></div>').parent(),i=function(){c.toggleClass("yaselect-open",a.is(":visible"))},f=function(){return a.find("option:nth("+(e.selectedIndex||0)+")").text()},g=b.find(".yaselect-current").text(f()),
+h=function(j){a.blur();g.text(f());a.css({top:b.outerHeight()});j&&b.focus()};if(d.hoverOnly||window.navigator&&navigator.userAgent.match(/iphone|ipod|ipad/i))return a.before(c).css({opacity:0.001}).change(function(){g.text(f())}).appendTo(c);a.before(c).keydown(function(a){if(a.which==13||a.which==32)a.preventDefault(),h(!0)}).change(function(){g.text(f())}).blur(function(){a.hide();i()}).click(function(){a.is(":hidden")?(a.show(),i(),setTimeout(function(){a.focus()})):h(!0)}).appendTo(c);b.mousedown(function(){a.click()}).keydown(function(b){[13,
+32,37,38,39,40].indexOf(b.which)!=-1&&(b.preventDefault(),a.click())});e.size=Math.min(e.options.length,d.size||10);h()})};
Please sign in to comment.
Something went wrong with that request. Please try again.