Anton Shestakov <av6@dwimlabs.net>, Wed, 20 Jul 2016 18:56:30 +0800
fruitbar: remove encoding declaration (not necessary, the code is ascii)
static/js/framework/views/inline.js
Permissions: -rw-r--r--
var InlineEditorView = Backbone.View.extend({ initialize: function(options) { renderInput: function(options) { this.$input = $('<input type="text" class="form-control input-sm">').val(options.target.text()); this.$input.keyup(function(e) { view.$saveButton.click(); view.$cancelButton.click(); this.$group.append(this.$saveButton, this.$cancelButton); this.$el.append(this.$input, this.$group); options.target.after(this.$el); renderTextarea: function(options) { this.$input = $('<textarea class="form-control input-sm" rows="3">').text(options.target.text()); this.$input.keyup(function(e) { view.$saveButton.click(); view.$cancelButton.click(); this.$group.append(this.$saveButton, this.$cancelButton); this.$el.append(this.$input, this.$group); options.target.after(this.$el); render: function(options) { this.$saveButton = $('<button class="btn btn-sm btn-success">').html('<i class="glyphicon glyphicon-ok"></i>'); this.$cancelButton = $('<button class="btn btn-sm btn-default">').html('<i class="glyphicon glyphicon-remove"></i>'); this.$el = $('<div class="inline-editor input-group">'); this.$group = $('<span class="input-group-btn">'); this.$cancelButton.click(function() { this.$saveButton.click(function() { view.trigger('save', view.$input.val()); return this.renderInput(options); return this.renderTextarea(options); var CollectionViewWithInlineEditor = CollectionView.extend({ bindInlineEditable: function(model, selector) { model.$item.delegate(selector, 'click', function(e) { var attribute = $this.attr('data-model-attribute'); var inlineEditor = new InlineEditorView({ type: $this.attr('data-input-type') || 'input' inlineEditor.on('save', function(value) { model.adhoc(data).then(function() {