Elgg
Version 2.3
|
Go to the source code of this file.
Functions | |
define ('elgg/lightbox', 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 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'), opacity:0.5, maxWidth: '100%', reposition:$(window).height() > 600};elgg.provide('elgg.ui.lightbox');if($.isPlainObject(elgg.ui.lightbox.deprecated_settings)){$.extend(settings, elgg.ui.lightbox.deprecated_settings, opts);}else{$.extend(settings, 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){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);}lightbox.open(currentOpts);});}, 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 We use a named module and inline it in elgg.js. More... | |
define | ( | 'elgg/lightbox' | , |
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 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'), opacity:0.5, maxWidth: '100%', reposition:$(window).height() > 600};elgg.provide('elgg.ui.lightbox');if($.isPlainObject(elgg.ui.lightbox.deprecated_settings)){$.extend(settings, elgg.ui.lightbox.deprecated_settings, opts);}else{$.extend(settings, 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){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);}lightbox.open(currentOpts);});}, 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 We use a named module and inline it in elgg.js.
This allows us to deprecate the old elgg.ui.lightbox library.
elgg/lightbox
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 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'), opacity:0.5, maxWidth: '100', reposition:.height() > 600};elgg.provide('elgg.ui.lightbox');if($.isPlainObject(elgg.ui.lightbox.deprecated_settings)){$.extend(settings, elgg.ui.lightbox.deprecated_settings, opts);}else{$.extend(settings, 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){.colorbox(lightbox.getOptions(opts));return;}.off('click.lightbox', selector).on('click.lightbox', selector, function(e){e.preventDefault();var $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);}lightbox.open(currentOpts);});}, 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;} Returns lightbox settings |
{Object} | opts Additional options |
Bind colorbox lightbox click to HTML
{Object} | selector CSS selector matching colorbox openers |
{Object} | opts Colorbox options. These are overridden by data-colorbox-opts options |
{Boolean} | use_element_data If set to false, selector will be bound directly as .colorbox() |
Open the colorbox
{object} | opts Colorbox options |
Close the colorbox
Resizes the colorbox