Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

added in logged-in check for enabling the save button #385

Merged
merged 1 commit into from

2 participants

@Pomax
Owner

No description provided.

public/friendlycode/js/fc/ui/editor-toolbar.js
((5 lines not shown))
panes.codeMirror.on("change", function() {
- var codeLength = panes.codeMirror.getValue().trim().length;
- [saveButton].forEach(function(button) {
- button.attr("disabled", codeLength ? false : true);
- });
+ if($("html").hasClass("loggedin")) {
@jbuck Owner
jbuck added a note

Instead of adding this on the parser.onchange event, why not have the webmaker-auth change the state of the save button in the event? Then you won't need to check this on every keypress

@Pomax Owner
Pomax added a note

the button disables right after saving, until you add new content (much like how popcorn works), so auth already "unlocks" it, but publishing may temporarily disable it again. Typing then unlocks it because the content changed since last publish (which caused the ticket's issue. If it unlocks without making sure the user's also already logged in, you can publish without logging in...)

@jbuck Owner
jbuck added a note

That's downright logical!

@jbuck Owner
jbuck added a note

Maybe cache the result of $("html") though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Pomax Pomax merged commit dc75a3d into mozilla:master
@Pomax Pomax deleted the unknown repository branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 4 deletions.
  1. +8 −4 public/friendlycode/js/fc/ui/editor-toolbar.js
View
12 public/friendlycode/js/fc/ui/editor-toolbar.js
@@ -67,11 +67,15 @@ define(function(require) {
onChangeViewLink( $('body').data('make-url') || false);
// If the editor has no content, disable the save button.
+ // Enable it only when the user is loggede in.
+ var authStatus = $("html");
panes.codeMirror.on("change", function() {
- var codeLength = panes.codeMirror.getValue().trim().length;
- [saveButton].forEach(function(button) {
- button.attr("disabled", codeLength ? false : true);
- });
+ if(authStatus.hasClass("loggedin")) {
+ var codeLength = panes.codeMirror.getValue().trim().length;
+ [saveButton].forEach(function(button) {
+ button.attr("disabled", codeLength ? false : true);
+ });
+ }
});
saveButton.click(function() {
Something went wrong with that request. Please try again.