diff options
author | mistic100 <mistic@piwigo.org> | 2014-07-04 07:53:45 +0000 |
---|---|---|
committer | mistic100 <mistic@piwigo.org> | 2014-07-04 07:53:45 +0000 |
commit | 314cd45f7557a211a53227af43f87c3988a58c28 (patch) | |
tree | 1c47c8c59f1b71253fe573bf72cf94b2067d366a | |
parent | f2704dcb6207a8f89fe5b1f6f2ffe6a3f9358cc6 (diff) |
fix sorting by global rank in selectize
git-svn-id: http://piwigo.org/svn/trunk@28937 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r-- | admin/themes/default/js/LocalStorageCache.js | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/admin/themes/default/js/LocalStorageCache.js b/admin/themes/default/js/LocalStorageCache.js index 214a4ffcd..1733ed85d 100644 --- a/admin/themes/default/js/LocalStorageCache.js +++ b/admin/themes/default/js/LocalStorageCache.js @@ -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) |