Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A lightbox gallery plugin for jQuery

License

NotificationsYou must be signed in to change notification settings

ajlkn/jquery.poptrox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Adds lightbox galleries to jQuery. Heavily customizable, easy to use, and built tosupport images, videos (YouTube, Vimeo, Wistia, Brightcove), Soundcloud tracks, IFRAMEs, and AJAX content.

Requires jQuery 1.7+.

Usage

Load it after jQuery:

<scriptsrc="http://code.jquery.com/jquery-x.x.x.min.js"></script><scriptsrc="jquery.poptrox.min.js"></script>

Set up your gallery:

<divid="gallery"><ahref="path/to/image1.jpg"><imgsrc="path/to/image1_thumbnail.jpg"/></a><ahref="path/to/image2.jpg"><imgsrc="path/to/image2_thumbnail.jpg"/></a><ahref="path/to/image3.jpg"><imgsrc="path/to/image3_thumbnail.jpg"/></a><ahref="path/to/image4.jpg"><imgsrc="path/to/image4_thumbnail.jpg"/></a><ahref="path/to/image5.jpg"><imgsrc="path/to/image5_thumbnail.jpg"/></a><ahref="path/to/image6.jpg"><imgsrc="path/to/image6_thumbnail.jpg"/></a></div>

And callpoptrox() on it:

varfoo=$('#gallery');foo.poptrox();

Notes

  • Poptrox parsesall anchors inside the element you call it on, even ifthey're nested in other stuff. For example, this would totally work:
<divid="gallery"><section><h2>Stuff I Like</h2><ul><li><ahref="path/to/image1.jpg"><imgsrc="path/to/image1_thumbnail.jpg"/></a></li><li><ahref="path/to/image2.jpg"><imgsrc="path/to/image2_thumbnail.jpg"/></a></li><li><ahref="path/to/image3.jpg"><imgsrc="path/to/image3_thumbnail.jpg"/></a></li></ul></section><section><h2>Stuff I Don't Like</h2><ul><li><ahref="path/to/image1.jpg"><imgsrc="path/to/image1_thumbnail.jpg"/></a></li><li><ahref="path/to/image2.jpg"><imgsrc="path/to/image2_thumbnail.jpg"/></a></li><li><ahref="path/to/image3.jpg"><imgsrc="path/to/image3_thumbnail.jpg"/></a></li></ul></section></div>
  • Each anchor must link to whatever you want shown in its popup, be it an imageor something else (see below).

  • If you want captions on your popups, enableusePopupCaption (see below) and assignatitle attribute to your<img> element, like so:

<ahref="path/to/image.jpg"><imgsrc="path/to/image_thumbnail.jpg"title="This right here is a caption."/></a>
  • You can also use thecaption option to tell Poptrox where it should look for captions:
caption:null

The default behavior, which simply uses thetitle attribute of each<img> element.

caption:{selector:"xxxxxx"}

Uses the content of the element pointed to by the selectorxxxxxx (must be inside the anchor).

caption:{selector:"xxxxxx",remove:true}

Uses the content of the element pointed to by the selectorxxxxxx (must be inside the anchor),thenremoves the element.

caption:function(a){/* return something */},

(Advanced) Uses a callback function to figure out the caption, wherea is a jQuery objectpointing to the anchor tag.

Supported Types

In addition to images, popups can also show other stuff (like YouTube videos).To do this, point your thumbnail's anchor to the appropriate URL (see below for specifics)and give it adata-poptrox attribute like so:

<ahref="http://untitled.tld/path/to/whatever"data-poptrox="type,(width)x(height)"><imgsrc="path/to/thumbnail.jpg"/></a>

Thedata-poptrox attribute breaks down like this:

  • type: The type (eg.youtube)
  • (width)x(height): An optional width and height for the popup (eg.800x400)

YouTube Videos

  • Link format:http://youtu.be/xxxxxxxxxxx (found via the "Share" link)
  • Type:youtube
  • Example:
<ahref="http://youtu.be/loGm3vT8EAQ"data-poptrox="youtube,800x480"><imgsrc="path/to/thumbnail.jpg"/></a>

Vimeo Videos

  • Link format:http://vimeo.com/xxxxxxxx (found via the "Share" button under "Embed")
  • Type:vimeo
  • Example:
<ahref="http://vimeo.com/22439234"data-poptrox="vimeo,800x480"><imgsrc="path/to/thumbnail.jpg"/></a>

Wistia Videos

  • Link format:http://fast.wistia.net/embed/iframe/fe8t32e27x (found via "Share" or "Get Link")
  • Type:wistia
  • Example:
<ahref="http://fast.wistia.net/embed/iframe/fe8t32e27x"data-poptrox="wistia,800x480"><imgsrc="path/to/thumbnail.jpg"/></a>

Brightcove Videos

  • Link format:http://bcove.me/xxxxxxxx (found via "Share" or "Get Link")
  • Type:bcove
  • Example:
<ahref="http://bcove.me/qly3wjdw"data-poptrox="bcove,636x360"><imgsrc="path/to/thumbnail.jpg"/></a>

Soundcloud Tracks

  • Link format:https://api.soundcloud.com/tracks/xxxxxxxx (found via the "Share" buttonunder "Widget Code" or "WordPress Code")
  • Type:soundcloud
  • Example:
<ahref="https://api.soundcloud.com/tracks/93549370"data-poptrox="soundcloud"><imgsrc="path/to/thumbnail.jpg"/></a>

IFRAMEs

  • Link format: Anything.
  • Type:iframe
  • Example:
<ahref="path/to/whatever.html"data-poptrox="iframe,600x400"><imgsrc="path/to/thumbnail.jpg"/></a>

AJAX Content

  • Link format: Anything (as long as it's on the same domain)
  • Type:ajax
  • Example:
<ahref="path/to/whatever.html"data-poptrox="ajax,600x400"><imgsrc="path/to/thumbnail.jpg"/></a>

Ignore

This "special" (unspecial?) type just tells Poptrox to treat whatever's inhref as if it were a normal link.

  • Link format: Anything.
  • Type:ignore
  • Example:
<ahref="http://n33.co"data-poptrox="ignore"><imgsrc="path/to/thumbnail.jpg"/></a>

Config

poptrox() has numerous options one can use or override, if one were so inclined:

foo.poptrox({preload:false,// If true, preload fullsize images in// the backgroundbaseZIndex:1000,// Base Z-IndexfadeSpeed:300,// Global fade speedoverlayColor:'#000000',// Overlay coloroverlayOpacity:0.6,// Overlay opacitywindowMargin:50,// Window margin size (in pixels; only comes into// play when an image is larger than the viewport)windowHeightPad:0,// Window height padselector:'a',// Anchor tag selectorcaption:null,// Caption settings (see docs)popupSpeed:300,// Popup (resize) speedpopupWidth:200,// Popup widthpopupHeight:100,// Popup heightpopupIsFixed:false,// If true, popup won't resize to fit imagesuseBodyOverflow:true,// If true, the BODY tag is set to overflow: hidden// when the popup is visibleusePopupEasyClose:true,// If true, popup can be closed by clicking on// it anywhereusePopupForceClose:false,// If true, popup can be closed even while content// is loadingusePopupLoader:true,// If true, show the popup loaderusePopupCloser:true,// If true, show the popup closer button/linkusePopupCaption:false,// If true, show the popup image captionusePopupNav:false,// If true, show (and use) popup navigationusePopupDefaultStyling:true,// If true, default popup styling will be applied// (background color, text color, etc)popupBackgroundColor:'#FFFFFF',// (Default Style) Popup background color (when// usePopupStyling = true)popupTextColor:'#000000',// (Default Style) Popup text color (when// usePopupStyling = true)popupLoaderTextSize:'2em',// (Default Style) Popup loader text sizepopupCloserBackgroundColor:'#000000',// (Default Style) Popup closer background color// (when usePopupStyling = true)popupCloserTextColor:'#FFFFFF',// (Default Style) Popup closer text color (when// usePopupStyling = true)popupCloserTextSize:'20px',// (Default Style) Popup closer text sizepopupPadding:10,// (Default Style) Popup padding (when// usePopupStyling = true)popupCaptionHeight:60,// (Default Style) Popup height of caption areapopupCaptionTextSize:null,// (Default Style) Popup caption text sizepopupBlankCaptionText:'(untitled)',// Applied to images that don't have captions// (when captions are enabled)popupCloserText:'&#215;',// Popup closer textpopupLoaderText:'&bull;&bull;',// Popup loader textpopupClass:'poptrox-popup',// Popup classpopupSelector:null,// (Advanced) Popup selector (use this if you// want to replace the built-in popup)popupLoaderSelector:'.loader',// (Advanced) Popup Loader selectorpopupCloserSelector:'.closer',// (Advanced) Popup Closer selectorpopupCaptionSelector:'.caption',// (Advanced) Popup Caption selectorpopupNavPreviousSelector:'.nav-previous',// (Advanced) Popup Nav Previous selectorpopupNavNextSelector:'.nav-next',// (Advanced) Popup Nav Next selectoronPopupClose:null,// Called when popup closesonPopupOpen:null// Called when popup opens});

License

jquery.poptrox.js is released under the MIT license.

Copyright © n33

Permission is hereby granted, free of charge, to any person obtaining acopy of this software and associated documentation files (the"Software"), to deal in the Software without restriction, includingwithout limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and topermit persons to whom the Software is furnished to do so, subject tothe following conditions:

The above copyright notice and this permission notice shall be includedin all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANYCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THESOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A lightbox gallery plugin for jQuery

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp