Update all plugins button, js approach (#194, #279)

This commit is contained in:
onli 2015-01-27 01:42:37 +01:00
parent a58cdb2902
commit ca6ac5eef9
3 changed files with 60 additions and 1 deletions

View File

@ -71,7 +71,7 @@
<input type="submit" value="{$CONST.GO}">
</div>
{else}
<a class="button_link" href="?serendipity[adminModule]=plugins">{$CONST.BACK}</a>
<a class="button_link" id="back" href="?serendipity[adminModule]=plugins">{$CONST.BACK}</a>
{/if}
</div>
</form>
@ -82,6 +82,7 @@
{foreach $pluggroups AS $pluggroup => $groupstack}
{if $only_group && $pluggroup != $only_group}{continue}{/if}
<h3>{foreach $groupnames as $available_group => $available_name}{if $pluggroup == $available_group}{$available_name}{/if}{/foreach}</h3>
{if $only_group == UPGRADE}<button id="updateAll">Update All</button>{/if}
<ul class="plugins_installable plainList clearfix">
{foreach $groupstack as $plug}
<li class="clearfix">

View File

@ -794,6 +794,35 @@
}, time);
}
serendipity.updateAll = function() {
var overlay = $('<div id="overlay"/>');
overlay.appendTo(document.body);
var progress = $('<progress id="updateProgress" />');
progress.attr('max', $('.plugin_status').length);
progress.appendTo(overlay);
$('#updateProgress').attr('value', 0);
serendipity.updateNext();
}
serendipity.updateNext = function() {
return $.get($('.plugin_status .button_link:visible').first().attr('href'))
.done(function() {
$('.plugins_installable > li:visible').first().fadeOut();
$('#updateProgress').attr('value', parseInt($('#updateProgress').attr('value')) + 1);
console.log($('.plugins_installable > li:visible').length);
if ($('.plugins_installable > li:visible').length > 0) {
return serendipity.updateNext();
} else {
$('#updateAll').hide();
$('#overlay').fadeOut();
$('#content').append('<span class="msg_success"><span class="icon-ok-circled"></span> {$CONST.SUCCESS} </span>');
}
})
.fail(function() {
$('#overlay').fadeOut();
});
}
}( window.serendipity = window.serendipity || {}, jQuery ))
$(function() {
@ -1361,6 +1390,13 @@ $(function() {
});
}
// update all button in plugin upgrade menu
if ($('#updateAll').length > 0) {
$('#updateAll').click(function() {
serendipity.updateAll();
});
}
// minify images before upload, approach taken from https://github.com/joelvardy/javascript-image-upload/
{if {serendipity_getConfigVar key='uploadResize'} && ({serendipity_getConfigVar key='maxImgWidth'} > 0 || {serendipity_getConfigVar key='maxImgHeight'} > 0)}
if ($('#uploadform').length > 0) {

View File

@ -2402,6 +2402,28 @@ input[name="serendipity[filter][fileCategory]"] {
}
/* end TEMP fixes */
#overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.5);
z-index: 10000;
}
#updateProgress {
margin: auto;
display: block;
position: relative;
top: 48%;
margin: auto;
}
#updateAll {
margin-bottom: 1em;
}
/* MAGNIFIC POPUP */
.mfp-bg {
top: 0;