File: D:/HostingSpaces/SBogers10/honger7.komma.pro/resources/assets/js/site/helpers.js
/*
* Simple isset method for this does not exist in javascript
*/
var isset = function(obj)
{
return typeof obj !== 'undefined' && obj !== null;
};
/**
* With this method you can call a function with it's string name
* This will also work with namespaced functions
* executeFunctionByName("My.Namespace.functionName", window, arguments);
*
* @param functionName
* @param context
* @returns {*}
*/
function executeFunctionByName(functionName, context /*, args */) {
var args = [].slice.call(arguments).splice(2);
// Split function name on .
var namespaces = functionName.split(".");
// Return last element of array and remove it
var func = namespaces.pop();
// Loop through every namespace
for(var i = 0; i < namespaces.length; i++) {
// Overwrite context with the namespace
// We go one level deeper every time
context = context[namespaces[i]];
}
// Finally call the function in the current context
return context[func].apply(context, args);
}