BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
3e7770aa
Commit
3e7770aa
authored
May 26, 2016
by
Jacob Schatz
Committed by
Phil Hughes
Jun 17, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Overwrite undo history
parent
3d5b1c35
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
5 deletions
+53
-5
text_utility.js.coffee
app/assets/javascripts/lib/text_utility.js.coffee
+44
-4
_discussion.html.haml
app/views/projects/issues/_discussion.html.haml
+7
-0
_discussion.html.haml
app/views/projects/merge_requests/_discussion.html.haml
+2
-1
No files found.
app/assets/javascripts/lib/text_utility.js.coffee
View file @
3e7770aa
...
...
@@ -3,11 +3,14 @@
w
.
gl
.
text
?=
{}
w
.
gl
.
text
.
undoManager
?=
{}
gl
.
text
.
randomString
=
->
Math
.
random
().
toString
(
36
).
substring
(
7
)
gl
.
text
.
replaceRange
=
(
s
,
start
,
end
,
substitute
)
->
s
.
substring
(
0
,
start
)
+
substitute
+
s
.
substring
(
end
);
gl
.
text
.
wrap
=
(
textArea
,
tag
)
->
$textArea
=
$
(
textArea
)
oldVal
=
$textArea
.
val
()
$textArea
.
focus
()
textArea
=
$textArea
.
get
(
0
)
selObj
=
window
.
getSelection
()
...
...
@@ -18,10 +21,12 @@
textArea
.
selectionStart
,
textArea
.
selectionEnd
,
(
tag
+
selObj
.
toString
()
+
tag
))
$textArea
.
data
(
'old-val'
,
text
).
val
(
replaceWith
);
$textArea
.
data
(
'old-val'
,
text
).
val
(
replaceWith
)
gl
.
text
.
undoManager
.
addUndo
(
oldVal
,
$textArea
.
val
())
gl
.
text
.
prepend
=
(
textArea
,
tag
)
->
$textArea
=
$
(
textArea
)
oldVal
=
$textArea
.
val
()
$textArea
.
focus
()
textArea
=
$textArea
.
get
(
0
)
selObj
=
window
.
getSelection
()
...
...
@@ -36,12 +41,45 @@
(
"
#{
lineBreak
}#{
tag
}
#{
selObj
.
toString
()
}
\n
"
)
)
$textArea
.
data
(
'old-val'
,
text
).
val
(
replaceWith
);
# $textArea.val(replaceWith)
gl
.
text
.
undoManager
.
addUndo
(
oldVal
,
$textArea
.
val
())
gl
.
text
.
undoManager
.
history
=
{}
gl
.
text
.
undoManager
.
undoHistory
=
{}
gl
.
text
.
undoManager
.
addUniqueIfNotExists
=
(
$ta
)
->
unique
=
$ta
.
attr
(
'data-unique'
)
if
not
unique
?
unique
=
gl
.
text
.
randomString
()
$ta
.
attr
(
'data-unique'
,
unique
)
gl
.
text
.
undoManager
.
history
[
unique
]
=
[]
gl
.
text
.
undoManager
.
undoHistory
[
unique
]
=
[]
unique
gl
.
text
.
undoManager
.
addUndo
=
(
oldVal
,
newVal
)
->
$thisTextarea
=
$
(
'textarea:focus'
)
unique
=
gl
.
text
.
undoManager
.
addUniqueIfNotExists
(
$thisTextarea
)
gl
.
text
.
undoManager
.
history
[
unique
].
push
({
oldVal
:
oldVal
,
newVal
:
newVal
})
gl
.
text
.
undoManager
.
undo
=
()
->
$thisTextarea
=
$
(
'textarea:focus'
)
unique
=
gl
.
text
.
undoManager
.
addUniqueIfNotExists
(
$thisTextarea
)
if
not
gl
.
text
.
undoManager
.
history
[
unique
].
length
return
latestChange
=
gl
.
text
.
undoManager
.
history
[
unique
].
pop
()
gl
.
text
.
undoManager
.
undoHistory
[
unique
].
push
(
latestChange
)
$thisTextarea
.
val
(
latestChange
.
oldVal
)
gl
.
text
.
undoManager
.
redo
=
()
->
$thisTextarea
=
$
(
'textarea:focus'
)
unique
=
gl
.
text
.
undoManager
.
addUniqueIfNotExists
(
$thisTextarea
)
if
not
gl
.
text
.
undoManager
.
undoHistory
[
unique
].
length
return
gl
.
text
.
addListeners
=
()
->
console
.
log
(
'addListeners'
)
self
=
@
$
(
'.js-md'
).
on
'click'
,
->
$this
=
$
(
@
)
...
...
@@ -61,12 +99,14 @@
$this
.
data
(
'md-tag'
)
)
$
(
window
).
on
'keydown'
,
(
e
)
-
>
$
(
window
).
on
'keydown'
,
(
e
)
=
>
if
e
.
ctrlKey
or
e
.
metaKey
if
String
.
fromCharCode
(
e
.
which
).
toLowerCase
()
is
'z'
and
!
e
.
shiftKey
e
.
preventDefault
()
self
.
undoManager
.
undo
()
else
if
((
String
.
fromCharCode
(
e
.
which
).
toLowerCase
()
is
'z'
and
e
.
shiftKey
)
or
(
String
.
fromCharCode
(
e
.
which
).
toLowerCase
()
is
'y'
))
e
.
preventDefault
()
self
.
undoManager
.
redo
()
gl
.
text
.
removeListeners
=
()
->
$
(
'js-md.btn-bold'
).
off
()
...
...
app/views/projects/issues/_discussion.html.haml
View file @
3e7770aa
...
...
@@ -5,3 +5,9 @@
#notes
=
render
'projects/notes/notes_with_form'
:javascript
$
(
function
(){
gl
.
text
.
removeListeners
();
gl
.
text
.
addListeners
();
})
\ No newline at end of file
app/views/projects/merge_requests/_discussion.html.haml
View file @
3e7770aa
...
...
@@ -11,4 +11,4 @@
$
(
function
(){
gl
.
text
.
removeListeners
();
gl
.
text
.
addListeners
();
})
})
\ No newline at end of file
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