From 1b5f3d320358366eec572263fc84aebab0f899a7 Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Thu, 17 Oct 2013 22:50:47 +0000 Subject: [PATCH] Added togglebutton group --- .../static/notebook/js/widgets/selection.js | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/IPython/html/static/notebook/js/widgets/selection.js b/IPython/html/static/notebook/js/widgets/selection.js index e4eedb54d..44dfe0345 100644 --- a/IPython/html/static/notebook/js/widgets/selection.js +++ b/IPython/html/static/notebook/js/widgets/selection.js @@ -63,6 +63,7 @@ var DropdownView = IPython.WidgetView.extend({ }); IPython.notebook.widget_manager.register_widget_view('DropdownView', DropdownView); + var RadioButtonView = IPython.WidgetView.extend({ // Called when view is rendered. @@ -126,3 +127,68 @@ var RadioButtonView = IPython.WidgetView.extend({ }); IPython.notebook.widget_manager.register_widget_view('RadioButtonView', RadioButtonView); + + +var ToggleButtonView = IPython.WidgetView.extend({ + + // Called when view is rendered. + render : function(){ + this.$el + .html('') + .addClass(this.model.comm.comm_id); + this.$buttongroup = $('
') + .addClass('btn-group') + .attr('data-toggle', 'buttons-radio') + .appendTo(this.$el); + this.update(); + }, + + // Handles: Backend -> Frontend Sync + // Frontent -> Frontend Sync + update : function(){ + + // Add missing items to the DOM. + var items = this.model.get('values'); + for (var index in items) { + var item_query = ' :contains("' + items[index] + '")'; + if (this.$buttongroup.find(item_query).length == 0) { + + var that = this; + $('