diff --git a/dist/styleguide/js/patternlab-viewer.js b/dist/styleguide/js/patternlab-viewer.js index 0d85cab..a63b40b 100644 --- a/dist/styleguide/js/patternlab-viewer.js +++ b/dist/styleguide/js/patternlab-viewer.js @@ -1342,6 +1342,13 @@ window.addEventListener("message", receiveIframeMessage, false); maxViewportWidth = config.ishViewportRange.l[1]; } + //if both are set, then let's use the larger one. + if (config.ishViewportRange && config.ishMaximum) { + var largeRange = parseInt(config.ishViewportRange.l[1]); + var ishMaximum = parseInt(config.ishMaximum); + maxViewportWidth = largeRange > ishMaximum ? largeRange : ishMaximum; + } + var viewportResizeHandleWidth = 14, //Width of the viewport drag-to-resize handle $sgViewport = $('#sg-viewport'), //Viewport element $sizePx = $('.sg-size-px'), //Px size input element in toolbar diff --git a/dist/styleguide/js/patternlab-viewer.min.js b/dist/styleguide/js/patternlab-viewer.min.js index 4c41f46..e39b67d 100644 --- a/dist/styleguide/js/patternlab-viewer.min.js +++ b/dist/styleguide/js/patternlab-viewer.min.js @@ -1 +1 @@ -function receiveIframeMessage(e){if("file:"==window.location.protocol||e.origin===window.location.protocol+"//"+window.location.host){var t,n={};try{n="string"!=typeof e.data?e.data:JSON.parse(e.data)}catch(a){}if(void 0!==n.event&&"patternLab.updatePath"==n.event)if(void 0!==patternData.patternPartial){var i=/(patterns|snapshots)\/(.*)$/;t=window.location.protocol+"//"+window.location.host+window.location.pathname.replace(i,"")+n.path+"?"+Date.now(),window.location.replace(t)}else t=window.location.protocol+"//"+window.location.host+window.location.pathname.replace("styleguide/html/styleguide.html","")+n.path+"?"+Date.now(),window.location.replace(t);else void 0!==n.event&&"patternLab.reload"==n.event&&window.location.reload()}}!function(e,t,n){function a(e){return e}function i(e){return decodeURIComponent(e.replace(o," "))}var o=/\+/g,r=e.cookie=function(o,l,s){if(l!==n){if(s=e.extend({},r.defaults,s),null===l&&(s.expires=-1),"number"==typeof s.expires){var d=s.expires,c=s.expires=new Date;c.setDate(c.getDate()+d)}return l=r.json?JSON.stringify(l):String(l),t.cookie=[encodeURIComponent(o),"=",r.raw?l:encodeURIComponent(l),s.expires?"; expires="+s.expires.toUTCString():"",s.path?"; path="+s.path:"",s.domain?"; domain="+s.domain:"",s.secure?"; secure":""].join("")}for(var p=r.raw?a:i,g=t.cookie.split("; "),u=0,f=g.length;f>u;u++){var h=g[u].split("=");if(p(h.shift())===o){var m=p(h.join("="));return r.json?JSON.parse(m):m}}return null};r.defaults={},e.removeCookie=function(t,n){return null!==e.cookie(t)?(e.cookie(t,null,n),!0):!1}}(jQuery,document);var DataSaver={cookieName:"patternlab",addValue:function(e,t){var n=$.cookie(this.cookieName);n=null===n||""===n?e+"~"+t:n+"|"+e+"~"+t,$.cookie(this.cookieName,n)},updateValue:function(e,t){if(this.findValue(e)){for(var n="",a=$.cookie(this.cookieName).split("|"),i=0;i0?"|"+o[0]+"~"+o[1]:o[0]+"~"+o[1]}$.cookie(this.cookieName,n)}else this.addValue(e,t)},removeValue:function(e){for(var t="",n=$.cookie(this.cookieName).split("|"),a=0,i=0;ia;)o+="-"+n[a],a++;var r=e.slice(o.length+1,e.length);return[o,r]},getRequestVars:function(){var e=new function(e){if(e.length>1)for(var t,n=0,a=e.substr(1).split("&");n1?unescape(t[1]):""}(window.location.search);return e},pushPattern:function(e,t){var n={pattern:e},a=urlHandler.getFileName(e),i=window.location.pathname;i="file"===window.location.protocol?i.replace("/public/index.html","public/"):i.replace(/\/index\.html/,"/");var o=window.location.protocol+"//"+window.location.host+i+a;if(t!=o){var r=JSON.stringify({event:"patternLab.updatePath",path:a});document.getElementById("sg-viewport").contentWindow.postMessage(r,urlHandler.targetOrigin)}else{var l="file:"==window.location.protocol?null:window.location.protocol+"//"+window.location.host+window.location.pathname.replace("index.html","")+"?p="+e;void 0!==history.pushState&&history.pushState(n,null,l),document.getElementById("title").innerHTML="Pattern Lab - "+e,null!==document.getElementById("sg-raw")&&document.getElementById("sg-raw").setAttribute("href",urlHandler.getFileName(e))}},popPattern:function(e){var t,n=e.state;if(null===n)return void(this.skipBack=!1);null!==n&&(t=n.pattern);var a="";a=this.getFileName(t),""===a&&(a="styleguide/html/styleguide.html");var i=JSON.stringify({event:"patternLab.updatePath",path:a});document.getElementById("sg-viewport").contentWindow.postMessage(i,urlHandler.targetOrigin),document.getElementById("title").innerHTML="Pattern Lab - "+t,null!==document.getElementById("sg-raw")&&document.getElementById("sg-raw").setAttribute("href",urlHandler.getFileName(t))}};window.onpopstate=function(e){urlHandler.skipBack=!0,urlHandler.popPattern(e)};var modalViewer={active:!1,switchText:!0,template:"info",patternData:{},targetOrigin:"file:"===window.location.protocol?"*":window.location.protocol+"//"+window.location.host,onReady:function(){Dispatcher.addListener("insertPanels",modalViewer.insert),$(window).on("resize",function(){"false"===DataSaver.findValue("modalActive")&&modalViewer.slide($("#sg-modal-container").outerHeight())}),$("#sg-t-patterninfo").click(function(e){e.preventDefault(),$("#sg-tools-toggle").removeClass("active"),$(this).parents("ul").removeClass("active"),modalViewer.toggle()}),$("#sg-modal-close-btn").on("click",function(e){e.preventDefault(),obj=JSON.stringify({event:"patternLab.annotationsHighlightHide"}),document.getElementById("sg-viewport").contentWindow.postMessage(obj,modalViewer.targetOrigin),modalViewer.close()}),"true"===DataSaver.findValue("modalActive")&&(modalViewer.active=!0,$("#sg-t-patterninfo").html("Hide Pattern Info")),modalViewer.hide();var e=urlHandler.getRequestVars();void 0===e.view||"code"!==e.view&&"c"!==e.view||modalViewer.queryPattern(),void 0===e.view||"annotations"!==e.view&&"a"!==e.view||modalViewer.queryPattern()},toggle:function(){modalViewer.active===!1?modalViewer.queryPattern():(obj=JSON.stringify({event:"patternLab.annotationsHighlightHide"}),document.getElementById("sg-viewport").contentWindow.postMessage(obj,modalViewer.targetOrigin),modalViewer.close())},open:function(){modalViewer.close(),DataSaver.updateValue("modalActive","true"),modalViewer.active=!0,$("#sg-t-"+modalViewer.template+" .sg-checkbox").addClass("active"),$("#sg-modal-container").addClass("active"),modalViewer.show()},close:function(){var e;DataSaver.updateValue("modalActive","false"),modalViewer.active=!1,$("#sg-modal-container").removeClass("active"),$(".sg-checkbox").removeClass("active"),modalViewer.hide(),$("#sg-t-patterninfo").html("Show Pattern Info"),e=JSON.stringify({event:"patternLab.patternModalClose"}),document.getElementById("sg-viewport").contentWindow.postMessage(e,modalViewer.targetOrigin)},hide:function(){modalViewer.slide($("#sg-modal-container").outerHeight()+30)},insert:function(e,t,n,a){if(n){var i=JSON.stringify({event:"patternLab.patternModalInsert",patternPartial:t,modalContent:e.outerHTML});document.getElementById("sg-viewport").contentWindow.postMessage(i,modalViewer.targetOrigin)}else $("#sg-modal-content").html(e),modalViewer.open();a===!0&&$("#sg-t-patterninfo").html("Hide Pattern Info")},refresh:function(e,t,n){t&&modalViewer.hide(),panelsViewer.gatherPanels(e,t,n)},slide:function(e){e=0===e?0:-e,$("#sg-modal-container").css("bottom",e)},slideToAnnotation:function(e){for(els=document.querySelectorAll("#sg-annotations > .sg-annotations-list > li"),i=0;i0&&(l={displayNumber:s,el:p.el,title:p.title,comment:p.comment},t.annotations.push(l),s++);if(t.annotations.length>0){var h=JSON.stringify({event:"patternLab.annotationsHighlightShow",annotations:t.annotations});document.getElementById("sg-viewport").contentWindow.postMessage(h,panelsViewer.targetOrigin)}if(t.lineage.length>0)for(u=0;u0)for(u=0;u0||void 0!==t.patternDescAdditions&&t.patternDescAdditions.length>0,t.lineageExists=0!==t.lineage.length,t.lineageRExists=0!==t.lineageR.length,t.patternStateExists=t.patternState.length>0,t.annotationExists=t.annotations.length>0,t.descBlockExists=t.patternDescExists||t.lineageExists||t.lineageRExists||t.patternStateExists||t.annotationExists,t.isPatternView=n===!1,i=document.getElementById("pl-panel-template-base"),o=Hogan.compile(i.innerHTML),r=o.render(t),d=document.createElement("div"),d.className="sg-modal-content-inner",d.innerHTML=r,r=d,r=panelsUtil.addClickEvents(r,f),u=0;uk?k:y>e?y:e,t===!1?$("#sg-gen-container,#sg-viewport").removeClass("vp-animate"):$("#sg-gen-container,#sg-viewport").addClass("vp-animate"),$("#sg-gen-container").width(n+P),x.width(n);var a="file:"===window.location.protocol?"*":window.location.protocol+"//"+window.location.host,i=JSON.stringify({event:"patternLab.resize",resize:"true"});document.getElementById("sg-viewport").contentWindow.postMessage(i,a),g(n),p(n)}function p(e){DataSaver.findValue("vpWidth")?DataSaver.updateValue("vpWidth",e):DataSaver.addValue("vpWidth",e)}function g(e,t,n){var a,i;"em"===t?(a=e,i=Math.floor(e*S)):(i=e,a=e/S),"updatePxInput"===n?b.val(i):"updateEmInput"===n?V.val(a.toFixed(2)):(V.val(a.toFixed(2)),b.val(i))}function u(e,t){return Math.floor(Math.random()*(t-e)+e)}function f(e){$("#sg-viewport").width(e),$("#sg-gen-container").width(1*e+14),g(e)}function h(){$(".sg-nav-container, .sg-nav-toggle, .sg-acc-handle, .sg-acc-panel").removeClass("active"),patternFinder.closeFinder()}function m(e){if("file:"===window.location.protocol||e.origin===window.location.protocol+"//"+window.location.host){var t={};try{t="string"!=typeof e.data?e.data:JSON.parse(e.data)}catch(o){}if(void 0!==t.event)if("patternLab.pageLoad"==t.event)urlHandler.skipBack||void 0!==history.state&&null!==history.state&&history.state.pattern===t.patternpartial||urlHandler.pushPattern(t.patternpartial,t.path),urlHandler.skipBack=!1;else if("patternLab.keyPress"==t.event){if("ctrl+shift+s"==t.keyPress)n();else if("ctrl+shift+m"==t.keyPress)a();else if("ctrl+shift+l"==t.keyPress)i();else if("ctrl+shift+d"==t.keyPress)E?r():l();else if("ctrl+shift+h"==t.keyPress)M?s():d();else if("ctrl+shift+0"==t.keyPress)c(320,!0);else if(found==t.keyPress.match(/ctrl\+shift\+([1-9])/)){var p=C[found[1]-1],g=-1!==p.indexOf("px")?"px":"em";p=p.replace(g,"");var u="px"===g?1*p:p*S;c(u,!0)}return!1}}}var v=document.body.clientWidth,w=$(document).height(),y=240,k=2600;void 0!==config.ishMinimum&&(y=parseInt(config.ishMinimum)),void 0!==config.ishMaximum&&(k=parseInt(config.ishMaximum)),void 0!==config.ishViewportRange&&(y=config.ishViewportRange.s[0],k=config.ishViewportRange.l[1]);var P=14,x=$("#sg-viewport"),b=$(".sg-size-px"),V=$(".sg-size-em"),S=void 0!==config.ishFontSize?parseInt(config.ishFontSize):parseInt($("body").css("font-size")),I=$(".sg-header").height(),D=!1,E=!1,L=!0,M=!1;$(e).resize(function(){v=document.body.clientWidth,w=$(document).height(),t(),L===!0&&c(v,!1)}),$(".sg-acc-handle").on("click",function(e){e.preventDefault();var n=$(this),a=n.next(".sg-acc-panel"),i=n.parent().parent().hasClass("sg-acc-panel");i||($(".sg-acc-handle").not(n).removeClass("active"),$(".sg-acc-panel").not(a).removeClass("active")),n.toggleClass("active"),a.toggleClass("active"),t()}),$(".sg-nav-toggle").on("click",function(e){e.preventDefault(),$(".sg-nav-container").toggleClass("active")}),$("#sg-t-toggle").on("click",function(e){e.preventDefault(),$(this).parents("ul").toggleClass("active")}),$("#sg-size-toggle").on("click",function(e){e.preventDefault(),$(this).parents("ul").toggleClass("active")}),$(".sg-size[data-size]").on("click",function(e){e.preventDefault(),r(),s(),L=!1;var t=$(this).attr("data-size");t.indexOf("px")>-1&&(S=1),t=t.replace(/[^\d.-]/g,""),c(Math.floor(t*S))}),$("#sg-size-s").on("click",function(e){e.preventDefault(),n()}),jwerty.key("ctrl+shift+s",function(e){return n(),!1}),$("#sg-size-m").on("click",function(e){e.preventDefault(),a()}),jwerty.key("ctrl+shift+m",function(e){return i(),!1}),$("#sg-size-l").on("click",function(e){e.preventDefault(),i()}),jwerty.key("ctrl+shift+l",function(e){return i(),!1}),$("#sg-size-full").on("click",function(e){e.preventDefault(),r(),s(),L=!0,c(v)}),$("#sg-size-random").on("click",function(e){e.preventDefault(),r(),s(),L=!1,c(u(y,v))}),$("#sg-size-disco").on("click",function(e){e.preventDefault(),s(),L=!1,E?r():l()}),jwerty.key("ctrl+shift+d",function(e){return E?r():l(),!1}),$("#sg-size-hay").on("click",function(e){e.preventDefault(),r(),M?s():d()}),jwerty.key("ctrl+shift+h",function(e){M?s():d()}),b.on("keydown",function(e){var t=Math.floor($(this).val());38===e.keyCode?(t++,c(t,!1)):40===e.keyCode?(t--,c(t,!1)):13===e.keyCode&&(e.preventDefault(),c(t),$(this).blur())}),b.on("keyup",function(){var e=Math.floor($(this).val());g(e,"px","updateEmInput")}),V.on("keydown",function(e){var t=parseFloat($(this).val());38===e.keyCode?(t++,c(Math.floor(t*S),!1)):40===e.keyCode?(t--,c(Math.floor(t*S),!1)):13===e.keyCode&&(e.preventDefault(),c(Math.floor(t*S)))}),V.on("keyup",function(){var e=parseFloat($(this).val());g(e,"em","updatePxInput")}),jwerty.key("ctrl+shift+0",function(e){return e.preventDefault(),c(320,!0),!1});var C=[];$("#sg-mq a").each(function(e){C.push($(this).html()),$(this).on("click",function(e,t){return function(e){e.preventDefault();var n=$(t).html(),a=-1!==n.indexOf("px")?"px":"em";n=n.replace(a,"");var i="px"===a?1*n:n*S;c(i,!0)}}(e,this)),jwerty.key("ctrl+shift+"+(e+1),function(e){return function(t){var n=$(e).html(),a=-1!==n.indexOf("px")?"px":"em";n=n.replace(a,"");var i="px"===a?1*n:n*S;return c(i,!0),!1}}(this))}),$("#sg-gen-container").on("transitionend webkitTransitionEnd",function(e){var t="file:"===window.location.protocol?"*":window.location.protocol+"//"+window.location.host,n=JSON.stringify({event:"patternLab.resize",resize:"true"});document.getElementById("sg-viewport").contentWindow.postMessage(n,t)}),$("#sg-gen-container").on("touchstart",function(e){}),$("#sg-rightpull").mousedown(function(e){var t=e.clientX,n=x.width();return L=!1,$("#sg-cover").css("display","block"),$("#sg-cover").mousemove(function(e){var a;a=n+2*(e.clientX-t),a>y&&(DataSaver.findValue("vpWidth")?DataSaver.updateValue("vpWidth",a):DataSaver.addValue("vpWidth",a),c(a,!1))}),!1}),$("body").mouseup(function(){$("#sg-cover").unbind("mousemove"),$("#sg-cover").css("display","none")});var H=$("#sg-viewport").width();$("#sg-gen-container").width(H);var N=screen.width;void 0!==window.orientation&&(N=0===window.orientation?screen.width:screen.height),$(window).width()==N&&"ontouchstart"in document.documentElement&&$(window).width()<=1024?$("#sg-rightpull-container").width(0):$("#sg-viewport").width(H-14),g($("#sg-viewport").width());var F=urlHandler.getRequestVars(),O=0,B=!0;void 0!==F.h||void 0!==F.hay?d():void 0!==F.d||void 0!==F.disco?l():void 0!==F.w||void 0!==F.width?(O=void 0!==F.w?F.w:F.width,O=-1!==O.indexOf("em")?Math.floor(Math.floor(O.replace("em",""))*S):Math.floor(O.replace("px","")),DataSaver.updateValue("vpWidth",O),f(O)):B&&(O=DataSaver.findValue("vpWidth"))&&f(O);var R=window.location.protocol+"//"+window.location.host+window.location.pathname.replace("index.html",""),T=void 0!==config.defaultPattern&&"string"==typeof config.defaultPattern&&config.defaultPattern.trim().length>0?config.defaultPattern:"all",q=R+"styleguide/html/styleguide.html?"+Date.now();if(void 0===F.p&&void 0===F.pattern||(T=void 0!==F.p?F.p:F.pattern),"all"!==T&&(patternPath=urlHandler.getFileName(T),q=""!==patternPath?R+patternPath+"?"+Date.now():q,document.getElementById("title").innerHTML="Pattern Lab - "+T,history.replaceState({pattern:T},null,null)),null!==document.getElementById("sg-raw")&&document.getElementById("sg-raw").setAttribute("href",urlHandler.getFileName(T)),urlHandler.skipBack=!0,document.getElementById("sg-viewport").contentWindow.location.replace(q),$("a[data-patternpartial]").on("click",function(e){e.preventDefault();var t=JSON.stringify({event:"patternLab.updatePath",path:urlHandler.getFileName($(this).attr("data-patternpartial"))});document.getElementById("sg-viewport").contentWindow.postMessage(t,urlHandler.targetOrigin),h()}),$("#sg-vp-wrap").click(function(){h()}),void 0!==window.orientation){var z=window.orientation;window.addEventListener("orientationchange",function(){window.orientation!=z&&($("#sg-gen-container").width($(window).width()),$("#sg-viewport").width($(window).width()),g($(window).width()),z=window.orientation)},!1)}window.addEventListener("message",m,!1)}(this);var pluginLoader={init:function(){for(var s,t,l,c,n,i=0;i0?"|"+o[0]+"~"+o[1]:o[0]+"~"+o[1]}$.cookie(this.cookieName,n)}else this.addValue(e,t)},removeValue:function(e){for(var t="",n=$.cookie(this.cookieName).split("|"),a=0,i=0;i1)for(var t,n=0,a=e.substr(1).split("&");n1?unescape(t[1]):""}(window.location.search);return e},pushPattern:function(e,t){var n={pattern:e},a=urlHandler.getFileName(e),i=window.location.pathname;i="file"===window.location.protocol?i.replace("/public/index.html","public/"):i.replace(/\/index\.html/,"/");var o=window.location.protocol+"//"+window.location.host+i+a;if(t!=o){var r=JSON.stringify({event:"patternLab.updatePath",path:a});document.getElementById("sg-viewport").contentWindow.postMessage(r,urlHandler.targetOrigin)}else{var l="file:"==window.location.protocol?null:window.location.protocol+"//"+window.location.host+window.location.pathname.replace("index.html","")+"?p="+e;void 0!==history.pushState&&history.pushState(n,null,l),document.getElementById("title").innerHTML="Pattern Lab - "+e,null!==document.getElementById("sg-raw")&&document.getElementById("sg-raw").setAttribute("href",urlHandler.getFileName(e))}},popPattern:function(e){var t,n=e.state;if(null===n)return void(this.skipBack=!1);null!==n&&(t=n.pattern);var a="";a=this.getFileName(t),""===a&&(a="styleguide/html/styleguide.html");var i=JSON.stringify({event:"patternLab.updatePath",path:a});document.getElementById("sg-viewport").contentWindow.postMessage(i,urlHandler.targetOrigin),document.getElementById("title").innerHTML="Pattern Lab - "+t,null!==document.getElementById("sg-raw")&&document.getElementById("sg-raw").setAttribute("href",urlHandler.getFileName(t))}};window.onpopstate=function(e){urlHandler.skipBack=!0,urlHandler.popPattern(e)};var modalViewer={active:!1,switchText:!0,template:"info",patternData:{},targetOrigin:"file:"===window.location.protocol?"*":window.location.protocol+"//"+window.location.host,onReady:function(){Dispatcher.addListener("insertPanels",modalViewer.insert),$(window).on("resize",function(){"false"===DataSaver.findValue("modalActive")&&modalViewer.slide($("#sg-modal-container").outerHeight())}),$("#sg-t-patterninfo").click(function(e){e.preventDefault(),$("#sg-tools-toggle").removeClass("active"),$(this).parents("ul").removeClass("active"),modalViewer.toggle()}),$("#sg-modal-close-btn").on("click",function(e){e.preventDefault(),obj=JSON.stringify({event:"patternLab.annotationsHighlightHide"}),document.getElementById("sg-viewport").contentWindow.postMessage(obj,modalViewer.targetOrigin),modalViewer.close()}),"true"===DataSaver.findValue("modalActive")&&(modalViewer.active=!0,$("#sg-t-patterninfo").html("Hide Pattern Info")),modalViewer.hide();var e=urlHandler.getRequestVars();void 0===e.view||"code"!==e.view&&"c"!==e.view||modalViewer.queryPattern(),void 0===e.view||"annotations"!==e.view&&"a"!==e.view||modalViewer.queryPattern()},toggle:function(){modalViewer.active===!1?modalViewer.queryPattern():(obj=JSON.stringify({event:"patternLab.annotationsHighlightHide"}),document.getElementById("sg-viewport").contentWindow.postMessage(obj,modalViewer.targetOrigin),modalViewer.close())},open:function(){modalViewer.close(),DataSaver.updateValue("modalActive","true"),modalViewer.active=!0,$("#sg-t-"+modalViewer.template+" .sg-checkbox").addClass("active"),$("#sg-modal-container").addClass("active"),modalViewer.show()},close:function(){var e;DataSaver.updateValue("modalActive","false"),modalViewer.active=!1,$("#sg-modal-container").removeClass("active"),$(".sg-checkbox").removeClass("active"),modalViewer.hide(),$("#sg-t-patterninfo").html("Show Pattern Info"),e=JSON.stringify({event:"patternLab.patternModalClose"}),document.getElementById("sg-viewport").contentWindow.postMessage(e,modalViewer.targetOrigin)},hide:function(){modalViewer.slide($("#sg-modal-container").outerHeight()+30)},insert:function(e,t,n,a){if(n){var i=JSON.stringify({event:"patternLab.patternModalInsert",patternPartial:t,modalContent:e.outerHTML});document.getElementById("sg-viewport").contentWindow.postMessage(i,modalViewer.targetOrigin)}else $("#sg-modal-content").html(e),modalViewer.open();a===!0&&$("#sg-t-patterninfo").html("Hide Pattern Info")},refresh:function(e,t,n){t&&modalViewer.hide(),panelsViewer.gatherPanels(e,t,n)},slide:function(e){e=0===e?0:-e,$("#sg-modal-container").css("bottom",e)},slideToAnnotation:function(e){for(els=document.querySelectorAll("#sg-annotations > .sg-annotations-list > li"),i=0;i0&&(l={displayNumber:s,el:p.el,title:p.title,comment:p.comment},t.annotations.push(l),s++);if(t.annotations.length>0){var h=JSON.stringify({event:"patternLab.annotationsHighlightShow",annotations:t.annotations});document.getElementById("sg-viewport").contentWindow.postMessage(h,panelsViewer.targetOrigin)}if(t.lineage.length>0)for(u=0;u0)for(u=0;u0||void 0!==t.patternDescAdditions&&t.patternDescAdditions.length>0,t.lineageExists=0!==t.lineage.length,t.lineageRExists=0!==t.lineageR.length,t.patternStateExists=t.patternState.length>0,t.annotationExists=t.annotations.length>0,t.descBlockExists=t.patternDescExists||t.lineageExists||t.lineageRExists||t.patternStateExists||t.annotationExists,t.isPatternView=n===!1,i=document.getElementById("pl-panel-template-base"),o=Hogan.compile(i.innerHTML),r=o.render(t),d=document.createElement("div"),d.className="sg-modal-content-inner",d.innerHTML=r,r=d,r=panelsUtil.addClickEvents(r,f),u=0;uk?k:ex?P:x}var b=14,V=$("#sg-viewport"),I=$(".sg-size-px"),S=$(".sg-size-em"),D=void 0!==config.ishFontSize?parseInt(config.ishFontSize):parseInt($("body").css("font-size")),E=$(".sg-header").height(),M=!1,L=!1,C=!0,H=!1;$(e).resize(function(){v=document.body.clientWidth,w=$(document).height(),t(),C===!0&&c(v,!1)}),$(".sg-acc-handle").on("click",function(e){e.preventDefault();var n=$(this),a=n.next(".sg-acc-panel"),i=n.parent().parent().hasClass("sg-acc-panel");i||($(".sg-acc-handle").not(n).removeClass("active"),$(".sg-acc-panel").not(a).removeClass("active")),n.toggleClass("active"),a.toggleClass("active"),t()}),$(".sg-nav-toggle").on("click",function(e){e.preventDefault(),$(".sg-nav-container").toggleClass("active")}),$("#sg-t-toggle").on("click",function(e){e.preventDefault(),$(this).parents("ul").toggleClass("active")}),$("#sg-size-toggle").on("click",function(e){e.preventDefault(),$(this).parents("ul").toggleClass("active")}),$(".sg-size[data-size]").on("click",function(e){e.preventDefault(),r(),s(),C=!1;var t=$(this).attr("data-size");t.indexOf("px")>-1&&(D=1),t=t.replace(/[^\d.-]/g,""),c(Math.floor(t*D))}),$("#sg-size-s").on("click",function(e){e.preventDefault(),n()}),jwerty.key("ctrl+shift+s",function(e){return n(),!1}),$("#sg-size-m").on("click",function(e){e.preventDefault(),a()}),jwerty.key("ctrl+shift+m",function(e){return i(),!1}),$("#sg-size-l").on("click",function(e){e.preventDefault(),i()}),jwerty.key("ctrl+shift+l",function(e){return i(),!1}),$("#sg-size-full").on("click",function(e){e.preventDefault(),r(),s(),C=!0,c(v)}),$("#sg-size-random").on("click",function(e){e.preventDefault(),r(),s(),C=!1,c(u(y,v))}),$("#sg-size-disco").on("click",function(e){e.preventDefault(),s(),C=!1,L?r():l()}),jwerty.key("ctrl+shift+d",function(e){return L?r():l(),!1}),$("#sg-size-hay").on("click",function(e){e.preventDefault(),r(),H?s():d()}),jwerty.key("ctrl+shift+h",function(e){H?s():d()}),I.on("keydown",function(e){var t=Math.floor($(this).val());38===e.keyCode?(t++,c(t,!1)):40===e.keyCode?(t--,c(t,!1)):13===e.keyCode&&(e.preventDefault(),c(t),$(this).blur())}),I.on("keyup",function(){var e=Math.floor($(this).val());g(e,"px","updateEmInput")}),S.on("keydown",function(e){var t=parseFloat($(this).val());38===e.keyCode?(t++,c(Math.floor(t*D),!1)):40===e.keyCode?(t--,c(Math.floor(t*D),!1)):13===e.keyCode&&(e.preventDefault(),c(Math.floor(t*D)))}),S.on("keyup",function(){var e=parseFloat($(this).val());g(e,"em","updatePxInput")}),jwerty.key("ctrl+shift+0",function(e){return e.preventDefault(),c(320,!0),!1});var N=[];$("#sg-mq a").each(function(e){N.push($(this).html()),$(this).on("click",function(e,t){return function(e){e.preventDefault();var n=$(t).html(),a=n.indexOf("px")!==-1?"px":"em";n=n.replace(a,"");var i="px"===a?1*n:n*D;c(i,!0)}}(e,this)),jwerty.key("ctrl+shift+"+(e+1),function(e){return function(t){var n=$(e).html(),a=n.indexOf("px")!==-1?"px":"em";n=n.replace(a,"");var i="px"===a?1*n:n*D;return c(i,!0),!1}}(this))}),$("#sg-gen-container").on("transitionend webkitTransitionEnd",function(e){var t="file:"===window.location.protocol?"*":window.location.protocol+"//"+window.location.host,n=JSON.stringify({event:"patternLab.resize",resize:"true"});document.getElementById("sg-viewport").contentWindow.postMessage(n,t)}),$("#sg-gen-container").on("touchstart",function(e){}),$("#sg-rightpull").mousedown(function(e){var t=e.clientX,n=V.width();return C=!1,$("#sg-cover").css("display","block"),$("#sg-cover").mousemove(function(e){var a;a=n+2*(e.clientX-t),a>y&&(DataSaver.findValue("vpWidth")?DataSaver.updateValue("vpWidth",a):DataSaver.addValue("vpWidth",a),c(a,!1))}),!1}),$("body").mouseup(function(){$("#sg-cover").unbind("mousemove"),$("#sg-cover").css("display","none")});var F=$("#sg-viewport").width();$("#sg-gen-container").width(F);var O=screen.width;void 0!==window.orientation&&(O=0===window.orientation?screen.width:screen.height),$(window).width()==O&&"ontouchstart"in document.documentElement&&$(window).width()<=1024?$("#sg-rightpull-container").width(0):$("#sg-viewport").width(F-14),g($("#sg-viewport").width());var B=urlHandler.getRequestVars(),R=0,T=!0;void 0!==B.h||void 0!==B.hay?d():void 0!==B.d||void 0!==B.disco?l():void 0!==B.w||void 0!==B.width?(R=void 0!==B.w?B.w:B.width,R=R.indexOf("em")!==-1?Math.floor(Math.floor(R.replace("em",""))*D):Math.floor(R.replace("px","")),DataSaver.updateValue("vpWidth",R),f(R)):T&&(R=DataSaver.findValue("vpWidth"))&&f(R);var q=window.location.protocol+"//"+window.location.host+window.location.pathname.replace("index.html",""),z=void 0!==config.defaultPattern&&"string"==typeof config.defaultPattern&&config.defaultPattern.trim().length>0?config.defaultPattern:"all",A=q+"styleguide/html/styleguide.html?"+Date.now();if(void 0===B.p&&void 0===B.pattern||(z=void 0!==B.p?B.p:B.pattern),"all"!==z&&(patternPath=urlHandler.getFileName(z),A=""!==patternPath?q+patternPath+"?"+Date.now():A,document.getElementById("title").innerHTML="Pattern Lab - "+z,history.replaceState({pattern:z},null,null)),null!==document.getElementById("sg-raw")&&document.getElementById("sg-raw").setAttribute("href",urlHandler.getFileName(z)),urlHandler.skipBack=!0,document.getElementById("sg-viewport").contentWindow.location.replace(A),$("a[data-patternpartial]").on("click",function(e){e.preventDefault();var t=JSON.stringify({event:"patternLab.updatePath",path:urlHandler.getFileName($(this).attr("data-patternpartial"))});document.getElementById("sg-viewport").contentWindow.postMessage(t,urlHandler.targetOrigin),h()}),$("#sg-vp-wrap").click(function(){h()}),void 0!==window.orientation){var W=window.orientation;window.addEventListener("orientationchange",function(){window.orientation!=W&&($("#sg-gen-container").width($(window).width()),$("#sg-viewport").width($(window).width()),g($(window).width()),W=window.orientation)},!1)}window.addEventListener("message",m,!1)}(this);var pluginLoader={init:function(){for(var s,t,l,c,n,i=0;i ishMaximum ? largeRange : ishMaximum; + } + var viewportResizeHandleWidth = 14, //Width of the viewport drag-to-resize handle $sgViewport = $('#sg-viewport'), //Viewport element $sizePx = $('.sg-size-px'), //Px size input element in toolbar