text: function updateViewportWidth(e){var t=$(".sg-size-px"),n=$(".sg-size-em"),r=parseInt($("body").css("font-size"));$("#sg-viewport").width(e);$("#sg-gen-container").width(Math.floor(e)+14);var i=Math.floor(e)/r;t.val(Math.floor(e));n.val(i.toFixed(2))}(function(e){function m(e){var t;e>i?t=i:e<r?t=r:t=e;$("#sg-gen-container").addClass("vp-animate");$("#sg-viewport").addClass("vp-animate");$("#sg-gen-container").width(t+14);$("#sg-viewport").width(t);S(t);g(t)}function g(e){findValue("vpWidth")?updateValue("vpWidth",e):addValue("vpWidth",e)}function E(){var e=o.width()-14,t=e/w;y.val(e);b.val(t.toFixed(2))}function S(e){var t=Math.floor(e),n=t/w;y.val(t);b.val(n.toFixed(2))}function x(e){var t=e/w;b.val(t.toFixed(2))}function T(e){var t=e*w;y.val(t)}function N(){m(L(240,t))}function C(){d=!1;clearInterval(p);p=!1}function k(){var e=$("#sg-viewport").width();v=!1;o.removeClass("hay-mode");$("#sg-gen-container").removeClass("hay-mode");m(Math.floor(e))}function L(e,t){return Math.random()*(t-e)+e}function A(e,t){var n=$("#"+e);if(n.length){n.attr("src",t);return!1}return!0}var t=document.body.clientWidth,n=document.body.clientHeight,r=240,i=2600,s=window.getComputedStyle(document.body,":after").getPropertyValue("content"),o=$("#sg-viewport"),u=$("#sg-t-toggle"),a=$("#sg-size-toggle"),f=$("#sg-t-annotations"),l=$("#sg-size"),c=Object,h=Object,p=!1,d=!1,v=!1;$(e).resize(function(){t=document.body.clientWidth;n=document.body.clientHeight;s=window.getComputedStyle(document.body,":after").getPropertyValue("content");E()});$(".sg-nav-toggle").on("click",function(e){e.preventDefault();$(".sg-nav-container").toggleClass("active")});u.on("click",function(e){e.preventDefault();$(this).parents("ul").toggleClass("active")});a.on("click",function(e){e.preventDefault();$(this).parents("ul").toggleClass("active")});$("#sg-controls a").on("click",function(e){var t=$(this);$("#sg-controls a").removeClass("active");t.addClass("active")});$("#sg-size-s").on("click",function(e){e.preventDefault();C();k();m(L(r,500))});$("#sg-size-m").on("click",function(e){e.preventDefault();C();k();m(L(500,800))});$("#sg-size-l").on("click",function(e){e.preventDefault();C();k();m(L(800,1200))});$("#sg-size-xl").on("click",function(e){e.preventDefault();C();k();m(L(1200,i))});$("#sg-size-full").on("click",function(e){e.preventDefault();C();k();m(t)});$("#sg-size-random").on("click",function(e){e.preventDefault();C();k();m(L(r,t))});$("#sg-size-disco").on("click",function(e){e.preventDefault();k();if(d)C();else{d=!0;p=setInterval(N,800)}});$("#sg-size-hay").on("click",function(e){e.preventDefault();C();if(v)k();else{v=!0;$("#sg-gen-container").removeClass("vp-animate").width(r+14);$("#sg-viewport").removeClass("vp-animate").width(r);var t=window.setTimeout(function(){$("#sg-gen-container").addClass("hay-mode").width(i+14);$("#sg-viewport").addClass("hay-mode").width(i)},200)}});$(".sg-size-px").on("keydown",function(e){var t=$(this).val();console.log("poop");if(e.keyCode==13){e.preventDefault();m(Math.floor(t));x(t);$(this).blur()}});$(".sg-size-em").on("keydown",function(e){var t=$(this).val(),n=parseInt($("body").css("font-size"));e.preventDefault();m(Math.floor(t*n));T(t)});o.load(function(){function r(){n.each(function(e){$this=$(this),$thisHTML=$this.html().replace(/[<>]/g,function(e){return{"<":"&lt;",">":"&gt;"}[e]}),$thisCode=$("<code></code>").html($thisHTML);$('<pre class="sg-code" />').html($thisCode).appendTo($this)});t.find(".sg-code").show()}function i(){n.each(function(e){$this=$(this),$thisAnnotation="This is an example of an annotation. Eventually this annotation will be replaced by a real annotation defined in an external JSON file.";$('<div class="sg-annotations" />').html($thisAnnotation).appendTo($this)});t.find(".sg-annotations").show()}var e=o.attr("src"),t=o.contents(),n=t.find(".sg-pattern");$("#sg-t-clean").on("click",function(e){e.preventDefault();$(this).toggleClass("active");o.contents().hide();t.find("body").toggleClass("sg-clean");t.find("#intro, .sg-head, #about-sg").toggle();t.find("[role=main]").toggleClass("clean")});$("#sg-t-code").on("click",function(e){var n=t.find(".sg-code");e.preventDefault();$(this).toggleClass("active");t.find(".sg-code").length==0?r():n.toggle()});$("#sg-t-annotations").on("click",function(e){var n=t.find(".sg-annotations");e.preventDefault();$(this).toggleClass("active");t.find(".sg-annotations").length==0?i():n.toggle()});t.find(".sg-head a").on("click",function(e){e.preventDefault();var t=$(this).attr("href");window.location=t})});var y=$(".sg-size-px"),b=$(".sg-size-em"),w=parseInt($("body").css("font-size"));E();$(".sg-acc-handle").on("click",function(e){var t=$(this),n=t.next(".sg-acc-panel");e.preventDefault();t.toggleClass("active");n.toggleClass("active")})})(this);$("#sg-rightpull").mousedown(function(e){$("#sg-gen-container").removeClass("vp-animate");$("#sg-viewport").removeClass("vp-animate");var t=e.clientX,n=$("#sg-viewport").width();$("#sg-cover").css("display","block");$("#sg-cover").mousemove(function(e){viewportWidth=t>e.clientX?n-(t-e.clientX)*2:n+(e.clientX-t)*2;if(viewportWidth>240){findValue("vpWidth")?updateValue("vpWidth",viewportWidth):addValue("vpWidth",viewportWidth);updateViewportWidth(viewportWidth)}})});$("body").mouseup(function(e){$("#sg-cover").unbind("mousemove");$("#sg-cover").css("display","none")});var origViewportWidth=$("#sg-viewport").width();$("#sg-gen-container").width(origViewportWidth);$("#sg-viewport").width(origViewportWidth-14);var vpWidth=0,trackViewportWidth=!0;trackViewportWidth&&(vpWidth=findValue("vpWidth"))&&updateViewportWidth(vpWidth);