<?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="myFireFoxTab-bindings"
   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. -->
  <!-- 本功能参照了all in one side bar扩展. 本人想了很久才搞定,难呀.如果大家需要使用,请指出来源地点.多谢了!:) -->
  <binding  id="tab-toolbars" >
    <content>
	  <xul:hbox position="1">
	  <xul:toolbox id="myTabBox-Left-toolbox" palette="BrowserToolbarPalette"  mode="icons" context="toolbar-context-menu" >
        <xul:toolbar id="myTab-Left-toolbar"  anonymous="true" fullscreentoolbar="true"
        	context="toolbar-context-menu" customizable="true" mode="icons" iconsize="small">
        	<!-- 打开历史-->
        	<xul:toolbarbutton id="myTabHistory-button"   hidden="true"
						   observes="viewHistorySidebar" />
        	<xul:toolbarbutton id="myTabBookmarks-button-hide"   hidden="true"
						   observes="viewBookmarksSidebar" />

        	<!-- 打开收藏 -->
        	<xul:hbox id="myTab-left-group">
        	<xul:toolbarbutton id="myFxvaBookmarks"  hidden="true"
					class="myTabToolBarButton"
					observes="viewBookmarksSidebar"
					tooltiptext="&bookmarksButton.label;" />

        	<!--增加到书签中-->
        	<xul:toolbarbutton id="myAddBookMark-button"
					class="myTabToolBarButton"
					type="menu"
                       label="tabCmd.label;"
                       tooltiptext="" >
						<xul:menupopup  position="after_start" >
						<!--加到收藏  -->
							<xul:menuitem key="addBookmarkAsKb"
									  label="&bookmarkThisPageCmd.label;"
									  command="Browser:AddBookmarkAs"/>
						<!--所有加到收藏  -->

							<xul:menuitem id="bookmarkAllCmd"
									  key="bookmarkAllTabsKb"
									  label="&bookmarkAllCmd.label;"
									  command="Browser:BookmarkAllTabs"/>
							<xul:menuseparator />
						<!--管理书签-->
							<xul:menuitem label="&import.label;"
								accesskey="&import.accesskey;"
								oncommand="BrowserImport();"/>
							<xul:menuseparator />
						     <xul:menuitem label="&organizeBookmarks.label;"
									  command="Browser:ShowAllBookmarks" key="manBookmarkKb"/>
					     </xul:menupopup>
					</xul:toolbarbutton>
			</xul:hbox>
        </xul:toolbar >
	  </xul:toolbox>
      </xul:hbox>

     <children/>

      <xul:hbox position="1000">
      <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:hbox id="myBookMarkOptionsBox">
				  <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="useBookmark"
								/>
						<xul:radio label="Use the current tab set as your home page"
								value="3"
								id="useBookmark"
								/>
						<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:hbox>

        	</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:menuitem
						label="Add or Change Home Page ..."
						image="chrome://global/skin/CuteMenus/home.png"
						oncommand="
							var myBookMarkOptions = document.getElementById('myBookMarkOptions');
							var browser = document.getElementById('main-window');
							myBookMarkOptions.popupBoxObject.openPopup(document.getElementById('myTabhome-button'), 'after_end', -1, -1, false, false);
						"/>
					<xul:menu 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') string = 'about:blank';
										else {
											string = gPrefService.getCharPref('browser.startup.homepage').replace(
												this.nextSibling ? 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
								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>
      </xul:hbox>
    </content>
  </binding>

  <binding id="tabbrowser-tab" display="xul:hbox"
	  extends="chrome://browser/content/tabbrowser.xml#tabbrowser-tab">
    <content chromedir="&locale.dir;"
             closetabtext="&closeTab.label;">
      <xul:image class="myTab-left-corner" xbl:inherits="selected"/>
      <xul:hbox class="tab-image-left" xbl:inherits="selected"/>
      <xul:hbox flex="1" class="tab-image-middle" align="center" xbl:inherits="selected">
		  <xul:image xbl:inherits="validate,src=image" class="tab-icon-image"/>
		  <xul:label flex="1" xbl:inherits="value=label,crop,accesskey" class="tab-text"/>
      </xul:hbox>
      <xul:toolbarbutton anonid="close-button" tabindex="-1" class="tab-close-button"/>
      <xul:hbox class="tab-image-right" xbl:inherits="selected"/>
      <xul:image class="myTab-right-corner" xbl:inherits="selected"  />
    </content>
  </binding>



   <binding id="tabbrowser-tabs"
            extends="chrome://browser/content/tabbrowser.xml#tabbrowser-tabs">

    <content>
      <xul:stack flex="1" class="tabs-stack">
        <xul:vbox>
          <xul:spacer flex="1"/>
          <xul:hbox class="tabs-bottom" align="center"/>
        </xul:vbox>
        <xul:hbox xbl:inherits="overflow" class="tabs-container">
			<xul:toolbarbutton id="myShowCaseButton"
				anonid="alltabs-button"
				type="menu"
				tooltiptext="Firefox ShowCase">
				<xul:menupopup class="tabs-alltabs-popup" anonid="alltabs-popup"
					position="after_start"/>
			</xul:toolbarbutton>

			<xul:stack class="myTabs-alltabs-box" align="center" pack="end" chromedir="&locale.dir;">
				<xul:hbox flex="1" class="tabs-alltabs-box" anonid="alltabs-box"/>
				<xul:hbox flex="1" class="tabs-alltabs-box-animate" anonid="alltabs-box-animate"/>
				<xul:toolbarbutton class="tabs-alltabs-button" type="menu"
								  >
				  <xul:menupopup class="tabs-alltabs-popup" anonid="alltabs-popup"
								 position="after_start"/>
				</xul:toolbarbutton>
			</xul:stack>


			<xul:arrowscrollbox anonid="arrowscrollbox" orient="horizontal" flex="1"
				style="min-width: 1px;" chromedir="&locale.dir;"
				clicktoscroll="true"

				class="tabbrowser-arrowscrollbox">
				<children/>
			</xul:arrowscrollbox>

            <!-- 在标签上加了一个按钮 -->
			<xul:toolbarbutton id="myNewTabButtonEnd"
					class="myNewTabButton"
					command="cmd_newNavigatorTab"/>

          <xul:toolbarbutton anonid="tabs-closebutton"
                             class="close-button tabs-closebutton" chromedir="&locale.dir;"/>
        </xul:hbox>
      </xul:stack>
    </content>


  </binding>

    <binding id="scrollbox" extends="chrome://global/content/bindings/scrollbox.xml#scrollbox">
    <content>
		<xul:box flex="1"   pack="start">
			 <children/>
			 <xul:hbox id="myTabGoBox"  position="100" pack="start" >
				<xul:toolbarbutton id="myTabBarNewButton"
					   class="myNewTabButton"
					   command="cmd_newNavigatorTab"/>
			 </xul:hbox>
		</xul:box>
	</content>
  </binding>


</bindings>