summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-05-26 14:15:17 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-05-26 14:15:17 +0000
commit8ea443b6d6a60b7d6a0a52ac35af560ac62ef8f1 (patch)
tree53dc4680fa319c47b6fb654eea718847bc31374e
parentebe0aef26901aee211e78b861925bbab97027aa6 (diff)
parentae552ec3158c88b6eb6d61cd4281442eff8d63b4 (diff)
downloadgitlab-ce-8ea443b6d6a60b7d6a0a52ac35af560ac62ef8f1.tar.gz
Merge branch 'fix-fullscreen-preview-in-milestones' into 'master'
Fix Markdown preview not working in Edit Milestone page ### What does this MR do? This MR removes the automatic Zen Mode URL update when a hash is present and makes Markdown preview work again in the Edit Milestone page. I think the intent was to make it possible to link to a full-screen edit with a URL (e.g. http://foo/bar/issues/1/edit#fullscreen), but I don't this has ever worked. Perhaps a future MR can support this. ### Why was this MR needed? A JavaScript error would be seen in the Milestone Edit page: ```javascript Uncaught error, unrecognized expression: $('.zennable input[type=checkbox]##md-preview-holder') ``` In the Milestone Edit page, apparently the use of the hash `#md-preview-holder` causes the Zen Mode JavaScript to attempt to parse the hash for the `fullscreen_` prefix and look up the checkbox based on a unknown ID. ### Are there points in the code the reviewer needs to double check? If we want to keep this hash update, an alternative fix is to add an `if` check in the beginning of `checkboxFromLocationHash`: ```coffeescript if (window.location.hash.indexOf('#' + ZenMode.fullscreen_prefix) == -1) return null ``` ### What are the relevant issue numbers? * Closes #1687 * Closes https://github.com/gitlabhq/gitlabhq/issues/9325 See merge request !711
-rw-r--r--CHANGELOG1
-rw-r--r--app/assets/javascripts/zen_mode.js.coffee23
2 files changed, 3 insertions, 21 deletions
diff --git a/CHANGELOG b/CHANGELOG
index a168342fceb..1b5427b5adc 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 7.12.0 (unreleased)
- Refactor permission checks with issues and merge requests project settings (Stan Hu)
+ - Fix Markdown preview not working in Edit Milestone page (Stan Hu)
- Add web hook support for note events (Stan Hu)
- Disable "New Issue" and "New Merge Request" buttons when features are disabled in project settings (Stan Hu)
- Remove Rack Attack monkey patches and bump to version 4.3.0 (Stan Hu)
diff --git a/app/assets/javascripts/zen_mode.js.coffee b/app/assets/javascripts/zen_mode.js.coffee
index 0fb8f7ed75f..26efc374f7f 100644
--- a/app/assets/javascripts/zen_mode.js.coffee
+++ b/app/assets/javascripts/zen_mode.js.coffee
@@ -1,6 +1,4 @@
class @ZenMode
- @fullscreen_prefix = 'fullscreen_'
-
constructor: ->
@active_zen_area = null
@active_checkbox = null
@@ -23,7 +21,7 @@ class @ZenMode
if checkbox.checked
# Disable other keyboard shortcuts in ZEN mode
Mousetrap.pause()
- @udpateActiveZenArea(checkbox)
+ @updateActiveZenArea(checkbox)
else
@exitZenMode()
@@ -32,14 +30,11 @@ class @ZenMode
@exitZenMode()
e.preventDefault()
- $(window).on 'hashchange', @updateZenModeFromLocationHash
-
- udpateActiveZenArea: (checkbox) =>
+ updateActiveZenArea: (checkbox) =>
@active_checkbox = $(checkbox)
@active_checkbox.prop('checked', true)
@active_zen_area = @active_checkbox.parent().find('textarea')
@active_zen_area.focus()
- window.location.hash = ZenMode.fullscreen_prefix + @active_checkbox.prop('id')
exitZenMode: =>
if @active_zen_area isnt null
@@ -51,17 +46,3 @@ class @ZenMode
window.scrollTo(window.pageXOffset, @scroll_position)
# Enable dropzone when leaving ZEN mode
Dropzone.forElement('.div-dropzone').enable()
-
- checkboxFromLocationHash: (e) ->
- id = $.trim(window.location.hash.replace('#' + ZenMode.fullscreen_prefix, ''))
- if id
- return $('.zennable input[type=checkbox]#' + id)[0]
- else
- return null
-
- updateZenModeFromLocationHash: (e) =>
- checkbox = @checkboxFromLocationHash()
- if checkbox
- @udpateActiveZenArea(checkbox)
- else
- @exitZenMode()