Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save simone-coelho/b73661e33dc93b29d0d95e414435936e to your computer and use it in GitHub Desktop.
Save simone-coelho/b73661e33dc93b29d0d95e414435936e to your computer and use it in GitHub Desktop.
DirectTV Slideout Template

Client Slideout Modal Template - Documentation

πŸ“‹ Overview

This template creates a customizable slideout modal that appears from the left or right side of the page. It features dynamic content, styling options, dual buttons, and comprehensive tracking capabilities.

✨ Simplified Design: This template has been streamlined with a single background color option for ease of use, removing complex split-color functionality that wasn't specified in the original requirements.

🎯 Features

  • βœ… Page visit triggering with timing control
  • βœ… Slide animations from left or right side with position control
  • βœ… Background color control: customizable background color
  • βœ… Dynamic text layout with 3 format options
  • βœ… Complete typography control for all text elements
  • βœ… Two customizable buttons with full styling and dimension control
  • βœ… Image support with optional display
  • βœ… Smart close button positioned in corner
  • βœ… Event tracking for all user interactions
  • βœ… Cookie-based display prevention
  • βœ… Mobile responsive design

πŸ”§ Configuration Guide

🎯 Trigger Settings (When to Show)

Page Visits

  • What it does: Sets how many page views are required before the slideout appears
  • Default: 1 (shows on first page visit)
  • Examples:
    • 1 = Show immediately on first visit
    • 3 = Show after user has visited 3 pages
    • 0 = Show on every page load (not recommended)

Timing (seconds)

  • What it does: Delay in seconds before the slideout appears
  • Default: 0 (immediate)
  • Examples:
    • 0 = Show immediately
    • 3 = Wait 3 seconds after page load
    • 10 = Wait 10 seconds (good for engagement timing)

πŸ“ Position Settings (Where to Show)

Slide Direction

  • What it does: Controls which side the slideout slides in from
  • Options:
    • Slide from Left = Appears from left edge of screen
    • Slide from Right = Appears from right edge of screen

Vertical Placement

  • What it does: Controls vertical position on the page
  • Options:
    • Top of Page = Appears near top of viewport
    • Center of Page = Appears vertically centered
    • Bottom of Page = Appears near bottom of viewport

πŸ–ΌοΈ Visual Elements

Border Color

  • What it does: Sets the color of the slideout's outer border
  • Default: #000000 (black)
  • Format: Hex color code (e.g., #FF0000 for red)

Image URL (optional)

  • What it does: Displays an image at the top of the slideout
  • Default: DirectTV services image for testing
  • Usage:
    • Leave blank to hide image section
    • Use full URL (https://...)
    • Images are automatically responsive

🎨 Background Styling

Background Color

  • What it does: Sets the background color for the entire slideout modal
  • Default: #F4F4F4 (light gray)
  • Format: Hex color code (e.g., #FFFFFF for white, #000000 for black)
  • Usage: This color fills the entire modal background area

πŸ“ Text Content & Styling

Text Layout Format

  • What it does: Controls the order and presence of headline/subheadline
  • Options:
    • Headline Only = Shows only main headline
    • Headline + Subheadline = Headline first, then subheadline
    • Subheadline + Headline = Subheadline first, then headline

Subheadline Settings

  • Text: The smaller header text
  • Font Family: Font name (e.g., "Arial, sans-serif")
  • Color: Hex color code for text
  • Font Size: Size with units (e.g., "16px")
  • Alignment: left, center, or right

Headline Settings

  • Text: The main header text
  • Font Family: Font name (e.g., "Arial, sans-serif")
  • Color: Hex color code for text
  • Font Size: Size with units (e.g., "24px")
  • Alignment: left, center, or right

Body Settings

  • Text: Main descriptive content (supports HTML)
  • Font Family: Font name (e.g., "Arial, sans-serif")
  • Color: Hex color code for text
  • Font Size: Size with units (e.g., "14px")
  • Alignment: left, center, or right

Legal Settings

  • Text: Small print, disclaimers (supports HTML)
  • Font Family: Font name (e.g., "Arial, sans-serif")
  • Color: Hex color code for text
  • Font Size: Size with units (e.g., "10px")
  • Alignment: left, center, or right

πŸ”˜ Button Configuration

Primary Button

  • Text: Button label (e.g., "Claim Offer")
  • Link URL: Where button clicks go (e.g., "/pages/landing")
  • Font Family: Button text font
  • Text Color: Button text color
  • Font Size: Button text size
  • Background Color: Button background color

Secondary Button

  • Text: Button label (e.g., "No Thanks")
  • Font Family: Button text font
  • Text Color: Button text color
  • Font Size: Button text size
  • Background Color: Button background color
  • Border Color: Button border color

Note: Secondary button automatically closes the slideout when clicked

Button Layout

  • Alignment: Position of button container (left, center, right)
  • Width: Button width (e.g., "120px")
  • Height: Button height (e.g., "40px")
  • Border Radius: Roundness of corners (e.g., "25px" for pills)
  • Gap Between Buttons: Space between the two buttons (e.g., "12px")

🎨 Styling Examples

Modern Pill Buttons

Width: 120px
Height: 36px
Border Radius: 25px
Gap: 15px

Square Corporate Buttons

Width: 100px
Height: 40px
Border Radius: 4px
Gap: 10px

Background Color Example

Background Color: #1E3A8A (dark blue)

πŸ“± Responsive Behavior

Desktop (768px+)

  • Width: 400px
  • Full feature set
  • Smooth animations

Mobile (<768px)

  • Width: 320px
  • Adjusted padding
  • Smaller fonts
  • Optimized touch targets

πŸ”§ Technical Features

Event Tracking

Automatically tracks these events to Optimizely:

  • slideout_closed - When X button is clicked
  • slideout_primary_button_clicked - When main button is clicked
  • slideout_secondary_button_clicked - When secondary button is clicked

Cookie Management

  • Sets slideoutShown=true cookie when closed
  • Prevents slideout from showing again for 24 hours
  • Respects user dismissal choice

Performance

  • Lightweight CSS animations
  • No external dependencies
  • Efficient DOM manipulation
  • Mobile-optimized

⚠️ Common Issues & Solutions

Image Not Showing

Problem: Image field has URL but image doesn't display Solutions:

  • Check URL is accessible (try opening in browser)
  • Ensure URL starts with https://
  • Verify image isn't blocked by CORS policy

Slideout Not Appearing

Possible causes:

  • Cookie already set from previous test
  • Page visits requirement not met
  • Timing delay still counting down
  • Check browser console for JavaScript errors

Buttons Too Large/Small

Problem: Buttons don't match design Solution: Adjust these fields:

  • Button Width (e.g., "100px")
  • Button Height (e.g., "36px")
  • Button Border Radius (e.g., "25px")

Text Overlapping

Problem: Text elements overlap or look cramped Solutions:

  • Reduce font sizes
  • Adjust button height
  • Shorten text content

πŸš€ Best Practices

Content

  • Keep headline under 50 characters
  • Use compelling action words for buttons
  • Make legal text concise but complete
  • Test with actual content, not Lorem Ipsum

Design

  • Use high contrast colors for accessibility
  • Keep button text readable at all sizes
  • Test on both light and dark backgrounds
  • Ensure image enhances, doesn't distract

Timing

  • 3-5 seconds delay often works well
  • Don't interrupt critical user flows
  • Consider page content when timing
  • Test with real user behavior

Mobile

  • Test on actual devices, not just browser resize
  • Ensure buttons are easily tappable (min 44px)
  • Keep text readable without zooming
  • Consider thumb-friendly button placement

πŸ“‹ Testing Checklist

  • Slideout appears from correct side
  • Timing delay works as expected
  • Image loads and displays properly
  • Background color shows correctly
  • All text is readable and properly styled
  • Both buttons work and are properly sized
  • Close button works and is positioned correctly
  • Slideout closes and doesn't reappear
  • Mobile responsive design works
  • Event tracking fires correctly

πŸ†˜ Quick Reference

Field Organization

  1. 🎯 Trigger: Page visits, timing
  2. πŸ“ Position: Direction, placement
  3. πŸ–ΌοΈ Visual: Border, image
  4. 🎨 Background: Color
  5. πŸ“ Text: Format, content, styling
  6. πŸ”˜ Buttons: Content, styling, layout

Template Summary

  • Total Fields: 37 configurable options
  • Field Groups: 6 logical sections with emoji organization
  • Complexity: Simplified single background color (no split functionality)

Key Measurements

  • Container: 400px wide (320px mobile)
  • Close button: 22px circle, 5px from corner edges
  • Padding: 15px internal spacing
  • Animation: 0.5s ease-out transition

This template provides a complete slideout modal solution with extensive customization options. For additional support or feature requests, refer to the Optimizely documentation or contact your development team.

{
"plugin_type": "widget",
"name": "Client Slideout Modal",
"edit_page_url": "www.optimizely.com",
"form_schema": [
{
"default_value": 1,
"field_type": "number",
"name": "page_visits",
"label": "🎯 Trigger: Page Visits",
"options": {
"min": 0,
"step": 1
}
},
{
"default_value": 0,
"field_type": "number",
"name": "timing",
"label": "⏱️ Trigger: Timing (seconds)",
"options": {
"min": 0,
"step": 1
}
},
{
"default_value": "right",
"field_type": "dropdown",
"name": "slide_direction",
"label": "πŸ“ Position: Slide Direction",
"options": {
"choices": [
{
"value": "left",
"label": "Slide from Left"
},
{
"value": "right",
"label": "Slide from Right"
}
]
}
},
{
"default_value": "center",
"field_type": "dropdown",
"name": "slide_position",
"label": "πŸ“ Position: Vertical Placement",
"options": {
"choices": [
{
"value": "top",
"label": "Top of Page"
},
{
"value": "center",
"label": "Center of Page"
},
{
"value": "bottom",
"label": "Bottom of Page"
}
]
}
},
{
"default_value": "#000000",
"field_type": "color",
"name": "border_color",
"label": "πŸ–ΌοΈ Border: Color",
"options": {
"mode": "hex"
}
},
{
"default_value": "https://www.directv.com/assets/content/1oztwobana/web/Signature-3up-DSK-MBL.jpg?position=c&color=ffffffff&quality=80&u=pw0kir",
"field_type": "text",
"name": "image_url",
"label": "πŸ–ΌοΈ Image: URL (optional)",
"options": null
},
{
"default_value": "#F4F4F4",
"field_type": "color",
"name": "background_color",
"label": "🎨 Background: Color",
"options": {
"mode": "hex"
}
},
{
"default_value": "subheadline_headline",
"field_type": "dropdown",
"name": "text_format",
"label": "πŸ“ Text: Layout Format",
"options": {
"choices": [
{
"value": "headline",
"label": "Headline Only"
},
{
"value": "headline_subheadline",
"label": "Headline + Subheadline"
},
{
"value": "subheadline_headline",
"label": "Subheadline + Headline"
}
]
}
},
{
"default_value": "Your subheadline text here",
"field_type": "text",
"name": "subheadline_text",
"label": "πŸ“ Subheadline: Text",
"options": null
},
{
"default_value": "Arial, sans-serif",
"field_type": "text",
"name": "subheadline_font_family",
"label": "πŸ“ Subheadline: Font Family",
"options": null
},
{
"default_value": "#666666",
"field_type": "color",
"name": "subheadline_color",
"label": "πŸ“ Subheadline: Color",
"options": {
"mode": "hex"
}
},
{
"default_value": "14px",
"field_type": "text",
"name": "subheadline_font_size",
"label": "πŸ“ Subheadline: Font Size",
"options": null
},
{
"default_value": "center",
"field_type": "dropdown",
"name": "subheadline_alignment",
"label": "πŸ“ Subheadline: Alignment",
"options": {
"choices": [
{
"value": "left",
"label": "Left"
},
{
"value": "center",
"label": "Center"
},
{
"value": "right",
"label": "Right"
}
]
}
},
{
"default_value": "Global slideout",
"field_type": "text",
"name": "headline_text",
"label": "πŸ“ Headline: Text",
"options": null
},
{
"default_value": "Arial, sans-serif",
"field_type": "text",
"name": "headline_font_family",
"label": "πŸ“ Headline: Font Family",
"options": null
},
{
"default_value": "#000443",
"field_type": "color",
"name": "headline_color",
"label": "πŸ“ Headline: Color",
"options": {
"mode": "hex"
}
},
{
"default_value": "20px",
"field_type": "text",
"name": "headline_font_size",
"label": "πŸ“ Headline: Font Size",
"options": null
},
{
"default_value": "center",
"field_type": "dropdown",
"name": "headline_alignment",
"label": "πŸ“ Headline: Alignment",
"options": {
"choices": [
{
"value": "left",
"label": "Left"
},
{
"value": "center",
"label": "Center"
},
{
"value": "right",
"label": "Right"
}
]
}
},
{
"default_value": "Some body copy and details here",
"field_type": "multi_text",
"name": "body_text",
"label": "πŸ“ Body: Text",
"options": null
},
{
"default_value": "Arial, sans-serif",
"field_type": "text",
"name": "body_font_family",
"label": "πŸ“ Body: Font Family",
"options": null
},
{
"default_value": "#000443",
"field_type": "color",
"name": "body_color",
"label": "πŸ“ Body: Color",
"options": {
"mode": "hex"
}
},
{
"default_value": "20px",
"field_type": "text",
"name": "body_font_size",
"label": "πŸ“ Body: Font Size",
"options": null
},
{
"default_value": "center",
"field_type": "dropdown",
"name": "body_alignment",
"label": "πŸ“ Body: Alignment",
"options": {
"choices": [
{
"value": "left",
"label": "Left"
},
{
"value": "center",
"label": "Center"
},
{
"value": "right",
"label": "Right"
}
]
}
},
{
"default_value": "(Up to $87.98 w/ req'd fees; plus taxes. Price is for CHOICE package and is higher after first month.)",
"field_type": "multi_text",
"name": "legal_text",
"label": "πŸ“ Legal: Text",
"options": null
},
{
"default_value": "Arial, sans-serif",
"field_type": "text",
"name": "legal_font_family",
"label": "πŸ“ Legal: Font Family",
"options": null
},
{
"default_value": "#000443",
"field_type": "color",
"name": "legal_color",
"label": "πŸ“ Legal: Color",
"options": {
"mode": "hex"
}
},
{
"default_value": "14px",
"field_type": "text",
"name": "legal_font_size",
"label": "πŸ“ Legal: Font Size",
"options": null
},
{
"default_value": "left",
"field_type": "dropdown",
"name": "legal_alignment",
"label": "πŸ“ Legal: Alignment",
"options": {
"choices": [
{
"value": "left",
"label": "Left"
},
{
"value": "center",
"label": "Center"
},
{
"value": "right",
"label": "Right"
}
]
}
},
{
"default_value": "Claim offer",
"field_type": "text",
"name": "button_text",
"label": "πŸ”˜ Primary Button: Text",
"options": null
},
{
"default_value": "/pages/virtual",
"field_type": "text",
"name": "button_link",
"label": "πŸ”˜ Primary Button: Link URL",
"options": null
},
{
"default_value": "Arial, sans-serif",
"field_type": "text",
"name": "button_font_family",
"label": "πŸ”˜ Primary Button: Font Family",
"options": null
},
{
"default_value": "#FFFFFF",
"field_type": "color",
"name": "button_text_color",
"label": "πŸ”˜ Primary Button: Text Color",
"options": {
"mode": "hex"
}
},
{
"default_value": "14px",
"field_type": "text",
"name": "button_font_size",
"label": "πŸ”˜ Primary Button: Font Size",
"options": null
},
{
"default_value": "#006DFF",
"field_type": "color",
"name": "button_color",
"label": "πŸ”˜ Primary Button: Background Color",
"options": {
"mode": "hex"
}
},
{
"default_value": "No thanks",
"field_type": "text",
"name": "button2_text",
"label": "πŸ”˜ Secondary Button: Text",
"options": null
},
{
"default_value": "Arial, sans-serif",
"field_type": "text",
"name": "button2_font_family",
"label": "πŸ”˜ Secondary Button: Font Family",
"options": null
},
{
"default_value": "#333333",
"field_type": "color",
"name": "button2_text_color",
"label": "πŸ”˜ Secondary Button: Text Color",
"options": {
"mode": "hex"
}
},
{
"default_value": "14px",
"field_type": "text",
"name": "button2_font_size",
"label": "πŸ”˜ Secondary Button: Font Size",
"options": null
},
{
"default_value": "#FFFFFF",
"field_type": "color",
"name": "button2_color",
"label": "πŸ”˜ Secondary Button: Background Color",
"options": {
"mode": "hex"
}
},
{
"default_value": "#333333",
"field_type": "color",
"name": "button2_border_color",
"label": "πŸ”˜ Secondary Button: Border Color",
"options": {
"mode": "hex"
}
},
{
"default_value": "right",
"field_type": "dropdown",
"name": "button_alignment",
"label": "πŸ”˜ Button Layout: Alignment",
"options": {
"choices": [
{
"value": "left",
"label": "Left"
},
{
"value": "center",
"label": "Center"
},
{
"value": "right",
"label": "Right"
}
]
}
},
{
"default_value": "100px",
"field_type": "text",
"name": "button_width",
"label": "πŸ”˜ Button Layout: Width",
"options": null
},
{
"default_value": "36px",
"field_type": "text",
"name": "button_height",
"label": "πŸ”˜ Button Layout: Height",
"options": null
},
{
"default_value": "25px",
"field_type": "text",
"name": "button_border_radius",
"label": "πŸ”˜ Button Layout: Border Radius",
"options": null
},
{
"default_value": "12px",
"field_type": "text",
"name": "button_gap",
"label": "πŸ”˜ Button Layout: Gap Between Buttons",
"options": null
}
],
"description": "Customizable slideout modal with dynamic content and styling options",
"options": {
"html": "<div id=\"optimizely-slideout-{{ extension.$instance }}\" class=\"slideout-panel slideout-{{ extension.slide_direction }} slideout-pos-{{ extension.slide_position }}\" data-extension-instance=\"{{ extension.$instance }}\" style=\"border-color: {{ extension.border_color }};\">\n <span class=\"slideout-close\" data-instance=\"{{ extension.$instance }}\">&times;</span>\n \n <div class=\"slideout-content\" data-text-format=\"{{ extension.text_format }}\" style=\"background-color: {{ extension.background_color }};\">\n <div class=\"slideout-image-container\">\n <img src=\"{{ extension.image_url }}\" alt=\"Slideout Image\" class=\"slideout-image\" />\n </div>\n \n <div class=\"slideout-text-content\">\n <h2 class=\"slideout-subheadline\" style=\"font-family: {{ extension.subheadline_font_family }}; color: {{ extension.subheadline_color }}; font-size: {{ extension.subheadline_font_size }}; text-align: {{ extension.subheadline_alignment }};\">{{ extension.subheadline_text }}</h2>\n <h1 class=\"slideout-headline\" style=\"font-family: {{ extension.headline_font_family }}; color: {{ extension.headline_color }}; font-size: {{ extension.headline_font_size }}; text-align: {{ extension.headline_alignment }};\">{{ extension.headline_text }}</h1>\n <div class=\"slideout-body\" style=\"font-family: {{ extension.body_font_family }}; color: {{ extension.body_color }}; font-size: {{ extension.body_font_size }}; text-align: {{ extension.body_alignment }};\">{{{ extension.body_text }}}</div>\n </div>\n \n <div class=\"slideout-button-container\" style=\"gap: {{ extension.button_gap }};\">\n <a href=\"{{ extension.button_link }}\" class=\"slideout-button slideout-button-primary\" style=\"font-family: {{ extension.button_font_family }}; color: {{ extension.button_text_color }}; font-size: {{ extension.button_font_size }}; background-color: {{ extension.button_color }}; width: {{ extension.button_width }}; height: {{ extension.button_height }}; border-radius: {{ extension.button_border_radius }};\" data-instance=\"{{ extension.$instance }}\">{{ extension.button_text }}</a>\n <a href=\"#\" class=\"slideout-button slideout-button-secondary\" style=\"font-family: {{ extension.button2_font_family }}; color: {{ extension.button2_text_color }}; font-size: {{ extension.button2_font_size }}; background-color: {{ extension.button2_color }}; border: 1px solid {{ extension.button2_border_color }}; width: {{ extension.button_width }}; height: {{ extension.button_height }}; border-radius: {{ extension.button_border_radius }};\" data-instance=\"{{ extension.$instance }}\">{{ extension.button2_text }}</a>\n </div>\n \n <div class=\"slideout-legal\" style=\"font-family: {{ extension.legal_font_family }}; color: {{ extension.legal_color }}; font-size: {{ extension.legal_font_size }}; text-align: center;\">{{{ extension.legal_text }}}</div>\n </div>\n</div>",
"css": ".slideout-panel {\n position: fixed;\n width: 400px;\n max-width: 90vw;\n height: auto;\n max-height: 600px;\n z-index: 999999999;\n display: none;\n border: 2px solid;\n transition: all 0.5s ease-out;\n box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);\n}\n\n/* Slide from Right */\n.slideout-right {\n right: -420px;\n top: 50%;\n transform: translateY(-50%);\n}\n\n.slideout-right.slideout-pos-top {\n top: 20px;\n transform: translateY(0);\n}\n\n.slideout-right.slideout-pos-bottom {\n bottom: 20px;\n top: auto;\n transform: translateY(0);\n}\n\n.slideout-right.show {\n right: 20px;\n}\n\n/* Slide from Left */\n.slideout-left {\n left: -420px;\n top: 50%;\n transform: translateY(-50%);\n}\n\n.slideout-left.slideout-pos-top {\n top: 20px;\n transform: translateY(0);\n}\n\n.slideout-left.slideout-pos-bottom {\n bottom: 20px;\n top: auto;\n transform: translateY(0);\n}\n\n.slideout-left.show {\n left: 20px;\n}\n\n.slideout-content {\n position: relative;\n width: 100%;\n height: 100%;\n background-color: #F4F4F4;\n border-radius: 8px;\n padding: 15px;\n box-sizing: border-box;\n overflow-y: auto;\n}\n\n.slideout-close {\n position: absolute;\n top: 5px;\n right: 5px;\n font-size: 18px;\n font-weight: bold;\n color: #000;\n cursor: pointer;\n line-height: 1;\n transition: all 0.2s;\n z-index: 1000000000;\n background: rgba(255,255,255,0.9);\n border-radius: 50%;\n width: 22px;\n height: 22px;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 1px 3px rgba(0,0,0,0.3);\n}\n\n.slideout-close:hover {\n background: rgba(255,255,255,1);\n box-shadow: 0 2px 6px rgba(0,0,0,0.4);\n}\n\n.slideout-image-container {\n margin-bottom: 15px;\n text-align: center;\n}\n\n.slideout-image {\n max-width: 100%;\n height: auto;\n border-radius: 4px;\n}\n\n.slideout-text-content {\n margin-bottom: 20px;\n}\n\n.slideout-headline {\n margin: 0 0 10px 0;\n line-height: 1.2;\n font-weight: bold;\n}\n\n.slideout-subheadline {\n margin: 0 0 10px 0;\n line-height: 1.3;\n}\n\n.slideout-body {\n margin: 10px 0;\n line-height: 1.5;\n}\n\n.slideout-legal {\n margin: 15px 0 0 0;\n line-height: 1.3;\n font-size: 10px;\n text-align: center;\n}\n\n.slideout-button-container {\n margin: 20px 0 15px 0;\n text-align: center;\n display: flex;\n justify-content: center;\n}\n\n.slideout-button {\n display: flex;\n align-items: center;\n justify-content: center;\n text-decoration: none;\n border: none;\n cursor: pointer;\n font-weight: 500;\n transition: all 0.2s ease;\n text-align: center;\n white-space: nowrap;\n box-sizing: border-box;\n}\n\n.slideout-button-secondary {\n background-color: transparent !important;\n border: 1px solid !important;\n}\n\n.slideout-button:hover {\n opacity: 0.9;\n transform: translateY(-1px);\n}\n\n@media (max-width: 768px) {\n .slideout-panel {\n width: 320px;\n max-height: 80vh;\n }\n \n .slideout-content {\n padding: 15px;\n }\n \n .slideout-headline {\n font-size: 18px !important;\n }\n \n .slideout-subheadline {\n font-size: 16px !important;\n }\n \n .slideout-body {\n font-size: 14px !important;\n }\n\n .slideout-legal {\n font-size: 9px !important;\n }\n\n .slideout-right.show {\n right: 10px;\n }\n \n .slideout-left.show {\n left: 10px;\n }\n}",
"apply_js": "var utils = window.optimizely.get('utils');\n\nutils.waitForElement('body').then(function(element){\n var html = extension.$html;\n element.insertAdjacentHTML('afterbegin', html);\n \n // Apply dynamic styling\n var slideoutPanel = document.querySelector('#optimizely-slideout-' + extension.$instance);\n var content = slideoutPanel.querySelector('.slideout-content');\n \n if (content) {\n // Handle image display\n var imageContainer = slideoutPanel.querySelector('.slideout-image-container');\n if (!extension.image_url || extension.image_url.trim() === '') {\n if (imageContainer) imageContainer.style.display = 'none';\n }\n }\n \n // Simple cookie check like the sample\n if (document.cookie.indexOf(\"slideoutShown\") > -1 === false) {\n // Show the slideout after delay\n var delay = parseInt(extension.timing) * 1000 || 0;\n setTimeout(function() {\n slideoutPanel.style.display = \"block\";\n setTimeout(function() {\n slideoutPanel.classList.add('show');\n }, 50);\n }, delay);\n \n // Set up close button\n var closeBtn = slideoutPanel.querySelector('.slideout-close');\n if (closeBtn) {\n closeBtn.addEventListener('click', function(e) {\n e.preventDefault();\n slideoutPanel.classList.remove('show');\n setTimeout(function() {\n slideoutPanel.style.display = 'none';\n }, 500);\n \n // Set cookie to prevent showing again\n document.cookie = 'slideoutShown=true; path=/; max-age=' + (24 * 60 * 60);\n \n // Track event\n window['optimizely'] = window['optimizely'] || [];\n window['optimizely'].push({\n type: \"event\",\n eventName: \"slideout_closed\"\n });\n });\n }\n \n // Track button clicks\n var primaryButton = slideoutPanel.querySelector('.slideout-button-primary');\n var secondaryButton = slideoutPanel.querySelector('.slideout-button-secondary');\n \n if (primaryButton) {\n primaryButton.addEventListener('click', function() {\n window['optimizely'] = window['optimizely'] || [];\n window['optimizely'].push({\n type: \"event\",\n eventName: \"slideout_primary_button_clicked\"\n });\n });\n }\n \n if (secondaryButton) {\n secondaryButton.addEventListener('click', function(e) {\n e.preventDefault();\n // Close slideout on secondary button click\n slideoutPanel.classList.remove('show');\n setTimeout(function() {\n slideoutPanel.style.display = 'none';\n }, 500);\n \n // Set cookie to prevent showing again\n document.cookie = 'slideoutShown=true; path=/; max-age=' + (24 * 60 * 60);\n \n window['optimizely'] = window['optimizely'] || [];\n window['optimizely'].push({\n type: \"event\",\n eventName: \"slideout_secondary_button_clicked\"\n });\n });\n }\n }\n});",
"undo_js": "// Remove slideout\nvar slideoutElement = document.querySelector('#optimizely-slideout-' + extension.$instance);\nif (slideoutElement) {\n slideoutElement.remove();\n}\n\n// Clear any timeouts or intervals related to this instance\nvar timers = window.optimizelySlideoutTimers || {};\nif (timers[extension.$instance]) {\n clearTimeout(timers[extension.$instance]);\n delete timers[extension.$instance];\n}\n\n// Remove event listeners (they'll be removed with the element)\n// Reset any modified styles or state if necessary"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment