-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for bookmarking the expanded/collapsed state of the whole…
… sidebar
- Loading branch information
Showing
8 changed files
with
119 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* global Shiny */ | ||
|
||
// sidebarCollapsedInputBinding | ||
// ------------------------------------------------------------------ | ||
// This keeps tracks of whether the sidebar is expanded (default) | ||
// or collapsed | ||
var sidebarCollapsedInputBinding = new Shiny.InputBinding(); | ||
$.extend(sidebarCollapsedInputBinding, { | ||
find: function(scope) { | ||
return $(scope).find('.main-sidebar').first(); | ||
}, | ||
getId: function(el) { | ||
return "sidebarCollapsed"; | ||
}, | ||
getValue: function(el) { | ||
return $(el).attr("data-collapsed"); | ||
}, | ||
setValue: function(el, value) { | ||
$(el).attr("data-collapsed", value); | ||
}, | ||
toggleValue: function(el) { | ||
var current = this.getValue(el); | ||
var newVal = (current === "true") ? "false" : "true"; | ||
this.setValue(el, newVal); | ||
}, | ||
receiveMessage: function(el, data) { | ||
if (data.hasOwnProperty('value')) | ||
this.setValue(el, data.value); | ||
}, | ||
subscribe: function(el, callback) { | ||
$(el).on('change.sidebarCollapsedInputBinding', function() { | ||
callback(); | ||
}); | ||
}, | ||
unsubscribe: function(el) { | ||
$(el).off('.sidebarCollapsedInputBinding'); | ||
} | ||
}); | ||
Shiny.inputBindings.register(sidebarCollapsedInputBinding, | ||
'shinydashboard.sidebarCollapsedInputBinding'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters