リンクからタブを開くかどうかの判断について、同じような処理は1箇所にまとめた

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@6619 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2010-04-23 01:15:23 +00:00
parent c07376f345
commit 456c287d3e
3 changed files with 27 additions and 29 deletions

View File

@ -343,16 +343,7 @@ TreeStyleTabService.overrideExtensionsOnInitAfter = function TSTService_override
eval('window.TMP_contentAreaClick = '+
window.TMP_contentAreaClick.toSource().replace(
'if (openT)',
<![CDATA[if (TreeStyleTabService.checkReadyToOpenNewTab({
uri : linkNode.href,
external : {
newTab : TreeStyleTabService.getTreePref('openOuterLinkInNewTab') || TreeStyleTabService.getTreePref('openAnyLinkInNewTab'),
forceChild : true
},
internal : {
newTab : TreeStyleTabService.getTreePref('openAnyLinkInNewTab')
}
})) {
<![CDATA[if (TreeStyleTabService.checkReadyToOpenNewTabFromLink(linkNode)) {
event.stopPropagation();
event.preventDefault();
handleLinkClick(event, linkNode.href, linkNode);

View File

@ -964,15 +964,8 @@ catch(e) {
).replace(
/(event.ctrlKey|event.metaKey)/,
<![CDATA[
TreeStyleTabService.checkReadyToOpenNewTab({
uri : href,
external : {
newTab : TreeStyleTabService.getTreePref('openOuterLinkInNewTab') || TreeStyleTabService.getTreePref('openAnyLinkInNewTab'),
forceChild : true
},
internal : {
newTab : TreeStyleTabService.getTreePref('openAnyLinkInNewTab')
},
TreeStyleTabService.checkReadyToOpenNewTabFromLink({
link : (linkNode || { href : href }),
modifier : $1,
invert : TreeStyleTabService.getTreePref('link.invertDefaultBehavior')
}) ?
@ -1032,16 +1025,7 @@ catch(e) {
!TreeStyleTabService.getTreePref('compatibility.TMP') ||
!('TMP_contentAreaClick' in window)
) &&
TreeStyleTabService.checkReadyToOpenNewTab({
uri : wrapper.href,
external : {
newTab : TreeStyleTabService.getTreePref('openOuterLinkInNewTab') || TreeStyleTabService.getTreePref('openAnyLinkInNewTab'),
forceChild : true
},
internal : {
newTab : TreeStyleTabService.getTreePref('openAnyLinkInNewTab')
}
})
TreeStyleTabService.checkReadyToOpenNewTabFromLink(wrapper)
) {
event.stopPropagation();
event.preventDefault();

View File

@ -1218,6 +1218,29 @@ var TreeStyleTabUtils = {
});
},
checkReadyToOpenNewTabFromLink : function TSTUtils_checkReadyToOpenNewTabFromLink(aLink)
{
var options = aLink;
if (typeof aLink == 'string') {
options = {
link : { href : aLink }
};
}
else if (aLink instanceof Ci.nsIDOMElement) {
options = { link : aLink };
}
options.__prpto__ = {
external : {
newTab : this.getTreePref('openOuterLinkInNewTab') || this.getTreePref('openAnyLinkInNewTab'),
forceChild : true
},
internal : {
newTab : this.getTreePref('openAnyLinkInNewTab')
}
}
return this.checkReadyToOpenNewTab(options);
},
_getDomainFromURI : function TSTUtils__getDomainFromURI(aURI)
{
if (!aURI) return null;