@@ -36,65 +36,49 @@ public function boot(Panel $panel): void
36
36
return $ url ;
37
37
};
38
38
39
- ImageColumn::macro ('simpleLightbox ' , macro: function ($ url = null , $ urlAsDefault = true ) use ($ ensureLightBoxUrl ) {
39
+ ImageColumn::macro ('simpleLightbox ' , macro: function ($ url = null , $ defaultDisplayUrl = true ) use ($ ensureLightBoxUrl ) {
40
40
41
- $ url = $ ensureLightBoxUrl ($ url , $ this );
42
-
43
- $ extraAttributes = $ this ->extraAttributes [0 ] ?? [];
44
- $ extraImgAttributes = $ this ->extraImgAttributes [0 ] ?? [];
45
-
46
- if ($ urlAsDefault ) {
41
+ if ($ defaultDisplayUrl ) {
47
42
$ this ->defaultImageUrl ($ url );
48
43
}
49
44
50
45
/** @phpstan-ignore-next-line */
51
46
return $ this
52
47
->openUrlInNewTab ()
53
48
->action (fn () => null ) // override default action for table row
54
- ->extraAttributes (array_merge ( $ extraAttributes , ['x-on:click ' => 'SimpleLightBox.open(event, \'' . $ url . '\') ' ]) )
55
- ->extraImgAttributes (array_merge ( $ extraImgAttributes , ['class ' => 'simple-light-box-img-indicator ' ]) );
49
+ ->extraAttributes (fn () => ['x-on:click ' => 'SimpleLightBox.open(event, \'' . $ ensureLightBoxUrl ( $ url, $ this ) . '\') ' ], true )
50
+ ->extraImgAttributes (['class ' => 'simple-light-box-img-indicator ' ], true );
56
51
});
57
52
58
- ImageEntry::macro ('simpleLightbox ' , function ($ url = null , $ urlAsDefault = true ) use ($ ensureLightBoxUrl ) {
59
-
60
- $ url = $ ensureLightBoxUrl ($ url , $ this );
61
-
62
- $ extraAttributes = $ this ->extraAttributes [0 ] ?? [];
63
- $ extraImgAttributes = $ this ->extraImgAttributes [0 ] ?? [];
53
+ ImageEntry::macro ('simpleLightbox ' , function ($ url = null , $ defaultDisplayUrl = true ) use ($ ensureLightBoxUrl ) {
64
54
65
- if ($ urlAsDefault ) {
55
+ if ($ defaultDisplayUrl ) {
66
56
$ this ->defaultImageUrl ($ url );
67
57
}
68
58
69
59
/** @phpstan-ignore-next-line */
70
60
return $ this
71
61
->openUrlInNewTab ()
72
- ->extraAttributes (array_merge ( $ extraAttributes , ['x-on:click ' => 'SimpleLightBox.open(event, \'' . $ url . '\') ' ]) )
73
- ->extraImgAttributes (array_merge ( $ extraImgAttributes , ['class ' => 'simple-light-box-img-indicator ' ]) );
62
+ ->extraAttributes (fn () => ['x-on:click ' => 'SimpleLightBox.open(event, \'' . $ ensureLightBoxUrl ( $ url, $ this ) . '\') ' ], true )
63
+ ->extraImgAttributes (['class ' => 'simple-light-box-img-indicator ' ], true );
74
64
});
75
65
76
- TextColumn::macro ('simpleLightbox ' , function ($ url = null , $ urlAsDefault = true ) use ($ ensureLightBoxUrl ) {
66
+ TextColumn::macro ('simpleLightbox ' , function ($ url = null , $ defaultDisplayUrl = true ) use ($ ensureLightBoxUrl ) {
77
67
78
- $ url = $ ensureLightBoxUrl ($ url , $ this );
79
-
80
- $ extraAttributes = $ this ->extraAttributes [0 ] ?? [];
81
-
82
- if ($ urlAsDefault ) {
68
+ if ($ defaultDisplayUrl ) {
83
69
$ this ->default ($ url );
84
70
}
85
71
86
72
/** @phpstan-ignore-next-line */
87
73
return $ this
88
74
->openUrlInNewTab ()
89
75
->url ($ url )
90
- ->extraAttributes (array_merge ( $ extraAttributes , ['x-on:click ' => 'SimpleLightBox.open(event, \'' . $ url . '\') ' ]) );
76
+ ->extraAttributes (fn () => ['x-on:click ' => 'SimpleLightBox.open(event, \'' . $ ensureLightBoxUrl ( $ url, $ this ) . '\') ' ], true );
91
77
});
92
78
93
- TextEntry::macro ('simpleLightbox ' , function ($ url = null , $ urlAsDefault = true ) {
94
-
95
- $ extraAttributes = $ this ->extraAttributes [0 ] ?? [];
79
+ TextEntry::macro ('simpleLightbox ' , function ($ url = null , $ defaultDisplayUrl = true ) {
96
80
97
- if ($ urlAsDefault ) {
81
+ if ($ defaultDisplayUrl ) {
98
82
$ this ->default ($ url );
99
83
}
100
84
@@ -104,10 +88,10 @@ public function boot(Panel $panel): void
104
88
// ->extraAttributes(array_merge($extraAttributes, ['x-on:click' => 'SimpleLightBox.open(event, \'' . $url . '\')']));
105
89
// Special case for text entry, open lightbox for text entry as cannot evaluate url at this point
106
90
->url ($ url )
107
- ->extraAttributes (array_merge ( $ extraAttributes , [
91
+ ->extraAttributes ([
108
92
'x-on:click ' => 'SimpleLightBox.openForTextEntry(event, \'a \', \'href \') ' ,
109
93
'class ' => 'fi-in-text-with-lightbox ' ,
110
- ]) )
94
+ ], true )
111
95
->extraEntryWrapperAttributes ([
112
96
'class ' => 'fi-in-text-with-lightbox-wrapper ' ,
113
97
], true );
0 commit comments