Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Toggler(button, toggleElement) {
- this.toggleElement = toggleElement;
- this.showing = true;
- button.addEventListener('click', this.onToggleButtonClick.bind(this), false);
- }
- Toggler.prototype.onToggleButtonClick = function(e) {
- this.toggle();
- }
- Toggle.prototype.toggle = function() {
- if(this.showing) {
- this.hide();
- } else {
- this.show();
- }
- }
- Toggle.prototype.show = function() {
- this.toggleElement.classList.remove('hide');
- this.showing = true;
- }
- Toggle.prototype.hide = function() {
- this.toggleElement.classList.add('hide');
- this.showing = false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement