Show More
@@ -113,7 +113,7 b' define(["notebook/js/widget"], function(widget_manager){' | |||
|
113 | 113 | // Handles: Backend -> Frontend Sync |
|
114 | 114 | // Frontent -> Frontend Sync |
|
115 | 115 | update : function(){ |
|
116 | if (!this.user_invoked_update) { | |
|
116 | if (this.$textbox.val() != this.model.get('value')) { | |
|
117 | 117 | this.$textbox.val(this.model.get('value')); |
|
118 | 118 | } |
|
119 | 119 | |
@@ -137,19 +137,15 b' define(["notebook/js/widget"], function(widget_manager){' | |||
|
137 | 137 | |
|
138 | 138 | // Handles and validates user input. |
|
139 | 139 | handleChanging: function(e) { |
|
140 | this.user_invoked_update = true; | |
|
141 | 140 | this.model.set('value', e.target.value); |
|
142 | 141 | this.model.update_other_views(this); |
|
143 | this.user_invoked_update = false; | |
|
144 | 142 | }, |
|
145 | 143 | |
|
146 | 144 | // Handles text submition |
|
147 | 145 | handleKeypress: function(e) { |
|
148 | 146 | if (e.keyCode == 13) { // Return key |
|
149 | this.user_invoked_update = true; | |
|
150 | 147 | this.model.set('submits', this.model.get('submits') + 1); |
|
151 | 148 | this.model.update_other_views(this); |
|
152 | this.user_invoked_update = false; | |
|
153 | 149 | } |
|
154 | 150 | }, |
|
155 | 151 | }); |
@@ -58,7 +58,7 b' class Widget(LoggingConfigurable):' | |||
|
58 | 58 | old._children.remove(self) |
|
59 | 59 | |
|
60 | 60 | # Private/protected declarations |
|
61 | _property_lock = False | |
|
61 | _property_lock = (None, None) # Last updated (key, value) from the front-end. Prevents echo. | |
|
62 | 62 | _css = Dict() # Internal CSS property dict |
|
63 | 63 | _add_class = List() # Used to add a js class to a DOM element (call#, selector, class_name) |
|
64 | 64 | _remove_class = List() # Used to remove a js class from a DOM element (call#, selector, class_name) |
@@ -153,20 +153,21 b' class Widget(LoggingConfigurable):' | |||
|
153 | 153 | |
|
154 | 154 | def _handle_recieve_state(self, sync_data): |
|
155 | 155 | """Called when a state is recieved from the frontend.""" |
|
156 | self._property_lock = True | |
|
157 | try: | |
|
158 | ||
|
159 | # Use _keys instead of keys - Don't get retrieve the css from the client side. | |
|
160 | for name in self._keys: | |
|
161 | if name in sync_data: | |
|
156 | # Use _keys instead of keys - Don't get retrieve the css from the client side. | |
|
157 | for name in self._keys: | |
|
158 | if name in sync_data: | |
|
159 | try: | |
|
160 | self._property_lock = (name, sync_data[name]) | |
|
162 | 161 | setattr(self, name, sync_data[name]) |
|
163 | finally: | |
|
164 |
self._property_lock = |
|
|
162 | finally: | |
|
163 | self._property_lock = (None, None) | |
|
165 | 164 | |
|
166 | 165 | |
|
167 | 166 | def _handle_property_changed(self, name, old, new): |
|
168 | 167 | """Called when a proeprty has been changed.""" |
|
169 | if not self._property_lock and self._comm is not None: | |
|
168 | # Make sure this isn't information that the front-end just sent us. | |
|
169 | if self._property_lock[0] != name and self._property_lock[1] != new \ | |
|
170 | and self._comm is not None: | |
|
170 | 171 | # TODO: Validate properties. |
|
171 | 172 | # Send new state to frontend |
|
172 | 173 | self.send_state(key=name) |
General Comments 0
You need to be logged in to leave comments.
Login now