Blame view

resources/js/common/jquery.litebox.js 878 Bytes
e77200db5   nologostudio.ru   Initial commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  // LiteBox v0.1 - jQuery lightbox plugin
  (function ($) {
      var origin;
      var dummy;
  
      $.fn.litebox = function () {
          origin = this;
  
          // Create empty div at the place of the original element and replace it
          // later when the litebox is closed.
          dummy = $('<div></div>').hide().insertBefore(origin).bind('close-litebox', function () {
              $(this).replaceWith(origin);
          });
  
          $('body').append('<div id="litebox-overlay"></div>');
          $('body').append('<div id="litebox"></div>');
          origin.appendTo('#litebox');
  
          addEvents();
      };
  
      function close() {
          $(dummy).trigger('close-litebox');
          $('#litebox-overlay').remove();
          $('#litebox').remove();
      }
  
      function addEvents() {
          $('#litebox-overlay').click(function () {
              close();
          });
      }
  }(jQuery));