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

Bootstrap version to 4.0.0-alpha.5 support #143

Open
wants to merge 1 commit 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
2 changes: 1 addition & 1 deletion css/bootstrap-toggle.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

.checkbox label .toggle,
.checkbox-inline .toggle {
margin-left: -20px;
margin-left: 0px;
margin-right: 5px;
}

Expand Down
2 changes: 1 addition & 1 deletion css/bootstrap-toggle.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright 2014 Min Hur, The New York Times Company
* Licensed under MIT
* ======================================================================== */
.checkbox label .toggle,.checkbox-inline .toggle{margin-left:-20px;margin-right:5px}
.checkbox label .toggle,.checkbox-inline .toggle{margin-left:0px;margin-right:5px}
.toggle{position:relative;overflow:hidden}
.toggle input[type=checkbox]{display:none}
.toggle-group{position:absolute;width:200%;top:0;bottom:0;left:0;transition:left .35s;-webkit-transition:left .35s;-moz-user-select:none;-webkit-user-select:none}
Expand Down
6 changes: 0 additions & 6 deletions doc/stylesheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ nav.navbar {
#navbar {
margin: 0px;
}
#navbar .navbar-nav li iframe {
margin-top: 15px;
}
#navbar .navbar-nav li:last-child iframe {
margin-right: 15px;
}

@media screen and (max-width: 767px) {
#navbar .navbar-nav li iframe {
Expand Down
71 changes: 34 additions & 37 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,35 @@
<title>Bootstrap Toggle</title>
<link rel="canonical" href="http://www.bootstraptoggle.com">
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/styles/github.min.css" rel="stylesheet" >
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<link href="css/bootstrap-toggle.css" rel="stylesheet">
<link href="doc/stylesheet.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
</head>
<body>
<header>
<nav class="navbar navbar-default container" role="navigation">
<nav class="navbar navbar-light bg-faded container" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<button class="navbar-toggler collapsed float-xs-right hidden-md-up" type="button" data-toggle="collapse" data-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation"></button>
<div id="navbar" class="collapse navbar-toggleable-md">
<a class="navbar-brand" href="#">Bootstrap Toggle</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="#usage">Usage</a></li>
<li><a href="#api">API</a></li>
<li><a href="#events">Events</a></li>
<li><a href="#demos">Demos</a></li>
<li><a href="https://github.com/minhur/bootstrap-toggle/issues">Issues</a></li>
<li><a href="https://github.com/minhur/bootstrap-toggle/archive/master.zip">Download</a></li>
<li>
<iframe src="https://mdo.github.io/github-buttons/github-btn.html?user=minhur&repo=bootstrap-toggle&type=watch" allowtransparency="true" frameborder="0" scrolling="0" width="62" height="20"></iframe>
<ul class="nav navbar-nav float-lg-right">
<li class="nav-item"><a href="#usage" class="nav-link">Usage</a></li>
<li class="nav-item"><a href="#api" class="nav-link">API</a></li>
<li class="nav-item"><a href="#events" class="nav-link">Events</a></li>
<li class="nav-item"><a href="#demos" class="nav-link">Demos</a></li>
<li class="nav-item"><a href="https://github.com/minhur/bootstrap-toggle/issues" class="nav-link">Issues</a></li>
<li class="nav-item"><a href="https://github.com/minhur/bootstrap-toggle/archive/master.zip" class="nav-link">Download</a></li>
<li class="nav-item">
<a href="#" class="nav-link">
<iframe src="https://mdo.github.io/github-buttons/github-btn.html?user=minhur&repo=bootstrap-toggle&type=watch" allowtransparency="true" frameborder="0" scrolling="0" width="62" height="20"></iframe>
</a>
</li>
<li>
<iframe src="https://mdo.github.io/github-buttons/github-btn.html?user=minhur&repo=bootstrap-toggle&type=fork" allowtransparency="true" frameborder="0" scrolling="0" width="53" height="20"></iframe>
<li class="nav-item">
<a href="#" class="nav-link">
<iframe src="https://mdo.github.io/github-buttons/github-btn.html?user=minhur&repo=bootstrap-toggle&type=fork" allowtransparency="true" frameborder="0" scrolling="0" width="53" height="20"></iframe>
</a>
</li>
</ul>
</div>
Expand All @@ -68,7 +65,7 @@ <h2>Getting Started</h2>
<hr>
<h3>Installation</h3>
<p>You can <a href="https://github.com/minhur/bootstrap-toggle/archive/master.zip">download</a> the latest version of Bootstrap Toggle or use CDN to load the library.</p>
<p><span class="label label-warning">Warning</span> If you are using Bootstrap v2.3.2, use <code>bootstrap2-toggle.min.js</code> and <code>bootstrap2-toggle.min.css</code> instead.</p>
<p><span class="tag tag-warning">Warning</span> If you are using Bootstrap v2.3.2, use <code>bootstrap2-toggle.min.js</code> and <code>bootstrap2-toggle.min.css</code> instead.</p>
<code class="highlight">&lt;link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet"&gt;
&lt;script src="https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js"&gt;&lt;/script&gt;</code>

Expand Down Expand Up @@ -184,16 +181,16 @@ <h3>Options</h3>
<td>string</td>
<td><code>"primary"</code></td>
<td>
Style of the <em>on</em> toggle.<br>Possible values are:<code>default</code>,<code>primary</code>,<code>success</code>,<code>info</code>,<code>warning</code>,<code>danger</code><br>
Style of the <em>on</em> toggle.<br>Possible values are:<code>secondary</code>,<code>primary</code>,<code>success</code>,<code>info</code>,<code>warning</code>,<code>danger</code><br>
Refer to Bootstrap <a href="http://getbootstrap.com/css/#buttons-options" target="_blank">Button Options</a> documentation for more information.
</td>
</tr>
<tr>
<td>offstyle</td>
<td>string</td>
<td><code>"default"</code></td>
<td><code>"secondary"</code></td>
<td>
Style of the <em>off</em> toggle.<br>Possible values are:<code>default</code>,<code>primary</code>,<code>success</code>,<code>info</code>,<code>warning</code>,<code>danger</code><br>
Style of the <em>off</em> toggle.<br>Possible values are:<code>secondary</code>,<code>primary</code>,<code>success</code>,<code>info</code>,<code>warning</code>,<code>danger</code><br>
Refer to Bootstrap <a href="http://getbootstrap.com/css/#buttons-options" target="_blank">Button Options</a> documentation for more information.
</td>
</tr>
Expand Down Expand Up @@ -245,43 +242,43 @@ <h3>Methods</h3>
<td><em>initialize</em></td>
<td><code>$('#toggle-demo').bootstrapToggle()</code></td>
<td>Initializes the toggle plugin with options</td>
<td><button class="btn btn-default btn-xs" onclick="demo.init('#toggle-demo')">Initialize</button></td>
<td><button class="btn btn-secondary btn-xs" onclick="demo.init('#toggle-demo')">Initialize</button></td>
</tr>
<tr>
<td>destroy</td>
<td><code>$('#toggle-demo').bootstrapToggle('destroy')</code></td>
<td>Destroys the toggle</td>
<td><button class="btn btn-default btn-xs" onclick="demo.destroy('#toggle-demo')">Destroy</button></td>
<td><button class="btn btn-secondary btn-xs" onclick="demo.destroy('#toggle-demo')">Destroy</button></td>
</tr>
<tr>
<td>on</td>
<td><code>$('#toggle-demo').bootstrapToggle('on')</code></td>
<td>Sets the toggle to 'On' state</td>
<td><button class="btn btn-default btn-xs" onclick="demo.on('#toggle-demo')">On</button></td>
<td><button class="btn btn-secondary btn-xs" onclick="demo.on('#toggle-demo')">On</button></td>
</tr>
<tr>
<td>off</td>
<td><code>$('#toggle-demo').bootstrapToggle('off')</code></td>
<td>Sets the toggle to 'Off' state</td>
<td><button class="btn btn-default btn-xs" onclick="demo.off('#toggle-demo')">Off</button></td>
<td><button class="btn btn-secondary btn-xs" onclick="demo.off('#toggle-demo')">Off</button></td>
</tr>
<tr>
<td>toggle</td>
<td><code>$('#toggle-demo').bootstrapToggle('toggle')</code></td>
<td>Toggles the state of the toggle</td>
<td><button class="btn btn-default btn-xs" onclick="demo.toggle('#toggle-demo')">Toggle</button></td>
<td><button class="btn btn-secondary btn-xs" onclick="demo.toggle('#toggle-demo')">Toggle</button></td>
</tr>
<tr>
<td>enable</td>
<td><code>$('#toggle-demo').bootstrapToggle('enable')</code></td>
<td>Enables the toggle</td>
<td><button class="btn btn-default btn-xs" onclick="demo.enable('#toggle-demo')">Enable</button></td>
<td><button class="btn btn-secondary btn-xs" onclick="demo.enable('#toggle-demo')">Enable</button></td>
</tr>
<tr>
<td>disable</td>
<td><code>$('#toggle-demo').bootstrapToggle('disable')</code></td>
<td>Disables the toggle</td>
<td><button class="btn btn-default btn-xs" onclick="demo.disable('#toggle-demo')">Disable</button></td>
<td><button class="btn btn-secondary btn-xs" onclick="demo.disable('#toggle-demo')">Disable</button></td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -321,7 +318,7 @@ <h3>API vs Input</h3>
$('#toggle-trigger').bootstrapToggle('on')
}
function toggleOff() {
$('#toggle-trigger').bootstrapToggle('off')
$('#toggle-trigger').bootstrapToggle('off')
}
function toggleOnByInput() {
$('#toggle-trigger').prop('checked', true).change()
Expand All @@ -345,7 +342,7 @@ <h3>Sizes</h3>
<input type="checkbox" checked data-toggle="toggle" data-size="small">
<input type="checkbox" checked data-toggle="toggle" data-size="mini">
</div>

<h3>Custom Sizes</h3>
<p>Bootstrap toggle can handle custom sizes by <code>data-width</code> and <code>data-height</code> options.</p>
<div class="example">
Expand All @@ -362,7 +359,7 @@ <h3>Colors</h3>
<input type="checkbox" checked data-toggle="toggle" data-onstyle="info">
<input type="checkbox" checked data-toggle="toggle" data-onstyle="warning">
<input type="checkbox" checked data-toggle="toggle" data-onstyle="danger">
<input type="checkbox" checked data-toggle="toggle" data-onstyle="default">
<input type="checkbox" checked data-toggle="toggle" data-onstyle="secondary">
</div>

<h3>Colors Mix</h3>
Expand Down Expand Up @@ -435,7 +432,7 @@ <h3>Animation Speed</h3>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/highlight.min.js"></script>
<script src="doc/script.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js"></script>
<script src="js/bootstrap-toggle.js"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
Expand Down
6 changes: 4 additions & 2 deletions js/bootstrap-toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
on: 'On',
off: 'Off',
onstyle: 'primary',
offstyle: 'default',
offstyle: 'secondary',
size: 'normal',
style: '',
width: null,
Expand Down Expand Up @@ -56,7 +56,7 @@
.addClass(this._onstyle + ' ' + size)
var $toggleOff = $('<label class="btn">').html(this.options.off)
.addClass(this._offstyle + ' ' + size + ' active')
var $toggleHandle = $('<span class="toggle-handle btn btn-default">')
var $toggleHandle = $('<span class="toggle-handle btn btn-secondary">')
.addClass(size)
var $toggleGroup = $('<div class="toggle-group">')
.append($toggleOn, $toggleOff, $toggleHandle)
Expand Down Expand Up @@ -106,11 +106,13 @@
}

Toggle.prototype.enable = function () {
this.$toggle.removeClass('disabled')
this.$toggle.removeAttr('disabled')
this.$element.prop('disabled', false)
}

Toggle.prototype.disable = function () {
this.$toggle.addClass('disabled')
this.$toggle.attr('disabled', 'disabled')
this.$element.prop('disabled', true)
}
Expand Down
2 changes: 1 addition & 1 deletion js/bootstrap-toggle.min.js

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