{I" class:ETI"BundledAsset; FI"logical_path; TI"mercury/table_editor.js; FI" pathname; TI"Œ/home/edik/.rvm/gems/ruby-2.0.0-p247@very_simple_cms/bundler/gems/mercury-3e0245e33195/app/assets/javascripts/mercury/table_editor.js.coffee; FI"content_type; TI"application/javascript; TI" mtime; Tl+½¡9RI"length; Ti¨4I"digest; TI"%6d5431ad8bc2dccb4e8cc7633e2fa2d5; FI"source; TI"¨4(function() { this.Mercury.tableEditor = function(table, cell, cellContent) { Mercury.tableEditor.load(table, cell, cellContent); return Mercury.tableEditor; }; jQuery.extend(Mercury.tableEditor, { load: function(table, cell, cellContent) { this.table = table; this.cell = cell; this.cellContent = cellContent != null ? cellContent : ''; this.row = this.cell.parent('tr'); this.columnCount = this.getColumnCount(); return this.rowCount = this.getRowCount(); }, addColumnBefore: function() { return this.addColumn('before'); }, addColumnAfter: function() { return this.addColumn('after'); }, addColumn: function(position) { var i, intersecting, matchOptions, matching, newCell, row, rowSpan, sig, _i, _len, _ref, _results; if (position == null) { position = 'after'; } sig = this.cellSignatureFor(this.cell); _ref = this.table.find('tr'); _results = []; for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) { row = _ref[i]; rowSpan = 1; matchOptions = position === 'after' ? { right: sig.right } : { left: sig.left }; if (matching = this.findCellByOptionsFor(row, matchOptions)) { newCell = jQuery("<" + (matching.cell.get(0).tagName) + ">").html(this.cellContent); this.setRowspanFor(newCell, matching.height); if (position === 'before') { matching.cell.before(newCell); } else { matching.cell.after(newCell); } _results.push(i += matching.height - 1); } else if (intersecting = this.findCellByIntersectionFor(row, sig)) { _results.push(this.setColspanFor(intersecting.cell, intersecting.width + 1)); } else { _results.push(void 0); } } return _results; }, removeColumn: function() { var adjusting, cell, i, intersecting, matching, removing, row, sig, _i, _j, _k, _len, _len1, _len2, _ref, _results; sig = this.cellSignatureFor(this.cell); if (sig.width > 1) { return; } removing = []; adjusting = []; _ref = this.table.find('tr'); for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) { row = _ref[i]; if (matching = this.findCellByOptionsFor(row, { left: sig.left, width: sig.width })) { removing.push(matching.cell); i += matching.height - 1; } else if (intersecting = this.findCellByIntersectionFor(row, sig)) { adjusting.push(intersecting.cell); } } for (_j = 0, _len1 = removing.length; _j < _len1; _j++) { cell = removing[_j]; jQuery(cell).remove(); } _results = []; for (_k = 0, _len2 = adjusting.length; _k < _len2; _k++) { cell = adjusting[_k]; _results.push(this.setColspanFor(cell, this.colspanFor(cell) - 1)); } return _results; }, addRowBefore: function() { return this.addRow('before'); }, addRowAfter: function() { return this.addRow('after'); }, addRow: function(position) { var cell, cellCount, colspan, newCell, newRow, previousRow, rowCount, rowspan, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2; if (position == null) { position = 'after'; } newRow = jQuery('