Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

Commit

Permalink
2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Oct 29, 2015
1 parent e0389aa commit 75bfeb8
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 27 deletions.
15 changes: 4 additions & 11 deletions dist/xrayhtml.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! X-rayHTML - v2.0.0 - 2015-10-28
/*! X-rayHTML - v2.0.1 - 2015-10-29
* https://github.com/filamentgroup/x-rayhtml
* Copyright (c) 2015 ; Licensed MIT */

Expand All @@ -13,8 +13,7 @@
padding: 2em 1em;
position: relative;
}
.xrayhtml:before {
content: "Example";
.xrayhtml .xraytitle {
text-transform: uppercase;
letter-spacing: 1px;
font: .75em sans-serif;
Expand All @@ -26,9 +25,7 @@
padding-right: .5em;
left: 1.333333333em; /* 16px */
z-index: 3;
}
.xrayhtml[data-title]:before {
content: "Example: " attr(data-title);
margin: 0;
}
.xrayhtml.method-flip:before {
background-color: rgba(255,255,255,.6);
Expand Down Expand Up @@ -65,13 +62,9 @@
.xrayhtml.antipattern {
border-color: #C9282D;
}
.xrayhtml.antipattern:before {
.xrayhtml.antipattern .xraytitle {
color: #d75e72;
font-weight: 700;
content: "Do Not Use";
}
.xrayhtml.antipattern[data-title]:before {
content: "Do Not Use: " attr(data-title);
}

/* Flip Animation */
Expand Down
59 changes: 44 additions & 15 deletions dist/xrayhtml.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! X-rayHTML - v2.0.0 - 2015-10-28
/*! X-rayHTML - v2.0.1 - 2015-10-29
* https://github.com/filamentgroup/x-rayhtml
* Copyright (c) 2015 ; Licensed MIT */

Expand All @@ -9,12 +9,16 @@ window.jQuery = window.jQuery || window.shoestring;
o = {
text: {
open: "View Source",
close: "View Demo"
close: "View Demo",
titlePrefix: "Example",
antipattern: "Do Not Use"
},
classes: {
button: "btn btn-small",
open: "view-source",
sourcepanel: "source-panel"
sourcepanel: "source-panel",
title: "xraytitle",
antipattern: "antipattern"
},
initSelector: "[data-" + pluginName + "]",
defaultReveal: "inline"
Expand Down Expand Up @@ -67,18 +71,42 @@ window.jQuery = window.jQuery || window.shoestring;
.insertBefore( el );
},
_createSource: function() {
var el = this,
preel = document.createElement( "pre" ),
codeel = document.createElement( "code" ),
wrap = document.createElement( "div" ),
sourcepanel = document.createElement( "div" ),
// remove empty value attributes
code = el.innerHTML.replace( /\=\"\"/g, '' ),
leadingWhiteSpace = code.match( /(^[\s]+)/ ),
lineWSRE = new RegExp( leadingWhiteSpace[ 1 ], "gmi" ),
source;

code = code.replace( lineWSRE, "\n" ),
var el = this;
var getPrefixText = function () {
if( el.className.match( new RegExp( "\\b" + o.classes.antipattern + "\\b", "gi" ) ) ) {
return o.text.antipattern;
}
return o.text.titlePrefix;
};
var title = el.getElementsByClassName( o.classes.title );
var deprecatedTitle;
var preel = document.createElement( "pre" );
var codeel = document.createElement( "code" );
var wrap = document.createElement( "div" );
var sourcepanel = document.createElement( "div" );
var code;
var leadingWhiteSpace;
var source;

if( title.length ) {
title = title[ 0 ];
title.parentNode.removeChild( title );
title.innerHTML = getPrefixText() + ": " + title.innerHTML;
} else {
deprecatedTitle = el.getAttribute( "data-title" );
title = document.createElement( "div" );
title.className = o.classes.title;
title.innerHTML = getPrefixText() + ( deprecatedTitle ? ": " + deprecatedTitle : "" );
}

// remove empty value attributes
code = el.innerHTML.replace( /\=\"\"/g, '' );
leadingWhiteSpace = code.match( /(^[\s]+)/ );

if( leadingWhiteSpace ) {
code = code.replace( new RegExp( leadingWhiteSpace[ 1 ], "gmi" ), "\n" );
}

source = document.createTextNode( code );

wrap.setAttribute( "class", "snippet" );
Expand All @@ -92,6 +120,7 @@ window.jQuery = window.jQuery || window.shoestring;
sourcepanel.appendChild( preel );

this.appendChild( sourcepanel );
this.insertBefore( title, this.firstChild );
}
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "X-rayHTML",
"description": "A plugin to easily show examples of components with the markup to use them.",
"homepage": "https://github.com/filamentgroup/x-rayhtml",
"version": "2.0.0",
"version": "2.0.1",
"author": "Mat Marquis",
"contributors": [
{
Expand Down

0 comments on commit 75bfeb8

Please sign in to comment.