dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #26493
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13115: minor change to window scope resolver, changed it to be a configurable scope-resolver that return...
------------------------------------------------------------
revno: 13115
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-12-03 09:45:42 +0100
message:
minor change to window scope resolver, changed it to be a configurable scope-resolver that returns a function that operates within the wanted scope
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js 2013-12-03 08:37:21 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js 2013-12-03 08:45:42 +0000
@@ -30,19 +30,19 @@
dhis2.util.namespace('dhis2.contextmenu.utils');
/**
- * Tried to find a function with fnName in window scope.
- *
- * TODO: extend to search for more scopes
- *
- * @param fnName Name of function to search for
+ * Creates a resolver to search within a certain scope
+ *
+ * @param scope Scope to search within
* @returns Function
*/
-dhis2.contextmenu.utils.findFnInWindowScope = function( fnName ) {
- if( typeof window[fnName] !== 'function' ) {
- throw new Error('target-fn \'' + fnName + '\' does not point to a valid function.')
+dhis2.contextmenu.utils.findInScope = function( scope ) {
+ return function( fnName ) {
+ if( typeof scope[fnName] !== 'function' ) {
+ throw new Error('target-fn \'' + fnName + '\' does not point to a valid function.')
+ }
+
+ return scope[fnName];
}
-
- return window[fnName];
};
dhis2.contextmenu.defaultOptions = {
@@ -50,7 +50,7 @@
menuId: 'menu',
menuItemActiveClass: 'menuItemActive',
listItemProps: ['id', 'uid', 'name', 'type'],
- functionResolver: dhis2.contextmenu.utils.findFnInWindowScope
+ functionResolver: dhis2.contextmenu.utils.findInScope(window)
};
dhis2.contextmenu.config = dhis2.contextmenu.defaultOptions;