Added dynamic badges for themes/plugins updates in the sidebar

This commit is contained in:
Djamil Legato
2014-12-19 14:05:10 -08:00
parent a4c0195052
commit a6d8fe2f9d
5 changed files with 38 additions and 15 deletions

View File

@@ -825,13 +825,15 @@ tr {
#admin-menu li .badges .count { #admin-menu li .badges .count {
background-color: #141f25; } background-color: #141f25; }
#admin-menu li .badges .updates { #admin-menu li .badges .updates {
background-color: #2693B7; } background-color: #2693B7;
#admin-menu li .badges .count ~ .updates { display: none; }
border-bottom-left-radius: 0; #admin-menu li .badges.with-updates .count {
border-top-left-radius: 0; }
#admin-menu li .badges .updates ~ .count {
border-bottom-right-radius: 0; border-bottom-right-radius: 0;
border-top-right-radius: 0; } border-top-right-radius: 0; }
#admin-menu li .badges.with-updates .updates {
border-bottom-left-radius: 0;
border-top-left-radius: 0;
display: inline-block; }
#admin-menu li a { #admin-menu li a {
-webkit-transition: all 0.2s ease; -webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease; -moz-transition: all 0.2s ease;

File diff suppressed because one or more lines are too long

View File

@@ -73,7 +73,24 @@ $(function () {
content = '{updates} of your {type} have an <strong>update available</strong>', content = '{updates} of your {type} have an <strong>update available</strong>',
button = '<button class="button button-small secondary">Update {Type}</button>', button = '<button class="button button-small secondary">Update {Type}</button>',
plugins = $('.grav-update.plugins'), plugins = $('.grav-update.plugins'),
themes = $('.grav-update.themes'); themes = $('.grav-update.themes'),
sidebar = {plugins: $('#admin-menu a[href$="/plugins"]'), themes: $('#admin-menu a[href$="/themes"]')};
// sidebar
if (sidebar.plugins.length || sidebar.themes.length) {
var length, badges;
if (sidebar.plugins.length && (length = Object.keys(resources.plugins).length)) {
badges = sidebar.plugins.find('.badges');
badges.addClass('with-updates');
badges.find('.badge.updates').text(length);
}
if (sidebar.themes.length && (length = Object.keys(resources.themes).length)) {
badges = sidebar.themes.find('.badges');
badges.addClass('with-updates');
badges.find('.badge.updates').text(length);
}
}
// list page // list page
if (plugins[0] && (length = Object.keys(resources.plugins).length)) { if (plugins[0] && (length = Object.keys(resources.plugins).length)) {

View File

@@ -102,17 +102,21 @@ $update-height: 3rem;
.updates { .updates {
background-color: $tertiary-accent-bg; background-color: $tertiary-accent-bg;
display: none;
} }
.count ~ .updates { &.with-updates {
border-bottom-left-radius: 0; .count {
border-top-left-radius: 0;
}
.updates ~ .count {
border-bottom-right-radius: 0; border-bottom-right-radius: 0;
border-top-right-radius: 0; border-top-right-radius: 0;
} }
.updates {
border-bottom-left-radius: 0;
border-top-left-radius: 0;
display: inline-block;
}
}
} }
a { a {

View File

@@ -35,7 +35,7 @@
<i class="fa fa-fw fa-plug"></i> Plugins <i class="fa fa-fw fa-plug"></i> Plugins
<span class="badges"> <span class="badges">
<span class="badge count">{{ admin.plugins|length }}</span> <span class="badge count">{{ admin.plugins|length }}</span>
<span class="badge updates">3</span> <span class="badge updates"></span>
</span> </span>
</a> </a>
</li> </li>