Bug 504552 default tab show only a message and no other panes - provide some error handling for when the quick search menu gets confused. r=asuth

This commit is contained in:
Mark Banner 2009-08-27 09:32:01 +01:00
Родитель 105dfb0172
Коммит 923ae85988
1 изменённых файлов: 37 добавлений и 9 удалений

Просмотреть файл

@ -235,19 +235,28 @@
<implementation>
<constructor>
<![CDATA[
if (!document.getElementById("quick-search-menupopup"))
let qsmenu = document.getElementById("quick-search-menupopup");
if (!qsmenu)
return; // no quick search item in scope
// Initialize the quick search mode based on the checked menu item.
// (getAttribute returns a string so "0" is still true...)
this.mQuickSearchMode =
document.getElementById('quick-search-menupopup')
.getAttribute('value') ||
this.mQuickSearchMode =
qsmenu.getAttribute('value') ||
QuickSearchConstants.kQuickSearchFromOrSubject.toString();
var selectedMenuItem =
document.getElementById('quick-search-menupopup')
.getElementsByAttribute('value', this.mQuickSearchMode)[0];
qsmenu.getElementsByAttribute('value', this.mQuickSearchMode)[0];
if (!selectedMenuItem) {
// We didn't expect this, try and fix it.
// Error condition, something went wrong - try and recover from it.
this.mQuickSearchMode =
QuickSearchConstants.kQuickSearchFromOrSubject.toString();
selectedMenuItem =
qsmenu.getElementsByAttribute('value', this.searchMode)[0];
}
selectedMenuItem.setAttribute('checked', 'true');
this.setSearchCriteriaText();
@ -292,9 +301,28 @@
<method name="setSearchCriteriaText">
<body><![CDATA[
this.showingSearchCriteria = true;
// extract the label value from the menu item
var menuItems = document.getElementById('quick-search-menupopup').getElementsByAttribute('value', this.searchMode);
this.inputField.value = menuItems[0].getAttribute('label');
let qsmenu = document.getElementById('quick-search-menupopup');
// extract the label value from the menu item
let menuItem = qsmenu.getElementsByAttribute('value',
this.searchMode)[0];
if (typeof menuItem == "undefined") {
// Error condition, something went wrong - try and recover from it.
this.mQuickSearchMode =
QuickSearchConstants.kQuickSearchFromOrSubject.toString();
let selectedMenuItem =
qsmenu.getElementsByAttribute('value', this.searchMode)[0];
selectedMenuItem.setAttribute('checked', 'true');
this.inputField.value = selectedMenuItem.getAttribute('label');
}
else
this.inputField.value = menuItem.getAttribute('label');
this.clearButtonHidden = true;
]]></body>
</method>