Tom's Web Consulting Squarespace Library
This is a monorepo of code for adding various effects to Squarespace v7.1 and v7.0 sites.
Please consider making a donation.
Your donations help me to continue to help you realize your website goals! The donation amounts are suggested amounts. Any donation amount is greatly appreciated!
Did my code help you build a site for your client and make you some dough? How about a slice of the bread for Tom?
twcsl contains over 85 effects. Each effect has it's own version number, code, read me, and etc. Each effect is independant. In other words all the effects are not necessarily designed to all work together.
-
v7.0 and v7.1 effects
-
v7.0 only effects
-
effects for all v7.0 templates
-
template specific effects
-
-
v7.1 only effects
-
twcsl
-
Add Images to Product Detail Page Based on Tags Above Additional Info
-
Add Text Based on Tags After Matched Text to Product Description
-
Change Form Block Post-Submit Redirect Based on a Radio Form Field Selected Option
-
Change Form Block Post-Submit Redirect Based on a Select Form Field Selected Option
-
Change Unable to Add Item to Cart Alert for Only N Available
-
Change Unable to Add Item to Cart Alert for Out of Stock Variants
-
Change Unable to Add Item to Cart Alert for Unselected Variants
-
Move Product Detail Additional Info First N Blocks to End of Product Details
-
Set Store Product Detail Named Form Labeled Text Field Character Max Length
-
-
-
Auto Change Product Grid Image Opacity on Touch Screen Device
-
Change Store Product Detail Related Products Grid Column Number for Desktop
-
Remove Product Detail Quantity Field Outer Outline When Focused
-
Replace Product Detail Add to Cart Button With Button that Redirects to a Url
-
Reposition First Page Section Background so Header Does Not Hide It
-
Store Product Detail Price Add Sqs-Money-Native for Variants
-
Store Product Detail Price Force Mutation on Quantity Change
The rest of this document covers twcsl.js.
twcsl.js is a Javascript library of common properties and methods useful for building effects in Squarespace sites.
Add the following to Settings > Advanced > Code Injection > HEADER.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://d1j8mu9lowy9zf.cloudfront.net/twcsl/0.1d15/twcsl.js"></script>You want to build an effect that does something when you are on a store category product grid page. You can use twcsl to test if you are on such a page with the following.
if ( twcsl.storePage.hasCategory ) console.log ( 'has category' );-
getFirstPageSection
-
getFirstPageSection ( )
- Returns jQuery object.
-
-
getFormFieldLabel
-
getFormFieldLabel ( field )
- Field is a jQuery object.
- Returns form field label as entered in SS form editor interface.
-
-
getFormNth
-
getFormNth ( [nth form on page] )
- Default is the first form on the page.
- Returns jQuery object or undefined for no form.
-
-
getUrlParser
-
getUrlParser ( url )
- Returns an anchor element.
-
-
scrollEffect
-
scrollEffect ( callback [, easingFunction, invertScale ] )
-
Calculates the scroll postion as a ratio that is passed to your callback.
easingFunction ( string ), default is linear
invertScale ( boolean ), default is false
-
-
-
blogPage ( object )
-
categories ( array, for detail page only )
-
category ( string )
-
categoryUrlSlug ( string )
-
categoryUrlSlugs ( array, for detail page only )
-
hasCategory ( boolean )
-
hasTag ( boolean )
-
isBlogPage ( boolean )
-
isList ( boolean )
-
isPost ( boolean )
-
tag ( string )
-
tags ( array, for detail page only )
-
tagUrlSlug ( string )
-
tagUrlSlugs ( array, for detail page only )
-
urlSlug ( string )
-
-
eventsPage ( object )
-
categories ( array, for detail page only )
-
category ( string )
-
categoryUrlSlug ( string )
-
categoryUrlSlugs ( array, for detail page only )
-
hasCategory ( boolean )
-
hasTag ( boolean )
-
isEvent ( boolean )
-
isEventPage ( boolean )
-
tag ( string )
-
tags ( array, for detail page only )
-
tagUrlSlug ( string )
-
tagUrlSlugs ( array, for detail page only )
-
urlSlug ( string )
-
-
is70 ( boolean )
-
is71 ( boolean )
-
isCart ( boolean )
-
isSearch ( boolean )
-
navigator ( object )
- hasTouchScreen ( boolean )
-
ssVersion ( string )
-
storePage ( object )
-
category ( string )
-
categoryUrlSlug ( string )
-
classTags ( array, for detail page only )
-
hasCategory ( boolean )
-
hasTag ( boolean )
-
isDetail ( boolean )
-
isStorePage ( boolean )
-
tag ( string )
-
tagUrlSlug ( string )
-
urlSlug ( string )
-
-
version ( string, twcsl version )
-
2021-09-03
- fixed bad blogPage isList check
- fixes for blogPage for various v7.0 templates
- bumped version to 0.1d15
-
2021-08-31
- added blogPage.isList
- added effects outline
- changed eventPage.isDetail to eventsPage.isEvent
- changed eventPage to eventsPage
- checked Five and Montauk family template support
- bumped version to 0.1d14
-
2021-08-06
- changed blogPage.isDetail to isPost
- bumped version to 0.1d13
-
2021-07-28
- fix for getFormFieldLabel not being exposed
- bumped version to 0.1d12
-
2021-07-25
- fix for firstPageSection, changed to method getFirstPageSection
- bumped version to 0.1d11
-
2021-07-25
- fix for getUrlParser not defined
- bumped version to 0.1d10
-
2021-07-24
- added getUrlParser method
- added getFormFieldLabel method
- checked Avenue template support
- consolidated nearly identical code into _getClassEventlistFilterText function
- bumped version to 0.1d9
-
2021-06-27
- added firstPageSection
- added storePage.classCategories
- added blogPage
- bumped version to 0.1d8
-
2021-06-07
- fix for _urlSlug undefined error on non-collection pages
- added isCart and isSearch properties
- bumped version to 0.1d7
-
2021-06-04
- reworked what was being labeled as category and tag, in many cases what was being return was not what the user enters in SS but classes or url search parameters as generated by SS
- fix for is70 check
- bumped version to 0.1d6
-
2021-06-02
- fix storePage.category being erroneously populated
- bumped version to 0.1d5
-
2021-06-01
- added eventPage property
- bumped version to 0.1d4
-
2021-05-31
- fix for library not initializing
- bumped version to 0.1d3
-
2021-05-29
- added tags property for storePage
- bumped version to 0.1d2
-
2021-05-26
- added version property for twcsl
- filled out the documentation a bit
- added getFormNth method
- changed order of parameters for scrollEffect method
- bumped version to 0.1d1
-
2021-05-22
- initial version
