Ejemplo n.º 1
0
    createdCallback: function() {
      this.acctsSlice = MailAPI.viewAccounts(false);
      this.acctsSlice.onsplice = this.onAccountsSplice.bind(this);

      this._secretButtonClickCount = 0;
      this._secretButtonTimer = null;
    },
Ejemplo n.º 2
0
/**
 * Global settings, list of accounts.
 */
function SettingsMainCard(domNode, mode, args) {
  this.domNode = domNode;

  this.acctsSlice = MailAPI.viewAccounts(false);
  this.acctsSlice.onsplice = this.onAccountsSplice.bind(this);

  domNode.getElementsByClassName('tng-close-btn')[0]
    .addEventListener('click', this.onClose.bind(this), false);

  var checkIntervalNode =
    domNode.getElementsByClassName('tng-main-check-interval')[0];
console.log('  CONFIG CURRENTLY:', JSON.stringify(MailAPI.config));//HACK
  checkIntervalNode.value = MailAPI.config.syncCheckIntervalEnum;
  checkIntervalNode.addEventListener(
    'change', this.onChangeSyncInterval.bind(this), false);

  this.accountsContainer =
    domNode.getElementsByClassName('tng-accounts-container')[0];

  domNode.getElementsByClassName('tng-account-add')[0]
    .addEventListener('click', this.onClickAddAccount.bind(this), false);

  this._secretButtonClickCount = 0;
  this._secretButtonTimer = null;
  // TODO: Need to remove the secret debug entry before shipping.
  domNode.getElementsByClassName('tng-email-lib-version')[0]
    .addEventListener('click', this.onClickSecretButton.bind(this), false);
}
Ejemplo n.º 3
0
/**
 * Global settings, list of accounts.
 */
function SettingsMainCard(domNode, mode, args) {
  this.domNode = domNode;

  this.acctsSlice = MailAPI.viewAccounts(false);
  this.acctsSlice.onsplice = this.onAccountsSplice.bind(this);

  domNode.getElementsByClassName('tng-close-btn')[0]
    .addEventListener('click', this.onClose.bind(this), false);

  this.accountsContainer =
    domNode.getElementsByClassName('tng-accounts-container')[0];

  domNode.getElementsByClassName('tng-account-add')[0]
    .addEventListener('click', this.onClickAddAccount.bind(this), false);

  this._secretButtonClickCount = 0;
  this._secretButtonTimer = null;
  // TODO: Need to remove the secret debug entry before shipping.
  domNode.getElementsByClassName('tng-email-lib-version')[0]
    .addEventListener('click', this.onClickSecretButton.bind(this), false);
}
Ejemplo n.º 4
0
  showMessageViewOrSetup: function(showLatest) {
    // Get the list of accounts including the unified account (if it exists)

    var acctsSlice = MailAPI.viewAccounts(false);
    acctsSlice.oncomplete = function() {
      // - we have accounts, show the message view!
      if (acctsSlice.items.length) {
        // For now, just use the first one; we do attempt to put unified first
        // so this should generally do the right thing.
        // XXX: Because we don't have unified account now, we should switch to
        //       the latest account which user just added.
        var account = showLatest ? acctsSlice.items.slice(-1)[0] :
                                   acctsSlice.defaultAccount;

        var foldersSlice = MailAPI.viewFolders('account', account);
        foldersSlice.oncomplete = function() {
          var inboxFolder = foldersSlice.getFirstFolderWithType('inbox');

          if (!inboxFolder)
            common.dieOnFatalError('We have an account without an inbox!',
                foldersSlice.items);

          if (!initialCardInsertion)
            Cards.removeAllCards();

          // Push the message list card
          Cards.pushCard(
            'message_list', 'nonsearch', 'immediate',
            {
              folder: inboxFolder,
              cacheableFolderId: account === acctsSlice.defaultAccount ?
                                 inboxFolder.id : null,
              waitForData: initialCardInsertion,
              onPushed: function() {
                // Add navigation, but before the message list.
                Cards.pushCard(
                  'folder_picker', 'navigation', 'none',
                  {
                    acctsSlice: acctsSlice,
                    curAccount: account,
                    foldersSlice: foldersSlice,
                    curFolder: inboxFolder,
                    onPushed: function() {
                      hasCardsPushed = true;

                      if (activityCallback) {
                        activityCallback();
                        activityCallback = null;
                      }
                    }
                  },
                  // Place to left of message list
                  'left');
              }
            });

          initialCardInsertion = false;
        };
      } else {
        if (acctsSlice)
          acctsSlice.die();

        // - no accounts, show the setup page!
        if (!Cards.hasCard(['setup_account_info', 'default'])) {
          if (activityCallback) {
            // Clear out activity callback, but do it
            // before calling activityCallback, in
            // case that code then needs to set a delayed
            // activityCallback for later.
            var activityCb = activityCallback;
            activityCallback = null;
            var result = activityCb();
            if (!result)
              return;
          }

          if (initialCardInsertion) {
            initialCardInsertion = false;
          } else {
            Cards.removeAllCards();
          }

          Cards.pushCard(
            'setup_account_info', 'default', 'immediate',
            {
              allowBack: false,
              onPushed: function(impl) {
                hasCardsPushed = true;
                htmlCache.delayedSaveFromNode(impl.domNode.cloneNode(true));
              }
            });
        }
      }
    };
  }