Commit d43bc1c4fa1f29eba51179749dc0300b78b7600f

Authored by Braulio Bhavamitra
1 parent 9928c540

modal: encapsulate to allow reuse of modal trigger

Without this it is not possible to load the modal programatically. This
follows the responsive plugin API.
Showing 1 changed file with 19 additions and 13 deletions   Show diff stats
public/javascripts/modal.js
@@ -3,19 +3,9 @@ noosfero.modal = { @@ -3,19 +3,9 @@ noosfero.modal = {
3 watchClass: function() { 3 watchClass: function() {
4 jQuery(function($) { 4 jQuery(function($) {
5 $(document).delegate('.modal-toggle', 'click', function() { 5 $(document).delegate('.modal-toggle', 'click', function() {
6 - $.colorbox({  
7 - href: $(this).attr('href'),  
8 - maxWidth: $(window).width()-50,  
9 - height: $(window).height()-50,  
10 - open: true,  
11 - close: 'Cancel',  
12 - class: 'modal',  
13 - onComplete: function(bt) {  
14 - var opt = {}, maxH = $(window).height()-50;  
15 - if ($('#cboxLoadedContent *:first').height() > maxH) opt.height = maxH;  
16 - $.colorbox.resize(opt);  
17 - }  
18 - }); 6 + var url = $(this).attr('href')
  7 + noosfero.modal.url(url)
  8 +
19 return false; 9 return false;
20 }); 10 });
21 11
@@ -27,6 +17,22 @@ noosfero.modal = { @@ -27,6 +17,22 @@ noosfero.modal = {
27 }); 17 });
28 }, 18 },
29 19
  20 + url: function (url, options) {
  21 + $.colorbox({
  22 + href: url,
  23 + maxWidth: $(window).width()-50,
  24 + height: $(window).height()-50,
  25 + open: true,
  26 + close: 'Cancel',
  27 + class: 'modal',
  28 + onComplete: function(bt) {
  29 + var opt = {}, maxH = $(window).height()-50;
  30 + if ($('#cboxLoadedContent *:first').height() > maxH) opt.height = maxH;
  31 + $.colorbox.resize(opt);
  32 + }
  33 + });
  34 + },
  35 +
30 inline: function(href, options) { 36 inline: function(href, options) {
31 href = jQuery(href); 37 href = jQuery(href);
32 options = jQuery.extend({ 38 options = jQuery.extend({