-
Notifications
You must be signed in to change notification settings - Fork 101
Plugins
Juan Corona edited this page Mar 19, 2015
·
9 revisions
define(['readium-plugins'], function (Plugins) {
Plugins.register("pluginIdentifierHere", function (api) {
//plugin implementation here
});
});
define(['readium-plugins'], function (Plugins) {
Plugins.register("pluginIdentifierHere", function (api) {
api.plugin.warn('Something weird happened.')
api.plugin.error('Something bad happened. Cancel initialization!')
});
});
define(['readium-plugins'], function (Plugins) {
Plugins.register("pluginIdentifierHere", function (api) {
api.reader.on(ReadiumSDK.Events.CONTENT_DOCUMENT_LOADED, function ($iframe, spineItem) {
var contentDoc = $iframe[0].contentDocument;
contentDoc.body.style.backgroundColor = "red";
});
});
});
define(['readium-plugins'], function(Plugins) {
Plugins.register("pluginIdentifierHere", function(api) {
this.sayHello = function() {
alert('Hello world!');
};
api.extendReader(this);
});
});
Your plugin interface can be accessed using reader.plugins.pluginIdentifierHere
define(['readium-plugins'], function(Plugins) {
Plugins.register("pluginIdentifierHere", function(api) {
this.sayHello = function() {
this.emit('hello', 'Hello world!');
};
// This is required to set up your event emitter on the reader,
// even if you do not provide an API.
api.extendReader(this);
});
});
- Add your plugin.js file inside the /plugins folder
- Open up