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
Tatuya Kamada
gitlab-ce
Commits
16459fdd
Commit
16459fdd
authored
Mar 30, 2016
by
Alfredo Sumaran
Committed by
Jacob Schatz
Apr 16, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes multiple ajax request and incorrect data being set for the current issuable
parent
ad48ecac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
16 deletions
+47
-16
app/assets/javascripts/gfm_auto_complete.js.coffee
app/assets/javascripts/gfm_auto_complete.js.coffee
+47
-16
No files found.
app/assets/javascripts/gfm_auto_complete.js.coffee
View file @
16459fdd
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
window
.
GitLab
?=
{}
window
.
GitLab
?=
{}
GitLab
.
GfmAutoComplete
=
GitLab
.
GfmAutoComplete
=
dataLoading
:
false
dataSource
:
''
dataSource
:
''
# Emoji
# Emoji
...
@@ -17,17 +19,41 @@ GitLab.GfmAutoComplete =
...
@@ -17,17 +19,41 @@ GitLab.GfmAutoComplete =
template
:
'<li><small>${id}</small> ${title}</li>'
template
:
'<li><small>${id}</small> ${title}</li>'
# Add GFM auto-completion to all input fields, that accept GFM input.
# Add GFM auto-completion to all input fields, that accept GFM input.
setup
:
->
setup
:
(
wrap
)
->
input
=
$
(
'.js-gfm-input'
)
@
input
=
$
(
'.js-gfm-input'
)
# destroy previous instances
@
destroyAtWho
()
# set up instances
@
setupAtWho
()
if
@
dataSource
if
!
@
dataLoading
@
dataLoading
=
true
# We should wait until initializations are done
# and only trigger the last .setup since
# The previous .dataSource belongs to the previous issuable
# and the last one will have the **proper** .dataSource property
# TODO: Make this a singleton and turn off events when moving to another page
setTimeout
(
=>
fetch
=
@
fetchData
(
@
dataSource
)
fetch
.
done
(
data
)
=>
@
dataLoading
=
false
@
loadData
(
data
)
,
1000
)
setupAtWho
:
->
# Emoji
# Emoji
input
.
atwho
@
input
.
atwho
at
:
':'
at
:
':'
displayTpl
:
@
Emoji
.
template
displayTpl
:
@
Emoji
.
template
insertTpl
:
':${name}:'
insertTpl
:
':${name}:'
# Team Members
# Team Members
input
.
atwho
@
input
.
atwho
at
:
'@'
at
:
'@'
displayTpl
:
@
Members
.
template
displayTpl
:
@
Members
.
template
insertTpl
:
'${atwho-at}${username}'
insertTpl
:
'${atwho-at}${username}'
...
@@ -42,7 +68,7 @@ GitLab.GfmAutoComplete =
...
@@ -42,7 +68,7 @@ GitLab.GfmAutoComplete =
title
:
sanitize
(
title
)
title
:
sanitize
(
title
)
search
:
sanitize
(
"
#{
m
.
username
}
#{
m
.
name
}
"
)
search
:
sanitize
(
"
#{
m
.
username
}
#{
m
.
name
}
"
)
input
.
atwho
@
input
.
atwho
at
:
'#'
at
:
'#'
alias
:
'issues'
alias
:
'issues'
searchKey
:
'search'
searchKey
:
'search'
...
@@ -55,7 +81,7 @@ GitLab.GfmAutoComplete =
...
@@ -55,7 +81,7 @@ GitLab.GfmAutoComplete =
title
:
sanitize
(
i
.
title
)
title
:
sanitize
(
i
.
title
)
search
:
"
#{
i
.
iid
}
#{
i
.
title
}
"
search
:
"
#{
i
.
iid
}
#{
i
.
title
}
"
input
.
atwho
@
input
.
atwho
at
:
'!'
at
:
'!'
alias
:
'mergerequests'
alias
:
'mergerequests'
searchKey
:
'search'
searchKey
:
'search'
...
@@ -68,13 +94,18 @@ GitLab.GfmAutoComplete =
...
@@ -68,13 +94,18 @@ GitLab.GfmAutoComplete =
title
:
sanitize
(
m
.
title
)
title
:
sanitize
(
m
.
title
)
search
:
"
#{
m
.
iid
}
#{
m
.
title
}
"
search
:
"
#{
m
.
iid
}
#{
m
.
title
}
"
if
@
dataSource
destroyAtWho
:
->
$
.
getJSON
(
@
dataSource
).
done
(
data
)
->
@
input
.
atwho
(
'destroy'
)
# load members
input
.
atwho
'load'
,
'@'
,
data
.
members
fetchData
:
(
dataSource
)
->
# load issues
$
.
getJSON
(
dataSource
)
input
.
atwho
'load'
,
'issues'
,
data
.
issues
# load merge requests
loadData
:
(
data
)
->
input
.
atwho
'load'
,
'mergerequests'
,
data
.
mergerequests
# load members
# load emojis
@
input
.
atwho
'load'
,
'@'
,
data
.
members
input
.
atwho
'load'
,
':'
,
data
.
emojis
# load issues
@
input
.
atwho
'load'
,
'issues'
,
data
.
issues
# load merge requests
@
input
.
atwho
'load'
,
'mergerequests'
,
data
.
mergerequests
# load emojis
@
input
.
atwho
'load'
,
':'
,
data
.
emojis
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