From e73015e6e5f0e06b4eb4935b715f303245433e49 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Sat, 18 Apr 2009 03:08:34 +0000 Subject: [PATCH] BUGFIX: got drag and drop ordering of field OPTIONS rewritten in jQuery --- javascript/UserForm.js | 61 ++++++++++++++++++++++++++----------- templates/EditableOption.ss | 1 + 2 files changed, 45 insertions(+), 17 deletions(-) diff --git a/javascript/UserForm.js b/javascript/UserForm.js index 644a77a..17dd3e2 100644 --- a/javascript/UserForm.js +++ b/javascript/UserForm.js @@ -147,23 +147,50 @@ /** * Sort Fields in the Field List */ - $("#Fields_fields").sortable({ - handle : '.fieldHandler', - cursor: 'pointer', - items: 'li.EditableFormField', - placeholder: 'removed-form-field', - opacity: 0.6, - revert: true, - change : function (event, ui) { - $("#Fields_fields").sortable('refreshPositions'); - }, - update : function (event, ui) { - // get all the fields - var sort = 1; - $("li.EditableFormField").each(function() { - $(this).find(".sortHidden").val(sort++); - }); - } + $("#Fields_fields").livequery(function() { + $(this).sortable({ + handle : '.fieldHandler', + cursor: 'pointer', + items: 'li.EditableFormField', + placeholder: 'removed-form-field', + opacity: 0.6, + revert: true, + change : function (event, ui) { + $("#Fields_fields").sortable('refreshPositions'); + }, + update : function (event, ui) { + // get all the fields + var sort = 1; + $("li.EditableFormField").each(function() { + $(this).find(".sortHidden").val(sort++); + }); + } + }); + }); + + /** + * Sort Options in a Field List - Such as options in a + * dropdown field. + */ + $(".editableOptions").livequery(function() { + $(this).sortable({ + handle : '.handle', + cursor: 'pointer', + items: 'li', + placeholder: 'removed-form-field', + opacity: 0.6, + revert: true, + change : function (event, ui) { + $(this).sortable('refreshPositions'); + }, + update : function (event, ui) { + // get all the fields + var sort = 1; + $(".editableOptions li").each(function() { + $(this).find(".sortOptionHidden").val(sort++); + }); + } + }); }); }); }) diff --git a/templates/EditableOption.ss b/templates/EditableOption.ss index 1cb543d..e13c83a 100644 --- a/templates/EditableOption.ss +++ b/templates/EditableOption.ss @@ -2,6 +2,7 @@ <% _t('DRAG', 'Drag to rearrange order of options') %> $DefaultSelect + <% if isReadonly %> <% _t('LOCKED', 'These fields cannot be modified') %>