var delegate = require('client/delegate'); var addLineNumbers = require('./addLineNumbers'); function CodeTabsBox(elem) { if (window.ebookType) { return; } this.elem = elem; this.translateX = 0; this.switchesElem = elem.querySelector('[data-code-tabs-switches]'); this.switchesElemItems = this.switchesElem.firstElementChild; this.arrowLeft = elem.querySelector('[data-code-tabs-left]'); this.arrowRight = elem.querySelector('[data-code-tabs-right]'); this.arrowLeft.onclick = function(e) { e.preventDefault(); this.translateX = Math.max(0, this.translateX - this.switchesElem.offsetWidth); this.renderTranslate(); }.bind(this); this.arrowRight.onclick = function(e) { e.preventDefault(); this.translateX = Math.min(this.translateX +this.switchesElem.offsetWidth, this.switchesElemItems.offsetWidth - this.switchesElem.offsetWidth); this.renderTranslate(); }.bind(this); this.delegate('.code-tabs__switch', 'click', this.onSwitchClick); } CodeTabsBox.prototype.onSwitchClick = function(e) { e.preventDefault(); var siblings = e.delegateTarget.parentNode.children; var tabs = this.elem.querySelector('[data-code-tabs-content]').children; var selectedIndex; for(var i=0; i