Skip to content

Commit 689d46e

Browse files
committed
fix minhur#16 - Change event triggered on initial render
1 parent 8a9f7fa commit 689d46e

7 files changed

+25
-25
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ <h3>Animation Speed</h3>
394394
<img class="nyt-logo" src="doc/nytdev.svg">
395395
</p>
396396
<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>
397-
<p>Latest Version: 2.0.0 | Code licensed under MIT</p>
397+
<p>Latest Version: 2.1.0 | Code licensed under MIT</p>
398398
<p>
399399
<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>
400400
<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>

js/bootstrap-toggle.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*! ========================================================================
2-
* Bootstrap Toggle: bootstrap-toggle.js v2.0.0
2+
* Bootstrap Toggle: bootstrap-toggle.js v2.1.0
33
* http://www.bootstraptoggle.com
44
* ========================================================================
55
* Copyright 2014 Min Hur, The New York Times Company
@@ -74,7 +74,7 @@
7474
$toggleOn.addClass('toggle-on')
7575
$toggleOff.addClass('toggle-off')
7676
this.$toggle.css({ width: width, height: height })
77-
this.update()
77+
this.update(true)
7878
this.trigger(true)
7979
}
8080

@@ -83,18 +83,18 @@
8383
else this.on()
8484
}
8585

86-
Toggle.prototype.on = function () {
86+
Toggle.prototype.on = function (silent) {
8787
if (this.$element.prop('disabled')) return false
8888
this.$toggle.removeClass(this._offstyle + ' off').addClass(this._onstyle)
8989
this.$element.prop('checked', true)
90-
this.trigger()
90+
if (!silent) this.trigger()
9191
}
9292

93-
Toggle.prototype.off = function () {
93+
Toggle.prototype.off = function (silent) {
9494
if (this.$element.prop('disabled')) return false
9595
this.$toggle.removeClass(this._onstyle).addClass(this._offstyle + ' off')
9696
this.$element.prop('checked', false)
97-
this.trigger()
97+
if (!silent) this.trigger()
9898
}
9999

100100
Toggle.prototype.enable = function () {
@@ -107,11 +107,11 @@
107107
this.$element.prop('disabled', true)
108108
}
109109

110-
Toggle.prototype.update = function () {
110+
Toggle.prototype.update = function (silent) {
111111
if (this.$element.prop('disabled')) this.disable()
112112
else this.enable()
113-
if (this.$element.prop('checked')) this.on()
114-
else this.off()
113+
if (this.$element.prop('checked')) this.on(silent)
114+
else this.off(silent)
115115
}
116116

117117
Toggle.prototype.trigger = function (silent) {

js/bootstrap-toggle.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/bootstrap-toggle.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/bootstrap2-toggle.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*! ========================================================================
2-
* Bootstrap Toggle: bootstrap2-toggle.js v2.0.0
2+
* Bootstrap Toggle: bootstrap2-toggle.js v2.1.0
33
* http://www.bootstraptoggle.com
44
* ========================================================================
55
* Copyright 2014 Min Hur, The New York Times Company
@@ -74,7 +74,7 @@
7474
$toggleOn.addClass('toggle-on')
7575
$toggleOff.addClass('toggle-off')
7676
this.$toggle.css({ width: width, height: height })
77-
this.update()
77+
this.update(true)
7878
this.trigger(true)
7979
}
8080

@@ -83,18 +83,18 @@
8383
else this.on()
8484
}
8585

86-
Toggle.prototype.on = function () {
86+
Toggle.prototype.on = function (silent) {
8787
if (this.$element.prop('disabled')) return false
8888
this.$toggle.removeClass(this._offstyle + ' off').addClass(this._onstyle)
8989
this.$element.prop('checked', true)
90-
this.trigger()
90+
if (!silent) this.trigger()
9191
}
9292

93-
Toggle.prototype.off = function () {
93+
Toggle.prototype.off = function (silent) {
9494
if (this.$element.prop('disabled')) return false
9595
this.$toggle.removeClass(this._onstyle).addClass(this._offstyle + ' off')
9696
this.$element.prop('checked', false)
97-
this.trigger()
97+
if (!silent) this.trigger()
9898
}
9999

100100
Toggle.prototype.enable = function () {
@@ -107,11 +107,11 @@
107107
this.$element.prop('disabled', true)
108108
}
109109

110-
Toggle.prototype.update = function () {
110+
Toggle.prototype.update = function (silent) {
111111
if (this.$element.prop('disabled')) this.disable()
112112
else this.enable()
113-
if (this.$element.prop('checked')) this.on()
114-
else this.off()
113+
if (this.$element.prop('checked')) this.on(silent)
114+
else this.off(silent)
115115
}
116116

117117
Toggle.prototype.trigger = function (silent) {

0 commit comments

Comments
 (0)