app/assets/javascripts/outpost/index_manager.js.coffee in outpost-cms-0.0.3 vs app/assets/javascripts/outpost/index_manager.js.coffee in outpost-cms-0.0.4

- old
+ new

@@ -4,14 +4,14 @@ # Load up special things in the index pages. # class outpost.IndexManager DefaultOptions: cellFinder: "*[data-updatable='true']" - + constructor: (@baseUrl, options={}) -> @options = _.defaults options, @DefaultOptions - + for cell in $(@options.cellFinder) new outpost.QuickEditCell $(cell), @baseUrl ## # QuickEditCell @@ -24,27 +24,27 @@ formTemplate: JST["outpost/templates/data_field"] attribute: "data-attribute" id: "data-id" highlightColor: "#dff0d8" highlightTime: 2000 - + constructor: (@el, baseUrl, options={}) -> @options = _.defaults options, @defaults - + # Check values @value = null @keyup = false - + # Attributes @attribute = @el.attr(@options.attribute) @id = @el.attr(@options.id) @url = "#{baseUrl}/#{@id}" - + @ajaxOptions = dataType: 'json' url: @url - + @el.on click: (event) => @buildForm() @el.on keyup: (event) => @@ -55,32 +55,32 @@ if not @keyup @updateData(event) , 'input' #------------- - + buildForm: (event) -> $.ajax _.extend @ajaxOptions, type: "GET" success: (data, status, xhr) => @value = data[@attribute] @el.html(@options.formTemplate attribute: @attribute, id: @id, inputValue: @value) @el.find("input").focus() #------------- - + updateData: (event) -> input = $(event.target) value = input.val() - + if value is @value @el.html(value) @keyup = false return - + $.ajax _.extend @ajaxOptions, type: "PUT" - data: + data: data_point: data_value: value success: (data, status, xhr) => @el.html(value) @el.effect "highlight", { color: @options.highlightColor }, @options.highlightTime