From 92b6d7bfd2019a52d5cd3006cd5fa7183fe5ba3e Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Thu, 14 Aug 2014 09:36:36 -0400 Subject: [PATCH] Sort tags for consistent display MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This ensures that the tag list will be consistent rather than based on the browser’s internal hash implementation. It also allows a custom override function to be configured when simple alphabetic sorting is not sufficient. Closes #342 Closes #505 --- source/js/VMM.Timeline.TimeNav.js | 3 +++ source/js/VMM.Timeline.js | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/source/js/VMM.Timeline.TimeNav.js b/source/js/VMM.Timeline.TimeNav.js index 491829f..07d79e8 100644 --- a/source/js/VMM.Timeline.TimeNav.js +++ b/source/js/VMM.Timeline.TimeNav.js @@ -1545,6 +1545,9 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin // CREATE TAGS tags = VMM.Util.deDupeArray(tags); + + config.tagSortFunction(tags); + if (tags.length > 3) { config.nav.rows.current = config.nav.rows.half; } else { diff --git a/source/js/VMM.Timeline.js b/source/js/VMM.Timeline.js index f75b4d0..1b1022a 100755 --- a/source/js/VMM.Timeline.js +++ b/source/js/VMM.Timeline.js @@ -135,7 +135,12 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') { ease: "easeInOutExpo", duration: 1000, gmap_key: "", - language: VMM.Language + language: VMM.Language, + tagSortFunction: function (arr) { + arr.sort(function (a, b) { + return a.localeCompare(b); + }) + } }; if ( w != null && w != "") {