リンクからタブを開くかどうかの判断について、同じような処理は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 = '+ eval('window.TMP_contentAreaClick = '+
window.TMP_contentAreaClick.toSource().replace( window.TMP_contentAreaClick.toSource().replace(
'if (openT)', 'if (openT)',
<![CDATA[if (TreeStyleTabService.checkReadyToOpenNewTab({ <![CDATA[if (TreeStyleTabService.checkReadyToOpenNewTabFromLink(linkNode)) {
uri : linkNode.href,
external : {
newTab : TreeStyleTabService.getTreePref('openOuterLinkInNewTab') || TreeStyleTabService.getTreePref('openAnyLinkInNewTab'),
forceChild : true
},
internal : {
newTab : TreeStyleTabService.getTreePref('openAnyLinkInNewTab')
}
})) {
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
handleLinkClick(event, linkNode.href, linkNode); handleLinkClick(event, linkNode.href, linkNode);

View File

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