NIHVIVO-2232 Menu items can now be reordered. Brace yourself.
This commit is contained in:
parent
a0f8144ee8
commit
2daad2b8b1
2 changed files with 5 additions and 29 deletions
|
@ -35,16 +35,12 @@ var menuManagement = {
|
||||||
this.menuItemsList.sortable({
|
this.menuItemsList.sortable({
|
||||||
cursor: 'move',
|
cursor: 'move',
|
||||||
update: function(event, ui) {
|
update: function(event, ui) {
|
||||||
alert("Congrats! You just reordered a menu item. (not really)");
|
menuManagement.reorderMenuItems(event, ui);
|
||||||
// Once we figure out how the editing will work, we'll call reorderMenuItems
|
|
||||||
// and get rid of the debug alert.
|
|
||||||
// menuManagement.reorderMenutItems(event, ui);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Reorder menu items. Called after menu item drag-and-drop
|
// Reorder menu items. Called after menu item drag-and-drop
|
||||||
// This is all make-believe at the moment. Just an example to demonstrate to Huda how this could work.
|
|
||||||
reorderMenuItems: function(event, ui) {
|
reorderMenuItems: function(event, ui) {
|
||||||
var menuItems = $('li.menuItem').map(function(index, el) {
|
var menuItems = $('li.menuItem').map(function(index, el) {
|
||||||
return $(this).data('menuItemUri');
|
return $(this).data('menuItemUri');
|
||||||
|
@ -66,9 +62,7 @@ var menuManagement = {
|
||||||
// Set the new position for this element. The only function of this value
|
// Set the new position for this element. The only function of this value
|
||||||
// is so we can reset an element to its original position in case reordering fails.
|
// is so we can reset an element to its original position in case reordering fails.
|
||||||
menuManagement.setPosition(this, pos);
|
menuManagement.setPosition(this, pos);
|
||||||
});
|
});
|
||||||
// Set the form rank field value.
|
|
||||||
$('#rank').val(pos + 1);
|
|
||||||
},
|
},
|
||||||
error: function(request, status, error) {
|
error: function(request, status, error) {
|
||||||
// ui is undefined after removal of a menu item.
|
// ui is undefined after removal of a menu item.
|
||||||
|
@ -128,20 +122,6 @@ var menuManagement = {
|
||||||
});
|
});
|
||||||
|
|
||||||
return matchingMenuItem;
|
return matchingMenuItem;
|
||||||
},
|
|
||||||
|
|
||||||
// Event listeners
|
|
||||||
|
|
||||||
// Disable drag-n-drop and associated cues if only one menu item remains
|
|
||||||
// Good chance we won't need this if Huda's able to hook into standard delete for n3 editing (loads confirmation in separate page)
|
|
||||||
disableMenuItemsDD: function() {
|
|
||||||
var menuItems = this.menuItemsList.children('li');
|
|
||||||
|
|
||||||
this.menuItemsList.sortable({ disable: true } );
|
|
||||||
|
|
||||||
this.menuItemsList.removeClass('dragNdrop');
|
|
||||||
|
|
||||||
menuItems.removeAttr('title');
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
<#-- List the menu items -->
|
<#-- List the menu items -->
|
||||||
<ul class="menuItems">
|
<ul class="menuItems">
|
||||||
<#list hasElement.statements as statement>
|
<#list hasElement.statements as statement>
|
||||||
<li class="menuItem"><#include "${hasElement.template}"> <span class="controls"><@p.editingLinks "hasElement" statement editable /></span></li>
|
<li class="menuItem" id="order_${statement_index}"><#include "${hasElement.template}"> <span class="controls"><@p.editingLinks "hasElement" statement editable /></span></li>
|
||||||
</#list>
|
</#list>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
@ -37,13 +37,9 @@ ${headScripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
// <#-- We need the controller to provide ${reorderUrl}. This is where ajax request will be sent on drag-n-drop events. -->
|
// <#-- We need the controller to provide ${reorderUrl}. This is where ajax request will be sent on drag-n-drop events. -->
|
||||||
var menuManagementData = {
|
var menuManagementData = {
|
||||||
// <#-- reorderUrl: '${reorderUrl}', -->
|
reorderUrl: '${reorderUrl}',
|
||||||
positionPredicate: '${positionPredicate}'
|
positionPredicate: '${positionPredicate}'
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<#-- Since the individual page can currently be viewed by anonymous users, only invoke sortable if logged in for now
|
${scripts.add('<script type="text/javascript" src="${urls.base}/js/individual/menuManagement.js"></script>')}
|
||||||
Jim is working on this (see NIHVIVO-2749) -->
|
|
||||||
<#if editable>
|
|
||||||
${scripts.add('<script type="text/javascript" src="${urls.base}/js/individual/menuManagement.js"></script>')}
|
|
||||||
</#if>
|
|
Loading…
Add table
Reference in a new issue