Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: dc1553c3b7
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 127 lines (82 sloc) 2.381 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
RailsBackboneRelational.Views.Comments ||= {}

class RailsBackboneRelational.Views.Comments.CommentView extends Backbone.View
  template: JST["backbone/templates/comments/comment"]
 
  
  @status = 'saved'

  events:
    "click .destroy" : "destroy"
    "dblclick .todo-array button": "show_index"

    "click .todo-array button": "whiteSpaceCheck"

    "click .direction" : "toggleDone"
    "click .save" : "save_array"
    
    #"hover .todo-array button": "show_tooltip"

  initialize: () ->
    
    @status = 'false'

    #@update_status(false)
    
    @status = 'saved!'
    this.model.bind('change', this.before_render);
 
  before_render:() =>
    @status = 'saved'
    @render()
  
    
  get_array: () ->
    @model.array

  className: 'sspann'

  tagName: "td"

  toggleDone : () ->
    @model.save(
    
      direction : !this.model.get('direction')
    )


    

  destroy: () ->
    @model.destroy()
    this.remove()

    return false



  render: =>
    listed2 = this.splitted2()
    
    comment = @model.toJSON()
    status = @status.toString()
    tmp = @template(
      'obj': comment
      'listed2': listed2
      'obj2': status
    )
    $(@el).html(tmp)
    
    return this
  
 
  splitted2: ->
    arr0 = @get_array()
    list = "<% _.each(people, function(name) { %> <button class='btn btn-info btn-block test'><%= name %></button> <% }); %>";
    arr = _.template(list, {people : arr0});
    #console.log(arr)
    arr
 
  show_tooltip: (ev) ->
    num = $(ev.target).index()
    #$(@el).popover({title: 'im the title'})
    alert(num)
   
        
  show_index: (ev) ->
    item = $(ev.target)
    num =(item).index()
    array = @get_array()
    array[num...num] = ['=']
    @array = array
    #@update_status('true')
    @status = 'not saved!'
    @render()
  
  update_status2: (sign) ->
    item = @$('.save')
    console.log(item)
    if(sign)
     $(item).attr('value', 'not Saved');
    else
     
     $(item).attr('background', '#000fff');
     $(item).attr('value', 'Saved');


  save_array: () ->
    text = @get_array().join("")
    @model.save(
     content: text
    )
    
  whiteSpaceCheck: (ev) ->
    item = $(ev.target)
    str = item.context.innerText
    
    if(str != '=')
     $(item).toggleClass("test1");
     num =(item).index()
    else
     @show_index(ev)
    
   


        
Something went wrong with that request. Please try again.