UGC Techdocs
  • Introduction
  • Guides
    • Analytics
      • Tracking UGC on Adobe Analytics
      • Tracking Widget interactions with Google Analytics
    • Direct Uploader
      • How to add Custom Data to Direct Uploader
      • How to capture Custom Data on Direct Uploader
      • How to automatically tag data on Direct Uploader
      • How to Customize error messages on Direct Uploader
      • How to Track Direct Uploader form submissions with Google Analytics (Universal & GA 4)
    • Data Templates
      • Creating a Data Template
    • Rights via Registration
      • Capture Custom Data on Rights by Registration Form
      • Styling Rights via Registration Form
    • REST API
      • Caching REST API results for optimization
      • Posting content into Nosto via Tile API
      • Posting images into Nosto via Tile API
    • Onsite Widgets (2.0)
      • Blank Canvas
        • How to Use the Blank Canvas to Create a Twitter Count Widget
        • Creating an Auto-Scrolling Carousel using Blank Canvas
        • Creating Gallery Widget by Using the Blank Canvas Widget
        • Creating a simple Hover effect using Blank Canvas
        • Creating a Word Cloud using Blank Canvas
        • Creating Your Widget by Using the Blank Canvas
      • Bind your own Events
      • Creating a Grid Widget from Waterfall
      • Create a Q&A Widget using Data Templates
      • Displaying a Widget in a Mobile App
      • Dynamically Specify Products to Display in Widget
      • Dynamically specify what Tile to display in a Widget
      • How to add a title / subtitle to a widget
      • How to localize the load more button on widgets
      • How to overlay existing Google Map with the UGC Map Widget
      • Styling cross-sellers on Grid and Carousel Widgets
      • How to Load External JS and CSS into Widgets
      • Profiling Widget Performance
      • Re-targeting with Widgets and Facebook Pixel
      • Render Widget filters dynamically
      • Styling Carousel Widget
      • Styling Grid Widget
      • Styling Masonry Widget
      • Styling Waterfall Widget
      • Styling Widget Expanded Tile
      • Styling Widget Shopspots
      • Using Web Fonts in Widgets
    • Digital Screens
      • Customizing Carousel Event Screen
      • Customizing Mosaic Event Screen
      • Customizing Scrollwall Event Screen
      • Customizing the Mosaic Event Screen to Have 9 Even Tiles
    • Email
      • Adding Location to an Email Tile
      • Styling the Email Widget
    • Integrations
      • DoubleClick
        • UGC Ads with Nosto and Google DoubleClick
      • Zapier
        • Consuming UGC Webhooks via Zapier
      • Mailchimp
        • Bring Social Content into a Mailchimp Campaign
    • Webhooks
      • Trigger notifications when content is in the moderation queue
  • Widgets
  • API Docs
    • JavaScript API
      • Widgets
        • Introduction
        • API Reference for Content Widgets
        • API Reference for Blank Canvas
        • API Reference for Map Widget
      • Digital Screens
        • Introduction
        • API Reference
    • Content API
      • Reference
    • REST API
      • Reference
        • Filters API
        • Moderation Views API
        • Tags API
        • Terms API
        • Tiles API
        • Users API
        • Widgets API
        • Automation Rules API
        • REST API Reference Widgets style and config
      • Best Practices
    • Webhooks
  • Enterprise Tools
    • Automation Rules
      • Triggers
      • Actions
      • Samples
    • Data Templates
    • User Access Control (UAC)
    • Single Sign On (SSO)
    • Enterprise Admin User Interface (EAUI)
    • Zapier
  • Commerce Tools
    • Product Feeds
    • Widget Implementation
    • Reporting
    • Integrations
      • Google Tag Manager
      • Magento
      • SalesForce Commerce Cloud
      • Shopify
      • Shopify Add To Cart
        • Global Variant Mapping for Add to Cart
        • Customise Add to Cart Widget Experience
  • Analytics
    • Google Analytics 4
      • Getting Started
      • Widgets Events
      • E-commerce Events
      • Email Events
  • Terms of Use
Powered by GitBook
On this page
  • Debugging Mode
  • Via URL Parameter
  • Via Global Variable
  • Use the Code Editor
  • Fork from Nosto's UGC
  • Customize Inline Tiles
  • Boilerplate
  • Available JavaScript Libraries
  • Customize Expanded Tile
  • Boilerplate
  • Available JavaScript Libraries
  • Create Your Widget - Blank Canvas
  • Boilerplate

Was this helpful?

  1. API Docs
  2. JavaScript API
  3. Widgets

Introduction

PreviousWidgetsNextAPI Reference for Content Widgets

Last updated 1 year ago

Was this helpful?

Debugging Mode

Sometimes it’s easier for you, as a developer, to investigate Custom JavaScript issues by viewing the widgets through the Debugging Mode in your browser. Our developers add debugging logs for almost all methods that widgets execute. You can view these logs in your Developer Console using the following methods.

Via URL Parameter

You can enable it by simply adding ?debug=1 as an extra URL parameter.

Via Global Variable

Or you can enable it by adding the following JavaScript global variable. You must place it before the widget embed code.

<script>window.Stackla = {debug: true};</script>

|

Use the Code Editor

Fork from Nosto's UGC

You can now also click the fork link at the top-right corner of each editor pane. This brings the boilerplate code from the Nosto's UGC codebase so that you don't need to write from scratch or copy & paste from our Developer Portal.

Customize Inline Tiles

All inline tiles reside in an Iframe with the widgetapp.stackla.com URL. You can't just write JavaScript on your website to access it because of browser security restrictions. The only way to access it is via our Code Editor.

Boilerplate

$.extend(Callbacks.prototype, {
    onCompleteJsonToHtml: function (tileObject, t) {
        return tileObject;
    },
    onCompleteRenderImage: function(img) {

    },
    // tiles is a jQuery array object, use tiles. each when traversing
    onCompleteAddingToDom: function (tiles) {
    },
    //Call first, before render/window resize
    onBeforeRenderIsotope: function (containerWidth, maxTileWidth, margin, numColumns, currentTileWidth) {
        //Can be used to handle break-points for responsiveness, for example:
        /*
        if (containerWidth > 900) {
            var columns = 6;
            return {
                tileWidth: Math.floor(((containerWidth - margin) / columns) - margin);
                numColumns: columns
            }
        } else {
            var columns = 3;
            return {
                tileWidth: Math.floor(((containerWidth - margin) / columns) - margin);
                numColumns: columns
            }
        }
        */

        // return tile width, the isotope will be init as tile width + margin
        return {
            tileWidth: currentTileWidth,
            numColumns: numColumns
        }
    },
    // call second, before each tile width and height is set
    getTileWidth: function (tile, tileWidth, margin, numColumns) {
        // return tile width
        return tileWidth;
    },
    //Call third, after tile width and height are set
    onCalculateDimensions: function (tile) {

    },
    // After the filtering changed
    onCompleteChangeFilter: function (tiles, prevFilterId, nextFilterId) {

    },
    // Before more tiles are rendered
    onBeforeRenderTiles: function (addedIds, addedData) {

    },
    // After more tiles are rendered
    onCompleteRenderTiles: function ($addedTiles, addedData) {

    },
    // Triggers when it's the end of the scrolling
    onScrollLoad: function (tiles, jsLoading) {

    },
    // Triggers when it's the end of the scrolling
    onScrollEnd: function (tiles, jsLoading) {

    },
    // Triggers when the parent page triggers a customized postMessage
    onMessage: function (type, data) {

    }
});
//======================
// Customisable Strings
//======================
Strings.load_more = 'Load more content';
Strings.scroll_load = 'Loading...';
Strings.scroll_end = 'There is no more content to be displayed.';

Available JavaScript Libraries

  • jQuery: You can access it by using the $ global variable. The current version is 1.7.1.

  • lodash: You can access it by using _ global variable. The current version is 3.10.1.

  • Mustache.js: You can access it by using the Mustache global variable. The current version is 0.8.1.

  • CryptoJS: You can access it by using CryptoJS global variable. The current version is 3.1.2.

Customize Expanded Tile

We would recommend the use of our Expanded Tile Code Editor when customizing your Expanded Tiles. However, as the Widget Expanded Tiles are rendered in their parent page, you can also customize them by adding JavaScript to your parent page HTML.

Boilerplate

// Events
Stackla.WidgetManager
    .on('tileExpand', function (e, data) {
        console.log(e.type, data.expandType,  data.tileData,  data.widgetId);
    })
    .on('beforeExpandedTileOpen', function (e, data) {
        console.log(e.type, data.el, data.tileData,  data.widgetId);
    })
    .on('expandedTileImageLoad', function (e, data) {
        console.log(e.type, data.el, data.tileEl, data.widgetId);
    })
    .on('beforeExpandedTileImageResize', function (e, data) {
        console.log(e.type, data.sizes, data.el, data.tileEl, data.widgetId);
    })
    .on('expandedTileOpen', function (e, data) {
        console.log(e.type, data.el, data.tileData,  data.widgetId);
    })
    .on('expandedTileImageResize', function (e, data) {
        console.log(e.type, data.sizes, data.el, data.tileEl, data.widgetId);
    })
    .on('userClick', function (e, data) {
        console.log(e.type, data.tileData, data.widgetId);
    })
    .on('shareClick', function (e, data) {
        console.log(e.type, data.shareNetwok, data.tileData, data.widgetId);
    })
    .on('moreLoad', function (e, data) {
        console.log(e.type, data.page, data.widgetId);
    })
    .on('shopspotFlyoutShow', function (e, data) {
        console.log(e.type, data.productTag, data.tileData, data.widgetId);
    })
    .on('shopspotActionClick', function (e, data) {
        console.log(e.type, data.productTag, data.tileData, data.widgetId);
    });

// Callbacks
var widgetId = '-1'; // TODO - Change to your widget ID.
window.StacklaFluidWidgetProperties = {};
window.StacklaFluidWidgetProperties[widgetId] = {
    callbacks: {
        'onAfterWidgetLoaded': function () {
            console.log('onAfterWidgetLoaded');
        },
        'onBeforeExpandedTileOpen': function (tile, data) {
            console.log('onBeforeExpandedTileOpen');
            return tile;
        },
        'onAfterExpandedTileOpen': function () {
            console.log('onAfterExpandedTileOpen');
        },
        'onBeforeExpandedTileImageResize': function () {
            console.log('onBeforeExpandedTileImageResize');
        },
        'onAfterExpandedTileImageResize': function () {
            console.log('onAfterExpandedTileImageResize');
        },
        'onAfterExpandedTileImageLoad': function () {
            console.log('onAfterExpandedTileImageLoad');
        }
    }
};

// Methods
// Stackla.WidgetManager.postMessage(typeName, data, [widgetId])
// Stackla.WidgetManager.sync();
// Stackla.WidgetManager.search(widgetId, keyword);
// Stackla.WidgetManager.changeFilter(widgetId, filterId);

Available JavaScript Libraries

  • jQuery: You can access it by using the $tackla global variable. The version is 1.10.2.

Create Your Widget - Blank Canvas

We provide a Blank Canvas widget so that you can build your widget when you find that the current UGC Widgets don't fit your customization needs.

Boilerplate

To quickly get started with the Blank Canvas widget customizations, you can copy and paste the following code into the Custom Code Editor in Nosto's UGC.

Custom Layout

<div class="track">
    <div class="container">
        {{#tiles}}
            {{>tpl-tile}}
        {{/tiles}}
    </div>
</div>

Custom Tile (#tpl-tile)

<div class="tile">
    <div class="hd">#{{id}}</div>
    <div class="bd">{{message}}</div>
    {{#image}}
    <div class="ft">
        <img src="{{image}}" width="120"/>
    </div>
    {{/image}}
</div>

Custom JavaScript

// Load tiles data from selected filter
Stackla.loadTilesByFilter(function (tiles) {
    // Render the layout template
    Stackla.render({tiles: tiles});
});

Custom CSS

@import url(https://fonts.googleapis.com/css?family=Open+Sans);
body {
    background: #ccc;
    padding: 10px 0 0 10px;
    font-family: 'Open Sans', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
.tile {
    background: #fff;
    border: solid 1px #ccc;
    color: #666;
    font-size: 13px;
    padding: 10px;
    margin-right: 10px;
    margin-bottom: 10px;
    .hd {
        margin-bottom: 10px;
    }
    .bd {
        color: #333;
        font-size: 16px;
    }
}

You can use the Code Editor to modify both your Custom CSS, HTML and JavaScript. The CSS editor supports . That means you can use both traditional CSS syntax and the better LESS syntax.

To quickly get started with Custom Expanded Tile JavaScript, you can or copy & paste the following code into the editor.

For more information, please check the documentation.

To quickly get started with Custom Expanded Tile JavaScript, you can or copy and paste the following code into the editor.

For more information, please check the and documentation.

For more information, please check the documentation.

LESS CSS pre-processor
Widget Inline Tile JavaScript API
Blank Canvas JavaScript API
fork
Back to Top
Back to Top
fork
Back to Top
Back to Top
Back to Top
Open in JSBin
Debugging Mode
Use the Code Editor
Customize Inline Tile
Customize Expanded Tile
Create Your Widget - Blank Canvas
Back to Top
How to use "Filter and search" in Widget
Widget Expanded Tile JavaScript API