Skip to content

Instantly share code, notes, and snippets.

@jakecraige
Last active August 29, 2015 14:05
Show Gist options
  • Save jakecraige/b1b0d0e23c1de2a34ed3 to your computer and use it in GitHub Desktop.
Save jakecraige/b1b0d0e23c1de2a34ed3 to your computer and use it in GitHub Desktop.
{{input type="checkbox" checked=value name="onoffswitch" class="onoffswitch-checkbox"}}
<label class="onoffswitch-label" for="myonoffswitch">
<div class="onoffswitch-inner"></div>
<div class="onoffswitch-switch"></div>
</label>
export default Ember.Component.extend({
classNames: 'onoffswitch',
didInsertElement: function() {
return this.$switch = this.$('.onoffswitch-checkbox');
},
click: function() {
return this.$switch.prop('checked', !this.$switch.prop('checked')).change();
}
});
.onoffswitch {
position: relative; width: 60px;
-webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
}
.onoffswitch-checkbox {
display: none;
}
.onoffswitch-label {
-webkit-transform: translateZ(0);
display: block; overflow: hidden; cursor: pointer;
border: 2px solid #FFFFFF; border-radius: 50px;
}
.onoffswitch-inner {
width: 200%; margin-left: -100%;
-webkit-transition: margin 0.15s ease-in 0s;
transition: margin 0.15s ease-in 0s;
}
.onoffswitch-inner:before, .onoffswitch-inner:after {
float: left; width: 50%; height: 32px; padding: 0; line-height: 32px;
font-size: 14px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;
-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
}
.onoffswitch-inner:before {
content: "";
padding-left: 15px;
background-color: #F05937; color: #FFFFFF;
}
.onoffswitch-inner:after {
content: "";
padding-right: 15px;
background-color: #D4D8D9; color: #666666;
text-align: right;
}
.onoffswitch-switch {
width: 26px; margin: 4px;
background: #FFFFFF;
border: 2px solid #FFFFFF; border-radius: 50px;
position: absolute; top: 0; bottom: 0; right: 24px;
-webkit-transition: all 0.15s ease-in 0s;
transition: all 0.15s ease-in 0s;
-webkit-box-shadow: 0px 0px 4px 0px rgba(0,0,0,0.35), 0px 3px 2px 0px rgba(0,0,0,0.10);
box-shadow: 0px 0px 4px 0px rgba(0,0,0,0.35), 0px 3px 2px 0px rgba(0,0,0,0.10);
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
margin-left: 0;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
right: 0px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment