Commit 25405a73 authored by Thimo Kraemer's avatar Thimo Kraemer

Pass action params to event binder callbacks

parent 3cdc9b23
...@@ -805,26 +805,26 @@ kss._EventHandler.prototype = { ...@@ -805,26 +805,26 @@ kss._EventHandler.prototype = {
}, this); }, this);
}, },
_execClientAction: function(action, params, selector) { _execClientAction: function(name, params, selector) {
if (!kss._actionProviders[action]) { if (!kss._actionProviders[name]) {
this.error('Skipping non-existent client action "' + action + '"'); this.error('Skipping non-existent client action "' + name + '"');
return; return;
} }
var _params = {}; var _params = {};
kss.each(params, function(value, key) { kss.each(params, function(value, key) {
_params[kss.camelCase(key)] = value; _params[kss.camelCase(key)] = value;
}); });
action = {name: action, type: 'client'}; var action = {name: name, type: 'client', params: _params};
this._callBinders('onstart', action); this._callBinders('onstart', action);
var error; var error;
try { try {
selector = selector || this.kssProps('selector'); selector = selector || this.kssProps('selector');
var nodes = kss.cssQuery(selector, this.node, true); var nodes = kss.cssQuery(selector, this.node, true);
this.log('Execute client action "' + action.name + '" for ' this.log('Execute client action "' + name + '" for '
+ nodes.length + ' node(s) (selector "' + selector + '")'); + nodes.length + ' node(s) (selector "' + selector + '")');
this.debug('Parameters:', _params); this.debug('Parameters:', _params);
kss.each(nodes, function(node) { kss.each(nodes, function(node) {
kss._actionProviders[action.name].call(this, node, _params); kss._actionProviders[name].call(this, node, _params);
}, this); }, this);
} }
catch (err) { catch (err) {
...@@ -834,7 +834,7 @@ kss._EventHandler.prototype = { ...@@ -834,7 +834,7 @@ kss._EventHandler.prototype = {
this._callBinders('oncomplete', action, error); this._callBinders('oncomplete', action, error);
}, },
_execServerAction: function(action, params, timeout) { _execServerAction: function(name, params, timeout) {
// Prevent server actions for mouse moves // Prevent server actions for mouse moves
if (['mousemove','drag','dragover'].indexOf(this.eventname) > -1) { if (['mousemove','drag','dragover'].indexOf(this.eventname) > -1) {
return; return;
...@@ -843,17 +843,17 @@ kss._EventHandler.prototype = { ...@@ -843,17 +843,17 @@ kss._EventHandler.prototype = {
if (timeout) { if (timeout) {
config.timeout = timeout; config.timeout = timeout;
} }
var action = {name: name, type: 'server', params: params};
if (params && (config.protocol == 'xml-rpc' || if (params && (config.protocol == 'xml-rpc' ||
config.protocol == 'json-rpc-v1')) { config.protocol == 'json-rpc-v1')) {
params = [params]; params = [params];
} }
action = {name: action, type: 'server'};
this._callBinders('onstart', action); this._callBinders('onstart', action);
try { try {
var msg = this.time('Execute server action "' + action.name + '"'); var msg = this.time('Execute server action "' + name + '"');
var rpc = new kss.RPC(config.endpoint, config); var rpc = new kss.RPC(config.endpoint, config);
var self = this; var self = this;
rpc.invoke(action.name, params, rpc.invoke(name, params,
function(result) { function(result) {
var error; var error;
try { try {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment