lightbox-bootstrap-rails 3.3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 996cdc837c4763be517172f32528ce7ce9776d48
4
+ data.tar.gz: 789d65b42dd66b36e218b994eddbfd46771216a0
5
+ SHA512:
6
+ metadata.gz: 37c220bcb6266c29f38a39c35055f1333c2f1f4efb4ae4f224b7c4f92de6a79df0571d603db293cca85fd5ec7b6c61b8e48e6f08218665611049233ce1211a8b
7
+ data.tar.gz: f5aa3b883799920c447fd90f25c9ad2c2aa838ce4d6fd9511497340d912350aed3a1bef2ba73a318f5d8153ff946db8110d7352780f15ce460ba636511dbcd72
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Hyo Seong Choi
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,67 @@
1
+ # Lightbox for Bootstrap 3
2
+
3
+ This gem was built for the use of 'Lightbox for Bootstrap 3' as Rails assets pipeline and you can look for the detailed documents at http://ashleydw.github.io/lightbox/
4
+
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'lightbox-bootstrap-rails'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install lightbox-bootstrap-rails
21
+
22
+ ## Usage
23
+
24
+ in assets/javascripts/application.js
25
+
26
+ ```
27
+ //= ...
28
+ //= require lightbox-bootstrap
29
+ //= ...
30
+ ```
31
+
32
+ in assets/stylesheets/application.scss
33
+
34
+ ```
35
+ ...
36
+ @import "bootstrap-sprockets";
37
+ @import "bootstrap";
38
+ @import "lightbox-bootstrap/rails"
39
+ ...
40
+ ```
41
+
42
+ Finally, you should add `assets/stylesheets/lightbox_bootstraped.coffee` as follows:
43
+
44
+ ```
45
+ $(document).delegate '*[data-toggle="lightbox"]', 'click', (event) ->
46
+ event.preventDefault()
47
+ $(this).ekkoLightbox()
48
+ return
49
+ ```
50
+
51
+ ## Test Application
52
+
53
+ Among the gem sources, a test application is provided and there you can find how to code in the wild.
54
+
55
+ # Changelog
56
+
57
+ -v 3.3.0.0 : initially created.
58
+ -v 3.3.0.1 : deployed to Rubygems.org
59
+
60
+
61
+ ## Contributing
62
+
63
+ 1. Fork it ( https://github.com/[my-github-username]/lightbox-bootstrap-rails/fork )
64
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
65
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
66
+ 4. Push to the branch (`git push origin my-new-feature`)
67
+ 5. Create a new Pull Request
@@ -0,0 +1,10 @@
1
+ require "lightbox/bootstrap/rails/version"
2
+
3
+ module Lightbox
4
+ module Bootstrap
5
+ module Rails
6
+ class Engine < ::Rails::Engine
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ module Lightbox
2
+ module Bootstrap
3
+ module Rails
4
+ VERSION = "3.3.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,398 @@
1
+ /*
2
+ Lightbox for Bootstrap 3 by @ashleydw
3
+ https://github.com/ashleydw/lightbox
4
+
5
+ License: https://github.com/ashleydw/lightbox/blob/master/LICENSE
6
+ */
7
+
8
+
9
+ (function() {
10
+ "use strict";
11
+ var $, EkkoLightbox;
12
+
13
+ $ = jQuery;
14
+
15
+ EkkoLightbox = function(element, options) {
16
+ var content, footer, header,
17
+ _this = this;
18
+ this.options = $.extend({
19
+ title: null,
20
+ footer: null,
21
+ remote: null
22
+ }, $.fn.ekkoLightbox.defaults, options || {});
23
+ this.$element = $(element);
24
+ content = '';
25
+ this.modal_id = this.options.modal_id ? this.options.modal_id : 'ekkoLightbox-' + Math.floor((Math.random() * 1000) + 1);
26
+ header = '<div class="modal-header"' + (this.options.title || this.options.always_show_close ? '' : ' style="display:none"') + '><button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button><h4 class="modal-title">' + (this.options.title || "&nbsp;") + '</h4></div>';
27
+ footer = '<div class="modal-footer"' + (this.options.footer ? '' : ' style="display:none"') + '>' + this.options.footer + '</div>';
28
+ $(document.body).append('<div id="' + this.modal_id + '" class="ekko-lightbox modal fade" tabindex="-1"><div class="modal-dialog"><div class="modal-content">' + header + '<div class="modal-body"><div class="ekko-lightbox-container"><div></div></div></div>' + footer + '</div></div></div>');
29
+ this.modal = $('#' + this.modal_id);
30
+ this.modal_dialog = this.modal.find('.modal-dialog').first();
31
+ this.modal_content = this.modal.find('.modal-content').first();
32
+ this.modal_body = this.modal.find('.modal-body').first();
33
+ this.lightbox_container = this.modal_body.find('.ekko-lightbox-container').first();
34
+ this.lightbox_body = this.lightbox_container.find('> div:first-child').first();
35
+ this.showLoading();
36
+ this.modal_arrows = null;
37
+ this.border = {
38
+ top: parseFloat(this.modal_dialog.css('border-top-width')) + parseFloat(this.modal_content.css('border-top-width')) + parseFloat(this.modal_body.css('border-top-width')),
39
+ right: parseFloat(this.modal_dialog.css('border-right-width')) + parseFloat(this.modal_content.css('border-right-width')) + parseFloat(this.modal_body.css('border-right-width')),
40
+ bottom: parseFloat(this.modal_dialog.css('border-bottom-width')) + parseFloat(this.modal_content.css('border-bottom-width')) + parseFloat(this.modal_body.css('border-bottom-width')),
41
+ left: parseFloat(this.modal_dialog.css('border-left-width')) + parseFloat(this.modal_content.css('border-left-width')) + parseFloat(this.modal_body.css('border-left-width'))
42
+ };
43
+ this.padding = {
44
+ top: parseFloat(this.modal_dialog.css('padding-top')) + parseFloat(this.modal_content.css('padding-top')) + parseFloat(this.modal_body.css('padding-top')),
45
+ right: parseFloat(this.modal_dialog.css('padding-right')) + parseFloat(this.modal_content.css('padding-right')) + parseFloat(this.modal_body.css('padding-right')),
46
+ bottom: parseFloat(this.modal_dialog.css('padding-bottom')) + parseFloat(this.modal_content.css('padding-bottom')) + parseFloat(this.modal_body.css('padding-bottom')),
47
+ left: parseFloat(this.modal_dialog.css('padding-left')) + parseFloat(this.modal_content.css('padding-left')) + parseFloat(this.modal_body.css('padding-left'))
48
+ };
49
+ this.modal.on('show.bs.modal', this.options.onShow.bind(this)).on('shown.bs.modal', function() {
50
+ _this.modal_shown();
51
+ return _this.options.onShown.call(_this);
52
+ }).on('hide.bs.modal', this.options.onHide.bind(this)).on('hidden.bs.modal', function() {
53
+ if (_this.gallery) {
54
+ $(document).off('keydown.ekkoLightbox');
55
+ }
56
+ _this.modal.remove();
57
+ return _this.options.onHidden.call(_this);
58
+ }).modal('show', options);
59
+ return this.modal;
60
+ };
61
+
62
+ EkkoLightbox.prototype = {
63
+ modal_shown: function() {
64
+ var video_id,
65
+ _this = this;
66
+ if (!this.options.remote) {
67
+ return this.error('No remote target given');
68
+ } else {
69
+ this.gallery = this.$element.data('gallery');
70
+ if (this.gallery) {
71
+ if (this.options.gallery_parent_selector === 'document.body' || this.options.gallery_parent_selector === '') {
72
+ this.gallery_items = $(document.body).find('*[data-toggle="lightbox"][data-gallery="' + this.gallery + '"]');
73
+ } else {
74
+ this.gallery_items = this.$element.parents(this.options.gallery_parent_selector).first().find('*[data-toggle="lightbox"][data-gallery="' + this.gallery + '"]');
75
+ }
76
+ this.gallery_index = this.gallery_items.index(this.$element);
77
+ $(document).on('keydown.ekkoLightbox', this.navigate.bind(this));
78
+ if (this.options.directional_arrows && this.gallery_items.length > 1) {
79
+ this.lightbox_container.append('<div class="ekko-lightbox-nav-overlay"><a href="#" class="' + this.strip_stops(this.options.left_arrow_class) + '"></a><a href="#" class="' + this.strip_stops(this.options.right_arrow_class) + '"></a></div>');
80
+ this.modal_arrows = this.lightbox_container.find('div.ekko-lightbox-nav-overlay').first();
81
+ this.lightbox_container.find('a' + this.strip_spaces(this.options.left_arrow_class)).on('click', function(event) {
82
+ event.preventDefault();
83
+ return _this.navigate_left();
84
+ });
85
+ this.lightbox_container.find('a' + this.strip_spaces(this.options.right_arrow_class)).on('click', function(event) {
86
+ event.preventDefault();
87
+ return _this.navigate_right();
88
+ });
89
+ }
90
+ }
91
+ if (this.options.type) {
92
+ if (this.options.type === 'image') {
93
+ return this.preloadImage(this.options.remote, true);
94
+ } else if (this.options.type === 'youtube' && (video_id = this.getYoutubeId(this.options.remote))) {
95
+ return this.showYoutubeVideo(video_id);
96
+ } else if (this.options.type === 'vimeo') {
97
+ return this.showVimeoVideo(this.options.remote);
98
+ } else if (this.options.type === 'instagram') {
99
+ return this.showInstagramVideo(this.options.remote);
100
+ } else if (this.options.type === 'url') {
101
+ return this.loadRemoteContent(this.options.remote);
102
+ } else if (this.options.type === 'video') {
103
+ return this.showVideoIframe(this.options.remote);
104
+ } else {
105
+ return this.error("Could not detect remote target type. Force the type using data-type=\"image|youtube|vimeo|instagram|url|video\"");
106
+ }
107
+ } else {
108
+ return this.detectRemoteType(this.options.remote);
109
+ }
110
+ }
111
+ },
112
+ strip_stops: function(str) {
113
+ return str.replace(/\./g, '');
114
+ },
115
+ strip_spaces: function(str) {
116
+ return str.replace(/\s/g, '');
117
+ },
118
+ isImage: function(str) {
119
+ return str.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i);
120
+ },
121
+ isSwf: function(str) {
122
+ return str.match(/\.(swf)((\?|#).*)?$/i);
123
+ },
124
+ getYoutubeId: function(str) {
125
+ var match;
126
+ match = str.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/);
127
+ if (match && match[2].length === 11) {
128
+ return match[2];
129
+ } else {
130
+ return false;
131
+ }
132
+ },
133
+ getVimeoId: function(str) {
134
+ if (str.indexOf('vimeo') > 0) {
135
+ return str;
136
+ } else {
137
+ return false;
138
+ }
139
+ },
140
+ getInstagramId: function(str) {
141
+ if (str.indexOf('instagram') > 0) {
142
+ return str;
143
+ } else {
144
+ return false;
145
+ }
146
+ },
147
+ navigate: function(event) {
148
+ event = event || window.event;
149
+ if (event.keyCode === 39 || event.keyCode === 37) {
150
+ if (event.keyCode === 39) {
151
+ return this.navigate_right();
152
+ } else if (event.keyCode === 37) {
153
+ return this.navigate_left();
154
+ }
155
+ }
156
+ },
157
+ navigateTo: function(index) {
158
+ var next, src;
159
+ if (index < 0 || index > this.gallery_items.length - 1) {
160
+ return this;
161
+ }
162
+ this.showLoading();
163
+ this.gallery_index = index;
164
+ this.$element = $(this.gallery_items.get(this.gallery_index));
165
+ this.updateTitleAndFooter();
166
+ src = this.$element.attr('data-remote') || this.$element.attr('href');
167
+ this.detectRemoteType(src, this.$element.attr('data-type') || false);
168
+ if (this.gallery_index + 1 < this.gallery_items.length) {
169
+ next = $(this.gallery_items.get(this.gallery_index + 1), false);
170
+ src = next.attr('data-remote') || next.attr('href');
171
+ if (next.attr('data-type') === 'image' || this.isImage(src)) {
172
+ return this.preloadImage(src, false);
173
+ }
174
+ }
175
+ },
176
+ navigate_left: function() {
177
+ if (this.gallery_items.length === 1) {
178
+ return;
179
+ }
180
+ if (this.gallery_index === 0) {
181
+ this.gallery_index = this.gallery_items.length - 1;
182
+ } else {
183
+ this.gallery_index--;
184
+ }
185
+ this.options.onNavigate.call(this, 'left', this.gallery_index);
186
+ return this.navigateTo(this.gallery_index);
187
+ },
188
+ navigate_right: function() {
189
+ if (this.gallery_items.length === 1) {
190
+ return;
191
+ }
192
+ if (this.gallery_index === this.gallery_items.length - 1) {
193
+ this.gallery_index = 0;
194
+ } else {
195
+ this.gallery_index++;
196
+ }
197
+ this.options.onNavigate.call(this, 'right', this.gallery_index);
198
+ return this.navigateTo(this.gallery_index);
199
+ },
200
+ detectRemoteType: function(src, type) {
201
+ var video_id;
202
+ type = type || false;
203
+ if (type === 'image' || this.isImage(src)) {
204
+ this.options.type = 'image';
205
+ return this.preloadImage(src, true);
206
+ } else if (type === 'youtube' || (video_id = this.getYoutubeId(src))) {
207
+ this.options.type = 'youtube';
208
+ return this.showYoutubeVideo(video_id);
209
+ } else if (type === 'vimeo' || (video_id = this.getVimeoId(src))) {
210
+ this.options.type = 'vimeo';
211
+ return this.showVimeoVideo(video_id);
212
+ } else if (type === 'instagram' || (video_id = this.getInstagramId(src))) {
213
+ this.options.type = 'instagram';
214
+ return this.showInstagramVideo(video_id);
215
+ } else if (type === 'video') {
216
+ this.options.type = 'video';
217
+ return this.showVideoIframe(video_id);
218
+ } else {
219
+ this.options.type = 'url';
220
+ return this.loadRemoteContent(src);
221
+ }
222
+ },
223
+ updateTitleAndFooter: function() {
224
+ var caption, footer, header, title;
225
+ header = this.modal_content.find('.modal-header');
226
+ footer = this.modal_content.find('.modal-footer');
227
+ title = this.$element.data('title') || "";
228
+ caption = this.$element.data('footer') || "";
229
+ if (title || this.options.always_show_close) {
230
+ header.css('display', '').find('.modal-title').html(title || "&nbsp;");
231
+ } else {
232
+ header.css('display', 'none');
233
+ }
234
+ if (caption) {
235
+ footer.css('display', '').html(caption);
236
+ } else {
237
+ footer.css('display', 'none');
238
+ }
239
+ return this;
240
+ },
241
+ showLoading: function() {
242
+ this.lightbox_body.html('<div class="modal-loading">' + this.options.loadingMessage + '</div>');
243
+ return this;
244
+ },
245
+ showYoutubeVideo: function(id) {
246
+ var height, width;
247
+ width = this.checkDimensions(this.$element.data('width') || 560);
248
+ height = width / (560 / 315);
249
+ return this.showVideoIframe('//www.youtube.com/embed/' + id + '?badge=0&autoplay=1&html5=1', width, height);
250
+ },
251
+ showVimeoVideo: function(id) {
252
+ var height, width;
253
+ width = this.checkDimensions(this.$element.data('width') || 560);
254
+ height = width / (500 / 281);
255
+ return this.showVideoIframe(id + '?autoplay=1', width, height);
256
+ },
257
+ showInstagramVideo: function(id) {
258
+ var height, width;
259
+ width = this.checkDimensions(this.$element.data('width') || 612);
260
+ this.resize(width);
261
+ height = width + 80;
262
+ this.lightbox_body.html('<iframe width="' + width + '" height="' + height + '" src="' + this.addTrailingSlash(id) + 'embed/" frameborder="0" allowfullscreen></iframe>');
263
+ this.options.onContentLoaded.call(this);
264
+ if (this.modal_arrows) {
265
+ return this.modal_arrows.css('display', 'none');
266
+ }
267
+ },
268
+ showVideoIframe: function(url, width, height) {
269
+ height = height || width;
270
+ this.resize(width);
271
+ this.lightbox_body.html('<div class="embed-responsive embed-responsive-16by9"><iframe width="' + width + '" height="' + height + '" src="' + url + '" frameborder="0" allowfullscreenclass="embed-responsive-item"></iframe></div>');
272
+ this.options.onContentLoaded.call(this);
273
+ if (this.modal_arrows) {
274
+ this.modal_arrows.css('display', 'none');
275
+ }
276
+ return this;
277
+ },
278
+ loadRemoteContent: function(url) {
279
+ var disableExternalCheck, width,
280
+ _this = this;
281
+ width = this.$element.data('width') || 560;
282
+ this.resize(width);
283
+ disableExternalCheck = this.$element.data('disableExternalCheck') || false;
284
+ if (!disableExternalCheck && !this.isExternal(url)) {
285
+ this.lightbox_body.load(url, $.proxy(function() {
286
+ return _this.$element.trigger('loaded.bs.modal');
287
+ }));
288
+ } else {
289
+ this.lightbox_body.html('<iframe width="' + width + '" height="' + width + '" src="' + url + '" frameborder="0" allowfullscreen></iframe>');
290
+ this.options.onContentLoaded.call(this);
291
+ }
292
+ if (this.modal_arrows) {
293
+ this.modal_arrows.css('display', 'none');
294
+ }
295
+ return this;
296
+ },
297
+ isExternal: function(url) {
298
+ var match;
299
+ match = url.match(/^([^:\/?#]+:)?(?:\/\/([^\/?#]*))?([^?#]+)?(\?[^#]*)?(#.*)?/);
300
+ if (typeof match[1] === "string" && match[1].length > 0 && match[1].toLowerCase() !== location.protocol) {
301
+ return true;
302
+ }
303
+ if (typeof match[2] === "string" && match[2].length > 0 && match[2].replace(new RegExp(":(" + {
304
+ "http:": 80,
305
+ "https:": 443
306
+ }[location.protocol] + ")?$"), "") !== location.host) {
307
+ return true;
308
+ }
309
+ return false;
310
+ },
311
+ error: function(message) {
312
+ this.lightbox_body.html(message);
313
+ return this;
314
+ },
315
+ preloadImage: function(src, onLoadShowImage) {
316
+ var img,
317
+ _this = this;
318
+ img = new Image();
319
+ if ((onLoadShowImage == null) || onLoadShowImage === true) {
320
+ img.onload = function() {
321
+ var image;
322
+ image = $('<img />');
323
+ image.attr('src', img.src);
324
+ image.addClass('img-responsive');
325
+ _this.lightbox_body.html(image);
326
+ if (_this.modal_arrows) {
327
+ _this.modal_arrows.css('display', 'block');
328
+ }
329
+ _this.resize(img.width);
330
+ return _this.options.onContentLoaded.call(_this);
331
+ };
332
+ img.onerror = function() {
333
+ return _this.error('Failed to load image: ' + src);
334
+ };
335
+ }
336
+ img.src = src;
337
+ return img;
338
+ },
339
+ resize: function(width) {
340
+ var width_total;
341
+ width_total = width + this.border.left + this.padding.left + this.padding.right + this.border.right;
342
+ this.modal_dialog.css('width', 'auto').css('max-width', width_total);
343
+ this.lightbox_container.find('a').css('line-height', function() {
344
+ return $(this).parent().height() + 'px';
345
+ });
346
+ return this;
347
+ },
348
+ checkDimensions: function(width) {
349
+ var body_width, width_total;
350
+ width_total = width + this.border.left + this.padding.left + this.padding.right + this.border.right;
351
+ body_width = document.body.clientWidth;
352
+ if (width_total > body_width) {
353
+ width = this.modal_body.width();
354
+ }
355
+ return width;
356
+ },
357
+ close: function() {
358
+ return this.modal.modal('hide');
359
+ },
360
+ addTrailingSlash: function(url) {
361
+ if (url.substr(-1) !== '/') {
362
+ url += '/';
363
+ }
364
+ return url;
365
+ }
366
+ };
367
+
368
+ $.fn.ekkoLightbox = function(options) {
369
+ return this.each(function() {
370
+ var $this;
371
+ $this = $(this);
372
+ options = $.extend({
373
+ remote: $this.attr('data-remote') || $this.attr('href'),
374
+ gallery_parent_selector: $this.attr('data-parent'),
375
+ type: $this.attr('data-type')
376
+ }, options, $this.data());
377
+ new EkkoLightbox(this, options);
378
+ return this;
379
+ });
380
+ };
381
+
382
+ $.fn.ekkoLightbox.defaults = {
383
+ gallery_parent_selector: 'document.body',
384
+ left_arrow_class: '.glyphicon .glyphicon-chevron-left',
385
+ right_arrow_class: '.glyphicon .glyphicon-chevron-right',
386
+ directional_arrows: true,
387
+ type: null,
388
+ always_show_close: true,
389
+ loadingMessage: 'Loading...',
390
+ onShow: function() {},
391
+ onShown: function() {},
392
+ onHide: function() {},
393
+ onHidden: function() {},
394
+ onNavigate: function() {},
395
+ onContentLoaded: function() {}
396
+ };
397
+
398
+ }).call(this);
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * Lightbox for Bootstrap 3 by @ashleydw
3
+ * https://github.com/ashleydw/lightbox
4
+ *
5
+ * License: https://github.com/ashleydw/lightbox/blob/master/LICENSE
6
+ */
7
+ (function(){"use strict";var a,b;a=jQuery,b=function(b,c){var d,e,f,g=this;return this.options=a.extend({title:null,footer:null,remote:null},a.fn.ekkoLightbox.defaults,c||{}),this.$element=a(b),d="",this.modal_id=this.options.modal_id?this.options.modal_id:"ekkoLightbox-"+Math.floor(1e3*Math.random()+1),f='<div class="modal-header"'+(this.options.title||this.options.always_show_close?"":' style="display:none"')+'><button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button><h4 class="modal-title">'+(this.options.title||"&nbsp;")+"</h4></div>",e='<div class="modal-footer"'+(this.options.footer?"":' style="display:none"')+">"+this.options.footer+"</div>",a(document.body).append('<div id="'+this.modal_id+'" class="ekko-lightbox modal fade" tabindex="-1"><div class="modal-dialog"><div class="modal-content">'+f+'<div class="modal-body"><div class="ekko-lightbox-container"><div></div></div></div>'+e+"</div></div></div>"),this.modal=a("#"+this.modal_id),this.modal_dialog=this.modal.find(".modal-dialog").first(),this.modal_content=this.modal.find(".modal-content").first(),this.modal_body=this.modal.find(".modal-body").first(),this.lightbox_container=this.modal_body.find(".ekko-lightbox-container").first(),this.lightbox_body=this.lightbox_container.find("> div:first-child").first(),this.showLoading(),this.modal_arrows=null,this.border={top:parseFloat(this.modal_dialog.css("border-top-width"))+parseFloat(this.modal_content.css("border-top-width"))+parseFloat(this.modal_body.css("border-top-width")),right:parseFloat(this.modal_dialog.css("border-right-width"))+parseFloat(this.modal_content.css("border-right-width"))+parseFloat(this.modal_body.css("border-right-width")),bottom:parseFloat(this.modal_dialog.css("border-bottom-width"))+parseFloat(this.modal_content.css("border-bottom-width"))+parseFloat(this.modal_body.css("border-bottom-width")),left:parseFloat(this.modal_dialog.css("border-left-width"))+parseFloat(this.modal_content.css("border-left-width"))+parseFloat(this.modal_body.css("border-left-width"))},this.padding={top:parseFloat(this.modal_dialog.css("padding-top"))+parseFloat(this.modal_content.css("padding-top"))+parseFloat(this.modal_body.css("padding-top")),right:parseFloat(this.modal_dialog.css("padding-right"))+parseFloat(this.modal_content.css("padding-right"))+parseFloat(this.modal_body.css("padding-right")),bottom:parseFloat(this.modal_dialog.css("padding-bottom"))+parseFloat(this.modal_content.css("padding-bottom"))+parseFloat(this.modal_body.css("padding-bottom")),left:parseFloat(this.modal_dialog.css("padding-left"))+parseFloat(this.modal_content.css("padding-left"))+parseFloat(this.modal_body.css("padding-left"))},this.modal.on("show.bs.modal",this.options.onShow.bind(this)).on("shown.bs.modal",function(){return g.modal_shown(),g.options.onShown.call(g)}).on("hide.bs.modal",this.options.onHide.bind(this)).on("hidden.bs.modal",function(){return g.gallery&&a(document).off("keydown.ekkoLightbox"),g.modal.remove(),g.options.onHidden.call(g)}).modal("show",c),this.modal},b.prototype={modal_shown:function(){var b,c=this;return this.options.remote?(this.gallery=this.$element.data("gallery"),this.gallery&&(this.gallery_items="document.body"===this.options.gallery_parent_selector||""===this.options.gallery_parent_selector?a(document.body).find('*[data-toggle="lightbox"][data-gallery="'+this.gallery+'"]'):this.$element.parents(this.options.gallery_parent_selector).first().find('*[data-toggle="lightbox"][data-gallery="'+this.gallery+'"]'),this.gallery_index=this.gallery_items.index(this.$element),a(document).on("keydown.ekkoLightbox",this.navigate.bind(this)),this.options.directional_arrows&&this.gallery_items.length>1&&(this.lightbox_container.append('<div class="ekko-lightbox-nav-overlay"><a href="#" class="'+this.strip_stops(this.options.left_arrow_class)+'"></a><a href="#" class="'+this.strip_stops(this.options.right_arrow_class)+'"></a></div>'),this.modal_arrows=this.lightbox_container.find("div.ekko-lightbox-nav-overlay").first(),this.lightbox_container.find("a"+this.strip_spaces(this.options.left_arrow_class)).on("click",function(a){return a.preventDefault(),c.navigate_left()}),this.lightbox_container.find("a"+this.strip_spaces(this.options.right_arrow_class)).on("click",function(a){return a.preventDefault(),c.navigate_right()}))),this.options.type?"image"===this.options.type?this.preloadImage(this.options.remote,!0):"youtube"===this.options.type&&(b=this.getYoutubeId(this.options.remote))?this.showYoutubeVideo(b):"vimeo"===this.options.type?this.showVimeoVideo(this.options.remote):"instagram"===this.options.type?this.showInstagramVideo(this.options.remote):"url"===this.options.type?this.loadRemoteContent(this.options.remote):"video"===this.options.type?this.showVideoIframe(this.options.remote):this.error('Could not detect remote target type. Force the type using data-type="image|youtube|vimeo|instagram|url|video"'):this.detectRemoteType(this.options.remote)):this.error("No remote target given")},strip_stops:function(a){return a.replace(/\./g,"")},strip_spaces:function(a){return a.replace(/\s/g,"")},isImage:function(a){return a.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i)},isSwf:function(a){return a.match(/\.(swf)((\?|#).*)?$/i)},getYoutubeId:function(a){var b;return b=a.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/),b&&11===b[2].length?b[2]:!1},getVimeoId:function(a){return a.indexOf("vimeo")>0?a:!1},getInstagramId:function(a){return a.indexOf("instagram")>0?a:!1},navigate:function(a){if(a=a||window.event,39===a.keyCode||37===a.keyCode){if(39===a.keyCode)return this.navigate_right();if(37===a.keyCode)return this.navigate_left()}},navigateTo:function(b){var c,d;return 0>b||b>this.gallery_items.length-1?this:(this.showLoading(),this.gallery_index=b,this.$element=a(this.gallery_items.get(this.gallery_index)),this.updateTitleAndFooter(),d=this.$element.attr("data-remote")||this.$element.attr("href"),this.detectRemoteType(d,this.$element.attr("data-type")||!1),this.gallery_index+1<this.gallery_items.length&&(c=a(this.gallery_items.get(this.gallery_index+1),!1),d=c.attr("data-remote")||c.attr("href"),"image"===c.attr("data-type")||this.isImage(d))?this.preloadImage(d,!1):void 0)},navigate_left:function(){return 1!==this.gallery_items.length?(0===this.gallery_index?this.gallery_index=this.gallery_items.length-1:this.gallery_index--,this.options.onNavigate.call(this,"left",this.gallery_index),this.navigateTo(this.gallery_index)):void 0},navigate_right:function(){return 1!==this.gallery_items.length?(this.gallery_index===this.gallery_items.length-1?this.gallery_index=0:this.gallery_index++,this.options.onNavigate.call(this,"right",this.gallery_index),this.navigateTo(this.gallery_index)):void 0},detectRemoteType:function(a,b){var c;return b=b||!1,"image"===b||this.isImage(a)?(this.options.type="image",this.preloadImage(a,!0)):"youtube"===b||(c=this.getYoutubeId(a))?(this.options.type="youtube",this.showYoutubeVideo(c)):"vimeo"===b||(c=this.getVimeoId(a))?(this.options.type="vimeo",this.showVimeoVideo(c)):"instagram"===b||(c=this.getInstagramId(a))?(this.options.type="instagram",this.showInstagramVideo(c)):"video"===b?(this.options.type="video",this.showVideoIframe(c)):(this.options.type="url",this.loadRemoteContent(a))},updateTitleAndFooter:function(){var a,b,c,d;return c=this.modal_content.find(".modal-header"),b=this.modal_content.find(".modal-footer"),d=this.$element.data("title")||"",a=this.$element.data("footer")||"",d||this.options.always_show_close?c.css("display","").find(".modal-title").html(d||"&nbsp;"):c.css("display","none"),a?b.css("display","").html(a):b.css("display","none"),this},showLoading:function(){return this.lightbox_body.html('<div class="modal-loading">'+this.options.loadingMessage+"</div>"),this},showYoutubeVideo:function(a){var b,c;return c=this.checkDimensions(this.$element.data("width")||560),b=c/(560/315),this.showVideoIframe("//www.youtube.com/embed/"+a+"?badge=0&autoplay=1&html5=1",c,b)},showVimeoVideo:function(a){var b,c;return c=this.checkDimensions(this.$element.data("width")||560),b=c/(500/281),this.showVideoIframe(a+"?autoplay=1",c,b)},showInstagramVideo:function(a){var b,c;return c=this.checkDimensions(this.$element.data("width")||612),this.resize(c),b=c+80,this.lightbox_body.html('<iframe width="'+c+'" height="'+b+'" src="'+this.addTrailingSlash(a)+'embed/" frameborder="0" allowfullscreen></iframe>'),this.options.onContentLoaded.call(this),this.modal_arrows?this.modal_arrows.css("display","none"):void 0},showVideoIframe:function(a,b,c){return c=c||b,this.resize(b),this.lightbox_body.html('<div class="embed-responsive embed-responsive-16by9"><iframe width="'+b+'" height="'+c+'" src="'+a+'" frameborder="0" allowfullscreenclass="embed-responsive-item"></iframe></div>'),this.options.onContentLoaded.call(this),this.modal_arrows&&this.modal_arrows.css("display","none"),this},loadRemoteContent:function(b){var c,d,e=this;return d=this.$element.data("width")||560,this.resize(d),c=this.$element.data("disableExternalCheck")||!1,c||this.isExternal(b)?(this.lightbox_body.html('<iframe width="'+d+'" height="'+d+'" src="'+b+'" frameborder="0" allowfullscreen></iframe>'),this.options.onContentLoaded.call(this)):this.lightbox_body.load(b,a.proxy(function(){return e.$element.trigger("loaded.bs.modal")})),this.modal_arrows&&this.modal_arrows.css("display","none"),this},isExternal:function(a){var b;return b=a.match(/^([^:\/?#]+:)?(?:\/\/([^\/?#]*))?([^?#]+)?(\?[^#]*)?(#.*)?/),"string"==typeof b[1]&&b[1].length>0&&b[1].toLowerCase()!==location.protocol?!0:"string"==typeof b[2]&&b[2].length>0&&b[2].replace(new RegExp(":("+{"http:":80,"https:":443}[location.protocol]+")?$"),"")!==location.host?!0:!1},error:function(a){return this.lightbox_body.html(a),this},preloadImage:function(b,c){var d,e=this;return d=new Image,(null==c||c===!0)&&(d.onload=function(){var b;return b=a("<img />"),b.attr("src",d.src),b.addClass("img-responsive"),e.lightbox_body.html(b),e.modal_arrows&&e.modal_arrows.css("display","block"),e.resize(d.width),e.options.onContentLoaded.call(e)},d.onerror=function(){return e.error("Failed to load image: "+b)}),d.src=b,d},resize:function(b){var c;return c=b+this.border.left+this.padding.left+this.padding.right+this.border.right,this.modal_dialog.css("width","auto").css("max-width",c),this.lightbox_container.find("a").css("line-height",function(){return a(this).parent().height()+"px"}),this},checkDimensions:function(a){var b,c;return c=a+this.border.left+this.padding.left+this.padding.right+this.border.right,b=document.body.clientWidth,c>b&&(a=this.modal_body.width()),a},close:function(){return this.modal.modal("hide")},addTrailingSlash:function(a){return"/"!==a.substr(-1)&&(a+="/"),a}},a.fn.ekkoLightbox=function(c){return this.each(function(){var d;return d=a(this),c=a.extend({remote:d.attr("data-remote")||d.attr("href"),gallery_parent_selector:d.attr("data-parent"),type:d.attr("data-type")},c,d.data()),new b(this,c),this})},a.fn.ekkoLightbox.defaults={gallery_parent_selector:"document.body",left_arrow_class:".glyphicon .glyphicon-chevron-left",right_arrow_class:".glyphicon .glyphicon-chevron-right",directional_arrows:!0,type:null,always_show_close:!0,loadingMessage:"Loading...",onShow:function(){},onShown:function(){},onHide:function(){},onHidden:function(){},onNavigate:function(){},onContentLoaded:function(){}}}).call(this);
@@ -0,0 +1 @@
1
+ //= require ./ekko-lightbox.min
@@ -0,0 +1,62 @@
1
+ /*!
2
+ * Lightbox for Bootstrap 3 by @ashleydw
3
+ * https://github.com/ashleydw/lightbox
4
+ *
5
+ * License: https://github.com/ashleydw/lightbox/blob/master/LICENSE
6
+ */
7
+
8
+ .ekko-lightbox-container {
9
+ position: relative;
10
+ }
11
+
12
+ .ekko-lightbox-nav-overlay {
13
+ position: absolute;
14
+ top: 0;
15
+ left: 0;
16
+ z-index: 100;
17
+ width: 100%;
18
+ height: 100%;
19
+ }
20
+
21
+ .ekko-lightbox-nav-overlay a {
22
+ z-index: 100;
23
+ display: block;
24
+ width: 49%;
25
+ height: 100%;
26
+ font-size: 30px;
27
+ color: #fff;
28
+ text-shadow: 2px 2px 4px #000;
29
+ opacity: 0;
30
+ filter: dropshadow(color=#000000, offx=2, offy=2);
31
+ -webkit-transition: opacity 0.5s;
32
+ -moz-transition: opacity 0.5s;
33
+ -o-transition: opacity 0.5s;
34
+ transition: opacity 0.5s;
35
+ }
36
+
37
+ .ekko-lightbox-nav-overlay a:empty {
38
+ width: 49%;
39
+ }
40
+
41
+ .ekko-lightbox a:hover {
42
+ text-decoration: none;
43
+ opacity: 1;
44
+ }
45
+
46
+ .ekko-lightbox .glyphicon-chevron-left {
47
+ left: 0;
48
+ float: left;
49
+ padding-left: 15px;
50
+ text-align: left;
51
+ }
52
+
53
+ .ekko-lightbox .glyphicon-chevron-right {
54
+ right: 0;
55
+ float: right;
56
+ padding-right: 15px;
57
+ text-align: right;
58
+ }
59
+
60
+ .ekko-lightbox .modal-footer {
61
+ text-align: left;
62
+ }
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * Lightbox for Bootstrap 3 by @ashleydw
3
+ * https://github.com/ashleydw/lightbox
4
+ *
5
+ * License: https://github.com/ashleydw/lightbox/blob/master/LICENSE
6
+ */.ekko-lightbox-container{position:relative}.ekko-lightbox-nav-overlay{position:absolute;top:0;left:0;z-index:100;width:100%;height:100%}.ekko-lightbox-nav-overlay a{z-index:100;display:block;width:49%;height:100%;font-size:30px;color:#fff;text-shadow:2px 2px 4px #000;opacity:0;filter:dropshadow(color=#000000,offx=2,offy=2);-webkit-transition:opacity .5s;-moz-transition:opacity .5s;-o-transition:opacity .5s;transition:opacity .5s}.ekko-lightbox-nav-overlay a:empty{width:49%}.ekko-lightbox a:hover{text-decoration:none;opacity:1}.ekko-lightbox .glyphicon-chevron-left{left:0;float:left;padding-left:15px;text-align:left}.ekko-lightbox .glyphicon-chevron-right{right:0;float:right;padding-right:15px;text-align:right}.ekko-lightbox .modal-footer{text-align:left}
@@ -0,0 +1,5 @@
1
+ /*
2
+ *= require ./ekko-lightbox.min
3
+ */
4
+
5
+ @import "ekko-lightbox.min"
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lightbox-bootstrap-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.3.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Hyo Seong Choi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Wrapping the assets of Lightbox for Bootstrap 3 as a ruby gem.
42
+ email:
43
+ - lucius.choi@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - LICENSE.txt
49
+ - README.md
50
+ - lib/lightbox/bootstrap/rails.rb
51
+ - lib/lightbox/bootstrap/rails/version.rb
52
+ - vendor/assets/javascripts/lightbox-bootstrap/ekko-lightbox.js
53
+ - vendor/assets/javascripts/lightbox-bootstrap/ekko-lightbox.min.js
54
+ - vendor/assets/javascripts/lightbox-bootstrap/index.js
55
+ - vendor/assets/stylesheets/lightbox-bootstrap/ekko-lightbox.css
56
+ - vendor/assets/stylesheets/lightbox-bootstrap/ekko-lightbox.min.css
57
+ - vendor/assets/stylesheets/lightbox-bootstrap/rails.css
58
+ homepage: https://github.com/luciuschoi/lightbox-bootstrap-rails
59
+ licenses: []
60
+ metadata:
61
+ allowed_push_host: https://rubygems.org
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.4.5
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: A gem built for the use of Lightbox for Bootstrap 3 as the rails assets pipeline.
82
+ test_files: []