Sha256: 4d4d6e4291c75f46101cf2831168c3a2051035e1490575fccf46bd4367e494d6
Contents?: true
Size: 1.86 KB
Versions: 39
Compression:
Stored size: 1.86 KB
Contents
class Tawork.Views.AttachmentView extends Backbone.View events: 'click .delete': 'delete_attachment' initialize: (options = {}) -> @attachment_id = @$el.data("attachment-id") @setup_uploader() delete_attachment: -> self = this if confirm("Are you sure you want to delete this file?") $.ajax method: "DELETE" url: "/attachments/#{@attachment_id}" success: (data) -> self.remove() false setup_uploader: -> uploader = new plupload.Uploader( runtimes: "html5" browse_button: "upload_attachment_#{@attachment_id}" # you can pass in id... multi_selection: false container: document.getElementById("attachments") # ... or DOM Element itself url: "/attachments/#{@attachment_id}/upload" filters: max_file_size: "100mb" multipart_params: authenticity_token: $("meta[name=csrf-token]").attr('content') init: PostInit: -> # $("#filelist").html("") # document.getElementById("uploadfiles").onclick = -> # uploader.start() # false FilesAdded: (up, files) -> plupload.each files, (file) -> $template = $($("#upload_template").clone().html()) $template.attr("id", file.id).find(".filename").text(file.name + "(#{plupload.formatSize(file.size)})") $("#filelist").append $template uploader.start() UploadProgress: (up, file) -> $("##{file.id}").find(".bar").css(width: "#{file.percent}%") FileUploaded: (up, file, response) -> try $("##{file.id}").fadeOut complete: -> eval response.response catch err console.log err Error: (up, err) -> document.getElementById("console").innerHTML += "\nError #" + err.code + ": " + err.message ) uploader.init()
Version data entries
39 entries across 39 versions & 1 rubygems