mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
BUGFIX: fixed sortable fields (again) not working on initial page load or when accessing a page directly. BUGFIX: fixed typo of livequery to live.
This commit is contained in:
parent
e7ba58970f
commit
4e6a9ec412
@ -5,71 +5,57 @@
|
|||||||
*/
|
*/
|
||||||
(function($) {
|
(function($) {
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the Field sortable
|
|
||||||
*/
|
|
||||||
set_sortable();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the sortable properties of the form as a function
|
* Update the sortable properties of the form as a function
|
||||||
* since the application will need to refresh the UI dynamically
|
* since the application will need to refresh the UI dynamically
|
||||||
*/
|
*/
|
||||||
function set_sortable() {
|
function update_sortable() {
|
||||||
/**
|
$("#Fields_fields").sortable({
|
||||||
* Sort Fields in the Field List
|
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) {
|
||||||
|
var sort = 1;
|
||||||
|
|
||||||
$("#Fields_fields").sortable({
|
$("li.EditableFormField").each(function() {
|
||||||
handle: '.fieldHandler',
|
$(this).find(".sortHidden").val(sort++);
|
||||||
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) {
|
|
||||||
update_fieldsSortingOrder();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
$(".editableOptions").sortable({
|
||||||
* Sort Options in a Field List - Such as options in a
|
handle: '.handle',
|
||||||
* dropdown field.
|
cursor:'pointer',
|
||||||
*
|
items: 'li',
|
||||||
*/
|
placeholder: 'removed-form-field',
|
||||||
$(".editableOptions").sortable({
|
opacity: 0.6,
|
||||||
handle: '.handle',
|
revert: true,
|
||||||
cursor:'pointer',
|
change : function (event, ui) {
|
||||||
items: 'li',
|
$(this).sortable('refreshPositions');
|
||||||
placeholder: 'removed-form-field',
|
},
|
||||||
opacity: 0.6,
|
update : function (event, ui) {
|
||||||
revert: true,
|
var sort = 1;
|
||||||
change : function (event, ui) {
|
$(".editableOptions li").each(function() {
|
||||||
$(this).sortable('refreshPositions');
|
$(this).find(".sortOptionHidden").val(sort++);
|
||||||
},
|
});
|
||||||
update : function (event, ui) {
|
}
|
||||||
update_editableOptionsSortingOrder();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_fieldsSortingOrder(){
|
update_sortable();
|
||||||
var sort = 1;
|
|
||||||
$("li.EditableFormField").each(function() {
|
/**
|
||||||
$(this).find(".sortHidden").val(sort++);
|
* Workaround for not refreshing the sort
|
||||||
});
|
*/
|
||||||
}
|
$(".fieldHandler").live('hover', function() {
|
||||||
|
update_sortable();
|
||||||
function update_editableOptionsSortingOrder(){
|
})
|
||||||
var sort = 1;
|
|
||||||
$(".editableOptions li").each(function() {
|
|
||||||
$(this).find(".sortOptionHidden").val(sort++);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/*--------------------- SUBMISSIONS ------------------------ */
|
/*--------------------- SUBMISSIONS ------------------------ */
|
||||||
|
|
||||||
@ -149,8 +135,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//update_sortable();
|
$("#Fields_fields").sortable('refresh');
|
||||||
update_fieldsSortingOrder();
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@ -251,9 +236,6 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//update_sortable();
|
|
||||||
update_editableOptionsSortingOrder();
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -274,7 +256,7 @@
|
|||||||
/**
|
/**
|
||||||
* Custom Rules Interface
|
* Custom Rules Interface
|
||||||
*/
|
*/
|
||||||
$(".customRules .conditionOption").livequery('change',function(){
|
$(".customRules .conditionOption").live('change',function(){
|
||||||
var valueInput = $(this).siblings(".ruleValue");
|
var valueInput = $(this).siblings(".ruleValue");
|
||||||
if($(this).val() != "" && $(this).val() != "IsBlank" && $(this).val() != "IsNotBlank") {
|
if($(this).val() != "" && $(this).val() != "IsBlank" && $(this).val() != "IsNotBlank") {
|
||||||
valueInput.removeClass("hidden");
|
valueInput.removeClass("hidden");
|
||||||
@ -326,8 +308,6 @@
|
|||||||
// append to the list
|
// append to the list
|
||||||
currentRules.append(newRule);
|
currentRules.append(newRule);
|
||||||
|
|
||||||
//update_sortable();
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user