From 55a257ddbafec204aa3ce483069a35a04df636e3 Mon Sep 17 00:00:00 2001 From: Justin DuJardin Date: Wed, 28 Mar 2012 10:22:02 -0700 Subject: [PATCH] Better extract width style from inline element : - Match floating point numbers as well as integers (e.g. "width:99.5%") - Strip all string spaces, to match styles specified with variable spacing (e.g. " width: 5em ;") --- select2.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/select2.js b/select2.js index 91e726d4..63655757 100755 --- a/select2.js +++ b/select2.js @@ -607,8 +607,8 @@ var style = this.opts.element.attr('style'); var attrs = style.split(';'); for (var i = 0; i < attrs.length; i++) { - var attr = attrs[i].trim(); - var matches = attr.match(/width:(([0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/); + var matches = attrs[i].replace(/\s/g,'') + .match(/width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/); if(matches == null || matches.length < 1) continue; return matches[1]; @@ -827,6 +827,14 @@ this.search.val(""); }; + SingleSelect2.prototype.alignDropdown = function () { + this.parent.alignDropdown.apply(this,arguments); + this.results.css({ + 'margin-top': this.search.height() + }); + }; + + function MultiSelect2(opts) { }