application/js/field/file.js in spontaneous-0.2.0.beta5 vs application/js/field/file.js in spontaneous-0.2.0.beta6
- old
+ new
@@ -4,41 +4,41 @@
var FileField = new JS.Class(Spontaneous.Field.String, {
selected_files: false,
currentValue: function() {
var pending, v = this.get('value');
- if ((pending = v['__pending__'])) {
- return pending['value'];
+ if ((pending = v.__pending__)) {
+ return pending.value;
}
return v;
},
currentFilename: function() {
- return this.currentValue()['filename'];
+ return this.currentValue().filename;
},
currentFilesize: function() {
- return this.currentValue()['filesize'];
+ return this.currentValue().filesize;
},
currentEditValue: function() {
var value, pending, ui, v = this.get('value');
- if ((pending = v['__pending__'])) {
- return pending['value'];
+ if ((pending = v.__pending__)) {
+ return pending.value;
}
- value = v['original'];
- if ((ui = v['__ui__'])) {
- value['path'] = value['src'];
- value['src'] = ui['src'];
+ value = v.original;
+ if ((ui = v.__ui__)) {
+ value.path = value.src;
+ value.src = ui.src;
}
return value;
},
preview: function() {
Spontaneous.UploadManager.register(this);
var self = this
- , value = this.currentValue()
+, value = this.currentValue()
, filename = this.currentFilename();
var wrap = dom.div('.file-field');
var dropper = dom.div('.file-drop');
var stopEvent = function(event) {
@@ -96,11 +96,11 @@
dropper.append(this.progress_bar().parent());
wrap.append(dropper, filename_info, filesize_info);
this.drop_target = dropper;
- this.value_wrap = wrap;
+ this.value_wrap = wrap;
return wrap;
},
upload_values: function() {
var file = this.selected_files[0];
@@ -131,11 +131,11 @@
}
return this._progress_bar;
},
disable_progress: function() {
this.progress_bar().parent().hide();
- this.drop_target.add(this.value_wrap).removeClass('uploading')
+ this.drop_target.add(this.value_wrap).removeClass('uploading');
},
upload_progress: function(position, total) {
if (!this.drop_target.hasClass('uploading')) {
this.drop_target.add(this.value_wrap).addClass('uploading');
}
@@ -146,16 +146,16 @@
return true;
},
edit: function() {
var self = this;
- var wrap = dom.div(".file-field", {'style':'position:relative;'});
+ var wrap = dom.div('.file-field', {'style':'position:relative;'});
var value = this.value();
var input = this.input();
var filename_info = dom.div('.filename');
var filesize_info = dom.div('.filesize');
- var choose_files = dom.a('.choose').text("Choose file...");
+ var choose_files = dom.a('.choose').text('Choose file...');
var set_info = function(filename, filesize) {
filename_info.text(filename);
if (filesize) {
filesize_info.text(parseFloat(filesize, 10).to_filesize());
@@ -166,11 +166,11 @@
if (files.length > 0) {
var file = files[0], url = window.URL.createObjectURL(file);
this.selected_files = files;
this._edited_value = url;
window.URL.revokeObjectURL(url);
- set_info(File.filename(file), file.fileSize)
+ set_info(File.filename(file), file.fileSize);
}
}.bind(this);
var onchange = function() {
var files = input[0].files;
@@ -238,10 +238,10 @@
filename: function(value) {
var s = value.html.split('/'), filename = s[s.length - 1];
return filename;
},
- accept_mimetype: "*/*",
+ accept_mimetype: '*/*',
generate_input: function() {
return dom.input({'type':'file', 'name':this.form_name(), 'accept':this.accept_mimetype});
},
accepts_focus: false,
// called by edit dialogue in order to begin the async upload of files