* Add JS tips section to frontend documentation
* Replace document.getElementsByTagName('body') with document.body
* Replace querySelectorAll with faster selecting methods where appropriate
* Replace querySelector with faster selecting methods where appropriate
* Fix typo
* Fix forEach and getElementsByClassName
* Change querySelector* to faster methods in erb files
* Change querySelector* to faster methods in ruby files
* Fix runkit tag
* Various fixes
* Update app/assets/javascripts/initializers/initializeEllipsisMenu.js
Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
* Update app/assets/javascripts/utilities/slideSidebar.js
Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
* Commenting out flaky spec
Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
import { Controller } from 'stimulus';
|
|
|
|
export default class BufferController extends Controller {
|
|
static targets = ['header', 'bodyText'];
|
|
|
|
tagBufferUpdateConfirmed() {
|
|
this.clearPreviousBadge();
|
|
|
|
this.headerTarget.innerHTML +=
|
|
'<span class="ml-2 badge badge-success">Confirm</span>';
|
|
}
|
|
|
|
tagBufferUpdateDismissed() {
|
|
this.clearPreviousBadge();
|
|
|
|
this.headerTarget.innerHTML +=
|
|
'<span class="ml-2 badge badge-danger">Dismiss</span>';
|
|
}
|
|
|
|
highlightElement() {
|
|
this.element.classList.add('bg-highlighted', 'border-highlighted');
|
|
setTimeout(() => {
|
|
this.element.classList.remove('bg-highlighted');
|
|
}, 350);
|
|
}
|
|
|
|
autosizeBodyText() {
|
|
this.bodyTextTarget.rows = this.bodyTextTarget.value.split(
|
|
/\r\n|\r|\n/,
|
|
).length;
|
|
}
|
|
|
|
clearPreviousBadge() {
|
|
const badge = this.headerTarget.getElementsByClassName('badge')[0];
|
|
if (badge) {
|
|
badge.remove();
|
|
}
|
|
}
|
|
|
|
get bufferUpdateId() {
|
|
return parseInt(this.data.get('id'), 10);
|
|
}
|
|
|
|
set bufferUpdateId(value) {
|
|
this.data.set('id', value);
|
|
}
|
|
}
|