B2G/gaia/apps/email/js/compose-cards.js
/**
 * Composer card; wants an initialized message composition object when it is
 * created (for now).
 */
Composer card; wants an initialized message composition object when it is
created (for now).
Composer card ; wants an initialized message composition object when it is created ( for now ) .
function ComposeCard(domNode, mode, args) {
  this.domNode = domNode;
  this.composer = args.composer;
  this.activity = args.activity;
  domNode.getElementsByClassName('cmp-back-btn')[0]
    .addEventListener('click', this.onBack.bind(this), false);
  this.sendButton = domNode.getElementsByClassName('cmp-send-btn')[0];
  this.sendButton.addEventListener('click', this.onSend.bind(this), false);
  this._bound_onVisibilityChange = this.onVisibilityChange.bind(this);
  document.addEventListener('mozvisibilitychange',
                            this._bound_onVisibilityChange);
  this.toNode = domNode.getElementsByClassName('cmp-to-text')[0];
  this.ccNode = domNode.getElementsByClassName('cmp-cc-text')[0];
  this.bccNode = domNode.getElementsByClassName('cmp-bcc-text')[0];
  this.subjectNode = domNode.getElementsByClassName('cmp-subject-text')[0];
  this.textBodyNode = domNode.getElementsByClassName('cmp-body-text')[0];
  this.textBodyNode.addEventListener('input',
                                     this.onTextBodyDelta.bind(this));
  this.textBodyNode.addEventListener('change',
                                     this.onTextBodyDelta.bind(this));
  this.htmlBodyContainer = domNode.getElementsByClassName('cmp-body-html')[0];
  this.htmlIframeNode = null;
  this.scrollContainer =
    domNode.getElementsByClassName('scrollregion-below-header')[0];
  this.toNode.addEventListener('keydown', this.onAddressKeydown.bind(this));
  this.ccNode.addEventListener('keydown', this.onAddressKeydown.bind(this));
  this.bccNode.addEventListener('keydown', this.onAddressKeydown.bind(this));
  this.toNode.addEventListener('input', this.onAddressInput.bind(this));
  this.ccNode.addEventListener('input', this.onAddressInput.bind(this));
  this.bccNode.addEventListener('input', this.onAddressInput.bind(this));
  var addBtns = domNode.getElementsByClassName('cmp-contact-add');
  for (var i = 0; i < addBtns.length; i++) {
    addBtns[i].addEventListener('click', this.onContactAdd.bind(this));
  }
  var containerList = domNode.getElementsByClassName('cmp-combo');
  for (var i = 0; i < containerList.length; i++) {
    containerList[i].addEventListener('click',
      this.onContainerClick.bind(this));
  }
  var attachmentBtns =
    domNode.getElementsByClassName('cmp-attachment-btn');
  for (var i = 0; i < attachmentBtns.length; i++) {
    attachmentBtns[i].addEventListener('click',
                                       this.onAttachmentAdd.bind(this));
  }
  var subjectContainer = domNode.querySelector('.cmp-subject');
  subjectContainer.addEventListener('click', function subjectFocus(evt) {
    focusInputAndPositionCursorFromContainerClick(
      evt, subjectContainer.querySelector('input'));
  });
  this.sentAudioKey = 'mail.sent-sound.enabled';
  this.sentAudio = new Audio('/sounds/sent.ogg');
  this.sentAudio.mozAudioChannelType = 'notification';
  this.sentAudioEnabled = false;
  if (navigator.mozSettings) {
    var req = navigator.mozSettings.createLock().get(this.sentAudioKey);
    req.onsuccess = (function onsuccess() {
      this.sentAudioEnabled = req.result[this.sentAudioKey];
    }).bind(this);
    navigator.mozSettings.addObserver(this.sentAudioKey, (function(e) {
      this.sentAudioEnabled = e.settingValue;
    }).bind(this));
  }
}
function ComposeCard ( domNode , mode , args ) { this . domNode = domNode ; this . composer = args . composer ; this . activity = args . activity ; domNode . getElementsByClassName ( 'cmp-back-btn' ) [ 0 ] . addEventListener ( 'click' , this . onBack . bind ( this ) , false ) ; this . sendButton = domNode . getElementsByClassName ( 'cmp-send-btn' ) [ 0 ] ; this . sendButton . addEventListener ( 'click' , this . onSend . bind ( this ) , false ) ; this . _bound_onVisibilityChange = this . onVisibilityChange . bind ( this ) ; document . addEventListener ( 'mozvisibilitychange' , this . _bound_onVisibilityChange ) ; this . toNode = domNode . getElementsByClassName ( 'cmp-to-text' ) [ 0 ] ; this . ccNode = domNode . getElementsByClassName ( 'cmp-cc-text' ) [ 0 ] ; this . bccNode = domNode . getElementsByClassName ( 'cmp-bcc-text' ) [ 0 ] ; this . subjectNode = domNode . getElementsByClassName ( 'cmp-subject-text' ) [ 0 ] ; this . textBodyNode = domNode . getElementsByClassName ( 'cmp-body-text' ) [ 0 ] ; this . textBodyNode . addEventListener ( 'input' , this . onTextBodyDelta . bind ( this ) ) ; this . textBodyNode . addEventListener ( 'change' , this . onTextBodyDelta . bind ( this ) ) ; this . htmlBodyContainer = domNode . getElementsByClassName ( 'cmp-body-html' ) [ 0 ] ; this . htmlIframeNode = null ; this . scrollContainer = domNode . getElementsByClassName ( 'scrollregion-below-header' ) [ 0 ] ; this . toNode . addEventListener ( 'keydown' , this . onAddressKeydown . bind ( this ) ) ; this . ccNode . addEventListener ( 'keydown' , this . onAddressKeydown . bind ( this ) ) ; this . bccNode . addEventListener ( 'keydown' , this . onAddressKeydown . bind ( this ) ) ; this . toNode . addEventListener ( 'input' , this . onAddressInput . bind ( this ) ) ; this . ccNode . addEventListener ( 'input' , this . onAddressInput . bind ( this ) ) ; this . bccNode . addEventListener ( 'input' , this . onAddressInput . bind ( this ) ) ; var addBtns = domNode . getElementsByClassName ( 'cmp-contact-add' ) ; for ( var i = 0 ; i < addBtns . length ; i ++ ) { addBtns [ i ] . addEventListener ( 'click' , this . onContactAdd . bind ( this ) ) ; } var containerList = domNode . getElementsByClassName ( 'cmp-combo' ) ; for ( var i = 0 ; i < containerList . length ; i ++ ) { containerList [ i ] . addEventListener ( 'click' , this . onContainerClick . bind ( this ) ) ; } var attachmentBtns = domNode . getElementsByClassName ( 'cmp-attachment-btn' ) ; for ( var i = 0 ; i < attachmentBtns . length ; i ++ ) { attachmentBtns [ i ] . addEventListener ( 'click' , this . onAttachmentAdd . bind ( this ) ) ; } var subjectContainer = domNode . querySelector ( '.cmp-subject' ) ; subjectContainer . addEventListener ( 'click' , function subjectFocus ( evt ) { focusInputAndPositionCursorFromContainerClick ( evt , subjectContainer . querySelector ( 'input' ) ) ; } ) ; this . sentAudioKey = 'mail.sent-sound.enabled' ; this . sentAudio = new Audio ( '/sounds/sent.ogg' ) ; this . sentAudio . mozAudioChannelType = 'notification' ; this . sentAudioEnabled = false ; if ( navigator . mozSettings ) { var req = navigator . mozSettings . createLock ( ) . get ( this . sentAudioKey ) ; req . onsuccess = ( function onsuccess ( ) { this . sentAudioEnabled = req . result [ this . sentAudioKey ] ; } ) . bind ( this ) ; navigator . mozSettings . addObserver ( this . sentAudioKey , ( function ( e ) { this . sentAudioEnabled = e . settingValue ; } ) . bind ( this ) ) ; } }
Composer card; wants an initialized message composition object when it is
 created (for now).
Composer card ; wants an initialized message composition object when it is created ( for now ) .
// Add input event listener for handling the bubble creation/deletion. // Add Contact-add buttons event listener // Add input focus: // Add attachments area event listener // Add subject focus for larger hitbox // Sent sound init