Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add drag-mode switching buttons #57

Merged
merged 1 commit into from Aug 27, 2021
Merged

Add drag-mode switching buttons #57

merged 1 commit into from Aug 27, 2021

Conversation

samwilson
Copy link
Member

Add radio buttons to toggle between 'crop' and 'move' drag modes,
and a separate 'Transcribe area' button for submitting to crop
the image.

The change to the copy-button is because it's now inside the form.

Bug: https://phabricator.wikimedia.org/T288672

@samwilson samwilson force-pushed the drag-mode branch 3 times, most recently from 240c155 to d6b2f4a Compare August 25, 2021 00:59
Copy link
Contributor

@Daimona Daimona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a general comment, I note that the new buttons don't work (obviously) if JavaScript is disabled. What do you think about having a nojs class in the html element, and remove it on page ready (like for MW)? Then add

nojs .buttons {
    display: none;
}

position: absolute;
right: 30px;
top: 15px;
.buttons {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 'buttons' might be a bit generic. I tried to come up with a better name, but I don't have good ideas at the moment. Perhaps 'output-buttons'?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

<div class="btn-group" role="group">
<button type="button" class="btn btn-default active drag-mode drag-mode-crop"
title="{{ msg('drag-mode-crop') }}" data-drag-mode="crop" disabled>
<img src="{{ asset('build/images/Crop_-_The_Noun_Project.svg') }}" height="20" width="20" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this have an alt attribute (e.g. alt="Crop") for cross-device compat? Unsure how that would work inside a button, though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I think it's fine inside a button.

Copy link
Member Author

@samwilson samwilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a general comment, I note that the new buttons don't work (obviously) if JavaScript is disabled. What do you think about having a nojs class in the html element, and remove it on page ready (like for MW)? Then add

nojs .buttons {
    display: none;
}

Great idea, done. Also applied it to the copy-to-clipboard button.

position: absolute;
right: 30px;
top: 15px;
.buttons {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

<div class="btn-group" role="group">
<button type="button" class="btn btn-default active drag-mode drag-mode-crop"
title="{{ msg('drag-mode-crop') }}" data-drag-mode="crop" disabled>
<img src="{{ asset('build/images/Crop_-_The_Noun_Project.svg') }}" height="20" width="20" />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I think it's fine inside a button.

@samwilson
Copy link
Member Author

I've also updated to @nayoub 's suggestion of starting in move mode, and requiring a click on crop to start cropping. This means that the mode buttons don't start as disabled.

Copy link
Contributor

@Daimona Daimona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New changes look good, just one JS issue (and a merge conflict to resolve)

assets/app.js Outdated
@@ -73,9 +77,13 @@ $(function () {
x = document.querySelector('[name="crop[x]"]'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't notice earlier, but now these elements don't exist when there's no output, so there's a JS error when you first load the page (Cannot read property 'value' of null at line 80). I guess the whole cropping thing should be inside a conditional

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, done. Sorry I didn't notice that earlier!

Add radio buttons to toggle between 'crop' and 'move' drag modes,
and a separate 'Transcribe area' button for submitting to crop
the image.

The change to the copy-button is because it's now inside the form.

Bug: https://phabricator.wikimedia.org/T288672
@Daimona
Copy link
Contributor

Daimona commented Aug 27, 2021

Thank you, everything looks good. I was thinking for a future change the "transcribe area" button could do its thing via AJAX and show the result without reloading the page, but it's just a minor thing that we don't have to care about for the time being.

@Daimona Daimona merged commit 618d8bf into main Aug 27, 2021
@Daimona Daimona deleted the drag-mode branch August 27, 2021 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants