30 //! If not all suggest items can fit in list, only half an item should be |
30 //! If not all suggest items can fit in list, only half an item should be |
31 //! visible the end when scrolled to the top. This is to indicate more items. |
31 //! visible the end when scrolled to the top. This is to indicate more items. |
32 function _setMaxHeight() |
32 function _setMaxHeight() |
33 { |
33 { |
34 // Calculate height of available space for suggest list. |
34 // Calculate height of available space for suggest list. |
35 var statusbarSz = snippets.StatusBarChromeId.getGeometry(); |
35 var statusbarHeight = (snippets.StatusBarChromeId != undefined && snippets.StatusBarChromeId.visible) ? snippets.StatusBarChromeId.getGeometry().height : 0; |
36 // The Orbit UI doesn't have a status bar. |
36 // The Orbit UI doesn't have a status bar. |
37 var statusbarHeight = (app.ui() == "orbit_ui") ? 0 : statusbarSz.height; |
37 var statusbarHeight = ((app.ui() == "orbit_ui") || (app.ui() == "maemo5_ui")) ? 0 : statusbarSz.height; |
38 var urlSearchSz = snippets[urlSnippetId].getGeometry(); |
38 var urlSearchSz = snippets[urlSnippetId].getGeometry(); |
39 var toolbarSz = snippets.WebViewToolbarId.getGeometry(); |
39 var toolbarSz = snippets.WebViewToolbarId.getGeometry(); |
40 // leave some space between suggest and toolbar (~10% of display height) |
40 // leave some space between suggest and toolbar (~10% of display height) |
41 var bufferHeight = Math.ceil(chrome.displaySize.height / 10); |
41 var bufferHeight = Math.ceil(chrome.displaySize.height / 10); |
42 var availableHeight = chrome.displaySize.height - |
42 var availableHeight = chrome.displaySize.height - |
92 \param input the current URL box text |
92 \param input the current URL box text |
93 */ |
93 */ |
94 function _updateSuggestList(input) |
94 function _updateSuggestList(input) |
95 { |
95 { |
96 var recenturl; |
96 var recenturl; |
97 var recenttitle = window.localeDelegate.translateText( |
97 var recenttitle = window.localeDelegate.translateText("txt_browser_chrome_suggests_search_for"); |
98 "txt_browser_chrome_suggests_search_for"); |
|
99 var snippetId = document.getElementById('SuggestsId'); |
98 var snippetId = document.getElementById('SuggestsId'); |
100 var suggests = window.bookmarksController.suggestSimilar(input); |
99 var suggests = window.bookmarksController.suggestSimilar(input); |
101 var suggestUL = document.createElement('ul'); |
100 var suggestUL = document.createElement('ul'); |
102 var suggestLI = document.createElement('li'); |
101 var suggestLI = document.createElement('li'); |
103 var pattern = new RegExp(input, "ig"); |
102 var pattern = new RegExp(input, "ig"); |
114 '<div class="SuggestElement">'+'<span class="aTitle">'+recenttitle+'</span>'+'</div></a>'; |
113 '<div class="SuggestElement">'+'<span class="aTitle">'+recenttitle+'</span>'+'</div></a>'; |
115 suggestUL.appendChild(suggestLI); |
114 suggestUL.appendChild(suggestLI); |
116 |
115 |
117 // add each search suggestion to unordered list |
116 // add each search suggestion to unordered list |
118 for (i=0; i < suggests.length; i++) { |
117 for (i=0; i < suggests.length; i++) { |
119 recenturl = suggests[i].url1; |
118 recenturl = suggests[i].url1; |
120 recenttitle = suggests[i].title1; |
119 recenttitle = suggests[i].title1; |
121 suggestLI = document.createElement('li'); |
120 suggestLI = document.createElement('li'); |
122 suggestLI.id = "suggestsLiId"; |
121 suggestLI.id = "suggestsLiId"; |
123 |
122 |
124 // bold search text |
123 // bold search text |