Created
September 24, 2013 16:17
-
-
Save lifeinafolder/6687233 to your computer and use it in GitHub Desktop.
An ember wrapper for the bootstrap-switch module.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//= require bootstrap-switch | |
UiControls = window.UiControls || Ember.Namespace.create(); | |
/** | |
* Custom iPhone style ON-OFF switch control | |
* | |
* @class | |
* @memberOf UiControls | |
* @extends Ember.View | |
* | |
* @example | |
* {{view UiControls.OnoffSwitch status="true"}} | |
*/ | |
UiControls.OnoffSwitch = Ember.View.extend({ | |
classNames: ['switch'], | |
classNameBindings: ['size'], | |
/** | |
* One of ['switch-large', 'switch-small', 'switch-mini'] | |
* @type {String} | |
*/ | |
size: null, | |
/** | |
* Status of the switch | |
* @type {Boolean} | |
*/ | |
status: false, | |
/** | |
* To disable the switch | |
* @type {Boolean} | |
*/ | |
disabled: false, | |
template: Ember.Handlebars.compile('{{view Ember.Checkbox checkedBinding="view.status" disabledBinding="view.disabled"}}'), | |
toggleState: function () { | |
this.$().bootstrapSwitch('toggleState'); | |
return this; | |
}, | |
// dont bubble clicks | |
click: function () { | |
return false; | |
}, | |
didInsertElement: function () { | |
this.$().bootstrapSwitch(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment