Mercurial > hg > digilib-old
comparison client/digitallibrary/jquery/jquery.digilib.js @ 793:63c1b33e38b1 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 | 304488c72344 |
children | ad5cc0212b66 |
comparison
equal
deleted
inserted
replaced
791:304488c72344 | 793:63c1b33e38b1 |
---|---|
267 if (plugins.geometry == null) { | 267 if (plugins.geometry == null) { |
268 $.error("jquery.digilib.geometry plugin not found!"); | 268 $.error("jquery.digilib.geometry plugin not found!"); |
269 // last straw: old version | 269 // last straw: old version |
270 geom = dlGeometry(); | 270 geom = dlGeometry(); |
271 } else { | 271 } else { |
272 geom = plugins.geometry.init(); | 272 // geometry plugin puts classes in the shared fn |
273 geom = fn.geometry; | |
273 } | 274 } |
274 FULL_AREA = geom.rectangle(0, 0, 1, 1); | 275 FULL_AREA = geom.rectangle(0, 0, 1, 1); |
275 | 276 |
276 // settings for this digilib instance are merged from defaults and options | 277 // settings for this digilib instance are merged from defaults and options |
277 var settings = $.extend({}, defaults, options); | 278 var settings = $.extend({}, defaults, options); |
325 settings : elemSettings, | 326 settings : elemSettings, |
326 queryParams : params, | 327 queryParams : params, |
327 // TODO: move plugins reference out of data | 328 // TODO: move plugins reference out of data |
328 plugins : plugins | 329 plugins : plugins |
329 }; | 330 }; |
330 // store in data element | 331 // store in jQuery data element |
331 $elem.data('digilib', data); | 332 $elem.data('digilib', data); |
332 } | 333 } |
333 unpackParams(data); | 334 unpackParams(data); |
334 // check if browser knows *background-size | 335 // check if browser knows *background-size |
335 for (var bs in {'':1, '-moz-':1, '-webkit-':1, '-o-':1}) { | 336 for (var bs in {'':1, '-moz-':1, '-webkit-':1, '-o-':1}) { |
356 } | 357 } |
357 } | 358 } |
358 // initialise plugins | 359 // initialise plugins |
359 for (n in plugins) { | 360 for (n in plugins) { |
360 var p = plugins[n]; | 361 var p = plugins[n]; |
361 // share common objects | 362 if (typeof p.init === 'function') { |
362 p.buttons = buttons; | 363 p.init(data); |
363 p.actions = actions; | 364 } |
364 p.fn = fn; | |
365 p.plugins = plugins; | |
366 // and init | |
367 p.init(data); | |
368 } | 365 } |
369 // get image info from server if needed | 366 // get image info from server if needed |
370 if (data.scaleMode === 'pixel' || data.scaleMode === 'size') { | 367 if (data.scaleMode === 'pixel' || data.scaleMode === 'size') { |
371 loadImageInfo(data, updateDisplay); // updateDisplay(data) on completion | 368 loadImageInfo(data, updateDisplay); // updateDisplay(data) on completion |
372 } | 369 } |
1805 if (action === 'plugin') { | 1802 if (action === 'plugin') { |
1806 var plugin = arguments[1]; | 1803 var plugin = arguments[1]; |
1807 // each plugin needs a name | 1804 // each plugin needs a name |
1808 if (plugin.name != null) { | 1805 if (plugin.name != null) { |
1809 plugins[plugin.name] = plugin; | 1806 plugins[plugin.name] = plugin; |
1807 // share common objects | |
1808 plugin.defaults = defaults; | |
1809 plugin.buttons = buttons; | |
1810 plugin.actions = actions; | |
1811 plugin.fn = fn; | |
1812 plugin.plugins = plugins; | |
1813 // and install | |
1814 if (typeof plugin.install === 'function') { | |
1815 plugin.install(plugin); | |
1816 } | |
1810 } | 1817 } |
1811 // initialisation of plugins done later | 1818 // initialisation of plugins done later |
1812 } else if (actions[action]) { | 1819 } else if (actions[action]) { |
1813 // call action on this with the remaining arguments (inserting data as first argument) | 1820 // call action on this with the remaining arguments (inserting data as first argument) |
1814 var $elem = $(this); | 1821 var $elem = $(this); |