1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 11:58:00 +01:00

Replaced <table>-based completion with equivalent CSS. Mainly proof-of concept. Feel free to revert.

This commit is contained in:
Kris Maglione
2008-10-10 03:49:36 +00:00
parent 5d68871ca7
commit baf2480b75
2 changed files with 38 additions and 44 deletions

View File

@@ -820,7 +820,7 @@ liberator.CommandLine = function () //{{{
[completionStartIndex, completions] = res; [completionStartIndex, completions] = res;
// sort the completion list // sort the completion list
if (/\bsort\b/.test(liberator.options["wildoptions"])) if (liberator.options["wildoptions"].has("sort"))
completions.sort(function (a, b) String.localeCompare(a[0], b[0])); completions.sort(function (a, b) String.localeCompare(a[0], b[0]));
completionList.setItems(completions); completionList.setItems(completions);
@@ -1289,11 +1289,11 @@ liberator.ItemList = function (id) //{{{
a = a(); a = a();
let row = let row =
<tr class="compitem"> <ul class="compitem">
<td class="favicon">{a ? <img src={a}/> : <></>}</td> <li class="favicon">{a ? <img src={a}/> : <></>}</li>
<td class="completion">{b}</td> <li class="completion">{b}</li>
<td class="description">{c}</td> <li class="description">{c}</li>
</tr>; </ul>;
if (dom) if (dom)
return liberator.util.xmlToDom(row, doc); return liberator.util.xmlToDom(row, doc);
@@ -1340,24 +1340,24 @@ liberator.ItemList = function (id) //{{{
XML.ignoreWhitespace = true; XML.ignoreWhitespace = true;
let div = <div class="ex-command-output hl-Normal"> let div = <div class="ex-command-output hl-Normal">
<span class="hl-Title" style="font-weight: bold">Completions:</span> <span class="hl-Title">Completions:</span>
<table width="100%" style="table-layout: fixed; width: 100%"><tbody/></table> <div class="completion-items"/>
</div>; </div>;
let tbody = div..tbody; let tbody = div.div;
for (let i in liberator.util.range(offset, endIndex)) for (let i in liberator.util.range(offset, endIndex))
tbody.* += createRow.apply(null, completions[i]); tbody.* += createRow.apply(null, completions[i]);
div.* += div.* +=
<table> <div class="completion-items">
{ {
liberator.template.map(liberator.util.range(0, maxItems), function (i) liberator.template.map(liberator.util.range(0, maxItems), function (i)
<tr class="compitem"><td class="hl-NonText">~</td></tr>) <ul class="compitem hl-NonText"><li>~</li></ul>)
} }
</table>; </div>;
let dom = liberator.util.xmlToDom(div, doc); let dom = liberator.util.xmlToDom(div, doc);
completionBody = dom.getElementsByTagName("tbody")[0]; completionBody = dom.getElementsByClassName("completion-items")[0];
completionElements = completionBody.childNodes; completionElements = completionBody.childNodes;
doc.body.replaceChild(dom, doc.body.firstChild); doc.body.replaceChild(dom, doc.body.firstChild);
} }
@@ -1370,7 +1370,7 @@ liberator.ItemList = function (id) //{{{
clear: function () { this.setItems([]); doc.body.innerHTML = ""; }, clear: function () { this.setItems([]); doc.body.innerHTML = ""; },
hide: function () { container.collapsed = true; }, hide: function () { container.collapsed = true; },
show: function () show: function show()
{ {
/* FIXME: Should only happen with autocomplete, /* FIXME: Should only happen with autocomplete,
* possibly only with async entries. * possibly only with async entries.
@@ -1385,7 +1385,7 @@ liberator.ItemList = function (id) //{{{
visible: function () !container.collapsed, visible: function () !container.collapsed,
// if @param selectedItem is given, show the list and select that item // if @param selectedItem is given, show the list and select that item
setItems: function (items, selectedItem) setItems: function setItems(items, selectedItem)
{ {
startIndex = endIndex = selIndex = -1; startIndex = endIndex = selIndex = -1;
completions = items || []; completions = items || [];
@@ -1397,7 +1397,7 @@ liberator.ItemList = function (id) //{{{
}, },
// select index, refill list if necessary // select index, refill list if necessary
selectItem: function (index) selectItem: function selectItem(index)
{ {
//if (container.collapsed) // fixme //if (container.collapsed) // fixme
// return; // return;
@@ -1496,22 +1496,13 @@ liberator.StatusLine = function () //{{{
setClass: function (type) setClass: function (type)
{ {
var highlightGroup; const highlightGroup = {
secure: "StatusLineSecure",
broken: "StatusLineBroken",
insecure: "StatusLine",
};
switch (type) statusBar.setAttribute("class", "chromeclass-status hl-" + highlightGroup[type]);
{
case "secure":
highlightGroup = "hl-StatusLineSecure";
break;
case "broken":
highlightGroup = "hl-StatusLineBroken";
break;
case "insecure":
highlightGroup = "hl-StatusLine";
break;
}
statusBar.setAttribute("class", "chromeclass-status " + highlightGroup);
}, },
// update all fields of the statusline // update all fields of the statusline
@@ -1591,17 +1582,12 @@ liberator.StatusLine = function () //{{{
progressStr = "[ Loading... ]"; progressStr = "[ Loading... ]";
else if (progress < 1) else if (progress < 1)
{ {
progressStr = "["; progress = Math.floor(progress * 20);
var done = Math.floor(progress * 20); progressStr = "["
for (let i = 0; i < done; i++) + "====================".substr(0, progress)
progressStr += "="; + ">"
+ "                    ".substr(0, 19 - progress)
progressStr += ">"; + "]";
for (let i = 19; i > done; i--)
progressStr += " ";
progressStr += "]";
} }
progressWidget.value = progressStr; progressWidget.value = progressStr;
} }

View File

@@ -72,12 +72,20 @@ the terms of any one of the MPL, the GPL or the LGPL.
*:-moz-loading, *:-moz-broken { display: none !important; } *:-moz-loading, *:-moz-broken { display: none !important; }
.compitem > td { -moz-binding: url(chrome://liberator/content/bindings.xml#compitem-td); } .compitem {
display: table-row;
}
.compitem > * {
-moz-binding: url(chrome://liberator/content/bindings.xml#compitem-td);
display: table-cell;
vertical-align: middle;
padding: 0 .5ex;
}
.compitem-td-span { height: 1.5em; display: block; } .compitem-td-span { height: 1.5em; display: block; }
.compitem[selected=true] { background-color: yellow; } .compitem[selected=true] { background-color: yellow; }
.compitem > .favicon { width: 16px; } .compitem > .favicon { width: 16px; }
.favicon > img { max-width: 16px, max-height: 16px} .favicon > img { max-width: 16px; max-height: 16px; }
.compitem > .completion { width: 45%; overflow: hidden; } .compitem > .completion { width: 45%; overflow: hidden; }
.compitem > .description { color: gray; } .compitem > .description { color: gray; }