application/js/field/file.js in spontaneous-0.2.0.beta1 vs application/js/field/file.js in spontaneous-0.2.0.beta2

- old
+ new

@@ -2,15 +2,44 @@ Spontaneous.Field.File = (function($, S) { var dom = S.Dom; 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']; + } + return v; + }, + + currentFilename: function() { + return this.currentValue()['filename']; + }, + + currentFilesize: function() { + return this.currentValue()['filesize']; + }, + + currentEditValue: function() { + var value, pending, ui, v = this.get('value'); + if ((pending = v['__pending__'])) { + return pending['value']; + } + 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.get('value') - , filename = this.filename(value); + , value = this.currentValue() + , filename = this.currentFilename(); var wrap = dom.div('.file-field'); var dropper = dom.div('.file-drop'); var stopEvent = function(event) { event.stopPropagation(); @@ -59,11 +88,11 @@ if (filesize) { filesize_info.text(parseFloat(filesize, 10).to_filesize()); } }; if (value) { - set_info(value.html, this.filename(value), value.filesize); + set_info(value.html, this.currentFilename(), this.currentFilesize()); } dropper.append(this.progress_bar().parent()); wrap.append(dropper, filename_info, filesize_info); @@ -235,10 +264,9 @@ }, original_value: function() { this.processed_value(); }, set_edited_value: function(value) { - console.log('set_edited_value', value, this.edited_value(), this.original_value()) if (value === this.edited_value()) { // do nothing } else { this.selected_files = null; this.set('value', value);