mirror of
https://github.com/pattern-lab/patternlab-php.git
synced 2025-01-17 06:08:23 +01:00
removing unnecessary styleguide files
This commit is contained in:
parent
0d9263d35f
commit
92e8235464
112
public/styleguide/css/vendor/prism.css
vendored
112
public/styleguide/css/vendor/prism.css
vendored
@ -1,112 +0,0 @@
|
||||
/**
|
||||
* okaidia theme for JavaScript, CSS and HTML
|
||||
* Loosely based on Monokai textmate theme by http://www.monokai.nl/
|
||||
* @author ocodia
|
||||
*/
|
||||
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
color: #f8f8f2;
|
||||
text-shadow: 0 1px rgba(0,0,0,0.3);
|
||||
font-family: Consolas, Monaco, 'Andale Mono', monospace;
|
||||
direction: ltr;
|
||||
text-align: left;
|
||||
white-space: pre;
|
||||
word-spacing: normal;
|
||||
|
||||
-moz-tab-size: 4;
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4;
|
||||
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
/* Code blocks */
|
||||
pre[class*="language-"] {
|
||||
padding: 1em;
|
||||
margin: .5em 0;
|
||||
overflow: auto;
|
||||
border-radius: 0.3em;
|
||||
}
|
||||
|
||||
:not(pre) > code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
background: #272822;
|
||||
}
|
||||
|
||||
/* Inline code */
|
||||
:not(pre) > code[class*="language-"] {
|
||||
padding: .1em;
|
||||
border-radius: .3em;
|
||||
}
|
||||
|
||||
.token.comment,
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
color: slategray;
|
||||
}
|
||||
|
||||
.token.punctuation {
|
||||
color: #f8f8f2;
|
||||
}
|
||||
|
||||
.namespace {
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
.token.property,
|
||||
.token.tag,
|
||||
.token.constant,
|
||||
.token.symbol {
|
||||
color: #f92672;
|
||||
}
|
||||
|
||||
.token.boolean,
|
||||
.token.number{
|
||||
color: #ae81ff;
|
||||
}
|
||||
|
||||
.token.selector,
|
||||
.token.attr-name,
|
||||
.token.string,
|
||||
.token.builtin {
|
||||
color: #a6e22e;
|
||||
}
|
||||
|
||||
|
||||
.token.operator,
|
||||
.token.entity,
|
||||
.token.url,
|
||||
.language-css .token.string,
|
||||
.style .token.string,
|
||||
.token.variable {
|
||||
color: #f8f8f2;
|
||||
}
|
||||
|
||||
.token.atrule,
|
||||
.token.attr-value
|
||||
{
|
||||
color: #e6db74;
|
||||
}
|
||||
|
||||
|
||||
.token.keyword{
|
||||
color: #66d9ef;
|
||||
}
|
||||
|
||||
.token.regex,
|
||||
.token.important {
|
||||
color: #fd971f;
|
||||
}
|
||||
|
||||
.token.important {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.token.entity {
|
||||
cursor: help;
|
||||
}
|
66
public/styleguide/css/vendor/typeahead.css
vendored
66
public/styleguide/css/vendor/typeahead.css
vendored
@ -1,66 +0,0 @@
|
||||
#sg-find {
|
||||
color: #000;
|
||||
text-transform: lowercase;
|
||||
}
|
||||
|
||||
.show-overflow {
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.typeahead,
|
||||
.tt-query,
|
||||
.tt-hint {
|
||||
width: 220px;
|
||||
height: 30px;
|
||||
padding: 8px 12px;
|
||||
font-size: 14px;
|
||||
line-height: 16px;
|
||||
border: 2px solid #ccc;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.typeahead {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.typeahead:focus {
|
||||
border: 2px solid #999;
|
||||
}
|
||||
|
||||
.tt-query {
|
||||
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
||||
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
||||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
||||
}
|
||||
|
||||
.tt-hint {
|
||||
color: #999
|
||||
}
|
||||
|
||||
.tt-dropdown-menu {
|
||||
width: 422px;
|
||||
padding: 8px 0;
|
||||
background-color: #fff;
|
||||
border: 1px solid #ccc;
|
||||
border: 1px solid rgba(0, 0, 0, 0.2);
|
||||
text-align: left;
|
||||
-webkit-box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||
-moz-box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||
box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||
}
|
||||
|
||||
.tt-suggestion {
|
||||
padding: 3px 13px;
|
||||
font-size: 14px;
|
||||
line-height: 16px;
|
||||
}
|
||||
|
||||
.tt-suggestion.tt-cursor {
|
||||
color: #fff;
|
||||
background-color: #0097cf;
|
||||
|
||||
}
|
||||
|
||||
.tt-suggestion p {
|
||||
margin: 0;
|
||||
}
|
Binary file not shown.
@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<metadata>Generated by IcoMoon</metadata>
|
||||
<defs>
|
||||
<font id="icomoon" horiz-adv-x="512">
|
||||
<font-face units-per-em="512" ascent="480" descent="-32" />
|
||||
<missing-glyph horiz-adv-x="512" />
|
||||
<glyph unicode=" " d="" horiz-adv-x="256" />
|
||||
<glyph unicode="" d="M496.131 44.302l-121.276 103.147c-12.537 11.283-25.945 16.463-36.776 15.963 28.628 33.534 45.921 77.039 45.921 124.588 0 106.039-85.961 192-192 192-106.038 0-192-85.961-192-192 0-106.039 85.961-192 192-192 47.549 0 91.054 17.293 124.588 45.922-0.5-10.831 4.68-24.239 15.963-36.776l103.147-121.276c17.661-19.623 46.511-21.277 64.11-3.678s15.946 46.449-3.677 64.11zM192 160c-70.692 0-128 57.308-128 128s57.308 128 128 128 128-57.308 128-128-57.307-128-128-128z" />
|
||||
<glyph unicode="" d="M512 175.953v96.094l-73.387 12.231c-2.979 9.066-6.611 17.834-10.847 26.25l43.227 60.517-67.948 67.949-60.413-43.152c-8.455 4.277-17.269 7.944-26.384 10.951l-12.201 73.207h-96.094l-12.201-73.208c-9.115-3.007-17.929-6.674-26.383-10.951l-60.414 43.152-67.949-67.949 43.227-60.518c-4.235-8.415-7.867-17.183-10.846-26.249l-73.387-12.23v-96.094l73.559-12.26c2.98-8.984 6.605-17.674 10.821-26.015l-43.374-60.724 67.949-67.948 60.827 43.447c8.301-4.175 16.945-7.764 25.882-10.717l12.289-73.736h96.094l12.289 73.737c8.937 2.953 17.581 6.542 25.883 10.716l60.826-43.446 67.948 67.948-43.372 60.723c4.216 8.341 7.839 17.031 10.82 26.016l73.559 12.259zM256 160c-35.346 0-64 28.653-64 64 0 35.346 28.654 64 64 64 35.347 0 64-28.654 64-64 0-35.347-28.653-64-64-64z" />
|
||||
<glyph unicode="" d="M0 272v-96c0-8.836 7.164-16 16-16h480c8.836 0 16 7.164 16 16v96c0 8.836-7.164 16-16 16h-480c-8.836 0-16-7.164-16-16z" />
|
||||
<glyph unicode="" d="M496 288h-176v176c0 8.836-7.164 16-16 16h-96c-8.836 0-16-7.164-16-16v-176h-176c-8.836 0-16-7.164-16-16v-96c0-8.836 7.164-16 16-16h176v-176c0-8.836 7.164-16 16-16h96c8.836 0 16 7.164 16 16v176h176c8.836 0 16 7.164 16 16v96c0 8.836-7.164 16-16 16z" />
|
||||
<glyph unicode="" d="M32 384h448v-96h-448zM32 256h448v-96h-448zM32 128h448v-96h-448z" />
|
||||
<glyph unicode="" d="M256 480c-141.385 0-256-114.615-256-256s114.615-256 256-256 256 114.615 256 256-114.615 256-256 256zM256 32c-106.039 0-192 85.961-192 192s85.961 192 192 192c106.039 0 192-85.961 192-192 0-106.039-85.961-192-192-192zM160 224c0 53.019 42.981 96 96 96s96-42.981 96-96c0-53.019-42.981-96-96-96-53.019 0-96 42.981-96 96z" />
|
||||
<glyph unicode="" d="M256 480c-141.385 0-256-114.615-256-256s114.615-256 256-256 256 114.615 256 256-114.615 256-256 256zM256 32c-106.039 0-192 85.961-192 192s85.961 192 192 192c106.039 0 192-85.961 192-192 0-106.039-85.961-192-192-192z" />
|
||||
<glyph unicode="" d="M446.059 385.941l-60.117 60.118c-18.669 18.668-55.542 33.941-81.942 33.941h-224c-26.4 0-48-21.6-48-48v-416c0-26.4 21.6-48 48-48h352c26.4 0 48 21.6 48 48v288c0 26.4-15.273 63.273-33.941 81.941zM320 412.219c1.098-0.402 2.226-0.84 3.379-1.318 9.030-3.741 15.299-8.088 17.308-10.097l60.118-60.119c2.009-2.009 6.356-8.277 10.097-17.307 0.478-1.153 0.916-2.281 1.318-3.378h-92.22v92.219zM416 32h-320v384h192v-128h128v-256zM128 224h256v-32h-256zM128 160h256v-32h-256zM128 96h256v-32h-256z" />
|
||||
<glyph unicode="" d="M476.698 442.679l-2.014 2.021c-47.074 47.067-124.097 47.067-171.163 0l-109.053-109.068c-47.067-47.066-47.067-124.088 0-171.155l2.013-2.013c3.916-3.924 8.073-7.462 12.368-10.729l39.924 39.925c-4.651 2.747-9.063 6.036-13.058 10.030l-2.021 2.021c-25.557 25.549-25.557 67.136 0 92.695l109.064 109.056c25.558 25.559 67.137 25.559 92.693 0l2.021-2.012c25.55-25.558 25.55-67.146 0-92.695l-49.343-49.343c8.566-21.154 12.624-43.7 12.269-66.193l76.302 76.302c47.067 47.068 47.067 124.089-0.002 171.158zM315.521 285.533c-3.916 3.916-8.073 7.461-12.368 10.72l-39.924-39.916c4.652-2.748 9.063-6.037 13.058-10.031l2.021-2.020c25.558-25.558 25.558-67.136 0-92.694l-109.065-109.067c-25.559-25.551-67.138-25.551-92.694 0l-2.021 2.021c-25.549 25.56-25.549 67.138 0 92.694l49.344 49.343c-8.567 21.153-12.623 43.701-12.269 66.193l-76.301-76.299c-47.068-47.066-47.068-124.089 0-171.162l2.013-2.016c47.076-47.064 124.096-47.064 171.164 0l109.055 109.059c47.067 47.066 47.067 124.097 0 171.163l-2.013 2.012z" />
|
||||
<glyph unicode="" d="M544 416h-512c-17.6 0-32-14.4-32-32v-320c0-17.6 14.4-32 32-32h512c17.6 0 32 14.4 32 32v320c0 17.6-14.4 32-32 32zM320 352h64v-64h-64v64zM416 256v-64h-64v64h64zM224 352h64v-64h-64v64zM320 256v-64h-64v64h64zM128 352h64v-64h-64v64zM224 256v-64h-64v64h64zM64 352h32v-64h-32v64zM64 256h64v-64h-64v64zM96 96h-32v64h32v-64zM384 96h-256v64h256v-64zM512 96h-96v64h96v-64zM512 192h-64v64h64v-64zM512 288h-96v64h96v-64z" horiz-adv-x="576" />
|
||||
<glyph unicode="" d="M160 448h-128v-128h128v128zM192 480v0-192h-192v192h192zM64 416h64v-64h-64zM480 448h-128v-128h128v128zM512 480v0-192h-192v192h192zM384 416h64v-64h-64zM160 128h-128v-128h128v128zM192 160v0-192h-192v192h192zM64 96h64v-64h-64zM224 480h32v-32h-32zM256 448h32v-32h-32zM224 416h32v-32h-32zM256 384h32v-32h-32zM224 352h32v-32h-32zM256 320h32v-32h-32zM224 288h32v-32h-32zM224 224h32v-32h-32zM256 192h32v-32h-32zM224 160h32v-32h-32zM256 128h32v-32h-32zM224 96h32v-32h-32zM256 64h32v-32h-32zM224 32h32v-32h-32zM256 0h32v-32h-32zM480 224h32v-32h-32zM32 224h32v-32h-32zM64 256h32v-32h-32zM0 256h32v-32h-32zM128 256h32v-32h-32zM160 224h32v-32h-32zM192 256h32v-32h-32zM288 224h32v-32h-32zM320 256h32v-32h-32zM352 224h32v-32h-32zM384 256h32v-32h-32zM416 224h32v-32h-32zM448 256h32v-32h-32zM480 160h32v-32h-32zM288 160h32v-32h-32zM320 192h32v-32h-32zM352 160h32v-32h-32zM416 160h32v-32h-32zM448 192h32v-32h-32zM480 96h32v-32h-32zM288 96h32v-32h-32zM320 128h32v-32h-32zM384 128h32v-32h-32zM416 96h32v-32h-32zM448 128h32v-32h-32zM480 32h32v-32h-32zM320 64h32v-32h-32zM352 32h32v-32h-32zM384 64h32v-32h-32zM416 32h32v-32h-32zM320 0h32v-32h-32zM384 0h32v-32h-32zM448 0h32v-32h-32z" />
|
||||
<glyph unicode="" d="M256 384c-111.659 0-208.441-65.021-256-160 47.559-94.979 144.341-160 256-160 111.657 0 208.439 65.021 256 160-47.558 94.979-144.343 160-256 160zM382.225 299.148c30.081-19.187 55.571-44.887 74.717-75.148-19.146-30.261-44.637-55.961-74.718-75.149-37.797-24.108-81.445-36.851-126.224-36.851-44.78 0-88.428 12.743-126.225 36.852-30.080 19.186-55.57 44.886-74.717 75.148 19.146 30.262 44.637 55.962 74.717 75.148 1.959 1.25 3.938 2.461 5.929 3.65-4.979-13.664-7.704-28.411-7.704-43.798 0-70.692 57.308-128 128-128s128 57.308 128 128c0 15.387-2.725 30.134-7.704 43.799 1.99-1.189 3.969-2.401 5.929-3.651zM256 275c0-26.51-21.49-48-48-48s-48 21.49-48 48 21.49 48 48 48 48-21.49 48-48z" />
|
||||
</font></defs></svg>
|
Before Width: | Height: | Size: 6.6 KiB |
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
||||
will hold the auto-generated styleguide.html
|
Binary file not shown.
Before Width: | Height: | Size: 23 KiB |
@ -1,308 +0,0 @@
|
||||
/*!
|
||||
* Annotations Support for Patterns - v0.3
|
||||
*
|
||||
* Copyright (c) 2013-2014 Dave Olsen, http://dmolsen.com
|
||||
* Licensed under the MIT license
|
||||
*
|
||||
*/
|
||||
|
||||
var annotationsPattern = {
|
||||
|
||||
commentsOverlayActive: false,
|
||||
commentsOverlay: false,
|
||||
commentsEmbeddedActive: false,
|
||||
commentsEmbedded: false,
|
||||
commentsGathered: { "commentOverlay": "on", "comments": { } },
|
||||
trackedElements: [ ],
|
||||
targetOrigin: (window.location.protocol == "file:") ? "*" : window.location.protocol+"//"+window.location.host,
|
||||
|
||||
/**
|
||||
* record which annotations are related to this pattern so they can be sent to the viewer when called
|
||||
*/
|
||||
gatherComments: function() {
|
||||
|
||||
// make sure this only added when we're on a pattern specific view
|
||||
if (document.getElementById("sg-patterns") === null) {
|
||||
|
||||
var count = 0;
|
||||
|
||||
for (comment in comments.comments) {
|
||||
var item = comments.comments[comment];
|
||||
var els = document.querySelectorAll(item.el);
|
||||
if (els.length > 0) {
|
||||
|
||||
count++;
|
||||
item.displaynumber = count;
|
||||
|
||||
for (var i = 0; i < els.length; ++i) {
|
||||
els[i].onclick = (function(item) {
|
||||
return function(e) {
|
||||
|
||||
if (annotationsPattern.commentsOverlayActive) {
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
// if an element was clicked on while the overlay was already on swap it
|
||||
var obj = JSON.stringify({ "displaynumber": item.displaynumber, "el": item.el, "title": item.title, "comment": item.comment });
|
||||
parent.postMessage(obj,annotationsPattern.targetOrigin);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
})(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
var obj = JSON.stringify({ "commentOverlay": "off" });
|
||||
parent.postMessage(obj,annotationsPattern.targetOrigin);
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* embed a comment by building the sg-annotations div (if necessary) and building an sg-annotation div
|
||||
* @param {Object} element to check the parent node of
|
||||
* @param {String} the title of the comment
|
||||
* @param {String} the comment HTML
|
||||
*/
|
||||
embedComments: function (el,title,comment) {
|
||||
|
||||
// build the annotation div and add the content to it
|
||||
var annotationDiv = document.createElement("div");
|
||||
annotationDiv.classList.add("sg-annotation");
|
||||
|
||||
var h3 = document.createElement("h3");
|
||||
var p = document.createElement("p");
|
||||
h3.innerHTML = title;
|
||||
p.innerHTML = comment;
|
||||
|
||||
annotationDiv.appendChild(h3);
|
||||
annotationDiv.appendChild(p);
|
||||
|
||||
// find the parent element to attach things to
|
||||
var parentEl = annotationsPattern.findParent(el);
|
||||
|
||||
// see if a child with the class annotations exists
|
||||
var els = parentEl.getElementsByClassName("sg-annotations");
|
||||
if (els.length > 0) {
|
||||
els[0].appendChild(annotationDiv);
|
||||
} else {
|
||||
var annotationsDiv = document.createElement("div");
|
||||
annotationsDiv.classList.add("sg-annotations");
|
||||
annotationsDiv.appendChild(annotationDiv);
|
||||
parentEl.appendChild(annotationsDiv);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* recursively find the parent of an element to see if it contains the sg-pattern class
|
||||
* @param {Object} element to check the parent node of
|
||||
*/
|
||||
findParent: function(el) {
|
||||
|
||||
var parentEl;
|
||||
|
||||
if (el.classList.contains("sg-pattern")) {
|
||||
return el;
|
||||
} else if (el.parentNode.classList.contains("sg-pattern")) {
|
||||
return el.parentNode;
|
||||
} else {
|
||||
parentEl = annotationsPattern.findParent(el.parentNode);
|
||||
}
|
||||
|
||||
return parentEl;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* toggle the annotation feature on/off
|
||||
* based on the great MDN docs at https://developer.mozilla.org/en-US/docs/Web/API/window.postMessage
|
||||
* @param {Object} event info
|
||||
*/
|
||||
receiveIframeMessage: function(event) {
|
||||
|
||||
var data = (typeof event.data !== "string") ? event.data : JSON.parse(event.data);
|
||||
|
||||
// does the origin sending the message match the current host? if not dev/null the request
|
||||
if ((window.location.protocol != "file:") && (event.origin !== window.location.protocol+"//"+window.location.host)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((data.resize !== undefined) && (annotationsPattern.commentsOverlayActive)) {
|
||||
|
||||
for (var i = 0; i < annotationsPattern.trackedElements.length; ++i) {
|
||||
var el = annotationsPattern.trackedElements[i];
|
||||
if (window.getComputedStyle(el.element,null).getPropertyValue("max-height") == "0px") {
|
||||
el.element.firstChild.style.display = "none";
|
||||
var obj = JSON.stringify({"annotationState": false, "displayNumber": el.displayNumber });
|
||||
parent.postMessage(obj,annotationsPattern.targetOrigin);
|
||||
} else {
|
||||
el.element.firstChild.style.display = "block";
|
||||
var obj = JSON.stringify({"annotationState": true, "displayNumber": el.displayNumber });
|
||||
parent.postMessage(obj,annotationsPattern.targetOrigin);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (data.commentToggle !== undefined) {
|
||||
|
||||
var i, els, item, displayNum;
|
||||
|
||||
// if this is an overlay make sure it's active for the onclick event
|
||||
annotationsPattern.commentsOverlayActive = false;
|
||||
annotationsPattern.commentsEmbeddedActive = false;
|
||||
|
||||
// see which flag to toggle based on if this is a styleguide or view-all page
|
||||
if ((data.commentToggle === "on") && (document.getElementById("sg-patterns") !== null)) {
|
||||
annotationsPattern.commentsEmbeddedActive = true;
|
||||
} else if (data.commentToggle === "on") {
|
||||
annotationsPattern.commentsOverlayActive = true;
|
||||
}
|
||||
|
||||
// if comments overlay is turned off make sure to remove the has-annotation class and pointer
|
||||
if (!annotationsPattern.commentsOverlayActive) {
|
||||
els = document.querySelectorAll(".has-annotation");
|
||||
for (i = 0; i < els.length; i++) {
|
||||
els[i].classList.remove("has-annotation");
|
||||
}
|
||||
els = document.querySelectorAll(".annotation-tip");
|
||||
for (i = 0; i < els.length; i++) {
|
||||
els[i].style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
// if comments embedding is turned off make sure to hide the annotations div
|
||||
if (!annotationsPattern.commentsEmbeddedActive) {
|
||||
els = document.getElementsByClassName("sg-annotations");
|
||||
for (i = 0; i < els.length; i++) {
|
||||
els[i].style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
// if comments overlay is turned on add the has-annotation class and pointer
|
||||
if (annotationsPattern.commentsOverlayActive) {
|
||||
|
||||
var count = 0;
|
||||
|
||||
for (i = 0; i < comments.comments.length; i++) {
|
||||
item = comments.comments[i];
|
||||
els = document.querySelectorAll(item.el);
|
||||
|
||||
var state = true;
|
||||
|
||||
if (els.length) {
|
||||
|
||||
count++;
|
||||
|
||||
//Loop through all items with annotations
|
||||
for (k = 0; k < els.length; k++) {
|
||||
|
||||
els[k].classList.add("has-annotation");
|
||||
|
||||
var span = document.createElement("span");
|
||||
span.innerHTML = count;
|
||||
span.classList.add("annotation-tip");
|
||||
|
||||
if (window.getComputedStyle(els[k],null).getPropertyValue("max-height") == "0px") {
|
||||
span.style.display = "none";
|
||||
state = false;
|
||||
}
|
||||
|
||||
annotationsPattern.trackedElements.push({ "itemel": item.el, "element": els[k], "displayNumber": count, "state": state });
|
||||
|
||||
els[k].insertBefore(span,els[k].firstChild);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// count elements so it can be used when displaying the results in the viewer
|
||||
var count = 0;
|
||||
|
||||
// iterate over the comments in annotations.js
|
||||
for(i = 0; i < comments.comments.length; i++) {
|
||||
|
||||
var state = true;
|
||||
|
||||
var item = comments.comments[i];
|
||||
var els = document.querySelectorAll(item.el);
|
||||
|
||||
// if an element is found in the given pattern add it to the overall object so it can be passed when the overlay is turned on
|
||||
if (els.length > 0) {
|
||||
count++;
|
||||
for (k = 0; k < els.length; k++) {
|
||||
if (window.getComputedStyle(els[k],null).getPropertyValue("max-height") == "0px") {
|
||||
state = false;
|
||||
}
|
||||
}
|
||||
annotationsPattern.commentsGathered.comments[count] = { "el": item.el, "title": item.title, "comment": item.comment, "number": count, "state": state };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// send the list of annotations for the page back to the parent
|
||||
var obj = JSON.stringify(annotationsPattern.commentsGathered);
|
||||
parent.postMessage(obj,annotationsPattern.targetOrigin);
|
||||
|
||||
} else if (annotationsPattern.commentsEmbeddedActive && !annotationsPattern.commentsEmbedded) {
|
||||
|
||||
// if comment embedding is turned on and comments haven't been embedded yet do it
|
||||
for (i = 0; i < comments.comments.length; i++) {
|
||||
item = comments.comments[i];
|
||||
els = document.querySelectorAll(item.el);
|
||||
if (els.length > 0) {
|
||||
annotationsPattern.embedComments(els[0],item.title,item.comment); //Embed the comment
|
||||
}
|
||||
annotationsPattern.commentsEmbedded = true;
|
||||
}
|
||||
|
||||
} else if (annotationsPattern.commentsEmbeddedActive && annotationsPattern.commentsEmbedded) {
|
||||
|
||||
// if comment embedding is turned on and comments have been embedded simply display them
|
||||
els = document.getElementsByClassName("sg-annotations");
|
||||
for (i = 0; i < els.length; ++i) {
|
||||
els[i].style.display = "block";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// add the onclick handlers to the elements that have an annotations
|
||||
annotationsPattern.gatherComments();
|
||||
window.addEventListener("message", annotationsPattern.receiveIframeMessage, false);
|
||||
|
||||
// before unloading the iframe make sure any active overlay is turned off/closed
|
||||
window.onbeforeunload = function() {
|
||||
var obj = JSON.stringify({ "commentOverlay": "off" });
|
||||
parent.postMessage(obj,annotationsPattern.targetOrigin);
|
||||
};
|
||||
|
||||
// tell the parent iframe that keys were pressed
|
||||
|
||||
// toggle the annotations panel
|
||||
jwerty.key('ctrl+shift+a', function (e) {
|
||||
var obj = JSON.stringify({ "keyPress": "ctrl+shift+a" });
|
||||
parent.postMessage(obj,codePattern.targetOrigin);
|
||||
return false;
|
||||
});
|
||||
|
||||
// close the annotations panel if using escape
|
||||
jwerty.key('esc', function (e) {
|
||||
var obj = JSON.stringify({ "keyPress": "esc" });
|
||||
parent.postMessage(obj,codePattern.targetOrigin);
|
||||
return false;
|
||||
});
|
@ -1,118 +0,0 @@
|
||||
/*!
|
||||
* Code View Support for Patterns - v0.3
|
||||
*
|
||||
* Copyright (c) 2013-2014 Dave Olsen, http://dmolsen.com
|
||||
* Licensed under the MIT license
|
||||
*
|
||||
*/
|
||||
|
||||
var codePattern = {
|
||||
|
||||
codeOverlayActive: false,
|
||||
codeEmbeddedActive: false,
|
||||
targetOrigin: (window.location.protocol === "file:") ? "*" : window.location.protocol+"//"+window.location.host,
|
||||
|
||||
/**
|
||||
* toggle the annotation feature on/off
|
||||
* based on the great MDN docs at https://developer.mozilla.org/en-US/docs/Web/API/window.postMessage
|
||||
* @param {Object} event info
|
||||
*/
|
||||
receiveIframeMessage: function(event) {
|
||||
|
||||
var data = (typeof event.data !== "string") ? event.data : JSON.parse(event.data);
|
||||
|
||||
// does the origin sending the message match the current host? if not dev/null the request
|
||||
if ((window.location.protocol != "file:") && (event.origin !== window.location.protocol+"//"+window.location.host)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.codeToggle !== undefined) {
|
||||
|
||||
var els, i;
|
||||
|
||||
// if this is an overlay make sure it's active for the onclick event
|
||||
codePattern.codeOverlayActive = false;
|
||||
codePattern.codeEmbeddedActive = false;
|
||||
|
||||
// see which flag to toggle based on if this is a styleguide or view-all page
|
||||
if ((data.codeToggle == "on") && (document.getElementById("sg-patterns") !== null)) {
|
||||
codePattern.codeEmbeddedActive = true;
|
||||
} else if (data.codeToggle == "on") {
|
||||
codePattern.codeOverlayActive = true;
|
||||
}
|
||||
|
||||
// if comments embedding is turned off make sure to hide the annotations div
|
||||
if (!codePattern.codeEmbeddedActive && (document.getElementById("sg-patterns") !== null)) {
|
||||
els = document.getElementsByClassName("sg-code");
|
||||
for (i = 0; i < els.length; i++) {
|
||||
els[i].style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
// if comments overlay is turned on add the has-comment class and pointer
|
||||
if (codePattern.codeOverlayActive) {
|
||||
|
||||
var obj = JSON.stringify({ "codeOverlay": "on", "lineage": lineage, "lineageR": lineageR, "patternPartial": patternPartial, "patternState": patternState, "cssEnabled": cssEnabled });
|
||||
parent.postMessage(obj,codePattern.targetOrigin);
|
||||
|
||||
} else if (codePattern.codeEmbeddedActive) {
|
||||
|
||||
// if code embedding is turned on simply display them
|
||||
els = document.getElementsByClassName("sg-code");
|
||||
for (i = 0; i < els.length; ++i) {
|
||||
els[i].style.display = "block";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// add the onclick handlers to the elements that have an annotations
|
||||
window.addEventListener("message", codePattern.receiveIframeMessage, false);
|
||||
|
||||
// before unloading the iframe make sure any active overlay is turned off/closed
|
||||
window.onbeforeunload = function() {
|
||||
var obj = JSON.stringify({ "codeOverlay": "off" });
|
||||
parent.postMessage(obj,codePattern.targetOrigin);
|
||||
};
|
||||
|
||||
// tell the parent iframe that keys were pressed
|
||||
|
||||
// toggle the code panel
|
||||
jwerty.key('ctrl+shift+c', function (e) {
|
||||
var obj = JSON.stringify({ "keyPress": "ctrl+shift+c" });
|
||||
parent.postMessage(obj,codePattern.targetOrigin);
|
||||
return false;
|
||||
});
|
||||
|
||||
// when the code panel is open hijack cmd+a so that it only selects the code view
|
||||
jwerty.key('cmd+a/ctrl+a', function (e) {
|
||||
var obj = JSON.stringify({ "keyPress": "cmd+a" });
|
||||
parent.postMessage(obj,codePattern.targetOrigin);
|
||||
return false;
|
||||
});
|
||||
|
||||
// open the mustache panel
|
||||
jwerty.key('ctrl+shift+u', function (e) {
|
||||
var obj = JSON.stringify({ "keyPress": "ctrl+shift+u" });
|
||||
parent.postMessage(obj,codePattern.targetOrigin);
|
||||
return false;
|
||||
});
|
||||
|
||||
// open the html panel
|
||||
jwerty.key('ctrl+shift+h', function (e) {
|
||||
var obj = JSON.stringify({ "keyPress": "ctrl+shift+h" });
|
||||
parent.postMessage(obj,codePattern.targetOrigin);
|
||||
return false;
|
||||
});
|
||||
|
||||
// close the code panel if using escape
|
||||
jwerty.key('esc', function (e) {
|
||||
var obj = JSON.stringify({ "keyPress": "esc" });
|
||||
parent.postMessage(obj,codePattern.targetOrigin);
|
||||
return false;
|
||||
});
|
@ -1,156 +0,0 @@
|
||||
/*!
|
||||
* jQuery Cookie Plugin v1.3
|
||||
* https://github.com/carhartl/jquery-cookie
|
||||
*
|
||||
* Copyright 2011, Klaus Hartl
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.opensource.org/licenses/GPL-2.0
|
||||
*/
|
||||
(function ($, document, undefined) {
|
||||
|
||||
var pluses = /\+/g;
|
||||
|
||||
function raw(s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
function decoded(s) {
|
||||
return decodeURIComponent(s.replace(pluses, ' '));
|
||||
}
|
||||
|
||||
var config = $.cookie = function (key, value, options) {
|
||||
|
||||
// write
|
||||
if (value !== undefined) {
|
||||
options = $.extend({}, config.defaults, options);
|
||||
|
||||
if (value === null) {
|
||||
options.expires = -1;
|
||||
}
|
||||
|
||||
if (typeof options.expires === 'number') {
|
||||
var days = options.expires, t = options.expires = new Date();
|
||||
t.setDate(t.getDate() + days);
|
||||
}
|
||||
|
||||
value = config.json ? JSON.stringify(value) : String(value);
|
||||
|
||||
return (document.cookie = [
|
||||
encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
|
||||
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
||||
options.path ? '; path=' + options.path : '',
|
||||
options.domain ? '; domain=' + options.domain : '',
|
||||
options.secure ? '; secure' : ''
|
||||
].join(''));
|
||||
}
|
||||
|
||||
// read
|
||||
var decode = config.raw ? raw : decoded;
|
||||
var cookies = document.cookie.split('; ');
|
||||
for (var i = 0, l = cookies.length; i < l; i++) {
|
||||
var parts = cookies[i].split('=');
|
||||
if (decode(parts.shift()) === key) {
|
||||
var cookie = decode(parts.join('='));
|
||||
return config.json ? JSON.parse(cookie) : cookie;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
config.defaults = {};
|
||||
|
||||
$.removeCookie = function (key, options) {
|
||||
if ($.cookie(key) !== null) {
|
||||
$.cookie(key, null, options);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
})(jQuery, document);
|
||||
|
||||
/*!
|
||||
* Data Saver - v0.1
|
||||
*
|
||||
* Copyright (c) 2013-2014 Dave Olsen, http://dmolsen.com
|
||||
* Licensed under the MIT license
|
||||
*/
|
||||
|
||||
var DataSaver = {
|
||||
|
||||
// the name of the cookie to store the data in
|
||||
cookieName: "patternlab",
|
||||
|
||||
/**
|
||||
* Add a given value to the cookie
|
||||
* @param {String} the name of the key
|
||||
* @param {String} the value
|
||||
*/
|
||||
addValue: function (name,val) {
|
||||
var cookieVal = $.cookie(this.cookieName);
|
||||
cookieVal = ((cookieVal === null) || (cookieVal === "")) ? name+"~"+val : cookieVal+"|"+name+"~"+val;
|
||||
$.cookie(this.cookieName,cookieVal);
|
||||
},
|
||||
|
||||
/**
|
||||
* Update a value found in the cookie. If the key doesn't exist add the value
|
||||
* @param {String} the name of the key
|
||||
* @param {String} the value
|
||||
*/
|
||||
updateValue: function (name,val) {
|
||||
if (this.findValue(name)) {
|
||||
var updateCookieVals = "";
|
||||
var cookieVals = $.cookie(this.cookieName).split("|");
|
||||
for (var i = 0; i < cookieVals.length; i++) {
|
||||
var fieldVals = cookieVals[i].split("~");
|
||||
if (fieldVals[0] == name) {
|
||||
fieldVals[1] = val;
|
||||
}
|
||||
updateCookieVals += (i > 0) ? "|"+fieldVals[0]+"~"+fieldVals[1] : fieldVals[0]+"~"+fieldVals[1];
|
||||
}
|
||||
$.cookie(this.cookieName,updateCookieVals);
|
||||
} else {
|
||||
this.addValue(name,val);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove the given key
|
||||
* @param {String} the name of the key
|
||||
*/
|
||||
removeValue: function (name) {
|
||||
var updateCookieVals = "";
|
||||
var cookieVals = $.cookie(this.cookieName).split("|");
|
||||
var k = 0;
|
||||
for (var i = 0; i < cookieVals.length; i++) {
|
||||
var fieldVals = cookieVals[i].split("~");
|
||||
if (fieldVals[0] != name) {
|
||||
updateCookieVals += (k === 0) ? fieldVals[0]+"~"+fieldVals[1] : "|"+fieldVals[0]+"~"+fieldVals[1];
|
||||
k++;
|
||||
}
|
||||
}
|
||||
$.cookie(this.cookieName,updateCookieVals);
|
||||
},
|
||||
|
||||
/**
|
||||
* Find the value using the given key
|
||||
* @param {String} the name of the key
|
||||
*
|
||||
* @return {String} the value of the key or false if the value isn't found
|
||||
*/
|
||||
findValue: function (name) {
|
||||
if ($.cookie(this.cookieName)) {
|
||||
var cookieVals = $.cookie(this.cookieName).split("|");
|
||||
for (var i = 0; i < cookieVals.length; i++) {
|
||||
var fieldVals = cookieVals[i].split("~");
|
||||
if (fieldVals[0] == name) {
|
||||
return fieldVals[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
@ -1,122 +0,0 @@
|
||||
/*!
|
||||
* Pattern Finder
|
||||
*
|
||||
* Copyright (c) 2014 Dave Olsen, http://dmolsen.com
|
||||
* Licensed under the MIT license
|
||||
*
|
||||
*/
|
||||
|
||||
var patternFinder = {
|
||||
|
||||
data: [],
|
||||
active: false,
|
||||
|
||||
init: function() {
|
||||
|
||||
for (var patternType in patternPaths) {
|
||||
if (patternPaths.hasOwnProperty(patternType)) {
|
||||
for (var pattern in patternPaths[patternType]) {
|
||||
var obj = {};
|
||||
obj.patternPartial = patternType+"-"+pattern;
|
||||
obj.patternPath = patternPaths[patternType][pattern];
|
||||
this.data.push(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// instantiate the bloodhound suggestion engine
|
||||
var patterns = new Bloodhound({
|
||||
datumTokenizer: function(d) { return Bloodhound.tokenizers.nonword(d.patternPartial); },
|
||||
queryTokenizer: Bloodhound.tokenizers.nonword,
|
||||
limit: 10,
|
||||
local: this.data
|
||||
});
|
||||
|
||||
// initialize the bloodhound suggestion engine
|
||||
patterns.initialize();
|
||||
|
||||
$('#sg-find .typeahead').typeahead({ highlight: true }, {
|
||||
displayKey: 'patternPartial',
|
||||
source: patterns.ttAdapter()
|
||||
}).on('typeahead:selected', patternFinder.onAutocompleted).on('typeahead:autocompleted', patternFinder.onSelected);
|
||||
|
||||
},
|
||||
|
||||
passPath: function(item) {
|
||||
// update the iframe via the history api handler
|
||||
patternFinder.closeFinder();
|
||||
var obj = JSON.stringify({ "path": urlHandler.getFileName(item.patternPartial) });
|
||||
document.getElementById("sg-viewport").contentWindow.postMessage(obj, urlHandler.targetOrigin);
|
||||
},
|
||||
|
||||
onSelected: function(e,item) {
|
||||
patternFinder.passPath(item);
|
||||
},
|
||||
|
||||
onAutocompleted: function(e,item) {
|
||||
patternFinder.passPath(item);
|
||||
},
|
||||
|
||||
toggleFinder: function() {
|
||||
if (!patternFinder.active) {
|
||||
patternFinder.openFinder();
|
||||
} else {
|
||||
patternFinder.closeFinder();
|
||||
}
|
||||
},
|
||||
|
||||
openFinder: function() {
|
||||
patternFinder.active = true;
|
||||
$('#sg-find .typeahead').val("");
|
||||
$("#sg-find").addClass('show-overflow');
|
||||
$('#sg-find .typeahead').focus();
|
||||
},
|
||||
|
||||
closeFinder: function() {
|
||||
patternFinder.active = false;
|
||||
$("#sg-find").removeClass('show-overflow');
|
||||
$('.sg-acc-handle, .sg-acc-panel').removeClass('active');
|
||||
$('#sg-find .typeahead').val("");
|
||||
},
|
||||
|
||||
receiveIframeMessage: function(event) {
|
||||
|
||||
var data = (typeof event.data !== "string") ? event.data : JSON.parse(event.data);
|
||||
|
||||
// does the origin sending the message match the current host? if not dev/null the request
|
||||
if ((window.location.protocol !== "file:") && (event.origin !== window.location.protocol+"//"+window.location.host)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.keyPress !== undefined) {
|
||||
if (data.keyPress == 'ctrl+shift+f') {
|
||||
patternFinder.toggleFinder();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
patternFinder.init();
|
||||
|
||||
window.addEventListener("message", patternFinder.receiveIframeMessage, false);
|
||||
|
||||
$('#sg-find .typeahead').focus(function() {
|
||||
if (!patternFinder.active) {
|
||||
patternFinder.openFinder();
|
||||
}
|
||||
});
|
||||
|
||||
$('#sg-find .typeahead').blur(function() {
|
||||
patternFinder.closeFinder();
|
||||
});
|
||||
|
||||
// jwerty stuff
|
||||
// toggle the annotations panel
|
||||
jwerty.key('ctrl+shift+f', function (e) {
|
||||
$('.sg-find .sg-acc-handle, .sg-find .sg-acc-panel').addClass('active');
|
||||
patternFinder.toggleFinder();
|
||||
return false;
|
||||
});
|
@ -1,114 +0,0 @@
|
||||
/*!
|
||||
* Basic postMessage Support - v0.1
|
||||
*
|
||||
* Copyright (c) 2013-2014 Dave Olsen, http://dmolsen.com
|
||||
* Licensed under the MIT license
|
||||
*
|
||||
* Handles the postMessage stuff in the pattern, view-all, and style guide templates.
|
||||
*
|
||||
*/
|
||||
|
||||
// alert the iframe parent that the pattern has loaded assuming this view was loaded in an iframe
|
||||
if (self != top) {
|
||||
|
||||
// handle the options that could be sent to the parent window
|
||||
// - all get path
|
||||
// - pattern & view all get a pattern partial, styleguide gets all
|
||||
// - pattern shares lineage
|
||||
var path = window.location.toString();
|
||||
var parts = path.split("?");
|
||||
var options = { "path": parts[0] };
|
||||
options.patternpartial = (patternPartial !== "") ? patternPartial : "all";
|
||||
if (lineage !== "") {
|
||||
options.lineage = lineage;
|
||||
}
|
||||
|
||||
var targetOrigin = (window.location.protocol == "file:") ? "*" : window.location.protocol+"//"+window.location.host;
|
||||
parent.postMessage(options, targetOrigin);
|
||||
|
||||
// find all links and add an onclick handler for replacing the iframe address so the history works
|
||||
var aTags = document.getElementsByTagName('a');
|
||||
for (var i = 0; i < aTags.length; i++) {
|
||||
aTags[i].onclick = function(e) {
|
||||
e.preventDefault();
|
||||
var href = this.getAttribute("href");
|
||||
if (href != "#") {
|
||||
window.location.replace(href);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// bind the keyboard shortcuts for various viewport resizings + pattern search
|
||||
var keys = [ "s", "m", "l", "d", "h", "f" ];
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
jwerty.key('ctrl+shift+'+keys[i], function (k,t) {
|
||||
return function(e) {
|
||||
var obj = JSON.stringify({ "keyPress": "ctrl+shift+"+k });
|
||||
parent.postMessage(obj,t);
|
||||
return false;
|
||||
}
|
||||
}(keys[i],targetOrigin));
|
||||
}
|
||||
|
||||
// bind the keyboard shortcuts for mqs
|
||||
var i = 0;
|
||||
while (i < 10) {
|
||||
jwerty.key('ctrl+shift+'+i, function (k,t) {
|
||||
return function(e) {
|
||||
var targetOrigin = (window.location.protocol == "file:") ? "*" : window.location.protocol+"//"+window.location.host;
|
||||
var obj = JSON.stringify({ "keyPress": "ctrl+shift+"+k });
|
||||
parent.postMessage(obj,t);
|
||||
return false;
|
||||
}
|
||||
}(i,targetOrigin));
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// if there are clicks on the iframe make sure the nav in the iframe parent closes
|
||||
var body = document.getElementsByTagName('body');
|
||||
body[0].onclick = function() {
|
||||
var targetOrigin = (window.location.protocol == "file:") ? "*" : window.location.protocol+"//"+window.location.host;
|
||||
var obj = JSON.stringify({ "bodyclick": "bodyclick" });
|
||||
parent.postMessage(obj,targetOrigin);
|
||||
};
|
||||
|
||||
// watch the iframe source so that it can be sent back to everyone else.
|
||||
function receiveIframeMessage(event) {
|
||||
|
||||
var path;
|
||||
var data = (typeof event.data !== "string") ? event.data : JSON.parse(event.data);
|
||||
|
||||
// does the origin sending the message match the current host? if not dev/null the request
|
||||
if ((window.location.protocol != "file:") && (event.origin !== window.location.protocol+"//"+window.location.host)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// see if it got a path to replace
|
||||
if (data.path !== undefined) {
|
||||
|
||||
if (patternPartial !== "") {
|
||||
|
||||
// handle patterns and the view all page
|
||||
var re = /patterns\/(.*)$/;
|
||||
path = window.location.protocol+"//"+window.location.host+window.location.pathname.replace(re,'')+data.path+'?'+Date.now();
|
||||
window.location.replace(path);
|
||||
|
||||
} else {
|
||||
|
||||
// handle the style guide
|
||||
path = window.location.protocol+"//"+window.location.host+window.location.pathname.replace("styleguide\/html\/styleguide.html","")+data.path+'?'+Date.now();
|
||||
window.location.replace(path);
|
||||
|
||||
}
|
||||
|
||||
} else if (data.reload !== undefined) {
|
||||
|
||||
// reload the location if there was a message to do so
|
||||
window.location.reload();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
window.addEventListener("message", receiveIframeMessage, false);
|
@ -1,191 +0,0 @@
|
||||
/*!
|
||||
* URL Handler - v0.1
|
||||
*
|
||||
* Copyright (c) 2013-2014 Dave Olsen, http://dmolsen.com
|
||||
* Licensed under the MIT license
|
||||
*
|
||||
* Helps handle the initial iFrame source. Parses a string to see if it matches
|
||||
* an expected pattern in Pattern Lab. Supports Pattern Labs fuzzy pattern partial
|
||||
* matching style.
|
||||
*
|
||||
*/
|
||||
|
||||
var urlHandler = {
|
||||
|
||||
// set-up some default vars
|
||||
skipBack: false,
|
||||
targetOrigin: (window.location.protocol == "file:") ? "*" : window.location.protocol+"//"+window.location.host,
|
||||
|
||||
/**
|
||||
* get the real file name for a given pattern name
|
||||
* @param {String} the shorthand partials syntax for a given pattern
|
||||
*
|
||||
* @return {String} the real file path
|
||||
*/
|
||||
getFileName: function (name) {
|
||||
|
||||
var baseDir = "patterns";
|
||||
var fileName = "";
|
||||
|
||||
if (name === undefined) {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
if (name == "all") {
|
||||
return "styleguide/html/styleguide.html";
|
||||
}
|
||||
|
||||
var paths = (name.indexOf("viewall-") != -1) ? viewAllPaths : patternPaths;
|
||||
var nameClean = name.replace("viewall-","");
|
||||
|
||||
// look at this as a regular pattern
|
||||
var bits = this.getPatternInfo(nameClean, paths);
|
||||
var patternType = bits[0];
|
||||
var pattern = bits[1];
|
||||
|
||||
if ((paths[patternType] !== undefined) && (paths[patternType][pattern] !== undefined)) {
|
||||
|
||||
fileName = paths[patternType][pattern];
|
||||
|
||||
} else if (paths[patternType] !== undefined) {
|
||||
|
||||
for (var patternMatchKey in paths[patternType]) {
|
||||
if (patternMatchKey.indexOf(pattern) != -1) {
|
||||
fileName = paths[patternType][patternMatchKey];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (fileName === "") {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
var regex = /\//g;
|
||||
if ((name.indexOf("viewall-") != -1) && (fileName !== "")) {
|
||||
fileName = baseDir+"/"+fileName.replace(regex,"-")+"/index.html";
|
||||
} else if (fileName !== "") {
|
||||
fileName = baseDir+"/"+fileName.replace(regex,"-")+"/"+fileName.replace(regex,"-")+".html";
|
||||
}
|
||||
|
||||
return fileName;
|
||||
},
|
||||
|
||||
/**
|
||||
* break up a pattern into its parts, pattern type and pattern name
|
||||
* @param {String} the shorthand partials syntax for a given pattern
|
||||
* @param {Object} the paths to be compared
|
||||
*
|
||||
* @return {Array} the pattern type and pattern name
|
||||
*/
|
||||
getPatternInfo: function (name, paths) {
|
||||
|
||||
var patternBits = name.split("-");
|
||||
|
||||
var i = 1;
|
||||
var c = patternBits.length;
|
||||
|
||||
var patternType = patternBits[0];
|
||||
while ((paths[patternType] === undefined) && (i < c)) {
|
||||
patternType += "-"+patternBits[i];
|
||||
i++;
|
||||
}
|
||||
|
||||
var pattern = name.slice(patternType.length+1,name.length);
|
||||
|
||||
return [patternType, pattern];
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* search the request vars for a particular item
|
||||
*
|
||||
* @return {Object} a search of the window.location.search vars
|
||||
*/
|
||||
getRequestVars: function() {
|
||||
|
||||
// the following is taken from https://developer.mozilla.org/en-US/docs/Web/API/window.location
|
||||
var oGetVars = new (function (sSearch) {
|
||||
if (sSearch.length > 1) {
|
||||
for (var aItKey, nKeyId = 0, aCouples = sSearch.substr(1).split("&"); nKeyId < aCouples.length; nKeyId++) {
|
||||
aItKey = aCouples[nKeyId].split("=");
|
||||
this[unescape(aItKey[0])] = aItKey.length > 1 ? unescape(aItKey[1]) : "";
|
||||
}
|
||||
}
|
||||
})(window.location.search);
|
||||
|
||||
return oGetVars;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* push a pattern onto the current history based on a click
|
||||
* @param {String} the shorthand partials syntax for a given pattern
|
||||
* @param {String} the path given by the loaded iframe
|
||||
*/
|
||||
pushPattern: function (pattern, givenPath) {
|
||||
var data = { "pattern": pattern };
|
||||
var fileName = urlHandler.getFileName(pattern);
|
||||
var path = window.location.pathname;
|
||||
path = (window.location.protocol === "file") ? path.replace("/public/index.html","public/") : path.replace(/\/index\.html/,"/");
|
||||
var expectedPath = window.location.protocol+"//"+window.location.host+path+fileName;
|
||||
if (givenPath != expectedPath) {
|
||||
// make sure to update the iframe because there was a click
|
||||
var obj = JSON.stringify({ "path": fileName });
|
||||
document.getElementById("sg-viewport").contentWindow.postMessage(obj, urlHandler.targetOrigin);
|
||||
} else {
|
||||
// add to the history
|
||||
var addressReplacement = (window.location.protocol == "file:") ? null : window.location.protocol+"//"+window.location.host+window.location.pathname.replace("index.html","")+"?p="+pattern;
|
||||
if (history.pushState != undefined) {
|
||||
history.pushState(data, null, addressReplacement);
|
||||
}
|
||||
document.getElementById("title").innerHTML = "Pattern Lab - "+pattern;
|
||||
if (document.getElementById("sg-raw") != undefined) {
|
||||
document.getElementById("sg-raw").setAttribute("href",urlHandler.getFileName(pattern));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* based on a click forward or backward modify the url and iframe source
|
||||
* @param {Object} event info like state and properties set in pushState()
|
||||
*/
|
||||
popPattern: function (e) {
|
||||
|
||||
var patternName;
|
||||
var state = e.state;
|
||||
|
||||
if (state === null) {
|
||||
this.skipBack = false;
|
||||
return;
|
||||
} else if (state !== null) {
|
||||
patternName = state.pattern;
|
||||
}
|
||||
|
||||
var iFramePath = "";
|
||||
iFramePath = this.getFileName(patternName);
|
||||
if (iFramePath === "") {
|
||||
iFramePath = "styleguide/html/styleguide.html";
|
||||
}
|
||||
|
||||
var obj = JSON.stringify({ "path": iFramePath });
|
||||
document.getElementById("sg-viewport").contentWindow.postMessage( obj, urlHandler.targetOrigin);
|
||||
document.getElementById("title").innerHTML = "Pattern Lab - "+patternName;
|
||||
document.getElementById("sg-raw").setAttribute("href",urlHandler.getFileName(patternName));
|
||||
|
||||
if (wsnConnected) {
|
||||
wsn.send( '{"url": "'+iFramePath+'", "patternpartial": "'+patternName+'" }' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* handle the onpopstate event
|
||||
*/
|
||||
window.onpopstate = function (event) {
|
||||
urlHandler.skipBack = true;
|
||||
urlHandler.popPattern(event);
|
||||
};
|
176
public/styleguide/js/vendor/classlist-polyfill.js
vendored
176
public/styleguide/js/vendor/classlist-polyfill.js
vendored
@ -1,176 +0,0 @@
|
||||
/*
|
||||
* classList.js: Cross-browser full element.classList implementation.
|
||||
* 2012-11-15
|
||||
*
|
||||
* By Eli Grey, http://eligrey.com
|
||||
* Public Domain.
|
||||
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
||||
*/
|
||||
|
||||
/*global self, document, DOMException */
|
||||
|
||||
/*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js*/
|
||||
|
||||
if (typeof document !== "undefined" && !("classList" in document.documentElement)) {
|
||||
|
||||
(function (view) {
|
||||
|
||||
"use strict";
|
||||
|
||||
if (!('HTMLElement' in view) && !('Element' in view)) return;
|
||||
|
||||
var
|
||||
classListProp = "classList"
|
||||
, protoProp = "prototype"
|
||||
, elemCtrProto = (view.HTMLElement || view.Element)[protoProp]
|
||||
, objCtr = Object
|
||||
, strTrim = String[protoProp].trim || function () {
|
||||
return this.replace(/^\s+|\s+$/g, "");
|
||||
}
|
||||
, arrIndexOf = Array[protoProp].indexOf || function (item) {
|
||||
var
|
||||
i = 0
|
||||
, len = this.length
|
||||
;
|
||||
for (; i < len; i++) {
|
||||
if (i in this && this[i] === item) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
// Vendors: please allow content code to instantiate DOMExceptions
|
||||
, DOMEx = function (type, message) {
|
||||
this.name = type;
|
||||
this.code = DOMException[type];
|
||||
this.message = message;
|
||||
}
|
||||
, checkTokenAndGetIndex = function (classList, token) {
|
||||
if (token === "") {
|
||||
throw new DOMEx(
|
||||
"SYNTAX_ERR"
|
||||
, "An invalid or illegal string was specified"
|
||||
);
|
||||
}
|
||||
if (/\s/.test(token)) {
|
||||
throw new DOMEx(
|
||||
"INVALID_CHARACTER_ERR"
|
||||
, "String contains an invalid character"
|
||||
);
|
||||
}
|
||||
return arrIndexOf.call(classList, token);
|
||||
}
|
||||
, ClassList = function (elem) {
|
||||
var
|
||||
trimmedClasses = strTrim.call(elem.className)
|
||||
, classes = trimmedClasses ? trimmedClasses.split(/\s+/) : []
|
||||
, i = 0
|
||||
, len = classes.length
|
||||
;
|
||||
for (; i < len; i++) {
|
||||
this.push(classes[i]);
|
||||
}
|
||||
this._updateClassName = function () {
|
||||
elem.className = this.toString();
|
||||
};
|
||||
}
|
||||
, classListProto = ClassList[protoProp] = []
|
||||
, classListGetter = function () {
|
||||
return new ClassList(this);
|
||||
}
|
||||
;
|
||||
// Most DOMException implementations don't allow calling DOMException's toString()
|
||||
// on non-DOMExceptions. Error's toString() is sufficient here.
|
||||
DOMEx[protoProp] = Error[protoProp];
|
||||
classListProto.item = function (i) {
|
||||
return this[i] || null;
|
||||
};
|
||||
classListProto.contains = function (token) {
|
||||
token += "";
|
||||
return checkTokenAndGetIndex(this, token) !== -1;
|
||||
};
|
||||
classListProto.add = function () {
|
||||
var
|
||||
tokens = arguments
|
||||
, i = 0
|
||||
, l = tokens.length
|
||||
, token
|
||||
, updated = false
|
||||
;
|
||||
do {
|
||||
token = tokens[i] + "";
|
||||
if (checkTokenAndGetIndex(this, token) === -1) {
|
||||
this.push(token);
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
while (++i < l);
|
||||
|
||||
if (updated) {
|
||||
this._updateClassName();
|
||||
}
|
||||
};
|
||||
classListProto.remove = function () {
|
||||
var
|
||||
tokens = arguments
|
||||
, i = 0
|
||||
, l = tokens.length
|
||||
, token
|
||||
, updated = false
|
||||
;
|
||||
do {
|
||||
token = tokens[i] + "";
|
||||
var index = checkTokenAndGetIndex(this, token);
|
||||
if (index !== -1) {
|
||||
this.splice(index, 1);
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
while (++i < l);
|
||||
|
||||
if (updated) {
|
||||
this._updateClassName();
|
||||
}
|
||||
};
|
||||
classListProto.toggle = function (token, forse) {
|
||||
token += "";
|
||||
|
||||
var
|
||||
result = this.contains(token)
|
||||
, method = result ?
|
||||
forse !== true && "remove"
|
||||
:
|
||||
forse !== false && "add"
|
||||
;
|
||||
|
||||
if (method) {
|
||||
this[method](token);
|
||||
}
|
||||
|
||||
return !result;
|
||||
};
|
||||
classListProto.toString = function () {
|
||||
return this.join(" ");
|
||||
};
|
||||
|
||||
if (objCtr.defineProperty) {
|
||||
var classListPropDesc = {
|
||||
get: classListGetter
|
||||
, enumerable: true
|
||||
, configurable: true
|
||||
};
|
||||
try {
|
||||
objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
|
||||
} catch (ex) { // IE 8 doesn't support enumerable:true
|
||||
if (ex.number === -0x7FF5EC54) {
|
||||
classListPropDesc.enumerable = false;
|
||||
objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
|
||||
}
|
||||
}
|
||||
} else if (objCtr[protoProp].__defineGetter__) {
|
||||
elemCtrProto.__defineGetter__(classListProp, classListGetter);
|
||||
}
|
||||
|
||||
}(self));
|
||||
|
||||
}
|
4
public/styleguide/js/vendor/jquery.js
vendored
4
public/styleguide/js/vendor/jquery.js
vendored
File diff suppressed because one or more lines are too long
523
public/styleguide/js/vendor/jwerty.js
vendored
523
public/styleguide/js/vendor/jwerty.js
vendored
@ -1,523 +0,0 @@
|
||||
/*
|
||||
* jwerty - Awesome handling of keyboard events
|
||||
*
|
||||
* jwerty is a JS lib which allows you to bind, fire and assert key combination
|
||||
* strings against elements and events. It normalises the poor std api into
|
||||
* something easy to use and clear.
|
||||
*
|
||||
* This code is licensed under the MIT
|
||||
* For the full license see: http://keithamus.mit-license.org/
|
||||
* For more information see: http://keithamus.github.com/jwerty
|
||||
*
|
||||
* @author Keith Cirkel ('keithamus') <jwerty@keithcirkel.co.uk>
|
||||
* @license http://keithamus.mit-license.org/
|
||||
* @copyright Copyright © 2011, Keith Cirkel
|
||||
*
|
||||
*/
|
||||
(function (global, exports) {
|
||||
|
||||
// Helper methods & vars:
|
||||
var $d = global.document,
|
||||
$ = (global.jQuery || global.Zepto || global.ender || $d),
|
||||
$$, // Element selector function
|
||||
$b, // Event binding function
|
||||
$f, // Event firing function
|
||||
ke = 'keydown';
|
||||
|
||||
function realTypeOf(v, s) {
|
||||
return (v === null) ? s === 'null'
|
||||
: (v === undefined) ? s === 'undefined'
|
||||
: (v.is && v instanceof $) ? s === 'element'
|
||||
: Object.prototype.toString.call(v).toLowerCase().indexOf(s) > 7;
|
||||
}
|
||||
|
||||
if ($ === $d) {
|
||||
$$ = function (selector, context) {
|
||||
return selector ? $.querySelector(selector, context || $) : $;
|
||||
};
|
||||
$b = function (e, fn) { e.addEventListener(ke, fn, false); };
|
||||
$f = function (e, jwertyEv) {
|
||||
var ret = $d.createEvent('Event'),
|
||||
i;
|
||||
|
||||
ret.initEvent(ke, true, true);
|
||||
|
||||
for (i in jwertyEv) ret[i] = jwertyEv[i];
|
||||
|
||||
return (e || $).dispatchEvent(ret);
|
||||
};
|
||||
} else {
|
||||
$$ = function (selector, context) { return $(selector || $d, context); };
|
||||
$b = function (e, fn) { $(e).bind(ke + '.jwerty', fn); };
|
||||
$f = function (e, ob) { $(e || $d).trigger($.Event(ke, ob)); };
|
||||
}
|
||||
|
||||
// Private
|
||||
var _modProps = { 16: 'shiftKey', 17: 'ctrlKey', 18: 'altKey', 91: 'metaKey' };
|
||||
|
||||
// Generate key mappings for common keys that are not printable.
|
||||
var _keys = {
|
||||
|
||||
// MOD aka toggleable keys
|
||||
mods: {
|
||||
// Shift key, ⇧
|
||||
'⇧': 16,
|
||||
shift: 16,
|
||||
// CTRL key, on Mac: ⌃
|
||||
'⌃': 17,
|
||||
ctrl: 17,
|
||||
// ALT key, on Mac: ⌥ (Alt)
|
||||
'⌥': 18,
|
||||
alt: 18,
|
||||
option: 18,
|
||||
// META, on Mac: ⌘ (CMD), on Windows (Win), on Linux (Super)
|
||||
'⌘': 91,
|
||||
meta: 91,
|
||||
cmd: 91,
|
||||
'super': 91,
|
||||
win: 91
|
||||
},
|
||||
|
||||
// Normal keys
|
||||
keys: {
|
||||
// Backspace key, on Mac: ⌫ (Backspace)
|
||||
'⌫': 8,
|
||||
backspace: 8,
|
||||
// Tab Key, on Mac: ⇥ (Tab), on Windows ⇥⇥
|
||||
'⇥': 9,
|
||||
'⇆': 9,
|
||||
tab: 9,
|
||||
// Return key, ↩
|
||||
'↩': 13,
|
||||
'return': 13,
|
||||
enter: 13,
|
||||
'⌅': 13,
|
||||
// Pause/Break key
|
||||
'pause': 19,
|
||||
'pause-break': 19,
|
||||
// Caps Lock key, ⇪
|
||||
'⇪': 20,
|
||||
caps: 20,
|
||||
'caps-lock': 20,
|
||||
// Escape key, on Mac: ⎋, on Windows: Esc
|
||||
'⎋': 27,
|
||||
escape: 27,
|
||||
esc: 27,
|
||||
// Space key
|
||||
space: 32,
|
||||
// Page-Up key, or pgup, on Mac: ↖
|
||||
'↖': 33,
|
||||
pgup: 33,
|
||||
'page-up': 33,
|
||||
// Page-Down key, or pgdown, on Mac: ↘
|
||||
'↘': 34,
|
||||
pgdown: 34,
|
||||
'page-down': 34,
|
||||
// END key, on Mac: ⇟
|
||||
'⇟': 35,
|
||||
end: 35,
|
||||
// HOME key, on Mac: ⇞
|
||||
'⇞': 36,
|
||||
home: 36,
|
||||
// Insert key, or ins
|
||||
ins: 45,
|
||||
insert: 45,
|
||||
// Delete key, on Mac: ⌫ (Delete)
|
||||
del: 46,
|
||||
'delete': 46,
|
||||
|
||||
// Left Arrow Key, or ←
|
||||
'←': 37,
|
||||
left: 37,
|
||||
'arrow-left': 37,
|
||||
// Up Arrow Key, or ↑
|
||||
'↑': 38,
|
||||
up: 38,
|
||||
'arrow-up': 38,
|
||||
// Right Arrow Key, or →
|
||||
'→': 39,
|
||||
right: 39,
|
||||
'arrow-right': 39,
|
||||
// Up Arrow Key, or ↓
|
||||
'↓': 40,
|
||||
down: 40,
|
||||
'arrow-down': 40,
|
||||
|
||||
// odities, printing characters that come out wrong:
|
||||
// Num-Multiply, or *
|
||||
'*': 106,
|
||||
star: 106,
|
||||
asterisk: 106,
|
||||
multiply: 106,
|
||||
// Num-Plus or +
|
||||
'+': 107,
|
||||
'plus': 107,
|
||||
// Num-Subtract, or -
|
||||
'-': 109,
|
||||
subtract: 109,
|
||||
'num-.': 110,
|
||||
'num-period': 110,
|
||||
'num-dot': 110,
|
||||
'num-full-stop': 110,
|
||||
'num-delete': 110,
|
||||
// Semicolon
|
||||
';': 186,
|
||||
semicolon: 186,
|
||||
// = or equals
|
||||
'=': 187,
|
||||
'equals': 187,
|
||||
// Comma, or ,
|
||||
',': 188,
|
||||
comma: 188,
|
||||
//'-': 189, //???
|
||||
// Period, or ., or full-stop
|
||||
'.': 190,
|
||||
period: 190,
|
||||
'full-stop': 190,
|
||||
// Slash, or /, or forward-slash
|
||||
'/': 191,
|
||||
slash: 191,
|
||||
'forward-slash': 191,
|
||||
// Tick, or `, or back-quote
|
||||
'`': 192,
|
||||
tick: 192,
|
||||
'back-quote': 192,
|
||||
// Open bracket, or [
|
||||
'[': 219,
|
||||
'open-bracket': 219,
|
||||
// Back slash, or \
|
||||
'\\': 220,
|
||||
'back-slash': 220,
|
||||
// Close backet, or ]
|
||||
']': 221,
|
||||
'close-bracket': 221,
|
||||
// Apostraphe, or Quote, or '
|
||||
'\'': 222,
|
||||
quote: 222,
|
||||
apostraphe: 222
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// To minimise code bloat, add all of the 0-9 and NUMPAD 0-9 keys in a loop
|
||||
var i = 47,
|
||||
n = 0;
|
||||
while (++i < 106) {
|
||||
_keys.keys[n] = i;
|
||||
_keys.keys['num-' + n] = i + 48;
|
||||
++n;
|
||||
}
|
||||
|
||||
// To minimise code bloat, add all of the F1-F25 keys in a loop
|
||||
i = 111,
|
||||
n = 1;
|
||||
while (++i < 136) {
|
||||
_keys.keys['f' + n] = i;
|
||||
++n;
|
||||
}
|
||||
|
||||
// To minimise code bloat, add all of the letters of the alphabet in a loop
|
||||
i = 64;
|
||||
while (++i < 91) {
|
||||
_keys.keys[String.fromCharCode(i).toLowerCase()] = i;
|
||||
}
|
||||
|
||||
function JwertyCode(jwertyCode) {
|
||||
var i,
|
||||
c,
|
||||
n,
|
||||
z,
|
||||
keyCombo,
|
||||
optionals,
|
||||
jwertyCodeFragment,
|
||||
rangeMatches,
|
||||
rangeI;
|
||||
|
||||
// In-case we get called with an instance of ourselves, just return that.
|
||||
if (jwertyCode instanceof JwertyCode) return jwertyCode;
|
||||
|
||||
// If jwertyCode isn't an array, cast it as a string and split into array.
|
||||
if (!realTypeOf(jwertyCode, 'array')) {
|
||||
jwertyCode = (String(jwertyCode)).replace(/\s/g, '').toLowerCase()
|
||||
.match(/(?:\+,|[^,])+/g);
|
||||
}
|
||||
|
||||
// Loop through each key sequence in jwertyCode
|
||||
for (i = 0, c = jwertyCode.length; i < c; ++i) {
|
||||
|
||||
// If the key combo at this part of the sequence isn't an array,
|
||||
// cast as a string and split into an array.
|
||||
if (!realTypeOf(jwertyCode[i], 'array')) {
|
||||
jwertyCode[i] = String(jwertyCode[i])
|
||||
.match(/(?:\+\/|[^\/])+/g);
|
||||
}
|
||||
|
||||
// Parse the key optionals in this sequence
|
||||
optionals = [],
|
||||
n = jwertyCode[i].length;
|
||||
while (n--) {
|
||||
|
||||
// Begin creating the object for this key combo
|
||||
jwertyCodeFragment = jwertyCode[i][n];
|
||||
|
||||
keyCombo = {
|
||||
jwertyCombo: String(jwertyCodeFragment),
|
||||
shiftKey: false,
|
||||
ctrlKey: false,
|
||||
altKey: false,
|
||||
metaKey: false
|
||||
};
|
||||
|
||||
// If jwertyCodeFragment isn't an array then cast as a string
|
||||
// and split it into one.
|
||||
if (!realTypeOf(jwertyCodeFragment, 'array')) {
|
||||
jwertyCodeFragment = String(jwertyCodeFragment).toLowerCase()
|
||||
.match(/(?:(?:[^\+])+|\+\+|^\+$)/g);
|
||||
}
|
||||
|
||||
z = jwertyCodeFragment.length;
|
||||
while (z--) {
|
||||
|
||||
// Normalise matching errors
|
||||
if (jwertyCodeFragment[z] === '++') jwertyCodeFragment[z] = '+';
|
||||
|
||||
// Inject either keyCode or ctrl/meta/shift/altKey into keyCombo
|
||||
if (jwertyCodeFragment[z] in _keys.mods) {
|
||||
keyCombo[_modProps[_keys.mods[jwertyCodeFragment[z]]]] = true;
|
||||
} else if (jwertyCodeFragment[z] in _keys.keys) {
|
||||
keyCombo.keyCode = _keys.keys[jwertyCodeFragment[z]];
|
||||
} else {
|
||||
rangeMatches = jwertyCodeFragment[z].match(/^\[([^-]+\-?[^-]*)-([^-]+\-?[^-]*)\]$/);
|
||||
}
|
||||
}
|
||||
if (realTypeOf(keyCombo.keyCode, 'undefined')) {
|
||||
// If we picked up a range match earlier...
|
||||
if (rangeMatches && (rangeMatches[1] in _keys.keys) && (rangeMatches[2] in _keys.keys)) {
|
||||
rangeMatches[2] = _keys.keys[rangeMatches[2]];
|
||||
rangeMatches[1] = _keys.keys[rangeMatches[1]];
|
||||
|
||||
// Go from match 1 and capture all key-comobs up to match 2
|
||||
for (rangeI = rangeMatches[1]; rangeI < rangeMatches[2]; ++rangeI) {
|
||||
optionals.push({
|
||||
altKey: keyCombo.altKey,
|
||||
shiftKey: keyCombo.shiftKey,
|
||||
metaKey: keyCombo.metaKey,
|
||||
ctrlKey: keyCombo.ctrlKey,
|
||||
keyCode: rangeI,
|
||||
jwertyCombo: String(jwertyCodeFragment)
|
||||
});
|
||||
|
||||
}
|
||||
keyCombo.keyCode = rangeI;
|
||||
// Inject either keyCode or ctrl/meta/shift/altKey into keyCombo
|
||||
} else {
|
||||
keyCombo.keyCode = 0;
|
||||
}
|
||||
}
|
||||
optionals.push(keyCombo);
|
||||
|
||||
}
|
||||
this[i] = optionals;
|
||||
}
|
||||
this.length = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
var jwerty = exports.jwerty = {
|
||||
/**
|
||||
* jwerty.event
|
||||
*
|
||||
* `jwerty.event` will return a function, which expects the first
|
||||
* argument to be a key event. When the key event matches `jwertyCode`,
|
||||
* `callbackFunction` is fired. `jwerty.event` is used by `jwerty.key`
|
||||
* to bind the function it returns. `jwerty.event` is useful for
|
||||
* attaching to your own event listeners. It can be used as a decorator
|
||||
* method to encapsulate functionality that you only want to fire after
|
||||
* a specific key combo. If `callbackContext` is specified then it will
|
||||
* be supplied as `callbackFunction`'s context - in other words, the
|
||||
* keyword `this` will be set to `callbackContext` inside the
|
||||
* `callbackFunction` function.
|
||||
*
|
||||
* @param {Mixed} jwertyCode can be an array, or string of key
|
||||
* combinations, which includes optinals and or sequences
|
||||
* @param {Function} callbackFucntion is a function (or boolean) which
|
||||
* is fired when jwertyCode is matched. Return false to
|
||||
* preventDefault()
|
||||
* @param {Object} callbackContext (Optional) The context to call
|
||||
* `callback` with (i.e this)
|
||||
*
|
||||
*/
|
||||
event: function (jwertyCode, callbackFunction, callbackContext /*? this */) {
|
||||
|
||||
// Construct a function out of callbackFunction, if it is a boolean.
|
||||
if (realTypeOf(callbackFunction, 'boolean')) {
|
||||
var bool = callbackFunction;
|
||||
callbackFunction = function () { return bool; };
|
||||
}
|
||||
|
||||
jwertyCode = new JwertyCode(jwertyCode);
|
||||
|
||||
// Initialise in-scope vars.
|
||||
var i = 0,
|
||||
c = jwertyCode.length - 1,
|
||||
returnValue,
|
||||
jwertyCodeIs;
|
||||
|
||||
// This is the event listener function that gets returned...
|
||||
return function (event) {
|
||||
|
||||
// if jwertyCodeIs returns truthy (string)...
|
||||
if ((jwertyCodeIs = jwerty.is(jwertyCode, event, i))) {
|
||||
// ... and this isn't the last key in the sequence,
|
||||
// incriment the key in sequence to check.
|
||||
if (i < c) {
|
||||
++i;
|
||||
return;
|
||||
// ... and this is the last in the sequence (or the only
|
||||
// one in sequence), then fire the callback
|
||||
} else {
|
||||
returnValue = callbackFunction.call(
|
||||
callbackContext || this, event, jwertyCodeIs);
|
||||
|
||||
// If the callback returned false, then we should run
|
||||
// preventDefault();
|
||||
if (returnValue === false) event.preventDefault();
|
||||
|
||||
// Reset i for the next sequence to fire.
|
||||
i = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If the event didn't hit this time, we should reset i to 0,
|
||||
// that is, unless this combo was the first in the sequence,
|
||||
// in which case we should reset i to 1.
|
||||
i = jwerty.is(jwertyCode, event) ? 1 : 0;
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* jwerty.is
|
||||
*
|
||||
* `jwerty.is` will return a boolean value, based on if `event` matches
|
||||
* `jwertyCode`. `jwerty.is` is called by `jwerty.event` to check
|
||||
* whether or not to fire the callback. `event` can be a DOM event, or
|
||||
* a jQuery/Zepto/Ender manufactured event. The properties of
|
||||
* `jwertyCode` (speficially ctrlKey, altKey, metaKey, shiftKey and
|
||||
* keyCode) should match `jwertyCode`'s properties - if they do, then
|
||||
* `jwerty.is` will return `true`. If they don't, `jwerty.is` will
|
||||
* return `false`.
|
||||
*
|
||||
* @param {Mixed} jwertyCode can be an array, or string of key
|
||||
* combinations, which includes optinals and or sequences
|
||||
* @param {KeyboardEvent} event is the KeyboardEvent to assert against
|
||||
* @param {Integer} i (Optional) checks the `i` key in jwertyCode
|
||||
* sequence
|
||||
*
|
||||
*/
|
||||
is: function (jwertyCode, event, i /*? 0*/) {
|
||||
jwertyCode = new JwertyCode(jwertyCode);
|
||||
// Default `i` to 0
|
||||
i = i || 0;
|
||||
// We are only interested in `i` of jwertyCode;
|
||||
jwertyCode = jwertyCode[i];
|
||||
// jQuery stores the *real* event in `originalEvent`, which we use
|
||||
// because it does annoything stuff to `metaKey`
|
||||
event = event.originalEvent || event;
|
||||
|
||||
// We'll look at each optional in this jwertyCode sequence...
|
||||
var n = jwertyCode.length,
|
||||
returnValue = false;
|
||||
|
||||
// Loop through each fragment of jwertyCode
|
||||
while (n--) {
|
||||
returnValue = jwertyCode[n].jwertyCombo;
|
||||
// For each property in the jwertyCode object, compare to `event`
|
||||
for (var p in jwertyCode[n]) {
|
||||
// ...except for jwertyCode.jwertyCombo...
|
||||
if (p !== 'jwertyCombo' && event[p] != jwertyCode[n][p]) returnValue = false;
|
||||
}
|
||||
// If this jwertyCode optional wasn't falsey, then we can return early.
|
||||
if (returnValue !== false) return returnValue;
|
||||
}
|
||||
return returnValue;
|
||||
},
|
||||
|
||||
/**
|
||||
* jwerty.key
|
||||
*
|
||||
* `jwerty.key` will attach an event listener and fire
|
||||
* `callbackFunction` when `jwertyCode` matches. The event listener is
|
||||
* attached to `document`, meaning it will listen for any key events
|
||||
* on the page (a global shortcut listener). If `callbackContext` is
|
||||
* specified then it will be supplied as `callbackFunction`'s context
|
||||
* - in other words, the keyword `this` will be set to
|
||||
* `callbackContext` inside the `callbackFunction` function.
|
||||
*
|
||||
* @param {Mixed} jwertyCode can be an array, or string of key
|
||||
* combinations, which includes optinals and or sequences
|
||||
* @param {Function} callbackFunction is a function (or boolean) which
|
||||
* is fired when jwertyCode is matched. Return false to
|
||||
* preventDefault()
|
||||
* @param {Object} callbackContext (Optional) The context to call
|
||||
* `callback` with (i.e this)
|
||||
* @param {Mixed} selector can be a string, jQuery/Zepto/Ender object,
|
||||
* or an HTML*Element on which to bind the eventListener
|
||||
* @param {Mixed} selectorContext can be a string, jQuery/Zepto/Ender
|
||||
* object, or an HTML*Element on which to scope the selector
|
||||
*
|
||||
*/
|
||||
key: function (jwertyCode, callbackFunction, callbackContext /*? this */, selector /*? document */, selectorContext /*? body */) {
|
||||
// Because callbackContext is optional, we should check if the
|
||||
// `callbackContext` is a string or element, and if it is, then the
|
||||
// function was called without a context, and `callbackContext` is
|
||||
// actually `selector`
|
||||
var realSelector = realTypeOf(callbackContext, 'element') || realTypeOf(callbackContext, 'string') ? callbackContext : selector,
|
||||
// If `callbackContext` is undefined, or if we skipped it (and
|
||||
// therefore it is `realSelector`), set context to `global`.
|
||||
realcallbackContext = realSelector === callbackContext ? global : callbackContext,
|
||||
// Finally if we did skip `callbackContext`, then shift
|
||||
// `selectorContext` to the left (take it from `selector`)
|
||||
realSelectorContext = realSelector === callbackContext ? selector : selectorContext;
|
||||
|
||||
// If `realSelector` is already a jQuery/Zepto/Ender/DOM element,
|
||||
// then just use it neat, otherwise find it in DOM using $$()
|
||||
$b(
|
||||
realTypeOf(realSelector, 'element') ? realSelector : $$(realSelector, realSelectorContext),
|
||||
jwerty.event(jwertyCode, callbackFunction, realcallbackContext)
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* jwerty.fire
|
||||
*
|
||||
* `jwerty.fire` will construct a keyup event to fire, based on
|
||||
* `jwertyCode`. The event will be fired against `selector`.
|
||||
* `selectorContext` is used to search for `selector` within
|
||||
* `selectorContext`, similar to jQuery's
|
||||
* `$('selector', 'context')`.
|
||||
*
|
||||
* @param {Mixed} jwertyCode can be an array, or string of key
|
||||
* combinations, which includes optinals and or sequences
|
||||
* @param {Mixed} selector can be a string, jQuery/Zepto/Ender object,
|
||||
* or an HTML*Element on which to bind the eventListener
|
||||
* @param {Mixed} selectorContext can be a string, jQuery/Zepto/Ender
|
||||
* object, or an HTML*Element on which to scope the selector
|
||||
*
|
||||
*/
|
||||
fire: function (jwertyCode, selector /*? document */, selectorContext /*? body */, i) {
|
||||
jwertyCode = new JwertyCode(jwertyCode);
|
||||
var realI = realTypeOf(selectorContext, 'number') ? selectorContext : i;
|
||||
|
||||
// If `realSelector` is already a jQuery/Zepto/Ender/DOM element,
|
||||
// then just use it neat, otherwise find it in DOM using $$()
|
||||
$f(
|
||||
realTypeOf(selector, 'element') ? selector : $$(selector, selectorContext),
|
||||
jwertyCode[realI || 0][0]
|
||||
);
|
||||
},
|
||||
|
||||
KEYS: _keys
|
||||
};
|
||||
|
||||
}(this, (typeof module !== 'undefined' && module.exports ? module.exports : this)));
|
7
public/styleguide/js/vendor/prism.js
vendored
7
public/styleguide/js/vendor/prism.js
vendored
@ -1,7 +0,0 @@
|
||||
/**
|
||||
* Prism: Lightweight, robust, elegant syntax highlighting
|
||||
* MIT license http://www.opensource.org/licenses/mit-license.php/
|
||||
* @author Lea Verou http://lea.verou.me
|
||||
*/(function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=self.Prism={util:{type:function(e){return Object.prototype.toString.call(e).match(/\[object (\w+)\]/)[1]},clone:function(e){var n=t.util.type(e);switch(n){case"Object":var r={};for(var i in e)e.hasOwnProperty(i)&&(r[i]=t.util.clone(e[i]));return r;case"Array":return e.slice()}return e}},languages:{extend:function(e,n){var r=t.util.clone(t.languages[e]);for(var i in n)r[i]=n[i];return r},insertBefore:function(e,n,r,i){i=i||t.languages;var s=i[e],o={};for(var u in s)if(s.hasOwnProperty(u)){if(u==n)for(var a in r)r.hasOwnProperty(a)&&(o[a]=r[a]);o[u]=s[u]}return i[e]=o},DFS:function(e,n){for(var r in e){n.call(e,r,e[r]);t.util.type(e)==="Object"&&t.languages.DFS(e[r],n)}}},highlightAll:function(e,n){var r=document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code');for(var i=0,s;s=r[i++];)t.highlightElement(s,e===!0,n)},highlightElement:function(r,i,s){var o,u,a=r;while(a&&!e.test(a.className))a=a.parentNode;if(a){o=(a.className.match(e)||[,""])[1];u=t.languages[o]}if(!u)return;r.className=r.className.replace(e,"").replace(/\s+/g," ")+" language-"+o;a=r.parentNode;/pre/i.test(a.nodeName)&&(a.className=a.className.replace(e,"").replace(/\s+/g," ")+" language-"+o);var f=r.textContent;if(!f)return;f=f.replace(/&/g,"&").replace(/</g,"<").replace(/\u00a0/g," ");var l={element:r,language:o,grammar:u,code:f};t.hooks.run("before-highlight",l);if(i&&self.Worker){var c=new Worker(t.filename);c.onmessage=function(e){l.highlightedCode=n.stringify(JSON.parse(e.data),o);t.hooks.run("before-insert",l);l.element.innerHTML=l.highlightedCode;s&&s.call(l.element);t.hooks.run("after-highlight",l)};c.postMessage(JSON.stringify({language:l.language,code:l.code}))}else{l.highlightedCode=t.highlight(l.code,l.grammar,l.language);t.hooks.run("before-insert",l);l.element.innerHTML=l.highlightedCode;s&&s.call(r);t.hooks.run("after-highlight",l)}},highlight:function(e,r,i){return n.stringify(t.tokenize(e,r),i)},tokenize:function(e,n,r){var i=t.Token,s=[e],o=n.rest;if(o){for(var u in o)n[u]=o[u];delete n.rest}e:for(var u in n){if(!n.hasOwnProperty(u)||!n[u])continue;var a=n[u],f=a.inside,l=!!a.lookbehind,c=0;a=a.pattern||a;for(var h=0;h<s.length;h++){var p=s[h];if(s.length>e.length)break e;if(p instanceof i)continue;a.lastIndex=0;var d=a.exec(p);if(d){l&&(c=d[1].length);var v=d.index-1+c,d=d[0].slice(c),m=d.length,g=v+m,y=p.slice(0,v+1),b=p.slice(g+1),w=[h,1];y&&w.push(y);var E=new i(u,f?t.tokenize(d,f):d);w.push(E);b&&w.push(b);Array.prototype.splice.apply(s,w)}}}return s},hooks:{all:{},add:function(e,n){var r=t.hooks.all;r[e]=r[e]||[];r[e].push(n)},run:function(e,n){var r=t.hooks.all[e];if(!r||!r.length)return;for(var i=0,s;s=r[i++];)s(n)}}},n=t.Token=function(e,t){this.type=e;this.content=t};n.stringify=function(e,r,i){if(typeof e=="string")return e;if(Object.prototype.toString.call(e)=="[object Array]")return e.map(function(t){return n.stringify(t,r,e)}).join("");var s={type:e.type,content:n.stringify(e.content,r,i),tag:"span",classes:["token",e.type],attributes:{},language:r,parent:i};s.type=="comment"&&(s.attributes.spellcheck="true");t.hooks.run("wrap",s);var o="";for(var u in s.attributes)o+=u+'="'+(s.attributes[u]||"")+'"';return"<"+s.tag+' class="'+s.classes.join(" ")+'" '+o+">"+s.content+"</"+s.tag+">"};if(!self.document){self.addEventListener("message",function(e){var n=JSON.parse(e.data),r=n.language,i=n.code;self.postMessage(JSON.stringify(t.tokenize(i,t.languages[r])));self.close()},!1);return}var r=document.getElementsByTagName("script");r=r[r.length-1];if(r){t.filename=r.src;document.addEventListener&&!r.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)}})();;
|
||||
Prism.languages.markup={comment:/<!--[\w\W]*?-->/g,prolog:/<\?.+?\?>/,doctype:/<!DOCTYPE.+?>/,cdata:/<!\[CDATA\[[\w\W]*?]]>/i,tag:{pattern:/<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|\w+))?\s*)*\/?>/gi,inside:{tag:{pattern:/^<\/?[\w:-]+/i,inside:{punctuation:/^<\/?/,namespace:/^[\w-]+?:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/gi,inside:{punctuation:/=|>|"/g}},punctuation:/\/?>/g,"attr-name":{pattern:/[\w:-]+/g,inside:{namespace:/^[\w-]+?:/}}}},entity:/&#?[\da-z]{1,8};/gi};Prism.hooks.add("wrap",function(e){e.type==="entity"&&(e.attributes.title=e.content.replace(/&/,"&"))});;
|
||||
Prism.languages.css={comment:/\/\*[\w\W]*?\*\//g,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*{))/gi,inside:{punctuation:/[;:]/g}},url:/url\((["']?).*?\1\)/gi,selector:/[^\{\}\s][^\{\};]*(?=\s*\{)/g,property:/(\b|\B)[\w-]+(?=\s*:)/ig,string:/("|')(\\?.)*?\1/g,important:/\B!important\b/gi,ignore:/&(lt|gt|amp);/gi,punctuation:/[\{\};:]/g};Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{style:{pattern:/(<|<)style[\w\W]*?(>|>)[\w\W]*?(<|<)\/style(>|>)/ig,inside:{tag:{pattern:/(<|<)style[\w\W]*?(>|>)|(<|<)\/style(>|>)/ig,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.css}}});;
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user