← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17898: context-menu plugin, don't clear out highlight when fn is called

 

------------------------------------------------------------
revno: 17898
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-01-07 16:17:32 +0700
message:
  context-menu plugin, don't clear out highlight when fn is called
modified:
  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.sharing.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	2014-05-06 03:55:23 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js	2015-01-07 09:17:32 +0000
@@ -84,7 +84,8 @@
     var targetFn = $target.data('target-fn');
     var fn = config.functionResolver(targetFn);
 
-    dhis2.contextmenu.disable();
+    dhis2.contextmenu.disable(false);
+    $menu.attr('fn-active', true);
     fn(context);
 
     return false;
@@ -144,24 +145,45 @@
   });
 
   $(document).on('click.context', function() {
-    dhis2.contextmenu.disable();
-    $menu.removeData('id');
+    if( !dhis2.contextmenu.visibleUiDialog() ) {
+      dhis2.contextmenu.disable();
+      $menu.removeData('id');
+    }
   });
 
   $(document).keyup(function( e ) {
     if( e.keyCode == 27 ) {
-      dhis2.contextmenu.disable();
+      if( !dhis2.contextmenu.visibleUiDialog() ) {
+        dhis2.contextmenu.disable();
+      }
     }
   });
 };
 
-dhis2.contextmenu.disable = function() {
+dhis2.contextmenu.visibleUiDialog = function() {
+  if( $('.ui-dialog').is(':visible') ) {
+    return true;
+  }
+
+  if( Boolean($menu.attr('fn-active')) ) {
+    $menu.removeAttr('fn-active');
+    return true;
+  }
+
+  return false;
+};
+
+dhis2.contextmenu.disable = function( clearHighlight ) {
+  clearHighlight = $.type(clearHighlight) === 'boolean' ? clearHighlight : true;
+
   var config = dhis2.contextmenu.config;
   var $list = $('#' + config.listId);
   var $menu = $('#' + config.menuId);
 
-  $list.find('tr').removeClass(config.menuItemActiveClass);
-  $list.find('td').removeClass(config.menuItemActiveClass);
+  if( clearHighlight ) {
+    $list.find('tr').removeClass(config.menuItemActiveClass);
+    $list.find('td').removeClass(config.menuItemActiveClass);
+  }
 
   if( $menu.is(":visible") ) {
     $menu.hide();

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.sharing.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.sharing.js	2014-11-17 09:27:53 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.sharing.js	2015-01-07 09:17:32 +0000
@@ -143,12 +143,12 @@
 }
 
 function setCreatedBy( user ) {
-	if ( user && user.name ) {
-		$('#sharingUser').text(user.name);
-	}
-	else {
-		$('#sharingUser').text("[None]");
-	}
+  if( user && user.name ) {
+    $('#sharingUser').text(user.name);
+  }
+  else {
+    $('#sharingUser').text("[None]");
+  }
 }
 
 function showSharingDialogWithContext( context ) {
@@ -159,7 +159,7 @@
 
 function showSharingDialog( type, uid ) {
   loadSharingSettings(type, uid).done(function( data ) {
-	setCreatedBy(data.object.user);
+    setCreatedBy(data.object.user);
     setPublicAccess(data.object.publicAccess);
     setExternalAccess(data.object.externalAccess);
     setUserGroupAccesses(data.object.userGroupAccesses);
@@ -185,7 +185,7 @@
       height: 500,
       buttons: {
         'Cancel': function() {
-          $(this).dialog('close');
+          $(this).dialog('destroy');
         },
         'Save': function() {
           var me = $(this);
@@ -195,7 +195,7 @@
           data.object.userGroupAccesses = getUserGroupAccesses();
 
           saveSharingSettings(type, uid, data).done(function() {
-            me.dialog('close');
+            me.dialog('destroy');
           });
         }
       }