fix sorting by global rank in selectize

git-svn-id: http://piwigo.org/svn/trunk@28937 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
mistic100
2014-07-04 07:53:45 +00:00
parent f2704dcb62
commit 314cd45f75
+24 -1
View File
@@ -218,10 +218,33 @@
CategoriesCache.prototype.selectize = function($target, options) {
options = options || {};
options.filter = function(cats) {
cats.map(function(c) {
c.pos = c.global_rank.split('.');
});
cats.sort(function(a, b) {
var i = 0;
while (a.pos[i] && b.pos[i]) {
if (a.pos[i] != b.pos[i]) {
return a.pos[i] - b.pos[i];
}
i++;
}
return (!a.pos[i] && b.pos[i]) ? -1 : 1;
});
cats.map(function(c, i) {
c.pos = i;
});
return cats;
};
$target.selectize({
valueField: 'id',
labelField: 'fullname',
sortField: 'global_rank',
sortField: 'pos',
searchField: ['fullname'],
plugins: ['remove_button'],
render: AbstractSelectizer.getRender('fullname', options.lang)