Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
photoswipe-3132556
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Issue forks
photoswipe-3132556
Commits
111293a2
Commit
111293a2
authored
8 years ago
by
git
Committed by
Paris Liakos
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2737585
by vaplas, dman: Not working on cached pages
parent
205fcbaf
Loading
Loading
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
js/photoswipe.jquery.js
+5
-0
5 additions, 0 deletions
js/photoswipe.jquery.js
photoswipe.module
+0
-12
0 additions, 12 deletions
photoswipe.module
photoswipe.services.yml
+1
-1
1 addition, 1 deletion
photoswipe.services.yml
src/PhotoswipeAssetsManager.php
+23
-3
23 additions, 3 deletions
src/PhotoswipeAssetsManager.php
with
29 additions
and
16 deletions
js/photoswipe.jquery.js
+
5
−
0
View file @
111293a2
...
...
@@ -16,6 +16,11 @@
var
$galleries
=
$
(
'
.photoswipe-gallery
'
,
context
);
if
(
$galleries
.
length
)
{
// if body haven't special container for show photoswipe gallery append it.
if
(
'
container
'
in
settings
.
photoswipe
&&
!
$
(
'
.pswp
'
).
length
){
$
(
'
body
'
).
append
(
settings
.
photoswipe
.
container
);
}
// loop through all gallery elements and bind events
$galleries
.
each
(
function
(
index
)
{
var
$gallery
=
$
(
this
);
...
...
This diff is collapsed.
Click to expand it.
photoswipe.module
+
0
−
12
View file @
111293a2
...
...
@@ -56,15 +56,3 @@ function photoswipe_page_attachments(array &$attachments) {
\Drupal
::
service
(
'photoswipe.assets_manager'
)
->
attach
(
$attachments
);
}
}
/**
* Implements hook_page_bottom().
*/
function
photoswipe_page_bottom
(
array
&
$page_bottom
)
{
// Load the Container HTML at the bottom of the page
if
(
\Drupal
::
service
(
'photoswipe.assets_manager'
)
->
isAttached
())
{
$page_bottom
[
'photoswipe'
]
=
array
(
'#theme'
=>
'photoswipe_container'
,
);
}
}
This diff is collapsed.
Click to expand it.
photoswipe.services.yml
+
1
−
1
View file @
111293a2
services
:
photoswipe.assets_manager
:
class
:
Drupal\photoswipe\PhotoswipeAssetsManager
arguments
:
[
'
@config.factory'
]
arguments
:
[
'
@config.factory'
,
'
@renderer'
]
This diff is collapsed.
Click to expand it.
src/PhotoswipeAssetsManager.php
+
23
−
3
View file @
111293a2
...
...
@@ -8,6 +8,7 @@
namespace
Drupal\photoswipe
;
use
Drupal\Core\Config\ConfigFactoryInterface
;
use
Drupal\Core\Render\RendererInterface
;
/**
* Photoswipe asset manager.
...
...
@@ -16,6 +17,8 @@ class PhotoswipeAssetsManager implements PhotoswipeAssetsManagerInterface {
/**
* Whether the assets were attached somewhere in this request or not.
*
* @var bool
*/
protected
$attached
;
...
...
@@ -26,11 +29,24 @@ class PhotoswipeAssetsManager implements PhotoswipeAssetsManagerInterface {
*/
protected
$config
;
/**
* The renderer.
*
* @var \Drupal\Core\Render\RendererInterface
*/
protected
$renderer
;
/**
* Creates a \Drupal\photoswipe\PhotoswipeAssetsManager.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config
* The config factory.
* @param \Drupal\Core\Render\RendererInterface $renderer
* The renderer service.
*/
public
function
__construct
(
ConfigFactoryInterface
$config
)
{
public
function
__construct
(
ConfigFactoryInterface
$config
,
RendererInterface
$renderer
)
{
$this
->
config
=
$config
->
get
(
'photoswipe.settings'
);
$this
->
renderer
=
$renderer
;
}
/**
...
...
@@ -39,14 +55,18 @@ class PhotoswipeAssetsManager implements PhotoswipeAssetsManagerInterface {
public
function
attach
(
array
&
$element
)
{
// We only need to load only once per pace.
if
(
!
$this
->
attached
)
{
// Add the library of Photoswipe assets
// Add the library of Photoswipe assets
.
$element
[
'#attached'
][
'library'
][]
=
'photoswipe/photoswipe'
;
// Load initialization file
// Load initialization file
.
$element
[
'#attached'
][
'library'
][]
=
'photoswipe/photoswipe.init'
;
// Add photoswipe js settings.
$element
[
'#attached'
][
'drupalSettings'
][
'photoswipe'
][
'options'
]
=
$this
->
config
->
get
(
'options'
);
// Add photoswipe container with class="pswp".
$template
=
[
"#theme"
=>
'photoswipe_container'
];
$element
[
'#attached'
][
'drupalSettings'
][
'photoswipe'
][
'container'
]
=
$this
->
renderer
->
render
(
$template
);
$this
->
attached
=
TRUE
;
}
}
...
...
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