Mercurial > hg > digilib-old
comparison client/digitallibrary/jquery/jquery.digilib.js @ 799:12f790cb30de jquery
started to adapt regions plugin to new plugin mechanism
author | hertzhaft |
---|---|
date | Fri, 18 Feb 2011 23:13:26 +0100 |
parents | b07d1824ca2a |
children | 1b1728926534 |
comparison
equal
deleted
inserted
replaced
798:b07d1824ca2a | 799:12f790cb30de |
---|---|
1594 setScaleMode : setScaleMode, | 1594 setScaleMode : setScaleMode, |
1595 isFullArea : isFullArea, | 1595 isFullArea : isFullArea, |
1596 getBorderWidth : getBorderWidth | 1596 getBorderWidth : getBorderWidth |
1597 }; | 1597 }; |
1598 | 1598 |
1599 // hook plugin into jquery | 1599 // hook digilib plugin into jquery |
1600 $.fn.digilib = function (action) { | 1600 $.fn.digilib = function (action) { |
1601 // plugin extension mechanism | 1601 // plugin extension mechanism, called when the plugins' code is read |
1602 if (action === 'plugin') { | 1602 if (action === 'plugin') { |
1603 var plugin = arguments[1]; | 1603 var plugin = arguments[1]; |
1604 // each plugin needs a name | 1604 // each plugin needs a name |
1605 if (plugin.name != null) { | 1605 if (plugin.name != null) { |
1606 plugins[plugin.name] = plugin; | 1606 plugins[plugin.name] = plugin; |
1613 // and install | 1613 // and install |
1614 if (typeof plugin.install === 'function') { | 1614 if (typeof plugin.install === 'function') { |
1615 plugin.install(plugin); | 1615 plugin.install(plugin); |
1616 } | 1616 } |
1617 } | 1617 } |
1618 // initialisation of plugins done later | 1618 // plugins will be initialised when action.init is called |
1619 } else if (actions[action]) { | 1619 } else if (actions[action]) { |
1620 // call action on this with the remaining arguments (inserting data as first argument) | 1620 // call action on this with the remaining arguments (inserting data as first argument) |
1621 var $elem = $(this); | 1621 var $elem = $(this); |
1622 var data = $elem.data('digilib'); | 1622 var data = $elem.data('digilib'); |
1623 var args = Array.prototype.slice.call(arguments, 1); | 1623 var args = Array.prototype.slice.call(arguments, 1); |
1624 args.unshift(data); | 1624 args.unshift(data); |
1625 return actions[action].apply(this, args); | 1625 return actions[action].apply(this, args); |
1626 } else if (typeof action === 'object' || !action) { | 1626 } else if (typeof action === 'object' || !action) { |
1627 // call init on this | 1627 // call init on the digilib jQuery object |
1628 return actions.init.apply(this, arguments); | 1628 return actions.init.apply(this, arguments); |
1629 } else { | 1629 } else { |
1630 $.error('action ' + action + ' does not exist on jQuery.digilib'); | 1630 $.error('action ' + action + ' does not exist on jQuery.digilib'); |
1631 } | 1631 } |
1632 }; | 1632 }; |