mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 15:22:26 +01:00
Turn favicons back on. Don't let the completion list jump. Move some stuff to vimperator.css.
This commit is contained in:
@@ -59,13 +59,7 @@ liberator.Completion = function () //{{{
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
function getIcon(uri)
|
||||
{
|
||||
return;
|
||||
try
|
||||
{
|
||||
let img = faviconService.getFaviconImageForPage(ioService.newURI(uri, null, null));
|
||||
return img.spec;
|
||||
}
|
||||
catch (e) {}
|
||||
return function () faviconService.getFaviconImageForPage(ioService.newURI(uri, null, null)).spec;
|
||||
}
|
||||
function addIcon(elem)
|
||||
{
|
||||
@@ -89,7 +83,7 @@ liberator.Completion = function () //{{{
|
||||
|
||||
// function uses smartcase
|
||||
// list = [ [['com1', 'com2'], 'text'], [['com3', 'com4'], 'text'] ]
|
||||
function buildLongestCommonSubstring(list, filter)
|
||||
function buildLongestCommonSubstring(list, filter, favicon)
|
||||
{
|
||||
var filtered = [];
|
||||
|
||||
@@ -113,7 +107,7 @@ liberator.Completion = function () //{{{
|
||||
if (compitem.indexOf(filter) == -1)
|
||||
continue;
|
||||
|
||||
filtered.push([compitem, item[1], item[2]]);
|
||||
filtered.push([compitem, item[1], favicon ? item[2] : null]);
|
||||
|
||||
if (longest)
|
||||
{
|
||||
@@ -129,7 +123,7 @@ liberator.Completion = function () //{{{
|
||||
}
|
||||
|
||||
// this function is case sensitive
|
||||
function buildLongestStartingSubstring(list, filter)
|
||||
function buildLongestStartingSubstring(list, filter, favicon)
|
||||
{
|
||||
var filtered = [];
|
||||
|
||||
@@ -146,7 +140,7 @@ liberator.Completion = function () //{{{
|
||||
if (compitem.indexOf(filter) != 0)
|
||||
continue;
|
||||
|
||||
filtered.push([compitem, item[1], item[2]]);
|
||||
filtered.push([compitem, item[1], favicon ? item[2] : null]);
|
||||
|
||||
if (longest)
|
||||
{
|
||||
@@ -191,15 +185,15 @@ liberator.Completion = function () //{{{
|
||||
|
||||
// generic filter function, also builds substrings needed
|
||||
// for :set wildmode=list:longest, if necessary
|
||||
filter: function (array, filter, matchFromBeginning)
|
||||
filter: function (array, filter, matchFromBeginning, favicon)
|
||||
{
|
||||
if (!filter)
|
||||
return array;
|
||||
return [[a[0], a[1], favicon ? a[2] : null] for each (a in array)];
|
||||
|
||||
if (matchFromBeginning)
|
||||
return buildLongestStartingSubstring(array, filter);
|
||||
return buildLongestStartingSubstring(array, filter, favicon);
|
||||
else
|
||||
return buildLongestCommonSubstring(array, filter);
|
||||
return buildLongestCommonSubstring(array, filter, favicon);
|
||||
},
|
||||
|
||||
autocommand: function (filter)
|
||||
@@ -300,9 +294,9 @@ liberator.Completion = function () //{{{
|
||||
}
|
||||
|
||||
if (tail)
|
||||
return [dir.length, buildLongestStartingSubstring(mapped, compl)];
|
||||
return [dir.length, buildLongestStartingSubstring(mapped, compl, true)];
|
||||
else
|
||||
return [0, buildLongestStartingSubstring(mapped, filter)];
|
||||
return [0, buildLongestStartingSubstring(mapped, filter, true)];
|
||||
},
|
||||
|
||||
javascript: function (str)
|
||||
@@ -394,7 +388,7 @@ liberator.Completion = function () //{{{
|
||||
{
|
||||
var keywords = [[k[0], k[1], getIcon(k[2])] for each (k in liberator.bookmarks.getKeywords())];
|
||||
var engines = liberator.bookmarks.getSearchEngines();
|
||||
return [0, this.filter(engines.concat(keywords), filter)];
|
||||
return [0, this.filter(engines.concat(keywords), filter, false, true)];
|
||||
},
|
||||
|
||||
// XXX: Move to bookmarks.js?
|
||||
|
||||
@@ -1127,8 +1127,10 @@ liberator.CommandLine = function () //{{{
|
||||
if (liberator.mode != liberator.modes.COMMAND_LINE)
|
||||
return;
|
||||
|
||||
/* Only hide if not pending.
|
||||
if (compl.length == 0)
|
||||
return completionList.hide();
|
||||
*/
|
||||
|
||||
completionList.setItems(compl);
|
||||
|
||||
@@ -1198,19 +1200,22 @@ liberator.ItemList = function (id) //{{{
|
||||
var listOffset = -1; // how many items is the displayed list shifted from the internal tab index
|
||||
var listIndex = -1; // listOffset + listIndex = completions[item]
|
||||
var selectedElement = null;
|
||||
var minHeight = 0;
|
||||
|
||||
// TODO: temporary, to be changed/removed
|
||||
function createRow(b, c, a, dom)
|
||||
{
|
||||
let row =
|
||||
<tr class="liberator-compitem">
|
||||
<td style="width: 16px"/>
|
||||
<td style="width: 45%; overflow: hidden">{b}</td>
|
||||
<td style="color: gray">{c}</td>
|
||||
<tr class="compitem">
|
||||
<td class="favicon"/>
|
||||
<td class="completion">{b}</td>
|
||||
<td class="description">{c}</td>
|
||||
</tr>
|
||||
|
||||
if (typeof a == "function")
|
||||
a = a();
|
||||
if (a)
|
||||
row.td[0].* = <img width="16px" height="16px" src={a}/>;
|
||||
row.td[0].* = <img src={a}/>;
|
||||
|
||||
if (dom)
|
||||
return liberator.util.xmlToDom(row, doc);
|
||||
@@ -1222,11 +1227,12 @@ liberator.ItemList = function (id) //{{{
|
||||
function getHeight()
|
||||
{
|
||||
if (completionElements.length == 0)
|
||||
return doc.height;
|
||||
return Math.max(minHeight, doc.height);
|
||||
|
||||
var wanted = Math.min(maxItems + listOffset,
|
||||
completionElements.length);
|
||||
return completionElements[wanted - 1].getBoundingClientRect().bottom;
|
||||
minHeight = Math.max(minHeight, completionElements[wanted - 1].getBoundingClientRect().bottom);
|
||||
return minHeight;
|
||||
}
|
||||
|
||||
var height = getHeight();
|
||||
@@ -1295,7 +1301,7 @@ liberator.ItemList = function (id) //{{{
|
||||
|
||||
doc.body.appendChild(liberator.util.xmlToDom(div, doc));
|
||||
|
||||
completionElements = doc.getElementsByClassName("liberator-compitem");
|
||||
completionElements = doc.getElementsByClassName("compitem");
|
||||
autoSize();
|
||||
}
|
||||
|
||||
@@ -1307,7 +1313,18 @@ liberator.ItemList = function (id) //{{{
|
||||
|
||||
clear: function () { this.setItems([]); doc.body.innerHTML = ""; },
|
||||
hide: function () { container.collapsed = true; },
|
||||
show: function () { container.collapsed = false; },
|
||||
show: function ()
|
||||
{
|
||||
/* FIXME: Should only happen with autocomplete,
|
||||
* possibly only with async entries.
|
||||
*/
|
||||
if (container.collapsed)
|
||||
{
|
||||
minHeight = 0;
|
||||
autoSize();
|
||||
}
|
||||
container.collapsed = false;
|
||||
},
|
||||
visible: function () !container.collapsed,
|
||||
|
||||
// if @param selectedItem is given, show the list and select that item
|
||||
@@ -1357,9 +1374,9 @@ liberator.ItemList = function (id) //{{{
|
||||
fill(newOffset);
|
||||
|
||||
if (selectedElement)
|
||||
selectedElement.style.backgroundColor = "";
|
||||
selectedElement.removeAttribute("selected");
|
||||
selectedElement = completionElements[index - newOffset];
|
||||
selectedElement.style.backgroundColor = "yellow";
|
||||
selectedElement.setAttribute("selected", "true");
|
||||
|
||||
listIndex = index;
|
||||
return;
|
||||
|
||||
@@ -26,6 +26,18 @@ the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the MPL, the GPL or the LGPL.
|
||||
}}} ***** END LICENSE BLOCK *****/
|
||||
|
||||
@-moz-document
|
||||
url-prefix(chrome://vimperator/),
|
||||
url-prefix(chrome://muttator/) {
|
||||
|
||||
.compitem[selected=true] { background-color: yellow; }
|
||||
.compitem .favicon { width: 16px; }
|
||||
.compitem .favicon img { width: 16px; height: 16px; }
|
||||
.compitem .completion { width: 45%; overflow: hidden; }
|
||||
.compitem .description { color: gray; }
|
||||
|
||||
}
|
||||
|
||||
@-moz-document
|
||||
url-prefix(chrome://vimperator/),
|
||||
url-prefix(chrome://muttator/),
|
||||
@@ -50,10 +62,6 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
||||
color: HighlightText !important;
|
||||
}
|
||||
|
||||
/*.liberator-compitem {
|
||||
min-height: 16px;
|
||||
}*/
|
||||
|
||||
/* fixes the min-height: 22px from firefox */
|
||||
#status-bar, statusbarpanel {
|
||||
-moz-appearance: none !important;
|
||||
|
||||
Reference in New Issue
Block a user