diff -r 000000000000 -r 1450b09d0cfd ginebra/chrome/bedrockchrome/suggests.snippet/suggests.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ginebra/chrome/bedrockchrome/suggests.snippet/suggests.js Tue May 04 12:39:35 2010 +0300 @@ -0,0 +1,75 @@ +function Suggests() +{ + // attach internal funcs + this.write = writeSuggests; + + // do setup + this.write(); + + this.showSuggests = function() { + //window.chrome.alert("showSuggests"); + window.snippets.updateGeometry(); + window.snippets.SuggestsId.repaint(); + + window.snippets.SuggestsId.setPosition(5,68); + window.snippets.SuggestsId.show(); + window.snippets.SuggestsId.zValue = 10; + } + + this.hideSuggests = function() { + // window.snippets.ContextMenuBgId.hide(); + window.snippets.SuggestsId.hide(); + } + + this.setWidth = function(width) { + document.getElementById("SuggestsId").style.width = width; + //window.chrome.alert("set width:" + document.getElementById("SuggestsId").offsetWidth); + } + + this.setHeight = function(height) { + document.getElementById("SuggestsId").style.height = height; + //window.chrome.alert("set height:" + document.getElementById("SuggestsId").offsetHeight); + } + + this.removeAllItems = function() { + var parentList = document.getElementById("SuggestsUListId"); + while (parentList.childNodes[0]) { + parentList.removeChild(parentList.childNodes[0]); + } + this.setHeight(0); + } + + this.addItem = function(str) { + this.setHeight(document.getElementById("SuggestsId").offsetHeight + 26); // FIXME 26 is the row height + var parentList = document.getElementById("SuggestsUListId"); + var item = document.createElement("li"); + var searchTag = "S: "; + var historyTag = "H: "; + var bookmarkTag = "B: "; + item.innerHTML = searchTag + "" + str + ""; + item.onmousedown=function() { + document.getElementById("urlBox").value = str; + var searchStr = window.chrome.searchUrl(str); + window.snippets.SuggestsId.hide(); + window.pageController.currentLoad(searchStr); + } + item.onmouseover=function() { item.style.backgroundColor = 'Aquamarine';} + item.onmouseout=function() { item.style.backgroundColor = ''; } + parentList.appendChild(item); + } +} + +// "Private" methods +function writeSuggests() { + var html = + '
' + + '
' + + '
' + + '
    ' + + '
' + + '
' + + '
' + + '
'; + document.write(html); +} +