mostly filebased Content Presentation System
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

featherlightREADME.md 30KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. Featherlight - ultra slim jQuery lightbox [![Build Status](https://travis-ci.org/noelboss/featherlight.svg?branch=master)](https://travis-ci.org/noelboss/featherlight)
  2. ------------------------
  3. **Featherlight is a very lightweight jQuery lightbox plugin. For more information and demos, visit the [official website](http://noelboss.github.io/featherlight/).**
  4. * Simple yet flexible
  5. * Image, Ajax, iFrame and custom content support
  6. * [Gallery Extension](https://github.com/noelboss/featherlight/#featherlight-gallery)
  7. * Minimal CSS
  8. * Name-spaced CSS and JavaScript
  9. * Responsive
  10. * Accessible
  11. * Customizable via javascript or attributes
  12. ## [» Download Current Release 1.7.13](https://github.com/noelboss/featherlight/archive/1.7.13.zip)
  13. Here you'll find a [list of all the changes](https://github.com/noelboss/featherlight/blob/master/CHANGELOG.md) and you can also download [old releases](https://github.com/noelboss/featherlight/releases) or [the master including all the latest bling](https://github.com/noelboss/featherlight/archive/master.zip).
  14. # Installation
  15. All styling is done using CSS so you'll want to include the Featherlight CSS in your head.
  16. <link href="//cdn.rawgit.com/noelboss/featherlight/1.7.13/release/featherlight.min.css" type="text/css" rel="stylesheet" />
  17. Be aware that Featherlight uses very unspecific CSS selectors to help you overwrite every aspect. This means in turn, that if you're not following a modularized approach to write CSS (which you should! It's terrific!) and have many global and specific definitions (read ID's and such – which you shouldn't), these definitions can break the Featherlight styling.
  18. Featherlight requires jQuery version 1.7.0 or higher (regular version, not the slim one). It's recommended to include the javascript at the bottom of the page before the closing `</body>` tag.
  19. <script src="//code.jquery.com/jquery-latest.js"></script>
  20. <script src="//cdn.rawgit.com/noelboss/featherlight/1.7.13/release/featherlight.min.js" type="text/javascript" charset="utf-8"></script>
  21. # Usage
  22. By default, featherlight acts on all elements using the 'data-featherlight' attribute. An element with this attribute triggers the lightbox. The value of the attribute acts as selector for an element that's opened as lightbox.
  23. <a href="#" data-featherlight="#mylightbox">Open element in lightbox</a>
  24. <div id="mylightbox">This div will be opened in a lightbox</div>
  25. Featherlight is smart. 'data-featherlight' can also contain a link to an image, an ajax-url or even DOM code:
  26. <a href="#" data-featherlight="myimage.png">Open image in lightbox</a>
  27. <a href="#" data-featherlight="myhtml.html .selector">Open ajax content in lightbox</a>
  28. <a href="#" data-featherlight="<p>Fancy DOM Lightbox!</p>">Open some DOM in lightbox</a>
  29. it also works with links using href and the "image" and "ajax" keywords (this can also be manually set with the configuration options like `{image: 'photo.jpg'}` or `{type: 'image'}`):
  30. <a href="myimage.png" data-featherlight="image">Open image in lightbox</a>
  31. <a href="myhtml.html .selector" data-featherlight="ajax">Open ajax content in lightbox</a>
  32. <a href="#" data-featherlight-ajax="myhtml.html .selector">Open ajax content in lightbox</a>
  33. <a href="#" data-featherlight="myhtml.html .selector" data-featherlight-type="ajax">Open ajax content in lightbox</a>
  34. By default, Featherlight initializes all elements matching `$.featherlight.autoBind` on document ready. If you want to prevent this, set `$.featherlight.autoBind` to `false` before the DOM is ready.
  35. ## Bind Featherlight
  36. You can bind the Featherlight events on any element using the following code:
  37. $('.myElement').featherlight($content, configuration);
  38. It will then look for the `targetAttr` (by default "data-featherlight") on this element and use its value to find the content that will be opened as lightbox when you click on the element.
  39. ***$content*** – jQuery Object or String: You can manually pass a jQuery object or a string (see [content filters](#content-filters)) to be opened in the lightbox. Optional
  40. ***configuration*** – Object: Object to configure certain aspects of the plugin. See [Configuration](#configuration). Optional
  41. ## Manual calling of Featherlight
  42. In cases where you don't want an Element to act as Trigger you can call Featherlight manually. You can use this for example in an ajax callback to display the response data.
  43. $.featherlight($content, configuration);
  44. ***$content*** – jQuery Object or String: You can manually pass a jQuery object or a string (see [content filters](#content-filters)) to be opened in the lightbox. Optional
  45. ***configuration*** – Object: Object to configure certain aspects of the plugin. See [Configuration](#configuration). Optional
  46. # Configuration
  47. Featherlight comes with a bunch of configuration-options which make it very flexible.
  48. These options can be passed when calling `featherlight`.
  49. Alternatively, they can specified as attribute on the elements triggering the lightbox;
  50. for example, `<a data-featherlight-close-on-esc="false" ...>` has the same effect as
  51. passing `{closeOnEsc: false}`.
  52. You can also modify the `$.featherlight.defaults` directly which holds all the defaults:
  53. ```javascript
  54. /* you can access and overwrite all defaults using $.featherlight.defaults */
  55. defaults: {
  56. namespace: 'featherlight', /* Name of the events and css class prefix */
  57. targetAttr: 'data-featherlight', /* Attribute of the triggered element that contains the selector to the lightbox content */
  58. variant: null, /* Class that will be added to change look of the lightbox */
  59. resetCss: false, /* Reset all css */
  60. background: null, /* Custom DOM for the background, wrapper and the closebutton */
  61. openTrigger: 'click', /* Event that triggers the lightbox */
  62. closeTrigger: 'click', /* Event that triggers the closing of the lightbox */
  63. filter: null, /* Selector to filter events. Think $(...).on('click', filter, eventHandler) */
  64. root: 'body', /* A selector specifying where to append featherlights */
  65. openSpeed: 250, /* Duration of opening animation */
  66. closeSpeed: 250, /* Duration of closing animation */
  67. closeOnClick: 'background', /* Close lightbox on click ('background', 'anywhere', or false) */
  68. closeOnEsc: true, /* Close lightbox when pressing esc */
  69. closeIcon: '&#10005;', /* Close icon */
  70. loading: '', /* Content to show while initial content is loading */
  71. persist: false, /* If set, the content will persist and will be shown again when opened again. 'shared' is a special value when binding multiple elements for them to share the same content */
  72. otherClose: null, /* Selector for alternate close buttons (e.g. "a.close") */
  73. beforeOpen: $.noop, /* Called before open. can return false to prevent opening of lightbox. Gets event as parameter, this contains all data */
  74. beforeContent: $.noop, /* Called when content is about to be presented. `this` is the featherlight instance. Gets event as parameter */
  75. beforeClose: $.noop, /* Called before close. can return false to prevent opening of lightbox. `this` is the featherlight instance. Gets event as parameter */
  76. afterOpen: $.noop, /* Called after open. `this` is the featherlight instance. Gets event as parameter */
  77. afterContent: $.noop, /* Called after content is ready and has been set. Gets event as parameter, this contains all data */
  78. afterClose: $.noop, /* Called after close. `this` is the featherlight instance. Gets event as parameter */
  79. onKeyUp: $.noop, /* Called on key up for the frontmost featherlight */
  80. onResize: $.noop, /* Called after new content and when a window is resized */
  81. type: null, /* Specify content type. If unset, it will check for the targetAttrs value. */
  82. contentFilters: ['jquery', 'image', 'html', 'ajax', 'text'] /* List of content filters to use to determine the content */
  83. jquery/image/html/ajax/text: undefined /* Specify content type and data */
  84. }
  85. ```
  86. ================================================
  87. namespace – String: 'featherlight'
  88. All functions bound to elements are namespaced. This is also used to prefix all CSS classes for the background, the content-wrapper and the close button.
  89. ================================================
  90. targetAttr – String: 'data-featherlight'
  91. Attribute on the triggering element pointing to the target element or content that will be opened in the lightbox.
  92. ================================================
  93. variant – String: null
  94. Pass your own CSS class to adjust the styling of the lightbox according to your need.
  95. ================================================
  96. resetCss – Boolean: false
  97. Set this to true to remove all default css and start from designing scratch.
  98. ================================================
  99. openTrigger & closeTrigger – String: 'click'
  100. Events that are used to open or close the lightbox. The close event is bound to the close button and to the lightbox background (if enabled).
  101. Has no effect if $.featherlight is called directly.
  102. ================================================
  103. filter - String: null
  104. A selector to filter events, when calling `featherlight` on a jQuery set, in a similar fashion to `$(...).on('click', filter, eventHandler)`.
  105. Attributes both the selector and the filtered element are taken into account.
  106. In the following example, the first link will make an ajax request while the second will display the text "second".
  107. <div data-featherlight data-featherlight-filter="a"
  108. data-featherlight-type="ajax">
  109. <a href="first">Hello</a>
  110. <a href="second" data-featherlight-type="text">World</a>
  111. </div>
  112. ================================================
  113. root - String: 'body'
  114. This selector specified where the featherlight should be appended.
  115. ================================================
  116. openSpeed & closeSpeed – Integer or String: 250
  117. Defines the speed for the opening and close animations. Values allowed are [jQuery animation durations](http://api.jquery.com/animate/#duration). Avoid the usage of 0 since this would cause a reversal of time and the end of the world! (Okay, kidding, just the closing callback would not be fired and unused ghost-DOM would linger around, but still.)
  118. ================================================
  119. closeOnClick – 'background', 'anywhere' or false
  120. If set, the close event is also bound to the either the background only or anywhere
  121. ================================================
  122. closeOnEsc – Boolean: true
  123. If true, the lightbox is closed when pressing the ESC key
  124. ================================================
  125. closeIcon – String: '&#10005;';
  126. Oh the naming...
  127. ================================================
  128. loading – String: '';
  129. Shown initially while content loads. The lightbox also has a class '.featherlight-loading' while content is loading. This makes it easy to specify a "Loading..." message or a spinner.
  130. ================================================
  131. persist - Boolean or 'shared': false;
  132. If set, the content will persist and will be shown again when opened again.
  133. In case where multiple buttons need to persist the same content, use the special value 'shared'.
  134. The content filter `jquery` (used for links like `.some-class` or `#some-id`) will clone the given content if and only if it is not persisted. Otherwise it will be moved into the lightbox.
  135. ================================================
  136. otherClose - String: null
  137. While the close icon generated by featherlight will have class 'featherlight-close', you may specify alternate selector for other buttons having the same effect in your dialog, for example "a:contains('Cancel')".
  138. ================================================
  139. background – DOM String: null
  140. You can provide the wrapping DOM. This is a bit tricky and just for the advanced users. It's recommended to study the plugin code. But you need to provide an element with a "{namespace}-inner" class: the content of the lightbox will replace this element. It is recommended that instead of providing this option you modify the lightbox on `beforeOpen` or `afterOpen`.
  141. ================================================
  142. beforeOpen, beforeClose – Function: null
  143. Called before the open or close method is executed. This function can return false to prevent open or
  144. close method from execution. `this` is an object and contains the triggering DOM element (if existing) and the related Featherlight objects.
  145. // example
  146. beforeOpen: function(event){
  147. console.log(this); // this contains all related elements
  148. return false; // prevent lightbox from opening
  149. }
  150. ================================================
  151. beforeContent, afterContent – Function: null
  152. Called before and after the loading of the content. For ajax calls or images, there can be a significant delay, for inline content the two calls will occur one right after the other. It receives the event object. `this` is an object and contains the triggering DOM element (if existing) and the related Featherlight objects.
  153. ================================================
  154. afterOpen, afterClose – Function: null
  155. Called after the open or close method is executed – it is not called, if the `before-` or `open` function returns `false`! It receives the event object. `this` is an object and contains the triggering DOM element (if existing) and the related Featherlight objects.
  156. // example
  157. afterOpen: function(event){
  158. console.log(this); // this contains all related elements
  159. alert(this.$content.hasClass('true')); // alert class of content
  160. }
  161. ================================================
  162. onKeyUp, onResize – Function: null
  163. The function receives the event object. `this` is an object and contains the triggering DOM element (if existing) and the related Featherlight objects.
  164. ================================================
  165. type – String: null
  166. The type object allows you to manually set what type the lightbox is. Set the value to 'image', 'ajax' or any of the content filters. Otherwise, the value from targetAttr will used be to determine the type of the lightbox. Example:
  167. $('.image-lightbox').featherlight({type: 'image'});
  168. # Methods
  169. `$.featherlight` is actually a constructor of new featherlight objects. Modify `$.featherlight.prototype` to change the default properties, or use the `configuration` object passed to the constructor to override the properties of that specific new instance.
  170. It's possible to use or change these methods, but the API isn't guaranteed to remain constant; enquire if you have particular needs.
  171. var current = $.featherlight.current();
  172. current.close();
  173. // do something else
  174. current.open(); // reopen it
  175. Check the source code for more details.
  176. # Globals
  177. `$.featherlight` has the following globals:
  178. autoBind: '[data-featherlight]' /* Will automatically bind elements matching this selector. Clear or set before onReady */
  179. current: function() /* returns the currently opened featherlight, or undefined */
  180. close: function() /* closes the currently opened featherlight (if any) */
  181. # Content Filters
  182. There are many ways to specify content to featherlight. Featherlight uses a set of heuristics to determine the type, for example data ending with `.gif` will be assumed to be an image. The following are equivalent:
  183. <a href="#" data-featherlight="photo.gif">See in a lightbox</a>
  184. <a href="photo.gif" data-featherlight>See in a lightbox</a>
  185. <a id="#example" href="#">See in a lightbox</a>
  186. <script>$('#example').featherlight('photo.gif');</script>
  187. In case the heuristic wouldn't work, you can specify which contentFilter to use:
  188. <a href="photo_without_extension" data-featherlight="image">See in a lightbox</a>
  189. <a id="force_as_image" href="photo_without_extension">See in a lightbox</a>
  190. <script>
  191. $('#force_as_image').featherlight('image');
  192. // Equivalent:
  193. $('#force_as_image').featherlight({type: {image: true}});
  194. </script>
  195. <a id="force_as_image2" href="#">See in a lightbox</a>
  196. <script>$('#force_as_image2').featherlight('photo_without_extension', {type:{image: true}});</script>
  197. You can add your own heuristics, for example:
  198. $.featherlight.contentFilters.feed = {
  199. regex: /^feed:/,
  200. process: function(url) { /* deal with url */ return $('Loading...'); }
  201. };
  202. $.featherlight.defaults.contentFilters.unshift('feed');
  203. This way the following would be possible:
  204. <a href="feed://some_url" data-featherlight>See the feed in a lightbox</a>
  205. The content filter 'text' needs to be specified explicitly, it has no heuristic attached to it:
  206. <a href="Hello, world" data-featherlight="text">Example</a>
  207. # Examples
  208. ## Use link-hashtags to open lightbox
  209. <a href="#targetElement" class="fl">Open</a>
  210. <div id="targetElement">Lightbox</div>
  211. $('a.fl').featherlight({
  212. targetAttr: 'href'
  213. });
  214. ## Open images with Featherlight
  215. Use a link and point the data-featherlight attribute to the desired attribute which contains the link...
  216. <a href="myimage.jpg" data-featherlight="image">Open Image</a>
  217. ...or directly provide the link as the data-featherlight attribute:
  218. <a href="#" data-featherlight="myimage.jpg">Open Image</a>
  219. ## Open lightbox with ajax content
  220. Use Featherlight with ajax using 'ajax' keyword or providing a url. It even supports selecting elements inside the response document.
  221. <a href="url.html .jQuery-Selector" data-featherlight="ajax">Open Ajax Content</a>
  222. or you can provide the link directly as the featherlight-attribute:
  223. <a href="#" data-featherlight="url.html .jQuery-Selector">Open Ajax Content</a>
  224. ## Open lightbox with iframe
  225. Featherlight generates an iframe with the 'iframe' keyword and a given URL.
  226. The default size of the iframe is very small (300 x 150).
  227. <a href="http://www.example.com" data-featherlight="iframe">Open example.com in an iframe</a>
  228. Options:
  229. You can use the following iframe attributes:
  230. `
  231. allow, allowfullscreen, frameborder, height, longdesc, marginheight, marginwidth, mozallowfullscreen, name, referrerpolicy, sandbox, scrolling, src, srcdoc, style, webkitallowfullscreen, width
  232. `
  233. For example, to set the height and width, you would use
  234. data-featherlight-iframe-height="640" data-featherlight-iframe-width="480"
  235. or to set some css style:
  236. data-featherlight-iframe-style="border:none"
  237. You can also set the iframe attributes `iframeWidth`, `iframeMinWidth` etc. using JavaScript:
  238. $.featherlight({iframe: 'editor.html', iframeMaxWidth: '80%', iframeWidth: 500,
  239. iframeHeight: 300});
  240. ## Open YouTube video with Featherlight
  241. Featherlight generates an iframe that contains the embedded video.
  242. Display a clickable thumbnail image that opens a video with a fixed size of 640 x 480 and automatically start playback:
  243. `
  244. <a href="http://www.youtube.com/embed/f0BzD1zCye0?rel=0&amp;autoplay=1" data-featherlight="iframe" data-featherlight-iframe-width="640" data-featherlight-iframe-height="480" data-featherlight-iframe-frameborder="0" data-featherlight-iframe-allow="autoplay; encrypted-media" data-featherlight-iframe-allowfullscreen="true">
  245. <img src="http://img.youtube.com/vi/f0BzD1zCye0/0.jpg" alt="" />
  246. </a>
  247. `
  248. A text link that opens a video in a lightbox that is stretched to 85% height and width of the viewport:
  249. `
  250. <a href="http://www.youtube.com/embed/f0BzD1zCye0?rel=0&amp;autoplay=1" data-featherlight="iframe" data-featherlight-iframe-frameborder="0" data-featherlight-iframe-allow="autoplay; encrypted-media" data-featherlight-iframe-allowfullscreen="true" data-featherlight-iframe-style="display:block;border:none;height:85vh;width:85vw;">My video</a>
  251. `
  252. A link that opens a video in a lightbox that fills 100% of the window:
  253. Note: the "close" icon is not visible so this example is not user-friendly.
  254. `
  255. <a href="http://www.youtube.com/embed/f0BzD1zCye0?rel=0&amp;autoplay=1" data-featherlight="iframe" data-featherlight-iframe-frameborder="0" data-featherlight-iframe-allow="autoplay; encrypted-media" data-featherlight-iframe-allowfullscreen="true"
  256. data-featherlight-iframe-style="position:fixed;background:#000;border:none;top:0;right:0;bottom:0;left:0;width:100%;height:100%;">My video</a>
  257. `
  258. # IE8 background transparency
  259. If you want the background in IE8 to be translucent, use data:image before the rgba background:
  260. background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAKQWlDQ1BJQ0MgUHJvZmlsZQAASA2dlndUU9kWh8+9N73QEiIgJfQaegkg0jtIFQRRiUmAUAKGhCZ2RAVGFBEpVmRUwAFHhyJjRRQLg4Ji1wnyEFDGwVFEReXdjGsJ7601896a/cdZ39nnt9fZZ+9917oAUPyCBMJ0WAGANKFYFO7rwVwSE8vE9wIYEAEOWAHA4WZmBEf4RALU/L09mZmoSMaz9u4ugGS72yy/UCZz1v9/kSI3QyQGAApF1TY8fiYX5QKUU7PFGTL/BMr0lSkyhjEyFqEJoqwi48SvbPan5iu7yZiXJuShGlnOGbw0noy7UN6aJeGjjAShXJgl4GejfAdlvVRJmgDl9yjT0/icTAAwFJlfzOcmoWyJMkUUGe6J8gIACJTEObxyDov5OWieAHimZ+SKBIlJYqYR15hp5ejIZvrxs1P5YjErlMNN4Yh4TM/0tAyOMBeAr2+WRQElWW2ZaJHtrRzt7VnW5mj5v9nfHn5T/T3IevtV8Sbsz55BjJ5Z32zsrC+9FgD2JFqbHbO+lVUAtG0GQOXhrE/vIADyBQC03pzzHoZsXpLE4gwnC4vs7GxzAZ9rLivoN/ufgm/Kv4Y595nL7vtWO6YXP4EjSRUzZUXlpqemS0TMzAwOl89k/fcQ/+PAOWnNycMsnJ/AF/GF6FVR6JQJhIlou4U8gViQLmQKhH/V4X8YNicHGX6daxRodV8AfYU5ULhJB8hvPQBDIwMkbj96An3rWxAxCsi+vGitka9zjzJ6/uf6Hwtcim7hTEEiU+b2DI9kciWiLBmj34RswQISkAd0oAo0gS4wAixgDRyAM3AD3iAAhIBIEAOWAy5IAmlABLJBPtgACkEx2AF2g2pwANSBetAEToI2cAZcBFfADXALDIBHQAqGwUswAd6BaQiC8BA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29sPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICAgICA8dGlmZjpDb21wcmVzc2lvbj41PC90aWZmOkNvbXByZXNzaW9uPgogICAgICAgICA8dGlmZjpSZXNvbHV0aW9uVW5pdD4xPC90aWZmOlJlc29sdXRpb25Vbml0PgogICAgICAgICA8dGlmZjpZUmVzb2x1dGlvbj43MjwvdGlmZjpZUmVzb2x1dGlvbj4KICAgICAgICAgPHRpZmY6WFJlc29sdXRpb24+NzI8L3RpZmY6WFJlc29sdXRpb24+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4xMDwvZXhpZjpQaXhlbFhEaW1lbnNpb24+CiAgICAgICAgIDxleGlmOkNvbG9yU3BhY2U+MTwvZXhpZjpDb2xvclNwYWNlPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MTA8L2V4aWY6UGl4ZWxZRGltZW5zaW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KbQS91AAAAB1JREFUGBljZGBgOA7EBAETQRVQBaMK8YYU0cEDAE1HANt9zybzAAAAAElFTkSuQmCC);
  261. background: rgba(0, 0, 0, 0.8);
  262. ---
  263. # Featherlight Gallery
  264. You will need to use an extension (featherlight.gallery.js). Since Featherlight was created to be as small and simple as possible, it has selected functionality, and allows you to add additional functionality by using extensions. featherlight.gallery.js is a small extension that turns your set of links into a [gallery](http://noelboss.github.io/featherlight/gallery.html).
  265. ## Gallery installation
  266. Simply include the extension CSS and JavaScript Files after the regular featherlight files like this:
  267. <link href="//cdn.rawgit.com/noelboss/featherlight/1.7.13/release/featherlight.min.css" type="text/css" rel="stylesheet" />
  268. <link href="//cdn.rawgit.com/noelboss/featherlight/1.7.13/release/featherlight.gallery.min.css" type="text/css" rel="stylesheet" />
  269. Add the JavaScript at the bottom of the body:
  270. ```html
  271. <script src="//code.jquery.com/jquery-latest.js"></script>
  272. <script src="//cdn.rawgit.com/noelboss/featherlight/1.7.13/release/featherlight.min.js" type="text/javascript" charset="utf-8"></script>
  273. <script src="//cdn.rawgit.com/noelboss/featherlight/1.7.13/release/featherlight.gallery.min.js" type="text/javascript" charset="utf-8"></script>
  274. ```
  275. Check out the example here: [Gallery with Featherlight](gallery.html)
  276. ## Gallery configuration
  277. The gallery also has a range of configuration options and the following defaults:
  278. ```javascript
  279. $('a.gallery').featherlightGallery({
  280. previousIcon: '&#9664;', /* Code that is used as previous icon */
  281. nextIcon: '&#9654;', /* Code that is used as next icon */
  282. galleryFadeIn: 100, /* fadeIn speed when slide is loaded */
  283. galleryFadeOut: 300 /* fadeOut speed before slide is loaded */
  284. });
  285. ```
  286. It also overrides its `autoBind` global option:
  287. ```javascript
  288. autoBind: '[data-featherlight-gallery]' /* Will automatically bind elements matching this selector. Clear or set before onReady */
  289. ```
  290. Example in pure HTML:
  291. ```html
  292. <section
  293. data-featherlight-gallery
  294. data-featherlight-filter="a"
  295. >
  296. <h>This is a gallery</h>
  297. <a href="photo_large.jpg"><img src="photo_thumbnail.jpg"></a>
  298. <a href="other_photo_large.jpg"><img src="other_photo_thumbnail.jpg"></a>
  299. </section>
  300. ```
  301. Example in JavaScript (assuming there are `a` tags of class `gallery` in the page):
  302. ```javascript
  303. $('a.gallery').featherlightGallery({
  304. previousIcon: '«',
  305. nextIcon: '»',
  306. galleryFadeIn: 300,
  307. openSpeed: 300
  308. });
  309. ```
  310. The gallery responds to custom events `previous` and `next` to navigate to the previous and next images.
  311. Instead of navigation buttons it will use swipe events on touch devices, assuming that one of the [supported swipe libraries](https://github.com/noelboss/featherlight/wiki/Gallery:-swipe-on-touch-devices) is also installed.
  312. It sets the classes `'featherlight-first-slide'` and `'featherlight-last-slide'` if the current slide is the first and/or last one.
  313. ## Gallery installation
  314. Simply include the extension CSS and JavaScript Files after the regular featherlight files like this:
  315. <link href="//cdn.rawgit.com/noelboss/featherlight/1.7.13/release/featherlight.min.css" type="text/css" rel="stylesheet" />
  316. <link href="//cdn.rawgit.com/noelboss/featherlight/1.7.13/release/featherlight.gallery.min.css" type="text/css" rel="stylesheet" />
  317. <script src="//code.jquery.com/jquery-latest.js"></script>
  318. <script src="//cdn.rawgit.com/noelboss/featherlight/1.7.13/release/featherlight.min.js" type="text/javascript" charset="utf-8"></script>
  319. <script src="//cdn.rawgit.com/noelboss/featherlight/1.7.13/release/featherlight.gallery.min.js" type="text/javascript" charset="utf-8"></script>
  320. ## Gallery on Mobile Devices
  321. To support mobile/tablet and all touch devices, you will need to include one of the [supported swipe libraries](https://github.com/noelboss/featherlight/wiki/Gallery:-swipe-on-touch-devices). For example, to use `swipe_detect` library, include it in the header:
  322. ```html
  323. <script src="//cdnjs.cloudflare.com/ajax/libs/detect_swipe/2.1.1/jquery.detect_swipe.min.js"></script>
  324. ```
  325. # Support
  326. ## Questions
  327. For questions, please use [Stack Overflow](http://stackoverflow.com/questions/ask) and be sure to use the `featherlight.js` tag. Please **provide an example**, starting for example from [this jsfiddle](http://jsfiddle.net/JNsu6/15/)
  328. ## Reporting bugs and issues
  329. If you believe you've found a bug, please open an issue on [Github](https://github.com/noelboss/featherlight/issues/new) and **provide an example** starting from [this jsfiddle](http://jsfiddle.net/JNsu6/15/).
  330. ## Pull requests
  331. Pull requests are welcome (good tips can be found on [Stack Overflow](http://stackoverflow.com/questions/14680711/how-to-do-a-github-pull-request))
  332. To run the tests, you can open `test/featherlight.html` or `test/featherlight_gallery.html` in your browser.
  333. Alternatively, run them from the console with `grunt test`; you will need to run `npm install` the first time.