PageSourceSearch

https://www.blueclinic.it/plugins/system/zo2/framework/assets/vendor/ekko-lightbox.js

js blueclinic.it collected 2026-09-26 16:12:54 UTC 7,480 bytes, 195 lines download raw bytes

1// Generated by CoffeeScript 1.6.3
2/*
3Lightbox for Bootstrap 3 by @ashleydw
4https://github.com/ashleydw/lightbox
5
6License: https://github.com/ashleydw/lightbox/blob/master/LICENSE
7*/
8
9(function() {
10  "use strict";
11  var EkkoLightbox;
12
13  EkkoLightbox = function(element, options) {
14    var content, footer, header, youtube;
15    this.options = jQuery.extend({
16      title: null,
17      footer: null,
18      remote: null,
19      keyboard: true,
20      onShow: function() {},
21      onShown: function() {},
22      onHide: function() {},
23      onHidden: function() {
24        if (this.gallery) {
25          jQuery(document).off('keydown.ekkoLightbox');
26        }
27        return this.modal.remove();
28      },
29      id: false
30    }, options || {});
31    this.$element = jQuery(element);
32    content = '';
33    this.modal_id = this.options.modal_id ? this.options.modal_id : 'ekkoLightbox-' + Math.floor((Math.random() * 1000) + 1);
34    header = this.options.title ? '<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button><h4 class="modal-title">' + this.options.title + '</h4></div>' : '';
35    footer = this.options.footer ? '<div class="modal-footer">' + this.options.footer + '</div>' : '';
36    jQuery(document.body).append('<div id="' + this.modal_id + '" class="modal fade" tabindex="-1"><div class="modal-dialog"><div class="modal-content">' + header + '<div class="modal-body"></div>' + footer + '</div></div></div>');
37    this.modal = jQuery('#' + this.modal_id);
38    this.modal_body = this.modal.find('.modal-body').first();
39    this.padding = {
40      left: parseFloat(this.modal_body.css('padding-left'), 10),
41      right: parseFloat(this.modal_body.css('padding-right'), 10),
42      bottom: parseFloat(this.modal_body.css('padding-bottom'), 10),
43      top: parseFloat(this.modal_body.css('padding-top'), 10)
44    };
45    if (!this.options.remote) {
46      this.error('No remote target given');
47    } else {
48      if (this.isImage(this.options.remote)) {
49        this.preloadImage(this.options.remote, true);
50      } else if (youtube = this.getYoutubeId(this.options.remote)) {
51        this.showYoutubeVideo(youtube);
52      } else if (this.isSwf(this.options.remote)) {
53        console.log('todo');
54      }
55      this.gallery = this.$element.data('gallery');
56      if (this.gallery) {
57        this.gallery_items = this.$element.parents('*:not(.row)').first().find('*[data-toggle="lightbox"][data-gallery="' + this.gallery + '"]');
58        this.gallery_index = this.gallery_items.index(this.$element);
59        jQuery(document).on('keydown.ekkoLightbox', this.navigate.bind(this));
60      }
61    }
62    this.modal.on('show.bs.modal', this.options.onShow.bind(this)).on('shown.bs.modal', this.options.onShown.bind(this)).on('hide.bs.modal', this.options.onHide.bind(this)).on('hidden.bs.modal', this.options.onHidden.bind(this)).modal('show', options);
63    return this.modal;
64  };
65
66  EkkoLightbox.prototype = {
67    isImage: function(str) {
68      return str.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i);
69    },
70    isSwf: function(str) {
71      return str.match(/\.(swf)((\?|#).*)?$/i);
72    },
73    getYoutubeId: function(str) {
74      var match;
75      match = str.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/);
76      if (match && match[2].length === 11) {
77        return match[2];
78      } else {
79        return false;
80      }
81    },
82    navigate: function(event) {
83      var next, src, youtube;
84      event = event || window.event;
85      if (event.keyCode === 39 || event.keyCode === 37) {
86        if (event.keyCode === 39 && this.gallery_index + 1 < this.gallery_items.length) {
87          this.gallery_index++;
88          this.$element = jQuery(this.gallery_items.get(this.gallery_index));
89          src = this.$element.attr('data-source') || this.$element.attr('href');
90          if (this.isImage(src)) {
91            this.preloadImage(src, true);
92          } else if (youtube = this.getYoutubeId(src)) {
93            this.showYoutubeVideo(youtube);
94          }
95          if (this.gallery_index + 1 < this.gallery_items.length) {
96            next = jQuery(this.gallery_items.get(this.gallery_index + 1), false);
97            src = next.attr('data-source') || next.attr('href');
98            if (this.isImage(src)) {
99              return this.preloadImage(src, false);
100            }
101          }
102        } else if (event.keyCode === 37 && this.gallery_index > 0) {
103          this.gallery_index--;
104          this.$element = jQuery(this.gallery_items.get(this.gallery_index));
105          src = this.$element.attr('data-source') || this.$element.attr('href');
106          if (this.isImage(src)) {
107            return this.preloadImage(src, true);
108          } else if (youtube = this.getYoutubeId(src)) {
109            return this.showYoutubeVideo(youtube);
110          }
111        }
112      }
113    },
114    showLoading: function() {
115      return this.modal_body.html('<div class="modal-loading">Loading..</div>');
116    },
117    showYoutubeVideo: function(id) {
118      this.resize(560, 315);
119      return this.modal_body.html('<iframe width="560" height="315" src="//www.youtube.com/embed/' + id + '?autoplay=1" frameborder="0" allowfullscreen></iframe>');
120    },
121    error: function(message) {
122      return this.modal_body.html(message);
123    },
124    preloadImage: function(src, onLoadShowImage) {
125      var img,
126        _this = this;
127      img = new Image();
128      if ((onLoadShowImage == null) || onLoadShowImage === true) {
129        img.onload = function() {
130          var i, width;
131          _this.checkImageDimensions(img);
132          _this.modal_body.html(img);
133          i = _this.modal_body.find('img').first();
134          width = i && i.width() > 0 ? i.width() : img.width;
135          return _this.resize(width, i.height());
136        };
137        img.onerror = function() {
138          return _this.error('Failed to load image: ' + src);
139        };
140      }
141      return img.src = src;
142    },
143    close: function() {
144      return this.modal.modal('hide');
145    },
146    center: function() {
147      return this.modal.find('.modal-dialog').css({
148        'left': function() {
149          return -(jQuery(this).width() / 2);
150        }
151      });
152    },
153    resize: function(width, height) {
154      width = width + this.padding.left + this.padding.right;
155      this.modal.find('.modal-content').css({
156        'width': width
157      });
158      this.modal.find('.modal-dialog').css({
159        'width': width + 20
160      });
161      return this.center();
162    },
163    checkImageDimensions: function(img) {
164      var w;
165      w = jQuery(window);
166      if ((img.width + (this.padding.left + this.padding.right + 20)) > w.width()) {
167        return img.width = w.width() - (this.padding.left + this.padding.right + 20);
168      }
169    }
170  };
171
172  jQuery.fn.ekkoLightbox = function(options, _relatedTarget) {
173    return this.each(function() {
174      var $this;
175      $this = jQuery(this);
176      options = jQuery.extend({
177        remote: $this.attr('data-source') || $this.attr('href')
178      }, $this.data());
179      new EkkoLightbox(this, options);
180      return this;
181    });
182  };
183
184  jQuery(document).delegate('*[data-toggle="lightbox"]', 'click', function(event) {
185    var $this;
186    event.preventDefault();
187    $this = jQuery(this);
188    return $this.ekkoLightbox({
189      remote: $this.attr('data-source') || $this.attr('href')
190    }).one('hide', function() {
191      return $this.is(':visible') && $this.focus();
192    });
193  });
194
195}).call(this);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.