settings['content'];
$style = $qt->settings['style'];
$position = $qt->settings['position'];
$show = $qt->settings['show'];
$hide = $qt->settings['hide'];
$miscellaneous = $qt->settings['miscellaneous'];
}
// The contents of $qt will either come from the db or from $form_state.
if (isset($form_state['values']['name'])) {
$qt = _qtip_convert_form_to_qtips($form_state);
}
$form = array('#tree' => TRUE);
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#description' => t('The human-friendly name to identify this qTip instance throughout the site.'),
'#default_value' => isset($qt->name) ? $qt->name : '',
'#weight' => -1000,
'#required' => TRUE,
);
$form['machine_name'] = array(
'#type' => 'machine_name',
'#description' => t('A unique machine-readable name for this qTip instance. It must only contain lowercase letters, numbers, and underscores. The machine name will be used internally by qTip and will be used in the CSS ID of your qTip instance.'),
'#machine_name' => array(
'exists' => 'qtip_machine_name_exists',
'source' => array('name'),
),
'#maxlength' => 32,
'#weight' => -999,
);
if (!empty($qt->machine_name)) {
$form['machine_name']['#default_value'] = $qt->machine_name;
$form['machine_name']['#disabled'] = TRUE;
$form['machine_name']['#value'] = $qt->machine_name;
}
/* Verical tabs */
$form['settings'] = array(
'#type' => 'vertical_tabs',
'#attached' => array(
'js' => array(drupal_get_path('module', 'qtip') . '/js/qtip.admin.js'),
),
);
/* Fieldsets */
$form['style'] = array(
'#type' => 'fieldset',
'#title' => t('Style'),
'#group' => 'settings',
'#weight' => $form['name']['#weight'] + 100,
);
$form['style']['tip_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Tip Settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => 100,
'#parents' => array('style'),
'#states' => array(
'visible' => array(
':input[name="style[tip][corner]"]' => array('checked' => TRUE),
),
),
);
$form['position'] = array(
'#type' => 'fieldset',
'#title' => t('Position'),
'#group' => 'settings',
'#weight' => $form['style']['#weight'] + 100,
);
$form['show'] = array(
'#type' => 'fieldset',
'#title' => t('Show'),
'#group' => 'settings',
'#weight' => $form['position']['#weight'] + 100,
);
$form['hide'] = array(
'#type' => 'fieldset',
'#title' => t('Hide'),
'#group' => 'settings',
'#weight' => $form['show']['#weight'] + 100,
);
$form['miscellaneous'] = array(
'#type' => 'fieldset',
'#title' => t('Miscellaneous'),
'#group' => 'settings',
'#weight' => $form['hide']['#weight'] + 100,
);
/* Styles */
$form['style']['classes'] = array(
'#type' => 'select',
'#title' => t('Color scheme'),
'#options' => array(
'Standard Color Schemes' => array(
'' => t('Plain (default)'),
'qtip-cream' => t('Cream'),
'qtip-light' => t('Light'),
'qtip-dark' => t('Dark'),
'qtip-red' => t('Red'),
'qtip-green' => t('Green'),
'qtip-blue' => t('Blue'),
),
'Advanced Color Schemes' => array(
'qtip-bootstrap' => t('Bootstrap'),
'qtip-tipsy' => t('Tipsy'),
'qtip-youtube' => t('YouTube'),
'qtip-jtools' => t('jTools'),
'qtip-cluetip' => t('ClueTip'),
'qtip-tipped' => t('Tipped'),
),
'qtip-custom' => 'Custom Color Scheme',
),
// '#description' => $settings['select']['description'],
'#default_value' => isset($style['classes']) ? $style['classes'] : '',
'#weight' => -100,
);
$form['style']['classes_custom'] = array(
'#type' => 'textfield',
'#title' => t('Custom CSS class'),
'#description' => t('The custom CSS class that will be used for all qTips.'),
'#default_value' => isset($style['classes_custom']) ? $style['classes_custom'] : '',
'#states' => array(
'visible' => array(
':input[name="style[classes]"]' => array('value' => 'qtip-custom'),
),
),
'#size' => 40,
'#weight' => -99,
);
$form['style']['shadow'] = array(
'#type' => 'checkbox',
'#title' => t('Show shadow under tooltips'),
'#description' => t('If checked a shadow will display under each tooltip.') . '
' .
'' . t('NOTE: This adds a class to each tooltip that uses the box-shadow CSS3 property, which is not supported in older browsers.') . '',
'#default_value' => isset($style['shadow']) ? $style['shadow'] : 0,
'#return_value' => 'qtip-shadow',
'#weight' => -90,
);
$form['style']['rounded_corners'] = array(
'#type' => 'checkbox',
'#title' => t('Show tooltips with rounded corners'),
'#description' => t('If checked each tooltip will have rounded corners.') . '
' .
'' . t('NOTE: This adds a class to each tooltip that uses the border-radius CSS3 property, which is not supported in older browsers.') . '',
'#default_value' => isset($style['rounded_corners']) ? $style['rounded_corners'] : 0,
'#return_value' => 'qtip-rounded',
'#weight' => -80,
);
/* Tip settings */
$form['style']['tip']['corner'] = array(
'#type' => 'checkbox',
'#title' => t('Show speech bubble tip'),
'#description' => t('If checked each tooltip will have a small speech bubble tip appended to them.'),
'#default_value' => isset($style['tip']['corner']) ? $style['tip']['corner'] : 0,
'#weight' => -70,
'#states' => array(
'invisible' => array(
':input[name="style[color_scheme]"]' => array('value' => 'qtip-youtube'),
),
),
);
$form['style']['tip_settings']['tip']['width'] = array(
'#type' => 'textfield',
'#title' => t('Width'),
'#description' => t('Determines the width of the rendered tip in pixels, in relation to the side of the tooltip it lies upon i.e. when the tip position is on the left or right, this quantity actually refers to the tips height in visual terms, and vice versa.') .
'
' . t('Make sure this is a number only, don\'t include any units e.g. \'px\'!') . '',
'#default_value' => isset($style['tip']['width']) ? $style['tip']['width'] : '6',
'#size' => 5,
'#weight' => -100,
'#required' => 1,
);
$form['style']['tip_settings']['tip']['height'] = array(
'#type' => 'textfield',
'#title' => t('Height'),
'#description' => t('Determines the height of the rendered tip in pixels, in relation to the side of the tooltip it lies upon i.e. when the tip position is on the left or right, this quantity actually refers to the tips width in visual terms, and vice versa.') .
'
' . t('Make sure this is a number only, don\'t include any units e.g. \'px\'!') . '',
'#default_value' => isset($style['tip']['height']) ? $style['tip']['height'] : '6',
'#size' => 5,
'#weight' => -90,
'#required' => 1,
);
$form['style']['tip_settings']['tip']['border'] = array(
'#type' => 'textfield',
'#title' => t('Border'),
'#description' => t('This option determines the width of the border that surrounds the tip element, much like the CSS border-width property of regular elements.') .
'
' . t('Make sure this is a number only, don\'t include any units e.g. \'px\'! Leave blank for default settings.') . '',
'#default_value' => isset($style['tip']['border']) ? $style['tip']['border'] : '',
'#size' => 5,
'#weight' => -80,
);
$form['style']['tip_settings']['tip']['corner_position'] = array(
'#type' => 'select',
'#title' => t('Position'),
'#options' => _qtip_admin_tooltip_position_options(),
'#default_value' => isset($style['tip']['corner_position']) ? $style['tip']['corner_position'] : '',
'#weight' => -70,
);
$form['style']['tip_settings']['tip']['mimic'] = array(
'#type' => 'select',
'#title' => t('Mimic'),
'#options' => _qtip_admin_tooltip_position_options(),
'#default_value' => isset($style['tip']['mimic']) ? $style['tip']['mimic'] : '',
'#weight' => -60,
);
$form['style']['tip_settings']['tip']['offset'] = array(
'#type' => 'textfield',
'#title' => t('Offset'),
'#description' => t('Determines the offset of the tip in relation to its current corner position. This value is relative i.e. depending on which corner the tooltip is set it will behave differently.') .
'
' . t('Make sure this is a number only, don\'t include any units e.g. \'px\'!') . '',
'#default_value' => isset($style['tip']['offset']) ? $style['tip']['offset'] : '',
'#size' => 5,
'#weight' => -50,
);
/* Position */
$form['position']['image'] = array(
'#type' => 'item',
'#markup' => '
hook_qtip_default_qtips()
to provide it as a default qtip.'),
);
return $form;
}
/**
* Helper function to convert the data on admin form into qtip presentation.
*/
function _qtip_convert_form_to_qtips($form_state) {
$qt = new stdClass();
$qt->name = $form_state['values']['name'];
if (isset($form_state['values']['machine_name'])) {
$qt->machine_name = $form_state['values']['machine_name'];
}
$qt->settings = array(
'content' => array(
'button' => $form_state['values']['miscellaneous']['button'],
),
'style' => $form_state['values']['style'],
'position' => $form_state['values']['position'],
'show' => $form_state['values']['show'],
'hide' => $form_state['values']['hide'],
'miscellaneous' => array(
'button_title_text' => $form_state['values']['miscellaneous']['button_title_text'],
),
);
return $qt;
}
/**
* Helper function to get options for tooltip positioning.
*/
function _qtip_admin_tooltip_position_options($normal = TRUE) {
$options = array(
'top left' => 'Top Left Corner',
'top center' => 'Top Center',
'top right' => 'Top Right Corner',
'right top' => 'Right Top Corner',
'right center' => 'Right Center',
'right bottom' => 'Right Bottom Corner',
'bottom right' => 'Bottom Right Corner', // Default value from qTip library
'bottom center' => 'Bottom Center',
'bottom left' => 'Bottom Left Corner',
'left bottom' => 'Left Bottom Corner',
'left center' => 'Left Center',
'left top' => 'Left Top',
'center' => 'Center',
);
if ($normal) {
// Prepend a 'Normal' option onto the beginning of the array, if set
$normal = array('' => 'Normal');
$options = $normal + $options;
}
return $options;
}