Added sorting icons.
Refactored determination of sortability of classes referenced as sortable foreign keys in admin in a more reliable way.
This commit is contained in:
@@ -42,7 +42,16 @@
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.sortable-help-text {
|
||||
color: #999;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.sortable a:hover
|
||||
{
|
||||
color: #003366;
|
||||
}
|
||||
|
||||
.sortable .fa {
|
||||
margin-right: 7px;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
.sortable.has_original {
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
.sortable .inline-related .module.aligned .fa,
|
||||
.sortable.inline-group .module .fa {
|
||||
display: block;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.sortable .inline-related .module.aligned .fa {
|
||||
margin: 9px 10px 0 0;
|
||||
}
|
||||
|
||||
.sortable.inline-group .module .fa {
|
||||
margin: 34px -10px 0 10px;
|
||||
}
|
||||
|
||||
@@ -8,17 +8,36 @@
|
||||
items : 'li',
|
||||
stop : function(event, ui)
|
||||
{
|
||||
var indexes = [];
|
||||
ui.item.parent().children('li').each(function(i)
|
||||
var indexes = [],
|
||||
lineItems = ui.item.parent().find('> li');
|
||||
|
||||
lineItems.each(function(i)
|
||||
{
|
||||
indexes.push($(this).find(':hidden[name="pk"]').val());
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: ui.item.find('a.admin_sorting_url').attr('href'),
|
||||
type: 'POST',
|
||||
data: { indexes: indexes.join(',') },
|
||||
success: function()
|
||||
{
|
||||
// set icons based on position
|
||||
lineItems.each(function(index, element) {
|
||||
var icon = $(element).find('> a .fa');
|
||||
icon.removeClass('fa-sort-desc fa-sort-asc fa-sort');
|
||||
|
||||
if (index === 0) {
|
||||
icon.addClass('fa fa-sort-desc');
|
||||
}
|
||||
else if (index == lineItems.length - 1) {
|
||||
icon.addClass('fa fa-sort-asc');
|
||||
}
|
||||
else {
|
||||
icon.addClass('fa fa-sort');
|
||||
}
|
||||
});
|
||||
|
||||
ui.item.effect('highlight', {}, 1000);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -41,7 +41,24 @@
|
||||
data: { indexes : indexes.join(',') },
|
||||
success: function() {
|
||||
var fieldsets = ui.item.find('fieldset'),
|
||||
highlightedSelector = fieldsets.filter('.collapsed').length === fieldsets.length ? 'h3' : '.form-row';
|
||||
highlightedSelector = fieldsets.filter('.collapsed').length === fieldsets.length ? 'h3' : '.form-row',
|
||||
icons = ui.item.parent().find(highlightedSelector).find('.fa');
|
||||
|
||||
// set icons based on position
|
||||
icons.removeClass('fa-sort-desc fa-sort-asc fa-sort');
|
||||
icons.each(function(index, element) {
|
||||
var icon = $(element);
|
||||
if (index === 0) {
|
||||
icon.addClass('fa fa-sort-desc');
|
||||
}
|
||||
else if (index == icons.length - 1) {
|
||||
icon.addClass('fa fa-sort-asc');
|
||||
}
|
||||
else {
|
||||
icon.addClass('fa fa-sort');
|
||||
}
|
||||
});
|
||||
|
||||
ui.item.find(highlightedSelector).effect('highlight', {}, 1000);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -38,7 +38,23 @@
|
||||
type: 'POST',
|
||||
data: { indexes : indexes.join(',') },
|
||||
success: function() {
|
||||
//highlight sorted row, then re-stripe table
|
||||
// set icons based on position
|
||||
var icons = ui.item.parent().find('.fa');
|
||||
icons.removeClass('fa-sort-desc fa-sort-asc fa-sort');
|
||||
icons.each(function(index, element) {
|
||||
var icon = $(element);
|
||||
if (index === 0) {
|
||||
icon.addClass('fa fa-sort-desc');
|
||||
}
|
||||
else if (index == icons.length - 1) {
|
||||
icon.addClass('fa fa-sort-asc');
|
||||
}
|
||||
else {
|
||||
icon.addClass('fa fa-sort');
|
||||
}
|
||||
});
|
||||
|
||||
// highlight sorted row, then re-stripe table
|
||||
ui.item.effect('highlight', {}, 1000);
|
||||
tabular_inline_rows.removeClass('row1 row2');
|
||||
$('.tabular table tbody tr:odd').addClass('row2');
|
||||
|
||||
Reference in New Issue
Block a user