Add entry_with_tagname_replacements for use on tagname inputs.
Unfortunately, when adjusting the box's value, it causes the datalist to disappear, and it only comes back after you press another key. I can't figure out how to make the datalist reappear automatically with js.
This commit is contained in:
parent
53888a1787
commit
10b674e8d8
4 changed files with 22 additions and 0 deletions
|
@ -125,6 +125,15 @@ function entry_with_history_hook(event)
|
|||
}
|
||||
}
|
||||
|
||||
common.entry_with_tagname_replacements =
|
||||
function entry_with_tagname_replacements(event)
|
||||
{
|
||||
var cursor_position = event.target.selectionStart;
|
||||
event.target.value = common.tagname_replacements(event.target.value);
|
||||
event.target.selectionStart = cursor_position;
|
||||
event.target.selectionEnd = cursor_position;
|
||||
}
|
||||
|
||||
common.html_to_element =
|
||||
function html_to_element(html)
|
||||
{
|
||||
|
@ -323,6 +332,13 @@ function normalize_tagname(tagname)
|
|||
tagname = tagname.split(".");
|
||||
tagname = tagname[tagname.length-1];
|
||||
tagname = tagname.split("+")[0];
|
||||
tagname = common.tagname_replacements(tagname);
|
||||
return tagname;
|
||||
}
|
||||
|
||||
common.tagname_replacements =
|
||||
function tagname_replacements(tagname)
|
||||
{
|
||||
tagname = tagname.replace(new RegExp(" ", 'g'), "_");
|
||||
tagname = tagname.replace(new RegExp("-", 'g'), "_");
|
||||
return tagname;
|
||||
|
|
|
@ -256,6 +256,7 @@ var PHOTO_ID = "{{photo.id}}";
|
|||
var add_tag_box = document.getElementById('add_tag_textbox');
|
||||
var add_tag_button = document.getElementById('add_tag_button');
|
||||
add_tag_box.addEventListener("keyup", common.entry_with_history_hook);
|
||||
add_tag_box.addEventListener("keyup", common.entry_with_tagname_replacements);
|
||||
common.bind_box_to_button(add_tag_box, add_tag_button, false);
|
||||
|
||||
var message_area = document.getElementById('message_area');
|
||||
|
|
|
@ -659,8 +659,12 @@ var inputted_forbids = [];
|
|||
{% endfor %}
|
||||
|
||||
input_musts.addEventListener("keyup", function(){tag_input_hook(this, inputted_musts, "search_builder_musts_inputted")});
|
||||
input_musts.addEventListener("keyup", common.entry_with_tagname_replacements);
|
||||
input_mays.addEventListener("keyup", function(){tag_input_hook(this, inputted_mays, "search_builder_mays_inputted")});
|
||||
input_mays.addEventListener("keyup", common.entry_with_tagname_replacements);
|
||||
input_forbids.addEventListener("keyup", function(){tag_input_hook(this, inputted_forbids, "search_builder_forbids_inputted")});
|
||||
input_forbids.addEventListener("keyup", common.entry_with_tagname_replacements);
|
||||
|
||||
common.bind_box_to_button(input_expression, document.getElementById("search_go_button"));
|
||||
</script>
|
||||
</html>
|
||||
|
|
|
@ -216,6 +216,7 @@ var add_tag_textbox = document.getElementById('add_tag_textbox');
|
|||
var add_tag_button = document.getElementById('add_tag_button');
|
||||
var message_area = document.getElementById('message_area');
|
||||
add_tag_textbox.addEventListener("keyup", common.entry_with_history_hook);
|
||||
add_tag_textbox.addEventListener("keyup", common.entry_with_tagname_replacements);
|
||||
common.bind_box_to_button(add_tag_textbox, add_tag_button, false);
|
||||
|
||||
function easybake_form()
|
||||
|
|
Loading…
Reference in a new issue