-
Notifications
You must be signed in to change notification settings - Fork 8
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
use bootstrap modal in file edit on discard #914
Merged
Merged
Conversation
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
@@ -41,7 +44,10 @@ $ -> | |||
false | |||
|
|||
editorDiscard = (e) -> | |||
discard() if editor.doc.isClean() or confirmDiscard() | |||
if editor.doc.isClean() |
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 personally think it would be cleaner to extract the bootstrap-modal functionality into the discard-function. For example
like this:
diff --git a/app/assets/javascripts/codemirror-custom.js.coffee b/app/assets/javascripts/codemirror-custom.js.coffee
index abe791e..7a30142 100644
--- a/app/assets/javascripts/codemirror-custom.js.coffee
+++ b/app/assets/javascripts/codemirror-custom.js.coffee
@@ -44,10 +44,7 @@ $ ->
false
editorDiscard = (e) ->
- if editor.doc.isClean()
- discard()
- else
- discard_modal.modal('show')
+ discard(editor.doc.isClean())
false
requireCommitMessage = (e) ->
@@ -58,18 +55,21 @@ $ ->
else
true
- discard = ->
- message_textarea.value = ""
- editor.setOption "readOnly", true
- editor.setValue original_editor_content
- message_group.removeClass hasErrorClass
- alert_error.hide()
- $(".show-when-editing").hide()
- $(".hide-when-editing").show()
- editorPreventFocus()
- editor.off "focus", editorSetFocus
- editor.off "blur", editorSetBlur
- discard_modal.modal('hide')
+ discard = (use_modal) ->
+ if use_modal == false
+ discard_modal.modal('show')
+ else
+ message_textarea.value = ""
+ editor.setOption "readOnly", true
+ editor.setValue original_editor_content
+ message_group.removeClass hasErrorClass
+ alert_error.hide()
+ $(".show-when-editing").hide()
+ $(".hide-when-editing").show()
+ editorPreventFocus()
+ editor.off "focus", editorSetFocus
+ editor.off "blur", editorSetBlur
+ discard_modal.modal('hide')
return
enableEditing = (e) ->
👍 |
eugenk
added a commit
that referenced
this pull request
Jun 10, 2014
…edit use bootstrap modal in file edit on discard
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
fixes #828