##// END OF EJS Templates
Add a helper method that acts on the changes made to a list.
Jonathan Frederic -
Show More
@@ -224,6 +224,31 b' function(widget_manager, underscore, backbone){'
224 224 }, this);
225 225 },
226 226
227 do_diff: function(old_list, new_list, removed_callback, added_callback) {
228 // Difference a changed list and call remove and add callbacks for
229 // each removed and added item in the new list.
230 //
231 // Parameters
232 // ----------
233 // old_list : array
234 // new_list : array
235 // removed_callback : Callback(item)
236 // Callback that is called for each item removed.
237 // added_callback : Callback(item)
238 // Callback that is called for each item added.
239
240
241 // removed items
242 _.each(_.difference(old_list, new_list), function(item, index, list) {
243 removed_callback(item);
244 }, this);
245
246 // added items
247 _.each(_.difference(new_list, old_list), function(item, index, list) {
248 added_callback(item);
249 }, this);
250 }
251
227 252 callbacks: function(){
228 253 return this.widget_manager.callbacks(this);
229 254 },
General Comments 0
You need to be logged in to leave comments. Login now