From 7d7f05e1644e6a5a0570b9103e659ce5de3feda3 Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Thu, 29 Sep 2016 17:15:38 +0200 Subject: [PATCH] Fix scroll --- butterfly/static/ext.js | 5 ++++- butterfly/static/ext.min.js | 2 +- coffees/ext/expand_extended.coffee | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/butterfly/static/ext.js b/butterfly/static/ext.js index c77169d..b6e5256 100644 --- a/butterfly/static/ext.js +++ b/butterfly/static/ext.js @@ -164,11 +164,14 @@ if (indexOf.call(line.classList, 'extended') >= 0) { results.push(line.addEventListener('click', (function(line) { return function() { + var after, before; if (indexOf.call(line.classList, 'expanded') >= 0) { return line.classList.remove('expanded'); } else { + before = line.getBoundingClientRect().height; line.classList.add('expanded'); - return butterfly.nativeScrollTo(); + after = line.getBoundingClientRect().height; + return document.body.scrollTop += after - before; } }; })(line))); diff --git a/butterfly/static/ext.min.js b/butterfly/static/ext.min.js index 94df0c2..e375a35 100644 --- a/butterfly/static/ext.min.js +++ b/butterfly/static/ext.min.js @@ -1,4 +1,4 @@ /*! butterfly 2016-09-29 */ -(function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};g=function(a){var b,c,d,e;if(a.indexOf("")<0)return a;for(c=-1,d="",e="normal";c=0&&c++,e="normal";break;case"csi":if("?>!$\" '".indexOf(b)>=0)break;if(b>="0"&&"9">=b)break;if(";"===b)break;e="normal";break;case"osc":""!==b&&""!==b||(""===b&&c++,e="normal")}return d},p=function(a,b){var c;return c=function(d){var e,f,h;return e=g(d.data.slice(1)),null===b||b.test(e)?(butterfly.body.classList.remove("alarm"),f="Butterfly ["+butterfly.title+"]",a?(h=new Notification(f,{body:e,icon:"/static/images/favicon.png"}),h.onclick=function(){return window.focus(),h.close()}):alert(f+"\n"+e),butterfly.ws.removeEventListener("message",c)):void 0},butterfly.ws.addEventListener("message",c),butterfly.body.classList.add("alarm")},f=function(a){return a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0,!1},document.addEventListener("keydown",function(a){var b;if(!a.altKey||65!==a.keyCode)return!0;if(b=null,a.shiftKey){if(b=prompt("Ring alarm when encountering the following text: (can be a regexp)"),!b)return;b=new RegExp(b)}return Notification&&"default"===Notification.permission?Notification.requestPermission(function(){return p("granted"===Notification.permission,b)}):p("granted"===Notification.permission,b),f(a)}),addEventListener("copy",h=function(a){var b,c,d,e,f,g,h;for(butterfly.bell("copied"),a.clipboardData.clearData(),h=getSelection().toString().replace(/\u00A0/g," ").replace(/\u2007/g," "),b="",g=h.split("\n"),d=0,e=g.length;e>d;d++)f=g[d],"⏎"===f.slice(-1)?(c="",f=f.slice(0,-1)):c="\n",b+=f.replace(/\s*$/,"")+c;return a.clipboardData.setData("text/plain",b.slice(0,-1)),a.preventDefault()}),addEventListener("paste",function(a){var b;return butterfly.bell("pasted"),b=a.clipboardData.getData("text/plain"),b=b.replace(/\r\n/g,"\n").replace(/\n/g,"\r"),butterfly.send(b),a.preventDefault()}),addEventListener("beforeunload",function(a){return butterfly.body.classList.contains("dead")||location.href.indexOf("session")>-1?void 0:a.returnValue="This terminal is active and not in session. Are you sure you want to kill it?"}),Terminal.on("change",function(a){var b,c,d,e;for(e=[],b=0,c=a.length;c>b;b++)d=a[b],s.call(d.classList,"extended")>=0?e.push(d.addEventListener("click",function(a){return function(){return s.call(a.classList,"expanded")>=0?a.classList.remove("expanded"):(a.classList.add("expanded"),butterfly.nativeScrollTo())}}(d))):e.push(void 0);return e}),r=function(a,b){var c,d,e,f,g;for(f=a.childNodes,g=[],d=0,e=f.length;e>d;d++)c=f[d],b.call(c),g.push(r(c,b));return g},k=function(a){var b,c,d;return d=/\b(?:https?|ftp):\/\/[a-z0-9-+&@#\/%?=~_|!:,.;]*[a-z0-9-+&@#\/%=~_|]/gim,c=/(^|[^\/])(www\.[\S]+(\b|$))/gim,b=/[\w.]+@[a-zA-Z_-]+?(?:\.[a-zA-Z]{2,6})+/gim,a.replace(d,'$&').replace(c,'$1$2').replace(b,'$&')},Terminal.on("change",function(a){var b,c,d,e;for(e=[],b=0,c=a.length;c>b;b++)d=a[b],e.push(r(d,function(){var a,b;return 3===this.nodeType&&(a=k(this.nodeValue),a!==this.nodeValue)?(b=document.createElement("span"),b.innerHTML=a,this.parentElement.replaceChild(b,this),!0):void 0}));return e}),document.addEventListener("keydown",function(a){return a.altKey&&79===a.keyCode?(open(location.href),f(a)):!0}),a=function(){function a(){this.el=document.getElementById("popup"),this.bound_click_maybe_close=this.click_maybe_close.bind(this),this.bound_key_maybe_close=this.key_maybe_close.bind(this)}return a.prototype.open=function(a){return this.el.innerHTML=a,this.el.classList.remove("hidden"),"undefined"!=typeof InstallTrigger&&(document.body.contentEditable="false"),addEventListener("click",this.bound_click_maybe_close),addEventListener("keydown",this.bound_key_maybe_close)},a.prototype.close=function(){return removeEventListener("click",this.bound_click_maybe_close),removeEventListener("keydown",this.bound_key_maybe_close),"undefined"!=typeof InstallTrigger&&(document.body.contentEditable="true"),this.el.classList.add("hidden"),this.el.innerHTML=""},a.prototype.click_maybe_close=function(a){var b;for(b=a.target;b.parentElement;){if(Array.prototype.slice.call(this.el.children).indexOf(b)>-1)return!0;b=b.parentElement}return this.close(),f(a)},a.prototype.key_maybe_close=function(a){return 27!==a.keyCode?!0:(this.close(),f(a))},a}(),m=new a,o=null,f=function(a){return a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0,!1},n=function(a){var b;for(b=a.previousSibling,b||(b=a.parentNode.previousSibling),b||(b=a.parentNode.parentNode.previousSibling);b.lastChild;)b=b.lastChild;return b},l=function(a){var b;for(b=a.nextSibling,b||(b=a.parentNode.nextSibling),b||(b=a.parentNode.parentNode.nextSibling);null!=b?b.firstChild:void 0;)b=b.firstChild;return b},b=function(){function a(){butterfly.body.classList.add("selection"),this.selection=getSelection()}return a.prototype.reset=function(){var a,b,c;for(this.selection=getSelection(),a=document.createRange(),a.setStart(this.selection.anchorNode,this.selection.anchorOffset),a.setEnd(this.selection.focusNode,this.selection.focusOffset),this.start={node:this.selection.anchorNode,offset:this.selection.anchorOffset},this.end={node:this.selection.focusNode,offset:this.selection.focusOffset},a.collapsed&&(b=[this.end,this.start],this.start=b[0],this.end=b[1]),this.startLine=this.start.node;!this.startLine.classList||s.call(this.startLine.classList,"line")<0;)this.startLine=this.startLine.parentNode;for(this.endLine=this.end.node,c=[];!this.endLine.classList||s.call(this.endLine.classList,"line")<0;)c.push(this.endLine=this.endLine.parentNode);return c},a.prototype.clear=function(){return this.selection.removeAllRanges()},a.prototype.destroy=function(){return butterfly.body.classList.remove("selection"),this.clear()},a.prototype.text=function(){return this.selection.toString().replace(/\u00A0/g," ").replace(/\u2007/g," ")},a.prototype.up=function(){return this.go(-1)},a.prototype.down=function(){return this.go(1)},a.prototype.go=function(a){var b;if(b=butterfly.children.indexOf(this.startLine)+a,b>=0&&b=0&&b0;)if(f[--d].match(b))return{node:e,offset:d+1};e=n(e),f=null!=e?e.textContent:void 0,d=f.length}else for(;e;){for(;d=0)return!0;if(a.shiftKey&&13===a.keyCode&&!o&&!getSelection().isCollapsed)return butterfly.send(getSelection().toString()),getSelection().removeAllRanges(),f(a);if(o){if(o.reset(),!a.ctrlKey&&a.shiftKey&&37<=(d=a.keyCode)&&40>=d)return!0;if(a.shiftKey&&a.ctrlKey)38===a.keyCode?o.up():40===a.keyCode&&o.down();else if(39===a.keyCode)o.shrinkLeft();else if(38===a.keyCode)o.expandLeft();else if(37===a.keyCode)o.shrinkRight();else{if(40!==a.keyCode)return f(a);o.expandRight()}return null!=o&&o.apply(),f(a)}return!o&&a.ctrlKey&&a.shiftKey&&38===a.keyCode?(o=new b,o.selectLine(butterfly.y-1),o.apply(),f(a)):!0}),document.addEventListener("keyup",function(a){var b,c;if(b=a.keyCode,s.call([16,17,18,19],b)>=0)return!0;if(o){if(13===a.keyCode)return butterfly.send(o.text()),o.destroy(),o=null,f(a);if(c=a.keyCode,s.call([37,38,39,40],c)<0)return o.destroy(),o=null,!0}return!0}),document.addEventListener("dblclick",function(a){var b,c,d,e,f;if(!(a.ctrlKey||a.altkey||(f=getSelection(),f.isCollapsed||f.toString().match(/\s/)))){for(e=document.createRange(),e.setStart(f.anchorNode,f.anchorOffset),e.setEnd(f.focusNode,f.focusOffset),e.collapsed&&(f.removeAllRanges(),d=document.createRange(),d.setStart(f.focusNode,f.focusOffset),d.setEnd(f.anchorNode,f.anchorOffset),f.addRange(d));!f.toString().match(/\s/)&&f.toString();)f.modify("extend","forward","character");for(f.modify("extend","backward","character"),b=f.anchorNode,c=f.anchorOffset,f.collapseToEnd(),f.extend(b,c);!f.toString().match(/\s/)&&f.toString();)f.modify("extend","backward","character");return f.modify("extend","forward","character")}}),document.addEventListener("keydown",function(a){var b;return a.altKey&&69===a.keyCode?(b=new XMLHttpRequest,b.addEventListener("load",function(){var a,b,c,d,e,f;if(e=JSON.parse(this.responseText),c="
",c+="

Session list

",0===e.sessions.length)c+="No current session for user "+e.user;else{for(c+="
    ",d=e.sessions,a=0,b=d.length;b>a;a++)f=d[a],c+='
  • '+f+"
  • ";c+="
"}return c+="
",m.open(c)}),b.open("GET","/sessions/list.json"),b.send(),f(a)):!0}),c=function(a){var b;return document.getElementById("style").setAttribute("href",a),b=document.createElement("img"),b.onerror=function(){return setTimeout(function(){return"undefined"!=typeof butterfly&&null!==butterfly?butterfly.resize():void 0},250)},b.src=a},d="undefined"!=typeof localStorage&&null!==localStorage?localStorage.getItem("theme"):void 0,d&&c(d),this.set_theme=function(a){return d=a,"undefined"!=typeof localStorage&&null!==localStorage&&localStorage.setItem("theme",a),a?c(a):void 0},document.addEventListener("keydown",function(a){var b,e;return a.altKey&&83===a.keyCode?a.shiftKey?(e=document.getElementById("style").getAttribute("href"),e=e.split("?")[0],c(e+"?"+(new Date).getTime()),f(a)):(b=new XMLHttpRequest,b.addEventListener("load",function(){var a,b,c,e,f,g,h,i,j,k,l,n;if(i=JSON.parse(this.responseText),a=i.builtin_themes,l=i.themes,b='
\n

Pick a theme:

\n \n \n
",m.open(b),k=document.getElementById("theme_list"),k.addEventListener("change",function(){return set_theme(k.value)})}),b.open("GET","/themes/list.json"),b.send(),f(a)):!0}),/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&(i=!1,e=!1,j=!0,q=document.createElement("input"),q.type="password",q.style.position="fixed",q.style.top=0,q.style.left=0,q.style.border="none",q.style.outline="none",q.style.opacity=0,q.value="0",document.body.appendChild(q),q.addEventListener("blur",function(){return setTimeout(function(a){return function(){return a.focus()}}(this),10)}),addEventListener("click",function(){return q.focus()}),addEventListener("touchstart",function(a){return 2===a.touches.length?i=!0:3===a.touches.length?(i=!1,e=!0):4===a.touches.length?(i=!0,e=!0):void 0}),q.addEventListener("keydown",function(a){return butterfly.keyDown(a),!0}),q.addEventListener("input",function(a){var b;return b=this.value.length,0===b?(a.keyCode=8,butterfly.keyDown(a),this.value="0",!0):(a.keyCode=this.value.charAt(1).charCodeAt(0),!i&&!e||j?(butterfly.keyPress(a),j=!1,this.value="0",!0):(a.keyCode=this.value.charAt(1).charCodeAt(0),a.ctrlKey=i,a.altKey=e,a.keyCode>=97&&a.keyCode<=122&&(a.keyCode-=32),butterfly.keyDown(a),this.value="0",i=e=!1,!0))}))}).call(this); +(function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};g=function(a){var b,c,d,e;if(a.indexOf("")<0)return a;for(c=-1,d="",e="normal";c=0&&c++,e="normal";break;case"csi":if("?>!$\" '".indexOf(b)>=0)break;if(b>="0"&&"9">=b)break;if(";"===b)break;e="normal";break;case"osc":""!==b&&""!==b||(""===b&&c++,e="normal")}return d},p=function(a,b){var c;return c=function(d){var e,f,h;return e=g(d.data.slice(1)),null===b||b.test(e)?(butterfly.body.classList.remove("alarm"),f="Butterfly ["+butterfly.title+"]",a?(h=new Notification(f,{body:e,icon:"/static/images/favicon.png"}),h.onclick=function(){return window.focus(),h.close()}):alert(f+"\n"+e),butterfly.ws.removeEventListener("message",c)):void 0},butterfly.ws.addEventListener("message",c),butterfly.body.classList.add("alarm")},f=function(a){return a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0,!1},document.addEventListener("keydown",function(a){var b;if(!a.altKey||65!==a.keyCode)return!0;if(b=null,a.shiftKey){if(b=prompt("Ring alarm when encountering the following text: (can be a regexp)"),!b)return;b=new RegExp(b)}return Notification&&"default"===Notification.permission?Notification.requestPermission(function(){return p("granted"===Notification.permission,b)}):p("granted"===Notification.permission,b),f(a)}),addEventListener("copy",h=function(a){var b,c,d,e,f,g,h;for(butterfly.bell("copied"),a.clipboardData.clearData(),h=getSelection().toString().replace(/\u00A0/g," ").replace(/\u2007/g," "),b="",g=h.split("\n"),d=0,e=g.length;e>d;d++)f=g[d],"⏎"===f.slice(-1)?(c="",f=f.slice(0,-1)):c="\n",b+=f.replace(/\s*$/,"")+c;return a.clipboardData.setData("text/plain",b.slice(0,-1)),a.preventDefault()}),addEventListener("paste",function(a){var b;return butterfly.bell("pasted"),b=a.clipboardData.getData("text/plain"),b=b.replace(/\r\n/g,"\n").replace(/\n/g,"\r"),butterfly.send(b),a.preventDefault()}),addEventListener("beforeunload",function(a){return butterfly.body.classList.contains("dead")||location.href.indexOf("session")>-1?void 0:a.returnValue="This terminal is active and not in session. Are you sure you want to kill it?"}),Terminal.on("change",function(a){var b,c,d,e;for(e=[],b=0,c=a.length;c>b;b++)d=a[b],s.call(d.classList,"extended")>=0?e.push(d.addEventListener("click",function(a){return function(){var b,c;return s.call(a.classList,"expanded")>=0?a.classList.remove("expanded"):(c=a.getBoundingClientRect().height,a.classList.add("expanded"),b=a.getBoundingClientRect().height,document.body.scrollTop+=b-c)}}(d))):e.push(void 0);return e}),r=function(a,b){var c,d,e,f,g;for(f=a.childNodes,g=[],d=0,e=f.length;e>d;d++)c=f[d],b.call(c),g.push(r(c,b));return g},k=function(a){var b,c,d;return d=/\b(?:https?|ftp):\/\/[a-z0-9-+&@#\/%?=~_|!:,.;]*[a-z0-9-+&@#\/%=~_|]/gim,c=/(^|[^\/])(www\.[\S]+(\b|$))/gim,b=/[\w.]+@[a-zA-Z_-]+?(?:\.[a-zA-Z]{2,6})+/gim,a.replace(d,'$&').replace(c,'$1$2').replace(b,'$&')},Terminal.on("change",function(a){var b,c,d,e;for(e=[],b=0,c=a.length;c>b;b++)d=a[b],e.push(r(d,function(){var a,b;return 3===this.nodeType&&(a=k(this.nodeValue),a!==this.nodeValue)?(b=document.createElement("span"),b.innerHTML=a,this.parentElement.replaceChild(b,this),!0):void 0}));return e}),document.addEventListener("keydown",function(a){return a.altKey&&79===a.keyCode?(open(location.href),f(a)):!0}),a=function(){function a(){this.el=document.getElementById("popup"),this.bound_click_maybe_close=this.click_maybe_close.bind(this),this.bound_key_maybe_close=this.key_maybe_close.bind(this)}return a.prototype.open=function(a){return this.el.innerHTML=a,this.el.classList.remove("hidden"),"undefined"!=typeof InstallTrigger&&(document.body.contentEditable="false"),addEventListener("click",this.bound_click_maybe_close),addEventListener("keydown",this.bound_key_maybe_close)},a.prototype.close=function(){return removeEventListener("click",this.bound_click_maybe_close),removeEventListener("keydown",this.bound_key_maybe_close),"undefined"!=typeof InstallTrigger&&(document.body.contentEditable="true"),this.el.classList.add("hidden"),this.el.innerHTML=""},a.prototype.click_maybe_close=function(a){var b;for(b=a.target;b.parentElement;){if(Array.prototype.slice.call(this.el.children).indexOf(b)>-1)return!0;b=b.parentElement}return this.close(),f(a)},a.prototype.key_maybe_close=function(a){return 27!==a.keyCode?!0:(this.close(),f(a))},a}(),m=new a,o=null,f=function(a){return a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0,!1},n=function(a){var b;for(b=a.previousSibling,b||(b=a.parentNode.previousSibling),b||(b=a.parentNode.parentNode.previousSibling);b.lastChild;)b=b.lastChild;return b},l=function(a){var b;for(b=a.nextSibling,b||(b=a.parentNode.nextSibling),b||(b=a.parentNode.parentNode.nextSibling);null!=b?b.firstChild:void 0;)b=b.firstChild;return b},b=function(){function a(){butterfly.body.classList.add("selection"),this.selection=getSelection()}return a.prototype.reset=function(){var a,b,c;for(this.selection=getSelection(),a=document.createRange(),a.setStart(this.selection.anchorNode,this.selection.anchorOffset),a.setEnd(this.selection.focusNode,this.selection.focusOffset),this.start={node:this.selection.anchorNode,offset:this.selection.anchorOffset},this.end={node:this.selection.focusNode,offset:this.selection.focusOffset},a.collapsed&&(b=[this.end,this.start],this.start=b[0],this.end=b[1]),this.startLine=this.start.node;!this.startLine.classList||s.call(this.startLine.classList,"line")<0;)this.startLine=this.startLine.parentNode;for(this.endLine=this.end.node,c=[];!this.endLine.classList||s.call(this.endLine.classList,"line")<0;)c.push(this.endLine=this.endLine.parentNode);return c},a.prototype.clear=function(){return this.selection.removeAllRanges()},a.prototype.destroy=function(){return butterfly.body.classList.remove("selection"),this.clear()},a.prototype.text=function(){return this.selection.toString().replace(/\u00A0/g," ").replace(/\u2007/g," ")},a.prototype.up=function(){return this.go(-1)},a.prototype.down=function(){return this.go(1)},a.prototype.go=function(a){var b;if(b=butterfly.children.indexOf(this.startLine)+a,b>=0&&b=0&&b0;)if(f[--d].match(b))return{node:e,offset:d+1};e=n(e),f=null!=e?e.textContent:void 0,d=f.length}else for(;e;){for(;d=0)return!0;if(a.shiftKey&&13===a.keyCode&&!o&&!getSelection().isCollapsed)return butterfly.send(getSelection().toString()),getSelection().removeAllRanges(),f(a);if(o){if(o.reset(),!a.ctrlKey&&a.shiftKey&&37<=(d=a.keyCode)&&40>=d)return!0;if(a.shiftKey&&a.ctrlKey)38===a.keyCode?o.up():40===a.keyCode&&o.down();else if(39===a.keyCode)o.shrinkLeft();else if(38===a.keyCode)o.expandLeft();else if(37===a.keyCode)o.shrinkRight();else{if(40!==a.keyCode)return f(a);o.expandRight()}return null!=o&&o.apply(),f(a)}return!o&&a.ctrlKey&&a.shiftKey&&38===a.keyCode?(o=new b,o.selectLine(butterfly.y-1),o.apply(),f(a)):!0}),document.addEventListener("keyup",function(a){var b,c;if(b=a.keyCode,s.call([16,17,18,19],b)>=0)return!0;if(o){if(13===a.keyCode)return butterfly.send(o.text()),o.destroy(),o=null,f(a);if(c=a.keyCode,s.call([37,38,39,40],c)<0)return o.destroy(),o=null,!0}return!0}),document.addEventListener("dblclick",function(a){var b,c,d,e,f;if(!(a.ctrlKey||a.altkey||(f=getSelection(),f.isCollapsed||f.toString().match(/\s/)))){for(e=document.createRange(),e.setStart(f.anchorNode,f.anchorOffset),e.setEnd(f.focusNode,f.focusOffset),e.collapsed&&(f.removeAllRanges(),d=document.createRange(),d.setStart(f.focusNode,f.focusOffset),d.setEnd(f.anchorNode,f.anchorOffset),f.addRange(d));!f.toString().match(/\s/)&&f.toString();)f.modify("extend","forward","character");for(f.modify("extend","backward","character"),b=f.anchorNode,c=f.anchorOffset,f.collapseToEnd(),f.extend(b,c);!f.toString().match(/\s/)&&f.toString();)f.modify("extend","backward","character");return f.modify("extend","forward","character")}}),document.addEventListener("keydown",function(a){var b;return a.altKey&&69===a.keyCode?(b=new XMLHttpRequest,b.addEventListener("load",function(){var a,b,c,d,e,f;if(e=JSON.parse(this.responseText),c="
",c+="

Session list

",0===e.sessions.length)c+="No current session for user "+e.user;else{for(c+="
    ",d=e.sessions,a=0,b=d.length;b>a;a++)f=d[a],c+='
  • '+f+"
  • ";c+="
"}return c+="
",m.open(c)}),b.open("GET","/sessions/list.json"),b.send(),f(a)):!0}),c=function(a){var b;return document.getElementById("style").setAttribute("href",a),b=document.createElement("img"),b.onerror=function(){return setTimeout(function(){return"undefined"!=typeof butterfly&&null!==butterfly?butterfly.resize():void 0},250)},b.src=a},d="undefined"!=typeof localStorage&&null!==localStorage?localStorage.getItem("theme"):void 0,d&&c(d),this.set_theme=function(a){return d=a,"undefined"!=typeof localStorage&&null!==localStorage&&localStorage.setItem("theme",a),a?c(a):void 0},document.addEventListener("keydown",function(a){var b,e;return a.altKey&&83===a.keyCode?a.shiftKey?(e=document.getElementById("style").getAttribute("href"),e=e.split("?")[0],c(e+"?"+(new Date).getTime()),f(a)):(b=new XMLHttpRequest,b.addEventListener("load",function(){var a,b,c,e,f,g,h,i,j,k,l,n;if(i=JSON.parse(this.responseText),a=i.builtin_themes,l=i.themes,b='
\n

Pick a theme:

\n \n \n
",m.open(b),k=document.getElementById("theme_list"),k.addEventListener("change",function(){return set_theme(k.value)})}),b.open("GET","/themes/list.json"),b.send(),f(a)):!0}),/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&(i=!1,e=!1,j=!0,q=document.createElement("input"),q.type="password",q.style.position="fixed",q.style.top=0,q.style.left=0,q.style.border="none",q.style.outline="none",q.style.opacity=0,q.value="0",document.body.appendChild(q),q.addEventListener("blur",function(){return setTimeout(function(a){return function(){return a.focus()}}(this),10)}),addEventListener("click",function(){return q.focus()}),addEventListener("touchstart",function(a){return 2===a.touches.length?i=!0:3===a.touches.length?(i=!1,e=!0):4===a.touches.length?(i=!0,e=!0):void 0}),q.addEventListener("keydown",function(a){return butterfly.keyDown(a),!0}),q.addEventListener("input",function(a){var b;return b=this.value.length,0===b?(a.keyCode=8,butterfly.keyDown(a),this.value="0",!0):(a.keyCode=this.value.charAt(1).charCodeAt(0),!i&&!e||j?(butterfly.keyPress(a),j=!1,this.value="0",!0):(a.keyCode=this.value.charAt(1).charCodeAt(0),a.ctrlKey=i,a.altKey=e,a.keyCode>=97&&a.keyCode<=122&&(a.keyCode-=32),butterfly.keyDown(a),this.value="0",i=e=!1,!0))}))}).call(this); //# sourceMappingURL=ext.min.js.map \ No newline at end of file diff --git a/coffees/ext/expand_extended.coffee b/coffees/ext/expand_extended.coffee index 9361333..794a9b2 100644 --- a/coffees/ext/expand_extended.coffee +++ b/coffees/ext/expand_extended.coffee @@ -5,5 +5,7 @@ Terminal.on 'change', (lines) -> if 'expanded' in line.classList line.classList.remove 'expanded' else + before = line.getBoundingClientRect().height line.classList.add 'expanded' - butterfly.nativeScrollTo() + after = line.getBoundingClientRect().height + document.body.scrollTop += after - before