Elgg  Version 1.9
lightbox.php
Go to the documentation of this file.
1 <?php
34 ?>
35 //<script>
36 
37 elgg.provide('elgg.ui.lightbox');
38 
39 <?php echo elgg_view('js/lightbox/settings'); ?>
40 
44 elgg.ui.lightbox.init = function() {
45  function registerDeprecationError() {
46  elgg.register_error("fancybox lightbox has been replaced by colorbox", 9999999999999);
47  }
48 
49  elgg.ui.lightbox.bind(".elgg-lightbox");
50  elgg.ui.lightbox.bind(".elgg-lightbox-photo", {photo: true});
51 
52  if (typeof $.fancybox === 'undefined') {
53  $.fancybox = {
54  // error message for firefox users
55  __noSuchMethod__ : registerDeprecationError,
56  close: function () {
57  registerDeprecationError();
58  $.colorbox.close();
59  }
60  };
61  // support $().fancybox({type:'image'})
62  $.fn.fancybox = function (arg) {
63  registerDeprecationError();
64  if (arg.type === 'image') {
65  arg.photo = true;
66  }
67  this.colorbox(arg);
68  return this;
69  };
70  }
71 };
72 
79 elgg.ui.lightbox.bind = function (selector, opts) {
80  if (!$.isPlainObject(opts)) {
81  opts = {};
82  }
83 
84  // merge opts into defaults
85  opts = $.extend({}, elgg.ui.lightbox.getSettings(), opts);
86 
87  $(document).on('click', selector, function (e) {
88  var $this = $(this),
89  href = $this.prop('href') || $this.prop('src'),
90  dataOpts = $this.data('colorboxOpts');
91  // Q: why not use "colorbox"? A: https://github.com/jackmoore/colorbox/issues/435
92 
93  if (!$.isPlainObject(dataOpts)) {
94  dataOpts = {};
95  }
96 
97  // merge data- options into opts
98  $.colorbox($.extend({href: href}, opts, dataOpts));
99  e.preventDefault();
100  });
101 };
102 
107 elgg.ui.lightbox.close = function() {
108  $.colorbox.close();
109 };
110 
111 elgg.register_hook_handler('init', 'system', elgg.ui.lightbox.init);
112 
113 <?php
114 
116 $js_path = "{$js_path}vendors/jquery/colorbox/jquery.colorbox-min.js";
117 readfile($js_path);
elgg photo
Definition: components.php:249
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
$js_path
Elgg lightbox.
Definition: lightbox.php:115
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype='')
Return a parsed view.
Definition: views.php:354