Author: nbelaevski
Date: 2008-08-07 13:26:56 -0400 (Thu, 07 Aug 2008)
New Revision: 9979
Modified:
trunk/ui/hotKey/src/main/config/component/hotKey.xml
trunk/ui/hotKey/src/main/resources/org/richfaces/renderkit/html/scripts/jquery.hotkeys.js
trunk/ui/hotKey/src/main/templates/org/richfaces/htmlHotKey.jspx
trunk/ui/hotKey/src/test/java/org/richfaces/component/HotKeyComponentTest.java
Log:
https://jira.jboss.org/jira/browse/RF-4021
Modified: trunk/ui/hotKey/src/main/config/component/hotKey.xml
===================================================================
--- trunk/ui/hotKey/src/main/config/component/hotKey.xml 2008-08-07 17:04:14 UTC (rev
9978)
+++ trunk/ui/hotKey/src/main/config/component/hotKey.xml 2008-08-07 17:26:56 UTC (rev
9979)
@@ -86,5 +86,10 @@
</description>
<defaultvalue>""</defaultvalue>
</property>
+ <property>
+ <name>disableInInputTypes</name>
+ <classname>java.lang.String</classname>
+ <defaultvalue>""</defaultvalue>
+ </property>
</component>
</components>
Modified:
trunk/ui/hotKey/src/main/resources/org/richfaces/renderkit/html/scripts/jquery.hotkeys.js
===================================================================
---
trunk/ui/hotKey/src/main/resources/org/richfaces/renderkit/html/scripts/jquery.hotkeys.js 2008-08-07
17:04:14 UTC (rev 9978)
+++
trunk/ui/hotKey/src/main/resources/org/richfaces/renderkit/html/scripts/jquery.hotkeys.js 2008-08-07
17:26:56 UTC (rev 9979)
@@ -57,13 +57,15 @@
return node[this._uniqueIDExpando];
};
+ this.buttonInputTypes = /^(submit|button|reset)$/i;
+
this.add = function(combi, options, callback) {
if (jQuery.isFunction(options)){
callback = options;
options = {};
}
var opt = {},
- defaults = {type: 'keydown', propagate: false, disableInInput: false,
target: jQuery('html')[0], checkParent: true},
+ defaults = {type: 'keydown', propagate: false, disableInInput: false,
disableInInputTypes: 'all', target: jQuery('html')[0], checkParent:
true},
that = this;
opt = jQuery.extend( opt , defaults, options || {} );
combi = combi.toLowerCase();
@@ -77,8 +79,30 @@
if(opt['disableInInput']) { // Disable shortcut keys in Input,
Textarea fields
var target = jQuery(element);
- if( target.is("input") || target.is("textarea")){
- return;
+ var types = opt['disableInInputTypes'];
+
+ if (target.is("input")) {
+ if ('all' == types) {
+ return;
+ } else {
+ if (that.buttonInputTypes.test(target.attr('type'))) {
+ if ('buttons' == types) {
+ return;
+ }
+ } else {
+ if ('inputs' == types) {
+ return;
+ }
+ }
+ }
+ } else if (target.is("textarea")) {
+ if ('inputs' == types || 'all' == types) {
+ return;
+ }
+ } else if (target.is("button")) {
+ if ('buttons' == types || 'all' == types) {
+ return;
+ }
}
}
var code = event.which,
Modified: trunk/ui/hotKey/src/main/templates/org/richfaces/htmlHotKey.jspx
===================================================================
--- trunk/ui/hotKey/src/main/templates/org/richfaces/htmlHotKey.jspx 2008-08-07 17:04:14
UTC (rev 9978)
+++ trunk/ui/hotKey/src/main/templates/org/richfaces/htmlHotKey.jspx 2008-08-07 17:26:56
UTC (rev 9979)
@@ -60,6 +60,22 @@
options.append(disableInInput);
}
+ String disableInInputTypes = (String)
attributes.get("disableInInputTypes");
+ if (disableInInputTypes != null && disableInInputTypes.length() > 0) {
+ if (Boolean.TRUE.equals(disableInInput)) {
+ options.append(",disableInInputTypes:");
+ options.append('\'');
+ options.append(getUtils().escapeJavaScript(disableInInputTypes));
+ options.append('\'');
+ } else {
+ context.getExternalContext().log(
+ "Attribute disableInInputTypes='" + disableInInputTypes +
+ "' will be ignored for component '" +
+ org.richfaces.component.util.MessageUtil.getLabel(context, component) +
+ "', because value of disableInInput attribute is not
'true'");
+ }
+ }
+
Boolean checkParent = (Boolean) attributes.get("checkParent");
if (checkParent != null) {
options.append(",checkParent:");
Modified: trunk/ui/hotKey/src/test/java/org/richfaces/component/HotKeyComponentTest.java
===================================================================
---
trunk/ui/hotKey/src/test/java/org/richfaces/component/HotKeyComponentTest.java 2008-08-07
17:04:14 UTC (rev 9978)
+++
trunk/ui/hotKey/src/test/java/org/richfaces/component/HotKeyComponentTest.java 2008-08-07
17:26:56 UTC (rev 9979)
@@ -154,6 +154,7 @@
attributes.put("type", "keypress");
attributes.put("propagate", Boolean.TRUE);
attributes.put("disableInInput", Boolean.FALSE);
+ attributes.put("disableInInputTypes", "all");
attributes.put("checkParent", Boolean.TRUE);
String scriptBody = processScriptBody();
@@ -166,10 +167,11 @@
attributes.put("type", "onkeyup");
attributes.put("propagate", Boolean.FALSE);
attributes.put("disableInInput", Boolean.TRUE);
+ attributes.put("disableInInputTypes", "texts");
attributes.put("checkParent", Boolean.FALSE);
String scriptBody = processScriptBody();
- assertEquals("'myForm:hKey','','',{timing:'onload',type:'keyup',propagate:false,disableInInput:true,checkParent:false},function(event){}",
scriptBody);
+ assertEquals("'myForm:hKey','','',{timing:'onload',type:'keyup',propagate:false,disableInInput:true,disableInInputTypes:'texts',checkParent:false},function(event){}",
scriptBody);
}
public void testHandler() throws Exception {