XF 2.1 Data-storage-type - cookie

Russ

Well-known member
Just curious but are you able to set a custom expiration on the cookie when using something along the lines of:

Code:
data-xf-init="toggle-storage" data-storage-type="cookie"

Using a data-* attribute?
 
Nope, it is hard-coded to ~4 hours. It wouldn't be hard to extend with something like;

Code:
var SV = window.SV || {};

(function ($, window, document, _undefined)
{
    "use strict";

    SV.ToggleStorage = XF.extend(XF.ToggleStorage, {
        updateStorage: function()
        {
            var options = this.options;

            XF.ToggleStorageData.set(
                options.storageContainer,
                options.storageKey,
                this.$target.hasClass(options.activeClass),
                this.$target.data('storage-expiry)
            );
        }
    });

    XF.Click.register('my-toggle-storage', 'SV.ToggleStorage');
}) (jQuery, window, document);

(Note uses this.$target.data() to avoid re-defining the options property)
 
Top Bottom