diff --git a/customize.dist/src/less2/include/buttons.less b/customize.dist/src/less2/include/buttons.less index ad6aaf9cc..a907d2a0b 100644 --- a/customize.dist/src/less2/include/buttons.less +++ b/customize.dist/src/less2/include/buttons.less @@ -85,6 +85,7 @@ white-space: normal; font-weight: bold; } + &.danger, &.btn-danger { background-color: @colortheme_alertify-red; border-color: @colortheme_alertify-red-border; @@ -94,6 +95,14 @@ } } + &.danger-alt, &.btn-danger-alt { + border-color: @colortheme_alertify-red; + color: @colortheme_alertify-red; + &:hover, &:active { + background-color: lighten(@colortheme_alertify-red, 35%); + } + } + &.safe, &.btn-safe { background-color: @colortheme_alertify-green; border-color: @colortheme_alertify-green-border; diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index b5e5aa90a..af1b4f679 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -30,6 +30,13 @@ define([ }); } + UIElements.prettySize = function (bytes) { + var kB = Util.bytesToKilobytes(bytes); + if (kB < 1024) { return kB + Messages.KB; } + var mB = Util.bytesToMegabytes(bytes); + return mB + Messages.MB; + }; + UIElements.updateTags = function (common, href) { var existing, tags; NThen(function(waitFor) { diff --git a/www/common/common-util.js b/www/common/common-util.js index da83b5960..e3ca9d007 100644 --- a/www/common/common-util.js +++ b/www/common/common-util.js @@ -224,6 +224,7 @@ else if (bytes >= oneMegabyte) { return 'MB'; } }; + // given a path, asynchronously return an arraybuffer Util.fetch = function (src, cb, progress) { var CB = Util.once(cb); diff --git a/www/common/sframe-common-file.js b/www/common/sframe-common-file.js index c7ca340a6..c1d0b74c0 100644 --- a/www/common/sframe-common-file.js +++ b/www/common/sframe-common-file.js @@ -182,13 +182,6 @@ define([ } }; - var prettySize = function (bytes) { - var kB = Util.bytesToKilobytes(bytes); - if (kB < 1024) { return kB + Messages.KB; } - var mB = Util.bytesToMegabytes(bytes); - return mB + Messages.MB; - }; - queue.next = function () { if (queue.queue.length === 0) { clearTimeout(queue.to); @@ -251,7 +244,7 @@ define([ // name $('').append($link).appendTo($tr); // size - $('').text(prettySize(estimate)).appendTo($tr); + $('').text(UIElements.prettySize(estimate)).appendTo($tr); // progress $('', {'class': 'cp-fileupload-table-progress'}).append($progressContainer).appendTo($tr); // cancel diff --git a/www/settings/inner.js b/www/settings/inner.js index 385c35cb4..31b62220c 100644 --- a/www/settings/inner.js +++ b/www/settings/inner.js @@ -73,6 +73,7 @@ define([ 'cp-settings-thumbnails', 'cp-settings-drive-backup', 'cp-settings-drive-import-local', + 'cp-settings-trim-history' //'cp-settings-drive-reset' ], 'cursor': [ @@ -1197,6 +1198,40 @@ define([ return $div; }; + makeBlock('trim-history', function (cb) { + // XXX settings_trimHistoryTitle, settings_trimHistoryHint, settings_trimHistoryButton + // XXX trimHistory_confirm + + var spinner = UI.makeSpinner(); + var button = h('button.btn.btn-danger-alt', { + disabled: 'disabled' + }, Messages.trimHistoryButton || 'test'); // XXX + var currentSize = h('p', $(spinner.spinner).clone()[0]); + var content = h('div', [ + currentSize, + button, + spinner.ok, + spinner.spinner + ]); + + Messages.trimHistory_currentSize = 'Abcd: {0}'; // XXX + + var size; + nThen(function (waitFor) { + size = UIElements.prettySize(1024*12); // XXX get size + }).nThen(function () { + $(currentSize).html(Messages._getKey('trimHistory_currentSize', [size])); + $(button).click(function () { + UI.confirm(Messages.trimHistory_confirm, function (yes) { + if (!yes) { return; } + spinner.spin(); + }); + }).prop('disabled', ''); + }); + + cb(content); + }, true); + /* create['drive-reset'] = function () { var $div = $('
', {'class': 'cp-settings-drive-reset cp-sidebarlayout-element'});