Skip to content

Popup Maker JavaScript & jQuery API

Daniel L. Iser edited this page Feb 17, 2021 · 3 revisions

General Information

Each popup is initialized separately already during page load. The following methods are used by using the popups id for the selector. All examples use ID #123.

Global Functions

PUM.getPopup: function (el)

Returns a valid popup even if you pass in a child of that popup.

PUM.getPopup(123); // Returns the popup with ID #123.
PUM.getPopup('#pum-123'); // Returns popup with ID 123.
PUM.getPopup('#my-popup-form'); // Returns the parent popup of your form, or false if the form isn't in a popup.

PUM.open: function (el, callback)

Will open a popup with an ID # of 123.

PUM.open(123)

PUM.close: function (el, callback)

Will close a popup with an ID # of 123.

PUM.close(123)

PUM.clearcookies: function (el)

Clears any Cookies attached to the popup with an ID # of 123.

PUM.clearCookies(123)

PUM.preventOpen: function (el)

Used to prevent any further attempts of a particular popup to open for the current page load.

PUM.preventOpen(123)

PUM.getSettings: function (el)

Get a JavaScript object containing the given popup's settings.

PUM.getSettings(123)

PUM.getSetting: function (el, key, _default)

Get a setting for specified popup by key. Optionally provide a default value.

PUM.getSetting(123, 'location', 'bottom center')

PUM.checkConditions: function (el)

Returns true or false based on popups targeting conditions.

PUM.checkConditions(123)

PUM.getCookie: function (cookie_name)

Get a cookie by name.

PUM.getCookie('pum-123')

PUM.setCookie: function (el, settings)

Set a cookie by name with optional expiration and path.

  • Expiration uses PHP strtotime format prefixed by +.
PUM.setCookie(123, {expires: "+1 week", path: "/"})

PUM.clearCookie: function (cookie_name, callback)

Clear a cookie by name with an optional callback.

PUM.clearCookie('pum-123')

PUM.clearCookies: function (el, callback)

Clear all cookies for a given popup.

PUM.clearCookies(123)

PUM.getClickTriggerSelector: function (el, trigger_settings)

Returns a valid CSS click trigger selector for all of popup #123's click triggers.

PUM.getClickTriggerSelector(123, {extra_selectors: '#custom-selector'}) // 

PUM.disableClickTriggers: function (el, trigger_settings)

Disables all click triggers for a given popup, with optional extra CSS selectors.

PUM.disableClickTriggers(123, {extra_selectors: '#custom-selector'}) // 

jQuery Methods

open

Open a popup, with an optional callback function.

jQuery('#pum-123').popmake('open', callback);

close

Close a popup

jQuery('#pum-123').popmake('close');

reposition

Reposition a popup to its starting location in the window, with an optional callback function.

jQuery('#pum-123').popmake('reposition', callback);

retheme

Retheme a popup, with an optional theme argument override.

jQuery('#pum-123').popmake('retheme', theme);

animate

Animate a popup with style and optional callback.

jQuery('#pum-123').popmake('animate', style, callback);

Access Settings

All of a popup's public settings are stored in the pum_vars.popups global, organized by ID. data-popmake attribute.

// Get the settings from our global API.
PUM.getSettings(123);

// Get specific settings from global API.
PUM.getSetting(123, 'triggers', []);

All admin settings are stored in the snake_case format, such as position_left.

// The id of the popup. Useful for checking if a certain popup is loading to attach settings.
settings.id

settings.slug

Events

pumInit

Runs when the popups are first initialized. Useful for checking settings and adding extra functionality runs just after document.ready.

pumBeforeOpen

Runs just before the popup is shown.

pumAfterOpen

Runs just after the popup is shown.

pumBeforeClose

Runs just before the popup is closed.

pumAfterClose

Runs just after the popup is closed.

pumBeforeReposition

Runs before repositioning the popup. Useful to change the position settings before it is moved.

Properties

last_open_trigger

Contains either reference to the original click trigger or a string of settings for the trigger used.

jQuery.fn.popmake.last_open_trigger;


// Use something like try {} catch (Error); In case the selector is from Auto Open for instance.
try {
     trigger = $($.fn.popmake.last_open_trigger);
} catch (Error);