Skip to content

Commit

Permalink
add constant file and list options in descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed May 18, 2021
1 parent 5c17d6b commit 3293097
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 35 deletions.
8 changes: 6 additions & 2 deletions src/components/modebar/attributes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

var constants = require('./constants');

module.exports = {
editType: 'modebar',

Expand Down Expand Up @@ -43,7 +45,8 @@ module.exports = {
'Determines which predefined modebar buttons to add.',
'Please note that these buttons will only be shown if they are',
'compatible with all trace types used in a graph.',
'Similar to `config.modeBarButtonsToAdd` option'
'Similar to `config.modeBarButtonsToAdd` option.',
'This may include *' + constants.backButtons.join('*, *') + '*.'
].join(' ')
},
remove: {
Expand All @@ -53,7 +56,8 @@ module.exports = {
editType: 'modebar',
description: [
'Determines which predefined modebar buttons to remove.',
'Similar to `config.modeBarButtonsToRemove` option'
'Similar to `config.modeBarButtonsToRemove` option.',
'This may include *' + constants.foreButtons.join('*, *') + '*.'
].join(' ')
}
};
41 changes: 41 additions & 0 deletions src/components/modebar/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'use strict';

var modeBarButtons = require('./buttons');
var buttonList = Object.keys(modeBarButtons);

var DRAW_MODES = [
'drawline',
'drawopenpath',
'drawclosedpath',
'drawcircle',
'drawrect',
'eraseshape'
];

var backButtons = [
'v1hovermode',
'hoverclosest',
'hovercompare',
'togglehover',
'togglespikelines'
].concat(DRAW_MODES);

var foreButtons = [];
var addToForeButtons = function(b) {
if(backButtons.indexOf(b._cat || b.name) !== -1) return;
// for convenience add lowercase shotname e.g. zoomin as well fullname zoomInGeo
var name = b.name;
var _cat = (b._cat || b.name).toLowerCase();
if(foreButtons.indexOf(name) === -1) foreButtons.push(name);
if(foreButtons.indexOf(_cat) === -1) foreButtons.push(_cat);
};
buttonList.forEach(function(k) {
addToForeButtons(modeBarButtons[k]);
});
foreButtons.sort();

module.exports = {
DRAW_MODES: DRAW_MODES,
backButtons: backButtons,
foreButtons: foreButtons
};
34 changes: 1 addition & 33 deletions src/components/modebar/manage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,7 @@ var isUnifiedHover = require('../fx/helpers').isUnifiedHover;

var createModeBar = require('./modebar');
var modeBarButtons = require('./buttons');
var buttonList = Object.keys(modeBarButtons);

var DRAW_MODES = [
'drawline',
'drawopenpath',
'drawclosedpath',
'drawcircle',
'drawrect',
'eraseshape'
];

var backButtons = [
'v1hovermode',
'hoverclosest',
'hovercompare',
'togglehover',
'togglespikelines'
].concat(DRAW_MODES);

var foreButtons = [];
var addToForeButtons = function(b) {
if(backButtons.indexOf(b._cat || b.name) !== -1) return;
// for convenience add lowercase shotname e.g. zoomin as well fullname zoomInGeo
var name = b.name;
var _cat = (b._cat || b.name).toLowerCase();
if(foreButtons.indexOf(name) === -1) foreButtons.push(name);
if(foreButtons.indexOf(_cat) === -1) foreButtons.push(_cat);
};
buttonList.forEach(function(k) {
addToForeButtons(modeBarButtons[k]);
});
foreButtons.sort();

var DRAW_MODES = require('./constants').DRAW_MODES;

/**
* ModeBar wrapper around 'create' and 'update',
Expand Down

0 comments on commit 3293097

Please sign in to comment.