Permalink
Browse files

fix(js): add missing elgg/lightbox#resize method

Adds the missing proxy elgg/lightbox#resize method so that
plugins no longer need to use $.colorbox directly
  • Loading branch information...
jdalsem authored and hypeJunction committed Jun 24, 2016
1 parent 45b2da7 commit 4f6a0174779abc11c6d92e54a107899aa30ef5a3
View
@@ -654,6 +654,18 @@ To support gallery sets (via ``rel`` attribute), you need to bind colorbox direc
lightbox.bind('a[rel="my-gallery"]', options, false); // 3rd attribute ensures binding is done without proxies
});
+You can also resize the lightbox programmatically if needed:
+
+.. code:: js
+
+ define(function(require) {
+ var lightbox = require('elgg/lightbox');
+
+ lightbox.resize({
+ width: '300px'
+ });
+ });
+
Module ``elgg/ckeditor``
------------------------
@@ -5,8 +5,15 @@
$ipsum = elgg_view('developers/ipsum');
+$resize_button = elgg_view('input/button', [
+ 'id' => 'elgg-lightbox-test-resize',
+ 'class' => 'elgg-button elgg-button-action',
+ 'value' => 'Add extra content and resize',
+]);
+
echo '<div class="mam" style="width: 400px;">';
echo elgg_view_module('aside', 'Lightbox Test', $ipsum, array(
- 'id' => 'elgg-lightbox-test'
+ 'id' => 'elgg-lightbox-test',
+ 'footer' => $resize_button,
));
echo '</div>';
@@ -5,4 +5,12 @@ define(function(require) {
width: 600
};
lightbox.bind('[rel="lightbox-gallery"]', opts, false);
+
+ $(document).on('click', '#elgg-lightbox-test-resize', function(event) {
+ event.preventDefault();
+ $body = $('#elgg-lightbox-test').find('.elgg-body');
+ $body.append($body.html());
+
+ lightbox.resize();
+ });
});
@@ -1,7 +1,7 @@
<?php
echo elgg_view('output/url', array(
- 'text' => 'Open lighbox',
+ 'text' => 'Open lightbox',
'href' => "ajax/view/developers/ajax",
'class' => 'elgg-lightbox'
));
@@ -21,6 +21,9 @@
'href' => '#lightbox-inline',
'class' => 'elgg-lightbox-inline mll',
));
+
+elgg_require_js('theme_sandbox/javascript/lightbox');
+
?>
<div class="hidden">
<div id="lightbox-inline">
@@ -41,8 +44,6 @@
return;
}
-elgg_require_js('theme_sandbox/javascript/lightbox');
-
echo elgg_view('output/url', array(
'text' => 'Open photo lightbox',
'href' => elgg_get_download_url($files[0]),
@@ -112,9 +112,13 @@ define('elgg/lightbox', function (require) {
* Close the colorbox
* @return void
*/
- close: function () {
- $.colorbox.close();
- }
+ close: $.colorbox.close,
+
+ /**
+ * Resizes the colorbox
+ * @return void
+ */
+ resize: $.colorbox.resize
};
lightbox.bind(".elgg-lightbox");

0 comments on commit 4f6a017

Please sign in to comment.