You are here

function simple_dialog_attach_js in Simple Dialog 8

Adds the necessary js and libraries to make the dialog work. Really just adds the jquery.ui library and the simple dialog javscript file but if we need to add anything else down the road, at least it's abstracted into an api function

Parameters

array $element: The renderable array element to #attach the js to

boolean $every_page: Optional variable to specify the simple dialog code should be added to every page. Defaults to false. If you're calling this function, you likely will not need to change this as the module has settings to specify adding the js on every page

1 call to simple_dialog_attach_js()
simple_dialog_page_build in ./simple_dialog.module
Implements hook_page_build()

File

./simple_dialog.module, line 221

Code

function simple_dialog_attach_js(&$element, $every_page = FALSE) {
  $element['#attached']['library'][] = 'system/ui.dialog';
  $element['#attached']['js'][] = array(
    'data' => array(
      'simpleDialog' => array(
        'classes' => \Drupal::config('simple_dialog.settings')
          ->get('classes'),
        'defaults' => array(
          'settings' => \Drupal::config('simple_dialog.settings')
            ->get('defaults.settings'),
          'target_selector' => \Drupal::config('simple_dialog.settings')
            ->get('defaults.target_selector'),
          'title' => \Drupal::config('simple_dialog.settings')
            ->get('defaults.title'),
        ),
      ),
    ),
    'type' => 'setting',
  );
  $element['#attached']['js'][drupal_get_path('module', 'simple_dialog') . '/js/simple_dialog.js'] = array(
    'every_page' => $every_page,
  );
}