Move status code into the new file
This commit is contained in:
parent
b0e7a5e468
commit
dfaf085843
|
@ -22,12 +22,6 @@ let BookWyrm = new class {
|
||||||
this.interact.bind(this))
|
this.interact.bind(this))
|
||||||
);
|
);
|
||||||
|
|
||||||
document.querySelectorAll('.submit-status')
|
|
||||||
.forEach(button => button.addEventListener(
|
|
||||||
'submit',
|
|
||||||
this.submitStatus.bind(this))
|
|
||||||
);
|
|
||||||
|
|
||||||
document.querySelectorAll('.hidden-form input')
|
document.querySelectorAll('.hidden-form input')
|
||||||
.forEach(button => button.addEventListener(
|
.forEach(button => button.addEventListener(
|
||||||
'change',
|
'change',
|
||||||
|
@ -298,27 +292,6 @@ let BookWyrm = new class {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Post a status with ajax
|
|
||||||
*
|
|
||||||
* @param {Event} event
|
|
||||||
* @return {undefined}
|
|
||||||
*/
|
|
||||||
submitStatus(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
const bookwyrm = this;
|
|
||||||
const form = event.currentTarget;
|
|
||||||
|
|
||||||
this.ajaxPost(form).catch(error => {
|
|
||||||
// @todo Display a notification in the UI instead.
|
|
||||||
console.warn('Request failed:', error);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Clear form data
|
|
||||||
form.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Submit a form using POST.
|
* Submit a form using POST.
|
||||||
*
|
*
|
||||||
|
|
|
@ -4,8 +4,15 @@ let StatusCache = new class {
|
||||||
constructor() {
|
constructor() {
|
||||||
document.querySelectorAll('[data-cache-draft]')
|
document.querySelectorAll('[data-cache-draft]')
|
||||||
.forEach(t => t.addEventListener('change', this.updateDraft.bind(this)));
|
.forEach(t => t.addEventListener('change', this.updateDraft.bind(this)));
|
||||||
|
|
||||||
document.querySelectorAll('[data-cache-draft]')
|
document.querySelectorAll('[data-cache-draft]')
|
||||||
.forEach(t => this.populateDraft(t));
|
.forEach(t => this.populateDraft(t));
|
||||||
|
|
||||||
|
document.querySelectorAll('.submit-status')
|
||||||
|
.forEach(button => button.addEventListener(
|
||||||
|
'submit',
|
||||||
|
this.submitStatus.bind(this))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,5 +42,26 @@ let StatusCache = new class {
|
||||||
|
|
||||||
node.value = value;
|
node.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post a status with ajax
|
||||||
|
*
|
||||||
|
* @param {Event} event
|
||||||
|
* @return {undefined}
|
||||||
|
*/
|
||||||
|
submitStatus(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
const bookwyrm = this;
|
||||||
|
const form = event.currentTarget;
|
||||||
|
|
||||||
|
this.ajaxPost(form).catch(error => {
|
||||||
|
// @todo Display a notification in the UI instead.
|
||||||
|
console.warn('Request failed:', error);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Clear form data
|
||||||
|
form.reset();
|
||||||
|
}
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue