##// 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 return Backbone.Model.apply(this);
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 send: function (content, cell) {
50 send: function (content, cell) {
@@ -507,6 +494,12 b' function(widget_manager, underscore, backbone){'
507 this.model.send(content, this.cell);
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 update: function () {
503 update: function () {
511 if (this.model.get('visible') !== undefined) {
504 if (this.model.get('visible') !== undefined) {
512 if (this.visible != this.model.get('visible')) {
505 if (this.visible != this.model.get('visible')) {
@@ -35,7 +35,7 b' define(["notebook/js/widgets/base"], function(widget_manager){'
35 .click(function(el) {
35 .click(function(el) {
36 that.user_invoked_update = true;
36 that.user_invoked_update = true;
37 that.model.set('value', that.$checkbox.prop('checked'));
37 that.model.set('value', that.$checkbox.prop('checked'));
38 that.model.update_other_views(that);
38 that.touch();
39 that.user_invoked_update = false;
39 that.user_invoked_update = false;
40 })
40 })
41 .appendTo(this.$el);
41 .appendTo(this.$el);
@@ -113,7 +113,7 b' define(["notebook/js/widgets/base"], function(widget_manager){'
113 handleClick: function(e) {
113 handleClick: function(e) {
114 this.user_invoked_update = true;
114 this.user_invoked_update = true;
115 this.model.set('value', ! $(e.target).hasClass('active'));
115 this.model.set('value', ! $(e.target).hasClass('active'));
116 this.model.update_other_views(this);
116 this.touch();
117 this.user_invoked_update = false;
117 this.user_invoked_update = false;
118 },
118 },
119 });
119 });
@@ -109,7 +109,7 b' define(["notebook/js/widgets/base"], function(widget_manager){'
109 events: { "slide" : "handleSliderChange" },
109 events: { "slide" : "handleSliderChange" },
110 handleSliderChange: function(e, ui) {
110 handleSliderChange: function(e, ui) {
111 this.model.set('value', ui.value);
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 if (numericalValue != this.model.get('value')) {
189 if (numericalValue != this.model.get('value')) {
190 this.changing = true;
190 this.changing = true;
191 this.model.set('value', numericalValue);
191 this.model.set('value', numericalValue);
192 this.model.update_other_views(this);
192 this.touch();
193 this.changing = false;
193 this.changing = false;
194 }
194 }
195 }
195 }
@@ -109,7 +109,7 b' define(["notebook/js/widgets/base"], function(widget_manager){'
109 events: { "slide" : "handleSliderChange" },
109 events: { "slide" : "handleSliderChange" },
110 handleSliderChange: function(e, ui) {
110 handleSliderChange: function(e, ui) {
111 this.model.set('value', ~~ui.value); // Double bit-wise not to truncate decimel
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 if (numericalValue != this.model.get('value')) {
188 if (numericalValue != this.model.get('value')) {
189 this.changing = true;
189 this.changing = true;
190 this.model.set('value', numericalValue);
190 this.model.set('value', numericalValue);
191 this.model.update_other_views(this);
191 this.touch();
192 this.changing = false;
192 this.changing = false;
193 }
193 }
194 }
194 }
@@ -76,7 +76,7 b' define(["notebook/js/widgets/base"], function(widget_manager){'
76 .attr('href', '#' + uuid)
76 .attr('href', '#' + uuid)
77 .click(function(evt){
77 .click(function(evt){
78 that.model.set("selected_index", index);
78 that.model.set("selected_index", index);
79 that.model.update_other_views(that);
79 that.touch();
80 })
80 })
81 .html('Page ' + index)
81 .html('Page ' + index)
82 .appendTo(accordion_heading);
82 .appendTo(accordion_heading);
@@ -151,7 +151,7 b' define(["notebook/js/widgets/base"], function(widget_manager){'
151 .appendTo(tab)
151 .appendTo(tab)
152 .click(function (e) {
152 .click(function (e) {
153 that.model.set("selected_index", index);
153 that.model.set("selected_index", index);
154 that.model.update_other_views(that);
154 that.touch();
155 that.select_page(index);
155 that.select_page(index);
156 });
156 });
157 this.containers.push(tab_text);
157 this.containers.push(tab_text);
@@ -103,7 +103,7 b' define(["notebook/js/widgets/base"], function(widget_manager){'
103 // Handle when a value is clicked.
103 // Handle when a value is clicked.
104 handle_click: function (e) {
104 handle_click: function (e) {
105 this.model.set('value', $(e.target).html(), this);
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 // Handle when a value is clicked.
190 // Handle when a value is clicked.
191 handle_click: function (e) {
191 handle_click: function (e) {
192 this.model.set('value', $(e.target).val(), this);
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 // Handle when a value is clicked.
272 // Handle when a value is clicked.
273 handle_click: function (e) {
273 handle_click: function (e) {
274 this.model.set('value', $(e.target).html(), this);
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 // Handle when a value is clicked.
351 // Handle when a value is clicked.
352 handle_click: function (e) {
352 handle_click: function (e) {
353 this.model.set('value', $(e.target).html(), this);
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 handleChanging: function(e) {
119 handleChanging: function(e) {
120 this.user_invoked_update = true;
120 this.user_invoked_update = true;
121 this.model.set('value', e.target.value);
121 this.model.set('value', e.target.value);
122 this.model.update_other_views(this);
122 this.touch();
123 this.user_invoked_update = false;
123 this.user_invoked_update = false;
124 },
124 },
125 });
125 });
@@ -173,7 +173,7 b' define(["notebook/js/widgets/base"], function(widget_manager){'
173 // Handles and validates user input.
173 // Handles and validates user input.
174 handleChanging: function(e) {
174 handleChanging: function(e) {
175 this.model.set('value', e.target.value);
175 this.model.set('value', e.target.value);
176 this.model.update_other_views(this);
176 this.touch();
177 },
177 },
178
178
179 // Handles text submition
179 // Handles text submition
General Comments 0
You need to be logged in to leave comments. Login now