mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 13:52:26 +01:00
Fix :bmarks, etc. Fix oversized completion tables.
This commit is contained in:
@@ -350,7 +350,8 @@ function Bookmarks() //{{{
|
|||||||
return {
|
return {
|
||||||
|
|
||||||
get format() ({
|
get format() ({
|
||||||
keys: { text: "url", description: "title", icon: "icon" },
|
title: ["URL", "Info"],
|
||||||
|
keys: { text: "url", description: "title", icon: "icon", extra: "extra" },
|
||||||
process: [template.icon, template.bookmarkDescription]
|
process: [template.icon, template.bookmarkDescription]
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -578,7 +579,7 @@ function Bookmarks() //{{{
|
|||||||
if (openItems)
|
if (openItems)
|
||||||
return liberator.open([i.url for each (i in items)], liberator.NEW_TAB);
|
return liberator.open([i.url for each (i in items)], liberator.NEW_TAB);
|
||||||
|
|
||||||
let list = template.genericTable(["", "title", "URL"], items);
|
let list = template.genericTable(items, this.format);
|
||||||
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
|
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -761,14 +762,14 @@ function History() //{{{
|
|||||||
// execute the query
|
// execute the query
|
||||||
let root = historyService.executeQuery(query, options).root;
|
let root = historyService.executeQuery(query, options).root;
|
||||||
root.containerOpen = true;
|
root.containerOpen = true;
|
||||||
for (let i = 0; i < root.childCount; i++)
|
for (let i in util.range(0, root.childCount))
|
||||||
{
|
{
|
||||||
let node = root.getChild(i);
|
let node = root.getChild(i);
|
||||||
if (node.type == node.RESULT_TYPE_URI) // just make sure it's a bookmark
|
if (node.type == node.RESULT_TYPE_URI)
|
||||||
items.push({ url: node.uri,
|
items.push({ url: node.uri,
|
||||||
title: node.title,
|
title: node.title,
|
||||||
icon: node.icon ? node.icon.spec : DEFAULT_FAVICON,
|
icon: node.icon ? node.icon.spec : DEFAULT_FAVICON
|
||||||
get xml() template.bookmarkItem(this)});
|
})
|
||||||
}
|
}
|
||||||
root.containerOpen = false; // close a container after using it!
|
root.containerOpen = false; // close a container after using it!
|
||||||
|
|
||||||
@@ -820,7 +821,7 @@ function History() //{{{
|
|||||||
if (openItems)
|
if (openItems)
|
||||||
return liberator.open([i[0] for each (i in items)], liberator.NEW_TAB);
|
return liberator.open([i[0] for each (i in items)], liberator.NEW_TAB);
|
||||||
|
|
||||||
let list = template.genericTable(["", "title", "URL"], items);
|
let list = template.genericTable(items, bookmarks.format);
|
||||||
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
|
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -994,12 +995,9 @@ function QuickMarks() //{{{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let items = ({ title: String(mark),
|
let items = [[mark, qmarks.get(mark)] for ([k, mark] in Iterator(marks))];
|
||||||
url: qmarks.get(mark),
|
|
||||||
get xml() <tr><td>  {this.title}</td><td>{this.url}</td></tr>
|
|
||||||
} for each (mark in marks));
|
|
||||||
|
|
||||||
let list = template.genericTable(["QuickMark", "URL"], items);
|
let list = template.genericTable(items, { title: ["QuickMark", "URL"] });
|
||||||
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
|
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -152,13 +152,15 @@ CompletionContext.prototype = {
|
|||||||
set filter(val) this._filter = val,
|
set filter(val) this._filter = val,
|
||||||
|
|
||||||
get format() ({
|
get format() ({
|
||||||
|
title: this.title,
|
||||||
keys: this.keys,
|
keys: this.keys,
|
||||||
process: this.process
|
process: this.process
|
||||||
}),
|
}),
|
||||||
set format(format)
|
set format(format)
|
||||||
{
|
{
|
||||||
this.keys = format.keys;
|
this.title = format.title || this.title;
|
||||||
this.process = format.process;
|
this.keys = format.keys || this.keys;
|
||||||
|
this.process = format.process || this.process;
|
||||||
},
|
},
|
||||||
|
|
||||||
get items()
|
get items()
|
||||||
|
|||||||
@@ -54,19 +54,22 @@ const template = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
bookmarkDescription: function (item, text)
|
bookmarkDescription: function (item, text)
|
||||||
<>
|
{
|
||||||
|
let extra = this.getKey(item, "extra");
|
||||||
|
return <>
|
||||||
<a href="#" class="hl-URL">{text}</a> 
|
<a href="#" class="hl-URL">{text}</a> 
|
||||||
{
|
{
|
||||||
!(item.item.extra.length) ? "" :
|
!(extra && extra.length) ? "" :
|
||||||
<span class="extra-info">
|
<span class="extra-info">
|
||||||
({
|
({
|
||||||
template.map(item.item.extra, function (e)
|
template.map(extra, function (e)
|
||||||
<>{e[0]}: <span class={e[2]}>{e[1]}</span></>,
|
<>{e[0]}: <span class={e[2]}>{e[1]}</span></>,
|
||||||
<> </>/* Non-breaking space */)
|
<> </>/* Non-breaking space */)
|
||||||
})
|
})
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
</>,
|
</>
|
||||||
|
},
|
||||||
|
|
||||||
icon: function (item, text)
|
icon: function (item, text)
|
||||||
{
|
{
|
||||||
@@ -183,19 +186,20 @@ const template = {
|
|||||||
|
|
||||||
// every item must have a .xml property which defines how to draw itself
|
// every item must have a .xml property which defines how to draw itself
|
||||||
// @param headers is an array of strings, the text for the header columns
|
// @param headers is an array of strings, the text for the header columns
|
||||||
genericTable: function genericTable(headers, items)
|
genericTable: function genericTable(items, format)
|
||||||
{
|
{
|
||||||
|
// FIXME: Kludge.
|
||||||
|
let context = new CompletionContext("");
|
||||||
|
context.filterFunc = function (items) items;
|
||||||
|
if (format)
|
||||||
|
context.format = format;
|
||||||
return this.generic(
|
return this.generic(
|
||||||
<table>
|
<div class="hl-Completions">
|
||||||
<tr align="left" class="hl-Title">
|
{ this.completionRow(context, context.title, "hl-CompTitle") }
|
||||||
{
|
{
|
||||||
headers.reduce(function (prev, cur) prev + <th>{cur}</th>, <></>)
|
this.map(items, function (item) template.completionRow(context, { text: context.getKey({item: item}, "text"), item: item }))
|
||||||
}
|
}
|
||||||
</tr>
|
</div>);
|
||||||
{
|
|
||||||
this.map(items, function (item) item.xml)
|
|
||||||
}
|
|
||||||
</table>);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// returns a single row for a bookmark or history item
|
// returns a single row for a bookmark or history item
|
||||||
|
|||||||
@@ -72,7 +72,11 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
|||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
.td-span {
|
.td-span {
|
||||||
height: 1.5em; line-height: 1.5em !important;
|
display: inline-block;
|
||||||
|
overflow: visible;
|
||||||
|
width: 0px;
|
||||||
|
height: 1.5em;
|
||||||
|
line-height: 1.5em !important;
|
||||||
}
|
}
|
||||||
.td-strut {
|
.td-strut {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|||||||
Reference in New Issue
Block a user