mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
fix sorting
This commit is contained in:
parent
363c2f702e
commit
0ff840dc48
@ -31,7 +31,7 @@
|
|||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
||||||
(function($) {
|
(function($) {
|
||||||
var comp;
|
var comp, by;
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
initEvents();
|
initEvents();
|
||||||
@ -93,7 +93,7 @@
|
|||||||
Set comp, which is a comparator function used for sorting and
|
Set comp, which is a comparator function used for sorting and
|
||||||
inserting comments into the list.
|
inserting comments into the list.
|
||||||
*/
|
*/
|
||||||
function setComparator(by) {
|
function setComparator() {
|
||||||
// If the first three letters are "asc", sort in ascending order
|
// If the first three letters are "asc", sort in ascending order
|
||||||
// and remove the prefix.
|
// and remove the prefix.
|
||||||
if (by.substring(0,3) == 'asc') {
|
if (by.substring(0,3) == 'asc') {
|
||||||
@ -106,7 +106,7 @@
|
|||||||
|
|
||||||
// Reset link styles and format the selected sort option.
|
// Reset link styles and format the selected sort option.
|
||||||
$('a.sel').attr('href', '#').removeClass('sel');
|
$('a.sel').attr('href', '#').removeClass('sel');
|
||||||
$('#' + by).removeAttr('href').addClass('sel');
|
$('a.' + by).removeAttr('href').addClass('sel');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -114,7 +114,7 @@
|
|||||||
the sortBy cookie, use those, otherwise use the default.
|
the sortBy cookie, use those, otherwise use the default.
|
||||||
*/
|
*/
|
||||||
function initComparator() {
|
function initComparator() {
|
||||||
var by = 'rating'; // Default to sort by rating.
|
by = 'rating'; // Default to sort by rating.
|
||||||
// If the sortBy cookie is set, use that instead.
|
// If the sortBy cookie is set, use that instead.
|
||||||
if (document.cookie.length > 0) {
|
if (document.cookie.length > 0) {
|
||||||
var start = document.cookie.indexOf('sortBy=');
|
var start = document.cookie.indexOf('sortBy=');
|
||||||
@ -127,7 +127,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setComparator(by);
|
setComparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -139,6 +139,7 @@
|
|||||||
var context = $.extend({id: id}, opts);
|
var context = $.extend({id: id}, opts);
|
||||||
var popup = $(renderTemplate(popupTemplate, context)).hide();
|
var popup = $(renderTemplate(popupTemplate, context)).hide();
|
||||||
popup.find('textarea[name="proposal"]').hide();
|
popup.find('textarea[name="proposal"]').hide();
|
||||||
|
popup.find('a.' + by).addClass('sel');
|
||||||
var form = popup.find('#cf' + id);
|
var form = popup.find('#cf' + id);
|
||||||
form.submit(function(event) {
|
form.submit(function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@ -381,13 +382,12 @@
|
|||||||
*/
|
*/
|
||||||
function handleReSort(link) {
|
function handleReSort(link) {
|
||||||
var classes = link.attr('class').split(/\s+/);
|
var classes = link.attr('class').split(/\s+/);
|
||||||
var by = '';
|
|
||||||
for (var i=0; i<classes.length; i++) {
|
for (var i=0; i<classes.length; i++) {
|
||||||
if (classes[i] != 'sort_option') {
|
if (classes[i] != 'sort_option') {
|
||||||
by = classes[i];
|
by = classes[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setComparator(by);
|
setComparator();
|
||||||
// Save/update the sortBy cookie.
|
// Save/update the sortBy cookie.
|
||||||
var expiration = new Date();
|
var expiration = new Date();
|
||||||
expiration.setDate(expiration.getDate() + 365);
|
expiration.setDate(expiration.getDate() + 365);
|
||||||
@ -739,7 +739,7 @@
|
|||||||
</p>\
|
</p>\
|
||||||
</form>\
|
</form>\
|
||||||
<h3 id="cn<%id%>">loading comments... <img src="<%loadingImage%>" alt="" /></h3>\
|
<h3 id="cn<%id%>">loading comments... <img src="<%loadingImage%>" alt="" /></h3>\
|
||||||
<ul id="cl<%id%>"></ul>\
|
<ul id="cl<%id%>" class="comment_ul"></ul>\
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user