B2G/gaia/apps/sms/js/recipients.js
/**
   * Recipients
   *
   * Create a Recipients list that backs the Recipients.View
   *
   * Recipients list will reject duplicates.
   *
   * @param {Object} setup Required parameters for created a Recipients list.
   *                  - outer, string ID of outer recipient display element.
   *                  - inner, string ID of inner recipient display element.
   *                  - template, Precompiled Utils.Template instance.
   */
Recipients
Create a Recipients list that backs the Recipients.View

Recipients list will reject duplicates.

@param {Object} setup Required parameters for created a Recipients list.
- outer, string ID of outer recipient display element.
- inner, string ID of inner recipient display element.
- template, Precompiled Utils.Template instance.
Recipients Create a Recipients list that backs the Recipients . View Recipients list will reject duplicates . @param { Object } setup Required parameters for created a Recipients list . - outer string ID of outer recipient display element . - inner string ID of inner recipient display element . - template Precompiled Utils . Template instance .
function Recipients(setup) {
    if (!setup) {
      throw new Error('`setup` missing');
    }
    if (!setup.template) {
      throw new Error('`setup.template` missing');
    }
    if (!setup.outer) {
      throw new Error('`setup.outer` missing');
    }
    if (!setup.inner) {
      throw new Error('`setup.inner` missing');
    }
    var list = [];
    Object.defineProperties(this, {
      length: {
        get: function() {
          return list.length;
        },
        set: function(value) {
          list.length = value;
          this.render();
          return value;
        }
      },
      list: {
        get: function() {
          return list.slice();
        }
      },
      numbers: {
        get: function() {
          var unique = [];
          var numbers = list.map(function(recipient) {
            return recipient.number || recipient.email;
          });
          for (var number of numbers) {
            if (unique.indexOf(number) === -1) {
              unique.push(number);
            }
          }
          return unique;
        }
      },
      inputValue: {
        get: function() {
          var node = document.getElementById(setup.inner).lastElementChild;
          return (node && node.isPlaceholder) ?
            node.textContent.trim() : '';
        }
      }
    });
    data.set(this, list);
    view.set(this, new Recipients.View(this, setup));
    events.set(this, { add: [], remove: [] });
  }
function Recipients ( setup ) { if ( ! setup ) { throw new Error ( '`setup` missing' ) ; } if ( ! setup . template ) { throw new Error ( '`setup.template` missing' ) ; } if ( ! setup . outer ) { throw new Error ( '`setup.outer` missing' ) ; } if ( ! setup . inner ) { throw new Error ( '`setup.inner` missing' ) ; } var list = [ ] ; Object . defineProperties ( this , { length : { get : function ( ) { return list . length ; } , set : function ( value ) { list . length = value ; this . render ( ) ; return value ; } } , list : { get : function ( ) { return list . slice ( ) ; } } , numbers : { get : function ( ) { var unique = [ ] ; var numbers = list . map ( function ( recipient ) { return recipient . number || recipient . email ; } ) ; for ( var number of numbers ) { if ( unique . indexOf ( number ) === - 1 ) { unique . push ( number ) ; } } return unique ; } } , inputValue : { get : function ( ) { var node = document . getElementById ( setup . inner ) . lastElementChild ; return ( node && node . isPlaceholder ) ? node . textContent . trim ( ) : '' ; } } } ) ; data . set ( this , list ) ; view . set ( this , new Recipients . View ( this , setup ) ) ; events . set ( this , { add : [ ] , remove : [ ] } ) ; }
Recipients
 Create a Recipients list that backs the Recipients.View
Recipients Create a Recipients list that backs the Recipients . View
// readonly