Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
switch-wayf
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GIP RENATER
switch-wayf
Commits
980db79e
Commit
980db79e
authored
Mar 01, 2019
by
Geoffroy ARNOUD
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added select2 dropdown into header and default-settings page #K7
parent
2836fbca
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
38 deletions
+37
-38
lib/default-header.php
lib/default-header.php
+4
-5
lib/default-settings.php
lib/default-settings.php
+0
-1
www/js/select2Functions.js
www/js/select2Functions.js
+33
-32
No files found.
lib/default-header.php
View file @
980db79e
...
...
@@ -13,9 +13,8 @@
<?php
if
(
$useSelect2
)
{
echo
'<link
rel="stylesheet" href="'
.
$_SERVER
[
'SCRIPT_NAME'
]
.
'/select2.css" type="text/css"
>'
.
PHP_EOL
;
echo
'<link
href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" /
>'
.
PHP_EOL
;
echo
'<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>'
.
PHP_EOL
;
// echo '<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.js"></script>'.PHP_EOL;
echo
'<script type="text/javascript" src="'
.
$javascriptURL
.
'/select2Functions.js"></script>'
.
PHP_EOL
;
}
elseif
(
$useImprovedDropDownList
)
{
echo
'<link rel="stylesheet" href="'
.
$_SERVER
[
'SCRIPT_NAME'
]
.
'/ImprovedDropDown.css" type="text/css">'
.
PHP_EOL
;
...
...
@@ -95,8 +94,8 @@
if
(
<?php
echo
(
$useSelect2
)
?
'true'
:
'false'
?>
){
$
(
'
.userIdPSelection
'
).
select2
({
ajax
:
{
url
:
<?php
echo
"'"
.
$
apiURL
.
"
/idps'"
?>
,
delay
:
25
0
,
url
:
<?php
echo
"'"
.
$
_SERVER
[
'REQUEST_URI'
]
.
"api
/idps'"
?>
,
delay
:
100
0
,
dataType
:
'
json
'
,
data
:
function
(
params
)
{
var
query
=
{
...
...
@@ -118,7 +117,7 @@
placeholder
:
"
<?php
echo
getLocalString
(
'select_idp'
)
?>
"
,
allowClear
:
true
,
templateResult
:
formatList
,
templateSelection
:
formatSelection
,
templateSelection
:
format
Repo
Selection
,
escapeMarkup
:
function
(
text
)
{
return
text
;
}
});
...
...
lib/default-settings.php
View file @
980db79e
...
...
@@ -13,7 +13,6 @@
<p
class=
"promptMessage"
>
<?php
echo
getLocalString
(
'permanent_cookie'
);
?>
</p>
<p>
<?php
echo
getLocalString
(
'select_idp'
);
?>
</p>
<div
style=
"text-align: center"
>
<select
name=
"user_idp"
id=
"userIdPSelection"
class=
"userIdPSelection"
tabindex=
"0"
>
<?php
// If we use select2, we don't want IDP to be in DOM, but to use AJAX instead
...
...
www/js/select2Functions.js
View file @
980db79e
...
...
@@ -4,48 +4,49 @@
* Inspired from https://select2.org/data-sources/ajax
*/
/*
* Format for list items
*/
function
formatList
(
idp
)
{
if
(
idp
.
loading
)
{
return
idp
.
text
;
}
if
(
idp
.
children
==
null
)
{
// IDP
var
img
=
""
;
if
(
idp
.
logo
!==
null
)
{
// Logo present
if
(
idp
.
logo
.
toLowerCase
().
indexOf
(
'
data:image
'
)
!==
0
)
{
// TODO : gérer le cas où on ne veut pas fetcher les logos distants
// remote logo
img
=
"
<img src='
"
+
idp
.
logo
+
"
' />
"
;
}
else
{
// local logo
img
=
"
<img src='
"
+
idp
.
logo
+
"
' />
"
;
}
if
(
idp
.
loading
)
{
return
idp
.
text
;
}
if
(
idp
.
children
==
null
)
{
// IDP
var
img
=
""
;
if
(
idp
.
logo
!==
null
)
{
// Logo present
if
(
idp
.
logo
.
toLowerCase
().
indexOf
(
'
data:image
'
)
!==
0
)
{
// TODO : gérer le cas où on ne veut pas fetcher les logos distants
// remote logo
img
=
"
<img src='
"
+
idp
.
logo
+
"
' />
"
;
}
else
{
// local logo
img
=
"
<img src='
"
+
idp
.
logo
+
"
' />
"
;
}
}
else
{
img
=
"
"
;
}
var
markup
=
"
<div class='select2-result-repository clearfix'>
"
+
"
<div class='select2-result-repository__logo'>
"
+
img
+
"
</div>
"
+
"
<div class='select2-result-repository__title'>
"
+
idp
.
text
+
"
</div></div>
"
;
return
markup
;
}
else
{
img
=
"
"
;
// Group
var
markup
=
"
<div class='select2-result-repository clearfix'>
"
+
idp
.
text
+
"
</div>
"
;
return
markup
;
}
var
markup
=
"
<div class='select2-result-repository clearfix'>
"
+
"
<div class='select2-result-repository__logo'>
"
+
img
+
"
</div>
"
+
"
<div class='select2-result-repository__title'>
"
+
idp
.
text
+
"
</div></div>
"
;
return
markup
;
}
else
{
// Group
var
markup
=
"
<div class='select2-result-repository clearfix'>
"
+
idp
.
text
+
"
</div>
"
;
return
markup
;
}
}
/*
* Format for selected element
*/
function
formatSelection
(
idp
)
{
return
idp
.
text
;
return
idp
.
text
;
}
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