cirandas.net

ref: master

plugins/responsive/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
65
66
67
noosfero.modal = {

  el: function() {
    return jQuery('#noosferoModal')
  },
  content: function() {
    return jQuery('#noosferoModalContent')
  },

  init: function() {
    noosfero.modal.watchClass();
  },

  show: function(options) {
    noosfero.modal.el().modal(options);
    noosfero.modal.resize();
  },

  resize: function(){
    var width = $('#noosferoModalContent').children().outerWidth(true);
    if (width > 500)
      $('#noosferoModal .modal-dialog').css('width', width)
  },

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

      return false;
    });

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

  url: function (url, options) {
    noosfero.modal.content().empty().load(url, function() {
      noosfero.modal.resize();
    });
    noosfero.modal.show(options);
  },

  inline: function(href, options) {
    noosfero.modal.html(jQuery(href).html(), options)

    return false;
  },

  html: function(html, options) {
    noosfero.modal.content().html(html)
    noosfero.modal.show(options);
  },

  close: function(){
    noosfero.modal.el().modal('hide');
  },

};

$(function() {
  noosfero.modal.init();
})