aboutsummaryrefslogtreecommitdiff
path: root/views/default/input/autocomplete.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-10-16 20:26:12 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-10-16 20:26:12 +0000
commitc66831fa5138a277a9729174caf14c7eb323fb07 (patch)
tree2444b54badf4914b59c88700cc1ce30a57ae7ff1 /views/default/input/autocomplete.php
parent8048313e87b9fd5ab6734e29a0e951524fa33e45 (diff)
downloadelgg-c66831fa5138a277a9729174caf14c7eb323fb07.tar.gz
elgg-c66831fa5138a277a9729174caf14c7eb323fb07.tar.bz2
Standardizing views.`
git-svn-id: http://code.elgg.org/elgg/trunk@3555 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'views/default/input/autocomplete.php')
-rw-r--r--views/default/input/autocomplete.php123
1 files changed, 63 insertions, 60 deletions
diff --git a/views/default/input/autocomplete.php b/views/default/input/autocomplete.php
index 052219a1b..7dc088d0e 100644
--- a/views/default/input/autocomplete.php
+++ b/views/default/input/autocomplete.php
@@ -1,56 +1,59 @@
<?php
+/**
+ * Displays an autocomplete text input.
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @author Curverider Ltd
+ * @link http://elgg.org/
+ *
+ * @TODO: This currently only works for ONE AUTOCOMPLETE TEXT FIELD on a page.
+ *
+ * @uses $vars['value'] The current value, if any
+ * @uses $vars['js'] Any Javascript to enter into the input tag
+ * @uses $vars['internalname'] The name of the input field
+ * @uses $vars['match_on'] Array | str What to match on. all|array(group|user|friend|subtype)
+ * @uses $vars['match_owner'] Bool. Match only entities that are owned by logged in user.
+ *
+ */
+
+global $autocomplete_js_loaded;
+
+$internalname = $vars['internalname'];
+$value = $vars['value'];
+
+if(!$value) {
+ $value= '';
+}
+
+if($vars['internal_id']) {
+ $id_autocomplete = $vars['internal_id'];
+}
+
+$ac_url_params = http_build_query(array(
+ 'match_on' => $vars['match_on'],
+ 'match_owner' => $vars['match_owner'],
+));
+$ac_url = $vars['url'] . 'pg/autocomplete?' . $ac_url_params;
+
+if (!isset($autocomplete_js_loaded)) {
+ $autocomplete_js_loaded = false;
+}
- /**
- * Displays an autocomplete text input.
- *
- * @package Elgg
- * @subpackage Core
- * @author Curverider Ltd
- * @link http://elgg.org/
- *
- * @TODO: This currently only works for ONE AUTOCOMPLETE TEXT FIELD on a page.
- *
- * @uses $vars['value'] The current value, if any
- * @uses $vars['js'] Any Javascript to enter into the input tag
- * @uses $vars['internalname'] The name of the input field
- * @uses $vars['match_on'] Array | str What to match on. all|array(group|user|friend|subtype)
- * @uses $vars['match_owner'] Bool. Match only entities that are owned by logged in user.
- *
- */
-
- global $autocomplete_js_loaded;
-
- $internalname = $vars['internalname'];
- $value = $vars['value'];
-
- if(!$value)
- $value= '';
-
- if($vars['internal_id'])
- $id_autocomplete = $vars['internal_id'];
-
- $ac_url_params = http_build_query(array(
- 'match_on' => $vars['match_on'],
- 'match_owner' => $vars['match_owner'],
- ));
- $ac_url = $vars['url'] . 'pg/autocomplete?' . $ac_url_params;
-
- if (!isset($autocomplete_js_loaded)) $autocomplete_js_loaded = false;
-
?>
<!-- show the input -->
- <input type="text" class='autocomplete' name ='<?php echo $internalname; ?>_autocomplete' value='<?php echo $value?>' />
- <input type="hidden" name="<?php echo $internalname; ?>" value='<?php echo $value; ?>' />
-
+<input type="text" class='autocomplete' name ='<?php echo $internalname; ?>_autocomplete' value='<?php echo $value?>' />
+<input type="hidden" name="<?php echo $internalname; ?>" value='<?php echo $value; ?>' />
+
<?php
- if (!$autocomplete_js_loaded) {
-?>
+if (!$autocomplete_js_loaded) {
+ ?>
-<!-- include autocomplete -->
-<script language="javascript" type="text/javascript" src="<?php echo $vars['url']; ?>vendors/jquery/jquery.autocomplete.min.js"></script>
-<script type="text/javascript">
-function bindAutocomplete() {
+ <!-- include autocomplete -->
+ <script language="javascript" type="text/javascript" src="<?php echo $vars['url']; ?>vendors/jquery/jquery.autocomplete.min.js"></script>
+ <script type="text/javascript">
+ function bindAutocomplete() {
$('input[type=text].autocomplete').autocomplete("<?php echo $ac_url; ?>", {
minChars: 1,
matchContains: true,
@@ -58,13 +61,13 @@ function bindAutocomplete() {
formatItem: function(row, i, max, term) {
eval("var info = " + row + ";");
var r = '';
-
+
switch (info.type) {
case 'user':
case 'group':
r = info.icon + info.name + ' - ' + info.desc;
break;
-
+
default:
r = info.name + ' - ' + info.desc;
break;
@@ -80,20 +83,20 @@ function bindAutocomplete() {
var hidden = $(this).next();
hidden.val(info.guid);
});
-}
+ }
-$(document).ready(function() {
+ $(document).ready(function() {
bindAutocomplete();
-});
+ });
-</script>
+ </script>
-<?php
+ <?php
- $autocomplete_js_loaded = true;
- } else {
-?>
-<!-- rebind autocomplete -->
-<script type="text/javascript">bindAutocomplete();</script>
-<?php
- } \ No newline at end of file
+ $autocomplete_js_loaded = true;
+} else {
+ ?>
+ <!-- rebind autocomplete -->
+ <script type="text/javascript">bindAutocomplete();</script>
+ <?php
+} \ No newline at end of file