------------------------------------------------------------
revno: 13115
committer: Morten Olav Hansen <morte...@gmail.com>
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;

_______________________________________________
Mailing list: https://launchpad.net/~dhis2-devs
Post to     : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp

Reply via email to