Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(js): adds elgg/lightbox AMD module, loaded on all pages
`elgg/lightbox` AMD module can now be used to open and close the lightbox programmatically. The module is inlined in `elgg.js` alongside the colorbox library, and the CSS is included with `elgg.css` as well. Hence it's no longer necessary to use `elgg_load_js('lightbox')` or `elgg_load_css('lightbox')`. Fixes Elgg#7895 Fixes Elgg#8309 Fixes Elgg#6991
- Loading branch information
1 parent
243c088
commit 4467b6e
Showing
19 changed files
with
402 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
mod/developers/views/default/theme_sandbox/javascript/lightbox.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
define(function(require) { | ||
var lightbox = require('elgg/lightbox'); | ||
var opts = { | ||
photo: true, | ||
width: 600 | ||
}; | ||
lightbox.bind('[rel="lightbox-gallery"]', opts, false); | ||
}); |
70 changes: 65 additions & 5 deletions
70
mod/developers/views/default/theme_sandbox/javascript/lightbox.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,72 @@ | ||
<?php | ||
|
||
elgg_load_js('lightbox'); | ||
elgg_load_css('lightbox'); | ||
|
||
$link = elgg_view('output/url', array( | ||
echo elgg_view('output/url', array( | ||
'text' => 'Open lighbox', | ||
'href' => "ajax/view/developers/ajax", | ||
'class' => 'elgg-lightbox' | ||
)); | ||
|
||
echo $link; | ||
echo elgg_view('output/url', array( | ||
'text' => 'Open iframe lightbox', | ||
'href' => 'https://elgg.org', | ||
'class' => 'elgg-lightbox-iframe mll', | ||
'data-colorbox-opts' => json_encode([ | ||
'width' => '80%', | ||
'height' => '80%', | ||
]), | ||
)); | ||
|
||
echo elgg_view('output/url', array( | ||
'text' => 'Open inline HTML lightbox', | ||
'href' => '#lightbox-inline', | ||
'class' => 'elgg-lightbox-inline mll', | ||
)); | ||
?> | ||
<div class="hidden"> | ||
<div id="lightbox-inline"> | ||
<?= elgg_view('developers/ipsum') ?> | ||
</div> | ||
</div> | ||
<?php | ||
$files = elgg_get_entities_from_metadata(array( | ||
'types' => 'object', | ||
'subtypes' => 'file', | ||
'metadata_name_value_paris' => [ | ||
'name' => 'simpletype', | ||
'value' => 'image', | ||
], | ||
)); | ||
|
||
if (!$files) { | ||
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]), | ||
'class' => 'elgg-lightbox-photo mll', | ||
)); | ||
?> | ||
<ul class="elgg-gallery elgg-gallery-fluid"> | ||
<?php | ||
foreach ($files as $file) { | ||
?> | ||
<li class="pam"> | ||
<?php | ||
echo elgg_view('output/url', array( | ||
'text' => elgg_view('output/img', array( | ||
'src' => $file->getIconURL('small'), | ||
'alt' => $file->getDisplayName(), | ||
)), | ||
'href' => $file->getIconURL('large'), | ||
'rel' => 'lightbox-gallery', | ||
)); | ||
?> | ||
</li> | ||
<?php | ||
} | ||
?> | ||
</ul> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.