{I"
class:ETI"BundledAsset; FI"logical_path; TI""mercury/modals/inserttable.js; FI"
pathname; TI"’/home/edik/.rvm/gems/ruby-2.0.0-p247@very_simple_cms/bundler/gems/mercury-3e0245e33195/app/assets/javascripts/mercury/modals/inserttable.js.coffee; FI"content_type; TI"application/javascript; TI"
mtime; Tl+½¡9RI"length; Ti6I"digest; TI"%a51b738365a85ba01b6c6141744a03d4; FI"source; TI"6(function() {
this.Mercury.modalHandlers.insertTable = {
initialize: function() {
var _this = this;
this.table = this.element.find('#table_display table');
this.table.on('click', function(event) {
return _this.onCellClick($(event.target));
});
this.element.find('#table_alignment').on('change', function() {
return _this.setTableAlignment();
});
this.element.find('#table_border').on('keyup', function() {
return _this.setTableBorder();
});
this.element.find('#table_spacing').on('keyup', function() {
return _this.setTableCellSpacing();
});
this.element.find('[data-action]').on('click', function(event) {
event.preventDefault();
return _this.onActionClick(jQuery(event.target).data('action'));
});
this.selectFirstCell();
return this.element.find('form').on('submit', function(event) {
event.preventDefault();
_this.submitForm();
return _this.hide();
});
},
selectFirstCell: function() {
var firstCell;
firstCell = this.table.find('td, th').first();
firstCell.addClass('selected');
return Mercury.tableEditor(this.table, firstCell, ' ');
},
onCellClick: function(cell) {
this.cell = cell;
this.table = this.cell.closest('table');
this.table.find('.selected').removeAttr('class');
this.cell.addClass('selected');
return Mercury.tableEditor(this.table, this.cell, ' ');
},
onActionClick: function(action) {
if (!action) {
return;
}
return Mercury.tableEditor[action]();
},
setTableAlignment: function() {
return this.table.attr({
align: this.element.find('#table_alignment').val()
});
},
setTableBorder: function() {
var border;
border = parseInt(this.element.find('#table_border').val(), 10);
if (isNaN(border)) {
return this.table.removeAttr('border');
} else {
return this.table.attr({
border: border
});
}
},
setTableCellSpacing: function() {
var cellspacing;
cellspacing = parseInt(this.element.find('#table_spacing').val(), 10);
if (isNaN(cellspacing)) {
return this.table.removeAttr('cellspacing');
} else {
return this.table.attr({
cellspacing: cellspacing
});
}
},
submitForm: function() {
var html, value;
this.table.find('.selected').removeAttr('class');
this.table.find('td, th').html('
');
html = jQuery('