lightbox.csslightbox.js のデフォルトのソースコード(Lightbox v2.51)
lightbox.css(全部)

1	/* line 6, ../sass/lightbox.sass */
2	#lightboxOverlay {
3	  position: absolute;
4	  top: 0;
5	  left: 0;
6	  z-index: 9999;
7	  background-color: black;
8	  filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=85);
9	  opacity: 0.85;
10	  display: none;
11	}
12	
13	/* line 15, ../sass/lightbox.sass */
14	#lightbox {
15	  position: absolute;
16	  left: 0;
17	  width: 100%;
18	  z-index: 10000;
19	  text-align: center;
20	  line-height: 0;
21	  font-family: "lucida grande", tahoma, verdana, arial, sans-serif;
22	  font-weight: normal;
23	}
24	/* line 24, ../sass/lightbox.sass */
25	#lightbox img {
26	  width: auto;
27	  height: auto;
28	}
29	/* line 27, ../sass/lightbox.sass */
30	#lightbox a img {
31	  border: none;
32	}
33	
34	/* line 30, ../sass/lightbox.sass */
35	.lb-outerContainer {
36	  position: relative;
37	  background-color: white;
38	  *zoom: 1;
39	  width: 250px;
40	  height: 250px;
41	  margin: 0 auto;
42	  -webkit-border-radius: 4px;
43	  -moz-border-radius: 4px;
44	  -ms-border-radius: 4px;
45	  -o-border-radius: 4px;
46	  border-radius: 4px;
47	}
48	/* line 38, ../../../../.rvm/gems/ruby-1.9.2-p290/gems/compass-0.12.1/frameworks/compass/stylesheets/compass/utilities/general/_clearfix.scss */
49	.lb-outerContainer:after {
50	  content: "";
51	  display: table;
52	  clear: both;
53	}
54	
55	/* line 39, ../sass/lightbox.sass */
56	.lb-container {
57	  padding: 10px;
58	}
59	
60	/* line 42, ../sass/lightbox.sass */
61	.lb-loader {
62	  position: absolute;
63	  top: 40%;
64	  left: 0%;
65	  height: 25%;
66	  width: 100%;
67	  text-align: center;
68	  line-height: 0;
69	}
70	
71	/* line 51, ../sass/lightbox.sass */
72	.lb-nav {
73	  position: absolute;
74	  top: 0;
75	  left: 0;
76	  height: 100%;
77	  width: 100%;
78	  z-index: 10;
79	}
80	
81	/* line 59, ../sass/lightbox.sass */
82	.lb-container > .nav {
83	  left: 0;
84	}
85	
86	/* line 62, ../sass/lightbox.sass */
87	.lb-nav a {
88	  outline: none;
89	}
90	
91	/* line 65, ../sass/lightbox.sass */
92	.lb-prev, .lb-next {
93	  width: 49%;
94	  height: 100%;
95	  background-image: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7");
96	  /* Trick IE into showing hover */
97	  display: block;
98	}
99	
100	/* line 72, ../sass/lightbox.sass */
101	.lb-prev {
102	  left: 0;
103	  float: left;
104	}
105	
106	/* line 76, ../sass/lightbox.sass */
107	.lb-next {
108	  right: 0;
109	  float: right;
110	}
111	
112	/* line 81, ../sass/lightbox.sass */
113	.lb-prev:hover {
114	  background: url(../images/prev.png) left 48% no-repeat;
115	}
116	
117	/* line 85, ../sass/lightbox.sass */
118	.lb-next:hover {
119	  background: url(../images/next.png) right 48% no-repeat;
120	}
121	
122	/* line 88, ../sass/lightbox.sass */
123	.lb-dataContainer {
124	  margin: 0 auto;
125	  padding-top: 5px;
126	  *zoom: 1;
127	  width: 100%;
128	  -moz-border-radius-bottomleft: 4px;
129	  -webkit-border-bottom-left-radius: 4px;
130	  -ms-border-bottom-left-radius: 4px;
131	  -o-border-bottom-left-radius: 4px;
132	  border-bottom-left-radius: 4px;
133	  -moz-border-radius-bottomright: 4px;
134	  -webkit-border-bottom-right-radius: 4px;
135	  -ms-border-bottom-right-radius: 4px;
136	  -o-border-bottom-right-radius: 4px;
137	  border-bottom-right-radius: 4px;
138	}
139	/* line 38, ../../../../.rvm/gems/ruby-1.9.2-p290/gems/compass-0.12.1/frameworks/compass/stylesheets/compass/utilities/general/_clearfix.scss */
140	.lb-dataContainer:after {
141	  content: "";
142	  display: table;
143	  clear: both;
144	}
145	
146	/* line 95, ../sass/lightbox.sass */
147	.lb-data {
148	  padding: 0 10px;
149	  color: #bbbbbb;
150	}
151	/* line 98, ../sass/lightbox.sass */
152	.lb-data .lb-details {
153	  width: 85%;
154	  float: left;
155	  text-align: left;
156	  line-height: 1.1em;
157	}
158	/* line 103, ../sass/lightbox.sass */
159	.lb-data .lb-caption {
160	  font-size: 13px;
161	  font-weight: bold;
162	  line-height: 1em;
163	}
164	/* line 107, ../sass/lightbox.sass */
165	.lb-data .lb-number {
166	  display: block;
167	  clear: left;
168	  padding-bottom: 1em;
169	  font-size: 11px;
170	}
171	/* line 112, ../sass/lightbox.sass */
172	.lb-data .lb-close {
173	  width: 35px;
174	  float: right;
175	  padding-bottom: 0.7em;
176	  outline: none;
177	}
178	/* line 117, ../sass/lightbox.sass */
179	.lb-data .lb-close:hover {
180	  cursor: pointer;
181	}
		}
lightbox.js(全部)
1	
2	/*
3	Lightbox v2.51
4	by Lokesh Dhakar - http://www.lokeshdhakar.com
5	
6	For more information, visit:
7	http://lokeshdhakar.com/projects/lightbox2/
8	
9	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
10	#NAME?
11	#NAME?
12	
13	Thanks
14	#NAME?
15	#NAME?
16	
17	
18	Table of Contents
19	=================
20	LightboxOptions
21	
22	Lightbox
23	#NAME?
24	#NAME?
25	#NAME?
26	#NAME?
27	#NAME?
28	#NAME?
29	#NAME?
30	#NAME?
31	#NAME?
32	#NAME?
33	#NAME?
34	#NAME?
35	#NAME?
36	#NAME?
37	#NAME?
38	
39	options = new LightboxOptions
40	lightbox = new Lightbox options
41	*/
42	
43	(function() {
44	  var $, Lightbox, LightboxOptions;
45	
46	  $ = jQuery;
47	
48	  LightboxOptions = (function() {
49	
50	    function LightboxOptions() {
51	      this.fileLoadingImage = 'images/loading.gif';
52	      this.fileCloseImage = 'images/close.png';
53	      this.resizeDuration = 700;
54	      this.fadeDuration = 500;
55	      this.labelImage = "Image";
56	      this.labelOf = "of";
57	    }
58	
59	    return LightboxOptions;
60	
61	  })();
62	
63	  Lightbox = (function() {
64	
65	    function Lightbox(options) {
66	      this.options = options;
67	      this.album = [];
68	      this.currentImageIndex = void 0;
69	      this.init();
70	    }
71	
72	    Lightbox.prototype.init = function() {
73	      this.enable();
74	      return this.build();
75	    };
76	
77	    Lightbox.prototype.enable = function() {
78	      var _this = this;
79	      return $('body').on('click', 'a[rel^=lightbox], area[rel^=lightbox]', function(e) {
80	        _this.start($(e.currentTarget));
81	        return false;
82	      });
83	    };
84	
85	    Lightbox.prototype.build = function() {
86	      var $lightbox,
87	        _this = this;
88	      $("
", { 89 id: 'lightboxOverlay' 90 }).after($('
', { 91 id: 'lightbox' 92 }).append($('
', { 93 "class": 'lb-outerContainer' 94 }).append($('
', { 95 "class": 'lb-container' 96 }).append($('', { 97 "class": 'lb-image' 98 }), $('
', { 99 "class": 'lb-nav' 100 }).append($('', { 101 "class": 'lb-prev' 102 }), $('', { 103 "class": 'lb-next' 104 })), $('
', { 105 "class": 'lb-loader' 106 }).append($('', { 107 "class": 'lb-cancel' 108 }).append($('', { 109 src: this.options.fileLoadingImage 110 }))))), $('
', { 111 "class": 'lb-dataContainer' 112 }).append($('
', { 113 "class": 'lb-data' 114 }).append($('
', { 115 "class": 'lb-details' 116 }).append($('', { 117 "class": 'lb-caption' 118 }), $('', { 119 "class": 'lb-number' 120 })), $('
', { 121 "class": 'lb-closeContainer' 122 }).append($('', { 123 "class": 'lb-close' 124 }).append($('', { 125 src: this.options.fileCloseImage 126 }))))))).appendTo($('body')); 127 $('#lightboxOverlay').hide().on('click', function(e) { 128 _this.end(); 129 return false; 130 }); 131 $lightbox = $('#lightbox'); 132 $lightbox.hide().on('click', function(e) { 133 if ($(e.target).attr('id') === 'lightbox') _this.end(); 134 return false; 135 }); 136 $lightbox.find('.lb-outerContainer').on('click', function(e) { 137 if ($(e.target).attr('id') === 'lightbox') _this.end(); 138 return false; 139 }); 140 $lightbox.find('.lb-prev').on('click', function(e) { 141 _this.changeImage(_this.currentImageIndex - 1); 142 return false; 143 }); 144 $lightbox.find('.lb-next').on('click', function(e) { 145 _this.changeImage(_this.currentImageIndex + 1); 146 return false; 147 }); 148 $lightbox.find('.lb-loader, .lb-close').on('click', function(e) { 149 _this.end(); 150 return false; 151 }); 152 }; 153 154 Lightbox.prototype.start = function($link) { 155 var $lightbox, $window, a, i, imageNumber, left, top, _len, _ref; 156 $(window).on("resize", this.sizeOverlay); 157 $('select, object, embed').css({ 158 visibility: "hidden" 159 }); 160 $('#lightboxOverlay').width($(document).width()).height($(document).height()).fadeIn(this.options.fadeDuration); 161 this.album = []; 162 imageNumber = 0; 163 if ($link.attr('rel') === 'lightbox') { 164 this.album.push({ 165 link: $link.attr('href'), 166 title: $link.attr('title') 167 }); 168 } else { 169 _ref = $($link.prop("tagName") + '[rel="' + $link.attr('rel') + '"]'); 170 for (i = 0, _len = _ref.length; i < _len; i++) { 171 a = _ref[i]; 172 this.album.push({ 173 link: $(a).attr('href'), 174 title: $(a).attr('title') 175 }); 176 if ($(a).attr('href') === $link.attr('href')) imageNumber = i; 177 } 178 } 179 $window = $(window); 180 top = $window.scrollTop() + $window.height() / 10; 181 left = $window.scrollLeft(); 182 $lightbox = $('#lightbox'); 183 $lightbox.css({ 184 top: top + 'px', 185 left: left + 'px' 186 }).fadeIn(this.options.fadeDuration); 187 this.changeImage(imageNumber); 188 }; 189 190 Lightbox.prototype.changeImage = function(imageNumber) { 191 var $image, $lightbox, preloader, 192 _this = this; 193 this.disableKeyboardNav(); 194 $lightbox = $('#lightbox'); 195 $image = $lightbox.find('.lb-image'); 196 this.sizeOverlay(); 197 $('#lightboxOverlay').fadeIn(this.options.fadeDuration); 198 $('.loader').fadeIn('slow'); 199 $lightbox.find('.lb-image, .lb-nav, .lb-prev, .lb-next, .lb-dataContainer, .lb-numbers, .lb-caption').hide(); 200 $lightbox.find('.lb-outerContainer').addClass('animating'); 201 preloader = new Image; 202 preloader.onload = function() { 203 $image.attr('src', _this.album[imageNumber].link); 204 $image.width = preloader.width; 205 $image.height = preloader.height; 206 return _this.sizeContainer(preloader.width, preloader.height); 207 }; 208 preloader.src = this.album[imageNumber].link; 209 this.currentImageIndex = imageNumber; 210 }; 211 212 Lightbox.prototype.sizeOverlay = function() { 213 return $('#lightboxOverlay').width($(document).width()).height($(document).height()); 214 }; 215 216 Lightbox.prototype.sizeContainer = function(imageWidth, imageHeight) { 217 var $container, $lightbox, $outerContainer, containerBottomPadding, containerLeftPadding, containerRightPadding, containerTopPadding, newHeight, newWidth, oldHeight, oldWidth, 218 _this = this; 219 $lightbox = $('#lightbox'); 220 $outerContainer = $lightbox.find('.lb-outerContainer'); 221 oldWidth = $outerContainer.outerWidth(); 222 oldHeight = $outerContainer.outerHeight(); 223 $container = $lightbox.find('.lb-container'); 224 containerTopPadding = parseInt($container.css('padding-top'), 10); 225 containerRightPadding = parseInt($container.css('padding-right'), 10); 226 containerBottomPadding = parseInt($container.css('padding-bottom'), 10); 227 containerLeftPadding = parseInt($container.css('padding-left'), 10); 228 newWidth = imageWidth + containerLeftPadding + containerRightPadding; 229 newHeight = imageHeight + containerTopPadding + containerBottomPadding; 230 if (newWidth !== oldWidth && newHeight !== oldHeight) { 231 $outerContainer.animate({ 232 width: newWidth, 233 height: newHeight 234 }, this.options.resizeDuration, 'swing'); 235 } else if (newWidth !== oldWidth) { 236 $outerContainer.animate({ 237 width: newWidth 238 }, this.options.resizeDuration, 'swing'); 239 } else if (newHeight !== oldHeight) { 240 $outerContainer.animate({ 241 height: newHeight 242 }, this.options.resizeDuration, 'swing'); 243 } 244 setTimeout(function() { 245 $lightbox.find('.lb-dataContainer').width(newWidth); 246 $lightbox.find('.lb-prevLink').height(newHeight); 247 $lightbox.find('.lb-nextLink').height(newHeight); 248 _this.showImage(); 249 }, this.options.resizeDuration); 250 }; 251 252 Lightbox.prototype.showImage = function() { 253 var $lightbox; 254 $lightbox = $('#lightbox'); 255 $lightbox.find('.lb-loader').hide(); 256 $lightbox.find('.lb-image').fadeIn('slow'); 257 this.updateNav(); 258 this.updateDetails(); 259 this.preloadNeighboringImages(); 260 this.enableKeyboardNav(); 261 }; 262 263 Lightbox.prototype.updateNav = function() { 264 var $lightbox; 265 $lightbox = $('#lightbox'); 266 $lightbox.find('.lb-nav').show(); 267 if (this.currentImageIndex > 0) $lightbox.find('.lb-prev').show(); 268 if (this.currentImageIndex < this.album.length - 1) { 269 $lightbox.find('.lb-next').show(); 270 } 271 }; 272 273 Lightbox.prototype.updateDetails = function() { 274 var $lightbox, 275 _this = this; 276 $lightbox = $('#lightbox'); 277 if (typeof this.album[this.currentImageIndex].title !== 'undefined' && this.album[this.currentImageIndex].title !== "") { 278 $lightbox.find('.lb-caption').html(this.album[this.currentImageIndex].title).fadeIn('fast'); 279 } 280 if (this.album.length > 1) { 281 $lightbox.find('.lb-number').html(this.options.labelImage + ' ' + (this.currentImageIndex + 1) + ' ' + this.options.labelOf + ' ' + this.album.length).fadeIn('fast'); 282 } else { 283 $lightbox.find('.lb-number').hide(); 284 } 285 $lightbox.find('.lb-outerContainer').removeClass('animating'); 286 $lightbox.find('.lb-dataContainer').fadeIn(this.resizeDuration, function() { 287 return _this.sizeOverlay(); 288 }); 289 }; 290 291 Lightbox.prototype.preloadNeighboringImages = function() { 292 var preloadNext, preloadPrev; 293 if (this.album.length > this.currentImageIndex + 1) { 294 preloadNext = new Image; 295 preloadNext.src = this.album[this.currentImageIndex + 1].link; 296 } 297 if (this.currentImageIndex > 0) { 298 preloadPrev = new Image; 299 preloadPrev.src = this.album[this.currentImageIndex - 1].link; 300 } 301 }; 302 303 Lightbox.prototype.enableKeyboardNav = function() { 304 $(document).on('keyup.keyboard', $.proxy(this.keyboardAction, this)); 305 }; 306 307 Lightbox.prototype.disableKeyboardNav = function() { 308 $(document).off('.keyboard'); 309 }; 310 311 Lightbox.prototype.keyboardAction = function(event) { 312 var KEYCODE_ESC, KEYCODE_LEFTARROW, KEYCODE_RIGHTARROW, key, keycode; 313 KEYCODE_ESC = 27; 314 KEYCODE_LEFTARROW = 37; 315 KEYCODE_RIGHTARROW = 39; 316 keycode = event.keyCode; 317 key = String.fromCharCode(keycode).toLowerCase(); 318 if (keycode === KEYCODE_ESC || key.match(/x|o|c/)) { 319 this.end(); 320 } else if (key === 'p' || keycode === KEYCODE_LEFTARROW) { 321 if (this.currentImageIndex !== 0) { 322 this.changeImage(this.currentImageIndex - 1); 323 } 324 } else if (key === 'n' || keycode === KEYCODE_RIGHTARROW) { 325 if (this.currentImageIndex !== this.album.length - 1) { 326 this.changeImage(this.currentImageIndex + 1); 327 } 328 } 329 }; 330 331 Lightbox.prototype.end = function() { 332 this.disableKeyboardNav(); 333 $(window).off("resize", this.sizeOverlay); 334 $('#lightbox').fadeOut(this.options.fadeDuration); 335 $('#lightboxOverlay').fadeOut(this.options.fadeDuration); 336 return $('select, object, embed').css({ 337 visibility: "visible" 338 }); 339 }; 340 341 return Lightbox; 342 343 })(); 344 345 $(function() { 346 var lightbox, options; 347 options = new LightboxOptions; 348 return lightbox = new Lightbox(options); 349 }); 350 351 }).call(this);