public
Description: Really simple lightbox.
Homepage:
Clone URL: git://github.com/drogus/lightbox-fu.git
lightbox-fu / jquery.lightBoxFu.js
100755 69 lines (63 sloc) 2.371 kb
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* lightboxFu
*
* Copyright (c) 2008 Piotr Sarnacki (drogomir.com)
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
*/
 
(function($) {
  $.extend($, {lightBoxFu: {}});
  $.extend($.lightBoxFu, {
    initialize: function (o) {
      if($('#lightboxfu').length == 0) {
options = {stylesheetsPath: '/stylesheets/', imagesPath: '/images/'};
jQuery.extend(options, o);
        html = '<div id="lightboxfu" style="display: none"><div id="lOverlay"><div id="lWindow"><div id="lInner"></div></div></div></div>';
if ($.browser.msie && $.browser.version == '6.0') {
html += '<link rel="stylesheet" type="text/css" href="'+options.stylesheetsPath+'lightbox-fu-ie6.css" />';
$('body').css('background', 'url('+options.imagesPath+'blank.gif) fixed');
} else if($.browser.msie && $.browser.version == '7.0') {
html += '<link rel="stylesheet" type="text/css" href="'+options.stylesheetsPath+'lightbox-fu-ie7.css" />';
}
        $('body').append(html);
if(!$.browser.msie) {
$('#lOverlay').css('background', 'url('+options.imagesPath+'overlay.png) fixed');
}
        
$.lightBoxFu.appendStyle();
      }
    },
    open: function(options) {
      options = options || {};
      $('#lInner').html(options.html);
      $('#lightboxfu').show();
      var width = options.width || '250';
      $('#lInner').css({'width': width});
      
      if(options.closeOnClick != false) {
        $('#lOverlay').one('click', $.lightBoxFu.close);
      }
    },
    close: function() {
      $('#lightboxfu').hide();
    },
    appendStyle: function() {
      if(!$.browser.msie) {
          $('#lOverlay').css({display: 'table'});
          $('#lOverlay #lWindow').css({display: 'table-cell'});
      }
      $('#lOverlay').css({position: 'fixed', top: 0, left: 0, width: "100%", height: "100%"});
      $('#lOverlay #lWindow').css({'vertical-align': 'middle'});
      $('#lOverlay #lInner').css({width: '300px', 'background-color': '#fff', '-webkit-border-radius': '10px', '-moz-border-radius': '10px', 'max-height': '350px', margin: '0 auto', padding: '15px', overflow: 'auto'});
    }
  });
  
  $.extend($.fn, {
lightBoxFu: function(options){
return this.each(function() {
        $(this).click(function() {
$.lightBoxFu.open(options);
          return false;
        });
      });
  }});
})(jQuery);