diff --git a/assets/script.js b/assets/script.js new file mode 100644 index 0000000..fe55c5b --- /dev/null +++ b/assets/script.js @@ -0,0 +1,37 @@ +jQuery(document).ready(function($) { + + // $('#show-tokens').on('click', function() { + // if ($('input.token').attr('type') == 'password') { + // $('input.token').attr('type', 'text'); + // $(this).addClass('dashicons-hidden').removeClass('dashicons-visibility') + // } else { + // $('input.token').attr('type', 'password'); + // $(this).addClass('dashicons-visibility').removeClass('dashicons-hidden') + // } + // return false; + // }); + + $('input.token').each(function() { + var token = $(this) + var toggle = $(''); + token.wrap('').after(toggle); + toggle.on('click', function() { + if (token.attr('type') == 'password') { + token.attr('type', 'text') + toggle.addClass('dashicons-hidden').removeClass('dashicons-visibility') + } else { + token.attr('type', 'password') + toggle.addClass('dashicons-visibility').removeClass('dashicons-hidden') + } + return false; + }); + }); + + $('.repo-toggle').on('click', function() { + var id = $(this).data('repo'); + $('.repo-'+id).toggleClass('open') + $('.repo-'+id+' > ul.packages').slideToggle(400) + return false; + }); + +}); \ No newline at end of file diff --git a/assets/style.css b/assets/style.css new file mode 100644 index 0000000..7627ce0 --- /dev/null +++ b/assets/style.css @@ -0,0 +1,133 @@ +.wrap { + overflow: hidden; +} +#show-tokens { + float: right; +} +.box { + margin: 20px 0; + background: #FFFFFF; + border: 1px solid #E5E5E5; + position: relative; + box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04); +} +.box .title { + border-bottom: 1px solid #EEEEEE; + margin: 0; + padding: 15px; + background: #FFFFFF; +} +.box .title h3 { + font-size: 14px; + line-height: 1em; + margin: 0; + padding: 0; +} +.box .inner { + padding: 15px; +} + +.gitea { + width: 100%; + padding: 0; + margin: 0; + border-top: 1px solid #e5e5e5; + box-shadow: 0 1px 1px rgba(0,0,0,.04); +} +.gitea > li { + overflow: hidden; + border-bottom: 1px solid #e5e5e5; + margin: 0; +} +.gitea > li > ul { + overflow: hidden; +} +.gitea > li li { + box-sizing: border-box; + padding: 8px 15px; + font-size: 12px; + margin: 0; + // width: 100%; +} +.gitea ul.packages > li { + padding: 0; +} +.gitea li.repository, +.gitea li.package { + width: 210px; + float: left; +} +.gitea a { + text-decoration: none; + outline: 0; +} +.gitea a:focus, +.gitea a:active { + outline: 0; + box-shadow: none; +} +.gitea a.repo-toggle { + font-size: 14px; + line-height: 14px; +} +.gitea > li:hover .row-actions { + left: 0; +} +.gitea input.token { + width: 70%; +} + +@media screen and (max-width: 782px) { + .gitea input.token { + width: 100%; + } +} + +.times { + color: #555d66; + float: right; + padding: 10px; + font-style: italic; +} +.form-table input[type=text], +.form-table input[type=password] { + width: 75%; +} + + + +.repo-row > ul.packages { + display: none; +} +.repo-row > ul:first-child { + transition: all 0.4s; +} +.repo-row.open > ul:first-child { + background: #2a9bd9; + border-color: #2a9bd9; + color: white; +} +.repo-row.open > ul:first-child a { + color: white; +} + +.token-box { + position: relative; +} +.token-toggle { + position: absolute; + right: 10px; + height: 20px; + top: 50%; + margin-top: -10px; + color: #aaa !important; +} +.token-toggle:hover { + color: #aaa !important; +} +.token-toggle:focus, +.token-toggle:active { + outline: 0; + box-shadow: none; + color: #aaa !important; +} \ No newline at end of file diff --git a/gitea-options.php b/gitea-options.php index 8eb617a..f8ba112 100644 --- a/gitea-options.php +++ b/gitea-options.php @@ -7,7 +7,7 @@ include_once(ABSPATH.'wp-admin/includes/class-wp-upgrader.php'); class Gitea_Options { private static $_instance; - var $install_log = false; + var $page = false; public static function getInstance() { if (!(self::$_instance instanceof self)) { @@ -18,14 +18,23 @@ class Gitea_Options { function __construct() { add_action('admin_menu', array($this, 'admin_menu')); + add_action('admin_enqueue_scripts', array($this, 'enqueue_assets')); } function admin_menu() { - $options = add_options_page('Gitea Updater', 'Gitea Updater', 'manage_options', 'gitea-updater', array($this, 'options_page')); - add_action('load-'.$options, array($this, 'options_post')); + $this->page = add_options_page('Gitea Updater', 'Gitea Updater', 'manage_options', 'gitea-updater', array($this, 'options_page')); + add_action('load-'.$this->page, array($this, 'options_post')); + } + + function enqueue_assets($hook) { + if ($hook != $this->page) return; + + wp_enqueue_style('gitea-updater', plugins_url('/assets/style.css', __FILE__)); + wp_enqueue_script('gitea-js', plugins_url('/assets/script.js', __FILE__), array('jquery'), null, true); } function options_post() { + if (isset($_GET['force-check'])) { Gitea_Updater::getInstance()->get_gitea_all(); set_site_transient('update_plugins', null); @@ -60,7 +69,7 @@ class Gitea_Options { - +
@@ -68,45 +77,44 @@ class Gitea_Options {

-

+
- $packages) : ?> -
- - - - - - + - - - $package) : ?> - - - - - +
  • +
  • + + -
    - - - -
    - -
    - - - -
    + +

    @@ -170,96 +178,8 @@ class Gitea_Options { themes:

    - */ ?> + */ ?> - - $theme) { $theme['url'] = $theme['gitea_host'].$theme['gitea_repo']; - $repositories[$plugin['gitea_host']]['theme'][$slug] = $theme; + $repositories[$theme['gitea_host']]['theme'][$slug] = $theme; } return $repositories;