Mercurial > hg > digilib
diff client/digitallibrary/jquery/jquery.digilib.js @ 786:912519475259 jquery
documentation for new plugin api in jquery-digilib-plugin.txt.
more steps towards plugification of birdseye view.
author | robcast |
---|---|
date | Fri, 18 Feb 2011 15:16:30 +0100 |
parents | 966d5c938b4c |
children | 1eef3e7a2270 |
line wrap: on
line diff
--- a/client/digitallibrary/jquery/jquery.digilib.js Fri Feb 18 10:39:40 2011 +0100 +++ b/client/digitallibrary/jquery/jquery.digilib.js Fri Feb 18 15:16:30 2011 +0100 @@ -269,7 +269,8 @@ // last straw: old version geom = dlGeometry(); } else { - geom = plugins.geometry.init(); + // geometry plugin puts classes in the shared fn + geom = fn.geometry; } FULL_AREA = geom.rectangle(0, 0, 1, 1); @@ -327,7 +328,7 @@ // TODO: move plugins reference out of data plugins : plugins }; - // store in data element + // store in jQuery data element $elem.data('digilib', data); } unpackParams(data); @@ -358,13 +359,9 @@ // initialise plugins for (n in plugins) { var p = plugins[n]; - // share common objects - p.buttons = buttons; - p.actions = actions; - p.fn = fn; - p.plugins = plugins; - // and init - p.init(data); + if (typeof p.init === 'function') { + p.init(data); + } } // get image info from server if needed if (data.scaleMode === 'pixel' || data.scaleMode === 'size') { @@ -1807,6 +1804,16 @@ // each plugin needs a name if (plugin.name != null) { plugins[plugin.name] = plugin; + // share common objects + plugin.defaults = defaults; + plugin.buttons = buttons; + plugin.actions = actions; + plugin.fn = fn; + plugin.plugins = plugins; + // and install + if (typeof plugin.install === 'function') { + plugin.install(plugin); + } } // initialisation of plugins done later } else if (actions[action]) {