Commit 8ea443b6 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

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
parents ebe0aef2 ae552ec3
......@@ -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)
......
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()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment