Skip to content

Commit fd4ec12

Browse files
Refactor progress bar implementation & Remove ESLint comments
1 parent 5332bc2 commit fd4ec12

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

administrator/components/com_media/tmpl/file/default.php

100644100755
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,13 @@
5858
$this->useCoreUI = true;
5959
?>
6060
<?php if ($tmpl === 'component') : ?>
61-
<div class="subhead noshadow mb-3">
62-
<?php echo $this->getDocument()->getToolbar('toolbar')->render(); ?>
63-
</div>
61+
<div class="subhead noshadow mb-3">
62+
<?php echo $this->getDocument()->getToolbar('toolbar')->render(); ?>
63+
</div>
6464
<?php endif; ?>
65+
<div id="progress" class="progress visually-hidden">
66+
<div id="progress-bar" class="progress-bar bg-success" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
67+
</div>
6568
<form action="#" method="post" name="adminForm" id="media-form" class="form-validate main-card media-form mt-3">
6669
<?php $fieldSets = $form->getFieldsets(); ?>
6770
<?php if ($fieldSets) : ?>
@@ -72,4 +75,4 @@
7275
<?php endif; ?>
7376
<input type="hidden" name="mediatypes" value="<?php echo $this->escape($mediaTypes); ?>">
7477
</form>
75-
<script type="module" src="<?php echo $script . '?' . $this->getDocument()->getMediaVersion(); ?>"></script>
78+
<script type="module" src="<?php echo $script . '?' . $this->getDocument()->getMediaVersion(); ?>"></script>

build/media_source/com_media/js/edit-images.es6.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -155,27 +155,24 @@ class Edit {
155155
// eslint-disable-next-line class-methods-use-this
156156
Redo() { }
157157

158-
// eslint-disable-next-line class-methods-use-this
159158
createProgressBar() {
160-
const mediaLoader = document.createElement('div');
161-
mediaLoader.id = 'media-edit-progress';
162-
mediaLoader.className = 'media-loader';
163-
164-
mediaLoader.style.top = '0';
165-
mediaLoader.style.zIndex = '1000';
166-
167-
this.baseContainer.insertAdjacentElement('beforebegin', mediaLoader);
159+
this.progress = document.getElementById('progress');
160+
this.progressBar = document.querySelector('.progress-bar');
161+
this.progress.classList.remove('visually-hidden');
168162
}
169163

170-
// @TODO Update the progress bar
171-
// eslint-disable-next-line class-methods-use-this
172-
updateProgressBar(/* position */) { }
164+
updateProgressBar(position) {
165+
if (this.progressBar) {
166+
this.progressBar.style.width = `${position}%`;
167+
this.progressBar.setAttribute('aria-valuenow', position);
168+
}
169+
}
173170

174-
// eslint-disable-next-line class-methods-use-this
175171
removeProgressBar() {
176-
const mediaLoader = document.getElementById('media-edit-progress');
177-
if (mediaLoader) {
178-
mediaLoader.remove();
172+
if (this.progress && this.progressBar) {
173+
this.progress.classList.add('visually-hidden');
174+
this.progressBar.style.width = '0';
175+
this.progressBar.setAttribute('aria-valuenow', '0');
179176
}
180177
}
181178

0 commit comments

Comments
 (0)