You are here

function popup_onload_prepare_popup in Popup On Load 7

Same name and namespace in other branches
  1. 8 popup_onload.module \popup_onload_prepare_popup()

Generate Javascript parameters for popup.

Parameters

object $popup_onload: Fully populated popup_onload entity.

Return value

array Popup javascript settings

2 calls to popup_onload_prepare_popup()
popup_onload_action_display_popup in ./popup_onload.rules.inc
Action to display a popup.
popup_onload_init in ./popup_onload.module
Implements hook_init().

File

./popup_onload.module, line 190
Contains main popup_onload hooks and functions.

Code

function popup_onload_prepare_popup($popup_onload) {
  $popup_markup = entity_view('popup_onload', [
    $popup_onload->popup_id => $popup_onload,
  ], 'full', NULL, TRUE);
  $overlay_close = TRUE;
  if (isset($popup_onload->field_overlayclose)) {
    $overlay_close = $popup_onload->field_overlayclose['und'][0]['value'] == 1 ? TRUE : FALSE;
  }
  $popup_settings = [
    'html' => drupal_render($popup_markup['popup_onload']),
    'delay' => variable_get(POPUP_ONLOAD_VAR_DISPLAY_DELAY, POPUP_ONLOAD_DEFAULT_DELAY),
    'fixed' => (bool) $popup_onload->fixed_position,
    'popup_id' => $popup_onload->popup_id,
    'className' => 'popup_onload',
    'overlayClose' => $overlay_close,
    'close' => '',
  ];
  if ($popup_onload->width) {
    $popup_settings['innerWidth'] = $popup_onload->width;
  }
  if ($popup_onload->height) {
    $popup_settings['innerHeight'] = $popup_onload->height;
  }

  // Let other modules alter popup settings.
  drupal_alter('popup_onload_js_settings', $popup_settings, $popup_onload);
  return $popup_settings;
}