browser/base/content/aboutSocialError.xhtml
author Phil Ringnalda <philringnalda@gmail.com>
Fri, 05 Oct 2012 20:11:45 -0700
changeset 109480 9b9678df767268bee3aceef3c09a422909be458d
parent 109464 c4bb09009a54d3afe26c40a9eb00a799dfdfafa6
child 109485 d8e2479870b90d2ca43a7d2bc18d033fa1c5cbf6
permissions -rw-r--r--
Backout e9237d1ae5ff (bug 790201), 0ecee5121681 (bug 766616), d8ec55d3b98e (bug 796218), c4bb09009a54 (bug 798437), 6a8bb5834090 (bug 766616) for bustage on a CLOSED TREE

<?xml version="1.0" encoding="UTF-8"?>

<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->

<!DOCTYPE html [
  <!ENTITY % htmlDTD
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "DTD/xhtml1-strict.dtd">
  %htmlDTD;
  <!ENTITY % netErrorDTD SYSTEM "chrome://global/locale/netError.dtd">
  %netErrorDTD;
]>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>&loadError.label;</title>
    <link rel="stylesheet" type="text/css" media="all"
          href="chrome://browser/skin/aboutSocialError.css"/>
  </head>

  <body>
    <div id="error-box">
      <p id="main-error-msg"></p>
      <p id="helper-error-msg"></p>
    </div>
    <div id="button-box">
      <button id="btnTryAgain" onclick="tryAgainButton()"/>
      <button id="btnCloseSidebar" onclick="closeSidebar()"/>
    </div>
  </body>

  <script type="text/javascript;version=1.8"><![CDATA[
    const Cu = Components.utils;

    Cu.import("resource://gre/modules/Services.jsm");
    Cu.import("resource://gre/modules/Social.jsm");

    let config = {
      tryAgainCallback: reloadProvider
    }

    function parseQueryString() {
      let url = document.documentURI;
      let queryString = url.replace(/^about:socialerror\??/, "");

      let modeMatch = queryString.match(/mode=([^&]+)/);
      let mode = modeMatch && modeMatch[1] ? modeMatch[1] : "";

      switch (mode) {
        case "onlyRefreshSidebar":
          config.tryAgainCallback = refreshSidebar;
          break;
        default:
          break;
      }
    }

    function setUpStrings() {
      let brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
      let browserBundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");

      let productName = brandBundle.GetStringFromName("brandShortName");
      let providerName = Social && Social.provider && Social.provider.name;

      // Sets up the error message
      let msg = browserBundle.formatStringFromName("social.error.message", [productName, providerName], 2);
      document.getElementById("main-error-msg").textContent = msg;

      // Sets up the buttons' labels and accesskeys
      let btnTryAgain = document.getElementById("btnTryAgain");
      btnTryAgain.textContent = browserBundle.GetStringFromName("social.error.tryAgain.label");
      btnTryAgain.accessKey = browserBundle.GetStringFromName("social.error.tryAgain.accesskey");

      let btnCloseSidebar = document.getElementById("btnCloseSidebar");
      btnCloseSidebar.textContent = browserBundle.GetStringFromName("social.error.closeSidebar.label");
      btnCloseSidebar.accessKey = browserBundle.GetStringFromName("social.error.closeSidebar.accesskey");
    }

    function closeSidebar() {
      Social.toggleSidebar();
    }

    function refreshSidebar() {
      window.location.href = Social.provider.sidebarURL;
    }

    function reloadProvider() {
      Social.provider.reload();
    }

    function tryAgainButton() {
      config.tryAgainCallback();
    }

    parseQueryString();
    setUpStrings();
  ]]></script>
</html>