PK8EVEVchrome/tabmixplus.jarPK 8content/PK 8content/tabmixplus/PK t5pHEEcontent/tabmixplus/about.xul %aboutDTD; %miscDTD; ]> PK 8content/tabmixplus/bookmarks/PK |p8ff)content/tabmixplus/bookmarks/bookmarks.jsvar Click2TabLoadBookmark = { init : function () { TMP_Bookmark.init(); eval("BookmarksMenu.loadBookmark = " + BookmarksMenu.loadBookmark.toString().replace( 'var browserTarget = whereToOpenLink(aEvent);', 'var browserTarget = whereToOpenLinkTabmix(aEvent, prefStringTMBookmark, selection, aDS);' )); } } // this code is call from browser window and from bookmark manager var TMP_Bookmark = { init : function () { BookmarksCommand.openGroupBookmark = this.TMP_openGroupBookmark; eval("BookmarksCommand.createContextMenu ="+BookmarksCommand.createContextMenu.toString().replace( 'popup.firstChild.setAttribute("default", "true");', '$& \ TMP_Bookmark.buildContextMenu(popup)' )); TMP_update_whereToOpen(); }, buildContextMenu : function (popup) { var _open = popup.getElementsByAttribute("command", "cmd_bm_open")[0]; var _openInWindow = popup.getElementsByAttribute("command", "cmd_bm_openinnewwindow")[0]; var _openInTab = popup.getElementsByAttribute("command", "cmd_bm_openinnewtab")[0]; TMP_updateContextMenu(_open, _openInWindow, _openInTab, prefStringTMBookmark); }, TMP_openGroupBookmark: function (aURI, aTargetBrowser) { var resource = RDF.GetResource(aURI); var urlArc = RDF.GetResource(NC_NS_TM+"URL"); // gNC_NS isn't for 1.0.7 RDFC.Init(BMDS, resource); var containerChildren = RDFC.GetElements(); var res, target, bmGroup = []; while (containerChildren.hasMoreElements()) { res = containerChildren.getNext().QueryInterface(kRDFRSCIID); target = BMDS.GetTarget(res, urlArc, true); if (target) bmGroup.push(target.QueryInterface(kRDFLITIID).Value); } // If the bookmark group was completely invalid, just bail. if (bmGroup.length != 0) { if ("_confirmOpenTabs" in this && !this._confirmOpenTabs(bmGroup.length)) return; var browserWindow = getTopWin(); if (!browserWindow) window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no", bmGroup.join("|")); else browserWindow.TMP_Bookmark.openGroup(bmGroup); } }, // fixed: reuse all blank tab not just in the end // fixed: if "browser.tabs.loadFolderAndReplace" is true don't reuse locked and protected tabs open bookmark after those tabs // fixed: focus the first tab if "extensions.tabmix.openTabNext" is true // fixed: remove "selected" and "flst_id" from reuse tab openGroup: function (bmGroup, aWhere) { var browser = getBrowser(); var tabs = browser.mTabContainer.childNodes; var doReplace = aWhere == "tab" ? false : gPref.getBoolPref("browser.tabs.loadFolderAndReplace"); var loadInBackground = aWhere == "tabshifted" ? true : gPref.getBoolPref("browser.tabs.loadBookmarksInBackground"); var openTabNext = gPref.getBoolPref("extensions.tabmix.openTabNext"); // catch tab for reuse var aTab, reuseTabs = [], removeTabs = [], i; var tabIsBlank, canReplace; for (i = 0; i < tabs.length ; i++) { aTab = tabs[i]; tabIsBlank = browser.isBlankNotBusyTab(aTab); canReplace = (doReplace && !aTab.hasAttribute("locked")) || tabIsBlank; if (reuseTabs.length < bmGroup.length && canReplace) reuseTabs.push(aTab); else if ((doReplace && !aTab.hasAttribute("locked") && !aTab.hasAttribute("protected")) || tabIsBlank) removeTabs.push(aTab); } var tabToSelect = null; var prevTab = (!doReplace && openTabNext && browser.mCurrentTab._tPos < tabs.length - 1) ? browser.mCurrentTab : browser.mTabContainer.lastChild; var tabPos, index; for (i = 0; i < bmGroup.length ; i++) { try { // bug 300911 if (i < reuseTabs.length) { aTab = reuseTabs[i]; browser.getBrowserForTab(aTab).loadURI(bmGroup[i]); // reset selected & flst_id attribute if (aTab != browser.mCurrentTab) { aTab.removeAttribute("selected"); aTab.removeAttribute("flst_id"); } else aTab.setAttribute("reloadcurrent", true); } else aTab = browser.addTab(bmGroup[i]); } catch (er) { } if (!tabToSelect) tabToSelect = aTab; // move tab to place index = prevTab._tPos + 1; tabPos = aTab._tPos < index ? index - 1 : index; browser.TMmoveTabTo(aTab, tabPos); prevTab = aTab; } browser.mTabContainer.nextTab = 1; // focus the first tab if prefs say to if (!loadInBackground || doReplace) { // Select the first tab in the group. // Set newly selected tab after quick timeout, otherwise hideous focus problems // can occur because new presshell is not ready to handle events function selectNewForegroundTab(browser, tab) { var old = browser.selectedTab; browser.selectedTab = tab; var reloadCurrent = old.hasAttribute("reloadcurrent"); if (reloadCurrent) old.removeAttribute("reloadcurrent"); if (reloadCurrent && old != tab) { old.removeAttribute("selected"); old.removeAttribute("flst_id"); } } setTimeout(selectNewForegroundTab, 0, browser, tabToSelect); } // Close any remaining open tabs or blank tabs that are left over. while (removeTabs.length > 0) { browser.removeTab(removeTabs.pop()); } // and focus the content content.focus(); }, _getBookmarkTitle: function (url) { if(! BMSVC || ! BMDS || ! RDF) return null; var urlArc = RDF.GetResource(NC_NS_TM+"URL"); var urlLiteral = RDF.GetLiteral(url); if (BMDS.hasArcIn(urlLiteral, urlArc)) { var bmResources, bmResource, title, type, ptype; bmResources = BMSVC.GetSources(urlArc, urlLiteral, true); while (bmResources.hasMoreElements()) { bmResource = bmResources.getNext(); type = BookmarksUtils.resolveType(bmResource); if (type != "ImmutableBookmark") { ptype = BookmarksUtils.resolveType(BMSVC.getParent(bmResource)); if ( (type == "Bookmark" || type == "IEFavorite") && ptype != "Livemark") { title = BookmarksUtils.getProperty(bmResource, NC_NS_TM+"Name"); if (title != "") return title; } } } } return null; } } PK T6/5-*content/tabmixplus/bookmarks/bookmarks.xul PK T6mxx1content/tabmixplus/bookmarks/bookmarksManager.xul PK 1T6[U//.content/tabmixplus/bookmarks/bookmarksPanel.jsvar BookmarksTreeClick2Tab = { bookmarksView : null, init : function () { window.removeEventListener('load', function () { BookmarksTreeClick2Tab.init(); }, false); if (typeof(PlacesController) == "function") { TMP_Places.init(); return; } TMP_Bookmark.init(); this.bookmarksView = document.getElementById("bookmarks-view"); eval("this.bookmarksView.openItemClick = " + this.bookmarksView.openItemClick.toString().replace( 'var browserTarget = whereToOpenLink(aEvent);', 'var browserTarget = whereToOpenLinkTabmix(aEvent, prefStringTMBookmark, selection, this.db);' )); eval("this.bookmarksView.openItemKey = " + this.bookmarksView.openItemKey.toString().replace( 'BookmarksCommand.openBookmark(this._selection, "current", this.db)', '{var browserTarget = whereToOpenLinkTabmix(null, prefStringTMBookmark, this._selection, this.db); BookmarksCommand.openBookmark(this._selection, browserTarget, this.db);}' )); } } PK 8content/tabmixplus/click/PK 87++!content/tabmixplus/click/click.jsvar onDoubleClick = false; var gTab; // single click function // function TM_checkClick (event) { if (event && event.button == 2) return; // right click if (event && event.button == 0 && event.detail > 1) return; // double click (with left button) var target = event.originalTarget; // don't do anything if user click on close tab button , or on any other button on tab or tabbar if (target.getAttribute("anonid") == "tmp-close-button" || target.localName == "toolbarbutton") return; // the fix for bug 216899 will make autoscrolling override contentLoadURL if both are enabled // we don't need autoscrolling to override contentLoadURL if user click on tab or tabbar if (event.button == 1 && gPref.getBoolPref("middlemouse.contentLoadURL")) { if (!event.getPreventDefault()) { middleMousePaste(event); event.stopPropagation(); } return; } onDoubleClick = false; var aTab = target; while ( aTab.localName != "tabs" ) { if ( aTab.localName == "tab" ) break; if ( aTab.parentNode ) aTab = aTab.parentNode; else return; } gTab = aTab; var clickOutTabs = aTab.localName == "tabs"; // for tab flip if ( !clickOutTabs && event.button == 0 && aTab.hasAttribute("clickOnCurrent") ) { aTab.removeAttribute("clickOnCurrent"); var tabFlip = TMP_getBoolPref(tabxBranch, "tabFlip", false); var tabFlipDelay = TMP_getIntPref (tabxBranch, "tabFlipDelay", 250); if (tabFlip && !event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey){ window.setTimeout(function () { if (!onDoubleClick) { gBrowser.previousTab(aTab); gBrowser.stopMouseHoverSelect(aTab); content.focus(); } }, tabFlipDelay ); return; } } var prefName /* middle click*/ if (event.button == 1) prefName = "middle" /* shift click*/ else if (event.button == 0 && event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey) prefName = "shift" /* alt click*/ else if (event.button == 0 && event.altKey && !event.ctrlKey && !event.shiftKey && !event.metaKey) prefName = "alt" /* ctrl click*/ else if (event.button == 0 && (event.ctrlKey && !event.metaKey || !event.ctrlKey && event.metaKey) && !event.shiftKey && !event.altKey) prefName = "ctrl" TMclickAction(prefName, clickOutTabs, aTab); } // Double click function // function TM_onTabBarDblClick (e) { if ( !e || e.button != 0 || e.ctrlKey || e.shiftKey || e.altKey || e.metaKey ) return; onDoubleClick = true; var aTab = e.originalTarget; // don't do anything if user click on close tab button , or on any other button on tab or tabbar if (aTab.getAttribute("anonid") == "tmp-close-button" || aTab.localName == "toolbarbutton") return; while ( aTab.localName != "tabs" ) { if ( aTab.localName == "tab" ) break; aTab = aTab.parentNode; } // check if the 2 click was not on the same tab // it's look like only problem in 1.0.7 if (gTab != aTab) { gTab = aTab; return; } else gTab = null; TMclickAction( "dbl", aTab.localName == "tabs", aTab ); } // call action function from click on tabs or tabbar // function TMclickAction ( pref, clickOutTabs, aTab ) { if (!pref) return; // just in case we missed something var defaultPref = {middleClickTab:2, middleClickTabbar:10, shiftClickTab:5, shiftClickTabbar:0, altClickTab:6, altClickTabbar:0, ctrlClickTab:22, ctrlClickTabbar:0, dblClickTab:0, dblClickTabbar:1}; pref += clickOutTabs ? "ClickTabbar" : "ClickTab"; var action = TMP_getIntPref (tabxBranch, pref , defaultPref[pref]); content.focus(); switch ( action ) { case 0 : break; case 1 : BrowserOpenTab(); break; case 2 : // removeTab tab after delay, // if the tab is in the middle of selecting or we just add new tab // it can caused problem function _delayCloseTab(b, tab){ b.closeTab(tab); } if (aTab.localName != "tab") aTab = gBrowser.mCurrentTab; setTimeout(_delayCloseTab, 0, gBrowser, aTab); break; case 3 : gBrowser.duplicateTab(aTab); break; case 4 : gBrowser.reloadTab(aTab); break; case 5 : gBrowser.protectTab(aTab); break; case 6 : gBrowser.lockTab(aTab); break; case 7 : gBrowser.reloadAllTabs(aTab); break; case 8: gBrowser.removeAllTabsBut(aTab); break; case 9: gBrowser.closeAllTabs(); break; case 10: TMP_ClosedTabs.undoCloseTab(); break; case 11: gBrowser.renameTab(aTab); break; case 12: //taken from tco if (SessionSaver && SessionSaver.snapBackTab) SessionSaver.snapBackTab(SessionSaver.snapback_noFX, SessionSaver.snapback_willFocus); break; case 13: gBrowser.undoRemoveAllTab(); break; case 14: gBrowser.duplicateInWindow(aTab, false); break; case 15: gBrowser.freezeTab(aTab); break; case 16: gBrowser.reloadAllTabsBut(aTab); break; case 17: gBrowser.closeLeftTabs(aTab); break; case 18: gBrowser.closeRightTabs(aTab); break; case 19: gBrowser.reloadLeftTabs(aTab); break; case 20: gBrowser.reloadRightTabs(aTab); break; case 21: // taken from tco if (aTab.localName != "tab") aTab = gBrowser.mCurrentTab; var href; if (window.IeView && window.IeView.ieViewLaunch) { href = gBrowser.getBrowserForTab(aTab).currentURI.spec; IeView.ieViewLaunch("Internet Explorer.lnk", href); } else if (window.gIeTab && window.gIeTab.switchTabEngine) { if (gBrowser.selectedTab != aTab) gBrowser.selectedTab = aTab; gIeTab.switchTabEngine(aTab, gIeTab.getBoolPref("ietab.alwaysNewTab", false)); } else if(window.ieview && window.ieview.launch) { href = gBrowser.getBrowserForTab(aTab).currentURI.spec; ieview.launch(href); } break; case 22: gBrowser.SelectToMerge(aTab); break; case 23: dtMergeWindows.mergeWindows(); break; case 24: gBrowser.closeGroupTabs(aTab); break; case 25: if (aTab.localName != "tab") aTab = gBrowser.mCurrentTab; var browserSpecs = gBrowser.getBrowserForTab(aTab).webNavigation; if (gIsPlaces) PlacesCommandHook.bookmarkPage(aTab.linkedBrowser, PlacesUtils.bookmarksMenuFolderId, true); else addBookmarkForBrowser(gBrowser.getBrowserForTab(aTab).webNavigation); break; case 26: if (document.getElementById('Browser:BookmarkAllTabs')) { if (gIsPlaces) PlacesCommandHook.bookmarkCurrentPages(); else addBookmarkForTabBrowser(gBrowser, true); } break; case 27: gBrowser.duplicateInWindow(aTab, true); break; case 28: gBrowser.copyTabUrl(aTab); break; } } function Tm_checkTabClick(event) { var tabContextMenu = window.gBrowser.mStrip.firstChild.nextSibling; // Undo close tab Commands - firefox 3.0 toggle this menu item also when submneu are show var undoClose = tabxPrefs.getBoolPref("undoClose"); TMP_showItem("context_undoCloseTab", tabxPrefs.getBoolPref("undoCloseTabMenu") && undoClose); if (event.originalTarget != tabContextMenu) return true; var item; if (document.popupNode.parentNode) item = document.popupNode.parentNode.parentNode.id; if (item && (item == "btn_tabslist" || item == "btn_tabslistSorted")) gBrowser.mContextTab = document.popupNode.tab; var clickOutTabs = gBrowser.mContextTab ? gBrowser.mContextTab.localName == "tabs": true; var aTab = clickOutTabs ? gBrowser.mCurrentTab : gBrowser.mContextTab; var cIndex = aTab._tPos; var isOneWindow = numberOfWindows() == 1; var newTab = document.getElementById("context_newTab"); TMP_showItem(newTab, tabxPrefs.getBoolPref("newTabMenu")); if (clickOutTabs) { TMP_setItem(newTab, "label", newTab.getAttribute("_newtab")); TMP_setItem(newTab, "oncommand", "TMP_BrowserOpenTab();"); } else { TMP_setItem(newTab, "label", newTab.getAttribute("_newtab") + " " + newTab.getAttribute("_afterthis")); TMP_setItem(newTab, "oncommand", "var tabbrowser = this.parentNode.parentNode.parentNode.parentNode; TMP_BrowserOpenTab(tabbrowser.mContextTab);"); } // Duplicate Commands TMP_showItem("tm-duplicateTab", tabxPrefs.getBoolPref("duplicateMenu")); TMP_showItem("tm-duplicateinWin", tabxPrefs.getBoolPref("duplicateinWinMenu") && !gSingleWindowMode); TMP_showItem("tm-detachTab", tabxPrefs.getBoolPref("detachTabMenu") && !gSingleWindowMode); TMP_showItem("tm-mergeWindowsTab", tabxPrefs.getBoolPref("showMergeWindow") && (!gSingleWindowMode || (gSingleWindowMode && !isOneWindow))); var showRenameTabMenu = tabxPrefs.getBoolPref("renameTabMenu"); TMP_showItem("tm-renameTab", showRenameTabMenu); TMP_showItem("tm-copyTabUrl", tabxPrefs.getBoolPref("copyTabUrlMenu")); // ---------------- menuseparator ---------------- // // Reload Commands TMP_showItem("context_reloadTab", tabxPrefs.getBoolPref("reloadTabMenu")); TMP_showItem("context_reloadAllTabs", tabxPrefs.getBoolPref("reloadAllMenu")); TMP_showItem("tm-autoreloadTab_menu", tabxPrefs.getBoolPref("autoReloadMenu")); TMP_showItem("tm-reloadRight", tabxPrefs.getBoolPref("reloadRightMenu")); TMP_showItem("tm-reloadLeft", tabxPrefs.getBoolPref("reloadLeftMenu")); TMP_showItem("tm-reloadOther", tabxPrefs.getBoolPref("reloadOtherMenu")); // ---------------- menuseparator ---------------- // TMP_showItem("tm-undoCloseList", tabxPrefs.getBoolPref("undoCloseListMenu") && undoClose); // ---------------- menuseparator ---------------- // // Close tab Commands TMP_showItem("context_closeTab", tabxPrefs.getBoolPref("closeTabMenu")); TMP_showItem("tm-closeAllTabs", tabxPrefs.getBoolPref("closeAllMenu")); TMP_showItem("tm-closeSimilar", tabxPrefs.getBoolPref("closeSimilarTabs")); TMP_showItem("context_closeOtherTabs", tabxPrefs.getBoolPref("closeOtherMenu")); TMP_showItem("tm-closeLeftTabs", tabxPrefs.getBoolPref("closeLeftMenu")); TMP_showItem("tm-closeRightTabs", tabxPrefs.getBoolPref("closeRightMenu")); // ---------------- menuseparator ---------------- // TMP_showItem("tm-docShell", tabxPrefs.getBoolPref("docShellMenu")); TMP_showItem("tm-freezeTab", tabxPrefs.getBoolPref("freezeTabMenu")); TMP_showItem("tm-protectTab", tabxPrefs.getBoolPref("protectTabMenu")); TMP_showItem("tm-lockTab", tabxPrefs.getBoolPref("lockTabMenu")); // ---------------- menuseparator ---------------- // TMP_showItem("context_bookmarkTab", tabxPrefs.getBoolPref("bookmarkTabMenu")); TMP_showItem("context_bookmarkAllTabs", tabxPrefs.getBoolPref("bookmarkTabsMenu")); // we call this again by popupshown to make sure we don't show 2 menuseparator together TMP_tabContextMenuShown(event); if (showRenameTabMenu) { // disabled rename if the title not ready yet var titleNotReady; if (aTab.hasAttribute("busy")) { var browser = gBrowser.getBrowserForTab(aTab); var url = browser.contentDocument.baseURI || browser.currentURI.spec; var docTitle = getTitleFromBookmark(url, browser.contentDocument.title); if (!docTitle || docTitle == gBrowser.mStringBundle.getString("tabs.untitled")) titleNotReady = true; } TMP_setItem("tm-renameTab", "disabled", titleNotReady); } var protectedTab = aTab.hasAttribute("protected"); var keepLastTab = tabxPrefs.getBoolPref("keepLastTab"); var lockedTab = aTab.hasAttribute("locked"); var tabsCount = gBrowser.mTabContainer.childNodes.length; var tabBarCollapsed = tabsCount == 1 && gPref.getBoolPref("browser.tabs.autoHide"); TMP_setItem("context_closeTab", "disabled", protectedTab || keepLastTab || tabBarCollapsed); TMP_setItem("tm-closeAllTabs", "disabled", tabsCount == 1 && (keepLastTab || tabBarCollapsed)); TMP_setItem("context_closeOtherTabs", "disabled", tabsCount == 1); var closeTabsEmpty = gBrowser.closedTabs.length < 1; TMP_setItem("context_undoCloseTab", "disabled", closeTabsEmpty); TMP_setItem("tm-undoCloseList", "disabled", closeTabsEmpty); TMP_setItem("tm-mergeWindowsTab", "disabled", isOneWindow); TMP_setItem("tm-closeRightTabs", "disabled", cIndex == tabsCount - 1); TMP_setItem("tm-closeLeftTabs", "disabled", cIndex == 0); TMP_setItem("tm-reloadRight", "disabled", cIndex == tabsCount - 1); TMP_setItem("tm-reloadLeft", "disabled", cIndex == 0); TMP_setItem("tm-reloadOther", "disabled", tabsCount == 1); TMP_setItem("tm-docShell", "disabled", clickOutTabs); var freezeTabMenu = document.getElementById("tm-freezeTab"); if ( !freezeTabMenu.hidden ) TMP_setItem(freezeTabMenu, "checked", lockedTab && protectedTab); var lockTabMenu = document.getElementById("tm-lockTab"); if ( !lockTabMenu.hidden ) TMP_setItem(lockTabMenu, "checked", lockedTab); var protectTabMenu = document.getElementById("tm-protectTab"); if ( !protectTabMenu.hidden ) TMP_setItem(protectTabMenu, "checked", protectedTab); onAutoReloadPopup(false, aTab); return true; } // don't show 2 menuseparator together // this function is call by "popupshown" event // this is only to the case that other extensions popupshowing run after our Tm_checkTabClick function TMP_tabContextMenuShown(event) { var tabContextMenu = window.gBrowser.mStrip.firstChild.nextSibling; if (event.originalTarget != tabContextMenu) return; // don't show 2 menuseparator together var hideNextSeparator = true, lastVisible, hideMenu = true; for(var mi = tabContextMenu.firstChild; mi; mi = mi.nextSibling) { if (mi.localName == "menuseparator") { mi.hidden = hideNextSeparator; if (!hideNextSeparator) { hideNextSeparator = true; lastVisible = mi; } } else if(!mi.hidden && !mi.collapsed) { hideNextSeparator = false; hideMenu = false; } } // hide the last visible menuseparator if it is the last visible in the menu if (hideNextSeparator && lastVisible) lastVisible.hidden = true; // if all the menu are hidden don't show the popup if (hideMenu) tabContextMenu.hidePopup(); } function TM_checkContentMenu () { try { var showFreezeTab = gPref.getBoolPref("extensions.tabmix.freezeTabContent"); var showLockTab = gPref.getBoolPref("extensions.tabmix.lockTabContent"); var showProtectTab = gPref.getBoolPref("extensions.tabmix.protectTabContent"); var showTabsList = gPref.getBoolPref("extensions.tabmix.tabsList"); var showCloseTab = gPref.getBoolPref("extensions.tabmix.closeTabContent"); var showUndoCloseTab = gPref.getBoolPref("extensions.tabmix.undoCloseTabContent"); var showUndoCloseList = gPref.getBoolPref("extensions.tabmix.undoCloseListContent"); var undoClose = gPref.getBoolPref("extensions.tabmix.undoClose"); var showDuplicateTab = gPref.getBoolPref("extensions.tabmix.duplicateTabContent"); var showDuplicateWin = gPref.getBoolPref("extensions.tabmix.duplicateWinContent"); var showDetachTab = gPref.getBoolPref("extensions.tabmix.detachTabContent"); var showLinkWithHist = gPref.getBoolPref("extensions.tabmix.linkWithHistory"); var showMerge = gPref.getBoolPref("extensions.tabmix.mergeWindowContent"); var showOpenHere = gPref.getBoolPref("extensions.tabmix.openLinkHere"); var showInverseLink = gPref.getBoolPref("extensions.tabmix.openInverseLink"); var showAutoReload = gPref.getBoolPref("extensions.tabmix.autoReloadContent"); var bgPref = gPref.getBoolPref("browser.tabs.loadInBackground"); var isOneWindow = numberOfWindows() == 1; } catch(e){} var tabsListMenu = document.getElementById("tm-tabsList"); var closeTabMenu = document.getElementById("tm-content-closetab"); var freezeTabMenu = document.getElementById("tm-content-freezeTab"); var lockTabMenu = document.getElementById("tm-content-lockTab"); var protectTabMenu = document.getElementById("tm-content-protectTab"); var undoCloseTabMenu = document.getElementById("tm-content-undoCloseTab"); var undoCloseListMenu = document.getElementById("tm-content-undoCloseList"); var undoCloseSep = document.getElementById("tm-content-undoCloseSep"); var duplicateTabMenu = document.getElementById("tm-duplicateTabContext"); var duplicateWinMenu = document.getElementById("tm-duplicateinWinContext"); var detachTabMenu = document.getElementById("tm-detachTabContext"); var linkWithHist = document.getElementById("tm-linkWithhistory"); var mergeMenu = document.getElementById("tm-mergeWindows"); var miscSep = document.getElementById("tm-content-miscSep"); var textSep = document.getElementById("tm-content-textSep"); var openHere = document.getElementById("tm-openlinkhere"); var inverseLink = document.getElementById("tm-openinverselink"); var autoReload = document.getElementById("tm-autoreload_menu"); var contentClick = gContextMenu.onTextInput || gContextMenu.onLink || gContextMenu.onImage; var tabsCount = gBrowser.mTabContainer.childNodes.length; var closeTabsEmpty = gBrowser.closedTabs.length < 1; var protectedTab = gBrowser.mCurrentTab.hasAttribute("protected"); var lockedTab = gBrowser.mCurrentTab.hasAttribute("locked"); openHere.hidden = !gContextMenu.onLink || !showOpenHere; inverseLink.hidden = !gContextMenu.onLink || !showInverseLink; if (!inverseLink.hidden){ var focusType = bgPref ? "fg":"bg"; inverseLink.setAttribute("label", inverseLink.getAttribute(focusType+"label")); inverseLink.setAttribute("accesskey", inverseLink.getAttribute(focusType+"accesskey")); } linkWithHist.hidden = !gContextMenu.onLink || !showLinkWithHist; closeTabMenu.hidden = !showCloseTab || contentClick; var keepLastTab = tabxPrefs.getBoolPref("keepLastTab"); var tabBarCollapsed = tabsCount == 1 && gPref.getBoolPref("browser.tabs.autoHide"); closeTabMenu.setAttribute("disabled", protectedTab || keepLastTab || tabBarCollapsed); freezeTabMenu.hidden = !showFreezeTab || contentClick; lockTabMenu.hidden = !showLockTab || contentClick; lockTabMenu.setAttribute("checked", lockedTab); protectTabMenu.hidden = !showProtectTab || contentClick; protectTabMenu.setAttribute("checked", protectedTab); duplicateTabMenu.hidden = !showDuplicateTab || contentClick; detachTabMenu.hidden = !showDetachTab || contentClick || gSingleWindowMode; duplicateWinMenu.hidden = !showDuplicateWin || contentClick || gSingleWindowMode; freezeTabMenu.setAttribute("checked", protectedTab && lockedTab); tabsListMenu.hidden = !showTabsList || contentClick; undoCloseTabMenu.hidden = closeTabsEmpty || !showUndoCloseTab || !undoClose || contentClick; undoCloseListMenu.hidden = closeTabsEmpty || !showUndoCloseList || !undoClose || contentClick; undoCloseSep.hidden = undoCloseTabMenu.hidden && undoCloseListMenu.hidden || gContextMenu.isTextSelected && closeTabMenu.hidden && lockTabMenu.hidden && protectTabMenu.hidden && tabsListMenu.hidden && freezeTabMenu.hidden; mergeMenu.hidden = !showMerge || isOneWindow || contentClick; miscSep.hidden = mergeMenu.hidden && closeTabMenu.hidden && duplicateTabMenu.hidden && duplicateWinMenu.hidden && lockTabMenu.hidden && protectTabMenu.hidden && tabsListMenu.hidden && freezeTabMenu.hidden || gContextMenu.isTextSelected; textSep.hidden = !gContextMenu.isTextSelected || mergeMenu.hidden && duplicateTabMenu.hidden && duplicateWinMenu.hidden && closeTabMenu.hidden && lockTabMenu.hidden && protectTabMenu.hidden && tabsListMenu.hidden && freezeTabMenu.hidden && undoCloseTabMenu.hidden && undoCloseListMenu.hidden; autoReload.hidden = !showAutoReload || contentClick || gContextMenu.isTextSelected; var hideOpenAllLinks = gPref.getBoolPref("extensions.tabmix.openAllLinks") ? openMultipleLinks(true) : true; document.getElementById("tm-openAllLinks").hidden = hideOpenAllLinks; onAutoReloadPopup(true); } function onAutoReloadPopup(currentTab, aTab) { var tab = currentTab ? gBrowser.mCurrentTab : aTab; var id = currentTab ? "tm-autoreload" : "tm-autoreloadTab"; var element = ["1", "2", "3", "4", "5", "6", "7", "8"]; var time = [5, 15, 30, 60, 2*60, 5*60, 15*60, 30*60]; if (tab.autoReloadEnabled == null) gBrowser.setupAutoReload(tab); document.getElementById(id+"_enable").setAttribute("checked", tab.autoReloadEnabled); for(var i=0; i 0) { var range = nsISelectionObject.getRangeAt(0); var treeWalker = window._content.document.createTreeWalker( range.cloneContents(), NodeFilter.SHOW_ELEMENT, myNodeFilter, true); var nextEpisode = treeWalker.nextNode(); var newTab, firstTab, firstUrl; while(nextEpisode != null) { if (nextEpisode.nodeName == "li") nextEpisode = nextEpisode.firstChild; // if(nextEpisode.href && nextEpisode.href.indexOf('http') == 0) { if(nextEpisode.href) { // might change it to only accept certain protocols like it used to if (check) return false; newTab = gBrowser.addTab(nextEpisode.href); if (!firstTab) { firstTab = newTab; firstUrl = nextEpisode.href; gBrowser.TMP_selectNewForegroundTab(firstTab, null, firstUrl); } } nextEpisode = treeWalker.nextNode(); } } return true; } function checkForCtrlClick(aEvent) { var aButton = aEvent.target; if (!aButton.disabled && aEvent.button == 0 && (aEvent.ctrlKey || aEvent.metaKey)) { if (aButton.id == "btn_undoclose") TMP_ClosedTabs.undoCloseTab(); else BrowserCloseTabOrWindow(); aButton.setAttribute("afterctrlclick", true); } } function isAfterCtrlClick(aButton) { if (aButton.getAttribute("afterctrlclick")) { aButton.removeAttribute("afterctrlclick"); if (aButton.hasAttribute("open")) aButton.removeAttribute("open"); return true; } return false; } function createUndoCloseList (popup) { if (isAfterCtrlClick(popup.parentNode)) return false; beforeCommonList(popup); // Grab the list of closed tabs var ctabs = gBrowser.closedTabs; var mi, count; for(var i = ctabs.length - 1; i >= 0; i--) { var tab = ctabs[i]; var tabSH = tab[1]; // Grab the session history for the tab // Grab the title and uri (make the uri friendly text) var title = tab[2]; var uri, _uri = tabSH.getEntryAtIndex(tabSH.index, false).URI; if ( _uri.scheme == "about" && title == "" ) uri = title = "about:blank"; else try { uri = _uri.scheme + ":\/\/" + _uri.hostPort + _uri.path; } catch (e) { uri = title; } var label = title ? title : uri; // Insert a menu item for each closed tab in the cache mi = document.createElement("menuitem"); mi.setAttribute("class", "menuitem-iconic bookmark-item"); mi.setAttribute("statustext", uri) mi.setAttribute("tooltiptext", label); count = (ctabs.length - i) + (ctabs.length - i<10 ? " : " : ": "); mi.setAttribute("label", count + label); if (!uri.match(/^https/)) mi.setAttribute("image", tab[3]); mi.setAttribute("accesskey", "" + (ctabs.length - i)); mi.closeTabIndex = i; if (i == ctabs.length - 1) mi.setAttribute("key", gIsFirefox2 ? "key_undoCloseTab" : "key_tm_undoClose"); popup.appendChild(mi); } var stringBundle = document.getElementById("tmp-string-bundle"); mi = document.createElement("menuseparator"); popup.appendChild(mi); mi = document.createElement("menuitem"); mi.setAttribute("label", stringBundle.getString("undoclosetab.clear.label")); mi.setAttribute("accesskey", stringBundle.getString("undoclosetab.clear.accesskey")); mi.closeTabIndex = -1; popup.appendChild(mi); mi = document.createElement("menuitem"); mi.setAttribute("label", stringBundle.getString("restoreall.label")); mi.setAttribute("accesskey", stringBundle.getString("restoreall.accesskey")); mi.closeTabIndex = -2; popup.appendChild(mi); return true; } function removeCloseTab (event, popup) { if (!tabxPrefs.getBoolPref("middleclickDelete")) return; var index = event.originalTarget.closeTabIndex if (event.button == 1 && index > -1 ){ getClosedTab('delete', index); if (gBrowser.closedTabs.length > 0) createUndoCloseList(popup); else { popup.hidePopup(); if (popup.parentNode.id != "btn_undoclose") popup.parentNode.parentNode.hidePopup(); } } } // sometimes context popup stay "open", we hide it manually. function TM_hidePopup () { var node = document.popupNode; while (node && node.localName != "menubar" && node.localName != "toolbar") { if (node.localName == "menupopup" || node.localName == "popup") { if (node.hasAttribute("open")) node.removeAttribute("open"); node.hidePopup(); } node = node.parentNode; } } // return the indexd tab from the list and remove the tab from the list function getClosedTab(where, index) { var ctabs = gBrowser.closedTabs; var aTab = null; var updateRDF = SessionManager.enableBackup && SessionPref.getBoolPref("save.closedtabs"); if(index >= 0) { TMP_SessionStore.removeClosedTab(ctabs.length - 1 - index); aTab = ctabs.splice(index, 1)[0]; var ord=-1; switch (where) { // xxx need more work on this. when tab added and removed case "current": ord = gBrowser.mCurrentTab._tPos; break; case "tab": if (gPref.getBoolPref("extensions.tabmix.openTabNext")) ord = gBrowser.mCurrentTab._tPos+1; else ord = gBrowser.mTabs.length; break; case "original": ord = aTab[0]; break; default: } // don't change position on delete if (ord > -1 && where != "delete") { for (var i = index; i < ctabs.length; i++){ if (ctabs[i][0] >= ord) ctabs[i][0]++; } if (updateRDF) SessionManager.fixClosedtabTabPos(ord); } } else { if (index == -2) gBrowser.delayUndoRemoveAllTab(); else if (index == -1) { while(ctabs.length > 0) ctabs.pop(); TMP_SessionStore.removeClosedTab(); if (updateRDF) SessionManager.deleteWinClosedtabs(gSessionPath[0] + "/" + gBrowser.windowID); } } if (ctabs.length < 1) TMP_ClosedTabs.setButtonDisableState(true); if (aTab != null && updateRDF) SessionManager.deleteClosedtabAt(index+1); return aTab; } function _restoreTab(where, index) { // call restoreTab after delay to let the popup menu time to hide window.setTimeout( function () { delayRestoreTab(where, index); }, 0 ); } // restore the tab function delayRestoreTab(where, index) { var ord, aTab = getClosedTab(where, index); if (!aTab) return; switch (where) { case "current": var cTab = gBrowser.mCurrentTab; ord = cTab._tPos; cTab.collapsed = true; var restoredTab = gBrowser.restoreTab(ord, aTab[1], aTab[4], aTab[5]); if (restoredTab != cTab) gBrowser.removeTab(cTab); else cTab.collapsed = false; break; case "window": var newWindow = window.openDialog( getBrowserURL(), "_blank", "chrome,all,dialog=no"); newWindow.duplicat = true; newWindow.duplicatData = { scroll: aTab[5], oldHistory: aTab[1], prop: aTab[4] } break; case "tab": if (gPref.getBoolPref("extensions.tabmix.openTabNext")) ord = gBrowser.mCurrentTab._tPos+1; else ord = gBrowser.mTabs.length; gBrowser.restoreTab(ord, aTab[1], aTab[4], aTab[5]); break; case "original": gBrowser.restoreTab(aTab[0], aTab[1], aTab[4], aTab[5]); } } function NW_waitForSessionHistory(event) { //try to set zoom factor befor we load content setTextZoom(getBrowser().selectedBrowser, window.duplicatData.scroll.split(",")[2]) waitForSessionHistory(20); } // wait For sessionHistory in new window function waitForSessionHistory(attempts) { var webNav = gBrowser.webNavigation; try{ webNav.sessionHistory; } // Test if sessionHistory exists yet catch (err) { // webNav.sessionHistory is not yet available, try again later if (attempts) window.setTimeout('waitForSessionHistory(' + --attempts + ')', 50); return; } if ((webNav.sessionHistory == null) && attempts){ window.setTimeout('waitForSessionHistory(' + --attempts + ')', 50); return; } gBrowser.restoreTab(gBrowser.selectedTab._tPos, window.duplicatData.oldHistory, window.duplicatData.prop, window.duplicatData.scroll); delete window.duplicatData; if (window.opener && window.opener.needToClose) setTimeout(function() {window.opener.TMP_BrowserCloseWindow();}, 0); } function closeTabAddBookmarks(currentIndex) { var tabData = gBrowser.closedTabs[currentIndex]; // tabData[1] - history tabData[2] - title var url = tabData[1].getEntryAtIndex(tabData[1].index, false).URI.spec; var title = getTitleFromBookmark(url, tabData[2]); if (gIsPlaces) PlacesCommandHook.bookmarkLink(PlacesUtils.bookmarksMenuFolderId, url, title); else BookmarksUtils.addBookmark(url, title, undefined); } function closeTabcopyTabUrl(currentIndex) { var tab = gBrowser.closedTabs[currentIndex]; var tabSH = tab[1]; // history var URL = tabSH.getEntryAtIndex(tabSH.index, false).URI.spec; var clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"] .getService(Components.interfaces.nsIClipboardHelper); clipboard.copyString(URL); } function removeTabFromList (event, popup, aType) { if (!tabxPrefs.getBoolPref("middleclickDelete")) return; if (event.target.id == "btn_tabslistSorted") return; if (event.button == 1) { var aTab = event.originalTarget.tab; if (popup.parentNode.id == "tm-tabsList" && (gBrowser.mCurrentTab == aTab || gBrowser.isBlankTab(gBrowser.mCurrentTab))) { popup.hidePopup(); gBrowser.removeTab(aTab); return; } gBrowser.removeTab(aTab); if (gBrowser.mTabs.length > 0) { createTabsList(popup, aType); var item = popup.parentNode.parentNode; if (item.parentNode.id == "btn_tabslist") createTabsList(item, aType); } else popup.hidePopup(); } } // called from tabmix.xml tabs scroll buttons function _createTabsList (event, side) { event.stopPropagation(); var tablist = document.getElementById("tabslist"); beforeCommonList(tablist); createCommonList(tablist, 2, side); if (tablist.hasChildNodes()) tablist.showPopup(event.target, -1, -1, "popup", "bottomleft","topleft"); } // show sort/unsort tabs list popup after click on sorted tab menu function showTabsListPopup (event) { event.stopPropagation(); setTimeout( function (popup){ popup.showPopup(popup.parentNode, -1, -1, "popup", "bottomleft", "topleft"); }, 0, event.target.parentNode); } function createTabsList (popup, aType) { if (isAfterCtrlClick(popup.parentNode)) return false; // the context menu isn't visible if the strip is collapsed // uncollapsed the stip and collapsed the tabbar instead if (popup.id == "btn_tabslist_menu" && gBrowser.mStrip.collapsed) { var visibility = gBrowser.mTabContainer.collapsed; popup.setAttribute("tabBar_collapsed", visibility); if (!visibility) gBrowser.mTabContainer.collapsed = true; gBrowser.mStrip.collapsed = false; } var tabContextMenu = gBrowser.mStrip.firstChild.nextSibling; if (popup.hasAttribute("contextmenu") && popup.getAttribute("contextmenu") != tabContextMenu.id) popup.setAttribute("contextmenu", tabContextMenu.id); if (gPref.getBoolPref("extensions.tabmix.enableScrollSwitch")) popup.addEventListener("DOMMouseScroll", TMP_tabsListScroll, true); beforeCommonList(popup); createCommonList(popup, aType); return true; } function beforeCommonList(popup) { var item = popup.parentNode; if (item.id == "btn_tabslist" || item.id == "btn_undoclose") item.removeAttribute("tooltiptext"); // clear out the menu popup if we show the popup after middle click while (popup.hasChildNodes()) { var menuItem = popup.firstChild; if (menuItem.id.indexOf("btn_tabslist") != -1) break; popup.removeChild(menuItem); } popup.addEventListener("DOMMenuItemActive", updateMenuItemActive, false); popup.addEventListener("DOMMenuItemInactive", updateMenuItemInactive, false); } function createCommonList (popup, aType, side) { var tabs = new Array(gBrowser.mTabs.length); var i; switch(aType) { case 1: for (i = 0; i < gBrowser.mTabs.length; i++) tabs[i] = new tabSorting(gBrowser.mTabs[i], i); tabs = tabs.sort(); for (i = 0; i < tabs.length; i++) createMenuItems(popup, tabs[i].Tab, tabs[i].Index, aType); break; case 2: for (i = 0; i < gBrowser.mTabs.length; i++) { if (side && side == "left" && !gBrowser.mTabs[i].collapsed) continue; else if (side && side == "right" && (gBrowser.mTabs[i].collapsed || gBrowser.mTabContainer.isTabVisible(gBrowser.mTabs[i]._tPos))) continue; createMenuItems(popup, gBrowser.mTabs[i], i, aType); } break; case 3: for (i = TMP_LastTab.TabHistory.length - 1; i >= 0; i--) createMenuItems(popup, TMP_LastTab.TabHistory[i], i, aType); break; } } function createMenuItems(popup, tab, value, aType) { var count, mi = document.createElement("menuitem"); mi.setAttribute("class", "menuitem-iconic bookmark-item alltabs-item"); mi.setAttribute("statustext", gBrowser.getBrowserForTab(tab).currentURI.spec); mi.setAttribute("tooltiptext", tab.label); count = aType != 3 ? (value + 1) + (value < 9 ? " : " : ": ") : ""; mi.setAttribute("count", count); mi.setAttribute("label", count + tab.label); mi.setAttribute("crop", tab.getAttribute("crop")); mi.setAttribute("image", tab.getAttribute("image")); if (tab.hasAttribute("busy")) mi.setAttribute("busy", tab.getAttribute("busy")); if (tab.selected) mi.setAttribute("selected", "true"); mi.value = value; tab.mCorrespondingMenuitem = mi; tab.addEventListener("DOMAttrModified", TMP_tabOnAttrModified, false); tab.addEventListener("TabClose", TMP_tabOnTabClose, false); mi.tab = tab; if (popup.id == "btn_tabslist_menu") popup.insertBefore(mi, document.getElementById("btn_tabslist_sep")); else popup.appendChild(mi); } function TMP_tabsListScroll(aEvent) { TMtabBarScroll(aEvent); } function TMP_tabOnAttrModified(aEvent) { var menuItem = aEvent.target.mCorrespondingMenuitem; if (menuItem) { var attrName = aEvent.attrName; var count = ""; switch (attrName) { case "label": count = menuItem.getAttribute("count"); case "crop": case "busy": case "image": case "selected": if (aEvent.attrChange == aEvent.REMOVAL) menuItem.removeAttribute(attrName); else menuItem.setAttribute(attrName, count + aEvent.newValue); } } } function TMP_tabOnTabClose(aEvent) { var menuItem = aEvent.target.mCorrespondingMenuitem; if (menuItem && menuItem.parentNode) menuItem.parentNode.removeChild(menuItem); } function TMP_TabsListOncommand(event) { TMP_tabSelectedFromList(event.originalTarget.tab); } function TMP_tabSelectedFromList(aTab) { if (gBrowser.selectedTab == aTab) gBrowser.mTabContainer.ensureTabIsVisible(gBrowser.mTabContainer.selectedIndex); else // if we select another tab _handleTabSelect will call ensureTabIsVisible gBrowser.selectedTab = aTab; } var gBackupLabel = ""; function hideCommonList(popup) { // restore the strip collapsed status if (popup.id == "btn_tabslist_menu" && popup.hasAttribute("tabBar_collapsed")) { gBrowser.mStrip.collapsed = true; var visibility = gBrowser.mTabContainer.collapsed; if (popup.getAttribute("tabBar_collapsed") == "false") gBrowser.mTabContainer.collapsed = false; popup.removeAttribute("tabBar_collapsed"); } // clear out the menu popup and remove the listeners while (popup.hasChildNodes()) { var menuItem = popup.firstChild; if (menuItem.id.indexOf("btn_tabslist") != -1) break; if ("tab" in menuItem) { menuItem.tab.removeEventListener("DOMAttrModified", TMP_tabOnAttrModified, false); menuItem.tab.removeEventListener("TabClose", TMP_tabOnTabClose, false); menuItem.tab.mCorrespondingMenuitem = null; } popup.removeChild(menuItem); } var item = popup.parentNode; if (item.id == "btn_tabslist" || item.id == "btn_undoclose") item.setAttribute('tooltiptext', item.getAttribute('_tooltiptext')); popup.removeEventListener("DOMMenuItemActive", updateMenuItemActive, false); popup.removeEventListener("DOMMenuItemInactive", updateMenuItemInactive, false); popup.removeEventListener("DOMMouseScroll", TMP_tabsListScroll, true); gBackupLabel = ""; } function updateMenuItemActive(event, tab) { var statusTextFld = document.getElementById("statusbar-display"); if (gBackupLabel=="") gBackupLabel = statusTextFld.label; if (!tab) tab = event.target; updateStatusText(tab.getAttribute("statustext")); } function updateMenuItemInactive(event) { updateStatusText(""); } function updateStatusText(itemText) { var statusTextFld = document.getElementById("statusbar-display"); var newText = itemText ? itemText : gBackupLabel; if (newText != statusTextFld.label) statusTextFld.label = newText; } function tabSorting(tab, index) { this.Tab = tab; this.Index = index; } tabSorting.prototype.toString = function() { return this.Tab.label.toLowerCase(); } PK 3+w00 content/tabmixplus/contents.rdf chrome://tabmixplus/content/pref/preferencesOverlay.xul chrome://tabmixplus/content/tabmix.xul chrome://tabmixplus/content/links/links.xul chrome://tabmixplus/content/bookmarks/bookmarks.xul chrome://tabmixplus/content/bookmarks/bookmarksManager.xul chrome://tabmixplus/content/links/links.xul chrome://tabmixplus/content/links/links.xul chrome://tabmixplus/content/history/history-panel.xul PK 8content/tabmixplus/extensions/PK 6O%content/tabmixplus/extensions/sage.js// prevent Sage from load pages in locked tabs // code by onemen const OPEN_TAB_FOR_SAGE = "extensions.tabmix.opentabfor.sage"; var TMP_Sage = { init: function () { eval("updateItemContextMenu ="+updateItemContextMenu.toString().replace( 'readStateController.onCommandUpdate();', '$& TMP_Sage.buildContextMenu();' )); eval("bookmarksTreeClick ="+bookmarksTreeClick.toString().replace( 'const BOOKMARK_SEPARATOR', 'var where = TMP_Places.fixWhereToOpen(aEvent, CreateHTML._tabbed ? "tab" : "current", TMP_Sage.openTabPref); \ CreateHTML.tabbed = where == "tab"; \ $&' )); eval("bookmarksOpen ="+bookmarksOpen.toString().replace( 'getContentBrowser().loadURI(lastResource.url);', 'if (CreateHTML._tabbed) getContentBrowser().addTab(lastResource.url); \ else $&' )); eval("openURI ="+openURI.toString().replace( 'switch (windowType)', 'windowType = TMP_Places.fixWhereToOpen((oType instanceof Event)? oType : null, !windowType ? "current" : windowType, TMP_Sage.openTabPref); \ $&' )); if (typeof(PlacesController) != "function") TMP_Bookmark.init(); window.removeEventListener('load', function () { TMP_Sage.init(); }, false); }, buildContextMenu: function () { var _open = document.getElementById("rssOpenItem"); var _openInWindow = document.getElementById("rssOpenNewWindowItem"); var _openInTab = document.getElementById("rssOpenNewTabItem"); TMP_updateContextMenu(_open, _openInWindow, _openInTab, this.openTabPref); }, get openTabPref() { var prefSVC = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefBranch); if (prefSVC.prefHasUserValue(OPEN_TAB_FOR_SAGE)) return OPEN_TAB_FOR_SAGE; else return prefStringTMBookmark; } }PK p6@y&content/tabmixplus/extensions/sage.xul PK [8 (content/tabmixplus/extensions/wizzrss.js// code by onemen // Look for RSS/Atom News Reader function TMP_LookForRSS() { if ("gotoLink" in window) TMP_wizzrss.init(); if ("openNewsfox" in window) TMP_Newsfox.init(); if ("RSSTICKER" in window) TMP_RSSTICKER.init(); } var TMP_RSSTICKER = { init : function () { eval("RSSTICKER.writeFeed ="+RSSTICKER.writeFeed.toString().replace( 'tbb.setAttribute("onclick"', 'tbb.setAttribute("onclick", "this.onClick(event);");\ tbb.setAttribute("_onclick"' ).replace( 'tbb.onContextOpen =', 'tbb.onContextOpen = TMP_RSSTICKER.onContextOpen; \ tbb.onClick = TMP_RSSTICKER.onClick; \ tbb._onContextOpen =' )); }, onClick : function (event) { if (event.ctrlKey) { this.markAsRead(true); } else if ((this.parent.alwaysOpenInNewTab && (event.which == 1)) || (event.which == 2)) { this.onContextOpen("tab"); } else if (event.which == 1) { this.onContextOpen(); } }, onContextOpen : function (target) { if (!target) { if (TMP_whereToOpen(null).lock) this.parent.browser.openInNewTab(this.href); else window._content.document.location.href = this.href; } else if (target == "window") { if (gSingleWindowMode) this.parent.browser.openInNewTab(this.href); else window.open(this.href); } else if (target == "tab") { this.parent.browser.openInNewTab(this.href); } this.markAsRead(); } } // prevent Wizz RSS from load pages in locked tabs var TMP_wizzrss = { init : function () { var codeToReplace = /getContentBrowser\(\).loadURI|contentBrowser.loadURI/; const newCode = "TMP_wizzrss.openURI"; var _functions = ["addFeedbase","validate","gohome","tryagain","promptStuff","promptStuff", "doSearch","viewLog","renderItem","playEnc","renderAllEnc","playAllEnc", "gotoLink","gotoLink","itemLinkClick","itemLinkClick","itemListClick"]; _functions.forEach( function(_function) { if (_function in window) eval("window." + _function + " ="+ window[_function].toString() .replace(codeToReplace,newCode)); } ); }, openURI : function (uri) { var w = Components.classes['@mozilla.org/appshell/window-mediator;1'] .getService(Components.interfaces.nsIWindowMediator) .getMostRecentWindow("navigator:browser"); var tabBrowser = w.getBrowser(); var openNewTab = w.TMP_whereToOpen(true).lock; if (openNewTab) { var newTab = tabBrowser.addTab(uri); var theBGPref = !readPref("WizzRSSFocusTab", false, 2); tabBrowser.TMP_selectNewForegroundTab(newTab, theBGPref); } else tabBrowser.loadURI(uri); } } // prevent Newsfox from load pages in locked tabs var TMP_Newsfox = { init : function () { eval("openNewsfox ="+openNewsfox.toString().replace( 'if (newTab) {', 'newTab = newTab || TMP_whereToOpen(null).lock; \ $&' )); } } PK d6PΎ)content/tabmixplus/extensions/wizzrss.xul PK 8content/tabmixplus/flst/PK a{p8oUzrzrcontent/tabmixplus/flst/flst.js//////////////////////////////////////// // flst.js // Daniel Lindkvist, 04-08-09 // modified by logixoul, 2005-04-18 , modified again by onemen //////////////////////////////////////// var flst = { slideshow: null, //for slideshow showAlert: function(msg) { try { var alerts = Components.classes["@mozilla.org/alerts-service;1"] .getService(Components.interfaces.nsIAlertsService); alerts.showAlertNotification("chrome://tabmixplus/skin/tmp.png", "Tab Mix Plus", msg, false, "", null); } catch (e) { var statusTextFld = document.getElementById("statusbar-display"); statusTextFld.label = msg; setTimeout(function() { statusTextFld.removeAttribute("label"); }, 2500); } }, //toggle flst on/off toggle: function(event) { var msg; var setting = TMP_getIntPref(tabxBranch, "focusTab", 2) var stringBundle = document.getElementById("tmp-string-bundle"); if ( setting != 4 ) { gPref.setIntPref("extensions.tabmix.focusTab",4); msg = stringBundle.getString("flstOn.label"); } else { gPref.setIntPref("extensions.tabmix.focusTab",2); msg = stringBundle.getString("flstOff.label"); } this.showAlert(msg); }, //for slideshow toggleSlideshow: function() { var stringBundle = document.getElementById("tmp-string-bundle"); if(this.slideshow != null) { window.clearInterval(this.slideshow); this.slideshow = null; this.showAlert(stringBundle.getString("slideshowOff.label")); return; } if (gBrowser.mTabContainer.childNodes.length < 2) return; var time = 4; try { time = gPref.getIntPref("extensions.tabmix.slideDelay"); } catch(e){ } time = time * 1000; // to get seconds this.slideshow = window.setInterval(this.focusNext, time); this.showAlert(stringBundle.getString("slideshowOn.label")); }, focusNext: function() { var tabs = gBrowser.mTabContainer.childNodes; if (tabs.length == 1) return; var index = gBrowser.mTabContainer.selectedIndex + 1; if (index == tabs.length) index = 0; gBrowser.selectedTab = tabs[index]; } } /*//////////////////////////////////////////////////////////////////// // The Original Code is the Merge Window function of "Duplicate Tab"// // extension for Mozilla Firefox.// // version 0.5.1// // The Initial Developer of the Original Code is Twanno. // // Modfied for TMP by CPU// *///////////////////////////////////////////////////////////////////// var dtMergeWindows = { // merge several windows to one window, or only selected tabs to previous focussed window, // or only current window with previous window mergeWindows: function() { var mergePopups = gPref.getBoolPref("extensions.tabmix.mergePopups"); var placePopupNextToOpener = gPref.getBoolPref("extensions.tabmix.placePopupNextToOpener"); var mergeAllWindows = gPref.getBoolPref("extensions.tabmix.mergeAllWindows"); var openTabNext = gPref.getBoolPref("extensions.tabmix.openTabNext"); var stringBundle = document.getElementById("tmp-string-bundle"); // other variables used in this function var currentIndex, tabs, browsers = new Array(), i, j; // get browser windows listed and add them to an array var windowsArrayList = dtMergeWindows.listWindows(); var windowsArray = windowsArrayList.windowsArray; var popupsArray = windowsArrayList.popupsArray; var currentWindowIsPopup = windowsArrayList.isCurrentWindowPopup; // force the merging of windows when the current window is a popup // and the popup would be merged with one other (non popup) window var forceMergeWindows = (currentWindowIsPopup && (windowsArray.length == 1 || !mergeAllWindows)); // foreground window is not a popup other window(s) is/are popup(s) var mergeBackGround = (windowsArray.length == 0 && popupsArray.length > 0 && !currentWindowIsPopup && mergePopups); // alert if just one window is open; no need to merge one window if (!forceMergeWindows && ((!mergePopups && windowsArray.length < 1 && !currentWindowIsPopup) || windowsArray.length+popupsArray.length < 1)) { var errorMessage = stringBundle.getString('tmp.merge.error'); const errorimage = "chrome://tabmixplus/skin/tmpsmall.png"; var browser = getBrowser().selectedBrowser; if (getBrowser().showMessage) { getBrowser().showMessage(browser, errorimage, errorMessage, '', null, null, null, "top", true); } else if (getBrowser().getNotificationBox) { var notificationBox = getBrowser().getNotificationBox(browser); if (!notificationBox.getNotificationWithValue("mergeWindows")) { const priority = notificationBox.PRIORITY_INFO_MEDIUM; notificationBox.appendNotification(errorMessage, "mergeWindows", errorimage, priority, null); } } else window.alert(errorMessage); return; } // check if one or more tabs are selected to be merged var selectedTabs = getBrowser().mTabContainer.getElementsByAttribute('mergeselected','true'); var tabsSelected = (selectedTabs.length > 0); // don't merge the current window if it is a popup and all windows are to be merged except popups var dontMergeCurrentWindow = (!forceMergeWindows && !mergePopups && currentWindowIsPopup && mergeAllWindows); // get currently focussed and previously focussed window // and get the window which has been out of focus longest var currentWindow = (dontMergeCurrentWindow)?windowsArray[windowsArray.length-1]:windowsArrayList.currentWindow; var previousWindow = (dontMergeCurrentWindow)?windowsArray[windowsArray.length-2]:windowsArray[windowsArray.length-1]; var firstWindow = windowsArray[0]; if (mergeBackGround) { // to correctly merge popup(s) when only the current window is not a popup currentWindow = popupsArray.pop(); firstWindow = windowsArrayList.currentWindow; previousWindow = windowsArrayList.currentWindow; currentWindowIsPopup = true; windowsArray[0] = windowsArrayList.currentWindow; } var previousWindowTabBar = previousWindow.getBrowser().mTabContainer; var firstWindowTabBar = firstWindow.getBrowser().mTabContainer; var previousWindowTabIndex = (openTabNext)?previousWindowTabBar.selectedIndex:previousWindowTabBar.childNodes.length; var firstWindowTabIndex = (openTabNext)?firstWindowTabBar.selectedIndex:firstWindowTabBar.childNodes.length; // get currently focussed tab, so it can be selected again after merging if (tabsSelected && !gBrowser.mCurrentTab.hasAttribute('mergeselected')) { i = 0, j = -1; while (i < gBrowser.mTabContainer.childNodes.length) { if (gBrowser.mTabContainer.childNodes[i].hasAttribute('mergeselected')) j++; if ((i >= gBrowser.mTabContainer.selectedIndex) && (j > -1)) { currentIndex = j; break; } i++; } } else currentIndex = (tabsSelected)?gBrowser.mTabContainer.selectedIndex:currentWindow.getBrowser().mTabContainer.selectedIndex; // If more then one window is opened and not all windows must be merged to one: // Either because of selected tabs or the pref is set to do so // Merge only the (selected) tabs of the currently focussed window and the previously focussed window if (tabsSelected || !mergeAllWindows) { var openerPosition = -1; tabs = currentWindow.getBrowser().mTabContainer.childNodes; // if tabs have been selected, list them in an array if (tabsSelected && !mergeBackGround) browsers = listTabs(selectedTabs, window); else if (tabsSelected && mergeBackGround) { var previousTabs = previousWindow.getBrowser().mTabContainer.childNodes; browsers = listTabs(tabs, currentWindow); for (i = 0; i < previousTabs.length; i++) { if (!previousTabs[i].hasAttribute('mergeselected')) previousTabs[i].setAttribute('mergeremove', 'true'); } } // if no tabs have been selected, list all tabs of the window in an array else if (!tabsSelected) { browsers = listTabs(tabs, currentWindow); } // if the current window is a popup window place the popup next to its opener // when that opener is found in the previous window. if (currentWindowIsPopup && placePopupNextToOpener) { var openerPositionArray = getPopupOpenerPosition(currentWindow, [previousWindow], previousWindowTabIndex); openerPosition = openerPositionArray[0]; if (openerPositionArray[1] == 'tabs') { currentIndex = (mergeBackGround)? currentIndex: openerPosition + currentIndex; // the popup opener was found in one of the tabs in the window that will remain. // place the tab(s) next to the opener setTabsInBrowser(previousWindow, browsers, openerPosition); } } // place all tabs in one window if (openerPosition == -1) { currentIndex = previousWindowTabIndex + currentIndex; setTabsInBrowser(previousWindow, browsers); } // prompt a warning if some tabs are selected and the window with remaining tabs is closed var promptpref = gPref.getBoolPref("extensions.tabmix.warnOnclose"); var closepref = gPref.getBoolPref("extensions.tabmix.closeOnSelect"); var askForPrompt = ((promptpref) && (tabsSelected) && (selectedTabs.length < tabs.length)); var promptOK = false, promptAgain = { value:true }; if (askForPrompt && closepref) { var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService); var promptTitle = stringBundle.getString('tmp.merge.warning.title'); var promptMessage = stringBundle.getString('tmp.merge.warning.message'); var promptCheckboxLabel = stringBundle.getString('tmp.merge.warning.checkboxLabel'); promptOK = promptService.confirmCheck(window, promptTitle, promptMessage, promptCheckboxLabel, promptAgain); } // select the tab which was selected in the top window previousWindowTabBar.selectedIndex = currentIndex; // close current window if all tabs are merged or if specified by user to do so with some tabs selected if ((promptOK || (!askForPrompt)) && closepref) { if (!promptAgain.value) { gPref.setBoolPref("exetnsions.tabmix.warnOnClose", false); } previousWindow.focus(); currentWindow.close(); } // If the window is not to be closed, remove the tabs that have been merged // if tab is protect remove mergeselected attribute else { // xxx if we close in one loop we get //Error: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMXULElement.boxObject] // Source file: chrome://global/content/bindings/browser.xml // we need to fix the flst select after remove and made the proper new tab index in gBrowser.removeTab //in the first loop we remove all the tab but the current tab //in the 2nd loop we remove the current tab for (i = selectedTabs.length - 1; i > -1; --i) { var tab = selectedTabs.item(i); if (tab.hasAttribute("protected")) { tab.removeAttribute("mergeselected"); tab.label = tab.label.substr(4); } else if (tab != currentWindow.getBrowser().mCurrentTab) currentWindow.getBrowser().removeTab(tab); } for (i = selectedTabs.length - 1; i > -1; --i) { tab = selectedTabs.item(i); currentWindow.getBrowser().removeTab(tab); } previousWindow.focus(); } if (mergeBackGround && tabsSelected) { // because the other windows are added to the window with selected tabs, the not selected tabs // have to be removed. (normally the selected tabs will be removed and placed in another window) for (i = 0; i < selectedTabs.length; i++) { selectedTabs.item(i).label = selectedTabs.item(i).label.substr(4); } for (i = 0; i < previousTabs.length; i++) { if (previousTabs[i].hasAttribute('mergeremove')) { if (i < currentIndex) currentIndex--; previousWindow.getBrowser().removeTab(previousTabs[i]); } if (previousTabs[i].hasAttribute('mergeselected')) previousTabs[i].removeAttribute('mergeselected'); previousTabs[i].label = previousTabs[i].label.substr(4); } } previousWindowTabBar.selectedIndex = currentIndex; } // Merge all windows to one window if more then one window is opened and // no tabs are selected and the pref is set to merge all windows. else if (!tabsSelected && mergeAllWindows) { // list all tabs on all windows with history scrollposition var addedTabsLength = 0, popupsList = new Array(); for (i = 1; i < windowsArray.length; i++) { tabs = windowsArray[i].getBrowser().mTabContainer.childNodes; browsers = browsers.concat(listTabs(tabs, windowsArray[i])); // the last window in the array is only the current window if merging of popups is disabled // and the current window is a popup window if (windowsArray[i] != currentWindow) addedTabsLength += tabs.length; } // the current window is a popup and popups should also be merged // or the current window is not a popup if (!dontMergeCurrentWindow) { tabs = currentWindow.getBrowser().mTabContainer.childNodes; if (!currentWindowIsPopup) { browsers = browsers.concat(listTabs(tabs, currentWindow)); currentIndex = firstWindowTabIndex + addedTabsLength + currentIndex; } else { var listedTabs = listTabs(tabs, currentWindow); if (placePopupNextToOpener) { openerPositionArray = getPopupOpenerPosition(currentWindow, windowsArray, firstWindowTabIndex); openerPosition = openerPositionArray[0]; switch (openerPositionArray[1]) { case 'browsers': // the popup opener was found in the list of browsers that will be added to the remaining window. currentIndex = openerPosition + 1 + currentIndex; popupsList[openerPosition] = listedTabs; currentIndexSet = true; break; case 'tabs': // the popup opener was found in one of the tabs in the window that will remain. setTabsInBrowser(firstWindow, listedTabs, openerPosition); // in this case current index is fixed because the to be focused tab // has now already been added to the remaining window currentIndex = openerPosition + 1 + currentIndex; break; case 'end': default: // no popup opener was found, the popup will be added at the end of the tab list. browsers = browsers.concat(listedTabs); currentIndex = firstWindowTabIndex + addedTabsLength + currentIndex; break; } } else { browsers = browsers.concat(listedTabs); currentIndex = firstWindowTabIndex + addedTabsLength + currentIndex; } } } else // the current window is a popup and should not be merged. currentIndex = firstWindowTabIndex + addedTabsLength + currentIndex; // add popup windows to the remaining window when popup windows should also be merged. if (mergePopups) { for (i = 0; i < popupsArray.length; i++) { tabs = popupsArray[i].getBrowser().mTabContainer.childNodes; if (placePopupNextToOpener) { listedTabs = listTabs(tabs, popupsArray[i]); var newWindowsArray = windowsArray; if (!currentWindowIsPopup && !mergeBackGround) newWindowsArray.push(currentWindow); openerPositionArray = getPopupOpenerPosition(popupsArray[i], newWindowsArray, firstWindowTabIndex); openerPosition = openerPositionArray[0]; switch (openerPositionArray[1]) { case 'browsers': // the popup opener was found in the list of browsers that will be added to the remaining window. if (openerPosition < currentIndex) currentIndex += tabs.length; if (popupsList[openerPosition] instanceof Array) popupsList[openerPosition] = popupsList[openerPosition].concat(listedTabs); else popupsList[openerPosition] = listedTabs; break; case 'tabs': // the popup opener was found in one of the tabs in the window that will remain. setTabsInBrowser(firstWindow, listedTabs, openerPosition); if (openerPosition < currentIndex) currentIndex += tabs.length; break; case 'end': default: // no popup opener was found, the pop up will be added at the end of the tab list. browsers = browsers.concat(listedTabs); break; } } else { browsers = browsers.concat(listTabs(tabs, popupsArray[i])); } } } // place all tabs in one window and select the tab which was selected in the top window setTabsInBrowser(firstWindow, browsers); // add popups which have openers next to their openers. while (popupsList.length > 0) { var popupTabs = popupsList.pop(); if (popupTabs instanceof Array) { var position = popupsList.length; setTabsInBrowser(firstWindow, popupTabs, position); } } // select the tab which was selected in the top window firstWindowTabBar.selectedIndex = currentIndex; // focus the window now containing the tabs and close all other windows firstWindow.focus(); // close windows from where tabs have been merged for (i = 1; i < windowsArray.length; i++) { windowsArray[i].close(); } // close popup windows if the popups have been merged if (mergePopups) { for (i = 0; i < popupsArray.length; i++) { popupsArray[i].close(); } } // if current window has been merged close it if (!dontMergeCurrentWindow) currentWindow.close(); // give focus again to the current window if it is a popup and popups should not be merged if (dontMergeCurrentWindow) setTimeout(windowsArrayList.currentWindow.focus, 0); } // retrieve the opener for a popup window, so it can be placed next to it function getPopupOpenerPosition(popupWindow, otherWindows, containerWindowTabsIndex) { var i, j, openerIndex = -1; var openerWindow = popupWindow.getBrowser().contentWindow.opener if (!openerWindow) { return [openerIndex, 'end']; } for (i = 0; i < otherWindows.length; i++) { if (otherWindows[i] == popupWindow) continue; var tabs = otherWindows[i].getBrowser().mTabContainer.childNodes; for (j = 0; j < tabs.length; j++) { openerIndex++; var possibleOpener = otherWindows[i].getBrowser().getBrowserForTab(tabs[j]).contentWindow; if (possibleOpener == openerWindow) { var where = (openerIndex >= containerWindowTabsIndex)? 'browsers': 'tabs'; return [openerIndex, where]; } } } return [-1, 'end']; } function listTabs(tabs, aWindow) { var x = 0, curBrowser, browsersArray = new Array(); for (x; x < tabs.length; x++) { curBrowser = aWindow.getBrowser().getBrowserForTab(tabs[x]); browsersArray[x] = [[dtMergeWindows.copyHistory(curBrowser.webNavigation.sessionHistory)], aWindow.SessionData.getTabProperties(tabs[x]), [curBrowser.contentWindow.scrollX, curBrowser.contentWindow.scrollY], curBrowser.markupDocumentViewer.textZoom]; } return browsersArray; } // add cloned tabs to a browser window function setTabsInBrowser(aWindow, pages) { var y = 0, openedBrowser, newTab; if (openTabNext) { var index = (aWindow == firstWindow)?firstWindowTabIndex:previousWindowTabIndex; } // add tabs to defined position in case of a popup: next to its opener var addToPosition = false; if (typeof(arguments[2]) == 'number') { addToPosition = true; var openerPosition = arguments[2]; var position = arguments[2]; } while (y < pages.length) { newTab = aWindow.getBrowser().addTab(); if (addToPosition && getBrowser().TMmoveTabTo) { var newTabPos = (aWindow.getBrowser().getTabIndex)? aWindow.getBrowser().getTabIndex(newTab): newTab._tPos; // the popup is placed next to its opener var newPosition = position + 1; if (newTabPos < newPosition) newPosition--; if (newTabPos != newPosition) aWindow.getBrowser().TMmoveTabTo((aWindow.getBrowser().getTabIndex)? newTabPos: newTab, newPosition); // set the opener again for the popup (this data will otherwise be lost) var openerBrowser = aWindow.getBrowser().getBrowserForTab(aWindow.getBrowser().mTabContainer.childNodes[openerPosition]); aWindow.getBrowser().getBrowserForTab(newTab).contentWindow.opener = openerBrowser.contentWindow; position++; } else if (openTabNext) { var firstArgument = (aWindow.getBrowser().getTabIndex)? aWindow.getBrowser().getTabIndex(newTab): newTab; aWindow.getBrowser().TMmoveTabTo(firstArgument, index + 1); index++; } openedBrowser = aWindow.getBrowser().getBrowserForTab(newTab); //we call setScrollPosition after load to make sure scrollPosition is set openedBrowser.addEventListener('load', aWindow.dupScrollPosition, true); openedBrowser._scrollData = { tabPos: newTab._tPos, href: null, _scrollX: pages[y][2][0], _scrollY: pages[y][2][1], zoom: pages[y][3] }; aWindow.SessionData.setTabProperties(newTab, pages[y][1]); dtMergeWindows.setClonedContent(openedBrowser, pages[y][0]); y++; } } }, // list all browser windows in een array from front to back (z-order on windows, on linux opening order); listWindows: function() { // function to check if a window is a popup or a normal window function isPopupWindow(domWin) { // the chrome flags are defined in the nsIWebBrowserChrome interface const webBrowserChrome = Components.interfaces.nsIWebBrowserChrome; var chromeBrowser = domWin.getBrowser().docShell.QueryInterface(Components.interfaces.nsIDocShellTreeItem) .treeOwner.QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(webBrowserChrome); // check if all chrome is enabled in the window, using chromeFlags from nsIWebBrowserChrome var chromeAll = chromeBrowser.chromeFlags & webBrowserChrome.CHROME_ALL; if (chromeAll == webBrowserChrome.CHROME_ALL) { return false; // no popup window (the window has all chrome enabled) } // in other cases some chrome is missing from the window: popup window return true; } var windowsArray = new Array(), popupsArray = new Array(); var i = 0, winEnumerator, currentWindow, isCurrentWindowPopup, win; var windowsMediator = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); currentWindow = windowsMediator.getMostRecentWindow('navigator:browser'); // on linux z enumerator does not work: use normal enumerator var platform = currentWindow.navigator.platform; if (platform.indexOf('Linux') != -1) { winEnumerator = windowsMediator.getEnumerator('navigator:browser'); while (winEnumerator.hasMoreElements()) { win = winEnumerator.getNext(); // list the currentWindow apart if (win == currentWindow.QueryInterface(Components.interfaces.nsIDOMWindow)) { currentWindow = win; isCurrentWindowPopup = isPopupWindow(win); continue; } if (isPopupWindow(win)) popupsArray.push(win); else windowsArray.push(win); } } else { // use getZOrderEnumerator on Windows and Mac; it does not work on linux winEnumerator = windowsMediator.getZOrderDOMWindowEnumerator('navigator:browser', false); while (winEnumerator.hasMoreElements()) { win = winEnumerator.getNext(); // list the current window apart if (win == currentWindow.QueryInterface(Components.interfaces.nsIDOMWindow)) { currentWindow = win; isCurrentWindowPopup = isPopupWindow(win); continue; } if (isPopupWindow(win)) popupsArray.push(win); else { windowsArray.push(win); } } } var windowsList = {windowsArray: windowsArray, popupsArray: popupsArray, currentWindow: currentWindow, isCurrentWindowPopup: isCurrentWindowPopup}; return windowsList; }, setClonedContent: function(aBrowser, aClonedContents) { if (aClonedContents[0].length == 0) return; this.clonedContents = aClonedContents; this.newBrowser = aBrowser; this.cloneTabHistory(aBrowser.webNavigation, aClonedContents[0]); }, cloneHistoryEntry: function(aEntry) { if (!aEntry) return null; aEntry = aEntry.QueryInterface(Components.interfaces.nsISHContainer); var newEntry = aEntry.clone(); newEntry = newEntry.QueryInterface(Components.interfaces.nsISHContainer); newEntry.loadType = Math.floor(aEntry.loadType); if (aEntry.childCount) { for (var j = 0; j < aEntry.childCount; j++) { var childEntry = dtMergeWindows.cloneHistoryEntry(aEntry.GetChildAt(j)); if (childEntry) newEntry.AddChild(childEntry, j); } } return newEntry; }, cloneTabHistory: function(webNav, originalHistory) { var newHistory = webNav.sessionHistory newHistory.QueryInterface(Components.interfaces.nsISHistoryInternal); // delete history entries if they are present if (newHistory.count > 0) newHistory.PurgeHistory(newHistory.count); for (var i = 0; i < originalHistory.length; i++) { var entry = originalHistory[i].QueryInterface(Components.interfaces.nsISHEntry); var newEntry = dtMergeWindows.cloneHistoryEntry(entry); newHistory.addEntry(newEntry, true); } // Goto current history location if (originalHistory.length > 0 && originalHistory.index < originalHistory.length) { try { webNav.gotoIndex(originalHistory.index); } catch(e) { window.setTimeout( function (webNav, index) { webNav.gotoIndex(index); }, 0, webNav, originalHistory.index); } } }, copyHistory: function(originalHistory, aOnlyBack) { // variables used in this function var pageCount, currentPageNum, firstPageNum, lastPageNum; currentPageNum = originalHistory.index; lastPageNum = originalHistory.count-1; firstPageNum = 0; pageCount = lastPageNum+1; currentPageNum = currentPageNum-firstPageNum; var copiedHistory = new Array(); for (var i = firstPageNum; i < pageCount; i++) { copiedHistory.push(originalHistory.getEntryAtIndex(i, false)); } copiedHistory.index = currentPageNum; return copiedHistory; } }; PK 844"content/tabmixplus/flst/lasttab.js/*//////////////////////////////////////////////////////////////////// // The Original Code is the "LastTab" extension for Mozilla Firefox.// // version 1.5 - October 26, 2005 // // The Initial Developer of the Original Code is Timothy Humphrey. // *//////////////////////////////////////////////////////////////////// var TMP_LastTab = { CtrlKey : false, favorLeftToRightOrdering : true, handleCtrlTab : true, KeyboardNavigating : true, KeyLock : false, respondToMouseInTabList : true, showTabList : true, SuppressTabListReset : false, TabHistory : [], TabIndex : 0, TabList : null, TabListLock : false, _inited: false, DisplayTabList : function() { var element = document.documentElement; var tablist = this.TabList; var menuitem, tab, imageUrl, x, y, i, activeIndex; createCommonList(tablist, this.handleCtrlTab ? 3 : 2); var item = tablist.childNodes[this.TabIndexToMenuItem()]; item.setAttribute("_moz-menuactive", "true"); updateMenuItemActive(null, item); //moveTo() method introduces anomalies, e.g. hovering over location bar moves the popup; hiding and showing the popup works better document.popupNode = element; x = -element.boxObject.screenX; y = 10000; tablist.showPopup(element, x, y, "popup", null, null); //show offscreen to get popup measurements x = Math.round((window.outerWidth - tablist.boxObject.width) / 2) - (element.boxObject.screenX - window.screenX); y = Math.round((window.outerHeight - tablist.boxObject.height) / 2) - (element.boxObject.screenY - window.screenY); if(x + element.boxObject.screenX < 0) x = -element.boxObject.screenX; else if(x + element.boxObject.screenX + tablist.boxObject.width > window.screen.availWidth) x = window.screen.availWidth - tablist.boxObject.width - element.boxObject.screenX; if(y + element.boxObject.screenY < 0) y = -element.boxObject.screenY; else if(y + element.boxObject.screenY + tablist.boxObject.height > window.screen.availHeight) y = window.screen.availHeight - tablist.boxObject.height - element.boxObject.screenY; if(x == -1 && y == -1) //workaround special status of -1, -1 position in showPopup() method x = y = 0; this.SuppressTabListReset = true; tablist.hidePopup(); this.SuppressTabListReset = false; tablist.showPopup(element, x, y, "popup", null, null); var ietab = "chrome://ietab/content/reloaded.html?url=" if (gBrowser.currentURI.spec.indexOf(ietab) == 0) tablist.focus(); this.TabListLock = true; }, init : function() { this._inited = true; var browser = document.documentElement; this.TabList = document.getElementById("lasttabTabList"); if ("_keyEventHandler" in gBrowser.mTabBox) gBrowser.mTabBox._eventNode.removeEventListener("keypress", gBrowser.mTabBox._keyEventHandler, false); else // we are after Bug 156459 fixed (2007-11-15) gBrowser.mTabBox._eventNode.removeEventListener("keypress", gBrowser.mTabBox, false); browser.addEventListener("keydown", this, true); browser.addEventListener("keypress", this, true); browser.addEventListener("keyup", this, true); this.TabList.addEventListener("DOMMenuItemActive", this, true); this.TabList.addEventListener("DOMMenuItemInactive", this, true); gBrowser.selectedTab.__LastTab = true; this.TabHistory.push(gBrowser.selectedTab); if (gBrowser.selectedTab._tPos != 0) { // if session manager select other tab then the first one we need to build TabHistory in two steps // to maintain natural Ctrl-Tab order. // we call MaintainTabHistory from here the 2nd time is call from OnSelect. this.MaintainTabHistory(gBrowser.selectedTab._tPos); } // we change pref string in tabmixplus 0.3 if (tabxPrefs.prefHasUserValue("HandleCtrlTab")) { tabxPrefs.setBoolPref("lasttab.handleCtrlTab", tabxPrefs.getBoolPref("HandleCtrlTab")); tabxPrefs.clearUserPref("HandleCtrlTab"); } if (tabxPrefs.prefHasUserValue("CtrlTabLeftToRight")) { tabxPrefs.clearUserPref("CtrlTabLeftToRight"); } this.ReadPreferences(); }, deinit : function() { var browser = document.documentElement; browser.removeEventListener("keydown", this, true); browser.removeEventListener("keypress", this, true); browser.removeEventListener("keyup", this, true); this.TabList.removeEventListener("DOMMenuItemActive", this, true); this.TabList.removeEventListener("DOMMenuItemInactive", this, true); }, handleEvent : function(event) { switch (event.type) { case "keydown": this.OnKeyDown(event); break; case "keypress": this.OnKeyPress(event); break; case "keyup": this.OnKeyUp(event); break; case "DOMMenuItemActive": this.ItemActive(event); break; case "DOMMenuItemInactive": this.ItemInactive(event); break; } }, ItemActive : function(event) { updateMenuItemActive(event); if(this.respondToMouseInTabList) { if(this.KeyboardNavigating) { if(event.target.value != this.inverseIndex(this.TabIndex)) this.TabList.childNodes[this.TabIndexToMenuItem()].setAttribute("_moz-menuactive", "false"); this.KeyboardNavigating = false; } this.TabIndex = this.inverseIndex(event.target.value); } else { if(event.target.value != this.inverseIndex(this.TabIndex)) event.target.setAttribute("_moz-menuactive", "false"); } }, ItemInactive : function(event) { updateMenuItemInactive(event); if(!this.respondToMouseInTabList && event.target.value == this.inverseIndex(this.TabIndex)) event.target.setAttribute("_moz-menuactive", "true"); }, MaintainTabHistory : function(lastIndex) { var newTabs = [], tab, i; // Gather tab synchronization info if (typeof(lastIndex)=="undefined") lastIndex = gBrowser.mTabContainer.childNodes.length; for(i = 0; i < lastIndex; i++) { tab = gBrowser.mTabContainer.childNodes[i]; if(!tab.__LastTab) newTabs[newTabs.length] = tab; } // Purge old tab info from history i = 0; try{ while(i < this.TabHistory.length) { if(!this.TabHistory[i] || this.TabHistory[i].parentNode != gBrowser.mTabContainer) this.TabHistory.splice(i, 1); else i++; } } catch (e) {tmLog("error from Ctrl+Tab in MaintainTabHistory " + typeof(this.TabHistory[i]) + "\n" + e + "\n" + "this.TabHistory.length " + this.TabHistory.length + "\n" + "i " + i);} // Add new tabs to history if(newTabs.length > 0) { tab = this.TabHistory.pop(); if(this.favorLeftToRightOrdering) { for(i = newTabs.length - 1; i >= 0; i--) { newTabs[i].__LastTab = true; this.TabHistory.push(newTabs[i]); } } else { for(i = 0; i < newTabs.length; i++) { newTabs[i].__LastTab = true; this.TabHistory.push(newTabs[i]); } } this.TabHistory.push(tab); } }, OnKeyDown : function(event) { this.CtrlKey = event.ctrlKey && !event.altKey && !event.metaKey; }, OnKeyPress : function _LastTab_OnKeyPress(event) { var tabCount = this.handleCtrlTab ? this.TabHistory.length : gBrowser.mTabs.length; if((this.handleCtrlTab || this.showTabList) && event.keyCode == Ci.nsIDOMKeyEvent.DOM_VK_TAB && event.ctrlKey && !event.altKey && !event.metaKey) { if(!this.KeyLock) { if (this.handleCtrlTab) { this.MaintainTabHistory(); tabCount = this.TabHistory.length; this.TabIndex = tabCount - 1; } else { this.TabIndex = tabCount - 1 - gBrowser.mCurrentTab._tPos; } this.KeyLock = true; } if(this.TabListLock) this.TabList.childNodes[this.TabIndexToMenuItem()].setAttribute("_moz-menuactive", "false"); if(event.shiftKey) { this.TabIndex++; if(this.TabIndex >= tabCount) this.TabIndex = 0; } else { this.TabIndex--; if(this.TabIndex < 0) this.TabIndex = tabCount - 1; } if(this.showTabList) { this.KeyboardNavigating = true; if(!this.TabListLock) { if(tabCount > 1) this.DisplayTabList(); } else { var item = this.TabList.childNodes[this.TabIndexToMenuItem()]; item.setAttribute("_moz-menuactive", "true"); updateMenuItemActive(null, item); } } else { TMP_tabSelectedFromList(this.TabHistory[this.TabIndex]); } event.stopPropagation(); event.preventDefault(); } else { if(this.TabListLock) this.TabList.hidePopup(); if ("_keyEventHandler" in gBrowser.mTabBox) gBrowser.mTabBox._keyEventHandler.handleEvent(event); else // we are after Bug 156459 fixed (2007-11-15) gBrowser.mTabBox.handleEvent(event); } }, OnKeyUp : function _LastTab_OnKeyUp(event) { var keyReleased = event.keyCode == Ci.nsIDOMKeyEvent.DOM_VK_CONTROL; this.CtrlKey = event.ctrlKey && !event.altKey && !event.metaKey; if(keyReleased && this.TabListLock) { if(this.TabList.childNodes[this.TabIndexToMenuItem()].getAttribute("_moz-menuactive") == "true") { var tabToSelect = this.handleCtrlTab ? this.TabHistory[this.TabIndex] : gBrowser.mTabs[gBrowser.mTabs.length - 1 - this.TabIndex]; TMP_tabSelectedFromList(tabToSelect); } updateMenuItemInactive(null); gBackupLabel==""; this.PushSelectedTab(); this.TabList.hidePopup(); } if(keyReleased && this.KeyLock) { this.PushSelectedTab(); this.TabIndex = 0; this.KeyLock = false; } }, OnMenuCommand : function _LastTab_OnMenuCommand(event) { if(this.respondToMouseInTabList) { var tabToSelect = this.handleCtrlTab ? this.TabHistory[event.target.value] : gBrowser.mTabs[event.target.value]; TMP_tabSelectedFromList(tabToSelect); this.PushSelectedTab(); } }, OnPopupHidden : function() { if(!this.SuppressTabListReset) { var tablist = this.TabList; while(tablist.childNodes.length > 0) tablist.removeChild(tablist.childNodes[0]); this.TabListLock = false; this.TabIndex = 0; this.KeyLock = false; hideCommonList(tablist); } }, OnSelect : function() { // session manager can select new tab befor TMP_LastTab is init if (!this._inited) return; var tabCount = this.TabHistory.length; this.MaintainTabHistory(); if(tabCount != gBrowser.mTabContainer.childNodes.length) { if(tabCount > gBrowser.mTabContainer.childNodes.length) { if(gBrowser.mTabContainer.childNodes.length == 1) { this.KeyLock = false; this.TabIndex = 0; } } this.PushSelectedTab(); } else if(!this.KeyLock) { if(this.CtrlKey) this.KeyLock = true; //allow other tab navigation methods to work else this.PushSelectedTab(); } }, PushSelectedTab : function() { var selectedTab = gBrowser.mTabContainer.selectedItem; var tabCount, i; if(this.TabHistory[this.TabHistory.length - 1] != selectedTab) { tabCount = this.TabHistory.length; for(i = 0; i < tabCount; i++) { if(this.TabHistory[i] == selectedTab) { this.TabHistory.push(this.TabHistory.splice(i, 1)[0]); break; } } } }, ReadPreferences : function() { this.handleCtrlTab = tabxPrefs.getBoolPref("lasttab.handleCtrlTab"); this.favorLeftToRightOrdering = tabxPrefs.getBoolPref("lasttab.favorLeftToRightOrdering"); this.respondToMouseInTabList = tabxPrefs.getBoolPref("lasttab.respondToMouseInTabList"); this.showTabList = tabxPrefs.getBoolPref("lasttab.showTabList"); }, TabIndexToMenuItem : function() { var activeIndex; if (this.handleCtrlTab) activeIndex = this.TabHistory.length - 1 - this.TabIndex; else activeIndex = gBrowser.mTabs.length - 1 - this.TabIndex; return activeIndex; }, inverseIndex : function(index) { return this.handleCtrlTab ? index : gBrowser.mTabs.length - 1 - index; } } PK 8content/tabmixplus/history/PK U6z%dd,content/tabmixplus/history/history-panel.xul PK 2{p8_J%content/tabmixplus/history/history.jsvar Click2TabHistoryPanel = { init : function () { window.removeEventListener('load', function () { Click2TabHistoryPanel.init(); }, false); if (typeof(PlacesController) == "function") { TMP_Places.init(); return; } TMP_update_whereToOpen(); eval("openURL = " + openURL.toString().replace( 'openURLIn(whereToOpenLink(aEvent));', 'openURLIn(whereToOpenLinkTabmix(aEvent, prefStringTMHistory));' )); eval("buildContextMenu ="+buildContextMenu.toString() .replace('openItemInNewTab.hidden = false;', '$& TMP_updateContextMenu(openItem, openItemInNewWindow, openItemInNewTab, prefStringTMHistory);' )); } } PK 8content/tabmixplus/links/PK 8IkIk(content/tabmixplus/links/contentLinks.js/* * chrome://tabmixplus/content/links/contentLinks.js * * original code by Bradley Chapman * modified and developped by Hemiola SUN * modified again by Bradley Chapman * */ var gIOService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService); var gPref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); var gWindowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); /** * @brief Open the given link node in the current window. * * @param event A valid event union. * @param linkNode The DOM node containing the URL to open. * @param currentTab A Boolean value. If true, the URL will be opened * within the current tab. If false, it will be * opened in a new tab. * @returns True if the function opened a URL, or the value * of handleLinkClick() if it chose not to. * */ function TMP_howToOpen(event, linkNode, currentTab) { // this helper function parses the event union for us // and makes a better determination of how a link will // be opened var where = whereToOpenLink(event); if (where == "save" || where == "window" ) { handleLinkClick(event, linkNode.href, linkNode); return true; } if ("webPanelSecurityCheck" in window) { // webPanelSecurityCheck was removed at 18/02/2007 if (!webPanelSecurityCheck(linkNode.ownerDocument.location.href, linkNode.href)) return false; } else { // for Firefox 3.0 after bug 370765 landed try { urlSecurityCheck(linkNode.href, linkNode.ownerDocument.nodePrincipal); } catch(ex) { return false; } } var postData = { }; var url = getShortcutOrURI(linkNode.href, postData); if (!url) return true; // if where is "tab", "tabshifted", "current" callers will control the inversion of currentTab var docURL = event.target.ownerDocument.location.href; // referrer header if (currentTab) { var referrerURI = gIOService.newURI(docURL, null, null); window.loadURI(url, referrerURI, postData.value, false); event.preventDefault(); return false; } else { try{ var f = window.openNewTabWith.toString(); if (f.indexOf("aEvent") > -1 ) window.openNewTabWith(url, event.target.ownerDocument, null, event, false); // firefox 3.0 + else if (f.indexOf("event") > f.indexOf("postData")) window.openNewTabWith(url, docURL, null, event, false); // firefox 1.5 + else window.openNewTabWith(url, linkNode, event, true, null); // firefox 1.0.x } catch (e) {} event.preventDefault(); return true; } } /** * @brief Check for certain JavaScript strings inside an attribute. * * @param attr The attribute to check. * @param string The string to check for. * @returns true if the strings are present, false if they aren't. * */ function TMP_checkAttr(attr, string) { if (typeof(attr) == "string") return attr.indexOf(string) == 0; return false; } /** * @brief Check if link refers to external domain. * * @param target The target link. * @param curpage The current page url * @returns current domain and target domain * */ function checkDomain(curpage, target) { function getDomain(url) { if (typeof(url) != "string") url = url.toString(); if (url.match(/^file:/)) return "local_file"; if (url.match(/^http/)) { url = gIOService.newURI(url, null, null); // catch redirect if (url.path.match(/^\/r\/\?http/)) url = gIOService.newURI(url.path.substr("/r/?".length), null, null); var host = url.hostPort.split("."); while (host.length > 2) host.shift(); return host.join("."); } return null; } return {current: getDomain(curpage), target: getDomain(target)}; } /** * @brief Handle left-clicks inside a browser viewport. * * This function is the primary entry point for all left-clicks on a browser * page; we triage and sort such clicks and handle the ones we want and pass * on the ones that we don't. * * @param event A valid event union. * @param fieldNormalClicks A Boolean value. If true, we will handle all left-clicks * that invoke this function. If false, we will only handle * the ones that require additional legwork (i.e. locked tabs). * @returns Either the return value of __contentAreaClick(), or the * return value of handleLinkClick(), or true if the function * was passed an event it could not handle. */ function TMP_contentAreaClick(event, fieldNormalClicks) { try { var targetPref = gPref.getIntPref("extensions.tabmix.speLink"); var linkTarget = gPref.getBoolPref("extensions.tabmix.linkTarget"); var suppressTabs = gPref.getBoolPref("extensions.tabmix.enablefiletype") } catch(e) {} // use the default if either of these are activated if (!event.isTrusted || event.getPreventDefault()) { return true; } var target = event.target; var linkNode; var where = whereToOpenLink(event); if (target instanceof HTMLButtonElement || target instanceof HTMLInputElement) { if (typeof(SubmitToTab)!='undefined' && SubmitToTab.contentAreaClick(event) == false) { return false; } } if (target instanceof HTMLAnchorElement || target instanceof HTMLAreaElement || target instanceof HTMLLinkElement) { if (target.hasAttribute("href")) linkNode = target; // xxxmpc: this is kind of a hack to work around a Gecko bug (see bug 266932) // we're going to walk up the DOM looking for a parent link node, // this shouldn't be necessary, but we're matching the existing behaviour for left click var parent = target.parentNode; while (parent) { if (parent instanceof HTMLAnchorElement || parent instanceof HTMLAreaElement || parent instanceof HTMLLinkElement) { if (parent.hasAttribute("href")) linkNode = parent; } parent = parent.parentNode; } } else { linkNode = event.originalTarget; while (linkNode && !(linkNode instanceof HTMLAnchorElement)) linkNode = linkNode.parentNode; // cannot be nested. So if we find an anchor without an // href, there is no useful around the target if (linkNode && !linkNode.hasAttribute("href")) linkNode = null; else if (linkNode && linkNode.hasAttribute("href")) target = linkNode; } if (!linkNode) return __contentAreaClick(event, fieldNormalClicks); // Check if new tab already opened from onclick event // 2006-09-26 if (target.hasAttribute("onclick") && gBrowser.contentDocument.location.href != document.commandDispatcher.focusedWindow.top.location.href) return true; // Check if link refers to external domain. // Get current page url var curpage = linkNode.ownerDocument.location.href; // 2006-09-29 var domain = checkDomain(curpage, target); var targetDomain = domain.target; var currentDomain = domain.current; var openT = linkNode.getAttribute("target"); // If link has no target attribute, check if there is a with a target attribute if (!openT) { var b = document.commandDispatcher.focusedWindow.document.getElementsByTagName("base"); if (b.length > 0) openT = b[0].getAttribute("target"); } if (linkNode.getAttribute("rel") == "sidebar" || openT == "_search" || linkNode.getAttribute("href").indexOf("mailto:") > -1) { return __contentAreaClick(event, fieldNormalClicks); } /* * prevent tabs from opening if left-clicked link ends with given filetype or matches regexp; * portions were taken from disable target for downloads by cusser * */ if (TMP_suppressTabsOnFileDownload(event, target, linkNode, suppressTabs)) { // don't do anything if we are on gmail and let gmail to take care of the download var isGmail = /^http:\/\/mail.google.com\/mail/.test(target.ownerDocument.location.href); if (isGmail) return true; else return TMP_howToOpen(event, linkNode, true); } /* * force a middle-clicked link to open in the current tab if certain conditions * are true. See the function comment for more details. * */ if (TMP_divertMiddleClick(event, linkNode, gBrowser.mCurrentTab, currentDomain, targetDomain, targetPref, gPref.getBoolPref("extensions.tabmix.middlecurrent"))) { return TMP_howToOpen(event, linkNode, true); } // catch other middle & right click if (event.button != 0) { handleLinkClick(event, linkNode.href, linkNode); return true; } // the rest of the code if for left-click only /* * open targeted links in the current tab only if certain conditions are met. * See the function comment for more details. * */ if (TMP_divertTargetedLink(event, target, linkNode, openT, document.commandDispatcher.focusedWindow.top.frames, gBrowser.mCurrentTab, currentDomain, targetDomain, targetPref, linkTarget)) { return TMP_howToOpen(event, linkNode, true); } /* * open links to other sites in a tab only if certain conditions are met. See the * function comment for more details. * */ if (TMP_openExSiteLink(event, target, linkNode, currentDomain, targetDomain, targetPref)) { return TMP_howToOpen(event, linkNode, false); } if (gBrowser.mCurrentTab.hasAttribute("locked")) { // tab is locked var href = null, onclick = null; if (target.hasAttribute("href")) href = target.getAttribute("href").toLowerCase(); if (target.hasAttribute("onclick")) onclick = target.getAttribute("onclick"); if (TMP_checkAttr(href, "javascript:") || TMP_checkAttr(href, "data:") || TMP_checkAttr(onclick, "window.open") || TMP_checkAttr(onclick, "NewWindow") || TMP_checkAttr(onclick, "PopUpWin") || (onclick && onclick.indexOf('this.target="_Blank"') != -1) || TMP_checkAttr(onclick, "return ")) { ; // javascript links, do nothing! } else { var current = TMP_checkAttr(href, "#"); return TMP_howToOpen(event, linkNode, current); } } // use whereToOpenLink() to determine if no modifiers were used else if (where == "current") { if (fieldNormalClicks && (!openT || openT == "_content" || openT == "_main")) return __contentAreaClick(event, fieldNormalClicks); else if (linkNode.hasAttribute("onclick")) return __contentAreaClick(event, fieldNormalClicks); else if (openT) handleLinkClick(event, linkNode.href, linkNode); } else handleLinkClick(event, linkNode.href, linkNode); return true; } /** * @brief Suppress tabs that may be created by downloading a file. * * This code borrows from Cusser's Disable Targets for Downloads extension. * * @param event A valid event union. * @param target The target of the event. * @param linkNode The DOM node containing the URL to be opened. * @param suppressTabs A Boolean value that controls controlling how the link should be opened. * @returns true if the link was handled by this function. * */ function TMP_suppressTabsOnFileDownload(event, target, linkNode, suppressTabs) { // prevent link with "custombutton" protocol to open new tab when custombutton extension exist if (event.button != 2 && typeof(custombuttons) !='undefined'){ if (TMP_checkAttr(linkNode.toString(), "custombutton://")) return true; } if (event.button != 0 || event.ctrlKey || event.metaKey || !suppressTabs) return false; // lets try not to look into links that start with javascript (from 2006-09-02) if (TMP_checkAttr(linkNode.toString(), "javascript:")) return false; if (target.hasAttribute("onclick")) { var onclick = target.getAttribute("onclick"); if (TMP_checkAttr(onclick, "return install") || TMP_checkAttr(onclick, "return installTheme") || TMP_checkAttr(onclick, "return note") || TMP_checkAttr(onclick, "return log")) // click on link in http://tinderbox.mozilla.org/showbuilds.cgi return true; } // prevent links in tinderbox.mozilla.org with linkHref to *.gz from open in this function if (TMP_checkAttr(linkNode.toString() , "http://tinderbox.mozilla.org/showlog") || TMP_checkAttr(linkNode.toString() , "http://tinderbox.mozilla.org/addnote")) return false; return isUrlForDownload(target.getAttribute("href")) } function isUrlForDownload(linkHref) { var filetype = gPref.getCharPref("extensions.tabmix.filetype"); filetype = filetype.toLowerCase(); filetype = filetype.split(" "); var linkHrefExt = ""; if (linkHref) { linkHref = linkHref.toLowerCase(); linkHrefExt = linkHref.substring(linkHref.lastIndexOf("/"),linkHref.length); linkHrefExt = linkHrefExt.substring(linkHrefExt.indexOf("."),linkHrefExt.length); } var testString, hrefExt, testExt; for (var l = 0; l < filetype.length; l++) { if (filetype[l].indexOf("/") != -1){ // add \ befor first ? testString = filetype[l].substring(1,filetype[l].length-1).replace(/^\?/,"\\?"); hrefExt = linkHref; } else { testString = "\\." + filetype[l]; hrefExt = linkHrefExt; try { // prevent filetype catch if it is in the middle of a word testExt = new RegExp(testString + "[a-z0-9?\.]+", 'i'); if (testExt.test(hrefExt)) continue; } catch (ex) {} } try { testExt = new RegExp(testString, 'i'); if (testExt.test(hrefExt)) return true; } catch (ex) {} } return false; } /** * @brief Divert middle-clicked links into the current tab. * * This function forces a middle-clicked link to open in the current tab if * the following conditions are true: * * - links to other sites are not configured to open in new tabs AND the current * page domain and the target page domain do not match OR the current * tab is locked * - middle-clicks are configured to open in the current tab AND the middle * mouse button was pressed OR the left mouse button and one of the Ctrl/Meta keys * was pressed * * @param event A valid event union. * @param linkNode The DOM node containing the URL to open. * @param currentTab A scripted tab object from the tabbrowser. * @param currentDomain The domain name of the website URL in the current tab. * @param targetDomain The domain name of the website URL in the link node. * @param targetPref An integer value that specifies whether or not links should * be forced into new tabs. * @param middlePref A Boolean value that controls how middle clicks are handled. * @returns true if the function handled the click, false if it didn't. * */ function TMP_divertMiddleClick(event, linkNode, currentTab, currentDomain, targetDomain, targetPref, middlePref) { if (!middlePref) return false; var isTabLocked = currentTab.hasAttribute("locked"); var isDifDomain = targetPref == 2 && targetDomain && targetDomain != currentDomain; if (!isTabLocked && !isDifDomain) return false; if (event.button == 1 || event.button == 0 && (event.ctrlKey || event.metaKey)) return true; return false; } /** * @brief Divert links that contain targets to the current tab. * * This function forces a link with a target attribute to open in the * current tab if the following conditions are true: * * - linkTarget is set * - neither of the Ctrl/Meta keys were used AND the linkNode has a target attribute * AND the content of the target attribute is not one of the special frame targets * AND it is not present in the document frame pool * - links to other sites are not configured to open in new tabs AND the domain name * of the current page and the domain name of the target page do not match * - the current tab is not locked * - the domain name of the current page and the domain name of the target page * do not match * - the target of the event has an onclick attribute that does not contain the * function call 'window.open' or the function call 'return top.js.OpenExtLink' * * @param event A valid event union. * @param target The target of the event. * @param linkNode The DOM node containing the URL to be opened. * @param targetAttr The target attribute of the link node. * @param frames The frame pool of the current document. * @param currentTab A scripted tab object from the tabbrowser. * @param currentDomain The domain name of the website URL loaded in the current tab. * @param targetDomain The domain name of the website URL to be loaded. * @param targetPref An integer value that specifies whether or not links should * be forced into new tabs. * @param linkTarget An integer value that specifies how normal links * that spawn new windows are handled. * @returns true if the function handled the click, false if it didn't. * */ function TMP_divertTargetedLink(event, target, linkNode, targetAttr, frames, currentTab, currentDomain, targetDomain, targetPref, linkTarget) { if (!linkTarget) return false; if (TMP_checkAttr(linkNode.toString(), "javascript:") || // 2005-11-28 some link in Bloglines start with javascript TMP_checkAttr(linkNode.toString(), "data:")) return false; if (event.ctrlKey || event.metaKey) return false; if (!targetAttr) return false; var targetString = /^(_self|_parent|_top|_content|_main)$/; if (targetString.test(targetAttr.toLowerCase())) return false; if (TMP_existsFrameName(frames, targetAttr)) return false; if (targetPref == 2 && targetDomain && targetDomain != currentDomain) return false; if (currentTab.hasAttribute("locked")) return false; if (targetDomain && targetDomain == currentDomain) return false; if (target.hasAttribute("onclick")) { var onclick = target.getAttribute("onclick"); if (TMP_checkAttr(onclick, "window.open") || TMP_checkAttr(onclick, "NewWindow") || TMP_checkAttr(onclick, "PopUpWin") || TMP_checkAttr(onclick, "return ")) return false; } return true; } /** * @brief Open links to other sites in tabs as directed. * * This function opens links to external sites in tabs as long as the following * conditions are met: * * - links to other sites are configured to open in tabs * - the link node does not have an 'onclick' attribute that contains either the function call * 'window.open' or the function call 'return top.js.OpenExtLink'. * - the domain name of the current page and the domain name of the target page do not match * OR the link node has an 'onmousedown' attribute that contains the text 'return rwt' * * @param event A valid event union. * @param target The target of the event. * @param linkNode The DOM node containing the URL to be opened. * @param currentDomain The domain name of the website URL loaded in the current tab. * @param targetDomain The domain name of the website URL to be loaded. * @param targetPref An integer value that specifies whether or not links should * be forced into new tabs. * @returns true if the function handled the click, false if it didn't. * */ function TMP_openExSiteLink(event, target, linkNode, currentDomain, targetDomain, targetPref) { if (targetPref != 2) return false; if (target.hasAttribute("onclick")) { var onclick = target.getAttribute("onclick"); if (TMP_checkAttr(onclick, "window.open") || TMP_checkAttr(onclick, "NewWindow") || TMP_checkAttr(onclick, "PopUpWin") || TMP_checkAttr(onclick, "return ")) return false; } if (targetDomain && targetDomain != currentDomain || TMP_checkAttr(target.getAttribute("onmousedown"), "return rwt")) return true; return false; } /** * @brief Check a document's frame pool and determine if * |targetFrame| is located inside of it. * * @param containerFrame The frame pool of the current document. * @param targetFrame The name of the frame that we are seeking. * @returns true if the frame exists within the given frame pool, * false if it does not. */ function TMP_existsFrameName(containerFrame, targetFrame) { for (var i = 0; i < containerFrame.length; ++i) { if (containerFrame[i].name == targetFrame) return true; if (containerFrame[i].frames.length) var return_var = TMP_existsFrameName(containerFrame[i].frames,targetFrame); } if (return_var) return return_var; return false; } /** * @brief Handle left-clicks on links within a help browser * * NOTE: Shift, Ctrl, and Meta are all ignored * * @param event A valid event union. * @return true if the event was not handled; * false if it was handled and a URI was * loaded. * */ function TMP_helpContentClick(event) { var helpBrowser = document.getElementById("help-content"); if (!helpBrowser) { return true; } if (event.button != 0) return true; // shall we ignore this? if (is_ignorable(event.target) || is_ignorable(event.originalTarget)) { return true; } var linkNode; var target = event.target; if (target instanceof HTMLAnchorElement || target instanceof HTMLAreaElement || target instanceof HTMLLinkElement) { if (target.hasAttribute("href")) { linkNode = target; } } else { linkNode = event.originalTarget; while (linkNode && !(linkNode instanceof HTMLAnchorElement)) { linkNode = linkNode.parentNode; } // cannot be nested. So if we find an anchor without an // href, there is no useful around the target if (linkNode && !linkNode.hasAttribute("href")) { return true; } } var uriSpec; if (linkNode instanceof Node && linkNode.hasAttribute("href")) { uriSpec = linkNode.href; } if (!uriSpec || uriSpec == undefined) { return true; } // do not handle URIs that are not http, ftp or https var URI = gIOService.newURI(uriSpec, null, null); if (!URI.schemeIs("http") && !URI.schemeIs("ftp") && !URI.schemeIs("https")) { helpBrowser.loadURI(URI.spec); return false; } TMP_openURL(URI.spec, event); return false; } /** * Determine if a node should be ignored by the iterator functions. * * @param nod An object implementing the DOM1 |Node| interface. * @return true if the node is: * 1) A |Text| node that is all whitespace * 2) A |Comment| node * and otherwise false. */ function is_ignorable(nod) { return (nod.nodeType == 8) || // A comment node ((nod.nodeType == 3) && is_all_ws(nod)); // a text node, all ws } /** * @brief Locate a browser window. * * @param aExclude A scripted window object that we do not * want to use. * @returns A scripted window object representing a browser * window that is not the same as aExclude, and is * additionally not a popup window. * */ function TMP_getBrowserWindow(aExclude) { var windows = gWindowManager.getEnumerator('navigator:browser'); while (windows.hasMoreElements()) { var win = windows.getNext().QueryInterface(Components.interfaces.nsIDOMWindow); if (TMP_checkForPopup(win.QueryInterface(Components.interfaces.nsIDOMWindowInternal))) continue; // this returns the first window that we find; it is not exhaustive if (win != aExclude) return win; } return null; } /** * @brief Checks to see if a given nsIDOMWindowInternal window is a popup or not. * * @param domWindow A scripted nsIDOMWindowInternal object. * @return true if the domWindow is a popup, false otherwise. * */ function TMP_checkForPopup(domWindow) { if (!(domWindow instanceof Components.interfaces.nsIDOMWindowInternal)) return false; // FIXME: locationbar, menubar, toolbar - // if these are hidden the window is probably a popup var locbarHidden = !domWindow.locationbar.QueryInterface(Components.interfaces.nsIDOMBarProp).visible; var menubarHidden = !domWindow.menubar.QueryInterface(Components.interfaces.nsIDOMBarProp).visible; try { var toolbarHidden = !domWindow.toolbar.QueryInterface(Components.interfaces.nsIDOMBarProp).visible; } catch (e) { toolbarHidden = "hidden" in domWindow.toolbar ? domWindow.toolbar.hidden : false; } // the following logic, while possibly slow, is designed // to catch all reasonable permutations of hidden UI if ((locbarHidden && menubarHidden) || (menubarHidden && toolbarHidden) || (locbarHidden && menubarHidden && toolbarHidden)) { return true; } return false; } /* * handle all DOM window open events and catch attempts to open new windows * * PRECONDITION: None. * POSTCONDITION: None. * */ var TMP_DOMWindowOpenObserver = { Tbplite: 'tbpl', observe : function(aSubject, aTopic, aData) { if (aTopic != 'domwindowopened') return; this.onObserve(aSubject, this); return; }, onObserve : function(aSubject, aThis) { gSingleWindowMode = TMP_getBoolPref(tabxBranch, "singleWindow", false); tabxPrefObserver.setLink_openPrefs(); if (!gSingleWindowMode) return; var newWindow = aSubject; var existingWindow = TMP_getBrowserWindow(newWindow); // no navigator:browser window open yet? if (!existingWindow) return; // if the href is missing, try again later (xxx) if (!newWindow.location.href) { existingWindow.setTimeout(aThis.onObserve, 0, newWindow, aThis); return; } // we don't want to open non-browser windows in a tab if(newWindow.location.href != "chrome://browser/content/browser.xul") return; if ( !('arguments' in newWindow) || newWindow.arguments.length == 0 ) return; var _Browser = existingWindow.getBrowser(); existingWindow.tablib.init(); // just incase tablib isn't init yet var newTab = _Browser.addTab(newWindow.arguments[0], null, null); _Browser.TMP_selectNewForegroundTab(newTab, false, newWindow.arguments[0]); setTimeout(newWindow.close, 0); return; } } // end of TMP_DOMWindowOpenObserver PK @?U5o-FF"content/tabmixplus/links/links.xul PK `3׹qͼ"content/tabmixplus/links/search.js/* * This was modified from Tab Browser Preferences by Bradley Chapman * * it contains specific code for the search bar dialog * */ function TMP_onLoad() { eval("onAfterLoad ="+onAfterLoad.toString().replace( 'var tabChecked = false;', 'gDialog.newtabFocus = document.getElementById("searchTabFocus");\ var tabChecked = false, focusChecked = false;' ).replace( 'tabChecked = pref.getBoolPref(kTabPref);', 'tabChecked = pref.getBoolPref("extensions.tabmix.opentabfor.search");\ focusChecked = pref.getBoolPref("extensions.tabmix.loadSearchInBackground");' ).replace( 'gDialog.newtab.setAttribute("checked", tabChecked);', 'gDialog.newtab.setAttribute("checked", tabChecked);\ gDialog.newtabFocus.setAttribute("checked", focusChecked);\ gDialog.newtabFocus.setAttribute("disabled", !gDialog.newtab.checked);' )); eval("setPrefs ="+setPrefs.toString().replace( 'pref.setBoolPref(kTabPref, gDialog.newtab.checked);', 'pref.setBoolPref("extensions.tabmix.opentabfor.search", gDialog.newtab.checked); \ pref.setBoolPref("extensions.tabmix.loadSearchInBackground", gDialog.newtabFocus.checked);' )); onLoad(); return true; }PK @"4{ )content/tabmixplus/links/SearchDialog.xul %searchDTD; %miscDTD; ]> PK 18ɂ<<)content/tabmixplus/links/userInterface.js/* * chrome://tabmixplus/content/links/userInterface.js * * original code by Bradley Chapman * modified and developped by Hemiola SUN * modified again by Bradley Chapman * */ var gIOService = Components.classes["@mozilla.org/network/io-service;1"] .getService(Components.interfaces.nsIIOService); var gPref = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefBranch); var gURIFixer = Components.classes["@mozilla.org/docshell/urifixup;1"] .getService(Components.interfaces.nsIURIFixup); var gWindowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator); /** * @brief Catch call to tabmix options from EM * we only use Tabmix options if we have browser window * * @param aURL A valid options URL string. * * @return true if the URL is for tabmix options * false if not. * */ function TMP_cmd_options(aURL) { if (aURL != "chrome://tabmixplus/content/pref/pref-tabmix.xul") return false; var browserWindow = gWindowManager.getMostRecentWindow("navigator:browser"); if (!browserWindow) { var tabmixopt = gWindowManager.getMostRecentWindow("mozilla:tabmixopt"); if (tabmixopt) tabmixopt.close(); var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); var stringBundle = Components.classes["@mozilla.org/intl/stringbundle;1"] .getService(Components.interfaces.nsIStringBundleService) .createBundle("chrome://tabmixplus/locale/tabmix.properties"); var title = stringBundle.GetStringFromName("tabmixoption.error.title"); var msg = stringBundle.GetStringFromName("tabmixoption.error.msg"); promptService.alert(window, title, msg); } else browserWindow.TMP_openDialog(-1); return true; } /** * @brief Load URLs from the Extension/Theme Managers, and item with text-link class * * This redefines chrome://mozapps/content/extensions/extensions.js:openURL() * * @param aURL A valid URI string. * @param event A valid event union. This can be null when * calling this function. * @return true. * */ function TMP_openURL(aURL, event) { var linkTarget, loadInBackground; try { linkTarget = gPref.getIntPref("browser.link.open_newwindow"); } catch (e) { linkTarget = 1; } if (aURL == null) aURL = "about:blank"; // check for an existing window and focus it; it's not application modal var browserWindow = gWindowManager.getMostRecentWindow("navigator:browser"); if (!browserWindow) { openDialog("chrome://browser/content/browser.xul", "_blank", "chrome,all,dialog=no", aURL, null, null, null); if (event && event instanceof Event) { event.preventDefault(); event.stopPropagation(); } return true; } var tabBrowser = browserWindow.getBrowser(); var originCharset = tabBrowser.contentDocument.characterSet; // if the current tab is empty, then do not open a new tab if (tabBrowser.selectedBrowser.webNavigation.currentURI.spec == "about:blank") { // 1: CURRENT_TAB linkTarget = 1; originCharset = null; } switch (linkTarget) { case 1 : tabBrowser.loadURI(aURL, null, originCharset); break; case 2 : var f = browserWindow.openNewWindowWith.toString(); if (f.indexOf("securityCheck") == -1) browserWindow.openNewWindowWith(aURL, null, null, false); // firefox 1.5 + else browserWindow.openNewWindowWith(aURL, null, true, null); // firefox 1.0.x break; case 3 : // added by request, for extensions with multiple homepages var urls = aURL.split("|"); var firstTab = tabBrowser.addTab(urls[0], null, originCharset); // only select the EM/TM link when asked to do so tabBrowser.TMP_selectNewForegroundTab(firstTab); for (var i = 1; i < urls.length; ++i) { tabBrowser.addTab(urls[i], null, originCharset); } tabBrowser.mTabContainer.nextTab = 1; break; } if (event && event instanceof Event) { event.preventDefault(); event.stopPropagation(); } return true; } function TMP_BrowserOpenTab(aTab) { var newTabContent = TMP_getIntPref(tabxBranch, "loadOnNewTab", 0 ); var url; switch (newTabContent) { case 0 : // blank tab, by default url = "about:blank"; break; case 1 : // home page url = gHomeButton.getHomePage().split("|")[0]; break; case 2 : // current URI var currentURI = gBrowser.selectedBrowser.webNavigation.currentURI; url = currentURI ? currentURI.spec : "about:blank"; break; case 3 : // duplicate tab gBrowser.duplicateTab(gBrowser.selectedTab); return; case 4 : // user url try { url = gPref.getComplexValue("extensions.tabmix.newTabUrl", Components.interfaces.nsIPrefLocalizedString).data; } catch (e) { tmLog(e); } // use this if we can't find the pref if (!url) url = "about:blank"; break; default: url = "about:blank"; } var originCharset = url != "about:blank" ? gBrowser.selectedBrowser.contentDocument.characterSet : null; var newTab = gBrowser.addTab(url, null, originCharset); if (aTab && aTab.localName == "tab") { var pos = newTab._tPos > aTab._tPos ? 1 : 0; gBrowser.TMmoveTabTo(newTab, aTab._tPos + pos); } if (url != "about:blank") content.focus(); gBrowser.TMP_selectNewForegroundTab(newTab, TMP_getBoolPref(tabxBranch, "loadNewInBackground", true ), url); } /** * @brief Load URLs generated by the search bar and the search dialog. * * @param aData A string containing aData from new service, FF 2.0, or a URI for older FF versions. * @param theSecondArg a valid event union: FF 1.0.7 and FF 1.5+ (see eval in tablib) - called from searchbar or a Boolean value - call from searchDialog. * @param newService A Boolean value, if true we are in FF 2.0 + (after 2006-03-17) * @return Nothing. * */ // XXX need to fix TMP_SearchLoadURL to work like in Fx 3.0 // #351253 [Firefox:Search]-Search button misinterprets modifiers when clicked [All] function TMP_SearchLoadURL(aData, theSecondArg, newService) { var theTabPref = TMP_getBoolPref(tabxBranch, "opentabfor.search", false) var theBGPref = TMP_getBoolPref(tabxBranch, "loadSearchInBackground", false) var URI, postData = null; if (typeof(newService) == "boolean" && newService) { // Bug 336925: Middle clicking search button should open new tab search.xml version 1.67 // Always open in a new tab on a middle-click; otherwise examine the // preference and the alt key. if (theSecondArg && "button" in theSecondArg && theSecondArg.button == 1) theTabPref = true; var searchbar = document.getElementById("searchbar"); var submission = searchbar.currentEngine.getSubmission(aData, null); URI = submission.uri.spec; postData = submission.postData; } else URI = aData; __TMP_LoadBarURL(URI, theSecondArg, theTabPref, theBGPref, postData, false); return; } /** * @brief Load URLs from the URL bar. * * @param event A valid event union. * @param aPostData Additional opaque data used by __TM_LoadBarURL(). * @return Nothing. * */ function TMP_BrowserLoadURL(theEvent, aPostData) { var theTabPref = TMP_getBoolPref(tabxBranch, "opentabfor.urlbar", false) var theBGPref = TMP_getBoolPref(tabxBranch, "loadUrlInBackground", false) var theURI = document.getElementById("urlbar").value; __TMP_LoadBarURL(theURI, theEvent, theTabPref, theBGPref, aPostData, true); } /** * @brief Load URLs from the URL bar, search bar and search dialog. * * This function is used directly by Tab Mix Plus. * * @param theURI The URI to be opened. * @param theEvent A valid event union, or a Boolean value when * called by TMP_SearchLoadURL(). * @param theTabPref A Boolean preference - if true, the URL will be * opened in a new tab; if false, it will load in * the current tab. * @param theBGPref A Boolean preference - if false, the newly created tab will be focused; * if true, the newly created tab will be unfocused. * @param thePostData Additional opaque data used by tabbrowser methods * @param aAllowThirdPartyFixup Allow third-party services to fixup this URL * @returns Nothing. * */ function __TMP_LoadBarURL(theURI, theEvent, theTabPref, theBGPref, thePostData, aAllowThirdPartyFixup) { var newTab, origTab, originCharset = null, isBlankTab, isAltKey = false; if (gBrowser.localName != "tabbrowser") { // _content is deprecated somewhere loadURI(theURI, null, thePostData, aAllowThirdPartyFixup); _content.focus(); return; } else { var currentURI = gBrowser.selectedBrowser.webNavigation.currentURI; var url = currentURI ? currentURI.spec : "about:blank"; originCharset = url != "about:blank" ? gBrowser.selectedBrowser.contentDocument.characterSet : null; } // open link in new tab, either because theTabPref is true or because // the user used the Alt key on the URL bar isAltKey = (theEvent instanceof Event && ('altKey' in theEvent && theEvent.altKey)); if (TMP_whereToOpen(theTabPref, isAltKey).inNew) { // FIXED: restore the URL bar origTab = gBrowser.selectedTab; TMP_handleURLBarRevert(origTab); // FIXED: don't send the referrer, this may be a security hole and // clutters server logs; thanks go to jruderman try { var lastBrowser = gBrowser.mPanelContainer.lastChild.firstChild; newTab = gBrowser.addTab(theURI, null, originCharset, thePostData, null, aAllowThirdPartyFixup); } catch (e) { // remove the new tab if after the new tab was opened the url failed to load var newLastBrowser = gBrowser.mPanelContainer.lastChild.firstChild; if (newLastBrowser != lastBrowser) { newTab = gBrowser.getTabForBrowser(newLastBrowser); gBrowser.removeTab(newTab); } return; } gBrowser.TMP_selectNewForegroundTab(newTab, theBGPref); // in Firefox 1.5, markLinkVisited() has been removed if (theEvent instanceof Event && "markLinkVisited" in window) TMP_markLinkVisited(theURI, theEvent.target); } // not opening in a new tab at all else loadURI(theURI, null, thePostData, aAllowThirdPartyFixup); // _content is deprecated somewhere _content.focus(); if (theEvent instanceof Event) { theEvent.preventDefault(); theEvent.stopPropagation(); } return; } /** * @brief Revert the URL bar to the URL of the currently selected browser. * * This was borrowed from chrome/browser.jar!/content/browser/browser.js:1840 * * If "ESC" is pressed in the url bar, we replace the urlbar's value * with the url of the page, unless it is about:blank, where we reset * it to "". * * @returns true if the URL bar dropdown is open, * false if not. * */ function TMP_handleURLBarRevert(browserTab) { var url; if (browserTab == null) { url = getWebNavigation().currentURI.spec; } else { // use the browserTab's currentURI instead url = gBrowser.getBrowserForTab(browserTab).webNavigation.currentURI.spec; } var throbberElement = document.getElementById("navigator-throbber"); var isScrolling = gURLBar.popupOpen; // don't revert to last valid url unless page is NOT loading // and user is NOT key-scrolling through autocomplete list if ((!throbberElement || !throbberElement.hasAttribute("busy")) && !isScrolling) { if (url != "about:blank" || content.opener) { gURLBar.value = url; SetPageProxyState("valid"); } else { //if about:blank, urlbar becomes "" gURLBar.value = ""; SetPageProxyState("invalid"); } } gBrowser.userTypedValue = null; // tell widget to revert to last typed text only if the user // was scrolling when they hit escape return !isScrolling; } /** * @brief Perform URI fixup on potentially broken URLs before * passing them to markLinkVisited. * * NOTE: * in Firefox 1.5, markLinkVisited() has been removed and * superseded by core history code that takes care of marking * links visited. * * @param url A URL string. * @param linkNode A DOM node that contains the URL string. * @returns Nothing. * */ function TMP_markLinkVisited(url, linkNode) { var visitedURI = gURIFixer.createFixupURI(url, 0); // if (self.markLinkVisited && visitedURI && linkNode) { if (visitedURI && linkNode) { markLinkVisited(visitedURI.spec, linkNode); } return; } // openUILink handles clicks on UI elements that cause URLs to load. function TMP_openUILink( url, e, ignoreButton, ignoreAlt, allowKeywordFixup, postData, referrerUrl) { var where = whereToOpenLink(e, ignoreButton, ignoreAlt); var win = getTopWin(); var lastBrowser; if (win) { lastBrowser = win.gBrowser.mPanelContainer.lastChild.firstChild; // don't open blanke tab when we are about to add new livemark var _addLivemark = /^feed:/.test(url) && gPref.getCharPref("browser.feeds.handler") == "bookmarks"; if (where == "current" && TMP_openUILink.caller.name != "openTopWin" && !_addLivemark) where = win.TMP_checkCurrent(url); } try { openUILinkIn(url, where, allowKeywordFixup, postData, referrerUrl); } catch (ex) { if (!win) return; var newLastBrowser = win.gBrowser.mPanelContainer.lastChild.firstChild; if (where == "tab" && newLastBrowser != lastBrowser) { var newTab = win.gBrowser.getTabForBrowser(newLastBrowser); win.gBrowser.removeTab(newTab); } } } function TMP_checkCurrent(url) { if (gBrowser.mCurrentTab.hasAttribute("locked")) { var isBlankTab = gBrowser.isBlankNotBusyTab(gBrowser.mCurrentTab); if (!isBlankTab) return "tab"; } else if (gPref.getIntPref("extensions.tabmix.speLink") == 2 ) { // Get current page url var curpage = gBrowser.mCurrentBrowser.webNavigation.currentURI.spec; var domain = checkDomain(curpage, url); if (domain.current && domain.target && domain.target != domain.current) return "tab"; } return "current"; } PK 8content/tabmixplus/minit/PK H53 'content/tabmixplus/minit/autoReload.xul %tabmixDTD; %miscDTD; ]> PK 8c8t#xsxs!content/tabmixplus/minit/minit.js//code from Dorando and Sboulema's MiniT+, modified by Hemiola SUN // modified by onemen const DRAG_LINK = 0; const DRAG_TAB_TO_NEW_WINDOW = 1; const DRAG_TAB_IN_SAME_WINDOW = 2; window.addEventListener("load", TMP_miniT_init, false); function TMP_miniT_init() { if (typeof(tablib)=="undefined") return; window.removeEventListener("load", TMP_miniT_init, false); // don't load tabmix into undock sidebar opened by ezsidebar extension var wintype = window.document.documentElement.getAttribute("windowtype"); if (wintype == "mozilla:sidebar") return; // init tabmix functions tablib.init(); TM_init(); TMP_LastTab.init(); TMP_TBP_init(); tabxOnLoad(); window.addEventListener("unload", TM_deinit, false); //this window open form duplicateInWindow or delayRestoreTab if (window.duplicat) NW_waitForSessionHistory(); // dragging tab gBrowser.mStrip.setAttribute("ondraggesture", "TMP_TabDragGesture(event);"); gBrowser.mStrip.setAttribute("ondragover", "TMP_TabDragOver(event);"); gBrowser.mStrip.setAttribute("ondragdrop", "TMP_TabDragDrop(event);"); gBrowser.mStrip.setAttribute("ondragexit", "TMP_TabDragExit(event);"); // for Firefox Dragmark gBrowser.mTabDropIndicatorBar.addEventListener('dragover', TMP_TabDragOver, true); gBrowser.mTabDropIndicatorBar.addEventListener('dragdrop', TMP_TabDragDrop, true); // insert vide-bar after update mTabDropIndicatorBar to prevent bug 398254 // Bug 398254 Since the landing of 372769, I can no longer drag and drop tabs with TabMixPlus gBrowser.mTabBox.insertBefore(document.getElementById('vide-bar'), gBrowser.mTabBox.firstChild); var stringBundle = document.getElementById("tmp-string-bundle"); TabDNDObserver.draglink = stringBundle.getString("droplink.label") } /////////////////////////////////////////////////////////////////////////// //// Drag and Drop observers function TMP_TabDragGesture(aEvent) { nsDragAndDrop.startDrag(aEvent, TabDNDObserver); aEvent.stopPropagation(); } function TMP_TabDragOver(aEvent) { nsDragAndDrop.dragOver(aEvent, TabDNDObserver); aEvent.stopPropagation(); } function TMP_TabDragDrop(aEvent) { nsDragAndDrop.drop(aEvent, TabDNDObserver); aEvent.stopPropagation(); } function TMP_TabDragExit(aEvent) { nsDragAndDrop.dragExit(aEvent, TabDNDObserver); aEvent.stopPropagation(); } var TabDNDObserver = { gBackupLabel: "", gMsg: null, draglink: "", lastTime: 0, onDragStart: function (event, transferData, action) { if(event.target.localName != "tab" || event.originalTarget.localName == "toolbarbutton") return; for ( var i = 0; i < gBrowser.mTabs.length; i++ ) gBrowser.mTabs[i].setAttribute("showbutton","off"); transferData.data = new TransferData(); var URI = gBrowser.getBrowserForTab(event.target).currentURI; if (URI) { transferData.data.addDataForFlavour("text/x-moz-url", URI.spec + "\n" + event.target.label); transferData.data.addDataForFlavour("text/unicode", URI.spec); transferData.data.addDataForFlavour("text/html", '' + event.target.label + ''); } else { transferData.data.addDataForFlavour("text/unicode", "about:blank"); } }, getSupportedFlavours : function () { var flavourSet = new FlavourSet(); flavourSet.appendFlavour("text/x-moz-url"); flavourSet.appendFlavour("text/unicode"); flavourSet.appendFlavour("application/x-moz-file", "nsIFile"); return flavourSet; }, canDrop: function (aEvent, aDragSession) { if (aDragSession.sourceNode && aDragSession.sourceNode.parentNode == gBrowser.mTabContainer) { var sourceBo = aDragSession.sourceNode.boxObject; if (aEvent.screenX >= sourceBo.screenX && aEvent.screenX <= (sourceBo.screenX +sourceBo.width) && aEvent.screenY >= sourceBo.screenY && aEvent.screenY <= (sourceBo.screenY +sourceBo.height)) return false; } return true; }, onDragOver: function minit_onDragOver(event, flavours, session) { var draggeType = this.getDragType(session); var newIndex = this.getNewIndex(event); var oldIndex = draggeType != DRAG_LINK ? session.sourceNode._tPos : -1; var left_right; // 1:right, 0: left, -1: drop link on tab to replace tab if (newIndex < gBrowser.mTabs.length) left_right = this.getLeft_Right(event, newIndex, oldIndex, draggeType); else { newIndex = draggeType != DRAG_TAB_IN_SAME_WINDOW && tabxPrefs.getBoolPref("openTabNext") ? gBrowser.mTabContainer.selectedIndex : gBrowser.mTabs.length - 1; left_right = 1; } var replaceTab = false; // don't allow to drop on lock tab unless the tab is blanck or the user press Ctrl/Meta Key or we drop link that start dounload if (left_right == -1) { // check if tab is lock replaceTab = true; var aTab = gBrowser.mTabs[newIndex]; var accelKeyPressed = event.ctrlKey || event.metaKey; if (!accelKeyPressed && aTab.getAttribute("locked") && !gBrowser.isBlankNotBusyTab(aTab)) { var disAllowDrop = true; try { var trans = Cc["@mozilla.org/widget/transferable;1"] .createInstance(Ci.nsITransferable); trans.addDataFlavor("text/unicode"); trans.addDataFlavor("text/x-moz-url"); session.getData(trans, 0); var data = { }, type = { }; trans.getAnyTransferData(type, data, { }); if (data) { data = data.value.QueryInterface(Ci.nsISupportsString).data; var url = transferUtils.retrieveURLFromData(data, type.value); disAllowDrop = !isUrlForDownload(url); } } catch (ex) { } if(disAllowDrop) session.canDrop = false; } } if (draggeType == DRAG_TAB_IN_SAME_WINDOW && oldIndex == newIndex) session.canDrop = false; if (session.canDrop && !this.isValidTarget(event, session)) return; // show Drag & Drop message if (draggeType == DRAG_LINK) { // no gNavigatorBundle.getString("droponnewtabbutton") in 1.0.7 this.gMsg = event.originalTarget.id == "tabs-newbutton" && "mTabDropIndicatorBar" in gBrowser ? gNavigatorBundle.getString("droponnewtabbutton") : this.draglink; var statusTextFld = document.getElementById("statusbar-display"); if (statusTextFld.label != this.gMsg) { if (this.gBackupLabel=="") this.gBackupLabel = statusTextFld.label; statusTextFld.label = this.gMsg; } } if(!session.canDrop) { this.clearDragmark(); return; } var hideIndicator = false; var tabStripBoxObject = gBrowser.mTabContainer.tabstrip.boxObject; var index = newIndex+left_right-1; var newTime; if ( event.clientX <= tabStripBoxObject.x && !gBrowser.mTabContainer.hasAttribute("disableScrollTabsLeft") ) { newTime = new Date().getTime(); if (newTime - this.lastTime > 100) { gBrowser.mTabContainer.tabsScroll(-1); this.lastTime = newTime; } hideIndicator = true; } else if( event.target.localName != "tab" && event.clientX >= (tabStripBoxObject.x + tabStripBoxObject.width) && !gBrowser.mTabContainer.hasAttribute("disableScrollTabsRight") ) { newTime = new Date().getTime(); if (newTime - this.lastTime > 100) { gBrowser.mTabContainer.tabsScroll(1); this.lastTime = newTime; } hideIndicator = true; } //xxx check later if we need this else if (draggeType != DRAG_TAB_IN_SAME_WINDOW && !replaceTab && event.target.localName != "tab") { // only drop if tab is visible var dropLinkonTabbar = gBrowser.mTabContainer.isTabVisible(newIndex) && (event.target.localName == "tabs" || event.target == gBrowser.mTabDropIndicatorBar.firstChild ); hideIndicator = !dropLinkonTabbar; session.canDrop = dropLinkonTabbar; } // xxx check later if we need this else if (index > 0 && !gBrowser.mTabContainer.isTabVisible(index) && !gBrowser.mTabs[index].collapsed && !gBrowser.mTabContainer.hasAttribute("disableScrollTabsRight")) { newTime = new Date().getTime(); if (newTime - this.lastTime > 100) { gBrowser.mTabContainer.tabsScroll(1); this.lastTime = newTime; } hideIndicator = true; } if ( replaceTab || hideIndicator ) { this.clearDragmark(); return; } this.setDragmark(newIndex, left_right); if (gIsFirefox3 && draggeType == DRAG_LINK && event.target.localName == "tab") { if (!gBrowser.mDragTime) gBrowser.mDragTime = Date.now(); if (Date.now() >= gBrowser.mDragTime + gBrowser.mDragOverDelay) gBrowser.mTabContainer.selectedItem = event.target; return; } }, onDrop: function minit_onDrop(event, dropData, session) { this.clearDragmark(); var draggeType = this.getDragType(session); var accelKeyPressed = event.ctrlKey || event.metaKey; var draggedTab; if (draggeType != DRAG_LINK) draggedTab = session.sourceNode; var newIndex = this.getNewIndex(event); var oldIndex = draggedTab ? draggedTab._tPos : -1; var left_right; if (newIndex < gBrowser.mTabs.length) left_right = this.getLeft_Right(event, newIndex, oldIndex, draggeType); else { newIndex = draggeType != DRAG_TAB_IN_SAME_WINDOW && tabxPrefs.getBoolPref("openTabNext") ? gBrowser.mTabContainer.selectedIndex : gBrowser.mTabs.length - 1; left_right = 1; } if (draggedTab && (accelKeyPressed || draggeType == DRAG_TAB_IN_SAME_WINDOW)) { if (accelKeyPressed) { // copy the dropped tab (wherever it's from) var newTab = gBrowser.duplicateTab(draggedTab); gBrowser.moveTabTo(newTab, newIndex + left_right); if (draggeType == DRAG_TAB_TO_NEW_WINDOW || event.shiftKey) gBrowser.selectedTab = newTab; } else { // move the dropped tab newIndex += left_right - (newIndex > oldIndex); if (newIndex != draggedTab._tPos) gBrowser.moveTabTo(draggedTab, newIndex); } draggedTab.collapsed = false; if ( gBrowser.mTabContainer.getAttribute("flowing") == "multibar" && gBrowser.mTabContainer.getAttribute("multibar") == "scrollbar" && oldIndex < gBrowser.mTabContainer.collapsedTabs ) gBrowser.mTabs[gBrowser.mTabContainer.collapsedTabs-1].collapsed = true; gBrowser.mTabContainer.ensureTabIsVisible(newIndex); checkBeforeAndAfter(); } else if (draggedTab) { // copy the dropped tab and remove it from the other window // (making it seem to have moved between windows) var sourceWindow = draggedTab.ownerDocument.defaultView; var remoteBrowser = sourceWindow.getBrowser(); var tabCount = remoteBrowser.tabContainer.childNodes.length; /* * In Firefox 2.0 when we move the current tab select other tab in surece window * before the new window get the focus, this will prevent the focus to jump back * to the surece window from the new window when gBrowser.removetab select new tab. */ if (!gIsFirefox3 && tabCount > 1 && draggedTab == remoteBrowser.mCurrentTab) { var newIndex = remoteBrowser.selectIndexAfterRemove(draggedTab); remoteBrowser.selectedTab = remoteBrowser.mTabContainer.childNodes[newIndex]; } newTab = gBrowser.duplicateTab(draggedTab); gBrowser.moveTabTo(newTab, newIndex + left_right); gBrowser.selectedTab = newTab; remoteBrowser.removeTab(draggedTab); // close the other window if gBrowser was its last tab if (tabCount == 1) draggedTab.ownerDocument.defaultView.close(); } else { var url = transferUtils.retrieveURLFromData(dropData.data, dropData.flavour.contentType); // valid urls don't contain spaces ' '; if we have a space it isn't a valid url. // Also disallow dropping javascript: or data: urls--bail out if (!url || !url.length || url.indexOf(" ", 0) != -1 || /^\s*(javascript|data):/.test(url)) return; // in firefox 3.0 dragDropSecurityCheck moved from gBrowser to nsDragAndDrop if (gIsFirefox3) nsDragAndDrop.dragDropSecurityCheck(event, session, url); else gBrowser.dragDropSecurityCheck(event, session, url); var bgLoad = true; try { bgLoad = gBrowser.mPrefs.getBoolPref("browser.tabs.loadInBackground"); } catch (e) { } if (event.shiftKey) bgLoad = !bgLoad; // shift Key reverse the pref url = getShortcutOrURI(url); var tab = null; if (left_right > -1 && !isUrlForDownload(url)) { // We're adding a new tab. try { tab = gBrowser.addTab(url); gBrowser.moveTabTo(tab, newIndex + left_right); } catch(ex) { // Just ignore invalid urls tmLog("addTab\n" + ex); return; } } else { // Load in an existing tab. tab = event.target.localName == "tab" ? event.target : gBrowser.mTabs[newIndex]; try { gBrowser.getBrowserForTab(tab).loadURI(url); } catch(ex) { // Just ignore invalid urls tmLog("load\n" + ex); return; } } if (gBrowser.mCurrentTab != tab) gBrowser.TMP_selectNewForegroundTab(tab, bgLoad, url); } }, onDragExit: function (event, session) { gBrowser.mDragTime = 0; this.isValidTarget(event, session); }, isValidTarget: function (event, session) { if ( event.clientY <= gBrowser.mStrip.boxObject.y+1 || event.clientX < gBrowser.mStrip.boxObject.x || event.clientY >= gBrowser.mStrip.boxObject.y + gBrowser.mStrip.boxObject.height) { if (document.getElementById("statusbar-display").label == this.gMsg) { document.getElementById("statusbar-display").label = this.gBackupLabel; this.gBackupLabel=""; } this.clearDragmark(event); session.canDrop = false; return false; } return true; }, getNewIndex: function (event) { // start to chack after collapsedTabs // if X is less then the first tab return 0 // check if the tab is visible... if not return gBrowser.mTabs.length // check if Y is below the tab.... if yes go to next row // in the row find the closest tab by X, // if no tab is match return gBrowser.mTabs.length var mX = event.clientX, mY = event.clientY; var i, aTab, tabs = gBrowser.mTabContainer.childNodes; var collapsed = gBrowser.mTabContainer.collapsedTabs; if ( !gBrowser.mTabContainer.hasAttribute("multibar") ) { for (i = event.target.localName == "tab" ? event.target._tPos : collapsed; i < gBrowser.mTabs.length; i++) if (mX < tabs[i].boxObject.x + tabs[i].boxObject.width) return i; } else { for (i = collapsed; i < tabs.length; i++) { if (!gBrowser.mTabContainer.isTabVisible(i)) return tabs.length; aTab = tabs[i]; if (mY >= aTab.baseY) { while (i < tabs.length - 1 && inSameRow(aTab, tabs[i+1]) ) i++; } else if (mX < aTab.boxObject.x + aTab.boxObject.width ) return i; else if (i == tabs.length - 1 || !inSameRow(aTab, tabs[i+1]) ) return i; } } return tabs.length; }, getLeft_Right: function (event, newIndex, oldIndex, draggeType) { var clientX = event.clientX; var left_right, tabBo = gBrowser.mTabs[newIndex].boxObject; if (draggeType == DRAG_LINK) { left_right = (clientX < tabBo.x + tabBo.width / 4 ) ? 0 : 1; if (left_right == 1 && clientX < tabBo.x + tabBo.width * 3 / 4 ) left_right = -1; } else { left_right = ( clientX < tabBo.x + tabBo.width / 2 ) ? 0 : 1; var isCtrlKey = ((event.ctrlKey || event.metaKey) && !event.shiftKey && !event.altKey); if (!isCtrlKey && draggeType == DRAG_TAB_IN_SAME_WINDOW) { if (newIndex == oldIndex - 1) left_right = 0; else if (newIndex == oldIndex + 1) left_right = 1; } } return left_right; }, getDragType: function minit_onDrop(session) { if (session.sourceNode && session.sourceNode.localName == "tab") { if (session.sourceNode.parentNode == gBrowser.mTabContainer) return DRAG_TAB_IN_SAME_WINDOW; // 2 if (session.sourceNode.ownerDocument.defaultView instanceof ChromeWindow && session.sourceNode.ownerDocument.documentElement.getAttribute("windowtype") == "navigator:browser") return DRAG_TAB_TO_NEW_WINDOW; // 1 } return DRAG_LINK; // 0 }, setDragmark: function (index, left_right) { var newIndex = index + left_right; if (gBrowser.hasAttribute("dragmarkindex") && gBrowser.getAttribute("dragmarkindex") == newIndex) return; this.clearDragmark();// clear old dragmark if one exist if (!tabxPrefs.getBoolPref("useFirefoxDragmark")) { var sameRow = newIndex != 0 && newIndex != gBrowser.mTabs.length && inSameRow(gBrowser.mTabs[newIndex-1], gBrowser.mTabs[newIndex]); if (sameRow || left_right==0) this.setDragmarkAttribute(gBrowser.mTabs[newIndex], "atLeft"); if (sameRow || left_right==1) this.setDragmarkAttribute(gBrowser.mTabs[newIndex-1], "atRight"); } else { // code for firefox indicator var ib = gBrowser.mTabDropIndicatorBar; var ind = ib.firstChild; this.setFirefoxDropIndicator(true); var tabStripBoxObject = gBrowser.mTabContainer.tabstrip.boxObject; var halfIndWidth = gIsFirefox3 ? 0 : Math.floor((ind.boxObject.width + 1) / 2); var minMarginLeft = tabStripBoxObject.x - halfIndWidth - (gIsFirefox3 ? gBrowser.boxObject.x : ib.boxObject.x); var maxMarginLeft = Math.min((minMarginLeft + tabStripBoxObject.width), (ib.boxObject.x + ib.boxObject.width - ind.boxObject.width)); if (gTabbarPosition == 0) this.setFirefoxDropIndicator(false); var newMarginLeft; if ( left_right == 0 ) newMarginLeft = gBrowser.mTabs[newIndex].boxObject.screenX - gBrowser.boxObject.screenX - halfIndWidth; else newMarginLeft = gBrowser.mTabs[index].boxObject.screenX + gBrowser.mTabs[index].boxObject.width - gBrowser.boxObject.screenX - halfIndWidth; // ensure we never place the drop indicator beyond our limits if (newMarginLeft < minMarginLeft) newMarginLeft = minMarginLeft; else if (newMarginLeft > maxMarginLeft) newMarginLeft = maxMarginLeft; ind.style.marginLeft = newMarginLeft + 'px'; if ( gTabbarPosition == 1) { ind.style.marginTop = gBrowser.mTabs[index].boxObject.screenY - ib.boxObject.screenY + "px"; ind.style.backgroundPosition = "50% 0%"; } else { var offset = gFirefox2DefaultTheme ? -3 : 0; ind.style.marginBottom = gBrowser.mTabContainer.boxObject.screenY - gBrowser.mTabs[index].boxObject.screenY + offset + "px"; ind.style.backgroundPosition = "50% 100%"; this.setFirefoxDropIndicator(true); } } gBrowser.setAttribute("dragmarkindex", newIndex); }, clearDragmark: function () { if (!gBrowser.hasAttribute("dragmarkindex")) return; if (!tabxPrefs.getBoolPref("useFirefoxDragmark")) { var index = gBrowser.getAttribute("dragmarkindex"); if (index != gBrowser.mTabs.length && gBrowser.mTabs[index].hasAttribute("dragmark")) this.removetDragmarkAttribute(gBrowser.mTabs[index]); if (index != 0 && gBrowser.mTabs[index-1].hasAttribute("dragmark")) this.removetDragmarkAttribute(gBrowser.mTabs[index-1]); } else this.setFirefoxDropIndicator(false); gBrowser.removeAttribute("dragmarkindex"); }, // since bug 390979 landed (2007-09-17) firefox use collapsed instead of visibility to show the tab drop indicator setFirefoxDropIndicator: function (val) { var ib = gBrowser.mTabDropIndicatorBar; if (gIsFirefox3) ib.collapsed = !val; else ib.setAttribute('dragging',val); }, removetDragmarkAttribute: function (tab) { tab.removeAttribute("dragmark"); if (TMP_getBoolPref(tabxBranch, "flexTabs", false) && TMP_getIntPref(tabxBranch, "maxWidth", 250) != TMP_getIntPref(tabxBranch, "minWidth", 30) && tab.hasAttribute("width")) window.setTimeout( function (aTab) {aTab.removeAttribute("width");}, 0, tab); }, setDragmarkAttribute: function (tab, markSide) { if (TMP_getBoolPref(tabxBranch, "flexTabs", false) && TMP_getIntPref(tabxBranch, "maxWidth", 250) != TMP_getIntPref(tabxBranch, "minWidth", 30)) tab.setAttribute("width", tab.boxObject.width); tab.setAttribute("dragmark", markSide); } } // TabDNDObserver end function TMP_goButtonClick(event) { // if go-Button has oncommand attribute we are befor bug 279687 landed if (!event.target.hasAttribute('oncommand') && event.button == 0) handleURLBarCommand(event); else if(event.button == 1) { // when user middle-click on go-Button duplicate current tab // unless the user typed value into the address bar var postData = { }; canonizeUrl(event, postData); var url = gURLBar.value; if (url == gBrowser.currentURI.spec) gBrowser.duplicateTab(gBrowser.mCurrentTab); else { gURLBar.value = gBrowser.currentURI.spec; gBrowser.userTypedValue = null; openUILink(url, event, false, false, true, postData.value); } } } function TM_BrowserHome() { var homePage = gHomeButton.getHomePage(); if (TMP_whereToOpen(false).inNew) { var urls = homePage.split("|"); var firstTabAdded = gBrowser.addTab(urls[0]); var bgLoad = getBoolPref("browser.tabs.loadBookmarksInBackground", false); content.focus(); gBrowser.TMP_selectNewForegroundTab(firstTabAdded, bgLoad, urls[0]); for (var i = 1; i < urls.length; ++i) gBrowser.addTab(urls[i]); } else loadOneOrMoreURIs(homePage); } var undocloseTabButtonObserver = { onDragOver: function(aEvent, aFlavour, aDragSession) { var aLocalName = aDragSession.sourceNode ? aDragSession.sourceNode.localName : null; if (aLocalName!="tab") { aDragSession.canDrop = false; return true; } var statusTextFld = document.getElementById("statusbar-display"); var stringBundle = document.getElementById("tmp-string-bundle"); statusTextFld.label = stringBundle.getString("droptoclose.label"); aEvent.target.setAttribute("dragover", "true"); return true; }, onDragExit: function (aEvent, aDragSession) { var aLocalName = aDragSession.sourceNode ? aDragSession.sourceNode.localName : null; if (aLocalName!="tab") return; var statusTextFld = document.getElementById("statusbar-display"); statusTextFld.label = ""; aEvent.target.removeAttribute("dragover"); }, onDrop: function (aEvent, aXferData, aDragSession) { var aLocalName = aDragSession.sourceNode ? aDragSession.sourceNode.localName : null; if (aLocalName=="tab") gBrowser.removeTab(aDragSession.sourceNode); }, getSupportedFlavours: function () { var flavourSet = new FlavourSet(); flavourSet.appendFlavour("text/x-moz-url"); return flavourSet; } } const prefStringTMHistory = "extensions.tabmix.opentabfor.history"; const NC_NS_TM = "http://home.netscape.com/NC-rdf#"; const prefStringTMUseMiddleClick = "extensions.tabmix.middlecurrent"; const prefStringTMBookmark = "extensions.tabmix.opentabfor.bookmarks"; function isBookmarkletTM(aSelection, aDS) { if (aSelection && (aSelection.length == 1) && ((aSelection.type[0] == "Bookmark") || (aSelection.type[0] == "ImmutableBookmark"))) { var jsURL = /^ *javascript:/; return jsURL.test(BookmarksUtils.getProperty(aSelection.item[0], NC_NS_TM+"URL", aDS)); } else return false; } function openInWebPanelTM(aSelection, aDS) { if (aSelection && (aSelection.length == 1) && ((aSelection.type[0] == "Bookmark") || (aSelection.type[0] == "ImmutableBookmark"))) return BMDS.GetTarget(aSelection.item[0], RDF.GetResource(NC_NS_TM + "WebPanel"), true); else return false; } function whereToOpenLinkTabmix(aEvent, prefString, aSelection, aDS) { var w = getTopWin(); if (!w) return "window"; var browserTarget = aEvent ? whereToOpenLink(aEvent) : "current"; var topBrowser = w.document.getElementById("content"); var prefService = Components.classes['@mozilla.org/preferences-service;1'] .getService(Components.interfaces.nsIPrefService).getBranch(null); if ((prefService.getBoolPref(prefString) || topBrowser.mCurrentTab.hasAttribute("locked")) && !isBookmarkletTM(aSelection, aDS) && !openInWebPanelTM(aSelection, aDS)) { var _button = aEvent instanceof MouseEvent ? aEvent.button : 0; if (aEvent && prefService.getBoolPref(prefStringTMUseMiddleClick) && (_button == 1 || _button == 0 && (aEvent.ctrlKey || aEvent.metaKey))) browserTarget = "current"; else { if ((browserTarget == "current") && (topBrowser.mCurrentBrowser.webProgress.isLoadingDocument || (topBrowser.mCurrentBrowser.currentURI.spec != "about:blank"))) browserTarget = "tab"; } } return browserTarget; } function TMP_update_whereToOpen() { //inverse focus of middle/ctrl/meta clicked bookmarks/history eval("whereToOpenLink ="+whereToOpenLink.toString().replace( 'var middle = !ignoreButton && e.button == 1;', 'var middle = e instanceof MouseEvent && !ignoreButton && e.button == 1;' ).replace( 'if (shift)', 'var inversefocus = getBoolPref("extensions.tabmix.inversefocusOther", true);\ if (inversefocus || (!inversefocus && shift))' )); } function TMP_whereToOpen(pref, altKey) { var aTab = gBrowser.mCurrentTab; var isBlankTab = gBrowser.isBlankNotBusyTab(aTab); var isLockTab = !isBlankTab && aTab.hasAttribute("locked"); var openTabPref = typeof(pref) == "string" ? gPref.getBoolPref(pref) : pref; if (typeof(altKey) != "undefined") { // don't reuse balnk tab if the user press alt key when the pref is to open in current tab if (altKey && !openTabPref) isBlankTab = false; // see bug 315034 If search is set to open in a new tab, // Alt+Enter should open the search result in the current tab // so here we reverse the pref if user press Alt key openTabPref = (altKey ^ openTabPref) == 1; } return { inNew: !isBlankTab && (isLockTab || openTabPref), lock: isLockTab }; } // update context menu for bookmarks manager and sidebar // for bookmarks/places, history, sage and more..... function TMP_updateContextMenu(open, openInWindow, openInTab, pref) { // if all 3 was hidden ... probably "Open all in Tabs" is visible if (open.hidden && openInWindow.hidden && openInTab.hidden) return; var w = getTopWin(); if (w) { var where = w.TMP_whereToOpen(pref); if (!openInWindow.hidden && w.gSingleWindowMode) openInWindow.hidden = true; else if (openInWindow.hasAttribute("default")) openInWindow.removeAttribute("default"); TMP_setItem(openInTab, "default", where.inNew ? "true" : null); if (open.hidden != where.lock) open.hidden = where.lock; if (!open.hidden) TMP_setItem(open, "default", !where.inNew ? "true" : null); } else { open.hidden = true; openInTab.hidden = true; openInWindow.hidden = false; openInWindow.setAttribute("default", true); } } // Show/hide one item (specified via name or the item element itself). function TMP_showItem (aItemOrId, aShow) { var item = typeof(aItemOrId) == "string" ? document.getElementById(aItemOrId) : aItemOrId; if (item) item.hidden = !aShow; } function TMP_setItem(aItemOrId, aAttr, aVal) { var elem = typeof(aItemOrId) == "string" ? document.getElementById(aItemOrId) : aItemOrId; if (elem) { if (aVal == null) { elem.removeAttribute(aAttr); } else if (elem.getAttribute(aAttr) != aVal) { elem.setAttribute(aAttr, aVal); } } } PK \8+wvv*content/tabmixplus/minit/setFixedLabel.xul %tabmixDTD; %miscDTD; ]> PK 8?<"content/tabmixplus/minit/tablib.js// code modified by Hemiola SUN, 2005-04-14 and fixed by onemen if(!window.tablib || tablib.version != "tabmixplus") var tablib = { version : "tabmixplus", _inited: false, init : function(){ if (this._inited) return; this._inited = true; if(gBrowser.mTabs.length > 0) gBrowser.mCurrentTab.__selected = true; eval("gBrowser.addTab ="+gBrowser.addTab.toString().replace( 't.setAttribute("label", aURI);', 't.setAttribute("label", widthFitTitle ? this.mStringBundle.getString("tabs.loading") : aURI);' ).replace( 't.maxWidth = 250;', 't.maxWidth = this.mTabContainer.mTabMaxWidth;' ).replace( 't.width = 0;', 't.style.maxWidth = t.maxWidth + "px";' ).replace( 't.setAttribute("flex", "100");', 'if (!widthFitTitle) { \ t.width = 0; \ $& \ } else t.setAttribute("newtab", "true");' ).replace( 'if (!blank)', 'this.TMP_openTabNext(t, blank, this.addTab.caller.name);\ $&' )); eval("gBrowser.removeTab ="+gBrowser.removeTab.toString().replace( 'var l = this.mTabContainer.childNodes.length;', 'if (aTab.hasAttribute("protected")) return; $&' ).replace( 'var oldTab = aTab;', '$& saveClosedTab(oldTab, oldBrowser); \ var tabmixIndex = this.selectIndexAfterRemove(oldTab); if (tabmixIndex > oldTab._tPos) tabmixIndex--;\ SessionManager.tabClosed(oldTab);' ).replace( 'this.selectedTab = this.mTabContainer.childNodes[newIndex];', 'this.mTabContainer.nextTab = 1; newIndex = tabmixIndex; $&' ).replace( 'this.addTab("about:blank");', 'if (this.mPrefs.getBoolPref("extensions.tabmix.keepLastTab")) \ return; \ $& \ setURLBarFocus();' )); // Fx 3.0 after bug 370742 "selectNewTab" method replaced by "_selectNewTab" var selectNewTab = gIsFirefox3 ? "_selectNewTab": "selectNewTab"; eval("gBrowser.mTabContainer." + selectNewTab + " ="+gBrowser.mTabContainer[selectNewTab].toString().replace( '{', '{ if(!gPref.getBoolPref("extensions.tabmix.mouseDownSelect") && arguments.callee.caller.name == "setTab") return; ' )); eval("BrowserCloseTabOrWindow ="+BrowserCloseTabOrWindow.toString().replace( /closeWindow\(true\);/g, 'closeLastTab();' ).replace( /gBrowser.removeCurrentTab\(\);/g, 'closeLastTab();' ).replace( 'BrowserCloseWindow();', 'closeLastTab();' )); function closeLastTab() { if (/^Mac/.test(navigator.platform) && window.location.href != getBrowserURL()) { closeWindow(true); return; } if (gBrowser.tabContainer.childNodes.length > 1 || gPref.getBoolPref("extensions.tabmix.keepWindow")) gBrowser.removeCurrentTab(); else TMP_BrowserCloseWindow(); } //don't open link from external application in new window when in single window mode //don't open link from external application in current tab if the tab is locked eval("nsBrowserAccess.prototype.openURI ="+nsBrowserAccess.prototype.openURI.toString().replace( 'switch (aWhere) {', 'if (gSingleWindowMode && aWhere == Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW) {;\ aWhere = Ci.nsIBrowserDOMWindow.OPEN_NEWTAB;}\ if (aWhere != Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW && aWhere != Ci.nsIBrowserDOMWindow.OPEN_NEWTAB){\ var isLockTab = TMP_whereToOpen(null).lock; if(isLockTab) aWhere = Ci.nsIBrowserDOMWindow.OPEN_NEWTAB;}\ $&' )); // reuse current tab if it's blank tab for external link set to open new tab if (gIsFirefox3) { eval("nsBrowserAccess.prototype.openURI ="+nsBrowserAccess.prototype.openURI.toString().replace( 'var newTab = win.gBrowser.loadOneTab("about:blank", null, null, null, loadInBackground, false);', 'var currentIsBlank = win.gBrowser.isBlankNotBusyTab(gBrowser.mCurrentTab);\ var newTab = currentIsBlank ? win.gBrowser.mCurrentTab : win.gBrowser.loadOneTab("about:blank", null, null, null, loadInBackground, false);\ if (currentIsBlank) win.content.focus();' )); } else if (gIsFirefox2) { eval("nsBrowserAccess.prototype.openURI ="+nsBrowserAccess.prototype.openURI.toString().replace( 'var newTab = gBrowser.loadOneTab("about:blank", null, null, null, loadInBackground, false);', 'var currentIsBlank = gBrowser.isBlankNotBusyTab(gBrowser.mCurrentTab);\ var newTab = currentIsBlank ? gBrowser.mCurrentTab : gBrowser.loadOneTab("about:blank", null, null, null, loadInBackground, false);\ if (currentIsBlank) content.focus();' )); } //inverse focus of middle/ctrl/meta clicked links eval("openNewTabWith ="+openNewTabWith.toString().replace( 'if (event && event.shiftKey)', 'if (event && (event.button == 1 || event.button == 0 && ( event.ctrlKey || event.metaKey )) && (prefSvc.getBoolPref("extensions.tabmix.inversefocusLinks") || !prefSvc.getBoolPref("extensions.tabmix.inversefocusLinks") && event.shiftKey))' )); // for Firefox 3.0 eval("openNewTabWith ="+openNewTabWith.toString().replace( 'if (aEvent && aEvent.shiftKey)', 'if (aEvent && (aEvent.button == 1 || aEvent.button == 0 && ( aEvent.ctrlKey || aEvent.metaKey )) && (prefSvc.getBoolPref("extensions.tabmix.inversefocusLinks") || !prefSvc.getBoolPref("extensions.tabmix.inversefocusLinks") && aEvent.shiftKey))' )); //use bookmark labels when needed to // not in use for firefox 3.0+ if ("constructGoMenuItem" in window) eval("constructGoMenuItem ="+constructGoMenuItem.toString().replace( 'menuitem.setAttribute("statustext", url);', '$& title = getTitleFromBookmark(url, title);' )); eval("FillHistoryMenu ="+FillHistoryMenu.toString().replace( /entry.title/g, 'menuItemTitle(entry)' )); eval("gBrowser.updateTitlebar ="+gBrowser.updateTitlebar.toString().replace( 'if (!docTitle)', 'var url = this.contentDocument.baseURI || this.currentURI.spec; \ if (this.mCurrentTab.getAttribute("label-uri") == url) docTitle = this.mCurrentTab.getAttribute("fixed-label"); \ else docTitle = getTitleFromBookmark(url, docTitle); \ $&' )); eval("gBrowser.setTabTitle ="+gBrowser.setTabTitle.toString().replace( 'if (!title) {', 'if (widthFitTitle) { var cIndex = this.mTabContainer.selectedIndex; \ var currentTabVisible = this.mTabContainer.isTabVisible(cIndex); } \ var url = browser.contentDocument.baseURI || browser.currentURI.spec; \ if (aTab.getAttribute("label-uri") == url) title = aTab.getAttribute("fixed-label"); \ else title = getTitleFromBookmark(url, title); \ $&' ).replace( 'aTab.setAttribute("crop", crop);', '$& \ if (aTab.hasAttribute("mergeselected")) aTab.label = "(*) "+aTab.label; \ if (widthFitTitle) { \ if (aTab.hasAttribute("width")) aTab.removeAttribute("width"); \ tabBarScrollStatus(); checkBeforeAndAfter(); \ if (currentTabVisible) this.mTabContainer.ensureTabIsVisible(cIndex);}' )); // we use BrowserGoHome from Firfox 3.0 var _homeButton = ("BrowserGoHome" in window) ? "BrowserGoHome" : "BrowserHomeClick"; eval("window[_homeButton] ="+window[_homeButton].toString().replace( 'var where = whereToOpenLink(aEvent);', '$& \ if (where == "current" && TMP_whereToOpen(false).inNew) where = "tab";' )); var searchbar = document.getElementById("searchbar"); // XXX need to fix TMP_SearchLoadURL to work like in Fx 3.0 // #351253 [Firefox:Search]-Search button misinterprets modifiers when clicked [All] // // for firefox 2.0 + // new handleSearchCommand in search.xml version 1.47 from bug 335441 2006-05-06 // Bug 336925: Middle clicking search button should open new tab search.xml version 1.67 if(searchbar && "handleSearchCommand" in searchbar) eval("searchbar.handleSearchCommand ="+searchbar.handleSearchCommand.toString().replace( 'this.doSearch', 'TMP_SearchLoadURL(textValue, aEvent, true); if (aEvent) aEvent.stopPropagation(); return; \ $&' )); // fix webSearch to open new tab if tab is lock if("BrowserSearch" in window) eval("BrowserSearch.webSearch ="+BrowserSearch.webSearch.toString().replace( 'loadURI(searchForm, null, null, false);', 'gBrowser.TMP_openURI(searchForm);' )); gBrowser.TMP_openURI = function (uri) { var openNewTab = TMP_whereToOpen(true).lock; if (openNewTab) this.loadOneTab(uri, null, null, null, false, false); else loadURI(uri, null, null, false); } if ("BrowserCloseWindow" in window) {// BrowserCloseWindow removed for Fx 3.0+ by bug #383760 eval("BrowserCloseWindow ="+BrowserCloseWindow.toString().replace( 'closeWindow', 'SessionManager.deinit(numberOfWindows() == 1, true); $&' )); eval("WindowIsClosing ="+WindowIsClosing.toString().replace( 'var reallyClose = browser.warnAboutClosingTabs(true);', 'var pref = "extensions.tabmix.warnAboutClosingTabs.timeout"; \ var startTime = new Date().valueOf(); \ var oldTime = gPref.prefHasUserValue(pref) ? gPref.getCharPref(pref) : 0; \ var reallyClose = browser.warnAboutClosingTabs("All_onExit"); \ gPref.setCharPref(pref, oldTime*1 + (new Date().valueOf() - startTime));' ).replace( 'return closeWindow(false);', '{ \ var _close = closeWindow(false); \ if (_close) SessionManager.deinit(numberOfWindows() == 1, WindowIsClosing.caller.name != "restartApp"); \ return _close; \ }' )); window.tryToClose = WindowIsClosing; } else { eval("WindowIsClosing ="+WindowIsClosing.toString().replace( 'return closeWindow(false,', 'return TMP_closeWindow(); $&' )); function TMP_closeWindow(){ var _close = closeWindow(false, function () { var pref = "extensions.tabmix.warnAboutClosingTabs.timeout"; var startTime = new Date().valueOf(); var oldTime = gPref.prefHasUserValue(pref) ? gPref.getCharPref(pref) : 0; var _canClose = getBrowser().warnAboutClosingTabs("All_onExit"); gPref.setCharPref(pref, oldTime*1 + (new Date().valueOf() - startTime)); return _canClose; }); if (_close) { var isRestartApp = TMP_closeWindow.caller.caller.name == "restartApp"; SessionManager.deinit(numberOfWindows() == 1, !isRestartApp); } return _close; } } // with MR Tech's local install // don't open trober in current tab when tab is locked // or trober is to diffrent site then the current if (typeof(Local_Install) == "object") eval("Local_Install.openThrobber ="+Local_Install.openThrobber.toString().replace( 'local_common.openURL(local_common.getThrobberURL(), inNewTab);', 'var url = local_common.getThrobberURL(); \ local_common.openURL(url, inNewTab ? inNewTab : TMP_checkCurrent(url) == "tab");' )); // use TMP TMP_ClosedTabs for this function undoCloseMiddleClick(aEvent) { if (aEvent.button != 1) return; undoCloseTab(aEvent.originalTarget.value, "end"); } // hide History > Undoclose tabs if SessionStore disabled eval("HistoryMenu.toggleRecentlyClosedTabs ="+HistoryMenu.toggleRecentlyClosedTabs.toString().replace( 'var undoPopup = document.getElementById("historyUndoPopup");', '$& \ var sessionRestoreDisabled = !window.__SSi; \ if (sessionRestoreDisabled) { \ document.getElementById("historyUndoMenu").setAttribute("hidden", sessionRestoreDisabled); \ var separator = document.getElementById("endUndoSeparator"); \ if (separator) separator.setAttribute("hidden", sessionRestoreDisabled); \ else document.getElementById("endHistorySeparator").setAttribute("hidden", sessionRestoreDisabled); \ return; \ }' )); // add tab image and url in statustext to closed tab list // *** in firefox3 we don't need to add image eval("HistoryMenu.populateUndoSubmenu ="+HistoryMenu.populateUndoSubmenu.toString().replace( 'm.setAttribute("label", undoItems[i].title);', '$& \ var tabData = undoItems[i].state; \ var activeIndex = (tabData.index || tabData.entries.length) - 1; \ var url = tabData.entries[activeIndex].url; \ if (gIsFirefox3) m.node = {uri:url, type:Ci.nsINavHistoryResultNode.RESULT_TYPE_URI}; \ else { \ m.setAttribute("statustext", url); \ if (!url.match(/^https/)) { \ m.setAttribute("image", TMP_SessionStore.getAttribute(tabData.xultab, "image")); \ m.setAttribute("class", "menuitem-iconic bookmark-item"); \ } \ }' ).replace( 'undoPopup.appendChild(document.createElement("menuseparator"));', '$& \ var _string = document.getElementById("tmp-string-bundle");\ m = undoPopup.appendChild(document.createElement("menuitem")); \ m.setAttribute("label", _string.getString("undoclosetab.clear.label")); \ m.setAttribute("accesskey", _string.getString("undoclosetab.clear.accesskey")); \ m.setAttribute("oncommand", "getClosedTab(null, -1);");' ).replace( 'm.addEventListener("command", function () {for (var i = 0; i < undoItems.length; i++) {undoCloseTab();}}, false);', 'm.addEventListener("command", function () {if (!_confirmOpenTabs(undoItems.length)) { return; } for (var i = 0; i < undoItems.length; i++) {undoCloseTab();}}, false);' )); var undoPopup = document.getElementById("historyUndoPopup") undoPopup.setAttribute("oncommand", "event.stopPropagation();"); undoPopup.setAttribute("onclick", "closeMenus(event.target); event.stopPropagation();"); if (gIsFirefox3) undoPopup.setAttribute("type", "places"); eval("gBrowser.setStripVisibilityTo ="+gBrowser.setStripVisibilityTo.toString().replace( 'this.mStrip.collapsed = !aShow;', 'if (!aShow || gHideTabBar != 2) $&' )); // make ChromaTabs extension compatible with Tabmix Plus if ("CHROMATABS" in window) eval("CHROMATABS.colorizeTab ="+CHROMATABS.colorizeTab.toString().replace( 'node = doc.getAnonymousElementByAttribute(tab, "class", "tab-image-left");', 'node = doc.getAnonymousElementByAttribute(tab, "class", "tab-image-left tab-startcap tab-left tab-left-border");' ).replace( 'node = doc.getAnonymousElementByAttribute(tab, "class", "tab-image-middle");', 'node = doc.getAnonymousElementByAttribute(tab, "class", "tab-middle box-inherit tab-image-middle tab-body");' ).replace( 'node = doc.getAnonymousElementByAttribute(tab, "class", "tab-close-button");', 'node = doc.getAnonymousElementByAttribute(tab, "anonid", "tmp-close-button");' ).replace( 'node = doc.getAnonymousElementByAttribute(tab, "class", "tab-image-right");', 'node = doc.getAnonymousElementByAttribute(tab, "class", "tab-image-right tab-endcap tab-right tab-right-border");' )); // fix bug in superDargandGo try { if ("superDrag" in window) //eval("superDrag.onDrop ="+superDrag.onDrop.toString().replace( eval("contentAreaDNDObserver.onDrop ="+contentAreaDNDObserver.onDrop.toString().replace( 'document.firstChild.getAttribute("windowtype")', 'window.document.documentElement.getAttribute("windowtype")' ).replace( 'preventBubble()', 'stopPropagation()' )); } catch (ex) {} // Don't allow to drop new uri on locked tab contentArea unless the tab is blanck or the user press Ctrl/Meta Key // when superDargandGo 2.6.2 is installed this eval throw an error, maybe by bug Bug 362582 try { eval("contentAreaDNDObserver.onDrop ="+contentAreaDNDObserver.onDrop.toString().replace( 'loadURI(uri, null, postData.value, false);', 'TMP_contentAreaOnDrop(aEvent, uri, postData.value);' )); } catch (ex) {} function TMP_contentAreaOnDrop(aEvent, aUri, aPostData) { var where; var browser = gBrowser.getBrowserForDocument(aEvent.target.ownerDocument); if (browser && aUri != browser.currentURI.spec) { var tab = gBrowser.getTabForBrowser(browser); var accelKeyPressed = aEvent.ctrlKey || aEvent.metaKey; if (!accelKeyPressed && tab.getAttribute("locked") && !gBrowser.isBlankNotBusyTab(tab) && !isUrlForDownload(aUri)) { where = "tab"; } } if (where == "tab") gBrowser.loadOneTab(aUri, null, null, aPostData, false, false); else loadURI(aUri, null, aPostData, false); } gBrowser.TMP_openTabNext = function _TMP_openTabNext(aTab, blank, aCaller) { var blockedCallers = {sss_restoreWindow:true, ct_SSS_undoCloseTab:true}; if (aCaller in blockedCallers) return; if (this.mPrefs.getBoolPref("extensions.tabmix.openTabNext")) { this.TMmoveTabTo(aTab, this.mCurrentTab._tPos + this.mTabContainer.nextTab,1); } else { // Update "last-tab" attribute var lastTab = this.mTabContainer.lastChild; var prevTab = lastTab.previousSibling; if (prevTab && prevTab.hasAttribute("last-tab")) prevTab.removeAttribute("last-tab"); if (!lastTab.hasAttribute("last-tab")) lastTab.setAttribute("last-tab", "true"); } if (this.mPrefs.getBoolPref("extensions.tabmix.openTabNextInverse")) this.mTabContainer.nextTab++; } gBrowser.TMmoveTabTo = function _TMmoveTabTo(aTab, aIndex, flag) { if ( aTab._tPos == aIndex ) return aTab; // splice, appendChild, insertBefore trigger tabxTabClosed and tabxTabAdded // we add this "tabmoved" attribute to test if it exsit in those function aTab.setAttribute("tabmoved", true); if(!(flag & 1)) this.mTabContainer.nextTab = 1; this._browsers = null; // invalidate cache this.mTabFilters.splice(aIndex,0,this.mTabFilters.splice(aTab._tPos, 1)[0]); this.mTabListeners.splice(aIndex,0,this.mTabListeners.splice(aTab._tPos, 1)[0]); var tabCount = this.mTabContainer.childNodes.length; var newPos = tabCount - 1 < aIndex ? tabCount - 1 : aIndex; var oldPosition = aTab._tPos; aIndex = aIndex < aTab._tPos ? aIndex: aIndex+1; if (aTab == this.mTabContainer.firstChild || aIndex == 0) this.mTabContainer.firstChild.removeAttribute("first-tab"); if (aTab == this.mTabContainer.lastChild || tabCount <= aIndex) this.mTabContainer.lastChild.removeAttribute("last-tab"); this.mCurrentTab.__selected = false; // use .item() instead of [] because dragging to the end of the strip goes out of // bounds: .item() returns null (so it acts like appendChild), but [] throws this.mTabContainer.insertBefore(aTab, this.mTabContainer.childNodes.item(aIndex)); // invalidate cache, because mTabContainer is about to change this._browsers = null; // Update "first-tab" and "last-tab" attributes if (!this.mTabContainer.firstChild.hasAttribute("first-tab")) this.mTabContainer.firstChild.setAttribute("first-tab", "true"); if (!this.mTabContainer.lastChild.hasAttribute("last-tab")) this.mTabContainer.lastChild.setAttribute("last-tab", "true"); var i; for (i = 0; i < tabCount; i++) { this.mTabContainer.childNodes[i]._tPos = i; /* we don't need this if we update first-tab and last-tab here this line interfere with our "unreadTab" because it add "selected" false attribute to all tab even befor they selected this.mTabContainer.childNodes[i].__selected = false; */ } this.mCurrentTab.__selected = true; var evt = document.createEvent("UIEvents"); evt.initUIEvent("TabMove", true, false, window, oldPosition); aTab.dispatchEvent(evt); SessionManager.tabMoved(aTab, oldPosition, newPos); aTab.removeAttribute("tabmoved"); this.mTabContainer.ensureTabIsVisible(aTab._tPos); return aTab; } gBrowser.duplicateTab = function tabbrowser_duplicateTab(aTab, aHref) { if (aTab.localName != "tab") aTab = this.mCurrentTab; var newTab = null; // try to have SessionStore duplicate the given tab newTab = this.SSS_duplicateTab(aTab, aHref); // if SSS_duplicateTab failed fall back to TMP_duplicateTab if(!newTab) newTab = this.TMP_duplicateTab(aTab, aHref); content.focus(); var bgPref = this.mPrefs.getBoolPref("extensions.tabmix.loadDuplicateInBackground"); var copyToNewWindow = window != aTab.ownerDocument.defaultView; if (!bgPref) { newTab.owner = copyToNewWindow ? null : aTab; this.TMP_selectNewForegroundTab(newTab, bgPref, aHref || this.getBrowserForTab(aTab).currentURI.spec, false); } if (!copyToNewWindow && this.mPrefs.getBoolPref("extensions.tabmix.openDuplicateNext")) { var pos = newTab._tPos > aTab._tPos ? 1 : 0; this.TMmoveTabTo(newTab, aTab._tPos+pos); } return newTab; } gBrowser.SSS_duplicateTab = function tabbrowser_SSS_duplicateTab(aTab, aHref) { var newTab = null; try { var newTab, tabState; // add new history entry after current index, and removing forword history function addNewHistoryEntry() { var activeIndex = (tabState.index || tabState.entries.length) - 1; var entriesToRemove = tabState.entries.length - tabState.index; var newEntry = { url: aHref }; tabState.entries.splice(activeIndex + 1 , entriesToRemove, newEntry); tabState.index++; } // we need to update history title after the new page loaded for use in back/forword button var self = this; function updateNewHistoryTitle(aEvent) { this.removeEventListener("load", updateNewHistoryTitle, true); var history = this.webNavigation.sessionHistory; var shEntry = history.getEntryAtIndex(history.index, false).QueryInterface(Ci.nsISHEntry); shEntry.setTitle(self.getTabForBrowser(this).label); } var ss = Cc["@mozilla.org/browser/sessionstore;1"] .getService(Ci.nsISessionStore); if (gIsFirefox3) { tabState = eval("(" + ss.getTabState(aTab) + ")"); newTab = this.addTab(); if (aHref) { addNewHistoryEntry(); this.getBrowserForTab(newTab).addEventListener("load", updateNewHistoryTitle, true); } ss.setTabState(newTab, tabState.toSource(), false); } else if (TMP_ClosedTabs.ssIsON){ /* * firefox 2 don't have duplicateTab or getTabState/setTabState so we use getWindowState/setWindowState * it only work if sessionStore is enabled */ var sourceWindow = aTab.ownerDocument.defaultView; // this will not work if session store is disabled var state = eval("(" + ss.getWindowState(sourceWindow) + ")"); tabState = state.windows[0].tabs[aTab._tPos]; if (aHref) addNewHistoryEntry(); state = { windows: [ { tabs: [tabState] } ] }; ss.setWindowState(window, state.toSource(), false); newTab = this.getTabForLastPanel(); if (aHref) this.getBrowserForTab(newTab).addEventListener("load", updateNewHistoryTitle, true); } } catch (ex) { object2String(ex); } return newTab; } gBrowser.TMP_duplicateTab = function tabbrowser_TMP_duplicateTab(aTab, href) { try { var aBrowser = this.getBrowserForTab(aTab); var originalHistory = aBrowser.webNavigation.sessionHistory; var newTab = this.addTab(); var newBrowser = this.getBrowserForTab(newTab); //try to set zoom factor befor we load content var zoomFactor = aBrowser.docShell.contentViewer ? aBrowser.markupDocumentViewer.textZoom : 1; setTextZoom(newBrowser, zoomFactor); var prop = SessionData.getTabProperties(aTab); SessionData.setTabProperties(newTab, prop); newBrowser.addEventListener('load', dupScrollPosition, true); //save scroll data and href to load after we clone tab history var bContent = aBrowser.contentWindow; newBrowser._scrollData = { href: href, _scrollX: bContent.scrollX, _scrollY: bContent.scrollY, zoom: zoomFactor }; dtMergeWindows.cloneTabHistory(newBrowser.webNavigation, dtMergeWindows.copyHistory(originalHistory)); } catch (ex) { } return newTab; } gBrowser.duplicateInWindow = function (aTab, aMoveTab) { if (aTab.localName != "tab") aTab = this.mCurrentTab; if (gSingleWindowMode) { if (!aMoveTab) this.duplicateTab(aTab); return; } function _restoreWindow(aWindow, aCount) { var oldTab = aWindow._duplicateTab; if (!oldTab) { tmLog("Error no _duplicateTab in window"); return; } var tabBrowser = aWindow.getBrowser(); // make sure sessionHistory is ready try { if (!tabBrowser.webNavigation.sessionHistory) { throw new Error(); } } catch (ex) { // in case browser or history aren't ready yet if (aCount < 20) { var restoreHistoryFunc = function() {_restoreWindow(aWindow, aCount + 1); } setTimeout(restoreHistoryFunc, 50); return; } } /* * In Firefox 2.0 when we move the current tab select other tab in surece window * before the new window get the focus, this will prevent the focus to jump back * to the surece window from the new window when gBrowser.removetab select new tab. * we remove the tab only after we duplicate it */ var sourceWindow = aWindow.opener; var moveMode = aWindow._duplicateMove && sourceWindow; // we don't have to do anything if the openr not exist if (moveMode) { var sourceBrowser = sourceWindow.getBrowser(); if (!gIsFirefox3 && sourceBrowser.mTabContainer.childNodes.length > 1 && oldTab == sourceBrowser.mCurrentTab) { var newIndex = sourceBrowser.selectIndexAfterRemove(oldTab); sourceBrowser.selectedTab = sourceBrowser.mTabContainer.childNodes[newIndex]; } } var tab = tabBrowser.mCurrentTab; var newTab = tabBrowser.duplicateTab(oldTab); // remove unused blank tab if (tabBrowser.isBlankNotBusyTab(tab)) tabBrowser.removeTab(tab); // make sure the new tab is in the end var lastIndex = tabBrowser.mTabContainer.childNodes.length - 1; if (newTab._tPos < lastIndex) tabBrowser.moveTabTo(newTab, lastIndex); // remove old tab and close the other window if _duplicateTab was its last tab if (moveMode) { var needToClose = "needToClose" in sourceWindow; if (oldTab.parentNode) { // make sure the tab still exist befor we try to remove it needToClose = needToClose || sourceBrowser.mTabContainer.childNodes.length == 1; oldTab.removeAttribute("protected"); sourceBrowser.removeTab(oldTab); } if (needToClose) sourceWindow.TMP_BrowserCloseWindow(); } delete aWindow._duplicateMove; delete aWindow._duplicateTab; } // we going to delete the moved tab after some timeout catch the flag now // we use this only if the tab was not exist anymore when its time to remove it if (aMoveTab && this.mTabContainer.childNodes.length == 1) window.needToClose = true; // open new window var newWindow = window.openDialog( getBrowserURL(), "_blank", "chrome,all,dialog=no"); newWindow._duplicateMove = aMoveTab; newWindow._duplicateTab = aTab; newWindow.addEventListener("load", function (aEvent) { var win = aEvent.currentTarget; win.removeEventListener("load", arguments.callee, false); // make sure sessionstore is init try { var ss = Cc["@mozilla.org/browser/sessionstore;1"] .getService(Ci.nsISessionStore).init(win); } catch(ex) { dump("nsSessionStore could not be initialized: " + ex + "\n"); return; } _restoreWindow(win, 0); }, false); } gBrowser.openLinkWithHistory = function (aTab) { return this.duplicateTab(aTab, gContextMenu.linkURL); } gBrowser.openHereWith = function () { var referrerURI = makeURI(gContextMenu.target.ownerDocument.location.href); loadURI(gContextMenu.linkURL, referrerURI, null, false); } gBrowser.openInverseLink = function (aTab) { var newTab = this.addTab(gContextMenu.linkURL); var bgPref = this.mPrefs.getBoolPref("browser.tabs.loadInBackground"); this.TMP_selectNewForegroundTab(newTab, !bgPref, gContextMenu.linkURL, true); return newTab; } gBrowser.closeAllTabs = function TMP_closeAllTabs() { if (this.warnAboutClosingTabs("All")) { var childNodes = this.mTabContainer.childNodes; if (this.mTabContainer.collapsedTabs > 0) this.mTabContainer.collapsedTabs = 0; for (var i = childNodes.length - 1; i >= 0; --i) { if (childNodes[i] != this.mCurrentTab) this.removeTab(childNodes[i]); } this.removeTab(this.mCurrentTab); // _handleTabSelect will call ensureTabIsVisible } } gBrowser.closeGroupTabs = function TMP_closeGroupTabs(aTab) { if (aTab.localName != "tab") aTab = this.mCurrentTab; var URL = this.getBrowserForTab(aTab).currentURI.spec; var matches = URL.match(/(^.*\/)(.*)/); var aDomain = matches ? matches[1] : URL; if (this.warnAboutClosingTabs("Group", null, null, aDomain)) { var childNodes = this.mTabContainer.childNodes; if (this.mTabContainer.collapsedTabs > 0) this.mTabContainer.collapsedTabs = 0; for ( i = childNodes.length - 1; i > -1; --i) { if (childNodes[i] != aTab && this.getBrowserForTab(childNodes[i]).currentURI.spec.indexOf(aDomain) != -1) this.removeTab(childNodes[i]); } this.removeTab(aTab); this.mTabContainer.ensureTabIsVisible(this.mTabContainer.selectedIndex); } } gBrowser.closeRightTabs = function (aTab) { if (aTab.localName != "tab") aTab = this.mCurrentTab; if (this.warnAboutClosingTabs("Right", aTab._tPos)) { if ( aTab._tPos < this.mCurrentTab._tPos ) this.mTabContainer.selectedItem = aTab; var childNodes = this.mTabContainer.childNodes; for ( i = childNodes.length - 1; i > aTab._tPos; i-- ) this.removeTab(childNodes[i]); } } gBrowser.closeLeftTabs = function TMP_closeLeftTabs(aTab) { if (aTab.localName != "tab") aTab = this.mCurrentTab; if (this.warnAboutClosingTabs("Left", aTab._tPos)) { if ( aTab._tPos > this.mCurrentTab._tPos ) this.mTabContainer.selectedItem = aTab; var childNodes = this.mTabContainer.childNodes; if (this.mTabContainer.collapsedTabs > 0) this.mTabContainer.collapsedTabs = 0; for ( i = aTab._tPos - 1; i >= 0; i-- ) this.removeTab(childNodes[i]); this.mTabContainer.ensureTabIsVisible(this.mTabContainer.selectedIndex); } } gBrowser.removeAllTabsBut = function TMP_removeAllTabsBut(aTab) { if (aTab.localName != "tab") aTab = this.mCurrentTab; if (this.warnAboutClosingTabs("AllBut", null, aTab.hasAttribute("protected"))) { if (aTab != this.mCurrentTab) this.mTabContainer.selectedItem = aTab; var childNodes = this.mTabContainer.childNodes; if (this.mTabContainer.collapsedTabs > 0) this.mTabContainer.collapsedTabs = 0; for (var i = childNodes.length - 1; i >= 0; --i) { if (childNodes[i] != aTab) this.removeTab(childNodes[i]); } this.mTabContainer.ensureTabIsVisible(this.mTabContainer.selectedIndex); } } gBrowser.reloadLeftTabs = function (aTab) { if (aTab.localName != "tab") aTab = this.mCurrentTab; var childNodes = this.mTabContainer.childNodes; if ( aTab._tPos > this.mCurrentTab._tPos ) this.mTabContainer.selectedItem = aTab; for ( i = aTab._tPos - 1; i >= 0; i-- ) this.reloadTab(childNodes[i]); } gBrowser.reloadRightTabs = function (aTab) { if (aTab.localName != "tab") aTab = this.mCurrentTab; var childNodes = this.mTabContainer.childNodes; if ( aTab._tPos < this.mCurrentTab._tPos ) this.mTabContainer.selectedItem = aTab; for ( i = childNodes.length - 1; i > aTab._tPos; i-- ) this.reloadTab(childNodes[i]); } gBrowser.reloadAllTabsBut = function (aTab) { if (aTab.localName != "tab") aTab = this.mCurrentTab; else this.mTabContainer.selectedItem = aTab; var childNodes = this.mTabContainer.childNodes; for (var i = childNodes.length - 1; i >= 0; --i) { if (childNodes[i] != aTab) this.reloadTab(childNodes[i]); } } // we call this function from TMP_ClosedTabs.undoCloseTab if sessionStore is disabled gBrowser.undoRemoveTab = function () { if( !this.mPrefs.getBoolPref("extensions.tabmix.undoClose" ) || !this.closedTabs.length ) return null; var aTab = getClosedTab("original", this.closedTabs.length-1); return this.restoreTab(aTab[0], aTab[1], aTab[4], aTab[5]); } gBrowser.delayUndoRemoveAllTab = function () { // call undoRemoveAllTab after delay to let the popup menu time to hide var _this = this; window.setTimeout( function () { _this.undoRemoveAllTab(); }, 0 ); } gBrowser.undoRemoveAllTab = function () { if (!_confirmOpenTabs(gBrowser.closedTabs.length)) return; TMP_ClosedTabs.setButtonDisableState(true); var aTab, blankTab, newTab, selectTab = true; // catch blank tab for reuse var blankTabs = []; for (var i = 0; i < this.mTabs.length ; i++) { aTab = this.mTabs[i]; if (this.isBlankNotBusyTab(aTab)) { aTab.reuse = true; blankTabs.push(aTab); } } while (this.closedTabs.length > 0) { aTab = getClosedTab("original", this.closedTabs.length-1); blankTab = blankTabs.pop(); newTab = (blankTab) ? blankTab : this.addTab(); this.restoreTabData(newTab, aTab[0], aTab[1], aTab[4], aTab[5], selectTab); selectTab = false; } // remove unused blank tabs while(blankTabs.length > 0){ blankTab = blankTabs.pop(); this.removeTab(blankTab); } this.mTabContainer.nextTab = 1 } gBrowser.restoreTab = function TMP_restoreTab(ord, hist, prop, zoom) { TMP_ClosedTabs.setButtonDisableState(this.closedTabs.length == 0); // reuse blanke tab var newTab = this.mCurrentTab; if (!this.isBlankNotBusyTab(newTab)) newTab = this.addTab(); this.restoreTabData(newTab, ord, hist, prop, zoom, true); return newTab; } gBrowser.restoreTabData = function TMP_restoreTabData(newTab, ord, hist, prop, zoom, selectTab) { var newBrowser = this.getBrowserForTab(newTab); if (zoom && zoom != "0,0,1") { //try to set zoom factor befor we load content var XYZ = zoom.split(","); setTextZoom(newBrowser, XYZ[2]); } var restorePosition = getBoolPref("extensions.tabmix.undoClosePosition", true ); var newPos; if ( restorePosition ) { newPos = ord > this.mTabs.length - 1 ? this.mTabs.length - 1 : ord; this.TMmoveTabTo(newTab, newPos); } else if (newTab.reuse) { // move reuse tabs to the end when restore all closed tabs list var openTabNext = this.mPrefs.getBoolPref("extensions.tabmix.openTabNext"); newPos = openTabNext ? this.mCurrentTab._tPos + this.mTabContainer.nextTab++ : this.mTabs.length - 1; this.TMmoveTabTo(newTab, newPos, 1); if (newTab != this.mCurrentTab) newTab.removeAttribute("flst_id"); delete newTab.reuse; } SessionData.setTabProperties(newTab, prop); var oldHistory = hist; var newHistory = newBrowser.webNavigation.sessionHistory; // reset old history if (newHistory.count > 0) { newHistory.PurgeHistory(newHistory.count); } newHistory.QueryInterface(Components.interfaces.nsISHistoryInternal); for (var i = 0; i < oldHistory.count; i++) { newHistory.addEntry(oldHistory.getEntryAtIndex(i, false), true); } if( oldHistory.count ) { try { newBrowser.webNavigation.gotoIndex(oldHistory.index); } catch (e) {} } // call to set scroll Position for restored closed tab from prev session if (zoom && zoom != "0,0,1") { newBrowser.addEventListener('load', dupScrollPosition, true); newBrowser._scrollData = { href: null, _scrollX: XYZ[0], _scrollY: XYZ[1], zoom: XYZ[2] } } if (selectTab) { content.focus(); this.TMP_selectNewForegroundTab(newTab, false, null, false); } return newTab; } gBrowser.lockTab = function (aTab) { if (aTab.localName != "tab") aTab = this.mCurrentTab; if ( aTab.hasAttribute("locked") ) { aTab.removeAttribute("locked"); aTab.setAttribute("_locked", "false"); } else { aTab.setAttribute("locked", "true"); aTab.setAttribute("_locked", "true"); } SessionManager.updateTabProp(aTab); } gBrowser.protectTab = function (aTab) { if (aTab.localName != "tab") aTab = this.mCurrentTab; if ( aTab.hasAttribute("protected") ) aTab.removeAttribute("protected"); else aTab.setAttribute("protected", "true"); SessionManager.updateTabProp(aTab); } gBrowser.freezeTab = function (aTab) { if (aTab.localName != "tab") aTab = this.mCurrentTab; if ( !aTab.hasAttribute("protected") || !aTab.hasAttribute("locked")){ aTab.setAttribute("protected", "true"); aTab.setAttribute("locked", "true"); aTab.setAttribute("_locked", "true"); } else { aTab.removeAttribute("protected"); aTab.removeAttribute("locked"); aTab.setAttribute("_locked", "false"); } SessionManager.updateTabProp(aTab); } gBrowser.SelectToMerge = function(aTab) { if (gSingleWindowMode && numberOfWindows() == 1) return; if (aTab.localName != "tab") aTab = this.mCurrentTab; if (aTab.hasAttribute("mergeselected")) { aTab.removeAttribute("mergeselected"); aTab.label = aTab.label.substr(4); } else { aTab.setAttribute("mergeselected", "true") aTab.label = "(*) "+aTab.label; } } gBrowser.onSetReloadTime = function(aTab, aReloadTime) { if (aTab.localName != "tab") aTab = this.mCurrentTab; aTab.autoReloadTime = aReloadTime; this.mPrefs.setIntPref("extensions.tabmix.reload_time", aTab.autoReloadTime); this.enableAutoReload(aTab); } gBrowser.setupAutoReload = function (aTab) { if (aTab.localName != "tab") aTab = this.mCurrentTab; aTab.autoReloadEnabled = false; aTab.autoReloadTime = this.mPrefs.getIntPref("extensions.tabmix.reload_time"); aTab.autoReloadTimerID = null; aTab.postDataAcceptedByUser = false; aTab.id = "ActiveReloadTab" + autoReloadTabID; autoReloadTabID++; } gBrowser.onAutoReloadEnable = function (aTab) { if (aTab.localName != "tab") aTab = this.mCurrentTab; if (aTab.autoReloadEnabled) this.disableAutoReload(aTab); else this.enableAutoReload(aTab); } gBrowser.enableAutoReload = function(aTab) { aTab.autoReloadEnabled = true; aTab.autoReloadURI = this.getBrowserForTab(aTab).currentURI.spec; clearTimeout(aTab.autoReloadTimerID); aTab.autoReloadTimerID = setTimeout(reloadPage, aTab.autoReloadTime*1000, aTab.id); aTab.setAttribute("reload-data", aTab.autoReloadURI + " " + aTab.autoReloadTime); } gBrowser.disableAutoReload = function (aTab) { aTab.autoReloadEnabled = false; aTab.autoReloadURI = null; aTab.postDataAcceptedByUser = false; clearTimeout(aTab.autoReloadTimerID); aTab.removeAttribute("reload-data"); } gBrowser.onEnableAutoReloadAllTabs = function () { var tabs = this.mTabContainer.childNodes; for(var i=0; i max_id ) { max_id = temp_id; tempIndex = items[i]._tPos; } } return tempIndex; } gBrowser.previousTab = function (aTab) { if (this.mTabs.length == 1) return; var tempIndex = this.previousTabIndex(aTab); // if no flst_id go to previousTab tab, from first tab go to the next tab if (tempIndex == -1) tempIndex = aTab._tPos == 0 ? 1 : aTab._tPos - 1; this.selectedTab = this.mTabs[tempIndex]; this.mCurrentTab.focus(); } gBrowser.selectIndexAfterRemove = function (oldTab) { var currentIndex = this.mCurrentTab._tPos; if (this.mCurrentTab != oldTab) return currentIndex; var l = this.mTabs.length; if (l==1) return 0; var mode = this.mPrefs.getIntPref("extensions.tabmix.focusTab"); switch ( mode ) { case 0: // first tab return currentIndex == 0 ? 1 : 0; break; case 1: // left tab return currentIndex == 0 ? 1 : currentIndex-1 ; break; case 3: // last tab return currentIndex == l - 1 ? currentIndex - 1 : l - 1; break; case 6: // last opened var lastTab = this.getTabForLastPanel(); if (lastTab == oldTab && l > 1) { lastTab = document.getAnonymousElementByAttribute(this, "linkedpanel", this.mPanelContainer.childNodes[l-2].id); } return lastTab._tPos; case 4: // last selected var tempIndex = this.previousTabIndex(oldTab); // if we don't find last selected we fall back to default if (tempIndex > -1) return tempIndex; case 2: // opener / right (default ) case 5: // right tab default: if (mode != 5 && this.mPrefs.getBoolPref("browser.tabs.selectOwnerOnClose") && "owner" in oldTab) { var owner = oldTab.owner; if (owner && owner.parentNode && owner != oldTab) // oldTab and owner still exist just return its position return owner._tPos; } } return currentIndex == l - 1 ? currentIndex - 1 : currentIndex + 1; } gBrowser.TMP_createTooltip = function (event) { event.stopPropagation(); var tn = document.tooltipNode; if (tn.localName != "tab") return false; // Not a tab, so cancel the tooltip if ("tmp_mOverCloseButton" in tn && tn.tmp_mOverCloseButton) { event.target.setAttribute("label", tn.getAttribute("closetabtext")); return true; } if (tn.hasAttribute("label")) { event.target.setAttribute("label", tn.getAttribute("label")); return true; } return false; } gBrowser.closeTab = function(aTab) { // throws exception when rapid click on close tab button // we call this after delay if (!aTab.parentNode) return; if (this.mTabContainer.childNodes.length == 1 && this.isBlankNotBusyTab(aTab) && !this.mPrefs.getBoolPref("extensions.tabmix.keepLastTab")) { var urlBar = document.getElementById("urlbar"); if (urlBar) { urlBar.value = ""; urlBar.focus(); } } else { // clear all timeouts befor we remove the tab if (aTab.isClosing) clearTimeout(aTab.isClosing); if (aTab.mSelect) clearTimeout(aTab.mSelect); if (aTab.mouseHoverSelect && aTab.mFocusId) { clearTimeout(aTab.mFocusId); } if (aTab.mButtonId) clearTimeout(aTab.mButtonId); if (aTab.hasAttribute("busy")) this.getBrowserForTab(aTab).stop(); this.removeTab(aTab); if (this.mTabContainer.childNodes.length == 1 && this.isBlankTab(this.mCurrentTab)) setURLBarFocus(); this.stopMouseHoverSelect(aTab); } } gBrowser.stopMouseHoverSelect = function(aTab) { // add extra delay after tab removed or after tab flip befor we select by hover // to let the user time to move the mouse if (aTab.mouseHoverSelect) { function removeDelayAfterClose(browser) { browser.removeAttribute("preventMouseHoverSelect"); } this.setAttribute("preventMouseHoverSelect",true); var delay = aTab.mouseHoverSelectDelay + 50; setTimeout(removeDelayAfterClose, delay, this); } } gBrowser.warnAboutClosingTabs = function (whatToClose, tabPos, protectedTab, aDomain) { // try to cach call from other extensions to warnAboutClosingTabs if (typeof(whatToClose) == "boolean") { if (!whatToClose) protectedTab = this.mCurrentTab.hasAttribute("protected"); whatToClose = whatToClose ? "All_onExit" : "AllBut"; } var childNodes = this.mTabContainer.childNodes; var numTabs = childNodes.length; var shouldPrompt = 0; const tabsPref = "browser.tabs.warnOnClose"; if (this.mPrefs.getBoolPref(tabsPref) && numTabs > 1) shouldPrompt = 1; // calc the number of tab to close when there is protected tabs. var protectedTabs = this.mTabContainer.getElementsByAttribute("protected", true); var numProtected = protectedTabs.length; const protectedTabsPref = "extensions.tabmix.protectedtabs.warnOnClose"; if (numProtected > 0 && whatToClose == "All_onExit" && this.mPrefs.getBoolPref(protectedTabsPref)) shouldPrompt = 2; if (shouldPrompt == 0) return true; var i, tabsToClose = 0; switch (whatToClose) { case "All": tabsToClose = numTabs - numProtected; break; case "All_onExit": tabsToClose = numTabs; break; case "AllBut": if (protectedTab) --numProtected; tabsToClose = numTabs - 1 - numProtected; break; case "Group": for ( i = numTabs - 1; i > -1; --i) { if (this.getBrowserForTab(childNodes[i]).currentURI.spec.indexOf(aDomain) != -1 && !childNodes[i].hasAttribute("protected")) tabsToClose++; } break; case "Right": for ( i = 0; i < protectedTabs.length; i++ ) if (protectedTabs[i]._tPos <= tabPos) --numProtected; tabsToClose = numTabs - tabPos - 1 - numProtected; break; case "Left": for ( i = 0; i < protectedTabs.length; i++ ) if (protectedTabs[i]._tPos >= tabPos) --numProtected; tabsToClose = tabPos - numProtected; break; } if (tabsToClose <= 1 && shouldPrompt < 2) return true; var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); //default to true: if it were false, we wouldn't get this far var warnOnClose = { value:true }; var bundle = this.mStringBundle; var message, messageKey, chkBoxLabel; if (shouldPrompt != 2) { try { messageKey = (tabsToClose == 1) ? "tabs.closeWarningOne" : "tabs.closeWarningMultiple"; message = bundle.getFormattedString(messageKey, [tabsToClose]); } catch (er) { messageKey = (tabsToClose == 1) ? "tabs.closeWarningOneTab" : "tabs.closeWarningMultipleTabs"; message = bundle.getFormattedString(messageKey, [tabsToClose]); } chkBoxLabel = bundle.getString('tabs.closeWarningPromptMe'); } else { var tmp_bundle = document.getElementById("tmp-string-bundle"); messageKey = "protectedtabs.closeWarning."; messageKey += (numProtected < tabsToClose) ? "3" : (numProtected == 1) ? "1" : "2"; message = tmp_bundle.getFormattedString(messageKey, [tabsToClose, numProtected]); chkBoxLabel = tmp_bundle.getString('protectedtabs.closeWarningPromptMe'); } var closeKey = (tabsToClose == 1) ? "tabs.closeButtonOne" : "tabs.closeButtonMultiple"; window.focus(); var buttonPressed = promptService.confirmEx(window, bundle.getString('tabs.closeWarningTitle'), message, (promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0) + (promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1), bundle.getString(closeKey), null, null, chkBoxLabel, warnOnClose); var reallyClose = (buttonPressed == 0); // don't set the pref unless they press OK and it's false if (reallyClose && !warnOnClose.value) { var pref = shouldPrompt != 2 ? tabsPref : protectedTabsPref; this.mPrefs.setBoolPref(pref, false); } return reallyClose; } gBrowser.TMP_selectNewForegroundTab = function (aTab, aLoadInBackground, aUrl, addOwner) { var bgLoad = (aLoadInBackground != null) ? aLoadInBackground : this.mPrefs.getBoolPref("browser.tabs.loadInBackground"); if (!bgLoad) { // set new tab owner addOwner = addOwner != null ? addOwner : true; if (addOwner) aTab.owner = this.selectedTab; this.selectedTab = aTab; if (aUrl && aUrl == "about:blank") setURLBarFocus(); } } gBrowser.getTabForBrowser = function (aBrowser) { return document.getAnonymousElementByAttribute(this, "linkedpanel", aBrowser.parentNode.id); } gBrowser.getTabForLastPanel = function () { return document.getAnonymousElementByAttribute(this, "linkedpanel", this.mPanelContainer.lastChild.id); } }} // end tablib // BrowserCloseWindow removed for Fx 3.0+ by bug #383760 function TMP_BrowserCloseWindow() { if ("BrowserCloseWindow" in window) BrowserCloseWindow(); else closeWindow(true); } function _confirmOpenTabs(numTabsToOpen) { if (gIsPlaces) { return PlacesController.prototype._confirmOpenTabs(numTabsToOpen); } else if ("_confirmOpenTabs" in BookmarksCommand) return BookmarksCommand._confirmOpenTabs(numTabsToOpen); return true; } function setURLBarFocus() { if (gURLBar) { if (gIsFirefox3) gURLBar.focus(); else setTimeout(function() { gURLBar.focus(); }, 0); } } function dupScrollPosition(event) { var browser = this; var data = browser._scrollData; browser.removeEventListener('load', dupScrollPosition, true); var tab = gBrowser.getTabForBrowser(browser); if (tab && tab.parentNode) SessionManager.setScrollPosition(tab, browser, data, 15); delete browser._scrollData; } function setTextZoom(aBrowser, zoomFactor) { if (gIsFirefox3) return; try { if (aBrowser.docShell.contentViewer == null) return; // probebly 1.0.7 if (zoomFactor && aBrowser.markupDocumentViewer.textZoom != zoomFactor) aBrowser.markupDocumentViewer.textZoom = zoomFactor; } catch (e) {} } function menuItemTitle(entry) { if (entry.URI) return getTitleFromBookmark(entry.URI.spec, entry.title); return entry.title; } function saveClosedTab(tab, browser) { var max_tabs_undo = gPref.getIntPref("browser.sessionstore.max_tabs_undo"); if (tabxPrefs.getBoolPref("undoClose") && max_tabs_undo > 0 && !gBrowser.isBlankBrowser(browser)) { TMP_ClosedTabs.setButtonDisableState(false); var bContent = browser.contentWindow; var zoomFactor = browser.docShell.contentViewer ? browser.markupDocumentViewer.textZoom : 1; gBrowser.closedTabs.push([tab._tPos, browser.sessionHistory, tab.getAttribute("label"), tab.getAttribute("image"), SessionData.getTabProperties(tab), bContent.scrollX + "," + bContent.scrollY + "," + zoomFactor ]); } if (gBrowser.closedTabs.length > max_tabs_undo) gBrowser.closedTabs.shift(); SessionManager.tabScrolled(tab); } var autoReloadTabID = 0; var gAutoReloadDialogAccepted; function autoReloadDialogResult(accepted){ gAutoReloadDialogAccepted = accepted; } function reloadPage(autoReloadTabID){ var aTab = document.getElementById(autoReloadTabID); if (aTab == null) return; var browser = gBrowser.getBrowserForTab(aTab); if (aTab.autoReloadEnabled == false ){ aTab.postDataAcceptedByUser = false; return; } var loadFlags = nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY | nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE; var entry = browser.webNavigation.sessionHistory.getEntryAtIndex(browser.webNavigation.sessionHistory.index, false); var postData = entry.QueryInterface(Components.interfaces.nsISHEntry).postData; var referrer = entry.QueryInterface(Components.interfaces.nsISHEntry).referrerURI; if ((postData!=null) && (aTab.postDataAcceptedByUser==false)){ var params = Components.classes['@mozilla.org/embedcomp/dialogparam;1'].createInstance(Components.interfaces.nsIDialogParamBlock); var stringBundle = document.getElementById("tmp-string-bundle"); params.SetString(12, stringBundle.getString('confirm_autoreloadPostData_title')); params.SetString(0, stringBundle.getString('confirm_autoreloadPostData')); params.SetString(2, 'alert-icon'); params.SetInt(2, 2); window.openDialog('chrome://global/content/commonDialog.xul', '_blank', 'chrome,modal,centerscreen', params); if (params.GetInt(0) == 0) aTab.postDataAcceptedByUser = true; else { aTab.autoReloadEnabled = false; return; } } browser.curScrollX = browser.contentWindow.scrollX; browser.curScrollY = browser.contentWindow.scrollY; var notifyFlags = Components.interfaces.nsIWebProgress.NOTIFY_ALL; browser.webNavigation.loadURI(browser.webNavigation.currentURI.spec, loadFlags, referrer, entry.postData, null); } PK 8content/tabmixplus/places/PK W6>0content/tabmixplus/places/bookmarkProperties.xul PK v8[]h#content/tabmixplus/places/places.js// code by onemen var TMP_Places = { init : function () { window.removeEventListener('load', function () { TMP_Places.init(); }, false); var _PlacesUtils = typeof(PlacesUIUtils) == "object" ? PlacesUIUtils : PlacesUtils; eval("_PlacesUtils._openTabset ="+_PlacesUtils._openTabset.toString().replace( 'window.openDialog', 'var win = window.openDialog' ).replace( 'return;', 'win.openFromPlaces = true; \ $&' ).replace( 'browserWindow.getBrowser().loadTabs(urls, loadInBackground, replaceCurrentTab);', 'browserWindow.TMP_Bookmark.openGroup(urls, where);' )); eval("PlacesController.prototype.buildContextMenu ="+PlacesController.prototype.buildContextMenu.toString().replace( 'return anyVisible;', 'if (anyVisible) TMP_Places.buildContextMenu(); \ $&' )); try { eval("_PlacesUtils.openNodeWithEvent ="+_PlacesUtils.openNodeWithEvent.toString().replace( 'this.openNodeIn(aNode, whereToOpenLink(aEvent));', 'this.openNodeIn(aNode, whereToOpenLink(aEvent), aEvent);' )); eval("_PlacesUtils.openNodeIn ="+_PlacesUtils.openNodeIn.toString().replace( 'openUILinkIn(aNode.uri, aWhere);', 'if (arguments.length == 3) aWhere = TMP_Places.isBookmarklet(aNode.uri) ? "current" : TMP_Places.fixWhereToOpen(arguments[2], aWhere); \ else if (aWhere == "current" && !TMP_Places.isBookmarklet(aNode.uri)) aWhere = TMP_Places.fixWhereToOpen(null, aWhere); \ $&' )); } catch (e) { if (window.document.documentElement.getAttribute("windowtype") == "navigator:browser") { setTimeout( function() { var tab = gBrowser.loadOneTab("http://tmp.garyr.net/error.html", null, null, null, false, false); gBrowser.moveTabTo(tab, gBrowser.browsers.length - 1); }, 0); } } // use tab label for bookmark name when user renamed the tab if ("PlacesCommandHook" in window) { eval("PlacesCommandHook.bookmarkPage ="+PlacesCommandHook.bookmarkPage.toString().replace( 'title = webNav.document.title || url.spec;', 'title = TMP_Places.getTabFixedTitle(aBrowser, url) || webNav.document.title || url.spec;' )); eval("PlacesCommandHook._getUniqueTabInfo ="+PlacesCommandHook._getUniqueTabInfo.toString().replace( 'tabList.push(uri);', 'tabList.push({uri: uri, title: TMP_Places.getTabFixedTitle(browsers[i], uri)});' ).replace( 'seenURIs.uri.spec = true;', 'seenURIs[uri.spec] = true;' )); } TMP_update_whereToOpen(); }, buildContextMenu : function() { var _open = document.getElementById("placesContext_open"); var _openInWindow = document.getElementById("placesContext_open:newwindow"); var _openInTab = document.getElementById("placesContext_open:newtab"); TMP_updateContextMenu(_open, _openInWindow, _openInTab, prefStringTMBookmark); }, historyMenuItemsTitle : function TMP_PC_historyMenuItemsTitle(aEvent) { var aMenuPopup = aEvent.target; if (aMenuPopup.id != "goPopup" || !gPref.getBoolPref("extensions.tabmix.titlefrombookmark")) return; for (var i = 0; i < aMenuPopup.childNodes.length ; i++) { if (aMenuPopup.childNodes[i].id == "startHistorySeparator") break; } for (i; i < aMenuPopup.childNodes.length ; i++) { var item = aMenuPopup.childNodes[i]; if (item.id == "endHistorySeparator") break; var bookMarkName = getTitleFromBookmark(item.getAttribute("statustext")); if (bookMarkName) item.setAttribute("label", bookMarkName); } }, historyMenu : function (aEvent) { var node = aEvent.target.node; if (node) { PlacesUIUtils.markPageAsTyped(node.uri); var where = this.isBookmarklet(node.uri) ? "current" : this.fixWhereToOpen(aEvent, whereToOpenLink(aEvent, false, true)); openUILinkIn(node.uri, where); } }, isBookmarklet : function (url) { var jsURL = /^ *javascript:/; return jsURL.test(url) ? true : false; }, fixWhereToOpen: function (aEvent, aWhere, aPref) { var w = getTopWin(); if (!w) return aWhere; var tabBrowser = w.getBrowser(); var aTab = tabBrowser.mCurrentTab; if (typeof(aPref) == "undefined") aPref = prefStringTMBookmark; if ((getBoolPref(aPref) || aTab.hasAttribute("locked"))) if (aEvent && getBoolPref(prefStringTMUseMiddleClick) && (aEvent.button == 1 || aEvent.button == 0 && (aEvent.ctrlKey || aEvent.metaKey))) aWhere = "current"; else if (aWhere == "current" && !( tabBrowser.isBlankNotBusyTab(aTab) )) aWhere = "tab"; return aWhere; }, _getBookmarkTitle: function TMP_PC__getBookmarkTitle(url) { var itemId = PlacesUtils.getMostRecentBookmarkForURI(gIOService.newURI(url, null, null)); return itemId > -1 ? PlacesUtils.bookmarks.getItemTitle(itemId): null; }, // start showAddBookmarkUI with user defined title if exist getTabFixedTitle: function TMP_PC_getTabFixedTitle(aBrowser, aURI) { var tabBrowser = getBrowser(); if (tabBrowser == aBrowser) aBrowser = tabBrowser.mCurrentBrowser; var aTab = tabBrowser.getTabForBrowser(aBrowser); if (aTab.getAttribute("label-uri") == aURI.spec) return aTab.getAttribute("fixed-label"); return null; } } PK ^~6$content/tabmixplus/places/places.xul PK 8content/tabmixplus/pref/PK ܔf5H-content/tabmixplus/pref/overlaySanitizeUI.xul %tabmixDTD; ]> PK ;8ƥdd*content/tabmixplus/pref/pref-appearance.jsvar gPref = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); var WindowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator); var mainOptions = WindowManager.getMostRecentWindow("mozilla:tabmixopt"); function Appearance_Init() { var allColorPickers = document.getElementsByTagName("colorpicker"); for (var i = 0; i < allColorPickers.length; i++) { allColorPickers[i].color = gPref.getCharPref(allColorPickers[i].getAttribute("prefstring")); } var allCheckboxes = document.getElementsByTagName("checkbox"); for (i = 0; i < allCheckboxes.length; i++) { allCheckboxes[i].checked = gPref.getBoolPref(allCheckboxes[i].getAttribute("prefstring")); } setDisabled("currentTab"); setDisabled("unreadTab"); setDisabled("progressMeter"); } function Appearance_Save() { var allColorPickers = document.getElementsByTagName("colorpicker"); for (var i = 0; i < allColorPickers.length; i++) { gPref.setCharPref(allColorPickers[i].getAttribute("prefstring"), allColorPickers[i].color); } var allCheckboxes = document.getElementsByTagName("checkbox"); for (i = 0; i < allCheckboxes.length; i++) { gPref.setBoolPref(allCheckboxes[i].getAttribute("prefstring"), allCheckboxes[i].checked); } } function setDisabled(id) { if (mainOptions.document.getElementById(id).checked) document.getElementById(id).removeAttribute("disabled"); else setColorpicker(id, false); } function setColorpicker(id, checked) { var cP = document.getElementById(id+"-colorpicker"); if (!checked) cP.setAttribute("disabled", true); else cP.removeAttribute("disabled"); cP.setAttribute("style", checked ? "opacity: 1.0" : "opacity: 0.5"); } PK v4+y+content/tabmixplus/pref/pref-appearance.xul &incompatible.extensions; PK v8g-content/tabmixplus/pref/preferencesOverlay.jsvar gTabMix_preferencesOverlay = { init: function gTabMix_preferencesOverlay_init(aEvent) { var prefWindow = aEvent.target.documentElement; this.onPaneLoad(prefWindow.lastSelected); eval("prefWindow.showPane ="+prefWindow.showPane.toString().replace( 'this._outer._selectPane(this._pane);', '$& gTabMix_preferencesOverlay.onPaneLoad(this._pane.id);' )); }, onPaneLoad: function gTabMix_preferencesOverlay_onPaneLoad(aPaneID) { switch (aPaneID) { case "paneTabs": this.loadOverlay(); break; case "panePrivacy": this.onPanePrivacyLoad(); break; default: } }, /* ........ paneTabs .............. */ loadOverlay: function () { var preferences = document.getElementById("paneTabs").childNodes[0]; // in Firefox 1.5 there is no id if (!preferences.hasAttribute("id")) { preferences.setAttribute("id", "tabsPreferences"); document.getElementById("hideTabBar").setAttribute("hidden", "true"); } else { document.getElementById("showTabBar").setAttribute("hidden", "true"); } function OverlayLoadObserver() { } OverlayLoadObserver.prototype = { _outer: this, observe: function (aSubject, aTopic, aData) { this._outer._afterOverlayLoaded(); } }; var obs = new OverlayLoadObserver(); document.loadOverlay("chrome://tabmixplus/content/pref/tab_panel.xul", obs); }, _afterOverlayLoaded: function () { document.getElementById("_hideTabbar").value = document.getElementById("extensions.tabmix.hideTabbar").value; var radiogroup = document.getElementById('linkTargeting'); radiogroup.removeAttribute('onsyncfrompreference'); radiogroup.value = document.getElementById("browser.link.open_external").value; var current_tab = document.getElementById("current_tab"); current_tab.setAttribute('label', currentLabel); current_tab.removeAttribute('hidden'); if (document.getElementById('BrowserPreferences')._shouldAnimate) window.sizeToContent(); }, showTabmixOptions: function () { var windowMediator = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator); var browserWindow = windowMediator.getMostRecentWindow('navigator:browser'); if (!browserWindow) { var tabmixopt = windowMediator.getMostRecentWindow("mozilla:tabmixopt"); if (tabmixopt) tabmixopt.close(); var stringBundle = Components.classes["@mozilla.org/intl/stringbundle;1"] .getService(Components.interfaces.nsIStringBundleService) .createBundle("chrome://tabmixplus/locale/tabmix.properties"); var title = stringBundle.GetStringFromName("tabmixoption.error.title"); var msg = stringBundle.GetStringFromName("tabmixoption.error.msg"); var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); promptService.alert(window, title, msg); } else browserWindow.TMP_openDialog(-1); }, /* ........ panePrivacy .............. */ onPanePrivacyLoad: function () { var clearDataNow = document.getElementById("clearDataNow"); //clearPrivateDataNow not exist in firefox 1.5 if (clearDataNow) clearDataNow.setAttribute("oncommand", "TMP_Sanitizer.tryToSanitize(); " + clearDataNow.getAttribute("oncommand")); } } PK OzQ8r(yy.content/tabmixplus/pref/preferencesOverlay.xul %pref-tabmixDTD; %tabmixplusDTD; ]> PK 8T 92%content/tabmixplus/pref/tab_panel.xul %pref-tabmixDTD; %tabmixplusDTD; ]>