##// END OF EJS Templates
Moved touch logic out of model into view....
Jonathan Frederic -
Show More
@@ -45,19 +45,6 b' function(widget_manager, underscore, backbone){'
45 45
46 46 return Backbone.Model.apply(this);
47 47 },
48
49
50 update_other_views: function (caller) {
51 this.last_modified_view = caller;
52 this.save(this.changedAttributes(), {patch: true});
53
54 for (var view_index in this.views) {
55 var view = this.views[view_index];
56 if (view !== caller) {
57 view.update();
58 }
59 }
60 },
61 48
62 49
63 50 send: function (content, cell) {
@@ -507,6 +494,12 b' function(widget_manager, underscore, backbone){'
507 494 this.model.send(content, this.cell);
508 495 },
509 496
497
498 touch: function () {
499 this.model.last_modified_view = this;
500 this.model.save(this.model.changedAttributes(), {patch: true});
501 },
502
510 503 update: function () {
511 504 if (this.model.get('visible') !== undefined) {
512 505 if (this.visible != this.model.get('visible')) {
@@ -35,7 +35,7 b' define(["notebook/js/widgets/base"], function(widget_manager){'
35 35 .click(function(el) {
36 36 that.user_invoked_update = true;
37 37 that.model.set('value', that.$checkbox.prop('checked'));
38 that.model.update_other_views(that);
38 that.touch();
39 39 that.user_invoked_update = false;
40 40 })
41 41 .appendTo(this.$el);
@@ -113,7 +113,7 b' define(["notebook/js/widgets/base"], function(widget_manager){'
113 113 handleClick: function(e) {
114 114 this.user_invoked_update = true;
115 115 this.model.set('value', ! $(e.target).hasClass('active'));
116 this.model.update_other_views(this);
116 this.touch();
117 117 this.user_invoked_update = false;
118 118 },
119 119 });
@@ -109,7 +109,7 b' define(["notebook/js/widgets/base"], function(widget_manager){'
109 109 events: { "slide" : "handleSliderChange" },
110 110 handleSliderChange: function(e, ui) {
111 111 this.model.set('value', ui.value);
112 this.model.update_other_views(this);
112 this.touch();
113 113 },
114 114 });
115 115
@@ -189,7 +189,7 b' define(["notebook/js/widgets/base"], function(widget_manager){'
189 189 if (numericalValue != this.model.get('value')) {
190 190 this.changing = true;
191 191 this.model.set('value', numericalValue);
192 this.model.update_other_views(this);
192 this.touch();
193 193 this.changing = false;
194 194 }
195 195 }
@@ -109,7 +109,7 b' define(["notebook/js/widgets/base"], function(widget_manager){'
109 109 events: { "slide" : "handleSliderChange" },
110 110 handleSliderChange: function(e, ui) {
111 111 this.model.set('value', ~~ui.value); // Double bit-wise not to truncate decimel
112 this.model.update_other_views(this);
112 this.touch();
113 113 },
114 114 });
115 115
@@ -188,7 +188,7 b' define(["notebook/js/widgets/base"], function(widget_manager){'
188 188 if (numericalValue != this.model.get('value')) {
189 189 this.changing = true;
190 190 this.model.set('value', numericalValue);
191 this.model.update_other_views(this);
191 this.touch();
192 192 this.changing = false;
193 193 }
194 194 }
@@ -76,7 +76,7 b' define(["notebook/js/widgets/base"], function(widget_manager){'
76 76 .attr('href', '#' + uuid)
77 77 .click(function(evt){
78 78 that.model.set("selected_index", index);
79 that.model.update_other_views(that);
79 that.touch();
80 80 })
81 81 .html('Page ' + index)
82 82 .appendTo(accordion_heading);
@@ -151,7 +151,7 b' define(["notebook/js/widgets/base"], function(widget_manager){'
151 151 .appendTo(tab)
152 152 .click(function (e) {
153 153 that.model.set("selected_index", index);
154 that.model.update_other_views(that);
154 that.touch();
155 155 that.select_page(index);
156 156 });
157 157 this.containers.push(tab_text);
@@ -103,7 +103,7 b' define(["notebook/js/widgets/base"], function(widget_manager){'
103 103 // Handle when a value is clicked.
104 104 handle_click: function (e) {
105 105 this.model.set('value', $(e.target).html(), this);
106 this.model.update_other_views(this);
106 this.touch();
107 107 },
108 108
109 109 });
@@ -190,7 +190,7 b' define(["notebook/js/widgets/base"], function(widget_manager){'
190 190 // Handle when a value is clicked.
191 191 handle_click: function (e) {
192 192 this.model.set('value', $(e.target).val(), this);
193 this.model.update_other_views(this);
193 this.touch();
194 194 },
195 195 });
196 196
@@ -272,7 +272,7 b' define(["notebook/js/widgets/base"], function(widget_manager){'
272 272 // Handle when a value is clicked.
273 273 handle_click: function (e) {
274 274 this.model.set('value', $(e.target).html(), this);
275 this.model.update_other_views(this);
275 this.touch();
276 276 },
277 277
278 278 });
@@ -351,7 +351,7 b' define(["notebook/js/widgets/base"], function(widget_manager){'
351 351 // Handle when a value is clicked.
352 352 handle_click: function (e) {
353 353 this.model.set('value', $(e.target).html(), this);
354 this.model.update_other_views(this);
354 this.touch();
355 355 },
356 356
357 357 });
@@ -119,7 +119,7 b' define(["notebook/js/widgets/base"], function(widget_manager){'
119 119 handleChanging: function(e) {
120 120 this.user_invoked_update = true;
121 121 this.model.set('value', e.target.value);
122 this.model.update_other_views(this);
122 this.touch();
123 123 this.user_invoked_update = false;
124 124 },
125 125 });
@@ -173,7 +173,7 b' define(["notebook/js/widgets/base"], function(widget_manager){'
173 173 // Handles and validates user input.
174 174 handleChanging: function(e) {
175 175 this.model.set('value', e.target.value);
176 this.model.update_other_views(this);
176 this.touch();
177 177 },
178 178
179 179 // Handles text submition
General Comments 0
You need to be logged in to leave comments. Login now