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
9081d3ef
Commit
9081d3ef
authored
Dec 02, 2016
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update droplab
parent
cb33856e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
4 deletions
+26
-4
app/assets/javascripts/droplab/droplab.js
app/assets/javascripts/droplab/droplab.js
+17
-2
app/assets/javascripts/droplab/droplab_ajax.js
app/assets/javascripts/droplab/droplab_ajax.js
+9
-2
No files found.
app/assets/javascripts/droplab/droplab.js
View file @
9081d3ef
...
...
@@ -51,13 +51,15 @@ Object.assign(DropDown.prototype, {
var
self
=
this
;
// event delegation.
this
.
list
.
addEventListener
(
'
click
'
,
function
(
e
)
{
if
(
e
.
target
.
tagName
===
'
A
'
||
e
.
target
.
tagName
===
'
button
'
)
{
// climb up the tree to find the LI
var
selected
=
utils
.
closest
(
e
.
target
,
'
LI
'
);
if
(
selected
)
{
e
.
preventDefault
();
self
.
hide
();
var
listEvent
=
new
CustomEvent
(
'
click.dl
'
,
{
detail
:
{
list
:
self
,
selected
:
e
.
target
,
selected
:
selected
,
data
:
e
.
target
.
dataset
,
},
});
...
...
@@ -102,6 +104,15 @@ Object.assign(DropDown.prototype, {
var
html
=
utils
.
t
(
sampleItem
.
outerHTML
,
dat
);
var
template
=
document
.
createElement
(
'
template
'
);
template
.
innerHTML
=
html
;
// Help set the image src template
var
imageTags
=
template
.
content
.
querySelectorAll
(
'
img[data-src]
'
);
for
(
var
i
=
0
;
i
<
imageTags
.
length
;
i
++
)
{
var
imageTag
=
imagetags
[
i
];
imageTag
.
src
=
imageTag
.
getAttribute
(
'
data-src
'
);
imageTag
.
removeAttribute
(
'
data-src
'
);
}
if
(
dat
.
hasOwnProperty
(
'
droplab_hidden
'
)
&&
dat
.
droplab_hidden
){
template
.
content
.
firstChild
.
style
.
display
=
'
none
'
}
else
{
...
...
@@ -115,6 +126,9 @@ Object.assign(DropDown.prototype, {
}
else
{
this
.
list
.
innerHTML
=
newChildren
.
join
(
''
);
}
// Show dropdown if there is data
data
!==
[]
?
this
.
show
()
:
this
.
hide
();
},
show
:
function
()
{
...
...
@@ -221,6 +235,7 @@ require('./window')(function(w){
// Restore initial State
hook
.
list
.
list
.
innerHTML
=
hook
.
list
.
initialState
;
hook
.
list
.
hide
();
hook
.
trigger
.
removeEventListener
(
'
mousedown
'
,
hook
.
events
.
mousedown
);
hook
.
trigger
.
removeEventListener
(
'
input
'
,
hook
.
events
.
input
);
hook
.
trigger
.
removeEventListener
(
'
keyup
'
,
hook
.
events
.
keyup
);
...
...
app/assets/javascripts/droplab/droplab_ajax.js
View file @
9081d3ef
...
...
@@ -3,6 +3,7 @@
/* global droplab */
droplab
.
plugin
(
function
init
(
DropLab
)
{
var
_addData
=
DropLab
.
prototype
.
addData
;
var
_setData
=
DropLab
.
prototype
.
setData
;
var
_loadUrlData
=
function
(
url
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
...
...
@@ -24,10 +25,16 @@ droplab.plugin(function init(DropLab) {
Object
.
assign
(
DropLab
.
prototype
,
{
addData
:
function
(
trigger
,
data
)
{
this
.
processData
(
trigger
,
data
,
_addData
);
},
setData
:
function
(
trigger
,
data
)
{
this
.
processData
(
trigger
,
data
,
_setData
);
},
processData
:
function
(
trigger
,
data
,
methodName
)
{
var
_this
=
this
;
if
(
'
string
'
===
typeof
data
)
{
_loadUrlData
(
data
).
then
(
function
(
d
)
{
_addData
.
call
(
_this
,
trigger
,
d
);
methodName
.
call
(
_this
,
trigger
,
d
);
}).
catch
(
function
(
e
)
{
if
(
e
.
message
)
console
.
error
(
e
.
message
,
e
.
stack
);
// eslint-disable-line no-console
...
...
@@ -35,7 +42,7 @@ droplab.plugin(function init(DropLab) {
console
.
error
(
e
);
// eslint-disable-line no-console
})
}
else
{
_addData
.
apply
(
this
,
arguments
);
methodName
.
apply
(
this
,
arguments
);
}
},
});
...
...
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