Sha256: 5ddfaed2fc5d991c3b87ad2f58071e59515044d8c71cdc8488b2a0179b2613cd

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

$ ->
  PostsApp.Router = Backbone.Router.extend
    routes:
      "": "index"
      "new" : "newPost"
      "edit/:id" : "editPost"

    newPost: ->
      new_posts = new PostsApp.EditPostView({model: new PostsApp.Post() })
      $('#posts').html(new_posts.render().el)

    index: ->
      index_view = new PostsApp.PostsIndexView({posts: PostsApp.Posts.toJSON()})
      $('#posts').html(index_view.render().el)
      PostsApp.Posts.fetch()

    editPost: (e) ->
      post = PostsApp.Posts.get(e) || new PostsApp.Post({id: e, title: 'The title'})
      post.fetch
        success: (model) =>
          edit_post_view = new PostsApp.EditPostView({model: post})
          $('#posts').html(edit_post_view.render().el)
          $('#uploader').uploadify
            'uploader'  : '/assets/uploadify.swf'
            'cancelImg' : '/assets/cancel.png'
            'auto'      : true
            'script'    : '/admin/posts/' + post.id + '/assets'
            'onComplete' : this.uploadComplete

    uploadComplete: (e, id, file, response, data) ->
      attachment = new PostsApp.AttachmentView
          url: $.parseJSON(response).attachment.url

      $('.attachment-list').append(attachment.render().el)

      true

  PostsApp.Posts = new PostsApp.PostCollection()

  PostsApp.PostsView = Backbone.View.extend
    el: $('#posts')

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
crowdblog-0.0.16 app/assets/javascripts/crowdblog/posts_main.js.coffee
crowdblog-0.0.15 app/assets/javascripts/crowdblog/posts_main.js.coffee
crowdblog-0.0.14 app/assets/javascripts/crowdblog/posts_main.js.coffee