From d43bc1c4fa1f29eba51179749dc0300b78b7600f Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Tue, 3 Mar 2015 20:46:08 -0300 Subject: [PATCH] modal: encapsulate to allow reuse of modal trigger --- public/javascripts/modal.js | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/public/javascripts/modal.js b/public/javascripts/modal.js index 0db0f6f..17a6037 100644 --- a/public/javascripts/modal.js +++ b/public/javascripts/modal.js @@ -3,19 +3,9 @@ noosfero.modal = { watchClass: function() { jQuery(function($) { $(document).delegate('.modal-toggle', 'click', function() { - $.colorbox({ - href: $(this).attr('href'), - 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); - } - }); + var url = $(this).attr('href') + noosfero.modal.url(url) + return false; }); @@ -27,6 +17,22 @@ noosfero.modal = { }); }, + 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({ -- libgit2 0.21.2