{I" class:ETI"BundledAsset;FI"logical_path;TI"#type_station/editables/file.js;FI" pathname;TI"i/Users/richardadams/github/type_station/app/assets/javascripts/type_station/editables/file.js.coffee;FI"content_type;TI"application/javascript;TI" mtime;Tl+)‰¿TI" length;Ti™ I" digest;TI"%1d2236d328c3de2abd24f7124925ca6e;FI" source;TI"™ (function() { var buildUploader, setUpDrops; buildUploader = function(element, data) { var $input, elementId; elementId = $(element).attr('id'); $input = $(''); $input.attr({ type: "file", name: "file", "class": 'ts-editable-file-input', 'data-form-data': JSON.stringify(data), 'data-element-id': elementId }).cloudinary_fileupload().bind('cloudinaryprogress', function(e, data) { return $('.ts-progress-bar').css('width', Math.round((data.loaded * 100.0) / data.total) + '%'); }).bind('cloudinarystart', function(e, data) { $(this).prop('disabled', true); return $('body').append($('
').addClass('ts-progress-bar')); }).bind('cloudinarydone', function(e, data) { var $element, imageTag, model, _i, _len, _ref; $element = $("#" + ($(this).data('elementId'))); _ref = $('.ts-editable-link-tag', $element); for (_i = 0, _len = _ref.length; _i < _len; _i++) { imageTag = _ref[_i]; $(imageTag).attr('href', $.cloudinary.url(data.result.public_id, {})); } $element.data('drop').close(); $(this).prop('disabled', false); $('.ts-progress-bar').remove(); model = window.TS.getModel($element.data('ts-edit-url')); return model.set($element.data('ts-field'), { field: $element.data('ts-field'), value: { identifier: data.result.public_id }, type: 'file' }); }); return $input; }; setUpDrops = function(elements) { var drop, drops, element, tsData, _i, _len; drops = []; for (_i = 0, _len = elements.length; _i < _len; _i++) { element = elements[_i]; tsData = $(element).data('tsData'); drop = new Drop({ target: $('.ts-editable-button', element)[0], content: buildUploader(element, tsData)[0], position: 'bottom center', openOn: 'click', classes: 'drop-theme-arrows-bounce-dark' }); $(element).data('drop', drop); drops.push(drop); } return drops; }; window.TS.EditableFile = (function() { function EditableFile(elements) { var element, _i, _len; this.elements = elements; this.drops = []; for (_i = 0, _len = elements.length; _i < _len; _i++) { element = elements[_i]; $(element).append($('
').addClass('ts-editable-button').addClass('ts-button').html("")); } } EditableFile.prototype.enable = function() { this.disable(); return this.drops = setUpDrops(this.elements); }; EditableFile.prototype.disable = function() { var drop, _i, _len, _ref; _ref = this.drops; for (_i = 0, _len = _ref.length; _i < _len; _i++) { drop = _ref[_i]; drop.close(); drop.remove(); drop.destroy(); } return this.drops = []; }; return EditableFile; })(); }).call(this); ;TI"required_assets_digest;TI"%3288f66e41405d827c19c93dcb58d4b1;FI" _version;TI"%64e62ddc273c2f5847f30d698ca14b67;F