mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 09:09:04 +01:00
allow to use hierarchical function names, eg. app.filemanager.upload via new et2_call function
This commit is contained in:
parent
28aab234a7
commit
3a14e96d1a
@ -733,3 +733,35 @@ function et2_rangeSubstract(_ar1, _ar2)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call a function specified by it's name (possibly dot separated, eg. "app.myapp.myfunc")
|
||||||
|
*
|
||||||
|
* @param string func dot-separated function name
|
||||||
|
* @param arguments variable number of arguments
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
|
function et2_call(_func)
|
||||||
|
{
|
||||||
|
var args = [].slice.call(arguments); // convert arguments to array
|
||||||
|
var func = args.shift();
|
||||||
|
var parent = window;
|
||||||
|
|
||||||
|
if (typeof _func == 'string')
|
||||||
|
{
|
||||||
|
var parts = _func.split('.');
|
||||||
|
func = parts.pop();
|
||||||
|
for(var i=0; i < parts.length && typeof parent[parts[i]] != 'undefined'; ++i)
|
||||||
|
{
|
||||||
|
parent = parent[parts[i]];
|
||||||
|
}
|
||||||
|
if (typeof parent[func] == 'function')
|
||||||
|
{
|
||||||
|
func = parent[func];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (typeof func != 'function')
|
||||||
|
{
|
||||||
|
throw _func+" is not a function!";
|
||||||
|
}
|
||||||
|
return func.apply(parent, args);
|
||||||
|
}
|
||||||
|
@ -258,7 +258,7 @@ var et2_file = et2_inputWidget.extend(
|
|||||||
this.disabled_buttons = $j("input[type='submit'], button").not("[disabled]").attr("disabled", true);
|
this.disabled_buttons = $j("input[type='submit'], button").not("[disabled]").attr("disabled", true);
|
||||||
|
|
||||||
event.data = this;
|
event.data = this;
|
||||||
if(this.options.onStart && typeof this.options.onStart == 'function') return this.options.onStart(event,file_count);
|
if(this.options.onStart) return et2_call(this.options.onStart, event, file_count);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ var et2_file = et2_inputWidget.extend(
|
|||||||
onFinish: function(event, file_count) {
|
onFinish: function(event, file_count) {
|
||||||
this.disabled_buttons.attr("disabled", false);
|
this.disabled_buttons.attr("disabled", false);
|
||||||
event.data = this;
|
event.data = this;
|
||||||
if(this.options.onFinish && typeof this.options.onFinish == 'function') return this.options.onFinish(event,file_count);
|
if(this.options.onFinish) return et2_call(this.options.onFinish, event, file_count);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
@ -326,7 +326,6 @@ console.warn(event,name,error);
|
|||||||
if(typeof response.response[0].data[key] == "string")
|
if(typeof response.response[0].data[key] == "string")
|
||||||
{
|
{
|
||||||
// Message from server - probably error
|
// Message from server - probably error
|
||||||
|
|
||||||
$j("[file='"+name+"']",this.progress)
|
$j("[file='"+name+"']",this.progress)
|
||||||
.addClass("error")
|
.addClass("error")
|
||||||
.css("display", "block")
|
.css("display", "block")
|
||||||
@ -349,9 +348,9 @@ console.warn(event,name,error);
|
|||||||
.css("display", "block")
|
.css("display", "block")
|
||||||
.text(this.egw().lang("Server error"));
|
.text(this.egw().lang("Server error"));
|
||||||
}
|
}
|
||||||
if(this.options.onFinishOne && typeof this.options.onFinishOne == 'function')
|
if(this.options.onFinishOne)
|
||||||
{
|
{
|
||||||
return this.options.onFinishOne(event,response,name,number,total);
|
return et2_call(this.options.onFinishOne,event,response,name,number,total);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user