application/js/field/image.js in spontaneous-0.2.0.beta5 vs application/js/field/image.js in spontaneous-0.2.0.beta6

- old
+ new

@@ -1,19 +1,19 @@ // console.log('Loading ImageField...') Spontaneous.Field.Image = (function($, S) { - "use strict"; + 'use strict'; var dom = S.Dom; var ImageFieldConflictView = new JS.Class(S.Field.String.ConflictView, { panel: function() { var labels = dom.div('.image-field-conflict.labels.differences'), outer = dom.div(), image_outer = dom.div('.image-field-conflict.changes.differences'), original = dom.div('.original.diff'), edited = dom.div('.final.diff'); - var local_label = dom.div('.diff').text("Server version"); - var server_label = dom.div('.diff').text("Your version"); + var local_label = dom.div('.diff').text('Server version'); + var server_label = dom.div('.diff').text('Your version'); original.append(dom.img().attr('src', this.values.server_original)).click(function() { this.useValue(this.values.server_original); edited.add(original).removeClass('selected'); original.addClass('selected'); }.bind(this)); @@ -58,33 +58,33 @@ this.callSuper(); }, currentValue: function() { var pending, v = this.get('value'); - if ((pending = v['__pending__'])) { - pending['path'] = pending['src']; - return pending['value']; + if ((pending = v.__pending__)) { + pending.path = pending.src; + return pending.value; } - return v['__ui__'] || v['original'] || {}; + return v.__ui__ || v.original || {}; }, 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; }, currentFilename: function() { var v = this.get('value'); - return (v['__pending__'] || v['original'])['filename']; + return (v.__pending__ || v.original).filename; }, /* * HACK: The async nature of image updates means that the version setting * may be out of date not because of the actions of another, but because * the field version has been updated in the background. @@ -97,27 +97,27 @@ * * Instead hackily use the pending version and hope it's not going to cause * weird problems with simultaneous updates. */ version: function() { - var pending, value = this.get("value"); - if ((pending = value["__pending__"])) { - return pending["version"]; + var pending, value = this.get('value'); + if ((pending = value.__pending__)) { + return pending.version; } return this.data.version; }, preview: function() { Spontaneous.UploadManager.register(this); var self = this - , value = this.currentValue() +, value = this.currentValue() , src = value.src - , img = null - , dim = 45; +, img = null +, dim = 45; // , container = container.parent('li'); - if (src === "") { + if (src === '') { img = dom.img('.missing-image', {'src':''}); } else { img = dom.img(); img.load(function() { var r = this.width/this.height, $this = $(this), h = $this.height(), dh = 0; @@ -173,12 +173,12 @@ if (r > 1) { // container.addClass('landscape'); } else { // container.removeClass('landscape'); } - }.bind(this)) - image.attr('src', url) + }.bind(this)); + image.attr('src', url); // see http://www.htmlfivewow.com/slide25 window.URL.revokeObjectURL(url); } return false; }.bind(this); @@ -235,15 +235,15 @@ } return this._spinner; }, upload_complete: function(values) { this.mark_unmodified(); - this.callSuper(values) + this.callSuper(values); if (values) { var value = this.currentValue(); if (this.image) { - var img = new Image() + var img = new Image(); img.onload = function() { this.image.attr('src', value.src); }.bind(this); img.src = value.src; } @@ -295,11 +295,11 @@ var set_info = function(filename, filesize, width, height) { filename_info.text(filename); if (filesize) { filesize_info.text(parseFloat(filesize, 10).to_filesize()); - } else if (filesize === 0 || filesize === "0") { + } else if (filesize === 0 || filesize === '0') { filesize_info.text(''); } set_dimensions(width, height); }; @@ -409,10 +409,10 @@ }, set_edited_value: function(value) { this.preview_img.attr('src', value); this.callSuper(value); }, - accept_mimetype: "image/*" + accept_mimetype: 'image/*' }); ImageField.ConflictView = ImageFieldConflictView; return ImageField;