o: ActiveSupport::Cache::Entry :@compressedF:@created_atf1359304431.22524:@expires_in0:@value"„{I" class:EFI"BundledAsset; FI"logical_path; FI"#anjlab/uploads/handler.form.js; TI" pathname; FI"Z/Users/yury/Work/uploads/app/assets/javascripts/anjlab/uploads/handler.form.js.coffee; TI"content_type; FI"application/javascript; FI" mtime; FI"2013-01-27T20:33:08+04:00; FI"length; Fi›I"digest; F"%01e3e65f8335a4e63f893048191357d9I"source; FI"›(function() { var utils, __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; }; utils = this.AnjLab.Uploads.Utils; this.AnjLab.Uploads.UploadHandlerForm = (function(_super) { __extends(UploadHandlerForm, _super); function UploadHandlerForm(options) { UploadHandlerForm.__super__.constructor.call(this, options); this.inputs = []; this.uuids = []; this.detachLoadEvents = {}; } UploadHandlerForm.prototype.attachLoadEvent = function(iframe, callback) { var detach, _this = this; detach = function() { var _ref, _ref1; if (!_this.detachLoadEvents[iframe.id]) { return; } _this.log('Received response for ' + iframe.id); if (!iframe.parentNode) { return; } try { if (((_ref = iframe.contentDocument) != null ? (_ref1 = _ref.body) != null ? _ref1.innerHTML : void 0 : void 0) === 'false') { return; } } catch (error) { _this.log("Error when attempting to access iframe during handling of upload response (" + error + ")", 'error'); } callback(); return delete _this.detachLoadEvents[iframe.id]; }; this.detachLoadEvents[iframe.id] = detach; return $(iframe).on('load', detach); }; UploadHandlerForm.prototype.getIframeContentJson = function(iframe) { var doc, innerHTML; try { doc = iframe.contentDocument || iframe.contentWindow.document; innerHTML = doc.body.innerHTML; this.log("converting iframe's innerHTML to JSON"); this.log("innerHTML = " + innerHTML); if (innerHTML && innerHTML.match(/^
")[0]; iframe.setAttribute('id', id); iframe.style.display = 'none'; document.body.appendChild(iframe); return iframe; }; UploadHandlerForm.prototype.createForm = function(id, iframe) { var $form, csrf_param, csrf_token, endpoint, params, protocol, url; params = this.options.paramsStore.getParams(id); protocol = this.options.demoMode ? "GET" : "POST"; csrf_param = $("meta[name=csrf-param]").attr("content"); csrf_token = $("meta[name=csrf-token]").attr("content"); $form = $(""); endpoint = this.options.endpointStore.getEndpoint(id); url = endpoint; params[this.options.uuidParamName] = this.uuids[id]; params['utf8'] = '✓'; url = endpoint + (/\?/.test(url) ? '&' : '?') + $.param(params); $form.attr('action', url); $form.attr('target', iframe.name); $form.css({ display: 'none' }); $form.appendTo(document.body); return $form; }; UploadHandlerForm.prototype.add = function(fileInput) { var id; fileInput.setAttribute('name', this.options.inputName); id = this.inputs.push(fileInput) - 1; this.uuids[id] = utils.getUniqueId(); if (fileInput.parentNode) { $(fileInput).remove(); } return id; }; UploadHandlerForm.prototype.getName = function(id) { return this.inputs[id].value.replace(/.*(\/|\\)/, ""); }; UploadHandlerForm.prototype.isValid = function(id) { return this.inputs[id] != null; }; UploadHandlerForm.prototype.reset = function() { UploadHandlerForm.__super__.reset.call(this); this.inputs = []; this.uuids = []; return this.detachLoadEvents = {}; }; UploadHandlerForm.prototype.getUuid = function(id) { return this.uuids[id]; }; UploadHandlerForm.prototype.cancelFile = function(id) { var iframe; this.options.onCancel(id, this.getName(id)); delete this.inputs[id]; delete this.uuids[id]; delete this.detachLoadEvents[id]; iframe = document.getElementById(id); if (iframe) { iframe.setAttribute('src', 'java' + String.fromCharCode(115) + 'cript:false;'); return $(iframe).remove(); } }; UploadHandlerForm.prototype.uploadFile = function(id) { var $form, fileName, iframe, input, _this = this; input = this.inputs[id]; fileName = this.getName(id); iframe = this.createIframe(id); $form = this.createForm(id, iframe); if (!input) { throw new Error('file with passed id was not added, or already uploaded or cancelled'); } this.options.onUpload(id, this.getName(id)); $form.append(input); this.attachLoadEvent(iframe, function() { var response; _this.log('iframe loaded'); response = _this.getIframeContentJson(iframe); setTimeout(function() { return $(iframe).remove(); }, 1); if (!response.success) { if (_this.options.onAutoRetry(id, fileName, response)) { return; } } _this.options.onComplete(id, fileName, response); return _this.uploadComplete(id); }); this.log("Sending upload request for " + id); $form.submit(); $form.remove(); return id; }; return UploadHandlerForm; })(this.AnjLab.Uploads.UploadHandler); }).call(this); ; TI"required_assets_digest; F"%c335e0db19b429ac870eea8c2a856364I" _version; F"%6776f581a4329e299531e1d52aa59832