Author: pyaschenko
Date: 2009-02-13 09:17:51 -0500 (Fri, 13 Feb 2009)
New Revision: 12655
Modified:
trunk/ui/componentControl/src/main/resources/org/richfaces/renderkit/html/script/controlUtils.js
trunk/ui/contextMenu/src/main/resources/org/richfaces/renderkit/html/scripts/context-menu.js
Log:
https://jira.jboss.org/jira/browse/RF-5225
Modified:
trunk/ui/componentControl/src/main/resources/org/richfaces/renderkit/html/script/controlUtils.js
===================================================================
---
trunk/ui/componentControl/src/main/resources/org/richfaces/renderkit/html/script/controlUtils.js 2009-02-13
13:42:30 UTC (rev 12654)
+++
trunk/ui/componentControl/src/main/resources/org/richfaces/renderkit/html/script/controlUtils.js 2009-02-13
14:17:51 UTC (rev 12655)
@@ -40,6 +40,14 @@
};
Richfaces.componentControl.performOperation = function( cevent, forAttr, operation,
params, disableDefault) {
+
+ // stop event before event isn't extended by prototype
+ if (disableDefault) {
+ var event = jQuery.event.fix(cevent);
+ event.stopPropagation();
+ event.preventDefault();
+ }
+
Richfaces.componentControl.eachComponent(forAttr, function(component) {
var paramsValue = params;
if (typeof params == "function") {
@@ -48,9 +56,6 @@
component[operation](cevent, paramsValue);
});
- if (disableDefault) {
- Event.stop(cevent);
- }
};
Modified:
trunk/ui/contextMenu/src/main/resources/org/richfaces/renderkit/html/scripts/context-menu.js
===================================================================
---
trunk/ui/contextMenu/src/main/resources/org/richfaces/renderkit/html/scripts/context-menu.js 2009-02-13
13:42:30 UTC (rev 12654)
+++
trunk/ui/contextMenu/src/main/resources/org/richfaces/renderkit/html/scripts/context-menu.js 2009-02-13
14:17:51 UTC (rev 12655)
@@ -17,15 +17,42 @@
},
destroy: function() {
+ this.enableDefaultContextMenu();
this.element.component = null;
this.element = null;
this.menuContent = null;
},
+ disableDefaultContextMenu: function (element, id, event, attachedToPerent)
+ {
+ if (event=="oncontextmenu") {
+ this.attachedToElementId = id;
+ this.attachedToParent = attachedToPerent;
+ this.eventName = "contextmenu";
+
+ Event.observe(element, this.eventName, Event.stop);
+ }
+ },
+
+ enableDefaultContextMenu: function ()
+ {
+ if (this.eventName=="contextmenu" && this.attachedToElementId) {
+ var element = $(this.attachedToElementId);
+ if (!element && this.attachedToParent) {
+ element = this.element;
+ if (element) {
+ element = element.parentNode;
+ }
+ }
+ Event.stopObserving(element, this.eventName, Event.stop);
+ }
+ },
+
// attach contextMenu to element specified by id
attachToElementById : function(id, event, context) {
var element = $(id);
+ this.disableDefaultContextMenu(element, id, event, false);
this.attachToElement(element, event, context);
},
@@ -39,7 +66,7 @@
element = element.parentNode;
}
}
-
+ disableDefaultContextMenu(element, id, event, true);
this.attachToElement(element, event, context);
},