Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b8b5df31
Commit
b8b5df31
authored
Nov 14, 2019
by
Lee Tickett
Committed by
Kushal Pandya
Nov 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove var from preview_markdown.js
parent
40731cbd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
24 deletions
+21
-24
app/assets/javascripts/behaviors/preview_markdown.js
app/assets/javascripts/behaviors/preview_markdown.js
+16
-24
changelogs/unreleased/remove_var_from_preview_markdown_js.yml
...gelogs/unreleased/remove_var_from_preview_markdown_js.yml
+5
-0
No files found.
app/assets/javascripts/behaviors/preview_markdown.js
View file @
b8b5df31
/* eslint-disable func-names
, no-var
*/
/* eslint-disable func-names */
import
$
from
'
jquery
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
...
...
@@ -12,11 +12,8 @@ import { __ } from '~/locale';
// more than `x` users are referenced.
//
var
lastTextareaPreviewed
;
var
lastTextareaHeight
=
null
;
var
markdownPreview
;
var
previewButtonSelector
;
var
writeButtonSelector
;
let
lastTextareaHeight
;
let
lastTextareaPreviewed
;
function
MarkdownPreview
()
{}
...
...
@@ -27,14 +24,13 @@ MarkdownPreview.prototype.emptyMessage = __('Nothing to preview.');
MarkdownPreview
.
prototype
.
ajaxCache
=
{};
MarkdownPreview
.
prototype
.
showPreview
=
function
(
$form
)
{
var
mdText
;
var
preview
=
$form
.
find
(
'
.js-md-preview
'
);
var
url
=
preview
.
data
(
'
url
'
);
const
preview
=
$form
.
find
(
'
.js-md-preview
'
);
const
url
=
preview
.
data
(
'
url
'
);
if
(
preview
.
hasClass
(
'
md-preview-loading
'
))
{
return
;
}
mdText
=
$form
.
find
(
'
textarea.markdown-area
'
).
val
();
const
mdText
=
$form
.
find
(
'
textarea.markdown-area
'
).
val
();
if
(
mdText
===
undefined
)
{
return
;
...
...
@@ -46,7 +42,7 @@ MarkdownPreview.prototype.showPreview = function($form) {
}
else
{
preview
.
addClass
(
'
md-preview-loading
'
).
text
(
__
(
'
Loading...
'
));
this
.
fetchMarkdownPreview
(
mdText
,
url
,
response
=>
{
var
body
;
let
body
;
if
(
response
.
body
.
length
>
0
)
{
({
body
}
=
response
);
}
else
{
...
...
@@ -91,8 +87,7 @@ MarkdownPreview.prototype.hideReferencedUsers = function($form) {
};
MarkdownPreview
.
prototype
.
renderReferencedUsers
=
function
(
users
,
$form
)
{
var
referencedUsers
;
referencedUsers
=
$form
.
find
(
'
.referenced-users
'
);
const
referencedUsers
=
$form
.
find
(
'
.referenced-users
'
);
if
(
referencedUsers
.
length
)
{
if
(
users
.
length
>=
this
.
referenceThreshold
)
{
referencedUsers
.
show
();
...
...
@@ -108,8 +103,7 @@ MarkdownPreview.prototype.hideReferencedCommands = function($form) {
};
MarkdownPreview
.
prototype
.
renderReferencedCommands
=
function
(
commands
,
$form
)
{
var
referencedCommands
;
referencedCommands
=
$form
.
find
(
'
.referenced-commands
'
);
const
referencedCommands
=
$form
.
find
(
'
.referenced-commands
'
);
if
(
commands
.
length
>
0
)
{
referencedCommands
.
html
(
commands
);
referencedCommands
.
show
();
...
...
@@ -119,15 +113,15 @@ MarkdownPreview.prototype.renderReferencedCommands = function(commands, $form) {
}
};
markdownPreview
=
new
MarkdownPreview
();
const
markdownPreview
=
new
MarkdownPreview
();
previewButtonSelector
=
'
.js-md-preview-button
'
;
writeButtonSelector
=
'
.js-md-write-button
'
;
const
previewButtonSelector
=
'
.js-md-preview-button
'
;
const
writeButtonSelector
=
'
.js-md-write-button
'
;
lastTextareaPreviewed
=
null
;
const
markdownToolbar
=
$
(
'
.md-header-toolbar
'
);
$
.
fn
.
setupMarkdownPreview
=
function
()
{
var
$form
=
$
(
this
);
const
$form
=
$
(
this
);
$form
.
find
(
'
textarea.markdown-area
'
).
on
(
'
input
'
,
()
=>
{
markdownPreview
.
hideReferencedUsers
(
$form
);
});
...
...
@@ -188,7 +182,7 @@ $(document).on('markdown-preview:hide', (e, $form) => {
});
$
(
document
).
on
(
'
markdown-preview:toggle
'
,
(
e
,
keyboardEvent
)
=>
{
var
$target
;
let
$target
;
$target
=
$
(
keyboardEvent
.
target
);
if
(
$target
.
is
(
'
textarea.markdown-area
'
))
{
$
(
document
).
triggerHandler
(
'
markdown-preview:show
'
,
[
$target
.
closest
(
'
form
'
)]);
...
...
@@ -201,16 +195,14 @@ $(document).on('markdown-preview:toggle', (e, keyboardEvent) => {
});
$
(
document
).
on
(
'
click
'
,
previewButtonSelector
,
function
(
e
)
{
var
$form
;
e
.
preventDefault
();
$form
=
$
(
this
).
closest
(
'
form
'
);
const
$form
=
$
(
this
).
closest
(
'
form
'
);
$
(
document
).
triggerHandler
(
'
markdown-preview:show
'
,
[
$form
]);
});
$
(
document
).
on
(
'
click
'
,
writeButtonSelector
,
function
(
e
)
{
var
$form
;
e
.
preventDefault
();
$form
=
$
(
this
).
closest
(
'
form
'
);
const
$form
=
$
(
this
).
closest
(
'
form
'
);
$
(
document
).
triggerHandler
(
'
markdown-preview:hide
'
,
[
$form
]);
});
...
...
changelogs/unreleased/remove_var_from_preview_markdown_js.yml
0 → 100644
View file @
b8b5df31
---
title
:
Remove var from preview_markdown.js
merge_request
:
20115
author
:
Lee Tickett
type
:
other
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment