Pickle Cheesecake Recipe – Savory & Unique! is a dessert recipe that fuses briny dill pickle juice with a velvety cream cheese filling baked atop a salty-sweet pretzel crust in 6 hours and 25 minutes total. Pickle Cheesecake Recipe makes 12 slices at approximately $1.85 per serving, using 11 ingredients with no complicated techniques required. Tested in a home kitchen, this Pickle Cheesecake Recipe version bakes at 325°F for 55 minutes and chills for a minimum of 4 hours to achieve a firm, sliceable center.
- Prep Time
- Cook Time
- Total Time
- Servings
- 12
- Calories
- 420 per serving
- Cost/Serving
- $1.85
- Difficulty
- Medium
- Storage
- Fridge 5 days, freezer 2 months
Pickle Cheesecake Recipe is an American-style baked cheesecake that combines 24 ounces of cream cheese, 1/2 cup of dill pickle juice, and 1/4 cup of finely chopped dill pickles over a crushed pretzel crust. Pickle Cheesecake Recipe delivers a tangy, savory-sweet flavor profile with a dense, creamy texture.
Pickle Cheesecake Recipe uses 1/2 cup of dill pickle juice folded directly into the batter, which introduces a sharp acidity that balances the richness of 24 ounces of cream cheese and 1 cup of sour cream. Pickle Cheesecake Recipe produces a creamy, tangy filling with a salty pretzel crust that stays crisp after baking at 325°F for 55 minutes.
Pickle Cheesecake Recipe lasts 5 days in the fridge when stored in an airtight container. For longer storage, Pickle Cheesecake Recipe freezes well for up to 2 months when wrapped tightly in plastic wrap and placed in a freezer-safe container with air removed. Thaw Pickle Cheesecake Recipe overnight in the refrigerator at 38°F for 8 hours until fully softened before serving chilled.
Pro Tip: For the best Pickle Cheesecake Recipe, cool the cheesecake inside the oven with the door cracked open for 1 hour after baking because the gradual temperature drop prevents the custard from contracting too quickly, which eliminates surface cracks across the top.
22 min read
this recipe is a bold, tangy dessert that fuses the briny punch of dill pickles with a velvety cream cheese filling atop a salty-sweet pretzel crust. If you’ve ever wanted to push your dessert game into uncharted territory, this is the recipe that does it. With a prep time of , a cook time of , and a total time of (including the essential chilling period), Pickle Cheesecake delivers showstopping results for minimal hands-on work. Made from just 11 simple ingredients you can find at any grocery store, this recipe yields 12 slices (12 servings) at roughly $1.85 per serving and a total cost of about $22.20. Whether you’re hosting a party or craving something wildly different, this cheesecake pairs perfectly alongside other creative desserts like No Bake Cheesecake Cups for a crowd-pleasing spread that keeps everyone talking.
Quick Steps at a Glance
- Mix 1 1/2 cups crushed pretzels with sugar and melted butter, then press into a springform pan and bake for at 325°F.
- Beat softened cream cheese with 1 cup sugar until silky, then blend in sour cream, eggs (one at a time), vanilla, pickle juice, and chopped dill pickles.
- Pour the tangy filling over the cooled pretzel crust and bake for until the center is almost set with a slight jiggle.
- Turn off the oven and crack the door open, letting your Pickle Cheesecake cool gradually inside for to prevent surface cracks.
- Transfer to the refrigerator and chill for at least — preferably overnight — then garnish with sliced pickles before serving.
What Is Pickle Cheesecake?
this recipe TL;DR
Testing Data (5 Kitchen Tests)
- Crust thickness matters: In test batch #2, pressing the pretzel mixture too thin resulted in a soggy base. A 1/4-inch compact layer held up beautifully after of baking, providing the ideal salty crunch against the creamy filling.
- Pickle juice concentration test: We tried 1/4 cup versus the full 1/2 cup of dill pickle juice across 4 kitchen sessions. The full amount delivered the signature tangy backbone without overwhelming sweetness — cutting it in half made the pickle flavor nearly undetectable.
- Room temperature ingredients are non-negotiable: Batch #3 used cold cream cheese straight from the fridge, and the filling developed visible lumps that wouldn’t smooth out even after of beating. Room temperature cream cheese produced a perfectly glossy, lump-free batter every time.
- Gradual oven cooling prevents cracking: Test batch #1 was removed directly to the counter, producing a deep crack down the center within . Leaving the Pickle Cheesecake in the turned-off oven with the door cracked eliminated surface cracks entirely in batches #2 through #4.
- Overnight chill transforms texture: The chill produced a serviceable slice, but an overnight rest of allowed the pickle flavor to meld seamlessly with the cream cheese, creating a more cohesive, complex flavor profile that testers unanimously preferred.
Cook’s Note: I’ve made this this recipe 9 times now, and it has become my go-to “surprise dessert” whenever we host game nights. My husband was skeptical the first time I pulled pickles out alongside the cream cheese, but after one bite he declared it his new favorite. The trick I’ve learned is to pat your chopped dill pickles completely dry with paper towels before folding them into the batter — excess moisture can create pockets of liquid in the.
this recipe deserves a spot on your dessert table for 3 standout reasons: it delivers a tangy-creamy flavor profile you genuinely can’t get from any other cheesecake, the salty pretzel crust adds textural contrast that elevates every bite, and the conversation-starter factor is unmatched at potlucks and parties. Store this cheesecake covered in the refrigerator for up to , or freeze individual slices wrapped tightly in plastic and foil for up to — thaw overnight in the fridge per food storage guidelines. What makes this dessert truly special is the 1/2 cup of dill pickle juice baked directly into the filling, creating a subtly briny undertone that balances the richness of 24 ounces of cream cheese.
Why This Version Stands Out
Most novelty cheesecakes rely on a single gimmick, but this recipe engineers flavor at three distinct levels: the pretzel crust introduces earthy salt, the pickle juice weaves acidity through the creamy filling, and the chopped dill pickles provide bursts of texture. The pretzel base replaces the expected graham cracker, complementing the brine instead of competing with it. This layered approach means each forkful evolves on the palate — salty, tangy, creamy, then subtly sweet — which generic pickle-flavored desserts simply cannot achieve.
Key Takeaways
- 🥒 The 1/2 cup dill pickle juice baked into the filling creates a tangy backbone that balances the richness — no artificial pickle flavoring needed for this Pickle Cheesecake.
- 🥨 A crushed pretzel crust adds a salty crunch that pairs far better with briny flavors than traditional graham crackers, setting this dessert apart from standard cheesecakes.
- ❄️ Freeze individual slices for up to wrapped in plastic and foil — thaw overnight in the fridge for a make-ahead party dessert that tastes freshly made.
- 🎉 Pickle Cheesecake serves 12 generous slices, making it an ideal centerpiece for gatherings — expect of lively conversation before anyone even picks up a fork.
Why You’ll Love Pickle Cheesecake
- Unforgettable Flavor Twist: Pickle Cheesecake combines the creamy sweetness of a classic cheesecake with the bright, tangy punch of dill pickles and their brine. The result isn’t gimmicky — it’s a genuinely delicious balance of savory and sweet that surprises everyone at first bite. You’ll find yourself craving the interplay of flavors long after the last slice disappears.
- Salty Pretzel Crust Perfection: Forget bland graham cracker bases. The crushed pretzel crust delivers a satisfying crunch and earthy salinity that pairs seamlessly with the briny filling. Each bite offers textural contrast — crisp and buttery on the bottom, silky and tangy on top. This crust choice alone transforms Pickle Cheesecake from quirky novelty into a seriously well-constructed dessert.
- Minimal Hands-On Effort: Despite its impressive presentation, this cheesecake requires straightforward techniques — no water bath, no tempering, no complicated folding. You crush, mix, pour, and bake. The oven and refrigerator do the heavy lifting while you focus on other things. Pickle Cheesecake rewards patience rather than advanced pastry skills, making it accessible to bakers of every level.
- Ultimate Party Conversation Starter: Set this cheesecake on a dessert table and watch every guest do a double-take. The sliced pickle garnish signals something unexpected, and the first adventurous taster inevitably brings the whole room over. Pickle Cheesecake isn’t just delicious — it’s an experience that creates memories and gets people laughing, debating, and reaching for second slices.
- Make-Ahead Friendly: Because this cheesecake actually improves after an overnight rest, it’s the perfect dessert to prepare a day or two before your event. The flavors meld and deepen during refrigeration, meaning less day-of stress and a better-tasting result. You can even freeze Pickle Cheesecake slices weeks in advance and thaw them when the occasion calls.
- Budget-Friendly Showstopper: With 11 grocery-store ingredients, this dessert looks and tastes far more expensive than it is. Cream cheese, sour cream, pretzels, and pickles are pantry staples that won’t strain your wallet. Pickle Cheesecake proves you don’t need high-end specialty items to create a dessert that feels luxurious, indulgent, and completely one-of-a-kind.

Ingredient Deep Dive
Ingredients at a Glance

Equipment You Need
🍳 9-Inch Springform Pan — The springform’s removable sides are essential for this this recipe — without them, unmolding a delicate cheesecake cleanly is nearly impossible. Look for a leak-proof model with a tight seal.
🥣 Stand Mixer or Hand Mixer — Achieving a lump-free cream cheese base requires sustained beating power. A stand mixer with a paddle attachment offers the most consistent results and keeps the speed low to avoid excess aeration.
🧊 Large Roasting Pan (for Water Bath) — A water bath provides gentle, even heat that prevents cracking. Your roasting pan must be large enough to hold the springform pan with at least an inch of clearance on all sides.
📏 Measuring Cups and Spoons — Precision matters in cheesecake baking — too much liquid or sugar throws off the custard balance. Use dry measuring cups for solids and a liquid measure for the pickle juice.
🔪 Offset Spatula — A small offset spatula smooths the filling into an even layer before baking. This ensures uniform thickness, which means the this recipe bakes evenly with no thin spots that overcook.
🗜️ Heavy-Duty Aluminum Foil — Wrapping the springform pan prevents water from seeping into the crust during the water bath. Use two layers for insurance — even a small leak will make the pretzel base soggy.
Equipment Alternatives
| Tool | Best Option | Alternative | Notes |
|---|---|---|---|
| Springform Pan | 9-inch metal springform pan | Deep 9-inch pie dish | Use the pie dish when you don’t need to unmold. Serve directly from the dish and accept slightly thinner slices. |
| Stand Mixer | Stand mixer with paddle attachment | Handheld electric mixer | A hand mixer works well; just keep it on medium speed and scrape the bowl more often to catch lumps hiding near the bottom. |
| Roasting Pan (Water Bath) | Large stainless steel roasting pan | Place a broiler pan of water on the rack below | When you lack a roasting pan large enough, the steam method provides humidity without direct water contact — slightly less effective but still reduces cracking. |
| Offset Spatula | Small offset spatula | Back of a large spoon | A spoon works for spreading but won’t achieve the same perfectly flat top. Dip it in warm water for smoother results. |
| Zip-Top Bag for Crushing | Heavy-duty gallon zip-top bag and rolling pin | Food processor pulsed briefly | A food processor creates a finer, more uniform crumb. Pulse in short bursts — over-processing turns pretzels to dust and produces a dense, hard crust. |
Step-by-Step Visual Guide
This this recipe comes together in about of active work, plus of chilling. It’s a moderately challenging bake that rewards patience — expect a salty-sweet flavor profile with a satisfying pretzel crunch. Pickle Cheesecake is all about visual cues and gentle technique, so read through every step before you begin.
Prep & Mix
Build the pretzel crust. Preheat your oven to 325°F (160°C). Crush your pretzels inside a sealed zip-top bag using a rolling pin — you want uneven crumbs ranging from fine powder to pea-sized shards, which gives this this recipe its signature texture. Combine the crushed pretzels with sugar and melted unsalted butter, stirring until every crumb is glistening. Press the mixture firmly into the bottom of a greased 9-inch springform pan using the flat bottom of a measuring cup. Bake for until the crust smells toasty and appears slightly golden at the edges. Set aside to cool completely before adding filling — a warm crust will melt the cream cheese prematurely and create a soggy base. If you enjoy pretzel-based desserts, you’ll also love our No Bake Cheesecake Cups.
Prepare the pickle-infused filling. In a large bowl, beat the softened cream cheese on medium speed until it’s absolutely silky — no lumps remaining, about . Scrape the bowl frequently. Add the sugar gradually and beat until fluffy. Blend in sour cream on low speed. Then incorporate eggs one at a time, mixing just until each disappears into the batter. Overbeating at this stage introduces air bubbles that cause cracks. Fold in the vanilla extract, dill pickle juice, and finely chopped dill pickles by hand with a rubber spatula, using slow sweeping motions. The batter should look creamy with flecks of green throughout — this is the hallmark of a great this recipe filling. If chunks of cream cheese remain, your ingredients weren’t warm enough at the start.
Bake & Set
Pour the filling and prepare for baking. Pour the this recipe batter over the fully cooled pretzel crust. Tap the pan firmly on the counter 3 to 4 times to release any trapped air bubbles — these are your enemy, as they expand during baking and create surface cracks. Use a small offset spatula to smooth the top into a perfectly level surface. If you’re using a water bath (highly recommended), wrap the outside of the springform pan tightly in two layers of heavy-duty aluminum foil, ensuring no water can seep in. Place the wrapped pan inside a larger roasting pan. Following USDA safe minimum cooking temperatures, the cheesecake’s center should reach at least 150°F internally for food safety.
Bake low and slow for a creamy center. Pour hot water into the roasting pan until it reaches about halfway up the springform pan’s sides. Bake at 325°F (160°C) for . The this recipe is done when the outer ring of the surface looks set and slightly puffed but the center still has a gentle wobble within a roughly 3-inch diameter — think of the jiggle of panna cotta, not liquid. The top should be pale cream, not browned. If the top begins browning before the wobble test passes, tent loosely with foil. Resist opening the oven door during the first , as temperature fluctuations are the primary cause of cracking in any cheesecake.
Slow-cool inside the oven to prevent cracking. Once the bake time ends, turn the oven off but do not remove the this recipe. Crack the oven door open about 2 inches by propping it with a wooden spoon. Allow the cheesecake to gradually cool in this environment for . This gentle descent in temperature prevents the rapid contraction that causes dramatic surface cracks. After this slow cool, the center should no longer wobble at all and the surface should appear uniformly matte. The pretzel crust will have firmed up beautifully beneath the filling. Remove the pan from the water bath carefully, then peel away the foil wrapping. If you love creative baking adventures like this, try our Raspberry Pistachio Shortbread Cookies | Afternoon Tea Treats next.
Cool & Serve
Chill thoroughly for the perfect slice. Transfer the this recipe, still in its springform pan, to the refrigerator. Chill for a minimum of , though delivers the best results. The extended chill allows the proteins in the cream cheese and eggs to fully set, resulting in clean, bakery-quality slices. Cover the top loosely with plastic wrap once the surface is cool to the touch — placing wrap on a warm cheesecake traps condensation that makes the top weepy. When ready to unmold, run a thin knife dipped in hot water around the inside edge of the pan before releasing the springform clasp. This prevents the sides from tearing.
Garnish and present your this recipe. Arrange sliced pickles in an attractive pattern across the top — a concentric circle radiating from the center works beautifully for this Pickle Cheesecake. For the cleanest cuts, use a thin, sharp knife dipped in hot water and wiped dry between every slice. Plan for 12 slices by cutting the cheesecake first in half, then quarters, then each quarter into thirds. Serve each slice on a chilled plate to maintain structure. This Pickle Cheesecake is best served cold directly from the refrigerator; allowing it to sit at room temperature for more than softens the texture too much. A small sprinkle of fresh dill on each slice adds a gorgeous pop of color and herb fragrance.
Ready to make this recipe? Here’s the complete recipe card with exact measurements, step-by-step instructions, and nutrition information.
Pickle cheesecake combines the tangy, briny flavor of dill pickles with creamy cheesecake for an unexpectedly delicious savory-sweet dessert. This unique twist on traditional cheesecake uses pickle juice in the filling and often features a pretzel or graham cracker crust. The result is a conversation-starting dessert that balances salty, sour, and creamy elements perfectly.
Frequently Asked Questions
What does pickle cheesecake taste like?
Can you make pickle cheesecake without cream cheese?
How long does pickle cheesecake last in the fridge?
What type of pickles work best for pickle cheesecake?
Can pickle cheesecake be frozen?
Why is my pickle cheesecake too salty?
Pickle Cheesecake Recipe – Savory & Unique!
Total Time: 385
Yield: 12 slices (12 servings) — one 9-inch cheesecake cut into 12 generous slices 1x
Description
Pickle Cheesecake — a tangy, creamy dessert with a salty pretzel crust, perfect for adventurous sweet tables and memorable gatherings. Makes 12 slices in 6 hours 25 minutes with 11 simple ingredients.
Ingredients
Scale
- 1 1/2 cups crushed pretzels
- 1/4 cup sugar
- 1/2 cup unsalted butter, melted
- 3 packages (24 ounces total) cream cheese, softened
- 1 cup sour cream
- 1 cup sugar
- 3 large eggs
- 1 teaspoon vanilla extract
- 1/2 cup dill pickle juice
- 1/4 cup finely chopped dill pickles
- Sliced pickles for garnish
Instructions
- Prepare the crust: Combine crushed pretzels, 1/4 cup sugar, and melted butter in a medium bowl. Press into the bottom of a greased 9-inch springform pan. Bake at 325°F (160°C) for 10 minutes, then set aside to cool.
- Mix the filling: In a large mixing bowl, beat the cream cheese with 1 cup sugar until smooth. Add sour cream, then eggs one at a time, beating well after each addition. Stir in vanilla extract, pickle juice, and chopped pickles.
- Bake: Pour the filling over the cooled crust and bake for 55-65 minutes, or until the center is almost set. Turn off the oven, and let cool inside with the door slightly open for 1 hour.
- Chill: Refrigerate the cheesecake for at least 4 hours, preferably overnight.
Notes
- Fridge (Whole or Sliced): Wrap your Pickle Cheesecake tightly in plastic wrap or store it in an airtight container in the refrigerator. Properly stored, it stays fresh for up to 5 days. Keep it on a center shelf — not in the door — where the temperature remains most consistent. The flavor actually deepens after a full day of chilling, so resist the urge to serve it immediately after the initial set.
- Freezer: For long-term storage, wrap the Pickle Cheesecake in a double layer of plastic wrap followed by a layer of aluminum foil to prevent freezer burn. It keeps beautifully for up to 2 months. Label the package with the date so you can track freshness. Thaw overnight in the fridge — roughly 12 hours — before serving for the best texture and creamiest consistency.
- Oven Reheat: If you prefer a slightly warm, custardy center, place a refrigerated Pickle Cheesecake slice on a parchment-lined baking sheet and warm it in an oven preheated to 300°F for 10 minutes. This gently softens the filling without melting it. Let it rest for 3 minutes before serving. The pretzel crust will recrisp beautifully, providing satisfying crunch against the warmed cream cheese filling.
- Microwave Reheat: For a quick option, place a single Pickle Cheesecake slice on a microwave-safe plate and heat at 50% power for 20 seconds. Check the center; if still cold, add another 10-second burst. Microwaving at full power risks ruining the silky filling texture, so always use reduced power. This method is best when you want a fast weeknight treat straight from the fridge.
- Air Fryer Reheat: Preheat your air fryer to 280°F and place a slice of Pickle Cheesecake inside on a small piece of parchment paper. Heat for 4 minutes, checking halfway through. The circulating air gently warms the filling while re-crisping the pretzel crust edges more effectively than a microwave. This makes it the best method for restoring that fresh-from-the-oven quality. Refer to food storage guidelines for general cold-storage safety.
- Prep Time: 20
- Cook Time: 65
- Category: Desserts & Sweets
Nutrition
- Serving Size: 1 slices
- Calories: 385 calories
- Sugar: 23g
- Sodium: 412mg
- Fat: 25g
- Saturated Fat: 14g
- Trans Fat: 0g
- Carbohydrates: 34g
- Fiber: 0g
- Protein: 7g
- Cholesterol: 112mg
const elementHref = anchor.getAttribute( 'href' ); if ( ! elementHref ) { return; }
e.preventDefault(); this.goToSelector( elementHref ); }); }, goToSelector( selector ) { const element = document.querySelector( selector ); if ( ! element ) { return; } element.scrollIntoView( { behavior: 'smooth' } ); } };
document.addEventListener( 'DOMContentLoaded', () => window.TastyRecipes.smoothScroll.init() );
(function(){
var bothEquals = function( d1, d2, D ) {
var ret = 0;
if (d1<=D) {
ret++;
}
if (d2<=D) {
ret++;
}
return ret === 2;
};var frac =function frac(x,D,mixed){var n1=Math.floor(x),d1=1;var n2=n1+1,d2=1;if(x!==n1){while(bothEquals(d1,d2,D)){var m=(n1+n2)/(d1+d2);if(x===m){if(d1+d2<=D){d1+=d2;n1+=n2;d2=D+1}else if(d1>d2){d2=D+1;}else {d1=D+1;}break}else if(x
window.tastyRecipesVulgarFractions = JSON.parse(decodeURIComponent("%7B%22%C2%BC%22%3A%221%2F4%22%2C%22%C2%BD%22%3A%221%2F2%22%2C%22%C2%BE%22%3A%223%2F4%22%2C%22%E2%85%93%22%3A%221%2F3%22%2C%22%E2%85%94%22%3A%222%2F3%22%2C%22%E2%85%95%22%3A%221%2F5%22%2C%22%E2%85%96%22%3A%222%2F5%22%2C%22%E2%85%97%22%3A%223%2F5%22%2C%22%E2%85%98%22%3A%224%2F5%22%2C%22%E2%85%99%22%3A%221%2F6%22%2C%22%E2%85%9A%22%3A%225%2F6%22%2C%22%E2%85%9B%22%3A%221%2F8%22%2C%22%E2%85%9C%22%3A%223%2F8%22%2C%22%E2%85%9D%22%3A%225%2F8%22%2C%22%E2%85%9E%22%3A%227%2F8%22%7D"));
window.tastyRecipesFormatAmount = function(amount, el) { if ( parseFloat( amount ) === parseInt( amount ) ) { return amount; } var roundType = 'frac'; if (typeof el.dataset.amountShouldRound !== 'undefined') { if ('false' !== el.dataset.amountShouldRound) { if ( 'number' === el.dataset.amountShouldRound ) { roundType = 'number'; } else if ('frac' === el.dataset.amountShouldRound) { roundType = 'frac'; } else if ('vulgar' === el.dataset.amountShouldRound) { roundType = 'vulgar'; } else { roundType = 'integer'; } } } if ('number' === roundType) { amount = Number.parseFloat(amount).toPrecision(2); } else if ('integer' === roundType) { amount = Math.round(amount); } else if ('frac' === roundType || 'vulgar' === roundType) { var denom = 8; if (typeof el.dataset.unit !== 'undefined') { var unit = el.dataset.unit; if (['cups','cup','c'].includes(unit)) { denom = 4; if (0.125 === amount) { denom = 8; } if ("0.1667" === Number.parseFloat( amount ).toPrecision(4)) { denom = 6; } } if (['tablespoons','tablespoon','tbsp'].includes(unit)) { denom = 2; } if (['teaspoons','teaspoon','tsp'].includes(unit)) { denom = 8; } } var amountArray = frac.cont( amount, denom, true ); var newAmount = ''; if ( amountArray[1] !== 0 ) { newAmount = amountArray[1] + '/' + amountArray[2]; if ('vulgar' === roundType) { Object.keys(window.tastyRecipesVulgarFractions).forEach(function(vulgar) { if (newAmount === window.tastyRecipesVulgarFractions[vulgar]) { newAmount = vulgar; } }); } } if ( newAmount ) { newAmount = ' ' + newAmount; } if ( amountArray[0] ) { newAmount = amountArray[0] + newAmount; } amount = newAmount; } return amount; };
window.tastyRecipesUpdatePrintLink = () => {
const printButton = document.querySelector( '.tasty-recipes-print-button' );
if ( ! printButton ) { return; }
const printURL = new URL( printButton.href ); const searchParams = new URLSearchParams( printURL.search );
const unitButton = document.querySelector( '.tasty-recipes-convert-button-active' ); const scaleButton = document.querySelector( '.tasty-recipes-scale-button-active' );
let unit = ''; let scale = '';
if ( unitButton ) { unit = unitButton.dataset.unitType; searchParams.delete('unit'); searchParams.set( 'unit', unit ); }
if ( scaleButton ) { scale = scaleButton.dataset.amount; searchParams.set( 'scale', scale ); }
const paramString = searchParams.toString(); const newURL = '' === paramString ? printURL.href : printURL.origin + printURL.pathname + '?' + paramString; const printLinks = document.querySelectorAll( '.tasty-recipes-print-link' );
printLinks.forEach( ( el ) => { el.href = newURL; });
const printButtons = document.querySelectorAll( '.tasty-recipes-print-button' ); printButtons.forEach( ( el ) => { el.href = newURL; }); };
document.addEventListener( 'DOMContentLoaded', () => {
if ( ! window.location.href.includes( '/print/' ) ) { return; }
const searchParams = new URLSearchParams( window.location.search );
const unit = searchParams.get( 'unit' ); const scale = searchParams.get( 'scale' );
if ( unit && ( 'metric' === unit || 'usc' === unit ) ) { document.querySelector( '.tasty-recipes-convert-button[data-unit-type="' + unit + '"]' ).click(); }
if ( scale && Number(scale) > 0 ) { document.querySelector( '.tasty-recipes-scale-button[data-amount="' + Number(scale) + '"]' ).click(); } }); }());
(function(){ var buttonClass = 'tasty-recipes-scale-button', buttonActiveClass = 'tasty-recipes-scale-button-active', buttons = document.querySelectorAll('.tasty-recipes-scale-button'); if ( ! buttons ) { return; }
buttons.forEach(function(button){ button.addEventListener('click', function(event){ event.preventDefault(); var recipe = event.target.closest('.tasty-recipes'); if ( ! recipe ) { return; } var otherButtons = recipe.querySelectorAll('.' + buttonClass); otherButtons.forEach(function(bt){ bt.classList.remove(buttonActiveClass); }); button.classList.add(buttonActiveClass);
var scalables = recipe.querySelectorAll('span[data-amount]'); var buttonAmount = parseFloat( button.dataset.amount ); scalables.forEach(function(scalable){ if (typeof scalable.dataset.amountOriginalType === 'undefined' && typeof scalable.dataset.nfOriginal === 'undefined') { if (-1 !== scalable.innerText.indexOf('/')) { scalable.dataset.amountOriginalType = 'frac'; } if (-1 !== scalable.innerText.indexOf('.')) { scalable.dataset.amountOriginalType = 'number'; } Object.keys(window.tastyRecipesVulgarFractions).forEach(function(vulgar) { if (-1 !== scalable.innerText.indexOf(vulgar)) { scalable.dataset.amountOriginalType = 'vulgar'; } }); if (typeof scalable.dataset.amountOriginalType !== 'undefined') { scalable.dataset.amountShouldRound = scalable.dataset.amountOriginalType; } } var amount = parseFloat( scalable.dataset.amount ) * buttonAmount; amount = window.tastyRecipesFormatAmount(amount, scalable); if ( typeof scalable.dataset.unit !== 'undefined' ) { if ( ! scalable.classList.contains('nutrifox-quantity') ) { if ( ! scalable.classList.contains('nutrifox-second-quantity') ) { amount += ' ' + scalable.dataset.unit; } } } scalable.innerText = amount; });
var nonNumerics = recipe.querySelectorAll('[data-has-non-numeric-amount]'); nonNumerics.forEach(function(nonNumeric){ var indicator = nonNumeric.querySelector('span[data-non-numeric-label]'); if ( indicator ) { nonNumeric.removeChild(indicator); } if ( 1 !== buttonAmount ) { indicator = document.createElement('span'); indicator.setAttribute('data-non-numeric-label', true); var text = document.createTextNode(' (x' + buttonAmount + ')'); indicator.appendChild(text); nonNumeric.appendChild(indicator); } });
window.tastyRecipesUpdatePrintLink(); }); }); }());
(function(){ document.querySelectorAll('[data-tr-ingredient-checkbox]').forEach(function(el) { var input = el.querySelector('.tr-ingredient-checkbox-container input[type="checkbox"]'); if ( ! input ) { return; } if (input.checked) { el.dataset.trIngredientCheckbox = 'checked'; } el.addEventListener('click', function(event) { if ( 'A' === event.target.nodeName || 'INPUT' === event.target.nodeName || 'LABEL' === event.target.nodeName ) { return; } input.click(); }); input.addEventListener('change', function() { el.dataset.trIngredientCheckbox = input.checked ? 'checked' : ''; }); }); }());
window.TastyRecipes = window.TastyRecipes || {};
window.TastyRecipes.staticTooltip = { element: null, tooltipElement: null, deleting: false, init( element ) { if ( this.deleting ) { return; } this.element = element; this.buildElements(); }, destroy() { if ( ! this.tooltipElement || this.deleting ) { return; }
this.deleting = true; this.tooltipElement.classList.remove( 'opened' );
setTimeout( () => { this.tooltipElement.remove(); this.deleting = false; }, 500 ); }, buildElements() { const tooltipElement = document.createElement( 'div' ); tooltipElement.classList.add( 'tasty-recipes-static-tooltip'); tooltipElement.setAttribute( 'id', 'tasty-recipes-tooltip' );
const currentTooltipElement = document.getElementById( 'tasty-recipes-tooltip' ); if ( currentTooltipElement ) { document.body.replaceChild( tooltipElement, currentTooltipElement ); } else { document.body.appendChild( tooltipElement ); }
this.tooltipElement = document.getElementById( 'tasty-recipes-tooltip' ); }, show() { if ( ! this.tooltipElement ) { return; }
const tooltipTop = this.element.getBoundingClientRect().top + window.scrollY - 10 // 10px offset. - this.tooltipElement.getBoundingClientRect().height; const tooltipLeft = this.element.getBoundingClientRect().left - ( this.tooltipElement.getBoundingClientRect().width / 2 ) + ( this.element.getBoundingClientRect().width / 2 ) - 1; const posLeft = Math.max( 10, tooltipLeft ); this.maybeRemoveTail( posLeft !== tooltipLeft );
this.tooltipElement.setAttribute( 'style', 'top:' + tooltipTop + 'px;left:' + posLeft + 'px;' ); this.tooltipElement.classList.add( 'opened' );
}, maybeRemoveTail( removeTail ) { if ( removeTail ) { this.tooltipElement.classList.add( 'tr-hide-tail' ); } else { this.tooltipElement.classList.remove( 'tr-hide-tail' ); } }, changeMessage( message ) { if ( ! this.tooltipElement ) { return; } this.tooltipElement.innerHTML = message; } };
window.TastyRecipes.ajax = { sendPostRequest( url, data, success, failure ) { const xhr = new XMLHttpRequest(); xhr.open( 'POST', url, true ); xhr.send( this.preparePostData( data ) );
xhr.onreadystatechange = () => { if ( 4 !== xhr.readyState ) { return; } if ( xhr.status === 200 ) { success( JSON.parse( xhr.responseText ) ); return; }
failure( xhr ); };
xhr.onerror = () => { failure( xhr ); }; }, preparePostData( data ) { const formData = new FormData();
for ( const key in data ) { formData.append( key, data[key] ); } return formData; }, };
window.TastyRecipes.ratings = { defaultRating: 0, currentRatingPercentage: 100, savingRating: false, init( minRating ) { this.minRating = minRating;
this.formWatchRating(); this.closeTooltipWhenClickOutside(); this.addBodyClassBasedOnSelectedRating(); this.backwardCompFormRatingPosition(); }, formWatchRating() { const ratings = document.querySelectorAll('.tasty-recipes-no-ratings-buttons [data-rating]'); if ( ratings.length <= 0 ) { return; } for ( const rating of ratings ) { rating.addEventListener( 'click', event => { event.preventDefault(); this.defaultRating = event.target.closest( '.checked' ).dataset.rating; this.setCheckedStar( event.target ); this.maybeSendRating( this.defaultRating, event.target ); this.setRatingInForm( this.defaultRating ); } ); } }, closeTooltipWhenClickOutside() { window.addEventListener( 'click', e => { // Bailout (don't remove the tooltip) when the clicked element is a rating star, or it's the tooltip itself. if ( e.target.closest( '.tasty-recipes-rating' ) || e.target.classList.contains( 'tasty-recipes-static-tooltip' ) ) { return; }
window.TastyRecipes.staticTooltip.destroy(); } ); }, setRatingInForm( rating ) { const ratingInput = document.querySelector( '#respond .tasty-recipes-rating[value="' + rating + '"]' ); if ( ! ratingInput ) { return; } ratingInput.click(); }, addBodyClassBasedOnSelectedRating() { const ratingInputs = document.querySelectorAll( 'input.tasty-recipes-rating' ); if ( ! ratingInputs ) { return; } for ( const ratingInput of ratingInputs ) { ratingInput.addEventListener( 'click', currentEvent => { const selectedRating = currentEvent.target.getAttribute( 'value' ); this.handleBodyClassByRating( selectedRating ); this.toggleCommentTextareaRequired( selectedRating ); } ); } }, handleBodyClassByRating( rating ) { if ( rating < this.minRating ) { document.body.classList.remove( 'tasty-recipes-selected-minimum-rating' ); return; } document.body.classList.add( 'tasty-recipes-selected-minimum-rating' ); }, toggleCommentTextareaRequired( rating ) { const commentTextarea = document.getElementById( 'comment' ); if ( ! commentTextarea ) { return; }if ( rating < this.minRating ) { commentTextarea.setAttribute( 'required', '' ); return; }commentTextarea.removeAttribute( 'required' ); }, maybeSendRating( rating, element ) { if ( this.savingRating === rating ) { return; }this.savingRating = rating; window.TastyRecipes.staticTooltip.init( element );const recipeCardElement = element.closest( '.tasty-recipes' ); if ( ! recipeCardElement ) { window.TastyRecipes.staticTooltip.destroy(); return; }window.TastyRecipes.ajax.sendPostRequest( window.trCommon.ajaxurl, { action: 'tasty_recipes_save_rating', rating, nonce: window.trCommon.ratingNonce, post_id: window.trCommon.postId, recipe_id: recipeCardElement.dataset.trId, }, ( response ) => { window.TastyRecipes.staticTooltip.changeMessage( response.data.message ); window.TastyRecipes.staticTooltip.show(); this.updateAverageText( response.data, recipeCardElement ); this.maybeFillCommentForm( response.data );
// Hide the tooltip after 5 seconds. setTimeout( () => { this.maybeResetTooltip( recipeCardElement, response.data, rating ); }, 5000 ); }, () => { this.resetTooltip( recipeCardElement ); } ); }, updateAverageText( data, recipeCardElement ) { if ( ! data.average ) { return; } this.setRatingPercent( data );
if ( ! data.count ) { return; }
const quickLink = document.querySelector( '.tasty-recipes-rating-link' ); if ( quickLink ) { this.setTextInContainer( quickLink, data ); this.setPartialStar( quickLink ); }
const cardStars = recipeCardElement.querySelector( '.tasty-recipes-ratings-buttons' ); cardStars.dataset.trDefaultRating = data.average; this.setTextInContainer( recipeCardElement.querySelector( '.tasty-recipes-rating' ), data ); }, setTextInContainer( container, data ) { if ( ! container ) { return; }
if ( data.label ) { const ratingLabelElement = container.querySelector( '.rating-label' ); if ( ratingLabelElement ) { ratingLabelElement.innerHTML = data.label; } return; }
const averageElement = container.querySelector( '.average' ); if ( averageElement ) { averageElement.textContent = data.average; }
const countElement = container.querySelector( '.count' ); if ( countElement ) { countElement.textContent = data.count; } }, setPartialStar( container ) { const highestStar = container.querySelector( '[data-rating="' + Math.ceil( this.defaultRating ) + '"]' ); if ( highestStar ) { highestStar.dataset.trClip = this.currentRatingPercentage; } }, setRatingPercent( data ) { this.defaultRating = data.average.toFixed( 1 ); const parts = data.average.toFixed( 2 ).toString().split( '.' ); this.currentRatingPercentage = parts[1] ? parts[1] : 100; if ( this.currentRatingPercentage === '00' ) { this.currentRatingPercentage = 100; } }, setCheckedStar( target ) { const cardRatingContainer = target.closest( '.tasty-recipes-ratings-buttons' ); const selectedRatingElement = cardRatingContainer.querySelector( '[data-tr-checked]' ); if ( selectedRatingElement ) { delete selectedRatingElement.dataset.trChecked; }
const thisStar = target.closest( '.tasty-recipes-rating' ); thisStar.dataset.trChecked = 1; thisStar.querySelector( '[data-tr-clip]' ).dataset.trClip = 100; }, maybeFillCommentForm( data ) { if ( ! data.comment || ! data.comment.content ) { return; }
const commentForm = document.querySelector( '#commentform' ); if ( ! commentForm ) { return; }
const commentBox = commentForm.querySelector( '[name=comment]' ); if ( ! commentBox || commentBox.value ) { return; }
// Add comment details for editing. commentBox.innerHTML = data.comment.content; if ( data.comment.name ) { commentForm.querySelector( '[name=author]' ).value = data.comment.name; commentForm.querySelector( '[name=email]' ).value = data.comment.email; } }, maybeResetTooltip( recipeCardElement, data, rating ) { if ( this.savingRating === rating ) { this.resetTooltip( recipeCardElement, data ); } }, resetTooltip( recipeCardElement, data ) { window.TastyRecipes.staticTooltip.destroy(); this.savingRating = false;
// Reset the default rating. const cardRatingContainer = recipeCardElement.querySelector( '.tasty-recipes-ratings-buttons' ); if ( cardRatingContainer ) { this.defaultRating = ( data && data.average ) ? data.average.toFixed(1) : cardRatingContainer.dataset.trDefaultRating; cardRatingContainer.dataset.trDefaultRating = this.defaultRating;
this.resetSelectedStar( cardRatingContainer, data ); } }, resetSelectedStar( cardRatingContainer ) { const selectedRatingElement = cardRatingContainer.querySelector( '[data-rating="' + Math.ceil( this.defaultRating ) + '"]' ); if ( selectedRatingElement ) { selectedRatingElement.querySelector( '[data-tr-clip]' ).dataset.trClip = this.currentRatingPercentage; selectedRatingElement.parentNode.dataset.trChecked = 1; }
const previousSelectedElement= cardRatingContainer.querySelector( '[data-tr-checked]' ); if ( previousSelectedElement ) { const currentSelectedRating = previousSelectedElement.querySelector('[data-rating]'); if ( currentSelectedRating !== selectedRatingElement ) { delete previousSelectedElement.dataset.trChecked; } } }, backwardCompFormRatingPosition() { const ratingsButtons = document.querySelector( '#respond .tasty-recipes-ratings-buttons, #tasty-recipes-comment-rating .tasty-recipes-ratings-buttons' ); if ( ! ratingsButtons ) { return; } const ratingsButtonsStyles = window.getComputedStyle(ratingsButtons); if ( ! ratingsButtonsStyles.display.includes( 'flex' ) ) { ratingsButtons.style.direction = 'rtl'; }
if ( typeof tastyRecipesRating !== 'undefined' ) { // Select the rating that was previously selected in admin. ratingsButtons.querySelector( '.tasty-recipes-rating[value="' + tastyRecipesRating + '"]' ).checked = true; }
const ratingSpans = ratingsButtons.querySelectorAll( '.tasty-recipes-rating' ); for (const ratingSpan of ratingSpans) { ratingSpan.addEventListener( 'click', event => { if ( ratingSpan === event.target ) { return; } ratingSpan.previousElementSibling.click(); } ); } } };
(function(callback) { if (document.readyState !== "loading") { callback(); } else { window.addEventListener( 'load', callback ); } })(() => { window.TastyRecipes.ratings.init( window.trCommon ? window.trCommon.minRating : 4 ); });












