/*\ title: $:/plugins/felixhayashi/hotzone/hotzone.js type: application/javascript module-type: startup @preserve \*/ (function(){"use strict";exports.name="hotzone";exports.platforms=["browser"];exports.after=["story"];exports.synchronous=true;exports.startup=function(){var t=require("$:/plugins/felixhayashi/hotzone/config.js").config;var e=null;var i=document.getElementsByClassName(t.classNames.storyRiver)[0];var r=$tw.wiki.getTiddlerData(t.references.userConfig,{});var s=isNaN(parseInt(r.focusOffset))?150:parseInt(r.focusOffset);var a=function(e,i,r){if(!(e instanceof Element))return;if(!$tw.utils.hasClass(e,t.classNames.tiddlerFrame))return;var s=e.getElementsByClassName(t.classNames.tiddlerTitle)[0];if(s){var a=s.innerText||s.textContent;return a.trim()}};var n=function(e,i){$tw.wiki.addTiddler(new $tw.Tiddler({title:t.references.focussedTiddlerStore,text:e},$tw.wiki.getModificationFields()));if(i){var r=document.getElementsByClassName("hzone-focus")[0];if(r){$tw.utils.removeClass(r,"hzone-focus")}$tw.utils.addClass(i,"hzone-focus")}};var l=function(){var r=$tw.wiki.getTiddler("$:/StoryList");if(r&&r.fields.list.length){var l=null;var o=Number.MAX_VALUE;var f=i.children;var u=t.classNames.tiddlerFrame;for(var d=f.length;d--;){if($tw.utils.hasClass(f[d],u)){var c=f[d].getBoundingClientRect();var v=Math.min(Math.abs(s-c.top),Math.abs(s-c.bottom));if(v=0;if(!r)return;f($tw.utils.getAnimationDuration()+10,true)}else if(t["$:/StoryList"]){f($tw.utils.getAnimationDuration()+10,true)}};var d=function(t){f(300,false)};$tw.wiki.addEventListener("change",u);window.addEventListener("scroll",d,false);d()}})();