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
8c64e8b4
Unverified
Commit
8c64e8b4
authored
Oct 12, 2017
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert CompareAutocomplete from class definition into simple function call, remove global export
parent
9f51a70e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
65 deletions
+56
-65
compare_autocomplete.js
app/assets/javascripts/compare_autocomplete.js
+54
-62
dispatcher.js
app/assets/javascripts/dispatcher.js
+2
-2
main.js
app/assets/javascripts/main.js
+0
-1
No files found.
app/assets/javascripts/compare_autocomplete.js
View file @
8c64e8b4
/* eslint-disable func-names, space-before-function-paren, one-var, no-var, one-var-declaration-per-line, object-shorthand, comma-dangle, prefer-arrow-callback, no-else-return, newline-per-chained-call, wrap-iife, max-len */
window
.
CompareAutocomplete
=
(
function
()
{
function
CompareAutocomplete
()
{
this
.
initDropdown
();
}
CompareAutocomplete
.
prototype
.
initDropdown
=
function
()
{
return
$
(
'.js-compare-dropdown'
).
each
(
function
()
{
var
$dropdown
,
selected
;
$dropdown
=
$
(
this
);
selected
=
$dropdown
.
data
(
'selected'
);
const
$dropdownContainer
=
$dropdown
.
closest
(
'.dropdown'
);
const
$fieldInput
=
$
(
`input[name="
${
$dropdown
.
data
(
'field-name'
)}
"]`
,
$dropdownContainer
);
const
$filterInput
=
$
(
'input[type="search"]'
,
$dropdownContainer
);
$dropdown
.
glDropdown
({
data
:
function
(
term
,
callback
)
{
return
$
.
ajax
({
url
:
$dropdown
.
data
(
'refs-url'
),
data
:
{
ref
:
$dropdown
.
data
(
'ref'
),
search
:
term
,
}
}).
done
(
function
(
refs
)
{
return
callback
(
refs
);
});
},
selectable
:
true
,
filterable
:
true
,
filterRemote
:
true
,
fieldName
:
$dropdown
.
data
(
'field-name'
),
filterInput
:
'input[type="search"]'
,
renderRow
:
function
(
ref
)
{
var
link
;
if
(
ref
.
header
!=
null
)
{
return
$
(
'<li />'
).
addClass
(
'dropdown-header'
).
text
(
ref
.
header
);
}
else
{
link
=
$
(
'<a />'
).
attr
(
'href'
,
'#'
).
addClass
(
ref
===
selected
?
'is-active'
:
''
).
text
(
ref
).
attr
(
'data-ref'
,
escape
(
ref
));
return
$
(
'<li />'
).
append
(
link
);
export
default
function
initCompareAutocomplete
()
{
$
(
'.js-compare-dropdown'
).
each
(()
=>
{
var
$dropdown
,
selected
;
$dropdown
=
$
(
this
);
selected
=
$dropdown
.
data
(
'selected'
);
const
$dropdownContainer
=
$dropdown
.
closest
(
'.dropdown'
);
const
$fieldInput
=
$
(
`input[name="
${
$dropdown
.
data
(
'field-name'
)}
"]`
,
$dropdownContainer
);
const
$filterInput
=
$
(
'input[type="search"]'
,
$dropdownContainer
);
$dropdown
.
glDropdown
({
data
:
function
(
term
,
callback
)
{
return
$
.
ajax
({
url
:
$dropdown
.
data
(
'refs-url'
),
data
:
{
ref
:
$dropdown
.
data
(
'ref'
),
search
:
term
,
}
},
id
:
function
(
obj
,
$el
)
{
return
$el
.
attr
(
'data-ref'
);
},
toggleLabel
:
function
(
obj
,
$el
)
{
return
$el
.
text
().
trim
();
}
});
$filterInput
.
on
(
'keyup'
,
(
e
)
=>
{
const
keyCode
=
e
.
keyCode
||
e
.
which
;
if
(
keyCode
!==
13
)
return
;
const
text
=
$filterInput
.
val
();
$fieldInput
.
val
(
text
);
$
(
'.dropdown-toggle-text'
,
$dropdown
).
text
(
text
);
$dropdownContainer
.
removeClass
(
'open'
);
});
$dropdownContainer
.
on
(
'click'
,
'.dropdown-content a'
,
(
e
)
=>
{
$dropdown
.
prop
(
'title'
,
e
.
target
.
text
.
replace
(
/_+
?
/g
,
'-'
));
if
(
$dropdown
.
hasClass
(
'has-tooltip'
))
{
$dropdown
.
tooltip
(
'fixTitle'
);
}).
done
(
function
(
refs
)
{
return
callback
(
refs
);
});
},
selectable
:
true
,
filterable
:
true
,
filterRemote
:
true
,
fieldName
:
$dropdown
.
data
(
'field-name'
),
filterInput
:
'input[type="search"]'
,
renderRow
:
function
(
ref
)
{
var
link
;
if
(
ref
.
header
!=
null
)
{
return
$
(
'<li />'
).
addClass
(
'dropdown-header'
).
text
(
ref
.
header
);
}
else
{
link
=
$
(
'<a />'
).
attr
(
'href'
,
'#'
).
addClass
(
ref
===
selected
?
'is-active'
:
''
).
text
(
ref
).
attr
(
'data-ref'
,
escape
(
ref
));
return
$
(
'<li />'
).
append
(
link
);
}
});
},
id
:
function
(
obj
,
$el
)
{
return
$el
.
attr
(
'data-ref'
);
},
toggleLabel
:
function
(
obj
,
$el
)
{
return
$el
.
text
().
trim
();
}
});
$filterInput
.
on
(
'keyup'
,
(
e
)
=>
{
const
keyCode
=
e
.
keyCode
||
e
.
which
;
if
(
keyCode
!==
13
)
return
;
const
text
=
$filterInput
.
val
();
$fieldInput
.
val
(
text
);
$
(
'.dropdown-toggle-text'
,
$dropdown
).
text
(
text
);
$dropdownContainer
.
removeClass
(
'open'
);
});
};
return
CompareAutocomplete
;
})();
$dropdownContainer
.
on
(
'click'
,
'.dropdown-content a'
,
(
e
)
=>
{
$dropdown
.
prop
(
'title'
,
e
.
target
.
text
.
replace
(
/_+
?
/g
,
'-'
));
if
(
$dropdown
.
hasClass
(
'has-tooltip'
))
{
$dropdown
.
tooltip
(
'fixTitle'
);
}
});
});
}
app/assets/javascripts/dispatcher.js
View file @
8c64e8b4
...
...
@@ -23,7 +23,7 @@ import Project from './project';
import
projectAvatar
from
'./project_avatar'
;
/* global MergeRequest */
import
Compare
from
'./compare'
;
/* global CompareAutocomplete */
import
initCompareAutocomplete
from
'./compare_autocomplete'
;
/* global ProjectFindFile */
import
ProjectNew
from
'./project_new'
;
import
projectImport
from
'./project_import'
;
...
...
@@ -617,7 +617,7 @@ import ProjectVariables from './project_variables';
projectAvatar
();
switch
(
path
[
1
])
{
case
'compare'
:
new
CompareAutocomplete
();
init
CompareAutocomplete
();
break
;
case
'edit'
:
shortcut_handler
=
new
ShortcutsNavigation
();
...
...
app/assets/javascripts/main.js
View file @
8c64e8b4
...
...
@@ -40,7 +40,6 @@ import './admin';
import
'./aside'
;
import
loadAwardsHandler
from
'./awards_handler'
;
import
bp
from
'./breakpoints'
;
import
'./compare_autocomplete'
;
import
'./confirm_danger_modal'
;
import
Flash
,
{
removeFlashClickListener
}
from
'./flash'
;
import
'./gl_dropdown'
;
...
...
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