Sha256: e614548d0ebacfdc0c0d97c9900a5134617a0b2c4aca604f0865dcce5563d3a4
Contents?: true
Size: 1.89 KB
Versions: 2
Compression:
Stored size: 1.89 KB
Contents
@Mercury.modalHandlers.insertTable = { initialize: -> @table = @element.find('#table_display table') @table.on 'click', (event) => @onCellClick($(event.target)) @element.find('#table_alignment').on 'change', => @setTableAlignment() @element.find('#table_border').on 'keyup', => @setTableBorder() @element.find('#table_spacing').on 'keyup', => @setTableCellSpacing() @element.find('[data-action]').on 'click', (event) => event.preventDefault() @onActionClick(jQuery(event.target).data('action')) @selectFirstCell() @element.find('form').on 'submit', (event) => event.preventDefault() @submitForm() @hide() selectFirstCell: -> firstCell = @table.find('td, th').first() firstCell.addClass('selected') Mercury.tableEditor(@table, firstCell, ' ') onCellClick: (@cell) -> @table = @cell.closest('table') @table.find('.selected').removeAttr('class') @cell.addClass('selected') Mercury.tableEditor(@table, @cell, ' ') onActionClick: (action) -> return unless action Mercury.tableEditor[action]() setTableAlignment: -> @table.attr({align: @element.find('#table_alignment').val()}) setTableBorder: -> border = parseInt(@element.find('#table_border').val(), 10) if isNaN(border) @table.removeAttr('border') else @table.attr({border: border}) setTableCellSpacing: -> cellspacing = parseInt(@element.find('#table_spacing').val(), 10) if isNaN(cellspacing) @table.removeAttr('cellspacing') else @table.attr({cellspacing: cellspacing}) submitForm: -> @table.find('.selected').removeAttr('class') @table.find('td, th').html('<br/>') html = jQuery('<div>').html(@table).html() value = html.replace(/^\s+|\n/gm, '').replace(/(<\/.*?>|<table.*?>|<tbody>|<tr>)/g, '$1\n') Mercury.trigger('action', {action: 'insertTable', value: value}) }
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
kiteditor-1.0.12 | app/assets/javascripts/mercury/modals/inserttable.js.coffee |
mercury-rails-0.9.0 | app/assets/javascripts/mercury/modals/inserttable.js.coffee |