Commit 25405a73 by Thimo Kraemer

Pass action params to event binder callbacks

parent 3cdc9b23
......@@ -805,26 +805,26 @@ kss._EventHandler.prototype = {
}, this);
},
_execClientAction: function(action, params, selector) {
if (!kss._actionProviders[action]) {
this.error('Skipping non-existent client action "' + action + '"');
_execClientAction: function(name, params, selector) {
if (!kss._actionProviders[name]) {
this.error('Skipping non-existent client action "' + name + '"');
return;
}
var _params = {};
kss.each(params, function(value, key) {
_params[kss.camelCase(key)] = value;
});
action = {name: action, type: 'client'};
var action = {name: name, type: 'client', params: _params};
this._callBinders('onstart', action);
var error;
try {
selector = selector || this.kssProps('selector');
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 + '")');
this.debug('Parameters:', _params);
kss.each(nodes, function(node) {
kss._actionProviders[action.name].call(this, node, _params);
kss._actionProviders[name].call(this, node, _params);
}, this);
}
catch (err) {
......@@ -834,7 +834,7 @@ kss._EventHandler.prototype = {
this._callBinders('oncomplete', action, error);
},
_execServerAction: function(action, params, timeout) {
_execServerAction: function(name, params, timeout) {
// Prevent server actions for mouse moves
if (['mousemove','drag','dragover'].indexOf(this.eventname) > -1) {
return;
......@@ -843,17 +843,17 @@ kss._EventHandler.prototype = {
if (timeout) {
config.timeout = timeout;
}
var action = {name: name, type: 'server', params: params};
if (params && (config.protocol == 'xml-rpc' ||
config.protocol == 'json-rpc-v1')) {
params = [params];
}
action = {name: action, type: 'server'};
this._callBinders('onstart', action);
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 self = this;
rpc.invoke(action.name, params,
rpc.invoke(name, params,
function(result) {
var error;
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