Show More
@@ -463,19 +463,11 b' define(["widgets/js/manager",' | |||
|
463 | 463 | |
|
464 | 464 | _get_selector_element: function (selector) { |
|
465 | 465 | // Get the elements via the css selector. |
|
466 | ||
|
467 | // If the selector is blank, apply the style to the $el_to_style | |
|
468 | // element. If the $el_to_style element is not defined, use apply | |
|
469 | // the style to the view's element. | |
|
470 | 466 | var elements; |
|
471 | 467 | if (!selector) { |
|
472 | if (this.$el_to_style === undefined) { | |
|
473 | elements = this.$el; | |
|
474 | } else { | |
|
475 | elements = this.$el_to_style; | |
|
476 | } | |
|
468 | elements = this.$el; | |
|
477 | 469 | } else { |
|
478 | elements = this.$el.find(selector); | |
|
470 | elements = this.$el.find(selector).addBack(selector); | |
|
479 | 471 | } |
|
480 | 472 | return elements; |
|
481 | 473 | }, |
@@ -21,7 +21,6 b' define([' | |||
|
21 | 21 | .appendTo(this.$el) |
|
22 | 22 | .click($.proxy(this.handle_click, this)); |
|
23 | 23 | |
|
24 | this.$el_to_style = this.$checkbox; // Set default element to style | |
|
25 | 24 | this.update(); // Set defaults. |
|
26 | 25 | }, |
|
27 | 26 |
@@ -152,7 +152,6 b' define([' | |||
|
152 | 152 | that.$body.outerHeight(that.$window.innerHeight() - that.$title_bar.outerHeight()); |
|
153 | 153 | }); |
|
154 | 154 | |
|
155 | this.$el_to_style = this.$body; | |
|
156 | 155 | this._shown_once = false; |
|
157 | 156 | this.popped_out = true; |
|
158 | 157 | |
@@ -264,7 +263,7 b' define([' | |||
|
264 | 263 | // "modal" - select the modal div |
|
265 | 264 | // "modal [selector]" - select element(s) within the modal div. |
|
266 | 265 | // "[selector]" - select elements within $el |
|
267 |
// "" - select the $el |
|
|
266 | // "" - select the $el | |
|
268 | 267 | if (selector.substring(0, 5) == 'modal') { |
|
269 | 268 | if (selector == 'modal') { |
|
270 | 269 | return this.$window; |
@@ -24,7 +24,6 b' define([' | |||
|
24 | 24 | this.$slider_container = $('<div />') |
|
25 | 25 | .addClass('widget-hslider') |
|
26 | 26 | .append(this.$slider); |
|
27 | this.$el_to_style = this.$slider_container; // Set default element to style | |
|
28 | 27 | this.$el.append(this.$slider_container); |
|
29 | 28 | |
|
30 | 29 | this.$readout = $('<div/>') |
@@ -158,7 +157,6 b' define([' | |||
|
158 | 157 | .addClass('form-control') |
|
159 | 158 | .addClass('widget-numeric-text') |
|
160 | 159 | .appendTo(this.$el); |
|
161 | this.$el_to_style = this.$textbox; // Set default element to style | |
|
162 | 160 | this.update(); // Set defaults. |
|
163 | 161 | }, |
|
164 | 162 | |
@@ -262,7 +260,6 b' define([' | |||
|
262 | 260 | .addClass('progress') |
|
263 | 261 | .addClass('widget-progress') |
|
264 | 262 | .appendTo(this.$el); |
|
265 | this.$el_to_style = this.$progress; // Set default element to style | |
|
266 | 263 | this.$bar = $('<div />') |
|
267 | 264 | .addClass('progress-bar') |
|
268 | 265 | .css('width', '50%') |
@@ -21,7 +21,6 b' define([' | |||
|
21 | 21 | .addClass('widget_item') |
|
22 | 22 | .addClass('btn-group') |
|
23 | 23 | .appendTo(this.$el); |
|
24 | this.$el_to_style = this.$buttongroup; // Set default element to style | |
|
25 | 24 | this.$droplabel = $('<button />') |
|
26 | 25 | .addClass('btn btn-default') |
|
27 | 26 | .addClass('widget-combo-btn') |
@@ -119,7 +118,6 b' define([' | |||
|
119 | 118 | this.$container = $('<div />') |
|
120 | 119 | .appendTo(this.$el) |
|
121 | 120 | .addClass('widget-radio-box'); |
|
122 | this.$el_to_style = this.$container; // Set default element to style | |
|
123 | 121 | this.update(); |
|
124 | 122 | }, |
|
125 | 123 | |
@@ -210,7 +208,6 b' define([' | |||
|
210 | 208 | .addClass('btn-group') |
|
211 | 209 | .attr('data-toggle', 'buttons-radio') |
|
212 | 210 | .appendTo(this.$el); |
|
213 | this.$el_to_style = this.$buttongroup; // Set default element to style | |
|
214 | 211 | this.update(); |
|
215 | 212 | }, |
|
216 | 213 | |
@@ -302,7 +299,6 b' define([' | |||
|
302 | 299 | .addClass('widget-listbox form-control') |
|
303 | 300 | .attr('size', 6) |
|
304 | 301 | .appendTo(this.$el); |
|
305 | this.$el_to_style = this.$listbox; // Set default element to style | |
|
306 | 302 | this.update(); |
|
307 | 303 | }, |
|
308 | 304 |
@@ -56,7 +56,6 b' define([' | |||
|
56 | 56 | .attr('rows', 5) |
|
57 | 57 | .addClass('widget-text form-control') |
|
58 | 58 | .appendTo(this.$el); |
|
59 | this.$el_to_style = this.$textbox; // Set default element to style | |
|
60 | 59 | this.update(); // Set defaults. |
|
61 | 60 | |
|
62 | 61 | this.model.on('msg:custom', $.proxy(this._handle_textarea_msg, this)); |
@@ -140,7 +139,6 b' define([' | |||
|
140 | 139 | .addClass('input') |
|
141 | 140 | .addClass('widget-text form-control') |
|
142 | 141 | .appendTo(this.$el); |
|
143 | this.$el_to_style = this.$textbox; // Set default element to style | |
|
144 | 142 | this.update(); // Set defaults. |
|
145 | 143 | this.model.on('change:placeholder', function(model, value, options) { |
|
146 | 144 | this.update_placeholder(value); |
@@ -149,7 +149,7 b' casper.notebook_test(function () {' | |||
|
149 | 149 | 'import time\n' + |
|
150 | 150 | 'textbox = widgets.TextWidget()\n' + |
|
151 | 151 | 'display(textbox)\n' + |
|
152 | 'textbox.add_class("my-throttle-textbox")\n' + | |
|
152 | 'textbox.add_class("my-throttle-textbox", selector="input")\n' + | |
|
153 | 153 | 'def handle_change(name, old, new):\n' + |
|
154 | 154 | ' display(len(new))\n' + |
|
155 | 155 | ' time.sleep(0.5)\n' + |
@@ -11,7 +11,7 b' casper.notebook_test(function () {' | |||
|
11 | 11 | float_text.index = this.append_cell( |
|
12 | 12 | 'float_widget = widgets.FloatTextWidget()\n' + |
|
13 | 13 | 'display(float_widget)\n' + |
|
14 | 'float_widget.add_class("my-second-float-text")\n' + | |
|
14 | 'float_widget.add_class("my-second-float-text", selector="input")\n' + | |
|
15 | 15 | 'print(float_widget.model_id)\n'); |
|
16 | 16 | this.execute_cell_then(float_text.index, function(index){ |
|
17 | 17 | float_text.model_id = this.get_output_cell(index).text.trim(); |
@@ -6,12 +6,12 b' casper.notebook_test(function () {' | |||
|
6 | 6 | 'print("Success")'); |
|
7 | 7 | this.execute_cell_then(index); |
|
8 | 8 | |
|
9 | var int_text = {} | |
|
9 | var int_text = {}; | |
|
10 | 10 | int_text.query = '.widget-area .widget-subarea .widget-hbox-single .my-second-int-text'; |
|
11 | 11 | int_text.index = this.append_cell( |
|
12 | 12 | 'int_widget = widgets.IntTextWidget()\n' + |
|
13 | 13 | 'display(int_widget)\n' + |
|
14 | 'int_widget.add_class("my-second-int-text")\n' + | |
|
14 | 'int_widget.add_class("my-second-int-text", selector="input")\n' + | |
|
15 | 15 | 'print(int_widget.model_id)\n'); |
|
16 | 16 | this.execute_cell_then(int_text.index, function(index){ |
|
17 | 17 | int_text.model_id = this.get_output_cell(index).text.trim(); |
@@ -69,7 +69,7 b' casper.notebook_test(function () {' | |||
|
69 | 69 | 'intrange = [widgets.BoundedIntTextWidget(),\n' + |
|
70 | 70 | ' widgets.IntSliderWidget()]\n' + |
|
71 | 71 | '[display(intrange[i]) for i in range(2)]\n' + |
|
72 | 'intrange[0].add_class("my-second-num-test-text")\n' + | |
|
72 | 'intrange[0].add_class("my-second-num-test-text", selector="input")\n' + | |
|
73 | 73 | 'print(intrange[0].model_id)\n'); |
|
74 | 74 | this.execute_cell_then(int_text2.index, function(index){ |
|
75 | 75 | int_text2.model_id = this.get_output_cell(index).text.trim(); |
@@ -388,10 +388,7 b' class DOMWidget(Widget):' | |||
|
388 | 388 | selector: unicode (optional, kwarg only) |
|
389 | 389 | JQuery selector to use to apply the CSS key/value. If no selector |
|
390 | 390 | is provided, an empty selector is used. An empty selector makes the |
|
391 |
front-end try to apply the css to |
|
|
392 | element is an attribute unique to each view, which is a DOM element | |
|
393 | of the view that should be styled with common CSS (see | |
|
394 | `$el_to_style` in the Javascript code). | |
|
391 | front-end try to apply the css to the top-level element. | |
|
395 | 392 | """ |
|
396 | 393 | if value is None: |
|
397 | 394 | css_dict = dict_or_key |
General Comments 0
You need to be logged in to leave comments.
Login now