Exemple #1
0
  it("splits list into batches, pads them", function() {
    assert.deepEqual(batch(['a', 'b', 'c', 'd', 'e'], 2, '-'), [
      ['a', 'b'], ['c', 'd'], ['e', '-']
    ], "list was correctly batched and padded");

    assert.deepEqual(batch(['a', 'b', 'c', 'd', 'e', 'f'], 3, '-'), [
      ['a', 'b', 'c'], ['d', 'e', 'f']
    ], "list was correctly batched and padded");
  });
Exemple #2
0
  it("splits list into batches", function() {
    assert.deepEqual(batch(['a', 'b', 'c', 'd', 'e'], 2), [
      ['a', 'b'], ['c', 'd'], ['e']
    ], "list was correctly batched");

    assert.deepEqual(batch(['a', 'b', 'c', 'd', 'e', 'f'], 2), [
      ['a', 'b'], ['c', 'd'], ['e', 'f']
    ], "list was correctly batched");

    assert.deepEqual(batch(['a', 'b', 'c', 'd', 'e', 'f'], 3), [
      ['a', 'b', 'c'], ['d', 'e', 'f']
    ], "list was correctly batched");
  });
Exemple #3
0
  getBody() {
    if (this.props.isLoaded) {
      /* jshint ignore:start */
      return batch(this.props.users, this.props.cols).map((row, r) => {
        return <div className="row" key={r}>
          {row.map((user) => {
            return <div className={this.getColClassName()} key={user.id}>
              <UserCard user={user}
                        showStatus={this.props.showStatus}
                        showRank={this.props.showRank} />
            </div>;
          })}
        </div>;
      });
      /* jshint ignore:end */
    } else {
      /* jshint ignore:start */
      let row = [];
      for (let i = 0; i < this.props.cols; i ++) {
        row.push(i);
      }

      return <div className="row">
        {row.map((i) => {
          return <div className={this.getColClassName()} key={i}>
            <UserPreview showStatus={this.props.showStatus} />
          </div>;
        })}
      </div>;
      /* jshint ignore:end */
    }
  }
Exemple #4
0
export default function(props) {
  if (!isVisible(props.post)) {
    return null
  }

  return (
    <div className="post-attachments">
      {batch(props.post.attachments, 2).map(row => {
        const key = row
          .map(a => {
            return a ? a.id : 0
          })
          .join("_")
        return <Row key={key} row={row} />
      })}
    </div>
  )
}
Exemple #5
0
  render() {
    /* jshint ignore:start */
    return <div className="avatars-gallery">
      <h3>{this.props.name}</h3>

      <div className="avatars-gallery-images">
        {batch(this.props.images, 4, null).map((row, i) => {
          return <div className="row" key={i}>
            {row.map((item, i) => {
              return <div className="col-xs-3" key={i}>
                {item ? <GalleryItem image={item}
                                     disabled={this.props.disabled}
                                     select={this.props.select}
                                     selection={this.props.selection} />
                      : <div className="blank-avatar" />}
              </div>
            })}
          </div>
        })}
      </div>
    </div>;
    /* jshint ignore:end */
  }