-
Notifications
You must be signed in to change notification settings - Fork 12
/
section auto layout right arrow auto click.html
337 lines (171 loc) · 7.57 KB
/
section auto layout right arrow auto click.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
<!--
begin section auto layout right arrow auto click
License : < https://tinyurl.com/s872fb68 >
Version : 0.3.2
SS Version : 7.1
Fluid
Engine
Compatible : Not Applicable
Dependencies : jQuery
Note : this effect is not active in SS Preview to test it use
private browsing < https://tinyurl.com/ynessvsf >
only slideshow banner and carousel auto layouts are
supported
By : Thomas Creedon < http://www.tomsWeb.consulting/ >
no user serviceable parts below
-->
<style>
html:not( .squarespace-damask ) #siteWrapper {
--twc-user-items-list-section : hidden;
}
html:not( .squarespace-damask ) .user-items-list-section {
visibility : var( --twc-user-items-list-section );
}
</style>
<script>
$( ( ) => {
const version = '0.3.2';
const s = `Section Auto Layout Right Arrow Auto Click v${ version }, ` +
'License < https://tinyurl.com/s872fb68 >, ' +
'Tom\'s Web Consulting < http://www.tomsWeb.consulting >';
console.log ( s );
if ( window.frameElement !== null ) return; // bail if in preview
const codeKey = 'twc-salraac';
const selectorKey = '.user-items-list-section';
if ( window.twc == undefined ) window.twc = { };
if ( twc.data == undefined ) twc.data = { };
if ( twc.data.hideShow == undefined ) twc.data.hideShow = { };
if ( twc.data.hideShow [ selectorKey ] == undefined )
twc
.data
.hideShow
[ selectorKey ]
=
[ ];
twc
.data
.hideShow
[ selectorKey ]
.push ( `--${ codeKey }` );
( ( ) => {
const autoLayoutSelector = [
'.user-items-list-banner-slideshow',
'.user-items-list-carousel',
]
.join ( ', ' )
const $elements = $( autoLayoutSelector );
if ( ! $elements.length ) return; // bail if no auto layouts of interest
const optionsGlobal = {
clickIntervalSeconds : 6,
killUponUserAction : true
};
const selector = `meta[name="${ codeKey }"]`;
const $element = $( selector );
const isGlobal = Boolean (
$element.length
);
if ( isGlobal ) {
const content = $element.attr ( 'content' );
// begin clickIntervalSeconds
let value = content
.match ( /click-interval-seconds=(\d+)/ );
if ( value !== null ) {
value = Number (
value
[ 1 ]
);
if ( ! isNaN ( value ) )
optionsGlobal.clickIntervalSeconds = value;
}
// end clickIntervalSeconds
// begin killUponUserAction
value = content
.match ( /kill-upon-user-action=(.+)/ );
if ( value !== null ) {
value = value
[ 1 ]
.toLowerCase ( );
optionsGlobal.killUponUserAction =
value == 'false' ? false : true;
}
// end killUponUserAction
}
$elements.each ( function ( ) {
const options =
JSON.parse ( JSON.stringify ( optionsGlobal ) );
const $this = $( this );
let $element = $this
.siblings ( '.list-section-title' )
.find ( `p:contains(${ codeKey })` );
const isLocal = Boolean (
$element.length
);
let b = ! ( isGlobal || isLocal );
if ( b ) return; // bail if not global or local
if ( isLocal ) {
let o = $element
.text ( )
.replace ( /[“”]/g, '"' )
.split ( ':' )
.slice ( 1 )
.join ( ':' );
o = ! o ? { } : JSON.parse ( o );
Object.assign ( options, o );
$element.remove ( );
$element = $element
.prevObject;
b = $element
.children ( )
.length;
if ( ! b ) {
const selector = '.section-title-vertical-padding-spacer';
$element.remove ( );
$element = $element
.prevObject;
$element
.siblings ( selector )
.remove ( );
}
if ( o.clickIntervalSeconds < 0 ) return true; // continue
}
const selector = '.mobile-arrow-button--right';
$( selector, $this ).each ( function ( ) {
const click = ( ) => {
const selector = '.sqs-modal-lightbox-focused';
const $element = $( selector );
if ( $element.length ) return; // bail if modal lightbox focused
$this.click ( );
}
const id =
setInterval ( click, options.clickIntervalSeconds * 1000 );
const $this = $( this );
const $pageSection = $this
.parents ( '.page-section' );
// continue if no kill on user interaction
if ( ! options.killUponUserAction ) return true;
$pageSection.on ( 'mousedown touchstart', function ( ) {
clearInterval ( id );
$( this )
.off ( 'mousedown touchstart' );
} );
} );
} );
} ) ( );
twc
.data
.hideShow
[ selectorKey ]
.pop ( `--${ codeKey }` );
const l = twc
.data
.hideShow
[ selectorKey ]
.length;
if ( ! l )
document
.getElementById ( 'siteWrapper' )
.style
.setProperty ( '--twc-user-items-list-section', 'visible' );
} );
</script>
<!-- end section auto layout right arrow auto click -->