aboutsummaryrefslogtreecommitdiff
path: root/views/default/js/lightbox.php
blob: 3e0f8912b1d212d2947f1eb7dbf6eff14c4b62b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
 * Colorbox -- Javascript
 *
 * Used as a view because we need to pass a full URL to AlphaImageLoader.
 *
 * @package        Lorea
 * @subpackage     Colorbox
 *
 * Copyright 2011-2012 Lorea Faeries <federation@lorea.org>
 *
 * This file is part of the Colorbox plugin for Elgg.
 *
 * Colorbox is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * Colorbox is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this program. If not, see
 * <http://www.gnu.org/licenses/>.
 *
 * Usage
 * Apply the class elgg-lightbox to links.
 *
 * Advanced Usage
 * Elgg is distributed with the Colorbox jQuery library. Please go to
 * http://www.jacklmoore.com/colorbox for more information on the options of this lightbox.
 *
 * Overriding
 * In a plugin, override this view and override the registration for the
 * lightbox JavaScript and CSS (@see elgg_views_boot()).
 *
 * @todo add support for passing options: $('#myplugin-lightbox').elgg.ui.lightbox(options);
 */
?>

/**
 * Lightbox initialization
 */

elgg.provide('elgg.ui.lightbox');

elgg.ui.lightbox.init = function() {

	$.extend($.colorbox.settings, {
		current: elgg.echo('js:lightbox:current', ['{current}', '{total}']),
		previous: elgg.echo('previous'),
		next: elgg.echo('next'),
		close: elgg.echo('close'),
		xhrError: elgg.echo('error:default'),
		imgError: elgg.echo('error:default'),
	});

	$(".elgg-lightbox").colorbox();
	$(".elgg-lightbox-photo").colorbox({photo: true});
	var n = 0;
	$(".elgg-lightbox-gallery").each(function() {
		$(this).find(".elgg-lightbox, .elgg-lightbox-photo")
		.addClass("elgg-lightbox-" + n)
		.colorbox({
			rel: "elgg-lightbox-" + n++,
		});
	});
}

elgg.ui.lightbox.close = function() {
	$.colorbox.close();
}

elgg.register_hook_handler('init', 'system', elgg.ui.lightbox.init);

<?php

$js_path = elgg_get_plugins_path();
$js_path = "{$js_path}colorbox/vendors/jquery/colorbox/colorbox/jquery.colorbox-min.js";
include $js_path;