From 8f19c47cfbccd1f40739aa5cb8ea22b2697c0e5e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Fri, 10 Feb 2017 13:21:41 +0100 Subject: [PATCH] kivi.Part.js: run_action als wrapper um functions und strings --- js/kivi.Part.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/js/kivi.Part.js b/js/kivi.Part.js index d7bbd2ffd..41e94bb9d 100644 --- a/js/kivi.Part.js +++ b/js/kivi.Part.js @@ -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 = $('').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 = { -- 2.20.1