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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
7114faf1
Commit
7114faf1
authored
Jan 09, 2018
by
Jacob Schatz
Committed by
Phil Hughes
Jan 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove preview_markdown from the global obj
parent
1086983d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
182 additions
and
184 deletions
+182
-184
app/assets/javascripts/behaviors/index.js
app/assets/javascripts/behaviors/index.js
+1
-0
app/assets/javascripts/main.js
app/assets/javascripts/main.js
+0
-1
app/assets/javascripts/preview_markdown.js
app/assets/javascripts/preview_markdown.js
+181
-183
No files found.
app/assets/javascripts/behaviors/index.js
View file @
7114faf1
...
@@ -7,6 +7,7 @@ import installGlEmojiElement from './gl_emoji';
...
@@ -7,6 +7,7 @@ import installGlEmojiElement from './gl_emoji';
import
'
./quick_submit
'
;
import
'
./quick_submit
'
;
import
'
./requires_input
'
;
import
'
./requires_input
'
;
import
'
./toggler_behavior
'
;
import
'
./toggler_behavior
'
;
import
'
../preview_markdown
'
;
installGlEmojiElement
();
installGlEmojiElement
();
initCopyAsGFM
();
initCopyAsGFM
();
...
...
app/assets/javascripts/main.js
View file @
7114faf1
...
@@ -46,7 +46,6 @@ import LazyLoader from './lazy_loader';
...
@@ -46,7 +46,6 @@ import LazyLoader from './lazy_loader';
import
'
./line_highlighter
'
;
import
'
./line_highlighter
'
;
import
initLogoAnimation
from
'
./logo
'
;
import
initLogoAnimation
from
'
./logo
'
;
import
'
./milestone_select
'
;
import
'
./milestone_select
'
;
import
'
./preview_markdown
'
;
import
'
./projects_dropdown
'
;
import
'
./projects_dropdown
'
;
import
'
./render_gfm
'
;
import
'
./render_gfm
'
;
import
initBreadcrumbs
from
'
./breadcrumb
'
;
import
initBreadcrumbs
from
'
./breadcrumb
'
;
...
...
app/assets/javascripts/preview_markdown.js
View file @
7114faf1
...
@@ -6,23 +6,22 @@
...
@@ -6,23 +6,22 @@
// (including the explanation of quick actions), and showing a warning when
// (including the explanation of quick actions), and showing a warning when
// more than `x` users are referenced.
// more than `x` users are referenced.
//
//
(
function
()
{
var
lastTextareaPreviewed
;
var
lastTextareaHeight
=
null
;
var
markdownPreview
;
var
previewButtonSelector
;
var
writeButtonSelector
;
window
.
MarkdownPreview
=
(
function
()
{
var
lastTextareaPreviewed
;
function
MarkdownPreview
()
{}
var
lastTextareaHeight
=
null
;
var
markdownPreview
;
var
previewButtonSelector
;
var
writeButtonSelector
;
// Minimum number of users referenced before triggering a warning
function
MarkdownPreview
()
{}
MarkdownPreview
.
prototype
.
referenceThreshold
=
10
;
MarkdownPreview
.
prototype
.
emptyMessage
=
'
Nothing to preview.
'
;
MarkdownPreview
.
prototype
.
ajaxCache
=
{};
// Minimum number of users referenced before triggering a warning
MarkdownPreview
.
prototype
.
referenceThreshold
=
10
;
MarkdownPreview
.
prototype
.
emptyMessage
=
'
Nothing to preview.
'
;
MarkdownPreview
.
prototype
.
showPreview
=
function
(
$form
)
{
MarkdownPreview
.
prototype
.
ajaxCache
=
{};
MarkdownPreview
.
prototype
.
showPreview
=
function
(
$form
)
{
var
mdText
;
var
mdText
;
var
preview
=
$form
.
find
(
'
.js-md-preview
'
);
var
preview
=
$form
.
find
(
'
.js-md-preview
'
);
var
url
=
preview
.
data
(
'
url
'
);
var
url
=
preview
.
data
(
'
url
'
);
...
@@ -53,9 +52,9 @@
...
@@ -53,9 +52,9 @@
}
}
}).
bind
(
this
));
}).
bind
(
this
));
}
}
};
};
MarkdownPreview
.
prototype
.
fetchMarkdownPreview
=
function
(
text
,
url
,
success
)
{
MarkdownPreview
.
prototype
.
fetchMarkdownPreview
=
function
(
text
,
url
,
success
)
{
if
(
!
url
)
{
if
(
!
url
)
{
return
;
return
;
}
}
...
@@ -78,13 +77,13 @@
...
@@ -78,13 +77,13 @@
success
(
response
);
success
(
response
);
}).
bind
(
this
)
}).
bind
(
this
)
});
});
};
};
MarkdownPreview
.
prototype
.
hideReferencedUsers
=
function
(
$form
)
{
MarkdownPreview
.
prototype
.
hideReferencedUsers
=
function
(
$form
)
{
$form
.
find
(
'
.referenced-users
'
).
hide
();
$form
.
find
(
'
.referenced-users
'
).
hide
();
};
};
MarkdownPreview
.
prototype
.
renderReferencedUsers
=
function
(
users
,
$form
)
{
MarkdownPreview
.
prototype
.
renderReferencedUsers
=
function
(
users
,
$form
)
{
var
referencedUsers
;
var
referencedUsers
;
referencedUsers
=
$form
.
find
(
'
.referenced-users
'
);
referencedUsers
=
$form
.
find
(
'
.referenced-users
'
);
if
(
referencedUsers
.
length
)
{
if
(
referencedUsers
.
length
)
{
...
@@ -95,13 +94,13 @@
...
@@ -95,13 +94,13 @@
referencedUsers
.
hide
();
referencedUsers
.
hide
();
}
}
}
}
};
};
MarkdownPreview
.
prototype
.
hideReferencedCommands
=
function
(
$form
)
{
MarkdownPreview
.
prototype
.
hideReferencedCommands
=
function
(
$form
)
{
$form
.
find
(
'
.referenced-commands
'
).
hide
();
$form
.
find
(
'
.referenced-commands
'
).
hide
();
};
};
MarkdownPreview
.
prototype
.
renderReferencedCommands
=
function
(
commands
,
$form
)
{
MarkdownPreview
.
prototype
.
renderReferencedCommands
=
function
(
commands
,
$form
)
{
var
referencedCommands
;
var
referencedCommands
;
referencedCommands
=
$form
.
find
(
'
.referenced-commands
'
);
referencedCommands
=
$form
.
find
(
'
.referenced-commands
'
);
if
(
commands
.
length
>
0
)
{
if
(
commands
.
length
>
0
)
{
...
@@ -111,25 +110,23 @@
...
@@ -111,25 +110,23 @@
referencedCommands
.
html
(
''
);
referencedCommands
.
html
(
''
);
referencedCommands
.
hide
();
referencedCommands
.
hide
();
}
}
};
};
return
MarkdownPreview
;
markdownPreview
=
new
MarkdownPreview
();
}());
markdownPreview
=
new
window
.
MarkdownPreview
();
previewButtonSelector
=
'
.js-md-preview-button
'
;
previewButtonSelector
=
'
.js-md-preview-button
'
;
writeButtonSelector
=
'
.js-md-write-button
'
;
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
);
var
$form
=
$
(
this
);
$form
.
find
(
'
textarea.markdown-area
'
).
on
(
'
input
'
,
function
()
{
$form
.
find
(
'
textarea.markdown-area
'
).
on
(
'
input
'
,
function
()
{
markdownPreview
.
hideReferencedUsers
(
$form
);
markdownPreview
.
hideReferencedUsers
(
$form
);
});
});
};
};
$
(
document
).
on
(
'
markdown-preview:show
'
,
function
(
e
,
$form
)
{
$
(
document
).
on
(
'
markdown-preview:show
'
,
function
(
e
,
$form
)
{
if
(
!
$form
)
{
if
(
!
$form
)
{
return
;
return
;
}
}
...
@@ -146,9 +143,9 @@
...
@@ -146,9 +143,9 @@
$form
.
find
(
'
.md-preview-holder
'
).
show
();
$form
.
find
(
'
.md-preview-holder
'
).
show
();
markdownToolbar
.
removeClass
(
'
active
'
);
markdownToolbar
.
removeClass
(
'
active
'
);
markdownPreview
.
showPreview
(
$form
);
markdownPreview
.
showPreview
(
$form
);
});
});
$
(
document
).
on
(
'
markdown-preview:hide
'
,
function
(
e
,
$form
)
{
$
(
document
).
on
(
'
markdown-preview:hide
'
,
function
(
e
,
$form
)
{
if
(
!
$form
)
{
if
(
!
$form
)
{
return
;
return
;
}
}
...
@@ -169,9 +166,9 @@
...
@@ -169,9 +166,9 @@
markdownToolbar
.
addClass
(
'
active
'
);
markdownToolbar
.
addClass
(
'
active
'
);
markdownPreview
.
hideReferencedCommands
(
$form
);
markdownPreview
.
hideReferencedCommands
(
$form
);
});
});
$
(
document
).
on
(
'
markdown-preview:toggle
'
,
function
(
e
,
keyboardEvent
)
{
$
(
document
).
on
(
'
markdown-preview:toggle
'
,
function
(
e
,
keyboardEvent
)
{
var
$target
;
var
$target
;
$target
=
$
(
keyboardEvent
.
target
);
$target
=
$
(
keyboardEvent
.
target
);
if
(
$target
.
is
(
'
textarea.markdown-area
'
))
{
if
(
$target
.
is
(
'
textarea.markdown-area
'
))
{
...
@@ -182,19 +179,20 @@
...
@@ -182,19 +179,20 @@
$
(
document
).
triggerHandler
(
'
markdown-preview:hide
'
,
[
$target
.
closest
(
'
form
'
)]);
$
(
document
).
triggerHandler
(
'
markdown-preview:hide
'
,
[
$target
.
closest
(
'
form
'
)]);
keyboardEvent
.
preventDefault
();
keyboardEvent
.
preventDefault
();
}
}
});
});
$
(
document
).
on
(
'
click
'
,
previewButtonSelector
,
function
(
e
)
{
$
(
document
).
on
(
'
click
'
,
previewButtonSelector
,
function
(
e
)
{
var
$form
;
var
$form
;
e
.
preventDefault
();
e
.
preventDefault
();
$form
=
$
(
this
).
closest
(
'
form
'
);
$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
;
var
$form
;
e
.
preventDefault
();
e
.
preventDefault
();
$form
=
$
(
this
).
closest
(
'
form
'
);
$form
=
$
(
this
).
closest
(
'
form
'
);
$
(
document
).
triggerHandler
(
'
markdown-preview:hide
'
,
[
$form
]);
$
(
document
).
triggerHandler
(
'
markdown-preview:hide
'
,
[
$form
]);
});
});
}());
export
default
MarkdownPreview
;
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