Merge 1375 from rel-1.1-maint branch; autocomplete help text
This commit is contained in:
parent
e48d80d008
commit
b01dbf2d54
1 changed files with 36 additions and 2 deletions
|
@ -58,6 +58,7 @@ var customForm = {
|
||||||
|
|
||||||
this.or = $('span.or');
|
this.or = $('span.or');
|
||||||
this.cancel = this.form.find('.cancel');
|
this.cancel = this.form.find('.cancel');
|
||||||
|
this.acHelpTextClass = 'acSelectorWithHelpText';
|
||||||
},
|
},
|
||||||
|
|
||||||
// Set up the form on page load
|
// Set up the form on page load
|
||||||
|
@ -131,6 +132,9 @@ var customForm = {
|
||||||
this.setButtonText('new');
|
this.setButtonText('new');
|
||||||
this.setLabels();
|
this.setLabels();
|
||||||
|
|
||||||
|
// Set the initial autocomplete help text in the acSelector field.
|
||||||
|
this.addAcHelpText();
|
||||||
|
|
||||||
this.cancel.unbind('click');
|
this.cancel.unbind('click');
|
||||||
if (this.formSteps > 1) {
|
if (this.formSteps > 1) {
|
||||||
this.cancel.click(function() {
|
this.cancel.click(function() {
|
||||||
|
@ -188,6 +192,18 @@ var customForm = {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.acSelector.focus(function() {
|
||||||
|
customForm.deleteAcHelpText();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.acSelector.blur(function() {
|
||||||
|
customForm.addAcHelpText();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.form.submit(function() {
|
||||||
|
customForm.deleteAcHelpText();
|
||||||
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
initAutocomplete: function() {
|
initAutocomplete: function() {
|
||||||
|
@ -442,8 +458,26 @@ var customForm = {
|
||||||
// or in repair mode in a two-step form with no type selected. Use the default type
|
// or in repair mode in a two-step form with no type selected. Use the default type
|
||||||
// name specified in the form data (this.typeName is 'Select one').
|
// name specified in the form data (this.typeName is 'Select one').
|
||||||
return this.acType ? this.typeName : this.capitalize(this.defaultTypeName);
|
return this.acType ? this.typeName : this.capitalize(this.defaultTypeName);
|
||||||
}
|
},
|
||||||
|
|
||||||
|
// Set the intial help text that appears in the autocomplete field and change the class name
|
||||||
|
addAcHelpText: function() {
|
||||||
|
var typeText;
|
||||||
|
|
||||||
|
if (!this.acSelector.val()) {
|
||||||
|
typeText = getTypeNameForLabels();
|
||||||
|
this.acSelector.val("Select an existing " + typeText + " or create a new one.")
|
||||||
|
.addClass(this.acHelpTextClass);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
deleteAcHelpText: function() {
|
||||||
|
if (this.acSelector.hasClass(this.acHelpTextClass)) {
|
||||||
|
this.acSelector.val('')
|
||||||
|
.removeClass(this.acHelpTextClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue