//----------------------------------------------------------------------------1// Copyright (C) 2013 The IPython Development Team2//3// Distributed under the terms of the BSD License. The full license is in4// the file COPYING, distributed as part of this software.5//----------------------------------------------------------------------------67//============================================================================8// ButtonWidget9//============================================================================1011/**12* @module IPython13* @namespace IPython14**/1516define(["widgets/js/widget"], function(WidgetManager){1718var ButtonView = IPython.DOMWidgetView.extend({19render : function(){20// Called when view is rendered.21this.setElement($("<button />")22.addClass('btn'));2324this.update(); // Set defaults.25},2627update : function(){28// Update the contents of this view29//30// Called when the model is changed. The model may have been31// changed by another view or by a state update from the back-end.32var description = this.model.get('description');33if (description.length === 0) {34this.$el.html(" "); // Preserve button height35} else {36this.$el.text(description);37}3839if (this.model.get('disabled')) {40this.$el.attr('disabled','disabled');41} else {42this.$el.removeAttr('disabled');43}4445return ButtonView.__super__.update.apply(this);46},4748events: {49// Dictionary of events and their handlers.50'click': '_handle_click',51},5253_handle_click: function(){54// Handles when the button is clicked.55this.send({event: 'click'});56},57});58WidgetManager.register_widget_view('ButtonView', ButtonView);59});606162