mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-30 04:23:11 +03:00
Dropzone: started on design/ui of uploading
- Added new wider target handling. - Updated upload item dom with design and seperate "landing" zone. - Added new helper for simple dom element creation.
This commit is contained in:
@ -1,3 +1,29 @@
|
||||
/**
|
||||
* Create a new element with the given attrs and children.
|
||||
* Children can be a string for text nodes or other elements.
|
||||
* @param {String} tagName
|
||||
* @param {Object<String, String>} attrs
|
||||
* @param {Element[]|String[]}children
|
||||
* @return {*}
|
||||
*/
|
||||
export function elem(tagName, attrs = {}, children = []) {
|
||||
const el = document.createElement(tagName);
|
||||
|
||||
for (const [key, val] of Object.entries(attrs)) {
|
||||
el.setAttribute(key, val);
|
||||
}
|
||||
|
||||
for (const child of children) {
|
||||
if (typeof child === 'string') {
|
||||
el.append(document.createTextNode(child));
|
||||
} else {
|
||||
el.append(child);
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the given callback against each element that matches the given selector.
|
||||
* @param {String} selector
|
||||
@ -108,6 +134,17 @@ export function showLoading(element) {
|
||||
element.innerHTML = '<div class="loading-container"><div></div><div></div><div></div></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a loading element indicator element.
|
||||
* @returns {Element}
|
||||
*/
|
||||
export function getLoading() {
|
||||
const wrap = document.createElement('div');
|
||||
wrap.classList.add('loading-container');
|
||||
wrap.innerHTML = '<div></div><div></div><div></div>';
|
||||
return wrap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove any loading indicators within the given element.
|
||||
* @param {Element} element
|
||||
|
Reference in New Issue
Block a user