You are here

function _tipsy_get_settings in Tipsy 7

Same name and namespace in other branches
  1. 8 tipsy.module \_tipsy_get_settings()

Helper function to retrieve all settings for tipsy.

3 calls to _tipsy_get_settings()
tipsy_admin in ./tipsy.admin.inc
Implementation of tipsy admin form.
tipsy_library in ./tipsy.module
Implements hook_library().
tipsy_options_form in ./tipsy.admin.inc
Implementation of form function for the tooltip options.

File

./tipsy.module, line 89

Code

function _tipsy_get_settings($new_rule = FALSE) {
  if ($new_rule == TRUE) {
    $settings = array(
      'selector' => '',
      'options' => array(
        'fade' => 1,
        'gravity' => 'w',
        'delayIn' => 0,
        'delayOut' => 0,
        'trigger' => 'hover',
        'opacity' => '0.8',
        'offset' => 0,
        'html' => 0,
        'tooltip_content' => array(
          'source' => 'attribute',
          'selector' => 'title',
        ),
      ),
    );
  }
  else {
    $wide_settings = array(
      'drupal_forms' => array(
        'forms' => FALSE,
        'options' => array(
          'fade' => 1,
          'gravity' => 'autoWE',
          'delayIn' => 0,
          'delayOut' => 0,
          'trigger' => 'focus',
          'opacity' => '0.8',
          'offset' => 0,
        ),
      ),
      'custom_selectors' => array(
        0 => array(
          'selector' => '.tipsy',
          'options' => array(
            'fade' => 1,
            'gravity' => 'w',
            'delayIn' => 0,
            'delayOut' => 0,
            'trigger' => 'hover',
            'opacity' => '0.8',
            'offset' => 0,
            'html' => 0,
            'tooltip_content' => array(
              'source' => 'attribute',
              'selector' => 'title',
            ),
          ),
        ),
      ),
    );
    $settings = variable_get('tipsy', $wide_settings);

    // Convert settings for tipsy older than 7.x-1.0-beta2.
    $converted_settings = FALSE;
    foreach ($settings['custom_selectors'] as &$selector) {
      if (isset($selector['options']['title'])) {
        $selector['options']['tooltip_content']['source'] = 'attribute';
        $selector['options']['tooltip_content']['selector'] = $selector['options']['title'];
        unset($selector['options']['title']);
        $converted_settings = TRUE;
      }
    }
    if ($converted_settings) {
      variable_set('tipsy', $settings);
    }
  }
  return $settings;
}