-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.min.js
1 lines (1 loc) · 7.48 KB
/
app.min.js
1
"use strict";!function(t){var e={headline:{type:"text",properties:{fontFamily:["Lato","Playfair Display","Fira Sans"],fontSize:["48px"],fontWeight:["700"],fontStyle:["normal"],textAlign:["left"],textTransform:["none"],color:["#333","mediumblue"],lineHeight:["1.2"],marginBottom:["4px"],letterSpacing:["-0.5px"],text:["Guns, Germs, and Steel"]}},subheadline:{type:"text",properties:{fontFamily:["sans-serif"],fontSize:["16px"],fontWeight:["400"],fontStyle:["italic"],textAlign:["left"],textTransform:["none"],color:["#666"],lineHeight:["1.2"],marginBottom:["16px"],letterSpacing:["0"],text:["by Jared Diamond"]}},description:{type:"text",properties:{fontFamily:["Roboto","Crimson"],fontSize:["16px"],fontWeight:["400"],fontStyle:["normal"],textAlign:["left"],textTransform:["none"],color:["#333"],lineHeight:["1.5"],marginBottom:["0"],letterSpacing:["0"],text:["In the 1930s, the Annales School in France undertook the study of long-term historical structures by using a synthesis of geography, history, and sociology. Scholars examined the impact of geography, climate, and land use. Although geography had been nearly eliminated as an academic discipline in the United States after the 1960s, several geography-based historical theories were published in the 1990s."]}}},n="ontouchstart"in document.documentElement&&navigator.userAgent.match(/Mobi/),a=(t.addIndex(t.forEach),t.compose(t.toLower,t.trim)),o=t.compose(t.map(t.trim),t.split(",")),i=function(t){return String(t).replace(/,(?=[^\s])/g,", ")},p=t.reduce(t.pipe(t.xprod,t.map(t.unnest)),[[]]),r=t.lift(t.map)(t.compose(t.zipObj,t.keys),t.compose(p,t.values)),s=t.compose(t.values,t.map(t.prop("properties")),t.values),c=t.lift(t.zipObj)(t.keys,t.compose(t.map(r),s)),l=t.memoize(t.compose(r,c)),m=t.compose(t.product,t.map(t.length),t.values,t.prop("properties")),d=t.map(t.compose(t.zipObj(["properties"]),t.of)),u=t.compose(d,t.map(t.map(t.of)),t.filter(t.is(Object))),v={fontFamily:["Lato","Playfair Display","Open Sans","Georgia","Karla","Roboto","Cardo","Abril Fatface","Montserrat","Fira Sans","Crimson","sans-serif","serif"],fontSize:["8px","16px","32px","48px"],fontWeight:["100","400","700","900"],fontStyle:["normal","italic","oblique"],textAlign:["left","center","right"],textTransform:["none","uppercase","lowercase","capitalize"],color:["black","#333","#666","coral","mediumblue"],lineHeight:["1.2","1.3","1.5"],marginBottom:["0","4px","8px","16px","32px","48px"],letterSpacing:["-2px","-1px","-0.5px","0","0.5px","1px","2px"]},f=function(t){return[t,t]},h=t.compose(t.zipObj(["text","value"]),f,t.of),g=t.map(t.map(h));g(v);var x={render:{combination:function(e,n){var a=e.state;$("#app").empty().append($.map(a.combination,function(o,i){return $("<div>").addClass("typography").attr("combination-index",i).on("mouseenter touchstart mouseleave",n.changeActiveCombinationIndex.bind(null,e,x)).append($("<div>").addClass("typography-identifier").append($("<p>").addClass("typography-identifier__text").text("Combination "+(i+1))).append($("<p>").addClass("typography-identifier__select").html("iterate this style →").attr("combination-index",i).css({textDecoration:1===a.totalPermutation?"line-through":""}).on("click",n.reduceToOneCombination.bind(null,e,x)))).append($("<div>").addClass("typography__item").append($("<div>").append($.map(t.keys(o),function(t){return $("<p>").attr("component-name",t).css(o[t]).addClass(""+(a.activeComponent===t?"element-on-focus":"")).text(""+o[t].text).on("click",n.changeActiveComponent.bind(null,e,x))}))))}))},activeCombination:function(e,n){var a=e.state,o=t.compose(t.keys,t.head)(a.combination);$(".active-combination").addClass("loaded").empty().append($.map(o,function(t){var o=m(a.app[t]);return $("<div>").addClass("active-combination__item "+(a.activeComponent===t?"is-active":"")).attr("component-name",t).on("click",n.changeActiveComponent.bind(null,e,x)).append($("<p>").addClass("active-combination__identifier").text(t)).append($("<p>").addClass("active-combination__count").text(o+" "+(o>1?"combinations":"combination")))}))},input:function(e,a){var o=e.state,p=150,r=t.compose(t.keys,t.path([o.activeComponent,"properties"]))(o.app);$("#inputs").removeClass("loaded"),o.activeComponent?($("#empty-state").removeClass("loaded"),setTimeout(function(){$("#inputs").empty(),$("#inputs").append($.map(r,function(e){var n=t.path([o.activeComponent,"properties",e])(o.app),a=i(n);return $("<div>").addClass("input-and-label").append($("<label>").text(e.replace(/([A-Z])/g," $1"))).append($(""+("text"===e?"<textarea>":"<input>")).text(""+("text"===e?a:"")).attr("value",""+("text"!==e?a:"")).attr("name",e))})),$("input").each(function(t,e){$(e).selectize({plugins:["remove_button","restore_on_backspace"],create:function(t){return{value:t,text:t}},delimiter:","})}),x.update.activeInputItem(e),$("input").on("change",a.userInput.bind(null,e,x)),$("textarea").on("input",a.userInput.bind(null,e,x)),n&&($(".selectize-input > .item").css({transition:"none"}),$(".selectize-input > .item a").css({transition:"none"})),$("#inputs").addClass("loaded")},p)):setTimeout(function(){$("#empty-state").addClass("loaded")},p)}},update:{activeInputItem:function(e){var n=e.state,o=$(".selectize-input > .item"),i=t.compose(t.values,t.path([n.activeCombinationIndex,n.activeComponent]))(n.combination),p=t.forEach(function(t){o.each(function(e,n){var o=$(n).attr("data-value");a(t)===a(o)&&$(n).addClass("active")})});o.removeClass("active"),null!==n.activeCombinationIndex&&p(i)},activeComponent:function(t){var e=t.state,n=$("#app .typography__item p");n.removeClass("element-on-focus"),n.each(function(t,n){$(n).attr("component-name")===e.activeComponent&&$(n).addClass("element-on-focus")})}}},b={userInput:function(e,n,a){var i=e.state,p=e.updateState,r=$(a.currentTarget).val(),s=$(a.currentTarget).attr("name"),c="text"===s?t.of(r):o(r),m=t.assocPath(["app",i.activeComponent,"properties",s],c)(i),d=l(m.app),u=t.merge(m,{combination:d,totalPermutation:t.length(d)});p(u),n.render.activeCombination(e,b),n.render.combination(e,b)},changeActiveComponent:function(t,e,n){var a=t.state,o=t.updateState,i=$(n.currentTarget).attr("component-name");a.activeComponent!==i&&"typography-identifier__select"!==n.target.className&&(o({activeComponent:i}),e.update.activeComponent(t,b),e.render.activeCombination(t,b),e.render.input(t,b)),n.stopPropagation()},changeActiveCombinationIndex:function(t,e,n){var a=$(n.currentTarget).attr("combination-index");t.updateState({activeCombinationIndex:"mouseleave"===n.type?null:a}),e.update.activeInputItem(t,b)},reduceToOneCombination:function(t,e,n){var a=t.state,o=t.updateState,i=$(n.currentTarget).attr("combination-index");if(a.totalPermutation>1){$("#app").removeClass("loaded"),$("#input-container").removeClass("loaded"),$("#credits").removeClass("loaded");var p=u(a.combination[i]),r=l(p);o({totalPermutation:1,activeCombinationIndex:0,app:p,combination:r}),setTimeout(function(){$("#inputs").removeClass("loaded")},200),setTimeout(function(){e.render.combination(t,b),e.render.activeCombination(t,b),e.render.input(t,b),$("#app").addClass("loaded"),$("#input-container").addClass("loaded"),$("#credits").addClass("loaded")},400)}}},C=l(e),y={state:{app:e,activeComponent:t.compose(t.head,t.keys)(e),combination:C,totalPermutation:t.length(C),activeCombinationIndex:null},updateState:function(e){return y.state=t.merge(y.state,e)}};$(document).ready(function(){t.forEach(function(t){return t(y,b)})(t.values(x.render)),$("#input-container").on("touchstart",b.changeActiveCombinationIndex.bind(null,y,x)),$("#app").on("click",b.changeActiveComponent.bind(null,y,x)),$("#app").addClass("loaded")})}(R);