24 define([
'jquery',
'elgg',
'elgg/Ajax',
'elgg/hooks',
'jquery.colorbox'],
function ($,
elgg, Ajax, hooks) {
35 getOptions:
function (opts) {
36 if (!$.isPlainObject(opts)) {
41 var defaults =
elgg.data.lightbox;
43 if (!defaults.reposition) {
45 defaults.reposition = $(window).height() > 600;
48 var settings = $.extend({}, defaults, opts);
50 return hooks.trigger(
'getOptions',
'ui.lightbox', null, settings);
62 bind:
function (selector, opts, use_element_data) {
63 if (!$.isPlainObject(opts)) {
68 if (use_element_data ===
false) {
69 $(selector).colorbox(lightbox.getOptions(opts));
74 .off(
'click.lightbox', selector)
75 .on(
'click.lightbox', selector,
function (e) {
80 $(
'.elgg-system-messages .elgg-message').
remove();
84 href = $this.prop(
'href') || $this.prop(
'src'),
86 dataOpts = $this.data(
'colorboxOpts'),
89 if (!$.isPlainObject(dataOpts)) {
93 if (!dataOpts.href && href) {
98 $.extend(currentOpts, opts, dataOpts);
99 if (currentOpts.inline && currentOpts.href) {
100 currentOpts.href =
elgg.getSelectorFromUrlFragment(currentOpts.href);
103 if (currentOpts.photo || currentOpts.inline || currentOpts.iframe || currentOpts.html) {
104 lightbox.open(currentOpts);
108 currentOpts.ajaxLoadWithDependencies =
true;
109 lightbox.open(currentOpts);
113 .off(
'resize.lightbox')
114 .on(
'resize.lightbox',
function() {
115 elgg.data.lightbox.reposition = $(window).height() > 600;
127 open:
function (opts) {
128 var currentOpts = lightbox.getOptions(opts);
130 if (!currentOpts.ajaxLoadWithDependencies) {
131 $.colorbox(currentOpts);
135 var href = currentOpts.href;
136 currentOpts.href =
false;
137 var data = currentOpts.data;
138 currentOpts.data = undefined;
141 $.colorbox(currentOpts);
143 var ajax =
new Ajax(
false);
146 }).done(
function(output) {
147 currentOpts.html = output;
148 $.colorbox(currentOpts);
151 currentOpts.html = undefined;
160 close: $.colorbox.close,
167 resize: $.colorbox.resize
170 lightbox.bind(
".elgg-lightbox");
171 lightbox.bind(
".elgg-lightbox-photo", {photo:
true});
172 lightbox.bind(
".elgg-lightbox-inline", {
inline:
true});
173 lightbox.bind(
".elgg-lightbox-iframe", {iframe:
true});
define(['jquery', 'elgg', 'elgg/Ajax', 'elgg/hooks', 'jquery.colorbox'], function($, elgg, Ajax, hooks){var lightbox={getOptions:function(opts){if(!$.isPlainObject(opts)){opts={};}var defaults=elgg.data.lightbox;if(!defaults.reposition){defaults.reposition=$(window).height() > 600;}var settings=$.extend({}, defaults, opts);return hooks.trigger('getOptions', 'ui.lightbox', null, settings);}, bind:function(selector, opts, use_element_data){if(!$.isPlainObject(opts)){opts={};}if(use_element_data===false){$(selector).colorbox(lightbox.getOptions(opts));return;}$(document).off('click.lightbox', selector).on('click.lightbox', selector, function(e){$(document).click();$('.elgg-system-messages.elgg-message').remove();e.preventDefault();var $this=$(this), href=$this.prop('href')||$this.prop('src'), dataOpts=$this.data('colorboxOpts'), currentOpts={};if(!$.isPlainObject(dataOpts)){dataOpts={};}if(!dataOpts.href &&href){dataOpts.href=href;}$.extend(currentOpts, opts, dataOpts);if(currentOpts.inline &¤tOpts.href){currentOpts.href=elgg.getSelectorFromUrlFragment(currentOpts.href);}if(currentOpts.photo||currentOpts.inline||currentOpts.iframe||currentOpts.html){lightbox.open(currentOpts);return;}currentOpts.ajaxLoadWithDependencies=true;lightbox.open(currentOpts);});$(window).off('resize.lightbox').on('resize.lightbox', function(){elgg.data.lightbox.reposition=$(window).height() > 600;lightbox.resize();});}, open:function(opts){var currentOpts=lightbox.getOptions(opts);if(!currentOpts.ajaxLoadWithDependencies){$.colorbox(currentOpts);return;}var href=currentOpts.href;currentOpts.href=false;var data=currentOpts.data;currentOpts.data=undefined;$.colorbox(currentOpts);var ajax=new Ajax(false);ajax.path(href,{data:data}).done(function(output){currentOpts.html=output;$.colorbox(currentOpts);currentOpts.html=undefined;});}, close:$.colorbox.close, resize:$.colorbox.resize};lightbox.bind(".elgg-lightbox");lightbox.bind(".elgg-lightbox-photo",{photo:true});lightbox.bind(".elgg-lightbox-inline",{inline:true});lightbox.bind(".elgg-lightbox-iframe",{iframe:true});return lightbox;})
Lightbox module.
function elgg combo checkbox click(function(){if($(this).is(':checked')){$(this).prev().attr('disabled', true);$(this).prev().val('');}else{$(this).prev().attr('disabled', false);}})