Show More
@@ -345,38 +345,6 b' define(["widgets/js/manager",' | |||||
345 | return null; |
|
345 | return null; | |
346 | }, |
|
346 | }, | |
347 |
|
347 | |||
348 | _do_diff: function(old_list, new_list, removed_callback, added_callback) { |
|
|||
349 | // Difference a changed list and call remove and add callbacks for |
|
|||
350 | // each removed and added item in the new list. |
|
|||
351 | // |
|
|||
352 | // Parameters |
|
|||
353 | // ---------- |
|
|||
354 | // old_list : array |
|
|||
355 | // new_list : array |
|
|||
356 | // removed_callback : Callback(item) |
|
|||
357 | // Callback that is called for each item removed. |
|
|||
358 | // added_callback : Callback(item) |
|
|||
359 | // Callback that is called for each item added. |
|
|||
360 |
|
||||
361 | // Walk the lists until an unequal entry is found. |
|
|||
362 | var i; |
|
|||
363 | for (i = 0; i < new_list.length; i++) { |
|
|||
364 | if (i >= old_list.length || new_list[i] !== old_list[i]) { |
|
|||
365 | break; |
|
|||
366 | } |
|
|||
367 | } |
|
|||
368 |
|
||||
369 | // Remove the non-matching items from the old list. |
|
|||
370 | for (var j = i; j < old_list.length; j++) { |
|
|||
371 | removed_callback(old_list[j]); |
|
|||
372 | } |
|
|||
373 |
|
||||
374 | // Add the rest of the new list items. |
|
|||
375 | for (; i < new_list.length; i++) { |
|
|||
376 | added_callback(new_list[i]); |
|
|||
377 | } |
|
|||
378 | }, |
|
|||
379 |
|
||||
380 | callbacks: function(){ |
|
348 | callbacks: function(){ | |
381 | // Create msg callbacks for a comm msg. |
|
349 | // Create msg callbacks for a comm msg. | |
382 | return this.model.callbacks(this); |
|
350 | return this.model.callbacks(this); | |
@@ -534,11 +502,8 b' define(["widgets/js/manager",' | |||||
534 | if ($el===undefined) { |
|
502 | if ($el===undefined) { | |
535 | $el = this.$el; |
|
503 | $el = this.$el; | |
536 | } |
|
504 | } | |
537 |
|
|
505 | _.difference(old_classes, new_classes).map(function(c) {$el.removeClass(c);}) | |
538 | $el.removeClass(removed); |
|
506 | _.difference(new_classes, old_classes).map(function(c) {$el.addClass(c);}) | |
539 | }, function(added) { |
|
|||
540 | $el.addClass(added); |
|
|||
541 | }); |
|
|||
542 | }, |
|
507 | }, | |
543 |
|
508 | |||
544 | update_mapped_classes: function(class_map, trait_name, previous_trait_value, $el) { |
|
509 | update_mapped_classes: function(class_map, trait_name, previous_trait_value, $el) { |
General Comments 0
You need to be logged in to leave comments.
Login now