From f2b8361ec1da7cd9f53379df0b214181b6c31b53 Mon Sep 17 00:00:00 2001 From: manolobevia Date: Mon, 21 Nov 2011 19:33:50 +0000 Subject: [PATCH] NIHVIVO-3184: Made some changes so the user can drag and drop the webpages for reordering. The ajax calls responsible for the reorder fails. --- .../forms/css/manageWebpagesForIndividual.css | 49 ++++ .../edit/forms/images/sortable_icon.png | Bin 0 -> 234 bytes .../forms/js/manageWebpagesForIndividual.js | 226 ++++++++++++++++++ .../forms/manageWebpagesForIndividual.ftl | 14 +- 4 files changed, 283 insertions(+), 6 deletions(-) create mode 100644 productMods/templates/freemarker/edit/forms/css/manageWebpagesForIndividual.css create mode 100644 productMods/templates/freemarker/edit/forms/images/sortable_icon.png create mode 100644 productMods/templates/freemarker/edit/forms/js/manageWebpagesForIndividual.js diff --git a/productMods/templates/freemarker/edit/forms/css/manageWebpagesForIndividual.css b/productMods/templates/freemarker/edit/forms/css/manageWebpagesForIndividual.css new file mode 100644 index 00000000..1975a818 --- /dev/null +++ b/productMods/templates/freemarker/edit/forms/css/manageWebpagesForIndividual.css @@ -0,0 +1,49 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +#webpageList { + margin-left: 0; +} + +#webpageList li { + list-style: none; + margin-bottom: .75em; +} + +/* Use class dd rather than jQuery UI's class ui-sortable, so that we can remove +the class if there's fewer than one author. We don't want to remove the ui-sortable +class, in case we want to re-enable DD without a page reload. */ +#webpageList.dd li { + padding-left: 1em; + background: url("../images/sortable_icon.png") no-repeat left center; + cursor: move; +} + +#webpageList .webpageName { + display: inline-block; + width: 15em; +} + +#addAndCancelLinks { + margin-top: 1.5em; +} + +#returnToIndividual { + margin-left: 2em; +} + +#showAddForm a:hover.cancel { + color: #fff; + background: #f70; +} + +#showAddForm a:hover.cancel { + color: #fff; + background: #f70; +} + +#webpageList a:link.remove, +#webpageList a:visited.remove, +#webpageList a:hover.remove { + color: #f70; + background: #fff; +} diff --git a/productMods/templates/freemarker/edit/forms/images/sortable_icon.png b/productMods/templates/freemarker/edit/forms/images/sortable_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..8cae70f7c166b3b40dbe1980d5e53486fbb69d5e GIT binary patch literal 234 zcmeAS@N?(olHy`uVBq!ia0vp^Y(UJz!3-qJI&EZtlw^r(L`iUdT1k0gQ7VIDN`6wR zf@f}GdTLN=VoGJ<$y6JlBCPGL(%Czz7PJf8P*^m@;iHU`^~Al~bu-?^tuQq`c5$}H|4q+gwtwZD&%n%3vW4kj T;NeC`pg9blu6{1-oD!M 0 && ! removeLast) { + manageWebpages.reorder(); + } + + // If fewer than two webpages remaining, disable drag-drop + if (numWebpages < 2) { + manageWebpages.disableDD(); + } + }); + + } else { + alert('Error processing request: web page not removed'); + } + } + }); + }, + + // Disable DD and associated cues if only one item remains + disableDD: function() { + var webpages = $('#webpageList'); + + $('#webpageList').sortable({ disable: true } ) + /* Use class dd rather than jQuery UI's class ui-sortable, so that we can remove + * the class if there's fewer than one webpage. We don't want to remove the ui-sortable + * class, in case we want to re-enable DD without a page reload (e.g., if implementing + * adding a webpage via Ajax request). + */ + .removeClass('dd'); + + $('.webpageName').removeAttr('title'); + } + +}; + +$(document).ready(function() { + manageWebpages.onLoad(); +}); diff --git a/productMods/templates/freemarker/edit/forms/manageWebpagesForIndividual.ftl b/productMods/templates/freemarker/edit/forms/manageWebpagesForIndividual.ftl index 6983f1f5..aaec2f41 100644 --- a/productMods/templates/freemarker/edit/forms/manageWebpagesForIndividual.ftl +++ b/productMods/templates/freemarker/edit/forms/manageWebpagesForIndividual.ftl @@ -2,10 +2,10 @@ <#-- Custom form for managing web pages for individuals --> -<#if (editConfiguration.pageData.webpages?size > 0) > - <#assign ulClass=""> -<#else> +<#if (editConfiguration.pageData.webpages?size > 1) > <#assign ulClass="class='dd'"> +<#else> + <#assign ulClass=""> <#assign baseEditWebpageUrl=editConfiguration.pageData.baseEditWebpageUrl!"baseEditWebpageUrl is undefined"> @@ -46,9 +46,9 @@ + @@ -70,8 +70,10 @@ var customFormData = { ${stylesheets.add('', - '')} + '', + '')} ${scripts.add('', + '', '', '')} \ No newline at end of file