Sorting and filtering of lists working (except file formats)
Refactored and bugfixing show_cover Refactored import of helper in web.py Fix for displaying /me (gettext) throwing error 500 Fix get search results throwing error 500 Fix routing books_list for python2.7 Fix for "me" and "settings" pages Update sidebarview and list view
This commit is contained in:
+133
-11
@@ -16,23 +16,88 @@
|
||||
*/
|
||||
|
||||
var direction = 0; // Descending order
|
||||
var sort = 0; // Show sorted entries
|
||||
|
||||
$("#sort_name").click(function() {
|
||||
var count = 0;
|
||||
var index = 0;
|
||||
var store;
|
||||
// Append 2nd half of list to first half for easier processing
|
||||
var cnt = $("#second").contents();
|
||||
$("#list").append(cnt);
|
||||
// Count no of elements
|
||||
var listItems = $('#list').children(".row");
|
||||
var listlength = listItems.length;
|
||||
// check for each element if its Starting character matches
|
||||
$(".row").each(function() {
|
||||
if ( sort === 1) {
|
||||
store = this.attributes["data-name"];
|
||||
} else {
|
||||
store = this.attributes["data-id"];
|
||||
}
|
||||
$(this).find('a').html(store.value);
|
||||
if($(this).css("display") != "none") {
|
||||
count++;
|
||||
}
|
||||
});
|
||||
/*listItems.sort(function(a,b){
|
||||
return $(a).children()[1].innerText.localeCompare($(b).children()[1].innerText)
|
||||
});*/
|
||||
// Find count of middle element
|
||||
if (count > 20) {
|
||||
var middle = parseInt(count / 2) + (count % 2);
|
||||
// search for the middle of all visibe elements
|
||||
$(".row").each(function() {
|
||||
index++;
|
||||
if($(this).css("display") != "none") {
|
||||
middle--;
|
||||
if (middle <= 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
// Move second half of visible elements
|
||||
$("#second").append(listItems.slice(index, listlength));
|
||||
}
|
||||
sort = (sort + 1) % 2;
|
||||
});
|
||||
|
||||
$("#desc").click(function() {
|
||||
if (direction === 0) {
|
||||
return;
|
||||
}
|
||||
var index = 0;
|
||||
var list = $('#list');
|
||||
var second = $('#second');
|
||||
// var cnt = ;
|
||||
list.append(second.contents());
|
||||
var listItems = list.children(".row");
|
||||
var reversed, elementLength, middle;
|
||||
Array.prototype.push.apply(listItems,second.children(".row"))
|
||||
reversed = listItems.get().reverse();
|
||||
elementLength = reversed.length;
|
||||
// Find count of middle element
|
||||
var count = $(".row:visible").length;
|
||||
if (count > 20) {
|
||||
var middle = parseInt(count / 2) + (count % 2);
|
||||
|
||||
middle = parseInt(elementLength / 2) + (elementLength % 2);
|
||||
//var middle = parseInt(count / 2) + (count % 2);
|
||||
// search for the middle of all visible elements
|
||||
$(reversed).each(function() {
|
||||
index++;
|
||||
if($(this).css("display") != "none") {
|
||||
middle--;
|
||||
if (middle <= 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
list.append(reversed.slice(0, middle));
|
||||
second.append(reversed.slice(middle,elementLength));
|
||||
list.append(reversed.slice(0, index));
|
||||
second.append(reversed.slice(index,elementLength));
|
||||
}
|
||||
else {
|
||||
list.append(reversed.slice(0, elementLength));
|
||||
}
|
||||
direction = 0;
|
||||
});
|
||||
|
||||
@@ -41,34 +106,91 @@ $("#asc").click(function() {
|
||||
if (direction === 1) {
|
||||
return;
|
||||
}
|
||||
var index = 0;
|
||||
var list = $("#list");
|
||||
var second = $('#second');
|
||||
list.append(second.contents());
|
||||
var listItems = list.children(".row");
|
||||
Array.prototype.push.apply(listItems,second.children(".row"));
|
||||
reversed = listItems.get().reverse();
|
||||
elementLength = reversed.length;
|
||||
middle = parseInt(elementLength / 2) + (elementLength % 2);
|
||||
|
||||
list.append(reversed.slice(0, middle));
|
||||
second.append(reversed.slice(middle,elementLength));
|
||||
// Find count of middle element
|
||||
var count = $(".row:visible").length;
|
||||
if (count > 20) {
|
||||
var middle = parseInt(count / 2) + (count % 2);
|
||||
|
||||
//var middle = parseInt(count / 2) + (count % 2);
|
||||
// search for the middle of all visible elements
|
||||
$(reversed).each(function() {
|
||||
index++;
|
||||
if($(this).css("display") != "none") {
|
||||
middle--;
|
||||
if (middle <= 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// middle = parseInt(elementLength / 2) + (elementLength % 2);
|
||||
|
||||
list.append(reversed.slice(0, index));
|
||||
second.append(reversed.slice(index,elementLength));
|
||||
} else {
|
||||
list.append(reversed.slice(0, elementLength));
|
||||
}
|
||||
direction = 1;
|
||||
});
|
||||
|
||||
$("#all").click(function() {
|
||||
$(".row").each(function() {
|
||||
var cnt = $("#second").contents();
|
||||
$("#list").append(cnt);
|
||||
// Find count of middle element
|
||||
var listItems = $('#list').children(".row");
|
||||
var listlength = listItems.length;
|
||||
var middle = parseInt(listlength / 2) + (listlength % 2);
|
||||
// go through all elements and make them visible
|
||||
listItems.each(function() {
|
||||
$(this).show();
|
||||
});
|
||||
// Move second half of all elements
|
||||
if (listlength > 20) {
|
||||
$("#second").append(listItems.slice(middle,listlength));
|
||||
}
|
||||
});
|
||||
|
||||
$(".char").click(function() {
|
||||
var character = this.innerText;
|
||||
|
||||
var count = 0;
|
||||
var index = 0;
|
||||
// Append 2nd half of list to first half for easier processing
|
||||
var cnt = $("#second").contents();
|
||||
$("#list").append(cnt);
|
||||
// Count no of elements
|
||||
var listItems = $('#list').children(".row");
|
||||
var listlength = listItems.length;
|
||||
// check for each element if its Starting character matches
|
||||
$(".row").each(function() {
|
||||
if (this.attributes["data-id"].value.charAt(0).toUpperCase() !== character) {
|
||||
$(this).hide();
|
||||
} else {
|
||||
$(this).show();
|
||||
count++;
|
||||
}
|
||||
});
|
||||
|
||||
if (count > 20) {
|
||||
// Find count of middle element
|
||||
var middle = parseInt(count / 2) + (count % 2);
|
||||
// search for the middle of all visibe elements
|
||||
$(".row").each(function() {
|
||||
index++;
|
||||
if($(this).css("display") != "none") {
|
||||
middle--;
|
||||
if (middle <= 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
// Move second half of visible elements
|
||||
$("#second").append(listItems.slice(index,listlength));
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user