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
880c9a2c
Commit
880c9a2c
authored
Nov 22, 2017
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport fix epic fullscreen
parent
9fefb6c2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
68 deletions
+91
-68
app/assets/javascripts/dropzone_input.js
app/assets/javascripts/dropzone_input.js
+4
-1
app/assets/javascripts/zen_mode.js
app/assets/javascripts/zen_mode.js
+6
-2
spec/javascripts/zen_mode_spec.js
spec/javascripts/zen_mode_spec.js
+81
-65
No files found.
app/assets/javascripts/dropzone_input.js
View file @
880c9a2c
...
@@ -36,7 +36,10 @@ export default function dropzoneInput(form) {
...
@@ -36,7 +36,10 @@ export default function dropzoneInput(form) {
$formDropzone
.
append
(
divHover
);
$formDropzone
.
append
(
divHover
);
$formDropzone
.
find
(
'
.div-dropzone-hover
'
).
append
(
iconPaperclip
);
$formDropzone
.
find
(
'
.div-dropzone-hover
'
).
append
(
iconPaperclip
);
if
(
!
uploadsPath
)
return
;
if
(
!
uploadsPath
)
{
$formDropzone
.
addClass
(
'
js-invalid-dropzone
'
);
return
;
}
const
dropzone
=
$formDropzone
.
dropzone
({
const
dropzone
=
$formDropzone
.
dropzone
({
url
:
uploadsPath
,
url
:
uploadsPath
,
...
...
app/assets/javascripts/zen_mode.js
View file @
880c9a2c
...
@@ -71,7 +71,7 @@ export default class ZenMode {
...
@@ -71,7 +71,7 @@ export default class ZenMode {
this
.
active_textarea
=
this
.
active_backdrop
.
find
(
'
textarea
'
);
this
.
active_textarea
=
this
.
active_backdrop
.
find
(
'
textarea
'
);
// Prevent a user-resized textarea from persisting to fullscreen
// Prevent a user-resized textarea from persisting to fullscreen
this
.
active_textarea
.
removeAttr
(
'
style
'
);
this
.
active_textarea
.
removeAttr
(
'
style
'
);
return
this
.
active_textarea
.
focus
();
this
.
active_textarea
.
focus
();
}
}
exit
()
{
exit
()
{
...
@@ -81,7 +81,11 @@ export default class ZenMode {
...
@@ -81,7 +81,11 @@ export default class ZenMode {
this
.
scrollTo
(
this
.
active_textarea
);
this
.
scrollTo
(
this
.
active_textarea
);
this
.
active_textarea
=
null
;
this
.
active_textarea
=
null
;
this
.
active_backdrop
=
null
;
this
.
active_backdrop
=
null
;
return
Dropzone
.
forElement
(
'
.div-dropzone
'
).
enable
();
const
$dropzone
=
$
(
'
.div-dropzone
'
);
if
(
$dropzone
&&
!
$dropzone
.
hasClass
(
'
js-invalid-dropzone
'
))
{
Dropzone
.
forElement
(
'
.div-dropzone
'
).
enable
();
}
}
}
}
}
...
...
spec/javascripts/zen_mode_spec.js
View file @
880c9a2c
/* eslint-disable space-before-function-paren, no-var, one-var, one-var-declaration-per-line, object-shorthand, comma-dangle, no-return-assign, new-cap, max-len */
/* global Mousetrap */
/* global Mousetrap */
import
Dropzone
from
'
dropzone
'
;
import
Dropzone
from
'
dropzone
'
;
import
ZenMode
from
'
~/zen_mode
'
;
import
ZenMode
from
'
~/zen_mode
'
;
(
function
()
{
describe
(
'
ZenMode
'
,
()
=>
{
var
enterZen
,
escapeKeydown
,
exitZen
;
let
zen
;
const
fixtureName
=
'
merge_requests/merge_request_with_comment.html.raw
'
;
describe
(
'
ZenMode
'
,
function
()
{
var
fixtureName
=
'
merge_requests/merge_request_with_comment.html.raw
'
;
preloadFixtures
(
fixtureName
);
preloadFixtures
(
fixtureName
);
beforeEach
(
function
()
{
loadFixtures
(
fixtureName
);
function
enterZen
()
{
spyOn
(
Dropzone
,
'
forElement
'
).
and
.
callFake
(
function
()
{
$
(
'
.notes-form .js-zen-enter
'
).
click
();
return
{
enable
:
function
()
{
return
true
;
}
}
};
// Stub Dropzone.forElement(...).enable()
function
exitZen
()
{
});
$
(
'
.notes-form .js-zen-leave
'
).
click
();
this
.
zen
=
new
ZenMode
();
}
function
escapeKeydown
()
{
$
(
'
.notes-form textarea
'
).
trigger
(
$
.
Event
(
'
keydown
'
,
{
keyCode
:
27
,
}));
}
beforeEach
(()
=>
{
loadFixtures
(
fixtureName
);
spyOn
(
Dropzone
,
'
forElement
'
).
and
.
callFake
(()
=>
({
enable
:
()
=>
true
,
}));
zen
=
new
ZenMode
();
// Set this manually because we can't actually scroll the window
// Set this manually because we can't actually scroll the window
return
this
.
zen
.
scroll_position
=
456
;
zen
.
scroll_position
=
456
;
});
});
describe
(
'
on enter
'
,
function
()
{
it
(
'
pauses Mousetrap
'
,
function
()
{
describe
(
'
on enter
'
,
()
=>
{
it
(
'
pauses Mousetrap
'
,
()
=>
{
spyOn
(
Mousetrap
,
'
pause
'
);
spyOn
(
Mousetrap
,
'
pause
'
);
enterZen
();
enterZen
();
return
expect
(
Mousetrap
.
pause
).
toHaveBeenCalled
();
expect
(
Mousetrap
.
pause
).
toHaveBeenCalled
();
});
});
return
it
(
'
removes textarea styling
'
,
function
()
{
it
(
'
removes textarea styling
'
,
()
=>
{
$
(
'
.notes-form textarea
'
).
attr
(
'
style
'
,
'
height: 400px
'
);
$
(
'
.notes-form textarea
'
).
attr
(
'
style
'
,
'
height: 400px
'
);
enterZen
();
enterZen
();
return
expect
(
$
(
'
.notes-form textarea
'
)).
not
.
toHaveAttr
(
'
style
'
);
expect
(
$
(
'
.notes-form textarea
'
)).
not
.
toHaveAttr
(
'
style
'
);
});
});
});
describe
(
'
in use
'
,
function
()
{
beforeEach
(
function
()
{
return
enterZen
();
});
});
return
it
(
'
exits on Escape
'
,
function
()
{
describe
(
'
in use
'
,
()
=>
{
beforeEach
(
enterZen
);
it
(
'
exits on Escape
'
,
()
=>
{
escapeKeydown
();
escapeKeydown
();
return
expect
(
$
(
'
.notes-form .zen-backdrop
'
)).
not
.
toHaveClass
(
'
fullscreen
'
);
expect
(
$
(
'
.notes-form .zen-backdrop
'
)).
not
.
toHaveClass
(
'
fullscreen
'
);
});
});
});
});
return
describe
(
'
on exit
'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'
on exit
'
,
()
=>
{
return
enterZen
(
);
beforeEach
(
enterZen
);
});
it
(
'
unpauses Mousetrap
'
,
function
()
{
it
(
'
unpauses Mousetrap
'
,
()
=>
{
spyOn
(
Mousetrap
,
'
unpause
'
);
spyOn
(
Mousetrap
,
'
unpause
'
);
exitZen
();
exitZen
();
return
expect
(
Mousetrap
.
unpause
).
toHaveBeenCalled
();
expect
(
Mousetrap
.
unpause
).
toHaveBeenCalled
();
});
});
return
it
(
'
restores the scroll position
'
,
function
()
{
spyOn
(
this
.
zen
,
'
scrollTo
'
);
it
(
'
restores the scroll position
'
,
()
=>
{
spyOn
(
zen
,
'
scrollTo
'
);
exitZen
();
exitZen
();
return
expect
(
this
.
zen
.
scrollTo
).
toHaveBeenCalled
();
expect
(
zen
.
scrollTo
).
toHaveBeenCalled
();
});
});
});
});
});
enterZen
=
function
()
{
describe
(
'
enabling dropzone
'
,
()
=>
{
return
$
(
'
.notes-form .js-zen-enter
'
).
click
();
beforeEach
(()
=>
{
};
enterZen
();
});
exitZen
=
function
()
{
it
(
'
should not call dropzone if element is not dropzone valid
'
,
()
=>
{
return
$
(
'
.notes-form .js-zen-leave
'
).
click
();
$
(
'
.div-dropzone
'
).
addClass
(
'
js-invalid-dropzone
'
);
};
exitZen
();
expect
(
Dropzone
.
forElement
).
not
.
toHaveBeenCalled
();
});
escapeKeydown
=
function
()
{
it
(
'
should call dropzone if element is dropzone valid
'
,
()
=>
{
return
$
(
'
.notes-form textarea
'
).
trigger
(
$
.
Event
(
'
keydown
'
,
{
$
(
'
.div-dropzone
'
).
removeClass
(
'
js-invalid-dropzone
'
);
keyCode
:
27
exitZen
();
}));
expect
(
Dropzone
.
forElement
).
toHaveBeenCalled
();
};
});
}).
call
(
window
);
});
});
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