/* THE AVATAR THAT TURNS INTO A FACE. * * Dr KC's idea: show everyone as a cute NEU-style character, and let the real * photograph appear only when somebody presses it. This is the switch, and it * is deliberately generic — it drives any element marked `data-mug`, so the * founders today and the rest of the staff, and any team photograph, work the * same way tomorrow without touching this file. * * WHY A BUTTON AND NOT A HOVER. A hover does not exist on a phone, and half * the people looking at this will be on one. Pressing works everywhere, it * can be reached from a keyboard, and it can be pressed again to go back. * * The real photograph is in the markup from the start rather than swapped in * on demand: it is already public on the page, hiding it behind a fetch would * buy nothing, and a face that has to load after the press feels broken. */ (function () { 'use strict'; /* WIRING IS A FUNCTION, NOT A ONE-OFF. Backstage's opening preview replaces the hero inside its frame as the form is typed into, and the button that comes back is a new element with nothing listening to it. So the same wiring can be run again — `data-mug-on` marks the ones already done, or re-running would bind a second click listener to every old button and one press would flip the picture twice, back to where it started. */ function wire() { var mugs = document.querySelectorAll('[data-mug]:not([data-mug-on])'); Array.prototype.forEach.call(mugs, function (mug) { mug.setAttribute('data-mug-on', ''); var real = mug.getAttribute('data-mug-real') || 'the photograph'; var toon = mug.getAttribute('data-mug-toon') || 'the drawing'; /* ── THE WAY TO SEE IT PROPERLY ── Taufik asked for a button beside the picture that opens it in its own tab. The catch is that there are two pictures here, so a fixed address would be wrong half the time: press to reveal the photograph, press "Open", and you would get the drawing. So the link follows the press. Named by id rather than nested, because an inside a