Skip to content

Commit c2680cb

Browse files
author
Ron Lussier
committed
Added support for 'copyClasses' option
Added support for the new 'copyClasses' option. This option allows a user to specify if they would like the native select box class(s) to be copied over to the drop down container (which holds both the drop down button and drop down list) (with value 'container') or the drop down button (with the default value 'button'). The option also takes the value 'none' to indicate that native classes should not be copied to the SelectBoxIt object.
1 parent 4b2bc40 commit c2680cb

File tree

3 files changed

+226
-129
lines changed

3 files changed

+226
-129
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
node_modules
1+
node_modules
2+
.DS_Store

src/javascripts/jquery.selectBoxIt.core.js

+35-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@
9999

100100
"rel"
101101

102-
]
102+
],
103+
104+
// **copyClasses**: HTML classes that will be copied over to the new drop down. The value indicates where the classes should be copied. The default value is 'button', but you can also use 'container' (recommended) or 'none'.
105+
"copyClasses": "button"
103106

104107
},
105108

@@ -343,7 +346,7 @@
343346
// Dynamically sets the dropdown `id` attribute
344347
"id": originalElemId && originalElemId + "SelectBoxIt",
345348

346-
"class": "selectboxit" + " " + (self.selectBox.attr("class") || ""),
349+
"class": "selectboxit",
347350

348351
// Sets the dropdown `name` attribute to be the same name as the original select box
349352
"name": self.originalElem.name,
@@ -371,6 +374,36 @@
371374
// Appends the inner dropdown list dropdown element to the dropdown list container dropdown element
372375
append(self.dropdown);
373376

377+
self._copyClasses();
378+
379+
// Maintains chainability
380+
return self;
381+
382+
},
383+
384+
// _Create dropdown
385+
// ------------
386+
// Copies the classes to the appropriate container
387+
_copyClasses: function() {
388+
389+
var self = this,
390+
391+
copyClasses = self.options["copyClasses"];
392+
393+
switch (copyClasses) {
394+
case "container":
395+
self.dropdownContainer.addClass(self.selectBox.attr("class"));
396+
break;
397+
398+
case "none":
399+
break;
400+
401+
case "button":
402+
default:
403+
self.dropdown.addClass(self.selectBox.attr("class"));
404+
break;
405+
}
406+
374407
// Maintains chainability
375408
return self;
376409

0 commit comments

Comments
 (0)