<?xml version="1.0"?>
<?xul-overlay href="chrome://global/content/editMenuOverlay.xul"?>
<?xul-overlay href="chrome://browser/content/baseMenuOverlay.xul"?>
<?xul-overlay href="chrome://browser/content/places/placesOverlay.xul"?>
<!DOCTYPE bindings [
<!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd" >
%browserDTD;
<!ENTITY % baseMenuOverlayDTD SYSTEM "chrome://browser/locale/baseMenuOverlay.dtd" >
%baseMenuOverlayDTD;
<!ENTITY % tabBrowserDTD SYSTEM "chrome://browser/locale/tabbrowser.dtd" >
%tabBrowserDTD;
<!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
%globalDTD;
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
%brandDTD;
<!ENTITY % mainDTD SYSTEM "chrome://browser/locale/preferences/main.dtd">
%mainDTD;
]>

<bindings id="myTabBarRightBox"
   xmlns="http://www.mozilla.org/xbl"
   xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
   xmlns:xbl="http://www.mozilla.org/xbl">
  <!-- Binding attached to the <hbox class="tabbrowser-strip"/> inside the
       <tabbrowser/> so that we can have a toolbar at each end of it.
       The anonid's are used when persisting the toolbar's attributes. -->
  <!-- 实现了基本功能,但不知应怎样引用javascript文件.本文的代码来源于firefox.本人只作了少量修改. -->
  <binding  id="myTabBarRight" >
    <resources>
      <stylesheet src="chrome://browser/skin/places/places.css"/>
      <stylesheet src="chrome://global/skin/xulscrollbars.css"/>
    </resources>
    <content>

  <xul:toolbox id="myTabBox-Right-toolbox"
	class="chromeclass-toolbar" palette="BrowserToolbarPalette"
	context="toolbar-context-menu" >
	<xul:menubar id="myTab-Right-toolbar" context="toolbar-context-menu">
		<!-- 恢复打开的tab-->
		<xul:toolbarbutton id="myUndoCloseTab" class="myTabToolBarMenuButton"
				label="&undoCloseTab.label;"
				type="menu"
				disabled="true"
				tooltiptext="&undoCloseTab.label;"
				onmousedown="
				  var undoPopup = document.getElementById('myhistoryUndoPopup');

				  while (undoPopup.hasChildNodes())
					undoPopup.removeChild(undoPopup.firstChild);

				  var ss = Cc['@mozilla.org/browser/sessionstore;1'].
						   getService(Ci.nsISessionStore);
				  if (ss.getClosedTabCount(window) == 0) {
					undoPopup.parentNode.setAttribute('disabled', true);
					return;
				  }

				  undoPopup.parentNode.removeAttribute('disabled');

				  var undoItems = eval('(' + ss.getClosedTabData(window) + ')');
				  for (var i = 0; i != undoItems.length; i++) {
					var m = document.createElement('menuitem');
					m.setAttribute('label', undoItems[i].title);
					if (undoItems[i].image)
					  m.setAttribute('image', undoItems[i].image);
					m.setAttribute('class', 'menuitem-iconic bookmark-item');
					m.setAttribute('value', i);
					m.setAttribute('oncommand', 'undoCloseTab(' + i + ');');
					m.addEventListener('click', undoCloseMiddleClick, false);
					if (i == 0)
					  m.setAttribute('key', 'key_undoCloseTab');
					undoPopup.appendChild(m);
				  }

				  var strings = gNavigatorBundle;
				  undoPopup.appendChild(document.createElement('menuseparator'));
				  m = undoPopup.appendChild(document.createElement('menuitem'));
				  m.setAttribute('label', strings.getString('menuOpenAllInTabs.label'));
				  m.setAttribute('accesskey', strings.getString('menuOpenAllInTabs.accesskey'));
				  m.addEventListener('command', function() {
					for (var i = 0; i != undoItems.length; i++)
					  undoCloseTab();
				  }, false);
				">
				<xul:menupopup id="myhistoryUndoPopup" position="after_start" />
		</xul:toolbarbutton>

		<!-- 打开主页 -->
		<xul:panel id="myBookMarkOptions" max-width="390" height="164"
			onpopupshowing="
				var browser = document.getElementById('content');
				var newVal =  browser.browsers[selectedIndex].currentURI.spec;
				var myBrowserCurrentPage =document.getElementById('myBrowserCurrentPage');
				myBrowserCurrentPage.value=newVal ;
			">

	  <xul:box id="myBookMarkOptionsTitleBox" >
		  <xul:label id="myBookMarkOptionsTitle"  value="Add or Chage Home Page" />
		  <xul:spacer flex="100"/>
		  <xul:toolbarbutton id="yBookMarkOptionsTitleClose"
				tooltiptext=""
				oncommand="var myBookMarkOptions = document.getElementById('myBookMarkOptions');
					myBookMarkOptions.hidePopup();
				"/>
	  </xul:box>
	  <xul:box id="myBookMarkOptionsBox"  flex="1">
		  <xul:image id="myHomeImage" />
	  <xul:hbox align="left" pack="end" flex="1">
			<xul:vbox>
				<xul:vbox >
					<xul:label id="myTitle" value="Would you like to use the following as your home page" />
					<xul:textbox id="myBrowserCurrentPage"  />
				</xul:vbox>

			<xul:vbox  pack="start">
				<xul:radiogroup id="myPageOption">
					<xul:radio
							value="1"
							label="Use this webpage as your only home page"
								id="useCurrent"
							/>
					<xul:radio label="Add this webpage to your home page tabs"
							value="2"
							id="addCurrent"
							/>
					<xul:radio label="Use the current tab set as your home page"
							value="3"
							id="addAllPage"
							/>
					<xul:radio label="&restoreDefault.label;"
							value="4"
							id="restoreDefaultHomePage"
							/>
				</xul:radiogroup>
			</xul:vbox>

		<xul:hbox  align="end" pack="end" >
		<xul:button id="myBookMarkOptionsYes" label="yes"
			 oncommand="
				var myPageOption = document.getElementById('myPageOption');
				var browser = document.getElementById('content');
				if (browser.browsers.length > 1) {
					switch(myPageOption.value)
					{
						case '1':
						  var newVal =browser.browsers[selectedIndex].currentURI.spec;
						  break;
						case '2':
						  var homePage = document.getElementById('browser.startup.homepage');
						  var newVal = homePage.value;
						  newVal += '|' + browser.browsers[selectedIndex].currentURI.spec;
						  break;
						case '3':
						  var newVal = browser.browsers[0].currentURI.spec;
						  for (var i = 1; i &lt;  browser.browsers.length; i++)
							newVal += '|' + browser.browsers[i].currentURI.spec;
						  break;
						default:
						  var homePage = document.getElementById('browser.startup.homepage');
						  var newVal = homePage.defaultValue;
					}
					gPrefService.setCharPref('browser.startup.homepage', newVal);
				}
				var myBookMarkOptions = document.getElementById('myBookMarkOptions');
				myBookMarkOptions.hidePopup();
				 "/>

				<xul:button id="myBookMarkOptionsNo" label="no"
					oncommand="var myBookMarkOptions = document.getElementById('myBookMarkOptions');
					myBookMarkOptions.hidePopup();
				 "/>
			</xul:hbox>
			</xul:vbox>
		  </xul:hbox>
		  </xul:box>

		</xul:panel>

		<xul:preferences id="mainPreferences">
		  <!-- Startup -->
		  <xul:preference id="browser.startup.homepage"
			  name="browser.startup.homepage"
			  type="wstring"/>
		</xul:preferences>

		<xul:toolbarbutton id="myTabhome-button"
				class="myTabToolBarMenuButton"
				myType="button"
				type="menu-button"
				command="Browser:Home"
				tooltiptext="&homeButton.label;">
			<xul:menupopup
				position="after_end"
				onpopuphidden="if (event.target == this)
					while(this.firstChild.id != 'homepagesSeparator') this.removeChild(this.firstChild);"
				oncommand="event.stopPropagation();"
				onpopupshowing="
					if (event.target != this) return;
					var links = gPrefService.getCharPref('browser.startup.homepage');
					var str = links.split('|');
					var i = 0;
					var separator = this.firstChild;
					while (str[i] != null) {
						var menuitem = document.createElement('menuitem');
						menuitem.setAttribute('label', str[i]);
						menuitem.className = 'menuitem-iconic bookmark-item';
						menuitem.setAttribute('oncommand', 'loadURI(&quot;' + str[i] + '&quot;);');
						this.insertBefore(menuitem, separator);
						i++;
					}
					this.lastChild.hidden = i == 1 &amp;&amp; str[0] == 'about:blank';
				">

				<xul:menuseparator id="homepagesSeparator"/>
				<xul:popup onpopupshowing="
					if (this.result) gPrefService.setCharPref('browser.startup.homepage', this.result);
				"/>
				<xul:menuitem
					id="myAddChangeHomePage"
					label="Add or Change Home Page ..."
					image="chrome://global/skin/CuteMenus/home.png"
					oncommand="
						var browsers = document.getElementById('content').browsers;
						var homePage = document.getElementById('browser.startup.homepage');
						var uriList = browsers[0].currentURI.spec;

						for (var i = 1; i &lt; browsers.length; i++)
						uriList += '|' + browsers[i].currentURI.spec;

						openDialog('chrome://global/skin/myFirefoxTab/x.xul', null,'chrome,centerscreen,dialog,modal',
							browsers[selectedIndex].currentURI.spec,
							browsers.length,
							homePage.value,
							homePage.defaultValue,
							uriList,
							this.previousSibling);
					"/>
				<xul:menu id="myRemoveMenu" label="Remove" accesskey="r">
					<xul:menupopup
						onpopupshowing="
						var separator = this.firstChild;
						for (var item = this.parentNode.parentNode.firstChild;
							item.id != 'homepagesSeparator'; item = item.nextSibling) {
							var newitem = this.insertBefore(item.cloneNode(true), separator);
							newitem.removeAttribute('oncommand');
							newitem.addEventListener('command', function() {
								var string;
								if (this.nextSibling.id == 'removeHomepagesSeparator' &amp;&amp; !this.previousSibling)
									string = 'about:blank';
								else {
									string = gPrefService.getCharPref('browser.startup.homepage').replace(
										this.previousSibling ? '|' + this.label : this.label + '|', '');
								}
								gPrefService.setCharPref('browser.startup.homepage', string);
							}, false);
						}
						"
						onpopuphidden="
							while (this.firstChild.id != 'removeHomepagesSeparator')
							this.removeChild(this.firstChild);
					">
						<xul:menuseparator id="removeHomepagesSeparator"/>
						<xul:menuitem  id="myRemoveAll"
							label="Remove All"
							accesskey="a"
							oncommand="gPrefService.setCharPref('browser.startup.homepage', 'about:blank')"/>
					</xul:menupopup>
				</xul:menu>
			</xul:menupopup>
		</xul:toolbarbutton>
		<!-- 使用feed -->
		<xul:toolbarbutton id="feed-button"  type="menu"
				style="-moz-user-focus: none"
				class="myTabToolBarButton"
				chromedir="&locale.dir;"
				onclick="return FeedHandler.onFeedButtonClick(event);">
		  <xul:menupopup position="after_end"
					 onpopupshowing="return FeedHandler.buildFeedList(this);"
					 oncommand="return FeedHandler.subscribeToFeed(null, event);"
					 onclick="checkForMiddleClick(this, event);"/>
		</xul:toolbarbutton>

		<!-- 下载的内容 -->
		<xul:toolbarbutton id="myTabdownloads-button" class="myTabToolBarButton"
				   observes="Tools:Downloads"
				   label="&downloads.label;"
				   tooltiptext="&downloads.tooltip;"/>

		<!-- 打印 -->
		<xul:toolbarbutton id="myTabPrint-button"
						class="myTabToolBarMenuButton"
						type="menu-button"
						myType="button"
						command="cmd_print"
						tooltiptext="&printButton.tooltip;">
				  <xul:menupopup  position="after_end" >
					  <!-- 打印 -->
					  <xul:menuitem label="&printCmd.label;"
							  accesskey="&printCmd.accesskey;"
							  key="printKb" command="cmd_print"/>
					  <!-- 打印预览 -->
					  <xul:menuitem label="&printPreviewCmd.label;"
							  accesskey="&printPreviewCmd.accesskey;"
							  command="cmd_printPreview"/>
					  <xul:menuseparator />
					  <!-- 页面设置 -->
					  <xul:menuitem label="&printSetupCmd.label;"
							  accesskey="&printSetupCmd.accesskey;"
							  command="cmd_pageSetup"/>
				  </xul:menupopup>
		</xul:toolbarbutton>
		<!-- 页面 -->
		<xul:toolbarbutton id="myPageInfo"
					type="menu"
					class="myTabToolBarMenuButton"
					tooltiptext="&pageInfoCmd.label;">
			<xul:menupopup  position="after_end" >

			<xul:menuitem id="menu_find"
					label="&findOnCmd.label;"
					accesskey="&findOnCmd.accesskey;"
					key="key_find"
					command="cmd_find"/>
			<xul:menuseparator/>
				<xul:menuitem label="&cutCmd.label;"
						  accesskey="&cutCmd.accesskey;"
						  command="cmd_cut"/>
				<xul:menuitem label="&copyCmd.label;"
						  accesskey="&copyCmd.accesskey;"
						  command="cmd_copy"/>
				<xul:menuitem label="&pasteCmd.label;"
						  accesskey="&pasteCmd.accesskey;"
						  command="cmd_paste"/>
				<xul:menuseparator/>
				<xul:menuitem label="&newNavigatorCmd.label;"
						  accesskey="&newNavigatorCmd.accesskey;"
						  key="key_newNavigator"
						  command="cmd_newNavigator"/>

				<xul:menuitem label="&savePageCmd.label;"
							accesskey="&savePageCmd.accesskey;"
							key="key_savePage"
							command="Browser:SavePage"/>
				<xul:menuitem id="menu_sendLink"
							label="&sendPageCmd.label;"
							accesskey="&sendPageCmd.accesskey;"
							command="Browser:SendLink"/>
				<xul:menuseparator/>
				<xul:menu id="viewFullZoomMenu" label="&fullZoom.label;"
				accesskey="&fullZoom.accesskey;" observes="isImage">
				  <xul:menupopup>
					<xul:menuitem key="key_fullZoomEnlarge" label="&fullZoomEnlargeCmd.label;"
					accesskey="&fullZoomEnlargeCmd.accesskey;"
							  command="cmd_fullZoomEnlarge"/>
					<xul:menuitem key="key_fullZoomReduce"  label="&fullZoomReduceCmd.label;"
					accesskey="&fullZoomReduceCmd.accesskey;"
							  command="cmd_fullZoomReduce"/>
					<xul:menuseparator/>
					<xul:menuitem key="key_fullZoomReset" label="&fullZoomResetCmd.label;"
					accesskey="&fullZoomResetCmd.accesskey;"
							  command="cmd_fullZoomReset"/>
				  </xul:menupopup>
				</xul:menu>
				<xul:menuseparator/>
				<xul:menuitem accesskey="&pageSourceCmd.accesskey;"
						label="&pageSourceCmd.label;"
						key="key_viewSource"
						command="View:PageSource"/>
				<xul:menuitem accesskey="&pageInfoCmd.accesskey;"
					label="&pageInfoCmd.label;"
					command="View:PageInfo"/>

				<xul:menuitem accesskey="&fullScreenCmd.accesskey;"
					  label="&fullScreenCmd.label;"
					  id="fullScreenItem"
					  type="checkbox"
					  command="View:FullScreen"/>
			</xul:menupopup>
		</xul:toolbarbutton>
		<!-- 扩展 -->
	   <xul:toolbarbutton id="myFxvaExtendButton"  type="menu"
				tooltiptext="&toolsMenu.label;"
				class="myTabToolBarMenuButton"
				label="&toolsMenu.label;"
				accesskey="&toolsMenu.accesskey;">
	  <xul:menupopup id="menu_ToolsPopup" position="after_end">
		  <xul:menuitem id="sanitizeItem"
					accesskey="&clearPrivateDataCmd.accesskey;"
					label="&clearPrivateDataCmd.label;"
					key="key_sanitize" command="Tools:Sanitize"/>
	<!--管理书签-->
		 <xul:menuitem label="&organizeBookmarks.label;"
				  command="Browser:ShowAllBookmarks" key="manBookmarkKb"/>
		  <xul:menuseparator/>
		  <xul:menuitem label="&downloads.label;" accesskey="&downloads.accesskey;"
					key="key_openDownloads" command="Tools:Downloads"/>
		  <xul:menuitem label="&addons.label;" accesskey="&addons.accesskey;"
					command="Tools:Addons"/>
		  <xul:menuseparator id="devToolsSeparator"/>
		  <xul:menuitem id="javascriptConsole"
					label="&errorConsoleCmd.label;" accesskey="&errorConsoleCmd.accesskey;"
					oncommand="toJavaScriptConsole();"/>
		  <xul:menuseparator id="prefSep"/>
		  <xul:menuitem label="&import.label;" accesskey="&import.accesskey;" oncommand="BrowserImport();"/>
		  <xul:menuitem id="goOfflineMenuitem"
					label="&goOfflineCmd.label;" accesskey="&goOfflineCmd.accesskey;"
					type="checkbox" oncommand="BrowserOffline.toggleOfflineStatus();"/>
		  <xul:menuitem disabled="false" label="&updateCmd.label;" id="checkForUpdates"
					oncommand="checkForUpdates(); "
					accesskey="o"
					class="menuitem-iconic" />
		  <xul:menuseparator id="prefSep"/>
		  <xul:menuitem id="myFxva-Settings" label="Theme Settings..."  style="display:none "
					oncommand="window.openDialog('chrome://myfxva/content/option.xul', '', 'chrome,dialog,modal')"/>
		  <xul:menuitem id="menu_preferences"
					label="&preferencesCmd.label;"
					accesskey="&preferencesCmd.accesskey;"
					oncommand="openPreferences();"/>
		  </xul:menupopup>
	</xul:toolbarbutton>
  </xul:menubar >

  </xul:toolbox>
  </content>
  </binding>
</bindings>