cirandas.net

ref: master

public/javascripts/modal.js


 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
noosfero.modal = {

  watchClass: function() {
    jQuery(function($) {
      $(document).delegate('.modal-toggle', 'click', function() {
        var url = $(this).attr('href')
        noosfero.modal.url(url)

        return false;
      });

      $(document).delegate('.modal-close', 'click', function() {
        $.colorbox.close();
        return false;
      });

    });
  },

  url: function (url, options) {
    $.colorbox({
      href:       url,
      maxWidth:   $(window).width()-50,
      height:     $(window).height()-50,
      open:       true,
      close:      'Cancel',
      class:      'modal',
      onComplete: function(bt) {
        var opt = {}, maxH = $(window).height()-50;
        if ($('#cboxLoadedContent *:first').height() > maxH) opt.height = maxH;
        $.colorbox.resize(opt);
      }
    });
  },

  inline: function(href, options) {
    href = jQuery(href);
    options = jQuery.extend({
      inline: true, href: href,
      onLoad: function(){ href.show(); },
      onCleanup: function(){ href.hide(); },
    }, options)

    jQuery.colorbox(options);

    return false;
  },

  html: function(html, options) {
    options = jQuery.extend({
      html: html,
    }, options);

    jQuery.colorbox(options);
  },

  close: function() {
    jQuery.colorbox.close();
  },

};

noosfero.modal.watchClass();