Sha256: 139eb5cd385034fea7dbc6d909dcf0fb669927e0d308eab013039f4eae20e23e
Contents?: true
Size: 1.57 KB
Versions: 2
Compression:
Stored size: 1.57 KB
Contents
$(function(){ $('body').on('click', '.settings-link', function() { $('.rails-db-settings').toggle(); }); $('body').on('click', '.column-name input', function() { table_name = 'Table: ' + $('a[table_name]').attr('table_name'); column_name = $(this).prop('name'); if($(this).prop('checked') == false) { write_column_to_cookie(table_name, column_name); } else { remove_column_from_cookie(table_name, column_name); } switch_column_visibility(column_name); toggle_columns(); }); }); function write_column_to_cookie(table_name, column_name) { column_names = get_column_names_from_cookie(table_name); $.cookie(table_name, column_names += ',' + column_name); }; function remove_column_from_cookie(table_name, column_name) { column_names = get_column_names_from_cookie(table_name); $.cookie(table_name, column_names.replace(',' + column_name, '')); }; function get_column_names_from_cookie(table_name) { cookie = $.cookie(table_name); if(cookie == undefined) { return ''; } else { return cookie; } }; function switch_column_visibility(column_name) { $('th.column_' + column_name).toggle(); $('td.column_' + column_name).toggle(); }; function toggle_columns() { if($('.column-name input:checked').length == 0) { $('.column-name input[type=checkbox]').each(function() { column_name = $(this).prop('name'); $(this).prop("checked", true); remove_column_from_cookie(table_name, column_name); switch_column_visibility(column_name); }); } };
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rails_db-0.9 | app/assets/javascripts/rails_db/show_hide_columns.js |
rails_db-0.8 | app/assets/javascripts/rails_db/show_hide_columns.js |