Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.

Commit

Permalink
Adopt Upload Dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
nagmat84 committed Sep 14, 2022
1 parent 0c96733 commit ef3eddc
Show file tree
Hide file tree
Showing 4 changed files with 414 additions and 237 deletions.
140 changes: 140 additions & 0 deletions scripts/3rd-party/basicModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
* @returns {void}
*/

/**
* @callback ModalDialogClosedCB
* @returns {void}
*/

/**
* @typedef ModelDialogFormElements
*
Expand Down Expand Up @@ -169,5 +174,140 @@
* @function close
* @memberOf basicModal
* @param {boolean} [force=false]
* @param {ModalDialogClosedCB} [onClosedCB]
* @returns {void}
*/

/**
* @function isActionButtonBusy
* @memberOf basicModal
* @returns {boolean}
*/

/**
* @function markActionButtonAsBusy
* @memberOf basicModal
* @returns {void}
*/

/**
* @function markActionButtonAsIdle
* @memberOf basicModal
* @returns {void}
*/

/**
* Returns `true`, if the Action button is visible.
*
* @function isActionButtonVisible
* @memberOf basicModal
* @returns {boolean}
*/

/**
* Returns `true`, if the Action button is hidden.
*
* Note, this method is not exactly the opposite of
* {@link basicModal#isActionButtonVisible}.
* This method only returns `true` if the dialog own an Action button which
* can be hidden.
* In other words, both {@link basicModal#isActionButtonVisible} and this method may
* return `false` simultaneously, if there is no Action button at all.
*
* @function isActionButtonHidden
* @memberOf basicModal
* @returns {boolean}
*/

/**
* Hides the Action button
*
* Note: This does not hide the button by setting the `display` property to
* `none`, but completely removes the button from the DOM.
* This is necessary, as an element which is not displayed is still considered
* when it comes to calculating the first or last child and hence rounding
* of the first/last button does not work as expected, if the button is still
* part of the DOM.
*
* @function hideActionButton
* @memberOf basicModal
* @returns {void}
*/

/**
* Shows the Action button, if one has been defined
*
* Note: This re-inserts the Action button into the DOM, but only if an Action
* button has previously been defined during the dialog construction.
*
* @function showActionButton
* @memberOf basicModal
* @returns {void}
*/

/**
* @function isCancelButtonBusy
* @memberOf basicModal
* @returns {boolean}
*/

/**
* @function markCancelButtonAsBusy
* @memberOf basicModal
* @returns {void}
*/

/**
* @function markCancelButtonAsIdle
* @memberOf basicModal
* @returns {void}
*/

/**
* Returns `true`, if the Cancel button is visible.
*
* @function isCancelButtonVisible
* @memberOf basicModal
* @returns {boolean}
*/

/**
* Returns `true`, if the Cancel button is hidden.
*
* Note, this method is not exactly the opposite of
* {@link basicModal#isCancelButtonVisible}.
* This method only returns `true` if the dialog own a Cancel button which
* can be hidden.
* In other words, both {@link basicModal#isCancelButtonVisible} and this method may
* return `false` simultaneously, if there is no Cancel button at all.
*
* @function isCancelButtonHidden
* @memberOf basicModal
* @returns {boolean}
*/

/**
* Hides the Cancel button
*
* Note: This does not hide the button by setting the `display` property to
* `none`, but completely removes the button from the DOM.
* This is necessary, as an element which is not displayed is still considered
* when it comes to calculating the first or last child and hence rounding
* of the first/last button does not work as expected, if the button is still
* part of the DOM.
*
* @function hideCancelButton
* @memberOf basicModal
* @returns {void}
*/

/**
* Shows the Cancel button, if one has been defined
*
* Note: This re-inserts the Cancel button into the DOM, but only if a Cancel
* button has previously been defined during the dialog construction.
*
* @function showCancelButton
* @memberOf basicModal
* @returns {void}
*/
56 changes: 0 additions & 56 deletions scripts/main/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,62 +495,6 @@ build.no_content = function (type) {
return html;
};

/**
* @param {string} title the title of the dialog
* @param {(FileList|File[]|DropboxFile[]|{name: string}[])} files a list of file entries to be shown in the dialog
* @returns {string} the HTML fragment for the dialog
*/
build.uploadModal = function (title, files) {
let html = "";

html += lychee.html`
<h1>$${title}</h1>
<div class='rows'>
`;

let i = 0;

while (i < files.length) {
let file = files[i];

if (file.name.length > 40) file.name = file.name.substr(0, 17) + "..." + file.name.substr(file.name.length - 20, 20);

html += lychee.html`
<div class='row'>
<a class='name'>${file.name}</a>
<a class='status'></a>
<p class='notice'></p>
</div>
`;

i++;
}

html += `</div>`;

return html;
};

/**
* Builds the HTML snippet for a row in the upload dialog.
*
* @param {string} name
* @returns {string}
*/
build.uploadNewFile = function (name) {
if (name.length > 40) {
name = name.substring(0, 17) + "..." + name.substring(name.length - 20, name.length);
}

return lychee.html`
<div class='row'>
<a class='name'>${name}</a>
<a class='status'></a>
<p class='notice'></p>
</div>
`;
};

/**
* @param {string[]} tags
* @returns {string}
Expand Down
Loading

0 comments on commit ef3eddc

Please sign in to comment.