-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17523 from atownson/issue_16009
Closes #16009 - Added styling to form templates to enable floating button groups
- Loading branch information
Showing
10 changed files
with
89 additions
and
23 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { getElements } from '../util'; | ||
|
||
/** | ||
* Conditionally add and remove a class that will float the button group | ||
* based on whether or not items in the list are checked | ||
*/ | ||
function toggleFloat(): void { | ||
const checkedCheckboxes = document.querySelector<HTMLInputElement>( | ||
'input[type="checkbox"][name="pk"]:checked', | ||
); | ||
const buttonGroup = document.querySelector<HTMLDivElement>( | ||
'div.form.form-horizontal div.btn-list', | ||
); | ||
if (!buttonGroup) { | ||
return; | ||
} | ||
const isFloating = buttonGroup.classList.contains('btn-float-group-left'); | ||
if (checkedCheckboxes !== null && !isFloating) { | ||
buttonGroup.classList.add('btn-float-group-left'); | ||
} else if (checkedCheckboxes === null && isFloating) { | ||
buttonGroup.classList.remove('btn-float-group-left'); | ||
} | ||
} | ||
|
||
/** | ||
* Initialize floating bulk buttons. | ||
*/ | ||
export function initFloatBulk(): void { | ||
for (const element of getElements<HTMLInputElement>('input[type="checkbox"][name="pk"]')) { | ||
element.addEventListener('change', () => { | ||
toggleFloat(); | ||
}); | ||
} | ||
// Handle the select-all checkbox | ||
for (const element of getElements<HTMLInputElement>( | ||
'table tr th > input[type="checkbox"].toggle', | ||
)) { | ||
element.addEventListener('change', () => { | ||
toggleFloat(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters