-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstyle_settings.theme.inc
119 lines (113 loc) · 3.67 KB
/
style_settings.theme.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
/**
* @file
* Theme form elements.
*/
/**
* Returns HTML for a number form element.
*
* @param $variables
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #title, #value, #description, #min, #max, #placeholder,
* #required, #attributes, #step, #size, #maxlength, #input_help.
*
* @ingroup themeable
*/
function theme_style_settings_number($variables) {
$element = $variables['element'];
$element['#attributes']['type'] = 'text';
element_set_attributes($element, array(
'id',
'name',
'value',
'step',
'min',
'max',
'size',
'maxlength',
'placeholder',
'input_help',
));
_form_set_class($element, array('form-text'));
$min = isset($element['#min']) ? t('Minimum') . '=' . $element['#min'] : '';
$max = isset($element['#max']) ? ' ' . t('Maximum') . '=' . $element['#max'] : '';
$step = isset($element['#step']) ? ' ' . t('Step') . '=' . $element['#step'] : '';
$input_help = $element['#input_help'] ? '<div class="description clearfix">' . $min . $max . $step . '</div>' : '';
$output = $input_help . '<input' . backdrop_attributes($element['#attributes']) . ' />';
return $output;
}
/**
* Returns HTML for a slider form element.
*
* @param $variables
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #title, #value, #description, #min, #max, #attributes,
* #step.
*
* @ingroup themeable
*/
function theme_style_settings_slider($variables) {
$element = $variables['element'];
// A unique identifier for the case of multiple sliders on one page.
$id = $element['#parents'][0];
$element['#attributes']['type'] = 'range';
$element['#attributes']['oninput'] = 'showValue' . $id . '(this.value)';
element_set_attributes($element, array(
'id',
'name',
'value',
'step',
'min',
'max',
));
_form_set_class($element, array('form-text', 'form-range'));
$output = '<input' . backdrop_attributes($element['#attributes']) . ' />';
$output .= '<span id="' . $id . '">';
$output .= $element['#attributes']['value'];
$output .= '</span>';
$output .= '<script type="text/javascript">
function showValue' . $id . '(newValue) {
document.getElementById("' . $id . '").innerHTML=newValue;
}
</script>';
return $output;
}
/**
* Returns HTML for an image URL form element.
*
* @param $variables
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #title, #value, #description, #size, #maxlength,
* #required, #attributes, #autocomplete_path.
*
* @ingroup themeable
*/
function theme_style_settings_imgurl($variables) {
$element = $variables['element'];
// A unique identifier to target the preview with ajax/JS to refresh.
$id = $element['#parents'][0];
$element['#attributes']['type'] = 'text';
element_set_attributes($element, array(
'id',
'name',
'value',
'size',
'maxlength',
));
_form_set_class($element, array('form-text'));
$output = '';
$value = trim($element['#attributes']['value']);
if (!empty($value)) {
$output .= '<div class="style-settings-image-preview">';
$output .= '<div class="style-settings-checkerboard">';
$output .= '<img id="' . $id . '-image-preview" typeof="foaf:Image" src="' . $element['#attributes']['value'] . '">';
$output .= '</div>';
$output .= '</div>';
}
$output .= '<div class="style-settings-image-data">';
$output .= '<input' . backdrop_attributes($element['#attributes']) . ' />';
return $output;
}