Skip to content
This repository has been archived by the owner on Nov 12, 2023. It is now read-only.

Commit

Permalink
Fixed minhur#106 in bootstrap v2 and v3
Browse files Browse the repository at this point in the history
  • Loading branch information
franklx committed Jan 22, 2017
1 parent b76c094 commit 3376c75
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 19 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bootstrap-toggle",
"description": "Bootstrap Toggle is a highly flexible Bootstrap plugin that converts checkboxes into toggles",
"version": "2.2.1",
"version": "2.2.2",
"keywords": [
"bootstrap",
"toggle",
Expand Down
2 changes: 1 addition & 1 deletion css/bootstrap-toggle.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*! ========================================================================
* Bootstrap Toggle: bootstrap-toggle.css v2.2.0
* Bootstrap Toggle: bootstrap-toggle.css v2.2.2
* http://www.bootstraptoggle.com
* ========================================================================
* Copyright 2014 Min Hur, The New York Times Company
Expand Down
4 changes: 2 additions & 2 deletions css/bootstrap-toggle.min.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*! ========================================================================
* Bootstrap Toggle: bootstrap-toggle.css v2.2.0
* Bootstrap Toggle: bootstrap-toggle.css v2.2.2
* http://www.bootstraptoggle.com
* ========================================================================
* Copyright 2014 Min Hur, The New York Times Company
Expand All @@ -25,4 +25,4 @@
.toggle-off.btn-sm{padding-left:20px}
.toggle.btn-xs{min-width:35px;min-height:22px}
.toggle-on.btn-xs{padding-right:12px}
.toggle-off.btn-xs{padding-left:12px}
.toggle-off.btn-xs{padding-left:12px}
2 changes: 1 addition & 1 deletion css/bootstrap2-toggle.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*! ========================================================================
* Bootstrap Toggle: bootstrap2-toggle.css v2.2.0
* Bootstrap Toggle: bootstrap2-toggle.css v2.2.2
* http://www.bootstraptoggle.com
* ========================================================================
* Copyright 2014 Min Hur, The New York Times Company
Expand Down
4 changes: 2 additions & 2 deletions css/bootstrap2-toggle.min.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*! ========================================================================
* Bootstrap Toggle: bootstrap2-toggle.css v2.2.0
* Bootstrap Toggle: bootstrap2-toggle.css v2.2.2
* http://www.bootstraptoggle.com
* ========================================================================
* Copyright 2014 Min Hur, The New York Times Company
Expand All @@ -25,4 +25,4 @@ label.checkbox .toggle,label.checkbox.inline .toggle{margin-left:-20px;margin-ri
.toggle-off.btn-small{padding-left:20px}
.toggle.btn-mini{min-width:20px}
.toggle-on.btn-mini{padding-right:12px}
.toggle-off.btn-mini{padding-left:12px}
.toggle-off.btn-mini{padding-left:12px}
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ <h3>Animation Speed</h3>
<img class="nyt-logo" src="doc/nytdev.svg">
</p>
<p>Designed and built by <a href="https://github.com/minhur" target="_blank">Min Hur</a> for <a href="http://developers.nytimes.com" target="_blank">The New York Times Company</a></p>
<p>Latest Version: 2.2.0 | Code licensed under MIT</p>
<p>Latest Version: 2.2.2 | Code licensed under MIT</p>
<p>
<iframe src="https://mdo.github.io/github-buttons/github-btn.html?user=minhur&repo=bootstrap-toggle&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110" height="20"></iframe>
<iframe src="https://mdo.github.io/github-buttons/github-btn.html?user=minhur&repo=bootstrap-toggle&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="95" height="20"></iframe>
Expand All @@ -446,4 +446,4 @@ <h3>Animation Speed</h3>
ga('send', 'pageview');
</script>
</body>
</html>
</html>
33 changes: 31 additions & 2 deletions js/bootstrap-toggle.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*! ========================================================================
* Bootstrap Toggle: bootstrap-toggle.js v2.2.0
* Bootstrap Toggle: bootstrap-toggle.js v2.2.2
* http://www.bootstraptoggle.com
* ========================================================================
* Copyright 2014 Min Hur, The New York Times Company
Expand All @@ -19,7 +19,7 @@
this.render()
}

Toggle.VERSION = '2.2.0'
Toggle.VERSION = '2.2.2'

Toggle.DEFAULTS = {
on: 'On',
Expand Down Expand Up @@ -75,6 +75,34 @@

var width = this.options.width || Math.max($toggleOn.outerWidth(), $toggleOff.outerWidth())+($toggleHandle.outerWidth()/2)
var height = this.options.height || Math.max($toggleOn.outerHeight(), $toggleOff.outerHeight())
function getOuterSize(obj) {
if ($(obj).length == 0) {
return false;
}
var clone = obj.clone();
clone.css({
visibility: "hidden",
width: "",
height: "",
maxWidth: "",
maxHeight: ""
});
$("body").append(clone);
var width = clone.outerWidth();
var height = clone.outerHeight();
clone.remove();
return {
width: width,
height: height
};
}
if (width == 0 || height == 0) {
var toggleOnSize = getOuterSize($toggleOn);
var toggleOffSize = getOuterSize($toggleOff);
var toggleHandleSize = getOuterSize($toggleHandle);
width = this.options.width || Math.max(toggleOnSize.width, toggleOffSize.width) + toggleHandleSize.width / 2;
height = this.options.height || Math.max(toggleOnSize.height, toggleOffSize.height) + toggleHandleSize.height / 2;
}
$toggleOn.addClass('toggle-on')
$toggleOff.addClass('toggle-off')
this.$toggle.css({ width: width, height: height })
Expand Down Expand Up @@ -178,3 +206,4 @@
})

}(jQuery);
// vim: set ts=8 sts=8 sw=8 noet sta :
4 changes: 2 additions & 2 deletions js/bootstrap-toggle.min.js

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

Loading

0 comments on commit 3376c75

Please sign in to comment.