{:uriI"file:///Users/byroot/workspace/shopify/shipit-engine/app/assets/javascripts/task/tty.js.coffee?type=application/javascript&pipeline=self&id=8e750bb9918bcfccb11336613a7a6db6a8a9fa8938f09f71e5e8c1b3ef95d30c:ET:load_pathI"I/Users/byroot/workspace/shopify/shipit-engine/app/assets/javascripts;T: filenameI"\/Users/byroot/workspace/shopify/shipit-engine/app/assets/javascripts/task/tty.js.coffee;T: nameI" task/tty;T:logical_pathI"task/tty.self.js;T:content_typeI"application/javascript;T: sourceI" (function() { var Scrolling, bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; this.TTY = (function() { var FORMATTERS, STICKY_SCROLL_TOLERENCE; FORMATTERS = []; STICKY_SCROLL_TOLERENCE = 200; TTY.appendFormatter = function(formatter) { return FORMATTERS.push(formatter); }; TTY.prependFormatter = function(formatter) { return FORMATTERS.unshift(formatter); }; function TTY($body) { this.appendChunk = bind(this.appendChunk, this); this.$code = $body.find('code'); this.scrolling = new Scrolling(this.$code); } TTY.prototype.popInitialOutput = function() { var output; output = this.$code.text(); this.$code.empty(); return output; }; TTY.prototype.formatChunks = function(chunk) { var formatter, i, len; for (i = 0, len = FORMATTERS.length; i < len; i++) { formatter = FORMATTERS[i]; chunk = formatter(chunk) || chunk; } return chunk; }; TTY.prototype.appendChunk = function(chunk) { return this.scrolling.preserve((function(_this) { return function() { return _this.$code.append(_this.formatChunks(chunk.raw)); }; })(this)); }; return TTY; })(); Scrolling = (function() { var TOLERENCE; TOLERENCE = 200; function Scrolling($code) { this.$code = $code; this.$window = $(window); this.initialScroll = true; } Scrolling.prototype.preserve = function(callback) { var wasScrolledToBottom; wasScrolledToBottom = this.isScrolledToBottom(); callback(); if (wasScrolledToBottom) { return this.$window.scrollTop(this.codeBottomPosition() - this.$window.height() + 50); } }; Scrolling.prototype.isScrolledToBottom = function() { var codeBottom, ref; if (this.initialScroll) { this.initialScroll = window.pageYOffset === 0; return true; } else { codeBottom = this.codeBottomPosition(); return (codeBottom + TOLERENCE > (ref = this.viewportBottomPosition()) && ref >= codeBottom - TOLERENCE); } }; Scrolling.prototype.viewportBottomPosition = function() { return window.pageYOffset + this.$window.height(); }; Scrolling.prototype.codeBottomPosition = function() { return this.$code.position().top + this.$code.height(); }; return Scrolling; })(); }).call(this); ;T: metadata{ :dependencieso:Set: @hash{ I"environment-version;TTI"environment-paths;TTI"jprocessors:type=application/javascript&file_type=application/javascript&engines=.coffee&pipeline=self;TTI"jfile-digest:///Users/byroot/workspace/shopify/shipit-engine/app/assets/javascripts/task/tty.js.coffee;TT: requiredo;;{: stubbedo;;{: linkso;;{: charsetI" utf-8;F: digest"%wA}[B#5ONA: lengthi :dependencies_digest"% ]7Hr܅&桾>2%(gOe~h:idI"E8e750bb9918bcfccb11336613a7a6db6a8a9fa8938f09f71e5e8c1b3ef95d30c;F: mtimel+RуU