02var15 each15 =15 (a,c)=>15 10Array.prototype.forEach.call(a,15 c); 02var15 node15 =15 elem15 =>15 elem15 06instanceof15 10window.$15 ?15 elem[020]15 :15 elem; 02var15 smrm15 =15 elem15 =>15 getComputedStyle(node(elem)).animationName!==05"none"?node(elem).addEventListener(05'animationend',node(elem).remove):node(elem).remove(); 02function15 beyond(node)15 { 15 02var15 rect15 =15 node.getBoundingClientRect(); 15 02return15 ( 15 (rect.x15 +15 rect.width)15 <15 02015 || 15 (rect.y15 +15 rect.height)15 <15 02015 || 15 (rect.x15 >15 10window.innerWidth15 ||15 rect.y15 >15 10window.innerHeight) 15 ); } 02var 15 popup15 =15 05'popup', 15 popupA15 =15 05'popupA', 15 popupF15 =15 05'popupF', 15 hilite15 =15 05'highlighted' ; 02var15 nav15 =15 { 15 setHighlight:15 (15/*HTMLElement | JQuery*/15 post,15 15/*boolean*/15 status)15 =>15 { 15 02switch15 (status)15 { 15 02case15 02true: 15 node(post).classList.add(hilite); 15 02break; 15 02case15 02false: 15 node(post).classList.remove(hilite); 15 02break; 15 02case15 02undefined: 15 node(post).classList.contains(hilite) 15 ?15 node(post).classList.add(hilite) 15 :15 node(post).classList.add(hilite) 15 ; 15 02break; 15 02default: 15 02break; 15 } 15 }, 15 clonePost:15 (clonedPost,15 parent,15 rm)15 =>15 { 15 02switch15 (rm)15 { 15 02case15 02true: 15 02case15 02undefined: 15 clonedPost.attr(05'id',15 clonedPost.attr(05'id')+05'_copy'); 15 clonedPost.addClass(popup); 15 clonedPost.addClass(popupA); 15 getComputedStyle(node(clonedPost)).animationName15 !=15 05'none' 15 ?15 clonedPost.on(15 05'animationend',15 e15 =>15 e.target.classList.remove(popupA)15 ) 15 :15 clonedPost.removeClass(popupA) 15 ; 15 parent.append(clonedPost); 15 02break; 15 02case15 02false: 15 clonedPost.addClass(popupF); 15 smrm(clonedPost); 15 02break; 15 02default: 15 02break; 15 } 15 02return15 clonedPost; 15 }, } 02function15 enableFastNavigation()15 {15 15// Highlights and popups 15 02function15 highlightOnLinkEnter(15/*JQuery*/15 post,15 15/*JQuery*/15 link)15 { 15 nav.setHighlight(post,15 02true); 15 link.on(05'mouseleave',15 02function15 mouseLeave()15 { 15 nav.setHighlight(post,15 02false); 15 link.off(05'mouseleave',15 mouseLeave); 15 }); 15 } 15 02function15 popup(15/*JQuery*/15 clonedPost,15 15/*JQuery*/15 link)15 { 15 02var15 popupDeletionTimer15 =15 02null; 15 02var15 parentPost15 =15 link.parent().parent(); 15 15/* Callbacks 15 * W: Each one assumes that clonedPost and link are valid JQuery objects.*/ 15 02const15 cbs15 =15 { 15 _initiateCountdown:15 ()15 =>15 { 15 popupDeletionTimer15 =15 setTimeout(15 ()15 =>15 { 15 nav.clonePost(clonedPost,15 parentPost,15 02false); 15 link.removeAttr(05'locked'); 15 },15 02100015 ); 15 }, 15 15/* Postlink mouseleave callback. */ 15 linkLeave:15 02function15 linkLeave(e)15 { 15 cbs._initiateCountdown(); 15 clonedPost.on(05'mouseenter',15 cbs.popupEnter); 15 link.off(05'mouseleave'); 15 }, 15 15/* Fires when cursor leaves a popup. */ 15 popupLeave:15 02function15 postLeave()15 { 15 cbs._initiateCountdown(); 15 clonedPost.on(05'mouseenter',15 cbs.popupEnter); 15 }, 15 15/* Fires if cursor returns onto a popup before postDeletionTimer's time is up. 15 Otherwise popup will be removed from document. */ 15 popupEnter:15 02function15 postEnter()15 { 15 clearTimeout(popupDeletionTimer); 15 postDeletionTimer15 =15 02null; 15 clonedPost.off(05'mouseenter',15 popupEnter); 15 } 15 }; 15 02if15 (link.attr(05'locked'))15 02return; 15 link.attr(05'locked',15 02true); 15 nav.clonePost(clonedPost,15 parentPost); 15 02let15 _l15 =15 node(link),15 _ld15 =15 _l.getBoundingClientRect(); 15 clonedPost 15 .css(05'position',15 05'absolute') 15 .css(05'left',15 _l.offsetLeft15 +15 05'px') 15 .css(05'top',15 _l.offsetTop15 +15 _ld.height15 +15 05'px') 15 ; 15 link.on(05'mouseleave',15 cbs.linkLeave); 15 clonedPost.on(05'mouseleave',15 cbs.popupLeave); 15 } 15 02function15 show(e)15 { 15 02let15 link15 =15 $(e.target), 15 numb15 =15 link.text().substr(022), 15 post15 =15 $(05`05#reply05${numb05}05`)15 ||15 02null; 15 02if15 (node(post))15 { 15 02if(15 beyond(node(post))15 )15 { 15 02let15 _embed15 =15 node(post).cloneNode(02true); 15 each(_embed.children,15 item15 =>15 { 15 02if15 (item.classList.contains(popup))15 item.remove(); 15 }); 15 popup($(_embed),15 link); 15 }15 02else15 { 15 highlightOnLinkEnter(post,15 link); 15 } 15 } 15 } 15 $(10document).on(05'mouseenter',15 05'.message a[href*="res"]',15 show); } 10document.addEventListener(05'DOMContentLoaded',15 enableFastNavigation);