class Tawork.Views.CompareView extends Backbone.View events: "click .change-item": "scroll_to_change" initialize: (options = {}) -> $('.nav.nav-pills li a').click (e) -> e.preventDefault() $(this).tab('show') @setup_change_list() setup_change_list: -> $changes = $("[changeid][id]") console.log $changes change_ids = [] $changes.each (index, change) -> $change = $(change) $li = $("
", class: "page-list-item") id = $change.attr("id") if id.indexOf("added") != -1 name = "Added" else name = "Removed" $link = $("", href: "#", class: "change-item").html(name).attr("data-id", $change.attr("id")) $li.append $link $(".compare-change-list").append($li) scroll_to_change: (event) -> $diff_link = @$("a[href='#version-diff']") if !$diff_link.closest("li").hasClass("active") $diff_link.click() $link = $(event.target).closest("a") $change = $("#" + $link.attr("data-id")) $changes = $("[changeid=" + $link.attr("data-id") + "], [changeid=" + $link.attr("data-id") + "] img") $(document).scrollTo $change, 100, offset: -75, onAfter: -> $changes.effect("highlight") false