Elgg  Version 2.3
lightbox.js.php
Go to the documentation of this file.
1 <?php
28 ?>
29 //<script>
30 
31 // We don't depend on elgg/lightbox because it blocks until after elgg/init.
32 // We want this API available immediately.
33 require(['elgg', 'jquery', 'jquery.colorbox'], function (elgg, $) {
34 
35  elgg.deprecated_notice('lightbox.js library has been deprecated. Avoid using elgg_load_js("lightbox.js"), ' +
36  'use elgg/lightbox AMD module instead');
37 
38  elgg.provide('elgg.ui.lightbox');
39 
40  if (typeof elgg.ui.lightbox.getSettings === 'function') {
41  elgg.ui.lightbox.deprecated_settings = elgg.ui.lightbox.getSettings();
42  }
43 
48  elgg.ui.lightbox.init = function () {
49  elgg.deprecated_notice('elgg.ui.lightbox.init() has been deprecated and should not be called directly. ' +
50  'Lightbox is initialized automatically in elgg AMD module', '2.2');
51  };
52 
57  elgg.ui.lightbox.getSettings = function (opts) {
58  elgg.deprecated_notice('elgg.ui.lightbox.getSettings() has been deprecated and should not be called ' +
59  'directly. Use elgg/lightbox AMD module instead', '2.2');
60 
61  if (!$.isPlainObject(opts)) {
62  opts = {};
63  }
64 
65  // Note: keep these in sync with /views/default/elgg/lightbox.js
66  var settings = {
67  current: elgg.echo('js:lightbox:current', ['{current}', '{total}']),
68  previous: elgg.echo('previous'),
69  next: elgg.echo('next'),
70  close: elgg.echo('close'),
71  xhrError: elgg.echo('error:default'),
72  imgError: elgg.echo('error:default'),
73  opacity: 0.5,
74  maxWidth: '100%',
75  // don't move colorbox on small viewports https://github.com/Elgg/Elgg/issues/5312
76  reposition: $(window).height() > 600
77  };
78 
79  elgg.provide('elgg.ui.lightbox');
80 
81  if ($.isPlainObject(elgg.ui.lightbox.deprecated_settings)) {
82  $.extend(settings, elgg.ui.lightbox.deprecated_settings, opts);
83  } else {
84  $.extend(settings, opts);
85  }
86 
87  return elgg.trigger_hook('getOptions', 'ui.lightbox', null, settings);
88  };
89 
94  elgg.ui.lightbox.bind = function () {
95  elgg.deprecated_notice('elgg.ui.lightbox.bind() has been deprecated. Use elgg/lightbox AMD module ' +
96  'instead', '2.2');
97 
98  require(['elgg/lightbox'], function (lightbox) {
99  return lightbox.bind.apply(this, arguments);
100  });
101  };
106  elgg.ui.lightbox.close = function () {
107  elgg.deprecated_notice('elgg.ui.lightbox.close() has been deprecated. Use elgg/lightbox AMD module ' +
108  'instead', '2.2');
109 
110  require(['elgg/lightbox'], function (lightbox) {
111  return lightbox.close.apply(this, arguments);
112  });
113  };
114 
115  function registerDeprecationError() {
116  elgg.register_error("fancybox lightbox has been replaced by colorbox.", 9999999999999);
117  }
118 
119  if (typeof $.fancybox === 'undefined') {
120  $.fancybox = {
121  // error message for firefox users
122  __noSuchMethod__: registerDeprecationError,
123  close: function () {
124  registerDeprecationError();
125  $.colorbox.close();
126  }
127  };
128  // support $().fancybox({type:'image'})
129  $.fn.fancybox = function (arg) {
130  registerDeprecationError();
131  if (arg.type === 'image') {
132  arg.photo = true;
133  }
134  this.colorbox(arg);
135  return this;
136  };
137  }
138 });
elgg
Definition: install.js:23
elgg isPlainObject
Check if the value is a "plain" object (i.e., created by {} or new Object())
Definition: elgglib.js:75
line height
Definition: admin.css.php:82
elgg form settings
Definition: admin.css.php:627
friends picker navigation li a current
Definition: admin.css.php:856
elgg require
Throw an error if the required package isn&#39;t present.
Definition: elgglib.js:164
ui datepicker ui datepicker next
Definition: admin.css.php:651