modify filterCR to call user-specified callback on CR (e.g. for search toolbar)

This commit is contained in:
Andrew Dolgov 2006-10-01 07:33:32 +01:00
parent 5f0429a233
commit 6e6504bc02
4 changed files with 22 additions and 12 deletions

View File

@ -2511,7 +2511,7 @@
print "<table width='100%'><tr><td>Search:</td><td>"; print "<table width='100%'><tr><td>Search:</td><td>";
print "<input name=\"query\" class=\"iedit\" print "<input name=\"query\" class=\"iedit\"
onkeypress=\"return filterCR(event)\" onkeypress=\"return filterCR(event, search)\"
onkeyup=\"toggleSubmitNotEmpty(this, 'search_submit_btn')\" onkeyup=\"toggleSubmitNotEmpty(this, 'search_submit_btn')\"
value=\"\"> value=\"\">
</td></tr>"; </td></tr>";
@ -2647,7 +2647,7 @@
print "<table width='100%'>"; print "<table width='100%'>";
print "<tr><td>Match:</td> print "<tr><td>Match:</td>
<td><input onkeypress=\"return filterCR(event)\" <td><input onkeypress=\"return filterCR(event, qaddFilter)\"
onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\" onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
name=\"reg_exp\" class=\"iedit\">"; name=\"reg_exp\" class=\"iedit\">";
print "</td><td>"; print "</td><td>";

View File

@ -1189,10 +1189,12 @@ function infobox_submit_callback() {
if (xmlhttp.readyState == 4) { if (xmlhttp.readyState == 4) {
closeInfoBox(); closeInfoBox();
try {
// called from prefs, reload tab // called from prefs, reload tab
if (active_tab) { if (active_tab) {
selectTab(active_tab, false); selectTab(active_tab, false);
} }
} catch (e) { }
notify(xmlhttp.responseText); notify(xmlhttp.responseText);
@ -1266,7 +1268,7 @@ function qafAdd() {
return false; return false;
} }
function filterCR(e) function filterCR(e, f)
{ {
var key; var key;
@ -1275,11 +1277,17 @@ function filterCR(e)
else else
key = e.which; //firefox key = e.which; //firefox
if(key == 13) if (key == 13) {
if (typeof f != 'undefined') {
f();
return false; return false;
else } else {
return false;
}
} else {
return true; return true;
} }
}
function getMainContext() { function getMainContext() {
return this.window; return this.window;

View File

@ -569,3 +569,5 @@ function userSwitch() {
var user = chooser[chooser.selectedIndex].value; var user = chooser[chooser.selectedIndex].value;
window.location = "tt-rss.php?swu=" + user; window.location = "tt-rss.php?swu=" + user;
} }

View File

@ -154,7 +154,7 @@ window.onload = init;
<?php if (get_pref($link, 'ENABLE_SEARCH_TOOLBAR')) { ?> <?php if (get_pref($link, 'ENABLE_SEARCH_TOOLBAR')) { ?>
<input name="query" <input name="query"
onKeyPress="return filterCR(event)" onKeyPress="return filterCR(event, viewCurrentFeed)"
onblur="javascript:enableHotkeys();" onfocus="javascript:disableHotkeys();"> onblur="javascript:enableHotkeys();" onfocus="javascript:disableHotkeys();">
<input class="button" type="submit" <input class="button" type="submit"
onclick="return viewCurrentFeed(0)" value="Search"> onclick="return viewCurrentFeed(0)" value="Search">