Skip to content

Commit

Permalink
ui/stats: Add sticky toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
sogehige committed Jun 12, 2018
1 parent f623d76 commit 737eddc
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions libs/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ function Panel () {
global.configuration.register('theme', 'core.theme', 'string', 'light')
global.configuration.register('percentage', 'core.percentage', 'bool', true)
global.configuration.register('shortennumbers', 'core.no-response-bool', 'bool', true)
global.configuration.register('stickystats', 'core.no-response-bool', 'bool', false)

this.addMenu({category: 'settings', name: 'systems', id: 'systems'})

Expand Down
36 changes: 36 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ <h6 class="dropdown-header">UI</h6>
<i class="far fa-check-square" aria-hidden="true"></i>
Shorten long numbers: 10000 => 10k
</button>
<button class="dropdown-item" id="sticky-btn" data-sticky="true" onclick="switchSticky()">
<i class="far fa-check-square" aria-hidden="true"></i>
Keep stats sticky on scroll
</button>
<button class="dropdown-item" id="stats-btn" data-show-stats="true" onclick="switchStats()">
<i class="far fa-check-square" aria-hidden="true"></i>
<span data-lang="stats-panel.show">Quick stats</span>
Expand Down Expand Up @@ -487,6 +491,11 @@ <h2>
btn.data('switchShortenNumbers', !data.shortennumber)
switchShortenNumbers(false)

/* STICKY BUTTON */
var btn = $('#sticky-btn')
btn.data('switchSticky', !data.stickystats)
switchSticky(false)

/* ME BUTTON */
var btn = $('#me-btn')
btn.data('sendWithMe', !data.sendWithMe)
Expand Down Expand Up @@ -1223,6 +1232,33 @@ <h2>
}
}

var switchSticky = function (update = true) {
var btn = $('#sticky-btn')
btn.data('switchSticky', _.isString(btn.data('switchSticky')) ? true : btn.data('switchSticky'))

if (btn.data('switchSticky')) {
btn.children('i').removeClass().addClass('far fa-square')
} else {
btn.children('i').removeClass().addClass('far fa-check-square')
}

btn.data('switchSticky', !btn.data('switchSticky'))

if (btn.data('switchSticky')) {
$('#quickStatsApp').addClass('sticky-top')
$('#quickStatsApp').css('top', '50px')
} else $('#quickStatsApp').removeClass('sticky-top')

if (update) {
console.debug('EMIT [saveConfiguration]', {
'stickystats': btn.data('switchSticky')
})
socket.emit('saveConfiguration', {
'stickystats': btn.data('switchSticky')
})
}
}

var switchMe = function (update = true) {
var btn = $('#me-btn')
btn.data('sendWithMe', _.isString(btn.data('sendWithMe')) ? true : btn.data('sendWithMe'))
Expand Down

0 comments on commit 737eddc

Please sign in to comment.