mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 22:22:27 +01:00
fixed :qmarks/:hs/:bmarks display, add a new template.genericTable() method
This commit is contained in:
@@ -77,7 +77,14 @@ function Bookmarks() //{{{
|
|||||||
let keyword = bookmarksService.getKeywordForBookmark(node.itemId);
|
let keyword = bookmarksService.getKeywordForBookmark(node.itemId);
|
||||||
let tags = taggingService.getTagsForURI(uri, {}) || [];
|
let tags = taggingService.getTagsForURI(uri, {}) || [];
|
||||||
//return bookmarks.push(new Bookmark(node.uri, node.title, null, keyword, tags, node.itemId));
|
//return bookmarks.push(new Bookmark(node.uri, node.title, null, keyword, tags, node.itemId));
|
||||||
return bookmarks.push({ url: node.uri, title: node.title, get icon() getFavicon(node.uri), keyword: keyword, tags: tags, id: node.itemId});
|
|
||||||
|
return bookmarks.push({ url: node.uri,
|
||||||
|
title: node.title,
|
||||||
|
get icon() getFavicon(node.uri), // TODO; must be a direct way to get the icon
|
||||||
|
keyword: keyword,
|
||||||
|
tags: tags,
|
||||||
|
id: node.itemId,
|
||||||
|
get xml() template.bookmarkItem(this)});
|
||||||
}
|
}
|
||||||
|
|
||||||
function readBookmark(id)
|
function readBookmark(id)
|
||||||
@@ -537,7 +544,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.bookmarks("title", items);
|
let list = template.genericTable(["", "title", "URL"], items);
|
||||||
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
|
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -718,7 +725,10 @@ function History() //{{{
|
|||||||
{
|
{
|
||||||
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) // just make sure it's a bookmark
|
||||||
items.push({ url: node.uri, title: node.title, icon: node.icon ? node.icon.spec : DEFAULT_FAVICON });
|
items.push({ url: node.uri,
|
||||||
|
title: node.title,
|
||||||
|
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!
|
||||||
|
|
||||||
@@ -770,7 +780,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.bookmarks("title", items);
|
let list = template.genericTable(["", "title", "URL"], items);
|
||||||
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
|
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -944,9 +954,12 @@ function QuickMarks() //{{{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let items = ({ title: String(mark), url: qmarks.get(mark) } for each (mark in marks));
|
let items = ({ title: String(mark),
|
||||||
// TODO: template.bookmarks is not the best for quickmarks
|
url: qmarks.get(mark),
|
||||||
let list = template.bookmarks("QuickMark", items);
|
get xml() <tr><td>  {this.title}</td><td>{this.url}</td></tr>
|
||||||
|
} for each (mark in marks));
|
||||||
|
|
||||||
|
let list = template.genericTable(["QuickMark", "URL"], items);
|
||||||
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
|
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -809,34 +809,6 @@ function Completion() //{{{
|
|||||||
|
|
||||||
bookmark: function (filter)
|
bookmark: function (filter)
|
||||||
{
|
{
|
||||||
// TODO: move to template.js?
|
|
||||||
function createHtml(item)
|
|
||||||
{
|
|
||||||
var extra = [];
|
|
||||||
if (item.keyword)
|
|
||||||
extra.push(['keyword', item.keyword, "hl-Keyword"]);
|
|
||||||
if (item.tags.length > 0)
|
|
||||||
extra.push(["tags", item.tags.join(","), "hl-Tag"]); // no space, otherwise it looks strange, since we just have spaces to seperate tags from keywords
|
|
||||||
|
|
||||||
return <ul class="hl-CompItem">
|
|
||||||
<li class="hl-CompIcon"><img src={item.icon || ""}/></li>
|
|
||||||
<li class="hl-CompResult">{util.clip(item.title || "", 50)}</li>
|
|
||||||
<li style="width: 100%">
|
|
||||||
<a href="#" class="hl-URL">{item.url}</a> 
|
|
||||||
{
|
|
||||||
!(extra.length) ? "" :
|
|
||||||
<span class="extra-info">
|
|
||||||
({
|
|
||||||
template.map(extra, function (e)
|
|
||||||
<>{e[0]}: <span class={e[2]}>{e[1]}</span></>,
|
|
||||||
<> </>/* Non-breaking space */)
|
|
||||||
})
|
|
||||||
</span>
|
|
||||||
}
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
start: 0,
|
start: 0,
|
||||||
get items() {
|
get items() {
|
||||||
@@ -846,28 +818,9 @@ function Completion() //{{{
|
|||||||
bmark[1] = bmark.title;
|
bmark[1] = bmark.title;
|
||||||
|
|
||||||
bmark.text = bmark.url;
|
bmark.text = bmark.url;
|
||||||
bmark.__defineGetter__("html", function () createHtml(bmark));
|
|
||||||
return bmark;
|
return bmark;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
createRow: function (item)
|
|
||||||
<ul class="hl-CompItem">
|
|
||||||
<li class="hl-CompIcon"><img src={item.icon || ""}/></li>
|
|
||||||
<li class="hl-CompResult">{util.clip(item.title || "", 50)}</li>
|
|
||||||
<li style="width: 100%">
|
|
||||||
<a href="#" class="hl-URL">{item.url}</a> 
|
|
||||||
{
|
|
||||||
!(item.extra && item.extra.length) ? "" :
|
|
||||||
<span class="extra-info">
|
|
||||||
({
|
|
||||||
template.map(item.extra, function (e)
|
|
||||||
<>{e[0]}: <span class={e[2]}>{e[1]}</span></>,
|
|
||||||
<> </>/* Non-breaking space */)
|
|
||||||
})
|
|
||||||
</span>
|
|
||||||
}
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -616,8 +616,8 @@ function Mail() //{{{
|
|||||||
"Toggle HTML message display",
|
"Toggle HTML message display",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
var want_html = (gPrefBranch.getIntPref("mailnews.display.html_as", 1) == 1);
|
let wantHtml = (gPrefBranch.getIntPref("mailnews.display.html_as", 1) == 1);
|
||||||
mail.setHTML(want_html ? 1 : 0);
|
mail.setHTML(wantHtml ? 1 : 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
// YANKING TEXT
|
// YANKING TEXT
|
||||||
|
|||||||
@@ -138,20 +138,51 @@ const template = {
|
|||||||
return <>:{commandline.getCommand()}<br/></> + xml;
|
return <>:{commandline.getCommand()}<br/></> + xml;
|
||||||
},
|
},
|
||||||
|
|
||||||
bookmarks: function (header, items)
|
// 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
|
||||||
|
genericTable: function (headers, items)
|
||||||
{
|
{
|
||||||
let createRow = completion.bookmark("").createRow;
|
|
||||||
return this.generic(
|
return this.generic(
|
||||||
<table>
|
<table>
|
||||||
<tr align="left" class="hl-Title">
|
<tr align="left" class="hl-Title">
|
||||||
<th/><th>{header}</th><th>URL</th>
|
{
|
||||||
|
headers.reduce(function (prev, cur) prev + <th>{cur}</th>, <></>)
|
||||||
|
}
|
||||||
</tr>
|
</tr>
|
||||||
{
|
{
|
||||||
this.map(items, function (item) createRow(item))
|
this.map(items, function (item) item.xml)
|
||||||
}
|
}
|
||||||
</table>);
|
</table>);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// returns a single row for a bookmark or history item
|
||||||
|
bookmarkItem: function (item)
|
||||||
|
{
|
||||||
|
var extra = [];
|
||||||
|
if (item.keyword)
|
||||||
|
extra.push(['keyword', item.keyword, "hl-Keyword"]);
|
||||||
|
if (item.tags && item.tags.length > 0)
|
||||||
|
extra.push(["tags", item.tags.join(","), "hl-Tag"]); // no space, otherwise it looks strange, since we just have spaces to seperate tags from keywords
|
||||||
|
|
||||||
|
return <ul class="hl-CompItem">
|
||||||
|
<li class="hl-CompIcon"><img src={item.icon || ""}/></li>
|
||||||
|
<li class="hl-CompResult">{util.clip(item.title || "", 50)}</li>
|
||||||
|
<li style="width: 100%">
|
||||||
|
<a href="#" class="hl-URL">{item.url}</a> 
|
||||||
|
{
|
||||||
|
!(extra.length) ? "" :
|
||||||
|
<span class="extra-info">
|
||||||
|
({
|
||||||
|
template.map(extra, function (e)
|
||||||
|
<>{e[0]}: <span class={e[2]}>{e[1]}</span></>,
|
||||||
|
<> </>/* Non-breaking space */)
|
||||||
|
})
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
},
|
||||||
|
|
||||||
jumps: function (index, elems)
|
jumps: function (index, elems)
|
||||||
{
|
{
|
||||||
return this.generic(
|
return this.generic(
|
||||||
|
|||||||
@@ -1381,14 +1381,14 @@ function ItemList(id) //{{{
|
|||||||
if (diff == 1) /* Scroll down */
|
if (diff == 1) /* Scroll down */
|
||||||
{
|
{
|
||||||
let item = items[endIndex - 1];
|
let item = items[endIndex - 1];
|
||||||
let row = "html" in item ? util.xmlToDom(item.html, doc) : createDefaultRow(item, true);
|
let row = "xml" in item ? util.xmlToDom(item.html, doc) : createDefaultRow(item, true);
|
||||||
tbody.removeChild(tbody.firstChild);
|
tbody.removeChild(tbody.firstChild);
|
||||||
tbody.appendChild(row);
|
tbody.appendChild(row);
|
||||||
}
|
}
|
||||||
else /* Scroll up */
|
else /* Scroll up */
|
||||||
{
|
{
|
||||||
let item = items[offset];
|
let item = items[offset];
|
||||||
let row = "html" in item ? util.xmlToDom(item.html, doc) : createDefaultRow(item, true);
|
let row = "xml" in item ? util.xmlToDom(item.html, doc) : createDefaultRow(item, true);
|
||||||
tbody.removeChild(tbody.lastChild);
|
tbody.removeChild(tbody.lastChild);
|
||||||
tbody.insertBefore(row, tbody.firstChild);
|
tbody.insertBefore(row, tbody.firstChild);
|
||||||
}
|
}
|
||||||
@@ -1402,7 +1402,7 @@ function ItemList(id) //{{{
|
|||||||
<div class="hl-Completions">
|
<div class="hl-Completions">
|
||||||
{
|
{
|
||||||
template.map(util.range(offset, endIndex), function (i)
|
template.map(util.range(offset, endIndex), function (i)
|
||||||
"html" in items[i] ? items[i].html : createDefaultRow(items[i]))
|
"xml" in items[i] ? items[i].html : createDefaultRow(items[i]))
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="hl-Completions">
|
<div class="hl-Completions">
|
||||||
|
|||||||
Reference in New Issue
Block a user