41 getOptions:
function (opts) {
47 var defaults = elgg.data.lightbox;
49 if (!defaults.reposition) {
51 defaults.reposition = $(window).height() > 600;
54 elgg.provide(
'elgg.ui.lightbox');
56 var settings = $.extend({}, defaults, opts);
58 return elgg.trigger_hook(
'getOptions',
'ui.lightbox', null, settings);
69 bind:
function (selector, opts, use_element_data) {
75 if (use_element_data ===
false) {
76 $(selector).colorbox(lightbox.getOptions(opts));
81 .off(
'click.lightbox', selector)
82 .on(
'click.lightbox', selector,
function (e) {
87 $(
'.elgg-system-messages .elgg-message').
remove();
91 href = $this.prop(
'href') || $this.prop(
'src'),
93 dataOpts = $this.data(
'colorboxOpts'),
100 if (!dataOpts.href && href) {
101 dataOpts.href = href;
105 $.extend(currentOpts, opts, dataOpts);
106 if (currentOpts.inline && currentOpts.href) {
107 currentOpts.href = elgg.getSelectorFromUrlFragment(currentOpts.href);
110 if (currentOpts.photo || currentOpts.inline || currentOpts.iframe || currentOpts.html) {
111 lightbox.open(currentOpts);
115 href = currentOpts.href;
116 currentOpts.href =
false;
117 var data = currentOpts.data;
118 currentOpts.data = undefined;
121 lightbox.open(currentOpts);
123 require([
'elgg/Ajax'],
function(Ajax) {
124 var
ajax =
new Ajax(
false);
125 ajax.path(href, {data: data}).done(
function(output) {
126 currentOpts.html = output;
127 lightbox.open(currentOpts);
130 currentOpts.html = undefined;
136 .off(
'resize.lightbox')
137 .on(
'resize.lightbox',
function() {
138 elgg.data.lightbox.reposition = $(window).height() > 600;
149 open:
function (opts) {
150 $.colorbox(lightbox.getOptions(opts));
157 close: $.colorbox.close,
163 resize: $.colorbox.resize
166 lightbox.bind(
".elgg-lightbox");
167 lightbox.bind(
".elgg-lightbox-photo", {photo:
true});
168 lightbox.bind(
".elgg-lightbox-inline", {
inline:
true});
169 lightbox.bind(
".elgg-lightbox-iframe", {iframe:
true});
elgg isPlainObject
Check if the value is a "plain" object (i.e., created by {} or new Object())
elgg ajax
Wrapper function for jQuery.ajax which ensures that the url being called is relative to the elgg site...
elgg require
Throw an error if the required package isn't present.
define(function(require){var elgg=require('elgg');var $=require('jquery');require('elgg/init');require('jquery.colorbox');var lightbox={getOptions:function(opts){if(!$.isPlainObject(opts)){opts={};}var defaults=elgg.data.lightbox;if(!defaults.reposition){defaults.reposition=$(window).height() > 600;}elgg.provide('elgg.ui.lightbox');var settings=$.extend({}, defaults, opts);return elgg.trigger_hook('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;}href=currentOpts.href;currentOpts.href=false;var data=currentOpts.data;currentOpts.data=undefined;lightbox.open(currentOpts);require(['elgg/Ajax'], function(Ajax){var ajax=new Ajax(false);ajax.path(href,{data:data}).done(function(output){currentOpts.html=output;lightbox.open(currentOpts);currentOpts.html=undefined;});});});$(window).off('resize.lightbox').on('resize.lightbox', function(){elgg.data.lightbox.reposition=$(window).height() > 600;lightbox.resize();});}, open:function(opts){$.colorbox(lightbox.getOptions(opts));}, 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);}})