You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2012/11/21 15:08:11 UTC
svn commit: r1412112 - in /myfaces/tobago/trunk:
tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/
tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/html/
tobago-example/tobago-example-demo/src/main/webapp/content/01-basic...
Author: lofwyr
Date: Wed Nov 21 14:08:10 2012
New Revision: 1412112
URL: http://svn.apache.org/viewvc?rev=1412112&view=rev
Log:
TOBAGO-1217: Input-suggest: Make the number of characters to open the list configurable
Modified:
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/html/DataAttributesUnitTest.java
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/01-basic/basic.xhtml
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-in.js
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java?rev=1412112&r1=1412111&r2=1412112&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java Wed Nov 21 14:08:10 2012
@@ -111,11 +111,6 @@ public final class DataAttributes {
public static final String ROWACTION = "data-tobago-rowaction";
- /**
- * Custom suggest attribute. Used for input suggest.
- */
- public static final String SUGGEST = "data-tobago-suggest";
-
public static final String SELECTIONMODE = "data-tobago-selectionmode";
/**
@@ -153,6 +148,15 @@ public final class DataAttributes {
*/
public static final String STYLE = "data-tobago-style";
+ /**
+ * Custom suggest attribute. Used for input suggest.
+ */
+ public static final String SUGGEST = "data-tobago-suggest";
+
+ public static final String SUGGEST_DELAY = "data-tobago-suggest-delay";
+
+ public static final String SUGGEST_MIN_CHARS = "data-tobago-suggest-min-chars";
+
public static final String TRANSITION = "data-tobago-transition";
/**
Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/html/DataAttributesUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/html/DataAttributesUnitTest.java?rev=1412112&r1=1412111&r2=1412112&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/html/DataAttributesUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/html/DataAttributesUnitTest.java Wed Nov 21 14:08:10 2012
@@ -31,11 +31,11 @@ public class DataAttributesUnitTest {
for (Field field : DataAttributes.class.getFields()) {
String value = (String) field.get(null);
- Assert.assertTrue("Regexp check: value='" + value + "'", value.matches("data-tobago-[a-z]+"));
+ Assert.assertTrue("Regexp check: value='" + value + "'", value.matches("data-tobago(-[a-z]+)*-[a-z]+"));
String extension = value.substring("data-tobago-".length());
String name = field.getName();
- Assert.assertEquals(name, extension.toUpperCase());
+ Assert.assertEquals(name, extension.toUpperCase().replaceAll("-", "_"));
}
}
}
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/01-basic/basic.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/01-basic/basic.xhtml?rev=1412112&r1=1412111&r2=1412112&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/01-basic/basic.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/01-basic/basic.xhtml Wed Nov 21 14:08:10 2012
@@ -50,7 +50,7 @@
label="#{overviewBundle.basic_textboxLabel}" tip="#{overviewBundle.basic_textboxTip}"/>
<tx:in value="#{overviewController.suggestInput}" tabIndex="3"
label="#{overviewBundle.basic_suggestLabel}" tip="#{overviewBundle.basic_suggestTip}"
- suggestMethod="#{overviewController.getInputSuggestItems}"/>
+ suggestMethod="#{overviewController.getInputSuggestItems}" suggestDelay="300" suggestMinChars="1"/>
<tx:date value="#{overviewController.basicDate}" tabIndex="4"
label="#{overviewBundle.basic_dateLabel}" required="true">
<f:convertDateTime pattern="dd/MM/yyyy"/>
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java?rev=1412112&r1=1412111&r2=1412112&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java Wed Nov 21 14:08:10 2012
@@ -150,6 +150,11 @@ public class InRenderer extends InputRen
boolean required = ComponentUtils.getBooleanAttribute(input, Attributes.REQUIRED);
writer.writeAttribute(HtmlAttributes.REQUIRED, required);
writer.writeAttribute(DataAttributes.SUGGEST, renderAjaxSuggest);
+ if (renderAjaxSuggest) {
+ UIIn in = (UIIn) input;
+ writer.writeAttribute(DataAttributes.SUGGEST_MIN_CHARS, in.getSuggestMinChars());
+ writer.writeAttribute(DataAttributes.SUGGEST_DELAY, in.getSuggestDelay());
+ }
HtmlRendererUtils.renderFocus(id, input.isFocus(), ComponentUtils.isError(input), facesContext, writer);
writeAdditionalAttributes(facesContext, writer, input);
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-in.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-in.js?rev=1412112&r1=1412111&r2=1412112&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-in.js (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-in.js Wed Nov 21 14:08:10 2012
@@ -147,7 +147,7 @@ Tobago.In.prototype.leaveRequired = func
Tobago.registerListener(Tobago.In.init, Tobago.Phase.DOCUMENT_READY);
Tobago.registerListener(Tobago.In.init, Tobago.Phase.AFTER_UPDATE);
-Tobago.AutocompleterAjax = function (elementId, required, requiredClass, options) {
+Tobago.AutocompleterAjax = function (elementId, required, requiredClass) {
LOG.debug('new Tobago.AutocompleterAjax ' + elementId); // @DEV_ONLY
this.id = elementId;
this.required = required;
@@ -155,12 +155,6 @@ Tobago.AutocompleterAjax = function (ele
this.suggestions = null;
this.setup();
- this.options = {
- minPrefixLength:2,
- eventDelay:500,
- createOverlay:false
- };
-
this.requestActive = false;
this.rerequest = false;
@@ -168,8 +162,6 @@ Tobago.AutocompleterAjax = function (ele
this.index = 0;
- Tobago.extend(this.options, options);
-
var input = Tobago.element(elementId);
this.oldValue = input.value;
@@ -218,7 +210,8 @@ Tobago.AutocompleterAjax.prototype.doChe
}
this.oldValue = input.value;
- if (input.value.length < this.options.minPrefixLength) {
+ var inputElement = jQuery(Tobago.Utils.escapeClientId(this.id));
+ if (input.value.length < inputElement.data("suggest-min-chars")) {
return;
}
@@ -229,7 +222,7 @@ Tobago.AutocompleterAjax.prototype.doChe
var self = this;
this.currentTimeout = setTimeout(function () {
self.fetchSuggestions(input);
- }, this.options.eventDelay);
+ }, inputElement.data("suggest-delay"));
};
@@ -238,7 +231,7 @@ Tobago.AutocompleterAjax.prototype.fetch
if (!this.requestActive) {
this.requestActive = true;
LOG.debug('fetchSuggestions() request Suggestions for ' + input.value); // @DEV_ONLY
- Tobago.Updater.update(input, input.id, input.id, this.options);
+ Tobago.Updater.update(input, input.id, input.id, {createOverlay: false});
} else {
this.rerequest = true;
}
@@ -250,7 +243,7 @@ Tobago.AutocompleterAjax.prototype.befor
this.requestActive = true;
var input = Tobago.element(this.id);
LOG.debug('doUpdate() request Suggestions for ' + input.value); // @DEV_ONLY
- Tobago.Updater.update(input, input.id, input.id, this.options);
+ Tobago.Updater.update(input, input.id, input.id, {createOverlay: false});
return false;
} else {
return true;