rem: } 
add: }  function enableFindButtons(aEnable) { var findNext = document.getElementById("find-next"); var findPrev = document.getElementById("find-previous"); var highlight = document.getElementById("highlight"); findNext.disabled = findPrev.disabled = highlight.disabled = !aEnable; }  function updateFoundLink(res) { var val = document.getElementById("find-field").value; if (res == Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND || !val) setFoundLink(null); else setFoundLink(getBrowser().fastFind.foundLink); }  function find(val) { if (!val) val = document.getElementById("find-field").value;  enableFindButtons(val);  var highlightBtn = document.getElementById("highlight"); if (highlightBtn.checked) setHighlightTimeout();  changeSelectionColor(true);  var fastFind = getBrowser().fastFind; var res = fastFind.find(val, gFindMode == FIND_LINKS); updateFoundLink(res); updateStatus(res, true);  if (gFindMode != FIND_NORMAL) setFindCloseTimeout(); }  function flashFindBar() { var findToolbar = document.getElementById("FindToolbar"); if (gFlashFindBarCount-- == 0) { clearInterval(gFlashFindBarTimeout); findToolbar.removeAttribute("flash"); gFlashFindBarCount = 6; return; }  findToolbar.setAttribute("flash", (gFlashFindBarCount % 2 == 0) ? "false" : "true"); }  function onFindCmd() { setFindMode(FIND_NORMAL); openFindBar(); if (gFlashFindBar) { gFlashFindBarTimeout = setInterval(flashFindBar, 500); var prefService = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefBranch);  prefService.setIntPref("accessibility.typeaheadfind.flashBar", --gFlashFindBar); } selectFindBar(); focusFindBar(); }  function onFindAgainCmd() { var findString = getBrowser().findString; if (!findString) { onFindCmd(); return; }  var res = findNext(); if (res == Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND) { if (openFindBar()) { focusFindBar(); selectFindBar(); if (gFindMode != FIND_NORMAL) setFindCloseTimeout();  updateStatus(res, true); } } }  function onFindPreviousCmd() { var findString = getBrowser().findString; if (!findString) { onFindCmd(); return; }  var res = findPrevious(); if (res == Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND) { if (openFindBar()) { focusFindBar(); selectFindBar(); if (gFindMode != FIND_NORMAL) setFindCloseTimeout();  updateStatus(res, false); } } }  function setHighlightTimeout() { if (gHighlightTimeout) clearTimeout(gHighlightTimeout); gHighlightTimeout = setTimeout(function() { toggleHighlight(false); toggleHighlight(true); }, 500); }  function isFindBarVisible() { var findBar = document.getElementById("FindToolbar"); return !findBar.hidden; }  function findNext() { changeSelectionColor(true);  var fastFind = getBrowser().fastFind; var res = fastFind.findNext(); updateFoundLink(res); updateStatus(res, true);  if (gFindMode != FIND_NORMAL && isFindBarVisible()) setFindCloseTimeout();  return res; }  function findPrevious() { changeSelectionColor(true);  var fastFind = getBrowser().fastFind; var res = fastFind.findPrevious(); updateFoundLink(res); updateStatus(res, false);  if (gFindMode != FIND_NORMAL && isFindBarVisible()) setFindCloseTimeout();  return res; }  function updateStatus(res, findNext) { var findBar = document.getElementById("FindToolbar"); var field = document.getElementById("find-field"); var statusIcon = document.getElementById("find-status-icon"); var statusText = document.getElementById("find-status"); switch(res) { case Components.interfaces.nsITypeAheadFind.FIND_WRAPPED: statusIcon.setAttribute("status", "wrapped"); statusText.value = findNext ? gWrappedToTopStr : gWrappedToBottomStr; break; case Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND: statusIcon.setAttribute("status", "notfound"); statusText.value = gNotFoundStr; field.setAttribute("status", "notfound"); break; case Components.interfaces.nsITypeAheadFind.FIND_FOUND: default: statusIcon.removeAttribute("status"); statusText.value = ""; field.removeAttribute("status"); break; } }  function setFindCloseTimeout() { if (gQuickFindTimeout) clearTimeout(gQuickFindTimeout);   if (gIsIMEComposing) { gQuickFindTimeout = null; return; }  gQuickFindTimeout = setTimeout(function() { if (gFindMode != FIND_NORMAL) closeFindBar(); }, gQuickFindTimeoutLength); }  function onFindBarCompositionStart(evt) { gIsIMEComposing = true;  if (gQuickFindTimeout) { clearTimeout(gQuickFindTimeout); gQuickFindTimeout = null; } }  function onFindBarCompositionEnd(evt) { gIsIMEComposing = false; if (gFindMode != FIND_NORMAL && isFindBarVisible()) setFindCloseTimeout(); }  function setFindMode(mode) { if (mode == gFindMode) return;  gFindMode = mode; } 
context: function onFindBarKeyPress(evt){  if (evt.keyCode == KeyEvent.DOM_VK_RETURN) {    if (gFindMode == FIND_NORMAL) {      var findString = document.getElementById("find-field");      if (!findString.value)        return;      if (evt.ctrlKey) {        document.getElementById("highlight").click();        return;      }      if (evt.shiftKey)        findPrevious();      else        findNext();    }    else {      if (gFoundLink) {        var tmpLink = gFoundLink;        if (finishFAYT(evt))          fireKeypressEvent(tmpLink, evt);      }    }  }  else if (evt.keyCode == KeyEvent.DOM_VK_TAB) {    var shouldHandle = !evt.altKey && !evt.ctrlKey && !evt.metaKey;    if (shouldHandle && gFindMode != FIND_NORMAL &&        gFoundLink && finishFAYT(evt)) {      if (evt.shiftKey)        document.commandDispatcher.rewindFocus();      else        document.commandDispatcher.advanceFocus();    }  }  else if (evt.keyCode == KeyEvent.DOM_VK_ESCAPE) {    closeFindBar();    evt.preventDefault();  }   else if (evt.keyCode == KeyEvent.DOM_VK_PAGE_UP) {    window.top._content.scrollByPages(-1);    evt.preventDefault();  }  else if (evt.keyCode == KeyEvent.DOM_VK_PAGE_DOWN) {    window.top._content.scrollByPages(1);    evt.preventDefault();  }  else if (evt.keyCode == KeyEvent.DOM_VK_UP) {    window.top._content.scrollByLines(-1);    evt.preventDefault();  }  else if (evt.keyCode == KeyEvent.DOM_VK_DOWN) {    window.top._content.scrollByLines(1);    evt.preventDefault();  }} 
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9421/4894bd2a1fd9c57370329309e9fec94111a67db5/findBar.js/clean/toolkit/components/typeaheadfind/content/findBar.js