summaryrefslogtreecommitdiffstats
path: root/jquery.multiple.select.js
diff options
context:
space:
mode:
authorBrett Zamir <brettz9@yahoo.com>2014-06-13 17:28:12 +0800
committerBrett Zamir <brettz9@yahoo.com>2014-06-13 17:28:12 +0800
commitca535f5016aa0cce3170c3ea58b2455f672b916a (patch)
tree21ffbcfa137787b646bc2b90c2b549545bb21f06 /jquery.multiple.select.js
parentd04e7c136c570e27ccbeab209c765f537e5d21ec (diff)
downloadmultiple-select-ca535f5016aa0cce3170c3ea58b2455f672b916a.zip
multiple-select-ca535f5016aa0cce3170c3ea58b2455f672b916a.tar.gz
multiple-select-ca535f5016aa0cce3170c3ea58b2455f672b916a.tar.bz2
Put class on ms-parent div instead of ul (so title tooltip can be accessible there); allow title attribute on individual options in addition to class
Diffstat (limited to 'jquery.multiple.select.js')
-rw-r--r--jquery.multiple.select.js19
1 files changed, 14 insertions, 5 deletions
diff --git a/jquery.multiple.select.js b/jquery.multiple.select.js
index 3fc0f95..05b8880 100644
--- a/jquery.multiple.select.js
+++ b/jquery.multiple.select.js
@@ -16,8 +16,11 @@
this.$el = $el.hide();
this.options = options;
-
- this.$parent = $('<div class="ms-parent"></div>');
+ this.$parent = $('<div' + $.map(['class', 'title'], function (att) {
+ var attValue = that.$el.attr(att) || '';
+ attValue = (att === 'class' ? ('ms-parent' + (attValue ? ' ' : '')) : '') + attValue;
+ return attValue ? (' ' + att + '="' + attValue + '"') : '';
+ }).join('') + '>');
this.$choice = $('<button type="button" class="ms-choice"><span class="placeholder">' +
options.placeholder + '</span><div></div></button>');
this.$drop = $('<div class="ms-drop ' + options.position + '"></div>');
@@ -62,7 +65,7 @@
'</div>'
);
}
- html.push('<ul' + (this.$el.attr('class') ? (' class="' + this.$el.attr('class') + '"') : '') + '>');
+ html.push('<ul>');
if (this.options.selectAll && !this.options.single) {
html.push(
'<li class="ms-select-all">',
@@ -100,10 +103,16 @@
optionToHtml: function(i, elm, group, groupDisabled) {
var that = this,
$elm = $(elm),
- classValue = $elm.attr('class'),
html = [],
multiple = this.options.multiple,
- clss = (multiple || classValue) ? (' class="' + ((multiple ? 'multiple' : '') + (classValue ? ((multiple ? ' ' : '') + classValue) : '')) + '"') : '',
+ optAttributesToCopy = ['class', 'title'],
+ clss = $.map(optAttributesToCopy, function (att, i) {
+ var isMultiple = att === 'class' && multiple;
+ var attValue = $elm.attr(att) || '';
+ return (isMultiple || attValue) ?
+ (' ' + att + '="' + (isMultiple ? ('multiple' + (attValue ? ' ' : '')) : '') + attValue + '"') :
+ '';
+ }).join(''),
disabled,
type = this.options.single ? 'radio' : 'checkbox';