diff options
-rw-r--r-- | jarmon/jarmon.js | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/jarmon/jarmon.js b/jarmon/jarmon.js index 3357864..cef338b 100644 --- a/jarmon/jarmon.js +++ b/jarmon/jarmon.js @@ -1280,7 +1280,10 @@ jarmon.Chart.STACKED_OPTIONS = { /** * A selection of useful time ranges * - * This is an array of `["human description", function]` pairs. + * For the most part, this is an array of `["human description", function]` + * pairs. However, if a third member of a tuple is `===true`, then that tuple + * is used as the default option. If no tuple is identified as the default this + * way, then the default is the first tuple. * * @todo This should probably be a member of jarmon.ChartCoordinator. * @@ -1334,14 +1337,18 @@ jarmon.ChartCoordinator = function(ui, charts) { }; var options = this.ui.find('select[name="from_standard"]'); + var default_index = 0; // Select the first shortcut by default for(var i=0; i<jarmon.timeRangeShortcuts.length; i++) { options.append($('<option />').text(jarmon.timeRangeShortcuts[i][0])); + if (jarmon.timeRangeShortcuts[i][2] === true) { + default_index = i; + } } // Append a custom option for when the user selects an area of the graph options.append($('<option />').text('custom')); - // Select the first shortcut by default - options.val(jarmon.timeRangeShortcuts[0][0]); + // Select whichever timeRangeShortcut is the default + options.val(jarmon.timeRangeShortcuts[default_index][0]); options.bind('change', function(e) { // No point in updating if the user chose custom. @@ -1638,7 +1645,7 @@ jarmon.ChartCoordinator.prototype.setTimeRange = function(from, to) { }; /** - * Reset all charts and the input form to the default time range - last hour + * Reset all charts and the input form to the default time range. * * @method **/ |