← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13562: re-organized eventhandlers in interpretation dropdown

 

------------------------------------------------------------
revno: 13562
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-01-03 17:27:30 +0100
message:
  re-organized eventhandlers in interpretation dropdown
modified:
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretationFeed.vm
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.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-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretationFeed.vm'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretationFeed.vm	2013-12-03 10:10:00 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretationFeed.vm	2014-01-03 16:27:30 +0000
@@ -18,49 +18,7 @@
 var i18n_could_not_save_interpretation = '$encoder.jsEscape( $i18n.getString( "could_not_save_interpretation" ) , "'")';
 
 jQuery(function() {
-  var dropDown = jQuery('.dropDown');
-
-  dropDown.on('click.dropdown', 'li', function( e ) {
-    var jqTarget = jQuery(e.target).closest('li');
-    var targetFn = dhis2.contextmenu.utils.findInScope(window)(jqTarget.data('target-fn'));
-
-    if( typeof targetFn !== 'undefined' ) {
-      targetFn(e);
-    }
-  });
-
-  jQuery('.interpretationContainer').on('click', '.gearDropDown', function( e ) {
-    var jqTarget = jQuery(e.target).closest('.gearDropDown');
-    jQuery('.gearDropDown').removeClass('active');
-
-    if(dropDown.is(':visible')) {
-      dropDown.hide();
-      return false;
-    }
-
-    jqTarget.addClass('active');
-    dropDown.show();
-    dropDown.css({
-      top: jqTarget.offset().top + jqTarget.innerHeight(),
-      left: jqTarget.offset().left - 34
-    });
-
-    return false;
-  });
-
-  jQuery(document).on('click', function() {
-    if( dropDown.is(":visible") ) {
-      jQuery('.gearDropDown').removeClass('active');
-      dropDown.hide();
-    }
-  });
-
-  $(document).keyup(function( e ) {
-    if( e.keyCode == 27 ) {
-      jQuery('.gearDropDown').removeClass('active');
-      dropDown.hide();
-    }
-  });
+    updateEventHandlers();
 });
 </script>
 

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js	2013-12-02 15:20:44 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js	2014-01-03 16:27:30 +0000
@@ -44,6 +44,7 @@
     }
 
     pageLock = false;
+    updateEventHandlers();
   });
 }
 
@@ -208,3 +209,49 @@
     });
   }
 }
+
+function updateEventHandlers() {
+    var dropDown = jQuery('.dropDown');
+
+    dropDown.off('click.dropdown').on('click.dropdown', 'li', function( e ) {
+      var jqTarget = jQuery(e.target).closest('li');
+      var targetFn = dhis2.contextmenu.utils.findInScope(window)(jqTarget.data('target-fn'));
+
+      if( typeof targetFn !== 'undefined' ) {
+        targetFn(e);
+      }
+    });
+
+    jQuery('.interpretationContainer').off('click').on('click', '.gearDropDown', function( e ) {
+      var jqTarget = jQuery(e.target).closest('.gearDropDown');
+      jQuery('.gearDropDown').removeClass('active');
+
+      if(dropDown.is(':visible')) {
+        dropDown.hide();
+        return false;
+      }
+
+      jqTarget.addClass('active');
+      dropDown.show();
+      dropDown.css({
+        top: jqTarget.offset().top + jqTarget.innerHeight(),
+        left: jqTarget.offset().left - 34
+      });
+
+      return false;
+    });
+
+    jQuery(document).off('click').on('click', function() {
+      if( dropDown.is(":visible") ) {
+        jQuery('.gearDropDown').removeClass('active');
+        dropDown.hide();
+      }
+    });
+
+    $(document).keyup(function( e ) {
+      if( e.keyCode == 27 ) {
+        jQuery('.gearDropDown').removeClass('active');
+        dropDown.hide();
+      }
+    });
+}