-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP Issues/995 #1141
base: master
Are you sure you want to change the base?
WIP Issues/995 #1141
Changes from all commits
04a70f0
66b46e2
1b0dddf
3c33566
f9bc1cd
cd4ecb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,12 +175,9 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce | |
|
||
if (visible && label != null) { | ||
rw.startElement("label", component); | ||
rw.writeAttribute("for", fieldId, "for"); // "input_" + | ||
// clientId | ||
generateErrorAndRequiredClass(inputText, rw, clientId, inputText.getLabelStyleClass(), responsiveLabelClass, | ||
"control-label"); | ||
rw.writeAttribute("for", fieldId, "for"); // "input_" + clientId | ||
generateErrorAndRequiredClass(inputText, rw, clientId, inputText.getLabelStyleClass(), responsiveLabelClass, "control-label"); | ||
writeAttribute(rw, "style", inputText.getLabelStyle()); | ||
|
||
rw.writeText(label, null); | ||
rw.endElement("label"); | ||
} | ||
|
@@ -204,12 +201,13 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce | |
// Input | ||
rw.startElement("input", inputText); | ||
rw.writeAttribute("id", fieldId, null); // "input_" + clientId | ||
|
||
String name = inputText.getName(); | ||
// System.out.println(name); | ||
if (null == name) { | ||
name = "input_" + clientId; | ||
} | ||
rw.writeAttribute("name", name, null); | ||
|
||
rw.writeAttribute("type", t, null); | ||
|
||
generateStyleClass(inputText, rw); | ||
|
@@ -234,7 +232,7 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce | |
if ((autocomplete != null) && (autocomplete.equals("off") || autocomplete.equals("false"))) { | ||
rw.writeAttribute("autocomplete", "off", null); | ||
} | ||
|
||
String v = getValue2Render(context, component); | ||
if (inputText instanceof InputSecret) { | ||
if (!((InputSecret) inputText).isRenderValue()) { | ||
|
@@ -260,25 +258,23 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce | |
numberOfDivs--; | ||
} | ||
|
||
// The following lines fix issue #1079 on basic tags (without typeahead). | ||
// They initialize tagsinput manually and empty duplicated 'name' attribute | ||
// on generated input (which holds the original HTML id). | ||
if (inputText.isTags() && (!inputText.isTypeahead())) { | ||
String id = fieldId; // input id | ||
id = id.replace(":", "\\\\:"); // escape the id for jQuery | ||
rw.startElement("script", null); | ||
String js = "$('#" + id + "').tagsinput();" + // | ||
"$('#" + id + "').attr('name','');"; | ||
String js = "$('#" + id + "').tagsinput();"; | ||
js += "$('#" + id + "').siblings('.bootstrap-tagsinput').addClass('form-control');"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with the update to 0.8.0 the bug with the 'name' was fixed, but there is a new bug fix a missing class |
||
rw.writeText(js, null); | ||
rw.endElement("script"); | ||
} | ||
|
||
Tooltip.activateTooltips(context, inputText); | ||
if (inputText.isTypeahead()) { | ||
String id = component.getClientId(); | ||
id = id.replace(":", "_"); // we need to escape the id for jQuery | ||
String componentClientId = component.getClientId(); | ||
// generateStyleClass() add the id as css class before | ||
String escapedClientId = componentClientId.replace(":", "_"); // we need to escape the id for jQuery | ||
rw.startElement("script", component); | ||
String typeaheadname = id + "_typeahead"; | ||
String typeaheadname = escapedClientId + "_typeahead"; | ||
if (inputText.isTags()) { | ||
String js = "var engine = new Bloodhound({" + // | ||
"name: '" + typeaheadname + "'," + // | ||
|
@@ -288,7 +284,8 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce | |
"}," + // | ||
"queryTokenizer: Bloodhound.tokenizers.whitespace" + // | ||
"});"; | ||
js += "$('." + id + "').tagsinput({" + // | ||
|
||
js += "$('." + escapedClientId + "').tagsinput({" + // | ||
"typeaheadjs: {" + // | ||
" name: 'animals'," + // | ||
" displayKey: 'val'," + // | ||
|
@@ -297,27 +294,19 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce | |
"}" + // | ||
"});";// | ||
|
||
// The following lines fix issue #1079 on tags with typeahead. | ||
// They empty duplicated 'name' attribute on generated input (which holds the original HTML id). | ||
String inputId = fieldId; // input id | ||
inputId = inputId.replace(":", "\\\\:"); // escape the id for jQuery | ||
js += "$('#" + inputId + "').attr('name','');"; | ||
js += "$('." + escapedClientId + "').siblings('.bootstrap-tagsinput').addClass('form-control');"; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with the update to 0.8.0 the bug with the 'name' was fixed, but there is a new bug fix a missing class |
||
rw.writeText(js, null); | ||
|
||
} else { | ||
|
||
String options = ""; | ||
options = addOption(options, "hint:" + inputText.isTypeaheadHint()); | ||
options = addOption(options, "highlight:" + inputText.isTypeaheadHighlight()); | ||
options = addOption(options, "minLength:" + inputText.getTypeaheadMinLength()); | ||
String options2 = ""; | ||
options2 = addOption(options2, "limit:" + inputText.getTypeaheadLimit()); | ||
options2 = addOption(options2, "name:'" + typeaheadname + "'"); | ||
options2 = addOption(options2, | ||
"source: BsF.substringMatcher(" + getTypeaheadValueArray(inputText) + ")"); | ||
|
||
rw.writeText("$('." + id + "').typeahead({" + options + "},{" + options2 + "});", null); | ||
options2 = addOption(options2, "source: BsF.substringMatcher(" + getTypeaheadValueArray(inputText) + ")"); | ||
rw.writeText("$('." + escapedClientId + "').typeahead({" + options + "},{" + options2 + "});", null); | ||
} | ||
rw.endElement("script"); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stephanrauh i have move the css from bootstrap-tagsinput.css to input-tags.css but i'm not sure if we need relative or absolute