forked from davgit/type-scale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.min.js
2 lines (2 loc) · 10 KB
/
script.min.js
1
2
$(document).ready(function(){function e(e){for(var t=window.location.search.substring(1).split("&"),a=0;a<t.length;a++){var o=t[a].split("=");if(o[0]==e)return decodeURIComponent(o[1])}return!1}function t(){e("size")===!1?(baseSize=1.25,$(".base_size").val(20),$(".css_font_size").text(1.25)):(baseSize=e("size")/16,$(".base_size").val(e("size")),$(".article_container").css("font-size",Math.round(1e3*baseSize)/1e3+"em"),$(".param_size").text(e("size")),$(".css_font_size").text(Math.round(1e3*baseSize)/1e3)),$(".base_em").text(Math.round(1e3*baseSize)/1e3)}function o(){e("scale")===!1?scaleRatio=1.414:(scaleRatio=e("scale"),$(".font_scale").val(e("scale")),$(".param_scale").text(e("scale"))),u()}function n(){scaleRatio=$(".font_scale").val(),u()}function s(){e("text")!==!1&&($(".preview_text").val(e("text")),$(".scale_preview_text").text(e("text")),$(".param_text").text(e("text")))}function i(){e("webfont")!==!1&&($(".web_font").val(e("webfont")),$(".webfont_url").attr("href","http://fonts.googleapis.com/css?family="+e("webfont")),$(".param_font").text(e("webfont")))}function l(){e("font-family")!==!1&&($(".web_font_name").val(e("font-family")),$(".scale_webfont, .article_content").attr("style","font-family:"+e("font-family")),$(".param_css").text(e("font-family")),$(".css_font_family").text(e("font-family")))}function r(){e("font-weight")!==!1&&($(".i_weight").val(e("font-weight")),$(".style_weight").html(".scale_webfont, .article_container {font-weight:"+e("font-weight")+";}"),$(".param_weight").text(e("font-weight")),$(".css_weight").text(e("font-weight")))}function c(){e("font-weight-headers")!==!1&&($(".i_weight_headers").val(e("font-weight-headers")),$(".style_weight_headers").html(".article_header {font-weight:"+e("font-weight-headers")+";}"),$(".param_weight_headers").text(e("font-weight-headers")),$(".css_weight_headers").text(e("font-weight-headers")))}function h(){e("font-family-headers")!==!1&&($(".font_family_headers").val(e("font-family-headers")),$(".style_font_headers").html(".article_header {font-family:"+e("font-family-headers")+";}"),$(".param_font_headers").text(e("font-family-headers")),$(".css_font_headers").html("<br> font-family: "+e("font-family-headers")+";"))}function f(){e("background-color")!==!1&&($(".background_color").val(e("background-color")),$(".style_background_color").html(".article_preview_open {background-color:"+e("background-color")+";}"),$(".param_background_color").text(e("background-color")),$(".css_background_color").text(e("background-color")))}function _(){e("font-color")!==!1&&($(".font_color").val(e("font-color")),$(".style_font_color").html(".article_preview_open {color:"+e("font-color")+";}"),$(".param_font_color").text(e("font-color")),$(".css_color").text(e("font-color")))}function u(){function e(){a=baseSize,b=scaleRatio,result=baseSize,$($(".scale_high").get().reverse()).each(function(){$(this).css("font-size",Math.round(1e3*result)/1e3+"em"),result=a*b,a=result})}function t(){a=1,b=scaleRatio,result=1,$($(".scale_high_label").get().reverse()).each(function(){$(this).text(Math.round(1e3*result)/1e3+"em"),result=a*b,a=result})}function o(){a=1,b=scaleRatio,result=1,$($(".article_header").get().reverse()).each(function(){result=a*b,a=result,$(this).css("font-size",Math.round(1e3*result)/1e3+"em")})}function n(){a=1,b=scaleRatio,result=1,$($(".css_header_size").get().reverse()).each(function(){result=a*b,a=result,$(this).text(Math.round(1e3*result)/1e3)})}function s(){a=baseSize,b=scaleRatio,result=baseSize,$(".scale_low").each(function(){result=a/b,a=result,$(this).css("font-size",Math.round(1e3*result)/1e3+"em")})}function i(){a=1,b=scaleRatio,result=1,$(".scale_low_label").each(function(){result=a/b,a=result,$(this).text(Math.round(1e3*result)/1e3+"em")})}function l(){a=1,b=scaleRatio,result=1,$(".css_small_size").each(function(){result=a/b,a=result,$(this).text(Math.round(1e3*result)/1e3)})}e(),t(),o(),n(),s(),i(),l(),d()}function d(){$("body").delay(650).queue(function(e){$(this).css("min-height",$(".article_preview_inner").outerHeight()),e()})}$(".stage").css("min-height",$(window).innerHeight()),$(".article_preview_button").click(function(){$(this).toggleClass("fa-times").toggleClass("fa-chevron-left"),$(".article_preview").toggleClass("article_preview_open")}),$(".expand_down").click(function(e){e.preventDefault(),$(this).children(".fa").toggleClass("fa-times").toggleClass("fa-chevron-down"),$(this).hasClass("more_options_button")&&d()}),$(".param_url").hover(function(){$(this).attr("href",$(this).text())}),$("[data-toggle]").click(function(e){e.preventDefault(),$($(this).data("toggle")).toggle()}),t(),$(".base_size").bind("change paste keyup",function(){baseSize=$.isNumeric($(this).val())?$(this).val()/16:0,$(".base_em").text(Math.round(1e3*baseSize)/1e3),n(),$(".param_size").text($(this).val()),$(".article_container").css("font-size",Math.round(1e3*baseSize)/1e3+"em"),$(".css_font_size").text(Math.round(1e3*baseSize)/1e3)}),o(),$(".font_scale").bind("change paste keyup",function(){n(),$(".param_scale").text($(this).val())}),s(),$(".preview_text").bind("change paste keyup",function(){previewText=$(this).val(),$(".scale_preview_text").text(previewText),$(".param_text").text(encodeURIComponent($(this).val()))}),i(),$(".web_font").bind("change paste keyup",function(){$(".webfont_url").attr("href","http://fonts.googleapis.com/css?family="+$(this).val()),$(".param_font").text(encodeURIComponent($(this).val()))}),l(),$(".web_font_name").bind("change paste keyup",function(){webFontName=$(this).val(),$(".scale_webfont, .article_content").attr("style","font-family:"+webFontName),$(".param_css").text(encodeURIComponent($(this).val())),$(".css_font_family").text($(this).val())}),r(),$(".i_weight").bind("change paste keyup",function(){$(".style_weight").html(".scale_webfont, .article_container {font-weight:"+$(this).val()+";}"),$(".param_weight").text($(this).val()),$(".css_weight").text($(this).val())}),c(),$(".i_weight_headers").bind("change paste keyup",function(){$(".style_weight_headers").html(".article_header {font-weight:"+$(this).val()+";}"),$(".param_weight_headers").text($(this).val()),$(".css_weight_headers").text($(this).val())}),h(),$(".font_family_headers").bind("change paste keyup",function(){$(".style_font_headers").html(".article_header {font-family:"+$(this).val()+";}"),$(".param_font_headers").text(encodeURIComponent($(this).val())),$(this).val()!==!1&&$(".css_font_headers").html("<br> font-family: "+$(this).val()+";"),d()}),f(),$(".background_color").bind("change paste keyup",function(){$(".style_background_color").html(".article_preview_open {background-color:"+$(this).val()+";}"),$(".param_background_color").text(encodeURIComponent($(this).val())),$(".css_background_color").text($(this).val())}),_(),$(".font_color").bind("change paste keyup",function(){$(".style_font_color").html(".article_preview_open {color:"+$(this).val()+";}"),$(".param_font_color").text(encodeURIComponent($(this).val())),$(".css_color").text($(this).val())})});
$(document).ready(function(){$(".codepen_btn").hover(function(){$(".codepen_able").each(function(){var e=$(this),a=e.data("type"),o=e.find("code"),t=(o.length,""),l="";"html"==a?t=o?o.html():e.html():"css"==a&&(l=o?o.text():e.html());var i=$(".web_font").val(),n={title:"A Type Scale",description:"Custom type scale and CSS from http://type-scale.com",html:t+'<link href="http://fonts.googleapis.com/css?family='+i+'" rel="stylesheet" type="text/css">\n\n<h1>One Morning, When Gregor Samsa Woke</h1>\n\n<p>From troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections. The bedding was hardly able to cover it and seemed ready to slide off any moment.</p>\n\n<p>His many legs, pitifully thin compared with the size of the rest of him, waved about helplessly as he looked. “What’s happened to me?” he thought. It wasn’t a dream. His room, a proper human room although a little too small, lay peacefully between its four familiar walls.</p>\n\n<h2>One Morning, When Gregor Samsa Woke</h2>\n\n<p>From troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections. The bedding was hardly able to cover it and seemed ready to slide off any moment.</p>\n\n<p>His many legs, pitifully thin compared with the size of the rest of him, waved about helplessly as he looked. “What’s happened to me?” he thought. It wasn’t a dream. His room, a proper human room although a little too small, lay peacefully between its four familiar walls.</p>\n\n<h3>One Morning, When Gregor Samsa Woke</h3>\n\n<p>From troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections. The bedding was hardly able to cover it and seemed ready to slide off any moment.</p>\n\n<p>His many legs, pitifully thin compared with the size of the rest of him, waved about helplessly as he looked. “What’s happened to me?” he thought. It wasn’t a dream. His room, a proper human room although a little too small, lay peacefully between its four familiar walls.</p>\n\n<h4>One Morning, When Gregor Samsa Woke</h4>\n\n<p>From troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections. The bedding was hardly able to cover it and seemed ready to slide off any moment.</p>\n\n<p>His many legs, pitifully thin compared with the size of the rest of him, waved about helplessly as he looked. “What’s happened to me?” he thought. It wasn’t a dream. His room, a proper human room although a little too small, lay peacefully between its four familiar walls.</p>',css:l},h=JSON.stringify(n);$(".codepen_json").val(h)})})});