slick-lightbox-rails 0.0.2
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.
- checksums.yaml +7 -0
- data/.gitignore +51 -0
- data/.gitmodules +3 -0
- data/LICENSE +21 -0
- data/README.md +17 -0
- data/Rakefile +76 -0
- data/app/assets/javascripts/slick-lightbox.js +1 -0
- data/app/assets/javascripts/slick-lightbox/slick-lightbox.js +331 -0
- data/app/assets/javascripts/slick-lightbox/slick-lightbox.min.js +2 -0
- data/app/assets/stylesheets/slick-lightbox.css +1 -0
- data/app/assets/stylesheets/slick-lightbox/slick-lightbox.css +1 -0
- data/lib/slick/lightbox/rails.rb +2 -0
- data/lib/slick/lightbox/rails/engine.rb +8 -0
- data/lib/slick/lightbox/rails/version.rb +8 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 231ab7f2e415b0ff7bdef8d8eec670b327359fdd
|
4
|
+
data.tar.gz: df759dade0de1dd3e19e60ad98870b65c2bacc5c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 77e956f6a251c314989dc96bf01e5ace8c442a04d0d6bfcbc205900584fcd7045184d40adf62c31a31c75d37bc30c95936229832876d728b2dc200dc9624bf1b
|
7
|
+
data.tar.gz: 2a42bc3c9f0fca6addfc6cc185fcbf0f0cebbefe8e0bec0b5f4fef013886ea749ba3fe468699c09d7f144c08612d88e39cf1d32e67568f8460bc363c0ee5d37d
|
data/.gitignore
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
pkg/
|
38
|
+
|
39
|
+
## Environment normalization:
|
40
|
+
/.bundle/
|
41
|
+
/vendor/bundle
|
42
|
+
/lib/bundler/man/
|
43
|
+
|
44
|
+
# for a library or gem, you might want to ignore these files since the code is
|
45
|
+
# intended to run in multiple environments; otherwise, check them in:
|
46
|
+
# Gemfile.lock
|
47
|
+
# .ruby-version
|
48
|
+
# .ruby-gemset
|
49
|
+
|
50
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
51
|
+
.rvmrc
|
data/.gitmodules
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Scott Johnson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
slick-lightbox-rails
|
2
|
+
====================
|
3
|
+
A Rails gem for the [slick-lightbox](https://github.com/mreq/slick-lightbox) project.
|
4
|
+
|
5
|
+
Usage
|
6
|
+
-------
|
7
|
+
Install by adding to Gemfile:
|
8
|
+
```
|
9
|
+
gem 'slick-lightbox-rails', >= 0.0.2
|
10
|
+
```
|
11
|
+
|
12
|
+
Run bundler:
|
13
|
+
```
|
14
|
+
bundle install
|
15
|
+
```
|
16
|
+
|
17
|
+
For examples on how to use slick-lightbox, see the [documentation](http://mreq.github.io/slick-lightbox/).
|
data/Rakefile
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
Encoding.default_external = "UTF-8" if defined?(Encoding)
|
2
|
+
require 'json'
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
|
5
|
+
def version
|
6
|
+
JSON.load(File.read('slick-lightbox/package.json'))['version']
|
7
|
+
end
|
8
|
+
|
9
|
+
task :submodule do
|
10
|
+
sh 'git submodule update --init' unless File.exist?('slick-lightbox/README.md')
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Remove the app directory"
|
14
|
+
task :clean do
|
15
|
+
rm_rf 'app'
|
16
|
+
source_dir = 'slick-lightbox'
|
17
|
+
%x( cd #{source_dir} && git reset --hard HEAD )
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Compile and minify the Javascript and CSS assets"
|
21
|
+
task :build_slick_lightbox => :submodule do
|
22
|
+
source_dir = 'slick-lightbox'
|
23
|
+
Rake.rake_output_message 'Installing npm dependencies...'
|
24
|
+
%x( cd #{source_dir} && npm i )
|
25
|
+
Rake.rake_output_message 'Compiling...'
|
26
|
+
%x( cd #{source_dir} && gulp build )
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Update Slick::Lightbox::Rails::SLICK_LIGHTBOX_VERSION"
|
30
|
+
task :version => :submodule do
|
31
|
+
Rake.rake_output_message "Setting Slick::Lightbox::Rails::SLICK_LIGHTBOX_VERSION = \"#{version}\""
|
32
|
+
|
33
|
+
versionRb = 'lib/slick/lightbox/rails/version.rb'
|
34
|
+
versionRbSource = File.read(versionRb)
|
35
|
+
versionDefinition = "SLICK_LIGHTBOX_VERSION = \"#{version}\""
|
36
|
+
versionRbSource.sub! /SLICK_LIGHTBOX_VERSION = "[^"]*"/, versionDefinition \
|
37
|
+
or fail "Could not find SLICK_LIGHTBOX_VERSION in #{versionRb}"
|
38
|
+
File.open(versionRb, 'w') do |out|
|
39
|
+
out.write(versionRbSource)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Move the build assets to the app dir"
|
44
|
+
task :move_to_app_dir => :build_slick_lightbox do
|
45
|
+
Rake.rake_output_message 'Moving built files...'
|
46
|
+
target_dir_js = 'app/assets/javascripts/slick-lightbox'
|
47
|
+
target_dir_css = 'app/assets/stylesheets/slick-lightbox'
|
48
|
+
|
49
|
+
mkdir_p target_dir_js
|
50
|
+
mkdir_p target_dir_css
|
51
|
+
|
52
|
+
FileUtils.cp(Dir.glob("slick-lightbox/dist/*.js"), target_dir_js)
|
53
|
+
FileUtils.cp(Dir.glob("slick-lightbox/dist/*.css"), target_dir_css)
|
54
|
+
end
|
55
|
+
|
56
|
+
desc "Generate root files"
|
57
|
+
task :generate_root_files => :move_to_app_dir do
|
58
|
+
Rake.rake_output_message 'Generating root files...'
|
59
|
+
target_js_file='app/assets/javascripts/slick-lightbox.js'
|
60
|
+
target_css_file='app/assets/stylesheets/slick-lightbox.css'
|
61
|
+
|
62
|
+
File.open(target_js_file, 'w') do |out|
|
63
|
+
out.write('//= require slick-lightbox/slick-lightbox')
|
64
|
+
end
|
65
|
+
|
66
|
+
File.open(target_css_file, 'w') do |out|
|
67
|
+
out.write('//= require slick-lightbox/slick-lightbox')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
desc "Clean and then generate everything (default)"
|
72
|
+
task :assets => [:clean, :generate_root_files, :version]
|
73
|
+
|
74
|
+
task :build => :assets
|
75
|
+
|
76
|
+
task :default => :assets
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require slick-lightbox/slick-lightbox
|
@@ -0,0 +1,331 @@
|
|
1
|
+
'use strict';
|
2
|
+
(function ($) {
|
3
|
+
var SlickLightbox, defaults;
|
4
|
+
SlickLightbox = function () {
|
5
|
+
/*
|
6
|
+
The core class.
|
7
|
+
*/
|
8
|
+
function SlickLightbox(element, options1) {
|
9
|
+
var slickLightbox;
|
10
|
+
this.options = options1;
|
11
|
+
/* Binds the plugin. */
|
12
|
+
this.$element = $(element);
|
13
|
+
this.didInit = false;
|
14
|
+
slickLightbox = this;
|
15
|
+
this.$element.on('click.slickLightbox', this.options.itemSelector, function (e) {
|
16
|
+
var $clickedItem, $items;
|
17
|
+
e.preventDefault();
|
18
|
+
$clickedItem = $(this);
|
19
|
+
$clickedItem.blur();
|
20
|
+
if (typeof slickLightbox.options.shouldOpen === 'function') {
|
21
|
+
if (!slickLightbox.options.shouldOpen(slickLightbox, $clickedItem, e)) {
|
22
|
+
return;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
$items = slickLightbox.filterOutSlickClones(slickLightbox.$element.find(slickLightbox.options.itemSelector));
|
26
|
+
return slickLightbox.init($items.index($clickedItem));
|
27
|
+
});
|
28
|
+
}
|
29
|
+
SlickLightbox.prototype.init = function (index) {
|
30
|
+
/* Creates the lightbox, opens it, binds events and calls `slick`. Accepts `index` of the element, that triggered it (so that we know, on which slide to start slick). */
|
31
|
+
this.didInit = true;
|
32
|
+
this.detectIE();
|
33
|
+
this.createModal();
|
34
|
+
this.bindEvents();
|
35
|
+
this.initSlick(index);
|
36
|
+
return this.open();
|
37
|
+
};
|
38
|
+
SlickLightbox.prototype.createModalItems = function () {
|
39
|
+
/* Creates individual slides to be used with slick. If `options.images` array is specified, it uses it's contents, otherwise loops through elements' `options.itemSelector`. */
|
40
|
+
var $items, createItem, itemTemplate, lazyPlaceholder, length, links;
|
41
|
+
lazyPlaceholder = this.options.lazyPlaceholder || 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
42
|
+
itemTemplate = function (source, caption, lazy) {
|
43
|
+
var imgSourceParams;
|
44
|
+
if (lazy === true) {
|
45
|
+
imgSourceParams = ' data-lazy="' + source + '" src="' + lazyPlaceholder + '" ';
|
46
|
+
} else {
|
47
|
+
imgSourceParams = ' src="' + source + '" ';
|
48
|
+
}
|
49
|
+
return '<div class="slick-lightbox-slick-item">\n <div class="slick-lightbox-slick-item-inner">\n <img class="slick-lightbox-slick-img" ' + imgSourceParams + ' />\n ' + caption + '\n </div>\n</div>';
|
50
|
+
};
|
51
|
+
if (this.options.images) {
|
52
|
+
links = $.map(this.options.images, function (img) {
|
53
|
+
return itemTemplate(img, this.options.lazy);
|
54
|
+
});
|
55
|
+
} else {
|
56
|
+
$items = this.filterOutSlickClones(this.$element.find(this.options.itemSelector));
|
57
|
+
length = $items.length;
|
58
|
+
createItem = function (_this) {
|
59
|
+
return function (el, index) {
|
60
|
+
var caption, info, src;
|
61
|
+
info = {
|
62
|
+
index: index,
|
63
|
+
length: length
|
64
|
+
};
|
65
|
+
caption = _this.getElementCaption(el, info);
|
66
|
+
src = _this.getElementSrc(el);
|
67
|
+
return itemTemplate(src, caption, _this.options.lazy);
|
68
|
+
};
|
69
|
+
}(this);
|
70
|
+
links = $.map($items, createItem);
|
71
|
+
}
|
72
|
+
return links;
|
73
|
+
};
|
74
|
+
SlickLightbox.prototype.createModal = function () {
|
75
|
+
/* Creates a `slick`-friendly modal. */
|
76
|
+
var html, links;
|
77
|
+
links = this.createModalItems();
|
78
|
+
html = '<div class="slick-lightbox slick-lightbox-hide-init' + (this.isIE ? ' slick-lightbox-ie' : '') + '" style="background: ' + this.options.background + ';">\n <div class="slick-lightbox-inner">\n <div class="slick-lightbox-slick slick-caption-' + this.options.captionPosition + '">' + links.join('') + '</div>\n <div>\n<div>';
|
79
|
+
this.$modalElement = $(html);
|
80
|
+
this.$parts = {};
|
81
|
+
this.$parts['closeButton'] = $(this.options.layouts.closeButton);
|
82
|
+
this.$modalElement.find('.slick-lightbox-inner').append(this.$parts['closeButton']);
|
83
|
+
return $('body').append(this.$modalElement);
|
84
|
+
};
|
85
|
+
SlickLightbox.prototype.initSlick = function (index) {
|
86
|
+
/* Runs slick by default, using `options.slick` if provided. If `options.slick` is a function, it gets fired instead of us initializing slick. Merges in initialSlide option. */
|
87
|
+
var additional;
|
88
|
+
additional = { initialSlide: index };
|
89
|
+
if (this.options.lazy) {
|
90
|
+
additional.lazyLoad = 'ondemand';
|
91
|
+
}
|
92
|
+
if (this.options.slick != null) {
|
93
|
+
if (typeof this.options.slick === 'function') {
|
94
|
+
this.slick = this.options.slick(this.$modalElement);
|
95
|
+
} else {
|
96
|
+
this.slick = this.$modalElement.find('.slick-lightbox-slick').slick($.extend({}, this.options.slick, additional));
|
97
|
+
}
|
98
|
+
} else {
|
99
|
+
this.slick = this.$modalElement.find('.slick-lightbox-slick').slick(additional);
|
100
|
+
}
|
101
|
+
return this.$modalElement.trigger('init.slickLightbox');
|
102
|
+
};
|
103
|
+
SlickLightbox.prototype.open = function () {
|
104
|
+
/* Opens the lightbox. */
|
105
|
+
if (this.options.useHistoryApi) {
|
106
|
+
this.writeHistory();
|
107
|
+
}
|
108
|
+
this.$element.trigger('show.slickLightbox');
|
109
|
+
setTimeout(function (_this) {
|
110
|
+
return function () {
|
111
|
+
return _this.$element.trigger('shown.slickLightbox');
|
112
|
+
};
|
113
|
+
}(this), this.getTransitionDuration());
|
114
|
+
return this.$modalElement.removeClass('slick-lightbox-hide-init');
|
115
|
+
};
|
116
|
+
SlickLightbox.prototype.close = function () {
|
117
|
+
/* Closes the lightbox and destroys it, maintaining the original element bindings. */
|
118
|
+
this.$element.trigger('hide.slickLightbox');
|
119
|
+
setTimeout(function (_this) {
|
120
|
+
return function () {
|
121
|
+
return _this.$element.trigger('hidden.slickLightbox');
|
122
|
+
};
|
123
|
+
}(this), this.getTransitionDuration());
|
124
|
+
this.$modalElement.addClass('slick-lightbox-hide');
|
125
|
+
return this.destroy();
|
126
|
+
};
|
127
|
+
SlickLightbox.prototype.bindEvents = function () {
|
128
|
+
/* Binds global events. */
|
129
|
+
var resizeSlides;
|
130
|
+
resizeSlides = function (_this) {
|
131
|
+
return function () {
|
132
|
+
var h;
|
133
|
+
h = _this.$modalElement.find('.slick-lightbox-inner').height();
|
134
|
+
_this.$modalElement.find('.slick-lightbox-slick-item').height(h);
|
135
|
+
return _this.$modalElement.find('.slick-lightbox-slick-img, .slick-lightbox-slick-item-inner').css('max-height', Math.round(_this.options.imageMaxHeight * h));
|
136
|
+
};
|
137
|
+
}(this);
|
138
|
+
$(window).on('orientationchange.slickLightbox resize.slickLightbox', resizeSlides);
|
139
|
+
if (this.options.useHistoryApi) {
|
140
|
+
$(window).on('popstate.slickLightbox', function (_this) {
|
141
|
+
return function () {
|
142
|
+
return _this.close();
|
143
|
+
};
|
144
|
+
}(this));
|
145
|
+
}
|
146
|
+
this.$modalElement.on('init.slickLightbox', resizeSlides);
|
147
|
+
this.$modalElement.on('destroy.slickLightbox', function (_this) {
|
148
|
+
return function () {
|
149
|
+
return _this.destroy();
|
150
|
+
};
|
151
|
+
}(this));
|
152
|
+
this.$element.on('destroy.slickLightbox', function (_this) {
|
153
|
+
return function () {
|
154
|
+
return _this.destroy(true);
|
155
|
+
};
|
156
|
+
}(this));
|
157
|
+
this.$parts['closeButton'].on('click.slickLightbox touchstart.slickLightbox', function (_this) {
|
158
|
+
return function (e) {
|
159
|
+
e.preventDefault();
|
160
|
+
return _this.close();
|
161
|
+
};
|
162
|
+
}(this));
|
163
|
+
if (this.options.closeOnEscape || this.options.navigateByKeyboard) {
|
164
|
+
$(document).on('keydown.slickLightbox', function (_this) {
|
165
|
+
return function (e) {
|
166
|
+
var code;
|
167
|
+
code = e.keyCode ? e.keyCode : e.which;
|
168
|
+
if (_this.options.navigateByKeyboard) {
|
169
|
+
if (code === 37) {
|
170
|
+
_this.slideSlick('left');
|
171
|
+
} else if (code === 39) {
|
172
|
+
_this.slideSlick('right');
|
173
|
+
}
|
174
|
+
}
|
175
|
+
if (_this.options.closeOnEscape) {
|
176
|
+
if (code === 27) {
|
177
|
+
return _this.close();
|
178
|
+
}
|
179
|
+
}
|
180
|
+
};
|
181
|
+
}(this));
|
182
|
+
}
|
183
|
+
if (this.options.closeOnBackdropClick) {
|
184
|
+
this.$modalElement.on('click.slickLightbox touchstart.slickLightbox', '.slick-lightbox-slick-img', function (e) {
|
185
|
+
return e.stopPropagation();
|
186
|
+
});
|
187
|
+
return this.$modalElement.on('click.slickLightbox', '.slick-lightbox-slick-item', function (_this) {
|
188
|
+
return function (e) {
|
189
|
+
e.preventDefault();
|
190
|
+
return _this.close();
|
191
|
+
};
|
192
|
+
}(this));
|
193
|
+
}
|
194
|
+
};
|
195
|
+
SlickLightbox.prototype.slideSlick = function (direction) {
|
196
|
+
/* Moves the slick prev or next. */
|
197
|
+
if (direction === 'left') {
|
198
|
+
return this.slick.slick('slickPrev');
|
199
|
+
} else {
|
200
|
+
return this.slick.slick('slickNext');
|
201
|
+
}
|
202
|
+
};
|
203
|
+
SlickLightbox.prototype.detectIE = function () {
|
204
|
+
/* Detects usage of IE8 and lower. */
|
205
|
+
var ieversion;
|
206
|
+
this.isIE = false;
|
207
|
+
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
|
208
|
+
ieversion = new Number(RegExp.$1);
|
209
|
+
if (ieversion < 9) {
|
210
|
+
return this.isIE = true;
|
211
|
+
}
|
212
|
+
}
|
213
|
+
};
|
214
|
+
SlickLightbox.prototype.getElementCaption = function (el, info) {
|
215
|
+
/* Returns caption for each slide based on the type of `options.caption`. */
|
216
|
+
var c;
|
217
|
+
if (!this.options.caption) {
|
218
|
+
return '';
|
219
|
+
}
|
220
|
+
c = function () {
|
221
|
+
switch (typeof this.options.caption) {
|
222
|
+
case 'function':
|
223
|
+
return this.options.caption(el, info);
|
224
|
+
case 'string':
|
225
|
+
return $(el).data(this.options.caption);
|
226
|
+
}
|
227
|
+
}.call(this);
|
228
|
+
return '<span class="slick-lightbox-slick-caption">' + c + '</span>';
|
229
|
+
};
|
230
|
+
SlickLightbox.prototype.getElementSrc = function (el) {
|
231
|
+
/* Returns src for each slide image based on the type of `options.src`. */
|
232
|
+
switch (typeof this.options.src) {
|
233
|
+
case 'function':
|
234
|
+
return this.options.src(el);
|
235
|
+
case 'string':
|
236
|
+
return $(el).attr(this.options.src);
|
237
|
+
default:
|
238
|
+
return el.href;
|
239
|
+
}
|
240
|
+
};
|
241
|
+
SlickLightbox.prototype.unbindEvents = function () {
|
242
|
+
/* Unbinds global events. */
|
243
|
+
$(window).off('.slickLightbox');
|
244
|
+
$(document).off('.slickLightbox');
|
245
|
+
return this.$modalElement.off('.slickLightbox');
|
246
|
+
};
|
247
|
+
SlickLightbox.prototype.destroy = function (unbindAnchors) {
|
248
|
+
if (unbindAnchors == null) {
|
249
|
+
unbindAnchors = false;
|
250
|
+
}
|
251
|
+
/* Destroys the lightbox and unbinds global events. If `true` is passed as an argument, unbinds the original element as well. */
|
252
|
+
if (this.didInit) {
|
253
|
+
this.unbindEvents();
|
254
|
+
setTimeout(function (_this) {
|
255
|
+
return function () {
|
256
|
+
return _this.$modalElement.remove();
|
257
|
+
};
|
258
|
+
}(this), this.options.destroyTimeout);
|
259
|
+
}
|
260
|
+
if (unbindAnchors) {
|
261
|
+
this.$element.off('.slickLightbox');
|
262
|
+
return this.$element.off('.slickLightbox', this.options.itemSelector);
|
263
|
+
}
|
264
|
+
};
|
265
|
+
SlickLightbox.prototype.destroyPrevious = function () {
|
266
|
+
/* Destroys lightboxes currently in DOM. */
|
267
|
+
return $('body').children('.slick-lightbox').trigger('destroy.slickLightbox');
|
268
|
+
};
|
269
|
+
SlickLightbox.prototype.getTransitionDuration = function () {
|
270
|
+
/* Detects the transition duration to know when to remove stuff from DOM etc. */
|
271
|
+
var duration;
|
272
|
+
if (this.transitionDuration) {
|
273
|
+
return this.transitionDuration;
|
274
|
+
}
|
275
|
+
duration = this.$modalElement.css('transition-duration');
|
276
|
+
if (typeof duration === 'undefined') {
|
277
|
+
return this.transitionDuration = 500;
|
278
|
+
} else {
|
279
|
+
return this.transitionDuration = duration.indexOf('ms') > -1 ? parseFloat(duration) : parseFloat(duration) * 1000;
|
280
|
+
}
|
281
|
+
};
|
282
|
+
SlickLightbox.prototype.writeHistory = function () {
|
283
|
+
/* Writes an empty state to the history API if supported. */
|
284
|
+
return typeof history !== 'undefined' && history !== null ? typeof history.pushState === 'function' ? history.pushState(null, null, '') : void 0 : void 0;
|
285
|
+
};
|
286
|
+
SlickLightbox.prototype.filterOutSlickClones = function ($items) {
|
287
|
+
/* Removes all slick clones from the set of elements. Only does so, if the target element is a slick slider. */
|
288
|
+
if (!this.$element.hasClass('slick-slider')) {
|
289
|
+
return $items;
|
290
|
+
}
|
291
|
+
return $items = $items.filter(function () {
|
292
|
+
var $item;
|
293
|
+
$item = $(this);
|
294
|
+
return !$item.hasClass('slick-cloned') && $item.parents('.slick-cloned').length === 0;
|
295
|
+
});
|
296
|
+
};
|
297
|
+
return SlickLightbox;
|
298
|
+
}();
|
299
|
+
defaults = {
|
300
|
+
background: 'rgba(0,0,0,.8)',
|
301
|
+
closeOnEscape: true,
|
302
|
+
closeOnBackdropClick: true,
|
303
|
+
destroyTimeout: 500,
|
304
|
+
itemSelector: 'a',
|
305
|
+
navigateByKeyboard: true,
|
306
|
+
src: false,
|
307
|
+
caption: false,
|
308
|
+
captionPosition: 'dynamic',
|
309
|
+
images: false,
|
310
|
+
slick: {},
|
311
|
+
useHistoryApi: false,
|
312
|
+
layouts: { closeButton: '<button type="button" class="slick-lightbox-close"></button>' },
|
313
|
+
shouldOpen: null,
|
314
|
+
imageMaxHeight: 0.9,
|
315
|
+
lazy: false
|
316
|
+
};
|
317
|
+
$.fn.slickLightbox = function (options) {
|
318
|
+
/* Fires the plugin. */
|
319
|
+
options = $.extend({}, defaults, options);
|
320
|
+
$(this).each(function () {
|
321
|
+
return this.slickLightbox = new SlickLightbox(this, options);
|
322
|
+
});
|
323
|
+
return this;
|
324
|
+
};
|
325
|
+
$.fn.unslickLightbox = function () {
|
326
|
+
/* Removes everything. */
|
327
|
+
return $(this).trigger('destroy.slickLightbox').each(function () {
|
328
|
+
return this.slickLightbox = null;
|
329
|
+
});
|
330
|
+
};
|
331
|
+
}(jQuery));
|
@@ -0,0 +1,2 @@
|
|
1
|
+
"use strict";!function(t){var i,n;i=function(){function i(i,n){var o;this.options=n,this.$element=t(i),this.didInit=!1,o=this,this.$element.on("click.slickLightbox",this.options.itemSelector,function(i){var n,e;if(i.preventDefault(),n=t(this),n.blur(),"function"!=typeof o.options.shouldOpen||o.options.shouldOpen(o,n,i))return e=o.filterOutSlickClones(o.$element.find(o.options.itemSelector)),o.init(e.index(n))})}return i.prototype.init=function(t){return this.didInit=!0,this.detectIE(),this.createModal(),this.bindEvents(),this.initSlick(t),this.open()},i.prototype.createModalItems=function(){var i,n,o,e,s,l;return e=this.options.lazyPlaceholder||"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",o=function(t,i,n){return'<div class="slick-lightbox-slick-item">\n <div class="slick-lightbox-slick-item-inner">\n <img class="slick-lightbox-slick-img" '+(!0===n?' data-lazy="'+t+'" src="'+e+'" ':' src="'+t+'" ')+" />\n "+i+"\n </div>\n</div>"},this.options.images?l=t.map(this.options.images,function(t){return o(t,this.options.lazy)}):(i=this.filterOutSlickClones(this.$element.find(this.options.itemSelector)),s=i.length,n=function(t){return function(i,n){var e,l,r;return l={index:n,length:s},e=t.getElementCaption(i,l),r=t.getElementSrc(i),o(r,e,t.options.lazy)}}(this),l=t.map(i,n)),l},i.prototype.createModal=function(){var i,n;return n=this.createModalItems(),i='<div class="slick-lightbox slick-lightbox-hide-init'+(this.isIE?" slick-lightbox-ie":"")+'" style="background: '+this.options.background+';">\n <div class="slick-lightbox-inner">\n <div class="slick-lightbox-slick slick-caption-'+this.options.captionPosition+'">'+n.join("")+"</div>\n <div>\n<div>",this.$modalElement=t(i),this.$parts={},this.$parts.closeButton=t(this.options.layouts.closeButton),this.$modalElement.find(".slick-lightbox-inner").append(this.$parts.closeButton),t("body").append(this.$modalElement)},i.prototype.initSlick=function(i){var n;return n={initialSlide:i},this.options.lazy&&(n.lazyLoad="ondemand"),null!=this.options.slick?"function"==typeof this.options.slick?this.slick=this.options.slick(this.$modalElement):this.slick=this.$modalElement.find(".slick-lightbox-slick").slick(t.extend({},this.options.slick,n)):this.slick=this.$modalElement.find(".slick-lightbox-slick").slick(n),this.$modalElement.trigger("init.slickLightbox")},i.prototype.open=function(){return this.options.useHistoryApi&&this.writeHistory(),this.$element.trigger("show.slickLightbox"),setTimeout(function(t){return function(){return t.$element.trigger("shown.slickLightbox")}}(this),this.getTransitionDuration()),this.$modalElement.removeClass("slick-lightbox-hide-init")},i.prototype.close=function(){return this.$element.trigger("hide.slickLightbox"),setTimeout(function(t){return function(){return t.$element.trigger("hidden.slickLightbox")}}(this),this.getTransitionDuration()),this.$modalElement.addClass("slick-lightbox-hide"),this.destroy()},i.prototype.bindEvents=function(){var i;if(i=function(t){return function(){var i;return i=t.$modalElement.find(".slick-lightbox-inner").height(),t.$modalElement.find(".slick-lightbox-slick-item").height(i),t.$modalElement.find(".slick-lightbox-slick-img, .slick-lightbox-slick-item-inner").css("max-height",Math.round(t.options.imageMaxHeight*i))}}(this),t(window).on("orientationchange.slickLightbox resize.slickLightbox",i),this.options.useHistoryApi&&t(window).on("popstate.slickLightbox",function(t){return function(){return t.close()}}(this)),this.$modalElement.on("init.slickLightbox",i),this.$modalElement.on("destroy.slickLightbox",function(t){return function(){return t.destroy()}}(this)),this.$element.on("destroy.slickLightbox",function(t){return function(){return t.destroy(!0)}}(this)),this.$parts.closeButton.on("click.slickLightbox touchstart.slickLightbox",function(t){return function(i){return i.preventDefault(),t.close()}}(this)),(this.options.closeOnEscape||this.options.navigateByKeyboard)&&t(document).on("keydown.slickLightbox",function(t){return function(i){var n;if(n=i.keyCode?i.keyCode:i.which,t.options.navigateByKeyboard&&(37===n?t.slideSlick("left"):39===n&&t.slideSlick("right")),t.options.closeOnEscape&&27===n)return t.close()}}(this)),this.options.closeOnBackdropClick)return this.$modalElement.on("click.slickLightbox touchstart.slickLightbox",".slick-lightbox-slick-img",function(t){return t.stopPropagation()}),this.$modalElement.on("click.slickLightbox",".slick-lightbox-slick-item",function(t){return function(i){return i.preventDefault(),t.close()}}(this))},i.prototype.slideSlick=function(t){return"left"===t?this.slick.slick("slickPrev"):this.slick.slick("slickNext")},i.prototype.detectIE=function(){if(this.isIE=!1,/MSIE (\d+\.\d+);/.test(navigator.userAgent)&&new Number(RegExp.$1)<9)return this.isIE=!0},i.prototype.getElementCaption=function(i,n){return this.options.caption?'<span class="slick-lightbox-slick-caption">'+function(){switch(typeof this.options.caption){case"function":return this.options.caption(i,n);case"string":return t(i).data(this.options.caption)}}.call(this)+"</span>":""},i.prototype.getElementSrc=function(i){switch(typeof this.options.src){case"function":return this.options.src(i);case"string":return t(i).attr(this.options.src);default:return i.href}},i.prototype.unbindEvents=function(){return t(window).off(".slickLightbox"),t(document).off(".slickLightbox"),this.$modalElement.off(".slickLightbox")},i.prototype.destroy=function(t){if(null==t&&(t=!1),this.didInit&&(this.unbindEvents(),setTimeout(function(t){return function(){return t.$modalElement.remove()}}(this),this.options.destroyTimeout)),t)return this.$element.off(".slickLightbox"),this.$element.off(".slickLightbox",this.options.itemSelector)},i.prototype.destroyPrevious=function(){return t("body").children(".slick-lightbox").trigger("destroy.slickLightbox")},i.prototype.getTransitionDuration=function(){var t;return this.transitionDuration?this.transitionDuration:(t=this.$modalElement.css("transition-duration"),this.transitionDuration=void 0===t?500:t.indexOf("ms")>-1?parseFloat(t):1e3*parseFloat(t))},i.prototype.writeHistory=function(){return"undefined"!=typeof history&&null!==history&&"function"==typeof history.pushState?history.pushState(null,null,""):void 0},i.prototype.filterOutSlickClones=function(i){return this.$element.hasClass("slick-slider")?i=i.filter(function(){var i;return i=t(this),!i.hasClass("slick-cloned")&&0===i.parents(".slick-cloned").length}):i},i}(),n={background:"rgba(0,0,0,.8)",closeOnEscape:!0,closeOnBackdropClick:!0,destroyTimeout:500,itemSelector:"a",navigateByKeyboard:!0,src:!1,caption:!1,captionPosition:"dynamic",images:!1,slick:{},useHistoryApi:!1,layouts:{closeButton:'<button type="button" class="slick-lightbox-close"></button>'},shouldOpen:null,imageMaxHeight:.9,lazy:!1},t.fn.slickLightbox=function(o){return o=t.extend({},n,o),t(this).each(function(){return this.slickLightbox=new i(this,o)}),this},t.fn.unslickLightbox=function(){return t(this).trigger("destroy.slickLightbox").each(function(){return this.slickLightbox=null})}}(jQuery);
|
2
|
+
//# sourceMappingURL=slick-lightbox.min.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require slick-lightbox/slick-lightbox
|
@@ -0,0 +1 @@
|
|
1
|
+
.slick-lightbox{position:fixed;top:0;left:0;z-index:9999;width:100%;height:100%;background:black;-webkit-transition:opacity 0.5s ease;transition:opacity 0.5s ease}.slick-lightbox .slick-loading .slick-list{background-color:transparent}.slick-lightbox .slick-prev{left:15px}.slick-lightbox .slick-next{right:15px}.slick-lightbox-hide{opacity:0}.slick-lightbox-hide.slick-lightbox-ie{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0)}.slick-lightbox-hide-init{position:absolute;top:-9999px;opacity:0}.slick-lightbox-hide-init.slick-lightbox-ie{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0)}.slick-lightbox-inner{position:fixed;top:0;left:0;width:100%;height:100%}.slick-lightbox-slick-item{text-align:center;overflow:hidden}.slick-lightbox-slick-item:before{content:'';display:inline-block;height:100%;vertical-align:middle;margin-right:-0.25em}.slick-caption-bottom .slick-lightbox-slick-item .slick-lightbox-slick-item .slick-lightbox-slick-caption{position:absolute;bottom:0;left:0;text-align:center;width:100%;margin-bottom:20px}.slick-caption-dynamic .slick-lightbox-slick-item .slick-lightbox-slick-item .slick-lightbox-slick-caption{display:block;text-align:center}.slick-lightbox-slick-item-inner{display:inline-block;vertical-align:middle;max-width:90%;max-height:90%}.slick-lightbox-slick-img{margin:0 auto;display:block;max-width:90%;max-height:90%}.slick-lightbox-slick-caption{margin:10px 0 0;color:white}.slick-lightbox-close{position:absolute;top:15px;right:15px;display:block;height:20px;width:20px;line-height:0;font-size:0;cursor:pointer;background:transparent;color:transparent;padding:0;border:none}.slick-lightbox-close:focus{outline:none}.slick-lightbox-close:before{font-family:"slick";font-size:20px;line-height:1;color:white;opacity:0.85;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:'×'}
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: slick-lightbox-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Scott Johnson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-10-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.2.16
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.2.16
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
description: slick-lightbox, a lightbox wrapper for Ken's amazing slick carosel, packaged
|
42
|
+
as a gem for simple use within Rails applications
|
43
|
+
email:
|
44
|
+
- jaywir3@gmail.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- ".gitmodules"
|
51
|
+
- LICENSE
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- app/assets/javascripts/slick-lightbox.js
|
55
|
+
- app/assets/javascripts/slick-lightbox/slick-lightbox.js
|
56
|
+
- app/assets/javascripts/slick-lightbox/slick-lightbox.min.js
|
57
|
+
- app/assets/stylesheets/slick-lightbox.css
|
58
|
+
- app/assets/stylesheets/slick-lightbox/slick-lightbox.css
|
59
|
+
- lib/slick/lightbox/rails.rb
|
60
|
+
- lib/slick/lightbox/rails/engine.rb
|
61
|
+
- lib/slick/lightbox/rails/version.rb
|
62
|
+
homepage: https://github.com/jwir3/slick-lightbox-rails
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 1.3.6
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.6.8
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: A lightbox wrapper for Ken's amazing slick carosel.
|
86
|
+
test_files: []
|