1 <?php
2 3 4 5 6 7 8
9
10 defined('JPATH_PLATFORM') or die;
11
12 use Joomla\Registry\Registry;
13
14 15 16 17 18
19 abstract class JHtmlFormbehavior
20 {
21 22 23 24
25 protected static $loaded = array();
26
27 28 29 30 31 32 33 34 35 36 37 38 39
40 public static function chosen($selector = '.advancedSelect', $debug = null, $options = array())
41 {
42 if (isset(static::$loaded[__METHOD__][$selector]))
43 {
44 return;
45 }
46
47
48 if ($debug === null)
49 {
50 $debug = JDEBUG;
51 }
52
53
54 if (!isset($options['disable_search_threshold']))
55 {
56 $options['disable_search_threshold'] = 10;
57 }
58
59
60 if (!isset($options['search_contains']))
61 {
62 $options['search_contains'] = true;
63 }
64
65 if (!isset($options['allow_single_deselect']))
66 {
67 $options['allow_single_deselect'] = true;
68 }
69
70 if (!isset($options['placeholder_text_multiple']))
71 {
72 $options['placeholder_text_multiple'] = JText::_('JGLOBAL_TYPE_OR_SELECT_SOME_OPTIONS');
73 }
74
75 if (!isset($options['placeholder_text_single']))
76 {
77 $options['placeholder_text_single'] = JText::_('JGLOBAL_SELECT_AN_OPTION');
78 }
79
80 if (!isset($options['no_results_text']))
81 {
82 $options['no_results_text'] = JText::_('JGLOBAL_SELECT_NO_RESULTS_MATCH');
83 }
84
85 $displayData = array(
86 'debug' => $debug,
87 'options' => $options,
88 'selector' => $selector,
89 );
90
91 JLayoutHelper::render('joomla.html.formbehavior.chosen', $displayData);
92
93 static::$loaded[__METHOD__][$selector] = true;
94
95 return;
96 }
97
98 99 100 101 102 103 104 105 106 107 108 109
110 public static function ajaxchosen(Registry $options, $debug = null)
111 {
112
113 $selector = $options->get('selector', '.tagfield');
114 $type = $options->get('type', 'GET');
115 $url = $options->get('url', null);
116 $dataType = $options->get('dataType', 'json');
117 $jsonTermKey = $options->get('jsonTermKey', 'term');
118 $afterTypeDelay = $options->get('afterTypeDelay', '500');
119 $minTermLength = $options->get('minTermLength', '3');
120
121
122 if (!empty($url))
123 {
124 if (isset(static::$loaded[__METHOD__][$selector]))
125 {
126 return;
127 }
128
129
130 static::chosen($selector, $debug);
131
132 $displayData = array(
133 'url' => $url,
134 'debug' => $debug,
135 'options' => $options,
136 'selector' => $selector,
137 'type' => $type,
138 'dataType' => $dataType,
139 'jsonTermKey' => $jsonTermKey,
140 'afterTypeDelay' => $afterTypeDelay,
141 'minTermLength' => $minTermLength,
142 );
143
144 JLayoutHelper::render('joomla.html.formbehavior.ajaxchosen', $displayData);
145
146 static::$loaded[__METHOD__][$selector] = true;
147 }
148
149 return;
150 }
151 }
152