diff --git a/customize.dist/src/less2/include/buttons.less b/customize.dist/src/less2/include/buttons.less index bcbff499e..c3ef85b1c 100644 --- a/customize.dist/src/less2/include/buttons.less +++ b/customize.dist/src/less2/include/buttons.less @@ -68,6 +68,9 @@ } } } + button.cp-button-confirm-placeholder { + margin-bottom: 3px !important; + } button:not(.pure-button):not(.md-button):not(.mdl-button) { diff --git a/www/common/common-interface.js b/www/common/common-interface.js index d65d30cfa..508bee6a4 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -623,9 +623,9 @@ define([ var to; var done = function (res) { - cb(res); + if (res) { cb(res); } clearTimeout(to); - $(content).remove(); + $(content).detach(); $(originalBtn).show(); }; @@ -646,9 +646,12 @@ define([ $(div).css('width', p+'%'); to = setTimeout(todo, INTERVAL); }; - to = setTimeout(todo, INTERVAL); - $(originalBtn).hide().after(content); + $(originalBtn).addClass('cp-button-confirm-placeholder').click(function () { + i = 1; + to = setTimeout(todo, INTERVAL); + $(originalBtn).hide().after(content); + }); }; diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index b9985ccc7..6c581386d 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -825,32 +825,29 @@ define([ $d.append(size); var $button = $(button); - $button.click(function () { - UI.confirmButton(button, { - classes: 'btn-danger' - }, function (yes) { - if (!yes) { return; } - - $button.remove(); - spinner.spin(); - history.execCommand('TRIM_HISTORY', { - pad: true, - channels: trimChannels, - teamId: typeof(owned) === "number" && owned - }, function (obj) { - spinner.hide(); - if (obj && obj.error) { - $(size).append(h('div.alert.alert-danger', Messages.trimHistory_error)); - return; - } - $(size).remove(); - var formatted = UIElements.prettySize(bytes - historyBytes); - $d.append(h('div.cp-app-prop', [ - Messages.upload_size, - h('br'), - h('span.cp-app-prop-content', formatted) - ])); - }); + UI.confirmButton(button, { + classes: 'btn-danger' + }, function () { + $button.remove(); + spinner.spin(); + history.execCommand('TRIM_HISTORY', { + pad: true, + channels: trimChannels, + teamId: typeof(owned) === "number" && owned + }, function (obj) { + spinner.hide(); + if (obj && obj.error) { + $(size).append(h('div.alert.alert-danger', Messages.trimHistory_error)); + return; + } + $(size).remove(); + var formatted = UIElements.prettySize(bytes - historyBytes); + $d.append(h('div.cp-app-prop', [ + Messages.upload_size, + h('br'), + h('span.cp-app-prop-content', formatted) + ])); + $d.append(h('div.alert.alert-success', Messages.trimHistory_success)); }); }); diff --git a/www/settings/inner.js b/www/settings/inner.js index a5b50fa2e..7dbe8b3ce 100644 --- a/www/settings/inner.js +++ b/www/settings/inner.js @@ -1258,27 +1258,24 @@ define([ return; } $(currentSize).html(Messages._getKey('trimHistory_currentSize', [UIElements.prettySize(size)])); - $button.click(function () { - UI.confirmButton(button, { - classes: 'btn-danger' - }, function (yes) { - if (!yes) { return; } - - $button.remove(); - spinner.spin(); - APP.history.execCommand('TRIM_HISTORY', { - channels: channels - }, function (obj) { - if (obj && obj.error) { - var error = h('div.alert.alert-danger', Messages.trimHistory_error); - $(content).empty().append(error); - return; - } - spinner.hide(); - redrawTrimHistory(cb, $div); - }); + $button.prop('disabled', ''); + UI.confirmButton(button, { + classes: 'btn-danger' + }, function () { + $button.remove(); + spinner.spin(); + APP.history.execCommand('TRIM_HISTORY', { + channels: channels + }, function (obj) { + if (obj && obj.error) { + var error = h('div.alert.alert-danger', Messages.trimHistory_error); + $(content).empty().append(error); + return; + } + spinner.hide(); + redrawTrimHistory(cb, $div); }); - }).prop('disabled', ''); + }); }); $div.find('#cp-settings-trim-container').remove();