Methods
Events
See also Using the JavaScript API, Application API and Player API.
These API methods are to be called on a lightbox
object, which you can retrieve in the following way
var lightbox = sublime.lightbox(elementOrId);
which is equivalent to
var lightbox = sublime(elementOrId);
lightbox.open()
Opens the lightbox. If it’s already opened, this call has no effect.
lightbox.close()
Closes the lightbox. If it’s already closed, this call has no effect.
lightbox.on(eventOrHash, [callback])
eventOrHash
(String
| Object
) – A string representing the event name to listen, or an object where its keys are events and its values are callback functions.callback
(Function
) – The function to call when the event occurs. Pass this parameter only if the first one is an event (String
).Registers and invokes the given callbacks every time that the corresponding events occur.
Example – listening a single event
sublime('my_lightbox_trigger_id').on('didOpen', function(lightbox) {
console.log('lightbox opened.');
});
Example – listening more events
sublime('my_lightbox_trigger_id').on({
contentReady: function(lightbox, player) { console.log('content ready.') },
didOpen: function(lightbox) { console.log('lightbox opened.') },
didClose: function(lightbox) { console.log('lightbox closed.') }
});
Below are all the events supported by the lightbox. You listen to these events via the lightbox.on
method.
sublime('my_lightbox_trigger_id').on('<event_name>', my_callback_function);
contentReady
Fired when the lightbox’s content (e.g. the video player) has been prepared.
Callback parameters
lightbox
(Object
) – The lightbox api object.content
(Object
) – The content api object, which in most cases will be the player.sublime('my_lightbox_trigger_id').on('contentReady', function(lightbox, player) {
// player is now ready (prepared)
});
didOpen
Fired when the lightbox did open (after the opening transition has finished).
Callback parameters
lightbox
(Object
) – The lightbox api object.sublime('my_lightbox_trigger_id').on('didOpen', function(lightbox) {
// lightbox did open
});
didClose
Fired when the lightbox did close (after the closing transition has finished).
Callback parameters
lightbox
(Object
) – The lightbox api object.sublime('my_lightbox_trigger_id').on('didClose', function(lightbox) {
// lightbox did close
});