// Generated by CoffeeScript 1.3.3 (function() { var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; define(['app.lib/editableView', 'moment', 'utils', 'libs/backbone/backbone.syphon', 'text!/tpl/MixEditView'], function(EditableView, moment, utils, Syphon, Template) { var MixEditView; return MixEditView = (function(_super) { __extends(MixEditView, _super); function MixEditView() { this.saveChanges = __bind(this.saveChanges, this); return MixEditView.__super__.constructor.apply(this, arguments); } MixEditView.prototype.template = _.template(Template); MixEditView.prototype.events = { "click #save-changes": "saveChanges", "change #mix_image": "imageChanged" }; MixEditView.prototype.checkRedirect = function() { if (this.state === 2) { return Backbone.history.navigate("/mix/" + this.model.get("slug"), { trigger: true }); } }; MixEditView.prototype.initialize = function() { this.guid = utils.generateGuid(); return this.state = 0; }; MixEditView.prototype.onRender = function() { var parent; console.log("MixEditView: onRender"); this.sendImage = false; parent = this; if (!this.model.id) { $("#mix-upload", this.el).uploadifive({ uploadScript: "/ajax/upload_mix_file_handler/", buttonText: "Select audio file (mp3 for now please)", formData: { "upload-hash": this.guid, sessionid: $.cookie("sessionid") }, onUploadFile: function(file) { return $(window).on("beforeunload", function() { return alert("Go on outta that.."); }); }, onAddQueueItem: function(file) { $("#upload-extension", this.el).val(file.name.split(".").pop()); return $("#mix-details", this.el).show(); }, onProgress: function(file, e) {}, onUploadComplete: function(file, data) { parent.state++; return parent.checkRedirect(); } }); $(".fileupload", this.el).fileupload({ uploadtype: "image" }); $("#mix-details", this.el).hide(); $(".upload-hash", this.el).val(this.guid); } else { $("#div-upload-mix", this.el).hide(); this.state = 1; } $("#image-form-proxy", this.el).ajaxForm({ beforeSubmit: function() { return $("#results").html("Submitting..."); }, success: function(data) { var $out; $out = $("#results"); $out.html("Your results:"); return $out.append("
" + data + "