Author: david
Date: 2008-11-28 18:17:25 -0800 (Fri, 28 Nov 2008)
New Revision: 1641
Added:
trunk/qubit/web/js/multiDelete.js
Modified:
trunk/qubit/apps/qubit/modules/informationobject/actions/editAction.class.php
trunk/qubit/apps/qubit/modules/informationobject/templates/editIsadSuccess.php
trunk/qubit/apps/qubit/modules/physicalobject/templates/_edit.php
Log:
Add jQuery/javascript code to:
- replace all "multiDelete" checkboxes with delete icons,
- remove delete icons from table headers (only necessary for non-javascript
degredation),
- do nice "hide" animation when one of the delete icons is clicked,
- add hidden field to form to delete clicked items when form is submitted.
(See issue #531)
Modified:
trunk/qubit/apps/qubit/modules/informationobject/actions/editAction.class.php
===================================================================
---
trunk/qubit/apps/qubit/modules/informationobject/actions/editAction.class.php
2008-11-28 23:17:58 UTC (rev 1640)
+++
trunk/qubit/apps/qubit/modules/informationobject/actions/editAction.class.php
2008-11-29 02:17:25 UTC (rev 1641)
@@ -41,6 +41,7 @@
$this->getResponse()->addJavaScript('jquery');
$this->getResponse()->addJavaScript('/vendor/drupal/misc/drupal');
$this->getResponse()->addJavaScript('multiInstanceSelect');
+ $this->getResponse()->addJavaScript('multiDelete');
//Actor (Event) Relations
$this->actorEvents = $this->informationObject->getActorEvents();
Modified:
trunk/qubit/apps/qubit/modules/informationobject/templates/editIsadSuccess.php
===================================================================
---
trunk/qubit/apps/qubit/modules/informationobject/templates/editIsadSuccess.php
2008-11-28 23:17:58 UTC (rev 1640)
+++
trunk/qubit/apps/qubit/modules/informationobject/templates/editIsadSuccess.php
2008-11-29 02:17:25 UTC (rev 1641)
@@ -3,7 +3,7 @@
<div class="pageTitle"><?php echo __('edit %1%', array('%1%' =>
sfConfig::get('app_ui_label_informationobject'))); ?></div>
-<?php echo form_tag('informationobject/updateIsad', 'multipart=true') ?>
+<?php echo form_tag('informationobject/updateIsad', array('multipart' =>
'true', 'id'=>'editForm')) ?>
<?php echo object_input_hidden_tag($informationObject, 'getId') ?>
<?php echo input_hidden_tag('collection_type_id',
QubitTerm::ARCHIVAL_MATERIAL_ID) ?>
@@ -46,18 +46,18 @@
<div class="form-item">
<table class="inline">
<tr>
- <th style="width: 90%"><?php echo __('title note(s)'); ?></th>
- <th style="width: 10%; text-align: right"><?php echo
image_tag('delete', 'align=top') ?></th>
+ <th style="width: 90%;"><?php echo __('title note(s)'); ?></th>
+ <th style="width: 10%; text-align: right"><?php echo
image_tag('delete', array('align' => 'top', 'class' => 'deleteIcon')) ?></th>
</tr>
<?php if ($titleNotes): ?>
<?php foreach ($titleNotes as $titleNote): ?>
<tr>
- <td style="width: 470">
+ <td><div class="animateNicely">
<?php echo $titleNote->getContent(array('cultureFallback' =>
'true')) ?>
- </td>
- <td style="text-align: right">
+ </div></td>
+ <td style="text-align: right;"><div class="animateNicely">
<input type="checkbox" name="delete_notes[<?php echo
$titleNote->getId() ?>]" value="delete" class="multiDelete" />
- </td>
+ </div></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
@@ -99,30 +99,24 @@
<th style="width: 35%;"><?php echo __('Name') ?></th>
<th style="width: 25%;"><?php echo __('Role').'/'.__('Event') ?></th>
<th style="width: 30%;"><?php echo __('Date(s)') ?></th>
- <th style="width: 10%; text-align: right;"><?php echo
image_tag('delete', 'align=top') ?></th>
+ <th style="width: 10%; text-align: right;"><?php echo
image_tag('delete', array('align' => 'top', 'class' => 'deleteIcon')) ?></th>
</tr>
<?php if(count($actorEvents)): ?>
<?php foreach ($actorEvents as $actorEvent): ?>
<tr>
- <?php if ($actorEvent->getActor()): ?>
- <td>
- <?php echo $actorEvent->getActor() ?>
- </td>
- <?php else: ?>
- <td></td>
- <?php endif; ?>
- <?php if ($actorEvent->getActor()): ?>
- <td>
- <?php echo $actorEvent->getType()->getRole() ?>
- </td>
- <?php else: ?>
- <td><?php echo $actorEvent->getType() ?></td>
- <?php endif; ?>
- <td><?php echo $actorEvent->getDateDisplay(array('cultureFallback'
=> 'true')) ?></td>
- <td style="text-align: right">
- <!-- <a href="javascript:editActorEventDialog(<?php echo
$actorEvent->getId()?>)"><?php echo image_tag('pencil', 'align=top') ?></a> -->
+ <td><div class="animateNicely">
+ <?php echo ($actorEvent->getActor()) ? $actorEvent->getActor() :
' ' ?>
+ </div></td>
+ <td><div class="animateNicely">
+ <?php echo ($actorEvent->getActor()) ?
$actorEvent->getType()->getRole() : $actorEvent->getType() ?>
+ </div></td>
+ <td><div class="animateNicely">
+ <?php echo $actorEvent->getDateDisplay(array('cultureFallback' =>
'true')) ?>
+ </div></td>
+ <!-- <td><a href="javascript:editActorEventDialog(<?php echo
$actorEvent->getId()?>)"><?php echo image_tag('pencil', 'align=top')
?></a></td> -->
+ <td style="text-align: right"><div class="animateNicely">
<input type="checkbox" name="delete_actor_events[<?php echo
$actorEvent->getId()?>]" value="delete" class="multiDelete" />
- </td>
+ </div></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
@@ -283,17 +277,17 @@
<table class="inline">
<tr>
<th style="width: 90%;"><?php echo __('language of material');
?></th>
- <th style="width: 10%; text-align: right;"><?php echo
image_tag('delete', 'align=top') ?></th>
+ <th style="width: 10%; text-align: right;"><?php echo
image_tag('delete', array('align' => 'top', 'class' => 'deleteIcon')) ?></th>
</tr>
<?php if ($languageCodes): ?>
<?php foreach ($languageCodes as $languageCode): ?>
<tr>
- <td>
+ <td><div class="animateNicely">
<?php echo
format_language($languageCode->getValue(array('sourceCulture'=>true))) ?>
- </td>
- <td style="text-align: right">
+ </div></td>
+ <td style="text-align: right"><div class="animateNicely">
<input type="checkbox" name="delete_properties[<?php echo
$languageCode->getId() ?>]" value="delete" class="multiDelete" />
- </td>
+ </div></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
@@ -309,17 +303,17 @@
<table class="inline">
<tr>
<th style="width: 90%;"><?php echo __('script of material'); ?></th>
- <th style="width: 10%; text-align: right;"><?php echo
image_tag('delete', 'align=top') ?></th>
+ <th style="width: 10%; text-align: right;"><?php echo
image_tag('delete', array('align' => 'top', 'class' => 'deleteIcon')) ?></th>
</tr>
<?php if ($scriptCodes): ?>
<?php foreach ($scriptCodes as $scriptCode): ?>
<tr>
- <td>
- <?php echo
format_script($scriptCode->getValue(array('sourceCulture'=>true))) ?>
- </td>
- <td style="text-align: right">
+ <td><div class="animateNicely">
+ <?php echo
format_script($scriptCode->getValue(array('sourceCulture'=>true))) ?>
+ </div></td>
+ <td style="text-align: right"><div class="animateNicely">
<input type="checkbox" name="delete_properties[<?php echo
$scriptCode->getId() ?>]" value="delete" class="multiDelete" />
- </td>
+ </div></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
@@ -378,17 +372,17 @@
<table class="inline">
<tr>
<th style="width: 90%;"><?php echo __('publication note'); ?></th>
- <th style="width: 10%; text-align: right;"><?php echo
image_tag('delete', 'align=top') ?></th>
+ <th style="width: 10%; text-align: right;"><?php echo
image_tag('delete', array('align' => 'top', 'class' => 'deleteIcon')) ?></th>
</tr>
<?php if ($publicationNotes): ?>
<?php foreach ($publicationNotes as $publicationNote): ?>
<tr>
- <td>
+ <td><div class="animateNicely">
<?php echo
nl2br($publicationNote->getContent(array('cultureFallback' => 'true'))) ?>
- </td>
- <td style="text-align: right">
+ </div></td>
+ <td style="text-align: right"><div class="animateNicely">
<input type="checkbox" name="delete_notes[<?php echo
$publicationNote->getId() ?>]" value="delete" class="multiDelete" />
- </td>
+ </div></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
@@ -409,21 +403,21 @@
<tr>
<th style="width: 65%;"><?php echo __('note'); ?></th>
<th style="width: 30%"><?php echo __('note type'); ?></th>
- <th style="width: 5%;"><?php echo image_tag('delete', 'align=top')
?></th>
+ <th style="width: 5%;"><?php echo image_tag('delete', array('align'
=> 'top', 'class' => 'deleteIcon')) ?></th>
</tr>
<?php if ($notes): ?>
- <?php foreach ($notes as $note): ?>
- <tr>
- <td>
- <?php echo nl2br($note->getContent(array('cultureFallback' =>
'true'))) ?><br/>
- <span class="note"><?php echo $note->getUser() ?>, <?php echo
$note->getUpdatedAt() ?></span>
- </td>
- <td><?php echo $note->getType() ?></td>
- <td style="text-align: center;">
- <input type="checkbox" name="delete_notes[<?php echo
$note->getId() ?>]" value="delete" class="multiDelete" />
- </td>
- </tr>
- <?php endforeach; ?>
+ <?php foreach ($notes as $note): ?>
+ <tr>
+ <td><div class="animateNicely">
+ <?php echo nl2br($note->getContent(array('cultureFallback' =>
'true'))) ?><br/>
+ <span class="note"><?php echo $note->getUser() ?>, <?php echo
$note->getUpdatedAt() ?></span>
+ </div></td>
+ <td><div class="animateNicely"><?php echo $note->getType()
?></div></td>
+ <td style="text-align: center;"><div class="animateNicely">
+ <input type="checkbox" name="delete_notes[<?php echo
$note->getId() ?>]" value="delete" class="multiDelete" />
+ </div></td>
+ </tr>
+ <?php endforeach; ?>
<?php endif; ?>
<tr valign="top">
<td><?php echo input_tag('note')?></td>
@@ -442,17 +436,17 @@
<table class="inline">
<tr>
<th style="width: 90%;"><?php echo __('subject access points');
?><span id="addSubjectAccessPointLink" style="font-weight:normal"></span></th>
- <th style="width: 10%; text-align: right;"><?php echo
image_tag('delete', 'align=top') ?></th>
+ <th style="width: 10%; text-align: right;"><?php echo
image_tag('delete', array('align' => 'top', 'class' => 'deleteIcon')) ?></th>
</tr>
<?php if ($subjectAccessPoints): ?>
<?php foreach ($subjectAccessPoints as $subject): ?>
<tr>
- <td>
+ <td><div class="animateNicely">
<?php echo $subject->getTerm() ?>
- </td>
- <td style="text-align: right">
+ </div></td>
+ <td style="text-align: right"><div class="animateNicely">
<input type="checkbox" name="delete_object_term_relations[<?php
echo $subject->getId() ?>]" value="delete" class="multiDelete" />
- </td>
+ </div></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
@@ -469,17 +463,17 @@
<table class="inline">
<tr>
<th style="width: 90%;"><?php echo __('place access points');
?><span id="addPlaceAccessPointLink" style="font-weight:normal"></span></th>
- <th style="width: 10%; text-align: right;"><?php echo
image_tag('delete', 'align=top') ?></th>
+ <th style="width: 10%; text-align: right;"><?php echo
image_tag('delete', array('align' => 'top', 'class' => 'deleteIcon')) ?></th>
</tr>
<?php if ($placeAccessPoints): ?>
<?php foreach ($placeAccessPoints as $place): ?>
<tr>
- <td>
+ <td><div class="animateNicely">
<?php echo $place->getTerm() ?>
- </td>
- <td style="text-align: right">
+ </div></td>
+ <td style="text-align: right"><div class="animateNicely">
<input type="checkbox" name="delete_object_term_relations[<?php
echo $place->getId() ?>]" value="delete" class="multiDelete" />
- </td>
+ </div></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
@@ -497,20 +491,20 @@
<tr>
<th style="width: 60%;"><?php echo __('name access points'); ?></th>
<th style="width: 30%;"><?php echo __('role'); ?></th>
- <th style="width: 10%; text-align: right;"><?php echo
image_tag('delete', 'align=top') ?></th>
+ <th style="width: 10%; text-align: right;"><?php echo
image_tag('delete', array('align' => 'top', 'class' => 'deleteIcon')) ?></th>
</tr>
<?php if ($nameAccessPoints): ?>
<?php foreach ($nameAccessPoints as $name): ?>
<tr>
- <td><?php echo $name->getActor() ?></td>
- <td><?php echo $name->getType()->getRole() ?></td>
- <td style="text-align: right">
+ <td><div class="animateNicely"><?php echo $name->getActor()
?></div></td>
+ <td><div class="animateNicely"><?php echo
$name->getType()->getRole() ?></div></td>
+ <td style="text-align: right"><div class="animateNicely">
<?php if ($name->getTypeId() == QubitTerm::SUBJECT_ID): ?>
<input type="checkbox" name="delete_actor_events[<?php echo
$name->getId() ?>]" value="delete" class="multiDelete" />
<?php else: ?>
<?php endif; ?>
- </td>
+ </div></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
@@ -569,17 +563,17 @@
<table class="inline">
<tr>
<th style="width: 90%;"><?php echo __('languages of archival
description'); ?></th>
- <th style="width: 10%; text-align: right;"><?php echo
image_tag('delete', 'align=top') ?></th>
+ <th style="width: 10%; text-align: right;"><?php echo
image_tag('delete', array('align' => 'top', 'class' => 'deleteIcon')) ?></th>
</tr>
<?php if ($descriptionLanguageCodes): ?>
<?php foreach ($descriptionLanguageCodes as $languageCode): ?>
<tr>
- <td>
+ <td><div class="animateNicely">
<?php echo
format_language($languageCode->getValue(array('sourceCulture'=>true))) ?>
- </td>
- <td style="text-align: right">
+ </div></td>
+ <td style="text-align: right"><div class="animateNicely">
<input type="checkbox" name="delete_properties[<?php echo
$languageCode->getId() ?>]" value="delete" class="multiDelete" />
- </td>
+ </div></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
@@ -595,17 +589,17 @@
<table class="inline">
<tr>
<th style="width: 90%;"><?php echo __('scripts of archival
description'); ?></th>
- <th style="width: 10%; text-align: right;"><?php echo
image_tag('delete', 'align=top') ?></th>
+ <th style="width: 10%; text-align: right;"><?php echo
image_tag('delete', array('align' => 'top', 'class' => 'deleteIcon')) ?></th>
</tr>
<?php if ($descriptionScriptCodes): ?>
<?php foreach ($descriptionScriptCodes as $scriptCode): ?>
<tr>
- <td>
+ <td><div class="animateNicely">
<?php echo
format_script($scriptCode->getValue(array('sourceCulture'=>true))) ?>
- </td>
- <td style="text-align: right">
+ </div></td>
+ <td style="text-align: right"><div class="animateNicely">
<input type="checkbox" name="delete_properties[<?php echo
$scriptCode->getId() ?>]" value="delete" class="multiDelete" />
- </td>
+ </div></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
Modified: trunk/qubit/apps/qubit/modules/physicalobject/templates/_edit.php
===================================================================
--- trunk/qubit/apps/qubit/modules/physicalobject/templates/_edit.php
2008-11-28 23:17:58 UTC (rev 1640)
+++ trunk/qubit/apps/qubit/modules/physicalobject/templates/_edit.php
2008-11-29 02:17:25 UTC (rev 1641)
@@ -4,25 +4,25 @@
<table class="inline" style="width: 98%;">
<tr>
<th colspan="2" style="width: 90%;"><?php echo __('containers'); ?></th>
- <th style="width: 5%;"><?php echo image_tag('delete', 'align=top') ?></th>
+ <th style="width: 5%;"><?php echo image_tag('delete', array('align' =>
'top', 'class' => 'deleteIcon')) ?></th>
</tr>
<?php foreach($relations as $relation): ?>
<?php $physicalObject =
QubitPhysicalObject::getById($relation->getSubjectId()); ?>
<tr>
- <td style="width: 90%">
+ <td style="width: 90%"><div class="animateNicely">
<?php if (strlen($type = $physicalObject->getType())) echo $type.': '; ?>
<b><?php echo $physicalObject->getName(array('cultureFallback' =>
'true')); ?></b>
<?php if ($location =
$physicalObject->getLocation(array('cultureFallback' => 'true'))) echo ' -
'.$location; ?>
- </td>
- <td style="width: 20px; border-top: 1px solid #cccccc;">
+ </div></td>
+ <td style="width: 20px;"><div class="animateNicely">
<?php echo link_to(image_tag('pencil', 'align=top'),
array('module' => 'physicalobject', 'action' => 'edit', 'id' =>
$physicalObject->getId()),
array('query_string' => 'next='.url_for(array('module' =>
'informationobject', 'action' => 'edit', 'id' => $informationObject->getId())))
) ?>
- </td>
- <td style="width: 20px; border-top: 1px solid #cccccc;">
+ </div></td>
+ <td style="width: 20px;"><div class="animateNicely">
<input type="checkbox" name="delete_relations[<?php echo
$relation->getId() ?>]" value="delete" class="multiDelete" />
- </td>
+ </div></td>
</tr>
<?php endforeach; ?>
</table>
Added: trunk/qubit/web/js/multiDelete.js
===================================================================
--- trunk/qubit/web/js/multiDelete.js (rev 0)
+++ trunk/qubit/web/js/multiDelete.js 2008-11-29 02:17:25 UTC (rev 1641)
@@ -0,0 +1,35 @@
+/**
+ * Replace delete checkboxes with delete icon, and dynamically hide
+ * elements marked for deletion.
+ *
+ * @param object thisElement dom <select> element to operate on
+ * @return void
+ */
+function multiDelete(thisElement, thisName)
+{
+ // Hide element
+ var parentRow = thisElement.parent('div').parent('td').parent('tr');
+ parentRow.find('td div').hide('normal', function() {
+ parentRow.remove();
+ });
+
+ // Append hidden field to delete element on form submit
+ $('form#editForm').append('<input type="hidden" name="'+thisName+'"
value="delete">');
+}
+
+/**
+ * On page load, replace "multiDelete" checkboxes with delete icons
+ */
+Drupal.behaviors.replaceMultiDelete = function (context)
+{
+ $('input[type="checkbox"].multiDelete').each(function () {
+ var deleteIcon = $('img.deleteIcon').eq(0).clone();
+ var thisName = $(this).attr('name');
+ $(this).replaceWith(deleteIcon.click(function () {
+ multiDelete($(this), thisName);
+ }));
+ });
+
+ // Remove delete icons in table headers
+ $('th img.deleteIcon').replaceWith(' ');
+}
\ No newline at end of file
Property changes on: trunk/qubit/web/js/multiDelete.js
___________________________________________________________________
Added: svn:keywords
+ Author Id Revision
Added: svn:eol-style
+ native
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---