summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Starbow2009-03-06 01:54:08 (GMT)
committerTao Starbow2009-03-06 01:54:08 (GMT)
commit9448d83e7899a0157107b881fa37128a4be21296 (patch)
treeecf7a3fdea00d349663282909d5cfe98026c95d3
parentb7f42e59f0c54ae7ef10d2640866d729259c3184 (diff)
* http://drupal.org/node/388406 - Only autofill a single autocomplete field if there are mutliples.
-rw-r--r--CHANGELOG.txt5
-rw-r--r--README.txt5
-rw-r--r--popups_reference.js12
-rw-r--r--popups_reference.module2
4 files changed, 19 insertions, 5 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index a23a9f1..03091bc 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,8 +1,9 @@
-Drupal-6--1-0
+Drupal-6-1-0-RC3
* Recommended for use with Popups API 6.x-1.2
Bug Fixes
* http://drupal.org/node/390146 (cYu) - Allow users with "admin nodes" permission to see links.
-
+ * http://drupal.org/node/388406 - Only autofill a single autocomplete field if there are mutliples.
+
Drupal-6-1-0-RC2
Bug Fixes
* http://drupal.org/node/361964 (DeFr) - Bad unicode in autocomplete
diff --git a/README.txt b/README.txt
index 74f1b6e..0076e5c 100644
--- a/README.txt
+++ b/README.txt
@@ -3,5 +3,8 @@ Initial inspiration: Add and Reference by tema (http://drupal.org/project/add_n_
TODO
* Fix losing highlighted selections on node add with multi-select box.
- * http://drupal.org/node/388406 - not working on multi-references.
+
+LIMITATIONS
+ * http://drupal.org/node/378988 - conflicts with Hierarchical Select.
+
\ No newline at end of file
diff --git a/popups_reference.js b/popups_reference.js
index 15e9c89..84159e6 100644
--- a/popups_reference.js
+++ b/popups_reference.js
@@ -40,8 +40,18 @@ Drupal.behaviors.popups_reference = function(context) {
var nid = popups_reference_get_cookie_value('PopupRefNid');
var title = decodeURIComponent(popups_reference_get_cookie_value('PopupRefTitle'));
$wrapper.find('select').val(nid); // Select
- $wrapper.find('input.form-autocomplete').val(title); // Autocomplete
$wrapper.find(':radio[value=' + nid + ']').select(); // Radio buttons
+
+ // Get the first empty autocomplete field to fill (http://drupal.org/node/388406).
+ $emptyAutos = $wrapper.find('input.form-autocomplete').filter(function(i) {
+ return !$(this).val();
+ });
+ if ($emptyAutos.length) {
+ $emptyAutos.eq(0).val(title);
+ }
+ else { // There are no empty fields, use the first one.
+ $wrapper.find('input.form-autocomplete:first').val(title);
+ }
});
});
});
diff --git a/popups_reference.module b/popups_reference.module
index f38d6e5..02ef41b 100644
--- a/popups_reference.module
+++ b/popups_reference.module
@@ -131,7 +131,7 @@ function _popups_reference_links($field, $src_type, $wrapper_id, $type) {
$links = array();
$all_types = node_get_types();
foreach ($field['referenceable_types'] as $add_type => $value) {
- if (!empty($value) && (user_access("create $add_type content") || user_access('administer nodes'))) {
+ if (!empty($value) && user_access("create $add_type content")) {
drupal_add_js(drupal_get_path('module', 'popups_reference') .'/popups_reference.js');
$path = 'node/add/' . str_replace('_', '-', $add_type);
$name = $all_types[$add_type]->name;