diff options
author | winniehell <git@winniehell.de> | 2017-03-05 22:43:05 +0300 |
---|---|---|
committer | winniehell <git@winniehell.de> | 2017-03-05 23:22:40 +0300 |
commit | 572f9782d5e8d6307784b61db0dfce48f5118445 (patch) | |
tree | 11b25c46733462729e4303b26b4895d983f14df0 /app/assets/javascripts/project_variables.js | |
parent | 4cd2ab52548e89cd7259cfb7ce320fdfa203fe84 (diff) |
Remove .es6 from file extensions (!9241)
Diffstat (limited to 'app/assets/javascripts/project_variables.js')
-rw-r--r-- | app/assets/javascripts/project_variables.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/app/assets/javascripts/project_variables.js b/app/assets/javascripts/project_variables.js new file mode 100644 index 00000000000..4ee2e49306d --- /dev/null +++ b/app/assets/javascripts/project_variables.js @@ -0,0 +1,43 @@ +(() => { + const HIDDEN_VALUE_TEXT = '******'; + + class ProjectVariables { + constructor() { + this.$revealBtn = $('.js-btn-toggle-reveal-values'); + this.$revealBtn.on('click', this.toggleRevealState.bind(this)); + } + + toggleRevealState(e) { + e.preventDefault(); + + const oldStatus = this.$revealBtn.attr('data-status'); + let newStatus = 'hidden'; + let newAction = 'Reveal Values'; + + if (oldStatus === 'hidden') { + newStatus = 'revealed'; + newAction = 'Hide Values'; + } + + this.$revealBtn.attr('data-status', newStatus); + + const $variables = $('.variable-value'); + + $variables.each((_, variable) => { + const $variable = $(variable); + let newText = HIDDEN_VALUE_TEXT; + + if (newStatus === 'revealed') { + newText = $variable.attr('data-value'); + } + + $variable.text(newText); + }); + + this.$revealBtn.text(newAction); + } + } + + window.gl = window.gl || {}; + window.gl.ProjectVariables = ProjectVariables; +})(); |