Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gsap
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
gsap
Commits
d6fb235b
Commit
d6fb235b
authored
1 year ago
by
Bryan Sharpe
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3341662
by b_sharpe: Add options to manually add libs
parent
7e67804d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1
Issue #3341662: Add options to manually add libs.
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
config/install/gsap.settings.yml
+2
-0
2 additions, 0 deletions
config/install/gsap.settings.yml
gsap.info.yml
+0
-1
0 additions, 1 deletion
gsap.info.yml
gsap.module
+13
-5
13 additions, 5 deletions
gsap.module
src/Form/Admin.php
+28
-2
28 additions, 2 deletions
src/Form/Admin.php
with
43 additions
and
8 deletions
config/install/gsap.settings.yml
+
2
−
0
View file @
d6fb235b
include_gsap
:
false
include_libs
:
false
libs
:
{
}
This diff is collapsed.
Click to expand it.
gsap.info.yml
+
0
−
1
View file @
d6fb235b
...
...
@@ -3,4 +3,3 @@ type: module
description
:
"
This
module
integrates
Greensock
GSAP
into
Drupal"
package
:
User interface
core_version_requirement
:
^9.2 || ^10
This diff is collapsed.
Click to expand it.
gsap.module
+
13
−
5
View file @
d6fb235b
...
...
@@ -26,12 +26,20 @@ function gsap_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_page_attachments().
*/
function
gsap_page_attachments
(
array
&
$attachments
)
{
$settings
=
\Drupal
::
config
(
'gsap.settings'
);
$attachments
[
'#cache'
][
'tags'
][]
=
'config:gsap.settings'
;
// Add main lib.
$attachments
[
'#attached'
][
'library'
][]
=
'gsap/gsap'
;
if
(
$settings
->
get
(
'include_gsap'
))
{
$attachments
[
'#attached'
][
'library'
][]
=
'gsap/gsap'
;
// Optional plugins.
$libraries
=
\Drupal
::
config
(
'gsap.settings'
)
->
get
(
'libs'
);
foreach
(
$libraries
as
$lib
)
{
$attachments
[
'#attached'
][
'library'
][]
=
'gsap/'
.
$lib
;
// Add defined optional plugins.
if
(
$settings
->
get
(
'include_libs'
))
{
$libraries
=
\Drupal
::
config
(
'gsap.settings'
)
->
get
(
'libs'
);
foreach
(
$libraries
as
$lib
)
{
$attachments
[
'#attached'
][
'library'
][]
=
'gsap/'
.
$lib
;
}
}
}
}
This diff is collapsed.
Click to expand it.
src/Form/Admin.php
+
28
−
2
View file @
d6fb235b
...
...
@@ -33,11 +33,27 @@ class Admin extends ConfigFormBase {
$config
=
$this
->
config
(
'gsap.settings'
);
$form
=
parent
::
buildForm
(
$form
,
$form_state
);
$form
[
'include_gsap'
]
=
[
'#title'
=>
$this
->
t
(
'Include GSAP on every page?'
),
'#type'
=>
'checkbox'
,
'#default_value'
=>
$config
->
get
(
'include_gsap'
)
??
FALSE
,
];
$form
[
'include_libs'
]
=
[
'#title'
=>
$this
->
t
(
'Include additional libs on every page?'
),
'#type'
=>
'checkbox'
,
'#default_value'
=>
$config
->
get
(
'include_libs'
)
??
FALSE
,
'#states'
=>
[
'disabled'
=>
[
':input[name="include_gsap"]'
=>
[
'checked'
=>
FALSE
],
],
],
];
$form
[
'libs'
]
=
[
'#title'
=>
$this
->
t
(
'
Libraries to Include.
'
),
'#title'
=>
$this
->
t
(
'
Available CDN Libraries
'
),
'#description'
=>
$this
->
t
(
'Select the plugins to include as libraries. These will be added to every page.'
),
'#type'
=>
'checkboxes'
,
'#required'
=>
TRUE
,
'#default_value'
=>
$config
->
get
(
'libs'
)
??
[],
'#options'
=>
[
'flip'
=>
$this
->
t
(
'Flip'
),
...
...
@@ -50,6 +66,14 @@ class Admin extends ConfigFormBase {
'pixi'
=>
$this
->
t
(
'Pixi'
),
'text'
=>
$this
->
t
(
'Text'
),
],
'#states'
=>
[
'invisible'
=>
[
':input[name="include_libs"]'
=>
[
'enabled'
=>
FALSE
],
],
'disabled'
=>
[
':input[name="include_libs"]'
=>
[
'checked'
=>
FALSE
],
],
],
];
return
$form
;
...
...
@@ -62,6 +86,8 @@ class Admin extends ConfigFormBase {
$libraries
=
array_values
(
array_filter
(
$form_state
->
getValue
(
'libs'
)));
$this
->
configFactory
->
getEditable
(
'gsap.settings'
)
->
set
(
'libs'
,
$libraries
)
->
set
(
'include_gsap'
,
$form_state
->
getValue
(
'include_gsap'
))
->
set
(
'include_libs'
,
$form_state
->
getValue
(
'include_libs'
))
->
save
();
parent
::
submitForm
(
$form
,
$form_state
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment