I"O(function() {
var buildUploader;
buildUploader = function(editor) {
var $input, $label, $labelIcon;
$input = $('');
$label = $('');
$labelIcon = $('').addClass("ts-file-style-icon " + (editor.data.type === 'image' ? 'ion-image' : 'ion-android-attach'));
$label.addClass('ts-file-editor').addClass('ts-editable-button').addClass('ts-button');
$input.attr({
type: "file",
name: "file",
"class": 'ts-editable-file-input',
style: 'display: none',
'data-form-data': JSON.stringify(editor.data.options.cloudinary),
'data-element-id': editor.$el.attr('id')
}).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, i, imageTag, j, len, len1, linkTag, model, ref, ref1, url;
$element = $("#" + ($(this).data('elementId')));
ref = $('.ts-editable-image-tag', $element);
for (i = 0, len = ref.length; i < len; i++) {
imageTag = ref[i];
$(imageTag).attr('src', $.cloudinary.url(data.result.public_id, $.extend({}, {
format: data.result.format
}, $(imageTag).data())));
}
ref1 = $('.ts-editable-link-tag', $element);
for (j = 0, len1 = ref1.length; j < len1; j++) {
linkTag = ref1[j];
if (data.result.type === "private") {
url = $(linkTag).data('download-url').replace('IDENTIFIER', data.result.public_id).replace('FORMAT', data.result.format);
$(linkTag).attr('href', url);
} else {
$(linkTag).attr('href', $.cloudinary.url(data.result.public_id, {
resource_type: 'raw',
format: data.result.format
}));
}
}
$(this).prop('disabled', false);
$('.ts-progress-bar').remove();
model = editor.ts.getModel(editor.data.url);
return model.set(editor.data.field, {
field: editor.data.field,
value: {
identifier: data.result.public_id,
format: data.result.format
},
type: editor.data.type
});
});
return $label.append($labelIcon).append($input);
};
this.TypeStation.FileEditor = (function() {
function FileEditor(ts, $el, data1) {
this.ts = ts;
this.$el = $el;
this.data = data1;
this.$el.addClass('ts-block');
}
FileEditor.prototype.enable = function() {
return this.$el.append(buildUploader(this));
};
FileEditor.prototype.disable = function() {
return this.$el.find('.ts-file-editor').remove();
};
return FileEditor;
})();
}).call(this);
:ET