scratch – Blame information for rev 115
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
115 | office | 1 | /* |
2 | * blueimp Gallery jQuery plugin |
||
3 | * https://github.com/blueimp/Gallery |
||
4 | * |
||
5 | * Copyright 2013, Sebastian Tschan |
||
6 | * https://blueimp.net |
||
7 | * |
||
8 | * Licensed under the MIT license: |
||
9 | * https://opensource.org/licenses/MIT |
||
10 | */ |
||
11 | |||
12 | /* global define, window, document */ |
||
13 | |||
14 | ;(function (factory) { |
||
15 | 'use strict' |
||
16 | if (typeof define === 'function' && define.amd) { |
||
17 | define([ |
||
18 | 'jquery', |
||
19 | './blueimp-gallery' |
||
20 | ], factory) |
||
21 | } else { |
||
22 | factory( |
||
23 | window.jQuery, |
||
24 | window.blueimp.Gallery |
||
25 | ) |
||
26 | } |
||
27 | }(function ($, Gallery) { |
||
28 | 'use strict' |
||
29 | |||
30 | // Global click handler to open links with data-gallery attribute |
||
31 | // in the Gallery lightbox: |
||
32 | $(document).on('click', '[data-gallery]', function (event) { |
||
33 | // Get the container id from the data-gallery attribute: |
||
34 | var id = $(this).data('gallery') |
||
35 | var widget = $(id) |
||
36 | var container = (widget.length && widget) || |
||
37 | $(Gallery.prototype.options.container) |
||
38 | var callbacks = { |
||
39 | onopen: function () { |
||
40 | container |
||
41 | .data('gallery', this) |
||
42 | .trigger('open') |
||
43 | }, |
||
44 | onopened: function () { |
||
45 | container.trigger('opened') |
||
46 | }, |
||
47 | onslide: function () { |
||
48 | container.trigger('slide', arguments) |
||
49 | }, |
||
50 | onslideend: function () { |
||
51 | container.trigger('slideend', arguments) |
||
52 | }, |
||
53 | onslidecomplete: function () { |
||
54 | container.trigger('slidecomplete', arguments) |
||
55 | }, |
||
56 | onclose: function () { |
||
57 | container.trigger('close') |
||
58 | }, |
||
59 | onclosed: function () { |
||
60 | container |
||
61 | .trigger('closed') |
||
62 | .removeData('gallery') |
||
63 | } |
||
64 | } |
||
65 | var options = $.extend( |
||
66 | // Retrieve custom options from data-attributes |
||
67 | // on the Gallery widget: |
||
68 | container.data(), |
||
69 | { |
||
70 | container: container[0], |
||
71 | index: this, |
||
72 | event: event |
||
73 | }, |
||
74 | callbacks |
||
75 | ) |
||
76 | // Select all links with the same data-gallery attribute: |
||
77 | var links = $('[data-gallery="' + id + '"]') |
||
78 | if (options.filter) { |
||
79 | links = links.filter(options.filter) |
||
80 | } |
||
81 | return new Gallery(links, options) |
||
82 | }) |
||
83 | })) |