diff --git a/admin/css/lbry-admin.css b/admin/css/lbry-admin.css index 7763519..a0d2dce 100644 --- a/admin/css/lbry-admin.css +++ b/admin/css/lbry-admin.css @@ -61,10 +61,10 @@ margin-right: 1em; } .post-lbry-display-before { - color: darkgreen; + color: green; } .post-lbry-display { - color: green; + color: #135548; } .lbry-pub-metabox { @@ -86,38 +86,36 @@ .lbry-meta-bx-content-last { padding: .2em .8em 1em .1em; } - +/*--------------------- + Channels Table + -------------------*/ table.lbry-channel-table { width: 100%; border-collapse: collapse; font-family: Georgia; } - .lbry-channel-table th, .lbry-channel-table td { padding: .4em 1.6em; border: 2px solid #fff; - background: #fbd7b4; + background: #97eb9d; font-size: 1em; } .lbry-channel-table thead th { padding: .5em 2em; - background: #f69546; + background: #135548; text-align: left; font-weight: normal; font-size: 1.2em; color: #fff; } -.lbry-channel-table tbody tr:nth-child(odd) *:nth-child(even), .lbry-channel-table tbody tr:nth-child(even) *:nth-child(odd) { - background: #f3eddd; +.lbry-channel-table tbody tr:nth-child(odd) td { + background: #e1fafa; } .lbry-channel-table tfoot th { - padding: .5em 2em; - background: #f69546; + padding: .5em 1.8em; + background: #175248; text-align: left; font-weight: normal; font-size: .9em; color: #fff; } -.lbry-channel-table tr *:nth-child(3), .lbry-channel-table tr *:nth-child(4) { - /* text-align: right; */ -} \ No newline at end of file diff --git a/admin/js/table-sort.js b/admin/js/table-sort.js new file mode 100644 index 0000000..d418778 --- /dev/null +++ b/admin/js/table-sort.js @@ -0,0 +1,83 @@ +jQuery(document).ready(function($) { + var compare = { + channel: function(a, b) { + a = a.replace(/^@/i, '') && a.replace(/[-]/gi, ''); + b = b.replace(/^@/i, '') && b.replace(/[-]/gi, ''); + + if (a < b) { + return -1; + } else { + return a > b ? 1 : 0; + } + }, + lbryurl: function(a, b) { + a = a.replace(/^lbry:\/\/@/i, '') && a.replace(/#[a-zA-Z0-9]+/, '') && a.replace(/-/g, ''); + b = b.replace(/^lbry:\/\/@/i, '') && b.replace(/#[a-zA-Z0-9]+/, '') && b.replace(/-/g, ''); + + if (a < b) { + return -1; + } else { + return a > b ? 1 : 0; + } + }, + claim: function(a, b) { + if (a < b) { + return -1; + } else { + return a > b ? 1 : 0; + } + }, + posts: function(a, b) { + a = Number(a); + b = Number(b); + + return a - b; + }, + support: function(a, b) { + a = a.replace(/,/g, ''); + b = b.replace(/,/g, ''); + + a = Number(a); + b = Number(b); + + return a - b; + }, + date: function(a, b) { + a = new Date(a); + b = new Date(b); + + return a - b; + } + }; + $('.lbry-channel-table').each(function() { + var $table = $(this); + var $tbody = $table.find('tbody'); + var $controls = $table.find('th'); + var rows = $tbody.find('tr').toArray(); + + $controls.on('click', function() { + var $header = $(this); + var order = $header.data('sort'); + var column; + + if ($header.is('.ascending') || $header.is('.descending')) { + $header.toggleClass('ascending descending'); + $tbody.append(rows.reverse()); + } else { + $header.addClass('ascending'); + $header.siblings().removeClass('ascending descending'); + if (compare.hasOwnProperty(order)) { + column = $controls.index(this); + + rows.sort(function(a, b) { + a = $(a).find('td').eq(column).text(); + b = $(b).find('td').eq(column).text(); + return compare[order](a, b); + }); + + $tbody.append(rows); + } + } + }); + }); +}); \ No newline at end of file diff --git a/classes/LBRY_Admin.php b/classes/LBRY_Admin.php index 88aabc0..575be85 100644 --- a/classes/LBRY_Admin.php +++ b/classes/LBRY_Admin.php @@ -51,6 +51,20 @@ class LBRY_Admin } } add_action( 'admin_enqueue_scripts', 'load_admin_stylesheet' ); + + // Admin channel sort JS enqueue + function load_admin_script() { + if ( ( $_GET['page'] == 'lbrypress') && ( $_GET['tab'] == 'channels' ) ) { + wp_enqueue_script( + 'lbry-table-sort', + plugins_url( '/admin/js/table-sort.js', LBRY_PLUGIN_FILE ), + array('jquery'), + LBRY_VERSION, + true + ); + } + } + add_action( 'admin_enqueue_scripts', 'load_admin_script' ); // Admin Error Notices function lbry_plugin_not_configured_notice() { @@ -258,10 +272,12 @@ class LBRY_Admin
Channel | -LBRY URL | -Posts | -Supports | +Channel | +LBRY URL | +Claim ID | +~ Date Created | +Posts | +Supports | ||
---|---|---|---|---|---|---|---|---|---|---|---|
name, 'lbrypress' ); ?> | + | + | - | Add | +Add | ||||||
LBRYPress | |||||||||||
LBRYPress |