This repository has been archived by the owner on Oct 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
index.html
192 lines (153 loc) · 5.73 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<!doctype html>
<!--[if lte IE 8]> <html lang="en" class="ie-lte8"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="demo/demo.css" rel="stylesheet">
<link href="src/X-rayHTML.css" rel="stylesheet">
<link href="src/lib/prism.css" rel="stylesheet">
<style>
.btn-xrayhtml-flipsource {
margin: 0 0 1em;
}
</style>
</head>
<body>
<div class="header">
<a href="http://filamentgroup.com/"><h1 id="fg-logo">Filament Group</h1></a>
</div>
<section>
<h1 class="sub">Basics</h1>
<p>By default, functionality is hooked to the <code>data-xrayhtml</code> attribute.</p>
<h2>Inline</h2>
<p>Bolting the <code>data-xrayhtml</code> attribute on without a value will give you inline code snippets, like so:</p>
<div data-xrayhtml>
<aside>
<blockquote>
<p>It is the unofficial force—the Baker Street irregulars.</p>
</blockquote>
<address>Sherlock Holmes</address>
<cite>Sign of Four</cite>
</aside>
</div>
<h2>Supplies Source Panel in Markup</h2>
<div data-xrayhtml>
<aside>
<blockquote>
<p>It is the unofficial force—the Baker Street irregulars.</p>
</blockquote>
<address>Sherlock Holmes</address>
<cite>Sign of Four</cite>
</aside>
<div class="source-panel">
<aside>
<blockquote>
<p>It is the unofficial force—the Baker Street irregulars (yes it can be different).</p>
</blockquote>
<address>Sherlock Holmes</address>
<cite>Sign of Four</cite>
</aside>
</div>
</div>
<h2>Add a subtitle</h2>
<p>Use a heading element with an <code>xraytitle</code> class to add your own subtitle to the example text.</p>
<p>Also works with a <code>data-title</code> attribute but that approach is deprecated.</p>
<div data-xrayhtml>
<h2 class="xraytitle">Parapraph</h2>
<p>This is a paragraph with text.</p>
</div>
<h2>Anti-patterns and Bad Examples</h2>
<p>Add <code>class="antipattern"</code> to show a bad example. Also works with subtitles as documented above.</p>
<div data-xrayhtml class="antipattern">
<h2 class="xraytitle">Non-standard HTML</h2>
<text><code>Text</code> is not a standard HTML element. Do not use this code.</text>
</div>
<h2>Flip</h2>
<p>Setting “flip” as the value of the <code>data-xrayhtml</code> attribute will give you this snazzy flip-to-reveal animation (browsers without support for 3D tranforms will simply show/hide the code snippet).</p>
<div data-xrayhtml="flip">
<aside>
<blockquote>
<p>It is the unofficial force—the Baker Street irregulars.</p>
</blockquote>
<address>Sherlock Holmes</address>
<cite>Sign of Four</cite>
</aside>
</div>
</section>
<section>
<h1 class="sub">Extras</h1>
<p>The plugin fires off a <code>create.xrayhtml</code> event that can be used to attach features like syntax highlighting (using <a href="http://prismjs.com">Prism.js</a>), or "copy to clipboard" (using <a href="https://clipboardjs.com/">Clipboard</a>).</p>
<h2>Prism.js</h2>
<p>Add the <code>prism</code> class to the <code>data-xrayhtml</code> container to colorize the code snippet.</p>
<div data-xrayhtml class="prism">
<aside>
<blockquote>
<p>It is the unofficial force—the Baker Street irregulars.</p>
</blockquote>
<address>Sherlock Holmes</address>
<cite>Sign of Four</cite>
</aside>
</div>
<h2>Copy (clipboard.js)</h2>
<p>Add the <code>xray-copy</code> class to the <code>data-xrayhtml</code> container to append a "Copy" button to the code snippet; when clicked, it'll copy the entire snippet.</p>
<div data-xrayhtml class="xray-copy">
<aside>
<blockquote>
<p>It is the unofficial force—the Baker Street irregulars.</p>
</blockquote>
<address>Sherlock Holmes</address>
<cite>Sign of Four</cite>
<p>(Copied from the demo page)</p>
</aside>
</div>
<h2>iframe</h2>
<p>It's also possible to use an iframe for situations where styles (like media queries) depend on the viewport. Specify the URL for the iframe with <code>data-xrayhtml-iframe="iframe.html"</code> on the <code>data-xrayhtml</code> element. You can also tell XRay where in the iframe page to place the included markup using <code>data-xrayhtml-iframe-target="#replace"</code>. Otherwise it will default to replacing the <code>body</code> HTML with the code XRay code snippet.</p>
<div data-xrayhtml data-xrayhtml-iframe="iframe.html" data-xrayhtml-iframe-target="#replace" class="prism">
<aside>
<blockquote>
<p>It is the unofficial force—the Baker Street irregulars.</p>
</blockquote>
<address>Sherlock Holmes</address>
<cite>Sign of Four</cite>
</aside>
</div>
</section>
<script src="src/lib/shoestring.js"></script>
<!-- Or jquery: <script src="src/lib/jquery.js"></script> -->
<script src="src/X-rayHTML.js"></script>
<!-- Demo Extras! -->
<script src="src/lib/prism.js"></script>
<script src="src/lib/clipboard.js"></script>
<script type="text/javascript">
$( window ).bind( "create.xrayhtml", function( e ) {
// Prism
var prism = !!~e.target.getAttribute( "class" ).indexOf( "prism" );
if( prism && "Prism" in window ) {
$( ".prism" ).find( "code" ).addClass( "language-markup" );
Prism.highlightAll();
}
// Clipboard
var copy = !!~e.target.getAttribute( "class" ).indexOf( "xray-copy" );
if( copy && "Clipboard" in window ) {
var $target = $( e.target );
var $snippet = $target.find( ".snippet" );
var html = $snippet.html();
var $link = $( "<a href='#' class='btn btn-xray-copy'>copy</a>" );
// place the link after the snippet but before the code
$snippet.after( $link );
// set of up the clipboard to use the html
new Clipboard($link[0], {
text: function(){
return html;
}
});
// disable the normal link click behavior
$link.bind( "click", function( e ){ e.preventDefault() });
}
});
</script>
</body>
</html>