pswp-rails 4.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -0
  3. data/LICENSE +21 -0
  4. data/README.md +23 -0
  5. data/lib/pswp-rails.rb +23 -0
  6. data/lib/pswp-rails/version.rb +3 -0
  7. data/pswp-rails.gemspec +18 -0
  8. data/vendor/assets/images/photoswipe/LICENSE +21 -0
  9. data/vendor/assets/images/photoswipe/default-skin/default-skin-svg.sketch/Data +0 -0
  10. data/vendor/assets/images/photoswipe/default-skin/default-skin-svg.sketch/metadata +18 -0
  11. data/vendor/assets/images/photoswipe/default-skin/default-skin-svg.sketch/version +1 -0
  12. data/vendor/assets/images/photoswipe/default-skin/default-skin.png +0 -0
  13. data/vendor/assets/images/photoswipe/default-skin/default-skin.psd +0 -0
  14. data/vendor/assets/images/photoswipe/default-skin/default-skin.svg +1 -0
  15. data/vendor/assets/images/photoswipe/default-skin/preloader.gif +0 -0
  16. data/vendor/assets/javascripts/photoswipe.js +2 -0
  17. data/vendor/assets/javascripts/photoswipe/LICENSE +21 -0
  18. data/vendor/assets/javascripts/photoswipe/index.js +2 -0
  19. data/vendor/assets/javascripts/photoswipe/photoswipe-ui-default.js +861 -0
  20. data/vendor/assets/javascripts/photoswipe/photoswipe.js +3718 -0
  21. data/vendor/assets/stylesheets/photoswipe-compass.scss +3 -0
  22. data/vendor/assets/stylesheets/photoswipe-compass/LICENSE +21 -0
  23. data/vendor/assets/stylesheets/photoswipe-compass/_main-settings.scss +9 -0
  24. data/vendor/assets/stylesheets/photoswipe-compass/_main.scss +203 -0
  25. data/vendor/assets/stylesheets/photoswipe-compass/default-skin/_default-skin.scss +587 -0
  26. data/vendor/assets/stylesheets/photoswipe-eskimo.scss +3 -0
  27. data/vendor/assets/stylesheets/photoswipe-eskimo/LICENSE +21 -0
  28. data/vendor/assets/stylesheets/photoswipe-eskimo/_main-settings.scss +9 -0
  29. data/vendor/assets/stylesheets/photoswipe-eskimo/_main.scss +194 -0
  30. data/vendor/assets/stylesheets/photoswipe-eskimo/default-skin/_default-skin.scss +585 -0
  31. data/vendor/assets/stylesheets/photoswipe.scss +3 -0
  32. data/vendor/assets/stylesheets/photoswipe/LICENSE +21 -0
  33. data/vendor/assets/stylesheets/photoswipe/_main-settings.scss +9 -0
  34. data/vendor/assets/stylesheets/photoswipe/_main.scss +209 -0
  35. data/vendor/assets/stylesheets/photoswipe/default-skin/_default-skin.scss +588 -0
  36. metadata +79 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7142640f690bcd22c8144582e4f742a08fc75ebc
4
+ data.tar.gz: 9fe21ec7ff372bf397a05a272b7e3393c043382d
5
+ SHA512:
6
+ metadata.gz: 1cabeea5f6917319e71ca2229d0378002d84787b46b817980d12220007f3c929a3dc4c927cb094d9e901b4e26607a4c1a41d7af3501e5b10fc7d28a1cd0e30d1
7
+ data.tar.gz: 688848b624159dec7526e3e93a689ab056f3eb8d5dfb724796ad03860783be16b385539d6dcc9d96d50b96bec1d75089b86203ed8100af8bd3c55f617d58d104
@@ -0,0 +1,3 @@
1
+ *.gem
2
+ Gemfile.lock
3
+ /.idea/
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014-2016 Dmitry Semenov, http://dimsemenov.com
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,23 @@
1
+ ## [PhotoSwipe](http://photoswipe.com/) image gallery integration with Rails asset pipeline
2
+
3
+ ## Installing gem
4
+ Add to your Gemfile:
5
+ ```ruby
6
+ gem 'pswp-rails', '~> 4.0'
7
+ ```
8
+
9
+ Add to your javascript:
10
+ ```coffee
11
+ #= require photoswipe
12
+ ```
13
+
14
+ Add to your stylesheet:
15
+ <br>
16
+ 1) if you are using compass
17
+ ```scss
18
+ @import 'photoswipe-compass';
19
+ ```
20
+ 2) if you are not using compass:
21
+ ```scss
22
+ @import 'photoswipe';
23
+ ```
@@ -0,0 +1,23 @@
1
+ require 'pswp-rails/version'
2
+
3
+ module PhotoSwipe
4
+ class Engine < Rails::Engine
5
+ # initializer 'sprockets.photoswipe', group: :all, after: 'sprockets.environment' do |app|
6
+ # configure_assets app do |env|
7
+ # env.precompile += %w( photoswipe.js photoswipe-ui-default.js photoswipe.scss )
8
+ #
9
+ # end
10
+ # end
11
+ #
12
+ # private
13
+ # def configure_assets(app)
14
+ # if config.respond_to?(:assets) && config.assets.respond_to?(:configure)
15
+ # # Rails 4.x
16
+ # config.assets.configure { |env| yield(env) }
17
+ # else
18
+ # # Rails 3.2
19
+ # yield(app.assets)
20
+ # end
21
+ # end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module PhotoSwipe
2
+ VERSION = '4.1.1'.freeze
3
+ end
@@ -0,0 +1,18 @@
1
+ require File.expand_path('../lib/pswp-rails/version', __FILE__)
2
+
3
+ # frozen_string_literal: true
4
+ Gem::Specification.new do |s|
5
+ s.name = 'pswp-rails'
6
+ s.version = PhotoSwipe::VERSION
7
+ s.author = 'Yaroslav Konoplov'
8
+ s.email = 'eahome00@gmail.com'
9
+ s.summary = 'PhotoSwipe image gallery (github.com/dimsemenov/PhotoSwipe) integration with Rails asset pipeline.'
10
+ s.description = 'PhotoSwipe image gallery (github.com/dimsemenov/PhotoSwipe) integration with Rails asset pipeline.'
11
+ s.homepage = 'https://github.com/yivo/pswp-rails'
12
+ s.license = 'MIT'
13
+
14
+ s.executables = `git ls-files -z -- bin/*`.split("\x0").map{ |f| File.basename(f) }
15
+ s.files = `git ls-files -z`.split("\x0")
16
+ s.test_files = `git ls-files -z -- {test,spec,features}/*`.split("\x0")
17
+ s.require_paths = ['lib']
18
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014-2016 Dmitry Semenov, http://dimsemenov.com
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>app</key>
6
+ <string>com.bohemiancoding.sketch3</string>
7
+ <key>build</key>
8
+ <integer>7574</integer>
9
+ <key>commit</key>
10
+ <string>8099b4f0b25d32201a4f1a171811eda68e6b1bd1</string>
11
+ <key>fonts</key>
12
+ <array/>
13
+ <key>length</key>
14
+ <integer>57208</integer>
15
+ <key>version</key>
16
+ <integer>36</integer>
17
+ </dict>
18
+ </plist>
@@ -0,0 +1 @@
1
+ <svg width="264" height="88" viewBox="0 0 264 88" xmlns="http://www.w3.org/2000/svg"><title>default-skin 2</title><g fill="none" fill-rule="evenodd"><g><path d="M67.002 59.5v3.768c-6.307.84-9.184 5.75-10.002 9.732 2.22-2.83 5.564-5.098 10.002-5.098V71.5L73 65.585 67.002 59.5z" id="Shape" fill="#fff"/><g fill="#fff"><path d="M13 29v-5h2v3h3v2h-5zM13 15h5v2h-3v3h-2v-5zM31 15v5h-2v-3h-3v-2h5zM31 29h-5v-2h3v-3h2v5z" id="Shape"/></g><g fill="#fff"><path d="M62 24v5h-2v-3h-3v-2h5zM62 20h-5v-2h3v-3h2v5zM70 20v-5h2v3h3v2h-5zM70 24h5v2h-3v3h-2v-5z"/></g><path d="M20.586 66l-5.656-5.656 1.414-1.414L22 64.586l5.656-5.656 1.414 1.414L23.414 66l5.656 5.656-1.414 1.414L22 67.414l-5.656 5.656-1.414-1.414L20.586 66z" fill="#fff"/><path d="M111.785 65.03L110 63.5l3-3.5h-10v-2h10l-3-3.5 1.785-1.468L117 59l-5.215 6.03z" fill="#fff"/><path d="M152.215 65.03L154 63.5l-3-3.5h10v-2h-10l3-3.5-1.785-1.468L147 59l5.215 6.03z" fill="#fff"/><g><path id="Rectangle-11" fill="#fff" d="M160.957 28.543l-3.25-3.25-1.413 1.414 3.25 3.25z"/><path d="M152.5 27c3.038 0 5.5-2.462 5.5-5.5s-2.462-5.5-5.5-5.5-5.5 2.462-5.5 5.5 2.462 5.5 5.5 5.5z" id="Oval-1" stroke="#fff" stroke-width="1.5"/><path fill="#fff" d="M150 21h5v1h-5z"/></g><g><path d="M116.957 28.543l-1.414 1.414-3.25-3.25 1.414-1.414 3.25 3.25z" fill="#fff"/><path d="M108.5 27c3.038 0 5.5-2.462 5.5-5.5s-2.462-5.5-5.5-5.5-5.5 2.462-5.5 5.5 2.462 5.5 5.5 5.5z" stroke="#fff" stroke-width="1.5"/><path fill="#fff" d="M106 21h5v1h-5z"/><path fill="#fff" d="M109.043 19.008l-.085 5-1-.017.085-5z"/></g></g></g></svg>
@@ -0,0 +1,2 @@
1
+ //= require ./photoswipe/photoswipe.js
2
+ //= require ./photoswipe/photoswipe-ui-default.js
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014-2016 Dmitry Semenov, http://dimsemenov.com
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ //= require ./photoswipe.js
2
+ //= require ./photoswipe-ui-default.js
@@ -0,0 +1,861 @@
1
+ /*! PhotoSwipe Default UI - 4.1.1 - 2015-12-24
2
+ * http://photoswipe.com
3
+ * Copyright (c) 2015 Dmitry Semenov; */
4
+ /**
5
+ *
6
+ * UI on top of main sliding area (caption, arrows, close button, etc.).
7
+ * Built just using public methods/properties of PhotoSwipe.
8
+ *
9
+ */
10
+ (function (root, factory) {
11
+ if (typeof define === 'function' && define.amd) {
12
+ define(factory);
13
+ } else if (typeof exports === 'object') {
14
+ module.exports = factory();
15
+ } else {
16
+ root.PhotoSwipeUI_Default = factory();
17
+ }
18
+ })(this, function () {
19
+
20
+ 'use strict';
21
+
22
+
23
+
24
+ var PhotoSwipeUI_Default =
25
+ function(pswp, framework) {
26
+
27
+ var ui = this;
28
+ var _overlayUIUpdated = false,
29
+ _controlsVisible = true,
30
+ _fullscrenAPI,
31
+ _controls,
32
+ _captionContainer,
33
+ _fakeCaptionContainer,
34
+ _indexIndicator,
35
+ _shareButton,
36
+ _shareModal,
37
+ _shareModalHidden = true,
38
+ _initalCloseOnScrollValue,
39
+ _isIdle,
40
+ _listen,
41
+
42
+ _loadingIndicator,
43
+ _loadingIndicatorHidden,
44
+ _loadingIndicatorTimeout,
45
+
46
+ _galleryHasOneSlide,
47
+
48
+ _options,
49
+ _defaultUIOptions = {
50
+ barsSize: {top:44, bottom:'auto'},
51
+ closeElClasses: ['item', 'caption', 'zoom-wrap', 'ui', 'top-bar'],
52
+ timeToIdle: 4000,
53
+ timeToIdleOutside: 1000,
54
+ loadingIndicatorDelay: 1000, // 2s
55
+
56
+ addCaptionHTMLFn: function(item, captionEl /*, isFake */) {
57
+ if(!item.title) {
58
+ captionEl.children[0].innerHTML = '';
59
+ return false;
60
+ }
61
+ captionEl.children[0].innerHTML = item.title;
62
+ return true;
63
+ },
64
+
65
+ closeEl:true,
66
+ captionEl: true,
67
+ fullscreenEl: true,
68
+ zoomEl: true,
69
+ shareEl: true,
70
+ counterEl: true,
71
+ arrowEl: true,
72
+ preloaderEl: true,
73
+
74
+ tapToClose: false,
75
+ tapToToggleControls: true,
76
+
77
+ clickToCloseNonZoomable: true,
78
+
79
+ shareButtons: [
80
+ {id:'facebook', label:'Share on Facebook', url:'https://www.facebook.com/sharer/sharer.php?u={{url}}'},
81
+ {id:'twitter', label:'Tweet', url:'https://twitter.com/intent/tweet?text={{text}}&url={{url}}'},
82
+ {id:'pinterest', label:'Pin it', url:'http://www.pinterest.com/pin/create/button/'+
83
+ '?url={{url}}&media={{image_url}}&description={{text}}'},
84
+ {id:'download', label:'Download image', url:'{{raw_image_url}}', download:true}
85
+ ],
86
+ getImageURLForShare: function( /* shareButtonData */ ) {
87
+ return pswp.currItem.src || '';
88
+ },
89
+ getPageURLForShare: function( /* shareButtonData */ ) {
90
+ return window.location.href;
91
+ },
92
+ getTextForShare: function( /* shareButtonData */ ) {
93
+ return pswp.currItem.title || '';
94
+ },
95
+
96
+ indexIndicatorSep: ' / ',
97
+ fitControlsWidth: 1200
98
+
99
+ },
100
+ _blockControlsTap,
101
+ _blockControlsTapTimeout;
102
+
103
+
104
+
105
+ var _onControlsTap = function(e) {
106
+ if(_blockControlsTap) {
107
+ return true;
108
+ }
109
+
110
+
111
+ e = e || window.event;
112
+
113
+ if(_options.timeToIdle && _options.mouseUsed && !_isIdle) {
114
+ // reset idle timer
115
+ _onIdleMouseMove();
116
+ }
117
+
118
+
119
+ var target = e.target || e.srcElement,
120
+ uiElement,
121
+ clickedClass = target.getAttribute('class') || '',
122
+ found;
123
+
124
+ for(var i = 0; i < _uiElements.length; i++) {
125
+ uiElement = _uiElements[i];
126
+ if(uiElement.onTap && clickedClass.indexOf('pswp__' + uiElement.name ) > -1 ) {
127
+ uiElement.onTap();
128
+ found = true;
129
+
130
+ }
131
+ }
132
+
133
+ if(found) {
134
+ if(e.stopPropagation) {
135
+ e.stopPropagation();
136
+ }
137
+ _blockControlsTap = true;
138
+
139
+ // Some versions of Android don't prevent ghost click event
140
+ // when preventDefault() was called on touchstart and/or touchend.
141
+ //
142
+ // This happens on v4.3, 4.2, 4.1,
143
+ // older versions strangely work correctly,
144
+ // but just in case we add delay on all of them)
145
+ var tapDelay = framework.features.isOldAndroid ? 600 : 30;
146
+ _blockControlsTapTimeout = setTimeout(function() {
147
+ _blockControlsTap = false;
148
+ }, tapDelay);
149
+ }
150
+
151
+ },
152
+ _fitControlsInViewport = function() {
153
+ return !pswp.likelyTouchDevice || _options.mouseUsed || screen.width > _options.fitControlsWidth;
154
+ },
155
+ _togglePswpClass = function(el, cName, add) {
156
+ framework[ (add ? 'add' : 'remove') + 'Class' ](el, 'pswp__' + cName);
157
+ },
158
+
159
+ // add class when there is just one item in the gallery
160
+ // (by default it hides left/right arrows and 1ofX counter)
161
+ _countNumItems = function() {
162
+ var hasOneSlide = (_options.getNumItemsFn() === 1);
163
+
164
+ if(hasOneSlide !== _galleryHasOneSlide) {
165
+ _togglePswpClass(_controls, 'ui--one-slide', hasOneSlide);
166
+ _galleryHasOneSlide = hasOneSlide;
167
+ }
168
+ },
169
+ _toggleShareModalClass = function() {
170
+ _togglePswpClass(_shareModal, 'share-modal--hidden', _shareModalHidden);
171
+ },
172
+ _toggleShareModal = function() {
173
+
174
+ _shareModalHidden = !_shareModalHidden;
175
+
176
+
177
+ if(!_shareModalHidden) {
178
+ _toggleShareModalClass();
179
+ setTimeout(function() {
180
+ if(!_shareModalHidden) {
181
+ framework.addClass(_shareModal, 'pswp__share-modal--fade-in');
182
+ }
183
+ }, 30);
184
+ } else {
185
+ framework.removeClass(_shareModal, 'pswp__share-modal--fade-in');
186
+ setTimeout(function() {
187
+ if(_shareModalHidden) {
188
+ _toggleShareModalClass();
189
+ }
190
+ }, 300);
191
+ }
192
+
193
+ if(!_shareModalHidden) {
194
+ _updateShareURLs();
195
+ }
196
+ return false;
197
+ },
198
+
199
+ _openWindowPopup = function(e) {
200
+ e = e || window.event;
201
+ var target = e.target || e.srcElement;
202
+
203
+ pswp.shout('shareLinkClick', e, target);
204
+
205
+ if(!target.href) {
206
+ return false;
207
+ }
208
+
209
+ if( target.hasAttribute('download') ) {
210
+ return true;
211
+ }
212
+
213
+ window.open(target.href, 'pswp_share', 'scrollbars=yes,resizable=yes,toolbar=no,'+
214
+ 'location=yes,width=550,height=420,top=100,left=' +
215
+ (window.screen ? Math.round(screen.width / 2 - 275) : 100) );
216
+
217
+ if(!_shareModalHidden) {
218
+ _toggleShareModal();
219
+ }
220
+
221
+ return false;
222
+ },
223
+ _updateShareURLs = function() {
224
+ var shareButtonOut = '',
225
+ shareButtonData,
226
+ shareURL,
227
+ image_url,
228
+ page_url,
229
+ share_text;
230
+
231
+ for(var i = 0; i < _options.shareButtons.length; i++) {
232
+ shareButtonData = _options.shareButtons[i];
233
+
234
+ image_url = _options.getImageURLForShare(shareButtonData);
235
+ page_url = _options.getPageURLForShare(shareButtonData);
236
+ share_text = _options.getTextForShare(shareButtonData);
237
+
238
+ shareURL = shareButtonData.url.replace('{{url}}', encodeURIComponent(page_url) )
239
+ .replace('{{image_url}}', encodeURIComponent(image_url) )
240
+ .replace('{{raw_image_url}}', image_url )
241
+ .replace('{{text}}', encodeURIComponent(share_text) );
242
+
243
+ shareButtonOut += '<a href="' + shareURL + '" target="_blank" '+
244
+ 'class="pswp__share--' + shareButtonData.id + '"' +
245
+ (shareButtonData.download ? 'download' : '') + '>' +
246
+ shareButtonData.label + '</a>';
247
+
248
+ if(_options.parseShareButtonOut) {
249
+ shareButtonOut = _options.parseShareButtonOut(shareButtonData, shareButtonOut);
250
+ }
251
+ }
252
+ _shareModal.children[0].innerHTML = shareButtonOut;
253
+ _shareModal.children[0].onclick = _openWindowPopup;
254
+
255
+ },
256
+ _hasCloseClass = function(target) {
257
+ for(var i = 0; i < _options.closeElClasses.length; i++) {
258
+ if( framework.hasClass(target, 'pswp__' + _options.closeElClasses[i]) ) {
259
+ return true;
260
+ }
261
+ }
262
+ },
263
+ _idleInterval,
264
+ _idleTimer,
265
+ _idleIncrement = 0,
266
+ _onIdleMouseMove = function() {
267
+ clearTimeout(_idleTimer);
268
+ _idleIncrement = 0;
269
+ if(_isIdle) {
270
+ ui.setIdle(false);
271
+ }
272
+ },
273
+ _onMouseLeaveWindow = function(e) {
274
+ e = e ? e : window.event;
275
+ var from = e.relatedTarget || e.toElement;
276
+ if (!from || from.nodeName === 'HTML') {
277
+ clearTimeout(_idleTimer);
278
+ _idleTimer = setTimeout(function() {
279
+ ui.setIdle(true);
280
+ }, _options.timeToIdleOutside);
281
+ }
282
+ },
283
+ _setupFullscreenAPI = function() {
284
+ if(_options.fullscreenEl && !framework.features.isOldAndroid) {
285
+ if(!_fullscrenAPI) {
286
+ _fullscrenAPI = ui.getFullscreenAPI();
287
+ }
288
+ if(_fullscrenAPI) {
289
+ framework.bind(document, _fullscrenAPI.eventK, ui.updateFullscreen);
290
+ ui.updateFullscreen();
291
+ framework.addClass(pswp.template, 'pswp--supports-fs');
292
+ } else {
293
+ framework.removeClass(pswp.template, 'pswp--supports-fs');
294
+ }
295
+ }
296
+ },
297
+ _setupLoadingIndicator = function() {
298
+ // Setup loading indicator
299
+ if(_options.preloaderEl) {
300
+
301
+ _toggleLoadingIndicator(true);
302
+
303
+ _listen('beforeChange', function() {
304
+
305
+ clearTimeout(_loadingIndicatorTimeout);
306
+
307
+ // display loading indicator with delay
308
+ _loadingIndicatorTimeout = setTimeout(function() {
309
+
310
+ if(pswp.currItem && pswp.currItem.loading) {
311
+
312
+ if( !pswp.allowProgressiveImg() || (pswp.currItem.img && !pswp.currItem.img.naturalWidth) ) {
313
+ // show preloader if progressive loading is not enabled,
314
+ // or image width is not defined yet (because of slow connection)
315
+ _toggleLoadingIndicator(false);
316
+ // items-controller.js function allowProgressiveImg
317
+ }
318
+
319
+ } else {
320
+ _toggleLoadingIndicator(true); // hide preloader
321
+ }
322
+
323
+ }, _options.loadingIndicatorDelay);
324
+
325
+ });
326
+ _listen('imageLoadComplete', function(index, item) {
327
+ if(pswp.currItem === item) {
328
+ _toggleLoadingIndicator(true);
329
+ }
330
+ });
331
+
332
+ }
333
+ },
334
+ _toggleLoadingIndicator = function(hide) {
335
+ if( _loadingIndicatorHidden !== hide ) {
336
+ _togglePswpClass(_loadingIndicator, 'preloader--active', !hide);
337
+ _loadingIndicatorHidden = hide;
338
+ }
339
+ },
340
+ _applyNavBarGaps = function(item) {
341
+ var gap = item.vGap;
342
+
343
+ if( _fitControlsInViewport() ) {
344
+
345
+ var bars = _options.barsSize;
346
+ if(_options.captionEl && bars.bottom === 'auto') {
347
+ if(!_fakeCaptionContainer) {
348
+ _fakeCaptionContainer = framework.createEl('pswp__caption pswp__caption--fake');
349
+ _fakeCaptionContainer.appendChild( framework.createEl('pswp__caption__center') );
350
+ _controls.insertBefore(_fakeCaptionContainer, _captionContainer);
351
+ framework.addClass(_controls, 'pswp__ui--fit');
352
+ }
353
+ if( _options.addCaptionHTMLFn(item, _fakeCaptionContainer, true) ) {
354
+
355
+ var captionSize = _fakeCaptionContainer.clientHeight;
356
+ gap.bottom = parseInt(captionSize,10) || 44;
357
+ } else {
358
+ gap.bottom = bars.top; // if no caption, set size of bottom gap to size of top
359
+ }
360
+ } else {
361
+ gap.bottom = bars.bottom === 'auto' ? 0 : bars.bottom;
362
+ }
363
+
364
+ // height of top bar is static, no need to calculate it
365
+ gap.top = bars.top;
366
+ } else {
367
+ gap.top = gap.bottom = 0;
368
+ }
369
+ },
370
+ _setupIdle = function() {
371
+ // Hide controls when mouse is used
372
+ if(_options.timeToIdle) {
373
+ _listen('mouseUsed', function() {
374
+
375
+ framework.bind(document, 'mousemove', _onIdleMouseMove);
376
+ framework.bind(document, 'mouseout', _onMouseLeaveWindow);
377
+
378
+ _idleInterval = setInterval(function() {
379
+ _idleIncrement++;
380
+ if(_idleIncrement === 2) {
381
+ ui.setIdle(true);
382
+ }
383
+ }, _options.timeToIdle / 2);
384
+ });
385
+ }
386
+ },
387
+ _setupHidingControlsDuringGestures = function() {
388
+
389
+ // Hide controls on vertical drag
390
+ _listen('onVerticalDrag', function(now) {
391
+ if(_controlsVisible && now < 0.95) {
392
+ ui.hideControls();
393
+ } else if(!_controlsVisible && now >= 0.95) {
394
+ ui.showControls();
395
+ }
396
+ });
397
+
398
+ // Hide controls when pinching to close
399
+ var pinchControlsHidden;
400
+ _listen('onPinchClose' , function(now) {
401
+ if(_controlsVisible && now < 0.9) {
402
+ ui.hideControls();
403
+ pinchControlsHidden = true;
404
+ } else if(pinchControlsHidden && !_controlsVisible && now > 0.9) {
405
+ ui.showControls();
406
+ }
407
+ });
408
+
409
+ _listen('zoomGestureEnded', function() {
410
+ pinchControlsHidden = false;
411
+ if(pinchControlsHidden && !_controlsVisible) {
412
+ ui.showControls();
413
+ }
414
+ });
415
+
416
+ };
417
+
418
+
419
+
420
+ var _uiElements = [
421
+ {
422
+ name: 'caption',
423
+ option: 'captionEl',
424
+ onInit: function(el) {
425
+ _captionContainer = el;
426
+ }
427
+ },
428
+ {
429
+ name: 'share-modal',
430
+ option: 'shareEl',
431
+ onInit: function(el) {
432
+ _shareModal = el;
433
+ },
434
+ onTap: function() {
435
+ _toggleShareModal();
436
+ }
437
+ },
438
+ {
439
+ name: 'button--share',
440
+ option: 'shareEl',
441
+ onInit: function(el) {
442
+ _shareButton = el;
443
+ },
444
+ onTap: function() {
445
+ _toggleShareModal();
446
+ }
447
+ },
448
+ {
449
+ name: 'button--zoom',
450
+ option: 'zoomEl',
451
+ onTap: pswp.toggleDesktopZoom
452
+ },
453
+ {
454
+ name: 'counter',
455
+ option: 'counterEl',
456
+ onInit: function(el) {
457
+ _indexIndicator = el;
458
+ }
459
+ },
460
+ {
461
+ name: 'button--close',
462
+ option: 'closeEl',
463
+ onTap: pswp.close
464
+ },
465
+ {
466
+ name: 'button--arrow--left',
467
+ option: 'arrowEl',
468
+ onTap: pswp.prev
469
+ },
470
+ {
471
+ name: 'button--arrow--right',
472
+ option: 'arrowEl',
473
+ onTap: pswp.next
474
+ },
475
+ {
476
+ name: 'button--fs',
477
+ option: 'fullscreenEl',
478
+ onTap: function() {
479
+ if(_fullscrenAPI.isFullscreen()) {
480
+ _fullscrenAPI.exit();
481
+ } else {
482
+ _fullscrenAPI.enter();
483
+ }
484
+ }
485
+ },
486
+ {
487
+ name: 'preloader',
488
+ option: 'preloaderEl',
489
+ onInit: function(el) {
490
+ _loadingIndicator = el;
491
+ }
492
+ }
493
+
494
+ ];
495
+
496
+ var _setupUIElements = function() {
497
+ var item,
498
+ classAttr,
499
+ uiElement;
500
+
501
+ var loopThroughChildElements = function(sChildren) {
502
+ if(!sChildren) {
503
+ return;
504
+ }
505
+
506
+ var l = sChildren.length;
507
+ for(var i = 0; i < l; i++) {
508
+ item = sChildren[i];
509
+ classAttr = item.className;
510
+
511
+ for(var a = 0; a < _uiElements.length; a++) {
512
+ uiElement = _uiElements[a];
513
+
514
+ if(classAttr.indexOf('pswp__' + uiElement.name) > -1 ) {
515
+
516
+ if( _options[uiElement.option] ) { // if element is not disabled from options
517
+
518
+ framework.removeClass(item, 'pswp__element--disabled');
519
+ if(uiElement.onInit) {
520
+ uiElement.onInit(item);
521
+ }
522
+
523
+ //item.style.display = 'block';
524
+ } else {
525
+ framework.addClass(item, 'pswp__element--disabled');
526
+ //item.style.display = 'none';
527
+ }
528
+ }
529
+ }
530
+ }
531
+ };
532
+ loopThroughChildElements(_controls.children);
533
+
534
+ var topBar = framework.getChildByClass(_controls, 'pswp__top-bar');
535
+ if(topBar) {
536
+ loopThroughChildElements( topBar.children );
537
+ }
538
+ };
539
+
540
+
541
+
542
+
543
+ ui.init = function() {
544
+
545
+ // extend options
546
+ framework.extend(pswp.options, _defaultUIOptions, true);
547
+
548
+ // create local link for fast access
549
+ _options = pswp.options;
550
+
551
+ // find pswp__ui element
552
+ _controls = framework.getChildByClass(pswp.scrollWrap, 'pswp__ui');
553
+
554
+ // create local link
555
+ _listen = pswp.listen;
556
+
557
+
558
+ _setupHidingControlsDuringGestures();
559
+
560
+ // update controls when slides change
561
+ _listen('beforeChange', ui.update);
562
+
563
+ // toggle zoom on double-tap
564
+ _listen('doubleTap', function(point) {
565
+ var initialZoomLevel = pswp.currItem.initialZoomLevel;
566
+ if(pswp.getZoomLevel() !== initialZoomLevel) {
567
+ pswp.zoomTo(initialZoomLevel, point, 333);
568
+ } else {
569
+ pswp.zoomTo(_options.getDoubleTapZoom(false, pswp.currItem), point, 333);
570
+ }
571
+ });
572
+
573
+ // Allow text selection in caption
574
+ _listen('preventDragEvent', function(e, isDown, preventObj) {
575
+ var t = e.target || e.srcElement;
576
+ if(
577
+ t &&
578
+ t.getAttribute('class') && e.type.indexOf('mouse') > -1 &&
579
+ ( t.getAttribute('class').indexOf('__caption') > 0 || (/(SMALL|STRONG|EM)/i).test(t.tagName) )
580
+ ) {
581
+ preventObj.prevent = false;
582
+ }
583
+ });
584
+
585
+ // bind events for UI
586
+ _listen('bindEvents', function() {
587
+ framework.bind(_controls, 'pswpTap click', _onControlsTap);
588
+ framework.bind(pswp.scrollWrap, 'pswpTap', ui.onGlobalTap);
589
+
590
+ if(!pswp.likelyTouchDevice) {
591
+ framework.bind(pswp.scrollWrap, 'mouseover', ui.onMouseOver);
592
+ }
593
+ });
594
+
595
+ // unbind events for UI
596
+ _listen('unbindEvents', function() {
597
+ if(!_shareModalHidden) {
598
+ _toggleShareModal();
599
+ }
600
+
601
+ if(_idleInterval) {
602
+ clearInterval(_idleInterval);
603
+ }
604
+ framework.unbind(document, 'mouseout', _onMouseLeaveWindow);
605
+ framework.unbind(document, 'mousemove', _onIdleMouseMove);
606
+ framework.unbind(_controls, 'pswpTap click', _onControlsTap);
607
+ framework.unbind(pswp.scrollWrap, 'pswpTap', ui.onGlobalTap);
608
+ framework.unbind(pswp.scrollWrap, 'mouseover', ui.onMouseOver);
609
+
610
+ if(_fullscrenAPI) {
611
+ framework.unbind(document, _fullscrenAPI.eventK, ui.updateFullscreen);
612
+ if(_fullscrenAPI.isFullscreen()) {
613
+ _options.hideAnimationDuration = 0;
614
+ _fullscrenAPI.exit();
615
+ }
616
+ _fullscrenAPI = null;
617
+ }
618
+ });
619
+
620
+
621
+ // clean up things when gallery is destroyed
622
+ _listen('destroy', function() {
623
+ if(_options.captionEl) {
624
+ if(_fakeCaptionContainer) {
625
+ _controls.removeChild(_fakeCaptionContainer);
626
+ }
627
+ framework.removeClass(_captionContainer, 'pswp__caption--empty');
628
+ }
629
+
630
+ if(_shareModal) {
631
+ _shareModal.children[0].onclick = null;
632
+ }
633
+ framework.removeClass(_controls, 'pswp__ui--over-close');
634
+ framework.addClass( _controls, 'pswp__ui--hidden');
635
+ ui.setIdle(false);
636
+ });
637
+
638
+
639
+ if(!_options.showAnimationDuration) {
640
+ framework.removeClass( _controls, 'pswp__ui--hidden');
641
+ }
642
+ _listen('initialZoomIn', function() {
643
+ if(_options.showAnimationDuration) {
644
+ framework.removeClass( _controls, 'pswp__ui--hidden');
645
+ }
646
+ });
647
+ _listen('initialZoomOut', function() {
648
+ framework.addClass( _controls, 'pswp__ui--hidden');
649
+ });
650
+
651
+ _listen('parseVerticalMargin', _applyNavBarGaps);
652
+
653
+ _setupUIElements();
654
+
655
+ if(_options.shareEl && _shareButton && _shareModal) {
656
+ _shareModalHidden = true;
657
+ }
658
+
659
+ _countNumItems();
660
+
661
+ _setupIdle();
662
+
663
+ _setupFullscreenAPI();
664
+
665
+ _setupLoadingIndicator();
666
+ };
667
+
668
+ ui.setIdle = function(isIdle) {
669
+ _isIdle = isIdle;
670
+ _togglePswpClass(_controls, 'ui--idle', isIdle);
671
+ };
672
+
673
+ ui.update = function() {
674
+ // Don't update UI if it's hidden
675
+ if(_controlsVisible && pswp.currItem) {
676
+
677
+ ui.updateIndexIndicator();
678
+
679
+ if(_options.captionEl) {
680
+ _options.addCaptionHTMLFn(pswp.currItem, _captionContainer);
681
+
682
+ _togglePswpClass(_captionContainer, 'caption--empty', !pswp.currItem.title);
683
+ }
684
+
685
+ _overlayUIUpdated = true;
686
+
687
+ } else {
688
+ _overlayUIUpdated = false;
689
+ }
690
+
691
+ if(!_shareModalHidden) {
692
+ _toggleShareModal();
693
+ }
694
+
695
+ _countNumItems();
696
+ };
697
+
698
+ ui.updateFullscreen = function(e) {
699
+
700
+ if(e) {
701
+ // some browsers change window scroll position during the fullscreen
702
+ // so PhotoSwipe updates it just in case
703
+ setTimeout(function() {
704
+ pswp.setScrollOffset( 0, framework.getScrollY() );
705
+ }, 50);
706
+ }
707
+
708
+ // toogle pswp--fs class on root element
709
+ framework[ (_fullscrenAPI.isFullscreen() ? 'add' : 'remove') + 'Class' ](pswp.template, 'pswp--fs');
710
+ };
711
+
712
+ ui.updateIndexIndicator = function() {
713
+ if(_options.counterEl) {
714
+ _indexIndicator.innerHTML = (pswp.getCurrentIndex()+1) +
715
+ _options.indexIndicatorSep +
716
+ _options.getNumItemsFn();
717
+ }
718
+ };
719
+
720
+ ui.onGlobalTap = function(e) {
721
+ e = e || window.event;
722
+ var target = e.target || e.srcElement;
723
+
724
+ if(_blockControlsTap) {
725
+ return;
726
+ }
727
+
728
+ if(e.detail && e.detail.pointerType === 'mouse') {
729
+
730
+ // close gallery if clicked outside of the image
731
+ if(_hasCloseClass(target)) {
732
+ pswp.close();
733
+ return;
734
+ }
735
+
736
+ if(framework.hasClass(target, 'pswp__img')) {
737
+ if(pswp.getZoomLevel() === 1 && pswp.getZoomLevel() <= pswp.currItem.fitRatio) {
738
+ if(_options.clickToCloseNonZoomable) {
739
+ pswp.close();
740
+ }
741
+ } else {
742
+ pswp.toggleDesktopZoom(e.detail.releasePoint);
743
+ }
744
+ }
745
+
746
+ } else {
747
+
748
+ // tap anywhere (except buttons) to toggle visibility of controls
749
+ if(_options.tapToToggleControls) {
750
+ if(_controlsVisible) {
751
+ ui.hideControls();
752
+ } else {
753
+ ui.showControls();
754
+ }
755
+ }
756
+
757
+ // tap to close gallery
758
+ if(_options.tapToClose && (framework.hasClass(target, 'pswp__img') || _hasCloseClass(target)) ) {
759
+ pswp.close();
760
+ return;
761
+ }
762
+
763
+ }
764
+ };
765
+ ui.onMouseOver = function(e) {
766
+ e = e || window.event;
767
+ var target = e.target || e.srcElement;
768
+
769
+ // add class when mouse is over an element that should close the gallery
770
+ _togglePswpClass(_controls, 'ui--over-close', _hasCloseClass(target));
771
+ };
772
+
773
+ ui.hideControls = function() {
774
+ framework.addClass(_controls,'pswp__ui--hidden');
775
+ _controlsVisible = false;
776
+ };
777
+
778
+ ui.showControls = function() {
779
+ _controlsVisible = true;
780
+ if(!_overlayUIUpdated) {
781
+ ui.update();
782
+ }
783
+ framework.removeClass(_controls,'pswp__ui--hidden');
784
+ };
785
+
786
+ ui.supportsFullscreen = function() {
787
+ var d = document;
788
+ return !!(d.exitFullscreen || d.mozCancelFullScreen || d.webkitExitFullscreen || d.msExitFullscreen);
789
+ };
790
+
791
+ ui.getFullscreenAPI = function() {
792
+ var dE = document.documentElement,
793
+ api,
794
+ tF = 'fullscreenchange';
795
+
796
+ if (dE.requestFullscreen) {
797
+ api = {
798
+ enterK: 'requestFullscreen',
799
+ exitK: 'exitFullscreen',
800
+ elementK: 'fullscreenElement',
801
+ eventK: tF
802
+ };
803
+
804
+ } else if(dE.mozRequestFullScreen ) {
805
+ api = {
806
+ enterK: 'mozRequestFullScreen',
807
+ exitK: 'mozCancelFullScreen',
808
+ elementK: 'mozFullScreenElement',
809
+ eventK: 'moz' + tF
810
+ };
811
+
812
+
813
+
814
+ } else if(dE.webkitRequestFullscreen) {
815
+ api = {
816
+ enterK: 'webkitRequestFullscreen',
817
+ exitK: 'webkitExitFullscreen',
818
+ elementK: 'webkitFullscreenElement',
819
+ eventK: 'webkit' + tF
820
+ };
821
+
822
+ } else if(dE.msRequestFullscreen) {
823
+ api = {
824
+ enterK: 'msRequestFullscreen',
825
+ exitK: 'msExitFullscreen',
826
+ elementK: 'msFullscreenElement',
827
+ eventK: 'MSFullscreenChange'
828
+ };
829
+ }
830
+
831
+ if(api) {
832
+ api.enter = function() {
833
+ // disable close-on-scroll in fullscreen
834
+ _initalCloseOnScrollValue = _options.closeOnScroll;
835
+ _options.closeOnScroll = false;
836
+
837
+ if(this.enterK === 'webkitRequestFullscreen') {
838
+ pswp.template[this.enterK]( Element.ALLOW_KEYBOARD_INPUT );
839
+ } else {
840
+ return pswp.template[this.enterK]();
841
+ }
842
+ };
843
+ api.exit = function() {
844
+ _options.closeOnScroll = _initalCloseOnScrollValue;
845
+
846
+ return document[this.exitK]();
847
+
848
+ };
849
+ api.isFullscreen = function() { return document[this.elementK]; };
850
+ }
851
+
852
+ return api;
853
+ };
854
+
855
+
856
+
857
+ };
858
+ return PhotoSwipeUI_Default;
859
+
860
+
861
+ });