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
af13ffbc
Commit
af13ffbc
authored
Nov 01, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dont emit toggle-markdown event if current target is already active and add specs
parent
9c3f094a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
5 deletions
+47
-5
app/assets/javascripts/vue_shared/components/markdown/header.vue
...ets/javascripts/vue_shared/components/markdown/header.vue
+11
-5
spec/javascripts/vue_shared/components/markdown/field_spec.js
.../javascripts/vue_shared/components/markdown/field_spec.js
+36
-0
No files found.
app/assets/javascripts/vue_shared/components/markdown/header.vue
View file @
af13ffbc
...
@@ -16,12 +16,18 @@
...
@@ -16,12 +16,18 @@
toolbarButton
,
toolbarButton
,
},
},
methods
:
{
methods
:
{
isMarkdownForm
(
form
)
{
return
form
&&
!
form
.
find
(
'
.js-vue-markdown-field
'
).
length
;
},
isActiveTarget
(
target
)
{
return
target
.
closest
(
'
li
'
).
classList
.
contains
(
'
active
'
);
},
toggleMarkdownPreview
(
e
,
form
)
{
toggleMarkdownPreview
(
e
,
form
)
{
if
(
form
&&
!
form
.
find
(
'
.js-vue-markdown-field
'
).
length
)
{
if
(
e
.
target
.
blur
)
e
.
target
.
blur
();
return
;
}
else
if
(
e
.
target
.
blur
)
{
if
(
this
.
isMarkdownForm
(
form
)
||
this
.
isActiveTarget
(
e
.
target
))
return
;
e
.
target
.
blur
();
}
this
.
$emit
(
'
toggle-markdown
'
);
this
.
$emit
(
'
toggle-markdown
'
);
},
},
...
...
spec/javascripts/vue_shared/components/markdown/field_spec.js
View file @
af13ffbc
...
@@ -39,6 +39,7 @@ describe('Markdown field component', () => {
...
@@ -39,6 +39,7 @@ describe('Markdown field component', () => {
describe
(
'
markdown preview
'
,
()
=>
{
describe
(
'
markdown preview
'
,
()
=>
{
let
previewLink
;
let
previewLink
;
let
writeLink
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
spyOn
(
Vue
.
http
,
'
post
'
).
and
.
callFake
(()
=>
new
Promise
((
resolve
)
=>
{
spyOn
(
Vue
.
http
,
'
post
'
).
and
.
callFake
(()
=>
new
Promise
((
resolve
)
=>
{
...
@@ -52,6 +53,7 @@ describe('Markdown field component', () => {
...
@@ -52,6 +53,7 @@ describe('Markdown field component', () => {
}));
}));
previewLink
=
vm
.
$el
.
querySelector
(
'
.nav-links li:nth-child(2) a
'
);
previewLink
=
vm
.
$el
.
querySelector
(
'
.nav-links li:nth-child(2) a
'
);
writeLink
=
vm
.
$el
.
querySelector
(
'
.nav-links li:nth-child(1) a
'
);
});
});
it
(
'
sets preview link as active
'
,
(
done
)
=>
{
it
(
'
sets preview link as active
'
,
(
done
)
=>
{
...
@@ -103,6 +105,40 @@ describe('Markdown field component', () => {
...
@@ -103,6 +105,40 @@ describe('Markdown field component', () => {
done
();
done
();
},
0
);
},
0
);
});
});
function
assertLinks
(
isWrite
)
{
expect
(
writeLink
.
parentNode
.
classList
.
contains
(
'
active
'
)).
toEqual
(
isWrite
);
expect
(
previewLink
.
parentNode
.
classList
.
contains
(
'
active
'
)).
toEqual
(
!
isWrite
);
expect
(
vm
.
$el
.
querySelector
(
'
.md-preview
'
).
style
.
display
).
toEqual
(
isWrite
?
'
none
'
:
''
);
}
it
(
'
clicking already active write or preview link does nothing
'
,
(
done
)
=>
{
writeLink
.
click
();
setTimeout
(()
=>
{
assertLinks
(
true
);
writeLink
.
click
();
setTimeout
(()
=>
{
assertLinks
(
true
);
previewLink
.
click
();
setTimeout
(()
=>
{
assertLinks
(
false
);
previewLink
.
click
();
setTimeout
(()
=>
{
assertLinks
(
false
);
done
();
});
});
});
});
});
});
});
describe
(
'
markdown buttons
'
,
()
=>
{
describe
(
'
markdown buttons
'
,
()
=>
{
...
...
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