Sha256: 46f3a1153c3f0d69f43567eb4b427931ccfc93897058e4645a96ed155a8e9e9f

Contents?: true

Size: 990 Bytes

Versions: 26

Compression:

Stored size: 990 Bytes

Contents

class App.Views.Admin.Articles.List extends App.Views.Base
  constructor: (opts = {}) ->
    super opts

  render: (opts) ->
    for article in opts.articles
      $('#articles').append this._articleForListTemplate(article)

  renderNewArticle: (article) ->
    $('#articles').prepend this._articleForListTemplate(article)

  updateArticle: (articleId) ->
    return if $("#article_#{articleId}").length is 0
    App.Models.Article.find(id: articleId).then (article) =>
      $("#article_#{article.id}").replaceWith this._articleForListTemplate(article)

  commentsQuantityChangedForArticle: (articleId, quantity) ->
    return if $("#article_#{articleId}").length is 0
    sel = $("#article_#{articleId} span.comments_quantity")
    match = /\d+/.exec sel.text()
    quantity = parseInt(match[0]) + quantity
    sel.text "#{quantity} comment#{if quantity is 1 then '' else 's'}"

  _articleForListTemplate: (article) ->
    JST["templates/admin/articles/article_for_list"] article: article

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
loco-rails-3.0.3 test/dummy/app/assets/javascripts/views/admin/articles/list.coffee
loco-rails-2.5.3 test/dummy/app/assets/javascripts/views/admin/articles/list.coffee
loco-rails-2.5.2 test/dummy/app/assets/javascripts/views/admin/articles/list.coffee
loco-rails-3.0.2 test/dummy/app/assets/javascripts/views/admin/articles/list.coffee
loco-rails-3.0.1 test/dummy/app/assets/javascripts/views/admin/articles/list.coffee
loco-rails-2.5.1 test/dummy/app/assets/javascripts/views/admin/articles/list.coffee
loco-rails-2.5.0 test/dummy/app/assets/javascripts/views/admin/articles/list.coffee
loco-rails-2.4.0 test/dummy/app/assets/javascripts/views/admin/articles/list.coffee
loco-rails-2.3.0 test/dummy/app/assets/javascripts/views/admin/articles/list.coffee
loco-rails-3.0.0 test/dummy/app/assets/javascripts/views/admin/articles/list.coffee
loco-rails-2.2.2 test/dummy/app/assets/javascripts/views/admin/articles/list.coffee
loco-rails-2.2.1 test/dummy/app/assets/javascripts/views/admin/articles/list.coffee
loco-rails-2.2.0 test/dummy/app/assets/javascripts/views/admin/articles/list.coffee
loco-rails-2.1.0 test/dummy/app/assets/javascripts/views/admin/articles/list.coffee
loco-rails-2.0.0 test/dummy/app/assets/javascripts/views/admin/articles/list.coffee
loco-rails-1.5.2 test/dummy/app/assets/javascripts/views/admin/articles/list.coffee
loco-rails-1.5.1 test/dummy/app/assets/javascripts/views/admin/articles/list.coffee
loco-rails-1.5.0 test/dummy/app/assets/javascripts/views/admin/articles/list.coffee
loco-rails-1.4.0 test/dummy/app/assets/javascripts/views/admin/articles/list.coffee
loco-rails-1.3.3 test/dummy/app/assets/javascripts/views/admin/articles/list.coffee