This repository has been archived by the owner on Apr 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 120
feat(firstrun): Add fx_firstrun_v2 events to support new firstrun flow. #4717
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,7 @@ define(function (require, exports, module) { | |
'submit form': preventDefaultThen('validateAndSubmit') | ||
}, | ||
|
||
_notifiedOfEngaged: false, | ||
onFormChange () { | ||
// the change event can be called after the form is already | ||
// submitted if the user presses "enter" in the form. If the | ||
|
@@ -84,6 +85,11 @@ define(function (require, exports, module) { | |
this.hideError(); | ||
this.hideSuccess(); | ||
this.enableSubmitIfValid(); | ||
|
||
if (! this._notifiedOfEngaged) { | ||
this._notifiedOfEngaged = true; | ||
this.notifier.trigger('form.engaged'); | ||
} | ||
}, | ||
|
||
afterRender () { | ||
|
@@ -142,25 +148,36 @@ define(function (require, exports, module) { | |
}, | ||
|
||
/** | ||
* TODO - this should be called disableSubmit | ||
* Disable the form | ||
*/ | ||
disableForm () { | ||
// the disabled class is used instead of the disabled attribute | ||
// so that the submit handler is still called. With the submit attribute | ||
// applied, no submit handler is fired, and the form validation does not | ||
// take place. | ||
this.$('button[type=submit]').addClass('disabled'); | ||
this._isFormEnabled = false; | ||
if (this.isFormEnabled()) { | ||
this.$('button[type=submit]').addClass('disabled'); | ||
this.notifier.trigger('form.disabled'); | ||
} | ||
}, | ||
|
||
/** | ||
* Enable the form | ||
*/ | ||
enableForm () { | ||
this.$('button[type=submit]').removeClass('disabled'); | ||
this._isFormEnabled = true; | ||
if (! this.isFormEnabled()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To avoid sending form.disabled and form.enabled every time either of these methods is called (which is pretty often), I only send the messages if a state change occurs. |
||
this.$('button[type=submit]').removeClass('disabled'); | ||
this.notifier.trigger('form.enabled'); | ||
} | ||
}, | ||
|
||
_isFormEnabled: true, | ||
/** | ||
* Check if the form is enabled | ||
* | ||
* @returns {Boolean} | ||
*/ | ||
isFormEnabled () { | ||
return !! this._isFormEnabled; | ||
return ! this.$('button[type=submit]').hasClass('disabled'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is modified to checking the DOM instead of relying on an internal variable because sometimes the form is disabled from the template. |
||
}, | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to add more than this PR than necessary, but it's time to move this mixin into a shared location so it can be used by either views or models without the wonkiness of including a view mixin in a model. I'll do that as a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This move was taken care of by @philbooth in #4718