assets-rails 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/README.md +13 -9
- data/assets-rails.gemspec +2 -0
- data/lib/assets-rails/engine.rb +3 -1
- data/lib/assets-rails/version.rb +1 -1
- data/vendor/assets/fonts/lightgallery/Slide-icons.dev.svg +33 -0
- data/vendor/assets/fonts/lightgallery/Slide-icons.eot +0 -0
- data/vendor/assets/fonts/lightgallery/Slide-icons.svg +33 -0
- data/vendor/assets/fonts/lightgallery/Slide-icons.ttf +0 -0
- data/vendor/assets/fonts/lightgallery/Slide-icons.woff +0 -0
- data/vendor/assets/fonts/photoswipe/v4.0.0/default-skin/default-skin.svg +38 -0
- data/vendor/assets/fonts/photoswipe/v4.0.2/default-skin/default-skin.svg +1 -0
- data/vendor/assets/images/jquery.share/social-icons-sprite.png +0 -0
- data/vendor/assets/images/jquery.share/social-icons.png +0 -0
- data/vendor/assets/images/lightgallery/loading.gif +0 -0
- data/vendor/assets/images/photoswipe/v4.0.0/default-skin/default-skin.png +0 -0
- data/vendor/assets/images/photoswipe/v4.0.0/default-skin/preloader.gif +0 -0
- data/vendor/assets/images/photoswipe/v4.0.2/default-skin/default-skin.png +0 -0
- data/vendor/assets/images/photoswipe/v4.0.2/default-skin/preloader.gif +0 -0
- data/vendor/assets/javascripts/imagesloaded/v3.1.8.js +1 -1
- data/vendor/assets/javascripts/imagesloaded/v3.1.8/imagesloaded.js +561 -3
- data/vendor/assets/javascripts/jquery.cookie/v1.4.1.js +2 -0
- data/vendor/assets/javascripts/jquery.cookie/v1.4.1/jquery.cookie.js +117 -0
- data/vendor/assets/javascripts/jquery.share.js +1 -0
- data/vendor/assets/javascripts/jquery.share/jquery.share.js +137 -0
- data/vendor/assets/javascripts/jquery.zoom/v1.7.13.js +1 -0
- data/vendor/assets/javascripts/jquery.zoom/v1.7.13/jquery.zoom.js +233 -0
- data/vendor/assets/javascripts/lightgallery/v1.1.4.js +1 -0
- data/vendor/assets/javascripts/lightgallery/v1.1.4/lightgallery.min.js +11 -0
- data/vendor/assets/javascripts/photoswipe/v4.0.0.js +2 -0
- data/vendor/assets/javascripts/photoswipe/v4.0.0/photoswipe-ui-default.js +824 -0
- data/vendor/assets/javascripts/photoswipe/v4.0.0/photoswipe.js +3647 -0
- data/vendor/assets/javascripts/photoswipe/v4.0.2.js +2 -0
- data/vendor/assets/javascripts/photoswipe/v4.0.2/photoswipe-ui-default.js +792 -0
- data/vendor/assets/javascripts/photoswipe/v4.0.2/photoswipe.js +3589 -0
- data/vendor/assets/stylesheets/font-awesome/v4.2.0/_variables.scss +1 -1
- data/vendor/assets/stylesheets/jquery.collageplus/v0.3.3/transitions.css +202 -0
- data/vendor/assets/stylesheets/jquery.share.css +3 -0
- data/vendor/assets/stylesheets/jquery.share/jquery.share.scss +215 -0
- data/vendor/assets/stylesheets/lightgallery/v1.1.4/lightgallery.scss +629 -0
- data/vendor/assets/stylesheets/photoswipe/v4.0.0.css +3 -0
- data/vendor/assets/stylesheets/photoswipe/v4.0.0/default-skin.scss +418 -0
- data/vendor/assets/stylesheets/photoswipe/v4.0.0/photoswipe.css +125 -0
- data/vendor/assets/stylesheets/photoswipe/v4.0.2.css +3 -0
- data/vendor/assets/stylesheets/photoswipe/v4.0.2/default-skin.scss +390 -0
- data/vendor/assets/stylesheets/photoswipe/v4.0.2/photoswipe.css +148 -0
- metadata +43 -5
@@ -0,0 +1,792 @@
|
|
1
|
+
/*! PhotoSwipe Default UI - 4.0.2 - 2014-12-28
|
2
|
+
* http://photoswipe.com
|
3
|
+
* Copyright (c) 2014 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
|
+
|
28
|
+
var ui = this;
|
29
|
+
var _overlayUIUpdated = false,
|
30
|
+
_controlsVisible = true,
|
31
|
+
_fullscrenAPI,
|
32
|
+
_controls,
|
33
|
+
_captionContainer,
|
34
|
+
_fakeCaptionContainer,
|
35
|
+
_indexIndicator,
|
36
|
+
_shareButton,
|
37
|
+
_shareModal,
|
38
|
+
_shareModalHidden = true,
|
39
|
+
_initalCloseOnScrollValue,
|
40
|
+
_isIdle,
|
41
|
+
_listen,
|
42
|
+
|
43
|
+
_loadingIndicator,
|
44
|
+
_loadingIndicatorHidden,
|
45
|
+
_loadingIndicatorTimeout,
|
46
|
+
|
47
|
+
_options = {
|
48
|
+
barsSize: {top:44, bottom:'auto'},
|
49
|
+
closeElClasses: ['item', 'caption', 'zoom-wrap', 'ui', 'top-bar'],
|
50
|
+
timeToIdle: 4000,
|
51
|
+
timeToIdleOutside: 1000,
|
52
|
+
loadingIndicatorDelay: 1000, // 2s
|
53
|
+
|
54
|
+
addCaptionHTMLFn: function(item, captionEl /*, isFake */) {
|
55
|
+
if(!item.title) {
|
56
|
+
captionEl.children[0].innerHTML = '';
|
57
|
+
return false;
|
58
|
+
}
|
59
|
+
captionEl.children[0].innerHTML = item.title;
|
60
|
+
return true;
|
61
|
+
},
|
62
|
+
|
63
|
+
closeEl:true,
|
64
|
+
captionEl: true,
|
65
|
+
fullscreenEl: true,
|
66
|
+
zoomEl: true,
|
67
|
+
shareEl: true,
|
68
|
+
counterEl: true,
|
69
|
+
arrowEl: true,
|
70
|
+
preloaderEl: true,
|
71
|
+
|
72
|
+
tapToClose: false,
|
73
|
+
tapToToggleControls: true,
|
74
|
+
|
75
|
+
shareButtons: [
|
76
|
+
{id:'facebook', label:'Share on Facebook', url:'https://www.facebook.com/sharer/sharer.php?u={{url}}'},
|
77
|
+
{id:'twitter', label:'Tweet', url:'https://twitter.com/intent/tweet?text={{text}}&url={{url}}'},
|
78
|
+
{id:'pinterest', label:'Pin it', url:'http://www.pinterest.com/pin/create/button/'+
|
79
|
+
'?url={{url}}&media={{image_url}}&description={{text}}'},
|
80
|
+
{id:'download', label:'Download image', url:'{{raw_image_url}}', download:true}
|
81
|
+
],
|
82
|
+
indexIndicatorSep: ' / '
|
83
|
+
|
84
|
+
},
|
85
|
+
_blockControlsTap,
|
86
|
+
_blockControlsTapTimeout;
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
var _onControlsTap = function(e) {
|
91
|
+
if(_blockControlsTap) {
|
92
|
+
return true;
|
93
|
+
}
|
94
|
+
|
95
|
+
|
96
|
+
e = e || window.event;
|
97
|
+
|
98
|
+
|
99
|
+
var target = e.target || e.srcElement,
|
100
|
+
uiElement,
|
101
|
+
clickedClass = target.className,
|
102
|
+
found;
|
103
|
+
|
104
|
+
for(var i = 0; i < _uiElements.length; i++) {
|
105
|
+
uiElement = _uiElements[i];
|
106
|
+
if(uiElement.onTap && clickedClass.indexOf('pswp__' + uiElement.name ) > -1 ) {
|
107
|
+
uiElement.onTap();
|
108
|
+
found = true;
|
109
|
+
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
if(found) {
|
114
|
+
if(e.stopPropagation) {
|
115
|
+
e.stopPropagation();
|
116
|
+
}
|
117
|
+
_blockControlsTap = true;
|
118
|
+
|
119
|
+
// Some versions of Android don't prevent ghost click event
|
120
|
+
// when preventDefault() was called on touchstart and/or touchend.
|
121
|
+
//
|
122
|
+
// This happens on v4.3, 4.2, 4.1,
|
123
|
+
// older versions strangely work correctly,
|
124
|
+
// but just in case we add delay on all of them)
|
125
|
+
var tapDelay = framework.features.isOldAndroid ? 600 : 30;
|
126
|
+
_blockControlsTapTimeout = setTimeout(function() {
|
127
|
+
_blockControlsTap = false;
|
128
|
+
}, tapDelay);
|
129
|
+
}
|
130
|
+
|
131
|
+
},
|
132
|
+
_fitControlsInViewport = function() {
|
133
|
+
return !pswp.likelyTouchDevice || pswp.options.mouseUsed || screen.width > 1200;
|
134
|
+
},
|
135
|
+
_toggleShareModal = function() {
|
136
|
+
|
137
|
+
_shareModalHidden = !_shareModalHidden;
|
138
|
+
|
139
|
+
|
140
|
+
if(!_shareModalHidden) {
|
141
|
+
framework[ (_shareModalHidden ? 'add' : 'remove') + 'Class'](_shareModal, 'pswp__share-modal--hidden');
|
142
|
+
setTimeout(function() {
|
143
|
+
if(!_shareModalHidden) {
|
144
|
+
framework.addClass(_shareModal, 'pswp__share-modal--fade-in');
|
145
|
+
}
|
146
|
+
}, 30);
|
147
|
+
} else {
|
148
|
+
framework.removeClass(_shareModal, 'pswp__share-modal--fade-in');
|
149
|
+
setTimeout(function() {
|
150
|
+
if(_shareModalHidden) {
|
151
|
+
framework[ (_shareModalHidden ? 'add' : 'remove') + 'Class'](_shareModal, 'pswp__share-modal--hidden');
|
152
|
+
}
|
153
|
+
}, 300);
|
154
|
+
}
|
155
|
+
|
156
|
+
if(!_shareModalHidden) {
|
157
|
+
_updateShareURLs();
|
158
|
+
}
|
159
|
+
return false;
|
160
|
+
},
|
161
|
+
_openWindowPopup = function(e) {
|
162
|
+
e = e || window.event;
|
163
|
+
var target = e.target || e.srcElement;
|
164
|
+
|
165
|
+
if(!target.href) {
|
166
|
+
return false;
|
167
|
+
}
|
168
|
+
|
169
|
+
if( target.hasAttribute('download') ) {
|
170
|
+
return true;
|
171
|
+
}
|
172
|
+
|
173
|
+
window.open(target.href, 'pswp_share', 'scrollbars=yes,resizable=yes,toolbar=no,'+
|
174
|
+
'location=yes,width=550,height=420,top=100,left=' +
|
175
|
+
(window.screen ? Math.round(screen.width / 2 - 275) : 100) );
|
176
|
+
|
177
|
+
if(!_shareModalHidden) {
|
178
|
+
_toggleShareModal();
|
179
|
+
}
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
return false;
|
184
|
+
},
|
185
|
+
_updateShareURLs = function() {
|
186
|
+
var shareButtonOut = '',
|
187
|
+
shareButtonData,
|
188
|
+
shareURL;
|
189
|
+
|
190
|
+
for(var i = 0; i < pswp.options.shareButtons.length; i++) {
|
191
|
+
shareButtonData = pswp.options.shareButtons[i];
|
192
|
+
|
193
|
+
shareURL = shareButtonData.url.replace('{{url}}', encodeURIComponent(window.location.href) )
|
194
|
+
.replace('{{image_url}}', encodeURIComponent(pswp.currItem.src || '') )
|
195
|
+
.replace('{{raw_image_url}}', pswp.currItem.src || '' )
|
196
|
+
.replace('{{text}}', encodeURIComponent(pswp.currItem.title || '') );
|
197
|
+
|
198
|
+
shareButtonOut += '<a href="' + shareURL + '" target="_blank" '+
|
199
|
+
'class="pswp__share--' + shareButtonData.id + '"' +
|
200
|
+
(shareButtonData.download ? 'download' : '') + '>' +
|
201
|
+
shareButtonData.label + '</a>';
|
202
|
+
}
|
203
|
+
_shareModal.children[0].innerHTML = shareButtonOut;
|
204
|
+
_shareModal.children[0].onclick = _openWindowPopup;
|
205
|
+
|
206
|
+
},
|
207
|
+
_hasCloseClass = function(target) {
|
208
|
+
for(var i = 0; i < pswp.options.closeElClasses.length; i++) {
|
209
|
+
if( framework.hasClass(target, 'pswp__' + pswp.options.closeElClasses[i]) ) {
|
210
|
+
return true;
|
211
|
+
}
|
212
|
+
}
|
213
|
+
},
|
214
|
+
_idleInterval,
|
215
|
+
_idleTimer,
|
216
|
+
_idleIncrement = 0,
|
217
|
+
_onIdleMouseMove = function() {
|
218
|
+
clearTimeout(_idleTimer);
|
219
|
+
_idleIncrement = 0;
|
220
|
+
if(_isIdle) {
|
221
|
+
ui.setIdle(false);
|
222
|
+
}
|
223
|
+
},
|
224
|
+
_onMouseLeaveWindow = function(e) {
|
225
|
+
e = e ? e : window.event;
|
226
|
+
var from = e.relatedTarget || e.toElement;
|
227
|
+
if (!from || from.nodeName === 'HTML') {
|
228
|
+
clearTimeout(_idleTimer);
|
229
|
+
_idleTimer = setTimeout(function() {
|
230
|
+
ui.setIdle(true);
|
231
|
+
}, pswp.options.timeToIdleOutside);
|
232
|
+
}
|
233
|
+
},
|
234
|
+
_setupFullscreenAPI = function() {
|
235
|
+
if(pswp.options.fullscreenEl) {
|
236
|
+
if(!_fullscrenAPI) {
|
237
|
+
_fullscrenAPI = ui.getFullscreenAPI();
|
238
|
+
}
|
239
|
+
if(_fullscrenAPI) {
|
240
|
+
framework.bind(document, _fullscrenAPI.eventK, ui.updateFullscreen);
|
241
|
+
ui.updateFullscreen();
|
242
|
+
framework.addClass(pswp.template, 'pswp--supports-fs');
|
243
|
+
} else {
|
244
|
+
framework.removeClass(pswp.template, 'pswp--supports-fs');
|
245
|
+
}
|
246
|
+
}
|
247
|
+
},
|
248
|
+
_setupLoadingIndicator = function() {
|
249
|
+
// Setup loading indicator
|
250
|
+
if(pswp.options.preloaderEl) {
|
251
|
+
|
252
|
+
_toggleLoadingIndicator(true);
|
253
|
+
|
254
|
+
_listen('beforeChange', function() {
|
255
|
+
|
256
|
+
clearTimeout(_loadingIndicatorTimeout);
|
257
|
+
|
258
|
+
// display loading indicator with delay
|
259
|
+
_loadingIndicatorTimeout = setTimeout(function() {
|
260
|
+
|
261
|
+
if(pswp.currItem && pswp.currItem.loading) {
|
262
|
+
|
263
|
+
if( !pswp.allowProgressiveImg() || (pswp.currItem.img && !pswp.currItem.img.naturalWidth) ) {
|
264
|
+
// show preloader if progressive loading is not enabled,
|
265
|
+
// or image width is not defined yet (because of slow connection)
|
266
|
+
_toggleLoadingIndicator(false);
|
267
|
+
// items-controller.js function allowProgressiveImg
|
268
|
+
}
|
269
|
+
|
270
|
+
} else {
|
271
|
+
_toggleLoadingIndicator(true); // hide preloader
|
272
|
+
}
|
273
|
+
|
274
|
+
}, pswp.options.loadingIndicatorDelay);
|
275
|
+
|
276
|
+
});
|
277
|
+
_listen('imageLoadComplete', function(index, item) {
|
278
|
+
if(pswp.currItem === item) {
|
279
|
+
_toggleLoadingIndicator(true);
|
280
|
+
}
|
281
|
+
});
|
282
|
+
|
283
|
+
}
|
284
|
+
},
|
285
|
+
_toggleLoadingIndicator = function(hide) {
|
286
|
+
if( _loadingIndicatorHidden !== hide ) {
|
287
|
+
framework[ (hide ? 'remove' : 'add') + 'Class' ](_loadingIndicator, 'pswp__preloader--active');
|
288
|
+
_loadingIndicatorHidden = hide;
|
289
|
+
}
|
290
|
+
},
|
291
|
+
_applyNavBarGaps = function(item) {
|
292
|
+
var gap = item.vGap;
|
293
|
+
|
294
|
+
if( _fitControlsInViewport() ) {
|
295
|
+
|
296
|
+
var bars = pswp.options.barsSize;
|
297
|
+
if(pswp.options.captionEl && bars.bottom === 'auto') {
|
298
|
+
if(!_fakeCaptionContainer) {
|
299
|
+
_fakeCaptionContainer = framework.createEl('pswp__caption pswp__caption--fake');
|
300
|
+
_fakeCaptionContainer.appendChild( framework.createEl('pswp__caption__center') );
|
301
|
+
_controls.insertBefore(_fakeCaptionContainer, _captionContainer);
|
302
|
+
framework.addClass(_controls, 'pswp__ui--fit');
|
303
|
+
}
|
304
|
+
if( pswp.options.addCaptionHTMLFn(item, _fakeCaptionContainer, true) ) {
|
305
|
+
|
306
|
+
var captionSize = _fakeCaptionContainer.clientHeight;
|
307
|
+
gap.bottom = parseInt(captionSize,10) || 44;
|
308
|
+
} else {
|
309
|
+
gap.bottom = bars.top; // if no caption, set size of bottom gap to size of top
|
310
|
+
}
|
311
|
+
} else {
|
312
|
+
gap.bottom = bars.bottom;
|
313
|
+
}
|
314
|
+
|
315
|
+
// height of top bar is static, no need to calculate it
|
316
|
+
gap.top = bars.top;
|
317
|
+
} else {
|
318
|
+
gap.top = gap.bottom = 0;
|
319
|
+
}
|
320
|
+
},
|
321
|
+
_setupIdle = function() {
|
322
|
+
// Hide controls when mouse is used
|
323
|
+
if(pswp.options.timeToIdle) {
|
324
|
+
_listen('mouseUsed', function() {
|
325
|
+
|
326
|
+
framework.bind(document, 'mousemove', _onIdleMouseMove);
|
327
|
+
framework.bind(document, 'mouseout', _onMouseLeaveWindow);
|
328
|
+
|
329
|
+
_idleInterval = setInterval(function() {
|
330
|
+
_idleIncrement++;
|
331
|
+
if(_idleIncrement === 2) {
|
332
|
+
ui.setIdle(true);
|
333
|
+
}
|
334
|
+
}, pswp.options.timeToIdle / 2);
|
335
|
+
});
|
336
|
+
}
|
337
|
+
},
|
338
|
+
_setupHidingControlsDuringGestures = function() {
|
339
|
+
|
340
|
+
// Hide controls on vertical drag
|
341
|
+
_listen('onVerticalDrag', function(now) {
|
342
|
+
if(_controlsVisible && now < 0.95) {
|
343
|
+
ui.hideControls();
|
344
|
+
} else if(!_controlsVisible && now >= 0.95) {
|
345
|
+
ui.showControls();
|
346
|
+
}
|
347
|
+
});
|
348
|
+
|
349
|
+
// Hide controls when pinching to close
|
350
|
+
var pinchControlsHidden;
|
351
|
+
_listen('onPinchClose' , function(now) {
|
352
|
+
if(_controlsVisible && now < 0.9) {
|
353
|
+
ui.hideControls();
|
354
|
+
pinchControlsHidden = true;
|
355
|
+
} else if(pinchControlsHidden && !_controlsVisible && now > 0.9) {
|
356
|
+
ui.showControls();
|
357
|
+
}
|
358
|
+
});
|
359
|
+
|
360
|
+
_listen('zoomGestureEnded', function() {
|
361
|
+
pinchControlsHidden = false;
|
362
|
+
if(pinchControlsHidden && !_controlsVisible) {
|
363
|
+
ui.showControls();
|
364
|
+
}
|
365
|
+
});
|
366
|
+
|
367
|
+
};
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
var _uiElements = [
|
372
|
+
{
|
373
|
+
name: 'caption',
|
374
|
+
option: 'captionEl',
|
375
|
+
onInit: function(el) {
|
376
|
+
_captionContainer = el;
|
377
|
+
}
|
378
|
+
},
|
379
|
+
{
|
380
|
+
name: 'share-modal',
|
381
|
+
option: 'shareEl',
|
382
|
+
onInit: function(el) {
|
383
|
+
_shareModal = el;
|
384
|
+
},
|
385
|
+
onTap: function() {
|
386
|
+
_toggleShareModal();
|
387
|
+
}
|
388
|
+
},
|
389
|
+
{
|
390
|
+
name: 'button--share',
|
391
|
+
option: 'shareEl',
|
392
|
+
onInit: function(el) {
|
393
|
+
_shareButton = el;
|
394
|
+
},
|
395
|
+
onTap: function() {
|
396
|
+
_toggleShareModal();
|
397
|
+
}
|
398
|
+
},
|
399
|
+
{
|
400
|
+
name: 'button--zoom',
|
401
|
+
option: 'zoomEl',
|
402
|
+
onTap: pswp.toggleDesktopZoom
|
403
|
+
},
|
404
|
+
{
|
405
|
+
name: 'counter',
|
406
|
+
option: 'counterEl',
|
407
|
+
onInit: function(el) {
|
408
|
+
_indexIndicator = el;
|
409
|
+
}
|
410
|
+
},
|
411
|
+
{
|
412
|
+
name: 'button--close',
|
413
|
+
option: 'closeEl',
|
414
|
+
onTap: pswp.close
|
415
|
+
},
|
416
|
+
{
|
417
|
+
name: 'button--arrow--left',
|
418
|
+
option: 'arrowEl',
|
419
|
+
onTap: pswp.prev
|
420
|
+
},
|
421
|
+
{
|
422
|
+
name: 'button--arrow--right',
|
423
|
+
option: 'arrowEl',
|
424
|
+
onTap: pswp.next
|
425
|
+
},
|
426
|
+
{
|
427
|
+
name: 'button--fs',
|
428
|
+
option: 'fullscreenEl',
|
429
|
+
onTap: function() {
|
430
|
+
if(_fullscrenAPI.isFullscreen()) {
|
431
|
+
_fullscrenAPI.exit();
|
432
|
+
} else {
|
433
|
+
_fullscrenAPI.enter();
|
434
|
+
}
|
435
|
+
}
|
436
|
+
},
|
437
|
+
{
|
438
|
+
name: 'preloader',
|
439
|
+
option: 'preloaderEl',
|
440
|
+
onInit: function(el) {
|
441
|
+
_loadingIndicator = el;
|
442
|
+
}
|
443
|
+
}
|
444
|
+
|
445
|
+
];
|
446
|
+
|
447
|
+
var _setupUIElements = function() {
|
448
|
+
var item,
|
449
|
+
classAttr,
|
450
|
+
uiElement;
|
451
|
+
|
452
|
+
var loopThroughChildElements = function(sChildren) {
|
453
|
+
if(!sChildren) {
|
454
|
+
return;
|
455
|
+
}
|
456
|
+
|
457
|
+
var l = sChildren.length;
|
458
|
+
for(var i = 0; i < l; i++) {
|
459
|
+
item = sChildren[i];
|
460
|
+
classAttr = item.className;
|
461
|
+
|
462
|
+
for(var a = 0; a < _uiElements.length; a++) {
|
463
|
+
uiElement = _uiElements[a];
|
464
|
+
|
465
|
+
if(classAttr.indexOf('pswp__' + uiElement.name) > -1 ) {
|
466
|
+
|
467
|
+
if( pswp.options[uiElement.option] ) { // if element is not disabled from options
|
468
|
+
|
469
|
+
framework.removeClass(item, 'pswp__element--disabled');
|
470
|
+
if(uiElement.onInit) {
|
471
|
+
uiElement.onInit(item);
|
472
|
+
}
|
473
|
+
|
474
|
+
//item.style.display = 'block';
|
475
|
+
} else {
|
476
|
+
framework.addClass(item, 'pswp__element--disabled');
|
477
|
+
//item.style.display = 'none';
|
478
|
+
}
|
479
|
+
}
|
480
|
+
}
|
481
|
+
}
|
482
|
+
};
|
483
|
+
loopThroughChildElements(_controls.children);
|
484
|
+
|
485
|
+
var topBar = framework.getChildByClass(_controls, 'pswp__top-bar');
|
486
|
+
if(topBar) {
|
487
|
+
loopThroughChildElements( topBar.children );
|
488
|
+
}
|
489
|
+
};
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
|
494
|
+
ui.init = function() {
|
495
|
+
|
496
|
+
// extend options
|
497
|
+
framework.extend(pswp.options, _options, true);
|
498
|
+
|
499
|
+
// find pswp__ui element
|
500
|
+
_controls = framework.getChildByClass(pswp.scrollWrap, 'pswp__ui');
|
501
|
+
|
502
|
+
// make local link
|
503
|
+
_listen = pswp.listen;
|
504
|
+
|
505
|
+
|
506
|
+
_setupHidingControlsDuringGestures();
|
507
|
+
|
508
|
+
// update controls when slides change
|
509
|
+
_listen('beforeChange', ui.update);
|
510
|
+
|
511
|
+
// toggle zoom on double-tap
|
512
|
+
_listen('doubleTap', function(point) {
|
513
|
+
var initialZoomLevel = pswp.currItem.initialZoomLevel;
|
514
|
+
if(pswp.getZoomLevel() !== initialZoomLevel) {
|
515
|
+
pswp.zoomTo(initialZoomLevel, point, 333);
|
516
|
+
} else {
|
517
|
+
pswp.zoomTo(pswp.options.getDoubleTapZoom(false, pswp.currItem), point, 333);
|
518
|
+
}
|
519
|
+
});
|
520
|
+
|
521
|
+
// Allow text selection in caption
|
522
|
+
_listen('preventDragEvent', function(e, isDown, preventObj) {
|
523
|
+
var t = e.target || e.srcElement;
|
524
|
+
if(
|
525
|
+
t &&
|
526
|
+
t.className && e.type.indexOf('mouse') > -1 &&
|
527
|
+
( t.className.indexOf('__caption') > 0 || (/(SMALL|STRONG|EM)/i).test(t.tagName) )
|
528
|
+
) {
|
529
|
+
preventObj.prevent = false;
|
530
|
+
}
|
531
|
+
});
|
532
|
+
|
533
|
+
// bind events for UI
|
534
|
+
_listen('bindEvents', function() {
|
535
|
+
framework.bind(_controls, 'pswpTap click', _onControlsTap);
|
536
|
+
framework.bind(pswp.scrollWrap, 'pswpTap', ui.onGlobalTap);
|
537
|
+
|
538
|
+
if(!pswp.likelyTouchDevice) {
|
539
|
+
framework.bind(pswp.scrollWrap, 'mouseover', ui.onMouseOver);
|
540
|
+
}
|
541
|
+
});
|
542
|
+
|
543
|
+
// unbind events for UI
|
544
|
+
_listen('unbindEvents', function() {
|
545
|
+
if(!_shareModalHidden) {
|
546
|
+
_toggleShareModal();
|
547
|
+
}
|
548
|
+
|
549
|
+
if(_idleInterval) {
|
550
|
+
clearInterval(_idleInterval);
|
551
|
+
}
|
552
|
+
framework.unbind(document, 'mouseout', _onMouseLeaveWindow);
|
553
|
+
framework.unbind(document, 'mousemove', _onIdleMouseMove);
|
554
|
+
framework.unbind(_controls, 'pswpTap click', _onControlsTap);
|
555
|
+
framework.unbind(pswp.scrollWrap, 'pswpTap', ui.onGlobalTap);
|
556
|
+
framework.unbind(pswp.scrollWrap, 'mouseover', ui.onMouseOver);
|
557
|
+
|
558
|
+
if(_fullscrenAPI) {
|
559
|
+
framework.unbind(document, _fullscrenAPI.eventK, ui.updateFullscreen);
|
560
|
+
if(_fullscrenAPI.isFullscreen()) {
|
561
|
+
pswp.options.hideAnimationDuration = 0;
|
562
|
+
_fullscrenAPI.exit();
|
563
|
+
}
|
564
|
+
_fullscrenAPI = null;
|
565
|
+
}
|
566
|
+
});
|
567
|
+
|
568
|
+
|
569
|
+
// clean up things when gallery is destroyed
|
570
|
+
_listen('destroy', function() {
|
571
|
+
if(pswp.options.captionEl) {
|
572
|
+
if(_fakeCaptionContainer) {
|
573
|
+
_controls.removeChild(_fakeCaptionContainer);
|
574
|
+
}
|
575
|
+
framework.removeClass(_captionContainer, 'pswp__caption--empty');
|
576
|
+
}
|
577
|
+
|
578
|
+
if(_shareModal) {
|
579
|
+
_shareModal.children[0].onclick = null;
|
580
|
+
}
|
581
|
+
framework.removeClass(_controls, 'pswp__ui--over-close');
|
582
|
+
framework.addClass( _controls, 'pswp__ui--hidden');
|
583
|
+
ui.setIdle(false);
|
584
|
+
});
|
585
|
+
|
586
|
+
|
587
|
+
if(!pswp.options.showAnimationDuration) {
|
588
|
+
framework.removeClass( _controls, 'pswp__ui--hidden');
|
589
|
+
}
|
590
|
+
_listen('initialZoomIn', function() {
|
591
|
+
if(pswp.options.showAnimationDuration) {
|
592
|
+
framework.removeClass( _controls, 'pswp__ui--hidden');
|
593
|
+
}
|
594
|
+
});
|
595
|
+
_listen('initialZoomOut', function() {
|
596
|
+
framework.addClass( _controls, 'pswp__ui--hidden');
|
597
|
+
});
|
598
|
+
|
599
|
+
_listen('parseVerticalMargin', _applyNavBarGaps);
|
600
|
+
|
601
|
+
_setupUIElements();
|
602
|
+
|
603
|
+
if(pswp.options.shareEl && _shareButton && _shareModal) {
|
604
|
+
_shareModalHidden = true;
|
605
|
+
}
|
606
|
+
|
607
|
+
_setupIdle();
|
608
|
+
|
609
|
+
_setupFullscreenAPI();
|
610
|
+
|
611
|
+
_setupLoadingIndicator();
|
612
|
+
};
|
613
|
+
|
614
|
+
ui.setIdle = function(isIdle) {
|
615
|
+
_isIdle = isIdle;
|
616
|
+
framework[ (isIdle ? 'add' : 'remove') + 'Class' ](_controls, 'pswp__ui--idle');
|
617
|
+
};
|
618
|
+
|
619
|
+
ui.update = function() {
|
620
|
+
// Don't update UI if it's hidden
|
621
|
+
if(_controlsVisible && pswp.currItem) {
|
622
|
+
|
623
|
+
ui.updateIndexIndicator();
|
624
|
+
|
625
|
+
if(pswp.options.captionEl) {
|
626
|
+
pswp.options.addCaptionHTMLFn(pswp.currItem, _captionContainer);
|
627
|
+
|
628
|
+
if(!pswp.currItem.title) {
|
629
|
+
framework.addClass(_captionContainer, 'pswp__caption--empty');
|
630
|
+
} else {
|
631
|
+
framework.removeClass(_captionContainer, 'pswp__caption--empty');
|
632
|
+
}
|
633
|
+
}
|
634
|
+
|
635
|
+
_overlayUIUpdated = true;
|
636
|
+
|
637
|
+
} else {
|
638
|
+
_overlayUIUpdated = false;
|
639
|
+
}
|
640
|
+
};
|
641
|
+
|
642
|
+
ui.updateFullscreen = function() {
|
643
|
+
framework[ (_fullscrenAPI.isFullscreen() ? 'add' : 'remove') + 'Class' ](pswp.template, 'pswp--fs');
|
644
|
+
};
|
645
|
+
|
646
|
+
ui.updateIndexIndicator = function() {
|
647
|
+
if(pswp.options.counterEl) {
|
648
|
+
_indexIndicator.innerHTML = (pswp.getCurrentIndex()+1) +
|
649
|
+
pswp.options.indexIndicatorSep +
|
650
|
+
pswp.options.getNumItemsFn();
|
651
|
+
}
|
652
|
+
};
|
653
|
+
|
654
|
+
ui.onGlobalTap = function(e) {
|
655
|
+
e = e || window.event;
|
656
|
+
var target = e.target || e.srcElement;
|
657
|
+
|
658
|
+
if(_blockControlsTap) {
|
659
|
+
return;
|
660
|
+
}
|
661
|
+
|
662
|
+
if(e.detail && e.detail.pointerType === 'mouse') {
|
663
|
+
|
664
|
+
// close gallery if clicked outside of the image
|
665
|
+
if(_hasCloseClass(target)) {
|
666
|
+
pswp.close();
|
667
|
+
}
|
668
|
+
|
669
|
+
if(framework.hasClass(target, 'pswp__img')) {
|
670
|
+
if(pswp.getZoomLevel() === 1 && pswp.getZoomLevel() <= pswp.currItem.fitRatio) {
|
671
|
+
pswp.close();
|
672
|
+
} else {
|
673
|
+
pswp.toggleDesktopZoom(e.detail.releasePoint);
|
674
|
+
}
|
675
|
+
}
|
676
|
+
|
677
|
+
} else {
|
678
|
+
|
679
|
+
// tap anywhere (except buttons) to toggle visibility of controls
|
680
|
+
if(pswp.options.tapToToggleControls) {
|
681
|
+
if(_controlsVisible) {
|
682
|
+
ui.hideControls();
|
683
|
+
} else {
|
684
|
+
ui.showControls();
|
685
|
+
}
|
686
|
+
}
|
687
|
+
|
688
|
+
// tap to close gallery
|
689
|
+
if(pswp.options.tapToClose && (framework.hasClass(target, 'pswp__img') || _hasCloseClass(target)) ) {
|
690
|
+
pswp.close();
|
691
|
+
return;
|
692
|
+
}
|
693
|
+
|
694
|
+
}
|
695
|
+
};
|
696
|
+
ui.onMouseOver = function(e) {
|
697
|
+
e = e || window.event;
|
698
|
+
var target = e.target || e.srcElement;
|
699
|
+
|
700
|
+
// add class when mouse is over an element that should close the gallery
|
701
|
+
framework[ (_hasCloseClass(target) ? 'add' : 'remove') + 'Class'](_controls, 'pswp__ui--over-close');
|
702
|
+
};
|
703
|
+
|
704
|
+
ui.hideControls = function() {
|
705
|
+
framework.addClass(_controls,'pswp__ui--hidden');
|
706
|
+
_controlsVisible = false;
|
707
|
+
};
|
708
|
+
|
709
|
+
ui.showControls = function() {
|
710
|
+
_controlsVisible = true;
|
711
|
+
if(!_overlayUIUpdated) {
|
712
|
+
ui.update();
|
713
|
+
}
|
714
|
+
framework.removeClass(_controls,'pswp__ui--hidden');
|
715
|
+
};
|
716
|
+
|
717
|
+
ui.supportsFullscreen = function() {
|
718
|
+
var d = document;
|
719
|
+
return !!(d.exitFullscreen || d.mozCancelFullScreen || d.webkitExitFullscreen || d.msExitFullscreen);
|
720
|
+
};
|
721
|
+
|
722
|
+
ui.getFullscreenAPI = function() {
|
723
|
+
var dE = document.documentElement,
|
724
|
+
api,
|
725
|
+
tF = 'fullscreenchange';
|
726
|
+
|
727
|
+
if (dE.requestFullscreen) {
|
728
|
+
api = {
|
729
|
+
enterK: 'requestFullscreen',
|
730
|
+
exitK: 'exitFullscreen',
|
731
|
+
elementK: 'fullscreenElement',
|
732
|
+
eventK: tF
|
733
|
+
};
|
734
|
+
|
735
|
+
} else if(dE.mozRequestFullScreen ) {
|
736
|
+
api = {
|
737
|
+
enterK: 'mozRequestFullScreen',
|
738
|
+
exitK: 'mozCancelFullScreen',
|
739
|
+
elementK: 'mozFullScreenElement',
|
740
|
+
eventK: 'moz' + tF
|
741
|
+
};
|
742
|
+
|
743
|
+
|
744
|
+
|
745
|
+
} else if(dE.webkitRequestFullscreen) {
|
746
|
+
api = {
|
747
|
+
enterK: 'webkitRequestFullscreen',
|
748
|
+
exitK: 'webkitExitFullscreen',
|
749
|
+
elementK: 'webkitFullscreenElement',
|
750
|
+
eventK: 'webkit' + tF
|
751
|
+
};
|
752
|
+
|
753
|
+
} else if(dE.msRequestFullscreen) {
|
754
|
+
api = {
|
755
|
+
enterK: 'msRequestFullscreen',
|
756
|
+
exitK: 'msExitFullscreen',
|
757
|
+
elementK: 'msFullscreenElement',
|
758
|
+
eventK: 'MSFullscreenChange'
|
759
|
+
};
|
760
|
+
}
|
761
|
+
|
762
|
+
if(api) {
|
763
|
+
api.enter = function() {
|
764
|
+
// disable close-on-scroll in fullscreen
|
765
|
+
_initalCloseOnScrollValue = pswp.options.closeOnScroll;
|
766
|
+
pswp.options.closeOnScroll = false;
|
767
|
+
|
768
|
+
if(this.enterK === 'webkitRequestFullscreen') {
|
769
|
+
pswp.template[this.enterK]( Element.ALLOW_KEYBOARD_INPUT );
|
770
|
+
} else {
|
771
|
+
return pswp.template[this.enterK]();
|
772
|
+
}
|
773
|
+
};
|
774
|
+
api.exit = function() {
|
775
|
+
pswp.options.closeOnScroll = _initalCloseOnScrollValue;
|
776
|
+
|
777
|
+
return document[this.exitK]();
|
778
|
+
|
779
|
+
};
|
780
|
+
api.isFullscreen = function() { return document[this.elementK]; };
|
781
|
+
}
|
782
|
+
|
783
|
+
return api;
|
784
|
+
};
|
785
|
+
|
786
|
+
|
787
|
+
|
788
|
+
};
|
789
|
+
return PhotoSwipeUI_Default;
|
790
|
+
|
791
|
+
|
792
|
+
});
|