itoggle.admin.inc in iToggle 7
iToggle Admin config pages.
File
includes/itoggle.admin.incView source
<?php
/**
* @file
* iToggle Admin config pages.
*/
function itoggle_form_admin() {
$form = array();
$itoggle_path = itoggle_get_path();
$form['itoggle']['basic'] = array(
'#type' => 'fieldset',
'#title' => t('Basic Settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['itoggle']['basic']['itoggle_path'] = array(
'#type' => 'textfield',
'#title' => t('Path'),
'#default_value' => $itoggle_path,
'#description' => t('The location where iToggle plugin is installed. Relative paths are from the Drupal root directory.'),
'#after_build' => array(
'_itoggle_admin_check_plugin_path',
),
);
$form['itoggle']['basic']['itoggle_compression_type'] = array(
'#type' => 'radios',
'#title' => t('Choose iToggle compression level'),
'#options' => array(
'min' => t('Production (Minified)'),
'none' => t('Development (Uncompressed Code)'),
),
'#default_value' => variable_get_value('itoggle_compression_type'),
);
$form['itoggle']['basic']['itoggle_css'] = array(
'#type' => 'checkbox',
'#title' => t('Include Default CSS'),
'#description' => t('Uncheck this if you want to include your own styles for iToggle.'),
'#default_value' => variable_get_value('itoggle_css'),
);
$form['itoggle']['basic']['itoggle_easing'] = array(
'#type' => 'textfield',
'#title' => t('Easing'),
'#description' => t('If you installed the <a href="@link">Easing</a> jQuery plugin you can specify an easing function for iToggle here. Warning, if Easing is not installed properly, this will break things!', array(
'@link' => 'http://gsgd.co.uk/sandbox/jquery/easing/',
)),
'#default_value' => variable_get_value('itoggle_easing'),
);
$form['itoggle']['basic']['itoggle_speed'] = array(
'#type' => 'textfield',
'#size' => 6,
'#title' => t('Speed'),
'#description' => t('iToggle animation speed, in milliseconds. Default is 200.'),
'#default_value' => variable_get_value('itoggle_speed'),
);
$form['advanced'] = array(
'#title' => t('Advanced Settings'),
'#type' => 'fieldset',
'#description' => '<p>' . t('For a full description of all iToggle callbacks, see the <a href="@link">documentation</a>.', array(
'@link' => 'http://labs.engageinteractive.co.uk/itoggle/',
)) . '</p>',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['advanced']['note'] = array(
'#markup' => '<strong>' . t('Important') . '</strong><p>' . t("All of these callbacks are automatically wrapped in a closure, so you do don't need to specify it, just enter the code directly.") . '</p>',
);
$form['advanced']['example'] = array(
'#markup' => '<p>' . t('For example') . ':</p><code>alert("onclick");</code></p>',
);
$form['advanced']['warning'] = array(
'#markup' => '<strong>' . t('Warning') . '</strong><p>' . t('The callbacks are called using eval(), yes, we hate it too so please be careful!') . '</p>',
);
$form['advanced']['advanced_confirm'] = array(
'#type' => 'checkbox',
'#title' => t('I confirm that I have read the above warnings and wish to configure callbacks for iToggle'),
'#default_value' => FALSE,
);
$form['advanced']['container'] = array(
'#type' => 'container',
'#states' => array(
'invisible' => array(
'input[name="advanced_confirm"]' => array(
'checked' => FALSE,
),
),
),
);
$form['advanced']['container']['itoggle_onclick'] = array(
'#title' => t('OnClick callback'),
'#type' => 'textarea',
'#description' => t('Specify an OnClick callback for iToggle.'),
'#default_value' => variable_get_value('itoggle_onclick'),
);
$form['advanced']['container']['itoggle_onclickon'] = array(
'#title' => t('OnClickOn callback'),
'#type' => 'textarea',
'#description' => t('Specify an OnClickOn callback for iToggle.'),
'#default_value' => variable_get_value('itoggle_onclickon'),
);
$form['advanced']['container']['itoggle_onclickoff'] = array(
'#title' => t('OnClickOff callback'),
'#type' => 'textarea',
'#description' => t('Specify an OnClickOff callback for iToggle.'),
'#default_value' => variable_get_value('itoggle_onclickoff'),
);
$form['advanced']['container']['itoggle_onslide'] = array(
'#title' => t('OnSlide callback'),
'#type' => 'textarea',
'#description' => t('Specify an OnSlide callback for iToggle.'),
'#default_value' => variable_get_value('itoggle_onslide'),
);
$form['advanced']['container']['itoggle_onslideon'] = array(
'#title' => t('OnSlideOn callback'),
'#type' => 'textarea',
'#description' => t('Specify an OnSlideOn callback for iToggle.'),
'#default_value' => variable_get_value('itoggle_onslideon'),
);
$form['advanced']['container']['itoggle_onslideoff'] = array(
'#title' => t('OnSlideOff callback'),
'#type' => 'textarea',
'#description' => t('Specify an OnSlideOff callback for iToggle.'),
'#default_value' => variable_get_value('itoggle_onslideoff'),
);
return system_settings_form($form);
}
/**
* Checks if the directory in $form_element exists and contains a file named
* 'engage.itoggle.js'. If validation fails, the form element is flagged
* with an error from within the file_check_directory function.
*
* This was borrowed from the Colorbox module
*
* @param $form_element
* The form element containing the name of the directory to check.
* @link http://drupal.org/project/colorbox
*/
function _itoggle_admin_check_plugin_path($form_element) {
$library_path = $form_element['#value'];
if (!is_dir($library_path) || !(file_exists($library_path . '/engage.itoggle.js') && file_exists($library_path . '/engage.itoggle-min.js'))) {
form_set_error($form_element['#parents'][0], t('You need to download the !itoggle and extract the entire contents of the archive into the %path folder of your server.', array(
'!itoggle' => l(t('iToggle plugin'), 'http://labs.engageinteractive.co.uk/itoggle/'),
'%path' => $library_path,
)));
}
return $form_element;
}
Functions
Name![]() |
Description |
---|---|
itoggle_form_admin | @file iToggle Admin config pages. |
_itoggle_admin_check_plugin_path | Checks if the directory in $form_element exists and contains a file named 'engage.itoggle.js'. If validation fails, the form element is flagged with an error from within the file_check_directory function. |