You are here

private function ip_geoloc_plugin_style_leaflet::_add_check_boxes in IP Geolocation Views & Maps 7

1 call to ip_geoloc_plugin_style_leaflet::_add_check_boxes()
ip_geoloc_plugin_style_leaflet::options_form in views/ip_geoloc_plugin_style_leaflet.inc
Implements options_form().

File

views/ip_geoloc_plugin_style_leaflet.inc, line 423

Class

ip_geoloc_plugin_style_leaflet

Code

private function _add_check_boxes(&$form, $lib_markercluster, &$weight) {
  $form['full_screen'] = array(
    '#title' => t('Add a full-screen toggle to the map'),
    '#type' => 'checkbox',
    '#default_value' => $this->options['full_screen'],
    '#weight' => $weight++,
  );
  $lib_fullscreen = libraries_get_path('leaflet-fullscreen');
  if ($lib_fullscreen) {
    $file_fullscreen = $lib_fullscreen . '/dist/Leaflet.fullscreen.min.js';
    if (!file_exists($file_fullscreen)) {
      $form['full_screen']['#description'] = t('Error: <em>leaflet-fullscreen</em> library found, but %js_file is missing.', array(
        '%js_file' => $file_fullscreen,
      ));
    }
  }
  else {
    $form['full_screen']['#description'] = t('Requires this <a target="_js" href="@js_lib">JS library</a> to be downloaded to <em>/sites/all/libraries</em>. Change the directory name to <em>leaflet-fullscreen</em>.', array(
      '@js_lib' => 'https://github.com/Leaflet/Leaflet.fullscreen',
    ));
  }
  $form['scale_imperial'] = array(
    '#title' => t('Add an imperial (miles) scale'),
    '#type' => 'checkbox',
    '#default_value' => $this->options['scale_imperial'],
    '#weight' => $weight++,
  );
  $form['scale_metric'] = array(
    '#title' => t('Add a metric (km) scale'),
    '#type' => 'checkbox',
    '#default_value' => $this->options['scale_metric'],
    '#weight' => $weight++,
  );
  $form['zoom_indicator'] = array(
    '#title' => t('Add an indicator showing the active zoom level'),
    '#type' => 'checkbox',
    '#default_value' => $this->options['zoom_indicator'],
    '#weight' => $weight++,
  );
  $form['map_reset'] = array(
    '#title' => t('Add a reset button'),
    '#type' => 'checkbox',
    '#default_value' => $this->options['map_reset'],
    '#description' => t('This button allows the visitor to reset the map to its initial bounds (center and zoom level).'),
    '#weight' => $weight++,
  );
  $form['map_reset_css_class'] = array(
    '#title' => t('CSS class to apply to reset button'),
    '#type' => 'textfield',
    '#size' => 40,
    '#default_value' => $this->options['map_reset_css_class'],
    '#description' => t('You can use this to superimpose a font-icon on the button. For instance, if you have the Font Awesome library loaded for your markers, try <strong>fa fa-repeat</strong>. If you enter only one or two characters, for example <strong>R</strong>, these will be used verbatim as the label instead.'),
    '#weight' => $weight++,
    '#states' => array(
      'visible' => array(
        'input[name="style_options[map_reset]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['map_cluster_toggle'] = array(
    '#title' => t('Add cluster toggle button'),
    '#type' => 'checkbox',
    '#default_value' => $this->options['map_cluster_toggle'],
    '#description' => t('This button allows the visitor to toggle marker clustering on/off at any time and at any zoom level.') . '<br/>' . t('A cluster radius must be specified below.'),
    '#weight' => $weight++,
  );
  $form['on_click_options'] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#title' => t('Behaviour when clicked'),
    '#description' => t('These apply to markers, polygons and polylines.'),
    '#weight' => $weight++,
  );
  $form['on_click_options']['goto_content_on_click'] = array(
    '#title' => t('When <em>clicked</em>, go to the associated content page'),
    '#type' => 'checkbox',
    '#default_value' => $this->options['on_click_options']['goto_content_on_click'],
  );
  $form['on_click_options']['open_balloons_on_click'] = array(
    '#title' => t('When <em>clicked</em>, pop up a balloon showing non-excluded fields'),
    '#type' => 'checkbox',
    '#default_value' => $this->options['on_click_options']['open_balloons_on_click'],
  );
  $form['on_hover_options'] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#title' => t('Behaviour when hovered'),
    '#weight' => $weight++,
  );
  $form['on_hover_options']['open_balloons_on_hover'] = array(
    '#title' => t('When <em>hovered</em>, pop up a balloon showing non-excluded fields'),
    '#description' => t('Applies to markers, polygons and polylines.'),
    '#type' => 'checkbox',
    '#default_value' => $this->options['on_hover_options']['open_balloons_on_hover'],
  );
  $form['on_hover_options']['polygon_add_shadow_on_hover'] = array(
    '#title' => t('When <em>hovered</em>, add an effect to highlight the hovered element'),
    '#description' => t('Applies to polygons. Does not apply to markers.'),
    '#type' => 'checkbox',
    '#default_value' => $this->options['on_hover_options']['polygon_add_shadow_on_hover'],
  );
  $form['on_hover_options']['shadow_on_hover_effect'] = array(
    '#title' => t('Choose hover effect'),
    '#description' => t('The SURGE effect was designed by Matt Winans for <a href="!url">the SURGE movement</a>.', array(
      '!url' => url('http://surgemovement.com/map'),
    )),
    '#type' => 'radios',
    '#options' => array(
      'animated blur' => t('Blur/shadow, animated'),
      'surge' => t('SURGE effect, animated'),
    ),
    '#default_value' => $this->options['on_hover_options']['shadow_on_hover_effect'],
    '#states' => array(
      'invisible' => array(
        ':input[name="style_options[on_hover_options][polygon_add_shadow_on_hover]"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form['on_hover_options']['use_tweenmax_for_shadow_on_hover'] = array(
    '#title' => t('Version of <em>TweenMax</em> to use for generating animated hover effects.'),
    '#description' => t('You may opt for the <em>TweenMax</em> library to generate anamated drop shadows.') . '<br/>' . t('<a href="!url" target="_tween">TweenMax</a> offers higher performance and wider cross-browser support, but does add 0.12MB to your map page download size.', array(
      '!url' => url('https://greensock.com/tweenmax'),
    )) . '<br/>' . t("If entered the minimised version of the TweenMax library will be included automatically from the CDN closest to the visitor.") . '<br/>' . t("The default version is %version. Leave blank to use pure HTML for animations instead.", array(
      '%version' => TWEENMAX_VERSION,
    )),
    '#type' => 'textfield',
    '#size' => 6,
    '#default_value' => $this->options['on_hover_options']['use_tweenmax_for_shadow_on_hover'],
    '#states' => array(
      'invisible' => array(
        ':input[name="style_options[on_hover_options][polygon_add_shadow_on_hover]"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form['on_hover_options']['polygon_fill_opacity_on_hover'] = array(
    '#title' => t('For polygons: when <em>hovered</em> change <em>fill opacity</em> to'),
    '#description' => t('A fraction between 0 (transparent) and 1 (solid). Leave blank for no change.'),
    '#type' => 'textfield',
    '#size' => 4,
    '#default_value' => $this->options['on_hover_options']['polygon_fill_opacity_on_hover'],
  );
  $form['on_hover_options']['polygon_line_weight_on_hover'] = array(
    '#title' => t('For polygons: when <em>hovered</em> change <em>line weight</em> to'),
    '#description' => t('Width in pixels, typically 1..10. Use 0 to remove outline altogether. Leave blank for no change.') . '<br/>' . t('Line color, line opacity and line dash pattern remain unchanged from what you specified in the section <em>Options for Polygons, Polylines and Circles</em>, below.'),
    '#type' => 'textfield',
    '#size' => 4,
    '#default_value' => $this->options['on_hover_options']['polygon_line_weight_on_hover'],
  );
  $form['on_hover_options']['tip'] = array(
    '#type' => 'markup',
    '#markup' => t('TIP: You can animate the transition of <em>fill opacity</em> and <em>line weight</em> by adding a CCS rule like this to your theme: <br/>  <code>path.leaflet-interactive { transition: all 0.7s linear }</code>'),
  );
  if (!$lib_markercluster) {
    $form['map_cluster_toggle']['#description'] .= '<br/>' . t('<a href="!url_project">Leaflet MarkerCluster</a> must be enabled.', array(
      '!url_project' => url('http://drupal.org/project/leaflet_markercluster'),
    ));
  }
}