Bug 439320 Use timed textbox in mailnews and addressbook (port bug 179050 to Thunderbird). r=philor
git-svn-id: svn://10.0.0.236/trunk@252496 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
e1a7723847
commit
7fc8a61b5d
@ -1634,14 +1634,13 @@
|
||||
title="&searchItem.title;"
|
||||
align="center"
|
||||
class="chromeclass-toolbar-additional">
|
||||
<textbox id="searchInput"
|
||||
flex="1"
|
||||
<textbox id="searchInput" timeout="800" flex="1"
|
||||
onfocus="onSearchInputFocus(event);"
|
||||
onclick="onSearchInputClick(event);"
|
||||
onmousedown="onSearchInputMousedown(event);"
|
||||
onblur="onSearchInputBlur(event);"
|
||||
oninput="onSearchInput(false);"
|
||||
onkeypress="onSearchKeyPress(event);"
|
||||
oncommand="onEnterInSearchBar();"
|
||||
onkeypress="onSearchKeyPress();"
|
||||
chromedir="&locale.dir;">
|
||||
<button id="quick-search-button" type="menu" chromedir="&locale.dir;">
|
||||
<menupopup id="quick-search-menupopup"
|
||||
|
||||
@ -49,7 +49,7 @@
|
||||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:xbl="http://www.mozilla.org/xbl">
|
||||
|
||||
<binding id="searchbar" extends="chrome://global/content/bindings/textbox.xml#textbox">
|
||||
<binding id="searchbar" extends="chrome://global/content/bindings/textbox.xml#timed-textbox">
|
||||
<resources>
|
||||
<stylesheet src="chrome://messenger/skin/searchBox.css"/>
|
||||
</resources>
|
||||
|
||||
@ -46,7 +46,6 @@ var gViewSearchListener;
|
||||
var gSearchBundle;
|
||||
var gStatusBar = null;
|
||||
var gSearchInProgress = false;
|
||||
var gSearchInput = null;
|
||||
var gDefaultSearchViewTerms = null;
|
||||
var gQSViewIsDirty = false;
|
||||
var gIgnoreFocus = false;
|
||||
@ -515,14 +514,10 @@ function onSearchStop()
|
||||
gSearchSession.interruptSearch();
|
||||
}
|
||||
|
||||
function onSearchKeyPress(event)
|
||||
function onSearchKeyPress()
|
||||
{
|
||||
if (gSearchInput.showingSearchCriteria)
|
||||
gSearchInput.showingSearchCriteria = false;
|
||||
|
||||
// 13 == return
|
||||
if (event && event.keyCode == 13)
|
||||
onSearchInput(true);
|
||||
}
|
||||
|
||||
function onSearchInputFocus(event)
|
||||
@ -538,54 +533,36 @@ function onSearchInputFocus(event)
|
||||
if (gIgnoreFocus) // got focus via mouse click, don't need to anything else
|
||||
gIgnoreFocus = false;
|
||||
else
|
||||
{
|
||||
gSearchInput.select();
|
||||
gQuickSearchFocusEl = gSearchInput; // only important that this be non-null
|
||||
}
|
||||
}
|
||||
|
||||
function onSearchInputMousedown(event)
|
||||
{
|
||||
GetSearchInput();
|
||||
if (gSearchInput.hasAttribute("focused"))
|
||||
{
|
||||
// If the search input is focused already, ignore the click so that
|
||||
// onSearchInputBlur does nothing.
|
||||
gIgnoreClick = true;
|
||||
|
||||
// already focused, don't need to restore focus elsewhere (if the Clear button was clicked)
|
||||
// ##HACK## Need to check 'clearButtonHidden' because the field is blurred when it has
|
||||
// focus and the hidden button is clicked, in which case we want to perform the normal
|
||||
// onBlur function.
|
||||
gQuickSearchFocusEl = gSearchInput.clearButtonHidden ? gSearchInput : null;
|
||||
}
|
||||
else
|
||||
{
|
||||
gIgnoreFocus = true;
|
||||
gIgnoreClick = false;
|
||||
|
||||
// save the last focused element so that focus can be restored (if the Clear button was clicked)
|
||||
gQuickSearchFocusEl = gLastFocusedElement;
|
||||
}
|
||||
// (if Clear button was clicked, onClearSearch() is called before onSearchInputClick())
|
||||
}
|
||||
|
||||
|
||||
function onSearchInputClick(event)
|
||||
{
|
||||
if (!gIgnoreClick)
|
||||
{
|
||||
gQuickSearchFocusEl = null; // ##HACK## avoid onSearchInputBlur() side effects
|
||||
gSearchInput.select(); // ## triggers onSearchInputBlur(), but focus returns to field
|
||||
}
|
||||
if (!gQuickSearchFocusEl)
|
||||
gQuickSearchFocusEl = gSearchInput; // mousedown wasn't on Clear button
|
||||
// Triggers onSearchInputBlur(), but focus returns to field.
|
||||
gSearchInput.select();
|
||||
}
|
||||
|
||||
function onSearchInputBlur(event)
|
||||
{
|
||||
if (!gQuickSearchFocusEl) // ignore the blur if we are in the middle of processing the clear button
|
||||
{
|
||||
// If we're doing something else, don't process the blur.
|
||||
if (gIgnoreClick)
|
||||
return;
|
||||
|
||||
gQuickSearchFocusEl = null;
|
||||
if (!gSearchInput.value)
|
||||
gSearchInput.showingSearchCriteria = true;
|
||||
|
||||
@ -593,48 +570,20 @@ function onSearchInputBlur(event)
|
||||
gSearchInput.setSearchCriteriaText();
|
||||
}
|
||||
|
||||
function onSearchInput(returnKeyHit)
|
||||
{
|
||||
if (gSearchInput.showingSearchCriteria && !(returnKeyHit && gSearchInput.value == ""))
|
||||
return;
|
||||
|
||||
if (gSearchTimer) {
|
||||
clearTimeout(gSearchTimer);
|
||||
gSearchTimer = null;
|
||||
}
|
||||
|
||||
// only select the text when the return key was hit
|
||||
if (returnKeyHit) {
|
||||
gSearchInput.select();
|
||||
onEnterInSearchBar();
|
||||
}
|
||||
else {
|
||||
gSearchTimer = setTimeout(onEnterInSearchBar, 800);
|
||||
}
|
||||
}
|
||||
|
||||
// temporary global used to make sure we restore focus to the correct element after clearing the quick search box
|
||||
// because clearing quick search means stealing focus.
|
||||
var gQuickSearchFocusEl = null;
|
||||
|
||||
function onClearSearch()
|
||||
{
|
||||
if (!gSearchInput.showingSearchCriteria) // ignore the text box value if it's just showing the search criteria string
|
||||
// If we're not showing search criteria, then we need to clear up.
|
||||
if (!gSearchInput.showingSearchCriteria)
|
||||
{
|
||||
Search("");
|
||||
// Hide the clear button
|
||||
gSearchInput.clearButtonHidden = true;
|
||||
gIgnoreClick = true;
|
||||
// this needs to be on a timer otherwise we end up messing up the focus while the Search("") is still happening
|
||||
if (gQuickSearchFocusEl) // set in onSearchInputMouseDown
|
||||
setTimeout(restoreSearchFocusAfterClear, 0);
|
||||
gSearchInput.select();
|
||||
gIgnoreClick = false;
|
||||
}
|
||||
}
|
||||
|
||||
function restoreSearchFocusAfterClear()
|
||||
{
|
||||
if (gQuickSearchFocusEl)
|
||||
gQuickSearchFocusEl.focus();
|
||||
}
|
||||
|
||||
// called from commandglue.js in cases where the view is being changed and QS
|
||||
// needs to be cleared.
|
||||
function ClearQSIfNecessary()
|
||||
@ -657,7 +606,7 @@ function Search(str)
|
||||
}
|
||||
|
||||
gSearchInput.value = str; //on input does not get fired for some reason
|
||||
onSearchInput(true);
|
||||
onEnterInSearchBar();
|
||||
}
|
||||
|
||||
// helper methods for the quick search drop down menu
|
||||
|
||||
@ -1019,50 +1019,10 @@ function GetSelectedDirectory()
|
||||
}
|
||||
}
|
||||
|
||||
function onAbSearchKeyPress(event)
|
||||
{
|
||||
// 13 == return
|
||||
if (event && event.keyCode == 13)
|
||||
onAbSearchInput(true);
|
||||
}
|
||||
|
||||
function onAbSearchInput(returnKeyHit)
|
||||
{
|
||||
if (gSearchInput.showingSearchCriteria && !(returnKeyHit && gSearchInput.value == ""))
|
||||
return;
|
||||
|
||||
SearchInputChanged();
|
||||
|
||||
if (gSearchTimer) {
|
||||
clearTimeout(gSearchTimer);
|
||||
gSearchTimer = null;
|
||||
}
|
||||
|
||||
if (returnKeyHit) {
|
||||
gSearchInput.select();
|
||||
onEnterInSearchBar();
|
||||
}
|
||||
else {
|
||||
gSearchTimer = setTimeout(onEnterInSearchBar, 800);
|
||||
}
|
||||
}
|
||||
|
||||
function SearchInputChanged()
|
||||
{
|
||||
var clearButton = document.getElementById("clear");
|
||||
if (clearButton) {
|
||||
if (gSearchInput.value && (gSearchInput.value != ""))
|
||||
clearButton.removeAttribute("disabled");
|
||||
else
|
||||
clearButton.setAttribute("disabled", "true");
|
||||
}
|
||||
}
|
||||
|
||||
function onAbClearSearch()
|
||||
{
|
||||
if (gSearchInput)
|
||||
gSearchInput.value =""; //on input does not get fired for some reason
|
||||
onAbSearchInput(true);
|
||||
gSearchInput.value = "";
|
||||
onEnterInSearchBar(true);
|
||||
}
|
||||
|
||||
function AbSwapFirstNameLastName()
|
||||
|
||||
@ -109,9 +109,10 @@
|
||||
|
||||
<vbox>
|
||||
<label value="&searchInput.label;" accesskey="&searchInput.accesskey;" control="searchInput"/>
|
||||
<textbox id="searchInput" flex="1" onfocus="onSearchInputFocus(event);" onblur="onSearchInputBlur(event);"
|
||||
onclick="this.select();" oninput="onAbSearchInput(false);"
|
||||
onkeypress="onAbSearchKeyPress(event);" chromedir="&locale.dir;">
|
||||
<textbox id="searchInput" flex="1" type="timed" timeout="800"
|
||||
onfocus="onSearchInputFocus(event);"
|
||||
onblur="onSearchInputBlur(event);" onclick="this.select();"
|
||||
oncommand="onEnterInSearchBar();" chromedir="&locale.dir;">
|
||||
<button id="quick-search-button" type="menu" chromedir="&locale.dir;">
|
||||
<menupopup id="quick-search-menupopup" value="0" persist="value" popupalign="topleft" popupanchor="bottomleft">
|
||||
<menuitem value="0" label="&SearchNameOrEmail.label;" type="radio"/>
|
||||
|
||||
@ -527,9 +527,10 @@
|
||||
</toolbaritem>
|
||||
|
||||
<toolbaritem id="search-container" title="&searchItem.title;" align="center" class="chromeclass-toolbar-additional">
|
||||
<textbox id="searchInput" flex="1" onfocus="onSearchInputFocus(event);" onblur="onSearchInputBlur(event);"
|
||||
onclick="this.select();" oninput="onAbSearchInput(false);"
|
||||
onkeypress="onAbSearchKeyPress(event);"
|
||||
<textbox id="searchInput" flex="1" timeout="800"
|
||||
onfocus="onSearchInputFocus(event);"
|
||||
onblur="onSearchInputBlur(event);"
|
||||
onclick="this.select();" oncommand="onEnterInSearchBar();"
|
||||
chromedir="&locale.dir;">
|
||||
<button id="quick-search-button" type="menu" chromedir="&locale.dir;">
|
||||
<menupopup id="quick-search-menupopup" value="0" persist="value" popupalign="topleft" popupanchor="bottomleft">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user