You are here

function mathjax_global_settings in MathJax: LaTeX for Drupal 7.2

Same name and namespace in other branches
  1. 6 mathjax.module \mathjax_global_settings()
  2. 7 mathjax.module \mathjax_global_settings()

Configure global settings for MathJax.

1 string reference to 'mathjax_global_settings'
mathjax_menu in ./mathjax.module
Implements hook_menu().

File

./mathjax.module, line 160
MathJax module.

Code

function mathjax_global_settings() {
  $form['mathjax']['mathjax_test'] = array(
    '#type' => 'fieldset',
    '#title' => 'MathJax Test',
  );
  $form['mathjax']['mathjax_test']['markup'] = array(
    '#type' => 'item',
    '#markup' => '<div class="tex2jax"><p>If the MathJax library is installed properly, you should see the square root of x here: $ \\sqrt{x} $ and the square root of y here: \\(\\sqrt{y}\\)</p><p>$$\\text{The quadratic formula should appear here: } x = \\frac {-b \\pm \\sqrt {b^2 - 4ac}}{2a}$$</p><p>\\[\\text{The cubic equation should appear here: } a x^3\\; +\\; b x^2\\; +\\; c x\\; +\\; d\\; =\\; 0\\]</p></div>',
  );
  $form['mathjax']['mathjax_use_cdn'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use MathJax Content Delivery Network (CDN)'),
    '#default_value' => variable_get('mathjax_use_cdn', TRUE),
    '#description' => t('Check this box to load MathJax source from MathJax servers (recommended) or from the link you can provide below. If you do not check this box, see the README about configuring a local MathJax source with the libraries module.'),
  );
  $form['mathjax']['mathjax_cdn_url'] = array(
    '#type' => 'textfield',
    '#title' => t('MathJax CDN URL'),
    '#default_value' => variable_get('mathjax_cdn_url', mathjax_default('cdn url')),
    '#description' => t("Enter the Mathjax CDN url here or leave it unchanged to use the one provided by <a target='_blank' href='@mathjax-homepage'>www.mathjax.org</a>.", array(
      '@mathjax-homepage' => url('http://www.mathjax.org'),
    )),
    '#states' => array(
      'invisible' => array(
        ':input[name="mathjax_use_cdn"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form['mathjax']['mathjax_config_type'] = array(
    '#type' => 'radios',
    '#title' => t('Configuration Type'),
    '#options' => array(
      0 => t('Text Format (Recommended&mdash;Add the MathJax filter to a <a href="@textformats">text format</a>.)', array(
        '@textformats' => url('admin/config/content/formats'),
      )),
      1 => t('Custom'),
    ),
    '#default_value' => variable_get('mathjax_config_type', 0),
  );
  $form['mathjax']['mathjax_note_default'] = array(
    '#type' => 'item',
    '#prefix' => '<span class="tex2jax_ignore">',
    '#markup' => t('MathJax
      will be available as a text filter. Mathematics inside the
      default delimiters will be rendered by MathJax. The
      default math delimiters are $$...$$ and \\[...\\] for displayed mathematics,
      and $...$ and \\(...\\) for in-line mathematics. <strong>You must add
      the MathJax filter to a <a href="@textformats">text format</a> and put
      MathJax at the bottom of the filter processing order.</strong>', array(
      '@textformats' => url('admin/config/content/formats'),
    )),
    '#suffix' => '</span>',
    '#states' => array(
      'invisible' => array(
        ':input[name="mathjax_config_type"]' => array(
          'value' => 1,
        ),
      ),
    ),
  );
  $form['mathjax']['mathjax_config_string'] = array(
    '#type' => 'textarea',
    '#title' => t('Custom configuration'),
    '#default_value' => variable_get('mathjax_config_string', mathjax_default('config string')),
    '#description' => t("Enter a JavaScript configuration string as documented on  <a target='_blank' href='@mathjax-help'>MathJax help</a>. Use with caution as you may introduce JavaScript errors.", array(
      '@mathjax-help' => url('http://docs.mathjax.org/en/latest/'),
    )),
    '#states' => array(
      'invisible' => array(
        ':input[name="mathjax_config_type"]' => array(
          'value' => 0,
        ),
      ),
    ),
  );
  return system_settings_form($form);
}