changeset 1535:f129468a9ab8

relaxed access to plugins environment
author hertzhaft
date Mon, 10 Oct 2016 13:31:27 +0200
parents 3ef5f84d768f
children c883ee76e1a7
files webapp/src/main/webapp/jquery/jquery.digilib.js
diffstat 1 files changed, 12 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/webapp/src/main/webapp/jquery/jquery.digilib.js	Thu Oct 06 18:19:10 2016 +0200
+++ b/webapp/src/main/webapp/jquery/jquery.digilib.js	Mon Oct 10 13:31:27 2016 +0200
@@ -1911,21 +1911,22 @@
     $.fn.digilib = function (action) {
         // plugin extension mechanism, called when the plugins' code is read 
         if (action === 'plugin') {
-            var plugin = arguments[1];
+            var plugin = arguments[1] || {};
             // 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);
                 }
-            }
+            // 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);
+                }
+            return plugin;
             // plugins will be initialised when action.init is called
         } else if (actions[action]) {
             // call action on this with the remaining arguments (inserting data as first argument)