Sha256: f6803e68ad59577f657b74eaec232933173c653f37275e5570cf42b590637077
Contents?: true
Size: 1.75 KB
Versions: 2
Compression:
Stored size: 1.75 KB
Contents
/*global editor*/ pageflow.FileInputView = Backbone.Marionette.ItemView.extend({ mixins: [pageflow.inputView], template: 'templates/inputs/file_input', className: 'file_input', ui: { fileName: '.file_name', thumbnail: '.file_thumbnail', editPositioningButton: '.edit_positioning', unsetButton: '.unset' }, events: { 'click .choose': function() { pageflow.editor.selectFile( this.options.collection.name, this.options.fileSelectionHandler || 'pageConfiguration', { id: this.model.getRoutableId ? this.model.getRoutableId() : this.model.id, attributeName: this.options.propertyName } ); return false; }, 'click .unset': function() { this.model.unsetReference(this.options.propertyName); return false; }, 'click. .edit_positioning': function() { pageflow.ImagePositioningView.open({ model: this.model, propertyName: this.options.propertyName }); return false; } }, initialize: function() { this.options = _.extend({ imagePositioning: true }, this.options); }, onRender: function() { this.update(); this.listenTo(this.model, 'change:' + this.options.propertyName, this.update); }, update: function() { var file = this._getFile(); this.ui.fileName.text(file ? file.get('file_name') : '(Kein)'); this.ui.unsetButton.toggle(!!file); this.ui.editPositioningButton.toggle(this.options.imagePositioning && !!file && file.isPositionable()); this.subview(new pageflow.FileThumbnailView({ el: this.ui.thumbnail, model: file })); }, _getFile: function() { return this.model.getReference(this.options.propertyName, this.options.collection); } });
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pageflow-0.4.0 | app/assets/javascripts/pageflow/editor/views/inputs/file_input_view.js |
pageflow-0.3.0 | app/assets/javascripts/pageflow/editor/views/inputs/file_input_view.js |