-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.html
196 lines (184 loc) · 12.6 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
193
194
195
196
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>caption.js | Easily and semantically add captions to images</title>
<meta name="description" content="An open-source jQuery plugin to easily and semantically add captions to images."/>
<link rel="icon" type="image/png" href="web/favicon.png"/>
<!--[if IE]><script src="//html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script><![endif]-->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lora:400,400italic,700,700italic|Abril+Fatface"/>
<link rel="stylesheet" href="web/scripts/syntaxhighlighter/styles/shCore.css"/>
<link rel="stylesheet" href="web/scripts/syntaxhighlighter/styles/shThemeDefault.css"/>
<link rel="stylesheet" href="web/styles/main.css"/>
<script>document.documentElement.className+='js';</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="web/scripts/jquery.lettering.js"></script>
<script src="web/scripts/syntaxhighlighter/scripts/shCore.min.js"></script>
<script src="web/scripts/syntaxhighlighter/scripts/shAutoloader.js"></script>
<script src="web/scripts/jquery.scrollTo-1.4.3.1-min.js"></script>
<script src="web/scripts/jquery.localscroll-1.2.7-min.js"></script>
<script src="dist/jquery.caption.js"></script>
<script src="web/scripts/main.js"></script>
<!--///////////////////////////// Required CSS /////////////////////////////-->
<link rel="stylesheet" href="dist/captionjs.css"/>
<!--///////////////////////////// Sample CSS /////////////////////////////-->
<style>
.captionjs, .captionjs figcaption {
margin: 0 0 20px;
padding: 0;
}
.captionjs figcaption {
font-size: 13px;
line-height: 1.5;
padding: 10px 15px;
border: 1px solid #ddd;
border-top: none;
background-color: #eee;
}
.captionjs.captionjs-stacked figcaption {
background-color: rgba(0, 0, 0, 0.75);
color: #fff;
border: none;
}
.captionjs.captionjs-animated figcaption {
border-top: 1px solid rgba(255, 255, 255, 0.3);
background-color: rgba(0, 0, 0, 0.75);
color: #fff;
border: none;
}
.captionjs.captionjs-hidden figcaption {
border-top: 1px solid rgba(255, 255, 255, 0.3);
background-color: rgba(0, 0, 0, 0.75);
color: #fff;
border: none;
}
.captionjs.captionjs-default a {
color: #000;
}
</style>
<!--///////////////////////////// Sample JS /////////////////////////////-->
<script>
$(window).load(function(){
$('img#example-1').captionjs({
'force_dimensions': true
});
$('img#example-2').captionjs({
'force_dimensions': true,
'mode' : 'stacked'
});
$('img#example-3').captionjs({
'force_dimensions': true,
'mode' : 'hidden'
});
$('img#example-4').captionjs({
'force_dimensions': true,
'mode' : 'animated'
});
$('img#example-5').captionjs({
'force_dimensions': true,
'is_responsive' : true,
'mode' : 'animated'
});
});
</script>
</head>
<body>
<a href="https://github.com/ericmagnuson/captionjs" class="github-corner" id="github" aria-label="View source on Github">
<svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true">
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
<path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
<path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path>
</svg>
</a>
<style>
.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}
</style>
<a id="top"></a>
<header class="wrapper">
<h1>caption.js</h1>
<h2>easily and semantically add captions to images</h2>
</header>
<nav class="wrapper">
<div>
<div>
<ul>
<li><a href="#quick_start">quick start</a></li>
<li><a href="#why_captionjs">why caption.js</a></li>
<li><a href="#documentation">documentation</a></li>
<li><a href="#examples">examples</a></li>
<li class="r"><a href="#top">top ↑</a></li>
</ul>
</div>
</div>
</nav>
<div class="wrapper">
<h2><a id="quick_start">Quick Start</a></h2>
<a href="https://captionjs.com/download" title="Download caption.js here!" id="download"><button>Download the latest version (v1.0.2)</button></a>
<p>To begin, make sure you have jQuery included on your page. Next, download the script from above, upload it to your server, and link to it in the <code><head></code> section of your page (make sure you adjust the path according to where you uploaded the script on your server).</p>
<pre class="brush: html">
<script src="jquery.caption.js"></script>
</pre>
<p>You may also put the above code right inside the closing <code></body></code> tag to help increase loading times on your site. For more info, see <a href="https://developer.yahoo.com/performance/rules.html#js_bottom">Yahoo!'s article on page speed optimization</a>.</p>
<p>Then, add the CSS to your site.</p>
<pre class="brush: html">
<link href="captionjs.css" rel="stylesheet"/>
</pre>
<p>Finally, initialize the plugin within a <code>$(window).load()</code> function as follows:</p>
<pre class="brush: js">
$(window).load(function() {
$('img.caption').captionjs();
});
</pre>
<p>Whatever text you have in an image's <code>data-caption</code> attribute will be the text for the caption.js caption. If no <code>data-caption</code> is set, caption.js will look for text in the image's <code>alt</code> text as a fallback. You can also turn the caption into a link by adding a <code>data-link</code> attribute to your image and inserting a fully qualified URL into it.</p>
<pre class="brush: html">
<img src="photo.jpg" data-caption="A wonderful caption for the photo."/></pre>
<p>To customize caption.js, see the documentation section below.</p>
<h2><a id="why_captionjs">Why caption.js?</a></h2>
<p>There are a lot of jQuery-based solutions for putting captions on your page. What sets caption.js apart from the rest is that, instead of wrapping your images layers deep in <code>divs</code>, it adds captions using semantic markup (i.e., <code>figure</code> and <code>figcaption</code> tags).</p>
<p>Using semantic markup not only helps organize your code, it aids in accessibility for people using assistive devices to view websites and helps in <abbr title="search engine optimization">SEO</abbr> by feeding search engines meaningful, structured code.</p>
<h2><a id="documentation">Documentation</a></h2>
<pre class="brush: js">
$(window).load(function() {
$('img.caption').captionjs({
'class_name' : 'captionjs', // Class name for each <figure>
'schema' : true, // Use schema.org markup (i.e., itemtype, itemprop)
'mode' : 'default', // default | stacked | animated | hidden (deprecated: hide)
'debug_mode' : false, // Output debug info to the JS console
'force_dimensions': true, // Force the dimensions in case they cannot be detected (e.g., image is not yet painted to viewport)
'is_responsive' : false, // Ensure the figure and image change size when in responsive layout. Requires a container to control responsiveness!
'inherit_styles' : false // Have the caption.js container inherit box-model properties from the original image
});
});
</pre>
<p>Since you’ll probably like to customize the <code><figure></code> elements that caption.js generates, you can set a custom class for them (or just use the default <code>.captionjs</code> class). caption.js also features four different modes, which are shown in the examples below. For diagnosing problems, a debug mode is available. If you have images which are initially hidden when the page is loaded (or if you're experiencing weird behaviors/sizing with the captions), set the <code>'force_dimensions'</code> option to <code>true</code> so that caption.js can correctly detect the size of your images. If you have a responsive site, enable <code>'is_responsive'</code> to ensure the figure will enlarge and shrink with your layout — just be sure to wrap the original image in a responsive container. Finally, the <code>inherit_styles</code> property will attempt to copy any box model properties from your original image to the caption.js container (that way you don't have to add any addition styles yourself).</p>
<h2><a id="examples">Examples</a></h2>
<img id="example-1" class="caption" src="https://farm9.staticflickr.com/8378/8360655820_df685ca91e_c.jpg" data-caption="The busy Khao San Road in Bangkok, Thailand." data-link="https://www.flickr.com/photos/esm723/8360655820"/>
<p>The first example is the <em>default</em> mode, in which the caption sits below the image. There is also a link added to the caption using the image&rsuo; <code>data-link</code> attribute.</p>
<img id="example-2" class="caption" src="https://farm9.staticflickr.com/8497/8360650488_12afeb2af7_c.jpg" data-caption="A bridge spanning a canal just west of Bangkok’s Hua Lamphong Railway Station."/>
<p>The second example shows how captions can be stacked on top of the image using the <em>stacked</em> mode.</p>
<img id="example-3" class="caption" src="https://farm9.staticflickr.com/8362/8359588651_2ba0f7c6a4_c.jpg" data-caption="A monk passing the time on a bench in Sanam Luang, a plaza next to the Grand Palace in Bangkok, Thailand that was once used for royal ceremonies."/>
<p>The third mode, <em>hidden</em>, has a caption that slides down when a user hovers over the photo, allowing the image to be seen unobscured.</p>
<img id="example-4" class="caption" src="https://farm3.staticflickr.com/2453/3725143668_c5f2500443_b.jpg" alt="Two climbers in the Bernese Alps of Switzerland stand on a precipice across from a large mountain peak shrouded in clouds called the Mönch."/>
<p>The last mode, <em>animated</em>, features an animated caption that appears when the user hovers over the image. Also, in this example, the caption text comes from the image's <code>alt</code> text rather than its <code>data-caption</code> attribute, as is the case for the other examples.</p>
<p>If you’re using caption.js in a responsive setting, be sure to enable the <code>is_responsive</code> setting, and make sure your original image is wrapped in a responsive container (in other words, the direct parent container should be responsive, or have a variable width). See below for an example.</p>
</div>
<div style="width: 100%">
<img id="example-5" class="caption" src="web/img/Evening_Return-wide.jpg" alt="View of Koh Phi Phi Leh at sunset during the return trip home."/>
</div>
<div class="wrapper">
<h2><a id="contribute">Contribute</a></h2>
<p>Want to help build out caption.js? Come on by on our <a href="https://github.com/ericmagnuson/captionjs" title="Fork us on Github">Github project page</a>. If you have an update you'd like to see implemented, just send a pull request or get in touch via <a href="https://twitter.com/captionjs" title="Visit caption.js' Twitter">Twitter</a>.</p>
</div>
<footer class="wrapper">
<p>by <a href="https://twitter.com/ericmagnuson" title="Visit Eric's Twitter">@ericmagnuson</a> | For questions and updates, find <a href="https://twitter.com/captionjs" title="Visit caption.js' Twitter">@captionjs</a> on Twitter.</p>
</footer>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-6413632-6', 'captionjs.com');
ga('send', 'pageview');
</script>
</body>
</html>