mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
scroll instead of anchor, closed button tags
This commit is contained in:
parent
9b99b17cea
commit
b7733a2ae5
2 changed files with 13 additions and 9 deletions
|
@ -88,10 +88,10 @@ describe('Image upload form', () => {
|
||||||
<input id="image_sources_0_source" name="image[sources][0][source]" type="text" class="js-source-url" />
|
<input id="image_sources_0_source" name="image[sources][0][source]" type="text" class="js-source-url" />
|
||||||
<textarea id="image_tag_input" name="image[tag_input]" class="js-image-tags-input"></textarea>
|
<textarea id="image_tag_input" name="image[tag_input]" class="js-image-tags-input"></textarea>
|
||||||
<div class="js-taginput" value="safe, pony, third tag"/>
|
<div class="js-taginput" value="safe, pony, third tag"/>
|
||||||
<button id="tagsinput-save" type="button" class="button"/>
|
<button id="tagsinput-save" type="button" class="button">Save</button>
|
||||||
<textarea id="image_description" name="image[description]" class="js-image-descr-input"></textarea>
|
<textarea id="image_description" name="image[description]" class="js-image-descr-input"></textarea>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<button class="button" type="submit"/>
|
<button class="button" type="submit">Upload</button>
|
||||||
</div>
|
</div>
|
||||||
</form>`,
|
</form>`,
|
||||||
);
|
);
|
||||||
|
|
|
@ -248,11 +248,15 @@ function setupImageUpload() {
|
||||||
requestAnimationFrame(() => submitButton.setAttribute('disabled', 'disabled'));
|
requestAnimationFrame(() => submitButton.setAttribute('disabled', 'disabled'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function anchorToTop() {
|
function scrollToTags() {
|
||||||
let url = window.location.href;
|
const taginputEle = $('#taginput-fancy-tag_input');
|
||||||
url = url.split('#')[0]; //remove any existing hash anchor from url
|
|
||||||
url += '#taginput-fancy-tag_input'; //move view to tags input
|
if (!taginputEle) {
|
||||||
window.location.href = url;
|
// default to scroll to top
|
||||||
|
window.scrollTo({ top: 0, left: 0 });
|
||||||
|
}
|
||||||
|
|
||||||
|
taginputEle.scrollIntoView();
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitHandler(event) {
|
function submitHandler(event) {
|
||||||
|
@ -268,8 +272,8 @@ function setupImageUpload() {
|
||||||
|
|
||||||
// Let the form submission complete
|
// Let the form submission complete
|
||||||
} else {
|
} else {
|
||||||
// Scroll to the top of page to see validation errors
|
// Scroll to view validation errors
|
||||||
anchorToTop();
|
scrollToTags();
|
||||||
|
|
||||||
// allow users to re-submit the form
|
// allow users to re-submit the form
|
||||||
enableUploadButton();
|
enableUploadButton();
|
||||||
|
|
Loading…
Reference in a new issue