(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o\n \n \n \n \n \n \n
\n

' + attributes.title + '

\n
' + attributes.body + '
\n \n \n \n \n
\n ').trim(); }; var Instructor = (function () { function Instructor(rootEl) { var options = arguments[1] === undefined ? {} : arguments[1]; _classCallCheck(this, Instructor); this.rootEl = rootEl; this.instructables = this.findAllInstructables(); this.instructions = options.instructions; this.index = 0; this._makeOverlayElement(); } _createClass(Instructor, [{ key: '_makeOverlayElement', value: function _makeOverlayElement() { this.overlayElement = document.createElement('div'); this.overlayElement.classList.add('instructable-overlay'); this.overlayElement.addEventListener('click', this._clickedOverlay.bind(this)); window.addEventListener('resize', this.removeOverlay.bind(this), false); } }, { key: '_clickedOverlay', value: function _clickedOverlay(event) { event.stopPropagation(); if (event.target.classList && event.target.classList.contains('more-button')) { this.showNextInstructable(); } else { this.removeOverlay(); } } }, { key: 'findAllInstructables', value: function findAllInstructables() { return [].slice.apply(this.rootEl.querySelectorAll(selector)); } }, { key: 'showNextInstructable', value: function showNextInstructable() { var node = this.instructables[this.index]; if (node) this.show(node); if (this.index >= this.instructables.length - 1) { this.index = 0; } else { this.index++; } } }, { key: 'show', value: function show(node) { var _this = this; var attributes = this.instructions[node.dataset.instructable]; if (!attributes) { throw new Error('Instructor: No instructions found for ' + node.classList); } if (!this.overlayElement.parentNode) { this.rootEl.appendChild(this.overlayElement); } attributes.top = node.offsetTop; attributes.left = node.offsetLeft; attributes.width = node.offsetWidth; attributes.height = node.offsetHeight; this.overlayElement.innerHTML = overlayTemplate(attributes); setTimeout(function () { return _this.overlayElement.classList.add('visible'); }, 1); var wrapperEl = this.overlayElement.querySelector('.instructable-wrapper'); (0, _fitElement2['default'])(wrapperEl, node, 'left'); } }, { key: 'removeOverlay', value: function removeOverlay() { var _this2 = this; if (!this.overlayElement.classList.contains('visible')) return false; if (this.overlayElement.parentNode) { this.overlayElement.classList.remove('visible'); setTimeout(function () { _this2.overlayElement.parentNode.removeChild(_this2.overlayElement); }, 350); } } }]); return Instructor; })(); exports['default'] = Instructor; if (typeof exports !== 'undefined') window.Instructor = Instructor; module.exports = exports['default']; },{"./fit-element":1}]},{},[2]);