Skip to content

Instantly share code, notes, and snippets.

@zappingseb
Created October 3, 2018 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zappingseb/6f8f61963094f1e4c13437fd06d4ba31 to your computer and use it in GitHub Desktop.
Save zappingseb/6f8f61963094f1e4c13437fd06d4ba31 to your computer and use it in GitHub Desktop.
// DoubleColorPicker Input Binding
//
// Definition of a Shiny InputBinding extension to
// get the values of two color pickers.
//
// https://github.com/zappingseb/customshinyinput
// Author: Sebastian Wolf
// License: MIT
// -----------------------------------------------------
// Create a shiny input binding
// Each custom input needs to be a shiny input binding
// that is defined by the JavaScript class "Shiny" and
// using the method "InputBinding"
// The name can be chosen, here it is "DoubleColorPickerBinding"
var DoubleColorPickerBinding = new Shiny.InputBinding();
// Extend the binding with the functions seen here
$.extend(DoubleColorPickerBinding, {
// The scope defines how the element is described in HTML code
// The best way to find the scope
find: function(scope) {
return $(scope).find(".doublecolorpicker");
},
getValue: function(el) {
// todo
},
setValue: function(el, value) {
// todo
},
subscribe: function(el, callback) {
// todo
},
unsubscribe: function(el) {
// todo
}
});
// Registering the shiny input
//
// The following function call is used to tell shiny that
// there now is a new Shiny.InputBinding that it shall
// deal with and that it's functionality can be found in
// the variable "DoubleColorPickerBinding"
Shiny.inputBindings.register(DoubleColorPickerBinding);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment