kivi.Part.js: run_action als wrapper um functions und strings
authorSven Schöling <s.schoeling@linet-services.de>
Fri, 10 Feb 2017 12:21:41 +0000 (13:21 +0100)
committerSven Schöling <s.schoeling@linet-services.de>
Mon, 13 Feb 2017 15:32:44 +0000 (16:32 +0100)
js/kivi.Part.js

index d7bbd2f..41e94bb 100644 (file)
@@ -384,13 +384,13 @@ namespace('kivi.Part', function(ns) {
         success: function (data) {
           if (data.length == 1) {
             self.set_item(data[0]);
-            if (callbacks && callbacks.match_one) callbacks.match_one(data[0]);
+            if (callbacks && callbacks.match_one) self.run_action(callbacks.match_one, [ data[0] ]);
           } else if (data.length > 1) {
             self.state = self.STATES.UNDEFINED;
-            if (callbacks && callbacks.match_many) callbacks.match_many(data);
+            if (callbacks && callbacks.match_many) self.run_action(callbacks.match_many, [ data ]);
           } else {
             self.state = self.STATES.UNDEFINED;
-            if (callbacks && callbacks.match_none) callbacks.match_none();
+            if (callbacks && callbacks.match_none) self.run_action(callbacks.match_none);
           }
           self.annotate_state();
         }
@@ -480,6 +480,12 @@ namespace('kivi.Part', function(ns) {
       var popup_button = $('<span>').addClass('ppp_popup_button');
       this.$dummy.after(popup_button);
       popup_button.click(function() { self.open_dialog() });
+    },
+    run_action: function(code, args) {
+      if (typeof code === 'function')
+        code.apply(this, args)
+      else
+        kivi.run(code, args);
     }
   };
   ns.Picker.prototype.STATES = {