Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use jQuery's .prop() and add disableAutoStyle option #132

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions jquery.selectBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
this.typeTimer = null;
this.typeSearch = '';
this.isMac = navigator.platform.match(/mac/i);
options = 'object' === typeof options ? options : {};
this.options = options = 'object' === typeof options ? options : {};
this.selectElement = select;

// Disable for iOS devices (their native controls are more suitable for a touch device)
// Disable for mobile devices (their native controls are more suitable for a touch device)
if (!options.mobile && navigator.userAgent.match(/iPad|iPhone|Android|IEMobile|BlackBerry/i)) {
return false;
}
Expand Down Expand Up @@ -67,11 +67,11 @@
, self = this;

control
.width(select.outerWidth())
.width(settings.disableAutoStyle ? '' : select.outerWidth())
.addClass(select.attr('class'))
.attr('title', select.attr('title') || '')
.attr('tabindex', tabIndex)
.css('display', 'inline-block')
.css('display', settings.disableAutoStyle ? '' : 'inline-block')
.bind('focus.selectBox', function () {
if (this !== document.activeElement && document.body !== document.activeElement) {
$(document.activeElement).blur();
Expand Down Expand Up @@ -209,7 +209,7 @@
- (parseInt(label.css('paddingLeft')) || 0)
- (parseInt(label.css('paddingRight')) || 0);

label.width(labelWidth);
label.width(this.options.disableAutoStyle ? '' : labelWidth);
this.disableSelection(control);
}
// Store data for later use and show the control
Expand Down Expand Up @@ -1042,7 +1042,7 @@
if (self.attr('disabled')) {
li.addClass('selectBox-disabled');
}
if (self.attr('selected')) {
if (self.prop('selected')) {
li.addClass('selectBox-selected');
}
options.append(li);
Expand Down Expand Up @@ -1131,4 +1131,4 @@
return $(this);
}
});
})(jQuery);
})(jQuery);
13 changes: 7 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ $('select').selectBox({

## Settings

| Key | Default | Values | Description |
| ---------------|:-------------:|---------------------------:|-------------------------------------------------:|
| mobile | `false` | Boolean | Disables the widget for mobile devices |
| menuTransition | `default` | `default`, `slide`, `fade` | The show/hide transition for dropdown menus |
| menuSpeed | `normal` | `slow`, `normal`, `fast` | The show/hide transition speed |
| loopOptions | `false` | Boolean | Flag to allow arrow keys to loop through options |
| Key | Default | Values | Description |
| --------------------|:-------------:|---------------------------:|-------------------------------------------------:|
| mobile | `false` | Boolean | Disables the widget for mobile devices |
| menuTransition | `default` | `default`, `slide`, `fade` | The show/hide transition for dropdown menus |
| menuSpeed | `normal` | `slow`, `normal`, `fast` | The show/hide transition speed |
| loopOptions | `false` | Boolean | Flag to allow arrow keys to loop through options |
| disableAutoStyle | `false` | Boolean | Disables setting inline styles |


To specify settings after the init, use this syntax:
Expand Down