Author: david
Date: Thu Oct 22 16:45:35 2009
New Revision: 3804
Log:
Switch event dialog 'actor' select to an autocomplete field (w/ Jack's awesome
patch).
Modified:
trunk/apps/qubit/modules/informationobject/templates/_eventForm.php
trunk/web/js/eventDialog.js
Modified: trunk/apps/qubit/modules/informationobject/templates/_eventForm.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/templates/_eventForm.php Thu Oct
22 16:01:13 2009 (r3803)
+++ trunk/apps/qubit/modules/informationobject/templates/_eventForm.php Thu Oct
22 16:45:35 2009 (r3804)
@@ -20,14 +20,13 @@
<table id="newEvent" class="inline">
<caption><?php echo __('new event') ?></caption>
<tr>
- <td colspan ="2" class="headerCell" style="width: 55%;"><?php echo
__('actor id') ?></td>
- <td class="headerCell" style="width: 40%;"><i><?php echo __('or') ?>
</i><?php echo __('add new name') ?></td>
+ <td colspan="3" class="headerCell" style="width: 55%;"><?php echo
__('actor name') ?></td>
</tr>
<tr>
- <td colspan ="2" class="noline">
- <input type="text" name="newEvent[actorId]" />
+ <td colspan="3" class="noline">
+ <select id="newEventActor" name="newEvent[actor]"
class="form-autocomplete" />
+ <input class="list" type="hidden" value="<?php echo
url_for(array('module' => 'actor', 'action' => 'autocomplete')) ?>"/>
</td>
- <td class="noline"><?php echo input_tag('newEvent[newActorName]')
?></td>
</tr>
<tr>
<td colspan="2" class="headerCell" style="width: 55%;"><?php echo
__('event type') ?></td><td class="headerCell" style="width: 40%;"><?php echo
__('place') ?></td>
@@ -57,22 +56,22 @@
/*
* Dynamically write form elements specific to the eventDialog YUI
* Dialog object, so we don't see them when Javascript is turned off. Include
- * them here (instead of in .js file) to allow PHP to parse i18n tags.
+ * them here (instead of in .js file) to allow PHP to parse i18n tags.
*/
-
+
// Make Qubit variables available to javascript
Qubit.labels = ({"unknown": "<?php echo __('unknown') ?>"});
Qubit.paths = ({"eventShow": "<?php echo url_for('event/show') ?>"});
// Do this after eventDialog.js actions
Drupal.behaviors.writeNewActorEventHTML = {
- attach: function(context)
+ attach: function(context)
{
// Create YUI container for form
$('body').prepend(
'<div class="yui-skin-sam">' +
'<div id="eventDialog">' +
- '<div class="hd"><?php echo __('new event') ?></div>' +
+ '<div class="hd"><?php echo __('new event') ?></div>' +
'<div class="bd">' +
'<form action="" method="POST" style="border: none">' +
'</form>' +
@@ -86,7 +85,7 @@
// Write a link to show the dialog
$("table#relatedEvents").append('<tr id="addEventLink"><td
colspan="4"><a href="javascript:Qubit.eventDialog.show()"><?php echo __('add
new') ?></a></td></tr>');
-
+
// Add links for editing existing events
var eventRows = $('table#relatedEvents tr').filter(function() { return
this.id.substr(0,5) == 'event' });
eventRows.each(function() {
@@ -94,11 +93,11 @@
var editLink = '<a
href="javascript:editInformationObjectEventDialog(\''+thisId+'\')"><img
src="'+$('img#imagesPencilPng').attr('src')+'" align="top" /></a> ';
$(this).find('button.delete-small').before(editLink);
});
-
+
// Initialize newEvent data store
$('body').data('cachedEvents', new Array());
$('body').data('deleteEvents', new Array());
-
+
// Attach the appendHiddenFormFields() action to the submit form
$('form#editForm').submit(function() {
appendHiddenEventFormFields($(this));
Modified: trunk/web/js/eventDialog.js
==============================================================================
--- trunk/web/js/eventDialog.js Thu Oct 22 16:01:13 2009 (r3803)
+++ trunk/web/js/eventDialog.js Thu Oct 22 16:45:35 2009 (r3804)
@@ -14,10 +14,9 @@
"endDate": null,
"endTime": null,
"informationObjectId": null,
- "actorId": null,
+ "actor": null,
"resourceTitle": null,
"resourceTypeId": null,
- "actorName": null,
"description": null,
"dateDisplay": null
}
@@ -99,6 +98,12 @@
if (dialogType.fields[fieldName].type == 'input')
{
$('table#newEvent input[name="newEvent[' + fieldName + ']"]').val('');
+
+ // For YUI autocomplete also clear yui-ac-input value
+ if (undefined != dialogType.fields[fieldName].id)
+ {
+ $('#' + dialogType.fields[fieldName].id).val('');
+ }
}
else
{
@@ -334,17 +339,8 @@
function updateInformationObjectEventList(thisEvent)
{
- // Determine the actor name to show in the creation events table
- var actorId = thisEvent.data.actorId;
- var nameDisplay = '';
- if (0 < actorId)
- {
- nameDisplay = actorId;
- }
- else if (0 < thisEvent.data.newActorName.length)
- {
- nameDisplay = thisEvent.data.newActorName;
- }
+ // Get the actor name to show in the creation events table
+ var nameDisplay = $('#newEventActor').val();
// Determine the date(s) to show in the creation events table
var dateDisplay = thisEvent.data.dateDisplay;
@@ -393,8 +389,7 @@
this.fields = {
"typeId": {"type": "select", "value": null},
"placeId": {"type": "select", "value": null},
- "actorId": {"type": "input", "value": null},
- "newActorName": {"type": "input", "value": null},
+ "actor": {"type": "input", "value": null, "id": "newEventActor"},
"startDate": {"type": "input", "value": null},
"endDate": {"type": "input", "value": null},
"dateDisplay": {"type": "input", "value": null},
@@ -407,8 +402,7 @@
this.fields.typeId.value = formData['newEvent[typeId]'];
this.fields.placeId.value = formData['newEvent[placeId]'];
- this.fields.actorId.value = formData['newEvent[actorId]'];
- this.fields.newActorName.value = formData['newEvent[newActorName]'];
+ this.fields.actor.value = formData['newEvent[actor]'];
this.fields.startDate.value = formData['newEvent[startDate]'];
this.fields.endDate.value = formData['newEvent[endDate]'];
this.fields.dateDisplay.value = formData['newEvent[dateDisplay]'];
@@ -437,8 +431,7 @@
// Move newEvent table contents into yui dialog container.
// This ensures that the standard form still works if javascript is disabled
var newEventTable = $('table#newEvent');
- newEventTable.clone().appendTo('div#eventDialog div.bd form');
- newEventTable.remove();
+ newEventTable.appendTo('div#eventDialog div.bd form');
// Instantiate the Dialog
Qubit.eventDialog = new YAHOO.widget.Dialog("eventDialog",
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---