Skip to content

Commit

Permalink
Fixed #2: Add "reverse" option. Bump 1.0.14.
Browse files Browse the repository at this point in the history
  • Loading branch information
vsn4ik committed Jul 13, 2014
1 parent c731cfe commit 5aa0148
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 25 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bootstrap-checkbox",
"version": "1.0.13",
"version": "1.0.14",
"authors": [
"vsn4ik"
],
Expand Down
9 changes: 6 additions & 3 deletions dist/bootstrap-checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if (typeof jQuery === 'undefined') {
if (this.$element.closest('label').length) {
console.warn('Please do not use bootstrap-checkbox element in label element.');
return;
};
}

this.options = $.extend({}, $.fn.checkboxpicker.defaults, options, this.$element.data());

Expand All @@ -29,8 +29,11 @@ if (typeof jQuery === 'undefined') {
// .btn-group-justified works with <a> elements as the <button> doesn't pick up the styles
this.$buttons = $('<a><a>').addClass('btn');

this.$off = this.$buttons.eq(0);
this.$on = this.$buttons.eq(1);
// === '': <... data-reverse>
var reverse = this.options.reverse || this.options.reverse === '';

this.$off = this.$buttons.eq(reverse ? 1 : 0);
this.$on = this.$buttons.eq(reverse ? 0 : 1);

this.init();
}
Expand Down
18 changes: 13 additions & 5 deletions dist/bootstrap-checkbox.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions docs/dist/bootstrap-checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if (typeof jQuery === 'undefined') {
if (this.$element.closest('label').length) {
console.warn('Please do not use bootstrap-checkbox element in label element.');
return;
};
}

this.options = $.extend({}, $.fn.checkboxpicker.defaults, options, this.$element.data());

Expand All @@ -29,8 +29,11 @@ if (typeof jQuery === 'undefined') {
// .btn-group-justified works with <a> elements as the <button> doesn't pick up the styles
this.$buttons = $('<a><a>').addClass('btn');

this.$off = this.$buttons.eq(0);
this.$on = this.$buttons.eq(1);
// === '': <... data-reverse>
var reverse = this.options.reverse || this.options.reverse === '';

this.$off = this.$buttons.eq(reverse ? 1 : 0);
this.$on = this.$buttons.eq(reverse ? 0 : 1);

this.init();
}
Expand Down
18 changes: 13 additions & 5 deletions docs/dist/bootstrap-checkbox.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 25 additions & 8 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,42 +50,47 @@ <h3>Options</h3>
<tr>
<td>style</td>
<td>false | string</td>
<td><code>false</code></td>
<td>false</td>
</tr>
<tr>
<td>defaultClass</td>
<td>string</td>
<td><code>btn-default</code></td>
<td>btn-default</td>
</tr>
<tr>
<td>offClass</td>
<td>string</td>
<td><code>btn-danger</code></td>
<td>btn-danger</td>
</tr>
<tr>
<td>onClass</td>
<td>string</td>
<td><code>btn-success</code></td>
<td>btn-success</td>
</tr>
<tr>
<td>offLabel</td>
<td>string</td>
<td><code>No</code></td>
<td>No</td>
</tr>
<tr>
<td>onLabel</td>
<td>string</td>
<td><code>Yes</code></td>
<td>Yes</td>
</tr>
<tr>
<td>offTitle</td>
<td>false | string</td>
<td><code>false</code></td>
<td>false</td>
</tr>
<tr>
<td>onTitle</td>
<td>false | string</td>
<td><code>false</code></td>
<td>false</td>
</tr>
<tr>
<td>reverse</td>
<td>boolean</td>
<td>false</td>
</tr>
</tbody>
</table>
Expand All @@ -107,6 +112,18 @@ <h3 id="examples">Examples</h3>
</div>
</div>

<div class="form-group">
<div class="col-sm-3">
<input type="checkbox" data-reverse>
</div>

<div class="col-sm-9">
{% highlight html %}
<input type="checkbox" data-reverse>
{% endhighlight %}
</div>
</div>

<div class="form-group">
<div class="col-sm-3">
<input type="checkbox" disabled checked>
Expand Down

0 comments on commit 5aa0148

Please sign in to comment.