# @cjsx React.DOM $ = require('jquery') Backbone = require('backbone') React = require('react') Cards = require('./cards') Card = require('./card') CardCollection = require('../models/cards') Pagination = require('./pagination') helpers = require('../helpers') config = require('../config') module.exports = React.createClass displayName: 'List' componentDidMount: -> console.log '[views/list] component did mount' @props.cards.on 'sync', @forceUpdate.bind(@, null) componentWillReceiveProps: (nextProps)-> console.log '[views/list] component will receive props' nextProps.cards.on 'sync', @forceUpdate.bind(@, null) atozParam: ()-> @queryParam {sort: 'title', order: 'asc', page: 1}, [] latestParam: ()-> @queryParam {sort: 'updated_at', order: 'desc', page: 1}, [] randomParam: ()-> @queryParam {order: 'random'}, ['sort', 'page'] tagParam: (tag)-> @queryParam {tag: tag}, [] queryParam: (param, deleteKeys)-> query = $.extend {}, @props.cards.query, param for key in deleteKeys delete query[key] $.param(query) render: ->
{if !@props.card && @props.cards.collectionName == 'Cards'
{ if @props.cards.pagination @props.cards.pagination.total_entries else }
{ if @props.cards.query.order == 'random'
  • { if @props.cards.pagination else }
else }
else if @props.card title = @props.card.get('title') else title = @props.router.title } { if @props.card && @props.card.query.context == 'none'
else } { if !@props.card && helpers.isMobile()
}