phpMv -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
Loading...
Searching...
No Matches
Autocomplete.php
Go to the documentation of this file.
1<?php
2namespace Ajax\ui\components;
3
8
16
17 public function __construct(JsUtils $js) {
18 parent::__construct($js);
19 $this->uiName = "autocomplete";
20 $this->setParam("minLength", 3);
21 }
22
30 public function setAjaxSource($url) {
31 if (JString::startsWith($url, "/")) {
32 $url = $this->js->getUrl($url);
33 }
34 $ajax = "%function (request, response) {
35 $.ajax({
36 url: '{$url}',
37 dataType: 'jsonp',
38 data: {q : request.term},
39 success: function(data) {response(data);}
40 });
41 }%";
42 return $this->setParam("source", $ajax);
43 }
44
54 public function setSource($source) {
55 $source = str_ireplace(array(
56 "\"",
57 "'"
58 ), "%quote%", $source);
59 return $this->setParam("source", "%" . $source . "%");
60 }
61
69 public function setAutofocus($value) {
70 return $this->setParamCtrl("autoFocus", $value, "is_bool");
71 }
72
82 public function setDelay($value) {
83 return $this->setParamCtrl("delay", $value, "is_int");
84 }
85
93 public function setDisabled($value) {
94 return $this->setParamCtrl("disabled", $value, "is_bool");
95 }
96
106 public function setMinLength($value) {
107 return $this->setParamCtrl("minLength", $value, "is_int");
108 }
109
119 public function setPosition(Position $position) {
120 return $this->setParam("position", $position->getParams());
121 }
122
129 public function onChange($jsCode) {
130 return $this->addEvent("change", $jsCode);
131 }
132
140 public function onClose($jsCode) {
141 return $this->addEvent("close", $jsCode);
142 }
143
153 public function onFocus($jsCode) {
154 return $this->addEvent("focus", $jsCode);
155 }
156
163 public function onOpen($jsCode) {
164 return $this->addEvent("open", $jsCode);
165 }
166
175 public function onResponse($jsCode) {
176 return $this->addEvent("response", $jsCode);
177 }
178
186 public function onSearch($jsCode) {
187 return $this->addEvent("search", $jsCode);
188 }
189
198 public function onSelect($jsCode) {
199 return $this->addEvent("select", $jsCode);
200 }
201}
JQuery PHP library.
Definition JsUtils.php:23
Base component for JQuery UI visuals components.
JQuery UI Autocomplete component.
setAutofocus($value)
If set to true the first item will automatically be focused when the menu is shown.
setDelay($value)
The delay in milliseconds between when a keystroke occurs and when a search is performed.
onClose($jsCode)
Triggered when the menu is hidden.
onResponse($jsCode)
Triggered after a search completes, before the menu is shown.
onChange($jsCode)
Triggered when the field is blurred, if the value has changed.
setSource($source)
Define the source property with a JSON Array of values Example : ["Bordeaux","Alsace",...
onSearch($jsCode)
Triggered before a search is performed, after minLength and delay are met.
setAjaxSource($url)
Define source property with an ajax request based on $url $url must return a JSON array of values.
onOpen($jsCode)
Triggered when the suggestion menu is opened or updated.
setDisabled($value)
Disables the autocomplete if set to true.
setPosition(Position $position)
Identifies the position of the suggestions menu in relation to the associated input element.
onSelect($jsCode)
Triggered when an item is selected from the menu.
setMinLength($value)
The minimum number of characters a user must type before a search is performed.
onFocus($jsCode)
Triggered when focus is moved to an item (not selecting).
Composant JQuery UI Position property.
Definition Position.php:12
$source
Project: doxygen-php-filters Author: Alex Schickedanz (AbcAeffchen) Date: 05.03.2015 License: GPL v2....
Definition traits.php:10