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
$
from
'
jquery
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
...
@@ -12,11 +12,8 @@ import { __ } from '~/locale';
...
@@ -12,11 +12,8 @@ import { __ } from '~/locale';
// more than `x` users are referenced.
// more than `x` users are referenced.
//
//
var
lastTextareaPreviewed
;
let
lastTextareaHeight
;
var
lastTextareaHeight
=
null
;
let
lastTextareaPreviewed
;
var
markdownPreview
;
var
previewButtonSelector
;
var
writeButtonSelector
;
function
MarkdownPreview
()
{}
function
MarkdownPreview
()
{}
...
@@ -27,14 +24,13 @@ MarkdownPreview.prototype.emptyMessage = __('Nothing to preview.');
...
@@ -27,14 +24,13 @@ MarkdownPreview.prototype.emptyMessage = __('Nothing to preview.');
MarkdownPreview
.
prototype
.
ajaxCache
=
{};
MarkdownPreview
.
prototype
.
ajaxCache
=
{};
MarkdownPreview
.
prototype
.
showPreview
=
function
(
$form
)
{
MarkdownPreview
.
prototype
.
showPreview
=
function
(
$form
)
{
var
mdText
;
const
preview
=
$form
.
find
(
'
.js-md-preview
'
);
var
preview
=
$form
.
find
(
'
.js-md-preview
'
);
const
url
=
preview
.
data
(
'
url
'
);
var
url
=
preview
.
data
(
'
url
'
);
if
(
preview
.
hasClass
(
'
md-preview-loading
'
))
{
if
(
preview
.
hasClass
(
'
md-preview-loading
'
))
{
return
;
return
;
}
}
mdText
=
$form
.
find
(
'
textarea.markdown-area
'
).
val
();
const
mdText
=
$form
.
find
(
'
textarea.markdown-area
'
).
val
();
if
(
mdText
===
undefined
)
{
if
(
mdText
===
undefined
)
{
return
;
return
;
...
@@ -46,7 +42,7 @@ MarkdownPreview.prototype.showPreview = function($form) {
...
@@ -46,7 +42,7 @@ MarkdownPreview.prototype.showPreview = function($form) {
}
else
{
}
else
{
preview
.
addClass
(
'
md-preview-loading
'
).
text
(
__
(
'
Loading...
'
));
preview
.
addClass
(
'
md-preview-loading
'
).
text
(
__
(
'
Loading...
'
));
this
.
fetchMarkdownPreview
(
mdText
,
url
,
response
=>
{
this
.
fetchMarkdownPreview
(
mdText
,
url
,
response
=>
{
var
body
;
let
body
;
if
(
response
.
body
.
length
>
0
)
{
if
(
response
.
body
.
length
>
0
)
{
({
body
}
=
response
);
({
body
}
=
response
);
}
else
{
}
else
{
...
@@ -91,8 +87,7 @@ MarkdownPreview.prototype.hideReferencedUsers = function($form) {
...
@@ -91,8 +87,7 @@ MarkdownPreview.prototype.hideReferencedUsers = function($form) {
};
};
MarkdownPreview
.
prototype
.
renderReferencedUsers
=
function
(
users
,
$form
)
{
MarkdownPreview
.
prototype
.
renderReferencedUsers
=
function
(
users
,
$form
)
{
var
referencedUsers
;
const
referencedUsers
=
$form
.
find
(
'
.referenced-users
'
);
referencedUsers
=
$form
.
find
(
'
.referenced-users
'
);
if
(
referencedUsers
.
length
)
{
if
(
referencedUsers
.
length
)
{
if
(
users
.
length
>=
this
.
referenceThreshold
)
{
if
(
users
.
length
>=
this
.
referenceThreshold
)
{
referencedUsers
.
show
();
referencedUsers
.
show
();
...
@@ -108,8 +103,7 @@ MarkdownPreview.prototype.hideReferencedCommands = function($form) {
...
@@ -108,8 +103,7 @@ MarkdownPreview.prototype.hideReferencedCommands = function($form) {
};
};
MarkdownPreview
.
prototype
.
renderReferencedCommands
=
function
(
commands
,
$form
)
{
MarkdownPreview
.
prototype
.
renderReferencedCommands
=
function
(
commands
,
$form
)
{
var
referencedCommands
;
const
referencedCommands
=
$form
.
find
(
'
.referenced-commands
'
);
referencedCommands
=
$form
.
find
(
'
.referenced-commands
'
);
if
(
commands
.
length
>
0
)
{
if
(
commands
.
length
>
0
)
{
referencedCommands
.
html
(
commands
);
referencedCommands
.
html
(
commands
);
referencedCommands
.
show
();
referencedCommands
.
show
();
...
@@ -119,15 +113,15 @@ MarkdownPreview.prototype.renderReferencedCommands = function(commands, $form) {
...
@@ -119,15 +113,15 @@ MarkdownPreview.prototype.renderReferencedCommands = function(commands, $form) {
}
}
};
};
markdownPreview
=
new
MarkdownPreview
();
const
markdownPreview
=
new
MarkdownPreview
();
previewButtonSelector
=
'
.js-md-preview-button
'
;
const
previewButtonSelector
=
'
.js-md-preview-button
'
;
writeButtonSelector
=
'
.js-md-write-button
'
;
const
writeButtonSelector
=
'
.js-md-write-button
'
;
lastTextareaPreviewed
=
null
;
lastTextareaPreviewed
=
null
;
const
markdownToolbar
=
$
(
'
.md-header-toolbar
'
);
const
markdownToolbar
=
$
(
'
.md-header-toolbar
'
);
$
.
fn
.
setupMarkdownPreview
=
function
()
{
$
.
fn
.
setupMarkdownPreview
=
function
()
{
var
$form
=
$
(
this
);
const
$form
=
$
(
this
);
$form
.
find
(
'
textarea.markdown-area
'
).
on
(
'
input
'
,
()
=>
{
$form
.
find
(
'
textarea.markdown-area
'
).
on
(
'
input
'
,
()
=>
{
markdownPreview
.
hideReferencedUsers
(
$form
);
markdownPreview
.
hideReferencedUsers
(
$form
);
});
});
...
@@ -188,7 +182,7 @@ $(document).on('markdown-preview:hide', (e, $form) => {
...
@@ -188,7 +182,7 @@ $(document).on('markdown-preview:hide', (e, $form) => {
});
});
$
(
document
).
on
(
'
markdown-preview:toggle
'
,
(
e
,
keyboardEvent
)
=>
{
$
(
document
).
on
(
'
markdown-preview:toggle
'
,
(
e
,
keyboardEvent
)
=>
{
var
$target
;
let
$target
;
$target
=
$
(
keyboardEvent
.
target
);
$target
=
$
(
keyboardEvent
.
target
);
if
(
$target
.
is
(
'
textarea.markdown-area
'
))
{
if
(
$target
.
is
(
'
textarea.markdown-area
'
))
{
$
(
document
).
triggerHandler
(
'
markdown-preview:show
'
,
[
$target
.
closest
(
'
form
'
)]);
$
(
document
).
triggerHandler
(
'
markdown-preview:show
'
,
[
$target
.
closest
(
'
form
'
)]);
...
@@ -201,16 +195,14 @@ $(document).on('markdown-preview:toggle', (e, keyboardEvent) => {
...
@@ -201,16 +195,14 @@ $(document).on('markdown-preview:toggle', (e, keyboardEvent) => {
});
});
$
(
document
).
on
(
'
click
'
,
previewButtonSelector
,
function
(
e
)
{
$
(
document
).
on
(
'
click
'
,
previewButtonSelector
,
function
(
e
)
{
var
$form
;
e
.
preventDefault
();
e
.
preventDefault
();
$form
=
$
(
this
).
closest
(
'
form
'
);
const
$form
=
$
(
this
).
closest
(
'
form
'
);
$
(
document
).
triggerHandler
(
'
markdown-preview:show
'
,
[
$form
]);
$
(
document
).
triggerHandler
(
'
markdown-preview:show
'
,
[
$form
]);
});
});
$
(
document
).
on
(
'
click
'
,
writeButtonSelector
,
function
(
e
)
{
$
(
document
).
on
(
'
click
'
,
writeButtonSelector
,
function
(
e
)
{
var
$form
;
e
.
preventDefault
();
e
.
preventDefault
();
$form
=
$
(
this
).
closest
(
'
form
'
);
const
$form
=
$
(
this
).
closest
(
'
form
'
);
$
(
document
).
triggerHandler
(
'
markdown-preview:hide
'
,
[
$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