Projet

Général

Profil

Paste
Télécharger (28,9 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / themes / bootstrap / theme-settings.php @ 5024cef7

1 87dbc3bf Benjamin Luce
<?php
2 eefc2ac0 Assos Assos
3 87dbc3bf Benjamin Luce
/**
4
 * @file
5
 * theme-settings.php
6
 *
7
 * Provides theme settings for Bootstrap based themes when admin theme is not.
8
 *
9 caf16a48 Assos Assos
 * @see ./includes/settings.inc
10 87dbc3bf Benjamin Luce
 */
11
12
/**
13
 * Include common Bootstrap functions.
14
 */
15 caf16a48 Assos Assos
include_once dirname(__FILE__) . '/includes/common.inc';
16
bootstrap_include('bootstrap', 'includes/cdn.inc');
17 87dbc3bf Benjamin Luce
18
/**
19
 * Implements hook_form_FORM_ID_alter().
20
 */
21
function bootstrap_form_system_theme_settings_alter(&$form, $form_state, $form_id = NULL) {
22 caf16a48 Assos Assos
  // Do not add Bootstrap specific settings to non-bootstrap based themes,
23
  // including a work-around for a core bug affecting admin themes.
24 9525582e Assos Assos
  // @see https://www.drupal.org/node/943212
25 caf16a48 Assos Assos
  $theme = !empty($form_state['build_info']['args'][0]) ? $form_state['build_info']['args'][0] : FALSE;
26
  if (isset($form_id) || $theme === FALSE || !in_array('bootstrap', _bootstrap_get_base_themes($theme, TRUE))) {
27 87dbc3bf Benjamin Luce
    return;
28
  }
29 caf16a48 Assos Assos
30
  // Display a warning if jQuery Update isn't enabled or using a lower version.
31
  if (!bootstrap_setting('toggle_jquery_error', $theme) || !module_exists('jquery_update')) {
32
    // Get theme specific jQuery version.
33
    $jquery_version = theme_get_setting('jquery_update_jquery_version', $theme);
34
35
    // Get site wide jQuery version if theme specific one is not set.
36
    if (!$jquery_version) {
37
      $jquery_version = variable_get('jquery_update_jquery_version', '1.10');
38
    }
39
40
    // Ensure the jQuery version is >= 1.9.
41
    if (!$jquery_version || !version_compare($jquery_version, '1.9', '>=')) {
42 749b8a23 Assos Assos
      $message = t('jQuery Update is not enabled, Bootstrap requires a minimum jQuery version of 1.9 or higher. Please enable the <a href="!jquery_update_project_url">jQuery Update</a> module. If you are seeing this message, then you must <a href="!jquery_update_configure">manually configuration</a> this setting or optionally <a href="!bootstrap_suppress_jquery_error">suppress this message</a> instead.', array(
43
        '!jquery_update_project_url' => check_plain('https://www.drupal.org/project/jquery_update'),
44
        '!jquery_update_configure' => check_plain(url('admin/config/development/jquery_update')),
45
        '!bootstrap_suppress_jquery_error' => check_plain(url('admin/appearance/settings/' . $theme, array(
46 caf16a48 Assos Assos
          'fragment' => 'edit-bootstrap-toggle-jquery-error',
47 749b8a23 Assos Assos
        ))),
48
      ));
49
      drupal_set_message($message, 'error', FALSE);
50 caf16a48 Assos Assos
    }
51
  }
52
53
  // Create vertical tabs for all Bootstrap related settings.
54
  $form['bootstrap'] = array(
55
    '#type' => 'vertical_tabs',
56
    '#attached' => array(
57
      'js'  => array(drupal_get_path('theme', 'bootstrap') . '/js/bootstrap.admin.js'),
58
    ),
59
    '#prefix' => '<h2><small>' . t('Bootstrap Settings') . '</small></h2>',
60
    '#weight' => -10,
61
  );
62
63
  // General.
64
  $form['general'] = array(
65
    '#type' => 'fieldset',
66
    '#title' => t('General'),
67
    '#group' => 'bootstrap',
68
  );
69
70 eefc2ac0 Assos Assos
  // Container.
71 caf16a48 Assos Assos
  $form['general']['container'] = array(
72
    '#type' => 'fieldset',
73
    '#title' => t('Container'),
74
    '#collapsible' => TRUE,
75
    '#collapsed' => TRUE,
76
  );
77
  $form['general']['container']['bootstrap_fluid_container'] = array(
78
    '#type' => 'checkbox',
79
    '#title' => t('Fluid container'),
80
    '#default_value' => bootstrap_setting('fluid_container', $theme),
81 749b8a23 Assos Assos
    '#description' => t('Use <code>.container-fluid</code> class. See <a href="!url">Fluid container</a>', array(
82 9525582e Assos Assos
      '!url' => 'https://getbootstrap.com/docs/3.3/css/#grid-example-fluid',
83 749b8a23 Assos Assos
    )),
84 caf16a48 Assos Assos
  );
85
86
  // Buttons.
87
  $form['general']['buttons'] = array(
88
    '#type' => 'fieldset',
89
    '#title' => t('Buttons'),
90
    '#collapsible' => TRUE,
91
    '#collapsed' => TRUE,
92
  );
93
  $form['general']['buttons']['bootstrap_button_size'] = array(
94
    '#type' => 'select',
95
    '#title' => t('Default button size'),
96
    '#default_value' => bootstrap_setting('button_size', $theme),
97
    '#empty_option' => t('Normal'),
98
    '#options' => array(
99
      'btn-xs' => t('Extra Small'),
100
      'btn-sm' => t('Small'),
101
      'btn-lg' => t('Large'),
102
    ),
103
  );
104
  $form['general']['buttons']['bootstrap_button_colorize'] = array(
105
    '#type' => 'checkbox',
106
    '#title' => t('Colorize Buttons'),
107
    '#default_value' => bootstrap_setting('button_colorize', $theme),
108
    '#description' => t('Adds classes to buttons based on their text value. See: <a href="!bootstrap_url" target="_blank">Buttons</a> and <a href="!api_url" target="_blank">hook_bootstrap_colorize_text_alter()</a>', array(
109 9525582e Assos Assos
      '!bootstrap_url' => 'https://getbootstrap.com/docs/3.3/css/#buttons',
110
      '!api_url' => 'https://drupal-bootstrap.org/apis/hook_bootstrap_colorize_text_alter',
111 caf16a48 Assos Assos
    )),
112
  );
113
  $form['general']['buttons']['bootstrap_button_iconize'] = array(
114
    '#type' => 'checkbox',
115
    '#title' => t('Iconize Buttons'),
116
    '#default_value' => bootstrap_setting('button_iconize', $theme),
117
    '#description' => t('Adds icons to buttons based on the text value. See: <a href="!api_url" target="_blank">hook_bootstrap_iconize_text_alter()</a>', array(
118 9525582e Assos Assos
      '!api_url' => 'https://drupal-bootstrap.org/apis/hook_bootstrap_iconize_text_alter',
119 caf16a48 Assos Assos
    )),
120
  );
121
122
  // Forms.
123
  $form['general']['forms'] = array(
124
    '#type' => 'fieldset',
125
    '#title' => t('Forms'),
126
    '#collapsible' => TRUE,
127
    '#collapsed' => TRUE,
128
  );
129
  $form['general']['forms']['bootstrap_forms_required_has_error'] = array(
130
    '#type' => 'checkbox',
131
    '#title' => t('Make required elements display as an error'),
132
    '#default_value' => bootstrap_setting('forms_required_has_error', $theme),
133
    '#description' => t('If an element in a form is required, enabling this will always display the element with a <code>.has-error</code> class. This turns the element red and helps in usability for determining which form elements are required to submit the form.  This feature compliments the "JavaScript > Forms > Automatically remove error classes when values have been entered" feature.'),
134
  );
135
  $form['general']['forms']['bootstrap_forms_smart_descriptions'] = array(
136
    '#type' => 'checkbox',
137
    '#title' => t('Smart form descriptions (via Tooltips)'),
138
    '#description' => t('Convert descriptions into tooltips (must be enabled) automatically based on certain criteria. This helps reduce the, sometimes unnecessary, amount of noise on a page full of form elements.'),
139
    '#default_value' => bootstrap_setting('forms_smart_descriptions', $theme),
140
  );
141
  $form['general']['forms']['bootstrap_forms_smart_descriptions_limit'] = array(
142
    '#type' => 'textfield',
143
    '#title' => t('"Smart form descriptions" maximum character limit'),
144
    '#description' => t('Prevents descriptions from becoming tooltips by checking the character length of the description (HTML is not counted towards this limit). To disable this filtering criteria, leave an empty value.'),
145
    '#default_value' => bootstrap_setting('forms_smart_descriptions_limit', $theme),
146
    '#states' => array(
147
      'visible' => array(
148
        ':input[name="bootstrap_forms_smart_descriptions"]' => array('checked' => TRUE),
149
      ),
150
    ),
151
  );
152
  $form['general']['forms']['bootstrap_forms_smart_descriptions_allowed_tags'] = array(
153
    '#type' => 'textfield',
154
    '#title' => t('"Smart form descriptions" allowed (HTML) tags'),
155
    '#description' => t('Prevents descriptions from becoming tooltips by checking for HTML not in the list above (i.e. links). Separate by commas. To disable this filtering criteria, leave an empty value.'),
156
    '#default_value' => bootstrap_setting('forms_smart_descriptions_allowed_tags', $theme),
157
    '#states' => array(
158
      'visible' => array(
159
        ':input[name="bootstrap_forms_smart_descriptions"]' => array('checked' => TRUE),
160
      ),
161
    ),
162
  );
163
164
  // Images.
165
  $form['general']['images'] = array(
166
    '#type' => 'fieldset',
167
    '#title' => t('Images'),
168
    '#collapsible' => TRUE,
169
    '#collapsed' => TRUE,
170
  );
171
  $form['general']['images']['bootstrap_image_shape'] = array(
172
    '#type' => 'select',
173
    '#title' => t('Default image shape'),
174
    '#description' => t('Add classes to an <code>&lt;img&gt;</code> element to easily style images in any project. Note: Internet Explorer 8 lacks support for rounded corners. See: <a href="!bootstrap_url" target="_blank">Image Shapes</a>', array(
175 9525582e Assos Assos
      '!bootstrap_url' => 'https://getbootstrap.com/docs/3.3/css/#images-shapes',
176 caf16a48 Assos Assos
    )),
177
    '#default_value' => bootstrap_setting('image_shape', $theme),
178
    '#empty_option' => t('None'),
179
    '#options' => array(
180
      'img-rounded' => t('Rounded'),
181
      'img-circle' => t('Circle'),
182
      'img-thumbnail' => t('Thumbnail'),
183
    ),
184
  );
185
  $form['general']['images']['bootstrap_image_responsive'] = array(
186
    '#type' => 'checkbox',
187
    '#title' => t('Responsive Images'),
188
    '#default_value' => bootstrap_setting('image_responsive', $theme),
189
    '#description' => t('Images in Bootstrap 3 can be made responsive-friendly via the addition of the <code>.img-responsive</code> class. This applies <code>max-width: 100%;</code> and <code>height: auto;</code> to the image so that it scales nicely to the parent element.'),
190
  );
191
192
  // Tables.
193
  $form['general']['tables'] = array(
194
    '#type' => 'fieldset',
195
    '#title' => t('Tables'),
196
    '#collapsible' => TRUE,
197
    '#collapsed' => TRUE,
198
  );
199
  $form['general']['tables']['bootstrap_table_bordered'] = array(
200
    '#type' => 'checkbox',
201
    '#title' => t('Bordered table'),
202
    '#default_value' => bootstrap_setting('table_bordered', $theme),
203
    '#description' => t('Add borders on all sides of the table and cells.'),
204
  );
205
  $form['general']['tables']['bootstrap_table_condensed'] = array(
206
    '#type' => 'checkbox',
207
    '#title' => t('Condensed table'),
208
    '#default_value' => bootstrap_setting('table_condensed', $theme),
209
    '#description' => t('Make tables more compact by cutting cell padding in half.'),
210
  );
211
  $form['general']['tables']['bootstrap_table_hover'] = array(
212
    '#type' => 'checkbox',
213
    '#title' => t('Hover rows'),
214
    '#default_value' => bootstrap_setting('table_hover', $theme),
215
    '#description' => t('Enable a hover state on table rows.'),
216
  );
217
  $form['general']['tables']['bootstrap_table_striped'] = array(
218
    '#type' => 'checkbox',
219
    '#title' => t('Striped rows'),
220
    '#default_value' => bootstrap_setting('table_striped', $theme),
221
    '#description' => t('Add zebra-striping to any table row within the <code>&lt;tbody&gt;</code>. <strong>Note:</strong> Striped tables are styled via the <code>:nth-child</code> CSS selector, which is not available in Internet Explorer 8.'),
222
  );
223
  $form['general']['tables']['bootstrap_table_responsive'] = array(
224 eefc2ac0 Assos Assos
    '#type' => 'select',
225 caf16a48 Assos Assos
    '#title' => t('Responsive tables'),
226
    '#default_value' => bootstrap_setting('table_responsive', $theme),
227 eefc2ac0 Assos Assos
    '#description' => t('Wraps tables with <code>.table-responsive</code> to make them horizontally scroll when viewing them on devices under 768px. When viewing on devices larger than 768px, you will not see a difference in the presentational aspect of these tables. The <code>Automatic</code> option will only apply this setting for front-end facing tables, not the tables in administrative areas.'),
228
    '#options' => array(
229
      -1 => t('Automatic'),
230
      0 => t('Disabled'),
231
      1 => t('Enabled'),
232
    ),
233 caf16a48 Assos Assos
  );
234
235
  // Components.
236
  $form['components'] = array(
237
    '#type' => 'fieldset',
238
    '#title' => t('Components'),
239
    '#group' => 'bootstrap',
240
  );
241
242
  // Breadcrumbs.
243
  $form['components']['breadcrumbs'] = array(
244
    '#type' => 'fieldset',
245
    '#title' => t('Breadcrumbs'),
246
  );
247 749b8a23 Assos Assos
248
  // Show message for Path Breadcrumbs module support.
249
  if (_bootstrap_use_path_breadcrumbs($theme)) {
250
    $form['components']['breadcrumbs']['#description'] = t('The <a href="!path_breadcrumbs" target="_blank">Path Breadcrumbs</a> module is being used to manage this site\'s breadcrumbs display and cannot be configured via theme settings. To configure this site\'s breadcrumbs display, enable the <a href="!enable">Path Breadcrumbs UI</a> sub-module and then visit <a href="!settings">Path Breadcrumbs Settings</a>.', array(
251
      '!path_breadcrumbs' => 'https://www.drupal.org/project/path_breadcrumbs',
252
      '!enable' => url('admin/modules', array('fragment' => 'edit-modules-path-breadcrumbs')),
253
      '!settings' => url('admin/structure/path-breadcrumbs/settings'),
254
    ));
255
  }
256
  else {
257
    $form['components']['breadcrumbs']['#collapsible'] = TRUE;
258
    $form['components']['breadcrumbs']['#collapsed'] = TRUE;
259
    $form['components']['breadcrumbs']['bootstrap_breadcrumb'] = array(
260
      '#type' => 'select',
261
      '#title' => t('Breadcrumb visibility'),
262
      '#default_value' => bootstrap_setting('breadcrumb', $theme),
263
      '#options' => array(
264
        0 => t('Hidden'),
265
        1 => t('Visible'),
266
        2 => t('Only in admin areas'),
267 caf16a48 Assos Assos
      ),
268 749b8a23 Assos Assos
    );
269
    $form['components']['breadcrumbs']['bootstrap_breadcrumb_home'] = array(
270
      '#type' => 'checkbox',
271
      '#title' => t('Show "Home" breadcrumb link'),
272
      '#default_value' => bootstrap_setting('breadcrumb_home', $theme),
273
      '#description' => t('If your site has a module dedicated to handling breadcrumbs already, ensure this setting is enabled.'),
274
      '#states' => array(
275
        'invisible' => array(
276
          ':input[name="bootstrap_breadcrumb"]' => array('value' => 0),
277
        ),
278 caf16a48 Assos Assos
      ),
279 749b8a23 Assos Assos
    );
280
    $form['components']['breadcrumbs']['bootstrap_breadcrumb_title'] = array(
281
      '#type' => 'checkbox',
282
      '#title' => t('Show current page title at end'),
283
      '#default_value' => bootstrap_setting('breadcrumb_title', $theme),
284
      '#description' => t('If your site has a module dedicated to handling breadcrumbs already, ensure this setting is disabled.'),
285
      '#states' => array(
286
        'invisible' => array(
287
          ':input[name="bootstrap_breadcrumb"]' => array('value' => 0),
288
        ),
289
      ),
290
    );
291
  }
292 caf16a48 Assos Assos
293
  // Navbar.
294
  $form['components']['navbar'] = array(
295
    '#type' => 'fieldset',
296
    '#title' => t('Navbar'),
297
    '#collapsible' => TRUE,
298
    '#collapsed' => TRUE,
299
  );
300
  $form['components']['navbar']['bootstrap_navbar_position'] = array(
301
    '#type' => 'select',
302
    '#title' => t('Navbar Position'),
303
    '#description' => t('Select your Navbar position.'),
304
    '#default_value' => bootstrap_setting('navbar_position', $theme),
305
    '#options' => array(
306
      'static-top' => t('Static Top'),
307
      'fixed-top' => t('Fixed Top'),
308
      'fixed-bottom' => t('Fixed Bottom'),
309
    ),
310
    '#empty_option' => t('Normal'),
311
  );
312
  $form['components']['navbar']['bootstrap_navbar_inverse'] = array(
313
    '#type' => 'checkbox',
314
    '#title' => t('Inverse navbar style'),
315
    '#description' => t('Select if you want the inverse navbar style.'),
316
    '#default_value' => bootstrap_setting('navbar_inverse', $theme),
317
  );
318
319 eefc2ac0 Assos Assos
  // Pager.
320 caf16a48 Assos Assos
  $form['components']['pager'] = array(
321
    '#type' => 'fieldset',
322
    '#title' => t('Pagination'),
323
    '#collapsible' => TRUE,
324
    '#collapsed' => TRUE,
325
  );
326
327
  $form['components']['pager']['bootstrap_pager_first_and_last'] = array(
328
    '#type' => 'checkbox',
329
    '#title' => t('Show "First" and "Last" links in the pager'),
330
    '#description' => t('Allow user to choose whether to display "First" and "Last" links on pagers.'),
331
    '#default_value' => bootstrap_setting('pager_first_and_last', $theme),
332
  );
333
334
  // Region wells.
335
  $wells = array(
336
    '' => t('None'),
337
    'well' => t('.well (normal)'),
338
    'well well-sm' => t('.well-sm (small)'),
339
    'well well-lg' => t('.well-lg (large)'),
340
  );
341
  $form['components']['region_wells'] = array(
342
    '#type' => 'fieldset',
343
    '#title' => t('Region wells'),
344 19bd065e Assos Assos
    '#description' => t('Enable the <code>.well</code>, <code>.well-sm</code> or <code>.well-lg</code> classes for specified regions. See: documentation on <a href="!wells" target="_blank">Bootstrap Wells</a>.', array(
345 9525582e Assos Assos
      '!wells' => 'https://getbootstrap.com/docs/3.3/components/#wells',
346 caf16a48 Assos Assos
    )),
347
    '#collapsible' => TRUE,
348
    '#collapsed' => TRUE,
349
  );
350
  // Get defined regions.
351
  $regions = system_region_list($theme);
352
  foreach ($regions as $name => $title) {
353
    $form['components']['region_wells']['bootstrap_region_well-' . $name] = array(
354
      '#title' => $title,
355
      '#type' => 'select',
356
      '#attributes' => array(
357
        'class' => array('input-sm'),
358
      ),
359
      '#options' => $wells,
360
      '#default_value' => bootstrap_setting('region_well-' . $name, $theme),
361
    );
362
  }
363
364
  // JavaScript settings.
365
  $form['javascript'] = array(
366
    '#type' => 'fieldset',
367
    '#title' => t('JavaScript'),
368
    '#group' => 'bootstrap',
369
  );
370
371
  // Anchors.
372
  $form['javascript']['anchors'] = array(
373
    '#type' => 'fieldset',
374
    '#title' => t('Anchors'),
375
    '#collapsible' => TRUE,
376
    '#collapsed' => TRUE,
377
    '#description' => t('This plugin is not able to be configured from the UI as it is severely broken. In an effort to balance not break backwards compatibility and to prevent new users from running into unforeseen issues, you must manually opt-in/out inside your theme .info file. Please see the following issue for more details: <a href="!url" target="_blank">Replace custom JS with the bootstrap-anchor plugin</a>', array(
378
      '!url' => 'https://www.drupal.org/node/2462645',
379
    )),
380
  );
381
  $form['javascript']['anchors']['bootstrap_anchors_fix'] = array(
382
    '#type' => 'checkbox',
383
    '#title' => t('Fix anchor positions'),
384
    '#default_value' => bootstrap_setting('anchors_fix', $theme),
385
    '#description' => t('Ensures anchors are correctly positioned only when there is margin or padding detected on the BODY element. This is useful when fixed navbar or administration menus are used.'),
386
    // Prevent UI edits, see description above.
387
    '#disabled' => TRUE,
388
  );
389
  $form['javascript']['anchors']['bootstrap_anchors_smooth_scrolling'] = array(
390
    '#type' => 'checkbox',
391
    '#title' => t('Enable smooth scrolling'),
392
    '#default_value' => bootstrap_setting('anchors_smooth_scrolling', $theme),
393
    '#description' => t('Animates page by scrolling to an anchor link target smoothly when clicked.'),
394
    '#states' => array(
395
      'invisible' => array(
396
        ':input[name="bootstrap_anchors_fix"]' => array('checked' => FALSE),
397
      ),
398
    ),
399
    // Prevent UI edits, see description above.
400
    '#disabled' => TRUE,
401
  );
402
403
  // Forms.
404
  $form['javascript']['forms'] = array(
405
    '#type' => 'fieldset',
406
    '#title' => t('Forms'),
407
    '#collapsible' => TRUE,
408
    '#collapsed' => TRUE,
409
  );
410
  $form['javascript']['forms']['bootstrap_forms_has_error_value_toggle'] = array(
411
    '#type' => 'checkbox',
412
    '#title' => t('Automatically remove error classes when values have been entered'),
413
    '#default_value' => bootstrap_setting('forms_has_error_value_toggle', $theme),
414
    '#description' => t('If an element has a <code>.has-error</code> class attached to it, enabling this will automatically remove that class when a value is entered. This feature compliments the "General > Forms > Make required elements display as an error" feature.'),
415
  );
416
417
  // Popovers.
418
  $form['javascript']['popovers'] = array(
419
    '#type' => 'fieldset',
420
    '#title' => t('Popovers'),
421
    '#description' => t('Add small overlays of content, like those on the iPad, to any element for housing secondary information.'),
422
    '#collapsible' => TRUE,
423
    '#collapsed' => TRUE,
424
  );
425
  $form['javascript']['popovers']['bootstrap_popover_enabled'] = array(
426
    '#type' => 'checkbox',
427
    '#title' => t('Enable popovers.'),
428 749b8a23 Assos Assos
    '#description' => t('Elements that have the <code>data-toggle="popover"</code> attribute set will automatically initialize the popover upon page load. <strong class="error text-error">WARNING: This feature can sometimes impact performance. Disable if pages appear to "hang" after initial load.</strong>'),
429 caf16a48 Assos Assos
    '#default_value' => bootstrap_setting('popover_enabled', $theme),
430
  );
431
  $form['javascript']['popovers']['options'] = array(
432
    '#type' => 'fieldset',
433
    '#title' => t('Options'),
434 749b8a23 Assos Assos
    '#description' => t('These are global options. Each popover can independently override desired settings by appending the option name to <code>data-</code>. Example: <code>data-animation="false"</code>.'),
435 caf16a48 Assos Assos
    '#collapsible' => TRUE,
436
    '#collapsed' => TRUE,
437
    '#states' => array(
438
      'visible' => array(
439
        ':input[name="bootstrap_popover_enabled"]' => array('checked' => TRUE),
440
      ),
441
    ),
442
  );
443
  $form['javascript']['popovers']['options']['bootstrap_popover_animation'] = array(
444
    '#type' => 'checkbox',
445
    '#title' => t('animate'),
446
    '#description' => t('Apply a CSS fade transition to the popover.'),
447
    '#default_value' => bootstrap_setting('popover_animation', $theme),
448
  );
449
  $form['javascript']['popovers']['options']['bootstrap_popover_html'] = array(
450
    '#type' => 'checkbox',
451
    '#title' => t('HTML'),
452
    '#description' => t("Insert HTML into the popover. If false, jQuery's text method will be used to insert content into the DOM. Use text if you're worried about XSS attacks."),
453
    '#default_value' => bootstrap_setting('popover_html', $theme),
454
  );
455
  $form['javascript']['popovers']['options']['bootstrap_popover_placement'] = array(
456
    '#type' => 'select',
457
    '#title' => t('placement'),
458
    '#description' => t('Where to position the popover. When "auto" is specified, it will dynamically reorient the popover. For example, if placement is "auto left", the popover will display to the left when possible, otherwise it will display right.'),
459
    '#default_value' => bootstrap_setting('popover_placement', $theme),
460
    '#options' => drupal_map_assoc(array(
461
      'top',
462
      'bottom',
463
      'left',
464
      'right',
465
      'auto',
466
      'auto top',
467
      'auto bottom',
468
      'auto left',
469
      'auto right',
470
    )),
471
  );
472
  $form['javascript']['popovers']['options']['bootstrap_popover_selector'] = array(
473
    '#type' => 'textfield',
474
    '#title' => t('selector'),
475 749b8a23 Assos Assos
    '#description' => t('If a selector is provided, tooltip objects will be delegated to the specified targets. In practice, this is used to enable dynamic HTML content to have popovers added. See <a href="!this" target="_blank">this</a> and <a href="!example" target="_blank">an informative example</a>.', array(
476
      '!this' => 'https://github.com/twbs/bootstrap/issues/4215',
477
      '!example' => 'http://jsfiddle.net/fScua/',
478 caf16a48 Assos Assos
    )),
479
    '#default_value' => bootstrap_setting('popover_selector', $theme),
480
  );
481
  $form['javascript']['popovers']['options']['bootstrap_popover_trigger'] = array(
482
    '#type' => 'checkboxes',
483
    '#title' => t('trigger'),
484
    '#description' => t('How a popover is triggered.'),
485
    '#default_value' => bootstrap_setting('popover_trigger', $theme),
486
    '#options' => drupal_map_assoc(array(
487
      'click',
488
      'hover',
489
      'focus',
490
      'manual',
491
    )),
492
  );
493
  $form['javascript']['popovers']['options']['bootstrap_popover_trigger_autoclose'] = array(
494
    '#type' => 'checkbox',
495
    '#title' => t('Auto-close on document click'),
496
    '#description' => t('Will automatically close the current popover if a click occurs anywhere else other than the popover element.'),
497
    '#default_value' => bootstrap_setting('popover_trigger_autoclose', $theme),
498
  );
499
  $form['javascript']['popovers']['options']['bootstrap_popover_title'] = array(
500
    '#type' => 'textfield',
501
    '#title' => t('title'),
502
    '#description' => t("Default title value if \"title\" attribute isn't present."),
503
    '#default_value' => bootstrap_setting('popover_title', $theme),
504
  );
505
  $form['javascript']['popovers']['options']['bootstrap_popover_content'] = array(
506
    '#type' => 'textfield',
507
    '#title' => t('content'),
508
    '#description' => t('Default content value if "data-content" or "data-target" attributes are not present.'),
509
    '#default_value' => bootstrap_setting('popover_content', $theme),
510
  );
511
  $form['javascript']['popovers']['options']['bootstrap_popover_delay'] = array(
512
    '#type' => 'textfield',
513
    '#title' => t('delay'),
514
    '#description' => t('The amount of time to delay showing and hiding the popover (in milliseconds). Does not apply to manual trigger type.'),
515
    '#default_value' => bootstrap_setting('popover_delay', $theme),
516
  );
517
  $form['javascript']['popovers']['options']['bootstrap_popover_container'] = array(
518
    '#type' => 'textfield',
519
    '#title' => t('container'),
520
    '#description' => t('Appends the popover to a specific element. Example: "body". This option is particularly useful in that it allows you to position the popover in the flow of the document near the triggering element - which will prevent the popover from floating away from the triggering element during a window resize.'),
521
    '#default_value' => bootstrap_setting('popover_container', $theme),
522
  );
523
524
  // Tooltips.
525
  $form['javascript']['tooltips'] = array(
526
    '#type' => 'fieldset',
527
    '#title' => t('Tooltips'),
528 749b8a23 Assos Assos
    '#description' => t('Inspired by the excellent jQuery.tipsy plugin written by Jason Frame; Tooltips are an updated version, which don\'t rely on images, use CSS3 for animations, and data-attributes for local title storage. See <a href="!url" target="_blank">Bootstrap tooltips</a> for more documentation.', array(
529 9525582e Assos Assos
      '!url' => 'https://getbootstrap.com/docs/3.3/javascript/#tooltips',
530 caf16a48 Assos Assos
    )),
531
    '#collapsible' => TRUE,
532
    '#collapsed' => TRUE,
533
  );
534
  $form['javascript']['tooltips']['bootstrap_tooltip_enabled'] = array(
535
    '#type' => 'checkbox',
536
    '#title' => t('Enable tooltips'),
537 749b8a23 Assos Assos
    '#description' => t('Elements that have the <code>data-toggle="tooltip"</code> attribute set will automatically initialize the tooltip upon page load. <strong class="error text-error">WARNING: This feature can sometimes impact performance. Disable if pages appear to "hang" after initial load.</strong>'),
538 caf16a48 Assos Assos
    '#default_value' => bootstrap_setting('tooltip_enabled', $theme),
539
  );
540
  $form['javascript']['tooltips']['options'] = array(
541
    '#type' => 'fieldset',
542
    '#title' => t('Options'),
543 749b8a23 Assos Assos
    '#description' => t('These are global options. Each tooltip can independently override desired settings by appending the option name to <code>data-</code>. Example: <code>data-animation="false"</code>.'),
544 caf16a48 Assos Assos
    '#collapsible' => TRUE,
545
    '#collapsed' => TRUE,
546
    '#states' => array(
547
      'visible' => array(
548
        ':input[name="bootstrap_tooltip_enabled"]' => array('checked' => TRUE),
549
      ),
550
    ),
551
  );
552
  $form['javascript']['tooltips']['options']['bootstrap_tooltip_animation'] = array(
553
    '#type' => 'checkbox',
554
    '#title' => t('animate'),
555
    '#description' => t('Apply a CSS fade transition to the tooltip.'),
556
    '#default_value' => bootstrap_setting('tooltip_animation', $theme),
557
  );
558
  $form['javascript']['tooltips']['options']['bootstrap_tooltip_html'] = array(
559
    '#type' => 'checkbox',
560
    '#title' => t('HTML'),
561
    '#description' => t("Insert HTML into the tooltip. If false, jQuery's text method will be used to insert content into the DOM. Use text if you're worried about XSS attacks."),
562
    '#default_value' => bootstrap_setting('tooltip_html', $theme),
563
  );
564
  $form['javascript']['tooltips']['options']['bootstrap_tooltip_placement'] = array(
565
    '#type' => 'select',
566
    '#title' => t('placement'),
567
    '#description' => t('Where to position the tooltip. When "auto" is specified, it will dynamically reorient the tooltip. For example, if placement is "auto left", the tooltip will display to the left when possible, otherwise it will display right.'),
568
    '#default_value' => bootstrap_setting('tooltip_placement', $theme),
569
    '#options' => drupal_map_assoc(array(
570
      'top',
571
      'bottom',
572
      'left',
573
      'right',
574
      'auto',
575
      'auto top',
576
      'auto bottom',
577
      'auto left',
578
      'auto right',
579
    )),
580
  );
581
  $form['javascript']['tooltips']['options']['bootstrap_tooltip_selector'] = array(
582
    '#type' => 'textfield',
583
    '#title' => t('selector'),
584
    '#description' => t('If a selector is provided, tooltip objects will be delegated to the specified targets.'),
585
    '#default_value' => bootstrap_setting('tooltip_selector', $theme),
586
  );
587
  $form['javascript']['tooltips']['options']['bootstrap_tooltip_trigger'] = array(
588
    '#type' => 'checkboxes',
589
    '#title' => t('trigger'),
590
    '#description' => t('How a tooltip is triggered.'),
591
    '#default_value' => bootstrap_setting('tooltip_trigger', $theme),
592
    '#options' => drupal_map_assoc(array(
593
      'click',
594
      'hover',
595
      'focus',
596
      'manual',
597
    )),
598
  );
599
  $form['javascript']['tooltips']['options']['bootstrap_tooltip_delay'] = array(
600
    '#type' => 'textfield',
601
    '#title' => t('delay'),
602
    '#description' => t('The amount of time to delay showing and hiding the tooltip (in milliseconds). Does not apply to manual trigger type.'),
603
    '#default_value' => bootstrap_setting('tooltip_delay', $theme),
604
  );
605
  $form['javascript']['tooltips']['options']['bootstrap_tooltip_container'] = array(
606
    '#type' => 'textfield',
607
    '#title' => t('container'),
608
    '#description' => t('Appends the tooltip to a specific element. Example: "body"'),
609
    '#default_value' => bootstrap_setting('tooltip_container', $theme),
610
  );
611
612
  // Advanced settings.
613
  $form['advanced'] = array(
614
    '#type' => 'fieldset',
615
    '#title' => t('Advanced'),
616
    '#group' => 'bootstrap',
617
  );
618
619
  // jQuery Update error suppression.
620
  $form['advanced']['bootstrap_toggle_jquery_error'] = array(
621
    '#type' => 'checkbox',
622
    '#title' => t('Suppress jQuery version error message'),
623
    '#default_value' => bootstrap_setting('toggle_jquery_error', $theme),
624
    '#description' => t('Enable this if the version of jQuery has been upgraded to 1.9+ using a method other than the <a href="!jquery_update" target="_blank">jQuery Update</a> module.', array(
625 9525582e Assos Assos
      '!jquery_update' => 'https://www.drupal.org/project/jquery_update',
626 caf16a48 Assos Assos
    )),
627
  );
628
629
  // BootstrapCDN.
630
  bootstrap_cdn_provider_settings_form($form, $form_state, $theme);
631 87dbc3bf Benjamin Luce
}