noosfero | modal: encapsulate to allow reuse of modal trigger

Bráulio Bhavamitra gitlab at gitlab.com
Tue Mar 3 20:47:54 BRT 2015


Bráulio Bhavamitra pushed to refs/heads/master at <a href="https://gitlab.com/noosfero/noosfero">Noosfero / noosfero</a>

Commits:
<a href="https://gitlab.com/noosfero/noosfero/commit/d43bc1c4fa1f29eba51179749dc0300b78b7600f">d43bc1c4</a> by Braulio Bhavamitra
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.

- - - - -


Changes:

=====================================
public/javascripts/modal.js
=====================================
--- 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({

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150303/f696e6f4/attachment-0001.html>


More information about the Noosfero-dev mailing list